@piagent/platform 1.51.2 → 1.52.2
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 +37 -0
- package/docs/command-reference-vietnamese.md +2 -2
- package/docs/distribution-standard.md +6 -6
- package/docs/harness-conformance.md +13 -13
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/publishing-for-teams.md +3 -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 +15 -15
- 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 +74 -42
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +15 -15
- 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 +84 -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 +74 -42
- 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/copies.mjs +15 -10
- package/packages/piagent-core/managed/general-clone.mjs +111 -0
- package/packages/piagent-core/managed/helper-roles.mjs +33 -42
- package/packages/piagent-core/managed/helper-run.mjs +21 -15
- package/packages/piagent-core/managed/helper-settlement.mjs +7 -11
- package/packages/piagent-core/managed/language-environment.mjs +6 -2
- package/packages/piagent-core/managed/ledger.mjs +11 -10
- package/packages/piagent-core/managed/objections.mjs +8 -25
- package/packages/piagent-core/managed/role-names.mjs +6 -0
- package/packages/piagent-core/managed/session.mjs +12 -13
- package/packages/piagent-core/managed/tool-boundary.mjs +4 -4
- package/packages/piagent-core/managed/workflow.mjs +2 -39
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-core/runtime/managed-failure.d.mts +1 -1
- package/packages/piagent-core/runtime/managed-failure.mjs +3 -3
- package/packages/piagent-webui/dist/client/assets/{App-C9tlGPMb.js → App-DQwj6l-F.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{GatewayApp-Dvo96qoX.js → GatewayApp-CP8GpZsK.js} +3 -3
- package/packages/piagent-webui/dist/client/assets/{InspectionApp-CGgHsOyC.js → InspectionApp-BZqu1pjw.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-n8UMMcrP.js → SessionAgentWorkspace-4nJSbzE9.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-B62kkr8J.js → SessionInspectorDrawer-DEb_TBE8.js} +2 -2
- package/packages/piagent-webui/dist/client/assets/SettingsNavigation-BF4X5xkR.js +3 -0
- package/packages/piagent-webui/dist/client/assets/{SettingsPage-DKg0SfZQ.js → SettingsPage-CS8LsdhS.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{TerminalPanel-BPTVsNjP.js → TerminalPanel-CiF2_woF.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-BHGFFBc2.js → WorkspaceCodeEditor-OFxSEbBs.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-nd4kghwK.js → WorkspaceExplorer-ZYIi-FWr.js} +3 -3
- package/packages/piagent-webui/dist/client/assets/{index-BiLVX8S-.js → index-CfJC4Unf.js} +2 -2
- package/packages/piagent-webui/dist/client/index.html +1 -1
- package/packages/piagent-webui/server/transcript-projection.ts +3 -3
- package/packages/piagent-webui/shared/company-copy.ts +3 -1
- package/packages/piagent-webui/shared/turn-end.ts +1 -1
- package/schemas/piagent-webui/transcript-v1.schema.json +3 -3
- package/scripts/runtime-advisory-exceptions.json +27 -27
- package/packages/piagent-webui/dist/client/assets/SettingsNavigation-BZijmuPt.js +0 -3
|
@@ -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{An as t,Bt as n,Et as r,G as i,Gt as a,Ht as o,K as s,Kt as c,Ln as l,Lt as u,R as d,Rn as f,Tt as p,Ut as m,Vt as h,W as g,Wt as _,Xt as v,bt as y,qt as b,t as ee}from"./vendor-DNZbaWhT.js";import{i as x,n as S}from"./ui-preferences-OfS30-ZV.js";import{t as C}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceCodeEditor-OFxSEbBs.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-DNZbaWhT.js","assets/ui-preferences-OfS30-ZV.js","assets/index-CfJC4Unf.js","assets/index-De7bIeMc.css","assets/dist-D6i5SpQu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Bt as n,Et as r,G as i,Gt as a,Ht as o,K as s,Kt as c,Ln as l,Lt as u,R as d,Rn as f,Tt as p,Ut as m,Vt as h,W as g,Wt as _,Xt as v,bt as y,qt as b,t as ee}from"./vendor-DNZbaWhT.js";import{i as x,n as S}from"./ui-preferences-OfS30-ZV.js";import{t as C}from"./index-CfJC4Unf.js";import{i as w,n as T,o as E}from"./bootstrap-CedkNtRG.js";import{G as D,lt as te}from"./api-BQS4Dtrr.js";import{l as O}from"./workspace-navigation-DW8zhH6U.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-CB3mQe7m.js";import{a as ie,i as ae,o as oe,t as R}from"./workspace-api-CFBR73lU.js";import{n as se,t as ce}from"./WorkspaceFilePreview-CvIBYige.js";import{t as le}from"./tab-close-BwkkhMH7.js";var z=e(f(),1),B=t();function ue(e,t,n,a=[]){let{locale:o}=x(),[s,c]=(0,z.useState)(()=>j(e)),[l,u]=(0,z.useState)();(0,z.useEffect)(()=>{c(j(e)),u(void 0);let t=t=>{t.detail===e&&c(j(e))};return window.addEventListener(I,t),()=>window.removeEventListener(I,t)},[e]),(0,z.useEffect)(()=>u(void 0),[t]);let d=t=>{c(t),M(e,t)},f={locale:o,comments:s,editing:l?L(l.path,l.side,l.line):null,open:(e,t,n,r)=>u({path:e,line:n,code:r,side:t}),cancel:()=>u(void 0),save:t=>{l&&d(re(j(e),{...l,text:t})),u(void 0)},remove:t=>d(j(e).filter(e=>L(e.path,e.side,e.line)!==t))},p=new Map(n.split(`
|
|
3
3
|
`).map((e,n)=>[L(t??``,`new`,n+1),e.slice(0,400)]));for(let e of a)for(let n of e.lines)n.oldLineNumber!==null&&p.set(L(t??``,`old`,n.oldLineNumber),n.text.slice(0,400));return{open:(e,n,r=`new`)=>{t&&u({path:t,line:e,code:n,side:r})},dialog:(0,B.jsxs)(r,{open:!!l,onClose:()=>u(void 0),fullWidth:!0,children:[(0,B.jsxs)(g,{children:[S(o,`Comment theo dòng`,`Line comment`),` · `,l?.path,`:`,l?.line]}),(0,B.jsx)(i,{children:(0,B.jsx)(A.Provider,{value:f,children:l&&(0,B.jsx)(P,{path:l.path,side:l.side,line:l.line})})})]}),bar:(0,B.jsx)(ne,{comments:s,lines:p,linesPath:t,locale:o,onClear:()=>d([]),onSend:()=>{let t=j(e);t.length&&k(e,F(t,o===`en`)),d([])}})}}var V=new Map;function de(e,t,o,c,l){let{locale:u}=x(),d=`${e}\0${t??``}`,f=`${d}\0${o}\0${c}`,p=(0,z.useRef)(f);p.current=f;let h=(0,z.useRef)(d);h.current=d;let v=(0,z.useRef)(!1),[y,b]=(0,z.useState)(!1),[ee,C]=(0,z.useState)(!1),[w,T]=(0,z.useState)(),[E,O]=(0,z.useState)(),[k,A]=(0,z.useState)(!1);(0,z.useEffect)(()=>{C(!1),T(void 0),O(void 0),A(V.has(d))},[d]);let j=async n=>{if(!(v.current||!c||!l||l.file.path!==t||l.file.currentDigest!==`sha256:${o}`)&&(C(!0),O(void 0),T(void 0),A(V.has(d)),!V.has(d))){v.current=!0,b(!0);try{let r=await D(e,l.file.fileRef,n);if(p.current!==f)return;if(r.state!==`ready`||!r.target||r.target.path!==t||r.target.fileRef!==l.file.fileRef||r.target.fileRevision!==l.file.fileRevision||!r.target.hunkRefs.some(e=>e===n))throw Error(`preview-unavailable`);T({value:r,scope:f})}catch{p.current===f&&O(S(u,`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{v.current=!1,b(!1)}}},M=async()=>{if(!(v.current||!c||!V.has(d)&&(!w||w.scope!==f))){v.current=!0,b(!0),O(void 0);try{let t=V.get(d)??await N(w.value);if(p.current!==f)return;if(!V.has(d)&&V.size>=128){O(S(u,`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}V.set(d,t),A(!0);let n=await te(t,void 0,e);if(n.phase!==`uncertain`&&V.delete(d),h.current===d&&A(V.has(d)),window.dispatchEvent(new CustomEvent(`piagent-workspace-changed`,{detail:{sessionRef:e}})),p.current!==f)return;A(V.has(d)),n.phase===`settled`?(C(!1),T(void 0)):(n.phase===`rejected`&&T(void 0),O(n.phase===`uncertain`?S(u,`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(u,`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{p.current===f&&O(S(u,`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{v.current=!1,b(!1)}}},P=w&&w.scope!==f;return{request:j,dialog:(0,B.jsxs)(r,{open:ee,onClose:()=>{y||C(!1)},fullWidth:!0,maxWidth:`md`,children:[(0,B.jsx)(g,{children:S(u,`Hoàn tác thay đổi của agent`,`Revert agent changes`)}),(0,B.jsxs)(i,{children:[(0,B.jsx)(n,{children:t}),(0,B.jsx)(n,{children:S(u,`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,B.jsx)(a,{severity:`warning`,children:E}),P&&(0,B.jsx)(a,{severity:`warning`,children:S(u,`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,B.jsx)(a,{severity:`info`,children:S(u,`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,B.jsxs)(_,{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,B.jsxs)(s,{children:[(0,B.jsx)(m,{disabled:y,onClick:()=>C(!1),children:S(u,`Đóng`,`Close`)}),(0,B.jsx)(m,{color:`error`,disabled:y||!c||!k&&(!w||!!P),onClick:()=>void M(),children:k?S(u,`Kiểm tra lại`,`Check again`):S(u,`Xác nhận hoàn tác`,`Confirm revert`)})]})]}),hasPending:k,checkPending:()=>{A(V.has(d)),C(!0)}}}async function H(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 U=(e,t)=>H(e,void 0,t),fe=(e,t,n)=>H(e,t,n);function pe(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 W=new Set,G=new Map,K=new Set,q=`piagent.kept-hunks.`,J=`piagent.kept-hunks`;function Y(e){try{let t=JSON.parse(localStorage.getItem(q+e)??`[]`);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`).slice(-4096)):W}catch{return W}}function me(e,t){try{let n=[...JSON.parse(localStorage.getItem(J)??`[]`).filter(t=>t!==e),e];for(let e of n.splice(0,Math.max(0,n.length-64)))localStorage.removeItem(q+e);localStorage.setItem(q+e,JSON.stringify([...t])),localStorage.setItem(J,JSON.stringify(n))}catch{}}var he=e=>(G.has(e)||G.set(e,Y(e)),G.get(e)??W);function ge(e,t,n,r){let i=new Set([...he(e),`${t}:${n}:${r}`].slice(-4096));for(G.delete(e),G.set(e,i);G.size>64;)G.delete(G.keys().next().value);me(e,i);for(let e of K)e()}function X(e){return(0,z.useSyncExternalStore)(e=>(K.add(e),()=>{K.delete(e)}),()=>he(e))}function _e(e,t,n){let[r,i]=(0,z.useState)(),a=X(e),o=JSON.stringify(t.map(e=>e.file.path).sort());(0,z.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 U(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 fe(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=>pe(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)&&ge(e,l.file.path,l.file.digest,t)}}}var Z=new Map,ve=new Set,ye={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 be=e=>Z.get(e)??ye;function xe(e){let t=(0,z.useSyncExternalStore)(e=>(ve.add(e),()=>{ve.delete(e)}),()=>Z.get(e)??ye),n=t=>{Z.set(e,t(Z.get(e)??ye));for(let e of ve)e()};return{...t,update:n}}function Se(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 Ce(e,t,n){let{update:r}=xe(e),i=(0,z.useRef)({update:r,conflict:n});i.current={update:r,conflict:n},(0,z.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 be(e).tabs)if(!(a.fresh||a.pending||t.current))try{let o=await R(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=Se(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 we=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 Te(e,t){let n=await fetch(we(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 Ee(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 De(e,t){let n=T();if(!n)throw Error(`workspace-write-unavailable`);let r=await w(we(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 Oe(e){let{locale:t}=x(),n=xe(e),[r,i]=(0,z.useState)(),[a,o]=(0,z.useState)(!1),s=(0,z.useRef)(!1),[c,l]=(0,z.useState)(),[u,d]=(0,z.useState)();Ce(e,s,d),(0,z.useEffect)(()=>{let t=new AbortController,n=!1,r=()=>{n||(n=!0,Te(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=be(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 R(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=be(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 Te(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 Ee(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 De(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 R(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=be(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 Te(e);i(o);let s=c?.file.digest??(await R(e,r)).digest;if(!o.writable||!s)throw Error(`unavailable`);let u=await De(e,await Ee(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 R(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 ke=e(l(),1);function Ae({sessionRef:e,onOpen:t}){let{locale:r}=x(),[i,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let t=new AbortController;if(c(void 0),f(!1),u(!1),!i.trim())return()=>t.abort();u(!0);let n=setTimeout(()=>{oe(e,i,t.signal).then(e=>{t.signal.aborted||c(e)}).catch(()=>{t.signal.aborted||f(!0)}).finally(()=>{t.signal.aborted||u(!1)})},250);return()=>{clearTimeout(n),t.abort()}},[i,e]),(0,B.jsxs)(p,{spacing:1,sx:{p:1},children:[(0,B.jsx)(y,{size:`small`,label:S(r,`Tìm nội dung`,`Search contents`),value:i,onChange:e=>o(e.target.value),slotProps:{htmlInput:{maxLength:512}}}),l&&(0,B.jsx)(b,{size:18}),(d||s?.available===!1)&&(0,B.jsx)(a,{severity:`warning`,children:S(r,`Chưa tìm được nội dung trong project này.`,`Content search is unavailable for this project.`)}),s?.available&&s.backend===`fts`&&(0,B.jsx)(n,{variant:`caption`,children:S(r,`Tìm trong các tệp đã lập chỉ mục.`,`Searching indexed files.`)}),s?.matches.map(e=>(0,B.jsxs)(m,{onClick:()=>t(e.path,e.line),sx:{textTransform:`none`,display:`block`,textAlign:`left`,overflowWrap:`anywhere`},children:[(0,B.jsxs)(n,{variant:`caption`,component:`span`,children:[e.path,`:`,e.line,`:`,e.column]}),(0,B.jsx)(n,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.preview})]},`${e.path}:${e.line}:${e.column}`)),s?.truncated&&(0,B.jsx)(n,{variant:`caption`,children:S(r,`Đã giới hạn kết quả. Hãy tìm cụ thể hơn.`,`Results were limited. Refine your search.`)}),s?.available&&!s.matches.length&&!s.truncated&&(0,B.jsx)(n,{variant:`caption`,children:S(r,`Không tìm thấy.`,`No matches.`)})]})}var je=v((0,B.jsx)(`path`,{d:`M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z`}),`ChevronRight`),Me=v((0,B.jsx)(`path`,{d:`M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z`}),`ExpandMore`),Ne=v((0,B.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`),Pe=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`));function Fe({sessionRef:e,refresh:t,active:r,onOpen:i,onFolder:a}){let{locale:o}=x(),[s,c]=(0,z.useState)(()=>new Set([``])),[l,f]=(0,z.useState)(()=>new Map),[p,h]=(0,z.useState)(),g=(t,n)=>{f(e=>new Map(e).set(t,e.get(t)??`loading`)),ae(e,t,n).then(e=>{n?.aborted||f(n=>new Map(n).set(t,e))}).catch(()=>{n?.aborted||f(e=>new Map(e).set(t,`error`))})};(0,z.useEffect)(()=>{f(new Map),c(new Set([``]))},[e]),(0,z.useEffect)(()=>{let e=new AbortController;for(let t of s)g(t,e.signal);return()=>e.abort()},[e,t]),(0,z.useEffect)(()=>{if(!r)return;let e=Pe(r).filter(e=>!s.has(e));if(e.length){c(t=>new Set([...t,...e]));for(let t of e)l.has(t)||g(t)}},[r]);let v=e=>{if(h(e),a(e),s.has(e)){c(t=>{let n=new Set(t);return n.delete(e),n});return}c(t=>new Set(t).add(e)),(!l.has(e)||l.get(e)===`error`)&&g(e)},y=(e,t)=>{let a=l.get(e);return!a||a===`loading`?(0,B.jsx)(b,{size:14,sx:{ml:1.5+t*1.5,my:.5}}):a===`error`?(0,B.jsx)(n,{variant:`caption`,color:`warning.main`,sx:{pl:1.5+t*1.5},children:S(o,`Chưa đọc được thư mục này.`,`This folder could not be read.`)}):(0,B.jsxs)(B.Fragment,{children:[a.entries.map(e=>{let n=e.kind===`directory`,a=n&&s.has(e.path),c=n?p===e.path:r===e.path,l=n?(0,B.jsxs)(B.Fragment,{children:[a?(0,B.jsx)(Me,{sx:{fontSize:16}}):(0,B.jsx)(je,{sx:{fontSize:16}}),a?(0,B.jsx)(d,{sx:{fontSize:16}}):(0,B.jsx)(u,{sx:{fontSize:16}})]}):(0,B.jsx)(Ne,{sx:{fontSize:16,ml:`16px`}});return(0,B.jsxs)(_,{children:[(0,B.jsxs)(m,{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":n?a:void 0,"aria-current":!n&&r===e.path?`true`:void 0,onClick:()=>n?v(e.path):(h(void 0),i(e.path)),sx:{justifyContent:`flex-start`,textTransform:`none`,gap:.5,minHeight:24,py:0,pl:.5+t*1.5,pr:1,color:`text.primary`,fontWeight:400,whiteSpace:`nowrap`,bgcolor:c?`action.selected`:void 0},children:[l,(0,B.jsxs)(_,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`},children:[e.name,e.protected?` 🔒`:``]})]}),a&&y(e.path,t+1)]},e.path)}),a.truncated&&(0,B.jsx)(n,{variant:`caption`,sx:{pl:1.5+t*1.5},children:S(o,`Danh sách đã được giới hạn.`,`Listing limit reached.`)})]})};return(0,B.jsx)(_,{role:`group`,"aria-label":S(o,`Cây thư mục`,`Folder tree`),sx:{py:.5},children:y(``,0)})}var Ie=(0,z.lazy)(()=>C(()=>import(`./WorkspaceCodeEditor-BHGFFBc2.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function Le({sessionRef:e,target:t,navigationHost:l,sidebarMode:u,onHide:d,fill:f}){let{locale:v}=x(),[C,w]=(0,z.useState)(`files`),[T,E]=(0,z.useState)(!1),[D,te]=(0,z.useState)(``),[k,A]=(0,z.useState)(!1),[j,M]=(0,z.useState)(),[N,P]=(0,z.useState)(``),F=Oe(e),{tabs:I,active:L}=F,[ne,re]=(0,z.useState)(``),[ae,oe]=(0,z.useState)(!1),[V,H]=(0,z.useState)(!1),U=(0,z.useRef)(null),[fe,pe]=(0,z.useState)(0);(0,z.useEffect)(()=>{let t=t=>{t.detail?.sessionRef===e&&pe(e=>e+1)};return window.addEventListener(`piagent-workspace-saved`,t),()=>window.removeEventListener(`piagent-workspace-saved`,t)},[e]),(0,z.useEffect)(()=>()=>U.current?.abort(),[]);let W=async(t,n=1)=>{if(U.current?.abort(),H(!1),I.find(e=>e.file.path===t)){F.select(t,n);return}U.current?.abort();let r=new AbortController;U.current=r,H(!0),oe(!1);try{let i=await R(e,t,r.signal);if(r.signal.aborted)return;if(i.protected){oe(!0);return}F.load(i,n)}catch{r.signal.aborted||oe(!0)}finally{r.signal.aborted||H(!1)}};(0,z.useEffect)(()=>{t&&W(t.path,t.line??1)},[t]),(0,z.useEffect)(()=>{u&&u!==`sessions`&&w(u)},[u]);let G=I.find(e=>e.file.path===L),K=G?.file,q=_e(e,I,L),J=de(e,K?.path,K?.digest??null,!!G&&!Q(G),q.diff),Y=ue(e,K?.path,G?.draft??``,q.hunks),[me,he]=(0,z.useState)(new Set),ge=!!K&&!K.binary&&!K.oversized&&se(K.path)===`image`&&!me.has(K.path),X=I.find(e=>e.file.path===F.conflict?.path),Z=(0,B.jsxs)(_,{component:`nav`,"aria-label":S(v,`Tệp dự án`,`Project files`),sx:{width:l?`100%`:{xs:136,sm:200},flexShrink:0,overflow:`auto`,borderRight:1,borderColor:`divider`},children:[!l&&(0,B.jsxs)(h,{value:C,onChange:(e,t)=>w(t),"aria-label":S(v,`Khám phá project`,`Explore project`),children:[(0,B.jsx)(o,{value:`files`,label:S(v,`Tệp`,`Files`)}),(0,B.jsx)(o,{value:`search`,label:S(v,`Tìm kiếm`,`Search`)})]}),C===`search`?(0,B.jsx)(Ae,{sessionRef:e,onOpen:(e,t)=>void W(e,t)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(m,{disabled:!F.authority?.writable,onClick:()=>{te(ne?`${ne}/`:``),E(!0)},children:S(v,`Tệp mới`,`New file`)}),(0,B.jsx)(Fe,{sessionRef:e,refresh:fe,active:L,onOpen:e=>{re(e.split(`/`).slice(0,-1).join(`/`)),W(e)},onFolder:re})]})]});return(0,B.jsxs)(B.Fragment,{children:[J.dialog,Y.dialog,(0,B.jsxs)(p,{direction:`row`,sx:{height:f?`100%`:`calc(100vh - 150px)`,minHeight:f?160:320},children:[l?(0,ke.createPortal)(Z,l):Z,(0,B.jsxs)(_,{sx:{minWidth:0,flex:1,display:`flex`,flexDirection:`column`},children:[ae&&(0,B.jsx)(a,{severity:`warning`,children:S(v,`Chưa đọc được tệp hoặc thư mục này.`,`This file or folder could not be read.`)}),Y.bar,F.message&&(0,B.jsx)(a,{severity:`warning`,children:F.message}),F.authority?.agentRunning&&(0,B.jsx)(a,{severity:`info`,children:S(v,`Agent đang chạy và có thể sửa tệp này.`,`The agent is running and may change this file.`)}),(0,B.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,borderBottom:1,borderColor:`divider`,minHeight:36},children:[(0,B.jsx)(h,{value:L??!1,onChange:(e,t)=>F.select(t),variant:`scrollable`,scrollButtons:`auto`,"aria-label":S(v,`Các tệp đang mở`,`Open files`),sx:{flex:1,minWidth:0,minHeight:36},children:I.map(e=>(0,B.jsx)(o,{value:e.file.path,sx:{minHeight:36,py:0},"aria-label":`${e.file.path}${Q(e)?` ●`:``}${q.counts.get(e.file.path)?` (${q.counts.get(e.file.path)})`:``}`,label:le(`${e.file.path}${Q(e)?` ●`:``}${q.counts.get(e.file.path)?` (${q.counts.get(e.file.path)})`:``}`,S(v,`Đóng ${e.file.path}`,`Close ${e.file.path}`),()=>F.close(e.file.path))},e.file.path))}),d&&(0,B.jsx)(c,{size:`small`,"aria-label":S(v,`Ẩn khung tệp`,`Hide files panel`),title:S(v,`Ẩn khung tệp (tệp đang mở vẫn giữ)`,`Hide files panel (open files are kept)`),onClick:d,children:(0,B.jsx)(ee,{fontSize:`small`})})]}),V&&(0,B.jsx)(b,{size:20}),K&&(0,B.jsxs)(p,{direction:`row`,sx:{flexShrink:0,overflowX:`auto`,"& .MuiButton-root":{whiteSpace:`nowrap`,flexShrink:0}},children:[!K.binary&&!K.oversized&&se(K.path)===`image`&&(0,B.jsx)(m,{size:`small`,onClick:()=>he(e=>{let t=new Set(e);return t.has(K.path)?t.delete(K.path):t.add(K.path),t}),children:ge?S(v,`Xem mã`,`View code`):S(v,`Xem hình`,`View picture`)}),(0,B.jsx)(m,{size:`small`,onClick:()=>void ie(e,K.path),children:S(v,`Tải về`,`Download`)}),J.hasPending&&(0,B.jsx)(m,{onClick:J.checkPending,children:S(v,`Kiểm tra hoàn tác`,`Check revert`)}),(0,B.jsx)(m,{size:`small`,disabled:!F.authority?.writable||K.readOnly||!G||!Q(G)&&!G.pending||F.saving,onClick:()=>void F.save(K.path),children:S(v,`Lưu`,`Save`)}),(0,B.jsx)(m,{size:`small`,onClick:()=>F.close(K.path),children:S(v,`Đóng tệp`,`Close file`)}),(0,B.jsx)(m,{size:`small`,disabled:!F.authority?.writable||K.readOnly||!K.digest||F.saving,onClick:()=>{P(K.path),M(K.path)},children:S(v,`Đổi tên`,`Rename`)}),(0,B.jsx)(m,{size:`small`,color:`error`,disabled:!F.authority?.writable||K.readOnly||!K.digest||F.saving,onClick:()=>{window.confirm(S(v,`Xóa ${K.path}? Có thể khôi phục bằng Git nếu tệp đã commit.`,`Delete ${K.path}? Git can restore it if it was committed.`))&&F.move(K.path)},children:S(v,`Xóa`,`Delete`)}),(0,B.jsx)(m,{size:`small`,onClick:()=>{(!G||!Q(G)||window.confirm(S(v,`Bỏ thay đổi chưa lưu và tải lại?`,`Discard unsaved changes and reload?`)))&&F.reload(K.path)},children:S(v,`Tải lại`,`Reload`)})]}),K?.binary||K?.oversized||ge?(0,B.jsx)(ce,{sessionRef:e,path:K.path}):K?.content!==null&&K?.content!==void 0?(0,B.jsx)(_,{sx:{flex:1,minHeight:0},children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(b,{size:20}),children:(0,B.jsx)(Ie,{onComment:Y.open,hunks:q.hunks,onKeep:q.keep,onRevert:F.authority?.writable?e=>void J.request(e):void 0,content:G?.draft??K.content,path:K.path,line:G?.line??1,readOnly:!F.authority?.writable||K.readOnly,onChange:e=>F.change(K.path,e),onSave:()=>void F.save(K.path)})})}):(0,B.jsx)(n,{sx:{p:2},children:S(v,`Chọn một tệp để mở.`,`Select a file to open.`)})]})]}),(0,B.jsxs)(r,{open:T,onClose:()=>E(!1),fullWidth:!0,children:[(0,B.jsx)(g,{children:S(v,`Tạo tệp mới`,`Create a new file`)}),(0,B.jsx)(i,{children:(0,B.jsx)(y,{autoFocus:!0,fullWidth:!0,label:S(v,`Đường dẫn trong project`,`Path in project`),value:D,onChange:e=>te(e.target.value)})}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{onClick:()=>E(!1),children:S(v,`Hủy`,`Cancel`)}),(0,B.jsx)(m,{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(v,`Tạo`,`Create`)})]})]}),(0,B.jsxs)(r,{open:!!j,onClose:()=>M(void 0),fullWidth:!0,children:[(0,B.jsx)(g,{children:S(v,`Đổi tên tệp`,`Rename file`)}),(0,B.jsx)(i,{children:(0,B.jsx)(y,{autoFocus:!0,fullWidth:!0,label:S(v,`Đường dẫn mới trong project`,`New path in project`),value:N,onChange:e=>P(e.target.value)})}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{onClick:()=>M(void 0),children:S(v,`Hủy`,`Cancel`)}),(0,B.jsx)(m,{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(v,`Đổi tên`,`Rename`)})]})]}),(0,B.jsxs)(r,{open:!!F.conflict,onClose:()=>{F.setConflict(void 0),A(!1)},fullWidth:!0,maxWidth:k?`lg`:`sm`,children:[(0,B.jsx)(g,{children:S(v,`Tệp đã thay đổi trên đĩa`,`The file changed on disk`)}),(0,B.jsxs)(i,{children:[(0,B.jsx)(n,{children:F.conflict?.path}),(0,B.jsx)(n,{children:S(v,`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&&X&&(0,B.jsxs)(p,{direction:`row`,spacing:1,children:[(0,B.jsxs)(_,{sx:{width:`50%`,height:360},children:[(0,B.jsx)(n,{children:S(v,`Trên đĩa`,`On disk`)}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(b,{size:20}),children:(0,B.jsx)(Ie,{path:F.conflict.path,content:F.conflict.content??``})})]}),(0,B.jsxs)(_,{sx:{width:`50%`,height:360},children:[(0,B.jsx)(n,{children:S(v,`Bản sửa của bạn`,`Your draft`)}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(b,{size:20}),children:(0,B.jsx)(Ie,{path:X.file.path,content:X.draft})})]})]})]}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{onClick:()=>{F.setConflict(void 0),A(!1)},children:S(v,`Để sau`,`Later`)}),(0,B.jsx)(m,{onClick:()=>{F.conflict&&(F.load(F.conflict),F.setConflict(void 0),A(!1))},children:S(v,`Tải lại`,`Reload`)}),(0,B.jsx)(m,{onClick:()=>A(!0),children:S(v,`Xem khác biệt`,`Compare`)}),(0,B.jsx)(m,{disabled:F.saving||!F.conflict?.digest||F.conflict.protected||F.conflict.readOnly,onClick:()=>{F.conflict&&F.save(F.conflict.path,F.conflict)},children:S(v,`Ghi đè`,`Overwrite`)})]})]})]})}export{Le as default};
|
|
5
|
+
`)]},e.hunkRef))]}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{disabled:y,onClick:()=>C(!1),children:S(u,`Đóng`,`Close`)}),(0,B.jsx)(m,{color:`error`,disabled:y||!c||!k&&(!w||!!P),onClick:()=>void M(),children:k?S(u,`Kiểm tra lại`,`Check again`):S(u,`Xác nhận hoàn tác`,`Confirm revert`)})]})]}),hasPending:k,checkPending:()=>{A(V.has(d)),C(!0)}}}async function H(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 U=(e,t)=>H(e,void 0,t),fe=(e,t,n)=>H(e,t,n);function pe(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 W=new Set,G=new Map,K=new Set,q=`piagent.kept-hunks.`,J=`piagent.kept-hunks`;function Y(e){try{let t=JSON.parse(localStorage.getItem(q+e)??`[]`);return Array.isArray(t)?new Set(t.filter(e=>typeof e==`string`).slice(-4096)):W}catch{return W}}function me(e,t){try{let n=[...JSON.parse(localStorage.getItem(J)??`[]`).filter(t=>t!==e),e];for(let e of n.splice(0,Math.max(0,n.length-64)))localStorage.removeItem(q+e);localStorage.setItem(q+e,JSON.stringify([...t])),localStorage.setItem(J,JSON.stringify(n))}catch{}}var he=e=>(G.has(e)||G.set(e,Y(e)),G.get(e)??W);function ge(e,t,n,r){let i=new Set([...he(e),`${t}:${n}:${r}`].slice(-4096));for(G.delete(e),G.set(e,i);G.size>64;)G.delete(G.keys().next().value);me(e,i);for(let e of K)e()}function X(e){return(0,z.useSyncExternalStore)(e=>(K.add(e),()=>{K.delete(e)}),()=>he(e))}function _e(e,t,n){let[r,i]=(0,z.useState)(),a=X(e),o=JSON.stringify(t.map(e=>e.file.path).sort());(0,z.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 U(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 fe(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=>pe(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)&&ge(e,l.file.path,l.file.digest,t)}}}var Z=new Map,ve=new Set,ye={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 be=e=>Z.get(e)??ye;function xe(e){let t=(0,z.useSyncExternalStore)(e=>(ve.add(e),()=>{ve.delete(e)}),()=>Z.get(e)??ye),n=t=>{Z.set(e,t(Z.get(e)??ye));for(let e of ve)e()};return{...t,update:n}}function Se(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 Ce(e,t,n){let{update:r}=xe(e),i=(0,z.useRef)({update:r,conflict:n});i.current={update:r,conflict:n},(0,z.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 be(e).tabs)if(!(a.fresh||a.pending||t.current))try{let o=await R(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=Se(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 we=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 Te(e,t){let n=await fetch(we(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 Ee(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 De(e,t){let n=T();if(!n)throw Error(`workspace-write-unavailable`);let r=await w(we(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 Oe(e){let{locale:t}=x(),n=xe(e),[r,i]=(0,z.useState)(),[a,o]=(0,z.useState)(!1),s=(0,z.useRef)(!1),[c,l]=(0,z.useState)(),[u,d]=(0,z.useState)();Ce(e,s,d),(0,z.useEffect)(()=>{let t=new AbortController,n=!1,r=()=>{n||(n=!0,Te(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=be(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 R(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=be(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 Te(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 Ee(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 De(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 R(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=be(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 Te(e);i(o);let s=c?.file.digest??(await R(e,r)).digest;if(!o.writable||!s)throw Error(`unavailable`);let u=await De(e,await Ee(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 R(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 ke=e(l(),1);function Ae({sessionRef:e,onOpen:t}){let{locale:r}=x(),[i,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(),[l,u]=(0,z.useState)(!1),[d,f]=(0,z.useState)(!1);return(0,z.useEffect)(()=>{let t=new AbortController;if(c(void 0),f(!1),u(!1),!i.trim())return()=>t.abort();u(!0);let n=setTimeout(()=>{oe(e,i,t.signal).then(e=>{t.signal.aborted||c(e)}).catch(()=>{t.signal.aborted||f(!0)}).finally(()=>{t.signal.aborted||u(!1)})},250);return()=>{clearTimeout(n),t.abort()}},[i,e]),(0,B.jsxs)(p,{spacing:1,sx:{p:1},children:[(0,B.jsx)(y,{size:`small`,label:S(r,`Tìm nội dung`,`Search contents`),value:i,onChange:e=>o(e.target.value),slotProps:{htmlInput:{maxLength:512}}}),l&&(0,B.jsx)(b,{size:18}),(d||s?.available===!1)&&(0,B.jsx)(a,{severity:`warning`,children:S(r,`Chưa tìm được nội dung trong project này.`,`Content search is unavailable for this project.`)}),s?.available&&s.backend===`fts`&&(0,B.jsx)(n,{variant:`caption`,children:S(r,`Tìm trong các tệp đã lập chỉ mục.`,`Searching indexed files.`)}),s?.matches.map(e=>(0,B.jsxs)(m,{onClick:()=>t(e.path,e.line),sx:{textTransform:`none`,display:`block`,textAlign:`left`,overflowWrap:`anywhere`},children:[(0,B.jsxs)(n,{variant:`caption`,component:`span`,children:[e.path,`:`,e.line,`:`,e.column]}),(0,B.jsx)(n,{variant:`body2`,component:`span`,sx:{display:`block`},children:e.preview})]},`${e.path}:${e.line}:${e.column}`)),s?.truncated&&(0,B.jsx)(n,{variant:`caption`,children:S(r,`Đã giới hạn kết quả. Hãy tìm cụ thể hơn.`,`Results were limited. Refine your search.`)}),s?.available&&!s.matches.length&&!s.truncated&&(0,B.jsx)(n,{variant:`caption`,children:S(r,`Không tìm thấy.`,`No matches.`)})]})}var je=v((0,B.jsx)(`path`,{d:`M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z`}),`ChevronRight`),Me=v((0,B.jsx)(`path`,{d:`M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z`}),`ExpandMore`),Ne=v((0,B.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`),Pe=e=>e.split(`/`).slice(0,-1).map((e,t,n)=>n.slice(0,t+1).join(`/`));function Fe({sessionRef:e,refresh:t,active:r,onOpen:i,onFolder:a}){let{locale:o}=x(),[s,c]=(0,z.useState)(()=>new Set([``])),[l,f]=(0,z.useState)(()=>new Map),[p,h]=(0,z.useState)(),g=(t,n)=>{f(e=>new Map(e).set(t,e.get(t)??`loading`)),ae(e,t,n).then(e=>{n?.aborted||f(n=>new Map(n).set(t,e))}).catch(()=>{n?.aborted||f(e=>new Map(e).set(t,`error`))})};(0,z.useEffect)(()=>{f(new Map),c(new Set([``]))},[e]),(0,z.useEffect)(()=>{let e=new AbortController;for(let t of s)g(t,e.signal);return()=>e.abort()},[e,t]),(0,z.useEffect)(()=>{if(!r)return;let e=Pe(r).filter(e=>!s.has(e));if(e.length){c(t=>new Set([...t,...e]));for(let t of e)l.has(t)||g(t)}},[r]);let v=e=>{if(h(e),a(e),s.has(e)){c(t=>{let n=new Set(t);return n.delete(e),n});return}c(t=>new Set(t).add(e)),(!l.has(e)||l.get(e)===`error`)&&g(e)},y=(e,t)=>{let a=l.get(e);return!a||a===`loading`?(0,B.jsx)(b,{size:14,sx:{ml:1.5+t*1.5,my:.5}}):a===`error`?(0,B.jsx)(n,{variant:`caption`,color:`warning.main`,sx:{pl:1.5+t*1.5},children:S(o,`Chưa đọc được thư mục này.`,`This folder could not be read.`)}):(0,B.jsxs)(B.Fragment,{children:[a.entries.map(e=>{let n=e.kind===`directory`,a=n&&s.has(e.path),c=n?p===e.path:r===e.path,l=n?(0,B.jsxs)(B.Fragment,{children:[a?(0,B.jsx)(Me,{sx:{fontSize:16}}):(0,B.jsx)(je,{sx:{fontSize:16}}),a?(0,B.jsx)(d,{sx:{fontSize:16}}):(0,B.jsx)(u,{sx:{fontSize:16}})]}):(0,B.jsx)(Ne,{sx:{fontSize:16,ml:`16px`}});return(0,B.jsxs)(_,{children:[(0,B.jsxs)(m,{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":n?a:void 0,"aria-current":!n&&r===e.path?`true`:void 0,onClick:()=>n?v(e.path):(h(void 0),i(e.path)),sx:{justifyContent:`flex-start`,textTransform:`none`,gap:.5,minHeight:24,py:0,pl:.5+t*1.5,pr:1,color:`text.primary`,fontWeight:400,whiteSpace:`nowrap`,bgcolor:c?`action.selected`:void 0},children:[l,(0,B.jsxs)(_,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`},children:[e.name,e.protected?` 🔒`:``]})]}),a&&y(e.path,t+1)]},e.path)}),a.truncated&&(0,B.jsx)(n,{variant:`caption`,sx:{pl:1.5+t*1.5},children:S(o,`Danh sách đã được giới hạn.`,`Listing limit reached.`)})]})};return(0,B.jsx)(_,{role:`group`,"aria-label":S(o,`Cây thư mục`,`Folder tree`),sx:{py:.5},children:y(``,0)})}var Ie=(0,z.lazy)(()=>C(()=>import(`./WorkspaceCodeEditor-OFxSEbBs.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function Le({sessionRef:e,target:t,navigationHost:l,sidebarMode:u,onHide:d,fill:f}){let{locale:v}=x(),[C,w]=(0,z.useState)(`files`),[T,E]=(0,z.useState)(!1),[D,te]=(0,z.useState)(``),[k,A]=(0,z.useState)(!1),[j,M]=(0,z.useState)(),[N,P]=(0,z.useState)(``),F=Oe(e),{tabs:I,active:L}=F,[ne,re]=(0,z.useState)(``),[ae,oe]=(0,z.useState)(!1),[V,H]=(0,z.useState)(!1),U=(0,z.useRef)(null),[fe,pe]=(0,z.useState)(0);(0,z.useEffect)(()=>{let t=t=>{t.detail?.sessionRef===e&&pe(e=>e+1)};return window.addEventListener(`piagent-workspace-saved`,t),()=>window.removeEventListener(`piagent-workspace-saved`,t)},[e]),(0,z.useEffect)(()=>()=>U.current?.abort(),[]);let W=async(t,n=1)=>{if(U.current?.abort(),H(!1),I.find(e=>e.file.path===t)){F.select(t,n);return}U.current?.abort();let r=new AbortController;U.current=r,H(!0),oe(!1);try{let i=await R(e,t,r.signal);if(r.signal.aborted)return;if(i.protected){oe(!0);return}F.load(i,n)}catch{r.signal.aborted||oe(!0)}finally{r.signal.aborted||H(!1)}};(0,z.useEffect)(()=>{t&&W(t.path,t.line??1)},[t]),(0,z.useEffect)(()=>{u&&u!==`sessions`&&w(u)},[u]);let G=I.find(e=>e.file.path===L),K=G?.file,q=_e(e,I,L),J=de(e,K?.path,K?.digest??null,!!G&&!Q(G),q.diff),Y=ue(e,K?.path,G?.draft??``,q.hunks),[me,he]=(0,z.useState)(new Set),ge=!!K&&!K.binary&&!K.oversized&&se(K.path)===`image`&&!me.has(K.path),X=I.find(e=>e.file.path===F.conflict?.path),Z=(0,B.jsxs)(_,{component:`nav`,"aria-label":S(v,`Tệp dự án`,`Project files`),sx:{width:l?`100%`:{xs:136,sm:200},flexShrink:0,overflow:`auto`,borderRight:1,borderColor:`divider`},children:[!l&&(0,B.jsxs)(h,{value:C,onChange:(e,t)=>w(t),"aria-label":S(v,`Khám phá project`,`Explore project`),children:[(0,B.jsx)(o,{value:`files`,label:S(v,`Tệp`,`Files`)}),(0,B.jsx)(o,{value:`search`,label:S(v,`Tìm kiếm`,`Search`)})]}),C===`search`?(0,B.jsx)(Ae,{sessionRef:e,onOpen:(e,t)=>void W(e,t)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(m,{disabled:!F.authority?.writable,onClick:()=>{te(ne?`${ne}/`:``),E(!0)},children:S(v,`Tệp mới`,`New file`)}),(0,B.jsx)(Fe,{sessionRef:e,refresh:fe,active:L,onOpen:e=>{re(e.split(`/`).slice(0,-1).join(`/`)),W(e)},onFolder:re})]})]});return(0,B.jsxs)(B.Fragment,{children:[J.dialog,Y.dialog,(0,B.jsxs)(p,{direction:`row`,sx:{height:f?`100%`:`calc(100vh - 150px)`,minHeight:f?160:320},children:[l?(0,ke.createPortal)(Z,l):Z,(0,B.jsxs)(_,{sx:{minWidth:0,flex:1,display:`flex`,flexDirection:`column`},children:[ae&&(0,B.jsx)(a,{severity:`warning`,children:S(v,`Chưa đọc được tệp hoặc thư mục này.`,`This file or folder could not be read.`)}),Y.bar,F.message&&(0,B.jsx)(a,{severity:`warning`,children:F.message}),F.authority?.agentRunning&&(0,B.jsx)(a,{severity:`info`,children:S(v,`Agent đang chạy và có thể sửa tệp này.`,`The agent is running and may change this file.`)}),(0,B.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,borderBottom:1,borderColor:`divider`,minHeight:36},children:[(0,B.jsx)(h,{value:L??!1,onChange:(e,t)=>F.select(t),variant:`scrollable`,scrollButtons:`auto`,"aria-label":S(v,`Các tệp đang mở`,`Open files`),sx:{flex:1,minWidth:0,minHeight:36},children:I.map(e=>(0,B.jsx)(o,{value:e.file.path,sx:{minHeight:36,py:0},"aria-label":`${e.file.path}${Q(e)?` ●`:``}${q.counts.get(e.file.path)?` (${q.counts.get(e.file.path)})`:``}`,label:le(`${e.file.path}${Q(e)?` ●`:``}${q.counts.get(e.file.path)?` (${q.counts.get(e.file.path)})`:``}`,S(v,`Đóng ${e.file.path}`,`Close ${e.file.path}`),()=>F.close(e.file.path))},e.file.path))}),d&&(0,B.jsx)(c,{size:`small`,"aria-label":S(v,`Ẩn khung tệp`,`Hide files panel`),title:S(v,`Ẩn khung tệp (tệp đang mở vẫn giữ)`,`Hide files panel (open files are kept)`),onClick:d,children:(0,B.jsx)(ee,{fontSize:`small`})})]}),V&&(0,B.jsx)(b,{size:20}),K&&(0,B.jsxs)(p,{direction:`row`,sx:{flexShrink:0,overflowX:`auto`,"& .MuiButton-root":{whiteSpace:`nowrap`,flexShrink:0}},children:[!K.binary&&!K.oversized&&se(K.path)===`image`&&(0,B.jsx)(m,{size:`small`,onClick:()=>he(e=>{let t=new Set(e);return t.has(K.path)?t.delete(K.path):t.add(K.path),t}),children:ge?S(v,`Xem mã`,`View code`):S(v,`Xem hình`,`View picture`)}),(0,B.jsx)(m,{size:`small`,onClick:()=>void ie(e,K.path),children:S(v,`Tải về`,`Download`)}),J.hasPending&&(0,B.jsx)(m,{onClick:J.checkPending,children:S(v,`Kiểm tra hoàn tác`,`Check revert`)}),(0,B.jsx)(m,{size:`small`,disabled:!F.authority?.writable||K.readOnly||!G||!Q(G)&&!G.pending||F.saving,onClick:()=>void F.save(K.path),children:S(v,`Lưu`,`Save`)}),(0,B.jsx)(m,{size:`small`,onClick:()=>F.close(K.path),children:S(v,`Đóng tệp`,`Close file`)}),(0,B.jsx)(m,{size:`small`,disabled:!F.authority?.writable||K.readOnly||!K.digest||F.saving,onClick:()=>{P(K.path),M(K.path)},children:S(v,`Đổi tên`,`Rename`)}),(0,B.jsx)(m,{size:`small`,color:`error`,disabled:!F.authority?.writable||K.readOnly||!K.digest||F.saving,onClick:()=>{window.confirm(S(v,`Xóa ${K.path}? Có thể khôi phục bằng Git nếu tệp đã commit.`,`Delete ${K.path}? Git can restore it if it was committed.`))&&F.move(K.path)},children:S(v,`Xóa`,`Delete`)}),(0,B.jsx)(m,{size:`small`,onClick:()=>{(!G||!Q(G)||window.confirm(S(v,`Bỏ thay đổi chưa lưu và tải lại?`,`Discard unsaved changes and reload?`)))&&F.reload(K.path)},children:S(v,`Tải lại`,`Reload`)})]}),K?.binary||K?.oversized||ge?(0,B.jsx)(ce,{sessionRef:e,path:K.path}):K?.content!==null&&K?.content!==void 0?(0,B.jsx)(_,{sx:{flex:1,minHeight:0},children:(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(b,{size:20}),children:(0,B.jsx)(Ie,{onComment:Y.open,hunks:q.hunks,onKeep:q.keep,onRevert:F.authority?.writable?e=>void J.request(e):void 0,content:G?.draft??K.content,path:K.path,line:G?.line??1,readOnly:!F.authority?.writable||K.readOnly,onChange:e=>F.change(K.path,e),onSave:()=>void F.save(K.path)})})}):(0,B.jsx)(n,{sx:{p:2},children:S(v,`Chọn một tệp để mở.`,`Select a file to open.`)})]})]}),(0,B.jsxs)(r,{open:T,onClose:()=>E(!1),fullWidth:!0,children:[(0,B.jsx)(g,{children:S(v,`Tạo tệp mới`,`Create a new file`)}),(0,B.jsx)(i,{children:(0,B.jsx)(y,{autoFocus:!0,fullWidth:!0,label:S(v,`Đường dẫn trong project`,`Path in project`),value:D,onChange:e=>te(e.target.value)})}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{onClick:()=>E(!1),children:S(v,`Hủy`,`Cancel`)}),(0,B.jsx)(m,{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(v,`Tạo`,`Create`)})]})]}),(0,B.jsxs)(r,{open:!!j,onClose:()=>M(void 0),fullWidth:!0,children:[(0,B.jsx)(g,{children:S(v,`Đổi tên tệp`,`Rename file`)}),(0,B.jsx)(i,{children:(0,B.jsx)(y,{autoFocus:!0,fullWidth:!0,label:S(v,`Đường dẫn mới trong project`,`New path in project`),value:N,onChange:e=>P(e.target.value)})}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{onClick:()=>M(void 0),children:S(v,`Hủy`,`Cancel`)}),(0,B.jsx)(m,{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(v,`Đổi tên`,`Rename`)})]})]}),(0,B.jsxs)(r,{open:!!F.conflict,onClose:()=>{F.setConflict(void 0),A(!1)},fullWidth:!0,maxWidth:k?`lg`:`sm`,children:[(0,B.jsx)(g,{children:S(v,`Tệp đã thay đổi trên đĩa`,`The file changed on disk`)}),(0,B.jsxs)(i,{children:[(0,B.jsx)(n,{children:F.conflict?.path}),(0,B.jsx)(n,{children:S(v,`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&&X&&(0,B.jsxs)(p,{direction:`row`,spacing:1,children:[(0,B.jsxs)(_,{sx:{width:`50%`,height:360},children:[(0,B.jsx)(n,{children:S(v,`Trên đĩa`,`On disk`)}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(b,{size:20}),children:(0,B.jsx)(Ie,{path:F.conflict.path,content:F.conflict.content??``})})]}),(0,B.jsxs)(_,{sx:{width:`50%`,height:360},children:[(0,B.jsx)(n,{children:S(v,`Bản sửa của bạn`,`Your draft`)}),(0,B.jsx)(z.Suspense,{fallback:(0,B.jsx)(b,{size:20}),children:(0,B.jsx)(Ie,{path:X.file.path,content:X.draft})})]})]})]}),(0,B.jsxs)(s,{children:[(0,B.jsx)(m,{onClick:()=>{F.setConflict(void 0),A(!1)},children:S(v,`Để sau`,`Later`)}),(0,B.jsx)(m,{onClick:()=>{F.conflict&&(F.load(F.conflict),F.setConflict(void 0),A(!1))},children:S(v,`Tải lại`,`Reload`)}),(0,B.jsx)(m,{onClick:()=>A(!0),children:S(v,`Xem khác biệt`,`Compare`)}),(0,B.jsx)(m,{disabled:F.saving||!F.conflict?.digest||F.conflict.protected||F.conflict.readOnly,onClick:()=>{F.conflict&&F.save(F.conflict.path,F.conflict)},children:S(v,`Ghi đè`,`Overwrite`)})]})]})]})}export{Le 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-BZqu1pjw.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-DNZbaWhT.js","assets/bootstrap-CedkNtRG.js","assets/api-BQS4Dtrr.js","assets/latest-request-DXcYQW86.js","assets/App-DQwj6l-F.js","assets/ui-preferences-OfS30-ZV.js","assets/ActivityPanel-DeeJLOYx.js","assets/view-model-BrdSO09E.js","assets/workspace-navigation-DW8zhH6U.js","assets/AttachmentImage-eZKqLYZ2.js","assets/transcript-view-model-BB1niiXd.js","assets/LineReview-CB3mQe7m.js","assets/GatewayApp-CP8GpZsK.js","assets/SettingsNavigation-BF4X5xkR.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{An as n,Cn as r,Dn as i,Fn as a,Gt as o,In as s,Ln as c,On as l,Pn as u,Rn as d,Sn as f,Ut as p,Wt as m,bn as h,gn as g,jn as _,kn as v,ln as y,mn as b,pn as x,un as S,vn as ee,yn as te}from"./vendor-DNZbaWhT.js";import{a as ne,n as re,o as ie,s as ae,t as oe}from"./ui-preferences-OfS30-ZV.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 se=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,ae());else{var t=n(l);t!==null&&ce(x,t.startTime-e)}}}var S=!1,ee=-1,te=5,ne=-1;function re(){return g?!0:!(e.unstable_now()-ne<te)}function ie(){if(g=!1,S){var t=e.unstable_now();ne=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(ee),ee=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&re());){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&&ce(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?ae():S=!1}}}var ae;if(typeof y==`function`)ae=function(){y(ie)};else if(typeof MessageChannel<`u`){var oe=new MessageChannel,se=oe.port2;oe.port1.onmessage=ie,ae=function(){se.postMessage(null)}}else ae=function(){_(ie,0)};function ce(t,n){ee=_(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`):te=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(ee),ee=-1):h=!0,ce(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,ae()))),r},e.unstable_shouldYield=re,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),ce=t(((e,t)=>{t.exports=se()})),le=t((e=>{var t=ce(),n=d(),r=c();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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(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 s(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 l(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 u(e){if(o(e)!==e)throw Error(i(188))}function f(e){var t=e.alternate;if(!t){if(t=o(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 s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return u(a),e;if(s===r)return u(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,l=a.child;l;){if(l===n){c=!0,n=a,r=s;break}if(l===r){c=!0,r=a,n=s;break}l=l.sibling}if(!c){for(l=s.child;l;){if(l===n){c=!0,n=s,r=a;break}if(l===r){c=!0,r=s,n=a;break}l=l.sibling}if(!c)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`),ee=Symbol.for(`react.forward_ref`),te=Symbol.for(`react.suspense`),ne=Symbol.for(`react.suspense_list`),re=Symbol.for(`react.memo`),ie=Symbol.for(`react.lazy`),ae=Symbol.for(`react.activity`),oe=Symbol.for(`react.memo_cache_sentinel`),se=Symbol.iterator;function le(e){return typeof e!=`object`||!e?null:(e=se&&e[se]||e[`@@iterator`],typeof e==`function`?e:null)}var ue=Symbol.for(`react.client.reference`);function C(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ue?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 te:return`Suspense`;case ne:return`SuspenseList`;case ae: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 ee:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case re:return t=e.displayName||null,t===null?C(e.type)||`Memo`:t;case ie:t=e._payload,e=e._init;try{return C(e(t))}catch{}}return null}var de=Array.isArray,w=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,T=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E={pending:!1,data:null,method:null,action:null},fe=[],pe=-1;function me(e){return{current:e}}function D(e){0>pe||(e.current=fe[pe],fe[pe]=null,pe--)}function O(e,t){pe++,fe[pe]=e.current,e.current=t}var he=me(null),ge=me(null),_e=me(null),ve=me(null);function ye(e,t){switch(O(_e,t),O(ge,e),O(he,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}}D(he),O(he,e)}function be(){D(he),D(ge),D(_e)}function xe(e){e.memoizedState!==null&&O(ve,e);var t=he.current,n=Hd(t,e.type);t!==n&&(O(ge,e),O(he,n))}function Se(e){ge.current===e&&(D(he),D(ge)),ve.current===e&&(D(ve),Qf._currentValue=E)}var Ce,we;function Te(e){if(Ce===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ce=t&&t[1]||``,we=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+Ce+e+we}var Ee=!1;function De(e,t){if(!e||Ee)return``;Ee=!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 be(){}var xe=({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 be;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function Se(){}function Ce(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function we(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 Te(e){return we(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Ee(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=ge,colorSchemeStorageKey:o=_e,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=xe,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=C.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=C.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=C.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=C.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Ce(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=C.useState(l||!d);C.useEffect(()=>{v(!0)},[]);let y=Te(h),b=C.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Ce(r)}})},[f,t]),x=C.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 we(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=C.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),ee=C.useRef(S);return ee.current=S,C.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>ee.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),C.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||Se,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||Se,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||Se;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 De=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function Oe(e){let{themeId:t,theme:n={},modeStorageKey:i=ge,colorSchemeStorageKey:a=_e,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=C.createContext(void 0),d=()=>C.useContext(u)||l,f={},p={};function m(e){let{children:l,theme:d,modeStorageKey:m=i,colorSchemeStorageKey:h=a,disableTransitionOnChange:g=o,storageManager:_,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:ee=!1,defaultMode:te=`system`,forceThemeRerender:ne=!1,noSsr:re}=e,ie=C.useRef(!1),ae=w(),oe=C.useContext(u),se=!!oe&&!S,ce=C.useMemo(()=>d||(typeof n==`function`?n():n),[d]),le=ce[t],ue=le||ce,{colorSchemes:de=f,components:T=p,cssVarPrefix:fe}=ue,pe=Object.keys(de).filter(e=>!!de[e]).join(`,`),me=C.useMemo(()=>pe.split(`,`),[pe]),D=typeof s==`string`?s:s.light,O=typeof s==`string`?s:s.dark,{mode:ge,setMode:_e,systemMode:ve,lightColorScheme:ye,darkColorScheme:be,colorScheme:xe,setColorScheme:Se}=Ee({supportedColorSchemes:me,defaultLightColorScheme:D,defaultDarkColorScheme:O,modeStorageKey:m,colorSchemeStorageKey:h,defaultMode:de[D]&&de[O]?te:de[ue.defaultColorScheme]?.palette?.mode||ue.palette?.mode,storageManager:_,storageWindow:y,noSsr:re}),Ce=ge,we=xe;se&&(Ce=oe.mode,we=oe.colorScheme);let Te=we||ue.defaultColorScheme;ue.vars&&!ne&&(Te=ue.defaultColorScheme);let Oe=C.useMemo(()=>{let e=ue.generateThemeVars?.()||ue.vars,t={...ue,components:T,colorSchemes:de,cssVarPrefix:fe,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),Te){let e=de[Te];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},[ue,Te,T,de,fe]),ke=ue.colorSchemeSelector;r(()=>{if(we&&x&&ke&&ke!==`media`){let e=ke,t=ke;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))x.classList.remove(...me.map(e=>t.substring(1).replace(`%s`,e))),x.classList.add(t.substring(1).replace(`%s`,we));else{let e=t.replace(`%s`,we).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||me.forEach(e=>{x.removeAttribute(t.replace(we,e))}),x.setAttribute(t,n?n.replace(/"|'/g,``):``)}else x.setAttribute(t,we)}}},[we,ke,x,me]),C.useEffect(()=>{let e;if(g&&ie.current&&b){let t=b.createElement(`style`);t.appendChild(b.createTextNode(De)),b.head.appendChild(t),window.getComputedStyle(b.body),e=setTimeout(()=>{b.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[we,g,b]),C.useEffect(()=>(ie.current=!0,()=>{ie.current=!1}),[]);let Ae=C.useMemo(()=>({allColorSchemes:me,colorScheme:we,darkColorScheme:be,lightColorScheme:ye,mode:Ce,setColorScheme:Se,setMode:_e,systemMode:ve}),[me,we,be,ye,Ce,Se,_e,ve,Oe.colorSchemeSelector]),je=!0;(ee||ue.cssVariables===!1||se&&ae?.cssVarPrefix===fe)&&(je=!1);let Me=(0,E.jsxs)(C.Fragment,{children:[(0,E.jsx)(he,{themeId:le?t:void 0,theme:Oe,children:l}),je&&(0,E.jsx)(v,{styles:Oe.generateStyleSheets?.()||[]})]});return se?Me:(0,E.jsx)(u.Provider,{value:Ae,children:Me})}let h=typeof s==`string`?s:s.light,g=typeof s==`string`?s:s.dark;return{CssVarsProvider:m,useColorScheme:d,getInitColorSchemeScript:e=>ye({colorSchemeStorageKey:a,defaultLightColorScheme:h,defaultDarkColorScheme:g,modeStorageKey:i,...e})}}var ke=typeof S({})==`function`,Ae=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),je=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}}),Me=(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:Ae(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...je(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},Ne=`mui-ecs`,Pe=e=>{let t=Me(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${Ne})`]={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(.${Ne}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${Ne}))`]:{colorScheme:r.palette?.mode}}}),t},Fe=S(ke?({theme:e,enableColorScheme:t})=>Me(e,t):({theme:e})=>Pe(e));function Ie(e){let{children:t,enableColorScheme:n=!1}=y({props:e,name:`MuiCssBaseline`});return(0,E.jsxs)(C.Fragment,{children:[ke&&(0,E.jsx)(Fe,{enableColorScheme:n}),!ke&&!n&&(0,E.jsx)(`span`,{className:Ne,style:{display:`none`}}),t]})}function Le({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,E.jsx)(he,{...t,themeId:n?x:void 0,theme:n||e})}var Re={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:ze,useColorScheme:Be,getInitColorSchemeScript:Ve}=Oe({themeId:x,theme:()=>b({cssVariables:!0}),colorSchemeStorageKey:Re.colorSchemeStorageKey,modeStorageKey:Re.modeStorageKey,defaultColorScheme:{light:Re.defaultLightColorScheme,dark:Re.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:g(e.palette,e.typography)};return t.unstable_sx=function(e){return _({sx:e,theme:this})},t}}),He=ze;function Ue({theme:e,...t}){let n=C.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,E.jsx)(Le,{theme:n,...t}):(0,E.jsx)(He,{theme:e,...t})}var We=ue(),Ge=class extends C.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){let{locale:e,children:t}=this.props;return this.state.failed?(0,E.jsxs)(m,{sx:{p:3},children:[(0,E.jsx)(o,{severity:`error`,children:re(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,E.jsx)(p,{onClick:()=>window.location.reload(),children:re(e,`Tải lại trang`,`Reload page`)})]}):(0,E.jsx)(C.Suspense,{fallback:(0,E.jsx)(m,{role:`status`,sx:{p:3},children:re(e,`Đang tải giao diện…`,`Loading view…`)}),children:t})}};function Ke(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 ${f(`#000`,.7)}, 0 0 0 1px ${f(s,.06)}`:`0 16px 40px -16px ${f(`#1a1a2e`,.25)}, 0 0 0 1px ${f(s,.06)}`,d=`0 0 0 3px ${f(r,t?.28:.22)}`;return b({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:f(s,.05),selected:f(s,.08),focus:f(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:f(r,.28)},"*":{scrollbarWidth:`thin`,scrollbarColor:`${f(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:f(s,.14),"&:hover":{borderColor:f(s,.28),backgroundColor:f(s,.04)}},contained:{"&.MuiButton-colorPrimary:hover":{backgroundColor:f(r,.88),boxShadow:`0 0 0 3px ${f(r,.18)}`}},text:{"&:hover":{backgroundColor:f(s,.06)}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:8,color:c,transition:`background-color .16s, color .16s`,"&:hover":{color:s,backgroundColor:f(s,.07)},"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{padding:5}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:999,fontWeight:500,fontSize:`0.75rem`},outlined:{borderColor:f(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:f(s,.05),color:s},"&.Mui-selected":{color:s,backgroundColor:f(s,t?.08:.07)},"&.Mui-selected:hover":{backgroundColor:f(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:f(s,t?.03:.02),transition:`box-shadow .16s`,"& .MuiOutlinedInput-notchedOutline":{borderColor:f(s,.12)},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:f(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?f(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:f(s,.06)},"&.Mui-selected":{backgroundColor:f(r,.12)}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:14,boxShadow:u,backgroundImage:`none`}}},MuiBackdrop:{styleOverrides:{root:{backgroundColor:f(`#000`,t?.6:.32),backdropFilter:`blur(2px)`}}},MuiDrawer:{styleOverrides:{paper:{backgroundImage:`none`,backgroundColor:o}}},MuiAlert:{styleOverrides:{root:{borderRadius:10,border:`1px solid ${f(s,.1)}`,fontSize:`0.8125rem`,alignItems:`center`}}},MuiDivider:{styleOverrides:{root:{borderColor:l}}},MuiLinearProgress:{styleOverrides:{root:{borderRadius:999,height:4},bar:{borderRadius:999}}}}})}function qe(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 Je=`modulepreload`,Ye=function(e){return`/`+e},Xe={},Ze=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=Ye(t,n),t=s(t),t in Xe)return;Xe[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`:Je,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)})},Qe=document.getElementById(`root`);if(!Qe)throw Error(`Piagent WebUI root is missing`);var $e=document.querySelector(`meta[name="csp-nonce"]`)?.content,et=s({key:`piagent-mui`,nonce:$e&&!$e.startsWith(`__PIAGENT_`)?$e:void 0,prepend:!0}),tt=(0,C.lazy)(()=>Ze(()=>import(`./InspectionApp-CGgHsOyC.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),nt=(0,C.lazy)(()=>Ze(()=>import(`./GatewayApp-Dvo96qoX.js`),__vite__mapDeps([14,1,2,7,3,4,9,15,10,11,12,16,5,17])));function rt(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function it(){let[e,t]=(0,C.useState)(()=>rt(`piagent-webui-locale`,[`vi`,`en`],qe(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,C.useState)(()=>rt(`piagent-webui-theme`,ie.map(e=>e.id),``)||ne[rt(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)]),i=ae(n)??ae(ne.dark),a=i.mode,o=(0,C.useCallback)(e=>r(t=>ae(t)?.mode===e?t:ne[e]),[]),s=(0,C.useMemo)(()=>Ke(i),[i]);(0,C.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,C.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,E.jsx)(oe,{value:c,children:(0,E.jsxs)(Ue,{theme:s,children:[(0,E.jsx)(Ie,{}),(0,E.jsx)(Ge,{locale:e,children:l===`gateway`?(0,E.jsx)(nt,{}):(0,E.jsx)(tt,{})})]})})}(0,We.createRoot)(Qe).render((0,E.jsx)(C.StrictMode,{children:(0,E.jsx)(u,{value:et,children:(0,E.jsx)(it,{})})}));export{Ge as n,Ze as t};
|
|
37
|
+
} catch(e){}})();`}},`mui-color-scheme-init`)}function be(){}var xe=({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 be;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function Se(){}function Ce(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function we(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 Te(e){return we(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Ee(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=ge,colorSchemeStorageKey:o=_e,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=xe,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=C.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=C.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=C.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=C.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Ce(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=C.useState(l||!d);C.useEffect(()=>{v(!0)},[]);let y=Te(h),b=C.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Ce(r)}})},[f,t]),x=C.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 we(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=C.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),ee=C.useRef(S);return ee.current=S,C.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>ee.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),C.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||Se,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||Se,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||Se;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 De=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function Oe(e){let{themeId:t,theme:n={},modeStorageKey:i=ge,colorSchemeStorageKey:a=_e,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=C.createContext(void 0),d=()=>C.useContext(u)||l,f={},p={};function m(e){let{children:l,theme:d,modeStorageKey:m=i,colorSchemeStorageKey:h=a,disableTransitionOnChange:g=o,storageManager:_,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:ee=!1,defaultMode:te=`system`,forceThemeRerender:ne=!1,noSsr:re}=e,ie=C.useRef(!1),ae=w(),oe=C.useContext(u),se=!!oe&&!S,ce=C.useMemo(()=>d||(typeof n==`function`?n():n),[d]),le=ce[t],ue=le||ce,{colorSchemes:de=f,components:T=p,cssVarPrefix:fe}=ue,pe=Object.keys(de).filter(e=>!!de[e]).join(`,`),me=C.useMemo(()=>pe.split(`,`),[pe]),D=typeof s==`string`?s:s.light,O=typeof s==`string`?s:s.dark,{mode:ge,setMode:_e,systemMode:ve,lightColorScheme:ye,darkColorScheme:be,colorScheme:xe,setColorScheme:Se}=Ee({supportedColorSchemes:me,defaultLightColorScheme:D,defaultDarkColorScheme:O,modeStorageKey:m,colorSchemeStorageKey:h,defaultMode:de[D]&&de[O]?te:de[ue.defaultColorScheme]?.palette?.mode||ue.palette?.mode,storageManager:_,storageWindow:y,noSsr:re}),Ce=ge,we=xe;se&&(Ce=oe.mode,we=oe.colorScheme);let Te=we||ue.defaultColorScheme;ue.vars&&!ne&&(Te=ue.defaultColorScheme);let Oe=C.useMemo(()=>{let e=ue.generateThemeVars?.()||ue.vars,t={...ue,components:T,colorSchemes:de,cssVarPrefix:fe,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),Te){let e=de[Te];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},[ue,Te,T,de,fe]),ke=ue.colorSchemeSelector;r(()=>{if(we&&x&&ke&&ke!==`media`){let e=ke,t=ke;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))x.classList.remove(...me.map(e=>t.substring(1).replace(`%s`,e))),x.classList.add(t.substring(1).replace(`%s`,we));else{let e=t.replace(`%s`,we).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||me.forEach(e=>{x.removeAttribute(t.replace(we,e))}),x.setAttribute(t,n?n.replace(/"|'/g,``):``)}else x.setAttribute(t,we)}}},[we,ke,x,me]),C.useEffect(()=>{let e;if(g&&ie.current&&b){let t=b.createElement(`style`);t.appendChild(b.createTextNode(De)),b.head.appendChild(t),window.getComputedStyle(b.body),e=setTimeout(()=>{b.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[we,g,b]),C.useEffect(()=>(ie.current=!0,()=>{ie.current=!1}),[]);let Ae=C.useMemo(()=>({allColorSchemes:me,colorScheme:we,darkColorScheme:be,lightColorScheme:ye,mode:Ce,setColorScheme:Se,setMode:_e,systemMode:ve}),[me,we,be,ye,Ce,Se,_e,ve,Oe.colorSchemeSelector]),je=!0;(ee||ue.cssVariables===!1||se&&ae?.cssVarPrefix===fe)&&(je=!1);let Me=(0,E.jsxs)(C.Fragment,{children:[(0,E.jsx)(he,{themeId:le?t:void 0,theme:Oe,children:l}),je&&(0,E.jsx)(v,{styles:Oe.generateStyleSheets?.()||[]})]});return se?Me:(0,E.jsx)(u.Provider,{value:Ae,children:Me})}let h=typeof s==`string`?s:s.light,g=typeof s==`string`?s:s.dark;return{CssVarsProvider:m,useColorScheme:d,getInitColorSchemeScript:e=>ye({colorSchemeStorageKey:a,defaultLightColorScheme:h,defaultDarkColorScheme:g,modeStorageKey:i,...e})}}var ke=typeof S({})==`function`,Ae=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),je=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}}),Me=(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:Ae(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...je(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},Ne=`mui-ecs`,Pe=e=>{let t=Me(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${Ne})`]={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(.${Ne}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${Ne}))`]:{colorScheme:r.palette?.mode}}}),t},Fe=S(ke?({theme:e,enableColorScheme:t})=>Me(e,t):({theme:e})=>Pe(e));function Ie(e){let{children:t,enableColorScheme:n=!1}=y({props:e,name:`MuiCssBaseline`});return(0,E.jsxs)(C.Fragment,{children:[ke&&(0,E.jsx)(Fe,{enableColorScheme:n}),!ke&&!n&&(0,E.jsx)(`span`,{className:Ne,style:{display:`none`}}),t]})}function Le({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,E.jsx)(he,{...t,themeId:n?x:void 0,theme:n||e})}var Re={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:ze,useColorScheme:Be,getInitColorSchemeScript:Ve}=Oe({themeId:x,theme:()=>b({cssVariables:!0}),colorSchemeStorageKey:Re.colorSchemeStorageKey,modeStorageKey:Re.modeStorageKey,defaultColorScheme:{light:Re.defaultLightColorScheme,dark:Re.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:g(e.palette,e.typography)};return t.unstable_sx=function(e){return _({sx:e,theme:this})},t}}),He=ze;function Ue({theme:e,...t}){let n=C.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,E.jsx)(Le,{theme:n,...t}):(0,E.jsx)(He,{theme:e,...t})}var We=ue(),Ge=class extends C.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}render(){let{locale:e,children:t}=this.props;return this.state.failed?(0,E.jsxs)(m,{sx:{p:3},children:[(0,E.jsx)(o,{severity:`error`,children:re(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,E.jsx)(p,{onClick:()=>window.location.reload(),children:re(e,`Tải lại trang`,`Reload page`)})]}):(0,E.jsx)(C.Suspense,{fallback:(0,E.jsx)(m,{role:`status`,sx:{p:3},children:re(e,`Đang tải giao diện…`,`Loading view…`)}),children:t})}};function Ke(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 ${f(`#000`,.7)}, 0 0 0 1px ${f(s,.06)}`:`0 16px 40px -16px ${f(`#1a1a2e`,.25)}, 0 0 0 1px ${f(s,.06)}`,d=`0 0 0 3px ${f(r,t?.28:.22)}`;return b({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:f(s,.05),selected:f(s,.08),focus:f(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:f(r,.28)},"*":{scrollbarWidth:`thin`,scrollbarColor:`${f(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:f(s,.14),"&:hover":{borderColor:f(s,.28),backgroundColor:f(s,.04)}},contained:{"&.MuiButton-colorPrimary:hover":{backgroundColor:f(r,.88),boxShadow:`0 0 0 3px ${f(r,.18)}`}},text:{"&:hover":{backgroundColor:f(s,.06)}}}},MuiIconButton:{styleOverrides:{root:{borderRadius:8,color:c,transition:`background-color .16s, color .16s`,"&:hover":{color:s,backgroundColor:f(s,.07)},"&.Mui-focusVisible":{boxShadow:d}},sizeSmall:{padding:5}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:999,fontWeight:500,fontSize:`0.75rem`},outlined:{borderColor:f(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:f(s,.05),color:s},"&.Mui-selected":{color:s,backgroundColor:f(s,t?.08:.07)},"&.Mui-selected:hover":{backgroundColor:f(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:f(s,t?.03:.02),transition:`box-shadow .16s`,"& .MuiOutlinedInput-notchedOutline":{borderColor:f(s,.12)},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:f(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?f(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:f(s,.06)},"&.Mui-selected":{backgroundColor:f(r,.12)}}}},MuiDialog:{styleOverrides:{paper:{borderRadius:14,boxShadow:u,backgroundImage:`none`}}},MuiBackdrop:{styleOverrides:{root:{backgroundColor:f(`#000`,t?.6:.32),backdropFilter:`blur(2px)`}}},MuiDrawer:{styleOverrides:{paper:{backgroundImage:`none`,backgroundColor:o}}},MuiAlert:{styleOverrides:{root:{borderRadius:10,border:`1px solid ${f(s,.1)}`,fontSize:`0.8125rem`,alignItems:`center`}}},MuiDivider:{styleOverrides:{root:{borderColor:l}}},MuiLinearProgress:{styleOverrides:{root:{borderRadius:999,height:4},bar:{borderRadius:999}}}}})}function qe(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 Je=`modulepreload`,Ye=function(e){return`/`+e},Xe={},Ze=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=Ye(t,n),t=s(t),t in Xe)return;Xe[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`:Je,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)})},Qe=document.getElementById(`root`);if(!Qe)throw Error(`Piagent WebUI root is missing`);var $e=document.querySelector(`meta[name="csp-nonce"]`)?.content,et=s({key:`piagent-mui`,nonce:$e&&!$e.startsWith(`__PIAGENT_`)?$e:void 0,prepend:!0}),tt=(0,C.lazy)(()=>Ze(()=>import(`./InspectionApp-BZqu1pjw.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),nt=(0,C.lazy)(()=>Ze(()=>import(`./GatewayApp-CP8GpZsK.js`),__vite__mapDeps([14,1,2,7,3,4,9,15,10,11,12,16,5,17])));function rt(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function it(){let[e,t]=(0,C.useState)(()=>rt(`piagent-webui-locale`,[`vi`,`en`],qe(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,C.useState)(()=>rt(`piagent-webui-theme`,ie.map(e=>e.id),``)||ne[rt(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)]),i=ae(n)??ae(ne.dark),a=i.mode,o=(0,C.useCallback)(e=>r(t=>ae(t)?.mode===e?t:ne[e]),[]),s=(0,C.useMemo)(()=>Ke(i),[i]);(0,C.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,C.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,E.jsx)(oe,{value:c,children:(0,E.jsxs)(Ue,{theme:s,children:[(0,E.jsx)(Ie,{}),(0,E.jsx)(Ge,{locale:e,children:l===`gateway`?(0,E.jsx)(nt,{}):(0,E.jsx)(tt,{})})]})})}(0,We.createRoot)(Qe).render((0,E.jsx)(C.StrictMode,{children:(0,E.jsx)(u,{value:et,children:(0,E.jsx)(it,{})})}));export{Ge as n,Ze 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-CfJC4Unf.js"></script>
|
|
11
11
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
|
12
12
|
<link rel="modulepreload" crossorigin href="/assets/vendor-DNZbaWhT.js">
|
|
13
13
|
<link rel="modulepreload" crossorigin href="/assets/ui-preferences-OfS30-ZV.js">
|
|
@@ -40,7 +40,7 @@ type HarnessFinding = { severity: "blocking" | "major" | "minor"; file: string;
|
|
|
40
40
|
type HarnessIssue = { kind: "wrong_premise" | "conflicts_with_request" | "ambiguous" | "out_of_scope"; detail: string };
|
|
41
41
|
type HarnessProcess = { phase: "plan" | "verify" | "review" | "reviewing" | "final" | "objection" | "answer" | "claims" | "rejudge" | "dispute" | "continue" | "undo"; outcome?: string; loop?: number; maxLoops?: number;
|
|
42
42
|
verified?: boolean; reviewed?: boolean; blockingOpen?: number; planOpen?: number; planDone?: number; planSteps?: number; round?: number; maxRounds?: number; idle?: number; planSkipped?: true; partOnly?: true; verifyPolicy?: string; reviewPolicy?: string; reviewUnavailable?: string;
|
|
43
|
-
findings?: HarnessFinding[]; role?: "scout" | "research" | "verify" | "review"; by?: "main" | "harness"; disputes?: number; unchanged?: true; issues?: HarnessIssue[]; claims?: { claim: string }[];
|
|
43
|
+
findings?: HarnessFinding[]; role?: "scout" | "research" | "advisor" | "general" | "verify" | "review"; by?: "main" | "harness"; disputes?: number; unchanged?: true; issues?: HarnessIssue[]; claims?: { claim: string }[];
|
|
44
44
|
undo?: { result: "done" | "refused" | "busy" | "none" | "failed"; restored: number; removed: number; files: string[]; more?: boolean } };
|
|
45
45
|
export type TranscriptDocument = { schemaVersion: 1; version: "piagent-webui-transcript-v1"; generatedAt: string; identity: TranscriptIdentity;
|
|
46
46
|
revision: TranscriptRevision; eventCursor: string; state: "ready" | "unavailable"; items: TranscriptItem[];
|
|
@@ -149,7 +149,7 @@ function typedSkillCall(text: string): string {
|
|
|
149
149
|
}
|
|
150
150
|
// A company request fails with Studio's (or Agent Watch's) own code: who
|
|
151
151
|
// failed, which kind of failure, and Studio's request id. Text is never shown.
|
|
152
|
-
export type CompanyFailure = { role: "main" | "scout" | "research" | "verify" | "review"; reasonCode: string; code: string; requestRef: string | null; local: boolean };
|
|
152
|
+
export type CompanyFailure = { role: "main" | "scout" | "research" | "advisor" | "general" | "verify" | "review"; reasonCode: string; code: string; requestRef: string | null; local: boolean };
|
|
153
153
|
export function companyFailure(text: unknown): CompanyFailure | null {
|
|
154
154
|
const parsed = parseFailure(text);
|
|
155
155
|
if (!parsed || !/^[A-Za-z0-9][A-Za-z0-9_:.-]{0,79}$/.test(parsed.code)) return null;
|
|
@@ -217,7 +217,7 @@ const PROCESS_OUTCOMES = ["no_change", "interrupted", "disputed", "blocking_open
|
|
|
217
217
|
// "continue": the harness sent the agent back to a checklist with open steps.
|
|
218
218
|
// "undo": the member's /undo put the last turn's files back (checkpoints.mjs).
|
|
219
219
|
const PROCESS_PHASES = ["plan", "verify", "review", "reviewing", "final", "objection", "answer", "claims", "rejudge", "dispute", "continue", "undo"];
|
|
220
|
-
const ISSUE_KINDS = ["wrong_premise", "conflicts_with_request", "ambiguous", "out_of_scope"], HELPER_ROLES = ["scout", "research", "verify", "review"];
|
|
220
|
+
const ISSUE_KINDS = ["wrong_premise", "conflicts_with_request", "ambiguous", "out_of_scope"], HELPER_ROLES = ["scout", "research", "advisor", "general", "verify", "review"];
|
|
221
221
|
const POLICY_MODES = ["off", "suggest", "require"];
|
|
222
222
|
function harnessProcess(details: any): HarnessProcess | null {
|
|
223
223
|
if (!PROCESS_PHASES.includes(details?.phase)) return null;
|
|
@@ -95,10 +95,12 @@ export function companyFailureText(reason: string, code: string | null, locale:
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// Who failed: a harness role, never a model name.
|
|
98
|
-
export type FailureRole = "main" | "scout" | "research" | "verify" | "review";
|
|
98
|
+
export type FailureRole = "main" | "scout" | "research" | "advisor" | "general" | "verify" | "review";
|
|
99
99
|
export function failureRoleText(role: FailureRole, locale: CopyLocale): string {
|
|
100
100
|
return role === "main" ? "Main agent" : role === "scout" ? pick(locale, ["Subagent scout", "Scout subagent"])
|
|
101
101
|
: role === "research" ? pick(locale, ["Subagent research", "Research subagent"])
|
|
102
|
+
: role === "advisor" ? pick(locale, ["Subagent advisor", "Advisor subagent"])
|
|
103
|
+
: role === "general" ? pick(locale, ["Subagent general", "General subagent"])
|
|
102
104
|
: role === "verify" ? pick(locale, ["Subagent verify", "Verify subagent"])
|
|
103
105
|
: pick(locale, ["Subagent review", "Review subagent"]);
|
|
104
106
|
}
|
|
@@ -7,7 +7,7 @@ import { failureRoleText, type CopyLocale, type FailureRole } from "./company-co
|
|
|
7
7
|
export type TurnEndState = "done" | "midway" | "failed" | "cancelled";
|
|
8
8
|
export type TurnEnd = { state: TurnEndState; planSteps: number; planDone: number; planDeferred?: number; rounds: number;
|
|
9
9
|
reason?: "idle" | "limit" | "policy"; role?: FailureRole; code?: string };
|
|
10
|
-
const ROLES: FailureRole[] = ["main", "scout", "research", "verify", "review"];
|
|
10
|
+
const ROLES: FailureRole[] = ["main", "scout", "research", "advisor", "general", "verify", "review"];
|
|
11
11
|
// The harness gives up after this many rounds in a row without progress, and
|
|
12
12
|
// runs at most this many (packages/piagent-core/managed/continuation.mjs).
|
|
13
13
|
export const IDLE_ROUNDS = 2, MAX_ROUNDS = 30;
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
}
|
|
187
187
|
},
|
|
188
188
|
"outcome": { "enum": ["no_change", "interrupted", "disputed", "blocking_open", "unverified", "review_unavailable", "unreviewed", "clean"] },
|
|
189
|
-
"role": { "enum": ["scout", "research", "verify", "review"] },
|
|
189
|
+
"role": { "enum": ["scout", "research", "advisor", "general", "verify", "review"] },
|
|
190
190
|
"by": { "enum": ["main", "harness"] },
|
|
191
191
|
"disputes": { "type": "integer", "minimum": 1, "maximum": 1000 },
|
|
192
192
|
"unchanged": { "const": true },
|
|
@@ -257,7 +257,7 @@
|
|
|
257
257
|
"planDeferred": { "type": "integer", "minimum": 1, "maximum": 30 },
|
|
258
258
|
"rounds": { "type": "integer", "minimum": 0, "maximum": 30 },
|
|
259
259
|
"reason": { "enum": ["idle", "limit", "policy"] },
|
|
260
|
-
"role": { "enum": ["main", "scout", "research", "verify", "review"] },
|
|
260
|
+
"role": { "enum": ["main", "scout", "research", "advisor", "general", "verify", "review"] },
|
|
261
261
|
"code": { "type": "string", "pattern": "^[a-z0-9_]{1,64}$" }
|
|
262
262
|
}
|
|
263
263
|
},
|
|
@@ -266,7 +266,7 @@
|
|
|
266
266
|
"additionalProperties": false,
|
|
267
267
|
"required": ["role", "reasonCode", "code", "requestRef", "local"],
|
|
268
268
|
"properties": {
|
|
269
|
-
"role": { "enum": ["main", "scout", "research", "verify", "review"] },
|
|
269
|
+
"role": { "enum": ["main", "scout", "research", "advisor", "general", "verify", "review"] },
|
|
270
270
|
"reasonCode": { "$ref": "common-v1.schema.json#/$defs/reasonCode" },
|
|
271
271
|
"code": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9_:.-]{0,79}$" },
|
|
272
272
|
"requestRef": { "anyOf": [{ "type": "string", "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$" }, { "type": "null" }] },
|
|
@@ -5,73 +5,73 @@
|
|
|
5
5
|
"id": "GHSA-xjj6-f33q-929c",
|
|
6
6
|
"package": "undici",
|
|
7
7
|
"node": "node_modules/undici",
|
|
8
|
-
"decided": "2026-
|
|
9
|
-
"until": "2026-11-
|
|
10
|
-
"reason": "Denial of service (an unhandled error crashes the process) when a response lists too many content-encodings; no data exposure. undici 8.10.2 is an exact dependency of every published Pi host (1.3.0 and 1.4.0), installed globally, so no Piagent change can update it; 8.12.2 fixes it. Remove when a Pi host carries undici >= 8.12.2."
|
|
8
|
+
"decided": "2026-11-09",
|
|
9
|
+
"until": "2026-11-21",
|
|
10
|
+
"reason": "Denial of service (an unhandled error crashes the process) when a response lists too many content-encodings; no data exposure. undici 8.10.2 is an exact dependency of every published Pi host (1.3.0 and 1.4.0), installed globally, so no Piagent change can update it; 8.12.2 fixes it. Remove when a Pi host carries undici >= 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
11
11
|
},
|
|
12
12
|
{
|
|
13
13
|
"id": "GHSA-4qv8-2p9j-2685",
|
|
14
14
|
"package": "undici",
|
|
15
15
|
"node": "node_modules/undici",
|
|
16
|
-
"decided": "2026-
|
|
17
|
-
"until": "2026-11-
|
|
18
|
-
"reason": "Denial of service (unbounded memory) in undici's EventSource parser fed by a hostile server; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2."
|
|
16
|
+
"decided": "2026-11-09",
|
|
17
|
+
"until": "2026-11-21",
|
|
18
|
+
"reason": "Denial of service (unbounded memory) in undici's EventSource parser fed by a hostile server; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"id": "GHSA-f72v-6w45-q472",
|
|
22
22
|
"package": "undici",
|
|
23
23
|
"node": "node_modules/undici",
|
|
24
|
-
"decided": "2026-
|
|
25
|
-
"until": "2026-11-
|
|
26
|
-
"reason": "Subresource Integrity check bypassed with a non-lowercase algorithm token; Pi does not fetch with integrity metadata. Pinned by the Pi host as above; fixed in undici 8.12.2."
|
|
24
|
+
"decided": "2026-11-09",
|
|
25
|
+
"until": "2026-11-21",
|
|
26
|
+
"reason": "Subresource Integrity check bypassed with a non-lowercase algorithm token; Pi does not fetch with integrity metadata. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"id": "GHSA-4w7w-5xrc-9h26",
|
|
30
30
|
"package": "undici",
|
|
31
31
|
"node": "node_modules/undici",
|
|
32
|
-
"decided": "2026-
|
|
33
|
-
"until": "2026-11-
|
|
34
|
-
"reason": "Cache poisoning and cross-user disclosure through cross-origin redirects in undici's cache; Pi does not share an HTTP cache between users. Pinned by the Pi host as above (8.10.2 in 1.3.0 and 1.4.0); fixed in undici 8.12.2."
|
|
32
|
+
"decided": "2026-11-09",
|
|
33
|
+
"until": "2026-11-21",
|
|
34
|
+
"reason": "Cache poisoning and cross-user disclosure through cross-origin redirects in undici's cache; Pi does not share an HTTP cache between users. Pinned by the Pi host as above (8.10.2 in 1.3.0 and 1.4.0); fixed in undici 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"id": "GHSA-2m5v-pch6-74hx",
|
|
38
38
|
"package": "undici",
|
|
39
39
|
"node": "node_modules/undici",
|
|
40
|
-
"decided": "2026-
|
|
41
|
-
"until": "2026-11-
|
|
42
|
-
"reason": "TLS certificate validation bypassed when an Agent drops its tls options; affects callers that pass custom tls settings to an undici Agent. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner accepted on 2026-10-28 to keep releases going; revisit as soon as a Pi host carries undici >= 8.12.2."
|
|
40
|
+
"decided": "2026-11-09",
|
|
41
|
+
"until": "2026-11-21",
|
|
42
|
+
"reason": "TLS certificate validation bypassed when an Agent drops its tls options; affects callers that pass custom tls settings to an undici Agent. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner accepted on 2026-10-28 to keep releases going; revisit as soon as a Pi host carries undici >= 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
"id": "GHSA-qrxm-fqhp-jwvm",
|
|
46
46
|
"package": "undici",
|
|
47
47
|
"node": "node_modules/undici",
|
|
48
|
-
"decided": "2026-
|
|
49
|
-
"until": "2026-11-
|
|
50
|
-
"reason": "Denial of service through a TLS 1.2 certificate-changing renegotiation by a hostile server; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2."
|
|
48
|
+
"decided": "2026-11-09",
|
|
49
|
+
"until": "2026-11-21",
|
|
50
|
+
"reason": "Denial of service through a TLS 1.2 certificate-changing renegotiation by a hostile server; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"id": "GHSA-9fm3-97px-rjf6",
|
|
54
54
|
"package": "undici",
|
|
55
55
|
"node": "node_modules/undici",
|
|
56
|
-
"decided": "2026-
|
|
57
|
-
"until": "2026-11-
|
|
58
|
-
"reason": "Denial of service from unbounded automatic PONG buffering in the WebSocket client fed by a hostile server; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2."
|
|
56
|
+
"decided": "2026-11-09",
|
|
57
|
+
"until": "2026-11-21",
|
|
58
|
+
"reason": "Denial of service from unbounded automatic PONG buffering in the WebSocket client fed by a hostile server; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
"id": "GHSA-55wc-3pg8-jfw6",
|
|
62
62
|
"package": "undici",
|
|
63
63
|
"node": "node_modules/undici",
|
|
64
|
-
"decided": "2026-
|
|
65
|
-
"until": "2026-11-
|
|
66
|
-
"reason": "Denial of service from an unhandled exception in the decompress interceptor; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2."
|
|
64
|
+
"decided": "2026-11-09",
|
|
65
|
+
"until": "2026-11-21",
|
|
66
|
+
"reason": "Denial of service from an unhandled exception in the decompress interceptor; no data exposure. Pinned by the Pi host as above; fixed in undici 8.12.2. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"id": "GHSA-g3hv-75wg-m249",
|
|
70
70
|
"package": "minimatch",
|
|
71
71
|
"node": "node_modules/minimatch",
|
|
72
|
-
"decided": "2026-
|
|
73
|
-
"until": "2026-11-
|
|
74
|
-
"reason": "Denial of service through globparts amplification; no data exposure. minimatch 10.2.6 is an exact dependency of Pi 1.3.0 and 1.4.0; fixed in minimatch 11.0.1, a major version the Pi host does not take yet."
|
|
72
|
+
"decided": "2026-11-09",
|
|
73
|
+
"until": "2026-11-21",
|
|
74
|
+
"reason": "Denial of service through globparts amplification; no data exposure. minimatch 10.2.6 is an exact dependency of Pi 1.3.0 and 1.4.0; fixed in minimatch 11.0.1, a major version the Pi host does not take yet. Owner extended 2026-11-09 to ship 1.52.0; Pi host 1.5.0 carries the fixes (undici 8.12.3, minimatch 11.0.3)."
|
|
75
75
|
}
|
|
76
76
|
]
|
|
77
77
|
}
|