@piagent/platform 1.42.1 → 1.43.4
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.
- package/CHANGELOG.md +70 -0
- package/docs/adaptive-delivery.md +56 -0
- package/docs/command-reference-vietnamese.md +2 -2
- package/docs/distribution-standard.md +6 -6
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/publishing-for-teams.md +5 -0
- package/docs/release-install-policy.md +2 -2
- package/docs/team-onboarding.md +2 -2
- package/docs-site/architecture.html +1 -1
- package/docs-site/assets/search-en.json +1 -1
- package/docs-site/assets/search-vi.json +1 -1
- package/docs-site/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/context-engine.html +1 -1
- package/docs-site/ecosystem.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +1 -1
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/ecosystem.html +1 -1
- package/docs-site/en/index.html +9 -9
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +1 -1
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/update.html +3 -3
- package/docs-site/en/whats-new.html +123 -69
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +9 -9
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/releases.json +165 -0
- package/docs-site/runtime.html +1 -1
- package/docs-site/scope.html +1 -1
- package/docs-site/security.html +1 -1
- package/docs-site/team.html +1 -1
- package/docs-site/update.html +3 -3
- package/docs-site/whats-new.html +123 -69
- package/docs-site/windows.html +1 -1
- package/docs-site/workflows.html +1 -1
- package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
- package/package.json +1 -1
- package/packages/piagent-core/managed/delivery-context.mjs +126 -0
- package/packages/piagent-core/managed/helper-run.mjs +2 -1
- package/packages/piagent-core/managed/patch-snapshot.mjs +7 -3
- package/packages/piagent-core/managed/review-snapshot-worker.mjs +53 -7
- package/packages/piagent-core/managed/session.mjs +7 -7
- package/packages/piagent-core/managed/workflow-context.mjs +117 -0
- package/packages/piagent-core/managed/workflow.mjs +22 -4
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-webui/dist/client/assets/{App-JMuP_9-r.js → App-CarM9drO.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/GatewayApp-uqpLU6gs.js +93 -0
- package/packages/piagent-webui/dist/client/assets/{InspectionApp-DtDc9NxN.js → InspectionApp-C00GhY47.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-DLwK12hX.js → SessionAgentWorkspace-CBbWJmh7.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-CsPNI6aU.js → SessionInspectorDrawer-CMgkZoNX.js} +2 -2
- package/packages/piagent-webui/dist/client/assets/{TerminalPanel-A78JVp4e.js → TerminalPanel-DNKKZsMX.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-DPOp-ZoD.js → WorkspaceCodeEditor-DUffKV2S.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-H8Ogln3d.js → WorkspaceExplorer-D5iHXMqE.js} +3 -3
- package/packages/piagent-webui/dist/client/assets/{index-qi6mjvTy.js → index-D6GtlEqC.js} +2 -2
- package/packages/piagent-webui/dist/client/index.html +1 -1
- package/packages/piagent-webui/dist/client/assets/GatewayApp-awcOLVTi.js +0 -93
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-CR4TO5f1.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-CA5pzJiI.js","assets/ui-preferences-Dy4qeODT.js","assets/terminal-transport-Dk5pYNX5.js","assets/bootstrap-CedkNtRG.js","assets/TerminalView-kHJ-D0s7.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Dn as n,Ht as r,In as i,It as a,Lt as o,Rt as s,Ut as c,Vt as l,t as u,zt as d}from"./vendor-CA5pzJiI.js";import{i as f,n as p}from"./ui-preferences-Dy4qeODT.js";import{t as m}from"./index-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Dn as n,Ht as r,In as i,It as a,Lt as o,Rt as s,Ut as c,Vt as l,t as u,zt as d}from"./vendor-CA5pzJiI.js";import{i as f,n as p}from"./ui-preferences-Dy4qeODT.js";import{t as m}from"./index-D6GtlEqC.js";import{t as h}from"./terminal-transport-Dk5pYNX5.js";import{t as g}from"./tab-close-DHDqCxTL.js";var _=e(i(),1);function v(e){return Array.isArray(e)?`[${e.map(v).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${v(t)}`).join(`,`)}}`:JSON.stringify(e)}async function y(e,t){let n=Date.now(),r=`terminal.command`,i={...e.identity},a={...e.revisions},o=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(v({action:r,identity:i,expectedRevisions:a,payload:t})));return{schemaVersion:1,version:`piagent-terminal-v1`,messageType:`command`,action:r,identity:i,expectedRevisions:a,payload:t,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(n).toISOString(),expiresAt:new Date(n+6e4).toISOString(),actionDigest:`sha256:${[...new Uint8Array(o)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}}var b=e=>e.phase===`rejected`&&e.reasonCode===`terminal-stale-revision`,x=class{#e;#t=new Set;#n;sessionRef;#r=null;#i=null;#a=Promise.resolve();#o=0;#s=0;#c=0;#l=null;constructor(e,t=h){this.sessionRef=e,this.#n=t,this.#e={state:null,connected:t.ready,error:null,pending:null,busy:!1}}snapshot=()=>this.#e;get disposable(){return!this.#t.size&&!this.#s&&!this.#e.pending&&!this.#e.busy}#u(e){this.#e={...this.#e,...e};for(let e of this.#t)e()}subscribe=e=>(this.#t.add(e),this.#r||(this.#r=this.#n.subscribe(e=>{e.messageType===`state`&&e.identity.sessionRef===this.sessionRef&&this.#u({state:e})}),this.#i=this.#n.connection(e=>{e||this.#o++,this.#u({connected:e}),e&&this.refresh()}),this.#u({connected:this.#n.ready}),this.#n.ready&&this.refresh()),()=>{this.#t.delete(e),this.#t.size||(this.#r?.(),this.#i?.(),this.#r=null,this.#i=null)});refresh=()=>(this.#l||=this.#n.state(this.sessionRef).then(e=>this.#u({state:e}),e=>{this.#u({error:e instanceof Error?e.message:`terminal-unavailable`})}).finally(()=>{this.#l=null}),this.#l);error=e=>this.#u({error:e});acknowledge=()=>{this.#e.busy||(this.#o++,this.#u({pending:null,error:null}))};async#d(e){this.#u({pending:e});let t=await this.#n.execute(e),n=this.#e.state;return n&&n.identity.runtimeInstanceRef===t.identity.runtimeInstanceRef&&n.identity.gatewayInstanceRef===t.identity.gatewayInstanceRef&&this.#u({state:{...n,revisions:t.observedRevisions}}),t.phase!==`settled`&&!b(t)&&this.#o++,t.phase===`uncertain`?(this.#u({error:t.reasonCode??`terminal-effect-uncertain`}),t):(this.#u({pending:null,error:t.phase===`rejected`?t.reasonCode??`terminal-command-rejected`:null}),t)}execute(e){let t=e.kind===`input`?new TextEncoder().encode(e.data).length:0;if(t>16384||this.#c+t>65536||this.#s>=64)return this.error(`terminal-input-limit`),Promise.resolve();if(!this.#e.connected||this.#e.pending&&!this.#e.busy)return this.error(`terminal-command-unconfirmed`),Promise.resolve();let n=this.#o;this.#c+=t,this.#s++;let r=this.#a.then(async()=>{if(n!==this.#o||this.#e.pending||!this.#e.connected)return;let t=this.#e.state;if(t?.available){if(e.kind===`resize`){let n=t.terminals.find(t=>t.terminalRef===e.terminalRef);if(!n||n.cols===e.cols&&n.rows===e.rows)return}this.#u({busy:!0});try{if(b(await this.#d(await y(t,e)))){await this.refresh();let t=this.#e.state;t?.available&&(this.#u({error:null}),await this.#d(await y(t,e)))}}catch(e){this.#o++,this.error(e instanceof Error?e.message:`terminal-effect-uncertain`)}finally{this.#u({busy:!1})}}}).finally(()=>{this.#c-=t,this.#s--});return this.#a=r.catch(()=>{}),r}retry=async()=>{let e=this.#e.pending;if(!(!e||this.#e.busy||!this.#e.connected)){this.#u({busy:!0});try{await this.#d(e)}catch(e){this.#o++,this.error(e instanceof Error?e.message:`terminal-effect-uncertain`)}finally{this.#u({busy:!1})}}}},S=new Map;function C(e){let t=S.get(e);if(!t){if(S.size>=64){let e=[...S].find(([,e])=>e.disposable);if(!e)throw Error(`terminal-client-capacity`);S.delete(e[0])}t=new x(e),S.set(e,t)}return t}var w=n(),T=(0,_.lazy)(()=>m(()=>import(`./TerminalView-CR4TO5f1.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function E({sessionRef:e,onHide:n}){let{locale:i}=f(),m=(0,_.useMemo)(()=>C(e),[e]),h=(0,_.useSyncExternalStore)(m.subscribe,m.snapshot),v=h.state,[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(280),E=(0,_.useRef)(null),D=v?.terminals.find(e=>e.terminalRef===y)?.terminalRef??v?.terminals[0]?.terminalRef??null,O=!h.connected||!v?.available||!!(h.pending&&!h.busy);return(0,w.jsxs)(t,{component:`section`,"aria-label":p(i,`Terminal`,`Terminal`),sx:{borderTop:1,borderColor:`divider`,minWidth:0},children:[(0,w.jsx)(t,{role:`separator`,tabIndex:0,"aria-label":p(i,`Chiều cao terminal`,`Terminal height`),"aria-orientation":`horizontal`,"aria-valuenow":x,"aria-valuemin":160,"aria-valuemax":700,onKeyDown:e=>{[`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),S(t=>Math.max(160,Math.min(700,t+(e.key===`ArrowUp`?20:-20)))))},onPointerDown:e=>{E.current={y:e.clientY,height:x},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{E.current&&S(Math.max(160,Math.min(700,E.current.height+E.current.y-e.clientY)))},onPointerUp:()=>{E.current=null},onPointerCancel:()=>{E.current=null},sx:{height:8,cursor:`row-resize`,touchAction:`none`,bgcolor:`action.hover`}}),(0,w.jsxs)(t,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,w.jsx)(o,{value:D??!1,onChange:(e,t)=>b(t),variant:`scrollable`,sx:{flex:1,minWidth:0},children:v?.terminals.map(e=>(0,w.jsx)(s,{value:e.terminalRef,"aria-label":`Terminal ${e.number}${e.state===`exited`?p(i,` · đã thoát`,` · exited`):``}`,label:g(`Terminal ${e.number}${e.state===`exited`?p(i,` · đã thoát`,` · exited`):``}`,p(i,`Đóng Terminal ${e.number}`,`Close Terminal ${e.number}`),()=>{h.busy||m.execute({kind:`close`,terminalRef:e.terminalRef})})},e.terminalRef))}),(0,w.jsx)(d,{disabled:O||h.busy||(v?.terminals.length??0)>=4,"aria-label":p(i,`Mở terminal`,`Open terminal`),onClick:()=>void m.execute({kind:`open`,cols:80,rows:24}),children:`+`}),D&&(0,w.jsx)(d,{disabled:O||h.busy,onClick:()=>void m.execute({kind:`close`,terminalRef:D}),children:p(i,`Đóng terminal`,`Close terminal`)}),n&&(0,w.jsx)(r,{size:`small`,"aria-label":p(i,`Ẩn khung terminal`,`Hide terminal panel`),title:p(i,`Ẩn khung terminal (terminal vẫn chạy)`,`Hide terminal panel (terminals keep running)`),onClick:n,children:(0,w.jsx)(u,{fontSize:`small`})})]}),!h.connected&&(0,w.jsx)(l,{severity:`info`,children:p(i,`Đang nối lại terminal…`,`Reconnecting terminal…`)}),v&&!v.available&&(0,w.jsx)(l,{severity:`info`,children:v.reasonCode===`managed-terminal-seatbelt-unavailable`?p(i,`Sandbox hiện tại trên macOS không hỗ trợ terminal công ty.`,`The current macOS sandbox does not support company terminals.`):v.reasonCode===`company-terminal-disconnected`?p(i,`Mất kết nối với terminal công ty. Đang kết nối lại…`,`Company terminal disconnected. Reconnecting…`):(0,w.jsxs)(w.Fragment,{children:[p(i,`Terminal chưa khả dụng trên môi trường này.`,`Terminal is unavailable in this environment.`),` `,v.reasonCode]})}),h.error&&(0,w.jsxs)(l,{severity:`warning`,children:[p(i,`Thao tác terminal chưa hoàn tất.`,`The terminal action did not complete.`),` `,h.error,h.pending?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(a,{variant:`body2`,children:p(i,`Kiểm tra output trước khi tiếp tục. Lệnh có thể đã chạy.`,`Check the output before continuing. The command may have run.`)}),(0,w.jsx)(d,{disabled:h.busy||!h.connected,onClick:()=>void m.retry(),children:p(i,`Kiểm tra lại lệnh`,`Check command again`)}),(0,w.jsx)(d,{disabled:h.busy,onClick:m.acknowledge,children:p(i,`Đã kiểm tra, tiếp tục`,`Checked, continue`)})]}):(0,w.jsx)(d,{onClick:()=>void m.refresh(),children:p(i,`Tải lại`,`Refresh`)})]}),!v&&!h.error&&(0,w.jsx)(c,{size:24}),v?.available&&!v.terminals.length&&(0,w.jsx)(a,{sx:{p:2},children:p(i,`Nhấn + để mở terminal trong project.`,`Press + to open a terminal in the project.`)}),(0,w.jsx)(a,{variant:`caption`,sx:{px:1},children:p(i,`Gõ @terminal hoặc @terminal:2 trong tin nhắn để đính output đã che secret khi gửi.`,`Use @terminal or @terminal:2 in your message to attach redacted output when you send.`)}),(0,w.jsx)(t,{sx:{height:x,minWidth:0},children:(0,w.jsx)(_.Suspense,{fallback:(0,w.jsx)(c,{size:24}),children:v?.terminals.map(e=>(0,w.jsx)(T,{identity:v.identity,terminalRef:e.terminalRef,active:D===e.terminalRef,onReady:()=>void m.refresh(),onError:m.error,onInput:t=>{!O&&e.state===`running`&&m.execute({kind:`input`,terminalRef:e.terminalRef,data:t})},onResize:(t,n)=>{!O&&e.state===`running`&&m.execute({kind:`resize`,terminalRef:e.terminalRef,cols:t,rows:n})}},`${v.identity.runtimeInstanceRef}:${e.terminalRef}`))})})]})}export{E as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-C2TMLUTo.js","assets/rolldown-runtime-hePW80VL.js","assets/dist-D6i5SpQu.js","assets/dist-IRUjhd1P.js","assets/dist-sNhoSseW.js","assets/dist-BM_LL1o9.js","assets/dist-DfjUS8LS.js","assets/dist-CqL3udNu.js","assets/dist-D4df0jLQ.js","assets/dist-B5MCHZv5.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Dn as n,In as r,ln as i,yn as a,zt as o}from"./vendor-CA5pzJiI.js";import{i as s,n as c,r as l}from"./ui-preferences-Dy4qeODT.js";import{t as u}from"./index-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Dn as n,In as r,ln as i,yn as a,zt as o}from"./vendor-CA5pzJiI.js";import{i as s,n as c,r as l}from"./ui-preferences-Dy4qeODT.js";import{t as u}from"./index-D6GtlEqC.js";import{C as d,D as f,E as p,G as m,N as h,O as g,S as _,T as v,j as y,k as b,t as x,w as S,x as C,y as w,z as T}from"./dist-D6i5SpQu.js";var E=class extends S{lines;label;comment;constructor(e,t,n){super(),this.lines=e,this.label=t,this.comment=n}toDOM(){let e=document.createElement(`div`);e.className=`cm-agent-deleted`;for(let t of this.lines){let n=document.createElement(`div`),r=document.createElement(`span`);if(r.textContent=`− ${t.text}`,n.append(r),this.comment){let e=document.createElement(`button`);e.type=`button`,e.textContent=this.label,e.setAttribute(`aria-label`,`${this.label} ${t.line}`),e.addEventListener(`click`,()=>this.comment?.(t.line,t.text,`old`)),n.append(e)}e.append(n)}return e}},D=class extends S{ref;label;keep;revertLabel;revert;constructor(e,t,n,r,i){super(),this.ref=e,this.label=t,this.keep=n,this.revertLabel=r,this.revert=i}toDOM(){let e=document.createElement(`div`);e.className=`cm-agent-actions`;let t=document.createElement(`button`);if(t.type=`button`,t.textContent=this.label,t.addEventListener(`click`,()=>this.keep(this.ref)),e.append(t),this.revert){let t=document.createElement(`button`);t.type=`button`,t.textContent=this.revertLabel,t.addEventListener(`click`,()=>this.revert?.(this.ref)),e.append(t)}return e}},O=new class extends d{toDOM(){let e=document.createElement(`span`);return e.textContent=`▎`,e.className=`cm-agent-marker`,e}};function k(e,t,n,r,i,a,o=``,s){let c=e.state.doc.toString(),l=[],u=[],d=t=>e.state.doc.line(Math.max(1,Math.min(e.state.doc.lines,t))).from;for(let e of t){let t=d(e.newStart+ +(e.newLineCount===0));u.push(t),l.push(C.widget({widget:new D(e.hunkRef,n,r,i,a),block:!0,side:-1}).range(t));let c=e.newStart+ +(e.newLineCount===0),f=[],p=()=>{f.length&&(l.push(C.widget({widget:new E(f,o,s),block:!0,side:-1}).range(d(c))),f=[])};for(let t of e.lines){if(t.kind===`deleted`){t.oldLineNumber!==null&&f.push({line:t.oldLineNumber,text:t.text});continue}p(),t.newLineNumber!==null&&(c=t.newLineNumber+1,t.kind===`added`&&l.push(C.line({class:`cm-agent-added`}).range(d(t.newLineNumber))))}p()}let f=T.define({create:()=>C.set(l,!0),update:(e,t)=>t.docChanged?C.none:e,provide:e=>_.decorations.from(e)}),p=e=>t=>{if(!u.length||t.state.doc.toString()!==c)return!1;let n=t.state.selection.main.head,r=e>0?u.find(e=>e>n)??u[0]:[...u].reverse().find(e=>e<n)??u.at(-1);return t.dispatch({selection:{anchor:r},effects:_.scrollIntoView(r,{y:`center`})}),!0};return[f,t.length?v({class:`cm-agent-gutter`,lineMarker:(e,t)=>e.state.field(f).size&&u.includes(t.from)?O:null}):[],g.of([{key:`Alt-ArrowDown`,run:p(1)},{key:`Alt-ArrowUp`,run:p(-1)}]),_.theme({".cm-agent-added":{backgroundColor:`color-mix(in srgb, #2e9d55 15%, transparent)`},".cm-agent-deleted":{margin:`0`,padding:`2px 8px`,whiteSpace:`pre-wrap`,backgroundColor:`color-mix(in srgb, #df4545 15%, transparent)`,fontFamily:`monospace`},".cm-agent-marker":{color:`#2e9d55`},".cm-agent-actions":{padding:`2px 8px`},".cm-agent-actions button":{color:`inherit`,background:`transparent`,border:`1px solid currentColor`,borderRadius:`4px`,cursor:`pointer`}})]}var A=e(r(),1),j=n();function M({syntax:e}){return x.define([{tag:[m.keyword,m.controlKeyword,m.moduleKeyword,m.definitionKeyword,m.modifier,m.self,m.null,m.bool,m.atom],color:e.keyword},{tag:[m.string,m.special(m.string),m.regexp,m.character],color:e.string},{tag:[m.number,m.integer,m.float,m.unit],color:e.number},{tag:[m.comment,m.lineComment,m.blockComment,m.docComment,m.meta],color:e.comment,fontStyle:`italic`},{tag:[m.function(m.variableName),m.function(m.propertyName),m.macroName],color:e.function},{tag:[m.typeName,m.className,m.namespace,m.tagName,m.standard(m.tagName)],color:e.type},{tag:[m.propertyName,m.attributeName,m.labelName],color:e.property},{tag:[m.operator,m.punctuation,m.bracket,m.derefOperator],color:e.operator},{tag:[m.heading,m.heading1,m.heading2,m.heading3],color:e.heading,fontWeight:`600`},{tag:[m.link,m.url],color:e.link,textDecoration:`underline`},{tag:m.emphasis,fontStyle:`italic`},{tag:m.strong,fontWeight:`600`},{tag:m.invalid,color:e.keyword,textDecoration:`underline wavy`}])}async function N(e){let t=e.split(`.`).at(-1)?.toLowerCase();switch(t){case`js`:case`mjs`:case`cjs`:case`jsx`:case`ts`:case`tsx`:return(await u(async()=>{let{javascript:e}=await import(`./dist-C2TMLUTo.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3,4]))).javascript({typescript:t===`ts`||t===`tsx`,jsx:t===`jsx`||t===`tsx`});case`json`:return(await u(async()=>{let{json:e}=await import(`./dist-BM_LL1o9.js`);return{json:e}},__vite__mapDeps([5,2,3]))).json();case`md`:return(await u(async()=>{let{markdown:e}=await import(`./dist-DfjUS8LS.js`);return{markdown:e}},__vite__mapDeps([6,2,4,7,3,8,1,0]))).markdown();case`py`:return(await u(async()=>{let{python:e}=await import(`./dist-B5MCHZv5.js`);return{python:e}},__vite__mapDeps([9,2,3,4]))).python();case`html`:return(await u(async()=>{let{html:e}=await import(`./dist-CqL3udNu.js`);return{html:e}},__vite__mapDeps([7,2,3,8,1,0,4]))).html();case`css`:return(await u(async()=>{let{css:e}=await import(`./dist-D4df0jLQ.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([8,1,2,3]))).css();default:return[]}}var P=[],F=e=>{};function I({content:e,path:n,line:r=1,readOnly:u=!0,onChange:d,onSave:m,hunks:v=P,onKeep:x=F,onRevert:S,onComment:C}){let T=(0,A.useRef)(null),E=(0,A.useRef)(null),D=i(),O=(0,A.useRef)({onChange:d,onSave:m,onComment:C});O.current={onChange:d,onSave:m,onComment:C};let I=(0,A.useRef)(e);I.current=e;let L=(0,A.useRef)(new y),R=(0,A.useRef)(new y),{locale:z}=s(),B=l();return(0,A.useEffect)(()=>{if(!T.current)return;let e=document.querySelector(`meta[name="csp-nonce"]`)?.content,t=new y,r=!1,i=new _({parent:T.current,state:h.create({doc:I.current,extensions:[R.current.of([]),_.cspNonce.of(e??``),L.current.of([h.readOnly.of(u),_.editable.of(!u)]),g.of([{key:`Mod-Shift-m`,run:e=>{let t=e.state.doc.lineAt(e.state.selection.main.head);return O.current.onComment?.(t.number,t.text),!!O.current.onComment}}]),g.of([`Ctrl-s`,`Meta-s`].map(e=>({key:e,run:()=>(O.current.onSave?.(),!0)}))),_.updateListener.of(e=>{e.docChanged&&O.current.onChange?.(e.state.doc.toString())}),b(),p(),f(),w(M(B)),t.of([]),_.contentAttributes.of({"aria-label":n,tabindex:`0`}),_.theme({"&":{height:`100%`,color:D.palette.text.primary,backgroundColor:D.palette.background.paper},".cm-scroller":{overflow:`auto`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:`13px`,lineHeight:1.55},".cm-content":{caretColor:D.palette.primary.main},".cm-cursor, .cm-dropCursor":{borderLeftColor:D.palette.primary.main},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:a(D.palette.primary.main,.25)},".cm-activeLine":{backgroundColor:a(D.palette.text.primary,.04)},".cm-gutters":{backgroundColor:D.palette.background.paper,color:D.palette.text.secondary,borderRight:`1px solid ${D.palette.divider}`},".cm-activeLineGutter":{backgroundColor:a(D.palette.text.primary,.06),color:D.palette.text.primary}},{dark:D.palette.mode===`dark`})]})});return E.current=i,N(n).then(e=>{r||i.dispatch({effects:t.reconfigure(e)})}).catch(()=>{}),()=>{r=!0,E.current=null,i.destroy()}},[n,D]),(0,A.useEffect)(()=>{let t=E.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e,n,D]),(0,A.useEffect)(()=>{let e=E.current;e&&e.dispatch({effects:R.current.reconfigure(k(e,v,c(z,`Giữ`,`Keep`),x,c(z,`Hoàn tác`,`Revert`),S,c(z,`Comment dòng đã xóa`,`Comment on removed line`),C))})},[v,x,S,C,e,n,D,z]),(0,A.useEffect)(()=>{E.current?.dispatch({effects:L.current.reconfigure([h.readOnly.of(u),_.editable.of(!u)])})},[u,n,D]),(0,A.useEffect)(()=>{let e=E.current;if(!e)return;let t=e.state.doc.line(Math.max(1,Math.min(e.state.doc.lines,r))).from;e.dispatch({selection:{anchor:t},effects:_.scrollIntoView(t,{y:`center`})})},[r,n,D]),(0,j.jsxs)(t,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[C&&(0,j.jsx)(o,{size:`small`,onClick:()=>{let e=E.current;if(!e)return;let t=e.state.doc.lineAt(e.state.selection.main.head);C(t.number,t.text)},children:c(z,`Comment dòng hiện tại`,`Comment on current line`)}),(0,j.jsx)(t,{ref:T,sx:{flex:1,minHeight:240,overflow:`hidden`}})]})}export{I as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceCodeEditor-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ct as n,Dn as r,Fn as i,G as a,Ht as o,In as s,It as c,L as l,Lt as u,Pt as d,Rt as f,St as p,U as m,Ut as h,Vt as g,W as _,_t as v,qt as y,t as ee,zt as b}from"./vendor-CA5pzJiI.js";import{i as x,n as S}from"./ui-preferences-Dy4qeODT.js";import{t as C}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceCodeEditor-DUffKV2S.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-CA5pzJiI.js","assets/ui-preferences-Dy4qeODT.js","assets/index-D6GtlEqC.js","assets/index-Dqb2hNan.css","assets/dist-D6i5SpQu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{Bt as t,Ct as n,Dn as r,Fn as i,G as a,Ht as o,In as s,It as c,L as l,Lt as u,Pt as d,Rt as f,St as p,U as m,Ut as h,Vt as g,W as _,_t as v,qt as y,t as ee,zt as b}from"./vendor-CA5pzJiI.js";import{i as x,n as S}from"./ui-preferences-Dy4qeODT.js";import{t as C}from"./index-D6GtlEqC.js";import{i as w,n as T,o as E}from"./bootstrap-CedkNtRG.js";import{W as D,ct as te}from"./api-BUjrtT1B.js";import{a as O}from"./workspace-navigation-C8GtShbg.js";import{r as k}from"./composer-drafts-BtMaVw8W.js";import{a as A,c as j,d as M,f as N,i as P,l as F,o as I,s as L,t as ne,u as re}from"./LineReview-DZ9ez8kO.js";import{t as ie}from"./tab-close-DHDqCxTL.js";import{i as ae,r as R,t as z}from"./workspace-api-O7auv_td.js";var B=e(s(),1),V=r();function oe(e,t,r,i=[]){let{locale:a}=x(),[o,s]=(0,B.useState)(()=>j(e)),[c,l]=(0,B.useState)();(0,B.useEffect)(()=>{s(j(e)),l(void 0);let t=t=>{t.detail===e&&s(j(e))};return window.addEventListener(I,t),()=>window.removeEventListener(I,t)},[e]),(0,B.useEffect)(()=>l(void 0),[t]);let u=t=>{s(t),M(e,t)},d={locale:a,comments:o,editing:c?L(c.path,c.side,c.line):null,open:(e,t,n,r)=>l({path:e,line:n,code:r,side:t}),cancel:()=>l(void 0),save:t=>{c&&u(re(j(e),{...c,text:t})),l(void 0)},remove:t=>u(j(e).filter(e=>L(e.path,e.side,e.line)!==t))},f=new Map(r.split(`
|
|
3
3
|
`).map((e,n)=>[L(t??``,`new`,n+1),e.slice(0,400)]));for(let e of i)for(let n of e.lines)n.oldLineNumber!==null&&f.set(L(t??``,`old`,n.oldLineNumber),n.text.slice(0,400));return{open:(e,n,r=`new`)=>{t&&l({path:t,line:e,code:n,side:r})},dialog:(0,V.jsxs)(n,{open:!!c,onClose:()=>l(void 0),fullWidth:!0,children:[(0,V.jsxs)(m,{children:[S(a,`Comment theo dòng`,`Line comment`),` · `,c?.path,`:`,c?.line]}),(0,V.jsx)(_,{children:(0,V.jsx)(A.Provider,{value:d,children:c&&(0,V.jsx)(P,{path:c.path,side:c.side,line:c.line})})})]}),bar:(0,V.jsx)(ne,{comments:o,lines:f,linesPath:t,locale:a,onClear:()=>u([]),onSend:()=>{let t=j(e);t.length&&k(e,F(t,a===`en`)),u([])}})}}var H=new Map;function se(e,r,i,o,s){let{locale:l}=x(),u=`${e}\0${r??``}`,d=`${u}\0${i}\0${o}`,f=(0,B.useRef)(d);f.current=d;let p=(0,B.useRef)(u);p.current=u;let h=(0,B.useRef)(!1),[v,y]=(0,B.useState)(!1),[ee,C]=(0,B.useState)(!1),[w,T]=(0,B.useState)(),[E,O]=(0,B.useState)(),[k,A]=(0,B.useState)(!1);(0,B.useEffect)(()=>{C(!1),T(void 0),O(void 0),A(H.has(u))},[u]);let j=async t=>{if(!(h.current||!o||!s||s.file.path!==r||s.file.currentDigest!==`sha256:${i}`)&&(C(!0),O(void 0),T(void 0),A(H.has(u)),!H.has(u))){h.current=!0,y(!0);try{let n=await D(e,s.file.fileRef,t);if(f.current!==d)return;if(n.state!==`ready`||!n.target||n.target.path!==r||n.target.fileRef!==s.file.fileRef||n.target.fileRevision!==s.file.fileRevision||!n.target.hunkRefs.some(e=>e===t))throw Error(`preview-unavailable`);T({value:n,scope:d})}catch{f.current===d&&O(S(l,`Chưa thể hoàn tác an toàn. Tải lại diff và thử lại.`,`Safe revert is unavailable. Refresh the diff and try again.`))}finally{h.current=!1,y(!1)}}},M=async()=>{if(!(h.current||!o||!H.has(u)&&(!w||w.scope!==d))){h.current=!0,y(!0),O(void 0);try{let t=H.get(u)??await N(w.value);if(f.current!==d)return;if(!H.has(u)&&H.size>=128){O(S(l,`Có quá nhiều lệnh chưa rõ kết quả. Kiểm tra lại các lệnh trước trước khi hoàn tác thêm.`,`Too many commands still need their results checked. Check earlier commands before reverting more.`));return}H.set(u,t),A(!0);let n=await te(t,void 0,e);if(n.phase!==`uncertain`&&H.delete(u),p.current===u&&A(H.has(u)),window.dispatchEvent(new CustomEvent(`piagent-workspace-changed`,{detail:{sessionRef:e}})),f.current!==d)return;A(H.has(u)),n.phase===`settled`?(C(!1),T(void 0)):(n.phase===`rejected`&&T(void 0),O(n.phase===`uncertain`?S(l,`Chưa xác định được kết quả. Kiểm tra tệp; kiểm tra lại sẽ dùng đúng lệnh cũ.`,`The result is uncertain. Inspect the file; checking again uses the same command.`):S(l,`Tệp hoặc quyền đã thay đổi. Hãy đóng và xem preview mới.`,`The file or permission changed. Close this dialog and request a new preview.`)))}catch{f.current===d&&O(S(l,`Chưa nhận được kết quả. Kiểm tra lại dùng cùng lệnh, không tạo lần hoàn tác mới.`,`No result received. Checking again reuses the same command.`))}finally{h.current=!1,y(!1)}}},P=w&&w.scope!==d;return{request:j,dialog:(0,V.jsxs)(n,{open:ee,onClose:()=>{v||C(!1)},fullWidth:!0,maxWidth:`md`,children:[(0,V.jsx)(m,{children:S(l,`Hoàn tác thay đổi của agent`,`Revert agent changes`)}),(0,V.jsxs)(_,{children:[(0,V.jsx)(c,{children:r}),(0,V.jsx)(c,{children:S(l,`Các dòng dưới đây sẽ được hoàn tác. Git index được giữ nguyên.`,`The changes below will be reverted. The Git index is preserved.`)}),E&&(0,V.jsx)(g,{severity:`warning`,children:E}),P&&(0,V.jsx)(g,{severity:`warning`,children:S(l,`Nội dung editor đã đổi. Mở lại preview trước khi hoàn tác.`,`Editor contents changed. Open a new preview before reverting.`)}),k&&!w&&(0,V.jsx)(g,{severity:`info`,children:S(l,`Có lệnh chưa xác nhận kết quả cho tệp này.`,`A command for this file still needs its result confirmed.`)}),w?.value.preview?.hunks.map(e=>(0,V.jsxs)(t,{component:`pre`,sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`},children:[e.header,`
|
|
4
4
|
`,e.lines.map(e=>`${e.marker}${e.text}`).join(`
|
|
5
|
-
`)]},e.hunkRef))]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{disabled:v,onClick:()=>C(!1),children:S(l,`Đóng`,`Close`)}),(0,V.jsx)(b,{color:`error`,disabled:v||!o||!k&&(!w||!!P),onClick:()=>void M(),children:k?S(l,`Kiểm tra lại`,`Check again`):S(l,`Xác nhận hoàn tác`,`Confirm revert`)})]})]}),hasPending:k,checkPending:()=>{A(H.has(u)),C(!0)}}}async function U(e,t,n){let r=await fetch(`/api/v1/sessions/${encodeURIComponent(e)}/source-review${t?`/${encodeURIComponent(t)}`:``}`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:n});if(r.status===401&&E(),!r.ok)throw Error(`source-review-unavailable`);return r.json()}var W=(e,t)=>U(e,void 0,t),ce=(e,t,n)=>U(e,t,n);function le(e,t,n,r,i){if(!e||!r||!n||e.file.path!==t||e.file.currentDigest!==`sha256:${n}`||e.availability.state!==`current`||e.truncation.truncated||e.redaction.applied)return[];let a=new Set(e.agentHunkRefs??[]);return e.hunks.filter(e=>a.has(e.hunkRef)&&!i.has(`${t}:${n}:${e.hunkRef}`))}var G=new Set,K=new Map,q=new Set,J=`piagent.kept-hunks.`,Y=`piagent.kept-hunks`;function X(e){try{let t=JSON.parse(localStorage.getItem(J+e)??`[]`);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`).slice(-4096)):G}catch{return G}}function ue(e,t){try{let n=[...JSON.parse(localStorage.getItem(Y)??`[]`).filter(t=>t!==e),e];for(let e of n.splice(0,Math.max(0,n.length-64)))localStorage.removeItem(J+e);localStorage.setItem(J+e,JSON.stringify([...t])),localStorage.setItem(Y,JSON.stringify(n))}catch{}}var de=e=>(K.has(e)||K.set(e,X(e)),K.get(e)??G);function fe(e,t,n,r){let i=new Set([...de(e),`${t}:${n}:${r}`].slice(-4096));for(K.delete(e),K.set(e,i);K.size>64;)K.delete(K.keys().next().value);ue(e,i);for(let e of q)e()}function pe(e){return(0,B.useSyncExternalStore)(e=>(q.add(e),()=>{q.delete(e)}),()=>de(e))}function me(e,t,n){let[r,i]=(0,B.useState)(),a=pe(e),o=JSON.stringify(t.map(e=>e.file.path).sort());(0,B.useEffect)(()=>{let t=JSON.parse(o);if(!t.length){i(void 0);return}let n=new AbortController,r=!1,a=!1,s=async()=>{if(!n.signal.aborted){if(r){a=!0;return}r=!0;try{let r=await W(e,n.signal),a=new Map;for(let i of t){if(n.signal.aborted)return;let t=r.files.find(e=>e.path===i&&e.pathDisplay===`exact-safe`);if(t)try{a.set(i,await ce(e,t.fileRef,n.signal))}catch{}}n.signal.aborted||i({session:e,diffs:a})}catch{n.signal.aborted||i(void 0)}finally{r=!1,a&&!n.signal.aborted&&(a=!1,s())}}};s();let c=window.setInterval(()=>void s(),3e3),l=t=>{t.detail?.sessionRef===e&&s()};return window.addEventListener(`piagent-workspace-saved`,l),window.addEventListener(`piagent-workspace-changed`,l),()=>{n.abort(),clearInterval(c),window.removeEventListener(`piagent-workspace-saved`,l),window.removeEventListener(`piagent-workspace-changed`,l)}},[e,o]);let s=r?.session===e?r.diffs:void 0,c=e=>le(s?.get(e.file.path),e.file.path,e.file.digest,!e.fresh&&!e.pending&&e.draft===(e.file.content??``),a),l=t.find(e=>e.file.path===n),u=l?c(l):[];return{diff:n?s?.get(n):void 0,hunks:u,counts:new Map(t.map(e=>[e.file.path,c(e).length])),keep:t=>{l?.file.digest&&u.some(e=>e.hunkRef===t)&&fe(e,l.file.path,l.file.digest,t)}}}var Z=new Map,he=new Set,ge={tabs:[]},Q=e=>e.fresh||e.draft!==(e.file.content??``);window.addEventListener(`beforeunload`,e=>{[...Z.values()].some(e=>e.tabs.some(Q))&&(e.preventDefault(),e.returnValue=``)});var _e=e=>Z.get(e)??ge;function ve(e){let t=(0,B.useSyncExternalStore)(e=>(he.add(e),()=>{he.delete(e)}),()=>Z.get(e)??ge),n=t=>{Z.set(e,t(Z.get(e)??ge));for(let e of he)e()};return{...t,update:n}}function ye(e,t,n){return e.file!==t||e.file.path!==n.path||e.pending||e.fresh||e.file.digest===n.digest&&e.file.protected===n.protected&&e.file.readOnly===n.readOnly?{tab:e}:e.draft===(e.file.content??``)?{tab:{...e,file:n,draft:n.content??``}}:{tab:e,conflict:n}}function be(e,t,n){let{update:r}=ve(e),i=(0,B.useRef)({update:r,conflict:n});i.current={update:r,conflict:n},(0,B.useEffect)(()=>{let n=new AbortController,r=new Map,a=!1,o=!1,s,c=async()=>{if(!(n.signal.aborted||t.current)){if(a){o=!0;return}a=!0;try{for(let a of _e(e).tabs)if(!(a.fresh||a.pending||t.current))try{let o=await z(e,a.file.path,n.signal);if(n.signal.aborted||t.current)return;let s;if(i.current.update(e=>({...e,tabs:e.tabs.map(t=>{if(t.file.path!==a.file.path)return t;let n=ye(t,a.file,o);return n.conflict&&e.active===t.file.path&&(s=n.conflict),n.tab})})),s){let e=`${s.digest}:${s.protected}:${s.readOnly}`;r.get(s.path)!==e&&(r.set(s.path,e),i.current.conflict(s))}}catch{}}finally{a=!1,o&&!n.signal.aborted&&(o=!1,l())}}},l=()=>{s||=setTimeout(()=>{s=void 0,c()},100)},u=t=>{t.detail?.sessionRef===e&&l()};window.addEventListener(`piagent-workspace-changed`,u),window.addEventListener(`piagent-workspace-saved`,u);let d=setInterval(l,5e3);return l(),()=>{n.abort(),clearTimeout(s),clearInterval(d),window.removeEventListener(`piagent-workspace-changed`,u),window.removeEventListener(`piagent-workspace-saved`,u)}},[e,t])}var xe=e=>`/api/v1/sessions/${encodeURIComponent(e)}/workspace/write`;function $(e){return Array.isArray(e)?`[${e.map($).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${$(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Se(e,t){let n=await fetch(xe(e),{credentials:`same-origin`,signal:t,headers:{Accept:`application/json`}});if(n.status===401&&E(),!n.ok)throw Error(`workspace-write-unavailable`);return await n.json()}async function Ce(e,t){let n=Date.now(),r=`workspace.write`,i=e.identity,a=e.revisions,o=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode($({action:r,identity:i,expectedRevisions:a,payload:t})));return{schemaVersion:1,version:`piagent-webui-workspace-write-v1`,messageType:`command`,action:r,identity:i,expectedRevisions:a,payload:t,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(n).toISOString(),expiresAt:new Date(n+6e4).toISOString(),actionDigest:`sha256:${[...new Uint8Array(o)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}}async function we(e,t){let n=T();if(!n)throw Error(`workspace-write-unavailable`);let r=await w(xe(e),{method:`POST`,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(t)});if(r.status===401&&E(),!r.ok)throw Error(`workspace-write-unavailable`);let i=await r.json(),a=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t.idempotencyKey)),o=`sha256:${[...new Uint8Array(a)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`;if(i.schemaVersion!==1||i.version!==t.version||i.messageType!==`receipt`||i.path!==t.payload.path||i.commandId!==t.commandId||i.action!==t.action||i.actionDigest!==t.actionDigest||i.idempotencyKeyDigest!==o||$(i.identity)!==$(t.identity)||![`settled`,`rejected`,`uncertain`].includes(i.phase)||i.phase===`settled`&&(i.resultCode!==`saved`||!/^[a-f0-9]{64}$/.test(i.digest??``)))throw Error(`workspace-write-receipt-invalid`);return i}function Te(e){let{locale:t}=x(),n=ve(e),[r,i]=(0,B.useState)(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(!1),[c,l]=(0,B.useState)(),[u,d]=(0,B.useState)();be(e,s,d),(0,B.useEffect)(()=>{let t=new AbortController,n=!1,r=()=>{n||(n=!0,Se(e,t.signal).then(i).catch(()=>{t.signal.aborted||i(void 0)}).finally(()=>{n=!1}))};r();let a=window.setInterval(r,5e3);return()=>{t.abort(),clearInterval(a)}},[e]);let f=(e,t=1,r=!1)=>n.update(n=>({active:e.path,tabs:[...n.tabs.filter(t=>t.file.path!==e.path),{file:e,line:t,fresh:r,draft:e.content??``}]})),p=(e,t)=>n.update(n=>({...n,active:e,tabs:n.tabs.map(n=>n.file.path===e&&t!==void 0?{...n,line:t}:n)})),m=(e,t)=>n.update(n=>({...n,tabs:n.tabs.map(n=>n.file.path===e?{...n,draft:t}:n)})),h=r=>{let i=_e(e).tabs.find(e=>e.file.path===r);i&&(Q(i)||i.pending)&&!window.confirm(S(t,`Bỏ thay đổi chưa lưu và đóng tệp?`,`Discard unsaved changes and close this file?`))||n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?e.tabs.find(e=>e.file.path!==r)?.file.path:e.active}))},g=async n=>{try{f(await z(e,n)),d(void 0),l(void 0)}catch{l(S(t,`Chưa tải lại được tệp. Bản sửa của bạn vẫn được giữ.`,`Could not reload the file. Your draft is preserved.`))}},_=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(!(!c||s.current||!Q(c)&&!c.pending||c.file.protected||c.file.readOnly)&&!(a&&!window.confirm(S(t,`Ghi đè phiên bản trên đĩa bằng bản sửa của bạn?`,`Replace the version on disk with your draft?`)))){s.current=!0,o(!0),l(void 0);try{let o=await Se(e);if(i(o),!o.writable)throw Error(`read-only`);let s=a?.digest??(c.fresh?`absent`:c.file.digest);if(!s)throw Error(`unavailable`);let u=c.pending??await Ce(o,{path:r,content:c.draft,expectedDigest:s});n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:u}:e)}));let f=await we(e,u);if(f.phase===`uncertain`){l(S(t,`Chưa xác định được kết quả lưu. Tải lại để kiểm tra trước khi lưu tiếp.`,`The save result is uncertain. Reload to check before saving again.`));return}n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:void 0}:e)})),f.phase===`settled`&&f.resultCode===`saved`?(n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,fresh:!1,file:{...e.file,content:u.payload.content,digest:f.digest,revision:f.observedRevisionsAfter.workspaceRevision}}:e)})),d(void 0),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}}))):f.resultCode===`stale-content`||f.resultCode===`stale-revision`?d(await z(e,r)):l(S(t,`Chưa lưu được tệp. Kiểm tra quyền ghi và thử lại.`,`Could not save the file. Check write access and try again.`))}catch{l(S(t,`Chưa lưu được tệp. Bản sửa vẫn được giữ; thử lưu lại hoặc tải lại để kiểm tra.`,`Could not confirm the save. Your draft is preserved; retry the save or reload to check.`))}finally{s.current=!1,o(!1)}}},v=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(s.current||c&&(Q(c)||c.pending))return l(S(t,`Lưu hoặc bỏ thay đổi trước khi đổi tên hay xóa tệp.`,`Save or discard your changes before renaming or deleting the file.`)),!1;s.current=!0,o(!0),l(void 0);try{let o=await Se(e);i(o);let s=c?.file.digest??(await z(e,r)).digest;if(!o.writable||!s)throw Error(`unavailable`);let u=await we(e,await Ce(o,a?{path:r,content:``,expectedDigest:s,operation:`rename`,destination:a}:{path:r,content:``,expectedDigest:s,operation:`delete`}));return u.phase===`settled`&&u.resultCode===`saved`?(n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?void 0:e.active})),a&&f(await z(e,a)),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}})),!0):(l(u.phase===`uncertain`?S(t,`Chưa xác định được kết quả. Tải lại danh sách tệp để kiểm tra.`,`The result is uncertain. Reload the file list to check.`):u.resultCode===`stale-content`?S(t,`Tệp đã thay đổi trên đĩa hoặc tên mới đã có. Tải lại rồi thử lại.`,`The file changed on disk or the new name exists. Reload and try again.`):S(t,`Không thực hiện được. Kiểm tra quyền ghi và tên tệp.`,`This could not be done. Check write access and the file name.`)),!1)}catch{return l(S(t,`Chưa xác nhận được thao tác. Tải lại danh sách tệp để kiểm tra.`,`Could not confirm the action. Reload the file list to check.`)),!1}finally{s.current=!1,o(!1)}};return{...n,authority:r,saving:a,message:c,conflict:u,setConflict:d,load:f,select:p,change:m,close:h,reload:g,save:_,move:v}}var Ee=e(i(),1);function De({sessionRef:e,onOpen:t}){let{locale:n}=x(),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(),[s,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t=new AbortController;if(o(void 0),d(!1),l(!1),!r.trim())return()=>t.abort();l(!0);let n=setTimeout(()=>{ae(e,r,t.signal).then(e=>{t.signal.aborted||o(e)}).catch(()=>{t.signal.aborted||d(!0)}).finally(()=>{t.signal.aborted||l(!1)})},250);return()=>{clearTimeout(n),t.abort()}},[r,e]),(0,V.jsxs)(p,{spacing:1,sx:{p:1},children:[(0,V.jsx)(v,{size:`small`,label:S(n,`Tìm nội dung`,`Search contents`),value:r,onChange:e=>i(e.target.value),slotProps:{htmlInput:{maxLength:512}}}),s&&(0,V.jsx)(h,{size:18}),(u||a?.available===!1)&&(0,V.jsx)(g,{severity:`warning`,children:S(n,`Chưa tìm được nội dung trong project này.`,`Content search is unavailable for this project.`)}),a?.available&&a.backend===`fts`&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Tìm trong các tệp đã lập chỉ mục.`,`Searching indexed files.`)}),a?.matches.map(e=>(0,V.jsxs)(b,{onClick:()=>t(e.path,e.line),sx:{textTransform:`none`,display:`block`,textAlign:`left`,overflowWrap:`anywhere`},children:[(0,V.jsxs)(c,{variant:`caption`,component:`span`,children:[e.path,`:`,e.line,`:`,e.column]}),(0,V.jsx)(c,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.preview})]},`${e.path}:${e.line}:${e.column}`)),a?.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Đã giới hạn kết quả. Hãy tìm cụ thể hơn.`,`Results were limited. Refine your search.`)}),a?.available&&!a.matches.length&&!a.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Không tìm thấy.`,`No matches.`)})]})}var Oe=y((0,V.jsx)(`path`,{d:`M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z`}),`ChevronRight`),ke=y((0,V.jsx)(`path`,{d:`M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z`}),`ExpandMore`),Ae=y((0,V.jsx)(`path`,{d:`M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zM6 20V4h7v5h5v11z`}),`InsertDriveFileOutlined`),je=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`));function Me({sessionRef:e,refresh:n,active:r,onOpen:i,onFolder:a}){let{locale:o}=x(),[s,u]=(0,B.useState)(()=>new Set([``])),[f,p]=(0,B.useState)(()=>new Map),[m,g]=(0,B.useState)(),_=(t,n)=>{p(e=>new Map(e).set(t,e.get(t)??`loading`)),R(e,t,n).then(e=>{n?.aborted||p(n=>new Map(n).set(t,e))}).catch(()=>{n?.aborted||p(e=>new Map(e).set(t,`error`))})};(0,B.useEffect)(()=>{p(new Map),u(new Set([``]))},[e]),(0,B.useEffect)(()=>{let e=new AbortController;for(let t of s)_(t,e.signal);return()=>e.abort()},[e,n]),(0,B.useEffect)(()=>{if(!r)return;let e=je(r).filter(e=>!s.has(e));if(e.length){u(t=>new Set([...t,...e]));for(let t of e)f.has(t)||_(t)}},[r]);let v=e=>{if(g(e),a(e),s.has(e)){u(t=>{let n=new Set(t);return n.delete(e),n});return}u(t=>new Set(t).add(e)),(!f.has(e)||f.get(e)===`error`)&&_(e)},y=(e,n)=>{let a=f.get(e);return!a||a===`loading`?(0,V.jsx)(h,{size:14,sx:{ml:1.5+n*1.5,my:.5}}):a===`error`?(0,V.jsx)(c,{variant:`caption`,color:`warning.main`,sx:{pl:1.5+n*1.5},children:S(o,`Chưa đọc được thư mục này.`,`This folder could not be read.`)}):(0,V.jsxs)(V.Fragment,{children:[a.entries.map(e=>{let a=e.kind===`directory`,c=a&&s.has(e.path),u=a?m===e.path:r===e.path,f=a?(0,V.jsxs)(V.Fragment,{children:[c?(0,V.jsx)(ke,{sx:{fontSize:16}}):(0,V.jsx)(Oe,{sx:{fontSize:16}}),c?(0,V.jsx)(l,{sx:{fontSize:16}}):(0,V.jsx)(d,{sx:{fontSize:16}})]}):(0,V.jsx)(Ae,{sx:{fontSize:16,ml:`16px`}});return(0,V.jsxs)(t,{children:[(0,V.jsxs)(b,{fullWidth:!0,size:`small`,disabled:e.protected||e.kind===`symlink`||e.kind===`other`,"aria-label":e.protected?`${e.name} (${S(o,`được bảo vệ`,`protected`)})`:e.name,"aria-expanded":a?c:void 0,"aria-current":!a&&r===e.path?`true`:void 0,onClick:()=>a?v(e.path):(g(void 0),i(e.path)),sx:{justifyContent:`flex-start`,textTransform:`none`,gap:.5,minHeight:24,py:0,pl:.5+n*1.5,pr:1,color:`text.primary`,fontWeight:400,whiteSpace:`nowrap`,bgcolor:u?`action.selected`:void 0},children:[f,(0,V.jsxs)(t,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`},children:[e.name,e.protected?` 🔒`:``]})]}),c&&y(e.path,n+1)]},e.path)}),a.truncated&&(0,V.jsx)(c,{variant:`caption`,sx:{pl:1.5+n*1.5},children:S(o,`Danh sách đã được giới hạn.`,`Listing limit reached.`)})]})};return(0,V.jsx)(t,{role:`group`,"aria-label":S(o,`Cây thư mục`,`Folder tree`),sx:{py:.5},children:y(``,0)})}var Ne=(0,B.lazy)(()=>C(()=>import(`./WorkspaceCodeEditor-DPOp-ZoD.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function Pe({sessionRef:e,target:r,navigationHost:i,sidebarMode:s,onHide:l,fill:d}){let{locale:y}=x(),[C,w]=(0,B.useState)(`files`),[T,E]=(0,B.useState)(!1),[D,te]=(0,B.useState)(``),[k,A]=(0,B.useState)(!1),[j,M]=(0,B.useState)(),[N,P]=(0,B.useState)(``),F=Te(e),{tabs:I,active:L}=F,[ne,re]=(0,B.useState)(``),[ae,R]=(0,B.useState)(!1),[H,U]=(0,B.useState)(!1),W=(0,B.useRef)(null),[ce,le]=(0,B.useState)(0);(0,B.useEffect)(()=>{let t=t=>{t.detail?.sessionRef===e&&le(e=>e+1)};return window.addEventListener(`piagent-workspace-saved`,t),()=>window.removeEventListener(`piagent-workspace-saved`,t)},[e]),(0,B.useEffect)(()=>()=>W.current?.abort(),[]);let G=async(t,n=1)=>{if(W.current?.abort(),U(!1),I.find(e=>e.file.path===t)){F.select(t,n);return}W.current?.abort();let r=new AbortController;W.current=r,U(!0),R(!1);try{let i=await z(e,t,r.signal);if(r.signal.aborted)return;if(i.protected){R(!0);return}F.load(i,n)}catch{r.signal.aborted||R(!0)}finally{r.signal.aborted||U(!1)}};(0,B.useEffect)(()=>{r&&G(r.path,r.line??1)},[r]),(0,B.useEffect)(()=>{s&&s!==`sessions`&&w(s)},[s]);let K=I.find(e=>e.file.path===L),q=K?.file,J=me(e,I,L),Y=se(e,q?.path,q?.digest??null,!!K&&!Q(K),J.diff),X=oe(e,q?.path,K?.draft??``,J.hunks),ue=I.find(e=>e.file.path===F.conflict?.path),de=(0,V.jsxs)(t,{component:`nav`,"aria-label":S(y,`Tệp dự án`,`Project files`),sx:{width:i?`100%`:{xs:136,sm:200},flexShrink:0,overflow:`auto`,borderRight:1,borderColor:`divider`},children:[!i&&(0,V.jsxs)(u,{value:C,onChange:(e,t)=>w(t),"aria-label":S(y,`Khám phá project`,`Explore project`),children:[(0,V.jsx)(f,{value:`files`,label:S(y,`Tệp`,`Files`)}),(0,V.jsx)(f,{value:`search`,label:S(y,`Tìm kiếm`,`Search`)})]}),C===`search`?(0,V.jsx)(De,{sessionRef:e,onOpen:(e,t)=>void G(e,t)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(b,{disabled:!F.authority?.writable,onClick:()=>{te(ne?`${ne}/`:``),E(!0)},children:S(y,`Tệp mới`,`New file`)}),(0,V.jsx)(Me,{sessionRef:e,refresh:ce,active:L,onOpen:e=>{re(e.split(`/`).slice(0,-1).join(`/`)),G(e)},onFolder:re})]})]});return(0,V.jsxs)(V.Fragment,{children:[Y.dialog,X.dialog,(0,V.jsxs)(p,{direction:`row`,sx:{height:d?`100%`:`calc(100vh - 150px)`,minHeight:d?160:320},children:[i?(0,Ee.createPortal)(de,i):de,(0,V.jsxs)(t,{sx:{minWidth:0,flex:1,display:`flex`,flexDirection:`column`},children:[ae&&(0,V.jsx)(g,{severity:`warning`,children:S(y,`Chưa đọc được tệp hoặc thư mục này.`,`This file or folder could not be read.`)}),X.bar,F.message&&(0,V.jsx)(g,{severity:`warning`,children:F.message}),F.authority?.agentRunning&&(0,V.jsx)(g,{severity:`info`,children:S(y,`Agent đang chạy và có thể sửa tệp này.`,`The agent is running and may change this file.`)}),(0,V.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,borderBottom:1,borderColor:`divider`,minHeight:36},children:[(0,V.jsx)(u,{value:L??!1,onChange:(e,t)=>F.select(t),variant:`scrollable`,scrollButtons:`auto`,"aria-label":S(y,`Các tệp đang mở`,`Open files`),sx:{flex:1,minWidth:0,minHeight:36},children:I.map(e=>(0,V.jsx)(f,{value:e.file.path,sx:{minHeight:36,py:0},"aria-label":`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,label:ie(`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,S(y,`Đóng ${e.file.path}`,`Close ${e.file.path}`),()=>F.close(e.file.path))},e.file.path))}),l&&(0,V.jsx)(o,{size:`small`,"aria-label":S(y,`Ẩn khung tệp`,`Hide files panel`),title:S(y,`Ẩn khung tệp (tệp đang mở vẫn giữ)`,`Hide files panel (open files are kept)`),onClick:l,children:(0,V.jsx)(ee,{fontSize:`small`})})]}),H&&(0,V.jsx)(h,{size:20}),q&&(0,V.jsxs)(p,{direction:`row`,sx:{flexShrink:0,overflowX:`auto`,"& .MuiButton-root":{whiteSpace:`nowrap`,flexShrink:0}},children:[Y.hasPending&&(0,V.jsx)(b,{onClick:Y.checkPending,children:S(y,`Kiểm tra hoàn tác`,`Check revert`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!K||!Q(K)&&!K.pending||F.saving,onClick:()=>void F.save(q.path),children:S(y,`Lưu`,`Save`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>F.close(q.path),children:S(y,`Đóng tệp`,`Close file`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{P(q.path),M(q.path)},children:S(y,`Đổi tên`,`Rename`)}),(0,V.jsx)(b,{size:`small`,color:`error`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{window.confirm(S(y,`Xóa ${q.path}? Có thể khôi phục bằng Git nếu tệp đã commit.`,`Delete ${q.path}? Git can restore it if it was committed.`))&&F.move(q.path)},children:S(y,`Xóa`,`Delete`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>{(!K||!Q(K)||window.confirm(S(y,`Bỏ thay đổi chưa lưu và tải lại?`,`Discard unsaved changes and reload?`)))&&F.reload(q.path)},children:S(y,`Tải lại`,`Reload`)})]}),q?.binary||q?.oversized?(0,V.jsx)(g,{severity:`info`,children:S(y,`Tệp nhị phân hoặc quá lớn để hiển thị.`,`This file is binary or too large to display.`)}):q?.content!==null&&q?.content!==void 0?(0,V.jsx)(t,{sx:{flex:1,minHeight:0},children:(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{onComment:X.open,hunks:J.hunks,onKeep:J.keep,onRevert:F.authority?.writable?e=>void Y.request(e):void 0,content:K?.draft??q.content,path:q.path,line:K?.line??1,readOnly:!F.authority?.writable||q.readOnly,onChange:e=>F.change(q.path,e),onSave:()=>void F.save(q.path)})})}):(0,V.jsx)(c,{sx:{p:2},children:S(y,`Chọn một tệp để mở.`,`Select a file to open.`)})]})]}),(0,V.jsxs)(n,{open:T,onClose:()=>E(!1),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Tạo tệp mới`,`Create a new file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn trong project`,`Path in project`),value:D,onChange:e=>te(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>E(!1),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(D)||!F.authority?.writable,onClick:()=>{let e=O(D);!e||!F.authority||(I.some(t=>t.file.path===e.path)?F.select(e.path):F.load({schemaVersion:1,version:`piagent-webui-workspace-file-v1`,generatedAt:new Date().toISOString(),identity:F.authority.identity,path:e.path,language:`text`,protected:!1,readOnly:!1,binary:!1,oversized:!1,content:``,digest:null,revision:null},1,!0),E(!1))},children:S(y,`Tạo`,`Create`)})]})]}),(0,V.jsxs)(n,{open:!!j,onClose:()=>M(void 0),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Đổi tên tệp`,`Rename file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn mới trong project`,`New path in project`),value:N,onChange:e=>P(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>M(void 0),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(N)||O(N)?.path===j||F.saving,onClick:()=>{let e=O(N);!e||!j||F.move(j,e.path).then(e=>{e&&M(void 0)})},children:S(y,`Đổi tên`,`Rename`)})]})]}),(0,V.jsxs)(n,{open:!!F.conflict,onClose:()=>{F.setConflict(void 0),A(!1)},fullWidth:!0,maxWidth:k?`lg`:`sm`,children:[(0,V.jsx)(m,{children:S(y,`Tệp đã thay đổi trên đĩa`,`The file changed on disk`)}),(0,V.jsxs)(_,{children:[(0,V.jsx)(c,{children:F.conflict?.path}),(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn vẫn được giữ. Chọn cách xử lý xung đột.`,`Your draft is preserved. Choose how to resolve the conflict.`)}),k&&F.conflict&&ue&&(0,V.jsxs)(p,{direction:`row`,spacing:1,children:[(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Trên đĩa`,`On disk`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:F.conflict.path,content:F.conflict.content??``})})]}),(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn`,`Your draft`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:ue.file.path,content:ue.draft})})]})]})]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>{F.setConflict(void 0),A(!1)},children:S(y,`Để sau`,`Later`)}),(0,V.jsx)(b,{onClick:()=>{F.conflict&&(F.load(F.conflict),F.setConflict(void 0),A(!1))},children:S(y,`Tải lại`,`Reload`)}),(0,V.jsx)(b,{onClick:()=>A(!0),children:S(y,`Xem khác biệt`,`Compare`)}),(0,V.jsx)(b,{disabled:F.saving||!F.conflict?.digest||F.conflict.protected||F.conflict.readOnly,onClick:()=>{F.conflict&&F.save(F.conflict.path,F.conflict)},children:S(y,`Ghi đè`,`Overwrite`)})]})]})]})}export{Pe as default};
|
|
5
|
+
`)]},e.hunkRef))]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{disabled:v,onClick:()=>C(!1),children:S(l,`Đóng`,`Close`)}),(0,V.jsx)(b,{color:`error`,disabled:v||!o||!k&&(!w||!!P),onClick:()=>void M(),children:k?S(l,`Kiểm tra lại`,`Check again`):S(l,`Xác nhận hoàn tác`,`Confirm revert`)})]})]}),hasPending:k,checkPending:()=>{A(H.has(u)),C(!0)}}}async function U(e,t,n){let r=await fetch(`/api/v1/sessions/${encodeURIComponent(e)}/source-review${t?`/${encodeURIComponent(t)}`:``}`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:n});if(r.status===401&&E(),!r.ok)throw Error(`source-review-unavailable`);return r.json()}var W=(e,t)=>U(e,void 0,t),ce=(e,t,n)=>U(e,t,n);function le(e,t,n,r,i){if(!e||!r||!n||e.file.path!==t||e.file.currentDigest!==`sha256:${n}`||e.availability.state!==`current`||e.truncation.truncated||e.redaction.applied)return[];let a=new Set(e.agentHunkRefs??[]);return e.hunks.filter(e=>a.has(e.hunkRef)&&!i.has(`${t}:${n}:${e.hunkRef}`))}var G=new Set,K=new Map,q=new Set,J=`piagent.kept-hunks.`,Y=`piagent.kept-hunks`;function X(e){try{let t=JSON.parse(localStorage.getItem(J+e)??`[]`);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`).slice(-4096)):G}catch{return G}}function ue(e,t){try{let n=[...JSON.parse(localStorage.getItem(Y)??`[]`).filter(t=>t!==e),e];for(let e of n.splice(0,Math.max(0,n.length-64)))localStorage.removeItem(J+e);localStorage.setItem(J+e,JSON.stringify([...t])),localStorage.setItem(Y,JSON.stringify(n))}catch{}}var de=e=>(K.has(e)||K.set(e,X(e)),K.get(e)??G);function fe(e,t,n,r){let i=new Set([...de(e),`${t}:${n}:${r}`].slice(-4096));for(K.delete(e),K.set(e,i);K.size>64;)K.delete(K.keys().next().value);ue(e,i);for(let e of q)e()}function pe(e){return(0,B.useSyncExternalStore)(e=>(q.add(e),()=>{q.delete(e)}),()=>de(e))}function me(e,t,n){let[r,i]=(0,B.useState)(),a=pe(e),o=JSON.stringify(t.map(e=>e.file.path).sort());(0,B.useEffect)(()=>{let t=JSON.parse(o);if(!t.length){i(void 0);return}let n=new AbortController,r=!1,a=!1,s=async()=>{if(!n.signal.aborted){if(r){a=!0;return}r=!0;try{let r=await W(e,n.signal),a=new Map;for(let i of t){if(n.signal.aborted)return;let t=r.files.find(e=>e.path===i&&e.pathDisplay===`exact-safe`);if(t)try{a.set(i,await ce(e,t.fileRef,n.signal))}catch{}}n.signal.aborted||i({session:e,diffs:a})}catch{n.signal.aborted||i(void 0)}finally{r=!1,a&&!n.signal.aborted&&(a=!1,s())}}};s();let c=window.setInterval(()=>void s(),3e3),l=t=>{t.detail?.sessionRef===e&&s()};return window.addEventListener(`piagent-workspace-saved`,l),window.addEventListener(`piagent-workspace-changed`,l),()=>{n.abort(),clearInterval(c),window.removeEventListener(`piagent-workspace-saved`,l),window.removeEventListener(`piagent-workspace-changed`,l)}},[e,o]);let s=r?.session===e?r.diffs:void 0,c=e=>le(s?.get(e.file.path),e.file.path,e.file.digest,!e.fresh&&!e.pending&&e.draft===(e.file.content??``),a),l=t.find(e=>e.file.path===n),u=l?c(l):[];return{diff:n?s?.get(n):void 0,hunks:u,counts:new Map(t.map(e=>[e.file.path,c(e).length])),keep:t=>{l?.file.digest&&u.some(e=>e.hunkRef===t)&&fe(e,l.file.path,l.file.digest,t)}}}var Z=new Map,he=new Set,ge={tabs:[]},Q=e=>e.fresh||e.draft!==(e.file.content??``);window.addEventListener(`beforeunload`,e=>{[...Z.values()].some(e=>e.tabs.some(Q))&&(e.preventDefault(),e.returnValue=``)});var _e=e=>Z.get(e)??ge;function ve(e){let t=(0,B.useSyncExternalStore)(e=>(he.add(e),()=>{he.delete(e)}),()=>Z.get(e)??ge),n=t=>{Z.set(e,t(Z.get(e)??ge));for(let e of he)e()};return{...t,update:n}}function ye(e,t,n){return e.file!==t||e.file.path!==n.path||e.pending||e.fresh||e.file.digest===n.digest&&e.file.protected===n.protected&&e.file.readOnly===n.readOnly?{tab:e}:e.draft===(e.file.content??``)?{tab:{...e,file:n,draft:n.content??``}}:{tab:e,conflict:n}}function be(e,t,n){let{update:r}=ve(e),i=(0,B.useRef)({update:r,conflict:n});i.current={update:r,conflict:n},(0,B.useEffect)(()=>{let n=new AbortController,r=new Map,a=!1,o=!1,s,c=async()=>{if(!(n.signal.aborted||t.current)){if(a){o=!0;return}a=!0;try{for(let a of _e(e).tabs)if(!(a.fresh||a.pending||t.current))try{let o=await z(e,a.file.path,n.signal);if(n.signal.aborted||t.current)return;let s;if(i.current.update(e=>({...e,tabs:e.tabs.map(t=>{if(t.file.path!==a.file.path)return t;let n=ye(t,a.file,o);return n.conflict&&e.active===t.file.path&&(s=n.conflict),n.tab})})),s){let e=`${s.digest}:${s.protected}:${s.readOnly}`;r.get(s.path)!==e&&(r.set(s.path,e),i.current.conflict(s))}}catch{}}finally{a=!1,o&&!n.signal.aborted&&(o=!1,l())}}},l=()=>{s||=setTimeout(()=>{s=void 0,c()},100)},u=t=>{t.detail?.sessionRef===e&&l()};window.addEventListener(`piagent-workspace-changed`,u),window.addEventListener(`piagent-workspace-saved`,u);let d=setInterval(l,5e3);return l(),()=>{n.abort(),clearTimeout(s),clearInterval(d),window.removeEventListener(`piagent-workspace-changed`,u),window.removeEventListener(`piagent-workspace-saved`,u)}},[e,t])}var xe=e=>`/api/v1/sessions/${encodeURIComponent(e)}/workspace/write`;function $(e){return Array.isArray(e)?`[${e.map($).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${$(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Se(e,t){let n=await fetch(xe(e),{credentials:`same-origin`,signal:t,headers:{Accept:`application/json`}});if(n.status===401&&E(),!n.ok)throw Error(`workspace-write-unavailable`);return await n.json()}async function Ce(e,t){let n=Date.now(),r=`workspace.write`,i=e.identity,a=e.revisions,o=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode($({action:r,identity:i,expectedRevisions:a,payload:t})));return{schemaVersion:1,version:`piagent-webui-workspace-write-v1`,messageType:`command`,action:r,identity:i,expectedRevisions:a,payload:t,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(n).toISOString(),expiresAt:new Date(n+6e4).toISOString(),actionDigest:`sha256:${[...new Uint8Array(o)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}}async function we(e,t){let n=T();if(!n)throw Error(`workspace-write-unavailable`);let r=await w(xe(e),{method:`POST`,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(t)});if(r.status===401&&E(),!r.ok)throw Error(`workspace-write-unavailable`);let i=await r.json(),a=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(t.idempotencyKey)),o=`sha256:${[...new Uint8Array(a)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`;if(i.schemaVersion!==1||i.version!==t.version||i.messageType!==`receipt`||i.path!==t.payload.path||i.commandId!==t.commandId||i.action!==t.action||i.actionDigest!==t.actionDigest||i.idempotencyKeyDigest!==o||$(i.identity)!==$(t.identity)||![`settled`,`rejected`,`uncertain`].includes(i.phase)||i.phase===`settled`&&(i.resultCode!==`saved`||!/^[a-f0-9]{64}$/.test(i.digest??``)))throw Error(`workspace-write-receipt-invalid`);return i}function Te(e){let{locale:t}=x(),n=ve(e),[r,i]=(0,B.useState)(),[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(!1),[c,l]=(0,B.useState)(),[u,d]=(0,B.useState)();be(e,s,d),(0,B.useEffect)(()=>{let t=new AbortController,n=!1,r=()=>{n||(n=!0,Se(e,t.signal).then(i).catch(()=>{t.signal.aborted||i(void 0)}).finally(()=>{n=!1}))};r();let a=window.setInterval(r,5e3);return()=>{t.abort(),clearInterval(a)}},[e]);let f=(e,t=1,r=!1)=>n.update(n=>({active:e.path,tabs:[...n.tabs.filter(t=>t.file.path!==e.path),{file:e,line:t,fresh:r,draft:e.content??``}]})),p=(e,t)=>n.update(n=>({...n,active:e,tabs:n.tabs.map(n=>n.file.path===e&&t!==void 0?{...n,line:t}:n)})),m=(e,t)=>n.update(n=>({...n,tabs:n.tabs.map(n=>n.file.path===e?{...n,draft:t}:n)})),h=r=>{let i=_e(e).tabs.find(e=>e.file.path===r);i&&(Q(i)||i.pending)&&!window.confirm(S(t,`Bỏ thay đổi chưa lưu và đóng tệp?`,`Discard unsaved changes and close this file?`))||n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?e.tabs.find(e=>e.file.path!==r)?.file.path:e.active}))},g=async n=>{try{f(await z(e,n)),d(void 0),l(void 0)}catch{l(S(t,`Chưa tải lại được tệp. Bản sửa của bạn vẫn được giữ.`,`Could not reload the file. Your draft is preserved.`))}},_=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(!(!c||s.current||!Q(c)&&!c.pending||c.file.protected||c.file.readOnly)&&!(a&&!window.confirm(S(t,`Ghi đè phiên bản trên đĩa bằng bản sửa của bạn?`,`Replace the version on disk with your draft?`)))){s.current=!0,o(!0),l(void 0);try{let o=await Se(e);if(i(o),!o.writable)throw Error(`read-only`);let s=a?.digest??(c.fresh?`absent`:c.file.digest);if(!s)throw Error(`unavailable`);let u=c.pending??await Ce(o,{path:r,content:c.draft,expectedDigest:s});n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:u}:e)}));let f=await we(e,u);if(f.phase===`uncertain`){l(S(t,`Chưa xác định được kết quả lưu. Tải lại để kiểm tra trước khi lưu tiếp.`,`The save result is uncertain. Reload to check before saving again.`));return}n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,pending:void 0}:e)})),f.phase===`settled`&&f.resultCode===`saved`?(n.update(e=>({...e,tabs:e.tabs.map(e=>e.file.path===r?{...e,fresh:!1,file:{...e.file,content:u.payload.content,digest:f.digest,revision:f.observedRevisionsAfter.workspaceRevision}}:e)})),d(void 0),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}}))):f.resultCode===`stale-content`||f.resultCode===`stale-revision`?d(await z(e,r)):l(S(t,`Chưa lưu được tệp. Kiểm tra quyền ghi và thử lại.`,`Could not save the file. Check write access and try again.`))}catch{l(S(t,`Chưa lưu được tệp. Bản sửa vẫn được giữ; thử lưu lại hoặc tải lại để kiểm tra.`,`Could not confirm the save. Your draft is preserved; retry the save or reload to check.`))}finally{s.current=!1,o(!1)}}},v=async(r,a)=>{let c=_e(e).tabs.find(e=>e.file.path===r);if(s.current||c&&(Q(c)||c.pending))return l(S(t,`Lưu hoặc bỏ thay đổi trước khi đổi tên hay xóa tệp.`,`Save or discard your changes before renaming or deleting the file.`)),!1;s.current=!0,o(!0),l(void 0);try{let o=await Se(e);i(o);let s=c?.file.digest??(await z(e,r)).digest;if(!o.writable||!s)throw Error(`unavailable`);let u=await we(e,await Ce(o,a?{path:r,content:``,expectedDigest:s,operation:`rename`,destination:a}:{path:r,content:``,expectedDigest:s,operation:`delete`}));return u.phase===`settled`&&u.resultCode===`saved`?(n.update(e=>({tabs:e.tabs.filter(e=>e.file.path!==r),active:e.active===r?void 0:e.active})),a&&f(await z(e,a)),window.dispatchEvent(new CustomEvent(`piagent-workspace-saved`,{detail:{sessionRef:e,path:r}})),!0):(l(u.phase===`uncertain`?S(t,`Chưa xác định được kết quả. Tải lại danh sách tệp để kiểm tra.`,`The result is uncertain. Reload the file list to check.`):u.resultCode===`stale-content`?S(t,`Tệp đã thay đổi trên đĩa hoặc tên mới đã có. Tải lại rồi thử lại.`,`The file changed on disk or the new name exists. Reload and try again.`):S(t,`Không thực hiện được. Kiểm tra quyền ghi và tên tệp.`,`This could not be done. Check write access and the file name.`)),!1)}catch{return l(S(t,`Chưa xác nhận được thao tác. Tải lại danh sách tệp để kiểm tra.`,`Could not confirm the action. Reload the file list to check.`)),!1}finally{s.current=!1,o(!1)}};return{...n,authority:r,saving:a,message:c,conflict:u,setConflict:d,load:f,select:p,change:m,close:h,reload:g,save:_,move:v}}var Ee=e(i(),1);function De({sessionRef:e,onOpen:t}){let{locale:n}=x(),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(),[s,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{let t=new AbortController;if(o(void 0),d(!1),l(!1),!r.trim())return()=>t.abort();l(!0);let n=setTimeout(()=>{ae(e,r,t.signal).then(e=>{t.signal.aborted||o(e)}).catch(()=>{t.signal.aborted||d(!0)}).finally(()=>{t.signal.aborted||l(!1)})},250);return()=>{clearTimeout(n),t.abort()}},[r,e]),(0,V.jsxs)(p,{spacing:1,sx:{p:1},children:[(0,V.jsx)(v,{size:`small`,label:S(n,`Tìm nội dung`,`Search contents`),value:r,onChange:e=>i(e.target.value),slotProps:{htmlInput:{maxLength:512}}}),s&&(0,V.jsx)(h,{size:18}),(u||a?.available===!1)&&(0,V.jsx)(g,{severity:`warning`,children:S(n,`Chưa tìm được nội dung trong project này.`,`Content search is unavailable for this project.`)}),a?.available&&a.backend===`fts`&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Tìm trong các tệp đã lập chỉ mục.`,`Searching indexed files.`)}),a?.matches.map(e=>(0,V.jsxs)(b,{onClick:()=>t(e.path,e.line),sx:{textTransform:`none`,display:`block`,textAlign:`left`,overflowWrap:`anywhere`},children:[(0,V.jsxs)(c,{variant:`caption`,component:`span`,children:[e.path,`:`,e.line,`:`,e.column]}),(0,V.jsx)(c,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.preview})]},`${e.path}:${e.line}:${e.column}`)),a?.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Đã giới hạn kết quả. Hãy tìm cụ thể hơn.`,`Results were limited. Refine your search.`)}),a?.available&&!a.matches.length&&!a.truncated&&(0,V.jsx)(c,{variant:`caption`,children:S(n,`Không tìm thấy.`,`No matches.`)})]})}var Oe=y((0,V.jsx)(`path`,{d:`M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z`}),`ChevronRight`),ke=y((0,V.jsx)(`path`,{d:`M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z`}),`ExpandMore`),Ae=y((0,V.jsx)(`path`,{d:`M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zM6 20V4h7v5h5v11z`}),`InsertDriveFileOutlined`),je=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`));function Me({sessionRef:e,refresh:n,active:r,onOpen:i,onFolder:a}){let{locale:o}=x(),[s,u]=(0,B.useState)(()=>new Set([``])),[f,p]=(0,B.useState)(()=>new Map),[m,g]=(0,B.useState)(),_=(t,n)=>{p(e=>new Map(e).set(t,e.get(t)??`loading`)),R(e,t,n).then(e=>{n?.aborted||p(n=>new Map(n).set(t,e))}).catch(()=>{n?.aborted||p(e=>new Map(e).set(t,`error`))})};(0,B.useEffect)(()=>{p(new Map),u(new Set([``]))},[e]),(0,B.useEffect)(()=>{let e=new AbortController;for(let t of s)_(t,e.signal);return()=>e.abort()},[e,n]),(0,B.useEffect)(()=>{if(!r)return;let e=je(r).filter(e=>!s.has(e));if(e.length){u(t=>new Set([...t,...e]));for(let t of e)f.has(t)||_(t)}},[r]);let v=e=>{if(g(e),a(e),s.has(e)){u(t=>{let n=new Set(t);return n.delete(e),n});return}u(t=>new Set(t).add(e)),(!f.has(e)||f.get(e)===`error`)&&_(e)},y=(e,n)=>{let a=f.get(e);return!a||a===`loading`?(0,V.jsx)(h,{size:14,sx:{ml:1.5+n*1.5,my:.5}}):a===`error`?(0,V.jsx)(c,{variant:`caption`,color:`warning.main`,sx:{pl:1.5+n*1.5},children:S(o,`Chưa đọc được thư mục này.`,`This folder could not be read.`)}):(0,V.jsxs)(V.Fragment,{children:[a.entries.map(e=>{let a=e.kind===`directory`,c=a&&s.has(e.path),u=a?m===e.path:r===e.path,f=a?(0,V.jsxs)(V.Fragment,{children:[c?(0,V.jsx)(ke,{sx:{fontSize:16}}):(0,V.jsx)(Oe,{sx:{fontSize:16}}),c?(0,V.jsx)(l,{sx:{fontSize:16}}):(0,V.jsx)(d,{sx:{fontSize:16}})]}):(0,V.jsx)(Ae,{sx:{fontSize:16,ml:`16px`}});return(0,V.jsxs)(t,{children:[(0,V.jsxs)(b,{fullWidth:!0,size:`small`,disabled:e.protected||e.kind===`symlink`||e.kind===`other`,"aria-label":e.protected?`${e.name} (${S(o,`được bảo vệ`,`protected`)})`:e.name,"aria-expanded":a?c:void 0,"aria-current":!a&&r===e.path?`true`:void 0,onClick:()=>a?v(e.path):(g(void 0),i(e.path)),sx:{justifyContent:`flex-start`,textTransform:`none`,gap:.5,minHeight:24,py:0,pl:.5+n*1.5,pr:1,color:`text.primary`,fontWeight:400,whiteSpace:`nowrap`,bgcolor:u?`action.selected`:void 0},children:[f,(0,V.jsxs)(t,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`},children:[e.name,e.protected?` 🔒`:``]})]}),c&&y(e.path,n+1)]},e.path)}),a.truncated&&(0,V.jsx)(c,{variant:`caption`,sx:{pl:1.5+n*1.5},children:S(o,`Danh sách đã được giới hạn.`,`Listing limit reached.`)})]})};return(0,V.jsx)(t,{role:`group`,"aria-label":S(o,`Cây thư mục`,`Folder tree`),sx:{py:.5},children:y(``,0)})}var Ne=(0,B.lazy)(()=>C(()=>import(`./WorkspaceCodeEditor-DUffKV2S.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function Pe({sessionRef:e,target:r,navigationHost:i,sidebarMode:s,onHide:l,fill:d}){let{locale:y}=x(),[C,w]=(0,B.useState)(`files`),[T,E]=(0,B.useState)(!1),[D,te]=(0,B.useState)(``),[k,A]=(0,B.useState)(!1),[j,M]=(0,B.useState)(),[N,P]=(0,B.useState)(``),F=Te(e),{tabs:I,active:L}=F,[ne,re]=(0,B.useState)(``),[ae,R]=(0,B.useState)(!1),[H,U]=(0,B.useState)(!1),W=(0,B.useRef)(null),[ce,le]=(0,B.useState)(0);(0,B.useEffect)(()=>{let t=t=>{t.detail?.sessionRef===e&&le(e=>e+1)};return window.addEventListener(`piagent-workspace-saved`,t),()=>window.removeEventListener(`piagent-workspace-saved`,t)},[e]),(0,B.useEffect)(()=>()=>W.current?.abort(),[]);let G=async(t,n=1)=>{if(W.current?.abort(),U(!1),I.find(e=>e.file.path===t)){F.select(t,n);return}W.current?.abort();let r=new AbortController;W.current=r,U(!0),R(!1);try{let i=await z(e,t,r.signal);if(r.signal.aborted)return;if(i.protected){R(!0);return}F.load(i,n)}catch{r.signal.aborted||R(!0)}finally{r.signal.aborted||U(!1)}};(0,B.useEffect)(()=>{r&&G(r.path,r.line??1)},[r]),(0,B.useEffect)(()=>{s&&s!==`sessions`&&w(s)},[s]);let K=I.find(e=>e.file.path===L),q=K?.file,J=me(e,I,L),Y=se(e,q?.path,q?.digest??null,!!K&&!Q(K),J.diff),X=oe(e,q?.path,K?.draft??``,J.hunks),ue=I.find(e=>e.file.path===F.conflict?.path),de=(0,V.jsxs)(t,{component:`nav`,"aria-label":S(y,`Tệp dự án`,`Project files`),sx:{width:i?`100%`:{xs:136,sm:200},flexShrink:0,overflow:`auto`,borderRight:1,borderColor:`divider`},children:[!i&&(0,V.jsxs)(u,{value:C,onChange:(e,t)=>w(t),"aria-label":S(y,`Khám phá project`,`Explore project`),children:[(0,V.jsx)(f,{value:`files`,label:S(y,`Tệp`,`Files`)}),(0,V.jsx)(f,{value:`search`,label:S(y,`Tìm kiếm`,`Search`)})]}),C===`search`?(0,V.jsx)(De,{sessionRef:e,onOpen:(e,t)=>void G(e,t)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(b,{disabled:!F.authority?.writable,onClick:()=>{te(ne?`${ne}/`:``),E(!0)},children:S(y,`Tệp mới`,`New file`)}),(0,V.jsx)(Me,{sessionRef:e,refresh:ce,active:L,onOpen:e=>{re(e.split(`/`).slice(0,-1).join(`/`)),G(e)},onFolder:re})]})]});return(0,V.jsxs)(V.Fragment,{children:[Y.dialog,X.dialog,(0,V.jsxs)(p,{direction:`row`,sx:{height:d?`100%`:`calc(100vh - 150px)`,minHeight:d?160:320},children:[i?(0,Ee.createPortal)(de,i):de,(0,V.jsxs)(t,{sx:{minWidth:0,flex:1,display:`flex`,flexDirection:`column`},children:[ae&&(0,V.jsx)(g,{severity:`warning`,children:S(y,`Chưa đọc được tệp hoặc thư mục này.`,`This file or folder could not be read.`)}),X.bar,F.message&&(0,V.jsx)(g,{severity:`warning`,children:F.message}),F.authority?.agentRunning&&(0,V.jsx)(g,{severity:`info`,children:S(y,`Agent đang chạy và có thể sửa tệp này.`,`The agent is running and may change this file.`)}),(0,V.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,borderBottom:1,borderColor:`divider`,minHeight:36},children:[(0,V.jsx)(u,{value:L??!1,onChange:(e,t)=>F.select(t),variant:`scrollable`,scrollButtons:`auto`,"aria-label":S(y,`Các tệp đang mở`,`Open files`),sx:{flex:1,minWidth:0,minHeight:36},children:I.map(e=>(0,V.jsx)(f,{value:e.file.path,sx:{minHeight:36,py:0},"aria-label":`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,label:ie(`${e.file.path}${Q(e)?` ●`:``}${J.counts.get(e.file.path)?` (${J.counts.get(e.file.path)})`:``}`,S(y,`Đóng ${e.file.path}`,`Close ${e.file.path}`),()=>F.close(e.file.path))},e.file.path))}),l&&(0,V.jsx)(o,{size:`small`,"aria-label":S(y,`Ẩn khung tệp`,`Hide files panel`),title:S(y,`Ẩn khung tệp (tệp đang mở vẫn giữ)`,`Hide files panel (open files are kept)`),onClick:l,children:(0,V.jsx)(ee,{fontSize:`small`})})]}),H&&(0,V.jsx)(h,{size:20}),q&&(0,V.jsxs)(p,{direction:`row`,sx:{flexShrink:0,overflowX:`auto`,"& .MuiButton-root":{whiteSpace:`nowrap`,flexShrink:0}},children:[Y.hasPending&&(0,V.jsx)(b,{onClick:Y.checkPending,children:S(y,`Kiểm tra hoàn tác`,`Check revert`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!K||!Q(K)&&!K.pending||F.saving,onClick:()=>void F.save(q.path),children:S(y,`Lưu`,`Save`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>F.close(q.path),children:S(y,`Đóng tệp`,`Close file`)}),(0,V.jsx)(b,{size:`small`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{P(q.path),M(q.path)},children:S(y,`Đổi tên`,`Rename`)}),(0,V.jsx)(b,{size:`small`,color:`error`,disabled:!F.authority?.writable||q.readOnly||!q.digest||F.saving,onClick:()=>{window.confirm(S(y,`Xóa ${q.path}? Có thể khôi phục bằng Git nếu tệp đã commit.`,`Delete ${q.path}? Git can restore it if it was committed.`))&&F.move(q.path)},children:S(y,`Xóa`,`Delete`)}),(0,V.jsx)(b,{size:`small`,onClick:()=>{(!K||!Q(K)||window.confirm(S(y,`Bỏ thay đổi chưa lưu và tải lại?`,`Discard unsaved changes and reload?`)))&&F.reload(q.path)},children:S(y,`Tải lại`,`Reload`)})]}),q?.binary||q?.oversized?(0,V.jsx)(g,{severity:`info`,children:S(y,`Tệp nhị phân hoặc quá lớn để hiển thị.`,`This file is binary or too large to display.`)}):q?.content!==null&&q?.content!==void 0?(0,V.jsx)(t,{sx:{flex:1,minHeight:0},children:(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{onComment:X.open,hunks:J.hunks,onKeep:J.keep,onRevert:F.authority?.writable?e=>void Y.request(e):void 0,content:K?.draft??q.content,path:q.path,line:K?.line??1,readOnly:!F.authority?.writable||q.readOnly,onChange:e=>F.change(q.path,e),onSave:()=>void F.save(q.path)})})}):(0,V.jsx)(c,{sx:{p:2},children:S(y,`Chọn một tệp để mở.`,`Select a file to open.`)})]})]}),(0,V.jsxs)(n,{open:T,onClose:()=>E(!1),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Tạo tệp mới`,`Create a new file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn trong project`,`Path in project`),value:D,onChange:e=>te(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>E(!1),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(D)||!F.authority?.writable,onClick:()=>{let e=O(D);!e||!F.authority||(I.some(t=>t.file.path===e.path)?F.select(e.path):F.load({schemaVersion:1,version:`piagent-webui-workspace-file-v1`,generatedAt:new Date().toISOString(),identity:F.authority.identity,path:e.path,language:`text`,protected:!1,readOnly:!1,binary:!1,oversized:!1,content:``,digest:null,revision:null},1,!0),E(!1))},children:S(y,`Tạo`,`Create`)})]})]}),(0,V.jsxs)(n,{open:!!j,onClose:()=>M(void 0),fullWidth:!0,children:[(0,V.jsx)(m,{children:S(y,`Đổi tên tệp`,`Rename file`)}),(0,V.jsx)(_,{children:(0,V.jsx)(v,{autoFocus:!0,fullWidth:!0,label:S(y,`Đường dẫn mới trong project`,`New path in project`),value:N,onChange:e=>P(e.target.value)})}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>M(void 0),children:S(y,`Hủy`,`Cancel`)}),(0,V.jsx)(b,{disabled:!O(N)||O(N)?.path===j||F.saving,onClick:()=>{let e=O(N);!e||!j||F.move(j,e.path).then(e=>{e&&M(void 0)})},children:S(y,`Đổi tên`,`Rename`)})]})]}),(0,V.jsxs)(n,{open:!!F.conflict,onClose:()=>{F.setConflict(void 0),A(!1)},fullWidth:!0,maxWidth:k?`lg`:`sm`,children:[(0,V.jsx)(m,{children:S(y,`Tệp đã thay đổi trên đĩa`,`The file changed on disk`)}),(0,V.jsxs)(_,{children:[(0,V.jsx)(c,{children:F.conflict?.path}),(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn vẫn được giữ. Chọn cách xử lý xung đột.`,`Your draft is preserved. Choose how to resolve the conflict.`)}),k&&F.conflict&&ue&&(0,V.jsxs)(p,{direction:`row`,spacing:1,children:[(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Trên đĩa`,`On disk`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:F.conflict.path,content:F.conflict.content??``})})]}),(0,V.jsxs)(t,{sx:{width:`50%`,height:360},children:[(0,V.jsx)(c,{children:S(y,`Bản sửa của bạn`,`Your draft`)}),(0,V.jsx)(B.Suspense,{fallback:(0,V.jsx)(h,{size:20}),children:(0,V.jsx)(Ne,{path:ue.file.path,content:ue.draft})})]})]})]}),(0,V.jsxs)(a,{children:[(0,V.jsx)(b,{onClick:()=>{F.setConflict(void 0),A(!1)},children:S(y,`Để sau`,`Later`)}),(0,V.jsx)(b,{onClick:()=>{F.conflict&&(F.load(F.conflict),F.setConflict(void 0),A(!1))},children:S(y,`Tải lại`,`Reload`)}),(0,V.jsx)(b,{onClick:()=>A(!0),children:S(y,`Xem khác biệt`,`Compare`)}),(0,V.jsx)(b,{disabled:F.saving||!F.conflict?.digest||F.conflict.protected||F.conflict.readOnly,onClick:()=>{F.conflict&&F.save(F.conflict.path,F.conflict)},children:S(y,`Ghi đè`,`Overwrite`)})]})]})]})}export{Pe as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InspectionApp-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InspectionApp-C00GhY47.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-CA5pzJiI.js","assets/bootstrap-CedkNtRG.js","assets/api-BUjrtT1B.js","assets/latest-request-DXcYQW86.js","assets/App-CarM9drO.js","assets/ui-preferences-Dy4qeODT.js","assets/ActivityPanel-DRAiHliI.js","assets/view-model-CWNiS4JN.js","assets/workspace-navigation-C8GtShbg.js","assets/transcript-view-model-BNGQCkzY.js","assets/LineReview-DZ9ez8kO.js","assets/GatewayApp-uqpLU6gs.js","assets/SettingsNavigation-CM0s3QUC.js","assets/composer-drafts-BtMaVw8W.js","assets/terminal-transport-Dk5pYNX5.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{Bt as n,Dn as r,En as i,Fn as a,In as o,Mn as s,Nn as c,On as l,Pn as u,Tn as d,Vt as f,_n as p,bn as m,dn as h,gn as g,hn as _,on as v,pn as y,sn as b,un as x,wn as S,yn as C,zt as ee}from"./vendor-CA5pzJiI.js";import{a as te,n as ne,o as re,s as ie,t as ae}from"./ui-preferences-Dy4qeODT.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var oe=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,ie());else{var t=n(l);t!==null&&se(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,te=-1;function ne(){return g?!0:!(e.unstable_now()-te<ee)}function re(){if(g=!1,S){var t=e.unstable_now();te=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&ne());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&se(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?ie():S=!1}}}var ie;if(typeof y==`function`)ie=function(){y(re)};else if(typeof MessageChannel<`u`){var ae=new MessageChannel,oe=ae.port2;ae.port1.onmessage=re,ie=function(){oe.postMessage(null)}}else ie=function(){_(re,0)};function se(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):ee=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,se(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ie()))),r},e.unstable_shouldYield=ne,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),se=t(((e,t)=>{t.exports=oe()})),ce=t((e=>{var t=se(),n=o(),r=a();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var o=a.alternate;if(o===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===o.child){for(o=a.child;o;){if(o===n)return d(a),e;if(o===r)return d(a),t;o=o.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=o;else{for(var s=!1,l=a.child;l;){if(l===n){s=!0,n=a,r=o;break}if(l===r){s=!0,r=a,n=o;break}l=l.sibling}if(!s){for(l=o.child;l;){if(l===n){s=!0,n=o,r=a;break}if(l===r){s=!0,r=o,n=a;break}l=l.sibling}if(!s)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.iterator;function ce(e){return typeof e!=`object`||!e?null:(e=oe&&e[oe]||e[`@@iterator`],typeof e==`function`?e:null)}var le=Symbol.for(`react.client.reference`);function w(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===le?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case ee:return`Suspense`;case te:return`SuspenseList`;case ie:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?w(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return w(e(t))}catch{}}return null}var ue=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D={pending:!1,data:null,method:null,action:null},de=[],fe=-1;function pe(e){return{current:e}}function O(e){0>fe||(e.current=de[fe],de[fe]=null,fe--)}function k(e,t){fe++,de[fe]=e.current,e.current=t}var me=pe(null),he=pe(null),ge=pe(null),_e=pe(null);function ve(e,t){switch(k(ge,t),k(he,e),k(me,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}O(me),k(me,e)}function ye(){O(me),O(he),O(ge)}function be(e){e.memoizedState!==null&&k(_e,e);var t=me.current,n=Hd(t,e.type);t!==n&&(k(he,e),k(me,n))}function xe(e){he.current===e&&(O(me),O(he)),_e.current===e&&(O(_e),Qf._currentValue=D)}var Se,Ce;function we(e){if(Se===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Se=t&&t[1]||``,Ce=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Se+e+Ce}var Te=!1;function Ee(e,t){if(!e||Te)return``;Te=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
@@ -34,4 +34,4 @@ try {
|
|
|
34
34
|
if (colorScheme) {
|
|
35
35
|
${l}
|
|
36
36
|
}
|
|
37
|
-
} catch(e){}})();`}},`mui-color-scheme-init`)}function ye(){}var be=({key:e,storageWindow:t})=>(!t&&typeof window<`u`&&(t=window),{get(n){if(typeof window>`u`)return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return ye;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function xe(){}function Se(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Ce(e,t){if(e.mode===`light`||e.mode===`system`&&e.systemMode===`light`)return t(`light`);if(e.mode===`dark`||e.mode===`system`&&e.systemMode===`dark`)return t(`dark`)}function we(e){return Ce(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Te(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=he,colorSchemeStorageKey:o=ge,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=be,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=w.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=w.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=w.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=w.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Se(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=w.useState(l||!d);w.useEffect(()=>{v(!0)},[]);let y=we(h),b=w.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Se(r)}})},[f,t]),x=w.useCallback(e=>{e?typeof e==`string`?e&&!u.includes(e)?console.error(`\`${e}\` does not exist in \`theme.colorSchemes\`.`):g(t=>{let n={...t};return Ce(t,t=>{t===`light`&&(p?.set(e),n.lightColorScheme=e),t===`dark`&&(m?.set(e),n.darkColorScheme=e)}),n}):g(t=>{let i={...t},a=e.light===null?n:e.light,o=e.dark===null?r:e.dark;return a&&(u.includes(a)?(i.lightColorScheme=a,p?.set(a)):console.error(`\`${a}\` does not exist in \`theme.colorSchemes\`.`)),o&&(u.includes(o)?(i.darkColorScheme=o,m?.set(o)):console.error(`\`${o}\` does not exist in \`theme.colorSchemes\`.`)),i}):g(e=>(p?.set(n),m?.set(r),{...e,lightColorScheme:n,darkColorScheme:r}))},[u,p,m,n,r]),S=w.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),C=w.useRef(S);return C.current=S,w.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>C.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),w.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||xe,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||xe,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||xe;return()=>{e(),n(),r()}}},[x,b,u,t,s,d,f,p,m]),{...h,mode:_?h.mode:void 0,systemMode:_?h.systemMode:void 0,colorScheme:_?y:void 0,setMode:b,setColorScheme:x}}var Ee=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function De(e){let{themeId:t,theme:n={},modeStorageKey:r=he,colorSchemeStorageKey:a=ge,disableTransitionOnChange:o=!1,defaultColorScheme:s,resolveTheme:c}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},u=w.createContext(void 0),d=()=>w.useContext(u)||l,f={},p={};function h(e){let{children:l,theme:d,modeStorageKey:h=r,colorSchemeStorageKey:g=a,disableTransitionOnChange:_=o,storageManager:v,storageWindow:y=typeof window>`u`?void 0:window,documentNode:b=typeof document>`u`?void 0:document,colorSchemeNode:x=typeof document>`u`?void 0:document.documentElement,disableNestedContext:S=!1,disableStyleSheetGeneration:C=!1,defaultMode:ee=`system`,forceThemeRerender:te=!1,noSsr:ne}=e,re=w.useRef(!1),ie=T(),ae=w.useContext(u),oe=!!ae&&!S,se=w.useMemo(()=>d||(typeof n==`function`?n():n),[d]),ce=se[t],le=ce||se,{colorSchemes:ue=f,components:E=p,cssVarPrefix:de}=le,fe=Object.keys(ue).filter(e=>!!ue[e]).join(`,`),pe=w.useMemo(()=>fe.split(`,`),[fe]),O=typeof s==`string`?s:s.light,k=typeof s==`string`?s:s.dark,{mode:he,setMode:ge,systemMode:_e,lightColorScheme:ve,darkColorScheme:ye,colorScheme:be,setColorScheme:xe}=Te({supportedColorSchemes:pe,defaultLightColorScheme:O,defaultDarkColorScheme:k,modeStorageKey:h,colorSchemeStorageKey:g,defaultMode:ue[O]&&ue[k]?ee:ue[le.defaultColorScheme]?.palette?.mode||le.palette?.mode,storageManager:v,storageWindow:y,noSsr:ne}),Se=he,Ce=be;oe&&(Se=ae.mode,Ce=ae.colorScheme);let we=Ce||le.defaultColorScheme;le.vars&&!te&&(we=le.defaultColorScheme);let De=w.useMemo(()=>{let e=le.generateThemeVars?.()||le.vars,t={...le,components:E,colorSchemes:ue,cssVarPrefix:de,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),we){let e=ue[we];e&&typeof e==`object`&&Object.keys(e).forEach(n=>{e[n]&&typeof e[n]==`object`?t[n]={...t[n],...e[n]}:t[n]=e[n]})}return c?c(t):t},[le,we,E,ue,de]),Oe=le.colorSchemeSelector;m(()=>{if(Ce&&x&&Oe&&Oe!==`media`){let e=Oe,t=Oe;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))x.classList.remove(...pe.map(e=>t.substring(1).replace(`%s`,e))),x.classList.add(t.substring(1).replace(`%s`,Ce));else{let e=t.replace(`%s`,Ce).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||pe.forEach(e=>{x.removeAttribute(t.replace(Ce,e))}),x.setAttribute(t,n?n.replace(/"|'/g,``):``)}else x.setAttribute(t,Ce)}}},[Ce,Oe,x,pe]),w.useEffect(()=>{let e;if(_&&re.current&&b){let t=b.createElement(`style`);t.appendChild(b.createTextNode(Ee)),b.head.appendChild(t),window.getComputedStyle(b.body),e=setTimeout(()=>{b.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[Ce,_,b]),w.useEffect(()=>(re.current=!0,()=>{re.current=!1}),[]);let ke=w.useMemo(()=>({allColorSchemes:pe,colorScheme:Ce,darkColorScheme:ye,lightColorScheme:ve,mode:Se,setColorScheme:xe,setMode:ge,systemMode:_e}),[pe,Ce,ye,ve,Se,xe,ge,_e,De.colorSchemeSelector]),Ae=!0;(C||le.cssVariables===!1||oe&&ie?.cssVarPrefix===de)&&(Ae=!1);let je=(0,D.jsxs)(w.Fragment,{children:[(0,D.jsx)(me,{themeId:ce?t:void 0,theme:De,children:l}),Ae&&(0,D.jsx)(i,{styles:De.generateStyleSheets?.()||[]})]});return oe?je:(0,D.jsx)(u.Provider,{value:ke,children:je})}let g=typeof s==`string`?s:s.light,_=typeof s==`string`?s:s.dark;return{CssVarsProvider:h,useColorScheme:d,getInitColorSchemeScript:e=>ve({colorSchemeStorageKey:a,defaultLightColorScheme:g,defaultDarkColorScheme:_,modeStorageKey:r,...e})}}var Oe=typeof b({})==`function`,ke=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),Ae=e=>({color:(e.vars||e).palette.text.primary,...e.typography.body1,backgroundColor:(e.vars||e).palette.background.default,"@media print":{backgroundColor:(e.vars||e).palette.common.white}}),je=(e,t=!1)=>{let n={};t&&e.colorSchemes&&typeof e.getColorSchemeSelector==`function`&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={":root":{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={colorScheme:r.palette?.mode}});let r={html:ke(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...Ae(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},Me=`mui-ecs`,Ne=e=>{let t=je(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${Me})`]={colorScheme:e.palette.mode}),e.colorSchemes&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={[`:root:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}}),t},Pe=b(Oe?({theme:e,enableColorScheme:t})=>je(e,t):({theme:e})=>Ne(e));function Fe(e){let{children:t,enableColorScheme:n=!1}=v({props:e,name:`MuiCssBaseline`});return(0,D.jsxs)(w.Fragment,{children:[Oe&&(0,D.jsx)(Pe,{enableColorScheme:n}),!Oe&&!n&&(0,D.jsx)(`span`,{className:Me,style:{display:`none`}}),t]})}function Ie({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,D.jsx)(me,{...t,themeId:n?x:void 0,theme:n||e})}var Le={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:Re,useColorScheme:ze,getInitColorSchemeScript:Be}=De({themeId:x,theme:()=>h({cssVariables:!0}),colorSchemeStorageKey:Le.colorSchemeStorageKey,modeStorageKey:Le.modeStorageKey,defaultColorScheme:{light:Le.defaultLightColorScheme,dark:Le.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:y(e.palette,e.typography)};return t.unstable_sx=function(e){return l({sx:e,theme:this})},t}}),Ve=Re;function He({theme:e,...t}){let n=w.useMemo(()=>{if(typeof e==`function`)return e;let t=`$$material`in e?e[x]:e;return`colorSchemes`in t?null:`vars`in t?e:{...e,vars:null}},[e]);return n?(0,D.jsx)(Ie,{theme:n,...t}):(0,D.jsx)(Ve,{theme:e,...t})}var Ue=le(),We=class extends w.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){let{locale:e,children:t}=this.props;return this.state.failed?(0,D.jsxs)(n,{sx:{p:3},children:[(0,D.jsx)(f,{severity:`error`,children:ne(e,`Không tải được giao diện. Vui lòng tải lại để thử lại.`,`Could not load this view. Reload to try again.`)}),(0,D.jsx)(ee,{onClick:()=>window.location.reload(),children:ne(e,`Tải lại trang`,`Reload page`)})]}):(0,D.jsx)(w.Suspense,{fallback:(0,D.jsx)(n,{role:`status`,sx:{p:3},children:ne(e,`Đang tải giao diện…`,`Loading view…`)}),children:t})}};function Ge(e){let t=e.mode===`dark`,n=e.mode,{primary:r,secondary:i,background:a,paper:o,text:s,muted:c,divider:l}=e,u=t?`0 16px 48px -12px ${C(`#000`,.7)}, 0 0 0 1px ${C(s,.06)}`:`0 16px 40px -16px ${C(`#1a1a2e`,.25)}, 0 0 0 1px ${C(s,.06)}`,d=`0 0 0 3px ${C(r,t?.28:.22)}`;return h({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:n,primary:{main:r,contrastText:e.onPrimary},secondary:{main:i},success:{main:i},warning:{main:e.warning},error:{main:e.error},background:{default:a,paper:o},text:{primary:s,secondary:c,disabled:c},divider:l,action:{hover:C(s,.05),selected:C(s,.08),focus:C(r,.14)}},shape:{borderRadius:6},transitions:{duration:{shortest:120,shorter:160,short:180,standard:200,complex:260,enteringScreen:200,leavingScreen:160}},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif`,fontSize:14,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.6rem`,fontWeight:650,letterSpacing:`-0.03em`,lineHeight:1.2},h2:{fontSize:`1.15rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`0.95rem`,fontWeight:600},body2:{fontSize:`0.8125rem`},button:{fontSize:`0.8125rem`,fontWeight:550,textTransform:`none`,letterSpacing:0},caption:{fontSize:`0.72rem`,letterSpacing:0},overline:{fontSize:`0.68rem`,fontWeight:600,letterSpacing:`0.08em`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:a,WebkitFontSmoothing:`antialiased`},body:{minWidth:320,minHeight:`100vh`,backgroundColor:a},"::selection":{backgroundColor:C(r,.28)},"*":{scrollbarWidth:`thin`,scrollbarColor:`${C(s,.18)} transparent`}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButtonBase:{defaultProps:{disableRipple:!0}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:32,borderRadius:8,paddingInline:12,transition:`background-color .16s, border-color .16s, box-shadow .16s, color .16s`,"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{minHeight:28,paddingInline:10,fontSize:`0.78rem`},outlined:{borderColor:C(s,.14),"&:hover":{borderColor:C(s,.28),backgroundColor:C(s,.04)}},contained:{"&.MuiButton-colorPrimary:hover":{backgroundColor:C(r,.88),boxShadow:`0 0 0 3px ${C(r,.18)}`}},text:{"&:hover":{backgroundColor:C(s,.06)}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:8,color:c,transition:`background-color .16s, color .16s`,"&:hover":{color:s,backgroundColor:C(s,.07)},"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{padding:5}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:999,fontWeight:500,fontSize:`0.75rem`},outlined:{borderColor:C(s,.14)},label:{paddingInline:9}}},MuiListItemButton:{styleOverrides:{root:{minHeight:36,margin:`1px 8px`,borderRadius:8,color:c,transition:`background-color .12s, color .12s`,"&:hover":{backgroundColor:C(s,.05),color:s},"&.Mui-selected":{color:s,backgroundColor:C(s,t?.08:.07)},"&.Mui-selected:hover":{backgroundColor:C(s,t?.11:.09)},"&.Mui-focusVisible":{boxShadow:d}}}},MuiTabs:{styleOverrides:{root:{minHeight:40},indicator:{height:2,borderRadius:2}}},MuiTab:{styleOverrides:{root:{minHeight:40,paddingInline:14,textTransform:`none`,fontWeight:550,fontSize:`0.8125rem`,color:c,"&.Mui-selected":{color:s}}}},MuiOutlinedInput:{styleOverrides:{root:{borderRadius:8,backgroundColor:C(s,t?.03:.02),transition:`box-shadow .16s`,"& .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.12)},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.24)},"&.Mui-focused":{boxShadow:d},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:r,borderWidth:1}}}},MuiTooltip:{defaultProps:{arrow:!1,enterDelay:350},styleOverrides:{tooltip:{fontSize:`0.75rem`,fontWeight:500,padding:`5px 9px`,borderRadius:6,color:t?s:`#fafafa`,backgroundColor:t?C(o,.98):`#1f1f24`,boxShadow:u}}},MuiMenu:{styleOverrides:{paper:{borderRadius:10,boxShadow:u,backgroundImage:`none`,marginTop:4},list:{padding:4}}},MuiPopover:{styleOverrides:{paper:{borderRadius:10,boxShadow:u}}},MuiMenuItem:{styleOverrides:{root:{minHeight:32,borderRadius:6,fontSize:`0.8125rem`,"&:hover":{backgroundColor:C(s,.06)},"&.Mui-selected":{backgroundColor:C(r,.12)}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:14,boxShadow:u,backgroundImage:`none`}}},MuiBackdrop:{styleOverrides:{root:{backgroundColor:C(`#000`,t?.6:.32),backdropFilter:`blur(2px)`}}},MuiDrawer:{styleOverrides:{paper:{backgroundImage:`none`,backgroundColor:o}}},MuiAlert:{styleOverrides:{root:{borderRadius:10,border:`1px solid ${C(s,.1)}`,fontSize:`0.8125rem`,alignItems:`center`}}},MuiDivider:{styleOverrides:{root:{borderColor:l}}},MuiLinearProgress:{styleOverrides:{root:{borderRadius:999,height:4},bar:{borderRadius:999}}}}})}function Ke(e){for(let t of e??[]){let e=String(t).toLowerCase().split(`-`)[0];if(e===`vi`)return`vi`;if(e)return`en`}return`en`}var qe=`modulepreload`,Je=function(e){return`/`+e},Ye={},Xe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Je(t,n),t=s(t),t in Ye)return;Ye[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:qe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ze=document.getElementById(`root`);if(!Ze)throw Error(`Piagent WebUI root is missing`);var Qe=document.querySelector(`meta[name="csp-nonce"]`)?.content,$e=u({key:`piagent-mui`,nonce:Qe&&!Qe.startsWith(`__PIAGENT_`)?Qe:void 0,prepend:!0}),et=(0,w.lazy)(()=>Xe(()=>import(`./InspectionApp-DtDc9NxN.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),tt=(0,w.lazy)(()=>Xe(()=>import(`./GatewayApp-awcOLVTi.js`),__vite__mapDeps([13,1,2,7,3,4,9,14,10,11,15,5,16])));function nt(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function rt(){let[e,t]=(0,w.useState)(()=>nt(`piagent-webui-locale`,[`vi`,`en`],Ke(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,w.useState)(()=>nt(`piagent-webui-theme`,re.map(e=>e.id),``)||te[nt(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)]),i=ie(n)??ie(te.dark),a=i.mode,o=(0,w.useCallback)(e=>r(t=>ie(t)?.mode===e?t:te[e]),[]),s=(0,w.useMemo)(()=>Ge(i),[i]);(0,w.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=a,document.documentElement.dataset.piagentTheme=i.id;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,a),window.localStorage.setItem(`piagent-webui-theme`,i.id)}catch{}},[a,e,i]);let c=(0,w.useMemo)(()=>({locale:e,colorMode:a,themeId:i.id,setLocale:t,setColorMode:o,setThemeId:r}),[a,e,i,o]),l=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,D.jsx)(ae,{value:c,children:(0,D.jsxs)(He,{theme:s,children:[(0,D.jsx)(Fe,{}),(0,D.jsx)(We,{locale:e,children:l===`gateway`?(0,D.jsx)(tt,{}):(0,D.jsx)(et,{})})]})})}(0,Ue.createRoot)(Ze).render((0,D.jsx)(w.StrictMode,{children:(0,D.jsx)(s,{value:$e,children:(0,D.jsx)(rt,{})})}));export{We as n,Xe as t};
|
|
37
|
+
} catch(e){}})();`}},`mui-color-scheme-init`)}function ye(){}var be=({key:e,storageWindow:t})=>(!t&&typeof window<`u`&&(t=window),{get(n){if(typeof window>`u`)return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return ye;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function xe(){}function Se(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Ce(e,t){if(e.mode===`light`||e.mode===`system`&&e.systemMode===`light`)return t(`light`);if(e.mode===`dark`||e.mode===`system`&&e.systemMode===`dark`)return t(`dark`)}function we(e){return Ce(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Te(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=he,colorSchemeStorageKey:o=ge,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=be,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=w.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=w.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=w.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=w.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Se(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=w.useState(l||!d);w.useEffect(()=>{v(!0)},[]);let y=we(h),b=w.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Se(r)}})},[f,t]),x=w.useCallback(e=>{e?typeof e==`string`?e&&!u.includes(e)?console.error(`\`${e}\` does not exist in \`theme.colorSchemes\`.`):g(t=>{let n={...t};return Ce(t,t=>{t===`light`&&(p?.set(e),n.lightColorScheme=e),t===`dark`&&(m?.set(e),n.darkColorScheme=e)}),n}):g(t=>{let i={...t},a=e.light===null?n:e.light,o=e.dark===null?r:e.dark;return a&&(u.includes(a)?(i.lightColorScheme=a,p?.set(a)):console.error(`\`${a}\` does not exist in \`theme.colorSchemes\`.`)),o&&(u.includes(o)?(i.darkColorScheme=o,m?.set(o)):console.error(`\`${o}\` does not exist in \`theme.colorSchemes\`.`)),i}):g(e=>(p?.set(n),m?.set(r),{...e,lightColorScheme:n,darkColorScheme:r}))},[u,p,m,n,r]),S=w.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),C=w.useRef(S);return C.current=S,w.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>C.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),w.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||xe,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||xe,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||xe;return()=>{e(),n(),r()}}},[x,b,u,t,s,d,f,p,m]),{...h,mode:_?h.mode:void 0,systemMode:_?h.systemMode:void 0,colorScheme:_?y:void 0,setMode:b,setColorScheme:x}}var Ee=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function De(e){let{themeId:t,theme:n={},modeStorageKey:r=he,colorSchemeStorageKey:a=ge,disableTransitionOnChange:o=!1,defaultColorScheme:s,resolveTheme:c}=e,l={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},u=w.createContext(void 0),d=()=>w.useContext(u)||l,f={},p={};function h(e){let{children:l,theme:d,modeStorageKey:h=r,colorSchemeStorageKey:g=a,disableTransitionOnChange:_=o,storageManager:v,storageWindow:y=typeof window>`u`?void 0:window,documentNode:b=typeof document>`u`?void 0:document,colorSchemeNode:x=typeof document>`u`?void 0:document.documentElement,disableNestedContext:S=!1,disableStyleSheetGeneration:C=!1,defaultMode:ee=`system`,forceThemeRerender:te=!1,noSsr:ne}=e,re=w.useRef(!1),ie=T(),ae=w.useContext(u),oe=!!ae&&!S,se=w.useMemo(()=>d||(typeof n==`function`?n():n),[d]),ce=se[t],le=ce||se,{colorSchemes:ue=f,components:E=p,cssVarPrefix:de}=le,fe=Object.keys(ue).filter(e=>!!ue[e]).join(`,`),pe=w.useMemo(()=>fe.split(`,`),[fe]),O=typeof s==`string`?s:s.light,k=typeof s==`string`?s:s.dark,{mode:he,setMode:ge,systemMode:_e,lightColorScheme:ve,darkColorScheme:ye,colorScheme:be,setColorScheme:xe}=Te({supportedColorSchemes:pe,defaultLightColorScheme:O,defaultDarkColorScheme:k,modeStorageKey:h,colorSchemeStorageKey:g,defaultMode:ue[O]&&ue[k]?ee:ue[le.defaultColorScheme]?.palette?.mode||le.palette?.mode,storageManager:v,storageWindow:y,noSsr:ne}),Se=he,Ce=be;oe&&(Se=ae.mode,Ce=ae.colorScheme);let we=Ce||le.defaultColorScheme;le.vars&&!te&&(we=le.defaultColorScheme);let De=w.useMemo(()=>{let e=le.generateThemeVars?.()||le.vars,t={...le,components:E,colorSchemes:ue,cssVarPrefix:de,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),we){let e=ue[we];e&&typeof e==`object`&&Object.keys(e).forEach(n=>{e[n]&&typeof e[n]==`object`?t[n]={...t[n],...e[n]}:t[n]=e[n]})}return c?c(t):t},[le,we,E,ue,de]),Oe=le.colorSchemeSelector;m(()=>{if(Ce&&x&&Oe&&Oe!==`media`){let e=Oe,t=Oe;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))x.classList.remove(...pe.map(e=>t.substring(1).replace(`%s`,e))),x.classList.add(t.substring(1).replace(`%s`,Ce));else{let e=t.replace(`%s`,Ce).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||pe.forEach(e=>{x.removeAttribute(t.replace(Ce,e))}),x.setAttribute(t,n?n.replace(/"|'/g,``):``)}else x.setAttribute(t,Ce)}}},[Ce,Oe,x,pe]),w.useEffect(()=>{let e;if(_&&re.current&&b){let t=b.createElement(`style`);t.appendChild(b.createTextNode(Ee)),b.head.appendChild(t),window.getComputedStyle(b.body),e=setTimeout(()=>{b.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[Ce,_,b]),w.useEffect(()=>(re.current=!0,()=>{re.current=!1}),[]);let ke=w.useMemo(()=>({allColorSchemes:pe,colorScheme:Ce,darkColorScheme:ye,lightColorScheme:ve,mode:Se,setColorScheme:xe,setMode:ge,systemMode:_e}),[pe,Ce,ye,ve,Se,xe,ge,_e,De.colorSchemeSelector]),Ae=!0;(C||le.cssVariables===!1||oe&&ie?.cssVarPrefix===de)&&(Ae=!1);let je=(0,D.jsxs)(w.Fragment,{children:[(0,D.jsx)(me,{themeId:ce?t:void 0,theme:De,children:l}),Ae&&(0,D.jsx)(i,{styles:De.generateStyleSheets?.()||[]})]});return oe?je:(0,D.jsx)(u.Provider,{value:ke,children:je})}let g=typeof s==`string`?s:s.light,_=typeof s==`string`?s:s.dark;return{CssVarsProvider:h,useColorScheme:d,getInitColorSchemeScript:e=>ve({colorSchemeStorageKey:a,defaultLightColorScheme:g,defaultDarkColorScheme:_,modeStorageKey:r,...e})}}var Oe=typeof b({})==`function`,ke=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),Ae=e=>({color:(e.vars||e).palette.text.primary,...e.typography.body1,backgroundColor:(e.vars||e).palette.background.default,"@media print":{backgroundColor:(e.vars||e).palette.common.white}}),je=(e,t=!1)=>{let n={};t&&e.colorSchemes&&typeof e.getColorSchemeSelector==`function`&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={":root":{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={colorScheme:r.palette?.mode}});let r={html:ke(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...Ae(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},Me=`mui-ecs`,Ne=e=>{let t=je(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${Me})`]={colorScheme:e.palette.mode}),e.colorSchemes&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={[`:root:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${Me}))`]:{colorScheme:r.palette?.mode}}}),t},Pe=b(Oe?({theme:e,enableColorScheme:t})=>je(e,t):({theme:e})=>Ne(e));function Fe(e){let{children:t,enableColorScheme:n=!1}=v({props:e,name:`MuiCssBaseline`});return(0,D.jsxs)(w.Fragment,{children:[Oe&&(0,D.jsx)(Pe,{enableColorScheme:n}),!Oe&&!n&&(0,D.jsx)(`span`,{className:Me,style:{display:`none`}}),t]})}function Ie({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,D.jsx)(me,{...t,themeId:n?x:void 0,theme:n||e})}var Le={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:Re,useColorScheme:ze,getInitColorSchemeScript:Be}=De({themeId:x,theme:()=>h({cssVariables:!0}),colorSchemeStorageKey:Le.colorSchemeStorageKey,modeStorageKey:Le.modeStorageKey,defaultColorScheme:{light:Le.defaultLightColorScheme,dark:Le.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:y(e.palette,e.typography)};return t.unstable_sx=function(e){return l({sx:e,theme:this})},t}}),Ve=Re;function He({theme:e,...t}){let n=w.useMemo(()=>{if(typeof e==`function`)return e;let t=`$$material`in e?e[x]:e;return`colorSchemes`in t?null:`vars`in t?e:{...e,vars:null}},[e]);return n?(0,D.jsx)(Ie,{theme:n,...t}):(0,D.jsx)(Ve,{theme:e,...t})}var Ue=le(),We=class extends w.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){let{locale:e,children:t}=this.props;return this.state.failed?(0,D.jsxs)(n,{sx:{p:3},children:[(0,D.jsx)(f,{severity:`error`,children:ne(e,`Không tải được giao diện. Vui lòng tải lại để thử lại.`,`Could not load this view. Reload to try again.`)}),(0,D.jsx)(ee,{onClick:()=>window.location.reload(),children:ne(e,`Tải lại trang`,`Reload page`)})]}):(0,D.jsx)(w.Suspense,{fallback:(0,D.jsx)(n,{role:`status`,sx:{p:3},children:ne(e,`Đang tải giao diện…`,`Loading view…`)}),children:t})}};function Ge(e){let t=e.mode===`dark`,n=e.mode,{primary:r,secondary:i,background:a,paper:o,text:s,muted:c,divider:l}=e,u=t?`0 16px 48px -12px ${C(`#000`,.7)}, 0 0 0 1px ${C(s,.06)}`:`0 16px 40px -16px ${C(`#1a1a2e`,.25)}, 0 0 0 1px ${C(s,.06)}`,d=`0 0 0 3px ${C(r,t?.28:.22)}`;return h({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:n,primary:{main:r,contrastText:e.onPrimary},secondary:{main:i},success:{main:i},warning:{main:e.warning},error:{main:e.error},background:{default:a,paper:o},text:{primary:s,secondary:c,disabled:c},divider:l,action:{hover:C(s,.05),selected:C(s,.08),focus:C(r,.14)}},shape:{borderRadius:6},transitions:{duration:{shortest:120,shorter:160,short:180,standard:200,complex:260,enteringScreen:200,leavingScreen:160}},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif`,fontSize:14,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.6rem`,fontWeight:650,letterSpacing:`-0.03em`,lineHeight:1.2},h2:{fontSize:`1.15rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`0.95rem`,fontWeight:600},body2:{fontSize:`0.8125rem`},button:{fontSize:`0.8125rem`,fontWeight:550,textTransform:`none`,letterSpacing:0},caption:{fontSize:`0.72rem`,letterSpacing:0},overline:{fontSize:`0.68rem`,fontWeight:600,letterSpacing:`0.08em`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:a,WebkitFontSmoothing:`antialiased`},body:{minWidth:320,minHeight:`100vh`,backgroundColor:a},"::selection":{backgroundColor:C(r,.28)},"*":{scrollbarWidth:`thin`,scrollbarColor:`${C(s,.18)} transparent`}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButtonBase:{defaultProps:{disableRipple:!0}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:32,borderRadius:8,paddingInline:12,transition:`background-color .16s, border-color .16s, box-shadow .16s, color .16s`,"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{minHeight:28,paddingInline:10,fontSize:`0.78rem`},outlined:{borderColor:C(s,.14),"&:hover":{borderColor:C(s,.28),backgroundColor:C(s,.04)}},contained:{"&.MuiButton-colorPrimary:hover":{backgroundColor:C(r,.88),boxShadow:`0 0 0 3px ${C(r,.18)}`}},text:{"&:hover":{backgroundColor:C(s,.06)}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:8,color:c,transition:`background-color .16s, color .16s`,"&:hover":{color:s,backgroundColor:C(s,.07)},"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{padding:5}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:999,fontWeight:500,fontSize:`0.75rem`},outlined:{borderColor:C(s,.14)},label:{paddingInline:9}}},MuiListItemButton:{styleOverrides:{root:{minHeight:36,margin:`1px 8px`,borderRadius:8,color:c,transition:`background-color .12s, color .12s`,"&:hover":{backgroundColor:C(s,.05),color:s},"&.Mui-selected":{color:s,backgroundColor:C(s,t?.08:.07)},"&.Mui-selected:hover":{backgroundColor:C(s,t?.11:.09)},"&.Mui-focusVisible":{boxShadow:d}}}},MuiTabs:{styleOverrides:{root:{minHeight:40},indicator:{height:2,borderRadius:2}}},MuiTab:{styleOverrides:{root:{minHeight:40,paddingInline:14,textTransform:`none`,fontWeight:550,fontSize:`0.8125rem`,color:c,"&.Mui-selected":{color:s}}}},MuiOutlinedInput:{styleOverrides:{root:{borderRadius:8,backgroundColor:C(s,t?.03:.02),transition:`box-shadow .16s`,"& .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.12)},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:C(s,.24)},"&.Mui-focused":{boxShadow:d},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:r,borderWidth:1}}}},MuiTooltip:{defaultProps:{arrow:!1,enterDelay:350},styleOverrides:{tooltip:{fontSize:`0.75rem`,fontWeight:500,padding:`5px 9px`,borderRadius:6,color:t?s:`#fafafa`,backgroundColor:t?C(o,.98):`#1f1f24`,boxShadow:u}}},MuiMenu:{styleOverrides:{paper:{borderRadius:10,boxShadow:u,backgroundImage:`none`,marginTop:4},list:{padding:4}}},MuiPopover:{styleOverrides:{paper:{borderRadius:10,boxShadow:u}}},MuiMenuItem:{styleOverrides:{root:{minHeight:32,borderRadius:6,fontSize:`0.8125rem`,"&:hover":{backgroundColor:C(s,.06)},"&.Mui-selected":{backgroundColor:C(r,.12)}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:14,boxShadow:u,backgroundImage:`none`}}},MuiBackdrop:{styleOverrides:{root:{backgroundColor:C(`#000`,t?.6:.32),backdropFilter:`blur(2px)`}}},MuiDrawer:{styleOverrides:{paper:{backgroundImage:`none`,backgroundColor:o}}},MuiAlert:{styleOverrides:{root:{borderRadius:10,border:`1px solid ${C(s,.1)}`,fontSize:`0.8125rem`,alignItems:`center`}}},MuiDivider:{styleOverrides:{root:{borderColor:l}}},MuiLinearProgress:{styleOverrides:{root:{borderRadius:999,height:4},bar:{borderRadius:999}}}}})}function Ke(e){for(let t of e??[]){let e=String(t).toLowerCase().split(`-`)[0];if(e===`vi`)return`vi`;if(e)return`en`}return`en`}var qe=`modulepreload`,Je=function(e){return`/`+e},Ye={},Xe=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Je(t,n),t=s(t),t in Ye)return;Ye[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:qe,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},Ze=document.getElementById(`root`);if(!Ze)throw Error(`Piagent WebUI root is missing`);var Qe=document.querySelector(`meta[name="csp-nonce"]`)?.content,$e=u({key:`piagent-mui`,nonce:Qe&&!Qe.startsWith(`__PIAGENT_`)?Qe:void 0,prepend:!0}),et=(0,w.lazy)(()=>Xe(()=>import(`./InspectionApp-C00GhY47.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12]))),tt=(0,w.lazy)(()=>Xe(()=>import(`./GatewayApp-uqpLU6gs.js`),__vite__mapDeps([13,1,2,7,3,4,9,14,10,11,15,5,16])));function nt(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function rt(){let[e,t]=(0,w.useState)(()=>nt(`piagent-webui-locale`,[`vi`,`en`],Ke(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,w.useState)(()=>nt(`piagent-webui-theme`,re.map(e=>e.id),``)||te[nt(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)]),i=ie(n)??ie(te.dark),a=i.mode,o=(0,w.useCallback)(e=>r(t=>ie(t)?.mode===e?t:te[e]),[]),s=(0,w.useMemo)(()=>Ge(i),[i]);(0,w.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=a,document.documentElement.dataset.piagentTheme=i.id;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,a),window.localStorage.setItem(`piagent-webui-theme`,i.id)}catch{}},[a,e,i]);let c=(0,w.useMemo)(()=>({locale:e,colorMode:a,themeId:i.id,setLocale:t,setColorMode:o,setThemeId:r}),[a,e,i,o]),l=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,D.jsx)(ae,{value:c,children:(0,D.jsxs)(He,{theme:s,children:[(0,D.jsx)(Fe,{}),(0,D.jsx)(We,{locale:e,children:l===`gateway`?(0,D.jsx)(tt,{}):(0,D.jsx)(et,{})})]})})}(0,Ue.createRoot)(Ze).render((0,D.jsx)(w.StrictMode,{children:(0,D.jsx)(s,{value:$e,children:(0,D.jsx)(rt,{})})}));export{We as n,Xe as t};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<meta name="csp-nonce" content="__PIAGENT_CSP_NONCE__" />
|
|
8
8
|
<meta name="piagent-webui-mode" content="__PIAGENT_WEBUI_MODE__" />
|
|
9
9
|
<title>Piagent WebUI</title>
|
|
10
|
-
<script type="module" crossorigin src="/assets/index-
|
|
10
|
+
<script type="module" crossorigin src="/assets/index-D6GtlEqC.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/vendor-CA5pzJiI.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/ui-preferences-Dy4qeODT.js">
|