@piagent/platform 1.48.5 → 1.49.0
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 +13 -0
- package/docs/command-reference-vietnamese.md +2 -2
- package/docs/distribution-standard.md +6 -6
- package/docs/operator-manual-vietnamese.md +7 -7
- package/docs/publishing-for-teams.md +1 -0
- package/docs/release-install-policy.md +2 -2
- package/docs/team-onboarding.md +2 -2
- package/docs-site/architecture.html +1 -1
- package/docs-site/assets/search-en.json +1 -1
- package/docs-site/assets/search-vi.json +1 -1
- package/docs-site/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/context-engine.html +1 -1
- package/docs-site/ecosystem.html +1 -1
- package/docs-site/en/architecture.html +1 -1
- package/docs-site/en/benchmark.html +1 -1
- package/docs-site/en/commands.html +1 -1
- package/docs-site/en/context-engine.html +1 -1
- package/docs-site/en/ecosystem.html +1 -1
- package/docs-site/en/index.html +9 -9
- package/docs-site/en/mcp-approval.html +1 -1
- package/docs-site/en/mcp-auth.html +1 -1
- package/docs-site/en/mcp-servers.html +1 -1
- package/docs-site/en/mcp.html +1 -1
- package/docs-site/en/permissions.html +1 -1
- package/docs-site/en/profiles.html +1 -1
- package/docs-site/en/quickstart.html +1 -1
- package/docs-site/en/runtime.html +1 -1
- package/docs-site/en/scope.html +1 -1
- package/docs-site/en/security.html +1 -1
- package/docs-site/en/team.html +1 -1
- package/docs-site/en/update.html +3 -3
- package/docs-site/en/whats-new.html +28 -17
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +9 -9
- package/docs-site/mcp-approval.html +1 -1
- package/docs-site/mcp-auth.html +1 -1
- package/docs-site/mcp-servers.html +1 -1
- package/docs-site/mcp.html +1 -1
- package/docs-site/permissions.html +1 -1
- package/docs-site/profiles.html +1 -1
- package/docs-site/quickstart.html +1 -1
- package/docs-site/releases.json +31 -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 +28 -17
- 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/check-questions.mjs +133 -0
- package/packages/piagent-core/managed/command-tools.mjs +2 -0
- package/packages/piagent-core/managed/helper-run.mjs +1 -1
- package/packages/piagent-core/managed/repository-checks.mjs +80 -0
- package/packages/piagent-core/managed/workflow.mjs +38 -88
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-webui/dist/client/assets/{App-DqN7B1JR.js → App-CU-wndsb.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{GatewayApp-B3--WjSd.js → GatewayApp-MIvgr7kn.js} +6 -6
- package/packages/piagent-webui/dist/client/assets/{InspectionApp-BKQiA0Ce.js → InspectionApp-Bfvr2S8S.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionAgentWorkspace-ZAdRbxVA.js → SessionAgentWorkspace-0Xowe-sG.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SessionInspectorDrawer-B2e4-1FG.js → SessionInspectorDrawer-72Z5908P.js} +2 -2
- package/packages/piagent-webui/dist/client/assets/{SettingsNavigation-C3MC0X4P.js → SettingsNavigation-Bu1A7x4F.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{SettingsPage-D4os5vHj.js → SettingsPage-DxGxE0AF.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{TerminalPanel-CVYUiDkn.js → TerminalPanel-BKgx9SjR.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceCodeEditor-E0Zopcke.js → WorkspaceCodeEditor-DFrh3qs2.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{WorkspaceExplorer-DldLoJyf.js → WorkspaceExplorer-D6ufO-eP.js} +3 -3
- package/packages/piagent-webui/dist/client/assets/{index-DcrpSyBK.js → index-C3CJv1wM.js} +2 -2
- package/packages/piagent-webui/dist/client/index.html +1 -1
- package/packages/piagent-webui/server/transcript-projection.ts +2 -1
- package/packages/piagent-webui/shared/process-copy.ts +3 -2
- package/schemas/piagent-webui/transcript-v1.schema.json +1 -0
- package/scripts/runtime-advisory-exceptions.json +8 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Bt as n,Dt as r,E as i,Et as a,G as o,J as s,K as c,L as l,O as u,Qt as d,Rn as f,Tt as p,Ut as m,W as h,Wt as g,Xt as _,a as v,bt as y,ct as b,d as x,ft as S,i as C,mt as w,p as T,q as E,qt as ee,rt as D,u as O,xt as k}from"./vendor-DNZbaWhT.js";import{i as A,n as j,o as M}from"./ui-preferences-OfS30-ZV.js";import{D as N,F as P,I as F,O as I,a as te,c as ne,pt as L,tt as R}from"./api-BQS4Dtrr.js";import{r as z}from"./view-model-CWNiS4JN.js";import{A as B,F as re,I as V,L as H,P as U,R as W,k as G,n as ie,t as ae,x as oe}from"./SettingsNavigation-C3MC0X4P.js";var K=e(f(),1),q=t(),se=_((0,q.jsx)(`path`,{d:`M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2M8.9 13.98l2.1 2.53 3.1-3.99c.2-.26.6-.26.8.01l3.51 4.68c.25.33.01.8-.4.8H6.02c-.42 0-.65-.48-.39-.81L8.12 14c.19-.26.57-.27.78-.02`}),`ImageRounded`),J=_((0,q.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M9.29 16.29 5.7 12.7a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0`}),`CheckCircleRounded`);function ce({catalog:e,refresh:t}){let{locale:i}=A(),[s,l]=(0,K.useState)(),[u,f]=(0,K.useState)(``),[_,v]=(0,K.useState)(!1),[b,x]=(0,K.useState)(null);(0,K.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,n=window.setTimeout(()=>{I(s.jobRef,e.signal).then(e=>{l(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||x(j(i,`Mất kết nối với luồng OAuth`,`OAuth flow disconnected`))})},750);return()=>{e.abort(),window.clearTimeout(n)}},[s?.jobRef,s?.generatedAt,s?.state,i]),(0,K.useEffect)(()=>f(``),[s?.prompt?.promptRef]);let S=async e=>{v(!0),x(null);try{l(await L(e))}catch{x(j(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{v(!1)}},C=async()=>{if(!(!s?.prompt||!u)){v(!0),x(null);try{l(await R(s.jobRef,s.prompt.promptRef,u))}catch{x(j(i,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{v(!1)}}},w=async()=>{s?.state===`running`&&await te(s.jobRef).catch(()=>void 0),l(void 0),x(null)},T=s?.events.slice(-4)??[];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,q.jsx)(d,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,q.jsx)(W,{name:e.name,size:38}),(0,q.jsx)(n,{sx:{flex:1,fontWeight:650},children:e.name}),e.state===`connected`&&(0,q.jsx)(r,{size:`small`,color:`success`,variant:`outlined`,icon:(0,q.jsx)(J,{}),label:j(i,`Đã kết nối`,`Connected`)}),(0,q.jsx)(m,{size:`small`,variant:`outlined`,disabled:_,onClick:()=>void S(e.providerRef),children:e.state===`connected`?j(i,`Kết nối lại`,`Reconnect`):j(i,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,q.jsx)(n,{color:`text.secondary`,children:j(i,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),b&&!s&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:b}),(0,q.jsxs)(a,{open:!!s,onClose:()=>void w(),fullWidth:!0,maxWidth:`xs`,children:[(0,q.jsx)(h,{children:s?.providerName??`OAuth`}),(0,q.jsx)(o,{children:(0,q.jsxs)(p,{spacing:1.25,sx:{pt:.5},children:[s?.state===`completed`&&(0,q.jsxs)(p,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,q.jsx)(J,{color:`success`}),(0,q.jsx)(n,{children:j(i,`Đã kết nối`,`Connected`)})]}),T.map(e=>(0,q.jsxs)(g,{children:[e.message&&(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,q.jsx)(n,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:650,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,q.jsx)(m,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,q.jsx)(E,{}),children:j(i,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,q.jsx)(m,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??j(i,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),s?.prompt&&(0,q.jsxs)(g,{children:[(0,q.jsx)(n,{variant:`body2`,sx:{mb:1},children:s.prompt.message}),s.prompt.type===`select`?(0,q.jsx)(k,{fullWidth:!0,size:`small`,value:u,onChange:e=>f(e.target.value),children:s.prompt.options.map(e=>(0,q.jsx)(D,{value:e.id,children:e.label},e.id))}):(0,q.jsx)(y,{fullWidth:!0,size:`small`,value:u,placeholder:s.prompt.placeholder??void 0,onChange:e=>f(e.target.value)})]}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,q.jsx)(n,{color:`error`,variant:`body2`,children:z(s.reasonCode??s.state,i)}),b&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`body2`,children:b})]})}),(0,q.jsxs)(c,{children:[(0,q.jsx)(m,{color:`inherit`,onClick:()=>void w(),children:s?.state===`running`?j(i,`Hủy`,`Cancel`):j(i,`Đóng`,`Close`)}),s?.prompt&&(0,q.jsx)(m,{variant:`contained`,disabled:_||!u,onClick:()=>void C(),children:j(i,`Tiếp tục`,`Continue`)})]})]})]})}var le=_((0,q.jsx)(`path`,{d:`M4 7v2c0 .55-.45 1-1 1s-1 .45-1 1v2c0 .55.45 1 1 1s1 .45 1 1v2c0 1.66 1.34 3 3 3h2c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h2c.55 0 1-.45 1-1s-.45-1-1-1H7C5.34 4 4 5.34 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.66-1.34-3-3-3h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c1.66 0 3-1.34 3-3v-2c0-.55.45-1 1-1s1-.45 1-1v-2c0-.55-.45-1-1-1`}),`DataObjectRounded`),ue=_([(0,q.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,q.jsx)(`path`,{d:`M10.35 14.01C7.62 13.91 2 15.27 2 18v1c0 .55.45 1 1 1h8.54c-2.47-2.76-1.23-5.89-1.19-5.99m9.08 4.01c.47-.8.7-1.77.48-2.82-.34-1.64-1.72-2.95-3.38-3.16-2.63-.34-4.85 1.87-4.5 4.5.22 1.66 1.52 3.04 3.16 3.38 1.05.22 2.02-.01 2.82-.48l1.86 1.86c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41zM16 18c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2`},`1`)],`PersonSearchRounded`),de=_((0,q.jsx)(`path`,{d:`M19.88 18.47c.48-.77.75-1.67.69-2.66-.13-2.15-1.84-3.97-3.97-4.2-2.72-.3-5.02 1.81-5.02 4.47 0 2.49 2.01 4.5 4.49 4.5.88 0 1.7-.26 2.39-.7l2.41 2.41c.39.39 1.03.39 1.42 0s.39-1.03 0-1.42zm-3.8.11c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5m-.36-8.5c-.74.02-1.45.18-2.1.45l-.55-.83-3.08 5.01c-.36.58-1.17.64-1.61.13l-2.12-2.47-3.06 4.9c-.31.49-.97.62-1.44.28-.42-.31-.54-.89-.26-1.34l3.78-6.05c.36-.57 1.17-.63 1.61-.12L9 12.5l3.18-5.17c.38-.62 1.28-.64 1.68-.03zm2.59.5c-.64-.28-1.33-.45-2.05-.49L20.8 2.9c.31-.49.97-.61 1.43-.27.43.31.54.9.26 1.34z`}),`QueryStatsRounded`);function Y({icon:e,title:t,detail:r,children:i}){return(0,q.jsxs)(d,{variant:`outlined`,sx:{p:2,borderRadius:1},children:[(0,q.jsxs)(p,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,q.jsx)(g,{sx:{width:38,height:38,borderRadius:1,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,q.jsxs)(g,{children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:t}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:r})]})]}),i]})}function X({children:e}){return(0,q.jsx)(p,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function fe({session:e,options:t,connections:i,onCompleted:a}){let{locale:o}=A(),[c,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(),[h,_]=(0,K.useState)(null),[v,b]=(0,K.useState)(e?.sessionRevision??``),[x,C]=(0,K.useState)(null),[E,O]=(0,K.useState)(``),[M,N]=(0,K.useState)(``),[P,F]=(0,K.useState)(``),[I,te]=(0,K.useState)(``);(0,K.useEffect)(()=>{b(e?.sessionRevision??``),f(void 0),_(null)},[e?.sessionRef]),(0,K.useEffect)(()=>{e?.sessionRevision&&b(e.sessionRevision)},[e?.sessionRevision]);let L=c||!e||!v||e.liveState===`running`||e.liveState===`waiting-approval`,R=t?.profiles??[],z=(0,K.useMemo)(()=>(i?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[i]),B=u?.outputs.find(e=>e.customType===`piagent-service-tier-receipt`)?.details,V=async(t,n=null,r=!1)=>{if(!(!e||!v)){l(!0),_(null);try{let i=await ne({schemaVersion:1,version:`piagent-runtime-command-v1`,messageType:`command`,requestId:`runtime_${crypto.randomUUID().replaceAll(`-`,`_`)}`,sessionRef:e.sessionRef,expectedSessionRevision:v,action:t,argument:n,confirmed:r});f(i),i.sessionRevisionAfter&&b(i.sessionRevisionAfter),i.state!==`settled`&&_(i.reasonCode??i.resultCode),await a?.()}catch{_(j(o,`Gateway chưa thể chạy điều khiển này.`,`The Gateway could not run this control.`))}finally{l(!1)}}},H=(e,t,n,r)=>C({action:e,argument:t,title:n,description:r}),U={size:`small`,variant:`outlined`,disabled:L};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(n,{component:`h1`,variant:`h1`,sx:{mb:.75},children:j(o,`Điều khiển project`,`Project controls`)}),(0,q.jsx)(n,{color:`text.secondary`,sx:{mb:2.5},children:j(o,`Cùng logic với Terminal: Web UI gửi đúng slash command vào Pi runtime. Các nút xem trạng thái không gọi model; thao tác ghi luôn hỏi xác nhận.`,`The same logic as Terminal: Web UI sends the exact slash command to the Pi runtime. Status controls do not call the model; writes always require confirmation.`)}),!e&&(0,q.jsx)(d,{variant:`outlined`,sx:{p:2,borderRadius:1,mb:2},children:(0,q.jsx)(n,{color:`text.secondary`,children:j(o,`Hãy chọn một cuộc trò chuyện để điều khiển project tương ứng.`,`Select a chat to control its project.`)})}),(0,q.jsxs)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,q.jsxs)(Y,{icon:(0,q.jsx)(de,{color:`primary`}),title:j(o,`Runtime & token`,`Runtime & tokens`),detail:j(o,`Tình trạng, inspector, lịch sử usage và preflight — 0 model token.`,`Status, inspector, usage history and preflight — zero model tokens.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`runtime.status`),children:`Pi status`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`runtime.inspector`),children:`Inspector`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`orchestration.status`),children:`Orchestration`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.live`),children:`Usage live`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.history`),children:`History`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.logs`),children:`Logs`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.efficiency`),children:`Efficiency`})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(y,{size:`small`,fullWidth:!0,label:j(o,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:P,onChange:e=>F(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,q.jsx)(m,{...U,sx:{whiteSpace:`nowrap`},onClick:()=>void V(`usage.preflight`,P.trim()||null),children:`Preflight`})]})]}),(0,q.jsx)(Y,{icon:(0,q.jsx)(w,{color:`primary`}),title:j(o,`Fast mode`,`Fast mode`),detail:j(o,`Giữ nguyên model/thinking và yêu cầu OpenAI Codex dùng service tier Fast. Session trống mặc định tắt; cấu hình môi trường hoặc trạng thái đã lưu khi resume có thể ghi đè.`,`Keeps model/thinking unchanged and requests the OpenAI Codex Fast service tier. Blank sessions default to off; an environment override or restored resume state can take precedence.`),children:(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`runtime.fast-status`),children:j(o,`Trạng thái`,`Status`)}),(0,q.jsx)(m,{...U,color:`primary`,onClick:()=>H(`runtime.fast-on`,null,j(o,`Bật Fast mode?`,`Enable Fast mode?`),j(o,`Các lượt model tiếp theo sẽ yêu cầu service tier Fast và có thể dùng quota hoặc chi phí provider khác. Model và thinking không đổi.`,`Future model turns will request the Fast service tier and may use provider quota or pricing differently. Model and thinking remain unchanged.`)),children:j(o,`Bật Fast`,`Enable Fast`)}),(0,q.jsx)(m,{...U,onClick:()=>H(`runtime.fast-off`,null,j(o,`Tắt Fast mode?`,`Disable Fast mode?`),j(o,`Piagent sẽ ngừng ép Fast từ lượt model tiếp theo; cấu hình tier của host/provider vẫn được giữ nguyên.`,`Piagent will stop forcing Fast on the next model turn; host/provider tier configuration still applies.`)),children:j(o,`Tắt Fast`,`Disable Fast`)})]})}),(0,q.jsxs)(Y,{icon:(0,q.jsx)(ue,{color:`primary`}),title:j(o,`Profile`,`Profile`),detail:j(o,`Xem và áp dụng profile dùng chung có kiểm soát. Muốn onboard project, hãy nhờ agent trong chat.`,`View and apply a controlled reusable profile. To onboard the project, ask the agent in chat.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`profile.status`),children:j(o,`Profile hiện tại`,`Current profile`)}),(0,q.jsx)(m,{...U,onClick:()=>void V(`profile.options`),children:j(o,`Danh sách profile`,`Profile options`)}),(0,q.jsx)(m,{...U,onClick:()=>void V(`profile.tech-options`),children:j(o,`Tech theo vai trò`,`Tech options`)})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(k,{size:`small`,fullWidth:!0,displayEmpty:!0,value:E,onChange:e=>O(e.target.value),disabled:L,renderValue:e=>e?R.find(t=>t.id===e)?.displayName??e:j(o,`Chọn profile…`,`Select profile…`),children:R.map(e=>(0,q.jsx)(D,{value:e.id,children:e.displayName},e.id))}),(0,q.jsx)(m,{...U,disabled:L||!E,sx:{whiteSpace:`nowrap`},onClick:()=>H(`profile.apply`,E,j(o,`Áp dụng profile?`,`Apply profile?`),j(o,`Piagent sẽ cập nhật policy profile của project. Có thể xem diff trong Source Changes sau khi chạy.`,`Piagent will update the project's profile policy. You can inspect the diff in Source Changes afterward.`)),children:j(o,`Áp dụng`,`Apply`)}),(0,q.jsx)(m,{...U,onClick:()=>H(`profile.auto`,null,j(o,`Tự nhận diện profile?`,`Auto-detect profile?`),j(o,`Piagent sẽ kiểm tra dấu hiệu công nghệ và ghi profile phù hợp vào project.`,`Piagent will inspect technology markers and write the matching project profile.`)),children:`Auto`})]})]}),(0,q.jsxs)(Y,{icon:(0,q.jsx)(le,{color:`primary`}),title:j(o,`Context engine`,`Context engine`),detail:j(o,`Tìm, đóng gói, đo tác động và rebuild context theo cùng policy Terminal.`,`Search, pack, measure impact and rebuild context under the same Terminal policy.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`context.status`),children:`Index status`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`context.efficiency`),children:`Efficiency`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`context.impact`),children:`Impact`}),(0,q.jsx)(m,{...U,color:`warning`,onClick:()=>H(`context.rebuild`,null,j(o,`Rebuild context index?`,`Rebuild context index?`),j(o,`Thao tác này cập nhật index cục bộ của project và không gọi model.`,`This updates the project's local index and does not call the model.`)),children:`Rebuild`})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(y,{size:`small`,fullWidth:!0,label:j(o,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:M,onChange:e=>N(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,q.jsx)(m,{...U,disabled:L||!M.trim(),onClick:()=>void V(`context.search`,M.trim()),children:`Search`}),(0,q.jsx)(m,{...U,disabled:L||!M.trim(),onClick:()=>void V(`context.pack`,M.trim()),children:`Pack`}),(0,q.jsx)(m,{...U,color:`warning`,onClick:()=>H(`context.compact`,M.trim()||null,j(o,`Compact context bằng model?`,`Compact context with the model?`),j(o,`Đây là điều khiển duy nhất trong bảng có thể dùng model token. Piagent vẫn giữ model hiện tại.`,`This is the only control in this panel that may use model tokens. Piagent keeps the current model.`)),children:`Compact`})]})]}),(0,q.jsx)(Y,{icon:(0,q.jsx)(T,{color:`primary`}),title:j(o,`Memory`,`Memory`),detail:j(o,`Xem chế độ, phạm vi và policy ghi nhớ đang có hiệu lực.`,`Inspect the active memory mode, scope and write policy.`),children:(0,q.jsx)(X,{children:(0,q.jsx)(m,{...U,onClick:()=>void V(`memory.status`),children:j(o,`Kiểm tra memory`,`Check memory`)})})}),(0,q.jsxs)(Y,{icon:(0,q.jsx)(S,{color:`primary`}),title:j(o,`MCP governance`,`MCP governance`),detail:j(o,`Doctor, trust decision và reset dùng cùng registry với Terminal.`,`Doctor, trust decisions and reset use the same registry as Terminal.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`mcp.status`),children:`MCP status`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`mcp.doctor`),children:`Doctor`})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(k,{size:`small`,fullWidth:!0,displayEmpty:!0,value:I,onChange:e=>te(e.target.value),disabled:L,renderValue:e=>e||j(o,`Chọn MCP…`,`Select MCP…`),children:z.map(e=>(0,q.jsx)(D,{value:e.name,children:e.name},e.connectionRef))}),(0,q.jsx)(m,{...U,disabled:L||!I,onClick:()=>void V(`mcp.detail`,I),children:`Detail`}),(0,q.jsx)(m,{...U,disabled:L||!I,onClick:()=>H(`mcp.approve`,I,j(o,`Phê duyệt MCP?`,`Approve MCP?`),j(o,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,q.jsx)(m,{...U,disabled:L||!I,color:`warning`,onClick:()=>H(`mcp.reject`,I,j(o,`Từ chối MCP?`,`Reject MCP?`),j(o,`Project sẽ ghi quyết định từ chối cho MCP đã chọn.`,`The project will record a rejection for the selected MCP.`)),children:`Reject`}),(0,q.jsx)(m,{...U,disabled:L||!I,color:`warning`,onClick:()=>H(`mcp.reset`,I,j(o,`Reset quyết định MCP?`,`Reset MCP decision?`),j(o,`Quyết định trust hiện tại của MCP sẽ được xóa để đánh giá lại.`,`The MCP's current trust decision will be cleared for reevaluation.`)),children:`Reset`})]})]})]}),(c||u||h)&&(0,q.jsx)(d,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:1},children:c?(0,q.jsxs)(p,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,q.jsx)(ee,{size:18}),(0,q.jsx)(n,{children:j(o,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,q.jsx)(s,{color:u?.state===`settled`?`success`:`warning`}),(0,q.jsx)(n,{sx:{fontWeight:650},children:u?u.action:j(o,`Không hoàn tất`,`Not completed`)}),u&&(0,q.jsx)(r,{size:`small`,color:u.state===`settled`?`success`:`warning`,variant:`outlined`,label:u.resultCode}),(u?.effect===`read-only`||u?.effect===`session-setting`)&&(0,q.jsx)(r,{size:`small`,color:u.modelCallObserved?`warning`:`success`,variant:`outlined`,label:u.modelCallObserved?j(o,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),B&&(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:j(o,`Fast: ${B.mode} · provider: ${B.provider??`unknown`} · ${B.reasonCode}`,`Fast: ${B.mode} · provider: ${B.provider??`unknown`} · ${B.reasonCode}`)}),h&&(0,q.jsx)(n,{color:`error`,variant:`body2`,sx:{mt:1},children:h}),u?.outputs.map((e,t)=>(0,q.jsx)(g,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,q.jsx)(re,{open:x!==null,title:x?.title??``,description:x?.description??``,cancelLabel:j(o,`Hủy`,`Cancel`),confirmLabel:j(o,`Xác nhận và chạy`,`Confirm and run`),onCancel:()=>C(null),onConfirm:()=>{let e=x;C(null),e&&V(e.action,e.argument,!0)}})]})}function Z(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function Q({children:e}){return(0,q.jsx)(n,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function $({icon:e,title:t,detail:r,action:i}){return(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,q.jsxs)(p,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,q.jsxs)(g,{children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:t}),r&&(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:r})]})]}),i]})}function pe(){let{locale:e,colorMode:t,themeId:r,setLocale:i,setColorMode:a,setThemeId:o}=A();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(e,`Giao diện`,`Appearance`)}),(0,q.jsxs)(d,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:[(0,q.jsx)($,{icon:(0,q.jsx)(u,{color:`primary`}),title:j(e,`Ngôn ngữ`,`Language`),detail:j(e,`Ngôn ngữ của giao diện. Agent trả lời theo ngôn ngữ bạn nhắn.`,`The interface language. The agent answers in the language you write.`),action:(0,q.jsxs)(O,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&i(t),children:[(0,q.jsx)(x,{value:`vi`,children:`VI`}),(0,q.jsx)(x,{value:`en`,children:`EN`})]})}),(0,q.jsx)(b,{}),(0,q.jsx)($,{icon:t===`dark`?(0,q.jsx)(C,{color:`primary`}):(0,q.jsx)(v,{color:`primary`}),title:j(e,`Chủ đề`,`Theme`),detail:j(e,`Sáng hoặc tối, lưu trên trình duyệt này.`,`Light or dark, kept in this browser.`),action:(0,q.jsxs)(O,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&a(t),children:[(0,q.jsx)(x,{value:`light`,children:j(e,`Sáng`,`Light`)}),(0,q.jsx)(x,{value:`dark`,children:j(e,`Tối`,`Dark`)})]})}),(0,q.jsx)(b,{}),(0,q.jsxs)(g,{sx:{p:2},children:[(0,q.jsx)(n,{sx:{fontWeight:600},children:j(e,`Chủ đề màu`,`Color theme`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:j(e,`Đổi màu giao diện, editor và terminal.`,`Colours for the interface, the editor and the terminal.`)}),(0,q.jsx)(g,{role:`radiogroup`,"aria-label":j(e,`Chủ đề màu`,`Color theme`),sx:{display:`grid`,gap:1,gridTemplateColumns:`repeat(auto-fill, minmax(150px, 1fr))`},children:M.map(e=>(0,q.jsxs)(g,{component:`button`,type:`button`,role:`radio`,"aria-checked":e.id===r,onClick:()=>o(e.id),sx:{textAlign:`left`,p:1,cursor:`pointer`,font:`inherit`,color:e.text,bgcolor:e.paper,borderRadius:`2px`,border:2,borderColor:e.id===r?`primary.main`:e.divider,outlineOffset:2},children:[(0,q.jsx)(g,{sx:{display:`flex`,gap:.5,mb:.75},children:[e.background,e.primary,e.secondary,e.syntax.keyword,e.syntax.string,e.warning].map((t,n)=>(0,q.jsx)(g,{"aria-hidden":!0,sx:{width:14,height:14,bgcolor:t,border:1,borderColor:e.divider}},n))}),(0,q.jsx)(g,{component:`span`,sx:{fontSize:13,fontWeight:500},children:e.label})]},e.id))})]})]})]})}function me({options:e,snapshot:t,activeModel:a,observedProvider:o}){let{locale:s}=A(),c=e?.webSearch,l=t?.capabilities.capabilities.attachments,u=l?.status===`available`?l.kinds.some(e=>e===`image`):null,f=t?.session.model.state===`known`?t.session.model.value:null,m=f?f.inputCapabilities.some(e=>e===`image`):null,h=a?.imageInput??m??u,_=(a?.provider??o??null)===`openai-codex`,v=[{key:`search`,icon:(0,q.jsx)(i,{color:`primary`}),title:c?.route===`codex-first`?`Codex Web Search`:j(s,`Tìm kiếm web`,`Web search`),detail:c?.route===`codex-first`?j(s,`Dùng đăng nhập Codex của Pi; tự chuyển sang Exa khi Codex Search không khả dụng.`,`Uses Pi's Codex sign-in and falls back to Exa when Codex Search is unavailable.`):c?.state===`configured`?j(s,`Route tự động đang hoạt động; kết nối Codex để ưu tiên native Web Search.`,`Automatic routing is configured; connect Codex to prefer native Web Search.`):j(s,`Chưa tìm thấy tích hợp web search trong Pi runtime.`,`The Pi runtime web-search integration was not found.`),status:c?.route===`codex-first`?j(s,`Ưu tiên Codex`,`Codex first`):c?.state===`configured`?j(s,`Đã cấu hình`,`Configured`):j(s,`Chưa có`,`Unavailable`),ready:c?.state===`configured`},{key:`vision`,icon:(0,q.jsx)(se,{color:`primary`}),title:_?`Codex Vision`:j(s,`Vision của model`,`Model vision`),detail:h===!0?j(s,`Ảnh đính kèm được gửi trực tiếp cho model của session hiện tại.`,`Image attachments are sent directly to the current session model.`):h===!1?j(s,`Model hiện tại chỉ nhận text; hãy chọn model hỗ trợ image input.`,`The current model is text-only; select a model that supports image input.`):j(s,`Runtime chưa công bố image-input capability của model hiện tại.`,`The runtime has not reported the current model's image-input capability.`),status:h===!0?j(s,`Đang dùng`,`Active`):h===!1?j(s,`Không hỗ trợ`,`Unsupported`):j(s,`Chưa rõ`,`Unknown`),ready:h===!0}];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(n,{variant:`h2`,sx:{mt:3,mb:.5},children:j(s,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:j(s,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:v.map(e=>(0,q.jsx)(d,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,q.jsxs)(p,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,q.jsx)(g,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:1,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:e.title}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,q.jsx)(r,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function he({options:e,auth:t,refreshAuth:i,session:a,snapshot:o,onSetModel:s,onSetThinking:c}){let{locale:l}=A(),[u,f]=(0,K.useState)(!1),[m,h]=(0,K.useState)(null),_=o?.session.model.state===`known`?o.session.model.value:null,v=(0,K.useMemo)(()=>{let t=new Map;for(let n of e?.models??[])t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t.entries()]},[e]),y=_?.modelRef??``,b=e?.models.find(e=>e.modelRef===y),x=b?y:``,S=_?.displayName??a?.modelLabel??`—`,C=a?.managedThinkingLevels??b?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],w=async e=>{if(e){f(!0),h(null);try{await e()}catch{h(j(l,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{f(!1)}}};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(l,`Nhà cung cấp & model`,`Providers & models`)}),a&&(0,q.jsxs)(d,{variant:`outlined`,sx:{p:2.25,borderRadius:1,mb:2},children:[(0,q.jsxs)(p,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,q.jsx)(W,{name:_?.provider??a.modelLabel??`model`,size:38}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:j(l,`Model của session hiện tại`,`Current session model`)}),(0,q.jsxs)(n,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[S,` · `,z(a.thinkingLevel,l)]})]}),(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:j(l,`Đang dùng`,`In use`)})]}),(0,q.jsxs)(p,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,q.jsxs)(g,{sx:{flex:1},children:[(0,q.jsx)(n,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,q.jsx)(k,{fullWidth:!0,size:`small`,value:x,displayEmpty:!0,renderValue:t=>t?e?.models.find(e=>e.modelRef===t)?.displayName??S:S,disabled:u||!s||a.liveState===`running`,onChange:e=>void w(()=>s?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,q.jsx)(D,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,q.jsxs)(g,{sx:{width:{md:220}},children:[(0,q.jsx)(n,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,q.jsx)(k,{fullWidth:!0,size:`small`,value:a.thinkingLevel===`unknown`?`off`:a.thinkingLevel,disabled:u||!c||a.liveState===`running`,onChange:e=>void w(()=>c?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:C.map(e=>(0,q.jsx)(D,{value:e,children:z(e,l)},e))})]})]}),m&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:m})]}),(0,q.jsx)(me,{options:e,snapshot:o,activeModel:b,observedProvider:_?.provider}),(0,q.jsx)(n,{variant:`h2`,sx:{mt:3,mb:.5},children:j(l,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:j(l,`Kết nối tài khoản để mở khóa model tương ứng.`,`Connect an account to make its models available.`)}),(0,q.jsx)(ce,{catalog:t,refresh:i}),(0,q.jsx)(n,{variant:`h2`,sx:{mt:3,mb:.5},children:j(l,`Danh mục model`,`Model catalog`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:j(l,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:v.map(([e,t])=>(0,q.jsxs)(d,{variant:`outlined`,sx:{p:1.5,borderRadius:1},children:[(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,q.jsx)(W,{name:e,size:32}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{noWrap:!0,sx:{fontWeight:650,textTransform:`capitalize`},children:e}),(0,q.jsxs)(n,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,q.jsx)(r,{size:`small`,color:`success`,variant:`outlined`,label:j(l,`Sẵn sàng`,`Ready`)})]}),(0,q.jsxs)(g,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&v.length===0&&(0,q.jsx)(n,{color:`text.secondary`,children:j(l,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function ge({value:e,loading:t,sessionRef:i,onChanged:a}){let{locale:o}=A();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(o,`MCP & kết nối`,`MCP & connections`)}),t?(0,q.jsx)(ee,{size:22}):(0,q.jsxs)(p,{spacing:1,children:[(e?.connections??[]).map(e=>(0,q.jsx)(d,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,q.jsx)(W,{name:e.name,size:38}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{noWrap:!0,sx:{fontWeight:650},children:e.name}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:H(e,o)})]}),i?(0,q.jsx)(V,{sessionRef:i,connection:e,onChanged:a}):(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:j(o,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,q.jsx)(n,{color:`text.secondary`,children:j(o,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function _e({snapshot:e,session:t,onSetPermission:r}){let{locale:i}=A(),a=e?.session.permissionProfile,[o,s]=(0,K.useState)(a?.state===`known`?a.value??null:null),[c,u]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[h,_]=(0,K.useState)(null);(0,K.useEffect)(()=>{s(t?.managedPermission??(a?.state===`known`?a.value??null:null))},[t?.sessionRef,t?.managedPermission,a?.state,a?.value]);let v=async e=>{if(r){u(!0),p(null);try{await r(e),s(e)}catch{p(j(i,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{u(!1)}}},y=e=>{if(e===`trusted-full-access`||e===`bypass`){_(e);return}v(e)},x=[{mode:`read-only`,detail:j(i,`Chỉ xem session, task và source; không thay đổi project.`,`Inspect the session, task, and source without changing the project.`)},{mode:`workspace-write`,detail:j(i,`Đọc, sửa file và chạy command trong project; thao tác nhạy cảm vẫn cần xác nhận.`,`Read and edit project files and run commands; sensitive actions still require confirmation.`)},{mode:`trusted-full-access`,detail:t?.managed?B(i):j(i,`Quyền rộng hơn trong runtime; xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`Broader runtime access; deleting or sending data externally still requires separate confirmation.`)},...!t?.managed||t.managedBypass?[{mode:`bypass`,detail:t?.managed?G(i):U(i)}]:[]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(i,`Quyền truy cập`,`Access`)}),(0,q.jsx)(n,{variant:`h2`,sx:{mb:.5},children:j(i,`Hồ sơ quyền`,`Permission profile`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:j(i,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,q.jsx)(d,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:x.map((e,n)=>(0,q.jsxs)(g,{children:[(0,q.jsx)($,{icon:(0,q.jsx)(l,{color:e.mode===`bypass`?`error`:e.mode===`trusted-full-access`?`warning`:`primary`}),title:z(e.mode,i),detail:e.detail,action:(0,q.jsx)(m,{size:`small`,variant:o===e.mode?`contained`:`outlined`,color:e.mode===`bypass`?`error`:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":o===e.mode,disabled:c||!t||!r||t.liveState===`running`,onClick:()=>y(e.mode),children:z(e.mode,i)})}),n<x.length-1&&(0,q.jsx)(b,{})]},e.mode))}),f&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:f}),(0,q.jsx)(re,{open:h!==null,title:h===`bypass`?j(i,`Bật Bypass?`,`Turn on Bypass?`):j(i,`Bật toàn quyền?`,`Enable full access?`),description:h===`bypass`?t?.managed?G(i):U(i):j(i,`Session này sẽ được phép đọc, sửa file và chạy command trong phạm vi runtime. Các thao tác xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`This session will be allowed to read and edit files and run commands within the runtime. Destructive actions and external data transfers still require separate confirmation.`),cancelLabel:j(i,`Hủy`,`Cancel`),confirmLabel:h===`bypass`?j(i,`Bật Bypass`,`Turn on Bypass`):j(i,`Bật toàn quyền`,`Enable full access`),onCancel:()=>_(null),onConfirm:()=>{let e=h;_(null),e&&v(e)}})]})}function ve({session:e,snapshot:t}){let{locale:r}=A(),i=t?.usage.context??(e?{state:e.contextUsage.state,tokens:e.contextUsage.usedTokens,contextWindow:e.contextUsage.contextWindow,percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100}:void 0),a=[[j(r,`Context`,`Context`),i?.percent==null?`—`:`${Math.round(i.percent)}%`],[`Tokens`,`${Z(i?.tokens,r)} / ${Z(i?.contextWindow,r)}`],[j(r,`Input`,`Input`),Z(t?.usage.sessionTotal.input,r)],[j(r,`Output`,`Output`),Z(t?.usage.sessionTotal.output,r)],[j(r,`Continuation`,`Continuation`),Z(t?.continuation.remaining,r)],[`Verifier`,t?.verification.state??`—`]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(r,`Usage & context`,`Usage & context`)}),(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,sm:`repeat(2,minmax(0,1fr))`,lg:`repeat(3,minmax(0,1fr))`},gap:1},children:a.map(([e,t])=>(0,q.jsxs)(d,{variant:`outlined`,sx:{p:2,borderRadius:1},children:[(0,q.jsx)(n,{variant:`caption`,color:`text.secondary`,children:e}),(0,q.jsx)(n,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:650},children:t})]},e))})]})}function ye({capabilities:e,connection:t}){let{locale:r}=A(),i=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[j(r,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:`Piagent`}),(0,q.jsx)(d,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:i.map(([e,t],r)=>(0,q.jsxs)(g,{children:[(0,q.jsxs)(p,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,q.jsx)(n,{color:`text.secondary`,children:e}),(0,q.jsx)(n,{sx:{fontWeight:650},children:String(t)})]}),r<i.length-1&&(0,q.jsx)(b,{})]},String(e)))})]})}function be({section:e,onSection:t,onBack:n,session:r,snapshot:i,capabilities:a,connection:o,onSetModel:s,onSetThinking:c,onSetPermission:l,onRuntimeChanged:u}){let{locale:d}=A(),[f,p]=(0,K.useState)(),[m,h]=(0,K.useState)(),[_,v]=(0,K.useState)(),[y,b]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let e=new AbortController;return F(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]),(0,K.useEffect)(()=>{let e=new AbortController;return N(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,K.useEffect)(()=>{if(!r){v(void 0);return}let e=new AbortController;return b(!0),v(void 0),P(r.sessionRef,e.signal).then(v).catch(()=>void 0).finally(()=>{e.signal.aborted||b(!1)}),()=>e.abort()},[r?.sessionRef]),(0,q.jsxs)(g,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`236px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,q.jsx)(ae,{section:e,onSection:t,onBack:n}),(0,q.jsxs)(g,{component:`main`,sx:{width:`100%`,minHeight:0,overflowY:`auto`,px:{xs:2,sm:3,lg:5},py:{xs:3,md:4}},children:[e===`general`&&(0,q.jsx)(pe,{}),e===`updates`&&(0,q.jsx)(oe,{}),e===`shortcuts`&&(0,q.jsx)(ie,{}),e===`models`&&(0,q.jsx)(he,{options:f,auth:m,refreshAuth:async()=>{let[e,t]=await Promise.all([N(),F()]);h(e),p(t)},session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,q.jsx)(ge,{value:_,loading:y,sessionRef:r?.sessionRef,onChanged:async e=>{if(e){v(e);return}r&&v(await P(r.sessionRef).catch(()=>_))}}),e===`controls`&&(0,q.jsx)(fe,{session:r,options:f,connections:_,onCompleted:u}),e===`permissions`&&(0,q.jsx)(_e,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,q.jsx)(ve,{session:r,snapshot:i}),e===`about`&&(0,q.jsx)(ye,{capabilities:a,connection:o})]})]})}export{be as SettingsPage};
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Bt as n,Dt as r,E as i,Et as a,G as o,J as s,K as c,L as l,O as u,Qt as d,Rn as f,Tt as p,Ut as m,W as h,Wt as g,Xt as _,a as v,bt as y,ct as b,d as x,ft as S,i as C,mt as w,p as T,q as E,qt as ee,rt as D,u as O,xt as k}from"./vendor-DNZbaWhT.js";import{i as A,n as j,o as M}from"./ui-preferences-OfS30-ZV.js";import{D as N,F as P,I as F,O as I,a as te,c as ne,pt as L,tt as R}from"./api-BQS4Dtrr.js";import{r as z}from"./view-model-CWNiS4JN.js";import{A as B,F as re,I as V,L as H,P as U,R as W,k as G,n as ie,t as ae,x as oe}from"./SettingsNavigation-Bu1A7x4F.js";var K=e(f(),1),q=t(),se=_((0,q.jsx)(`path`,{d:`M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2M8.9 13.98l2.1 2.53 3.1-3.99c.2-.26.6-.26.8.01l3.51 4.68c.25.33.01.8-.4.8H6.02c-.42 0-.65-.48-.39-.81L8.12 14c.19-.26.57-.27.78-.02`}),`ImageRounded`),J=_((0,q.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2M9.29 16.29 5.7 12.7a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0L10 14.17l6.88-6.88c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41l-7.59 7.59c-.38.39-1.02.39-1.41 0`}),`CheckCircleRounded`);function ce({catalog:e,refresh:t}){let{locale:i}=A(),[s,l]=(0,K.useState)(),[u,f]=(0,K.useState)(``),[_,v]=(0,K.useState)(!1),[b,x]=(0,K.useState)(null);(0,K.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,n=window.setTimeout(()=>{I(s.jobRef,e.signal).then(e=>{l(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||x(j(i,`Mất kết nối với luồng OAuth`,`OAuth flow disconnected`))})},750);return()=>{e.abort(),window.clearTimeout(n)}},[s?.jobRef,s?.generatedAt,s?.state,i]),(0,K.useEffect)(()=>f(``),[s?.prompt?.promptRef]);let S=async e=>{v(!0),x(null);try{l(await L(e))}catch{x(j(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{v(!1)}},C=async()=>{if(!(!s?.prompt||!u)){v(!0),x(null);try{l(await R(s.jobRef,s.prompt.promptRef,u))}catch{x(j(i,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{v(!1)}}},w=async()=>{s?.state===`running`&&await te(s.jobRef).catch(()=>void 0),l(void 0),x(null)},T=s?.events.slice(-4)??[];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,q.jsx)(d,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,q.jsx)(W,{name:e.name,size:38}),(0,q.jsx)(n,{sx:{flex:1,fontWeight:650},children:e.name}),e.state===`connected`&&(0,q.jsx)(r,{size:`small`,color:`success`,variant:`outlined`,icon:(0,q.jsx)(J,{}),label:j(i,`Đã kết nối`,`Connected`)}),(0,q.jsx)(m,{size:`small`,variant:`outlined`,disabled:_,onClick:()=>void S(e.providerRef),children:e.state===`connected`?j(i,`Kết nối lại`,`Reconnect`):j(i,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,q.jsx)(n,{color:`text.secondary`,children:j(i,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),b&&!s&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:b}),(0,q.jsxs)(a,{open:!!s,onClose:()=>void w(),fullWidth:!0,maxWidth:`xs`,children:[(0,q.jsx)(h,{children:s?.providerName??`OAuth`}),(0,q.jsx)(o,{children:(0,q.jsxs)(p,{spacing:1.25,sx:{pt:.5},children:[s?.state===`completed`&&(0,q.jsxs)(p,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,q.jsx)(J,{color:`success`}),(0,q.jsx)(n,{children:j(i,`Đã kết nối`,`Connected`)})]}),T.map(e=>(0,q.jsxs)(g,{children:[e.message&&(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,q.jsx)(n,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:650,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,q.jsx)(m,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,q.jsx)(E,{}),children:j(i,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,q.jsx)(m,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??j(i,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),s?.prompt&&(0,q.jsxs)(g,{children:[(0,q.jsx)(n,{variant:`body2`,sx:{mb:1},children:s.prompt.message}),s.prompt.type===`select`?(0,q.jsx)(k,{fullWidth:!0,size:`small`,value:u,onChange:e=>f(e.target.value),children:s.prompt.options.map(e=>(0,q.jsx)(D,{value:e.id,children:e.label},e.id))}):(0,q.jsx)(y,{fullWidth:!0,size:`small`,value:u,placeholder:s.prompt.placeholder??void 0,onChange:e=>f(e.target.value)})]}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,q.jsx)(n,{color:`error`,variant:`body2`,children:z(s.reasonCode??s.state,i)}),b&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`body2`,children:b})]})}),(0,q.jsxs)(c,{children:[(0,q.jsx)(m,{color:`inherit`,onClick:()=>void w(),children:s?.state===`running`?j(i,`Hủy`,`Cancel`):j(i,`Đóng`,`Close`)}),s?.prompt&&(0,q.jsx)(m,{variant:`contained`,disabled:_||!u,onClick:()=>void C(),children:j(i,`Tiếp tục`,`Continue`)})]})]})]})}var le=_((0,q.jsx)(`path`,{d:`M4 7v2c0 .55-.45 1-1 1s-1 .45-1 1v2c0 .55.45 1 1 1s1 .45 1 1v2c0 1.66 1.34 3 3 3h2c.55 0 1-.45 1-1s-.45-1-1-1H7c-.55 0-1-.45-1-1v-2c0-1.3-.84-2.42-2-2.83v-.34C5.16 11.42 6 10.3 6 9V7c0-.55.45-1 1-1h2c.55 0 1-.45 1-1s-.45-1-1-1H7C5.34 4 4 5.34 4 7m17 3c-.55 0-1-.45-1-1V7c0-1.66-1.34-3-3-3h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c.55 0 1 .45 1 1v2c0 1.3.84 2.42 2 2.83v.34c-1.16.41-2 1.52-2 2.83v2c0 .55-.45 1-1 1h-2c-.55 0-1 .45-1 1s.45 1 1 1h2c1.66 0 3-1.34 3-3v-2c0-.55.45-1 1-1s1-.45 1-1v-2c0-.55-.45-1-1-1`}),`DataObjectRounded`),ue=_([(0,q.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,q.jsx)(`path`,{d:`M10.35 14.01C7.62 13.91 2 15.27 2 18v1c0 .55.45 1 1 1h8.54c-2.47-2.76-1.23-5.89-1.19-5.99m9.08 4.01c.47-.8.7-1.77.48-2.82-.34-1.64-1.72-2.95-3.38-3.16-2.63-.34-4.85 1.87-4.5 4.5.22 1.66 1.52 3.04 3.16 3.38 1.05.22 2.02-.01 2.82-.48l1.86 1.86c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41zM16 18c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2`},`1`)],`PersonSearchRounded`),de=_((0,q.jsx)(`path`,{d:`M19.88 18.47c.48-.77.75-1.67.69-2.66-.13-2.15-1.84-3.97-3.97-4.2-2.72-.3-5.02 1.81-5.02 4.47 0 2.49 2.01 4.5 4.49 4.5.88 0 1.7-.26 2.39-.7l2.41 2.41c.39.39 1.03.39 1.42 0s.39-1.03 0-1.42zm-3.8.11c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5m-.36-8.5c-.74.02-1.45.18-2.1.45l-.55-.83-3.08 5.01c-.36.58-1.17.64-1.61.13l-2.12-2.47-3.06 4.9c-.31.49-.97.62-1.44.28-.42-.31-.54-.89-.26-1.34l3.78-6.05c.36-.57 1.17-.63 1.61-.12L9 12.5l3.18-5.17c.38-.62 1.28-.64 1.68-.03zm2.59.5c-.64-.28-1.33-.45-2.05-.49L20.8 2.9c.31-.49.97-.61 1.43-.27.43.31.54.9.26 1.34z`}),`QueryStatsRounded`);function Y({icon:e,title:t,detail:r,children:i}){return(0,q.jsxs)(d,{variant:`outlined`,sx:{p:2,borderRadius:1},children:[(0,q.jsxs)(p,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,q.jsx)(g,{sx:{width:38,height:38,borderRadius:1,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,q.jsxs)(g,{children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:t}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:r})]})]}),i]})}function X({children:e}){return(0,q.jsx)(p,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function fe({session:e,options:t,connections:i,onCompleted:a}){let{locale:o}=A(),[c,l]=(0,K.useState)(!1),[u,f]=(0,K.useState)(),[h,_]=(0,K.useState)(null),[v,b]=(0,K.useState)(e?.sessionRevision??``),[x,C]=(0,K.useState)(null),[E,O]=(0,K.useState)(``),[M,N]=(0,K.useState)(``),[P,F]=(0,K.useState)(``),[I,te]=(0,K.useState)(``);(0,K.useEffect)(()=>{b(e?.sessionRevision??``),f(void 0),_(null)},[e?.sessionRef]),(0,K.useEffect)(()=>{e?.sessionRevision&&b(e.sessionRevision)},[e?.sessionRevision]);let L=c||!e||!v||e.liveState===`running`||e.liveState===`waiting-approval`,R=t?.profiles??[],z=(0,K.useMemo)(()=>(i?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[i]),B=u?.outputs.find(e=>e.customType===`piagent-service-tier-receipt`)?.details,V=async(t,n=null,r=!1)=>{if(!(!e||!v)){l(!0),_(null);try{let i=await ne({schemaVersion:1,version:`piagent-runtime-command-v1`,messageType:`command`,requestId:`runtime_${crypto.randomUUID().replaceAll(`-`,`_`)}`,sessionRef:e.sessionRef,expectedSessionRevision:v,action:t,argument:n,confirmed:r});f(i),i.sessionRevisionAfter&&b(i.sessionRevisionAfter),i.state!==`settled`&&_(i.reasonCode??i.resultCode),await a?.()}catch{_(j(o,`Gateway chưa thể chạy điều khiển này.`,`The Gateway could not run this control.`))}finally{l(!1)}}},H=(e,t,n,r)=>C({action:e,argument:t,title:n,description:r}),U={size:`small`,variant:`outlined`,disabled:L};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(n,{component:`h1`,variant:`h1`,sx:{mb:.75},children:j(o,`Điều khiển project`,`Project controls`)}),(0,q.jsx)(n,{color:`text.secondary`,sx:{mb:2.5},children:j(o,`Cùng logic với Terminal: Web UI gửi đúng slash command vào Pi runtime. Các nút xem trạng thái không gọi model; thao tác ghi luôn hỏi xác nhận.`,`The same logic as Terminal: Web UI sends the exact slash command to the Pi runtime. Status controls do not call the model; writes always require confirmation.`)}),!e&&(0,q.jsx)(d,{variant:`outlined`,sx:{p:2,borderRadius:1,mb:2},children:(0,q.jsx)(n,{color:`text.secondary`,children:j(o,`Hãy chọn một cuộc trò chuyện để điều khiển project tương ứng.`,`Select a chat to control its project.`)})}),(0,q.jsxs)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,q.jsxs)(Y,{icon:(0,q.jsx)(de,{color:`primary`}),title:j(o,`Runtime & token`,`Runtime & tokens`),detail:j(o,`Tình trạng, inspector, lịch sử usage và preflight — 0 model token.`,`Status, inspector, usage history and preflight — zero model tokens.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`runtime.status`),children:`Pi status`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`runtime.inspector`),children:`Inspector`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`orchestration.status`),children:`Orchestration`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.live`),children:`Usage live`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.history`),children:`History`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.logs`),children:`Logs`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`usage.efficiency`),children:`Efficiency`})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(y,{size:`small`,fullWidth:!0,label:j(o,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:P,onChange:e=>F(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,q.jsx)(m,{...U,sx:{whiteSpace:`nowrap`},onClick:()=>void V(`usage.preflight`,P.trim()||null),children:`Preflight`})]})]}),(0,q.jsx)(Y,{icon:(0,q.jsx)(w,{color:`primary`}),title:j(o,`Fast mode`,`Fast mode`),detail:j(o,`Giữ nguyên model/thinking và yêu cầu OpenAI Codex dùng service tier Fast. Session trống mặc định tắt; cấu hình môi trường hoặc trạng thái đã lưu khi resume có thể ghi đè.`,`Keeps model/thinking unchanged and requests the OpenAI Codex Fast service tier. Blank sessions default to off; an environment override or restored resume state can take precedence.`),children:(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`runtime.fast-status`),children:j(o,`Trạng thái`,`Status`)}),(0,q.jsx)(m,{...U,color:`primary`,onClick:()=>H(`runtime.fast-on`,null,j(o,`Bật Fast mode?`,`Enable Fast mode?`),j(o,`Các lượt model tiếp theo sẽ yêu cầu service tier Fast và có thể dùng quota hoặc chi phí provider khác. Model và thinking không đổi.`,`Future model turns will request the Fast service tier and may use provider quota or pricing differently. Model and thinking remain unchanged.`)),children:j(o,`Bật Fast`,`Enable Fast`)}),(0,q.jsx)(m,{...U,onClick:()=>H(`runtime.fast-off`,null,j(o,`Tắt Fast mode?`,`Disable Fast mode?`),j(o,`Piagent sẽ ngừng ép Fast từ lượt model tiếp theo; cấu hình tier của host/provider vẫn được giữ nguyên.`,`Piagent will stop forcing Fast on the next model turn; host/provider tier configuration still applies.`)),children:j(o,`Tắt Fast`,`Disable Fast`)})]})}),(0,q.jsxs)(Y,{icon:(0,q.jsx)(ue,{color:`primary`}),title:j(o,`Profile`,`Profile`),detail:j(o,`Xem và áp dụng profile dùng chung có kiểm soát. Muốn onboard project, hãy nhờ agent trong chat.`,`View and apply a controlled reusable profile. To onboard the project, ask the agent in chat.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`profile.status`),children:j(o,`Profile hiện tại`,`Current profile`)}),(0,q.jsx)(m,{...U,onClick:()=>void V(`profile.options`),children:j(o,`Danh sách profile`,`Profile options`)}),(0,q.jsx)(m,{...U,onClick:()=>void V(`profile.tech-options`),children:j(o,`Tech theo vai trò`,`Tech options`)})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(k,{size:`small`,fullWidth:!0,displayEmpty:!0,value:E,onChange:e=>O(e.target.value),disabled:L,renderValue:e=>e?R.find(t=>t.id===e)?.displayName??e:j(o,`Chọn profile…`,`Select profile…`),children:R.map(e=>(0,q.jsx)(D,{value:e.id,children:e.displayName},e.id))}),(0,q.jsx)(m,{...U,disabled:L||!E,sx:{whiteSpace:`nowrap`},onClick:()=>H(`profile.apply`,E,j(o,`Áp dụng profile?`,`Apply profile?`),j(o,`Piagent sẽ cập nhật policy profile của project. Có thể xem diff trong Source Changes sau khi chạy.`,`Piagent will update the project's profile policy. You can inspect the diff in Source Changes afterward.`)),children:j(o,`Áp dụng`,`Apply`)}),(0,q.jsx)(m,{...U,onClick:()=>H(`profile.auto`,null,j(o,`Tự nhận diện profile?`,`Auto-detect profile?`),j(o,`Piagent sẽ kiểm tra dấu hiệu công nghệ và ghi profile phù hợp vào project.`,`Piagent will inspect technology markers and write the matching project profile.`)),children:`Auto`})]})]}),(0,q.jsxs)(Y,{icon:(0,q.jsx)(le,{color:`primary`}),title:j(o,`Context engine`,`Context engine`),detail:j(o,`Tìm, đóng gói, đo tác động và rebuild context theo cùng policy Terminal.`,`Search, pack, measure impact and rebuild context under the same Terminal policy.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`context.status`),children:`Index status`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`context.efficiency`),children:`Efficiency`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`context.impact`),children:`Impact`}),(0,q.jsx)(m,{...U,color:`warning`,onClick:()=>H(`context.rebuild`,null,j(o,`Rebuild context index?`,`Rebuild context index?`),j(o,`Thao tác này cập nhật index cục bộ của project và không gọi model.`,`This updates the project's local index and does not call the model.`)),children:`Rebuild`})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(y,{size:`small`,fullWidth:!0,label:j(o,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:M,onChange:e=>N(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,q.jsx)(m,{...U,disabled:L||!M.trim(),onClick:()=>void V(`context.search`,M.trim()),children:`Search`}),(0,q.jsx)(m,{...U,disabled:L||!M.trim(),onClick:()=>void V(`context.pack`,M.trim()),children:`Pack`}),(0,q.jsx)(m,{...U,color:`warning`,onClick:()=>H(`context.compact`,M.trim()||null,j(o,`Compact context bằng model?`,`Compact context with the model?`),j(o,`Đây là điều khiển duy nhất trong bảng có thể dùng model token. Piagent vẫn giữ model hiện tại.`,`This is the only control in this panel that may use model tokens. Piagent keeps the current model.`)),children:`Compact`})]})]}),(0,q.jsx)(Y,{icon:(0,q.jsx)(T,{color:`primary`}),title:j(o,`Memory`,`Memory`),detail:j(o,`Xem chế độ, phạm vi và policy ghi nhớ đang có hiệu lực.`,`Inspect the active memory mode, scope and write policy.`),children:(0,q.jsx)(X,{children:(0,q.jsx)(m,{...U,onClick:()=>void V(`memory.status`),children:j(o,`Kiểm tra memory`,`Check memory`)})})}),(0,q.jsxs)(Y,{icon:(0,q.jsx)(S,{color:`primary`}),title:j(o,`MCP governance`,`MCP governance`),detail:j(o,`Doctor, trust decision và reset dùng cùng registry với Terminal.`,`Doctor, trust decisions and reset use the same registry as Terminal.`),children:[(0,q.jsxs)(X,{children:[(0,q.jsx)(m,{...U,onClick:()=>void V(`mcp.status`),children:`MCP status`}),(0,q.jsx)(m,{...U,onClick:()=>void V(`mcp.doctor`),children:`Doctor`})]}),(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,q.jsx)(k,{size:`small`,fullWidth:!0,displayEmpty:!0,value:I,onChange:e=>te(e.target.value),disabled:L,renderValue:e=>e||j(o,`Chọn MCP…`,`Select MCP…`),children:z.map(e=>(0,q.jsx)(D,{value:e.name,children:e.name},e.connectionRef))}),(0,q.jsx)(m,{...U,disabled:L||!I,onClick:()=>void V(`mcp.detail`,I),children:`Detail`}),(0,q.jsx)(m,{...U,disabled:L||!I,onClick:()=>H(`mcp.approve`,I,j(o,`Phê duyệt MCP?`,`Approve MCP?`),j(o,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,q.jsx)(m,{...U,disabled:L||!I,color:`warning`,onClick:()=>H(`mcp.reject`,I,j(o,`Từ chối MCP?`,`Reject MCP?`),j(o,`Project sẽ ghi quyết định từ chối cho MCP đã chọn.`,`The project will record a rejection for the selected MCP.`)),children:`Reject`}),(0,q.jsx)(m,{...U,disabled:L||!I,color:`warning`,onClick:()=>H(`mcp.reset`,I,j(o,`Reset quyết định MCP?`,`Reset MCP decision?`),j(o,`Quyết định trust hiện tại của MCP sẽ được xóa để đánh giá lại.`,`The MCP's current trust decision will be cleared for reevaluation.`)),children:`Reset`})]})]})]}),(c||u||h)&&(0,q.jsx)(d,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:1},children:c?(0,q.jsxs)(p,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,q.jsx)(ee,{size:18}),(0,q.jsx)(n,{children:j(o,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,q.jsx)(s,{color:u?.state===`settled`?`success`:`warning`}),(0,q.jsx)(n,{sx:{fontWeight:650},children:u?u.action:j(o,`Không hoàn tất`,`Not completed`)}),u&&(0,q.jsx)(r,{size:`small`,color:u.state===`settled`?`success`:`warning`,variant:`outlined`,label:u.resultCode}),(u?.effect===`read-only`||u?.effect===`session-setting`)&&(0,q.jsx)(r,{size:`small`,color:u.modelCallObserved?`warning`:`success`,variant:`outlined`,label:u.modelCallObserved?j(o,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),B&&(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:j(o,`Fast: ${B.mode} · provider: ${B.provider??`unknown`} · ${B.reasonCode}`,`Fast: ${B.mode} · provider: ${B.provider??`unknown`} · ${B.reasonCode}`)}),h&&(0,q.jsx)(n,{color:`error`,variant:`body2`,sx:{mt:1},children:h}),u?.outputs.map((e,t)=>(0,q.jsx)(g,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,q.jsx)(re,{open:x!==null,title:x?.title??``,description:x?.description??``,cancelLabel:j(o,`Hủy`,`Cancel`),confirmLabel:j(o,`Xác nhận và chạy`,`Confirm and run`),onCancel:()=>C(null),onConfirm:()=>{let e=x;C(null),e&&V(e.action,e.argument,!0)}})]})}function Z(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function Q({children:e}){return(0,q.jsx)(n,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function $({icon:e,title:t,detail:r,action:i}){return(0,q.jsxs)(p,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,q.jsxs)(p,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,q.jsxs)(g,{children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:t}),r&&(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:r})]})]}),i]})}function pe(){let{locale:e,colorMode:t,themeId:r,setLocale:i,setColorMode:a,setThemeId:o}=A();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(e,`Giao diện`,`Appearance`)}),(0,q.jsxs)(d,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:[(0,q.jsx)($,{icon:(0,q.jsx)(u,{color:`primary`}),title:j(e,`Ngôn ngữ`,`Language`),detail:j(e,`Ngôn ngữ của giao diện. Agent trả lời theo ngôn ngữ bạn nhắn.`,`The interface language. The agent answers in the language you write.`),action:(0,q.jsxs)(O,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&i(t),children:[(0,q.jsx)(x,{value:`vi`,children:`VI`}),(0,q.jsx)(x,{value:`en`,children:`EN`})]})}),(0,q.jsx)(b,{}),(0,q.jsx)($,{icon:t===`dark`?(0,q.jsx)(C,{color:`primary`}):(0,q.jsx)(v,{color:`primary`}),title:j(e,`Chủ đề`,`Theme`),detail:j(e,`Sáng hoặc tối, lưu trên trình duyệt này.`,`Light or dark, kept in this browser.`),action:(0,q.jsxs)(O,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&a(t),children:[(0,q.jsx)(x,{value:`light`,children:j(e,`Sáng`,`Light`)}),(0,q.jsx)(x,{value:`dark`,children:j(e,`Tối`,`Dark`)})]})}),(0,q.jsx)(b,{}),(0,q.jsxs)(g,{sx:{p:2},children:[(0,q.jsx)(n,{sx:{fontWeight:600},children:j(e,`Chủ đề màu`,`Color theme`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:j(e,`Đổi màu giao diện, editor và terminal.`,`Colours for the interface, the editor and the terminal.`)}),(0,q.jsx)(g,{role:`radiogroup`,"aria-label":j(e,`Chủ đề màu`,`Color theme`),sx:{display:`grid`,gap:1,gridTemplateColumns:`repeat(auto-fill, minmax(150px, 1fr))`},children:M.map(e=>(0,q.jsxs)(g,{component:`button`,type:`button`,role:`radio`,"aria-checked":e.id===r,onClick:()=>o(e.id),sx:{textAlign:`left`,p:1,cursor:`pointer`,font:`inherit`,color:e.text,bgcolor:e.paper,borderRadius:`2px`,border:2,borderColor:e.id===r?`primary.main`:e.divider,outlineOffset:2},children:[(0,q.jsx)(g,{sx:{display:`flex`,gap:.5,mb:.75},children:[e.background,e.primary,e.secondary,e.syntax.keyword,e.syntax.string,e.warning].map((t,n)=>(0,q.jsx)(g,{"aria-hidden":!0,sx:{width:14,height:14,bgcolor:t,border:1,borderColor:e.divider}},n))}),(0,q.jsx)(g,{component:`span`,sx:{fontSize:13,fontWeight:500},children:e.label})]},e.id))})]})]})]})}function me({options:e,snapshot:t,activeModel:a,observedProvider:o}){let{locale:s}=A(),c=e?.webSearch,l=t?.capabilities.capabilities.attachments,u=l?.status===`available`?l.kinds.some(e=>e===`image`):null,f=t?.session.model.state===`known`?t.session.model.value:null,m=f?f.inputCapabilities.some(e=>e===`image`):null,h=a?.imageInput??m??u,_=(a?.provider??o??null)===`openai-codex`,v=[{key:`search`,icon:(0,q.jsx)(i,{color:`primary`}),title:c?.route===`codex-first`?`Codex Web Search`:j(s,`Tìm kiếm web`,`Web search`),detail:c?.route===`codex-first`?j(s,`Dùng đăng nhập Codex của Pi; tự chuyển sang Exa khi Codex Search không khả dụng.`,`Uses Pi's Codex sign-in and falls back to Exa when Codex Search is unavailable.`):c?.state===`configured`?j(s,`Route tự động đang hoạt động; kết nối Codex để ưu tiên native Web Search.`,`Automatic routing is configured; connect Codex to prefer native Web Search.`):j(s,`Chưa tìm thấy tích hợp web search trong Pi runtime.`,`The Pi runtime web-search integration was not found.`),status:c?.route===`codex-first`?j(s,`Ưu tiên Codex`,`Codex first`):c?.state===`configured`?j(s,`Đã cấu hình`,`Configured`):j(s,`Chưa có`,`Unavailable`),ready:c?.state===`configured`},{key:`vision`,icon:(0,q.jsx)(se,{color:`primary`}),title:_?`Codex Vision`:j(s,`Vision của model`,`Model vision`),detail:h===!0?j(s,`Ảnh đính kèm được gửi trực tiếp cho model của session hiện tại.`,`Image attachments are sent directly to the current session model.`):h===!1?j(s,`Model hiện tại chỉ nhận text; hãy chọn model hỗ trợ image input.`,`The current model is text-only; select a model that supports image input.`):j(s,`Runtime chưa công bố image-input capability của model hiện tại.`,`The runtime has not reported the current model's image-input capability.`),status:h===!0?j(s,`Đang dùng`,`Active`):h===!1?j(s,`Không hỗ trợ`,`Unsupported`):j(s,`Chưa rõ`,`Unknown`),ready:h===!0}];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(n,{variant:`h2`,sx:{mt:3,mb:.5},children:j(s,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:j(s,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:v.map(e=>(0,q.jsx)(d,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,q.jsxs)(p,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,q.jsx)(g,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:1,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:e.title}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,q.jsx)(r,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function he({options:e,auth:t,refreshAuth:i,session:a,snapshot:o,onSetModel:s,onSetThinking:c}){let{locale:l}=A(),[u,f]=(0,K.useState)(!1),[m,h]=(0,K.useState)(null),_=o?.session.model.state===`known`?o.session.model.value:null,v=(0,K.useMemo)(()=>{let t=new Map;for(let n of e?.models??[])t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t.entries()]},[e]),y=_?.modelRef??``,b=e?.models.find(e=>e.modelRef===y),x=b?y:``,S=_?.displayName??a?.modelLabel??`—`,C=a?.managedThinkingLevels??b?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],w=async e=>{if(e){f(!0),h(null);try{await e()}catch{h(j(l,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{f(!1)}}};return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(l,`Nhà cung cấp & model`,`Providers & models`)}),a&&(0,q.jsxs)(d,{variant:`outlined`,sx:{p:2.25,borderRadius:1,mb:2},children:[(0,q.jsxs)(p,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,q.jsx)(W,{name:_?.provider??a.modelLabel??`model`,size:38}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{sx:{fontWeight:650},children:j(l,`Model của session hiện tại`,`Current session model`)}),(0,q.jsxs)(n,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[S,` · `,z(a.thinkingLevel,l)]})]}),(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:j(l,`Đang dùng`,`In use`)})]}),(0,q.jsxs)(p,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,q.jsxs)(g,{sx:{flex:1},children:[(0,q.jsx)(n,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,q.jsx)(k,{fullWidth:!0,size:`small`,value:x,displayEmpty:!0,renderValue:t=>t?e?.models.find(e=>e.modelRef===t)?.displayName??S:S,disabled:u||!s||a.liveState===`running`,onChange:e=>void w(()=>s?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,q.jsx)(D,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,q.jsxs)(g,{sx:{width:{md:220}},children:[(0,q.jsx)(n,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,q.jsx)(k,{fullWidth:!0,size:`small`,value:a.thinkingLevel===`unknown`?`off`:a.thinkingLevel,disabled:u||!c||a.liveState===`running`,onChange:e=>void w(()=>c?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:C.map(e=>(0,q.jsx)(D,{value:e,children:z(e,l)},e))})]})]}),m&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:m})]}),(0,q.jsx)(me,{options:e,snapshot:o,activeModel:b,observedProvider:_?.provider}),(0,q.jsx)(n,{variant:`h2`,sx:{mt:3,mb:.5},children:j(l,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:j(l,`Kết nối tài khoản để mở khóa model tương ứng.`,`Connect an account to make its models available.`)}),(0,q.jsx)(ce,{catalog:t,refresh:i}),(0,q.jsx)(n,{variant:`h2`,sx:{mt:3,mb:.5},children:j(l,`Danh mục model`,`Model catalog`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:j(l,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:v.map(([e,t])=>(0,q.jsxs)(d,{variant:`outlined`,sx:{p:1.5,borderRadius:1},children:[(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,q.jsx)(W,{name:e,size:32}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{noWrap:!0,sx:{fontWeight:650,textTransform:`capitalize`},children:e}),(0,q.jsxs)(n,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,q.jsx)(r,{size:`small`,color:`success`,variant:`outlined`,label:j(l,`Sẵn sàng`,`Ready`)})]}),(0,q.jsxs)(g,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&v.length===0&&(0,q.jsx)(n,{color:`text.secondary`,children:j(l,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function ge({value:e,loading:t,sessionRef:i,onChanged:a}){let{locale:o}=A();return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(o,`MCP & kết nối`,`MCP & connections`)}),t?(0,q.jsx)(ee,{size:22}):(0,q.jsxs)(p,{spacing:1,children:[(e?.connections??[]).map(e=>(0,q.jsx)(d,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,q.jsxs)(p,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,q.jsx)(W,{name:e.name,size:38}),(0,q.jsxs)(g,{sx:{flex:1,minWidth:0},children:[(0,q.jsx)(n,{noWrap:!0,sx:{fontWeight:650},children:e.name}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,children:H(e,o)})]}),i?(0,q.jsx)(V,{sessionRef:i,connection:e,onChanged:a}):(0,q.jsx)(r,{size:`small`,variant:`outlined`,label:j(o,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,q.jsx)(n,{color:`text.secondary`,children:j(o,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function _e({snapshot:e,session:t,onSetPermission:r}){let{locale:i}=A(),a=e?.session.permissionProfile,[o,s]=(0,K.useState)(a?.state===`known`?a.value??null:null),[c,u]=(0,K.useState)(!1),[f,p]=(0,K.useState)(null),[h,_]=(0,K.useState)(null);(0,K.useEffect)(()=>{s(t?.managedPermission??(a?.state===`known`?a.value??null:null))},[t?.sessionRef,t?.managedPermission,a?.state,a?.value]);let v=async e=>{if(r){u(!0),p(null);try{await r(e),s(e)}catch{p(j(i,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{u(!1)}}},y=e=>{if(e===`trusted-full-access`||e===`bypass`){_(e);return}v(e)},x=[{mode:`read-only`,detail:j(i,`Chỉ xem session, task và source; không thay đổi project.`,`Inspect the session, task, and source without changing the project.`)},{mode:`workspace-write`,detail:j(i,`Đọc, sửa file và chạy command trong project; thao tác nhạy cảm vẫn cần xác nhận.`,`Read and edit project files and run commands; sensitive actions still require confirmation.`)},{mode:`trusted-full-access`,detail:t?.managed?B(i):j(i,`Quyền rộng hơn trong runtime; xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`Broader runtime access; deleting or sending data externally still requires separate confirmation.`)},...!t?.managed||t.managedBypass?[{mode:`bypass`,detail:t?.managed?G(i):U(i)}]:[]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(i,`Quyền truy cập`,`Access`)}),(0,q.jsx)(n,{variant:`h2`,sx:{mb:.5},children:j(i,`Hồ sơ quyền`,`Permission profile`)}),(0,q.jsx)(n,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:j(i,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,q.jsx)(d,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:x.map((e,n)=>(0,q.jsxs)(g,{children:[(0,q.jsx)($,{icon:(0,q.jsx)(l,{color:e.mode===`bypass`?`error`:e.mode===`trusted-full-access`?`warning`:`primary`}),title:z(e.mode,i),detail:e.detail,action:(0,q.jsx)(m,{size:`small`,variant:o===e.mode?`contained`:`outlined`,color:e.mode===`bypass`?`error`:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":o===e.mode,disabled:c||!t||!r||t.liveState===`running`,onClick:()=>y(e.mode),children:z(e.mode,i)})}),n<x.length-1&&(0,q.jsx)(b,{})]},e.mode))}),f&&(0,q.jsx)(n,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:f}),(0,q.jsx)(re,{open:h!==null,title:h===`bypass`?j(i,`Bật Bypass?`,`Turn on Bypass?`):j(i,`Bật toàn quyền?`,`Enable full access?`),description:h===`bypass`?t?.managed?G(i):U(i):j(i,`Session này sẽ được phép đọc, sửa file và chạy command trong phạm vi runtime. Các thao tác xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`This session will be allowed to read and edit files and run commands within the runtime. Destructive actions and external data transfers still require separate confirmation.`),cancelLabel:j(i,`Hủy`,`Cancel`),confirmLabel:h===`bypass`?j(i,`Bật Bypass`,`Turn on Bypass`):j(i,`Bật toàn quyền`,`Enable full access`),onCancel:()=>_(null),onConfirm:()=>{let e=h;_(null),e&&v(e)}})]})}function ve({session:e,snapshot:t}){let{locale:r}=A(),i=t?.usage.context??(e?{state:e.contextUsage.state,tokens:e.contextUsage.usedTokens,contextWindow:e.contextUsage.contextWindow,percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100}:void 0),a=[[j(r,`Context`,`Context`),i?.percent==null?`—`:`${Math.round(i.percent)}%`],[`Tokens`,`${Z(i?.tokens,r)} / ${Z(i?.contextWindow,r)}`],[j(r,`Input`,`Input`),Z(t?.usage.sessionTotal.input,r)],[j(r,`Output`,`Output`),Z(t?.usage.sessionTotal.output,r)],[j(r,`Continuation`,`Continuation`),Z(t?.continuation.remaining,r)],[`Verifier`,t?.verification.state??`—`]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:j(r,`Usage & context`,`Usage & context`)}),(0,q.jsx)(g,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,sm:`repeat(2,minmax(0,1fr))`,lg:`repeat(3,minmax(0,1fr))`},gap:1},children:a.map(([e,t])=>(0,q.jsxs)(d,{variant:`outlined`,sx:{p:2,borderRadius:1},children:[(0,q.jsx)(n,{variant:`caption`,color:`text.secondary`,children:e}),(0,q.jsx)(n,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:650},children:t})]},e))})]})}function ye({capabilities:e,connection:t}){let{locale:r}=A(),i=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[j(r,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(Q,{children:`Piagent`}),(0,q.jsx)(d,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:i.map(([e,t],r)=>(0,q.jsxs)(g,{children:[(0,q.jsxs)(p,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,q.jsx)(n,{color:`text.secondary`,children:e}),(0,q.jsx)(n,{sx:{fontWeight:650},children:String(t)})]}),r<i.length-1&&(0,q.jsx)(b,{})]},String(e)))})]})}function be({section:e,onSection:t,onBack:n,session:r,snapshot:i,capabilities:a,connection:o,onSetModel:s,onSetThinking:c,onSetPermission:l,onRuntimeChanged:u}){let{locale:d}=A(),[f,p]=(0,K.useState)(),[m,h]=(0,K.useState)(),[_,v]=(0,K.useState)(),[y,b]=(0,K.useState)(!1);return(0,K.useEffect)(()=>{let e=new AbortController;return F(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]),(0,K.useEffect)(()=>{let e=new AbortController;return N(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,K.useEffect)(()=>{if(!r){v(void 0);return}let e=new AbortController;return b(!0),v(void 0),P(r.sessionRef,e.signal).then(v).catch(()=>void 0).finally(()=>{e.signal.aborted||b(!1)}),()=>e.abort()},[r?.sessionRef]),(0,q.jsxs)(g,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`236px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,q.jsx)(ae,{section:e,onSection:t,onBack:n}),(0,q.jsxs)(g,{component:`main`,sx:{width:`100%`,minHeight:0,overflowY:`auto`,px:{xs:2,sm:3,lg:5},py:{xs:3,md:4}},children:[e===`general`&&(0,q.jsx)(pe,{}),e===`updates`&&(0,q.jsx)(oe,{}),e===`shortcuts`&&(0,q.jsx)(ie,{}),e===`models`&&(0,q.jsx)(he,{options:f,auth:m,refreshAuth:async()=>{let[e,t]=await Promise.all([N(),F()]);h(e),p(t)},session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,q.jsx)(ge,{value:_,loading:y,sessionRef:r?.sessionRef,onChanged:async e=>{if(e){v(e);return}r&&v(await P(r.sessionRef).catch(()=>_))}}),e===`controls`&&(0,q.jsx)(fe,{session:r,options:f,connections:_,onCompleted:u}),e===`permissions`&&(0,q.jsx)(_e,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,q.jsx)(ve,{session:r,snapshot:i}),e===`about`&&(0,q.jsx)(ye,{capabilities:a,connection:o})]})]})}export{be as SettingsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalView-C3upxbKw.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-DNZbaWhT.js","assets/ui-preferences-OfS30-ZV.js","assets/terminal-transport-Dk5pYNX5.js","assets/bootstrap-CedkNtRG.js","assets/TerminalView-kHJ-D0s7.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Bt as n,Gt as r,Ht as i,Kt as a,Rn as o,Ut as s,Vt as c,Wt as l,qt as u,t as d}from"./vendor-DNZbaWhT.js";import{i as f,n as p}from"./ui-preferences-OfS30-ZV.js";import{t as m}from"./index-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Bt as n,Gt as r,Ht as i,Kt as a,Rn as o,Ut as s,Vt as c,Wt as l,qt as u,t as d}from"./vendor-DNZbaWhT.js";import{i as f,n as p}from"./ui-preferences-OfS30-ZV.js";import{t as m}from"./index-C3CJv1wM.js";import{t as h}from"./terminal-transport-Dk5pYNX5.js";import{t as g}from"./tab-close-BwkkhMH7.js";var _=e(o(),1);function v(e){return Array.isArray(e)?`[${e.map(v).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${v(t)}`).join(`,`)}}`:JSON.stringify(e)}async function y(e,t){let n=Date.now(),r=`terminal.command`,i={...e.identity},a={...e.revisions},o=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(v({action:r,identity:i,expectedRevisions:a,payload:t})));return{schemaVersion:1,version:`piagent-terminal-v1`,messageType:`command`,action:r,identity:i,expectedRevisions:a,payload:t,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(n).toISOString(),expiresAt:new Date(n+6e4).toISOString(),actionDigest:`sha256:${[...new Uint8Array(o)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}}var b=e=>e.phase===`rejected`&&e.reasonCode===`terminal-stale-revision`,x=class{#e;#t=new Set;#n;sessionRef;#r=null;#i=null;#a=Promise.resolve();#o=0;#s=0;#c=0;#l=null;constructor(e,t=h){this.sessionRef=e,this.#n=t,this.#e={state:null,connected:t.ready,error:null,pending:null,busy:!1}}snapshot=()=>this.#e;get disposable(){return!this.#t.size&&!this.#s&&!this.#e.pending&&!this.#e.busy}#u(e){this.#e={...this.#e,...e};for(let e of this.#t)e()}subscribe=e=>(this.#t.add(e),this.#r||(this.#r=this.#n.subscribe(e=>{e.messageType===`state`&&e.identity.sessionRef===this.sessionRef&&this.#u({state:e})}),this.#i=this.#n.connection(e=>{e||this.#o++,this.#u({connected:e}),e&&this.refresh()}),this.#u({connected:this.#n.ready}),this.#n.ready&&this.refresh()),()=>{this.#t.delete(e),this.#t.size||(this.#r?.(),this.#i?.(),this.#r=null,this.#i=null)});refresh=()=>(this.#l||=this.#n.state(this.sessionRef).then(e=>this.#u({state:e}),e=>{this.#u({error:e instanceof Error?e.message:`terminal-unavailable`})}).finally(()=>{this.#l=null}),this.#l);error=e=>this.#u({error:e});acknowledge=()=>{this.#e.busy||(this.#o++,this.#u({pending:null,error:null}))};async#d(e){this.#u({pending:e});let t=await this.#n.execute(e),n=this.#e.state;return n&&n.identity.runtimeInstanceRef===t.identity.runtimeInstanceRef&&n.identity.gatewayInstanceRef===t.identity.gatewayInstanceRef&&this.#u({state:{...n,revisions:t.observedRevisions}}),t.phase!==`settled`&&!b(t)&&this.#o++,t.phase===`uncertain`?(this.#u({error:t.reasonCode??`terminal-effect-uncertain`}),t):(this.#u({pending:null,error:t.phase===`rejected`?t.reasonCode??`terminal-command-rejected`:null}),t)}execute(e){let t=e.kind===`input`?new TextEncoder().encode(e.data).length:0;if(t>16384||this.#c+t>65536||this.#s>=64)return this.error(`terminal-input-limit`),Promise.resolve();if(!this.#e.connected||this.#e.pending&&!this.#e.busy)return this.error(`terminal-command-unconfirmed`),Promise.resolve();let n=this.#o;this.#c+=t,this.#s++;let r=this.#a.then(async()=>{if(n!==this.#o||this.#e.pending||!this.#e.connected)return;let t=this.#e.state;if(t?.available){if(e.kind===`resize`){let n=t.terminals.find(t=>t.terminalRef===e.terminalRef);if(!n||n.cols===e.cols&&n.rows===e.rows)return}this.#u({busy:!0});try{if(b(await this.#d(await y(t,e)))){await this.refresh();let t=this.#e.state;t?.available&&(this.#u({error:null}),await this.#d(await y(t,e)))}}catch(e){this.#o++,this.error(e instanceof Error?e.message:`terminal-effect-uncertain`)}finally{this.#u({busy:!1})}}}).finally(()=>{this.#c-=t,this.#s--});return this.#a=r.catch(()=>{}),r}retry=async()=>{let e=this.#e.pending;if(!(!e||this.#e.busy||!this.#e.connected)){this.#u({busy:!0});try{await this.#d(e)}catch(e){this.#o++,this.error(e instanceof Error?e.message:`terminal-effect-uncertain`)}finally{this.#u({busy:!1})}}}},S=new Map;function C(e){let t=S.get(e);if(!t){if(S.size>=64){let e=[...S].find(([,e])=>e.disposable);if(!e)throw Error(`terminal-client-capacity`);S.delete(e[0])}t=new x(e),S.set(e,t)}return t}var w=t(),T=(0,_.lazy)(()=>m(()=>import(`./TerminalView-C3upxbKw.js`),__vite__mapDeps([0,1,2,3,4,5,6])));function E({sessionRef:e,onHide:t}){let{locale:o}=f(),m=(0,_.useMemo)(()=>C(e),[e]),h=(0,_.useSyncExternalStore)(m.subscribe,m.snapshot),v=h.state,[y,b]=(0,_.useState)(null),[x,S]=(0,_.useState)(280),E=(0,_.useRef)(null),D=v?.terminals.find(e=>e.terminalRef===y)?.terminalRef??v?.terminals[0]?.terminalRef??null,O=!h.connected||!v?.available||!!(h.pending&&!h.busy);return(0,w.jsxs)(l,{component:`section`,"aria-label":p(o,`Terminal`,`Terminal`),sx:{borderTop:1,borderColor:`divider`,minWidth:0},children:[(0,w.jsx)(l,{role:`separator`,tabIndex:0,"aria-label":p(o,`Chiều cao terminal`,`Terminal height`),"aria-orientation":`horizontal`,"aria-valuenow":x,"aria-valuemin":160,"aria-valuemax":700,onKeyDown:e=>{[`ArrowUp`,`ArrowDown`].includes(e.key)&&(e.preventDefault(),S(t=>Math.max(160,Math.min(700,t+(e.key===`ArrowUp`?20:-20)))))},onPointerDown:e=>{E.current={y:e.clientY,height:x},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{E.current&&S(Math.max(160,Math.min(700,E.current.height+E.current.y-e.clientY)))},onPointerUp:()=>{E.current=null},onPointerCancel:()=>{E.current=null},sx:{height:8,cursor:`row-resize`,touchAction:`none`,bgcolor:`action.hover`}}),(0,w.jsxs)(l,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,w.jsx)(c,{value:D??!1,onChange:(e,t)=>b(t),variant:`scrollable`,sx:{flex:1,minWidth:0},children:v?.terminals.map(e=>(0,w.jsx)(i,{value:e.terminalRef,"aria-label":`Terminal ${e.number}${e.state===`exited`?p(o,` · đã thoát`,` · exited`):``}`,label:g(`Terminal ${e.number}${e.state===`exited`?p(o,` · đã thoát`,` · exited`):``}`,p(o,`Đóng Terminal ${e.number}`,`Close Terminal ${e.number}`),()=>{h.busy||m.execute({kind:`close`,terminalRef:e.terminalRef})})},e.terminalRef))}),(0,w.jsx)(s,{disabled:O||h.busy||(v?.terminals.length??0)>=4,"aria-label":p(o,`Mở terminal`,`Open terminal`),onClick:()=>void m.execute({kind:`open`,cols:80,rows:24}),children:`+`}),D&&(0,w.jsx)(s,{disabled:O||h.busy,onClick:()=>void m.execute({kind:`close`,terminalRef:D}),children:p(o,`Đóng terminal`,`Close terminal`)}),t&&(0,w.jsx)(a,{size:`small`,"aria-label":p(o,`Ẩn khung terminal`,`Hide terminal panel`),title:p(o,`Ẩn khung terminal (terminal vẫn chạy)`,`Hide terminal panel (terminals keep running)`),onClick:t,children:(0,w.jsx)(d,{fontSize:`small`})})]}),!h.connected&&(0,w.jsx)(r,{severity:`info`,children:p(o,`Đang nối lại terminal…`,`Reconnecting terminal…`)}),v&&!v.available&&(0,w.jsx)(r,{severity:`info`,children:v.reasonCode===`managed-terminal-seatbelt-unavailable`?p(o,`Sandbox hiện tại trên macOS không hỗ trợ terminal công ty.`,`The current macOS sandbox does not support company terminals.`):v.reasonCode===`company-terminal-disconnected`?p(o,`Mất kết nối với terminal công ty. Đang kết nối lại…`,`Company terminal disconnected. Reconnecting…`):(0,w.jsxs)(w.Fragment,{children:[p(o,`Terminal chưa khả dụng trên môi trường này.`,`Terminal is unavailable in this environment.`),` `,v.reasonCode]})}),h.error&&(0,w.jsxs)(r,{severity:`warning`,children:[p(o,`Thao tác terminal chưa hoàn tất.`,`The terminal action did not complete.`),` `,h.error,h.pending?(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(n,{variant:`body2`,children:p(o,`Kiểm tra output trước khi tiếp tục. Lệnh có thể đã chạy.`,`Check the output before continuing. The command may have run.`)}),(0,w.jsx)(s,{disabled:h.busy||!h.connected,onClick:()=>void m.retry(),children:p(o,`Kiểm tra lại lệnh`,`Check command again`)}),(0,w.jsx)(s,{disabled:h.busy,onClick:m.acknowledge,children:p(o,`Đã kiểm tra, tiếp tục`,`Checked, continue`)})]}):(0,w.jsx)(s,{onClick:()=>void m.refresh(),children:p(o,`Tải lại`,`Refresh`)})]}),!v&&!h.error&&(0,w.jsx)(u,{size:24}),v?.available&&!v.terminals.length&&(0,w.jsx)(n,{sx:{p:2},children:p(o,`Nhấn + để mở terminal trong project.`,`Press + to open a terminal in the project.`)}),(0,w.jsx)(n,{variant:`caption`,sx:{px:1},children:p(o,`Gõ @terminal hoặc @terminal:2 trong tin nhắn để đính output đã che secret khi gửi.`,`Use @terminal or @terminal:2 in your message to attach redacted output when you send.`)}),(0,w.jsx)(l,{sx:{height:x,minWidth:0},children:(0,w.jsx)(_.Suspense,{fallback:(0,w.jsx)(u,{size:24}),children:v?.terminals.map(e=>(0,w.jsx)(T,{identity:v.identity,terminalRef:e.terminalRef,active:D===e.terminalRef,onReady:()=>void m.refresh(),onError:m.error,onInput:t=>{!O&&e.state===`running`&&m.execute({kind:`input`,terminalRef:e.terminalRef,data:t})},onResize:(t,n)=>{!O&&e.state===`running`&&m.execute({kind:`resize`,terminalRef:e.terminalRef,cols:t,rows:n})}},`${v.identity.runtimeInstanceRef}:${e.terminalRef}`))})})]})}export{E as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-C2TMLUTo.js","assets/rolldown-runtime-hePW80VL.js","assets/dist-D6i5SpQu.js","assets/dist-IRUjhd1P.js","assets/dist-sNhoSseW.js","assets/dist-BM_LL1o9.js","assets/dist-DfjUS8LS.js","assets/dist-CqL3udNu.js","assets/dist-D4df0jLQ.js","assets/dist-B5MCHZv5.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Rn as n,Sn as r,Ut as i,Wt as a,fn as o}from"./vendor-DNZbaWhT.js";import{i as s,n as c,r as l}from"./ui-preferences-OfS30-ZV.js";import{t as u}from"./index-
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{An as t,Rn as n,Sn as r,Ut as i,Wt as a,fn as o}from"./vendor-DNZbaWhT.js";import{i as s,n as c,r as l}from"./ui-preferences-OfS30-ZV.js";import{t as u}from"./index-C3CJv1wM.js";import{C as d,D as f,E as p,G as m,N as h,O as g,S as _,T as v,j as y,k as b,t as x,w as S,x as C,y as w,z as T}from"./dist-D6i5SpQu.js";var E=class extends S{lines;label;comment;constructor(e,t,n){super(),this.lines=e,this.label=t,this.comment=n}toDOM(){let e=document.createElement(`div`);e.className=`cm-agent-deleted`;for(let t of this.lines){let n=document.createElement(`div`),r=document.createElement(`span`);if(r.textContent=`− ${t.text}`,n.append(r),this.comment){let e=document.createElement(`button`);e.type=`button`,e.textContent=this.label,e.setAttribute(`aria-label`,`${this.label} ${t.line}`),e.addEventListener(`click`,()=>this.comment?.(t.line,t.text,`old`)),n.append(e)}e.append(n)}return e}},D=class extends S{ref;label;keep;revertLabel;revert;constructor(e,t,n,r,i){super(),this.ref=e,this.label=t,this.keep=n,this.revertLabel=r,this.revert=i}toDOM(){let e=document.createElement(`div`);e.className=`cm-agent-actions`;let t=document.createElement(`button`);if(t.type=`button`,t.textContent=this.label,t.addEventListener(`click`,()=>this.keep(this.ref)),e.append(t),this.revert){let t=document.createElement(`button`);t.type=`button`,t.textContent=this.revertLabel,t.addEventListener(`click`,()=>this.revert?.(this.ref)),e.append(t)}return e}},O=new class extends d{toDOM(){let e=document.createElement(`span`);return e.textContent=`▎`,e.className=`cm-agent-marker`,e}};function k(e,t,n,r,i,a,o=``,s){let c=e.state.doc.toString(),l=[],u=[],d=t=>e.state.doc.line(Math.max(1,Math.min(e.state.doc.lines,t))).from;for(let e of t){let t=d(e.newStart+ +(e.newLineCount===0));u.push(t),l.push(C.widget({widget:new D(e.hunkRef,n,r,i,a),block:!0,side:-1}).range(t));let c=e.newStart+ +(e.newLineCount===0),f=[],p=()=>{f.length&&(l.push(C.widget({widget:new E(f,o,s),block:!0,side:-1}).range(d(c))),f=[])};for(let t of e.lines){if(t.kind===`deleted`){t.oldLineNumber!==null&&f.push({line:t.oldLineNumber,text:t.text});continue}p(),t.newLineNumber!==null&&(c=t.newLineNumber+1,t.kind===`added`&&l.push(C.line({class:`cm-agent-added`}).range(d(t.newLineNumber))))}p()}let f=T.define({create:()=>C.set(l,!0),update:(e,t)=>t.docChanged?C.none:e,provide:e=>_.decorations.from(e)}),p=e=>t=>{if(!u.length||t.state.doc.toString()!==c)return!1;let n=t.state.selection.main.head,r=e>0?u.find(e=>e>n)??u[0]:[...u].reverse().find(e=>e<n)??u.at(-1);return t.dispatch({selection:{anchor:r},effects:_.scrollIntoView(r,{y:`center`})}),!0};return[f,t.length?v({class:`cm-agent-gutter`,lineMarker:(e,t)=>e.state.field(f).size&&u.includes(t.from)?O:null}):[],g.of([{key:`Alt-ArrowDown`,run:p(1)},{key:`Alt-ArrowUp`,run:p(-1)}]),_.theme({".cm-agent-added":{backgroundColor:`color-mix(in srgb, #2e9d55 15%, transparent)`},".cm-agent-deleted":{margin:`0`,padding:`2px 8px`,whiteSpace:`pre-wrap`,backgroundColor:`color-mix(in srgb, #df4545 15%, transparent)`,fontFamily:`monospace`},".cm-agent-marker":{color:`#2e9d55`},".cm-agent-actions":{padding:`2px 8px`},".cm-agent-actions button":{color:`inherit`,background:`transparent`,border:`1px solid currentColor`,borderRadius:`4px`,cursor:`pointer`}})]}var A=e(n(),1),j=t();function M({syntax:e}){return x.define([{tag:[m.keyword,m.controlKeyword,m.moduleKeyword,m.definitionKeyword,m.modifier,m.self,m.null,m.bool,m.atom],color:e.keyword},{tag:[m.string,m.special(m.string),m.regexp,m.character],color:e.string},{tag:[m.number,m.integer,m.float,m.unit],color:e.number},{tag:[m.comment,m.lineComment,m.blockComment,m.docComment,m.meta],color:e.comment,fontStyle:`italic`},{tag:[m.function(m.variableName),m.function(m.propertyName),m.macroName],color:e.function},{tag:[m.typeName,m.className,m.namespace,m.tagName,m.standard(m.tagName)],color:e.type},{tag:[m.propertyName,m.attributeName,m.labelName],color:e.property},{tag:[m.operator,m.punctuation,m.bracket,m.derefOperator],color:e.operator},{tag:[m.heading,m.heading1,m.heading2,m.heading3],color:e.heading,fontWeight:`600`},{tag:[m.link,m.url],color:e.link,textDecoration:`underline`},{tag:m.emphasis,fontStyle:`italic`},{tag:m.strong,fontWeight:`600`},{tag:m.invalid,color:e.keyword,textDecoration:`underline wavy`}])}async function N(e){let t=e.split(`.`).at(-1)?.toLowerCase();switch(t){case`js`:case`mjs`:case`cjs`:case`jsx`:case`ts`:case`tsx`:return(await u(async()=>{let{javascript:e}=await import(`./dist-C2TMLUTo.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3,4]))).javascript({typescript:t===`ts`||t===`tsx`,jsx:t===`jsx`||t===`tsx`});case`json`:return(await u(async()=>{let{json:e}=await import(`./dist-BM_LL1o9.js`);return{json:e}},__vite__mapDeps([5,2,3]))).json();case`md`:return(await u(async()=>{let{markdown:e}=await import(`./dist-DfjUS8LS.js`);return{markdown:e}},__vite__mapDeps([6,2,4,7,3,8,1,0]))).markdown();case`py`:return(await u(async()=>{let{python:e}=await import(`./dist-B5MCHZv5.js`);return{python:e}},__vite__mapDeps([9,2,3,4]))).python();case`html`:return(await u(async()=>{let{html:e}=await import(`./dist-CqL3udNu.js`);return{html:e}},__vite__mapDeps([7,2,3,8,1,0,4]))).html();case`css`:return(await u(async()=>{let{css:e}=await import(`./dist-D4df0jLQ.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([8,1,2,3]))).css();default:return[]}}var P=[],F=e=>{};function I({content:e,path:t,line:n=1,readOnly:u=!0,onChange:d,onSave:m,hunks:v=P,onKeep:x=F,onRevert:S,onComment:C}){let T=(0,A.useRef)(null),E=(0,A.useRef)(null),D=o(),O=(0,A.useRef)({onChange:d,onSave:m,onComment:C});O.current={onChange:d,onSave:m,onComment:C};let I=(0,A.useRef)(e);I.current=e;let L=(0,A.useRef)(new y),R=(0,A.useRef)(new y),{locale:z}=s(),B=l();return(0,A.useEffect)(()=>{if(!T.current)return;let e=document.querySelector(`meta[name="csp-nonce"]`)?.content,n=new y,i=!1,a=new _({parent:T.current,state:h.create({doc:I.current,extensions:[R.current.of([]),_.cspNonce.of(e??``),L.current.of([h.readOnly.of(u),_.editable.of(!u)]),g.of([{key:`Mod-Shift-m`,run:e=>{let t=e.state.doc.lineAt(e.state.selection.main.head);return O.current.onComment?.(t.number,t.text),!!O.current.onComment}}]),g.of([`Ctrl-s`,`Meta-s`].map(e=>({key:e,run:()=>(O.current.onSave?.(),!0)}))),_.updateListener.of(e=>{e.docChanged&&O.current.onChange?.(e.state.doc.toString())}),b(),p(),f(),w(M(B)),n.of([]),_.contentAttributes.of({"aria-label":t,tabindex:`0`}),_.theme({"&":{height:`100%`,color:D.palette.text.primary,backgroundColor:D.palette.background.paper},".cm-scroller":{overflow:`auto`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:`13px`,lineHeight:1.55},".cm-content":{caretColor:D.palette.primary.main},".cm-cursor, .cm-dropCursor":{borderLeftColor:D.palette.primary.main},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:r(D.palette.primary.main,.25)},".cm-activeLine":{backgroundColor:r(D.palette.text.primary,.04)},".cm-gutters":{backgroundColor:D.palette.background.paper,color:D.palette.text.secondary,borderRight:`1px solid ${D.palette.divider}`},".cm-activeLineGutter":{backgroundColor:r(D.palette.text.primary,.06),color:D.palette.text.primary}},{dark:D.palette.mode===`dark`})]})});return E.current=a,N(t).then(e=>{i||a.dispatch({effects:n.reconfigure(e)})}).catch(()=>{}),()=>{i=!0,E.current=null,a.destroy()}},[t,D]),(0,A.useEffect)(()=>{let t=E.current;t&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},[e,t,D]),(0,A.useEffect)(()=>{let e=E.current;e&&e.dispatch({effects:R.current.reconfigure(k(e,v,c(z,`Giữ`,`Keep`),x,c(z,`Hoàn tác`,`Revert`),S,c(z,`Comment dòng đã xóa`,`Comment on removed line`),C))})},[v,x,S,C,e,t,D,z]),(0,A.useEffect)(()=>{E.current?.dispatch({effects:L.current.reconfigure([h.readOnly.of(u),_.editable.of(!u)])})},[u,t,D]),(0,A.useEffect)(()=>{let e=E.current;if(!e)return;let t=e.state.doc.line(Math.max(1,Math.min(e.state.doc.lines,n))).from;e.dispatch({selection:{anchor:t},effects:_.scrollIntoView(t,{y:`center`})})},[n,t,D]),(0,j.jsxs)(a,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[C&&(0,j.jsx)(i,{size:`small`,onClick:()=>{let e=E.current;if(!e)return;let t=e.state.doc.lineAt(e.state.selection.main.head);C(t.number,t.text)},children:c(z,`Comment dòng hiện tại`,`Comment on current line`)}),(0,j.jsx)(a,{ref:T,sx:{flex:1,minHeight:240,overflow:`hidden`}})]})}export{I as default};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/WorkspaceCodeEditor-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{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-DFrh3qs2.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-DNZbaWhT.js","assets/ui-preferences-OfS30-ZV.js","assets/index-C3CJv1wM.js","assets/index-CjM70M7D.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-C3CJv1wM.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-E0Zopcke.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-DFrh3qs2.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-Bfvr2S8S.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-CU-wndsb.js","assets/ui-preferences-OfS30-ZV.js","assets/ActivityPanel-Bv-jc1s3.js","assets/view-model-CWNiS4JN.js","assets/workspace-navigation-DW8zhH6U.js","assets/AttachmentImage-eZKqLYZ2.js","assets/transcript-view-model-acWtHGyE.js","assets/LineReview-CB3mQe7m.js","assets/GatewayApp-MIvgr7kn.js","assets/SettingsNavigation-Bu1A7x4F.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-BKQiA0Ce.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),nt=(0,C.lazy)(()=>Ze(()=>import(`./GatewayApp-B3--WjSd.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-Bfvr2S8S.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13]))),nt=(0,C.lazy)(()=>Ze(()=>import(`./GatewayApp-MIvgr7kn.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-C3CJv1wM.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">
|
|
@@ -39,7 +39,7 @@ type TranscriptItem = { messageRef: string; parentMessageRef: string | null; rol
|
|
|
39
39
|
type HarnessFinding = { severity: "blocking" | "major" | "minor"; file: string; line: number | null; issue: 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" | "final" | "objection" | "answer" | "claims" | "rejudge" | "dispute" | "continue" | "undo"; outcome?: string; loop?: number; maxLoops?: number;
|
|
42
|
-
verified?: boolean; reviewed?: boolean; blockingOpen?: number; planOpen?: number; planDone?: number; planSteps?: number; round?: number; maxRounds?: number; idle?: number; planSkipped?: true; verifyPolicy?: string; reviewPolicy?: string; reviewUnavailable?: string;
|
|
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
43
|
findings?: HarnessFinding[]; role?: "scout" | "research" | "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;
|
|
@@ -237,6 +237,7 @@ function harnessProcess(details: any): HarnessProcess | null {
|
|
|
237
237
|
if (upTo(details.maxRounds, 1, 30)) out.maxRounds = details.maxRounds;
|
|
238
238
|
if (upTo(details.idle, 1, 2)) out.idle = details.idle;
|
|
239
239
|
if (details.planSkipped === true) out.planSkipped = true;
|
|
240
|
+
if (details.partOnly === true) out.partOnly = true;
|
|
240
241
|
if (POLICY_MODES.includes(details.policy?.verify)) out.verifyPolicy = details.policy.verify;
|
|
241
242
|
if (POLICY_MODES.includes(details.policy?.review)) out.reviewPolicy = details.policy.review;
|
|
242
243
|
if (["too_large", "not_git", "limit", "failed"].includes(details.reviewUnavailable)) out.reviewUnavailable = details.reviewUnavailable;
|