@piagent/platform 1.18.0 → 1.19.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 +22 -0
- package/README.md +1 -1
- package/README.vi.md +1 -1
- package/docs/command-reference-vietnamese.md +2 -2
- package/docs/distribution-standard.md +6 -6
- package/docs/languages.json +2 -2
- 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/benchmark.html +1 -1
- package/docs-site/commands.html +1 -1
- package/docs-site/content/en/index.html +4 -4
- package/docs-site/content/en/whats-new.html +7 -0
- package/docs-site/content/index.html +4 -4
- package/docs-site/content/whats-new.html +7 -0
- 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 +5 -5
- 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/whats-new.html +8 -1
- package/docs-site/en/windows.html +1 -1
- package/docs-site/en/workflows.html +1 -1
- package/docs-site/index.html +5 -5
- 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/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/whats-new.html +8 -1
- 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/call-purpose.mjs +3 -2
- package/packages/piagent-core/managed/command-tools.mjs +59 -0
- package/packages/piagent-core/managed/container-engine.mjs +102 -0
- package/packages/piagent-core/managed/continuation.mjs +131 -0
- package/packages/piagent-core/managed/doctor.mjs +7 -0
- package/packages/piagent-core/managed/language-environment.mjs +57 -0
- package/packages/piagent-core/managed/linux-sandbox.mjs +3 -1
- package/packages/piagent-core/managed/patch-snapshot.mjs +25 -9
- package/packages/piagent-core/managed/repository-operation.mjs +20 -0
- package/packages/piagent-core/managed/review-snapshot-worker.mjs +11 -4
- package/packages/piagent-core/managed/sandbox-diagnostic.mjs +6 -1
- package/packages/piagent-core/managed/session.mjs +50 -62
- package/packages/piagent-core/managed/tool-boundary.mjs +21 -10
- package/packages/piagent-core/managed/tool-worker.mjs +3 -3
- package/packages/piagent-core/managed/workflow.mjs +20 -20
- package/packages/piagent-core/package.json +1 -1
- package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-DlbuyiQ3.js → MarkdownMessage-nggiOt0N.js} +1 -1
- package/packages/piagent-webui/dist/client/assets/{index-BGxsZHB5.js → index-CM9cs-gP.js} +16 -14
- package/packages/piagent-webui/dist/client/index.html +1 -1
- package/packages/piagent-webui/gateway/company-relay.ts +14 -2
- package/packages/piagent-webui/gateway/gateway-service.ts +20 -8
- package/packages/piagent-webui/gateway/git-repositories.ts +46 -0
- package/packages/piagent-webui/gateway/managed-projection.ts +9 -2
- package/packages/piagent-webui/gateway/project-registry.ts +10 -6
- package/packages/piagent-webui/gateway/session-catalog.ts +13 -6
- package/packages/piagent-webui/server/loopback-server.ts +1 -1
- package/packages/piagent-webui/server/member-routes.ts +6 -3
- package/packages/piagent-webui/server/tool-call-summary.ts +3 -1
- package/packages/piagent-webui/server/transcript-projection.ts +20 -4
- package/packages/piagent-webui/shared/process-copy.ts +3 -1
- package/packages/piagent-webui/shared/turn-end.ts +68 -0
- package/schemas/piagent-webui/session-catalog-v1.schema.json +11 -1
- package/schemas/piagent-webui/transcript-v1.schema.json +23 -2
- package/scripts/company-terminal.mjs +15 -0
|
@@ -168,13 +168,14 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
168
168
|
animation: ${fu} 1.4s linear infinite;
|
|
169
169
|
`,hu=typeof pu==`string`?null:Et`
|
|
170
170
|
animation: ${pu} 1.4s ease-in-out infinite;
|
|
171
|
-
`,gu=e=>{let{classes:t,variant:n,color:r,disableShrink:i}=e;return ba({root:[`root`,n,`color${q(r)}`],svg:[`svg`],track:[`track`],circle:[`circle`,i&&`circleDisableShrink`]},uu,t)},_u=K(`span`,{name:`MuiCircularProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`color${q(n.color)}`]]}})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`});return{display:`inline-block`,variants:[{props:{variant:`determinate`},style:{...Ks(e,`transform`)}},{props:{variant:`indeterminate`},style:mu||{animation:`${fu} 1.4s linear infinite`}},...t?[{props:{variant:`indeterminate`},style:t}]:[],...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}}))]}})),vu=K(`svg`,{name:`MuiCircularProgress`,slot:`Svg`})({display:`block`}),yu=K(`circle`,{name:`MuiCircularProgress`,slot:`Circle`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.circle,n.disableShrink&&t.circleDisableShrink]}})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`});return{stroke:`currentColor`,variants:[{props:{variant:`determinate`},style:{...Ks(e,`stroke-dashoffset`)}},{props:{variant:`indeterminate`},style:{strokeDasharray:`80px, 200px`,strokeDashoffset:0}},{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:hu||{animation:`${pu} 1.4s ease-in-out infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:t}]:[]]}})),bu=K(`circle`,{name:`MuiCircularProgress`,slot:`Track`})(ys(({theme:e})=>({stroke:`currentColor`,opacity:(e.vars||e).palette.action.activatedOpacity}))),xu=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiCircularProgress`}),{className:r,color:i=`primary`,disableShrink:a=!1,enableTrackSlot:o=!1,min:s,max:c,size:l=40,style:u,thickness:d=3.6,value:f=n.min??0,variant:p=`indeterminate`,...m}=n,h=s??0,g=c??100,_={...n,color:i,disableShrink:a,size:l,thickness:d,value:f,variant:p,enableTrackSlot:o},v=gu(_),y={},b={},x={};if(p===`determinate`){let e=2*Math.PI*((du-d)/2),t=g-h;y.strokeDasharray=e.toFixed(3),y.strokeDashoffset=t>0?`${((g-f)/t*e).toFixed(3)}px`:`${e.toFixed(3)}px`,b.transform=`rotate(-90deg)`,x[`aria-valuenow`]=f,x[`aria-valuemin`]=h,x[`aria-valuemax`]=g}return(0,U.jsx)(_u,{className:W(v.root,r),style:{width:l,height:l,...b,...u},ownerState:_,ref:t,role:`progressbar`,...x,...m,children:(0,U.jsxs)(vu,{className:v.svg,ownerState:_,viewBox:`${du/2} ${du/2} ${du} ${du}`,children:[o?(0,U.jsx)(bu,{className:v.track,ownerState:_,cx:du,cy:du,r:(du-d)/2,fill:`none`,strokeWidth:d,"aria-hidden":`true`}):null,(0,U.jsx)(yu,{className:v.circle,style:y,ownerState:_,cx:du,cy:du,r:(du-d)/2,fill:`none`,strokeWidth:d})]})})});function Su(e){return Gr(`MuiDivider`,e)}var Cu=Kr(`MuiDivider`,[`root`,`absolute`,`fullWidth`,`inset`,`middle`,`flexItem`,`vertical`,`withChildren`,`textAlignRight`,`textAlignLeft`,`wrapper`,`wrapperVertical`]),wu=e=>{let{absolute:t,children:n,classes:r,flexItem:i,orientation:a,textAlign:o,variant:s}=e;return ba({root:[`root`,t&&`absolute`,s,a===`vertical`&&`vertical`,i&&`flexItem`,n&&`withChildren`,o===`right`&&a!==`vertical`&&`textAlignRight`,o===`left`&&a!==`vertical`&&`textAlignLeft`],wrapper:[`wrapper`,a===`vertical`&&`wrapperVertical`]},Su,r)},Tu=K(`div`,{name:`MuiDivider`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.absolute&&t.absolute,t[n.variant],n.orientation===`vertical`&&t.vertical,n.flexItem&&t.flexItem,n.children&&t.withChildren,n.textAlign===`right`&&n.orientation!==`vertical`&&t.textAlignRight,n.textAlign===`left`&&n.orientation!==`vertical`&&t.textAlignLeft]}})(ys(({theme:e})=>({margin:0,flexShrink:0,borderWidth:0,borderStyle:`solid`,borderColor:(e.vars||e).palette.divider,borderBottomWidth:`thin`,variants:[{props:{absolute:!0},style:{position:`absolute`,bottom:0,left:0,width:`100%`}},{props:{variant:`inset`},style:{marginLeft:72}},{props:{variant:`middle`,orientation:`horizontal`},style:{marginLeft:e.spacing(2),marginRight:e.spacing(2)}},{props:{variant:`middle`,orientation:`vertical`},style:{marginTop:e.spacing(1),marginBottom:e.spacing(1)}},{props:{orientation:`vertical`},style:{height:`100%`,borderBottomWidth:0,borderRightWidth:`thin`}},{props:{flexItem:!0},style:{alignSelf:`stretch`,height:`auto`}},{props:({ownerState:e})=>!!e.children,style:{display:`flex`,textAlign:`center`,border:0,borderTopStyle:`solid`,borderLeftStyle:`solid`,"&::before, &::after":{content:`""`,alignSelf:`center`}}},{props:({ownerState:e})=>e.children&&e.orientation!==`vertical`,style:{"&::before, &::after":{width:`100%`,borderTop:`thin solid ${(e.vars||e).palette.divider}`,borderTopStyle:`inherit`}}},{props:({ownerState:e})=>e.orientation===`vertical`&&e.children,style:{flexDirection:`column`,"&::before, &::after":{height:`100%`,borderLeft:`thin solid ${(e.vars||e).palette.divider}`,borderLeftStyle:`inherit`}}},{props:({ownerState:e})=>e.textAlign===`right`&&e.orientation!==`vertical`,style:{"&::before":{width:`90%`},"&::after":{width:`10%`}}},{props:({ownerState:e})=>e.textAlign===`left`&&e.orientation!==`vertical`,style:{"&::before":{width:`10%`},"&::after":{width:`90%`}}}]}))),Eu=K(`span`,{name:`MuiDivider`,slot:`Wrapper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.wrapper,n.orientation===`vertical`&&t.wrapperVertical]}})(ys(({theme:e})=>({display:`inline-block`,paddingLeft:`calc(${e.spacing(1)} * 1.2)`,paddingRight:`calc(${e.spacing(1)} * 1.2)`,whiteSpace:`nowrap`,variants:[{props:{orientation:`vertical`},style:{paddingTop:`calc(${e.spacing(1)} * 1.2)`,paddingBottom:`calc(${e.spacing(1)} * 1.2)`}}]}))),Du=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDivider`}),{absolute:r=!1,children:i,className:a,orientation:o=`horizontal`,component:s=i||o===`vertical`?`div`:`hr`,flexItem:c=!1,role:l=s===`hr`?void 0:`separator`,textAlign:u=`center`,variant:d=`fullWidth`,...f}=n,p={...n,absolute:r,component:s,flexItem:c,orientation:o,role:l,textAlign:u,variant:d},m=wu(p);return(0,U.jsx)(Tu,{as:s,className:W(m.root,a),role:l,ref:t,ownerState:p,"aria-orientation":l===`separator`&&(s!==`hr`||o===`vertical`)?o:void 0,...f,children:i?(0,U.jsx)(Eu,{className:m.wrapper,ownerState:p,children:i}):null})});function Ou(e=window){let t=e.document.documentElement.clientWidth;return e.innerWidth-t}function ku(e){let t=ls(e);return e===t.body||e===t.documentElement?us(e).innerWidth>t.documentElement.clientWidth:e.scrollHeight>e.clientHeight}function Au(e,t){t?e.setAttribute(`aria-hidden`,`true`):e.removeAttribute(`aria-hidden`)}function ju(e){return parseFloat(us(e).getComputedStyle(e).paddingRight)||0}function Mu(e){let t=[`TEMPLATE`,`SCRIPT`,`STYLE`,`LINK`,`MAP`,`META`,`NOSCRIPT`,`PICTURE`,`COL`,`COLGROUP`,`PARAM`,`SLOT`,`SOURCE`,`TRACK`].includes(e.tagName),n=e.tagName===`INPUT`&&e.getAttribute(`type`)===`hidden`;return t||n}function Nu(e,t,n,r,i){let a=[t,n,...r];[].forEach.call(e.children,e=>{let t=!a.includes(e),n=!Mu(e);t&&n&&Au(e,i)})}function Pu(e,t){let n=[],r=e.container;if(!t.disableScrollLock){let e;if(r.parentNode instanceof DocumentFragment)e=ls(r).body;else{let t=r.parentElement,n=us(r);e=t?.nodeName===`HTML`&&n.getComputedStyle(t).overflowY===`scroll`?t:r}if(ku(e)){let t=Ou(us(e));n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${ju(e)+t}px`;let i=ls(r).querySelectorAll(`.mui-fixed`);[].forEach.call(i,e=>{n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${ju(e)+t}px`})}n.push({value:e.style.overflow,property:`overflow`,el:e},{value:e.style.overflowX,property:`overflow-x`,el:e},{value:e.style.overflowY,property:`overflow-y`,el:e}),e.style.overflow=`hidden`}return()=>{n.forEach(({value:e,el:t,property:n})=>{e?t.style.setProperty(n,e):t.style.removeProperty(n)})}}function Fu(e){let t=[];return[].forEach.call(e.children,e=>{e.getAttribute(`aria-hidden`)===`true`&&t.push(e)}),t}var Iu=class{constructor(){this.modals=[],this.containers=[]}add(e,t){let n=this.modals.indexOf(e);if(n!==-1)return n;n=this.modals.length,this.modals.push(e),e.modalRef&&Au(e.modalRef,!1);let r=Fu(t);Nu(t,e.mount,e.modalRef,r,!0);let i=this.containers.findIndex(e=>e.container===t);return i===-1?(this.containers.push({modals:[e],container:t,restore:null,hiddenSiblings:r}),n):(this.containers[i].modals.push(e),n)}mount(e,t){let n=this.containers.findIndex(t=>t.modals.includes(e)),r=this.containers[n];r.restore||=Pu(r,t)}remove(e,t=!0){let n=this.modals.indexOf(e);if(n===-1)return n;let r=this.containers.findIndex(t=>t.modals.includes(e)),i=this.containers[r];if(i.modals.splice(i.modals.indexOf(e),1),this.modals.splice(n,1),i.modals.length===0)i.restore&&i.restore(),e.modalRef&&Au(e.modalRef,t),Nu(i.container,e.mount,e.modalRef,i.hiddenSiblings,!1),this.containers.splice(r,1);else{let e=i.modals[i.modals.length-1];e.modalRef&&Au(e.modalRef,!1)}return n}isTopModal(e){return this.modals.length>0&&this.modals[this.modals.length-1]===e}};function Lu(e){return e?.props?.ref||null}function Ru(e,t){if(!e||!t)return!1;if(e.contains(t))return!0;let n=t.getRootNode?.();if(n&&n instanceof ShadowRoot){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode??n.host??null}}return!1}var zu=Ru,Bu=`data-mui-focusable`;function Vu(e){return e?e.hasAttribute(`data-mui-focusable`)?e:e.querySelector(`[${Bu}]`):null}var Hu=[`input`,`select`,`textarea`,`a[href]`,`button`,`[tabindex]`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function Uu(e){let t=parseInt(e.getAttribute(`tabindex`)||``,10);return Number.isNaN(t)?e.contentEditable===`true`||(e.nodeName===`AUDIO`||e.nodeName===`VIDEO`||e.nodeName===`DETAILS`)&&e.getAttribute(`tabindex`)===null?0:e.tabIndex:t}function Wu(e){if(e.tagName!==`INPUT`||e.type!==`radio`||!e.name)return!1;let t=t=>e.ownerDocument.querySelector(`input[type="radio"]${t}`),n=t(`[name="${e.name}"]:checked`);return n||=t(`[name="${e.name}"]`),n!==e}function Gu(e){return!(e.disabled||e.tagName===`INPUT`&&e.type===`hidden`||Wu(e))}function Ku(e){let t=[],n=[];return Array.from(e.querySelectorAll(Hu)).forEach((e,r)=>{let i=Uu(e);i===-1||!Gu(e)||(i===0?t.push(e):n.push({documentOrder:r,tabIndex:i,node:e}))}),n.sort((e,t)=>e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex).map(e=>e.node).concat(t)}function qu(){return!0}function Ju(e){let{children:t,disableAutoFocus:n=!1,disableEnforceFocus:r=!1,disableRestoreFocus:i=!1,getTabbable:a=Ku,isEnabled:o=qu,open:s}=e,c=v.useRef(!1),l=v.useRef(null),u=v.useRef(null),d=v.useRef(null),f=v.useRef(null),p=v.useRef(!1),m=v.useRef(null),h=ss(Lu(t),m),g=v.useRef(null);v.useEffect(()=>{!s||!m.current||(p.current=!n)},[n,s]),v.useEffect(()=>{if(c.current=!1,!s||!m.current)return;let e=ws(ls(m.current)),t=Vu(m.current)??m.current;return zu(m.current,e)||(t.hasAttribute(`tabIndex`)||t.setAttribute(`tabIndex`,`-1`),p.current&&t.focus()),()=>{!i&&d.current&&(c.current=!0,d.current.focus(),d.current=null)}},[s]),v.useEffect(()=>{if(!s||!m.current)return;let e=ls(m.current),t=t=>{if(g.current=t,r||!o()||t.key!==`Tab`)return;let n=m.current,i=ws(e);if(n===null)return;let s=Vu(n);if(i===n||i===s){let e=a(n);if(e.length===0)return;t.preventDefault(),t.shiftKey?e[e.length-1].focus():e[0].focus();return}if(zu(n,i)){let e=a(n),r=e.indexOf(i);if(r===-1||!e.some(e=>Uu(e)>0))return;t.preventDefault();let o=0;o=t.shiftKey?r<=0?e.length-1:r-1:r===e.length-1?0:r+1,e[o].focus()}},n=()=>{let t=m.current;if(t===null)return;let n=ws(e);if(!e.hasFocus()||!o()||c.current){c.current=!1;return}if(zu(t,n)||r&&n!==l.current&&n!==u.current)return;if(n!==f.current)f.current=null;else if(f.current!==null)return;if(!p.current)return;let i=[];if((n===l.current||n===u.current)&&(i=a(m.current)),i.length>0){let e=!!(g.current?.shiftKey&&g.current?.key===`Tab`),t=i[0],n=i[i.length-1];typeof t!=`string`&&typeof n!=`string`&&(e?n.focus():t.focus())}else t.focus()};e.addEventListener(`focusin`,n),e.addEventListener(`keydown`,t,!0);let i=setInterval(()=>{let t=ws(e);t&&t.tagName===`BODY`&&n()},50);return()=>{clearInterval(i),e.removeEventListener(`focusin`,n),e.removeEventListener(`keydown`,t,!0)}},[n,r,i,o,s,a]);let _=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0,f.current=e.target;let n=t.props.onFocus;n&&n(e)},y=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0};return(0,U.jsxs)(v.Fragment,{children:[(0,U.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:l,"data-testid":`sentinelStart`}),v.cloneElement(t,{ref:h,onFocus:_}),(0,U.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:u,"data-testid":`sentinelEnd`})]})}function Yu(e,t){typeof e==`function`?e(t):e&&(e.current=t)}var Xu=l(h(),1);function Zu(e){return typeof e==`function`?e():e}var Qu=v.forwardRef(function(e,t){let{children:n,container:r,disablePortal:i=!1}=e,[a,o]=v.useState(null),s=ss(v.isValidElement(n)?Lu(n):null,t);if(ci(()=>{i||o(Zu(r)||document.body)},[r,i]),ci(()=>{if(a&&!i)return Yu(t,a),()=>{Yu(t,null)}},[t,a,i]),i){if(v.isValidElement(n)){let e={ref:s};return v.cloneElement(n,e)}return n}return a&&Xu.createPortal(n,a)});function $u(e){let t=gl(()=>ed(e)).current;return t.next=e,ci(t.effect),t}function ed(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var td=v.createContext(null);function nd(e){if(e==null)return{appear:void 0,enter:void 0,exit:void 0};if(typeof e==`number`)return{appear:e,enter:e,exit:e};let t=e.enter,n=e.exit;return{appear:e.appear===void 0?t:e.appear,enter:t,exit:n}}function rd(e){if(e.autoTimeout!=null)return e.autoTimeout;let t=nd(e.timeout);return e.currentStatus===`entering`?e.isAppearing?t.appear??t.enter??null:t.enter??null:t.exit??null}function id(e){let{in:t=!1,appear:n=!1,enter:r=!0,exit:i=!0,mountOnEnter:a=!1,unmountOnExit:o=!1,timeout:s,addEndListener:c,reduceMotion:l=!1,getAutoTimeout:u,nodeRef:d,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,children:y,...b}=e,x=v.useContext(td),S=x&&!x.isMounting?r:n,[C,w]=v.useState(()=>t?S?`exited`:`entered`:a||o?`unmounted`:`exited`),T=v.useRef(C);T.current=C,t&&C===`unmounted`&&(T.current=`exited`,w(`exited`));let E=v.useRef(t&&S),D=v.useRef(!1),O=v.useRef(null),k=v.useRef(C),A=v.useRef(!1),j=v.useRef(l),M=$u({timeout:s,addEndListener:c,reduceMotion:l,getAutoTimeout:u,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,enter:r,exit:i,mountOnEnter:a,unmountOnExit:o,nodeRef:d,parentGroup:x}),N=v.useCallback(()=>{O.current!==null&&(O.current.cancel(),O.current=null)},[]),P=v.useCallback(e=>{let t=!0,n=()=>{t&&(t=!1,O.current=null,e())};return n.cancel=()=>{t=!1},O.current=n,n},[]),F=v.useCallback((e,t)=>{let n,r=()=>{n!==void 0&&(clearTimeout(n),n=void 0)},i=P(()=>{r(),T.current=e,w(e)}),a=i.cancel;i.cancel=()=>{r(),a()};let o=M.current.nodeRef.current,s=M.current.addEndListener,c=M.current.getAutoTimeout!==void 0,l=M.current.getAutoTimeout?.(),u=rd({currentStatus:t,isAppearing:A.current,timeout:M.current.timeout,autoTimeout:l}),d=j.current,f=u??(d&&c?0:null),p=e=>{n=setTimeout(i,e)};if(!o){p(0);return}if(s){f!=null&&p(d?0:f),s.length>=2?s(o,i):s(i);return}p(d?0:u??0)},[P,M]),I=v.useCallback(e=>{let t=M.current,n=t.parentGroup?t.parentGroup.isMounting:e;if(A.current=n,!e&&!t.enter){T.current=`entered`,w(`entered`);return}j.current=t.reduceMotion,t.onEnter?.(n),T.current=`entering`,w(`entering`)},[M]),L=v.useCallback(()=>{let e=M.current;if(!e.exit){T.current=`exited`,w(`exited`);return}j.current=e.reduceMotion,e.onExit?.(),T.current=`exiting`,w(`exiting`)},[M]),R=v.useCallback((e,t)=>{if(N(),t===`entering`){let t=M.current;if(t.mountOnEnter||t.unmountOnExit){let e=t.nodeRef.current;e&&Ms(e)}I(e)}else L()},[N,I,L,M]);return ci(()=>(D.current=!0,E.current&&(E.current=!1,R(!0,`entering`)),()=>{D.current=!1,N()}),[N,R]),ci(()=>{if(!D.current)return;let e=T.current;t?e!==`entering`&&e!==`entered`&&R(!1,`entering`):e===`entering`||e===`entered`?R(!1,`exiting`):e===`exited`&&o&&(T.current=`unmounted`,w(`unmounted`))},[t,C,o,R]),ci(()=>{if(C===`unmounted`||k.current===`unmounted`){k.current=C;return}let e=k.current!==C;e&&(k.current=C);let t=M.current;C===`entering`?(e&&t.onEntering?.(A.current),O.current===null&&T.current===C&&F(`entered`,`entering`)):C===`exiting`?(e&&t.onExiting?.(),O.current===null&&T.current===C&&F(`exited`,`exiting`)):C===`entered`&&e?t.onEntered?.(A.current):C===`exited`&&e&&t.onExited?.()},[M,F,C]),C===`unmounted`?null:(0,U.jsx)(td.Provider,{value:null,children:y(C,b)})}var ad={entering:{opacity:1},entered:{opacity:1},exiting:{opacity:0},exited:{opacity:0}},od={opacity:0,visibility:`hidden`},sd=v.forwardRef(function(e,t){let n=Go(),r={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:i,appear:a=!0,children:o,disablePrefersReducedMotion:s=!1,easing:c,in:l,onEnter:u,onEntered:d,onEntering:f,onExit:p,onExited:m,onExiting:h,style:g,timeout:_=r,...y}=e,b=Ll(n.motion.reducedMotion,s),x=v.useRef(null),S=bs(x,Lu(o),t),C=Hs(x,f),w=Hs(x,(e,t)=>{b.shouldReduceMotion||Ms(e);let r=Ws({style:g,timeout:_,easing:c},{mode:`enter`}),i=b.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`opacity`,{duration:i.duration,easing:r.easing,delay:i.delay}),u&&u(e,t)}),T=Hs(x,d),E=Hs(x,h),D=Hs(x,e=>{let t=Ws({style:g,timeout:_,easing:c},{mode:`exit`}),r=b.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`opacity`,{duration:r.duration,easing:t.easing,delay:r.delay}),p&&p(e)}),O=Hs(x,e=>{e.style.transition=``,m&&m(e)});return(0,U.jsx)(id,{appear:a,in:l,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:i?e=>{i(x.current,e)}:void 0,reduceMotion:b.shouldReduceMotion,timeout:_,...y,children:(e,{ownerState:t,...n})=>{let r=Us(e,l,ad,od,g,o.props.style);return v.cloneElement(o,{style:r,ref:S,...n})}})});function cd(e){return Gr(`MuiBackdrop`,e)}Kr(`MuiBackdrop`,[`root`,`invisible`]);var ld=e=>{let{classes:t,invisible:n}=e;return ba({root:[`root`,n&&`invisible`]},cd,t)},ud=K(`div`,{name:`MuiBackdrop`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.invisible&&t.invisible]}})({position:`fixed`,display:`flex`,alignItems:`center`,justifyContent:`center`,right:0,bottom:0,top:0,left:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,WebkitTapHighlightColor:`transparent`,variants:[{props:{invisible:!0},style:{backgroundColor:`transparent`}}]}),dd=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiBackdrop`}),{children:r,className:i,component:a=`div`,invisible:o=!1,open:s,slotProps:c={},slots:l={},transitionDuration:u,...d}=n,f={...n,component:a,invisible:o},p=ld(f),m={component:a,slots:l,slotProps:c},[h,g]=Xc(`root`,{elementType:ud,externalForwardedProps:m,className:W(p.root,i),ownerState:f}),[_,v]=Xc(`transition`,{elementType:sd,externalForwardedProps:m,ownerState:f});return(0,U.jsx)(_,{in:s,timeout:u,...d,...v,children:(0,U.jsx)(h,{...g,ref:t,children:r})})});function fd(...e){return e.reduce((e,t)=>t==null?e:function(...n){e.apply(this,n),t.apply(this,n)},()=>{})}function pd(e){return typeof e==`function`?e():e}function md(e){return e?e.props.hasOwnProperty(`in`):!1}var hd=()=>{},gd=new Iu;function _d(e){let{container:t,disableScrollLock:n=!1,closeAfterTransition:r=!1,onTransitionEnter:i,onTransitionExited:a,children:o,onClose:s,open:c,rootRef:l}=e,u=v.useRef({}),d=v.useRef(null),f=v.useRef(null),p=v.useRef(null),m=ss(p,l),[h,g]=v.useState(!c),_=md(o),y=!0;(e[`aria-hidden`]===`false`||e[`aria-hidden`]===!1)&&(y=!1);let b=()=>ls(d.current),x=()=>(u.current.modalRef=p.current,u.current.mount=d.current,u.current),S=()=>{gd.mount(x(),{disableScrollLock:n}),p.current&&(p.current.scrollTop=0)},C=cs(()=>{let e=pd(t)||b().body;gd.add(x(),e),p.current&&S()}),w=()=>gd.isTopModal(x()),T=cs(e=>{d.current=e,e&&(f.current=e,c&&w()?S():p.current&&Au(p.current,y))}),E=v.useCallback(()=>{gd.remove(x(),y)},[y]);v.useEffect(()=>()=>{E()},[E]),v.useEffect(()=>{c?C():(!_||!r)&&E()},[c,E,_,r,C]);let D=e=>t=>{e.onKeyDown?.(t),!(t.key!==`Escape`||t.which===229||!w())&&(t.stopPropagation(),s&&s(t,`escapeKeyDown`))},O=e=>t=>{e.onClick?.(t),t.target===t.currentTarget&&s&&s(t,`backdropClick`)};return{getRootProps:(t={})=>{let n=qc(e);delete n.onTransitionEnter,delete n.onTransitionExited;let r={...n,...t};return{role:`presentation`,...r,onKeyDown:D(r),ref:m}},getBackdropProps:(e={})=>{let t=e;return{"aria-hidden":!0,...t,onClick:O(t),open:c}},getTransitionProps:()=>({onEnter:fd(()=>{g(!1),i&&i()},o?.props.onEnter??hd),onExited:fd(()=>{g(!0),a&&a(),r&&E()},o?.props.onExited??hd)}),rootRef:m,portalRef:T,portalContainer:!c&&_&&!h?f.current??t:t,isTopModal:w,exited:h,hasTransition:_}}function vd(e){return Gr(`MuiModal`,e)}Kr(`MuiModal`,[`root`,`hidden`,`backdrop`]);var yd=e=>{let{open:t,exited:n,classes:r}=e;return ba({root:[`root`,!t&&n&&`hidden`],backdrop:[`backdrop`]},vd,r)},bd=K(`div`,{name:`MuiModal`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.open&&n.exited&&t.hidden]}})(ys(({theme:e})=>({position:`fixed`,zIndex:(e.vars||e).zIndex.modal,right:0,bottom:0,top:0,left:0,variants:[{props:({ownerState:e})=>!e.open&&e.exited,style:{visibility:`hidden`}}]}))),xd=K(dd,{name:`MuiModal`,slot:`Backdrop`})({zIndex:-1}),Sd=v.forwardRef(function(e,t){let n=Xo({name:`MuiModal`,props:e}),{classes:r,className:i,closeAfterTransition:a=!1,children:o,container:s,component:c,disableAutoFocus:l=!1,disableEnforceFocus:u=!1,disablePortal:d=!1,disableRestoreFocus:f=!1,disableScrollLock:p=!1,hideBackdrop:m=!1,keepMounted:h=!1,onClose:g,onTransitionEnter:_,onTransitionExited:y,open:b,slotProps:x={},slots:S={},theme:C,...w}=n,T={...n,closeAfterTransition:a,disableAutoFocus:l,disableEnforceFocus:u,disablePortal:d,disableRestoreFocus:f,disableScrollLock:p,hideBackdrop:m,keepMounted:h},{getRootProps:E,getBackdropProps:D,getTransitionProps:O,portalRef:k,portalContainer:A,isTopModal:j,exited:M,hasTransition:N}=_d({...T,rootRef:t}),P={...T,exited:M},F=yd(P),I={};if(o.props.tabIndex===void 0&&(I.tabIndex=`-1`),N){let{onEnter:e,onExited:t}=O();I.onEnter=e,I.onExited=t}let L={slots:S,slotProps:x},[R,ee]=Xc(`root`,{ref:t,elementType:bd,externalForwardedProps:{...L,...w,component:c},getSlotProps:E,ownerState:P,className:W(i,F?.root,!P.open&&P.exited&&F?.hidden)}),[te,z]=Xc(`backdrop`,{elementType:xd,externalForwardedProps:L,shouldForwardComponentProp:!0,getSlotProps:e=>D({...e,onClick:t=>{e?.onClick&&e.onClick(t)}}),className:F?.backdrop,ownerState:P});return!h&&!b&&(!N||M)?null:(0,U.jsx)(Qu,{ref:k,container:A,disablePortal:d,children:(0,U.jsxs)(R,{...ee,children:[m?null:(0,U.jsx)(te,{...z}),(0,U.jsx)(Ju,{disableEnforceFocus:u,disableAutoFocus:l,disableRestoreFocus:f,isEnabled:j,open:b,children:v.cloneElement(o,I)})]})})}),Cd=os,wd=xa,Td=us,Ed=Ki;function Dd(e){let{controlled:t,default:n,name:r,state:i=`value`}=e,{current:a}=v.useRef(t!==void 0),[o,s]=v.useState(n);return[a?t:o,v.useCallback(e=>{a||s(e)},[])]}var Od=Dd;function kd(e,t){if(!e)return t;function n(e,t){let n={};return Object.keys(t).forEach(r=>{Kc(r,t[r])&&typeof e[r]==`function`&&(n[r]=(...n)=>{e[r](...n),t[r](...n)})}),n}if(typeof e==`function`||typeof t==`function`)return r=>{let i=typeof t==`function`?t(r):t,a=typeof e==`function`?e({...r,...i}):e,o=W(r?.className,i?.className,a?.className),s=n(a,i);return{...i,...a,...s,...!!o&&{className:o},...i?.style&&a?.style&&{style:{...i.style,...a.style}},...i?.sx&&a?.sx&&{sx:[...Array.isArray(i.sx)?i.sx:[i.sx],...Array.isArray(a.sx)?a.sx:[a.sx]]}}};let r=t,i=n(e,r),a=W(r?.className,e?.className);return{...t,...e,...i,...!!a&&{className:a},...r?.style&&e?.style&&{style:{...r.style,...e.style}},...r?.sx&&e?.sx&&{sx:[...Array.isArray(r.sx)?r.sx:[r.sx],...Array.isArray(e.sx)?e.sx:[e.sx]]}}}var Ad={visibility:`hidden`},jd={};function Md(e){return typeof e==`string`&&/^translate\(.+,\s*.+\)$/.test(e)}function Nd(e,t,n,r=jd){let{resetInlineTransform:i=!0}=r,a=n&&n.getBoundingClientRect(),o=Td(t),s,c;if(i){let e=t.style.transform,n=t.style.transition;t.style.transition=``,t.style.transform=``,s=t.getBoundingClientRect(),c=o.getComputedStyle(t).getPropertyValue(`transform`),t.style.transform=e,t.style.transition=n}else s=t.getBoundingClientRect(),c=o.getComputedStyle(t).getPropertyValue(`transform`);let{offsetX:l,offsetY:u}=Vs(c);return e===`left`?a?`translateX(${a.right+l-s.left}px)`:`translateX(${o.innerWidth+l-s.left}px)`:e===`right`?a?`translateX(-${s.right-a.left-l}px)`:`translateX(-${s.left+s.width-l}px)`:e===`up`?a?`translateY(${a.bottom+u-s.top}px)`:`translateY(${o.innerHeight+u-s.top}px)`:a?`translateY(-${s.top-a.top+s.height-u}px)`:`translateY(-${s.top+s.height-u}px)`}function Pd(e){return typeof e==`function`?e():e}function Fd(e,t,n,r){let i=Nd(e,t,Pd(n),r);i&&(t.style.transform=i)}var Id=v.forwardRef(function(e,t){let n=Go(),r={enter:n.transitions.easing.easeOut,exit:n.transitions.easing.sharp},i={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:a,appear:o=!0,children:s,container:c,disablePrefersReducedMotion:l=!1,direction:u=`down`,easing:d=r,in:f,onEnter:p,onEntered:m,onEntering:h,onExit:g,onExited:_,onExiting:y,style:b,timeout:x=i,...S}=e,C=Ll(n.motion.reducedMotion,l),w=v.useRef(null),T=v.useRef(!1),E=bs(Lu(s),w,t),D=Hs(w,(e,t)=>{Fd(u,e,c),C.shouldReduceMotion||Ms(e),p&&p(e,t)}),O=Hs(w,(e,t)=>{let r=Ws({timeout:x,style:b,easing:d},{mode:`enter`}),i=C.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`transform`,{duration:i.duration,easing:r.easing,delay:i.delay}),e.style.transform=`none`,h&&h(e,t)}),k=Hs(w,m),A=Hs(w,y),j=Hs(w,e=>{let t=Ws({timeout:x,style:b,easing:d},{mode:`exit`}),r=C.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`transform`,{duration:r.duration,easing:t.easing,delay:r.delay});let i=Md(e.style.transform);T.current=i,Fd(u,e,c,{resetInlineTransform:!i}),g&&g(e)}),M=Hs(w,e=>{T.current=!1,e.style.transition=``,_&&_(e)}),N=a?e=>{a(w.current,e)}:void 0,P=v.useCallback(()=>{w.current&&Fd(u,w.current,c)},[u,c]);return v.useEffect(()=>{if(f||u===`down`||u===`right`)return;let e=Cd(()=>{w.current&&Fd(u,w.current,c)}),t=Td(w.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[u,f,c]),v.useEffect(()=>{!f&&!T.current&&P()},[f,P]),(0,U.jsx)(id,{nodeRef:w,onEnter:D,onEntered:k,onEntering:O,onExit:j,onExited:M,onExiting:A,addEndListener:N,appear:o,in:f,reduceMotion:C.shouldReduceMotion,timeout:x,...S,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!f?b||s.props.style?{visibility:`hidden`,...b,...s.props.style}:Ad:b&&s.props.style?{...b,...s.props.style}:b||s.props.style,v.cloneElement(s,{ref:E,style:r,...n})}})});function Ld(e){return Gr(`MuiDrawer`,e)}Kr(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`modal`]);var Rd=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},zd=e=>{let{classes:t,anchor:n,variant:r}=e;return ba({root:[`root`,`anchor${q(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`]},Ld,t)},Bd=K(Sd,{name:`MuiDrawer`,slot:`Root`,overridesResolver:Rd})(ys(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),Vd=K(`div`,{shouldForwardProp:Jo,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:Rd})({flex:`0 0 auto`}),Hd=K(Pc,{name:`MuiDrawer`,slot:`Paper`})(ys(({theme:e})=>({overflowY:`auto`,display:`flex`,flexDirection:`column`,height:`100%`,flex:`1 0 auto`,zIndex:(e.vars||e).zIndex.drawer,WebkitOverflowScrolling:`touch`,position:`fixed`,top:0,outline:0,variants:[{props:{anchor:`left`},style:{left:0}},{props:{anchor:`top`},style:{top:0,left:0,right:0,height:`auto`,maxHeight:`100%`}},{props:{anchor:`right`},style:{right:0}},{props:{anchor:`bottom`},style:{top:`auto`,left:0,bottom:0,right:0,height:`auto`,maxHeight:`100%`}},{props:({ownerState:e})=>e.anchor===`left`&&e.variant!==`temporary`,style:{borderRight:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`top`&&e.variant!==`temporary`,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`right`&&e.variant!==`temporary`,style:{borderLeft:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`bottom`&&e.variant!==`temporary`,style:{borderTop:`1px solid ${(e.vars||e).palette.divider}`}}]}))),Ud={left:`right`,right:`left`,top:`down`,bottom:`up`};function Wd(e){return[`left`,`right`].includes(e)}function Gd({direction:e},t){return e===`rtl`&&Wd(t)?Ud[t]:t}var Kd=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDrawer`}),r=Go(),i=Ri(),a={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{anchor:o=`left`,children:s,className:c,elevation:l=16,hideBackdrop:u=!1,ModalProps:d={},onClose:f,open:p=!1,transitionDuration:m=a,variant:h=`temporary`,slots:g={},slotProps:_={},...y}=n,b=v.useRef(!1),x=v.useRef(null),S=bs(t,x);v.useEffect(()=>{b.current=!0},[]);let C=v.useCallback(()=>x.current,[]),w=Gd({direction:i?`rtl`:`ltr`},o),T=o,E={...n,anchor:T,elevation:l,open:p,variant:h,...y},D=zd(E),O={slots:g,slotProps:{..._,backdrop:kd(_.backdrop,{transitionDuration:m})}},[k,A]=Xc(`root`,{ref:S,elementType:Bd,className:W(D.root,D.modal,c),shouldForwardComponentProp:!0,ownerState:E,externalForwardedProps:{...O,...y,...d},additionalProps:{closeAfterTransition:!0,open:p,onClose:f,hideBackdrop:u,slots:{backdrop:O.slots.backdrop},slotProps:{backdrop:O.slotProps.backdrop}}}),[j,M]=Xc(`paper`,{elementType:Hd,shouldForwardComponentProp:!0,className:D.paper,ownerState:E,externalForwardedProps:O,additionalProps:{elevation:h===`temporary`?l:0,square:!0,...h===`temporary`&&{role:`dialog`,"aria-modal":`true`,"data-mui-focusable":``,tabIndex:-1}}}),[N,P]=Xc(`docked`,{elementType:Vd,ref:S,className:W(D.root,D.docked,c),ownerState:E,externalForwardedProps:O,additionalProps:y}),[F,I]=Xc(`transition`,{elementType:Id,ownerState:E,externalForwardedProps:O,additionalProps:{in:p,direction:Ud[w],timeout:m,appear:b.current,...h===`temporary`&&(g.transition==null||g.transition===Id)&&{container:C}}}),L=(0,U.jsx)(j,{...M,children:s});if(h===`permanent`)return(0,U.jsx)(N,{...P,children:L});let R=(0,U.jsx)(F,{...I,children:L});return h===`persistent`?(0,U.jsx)(N,{...P,children:R}):(0,U.jsx)(k,{...A,children:R})});function qd(e){return Gr(`MuiIconButton`,e)}var Jd=Kr(`MuiIconButton`,[`root`,`disabled`,`colorInherit`,`colorPrimary`,`colorSecondary`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`,`edgeStart`,`edgeEnd`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`loading`,`loadingIndicator`,`loadingWrapper`]),Yd=e=>{let{classes:t,disabled:n,color:r,edge:i,size:a,loading:o}=e;return ba({root:[`root`,o&&`loading`,n&&`disabled`,r!=="default"&&`color${q(r)}`,i&&`edge${q(i)}`,`size${q(a)}`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},qd,t)},Xd=K(tu,{name:`MuiIconButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.loading&&t.loading,n.color!=="default"&&t[`color${q(n.color)}`],n.edge&&t[`edge${q(n.edge)}`],t[`size${q(n.size)}`]]}})(ys(({theme:e})=>({textAlign:`center`,flex:`0 0 auto`,fontSize:e.typography.pxToRem(24),padding:8,borderRadius:`50%`,color:(e.vars||e).palette.action.active,...Ks(e,`background-color`,{duration:e.transitions.duration.shortest}),variants:[{props:e=>!e.disableRipple,style:{"--IconButton-hoverBg":e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity),"&:hover":{backgroundColor:`var(--IconButton-hoverBg)`,"@media (hover: none)":{backgroundColor:`transparent`}}}},{props:{edge:`start`},style:{marginLeft:-12}},{props:{edge:`start`,size:`small`},style:{marginLeft:-3}},{props:{edge:`end`},style:{marginRight:-12}},{props:{edge:`end`,size:`small`},style:{marginRight:-3}}]})),ys(({theme:e})=>({variants:[{props:{color:`inherit`},style:{color:`inherit`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main,"--IconButton-hoverBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}})),{props:{size:`small`},style:{padding:5,fontSize:e.typography.pxToRem(18)}},{props:{size:`large`},style:{padding:12,fontSize:e.typography.pxToRem(28)}}],[`&.${Jd.disabled}`]:{backgroundColor:`transparent`,color:(e.vars||e).palette.action.disabled},[`&.${Jd.loading}`]:{color:`transparent`}}))),Zd=K(`span`,{name:`MuiIconButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,color:(e.vars||e).palette.action.disabled,variants:[{props:{loading:!0},style:{display:`flex`}}]})),Qd=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiIconButton`}),{edge:r=!1,children:i,className:a,color:o=`default`,disabled:s=!1,disableFocusRipple:c=!1,size:l=`medium`,id:u,loading:d=null,loadingIndicator:f,...p}=n,m=Ed(u),h=f??(0,U.jsx)(xu,{"aria-labelledby":m,color:`inherit`,size:16}),g={...n,edge:r,color:o,disabled:s,disableFocusRipple:c,loading:d,loadingIndicator:h,size:l},_=Yd(g);return(0,U.jsxs)(Xd,{id:d?m:u,className:W(_.root,a),centerRipple:!0,internalNativeButton:!0,focusRipple:!c,disabled:s||d,ref:t,...p,ownerState:g,children:[typeof d==`boolean`&&(0,U.jsx)(`span`,{className:_.loadingWrapper,style:{display:`contents`},children:(0,U.jsx)(Zd,{className:_.loadingIndicator,ownerState:g,children:d&&h})}),i]})}),$d=v.createContext({});function ef(e){return Gr(`MuiList`,e)}Kr(`MuiList`,[`root`,`padding`,`dense`,`subheader`]);var tf=e=>{let{classes:t,disablePadding:n,dense:r,subheader:i}=e;return ba({root:[`root`,!n&&`padding`,r&&`dense`,i&&`subheader`]},ef,t)},nf=K(`ul`,{name:`MuiList`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disablePadding&&t.padding,n.dense&&t.dense,n.subheader&&t.subheader]}})({listStyle:`none`,margin:0,padding:0,position:`relative`,variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>e.subheader,style:{paddingTop:0,isolation:`isolate`}}]}),rf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiList`}),{children:r,className:i,component:a=`ul`,dense:o=!1,disablePadding:s=!1,subheader:c,...l}=n,u=v.useMemo(()=>({dense:o}),[o]),d={...n,component:a,dense:o,disablePadding:s},f=tf(d);return(0,U.jsx)($d.Provider,{value:u,children:(0,U.jsxs)(nf,{as:a,className:W(f.root,i),ref:t,ownerState:d,...l,children:[c,r]})})}),af=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.alignItems===`flex-start`&&t.alignItemsFlexStart,n.divider&&t.divider,!n.disableGutters&&t.gutters]},of=e=>{let{alignItems:t,classes:n,dense:r,disabled:i,disableGutters:a,divider:o,selected:s}=e,c=ba({root:[`root`,r&&`dense`,!a&&`gutters`,o&&`divider`,i&&`disabled`,t===`flex-start`&&`alignItemsFlexStart`,s&&`selected`]},dc,n);return{...n,...c}},sf=K(tu,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiListItemButton`,slot:`Root`,overridesResolver:af})(ys(({theme:e})=>({display:`flex`,flexGrow:1,justifyContent:`flex-start`,alignItems:`center`,position:`relative`,textDecoration:`none`,minWidth:0,boxSizing:`border-box`,textAlign:`left`,paddingTop:8,paddingBottom:8,...Ks(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${fc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${fc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${fc.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${fc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${fc.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},variants:[{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:`padding-box`}},{props:{alignItems:`flex-start`},style:{alignItems:`flex-start`}},{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.dense,style:{paddingTop:4,paddingBottom:4}}]}))),cf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemButton`}),{alignItems:r=`center`,autoFocus:i=!1,component:a=`div`,children:o,dense:s=!1,disableGutters:c=!1,divider:l=!1,focusVisibleClassName:u,selected:d=!1,className:f,...p}=n,m=v.useContext($d),h=v.useMemo(()=>({dense:s||m.dense||!1,alignItems:r,disableGutters:c}),[r,m.dense,s,c]),g=v.useRef(null);xs(()=>{i&&g.current&&g.current.focus()},[i]);let _={...n,alignItems:r,dense:h.dense,disableGutters:c,divider:l,selected:d},y=of(_),{root:b,...x}=y,S=bs(g,t);return(0,U.jsx)($d.Provider,{value:h,children:(0,U.jsx)(sf,{ref:S,href:p.href||p.to,component:(p.href||p.to)&&a===`div`?`button`:a,internalNativeButton:!1,focusVisibleClassName:W(y.focusVisible,u),ownerState:_,className:W(y.root,f),...p,classes:x,children:o})})});function lf(e){return Gr(`MuiListItemIcon`,e)}var uf=Kr(`MuiListItemIcon`,[`root`,`alignItemsFlexStart`]),df=e=>{let{alignItems:t,classes:n}=e;return ba({root:[`root`,t===`flex-start`&&`alignItemsFlexStart`]},lf,n)},ff=K(`div`,{name:`MuiListItemIcon`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.alignItems===`flex-start`&&t.alignItemsFlexStart]}})(ys(({theme:e})=>({minWidth:e.spacing(4.5),color:(e.vars||e).palette.action.active,flexShrink:0,display:`inline-flex`,variants:[{props:{alignItems:`flex-start`},style:{marginTop:8}}]}))),pf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemIcon`}),{className:r,...i}=n,a=v.useContext($d),o={...n,alignItems:a.alignItems},s=df(o);return(0,U.jsx)(ff,{className:W(s.root,r),ownerState:o,ref:t,...i})});function mf(e){return Gr(`MuiTypography`,e)}var hf=Kr(`MuiTypography`,[`root`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`subtitle1`,`subtitle2`,`body1`,`body2`,`inherit`,`button`,`caption`,`overline`,`alignLeft`,`alignRight`,`alignCenter`,`alignJustify`,`noWrap`,`gutterBottom`]),gf=e=>{let{align:t,gutterBottom:n,noWrap:r,variant:i,classes:a}=e;return ba({root:[`root`,i,e.align!==`inherit`&&`align${q(t)}`,n&&`gutterBottom`,r&&`noWrap`]},mf,a)},_f=K(`span`,{name:`MuiTypography`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!==`inherit`&&t[`align${q(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom]}})(ys(({theme:e})=>({margin:0,variants:[{props:{variant:`inherit`},style:{font:`inherit`,lineHeight:`inherit`,letterSpacing:`inherit`}},...Object.entries(e.typography).filter(([e,t])=>e!==`inherit`&&t&&typeof t==`object`).map(([e,t])=>({props:{variant:e},style:t})),...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}})),...Object.entries(e.palette?.text||{}).filter(([,e])=>typeof e==`string`).map(([t])=>({props:{color:`text${q(t)}`},style:{color:(e.vars||e).palette.text[t]}})),{props:({ownerState:e})=>e.align!==`inherit`,style:{textAlign:`var(--Typography-textAlign)`}},{props:({ownerState:e})=>e.noWrap,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},{props:({ownerState:e})=>e.gutterBottom,style:{marginBottom:`0.35em`}}]}))),vf={h1:`h1`,h2:`h2`,h3:`h3`,h4:`h4`,h5:`h5`,h6:`h6`,subtitle1:`h6`,subtitle2:`h6`,body1:`p`,body2:`p`,inherit:`p`},X=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTypography`}),{color:r,align:i=`inherit`,className:a,component:o,gutterBottom:s=!1,noWrap:c=!1,variant:l=`body1`,variantMapping:u=vf,...d}=n,f={...n,align:i,color:r,className:a,component:o,gutterBottom:s,noWrap:c,variant:l,variantMapping:u},p=o||u[l]||vf[l]||`span`,m=gf(f);return(0,U.jsx)(_f,{as:p,ref:t,className:W(m.root,a),...d,ownerState:f,style:{...i!==`inherit`&&{"--Typography-textAlign":i},...d.style}})});function yf(e){return Gr(`MuiListItemText`,e)}var bf=Kr(`MuiListItemText`,[`root`,`multiline`,`dense`,`inset`,`primary`,`secondary`]),xf=e=>{let{classes:t,inset:n,primary:r,secondary:i,dense:a}=e;return ba({root:[`root`,n&&`inset`,a&&`dense`,r&&i&&`multiline`],primary:[`primary`],secondary:[`secondary`]},yf,t)},Sf=K(`div`,{name:`MuiListItemText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${bf.primary}`]:t.primary},{[`& .${bf.secondary}`]:t.secondary},t.root,n.inset&&t.inset,n.primary&&n.secondary&&t.multiline,n.dense&&t.dense]}})({flex:`1 1 auto`,minWidth:0,marginTop:4,marginBottom:4,[`.${hf.root}:where(& .${bf.primary})`]:{display:`block`},[`.${hf.root}:where(& .${bf.secondary})`]:{display:`block`},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),Cf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemText`}),{children:r,className:i,disableTypography:a=!1,inset:o=!1,primary:s,secondary:c,slots:l={},slotProps:u={},...d}=n,{dense:f}=v.useContext($d),p=s??r,m=c,h={...n,disableTypography:a,inset:o,primary:!!p,secondary:!!m,dense:f},g=xf(h),_={slots:l,slotProps:u},[y,b]=Xc(`root`,{className:W(g.root,i),elementType:Sf,externalForwardedProps:{..._,...d},ownerState:h,ref:t}),[x,S]=Xc(`primary`,{className:g.primary,elementType:X,externalForwardedProps:_,ownerState:h}),[C,w]=Xc(`secondary`,{className:g.secondary,elementType:X,externalForwardedProps:_,ownerState:h});return p!=null&&p.type!==X&&!a&&(p=(0,U.jsx)(x,{variant:f?`body2`:`body1`,component:S?.variant?void 0:`span`,...S,children:p})),m!=null&&m.type!==X&&!a&&(m=(0,U.jsx)(C,{variant:`body2`,color:`textSecondary`,...w,children:m})),(0,U.jsxs)(y,{...b,children:[p,m]})}),Z=Oa({createStyledComponent:K(`div`,{name:`MuiStack`,slot:`Root`}),useThemeProps:e=>Xo({props:e,name:`MuiStack`})}),wf=v.createContext({}),Tf=v.createContext(void 0);function Ef(e,t){return t===void 0||e===void 0?!1:Array.isArray(t)?t.includes(e):e===t}var Df=v.createContext(void 0);function Of(){let e=v.useContext(Df);if(e===void 0)throw Error(`MUI: RovingTabIndexContext is missing. Roving tab index items must be placed within a roving tab index provider.`);return e}var kf=Object.is;function Af(e,t){if(e===t)return!0;if(!(e instanceof Object)||!(t instanceof Object))return!1;let n=0,r=0;for(let r in e)if(n+=1,!kf(e[r],t[r])||!(r in t))return!1;for(let e in t)r+=1;return n===r}var jf=[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function Mf(e){let{activeItemId:t,getDefaultActiveItemId:n,orientation:r,isRtl:i=!1,isItemFocusable:a=Kf,wrap:o=!0}=e,[s,c]=v.useState(t),[l,u]=v.useState(t),d=s;t!==l&&(u(t),t!==void 0&&t!==s&&(d=t,c(t)));let f=v.useRef(null),p=v.useRef(new Map),[m,h]=v.useState(0),g=v.useMemo(()=>Uf(p.current),[m]),_=Pf(d,g,a,n),y=v.useRef(_);y.current=_;let b=v.useCallback(()=>{let e=Uf(p.current);return Bf(e,Pf(y.current,e,a,n))},[n,a]),x=v.useCallback(()=>p.current,[]),S=cs(e=>{Af(p.current.get(e.id)??null,e)||(p.current.set(e.id,e),h(e=>e+1))}),C=cs(e=>{p.current.delete(e)&&h(e=>e+1)}),w=cs(e=>{c(e)}),T=v.useCallback(e=>y.current===e,[]),E=v.useCallback((e,t,n,r)=>{let i=Rf(Wf(p.current),e,t,n,r??a);return i?(i.element?.focus(),c(i.id),i):null},[a]),D=v.useCallback((e,t,n)=>({onFocus:e=>{t?.(e);let n=Wf(p.current),r=Hf(n,e.target);r!==-1&&c(n[r].id)},onKeyDown:e=>{if(n?.(e),e.defaultPrevented||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||!jf.includes(e.key))return;let t=r===`horizontal`?`ArrowLeft`:`ArrowUp`,a=r===`horizontal`?`ArrowRight`:`ArrowDown`;r===`horizontal`&&i&&(t=`ArrowRight`,a=`ArrowLeft`);let s=Wf(p.current),c=Cs(ls(f.current)),l=c===f.current,u=Lf(s,c,y.current),d=`next`;switch(e.key){case t:d=`previous`,e.preventDefault(),l&&(u=s.length);break;case a:e.preventDefault(),l&&(u=-1);break;case`Home`:e.preventDefault(),u=-1;break;case`End`:e.preventDefault(),d=`previous`,u=s.length;break;default:return}E(u,d,o)},ref:Yf(e,e=>{f.current=e})}),[E,i,r,o]),O=v.useCallback(e=>{let t=Wf(p.current),n=Cs(ls(f.current)),r=n===f.current?-1:Lf(t,n,y.current);return E(r,`next`,!0,e)?.id??null},[E]);return v.useMemo(()=>({activeItemId:_,focusNext:O,getActiveItem:b,getContainerProps:D,getItemMap:x,isItemActive:T,registerItem:S,setActiveItemId:w,unregisterItem:C}),[_,O,b,D,x,T,S,w,C])}function Nf(e){let{activeItemId:t,registerItem:n,unregisterItem:r}=Of(),i=v.useRef(null),a=v.useMemo(()=>({disabled:e.disabled??!1,element:null,focusableWhenDisabled:e.focusableWhenDisabled??!1,id:e.id,selected:e.selected??!1,textValue:e.textValue}),[e.disabled,e.focusableWhenDisabled,e.id,e.selected,e.textValue]),o=v.useRef(a);o.current=a;let s=v.useCallback(t=>{if(i.current=t,t==null){queueMicrotask(()=>{i.current??r(e.id)});return}n({...o.current,element:t})},[e.id,n,r]),c=ss(e.ref,s);return ci(()=>{i.current&&n({...a,element:i.current})},[a,n]),ci(()=>{let t=e.id;return()=>{r(t)}},[e.id,r]),{ref:c,tabIndex:t===e.id?0:-1}}function Pf(e,t,n,r){return e==null?If(t,n,r):Ff(e,t,n)}function Ff(e,t,n){let r=Vf(t,e);return r===-1?zf(t,n):n(t[r])?t[r].id:Rf(t,r,`next`,!1,n)?.id??null}function If(e,t,n){let r=n?.(e);if(r!=null){let n=Bf(e,r);if(n&&t(n))return n.id}return zf(e,t)}function Lf(e,t,n){if(t){let n=Hf(e,t);if(n!==-1)return n}return Vf(e,n)}function Rf(e,t,n,r,i){let a=e.length-1;if(a===-1)return null;let o=!1,s=Gf(t,a,n,r),c=s;for(;s!==-1;){if(s===c){if(o)return null;o=!0}let t=e[s];if(!t||!i(t))s=Gf(s,a,n,r);else return t}return null}function zf(e,t){return e.find(e=>t(e))?.id??null}function Bf(e,t){return t==null?null:e.find(e=>e.id===t)??null}function Vf(e,t){return t==null?-1:e.findIndex(e=>e.id===t)}function Hf(e,t){return t?e.findIndex(e=>e.element===t||e.element?.contains(t)):-1}function Uf(e){let t=Array.from(e.values());if(t.every(e=>e.element==null))return t;let n=t.filter(qf).sort((e,t)=>Jf(e.element,t.element)),r=t.filter(e=>!qf(e));return[...n,...r]}function Wf(e){return Uf(e).filter(qf)}function Gf(e,t,n,r=!0){return n===`next`?e===t?r?0:-1:e+1:e===0?r?t:-1:e-1}function Kf(e){return e.element?e.focusableWhenDisabled?!0:!e.disabled&&!e.element.hasAttribute(`disabled`)&&e.element.getAttribute(`aria-disabled`)!==`true`&&e.element.hasAttribute(`tabindex`):!1}function qf(e){return e.element!=null&&e.element.isConnected}function Jf(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function Yf(...e){return t=>{e.forEach(e=>{Yu(e??null,t)})}}function Xf(e,t){let{children:n,disabled:r=!1,selected:i=!1,value:a}=e,o=Of(),s=Nf({id:a,ref:t,disabled:r,selected:i}),c=o.getItemMap().size===0&&i?0:s.tabIndex;return v.cloneElement(v.Children.only(n),{...s,tabIndex:n.props.tabIndex??c})}var Zf=v.forwardRef(Xf),Qf=e=>{let{classes:t,fullWidth:n,selected:r,disabled:i,size:a,color:o}=e;return ba({root:[`root`,r&&`selected`,i&&`disabled`,n&&`fullWidth`,`size${q(a)}`,o]},yc,t)},$f=K(tu,{name:`MuiToggleButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`size${q(n.size)}`]]}})(ys(({theme:e})=>({...e.typography.button,borderRadius:(e.vars||e).shape.borderRadius,padding:11,border:`1px solid ${(e.vars||e).palette.divider}`,color:(e.vars||e).palette.action.active,[`&.${bc.disabled}`]:{color:(e.vars||e).palette.action.disabled,border:`1px solid ${(e.vars||e).palette.action.disabledBackground}`},"&:hover":{textDecoration:`none`,backgroundColor:e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:`transparent`}},variants:[{props:{color:`standard`},style:{[`&.${bc.selected}`]:{color:(e.vars||e).palette.text.primary,backgroundColor:e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.selectedOpacity),"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.text.primary,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.selectedOpacity)}}}}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{[`&.${bc.selected}`]:{color:(e.vars||e).palette[t].main,backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity),"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity)}}}}})),{props:{fullWidth:!0},style:{width:`100%`}},{props:{size:`small`},style:{padding:7,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`},style:{padding:15,fontSize:e.typography.pxToRem(15)}}]}))),ep=v.forwardRef(function(e,t){let{value:n,isRovingTabIndex:r,...i}=v.useContext(wf),a=v.useContext(Tf),o=Xo({props:ai({...i,selected:Ef(e.value,n)},e),name:`MuiToggleButton`}),{children:s,className:c,color:l=`standard`,disabled:u=!1,disableFocusRipple:d=!1,fullWidth:f=!1,onChange:p,onClick:m,selected:h,size:g=`medium`,value:_,...y}=o,b={...o,color:l,disabled:u,disableFocusRipple:d,fullWidth:f,size:g},x=Qf(b),S=e=>{m&&(m(e,_),e.defaultPrevented)||p&&p(e,_)},C=a||``,w=(0,U.jsx)($f,{className:W(i.className,x.root,c,C),internalNativeButton:!0,disabled:u,focusRipple:!d,ref:r?void 0:t,onClick:S,onChange:p,value:_,ownerState:b,"aria-pressed":h,...y,children:s});return r?(0,U.jsx)(Zf,{disabled:u,selected:h,ref:t,value:_,children:w}):w});function tp(e){return v.Children.toArray(e).filter(e=>v.isValidElement(e))}function np(e){return Gr(`MuiToggleButtonGroup`,e)}var rp=Kr(`MuiToggleButtonGroup`,[`root`,`selected`,`horizontal`,`vertical`,`disabled`,`grouped`,`fullWidth`,`firstButton`,`lastButton`,`middleButton`]),ip=e=>{let{classes:t,orientation:n,fullWidth:r,disabled:i}=e;return ba({root:[`root`,n,r&&`fullWidth`],grouped:[`grouped`,i&&`disabled`],firstButton:[`firstButton`],lastButton:[`lastButton`],middleButton:[`middleButton`]},np,t)},ap=K(`div`,{name:`MuiToggleButtonGroup`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${rp.grouped}`]:t.grouped},{[`& .${rp.firstButton}`]:t.firstButton},{[`& .${rp.lastButton}`]:t.lastButton},{[`& .${rp.middleButton}`]:t.middleButton},t.root,n.orientation===`vertical`&&t.vertical,n.fullWidth&&t.fullWidth]}})(ys(({theme:e})=>({display:`inline-flex`,borderRadius:(e.vars||e).shape.borderRadius,variants:[{props:{orientation:`vertical`},style:{flexDirection:`column`,[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderTop:0,marginTop:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginTop:-1,borderTop:`1px solid transparent`,borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${rp.lastButton}.${bc.disabled},& .${rp.middleButton}.${bc.disabled}`]:{borderTop:`1px solid transparent`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{orientation:`horizontal`},style:{[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginLeft:-1,borderLeft:`1px solid transparent`,borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${rp.lastButton}.${bc.disabled},& .${rp.middleButton}.${bc.disabled}`]:{borderLeft:`1px solid transparent`}}}]}))),op=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiToggleButtonGroup`}),{children:r,className:i,color:a=`standard`,disabled:o=!1,exclusive:s=!1,fullWidth:c=!1,onChange:l,orientation:u=`horizontal`,size:d=`medium`,value:f,...p}=n,m={...n,disabled:o,fullWidth:c,orientation:u,size:d},h=ip(m),g=Ri(),_=v.useCallback((e,t)=>{if(!l)return;let n=f&&f.indexOf(t),r;f&&n>=0?(r=f.slice(),r.splice(n,1)):r=f?f.concat(t):[t],l(e,r)},[l,f]),y=v.useCallback((e,t)=>{l&&l(e,f===t?null:t)},[l,f]),b=v.useMemo(()=>({className:h.grouped,onChange:s?y:_,value:f,size:d,fullWidth:c,color:a,disabled:o,isRovingTabIndex:!0}),[h.grouped,s,y,_,f,d,c,a,o]),x=tp(r),S=x.length,C=e=>{let t=e===0,n=e===S-1;return t&&n?``:t?h.firstButton:n?h.lastButton:h.middleButton},w=Mf({orientation:u,isRtl:g}),T=w.getContainerProps(t,p.onFocus,p.onKeyDown);return(0,U.jsx)(ap,{role:`group`,className:W(h.root,i),ownerState:m,...p,...T,children:(0,U.jsx)(Df.Provider,{value:w,children:(0,U.jsx)(wf.Provider,{value:b,children:x.map((e,t)=>(0,U.jsx)(Tf.Provider,{value:C(t),children:e},t))})})})});function sp(e){return Gr(`MuiToolbar`,e)}Kr(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var cp=e=>{let{classes:t,disableGutters:n,variant:r}=e;return ba({root:[`root`,!n&&`gutters`,r]},sp,t)},lp=K(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(ys(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up(`sm`)]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:`dense`},style:{minHeight:48}},{props:{variant:`regular`},style:e.mixins.toolbar}]}))),up=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiToolbar`}),{className:r,component:i=`div`,disableGutters:a=!1,variant:o=`regular`,...s}=n,c={...n,component:i,disableGutters:a,variant:o},l=cp(c);return(0,U.jsx)(lp,{as:i,className:W(l.root,r),ref:t,ownerState:c,...s})});function dp(e){return`scale(${e}, ${e**2})`}var fp={entering:{opacity:1,transform:dp(1)},entered:{opacity:1,transform:`none`},exiting:{opacity:0,transform:dp(.75)},exited:{opacity:0,transform:dp(.75)}},pp={opacity:0,transform:dp(.75),visibility:`hidden`},mp=v.forwardRef(function(e,t){let{addEndListener:n,appear:r=!0,children:i,disablePrefersReducedMotion:a=!1,easing:o,in:s,onEnter:c,onEntered:l,onEntering:u,onExit:d,onExited:f,onExiting:p,style:m,timeout:h=`auto`,...g}=e,_=v.useRef(null),y=Go(),b=Ll(y.motion.reducedMotion,a),x=v.useRef(null),S=bs(x,Lu(i),t),C=Hs(x,u),w=Hs(x,(e,t)=>{b.shouldReduceMotion||Ms(e);let{duration:n,delay:r,easing:i}=Ws({style:m,timeout:h,easing:o},{mode:`enter`}),a;h===`auto`&&!b.shouldReduceMotion?(a=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=a):(a=n,_.current=null);let s=b.getTransitionTiming({duration:a,delay:r});e.style.transition=[y.transitions.create(`opacity`,{duration:s.duration,delay:s.delay}),y.transitions.create(`transform`,{duration:typeof s.duration==`string`?s.duration:s.duration*.666,delay:s.delay,easing:i})].join(`,`),c&&c(e,t)}),T=Hs(x,l),E=Hs(x,p),D=Hs(x,e=>{let{duration:t,delay:n,easing:r}=Ws({style:m,timeout:h,easing:o},{mode:`exit`}),i;h===`auto`&&!b.shouldReduceMotion?(i=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=i):(i=t,_.current=null);let a=b.getTransitionTiming({duration:i,delay:n});e.style.transition=[y.transitions.create(`opacity`,{duration:a.duration,delay:a.delay}),y.transitions.create(`transform`,{duration:typeof a.duration==`string`?a.duration:a.duration*.666,delay:a.delay||(typeof a.duration==`string`?a.duration:a.duration*.333),easing:r})].join(`,`),e.style.opacity=0,e.style.transform=dp(.75),d&&d(e)}),O=Hs(x,e=>{e.style.transition=``,f&&f(e)});return(0,U.jsx)(id,{appear:r,in:s,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:n?e=>{n(x.current,e)}:void 0,getAutoTimeout:h===`auto`?()=>_.current:void 0,reduceMotion:b.shouldReduceMotion,timeout:h===`auto`?null:h,...g,children:(e,{ownerState:t,...n})=>{let r=Us(e,s,fp,pp,m,i.props.style);return v.cloneElement(i,{style:r,ref:S,...n})}})});mp&&(mp.muiSupportAuto=!0);var hp=`bottom`,gp=`right`,_p=`left`,vp=`auto`,yp=[`top`,hp,gp,_p],bp=`start`,xp=`clippingParents`,Sp=`viewport`,Cp=`popper`,wp=`reference`,Tp=yp.reduce(function(e,t){return e.concat([t+`-`+bp,t+`-end`])},[]),Ep=[].concat(yp,[vp]).reduce(function(e,t){return e.concat([t,t+`-`+bp,t+`-end`])},[]),Dp=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function Op(e){return e?(e.nodeName||``).toLowerCase():null}function kp(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ap(e){return e instanceof kp(e).Element||e instanceof Element}function jp(e){return e instanceof kp(e).HTMLElement||e instanceof HTMLElement}function Mp(e){return typeof ShadowRoot>`u`?!1:e instanceof kp(e).ShadowRoot||e instanceof ShadowRoot}function Np(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];!jp(i)||!Op(i)||(Object.assign(i.style,n),Object.keys(r).forEach(function(e){var t=r[e];t===!1?i.removeAttribute(e):i.setAttribute(e,t===!0?``:t)}))})}function Pp(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],i=t.attributes[e]||{},a=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]=``,e},{});!jp(r)||!Op(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Fp={name:`applyStyles`,enabled:!0,phase:`write`,fn:Np,effect:Pp,requires:[`computeStyles`]};function Ip(e){return e.split(`-`)[0]}var Lp=Math.max,Rp=Math.min,zp=Math.round;function Bp(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+`/`+e.version}).join(` `):navigator.userAgent}function Vp(){return!/^((?!chrome|android).)*safari/i.test(Bp())}function Hp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&jp(e)&&(i=e.offsetWidth>0&&zp(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&zp(r.height)/e.offsetHeight||1);var o=(Ap(e)?kp(e):window).visualViewport,s=!Vp()&&n,c=(r.left+(s&&o?o.offsetLeft:0))/i,l=(r.top+(s&&o?o.offsetTop:0))/a,u=r.width/i,d=r.height/a;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c,x:c,y:l}}function Up(e){var t=Hp(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Wp(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Mp(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Gp(e){return kp(e).getComputedStyle(e)}function Kp(e){return[`table`,`td`,`th`].indexOf(Op(e))>=0}function qp(e){return((Ap(e)?e.ownerDocument:e.document)||window.document).documentElement}function Jp(e){return Op(e)===`html`?e:e.assignedSlot||e.parentNode||(Mp(e)?e.host:null)||qp(e)}function Yp(e){return!jp(e)||Gp(e).position===`fixed`?null:e.offsetParent}function Xp(e){var t=/firefox/i.test(Bp());if(/Trident/i.test(Bp())&&jp(e)&&Gp(e).position===`fixed`)return null;var n=Jp(e);for(Mp(n)&&(n=n.host);jp(n)&&[`html`,`body`].indexOf(Op(n))<0;){var r=Gp(n);if(r.transform!==`none`||r.perspective!==`none`||r.contain===`paint`||[`transform`,`perspective`].indexOf(r.willChange)!==-1||t&&r.willChange===`filter`||t&&r.filter&&r.filter!==`none`)return n;n=n.parentNode}return null}function Zp(e){for(var t=kp(e),n=Yp(e);n&&Kp(n)&&Gp(n).position===`static`;)n=Yp(n);return n&&(Op(n)===`html`||Op(n)===`body`&&Gp(n).position===`static`)?t:n||Xp(e)||t}function Qp(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function $p(e,t,n){return Lp(e,Rp(t,n))}function em(e,t,n){var r=$p(e,t,n);return r>n?n:r}function tm(){return{top:0,right:0,bottom:0,left:0}}function nm(e){return Object.assign({},tm(),e)}function rm(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var im=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,nm(typeof e==`number`?rm(e,yp):e)};function am(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=Ip(n.placement),c=Qp(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=im(i.padding,n),d=Up(a),f=c===`y`?`top`:_p,p=c===`y`?hp:gp,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=Zp(a),_=g?c===`y`?g.clientHeight||0:g.clientWidth||0:0,v=m/2-h/2,y=u[f],b=_-d[l]-u[p],x=_/2-d[l]/2+v,S=$p(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function om(e){var t=e.state,n=e.options.element,r=n===void 0?`[data-popper-arrow]`:n;r!=null&&(typeof r==`string`&&(r=t.elements.popper.querySelector(r),!r)||Wp(t.elements.popper,r)&&(t.elements.arrow=r))}var sm={name:`arrow`,enabled:!0,phase:`main`,fn:am,effect:om,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function cm(e){return e.split(`-`)[1]}var lm={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function um(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:zp(n*i)/i||0,y:zp(r*i)/i||0}}function dm(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,o=e.offsets,s=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,p=f===void 0?0:f,m=o.y,h=m===void 0?0:m,g=typeof u==`function`?u({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var _=o.hasOwnProperty(`x`),v=o.hasOwnProperty(`y`),y=_p,b=`top`,x=window;if(l){var S=Zp(n),C=`clientHeight`,w=`clientWidth`;if(S===kp(n)&&(S=qp(n),Gp(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=hp;var T=d&&S===x&&x.visualViewport?x.visualViewport.height:S[C];h-=T-r.height,h*=c?1:-1}if(i===`left`||(i===`top`||i===`bottom`)&&a===`end`){y=gp;var E=d&&S===x&&x.visualViewport?x.visualViewport.width:S[w];p-=E-r.width,p*=c?1:-1}}var D=Object.assign({position:s},l&&lm),O=u===!0?um({x:p,y:h},kp(n)):{x:p,y:h};if(p=O.x,h=O.y,c){var k;return Object.assign({},D,(k={},k[b]=v?`0`:``,k[y]=_?`0`:``,k.transform=(x.devicePixelRatio||1)<=1?`translate(`+p+`px, `+h+`px)`:`translate3d(`+p+`px, `+h+`px, 0)`,k))}return Object.assign({},D,(t={},t[b]=v?h+`px`:``,t[y]=_?p+`px`:``,t.transform=``,t))}function fm(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0||r,a=n.adaptive,o=a===void 0||a,s=n.roundOffsets,c=s===void 0||s,l={placement:Ip(t.placement),variation:cm(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy===`fixed`};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,dm(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,dm(Object.assign({},l,{offsets:t.modifiersData.arrow,position:`absolute`,adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}var pm={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:fm,data:{}},mm={passive:!0};function hm(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0||i,o=r.resize,s=o===void 0||o,c=kp(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,mm)}),s&&c.addEventListener(`resize`,n.update,mm),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,mm)}),s&&c.removeEventListener(`resize`,n.update,mm)}}var gm={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:hm,data:{}},_m={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vm(e){return e.replace(/left|right|bottom|top/g,function(e){return _m[e]})}var ym={start:`end`,end:`start`};function bm(e){return e.replace(/start|end/g,function(e){return ym[e]})}function xm(e){var t=kp(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Sm(e){return Hp(qp(e)).left+xm(e).scrollLeft}function Cm(e,t){var n=kp(e),r=qp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=Vp();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+Sm(e),y:c}}function wm(e){var t=qp(e),n=xm(e),r=e.ownerDocument?.body,i=Lp(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=Lp(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+Sm(e),s=-n.scrollTop;return Gp(r||t).direction===`rtl`&&(o+=Lp(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function Tm(e){var t=Gp(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Em(e){return[`html`,`body`,`#document`].indexOf(Op(e))>=0?e.ownerDocument.body:jp(e)&&Tm(e)?e:Em(Jp(e))}function Dm(e,t){t===void 0&&(t=[]);var n=Em(e),r=n===e.ownerDocument?.body,i=kp(n),a=r?[i].concat(i.visualViewport||[],Tm(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(Dm(Jp(a)))}function Om(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function km(e,t){var n=Hp(e,!1,t===`fixed`);return n.top+=e.clientTop,n.left+=e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Am(e,t,n){return t===`viewport`?Om(Cm(e,n)):Ap(t)?km(t,n):Om(wm(qp(e)))}function jm(e){var t=Dm(Jp(e)),n=[`absolute`,`fixed`].indexOf(Gp(e).position)>=0&&jp(e)?Zp(e):e;return Ap(n)?t.filter(function(e){return Ap(e)&&Wp(e,n)&&Op(e)!==`body`}):[]}function Mm(e,t,n,r){var i=t===`clippingParents`?jm(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=Am(e,n,r);return t.top=Lp(i.top,t.top),t.right=Rp(i.right,t.right),t.bottom=Rp(i.bottom,t.bottom),t.left=Lp(i.left,t.left),t},Am(e,o,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Nm(e){var t=e.reference,n=e.element,r=e.placement,i=r?Ip(r):null,a=r?cm(r):null,o=t.x+t.width/2-n.width/2,s=t.y+t.height/2-n.height/2,c;switch(i){case`top`:c={x:o,y:t.y-n.height};break;case hp:c={x:o,y:t.y+t.height};break;case gp:c={x:t.x+t.width,y:s};break;case _p:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?Qp(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case bp:c[l]=c[l]-(t[u]/2-n[u]/2);break;case`end`:c[l]=c[l]+(t[u]/2-n[u]/2)}}return c}function Pm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,o=a===void 0?e.strategy:a,s=n.boundary,c=s===void 0?xp:s,l=n.rootBoundary,u=l===void 0?Sp:l,d=n.elementContext,f=d===void 0?Cp:d,p=n.altBoundary,m=p!==void 0&&p,h=n.padding,g=h===void 0?0:h,_=nm(typeof g==`number`?rm(g,yp):g),v=f===`popper`?wp:Cp,y=e.rects.popper,b=e.elements[m?v:f],x=Mm(Ap(b)?b:b.contextElement||qp(e.elements.popper),c,u,o),S=Hp(e.elements.reference),C=Nm({reference:S,element:y,strategy:`absolute`,placement:i}),w=Om(Object.assign({},y,C)),T=f===`popper`?w:S,E={top:x.top-T.top+_.top,bottom:T.bottom-x.bottom+_.bottom,left:x.left-T.left+_.left,right:T.right-x.right+_.right},D=e.modifiersData.offset;if(f===`popper`&&D){var O=D[i];Object.keys(E).forEach(function(e){var t=[`right`,`bottom`].indexOf(e)>=0?1:-1,n=[`top`,`bottom`].indexOf(e)>=0?`y`:`x`;E[e]+=O[n]*t})}return E}function Fm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,o=n.padding,s=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?Ep:c,u=cm(r),d=u?s?Tp:Tp.filter(function(e){return cm(e)===u}):yp,f=d.filter(function(e){return l.indexOf(e)>=0});f.length===0&&(f=d);var p=f.reduce(function(t,n){return t[n]=Pm(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[Ip(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function Im(e){if(Ip(e)===`auto`)return[];var t=vm(e);return[bm(e),t,bm(t)]}function Lm(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o===void 0||o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0||p,h=n.allowedAutoPlacements,g=t.options.placement,_=Ip(g)===g,v=c||(_||!m?[vm(g)]:Im(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(Ip(n)===`auto`?Fm(t,{placement:n,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:h}):n)},[]),b=t.rects.reference,x=t.rects.popper,S=new Map,C=!0,w=y[0],T=0;T<y.length;T++){var E=y[T],D=Ip(E),O=cm(E)===bp,k=[`top`,hp].indexOf(D)>=0,A=k?`width`:`height`,j=Pm(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?gp:_p:O?hp:`top`;b[A]>x[A]&&(M=vm(M));var N=vm(M),P=[];if(a&&P.push(j[D]<=0),s&&P.push(j[M]<=0,j[N]<=0),P.every(function(e){return e})){w=E,C=!1;break}S.set(E,P)}if(C)for(var F=m?3:1,I=function(e){var t=y.find(function(t){var n=S.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return w=t,`break`},L=F;L>0&&I(L)!==`break`;L--);t.placement!==w&&(t.modifiersData[r]._skip=!0,t.placement=w,t.reset=!0)}}var Rm={name:`flip`,enabled:!0,phase:`main`,fn:Lm,requiresIfExists:[`offset`],data:{_skip:!1}};function zm(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Bm(e){return[`top`,gp,hp,_p].some(function(t){return e[t]>=0})}function Vm(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=Pm(t,{elementContext:`reference`}),s=Pm(t,{altBoundary:!0}),c=zm(o,r),l=zm(s,i,a),u=Bm(c),d=Bm(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var Hm={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Vm};function Um(e,t,n){var r=Ip(e),i=[`left`,`top`].indexOf(r)>=0?-1:1,a=typeof n==`function`?n(Object.assign({},t,{placement:e})):n,o=a[0],s=a[1];return o||=0,s=(s||0)*i,[`left`,`right`].indexOf(r)>=0?{x:s,y:o}:{x:o,y:s}}function Wm(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=Ep.reduce(function(e,n){return e[n]=Um(n,t.rects,a),e},{}),s=o[t.placement],c=s.x,l=s.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}var Gm={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:Wm};function Km(e){var t=e.state,n=e.name;t.modifiersData[n]=Nm({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var qm={name:`popperOffsets`,enabled:!0,phase:`read`,fn:Km,data:{}};function Jm(e){return e===`x`?`y`:`x`}function Ym(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o!==void 0&&o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0||f,m=n.tetherOffset,h=m===void 0?0:m,g=Pm(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=Ip(t.placement),v=cm(t.placement),y=!v,b=Qp(_),x=Jm(b),S=t.modifiersData.popperOffsets,C=t.rects.reference,w=t.rects.popper,T=typeof h==`function`?h(Object.assign({},t.rects,{placement:t.placement})):h,E=typeof T==`number`?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(a){var k=b===`y`?`top`:_p,A=b===`y`?hp:gp,j=b===`y`?`height`:`width`,M=S[b],N=M+g[k],P=M-g[A],F=p?-w[j]/2:0,I=v===`start`?C[j]:w[j],L=v===`start`?-w[j]:-C[j],R=t.elements.arrow,ee=p&&R?Up(R):{width:0,height:0},te=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:tm(),z=te[k],B=te[A],V=$p(0,C[j],ee[j]),ne=y?C[j]/2-F-V-z-E.mainAxis:I-V-z-E.mainAxis,re=y?-C[j]/2+F+V+B+E.mainAxis:L+V+B+E.mainAxis,ie=t.elements.arrow&&Zp(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+ne-oe-ae,H=M+re-oe,ce=$p(p?Rp(N,se):N,M,p?Lp(P,H):P);S[b]=ce,O[b]=ce-M}if(s){var le=b===`x`?`top`:_p,ue=b===`x`?hp:gp,de=S[x],fe=x===`y`?`height`:`width`,pe=de+g[le],me=de-g[ue],he=[`top`,_p].indexOf(_)!==-1,ge=D?.[x]??0,_e=he?pe:de-C[fe]-w[fe]-ge+E.altAxis,ve=he?de+C[fe]+w[fe]-ge-E.altAxis:me,ye=p&&he?em(_e,de,ve):$p(p?_e:pe,de,p?ve:me);S[x]=ye,O[x]=ye-de}t.modifiersData[r]=O}}var Xm={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Ym,requiresIfExists:[`offset`]};function Zm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Qm(e){return e===kp(e)||!jp(e)?xm(e):Zm(e)}function $m(e){var t=e.getBoundingClientRect(),n=zp(t.width)/e.offsetWidth||1,r=zp(t.height)/e.offsetHeight||1;return n!==1||r!==1}function eh(e,t,n){n===void 0&&(n=!1);var r=jp(t),i=jp(t)&&$m(t),a=qp(t),o=Hp(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Op(t)!==`body`||Tm(a))&&(s=Qm(t)),jp(t)?(c=Hp(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=Sm(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function th(e){var t=new Map,n=new Set,r=[];e.forEach(function(e){t.set(e.name,e)});function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}}),r.push(e)}return e.forEach(function(e){n.has(e.name)||i(e)}),r}function nh(e){var t=th(e);return Dp.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function rh(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function ih(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}var ah={placement:`bottom`,modifiers:[],strategy:`absolute`};function oh(){return![...arguments].some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function sh(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?ah:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},ah,a),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},o=[],s=!1,c={state:i,setOptions:function(n){var o=typeof n==`function`?n(i.options):n;u(),i.options=Object.assign({},a,i.options,o),i.scrollParents={reference:Ap(e)?Dm(e):e.contextElement?Dm(e.contextElement):[],popper:Dm(t)};var s=nh(ih([].concat(r,i.options.modifiers)));return i.orderedModifiers=s.filter(function(e){return e.enabled}),l(),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if(oh(t,n)){i.rects={reference:eh(t,Zp(n),i.options.strategy===`fixed`),popper:Up(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach(function(e){return i.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<i.orderedModifiers.length;r++){if(i.reset===!0){i.reset=!1,r=-1;continue}var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=l===void 0?{}:l,d=a.name;typeof o==`function`&&(i=o({state:i,options:u,name:d,instance:c})||i)}}}},update:rh(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!oh(e,t))return c;c.setOptions(n).then(function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)});function l(){i.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=n===void 0?{}:n,a=e.effect;if(typeof a==`function`){var s=a({state:i,name:t,instance:c,options:r});o.push(s||function(){})}})}function u(){o.forEach(function(e){return e()}),o=[]}return c}}var ch=sh({defaultModifiers:[gm,qm,pm,Fp,Gm,Rm,Xm,sm,Hm]});function lh(e){let{elementType:t,externalSlotProps:n,ownerState:r,skipResolvingSlotProps:i=!1,...a}=e,o=i?{}:Gc(n,r),{props:s,internalRef:c}=Yc({...a,externalSlotProps:o}),l=ss(c,o?.ref,e.additionalProps?.ref);return Wc(t,{...s,ref:l},r)}function uh(e){return Gr(`MuiPopper`,e)}Kr(`MuiPopper`,[`root`]);function dh(e,t){if(t===`ltr`)return e;switch(e){case`bottom-end`:return`bottom-start`;case`bottom-start`:return`bottom-end`;case`top-end`:return`top-start`;case`top-start`:return`top-end`;default:return e}}function fh(e){return typeof e==`function`?e():e}function ph(e){return e.nodeType!==void 0}var mh=e=>{let{classes:t}=e;return ba({root:[`root`]},uh,t)},hh={},gh=v.forwardRef(function(e,t){let{anchorEl:n,children:r,direction:i,disablePortal:a,modifiers:o,open:s,placement:c,popperOptions:l,popperRef:u,slotProps:d={},slots:f={},TransitionProps:p,ownerState:m,...h}=e,g=v.useRef(null),_=ss(g,t),y=v.useRef(null),b=ss(y,u),x=v.useRef(b);ci(()=>{x.current=b},[b]),v.useImperativeHandle(u,()=>y.current,[]);let S=dh(c,i),[C,w]=v.useState(S),T=v.useMemo(()=>fh(n),[n]);v.useEffect(()=>{y.current&&y.current.forceUpdate()}),ci(()=>{if(!T||!s)return;let e=e=>{w(e.placement)},t=[{name:`preventOverflow`,options:{altBoundary:a}},{name:`flip`,options:{altBoundary:a}},{name:`onUpdate`,enabled:!0,phase:`afterWrite`,fn:({state:t})=>{e(t)}}];o!=null&&(t=t.concat(o)),l&&l.modifiers!=null&&(t=t.concat(l.modifiers));let n=ch(T,g.current,{placement:S,...l,modifiers:t});x.current(n);let r=g.current;return()=>{if(r){let{style:e}=r,t=e.position,i=e.top,a=e.left,o=e.transform;n.destroy(),e.position=t,e.top=i,e.left=a,e.transform=o}else n.destroy();x.current(null)}},[T,a,o,s,l,S]);let E={placement:C};p!==null&&(E.TransitionProps=p);let D=mh(e),O=f.root??`div`,k=lh({elementType:O,externalSlotProps:d.root,externalForwardedProps:h,additionalProps:{role:`tooltip`,ref:_},ownerState:e,className:D.root});return(0,U.jsx)(O,{...k,children:typeof r==`function`?r(E):r})}),_h=K(v.forwardRef(function(e,t){let{anchorEl:n,children:r,container:i,direction:a=`ltr`,disablePortal:o=!1,keepMounted:s=!1,modifiers:c,open:l,placement:u=`bottom`,popperOptions:d=hh,popperRef:f,style:p,transition:m=!1,slotProps:h={},slots:g={},..._}=e,[y,b]=v.useState(!0),x=()=>{b(!1)},S=()=>{b(!0)};if(!s&&!l&&(!m||y))return null;let C;if(i)C=i;else if(n){let e=fh(n);C=e&&ph(e)?ls(e).body:ls(null).body}let w=!l&&s&&(!m||y)?`none`:void 0,T=m?{in:l,onEnter:x,onExited:S}:void 0;return(0,U.jsx)(Qu,{disablePortal:o,container:C,children:(0,U.jsx)(gh,{anchorEl:n,direction:a,disablePortal:o,modifiers:c,ref:t,open:m?!y:l,placement:u,popperOptions:d,popperRef:f,slotProps:h,slots:g,..._,style:{position:`fixed`,top:0,left:0,display:w,...p},TransitionProps:T,children:r})})}),{name:`MuiPopper`,slot:`Root`})({}),vh=v.forwardRef(function(e,t){let n=Ri(),{anchorEl:r,component:i,container:a,disablePortal:o,keepMounted:s,modifiers:c,open:l,placement:u,popperOptions:d,popperRef:f,transition:p,slots:m,slotProps:h,...g}=Xo({props:e,name:`MuiPopper`}),_={anchorEl:r,container:a,disablePortal:o,keepMounted:s,modifiers:c,open:l,placement:u,popperOptions:d,popperRef:f,transition:p,...g};return(0,U.jsx)(_h,{as:i,direction:n?`rtl`:`ltr`,slots:m,slotProps:h,..._,ref:t})});function yh(e){return Gr(`MuiTooltip`,e)}var bh=Kr(`MuiTooltip`,[`popper`,`popperInteractive`,`popperArrow`,`popperClose`,`tooltip`,`tooltipArrow`,`touch`,`tooltipPlacementLeft`,`tooltipPlacementRight`,`tooltipPlacementTop`,`tooltipPlacementBottom`,`arrow`]);function xh(e){return Math.round(e*1e5)/1e5}var Sh=e=>{let{classes:t,disableInteractive:n,arrow:r,touch:i,placement:a}=e;return ba({popper:[`popper`,!n&&`popperInteractive`,r&&`popperArrow`],tooltip:[`tooltip`,r&&`tooltipArrow`,i&&`touch`,`tooltipPlacement${q(a.split(`-`)[0])}`],arrow:[`arrow`]},yh,t)},Ch=K(vh,{name:`MuiTooltip`,slot:`Popper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.popper,!n.disableInteractive&&t.popperInteractive,n.arrow&&t.popperArrow,!n.open&&t.popperClose]}})(ys(({theme:e})=>({zIndex:(e.vars||e).zIndex.tooltip,pointerEvents:`none`,variants:[{props:({ownerState:e,open:t})=>t&&!e.disableInteractive,style:{pointerEvents:`auto`}},{props:({ownerState:e})=>e.arrow,style:{[`&[data-popper-placement*="bottom"] .${bh.arrow}`]:{top:0,marginTop:`-0.71em`,"&::before":{transformOrigin:`0 100%`}},[`&[data-popper-placement*="top"] .${bh.arrow}`]:{bottom:0,marginBottom:`-0.71em`,"&::before":{transformOrigin:`100% 0`}},[`&[data-popper-placement*="right"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineStart:0,marginInlineStart:`-0.71em`,"&::before":{transformOrigin:`100% 100%`}},[`&[data-popper-placement*="left"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineEnd:0,marginInlineEnd:`-0.71em`,"&::before":{transformOrigin:`0 0`}}}}]}))),wh=K(`div`,{name:`MuiTooltip`,slot:`Tooltip`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.tooltip,n.touch&&t.touch,n.arrow&&t.tooltipArrow,t[`tooltipPlacement${q(n.placement.split(`-`)[0])}`]]}})(ys(({theme:e})=>({backgroundColor:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.92),borderRadius:(e.vars||e).shape.borderRadius,color:(e.vars||e).palette.common.white,fontFamily:e.typography.fontFamily,padding:`4px 8px`,fontSize:e.typography.pxToRem(11),maxWidth:300,margin:2,wordWrap:`break-word`,fontWeight:e.typography.fontWeightMedium,[`.${bh.popper}[data-popper-placement*="left"] &`]:{transformOrigin:`right center`,marginInlineEnd:`14px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{transformOrigin:`left center`,marginInlineStart:`14px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{transformOrigin:`center bottom`,marginBottom:`14px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{transformOrigin:`center top`,marginTop:`14px`},variants:[{props:({ownerState:e})=>e.arrow,style:{position:`relative`,marginBlock:0}},{props:({ownerState:e})=>e.touch,style:{padding:`8px 16px`,fontSize:e.typography.pxToRem(14),lineHeight:`${xh(16/14)}em`,fontWeight:e.typography.fontWeightRegular}},{props:({ownerState:e})=>e.touch,style:{[`.${bh.popper}[data-popper-placement*="left"] &`]:{marginInlineEnd:`24px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{marginInlineStart:`24px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{marginBottom:`24px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{marginTop:`24px`}}}]}))),Th=K(`span`,{name:`MuiTooltip`,slot:`Arrow`})(ys(({theme:e})=>({overflow:`hidden`,position:`absolute`,width:`1em`,height:`0.71em`,boxSizing:`border-box`,color:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.9),"&::before":{content:`""`,margin:`auto`,display:`block`,width:`100%`,height:`100%`,backgroundColor:`currentColor`,transform:`rotate(45deg)`}}))),Eh=!1,Dh=new Sl,Oh={x:0,y:0};function kh(e,t){return(n,...r)=>{t&&t(n,...r),e(n,...r)}}var Ah=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTooltip`}),{arrow:r=!1,children:i,classes:a,describeChild:o=!1,disableFocusListener:s=!1,disableHoverListener:c=!1,disableInteractive:l=!1,disableTouchListener:u=!1,enterDelay:d=100,enterNextDelay:f=0,enterTouchDelay:p=700,followCursor:m=!1,id:h,leaveDelay:g=0,leaveTouchDelay:_=1500,onClose:y,onOpen:b,open:x,placement:S=`bottom`,slotProps:C={},slots:w={},title:T,...E}=n,D=v.isValidElement(i)?i:(0,U.jsx)(`span`,{children:i}),O=Go(),[k,A]=v.useState(),[j,M]=v.useState(null),N=v.useRef(!1),P=l||m,F=Cl(),I=Cl(),L=Cl(),R=Cl(),[ee,te]=Od({controlled:x,default:!1,name:`Tooltip`,state:`open`}),z=ee,B=Ed(h),V=v.useRef(),ne=dl(()=>{V.current!==void 0&&(document.body.style.WebkitUserSelect=V.current,V.current=void 0),R.clear()});v.useEffect(()=>ne,[ne]);let re=e=>{Dh.clear(),Eh=!0,te(!0),b&&!z&&b(e)},ie=dl(e=>{Dh.start(800+g,()=>{Eh=!1}),te(!1),y&&z&&y(e),F.start(O.transitions.duration.shortest,()=>{N.current=!1})}),ae=e=>{k?.disabled||N.current&&e.type!==`touchstart`||(k&&k.removeAttribute(`title`),I.clear(),L.clear(),d||Eh&&f?I.start(Eh?f:d,()=>{re(e)}):re(e))},oe=e=>{I.clear(),L.start(g,()=>{ie(e)})},[,se]=v.useState(!1),H=e=>{let t=e?.target??k;if(!t||t.disabled||!ul(t)){se(!1);let n=e??new Event(`blur`);!e&&t&&(Object.defineProperty(n,"target",{value:t}),Object.defineProperty(n,"currentTarget",{value:t})),oe(n)}},ce=e=>{if(k||A(e.currentTarget),ul(e.target)){let t=e=>{e.target.disabled&&H(e),e.target.removeEventListener(`blur`,t)};e.target.addEventListener(`blur`,t),se(!0),ae(e)}},le=e=>{N.current=!0;let t=D.props;t.onTouchStart&&t.onTouchStart(e)},ue=e=>{le(e),L.clear(),F.clear(),ne(),V.current=document.body.style.WebkitUserSelect,document.body.style.WebkitUserSelect=`none`,R.start(p,()=>{document.body.style.WebkitUserSelect=V.current,ae(e)})},de=e=>{D.props.onTouchEnd&&D.props.onTouchEnd(e),ne(),L.start(_,()=>{ie(e)})};v.useEffect(()=>{if(!z)return;function e(e){e.key===`Escape`&&ie(e)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[ie,z]);let fe=bs(Lu(D),A,t);!T&&T!==0&&(z=!1);let pe=v.useRef(),me=e=>{let t=D.props;t.onMouseMove&&t.onMouseMove(e),Oh={x:e.clientX,y:e.clientY},pe.current&&pe.current.update()},he={},ge=typeof T==`string`;o?(he.title=!z&&ge&&!c?T:null,he[`aria-describedby`]=z?B:null):(he[`aria-label`]=ge?T:null,he[`aria-labelledby`]=z&&!ge?B:null);let _e={...he,...E,...D.props,className:W(E.className,D.props.className),onTouchStart:le,ref:fe,...m?{onMouseMove:me}:{}},ve={};u||(_e.onTouchStart=ue,_e.onTouchEnd=de),c||(_e.onMouseOver=kh(ae,_e.onMouseOver),_e.onMouseLeave=kh(oe,_e.onMouseLeave),P||(ve.onMouseOver=ae,ve.onMouseLeave=oe)),s||(_e.onFocus=kh(ce,_e.onFocus),_e.onBlur=kh(H,_e.onBlur),P||(ve.onFocus=ce,ve.onBlur=H));let ye={...n,arrow:r,disableInteractive:P,placement:S,touch:N.current},be=typeof C.popper==`function`?C.popper(ye):C.popper,xe=v.useMemo(()=>{let e=[{name:`arrow`,enabled:!!j,options:{element:j,padding:4}}];return be?.popperOptions?.modifiers&&(e=e.concat(be.popperOptions.modifiers)),{...be?.popperOptions,modifiers:e}},[j,be?.popperOptions]),Se=Sh(ye),Ce={slots:w,slotProps:{arrow:C.arrow,popper:be,tooltip:C.tooltip,transition:C.transition}},[we,Te]=Xc(`popper`,{elementType:Ch,externalForwardedProps:Ce,ownerState:ye,className:Se.popper}),[Ee,De]=Xc(`transition`,{elementType:mp,externalForwardedProps:Ce,ownerState:ye}),[Oe,ke]=Xc(`tooltip`,{elementType:wh,className:Se.tooltip,externalForwardedProps:Ce,ownerState:ye}),[Ae,je]=Xc(`arrow`,{elementType:Th,className:Se.arrow,externalForwardedProps:Ce,ownerState:ye,ref:M});return(0,U.jsxs)(v.Fragment,{children:[v.cloneElement(D,_e),(0,U.jsx)(we,{as:vh,placement:S,anchorEl:m?{getBoundingClientRect:()=>({top:Oh.y,left:Oh.x,right:Oh.x,bottom:Oh.y,width:0,height:0})}:k,popperRef:pe,open:k?z:!1,id:B,transition:!0,...ve,...Te,popperOptions:xe,children:({TransitionProps:e})=>(0,U.jsx)(Ee,{timeout:O.transitions.duration.shorter,...e,...De,children:(0,U.jsxs)(Oe,{...ke,children:[T,r?(0,U.jsx)(Ae,{...je}):null]})})})]})}),jh=Y((0,U.jsx)(`path`,{d:`M4 13h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1m0 8h6c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1m10 0h6c.55 0 1-.45 1-1v-8c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1M13 4v4c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1`}),`DashboardRounded`),Mh=Y((0,U.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2`}),`ChatBubbleRounded`),Nh=Y((0,U.jsx)(`path`,{d:`M14.59 2.59c-.38-.38-.89-.59-1.42-.59H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8.83c0-.53-.21-1.04-.59-1.41zM15 18H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m0-4H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m-2-6V3.5L18.5 9H14c-.55 0-1-.45-1-1`}),`DescriptionRounded`),Ph=Y((0,U.jsx)(`path`,{d:`M3 7c.55 0 1 .45 1 1v13h13c.55 0 1 .45 1 1s-.45 1-1 1H4c-1.1 0-2-.9-2-2V8c0-.55.45-1 1-1m12.59-5.41c-.38-.38-.89-.59-1.42-.59H8c-1.1 0-1.99.9-1.99 2L6 17c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V7.83c0-.53-.21-1.04-.59-1.41zM15.5 15h-4c-.55 0-1-.45-1-1s.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1m0-6h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V9h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V6c0-.55.45-1 1-1s1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1`}),`DifferenceRounded`),Fh=Y((0,U.jsx)(`path`,{d:`M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2m0 14H4V8h16zm-8-2c0-.55.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1M6.79 9.71c.39-.39 1.02-.39 1.41 0l2.59 2.59c.39.39.39 1.02 0 1.41L8.2 16.3c-.39.39-1.02.39-1.41 0a.996.996 0 0 1 0-1.41L8.67 13l-1.88-1.88a.996.996 0 0 1 0-1.41`}),`TerminalRounded`),Ih=Y((0,U.jsx)(`path`,{d:`M13.26 3C8.17 2.86 4 6.95 4 12H2.21c-.45 0-.67.54-.35.85l2.79 2.8c.2.2.51.2.71 0l2.79-2.8c.31-.31.09-.85-.36-.85H6c0-3.9 3.18-7.05 7.1-7 3.72.05 6.85 3.18 6.9 6.9.05 3.91-3.1 7.1-7 7.1-1.61 0-3.1-.55-4.28-1.48-.4-.31-.96-.28-1.32.08-.42.42-.39 1.13.08 1.49C9 20.29 10.91 21 13 21c5.05 0 9.14-4.17 9-9.26-.13-4.69-4.05-8.61-8.74-8.74m-.51 5c-.41 0-.75.34-.75.75v3.68c0 .35.19.68.49.86l3.12 1.85c.36.21.82.09 1.03-.26.21-.36.09-.82-.26-1.03l-2.88-1.71v-3.4c0-.4-.34-.74-.75-.74`}),`HistoryRounded`),Lh=Y((0,U.jsx)(`path`,{d:`M9.19 6.35c-2.04 2.29-3.44 5.58-3.57 5.89l-2.26-.97c-.65-.28-.81-1.13-.31-1.63l3.01-3.01c.47-.47 1.15-.68 1.81-.55zm1.49 10.16c.3.3.74.38 1.12.2 1.16-.54 3.65-1.81 5.26-3.42 4.59-4.59 4.63-8.33 4.36-9.93-.07-.4-.39-.72-.79-.79-1.6-.27-5.34-.23-9.93 4.36-1.61 1.61-2.87 4.1-3.42 5.26-.18.38-.09.83.2 1.12zm6.97-1.7c-2.29 2.04-5.58 3.44-5.89 3.57l.97 2.26c.28.65 1.13.81 1.63.31l3.01-3.01c.47-.47.68-1.15.55-1.81zm-8.71 2.6c.2 1.06-.15 2.04-.82 2.71-.77.77-3.16 1.34-4.71 1.64-.69.13-1.3-.48-1.17-1.17.3-1.55.86-3.94 1.64-4.71.67-.67 1.65-1.02 2.71-.82 1.17.22 2.13 1.18 2.35 2.35M13 9c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2`}),`RocketLaunchRounded`),Rh=Y((0,U.jsx)(`path`,{d:`M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1m0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1`}),`MenuRounded`),zh=Y((0,U.jsx)(`path`,{d:`M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5M2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1m18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1M11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1m0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1M5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0z`}),`LightModeRounded`),Bh=Y((0,U.jsx)(`path`,{d:`M11.01 3.05C6.51 3.54 3 7.36 3 12c0 4.97 4.03 9 9 9 4.63 0 8.45-3.5 8.95-8 .09-.79-.78-1.42-1.54-.95-.84.54-1.84.85-2.91.85-2.98 0-5.4-2.42-5.4-5.4 0-1.06.31-2.06.84-2.89.45-.67-.04-1.63-.93-1.56`}),`DarkModeRounded`),Vh=Y((0,U.jsx)(`path`,{d:`M20 6h-8l-1.41-1.41C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m-1 12H5c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1`}),`FolderOpenRounded`);function Hh(e){return Gr(`MuiTab`,e)}var Uh=Kr(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`icon`]),Wh=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e;return ba({root:[`root`,a&&o&&`labelIcon`,`textColor${q(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`icon`]},Hh,t)},Gh=K(tu,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${q(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${Uh.icon}`]:t.icon}]}})(ys(({theme:e})=>({...e.typography.button,maxWidth:360,minWidth:90,position:`relative`,minHeight:48,flexShrink:0,padding:`12px 16px`,overflow:`hidden`,whiteSpace:`normal`,textAlign:`center`,lineHeight:1.25,variants:[{props:({ownerState:e})=>e.label&&(e.iconPosition===`top`||e.iconPosition===`bottom`),style:{flexDirection:`column`}},{props:({ownerState:e})=>e.label&&e.iconPosition!==`top`&&e.iconPosition!==`bottom`,style:{flexDirection:`row`}},{props:({ownerState:e})=>e.icon&&e.label,style:{minHeight:72,paddingTop:9,paddingBottom:9}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`top`,style:{[`& > .${Uh.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${Uh.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${Uh.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${Uh.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${Uh.selected}`]:{opacity:1},[`&.${Uh.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:({ownerState:e})=>e.fullWidth,style:{flexShrink:1,flexGrow:1,flexBasis:0,maxWidth:`none`}},{props:({ownerState:e})=>e.wrapped,style:{fontSize:e.typography.pxToRem(12)}}]}))),Kh=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTab`}),{className:r,disabled:i=!1,disableFocusRipple:a=!1,fullWidth:o,icon:s,iconPosition:c=`top`,indicator:l,label:u,onChange:d,onClick:f,onFocus:p,selected:m,selectionFollowsFocus:h,textColor:g=`inherit`,value:_,wrapped:y=!1,...b}=n,x=Of(),S=Nf({id:_,ref:t,disabled:i,selected:m}),C=x.getItemMap().size===0&&m?0:S.tabIndex,w={...n,disabled:i,disableFocusRipple:a,selected:m,icon:!!s,iconPosition:c,label:!!u,fullWidth:o,textColor:g,wrapped:y},T=Wh(w),E=s&&u&&v.isValidElement(s)?v.cloneElement(s,{className:W(T.icon,s.props.className)}):s;return(0,U.jsxs)(Gh,{internalNativeButton:!0,focusRipple:!a,className:W(T.root,r),ref:S.ref,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,_),f&&f(e)},onFocus:e=>{h&&!m&&d&&d(e,_),p&&p(e)},tabIndex:C,ownerState:w,...b,children:[c===`top`||c===`start`?(0,U.jsxs)(v.Fragment,{children:[E,u]}):(0,U.jsxs)(v.Fragment,{children:[u,E]}),l]})});function qh(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function Jh(e,t,n,r={},i=()=>{}){let{ease:a=qh,duration:o=300}=r,s=null,c=t[e],l=!1,u=()=>{l=!0},d=r=>{if(l){i(Error(`Animation cancelled`));return}s===null&&(s=r);let u=Math.min(1,(r-s)/o);if(t[e]=a(u)*(n-c)+c,u>=1){requestAnimationFrame(()=>{i(null)});return}requestAnimationFrame(d)};return c===n?(i(Error(`Element already at target position`)),u):(requestAnimationFrame(d),u)}var Yh={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`,pointerEvents:`none`};function Xh(e){let{onChange:t,...n}=e,r=v.useRef(),i=v.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return xs(()=>{let e=Cd(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=Td(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),v.useEffect(()=>{a(),t(r.current)},[t]),(0,U.jsx)(`div`,{style:Yh,...n,ref:i})}var Zh=Y((0,U.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Qh=Y((0,U.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function $h(e){return Gr(`MuiTabScrollButton`,e)}var eg=Kr(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),tg=e=>{let{classes:t,orientation:n,disabled:r}=e;return ba({root:[`root`,n,r&&`disabled`]},$h,t)},ng=K(tu,{name:`MuiTabScrollButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.orientation&&t[n.orientation]]}})({width:40,flexShrink:0,opacity:.8,[`&.${eg.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),rg=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,{nativeButton:u,...d}=l,f=Ri(),p={isRtl:f,...n},m=tg(p),h=i.StartScrollButtonIcon??Zh,g=i.EndScrollButtonIcon??Qh,_=lh({elementType:h,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p}),v=lh({elementType:g,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p});return(0,U.jsx)(ng,{component:`div`,className:W(m.root,r),ref:t,role:null,ownerState:p,tabIndex:null,...d,style:{...d.style,...s===`vertical`&&{"--TabScrollButton-svgRotate":`rotate(${f?-90:90}deg)`}},children:o===`left`?(0,U.jsx)(h,{..._}):(0,U.jsx)(g,{...v})})});function ig(e){return Gr(`MuiTabs`,e)}var ag=Kr(`MuiTabs`,[`root`,`vertical`,`list`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),og=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return ba({root:[`root`,t&&`vertical`],scroller:[`scroller`,n&&`fixed`,r&&`hideScrollbar`,i&&`scrollableX`,a&&`scrollableY`],list:[`list`,t&&`vertical`,o&&`centered`],indicator:[`indicator`],scrollButtons:[`scrollButtons`,s&&`scrollButtonsHideMobile`],scrollableX:[i&&`scrollableX`],hideScrollbar:[r&&`hideScrollbar`]},ig,c)},sg=K(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${ag.scrollButtons}`]:t.scrollButtons},{[`& .${ag.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(ys(({theme:e})=>({overflow:`hidden`,minHeight:48,WebkitOverflowScrolling:`touch`,display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.scrollButtonsHideMobile,style:{[`& .${ag.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),cg=K(`div`,{name:`MuiTabs`,slot:`Scroller`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.scroller,n.fixed&&t.fixed,n.hideScrollbar&&t.hideScrollbar,n.scrollableX&&t.scrollableX,n.scrollableY&&t.scrollableY]}})({position:`relative`,display:`inline-block`,flex:`1 1 auto`,whiteSpace:`nowrap`,variants:[{props:({ownerState:e})=>e.fixed,style:{overflowX:`hidden`,width:`100%`}},{props:({ownerState:e})=>e.hideScrollbar,style:{scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}},{props:({ownerState:e})=>e.scrollableX,style:{overflowX:`auto`,overflowY:`hidden`}},{props:({ownerState:e})=>e.scrollableY,style:{overflowY:`auto`,overflowX:`hidden`}}]}),lg=K(`div`,{name:`MuiTabs`,slot:`List`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.list,n.centered&&t.centered]}})({display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.centered,style:{justifyContent:`center`}}]}),ug=K(`span`,{name:`MuiTabs`,slot:`Indicator`})(ys(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,...Ks(e),variants:[{props:{indicatorColor:`primary`},style:{backgroundColor:(e.vars||e).palette.primary.main}},{props:{indicatorColor:`secondary`},style:{backgroundColor:(e.vars||e).palette.secondary.main}},{props:({ownerState:e})=>e.vertical,style:{height:`100%`,width:2,right:0}}]}))),dg=K(Xh)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),fg={},pg=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTabs`}),r=Go(),i=Ri(),a=Ll(r.motion.reducedMotion,!1),{"aria-label":o,"aria-labelledby":s,action:c,centered:l=!1,children:u,className:d,component:f=`div`,allowScrollButtonsMobile:p=!1,indicatorColor:m=`primary`,onChange:h,orientation:g=`horizontal`,scrollButtons:_=`auto`,selectionFollowsFocus:y,slots:b={},slotProps:x={},textColor:S=`primary`,value:C,variant:w=`standard`,visibleScrollbar:T=!1,...E}=n,D=w===`scrollable`,O=g===`vertical`,k=O?`scrollTop`:`scrollLeft`,A=O?`top`:`left`,j=O?`bottom`:`right`,M=O?`clientHeight`:`clientWidth`,N=O?`height`:`width`,P={...n,component:f,allowScrollButtonsMobile:p,indicatorColor:m,orientation:g,vertical:O,scrollButtons:_,textColor:S,variant:w,visibleScrollbar:T,fixed:!D,hideScrollbar:D&&!T,scrollableX:D&&!O,scrollableY:D&&O,centered:l&&!D,scrollButtonsHideMobile:!p},F=og(P),I=lh({elementType:b.startScrollButtonIcon,externalSlotProps:x.startScrollButtonIcon,ownerState:P}),L=lh({elementType:b.endScrollButtonIcon,externalSlotProps:x.endScrollButtonIcon,ownerState:P}),[R,ee]=v.useState(!1),[te,z]=v.useState(fg),[B,V]=v.useState(!1),[ne,re]=v.useState(!1),[ie,ae]=v.useState(!1),oe=C===!1?null:C,[se,H]=v.useState(!1),[ce,le]=v.useState({overflow:`hidden`,scrollbarWidth:0}),ue=new Map,de=v.useRef(null),fe=v.useRef(null),pe={slots:b,slotProps:x},me=()=>{let e=de.current,t;if(e){let n=e.getBoundingClientRect();t={clientWidth:e.clientWidth,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}let n;if(e&&C!==!1){let e=fe.current.children;if(e.length>0){let t=e[ue.get(C)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},he=dl(()=>{let{tabsMeta:e,tabMeta:t}=me(),n=0,r;O?(r=`top`,t&&e&&(n=t.top-e.top+e.scrollTop)):(r=i?`right`:`left`,t&&e&&(n=(i?-1:1)*(t[r]-e[r]+e.scrollLeft)));let a={[r]:n,[N]:t?t[N]:0};if(typeof te[r]!=`number`||typeof te[N]!=`number`)z(a);else{let e=Math.abs(te[r]-a[r]),t=Math.abs(te[N]-a[N]);(e>=1||t>=1)&&z(a)}}),ge=(e,{animation:t=!0}={})=>{t&&!a.shouldReduceMotion?Jh(k,de.current,e,{duration:r.transitions.duration.standard}):de.current[k]=e},_e=e=>{let t=de.current[k];t+=O?e:e*(i?-1:1),ge(t)},ve=()=>{let e=de.current[M],t=0,n=Array.from(fe.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[M]>e){r===0&&(t=e);break}t+=i[M]}return t},ye=()=>{_e(-1*ve())},be=()=>{_e(ve())},[xe,{onChange:Se,...Ce}]=Xc(`scrollbar`,{className:W(F.scrollableX,F.hideScrollbar),elementType:dg,shouldForwardComponentProp:!0,externalForwardedProps:pe,ownerState:P}),we=v.useCallback(e=>{Se?.(e),le({overflow:null,scrollbarWidth:e})},[Se]),[Te,Ee]=Xc(`scrollButtons`,{className:F.scrollButtons,elementType:rg,externalForwardedProps:pe,ownerState:P,additionalProps:{orientation:g,slots:{StartScrollButtonIcon:b.startScrollButtonIcon,EndScrollButtonIcon:b.endScrollButtonIcon},slotProps:{startScrollButtonIcon:I,endScrollButtonIcon:L}}}),De=()=>{let e={};e.scrollbarSizeListener=D?(0,U.jsx)(xe,{...Ce,onChange:we}):null;let t=D&&(_===`auto`&&(B||ne)||_===!0);return e.scrollButtonStart=t?(0,U.jsx)(Te,{direction:i?`right`:`left`,onClick:ye,disabled:!B,...Ee}):null,e.scrollButtonEnd=t?(0,U.jsx)(Te,{direction:i?`left`:`right`,onClick:be,disabled:!ne,...Ee}):null,e},Oe=dl(e=>{let{tabsMeta:t,tabMeta:n}=me();if(!(!n||!t)){if(n[A]<t[A]){let r=t[k]+(n[A]-t[A]);ge(r,{animation:e})}else if(n[j]>t[j]){let r=t[k]+(n[j]-t[j]);ge(r,{animation:e})}}}),ke=dl(()=>{D&&_!==!1&&ae(!ie)});v.useEffect(()=>{let e=Cd(()=>{de.current&&he()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),ke()},r=Td(de.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(fe.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(fe.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[he,ke]),v.useEffect(()=>{let e=Array.from(fe.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&D&&_!==!1){let n=e[0],r=e[t-1],i={root:de.current,threshold:.99},a=new IntersectionObserver(e=>{V(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{re(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[D,_,ie,u?.length]),v.useEffect(()=>{ee(!0)},[]),v.useEffect(()=>{he()}),v.useEffect(()=>{Oe(fg!==te)},[Oe,te]),v.useImperativeHandle(c,()=>({updateIndicator:he,updateScrollButtons:ke}),[he,ke]);let[Ae,je]=Xc(`indicator`,{className:F.indicator,elementType:ug,externalForwardedProps:pe,ownerState:P,additionalProps:{style:te}}),Me=(0,U.jsx)(Ae,{...je}),Ne=Mf({activeItemId:se?void 0:oe,orientation:g,isRtl:i}),Pe=Ne.getContainerProps(),Fe=v.Children.toArray(u).filter(v.isValidElement).map((e,t)=>{let n=e.props.value===void 0?t:e.props.value;return ue.set(n,t),{child:e,index:t,childValue:n}}).map(({child:e,childValue:t})=>{let n=t===C;return v.cloneElement(e,{fullWidth:w===`fullWidth`,indicator:n&&!R&&Me,selected:n,selectionFollowsFocus:y,onChange:h,textColor:S,value:t})}),Ie=De(),[Le,Re]=Xc(`root`,{ref:t,className:W(F.root,d),elementType:sg,externalForwardedProps:{...pe,...E,component:f},ownerState:P}),[ze,Be]=Xc(`scroller`,{ref:de,className:F.scroller,elementType:cg,externalForwardedProps:pe,ownerState:P,additionalProps:{style:{overflow:ce.overflow,[O?`margin${i?`Left`:`Right`}`:`marginBottom`]:T?void 0:-ce.scrollbarWidth}}}),Ve=bs(Pe.ref,fe),He=e=>{let t=fe.current;ws(Ss(t))?.getAttribute(`role`)===`tab`&&Pe.onKeyDown(e)},[Ue,We]=Xc(`list`,{ref:Ve,className:F.list,elementType:lg,externalForwardedProps:pe,ownerState:P,getSlotProps:e=>({...e,onBlur:t=>{zu(t.currentTarget,t.relatedTarget)||H(!1),e.onBlur?.(t)},onKeyDown:t=>{He(t),e.onKeyDown?.(t)},onFocus:t=>{H(!0),Pe.onFocus(t),e.onFocus?.(t)}})});return(0,U.jsxs)(Le,{...Re,children:[Ie.scrollButtonStart,Ie.scrollbarSizeListener,(0,U.jsxs)(ze,{...Be,children:[(0,U.jsx)(Ue,{"aria-label":o,"aria-labelledby":s,"aria-orientation":g===`vertical`?`vertical`:null,role:`tablist`,...We,children:(0,U.jsx)(Df.Provider,{value:Ne,children:Fe})}),R&&Me]}),Ie.scrollButtonEnd]})}),mg=null,hg=null;async function gg(e){if(!e.ok)return!1;try{let t=await e.json();return typeof t.csrfToken!=`string`||!/^[A-Za-z0-9_-]{43}$/.test(t.csrfToken)?!1:(mg=t.csrfToken,!0)}catch{return!1}}function _g(){return mg}async function vg(e,t){let n=await fetch(e,t);if(n.status!==403)return n;let r=t.headers[`X-Piagent-CSRF`];try{await gg(await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t.signal}))}catch{return n}return!mg||mg===r?n:fetch(e,{...t,headers:{...t.headers,"X-Piagent-CSRF":mg}})}var yg=null;function bg(){return yg}async function xg(){let e=new URLSearchParams(window.location.hash.slice(1)),t=e.get(`bootstrap`),n=e.get(`project`);if(n&&/^[A-Za-z0-9_-]{1,120}$/.test(n)&&(yg=n),!t){n&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);try{return await gg(await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`}}))?`existing-session`:`failed`}catch{return`failed`}}window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);try{return await gg(await fetch(`/api/v1/bootstrap`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({capability:t})}))?`authenticated`:`failed`}catch{return`failed`}}function Sg(){return hg??=xg(),hg}var Cg=!1,wg=null,Tg=new Set;function Eg(){return Cg}function Dg(e){return Tg.add(e),()=>{Tg.delete(e)}}function Og(){Cg||wg||(wg=(async()=>{try{await Sg();let e=await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(e.status!==401){await gg(e);return}Cg=!0;for(let e of Tg)e()}catch{}finally{wg=null}})())}var kg=class extends Error{status;constructor(e){super(`webui-request-${e}`),this.status=e}};async function Ag(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new kg(t.status);return await t.json()}function jg(e){return Ug(`/api/v1/session-catalog`,e)}function Mg(e){return Ug(`/api/v1/session-live-state`,e)}function Ng(e){return Ug(`/api/v1/session-creation-options`,e)}function Pg(e){return Ug(`/api/v1/provider-auth`,e)}function Fg(e,t){return Ug(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function Ig(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/provider-auth`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}function Lg(e,t){return Ig({action:`provider-auth.start`,providerRef:e},t)}function Rg(e,t,n,r){return Ig({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function zg(e,t){return Ig({action:`provider-auth.cancel`,jobRef:e},t)}async function Bg(e){let t=_g();if(!t)throw new kg(403);let n=await vg(`/api/v1/projects/import`,{method:`POST`,credentials:`same-origin`,signal:e,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":t},body:JSON.stringify({action:`project.import`})});if(!n.ok)throw new kg(n.status);return await n.json()}async function Vg(e){try{return await Ug(`/api/v1/managed`,e)}catch(e){if(e instanceof kg&&e.status===404)return null;throw e}}async function Hg(e){let t=_g();if(!t)throw new kg(403);let n=await vg(`/api/v1/managed/connect`,{method:`POST`,credentials:`same-origin`,signal:e,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":t},body:JSON.stringify({action:`managed.connect`})});if(!n.ok)throw new kg(n.status);return await n.json()}async function Ug(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(n.status===401&&Og(),!n.ok)throw new kg(n.status);return await n.json()}function Wg(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function Gg(e,t){return Ug(Wg(e,`/api/v1/snapshot`),t)}function Kg(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),Ug(Wg(e,`/api/v1/transcript?${i}`),r)}function qg(e,t,n){return Ug(Wg(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function Jg(e,t,n){return Ug(Wg(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function Yg(e,t,n,r){return Ug(Wg(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function Xg(e,t,n,r){return Ug(Wg(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function Zg(e,t,n,r){return Ug(Wg(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function Qg(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return Ug(Wg(e,`/api/v1/source-reverts/${encodeURIComponent(t)}${i}`),r)}function $g(e,t){return Ug(Wg(e,`/api/v1/commit-summary`),t)}function e_(e,t,n){return Ug(Wg(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function t_(e,t){return Ug(Wg(e,`/api/v1/connections`),t)}async function n_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/session-connections`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}function r_(e,t){return Ug(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function i_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/runtime-commands`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function a_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}/cancel`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"X-Piagent-CSRF":n}});if(!r.ok)throw new kg(r.status);return await r.json()}function o_(e,t){return Ug(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function s_(e,t,n){return Ug(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function c_(e,t,n){return Ug(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function l_(e,t,n){return Ug(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function u_(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return Ug(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function d_(e){return Ug(`/api/v1/commit-summary`,e)}function f_(e){return Ug(`/api/v1/tasks`,e)}function p_(e,t){return Ug(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function m_(e,t){return Ug(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function h_(e,t){return Ug(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function g_(e,t){return Ug(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function __(e){return Ug(`/api/v1/monitoring/release`,e)}function v_(e,t){return Ug(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function y_(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),Ug(`/api/v1/transcript?${r}`,n)}function b_(e){return Ug(`/api/v1/chat/queue`,e)}function x_(e){return Ug(`/api/v1/session-options/models`,e)}function S_(e,t){return Ug(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function C_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/approvals/${encodeURIComponent(e.approvalRef)}/decision`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function w_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/chat/messages`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function T_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/session-options`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function E_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/lifecycle`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function D_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/control/resume-and-continue`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function O_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/reviews`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function k_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function A_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function j_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/source-handoffs`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function M_(e,t,n){let r=_g();if(!r)throw new kg(403);let i=await vg(`/api/v1/sessions/${encodeURIComponent(e)}/attachments`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r},body:JSON.stringify(t)});if(!i.ok)throw new kg(i.status);return await i.json()}function N_(e,t){return Ug(e?Wg(e,`/api/v1/documents`):`/api/v1/documents`,t)}function P_(e,t,n){let r=`/api/v1/documents/${encodeURIComponent(t)}`;return Ug(e?Wg(e,r):r,n)}async function F_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/attachments`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}function I_(e,t,n){return Ug(`/api/v1/projects/${encodeURIComponent(e)}/paths?query=${encodeURIComponent(t)}`,n)}function L_(e,t){return Ug(`/api/v1/projects/${encodeURIComponent(e)}/commands`,t)}function R_(e,t){return Ug(`/api/v1/sessions/${encodeURIComponent(e)}/questions`,t)}async function z_(e,t,n,r){let i=_g();if(!i)throw new kg(403);let a=await vg(`/api/v1/sessions/${encodeURIComponent(e)}/questions/${encodeURIComponent(t)}/answer`,{method:`POST`,credentials:`same-origin`,signal:r,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":i},body:JSON.stringify(n)});if(!a.ok)throw new kg(a.status)}var B_=class extends Error{status;code;detail;constructor(e,t,n){super(t),this.status=e,this.code=t,this.detail=n}};function V_(e,t){return Ug(`/api/v1/projects/${encodeURIComponent(e)}/branches`,t)}async function H_(e,t,n){let r=_g();if(!r)throw new B_(403,`mutation-authority-rejected`,null);let i=await vg(`/api/v1/projects/${encodeURIComponent(e)}/branches/switch`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r},body:JSON.stringify(t)});if(i.status===401&&Og(),!i.ok){let e=`branch-request-${i.status}`,t=null;try{let n=await i.json();typeof n.error?.code==`string`&&(e=n.error.code),typeof n.error?.detail==`string`&&(t=n.error.detail)}catch{}throw new B_(i.status,e,t)}return await i.json()}function U_(e){return Array.isArray(e)?`[${e.map(U_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${U_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function W_(e){let t=new TextEncoder().encode(typeof e==`string`?e:U_(e)),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function G_(e,t,n,r){let i=new Date,a=new Date(i.getTime()+3e5),o=r?.attachmentRefs??[],s={messageRequestId:r?.messageRequestId??`message-request.${crypto.randomUUID()}`,capabilityAction:n===`steer`?`interruptAndSend`:n===`hold`?`hold`:`send`,delivery:n,text:t,attachmentRefs:o,contentDigest:await W_({attachmentRefs:o,text:t})},c={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},l={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:i.toISOString(),expiresAt:a.toISOString(),capabilityScope:`control.chat`,action:`chat.send`,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:c,payload:s};return l.actionDigest=await W_({action:l.action,identity:l.identity,expectedRevisions:c,payload:s}),l}async function K_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5);return{schemaVersion:1,version:`piagent-webui-attachment-v1`,messageType:`stage-command`,commandId:`attachment-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),identity:{...structuredClone(e.identity),toolCallId:null},expectedRuntimeRevision:e.revision.runtimeRevision,messageRequestId:t,file:n}}function q_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5);return{schemaVersion:1,version:`piagent-webui-attachment-v1`,messageType:`discard-command`,commandId:`attachment-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),identity:{...structuredClone(e.identity),toolCallId:null},expectedRuntimeRevision:e.revision.runtimeRevision,messageRequestId:t,attachmentRef:n}}async function J_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},o={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.chat`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:a,payload:n};return o.actionDigest=await W_({action:t,identity:o.identity,expectedRevisions:a,payload:n}),o}async function Y_(e,t){let n=[];return{queueItemRef:e,text:t,attachmentRefs:n,contentDigest:await W_({attachmentRefs:n,text:t})}}async function X_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},o=t===`session-options.set-model`?{modelRef:n,effectScopeAcknowledged:`session-and-user-default`}:{thinkingLevel:n,effectScopeAcknowledged:`session-and-user-default`},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.sessionOptions`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:a,payload:o};return s.actionDigest=await W_({action:t,identity:s.identity,expectedRevisions:a,payload:o}),s}async function Z_(e,t){let n=new Date,r=new Date(n.getTime()+3e5),i={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},a=t===`lifecycle.stop`?{requestedScope:`current-agent-operation`}:t===`lifecycle.pause`?{safePointPolicy:`after-current-atomic-unit`}:{},o={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.toISOString(),capabilityScope:`control.lifecycle`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:i,payload:a};return o.actionDigest=await W_({action:t,identity:o.identity,expectedRevisions:i,payload:a}),o}async function Q_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a=n?.attachmentRefs??[],o={messageRequestId:n?.messageRequestId??`message-request.${crypto.randomUUID()}`,capabilityAction:`send`,delivery:`new-operation`,text:t,attachmentRefs:a,contentDigest:await W_({attachmentRefs:a,text:t})},s={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.resumeAndContinue`,action:`lifecycle.resume-and-continue`,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:s,payload:o};return c.actionDigest=await W_({action:c.action,identity:c.identity,expectedRevisions:s,payload:o}),c}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 ev(e){let t=new TextEncoder().encode($_(e)),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function tv(e,t,n){if(!t.target||t.state===`unavailable`)throw Error(`review-target-unavailable`);let r=new Date,i=new Date(r.getTime()+3e5),a=t.target,o={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},s={runtimeRevision:e.revision.runtimeRevision,taskRevision:a.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:a.workspaceRevision,indexRevision:a.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:a.patchPreimage},c={view:a.view,fileRef:a.fileRef,diffRef:a.diffRef,reviewState:n,contentDigest:a.contentDigest},l={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`review-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`reviewActions`,action:`review.mark`,actionDigest:``,identity:o,expectedRevisions:s,payload:c};return l.actionDigest=await ev({action:l.action,identity:o,expectedRevisions:s,payload:c}),l}function nv(e){return Array.isArray(e)?`[${e.map(nv).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${nv(t)}`).join(`,`)}}`:JSON.stringify(e)}async function rv(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(nv(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function iv(e,t,n=[]){if(t.state!==`ready`||!t.target)throw Error(`source-mutation-preview-unavailable`);let r=new Date,i=t.target,a={...structuredClone(e.identity),agentOperationId:null,toolCallId:null};if(n.length>128||new Set(n).size!==n.length||n.some(e=>!i.hunkRefs.includes(e))||nv(n)!==nv(i.hunkRefs.filter(e=>n.includes(e))))throw Error(`source-mutation-hunk-unavailable`);let o={runtimeRevision:e.revision.runtimeRevision,taskRevision:i.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:i.workspaceRevision,indexRevision:i.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:i.workspacePreimage,indexPreimage:i.indexPreimage,patchPreimage:i.patchPreimage},s={fileRef:i.fileRef,hunkRefs:[...n],contentDigest:i.contentDigest},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-mutation.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:new Date(r.getTime()+3e5).toISOString(),capabilityScope:`reviewActions`,action:t.action,actionDigest:``,identity:a,expectedRevisions:o,payload:s};return c.actionDigest=await rv({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}function av(e){return Array.isArray(e)?`[${e.map(av).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${av(t)}`).join(`,`)}}`:JSON.stringify(e)}async function ov(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(av(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function sv(e,t){if(t.state!==`ready`||!t.target)throw Error(`source-revert-preview-unavailable`);let n=new Date,r=t.target;if(Date.parse(r.expiresAt)<=n.getTime())throw Error(`source-revert-preview-expired`);let i={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},a={runtimeRevision:e.revision.runtimeRevision,taskRevision:r.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:r.workspaceRevision,indexRevision:r.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:r.workspacePreimage,indexPreimage:r.indexPreimage,patchPreimage:r.patchPreimage},o={fileRef:r.fileRef,hunkRefs:[...r.hunkRefs],previewRef:r.previewRef,confirmedPreviewDigest:r.confirmedPreviewDigest,contentDigest:r.contentDigest},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-revert.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.expiresAt,capabilityScope:`reviewActions`,action:`source.revert`,actionDigest:``,identity:i,expectedRevisions:a,payload:o};return s.actionDigest=await ov({action:s.action,identity:i,expectedRevisions:a,payload:o}),s}function cv(e){return Array.isArray(e)?`[${e.map(cv).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${cv(t)}`).join(`,`)}}`:JSON.stringify(e)}async function lv(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(cv(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function uv(e,t,n=null,r=null){if(!e.identity.taskId||!e.identity.taskRunId||!e.revision.taskRevision||!e.revision.workspaceRevision)throw Error(`source-open-task-authority-unavailable`);if(r!==null&&n===null)throw Error(`source-open-location-invalid`);let i=new Date,a={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},o={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},s={fileRef:t,line:n,column:r},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-open.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),capabilityScope:`reviewActions`,action:`source.open-in-vscode`,actionDigest:``,identity:a,expectedRevisions:o,payload:s};return c.actionDigest=await lv({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}var dv=new Set(`as.async.await.break.case.catch.class.const.continue.def.delete.do.else.enum.export.extends.finally.for.from.function.if.implements.import.in.interface.let.new.of.package.private.protected.public.return.static.struct.switch.throw.try.type.var.while.with.yield`.split(`.`)),fv=new Set([`false`,`nil`,`null`,`None`,`true`,`undefined`]),pv=new Set([`py`,`rb`,`sh`,`bash`,`zsh`,`yaml`,`yml`,`toml`]);function mv(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<0?``:t.slice(n+1).toLowerCase()}function hv(e){return/[A-Za-z_$]/.test(e)}function gv(e){return/[A-Za-z0-9_$-]/.test(e)}function _v(e){return e>=`0`&&e<=`9`}function vv(e,t,n){if(!n)return;let r=e[e.length-1];r?.kind===t?r.text+=n:e.push({kind:t,text:n})}function yv(e,t){let n=[],r=mv(t),i=0;for(;i<e.length;){if(e.startsWith(`//`,i)||e.startsWith(`/*`,i)||e[i]===`#`&&pv.has(r)){vv(n,`comment`,e.slice(i));break}let t=e[i]??``;if(t===`"`||t===`'`||t==="`"){let r=t,a=i+1;for(;a<e.length;){if(e[a]===`\\`){a+=2;continue}if(e[a]===r){a+=1;break}a+=1}let o=e.slice(i,a);vv(n,e.slice(a).match(/^\s*:/)&&r===`"`?`property`:`string`,o),i=a;continue}if(_v(t)||t===`.`&&_v(e[i+1]??``)){let t=i+1;for(;t<e.length&&/[0-9A-Fa-f_xXob.+-]/.test(e[t]??``);)t+=1;vv(n,`number`,e.slice(i,t)),i=t;continue}if(hv(t)){let t=i+1;for(;t<e.length&&gv(e[t]??``);)t+=1;let r=e.slice(i,t);vv(n,dv.has(r)?`keyword`:fv.has(r)?`literal`:`plain`,r),i=t;continue}vv(n,`plain`,t),i+=1}return n}var bv=[{view:`task`,label:`Thay đổi của task`,shortLabel:`Task`},{view:`working-tree`,label:`Toàn bộ working tree`,shortLabel:`Working Tree`},{view:`staged`,label:`Đã chuẩn bị commit`,shortLabel:`Staged`}];function xv(e){return e===`vi`?bv:[{view:`task`,label:`Task Changes`,shortLabel:`Task`},{view:`working-tree`,label:`Full Working Tree`,shortLabel:`Working Tree`},{view:`staged`,label:`Staged Changes`,shortLabel:`Staged`}]}var Sv={"pre-existing-user":`Có sẵn trước task`,"runtime-observed-agent":`Pi runtime đã chạm`,"post-baseline-unattributed":`Thay đổi sau baseline · chưa rõ nguồn`,mixed:`Trộn thay đổi người dùng và runtime`};function Cv(e,t=`vi`){return t===`vi`?Sv[e.provenance.classification]:{"pre-existing-user":`Pre-existing user change`,"runtime-observed-agent":`Runtime-observed agent touch`,"post-baseline-unattributed":`Post-baseline · unattributed`,mixed:`Mixed user and runtime change`}[e.provenance.classification]}function wv(e,t=`vi`){return e.stats.state===`exact`?`+${e.stats.additions??0} −${e.stats.deletions??0}`:t===`vi`?`Dòng thay đổi chưa xác định`:`Line changes unavailable`}function Tv(e,t=`vi`){let n=e.page.total;return e.availability.state===`stale`?t===`vi`?`Đang đồng bộ lại…`:`Resynchronizing…`:e.availability.state===`unavailable`?e.availability.message??(t===`vi`?`Nguồn thay đổi chưa sẵn sàng`:`Source changes unavailable`):n===0?t===`vi`?`Không có file thay đổi`:`No changed files`:t===`vi`?`${n} file${e.page.truncated?` · danh sách đã rút gọn`:``}`:`${n} file${n===1?``:`s`}${e.page.truncated?` · list truncated`:``}`}function Ev(e,t=`vi`){return t===`vi`?`${e.criterionIds.length} tiêu chí · ${e.verifierAttemptIds.length} verifier`:`${e.criterionIds.length} criteria · ${e.verifierAttemptIds.length} verifiers`}function Dv(e,t){return[t.projectRef,t.runtimeInstanceId,t.sessionRef,t.taskId??`no-task`,t.taskRunId??`no-run`,e.sourceProjectionRevision??`no-source-projection-revision`,e.taskViewRevision??`no-task-view-revision`,e.workspaceRevision??`no-workspace-revision`,e.indexRevision??`no-index-revision`].join(``)}function Ov(e,t,n,r){if(!e||e.view!==t||e.availability.state===`stale`||e.identity.projectRef!==r.projectRef||e.identity.runtimeInstanceId!==r.runtimeInstanceId||e.identity.sessionRef!==r.sessionRef||e.identity.taskId!==r.taskId||e.identity.taskRunId!==r.taskRunId)return!1;let i=t===`task`?n.taskViewRevision:t===`working-tree`?n.workspaceRevision:n.indexRevision;if(!(i===null?e.availability.state===`unavailable`:e.viewRevision===i))return!1;let a=e.snapshotBinding;return a?n.sourceProjectionRevision!==null&&a.sourceProjectionRevision===n.sourceProjectionRevision&&a.taskViewRevision===n.taskViewRevision&&a.workspaceRevision===n.workspaceRevision&&a.indexRevision===n.indexRevision:n.sourceProjectionRevision===null}function kv(e,t){if(!e||e.state!==`unavailable`||e.target!==null||!e.reasonCode)return!1;let n=t?.availability.state===`current`&&t.fallback.kind===`none`;return e.reasonCode===`review-target-unavailable`?n:e.reasonCode===`no-unstaged-change`||e.reasonCode===`no-staged-change`?n&&t.hunks.length>0:[`-target-stale`,`-preview-incomplete`,`-preimage-unavailable`,`-authority-unavailable`].some(t=>e.reasonCode.endsWith(t))}function Av(e,t,n,r,i,a){return t===n&&Ov(e,a,r,i)?e??null:null}function jv(e,t,n,r,i,a){let o=e?.identity;return!!(e&&o&&o.projectRef===a.identity.projectRef&&o.runtimeInstanceId===a.identity.runtimeInstanceId&&o.sessionRef===a.identity.sessionRef&&o.taskId===a.identity.taskId&&o.taskRunId===a.identity.taskRunId&&e.view===t&&e.file.fileRef===n&&e.file.fileRevision===i&&e.precondition.expectedViewRevision===r&&e.precondition.expectedFileRevision===i&&e.observed.viewRevision===r&&e.observed.fileRevision===i&&e.availability.state!==`stale`&&e.fallback.kind!==`stale`)}function Mv(e,t){return t&&e.some(e=>e.fileRef===t)?t:e[0]?.fileRef??null}var Nv={active:`Đang hoạt động`,"pause-requested":`Đang yêu cầu tạm dừng`,paused:`Đã tạm dừng`,terminal:`Đã kết thúc`,idle:`Đang chờ`,running:`Đang chạy`,stopping:`Đang dừng`,settled:`Đã ổn định`,unknown:`Chưa xác định`,pending:`Chưa xong`,completed:`Hoàn thành`,blocked:`Bị chặn`,partial:`Một phần`,failed:`Thất bại`,satisfied:`Đã đạt`,unavailable:`Không có dữ liệu`,connected:`Đã kết nối`,disconnected:`Mất kết nối`,reconnecting:`Đang kết nối lại`,"resync-required":`Cần đồng bộ lại`,none:`Không có`,waiting:`Đang chờ duyệt`,current:`Mới nhất`,stale:`Đã cũ`,"not-run":`Chưa chạy`,"in-progress":`Đang làm`,done:`Đã xong`,skipped:`Bỏ qua`,resume:`Tiếp tục`,retry:`Thử lại`,observed:`Đã ghi nhận`,requested:`Đã yêu cầu`,"possible-interruption":`Có thể bị gián đoạn`,complete:`Đầy đủ`,"aggregate-only":`Chỉ có dữ liệu tổng hợp`,off:`Tắt`,minimal:`Tối thiểu`,low:`Thấp`,medium:`Trung bình`,high:`Cao`,xhigh:`Rất cao`,max:`Tối đa`,orphaned:`Mất owner`,cancelled:`Đã hủy`,succeeded:`Thành công`,"stale-result":`Kết quả đến muộn`,accepted:`Đã nhận`,rejected:`Không nhận`,"not-recorded":`Chưa có kết quả`,parent:`Task cha`,helper:`Helper`,"read-only":`Chỉ đọc`,"workspace-write":`Ghi trong project`,"trusted-full-access":`Toàn quyền`,"single-writer":`Một writer`,retriever:`Retriever`,scout:`Scout`,planner:`Planner`,worker:`Worker`,reviewer:`Reviewer`,oracle:`Oracle`,researcher:`Researcher`,ready:`Sẵn sàng`,missing:`Chưa có bằng chứng`,interrupted:`Bị gián đoạn`,stopped:`Đã dừng`,aborted:`Đã hủy do lỗi`,incomplete:`Chưa có kết luận`,passed:`Đạt`,"not-applicable":`Không áp dụng`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"pdf-text-unavailable":`PDF này không có text bóc được; nhiều khả năng là bản scan, cần OCR trước`,"pdf-extraction-failed":`Không chuyển được PDF này sang text`,"docx-unreadable":`File .docx này hỏng, bị mã hóa, hoặc không phải file Word thật`,"document-text-empty":`Tài liệu không có chữ nào để đọc`,"document-size-limit":`Tài liệu vượt giới hạn dung lượng`,"text-size-limit":`File text vượt giới hạn dung lượng`,"text-content-invalid":`File có đuôi text nhưng nội dung không phải text`,"image-mime-mismatch":`Nội dung ảnh không khớp với đuôi file`,"model-image-input-unavailable":`Model hiện tại không nhận ảnh`,"attachment-capacity-limit":`Đã chạm giới hạn số file hoặc dung lượng đính kèm`,"no-readable-root":`Chưa có thư mục nào đọc được`,"document-roots-unavailable":`Không xác định được thư mục tài liệu`,"document-not-listed":`Tài liệu không còn trong danh sách; hãy tải lại`,"document-unavailable":`Không mở được tài liệu này`,"document-protected":`Tài liệu nằm trong protectedPaths nên không được đọc`,"document-changed":`File đã thay đổi sau khi liệt kê; chưa đọc gì cả`,"document-unreadable":`Không đọc được nội dung tài liệu`,"document-needs-ocr":`Tài liệu là bản scan, cần OCR trước khi đọc được chữ`,"document-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"session-command-effect-unknown":`Pi đã nhận yêu cầu nhưng đang đồng bộ trạng thái; không gửi lại để tránh chạy trùng`},Pv={active:`Active`,"pause-requested":`Pause requested`,paused:`Paused`,terminal:`Finished`,idle:`Idle`,running:`Running`,stopping:`Stopping`,settled:`Settled`,unknown:`Unknown`,pending:`Pending`,completed:`Completed`,blocked:`Blocked`,partial:`Partial`,failed:`Failed`,satisfied:`Satisfied`,unavailable:`Unavailable`,connected:`Connected`,disconnected:`Disconnected`,reconnecting:`Reconnecting`,"resync-required":`Resync required`,none:`None`,waiting:`Awaiting approval`,current:`Current`,stale:`Stale`,"not-run":`Not run`,"in-progress":`In progress`,done:`Done`,skipped:`Skipped`,resume:`Resume`,retry:`Retry`,observed:`Observed`,requested:`Requested`,"possible-interruption":`Possible interruption`,complete:`Complete`,"aggregate-only":`Aggregate only`,off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,orphaned:`Owner missing`,cancelled:`Cancelled`,succeeded:`Succeeded`,"stale-result":`Stale result`,accepted:`Accepted`,rejected:`Rejected`,"not-recorded":`Not recorded`,parent:`Parent task`,helper:`Helper`,"read-only":`Read only`,"workspace-write":`Workspace write`,"trusted-full-access":`Full access`,"single-writer":`Single writer`,retriever:`Retriever`,scout:`Scout`,planner:`Planner`,worker:`Worker`,reviewer:`Reviewer`,oracle:`Oracle`,researcher:`Researcher`,ready:`Ready`,missing:`Evidence missing`,interrupted:`Interrupted`,stopped:`Stopped`,aborted:`Aborted`,incomplete:`Incomplete`,passed:`Passed`,"not-applicable":`Not applicable`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"pdf-text-unavailable":`This PDF holds no extractable text; it is probably scanned and needs OCR first`,"pdf-extraction-failed":`The PDF could not be converted to text`,"docx-unreadable":`This .docx is corrupt, encrypted, or not really a Word document`,"document-text-empty":`The document contains no readable text`,"document-size-limit":`The document is over the size limit`,"text-size-limit":`The text file is over the size limit`,"text-content-invalid":`The file has a text extension but its bytes are not text`,"image-mime-mismatch":`The image content does not match its file extension`,"model-image-input-unavailable":`The current model does not accept images`,"attachment-capacity-limit":`The attachment count or size limit was reached`,"no-readable-root":`No readable directory is available`,"document-roots-unavailable":`The document directories could not be resolved`,"document-not-listed":`The document is no longer listed; reload the list`,"document-unavailable":`This document could not be opened`,"document-protected":`The document is under protectedPaths and is not readable`,"document-changed":`The file changed after it was listed; nothing was read`,"document-unreadable":`The document content could not be read`,"document-needs-ocr":`The document is scanned and needs OCR before it holds text`,"document-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"session-command-effect-unknown":`Pi received the request and is resyncing; do not resend it, to avoid a duplicate run`};function Fv(e,t=`vi`){return e?(t===`vi`?Nv:Pv)[e]??e.replaceAll(`-`,` `):t===`vi`?`Chưa có`:`Not available`}function Iv(e){return[`completed`,`satisfied`,`current`,`connected`,`done`,`passed`].includes(e??``)?`positive`:[`blocked`,`failed`,`error`,`expired`].includes(e??``)?`danger`:[`pause-requested`,`paused`,`waiting`,`stale`,`stale-result`,`orphaned`,`partial`,`reconnecting`].includes(e??``)?`warning`:[`running`,`active`,`in-progress`].includes(e??``)?`info`:`neutral`}function Lv(e){return e?e.length>22?`${e.slice(0,10)}…${e.slice(-7)}`:e:`—`}function Rv(e,t=`vi`){return e.session.model.state===`known`&&e.session.model.value?e.session.model.value.displayName:t===`vi`?`Model chưa xác định`:`Unknown model`}function zv(e,t=`vi`){return e.session.thinking.state===`known`&&e.session.thinking.value?Fv(e.session.thinking.value,t):t===`vi`?`Chưa xác định`:`Unknown`}function Bv(e,t=`vi`){let n=e.session.permissionProfile;return n.state===`known`&&n.value?Fv(n.value,t):t===`vi`?`Quyền chưa xác định`:`Unknown permission`}function Vv(e,t=`vi`){let n=e.relatedFileRefs.length,r=e.verifierAttemptRefs.length;return!n&&!r?t===`vi`?`Chưa có bằng chứng liên kết`:`No linked evidence`:t===`vi`?`${n} file · ${r} lần kiểm tra`:`${n} files · ${r} verifier runs`}function Hv(e,t=`vi`){let n=e.task;return n?{completed:n.progress.completed,total:n.progress.total,percent:Math.max(0,Math.min(100,n.progress.percent)),text:t===`vi`?`${n.progress.completed}/${n.progress.total} tiêu chí`:`${n.progress.completed}/${n.progress.total} criteria`}:{completed:0,total:0,percent:0,text:t===`vi`?`Chưa có task đang chạy`:`No active task`}}var Uv=(0,v.createContext)(null);function Wv({value:e,children:t}){return(0,U.jsx)(Uv.Provider,{value:e,children:t})}function Gv(){let e=(0,v.useContext)(Uv);if(!e)throw Error(`Piagent UI preferences are missing`);return e}function Q(e,t,n){return e===`vi`?t:n}function Kv(e){let t=e?.target;return t?[t.view,t.fileRef,t.diffRef,t.taskRevision,t.workspaceRevision,t.indexRevision??``,t.viewRevision,t.fileRevision,t.patchPreimage,t.contentDigest].join(``):`no-target`}function qv(e){return e?[Kv(e),e.state,e.recordedState??``,e.recordedAt??``,e.evidenceRef??``].join(``):`no-review-state`}function Jv(e,t){return e.identity.projectRef===t.identity.projectRef&&e.identity.runtimeInstanceId===t.identity.runtimeInstanceId&&e.identity.sessionRef===t.identity.sessionRef&&e.identity.taskId===t.identity.taskId&&e.identity.taskRunId===t.identity.taskRunId&&e.identity.agentOperationId===t.identity.agentOperationId&&e.identity.toolCallId===t.identity.toolCallId}function Yv(e,t,n,r){return t.phase===`settled`&&t.resultCode===n&&t.action===`review.mark`&&t.commandId===e.commandId&&t.actionDigest===e.actionDigest&&t.idempotencyKeyDigest===r&&Jv(e,t)&&typeof t.settledAt==`string`&&typeof t.settlementEvidenceRef==`string`}function Xv(e,t){return!!(e&&e.projectRef===t.projectRef&&e.runtimeInstanceId===t.runtimeInstanceId&&e.sessionRef===t.sessionRef&&e.taskId===t.taskId&&e.taskRunId===t.taskRunId)}function Zv(e,t,n,r,i,a){return e.view===t&&e.fileRef===n&&e.taskRevision===a.revision.taskRevision&&e.workspaceRevision===a.sourceChanges.workingTree.revision&&e.indexRevision===a.sourceChanges.staged.revision&&e.viewRevision===r&&e.fileRevision===i}function Qv(e,t,n,r,i,a,o){return!e||!Xv(e.identity,a.identity)?!1:e.target?Zv(e.target,t,n,r,i,a):e.state===`unavailable`&&!kv(e,o)}async function $v(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function ey({state:e,busy:t,status:n,deterministicEnabled:r,modelEnabled:i,locale:a,onGenerate:o,onCopy:s,onModel:c}){let l=e.value?.state===`ready`?e.value.summary:null;return(0,U.jsxs)(`section`,{className:`commit-summary-panel`,"aria-labelledby":`commit-summary-title`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Commit summary`}),(0,U.jsx)(`h3`,{id:`commit-summary-title`,children:Q(a,`Tóm tắt phần đã stage`,`Staged changes summary`)}),(0,U.jsx)(`span`,{children:Q(a,`Bản deterministic dùng 0 model token. Không commit hoặc push.`,`The deterministic version uses 0 model tokens. It does not commit or push.`)})]}),l?(0,U.jsxs)(`div`,{className:`commit-summary-output`,children:[(0,U.jsx)(`strong`,{children:l.title}),l.bodyLines.map((e,t)=>(0,U.jsx)(`code`,{children:e},`${l.summaryRef}.${t}`)),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`button`,{type:`button`,onClick:s,children:`Copy`}),(0,U.jsx)(`button`,{type:`button`,disabled:!i||t,onClick:c,children:Q(a,`Nhờ Pi viết lại · tốn model token`,`Ask Pi to rewrite · uses model tokens`)})]})]}):(0,U.jsx)(`button`,{type:`button`,disabled:!r||t,onClick:o,children:t?Q(a,`Đang tạo…`,`Generating…`):Q(a,`Tạo summary · 0 token`,`Generate summary · 0 tokens`)}),n&&(0,U.jsx)(`p`,{className:`commit-summary-status`,role:`status`,children:n})]})}function ty({file:e,selected:t,onSelect:n,locale:r}){let i=e.path.lastIndexOf(`/`),a=i<0?e.path:e.path.slice(i+1);return(0,U.jsxs)(cf,{component:`button`,className:`file-row`,selected:t,"data-selected":t,onClick:n,type:`button`,"aria-label":`${e.status} ${e.path} ${wv(e,r)}`,"aria-pressed":t,children:[(0,U.jsx)(`span`,{className:`file-status status-${e.status}`,children:e.status}),(0,U.jsxs)(`span`,{className:`file-name`,children:[(0,U.jsx)(`strong`,{children:a}),e.oldPath&&(0,U.jsxs)(`small`,{children:[Q(r,`từ`,`from`),` `,e.oldPath]})]}),(0,U.jsx)(`span`,{className:`file-provenance`,children:Cv(e,r)}),(0,U.jsx)(`span`,{className:`file-evidence`,children:Ev(e,r)}),(0,U.jsx)(`span`,{className:`file-stats`,children:wv(e,r)})]})}function ny({text:e,path:t}){return(0,U.jsx)(U.Fragment,{children:yv(e,t).map((e,t)=>(0,U.jsx)(`span`,{className:`syntax-${e.kind}`,children:e.text},`${t}.${e.kind}`))})}function ry({line:e,side:t,path:n}){let r=e.oldLineNumber??``,i=e.newLineNumber??``;if(t===`inline`)return(0,U.jsxs)(`div`,{className:`diff-line diff-${e.kind}`,children:[(0,U.jsx)(`span`,{children:r}),(0,U.jsx)(`span`,{children:i}),(0,U.jsx)(`b`,{children:e.marker}),(0,U.jsx)(`code`,{children:(0,U.jsx)(ny,{text:e.text,path:n})})]});let a=e.kind===`added`?``:e.text,o=e.kind===`deleted`?``:e.text;return(0,U.jsxs)(`div`,{className:`split-line diff-${e.kind}`,children:[(0,U.jsx)(`span`,{children:r}),(0,U.jsx)(`code`,{children:(0,U.jsx)(ny,{text:a,path:n})}),(0,U.jsx)(`span`,{children:i}),(0,U.jsx)(`code`,{children:(0,U.jsx)(ny,{text:o,path:n})})]})}function iy({state:e,review:t,mutation:n,revert:r,reviewEnabled:i,reviewBusy:a,reviewError:o,mutationEnabled:s,mutationBusy:c,mutationError:l,revertEnabled:u,revertBusy:d,openEnabled:f,openBusy:p,openStatus:m,detailError:h,mode:g,onMode:_,onReview:v,onMutation:y,onRevert:b,onOpen:x,onRetry:S,locale:C}){if(e.state===`idle`)return(0,U.jsx)(`div`,{className:`diff-empty`,children:(0,U.jsx)(`p`,{children:Q(C,`Chọn một file để xem diff và bằng chứng liên quan.`,`Select a file to inspect its diff and related evidence.`)})});if(e.state===`loading`)return(0,U.jsx)(`div`,{className:`diff-empty`,children:(0,U.jsx)(`p`,{children:Q(C,`Đang dựng diff từ Git và task baseline…`,`Building the diff from Git and the task baseline…`)})});if(e.state===`error`||!e.value)return(0,U.jsxs)(`div`,{className:`diff-empty error-state`,children:[(0,U.jsx)(`p`,{children:Q(C,`Diff chưa thể đồng bộ với revision hiện tại.`,`The diff could not be reconciled with the current revision.`)}),S&&(0,U.jsx)(`button`,{type:`button`,onClick:S,children:Q(C,`Thử đồng bộ lại`,`Retry reconciliation`)})]});let w=e.value;return(0,U.jsxs)(J,{className:`diff-viewer`,sx:{minWidth:0,bgcolor:`background.paper`},children:[(0,U.jsxs)(J,{component:`header`,className:`diff-toolbar`,sx:{position:`sticky`,top:0,zIndex:2,bgcolor:`background.paper`},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:w.file.path}),(0,U.jsx)(lu,{size:`small`,variant:`outlined`,className:`access-badge tone-${Iv(w.availability.state)}`,label:Fv(w.availability.state,C)})]}),(0,U.jsxs)(`div`,{className:`diff-actions`,children:[t.state===`ready`&&t.value&&(0,U.jsxs)(`div`,{className:`review-state review-${t.value.state}`,children:[(0,U.jsx)(`span`,{children:t.value.state===`reviewed`?Q(C,`Đã review`,`Reviewed`):t.value.state===`stale`?Q(C,`Review đã cũ`,`Review stale`):t.value.state===`unavailable`?Q(C,`Không thể review`,`Review unavailable`):Q(C,`Chưa review`,`Not reviewed`)}),t.value.target&&t.value.state!==`unavailable`&&(0,U.jsx)(`button`,{type:`button`,disabled:!i||a,onClick:()=>v(t.value.state===`reviewed`?`unreviewed`:`reviewed`),children:a?Q(C,`Đang ghi…`,`Saving…`):t.value.state===`reviewed`?Q(C,`Bỏ dấu review`,`Mark unreviewed`):t.value.state===`stale`?Q(C,`Review lại`,`Review again`):Q(C,`Đánh dấu đã review`,`Mark reviewed`)})]}),n.state===`ready`&&n.value?.state===`ready`&&n.value.target&&(0,U.jsxs)(`div`,{className:`source-mutation-preview`,children:[(0,U.jsx)(`span`,{children:n.value.action===`source.stage`?Q(C,`Chuẩn bị đúng thay đổi file này để commit`,`Prepare this exact file change for commit`):Q(C,`Bỏ khỏi vùng commit; giữ nguyên file đang làm việc`,`Remove from commit while keeping the working file`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>y([]),children:c?Q(C,`Đang cập nhật Git…`,`Updating Git…`):n.value.action===`source.stage`?`Stage file`:`Unstage file`})]}),r.state===`ready`&&r.value?.state===`ready`&&r.value.target&&(0,U.jsxs)(`div`,{className:`source-revert-preview`,children:[(0,U.jsx)(`span`,{children:Q(C,`Hoàn tác phần chưa stage; giữ nguyên index`,`Revert unstaged changes while preserving the index`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!u||d,onClick:()=>b(null),children:d?Q(C,`Đang dựng preview…`,`Building preview…`):`Revert file`})]}),f&&(0,U.jsx)(`div`,{className:`source-open-action`,children:(0,U.jsx)(`button`,{type:`button`,disabled:p,onClick:x,children:p?Q(C,`Đang mở…`,`Opening…`):Q(C,`Mở trong VS Code`,`Open in VS Code`)})}),(0,U.jsxs)(op,{className:`mode-switch`,exclusive:!0,size:`small`,value:g,"aria-label":Q(C,`Kiểu hiển thị diff`,`Diff layout`),onChange:(e,t)=>t&&_(t),children:[(0,U.jsx)(ep,{value:`inline`,"aria-label":`Inline`,children:`Inline`}),(0,U.jsx)(ep,{value:`split`,"aria-label":Q(C,`Hai cột`,`Side by side`),children:Q(C,`Hai cột`,`Side by side`)})]})]})]}),o&&(0,U.jsx)(`div`,{className:`review-error`,role:`status`,children:o}),l&&(0,U.jsx)(`div`,{className:`review-error`,role:`status`,children:l}),m&&(0,U.jsx)(`div`,{className:`source-open-status`,role:`status`,children:m}),h&&(0,U.jsxs)(`div`,{className:`detail-reconciliation-warning`,role:`status`,children:[(0,U.jsx)(`span`,{children:Q(C,`Một thao tác source chưa đồng bộ; diff hiện tại vẫn chính xác.`,`A source action is not reconciled yet; the current diff remains exact.`)}),S&&(0,U.jsx)(`button`,{type:`button`,onClick:S,children:Q(C,`Thử đồng bộ lại`,`Retry reconciliation`)})]}),(0,U.jsxs)(`div`,{className:`diff-context`,children:[(0,U.jsx)(`span`,{children:Cv(w.file,C)}),(0,U.jsx)(`span`,{children:Ev(w.file,C)}),(0,U.jsxs)(`span`,{className:`additions`,children:[`+`,w.file.stats.additions??`?`]}),(0,U.jsxs)(`span`,{className:`deletions`,children:[`−`,w.file.stats.deletions??`?`]})]}),w.fallback.kind!==`none`&&(0,U.jsxs)(`div`,{className:`diff-fallback`,children:[(0,U.jsx)(`strong`,{children:Fv(w.fallback.kind,C)}),(0,U.jsx)(`span`,{children:w.fallback.message??w.fallback.reasonCode??Q(C,`Nội dung diff không sẵn sàng`,`Diff content unavailable`)})]}),w.hunks.map((e,t)=>(0,U.jsxs)(`section`,{className:`diff-hunk`,"aria-label":`${Q(C,`Vùng thay đổi`,`Change region`)} ${t+1}`,children:[(0,U.jsxs)(`div`,{className:`hunk-header`,children:[(0,U.jsx)(`span`,{children:e.header}),(0,U.jsxs)(`span`,{className:`hunk-actions`,children:[n.value?.state===`ready`&&n.value.target?.hunkRefs.includes(e.hunkRef)&&(0,U.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>y([e.hunkRef]),children:n.value.action===`source.stage`?`Stage hunk`:`Unstage hunk`}),r.value?.state===`ready`&&r.value.target&&r.value.preview?.hunks.some(t=>t.hunkRef===e.hunkRef)&&(0,U.jsx)(`button`,{className:`revert-action`,type:`button`,disabled:!u||d,onClick:()=>b(e.hunkRef),children:`Revert hunk`})]})]}),(0,U.jsx)(`div`,{className:g===`split`?`split-code`:`inline-code`,children:e.lines.map(e=>(0,U.jsx)(ry,{line:e,side:g,path:w.file.path},e.lineRef))}),w.unchangedRegions[t]&&(0,U.jsxs)(`div`,{className:`unchanged-region`,children:[`… `,w.unchangedRegions[t].lineCount,` `,Q(C,`dòng không đổi đã thu gọn`,`unchanged lines collapsed`),` …`]})]},e.hunkRef)),w.truncation.truncated&&(0,U.jsxs)(`div`,{className:`diff-fallback`,children:[(0,U.jsx)(`strong`,{children:Q(C,`Diff đã rút gọn`,`Diff truncated`)}),(0,U.jsxs)(`span`,{children:[Q(C,`Còn`,`Another`),` `,w.truncation.omittedLines,` `,Q(C,`dòng chưa hiển thị.`,`lines are not shown.`)]})]})]})}function ay({snapshot:e,refreshSnapshot:t,sessionRef:n}){let{locale:r}=Gv(),i=!!(e.task&&e.sourceChanges.task?.state!==`unavailable`&&e.sourceChanges.task?.revision),a=(0,v.useMemo)(()=>xv(r),[r]),[o,s]=(0,v.useState)(()=>i?`task`:`working-tree`),[c,l]=(0,v.useState)({}),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)({state:`idle`}),[m,h]=(0,v.useState)({state:`idle`}),[g,_]=(0,v.useState)({state:`idle`}),[y,b]=(0,v.useState)({state:`idle`}),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)(null),[z,B]=(0,v.useState)({state:`idle`}),[V,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(null),[ae,oe]=(0,v.useState)(!1),[se,H]=(0,v.useState)(0),[ce,le]=(0,v.useState)(`inline`),ue={sourceProjectionRevision:e.sourceChanges.projectionRevision??null,taskViewRevision:e.sourceChanges.task.revision,workspaceRevision:e.sourceChanges.workingTree.revision,indexRevision:e.sourceChanges.staged.revision},de=Dv(ue,e.identity),fe=[de,se].join(``),pe=[de,e.revision.taskRevision??`no-task-revision`].join(``),me=[n??`default-session`,o,e.identity.projectRef,e.identity.runtimeInstanceId,e.identity.sessionRef,e.identity.taskId??`no-task`,e.identity.taskRunId??`no-run`].join(``),he=(0,v.useRef)(me);he.current=me;let ge=(0,v.useRef)(0),_e=(0,v.useRef)(me);_e.current!==me&&(_e.current=me,ge.current+=1);let ve=ge.current,ye=(0,v.useRef)(null),be=c[o],xe=be?.state===`ready`?Av(be.value,be.revisionKey,fe,ue,e.identity,o):null,Se=be?.state===`ready`&&!xe?{state:`loading`}:be,Ce=xe?.files??[],we=Mv(Ce,u),Te=we?Ce.find(e=>e.fileRef===we)??null:null,Ee=!!(xe&&Te),De=e.capabilities.capabilities.reviewActions,Oe=JSON.stringify(De),ke=o===`working-tree`?`source.stage`:o===`staged`?`source.unstage`:null,Ae=De.status===`available`&&De.actions.reviewMark.available,je=ke===`source.stage`?De.status===`available`&&De.actions.stage.available:ke===`source.unstage`&&De.status===`available`&&De.actions.unstage.available,Me=o===`working-tree`&&De.status===`available`&&De.actions.revert.available,Ne=Ee?[n??`default-session`,o,we,xe.viewRevision,Te.fileRevision,pe,se,Oe].join(``):`no-detail-request`,Pe=!!(Ee&&f.requestKey===Ne&&f.state===`ready`&&jv(f.value,o,we,xe.viewRevision,Te.fileRevision,e)),Fe=!!(Ee&&m.requestKey===Ne&&m.state===`ready`&&Qv(m.value,o,we,xe.viewRevision,Te.fileRevision,e,Pe?f.value:void 0)),Ie=!!(Ee&&g.requestKey===Ne&&g.state===`ready`&&Qv(g.value,o,we,xe.viewRevision,Te.fileRevision,e,Pe?f.value:void 0)),Le=!!(Ee&&y.requestKey===Ne&&y.state===`ready`&&Qv(y.value,o,we,xe.viewRevision,Te.fileRevision,e,Pe?f.value:void 0)),Re=!!(Ee&&f.requestKey===Ne&&f.state===`ready`&&!Pe),ze=!!(Ee&&m.requestKey===Ne&&m.state===`ready`&&!Fe),Be=!!(Ee&&g.requestKey===Ne&&g.state===`ready`&&!Ie),Ve=!!(Ee&&y.requestKey===Ne&&y.state===`ready`&&!Le),He=!!(Ee&&f.requestKey===Ne&&f.state===`error`),Ue=!!(Ee&&Ae&&m.requestKey===Ne&&m.state===`error`),We=!!(Ee&&je&&g.requestKey===Ne&&g.state===`error`),Ge=!!(Ee&&Me&&y.requestKey===Ne&&y.state===`error`),Ke=Re||ze||Be||Ve||He||Ue||We||Ge,qe=!!(Ee&&Pe&&(!Ae||Fe)&&(!je||Ie)&&(!Me||Le)),Je=(0,v.useRef)(null);we&&(Je.current={sourceScope:me,fileRef:we});let Ye=[me,we??(Je.current?.sourceScope===me?Je.current.fileRef:`no-file`)].join(``),Xe=(0,v.useRef)(Ye);Xe.current=Ye;let Ze=(0,v.useRef)(new Set),Qe=(0,v.useRef)(0),$e=(0,v.useRef)(Ye);$e.current!==Ye&&($e.current=Ye,Qe.current+=1);let et=Qe.current,[tt,nt]=(0,v.useState)(null),rt=!!(Ke&&t&&(!Ze.current.has(Ye)||tt?.scope===Ye&&tt.generation===et&&tt.requestKey===Ne)),it=Ee?f.requestKey===Ne?(Re||He)&&rt?{state:`loading`}:Re||He?{state:`error`}:f:{state:`loading`}:{state:`idle`},at=Ee&&Ae?m.requestKey===Ne?rt?{state:`loading`}:ze||Ue?{state:`error`}:m:{state:`loading`}:{state:`idle`},ot=Ee&&je?g.requestKey===Ne?rt?{state:`loading`}:Be||We?{state:`error`}:g:{state:`loading`}:{state:`idle`},st=Ee&&Me?y.requestKey===Ne?rt?{state:`loading`}:Ve||Ge?{state:`error`}:y:{state:`loading`}:{state:`idle`},ct=Ee?[n??`default-session`,o,we,xe.viewRevision,Te.fileRevision,pe].join(``):`no-source-authority`,lt=(0,v.useRef)(ct);lt.current=ct;let ut=[ct,e.revision.runtimeRevision,e.revision.controlRevision??`no-control-revision`,e.revision.approvalRevision??`no-approval-revision`,e.revision.sessionOptionRevision??`no-session-option-revision`,e.revision.queueRevision??`no-queue-revision`].join(``),dt=(0,v.useRef)(ut);dt.current=ut;let ft=[n??`default-session`,e.identity.projectRef,e.identity.runtimeInstanceId,e.identity.sessionRef,e.identity.taskId??`no-task`,e.identity.taskRunId??`no-run`,e.revision.taskRevision??`no-task-revision`,e.sourceChanges.staged.revision??`no-index-revision`].join(``),pt=(0,v.useRef)(ft);pt.current=ft;let mt=(0,v.useRef)(``),ht=(0,v.useRef)(``);mt.current=[ct,Kv(at.value)].join(``),ht.current=qv(at.value),(0,v.useEffect)(()=>{B({state:`idle`}),ie(null),oe(!1)},[ft]),(0,v.useEffect)(()=>{!i&&o===`task`&&(s(`working-tree`),d(null))},[i,o]),(0,v.useEffect)(()=>{ye.current=null,te(null)},[me,ve]),(0,v.useEffect)(()=>{qe&&(Ze.current.delete(Ye),nt(e=>e?.scope===Ye?null:e))},[qe,Ye]),(0,v.useEffect)(()=>{let r=new AbortController,i=fe;return l(e=>({...e,[o]:{state:`loading`,revisionKey:i}})),(n?Jg(n,o,r.signal):o_(o,r.signal)).then(n=>{if(!n){r.signal.aborted||l(e=>({...e,[o]:{state:`error`,revisionKey:i}}));return}if(!Ov(n,o,ue,e.identity)){if(r.signal.aborted)return;if(!t||ye.current===me){l(e=>({...e,[o]:{state:`error`,revisionKey:i}}));return}ye.current=me,l(e=>({...e,[o]:{state:`loading`,revisionKey:i}})),t().then(e=>{if(!r.signal.aborted){if(!e){l(e=>({...e,[o]:{state:`error`,revisionKey:i}}));return}H(e=>e+1)}}).catch(()=>{r.signal.aborted||l(e=>({...e,[o]:{state:`error`,revisionKey:i}}))});return}ye.current=null,r.signal.aborted||l(e=>({...e,[o]:{state:`ready`,value:n,revisionKey:i}}))}).catch(()=>{r.signal.aborted||l(e=>({...e,[o]:{state:`error`,revisionKey:i}}))}),()=>r.abort()},[o,fe,n]);let gt=(0,v.useCallback)(()=>{let e=me,n=ve,r=de;ye.current=null,l(e=>({...e,[o]:{state:`loading`,revisionKey:fe}})),(async()=>{let i;try{i=await t?.()}catch{}if(he.current!==e||ge.current!==n)return;ye.current=e;let a=i?Dv({sourceProjectionRevision:i.sourceChanges.projectionRevision??null,taskViewRevision:i.sourceChanges.task.revision,workspaceRevision:i.sourceChanges.workingTree.revision,indexRevision:i.sourceChanges.staged.revision},i.identity):r;(!i||a===r)&&H(e=>e+1)})()},[t,de,ve,me,fe,o]);(0,v.useEffect)(()=>{if(!we){p({state:`idle`}),h({state:`idle`}),_({state:`idle`}),b({state:`idle`}),E(null),A(null),P(null),S(null),R(null);return}let e=new AbortController,t=Ne;return p({state:`loading`,requestKey:t}),E(null),A(null),P(null),S(null),R(null),h(Ae?{state:`loading`,requestKey:t}:{state:`idle`}),_(je?{state:`loading`,requestKey:t}:{state:`idle`}),b(Me?{state:`loading`,requestKey:t}:{state:`idle`}),(n?Yg(n,o,we,e.signal):s_(o,we,e.signal)).then(n=>{e.signal.aborted||p({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||p({state:`error`,requestKey:t})}),Ae&&(n?Xg(n,o,we,e.signal):c_(o,we,e.signal)).then(n=>{e.signal.aborted||h({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||h({state:`error`,requestKey:t})}),je&&ke&&(n?Zg(n,ke,we,e.signal):l_(ke,we,e.signal)).then(n=>{e.signal.aborted||_({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||_({state:`error`,requestKey:t})}),Me&&(n?Qg(n,we,null,e.signal):u_(we,null,e.signal)).then(n=>{e.signal.aborted||b({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||b({state:`error`,requestKey:t})}),()=>e.abort()},[we,o,pe,se,n,Oe,Ne]);let _t=(0,v.useCallback)(e=>{if(!Ee||!t)return;let n=Ye,r=et,i=Ne;!e&&Ze.current.has(n)||(Ze.current.add(n),nt({scope:n,generation:r,requestKey:i}),t().then(e=>{e&&Xe.current===n&&Qe.current===r&&H(e=>e+1)}).catch(()=>void 0).finally(()=>{nt(e=>e?.scope===n&&e.generation===r&&e.requestKey===i?null:e)}))},[Ee,et,Ye,Ne,t]);(0,v.useEffect)(()=>{!Ee||!Ke||!t||Ze.current.has(Ye)||_t(!1)},[_t,Ee,Ke,Ye,t]);let vt=Ce,yt=(0,v.useMemo)(()=>{let e=new Map;for(let t of vt){let n=t.path.lastIndexOf(`/`),i=n<0?Q(r,`Gốc project`,`Project root`):t.path.slice(0,n);e.set(i,[...e.get(i)??[],t])}return[...e.entries()]},[vt,r]),bt=(0,v.useMemo)(()=>{let t={task:e.sourceChanges.task.counts.files,"working-tree":e.sourceChanges.workingTree.counts.files,staged:e.sourceChanges.staged.counts.files},n=n=>{let r=c[n];return(r?.state===`ready`?Av(r.value,r.revisionKey,fe,ue,e.identity,n):null)?.page.total??t[n]};return{task:n(`task`),"working-tree":n(`working-tree`),staged:n(`staged`)}},[c,fe,e.sourceChanges.task.counts.files,e.sourceChanges.workingTree.counts.files,e.sourceChanges.staged.counts.files]),xt=e=>{te(null),s(e),d(null)},St=De.status===`available`&&De.actions.reviewMark.available,Ct=ot.value?.action===`source.stage`?De.status===`available`&&De.actions.stage.available:ot.value?.action===`source.unstage`&&De.status===`available`&&De.actions.unstage.available,wt=De.status===`available`&&De.actions.revert.available,Tt=o===`working-tree`&&De.status===`available`&&De.actions.openInVsCode.available&&it.state===`ready`&&it.value?.availability.state===`current`&&it.value.fallback.kind===`none`,Et=o===`staged`&&vt.length>0,Dt=Et&&De.status===`available`&&De.actions.generateCommitSummaryDeterministic.available,Ot=Et&&De.status===`available`&&De.actions.generateCommitSummaryModel.available,kt=t=>!t||t.identity.projectRef!==e.identity.projectRef||t.identity.runtimeInstanceId!==e.identity.runtimeInstanceId||t.identity.sessionRef!==e.identity.sessionRef||t.identity.taskId!==e.identity.taskId||t.identity.taskRunId!==e.identity.taskRunId?!1:t.summary?t.summary.taskRevision===e.revision.taskRevision&&t.summary.indexRevision===e.sourceChanges.staged.revision:t.state===`unavailable`,At=async t=>{if(!we||!at.value||C)return;let i=at.value,a=qv(i),s=mt.current,c=dt.current,l=me,u=ve,d=Ye,f=et,p=de,m=!1;w(!0),E(null),te(null);try{let g=await tv(e,i,t);if(mt.current!==s||ht.current!==a||dt.current!==c)return;let _=await $v(g.idempotencyKey);if(mt.current!==s||ht.current!==a||dt.current!==c)return;m=!0;let v=await O_(g);if(!Yv(g,v,t,_)){if(v.phase!==`rejected`){await jt(l,u,d,f,p,Q(r,`Chưa xác nhận được receipt review. Piagent đã đọc lại trạng thái chính thức và sẽ không tự gửi lại lệnh.`,`The review receipt is unconfirmed. Piagent reloaded canonical state and will not resend the command.`));return}mt.current===s&&ht.current===a&&E(v.error?.message??Q(r,`Không xác nhận được trạng thái review chính xác; hãy tải lại diff.`,`The exact review state could not be confirmed; reload the diff.`));return}if(mt.current!==s||ht.current!==a)return;h(e=>mt.current===s&&qv(e.value)===a?{state:`ready`,requestKey:e.requestKey,value:{...i,generatedAt:v.settledAt,state:v.resultCode,recordedState:v.resultCode,recordedAt:v.settledAt,evidenceRef:v.settlementEvidenceRef,reasonCode:null,health:{state:`ok`,reasonCode:null,message:null}}}:e),(n?Xg(n,o,we):c_(o,we)).then(e=>h(t=>mt.current===s&&t.state===`ready`&&t.value?.evidenceRef===v.settlementEvidenceRef?{state:`ready`,value:e,requestKey:t.requestKey}:t)).catch(()=>void 0)}catch{m?await jt(l,u,d,f,p,Q(r,`Mất kết nối khi đang ghi review. Piagent đã đọc lại trạng thái chính thức và sẽ không tự gửi lại lệnh.`,`The connection was lost while saving review. Piagent reloaded canonical state and will not resend the command.`)):mt.current===s&&ht.current===a&&E(Q(r,`Không thể ghi trạng thái review. Nội dung source không bị thay đổi.`,`Unable to save review state. Source content was not changed.`))}finally{w(!1)}},jt=async(e,n,r,i,a,o)=>{Xe.current===r&&Qe.current===i&&(p({state:`idle`}),h({state:`idle`}),_({state:`idle`}),b({state:`idle`}),S(null),E(null),A(null),P(null),R(null),te(null));let s;try{s=await t?.()}catch{}if(he.current!==e||ge.current!==n)return;let c=s?Dv({sourceProjectionRevision:s.sourceChanges.projectionRevision??null,taskViewRevision:s.sourceChanges.task.revision,workspaceRevision:s.sourceChanges.workingTree.revision,indexRevision:s.sourceChanges.staged.revision},s.identity):a;(!s||c===a)&&H(e=>e+1),te({scope:e,generation:n,message:o})},Mt=async(n=[])=>{if(!we||!xe||!ot.value||ot.value.state!==`ready`||D)return;let i=lt.current,a=dt.current,o=ot.value,s=me,c=ve,l=Ye,u=et,f=de,p=!1;O(!0),A(null),te(null);try{let m=await iv(e,o,n);if(lt.current!==i||dt.current!==a)return;p=!0;let h=await k_(m);if(h.phase===`uncertain`){await jt(s,c,l,u,f,Q(r,`Chưa xác nhận được trạng thái Git. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`Git state is unconfirmed. Piagent refreshed Source Changes and will not resend the command.`));return}if(h.phase!==`settled`||![`staged`,`unstaged`].includes(h.resultCode)){lt.current===i&&A(h.error?.message??Q(r,`File hoặc Git index đã thay đổi; hãy tải lại preview.`,`The file or Git index changed; reload the preview.`));return}lt.current===i&&d(null),await t?.(),H(e=>e+1)}catch{p?await jt(s,c,l,u,f,Q(r,`Mất kết nối khi đang cập nhật Git. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`The connection was lost while updating Git. Piagent refreshed Source Changes and will not resend the command.`)):lt.current===i&&A(Q(r,`Không thể chuẩn bị lệnh cập nhật Git; source chưa bị thay đổi.`,`Unable to prepare the Git update; source was not changed.`))}finally{O(!1)}},Nt=async e=>{if(!we||!xe||!wt||j)return;let t=lt.current,i=we;M(!0),P(null),te(null);try{let a=n?await Qg(n,i,e):await u_(i,e);if(lt.current!==t)return;if(a.state!==`ready`||!a.target){P(Q(r,`Không thể hoàn tác an toàn: provenance hoặc diff hiện tại không còn đủ bằng chứng.`,`Safe revert is unavailable because provenance or the current diff lacks evidence.`));return}S(a)}catch{lt.current===t&&P(Q(r,`Không thể dựng preview hoàn tác. Source chưa bị thay đổi.`,`Unable to build a revert preview. Source was not changed.`))}finally{M(!1)}},Pt=async()=>{if(!x?.target||!we||!xe||!Te||j||!Zv(x.target,o,we,xe.viewRevision,Te.fileRevision,e))return;let n=lt.current,i=dt.current,a=x,s=me,c=ve,l=Ye,u=et,f=de,p=!1;M(!0),P(null),te(null);try{let o=await sv(e,a);if(lt.current!==n||dt.current!==i)return;p=!0;let m=await A_(o);if(m.phase===`uncertain`){await jt(s,c,l,u,f,Q(r,`Chưa xác nhận được kết quả revert. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`The revert result is unconfirmed. Piagent refreshed Source Changes and will not resend the command.`));return}if(m.phase!==`settled`||m.resultCode!==`reverted`){lt.current===n&&P(m.error?.message??Q(r,`Preview đã cũ; hãy mở lại trước khi xác nhận.`,`The preview is stale; reopen it before confirming.`));return}lt.current===n&&(S(null),d(null)),await t?.(),H(e=>e+1)}catch{p?await jt(s,c,l,u,f,Q(r,`Mất kết nối khi đang revert. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`The connection was lost during revert. Piagent refreshed Source Changes and will not resend the command.`)):lt.current===n&&P(Q(r,`Không thể chuẩn bị lệnh revert; source chưa bị thay đổi.`,`Unable to prepare the revert command; source was not changed.`))}finally{M(!1)}},Ft=async()=>{if(!we||!Tt||F)return;let t=lt.current,n=dt.current,i=we;I(!0),R(null);try{let a=await uv(e,i);if(lt.current!==t||dt.current!==n)return;let o=await j_(a);if(lt.current!==t)return;o.phase===`settled`&&o.resultCode===`opened`?R(Q(r,`VS Code đã nhận yêu cầu mở file.`,`VS Code received the open-file request.`)):R(o.phase===`uncertain`?Q(r,`Không xác nhận được VS Code đã nhận file. Piagent sẽ không tự mở lại.`,`It is unknown whether VS Code received the file. Piagent will not retry automatically.`):o.error?.message??Q(r,`File hoặc phiên làm việc đã thay đổi; hãy tải lại trước khi mở.`,`The file or session changed; refresh before opening.`))}catch{lt.current===t&&R(Q(r,`Không thể mở file trong VS Code. Diff hiện tại vẫn được giữ nguyên.`,`Unable to open the file in VS Code. The current diff remains available.`))}finally{I(!1)}},It=async()=>{if(!Dt||V)return;let e=pt.current;ne(!0),ie(null),B({state:`loading`});try{let t=n?await $g(n):await d_();if(pt.current!==e)return;if(!kt(t)){B({state:`error`}),ie(Q(r,`Staged Changes đã đổi trong lúc dựng summary; hãy tạo lại.`,`Staged Changes changed while the summary was generated; generate it again.`));return}B({state:`ready`,value:t}),t.state!==`ready`&&ie(Q(r,`Staged Changes đã thay đổi hoặc chưa có dữ liệu để tóm tắt.`,`Staged Changes changed or has no data to summarize.`))}catch{pt.current===e&&(B({state:`error`}),ie(Q(r,`Không thể dựng commit summary từ index hiện tại.`,`Unable to generate a commit summary from the current index.`)))}finally{ne(!1)}},Lt=async()=>{let e=z.value?.summary;if(!e||!kt(z.value))return;let t=pt.current;try{await navigator.clipboard.writeText([e.title,``,...e.bodyLines].join(`
|
|
172
|
-
`)),pt.current===t&&ie(Q(r,`Đã copy summary. Chưa có commit nào được tạo.`,`Summary copied. No commit was created.`))}catch{pt.current===t&&ie(Q(r,`Trình duyệt không cho phép copy tự động.`,`The browser did not allow automatic copying.`))}},Rt=async()=>{let t=z.value?.summary;if(!t||!kt(z.value)||!Ot||V)return;let n=pt.current;ne(!0),ie(null);try{let i=await G_(e,t.modelPrompt,`new-operation`);if(pt.current!==n||!kt(z.value))return;let a=await w_(i);if(pt.current!==n)return;a.phase===`settled`&&a.resultCode===`dispatch-observed`?ie(Q(r,`Đã gửi yêu cầu sang Chat. Pi sẽ trả commit summary ở hội thoại; chưa commit hoặc push.`,`Request sent to Chat. Pi will return the commit summary in the conversation; nothing was committed or pushed.`)):ie(a.phase===`uncertain`?Q(r,`Không xác nhận được yêu cầu đã tới Pi; hệ thống sẽ không tự gửi lại.`,`It is unknown whether the request reached Pi; it will not be resent automatically.`):a.error?.message??Q(r,`Không thể bắt đầu model work từ session hiện tại.`,`Unable to start model work from the current session.`))}catch{pt.current===n&&ie(Q(r,`Không thể gửi yêu cầu sang Pi session hiện tại.`,`Unable to send the request to the current Pi session.`))}finally{ne(!1),oe(!1)}},zt=ee?.scope===me&&ee.generation===ve?ee.message:null;return(0,U.jsxs)(Pc,{component:`section`,variant:`outlined`,className:`source-workspace`,"aria-labelledby":`source-title`,sx:{overflow:`hidden`,minHeight:`calc(100vh - 120px)`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(J,{component:`header`,className:`source-heading`,sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,px:{xs:2,sm:2.5},py:1.75,borderBottom:1,borderColor:`divider`},children:[(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`overline`,color:`primary.main`,sx:{fontWeight:800,letterSpacing:`.14em`,lineHeight:1},children:`Source changes`}),(0,U.jsx)(X,{variant:`h2`,id:`source-title`,sx:{mt:.5},children:Q(r,`Thay đổi trong project`,`Project changes`)})]}),(0,U.jsx)(lu,{label:`Git + task baseline`,variant:`outlined`,size:`small`})]}),(0,U.jsx)(pg,{className:`source-tabs`,value:o,onChange:(e,t)=>xt(t),selectionFollowsFocus:!0,variant:`scrollable`,scrollButtons:`auto`,"aria-label":Q(r,`Nguồn thay đổi`,`Change sources`),sx:{borderBottom:1,borderColor:`divider`,minHeight:48},children:a.map(e=>(0,U.jsx)(Kh,{id:`source-tab-${e.view}`,value:e.view,"aria-controls":`source-tabpanel`,disabled:e.view===`task`&&!i,title:e.view===`task`&&!i?Q(r,`Session này chưa có task baseline`,`This session has no task baseline`):void 0,label:(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsx)(`span`,{children:e.label}),bt[e.view]>0&&(0,U.jsx)(lu,{size:`small`,label:bt[e.view],sx:{height:20,minWidth:24,"& .MuiChip-label":{px:.75}}})]})},e.view))}),o===`staged`&&(0,U.jsx)(ey,{state:z,busy:V,status:re,locale:r,deterministicEnabled:Dt,modelEnabled:Ot,onGenerate:()=>{It()},onCopy:()=>{Lt()},onModel:()=>oe(!0)}),(0,U.jsxs)(J,{className:`source-body`,sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`minmax(286px, 330px) minmax(0, 1fr)`},flex:1,minHeight:620},children:[(0,U.jsxs)(J,{className:`file-panel`,id:`source-tabpanel`,role:`tabpanel`,"aria-labelledby":`source-tab-${o}`,sx:{minWidth:0,borderRight:{md:1},borderBottom:{xs:1,md:0},borderColor:`divider`,bgcolor:`background.default`},children:[(0,U.jsxs)(J,{className:`file-panel-meta`,sx:{minHeight:44,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:1,px:1.5,borderBottom:1,borderColor:`divider`},children:[(0,U.jsx)(`span`,{"aria-live":`polite`,children:Se?.state===`ready`&&Se.value?Tv(Se.value,r):Se?.state===`error`?Q(r,`Không thể tải danh sách file`,`Unable to load files`):Q(r,`Đang tải…`,`Loading…`)}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[Se?.state===`error`&&(0,U.jsx)(`button`,{className:`source-list-retry`,type:`button`,onClick:gt,children:Q(r,`Thử tải lại`,`Retry`)}),(0,U.jsx)(`small`,{children:a.find(e=>e.view===o)?.shortLabel})]})]}),(0,U.jsxs)(J,{className:`file-list`,sx:{maxHeight:{xs:300,md:`calc(100vh - 270px)`},overflow:`auto`,p:.75},children:[yt.map(([e,t])=>(0,U.jsxs)(J,{children:[(0,U.jsxs)(Z,{direction:`row`,className:`file-group-label`,children:[(0,U.jsx)(Vh,{}),(0,U.jsx)(X,{component:`span`,noWrap:!0,children:e})]}),t.map(e=>(0,U.jsx)(ty,{file:e,selected:e.fileRef===we,onSelect:()=>{te(null),d(e.fileRef)},locale:r},e.fileRef))]},e)),Se?.state===`ready`&&vt.length===0&&(0,U.jsx)(`div`,{className:`files-empty`,children:Q(r,`Không có thay đổi trong view này.`,`No changes in this view.`)})]})]}),(0,U.jsx)(iy,{state:it,review:at,mutation:ot,revert:st,reviewEnabled:St,reviewBusy:C,reviewError:T,mutationEnabled:Ct,mutationBusy:D,mutationError:k,revertEnabled:wt,revertBusy:j,openEnabled:Tt,openBusy:F,openStatus:L,detailError:Ke&&!rt,mode:ce,onMode:le,onReview:e=>{At(e)},onMutation:e=>{Mt(e)},onRevert:e=>{Nt(e)},onOpen:()=>{Ft()},onRetry:Ee&&t?()=>_t(!0):void 0,locale:r})]}),zt&&(0,U.jsx)(`div`,{className:`source-action-warning`,role:`status`,children:zt}),N&&(0,U.jsx)(`div`,{className:`source-revert-error`,role:`status`,children:N}),x?.target&&we&&xe&&Te&&Zv(x.target,o,we,xe.viewRevision,Te.fileRevision,e)&&(0,U.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,U.jsxs)(`section`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`revert-dialog-title`,"aria-describedby":`revert-dialog-description`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Xác nhận hoàn tác`,`Confirm revert`)}),(0,U.jsxs)(`h3`,{id:`revert-dialog-title`,children:[`Revert `,x.target.hunkRefs.length?`hunk`:`file`,`?`]}),(0,U.jsxs)(`p`,{id:`revert-dialog-description`,children:[Q(r,`Thao tác sẽ bỏ`,`This will discard`),` `,(0,U.jsxs)(`strong`,{children:[x.target.summary.additionsDiscarded,` `,Q(r,`dòng thêm`,`added lines`)]}),` `,Q(r,`và khôi phục`,`and restore`),` `,(0,U.jsxs)(`strong`,{children:[x.target.summary.deletionsRestored,` `,Q(r,`dòng xóa`,`deleted lines`)]}),` `,Q(r,`trong`,`in`),` `,(0,U.jsx)(`code`,{children:x.target.path}),`.`]}),(0,U.jsx)(`div`,{className:`revert-diff`,"aria-label":Q(r,`Các dòng chính xác sẽ được hoàn tác`,`Exact lines to revert`),children:x.preview?.hunks.map(e=>(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`div`,{children:e.header}),e.lines.map((t,n)=>(0,U.jsxs)(`code`,{className:`revert-line revert-${t.kind}`,children:[(0,U.jsx)(`b`,{children:t.marker}),t.text]},`${e.hunkRef}.${n}`))]},e.hunkRef))}),(0,U.jsxs)(`div`,{className:`revert-safety`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Phần đã stage được giữ nguyên.`,`Staged content is preserved.`)}),(0,U.jsx)(`span`,{children:Q(r,`Không auto-commit. Khả năng khôi phục sau thao tác không được bảo đảm.`,`No auto-commit. Recovery after this action is not guaranteed.`)})]}),(0,U.jsxs)(`div`,{className:`confirm-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>S(null),children:Q(r,`Hủy`,`Cancel`)}),(0,U.jsx)(`button`,{className:`danger-action`,type:`button`,disabled:j,onClick:()=>{Pt()},children:j?Q(r,`Đang hoàn tác…`,`Reverting…`):Q(r,`Xác nhận revert`,`Confirm revert`)})]})]})}),ae&&kt(z.value)&&(0,U.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,U.jsxs)(`section`,{className:`confirm-dialog model-summary-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`model-summary-dialog-title`,"aria-describedby":`model-summary-dialog-description`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Model work có tính phí`,`Token-consuming model work`)}),(0,U.jsx)(`h3`,{id:`model-summary-dialog-title`,children:Q(r,`Nhờ Pi viết lại commit summary?`,`Ask Pi to rewrite the commit summary?`)}),(0,U.jsx)(`p`,{id:`model-summary-dialog-description`,children:Q(r,`Thao tác này gửi một message vào đúng Pi session hiện tại, bắt đầu một Pi operation và tiêu token theo model/thinking đang chọn. Chỉ staged summary đã rút gọn được gửi; source text không được đính kèm.`,`This sends a message to the exact current Pi session, starts a Pi operation, and consumes tokens using the selected model and thinking level. Only the bounded staged summary is sent; source text is not attached.`)}),(0,U.jsxs)(`div`,{className:`revert-safety`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Không tự commit hoặc push.`,`Does not commit or push.`)}),(0,U.jsx)(`span`,{children:Q(r,`Kết quả sẽ xuất hiện trong Chat để review và copy.`,`The result will appear in Chat for review and copying.`)})]}),(0,U.jsxs)(`div`,{className:`confirm-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:V,onClick:()=>oe(!1),children:Q(r,`Hủy`,`Cancel`)}),(0,U.jsx)(`button`,{type:`button`,disabled:V,onClick:()=>{Rt()},children:V?Q(r,`Đang gửi…`,`Sending…`):Q(r,`Xác nhận và gửi sang Pi`,`Confirm and send to Pi`)})]})]})})]})}function oy(e){return Gr(`MuiInputAdornment`,e)}var sy=Kr(`MuiInputAdornment`,[`root`,`filled`,`standard`,`outlined`,`positionStart`,`positionEnd`,`disablePointerEvents`,`hiddenLabel`,`sizeSmall`]),cy,ly=(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${q(n.position)}`],n.disablePointerEvents===!0&&t.disablePointerEvents,t[n.variant]]},uy=e=>{let{classes:t,disablePointerEvents:n,hiddenLabel:r,position:i,size:a,variant:o}=e;return ba({root:[`root`,n&&`disablePointerEvents`,i&&`position${q(i)}`,o,r&&`hiddenLabel`,a&&`size${q(a)}`]},oy,t)},dy=K(`div`,{name:`MuiInputAdornment`,slot:`Root`,overridesResolver:ly})(ys(({theme:e})=>({display:`flex`,maxHeight:`2em`,alignItems:`center`,whiteSpace:`nowrap`,color:(e.vars||e).palette.action.active,variants:[{props:{variant:`filled`},style:{[`&.${sy.positionStart}&:not(.${sy.hiddenLabel})`]:{marginTop:16}}},{props:{position:`start`},style:{marginRight:8}},{props:{position:`end`},style:{marginLeft:8}},{props:{disablePointerEvents:!0},style:{pointerEvents:`none`}}]}))),fy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiInputAdornment`}),{children:r,className:i,component:a=`div`,disablePointerEvents:o=!1,disableTypography:s=!1,position:c,variant:l,...u}=n,d=_s()||{},f=l;l&&d.variant,d&&!f&&(f=d.variant);let p={...n,hiddenLabel:d.hiddenLabel,size:d.size,disablePointerEvents:o,position:c,variant:f},m=uy(p);return(0,U.jsx)(gs.Provider,{value:null,children:(0,U.jsx)(dy,{as:a,ownerState:p,className:W(m.root,i),ref:t,...u,children:typeof r==`string`&&!s?(0,U.jsx)(X,{color:`textSecondary`,children:r}):(0,U.jsxs)(v.Fragment,{children:[c===`start`?cy||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``}):null,r]})})})});function py(e){return Gr(`MuiInputLabel`,e)}var my=Kr(`MuiInputLabel`,[`root`,`focused`,`disabled`,`error`,`required`,`asterisk`,`formControl`,`sizeSmall`,`shrink`,`animated`,`standard`,`filled`,`outlined`]),hy=e=>{let{classes:t,disableUnderline:n}=e,r=ba({root:[`root`,!n&&`underline`],input:[`input`]},lc,t);return{...t,...r}},gy=K($s,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Xs(e,t),!n.disableUnderline&&t.underline]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`;return e.vars&&(t=e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline)),{position:`relative`,variants:[{props:({ownerState:e})=>e.formControl,style:{[`label + &, .${my.root} + &`]:{marginTop:16}}},{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ks(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${uc.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${uc.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${t}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ks(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${uc.disabled}, .${uc.error}):before`]:{borderBottom:`2px solid ${(e.vars||e).palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},[`&.${uc.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t,disableUnderline:!1},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t].main}`}}}))]}})),_y=K(ec,{name:`MuiInput`,slot:`Input`,overridesResolver:Zs})({}),vy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiInput`}),{disableUnderline:r=!1,fullWidth:i=!1,inputComponent:a=`input`,multiline:o=!1,notched:s,slotProps:c,slots:l={},type:u=`text`,...d}=n,f=hy(n),p={root:{ownerState:{disableUnderline:r}}},m=c?Wt(c,p):p,h=l.root??gy,g=l.input??_y;return(0,U.jsx)(nc,{slots:{root:h,input:g},slotProps:m,fullWidth:i,inputComponent:a,multiline:o,ref:t,type:u,...d,classes:f})});vy.muiName=`Input`;function yy(e){return Gr(`MuiSelect`,e)}var by=Kr(`MuiSelect`,[`root`,`select`,`multiple`,`filled`,`outlined`,`standard`,`disabled`,`focused`,`icon`,`iconOpen`,`nativeInput`,`error`]),xy=e=>{let{classes:t,disableUnderline:n,startAdornment:r,endAdornment:i,size:a,hiddenLabel:o,multiline:s}=e,c=ba({root:[`root`,!n&&`underline`,r&&`adornedStart`,i&&`adornedEnd`,a===`small`&&`size${q(a)}`,o&&`hiddenLabel`,s&&`multiline`],input:[`input`]},rc,t);return{...t,...c}},Sy=K($s,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiFilledInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Xs(e,t),!n.disableUnderline&&t.underline]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`,n=t?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`,r=t?`rgba(0, 0, 0, 0.06)`:`rgba(255, 255, 255, 0.09)`,i=t?`rgba(0, 0, 0, 0.09)`:`rgba(255, 255, 255, 0.13)`,a=t?`rgba(0, 0, 0, 0.12)`:`rgba(255, 255, 255, 0.12)`;return{position:`relative`,backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r,borderTopLeftRadius:(e.vars||e).shape.borderRadius,borderTopRightRadius:(e.vars||e).shape.borderRadius,...Ks(e,`background-color`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),"&:hover":{backgroundColor:e.vars?e.vars.palette.FilledInput.hoverBg:i,"@media (hover: none)":{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r}},[`&.${ic.focused}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r},[`&.${ic.disabled}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.disabledBg:a},variants:[{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ks(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${ic.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${ic.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${e.vars?e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline):n}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ks(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${ic.disabled}, .${ic.error}):before`]:{borderBottom:`1px solid ${(e.vars||e).palette.text.primary}`},[`&.${ic.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{disableUnderline:!1,color:t},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t]?.main}`}}})),{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:12}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`12px`,paddingRight:`var(--_trailingPad)`,[`&.${by.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`25px 12px 8px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}}]}})),Cy=K(ec,{name:`MuiFilledInput`,slot:`Input`,overridesResolver:Zs})(ys(({theme:e})=>({paddingTop:25,paddingRight:12,paddingBottom:8,paddingLeft:12,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderTopLeftRadius:`inherit`,borderTopRightRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}},{props:({ownerState:e})=>e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}},{props:({ownerState:e})=>e.multiline,style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}}]}))),wy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFilledInput`}),{disableUnderline:r=!1,fullWidth:i=!1,hiddenLabel:a,inputComponent:o=`input`,multiline:s=!1,notched:c,slotProps:l,slots:u={},type:d=`text`,...f}=n,p={...n,disableUnderline:r,fullWidth:i,inputComponent:o,multiline:s,type:d},m=xy(n),h={root:{ownerState:p},input:{ownerState:p}},g=l?Wt(h,l):h,_=u.root??Sy,v=u.input??Cy;return(0,U.jsx)(nc,{slots:{root:_,input:v},slotProps:g,fullWidth:i,inputComponent:o,multiline:s,ref:t,type:d,...f,classes:m})});wy.muiName=`Input`;var Ty,Ey=K(`fieldset`,{name:`MuiNotchedOutlined`,shouldForwardProp:Jo})({textAlign:`left`,position:`absolute`,bottom:0,right:0,top:-5,left:0,margin:0,padding:`0 8px`,pointerEvents:`none`,borderRadius:`inherit`,borderStyle:`solid`,borderWidth:1,overflow:`hidden`,minWidth:`0%`}),Dy=K(`legend`,{name:`MuiNotchedOutlined`,shouldForwardProp:Jo})(ys(({theme:e})=>({float:`unset`,width:`auto`,overflow:`hidden`,variants:[{props:({ownerState:e})=>!e.withLabel,style:{padding:0,lineHeight:`11px`,...Ks(e,`width`,{duration:150,easing:e.transitions.easing.easeOut})}},{props:({ownerState:e})=>e.withLabel,style:{display:`block`,padding:0,height:11,fontSize:`0.75em`,visibility:`hidden`,maxWidth:.01,...Ks(e,`max-width`,{duration:50,easing:e.transitions.easing.easeOut}),whiteSpace:`nowrap`,"& > span":{paddingLeft:5,paddingRight:5,display:`inline-block`,opacity:0,visibility:`visible`}}},{props:({ownerState:e})=>e.withLabel&&e.notched,style:{maxWidth:`100%`,...Ks(e,`max-width`,{duration:100,easing:e.transitions.easing.easeOut,delay:50})}}]})));function Oy(e){let{children:t,classes:n,className:r,label:i,notched:a,...o}=e,s=i!=null&&i!==``,c={...e,notched:a,withLabel:s};return(0,U.jsx)(Ey,{"aria-hidden":!0,className:r,ownerState:c,...o,children:(0,U.jsx)(Dy,{ownerState:c,children:s?(0,U.jsx)(`span`,{children:i}):Ty||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``})})})}var ky=e=>{let{classes:t}=e,n=ba({root:[`root`],notchedOutline:[`notchedOutline`],input:[`input`]},_c,t);return{...t,...n}},Ay=K($s,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiOutlinedInput`,slot:`Root`,overridesResolver:Xs})(ys(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{position:`relative`,borderRadius:(e.vars||e).shape.borderRadius,[`&:hover .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${vc.notchedOutline}`]:{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}},[`&.${vc.focused} .${vc.notchedOutline}`]:{borderWidth:2},variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{[`&.${vc.focused} .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${vc.error} .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette.error.main},[`&.${vc.disabled} .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled}}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:14}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`14px`,paddingRight:`var(--_trailingPad)`,[`&.${by.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`16.5px 14px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{padding:`8.5px 14px`}}]}})),jy=K(Oy,{name:`MuiOutlinedInput`,slot:`NotchedOutline`})(ys(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}})),My=K(ec,{name:`MuiOutlinedInput`,slot:`Input`,overridesResolver:Zs})(ys(({theme:e})=>({padding:`16.5px 14px`,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{padding:`8.5px 14px`}},{props:({ownerState:e})=>e.multiline,style:{padding:0}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}}]}))),Ny=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiOutlinedInput`}),{fullWidth:r=!1,inputComponent:i=`input`,label:a,multiline:o=!1,notched:s,slots:c={},slotProps:l={},type:u=`text`,...d}=n,f=ky(n),[p,m]=vs({props:n,states:[`color`,`disabled`,`error`,`focused`,`hiddenLabel`,`size`,`required`]}),h={...n,color:p.color||`primary`,disabled:p.disabled,error:p.error,focused:p.focused,formControl:m,fullWidth:r,hiddenLabel:p.hiddenLabel,multiline:o,size:p.size,type:u},g=c.root??Ay,_=c.input??My,[y,b]=Xc(`notchedOutline`,{elementType:jy,className:f.notchedOutline,shouldForwardComponentProp:!0,ownerState:h,externalForwardedProps:{slots:c,slotProps:l},additionalProps:{label:a!=null&&a!==``&&p.required?(0,U.jsxs)(v.Fragment,{children:[a,` `,`*`]}):a}});return(0,U.jsx)(nc,{slots:{root:g,input:_},slotProps:l,renderSuffix:e=>(0,U.jsx)(y,{...b,notched:s===void 0?!!(e.startAdornment||e.filled||e.focused):s}),fullWidth:r,inputComponent:i,multiline:o,ref:t,type:u,...d,classes:{...f,notchedOutline:null}})});Ny.muiName=`Input`;var Py=e=>{let{classes:t,color:n,focused:r,disabled:i,error:a,filled:o,required:s}=e;return ba({root:[`root`,`color${q(n)}`,i&&`disabled`,a&&`error`,o&&`filled`,r&&`focused`,s&&`required`],asterisk:[`asterisk`,a&&`error`]},sc,t)},Fy=K(`label`,{name:`MuiFormLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color===`secondary`&&t.colorSecondary,n.filled&&t.filled]}})(ys(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.body1,lineHeight:`1.4375em`,padding:0,position:`relative`,variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{[`&.${cc.focused}`]:{color:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${cc.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${cc.error}`]:{color:(e.vars||e).palette.error.main}}}]}))),Iy=K(`span`,{name:`MuiFormLabel`,slot:`Asterisk`})(ys(({theme:e})=>({[`&.${cc.error}`]:{color:(e.vars||e).palette.error.main}}))),Ly=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFormLabel`}),{children:r,className:i,color:a,component:o=`label`,disabled:s,error:c,filled:l,focused:u,required:d,...f}=n,[p]=vs({props:n,states:[`color`,`required`,`focused`,`disabled`,`error`,`filled`]}),m={...n,color:p.color||`primary`,component:o,disabled:p.disabled,error:p.error,filled:p.filled,focused:p.focused,required:p.required},h=Py(m);return(0,U.jsxs)(Fy,{as:o,ownerState:m,className:W(h.root,i),ref:t,...f,children:[r,p.required&&(0,U.jsxs)(Iy,{ownerState:m,"aria-hidden":!0,className:h.asterisk,children:[` `,`*`]})]})}),Ry=e=>{let{classes:t,formControl:n,size:r,shrink:i,disableAnimation:a,variant:o,required:s}=e,c=ba({root:[`root`,n&&`formControl`,!a&&`animated`,i&&`shrink`,r&&r!==`medium`&&`size${q(r)}`,o],asterisk:[s&&`asterisk`]},py,t);return{...t,...c}},zy=K(Ly,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiInputLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${cc.asterisk}`]:t.asterisk},t.root,n.formControl&&t.formControl,n.size===`small`&&t.sizeSmall,n.shrink&&t.shrink,!n.disableAnimation&&t.animated,n.focused&&t.focused,t[n.variant]]}})(ys(({theme:e})=>({display:`block`,transformOrigin:`top left`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,variants:[{props:({ownerState:e})=>e.formControl,style:{position:`absolute`,left:0,top:0,transform:`translate(0, 20px) scale(1)`}},{props:{size:`small`},style:{transform:`translate(0, 17px) scale(1)`}},{props:({ownerState:e})=>e.shrink,style:{transform:`translate(0, -1.5px) scale(0.75)`,transformOrigin:`top left`,maxWidth:`133%`}},{props:({ownerState:e})=>!e.disableAnimation,style:{...Ks(e,[`color`,`transform`,`max-width`],{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut})}},{props:{variant:`filled`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(12px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`filled`,size:`small`},style:{transform:`translate(12px, 13px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`filled`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,transform:`translate(12px, 7px) scale(0.75)`,maxWidth:`calc(133% - 24px)`}},{props:({variant:e,ownerState:t,size:n})=>e===`filled`&&t.shrink&&n===`small`,style:{transform:`translate(12px, 4px) scale(0.75)`}},{props:{variant:`outlined`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(14px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`outlined`,size:`small`},style:{transform:`translate(14px, 9px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`outlined`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,maxWidth:`calc(133% - 32px)`,transform:`translate(14px, -9px) scale(0.75)`}}]}))),By=v.forwardRef(function(e,t){let n=Xo({name:`MuiInputLabel`,props:e}),{disableAnimation:r=!1,margin:i,shrink:a,variant:o,className:s,...c}=n,[l,u]=vs({props:n,states:[`size`,`variant`,`required`,`focused`]}),d=a;d===void 0&&u&&(d=u.filled||u.focused||u.adornedStart);let f={...n,disableAnimation:r,formControl:u,shrink:d,size:l.size,variant:l.variant,required:l.required,focused:l.focused},p=Ry(f);return(0,U.jsx)(zy,{"data-shrink":d,ref:t,className:W(p.root,s),...c,ownerState:f,classes:p})});function Vy(e){return Gr(`MuiFormControl`,e)}Kr(`MuiFormControl`,[`root`,`marginNone`,`marginNormal`,`marginDense`,`fullWidth`,`disabled`]);var Hy=e=>{let{classes:t,margin:n,fullWidth:r}=e;return ba({root:[`root`,n!==`none`&&`margin${q(n)}`,r&&`fullWidth`]},Vy,t)},Uy=K(`div`,{name:`MuiFormControl`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`margin${q(n.margin)}`],n.fullWidth&&t.fullWidth]}})({display:`inline-flex`,flexDirection:`column`,position:`relative`,minWidth:0,padding:0,margin:0,border:0,verticalAlign:`top`,variants:[{props:{margin:`normal`},style:{marginTop:16,marginBottom:8}},{props:{margin:`dense`},style:{marginTop:8,marginBottom:4}},{props:{fullWidth:!0},style:{width:`100%`}}]}),Wy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFormControl`}),{children:r,className:i,color:a=`primary`,component:o=`div`,disabled:s=!1,error:c=!1,focused:l,fullWidth:u=!1,hiddenLabel:d=!1,margin:f=`none`,required:p=!1,size:m=`medium`,variant:h=`outlined`,...g}=n,_={...n,color:a,component:o,disabled:s,error:c,fullWidth:u,hiddenLabel:d,margin:f,required:p,size:m,variant:h},y=Hy(_),[b,x]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{if(!wd(t,[`Input`,`Select`]))return;let n=wd(t,[`Select`])?t.props.input:t;n&&Ds(n.props)&&(e=!0)}),e}),[S,C]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{wd(t,[`Input`,`Select`])&&(Es(t.props,!0)||Es(t.props.inputProps,!0))&&(e=!0)}),e}),[w,T]=v.useState(!1);s&&w&&T(!1);let E=l!==void 0&&!s?l:w,D;v.useRef(!1);let O=v.useCallback(()=>{C(!0)},[]),k=v.useCallback(()=>{C(!1)},[]),A=v.useMemo(()=>({adornedStart:b,setAdornedStart:x,color:a,disabled:s,error:c,filled:S,focused:E,fullWidth:u,hiddenLabel:d,size:m,onBlur:()=>{T(!1)},onFocus:()=>{T(!0)},onEmpty:k,onFilled:O,registerEffect:D,required:p,variant:h}),[b,a,s,c,S,E,u,d,D,k,O,p,m,h]);return(0,U.jsx)(gs.Provider,{value:A,children:(0,U.jsx)(Uy,{as:o,ownerState:_,className:W(y.root,i),ref:t,...g,children:r})})}),Gy,Ky=e=>{let{classes:t,contained:n,size:r,disabled:i,error:a,filled:o,focused:s,required:c}=e;return ba({root:[`root`,i&&`disabled`,a&&`error`,r&&`size${q(r)}`,n&&`contained`,s&&`focused`,o&&`filled`,c&&`required`]},ac,t)},qy=K(`p`,{name:`MuiFormHelperText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.size&&t[`size${q(n.size)}`],n.contained&&t.contained,n.filled&&t.filled]}})(ys(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.caption,textAlign:`left`,marginTop:3,marginRight:0,marginBottom:0,marginLeft:0,[`&.${oc.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${oc.error}`]:{color:(e.vars||e).palette.error.main},variants:[{props:{size:`small`},style:{marginTop:4}},{props:({ownerState:e})=>e.contained,style:{marginLeft:14,marginRight:14}}]}))),Jy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFormHelperText`}),{children:r,className:i,component:a=`p`,disabled:o,error:s,filled:c,focused:l,margin:u,required:d,variant:f,...p}=n,[m]=vs({props:n,states:[`variant`,`size`,`disabled`,`error`,`filled`,`focused`,`required`]}),h={...n,component:a,contained:m.variant===`filled`||m.variant===`outlined`,variant:m.variant,size:m.size,disabled:m.disabled,error:m.error,filled:m.filled,focused:m.focused,required:m.required};delete h.ownerState;let g=Ky(h);return(0,U.jsx)(qy,{as:a,className:W(g.root,i),ref:t,...p,ownerState:h,children:r===` `?Gy||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``}):r})}),Yy=Ou;function Xy(e,t){if(t==null){e.focus();return}try{e.focus({focusVisible:t===`keyboard`})}catch{e.focus()}}function Zy(e){return e?e.type===`mousedown`||e.type===`pointerdown`||e.type===`touchstart`?`pointer`:e.type===`keydown`||e.type===`click`&&e.detail===0?`keyboard`:null:null}function Qy(e){return e==null||typeof e==`string`&&!e.trim()}function $y(e,t){return typeof t==`object`&&t?e===t:String(e)===String(t)}var eb=v.createContext(null);function tb(){return v.useContext(eb)}var nb=eb.Provider,rb=v.createContext(void 0);function ib(){let e=v.useContext(rb);if(e===void 0)throw Error(`MUI: MenuListContext is missing. MenuItems must be placed within Menu or MenuList.`);return e}function ab(e){let t=e?.element??e;if(!t)return``;if(e?.textValue!==void 0)return e.textValue;let n=t.innerText;return n===void 0&&(n=t.textContent),n??``}function ob(e,t){if(t===void 0)return!0;let n=ab(e);return n=n.trim().toLowerCase(),n.length===0?!1:t.repeating?n[0]===t.keys[0]:n.startsWith(t.keys.join(``))}function sb(e,t){return ob(e,t)?Kf(e):!1}function cb(e,t){Xy(e,t)}var lb=v.forwardRef(function(e,t){let{actions:n,autoFocus:r=!1,autoFocusItem:i=!1,children:a,className:o,disabledItemsFocusable:s=!1,disableListWrap:c=!1,onKeyDown:l,variant:u=`selectedMenu`,...d}=e,f=v.useRef(null),p=v.useRef(!1),[m,h]=v.useState(!1),g=tb(),_=v.useRef({keys:[],repeating:!0,previousKeyMatched:!0,lastTime:null}),y=Mf({activeItemId:void 0,getDefaultActiveItemId:v.useCallback(e=>u===`selectedMenu`?e.find(e=>e.selected&&Kf(e))?.id??e.find(e=>Kf(e))?.id??null:e.find(e=>Kf(e))?.id??null,[u]),orientation:`vertical`,wrap:!c}),{activeItemId:b,focusNext:x,getActiveItem:S,getContainerProps:C,getItemMap:w}=y,T=dl((e=!1)=>{if(!f.current||!e&&p.current)return null;if(i){let e=S();if(e?.element){let t=Array.from(w().values()).some(e=>e.selected),n=u===`menu`&&t&&!e.selected&&g==null;return h(n),cb(e.element,g),p.current=!0,e.element}return r?(h(!1),f.current.focus(),f.current):null}return r?(h(!1),f.current.focus(),p.current=!0,f.current):(h(!1),null)});xs(()=>{if(!r&&!i){p.current=!1,h(!1);return}T()},[b,i,r,T]),v.useImperativeHandle(n,()=>({adjustStyleForScrollbar:(e,{direction:t})=>{let n=!f.current.style.width;if(e.clientHeight<f.current.clientHeight&&n){let n=`${Yy(Td(e))}px`;f.current.style[t===`rtl`?`paddingLeft`:`paddingRight`]=n,f.current.style.width=`calc(100% + ${n})`}return f.current},focusInitialTarget:()=>{if(!f.current)return null;let e=ws(Ss(f.current));return e&&zu(f.current,e)?e:T(!0)}}),[T]);let E=C(void 0,d.onFocus),D=bs(f,E.ref,t),O=v.useMemo(()=>({itemsFocusableWhenDisabled:s,suppressInitialFocusVisible:m,variant:u}),[s,m,u]),k=dl(e=>{if(m&&h(!1),(e.ctrlKey||e.metaKey||e.altKey)&&l){l(e);return}if(E.onKeyDown(e),e.key.length===1){let t=_.current,n=e.key.toLowerCase(),r=performance.now();t.keys.length>0&&(r-t.lastTime>500?(t.keys=[],t.repeating=!0,t.previousKeyMatched=!0):t.repeating&&n!==t.keys[0]&&(t.repeating=!1)),t.lastTime=r,t.keys.push(n);let i=ws(Ss(f.current)),a=i&&!t.repeating&&ob(i,t);t.previousKeyMatched&&(a||x(e=>sb(e,t))!=null)?e.preventDefault():t.previousKeyMatched=!1}l&&l(e)});return(0,U.jsx)(rf,{role:`menu`,ref:D,className:o,onKeyDown:k,tabIndex:-1,...d,onFocus:E.onFocus,children:(0,U.jsx)(rb.Provider,{value:O,children:(0,U.jsx)(Df.Provider,{value:y,children:a})})})});function ub(e){return Gr(`MuiPopover`,e)}Kr(`MuiPopover`,[`root`,`paper`]);function db(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.height/2:t===`bottom`&&(n=e.height),n}function fb(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.width/2:t===`right`&&(n=e.width),n}function pb(e){return[e.horizontal,e.vertical].map(e=>typeof e==`number`?`${e}px`:e).join(` `)}function mb(e){return typeof e==`function`?e():e}var hb=e=>{let{classes:t}=e;return ba({root:[`root`],paper:[`paper`]},ub,t)},gb=K(Sd,{name:`MuiPopover`,slot:`Root`})({}),_b=K(Pc,{name:`MuiPopover`,slot:`Paper`})({position:`absolute`,overflowY:`auto`,overflowX:`hidden`,minWidth:16,minHeight:16,maxWidth:`calc(100% - 32px)`,maxHeight:`calc(100% - 32px)`,outline:0}),vb=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiPopover`}),{action:r,anchorEl:i,anchorOrigin:a={vertical:`top`,horizontal:`left`},anchorPosition:o,anchorReference:s=`anchorEl`,children:c,className:l,container:u,disableAutoFocus:d=!1,elevation:f=8,marginThreshold:p=16,open:m,slots:h={},slotProps:g={},transformOrigin:_={vertical:`top`,horizontal:`left`},transitionDuration:y=`auto`,disableScrollLock:b=!1,...x}=n,S=v.useRef(),C={...n,anchorOrigin:a,anchorReference:s,elevation:f,marginThreshold:p,transformOrigin:_,transitionDuration:y},w=hb(C),T=v.useCallback(()=>{if(s===`anchorPosition`)return o;let e=mb(i),t=(e&&e.nodeType===1?e:Ss(S.current).body).getBoundingClientRect();return{top:t.top+db(t,a.vertical),left:t.left+fb(t,a.horizontal)}},[i,a.horizontal,a.vertical,o,s]),E=v.useCallback(e=>({vertical:db(e,_.vertical),horizontal:fb(e,_.horizontal)}),[_.horizontal,_.vertical]),D=v.useCallback(e=>{let t={width:e.offsetWidth,height:e.offsetHeight},n=E(t);if(s===`none`)return{top:null,left:null,transformOrigin:pb(n)};let r=T(),a=r.top-n.vertical,o=r.left-n.horizontal,c=a+t.height,l=o+t.width,u=Td(mb(i)),d=u.innerHeight-p,f=u.innerWidth-p;if(p!=null&&a<p){let e=a-p;a-=e,n.vertical+=e}else if(p!=null&&c>d){let e=c-d;a-=e,n.vertical+=e}if(p!=null&&o<p){let e=o-p;o-=e,n.horizontal+=e}else if(l>f){let e=l-f;o-=e,n.horizontal+=e}return{top:`${Math.round(a)}px`,left:`${Math.round(o)}px`,transformOrigin:pb(n)}},[i,s,T,E,p]),[O,k]=v.useState(m),A=v.useCallback(()=>{let e=S.current;if(!e)return;let t=D(e);t.top!=null&&e.style.setProperty(`top`,t.top),t.left!=null&&(e.style.left=t.left),e.style.transformOrigin=t.transformOrigin,k(!0)},[D]);v.useEffect(()=>(b&&window.addEventListener(`scroll`,A),()=>window.removeEventListener(`scroll`,A)),[i,b,A]);let j=()=>{A()},M=()=>{k(!1)};v.useEffect(()=>{m&&A()}),v.useImperativeHandle(r,()=>m?{updatePosition:()=>{A()}}:null,[m,A]),v.useEffect(()=>{if(!m)return;let e=Cd(()=>{A()}),t=Td(mb(i));return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[i,m,A]);let N=y,P={slots:h,slotProps:g},[F,I]=Xc(`transition`,{elementType:mp,externalForwardedProps:P,ownerState:C,getSlotProps:e=>({...e,onEntering:(t,n)=>{e.onEntering?.(t,n),j()},onExited:t=>{e.onExited?.(t),M()}}),additionalProps:{appear:!0,in:m}});y===`auto`&&!F.muiSupportAuto&&(N=void 0);let L=u||(i?Ss(mb(i)).body:void 0),[R,{slots:ee,slotProps:te,...z}]=Xc(`root`,{ref:t,elementType:gb,externalForwardedProps:{...P,...x},shouldForwardComponentProp:!0,additionalProps:{slots:{backdrop:h.backdrop},slotProps:{backdrop:kd(typeof g.backdrop==`function`?g.backdrop(C):g.backdrop,{invisible:!0})},container:L,open:m},ownerState:C,className:W(w.root,l)}),[B,V]=Xc(`paper`,{ref:S,className:w.paper,elementType:_b,externalForwardedProps:P,shouldForwardComponentProp:!0,additionalProps:{elevation:f,style:O?void 0:{opacity:0}},ownerState:C});return(0,U.jsx)(R,{...z,...!as(R)&&{slots:ee,slotProps:te,disableAutoFocus:d,disableScrollLock:b},children:(0,U.jsx)(F,{...I,timeout:N,children:(0,U.jsx)(B,{...V,children:c})})})});function yb(e){return Gr(`MuiMenu`,e)}Kr(`MuiMenu`,[`root`,`paper`,`list`]);var bb={vertical:`top`,horizontal:`right`},xb={vertical:`top`,horizontal:`left`},Sb=e=>{let{classes:t}=e;return ba({root:[`root`],paper:[`paper`],list:[`list`]},yb,t)},Cb=K(vb,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiMenu`,slot:`Root`})({}),wb=K(_b,{name:`MuiMenu`,slot:`Paper`})({maxHeight:`calc(100% - 96px)`,WebkitOverflowScrolling:`touch`}),Tb=K(lb,{name:`MuiMenu`,slot:`List`})({outline:0}),Eb=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiMenu`}),{autoFocus:r=!0,children:i,className:a,disableAutoFocusItem:o=!1,onClose:s,open:c,PopoverClasses:l,transitionDuration:u=`auto`,variant:d=`selectedMenu`,slots:f={},slotProps:p={},...m}=n,h=Ri(),g={...n,autoFocus:r,disableAutoFocusItem:o,transitionDuration:u,variant:d},_=Sb(g),y=r&&c,b=y&&!o,x=v.useRef(null),S=(e,t)=>{x.current&&(x.current.adjustStyleForScrollbar(e,{direction:h?`rtl`:`ltr`}),y&&x.current.focusInitialTarget?.())},C=e=>{e.key===`Tab`&&(e.preventDefault(),s&&s(e,`tabKeyDown`))},w={slots:f,slotProps:p},T=lh({elementType:f.root,externalSlotProps:p.root,ownerState:g,className:[_.root,a]}),[E,D]=Xc(`paper`,{className:_.paper,elementType:wb,externalForwardedProps:w,shouldForwardComponentProp:!0,ownerState:g}),[O,k]=Xc(`list`,{className:_.list,elementType:Tb,shouldForwardComponentProp:!0,externalForwardedProps:w,getSlotProps:e=>({...e,onKeyDown:t=>{C(t),e.onKeyDown?.(t)}}),ownerState:g}),A=typeof p.transition==`function`?p.transition(g):p.transition;return(0,U.jsx)(Cb,{disableAutoFocus:r,onClose:s,anchorOrigin:{vertical:`bottom`,horizontal:h?`right`:`left`},transformOrigin:h?bb:xb,slots:{root:f.root,paper:E,backdrop:f.backdrop,transition:f.transition},slotProps:{root:T,paper:D,backdrop:typeof p.backdrop==`function`?p.backdrop(g):p.backdrop,transition:{...A,onEntering:(...e)=>{S(...e),A?.onEntering?.(...e)}}},open:c,ref:t,transitionDuration:u,ownerState:g,...m,classes:l,children:(0,U.jsx)(O,{actions:x,autoFocus:y,autoFocusItem:b,variant:d,...k,children:i})})}),Db=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return ba({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,`icon${q(n)}`,a&&`iconOpen`,r&&`disabled`]},hc,t)},Ob=K(`select`,{name:`MuiNativeSelect`})(({theme:e})=>({MozAppearance:`none`,WebkitAppearance:`none`,userSelect:`none`,borderRadius:0,cursor:`pointer`,"&:focus":{borderRadius:0},[`&.${gc.disabled}`]:{cursor:`default`},"&[multiple]":{height:`auto`},"&:not([multiple]) option, &:not([multiple]) optgroup":{backgroundColor:(e.vars||e).palette.background.paper},[`& ~ .${sy.root}`]:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,right:`calc(var(--_caret, 24px) + (var(--_endAdornment, 28px) - 1.5rem)/2)`},[`.${ks.root}:has(> &)`]:{"--_endAdornment":`0px`},variants:[{props:({ownerState:e})=>e.variant!==`filled`&&e.variant!==`outlined`,style:{[`.${ks.root}:has(> &)`]:{"--_caret":`24px`},[`.${ks.root}:has(> & ~ .${sy.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 24px) + var(--_endAdornment, 0px))`,minWidth:16}}},{props:{variant:`filled`},style:{[`.${ks.root}:has(> &)`]:{"--_caret":`32px`},[`.${ks.root}:has(> & ~ .${sy.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}},{props:{variant:`outlined`},style:{[`.${ks.root}:has(> &)`]:{"--_caret":`32px`},[`.${ks.root}:has(> & ~ .${sy.root})`]:{"--_endAdornment":`28px`},borderRadius:(e.vars||e).shape.borderRadius,"&:focus":{borderRadius:(e.vars||e).shape.borderRadius},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}}]})),kb=K(Ob,{name:`MuiNativeSelect`,slot:`Select`,shouldForwardProp:Jo,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.select,t[n.variant],n.error&&t.error,{[`&.${gc.multiple}`]:t.multiple}]}})({}),Ab=K(`svg`,{name:`MuiNativeSelect`})(({theme:e})=>({position:`absolute`,right:0,top:`calc(50% - .5em)`,pointerEvents:`none`,color:(e.vars||e).palette.action.active,[`&.${gc.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:({ownerState:e})=>e.open,style:{transform:`rotate(180deg)`}},{props:{variant:`filled`},style:{right:7}},{props:{variant:`outlined`},style:{right:7}}]})),jb=K(Ab,{name:`MuiNativeSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.variant&&t[`icon${q(n.variant)}`],n.open&&t.iconOpen]}})({}),Mb=v.forwardRef(function(e,t){let{className:n,disabled:r,error:i,IconComponent:a,inputRef:o,variant:s=`standard`,...c}=e,l={...e,disabled:r,variant:s,error:i},u=Db(l);return(0,U.jsxs)(v.Fragment,{children:[(0,U.jsx)(kb,{ownerState:l,className:W(u.select,n),disabled:r,ref:o||t,...c}),e.multiple?null:(0,U.jsx)(jb,{as:a,ownerState:l,className:u.icon})]})});function Nb(e){return Object.prototype.hasOwnProperty.call(e.props,`value`)}function Pb(e){if(typeof e==`string`||typeof e==`number`)return String(e);let t=``;return v.Children.forEach(e,e=>{typeof e==`string`||typeof e==`number`?t+=String(e):v.isValidElement(e)&&(t+=Pb(e.props.children))}),t}function Fb(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length;for(let n=0;n<e.length;n+=1){let i=(r+n)%e.length;if(e[i].label.startsWith(t))return i}return-1}function Ib(e,t){return!e.some(e=>e.label[0]===t&&e.label[1]===t)}function Lb(e,t){let n=[],r=-1;for(let i=0;i<e.length;i+=1){let a=e[i];if(!v.isValidElement(a)||!Nb(a)||a.props.disabled)continue;let o=Pb(a.props.children).trim().toLowerCase();o!==``&&(r===-1&&$y(t,a.props.value)&&(r=n.length),n.push({child:a,label:o,value:a.props.value}))}return{options:n,selectedIndex:r}}var Rb,zb=2,Bb=400,Vb=200,Hb=750,Ub=` `,Wb=`ArrowUp`,Gb=`ArrowDown`,Kb=`Enter`;function qb(e,t){if(!t)return!1;if(e.composedPath().includes(t)||e.target?.nodeType&&t.contains(e.target))return!0;let n=t.getBoundingClientRect();return n.width===0&&n.height===0?!1:e.clientX>=n.left-zb&&e.clientX<=n.right+zb&&e.clientY>=n.top-zb&&e.clientY<=n.bottom+zb}var Jb=K(Ob,{name:`MuiSelect`,slot:`Select`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`&.${by.select}`]:t.select},{[`&.${by.select}`]:t[n.variant]},{[`&.${by.error}`]:t.error},{[`&.${by.multiple}`]:t.multiple}]}})({[`&.${by.select}`]:{height:`auto`,minHeight:`1.4375em`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`}}),Yb=K(Ab,{name:`MuiSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.open&&t.iconOpen]}})({}),Xb=K(`input`,{shouldForwardProp:e=>qo(e)&&e!==`classes`,name:`MuiSelect`,slot:`NativeInput`})({bottom:0,left:0,position:`absolute`,opacity:0,pointerEvents:`none`,width:`100%`,boxSizing:`border-box`}),Zb=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return ba({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,a&&`iconOpen`,r&&`disabled`],nativeInput:[`nativeInput`]},yy,t)},Qb=v.forwardRef(function(e,t){let{"aria-describedby":n,"aria-label":r,autoFocus:i,autoWidth:a,children:o,className:s,defaultOpen:c,defaultValue:l,disabled:u,displayEmpty:d,error:f=!1,IconComponent:p,inputRef:m,labelId:h,MenuProps:g={},multiple:_,name:y,onBlur:b,onChange:x,onClose:S,onFocus:C,onKeyDown:w,onMouseDown:T,onOpen:E,open:D,readOnly:O,renderValue:k,required:A,SelectDisplayProps:j={},tabIndex:M,type:N,value:P,variant:F=`standard`,...I}=e,[L,R]=Od({controlled:P,default:l,name:`Select`}),[ee,te]=Od({controlled:D,default:c,name:`Select`}),z=v.useRef(null),B=v.useRef(null),V=v.useRef(null),ne=v.useRef(!1),re=v.useRef(!1),ie=v.useRef(null),ae=v.useRef(!1),oe=v.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),se=v.useRef({buffer:``,previousSearchIndex:null,matchedIndex:null}),H=Cl(),ce=Cl(),le=Cl(),[ue,de]=v.useState(null),{current:fe}=v.useRef(D!=null),[pe,me]=v.useState(),[he,ge]=v.useState(null),_e=bs(t,m),ve=v.useCallback(e=>{B.current=e,e&&de(e)},[]),ye=ue?.parentNode;v.useImperativeHandle(_e,()=>({focus:()=>{B.current.focus()},node:z.current,value:L}),[L]);let be=ue!==null&&ee,xe=v.useCallback(()=>{le.clear(),se.current.buffer=``,se.current.previousSearchIndex=null,se.current.matchedIndex=null},[le]);xs(()=>{ne.current=be,be&&xe()},[be,xe]);let Se=v.useCallback(()=>{H.clear(),ce.clear()},[H,ce]),Ce=v.useCallback(()=>{Se(),ae.current=!1,oe.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},[Se]),we=v.useCallback(()=>{ie.current&&=(ie.current(),null)},[]);v.useEffect(()=>{be||(Ce(),we())},[be,Ce,we]),v.useEffect(()=>()=>{Ce(),we(),xe()},[Ce,we,xe]),v.useEffect(()=>{if(!be||!ye||a||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{me(ye.clientWidth)});return e.observe(ye),()=>{e.disconnect()}},[be,ye,a]),v.useEffect(()=>{c&&ee&&ue&&!fe&&(me(a?null:ye.clientWidth),B.current.focus())},[ue,a]),v.useEffect(()=>{i&&B.current.focus()},[i]),v.useEffect(()=>{if(!h)return;let e=Ss(B.current).getElementById(h);if(e){let t=()=>{getSelection().isCollapsed&&B.current.focus()};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}},[h]);let Te=dl((e,t)=>{e||(Ce(),we()),e?(xe(),ge(Zy(t)),E&&E(t)):(ge(null),S&&S(t)),fe||(ne.current=e,me(a?null:ye.clientWidth),te(e))}),Ee=()=>{Ce(),re.current?ce.start(Vb,()=>{oe.current.allowUnselectedMouseUp=!0,H.start(Vb,()=>{oe.current.allowSelectedMouseUp=!0})}):H.start(Bb,()=>{oe.current.allowSelectedMouseUp=!0,oe.current.allowUnselectedMouseUp=!0})},De=e=>{if(T?.(e),e.button!==0||(e.preventDefault(),!B.current))return;B.current.focus();let t=Ss(e.currentTarget);Ee(),we();let n=e=>{ie.current=null,B.current&&(qb(e,B.current)||qb(e,V.current)||!ne.current&&fe||Te(!1,e))};t.addEventListener(`mouseup`,n,{capture:!0,once:!0}),ie.current=()=>{t.removeEventListener(`mouseup`,n,!0)},Te(!0,e)},Oe=e=>{Te(!1,e)},ke=v.Children.toArray(o),Ae=e=>{let t=ke.find(t=>t.props.value===e.target.value);t!==void 0&&(R(t.props.value),x&&x(e,t))},je=(e,t,n)=>{if(R(n),x){let r=e.nativeEvent||e,i=new r.constructor(r.type,r);Object.defineProperty(i,"target",{writable:!0,value:{value:n,name:y}}),x(i,t)}},Me=e=>t=>{ae.current=!1;let n;if(t.currentTarget.hasAttribute(`tabindex`)){if(_){n=Array.isArray(L)?L.slice():[];let t=L.indexOf(e.props.value);t===-1?n.push(e.props.value):n.splice(t,1)}else n=e.props.value;e.props.onClick&&e.props.onClick(t),L!==n&&je(t,e,n),_||Te(!1,t)}},Ne=(e,t)=>n=>{if(e.props.onMouseUp?.(n),ae.current){ae.current=!1;return}let r=!oe.current.allowSelectedMouseUp&&t,i=!oe.current.allowUnselectedMouseUp&&!t;r||i||n.currentTarget.click()},Pe=e=>{let t=se.current,n=t.buffer!==``;if(be||_||u||e.defaultPrevented||e.nativeEvent?.isComposing||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||e.key===Ub&&!n)return!1;e.key===Ub&&e.preventDefault();let r=t.buffer===``,{options:i,selectedIndex:a}=Lb(ke,L);if(i.length===0)return e.key!==Ub&&xe(),!0;r&&(t.previousSearchIndex=a);let o=e.key.toLowerCase();t.buffer===o&&Ib(i,o)&&(t.buffer=``,t.previousSearchIndex=t.matchedIndex),t.buffer+=o,le.start(Hb,xe);let s=Fb(i,t.buffer,(t.previousSearchIndex??-1)+1);if(s!==-1){let n=i[s];return t.matchedIndex=s,$y(L,n.value)||je(e,n.child,n.value),!0}return e.key!==Ub&&xe(),!0},Fe=e=>{if(!O){let t=Pe(e),n=e.key===Ub||e.key===Wb||e.key===Gb||e.key===Kb;!t&&n&&(e.preventDefault(),Te(!0,e)),w?.(e)}},Ie=e=>{xe(),!be&&b&&(Object.defineProperty(e,"target",{writable:!0,value:{value:L,name:y}}),b(e))},Le=e=>t=>{e?.props?.onKeyDown?.(t),t.key===Ub&&t.target===t.currentTarget&&!t.defaultPrevented&&(t.preventDefault(),t.repeat||t.currentTarget.click())};delete I[`aria-invalid`];let Re,ze,Be=[],Ve=!1,He=!1;(Es({value:L})||d)&&(k?Re=k(L):Ve=!0);let Ue=ke.map(e=>{if(!v.isValidElement(e))return null;let t;if(_){if(!Array.isArray(L))throw Error(Lt(2));t=L.some(t=>$y(t,e.props.value)),t&&Ve&&Be.push(e.props.children)}else t=$y(L,e.props.value),t&&Ve&&(ze=e.props.children);return t&&(He=!0),v.cloneElement(e,{"aria-selected":t?`true`:`false`,onMouseDown:t=>{ae.current=!0,e.props.onMouseDown?.(t)},onPointerDown:t=>{ae.current=!0,e.props.onPointerDown?.(t)},onClick:Me(e),onMouseUp:Ne(e,t),onKeyUp:t=>{t.key===Ub&&t.preventDefault(),e.props.onKeyUp&&e.props.onKeyUp(t)},onKeyDown:Le(e),role:`option`,selected:t,value:void 0,"data-value":e.props.value})});xs(()=>{re.current=He,!be&&!_&&!He&&xe()},[He,_,be,xe]),Ve&&(Re=_?Be.length===0?null:Be.reduce((e,t,n)=>(e.push(t),n<Be.length-1&&e.push(`, `),e),[]):ze);let We=pe;!a&&fe&&ue&&(We=ye.clientWidth);let Ge;Ge=M===void 0?u?null:0:M;let Ke=j.id||(y?`mui-component-select-${y}`:void 0),qe={...e,variant:F,value:L,open:be,error:f},Je=Zb(qe),Ye=typeof g.slotProps?.paper==`function`?g.slotProps.paper(qe):g.slotProps?.paper,Xe=bs(Ye?.ref,V),Ze=typeof g.slotProps?.list==`function`?g.slotProps.list(qe):g.slotProps?.list,Qe=Ki(),$e=Ki();return(0,U.jsxs)(v.Fragment,{children:[(0,U.jsx)(Jb,{as:`div`,ref:ve,tabIndex:Ge,role:`combobox`,"aria-controls":be?Qe:void 0,"aria-disabled":u?`true`:void 0,"aria-expanded":be?`true`:`false`,"aria-haspopup":`listbox`,"aria-readonly":O?`true`:void 0,"aria-label":r,"aria-labelledby":h,"aria-describedby":n,"aria-required":A?`true`:void 0,"aria-invalid":f?`true`:void 0,onKeyDown:Fe,onMouseDown:u||O?null:De,onBlur:Ie,onFocus:C,...j,ownerState:qe,className:W(j.className,Je.select,s),id:Ke,children:Qy(Re)?Rb||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``}):Re}),(0,U.jsx)(Xb,{"aria-invalid":f,value:Array.isArray(L)?L.join(`,`):L,name:y,ref:z,"aria-hidden":!0,onChange:Ae,tabIndex:-1,disabled:u,readOnly:O,className:Je.nativeInput,autoFocus:i,required:A,...I,id:I.id??$e,ownerState:qe}),(0,U.jsx)(Yb,{as:p,className:Je.icon,ownerState:qe}),(0,U.jsx)(nb,{value:he,children:(0,U.jsx)(Eb,{id:`menu-${y||``}`,anchorEl:ye,open:be,onClose:Oe,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},...g,slotProps:{...g.slotProps,list:{"aria-labelledby":h,role:`listbox`,"aria-multiselectable":_?`true`:void 0,disableListWrap:!0,id:Qe,...Ze},paper:{...Ye,ref:Xe,style:{minWidth:We,...Ye?.style}}},children:Ue})})]})}),$b=Y((0,U.jsx)(`path`,{d:`M7 10l5 5 5-5z`}),`ArrowDropDown`),ex=e=>{let{classes:t}=e,n=ba({root:[`root`]},yy,t);return{...t,...n}},tx={name:`MuiSelect`,slot:`Root`,shouldForwardProp:e=>Jo(e)&&e!==`variant`},nx=K(vy,tx)(``),rx=K(Ny,tx)(``),ix=K(wy,tx)(``),ax=v.forwardRef(function(e,t){let n=Xo({name:`MuiSelect`,props:e}),{autoWidth:r=!1,children:i,classes:a={},className:o,defaultOpen:s=!1,displayEmpty:c=!1,IconComponent:l=$b,id:u,input:d,inputProps:f,label:p,labelId:m,MenuProps:h,multiple:g=!1,native:_=!1,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:C,variant:w=`outlined`,...T}=n,E=_?Mb:Qb,[D]=vs({props:n,states:[`variant`,`error`]}),O=D.variant||w,k={...n,variant:O,classes:a},A=ex(k),{root:j,...M}=A,N=d||{standard:(0,U.jsx)(nx,{ownerState:k}),outlined:(0,U.jsx)(rx,{label:p,ownerState:k}),filled:(0,U.jsx)(ix,{ownerState:k})}[O],P=bs(t,Lu(N));return(0,U.jsx)(v.Fragment,{children:v.cloneElement(N,{inputComponent:E,inputProps:{children:i,error:D.error,IconComponent:l,variant:O,type:void 0,multiple:g,..._?{id:u}:{autoWidth:r,defaultOpen:s,displayEmpty:c,labelId:m,MenuProps:h,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:{id:u,...C}},...f,classes:f?Wt(M,f.classes):M,...d?d.props.inputProps:{}},...(g&&_||c)&&O===`outlined`?{notched:!0}:{},ref:P,className:W(N.props.className,o,A.root),...!d&&{variant:O},...T})})});ax.muiName=`Select`;function ox(e){return Gr(`MuiTextField`,e)}Kr(`MuiTextField`,[`root`]);var sx={standard:vy,filled:wy,outlined:Ny},cx=e=>{let{classes:t}=e;return ba({root:[`root`]},ox,t)},lx=K(Wy,{name:`MuiTextField`,slot:`Root`})({}),ux=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTextField`}),{autoComplete:r,autoFocus:i=!1,children:a,className:o,color:s=`primary`,defaultValue:c,disabled:l=!1,error:u=!1,fullWidth:d=!1,helperText:f,id:p,inputRef:m,label:h,maxRows:g,minRows:_,multiline:v=!1,name:y,onBlur:b,onChange:x,onFocus:S,placeholder:C,required:w=!1,rows:T,select:E=!1,slots:D={},slotProps:O={},type:k,value:A,variant:j=`outlined`,...M}=n,N={...n,autoFocus:i,color:s,disabled:l,error:u,fullWidth:d,multiline:v,required:w,select:E,variant:j},P=cx(N),F=Ki(p),I=f&&F?`${F}-helper-text`:void 0,L=h&&F?`${F}-label`:void 0,R=sx[j],ee={slots:D,slotProps:O},[te,z]=Xc(`select`,{elementType:ax,externalForwardedProps:ee,ownerState:N}),B=E&&z.native,V={},ne=ee.slotProps.inputLabel;j===`outlined`&&(ne&&ne.shrink!==void 0&&(V.notched=ne.shrink),V.label=h),E&&(B||(V.id=void 0),V[`aria-describedby`]=void 0);let[re,ie]=Xc(`root`,{elementType:lx,shouldForwardComponentProp:!0,externalForwardedProps:{...ee,...M},ownerState:N,className:W(P.root,o),ref:t,additionalProps:{disabled:l,error:u,fullWidth:d,required:w,color:s,variant:j}}),[ae,oe]=Xc(`input`,{elementType:R,externalForwardedProps:ee,additionalProps:V,ownerState:N}),[se,H]=Xc(`inputLabel`,{elementType:By,externalForwardedProps:ee,ownerState:N}),[ce,le]=Xc(`htmlInput`,{elementType:`input`,externalForwardedProps:ee,ownerState:N}),[ue,de]=Xc(`formHelperText`,{elementType:Jy,externalForwardedProps:ee,ownerState:N}),fe=(0,U.jsx)(ae,{"aria-describedby":I,autoComplete:r,autoFocus:i,defaultValue:c,fullWidth:d,multiline:v,name:y,rows:T,maxRows:g,minRows:_,type:k,value:A,id:F,inputRef:m,onBlur:b,onChange:x,onFocus:S,placeholder:C,inputProps:le,slots:{input:D.htmlInput?ce:void 0},...oe});return(0,U.jsxs)(re,{...ie,children:[h!=null&&h!==``&&(0,U.jsx)(se,{htmlFor:E&&!B?void 0:F,id:L,...E&&!B&&{component:`div`},...H,children:h}),E?(0,U.jsx)(te,{"aria-describedby":I,id:F,labelId:L,value:A,input:fe,...z,children:a}):fe,f&&(0,U.jsx)(ue,{id:I,...de,children:f})]})}),dx=Y((0,U.jsx)(`path`,{d:`M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0s.41-1.08 0-1.49zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14`}),`SearchRounded`),fx=`modulepreload`,px=function(e){return`/`+e},mx={},hx=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=px(t,n),t=s(t),t in mx)return;mx[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`:fx,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)})},gx=(0,v.lazy)(async()=>({default:(await hx(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-DlbuyiQ3.js`);return{MarkdownMessage:e}},[])).MarkdownMessage})),_x=new Set([`md`,`markdown`]),vx=new Set([`csv`,`tsv`]);function yx(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function bx(e,t){return e.source===`project`?Q(t,`Project`,`Project`):Q(t,`Thư mục đã cấp quyền`,`Granted directory`)}function xx(e,t){let n=[],r=[],i=``,a=!1,o=0,s=()=>{r.length<40&&r.push(i),i=``},c=()=>{s(),r.some(e=>e.length>0)&&n.push(r),r=[]};for(;o<e.length&&n.length<500;){let n=e[o];if(a){if(n===`"`&&e[o+1]===`"`){i+=`"`,o+=2;continue}if(n===`"`){a=!1,o+=1;continue}i+=n,o+=1;continue}if(n===`"`&&i.length===0){a=!0,o+=1;continue}if(n===t){s(),o+=1;continue}if(n===`
|
|
171
|
+
`,gu=e=>{let{classes:t,variant:n,color:r,disableShrink:i}=e;return ba({root:[`root`,n,`color${q(r)}`],svg:[`svg`],track:[`track`],circle:[`circle`,i&&`circleDisableShrink`]},uu,t)},_u=K(`span`,{name:`MuiCircularProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`color${q(n.color)}`]]}})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`});return{display:`inline-block`,variants:[{props:{variant:`determinate`},style:{...Ks(e,`transform`)}},{props:{variant:`indeterminate`},style:mu||{animation:`${fu} 1.4s linear infinite`}},...t?[{props:{variant:`indeterminate`},style:t}]:[],...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}}))]}})),vu=K(`svg`,{name:`MuiCircularProgress`,slot:`Svg`})({display:`block`}),yu=K(`circle`,{name:`MuiCircularProgress`,slot:`Circle`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.circle,n.disableShrink&&t.circleDisableShrink]}})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`});return{stroke:`currentColor`,variants:[{props:{variant:`determinate`},style:{...Ks(e,`stroke-dashoffset`)}},{props:{variant:`indeterminate`},style:{strokeDasharray:`80px, 200px`,strokeDashoffset:0}},{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:hu||{animation:`${pu} 1.4s ease-in-out infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:t}]:[]]}})),bu=K(`circle`,{name:`MuiCircularProgress`,slot:`Track`})(ys(({theme:e})=>({stroke:`currentColor`,opacity:(e.vars||e).palette.action.activatedOpacity}))),xu=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiCircularProgress`}),{className:r,color:i=`primary`,disableShrink:a=!1,enableTrackSlot:o=!1,min:s,max:c,size:l=40,style:u,thickness:d=3.6,value:f=n.min??0,variant:p=`indeterminate`,...m}=n,h=s??0,g=c??100,_={...n,color:i,disableShrink:a,size:l,thickness:d,value:f,variant:p,enableTrackSlot:o},v=gu(_),y={},b={},x={};if(p===`determinate`){let e=2*Math.PI*((du-d)/2),t=g-h;y.strokeDasharray=e.toFixed(3),y.strokeDashoffset=t>0?`${((g-f)/t*e).toFixed(3)}px`:`${e.toFixed(3)}px`,b.transform=`rotate(-90deg)`,x[`aria-valuenow`]=f,x[`aria-valuemin`]=h,x[`aria-valuemax`]=g}return(0,U.jsx)(_u,{className:W(v.root,r),style:{width:l,height:l,...b,...u},ownerState:_,ref:t,role:`progressbar`,...x,...m,children:(0,U.jsxs)(vu,{className:v.svg,ownerState:_,viewBox:`${du/2} ${du/2} ${du} ${du}`,children:[o?(0,U.jsx)(bu,{className:v.track,ownerState:_,cx:du,cy:du,r:(du-d)/2,fill:`none`,strokeWidth:d,"aria-hidden":`true`}):null,(0,U.jsx)(yu,{className:v.circle,style:y,ownerState:_,cx:du,cy:du,r:(du-d)/2,fill:`none`,strokeWidth:d})]})})});function Su(e){return Gr(`MuiDivider`,e)}var Cu=Kr(`MuiDivider`,[`root`,`absolute`,`fullWidth`,`inset`,`middle`,`flexItem`,`vertical`,`withChildren`,`textAlignRight`,`textAlignLeft`,`wrapper`,`wrapperVertical`]),wu=e=>{let{absolute:t,children:n,classes:r,flexItem:i,orientation:a,textAlign:o,variant:s}=e;return ba({root:[`root`,t&&`absolute`,s,a===`vertical`&&`vertical`,i&&`flexItem`,n&&`withChildren`,o===`right`&&a!==`vertical`&&`textAlignRight`,o===`left`&&a!==`vertical`&&`textAlignLeft`],wrapper:[`wrapper`,a===`vertical`&&`wrapperVertical`]},Su,r)},Tu=K(`div`,{name:`MuiDivider`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.absolute&&t.absolute,t[n.variant],n.orientation===`vertical`&&t.vertical,n.flexItem&&t.flexItem,n.children&&t.withChildren,n.textAlign===`right`&&n.orientation!==`vertical`&&t.textAlignRight,n.textAlign===`left`&&n.orientation!==`vertical`&&t.textAlignLeft]}})(ys(({theme:e})=>({margin:0,flexShrink:0,borderWidth:0,borderStyle:`solid`,borderColor:(e.vars||e).palette.divider,borderBottomWidth:`thin`,variants:[{props:{absolute:!0},style:{position:`absolute`,bottom:0,left:0,width:`100%`}},{props:{variant:`inset`},style:{marginLeft:72}},{props:{variant:`middle`,orientation:`horizontal`},style:{marginLeft:e.spacing(2),marginRight:e.spacing(2)}},{props:{variant:`middle`,orientation:`vertical`},style:{marginTop:e.spacing(1),marginBottom:e.spacing(1)}},{props:{orientation:`vertical`},style:{height:`100%`,borderBottomWidth:0,borderRightWidth:`thin`}},{props:{flexItem:!0},style:{alignSelf:`stretch`,height:`auto`}},{props:({ownerState:e})=>!!e.children,style:{display:`flex`,textAlign:`center`,border:0,borderTopStyle:`solid`,borderLeftStyle:`solid`,"&::before, &::after":{content:`""`,alignSelf:`center`}}},{props:({ownerState:e})=>e.children&&e.orientation!==`vertical`,style:{"&::before, &::after":{width:`100%`,borderTop:`thin solid ${(e.vars||e).palette.divider}`,borderTopStyle:`inherit`}}},{props:({ownerState:e})=>e.orientation===`vertical`&&e.children,style:{flexDirection:`column`,"&::before, &::after":{height:`100%`,borderLeft:`thin solid ${(e.vars||e).palette.divider}`,borderLeftStyle:`inherit`}}},{props:({ownerState:e})=>e.textAlign===`right`&&e.orientation!==`vertical`,style:{"&::before":{width:`90%`},"&::after":{width:`10%`}}},{props:({ownerState:e})=>e.textAlign===`left`&&e.orientation!==`vertical`,style:{"&::before":{width:`10%`},"&::after":{width:`90%`}}}]}))),Eu=K(`span`,{name:`MuiDivider`,slot:`Wrapper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.wrapper,n.orientation===`vertical`&&t.wrapperVertical]}})(ys(({theme:e})=>({display:`inline-block`,paddingLeft:`calc(${e.spacing(1)} * 1.2)`,paddingRight:`calc(${e.spacing(1)} * 1.2)`,whiteSpace:`nowrap`,variants:[{props:{orientation:`vertical`},style:{paddingTop:`calc(${e.spacing(1)} * 1.2)`,paddingBottom:`calc(${e.spacing(1)} * 1.2)`}}]}))),Du=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDivider`}),{absolute:r=!1,children:i,className:a,orientation:o=`horizontal`,component:s=i||o===`vertical`?`div`:`hr`,flexItem:c=!1,role:l=s===`hr`?void 0:`separator`,textAlign:u=`center`,variant:d=`fullWidth`,...f}=n,p={...n,absolute:r,component:s,flexItem:c,orientation:o,role:l,textAlign:u,variant:d},m=wu(p);return(0,U.jsx)(Tu,{as:s,className:W(m.root,a),role:l,ref:t,ownerState:p,"aria-orientation":l===`separator`&&(s!==`hr`||o===`vertical`)?o:void 0,...f,children:i?(0,U.jsx)(Eu,{className:m.wrapper,ownerState:p,children:i}):null})});function Ou(e=window){let t=e.document.documentElement.clientWidth;return e.innerWidth-t}function ku(e){let t=ls(e);return e===t.body||e===t.documentElement?us(e).innerWidth>t.documentElement.clientWidth:e.scrollHeight>e.clientHeight}function Au(e,t){t?e.setAttribute(`aria-hidden`,`true`):e.removeAttribute(`aria-hidden`)}function ju(e){return parseFloat(us(e).getComputedStyle(e).paddingRight)||0}function Mu(e){let t=[`TEMPLATE`,`SCRIPT`,`STYLE`,`LINK`,`MAP`,`META`,`NOSCRIPT`,`PICTURE`,`COL`,`COLGROUP`,`PARAM`,`SLOT`,`SOURCE`,`TRACK`].includes(e.tagName),n=e.tagName===`INPUT`&&e.getAttribute(`type`)===`hidden`;return t||n}function Nu(e,t,n,r,i){let a=[t,n,...r];[].forEach.call(e.children,e=>{let t=!a.includes(e),n=!Mu(e);t&&n&&Au(e,i)})}function Pu(e,t){let n=[],r=e.container;if(!t.disableScrollLock){let e;if(r.parentNode instanceof DocumentFragment)e=ls(r).body;else{let t=r.parentElement,n=us(r);e=t?.nodeName===`HTML`&&n.getComputedStyle(t).overflowY===`scroll`?t:r}if(ku(e)){let t=Ou(us(e));n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${ju(e)+t}px`;let i=ls(r).querySelectorAll(`.mui-fixed`);[].forEach.call(i,e=>{n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${ju(e)+t}px`})}n.push({value:e.style.overflow,property:`overflow`,el:e},{value:e.style.overflowX,property:`overflow-x`,el:e},{value:e.style.overflowY,property:`overflow-y`,el:e}),e.style.overflow=`hidden`}return()=>{n.forEach(({value:e,el:t,property:n})=>{e?t.style.setProperty(n,e):t.style.removeProperty(n)})}}function Fu(e){let t=[];return[].forEach.call(e.children,e=>{e.getAttribute(`aria-hidden`)===`true`&&t.push(e)}),t}var Iu=class{constructor(){this.modals=[],this.containers=[]}add(e,t){let n=this.modals.indexOf(e);if(n!==-1)return n;n=this.modals.length,this.modals.push(e),e.modalRef&&Au(e.modalRef,!1);let r=Fu(t);Nu(t,e.mount,e.modalRef,r,!0);let i=this.containers.findIndex(e=>e.container===t);return i===-1?(this.containers.push({modals:[e],container:t,restore:null,hiddenSiblings:r}),n):(this.containers[i].modals.push(e),n)}mount(e,t){let n=this.containers.findIndex(t=>t.modals.includes(e)),r=this.containers[n];r.restore||=Pu(r,t)}remove(e,t=!0){let n=this.modals.indexOf(e);if(n===-1)return n;let r=this.containers.findIndex(t=>t.modals.includes(e)),i=this.containers[r];if(i.modals.splice(i.modals.indexOf(e),1),this.modals.splice(n,1),i.modals.length===0)i.restore&&i.restore(),e.modalRef&&Au(e.modalRef,t),Nu(i.container,e.mount,e.modalRef,i.hiddenSiblings,!1),this.containers.splice(r,1);else{let e=i.modals[i.modals.length-1];e.modalRef&&Au(e.modalRef,!1)}return n}isTopModal(e){return this.modals.length>0&&this.modals[this.modals.length-1]===e}};function Lu(e){return e?.props?.ref||null}function Ru(e,t){if(!e||!t)return!1;if(e.contains(t))return!0;let n=t.getRootNode?.();if(n&&n instanceof ShadowRoot){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode??n.host??null}}return!1}var zu=Ru,Bu=`data-mui-focusable`;function Vu(e){return e?e.hasAttribute(`data-mui-focusable`)?e:e.querySelector(`[${Bu}]`):null}var Hu=[`input`,`select`,`textarea`,`a[href]`,`button`,`[tabindex]`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function Uu(e){let t=parseInt(e.getAttribute(`tabindex`)||``,10);return Number.isNaN(t)?e.contentEditable===`true`||(e.nodeName===`AUDIO`||e.nodeName===`VIDEO`||e.nodeName===`DETAILS`)&&e.getAttribute(`tabindex`)===null?0:e.tabIndex:t}function Wu(e){if(e.tagName!==`INPUT`||e.type!==`radio`||!e.name)return!1;let t=t=>e.ownerDocument.querySelector(`input[type="radio"]${t}`),n=t(`[name="${e.name}"]:checked`);return n||=t(`[name="${e.name}"]`),n!==e}function Gu(e){return!(e.disabled||e.tagName===`INPUT`&&e.type===`hidden`||Wu(e))}function Ku(e){let t=[],n=[];return Array.from(e.querySelectorAll(Hu)).forEach((e,r)=>{let i=Uu(e);i===-1||!Gu(e)||(i===0?t.push(e):n.push({documentOrder:r,tabIndex:i,node:e}))}),n.sort((e,t)=>e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex).map(e=>e.node).concat(t)}function qu(){return!0}function Ju(e){let{children:t,disableAutoFocus:n=!1,disableEnforceFocus:r=!1,disableRestoreFocus:i=!1,getTabbable:a=Ku,isEnabled:o=qu,open:s}=e,c=v.useRef(!1),l=v.useRef(null),u=v.useRef(null),d=v.useRef(null),f=v.useRef(null),p=v.useRef(!1),m=v.useRef(null),h=ss(Lu(t),m),g=v.useRef(null);v.useEffect(()=>{!s||!m.current||(p.current=!n)},[n,s]),v.useEffect(()=>{if(c.current=!1,!s||!m.current)return;let e=ws(ls(m.current)),t=Vu(m.current)??m.current;return zu(m.current,e)||(t.hasAttribute(`tabIndex`)||t.setAttribute(`tabIndex`,`-1`),p.current&&t.focus()),()=>{!i&&d.current&&(c.current=!0,d.current.focus(),d.current=null)}},[s]),v.useEffect(()=>{if(!s||!m.current)return;let e=ls(m.current),t=t=>{if(g.current=t,r||!o()||t.key!==`Tab`)return;let n=m.current,i=ws(e);if(n===null)return;let s=Vu(n);if(i===n||i===s){let e=a(n);if(e.length===0)return;t.preventDefault(),t.shiftKey?e[e.length-1].focus():e[0].focus();return}if(zu(n,i)){let e=a(n),r=e.indexOf(i);if(r===-1||!e.some(e=>Uu(e)>0))return;t.preventDefault();let o=0;o=t.shiftKey?r<=0?e.length-1:r-1:r===e.length-1?0:r+1,e[o].focus()}},n=()=>{let t=m.current;if(t===null)return;let n=ws(e);if(!e.hasFocus()||!o()||c.current){c.current=!1;return}if(zu(t,n)||r&&n!==l.current&&n!==u.current)return;if(n!==f.current)f.current=null;else if(f.current!==null)return;if(!p.current)return;let i=[];if((n===l.current||n===u.current)&&(i=a(m.current)),i.length>0){let e=!!(g.current?.shiftKey&&g.current?.key===`Tab`),t=i[0],n=i[i.length-1];typeof t!=`string`&&typeof n!=`string`&&(e?n.focus():t.focus())}else t.focus()};e.addEventListener(`focusin`,n),e.addEventListener(`keydown`,t,!0);let i=setInterval(()=>{let t=ws(e);t&&t.tagName===`BODY`&&n()},50);return()=>{clearInterval(i),e.removeEventListener(`focusin`,n),e.removeEventListener(`keydown`,t,!0)}},[n,r,i,o,s,a]);let _=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0,f.current=e.target;let n=t.props.onFocus;n&&n(e)},y=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0};return(0,U.jsxs)(v.Fragment,{children:[(0,U.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:l,"data-testid":`sentinelStart`}),v.cloneElement(t,{ref:h,onFocus:_}),(0,U.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:u,"data-testid":`sentinelEnd`})]})}function Yu(e,t){typeof e==`function`?e(t):e&&(e.current=t)}var Xu=l(h(),1);function Zu(e){return typeof e==`function`?e():e}var Qu=v.forwardRef(function(e,t){let{children:n,container:r,disablePortal:i=!1}=e,[a,o]=v.useState(null),s=ss(v.isValidElement(n)?Lu(n):null,t);if(ci(()=>{i||o(Zu(r)||document.body)},[r,i]),ci(()=>{if(a&&!i)return Yu(t,a),()=>{Yu(t,null)}},[t,a,i]),i){if(v.isValidElement(n)){let e={ref:s};return v.cloneElement(n,e)}return n}return a&&Xu.createPortal(n,a)});function $u(e){let t=gl(()=>ed(e)).current;return t.next=e,ci(t.effect),t}function ed(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var td=v.createContext(null);function nd(e){if(e==null)return{appear:void 0,enter:void 0,exit:void 0};if(typeof e==`number`)return{appear:e,enter:e,exit:e};let t=e.enter,n=e.exit;return{appear:e.appear===void 0?t:e.appear,enter:t,exit:n}}function rd(e){if(e.autoTimeout!=null)return e.autoTimeout;let t=nd(e.timeout);return e.currentStatus===`entering`?e.isAppearing?t.appear??t.enter??null:t.enter??null:t.exit??null}function id(e){let{in:t=!1,appear:n=!1,enter:r=!0,exit:i=!0,mountOnEnter:a=!1,unmountOnExit:o=!1,timeout:s,addEndListener:c,reduceMotion:l=!1,getAutoTimeout:u,nodeRef:d,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,children:y,...b}=e,x=v.useContext(td),S=x&&!x.isMounting?r:n,[C,w]=v.useState(()=>t?S?`exited`:`entered`:a||o?`unmounted`:`exited`),T=v.useRef(C);T.current=C,t&&C===`unmounted`&&(T.current=`exited`,w(`exited`));let E=v.useRef(t&&S),D=v.useRef(!1),O=v.useRef(null),k=v.useRef(C),A=v.useRef(!1),j=v.useRef(l),M=$u({timeout:s,addEndListener:c,reduceMotion:l,getAutoTimeout:u,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,enter:r,exit:i,mountOnEnter:a,unmountOnExit:o,nodeRef:d,parentGroup:x}),N=v.useCallback(()=>{O.current!==null&&(O.current.cancel(),O.current=null)},[]),P=v.useCallback(e=>{let t=!0,n=()=>{t&&(t=!1,O.current=null,e())};return n.cancel=()=>{t=!1},O.current=n,n},[]),F=v.useCallback((e,t)=>{let n,r=()=>{n!==void 0&&(clearTimeout(n),n=void 0)},i=P(()=>{r(),T.current=e,w(e)}),a=i.cancel;i.cancel=()=>{r(),a()};let o=M.current.nodeRef.current,s=M.current.addEndListener,c=M.current.getAutoTimeout!==void 0,l=M.current.getAutoTimeout?.(),u=rd({currentStatus:t,isAppearing:A.current,timeout:M.current.timeout,autoTimeout:l}),d=j.current,f=u??(d&&c?0:null),p=e=>{n=setTimeout(i,e)};if(!o){p(0);return}if(s){f!=null&&p(d?0:f),s.length>=2?s(o,i):s(i);return}p(d?0:u??0)},[P,M]),I=v.useCallback(e=>{let t=M.current,n=t.parentGroup?t.parentGroup.isMounting:e;if(A.current=n,!e&&!t.enter){T.current=`entered`,w(`entered`);return}j.current=t.reduceMotion,t.onEnter?.(n),T.current=`entering`,w(`entering`)},[M]),L=v.useCallback(()=>{let e=M.current;if(!e.exit){T.current=`exited`,w(`exited`);return}j.current=e.reduceMotion,e.onExit?.(),T.current=`exiting`,w(`exiting`)},[M]),R=v.useCallback((e,t)=>{if(N(),t===`entering`){let t=M.current;if(t.mountOnEnter||t.unmountOnExit){let e=t.nodeRef.current;e&&Ms(e)}I(e)}else L()},[N,I,L,M]);return ci(()=>(D.current=!0,E.current&&(E.current=!1,R(!0,`entering`)),()=>{D.current=!1,N()}),[N,R]),ci(()=>{if(!D.current)return;let e=T.current;t?e!==`entering`&&e!==`entered`&&R(!1,`entering`):e===`entering`||e===`entered`?R(!1,`exiting`):e===`exited`&&o&&(T.current=`unmounted`,w(`unmounted`))},[t,C,o,R]),ci(()=>{if(C===`unmounted`||k.current===`unmounted`){k.current=C;return}let e=k.current!==C;e&&(k.current=C);let t=M.current;C===`entering`?(e&&t.onEntering?.(A.current),O.current===null&&T.current===C&&F(`entered`,`entering`)):C===`exiting`?(e&&t.onExiting?.(),O.current===null&&T.current===C&&F(`exited`,`exiting`)):C===`entered`&&e?t.onEntered?.(A.current):C===`exited`&&e&&t.onExited?.()},[M,F,C]),C===`unmounted`?null:(0,U.jsx)(td.Provider,{value:null,children:y(C,b)})}var ad={entering:{opacity:1},entered:{opacity:1},exiting:{opacity:0},exited:{opacity:0}},od={opacity:0,visibility:`hidden`},sd=v.forwardRef(function(e,t){let n=Go(),r={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:i,appear:a=!0,children:o,disablePrefersReducedMotion:s=!1,easing:c,in:l,onEnter:u,onEntered:d,onEntering:f,onExit:p,onExited:m,onExiting:h,style:g,timeout:_=r,...y}=e,b=Ll(n.motion.reducedMotion,s),x=v.useRef(null),S=bs(x,Lu(o),t),C=Hs(x,f),w=Hs(x,(e,t)=>{b.shouldReduceMotion||Ms(e);let r=Ws({style:g,timeout:_,easing:c},{mode:`enter`}),i=b.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`opacity`,{duration:i.duration,easing:r.easing,delay:i.delay}),u&&u(e,t)}),T=Hs(x,d),E=Hs(x,h),D=Hs(x,e=>{let t=Ws({style:g,timeout:_,easing:c},{mode:`exit`}),r=b.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`opacity`,{duration:r.duration,easing:t.easing,delay:r.delay}),p&&p(e)}),O=Hs(x,e=>{e.style.transition=``,m&&m(e)});return(0,U.jsx)(id,{appear:a,in:l,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:i?e=>{i(x.current,e)}:void 0,reduceMotion:b.shouldReduceMotion,timeout:_,...y,children:(e,{ownerState:t,...n})=>{let r=Us(e,l,ad,od,g,o.props.style);return v.cloneElement(o,{style:r,ref:S,...n})}})});function cd(e){return Gr(`MuiBackdrop`,e)}Kr(`MuiBackdrop`,[`root`,`invisible`]);var ld=e=>{let{classes:t,invisible:n}=e;return ba({root:[`root`,n&&`invisible`]},cd,t)},ud=K(`div`,{name:`MuiBackdrop`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.invisible&&t.invisible]}})({position:`fixed`,display:`flex`,alignItems:`center`,justifyContent:`center`,right:0,bottom:0,top:0,left:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,WebkitTapHighlightColor:`transparent`,variants:[{props:{invisible:!0},style:{backgroundColor:`transparent`}}]}),dd=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiBackdrop`}),{children:r,className:i,component:a=`div`,invisible:o=!1,open:s,slotProps:c={},slots:l={},transitionDuration:u,...d}=n,f={...n,component:a,invisible:o},p=ld(f),m={component:a,slots:l,slotProps:c},[h,g]=Xc(`root`,{elementType:ud,externalForwardedProps:m,className:W(p.root,i),ownerState:f}),[_,v]=Xc(`transition`,{elementType:sd,externalForwardedProps:m,ownerState:f});return(0,U.jsx)(_,{in:s,timeout:u,...d,...v,children:(0,U.jsx)(h,{...g,ref:t,children:r})})});function fd(...e){return e.reduce((e,t)=>t==null?e:function(...n){e.apply(this,n),t.apply(this,n)},()=>{})}function pd(e){return typeof e==`function`?e():e}function md(e){return e?e.props.hasOwnProperty(`in`):!1}var hd=()=>{},gd=new Iu;function _d(e){let{container:t,disableScrollLock:n=!1,closeAfterTransition:r=!1,onTransitionEnter:i,onTransitionExited:a,children:o,onClose:s,open:c,rootRef:l}=e,u=v.useRef({}),d=v.useRef(null),f=v.useRef(null),p=v.useRef(null),m=ss(p,l),[h,g]=v.useState(!c),_=md(o),y=!0;(e[`aria-hidden`]===`false`||e[`aria-hidden`]===!1)&&(y=!1);let b=()=>ls(d.current),x=()=>(u.current.modalRef=p.current,u.current.mount=d.current,u.current),S=()=>{gd.mount(x(),{disableScrollLock:n}),p.current&&(p.current.scrollTop=0)},C=cs(()=>{let e=pd(t)||b().body;gd.add(x(),e),p.current&&S()}),w=()=>gd.isTopModal(x()),T=cs(e=>{d.current=e,e&&(f.current=e,c&&w()?S():p.current&&Au(p.current,y))}),E=v.useCallback(()=>{gd.remove(x(),y)},[y]);v.useEffect(()=>()=>{E()},[E]),v.useEffect(()=>{c?C():(!_||!r)&&E()},[c,E,_,r,C]);let D=e=>t=>{e.onKeyDown?.(t),!(t.key!==`Escape`||t.which===229||!w())&&(t.stopPropagation(),s&&s(t,`escapeKeyDown`))},O=e=>t=>{e.onClick?.(t),t.target===t.currentTarget&&s&&s(t,`backdropClick`)};return{getRootProps:(t={})=>{let n=qc(e);delete n.onTransitionEnter,delete n.onTransitionExited;let r={...n,...t};return{role:`presentation`,...r,onKeyDown:D(r),ref:m}},getBackdropProps:(e={})=>{let t=e;return{"aria-hidden":!0,...t,onClick:O(t),open:c}},getTransitionProps:()=>({onEnter:fd(()=>{g(!1),i&&i()},o?.props.onEnter??hd),onExited:fd(()=>{g(!0),a&&a(),r&&E()},o?.props.onExited??hd)}),rootRef:m,portalRef:T,portalContainer:!c&&_&&!h?f.current??t:t,isTopModal:w,exited:h,hasTransition:_}}function vd(e){return Gr(`MuiModal`,e)}Kr(`MuiModal`,[`root`,`hidden`,`backdrop`]);var yd=e=>{let{open:t,exited:n,classes:r}=e;return ba({root:[`root`,!t&&n&&`hidden`],backdrop:[`backdrop`]},vd,r)},bd=K(`div`,{name:`MuiModal`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.open&&n.exited&&t.hidden]}})(ys(({theme:e})=>({position:`fixed`,zIndex:(e.vars||e).zIndex.modal,right:0,bottom:0,top:0,left:0,variants:[{props:({ownerState:e})=>!e.open&&e.exited,style:{visibility:`hidden`}}]}))),xd=K(dd,{name:`MuiModal`,slot:`Backdrop`})({zIndex:-1}),Sd=v.forwardRef(function(e,t){let n=Xo({name:`MuiModal`,props:e}),{classes:r,className:i,closeAfterTransition:a=!1,children:o,container:s,component:c,disableAutoFocus:l=!1,disableEnforceFocus:u=!1,disablePortal:d=!1,disableRestoreFocus:f=!1,disableScrollLock:p=!1,hideBackdrop:m=!1,keepMounted:h=!1,onClose:g,onTransitionEnter:_,onTransitionExited:y,open:b,slotProps:x={},slots:S={},theme:C,...w}=n,T={...n,closeAfterTransition:a,disableAutoFocus:l,disableEnforceFocus:u,disablePortal:d,disableRestoreFocus:f,disableScrollLock:p,hideBackdrop:m,keepMounted:h},{getRootProps:E,getBackdropProps:D,getTransitionProps:O,portalRef:k,portalContainer:A,isTopModal:j,exited:M,hasTransition:N}=_d({...T,rootRef:t}),P={...T,exited:M},F=yd(P),I={};if(o.props.tabIndex===void 0&&(I.tabIndex=`-1`),N){let{onEnter:e,onExited:t}=O();I.onEnter=e,I.onExited=t}let L={slots:S,slotProps:x},[R,ee]=Xc(`root`,{ref:t,elementType:bd,externalForwardedProps:{...L,...w,component:c},getSlotProps:E,ownerState:P,className:W(i,F?.root,!P.open&&P.exited&&F?.hidden)}),[te,z]=Xc(`backdrop`,{elementType:xd,externalForwardedProps:L,shouldForwardComponentProp:!0,getSlotProps:e=>D({...e,onClick:t=>{e?.onClick&&e.onClick(t)}}),className:F?.backdrop,ownerState:P});return!h&&!b&&(!N||M)?null:(0,U.jsx)(Qu,{ref:k,container:A,disablePortal:d,children:(0,U.jsxs)(R,{...ee,children:[m?null:(0,U.jsx)(te,{...z}),(0,U.jsx)(Ju,{disableEnforceFocus:u,disableAutoFocus:l,disableRestoreFocus:f,isEnabled:j,open:b,children:v.cloneElement(o,I)})]})})}),Cd=os,wd=xa,Td=us,Ed=Ki;function Dd(e){let{controlled:t,default:n,name:r,state:i=`value`}=e,{current:a}=v.useRef(t!==void 0),[o,s]=v.useState(n);return[a?t:o,v.useCallback(e=>{a||s(e)},[])]}var Od=Dd;function kd(e,t){if(!e)return t;function n(e,t){let n={};return Object.keys(t).forEach(r=>{Kc(r,t[r])&&typeof e[r]==`function`&&(n[r]=(...n)=>{e[r](...n),t[r](...n)})}),n}if(typeof e==`function`||typeof t==`function`)return r=>{let i=typeof t==`function`?t(r):t,a=typeof e==`function`?e({...r,...i}):e,o=W(r?.className,i?.className,a?.className),s=n(a,i);return{...i,...a,...s,...!!o&&{className:o},...i?.style&&a?.style&&{style:{...i.style,...a.style}},...i?.sx&&a?.sx&&{sx:[...Array.isArray(i.sx)?i.sx:[i.sx],...Array.isArray(a.sx)?a.sx:[a.sx]]}}};let r=t,i=n(e,r),a=W(r?.className,e?.className);return{...t,...e,...i,...!!a&&{className:a},...r?.style&&e?.style&&{style:{...r.style,...e.style}},...r?.sx&&e?.sx&&{sx:[...Array.isArray(r.sx)?r.sx:[r.sx],...Array.isArray(e.sx)?e.sx:[e.sx]]}}}var Ad={visibility:`hidden`},jd={};function Md(e){return typeof e==`string`&&/^translate\(.+,\s*.+\)$/.test(e)}function Nd(e,t,n,r=jd){let{resetInlineTransform:i=!0}=r,a=n&&n.getBoundingClientRect(),o=Td(t),s,c;if(i){let e=t.style.transform,n=t.style.transition;t.style.transition=``,t.style.transform=``,s=t.getBoundingClientRect(),c=o.getComputedStyle(t).getPropertyValue(`transform`),t.style.transform=e,t.style.transition=n}else s=t.getBoundingClientRect(),c=o.getComputedStyle(t).getPropertyValue(`transform`);let{offsetX:l,offsetY:u}=Vs(c);return e===`left`?a?`translateX(${a.right+l-s.left}px)`:`translateX(${o.innerWidth+l-s.left}px)`:e===`right`?a?`translateX(-${s.right-a.left-l}px)`:`translateX(-${s.left+s.width-l}px)`:e===`up`?a?`translateY(${a.bottom+u-s.top}px)`:`translateY(${o.innerHeight+u-s.top}px)`:a?`translateY(-${s.top-a.top+s.height-u}px)`:`translateY(-${s.top+s.height-u}px)`}function Pd(e){return typeof e==`function`?e():e}function Fd(e,t,n,r){let i=Nd(e,t,Pd(n),r);i&&(t.style.transform=i)}var Id=v.forwardRef(function(e,t){let n=Go(),r={enter:n.transitions.easing.easeOut,exit:n.transitions.easing.sharp},i={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:a,appear:o=!0,children:s,container:c,disablePrefersReducedMotion:l=!1,direction:u=`down`,easing:d=r,in:f,onEnter:p,onEntered:m,onEntering:h,onExit:g,onExited:_,onExiting:y,style:b,timeout:x=i,...S}=e,C=Ll(n.motion.reducedMotion,l),w=v.useRef(null),T=v.useRef(!1),E=bs(Lu(s),w,t),D=Hs(w,(e,t)=>{Fd(u,e,c),C.shouldReduceMotion||Ms(e),p&&p(e,t)}),O=Hs(w,(e,t)=>{let r=Ws({timeout:x,style:b,easing:d},{mode:`enter`}),i=C.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`transform`,{duration:i.duration,easing:r.easing,delay:i.delay}),e.style.transform=`none`,h&&h(e,t)}),k=Hs(w,m),A=Hs(w,y),j=Hs(w,e=>{let t=Ws({timeout:x,style:b,easing:d},{mode:`exit`}),r=C.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`transform`,{duration:r.duration,easing:t.easing,delay:r.delay});let i=Md(e.style.transform);T.current=i,Fd(u,e,c,{resetInlineTransform:!i}),g&&g(e)}),M=Hs(w,e=>{T.current=!1,e.style.transition=``,_&&_(e)}),N=a?e=>{a(w.current,e)}:void 0,P=v.useCallback(()=>{w.current&&Fd(u,w.current,c)},[u,c]);return v.useEffect(()=>{if(f||u===`down`||u===`right`)return;let e=Cd(()=>{w.current&&Fd(u,w.current,c)}),t=Td(w.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[u,f,c]),v.useEffect(()=>{!f&&!T.current&&P()},[f,P]),(0,U.jsx)(id,{nodeRef:w,onEnter:D,onEntered:k,onEntering:O,onExit:j,onExited:M,onExiting:A,addEndListener:N,appear:o,in:f,reduceMotion:C.shouldReduceMotion,timeout:x,...S,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!f?b||s.props.style?{visibility:`hidden`,...b,...s.props.style}:Ad:b&&s.props.style?{...b,...s.props.style}:b||s.props.style,v.cloneElement(s,{ref:E,style:r,...n})}})});function Ld(e){return Gr(`MuiDrawer`,e)}Kr(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`modal`]);var Rd=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},zd=e=>{let{classes:t,anchor:n,variant:r}=e;return ba({root:[`root`,`anchor${q(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`]},Ld,t)},Bd=K(Sd,{name:`MuiDrawer`,slot:`Root`,overridesResolver:Rd})(ys(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),Vd=K(`div`,{shouldForwardProp:Jo,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:Rd})({flex:`0 0 auto`}),Hd=K(Pc,{name:`MuiDrawer`,slot:`Paper`})(ys(({theme:e})=>({overflowY:`auto`,display:`flex`,flexDirection:`column`,height:`100%`,flex:`1 0 auto`,zIndex:(e.vars||e).zIndex.drawer,WebkitOverflowScrolling:`touch`,position:`fixed`,top:0,outline:0,variants:[{props:{anchor:`left`},style:{left:0}},{props:{anchor:`top`},style:{top:0,left:0,right:0,height:`auto`,maxHeight:`100%`}},{props:{anchor:`right`},style:{right:0}},{props:{anchor:`bottom`},style:{top:`auto`,left:0,bottom:0,right:0,height:`auto`,maxHeight:`100%`}},{props:({ownerState:e})=>e.anchor===`left`&&e.variant!==`temporary`,style:{borderRight:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`top`&&e.variant!==`temporary`,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`right`&&e.variant!==`temporary`,style:{borderLeft:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>e.anchor===`bottom`&&e.variant!==`temporary`,style:{borderTop:`1px solid ${(e.vars||e).palette.divider}`}}]}))),Ud={left:`right`,right:`left`,top:`down`,bottom:`up`};function Wd(e){return[`left`,`right`].includes(e)}function Gd({direction:e},t){return e===`rtl`&&Wd(t)?Ud[t]:t}var Kd=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDrawer`}),r=Go(),i=Ri(),a={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{anchor:o=`left`,children:s,className:c,elevation:l=16,hideBackdrop:u=!1,ModalProps:d={},onClose:f,open:p=!1,transitionDuration:m=a,variant:h=`temporary`,slots:g={},slotProps:_={},...y}=n,b=v.useRef(!1),x=v.useRef(null),S=bs(t,x);v.useEffect(()=>{b.current=!0},[]);let C=v.useCallback(()=>x.current,[]),w=Gd({direction:i?`rtl`:`ltr`},o),T=o,E={...n,anchor:T,elevation:l,open:p,variant:h,...y},D=zd(E),O={slots:g,slotProps:{..._,backdrop:kd(_.backdrop,{transitionDuration:m})}},[k,A]=Xc(`root`,{ref:S,elementType:Bd,className:W(D.root,D.modal,c),shouldForwardComponentProp:!0,ownerState:E,externalForwardedProps:{...O,...y,...d},additionalProps:{closeAfterTransition:!0,open:p,onClose:f,hideBackdrop:u,slots:{backdrop:O.slots.backdrop},slotProps:{backdrop:O.slotProps.backdrop}}}),[j,M]=Xc(`paper`,{elementType:Hd,shouldForwardComponentProp:!0,className:D.paper,ownerState:E,externalForwardedProps:O,additionalProps:{elevation:h===`temporary`?l:0,square:!0,...h===`temporary`&&{role:`dialog`,"aria-modal":`true`,"data-mui-focusable":``,tabIndex:-1}}}),[N,P]=Xc(`docked`,{elementType:Vd,ref:S,className:W(D.root,D.docked,c),ownerState:E,externalForwardedProps:O,additionalProps:y}),[F,I]=Xc(`transition`,{elementType:Id,ownerState:E,externalForwardedProps:O,additionalProps:{in:p,direction:Ud[w],timeout:m,appear:b.current,...h===`temporary`&&(g.transition==null||g.transition===Id)&&{container:C}}}),L=(0,U.jsx)(j,{...M,children:s});if(h===`permanent`)return(0,U.jsx)(N,{...P,children:L});let R=(0,U.jsx)(F,{...I,children:L});return h===`persistent`?(0,U.jsx)(N,{...P,children:R}):(0,U.jsx)(k,{...A,children:R})});function qd(e){return Gr(`MuiIconButton`,e)}var Jd=Kr(`MuiIconButton`,[`root`,`disabled`,`colorInherit`,`colorPrimary`,`colorSecondary`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`,`edgeStart`,`edgeEnd`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`loading`,`loadingIndicator`,`loadingWrapper`]),Yd=e=>{let{classes:t,disabled:n,color:r,edge:i,size:a,loading:o}=e;return ba({root:[`root`,o&&`loading`,n&&`disabled`,r!=="default"&&`color${q(r)}`,i&&`edge${q(i)}`,`size${q(a)}`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},qd,t)},Xd=K(tu,{name:`MuiIconButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.loading&&t.loading,n.color!=="default"&&t[`color${q(n.color)}`],n.edge&&t[`edge${q(n.edge)}`],t[`size${q(n.size)}`]]}})(ys(({theme:e})=>({textAlign:`center`,flex:`0 0 auto`,fontSize:e.typography.pxToRem(24),padding:8,borderRadius:`50%`,color:(e.vars||e).palette.action.active,...Ks(e,`background-color`,{duration:e.transitions.duration.shortest}),variants:[{props:e=>!e.disableRipple,style:{"--IconButton-hoverBg":e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity),"&:hover":{backgroundColor:`var(--IconButton-hoverBg)`,"@media (hover: none)":{backgroundColor:`transparent`}}}},{props:{edge:`start`},style:{marginLeft:-12}},{props:{edge:`start`,size:`small`},style:{marginLeft:-3}},{props:{edge:`end`},style:{marginRight:-12}},{props:{edge:`end`,size:`small`},style:{marginRight:-3}}]})),ys(({theme:e})=>({variants:[{props:{color:`inherit`},style:{color:`inherit`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main,"--IconButton-hoverBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}})),{props:{size:`small`},style:{padding:5,fontSize:e.typography.pxToRem(18)}},{props:{size:`large`},style:{padding:12,fontSize:e.typography.pxToRem(28)}}],[`&.${Jd.disabled}`]:{backgroundColor:`transparent`,color:(e.vars||e).palette.action.disabled},[`&.${Jd.loading}`]:{color:`transparent`}}))),Zd=K(`span`,{name:`MuiIconButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,color:(e.vars||e).palette.action.disabled,variants:[{props:{loading:!0},style:{display:`flex`}}]})),Qd=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiIconButton`}),{edge:r=!1,children:i,className:a,color:o=`default`,disabled:s=!1,disableFocusRipple:c=!1,size:l=`medium`,id:u,loading:d=null,loadingIndicator:f,...p}=n,m=Ed(u),h=f??(0,U.jsx)(xu,{"aria-labelledby":m,color:`inherit`,size:16}),g={...n,edge:r,color:o,disabled:s,disableFocusRipple:c,loading:d,loadingIndicator:h,size:l},_=Yd(g);return(0,U.jsxs)(Xd,{id:d?m:u,className:W(_.root,a),centerRipple:!0,internalNativeButton:!0,focusRipple:!c,disabled:s||d,ref:t,...p,ownerState:g,children:[typeof d==`boolean`&&(0,U.jsx)(`span`,{className:_.loadingWrapper,style:{display:`contents`},children:(0,U.jsx)(Zd,{className:_.loadingIndicator,ownerState:g,children:d&&h})}),i]})}),$d=v.createContext({});function ef(e){return Gr(`MuiList`,e)}Kr(`MuiList`,[`root`,`padding`,`dense`,`subheader`]);var tf=e=>{let{classes:t,disablePadding:n,dense:r,subheader:i}=e;return ba({root:[`root`,!n&&`padding`,r&&`dense`,i&&`subheader`]},ef,t)},nf=K(`ul`,{name:`MuiList`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disablePadding&&t.padding,n.dense&&t.dense,n.subheader&&t.subheader]}})({listStyle:`none`,margin:0,padding:0,position:`relative`,variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>e.subheader,style:{paddingTop:0,isolation:`isolate`}}]}),rf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiList`}),{children:r,className:i,component:a=`ul`,dense:o=!1,disablePadding:s=!1,subheader:c,...l}=n,u=v.useMemo(()=>({dense:o}),[o]),d={...n,component:a,dense:o,disablePadding:s},f=tf(d);return(0,U.jsx)($d.Provider,{value:u,children:(0,U.jsxs)(nf,{as:a,className:W(f.root,i),ref:t,ownerState:d,...l,children:[c,r]})})}),af=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.alignItems===`flex-start`&&t.alignItemsFlexStart,n.divider&&t.divider,!n.disableGutters&&t.gutters]},of=e=>{let{alignItems:t,classes:n,dense:r,disabled:i,disableGutters:a,divider:o,selected:s}=e,c=ba({root:[`root`,r&&`dense`,!a&&`gutters`,o&&`divider`,i&&`disabled`,t===`flex-start`&&`alignItemsFlexStart`,s&&`selected`]},dc,n);return{...n,...c}},sf=K(tu,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiListItemButton`,slot:`Root`,overridesResolver:af})(ys(({theme:e})=>({display:`flex`,flexGrow:1,justifyContent:`flex-start`,alignItems:`center`,position:`relative`,textDecoration:`none`,minWidth:0,boxSizing:`border-box`,textAlign:`left`,paddingTop:8,paddingBottom:8,...Ks(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${fc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${fc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${fc.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${fc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${fc.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},variants:[{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:`padding-box`}},{props:{alignItems:`flex-start`},style:{alignItems:`flex-start`}},{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.dense,style:{paddingTop:4,paddingBottom:4}}]}))),cf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemButton`}),{alignItems:r=`center`,autoFocus:i=!1,component:a=`div`,children:o,dense:s=!1,disableGutters:c=!1,divider:l=!1,focusVisibleClassName:u,selected:d=!1,className:f,...p}=n,m=v.useContext($d),h=v.useMemo(()=>({dense:s||m.dense||!1,alignItems:r,disableGutters:c}),[r,m.dense,s,c]),g=v.useRef(null);xs(()=>{i&&g.current&&g.current.focus()},[i]);let _={...n,alignItems:r,dense:h.dense,disableGutters:c,divider:l,selected:d},y=of(_),{root:b,...x}=y,S=bs(g,t);return(0,U.jsx)($d.Provider,{value:h,children:(0,U.jsx)(sf,{ref:S,href:p.href||p.to,component:(p.href||p.to)&&a===`div`?`button`:a,internalNativeButton:!1,focusVisibleClassName:W(y.focusVisible,u),ownerState:_,className:W(y.root,f),...p,classes:x,children:o})})});function lf(e){return Gr(`MuiListItemIcon`,e)}var uf=Kr(`MuiListItemIcon`,[`root`,`alignItemsFlexStart`]),df=e=>{let{alignItems:t,classes:n}=e;return ba({root:[`root`,t===`flex-start`&&`alignItemsFlexStart`]},lf,n)},ff=K(`div`,{name:`MuiListItemIcon`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.alignItems===`flex-start`&&t.alignItemsFlexStart]}})(ys(({theme:e})=>({minWidth:e.spacing(4.5),color:(e.vars||e).palette.action.active,flexShrink:0,display:`inline-flex`,variants:[{props:{alignItems:`flex-start`},style:{marginTop:8}}]}))),pf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemIcon`}),{className:r,...i}=n,a=v.useContext($d),o={...n,alignItems:a.alignItems},s=df(o);return(0,U.jsx)(ff,{className:W(s.root,r),ownerState:o,ref:t,...i})});function mf(e){return Gr(`MuiTypography`,e)}var hf=Kr(`MuiTypography`,[`root`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`subtitle1`,`subtitle2`,`body1`,`body2`,`inherit`,`button`,`caption`,`overline`,`alignLeft`,`alignRight`,`alignCenter`,`alignJustify`,`noWrap`,`gutterBottom`]),gf=e=>{let{align:t,gutterBottom:n,noWrap:r,variant:i,classes:a}=e;return ba({root:[`root`,i,e.align!==`inherit`&&`align${q(t)}`,n&&`gutterBottom`,r&&`noWrap`]},mf,a)},_f=K(`span`,{name:`MuiTypography`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!==`inherit`&&t[`align${q(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom]}})(ys(({theme:e})=>({margin:0,variants:[{props:{variant:`inherit`},style:{font:`inherit`,lineHeight:`inherit`,letterSpacing:`inherit`}},...Object.entries(e.typography).filter(([e,t])=>e!==`inherit`&&t&&typeof t==`object`).map(([e,t])=>({props:{variant:e},style:t})),...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}})),...Object.entries(e.palette?.text||{}).filter(([,e])=>typeof e==`string`).map(([t])=>({props:{color:`text${q(t)}`},style:{color:(e.vars||e).palette.text[t]}})),{props:({ownerState:e})=>e.align!==`inherit`,style:{textAlign:`var(--Typography-textAlign)`}},{props:({ownerState:e})=>e.noWrap,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},{props:({ownerState:e})=>e.gutterBottom,style:{marginBottom:`0.35em`}}]}))),vf={h1:`h1`,h2:`h2`,h3:`h3`,h4:`h4`,h5:`h5`,h6:`h6`,subtitle1:`h6`,subtitle2:`h6`,body1:`p`,body2:`p`,inherit:`p`},X=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTypography`}),{color:r,align:i=`inherit`,className:a,component:o,gutterBottom:s=!1,noWrap:c=!1,variant:l=`body1`,variantMapping:u=vf,...d}=n,f={...n,align:i,color:r,className:a,component:o,gutterBottom:s,noWrap:c,variant:l,variantMapping:u},p=o||u[l]||vf[l]||`span`,m=gf(f);return(0,U.jsx)(_f,{as:p,ref:t,className:W(m.root,a),...d,ownerState:f,style:{...i!==`inherit`&&{"--Typography-textAlign":i},...d.style}})});function yf(e){return Gr(`MuiListItemText`,e)}var bf=Kr(`MuiListItemText`,[`root`,`multiline`,`dense`,`inset`,`primary`,`secondary`]),xf=e=>{let{classes:t,inset:n,primary:r,secondary:i,dense:a}=e;return ba({root:[`root`,n&&`inset`,a&&`dense`,r&&i&&`multiline`],primary:[`primary`],secondary:[`secondary`]},yf,t)},Sf=K(`div`,{name:`MuiListItemText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${bf.primary}`]:t.primary},{[`& .${bf.secondary}`]:t.secondary},t.root,n.inset&&t.inset,n.primary&&n.secondary&&t.multiline,n.dense&&t.dense]}})({flex:`1 1 auto`,minWidth:0,marginTop:4,marginBottom:4,[`.${hf.root}:where(& .${bf.primary})`]:{display:`block`},[`.${hf.root}:where(& .${bf.secondary})`]:{display:`block`},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),Cf=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemText`}),{children:r,className:i,disableTypography:a=!1,inset:o=!1,primary:s,secondary:c,slots:l={},slotProps:u={},...d}=n,{dense:f}=v.useContext($d),p=s??r,m=c,h={...n,disableTypography:a,inset:o,primary:!!p,secondary:!!m,dense:f},g=xf(h),_={slots:l,slotProps:u},[y,b]=Xc(`root`,{className:W(g.root,i),elementType:Sf,externalForwardedProps:{..._,...d},ownerState:h,ref:t}),[x,S]=Xc(`primary`,{className:g.primary,elementType:X,externalForwardedProps:_,ownerState:h}),[C,w]=Xc(`secondary`,{className:g.secondary,elementType:X,externalForwardedProps:_,ownerState:h});return p!=null&&p.type!==X&&!a&&(p=(0,U.jsx)(x,{variant:f?`body2`:`body1`,component:S?.variant?void 0:`span`,...S,children:p})),m!=null&&m.type!==X&&!a&&(m=(0,U.jsx)(C,{variant:`body2`,color:`textSecondary`,...w,children:m})),(0,U.jsxs)(y,{...b,children:[p,m]})}),Z=Oa({createStyledComponent:K(`div`,{name:`MuiStack`,slot:`Root`}),useThemeProps:e=>Xo({props:e,name:`MuiStack`})}),wf=v.createContext({}),Tf=v.createContext(void 0);function Ef(e,t){return t===void 0||e===void 0?!1:Array.isArray(t)?t.includes(e):e===t}var Df=v.createContext(void 0);function Of(){let e=v.useContext(Df);if(e===void 0)throw Error(`MUI: RovingTabIndexContext is missing. Roving tab index items must be placed within a roving tab index provider.`);return e}var kf=Object.is;function Af(e,t){if(e===t)return!0;if(!(e instanceof Object)||!(t instanceof Object))return!1;let n=0,r=0;for(let r in e)if(n+=1,!kf(e[r],t[r])||!(r in t))return!1;for(let e in t)r+=1;return n===r}var jf=[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function Mf(e){let{activeItemId:t,getDefaultActiveItemId:n,orientation:r,isRtl:i=!1,isItemFocusable:a=Kf,wrap:o=!0}=e,[s,c]=v.useState(t),[l,u]=v.useState(t),d=s;t!==l&&(u(t),t!==void 0&&t!==s&&(d=t,c(t)));let f=v.useRef(null),p=v.useRef(new Map),[m,h]=v.useState(0),g=v.useMemo(()=>Uf(p.current),[m]),_=Pf(d,g,a,n),y=v.useRef(_);y.current=_;let b=v.useCallback(()=>{let e=Uf(p.current);return Bf(e,Pf(y.current,e,a,n))},[n,a]),x=v.useCallback(()=>p.current,[]),S=cs(e=>{Af(p.current.get(e.id)??null,e)||(p.current.set(e.id,e),h(e=>e+1))}),C=cs(e=>{p.current.delete(e)&&h(e=>e+1)}),w=cs(e=>{c(e)}),T=v.useCallback(e=>y.current===e,[]),E=v.useCallback((e,t,n,r)=>{let i=Rf(Wf(p.current),e,t,n,r??a);return i?(i.element?.focus(),c(i.id),i):null},[a]),D=v.useCallback((e,t,n)=>({onFocus:e=>{t?.(e);let n=Wf(p.current),r=Hf(n,e.target);r!==-1&&c(n[r].id)},onKeyDown:e=>{if(n?.(e),e.defaultPrevented||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||!jf.includes(e.key))return;let t=r===`horizontal`?`ArrowLeft`:`ArrowUp`,a=r===`horizontal`?`ArrowRight`:`ArrowDown`;r===`horizontal`&&i&&(t=`ArrowRight`,a=`ArrowLeft`);let s=Wf(p.current),c=Cs(ls(f.current)),l=c===f.current,u=Lf(s,c,y.current),d=`next`;switch(e.key){case t:d=`previous`,e.preventDefault(),l&&(u=s.length);break;case a:e.preventDefault(),l&&(u=-1);break;case`Home`:e.preventDefault(),u=-1;break;case`End`:e.preventDefault(),d=`previous`,u=s.length;break;default:return}E(u,d,o)},ref:Yf(e,e=>{f.current=e})}),[E,i,r,o]),O=v.useCallback(e=>{let t=Wf(p.current),n=Cs(ls(f.current)),r=n===f.current?-1:Lf(t,n,y.current);return E(r,`next`,!0,e)?.id??null},[E]);return v.useMemo(()=>({activeItemId:_,focusNext:O,getActiveItem:b,getContainerProps:D,getItemMap:x,isItemActive:T,registerItem:S,setActiveItemId:w,unregisterItem:C}),[_,O,b,D,x,T,S,w,C])}function Nf(e){let{activeItemId:t,registerItem:n,unregisterItem:r}=Of(),i=v.useRef(null),a=v.useMemo(()=>({disabled:e.disabled??!1,element:null,focusableWhenDisabled:e.focusableWhenDisabled??!1,id:e.id,selected:e.selected??!1,textValue:e.textValue}),[e.disabled,e.focusableWhenDisabled,e.id,e.selected,e.textValue]),o=v.useRef(a);o.current=a;let s=v.useCallback(t=>{if(i.current=t,t==null){queueMicrotask(()=>{i.current??r(e.id)});return}n({...o.current,element:t})},[e.id,n,r]),c=ss(e.ref,s);return ci(()=>{i.current&&n({...a,element:i.current})},[a,n]),ci(()=>{let t=e.id;return()=>{r(t)}},[e.id,r]),{ref:c,tabIndex:t===e.id?0:-1}}function Pf(e,t,n,r){return e==null?If(t,n,r):Ff(e,t,n)}function Ff(e,t,n){let r=Vf(t,e);return r===-1?zf(t,n):n(t[r])?t[r].id:Rf(t,r,`next`,!1,n)?.id??null}function If(e,t,n){let r=n?.(e);if(r!=null){let n=Bf(e,r);if(n&&t(n))return n.id}return zf(e,t)}function Lf(e,t,n){if(t){let n=Hf(e,t);if(n!==-1)return n}return Vf(e,n)}function Rf(e,t,n,r,i){let a=e.length-1;if(a===-1)return null;let o=!1,s=Gf(t,a,n,r),c=s;for(;s!==-1;){if(s===c){if(o)return null;o=!0}let t=e[s];if(!t||!i(t))s=Gf(s,a,n,r);else return t}return null}function zf(e,t){return e.find(e=>t(e))?.id??null}function Bf(e,t){return t==null?null:e.find(e=>e.id===t)??null}function Vf(e,t){return t==null?-1:e.findIndex(e=>e.id===t)}function Hf(e,t){return t?e.findIndex(e=>e.element===t||e.element?.contains(t)):-1}function Uf(e){let t=Array.from(e.values());if(t.every(e=>e.element==null))return t;let n=t.filter(qf).sort((e,t)=>Jf(e.element,t.element)),r=t.filter(e=>!qf(e));return[...n,...r]}function Wf(e){return Uf(e).filter(qf)}function Gf(e,t,n,r=!0){return n===`next`?e===t?r?0:-1:e+1:e===0?r?t:-1:e-1}function Kf(e){return e.element?e.focusableWhenDisabled?!0:!e.disabled&&!e.element.hasAttribute(`disabled`)&&e.element.getAttribute(`aria-disabled`)!==`true`&&e.element.hasAttribute(`tabindex`):!1}function qf(e){return e.element!=null&&e.element.isConnected}function Jf(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function Yf(...e){return t=>{e.forEach(e=>{Yu(e??null,t)})}}function Xf(e,t){let{children:n,disabled:r=!1,selected:i=!1,value:a}=e,o=Of(),s=Nf({id:a,ref:t,disabled:r,selected:i}),c=o.getItemMap().size===0&&i?0:s.tabIndex;return v.cloneElement(v.Children.only(n),{...s,tabIndex:n.props.tabIndex??c})}var Zf=v.forwardRef(Xf),Qf=e=>{let{classes:t,fullWidth:n,selected:r,disabled:i,size:a,color:o}=e;return ba({root:[`root`,r&&`selected`,i&&`disabled`,n&&`fullWidth`,`size${q(a)}`,o]},yc,t)},$f=K(tu,{name:`MuiToggleButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`size${q(n.size)}`]]}})(ys(({theme:e})=>({...e.typography.button,borderRadius:(e.vars||e).shape.borderRadius,padding:11,border:`1px solid ${(e.vars||e).palette.divider}`,color:(e.vars||e).palette.action.active,[`&.${bc.disabled}`]:{color:(e.vars||e).palette.action.disabled,border:`1px solid ${(e.vars||e).palette.action.disabledBackground}`},"&:hover":{textDecoration:`none`,backgroundColor:e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:`transparent`}},variants:[{props:{color:`standard`},style:{[`&.${bc.selected}`]:{color:(e.vars||e).palette.text.primary,backgroundColor:e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.selectedOpacity),"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.text.primary,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.selectedOpacity)}}}}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{[`&.${bc.selected}`]:{color:(e.vars||e).palette[t].main,backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity),"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity)}}}}})),{props:{fullWidth:!0},style:{width:`100%`}},{props:{size:`small`},style:{padding:7,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`},style:{padding:15,fontSize:e.typography.pxToRem(15)}}]}))),ep=v.forwardRef(function(e,t){let{value:n,isRovingTabIndex:r,...i}=v.useContext(wf),a=v.useContext(Tf),o=Xo({props:ai({...i,selected:Ef(e.value,n)},e),name:`MuiToggleButton`}),{children:s,className:c,color:l=`standard`,disabled:u=!1,disableFocusRipple:d=!1,fullWidth:f=!1,onChange:p,onClick:m,selected:h,size:g=`medium`,value:_,...y}=o,b={...o,color:l,disabled:u,disableFocusRipple:d,fullWidth:f,size:g},x=Qf(b),S=e=>{m&&(m(e,_),e.defaultPrevented)||p&&p(e,_)},C=a||``,w=(0,U.jsx)($f,{className:W(i.className,x.root,c,C),internalNativeButton:!0,disabled:u,focusRipple:!d,ref:r?void 0:t,onClick:S,onChange:p,value:_,ownerState:b,"aria-pressed":h,...y,children:s});return r?(0,U.jsx)(Zf,{disabled:u,selected:h,ref:t,value:_,children:w}):w});function tp(e){return v.Children.toArray(e).filter(e=>v.isValidElement(e))}function np(e){return Gr(`MuiToggleButtonGroup`,e)}var rp=Kr(`MuiToggleButtonGroup`,[`root`,`selected`,`horizontal`,`vertical`,`disabled`,`grouped`,`fullWidth`,`firstButton`,`lastButton`,`middleButton`]),ip=e=>{let{classes:t,orientation:n,fullWidth:r,disabled:i}=e;return ba({root:[`root`,n,r&&`fullWidth`],grouped:[`grouped`,i&&`disabled`],firstButton:[`firstButton`],lastButton:[`lastButton`],middleButton:[`middleButton`]},np,t)},ap=K(`div`,{name:`MuiToggleButtonGroup`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${rp.grouped}`]:t.grouped},{[`& .${rp.firstButton}`]:t.firstButton},{[`& .${rp.lastButton}`]:t.lastButton},{[`& .${rp.middleButton}`]:t.middleButton},t.root,n.orientation===`vertical`&&t.vertical,n.fullWidth&&t.fullWidth]}})(ys(({theme:e})=>({display:`inline-flex`,borderRadius:(e.vars||e).shape.borderRadius,variants:[{props:{orientation:`vertical`},style:{flexDirection:`column`,[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderTop:0,marginTop:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginTop:-1,borderTop:`1px solid transparent`,borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${rp.lastButton}.${bc.disabled},& .${rp.middleButton}.${bc.disabled}`]:{borderTop:`1px solid transparent`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{orientation:`horizontal`},style:{[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginLeft:-1,borderLeft:`1px solid transparent`,borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${rp.lastButton}.${bc.disabled},& .${rp.middleButton}.${bc.disabled}`]:{borderLeft:`1px solid transparent`}}}]}))),op=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiToggleButtonGroup`}),{children:r,className:i,color:a=`standard`,disabled:o=!1,exclusive:s=!1,fullWidth:c=!1,onChange:l,orientation:u=`horizontal`,size:d=`medium`,value:f,...p}=n,m={...n,disabled:o,fullWidth:c,orientation:u,size:d},h=ip(m),g=Ri(),_=v.useCallback((e,t)=>{if(!l)return;let n=f&&f.indexOf(t),r;f&&n>=0?(r=f.slice(),r.splice(n,1)):r=f?f.concat(t):[t],l(e,r)},[l,f]),y=v.useCallback((e,t)=>{l&&l(e,f===t?null:t)},[l,f]),b=v.useMemo(()=>({className:h.grouped,onChange:s?y:_,value:f,size:d,fullWidth:c,color:a,disabled:o,isRovingTabIndex:!0}),[h.grouped,s,y,_,f,d,c,a,o]),x=tp(r),S=x.length,C=e=>{let t=e===0,n=e===S-1;return t&&n?``:t?h.firstButton:n?h.lastButton:h.middleButton},w=Mf({orientation:u,isRtl:g}),T=w.getContainerProps(t,p.onFocus,p.onKeyDown);return(0,U.jsx)(ap,{role:`group`,className:W(h.root,i),ownerState:m,...p,...T,children:(0,U.jsx)(Df.Provider,{value:w,children:(0,U.jsx)(wf.Provider,{value:b,children:x.map((e,t)=>(0,U.jsx)(Tf.Provider,{value:C(t),children:e},t))})})})});function sp(e){return Gr(`MuiToolbar`,e)}Kr(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var cp=e=>{let{classes:t,disableGutters:n,variant:r}=e;return ba({root:[`root`,!n&&`gutters`,r]},sp,t)},lp=K(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(ys(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up(`sm`)]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:`dense`},style:{minHeight:48}},{props:{variant:`regular`},style:e.mixins.toolbar}]}))),up=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiToolbar`}),{className:r,component:i=`div`,disableGutters:a=!1,variant:o=`regular`,...s}=n,c={...n,component:i,disableGutters:a,variant:o},l=cp(c);return(0,U.jsx)(lp,{as:i,className:W(l.root,r),ref:t,ownerState:c,...s})});function dp(e){return`scale(${e}, ${e**2})`}var fp={entering:{opacity:1,transform:dp(1)},entered:{opacity:1,transform:`none`},exiting:{opacity:0,transform:dp(.75)},exited:{opacity:0,transform:dp(.75)}},pp={opacity:0,transform:dp(.75),visibility:`hidden`},mp=v.forwardRef(function(e,t){let{addEndListener:n,appear:r=!0,children:i,disablePrefersReducedMotion:a=!1,easing:o,in:s,onEnter:c,onEntered:l,onEntering:u,onExit:d,onExited:f,onExiting:p,style:m,timeout:h=`auto`,...g}=e,_=v.useRef(null),y=Go(),b=Ll(y.motion.reducedMotion,a),x=v.useRef(null),S=bs(x,Lu(i),t),C=Hs(x,u),w=Hs(x,(e,t)=>{b.shouldReduceMotion||Ms(e);let{duration:n,delay:r,easing:i}=Ws({style:m,timeout:h,easing:o},{mode:`enter`}),a;h===`auto`&&!b.shouldReduceMotion?(a=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=a):(a=n,_.current=null);let s=b.getTransitionTiming({duration:a,delay:r});e.style.transition=[y.transitions.create(`opacity`,{duration:s.duration,delay:s.delay}),y.transitions.create(`transform`,{duration:typeof s.duration==`string`?s.duration:s.duration*.666,delay:s.delay,easing:i})].join(`,`),c&&c(e,t)}),T=Hs(x,l),E=Hs(x,p),D=Hs(x,e=>{let{duration:t,delay:n,easing:r}=Ws({style:m,timeout:h,easing:o},{mode:`exit`}),i;h===`auto`&&!b.shouldReduceMotion?(i=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=i):(i=t,_.current=null);let a=b.getTransitionTiming({duration:i,delay:n});e.style.transition=[y.transitions.create(`opacity`,{duration:a.duration,delay:a.delay}),y.transitions.create(`transform`,{duration:typeof a.duration==`string`?a.duration:a.duration*.666,delay:a.delay||(typeof a.duration==`string`?a.duration:a.duration*.333),easing:r})].join(`,`),e.style.opacity=0,e.style.transform=dp(.75),d&&d(e)}),O=Hs(x,e=>{e.style.transition=``,f&&f(e)});return(0,U.jsx)(id,{appear:r,in:s,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:n?e=>{n(x.current,e)}:void 0,getAutoTimeout:h===`auto`?()=>_.current:void 0,reduceMotion:b.shouldReduceMotion,timeout:h===`auto`?null:h,...g,children:(e,{ownerState:t,...n})=>{let r=Us(e,s,fp,pp,m,i.props.style);return v.cloneElement(i,{style:r,ref:S,...n})}})});mp&&(mp.muiSupportAuto=!0);var hp=`bottom`,gp=`right`,_p=`left`,vp=`auto`,yp=[`top`,hp,gp,_p],bp=`start`,xp=`clippingParents`,Sp=`viewport`,Cp=`popper`,wp=`reference`,Tp=yp.reduce(function(e,t){return e.concat([t+`-`+bp,t+`-end`])},[]),Ep=[].concat(yp,[vp]).reduce(function(e,t){return e.concat([t,t+`-`+bp,t+`-end`])},[]),Dp=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function Op(e){return e?(e.nodeName||``).toLowerCase():null}function kp(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ap(e){return e instanceof kp(e).Element||e instanceof Element}function jp(e){return e instanceof kp(e).HTMLElement||e instanceof HTMLElement}function Mp(e){return typeof ShadowRoot>`u`?!1:e instanceof kp(e).ShadowRoot||e instanceof ShadowRoot}function Np(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];!jp(i)||!Op(i)||(Object.assign(i.style,n),Object.keys(r).forEach(function(e){var t=r[e];t===!1?i.removeAttribute(e):i.setAttribute(e,t===!0?``:t)}))})}function Pp(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],i=t.attributes[e]||{},a=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]=``,e},{});!jp(r)||!Op(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Fp={name:`applyStyles`,enabled:!0,phase:`write`,fn:Np,effect:Pp,requires:[`computeStyles`]};function Ip(e){return e.split(`-`)[0]}var Lp=Math.max,Rp=Math.min,zp=Math.round;function Bp(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+`/`+e.version}).join(` `):navigator.userAgent}function Vp(){return!/^((?!chrome|android).)*safari/i.test(Bp())}function Hp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&jp(e)&&(i=e.offsetWidth>0&&zp(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&zp(r.height)/e.offsetHeight||1);var o=(Ap(e)?kp(e):window).visualViewport,s=!Vp()&&n,c=(r.left+(s&&o?o.offsetLeft:0))/i,l=(r.top+(s&&o?o.offsetTop:0))/a,u=r.width/i,d=r.height/a;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c,x:c,y:l}}function Up(e){var t=Hp(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Wp(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Mp(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Gp(e){return kp(e).getComputedStyle(e)}function Kp(e){return[`table`,`td`,`th`].indexOf(Op(e))>=0}function qp(e){return((Ap(e)?e.ownerDocument:e.document)||window.document).documentElement}function Jp(e){return Op(e)===`html`?e:e.assignedSlot||e.parentNode||(Mp(e)?e.host:null)||qp(e)}function Yp(e){return!jp(e)||Gp(e).position===`fixed`?null:e.offsetParent}function Xp(e){var t=/firefox/i.test(Bp());if(/Trident/i.test(Bp())&&jp(e)&&Gp(e).position===`fixed`)return null;var n=Jp(e);for(Mp(n)&&(n=n.host);jp(n)&&[`html`,`body`].indexOf(Op(n))<0;){var r=Gp(n);if(r.transform!==`none`||r.perspective!==`none`||r.contain===`paint`||[`transform`,`perspective`].indexOf(r.willChange)!==-1||t&&r.willChange===`filter`||t&&r.filter&&r.filter!==`none`)return n;n=n.parentNode}return null}function Zp(e){for(var t=kp(e),n=Yp(e);n&&Kp(n)&&Gp(n).position===`static`;)n=Yp(n);return n&&(Op(n)===`html`||Op(n)===`body`&&Gp(n).position===`static`)?t:n||Xp(e)||t}function Qp(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function $p(e,t,n){return Lp(e,Rp(t,n))}function em(e,t,n){var r=$p(e,t,n);return r>n?n:r}function tm(){return{top:0,right:0,bottom:0,left:0}}function nm(e){return Object.assign({},tm(),e)}function rm(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var im=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,nm(typeof e==`number`?rm(e,yp):e)};function am(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=Ip(n.placement),c=Qp(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=im(i.padding,n),d=Up(a),f=c===`y`?`top`:_p,p=c===`y`?hp:gp,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=Zp(a),_=g?c===`y`?g.clientHeight||0:g.clientWidth||0:0,v=m/2-h/2,y=u[f],b=_-d[l]-u[p],x=_/2-d[l]/2+v,S=$p(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function om(e){var t=e.state,n=e.options.element,r=n===void 0?`[data-popper-arrow]`:n;r!=null&&(typeof r==`string`&&(r=t.elements.popper.querySelector(r),!r)||Wp(t.elements.popper,r)&&(t.elements.arrow=r))}var sm={name:`arrow`,enabled:!0,phase:`main`,fn:am,effect:om,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function cm(e){return e.split(`-`)[1]}var lm={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function um(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:zp(n*i)/i||0,y:zp(r*i)/i||0}}function dm(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,o=e.offsets,s=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,p=f===void 0?0:f,m=o.y,h=m===void 0?0:m,g=typeof u==`function`?u({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var _=o.hasOwnProperty(`x`),v=o.hasOwnProperty(`y`),y=_p,b=`top`,x=window;if(l){var S=Zp(n),C=`clientHeight`,w=`clientWidth`;if(S===kp(n)&&(S=qp(n),Gp(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=hp;var T=d&&S===x&&x.visualViewport?x.visualViewport.height:S[C];h-=T-r.height,h*=c?1:-1}if(i===`left`||(i===`top`||i===`bottom`)&&a===`end`){y=gp;var E=d&&S===x&&x.visualViewport?x.visualViewport.width:S[w];p-=E-r.width,p*=c?1:-1}}var D=Object.assign({position:s},l&&lm),O=u===!0?um({x:p,y:h},kp(n)):{x:p,y:h};if(p=O.x,h=O.y,c){var k;return Object.assign({},D,(k={},k[b]=v?`0`:``,k[y]=_?`0`:``,k.transform=(x.devicePixelRatio||1)<=1?`translate(`+p+`px, `+h+`px)`:`translate3d(`+p+`px, `+h+`px, 0)`,k))}return Object.assign({},D,(t={},t[b]=v?h+`px`:``,t[y]=_?p+`px`:``,t.transform=``,t))}function fm(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0||r,a=n.adaptive,o=a===void 0||a,s=n.roundOffsets,c=s===void 0||s,l={placement:Ip(t.placement),variation:cm(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy===`fixed`};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,dm(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,dm(Object.assign({},l,{offsets:t.modifiersData.arrow,position:`absolute`,adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}var pm={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:fm,data:{}},mm={passive:!0};function hm(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0||i,o=r.resize,s=o===void 0||o,c=kp(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,mm)}),s&&c.addEventListener(`resize`,n.update,mm),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,mm)}),s&&c.removeEventListener(`resize`,n.update,mm)}}var gm={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:hm,data:{}},_m={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vm(e){return e.replace(/left|right|bottom|top/g,function(e){return _m[e]})}var ym={start:`end`,end:`start`};function bm(e){return e.replace(/start|end/g,function(e){return ym[e]})}function xm(e){var t=kp(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Sm(e){return Hp(qp(e)).left+xm(e).scrollLeft}function Cm(e,t){var n=kp(e),r=qp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=Vp();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+Sm(e),y:c}}function wm(e){var t=qp(e),n=xm(e),r=e.ownerDocument?.body,i=Lp(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=Lp(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+Sm(e),s=-n.scrollTop;return Gp(r||t).direction===`rtl`&&(o+=Lp(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function Tm(e){var t=Gp(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Em(e){return[`html`,`body`,`#document`].indexOf(Op(e))>=0?e.ownerDocument.body:jp(e)&&Tm(e)?e:Em(Jp(e))}function Dm(e,t){t===void 0&&(t=[]);var n=Em(e),r=n===e.ownerDocument?.body,i=kp(n),a=r?[i].concat(i.visualViewport||[],Tm(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(Dm(Jp(a)))}function Om(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function km(e,t){var n=Hp(e,!1,t===`fixed`);return n.top+=e.clientTop,n.left+=e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Am(e,t,n){return t===`viewport`?Om(Cm(e,n)):Ap(t)?km(t,n):Om(wm(qp(e)))}function jm(e){var t=Dm(Jp(e)),n=[`absolute`,`fixed`].indexOf(Gp(e).position)>=0&&jp(e)?Zp(e):e;return Ap(n)?t.filter(function(e){return Ap(e)&&Wp(e,n)&&Op(e)!==`body`}):[]}function Mm(e,t,n,r){var i=t===`clippingParents`?jm(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=Am(e,n,r);return t.top=Lp(i.top,t.top),t.right=Rp(i.right,t.right),t.bottom=Rp(i.bottom,t.bottom),t.left=Lp(i.left,t.left),t},Am(e,o,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Nm(e){var t=e.reference,n=e.element,r=e.placement,i=r?Ip(r):null,a=r?cm(r):null,o=t.x+t.width/2-n.width/2,s=t.y+t.height/2-n.height/2,c;switch(i){case`top`:c={x:o,y:t.y-n.height};break;case hp:c={x:o,y:t.y+t.height};break;case gp:c={x:t.x+t.width,y:s};break;case _p:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?Qp(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case bp:c[l]=c[l]-(t[u]/2-n[u]/2);break;case`end`:c[l]=c[l]+(t[u]/2-n[u]/2)}}return c}function Pm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,o=a===void 0?e.strategy:a,s=n.boundary,c=s===void 0?xp:s,l=n.rootBoundary,u=l===void 0?Sp:l,d=n.elementContext,f=d===void 0?Cp:d,p=n.altBoundary,m=p!==void 0&&p,h=n.padding,g=h===void 0?0:h,_=nm(typeof g==`number`?rm(g,yp):g),v=f===`popper`?wp:Cp,y=e.rects.popper,b=e.elements[m?v:f],x=Mm(Ap(b)?b:b.contextElement||qp(e.elements.popper),c,u,o),S=Hp(e.elements.reference),C=Nm({reference:S,element:y,strategy:`absolute`,placement:i}),w=Om(Object.assign({},y,C)),T=f===`popper`?w:S,E={top:x.top-T.top+_.top,bottom:T.bottom-x.bottom+_.bottom,left:x.left-T.left+_.left,right:T.right-x.right+_.right},D=e.modifiersData.offset;if(f===`popper`&&D){var O=D[i];Object.keys(E).forEach(function(e){var t=[`right`,`bottom`].indexOf(e)>=0?1:-1,n=[`top`,`bottom`].indexOf(e)>=0?`y`:`x`;E[e]+=O[n]*t})}return E}function Fm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,o=n.padding,s=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?Ep:c,u=cm(r),d=u?s?Tp:Tp.filter(function(e){return cm(e)===u}):yp,f=d.filter(function(e){return l.indexOf(e)>=0});f.length===0&&(f=d);var p=f.reduce(function(t,n){return t[n]=Pm(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[Ip(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function Im(e){if(Ip(e)===`auto`)return[];var t=vm(e);return[bm(e),t,bm(t)]}function Lm(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o===void 0||o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0||p,h=n.allowedAutoPlacements,g=t.options.placement,_=Ip(g)===g,v=c||(_||!m?[vm(g)]:Im(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(Ip(n)===`auto`?Fm(t,{placement:n,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:h}):n)},[]),b=t.rects.reference,x=t.rects.popper,S=new Map,C=!0,w=y[0],T=0;T<y.length;T++){var E=y[T],D=Ip(E),O=cm(E)===bp,k=[`top`,hp].indexOf(D)>=0,A=k?`width`:`height`,j=Pm(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?gp:_p:O?hp:`top`;b[A]>x[A]&&(M=vm(M));var N=vm(M),P=[];if(a&&P.push(j[D]<=0),s&&P.push(j[M]<=0,j[N]<=0),P.every(function(e){return e})){w=E,C=!1;break}S.set(E,P)}if(C)for(var F=m?3:1,I=function(e){var t=y.find(function(t){var n=S.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return w=t,`break`},L=F;L>0&&I(L)!==`break`;L--);t.placement!==w&&(t.modifiersData[r]._skip=!0,t.placement=w,t.reset=!0)}}var Rm={name:`flip`,enabled:!0,phase:`main`,fn:Lm,requiresIfExists:[`offset`],data:{_skip:!1}};function zm(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Bm(e){return[`top`,gp,hp,_p].some(function(t){return e[t]>=0})}function Vm(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=Pm(t,{elementContext:`reference`}),s=Pm(t,{altBoundary:!0}),c=zm(o,r),l=zm(s,i,a),u=Bm(c),d=Bm(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var Hm={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Vm};function Um(e,t,n){var r=Ip(e),i=[`left`,`top`].indexOf(r)>=0?-1:1,a=typeof n==`function`?n(Object.assign({},t,{placement:e})):n,o=a[0],s=a[1];return o||=0,s=(s||0)*i,[`left`,`right`].indexOf(r)>=0?{x:s,y:o}:{x:o,y:s}}function Wm(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=Ep.reduce(function(e,n){return e[n]=Um(n,t.rects,a),e},{}),s=o[t.placement],c=s.x,l=s.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}var Gm={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:Wm};function Km(e){var t=e.state,n=e.name;t.modifiersData[n]=Nm({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var qm={name:`popperOffsets`,enabled:!0,phase:`read`,fn:Km,data:{}};function Jm(e){return e===`x`?`y`:`x`}function Ym(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o!==void 0&&o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0||f,m=n.tetherOffset,h=m===void 0?0:m,g=Pm(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=Ip(t.placement),v=cm(t.placement),y=!v,b=Qp(_),x=Jm(b),S=t.modifiersData.popperOffsets,C=t.rects.reference,w=t.rects.popper,T=typeof h==`function`?h(Object.assign({},t.rects,{placement:t.placement})):h,E=typeof T==`number`?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(a){var k=b===`y`?`top`:_p,A=b===`y`?hp:gp,j=b===`y`?`height`:`width`,M=S[b],N=M+g[k],P=M-g[A],F=p?-w[j]/2:0,I=v===`start`?C[j]:w[j],L=v===`start`?-w[j]:-C[j],R=t.elements.arrow,ee=p&&R?Up(R):{width:0,height:0},te=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:tm(),z=te[k],B=te[A],V=$p(0,C[j],ee[j]),ne=y?C[j]/2-F-V-z-E.mainAxis:I-V-z-E.mainAxis,re=y?-C[j]/2+F+V+B+E.mainAxis:L+V+B+E.mainAxis,ie=t.elements.arrow&&Zp(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+ne-oe-ae,H=M+re-oe,ce=$p(p?Rp(N,se):N,M,p?Lp(P,H):P);S[b]=ce,O[b]=ce-M}if(s){var le=b===`x`?`top`:_p,ue=b===`x`?hp:gp,de=S[x],fe=x===`y`?`height`:`width`,pe=de+g[le],me=de-g[ue],he=[`top`,_p].indexOf(_)!==-1,ge=D?.[x]??0,_e=he?pe:de-C[fe]-w[fe]-ge+E.altAxis,ve=he?de+C[fe]+w[fe]-ge-E.altAxis:me,ye=p&&he?em(_e,de,ve):$p(p?_e:pe,de,p?ve:me);S[x]=ye,O[x]=ye-de}t.modifiersData[r]=O}}var Xm={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Ym,requiresIfExists:[`offset`]};function Zm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Qm(e){return e===kp(e)||!jp(e)?xm(e):Zm(e)}function $m(e){var t=e.getBoundingClientRect(),n=zp(t.width)/e.offsetWidth||1,r=zp(t.height)/e.offsetHeight||1;return n!==1||r!==1}function eh(e,t,n){n===void 0&&(n=!1);var r=jp(t),i=jp(t)&&$m(t),a=qp(t),o=Hp(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Op(t)!==`body`||Tm(a))&&(s=Qm(t)),jp(t)?(c=Hp(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=Sm(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function th(e){var t=new Map,n=new Set,r=[];e.forEach(function(e){t.set(e.name,e)});function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}}),r.push(e)}return e.forEach(function(e){n.has(e.name)||i(e)}),r}function nh(e){var t=th(e);return Dp.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function rh(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function ih(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}var ah={placement:`bottom`,modifiers:[],strategy:`absolute`};function oh(){return![...arguments].some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function sh(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?ah:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},ah,a),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},o=[],s=!1,c={state:i,setOptions:function(n){var o=typeof n==`function`?n(i.options):n;u(),i.options=Object.assign({},a,i.options,o),i.scrollParents={reference:Ap(e)?Dm(e):e.contextElement?Dm(e.contextElement):[],popper:Dm(t)};var s=nh(ih([].concat(r,i.options.modifiers)));return i.orderedModifiers=s.filter(function(e){return e.enabled}),l(),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if(oh(t,n)){i.rects={reference:eh(t,Zp(n),i.options.strategy===`fixed`),popper:Up(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach(function(e){return i.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<i.orderedModifiers.length;r++){if(i.reset===!0){i.reset=!1,r=-1;continue}var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=l===void 0?{}:l,d=a.name;typeof o==`function`&&(i=o({state:i,options:u,name:d,instance:c})||i)}}}},update:rh(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!oh(e,t))return c;c.setOptions(n).then(function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)});function l(){i.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=n===void 0?{}:n,a=e.effect;if(typeof a==`function`){var s=a({state:i,name:t,instance:c,options:r});o.push(s||function(){})}})}function u(){o.forEach(function(e){return e()}),o=[]}return c}}var ch=sh({defaultModifiers:[gm,qm,pm,Fp,Gm,Rm,Xm,sm,Hm]});function lh(e){let{elementType:t,externalSlotProps:n,ownerState:r,skipResolvingSlotProps:i=!1,...a}=e,o=i?{}:Gc(n,r),{props:s,internalRef:c}=Yc({...a,externalSlotProps:o}),l=ss(c,o?.ref,e.additionalProps?.ref);return Wc(t,{...s,ref:l},r)}function uh(e){return Gr(`MuiPopper`,e)}Kr(`MuiPopper`,[`root`]);function dh(e,t){if(t===`ltr`)return e;switch(e){case`bottom-end`:return`bottom-start`;case`bottom-start`:return`bottom-end`;case`top-end`:return`top-start`;case`top-start`:return`top-end`;default:return e}}function fh(e){return typeof e==`function`?e():e}function ph(e){return e.nodeType!==void 0}var mh=e=>{let{classes:t}=e;return ba({root:[`root`]},uh,t)},hh={},gh=v.forwardRef(function(e,t){let{anchorEl:n,children:r,direction:i,disablePortal:a,modifiers:o,open:s,placement:c,popperOptions:l,popperRef:u,slotProps:d={},slots:f={},TransitionProps:p,ownerState:m,...h}=e,g=v.useRef(null),_=ss(g,t),y=v.useRef(null),b=ss(y,u),x=v.useRef(b);ci(()=>{x.current=b},[b]),v.useImperativeHandle(u,()=>y.current,[]);let S=dh(c,i),[C,w]=v.useState(S),T=v.useMemo(()=>fh(n),[n]);v.useEffect(()=>{y.current&&y.current.forceUpdate()}),ci(()=>{if(!T||!s)return;let e=e=>{w(e.placement)},t=[{name:`preventOverflow`,options:{altBoundary:a}},{name:`flip`,options:{altBoundary:a}},{name:`onUpdate`,enabled:!0,phase:`afterWrite`,fn:({state:t})=>{e(t)}}];o!=null&&(t=t.concat(o)),l&&l.modifiers!=null&&(t=t.concat(l.modifiers));let n=ch(T,g.current,{placement:S,...l,modifiers:t});x.current(n);let r=g.current;return()=>{if(r){let{style:e}=r,t=e.position,i=e.top,a=e.left,o=e.transform;n.destroy(),e.position=t,e.top=i,e.left=a,e.transform=o}else n.destroy();x.current(null)}},[T,a,o,s,l,S]);let E={placement:C};p!==null&&(E.TransitionProps=p);let D=mh(e),O=f.root??`div`,k=lh({elementType:O,externalSlotProps:d.root,externalForwardedProps:h,additionalProps:{role:`tooltip`,ref:_},ownerState:e,className:D.root});return(0,U.jsx)(O,{...k,children:typeof r==`function`?r(E):r})}),_h=K(v.forwardRef(function(e,t){let{anchorEl:n,children:r,container:i,direction:a=`ltr`,disablePortal:o=!1,keepMounted:s=!1,modifiers:c,open:l,placement:u=`bottom`,popperOptions:d=hh,popperRef:f,style:p,transition:m=!1,slotProps:h={},slots:g={},..._}=e,[y,b]=v.useState(!0),x=()=>{b(!1)},S=()=>{b(!0)};if(!s&&!l&&(!m||y))return null;let C;if(i)C=i;else if(n){let e=fh(n);C=e&&ph(e)?ls(e).body:ls(null).body}let w=!l&&s&&(!m||y)?`none`:void 0,T=m?{in:l,onEnter:x,onExited:S}:void 0;return(0,U.jsx)(Qu,{disablePortal:o,container:C,children:(0,U.jsx)(gh,{anchorEl:n,direction:a,disablePortal:o,modifiers:c,ref:t,open:m?!y:l,placement:u,popperOptions:d,popperRef:f,slotProps:h,slots:g,..._,style:{position:`fixed`,top:0,left:0,display:w,...p},TransitionProps:T,children:r})})}),{name:`MuiPopper`,slot:`Root`})({}),vh=v.forwardRef(function(e,t){let n=Ri(),{anchorEl:r,component:i,container:a,disablePortal:o,keepMounted:s,modifiers:c,open:l,placement:u,popperOptions:d,popperRef:f,transition:p,slots:m,slotProps:h,...g}=Xo({props:e,name:`MuiPopper`}),_={anchorEl:r,container:a,disablePortal:o,keepMounted:s,modifiers:c,open:l,placement:u,popperOptions:d,popperRef:f,transition:p,...g};return(0,U.jsx)(_h,{as:i,direction:n?`rtl`:`ltr`,slots:m,slotProps:h,..._,ref:t})});function yh(e){return Gr(`MuiTooltip`,e)}var bh=Kr(`MuiTooltip`,[`popper`,`popperInteractive`,`popperArrow`,`popperClose`,`tooltip`,`tooltipArrow`,`touch`,`tooltipPlacementLeft`,`tooltipPlacementRight`,`tooltipPlacementTop`,`tooltipPlacementBottom`,`arrow`]);function xh(e){return Math.round(e*1e5)/1e5}var Sh=e=>{let{classes:t,disableInteractive:n,arrow:r,touch:i,placement:a}=e;return ba({popper:[`popper`,!n&&`popperInteractive`,r&&`popperArrow`],tooltip:[`tooltip`,r&&`tooltipArrow`,i&&`touch`,`tooltipPlacement${q(a.split(`-`)[0])}`],arrow:[`arrow`]},yh,t)},Ch=K(vh,{name:`MuiTooltip`,slot:`Popper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.popper,!n.disableInteractive&&t.popperInteractive,n.arrow&&t.popperArrow,!n.open&&t.popperClose]}})(ys(({theme:e})=>({zIndex:(e.vars||e).zIndex.tooltip,pointerEvents:`none`,variants:[{props:({ownerState:e,open:t})=>t&&!e.disableInteractive,style:{pointerEvents:`auto`}},{props:({ownerState:e})=>e.arrow,style:{[`&[data-popper-placement*="bottom"] .${bh.arrow}`]:{top:0,marginTop:`-0.71em`,"&::before":{transformOrigin:`0 100%`}},[`&[data-popper-placement*="top"] .${bh.arrow}`]:{bottom:0,marginBottom:`-0.71em`,"&::before":{transformOrigin:`100% 0`}},[`&[data-popper-placement*="right"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineStart:0,marginInlineStart:`-0.71em`,"&::before":{transformOrigin:`100% 100%`}},[`&[data-popper-placement*="left"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineEnd:0,marginInlineEnd:`-0.71em`,"&::before":{transformOrigin:`0 0`}}}}]}))),wh=K(`div`,{name:`MuiTooltip`,slot:`Tooltip`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.tooltip,n.touch&&t.touch,n.arrow&&t.tooltipArrow,t[`tooltipPlacement${q(n.placement.split(`-`)[0])}`]]}})(ys(({theme:e})=>({backgroundColor:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.92),borderRadius:(e.vars||e).shape.borderRadius,color:(e.vars||e).palette.common.white,fontFamily:e.typography.fontFamily,padding:`4px 8px`,fontSize:e.typography.pxToRem(11),maxWidth:300,margin:2,wordWrap:`break-word`,fontWeight:e.typography.fontWeightMedium,[`.${bh.popper}[data-popper-placement*="left"] &`]:{transformOrigin:`right center`,marginInlineEnd:`14px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{transformOrigin:`left center`,marginInlineStart:`14px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{transformOrigin:`center bottom`,marginBottom:`14px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{transformOrigin:`center top`,marginTop:`14px`},variants:[{props:({ownerState:e})=>e.arrow,style:{position:`relative`,marginBlock:0}},{props:({ownerState:e})=>e.touch,style:{padding:`8px 16px`,fontSize:e.typography.pxToRem(14),lineHeight:`${xh(16/14)}em`,fontWeight:e.typography.fontWeightRegular}},{props:({ownerState:e})=>e.touch,style:{[`.${bh.popper}[data-popper-placement*="left"] &`]:{marginInlineEnd:`24px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{marginInlineStart:`24px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{marginBottom:`24px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{marginTop:`24px`}}}]}))),Th=K(`span`,{name:`MuiTooltip`,slot:`Arrow`})(ys(({theme:e})=>({overflow:`hidden`,position:`absolute`,width:`1em`,height:`0.71em`,boxSizing:`border-box`,color:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.9),"&::before":{content:`""`,margin:`auto`,display:`block`,width:`100%`,height:`100%`,backgroundColor:`currentColor`,transform:`rotate(45deg)`}}))),Eh=!1,Dh=new Sl,Oh={x:0,y:0};function kh(e,t){return(n,...r)=>{t&&t(n,...r),e(n,...r)}}var Ah=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTooltip`}),{arrow:r=!1,children:i,classes:a,describeChild:o=!1,disableFocusListener:s=!1,disableHoverListener:c=!1,disableInteractive:l=!1,disableTouchListener:u=!1,enterDelay:d=100,enterNextDelay:f=0,enterTouchDelay:p=700,followCursor:m=!1,id:h,leaveDelay:g=0,leaveTouchDelay:_=1500,onClose:y,onOpen:b,open:x,placement:S=`bottom`,slotProps:C={},slots:w={},title:T,...E}=n,D=v.isValidElement(i)?i:(0,U.jsx)(`span`,{children:i}),O=Go(),[k,A]=v.useState(),[j,M]=v.useState(null),N=v.useRef(!1),P=l||m,F=Cl(),I=Cl(),L=Cl(),R=Cl(),[ee,te]=Od({controlled:x,default:!1,name:`Tooltip`,state:`open`}),z=ee,B=Ed(h),V=v.useRef(),ne=dl(()=>{V.current!==void 0&&(document.body.style.WebkitUserSelect=V.current,V.current=void 0),R.clear()});v.useEffect(()=>ne,[ne]);let re=e=>{Dh.clear(),Eh=!0,te(!0),b&&!z&&b(e)},ie=dl(e=>{Dh.start(800+g,()=>{Eh=!1}),te(!1),y&&z&&y(e),F.start(O.transitions.duration.shortest,()=>{N.current=!1})}),ae=e=>{k?.disabled||N.current&&e.type!==`touchstart`||(k&&k.removeAttribute(`title`),I.clear(),L.clear(),d||Eh&&f?I.start(Eh?f:d,()=>{re(e)}):re(e))},oe=e=>{I.clear(),L.start(g,()=>{ie(e)})},[,se]=v.useState(!1),H=e=>{let t=e?.target??k;if(!t||t.disabled||!ul(t)){se(!1);let n=e??new Event(`blur`);!e&&t&&(Object.defineProperty(n,"target",{value:t}),Object.defineProperty(n,"currentTarget",{value:t})),oe(n)}},ce=e=>{if(k||A(e.currentTarget),ul(e.target)){let t=e=>{e.target.disabled&&H(e),e.target.removeEventListener(`blur`,t)};e.target.addEventListener(`blur`,t),se(!0),ae(e)}},le=e=>{N.current=!0;let t=D.props;t.onTouchStart&&t.onTouchStart(e)},ue=e=>{le(e),L.clear(),F.clear(),ne(),V.current=document.body.style.WebkitUserSelect,document.body.style.WebkitUserSelect=`none`,R.start(p,()=>{document.body.style.WebkitUserSelect=V.current,ae(e)})},de=e=>{D.props.onTouchEnd&&D.props.onTouchEnd(e),ne(),L.start(_,()=>{ie(e)})};v.useEffect(()=>{if(!z)return;function e(e){e.key===`Escape`&&ie(e)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[ie,z]);let fe=bs(Lu(D),A,t);!T&&T!==0&&(z=!1);let pe=v.useRef(),me=e=>{let t=D.props;t.onMouseMove&&t.onMouseMove(e),Oh={x:e.clientX,y:e.clientY},pe.current&&pe.current.update()},he={},ge=typeof T==`string`;o?(he.title=!z&&ge&&!c?T:null,he[`aria-describedby`]=z?B:null):(he[`aria-label`]=ge?T:null,he[`aria-labelledby`]=z&&!ge?B:null);let _e={...he,...E,...D.props,className:W(E.className,D.props.className),onTouchStart:le,ref:fe,...m?{onMouseMove:me}:{}},ve={};u||(_e.onTouchStart=ue,_e.onTouchEnd=de),c||(_e.onMouseOver=kh(ae,_e.onMouseOver),_e.onMouseLeave=kh(oe,_e.onMouseLeave),P||(ve.onMouseOver=ae,ve.onMouseLeave=oe)),s||(_e.onFocus=kh(ce,_e.onFocus),_e.onBlur=kh(H,_e.onBlur),P||(ve.onFocus=ce,ve.onBlur=H));let ye={...n,arrow:r,disableInteractive:P,placement:S,touch:N.current},be=typeof C.popper==`function`?C.popper(ye):C.popper,xe=v.useMemo(()=>{let e=[{name:`arrow`,enabled:!!j,options:{element:j,padding:4}}];return be?.popperOptions?.modifiers&&(e=e.concat(be.popperOptions.modifiers)),{...be?.popperOptions,modifiers:e}},[j,be?.popperOptions]),Se=Sh(ye),Ce={slots:w,slotProps:{arrow:C.arrow,popper:be,tooltip:C.tooltip,transition:C.transition}},[we,Te]=Xc(`popper`,{elementType:Ch,externalForwardedProps:Ce,ownerState:ye,className:Se.popper}),[Ee,De]=Xc(`transition`,{elementType:mp,externalForwardedProps:Ce,ownerState:ye}),[Oe,ke]=Xc(`tooltip`,{elementType:wh,className:Se.tooltip,externalForwardedProps:Ce,ownerState:ye}),[Ae,je]=Xc(`arrow`,{elementType:Th,className:Se.arrow,externalForwardedProps:Ce,ownerState:ye,ref:M});return(0,U.jsxs)(v.Fragment,{children:[v.cloneElement(D,_e),(0,U.jsx)(we,{as:vh,placement:S,anchorEl:m?{getBoundingClientRect:()=>({top:Oh.y,left:Oh.x,right:Oh.x,bottom:Oh.y,width:0,height:0})}:k,popperRef:pe,open:k?z:!1,id:B,transition:!0,...ve,...Te,popperOptions:xe,children:({TransitionProps:e})=>(0,U.jsx)(Ee,{timeout:O.transitions.duration.shorter,...e,...De,children:(0,U.jsxs)(Oe,{...ke,children:[T,r?(0,U.jsx)(Ae,{...je}):null]})})})]})}),jh=Y((0,U.jsx)(`path`,{d:`M4 13h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1m0 8h6c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1m10 0h6c.55 0 1-.45 1-1v-8c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1M13 4v4c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1`}),`DashboardRounded`),Mh=Y((0,U.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2`}),`ChatBubbleRounded`),Nh=Y((0,U.jsx)(`path`,{d:`M14.59 2.59c-.38-.38-.89-.59-1.42-.59H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8.83c0-.53-.21-1.04-.59-1.41zM15 18H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m0-4H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m-2-6V3.5L18.5 9H14c-.55 0-1-.45-1-1`}),`DescriptionRounded`),Ph=Y((0,U.jsx)(`path`,{d:`M3 7c.55 0 1 .45 1 1v13h13c.55 0 1 .45 1 1s-.45 1-1 1H4c-1.1 0-2-.9-2-2V8c0-.55.45-1 1-1m12.59-5.41c-.38-.38-.89-.59-1.42-.59H8c-1.1 0-1.99.9-1.99 2L6 17c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V7.83c0-.53-.21-1.04-.59-1.41zM15.5 15h-4c-.55 0-1-.45-1-1s.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1m0-6h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V9h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V6c0-.55.45-1 1-1s1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1`}),`DifferenceRounded`),Fh=Y((0,U.jsx)(`path`,{d:`M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2m0 14H4V8h16zm-8-2c0-.55.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1M6.79 9.71c.39-.39 1.02-.39 1.41 0l2.59 2.59c.39.39.39 1.02 0 1.41L8.2 16.3c-.39.39-1.02.39-1.41 0a.996.996 0 0 1 0-1.41L8.67 13l-1.88-1.88a.996.996 0 0 1 0-1.41`}),`TerminalRounded`),Ih=Y((0,U.jsx)(`path`,{d:`M13.26 3C8.17 2.86 4 6.95 4 12H2.21c-.45 0-.67.54-.35.85l2.79 2.8c.2.2.51.2.71 0l2.79-2.8c.31-.31.09-.85-.36-.85H6c0-3.9 3.18-7.05 7.1-7 3.72.05 6.85 3.18 6.9 6.9.05 3.91-3.1 7.1-7 7.1-1.61 0-3.1-.55-4.28-1.48-.4-.31-.96-.28-1.32.08-.42.42-.39 1.13.08 1.49C9 20.29 10.91 21 13 21c5.05 0 9.14-4.17 9-9.26-.13-4.69-4.05-8.61-8.74-8.74m-.51 5c-.41 0-.75.34-.75.75v3.68c0 .35.19.68.49.86l3.12 1.85c.36.21.82.09 1.03-.26.21-.36.09-.82-.26-1.03l-2.88-1.71v-3.4c0-.4-.34-.74-.75-.74`}),`HistoryRounded`),Lh=Y((0,U.jsx)(`path`,{d:`M9.19 6.35c-2.04 2.29-3.44 5.58-3.57 5.89l-2.26-.97c-.65-.28-.81-1.13-.31-1.63l3.01-3.01c.47-.47 1.15-.68 1.81-.55zm1.49 10.16c.3.3.74.38 1.12.2 1.16-.54 3.65-1.81 5.26-3.42 4.59-4.59 4.63-8.33 4.36-9.93-.07-.4-.39-.72-.79-.79-1.6-.27-5.34-.23-9.93 4.36-1.61 1.61-2.87 4.1-3.42 5.26-.18.38-.09.83.2 1.12zm6.97-1.7c-2.29 2.04-5.58 3.44-5.89 3.57l.97 2.26c.28.65 1.13.81 1.63.31l3.01-3.01c.47-.47.68-1.15.55-1.81zm-8.71 2.6c.2 1.06-.15 2.04-.82 2.71-.77.77-3.16 1.34-4.71 1.64-.69.13-1.3-.48-1.17-1.17.3-1.55.86-3.94 1.64-4.71.67-.67 1.65-1.02 2.71-.82 1.17.22 2.13 1.18 2.35 2.35M13 9c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2`}),`RocketLaunchRounded`),Rh=Y((0,U.jsx)(`path`,{d:`M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1m0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1`}),`MenuRounded`),zh=Y((0,U.jsx)(`path`,{d:`M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5M2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1m18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1M11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1m0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1M5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0z`}),`LightModeRounded`),Bh=Y((0,U.jsx)(`path`,{d:`M11.01 3.05C6.51 3.54 3 7.36 3 12c0 4.97 4.03 9 9 9 4.63 0 8.45-3.5 8.95-8 .09-.79-.78-1.42-1.54-.95-.84.54-1.84.85-2.91.85-2.98 0-5.4-2.42-5.4-5.4 0-1.06.31-2.06.84-2.89.45-.67-.04-1.63-.93-1.56`}),`DarkModeRounded`),Vh=Y((0,U.jsx)(`path`,{d:`M20 6h-8l-1.41-1.41C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m-1 12H5c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1`}),`FolderOpenRounded`);function Hh(e){return Gr(`MuiTab`,e)}var Uh=Kr(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`icon`]),Wh=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e;return ba({root:[`root`,a&&o&&`labelIcon`,`textColor${q(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`icon`]},Hh,t)},Gh=K(tu,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${q(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${Uh.icon}`]:t.icon}]}})(ys(({theme:e})=>({...e.typography.button,maxWidth:360,minWidth:90,position:`relative`,minHeight:48,flexShrink:0,padding:`12px 16px`,overflow:`hidden`,whiteSpace:`normal`,textAlign:`center`,lineHeight:1.25,variants:[{props:({ownerState:e})=>e.label&&(e.iconPosition===`top`||e.iconPosition===`bottom`),style:{flexDirection:`column`}},{props:({ownerState:e})=>e.label&&e.iconPosition!==`top`&&e.iconPosition!==`bottom`,style:{flexDirection:`row`}},{props:({ownerState:e})=>e.icon&&e.label,style:{minHeight:72,paddingTop:9,paddingBottom:9}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`top`,style:{[`& > .${Uh.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${Uh.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${Uh.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${Uh.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${Uh.selected}`]:{opacity:1},[`&.${Uh.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:({ownerState:e})=>e.fullWidth,style:{flexShrink:1,flexGrow:1,flexBasis:0,maxWidth:`none`}},{props:({ownerState:e})=>e.wrapped,style:{fontSize:e.typography.pxToRem(12)}}]}))),Kh=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTab`}),{className:r,disabled:i=!1,disableFocusRipple:a=!1,fullWidth:o,icon:s,iconPosition:c=`top`,indicator:l,label:u,onChange:d,onClick:f,onFocus:p,selected:m,selectionFollowsFocus:h,textColor:g=`inherit`,value:_,wrapped:y=!1,...b}=n,x=Of(),S=Nf({id:_,ref:t,disabled:i,selected:m}),C=x.getItemMap().size===0&&m?0:S.tabIndex,w={...n,disabled:i,disableFocusRipple:a,selected:m,icon:!!s,iconPosition:c,label:!!u,fullWidth:o,textColor:g,wrapped:y},T=Wh(w),E=s&&u&&v.isValidElement(s)?v.cloneElement(s,{className:W(T.icon,s.props.className)}):s;return(0,U.jsxs)(Gh,{internalNativeButton:!0,focusRipple:!a,className:W(T.root,r),ref:S.ref,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,_),f&&f(e)},onFocus:e=>{h&&!m&&d&&d(e,_),p&&p(e)},tabIndex:C,ownerState:w,...b,children:[c===`top`||c===`start`?(0,U.jsxs)(v.Fragment,{children:[E,u]}):(0,U.jsxs)(v.Fragment,{children:[u,E]}),l]})});function qh(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function Jh(e,t,n,r={},i=()=>{}){let{ease:a=qh,duration:o=300}=r,s=null,c=t[e],l=!1,u=()=>{l=!0},d=r=>{if(l){i(Error(`Animation cancelled`));return}s===null&&(s=r);let u=Math.min(1,(r-s)/o);if(t[e]=a(u)*(n-c)+c,u>=1){requestAnimationFrame(()=>{i(null)});return}requestAnimationFrame(d)};return c===n?(i(Error(`Element already at target position`)),u):(requestAnimationFrame(d),u)}var Yh={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`,pointerEvents:`none`};function Xh(e){let{onChange:t,...n}=e,r=v.useRef(),i=v.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return xs(()=>{let e=Cd(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=Td(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),v.useEffect(()=>{a(),t(r.current)},[t]),(0,U.jsx)(`div`,{style:Yh,...n,ref:i})}var Zh=Y((0,U.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Qh=Y((0,U.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function $h(e){return Gr(`MuiTabScrollButton`,e)}var eg=Kr(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),tg=e=>{let{classes:t,orientation:n,disabled:r}=e;return ba({root:[`root`,n,r&&`disabled`]},$h,t)},ng=K(tu,{name:`MuiTabScrollButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.orientation&&t[n.orientation]]}})({width:40,flexShrink:0,opacity:.8,[`&.${eg.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),rg=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,{nativeButton:u,...d}=l,f=Ri(),p={isRtl:f,...n},m=tg(p),h=i.StartScrollButtonIcon??Zh,g=i.EndScrollButtonIcon??Qh,_=lh({elementType:h,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p}),v=lh({elementType:g,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p});return(0,U.jsx)(ng,{component:`div`,className:W(m.root,r),ref:t,role:null,ownerState:p,tabIndex:null,...d,style:{...d.style,...s===`vertical`&&{"--TabScrollButton-svgRotate":`rotate(${f?-90:90}deg)`}},children:o===`left`?(0,U.jsx)(h,{..._}):(0,U.jsx)(g,{...v})})});function ig(e){return Gr(`MuiTabs`,e)}var ag=Kr(`MuiTabs`,[`root`,`vertical`,`list`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),og=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return ba({root:[`root`,t&&`vertical`],scroller:[`scroller`,n&&`fixed`,r&&`hideScrollbar`,i&&`scrollableX`,a&&`scrollableY`],list:[`list`,t&&`vertical`,o&&`centered`],indicator:[`indicator`],scrollButtons:[`scrollButtons`,s&&`scrollButtonsHideMobile`],scrollableX:[i&&`scrollableX`],hideScrollbar:[r&&`hideScrollbar`]},ig,c)},sg=K(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${ag.scrollButtons}`]:t.scrollButtons},{[`& .${ag.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(ys(({theme:e})=>({overflow:`hidden`,minHeight:48,WebkitOverflowScrolling:`touch`,display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.scrollButtonsHideMobile,style:{[`& .${ag.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),cg=K(`div`,{name:`MuiTabs`,slot:`Scroller`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.scroller,n.fixed&&t.fixed,n.hideScrollbar&&t.hideScrollbar,n.scrollableX&&t.scrollableX,n.scrollableY&&t.scrollableY]}})({position:`relative`,display:`inline-block`,flex:`1 1 auto`,whiteSpace:`nowrap`,variants:[{props:({ownerState:e})=>e.fixed,style:{overflowX:`hidden`,width:`100%`}},{props:({ownerState:e})=>e.hideScrollbar,style:{scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}},{props:({ownerState:e})=>e.scrollableX,style:{overflowX:`auto`,overflowY:`hidden`}},{props:({ownerState:e})=>e.scrollableY,style:{overflowY:`auto`,overflowX:`hidden`}}]}),lg=K(`div`,{name:`MuiTabs`,slot:`List`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.list,n.centered&&t.centered]}})({display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.centered,style:{justifyContent:`center`}}]}),ug=K(`span`,{name:`MuiTabs`,slot:`Indicator`})(ys(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,...Ks(e),variants:[{props:{indicatorColor:`primary`},style:{backgroundColor:(e.vars||e).palette.primary.main}},{props:{indicatorColor:`secondary`},style:{backgroundColor:(e.vars||e).palette.secondary.main}},{props:({ownerState:e})=>e.vertical,style:{height:`100%`,width:2,right:0}}]}))),dg=K(Xh)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),fg={},pg=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTabs`}),r=Go(),i=Ri(),a=Ll(r.motion.reducedMotion,!1),{"aria-label":o,"aria-labelledby":s,action:c,centered:l=!1,children:u,className:d,component:f=`div`,allowScrollButtonsMobile:p=!1,indicatorColor:m=`primary`,onChange:h,orientation:g=`horizontal`,scrollButtons:_=`auto`,selectionFollowsFocus:y,slots:b={},slotProps:x={},textColor:S=`primary`,value:C,variant:w=`standard`,visibleScrollbar:T=!1,...E}=n,D=w===`scrollable`,O=g===`vertical`,k=O?`scrollTop`:`scrollLeft`,A=O?`top`:`left`,j=O?`bottom`:`right`,M=O?`clientHeight`:`clientWidth`,N=O?`height`:`width`,P={...n,component:f,allowScrollButtonsMobile:p,indicatorColor:m,orientation:g,vertical:O,scrollButtons:_,textColor:S,variant:w,visibleScrollbar:T,fixed:!D,hideScrollbar:D&&!T,scrollableX:D&&!O,scrollableY:D&&O,centered:l&&!D,scrollButtonsHideMobile:!p},F=og(P),I=lh({elementType:b.startScrollButtonIcon,externalSlotProps:x.startScrollButtonIcon,ownerState:P}),L=lh({elementType:b.endScrollButtonIcon,externalSlotProps:x.endScrollButtonIcon,ownerState:P}),[R,ee]=v.useState(!1),[te,z]=v.useState(fg),[B,V]=v.useState(!1),[ne,re]=v.useState(!1),[ie,ae]=v.useState(!1),oe=C===!1?null:C,[se,H]=v.useState(!1),[ce,le]=v.useState({overflow:`hidden`,scrollbarWidth:0}),ue=new Map,de=v.useRef(null),fe=v.useRef(null),pe={slots:b,slotProps:x},me=()=>{let e=de.current,t;if(e){let n=e.getBoundingClientRect();t={clientWidth:e.clientWidth,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}let n;if(e&&C!==!1){let e=fe.current.children;if(e.length>0){let t=e[ue.get(C)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},he=dl(()=>{let{tabsMeta:e,tabMeta:t}=me(),n=0,r;O?(r=`top`,t&&e&&(n=t.top-e.top+e.scrollTop)):(r=i?`right`:`left`,t&&e&&(n=(i?-1:1)*(t[r]-e[r]+e.scrollLeft)));let a={[r]:n,[N]:t?t[N]:0};if(typeof te[r]!=`number`||typeof te[N]!=`number`)z(a);else{let e=Math.abs(te[r]-a[r]),t=Math.abs(te[N]-a[N]);(e>=1||t>=1)&&z(a)}}),ge=(e,{animation:t=!0}={})=>{t&&!a.shouldReduceMotion?Jh(k,de.current,e,{duration:r.transitions.duration.standard}):de.current[k]=e},_e=e=>{let t=de.current[k];t+=O?e:e*(i?-1:1),ge(t)},ve=()=>{let e=de.current[M],t=0,n=Array.from(fe.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[M]>e){r===0&&(t=e);break}t+=i[M]}return t},ye=()=>{_e(-1*ve())},be=()=>{_e(ve())},[xe,{onChange:Se,...Ce}]=Xc(`scrollbar`,{className:W(F.scrollableX,F.hideScrollbar),elementType:dg,shouldForwardComponentProp:!0,externalForwardedProps:pe,ownerState:P}),we=v.useCallback(e=>{Se?.(e),le({overflow:null,scrollbarWidth:e})},[Se]),[Te,Ee]=Xc(`scrollButtons`,{className:F.scrollButtons,elementType:rg,externalForwardedProps:pe,ownerState:P,additionalProps:{orientation:g,slots:{StartScrollButtonIcon:b.startScrollButtonIcon,EndScrollButtonIcon:b.endScrollButtonIcon},slotProps:{startScrollButtonIcon:I,endScrollButtonIcon:L}}}),De=()=>{let e={};e.scrollbarSizeListener=D?(0,U.jsx)(xe,{...Ce,onChange:we}):null;let t=D&&(_===`auto`&&(B||ne)||_===!0);return e.scrollButtonStart=t?(0,U.jsx)(Te,{direction:i?`right`:`left`,onClick:ye,disabled:!B,...Ee}):null,e.scrollButtonEnd=t?(0,U.jsx)(Te,{direction:i?`left`:`right`,onClick:be,disabled:!ne,...Ee}):null,e},Oe=dl(e=>{let{tabsMeta:t,tabMeta:n}=me();if(!(!n||!t)){if(n[A]<t[A]){let r=t[k]+(n[A]-t[A]);ge(r,{animation:e})}else if(n[j]>t[j]){let r=t[k]+(n[j]-t[j]);ge(r,{animation:e})}}}),ke=dl(()=>{D&&_!==!1&&ae(!ie)});v.useEffect(()=>{let e=Cd(()=>{de.current&&he()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),ke()},r=Td(de.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(fe.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(fe.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[he,ke]),v.useEffect(()=>{let e=Array.from(fe.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&D&&_!==!1){let n=e[0],r=e[t-1],i={root:de.current,threshold:.99},a=new IntersectionObserver(e=>{V(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{re(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[D,_,ie,u?.length]),v.useEffect(()=>{ee(!0)},[]),v.useEffect(()=>{he()}),v.useEffect(()=>{Oe(fg!==te)},[Oe,te]),v.useImperativeHandle(c,()=>({updateIndicator:he,updateScrollButtons:ke}),[he,ke]);let[Ae,je]=Xc(`indicator`,{className:F.indicator,elementType:ug,externalForwardedProps:pe,ownerState:P,additionalProps:{style:te}}),Me=(0,U.jsx)(Ae,{...je}),Ne=Mf({activeItemId:se?void 0:oe,orientation:g,isRtl:i}),Pe=Ne.getContainerProps(),Fe=v.Children.toArray(u).filter(v.isValidElement).map((e,t)=>{let n=e.props.value===void 0?t:e.props.value;return ue.set(n,t),{child:e,index:t,childValue:n}}).map(({child:e,childValue:t})=>{let n=t===C;return v.cloneElement(e,{fullWidth:w===`fullWidth`,indicator:n&&!R&&Me,selected:n,selectionFollowsFocus:y,onChange:h,textColor:S,value:t})}),Ie=De(),[Le,Re]=Xc(`root`,{ref:t,className:W(F.root,d),elementType:sg,externalForwardedProps:{...pe,...E,component:f},ownerState:P}),[ze,Be]=Xc(`scroller`,{ref:de,className:F.scroller,elementType:cg,externalForwardedProps:pe,ownerState:P,additionalProps:{style:{overflow:ce.overflow,[O?`margin${i?`Left`:`Right`}`:`marginBottom`]:T?void 0:-ce.scrollbarWidth}}}),Ve=bs(Pe.ref,fe),He=e=>{let t=fe.current;ws(Ss(t))?.getAttribute(`role`)===`tab`&&Pe.onKeyDown(e)},[Ue,We]=Xc(`list`,{ref:Ve,className:F.list,elementType:lg,externalForwardedProps:pe,ownerState:P,getSlotProps:e=>({...e,onBlur:t=>{zu(t.currentTarget,t.relatedTarget)||H(!1),e.onBlur?.(t)},onKeyDown:t=>{He(t),e.onKeyDown?.(t)},onFocus:t=>{H(!0),Pe.onFocus(t),e.onFocus?.(t)}})});return(0,U.jsxs)(Le,{...Re,children:[Ie.scrollButtonStart,Ie.scrollbarSizeListener,(0,U.jsxs)(ze,{...Be,children:[(0,U.jsx)(Ue,{"aria-label":o,"aria-labelledby":s,"aria-orientation":g===`vertical`?`vertical`:null,role:`tablist`,...We,children:(0,U.jsx)(Df.Provider,{value:Ne,children:Fe})}),R&&Me]}),Ie.scrollButtonEnd]})}),mg=null,hg=null;async function gg(e){if(!e.ok)return!1;try{let t=await e.json();return typeof t.csrfToken!=`string`||!/^[A-Za-z0-9_-]{43}$/.test(t.csrfToken)?!1:(mg=t.csrfToken,!0)}catch{return!1}}function _g(){return mg}async function vg(e,t){let n=await fetch(e,t);if(n.status!==403)return n;let r=t.headers[`X-Piagent-CSRF`];try{await gg(await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t.signal}))}catch{return n}return!mg||mg===r?n:fetch(e,{...t,headers:{...t.headers,"X-Piagent-CSRF":mg}})}var yg=null;function bg(){return yg}async function xg(){let e=new URLSearchParams(window.location.hash.slice(1)),t=e.get(`bootstrap`),n=e.get(`project`);if(n&&/^[A-Za-z0-9_-]{1,120}$/.test(n)&&(yg=n),!t){n&&window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);try{return await gg(await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`}}))?`existing-session`:`failed`}catch{return`failed`}}window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);try{return await gg(await fetch(`/api/v1/bootstrap`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({capability:t})}))?`authenticated`:`failed`}catch{return`failed`}}function Sg(){return hg??=xg(),hg}var Cg=!1,wg=null,Tg=new Set;function Eg(){return Cg}function Dg(e){return Tg.add(e),()=>{Tg.delete(e)}}function Og(){Cg||wg||(wg=(async()=>{try{await Sg();let e=await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`}});if(e.status!==401){await gg(e);return}Cg=!0;for(let e of Tg)e()}catch{}finally{wg=null}})())}var kg=class extends Error{status;code;constructor(e,t=null){super(`webui-request-${e}`),this.status=e,this.code=t}};async function Ag(e){try{let t=await e.json();return typeof t.error?.code==`string`?t.error.code:null}catch{return null}}async function jg(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new kg(t.status);return await t.json()}function Mg(e){return Wg(`/api/v1/session-catalog`,e)}function Ng(e){return Wg(`/api/v1/session-live-state`,e)}function Pg(e){return Wg(`/api/v1/session-creation-options`,e)}function Fg(e){return Wg(`/api/v1/provider-auth`,e)}function Ig(e,t){return Wg(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function Lg(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/provider-auth`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}function Rg(e,t){return Lg({action:`provider-auth.start`,providerRef:e},t)}function zg(e,t,n,r){return Lg({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function Bg(e,t){return Lg({action:`provider-auth.cancel`,jobRef:e},t)}async function Vg(e){let t=_g();if(!t)throw new kg(403);let n=await vg(`/api/v1/projects/import`,{method:`POST`,credentials:`same-origin`,signal:e,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":t},body:JSON.stringify({action:`project.import`})});if(!n.ok)throw new kg(n.status,await Ag(n));return await n.json()}async function Hg(e){try{return await Wg(`/api/v1/managed`,e)}catch(e){if(e instanceof kg&&e.status===404)return null;throw e}}async function Ug(e){let t=_g();if(!t)throw new kg(403);let n=await vg(`/api/v1/managed/connect`,{method:`POST`,credentials:`same-origin`,signal:e,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":t},body:JSON.stringify({action:`managed.connect`})});if(!n.ok)throw new kg(n.status);return await n.json()}async function Wg(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(n.status===401&&Og(),!n.ok)throw new kg(n.status);return await n.json()}function Gg(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function Kg(e,t){return Wg(Gg(e,`/api/v1/snapshot`),t)}function qg(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),Wg(Gg(e,`/api/v1/transcript?${i}`),r)}function Jg(e,t,n){return Wg(Gg(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function Yg(e,t,n){return Wg(Gg(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function Xg(e,t,n,r){return Wg(Gg(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function Zg(e,t,n,r){return Wg(Gg(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function Qg(e,t,n,r){return Wg(Gg(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function $g(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return Wg(Gg(e,`/api/v1/source-reverts/${encodeURIComponent(t)}${i}`),r)}function e_(e,t){return Wg(Gg(e,`/api/v1/commit-summary`),t)}function t_(e,t,n){return Wg(Gg(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function n_(e,t){return Wg(Gg(e,`/api/v1/connections`),t)}async function r_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/session-connections`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}function i_(e,t){return Wg(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function a_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/runtime-commands`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function o_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}/cancel`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"X-Piagent-CSRF":n}});if(!r.ok)throw new kg(r.status);return await r.json()}function s_(e,t){return Wg(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function c_(e,t,n){return Wg(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function l_(e,t,n){return Wg(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function u_(e,t,n){return Wg(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function d_(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return Wg(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function f_(e){return Wg(`/api/v1/commit-summary`,e)}function p_(e){return Wg(`/api/v1/tasks`,e)}function m_(e,t){return Wg(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function h_(e,t){return Wg(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function g_(e,t){return Wg(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function __(e,t){return Wg(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function v_(e){return Wg(`/api/v1/monitoring/release`,e)}function y_(e,t){return Wg(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function b_(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),Wg(`/api/v1/transcript?${r}`,n)}function x_(e){return Wg(`/api/v1/chat/queue`,e)}function S_(e){return Wg(`/api/v1/session-options/models`,e)}function C_(e,t){return Wg(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function w_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/approvals/${encodeURIComponent(e.approvalRef)}/decision`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function T_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/chat/messages`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function E_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/session-options`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function D_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/lifecycle`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function O_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/control/resume-and-continue`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function k_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/reviews`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function A_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function j_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function M_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/source-handoffs`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}async function N_(e,t,n){let r=_g();if(!r)throw new kg(403);let i=await vg(`/api/v1/sessions/${encodeURIComponent(e)}/attachments`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r},body:JSON.stringify(t)});if(!i.ok)throw new kg(i.status);return await i.json()}function P_(e,t){return Wg(e?Gg(e,`/api/v1/documents`):`/api/v1/documents`,t)}function F_(e,t,n){let r=`/api/v1/documents/${encodeURIComponent(t)}`;return Wg(e?Gg(e,r):r,n)}async function I_(e,t){let n=_g();if(!n)throw new kg(403);let r=await vg(`/api/v1/attachments`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(e)});if(!r.ok)throw new kg(r.status);return await r.json()}function L_(e,t,n){return Wg(`/api/v1/projects/${encodeURIComponent(e)}/paths?query=${encodeURIComponent(t)}`,n)}function R_(e,t){return Wg(`/api/v1/projects/${encodeURIComponent(e)}/commands`,t)}function z_(e,t){return Wg(`/api/v1/sessions/${encodeURIComponent(e)}/questions`,t)}async function B_(e,t,n,r){let i=_g();if(!i)throw new kg(403);let a=await vg(`/api/v1/sessions/${encodeURIComponent(e)}/questions/${encodeURIComponent(t)}/answer`,{method:`POST`,credentials:`same-origin`,signal:r,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":i},body:JSON.stringify(n)});if(!a.ok)throw new kg(a.status)}var V_=class extends Error{status;code;detail;constructor(e,t,n){super(t),this.status=e,this.code=t,this.detail=n}};function H_(e,t=null,n){return Wg(`/api/v1/projects/${encodeURIComponent(e)}/branches${t===null?``:`?repository=${encodeURIComponent(t)}`}`,n)}async function U_(e,t,n){let r=_g();if(!r)throw new V_(403,`mutation-authority-rejected`,null);let i=await vg(`/api/v1/projects/${encodeURIComponent(e)}/branches/switch`,{method:`POST`,credentials:`same-origin`,signal:n,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r},body:JSON.stringify(t)});if(i.status===401&&Og(),!i.ok){let e=`branch-request-${i.status}`,t=null;try{let n=await i.json();typeof n.error?.code==`string`&&(e=n.error.code),typeof n.error?.detail==`string`&&(t=n.error.detail)}catch{}throw new V_(i.status,e,t)}return await i.json()}function W_(e){return Array.isArray(e)?`[${e.map(W_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${W_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function G_(e){let t=new TextEncoder().encode(typeof e==`string`?e:W_(e)),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function K_(e,t,n,r){let i=new Date,a=new Date(i.getTime()+3e5),o=r?.attachmentRefs??[],s={messageRequestId:r?.messageRequestId??`message-request.${crypto.randomUUID()}`,capabilityAction:n===`steer`?`interruptAndSend`:n===`hold`?`hold`:`send`,delivery:n,text:t,attachmentRefs:o,contentDigest:await G_({attachmentRefs:o,text:t})},c={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},l={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:i.toISOString(),expiresAt:a.toISOString(),capabilityScope:`control.chat`,action:`chat.send`,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:c,payload:s};return l.actionDigest=await G_({action:l.action,identity:l.identity,expectedRevisions:c,payload:s}),l}async function q_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5);return{schemaVersion:1,version:`piagent-webui-attachment-v1`,messageType:`stage-command`,commandId:`attachment-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),identity:{...structuredClone(e.identity),toolCallId:null},expectedRuntimeRevision:e.revision.runtimeRevision,messageRequestId:t,file:n}}function J_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5);return{schemaVersion:1,version:`piagent-webui-attachment-v1`,messageType:`discard-command`,commandId:`attachment-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),identity:{...structuredClone(e.identity),toolCallId:null},expectedRuntimeRevision:e.revision.runtimeRevision,messageRequestId:t,attachmentRef:n}}async function Y_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},o={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.chat`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:a,payload:n};return o.actionDigest=await G_({action:t,identity:o.identity,expectedRevisions:a,payload:n}),o}async function X_(e,t){let n=[];return{queueItemRef:e,text:t,attachmentRefs:n,contentDigest:await G_({attachmentRefs:n,text:t})}}async function Z_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},o=t===`session-options.set-model`?{modelRef:n,effectScopeAcknowledged:`session-and-user-default`}:{thinkingLevel:n,effectScopeAcknowledged:`session-and-user-default`},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.sessionOptions`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:a,payload:o};return s.actionDigest=await G_({action:t,identity:s.identity,expectedRevisions:a,payload:o}),s}async function Q_(e,t){let n=new Date,r=new Date(n.getTime()+3e5),i={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},a=t===`lifecycle.stop`?{requestedScope:`current-agent-operation`}:t===`lifecycle.pause`?{safePointPolicy:`after-current-atomic-unit`}:{},o={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.toISOString(),capabilityScope:`control.lifecycle`,action:t,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:i,payload:a};return o.actionDigest=await G_({action:t,identity:o.identity,expectedRevisions:i,payload:a}),o}async function $_(e,t,n){let r=new Date,i=new Date(r.getTime()+3e5),a=n?.attachmentRefs??[],o={messageRequestId:n?.messageRequestId??`message-request.${crypto.randomUUID()}`,capabilityAction:`send`,delivery:`new-operation`,text:t,attachmentRefs:a,contentDigest:await G_({attachmentRefs:a,text:t})},s={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`control.resumeAndContinue`,action:`lifecycle.resume-and-continue`,actionDigest:``,identity:structuredClone(e.identity),expectedRevisions:s,payload:o};return c.actionDigest=await G_({action:c.action,identity:c.identity,expectedRevisions:s,payload:o}),c}function ev(e){return Array.isArray(e)?`[${e.map(ev).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${ev(t)}`).join(`,`)}}`:JSON.stringify(e)}async function tv(e){let t=new TextEncoder().encode(ev(e)),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function nv(e,t,n){if(!t.target||t.state===`unavailable`)throw Error(`review-target-unavailable`);let r=new Date,i=new Date(r.getTime()+3e5),a=t.target,o={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},s={runtimeRevision:e.revision.runtimeRevision,taskRevision:a.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:a.workspaceRevision,indexRevision:a.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:a.patchPreimage},c={view:a.view,fileRef:a.fileRef,diffRef:a.diffRef,reviewState:n,contentDigest:a.contentDigest},l={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`review-command.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:i.toISOString(),capabilityScope:`reviewActions`,action:`review.mark`,actionDigest:``,identity:o,expectedRevisions:s,payload:c};return l.actionDigest=await tv({action:l.action,identity:o,expectedRevisions:s,payload:c}),l}function rv(e){return Array.isArray(e)?`[${e.map(rv).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${rv(t)}`).join(`,`)}}`:JSON.stringify(e)}async function iv(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(rv(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function av(e,t,n=[]){if(t.state!==`ready`||!t.target)throw Error(`source-mutation-preview-unavailable`);let r=new Date,i=t.target,a={...structuredClone(e.identity),agentOperationId:null,toolCallId:null};if(n.length>128||new Set(n).size!==n.length||n.some(e=>!i.hunkRefs.includes(e))||rv(n)!==rv(i.hunkRefs.filter(e=>n.includes(e))))throw Error(`source-mutation-hunk-unavailable`);let o={runtimeRevision:e.revision.runtimeRevision,taskRevision:i.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:i.workspaceRevision,indexRevision:i.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:i.workspacePreimage,indexPreimage:i.indexPreimage,patchPreimage:i.patchPreimage},s={fileRef:i.fileRef,hunkRefs:[...n],contentDigest:i.contentDigest},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-mutation.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:r.toISOString(),expiresAt:new Date(r.getTime()+3e5).toISOString(),capabilityScope:`reviewActions`,action:t.action,actionDigest:``,identity:a,expectedRevisions:o,payload:s};return c.actionDigest=await iv({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}function ov(e){return Array.isArray(e)?`[${e.map(ov).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${ov(t)}`).join(`,`)}}`:JSON.stringify(e)}async function sv(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(ov(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function cv(e,t){if(t.state!==`ready`||!t.target)throw Error(`source-revert-preview-unavailable`);let n=new Date,r=t.target;if(Date.parse(r.expiresAt)<=n.getTime())throw Error(`source-revert-preview-expired`);let i={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},a={runtimeRevision:e.revision.runtimeRevision,taskRevision:r.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:r.workspaceRevision,indexRevision:r.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:r.workspacePreimage,indexPreimage:r.indexPreimage,patchPreimage:r.patchPreimage},o={fileRef:r.fileRef,hunkRefs:[...r.hunkRefs],previewRef:r.previewRef,confirmedPreviewDigest:r.confirmedPreviewDigest,contentDigest:r.contentDigest},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-revert.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.expiresAt,capabilityScope:`reviewActions`,action:`source.revert`,actionDigest:``,identity:i,expectedRevisions:a,payload:o};return s.actionDigest=await sv({action:s.action,identity:i,expectedRevisions:a,payload:o}),s}function lv(e){return Array.isArray(e)?`[${e.map(lv).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${lv(t)}`).join(`,`)}}`:JSON.stringify(e)}async function uv(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(lv(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function dv(e,t,n=null,r=null){if(!e.identity.taskId||!e.identity.taskRunId||!e.revision.taskRevision||!e.revision.workspaceRevision)throw Error(`source-open-task-authority-unavailable`);if(r!==null&&n===null)throw Error(`source-open-location-invalid`);let i=new Date,a={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},o={runtimeRevision:e.revision.runtimeRevision,taskRevision:e.revision.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:e.revision.workspaceRevision,indexRevision:e.revision.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:null,indexPreimage:null,patchPreimage:null},s={fileRef:t,line:n,column:r},c={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-open.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),capabilityScope:`reviewActions`,action:`source.open-in-vscode`,actionDigest:``,identity:a,expectedRevisions:o,payload:s};return c.actionDigest=await uv({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}var fv=new Set(`as.async.await.break.case.catch.class.const.continue.def.delete.do.else.enum.export.extends.finally.for.from.function.if.implements.import.in.interface.let.new.of.package.private.protected.public.return.static.struct.switch.throw.try.type.var.while.with.yield`.split(`.`)),pv=new Set([`false`,`nil`,`null`,`None`,`true`,`undefined`]),mv=new Set([`py`,`rb`,`sh`,`bash`,`zsh`,`yaml`,`yml`,`toml`]);function hv(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<0?``:t.slice(n+1).toLowerCase()}function gv(e){return/[A-Za-z_$]/.test(e)}function _v(e){return/[A-Za-z0-9_$-]/.test(e)}function vv(e){return e>=`0`&&e<=`9`}function yv(e,t,n){if(!n)return;let r=e[e.length-1];r?.kind===t?r.text+=n:e.push({kind:t,text:n})}function bv(e,t){let n=[],r=hv(t),i=0;for(;i<e.length;){if(e.startsWith(`//`,i)||e.startsWith(`/*`,i)||e[i]===`#`&&mv.has(r)){yv(n,`comment`,e.slice(i));break}let t=e[i]??``;if(t===`"`||t===`'`||t==="`"){let r=t,a=i+1;for(;a<e.length;){if(e[a]===`\\`){a+=2;continue}if(e[a]===r){a+=1;break}a+=1}let o=e.slice(i,a);yv(n,e.slice(a).match(/^\s*:/)&&r===`"`?`property`:`string`,o),i=a;continue}if(vv(t)||t===`.`&&vv(e[i+1]??``)){let t=i+1;for(;t<e.length&&/[0-9A-Fa-f_xXob.+-]/.test(e[t]??``);)t+=1;yv(n,`number`,e.slice(i,t)),i=t;continue}if(gv(t)){let t=i+1;for(;t<e.length&&_v(e[t]??``);)t+=1;let r=e.slice(i,t);yv(n,fv.has(r)?`keyword`:pv.has(r)?`literal`:`plain`,r),i=t;continue}yv(n,`plain`,t),i+=1}return n}var xv=[{view:`task`,label:`Thay đổi của task`,shortLabel:`Task`},{view:`working-tree`,label:`Toàn bộ working tree`,shortLabel:`Working Tree`},{view:`staged`,label:`Đã chuẩn bị commit`,shortLabel:`Staged`}];function Sv(e){return e===`vi`?xv:[{view:`task`,label:`Task Changes`,shortLabel:`Task`},{view:`working-tree`,label:`Full Working Tree`,shortLabel:`Working Tree`},{view:`staged`,label:`Staged Changes`,shortLabel:`Staged`}]}var Cv={"pre-existing-user":`Có sẵn trước task`,"runtime-observed-agent":`Pi runtime đã chạm`,"post-baseline-unattributed":`Thay đổi sau baseline · chưa rõ nguồn`,mixed:`Trộn thay đổi người dùng và runtime`};function wv(e,t=`vi`){return t===`vi`?Cv[e.provenance.classification]:{"pre-existing-user":`Pre-existing user change`,"runtime-observed-agent":`Runtime-observed agent touch`,"post-baseline-unattributed":`Post-baseline · unattributed`,mixed:`Mixed user and runtime change`}[e.provenance.classification]}function Tv(e,t=`vi`){return e.stats.state===`exact`?`+${e.stats.additions??0} −${e.stats.deletions??0}`:t===`vi`?`Dòng thay đổi chưa xác định`:`Line changes unavailable`}function Ev(e,t=`vi`){let n=e.page.total;return e.availability.state===`stale`?t===`vi`?`Đang đồng bộ lại…`:`Resynchronizing…`:e.availability.state===`unavailable`?e.availability.message??(t===`vi`?`Nguồn thay đổi chưa sẵn sàng`:`Source changes unavailable`):n===0?t===`vi`?`Không có file thay đổi`:`No changed files`:t===`vi`?`${n} file${e.page.truncated?` · danh sách đã rút gọn`:``}`:`${n} file${n===1?``:`s`}${e.page.truncated?` · list truncated`:``}`}function Dv(e,t=`vi`){return t===`vi`?`${e.criterionIds.length} tiêu chí · ${e.verifierAttemptIds.length} verifier`:`${e.criterionIds.length} criteria · ${e.verifierAttemptIds.length} verifiers`}function Ov(e,t){return[t.projectRef,t.runtimeInstanceId,t.sessionRef,t.taskId??`no-task`,t.taskRunId??`no-run`,e.sourceProjectionRevision??`no-source-projection-revision`,e.taskViewRevision??`no-task-view-revision`,e.workspaceRevision??`no-workspace-revision`,e.indexRevision??`no-index-revision`].join(``)}function kv(e,t,n,r){if(!e||e.view!==t||e.availability.state===`stale`||e.identity.projectRef!==r.projectRef||e.identity.runtimeInstanceId!==r.runtimeInstanceId||e.identity.sessionRef!==r.sessionRef||e.identity.taskId!==r.taskId||e.identity.taskRunId!==r.taskRunId)return!1;let i=t===`task`?n.taskViewRevision:t===`working-tree`?n.workspaceRevision:n.indexRevision;if(!(i===null?e.availability.state===`unavailable`:e.viewRevision===i))return!1;let a=e.snapshotBinding;return a?n.sourceProjectionRevision!==null&&a.sourceProjectionRevision===n.sourceProjectionRevision&&a.taskViewRevision===n.taskViewRevision&&a.workspaceRevision===n.workspaceRevision&&a.indexRevision===n.indexRevision:n.sourceProjectionRevision===null}function Av(e,t){if(!e||e.state!==`unavailable`||e.target!==null||!e.reasonCode)return!1;let n=t?.availability.state===`current`&&t.fallback.kind===`none`;return e.reasonCode===`review-target-unavailable`?n:e.reasonCode===`no-unstaged-change`||e.reasonCode===`no-staged-change`?n&&t.hunks.length>0:[`-target-stale`,`-preview-incomplete`,`-preimage-unavailable`,`-authority-unavailable`].some(t=>e.reasonCode.endsWith(t))}function jv(e,t,n,r,i,a){return t===n&&kv(e,a,r,i)?e??null:null}function Mv(e,t,n,r,i,a){let o=e?.identity;return!!(e&&o&&o.projectRef===a.identity.projectRef&&o.runtimeInstanceId===a.identity.runtimeInstanceId&&o.sessionRef===a.identity.sessionRef&&o.taskId===a.identity.taskId&&o.taskRunId===a.identity.taskRunId&&e.view===t&&e.file.fileRef===n&&e.file.fileRevision===i&&e.precondition.expectedViewRevision===r&&e.precondition.expectedFileRevision===i&&e.observed.viewRevision===r&&e.observed.fileRevision===i&&e.availability.state!==`stale`&&e.fallback.kind!==`stale`)}function Nv(e,t){return t&&e.some(e=>e.fileRef===t)?t:e[0]?.fileRef??null}var Pv={active:`Đang hoạt động`,"pause-requested":`Đang yêu cầu tạm dừng`,paused:`Đã tạm dừng`,terminal:`Đã kết thúc`,idle:`Đang chờ`,running:`Đang chạy`,stopping:`Đang dừng`,settled:`Đã ổn định`,unknown:`Chưa xác định`,pending:`Chưa xong`,completed:`Hoàn thành`,blocked:`Bị chặn`,partial:`Một phần`,failed:`Thất bại`,satisfied:`Đã đạt`,unavailable:`Không có dữ liệu`,connected:`Đã kết nối`,disconnected:`Mất kết nối`,reconnecting:`Đang kết nối lại`,"resync-required":`Cần đồng bộ lại`,none:`Không có`,waiting:`Đang chờ duyệt`,current:`Mới nhất`,stale:`Đã cũ`,"not-run":`Chưa chạy`,"in-progress":`Đang làm`,done:`Đã xong`,skipped:`Bỏ qua`,resume:`Tiếp tục`,retry:`Thử lại`,observed:`Đã ghi nhận`,requested:`Đã yêu cầu`,"possible-interruption":`Có thể bị gián đoạn`,complete:`Đầy đủ`,"aggregate-only":`Chỉ có dữ liệu tổng hợp`,off:`Tắt`,minimal:`Tối thiểu`,low:`Thấp`,medium:`Trung bình`,high:`Cao`,xhigh:`Rất cao`,max:`Tối đa`,orphaned:`Mất owner`,cancelled:`Đã hủy`,succeeded:`Thành công`,"stale-result":`Kết quả đến muộn`,accepted:`Đã nhận`,rejected:`Không nhận`,"not-recorded":`Chưa có kết quả`,parent:`Task cha`,helper:`Helper`,"read-only":`Chỉ đọc`,"workspace-write":`Ghi trong project`,"trusted-full-access":`Toàn quyền`,"single-writer":`Một writer`,retriever:`Retriever`,scout:`Scout`,planner:`Planner`,worker:`Worker`,reviewer:`Reviewer`,oracle:`Oracle`,researcher:`Researcher`,ready:`Sẵn sàng`,missing:`Chưa có bằng chứng`,interrupted:`Bị gián đoạn`,stopped:`Đã dừng`,aborted:`Đã hủy do lỗi`,incomplete:`Chưa có kết luận`,passed:`Đạt`,"not-applicable":`Không áp dụng`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"pdf-text-unavailable":`PDF này không có text bóc được; nhiều khả năng là bản scan, cần OCR trước`,"pdf-extraction-failed":`Không chuyển được PDF này sang text`,"docx-unreadable":`File .docx này hỏng, bị mã hóa, hoặc không phải file Word thật`,"document-text-empty":`Tài liệu không có chữ nào để đọc`,"document-size-limit":`Tài liệu vượt giới hạn dung lượng`,"text-size-limit":`File text vượt giới hạn dung lượng`,"text-content-invalid":`File có đuôi text nhưng nội dung không phải text`,"image-mime-mismatch":`Nội dung ảnh không khớp với đuôi file`,"model-image-input-unavailable":`Model hiện tại không nhận ảnh`,"attachment-capacity-limit":`Đã chạm giới hạn số file hoặc dung lượng đính kèm`,"no-readable-root":`Chưa có thư mục nào đọc được`,"document-roots-unavailable":`Không xác định được thư mục tài liệu`,"document-not-listed":`Tài liệu không còn trong danh sách; hãy tải lại`,"document-unavailable":`Không mở được tài liệu này`,"document-protected":`Tài liệu nằm trong protectedPaths nên không được đọc`,"document-changed":`File đã thay đổi sau khi liệt kê; chưa đọc gì cả`,"document-unreadable":`Không đọc được nội dung tài liệu`,"document-needs-ocr":`Tài liệu là bản scan, cần OCR trước khi đọc được chữ`,"document-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"session-command-effect-unknown":`Pi đã nhận yêu cầu nhưng đang đồng bộ trạng thái; không gửi lại để tránh chạy trùng`},Fv={active:`Active`,"pause-requested":`Pause requested`,paused:`Paused`,terminal:`Finished`,idle:`Idle`,running:`Running`,stopping:`Stopping`,settled:`Settled`,unknown:`Unknown`,pending:`Pending`,completed:`Completed`,blocked:`Blocked`,partial:`Partial`,failed:`Failed`,satisfied:`Satisfied`,unavailable:`Unavailable`,connected:`Connected`,disconnected:`Disconnected`,reconnecting:`Reconnecting`,"resync-required":`Resync required`,none:`None`,waiting:`Awaiting approval`,current:`Current`,stale:`Stale`,"not-run":`Not run`,"in-progress":`In progress`,done:`Done`,skipped:`Skipped`,resume:`Resume`,retry:`Retry`,observed:`Observed`,requested:`Requested`,"possible-interruption":`Possible interruption`,complete:`Complete`,"aggregate-only":`Aggregate only`,off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,orphaned:`Owner missing`,cancelled:`Cancelled`,succeeded:`Succeeded`,"stale-result":`Stale result`,accepted:`Accepted`,rejected:`Rejected`,"not-recorded":`Not recorded`,parent:`Parent task`,helper:`Helper`,"read-only":`Read only`,"workspace-write":`Workspace write`,"trusted-full-access":`Full access`,"single-writer":`Single writer`,retriever:`Retriever`,scout:`Scout`,planner:`Planner`,worker:`Worker`,reviewer:`Reviewer`,oracle:`Oracle`,researcher:`Researcher`,ready:`Ready`,missing:`Evidence missing`,interrupted:`Interrupted`,stopped:`Stopped`,aborted:`Aborted`,incomplete:`Incomplete`,passed:`Passed`,"not-applicable":`Not applicable`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"pdf-text-unavailable":`This PDF holds no extractable text; it is probably scanned and needs OCR first`,"pdf-extraction-failed":`The PDF could not be converted to text`,"docx-unreadable":`This .docx is corrupt, encrypted, or not really a Word document`,"document-text-empty":`The document contains no readable text`,"document-size-limit":`The document is over the size limit`,"text-size-limit":`The text file is over the size limit`,"text-content-invalid":`The file has a text extension but its bytes are not text`,"image-mime-mismatch":`The image content does not match its file extension`,"model-image-input-unavailable":`The current model does not accept images`,"attachment-capacity-limit":`The attachment count or size limit was reached`,"no-readable-root":`No readable directory is available`,"document-roots-unavailable":`The document directories could not be resolved`,"document-not-listed":`The document is no longer listed; reload the list`,"document-unavailable":`This document could not be opened`,"document-protected":`The document is under protectedPaths and is not readable`,"document-changed":`The file changed after it was listed; nothing was read`,"document-unreadable":`The document content could not be read`,"document-needs-ocr":`The document is scanned and needs OCR before it holds text`,"document-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"session-command-effect-unknown":`Pi received the request and is resyncing; do not resend it, to avoid a duplicate run`};function Iv(e,t=`vi`){return e?(t===`vi`?Pv:Fv)[e]??e.replaceAll(`-`,` `):t===`vi`?`Chưa có`:`Not available`}function Lv(e){return[`completed`,`satisfied`,`current`,`connected`,`done`,`passed`].includes(e??``)?`positive`:[`blocked`,`failed`,`error`,`expired`].includes(e??``)?`danger`:[`pause-requested`,`paused`,`waiting`,`stale`,`stale-result`,`orphaned`,`partial`,`reconnecting`].includes(e??``)?`warning`:[`running`,`active`,`in-progress`].includes(e??``)?`info`:`neutral`}function Rv(e){return e?e.length>22?`${e.slice(0,10)}…${e.slice(-7)}`:e:`—`}function zv(e,t=`vi`){return e.session.model.state===`known`&&e.session.model.value?e.session.model.value.displayName:t===`vi`?`Model chưa xác định`:`Unknown model`}function Bv(e,t=`vi`){return e.session.thinking.state===`known`&&e.session.thinking.value?Iv(e.session.thinking.value,t):t===`vi`?`Chưa xác định`:`Unknown`}function Vv(e,t=`vi`){let n=e.session.permissionProfile;return n.state===`known`&&n.value?Iv(n.value,t):t===`vi`?`Quyền chưa xác định`:`Unknown permission`}function Hv(e,t=`vi`){let n=e.relatedFileRefs.length,r=e.verifierAttemptRefs.length;return!n&&!r?t===`vi`?`Chưa có bằng chứng liên kết`:`No linked evidence`:t===`vi`?`${n} file · ${r} lần kiểm tra`:`${n} files · ${r} verifier runs`}function Uv(e,t=`vi`){let n=e.task;return n?{completed:n.progress.completed,total:n.progress.total,percent:Math.max(0,Math.min(100,n.progress.percent)),text:t===`vi`?`${n.progress.completed}/${n.progress.total} tiêu chí`:`${n.progress.completed}/${n.progress.total} criteria`}:{completed:0,total:0,percent:0,text:t===`vi`?`Chưa có task đang chạy`:`No active task`}}var Wv=(0,v.createContext)(null);function Gv({value:e,children:t}){return(0,U.jsx)(Wv.Provider,{value:e,children:t})}function Kv(){let e=(0,v.useContext)(Wv);if(!e)throw Error(`Piagent UI preferences are missing`);return e}function Q(e,t,n){return e===`vi`?t:n}function qv(e){let t=e?.target;return t?[t.view,t.fileRef,t.diffRef,t.taskRevision,t.workspaceRevision,t.indexRevision??``,t.viewRevision,t.fileRevision,t.patchPreimage,t.contentDigest].join(``):`no-target`}function Jv(e){return e?[qv(e),e.state,e.recordedState??``,e.recordedAt??``,e.evidenceRef??``].join(``):`no-review-state`}function Yv(e,t){return e.identity.projectRef===t.identity.projectRef&&e.identity.runtimeInstanceId===t.identity.runtimeInstanceId&&e.identity.sessionRef===t.identity.sessionRef&&e.identity.taskId===t.identity.taskId&&e.identity.taskRunId===t.identity.taskRunId&&e.identity.agentOperationId===t.identity.agentOperationId&&e.identity.toolCallId===t.identity.toolCallId}function Xv(e,t,n,r){return t.phase===`settled`&&t.resultCode===n&&t.action===`review.mark`&&t.commandId===e.commandId&&t.actionDigest===e.actionDigest&&t.idempotencyKeyDigest===r&&Yv(e,t)&&typeof t.settledAt==`string`&&typeof t.settlementEvidenceRef==`string`}function Zv(e,t){return!!(e&&e.projectRef===t.projectRef&&e.runtimeInstanceId===t.runtimeInstanceId&&e.sessionRef===t.sessionRef&&e.taskId===t.taskId&&e.taskRunId===t.taskRunId)}function Qv(e,t,n,r,i,a){return e.view===t&&e.fileRef===n&&e.taskRevision===a.revision.taskRevision&&e.workspaceRevision===a.sourceChanges.workingTree.revision&&e.indexRevision===a.sourceChanges.staged.revision&&e.viewRevision===r&&e.fileRevision===i}function $v(e,t,n,r,i,a,o){return!e||!Zv(e.identity,a.identity)?!1:e.target?Qv(e.target,t,n,r,i,a):e.state===`unavailable`&&!Av(e,o)}async function ey(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function ty({state:e,busy:t,status:n,deterministicEnabled:r,modelEnabled:i,locale:a,onGenerate:o,onCopy:s,onModel:c}){let l=e.value?.state===`ready`?e.value.summary:null;return(0,U.jsxs)(`section`,{className:`commit-summary-panel`,"aria-labelledby":`commit-summary-title`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Commit summary`}),(0,U.jsx)(`h3`,{id:`commit-summary-title`,children:Q(a,`Tóm tắt phần đã stage`,`Staged changes summary`)}),(0,U.jsx)(`span`,{children:Q(a,`Bản deterministic dùng 0 model token. Không commit hoặc push.`,`The deterministic version uses 0 model tokens. It does not commit or push.`)})]}),l?(0,U.jsxs)(`div`,{className:`commit-summary-output`,children:[(0,U.jsx)(`strong`,{children:l.title}),l.bodyLines.map((e,t)=>(0,U.jsx)(`code`,{children:e},`${l.summaryRef}.${t}`)),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`button`,{type:`button`,onClick:s,children:`Copy`}),(0,U.jsx)(`button`,{type:`button`,disabled:!i||t,onClick:c,children:Q(a,`Nhờ Pi viết lại · tốn model token`,`Ask Pi to rewrite · uses model tokens`)})]})]}):(0,U.jsx)(`button`,{type:`button`,disabled:!r||t,onClick:o,children:t?Q(a,`Đang tạo…`,`Generating…`):Q(a,`Tạo summary · 0 token`,`Generate summary · 0 tokens`)}),n&&(0,U.jsx)(`p`,{className:`commit-summary-status`,role:`status`,children:n})]})}function ny({file:e,selected:t,onSelect:n,locale:r}){let i=e.path.lastIndexOf(`/`),a=i<0?e.path:e.path.slice(i+1);return(0,U.jsxs)(cf,{component:`button`,className:`file-row`,selected:t,"data-selected":t,onClick:n,type:`button`,"aria-label":`${e.status} ${e.path} ${Tv(e,r)}`,"aria-pressed":t,children:[(0,U.jsx)(`span`,{className:`file-status status-${e.status}`,children:e.status}),(0,U.jsxs)(`span`,{className:`file-name`,children:[(0,U.jsx)(`strong`,{children:a}),e.oldPath&&(0,U.jsxs)(`small`,{children:[Q(r,`từ`,`from`),` `,e.oldPath]})]}),(0,U.jsx)(`span`,{className:`file-provenance`,children:wv(e,r)}),(0,U.jsx)(`span`,{className:`file-evidence`,children:Dv(e,r)}),(0,U.jsx)(`span`,{className:`file-stats`,children:Tv(e,r)})]})}function ry({text:e,path:t}){return(0,U.jsx)(U.Fragment,{children:bv(e,t).map((e,t)=>(0,U.jsx)(`span`,{className:`syntax-${e.kind}`,children:e.text},`${t}.${e.kind}`))})}function iy({line:e,side:t,path:n}){let r=e.oldLineNumber??``,i=e.newLineNumber??``;if(t===`inline`)return(0,U.jsxs)(`div`,{className:`diff-line diff-${e.kind}`,children:[(0,U.jsx)(`span`,{children:r}),(0,U.jsx)(`span`,{children:i}),(0,U.jsx)(`b`,{children:e.marker}),(0,U.jsx)(`code`,{children:(0,U.jsx)(ry,{text:e.text,path:n})})]});let a=e.kind===`added`?``:e.text,o=e.kind===`deleted`?``:e.text;return(0,U.jsxs)(`div`,{className:`split-line diff-${e.kind}`,children:[(0,U.jsx)(`span`,{children:r}),(0,U.jsx)(`code`,{children:(0,U.jsx)(ry,{text:a,path:n})}),(0,U.jsx)(`span`,{children:i}),(0,U.jsx)(`code`,{children:(0,U.jsx)(ry,{text:o,path:n})})]})}function ay({state:e,review:t,mutation:n,revert:r,reviewEnabled:i,reviewBusy:a,reviewError:o,mutationEnabled:s,mutationBusy:c,mutationError:l,revertEnabled:u,revertBusy:d,openEnabled:f,openBusy:p,openStatus:m,detailError:h,mode:g,onMode:_,onReview:v,onMutation:y,onRevert:b,onOpen:x,onRetry:S,locale:C}){if(e.state===`idle`)return(0,U.jsx)(`div`,{className:`diff-empty`,children:(0,U.jsx)(`p`,{children:Q(C,`Chọn một file để xem diff và bằng chứng liên quan.`,`Select a file to inspect its diff and related evidence.`)})});if(e.state===`loading`)return(0,U.jsx)(`div`,{className:`diff-empty`,children:(0,U.jsx)(`p`,{children:Q(C,`Đang dựng diff từ Git và task baseline…`,`Building the diff from Git and the task baseline…`)})});if(e.state===`error`||!e.value)return(0,U.jsxs)(`div`,{className:`diff-empty error-state`,children:[(0,U.jsx)(`p`,{children:Q(C,`Diff chưa thể đồng bộ với revision hiện tại.`,`The diff could not be reconciled with the current revision.`)}),S&&(0,U.jsx)(`button`,{type:`button`,onClick:S,children:Q(C,`Thử đồng bộ lại`,`Retry reconciliation`)})]});let w=e.value;return(0,U.jsxs)(J,{className:`diff-viewer`,sx:{minWidth:0,bgcolor:`background.paper`},children:[(0,U.jsxs)(J,{component:`header`,className:`diff-toolbar`,sx:{position:`sticky`,top:0,zIndex:2,bgcolor:`background.paper`},children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:w.file.path}),(0,U.jsx)(lu,{size:`small`,variant:`outlined`,className:`access-badge tone-${Lv(w.availability.state)}`,label:Iv(w.availability.state,C)})]}),(0,U.jsxs)(`div`,{className:`diff-actions`,children:[t.state===`ready`&&t.value&&(0,U.jsxs)(`div`,{className:`review-state review-${t.value.state}`,children:[(0,U.jsx)(`span`,{children:t.value.state===`reviewed`?Q(C,`Đã review`,`Reviewed`):t.value.state===`stale`?Q(C,`Review đã cũ`,`Review stale`):t.value.state===`unavailable`?Q(C,`Không thể review`,`Review unavailable`):Q(C,`Chưa review`,`Not reviewed`)}),t.value.target&&t.value.state!==`unavailable`&&(0,U.jsx)(`button`,{type:`button`,disabled:!i||a,onClick:()=>v(t.value.state===`reviewed`?`unreviewed`:`reviewed`),children:a?Q(C,`Đang ghi…`,`Saving…`):t.value.state===`reviewed`?Q(C,`Bỏ dấu review`,`Mark unreviewed`):t.value.state===`stale`?Q(C,`Review lại`,`Review again`):Q(C,`Đánh dấu đã review`,`Mark reviewed`)})]}),n.state===`ready`&&n.value?.state===`ready`&&n.value.target&&(0,U.jsxs)(`div`,{className:`source-mutation-preview`,children:[(0,U.jsx)(`span`,{children:n.value.action===`source.stage`?Q(C,`Chuẩn bị đúng thay đổi file này để commit`,`Prepare this exact file change for commit`):Q(C,`Bỏ khỏi vùng commit; giữ nguyên file đang làm việc`,`Remove from commit while keeping the working file`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>y([]),children:c?Q(C,`Đang cập nhật Git…`,`Updating Git…`):n.value.action===`source.stage`?`Stage file`:`Unstage file`})]}),r.state===`ready`&&r.value?.state===`ready`&&r.value.target&&(0,U.jsxs)(`div`,{className:`source-revert-preview`,children:[(0,U.jsx)(`span`,{children:Q(C,`Hoàn tác phần chưa stage; giữ nguyên index`,`Revert unstaged changes while preserving the index`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!u||d,onClick:()=>b(null),children:d?Q(C,`Đang dựng preview…`,`Building preview…`):`Revert file`})]}),f&&(0,U.jsx)(`div`,{className:`source-open-action`,children:(0,U.jsx)(`button`,{type:`button`,disabled:p,onClick:x,children:p?Q(C,`Đang mở…`,`Opening…`):Q(C,`Mở trong VS Code`,`Open in VS Code`)})}),(0,U.jsxs)(op,{className:`mode-switch`,exclusive:!0,size:`small`,value:g,"aria-label":Q(C,`Kiểu hiển thị diff`,`Diff layout`),onChange:(e,t)=>t&&_(t),children:[(0,U.jsx)(ep,{value:`inline`,"aria-label":`Inline`,children:`Inline`}),(0,U.jsx)(ep,{value:`split`,"aria-label":Q(C,`Hai cột`,`Side by side`),children:Q(C,`Hai cột`,`Side by side`)})]})]})]}),o&&(0,U.jsx)(`div`,{className:`review-error`,role:`status`,children:o}),l&&(0,U.jsx)(`div`,{className:`review-error`,role:`status`,children:l}),m&&(0,U.jsx)(`div`,{className:`source-open-status`,role:`status`,children:m}),h&&(0,U.jsxs)(`div`,{className:`detail-reconciliation-warning`,role:`status`,children:[(0,U.jsx)(`span`,{children:Q(C,`Một thao tác source chưa đồng bộ; diff hiện tại vẫn chính xác.`,`A source action is not reconciled yet; the current diff remains exact.`)}),S&&(0,U.jsx)(`button`,{type:`button`,onClick:S,children:Q(C,`Thử đồng bộ lại`,`Retry reconciliation`)})]}),(0,U.jsxs)(`div`,{className:`diff-context`,children:[(0,U.jsx)(`span`,{children:wv(w.file,C)}),(0,U.jsx)(`span`,{children:Dv(w.file,C)}),(0,U.jsxs)(`span`,{className:`additions`,children:[`+`,w.file.stats.additions??`?`]}),(0,U.jsxs)(`span`,{className:`deletions`,children:[`−`,w.file.stats.deletions??`?`]})]}),w.fallback.kind!==`none`&&(0,U.jsxs)(`div`,{className:`diff-fallback`,children:[(0,U.jsx)(`strong`,{children:Iv(w.fallback.kind,C)}),(0,U.jsx)(`span`,{children:w.fallback.message??w.fallback.reasonCode??Q(C,`Nội dung diff không sẵn sàng`,`Diff content unavailable`)})]}),w.hunks.map((e,t)=>(0,U.jsxs)(`section`,{className:`diff-hunk`,"aria-label":`${Q(C,`Vùng thay đổi`,`Change region`)} ${t+1}`,children:[(0,U.jsxs)(`div`,{className:`hunk-header`,children:[(0,U.jsx)(`span`,{children:e.header}),(0,U.jsxs)(`span`,{className:`hunk-actions`,children:[n.value?.state===`ready`&&n.value.target?.hunkRefs.includes(e.hunkRef)&&(0,U.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>y([e.hunkRef]),children:n.value.action===`source.stage`?`Stage hunk`:`Unstage hunk`}),r.value?.state===`ready`&&r.value.target&&r.value.preview?.hunks.some(t=>t.hunkRef===e.hunkRef)&&(0,U.jsx)(`button`,{className:`revert-action`,type:`button`,disabled:!u||d,onClick:()=>b(e.hunkRef),children:`Revert hunk`})]})]}),(0,U.jsx)(`div`,{className:g===`split`?`split-code`:`inline-code`,children:e.lines.map(e=>(0,U.jsx)(iy,{line:e,side:g,path:w.file.path},e.lineRef))}),w.unchangedRegions[t]&&(0,U.jsxs)(`div`,{className:`unchanged-region`,children:[`… `,w.unchangedRegions[t].lineCount,` `,Q(C,`dòng không đổi đã thu gọn`,`unchanged lines collapsed`),` …`]})]},e.hunkRef)),w.truncation.truncated&&(0,U.jsxs)(`div`,{className:`diff-fallback`,children:[(0,U.jsx)(`strong`,{children:Q(C,`Diff đã rút gọn`,`Diff truncated`)}),(0,U.jsxs)(`span`,{children:[Q(C,`Còn`,`Another`),` `,w.truncation.omittedLines,` `,Q(C,`dòng chưa hiển thị.`,`lines are not shown.`)]})]})]})}function oy({snapshot:e,refreshSnapshot:t,sessionRef:n}){let{locale:r}=Kv(),i=!!(e.task&&e.sourceChanges.task?.state!==`unavailable`&&e.sourceChanges.task?.revision),a=(0,v.useMemo)(()=>Sv(r),[r]),[o,s]=(0,v.useState)(()=>i?`task`:`working-tree`),[c,l]=(0,v.useState)({}),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)({state:`idle`}),[m,h]=(0,v.useState)({state:`idle`}),[g,_]=(0,v.useState)({state:`idle`}),[y,b]=(0,v.useState)({state:`idle`}),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)(null),[z,B]=(0,v.useState)({state:`idle`}),[V,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(null),[ae,oe]=(0,v.useState)(!1),[se,H]=(0,v.useState)(0),[ce,le]=(0,v.useState)(`inline`),ue={sourceProjectionRevision:e.sourceChanges.projectionRevision??null,taskViewRevision:e.sourceChanges.task.revision,workspaceRevision:e.sourceChanges.workingTree.revision,indexRevision:e.sourceChanges.staged.revision},de=Ov(ue,e.identity),fe=[de,se].join(``),pe=[de,e.revision.taskRevision??`no-task-revision`].join(``),me=[n??`default-session`,o,e.identity.projectRef,e.identity.runtimeInstanceId,e.identity.sessionRef,e.identity.taskId??`no-task`,e.identity.taskRunId??`no-run`].join(``),he=(0,v.useRef)(me);he.current=me;let ge=(0,v.useRef)(0),_e=(0,v.useRef)(me);_e.current!==me&&(_e.current=me,ge.current+=1);let ve=ge.current,ye=(0,v.useRef)(null),be=c[o],xe=be?.state===`ready`?jv(be.value,be.revisionKey,fe,ue,e.identity,o):null,Se=be?.state===`ready`&&!xe?{state:`loading`}:be,Ce=xe?.files??[],we=Nv(Ce,u),Te=we?Ce.find(e=>e.fileRef===we)??null:null,Ee=!!(xe&&Te),De=e.capabilities.capabilities.reviewActions,Oe=JSON.stringify(De),ke=o===`working-tree`?`source.stage`:o===`staged`?`source.unstage`:null,Ae=De.status===`available`&&De.actions.reviewMark.available,je=ke===`source.stage`?De.status===`available`&&De.actions.stage.available:ke===`source.unstage`&&De.status===`available`&&De.actions.unstage.available,Me=o===`working-tree`&&De.status===`available`&&De.actions.revert.available,Ne=Ee?[n??`default-session`,o,we,xe.viewRevision,Te.fileRevision,pe,se,Oe].join(``):`no-detail-request`,Pe=!!(Ee&&f.requestKey===Ne&&f.state===`ready`&&Mv(f.value,o,we,xe.viewRevision,Te.fileRevision,e)),Fe=!!(Ee&&m.requestKey===Ne&&m.state===`ready`&&$v(m.value,o,we,xe.viewRevision,Te.fileRevision,e,Pe?f.value:void 0)),Ie=!!(Ee&&g.requestKey===Ne&&g.state===`ready`&&$v(g.value,o,we,xe.viewRevision,Te.fileRevision,e,Pe?f.value:void 0)),Le=!!(Ee&&y.requestKey===Ne&&y.state===`ready`&&$v(y.value,o,we,xe.viewRevision,Te.fileRevision,e,Pe?f.value:void 0)),Re=!!(Ee&&f.requestKey===Ne&&f.state===`ready`&&!Pe),ze=!!(Ee&&m.requestKey===Ne&&m.state===`ready`&&!Fe),Be=!!(Ee&&g.requestKey===Ne&&g.state===`ready`&&!Ie),Ve=!!(Ee&&y.requestKey===Ne&&y.state===`ready`&&!Le),He=!!(Ee&&f.requestKey===Ne&&f.state===`error`),Ue=!!(Ee&&Ae&&m.requestKey===Ne&&m.state===`error`),We=!!(Ee&&je&&g.requestKey===Ne&&g.state===`error`),Ge=!!(Ee&&Me&&y.requestKey===Ne&&y.state===`error`),Ke=Re||ze||Be||Ve||He||Ue||We||Ge,qe=!!(Ee&&Pe&&(!Ae||Fe)&&(!je||Ie)&&(!Me||Le)),Je=(0,v.useRef)(null);we&&(Je.current={sourceScope:me,fileRef:we});let Ye=[me,we??(Je.current?.sourceScope===me?Je.current.fileRef:`no-file`)].join(``),Xe=(0,v.useRef)(Ye);Xe.current=Ye;let Ze=(0,v.useRef)(new Set),Qe=(0,v.useRef)(0),$e=(0,v.useRef)(Ye);$e.current!==Ye&&($e.current=Ye,Qe.current+=1);let et=Qe.current,[tt,nt]=(0,v.useState)(null),rt=!!(Ke&&t&&(!Ze.current.has(Ye)||tt?.scope===Ye&&tt.generation===et&&tt.requestKey===Ne)),it=Ee?f.requestKey===Ne?(Re||He)&&rt?{state:`loading`}:Re||He?{state:`error`}:f:{state:`loading`}:{state:`idle`},at=Ee&&Ae?m.requestKey===Ne?rt?{state:`loading`}:ze||Ue?{state:`error`}:m:{state:`loading`}:{state:`idle`},ot=Ee&&je?g.requestKey===Ne?rt?{state:`loading`}:Be||We?{state:`error`}:g:{state:`loading`}:{state:`idle`},st=Ee&&Me?y.requestKey===Ne?rt?{state:`loading`}:Ve||Ge?{state:`error`}:y:{state:`loading`}:{state:`idle`},ct=Ee?[n??`default-session`,o,we,xe.viewRevision,Te.fileRevision,pe].join(``):`no-source-authority`,lt=(0,v.useRef)(ct);lt.current=ct;let ut=[ct,e.revision.runtimeRevision,e.revision.controlRevision??`no-control-revision`,e.revision.approvalRevision??`no-approval-revision`,e.revision.sessionOptionRevision??`no-session-option-revision`,e.revision.queueRevision??`no-queue-revision`].join(``),dt=(0,v.useRef)(ut);dt.current=ut;let ft=[n??`default-session`,e.identity.projectRef,e.identity.runtimeInstanceId,e.identity.sessionRef,e.identity.taskId??`no-task`,e.identity.taskRunId??`no-run`,e.revision.taskRevision??`no-task-revision`,e.sourceChanges.staged.revision??`no-index-revision`].join(``),pt=(0,v.useRef)(ft);pt.current=ft;let mt=(0,v.useRef)(``),ht=(0,v.useRef)(``);mt.current=[ct,qv(at.value)].join(``),ht.current=Jv(at.value),(0,v.useEffect)(()=>{B({state:`idle`}),ie(null),oe(!1)},[ft]),(0,v.useEffect)(()=>{!i&&o===`task`&&(s(`working-tree`),d(null))},[i,o]),(0,v.useEffect)(()=>{ye.current=null,te(null)},[me,ve]),(0,v.useEffect)(()=>{qe&&(Ze.current.delete(Ye),nt(e=>e?.scope===Ye?null:e))},[qe,Ye]),(0,v.useEffect)(()=>{let r=new AbortController,i=fe;return l(e=>({...e,[o]:{state:`loading`,revisionKey:i}})),(n?Yg(n,o,r.signal):s_(o,r.signal)).then(n=>{if(!n){r.signal.aborted||l(e=>({...e,[o]:{state:`error`,revisionKey:i}}));return}if(!kv(n,o,ue,e.identity)){if(r.signal.aborted)return;if(!t||ye.current===me){l(e=>({...e,[o]:{state:`error`,revisionKey:i}}));return}ye.current=me,l(e=>({...e,[o]:{state:`loading`,revisionKey:i}})),t().then(e=>{if(!r.signal.aborted){if(!e){l(e=>({...e,[o]:{state:`error`,revisionKey:i}}));return}H(e=>e+1)}}).catch(()=>{r.signal.aborted||l(e=>({...e,[o]:{state:`error`,revisionKey:i}}))});return}ye.current=null,r.signal.aborted||l(e=>({...e,[o]:{state:`ready`,value:n,revisionKey:i}}))}).catch(()=>{r.signal.aborted||l(e=>({...e,[o]:{state:`error`,revisionKey:i}}))}),()=>r.abort()},[o,fe,n]);let gt=(0,v.useCallback)(()=>{let e=me,n=ve,r=de;ye.current=null,l(e=>({...e,[o]:{state:`loading`,revisionKey:fe}})),(async()=>{let i;try{i=await t?.()}catch{}if(he.current!==e||ge.current!==n)return;ye.current=e;let a=i?Ov({sourceProjectionRevision:i.sourceChanges.projectionRevision??null,taskViewRevision:i.sourceChanges.task.revision,workspaceRevision:i.sourceChanges.workingTree.revision,indexRevision:i.sourceChanges.staged.revision},i.identity):r;(!i||a===r)&&H(e=>e+1)})()},[t,de,ve,me,fe,o]);(0,v.useEffect)(()=>{if(!we){p({state:`idle`}),h({state:`idle`}),_({state:`idle`}),b({state:`idle`}),E(null),A(null),P(null),S(null),R(null);return}let e=new AbortController,t=Ne;return p({state:`loading`,requestKey:t}),E(null),A(null),P(null),S(null),R(null),h(Ae?{state:`loading`,requestKey:t}:{state:`idle`}),_(je?{state:`loading`,requestKey:t}:{state:`idle`}),b(Me?{state:`loading`,requestKey:t}:{state:`idle`}),(n?Xg(n,o,we,e.signal):c_(o,we,e.signal)).then(n=>{e.signal.aborted||p({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||p({state:`error`,requestKey:t})}),Ae&&(n?Zg(n,o,we,e.signal):l_(o,we,e.signal)).then(n=>{e.signal.aborted||h({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||h({state:`error`,requestKey:t})}),je&&ke&&(n?Qg(n,ke,we,e.signal):u_(ke,we,e.signal)).then(n=>{e.signal.aborted||_({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||_({state:`error`,requestKey:t})}),Me&&(n?$g(n,we,null,e.signal):d_(we,null,e.signal)).then(n=>{e.signal.aborted||b({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||b({state:`error`,requestKey:t})}),()=>e.abort()},[we,o,pe,se,n,Oe,Ne]);let _t=(0,v.useCallback)(e=>{if(!Ee||!t)return;let n=Ye,r=et,i=Ne;!e&&Ze.current.has(n)||(Ze.current.add(n),nt({scope:n,generation:r,requestKey:i}),t().then(e=>{e&&Xe.current===n&&Qe.current===r&&H(e=>e+1)}).catch(()=>void 0).finally(()=>{nt(e=>e?.scope===n&&e.generation===r&&e.requestKey===i?null:e)}))},[Ee,et,Ye,Ne,t]);(0,v.useEffect)(()=>{!Ee||!Ke||!t||Ze.current.has(Ye)||_t(!1)},[_t,Ee,Ke,Ye,t]);let vt=Ce,yt=(0,v.useMemo)(()=>{let e=new Map;for(let t of vt){let n=t.path.lastIndexOf(`/`),i=n<0?Q(r,`Gốc project`,`Project root`):t.path.slice(0,n);e.set(i,[...e.get(i)??[],t])}return[...e.entries()]},[vt,r]),bt=(0,v.useMemo)(()=>{let t={task:e.sourceChanges.task.counts.files,"working-tree":e.sourceChanges.workingTree.counts.files,staged:e.sourceChanges.staged.counts.files},n=n=>{let r=c[n];return(r?.state===`ready`?jv(r.value,r.revisionKey,fe,ue,e.identity,n):null)?.page.total??t[n]};return{task:n(`task`),"working-tree":n(`working-tree`),staged:n(`staged`)}},[c,fe,e.sourceChanges.task.counts.files,e.sourceChanges.workingTree.counts.files,e.sourceChanges.staged.counts.files]),xt=e=>{te(null),s(e),d(null)},St=De.status===`available`&&De.actions.reviewMark.available,Ct=ot.value?.action===`source.stage`?De.status===`available`&&De.actions.stage.available:ot.value?.action===`source.unstage`&&De.status===`available`&&De.actions.unstage.available,wt=De.status===`available`&&De.actions.revert.available,Tt=o===`working-tree`&&De.status===`available`&&De.actions.openInVsCode.available&&it.state===`ready`&&it.value?.availability.state===`current`&&it.value.fallback.kind===`none`,Et=o===`staged`&&vt.length>0,Dt=Et&&De.status===`available`&&De.actions.generateCommitSummaryDeterministic.available,Ot=Et&&De.status===`available`&&De.actions.generateCommitSummaryModel.available,kt=t=>!t||t.identity.projectRef!==e.identity.projectRef||t.identity.runtimeInstanceId!==e.identity.runtimeInstanceId||t.identity.sessionRef!==e.identity.sessionRef||t.identity.taskId!==e.identity.taskId||t.identity.taskRunId!==e.identity.taskRunId?!1:t.summary?t.summary.taskRevision===e.revision.taskRevision&&t.summary.indexRevision===e.sourceChanges.staged.revision:t.state===`unavailable`,At=async t=>{if(!we||!at.value||C)return;let i=at.value,a=Jv(i),s=mt.current,c=dt.current,l=me,u=ve,d=Ye,f=et,p=de,m=!1;w(!0),E(null),te(null);try{let g=await nv(e,i,t);if(mt.current!==s||ht.current!==a||dt.current!==c)return;let _=await ey(g.idempotencyKey);if(mt.current!==s||ht.current!==a||dt.current!==c)return;m=!0;let v=await k_(g);if(!Xv(g,v,t,_)){if(v.phase!==`rejected`){await jt(l,u,d,f,p,Q(r,`Chưa xác nhận được receipt review. Piagent đã đọc lại trạng thái chính thức và sẽ không tự gửi lại lệnh.`,`The review receipt is unconfirmed. Piagent reloaded canonical state and will not resend the command.`));return}mt.current===s&&ht.current===a&&E(v.error?.message??Q(r,`Không xác nhận được trạng thái review chính xác; hãy tải lại diff.`,`The exact review state could not be confirmed; reload the diff.`));return}if(mt.current!==s||ht.current!==a)return;h(e=>mt.current===s&&Jv(e.value)===a?{state:`ready`,requestKey:e.requestKey,value:{...i,generatedAt:v.settledAt,state:v.resultCode,recordedState:v.resultCode,recordedAt:v.settledAt,evidenceRef:v.settlementEvidenceRef,reasonCode:null,health:{state:`ok`,reasonCode:null,message:null}}}:e),(n?Zg(n,o,we):l_(o,we)).then(e=>h(t=>mt.current===s&&t.state===`ready`&&t.value?.evidenceRef===v.settlementEvidenceRef?{state:`ready`,value:e,requestKey:t.requestKey}:t)).catch(()=>void 0)}catch{m?await jt(l,u,d,f,p,Q(r,`Mất kết nối khi đang ghi review. Piagent đã đọc lại trạng thái chính thức và sẽ không tự gửi lại lệnh.`,`The connection was lost while saving review. Piagent reloaded canonical state and will not resend the command.`)):mt.current===s&&ht.current===a&&E(Q(r,`Không thể ghi trạng thái review. Nội dung source không bị thay đổi.`,`Unable to save review state. Source content was not changed.`))}finally{w(!1)}},jt=async(e,n,r,i,a,o)=>{Xe.current===r&&Qe.current===i&&(p({state:`idle`}),h({state:`idle`}),_({state:`idle`}),b({state:`idle`}),S(null),E(null),A(null),P(null),R(null),te(null));let s;try{s=await t?.()}catch{}if(he.current!==e||ge.current!==n)return;let c=s?Ov({sourceProjectionRevision:s.sourceChanges.projectionRevision??null,taskViewRevision:s.sourceChanges.task.revision,workspaceRevision:s.sourceChanges.workingTree.revision,indexRevision:s.sourceChanges.staged.revision},s.identity):a;(!s||c===a)&&H(e=>e+1),te({scope:e,generation:n,message:o})},Mt=async(n=[])=>{if(!we||!xe||!ot.value||ot.value.state!==`ready`||D)return;let i=lt.current,a=dt.current,o=ot.value,s=me,c=ve,l=Ye,u=et,f=de,p=!1;O(!0),A(null),te(null);try{let m=await av(e,o,n);if(lt.current!==i||dt.current!==a)return;p=!0;let h=await A_(m);if(h.phase===`uncertain`){await jt(s,c,l,u,f,Q(r,`Chưa xác nhận được trạng thái Git. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`Git state is unconfirmed. Piagent refreshed Source Changes and will not resend the command.`));return}if(h.phase!==`settled`||![`staged`,`unstaged`].includes(h.resultCode)){lt.current===i&&A(h.error?.message??Q(r,`File hoặc Git index đã thay đổi; hãy tải lại preview.`,`The file or Git index changed; reload the preview.`));return}lt.current===i&&d(null),await t?.(),H(e=>e+1)}catch{p?await jt(s,c,l,u,f,Q(r,`Mất kết nối khi đang cập nhật Git. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`The connection was lost while updating Git. Piagent refreshed Source Changes and will not resend the command.`)):lt.current===i&&A(Q(r,`Không thể chuẩn bị lệnh cập nhật Git; source chưa bị thay đổi.`,`Unable to prepare the Git update; source was not changed.`))}finally{O(!1)}},Nt=async e=>{if(!we||!xe||!wt||j)return;let t=lt.current,i=we;M(!0),P(null),te(null);try{let a=n?await $g(n,i,e):await d_(i,e);if(lt.current!==t)return;if(a.state!==`ready`||!a.target){P(Q(r,`Không thể hoàn tác an toàn: provenance hoặc diff hiện tại không còn đủ bằng chứng.`,`Safe revert is unavailable because provenance or the current diff lacks evidence.`));return}S(a)}catch{lt.current===t&&P(Q(r,`Không thể dựng preview hoàn tác. Source chưa bị thay đổi.`,`Unable to build a revert preview. Source was not changed.`))}finally{M(!1)}},Pt=async()=>{if(!x?.target||!we||!xe||!Te||j||!Qv(x.target,o,we,xe.viewRevision,Te.fileRevision,e))return;let n=lt.current,i=dt.current,a=x,s=me,c=ve,l=Ye,u=et,f=de,p=!1;M(!0),P(null),te(null);try{let o=await cv(e,a);if(lt.current!==n||dt.current!==i)return;p=!0;let m=await j_(o);if(m.phase===`uncertain`){await jt(s,c,l,u,f,Q(r,`Chưa xác nhận được kết quả revert. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`The revert result is unconfirmed. Piagent refreshed Source Changes and will not resend the command.`));return}if(m.phase!==`settled`||m.resultCode!==`reverted`){lt.current===n&&P(m.error?.message??Q(r,`Preview đã cũ; hãy mở lại trước khi xác nhận.`,`The preview is stale; reopen it before confirming.`));return}lt.current===n&&(S(null),d(null)),await t?.(),H(e=>e+1)}catch{p?await jt(s,c,l,u,f,Q(r,`Mất kết nối khi đang revert. Piagent đã tải lại Source Changes và sẽ không tự gửi lại lệnh.`,`The connection was lost during revert. Piagent refreshed Source Changes and will not resend the command.`)):lt.current===n&&P(Q(r,`Không thể chuẩn bị lệnh revert; source chưa bị thay đổi.`,`Unable to prepare the revert command; source was not changed.`))}finally{M(!1)}},Ft=async()=>{if(!we||!Tt||F)return;let t=lt.current,n=dt.current,i=we;I(!0),R(null);try{let a=await dv(e,i);if(lt.current!==t||dt.current!==n)return;let o=await M_(a);if(lt.current!==t)return;o.phase===`settled`&&o.resultCode===`opened`?R(Q(r,`VS Code đã nhận yêu cầu mở file.`,`VS Code received the open-file request.`)):R(o.phase===`uncertain`?Q(r,`Không xác nhận được VS Code đã nhận file. Piagent sẽ không tự mở lại.`,`It is unknown whether VS Code received the file. Piagent will not retry automatically.`):o.error?.message??Q(r,`File hoặc phiên làm việc đã thay đổi; hãy tải lại trước khi mở.`,`The file or session changed; refresh before opening.`))}catch{lt.current===t&&R(Q(r,`Không thể mở file trong VS Code. Diff hiện tại vẫn được giữ nguyên.`,`Unable to open the file in VS Code. The current diff remains available.`))}finally{I(!1)}},It=async()=>{if(!Dt||V)return;let e=pt.current;ne(!0),ie(null),B({state:`loading`});try{let t=n?await e_(n):await f_();if(pt.current!==e)return;if(!kt(t)){B({state:`error`}),ie(Q(r,`Staged Changes đã đổi trong lúc dựng summary; hãy tạo lại.`,`Staged Changes changed while the summary was generated; generate it again.`));return}B({state:`ready`,value:t}),t.state!==`ready`&&ie(Q(r,`Staged Changes đã thay đổi hoặc chưa có dữ liệu để tóm tắt.`,`Staged Changes changed or has no data to summarize.`))}catch{pt.current===e&&(B({state:`error`}),ie(Q(r,`Không thể dựng commit summary từ index hiện tại.`,`Unable to generate a commit summary from the current index.`)))}finally{ne(!1)}},Lt=async()=>{let e=z.value?.summary;if(!e||!kt(z.value))return;let t=pt.current;try{await navigator.clipboard.writeText([e.title,``,...e.bodyLines].join(`
|
|
172
|
+
`)),pt.current===t&&ie(Q(r,`Đã copy summary. Chưa có commit nào được tạo.`,`Summary copied. No commit was created.`))}catch{pt.current===t&&ie(Q(r,`Trình duyệt không cho phép copy tự động.`,`The browser did not allow automatic copying.`))}},Rt=async()=>{let t=z.value?.summary;if(!t||!kt(z.value)||!Ot||V)return;let n=pt.current;ne(!0),ie(null);try{let i=await K_(e,t.modelPrompt,`new-operation`);if(pt.current!==n||!kt(z.value))return;let a=await T_(i);if(pt.current!==n)return;a.phase===`settled`&&a.resultCode===`dispatch-observed`?ie(Q(r,`Đã gửi yêu cầu sang Chat. Pi sẽ trả commit summary ở hội thoại; chưa commit hoặc push.`,`Request sent to Chat. Pi will return the commit summary in the conversation; nothing was committed or pushed.`)):ie(a.phase===`uncertain`?Q(r,`Không xác nhận được yêu cầu đã tới Pi; hệ thống sẽ không tự gửi lại.`,`It is unknown whether the request reached Pi; it will not be resent automatically.`):a.error?.message??Q(r,`Không thể bắt đầu model work từ session hiện tại.`,`Unable to start model work from the current session.`))}catch{pt.current===n&&ie(Q(r,`Không thể gửi yêu cầu sang Pi session hiện tại.`,`Unable to send the request to the current Pi session.`))}finally{ne(!1),oe(!1)}},zt=ee?.scope===me&&ee.generation===ve?ee.message:null;return(0,U.jsxs)(Pc,{component:`section`,variant:`outlined`,className:`source-workspace`,"aria-labelledby":`source-title`,sx:{overflow:`hidden`,minHeight:`calc(100vh - 120px)`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(J,{component:`header`,className:`source-heading`,sx:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,px:{xs:2,sm:2.5},py:1.75,borderBottom:1,borderColor:`divider`},children:[(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`overline`,color:`primary.main`,sx:{fontWeight:800,letterSpacing:`.14em`,lineHeight:1},children:`Source changes`}),(0,U.jsx)(X,{variant:`h2`,id:`source-title`,sx:{mt:.5},children:Q(r,`Thay đổi trong project`,`Project changes`)})]}),(0,U.jsx)(lu,{label:`Git + task baseline`,variant:`outlined`,size:`small`})]}),(0,U.jsx)(pg,{className:`source-tabs`,value:o,onChange:(e,t)=>xt(t),selectionFollowsFocus:!0,variant:`scrollable`,scrollButtons:`auto`,"aria-label":Q(r,`Nguồn thay đổi`,`Change sources`),sx:{borderBottom:1,borderColor:`divider`,minHeight:48},children:a.map(e=>(0,U.jsx)(Kh,{id:`source-tab-${e.view}`,value:e.view,"aria-controls":`source-tabpanel`,disabled:e.view===`task`&&!i,title:e.view===`task`&&!i?Q(r,`Session này chưa có task baseline`,`This session has no task baseline`):void 0,label:(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsx)(`span`,{children:e.label}),bt[e.view]>0&&(0,U.jsx)(lu,{size:`small`,label:bt[e.view],sx:{height:20,minWidth:24,"& .MuiChip-label":{px:.75}}})]})},e.view))}),o===`staged`&&(0,U.jsx)(ty,{state:z,busy:V,status:re,locale:r,deterministicEnabled:Dt,modelEnabled:Ot,onGenerate:()=>{It()},onCopy:()=>{Lt()},onModel:()=>oe(!0)}),(0,U.jsxs)(J,{className:`source-body`,sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`minmax(286px, 330px) minmax(0, 1fr)`},flex:1,minHeight:620},children:[(0,U.jsxs)(J,{className:`file-panel`,id:`source-tabpanel`,role:`tabpanel`,"aria-labelledby":`source-tab-${o}`,sx:{minWidth:0,borderRight:{md:1},borderBottom:{xs:1,md:0},borderColor:`divider`,bgcolor:`background.default`},children:[(0,U.jsxs)(J,{className:`file-panel-meta`,sx:{minHeight:44,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:1,px:1.5,borderBottom:1,borderColor:`divider`},children:[(0,U.jsx)(`span`,{"aria-live":`polite`,children:Se?.state===`ready`&&Se.value?Ev(Se.value,r):Se?.state===`error`?Q(r,`Không thể tải danh sách file`,`Unable to load files`):Q(r,`Đang tải…`,`Loading…`)}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[Se?.state===`error`&&(0,U.jsx)(`button`,{className:`source-list-retry`,type:`button`,onClick:gt,children:Q(r,`Thử tải lại`,`Retry`)}),(0,U.jsx)(`small`,{children:a.find(e=>e.view===o)?.shortLabel})]})]}),(0,U.jsxs)(J,{className:`file-list`,sx:{maxHeight:{xs:300,md:`calc(100vh - 270px)`},overflow:`auto`,p:.75},children:[yt.map(([e,t])=>(0,U.jsxs)(J,{children:[(0,U.jsxs)(Z,{direction:`row`,className:`file-group-label`,children:[(0,U.jsx)(Vh,{}),(0,U.jsx)(X,{component:`span`,noWrap:!0,children:e})]}),t.map(e=>(0,U.jsx)(ny,{file:e,selected:e.fileRef===we,onSelect:()=>{te(null),d(e.fileRef)},locale:r},e.fileRef))]},e)),Se?.state===`ready`&&vt.length===0&&(0,U.jsx)(`div`,{className:`files-empty`,children:Q(r,`Không có thay đổi trong view này.`,`No changes in this view.`)})]})]}),(0,U.jsx)(ay,{state:it,review:at,mutation:ot,revert:st,reviewEnabled:St,reviewBusy:C,reviewError:T,mutationEnabled:Ct,mutationBusy:D,mutationError:k,revertEnabled:wt,revertBusy:j,openEnabled:Tt,openBusy:F,openStatus:L,detailError:Ke&&!rt,mode:ce,onMode:le,onReview:e=>{At(e)},onMutation:e=>{Mt(e)},onRevert:e=>{Nt(e)},onOpen:()=>{Ft()},onRetry:Ee&&t?()=>_t(!0):void 0,locale:r})]}),zt&&(0,U.jsx)(`div`,{className:`source-action-warning`,role:`status`,children:zt}),N&&(0,U.jsx)(`div`,{className:`source-revert-error`,role:`status`,children:N}),x?.target&&we&&xe&&Te&&Qv(x.target,o,we,xe.viewRevision,Te.fileRevision,e)&&(0,U.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,U.jsxs)(`section`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`revert-dialog-title`,"aria-describedby":`revert-dialog-description`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Xác nhận hoàn tác`,`Confirm revert`)}),(0,U.jsxs)(`h3`,{id:`revert-dialog-title`,children:[`Revert `,x.target.hunkRefs.length?`hunk`:`file`,`?`]}),(0,U.jsxs)(`p`,{id:`revert-dialog-description`,children:[Q(r,`Thao tác sẽ bỏ`,`This will discard`),` `,(0,U.jsxs)(`strong`,{children:[x.target.summary.additionsDiscarded,` `,Q(r,`dòng thêm`,`added lines`)]}),` `,Q(r,`và khôi phục`,`and restore`),` `,(0,U.jsxs)(`strong`,{children:[x.target.summary.deletionsRestored,` `,Q(r,`dòng xóa`,`deleted lines`)]}),` `,Q(r,`trong`,`in`),` `,(0,U.jsx)(`code`,{children:x.target.path}),`.`]}),(0,U.jsx)(`div`,{className:`revert-diff`,"aria-label":Q(r,`Các dòng chính xác sẽ được hoàn tác`,`Exact lines to revert`),children:x.preview?.hunks.map(e=>(0,U.jsxs)(`section`,{children:[(0,U.jsx)(`div`,{children:e.header}),e.lines.map((t,n)=>(0,U.jsxs)(`code`,{className:`revert-line revert-${t.kind}`,children:[(0,U.jsx)(`b`,{children:t.marker}),t.text]},`${e.hunkRef}.${n}`))]},e.hunkRef))}),(0,U.jsxs)(`div`,{className:`revert-safety`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Phần đã stage được giữ nguyên.`,`Staged content is preserved.`)}),(0,U.jsx)(`span`,{children:Q(r,`Không auto-commit. Khả năng khôi phục sau thao tác không được bảo đảm.`,`No auto-commit. Recovery after this action is not guaranteed.`)})]}),(0,U.jsxs)(`div`,{className:`confirm-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>S(null),children:Q(r,`Hủy`,`Cancel`)}),(0,U.jsx)(`button`,{className:`danger-action`,type:`button`,disabled:j,onClick:()=>{Pt()},children:j?Q(r,`Đang hoàn tác…`,`Reverting…`):Q(r,`Xác nhận revert`,`Confirm revert`)})]})]})}),ae&&kt(z.value)&&(0,U.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,U.jsxs)(`section`,{className:`confirm-dialog model-summary-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`model-summary-dialog-title`,"aria-describedby":`model-summary-dialog-description`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Model work có tính phí`,`Token-consuming model work`)}),(0,U.jsx)(`h3`,{id:`model-summary-dialog-title`,children:Q(r,`Nhờ Pi viết lại commit summary?`,`Ask Pi to rewrite the commit summary?`)}),(0,U.jsx)(`p`,{id:`model-summary-dialog-description`,children:Q(r,`Thao tác này gửi một message vào đúng Pi session hiện tại, bắt đầu một Pi operation và tiêu token theo model/thinking đang chọn. Chỉ staged summary đã rút gọn được gửi; source text không được đính kèm.`,`This sends a message to the exact current Pi session, starts a Pi operation, and consumes tokens using the selected model and thinking level. Only the bounded staged summary is sent; source text is not attached.`)}),(0,U.jsxs)(`div`,{className:`revert-safety`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Không tự commit hoặc push.`,`Does not commit or push.`)}),(0,U.jsx)(`span`,{children:Q(r,`Kết quả sẽ xuất hiện trong Chat để review và copy.`,`The result will appear in Chat for review and copying.`)})]}),(0,U.jsxs)(`div`,{className:`confirm-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:V,onClick:()=>oe(!1),children:Q(r,`Hủy`,`Cancel`)}),(0,U.jsx)(`button`,{type:`button`,disabled:V,onClick:()=>{Rt()},children:V?Q(r,`Đang gửi…`,`Sending…`):Q(r,`Xác nhận và gửi sang Pi`,`Confirm and send to Pi`)})]})]})})]})}function sy(e){return Gr(`MuiInputAdornment`,e)}var cy=Kr(`MuiInputAdornment`,[`root`,`filled`,`standard`,`outlined`,`positionStart`,`positionEnd`,`disablePointerEvents`,`hiddenLabel`,`sizeSmall`]),ly,uy=(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${q(n.position)}`],n.disablePointerEvents===!0&&t.disablePointerEvents,t[n.variant]]},dy=e=>{let{classes:t,disablePointerEvents:n,hiddenLabel:r,position:i,size:a,variant:o}=e;return ba({root:[`root`,n&&`disablePointerEvents`,i&&`position${q(i)}`,o,r&&`hiddenLabel`,a&&`size${q(a)}`]},sy,t)},fy=K(`div`,{name:`MuiInputAdornment`,slot:`Root`,overridesResolver:uy})(ys(({theme:e})=>({display:`flex`,maxHeight:`2em`,alignItems:`center`,whiteSpace:`nowrap`,color:(e.vars||e).palette.action.active,variants:[{props:{variant:`filled`},style:{[`&.${cy.positionStart}&:not(.${cy.hiddenLabel})`]:{marginTop:16}}},{props:{position:`start`},style:{marginRight:8}},{props:{position:`end`},style:{marginLeft:8}},{props:{disablePointerEvents:!0},style:{pointerEvents:`none`}}]}))),py=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiInputAdornment`}),{children:r,className:i,component:a=`div`,disablePointerEvents:o=!1,disableTypography:s=!1,position:c,variant:l,...u}=n,d=_s()||{},f=l;l&&d.variant,d&&!f&&(f=d.variant);let p={...n,hiddenLabel:d.hiddenLabel,size:d.size,disablePointerEvents:o,position:c,variant:f},m=dy(p);return(0,U.jsx)(gs.Provider,{value:null,children:(0,U.jsx)(fy,{as:a,ownerState:p,className:W(m.root,i),ref:t,...u,children:typeof r==`string`&&!s?(0,U.jsx)(X,{color:`textSecondary`,children:r}):(0,U.jsxs)(v.Fragment,{children:[c===`start`?ly||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``}):null,r]})})})});function my(e){return Gr(`MuiInputLabel`,e)}var hy=Kr(`MuiInputLabel`,[`root`,`focused`,`disabled`,`error`,`required`,`asterisk`,`formControl`,`sizeSmall`,`shrink`,`animated`,`standard`,`filled`,`outlined`]),gy=e=>{let{classes:t,disableUnderline:n}=e,r=ba({root:[`root`,!n&&`underline`],input:[`input`]},lc,t);return{...t,...r}},_y=K($s,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Xs(e,t),!n.disableUnderline&&t.underline]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`;return e.vars&&(t=e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline)),{position:`relative`,variants:[{props:({ownerState:e})=>e.formControl,style:{[`label + &, .${hy.root} + &`]:{marginTop:16}}},{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ks(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${uc.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${uc.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${t}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ks(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${uc.disabled}, .${uc.error}):before`]:{borderBottom:`2px solid ${(e.vars||e).palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},[`&.${uc.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t,disableUnderline:!1},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t].main}`}}}))]}})),vy=K(ec,{name:`MuiInput`,slot:`Input`,overridesResolver:Zs})({}),yy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiInput`}),{disableUnderline:r=!1,fullWidth:i=!1,inputComponent:a=`input`,multiline:o=!1,notched:s,slotProps:c,slots:l={},type:u=`text`,...d}=n,f=gy(n),p={root:{ownerState:{disableUnderline:r}}},m=c?Wt(c,p):p,h=l.root??_y,g=l.input??vy;return(0,U.jsx)(nc,{slots:{root:h,input:g},slotProps:m,fullWidth:i,inputComponent:a,multiline:o,ref:t,type:u,...d,classes:f})});yy.muiName=`Input`;function by(e){return Gr(`MuiSelect`,e)}var xy=Kr(`MuiSelect`,[`root`,`select`,`multiple`,`filled`,`outlined`,`standard`,`disabled`,`focused`,`icon`,`iconOpen`,`nativeInput`,`error`]),Sy=e=>{let{classes:t,disableUnderline:n,startAdornment:r,endAdornment:i,size:a,hiddenLabel:o,multiline:s}=e,c=ba({root:[`root`,!n&&`underline`,r&&`adornedStart`,i&&`adornedEnd`,a===`small`&&`size${q(a)}`,o&&`hiddenLabel`,s&&`multiline`],input:[`input`]},rc,t);return{...t,...c}},Cy=K($s,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiFilledInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Xs(e,t),!n.disableUnderline&&t.underline]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`,n=t?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`,r=t?`rgba(0, 0, 0, 0.06)`:`rgba(255, 255, 255, 0.09)`,i=t?`rgba(0, 0, 0, 0.09)`:`rgba(255, 255, 255, 0.13)`,a=t?`rgba(0, 0, 0, 0.12)`:`rgba(255, 255, 255, 0.12)`;return{position:`relative`,backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r,borderTopLeftRadius:(e.vars||e).shape.borderRadius,borderTopRightRadius:(e.vars||e).shape.borderRadius,...Ks(e,`background-color`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),"&:hover":{backgroundColor:e.vars?e.vars.palette.FilledInput.hoverBg:i,"@media (hover: none)":{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r}},[`&.${ic.focused}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r},[`&.${ic.disabled}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.disabledBg:a},variants:[{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ks(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${ic.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${ic.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${e.vars?e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline):n}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ks(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${ic.disabled}, .${ic.error}):before`]:{borderBottom:`1px solid ${(e.vars||e).palette.text.primary}`},[`&.${ic.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{disableUnderline:!1,color:t},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t]?.main}`}}})),{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:12}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`12px`,paddingRight:`var(--_trailingPad)`,[`&.${xy.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`25px 12px 8px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}}]}})),wy=K(ec,{name:`MuiFilledInput`,slot:`Input`,overridesResolver:Zs})(ys(({theme:e})=>({paddingTop:25,paddingRight:12,paddingBottom:8,paddingLeft:12,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderTopLeftRadius:`inherit`,borderTopRightRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}},{props:({ownerState:e})=>e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}},{props:({ownerState:e})=>e.multiline,style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}}]}))),Ty=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFilledInput`}),{disableUnderline:r=!1,fullWidth:i=!1,hiddenLabel:a,inputComponent:o=`input`,multiline:s=!1,notched:c,slotProps:l,slots:u={},type:d=`text`,...f}=n,p={...n,disableUnderline:r,fullWidth:i,inputComponent:o,multiline:s,type:d},m=Sy(n),h={root:{ownerState:p},input:{ownerState:p}},g=l?Wt(h,l):h,_=u.root??Cy,v=u.input??wy;return(0,U.jsx)(nc,{slots:{root:_,input:v},slotProps:g,fullWidth:i,inputComponent:o,multiline:s,ref:t,type:d,...f,classes:m})});Ty.muiName=`Input`;var Ey,Dy=K(`fieldset`,{name:`MuiNotchedOutlined`,shouldForwardProp:Jo})({textAlign:`left`,position:`absolute`,bottom:0,right:0,top:-5,left:0,margin:0,padding:`0 8px`,pointerEvents:`none`,borderRadius:`inherit`,borderStyle:`solid`,borderWidth:1,overflow:`hidden`,minWidth:`0%`}),Oy=K(`legend`,{name:`MuiNotchedOutlined`,shouldForwardProp:Jo})(ys(({theme:e})=>({float:`unset`,width:`auto`,overflow:`hidden`,variants:[{props:({ownerState:e})=>!e.withLabel,style:{padding:0,lineHeight:`11px`,...Ks(e,`width`,{duration:150,easing:e.transitions.easing.easeOut})}},{props:({ownerState:e})=>e.withLabel,style:{display:`block`,padding:0,height:11,fontSize:`0.75em`,visibility:`hidden`,maxWidth:.01,...Ks(e,`max-width`,{duration:50,easing:e.transitions.easing.easeOut}),whiteSpace:`nowrap`,"& > span":{paddingLeft:5,paddingRight:5,display:`inline-block`,opacity:0,visibility:`visible`}}},{props:({ownerState:e})=>e.withLabel&&e.notched,style:{maxWidth:`100%`,...Ks(e,`max-width`,{duration:100,easing:e.transitions.easing.easeOut,delay:50})}}]})));function ky(e){let{children:t,classes:n,className:r,label:i,notched:a,...o}=e,s=i!=null&&i!==``,c={...e,notched:a,withLabel:s};return(0,U.jsx)(Dy,{"aria-hidden":!0,className:r,ownerState:c,...o,children:(0,U.jsx)(Oy,{ownerState:c,children:s?(0,U.jsx)(`span`,{children:i}):Ey||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``})})})}var Ay=e=>{let{classes:t}=e,n=ba({root:[`root`],notchedOutline:[`notchedOutline`],input:[`input`]},_c,t);return{...t,...n}},jy=K($s,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiOutlinedInput`,slot:`Root`,overridesResolver:Xs})(ys(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{position:`relative`,borderRadius:(e.vars||e).shape.borderRadius,[`&:hover .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${vc.notchedOutline}`]:{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}},[`&.${vc.focused} .${vc.notchedOutline}`]:{borderWidth:2},variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{[`&.${vc.focused} .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${vc.error} .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette.error.main},[`&.${vc.disabled} .${vc.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled}}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:14}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`14px`,paddingRight:`var(--_trailingPad)`,[`&.${xy.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`16.5px 14px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{padding:`8.5px 14px`}}]}})),My=K(ky,{name:`MuiOutlinedInput`,slot:`NotchedOutline`})(ys(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}})),Ny=K(ec,{name:`MuiOutlinedInput`,slot:`Input`,overridesResolver:Zs})(ys(({theme:e})=>({padding:`16.5px 14px`,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{padding:`8.5px 14px`}},{props:({ownerState:e})=>e.multiline,style:{padding:0}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}}]}))),Py=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiOutlinedInput`}),{fullWidth:r=!1,inputComponent:i=`input`,label:a,multiline:o=!1,notched:s,slots:c={},slotProps:l={},type:u=`text`,...d}=n,f=Ay(n),[p,m]=vs({props:n,states:[`color`,`disabled`,`error`,`focused`,`hiddenLabel`,`size`,`required`]}),h={...n,color:p.color||`primary`,disabled:p.disabled,error:p.error,focused:p.focused,formControl:m,fullWidth:r,hiddenLabel:p.hiddenLabel,multiline:o,size:p.size,type:u},g=c.root??jy,_=c.input??Ny,[y,b]=Xc(`notchedOutline`,{elementType:My,className:f.notchedOutline,shouldForwardComponentProp:!0,ownerState:h,externalForwardedProps:{slots:c,slotProps:l},additionalProps:{label:a!=null&&a!==``&&p.required?(0,U.jsxs)(v.Fragment,{children:[a,` `,`*`]}):a}});return(0,U.jsx)(nc,{slots:{root:g,input:_},slotProps:l,renderSuffix:e=>(0,U.jsx)(y,{...b,notched:s===void 0?!!(e.startAdornment||e.filled||e.focused):s}),fullWidth:r,inputComponent:i,multiline:o,ref:t,type:u,...d,classes:{...f,notchedOutline:null}})});Py.muiName=`Input`;var Fy=e=>{let{classes:t,color:n,focused:r,disabled:i,error:a,filled:o,required:s}=e;return ba({root:[`root`,`color${q(n)}`,i&&`disabled`,a&&`error`,o&&`filled`,r&&`focused`,s&&`required`],asterisk:[`asterisk`,a&&`error`]},sc,t)},Iy=K(`label`,{name:`MuiFormLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color===`secondary`&&t.colorSecondary,n.filled&&t.filled]}})(ys(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.body1,lineHeight:`1.4375em`,padding:0,position:`relative`,variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{[`&.${cc.focused}`]:{color:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${cc.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${cc.error}`]:{color:(e.vars||e).palette.error.main}}}]}))),Ly=K(`span`,{name:`MuiFormLabel`,slot:`Asterisk`})(ys(({theme:e})=>({[`&.${cc.error}`]:{color:(e.vars||e).palette.error.main}}))),Ry=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFormLabel`}),{children:r,className:i,color:a,component:o=`label`,disabled:s,error:c,filled:l,focused:u,required:d,...f}=n,[p]=vs({props:n,states:[`color`,`required`,`focused`,`disabled`,`error`,`filled`]}),m={...n,color:p.color||`primary`,component:o,disabled:p.disabled,error:p.error,filled:p.filled,focused:p.focused,required:p.required},h=Fy(m);return(0,U.jsxs)(Iy,{as:o,ownerState:m,className:W(h.root,i),ref:t,...f,children:[r,p.required&&(0,U.jsxs)(Ly,{ownerState:m,"aria-hidden":!0,className:h.asterisk,children:[` `,`*`]})]})}),zy=e=>{let{classes:t,formControl:n,size:r,shrink:i,disableAnimation:a,variant:o,required:s}=e,c=ba({root:[`root`,n&&`formControl`,!a&&`animated`,i&&`shrink`,r&&r!==`medium`&&`size${q(r)}`,o],asterisk:[s&&`asterisk`]},my,t);return{...t,...c}},By=K(Ry,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiInputLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${cc.asterisk}`]:t.asterisk},t.root,n.formControl&&t.formControl,n.size===`small`&&t.sizeSmall,n.shrink&&t.shrink,!n.disableAnimation&&t.animated,n.focused&&t.focused,t[n.variant]]}})(ys(({theme:e})=>({display:`block`,transformOrigin:`top left`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,variants:[{props:({ownerState:e})=>e.formControl,style:{position:`absolute`,left:0,top:0,transform:`translate(0, 20px) scale(1)`}},{props:{size:`small`},style:{transform:`translate(0, 17px) scale(1)`}},{props:({ownerState:e})=>e.shrink,style:{transform:`translate(0, -1.5px) scale(0.75)`,transformOrigin:`top left`,maxWidth:`133%`}},{props:({ownerState:e})=>!e.disableAnimation,style:{...Ks(e,[`color`,`transform`,`max-width`],{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut})}},{props:{variant:`filled`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(12px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`filled`,size:`small`},style:{transform:`translate(12px, 13px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`filled`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,transform:`translate(12px, 7px) scale(0.75)`,maxWidth:`calc(133% - 24px)`}},{props:({variant:e,ownerState:t,size:n})=>e===`filled`&&t.shrink&&n===`small`,style:{transform:`translate(12px, 4px) scale(0.75)`}},{props:{variant:`outlined`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(14px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`outlined`,size:`small`},style:{transform:`translate(14px, 9px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`outlined`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,maxWidth:`calc(133% - 32px)`,transform:`translate(14px, -9px) scale(0.75)`}}]}))),Vy=v.forwardRef(function(e,t){let n=Xo({name:`MuiInputLabel`,props:e}),{disableAnimation:r=!1,margin:i,shrink:a,variant:o,className:s,...c}=n,[l,u]=vs({props:n,states:[`size`,`variant`,`required`,`focused`]}),d=a;d===void 0&&u&&(d=u.filled||u.focused||u.adornedStart);let f={...n,disableAnimation:r,formControl:u,shrink:d,size:l.size,variant:l.variant,required:l.required,focused:l.focused},p=zy(f);return(0,U.jsx)(By,{"data-shrink":d,ref:t,className:W(p.root,s),...c,ownerState:f,classes:p})});function Hy(e){return Gr(`MuiFormControl`,e)}Kr(`MuiFormControl`,[`root`,`marginNone`,`marginNormal`,`marginDense`,`fullWidth`,`disabled`]);var Uy=e=>{let{classes:t,margin:n,fullWidth:r}=e;return ba({root:[`root`,n!==`none`&&`margin${q(n)}`,r&&`fullWidth`]},Hy,t)},Wy=K(`div`,{name:`MuiFormControl`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`margin${q(n.margin)}`],n.fullWidth&&t.fullWidth]}})({display:`inline-flex`,flexDirection:`column`,position:`relative`,minWidth:0,padding:0,margin:0,border:0,verticalAlign:`top`,variants:[{props:{margin:`normal`},style:{marginTop:16,marginBottom:8}},{props:{margin:`dense`},style:{marginTop:8,marginBottom:4}},{props:{fullWidth:!0},style:{width:`100%`}}]}),Gy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFormControl`}),{children:r,className:i,color:a=`primary`,component:o=`div`,disabled:s=!1,error:c=!1,focused:l,fullWidth:u=!1,hiddenLabel:d=!1,margin:f=`none`,required:p=!1,size:m=`medium`,variant:h=`outlined`,...g}=n,_={...n,color:a,component:o,disabled:s,error:c,fullWidth:u,hiddenLabel:d,margin:f,required:p,size:m,variant:h},y=Uy(_),[b,x]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{if(!wd(t,[`Input`,`Select`]))return;let n=wd(t,[`Select`])?t.props.input:t;n&&Ds(n.props)&&(e=!0)}),e}),[S,C]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{wd(t,[`Input`,`Select`])&&(Es(t.props,!0)||Es(t.props.inputProps,!0))&&(e=!0)}),e}),[w,T]=v.useState(!1);s&&w&&T(!1);let E=l!==void 0&&!s?l:w,D;v.useRef(!1);let O=v.useCallback(()=>{C(!0)},[]),k=v.useCallback(()=>{C(!1)},[]),A=v.useMemo(()=>({adornedStart:b,setAdornedStart:x,color:a,disabled:s,error:c,filled:S,focused:E,fullWidth:u,hiddenLabel:d,size:m,onBlur:()=>{T(!1)},onFocus:()=>{T(!0)},onEmpty:k,onFilled:O,registerEffect:D,required:p,variant:h}),[b,a,s,c,S,E,u,d,D,k,O,p,m,h]);return(0,U.jsx)(gs.Provider,{value:A,children:(0,U.jsx)(Wy,{as:o,ownerState:_,className:W(y.root,i),ref:t,...g,children:r})})}),Ky,qy=e=>{let{classes:t,contained:n,size:r,disabled:i,error:a,filled:o,focused:s,required:c}=e;return ba({root:[`root`,i&&`disabled`,a&&`error`,r&&`size${q(r)}`,n&&`contained`,s&&`focused`,o&&`filled`,c&&`required`]},ac,t)},Jy=K(`p`,{name:`MuiFormHelperText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.size&&t[`size${q(n.size)}`],n.contained&&t.contained,n.filled&&t.filled]}})(ys(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.caption,textAlign:`left`,marginTop:3,marginRight:0,marginBottom:0,marginLeft:0,[`&.${oc.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${oc.error}`]:{color:(e.vars||e).palette.error.main},variants:[{props:{size:`small`},style:{marginTop:4}},{props:({ownerState:e})=>e.contained,style:{marginLeft:14,marginRight:14}}]}))),Yy=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiFormHelperText`}),{children:r,className:i,component:a=`p`,disabled:o,error:s,filled:c,focused:l,margin:u,required:d,variant:f,...p}=n,[m]=vs({props:n,states:[`variant`,`size`,`disabled`,`error`,`filled`,`focused`,`required`]}),h={...n,component:a,contained:m.variant===`filled`||m.variant===`outlined`,variant:m.variant,size:m.size,disabled:m.disabled,error:m.error,filled:m.filled,focused:m.focused,required:m.required};delete h.ownerState;let g=qy(h);return(0,U.jsx)(Jy,{as:a,className:W(g.root,i),ref:t,...p,ownerState:h,children:r===` `?Ky||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``}):r})}),Xy=Ou;function Zy(e,t){if(t==null){e.focus();return}try{e.focus({focusVisible:t===`keyboard`})}catch{e.focus()}}function Qy(e){return e?e.type===`mousedown`||e.type===`pointerdown`||e.type===`touchstart`?`pointer`:e.type===`keydown`||e.type===`click`&&e.detail===0?`keyboard`:null:null}function $y(e){return e==null||typeof e==`string`&&!e.trim()}function eb(e,t){return typeof t==`object`&&t?e===t:String(e)===String(t)}var tb=v.createContext(null);function nb(){return v.useContext(tb)}var rb=tb.Provider,ib=v.createContext(void 0);function ab(){let e=v.useContext(ib);if(e===void 0)throw Error(`MUI: MenuListContext is missing. MenuItems must be placed within Menu or MenuList.`);return e}function ob(e){let t=e?.element??e;if(!t)return``;if(e?.textValue!==void 0)return e.textValue;let n=t.innerText;return n===void 0&&(n=t.textContent),n??``}function sb(e,t){if(t===void 0)return!0;let n=ob(e);return n=n.trim().toLowerCase(),n.length===0?!1:t.repeating?n[0]===t.keys[0]:n.startsWith(t.keys.join(``))}function cb(e,t){return sb(e,t)?Kf(e):!1}function lb(e,t){Zy(e,t)}var ub=v.forwardRef(function(e,t){let{actions:n,autoFocus:r=!1,autoFocusItem:i=!1,children:a,className:o,disabledItemsFocusable:s=!1,disableListWrap:c=!1,onKeyDown:l,variant:u=`selectedMenu`,...d}=e,f=v.useRef(null),p=v.useRef(!1),[m,h]=v.useState(!1),g=nb(),_=v.useRef({keys:[],repeating:!0,previousKeyMatched:!0,lastTime:null}),y=Mf({activeItemId:void 0,getDefaultActiveItemId:v.useCallback(e=>u===`selectedMenu`?e.find(e=>e.selected&&Kf(e))?.id??e.find(e=>Kf(e))?.id??null:e.find(e=>Kf(e))?.id??null,[u]),orientation:`vertical`,wrap:!c}),{activeItemId:b,focusNext:x,getActiveItem:S,getContainerProps:C,getItemMap:w}=y,T=dl((e=!1)=>{if(!f.current||!e&&p.current)return null;if(i){let e=S();if(e?.element){let t=Array.from(w().values()).some(e=>e.selected),n=u===`menu`&&t&&!e.selected&&g==null;return h(n),lb(e.element,g),p.current=!0,e.element}return r?(h(!1),f.current.focus(),f.current):null}return r?(h(!1),f.current.focus(),p.current=!0,f.current):(h(!1),null)});xs(()=>{if(!r&&!i){p.current=!1,h(!1);return}T()},[b,i,r,T]),v.useImperativeHandle(n,()=>({adjustStyleForScrollbar:(e,{direction:t})=>{let n=!f.current.style.width;if(e.clientHeight<f.current.clientHeight&&n){let n=`${Xy(Td(e))}px`;f.current.style[t===`rtl`?`paddingLeft`:`paddingRight`]=n,f.current.style.width=`calc(100% + ${n})`}return f.current},focusInitialTarget:()=>{if(!f.current)return null;let e=ws(Ss(f.current));return e&&zu(f.current,e)?e:T(!0)}}),[T]);let E=C(void 0,d.onFocus),D=bs(f,E.ref,t),O=v.useMemo(()=>({itemsFocusableWhenDisabled:s,suppressInitialFocusVisible:m,variant:u}),[s,m,u]),k=dl(e=>{if(m&&h(!1),(e.ctrlKey||e.metaKey||e.altKey)&&l){l(e);return}if(E.onKeyDown(e),e.key.length===1){let t=_.current,n=e.key.toLowerCase(),r=performance.now();t.keys.length>0&&(r-t.lastTime>500?(t.keys=[],t.repeating=!0,t.previousKeyMatched=!0):t.repeating&&n!==t.keys[0]&&(t.repeating=!1)),t.lastTime=r,t.keys.push(n);let i=ws(Ss(f.current)),a=i&&!t.repeating&&sb(i,t);t.previousKeyMatched&&(a||x(e=>cb(e,t))!=null)?e.preventDefault():t.previousKeyMatched=!1}l&&l(e)});return(0,U.jsx)(rf,{role:`menu`,ref:D,className:o,onKeyDown:k,tabIndex:-1,...d,onFocus:E.onFocus,children:(0,U.jsx)(ib.Provider,{value:O,children:(0,U.jsx)(Df.Provider,{value:y,children:a})})})});function db(e){return Gr(`MuiPopover`,e)}Kr(`MuiPopover`,[`root`,`paper`]);function fb(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.height/2:t===`bottom`&&(n=e.height),n}function pb(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.width/2:t===`right`&&(n=e.width),n}function mb(e){return[e.horizontal,e.vertical].map(e=>typeof e==`number`?`${e}px`:e).join(` `)}function hb(e){return typeof e==`function`?e():e}var gb=e=>{let{classes:t}=e;return ba({root:[`root`],paper:[`paper`]},db,t)},_b=K(Sd,{name:`MuiPopover`,slot:`Root`})({}),vb=K(Pc,{name:`MuiPopover`,slot:`Paper`})({position:`absolute`,overflowY:`auto`,overflowX:`hidden`,minWidth:16,minHeight:16,maxWidth:`calc(100% - 32px)`,maxHeight:`calc(100% - 32px)`,outline:0}),yb=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiPopover`}),{action:r,anchorEl:i,anchorOrigin:a={vertical:`top`,horizontal:`left`},anchorPosition:o,anchorReference:s=`anchorEl`,children:c,className:l,container:u,disableAutoFocus:d=!1,elevation:f=8,marginThreshold:p=16,open:m,slots:h={},slotProps:g={},transformOrigin:_={vertical:`top`,horizontal:`left`},transitionDuration:y=`auto`,disableScrollLock:b=!1,...x}=n,S=v.useRef(),C={...n,anchorOrigin:a,anchorReference:s,elevation:f,marginThreshold:p,transformOrigin:_,transitionDuration:y},w=gb(C),T=v.useCallback(()=>{if(s===`anchorPosition`)return o;let e=hb(i),t=(e&&e.nodeType===1?e:Ss(S.current).body).getBoundingClientRect();return{top:t.top+fb(t,a.vertical),left:t.left+pb(t,a.horizontal)}},[i,a.horizontal,a.vertical,o,s]),E=v.useCallback(e=>({vertical:fb(e,_.vertical),horizontal:pb(e,_.horizontal)}),[_.horizontal,_.vertical]),D=v.useCallback(e=>{let t={width:e.offsetWidth,height:e.offsetHeight},n=E(t);if(s===`none`)return{top:null,left:null,transformOrigin:mb(n)};let r=T(),a=r.top-n.vertical,o=r.left-n.horizontal,c=a+t.height,l=o+t.width,u=Td(hb(i)),d=u.innerHeight-p,f=u.innerWidth-p;if(p!=null&&a<p){let e=a-p;a-=e,n.vertical+=e}else if(p!=null&&c>d){let e=c-d;a-=e,n.vertical+=e}if(p!=null&&o<p){let e=o-p;o-=e,n.horizontal+=e}else if(l>f){let e=l-f;o-=e,n.horizontal+=e}return{top:`${Math.round(a)}px`,left:`${Math.round(o)}px`,transformOrigin:mb(n)}},[i,s,T,E,p]),[O,k]=v.useState(m),A=v.useCallback(()=>{let e=S.current;if(!e)return;let t=D(e);t.top!=null&&e.style.setProperty(`top`,t.top),t.left!=null&&(e.style.left=t.left),e.style.transformOrigin=t.transformOrigin,k(!0)},[D]);v.useEffect(()=>(b&&window.addEventListener(`scroll`,A),()=>window.removeEventListener(`scroll`,A)),[i,b,A]);let j=()=>{A()},M=()=>{k(!1)};v.useEffect(()=>{m&&A()}),v.useImperativeHandle(r,()=>m?{updatePosition:()=>{A()}}:null,[m,A]),v.useEffect(()=>{if(!m)return;let e=Cd(()=>{A()}),t=Td(hb(i));return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[i,m,A]);let N=y,P={slots:h,slotProps:g},[F,I]=Xc(`transition`,{elementType:mp,externalForwardedProps:P,ownerState:C,getSlotProps:e=>({...e,onEntering:(t,n)=>{e.onEntering?.(t,n),j()},onExited:t=>{e.onExited?.(t),M()}}),additionalProps:{appear:!0,in:m}});y===`auto`&&!F.muiSupportAuto&&(N=void 0);let L=u||(i?Ss(hb(i)).body:void 0),[R,{slots:ee,slotProps:te,...z}]=Xc(`root`,{ref:t,elementType:_b,externalForwardedProps:{...P,...x},shouldForwardComponentProp:!0,additionalProps:{slots:{backdrop:h.backdrop},slotProps:{backdrop:kd(typeof g.backdrop==`function`?g.backdrop(C):g.backdrop,{invisible:!0})},container:L,open:m},ownerState:C,className:W(w.root,l)}),[B,V]=Xc(`paper`,{ref:S,className:w.paper,elementType:vb,externalForwardedProps:P,shouldForwardComponentProp:!0,additionalProps:{elevation:f,style:O?void 0:{opacity:0}},ownerState:C});return(0,U.jsx)(R,{...z,...!as(R)&&{slots:ee,slotProps:te,disableAutoFocus:d,disableScrollLock:b},children:(0,U.jsx)(F,{...I,timeout:N,children:(0,U.jsx)(B,{...V,children:c})})})});function bb(e){return Gr(`MuiMenu`,e)}Kr(`MuiMenu`,[`root`,`paper`,`list`]);var xb={vertical:`top`,horizontal:`right`},Sb={vertical:`top`,horizontal:`left`},Cb=e=>{let{classes:t}=e;return ba({root:[`root`],paper:[`paper`],list:[`list`]},bb,t)},wb=K(yb,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiMenu`,slot:`Root`})({}),Tb=K(vb,{name:`MuiMenu`,slot:`Paper`})({maxHeight:`calc(100% - 96px)`,WebkitOverflowScrolling:`touch`}),Eb=K(ub,{name:`MuiMenu`,slot:`List`})({outline:0}),Db=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiMenu`}),{autoFocus:r=!0,children:i,className:a,disableAutoFocusItem:o=!1,onClose:s,open:c,PopoverClasses:l,transitionDuration:u=`auto`,variant:d=`selectedMenu`,slots:f={},slotProps:p={},...m}=n,h=Ri(),g={...n,autoFocus:r,disableAutoFocusItem:o,transitionDuration:u,variant:d},_=Cb(g),y=r&&c,b=y&&!o,x=v.useRef(null),S=(e,t)=>{x.current&&(x.current.adjustStyleForScrollbar(e,{direction:h?`rtl`:`ltr`}),y&&x.current.focusInitialTarget?.())},C=e=>{e.key===`Tab`&&(e.preventDefault(),s&&s(e,`tabKeyDown`))},w={slots:f,slotProps:p},T=lh({elementType:f.root,externalSlotProps:p.root,ownerState:g,className:[_.root,a]}),[E,D]=Xc(`paper`,{className:_.paper,elementType:Tb,externalForwardedProps:w,shouldForwardComponentProp:!0,ownerState:g}),[O,k]=Xc(`list`,{className:_.list,elementType:Eb,shouldForwardComponentProp:!0,externalForwardedProps:w,getSlotProps:e=>({...e,onKeyDown:t=>{C(t),e.onKeyDown?.(t)}}),ownerState:g}),A=typeof p.transition==`function`?p.transition(g):p.transition;return(0,U.jsx)(wb,{disableAutoFocus:r,onClose:s,anchorOrigin:{vertical:`bottom`,horizontal:h?`right`:`left`},transformOrigin:h?xb:Sb,slots:{root:f.root,paper:E,backdrop:f.backdrop,transition:f.transition},slotProps:{root:T,paper:D,backdrop:typeof p.backdrop==`function`?p.backdrop(g):p.backdrop,transition:{...A,onEntering:(...e)=>{S(...e),A?.onEntering?.(...e)}}},open:c,ref:t,transitionDuration:u,ownerState:g,...m,classes:l,children:(0,U.jsx)(O,{actions:x,autoFocus:y,autoFocusItem:b,variant:d,...k,children:i})})}),Ob=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return ba({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,`icon${q(n)}`,a&&`iconOpen`,r&&`disabled`]},hc,t)},kb=K(`select`,{name:`MuiNativeSelect`})(({theme:e})=>({MozAppearance:`none`,WebkitAppearance:`none`,userSelect:`none`,borderRadius:0,cursor:`pointer`,"&:focus":{borderRadius:0},[`&.${gc.disabled}`]:{cursor:`default`},"&[multiple]":{height:`auto`},"&:not([multiple]) option, &:not([multiple]) optgroup":{backgroundColor:(e.vars||e).palette.background.paper},[`& ~ .${cy.root}`]:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,right:`calc(var(--_caret, 24px) + (var(--_endAdornment, 28px) - 1.5rem)/2)`},[`.${ks.root}:has(> &)`]:{"--_endAdornment":`0px`},variants:[{props:({ownerState:e})=>e.variant!==`filled`&&e.variant!==`outlined`,style:{[`.${ks.root}:has(> &)`]:{"--_caret":`24px`},[`.${ks.root}:has(> & ~ .${cy.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 24px) + var(--_endAdornment, 0px))`,minWidth:16}}},{props:{variant:`filled`},style:{[`.${ks.root}:has(> &)`]:{"--_caret":`32px`},[`.${ks.root}:has(> & ~ .${cy.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}},{props:{variant:`outlined`},style:{[`.${ks.root}:has(> &)`]:{"--_caret":`32px`},[`.${ks.root}:has(> & ~ .${cy.root})`]:{"--_endAdornment":`28px`},borderRadius:(e.vars||e).shape.borderRadius,"&:focus":{borderRadius:(e.vars||e).shape.borderRadius},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}}]})),Ab=K(kb,{name:`MuiNativeSelect`,slot:`Select`,shouldForwardProp:Jo,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.select,t[n.variant],n.error&&t.error,{[`&.${gc.multiple}`]:t.multiple}]}})({}),jb=K(`svg`,{name:`MuiNativeSelect`})(({theme:e})=>({position:`absolute`,right:0,top:`calc(50% - .5em)`,pointerEvents:`none`,color:(e.vars||e).palette.action.active,[`&.${gc.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:({ownerState:e})=>e.open,style:{transform:`rotate(180deg)`}},{props:{variant:`filled`},style:{right:7}},{props:{variant:`outlined`},style:{right:7}}]})),Mb=K(jb,{name:`MuiNativeSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.variant&&t[`icon${q(n.variant)}`],n.open&&t.iconOpen]}})({}),Nb=v.forwardRef(function(e,t){let{className:n,disabled:r,error:i,IconComponent:a,inputRef:o,variant:s=`standard`,...c}=e,l={...e,disabled:r,variant:s,error:i},u=Ob(l);return(0,U.jsxs)(v.Fragment,{children:[(0,U.jsx)(Ab,{ownerState:l,className:W(u.select,n),disabled:r,ref:o||t,...c}),e.multiple?null:(0,U.jsx)(Mb,{as:a,ownerState:l,className:u.icon})]})});function Pb(e){return Object.prototype.hasOwnProperty.call(e.props,`value`)}function Fb(e){if(typeof e==`string`||typeof e==`number`)return String(e);let t=``;return v.Children.forEach(e,e=>{typeof e==`string`||typeof e==`number`?t+=String(e):v.isValidElement(e)&&(t+=Fb(e.props.children))}),t}function Ib(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length;for(let n=0;n<e.length;n+=1){let i=(r+n)%e.length;if(e[i].label.startsWith(t))return i}return-1}function Lb(e,t){return!e.some(e=>e.label[0]===t&&e.label[1]===t)}function Rb(e,t){let n=[],r=-1;for(let i=0;i<e.length;i+=1){let a=e[i];if(!v.isValidElement(a)||!Pb(a)||a.props.disabled)continue;let o=Fb(a.props.children).trim().toLowerCase();o!==``&&(r===-1&&eb(t,a.props.value)&&(r=n.length),n.push({child:a,label:o,value:a.props.value}))}return{options:n,selectedIndex:r}}var zb,Bb=2,Vb=400,Hb=200,Ub=750,Wb=` `,Gb=`ArrowUp`,Kb=`ArrowDown`,qb=`Enter`;function Jb(e,t){if(!t)return!1;if(e.composedPath().includes(t)||e.target?.nodeType&&t.contains(e.target))return!0;let n=t.getBoundingClientRect();return n.width===0&&n.height===0?!1:e.clientX>=n.left-Bb&&e.clientX<=n.right+Bb&&e.clientY>=n.top-Bb&&e.clientY<=n.bottom+Bb}var Yb=K(kb,{name:`MuiSelect`,slot:`Select`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`&.${xy.select}`]:t.select},{[`&.${xy.select}`]:t[n.variant]},{[`&.${xy.error}`]:t.error},{[`&.${xy.multiple}`]:t.multiple}]}})({[`&.${xy.select}`]:{height:`auto`,minHeight:`1.4375em`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`}}),Xb=K(jb,{name:`MuiSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.open&&t.iconOpen]}})({}),Zb=K(`input`,{shouldForwardProp:e=>qo(e)&&e!==`classes`,name:`MuiSelect`,slot:`NativeInput`})({bottom:0,left:0,position:`absolute`,opacity:0,pointerEvents:`none`,width:`100%`,boxSizing:`border-box`}),Qb=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return ba({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,a&&`iconOpen`,r&&`disabled`],nativeInput:[`nativeInput`]},by,t)},$b=v.forwardRef(function(e,t){let{"aria-describedby":n,"aria-label":r,autoFocus:i,autoWidth:a,children:o,className:s,defaultOpen:c,defaultValue:l,disabled:u,displayEmpty:d,error:f=!1,IconComponent:p,inputRef:m,labelId:h,MenuProps:g={},multiple:_,name:y,onBlur:b,onChange:x,onClose:S,onFocus:C,onKeyDown:w,onMouseDown:T,onOpen:E,open:D,readOnly:O,renderValue:k,required:A,SelectDisplayProps:j={},tabIndex:M,type:N,value:P,variant:F=`standard`,...I}=e,[L,R]=Od({controlled:P,default:l,name:`Select`}),[ee,te]=Od({controlled:D,default:c,name:`Select`}),z=v.useRef(null),B=v.useRef(null),V=v.useRef(null),ne=v.useRef(!1),re=v.useRef(!1),ie=v.useRef(null),ae=v.useRef(!1),oe=v.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),se=v.useRef({buffer:``,previousSearchIndex:null,matchedIndex:null}),H=Cl(),ce=Cl(),le=Cl(),[ue,de]=v.useState(null),{current:fe}=v.useRef(D!=null),[pe,me]=v.useState(),[he,ge]=v.useState(null),_e=bs(t,m),ve=v.useCallback(e=>{B.current=e,e&&de(e)},[]),ye=ue?.parentNode;v.useImperativeHandle(_e,()=>({focus:()=>{B.current.focus()},node:z.current,value:L}),[L]);let be=ue!==null&&ee,xe=v.useCallback(()=>{le.clear(),se.current.buffer=``,se.current.previousSearchIndex=null,se.current.matchedIndex=null},[le]);xs(()=>{ne.current=be,be&&xe()},[be,xe]);let Se=v.useCallback(()=>{H.clear(),ce.clear()},[H,ce]),Ce=v.useCallback(()=>{Se(),ae.current=!1,oe.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},[Se]),we=v.useCallback(()=>{ie.current&&=(ie.current(),null)},[]);v.useEffect(()=>{be||(Ce(),we())},[be,Ce,we]),v.useEffect(()=>()=>{Ce(),we(),xe()},[Ce,we,xe]),v.useEffect(()=>{if(!be||!ye||a||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{me(ye.clientWidth)});return e.observe(ye),()=>{e.disconnect()}},[be,ye,a]),v.useEffect(()=>{c&&ee&&ue&&!fe&&(me(a?null:ye.clientWidth),B.current.focus())},[ue,a]),v.useEffect(()=>{i&&B.current.focus()},[i]),v.useEffect(()=>{if(!h)return;let e=Ss(B.current).getElementById(h);if(e){let t=()=>{getSelection().isCollapsed&&B.current.focus()};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}},[h]);let Te=dl((e,t)=>{e||(Ce(),we()),e?(xe(),ge(Qy(t)),E&&E(t)):(ge(null),S&&S(t)),fe||(ne.current=e,me(a?null:ye.clientWidth),te(e))}),Ee=()=>{Ce(),re.current?ce.start(Hb,()=>{oe.current.allowUnselectedMouseUp=!0,H.start(Hb,()=>{oe.current.allowSelectedMouseUp=!0})}):H.start(Vb,()=>{oe.current.allowSelectedMouseUp=!0,oe.current.allowUnselectedMouseUp=!0})},De=e=>{if(T?.(e),e.button!==0||(e.preventDefault(),!B.current))return;B.current.focus();let t=Ss(e.currentTarget);Ee(),we();let n=e=>{ie.current=null,B.current&&(Jb(e,B.current)||Jb(e,V.current)||!ne.current&&fe||Te(!1,e))};t.addEventListener(`mouseup`,n,{capture:!0,once:!0}),ie.current=()=>{t.removeEventListener(`mouseup`,n,!0)},Te(!0,e)},Oe=e=>{Te(!1,e)},ke=v.Children.toArray(o),Ae=e=>{let t=ke.find(t=>t.props.value===e.target.value);t!==void 0&&(R(t.props.value),x&&x(e,t))},je=(e,t,n)=>{if(R(n),x){let r=e.nativeEvent||e,i=new r.constructor(r.type,r);Object.defineProperty(i,"target",{writable:!0,value:{value:n,name:y}}),x(i,t)}},Me=e=>t=>{ae.current=!1;let n;if(t.currentTarget.hasAttribute(`tabindex`)){if(_){n=Array.isArray(L)?L.slice():[];let t=L.indexOf(e.props.value);t===-1?n.push(e.props.value):n.splice(t,1)}else n=e.props.value;e.props.onClick&&e.props.onClick(t),L!==n&&je(t,e,n),_||Te(!1,t)}},Ne=(e,t)=>n=>{if(e.props.onMouseUp?.(n),ae.current){ae.current=!1;return}let r=!oe.current.allowSelectedMouseUp&&t,i=!oe.current.allowUnselectedMouseUp&&!t;r||i||n.currentTarget.click()},Pe=e=>{let t=se.current,n=t.buffer!==``;if(be||_||u||e.defaultPrevented||e.nativeEvent?.isComposing||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||e.key===Wb&&!n)return!1;e.key===Wb&&e.preventDefault();let r=t.buffer===``,{options:i,selectedIndex:a}=Rb(ke,L);if(i.length===0)return e.key!==Wb&&xe(),!0;r&&(t.previousSearchIndex=a);let o=e.key.toLowerCase();t.buffer===o&&Lb(i,o)&&(t.buffer=``,t.previousSearchIndex=t.matchedIndex),t.buffer+=o,le.start(Ub,xe);let s=Ib(i,t.buffer,(t.previousSearchIndex??-1)+1);if(s!==-1){let n=i[s];return t.matchedIndex=s,eb(L,n.value)||je(e,n.child,n.value),!0}return e.key!==Wb&&xe(),!0},Fe=e=>{if(!O){let t=Pe(e),n=e.key===Wb||e.key===Gb||e.key===Kb||e.key===qb;!t&&n&&(e.preventDefault(),Te(!0,e)),w?.(e)}},Ie=e=>{xe(),!be&&b&&(Object.defineProperty(e,"target",{writable:!0,value:{value:L,name:y}}),b(e))},Le=e=>t=>{e?.props?.onKeyDown?.(t),t.key===Wb&&t.target===t.currentTarget&&!t.defaultPrevented&&(t.preventDefault(),t.repeat||t.currentTarget.click())};delete I[`aria-invalid`];let Re,ze,Be=[],Ve=!1,He=!1;(Es({value:L})||d)&&(k?Re=k(L):Ve=!0);let Ue=ke.map(e=>{if(!v.isValidElement(e))return null;let t;if(_){if(!Array.isArray(L))throw Error(Lt(2));t=L.some(t=>eb(t,e.props.value)),t&&Ve&&Be.push(e.props.children)}else t=eb(L,e.props.value),t&&Ve&&(ze=e.props.children);return t&&(He=!0),v.cloneElement(e,{"aria-selected":t?`true`:`false`,onMouseDown:t=>{ae.current=!0,e.props.onMouseDown?.(t)},onPointerDown:t=>{ae.current=!0,e.props.onPointerDown?.(t)},onClick:Me(e),onMouseUp:Ne(e,t),onKeyUp:t=>{t.key===Wb&&t.preventDefault(),e.props.onKeyUp&&e.props.onKeyUp(t)},onKeyDown:Le(e),role:`option`,selected:t,value:void 0,"data-value":e.props.value})});xs(()=>{re.current=He,!be&&!_&&!He&&xe()},[He,_,be,xe]),Ve&&(Re=_?Be.length===0?null:Be.reduce((e,t,n)=>(e.push(t),n<Be.length-1&&e.push(`, `),e),[]):ze);let We=pe;!a&&fe&&ue&&(We=ye.clientWidth);let Ge;Ge=M===void 0?u?null:0:M;let Ke=j.id||(y?`mui-component-select-${y}`:void 0),qe={...e,variant:F,value:L,open:be,error:f},Je=Qb(qe),Ye=typeof g.slotProps?.paper==`function`?g.slotProps.paper(qe):g.slotProps?.paper,Xe=bs(Ye?.ref,V),Ze=typeof g.slotProps?.list==`function`?g.slotProps.list(qe):g.slotProps?.list,Qe=Ki(),$e=Ki();return(0,U.jsxs)(v.Fragment,{children:[(0,U.jsx)(Yb,{as:`div`,ref:ve,tabIndex:Ge,role:`combobox`,"aria-controls":be?Qe:void 0,"aria-disabled":u?`true`:void 0,"aria-expanded":be?`true`:`false`,"aria-haspopup":`listbox`,"aria-readonly":O?`true`:void 0,"aria-label":r,"aria-labelledby":h,"aria-describedby":n,"aria-required":A?`true`:void 0,"aria-invalid":f?`true`:void 0,onKeyDown:Fe,onMouseDown:u||O?null:De,onBlur:Ie,onFocus:C,...j,ownerState:qe,className:W(j.className,Je.select,s),id:Ke,children:$y(Re)?zb||=(0,U.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:``}):Re}),(0,U.jsx)(Zb,{"aria-invalid":f,value:Array.isArray(L)?L.join(`,`):L,name:y,ref:z,"aria-hidden":!0,onChange:Ae,tabIndex:-1,disabled:u,readOnly:O,className:Je.nativeInput,autoFocus:i,required:A,...I,id:I.id??$e,ownerState:qe}),(0,U.jsx)(Xb,{as:p,className:Je.icon,ownerState:qe}),(0,U.jsx)(rb,{value:he,children:(0,U.jsx)(Db,{id:`menu-${y||``}`,anchorEl:ye,open:be,onClose:Oe,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},...g,slotProps:{...g.slotProps,list:{"aria-labelledby":h,role:`listbox`,"aria-multiselectable":_?`true`:void 0,disableListWrap:!0,id:Qe,...Ze},paper:{...Ye,ref:Xe,style:{minWidth:We,...Ye?.style}}},children:Ue})})]})}),ex=Y((0,U.jsx)(`path`,{d:`M7 10l5 5 5-5z`}),`ArrowDropDown`),tx=e=>{let{classes:t}=e,n=ba({root:[`root`]},by,t);return{...t,...n}},nx={name:`MuiSelect`,slot:`Root`,shouldForwardProp:e=>Jo(e)&&e!==`variant`},rx=K(yy,nx)(``),ix=K(Py,nx)(``),ax=K(Ty,nx)(``),ox=v.forwardRef(function(e,t){let n=Xo({name:`MuiSelect`,props:e}),{autoWidth:r=!1,children:i,classes:a={},className:o,defaultOpen:s=!1,displayEmpty:c=!1,IconComponent:l=ex,id:u,input:d,inputProps:f,label:p,labelId:m,MenuProps:h,multiple:g=!1,native:_=!1,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:C,variant:w=`outlined`,...T}=n,E=_?Nb:$b,[D]=vs({props:n,states:[`variant`,`error`]}),O=D.variant||w,k={...n,variant:O,classes:a},A=tx(k),{root:j,...M}=A,N=d||{standard:(0,U.jsx)(rx,{ownerState:k}),outlined:(0,U.jsx)(ix,{label:p,ownerState:k}),filled:(0,U.jsx)(ax,{ownerState:k})}[O],P=bs(t,Lu(N));return(0,U.jsx)(v.Fragment,{children:v.cloneElement(N,{inputComponent:E,inputProps:{children:i,error:D.error,IconComponent:l,variant:O,type:void 0,multiple:g,..._?{id:u}:{autoWidth:r,defaultOpen:s,displayEmpty:c,labelId:m,MenuProps:h,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:{id:u,...C}},...f,classes:f?Wt(M,f.classes):M,...d?d.props.inputProps:{}},...(g&&_||c)&&O===`outlined`?{notched:!0}:{},ref:P,className:W(N.props.className,o,A.root),...!d&&{variant:O},...T})})});ox.muiName=`Select`;function sx(e){return Gr(`MuiTextField`,e)}Kr(`MuiTextField`,[`root`]);var cx={standard:yy,filled:Ty,outlined:Py},lx=e=>{let{classes:t}=e;return ba({root:[`root`]},sx,t)},ux=K(Gy,{name:`MuiTextField`,slot:`Root`})({}),dx=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiTextField`}),{autoComplete:r,autoFocus:i=!1,children:a,className:o,color:s=`primary`,defaultValue:c,disabled:l=!1,error:u=!1,fullWidth:d=!1,helperText:f,id:p,inputRef:m,label:h,maxRows:g,minRows:_,multiline:v=!1,name:y,onBlur:b,onChange:x,onFocus:S,placeholder:C,required:w=!1,rows:T,select:E=!1,slots:D={},slotProps:O={},type:k,value:A,variant:j=`outlined`,...M}=n,N={...n,autoFocus:i,color:s,disabled:l,error:u,fullWidth:d,multiline:v,required:w,select:E,variant:j},P=lx(N),F=Ki(p),I=f&&F?`${F}-helper-text`:void 0,L=h&&F?`${F}-label`:void 0,R=cx[j],ee={slots:D,slotProps:O},[te,z]=Xc(`select`,{elementType:ox,externalForwardedProps:ee,ownerState:N}),B=E&&z.native,V={},ne=ee.slotProps.inputLabel;j===`outlined`&&(ne&&ne.shrink!==void 0&&(V.notched=ne.shrink),V.label=h),E&&(B||(V.id=void 0),V[`aria-describedby`]=void 0);let[re,ie]=Xc(`root`,{elementType:ux,shouldForwardComponentProp:!0,externalForwardedProps:{...ee,...M},ownerState:N,className:W(P.root,o),ref:t,additionalProps:{disabled:l,error:u,fullWidth:d,required:w,color:s,variant:j}}),[ae,oe]=Xc(`input`,{elementType:R,externalForwardedProps:ee,additionalProps:V,ownerState:N}),[se,H]=Xc(`inputLabel`,{elementType:Vy,externalForwardedProps:ee,ownerState:N}),[ce,le]=Xc(`htmlInput`,{elementType:`input`,externalForwardedProps:ee,ownerState:N}),[ue,de]=Xc(`formHelperText`,{elementType:Yy,externalForwardedProps:ee,ownerState:N}),fe=(0,U.jsx)(ae,{"aria-describedby":I,autoComplete:r,autoFocus:i,defaultValue:c,fullWidth:d,multiline:v,name:y,rows:T,maxRows:g,minRows:_,type:k,value:A,id:F,inputRef:m,onBlur:b,onChange:x,onFocus:S,placeholder:C,inputProps:le,slots:{input:D.htmlInput?ce:void 0},...oe});return(0,U.jsxs)(re,{...ie,children:[h!=null&&h!==``&&(0,U.jsx)(se,{htmlFor:E&&!B?void 0:F,id:L,...E&&!B&&{component:`div`},...H,children:h}),E?(0,U.jsx)(te,{"aria-describedby":I,id:F,labelId:L,value:A,input:fe,...z,children:a}):fe,f&&(0,U.jsx)(ue,{id:I,...de,children:f})]})}),fx=Y((0,U.jsx)(`path`,{d:`M15.5 14h-.79l-.28-.27c1.2-1.4 1.82-3.31 1.48-5.34-.47-2.78-2.79-5-5.59-5.34-4.23-.52-7.79 3.04-7.27 7.27.34 2.8 2.56 5.12 5.34 5.59 2.03.34 3.94-.28 5.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0s.41-1.08 0-1.49zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14`}),`SearchRounded`),px=`modulepreload`,mx=function(e){return`/`+e},hx={},gx=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=mx(t,n),t=s(t),t in hx)return;hx[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`:px,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)})},_x=(0,v.lazy)(async()=>({default:(await gx(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-nggiOt0N.js`);return{MarkdownMessage:e}},[])).MarkdownMessage})),vx=new Set([`md`,`markdown`]),yx=new Set([`csv`,`tsv`]);function bx(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function xx(e,t){return e.source===`project`?Q(t,`Project`,`Project`):Q(t,`Thư mục đã cấp quyền`,`Granted directory`)}function Sx(e,t){let n=[],r=[],i=``,a=!1,o=0,s=()=>{r.length<40&&r.push(i),i=``},c=()=>{s(),r.some(e=>e.length>0)&&n.push(r),r=[]};for(;o<e.length&&n.length<500;){let n=e[o];if(a){if(n===`"`&&e[o+1]===`"`){i+=`"`,o+=2;continue}if(n===`"`){a=!1,o+=1;continue}i+=n,o+=1;continue}if(n===`"`&&i.length===0){a=!0,o+=1;continue}if(n===t){s(),o+=1;continue}if(n===`
|
|
173
173
|
`||n===`\r`){c(),n===`\r`&&e[o+1]===`
|
|
174
|
-
`&&(o+=1),o+=1;continue}i+=n,o+=1}return n.length<500&&(i.length>0||r.length>0)&&c(),n}function Sx({text:e,separator:t}){let n=(0,v.useMemo)(()=>xx(e,t),[e,t]);if(n.length===0)return null;let[r,...i]=n,a=Math.min(Math.max(...n.map(e=>e.length)),40);return(0,U.jsx)(J,{sx:{overflowX:`auto`},children:(0,U.jsxs)(J,{component:`table`,className:`document-table`,children:[(0,U.jsx)(J,{component:`thead`,children:(0,U.jsx)(J,{component:`tr`,children:Array.from({length:a},(e,t)=>(0,U.jsx)(J,{component:`th`,children:r[t]??``},t))})}),(0,U.jsx)(J,{component:`tbody`,children:i.map((e,t)=>(0,U.jsx)(J,{component:`tr`,children:Array.from({length:a},(t,n)=>(0,U.jsx)(J,{component:`td`,children:e[n]??``},n))},t))})]})})}function Cx({document:e,extension:t}){let n=e.text??``;return _x.has(t??``)?(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(J,{component:`pre`,className:`document-plain`,children:n}),children:(0,U.jsx)(gx,{children:n})}):vx.has(t??``)?(0,U.jsx)(Sx,{text:n,separator:t===`tsv`?` `:`,`}):(0,U.jsx)(J,{component:`pre`,className:`document-plain`,children:n})}function wx({sessionRef:e=null}){let{locale:t}=Gv(),[n,r]=(0,v.useState)({state:`idle`}),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({state:`idle`}),[c,l]=(0,v.useState)(``),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=new AbortController;return r({state:`loading`}),a(null),s({state:`idle`}),N_(e,t.signal).then(e=>r({state:`ready`,value:e})).catch(()=>{t.signal.aborted||r({state:`error`})}),()=>t.abort()},[e]),(0,v.useEffect)(()=>{if(!i){s({state:`idle`});return}let t=new AbortController;return s({state:`loading`}),P_(e,i,t.signal).then(e=>{s({state:`ready`,value:e}),u.current?.scrollTo({top:0})}).catch(()=>{t.signal.aborted||s({state:`error`})}),()=>t.abort()},[e,i]);let d=n.value,f=c.trim().toLowerCase(),p=(0,v.useMemo)(()=>(d?.documents??[]).filter(e=>!f||e.relativePath.toLowerCase().includes(f)),[d,f]),m=(0,v.useMemo)(()=>(d?.roots??[]).map(e=>({root:e,entries:p.filter(t=>t.rootRef===e.rootRef)})).filter(e=>e.entries.length>0),[d,p]),h=p.find(e=>e.documentRef===i)??d?.documents.find(e=>e.documentRef===i);return(0,U.jsxs)(`section`,{className:`document-workspace surface`,"aria-labelledby":`documents-heading`,children:[(0,U.jsxs)(`header`,{className:`document-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(t,`Chỉ đọc · không sửa file`,`Read only · never writes`)}),(0,U.jsx)(`h2`,{id:`documents-heading`,children:Q(t,`Tài liệu`,`Documents`)})]}),(0,U.jsx)(`span`,{children:d?`${d.documents.length}${d.truncated?`+`:``} ${Q(t,`tài liệu`,`documents`)}`:`—`})]}),(0,U.jsxs)(`div`,{className:`document-body`,children:[(0,U.jsxs)(`aside`,{className:`document-list`,"aria-label":Q(t,`Danh sách tài liệu`,`Document list`),children:[(0,U.jsx)(ux,{size:`small`,fullWidth:!0,value:c,onChange:e=>l(e.target.value),placeholder:Q(t,`Lọc theo tên hoặc thư mục…`,`Filter by name or folder…`),slotProps:{htmlInput:{"aria-label":Q(t,`Lọc tài liệu`,`Filter documents`)},input:{startAdornment:(0,U.jsx)(fy,{position:`start`,children:(0,U.jsx)(dx,{fontSize:`small`})})}}}),n.state===`loading`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Đang quét tài liệu…`,`Scanning for documents…`)}),n.state===`error`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Không đọc được danh sách tài liệu.`,`The document list could not be read.`)}),d?.state===`unavailable`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Fv(d.reasonCode,t)}),n.state===`ready`&&d?.state===`ready`&&m.length===0&&(0,U.jsx)(`p`,{className:`document-empty`,children:f?Q(t,`Không có tài liệu nào khớp bộ lọc.`,`No document matches the filter.`):Q(t,`Chưa tìm thấy tài liệu nào.`,`No documents were found.`)}),m.map(e=>(0,U.jsxs)(`div`,{className:`document-group`,children:[(0,U.jsxs)(`div`,{className:`document-group-heading`,children:[(0,U.jsx)(`strong`,{children:bx(e.root,t)}),(0,U.jsx)(`span`,{title:e.root.path,children:e.root.path})]}),e.entries.map(e=>(0,U.jsxs)(cf,{component:`button`,type:`button`,className:`document-row`,selected:e.documentRef===i,onClick:()=>a(e.documentRef),children:[(0,U.jsx)(Nh,{fontSize:`small`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`document-row-copy`,children:[(0,U.jsx)(`strong`,{children:e.name}),(0,U.jsx)(`small`,{children:e.relativePath})]}),(0,U.jsxs)(`span`,{className:`document-row-meta`,children:[e.extension,` · `,yx(e.sizeBytes)]})]},e.documentRef))]},e.root.rootRef)),d?.truncated&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Danh sách đã đạt giới hạn; dùng bộ lọc để thu hẹp.`,`The list reached its limit; use the filter to narrow it.`)})]}),(0,U.jsxs)(`div`,{className:`document-viewer`,ref:u,children:[!i&&(0,U.jsxs)(`div`,{className:`document-placeholder`,children:[(0,U.jsx)(Nh,{"aria-hidden":`true`}),(0,U.jsx)(X,{variant:`body2`,children:Q(t,`Chọn một tài liệu để đọc nội dung tại đây.`,`Pick a document to read it here.`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:Q(t,`Hỗ trợ .md .txt .csv .json .yaml .docx .pdf`,`Supports .md .txt .csv .json .yaml .docx .pdf`)})]}),i&&o.state===`loading`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Đang mở tài liệu…`,`Opening the document…`)}),i&&o.state===`error`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Không mở được tài liệu này.`,`This document could not be opened.`)}),o.state===`ready`&&o.value&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`document-toolbar`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:o.value.name??h?.name??`—`}),(0,U.jsx)(`small`,{children:o.value.relativePath??h?.relativePath??``})]}),(0,U.jsxs)(`div`,{className:`document-badges`,children:[o.value.format&&(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:o.value.format}),o.value.truncated&&(0,U.jsx)(lu,{size:`small`,color:`warning`,variant:`outlined`,label:Q(t,`Đã cắt bớt`,`Truncated`)}),o.value.redacted&&(0,U.jsx)(lu,{size:`small`,color:`warning`,variant:`outlined`,label:Q(t,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`)})]})]}),o.value.state===`unavailable`?(0,U.jsx)(`p`,{className:`document-empty`,children:Fv(o.value.reasonCode,t)}):(0,U.jsx)(`article`,{className:`document-content`,children:(0,U.jsx)(Cx,{document:o.value,extension:h?.extension})})]})]})]})]})}function Tx(e,t=`vi`){let n=e.state===`running`?`running`:e.state===`failed`?`failed`:`passed`,r=n===`running`?t===`vi`?`đang chạy`:`running`:n===`failed`?t===`vi`?`thất bại`:`failed`:t===`vi`?`hoàn tất`:`completed`,i=e.startedAt??e.finishedAt??``;return{activityRef:`live.${e.toolCallRef}`,kind:[`bash`,`shell`,`exec`].includes(e.toolLabel)?`command`:`tool`,state:n,label:`${e.toolLabel} ${r}`,preview:t===`vi`?`Cập nhật trực tiếp từ Gateway`:`Live update from the Gateway`,toolCallId:e.toolCallRef,toolName:e.toolLabel,commandDigest:null,logRef:null,exitCode:null,exitCodeExact:!1,startedAt:i,finishedAt:n===`running`?null:e.finishedAt??i}}function Ex(e,t=`vi`){let n=e.state===`failed`?t===`vi`?`Lượt chạy gặp lỗi`:`Operation failed`:e.state===`blocked`?t===`vi`?`Lượt chạy bị chặn`:`Operation blocked`:e.state===`aborted`?t===`vi`?`Lượt chạy đã dừng`:`Operation stopped`:t===`vi`?`Chưa xác định kết quả lượt chạy`:`Operation outcome unknown`;return{activityRef:e.activityRef,kind:`system`,state:e.state,label:n,preview:e.reasonCode,toolCallId:null,toolName:null,commandDigest:null,logRef:null,exitCode:null,exitCodeExact:!1,startedAt:e.settledAt,finishedAt:e.settledAt}}function Dx(e,t,n,r=`vi`,i){let a=[...e,...t],o=new Set(a.map(e=>e.activityRef)),s=n.filter(e=>!o.has(e.activityRef)).map(e=>Ex(e,r));if(i===void 0)return{rows:[...e,...s,...t],terminalCount:s.length,runningCount:e.length};let c=i.filter(e=>e.state===`running`).map(e=>Tx(e,r));return{rows:[...c,...s,...t],terminalCount:s.length,runningCount:c.length}}function Ox(e,t=`vi`){return e.state===`passed`&&/ recovered$/i.test(e.label)?t===`vi`?`Đã khôi phục`:`Recovered`:e.state===`passed`&&/ warning$/i.test(e.label)?t===`vi`?`Đã xử lý cảnh báo`:`Handled warning`:e.state===`passed`&&e.exitCodeExact?`Pass · exit ${e.exitCode??0}`:e.state===`failed`&&e.exitCodeExact?`Fail · exit ${e.exitCode??`?`}`:e.state===`blocked`?`Blocked`:e.state===`aborted`?t===`vi`?`Đã dừng`:`Stopped`:e.state===`unknown`?t===`vi`?`Chưa xác định`:`Unknown`:e.state===`failed`?t===`vi`?`Thất bại`:`Failed`:e.state===`running`?t===`vi`?`Đang chạy`:`Running`:e.state.replaceAll(`-`,` `)}function kx(e,t=`vi`){let n=Date.parse(e.startedAt),r=e.finishedAt?Date.parse(e.finishedAt):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return t===`vi`?`Thời gian chưa xác định`:`Unknown duration`;let i=Math.round((r-n)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function Ax({activity:e,preview:t,onPreview:n,locale:r}){return(0,U.jsxs)(`article`,{className:`activity-row`,children:[(0,U.jsx)(`span`,{className:`activity-state tone-${Iv(e.state)}`,"aria-label":e.state}),(0,U.jsxs)(`div`,{className:`activity-copy`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.label}),(0,U.jsx)(`span`,{children:e.kind})]}),(0,U.jsx)(`p`,{children:e.preview||Q(r,`Không có mô tả ngắn`,`No short description`)}),t&&(0,U.jsxs)(`div`,{className:`log-preview ${t.state===`error`?`error-state`:``}`,children:[t.state===`loading`?Q(r,`Đang tải log ngắn…`,`Loading log preview…`):t.state===`error`?Q(r,`Log preview không còn sẵn sàng.`,`Log preview is no longer available.`):t.value?.preview??`${Q(r,`Không có nội dung log`,`No log content`)} · ${t.value?.reasonCode??`unavailable`}`,t.value?.truncated&&(0,U.jsx)(`small`,{children:Q(r,`Preview đã được rút gọn`,`Preview truncated`)})]})]}),(0,U.jsxs)(`div`,{className:`activity-result`,children:[(0,U.jsx)(`strong`,{children:Ox(e,r)}),(0,U.jsx)(`span`,{children:kx(e,r)}),e.logRef&&n&&(0,U.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":!!t,children:t?Q(r,`Ẩn log`,`Hide log`):Q(r,`Xem log`,`View log`)})]})]})}function jx({snapshot:e,sessionRef:t,terminalActivities:n=[],liveActivities:r}){let{locale:i}=Gv(),[a,o]=(0,v.useState)({}),s=e?.activity.running??[],c=e?.activity.recent??[],{rows:l,terminalCount:u,runningCount:d}=Dx(s,c,n,i,r),f=e=>{if(a[e.activityRef]){o(t=>({...t,[e.activityRef]:void 0}));return}o(t=>({...t,[e.activityRef]:{state:`loading`}})),(t?e_(t,e.activityRef):v_(e.activityRef)).then(t=>o(n=>({...n,[e.activityRef]:{state:`ready`,value:t}}))).catch(()=>o(t=>({...t,[e.activityRef]:{state:`error`}})))};return(0,U.jsxs)(`section`,{className:`activity-panel surface`,"aria-labelledby":`activity-title`,children:[(0,U.jsxs)(`header`,{className:`panel-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Activity`}),(0,U.jsx)(`h2`,{id:`activity-title`,children:Q(i,`Tool, command và kết quả lượt chạy`,`Tools, commands, and operation outcomes`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`running-count`,children:[d,` `,Q(i,`đang chạy`,`running`)]}),(0,U.jsxs)(`span`,{children:[c.length+u,` `,Q(i,`gần đây`,`recent`)]})]})]}),(0,U.jsxs)(`div`,{className:`activity-list`,children:[l.map(e=>(0,U.jsx)(Ax,{activity:e,preview:a[e.activityRef],onPreview:e.logRef?()=>f(e):void 0,locale:i},e.activityRef)),l.length===0&&(0,U.jsx)(`div`,{className:`activity-empty`,children:Q(i,`Chưa có tool, command hoặc kết quả lượt chạy nào trong timeline hiện tại.`,`No tools, commands, or operation outcomes in the current timeline.`)})]}),e?.activity.page.truncated&&(0,U.jsx)(`footer`,{className:`panel-footnote`,children:Q(i,`Timeline đã được rút gọn theo giới hạn local.`,`The timeline was truncated to local limits.`)})]})}function Mx(e,t=`vi`){return e===null||!Number.isFinite(e)?t===`vi`?`Không có dữ liệu`:`No data`:Math.abs(e)<1e3?String(Math.round(e)):Math.abs(e)<1e6?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:`${(e/1e6).toFixed(1)}m`}function Nx(e,t=`vi`){return e.state!==`known`||e.tokens===null||e.percent===null?t===`vi`?`Context chưa xác định`:`Unknown context`:`${Mx(e.tokens,t)} / ${Mx(e.contextWindow,t)} · ${e.percent.toFixed(1)}%`}function Px(e,t=`vi`){return e.state===`known`?`↑ ${Mx(e.input,t)} · ↓ ${Mx(e.output,t)}`:t===`vi`?`Không có dữ liệu`:`No data`}function Fx(e,t=`vi`){return e?e.state===`passed`?e.exitCodeExact?`Pass · exit ${e.exitCode??0}`:t===`vi`?`Pass · exit chưa xác định`:`Pass · unknown exit`:e.state===`failed`?e.exitCodeExact?`Fail · exit ${e.exitCode??`?`}`:t===`vi`?`Fail · exit chưa xác định`:`Fail · unknown exit`:e.state===`stale`?e.staleFilesKnown?`Stale · ${e.staleByPaths.length} file`:t===`vi`?`Stale · file chưa xác định`:`Stale · unknown files`:e.state.replaceAll(`-`,` `):t===`vi`?`Chưa có verifier gần nhất`:`No recent verifier`}function Ix(e,t=`vi`){return e.task?.blocker??e.task?.reasonCode??e.verification.reasonCode??e.health.issues.find(e=>e.severity===`error`)?.message??(t===`vi`?`Không có blocker được ghi nhận`:`No recorded blocker`)}function Lx({kicker:e,title:t,children:n}){return(0,U.jsxs)(`section`,{className:`evidence-card surface`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:e}),(0,U.jsx)(`h3`,{children:t}),n]})}function Rx({snapshot:e}){let{locale:t}=Gv(),n=e.verification.latest,r=e.usage.context,i=e.continuation,a=e.handoff,o=r.state===`known`&&r.percent!==null?Math.max(0,Math.min(100,r.percent)):0;return(0,U.jsxs)(`section`,{className:`evidence-section`,"aria-labelledby":`evidence-title`,children:[(0,U.jsxs)(`header`,{className:`section-title-row`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Completion evidence`}),(0,U.jsx)(`h2`,{id:`evidence-title`,children:Q(t,`Verifier, usage và handoff`,`Verifier, usage, and handoff`)})]}),(0,U.jsx)(`span`,{children:Ix(e,t)})]}),(0,U.jsxs)(`div`,{className:`evidence-grid`,children:[(0,U.jsx)(Lx,{kicker:Q(t,`Verifier gần nhất`,`Latest verifier`),title:Fx(n,t),children:n?(0,U.jsxs)(`dl`,{className:`evidence-list`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Command`}),(0,U.jsx)(`dd`,{title:n.command,children:n.command})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Exact`}),(0,U.jsx)(`dd`,{children:n.exact?Q(t,`Có`,`Yes`):Q(t,`Không`,`No`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Tree digest`}),(0,U.jsx)(`dd`,{title:n.treeDigest??void 0,children:Lv(n.treeDigest)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`File làm stale`,`Stale files`)}),(0,U.jsx)(`dd`,{children:n.staleFilesKnown?n.staleByPaths.length:Q(t,`Chưa biết`,`Unknown`)})]})]}):(0,U.jsx)(`p`,{className:`card-empty`,children:e.verification.reasonCode?Fv(e.verification.reasonCode,t):Q(t,`Task chưa chạy verifier.`,`The task has not run a verifier.`)})}),(0,U.jsxs)(Lx,{kicker:`Token & context`,title:Nx(r,t),children:[(0,U.jsx)(`div`,{className:`context-meter`,role:`progressbar`,"aria-label":Q(t,`Mức sử dụng context`,`Context usage`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:(0,U.jsx)(`span`,{style:{width:`${o}%`}})}),(0,U.jsxs)(`dl`,{className:`evidence-list`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Turn gần nhất`,`Latest turn`)}),(0,U.jsx)(`dd`,{children:Px(e.usage.latestTurn,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Task total`}),(0,U.jsx)(`dd`,{children:Px(e.usage.taskTotal,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Session total`}),(0,U.jsx)(`dd`,{children:Px(e.usage.sessionTotal,t)})]})]})]}),(0,U.jsxs)(Lx,{kicker:`Continuation budget`,title:Fv(i.state,t),children:[(0,U.jsxs)(`dl`,{className:`budget-grid`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Còn lại`,`Remaining`)}),(0,U.jsx)(`dd`,{children:Mx(i.remaining,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Đã dùng`,`Used`)}),(0,U.jsx)(`dd`,{children:Mx(i.consumed,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Tối đa`,`Maximum`)}),(0,U.jsx)(`dd`,{children:Mx(i.maximum,t)})]})]}),i.reasonCode&&(0,U.jsx)(`p`,{className:`card-note`,children:Fv(i.reasonCode,t)})]}),(0,U.jsx)(Lx,{kicker:`Handoff`,title:a?Fv(a.state,t):Q(t,`Chưa có handoff`,`No handoff`),children:a?(0,U.jsxs)(`div`,{className:`handoff-copy`,children:[(0,U.jsx)(`p`,{children:a.summary}),a.blocker&&(0,U.jsxs)(`div`,{className:`handoff-blocker`,children:[(0,U.jsx)(`strong`,{children:`Blocker`}),(0,U.jsx)(`span`,{children:a.blocker})]}),a.nextSafeAction&&(0,U.jsxs)(`div`,{className:`next-action`,children:[(0,U.jsx)(`strong`,{children:Q(t,`Bước an toàn tiếp theo`,`Next safe action`)}),(0,U.jsx)(`span`,{children:a.nextSafeAction})]})]}):(0,U.jsx)(`p`,{className:`card-empty`,children:Q(t,`Handoff sẽ xuất hiện khi runtime ghi nhận trạng thái chuyển giao.`,`A handoff will appear when the runtime records a transfer state.`)})})]})]})}var zx=16384;function Bx(e,t){let n=new Map;for(let r of[...t,...e])n.has(r.messageRef)||n.set(r.messageRef,r);return[...n.values()].slice(0,200)}function Vx(e){let t=new Map,n=new Map;for(let r of e.slice(-500)){let e=r.kind,i=r.payload??{},a=r.messageRef;if([`agent-operation.settled`,`session.replacement-pending`,`session.replacement-committed`,`session.shutdown`].includes(String(e))){t.clear(),n.clear();continue}if(e===`message.started`&&i.role===`assistant`&&typeof a==`string`)t.set(a,{messageRef:a,text:``,thinking:!1,truncated:!1});else if(e===`message.text-delta`&&typeof a==`string`&&typeof i.delta==`string`){let e=t.get(a);if(!e)continue;let n=`${e.text}${i.delta}`;t.set(a,{...e,text:n.slice(0,zx),truncated:e.truncated||n.length>zx})}else if(e===`message.thinking-state`&&typeof a==`string`){let e=t.get(a);if(!e)continue;t.set(a,{...e,thinking:i.state!==`completed`})}else[`message.completed`,`message.failed`].includes(String(e))&&typeof a==`string`&&t.delete(a);[`activity.started`,`activity.progress`,`activity.finished`,`activity.failed`,`activity.blocked`,`activity.aborted`].includes(String(e))&&typeof r.toolCallId==`string`&&typeof i.activityRef==`string`&&typeof i.toolName==`string`&&n.set(r.toolCallId,{toolCallId:r.toolCallId,activityRef:i.activityRef,toolName:i.toolName,state:String(i.state??`unknown`)})}return{assistants:[...t.values()].slice(-2),tools:[...n.values()].slice(-8)}}var Hx=/^(?:\p{White_Space}|\p{Cc}|\p{Default_Ignorable_Code_Point})$/u,Ux=/\u001b(?:\[[0-?]*[ -/]*[@-~]|[@-_])/g;function Wx(e){for(let t of e.replace(Ux,``))if(!Hx.test(t))return!0;return!1}function Gx(e,t,n){if(!n?.complete)return{key:`${e}:${t}:active`,completionKey:null,user:``,assistant:``,operationRef:null,messageRequestId:null,startedAt:null};let r=n.startedAt??null,i=n.messageRequestId??null,a=`${i??`unknown`}:${n.operationRef??`unknown`}:${r??`unknown`}:${n.user}:${n.assistant.length}`;return{key:`${e}:${t}:complete:${a}`,completionKey:a,user:n.user,assistant:n.assistant,operationRef:n.operationRef,messageRequestId:i,startedAt:r}}function Kx(e){let t=/^\[Piagent completion gate: (CONTINUING|NOT APPROVED)\][\t ]*/i.exec(e);if(!t)return{text:e,completionGate:null};let n=t[1]?.toUpperCase()===`CONTINUING`?`continuing`:`not-approved`,r=e.indexOf(`
|
|
174
|
+
`&&(o+=1),o+=1;continue}i+=n,o+=1}return n.length<500&&(i.length>0||r.length>0)&&c(),n}function Cx({text:e,separator:t}){let n=(0,v.useMemo)(()=>Sx(e,t),[e,t]);if(n.length===0)return null;let[r,...i]=n,a=Math.min(Math.max(...n.map(e=>e.length)),40);return(0,U.jsx)(J,{sx:{overflowX:`auto`},children:(0,U.jsxs)(J,{component:`table`,className:`document-table`,children:[(0,U.jsx)(J,{component:`thead`,children:(0,U.jsx)(J,{component:`tr`,children:Array.from({length:a},(e,t)=>(0,U.jsx)(J,{component:`th`,children:r[t]??``},t))})}),(0,U.jsx)(J,{component:`tbody`,children:i.map((e,t)=>(0,U.jsx)(J,{component:`tr`,children:Array.from({length:a},(t,n)=>(0,U.jsx)(J,{component:`td`,children:e[n]??``},n))},t))})]})})}function wx({document:e,extension:t}){let n=e.text??``;return vx.has(t??``)?(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(J,{component:`pre`,className:`document-plain`,children:n}),children:(0,U.jsx)(_x,{children:n})}):yx.has(t??``)?(0,U.jsx)(Cx,{text:n,separator:t===`tsv`?` `:`,`}):(0,U.jsx)(J,{component:`pre`,className:`document-plain`,children:n})}function Tx({sessionRef:e=null}){let{locale:t}=Kv(),[n,r]=(0,v.useState)({state:`idle`}),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({state:`idle`}),[c,l]=(0,v.useState)(``),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=new AbortController;return r({state:`loading`}),a(null),s({state:`idle`}),P_(e,t.signal).then(e=>r({state:`ready`,value:e})).catch(()=>{t.signal.aborted||r({state:`error`})}),()=>t.abort()},[e]),(0,v.useEffect)(()=>{if(!i){s({state:`idle`});return}let t=new AbortController;return s({state:`loading`}),F_(e,i,t.signal).then(e=>{s({state:`ready`,value:e}),u.current?.scrollTo({top:0})}).catch(()=>{t.signal.aborted||s({state:`error`})}),()=>t.abort()},[e,i]);let d=n.value,f=c.trim().toLowerCase(),p=(0,v.useMemo)(()=>(d?.documents??[]).filter(e=>!f||e.relativePath.toLowerCase().includes(f)),[d,f]),m=(0,v.useMemo)(()=>(d?.roots??[]).map(e=>({root:e,entries:p.filter(t=>t.rootRef===e.rootRef)})).filter(e=>e.entries.length>0),[d,p]),h=p.find(e=>e.documentRef===i)??d?.documents.find(e=>e.documentRef===i);return(0,U.jsxs)(`section`,{className:`document-workspace surface`,"aria-labelledby":`documents-heading`,children:[(0,U.jsxs)(`header`,{className:`document-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(t,`Chỉ đọc · không sửa file`,`Read only · never writes`)}),(0,U.jsx)(`h2`,{id:`documents-heading`,children:Q(t,`Tài liệu`,`Documents`)})]}),(0,U.jsx)(`span`,{children:d?`${d.documents.length}${d.truncated?`+`:``} ${Q(t,`tài liệu`,`documents`)}`:`—`})]}),(0,U.jsxs)(`div`,{className:`document-body`,children:[(0,U.jsxs)(`aside`,{className:`document-list`,"aria-label":Q(t,`Danh sách tài liệu`,`Document list`),children:[(0,U.jsx)(dx,{size:`small`,fullWidth:!0,value:c,onChange:e=>l(e.target.value),placeholder:Q(t,`Lọc theo tên hoặc thư mục…`,`Filter by name or folder…`),slotProps:{htmlInput:{"aria-label":Q(t,`Lọc tài liệu`,`Filter documents`)},input:{startAdornment:(0,U.jsx)(py,{position:`start`,children:(0,U.jsx)(fx,{fontSize:`small`})})}}}),n.state===`loading`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Đang quét tài liệu…`,`Scanning for documents…`)}),n.state===`error`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Không đọc được danh sách tài liệu.`,`The document list could not be read.`)}),d?.state===`unavailable`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Iv(d.reasonCode,t)}),n.state===`ready`&&d?.state===`ready`&&m.length===0&&(0,U.jsx)(`p`,{className:`document-empty`,children:f?Q(t,`Không có tài liệu nào khớp bộ lọc.`,`No document matches the filter.`):Q(t,`Chưa tìm thấy tài liệu nào.`,`No documents were found.`)}),m.map(e=>(0,U.jsxs)(`div`,{className:`document-group`,children:[(0,U.jsxs)(`div`,{className:`document-group-heading`,children:[(0,U.jsx)(`strong`,{children:xx(e.root,t)}),(0,U.jsx)(`span`,{title:e.root.path,children:e.root.path})]}),e.entries.map(e=>(0,U.jsxs)(cf,{component:`button`,type:`button`,className:`document-row`,selected:e.documentRef===i,onClick:()=>a(e.documentRef),children:[(0,U.jsx)(Nh,{fontSize:`small`,"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`document-row-copy`,children:[(0,U.jsx)(`strong`,{children:e.name}),(0,U.jsx)(`small`,{children:e.relativePath})]}),(0,U.jsxs)(`span`,{className:`document-row-meta`,children:[e.extension,` · `,bx(e.sizeBytes)]})]},e.documentRef))]},e.root.rootRef)),d?.truncated&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Danh sách đã đạt giới hạn; dùng bộ lọc để thu hẹp.`,`The list reached its limit; use the filter to narrow it.`)})]}),(0,U.jsxs)(`div`,{className:`document-viewer`,ref:u,children:[!i&&(0,U.jsxs)(`div`,{className:`document-placeholder`,children:[(0,U.jsx)(Nh,{"aria-hidden":`true`}),(0,U.jsx)(X,{variant:`body2`,children:Q(t,`Chọn một tài liệu để đọc nội dung tại đây.`,`Pick a document to read it here.`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:Q(t,`Hỗ trợ .md .txt .csv .json .yaml .docx .pdf`,`Supports .md .txt .csv .json .yaml .docx .pdf`)})]}),i&&o.state===`loading`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Đang mở tài liệu…`,`Opening the document…`)}),i&&o.state===`error`&&(0,U.jsx)(`p`,{className:`document-empty`,children:Q(t,`Không mở được tài liệu này.`,`This document could not be opened.`)}),o.state===`ready`&&o.value&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`document-toolbar`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:o.value.name??h?.name??`—`}),(0,U.jsx)(`small`,{children:o.value.relativePath??h?.relativePath??``})]}),(0,U.jsxs)(`div`,{className:`document-badges`,children:[o.value.format&&(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:o.value.format}),o.value.truncated&&(0,U.jsx)(lu,{size:`small`,color:`warning`,variant:`outlined`,label:Q(t,`Đã cắt bớt`,`Truncated`)}),o.value.redacted&&(0,U.jsx)(lu,{size:`small`,color:`warning`,variant:`outlined`,label:Q(t,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`)})]})]}),o.value.state===`unavailable`?(0,U.jsx)(`p`,{className:`document-empty`,children:Iv(o.value.reasonCode,t)}):(0,U.jsx)(`article`,{className:`document-content`,children:(0,U.jsx)(wx,{document:o.value,extension:h?.extension})})]})]})]})]})}function Ex(e,t=`vi`){let n=e.state===`running`?`running`:e.state===`failed`?`failed`:`passed`,r=n===`running`?t===`vi`?`đang chạy`:`running`:n===`failed`?t===`vi`?`thất bại`:`failed`:t===`vi`?`hoàn tất`:`completed`,i=e.startedAt??e.finishedAt??``;return{activityRef:`live.${e.toolCallRef}`,kind:[`bash`,`shell`,`exec`].includes(e.toolLabel)?`command`:`tool`,state:n,label:`${e.toolLabel} ${r}`,preview:t===`vi`?`Cập nhật trực tiếp từ Gateway`:`Live update from the Gateway`,toolCallId:e.toolCallRef,toolName:e.toolLabel,commandDigest:null,logRef:null,exitCode:null,exitCodeExact:!1,startedAt:i,finishedAt:n===`running`?null:e.finishedAt??i}}function Dx(e,t=`vi`){let n=e.state===`failed`?t===`vi`?`Lượt chạy gặp lỗi`:`Operation failed`:e.state===`blocked`?t===`vi`?`Lượt chạy bị chặn`:`Operation blocked`:e.state===`aborted`?t===`vi`?`Lượt chạy đã dừng`:`Operation stopped`:t===`vi`?`Chưa xác định kết quả lượt chạy`:`Operation outcome unknown`;return{activityRef:e.activityRef,kind:`system`,state:e.state,label:n,preview:e.reasonCode,toolCallId:null,toolName:null,commandDigest:null,logRef:null,exitCode:null,exitCodeExact:!1,startedAt:e.settledAt,finishedAt:e.settledAt}}function Ox(e,t,n,r=`vi`,i){let a=[...e,...t],o=new Set(a.map(e=>e.activityRef)),s=n.filter(e=>!o.has(e.activityRef)).map(e=>Dx(e,r));if(i===void 0)return{rows:[...e,...s,...t],terminalCount:s.length,runningCount:e.length};let c=i.filter(e=>e.state===`running`).map(e=>Ex(e,r));return{rows:[...c,...s,...t],terminalCount:s.length,runningCount:c.length}}function kx(e,t=`vi`){return e.state===`passed`&&/ recovered$/i.test(e.label)?t===`vi`?`Đã khôi phục`:`Recovered`:e.state===`passed`&&/ warning$/i.test(e.label)?t===`vi`?`Đã xử lý cảnh báo`:`Handled warning`:e.state===`passed`&&e.exitCodeExact?`Pass · exit ${e.exitCode??0}`:e.state===`failed`&&e.exitCodeExact?`Fail · exit ${e.exitCode??`?`}`:e.state===`blocked`?`Blocked`:e.state===`aborted`?t===`vi`?`Đã dừng`:`Stopped`:e.state===`unknown`?t===`vi`?`Chưa xác định`:`Unknown`:e.state===`failed`?t===`vi`?`Thất bại`:`Failed`:e.state===`running`?t===`vi`?`Đang chạy`:`Running`:e.state.replaceAll(`-`,` `)}function Ax(e,t=`vi`){let n=Date.parse(e.startedAt),r=e.finishedAt?Date.parse(e.finishedAt):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r)||r<n)return t===`vi`?`Thời gian chưa xác định`:`Unknown duration`;let i=Math.round((r-n)/1e3);return i<60?`${i}s`:`${Math.floor(i/60)}m ${i%60}s`}function jx({activity:e,preview:t,onPreview:n,locale:r}){return(0,U.jsxs)(`article`,{className:`activity-row`,children:[(0,U.jsx)(`span`,{className:`activity-state tone-${Lv(e.state)}`,"aria-label":e.state}),(0,U.jsxs)(`div`,{className:`activity-copy`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.label}),(0,U.jsx)(`span`,{children:e.kind})]}),(0,U.jsx)(`p`,{children:e.preview||Q(r,`Không có mô tả ngắn`,`No short description`)}),t&&(0,U.jsxs)(`div`,{className:`log-preview ${t.state===`error`?`error-state`:``}`,children:[t.state===`loading`?Q(r,`Đang tải log ngắn…`,`Loading log preview…`):t.state===`error`?Q(r,`Log preview không còn sẵn sàng.`,`Log preview is no longer available.`):t.value?.preview??`${Q(r,`Không có nội dung log`,`No log content`)} · ${t.value?.reasonCode??`unavailable`}`,t.value?.truncated&&(0,U.jsx)(`small`,{children:Q(r,`Preview đã được rút gọn`,`Preview truncated`)})]})]}),(0,U.jsxs)(`div`,{className:`activity-result`,children:[(0,U.jsx)(`strong`,{children:kx(e,r)}),(0,U.jsx)(`span`,{children:Ax(e,r)}),e.logRef&&n&&(0,U.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":!!t,children:t?Q(r,`Ẩn log`,`Hide log`):Q(r,`Xem log`,`View log`)})]})]})}function Mx({snapshot:e,sessionRef:t,terminalActivities:n=[],liveActivities:r}){let{locale:i}=Kv(),[a,o]=(0,v.useState)({}),s=e?.activity.running??[],c=e?.activity.recent??[],{rows:l,terminalCount:u,runningCount:d}=Ox(s,c,n,i,r),f=e=>{if(a[e.activityRef]){o(t=>({...t,[e.activityRef]:void 0}));return}o(t=>({...t,[e.activityRef]:{state:`loading`}})),(t?t_(t,e.activityRef):y_(e.activityRef)).then(t=>o(n=>({...n,[e.activityRef]:{state:`ready`,value:t}}))).catch(()=>o(t=>({...t,[e.activityRef]:{state:`error`}})))};return(0,U.jsxs)(`section`,{className:`activity-panel surface`,"aria-labelledby":`activity-title`,children:[(0,U.jsxs)(`header`,{className:`panel-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Activity`}),(0,U.jsx)(`h2`,{id:`activity-title`,children:Q(i,`Tool, command và kết quả lượt chạy`,`Tools, commands, and operation outcomes`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`running-count`,children:[d,` `,Q(i,`đang chạy`,`running`)]}),(0,U.jsxs)(`span`,{children:[c.length+u,` `,Q(i,`gần đây`,`recent`)]})]})]}),(0,U.jsxs)(`div`,{className:`activity-list`,children:[l.map(e=>(0,U.jsx)(jx,{activity:e,preview:a[e.activityRef],onPreview:e.logRef?()=>f(e):void 0,locale:i},e.activityRef)),l.length===0&&(0,U.jsx)(`div`,{className:`activity-empty`,children:Q(i,`Chưa có tool, command hoặc kết quả lượt chạy nào trong timeline hiện tại.`,`No tools, commands, or operation outcomes in the current timeline.`)})]}),e?.activity.page.truncated&&(0,U.jsx)(`footer`,{className:`panel-footnote`,children:Q(i,`Timeline đã được rút gọn theo giới hạn local.`,`The timeline was truncated to local limits.`)})]})}function Nx(e,t=`vi`){return e===null||!Number.isFinite(e)?t===`vi`?`Không có dữ liệu`:`No data`:Math.abs(e)<1e3?String(Math.round(e)):Math.abs(e)<1e6?`${(e/1e3).toFixed(e>=1e4?0:1)}k`:`${(e/1e6).toFixed(1)}m`}function Px(e,t=`vi`){return e.state!==`known`||e.tokens===null||e.percent===null?t===`vi`?`Context chưa xác định`:`Unknown context`:`${Nx(e.tokens,t)} / ${Nx(e.contextWindow,t)} · ${e.percent.toFixed(1)}%`}function Fx(e,t=`vi`){return e.state===`known`?`↑ ${Nx(e.input,t)} · ↓ ${Nx(e.output,t)}`:t===`vi`?`Không có dữ liệu`:`No data`}function Ix(e,t=`vi`){return e?e.state===`passed`?e.exitCodeExact?`Pass · exit ${e.exitCode??0}`:t===`vi`?`Pass · exit chưa xác định`:`Pass · unknown exit`:e.state===`failed`?e.exitCodeExact?`Fail · exit ${e.exitCode??`?`}`:t===`vi`?`Fail · exit chưa xác định`:`Fail · unknown exit`:e.state===`stale`?e.staleFilesKnown?`Stale · ${e.staleByPaths.length} file`:t===`vi`?`Stale · file chưa xác định`:`Stale · unknown files`:e.state.replaceAll(`-`,` `):t===`vi`?`Chưa có verifier gần nhất`:`No recent verifier`}function Lx(e,t=`vi`){return e.task?.blocker??e.task?.reasonCode??e.verification.reasonCode??e.health.issues.find(e=>e.severity===`error`)?.message??(t===`vi`?`Không có blocker được ghi nhận`:`No recorded blocker`)}function Rx({kicker:e,title:t,children:n}){return(0,U.jsxs)(`section`,{className:`evidence-card surface`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:e}),(0,U.jsx)(`h3`,{children:t}),n]})}function zx({snapshot:e}){let{locale:t}=Kv(),n=e.verification.latest,r=e.usage.context,i=e.continuation,a=e.handoff,o=r.state===`known`&&r.percent!==null?Math.max(0,Math.min(100,r.percent)):0;return(0,U.jsxs)(`section`,{className:`evidence-section`,"aria-labelledby":`evidence-title`,children:[(0,U.jsxs)(`header`,{className:`section-title-row`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Completion evidence`}),(0,U.jsx)(`h2`,{id:`evidence-title`,children:Q(t,`Verifier, usage và handoff`,`Verifier, usage, and handoff`)})]}),(0,U.jsx)(`span`,{children:Lx(e,t)})]}),(0,U.jsxs)(`div`,{className:`evidence-grid`,children:[(0,U.jsx)(Rx,{kicker:Q(t,`Verifier gần nhất`,`Latest verifier`),title:Ix(n,t),children:n?(0,U.jsxs)(`dl`,{className:`evidence-list`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Command`}),(0,U.jsx)(`dd`,{title:n.command,children:n.command})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Exact`}),(0,U.jsx)(`dd`,{children:n.exact?Q(t,`Có`,`Yes`):Q(t,`Không`,`No`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Tree digest`}),(0,U.jsx)(`dd`,{title:n.treeDigest??void 0,children:Rv(n.treeDigest)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`File làm stale`,`Stale files`)}),(0,U.jsx)(`dd`,{children:n.staleFilesKnown?n.staleByPaths.length:Q(t,`Chưa biết`,`Unknown`)})]})]}):(0,U.jsx)(`p`,{className:`card-empty`,children:e.verification.reasonCode?Iv(e.verification.reasonCode,t):Q(t,`Task chưa chạy verifier.`,`The task has not run a verifier.`)})}),(0,U.jsxs)(Rx,{kicker:`Token & context`,title:Px(r,t),children:[(0,U.jsx)(`div`,{className:`context-meter`,role:`progressbar`,"aria-label":Q(t,`Mức sử dụng context`,`Context usage`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:(0,U.jsx)(`span`,{style:{width:`${o}%`}})}),(0,U.jsxs)(`dl`,{className:`evidence-list`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Turn gần nhất`,`Latest turn`)}),(0,U.jsx)(`dd`,{children:Fx(e.usage.latestTurn,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Task total`}),(0,U.jsx)(`dd`,{children:Fx(e.usage.taskTotal,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Session total`}),(0,U.jsx)(`dd`,{children:Fx(e.usage.sessionTotal,t)})]})]})]}),(0,U.jsxs)(Rx,{kicker:`Continuation budget`,title:Iv(i.state,t),children:[(0,U.jsxs)(`dl`,{className:`budget-grid`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Còn lại`,`Remaining`)}),(0,U.jsx)(`dd`,{children:Nx(i.remaining,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Đã dùng`,`Used`)}),(0,U.jsx)(`dd`,{children:Nx(i.consumed,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Tối đa`,`Maximum`)}),(0,U.jsx)(`dd`,{children:Nx(i.maximum,t)})]})]}),i.reasonCode&&(0,U.jsx)(`p`,{className:`card-note`,children:Iv(i.reasonCode,t)})]}),(0,U.jsx)(Rx,{kicker:`Handoff`,title:a?Iv(a.state,t):Q(t,`Chưa có handoff`,`No handoff`),children:a?(0,U.jsxs)(`div`,{className:`handoff-copy`,children:[(0,U.jsx)(`p`,{children:a.summary}),a.blocker&&(0,U.jsxs)(`div`,{className:`handoff-blocker`,children:[(0,U.jsx)(`strong`,{children:`Blocker`}),(0,U.jsx)(`span`,{children:a.blocker})]}),a.nextSafeAction&&(0,U.jsxs)(`div`,{className:`next-action`,children:[(0,U.jsx)(`strong`,{children:Q(t,`Bước an toàn tiếp theo`,`Next safe action`)}),(0,U.jsx)(`span`,{children:a.nextSafeAction})]})]}):(0,U.jsx)(`p`,{className:`card-empty`,children:Q(t,`Handoff sẽ xuất hiện khi runtime ghi nhận trạng thái chuyển giao.`,`A handoff will appear when the runtime records a transfer state.`)})})]})]})}var Bx=16384;function Vx(e,t){let n=new Map;for(let r of[...t,...e])n.has(r.messageRef)||n.set(r.messageRef,r);return[...n.values()].slice(0,200)}function Hx(e){let t=new Map,n=new Map;for(let r of e.slice(-500)){let e=r.kind,i=r.payload??{},a=r.messageRef;if([`agent-operation.settled`,`session.replacement-pending`,`session.replacement-committed`,`session.shutdown`].includes(String(e))){t.clear(),n.clear();continue}if(e===`message.started`&&i.role===`assistant`&&typeof a==`string`)t.set(a,{messageRef:a,text:``,thinking:!1,truncated:!1});else if(e===`message.text-delta`&&typeof a==`string`&&typeof i.delta==`string`){let e=t.get(a);if(!e)continue;let n=`${e.text}${i.delta}`;t.set(a,{...e,text:n.slice(0,Bx),truncated:e.truncated||n.length>Bx})}else if(e===`message.thinking-state`&&typeof a==`string`){let e=t.get(a);if(!e)continue;t.set(a,{...e,thinking:i.state!==`completed`})}else[`message.completed`,`message.failed`].includes(String(e))&&typeof a==`string`&&t.delete(a);[`activity.started`,`activity.progress`,`activity.finished`,`activity.failed`,`activity.blocked`,`activity.aborted`].includes(String(e))&&typeof r.toolCallId==`string`&&typeof i.activityRef==`string`&&typeof i.toolName==`string`&&n.set(r.toolCallId,{toolCallId:r.toolCallId,activityRef:i.activityRef,toolName:i.toolName,state:String(i.state??`unknown`)})}return{assistants:[...t.values()].slice(-2),tools:[...n.values()].slice(-8)}}var Ux=/^(?:\p{White_Space}|\p{Cc}|\p{Default_Ignorable_Code_Point})$/u,Wx=/\u001b(?:\[[0-?]*[ -/]*[@-~]|[@-_])/g;function Gx(e){for(let t of e.replace(Wx,``))if(!Ux.test(t))return!0;return!1}function Kx(e,t,n){if(!n?.complete)return{key:`${e}:${t}:active`,completionKey:null,user:``,assistant:``,operationRef:null,messageRequestId:null,startedAt:null};let r=n.startedAt??null,i=n.messageRequestId??null,a=`${i??`unknown`}:${n.operationRef??`unknown`}:${r??`unknown`}:${n.user}:${n.assistant.length}`;return{key:`${e}:${t}:complete:${a}`,completionKey:a,user:n.user,assistant:n.assistant,operationRef:n.operationRef,messageRequestId:i,startedAt:r}}function qx(e){let t=/^\[Piagent completion gate: (CONTINUING|NOT APPROVED)\][\t ]*/i.exec(e);if(!t)return{text:e,completionGate:null};let n=t[1]?.toUpperCase()===`CONTINUING`?`continuing`:`not-approved`,r=e.indexOf(`
|
|
175
175
|
|
|
176
|
-
`,t[0].length);return{text:r<0?``:e.slice(r+2).trimStart(),completionGate:n}}var qx=new Set([`provider-auth-expired`,`provider-auth-required`,`provider-rate-limited`,`provider-unavailable`,`provider-response-failed`,`assistant-output-incomplete`]);function Jx(e){let t=e.content.reasonCode;return e.role===`assistant`&&e.toolCalls.length===0&&e.content.state===`unavailable`&&t&&(qx.has(t)||t.startsWith(`company-`))?t:null}function Yx(e){let t=Kx(e);return t.completionGate===null&&Wx(t.text)?t.text:null}function Xx(e,t){let n=e?.trim(),r=t.trim();return!!(n&&r&&(n===r||n.startsWith(`/`)&&n.endsWith(` ${r}`)))}function Zx(e,t){if(e.agentOperationId&&t.operationRef&&e.agentOperationId!==t.operationRef)return!1;if(e.messageRequestId&&t.messageRequestId)return e.messageRequestId===t.messageRequestId;if(e.agentOperationId&&t.operationRef)return e.agentOperationId===t.operationRef;let n=Date.parse(e.recordedAt),r=Date.parse(t.startedAt??``);return Number.isFinite(n)&&Number.isFinite(r)&&n>=r}function Qx(e,t,n){let r=t.trim();if(!r)return-1;for(let t=e.length-1;t>=0;--t){let i=e[t];if(i?.role===`user`&&Xx(i.content.text,r)&&Zx(i,n))return t}return-1}function $x(e,t,n){return Qx(e,t,n)>=0}function eS(e,t,n,r){let i=Qx(e,t,r);if(i<0)return!1;let a=Yx(n)?.trim()??``;if(!a)return!0;let o=e[i]?.messageRef??null;for(let t=i+1;t<e.length;t+=1){let n=e[t];if(n?.role===`user`)return!1;if(!(n?.role!==`assistant`&&n?.role!==`custom`||n.toolCalls.length>0)&&!(o&&n.parentMessageRef&&n.parentMessageRef!==o)&&Yx(n.content.text??``)?.trim()===a)return!0}return!1}function tS(e,t,n){let r=Qx(e,t,n);if(r<0)return!1;let i=e[r]?.messageRef??null;for(let t=r+1;t<e.length;t+=1){let n=e[t];if(n?.role===`user`)return!1;if(!(n?.role!==`assistant`&&n?.role!==`custom`||n.toolCalls.length>0)&&!(i&&n.parentMessageRef&&n.parentMessageRef!==i)&&(Yx(n.content.text??``)||Jx(n)))return!0}return!1}function nS(e){let t=[],n=new Map,r=new Set,i=null,a=!1,o=null;for(let s of e){if(s.role===`user`){n.clear(),r.add(s.messageRef),i=s.messageRef,t.push(s),a=!1,o=null;continue}if(s.role!==`assistant`&&s.role!==`custom`||(s.parentMessageRef?!r.has(s.parentMessageRef):i===null)||s.toolCalls.length>0)continue;if(Jx(s)){if(a)continue;o?t[t.indexOf(o)]=s:t.push(s),o=s;continue}let e=Yx(s.content.text??``);if(!e)continue;a=!0,o&&=(t.splice(t.indexOf(o),1),null);let c=`${s.role}:${e.trim()}`,l=n.get(c);l===void 0?(n.set(c,t.length),t.push(s)):t[l]=s}return t}function rS(e,t,n){return e===`vi`?t:n}var iS={txt:`text/plain`,text:`text/plain`,md:`text/markdown`,markdown:`text/markdown`,csv:`text/csv`,tsv:`text/tab-separated-values`,json:`application/json`,yaml:`application/yaml`,yml:`application/yaml`,pdf:`application/pdf`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`},aS=Object.keys(iS).map(e=>`.${e}`).join(`,`),oS=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]);function sS(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024).toFixed(+(e<10240))} KiB`}function cS(e,t){let n=e.truncated?` · ${rS(t,`đã cắt bớt`,`truncated`)}`:``;return e.kind===`image`?`${rS(t,`Ảnh`,`Image`)} · ${sS(e.sizeBytes)}`:e.kind===`document`?`${rS(t,`Tài liệu`,`Document`)} · ${sS(e.sourceBytes)} → ${sS(e.sizeBytes)} ${rS(t,`văn bản`,`text`)}${n}`:`File · ${sS(e.sizeBytes)}${n}`}function lS(e){return[...e,...Object.entries(iS).filter(([,t])=>e.has(t)).map(([e])=>`.${e}`)].join(`,`)}function uS(e){return!!(e&&[...e.types].includes(`Files`))}async function dS(e){let{snapshot:t,locale:n}=e,r=[...e.existing],i=null,a=Math.max(0,4-r.length);e.files.length>a&&(i=rS(n,`Chỉ nhận tối đa 4 file mỗi tin nhắn; đã bỏ qua ${e.files.length-a} file.`,`At most 4 files per message; ${e.files.length-a} skipped.`));for(let o of[...e.files].slice(0,a)){let a=iS[o.name.split(`.`).pop()?.toLowerCase()??``];if(!a){i=`${o.name}: ${rS(n,`loại file chưa được hỗ trợ.`,`unsupported file type.`)}`;continue}if(!e.allowed.has(a)){i=`${o.name}: ${a===`application/pdf`?rS(n,`host chưa cài pdftotext (poppler) nên chưa đọc được .pdf.`,`this host has no pdftotext (poppler), so .pdf cannot be read.`):rS(n,`phiên Pi hiện tại không nhận loại file này.`,`the current Pi session does not accept this file type.`)}`;continue}let s=a.startsWith(`image/`)||oS.has(a)?Math.min(t.capabilities.limits.maxAttachmentFileBytes,8388608):262144;if(o.size<1||o.size>s||r.reduce((e,t)=>e+t.sourceBytes,0)+o.size>t.capabilities.limits.maxAttachmentTotalBytes){i=`${o.name}: ${oS.has(a)?rS(n,`vượt giới hạn gửi trực tiếp ${sS(s)}. Hãy đặt tài liệu lớn trong project rồi mở ở mục Tài liệu; Pi sẽ đọc theo phần thay vì nhét cả file vào chat.`,`exceeds the ${sS(s)} direct-send limit. Put a large document in the project and open Documents; Pi can read it in parts instead of placing the whole file in chat.`):rS(n,`vượt giới hạn đính kèm (tối đa ${sS(s)}).`,`attachment limit exceeded (max ${sS(s)}).`)}`;continue}let c=new Uint8Array(await o.arrayBuffer()),l=``;for(let e=0;e<c.length;e+=32768)l+=String.fromCharCode(...c.subarray(e,e+32768));let u=await e.stage(await K_(t,e.messageRequestId,{displayName:o.name,declaredMimeType:a,dataBase64:btoa(l)}));if(u.resultCode!==`staged`||!(`attachment`in u)||!u.attachment){i=`${o.name}: ${Fv(u.error?.code??u.resultCode,n)}`;continue}r=[...r,u.attachment]}return{attachments:r,status:i}}async function fS(e){let t=await e.stage(q_(e.snapshot,e.messageRequestId,e.attachmentRef));return t.messageType===`discard-receipt`&&t.resultCode===`discarded`?{discarded:!0,status:null}:{discarded:!1,status:`${rS(e.locale,`Chưa thể bỏ file`,`Unable to remove file`)} · ${Fv(t.error?.code??t.resultCode,e.locale)}`}}function pS({snapshot:e,events:t,refreshSnapshot:n}){let{locale:r}=Gv(),[i,a]=(0,v.useState)(),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(()=>`message-request.${crypto.randomUUID()}`),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),k=(0,v.useRef)(0),A=(0,v.useMemo)(()=>Vx(t),[t]),j=[...t].reverse().find(e=>[`message.completed`,`message.failed`,`agent-operation.settled`].includes(String(e.kind)))?.eventCursor??null;(0,v.useEffect)(()=>{let e=new AbortController;return s(!0),a(void 0),y_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0).finally(()=>s(!1)),()=>e.abort()},[e.identity.sessionRef]),(0,v.useEffect)(()=>{w([]),S(`message-request.${crypto.randomUUID()}`)},[e.identity.sessionRef]),(0,v.useEffect)(()=>{let e=e=>{e.dataTransfer&&[...e.dataTransfer.types].includes(`Files`)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]),(0,v.useEffect)(()=>{if(!j)return;let e=new AbortController,t=window.setTimeout(()=>{y_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0)},80);return()=>{window.clearTimeout(t),e.abort()}},[j]);let M=async()=>{try{let e=await b_();return h(e),e}catch{return}};(0,v.useEffect)(()=>{let e=new AbortController;return b_(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[e.identity.sessionRef,e.revision.queueRevision]);let N=async()=>{let e=i?.page.nextBeforeCursor;if(e)try{let t=await y_(e,i.page.limit);a(e=>e?{...e,items:Bx(e.items,t.items),page:t.page}:t)}catch{}},P=(0,v.useMemo)(()=>i?.state===`ready`?nS(i.items):[],[i]),F=e.capabilities.capabilities[`control.chat`],I=F.status===`available`?F.actions:null,L=!!I?.send.available,R=e.capabilities.capabilities[`control.resumeAndContinue`].status===`available`,ee=L||R,te=e.capabilities.capabilities.attachments,z=te.status===`available`,B=(0,v.useMemo)(()=>new Set(te.status===`available`?te.mimeTypes:[]),[te]),V=(0,v.useMemo)(()=>lS(B),[B]),ne=z&&!u&&!T&&C.length<4,re=e.session.operation.liveness===`running`,ie=async()=>{await n?.(),await M()},ae=async t=>{let n=c.trim();if(!(!n||u||(t===`resume-and-continue`?!R:!L))){d(!0),p(null);try{let i=C.length?{messageRequestId:x,attachmentRefs:C.map(e=>e.attachmentRef)}:void 0,a=t===`resume-and-continue`?await D_(await Q_(e,n,i)):await w_(await G_(e,n,t,i));[`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(l(``),w([]),S(`message-request.${crypto.randomUUID()}`),p(a.resultCode===`dispatch-observed`?Q(r,`Đã gửi vào Pi session`,`Sent to the Pi session`):Q(r,`Pi đã nhận yêu cầu`,`Pi received the request`))):a.resultCode===`held`?(l(``),p(Q(r,`Đã giữ trong hàng đợi`,`Held in the queue`))):a.resultCode===`resumed-not-dispatched`?p(Q(r,`Task đã mở lại nhưng tin nhắn chưa được gửi; nội dung vẫn được giữ để kiểm tra lại.`,`The task resumed but the message was not sent; the content remains for review.`)):p(`${Q(r,`Chưa gửi`,`Not sent`)} · ${Fv(a.resultCode,r)}`),await ie()}catch{p(Q(r,`Không thể gửi; trạng thái Pi có thể đã thay đổi.`,`Unable to send; Pi state may have changed.`))}finally{d(!1)}}},oe=async t=>{if(!(!t?.length||!z||T)){E(!0),p(null);try{let n=await dS({files:t,snapshot:e,messageRequestId:x,existing:C,allowed:B,locale:r,stage:F_});w(n.attachments),p(n.status)}catch{p(Q(r,`Không thể đính kèm; file không được gửi vào Pi.`,`Unable to attach the file; it was not sent to Pi.`))}finally{E(!1)}}},se=()=>{k.current=0,O(!1)},H=e=>{uS(e.dataTransfer)&&(e.preventDefault(),se(),ne&&oe(e.dataTransfer.files))},ce=async t=>{if(!(u||T)){E(!0),p(null);try{let n=await fS({snapshot:e,messageRequestId:x,attachmentRef:t,locale:r,stage:F_});n.discarded?w(e=>e.filter(e=>e.attachmentRef!==t)):p(n.status)}catch{p(Q(r,`Không thể bỏ file; trạng thái Pi có thể đã thay đổi.`,`Unable to remove the file; Pi state may have changed.`))}finally{E(!1)}}},le=async(t,n,i)=>{if(!u){d(!0),p(null);try{let a=await w_(await J_(e,t,t===`queue.update`?await Y_(n,i?.trim()??``):t===`queue.delete`?{queueItemRef:n}:{queueItemRef:n,messageRequestId:`message-request.${crypto.randomUUID()}`}));[`updated`,`deleted`,`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(_(null),b(``),p(Fv(a.resultCode,r))):p(`${Q(r,`Chưa thay đổi`,`Not changed`)} · ${Fv(a.resultCode,r)}`),await ie()}catch{p(Q(r,`Hàng đợi đã thay đổi; đã tải lại trạng thái mới nhất.`,`The queue changed; the latest state has been reloaded.`)),await ie()}finally{d(!1)}}};return(0,U.jsxs)(`section`,{className:`chat-panel surface`,"aria-labelledby":`chat-heading`,"data-dragging":D||void 0,onDragEnter:e=>{uS(e.dataTransfer)&&(k.current+=1,O(!0))},onDragOver:e=>{uS(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=ne?`copy`:`none`)},onDragLeave:e=>{uS(e.dataTransfer)&&(--k.current,k.current<=0&&se())},onDrop:H,children:[D&&(0,U.jsxs)(`div`,{className:`chat-drop-overlay`,role:`status`,children:[(0,U.jsx)(`strong`,{children:ne?Q(r,`Thả tài liệu vào đây`,`Drop documents here`):C.length>=4?Q(r,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):Q(r,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),ne&&(0,U.jsx)(`small`,{children:Q(r,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),(0,U.jsxs)(`header`,{className:`chat-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Đúng Pi session hiện tại`,`Exact current Pi session`)}),(0,U.jsx)(`h2`,{id:`chat-heading`,children:`Chat`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{children:[P.length,` `,Q(r,`message gần nhất`,`recent messages`)]}),(0,U.jsx)(`span`,{className:`chat-read-state`,children:Q(r,`Streaming trực tiếp`,`Live streaming`)})]})]}),(0,U.jsxs)(`div`,{className:`chat-body`,"aria-live":`polite`,children:[i?.page.hasOlder&&(0,U.jsx)(`button`,{type:`button`,className:`load-older`,onClick:()=>void N(),children:Q(r,`Tải message cũ hơn`,`Load older messages`)}),o&&(0,U.jsx)(`p`,{className:`chat-empty`,children:Q(r,`Đang tải transcript hiện tại…`,`Loading the current transcript…`)}),!o&&i?.state===`unavailable`&&(0,U.jsxs)(`p`,{className:`chat-empty`,children:[Q(r,`Transcript cần đồng bộ lại`,`Transcript needs resync`),` · `,Fv(i.reasonCode,r)]}),!o&&i?.state===`ready`&&P.length===0&&A.assistants.length===0&&(0,U.jsx)(`p`,{className:`chat-empty`,children:Q(r,`Chưa có message trong Pi session này.`,`There are no messages in this Pi session.`)}),P.map(e=>e.role===`tool-result`?(0,U.jsxs)(`article`,{className:`chat-tool-result`,children:[(0,U.jsx)(`strong`,{children:e.toolCalls[0]?.toolName??`Tool`}),(0,U.jsx)(`span`,{children:Q(r,`Kết quả chi tiết nằm trong Activity`,`Detailed output is available in Activity`)})]},e.messageRef):(0,U.jsxs)(`article`,{className:`chat-message chat-${e.role}`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.role===`user`?Q(r,`Anh`,`You`):e.role===`custom`?Q(r,`Biên nhận Piagent`,`Piagent receipt`):`Pi`}),(0,U.jsx)(`time`,{children:new Date(e.recordedAt).toLocaleTimeString(r===`vi`?`vi-VN`:`en-US`,{hour:`2-digit`,minute:`2-digit`})})]}),(0,U.jsx)(`p`,{children:e.content.text||(e.content.imageCount?`${e.content.imageCount} ${Q(r,`ảnh đính kèm`,`attached images`)}`:Q(r,`Message trống`,`Empty message`))}),(e.content.redacted||e.content.truncated)&&(0,U.jsx)(`small`,{children:e.content.redacted?Q(r,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`):Q(r,`Nội dung đã rút gọn`,`Content truncated`)})]},e.messageRef)),A.assistants.map(e=>(0,U.jsxs)(`article`,{className:`chat-message chat-assistant chat-streaming`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:`Pi`}),(0,U.jsx)(`span`,{className:`stream-indicator`,children:Q(r,`Đang trả lời`,`Responding`)})]}),(0,U.jsx)(`p`,{children:e.text||(e.thinking?Q(r,`Đang suy nghĩ…`,`Thinking…`):Q(r,`Đang chuẩn bị câu trả lời…`,`Preparing a response…`))}),e.truncated&&(0,U.jsx)(`small`,{children:Q(r,`Live preview đã đạt giới hạn`,`Live preview limit reached`)})]},e.messageRef)),A.tools.filter(e=>[`started`,`progress`].includes(e.state)).map(e=>(0,U.jsxs)(`article`,{className:`chat-tool-live`,children:[(0,U.jsx)(`span`,{className:`tool-spinner`,"aria-hidden":`true`}),(0,U.jsx)(`strong`,{children:e.toolName}),(0,U.jsx)(`span`,{children:Fv(e.state,r)})]},e.toolCallId))]}),m?.state===`ready`&&m.items.length>0&&(0,U.jsxs)(`section`,{className:`held-queue`,"aria-label":Q(r,`Tin nhắn đang giữ`,`Held messages`),children:[(0,U.jsxs)(`div`,{className:`held-queue-heading`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Đang giữ ${m.heldCount} tin`,`${m.heldCount} held messages`)}),m.quarantinedCount>0&&(0,U.jsxs)(`span`,{children:[m.quarantinedCount,` `,Q(r,`tin cần kiểm tra`,`need review`)]})]}),(0,U.jsx)(`ol`,{children:m.items.map(e=>(0,U.jsxs)(`li`,{"data-state":e.state,children:[g===e.queueItemRef?(0,U.jsx)(`textarea`,{"aria-label":Q(r,`Sửa tin nhắn đang giữ`,`Edit held message`),rows:2,maxLength:65536,value:y,onChange:e=>b(e.target.value)}):(0,U.jsx)(`p`,{children:e.preview}),(0,U.jsx)(`div`,{children:g===e.queueItemRef?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,disabled:u||!y.trim(),onClick:()=>void le(`queue.update`,e.queueItemRef,y),children:Q(r,`Lưu`,`Save`)}),(0,U.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{_(null),b(``)},children:Q(r,`Hủy`,`Cancel`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||!I?.dispatchHeld.available,onClick:()=>void le(`queue.dispatch`,e.queueItemRef),children:Q(r,`Gửi`,`Send`)}),(0,U.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||e.redacted||e.truncated||!I?.editHeld.available,title:e.redacted||e.truncated?Q(r,`Không sửa từ preview đã che hoặc rút gọn`,`Redacted or truncated previews cannot be edited`):void 0,onClick:()=>{_(e.queueItemRef),b(e.preview)},children:Q(r,`Sửa`,`Edit`)}),(0,U.jsx)(`button`,{type:`button`,disabled:u||!I?.deleteHeld.available,onClick:()=>void le(`queue.delete`,e.queueItemRef),children:Q(r,`Xóa`,`Delete`)})]})}),(e.redacted||e.truncated||e.state===`quarantined`)&&(0,U.jsx)(`small`,{children:e.state===`quarantined`?Q(r,`Lần gửi trước chưa xác định; không tự gửi lại`,`The previous dispatch is uncertain; it will not be resent automatically`):e.redacted?Q(r,`Preview đã che dữ liệu nhạy cảm`,`Sensitive data is redacted in the preview`):Q(r,`Preview đã rút gọn`,`Preview truncated`)})]},e.queueItemRef))})]}),(0,U.jsxs)(`footer`,{className:`chat-composer-preview`,children:[C.length>0&&(0,U.jsx)(`ul`,{className:`attachment-list`,"aria-label":Q(r,`File sẽ gửi cùng message`,`Files to send with the message`),children:C.map(e=>(0,U.jsxs)(`li`,{"data-kind":e.kind,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`strong`,{children:e.displayName}),(0,U.jsx)(`small`,{children:cS(e,r)})]}),(0,U.jsx)(`button`,{type:`button`,disabled:u||T,"aria-label":`${Q(r,`Bỏ`,`Remove`)} ${e.displayName}`,onClick:()=>void ce(e.attachmentRef),children:Q(r,`Bỏ`,`Remove`)})]},e.attachmentRef))}),(0,U.jsx)(`textarea`,{"aria-label":Q(r,`Nội dung chat`,`Chat message`),placeholder:R?Q(r,`Nhập việc cần Pi làm ngay sau khi mở lại task…`,`Enter work for Pi immediately after the task resumes…`):L?Q(r,`Nhắn vào đúng Pi session này…`,`Message this exact Pi session…`):Q(r,`Chat control chưa khả dụng.`,`Chat control is unavailable.`),disabled:!ee||u,maxLength:65536,rows:2,value:c,onChange:e=>l(e.target.value),onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),ne&&oe(e.clipboardData.files))}}),(0,U.jsxs)(`div`,{className:`composer-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:!ee||u||!c.trim(),onClick:()=>void ae(R?`resume-and-continue`:re?`follow-up`:`new-operation`),children:u?Q(r,`Đang gửi…`,`Sending…`):R?Q(r,`Tiếp tục & gửi`,`Resume & send`):re?Q(r,`Gửi sau`,`Send next`):Q(r,`Gửi`,`Send`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!L||u||!c.trim()||C.length>0||!I?.hold.available,title:C.length?Q(r,`Bản này chưa giữ file trong hàng đợi`,`This version does not hold attachments in the queue`):void 0,onClick:()=>void ae(`hold`),children:Q(r,`Giữ lại`,`Hold`)}),re&&(0,U.jsx)(`button`,{type:`button`,className:`interrupt-send`,disabled:!L||u||!c.trim()||!I?.interruptAndSend.available,onClick:()=>void ae(`steer`),children:Q(r,`Ngắt & gửi`,`Interrupt & send`)})]}),(0,U.jsxs)(`label`,{className:`attachment-picker ${ne?``:`disabled`}`,title:Q(r,`Chọn file, hoặc kéo thả / dán thẳng vào khung chat`,`Pick a file, or drag and drop / paste straight into the chat`),children:[(0,U.jsx)(`input`,{type:`file`,multiple:!0,disabled:!ne,accept:V||void 0,onChange:e=>{oe(e.target.files),e.currentTarget.value=``}}),T?Q(r,`Đang đọc tài liệu…`,`Reading documents…`):`${Q(r,`Đính kèm hoặc kéo thả`,`Attach or drop`)} (${C.length}/4)`]}),f&&(0,U.jsx)(`small`,{role:`status`,children:f})]})]})}function mS({snapshot:e,refreshSnapshot:t}){let{locale:n}=Gv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(0),g=(0,v.useRef)({revision:0,modelDirty:!1,thinkingDirty:!1}),_=e.capabilities.capabilities[`control.sessionOptions`],y=_.status===`available`?_.actions:null,b=async e=>{let t=++h.current,n=g.current.revision;try{let r=await x_(e);return t===h.current?(i(r),r.state===`ready`&&n===g.current.revision&&(g.current.modelDirty||o(r.activeModelRef??``),g.current.thinkingDirty||c(r.activeThinkingLevel??`off`)),r):r}catch{!e?.aborted&&t===h.current&&i(void 0);return}};(0,v.useEffect)(()=>{let e=new AbortController;return b(e.signal),()=>e.abort()},[e.identity.sessionRef,e.revision.sessionOptionRevision]);let x=(0,v.useMemo)(()=>r?.models.find(e=>e.modelRef===r.activeModelRef),[r]),S=async i=>{if(!l||d||!r||r.state!==`ready`)return;let o=i===`model`?`session-options.set-model`:`session-options.set-thinking`,c=i===`model`?a:s;f(i),m(null);try{let r=await T_(await X_(e,o,c));m(r.resultCode===`changed`?Q(n,`Đã cập nhật trong Pi và mặc định người dùng`,`Updated in Pi and user defaults`):r.resultCode===`unchanged`?Q(n,`Giá trị này đang được dùng`,`This value is already active`):r.resultCode===`effect-unknown`?Q(n,`Pi chưa xác nhận được hậu trạng thái; hãy tải lại trước khi thử tiếp`,`Pi could not confirm the resulting state; refresh before trying again`):`${Q(n,`Chưa thay đổi`,`Not changed`)} · ${Fv(r.resultCode,n)}`),u(!1),g.current.revision+=1,i===`model`?g.current.modelDirty=!1:g.current.thinkingDirty=!1,await t?.(),await b()}catch{m(Q(n,`Không thể đổi; trạng thái Pi có thể đã thay đổi.`,`Unable to change the setting; Pi state may have changed.`))}finally{f(null)}};return(0,U.jsxs)(`section`,{className:`session-options surface`,"aria-labelledby":`session-options-title`,children:[(0,U.jsxs)(`div`,{className:`session-options-copy`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Model & thinking`}),(0,U.jsx)(`h2`,{id:`session-options-title`,children:Q(n,`Thiết lập cho Pi session`,`Pi session settings`)}),(0,U.jsx)(`p`,{children:Q(n,`Chỉ thay đổi khi Pi đang chờ. Thao tác này không gọi model, nhưng Pi cũng cập nhật mặc định người dùng.`,`Settings can only change while Pi is idle. This does not call the model, but Pi also updates user defaults.`)})]}),r?.state===`ready`?(0,U.jsxs)(`div`,{className:`session-options-controls`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:`Model`}),(0,U.jsx)(`select`,{"aria-label":Q(n,`Chọn model`,`Select model`),value:a,disabled:d!==null||!y?.setModel.available,onChange:e=>{g.current.revision+=1,g.current.modelDirty=!0,o(e.target.value),u(!1),m(null)},children:r.models.map(e=>(0,U.jsxs)(`option`,{value:e.modelRef,children:[e.displayName,` · `,e.provider]},e.modelRef))})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:`Thinking`}),(0,U.jsx)(`select`,{"aria-label":Q(n,`Chọn thinking`,`Select thinking`),value:s,disabled:d!==null||!y?.setThinking.available,onChange:e=>{g.current.revision+=1,g.current.thinkingDirty=!0,c(e.target.value),u(!1),m(null)},children:(x?.supportedThinkingLevels??[]).map(e=>(0,U.jsx)(`option`,{value:e,children:Fv(e,n)},e))})]}),(0,U.jsxs)(`label`,{className:`effect-ack`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:l,disabled:d!==null||!y,onChange:e=>u(e.target.checked)}),(0,U.jsx)(`span`,{children:Q(n,`Tôi hiểu thay đổi này áp dụng cho session và mặc định người dùng.`,`I understand this applies to the session and user defaults.`)})]}),(0,U.jsxs)(`div`,{className:`session-option-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setModel.available||a===r.activeModelRef,onClick:()=>void S(`model`),children:d===`model`?Q(n,`Đang đổi…`,`Changing…`):Q(n,`Đổi model`,`Change model`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setThinking.available||s===r.activeThinkingLevel,onClick:()=>void S(`thinking`),children:d===`thinking`?Q(n,`Đang đổi…`,`Changing…`):Q(n,`Đổi thinking`,`Change thinking`)})]}),p&&(0,U.jsx)(`small`,{role:`status`,children:p}),!y?.setModel.available&&(0,U.jsxs)(`small`,{children:[Q(n,`Đang khóa thay đổi`,`Changes locked`),` · `,Fv(y?.setModel.reasonCode??(_.status===`unavailable`?_.reason?.code:`unavailable`),n)]})]}):(0,U.jsxs)(`div`,{className:`session-options-unavailable`,children:[(0,U.jsx)(`strong`,{children:Q(n,`Catalog model chưa sẵn sàng`,`Model catalog unavailable`)}),(0,U.jsx)(`span`,{children:Fv(r?.reasonCode??`authenticated-model-catalog-unavailable`,n)})]})]})}var hS=(e,t,n)=>e===`vi`?t:n,gS={"workspace-patch":[`Sửa trong project`,`Change in the project`],"external-provider-action":[`Tác động ra bên ngoài`,`Reaches outside this machine`]},_S={"one-shell-command":[`Đúng một lệnh`,`This one command`],"network-command-once":[`Đúng một lệnh, có mạng`,`This one command, with network`],"one-external-action":[`Đúng một hành động`,`This one action`]},vS={"Run this exact command once, after the guard checks the working tree again.":[`Chạy đúng lệnh này một lần, sau khi guard kiểm tra lại thư mục làm việc.`,``],"The command does not run; the agent is told you declined.":[`Lệnh không chạy; agent được báo là bạn đã từ chối.`,``],"Run this exact action once, after the guard checks its authority again.":[`Thực hiện đúng hành động này một lần, sau khi guard kiểm tra lại quyền.`,``],"The action does not run; nothing outside changes.":[`Hành động không chạy; không có gì bên ngoài bị thay đổi.`,``],"Run this exact command once, with internet access.":[`Chạy đúng lệnh này một lần, có mạng.`,``],"Run this exact command once, with internet access; a server it starts accepts connections while it runs.":[`Chạy đúng lệnh này một lần, có mạng; server mà lệnh mở nhận kết nối trong lúc chạy.`,``]},yS=(e,t,n)=>{let r=e[t];return r?hS(n,r[0],r[1]||t):null};function bS(e,t){return t===`vi`?e.split(`; `).map(e=>{let t=e.match(/^Confirmation required: the command runs (.+)$/);if(t)return`Lệnh có ${t[1]} nên cần bạn duyệt trước khi chạy.`;let n=e.match(/^External provider action (.+) requires confirmation$/);return n?`Hành động ra bên ngoài (${n[1]}) cần bạn duyệt.`:e}).join(` `):e}var xS=(e,t)=>yS(gS,e.kind,t)??Fv(e.kind,t),SS=(e,t)=>yS(_S,e.requestedScope,t)??Fv(e.requestedScope,t),CS=(e,t)=>yS(vS,e,t)??e;function wS(e,t){return{schemaVersion:1,version:`piagent-webui-approval-v1`,recordType:`decision`,approvalRef:e.approvalRef,decisionId:`decision.${crypto.randomUUID()}`,decisionToken:e.decisionToken,identity:structuredClone(e.identity),actionDigest:e.action.actionDigest,expectedRevisions:structuredClone(e.expectedRevisions),decision:t,reason:null,decidedAt:new Date().toISOString(),expiresAt:e.expiresAt,decisionSurface:`webui`,executor:`pi-guard`,directExecution:!1}}function TS({state:e,setState:t,refreshSnapshot:n,locale:r}){let i=e.request;if(!i)return(0,U.jsx)(`article`,{className:`approval-card`,children:(0,U.jsx)(`p`,{children:e.error??Q(r,`Đang tải yêu cầu phê duyệt…`,`Loading approval request…`)})});let a=i.action,o=Math.max(0,Math.ceil((Date.parse(i.expiresAt)-Date.now())/1e3)),s=async e=>{t({request:i,deciding:e});try{await C_(wS(i,e)),await n?.()}catch{t({request:i,error:Q(r,`Yêu cầu đã hết hạn, thay đổi hoặc được trả lời ở terminal. Hãy tải trạng thái mới.`,`The request expired, changed, or was answered in the terminal. Refresh status.`)})}};return(0,U.jsxs)(`article`,{className:`approval-card risk-${a.riskClass}`,"aria-labelledby":`approval-${i.approvalRef}`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Cần phê duyệt`,`Approval required`)}),(0,U.jsx)(`h2`,{id:`approval-${i.approvalRef}`,children:a.toolName})]}),(0,U.jsx)(`span`,{className:`approval-risk`,children:Fv(a.riskClass,r)})]}),(0,U.jsx)(`p`,{className:`approval-reason`,children:bS(a.reason,r)}),a.commandPreview&&(0,U.jsx)(`pre`,{className:`approval-preview`,children:(0,U.jsx)(`code`,{children:a.commandPreview})}),!a.commandPreview&&a.parameterPreview&&a.parameterPreview!==`No additional parameters`&&(0,U.jsx)(`p`,{className:`approval-preview`,children:a.parameterPreview}),(0,U.jsxs)(`dl`,{className:`approval-facts`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Hành động`,`Action`)}),(0,U.jsx)(`dd`,{children:xS(a,r)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Phạm vi`,`Scope`)}),(0,U.jsx)(`dd`,{children:SS(a,r)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Thư mục`,`Directory`)}),(0,U.jsx)(`dd`,{children:a.cwdDisplay??Q(r,`Đã ẩn`,`Hidden`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Hết hạn`,`Expires`)}),(0,U.jsxs)(`dd`,{children:[o,`s`]})]})]}),a.targetPaths.length>0&&(0,U.jsxs)(`div`,{className:`approval-targets`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Đích tác động`,`Targets`)}),(0,U.jsx)(`ul`,{children:a.targetPaths.map(e=>(0,U.jsx)(`li`,{children:e===`.`?Q(r,`Cả thư mục project`,`The whole project folder`):e},e))})]}),(0,U.jsxs)(`div`,{className:`approval-consequences`,children:[(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:Q(r,`Nếu cho phép:`,`If allowed:`)}),` `,CS(a.consequences.allow,r)]}),(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:Q(r,`Nếu từ chối:`,`If denied:`)}),` `,CS(a.consequences.deny,r)]})]}),e.error&&(0,U.jsx)(`p`,{className:`form-error`,role:`alert`,children:e.error}),(0,U.jsxs)(`footer`,{children:[(0,U.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!e.deciding,onClick:()=>void s(`deny`),children:Q(r,`Từ chối`,`Deny`)}),(0,U.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:!!e.deciding,onClick:()=>void s(`allow`),children:e.deciding===`allow`?Q(r,`Đang kiểm tra lại…`,`Rechecking…`):Q(r,`Cho phép đúng 1 lần`,`Allow once`)})]})]})}function ES({approvalRefs:e,sessionRef:t,refreshSnapshot:n}){let{locale:r}=Gv(),i=(0,v.useMemo)(()=>e,[e.join(`\0`)]),[a,o]=(0,v.useState)({});return(0,v.useEffect)(()=>{let e=new AbortController;for(let n of i)(t?qg(t,n,e.signal):S_(n,e.signal)).then(e=>o(t=>({...t,[n]:{request:e}})),()=>o(e=>({...e,[n]:{error:Q(r,`Không thể tải yêu cầu phê duyệt hiện tại.`,`Unable to load the current approval request.`)}})));return()=>e.abort()},[r,t,i]),i.length===0?null:(0,U.jsx)(`section`,{className:`approval-stack`,"aria-label":Q(r,`Yêu cầu phê duyệt đang chờ`,`Pending approval requests`),"aria-live":`polite`,children:i.map(e=>(0,U.jsx)(TS,{state:a[e]??{},setState:t=>o(n=>({...n,[e]:t})),refreshSnapshot:n,locale:r},e))})}function DS({snapshot:e,refreshSnapshot:t}){let n=(0,v.useMemo)(()=>e.approvals.pending.map(e=>e.approvalRef),[e.approvals.pending]);return(0,U.jsx)(ES,{approvalRefs:n,refreshSnapshot:t})}var OS={stopped:`Đã dừng lượt Pi hiện tại; task vẫn được giữ lại.`,"emergency-stop":`Đã dừng lượt Pi hiện tại.`,"stop-requested":`Đang chờ Pi xác nhận lượt hiện tại đã dừng.`,"already-idle":`Pi đang chờ, không có lượt nào cần dừng.`,"pause-requested":`Đang chờ tool hiện tại kết thúc tại điểm an toàn.`,paused:`Task đã tạm dừng an toàn.`,"already-pausing":`Task đang chờ điểm tạm dừng an toàn.`,"already-paused":`Task đang được tạm dừng.`,resumed:`Task đã hoạt động lại; chưa gửi thêm tin nhắn cho model.`,"pause-cancelled":`Đã hủy yêu cầu tạm dừng; chưa gọi model.`,"already-active":`Task đang hoạt động.`,"resume-rejected":`Chưa thể tiếp tục vì bằng chứng khôi phục chưa đủ an toàn.`,"settlement-unknown":`Chưa xác nhận được Pi đã dừng. Hãy xem trạng thái mới trước khi thử lại.`,"pause-unconfirmed":`Chưa đủ bằng chứng để xác nhận task đã tạm dừng.`},kS={stopped:`Stopped the current Pi turn; the task remains intact.`,"emergency-stop":`Stopped the current Pi turn.`,"stop-requested":`Waiting for Pi to confirm the current turn has stopped.`,"already-idle":`Pi is idle; there is no turn to stop.`,"pause-requested":`Waiting for the current tool to finish at a safe point.`,paused:`The task is safely paused.`,"already-pausing":`The task is waiting for a safe pause point.`,"already-paused":`The task is paused.`,resumed:`The task is active again; no model message was sent.`,"pause-cancelled":`Cancelled the pause request; no model call was made.`,"already-active":`The task is active.`,"resume-rejected":`Resume is blocked because recovery evidence is not yet safe.`,"settlement-unknown":`Pi stop is unconfirmed. Refresh status before trying again.`,"pause-unconfirmed":`There is not enough evidence to confirm the task is paused.`};function AS(e,t){return(t===`vi`?OS:kS)[e.resultCode]??(e.error?.message||`${Q(t,`Chưa thực hiện`,`Not executed`)} · ${Fv(e.resultCode,t)}`)}function jS({snapshot:e,refreshSnapshot:t}){let{locale:n}=Gv(),r=e.capabilities.capabilities[`control.lifecycle`],[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=r.status===`available`,l=c?r.currentPhase:`unknown`,u=c?r.stopPhaseSupport[l]:null,d=!!(u?.stop===`supported`&&e.identity.agentOperationId),f=!!(c&&r.actions.pause.available),p=!!(c&&r.actions.resume.available);(0,v.useEffect)(()=>{o?.resultCode===`pause-requested`&&e.session.controlState===`paused`&&s({action:`lifecycle.pause`,resultCode:`paused`,text:(n===`vi`?OS:kS).paused}),o?.resultCode===`stop-requested`&&e.session.operation.liveness===`idle`&&s({action:`lifecycle.stop`,resultCode:`stopped`,text:(n===`vi`?OS:kS).stopped})},[o?.resultCode,n,e.session.controlState,e.session.operation.liveness]);let m=async r=>{if(!i){a(r),s(null);try{let i=await E_(await Z_(e,r));s({action:r,resultCode:i.resultCode,text:AS(i,n)}),await t?.()}catch{s({action:r,resultCode:`request-failed`,text:Q(n,`Trạng thái Pi đã thay đổi hoặc kết nối local bị gián đoạn. Hãy tải trạng thái mới rồi thử lại.`,`Pi state changed or the local connection was interrupted. Refresh status before trying again.`)})}finally{a(null)}}};return(0,U.jsxs)(`section`,{className:`lifecycle-panel surface`,"aria-labelledby":`lifecycle-title`,children:[(0,U.jsxs)(`div`,{className:`lifecycle-copy`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(n,`Điều khiển task`,`Task controls`)}),(0,U.jsx)(`h2`,{id:`lifecycle-title`,children:`Stop, pause & resume`}),(0,U.jsx)(`p`,{children:Q(n,`Stop dừng lượt Pi đang chạy. Pause chờ tool hiện tại kết thúc rồi giữ task. Resume chỉ mở lại task, không tự gọi model. Muốn mở lại và giao việc ngay, dùng “Tiếp tục & gửi” trong Chat.`,`Stop ends the running Pi turn. Pause waits for the current tool to reach a safe point and holds the task. Resume reopens the task without calling the model. Use “Resume & send” in Chat to continue with new work.`)})]}),(0,U.jsxs)(`div`,{className:`lifecycle-state`,children:[(0,U.jsx)(`span`,{children:Q(n,`Trạng thái`,`Status`)}),(0,U.jsx)(`strong`,{children:Fv(e.session.controlState,n)}),(0,U.jsxs)(`small`,{children:[`Pi: `,Fv(e.session.operation.liveness,n),` · phase: `,Fv(l,n)]})]}),(0,U.jsxs)(`div`,{className:`lifecycle-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:i!==null||!d,onClick:()=>void m(`lifecycle.stop`),title:d?void 0:Fv(u?.reasonCode??`no-current-operation`,n),children:i===`lifecycle.stop`?Q(n,`Đang dừng…`,`Stopping…`):Q(n,`Dừng lượt hiện tại`,`Stop current turn`)}),(0,U.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:i!==null||!f,onClick:()=>void m(`lifecycle.pause`),title:!f&&c?Fv(r.actions.pause.reasonCode,n):void 0,children:i===`lifecycle.pause`?Q(n,`Đang yêu cầu…`,`Requesting…`):Q(n,`Tạm dừng task`,`Pause task`)}),(0,U.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:i!==null||!p,onClick:()=>void m(`lifecycle.resume`),title:!p&&c?Fv(r.actions.resume.reasonCode,n):void 0,children:i===`lifecycle.resume`?Q(n,`Đang mở lại…`,`Resuming…`):Q(n,`Tiếp tục task`,`Resume task`)})]}),o&&(0,U.jsx)(`p`,{className:`lifecycle-result result-${o.resultCode===`request-failed`||o.resultCode.includes(`unknown`)||o.resultCode.includes(`unconfirmed`)||o.resultCode===`resume-rejected`?`warning`:`ok`}`,role:`status`,children:o.text}),!c&&(0,U.jsxs)(`p`,{className:`lifecycle-result result-warning`,children:[Q(n,`Điều khiển chưa sẵn sàng`,`Controls unavailable`),` · `,Fv(r.reason?.code,n)]})]})}function MS(e,t){try{return new Intl.DateTimeFormat(t===`vi`?`vi-VN`:`en-US`,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e))}catch{return e}}function NS({value:e,locale:t}){return(0,U.jsxs)(`span`,{className:`status-pill tone-${Iv(e)}`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Fv(e,t)]})}function PS({snapshot:e}){let{locale:t}=Gv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),[o,s]=(0,v.useState)(`all`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(),[f,p]=(0,v.useState)(`idle`),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(`idle`),[y,b]=(0,v.useState)(),[x,S]=(0,v.useState)(`idle`),[C,w]=(0,v.useState)(),[T,E]=(0,v.useState)(`idle`);(0,v.useEffect)(()=>{let e=new AbortController;return a(`loading`),f_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`),l(e=>e&&t.runs.some(t=>t.runRef===e)?e:t.activeRunRef??t.runs[0]?.runRef??null))}).catch(()=>{e.signal.aborted||a(`error`)}),()=>e.abort()},[e.revision.taskRevision,e.revision.eventCursor]);let D=(0,v.useMemo)(()=>(n?.runs??[]).filter(e=>o===`all`||o===`current`&&e.isCurrentSession||o===`terminal`&&e.terminal),[n,o]);return(0,v.useEffect)(()=>{if(!c){d(void 0),p(`idle`);return}let e=new AbortController;return p(`loading`),p_(c,e.signal).then(t=>{e.signal.aborted||(d(t),p(`ready`))}).catch(()=>{e.signal.aborted||p(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){b(void 0),S(`idle`);return}let e=new AbortController;return S(`loading`),h_(c,e.signal).then(t=>{e.signal.aborted||(b(t),S(`ready`))}).catch(()=>{e.signal.aborted||S(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){h(void 0),_(`idle`);return}let e=new AbortController;return _(`loading`),m_(c,e.signal).then(t=>{e.signal.aborted||(h(t),_(`ready`))}).catch(()=>{e.signal.aborted||_(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){w(void 0),E(`idle`);return}let e=new AbortController;return E(`loading`),g_(c,e.signal).then(t=>{e.signal.aborted||(w(t),E(`ready`))}).catch(()=>{e.signal.aborted||E(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,U.jsxs)(`section`,{className:`task-run-index surface`,"aria-labelledby":`task-run-index-title`,children:[(0,U.jsxs)(`header`,{className:`source-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Long-task dashboard`}),(0,U.jsx)(`h2`,{id:`task-run-index-title`,children:Q(t,`Task và các lần chạy gần đây`,`Tasks and recent runs`)})]}),(0,U.jsxs)(`span`,{children:[n?.page.total??0,` `,Q(t,`run từ local state`,`runs from local state`)]})]}),(0,U.jsx)(`div`,{className:`task-index-controls`,role:`group`,"aria-label":Q(t,`Lọc task run`,`Filter task runs`),children:[[`all`,Q(t,`Tất cả`,`All`)],[`current`,Q(t,`Session này`,`This session`)],[`terminal`,Q(t,`Đã kết thúc`,`Finished`)]].map(([e,t])=>(0,U.jsx)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>s(e),children:t},e))}),i===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang đọc task state bền vững…`,`Reading durable task state…`)}),(i===`error`||n?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Task history chưa sẵn sàng; Pi session hiện tại không bị ảnh hưởng.`,`Task history is unavailable; the current Pi session is unaffected.`)}),i===`ready`&&n?.state===`ready`&&(0,U.jsxs)(`div`,{className:`task-run-list`,children:[D.map(e=>(0,U.jsxs)(`article`,{className:`task-run-card`,"data-active":e.isActive,"data-selected":e.runRef===c,children:[(0,U.jsxs)(`div`,{className:`task-run-main`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.summary||e.taskId}),e.isActive&&(0,U.jsx)(`span`,{className:`active-run-tag`,children:Q(t,`Đang hoạt động`,`Active`)})]}),(0,U.jsxs)(`small`,{children:[e.taskId,` · `,Q(t,`lần`,`attempt`),` `,e.attempt,`/`,e.maxAttempts,` · `,Q(t,`cập nhật`,`updated`),` `,MS(e.updatedAt,t)]})]}),(0,U.jsxs)(`div`,{className:`task-run-meta`,children:[(0,U.jsx)(NS,{value:e.outcome,locale:t}),(0,U.jsx)(`span`,{children:e.progress.total?`${e.progress.completed}/${e.progress.total} ${Q(t,`bước`,`steps`)}`:Q(t,`Chưa có work plan`,`No work plan`)}),(0,U.jsx)(`span`,{children:e.sessionLabel??(e.isCurrentSession?Q(t,`Session hiện tại`,`Current session`):Q(t,`Session khác`,`Other session`))}),(0,U.jsx)(`button`,{type:`button`,"aria-pressed":e.runRef===c,onClick:()=>l(e.runRef),children:Q(t,`Xem timeline`,`View timeline`)})]})]},e.runRef)),D.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Không có task run trong bộ lọc này.`,`No task runs match this filter.`)})]}),n?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n?.page.truncated&&(0,U.jsxs)(`p`,{className:`task-index-warning`,children:[Q(t,`Danh sách đã rút gọn;`,`The list is truncated;`),` `,n.page.total-n.page.returned,` `,Q(t,`run cũ chưa hiển thị.`,`older runs are not shown.`)]}),(0,U.jsxs)(`section`,{className:`task-timeline`,"aria-labelledby":`task-timeline-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Recovery timeline`}),(0,U.jsx)(`h3`,{id:`task-timeline-title`,children:Q(t,`Crash, resume, pause và checkpoint`,`Crash, resume, pause, and checkpoints`)})]}),u?.state===`ready`&&(0,U.jsx)(NS,{value:u.continuity.recoveryDecision,locale:t})]}),f===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem timeline.`,`Select a run to view its timeline.`)}),f===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh chuỗi Task Journal…`,`Verifying the Task Journal chain…`)}),(f===`error`||u?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Timeline không đủ bằng chứng tin cậy; task hiện tại không bị ảnh hưởng.`,`The timeline lacks trustworthy evidence; the current task is unaffected.`)}),f===`ready`&&u?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`timeline-continuity`,children:[(0,U.jsxs)(`span`,{children:[`Crash evidence: `,(0,U.jsx)(`strong`,{children:Fv(u.continuity.crashEvidence,t)})]}),(0,U.jsxs)(`span`,{children:[`Recovery: `,(0,U.jsx)(`strong`,{children:Fv(u.continuity.recoveryDecision,t)})]})]}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:u.events.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Iv(e.state)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.title}),(0,U.jsxs)(`small`,{children:[`#`,e.sequence,` · `,MS(e.recordedAt,t)]}),e.detail&&(0,U.jsx)(`p`,{children:e.detail})]}),(0,U.jsx)(NS,{value:e.state,locale:t})]},e.eventRef))}),u.events.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Run này chưa có fact timeline bền vững.`,`This run has no durable timeline facts.`)})]}),u?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,U.jsxs)(`section`,{className:`task-timeline recovery-history`,"aria-labelledby":`recovery-history-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Compaction & recovery`}),(0,U.jsx)(`h3`,{id:`recovery-history-title`,children:Q(t,`Lịch sử rút gọn và phục hồi`,`Compaction and recovery history`)})]}),m?.state===`ready`&&(0,U.jsx)(NS,{value:m.completeness,locale:t})]}),g===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem lịch sử rút gọn.`,`Select a run to view compaction history.`)}),g===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang đọc metadata compaction an toàn…`,`Reading safe compaction metadata…`)}),(g===`error`||m?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Lịch sử compaction chưa đủ bằng chứng tin cậy; task hiện tại không bị ảnh hưởng.`,`Compaction history lacks trustworthy evidence; the current task is unaffected.`)}),g===`ready`&&m?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`timeline-continuity recovery-summary`,children:[(0,U.jsxs)(`span`,{children:[`Context compact: `,(0,U.jsx)(`strong`,{children:m.summary.contextCompactions})]}),(0,U.jsxs)(`span`,{children:[`Tool result: `,(0,U.jsx)(`strong`,{children:m.summary.toolResultCompactions})]}),(0,U.jsxs)(`span`,{children:[`Recovery: `,(0,U.jsx)(`strong`,{children:Fv(m.recovery.decision,t)})]}),(0,U.jsxs)(`span`,{children:[`Verifier: `,(0,U.jsx)(`strong`,{children:Fv(m.recovery.verifierState,t)})]})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Nội dung capture được giữ trong private runtime state và không gửi vào trình duyệt.`,`Captured content stays in private runtime state and is not sent to the browser.`)}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:m.events.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Iv(e.kind)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.title}),(0,U.jsxs)(`small`,{children:[`#`,e.sequence,` · `,MS(e.recordedAt,t)]}),e.kind===`tool-result-compaction`&&(0,U.jsxs)(`p`,{children:[e.toolName,` · `,e.originalLines??`?`,` `,Q(t,`dòng`,`lines`),` · `,e.captureCount,` capture`]}),e.detail&&(0,U.jsx)(`p`,{children:e.detail})]}),(0,U.jsx)(NS,{value:`observed`,locale:t})]},e.eventRef))}),m.events.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Run này chưa có metadata compaction đã quan sát.`,`This run has no observed compaction metadata.`)})]}),m?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,U.jsxs)(`section`,{className:`task-timeline handoff-history`,"aria-labelledby":`handoff-history-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Handoff`}),(0,U.jsx)(`h3`,{id:`handoff-history-title`,children:Q(t,`Bàn giao và việc cần làm tiếp theo`,`Handoff and next work`)})]}),y?.state===`ready`&&(0,U.jsx)(NS,{value:y.completeness,locale:t})]}),x===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem handoff.`,`Select a run to view its handoff.`)}),x===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh handoff và next action…`,`Verifying the handoff and next action…`)}),(x===`error`||y?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Handoff không đủ bằng chứng tin cậy; WebUI không đề xuất hành động.`,`The handoff lacks trustworthy evidence; WebUI will not suggest an action.`)}),x===`ready`&&y?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`next-action-card`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:Q(t,`Việc tiếp theo`,`Next work`)}),(0,U.jsx)(`strong`,{children:Fv(y.nextAction.action,t)})]}),(0,U.jsx)(`p`,{children:y.nextAction.reason}),(0,U.jsxs)(`small`,{children:[y.nextAction.exactCommandCount,` verifier command · `,Q(t,`chỉ xem, không tự chạy`,`read-only, never auto-run`)]})]}),y.current&&(0,U.jsxs)(`div`,{className:`timeline-continuity handoff-summary`,children:[(0,U.jsxs)(`span`,{children:[`Outcome: `,(0,U.jsx)(`strong`,{children:Fv(y.current.taskOutcome,t)})]}),(0,U.jsxs)(`span`,{children:[`Gate: `,(0,U.jsx)(`strong`,{children:Fv(y.current.gateDecision,t)})]}),(0,U.jsxs)(`span`,{children:[`Authority: `,(0,U.jsx)(`strong`,{children:Fv(y.current.requiredAuthority,t)})]}),(0,U.jsxs)(`span`,{children:[`Tree evidence: `,(0,U.jsx)(`strong`,{children:y.current.treeEvidenceCurrent?`current`:`not current`})]})]}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:y.events.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Iv(e.completionApproved?`completed`:`handoff`)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:Q(t,`Handoff projection đã được ghi`,`Handoff projection recorded`)}),(0,U.jsxs)(`small`,{children:[`#`,e.sequence,` · `,MS(e.recordedAt,t)]}),(0,U.jsxs)(`p`,{children:[e.phase??`unknown`,` · `,Fv(e.projectedAction,t)]})]}),(0,U.jsx)(NS,{value:e.completionApproved?`completed`:`observed`,locale:t})]},e.eventRef))}),!y.current&&y.events.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Run này chưa có handoff đã quan sát.`,`This run has no observed handoff.`)})]}),y?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,U.jsxs)(`section`,{className:`task-timeline subagent-tree`,"aria-labelledby":`subagent-tree-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Helper / subagent tree`}),(0,U.jsx)(`h3`,{id:`subagent-tree-title`,children:Q(t,`Quyền sở hữu và vòng đời helper`,`Helper ownership and lifecycle`)})]}),C?.state===`ready`&&(0,U.jsx)(NS,{value:C.evidenceState,locale:t})]}),T===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem helper/subagent.`,`Select a run to view helpers and subagents.`)}),T===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh helper ledger bền vững…`,`Verifying the durable helper ledger…`)}),(T===`error`||C?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Helper ledger không đủ tin cậy; WebUI không suy đoán cây subagent.`,`The helper ledger lacks trustworthy evidence; WebUI will not infer a subagent tree.`)}),T===`ready`&&C?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`next-action-card`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:Q(t,`Quyết định điều phối`,`Delegation decision`)}),(0,U.jsx)(`strong`,{children:C.delegation.action===`dispatch`?Q(t,`Gửi 1 helper chỉ đọc`,`Dispatch one read-only helper`):Q(t,`Parent tự làm`,`Parent works directly`)})]}),(0,U.jsx)(`p`,{children:C.delegation.reasonCodes.map(e=>Fv(e,t)).join(` · `)}),(0,U.jsxs)(`small`,{children:[Q(t,`Tiết kiệm token dự kiến`,`Projected net token saving`),`: `,C.delegation.projectedNetSavingsRatio===null?Q(t,`chưa được chứng minh`,`not proven`):`${Math.round(C.delegation.projectedNetSavingsRatio*100)}%`,` · `,Q(t,`ngưỡng`,`threshold`),` `,Math.round(C.delegation.minimumRequiredNetSavingsRatio*100),`% · `,Q(t,`tối đa 1 helper, 0 retry, 0 writer`,`max 1 helper, 0 retries, 0 writers`)]})]}),(0,U.jsxs)(`div`,{className:`timeline-continuity subagent-summary`,children:[(0,U.jsxs)(`span`,{children:[Q(t,`Tổng helper`,`Total helpers`),`: `,(0,U.jsx)(`strong`,{children:C.summary.total})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Đang chạy`,`Running`),`: `,(0,U.jsx)(`strong`,{children:C.summary.active})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Kết quả stale`,`Stale results`),`: `,(0,U.jsx)(`strong`,{children:C.summary.staleResults})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Writer hiện tại`,`Current writer`),`: `,(0,U.jsx)(`strong`,{children:Fv(C.writer.state,t)})]})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Prompt, output, model và session ID của helper không được gửi vào trình duyệt.`,`Helper prompts, outputs, models, and session IDs are not sent to the browser.`)}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:C.children.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Iv(e.lifecycleState)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`strong`,{children:[Fv(e.role,t),` · `,Fv(e.authority,t)]}),(0,U.jsxs)(`small`,{children:[MS(e.reservedAt,t),` → `,e.completedAt?MS(e.completedAt,t):Q(t,`đang giữ lease`,`lease active`)]}),(0,U.jsxs)(`p`,{children:[e.result.disposition?Fv(e.result.disposition,t):Q(t,`Chưa có result evidence`,`No result evidence`),e.result.calls===null?``:` · ${e.result.calls} calls · ${e.result.tokens??0} tokens`]})]}),(0,U.jsx)(NS,{value:e.result.state===`not-recorded`?e.lifecycleState:e.result.state,locale:t})]},e.nodeRef))}),C.children.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Không có lifecycle helper chi tiết cho run này.`,`No detailed helper lifecycle is available for this run.`)}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Cây lồng nhiều tầng: chưa có durable lineage; WebUI chỉ hiển thị quan hệ task cha → helper trực tiếp.`,`Nested trees: durable lineage is not yet available, so WebUI only shows parent task → direct helper relationships.`)})]}),C?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]})]})}function FS(e,t){if(!e)return Q(t,`Chưa có`,`Not available`);try{return new Intl.DateTimeFormat(t===`vi`?`vi-VN`:`en-US`,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e))}catch{return e}}function IS({value:e,locale:t}){return(0,U.jsxs)(`span`,{className:`status-pill tone-${Iv(e)}`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Fv(e,t)]})}function LS({snapshot:e}){let{locale:t}=Gv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{o.current?.abort();let e=new AbortController;o.current=e,a(`loading`),__(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`))}).catch(()=>{e.signal.aborted||a(`error`)})},[]);return(0,v.useEffect)(()=>(s(),()=>o.current?.abort()),[s,e.identity.projectRef,e.identity.runtimeInstanceId]),(0,U.jsxs)(`section`,{className:`release-monitor surface`,"aria-labelledby":`release-monitor-title`,children:[(0,U.jsxs)(`header`,{className:`source-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Benchmark & release`}),(0,U.jsx)(`h2`,{id:`release-monitor-title`,children:Q(t,`Theo dõi chất lượng và mức sẵn sàng phát hành`,`Quality and release readiness`)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,children:i===`loading`?Q(t,`Đang đọc…`,`Loading…`):Q(t,`Làm mới`,`Refresh`)})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Màn hình chỉ đọc bằng chứng local; không tự chạy benchmark, resume, commit, tag, publish hay push.`,`This screen only reads local evidence; it never runs benchmarks, resumes, commits, tags, publishes, or pushes.`)}),(i===`error`||n?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Bằng chứng benchmark/release chưa sẵn sàng; Pi session hiện tại không bị ảnh hưởng.`,`Benchmark and release evidence is unavailable; the current Pi session is unaffected.`)}),i===`loading`&&!n&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh report, manifest và ledger…`,`Verifying reports, manifests, and ledgers…`)}),n&&(0,U.jsxs)(`div`,{className:`release-monitor-grid`,children:[(0,U.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`benchmark-monitor-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Benchmark runs`}),(0,U.jsx)(`h3`,{id:`benchmark-monitor-title`,children:Q(t,`Các lần đo gần đây`,`Recent runs`)})]}),(0,U.jsx)(IS,{value:n.benchmark.state,locale:t})]}),n.benchmark.runs.map(e=>(0,U.jsxs)(`article`,{className:`benchmark-run-card`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.suiteId}),(0,U.jsx)(IS,{value:e.lifecycle,locale:t})]}),(0,U.jsxs)(`small`,{children:[FS(e.updatedAt,t),` · `,e.completedRuns,`/`,e.expectedRuns,` `,Q(t,`lượt`,`runs`),` · `,Q(t,`nguồn`,`source`),` `,Fv(e.sourceState,t)]}),(0,U.jsxs)(`div`,{className:`benchmark-run-facts`,children:[(0,U.jsxs)(`span`,{children:[`Gate `,(0,U.jsx)(`b`,{children:Fv(e.releaseGate,t)})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Điểm`,`Score`),` `,(0,U.jsx)(`b`,{children:e.scores.overall??`—`})]}),(0,U.jsxs)(`span`,{children:[`Claim `,(0,U.jsx)(`b`,{children:Fv(e.claimTier,t)})]})]})]},e.runRef)),n.benchmark.runs.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chưa có run thuộc repo hiện tại với bằng chứng đủ tin cậy.`,`No trustworthy runs are available for the current repository.`)}),n.benchmark.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n.benchmark.page.truncated&&(0,U.jsx)(`p`,{className:`task-index-warning`,children:Q(t,`Danh sách được giới hạn để giữ WebUI nhẹ và ổn định.`,`The list is bounded to keep WebUI fast and stable.`)})]}),(0,U.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`release-readiness-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Release readiness`}),(0,U.jsx)(`h3`,{id:`release-readiness-title`,children:Q(t,`RC hiện tại`,`Current RC`)})]}),(0,U.jsx)(IS,{value:n.release.state,locale:t})]}),(0,U.jsxs)(`dl`,{className:`release-readiness-facts`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Local safe gate`}),(0,U.jsx)(`dd`,{children:(0,U.jsx)(IS,{value:n.release.localSafeGate,locale:t})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`RC assembly`}),(0,U.jsx)(`dd`,{children:Fv(n.release.rcAssembly,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Beta`}),(0,U.jsx)(`dd`,{children:Fv(n.release.beta,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`GA`}),(0,U.jsx)(`dd`,{children:Fv(n.release.gaRelease,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Báo cáo`,`Report`)}),(0,U.jsx)(`dd`,{children:FS(n.release.generatedAt,t)})]})]}),n.release.sourceState===`stale`&&(0,U.jsx)(`p`,{className:`task-index-warning`,children:Q(t,`Báo cáo RC thuộc phiên bản source cũ; không dùng để xác nhận tree hiện tại.`,`The RC report belongs to an older source revision and cannot validate the current tree.`)}),n.release.blockers.length>0&&(0,U.jsxs)(`div`,{className:`release-blockers`,children:[(0,U.jsxs)(`strong`,{children:[n.release.blockerCount,` blocker`]}),(0,U.jsx)(`ul`,{children:n.release.blockers.map((e,t)=>(0,U.jsx)(`li`,{children:e},`${t}-${e}`))})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Mọi quyền phát hành đều tắt. Việc phát hành vẫn cần operator phê duyệt ngoài màn hình này.`,`All release authority is disabled. Release still requires operator approval outside this screen.`)})]})]})]})}var RS=264,zS={overview:{vi:[`Tổng quan`,`Task contract, tiến độ và bằng chứng hoàn thành`],en:[`Overview`,`Task contract, progress, and completion evidence`]},chat:{vi:[`Chat & điều khiển`,`Đúng Pi session hiện tại, không tạo runtime thứ hai`],en:[`Chat & controls`,`The exact current Pi session, without a second runtime`]},documents:{vi:[`Tài liệu`,`Mở .md, .docx, .pdf, .csv trong project và thư mục đã cấp quyền`],en:[`Documents`,`Open .md, .docx, .pdf, and .csv from the project and granted directories`]},source:{vi:[`Source Changes`,`Review thay đổi theo task baseline, working tree và staged`],en:[`Source Changes`,`Review task baseline, working tree, and staged changes`]},activity:{vi:[`Activity`,`Tool call, command, verifier và log preview`],en:[`Activity`,`Tool calls, commands, verifiers, and bounded log previews`]},history:{vi:[`Lịch sử task`,`Crash, resume, checkpoint, handoff và helper`],en:[`Task history`,`Crash, resume, checkpoints, handoffs, and helpers`]},release:{vi:[`Release`,`Benchmark evidence và mức sẵn sàng phát hành`],en:[`Release`,`Benchmark evidence and release readiness`]}};function BS({value:e,text:t,locale:n=`vi`}){return(0,U.jsxs)(`span`,{className:`status-pill tone-${Iv(e)}`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),t??Fv(e,n)]})}function VS({locale:e}){return(0,U.jsxs)(`section`,{className:`task-empty surface`,"aria-labelledby":`task-title`,children:[(0,U.jsx)(`div`,{className:`empty-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,U.jsx)(`h2`,{id:`task-title`,children:Q(e,`Chưa có task đang chạy`,`No active task`)}),(0,U.jsx)(`p`,{children:Q(e,`WebUI đang theo dõi đúng Pi session. Khi task bắt đầu, mục tiêu, tiêu chí và tiến độ sẽ xuất hiện tại đây.`,`WebUI is observing the exact Pi session. Objectives, criteria, and progress will appear here when a task begins.`)})]})]})}function HS({snapshot:e,locale:t}){let n=e.task;if(!n)return(0,U.jsx)(VS,{locale:t});let r=Hv(e,t);return(0,U.jsxs)(`section`,{className:`task-dashboard surface`,"aria-labelledby":`task-title`,children:[(0,U.jsxs)(`header`,{className:`task-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(t,`Task hiện tại`,`Current task`)}),(0,U.jsx)(`h2`,{id:`task-title`,children:n.summary}),(0,U.jsxs)(`div`,{className:`task-meta`,children:[(0,U.jsx)(BS,{value:n.outcome,locale:t}),(0,U.jsx)(`span`,{children:Fv(n.changeMode,t)}),(0,U.jsx)(`span`,{children:Fv(n.riskLane,t)})]})]}),(0,U.jsxs)(`div`,{className:`progress-number`,"aria-label":`${Q(t,`Tiến độ`,`Progress`)} ${r.percent}%`,children:[(0,U.jsxs)(`strong`,{children:[r.percent,`%`]}),(0,U.jsx)(`span`,{children:r.text})]})]}),(0,U.jsx)(`div`,{className:`progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.percent,"aria-label":Q(t,`Tiến độ tiêu chí`,`Criteria progress`),children:(0,U.jsx)(`span`,{style:{width:`${r.percent}%`}})}),n.blocker&&(0,U.jsxs)(`div`,{className:`blocker`,role:`status`,children:[(0,U.jsx)(`span`,{children:`Blocker`}),(0,U.jsx)(`p`,{children:n.blocker})]}),(0,U.jsxs)(`div`,{className:`criteria-heading`,children:[(0,U.jsx)(`h2`,{children:Q(t,`Tiêu chí hoàn thành`,`Completion criteria`)}),(0,U.jsxs)(`span`,{children:[n.criteria.length,` `,Q(t,`tiêu chí`,`criteria`)]})]}),(0,U.jsx)(`ol`,{className:`criteria-list`,children:n.criteria.map((e,n)=>(0,U.jsxs)(`li`,{className:`criterion-card`,children:[(0,U.jsx)(`span`,{className:`criterion-index tone-${Iv(e.state)}`,children:String(n+1).padStart(2,`0`)}),(0,U.jsxs)(`div`,{className:`criterion-copy`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{children:e.obligation}),e.priority===`critical`&&(0,U.jsx)(`span`,{className:`critical-tag`,children:Q(t,`Quan trọng`,`Critical`)})]}),(0,U.jsx)(`small`,{children:Vv(e,t)})]}),(0,U.jsx)(BS,{value:e.state,locale:t})]},e.criterionId))}),n.workPlan.length>0&&(0,U.jsxs)(`details`,{className:`work-plan`,children:[(0,U.jsxs)(`summary`,{children:[Q(t,`Kế hoạch thực hiện`,`Work plan`),` · `,n.workPlan.length,` `,Q(t,`bước`,`steps`)]}),(0,U.jsx)(`ol`,{children:n.workPlan.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(BS,{value:e.status,locale:t}),(0,U.jsx)(`span`,{children:e.summary})]},e.stepId))})]})]})}function US({snapshot:e,locale:t}){return(0,U.jsxs)(`aside`,{className:`context-rail`,"aria-label":Q(t,`Tóm tắt phiên`,`Session summary`),children:[(0,U.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,U.jsxs)(`dl`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Task ID`}),(0,U.jsx)(`dd`,{title:e.identity.taskId??void 0,children:Lv(e.identity.taskId)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Run ID`}),(0,U.jsx)(`dd`,{title:e.identity.taskRunId??void 0,children:Lv(e.identity.taskRunId)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Verifier`}),(0,U.jsx)(`dd`,{children:(0,U.jsx)(BS,{value:e.verification.state,locale:t})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Queue`}),(0,U.jsx)(`dd`,{children:e.session.queue.state===`known`?`${e.session.queue.heldCount??0} ${Q(t,`đang giữ`,`held`)}`:Fv(e.session.queue.state,t)})]})]})]}),(0,U.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(t,`Sức khỏe`,`Health`)}),(0,U.jsxs)(`div`,{className:`health-line`,children:[(0,U.jsx)(BS,{value:e.health.state,locale:t}),(0,U.jsxs)(`span`,{children:[e.health.issues.length,` `,Q(t,`lưu ý`,`issues`)]})]}),e.health.issues.slice(0,3).map(e=>(0,U.jsx)(`p`,{className:`health-issue`,children:e.message},e.issueRef))]})]})}function WS({snapshot:e,locale:t}){let n=[[`Runtime`,(0,U.jsx)(BS,{value:e.session.operation.liveness,locale:t})],[`Task`,(0,U.jsx)(BS,{value:e.session.controlState,locale:t})],[`Model`,(0,U.jsx)(`strong`,{children:Rv(e,t)})],[`Thinking`,(0,U.jsx)(`strong`,{children:zv(e,t)})],[Q(t,`Quyền`,`Permission`),(0,U.jsx)(`strong`,{children:Bv(e,t)})],[`Approval`,(0,U.jsx)(BS,{value:e.session.approvalState,locale:t})]];return(0,U.jsx)(Pc,{variant:`outlined`,className:`runtime-overview`,"aria-label":Q(t,`Trạng thái Pi session`,`Pi session status`),sx:{display:`grid`,gridTemplateColumns:{xs:`repeat(2, minmax(0,1fr))`,sm:`repeat(3, minmax(0,1fr))`,xl:`repeat(6, minmax(0,1fr))`},overflow:`hidden`},children:n.map(([e,t])=>(0,U.jsxs)(J,{sx:{minWidth:0,minHeight:72,px:2,py:1.5,display:`flex`,flexDirection:`column`,justifyContent:`center`,gap:.75,borderRight:1,borderBottom:{xs:1,xl:0},borderColor:`divider`,"&:last-child":{borderRight:0}},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:800,letterSpacing:`.11em`,textTransform:`uppercase`},children:e}),t]},e))})}function GS({active:e,snapshot:t,events:n,refreshSnapshot:r,locale:i}){return e===`overview`?(0,U.jsxs)(Z,{className:`workspace-stack`,spacing:2.25,children:[(0,U.jsx)(WS,{snapshot:t,locale:i}),(0,U.jsxs)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`minmax(0,1fr) 300px`},alignItems:`start`,gap:2.25},children:[(0,U.jsx)(HS,{snapshot:t,locale:i}),(0,U.jsx)(US,{snapshot:t,locale:i})]}),(0,U.jsx)(Rx,{snapshot:t})]}):e===`chat`?(0,U.jsxs)(Z,{className:`workspace-stack`,spacing:2.25,children:[(0,U.jsx)(jS,{snapshot:t,refreshSnapshot:r}),(0,U.jsx)(mS,{snapshot:t,refreshSnapshot:r}),(0,U.jsx)(pS,{snapshot:t,events:n,refreshSnapshot:r})]}):e===`documents`?(0,U.jsx)(wx,{}):e===`source`?(0,U.jsx)(ay,{snapshot:t,refreshSnapshot:r}):e===`activity`?(0,U.jsx)(jx,{snapshot:t}):e===`history`?(0,U.jsx)(PS,{snapshot:t}):(0,U.jsx)(LS,{snapshot:t})}function KS({snapshot:e,connection:t=`connecting`,events:n=[],refreshSnapshot:r}){let{locale:i,colorMode:a,setLocale:o,setColorMode:s}=Gv(),[c,l]=(0,v.useState)(`overview`),[u,d]=(0,v.useState)(!1);if(!e)return(0,U.jsxs)(J,{className:`loading-shell`,children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsx)(`p`,{className:`section-kicker`,children:`Piagent WebUI · local`}),(0,U.jsx)(X,{variant:`h1`,children:t===`failed`?Q(i,`Không thể nối vào Pi session`,`Unable to connect to the Pi session`):Q(i,`Đang mở không gian làm việc`,`Opening the workspace`)}),(0,U.jsx)(X,{color:`text.secondary`,children:t===`failed`?Q(i,`Hãy mở lại WebUI từ Pi terminal để tạo phiên local mới.`,`Reopen WebUI from the Pi terminal to create a new local session.`):Q(i,`Đang tải task contract và trạng thái runtime hiện tại…`,`Loading the task contract and current runtime state…`)}),t!==`failed`&&(0,U.jsx)(xu,{size:22}),(0,U.jsx)(BS,{value:t,locale:i})]});let f=zS[c][i],p=(e.sourceChanges.task?.counts.files??0)+e.sourceChanges.workingTree.counts.files+e.sourceChanges.staged.counts.files,m=[{id:`overview`,label:Q(i,`Tổng quan`,`Overview`),icon:(0,U.jsx)(jh,{})},{id:`chat`,label:Q(i,`Chat & Task`,`Chat & Task`),icon:(0,U.jsx)(Mh,{}),count:e.session.queue.heldCount??0},{id:`documents`,label:Q(i,`Tài liệu`,`Documents`),icon:(0,U.jsx)(Nh,{})},{id:`source`,label:`Source Changes`,icon:(0,U.jsx)(Ph,{}),count:p},{id:`activity`,label:`Activity`,icon:(0,U.jsx)(Fh,{}),count:e.activity.running.length},{id:`history`,label:Q(i,`Lịch sử`,`History`),icon:(0,U.jsx)(Ih,{})},{id:`release`,label:`Release`,icon:(0,U.jsx)(Lh,{})}],h=e=>{l(e),d(!1)},g=(0,U.jsxs)(J,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(up,{sx:{minHeight:`72px !important`,px:`18px !important`,gap:1.25},children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:760,lineHeight:1.15},children:`Piagent`}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:`WebUI · local`})]})]}),(0,U.jsxs)(J,{sx:{mx:1.5,mb:1.25,p:1.35,border:1,borderColor:`divider`,borderRadius:2,bgcolor:`action.hover`},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textTransform:`uppercase`,letterSpacing:`.09em`},children:Q(i,`Pi session hiện tại`,`Current Pi session`)}),(0,U.jsx)(X,{variant:`body2`,noWrap:!0,title:e.session.displayName??void 0,sx:{mt:.45,fontWeight:700},children:e.session.displayName??`Pi session`}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,title:e.identity.sessionRef,children:Lv(e.identity.sessionRef)})]}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{px:2.5,pt:1,pb:.5,fontWeight:800,letterSpacing:`.1em`,textTransform:`uppercase`},children:Q(i,`Không gian làm việc`,`Workspaces`)}),(0,U.jsx)(rf,{component:`nav`,"aria-label":Q(i,`Điều hướng WebUI`,`WebUI navigation`),sx:{py:.5},children:m.map(e=>(0,U.jsxs)(cf,{selected:c===e.id,"aria-current":c===e.id?`page`:void 0,onClick:()=>h(e.id),children:[(0,U.jsx)(pf,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:e.icon}),(0,U.jsx)(Cf,{primary:e.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:c===e.id?750:600}}}}),!!e.count&&(0,U.jsx)(rl,{badgeContent:e.count,color:e.id===`activity`?`secondary`:`primary`,max:99,sx:{mr:1}})]},e.id))}),(0,U.jsxs)(J,{sx:{mt:`auto`,p:1.5},children:[(0,U.jsx)(Du,{sx:{mb:1.5}}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsxs)(op,{exclusive:!0,size:`small`,value:i,"aria-label":Q(i,`Ngôn ngữ`,`Language`),onChange:(e,t)=>t&&o(t),sx:{flex:1},children:[(0,U.jsx)(ep,{value:`vi`,"aria-label":`Tiếng Việt`,sx:{flex:1},children:`VI`}),(0,U.jsx)(ep,{value:`en`,"aria-label":`English`,sx:{flex:1},children:`EN`})]}),(0,U.jsx)(Ah,{title:a===`dark`?Q(i,`Chuyển sang giao diện sáng`,`Use light mode`):Q(i,`Chuyển sang giao diện tối`,`Use dark mode`),children:(0,U.jsx)(Qd,{"aria-label":a===`dark`?Q(i,`Dùng giao diện sáng`,`Use light mode`):Q(i,`Dùng giao diện tối`,`Use dark mode`),onClick:()=>s(a===`dark`?`light`:`dark`),sx:{border:1,borderColor:`divider`,borderRadius:1.5},children:a===`dark`?(0,U.jsx)(zh,{fontSize:`small`}):(0,U.jsx)(Bh,{fontSize:`small`})})})]})]})]});return(0,U.jsxs)(J,{className:`app-shell`,"data-contract":`snapshot-v1`,children:[(0,U.jsx)(`a`,{className:`skip-link`,href:`#main-content`,children:Q(i,`Bỏ qua điều hướng`,`Skip navigation`)}),(0,U.jsx)(zc,{position:`fixed`,color:`transparent`,elevation:0,sx:{width:{md:`calc(100% - ${RS}px)`},ml:{md:`${RS}px`},borderBottom:1,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .88)`,backdropFilter:`blur(18px)`},children:(0,U.jsxs)(up,{sx:{minHeight:`72px !important`,gap:1.5},children:[(0,U.jsx)(Qd,{edge:`start`,"aria-label":Q(i,`Mở menu`,`Open menu`),onClick:()=>d(!0),sx:{display:{md:`none`}},children:(0,U.jsx)(Rh,{})}),(0,U.jsxs)(J,{sx:{minWidth:0,flex:1},children:[(0,U.jsx)(X,{component:`h1`,variant:`h2`,noWrap:!0,children:f[0]}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{display:{xs:`none`,sm:`block`}},children:f[1]})]}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},"aria-live":`polite`,children:[(0,U.jsx)(lu,{variant:`outlined`,size:`small`,color:t===`connected`?`success`:`default`,label:t===`connected`?`Live`:Fv(t,i)}),e.approvals.pending.length>0&&(0,U.jsx)(lu,{color:`warning`,size:`small`,label:`${e.approvals.pending.length} approval`}),(0,U.jsx)(lu,{variant:`outlined`,size:`small`,sx:{display:{xs:`none`,sm:`flex`}},label:e.capabilities.capabilities[`control.chat`].status===`available`?Q(i,`Chat bật`,`Chat enabled`):Q(i,`Chỉ xem`,`Read only`)})]})]})}),(0,U.jsxs)(J,{component:`nav`,"aria-label":Q(i,`Sidebar chính`,`Primary sidebar`),sx:{width:{md:RS},flexShrink:{md:0}},children:[(0,U.jsx)(Kd,{variant:`temporary`,open:u,onClose:()=>d(!1),ModalProps:{keepMounted:!0},sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:RS}},children:g}),(0,U.jsx)(Kd,{variant:`permanent`,open:!0,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:RS,borderRight:1,borderColor:`divider`,bgcolor:`background.paper`}},children:g})]}),(0,U.jsx)(J,{component:`main`,id:`main-content`,sx:{ml:{md:`${RS}px`},minWidth:0,pt:`72px`},children:(0,U.jsxs)(J,{className:`workspace-view workspace-${c}`,sx:{width:`100%`,maxWidth:c===`source`?`none`:1580,mx:`auto`,p:{xs:1.5,sm:2.5,lg:3}},children:[e.approvals.pending.length>0&&(0,U.jsx)(J,{sx:{mb:2.25},children:(0,U.jsx)(DS,{snapshot:e,refreshSnapshot:r})}),(0,U.jsx)(GS,{active:c,snapshot:e,events:n,refreshSnapshot:r,locale:i})]})})]})}var qS=Y((0,U.jsx)(`path`,{d:`M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1`}),`AddRounded`),JS=Y((0,U.jsx)(`path`,{d:`M16.5 6.75v10.58c0 2.09-1.53 3.95-3.61 4.15-2.39.23-4.39-1.64-4.39-3.98V5.14c0-1.31.94-2.5 2.24-2.63 1.5-.15 2.76 1.02 2.76 2.49v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75v8.61c0 1.31.94 2.5 2.24 2.63 1.5.15 2.76-1.02 2.76-2.49V5.17c0-2.09-1.53-3.95-3.61-4.15C9.01.79 7 2.66 7 5v12.27c0 2.87 2.1 5.44 4.96 5.71 3.29.3 6.04-2.26 6.04-5.48V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75`}),`AttachFileRounded`),YS=Y((0,U.jsx)(`path`,{d:`M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0a.996.996 0 0 1 0-1.41L10.59 12 7.7 9.11a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41`}),`CancelRounded`),XS=Y((0,U.jsx)(`path`,{d:`M17.65 6.35c-1.63-1.63-3.94-2.57-6.48-2.31-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20c3.19 0 5.93-1.87 7.21-4.56.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53-1.13 2.43-3.84 3.97-6.8 3.31-2.22-.49-4.01-2.3-4.48-4.52C5.31 9.44 8.26 6 12 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71z`}),`RefreshRounded`),ZS=Y((0,U.jsx)(`path`,{d:`m3.4 20.4 17.45-7.48c.81-.35.81-1.49 0-1.84L3.4 3.6c-.66-.29-1.39.2-1.39.91L2 9.12c0 .5.37.93.87.99L17 12 2.87 13.88c-.5.07-.87.5-.87 1l.01 4.61c0 .71.73 1.2 1.39.91`}),`SendRounded`),QS=Y((0,U.jsx)(`path`,{d:`M2 4v16h20V4zm18 4.67h-2.5V6H20zm-2.5 2H20v2.67h-2.5zM4 6h11.5v12H4zm13.5 12v-2.67H20V18z`}),`ViewSidebarOutlined`),$S=Y((0,U.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m3 14H9c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h6c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1`}),`StopCircleRounded`);function eC(e){return Gr(`MuiAlert`,e)}var tC=Kr(`MuiAlert`,[`root`,`action`,`icon`,`message`,`filled`,`colorSuccess`,`colorInfo`,`colorWarning`,`colorError`,`outlined`,`standard`]),nC=Y((0,U.jsx)(`path`,{d:`M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z`}),`SuccessOutlined`),rC=Y((0,U.jsx)(`path`,{d:`M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z`}),`ReportProblemOutlined`),iC=Y((0,U.jsx)(`path`,{d:`M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z`}),`ErrorOutline`),aC=Y((0,U.jsx)(`path`,{d:`M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z`}),`InfoOutlined`),oC=Y((0,U.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`}),`Close`),sC=e=>{let{variant:t,color:n,severity:r,classes:i}=e;return ba({root:[`root`,`color${q(n||r)}`,`${t}`],icon:[`icon`],message:[`message`],action:[`action`]},eC,i)},cC=K(Pc,{name:`MuiAlert`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant]]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`?e.darken:e.lighten,n=e.palette.mode===`light`?e.lighten:e.darken;return{...e.typography.body2,backgroundColor:`transparent`,display:`flex`,padding:`6px 16px`,variants:[...Object.entries(e.palette).filter(Ac([`light`])).map(([r])=>({props:{colorSeverity:r,variant:`standard`},style:{color:e.vars?e.vars.palette.Alert[`${r}Color`]:t(e.palette[r].light,.6),backgroundColor:e.vars?e.vars.palette.Alert[`${r}StandardBg`]:n(e.palette[r].light,.9),[`& .${tC.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}}})),...Object.entries(e.palette).filter(Ac([`light`])).map(([n])=>({props:{colorSeverity:n,variant:`outlined`},style:{color:e.vars?e.vars.palette.Alert[`${n}Color`]:t(e.palette[n].light,.6),border:`1px solid ${(e.vars||e).palette[n].light}`,[`& .${tC.icon}`]:e.vars?{color:e.vars.palette.Alert[`${n}IconColor`]}:{color:e.palette[n].main}}})),...Object.entries(e.palette).filter(Ac([`dark`])).map(([t])=>({props:{colorSeverity:t,variant:`filled`},style:{fontWeight:e.typography.fontWeightMedium,...e.vars?{color:e.vars.palette.Alert[`${t}FilledColor`],backgroundColor:e.vars.palette.Alert[`${t}FilledBg`]}:{backgroundColor:e.palette.mode===`dark`?e.palette[t].dark:e.palette[t].main,color:e.palette.getContrastText(e.palette[t].main)}}}))]}})),lC=K(`div`,{name:`MuiAlert`,slot:`Icon`})({marginRight:12,padding:`7px 0`,display:`flex`,fontSize:22,opacity:.9}),uC=K(`div`,{name:`MuiAlert`,slot:`Message`})({padding:`8px 0`,minWidth:0,overflow:`auto`}),dC=K(`div`,{name:`MuiAlert`,slot:`Action`})({display:`flex`,alignItems:`flex-start`,padding:`4px 0 0 16px`,marginLeft:`auto`,marginRight:-8}),fC={success:(0,U.jsx)(nC,{fontSize:`inherit`}),warning:(0,U.jsx)(rC,{fontSize:`inherit`}),error:(0,U.jsx)(iC,{fontSize:`inherit`}),info:(0,U.jsx)(aC,{fontSize:`inherit`})},pC=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiAlert`}),{action:r,children:i,className:a,closeText:o=`Close`,color:s,icon:c,iconMapping:l=fC,onClose:u,role:d=`alert`,severity:f=`success`,slotProps:p={},slots:m={},variant:h=`standard`,...g}=n,_={...n,color:s,severity:f,variant:h,colorSeverity:s||f},v=sC(_),y={slots:m,slotProps:p},[b,x]=Xc(`root`,{ref:t,shouldForwardComponentProp:!0,className:W(v.root,a),elementType:cC,externalForwardedProps:{...y,...g},ownerState:_,additionalProps:{role:d,elevation:0}}),[S,C]=Xc(`icon`,{className:v.icon,elementType:lC,externalForwardedProps:y,ownerState:_}),[w,T]=Xc(`message`,{className:v.message,elementType:uC,externalForwardedProps:y,ownerState:_}),[E,D]=Xc(`action`,{className:v.action,elementType:dC,externalForwardedProps:y,ownerState:_}),[O,k]=Xc(`closeButton`,{elementType:Qd,externalForwardedProps:y,ownerState:_}),[A,j]=Xc(`closeIcon`,{elementType:oC,externalForwardedProps:y,ownerState:_});return(0,U.jsxs)(b,{...x,children:[c===!1?null:(0,U.jsx)(S,{...C,children:c||l[f]||fC[f]}),(0,U.jsx)(w,{...T,children:i}),r==null?null:(0,U.jsx)(E,{...D,children:r}),r==null&&u?(0,U.jsx)(E,{...D,children:(0,U.jsx)(O,{size:`small`,"aria-label":o,title:o,color:`inherit`,onClick:u,...k,children:(0,U.jsx)(A,{fontSize:`small`,...j})})}):null]})});function mC(e){return Gr(`MuiButton`,e)}var hC=Kr(`MuiButton`,`root.text.outlined.contained.disableElevation.focusVisible.disabled.colorInherit.colorPrimary.colorSecondary.colorSuccess.colorError.colorInfo.colorWarning.sizeMedium.sizeSmall.sizeLarge.fullWidth.startIcon.endIcon.icon.loading.loadingWrapper.loadingIconPlaceholder.loadingIndicator.loadingPositionCenter.loadingPositionStart.loadingPositionEnd`.split(`.`)),gC=v.createContext({}),_C=v.createContext(void 0),vC=e=>{let{color:t,disableElevation:n,fullWidth:r,size:i,variant:a,loading:o,loadingPosition:s,classes:c}=e,l=ba({root:[`root`,o&&`loading`,a,`size${q(i)}`,`color${q(t)}`,n&&`disableElevation`,r&&`fullWidth`,o&&`loadingPosition${q(s)}`],startIcon:[`icon`,`startIcon`],endIcon:[`icon`,`endIcon`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},mC,c);return{...c,...l}},yC=[{props:{size:`small`},style:{"& > *:nth-of-type(1)":{fontSize:18}}},{props:{size:`medium`},style:{"& > *:nth-of-type(1)":{fontSize:20}}},{props:{size:`large`},style:{"& > *:nth-of-type(1)":{fontSize:22}}}],bC=K(tu,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`size${q(n.size)}`],n.color===`inherit`&&t.colorInherit,n.disableElevation&&t.disableElevation,n.fullWidth&&t.fullWidth,n.loading&&t.loading]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`?e.palette.grey[300]:e.palette.grey[800],n=e.palette.mode===`light`?e.palette.grey.A100:e.palette.grey[700];return{...e.typography.button,minWidth:64,padding:`6px 16px`,border:0,borderRadius:(e.vars||e).shape.borderRadius,...Ks(e,[`background-color`,`box-shadow`,`border-color`,`color`],{duration:e.transitions.duration.short}),"&:hover":{textDecoration:`none`},[`&.${hC.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:{variant:`contained`},style:{color:`var(--variant-containedColor)`,backgroundColor:`var(--variant-containedBg)`,boxShadow:(e.vars||e).shadows[2],"&:hover":{boxShadow:(e.vars||e).shadows[4],"@media (hover: none)":{boxShadow:(e.vars||e).shadows[2]}},"&:active":{boxShadow:(e.vars||e).shadows[8]},[`&.${hC.focusVisible}`]:{boxShadow:(e.vars||e).shadows[6]},[`&.${hC.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}},{props:{variant:`outlined`},style:{padding:`5px 15px`,border:`1px solid currentColor`,borderColor:`var(--variant-outlinedBorder, currentColor)`,backgroundColor:`var(--variant-outlinedBg)`,color:`var(--variant-outlinedColor)`,[`&.${hC.disabled}`]:{border:`1px solid ${(e.vars||e).palette.action.disabledBackground}`}}},{props:{variant:`text`},style:{padding:`6px 8px`,color:`var(--variant-textColor)`,backgroundColor:`var(--variant-textBg)`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{"--variant-textColor":(e.vars||e).palette[t].main,"--variant-outlinedColor":(e.vars||e).palette[t].main,"--variant-outlinedBorder":e.alpha((e.vars||e).palette[t].main,.5),"--variant-containedColor":(e.vars||e).palette[t].contrastText,"--variant-containedBg":(e.vars||e).palette[t].main,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":(e.vars||e).palette[t].dark,"--variant-textBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBorder":(e.vars||e).palette[t].main,"--variant-outlinedBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}}}})),{props:{color:`inherit`},style:{color:`inherit`,borderColor:`currentColor`,"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedBg:t,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedHoverBg:n,"--variant-textBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity)}}}},{props:{size:`small`,variant:`text`},style:{padding:`4px 5px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`text`},style:{padding:`8px 11px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`outlined`},style:{padding:`3px 9px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`outlined`},style:{padding:`7px 21px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`contained`},style:{padding:`4px 10px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`contained`},style:{padding:`8px 22px`,fontSize:e.typography.pxToRem(15)}},{props:{disableElevation:!0},style:{boxShadow:`none`,"&:hover":{boxShadow:`none`},[`&.${hC.focusVisible}`]:{boxShadow:`none`},"&:active":{boxShadow:`none`},[`&.${hC.disabled}`]:{boxShadow:`none`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{loadingPosition:`center`},style:{...Ks(e,[`background-color`,`box-shadow`,`border-color`],{duration:e.transitions.duration.short}),[`&.${hC.loading}`]:{color:`transparent`}}}]}})),xC=K(`span`,{name:`MuiButton`,slot:`StartIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.startIcon,n.loading&&t.startIconLoadingStart]}})(({theme:e})=>({display:`inherit`,alignItems:`center`,marginRight:8,marginLeft:-4,"&::before":{content:`"\\200b"`,width:0,overflow:`hidden`},variants:[{props:{size:`small`},style:{marginLeft:-2}},{props:{loadingPosition:`start`,loading:!0},style:{...Ks(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`start`,loading:!0,fullWidth:!0},style:{marginRight:-8}},...yC]})),SC=K(`span`,{name:`MuiButton`,slot:`EndIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.endIcon,n.loading&&t.endIconLoadingEnd]}})(({theme:e})=>({display:`inherit`,marginRight:-4,marginLeft:8,variants:[{props:{size:`small`},style:{marginRight:-2}},{props:{loadingPosition:`end`,loading:!0},style:{...Ks(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`end`,loading:!0,fullWidth:!0},style:{marginLeft:-8}},...yC]})),CC=K(`span`,{name:`MuiButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,variants:[{props:{loading:!0},style:{display:`flex`}},{props:{loadingPosition:`start`},style:{left:14}},{props:{loadingPosition:`start`,size:`small`},style:{left:10}},{props:{variant:`text`,loadingPosition:`start`},style:{left:6}},{props:{loadingPosition:`center`},style:{left:`50%`,transform:`translate(-50%)`,color:(e.vars||e).palette.action.disabled}},{props:{loadingPosition:`end`},style:{right:14}},{props:{loadingPosition:`end`,size:`small`},style:{right:10}},{props:{variant:`text`,loadingPosition:`end`},style:{right:6}},{props:{loadingPosition:`start`,fullWidth:!0},style:{position:`relative`,left:-10}},{props:{loadingPosition:`end`,fullWidth:!0},style:{position:`relative`,right:-10}}]})),wC=K(`span`,{name:`MuiButton`,slot:`LoadingIconPlaceholder`})({display:`inline-block`,width:`1em`,height:`1em`}),$=v.forwardRef(function(e,t){let n=v.useContext(gC),r=v.useContext(_C),i=Xo({props:ai(n,e),name:`MuiButton`}),{children:a,color:o=`primary`,component:s=`button`,className:c,disabled:l=!1,disableElevation:u=!1,disableFocusRipple:d=!1,endIcon:f,focusVisibleClassName:p,fullWidth:m=!1,id:h,loading:g=null,loadingIndicator:_,loadingPosition:y=`center`,size:b=`medium`,startIcon:x,type:S,variant:C=`text`,...w}=i,T=Ed(h),E=_??(0,U.jsx)(xu,{"aria-labelledby":T,color:`inherit`,size:16}),D={...i,color:o,component:s,disabled:l,disableElevation:u,disableFocusRipple:d,fullWidth:m,loading:g,loadingIndicator:E,loadingPosition:y,size:b,type:S,variant:C},O=vC(D),k=(x||g&&y===`start`)&&(0,U.jsx)(xC,{className:O.startIcon,ownerState:D,children:x||(0,U.jsx)(wC,{className:O.loadingIconPlaceholder,ownerState:D})}),A=(f||g&&y===`end`)&&(0,U.jsx)(SC,{className:O.endIcon,ownerState:D,children:f||(0,U.jsx)(wC,{className:O.loadingIconPlaceholder,ownerState:D})}),j=r||``,M=typeof g==`boolean`?(0,U.jsx)(`span`,{className:O.loadingWrapper,style:{display:`contents`},children:g&&(0,U.jsx)(CC,{className:O.loadingIndicator,ownerState:D,children:E})}):null,{root:N,...P}=O;return(0,U.jsxs)(bC,{ownerState:D,className:W(n.className,O.root,c,j),component:s,disabled:l||g,focusRipple:!d,focusVisibleClassName:W(O.focusVisible,p),ref:t,internalNativeButton:!0,type:S,id:g?T:h,...w,classes:P,children:[k,y!==`end`&&M,a,y===`end`&&M,A]})});function TC(e){return Gr(`MuiCollapse`,e)}Kr(`MuiCollapse`,[`root`,`horizontal`,`vertical`,`entered`,`hidden`,`wrapper`,`wrapperInner`]);var EC={},DC=e=>{let{orientation:t,classes:n}=e;return ba({root:[`root`,t],entered:[`entered`],hidden:[`hidden`],wrapper:[`wrapper`,t],wrapperInner:[`wrapperInner`,t]},TC,n)},OC=K(`div`,{name:`MuiCollapse`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.orientation],n.state===`entered`&&t.entered,n.state===`exited`&&!n.in&&n.collapsedSize===`0px`&&t.hidden]}})(ys(({theme:e})=>({height:0,overflow:`hidden`,transition:e.transitions.create(`height`),variants:[{props:{orientation:`horizontal`},style:{height:`auto`,width:0,transition:e.transitions.create(`width`)}},{props:{state:`entered`},style:{height:`auto`,overflow:`visible`}},{props:{state:`entered`,orientation:`horizontal`},style:{width:`auto`}},{props:({ownerState:e})=>e.state===`exited`&&!e.in&&e.collapsedSize===`0px`,style:{visibility:`hidden`}}]}))),kC=K(`div`,{name:`MuiCollapse`,slot:`Wrapper`})({display:`flex`,width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),AC=K(`div`,{name:`MuiCollapse`,slot:`WrapperInner`})({width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),jC=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiCollapse`}),{addEndListener:r,children:i,className:a,collapsedSize:o=`0px`,component:s,disablePrefersReducedMotion:c=!1,easing:l,in:u,onEnter:d,onEntered:f,onEntering:p,onExit:m,onExited:h,onExiting:g,orientation:_=`vertical`,slots:y=EC,slotProps:b=EC,style:x,timeout:S=fo.standard,TransitionComponent:C=id,...w}=n,T={...n,orientation:_,collapsedSize:o},E=DC(T),D=Go(),O=v.useRef(null),k=v.useRef(null),A=typeof o==`number`?`${o}px`:o,j=_===`horizontal`,M=j?`width`:`height`,N=Ll(D.motion.reducedMotion,c),P=v.useRef(null),F=bs(t,P),I=()=>O.current?O.current[j?`clientWidth`:`clientHeight`]:0,L=Hs(P,(e,t)=>{O.current&&j&&(O.current.style.position=`absolute`),e.style[M]=A,d&&d(e,t)}),R=Hs(P,(e,t)=>{let n=I();O.current&&j&&(O.current.style.position=``);let{duration:r,easing:i}=Ws({style:x,timeout:S,easing:l},{mode:`enter`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(n);k.current=e}else k.current=null;let a=N.getTransitionTiming({duration:k.current??r,delay:void 0});e.style.transitionDuration=typeof a.duration==`string`?a.duration:`${a.duration}ms`,e.style[M]=`${n}px`,e.style.transitionTimingFunction=i,p&&p(e,t)}),ee=Hs(P,(e,t)=>{e.style[M]=`auto`,f&&f(e,t)}),te=Hs(P,e=>{e.style[M]=`${I()}px`,m&&m(e)}),z=Hs(P,h),B=Hs(P,e=>{let t=I(),{duration:n,easing:r}=Ws({style:x,timeout:S,easing:l},{mode:`exit`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(t);k.current=e}else k.current=null;let i=N.getTransitionTiming({duration:k.current??n,delay:void 0});e.style.transitionDuration=typeof i.duration==`string`?i.duration:`${i.duration}ms`,e.style[M]=A,e.style.transitionTimingFunction=r,g&&g(e)}),V=r?e=>{r(P.current,e)}:void 0,ne={slots:y,slotProps:b,component:s},[re,ie]=Xc(`root`,{ref:F,className:W(E.root,a),elementType:OC,externalForwardedProps:ne,ownerState:T,additionalProps:{style:{[j?`minWidth`:`minHeight`]:A,...x}}}),[ae,oe]=Xc(`wrapper`,{ref:O,className:E.wrapper,elementType:kC,externalForwardedProps:ne,ownerState:T}),[se,H]=Xc(`wrapperInner`,{className:E.wrapperInner,elementType:AC,externalForwardedProps:ne,ownerState:T});return(0,U.jsx)(C,{in:u,onEnter:L,onEntered:ee,onEntering:R,onExit:te,onExited:z,onExiting:B,addEndListener:V,getAutoTimeout:S===`auto`?()=>k.current:void 0,reduceMotion:N.shouldReduceMotion,nodeRef:P,timeout:S===`auto`?null:S,...w,children:(e,{ownerState:t,...n})=>{let r={...T,state:e};return(0,U.jsx)(re,{...ie,className:W(ie.className,{entered:E.entered,exited:!u&&A===`0px`&&E.hidden}[e]),ownerState:r,...n,children:(0,U.jsx)(ae,{...oe,ownerState:r,children:(0,U.jsx)(se,{...H,ownerState:r,children:i})})})}})});jC&&(jC.muiSupportAuto=!0);function MC(e){return Gr(`MuiDialog`,e)}Kr(`MuiDialog`,[`root`,`backdrop`,`scrollPaper`,`scrollBody`,`container`,`paper`,`paperWidthFalse`,`paperWidthXs`,`paperWidthSm`,`paperWidthMd`,`paperWidthLg`,`paperWidthXl`,`paperFullWidth`,`paperFullScreen`]);var NC=v.createContext({}),PC=K(dd,{name:`MuiDialog`,slot:`Backdrop`})({zIndex:-1}),FC=e=>{let{classes:t,scroll:n,maxWidth:r,fullWidth:i,fullScreen:a}=e;return ba({root:[`root`],backdrop:[`backdrop`],container:[`container`,`scroll${q(n)}`],paper:[`paper`,`paperWidth${q(String(r))}`,i&&`paperFullWidth`,a&&`paperFullScreen`]},MC,t)},IC=K(Sd,{name:`MuiDialog`,slot:`Root`})({"@media print":{position:`absolute !important`}}),LC=K(`div`,{name:`MuiDialog`,slot:`Container`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.container,t[`scroll${q(n.scroll)}`]]}})({height:`100%`,"@media print":{height:`auto`},outline:0,variants:[{props:{scroll:`paper`},style:{display:`flex`,justifyContent:`center`,alignItems:`center`}},{props:{scroll:`body`},style:{overflowY:`auto`,overflowX:`hidden`,textAlign:`center`,"&::after":{content:`""`,display:`inline-block`,verticalAlign:`middle`,height:`100%`,width:`0`}}}]}),RC=K(Pc,{name:`MuiDialog`,slot:`Paper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.paper,t[`paperWidth${q(String(n.maxWidth))}`],n.fullWidth&&t.paperFullWidth,n.fullScreen&&t.paperFullScreen]}})(ys(({theme:e})=>({margin:32,position:`relative`,overflowY:`auto`,outline:0,"@media print":{overflowY:`visible`,boxShadow:`none`},variants:[{props:{scroll:`paper`},style:{display:`flex`,flexDirection:`column`,maxHeight:`calc(100% - 64px)`}},{props:{scroll:`body`},style:{display:`inline-block`,verticalAlign:`middle`,textAlign:`initial`}},{props:({ownerState:e})=>!e.maxWidth,style:{maxWidth:`calc(100% - 64px)`}},{props:{maxWidth:`xs`},style:{maxWidth:e.breakpoints.unit===`px`?Math.max(e.breakpoints.values.xs,444):`max(${e.breakpoints.values.xs}${e.breakpoints.unit}, 444px)`}},{props:{maxWidth:`xs`,scroll:`body`},style:{[e.breakpoints.down(Math.max(e.breakpoints.values.xs,444)+64)]:{maxWidth:`calc(100% - 64px)`}}},...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t},style:{maxWidth:`${e.breakpoints.values[t]}${e.breakpoints.unit}`}})),...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t,scroll:`body`},style:{[e.breakpoints.down(e.breakpoints.values[t]+64)]:{maxWidth:`calc(100% - 64px)`}}})),{props:({ownerState:e})=>e.fullWidth,style:{width:`calc(100% - 64px)`}},{props:({ownerState:e})=>e.fullScreen,style:{margin:0,width:`100%`,maxWidth:`100%`,height:`100%`,maxHeight:`none`,borderRadius:0}},{props:({ownerState:e})=>e.fullScreen&&e.scroll===`body`,style:{margin:0,maxWidth:`100%`}}]}))),zC=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialog`}),r=Go(),i={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{"aria-describedby":a,"aria-labelledby":o,"aria-modal":s=!0,children:c,className:l,fullScreen:u=!1,fullWidth:d=!1,maxWidth:f=`sm`,onClick:p,onClose:m,open:h,PaperComponent:g=Pc,role:_=`dialog`,scroll:y=`paper`,slots:b={},slotProps:x={},transitionDuration:S=i,...C}=n,w={...n,fullScreen:u,fullWidth:d,maxWidth:f,scroll:y},T=FC(w),E=v.useRef(),D=e=>{E.current=e.target===e.currentTarget},O=e=>{p&&p(e),E.current&&(E.current=null,m&&m(e,`backdropClick`))},k=Ki(o),A=v.useMemo(()=>({titleId:k}),[k]),j={slots:b,slotProps:x},[M,N]=Xc(`root`,{elementType:IC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:W(T.root,l),ref:t}),[P,F]=Xc(`backdrop`,{elementType:PC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.backdrop}),[I,L]=Xc(`paper`,{elementType:RC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.paper,additionalProps:{elevation:24,role:_,"aria-describedby":a,"aria-labelledby":k,"aria-modal":s,tabIndex:-1,[Bu]:``}}),[R,ee]=Xc(`container`,{elementType:LC,externalForwardedProps:j,ownerState:w,className:T.container}),[te,z]=Xc(`transition`,{elementType:sd,externalForwardedProps:j,ownerState:w,additionalProps:{appear:!0,in:h,timeout:S,role:`presentation`}});return(0,U.jsx)(M,{closeAfterTransition:!0,slots:{backdrop:P},slotProps:{backdrop:{transitionDuration:S,...F}},onClose:m,open:h,onClick:O,...N,...C,children:(0,U.jsx)(te,{...z,children:(0,U.jsx)(R,{onMouseDown:D,...ee,children:(0,U.jsx)(I,{as:g,...L,children:(0,U.jsx)(NC.Provider,{value:A,children:c})})})})})}),BC=(e,[t,n])=>e===`vi`?t:n,VC={"managed-config-missing":[`Chưa nhập cấu hình công ty. Mở Agent Watch → Studio → Nhập cấu hình cho Piagent (trên Windows: Kết nối Piagent trong WSL).`,`Company configuration is not imported. Open Agent Watch → Studio and import it for Piagent (on Windows: Connect Piagent in WSL).`],"managed-keychain-approval-required":[`macOS chưa cho Agent Watch đọc key. Chọn “Luôn cho phép” khi được hỏi rồi kết nối lại.`,`macOS did not let Agent Watch read the key. Choose “Always Allow” when asked, then connect again.`],"managed-key-unavailable":[`Agent Watch không đọc được key công ty trên máy này. Mở Agent Watch, dán lại mã kết nối, bấm Kết nối Piagent trong WSL rồi kết nối lại.`,`Agent Watch cannot read the company key on this computer. Open Agent Watch, paste the connection code again, choose Connect Piagent in WSL, then connect again.`],"managed-profile-disconnected":[`Cấu hình Piagent đang thuộc key công ty đã ngắt kết nối. Nhập lại cấu hình cho Piagent trong Agent Watch (trên Windows: Kết nối Piagent trong WSL).`,`The Piagent configuration belongs to a disconnected company key. Import it again in Agent Watch (on Windows: Connect Piagent in WSL).`],"managed-launch-binding-changed":[`Agent Watch hoặc Piagent vừa cập nhật. Nhập lại cấu hình cho Piagent trong Agent Watch (trên Windows: Kết nối Piagent trong WSL).`,`Agent Watch or Piagent changed. Import the Piagent configuration again in Agent Watch (on Windows: Connect Piagent in WSL).`],"managed-launch-version-mismatch":[`Agent Watch đang dùng một bản Piagent khác với dashboard này. Mở Agent Watch → Studio, bấm Áp dụng cho Piagent rồi kết nối lại.`,`Agent Watch points at another Piagent install than this dashboard. Open Agent Watch → Studio, apply for Piagent, then connect again.`],"managed-launch-stale-runtime":[`Phiên công ty của bản Piagent cũ chưa dừng được. Thử kết nối lại sau ít giây.`,`The company runtime from the previous Piagent did not stop yet. Connect again in a few seconds.`],"managed-launch-timeout":[`Phiên công ty khởi động quá lâu. Kết nối lại.`,`The company runtime took too long to start. Connect again.`]},HC={"company-quota":{title:[`Hết hạn mức token`,`Token quota used up`],text:[`Hạn mức token của key này đã hết. Chờ kỳ hạn mức mới hoặc liên hệ quản trị viên để tăng hạn mức.`,`This key's token quota is used up. Wait for the next quota period or ask an administrator to raise it.`]},"company-provider-limit":{title:[`Tài khoản model của công ty hết lượt`,`Company model account limited`],text:[`Nhà cung cấp đang giới hạn tài khoản model của công ty (hết lượt dùng hoặc quá tải). Thử lại sau; quản trị viên có thể đổi model trong Harness.`,`The provider is limiting the company's model account (out of usage or overloaded). Try again later; an administrator can switch the harness model.`]},"company-account":{title:[`Tài khoản model cần đăng nhập lại`,`Model account must sign in again`],text:[`Tài khoản model của công ty đã hết phiên đăng nhập. Quản trị viên cần đăng nhập lại trong Studio (Tài khoản AI).`,`The company's model account is signed out. An administrator has to sign it in again in Studio (AI accounts).`]},"company-busy":{title:[`Đang quá tải`,`Busy`],text:[`Studio đang xử lý quá nhiều request của key này, hoặc tài khoản model đang bận. Chờ vài giây rồi gửi lại.`,`Studio is handling too many requests for this key, or the model account is busy. Wait a few seconds and send again.`]},"company-trial-limit":{title:[`Studio hết lượt thử nghiệm`,`Studio live-test limit reached`],text:[`Studio đã dùng hết số request thử nghiệm được cấp. Quản trị viên cần nâng trần trước khi chạy tiếp.`,`Studio has used up its live-test request ceiling. An administrator has to raise it before anything runs.`]},"company-key":{title:[`Key công ty không dùng được`,`Company key unusable`],text:[`Key công ty đã hết hạn, bị thu hồi, hoặc Agent Watch không đọc được. Nhập lại key trong Agent Watch.`,`The company key expired, was revoked, or Agent Watch cannot read it. Import the key again in Agent Watch.`]},"company-policy":{title:[`Không được phép`,`Not allowed`],text:[`Key này không được dùng model, mức suy luận hoặc độ dài trả lời đang chọn. Nếu Harness vừa đổi, gửi lại để dùng cấu hình mới; nếu vẫn lỗi, kiểm tra Harness trong Studio.`,`This key may not use this model, thinking level or answer length. If the harness just changed, send again to use the new one; otherwise check the harness in Studio.`]},"company-new-session":{title:[`Cần cuộc trò chuyện mới`,`New conversation needed`],text:[`Cuộc trò chuyện này không tiếp tục được với tài khoản model hiện tại. Nội dung cũ vẫn đọc được; tạo cuộc trò chuyện mới để làm tiếp.`,`This conversation cannot continue with the current model account. It stays readable; start a new conversation to go on.`]},"company-rejected":{title:[`Yêu cầu bị từ chối`,`Request rejected`],text:[`Model từ chối yêu cầu này, thường vì cuộc trò chuyện đã dài hơn model hiện tại nhận được. Bấm Tiếp tục: phần cũ được tóm tắt rồi mới gửi. Nếu vẫn bị từ chối, rút gọn tin nhắn hoặc tạo cuộc trò chuyện mới.`,`The model rejected this request, usually because the conversation grew longer than the current model accepts. Press Continue: the older part is summarised before sending. If it is still rejected, shorten the message or start a new conversation.`]},"company-refused":{title:[`Model từ chối yêu cầu này`,`The model declined this request`],text:[`Nhà cung cấp model từ chối yêu cầu này theo chính sách sử dụng của họ (ví dụ: in, mã hoá hoặc gửi ra ngoài thông tin bí mật). Gửi lại nguyên văn sẽ bị từ chối tiếp; hãy viết lại yêu cầu theo cách khác.`,`The model's provider declined this request under its usage policy (for example, printing, encoding or sending out secrets). The same request is declined again; ask in a different way.`]},"company-unreachable":{title:[`Lỗi kết nối`,`Connection error`],text:[`Không kết nối được tới Studio. Kiểm tra mạng hoặc VPN rồi gửi lại.`,`Studio could not be reached. Check the network or VPN and send again.`]},"company-service":{title:[`Dịch vụ model lỗi`,`Model service error`],text:[`Studio đã nhận yêu cầu nhưng dịch vụ model phía sau không trả lời. Gửi lại; nếu lặp lại, báo quản trị viên kèm mã bên dưới.`,`Studio took the request but its model service did not answer. Send again; if it repeats, give an administrator the code below.`]},"company-config-changed":{title:[`Cấu hình vừa thay đổi`,`Configuration changed`],text:[`Key hoặc Harness vừa thay đổi trong Studio. Gửi lại để chạy với cấu hình mới.`,`The key or harness just changed in Studio. Send again to run with the new one.`]},"company-update":{title:[`Cần cập nhật Piagent`,`Piagent update needed`],text:[`Harness dùng model mà bản Piagent này chưa biết. Cập nhật Piagent rồi gửi lại.`,`The harness uses a model this Piagent does not know. Update Piagent and send again.`]},"company-tool":{title:[`Công cụ lỗi`,`Tool error`],text:[`Công cụ này không chạy được ở bước này (ví dụ subagent đã chạy đủ 8 lần cho tin nhắn này).`,`This tool could not run at this step (for example, the subagent already ran 8 times for this message).`]},"company-failed":{title:[`Lỗi chưa phân loại`,`Unclassified error`],text:[`Yêu cầu không hoàn tất. Gửi lại; nếu lặp lại, báo quản trị viên kèm mã bên dưới.`,`The request did not complete. Send again; if it repeats, give an administrator the code below.`]}},UC=[`Cuộc trò chuyện này thuộc thành viên hoặc Studio khác với key đang nhập trong Agent Watch. Nội dung cũ vẫn đọc được; tạo cuộc trò chuyện mới để làm tiếp.`,`This conversation belongs to another member or Studio than the key Agent Watch holds. It stays readable; start a new conversation to go on.`],WC={harness_route_unavailable:{title:[`Không có tài khoản AI cho vai trò này`,`No AI account for this role`],text:[`Không tài khoản AI nào của công ty đang phục vụ model của vai trò này cho team (tài khoản bị ngắt, tắt cho team hoặc hết lượt). Quản trị viên cần gắn hoặc bật tài khoản trong Studio (Tài khoản AI), hoặc đổi model của vai trò trong Harness.`,`No company AI account serves this role's model for the team right now (disconnected, off for the team or out of usage). An administrator has to link or enable one in Studio (AI accounts), or change the role's model in the harness.`]},harness_profile_unavailable:{title:[`Harness không có model cho vai trò này`,`Harness has no model for this role`],text:[`Lượt này bắt đầu khi Harness của team không có model dùng được cho vai trò này. Quản trị viên kiểm tra Harness và tài khoản AI của team trong Studio, rồi gửi lại.`,`This run started while the team's harness had no usable model for this role. An administrator checks the team's harness and AI accounts in Studio; then send again.`]}};function GC(e,t,n){let r=(t?WC[t]:void 0)??HC[e]??(e.startsWith(`company-`)?HC[`company-failed`]:void 0);return r?{title:BC(n,r.title),text:BC(n,t===`managed-session-scope-changed`?UC:r.text)}:null}function KC(e,t){return e===`main`?`Main agent`:e===`scout`?BC(t,[`Subagent scout`,`Scout subagent`]):e===`research`?BC(t,[`Subagent research`,`Research subagent`]):e===`verify`?BC(t,[`Subagent verify`,`Verify subagent`]):BC(t,[`Subagent review`,`Review subagent`])}function qC(e,t,n){return GC(e,t,n)}var JC=new Set([`company-quota`,`company-provider-limit`,`company-account`,`company-busy`,`company-trial-limit`,`company-key`,`company-policy`,`company-rejected`,`company-unreachable`,`company-service`,`company-config-changed`,`company-failed`]);function YC(e){return JC.has(e)||!e.startsWith(`company-`)}function XC(e,t){return KC(e,t)}var ZC=VC,QC={"session-revision-stale":[`Danh sách cuộc trò chuyện vừa thay đổi. Gửi lại tin nhắn.`,`The conversation list just changed. Send the message again.`],"catalog-unavailable":[`Danh sách cuộc trò chuyện chưa tải xong. Thử lại sau vài giây.`,`The conversation list has not loaded yet. Try again in a few seconds.`],"session-model-mismatch":[`Cuộc trò chuyện đã tạo nhưng đang dùng model khác model đã chọn, nên tin nhắn chưa được gửi.`,`The conversation was created with a different model than the one chosen, so the message was not sent.`],"gateway-command-response-timeout":[`Piagent chưa xác nhận được cuộc trò chuyện mới sau 2 phút; nó có thể đã được tạo và đang chạy. Xem danh sách cuộc trò chuyện bên trái trước khi gửi lại.`,`Piagent could not confirm the new conversation within 2 minutes; it may have been created and be running. Check the conversation list before sending again.`],"session-command-expired":[`Yêu cầu chờ quá lâu nên đã hết hạn. Gửi lại tin nhắn.`,`The request waited too long and expired. Send the message again.`]};function $C(e,t){let n=e.startsWith(`company-`)?qC(e,null,t):null;if(n)return`${n.title}: ${n.text}`;let r=QC[e]??ZC[e];return r?Q(t,...r):`${Q(t,`Chưa tạo được cuộc trò chuyện`,`The conversation could not be created`)} (${e}).`}function ew(e,t){let n=ZC[e?.reasonCode??``];return n?Q(t,...n):null}var tw=(e,t)=>e?.state===`connecting`?Q(t,`Đang kết nối phiên công ty…`,`Connecting the company runtime…`):ew(e,t)??Q(t,`Chưa kết nối phiên công ty. Bấm để kết nối.`,`The company runtime is not connected. Select to connect.`);function nw({locale:e,onConnected:t}){let[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1),s=()=>{o.current&&(o.current=!1,t())};if((0,v.useEffect)(()=>{let e=!0,t=()=>void Vg().then(t=>{e&&(r(t),t?.state===`ready`?s():t&&(o.current=!0))}).catch(()=>void 0);t();let n=window.setInterval(t,5e3);return()=>{e=!1,window.clearInterval(n)}},[]),!n||n.state===`ready`||n.state===`unconfigured`)return null;let c=async()=>{a(!0);try{let e=await Hg();r(e),e.state===`ready`&&s()}catch{r(await Vg().catch(()=>null)??n)}finally{a(!1)}},l=ew(n,e),u=i||n.state===`connecting`;return(0,U.jsxs)(pC,{severity:`warning`,role:`status`,sx:{mb:2},action:(0,U.jsx)($,{color:`inherit`,size:`small`,disabled:u,onClick:()=>void c(),sx:{whiteSpace:`nowrap`},children:u?Q(e,`Đang kết nối…`,`Connecting…`):Q(e,`Kết nối lại`,`Reconnect`)}),children:[Q(e,`Chế độ công ty đang tắt nên chưa đọc hay gửi tiếp được cuộc trò chuyện này. Bấm Kết nối lại; macOS có thể hỏi quyền đọc key một lần.`,`Company mode is not running, so this conversation cannot be read or continued yet. Select Reconnect; macOS may ask once to read the key.`),l&&(0,U.jsxs)(U.Fragment,{children:[` `,l]})]})}var rw=Y((0,U.jsx)(`path`,{d:`M13 3.87v.02c0 .67.45 1.23 1.08 1.43C16.93 6.21 19 8.86 19 12c0 .52-.06 1.01-.17 1.49-.14.64.12 1.3.69 1.64l.01.01c.86.5 1.98.05 2.21-.91.17-.72.26-1.47.26-2.23 0-4.5-2.98-8.32-7.08-9.57-.95-.29-1.92.44-1.92 1.44m-2.06 15.05c-2.99-.43-5.42-2.86-5.86-5.84-.54-3.6 1.66-6.77 4.83-7.76.64-.19 1.09-.76 1.09-1.43v-.02c0-1-.97-1.73-1.93-1.44-4.51 1.38-7.66 5.86-6.98 10.96.59 4.38 4.13 7.92 8.51 8.51 3.14.42 6.04-.61 8.13-2.53.74-.68.61-1.89-.26-2.39-.58-.34-1.3-.23-1.8.22-1.47 1.34-3.51 2.05-5.73 1.72`}),`DataUsageRounded`),iw=Y((0,U.jsx)(`path`,{d:`M8.4 18.2c.38.5.6 1.12.6 1.8 0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3c.44 0 .85.09 1.23.26l1.41-1.77c-.92-1.03-1.29-2.39-1.09-3.69l-2.03-.68c-.54.83-1.46 1.38-2.52 1.38-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3c0 .07 0 .14-.01.21l2.03.68c.64-1.21 1.82-2.09 3.22-2.32V5.91C9.96 5.57 9 4.4 9 3c0-1.66 1.34-3 3-3s3 1.34 3 3c0 1.4-.96 2.57-2.25 2.91v2.16c1.4.23 2.58 1.11 3.22 2.32L18 9.71V9.5c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3c-1.06 0-1.98-.55-2.52-1.37l-2.03.68c.2 1.29-.16 2.65-1.09 3.69l1.41 1.77Q17.34 17 18 17c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3c0-.68.22-1.3.6-1.8l-1.41-1.77c-1.35.75-3.01.76-4.37 0z`}),`HubRounded`),aw=Y((0,U.jsx)(`path`,{d:`M15.5 13.5c0 2-2.5 3.5-2.5 5h-2c0-1.5-2.5-3-2.5-5 0-1.93 1.57-3.5 3.5-3.5s3.5 1.57 3.5 3.5m-2.5 6h-2V21h2zm6-6.5c0 1.68-.59 3.21-1.58 4.42l1.42 1.42C20.18 17.27 21 15.23 21 13c0-2.74-1.23-5.19-3.16-6.84l-1.42 1.42C17.99 8.86 19 10.82 19 13m-3-8-4-4v3c-4.97 0-9 4.03-9 9 0 2.23.82 4.27 2.16 5.84l1.42-1.42C5.59 16.21 5 14.68 5 13c0-3.86 3.14-7 7-7v3z`}),`ModelTrainingOutlined`),ow=Y((0,U.jsx)(`path`,{d:`M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5zm6 9.09c0 4-2.55 7.7-6 8.83-3.45-1.13-6-4.82-6-8.83v-4.7l6-2.25 6 2.25z`}),`ShieldOutlined`);function sw(e){return Gr(`MuiListItem`,e)}Kr(`MuiListItem`,[`root`,`dense`,`alignItemsFlexStart`,`divider`,`gutters`,`padding`,`secondaryAction`]);function cw(e){return Gr(`MuiListItemSecondaryAction`,e)}Kr(`MuiListItemSecondaryAction`,[`root`,`disableGutters`]);var lw=e=>{let{disableGutters:t,classes:n}=e;return ba({root:[`root`,t&&`disableGutters`]},cw,n)},uw=K(`div`,{name:`MuiListItemSecondaryAction`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.disableGutters&&t.disableGutters]}})({position:`absolute`,right:16,top:`50%`,transform:`translateY(-50%)`,variants:[{props:({ownerState:e})=>e.disableGutters,style:{right:0}}]}),dw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemSecondaryAction`}),{className:r,component:i,...a}=n,o=v.useContext($d),s={...n,disableGutters:o.disableGutters},c=lw(s);return(0,U.jsx)(uw,{as:i,className:W(c.root,r),ownerState:s,ref:t,...a})});dw.muiName=`ListItemSecondaryAction`;var fw=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.alignItems===`flex-start`&&t.alignItemsFlexStart,n.divider&&t.divider,!n.disableGutters&&t.gutters,!n.disablePadding&&t.padding]},pw=e=>{let{alignItems:t,classes:n,dense:r,disableGutters:i,disablePadding:a,divider:o}=e;return ba({root:[`root`,r&&`dense`,!i&&`gutters`,!a&&`padding`,o&&`divider`,t===`flex-start`&&`alignItemsFlexStart`],secondaryAction:[`secondaryAction`]},sw,n)},mw=K(`div`,{name:`MuiListItem`,slot:`Root`,overridesResolver:fw})(ys(({theme:e})=>({display:`flex`,justifyContent:`flex-start`,alignItems:`center`,position:`relative`,textDecoration:`none`,width:`100%`,boxSizing:`border-box`,textAlign:`left`,variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>!e.disablePadding&&e.dense,style:{paddingTop:4,paddingBottom:4}},{props:({ownerState:e})=>!e.disablePadding&&!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>!e.disablePadding&&!!e.secondaryAction,style:{paddingRight:48}},{props:({ownerState:e})=>!!e.secondaryAction,style:{[`& > .${fc.root}`]:{paddingRight:48}}},{props:{alignItems:`flex-start`},style:{alignItems:`flex-start`}},{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:`padding-box`}},{props:({ownerState:e})=>e.button,style:{...Ks(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}}}}]}))),hw=K(dw,{name:`MuiListItem`,slot:`secondaryAction`})({}),gw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItem`}),{alignItems:r=`center`,children:i,className:a,component:o=`li`,dense:s=!1,disableGutters:c=!1,disablePadding:l=!1,divider:u=!1,secondaryAction:d,slotProps:f={},slots:p={},...m}=n,h=v.useContext($d),g=v.useMemo(()=>({dense:s||h.dense||!1,alignItems:r,disableGutters:c}),[r,h.dense,s,c]),_={...n,alignItems:r,dense:g.dense,disableGutters:c,disablePadding:l,divider:u,secondaryAction:d},y=pw(_),b={slots:p,slotProps:f},[x,S]=Xc(`root`,{ref:t,elementType:mw,externalForwardedProps:{component:o,...b,...m},ownerState:_,className:W(y.root,a)}),[C,w]=Xc(`secondaryAction`,{elementType:hw,shouldForwardComponentProp:!0,externalForwardedProps:b,ownerState:_,className:y.secondaryAction});return(0,U.jsx)($d.Provider,{value:g,children:(0,U.jsxs)(x,{...S,children:[i,d&&(0,U.jsx)(C,{...w,children:d})]})})}),_w=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},vw=e=>{let{disabled:t,dense:n,divider:r,disableGutters:i,selected:a,classes:o}=e,s=ba({root:[`root`,n&&`dense`,t&&`disabled`,!i&&`gutters`,r&&`divider`,a&&`selected`]},pc,o);return{...o,...s}},yw=K(tu,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiMenuItem`,slot:`Root`,overridesResolver:_w})(ys(({theme:e})=>({...e.typography.body1,display:`flex`,justifyContent:`flex-start`,alignItems:`center`,position:`relative`,textDecoration:`none`,minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:`border-box`,whiteSpace:`nowrap`,"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${mc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${mc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${mc.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${mc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${mc.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${Cu.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${Cu.inset}`]:{marginLeft:52},[`& .${bf.root}`]:{marginTop:0,marginBottom:0},[`& .${bf.inset}`]:{paddingLeft:36},[`& .${uf.root}`]:{minWidth:36},variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:`padding-box`}},{props:({ownerState:e})=>!e.dense,style:{[e.breakpoints.up(`sm`)]:{minHeight:`auto`}}},{props:({ownerState:e})=>e.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${uf.root} svg`]:{fontSize:`1.25rem`}}}]}))),bw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiMenuItem`}),{autoFocus:r=!1,component:i=`li`,dense:a=!1,divider:o=!1,disableGutters:s=!1,focusVisibleClassName:c,role:l=`menuitem`,tabIndex:u,className:d,...f}=n,p=l===`menuitemcheckbox`||l===`menuitemradio`?!!n.selected:void 0,m=tb(),h=v.useContext($d),g=v.useMemo(()=>({dense:a||h.dense||!1,disableGutters:s}),[h.dense,a,s]),_=ib(),y=Ed(),b=_.suppressInitialFocusVisible,x=_.itemsFocusableWhenDisabled,S=v.useRef(null);xs(()=>{r&&S.current&&Xy(S.current,m)},[r]);let C={...n,dense:g.dense,divider:o,disableGutters:s},w=vw(n),{root:T,...E}=w,D=Nf({id:y,ref:t,disabled:n.disabled,focusableWhenDisabled:x,selected:n.selected}),O=bs(S,D.ref),k;return u===void 0?_.variant===`selectedMenu`?k=D.tabIndex:(!n.disabled||x)&&(k=-1):k=u,(0,U.jsx)($d.Provider,{value:g,children:(0,U.jsx)(yw,{ref:O,role:l,"aria-checked":p,tabIndex:k,component:i,internalNativeButton:!1,focusableWhenDisabled:x,suppressFocusVisible:b,focusVisibleClassName:W(w.focusVisible,c),className:W(w.root,d),...f,ownerState:C,classes:E})})}),xw=Y((0,U.jsx)(`path`,{d:`m19.46 8 .79-1.75L22 5.46c.39-.18.39-.73 0-.91l-1.75-.79L19.46 2c-.18-.39-.73-.39-.91 0l-.79 1.75-1.76.79c-.39.18-.39.73 0 .91l1.75.79.79 1.76c.18.39.74.39.92 0M11.5 9.5 9.91 6c-.35-.78-1.47-.78-1.82 0L6.5 9.5 3 11.09c-.78.36-.78 1.47 0 1.82l3.5 1.59L8.09 18c.36.78 1.47.78 1.82 0l1.59-3.5 3.5-1.59c.78-.36.78-1.47 0-1.82zm7.04 6.5-.79 1.75-1.75.79c-.39.18-.39.73 0 .91l1.75.79.79 1.76c.18.39.73.39.91 0l.79-1.75 1.76-.79c.39-.18.39-.73 0-.91l-1.75-.79-.79-1.76c-.18-.39-.74-.39-.92 0`}),`AutoAwesomeRounded`),Sw=Y((0,U.jsx)(`path`,{d:`M12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6m0-2C9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96C18.67 6.59 15.64 4 12 4`}),`CloudOutlined`),Cw=Y((0,U.jsx)(`path`,{d:`M8.7 15.9 4.8 12l3.9-3.9c.39-.39.39-1.01 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59c-.39.39-.39 1.02 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4m6.6 0 3.9-3.9-3.9-3.9a.984.984 0 0 1 0-1.4c.39-.39 1.01-.39 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6c-.39.39-1.01.39-1.4 0a.984.984 0 0 1 0-1.4`}),`CodeRounded`),ww=Y((0,U.jsx)(`path`,{d:`M7 5h10v1c0 .55.45 1 1 1s1-.45 1-1V3c0-1.1-.9-1.99-2-1.99L7 1c-1.1 0-2 .9-2 2v3c0 .55.45 1 1 1s1-.45 1-1zm9.12 10.88 3.17-3.17c.39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.03-.39-1.42 0s-.39 1.02 0 1.41L17.17 12l-2.47 2.47c-.39.39-.39 1.02 0 1.41s1.03.39 1.42 0m-6.83-1.42L6.83 12l2.46-2.46c.39-.39.39-1.02 0-1.41s-1.03-.39-1.42 0L4.7 11.3c-.39.39-.39 1.02 0 1.41l3.17 3.17c.39.39 1.03.39 1.42 0 .4-.39.39-1.03 0-1.42M17 19H7v-1c0-.55-.45-1-1-1s-1 .45-1 1v3c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2v-3c0-.55-.45-1-1-1s-1 .45-1 1z`}),`DeveloperModeRounded`),Tw=Y((0,U.jsx)(`path`,{d:`M10.59 4.59C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z`}),`FolderRounded`),Ew=Y((0,U.jsx)(`path`,{d:`M12 1.27a11 11 0 00-3.48 21.46c.55.09.73-.28.73-.55v-1.84c-3.03.64-3.67-1.46-3.67-1.46-.55-1.29-1.28-1.65-1.28-1.65-.92-.65.1-.65.1-.65 1.1 0 1.73 1.1 1.73 1.1.92 1.65 2.57 1.2 3.21.92a2 2 0 01.64-1.47c-2.47-.27-5.04-1.19-5.04-5.5 0-1.1.46-2.1 1.2-2.84a3.76 3.76 0 010-2.93s.91-.28 3.11 1.1c1.8-.49 3.7-.49 5.5 0 2.1-1.38 3.02-1.1 3.02-1.1a3.76 3.76 0 010 2.93c.83.74 1.2 1.74 1.2 2.94 0 4.21-2.57 5.13-5.04 5.4.45.37.82.92.82 2.02v3.03c0 .27.1.64.73.55A11 11 0 0012 1.27`}),`GitHub`),Dw=Y((0,U.jsx)(`path`,{d:`M4 20h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2s.9 2 2 2m0-3h2v2H4zM2 6c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2m4 1H4V5h2zm-2 7h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2s.9 2 2 2m0-3h2v2H4z`}),`StorageRounded`),Ow={anthropic:`#d97757`,claude:`#d97757`,context7:`#7456f1`,chrome:`#4285f4`,deepseek:`#4d6bfe`,figma:`#1e1e1e`,gemini:`#4285f4`,github:`#24292f`,google:`#4285f4`,groq:`#f55036`,linear:`#5e6ad2`,mistral:`#f7a000`,notion:`#111111`,openai:`#10a37f`,slack:`#611f69`};function kw(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{fill:`#f24e1e`,d:`M5 2h7v7H8.5A3.5 3.5 0 0 1 5 5.5V2Z`}),(0,U.jsx)(`path`,{fill:`#ff7262`,d:`M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2Z`}),(0,U.jsx)(`path`,{fill:`#a259ff`,d:`M5 9h7v7H8.5A3.5 3.5 0 0 1 5 12.5V9Z`}),(0,U.jsx)(`circle`,{cx:`15.5`,cy:`12.5`,r:`3.5`,fill:`#1abcfe`}),(0,U.jsx)(`path`,{fill:`#0acf83`,d:`M5 16h7v3.5A3.5 3.5 0 1 1 5 16Z`})]})}function Aw(e){let t=e.toLowerCase();return t.includes(`figma`)?(0,U.jsx)(kw,{}):t.includes(`github`)?(0,U.jsx)(Ew,{fontSize:`inherit`}):t.includes(`chrome`)||t.includes(`devtools`)?(0,U.jsx)(ww,{fontSize:`inherit`}):t.includes(`anthropic`)||t.includes(`claude`)?(0,U.jsx)(xw,{fontSize:`inherit`}):t.includes(`file`)||t.includes(`folder`)?(0,U.jsx)(Tw,{fontSize:`inherit`}):t.includes(`postgres`)||t.includes(`database`)||t.includes(`supabase`)?(0,U.jsx)(Dw,{fontSize:`inherit`}):t.includes(`code`)||t.includes(`context7`)?(0,U.jsx)(Cw,{fontSize:`inherit`}):t.includes(`google`)||t.includes(`drive`)||t.includes(`cloud`)?(0,U.jsx)(Sw,{fontSize:`inherit`}):(0,U.jsx)(iw,{fontSize:`inherit`})}function jw({name:e,size:t=34}){let n=e.toLowerCase(),r=Object.keys(Ow).find(e=>n.includes(e));return(0,U.jsx)(J,{"aria-hidden":`true`,sx:{width:t,height:t,flex:`0 0 ${t}px`,display:`grid`,placeItems:`center`,borderRadius:t>30?2:1.4,bgcolor:r?Ow[r]:`action.selected`,color:r?`#fff`:`text.secondary`,fontSize:Math.round(t*.52),border:1,borderColor:r?`transparent`:`divider`},children:Aw(e)})}var Mw=Y((0,U.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m3.88-11.71L10 14.17l-1.88-1.88a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l2.59 2.59c.39.39 1.02.39 1.41 0L17.3 9.7c.39-.39.39-1.02 0-1.41s-1.03-.39-1.42 0`}),`CheckCircleOutlineRounded`),Nw=Y((0,U.jsx)(`path`,{d:`M18 19H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h5c.55 0 1-.45 1-1s-.45-1-1-1H5c-1.11 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-6c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55-.45 1-1 1M14 4c0 .55.45 1 1 1h2.59l-9.13 9.13c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0L19 6.41V9c0 .55.45 1 1 1s1-.45 1-1V3h-6c-.55 0-1 .45-1 1`}),`LaunchRounded`);function Pw(e){return Gr(`MuiDialogActions`,e)}Kr(`MuiDialogActions`,[`root`,`spacing`]);var Fw=e=>{let{classes:t,disableSpacing:n}=e;return ba({root:[`root`,!n&&`spacing`]},Pw,t)},Iw=K(`div`,{name:`MuiDialogActions`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableSpacing&&t.spacing]}})({display:`flex`,alignItems:`center`,padding:8,justifyContent:`flex-end`,flex:`0 0 auto`,variants:[{props:({ownerState:e})=>!e.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),Lw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogActions`}),{className:r,disableSpacing:i=!1,...a}=n,o={...n,disableSpacing:i},s=Fw(o);return(0,U.jsx)(Iw,{className:W(s.root,r),ownerState:o,ref:t,...a})});function Rw(e){return Gr(`MuiDialogContent`,e)}Kr(`MuiDialogContent`,[`root`,`dividers`]);function zw(e){return Gr(`MuiDialogTitle`,e)}var Bw=Kr(`MuiDialogTitle`,[`root`]),Vw=e=>{let{classes:t,dividers:n}=e;return ba({root:[`root`,n&&`dividers`]},Rw,t)},Hw=K(`div`,{name:`MuiDialogContent`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.dividers&&t.dividers]}})(ys(({theme:e})=>({flex:`1 1 auto`,WebkitOverflowScrolling:`touch`,overflowY:`auto`,padding:`20px 24px`,variants:[{props:({ownerState:e})=>e.dividers,style:{padding:`16px 24px`,borderTop:`1px solid ${(e.vars||e).palette.divider}`,borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>!e.dividers,style:{[`.${Bw.root} + &`]:{paddingTop:0}}}]}))),Uw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogContent`}),{className:r,dividers:i=!1,...a}=n,o={...n,dividers:i},s=Vw(o);return(0,U.jsx)(Hw,{className:W(s.root,r),ownerState:o,ref:t,...a})}),Ww=e=>{let{classes:t}=e;return ba({root:[`root`]},zw,t)},Gw=K(X,{name:`MuiDialogTitle`,slot:`Root`})({padding:`16px 24px`,flex:`0 0 auto`}),Kw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogTitle`}),{className:r,id:i,...a}=n,o=n,s=Ww(o),{titleId:c=i}=v.useContext(NC);return(0,U.jsx)(Gw,{component:`h2`,className:W(s.root,r),ownerState:o,ref:t,variant:`h6`,id:i??c,...a})});function qw(e){return Gr(`PrivateSwitchBase`,e)}Kr(`PrivateSwitchBase`,[`root`,`checked`,`disabled`,`input`,`edgeStart`,`edgeEnd`]);var Jw=e=>{let{classes:t,checked:n,disabled:r,edge:i}=e;return ba({root:[`root`,n&&`checked`,r&&`disabled`,i&&`edge${q(i)}`],input:[`input`]},qw,t)},Yw=K(tu,{name:`MuiSwitchBase`})({padding:9,borderRadius:`50%`,variants:[{props:{edge:`start`,size:`small`},style:{marginLeft:-3}},{props:({edge:e,ownerState:t})=>e===`start`&&t.size!==`small`,style:{marginLeft:-12}},{props:{edge:`end`,size:`small`},style:{marginRight:-3}},{props:({edge:e,ownerState:t})=>e===`end`&&t.size!==`small`,style:{marginRight:-12}}]}),Xw=K(`input`,{name:`MuiSwitchBase`,shouldForwardProp:Jo})({cursor:`inherit`,position:`absolute`,opacity:0,width:`100%`,height:`100%`,top:0,left:0,margin:0,padding:0,zIndex:1}),Zw=v.forwardRef(function(e,t){let{autoFocus:n,checked:r,checkedIcon:i,defaultChecked:a,disabled:o,disableFocusRipple:s=!1,edge:c=!1,icon:l,id:u,name:d,onBlur:f,onChange:p,onFocus:m,readOnly:h,required:g=!1,tabIndex:_,type:v,value:y,slots:b={},slotProps:x={},...S}=e,{nativeButton:C,...w}=S,[T,E]=Od({controlled:r,default:!!a,name:`SwitchBase`,state:`checked`}),D=_s(),O=e=>{m&&m(e),D&&D.onFocus&&D.onFocus(e)},k=e=>{f&&f(e),D&&D.onBlur&&D.onBlur(e)},A=e=>{if(e.nativeEvent.defaultPrevented||h)return;let t=e.target.checked;E(t),p&&p(e,t)},j=o;D&&j===void 0&&(j=D.disabled);let M=v===`checkbox`||v===`radio`,N={...e,checked:T,disabled:j,disableFocusRipple:s,edge:c},P=Jw(N),F={slots:b,slotProps:x},[I,L]=Xc(`root`,{ref:t,elementType:Yw,className:P.root,shouldForwardComponentProp:!0,externalForwardedProps:{...F,component:`span`,...w},getSlotProps:e=>({...e,onFocus:t=>{e.onFocus?.(t),O(t)},onBlur:t=>{e.onBlur?.(t),k(t)}}),ownerState:N,additionalProps:{centerRipple:!0,focusRipple:!s,role:void 0,tabIndex:null}}),[R,ee]=Xc(`input`,{elementType:Xw,className:P.input,externalForwardedProps:F,getSlotProps:e=>({...e,onChange:t=>{e.onChange?.(t),A(t)}}),ownerState:N,additionalProps:{autoFocus:n,checked:r,defaultChecked:a,disabled:j,id:M?u:void 0,name:d,readOnly:h,required:g,tabIndex:_,type:v,...v===`checkbox`&&y===void 0?{}:{value:y}}});return(0,U.jsxs)(I,{...L,children:[(0,U.jsx)(R,{...ee}),T?i:l]})});function Qw(e){return Gr(`MuiSwitch`,e)}var $w=Kr(`MuiSwitch`,[`root`,`edgeStart`,`edgeEnd`,`switchBase`,`colorPrimary`,`colorSecondary`,`sizeSmall`,`sizeMedium`,`checked`,`disabled`,`input`,`thumb`,`track`]),eT=e=>{let{classes:t,edge:n,size:r,color:i,checked:a,disabled:o}=e,s=ba({root:[`root`,n&&`edge${q(n)}`,`size${q(r)}`],switchBase:[`switchBase`,`color${q(i)}`,a&&`checked`,o&&`disabled`],thumb:[`thumb`],track:[`track`],input:[`input`]},Qw,t);return{...t,...s}},tT=K(`span`,{name:`MuiSwitch`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.edge&&t[`edge${q(n.edge)}`],t[`size${q(n.size)}`]]}})({display:`inline-flex`,width:58,height:38,overflow:`hidden`,padding:12,boxSizing:`border-box`,position:`relative`,flexShrink:0,zIndex:0,verticalAlign:`middle`,"@media print":{colorAdjust:`exact`},variants:[{props:{edge:`start`},style:{marginLeft:-8}},{props:{edge:`end`},style:{marginRight:-8}},{props:{size:`small`},style:{width:40,height:24,padding:7,[`& .${$w.thumb}`]:{width:16,height:16},[`& .${$w.switchBase}`]:{padding:4,[`&.${$w.checked}`]:{transform:`translateX(16px)`}}}}]}),nT=K(Zw,{name:`MuiSwitch`,slot:`SwitchBase`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.switchBase,{[`& .${$w.input}`]:t.input},n.color!=="default"&&t[`color${q(n.color)}`]]}})(ys(({theme:e})=>({position:`absolute`,top:0,left:0,zIndex:1,color:e.vars?e.vars.palette.Switch.defaultColor:`${e.palette.mode===`light`?e.palette.common.white:e.palette.grey[300]}`,...Ks(e,[`left`,`transform`],{duration:e.transitions.duration.shortest}),[`&.${$w.checked}`]:{transform:`translateX(20px)`},[`&.${$w.disabled}`]:{color:e.vars?e.vars.palette.Switch.defaultDisabledColor:`${e.palette.mode===`light`?e.palette.grey[100]:e.palette.grey[600]}`},[`&.${$w.checked} + .${$w.track}`]:{opacity:.5},[`&.${$w.disabled} + .${$w.track}`]:{opacity:e.vars?e.vars.opacity.switchTrackDisabled:`${e.palette.mode===`light`?.12:.2}`},[`& .${$w.input}`]:{left:`-100%`,width:`300%`}})),ys(({theme:e})=>({"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:`transparent`}},variants:[...Object.entries(e.palette).filter(Ac([`light`])).map(([t])=>({props:{color:t},style:{[`&.${$w.checked}`]:{color:(e.vars||e).palette[t].main,"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${$w.disabled}`]:{color:e.vars?e.vars.palette.Switch[`${t}DisabledColor`]:`${e.palette.mode===`light`?e.lighten(e.palette[t].main,.62):e.darken(e.palette[t].main,.55)}`}},[`&.${$w.checked} + .${$w.track}`]:{backgroundColor:(e.vars||e).palette[t].main}}}))]}))),rT=K(`span`,{name:`MuiSwitch`,slot:`Track`})(ys(({theme:e})=>({height:`100%`,width:`100%`,borderRadius:7,zIndex:-1,...Ks(e,[`opacity`,`background-color`],{duration:e.transitions.duration.shortest}),"@media (forced-colors: active)":{boxSizing:`border-box`,border:`1px solid ButtonBorder`},backgroundColor:e.vars?e.vars.palette.common.onBackground:`${e.palette.mode===`light`?e.palette.common.black:e.palette.common.white}`,opacity:e.vars?e.vars.opacity.switchTrack:`${e.palette.mode===`light`?.38:.3}`}))),iT=K(`span`,{name:`MuiSwitch`,slot:`Thumb`})(ys(({theme:e})=>({boxShadow:(e.vars||e).shadows[1],backgroundColor:`currentColor`,boxSizing:`border-box`,border:`1px solid transparent`,width:20,height:20,borderRadius:`50%`}))),aT=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiSwitch`}),{className:r,color:i=`primary`,edge:a=!1,size:o=`medium`,sx:s,slots:c={},slotProps:l={},...u}=n,d={...n,color:i,edge:a,size:o},f=eT(d),p=l.input,m={slots:c,slotProps:l},[h,g]=Xc(`root`,{className:W(f.root,r),elementType:tT,externalForwardedProps:m,ownerState:d,additionalProps:{sx:s}}),[_,v]=Xc(`thumb`,{className:f.thumb,elementType:iT,externalForwardedProps:m,ownerState:d}),y=(0,U.jsx)(_,{...v}),[b,x]=Xc(`track`,{className:f.track,elementType:rT,externalForwardedProps:m,ownerState:d});return(0,U.jsxs)(h,{...g,children:[(0,U.jsx)(nT,{type:`checkbox`,icon:y,checkedIcon:y,ref:t,ownerState:d,...u,classes:{...f,root:f.switchBase},slots:{...c.switchBase&&{root:c.switchBase},...c.input&&{input:c.input}},slotProps:{...l.switchBase&&{root:typeof l.switchBase==`function`?l.switchBase(d):l.switchBase},input:kd(typeof p==`function`?p(d):p,{role:`switch`})}}),(0,U.jsx)(b,{...x})]})});function oT(e,t){let n=e.name.toLowerCase();return n===`figma-desktop`?Q(t,`Cần bật MCP trong Figma Desktop`,`Enable MCP in Figma Desktop`):n===`figma`?e.state===`disabled`?Q(t,`Remote OAuth · chưa được Figma duyệt`,`Remote OAuth · not approved by Figma`):`Remote OAuth`:`${e.transport} · ${e.scope}`}function sT(e,t,n){return e===`mcp-oauth-client-not-approved`&&t.toLowerCase()===`figma`?Q(n,`Figma Remote chưa cho phép Piagent đăng ký OAuth. Có thể dùng kết nối Figma Desktop bên dưới.`,`Figma Remote has not approved Piagent as an OAuth client. You can use the Figma Desktop connection below.`):e===`mcp-oauth-client-not-approved`?Q(n,`Nhà cung cấp chưa cho phép client OAuth này.`,`The provider has not approved this OAuth client.`):e===`mcp-oauth-registration-rejected`?Q(n,`Nhà cung cấp từ chối đăng ký OAuth.`,`The provider rejected OAuth client registration.`):e===`mcp-oauth-cancelled`||e===`cancelled-by-user`?Q(n,`Đã hủy đăng nhập.`,`Sign in cancelled.`):Q(n,`Không thể kết nối OAuth. Vui lòng thử lại.`,`Could not connect OAuth. Please try again.`)}function cT({sessionRef:e,connection:t,onChanged:n,compact:r=!1}){let{locale:i}=Gv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,t=window.setTimeout(()=>void r_(s.jobRef,e.signal).then(e=>{c(e),e.state===`completed`&&n()}).catch(()=>u(Q(i,`Mất kết nối OAuth`,`OAuth flow disconnected`))),750);return()=>{e.abort(),window.clearTimeout(t)}},[s?.jobRef,s?.generatedAt,s?.state,i,n]);let d=async r=>{o(!0),u(null);try{let i=await n_({action:r?`mcp.enable`:`mcp.disable`,sessionRef:e,connectionRef:t.connectionRef});`connections`in i?n(i):n()}catch{u(Q(i,`Không thể cập nhật MCP`,`Could not update MCP`))}finally{o(!1)}},f=async()=>{o(!0),u(null);try{let n=await n_({action:`mcp.oauth`,sessionRef:e,connectionRef:t.connectionRef});if(`jobRef`in n)c(n);else throw Error(`mcp-oauth-job-missing`)}catch{u(Q(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{o(!1)}},p=async()=>{s?.state===`running`&&await a_(s.jobRef).catch(()=>void 0),c(void 0),u(null)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{direction:`row`,spacing:.75,sx:{alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`},children:[t.authState===`connected`&&(0,U.jsx)(lu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,U.jsx)(Mw,{}),label:Q(i,`Đã kết nối`,`Connected`)}),t.oauthSupported&&t.authState!==`connected`&&t.state!==`disabled`&&(0,U.jsx)($,{size:`small`,variant:`outlined`,disabled:a,onClick:()=>void f(),children:`OAuth`}),t.toggleSupported&&(0,U.jsx)(Ah,{title:t.state===`disabled`?Q(i,`Bật ${t.name}`,`Enable ${t.name}`):Q(i,`Tắt ${t.name}`,`Disable ${t.name}`),arrow:!0,children:(0,U.jsx)(`span`,{children:(0,U.jsx)(aT,{size:r?`small`:`medium`,checked:t.state!==`disabled`,disabled:a,onChange:(e,t)=>void d(t),slotProps:{input:{"aria-label":t.state===`disabled`?Q(i,`Bật ${t.name}`,`Enable ${t.name}`):Q(i,`Tắt ${t.name}`,`Disable ${t.name}`)}}})})})]}),l&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,children:l}),(0,U.jsxs)(zC,{open:!!s,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,U.jsxs)(Kw,{children:[t.name,` · OAuth`]}),(0,U.jsx)(Uw,{children:(0,U.jsxs)(Z,{spacing:1.25,sx:{pt:.5},children:[s?.state===`running`&&!s.authorizationUrl&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(i,`Đang chuẩn bị đăng nhập…`,`Preparing sign in…`)}),s?.authorizationUrl&&(0,U.jsx)($,{component:`a`,href:s.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,variant:`contained`,endIcon:(0,U.jsx)(Nw,{}),children:Q(i,`Mở trang đăng nhập`,`Open sign in`)}),s?.state===`completed`&&(0,U.jsx)(X,{color:`success.main`,children:Q(i,`Đã kết nối MCP`,`MCP connected`)}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,U.jsx)(X,{color:`error`,children:sT(s.reasonCode,t.name,i)})]})}),(0,U.jsx)(Lw,{children:(0,U.jsx)($,{color:`inherit`,onClick:()=>void p(),children:s?.state===`running`?Q(i,`Hủy`,`Cancel`):Q(i,`Đóng`,`Close`)})})]})]})}var lT=Y((0,U.jsx)(`path`,{d:`M12 5.99 19.53 19H4.47zM2.74 18c-.77 1.33.19 3 1.73 3h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0zM11 11v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1m0 5h2v2h-2z`}),`WarningAmberRounded`);function uT(e){return Gr(`MuiDialogContentText`,e)}Kr(`MuiDialogContentText`,[`root`]);var dT=e=>{let{classes:t}=e,n=ba({root:[`root`]},uT,t);return{...t,...n}},fT=K(X,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiDialogContentText`,slot:`Root`})({}),pT=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogContentText`}),{children:r,className:i,...a}=n,o=dT(a);return(0,U.jsx)(fT,{component:`p`,variant:`body1`,color:`textSecondary`,ref:t,ownerState:a,className:W(o.root,i),...n,classes:o})});function mT({open:e,title:t,description:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){return(0,U.jsxs)(zC,{open:e,onClose:o,fullWidth:!0,maxWidth:`xs`,"aria-describedby":`piagent-confirm-dialog-description`,slotProps:{paper:{sx:{borderRadius:3,p:.5}}},children:[(0,U.jsxs)(Kw,{sx:{display:`flex`,alignItems:`center`,gap:1.25,pb:1},children:[(0,U.jsx)(J,{sx:{width:36,height:36,borderRadius:2,display:`grid`,placeItems:`center`,bgcolor:`warning.main`,color:`warning.contrastText`},children:(0,U.jsx)(lT,{fontSize:`small`})}),(0,U.jsx)(X,{component:`span`,sx:{fontSize:`1.08rem`,fontWeight:700},children:t})]}),(0,U.jsx)(Uw,{children:(0,U.jsx)(pT,{id:`piagent-confirm-dialog-description`,sx:{color:`text.secondary`,lineHeight:1.65},children:n})}),(0,U.jsxs)(Lw,{sx:{px:2.5,pb:2,gap:.75},children:[(0,U.jsx)($,{color:`inherit`,onClick:o,autoFocus:!0,children:i}),(0,U.jsx)($,{variant:`contained`,color:`warning`,onClick:a,children:r})]})]})}function hT({name:e,value:t}){return(0,U.jsxs)(Z,{direction:`row`,sx:{justifyContent:`space-between`,gap:3,py:.65},children:[(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:e}),(0,U.jsx)(X,{variant:`body2`,sx:{fontWeight:600},children:t})]})}function gT({title:e,label:t,icon:n,active:r,badge:i,onClick:a}){let o={border:1,borderColor:r?`primary.main`:`divider`,bgcolor:r?`action.selected`:`transparent`,color:r?`primary.main`:`text.secondary`,borderRadius:2,"&:hover":{bgcolor:`action.hover`,color:`text.primary`}},s=t?(0,U.jsx)($,{size:`small`,"aria-label":e,onClick:a,startIcon:n,sx:{...o,minHeight:34,minWidth:{xs:34,md:64},maxWidth:260,px:{xs:.75,md:1.15},"& .MuiButton-startIcon":{mr:{xs:0,md:.65},ml:0},"& .MuiButton-startIcon svg":{fontSize:17}},children:(0,U.jsx)(J,{component:`span`,sx:{display:{xs:`none`,md:`inline`},overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})}):(0,U.jsx)(Qd,{size:`small`,"aria-label":e,onClick:a,sx:{...o,width:34,height:34},children:n});return(0,U.jsx)(Ah,{title:e,arrow:!0,children:i?(0,U.jsx)(rl,{badgeContent:i,color:`primary`,max:9999,sx:{"& .MuiBadge-badge":{height:16,minWidth:16,px:.4,fontSize:9,fontWeight:700}},children:s}):s})}function _T({session:e,snapshot:t,connections:n,locale:r,onOpenChanges:i,canSetModel:a,canSetThinking:o,canSetPermission:s,onSetModel:c,onSetThinking:l,onSetPermission:u,onConnectionsChanged:d,placement:f=`composer`}){let[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(f!==`header`)return;let e=new AbortController;return Ng(e.signal).then(y).catch(()=>void 0),()=>e.abort()},[f]);let E=e=>t=>{m(e),g(t.currentTarget)},D=()=>{m(null),g(null)},O=t?.sourceChanges,k=O?.workingTree.counts.files??0,A=t?.session.permissionProfile,[j,M]=(0,v.useState)(A?.state===`known`?A.value??null:null);(0,v.useEffect)(()=>{M(null)},[e.sessionRef]),(0,v.useEffect)(()=>{A?.state===`known`&&M(A.value??null)},[A?.state,A?.value]),(0,v.useEffect)(()=>{e.managedPermission&&M(e.managedPermission)},[e.managedPermission]);let N=t?.usage.context,P=N?.state===`known`,F=P?N.tokens:e.contextUsage.usedTokens,I=P?N.contextWindow:e.contextUsage.contextWindow,L=P?N.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,R=L==null?`—`:`${Math.round(L)}%`,ee=t?.session.model.state===`known`&&t.session.model.value?t.session.model.value.modelRef:``,te=_?.models.find(e=>e.modelRef===ee)??(_?.models.length===1?_.models[0]:void 0),z=e.modelLabel===`agent-watch-auto`||_?.models.length===1&&_.models[0].provider===`agent_watch_managed`,B=(0,v.useMemo)(()=>e.managedThinkingLevels??te?.thinkingLevels??(z?[]:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),[te,e.managedThinkingLevels,z]),V=async e=>{if(!(!e||!c)){x(!0),C(null);try{await c(e)}catch{C(Q(r,`Chưa thể đổi model lúc này`,`Could not change the model right now`))}finally{x(!1)}}},ne=async e=>{if(l){x(!0),C(null);try{await l(e)}catch{C(Q(r,`Chưa thể đổi thinking lúc này`,`Could not change thinking right now`))}finally{x(!1)}}},re=async e=>{if(u){x(!0),C(null);try{await u(e),M(e)}catch{C(Q(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{x(!1)}}},ie=e=>{if(e===`trusted-full-access`){D(),T(e);return}re(e)},ae=p===`model`?`Model & thinking`:p===`context`?`Context`:p===`connections`?Q(r,`MCP & kết nối`,`MCP & connections`):p===`permission`?Q(r,`Quyền`,`Access`):Q(r,`Source Changes`,`Source Changes`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(J,{sx:{display:`flex`,gap:.65,mb:f===`composer`?.8:0,px:.1,flexWrap:f===`header`?`nowrap`:`wrap`,flexShrink:0,alignItems:`center`,justifyContent:f===`header`?`flex-end`:`flex-start`},children:[f===`header`&&z&&(e.managedHelpers?.maximum??2)>0&&(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,title:Q(r,`Subagent đang chạy trong phiên này; Studio giới hạn tổng số theo thành viên.`,`Subagents running in this session; Studio caps the total per member.`),sx:{whiteSpace:`nowrap`,display:{xs:`none`,sm:`block`},mr:.5},children:[Q(r,`Subagent`,`Subagents`),` `,e.managedHelpers?.active??0,`/`,e.managedHelpers?.maximum??2]}),f===`header`&&(0,U.jsx)(gT,{active:p===`model`,onClick:E(`model`),icon:(0,U.jsx)(aw,{fontSize:`small`}),label:`${(z?`agent-watch-auto`:e.modelLabel)??Q(r,`Model session`,`Session model`)} · ${e.thinkingLevel===`unknown`||B.length>0&&!B.includes(e.thinkingLevel)?`—`:Fv(e.thinkingLevel,r)}`,title:z?`agent-watch-auto · Thinking`:Q(r,`Đổi model và mức suy luận`,`Change model and thinking level`)}),f===`header`&&(0,U.jsx)(gT,{active:p===`permission`,onClick:E(`permission`),icon:(0,U.jsx)(ow,{fontSize:`small`}),label:z?vT(j,r):j?Fv(j,r):Q(r,`Quyền`,`Access`),title:Q(r,`Đổi quyền truy cập`,`Change access level`)}),f===`composer`&&(0,U.jsx)(gT,{active:p===`context`,onClick:E(`context`),icon:(0,U.jsx)(rw,{fontSize:`small`}),title:`Context · ${R}`}),f===`composer`&&(0,U.jsx)(gT,{active:p===`connections`,onClick:E(`connections`),icon:(0,U.jsx)(iw,{fontSize:`small`}),badge:n?.summary.configured??0,title:(n?.summary.configured??0)>0?Q(r,`MCP & kết nối · ${n?.summary.configured}`,`MCP & connections · ${n?.summary.configured}`):Q(r,`MCP & kết nối`,`MCP & connections`)}),f===`composer`&&(0,U.jsx)(gT,{active:p===`changes`,onClick:E(`changes`),icon:(0,U.jsx)(Ph,{fontSize:`small`}),badge:k,title:`Source Changes${k?` · ${k}`:``}`})]}),(0,U.jsxs)(vb,{open:p!==null,anchorEl:h,onClose:D,anchorOrigin:{vertical:f===`header`?`bottom`:`top`,horizontal:`left`},transformOrigin:{vertical:f===`header`?`top`:`bottom`,horizontal:`left`},slotProps:{paper:{sx:{width:330,maxWidth:`calc(100vw - 24px)`,borderRadius:2.5,p:1.5,mt:+(f===`header`)}}},children:[(0,U.jsx)(X,{sx:{px:.5,pb:1,fontWeight:600},children:ae}),(0,U.jsx)(Du,{}),p===`model`&&(0,U.jsxs)(Z,{sx:{px:.5,pt:1},spacing:1.25,children:[z?(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{children:`agent-watch-auto`}),(0,U.jsx)(hT,{name:`Context`,value:I?new Intl.NumberFormat().format(I):`—`})]}):(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,U.jsx)(ax,{fullWidth:!0,size:`small`,value:ee,disabled:!a||b||e.liveState===`running`,onChange:e=>void V(e.target.value),sx:{mt:.5},children:(_?.models??[]).map(e=>(0,U.jsx)(bw,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,U.jsx)(ax,{fullWidth:!0,size:`small`,inputProps:{"aria-label":`Thinking`},value:e.thinkingLevel===`unknown`?``:e.thinkingLevel,disabled:!o||b||e.liveState===`running`,onChange:e=>void ne(e.target.value),sx:{mt:.5},children:B.map(e=>(0,U.jsx)(bw,{value:e,children:Fv(e,r)},e))})]}),S&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`context`&&(0,U.jsxs)(J,{sx:{px:.5,pt:.75},children:[(0,U.jsx)(hT,{name:Q(r,`Đã dùng`,`Used`),value:R}),(0,U.jsx)(hT,{name:`Tokens`,value:F===null?`—`:new Intl.NumberFormat().format(F)}),(0,U.jsx)(hT,{name:`Window`,value:I===null?`—`:new Intl.NumberFormat().format(I)})]}),p===`connections`&&(0,U.jsxs)(rf,{dense:!0,disablePadding:!0,sx:{pt:.5},children:[(n?.connections??[]).map(t=>(0,U.jsxs)(gw,{sx:{alignItems:`center`,gap:.5},children:[(0,U.jsx)(pf,{sx:{minWidth:38},children:(0,U.jsx)(jw,{name:t.name,size:28})}),(0,U.jsx)(Cf,{primary:t.name,secondary:oT(t,r)}),(0,U.jsx)(cT,{compact:!0,sessionRef:e.sessionRef,connection:t,onChanged:e=>d?.(e)})]},t.connectionRef)),n&&n.connections.length===0&&(0,U.jsx)(gw,{children:(0,U.jsx)(Cf,{primary:Q(r,`Chưa có MCP`,`No MCP configured`)})}),!n&&(0,U.jsx)(gw,{children:(0,U.jsx)(Cf,{primary:Q(r,`Đang đọc…`,`Loading…`)})})]}),p===`permission`&&(0,U.jsxs)(Z,{sx:{px:.5,pt:1},spacing:.75,children:[(z?[`workspace-write`,`trusted-full-access`]:[`read-only`,`workspace-write`,`trusted-full-access`]).map(t=>(0,U.jsx)($,{variant:j===t?`contained`:`outlined`,color:t===`trusted-full-access`?`warning`:`primary`,disabled:!s||b||e.liveState===`running`,onClick:()=>ie(t),sx:{justifyContent:`flex-start`},children:z?vT(t,r):Fv(t,r)},t)),S&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`changes`&&(0,U.jsxs)(J,{sx:{px:.5,pt:.75},children:[(0,U.jsx)(hT,{name:Q(r,`Task changes`,`Task changes`),value:String(O?.task?.counts.files??0)}),(0,U.jsx)(hT,{name:Q(r,`Working tree`,`Working tree`),value:String(O?.workingTree.counts.files??0)}),(0,U.jsx)(hT,{name:Q(r,`Staged`,`Staged`),value:String(O?.staged.counts.files??0)}),(0,U.jsx)($,{fullWidth:!0,variant:`outlined`,startIcon:(0,U.jsx)(Ph,{}),sx:{mt:1},onClick:()=>{D(),i()},children:Q(r,`Mở Source Changes`,`Open Source Changes`)})]})]}),(0,U.jsx)(mT,{open:w!==null,title:z?Q(r,`Bật Bypass?`,`Turn on Bypass?`):Q(r,`Bật toàn quyền?`,`Enable full access?`),description:z?yT(r):Q(r,`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:Q(r,`Hủy`,`Cancel`),confirmLabel:z?Q(r,`Bật Bypass`,`Turn on Bypass`):Q(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>T(null),onConfirm:()=>{T(null),re(`trusted-full-access`)}})]})}function vT(e,t){return e===`trusted-full-access`?`Bypass`:Q(t,`Hỏi trước`,`Ask first`)}function yT(e){return Q(e,`Lệnh cần internet (cài package, tải file, git pull, test có server hay browser) chạy luôn, không hỏi. Vẫn hỏi trước khi đẩy hoặc gửi dữ liệu ra ngoài (git push, publish, deploy, upload, ssh), chạy migration database, xóa mà không rõ đích hoặc dùng sudo.`,`Commands that need the internet (package installs, downloads, git pull, tests with a server or browser) run without asking. You are still asked before anything that pushes or sends data out (git push, publish, deploy, uploads, ssh), database migrations, deletes whose target is unknown, and sudo.`)}function bT(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229}var xT=Y((0,U.jsx)(`path`,{d:`M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42a.996.996 0 0 0-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1`}),`ArrowBackRounded`),ST=Y((0,U.jsx)(`path`,{d:`M12 7V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zM6 19H4v-2h2zm0-4H4v-2h2zm0-4H4V9h2zm0-4H4V5h2zm4 12H8v-2h2zm0-4H8v-2h2zm0-4H8V9h2zm0-4H8V5h2zm9 12h-7v-2h2v-2h-2v-2h2v-2h-2V9h7c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1m-1-8h-2v2h2zm0 4h-2v2h2z`}),`BusinessRounded`),CT=Y((0,U.jsx)(`path`,{d:`M15.88 9.29 12 13.17 8.12 9.29a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0`}),`ExpandMoreRounded`),wT=Y((0,U.jsx)(`path`,{d:`M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m0 12H4V8h16z`}),`FolderOpenOutlined`),TT=Y((0,U.jsx)(`path`,{d:`m11.19 1.36-7 3.11C3.47 4.79 3 5.51 3 6.3V11c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V6.3c0-.79-.47-1.51-1.19-1.83l-7-3.11c-.51-.23-1.11-.23-1.62 0M12 11.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11z`}),`SecurityRounded`),ET=Y((0,U.jsx)(`path`,{d:`M3 18c0 .55.45 1 1 1h5v-2H4c-.55 0-1 .45-1 1M3 6c0 .55.45 1 1 1h9V5H4c-.55 0-1 .45-1 1m10 14v-1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7v-1c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1M7 10v1H4c-.55 0-1 .45-1 1s.45 1 1 1h3v1c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1s-1 .45-1 1m14 2c0-.55-.45-1-1-1h-9v2h9c.55 0 1-.45 1-1m-5-3c.55 0 1-.45 1-1V7h3c.55 0 1-.45 1-1s-.45-1-1-1h-3V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1`}),`TuneRounded`);function DT(e){return Gr(`MuiListSubheader`,e)}Kr(`MuiListSubheader`,[`root`,`colorPrimary`,`colorInherit`,`gutters`,`inset`,`sticky`]);var OT=e=>{let{classes:t,color:n,disableGutters:r,inset:i,disableSticky:a}=e;return ba({root:[`root`,n!=="default"&&`color${q(n)}`,!r&&`gutters`,i&&`inset`,!a&&`sticky`]},DT,t)},kT=K(`li`,{name:`MuiListSubheader`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color!=="default"&&t[`color${q(n.color)}`],!n.disableGutters&&t.gutters,n.inset&&t.inset,!n.disableSticky&&t.sticky]}})(ys(({theme:e})=>({boxSizing:`border-box`,lineHeight:`48px`,listStyle:`none`,color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14),variants:[{props:{color:`primary`},style:{color:(e.vars||e).palette.primary.main}},{props:{color:`inherit`},style:{color:`inherit`}},{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:72}},{props:({ownerState:e})=>!e.disableSticky,style:{position:`sticky`,top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),AT=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListSubheader`}),{className:r,color:i=`default`,component:a=`li`,disableGutters:o=!1,disableSticky:s=!1,inset:c=!1,...l}=n,u={...n,color:i,component:a,disableGutters:o,disableSticky:s,inset:c},d=OT(u);return(0,U.jsx)(kT,{as:a,className:W(d.root,r),ref:t,ownerState:u,...l})}),jT=Y((0,U.jsx)(`path`,{d:`m19 9 1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25zm0 6-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25zm-7.5-5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12zm-1.51 3.49L9 15.17l-.99-2.18L5.83 12l2.18-.99L9 8.83l.99 2.18 2.18.99z`}),`AutoAwesomeOutlined`),MT=Y((0,U.jsx)(`path`,{d:`M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm4 18H6V4h7v5h5z`}),`DescriptionOutlined`),NT=Y((0,U.jsx)(`path`,{d:`m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z`}),`FolderOutlined`);function PT(e,t){let n=e.slice(0,t),r=/(^|[\s(])@"([^"\n]*)$/.exec(n);if(r)return{start:r.index+r[1].length,end:e[t]===`"`?t+1:t,query:r[2],quoted:!0};let i=/(^|[\s(])@([^\s"]*)$/.exec(n);return i?{start:i.index+i[1].length,end:t+(/^[^\s"]*/.exec(e.slice(t))?.[0].length??0),query:i[2],quoted:!1}:null}function FT(e,t,n){let r=t.quoted||/\s/.test(n.value),i=r?`@"${n.value}"`:`@${n.value}`,a=n.kind===`directory`,o=e.slice(t.end),s=a||/^\s/.test(o)?``:` `;return{text:e.slice(0,t.start)+i+s+o,caret:t.start+i.length+s.length-(a&&r?1:0)}}function IT(e,t){let n=e.slice(0,t);return/^\/[^\s/]*$/.test(n)?{start:0,end:t+(/^[^\s]*/.exec(e.slice(t))?.[0].length??0),query:n.slice(1),quoted:!1}:null}function LT(e,t,n){let r=n.kind===`skill`?`/skill:${n.name}`:`/${n.name}`,i=e.slice(t.end);return{text:r+(/^\s/.test(i)?``:` `)+i,caret:r.length+1}}var RT=20,zT=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase();function BT(e,t,n){let r=zT(t.replace(/^skill:/,``)),i=e=>zT(e.name).startsWith(r)?0:zT(e.name).includes(r)?1:zT(e.description).includes(r)?2:3,a=e=>`${e.scope===`user`?`~/`:``}.${e.origin===`pi`?`pi`:e.origin}`;return e.filter(e=>i(e)<3&&(!t.startsWith(`skill:`)||e.kind===`skill`)).sort((e,t)=>i(e)-i(t)||e.name.localeCompare(t.name)).slice(0,RT).map(e=>({key:`${e.kind}:${e.name}`,icon:e.kind,label:e.kind===`skill`?`/skill:${e.name}`:`/${e.name}`,hint:e.argumentHint,detail:`${e.description}${e.description?` · `:``}${e.kind===`skill`?`skill`:Q(n,`lệnh`,`command`)} ${a(e)}`,apply:(t,n)=>LT(t,n,e)}))}function VT({projectRef:e,value:t,onChange:n,locale:r}){let i=(0,v.useRef)(null),a=(0,v.useId)(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(0),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),y=e&&o!==null&&o<=t.length?o:null,b=y===null?null:IT(t,y),x=y===null||b?null:PT(t,y),S=b??x,C=b?`command`:`path`,w=S&&`${C}:${S.start}`!==u?S:null,T=w&&C===`path`?w.query:null;(0,v.useEffect)(()=>{if(T===null||!e){h(null);return}let t=new AbortController,n=setTimeout(()=>{I_(e,T,t.signal).then(e=>{h({query:T,items:e.suggestions.map(e=>({key:e.value,label:e.label,hint:null,icon:e.kind,detail:e.detail.slice(0,Math.max(0,e.detail.length-e.label.replace(/\/$/,``).length)),apply:(t,n)=>FT(t,n,e)}))}),p(0)}).catch(()=>{t.signal.aborted||h({query:T,items:[]})})},90);return()=>{clearTimeout(n),t.abort()}},[e,T]);let E=!!(w&&C===`command`&&e&&g?.projectRef!==e);(0,v.useEffect)(()=>{if(!E||!e)return;let t=new AbortController;return L_(e,t.signal).then(t=>_({projectRef:e,list:t.commands})).catch(()=>{t.signal.aborted||_({projectRef:e,list:[]})}),()=>t.abort()},[E,e]);let D=w?C===`path`?m?.items??null:g&&g.projectRef===e?BT(g.list,w.query,r):null:null;(0,v.useEffect)(()=>{p(0)},[C,w?.query]);let O=!!(c&&w&&D&&i.current),k=O?D:[];(0,v.useEffect)(()=>{O&&document.getElementById(`${a}-${f}`)?.scrollIntoView({block:`nearest`})},[O,f,a]);let A=e=>{if(!w)return;let r=e.apply(t,w);n(r.text),s(r.caret),requestAnimationFrame(()=>{let e=i.current;e&&(e.focus(),e.setSelectionRange(r.caret,r.caret),s(r.caret))})},j=e=>!O||e.nativeEvent.isComposing||e.keyCode===229?!1:e.key===`Escape`?(e.preventDefault(),d(`${C}:${w.start}`),!0):k.length?e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),p(t=>(t+(e.key===`ArrowDown`?1:k.length-1))%k.length),!0):(e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),A(k[Math.min(f,k.length-1)]),!0):!1,M=e=>e===`directory`?(0,U.jsx)(NT,{fontSize:`small`,color:`primary`}):e===`file`?(0,U.jsx)(MT,{fontSize:`small`,color:`action`}):e===`skill`?(0,U.jsx)(jT,{fontSize:`small`,color:`secondary`}):(0,U.jsx)(Fh,{fontSize:`small`,color:`primary`}),N=C===`command`?Q(r,`Lệnh và skill`,`Commands and skills`):Q(r,`File và folder`,`Files and folders`),P=i.current,F=(0,U.jsx)(vh,{open:O,anchorEl:P,placement:`top-start`,disablePortal:!0,sx:{zIndex:1350,width:Math.min(640,P?.clientWidth??640)},modifiers:[{name:`offset`,options:{offset:[0,10]}}],children:(0,U.jsxs)(Pc,{elevation:8,sx:{borderRadius:2,overflow:`hidden`,display:`flex`,flexDirection:`column`,maxHeight:340},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{px:1.5,pt:1,pb:.5},children:C===`command`?Q(r,`Lệnh và skill của project và trên máy này · Tab để chọn`,`Commands and skills of the project and on this computer · Tab to pick`):Q(r,`File và folder · gõ ~/ hoặc / để chọn folder khác trên máy · Tab để chọn`,`Files and folders · type ~/ or / for other folders on this computer · Tab to pick`)}),k.length?(0,U.jsx)(J,{component:`ul`,role:`listbox`,id:a,"aria-label":N,sx:{listStyle:`none`,m:0,p:.5,pt:0,overflowY:`auto`},children:k.map((e,t)=>(0,U.jsxs)(J,{component:`li`,id:`${a}-${t}`,role:`option`,"aria-selected":t===f,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>p(t),onClick:()=>A(e),sx:{display:`flex`,alignItems:`center`,gap:1,minWidth:0,px:1,py:.55,borderRadius:1.5,cursor:`pointer`,bgcolor:t===f?`action.selected`:`transparent`},children:[M(e.icon),(0,U.jsx)(X,{noWrap:!0,sx:{flexShrink:0,maxWidth:`55%`,fontSize:14,fontWeight:600},children:e.label}),e.hint&&(0,U.jsx)(X,{noWrap:!0,variant:`caption`,sx:{flexShrink:0,maxWidth:`25%`,fontFamily:`monospace`},children:e.hint}),(0,U.jsx)(X,{noWrap:!0,variant:`caption`,color:`text.secondary`,sx:{minWidth:0},children:e.detail})]},e.key))}):(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,pb:1.25},children:C===`command`?Q(r,`Không có lệnh hoặc skill khớp`,`No matching command or skill`):Q(r,`Không có file hoặc folder khớp`,`No matching file or folder`)})]})}),I=e=>s(e.target.selectionStart??null);return{inputRef:i,menu:F,onKeyDown:j,track:I,inputProps:{onFocus:()=>l(!0),onBlur:()=>l(!1)},htmlInput:{onSelect:I,"aria-autocomplete":`list`,"aria-controls":O&&k.length?a:void 0,"aria-activedescendant":O&&k.length?`${a}-${f}`:void 0}}}var HT=`new-chat`,UT=`piagent.composer-drafts.v1`,WT=50,GT=32768,KT=12096e5,qT=null,JT,YT=new Map;function XT(){if(qT)return qT;qT=new Map;try{let e=JSON.parse(window.localStorage.getItem(UT)??`{}`),t=Date.now();for(let[n,r]of Object.entries(e??{}))typeof r?.text==`string`&&typeof r.savedAt==`number`&&t-r.savedAt<KT&&qT.set(n,{text:r.text.slice(0,GT),savedAt:r.savedAt})}catch{}return qT}function ZT(){JT!==void 0&&(window.clearTimeout(JT),JT=void 0);try{let e=[...XT()].sort((e,t)=>t[1].savedAt-e[1].savedAt).slice(0,WT);window.localStorage.setItem(UT,JSON.stringify(Object.fromEntries(e)))}catch{}}var QT=!1;function $T(){QT||(QT=!0,window.addEventListener(`pagehide`,ZT)),JT===void 0&&(JT=window.setTimeout(ZT,300))}function eE(e){return XT().get(e)?.text??``}function tE(e,t){let n=XT();if(t.trim())n.set(e,{text:t.slice(0,GT),savedAt:Date.now()});else if(!n.delete(e))return;$T()}function nE(e){return YT.get(e)}function rE(e,t){t===null?YT.delete(e):YT.set(e,t)}var iE=`agent_watch_managed`;function aE({active:e,defaultProjectRef:t,busy:n,error:r,onCancel:i,onCreate:a}){let{locale:o}=Gv(),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(void 0),[d,f]=(0,v.useState)(!1),p=l===null&&s?.models.length===1&&s.models[0].provider===`agent_watch_managed`,[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(`high`),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(()=>eE(HT)),k=e=>{O(e),tE(HT,e)},[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(()=>nE(`new-chat`)??[]),[P,F]=(0,v.useState)(null);(0,v.useEffect)(()=>{rE(HT,M.length?M:null)},[M]);let[I,L]=(0,v.useState)(!1),R=(0,v.useRef)(0),[ee,te]=(0,v.useState)(null),[z,B]=(0,v.useState)(null),[V,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e)return;let n=new AbortController;return c(void 0),h(!1),ie(null),F(null),L(!1),w(!1),R.current=0,Ng(n.signal).then(e=>{n.signal.aborted||(c(e),_(e.projects.some(e=>e.projectRef===t)?t:e.projects[0]?.projectRef??``),b(e.defaultModelRef??``),S(e.defaultThinkingLevel??`high`),E(null))}).catch(()=>{n.signal.aborted||h(!0)}),u(void 0),Vg(n.signal).then(e=>{n.signal.aborted||u(e)}).catch(()=>{n.signal.aborted||u(null)}),()=>n.abort()},[e,t]),(0,v.useEffect)(()=>{if(!e)return;let t=e=>{uS(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,t),window.addEventListener(`drop`,t),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`drop`,t)}},[e]);let ae=s?.projects.find(e=>e.projectRef===g),oe=VT({projectRef:ae?.projectRef,value:D,onChange:k,locale:o}),se=s?.models.find(e=>e.modelRef===y),H=!p&&se?.provider===iE,ce=p?[]:s?.models.filter(e=>e.provider===iE)??[],le=p?s?.models??[]:s?.models.filter(e=>e.provider!==iE)??[],ue=async()=>{f(!0);try{let e=await Hg().catch(()=>null),t=await Ng();c(t),u(e??await Vg().catch(()=>null));let n=t.models.find(e=>e.provider===iE);n&&(b(n.modelRef),me())}catch{h(!0)}finally{f(!1)}},de=s?.models.find(e=>e.modelRef===s.defaultModelRef),fe=(0,v.useMemo)(()=>se?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[se]);(0,v.useEffect)(()=>{fe.includes(x)||S(fe.includes(`high`)?`high`:fe[0]??`off`)},[y,fe]);let pe=e=>t=>{te(e),B(t.currentTarget)},me=()=>{te(null),B(null)},he=async()=>{ne(!0),ie(null);try{let e=await Bg(),t=e.projects?.length?e.projects:[e.project];c(e=>e&&{...e,projects:[...e.projects.filter(e=>!t.some(t=>t.projectRef===e.projectRef)),...t]}),_(e.project.projectRef),me()}catch(e){e instanceof kg&&e.status===409?ie(null):ie(Q(o,`Không thể thêm thư mục`,`Could not add this folder`))}finally{ne(!1)}},ge=e=>{if(!e?.length)return;let t=[...M],n=!1;for(let r of[...e])if(!t.some(e=>e.name===r.name&&e.size===r.size&&e.lastModified===r.lastModified)){if(t.length===4){n=!0;continue}t.push(r)}N(t),F(n?Q(o,`Mỗi tin nhắn nhận tối đa 4 file.`,`Each message accepts at most 4 files.`):null)},_e=!n&&!m&&M.length<4,ve=(0,v.useRef)(!1),ye=()=>{ve.current||n||!ae||!D.trim()||(ve.current=!0,Promise.resolve(a({projectRef:g,placeRef:ae.placeRef,modelRef:y||null,thinkingLevel:x,permissionMode:T,message:D,files:M})).finally(()=>{ve.current=!1}))};return(0,U.jsxs)(J,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,U.jsx)(J,{sx:{p:{xs:1.5,sm:2}},children:(0,U.jsx)(Qd,{"aria-label":Q(o,`Quay lại`,`Back`),onClick:i,children:(0,U.jsx)(xT,{})})}),(0,U.jsxs)(Z,{sx:{flex:1,alignItems:`center`,justifyContent:`center`,px:2,pb:{xs:5,md:12}},spacing:4,children:[(0,U.jsx)(X,{component:`h1`,sx:{fontSize:{xs:`2rem`,md:`2.45rem`},fontWeight:500,letterSpacing:`-.035em`,textAlign:`center`},children:Q(o,`Hôm nay làm gì?`,`What should we work on?`)}),(0,U.jsxs)(J,{sx:{position:`relative`,width:`100%`,maxWidth:820,border:1,borderColor:I?`primary.main`:`divider`,borderStyle:I?`dashed`:`solid`,borderRadius:3.5,bgcolor:`background.paper`,p:1.25,boxShadow:`0 18px 55px rgba(0,0,0,.13)`},onDragEnter:e=>{uS(e.dataTransfer)&&(R.current+=1,L(!0))},onDragOver:e=>{uS(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=_e?`copy`:`none`)},onDragLeave:e=>{uS(e.dataTransfer)&&(--R.current,R.current<=0&&(R.current=0,L(!1)))},onDrop:e=>{uS(e.dataTransfer)&&(e.preventDefault(),R.current=0,L(!1),_e&&ge(e.dataTransfer.files))},children:[I&&(0,U.jsxs)(J,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3.5,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,U.jsx)(X,{sx:{fontWeight:750},children:_e?Q(o,`Thả tài liệu vào đây`,`Drop documents here`):M.length>=4?Q(o,`Đã đủ 4 file cho tin nhắn đầu tiên`,`The first message already holds 4 files`):Q(o,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),_e&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(o,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),!s&&!m?(0,U.jsxs)(Z,{direction:`row`,spacing:1.5,sx:{minHeight:126,alignItems:`center`,justifyContent:`center`},children:[(0,U.jsx)(xu,{size:20}),(0,U.jsx)(X,{color:`text.secondary`,children:Q(o,`Đang mở…`,`Opening…`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(ux,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:3,maxRows:8,value:D,disabled:n||m,inputRef:oe.inputRef,...oe.inputProps,onChange:e=>{k(e.target.value),oe.track(e)},onKeyDown:e=>{oe.onKeyDown(e)||bT(e)&&(e.preventDefault(),ye())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),_e&&ge(e.clipboardData.files))},placeholder:Q(o,`Nhắn cho Piagent… (@ để chọn file, folder)`,`Message Piagent… (@ for files and folders)`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:{maxLength:32768,...oe.htmlInput}},sx:{px:.5}}),oe.menu,M.length>0&&(0,U.jsx)(Z,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pt:.75},"aria-label":Q(o,`File sẽ gửi cùng tin nhắn đầu tiên`,`Files for the first message`),children:M.map(e=>(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:`${e.name} · ${sS(e.size)}`,onDelete:n?void 0:()=>{N(t=>t.filter(t=>t!==e)),F(null)},deleteIcon:(0,U.jsx)(YS,{"aria-label":`${Q(o,`Bỏ`,`Remove`)} ${e.name}`,role:`button`})},`${e.name}:${e.size}:${e.lastModified}`))}),(0,U.jsx)(jC,{in:C,id:`piagent-new-session-options`,children:(0,U.jsxs)(J,{sx:{mx:.35,mt:1,px:1.1,py:1,borderRadius:2,bgcolor:`action.hover`},children:[(0,U.jsx)(X,{variant:`caption`,sx:{display:`block`,mb:.75,fontWeight:750},children:Q(o,`Tùy chọn cho tin nhắn đầu tiên`,`Options for the first message`)}),(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:(0,U.jsx)(ET,{}),endIcon:(0,U.jsx)(CT,{}),onClick:pe(`thinking`),children:Fv(x,o)}),(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:(0,U.jsx)(TT,{}),endIcon:(0,U.jsx)(CT,{}),onClick:pe(`permission`),children:p||H?vT(T,o):T?Fv(T,o):Q(o,`Quyền theo profile`,`Profile access`)}),(0,U.jsxs)($,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,U.jsx)(JS,{}),disabled:!_e,"aria-label":`${Q(o,`Thêm file`,`Add files`)} (${M.length}/4)`,children:[Q(o,`Đính kèm`,`Attach`),(0,U.jsx)(`input`,{type:`file`,hidden:!0,multiple:!0,disabled:!_e,accept:aS,onChange:e=>{ge(e.target.files),e.currentTarget.value=``}})]})]}),H&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.75},children:Q(o,`Model và quyền theo Harness công ty; thinking chọn ở đây.`,`Models and access follow the company Harness; choose thinking here.`)})]})}),(0,U.jsxs)(Z,{direction:`row`,sx:{mt:1,alignItems:`center`,gap:.65,flexWrap:`nowrap`,minWidth:0},children:[(0,U.jsx)(Ah,{title:C?Q(o,`Ẩn tùy chọn`,`Hide options`):Q(o,`Thêm tùy chọn`,`More options`),children:(0,U.jsx)(Qd,{size:`small`,"aria-label":C?Q(o,`Ẩn tùy chọn`,`Hide options`):Q(o,`Thêm tùy chọn`,`More options`),"aria-expanded":C,"aria-controls":`piagent-new-session-options`,onClick:()=>w(e=>!e),sx:{flex:`0 0 auto`,bgcolor:C?`action.selected`:`transparent`},children:(0,U.jsx)(qS,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:C?`rotate(45deg)`:`none`}})})}),(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:(0,U.jsx)(wT,{}),endIcon:(0,U.jsx)(CT,{}),onClick:pe(`project`),"aria-label":`${Q(o,`Project`,`Project`)}: ${ae?.label??Q(o,`Chọn project`,`Choose project`)}`,sx:{minWidth:0,maxWidth:{xs:118,sm:250},px:{xs:.75,sm:1},"& .MuiButton-startIcon":{display:{xs:`none`,sm:`inherit`}}},children:(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:ae?.label??Q(o,`Chọn project`,`Choose project`)})}),(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:H?(0,U.jsx)(ST,{}):(0,U.jsx)(aw,{}),endIcon:(0,U.jsx)(CT,{}),onClick:pe(`model`),"aria-label":`${Q(o,`Model`,`Model`)}: ${H?Q(o,`Công ty · agent-watch-auto`,`Company · agent-watch-auto`):se?.displayName??de?.displayName??Q(o,`Mặc định của Pi`,`Pi default`)}`,sx:{minWidth:0,maxWidth:{xs:142,sm:250},px:{xs:.75,sm:1},"& .MuiButton-startIcon":{display:{xs:`none`,sm:`inherit`}}},children:(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:H?Q(o,`Công ty · agent-watch-auto`,`Company · agent-watch-auto`):se?`${se.displayName}${se.modelRef===s?.defaultModelRef?Q(o,` · mặc định`,` · default`):``}`:de?.displayName??Q(o,`Mặc định của Pi`,`Pi default`)})}),(0,U.jsx)(J,{sx:{flex:1,minWidth:0}}),(0,U.jsx)(Qd,{"aria-label":Q(o,`Gửi`,`Send`),disabled:n||m||!ae||!D.trim(),onClick:ye,sx:{flex:`0 0 auto`,bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,U.jsx)(ZS,{fontSize:`small`})})]})]}),(P||re||r||m)&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,sx:{display:`block`,px:.5,pt:1},children:P??re??r??Q(o,`Không tải được lựa chọn`,`Could not load choices`)})]})]}),(0,U.jsxs)(Eb,{anchorEl:z,open:ee===`project`,onClose:me,slotProps:{paper:{sx:{width:310,maxHeight:380}}},children:[(s?.projects??[]).map(e=>(0,U.jsxs)(bw,{selected:g===e.projectRef,onClick:()=>{_(e.projectRef),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(jw,{name:`folder`,size:26})}),(0,U.jsx)(Cf,{primary:e.label,secondary:e.hint,slotProps:{secondary:{noWrap:!0,title:e.hint}}})]},e.projectRef)),(0,U.jsx)(Du,{}),(0,U.jsxs)(bw,{disabled:V||s?.projectImport?.status!==`available`,onClick:()=>void he(),children:[(0,U.jsx)(pf,{children:(0,U.jsx)(qS,{})}),(0,U.jsx)(Cf,{primary:V?Q(o,`Đang chọn…`,`Choosing…`):Q(o,`Thêm một hoặc nhiều folder`,`Add one or more folders`)})]})]}),(0,U.jsxs)(Eb,{anchorEl:z,open:ee===`model`,onClose:me,slotProps:{paper:{sx:{width:360,maxHeight:440}}},children:[!p&&(ce.length>0||l?.available)&&[(0,U.jsx)(AT,{children:Q(o,`Công ty`,`Company`)},`company-heading`),...ce.length?ce.map(e=>(0,U.jsxs)(bw,{selected:y===e.modelRef,onClick:()=>{b(e.modelRef),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ST,{})}),(0,U.jsx)(Cf,{primary:`agent-watch-auto`,secondary:Q(o,`Harness công ty · Studio quản lý model`,`Company Harness · models managed by Studio`)})]},e.modelRef)):[(0,U.jsxs)(bw,{disabled:d,onClick:()=>void ue(),children:[(0,U.jsx)(pf,{children:d?(0,U.jsx)(xu,{size:20}):(0,U.jsx)(ST,{})}),(0,U.jsx)(Cf,{primary:`agent-watch-auto`,secondary:d?Q(o,`Đang kết nối…`,`Connecting…`):tw(l,o),slotProps:{secondary:{sx:{whiteSpace:`normal`}}}})]},`company-connect`)],(0,U.jsx)(AT,{children:Q(o,`Cá nhân`,`Personal`)},`personal-heading`)],!s?.defaultModelRef&&(0,U.jsxs)(bw,{selected:!y,onClick:()=>{b(``),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(aw,{})}),(0,U.jsx)(Cf,{primary:Q(o,`Model mặc định của Pi`,`Pi default model`)})]}),le.map(e=>(0,U.jsxs)(bw,{selected:y===e.modelRef,onClick:()=>{b(e.modelRef),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(jw,{name:e.provider,size:26})}),(0,U.jsx)(Cf,{primary:e.displayName,secondary:e.modelRef===s?.defaultModelRef?Q(o,`Mặc định · ${e.provider} · High`,`Default · ${e.provider} · High`):e.provider})]},e.modelRef))]}),(0,U.jsx)(Eb,{anchorEl:z,open:ee===`thinking`,onClose:me,slotProps:{paper:{sx:{width:250,maxHeight:400}}},children:fe.map(e=>(0,U.jsxs)(bw,{value:e,selected:x===e,onClick:()=>{S(e),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ET,{})}),(0,U.jsx)(Cf,{primary:Fv(e,o)})]},e))}),(0,U.jsx)(Eb,{anchorEl:z,open:ee===`permission`,onClose:me,slotProps:{paper:{sx:{width:310}}},children:p||H?[(0,U.jsxs)(bw,{selected:T!==`trusted-full-access`,onClick:()=>{E(null),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(TT,{})}),(0,U.jsx)(Cf,{primary:vT(null,o),secondary:Q(o,`Hỏi trước mỗi lệnh cần internet`,`Asks before each command that needs the internet`)})]},`ask`),(0,U.jsxs)(bw,{selected:T===`trusted-full-access`,onClick:()=>{me(),j(`trusted-full-access`)},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(TT,{color:`warning`})}),(0,U.jsx)(Cf,{primary:`Bypass`,secondary:Q(o,`Chỉ hỏi việc bắt buộc phải xác nhận`,`Asks only what must be confirmed`)})]},`bypass`)]:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(bw,{selected:T===null,onClick:()=>{E(null),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(TT,{})}),(0,U.jsx)(Cf,{primary:Q(o,`Theo profile project`,`Project profile default`)})]}),[`read-only`,`workspace-write`,`trusted-full-access`].map(e=>(0,U.jsxs)(bw,{selected:T===e,onClick:()=>{me(),e===`trusted-full-access`?j(e):E(e)},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(TT,{})}),(0,U.jsx)(Cf,{primary:Fv(e,o)})]},e))]})}),(0,U.jsx)(mT,{open:A!==null,title:p||H?Q(o,`Tạo cuộc trò chuyện với Bypass?`,`Create with Bypass?`):Q(o,`Tạo session với toàn quyền?`,`Create with full access?`),description:p||H?yT(o):Q(o,`Session mới được phép đọc, sửa file và chạy command trong runtime. Xóa dữ liệu và gửi ra ngoài vẫn cần xác nhận riêng.`,`The new session may read and edit files and run commands. Deletion and external transfer still require separate approval.`),cancelLabel:Q(o,`Hủy`,`Cancel`),confirmLabel:p||H?Q(o,`Dùng Bypass`,`Use Bypass`):Q(o,`Dùng toàn quyền`,`Use full access`),onCancel:()=>j(null),onConfirm:()=>{j(null),E(`trusted-full-access`)}})]})}var oE=`piagent dashboard`;function sE(){return(0,v.useSyncExternalStore)(Dg,Eg,Eg)}function cE({locale:e}){let[t,n]=(0,v.useState)(!1);return(0,U.jsxs)(Z,{role:`alert`,spacing:2,sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,px:2,textAlign:`center`},children:[(0,U.jsx)(X,{variant:`h6`,component:`h1`,children:Q(e,`Tab này đã hết phiên đăng nhập`,`This tab is no longer signed in`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{maxWidth:520},children:Q(e,`Piagent vừa khởi động lại, phiên đã quá 8 giờ, hoặc tab được mở từ một link cũ. Các cuộc trò chuyện vẫn còn nguyên — mở lại Piagent để vào tiếp.`,`Piagent restarted, the session is older than 8 hours, or this tab came from an old link. Your conversations are kept — open Piagent again to continue.`)}),(0,U.jsxs)(J,{sx:{display:`flex`,gap:1,alignItems:`center`,flexWrap:`wrap`,justifyContent:`center`},children:[(0,U.jsx)(J,{component:`code`,sx:{px:1.5,py:.75,borderRadius:1,bgcolor:`action.hover`,fontSize:`.9rem`},children:oE}),(0,U.jsx)($,{size:`small`,variant:`outlined`,onClick:()=>{navigator.clipboard?.writeText(oE).then(()=>n(!0),()=>n(!1))},children:t?Q(e,`Đã chép`,`Copied`):Q(e,`Chép lệnh`,`Copy command`)})]}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Chạy lệnh trên trong terminal, hoặc bấm WebUI trong Agent Watch. Sau đó có thể đóng tab này.`,`Run it in a terminal, or choose WebUI in Agent Watch. You can close this tab afterwards.`)})]})}var lE=Y((0,U.jsx)(`path`,{d:`m12.35 15.65 2.79-2.79c.31-.31.09-.85-.35-.85H13V4c0-.55-.45-1-1-1s-1 .45-1 1v8H9.21c-.45 0-.67.54-.35.85l2.79 2.79c.19.2.51.2.7.01M21 3h-5.01c-.54 0-.99.45-.99.99 0 .55.45.99.99.99H20c.55 0 1 .45 1 1v12.03c0 .55-.45 1-1 1H4c-.55 0-1-.45-1-1V5.99c0-.55.45-1 1-1h4.01c.54 0 .99-.45.99-.99 0-.55-.45-1-.99-1H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2`}),`SystemUpdateAltRounded`);function uE(e={}){let{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:r,open:i,resumeHideDuration:a}=e,o=Cl();v.useEffect(()=>{if(!i)return;function e(e){e.defaultPrevented||e.key===`Escape`&&r?.(e,`escapeKeyDown`)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[i,r]);let s=cs((e,t)=>{r?.(e,t)}),c=cs(e=>{!r||e==null||o.start(e,()=>{s(null,`timeout`)})});v.useEffect(()=>(i&&c(t),o.clear),[i,t,c,o]);let l=e=>{r?.(e,`clickaway`)},u=o.clear,d=v.useCallback(()=>{t!=null&&c(a??t*.5)},[t,a,c]),f=e=>t=>{let n=e.onBlur;n?.(t),d()},p=e=>t=>{let n=e.onFocus;n?.(t),u()},m=e=>t=>{let n=e.onMouseEnter;n?.(t),u()},h=e=>t=>{let n=e.onMouseLeave;n?.(t),d()};return v.useEffect(()=>{if(!n&&i)return window.addEventListener(`focus`,d),window.addEventListener(`blur`,u),()=>{window.removeEventListener(`focus`,d),window.removeEventListener(`blur`,u)}},[n,i,d,u]),{getRootProps:(t={})=>{let n={...qc(e),...qc(t)};return{role:`presentation`,...t,...n,onBlur:f(n),onFocus:p(n),onMouseEnter:m(n),onMouseLeave:h(n)}},onClickAway:l}}function dE(e){return e.substring(2).toLowerCase()}function fE(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}function pE(e){let{children:t,disableReactTree:n=!1,mouseEvent:r=`onClick`,onClickAway:i,touchEvent:a=`onTouchEnd`}=e,o=v.useRef(!1),s=v.useRef(null),c=v.useRef(!1),l=v.useRef(!1);v.useEffect(()=>(setTimeout(()=>{c.current=!0},0),()=>{c.current=!1}),[]);let u=ss(Lu(t),s),d=cs(e=>{let t=l.current;l.current=!1;let r=ls(s.current);if(!c.current||!s.current||`clientX`in e&&fE(e,r))return;if(o.current){o.current=!1;return}let a;a=e.composedPath?e.composedPath().includes(s.current):!Ru(r.documentElement,e.target)||Ru(s.current,e.target),!a&&(n||!t)&&i(e)}),f=e=>n=>{l.current=!0;let r=t.props[e];r&&r(n)},p={ref:u};return a!==!1&&(p[a]=f(a)),v.useEffect(()=>{if(a!==!1){let e=dE(a),t=ls(s.current),n=()=>{o.current=!0};return t.addEventListener(e,d),t.addEventListener(`touchmove`,n),()=>{t.removeEventListener(e,d),t.removeEventListener(`touchmove`,n)}}},[d,a]),r!==!1&&(p[r]=f(r)),v.useEffect(()=>{if(r!==!1){let e=dE(r),t=ls(s.current);return t.addEventListener(e,d),()=>{t.removeEventListener(e,d)}}},[d,r]),v.cloneElement(t,p)}function mE(e){return Gr(`MuiSnackbarContent`,e)}Kr(`MuiSnackbarContent`,[`root`,`message`,`action`]);var hE=e=>{let{classes:t}=e;return ba({root:[`root`],action:[`action`],message:[`message`]},mE,t)},gE=K(Pc,{name:`MuiSnackbarContent`,slot:`Root`})(ys(({theme:e})=>{let t=e.palette.mode===`light`?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(ki(e.palette.background.default,t)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:ki(e.palette.background.default,t),display:`flex`,alignItems:`center`,flexWrap:`wrap`,padding:`6px 16px`,flexGrow:1,[e.breakpoints.up(`sm`)]:{flexGrow:`initial`,minWidth:288}}})),_E=K(`div`,{name:`MuiSnackbarContent`,slot:`Message`})({padding:`8px 0`}),vE=K(`div`,{name:`MuiSnackbarContent`,slot:`Action`})({display:`flex`,alignItems:`center`,marginLeft:`auto`,paddingLeft:16,marginRight:-8}),yE=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiSnackbarContent`}),{action:r,className:i,message:a,role:o=`alert`,...s}=n,c=n,l=hE(c);return(0,U.jsxs)(gE,{role:o,elevation:6,className:W(l.root,i),ownerState:c,ref:t,...s,children:[(0,U.jsx)(_E,{className:l.message,ownerState:c,children:a}),r?(0,U.jsx)(vE,{className:l.action,ownerState:c,children:r}):null]})});function bE(e){return Gr(`MuiSnackbar`,e)}Kr(`MuiSnackbar`,[`root`,`anchorOriginTopCenter`,`anchorOriginBottomCenter`,`anchorOriginTopRight`,`anchorOriginBottomRight`,`anchorOriginTopLeft`,`anchorOriginBottomLeft`]);var xE=e=>{let{classes:t,anchorOrigin:n}=e;return ba({root:[`root`,`anchorOrigin${q(n.vertical)}${q(n.horizontal)}`]},bE,t)},SE=K(`div`,{name:`MuiSnackbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`anchorOrigin${q(n.anchorOrigin.vertical)}${q(n.anchorOrigin.horizontal)}`]]}})(ys(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:`fixed`,display:`flex`,left:8,right:8,justifyContent:`center`,alignItems:`center`,variants:[{props:({ownerState:e})=>e.anchorOrigin.vertical===`top`,style:{top:8,[e.breakpoints.up(`sm`)]:{top:24}}},{props:({ownerState:e})=>e.anchorOrigin.vertical!==`top`,style:{bottom:8,[e.breakpoints.up(`sm`)]:{bottom:24}}},{props:({ownerState:e})=>e.anchorOrigin.horizontal===`left`,style:{justifyContent:`flex-start`,[e.breakpoints.up(`sm`)]:{left:24,right:`auto`}}},{props:({ownerState:e})=>e.anchorOrigin.horizontal===`right`,style:{justifyContent:`flex-end`,[e.breakpoints.up(`sm`)]:{right:24,left:`auto`}}},{props:({ownerState:e})=>e.anchorOrigin.horizontal===`center`,style:{[e.breakpoints.up(`sm`)]:{left:`50%`,right:`auto`,transform:`translateX(-50%)`}}}]}))),CE=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiSnackbar`}),r=Go(),i={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{action:a,anchorOrigin:{vertical:o,horizontal:s}={vertical:`bottom`,horizontal:`left`},autoHideDuration:c=null,children:l,className:u,disableWindowBlurListener:d=!1,message:f,onBlur:p,onClose:m,onFocus:h,onMouseEnter:g,onMouseLeave:_,open:y,resumeHideDuration:b,slots:x={},slotProps:S={},transitionDuration:C=i,...w}=n,T={...n,anchorOrigin:{vertical:o,horizontal:s},autoHideDuration:c,disableWindowBlurListener:d,transitionDuration:C},E=xE(T),{getRootProps:D,onClickAway:O}=uE(T),[k,A]=v.useState(!0),j={slots:x,slotProps:S},[M,N]=Xc(`root`,{ref:t,className:[E.root,u],elementType:SE,getSlotProps:D,externalForwardedProps:{...j,...w},ownerState:T}),[P,{ownerState:F,...I}]=Xc(`clickAwayListener`,{elementType:pE,externalForwardedProps:j,getSlotProps:e=>({onClickAway:(...t)=>{let n=t[0];e.onClickAway?.(...t),!n?.defaultMuiPrevented&&O(...t)}}),ownerState:T}),[L,R]=Xc(`content`,{elementType:yE,shouldForwardComponentProp:!0,externalForwardedProps:j,additionalProps:{message:f,action:a},ownerState:T}),[ee,te]=Xc(`transition`,{elementType:mp,externalForwardedProps:j,getSlotProps:e=>({onEnter:(...t)=>{e.onEnter?.(...t),A(!1)},onExited:(...t)=>{e.onExited?.(...t),A(!0)}}),additionalProps:{appear:!0,in:y,timeout:C,direction:o===`top`?`down`:`up`},ownerState:T});return!y&&k?null:(0,U.jsx)(P,{...I,...x.clickAwayListener&&{ownerState:F},children:(0,U.jsx)(M,{...N,children:(0,U.jsx)(ee,{...te,children:l||(0,U.jsx)(L,{...R})})})})}),wE=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function TE(e,t){let n;if(t?.method===`POST`){let r=_g();if(!r)throw new wE(403,`mutation-authority-rejected`);n=await vg(e,{...t,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r}})}else n=await fetch(e,{...t,credentials:`same-origin`,headers:{Accept:`application/json`}});n.status===401&&Og();let r=await n.json().catch(()=>null);if(!n.ok)throw new wE(n.status,typeof r?.error?.code==`string`?r.error.code:`request-${n.status}`);return r}var EE=e=>TE(`/api/v1/updates`,{signal:e}),DE=()=>TE(`/api/v1/updates/check`,{method:`POST`,body:`{}`}),OE=e=>TE(`/api/v1/updates/apply`,{method:`POST`,body:JSON.stringify({version:e})}),kE=e=>e?.job?.state===`starting`||e?.job?.state===`running`,AE=(0,v.createContext)(null);function jE({children:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!0),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),d=(0,v.useRef)(!0),f=(0,v.useCallback)(async()=>{try{if(await Sg(),Eg())return;let e=await EE();d.current&&(n(e),i(!0))}catch(e){d.current&&e instanceof wE&&e.status===404&&i(!1)}},[]),p=kE(t),m=t!==null||!r;(0,v.useEffect)(()=>{d.current=!0,f();let e=setInterval(()=>void f(),m?p?3e3:6e4:2e3);return()=>{clearInterval(e)}},[f,p,m]),(0,v.useEffect)(()=>()=>{d.current=!1},[]);let h=(0,v.useCallback)(async()=>{o(!0),u(null);try{n(await DE())}catch(e){u(e instanceof Error?e.message:`update-unavailable`)}finally{o(!1)}},[]),g=(0,v.useCallback)(async()=>{let e=t?.piagent.latest;if(e){c(!0),u(null);try{await OE(e),await f()}catch(e){u(e instanceof Error?e.message:`update-unavailable`),await f()}finally{c(!1)}}},[t?.piagent.latest,f]),_=(0,v.useMemo)(()=>({status:t,supported:r,checking:a||!!t?.checking,applying:s,error:l,refresh:f,check:h,apply:g}),[t,r,a,s,l,f,h,g]);return(0,U.jsx)(AE.Provider,{value:_,children:e})}function ME(){let e=(0,v.useContext)(AE);if(!e)throw Error(`Piagent update state is missing`);return e}var NE=`~/.pi/piagent-update-job.log`;function PE(e,t){let n={"update-blocked-running":[`Đang có cuộc trò chuyện chạy. Cập nhật khi chúng xong, hoặc bấm Dừng.`,`A conversation is running. Update when it finishes, or stop it.`],"update-already-running":[`Một lần cập nhật khác đang chạy.`,`Another update is running.`],"update-version-changed":[`Đã có bản mới hơn bản bạn thấy. Kiểm tra lại rồi cập nhật.`,`A newer release appeared. Check again, then update.`],"update-not-available":[`Máy này đã ở bản mới nhất.`,`This machine is already up to date.`],"update-not-installable":[`Bản Piagent này không tự cập nhật được từ dashboard.`,`This Piagent cannot update itself from the dashboard.`]}[t];return n?Q(e,n[0],n[1]):Q(e,`Chưa cập nhật được. Thử lại sau.`,`The update could not start. Try again later.`)}function FE(e,t){return t.state===`succeeded`?t.reason===`dashboard-restart-failed`?{severity:`warning`,text:Q(e,`Đã cập nhật lên ${t.installed??t.to}, nhưng dashboard chưa tự mở lại. Chạy \`piagent dashboard restart\`.`,`Updated to ${t.installed??t.to}, but the dashboard did not restart. Run \`piagent dashboard restart\`.`)}:{severity:`success`,text:Q(e,`Đã cập nhật Piagent ${t.from} → ${t.installed??t.to}.`,`Updated Piagent ${t.from} → ${t.installed??t.to}.`)}:t.state===`failed`?{severity:`error`,text:`${t.reason===`update-interrupted`?Q(e,`Lần cập nhật bị ngắt giữa chừng.`,`The update was interrupted.`):t.reason===`update-version-mismatch`?Q(e,`Bản cài xong không đúng bản đã chọn.`,`The installed release is not the one chosen.`):Q(e,`Lệnh cập nhật báo lỗi.`,`The update command failed.`)} ${Q(e,`Chi tiết trong ${NE}.`,`Details are in ${NE}.`)}`}:null}function IE(e,t){if(!t)return Q(e,`chưa kiểm tra`,`not checked yet`);let n=Math.max(0,Math.round((Date.now()-Date.parse(t))/6e4));if(n<1)return Q(e,`vừa xong`,`just now`);if(n<60)return Q(e,`${n} phút trước`,`${n} min ago`);let r=Math.round(n/60);return r<48?Q(e,`${r} giờ trước`,`${r} h ago`):Q(e,`${Math.round(r/24)} ngày trước`,`${Math.round(r/24)} days ago`)}function LE({name:e,detail:t,chip:n,tone:r}){return(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:760},children:e}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:t})]}),(0,U.jsx)(lu,{size:`small`,label:n,color:r,variant:r==="default"?`outlined`:`filled`,sx:{alignSelf:{xs:`flex-start`,sm:`center`}}})]})}function RE(e,t){let n=[];return t.piagent.updateAvailable&&n.push(Q(e,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`)),t.pi.updateAvailable&&n.push(Q(e,`Pi ${t.pi.installed??`?`} → ${t.pi.required} (bản Piagent ${t.piagent.latest} yêu cầu)`,`Pi ${t.pi.installed??`?`} → ${t.pi.required} (the version Piagent ${t.piagent.latest} requires)`)),n.push(Q(e,`Dashboard khởi động lại và mở trong tab mới; tab này có thể đóng.`,`The dashboard restarts and opens in a new tab; this tab can be closed.`)),n}function zE(){let{locale:e}=Gv(),{status:t,supported:n,checking:r,applying:i,error:a,check:o,apply:s}=ME(),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null),d=kE(t);if((0,v.useEffect)(()=>{d&&!u.current?.closest(`[role=dialog]`)?.contains(document.activeElement)&&u.current?.focus()},[d]),!n)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:3},children:Q(e,`Cập nhật`,`Updates`)}),(0,U.jsx)(pC,{severity:`info`,children:Q(e,`Gateway này chưa hỗ trợ kiểm tra cập nhật.`,`This Gateway does not check for updates.`)})]});let f=t?.job,p=f?FE(e,f):null,m=(t?.runningConversations??0)>0,h=t?[Q(e,`Đang dùng ${t.pi.installed??`—`}`,`Using ${t.pi.installed??`—`}`),t.pi.required?Q(e,`Piagent ${t.piagent.latest} cần ${t.pi.required}`,`Piagent ${t.piagent.latest} needs ${t.pi.required}`):null].filter(Boolean).join(` · `):`—`;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,ref:u,tabIndex:-1,sx:{mb:1},children:Q(e,`Cập nhật`,`Updates`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{mb:3},children:Q(e,`Piagent và Pi được cập nhật cùng nhau: Pi luôn lên đúng bản mà Piagent mới đã kiểm chứng.`,`Piagent and Pi update together: Pi always moves to the version the new Piagent is qualified on.`)}),(0,U.jsxs)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:[(0,U.jsx)(LE,{name:`Piagent`,detail:Q(e,`Đang dùng ${t?.piagent.installed??`—`}`,`Using ${t?.piagent.installed??`—`}`),chip:t?.piagent.updateAvailable?Q(e,`Có bản ${t.piagent.latest}`,`${t.piagent.latest} available`):t?.piagent.latest?Q(e,`Mới nhất`,`Up to date`):Q(e,`Chưa rõ`,`Unknown`),tone:t?.piagent.updateAvailable?`primary`:`default`}),(0,U.jsx)(Du,{}),(0,U.jsx)(LE,{name:`Pi`,detail:h,chip:t?.pi.updateAvailable?Q(e,`Lên ${t.pi.required}`,`To ${t.pi.required}`):Q(e,`Đúng bản`,`Matches`),tone:t?.pi.updateAvailable?`primary`:`default`}),t?.pi.newerUntested&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Du,{}),(0,U.jsx)(J,{sx:{px:2.25,py:1.5},children:(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Pi đã có bản ${t.pi.latest}, nhưng Piagent chưa kiểm chứng bản đó (chưa tương thích). Pi sẽ được nâng khi một bản Piagent hỗ trợ nó.`,`Pi ${t.pi.latest} is out, but Piagent is not qualified on it yet (not compatible). Pi moves when a Piagent release supports it.`)})})]}),(0,U.jsx)(Du,{}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Kiểm tra lần cuối: ${IE(e,t?.checkedAt??null)} · tự kiểm tra ${(t?.checkEveryHours??1)===1?`mỗi giờ`:`mỗi ${t?.checkEveryHours} giờ`}`,`Last checked: ${IE(e,t?.checkedAt??null)} · checks every ${(t?.checkEveryHours??1)===1?`hour`:`${t?.checkEveryHours} hours`}`)}),(0,U.jsx)($,{variant:`outlined`,disabled:r||d||!t?.installable,onClick:()=>void o(),startIcon:r?(0,U.jsx)(xu,{size:14}):void 0,children:Q(e,`Kiểm tra ngay`,`Check now`)})]})]}),(0,U.jsxs)(J,{sx:{mt:2.5,display:`grid`,gap:1.5},children:[t&&!t.installable&&(0,U.jsx)(pC,{severity:`info`,children:t.reason===`company-runtime`?Q(e,`Đây là runtime công ty; cập nhật từ dashboard Piagent.`,`This is the company runtime; update from the Piagent dashboard.`):Q(e,`Piagent này chạy từ mã nguồn (git). Cập nhật bằng git pull rồi cài lại.`,`This Piagent runs from a source checkout. Update it with git pull and reinstall.`)}),d&&(0,U.jsx)(pC,{severity:`info`,icon:(0,U.jsx)(xu,{size:18}),children:Q(e,`Đang cập nhật lên Piagent ${f?.to}… Xong, dashboard mở lại trong tab mới; tab này có thể đóng.`,`Updating to Piagent ${f?.to}… When done, the dashboard opens in a new tab; this tab can be closed.`)}),!d&&p&&(0,U.jsx)(pC,{severity:p.severity,children:p.text}),!d&&f?.bindingChanged&&(0,U.jsx)(pC,{severity:`warning`,children:Q(e,`Bản mới đổi trình khởi chạy công ty: mở Agent Watch và kết nối lại key công ty để tiếp tục dùng chế độ công ty.`,`The new release changed the company launcher: open Agent Watch and connect the company key again to keep company mode.`)}),a&&(0,U.jsx)(pC,{severity:`error`,role:`alert`,children:PE(e,a)}),t?.installable&&t.updateAvailable&&!d&&(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},gap:1.5},children:[(0,U.jsx)($,{variant:`contained`,size:`large`,startIcon:i?(0,U.jsx)(xu,{size:16,color:`inherit`}):(0,U.jsx)(lE,{}),disabled:i||m,onClick:()=>l(!0),children:Q(e,`Cập nhật lên Piagent ${t.piagent.latest}`,`Update to Piagent ${t.piagent.latest}`)}),m&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`${t.runningConversations} cuộc trò chuyện đang chạy; nút mở lại khi chúng xong.`,`${t.runningConversations} conversation(s) running; available once they finish.`)})]})]}),(0,U.jsxs)(zC,{open:c&&!!t,onClose:()=>l(!1),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-confirm`,children:[(0,U.jsx)(Kw,{id:`piagent-update-confirm`,children:Q(e,`Cập nhật Piagent?`,`Update Piagent?`)}),(0,U.jsx)(Uw,{children:(0,U.jsx)(J,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:t&&RE(e,t).map(e=>(0,U.jsx)(X,{component:`li`,variant:`body2`,children:e},e))})}),(0,U.jsxs)(Lw,{children:[(0,U.jsx)($,{onClick:()=>l(!1),children:Q(e,`Để sau`,`Later`)}),(0,U.jsx)($,{variant:`contained`,onClick:()=>{l(!1),s()},children:Q(e,`Cập nhật`,`Update`)})]})]})]})}var BE=`piagent-update-snooze`,VE=`piagent-update-job-seen`,HE=36e5;function UE(e){try{return window.localStorage.getItem(e)}catch{return null}}function WE(e,t){try{window.localStorage.setItem(e,t)}catch{}}function GE(e,t){try{let n=JSON.parse(UE(BE)??`null`);return n?.version===e&&typeof n.until==`number`&&t<n.until}catch{return!1}}function KE({locale:e,onDetails:t}){let{status:n,applying:r,error:i,apply:a}=ME(),[o,s]=(0,v.useState)(()=>Date.now()),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=window.setInterval(()=>s(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let f=n?.piagent.latest??null,p=n?.job??null;(0,v.useEffect)(()=>{!p||p.state!==`succeeded`||UE(VE)===p.startedAt||(WE(VE,p.startedAt),d(Q(e,`Đã cập nhật Piagent ${p.from} → ${p.installed??p.to}.`,`Piagent updated ${p.from} → ${p.installed??p.to}.`)))},[p,e]);let m=!!(n?.installable&&n.updateAvailable&&f&&!kE(n))&&c!==f&&!GE(f,o),h=()=>{f&&(WE(BE,JSON.stringify({version:f,until:Date.now()+HE})),l(f))},g=(n?.runningConversations??0)>0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(zC,{open:m,onClose:h,fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-offer`,children:[(0,U.jsxs)(Kw,{id:`piagent-update-offer`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,U.jsx)(lE,{color:`primary`}),Q(e,`Có bản Piagent mới: ${f}`,`Piagent ${f} is available`)]}),(0,U.jsxs)(Uw,{sx:{display:`grid`,gap:1.5},children:[(0,U.jsx)(J,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:n&&RE(e,n).map(e=>(0,U.jsx)(X,{component:`li`,variant:`body2`,children:e},e))}),g&&(0,U.jsx)(pC,{severity:`info`,children:Q(e,`${n?.runningConversations} cuộc trò chuyện đang chạy. Cập nhật khi chúng xong — dialog này sẽ nhắc lại.`,`${n?.runningConversations} conversation(s) running. Update once they finish — this will ask again.`)}),i&&(0,U.jsx)(pC,{severity:`error`,children:PE(e,i)})]}),(0,U.jsxs)(Lw,{sx:{flexWrap:`wrap`,gap:1},children:[(0,U.jsx)($,{onClick:h,children:Q(e,`Để sau (nhắc lại sau 1 giờ)`,`Later (ask again in an hour)`)}),(0,U.jsx)($,{onClick:()=>{l(f),t()},children:Q(e,`Xem chi tiết`,`Details`)}),(0,U.jsx)($,{variant:`contained`,disabled:g||r,onClick:()=>{l(f),a().then(t)},children:Q(e,`Cập nhật ngay`,`Update now`)})]})]}),(0,U.jsx)(CE,{open:u!==null,autoHideDuration:8e3,onClose:()=>d(null),anchorOrigin:{vertical:`top`,horizontal:`center`},children:(0,U.jsx)(pC,{severity:`success`,variant:`filled`,onClose:()=>d(null),children:u})})]})}var qE=Y((0,U.jsx)(`path`,{d:`M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4`}),`CloseRounded`),JE=fi({themeId:Wo});function YE({active:e,snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i,refresh:a}){let{locale:o}=Gv();return e===`source`?(0,U.jsx)(ay,{snapshot:t,sessionRef:n,refreshSnapshot:a}):e===`documents`?(0,U.jsx)(wx,{sessionRef:n}):e===`activity`?(0,U.jsx)(jx,{snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i}):(0,U.jsxs)(Z,{spacing:2.25,children:[(0,U.jsx)(WS,{snapshot:t,locale:o}),(0,U.jsx)(HS,{snapshot:t,locale:o}),(0,U.jsx)(Rx,{snapshot:t})]})}var XE=`min(44vw, 860px)`;function ZE({open:e,active:t,snapshot:n,state:r,sessionRef:i,terminalActivities:a,liveActivities:o,onClose:s,onActive:c,refresh:l}){let{locale:u}=Gv(),d=JE(Go().breakpoints.up(`xl`)),f=n?.sourceChanges.workingTree.counts.files??0,p=o===void 0?n?.activity.running.length??0:o.filter(e=>e.state===`running`).length;return(0,U.jsxs)(Kd,{anchor:`right`,variant:d?`persistent`:`temporary`,open:e,onClose:s,sx:{"& .MuiDrawer-paper":{width:{xs:`100%`,sm:`min(88vw, 980px)`,xl:XE},bgcolor:`background.default`}},children:[(0,U.jsxs)(J,{sx:{position:`sticky`,top:0,zIndex:3,bgcolor:`background.paper`,borderBottom:1,borderColor:`divider`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{minHeight:64,px:{xs:1.5,md:2},alignItems:`center`,gap:1},children:[(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:820},children:Q(u,`Agent Inspector`,`Agent Inspector`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(u,`Task contract · Git truth · verifier`,`Task contract · Git truth · verifier`)})]}),(0,U.jsx)(Ah,{title:Q(u,`Làm mới Inspector`,`Refresh Inspector`),children:(0,U.jsx)(Qd,{onClick:()=>void l(),children:(0,U.jsx)(XS,{fontSize:`small`})})}),(0,U.jsx)(Qd,{"aria-label":Q(u,`Đóng Inspector`,`Close Inspector`),onClick:s,children:(0,U.jsx)(qE,{})})]}),(0,U.jsxs)(pg,{value:t,onChange:(e,t)=>c(t),variant:`scrollable`,scrollButtons:`auto`,children:[(0,U.jsx)(Kh,{value:`task`,icon:(0,U.jsx)(jh,{}),iconPosition:`start`,label:n?.task?`${Q(u,`Task`,`Task`)} · ${n.task.progress.completed}/${n.task.progress.total}`:Q(u,`Task`,`Task`)}),(0,U.jsx)(Kh,{value:`source`,icon:(0,U.jsx)(Ph,{}),iconPosition:`start`,label:`Source Changes${f?` · ${f}`:``}`}),(0,U.jsx)(Kh,{value:`documents`,icon:(0,U.jsx)(Nh,{}),iconPosition:`start`,label:Q(u,`Tài liệu`,`Documents`)}),(0,U.jsx)(Kh,{value:`activity`,icon:(0,U.jsx)(Fh,{}),iconPosition:`start`,label:`${Q(u,`Activity`,`Activity`)}${p?` · ${p}`:``}`})]})]}),r===`loading`?(0,U.jsxs)(Z,{sx:{alignItems:`center`,py:12},spacing:1.5,children:[(0,U.jsx)(xu,{size:25}),(0,U.jsx)(X,{color:`text.secondary`,children:Q(u,`Đang dựng Inspector từ session và Git…`,`Building the Inspector from the session and Git…`)})]}):(r===`error`||!n)&&i&&t===`activity`&&a?.length?(0,U.jsx)(J,{sx:{p:{xs:1.5,sm:2.5,xl:3},maxWidth:1500,mx:`auto`,width:`100%`},children:(0,U.jsx)(jx,{sessionRef:i,terminalActivities:a,liveActivities:o})}):r===`error`||!n||!i?(0,U.jsxs)(Z,{sx:{p:3,maxWidth:720},spacing:2,children:[(0,U.jsx)(pC,{severity:`warning`,children:Q(u,`Không thể dựng Inspector cho session này. Chat vẫn an toàn; hãy kiểm tra project còn tồn tại và thử làm mới.`,`The Inspector could not be built for this session. Chat remains safe; check that the project still exists and refresh.`)}),(0,U.jsx)($,{variant:`outlined`,onClick:()=>void l(),children:Q(u,`Thử lại`,`Try again`)})]}):(0,U.jsx)(J,{sx:{p:t===`source`?{xs:1,md:1.5}:{xs:1.5,sm:2.5,xl:3},maxWidth:t===`source`?`none`:1500,mx:`auto`,width:`100%`},children:(0,U.jsx)(YE,{active:t,snapshot:n,sessionRef:i,terminalActivities:a,liveActivities:o,refresh:l})})]})}var QE=Y((0,U.jsx)(`path`,{d:`M12 7c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1m-.01-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m1-3h-2v-2h2z`}),`ErrorOutlineRounded`),$E=e=>Array.from({length:e},()=>({selected:[],other:``,otherOn:!1})),eD=e=>e.selected.length>0||e.otherOn&&e.other.trim().length>0;function tD({sessionRef:e,pending:t,locale:n,onDone:r}){let[i,a]=(0,v.useState)(()=>$E(t.questions.length)),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),u=(0,v.useRef)([]),d=(0,v.useRef)(null),f=(0,v.useRef)([]),[p,m]=(0,v.useState)(0);(0,v.useEffect)(()=>{d.current?.scrollIntoView({block:`nearest`,behavior:`smooth`}),d.current?.focus({preventScroll:!0})},[]);let h=(e,t)=>a(n=>n.map((n,r)=>r===e?t(n):n)),g=(e,n)=>h(e,r=>t.questions[e].multiSelect?{...r,selected:r.selected.includes(n)?r.selected.filter(e=>e!==n):[...r.selected,n]}:{selected:[n],other:r.other,otherOn:!1}),_=(e,n=!0)=>{h(e,r=>t.questions[e].multiSelect?{...r,otherOn:n}:{selected:[],other:r.other,otherOn:n}),n&&setTimeout(()=>u.current[e]?.focus(),0)},y=i.every(eD),b=e=>{if(e.target.tagName===`INPUT`&&e.target.type===`text`)return;if(e.key===`Enter`){y&&(e.preventDefault(),S());return}let n=Number(e.target.closest(`fieldset`)?.getAttribute(`data-question`)??NaN),r=Number.isInteger(n)?n:p,a=Number(e.key),o=t.questions[r],s=o.options.length;if(!(!Number.isInteger(a)||a<1||a>s+1)){if(e.preventDefault(),a===s+1){_(r,!o.multiSelect||!i[r].otherOn);return}g(r,a-1),!o.multiSelect&&r+1<t.questions.length&&(m(r+1),f.current[r+1]?.focus({preventScroll:!1}))}},x=async(i,a)=>{s(a),l(``);try{await z_(e,t.questionRef,i),r()}catch(e){s(null),l(e.status===409?Q(n,`Câu hỏi này đã được trả lời hoặc lượt làm việc đã dừng.`,`This question was already answered or the turn stopped.`):Q(n,`Chưa gửi được câu trả lời. Thử lại.`,`The answer could not be sent. Try again.`))}},S=()=>{!y||o||x({answers:i.map(e=>({selected:[...e.selected].sort((e,t)=>e-t),...e.otherOn&&e.other.trim()?{other:e.other.trim()}:{}}))},`answer`)},C=t.questions.length;return(0,U.jsxs)(`article`,{className:`question-card`,ref:d,tabIndex:-1,onKeyDown:b,"aria-labelledby":`question-${t.questionRef}`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(n,`Main agent cần bạn quyết định`,`The main agent needs your decision`)}),(0,U.jsx)(`h2`,{id:`question-${t.questionRef}`,children:C>1?Q(n,`${C} câu hỏi`,`${C} questions`):Q(n,`1 câu hỏi`,`1 question`)})]}),(0,U.jsx)(`span`,{className:`question-hint`,children:Q(n,`Bấm số để chọn · Enter để gửi`,`Press a number to choose · Enter to send`)})]}),t.questions.map((e,r)=>{let a=i[r],o=`${t.questionRef}-${r}`,s=e.multiSelect?`checkbox`:`radio`;return(0,U.jsxs)(`fieldset`,{className:r===p?`question-block active`:`question-block`,"data-question":r,tabIndex:-1,ref:e=>{f.current[r]=e},onFocus:()=>m(r),children:[(0,U.jsxs)(`legend`,{children:[C>1&&(0,U.jsxs)(`span`,{className:`question-number`,children:[r+1,`.`]}),e.header&&(0,U.jsx)(`span`,{className:`question-chip`,children:e.header}),(0,U.jsx)(`span`,{className:`question-text`,children:e.question})]}),e.multiSelect&&(0,U.jsx)(`p`,{className:`question-multi`,children:Q(n,`Có thể chọn nhiều đáp án.`,`You can choose more than one.`)}),(0,U.jsxs)(`ol`,{className:`question-options`,children:[e.options.map((e,t)=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`label`,{className:a.selected.includes(t)?`selected`:void 0,children:[(0,U.jsx)(`input`,{type:s,name:o,checked:a.selected.includes(t),onChange:()=>g(r,t)}),(0,U.jsx)(`span`,{className:`option-number`,"aria-hidden":`true`,children:t+1}),(0,U.jsxs)(`span`,{className:`option-body`,children:[(0,U.jsx)(`strong`,{children:e.label}),e.description&&(0,U.jsx)(`small`,{children:e.description})]})]})},t)),(0,U.jsxs)(`li`,{className:`question-other`,children:[(0,U.jsxs)(`label`,{className:a.otherOn?`selected`:void 0,children:[(0,U.jsx)(`input`,{type:s,name:o,checked:a.otherOn,onChange:()=>_(r,!e.multiSelect||!a.otherOn)}),(0,U.jsx)(`span`,{className:`option-number`,"aria-hidden":`true`,children:e.options.length+1}),(0,U.jsx)(`span`,{className:`option-body`,children:(0,U.jsx)(`strong`,{children:Q(n,`Khác`,`Other`)})})]}),a.otherOn&&(0,U.jsx)(`input`,{type:`text`,ref:e=>{u.current[r]=e},maxLength:1e3,value:a.other,"aria-label":Q(n,`Câu trả lời khác cho câu ${r+1}`,`Other answer to question ${r+1}`),placeholder:Q(n,`Nhập câu trả lời của bạn`,`Type your answer`),onChange:e=>h(r,t=>({...t,other:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())}})]})]})]},o)}),c&&(0,U.jsx)(`p`,{className:`form-error`,role:`alert`,children:c}),(0,U.jsxs)(`footer`,{children:[(0,U.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!o,onClick:()=>void x({skipped:!0},`skip`),children:o===`skip`?Q(n,`Đang gửi…`,`Sending…`):Q(n,`Để agent tự quyết`,`Let the agent decide`)}),(0,U.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:!y||!!o,onClick:S,children:o===`answer`?Q(n,`Đang gửi…`,`Sending…`):Q(n,`Gửi câu trả lời`,`Send answer`)})]})]})}function nD({sessionRef:e,waiting:t}){let{locale:n}=Gv(),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let t=new AbortController;return R_(e,t.signal).then(e=>i(e.questions??[]),()=>void 0),()=>t.abort()},[e,t,a]),(0,v.useEffect)(()=>{if(!t&&!r.length)return;let e=setInterval(()=>o(e=>e+1),r.length?4e3:1500);return()=>clearInterval(e)},[t,r.length]),r.length?(0,U.jsx)(`section`,{className:`question-stack`,"aria-label":Q(n,`Câu hỏi đang chờ bạn trả lời`,`Questions waiting for your answer`),"aria-live":`polite`,children:r.map(t=>(0,U.jsx)(tD,{sessionRef:e,pending:t,locale:n,onDone:()=>i(e=>e.filter(e=>e.questionRef!==t.questionRef))},t.questionRef))}):null}function rD(e,t){return e?.state===`ready`&&e.gatewayInstanceRef===t&&Number.isSafeInteger(e.eventSequence)&&e.eventSequence>=0&&Array.isArray(e.operations)&&Array.isArray(e.settlements)?e.eventSequence:null}function iD(e,t){return e&&!t?`connected`:`reconnecting`}var aD=100,oD=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/,sD=/^[a-z0-9][a-z0-9.-]{0,95}$/,cD=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function lD(e,t){return typeof t==`string`&&sD.test(t)?t:e===`aborted`?`operation-aborted`:e===`blocked`?`operation-blocked`:e===`error`?`operation-failed`:`operation-settlement-unknown`}function uD(e){if(e.settlement===`completed`||typeof e.operationRef!=`string`||!oD.test(e.operationRef)||typeof e.settledAt!=`string`||!cD.test(e.settledAt)||!Number.isSafeInteger(e.sequence)||Number(e.sequence)<1)return null;let t=[`blocked`,`aborted`,`error`,`unknown`].includes(String(e.settlement))?e.settlement:`unknown`,n=t===`error`?`failed`:t;return{activityRef:e.operationRef,operationRef:e.operationRef,settlement:t,state:n,reasonCode:lD(t,e.reasonCode),settledAt:e.settledAt,sequence:Number(e.sequence)}}function dD(e,t){let n=new Map;for(let r of[...e,...t])n.has(r.operationRef)||n.set(r.operationRef,r);return[...n.values()].sort((e,t)=>t.sequence-e.sequence).slice(0,aD)}function fD(e){if(e.state!==`ready`)return{};let t={};for(let n of e.settlements??[]){let e=uD(n);e&&(t[n.sessionRef]=dD(t[n.sessionRef]??[],[e]))}return t}function pD(e,t){let n=[`completed`,`blocked`,`aborted`,`error`].includes(String(t.settlement))?t.settlement:`unknown`;return{...e,operationRef:t.operationRef,abortable:!1,complete:!0,settlement:n,activities:[],delivery:e.user?`admitted`:e.delivery,assistant:n===`completed`?e.assistant:``,error:n===`completed`?null:String(t.reasonCode??`operation-settlement-unknown`)}}function mD(e,t){return{...e??{assistant:``,activities:[],operationRef:null,complete:!0,error:null},user:t.message,assistant:``,attachments:t.attachments,activities:[],operationRef:null,abortable:!1,complete:!1,settlement:null,error:null,messageRequestId:t.messageRequestId,delivery:`submitting`,startedAt:t.submittedAt,lastEventAt:t.submittedAt}}function hD(e,t,n,r){let i=t===`admitted`&&!!n&&e.operationRef===n&&e.complete;return{...e,delivery:t,operationRef:n??e.operationRef,abortable:t===`admitted`&&!i&&!!(n??e.operationRef),complete:t===`admitted`?i:e.complete,error:null,lastEventAt:r??e.lastEventAt}}function gD(e,t,n){return!e||e.messageRequestId!==n||e.delivery===`admitted`?e:t}function _D(e,t){if(t.state!==`ready`)return{...e};let n=new Map(t.operations.map(e=>[e.sessionRef,e])),r={...e};for(let[i,a]of Object.entries(e))n.has(i)||a.complete||a.delivery!==`submitting`&&(r[i]={...a,assistant:``,activities:[],operationRef:null,abortable:!1,complete:!0,settlement:`unknown`,error:`operation-settlement-unavailable`,lastEventAt:t.generatedAt});for(let n of t.operations){let i=e[n.sessionRef],a=!(n.messageRequestId&&i?.messageRequestId&&n.messageRequestId!==i.messageRequestId)&&(i?.operationRef===n.operationRef||!!(i?.user&&[`submitting`,`unconfirmed`].includes(String(i.delivery))));r[n.sessionRef]=a?{...i,operationRef:n.operationRef,abortable:n.abortable,complete:!1,settlement:null,messageRequestId:n.messageRequestId??i?.messageRequestId,delivery:i?.user?`admitted`:i?.delivery,error:null,lastEventAt:t.generatedAt}:{user:``,assistant:``,attachments:[],activities:[],operationRef:n.operationRef,messageRequestId:n.messageRequestId??null,abortable:n.abortable,complete:!1,settlement:null,error:null,runtimeRecovery:null,startedAt:t.generatedAt,lastEventAt:t.generatedAt}}return r}function vD(e,t){let n=e.toLowerCase();return n===`compaction`?t===`vi`?`tóm tắt phần cũ của cuộc trò chuyện`:`summarising the older part of the conversation`:n===`capacity-wait`?t===`vi`?`chờ tài khoản công ty rảnh`:`waiting for a free company account`:n===`ask_user`?t===`vi`?`chờ bạn trả lời câu hỏi`:`waiting for your answer`:/(subagent|scout|delegate|agent)/.test(n)?t===`vi`?`phối hợp agent hỗ trợ`:`coordinating a helper agent`:/(bash|exec|shell|command|terminal)/.test(n)?t===`vi`?`chạy lệnh`:`running a command`:/(read|grep|find|list|glob|search_file)/.test(n)?t===`vi`?`đọc mã nguồn`:`reading source`:/(edit|write|patch|apply)/.test(n)?t===`vi`?`cập nhật file`:`updating files`:/(test|verify|check|lint)/.test(n)?t===`vi`?`kiểm tra kết quả`:`verifying results`:/(web|search|browser|fetch)/.test(n)?t===`vi`?`tìm kiếm thông tin`:`searching`:t===`vi`?`chạy công cụ`:`running a tool`}var yD=/(?:sk-(?:proj|live|test|svcacct)-[A-Za-z0-9_-]{8,}|as_(?:live|device|run)_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}_|(?:api[_-]?key|password|secret|token)=)/i;function bD(e){if(typeof e!=`string`)return null;let t=(e.replace(/\\/g,`/`).split(`/`).at(-1)??``).trim();return!t||t===`.`||t===`..`||t.length>160||/[\u0000-\u001f\u007f/\\]/.test(t)||yD.test(t)||t.includes(`[REDACTED`)?null:t}function xD(e,t=`vi`,n=Date.now()){let r=[...e.activities].reverse().find(e=>e.state===`running`),i=r?vD(r.toolLabel,t):e.activities.length?t===`vi`?`tổng hợp bước tiếp theo`:`preparing the next step`:t===`vi`?`phân tích yêu cầu`:`analyzing the request`,a=Date.parse(e.lastEventAt??r?.startedAt??e.startedAt??``),o=Number.isFinite(a)?Math.max(0,Math.floor((n-a)/1e3)):null,s=o===null?t===`vi`?`Đang chờ cập nhật tiến trình đầu tiên`:`Waiting for the first progress update`:o<10?t===`vi`?`Tiến trình vừa cập nhật`:`Progress updated just now`:o<60?t===`vi`?`Cập nhật ${o} giây trước`:`Updated ${o}s ago`:t===`vi`?`Cập nhật ${Math.floor(o/60)} phút trước`:`Updated ${Math.floor(o/60)}m ago`,c=bD(r?.fileLabel),l=c?`${c} · ${s}`:s;return{label:t===`vi`?`Piagent đang ${i}…`:`Piagent is ${i}…`,detail:l}}function SD(e,t,n,r){if(e?.state!==`ready`||e.gatewayInstanceRef!==t)return!1;let i=e.operations.find(e=>e.sessionRef===n);return i?.operationRef===r&&i.abortable===!0}function CD(e,t){return{key:t,user:e,steps:[],answer:null,failure:null,failureDetail:null,requests:0,tokens:0,model:null,process:null,startedAt:e.recordedAt,endedAt:null,outputTokens:0,generationMs:0}}var wD=new Set([`objection`,`rejudge`,`dispute`]);function TD(e){let t=[],n=null,r=NaN;for(let i of e){let e=Date.parse(i.recordedAt),a=r;if(i.role!==`custom`&&(r=e),i.role===`user`){n=CD(i,i.messageRef),t.push(n);continue}if(!n||i.role===`tool-result`)continue;if(n.endedAt=i.recordedAt,i.role===`custom`&&i.process){if(i.process.phase===`final`){n.process=i.process;continue}n.answer&&!wD.has(i.process.phase)&&(n.steps.push({kind:`note`,key:`${i.messageRef}:answer`,text:n.answer}),n.answer=null),n.steps.push({kind:`process`,key:i.messageRef,process:i.process});continue}i.role===`assistant`&&i.usage?.outputTokens&&e>a&&(n.outputTokens+=i.usage.outputTokens,n.generationMs+=e-a),i.role===`assistant`&&(i.failure?.local||(n.requests+=1),n.tokens+=i.usage?.totalTokens??0,n.model=i.model??n.model);let o=Jx(i);if(o){n.answer||(n.failure=o,n.failureDetail=i.failure??null);continue}for(let e of i.toolCalls)n.steps.push({kind:`tool`,key:`${i.messageRef}:${e.toolCallRef}`,tool:e});if(i.toolCalls.length)continue;let s=i.role===`assistant`?Yx(i.content.text??``):i.content.text;if(s){if(i.role===`custom`){n.steps.push({kind:`note`,key:i.messageRef,text:s});continue}n.answer&&n.answer.trim()!==s.trim()&&n.steps.push({kind:`note`,key:`${i.messageRef}:previous`,text:n.answer}),n.answer=s,n.failure=null,n.failureDetail=null}}return t}function ED(e){let t=Date.parse(e.startedAt??``),n=Date.parse(e.endedAt??``);return Number.isFinite(t)&&Number.isFinite(n)&&n>=t?Math.round((n-t)/1e3):null}function DD(e){if(e.outputTokens<50||e.generationMs<250)return null;let t=e.outputTokens/(e.generationMs/1e3);return t>=10?Math.round(t):Math.round(t*10)/10}function OD(e,t){return e<40||t<1e3?null:Math.round(e/4/(t/1e3))}function kD(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:`${(e/1e6).toFixed(1)}M`}var AD=Y((0,U.jsx)(`path`,{d:`M19 5v14H5V5zm0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-4.86 8.86-3 3.87L9 13.14 6 17h12z`}),`ImageOutlined`);function jD(e){return Gr(`MuiAlertTitle`,e)}Kr(`MuiAlertTitle`,[`root`]);var MD=e=>{let{classes:t}=e;return ba({root:[`root`]},jD,t)},ND=K(X,{name:`MuiAlertTitle`,slot:`Root`})(ys(({theme:e})=>({fontWeight:e.typography.fontWeightMedium,marginTop:-2}))),PD=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiAlertTitle`}),{className:r,...i}=n,a=n,o=MD(a);return(0,U.jsx)(ND,{gutterBottom:!0,component:`div`,ownerState:a,ref:t,className:W(o.root,r),...i})}),FD=Y((0,U.jsx)(`path`,{d:`M22 11V3h-7v3H9V3H2v8h7V8h2v10h4v3h7v-8h-7v3h-2V8h2v3zM7 9H4V5h3zm10 6h3v4h-3zm0-10h3v4h-3z`}),`AccountTreeOutlined`),ID=Y((0,U.jsx)(`path`,{d:`m22.61 18.99-9.08-9.08c.93-2.34.45-5.1-1.44-7C9.79.61 6.21.4 3.66 2.26L7.5 6.11 6.08 7.52 2.25 3.69C.39 6.23.6 9.82 2.9 12.11c1.86 1.86 4.57 2.35 6.89 1.48l9.11 9.11c.39.39 1.02.39 1.41 0l2.3-2.3c.4-.38.4-1.01 0-1.41m-3 1.6-9.46-9.46c-.61.45-1.29.72-2 .82-1.36.2-2.79-.21-3.83-1.25C3.37 9.76 2.93 8.5 3 7.26l3.09 3.09 4.24-4.24-3.09-3.09c1.24-.07 2.49.37 3.44 1.31 1.08 1.08 1.49 2.57 1.24 3.96-.12.71-.42 1.37-.88 1.96l9.45 9.45z`}),`BuildOutlined`),LD=Y((0,U.jsx)(`path`,{d:`M22 8c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1m-9 8c0 .55.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7c-.55 0-1 .45-1 1M10.47 4.63c.39.39.39 1.02 0 1.41l-4.23 4.25c-.39.39-1.02.39-1.42 0L2.7 8.16a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0l1.42 1.42 3.54-3.54c.38-.38 1.02-.38 1.4 0m.01 8.01c.39.39.39 1.02 0 1.41L6.25 18.3c-.39.39-1.02.39-1.42 0L2.7 16.16c-.39-.39-.39-1.02 0-1.41s1.02-.39 1.41 0l1.42 1.42 3.54-3.54c.38-.38 1.02-.38 1.41.01`}),`ChecklistRounded`),RD=Y((0,U.jsx)(`path`,{d:`m14.85 4.85 1.44 1.44-2.88 2.88 1.42 1.42 2.88-2.88 1.44 1.44c.31.31.85.09.85-.36V4.5c0-.28-.22-.5-.5-.5h-4.29c-.45 0-.67.54-.36.85M8.79 4H4.5c-.28 0-.5.22-.5.5v4.29c0 .45.54.67.85.35L6.29 7.7 11 12.4V19c0 .55.45 1 1 1s1-.45 1-1v-7c0-.26-.11-.52-.29-.71l-5-5.01 1.44-1.44c.31-.3.09-.84-.36-.84`}),`CallSplitRounded`),zD=Y((0,U.jsx)(`path`,{d:`M9 16.17 5.53 12.7a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71c.39-.39.39-1.02 0-1.41a.996.996 0 0 0-1.41 0z`}),`CheckRounded`),BD=Y((0,U.jsx)(`path`,{d:`m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z`}),`EditOutlined`),VD=Y((0,U.jsx)(`path`,{d:`M8 2c-1.1 0-2 .9-2 2v3.17c0 .53.21 1.04.59 1.42L10 12l-3.42 3.42c-.37.38-.58.89-.58 1.42V20c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2v-3.16c0-.53-.21-1.04-.58-1.41L14 12l3.41-3.4c.38-.38.59-.89.59-1.42V4c0-1.1-.9-2-2-2zm8 14.5V19c0 .55-.45 1-1 1H9c-.55 0-1-.45-1-1v-2.5l4-4zm-4-5-4-4V5c0-.55.45-1 1-1h6c.55 0 1 .45 1 1v2.5z`}),`HourglassEmptyRounded`),HD=Y((0,U.jsx)(`path`,{d:`M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56M12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96M4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2s.06 1.34.14 2zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56m2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8M12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96M14.34 14H9.66c-.09-.66-.16-1.32-.16-2s.07-1.35.16-2h4.68c.09.65.16 1.32.16 2s-.07 1.34-.16 2m.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56M16.36 14c.08-.66.14-1.32.14-2s-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2z`}),`LanguageRounded`),UD=Y((0,U.jsx)(`path`,{d:`M13 11h-2v3H8v2h3v3h2v-3h3v-2h-3zm1-9H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm4 18H6V4h7v5h5z`}),`NoteAddOutlined`),WD=Y((0,U.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39`}),`PublicRounded`),GD=Y((0,U.jsx)(`path`,{d:`M19.3 16.9c.58-1.01.95-2.23.51-3.65-.53-1.72-2.04-3.05-3.84-3.22-2.87-.28-5.23 2.07-4.95 4.95.18 1.79 1.5 3.31 3.22 3.84 1.43.44 2.64.07 3.65-.51l2.5 2.5c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4zm-3.8.1c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5M12 20v2C6.48 22 2 17.52 2 12S6.48 2 12 2c4.84 0 8.87 3.44 9.8 8h-2.07c-.64-2.46-2.4-4.47-4.73-5.41V5c0 1.1-.9 2-2 2h-2v2c0 .55-.45 1-1 1H8v2h2v3H9l-4.79-4.79C4.08 10.79 4 11.38 4 12c0 4.41 3.59 8 8 8`}),`TravelExploreRounded`);function KD(e){return{color:`${e}.dark`,'html[data-piagent-color-mode="dark"] &':{color:`${e}.main`}}}var qD=`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,JD={read:MT,write:UD,edit:BD,command:Fh,search:dx,list:wT,"web-search":GD,"web-fetch":HD,subagent:FD,network:WD,git:RD,plan:LD,other:ID},YD={read:[`Đọc`,`Read`],write:[`Tạo`,`Write`],edit:[`Sửa`,`Edit`],command:[`Chạy`,`Run`],search:[`Tìm`,`Search`],list:[`Xem thư mục`,`List`],"web-search":[`Tìm web`,`Web search`],"web-fetch":[`Đọc trang`,`Fetch page`],subagent:[`Subagent`,`Subagent`],network:[`Chạy có mạng`,`Run with network`],git:[`Git`,`Git`],plan:[`Plan`,`Plan`],other:[`Công cụ`,`Tool`]},XD={read:`read`,write:`write`,edit:`edit`,apply_patch:`edit`,bash:`command`,run_experiment:`command`,grep:`search`,find:`search`,ls:`list`,web_search:`web-search`,web_fetch:`web-fetch`,delegate:`subagent`,subagent:`subagent`,run_with_network:`network`,fetch_origin:`git`,update_plan:`plan`};function ZD(e){return XD[e.toLowerCase()]??`other`}function QD({preview:e}){return(0,U.jsx)(J,{component:`pre`,sx:{m:0,fontFamily:qD,fontSize:12,lineHeight:1.55,overflowX:`auto`},children:e.split(`
|
|
177
|
-
`).map((e,t)=>{let n=e[0],r=n===`+`?`success`:n===`-`?`error`:null;return(0,U.jsx)(J,{component:`div`,sx:{px:1,whiteSpace:`pre`,...r?KD(r):{color:e===`@@`?`text.disabled`:`text.secondary`},bgcolor:r?`rgba(var(--piagent-palette-${r}-mainChannel) / .12)`:`transparent`},children:e===`@@`?`⋯`:e||` `},t)})})}function $D({tool:e,locale:t,live:n,waiting:r}){let i=e.summary??{kind:`other`,target:null,detail:null},a=`change`in e?e.change:void 0,o=`result`in e?e.result:void 0,s=e.state===`failed`||o?.isError===!0,c=`failure`in e&&e.failure?{detail:e.failure,copy:qC(e.failure.reasonCode,e.failure.code,t)}:null,l=n?e.state===`running`:e.state===`requested`,[u,d]=(0,v.useState)(()=>s||(i.kind===`edit`||i.kind===`write`)&&!!a?.preview),f=!!(a?.preview||o?.text||c?.copy||i.detail&&i.kind!==`read`),p=r?VD:JD[i.kind],m=YD[i.kind][t===`vi`?0:1],h=i.kind===`other`?e.toolName:m;return(0,U.jsxs)(J,{sx:{border:1,borderColor:s?`error.main`:`divider`,borderRadius:2,bgcolor:`background.paper`,overflow:`hidden`},children:[(0,U.jsxs)(tu,{component:`div`,disabled:!f,onClick:()=>d(e=>!e),"aria-expanded":f?u:void 0,sx:{width:`100%`,display:`flex`,alignItems:`center`,gap:1,px:1.25,py:.85,textAlign:`left`,justifyContent:`flex-start`},children:[(0,U.jsx)(p,{sx:{fontSize:17,color:s?`error.main`:`text.secondary`,flexShrink:0}}),(0,U.jsx)(X,{variant:`body2`,sx:{fontWeight:600,flexShrink:0},children:h}),i.target&&(0,U.jsx)(X,{variant:`body2`,noWrap:!0,title:i.target,sx:{fontFamily:qD,fontSize:12.5,color:`text.secondary`,minWidth:0,flex:1},children:i.target}),!i.target&&(0,U.jsx)(J,{sx:{flex:1}}),i.kind===`read`&&i.detail&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{flexShrink:0},children:Q(t,`dòng ${i.detail}`,`lines ${i.detail}`)}),a&&(a.added>0||a.removed>0)&&(0,U.jsxs)(X,{variant:`caption`,sx:{fontFamily:qD,flexShrink:0},children:[a.added>0&&(0,U.jsxs)(J,{component:`span`,sx:KD(`success`),children:[`+`,a.added,` `]}),a.removed>0&&(0,U.jsxs)(J,{component:`span`,sx:KD(`error`),children:[`−`,a.removed]})]}),s&&!l&&(0,U.jsx)(X,{variant:`caption`,sx:{flexShrink:0,fontWeight:600,...KD(`error`)},children:Q(t,`Lỗi`,`Failed`)}),l?(0,U.jsx)(xu,{size:14,thickness:5,"aria-label":Q(t,`Đang chạy`,`Running`)}):s?(0,U.jsx)(qE,{sx:{fontSize:16,color:`error.main`},"aria-hidden":`true`}):(0,U.jsx)(zD,{sx:{fontSize:16,color:`success.main`},"aria-label":Q(t,`Xong`,`Done`)}),f&&(0,U.jsx)(CT,{sx:{fontSize:18,color:`text.disabled`,transition:`transform .15s`,transform:u?`rotate(180deg)`:`none`}})]}),(0,U.jsx)(jC,{in:u&&f,unmountOnExit:!0,children:(0,U.jsxs)(J,{sx:{borderTop:1,borderColor:`divider`,bgcolor:`action.hover`,maxHeight:360,overflow:`auto`},children:[i.detail&&i.kind!==`read`&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1.25,py:.75,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,...i.kind===`command`?{fontFamily:qD,fontSize:12}:{}},children:i.detail}),c?.copy&&(0,U.jsxs)(J,{sx:{px:1.25,py:.75},children:[(0,U.jsxs)(X,{variant:`body2`,sx:{fontWeight:650,...KD(`error`)},children:[XC(c.detail.role,t),` `,Q(t,`lỗi`,`failed`),` · `,c.copy.title]}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:c.copy.text}),(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,sx:{fontFamily:qD,overflowWrap:`anywhere`},title:c.detail.requestRef??void 0,children:[Q(t,`Mã`,`Code`),`: `,c.detail.code,c.detail.requestRef?` · request ${c.detail.requestRef.slice(0,8)}`:``]})]}),a?.preview&&(0,U.jsx)(J,{sx:{py:.5},children:(0,U.jsx)(QD,{preview:a.preview})}),o?.text&&!c?.copy&&(0,U.jsx)(J,{component:`pre`,sx:{m:0,px:1.25,py:.75,fontFamily:qD,fontSize:12,lineHeight:1.55,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,color:o.isError?`error.main`:`text.secondary`},children:o.text}),(a?.truncated||o?.truncated)&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,px:1.25,pb:.75},children:Q(t,`Đã rút gọn`,`Truncated`)})]})})]})}var eO=Y((0,U.jsx)(`path`,{d:`M15 4v7H5.17L4 12.17V4zm1-2H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1m5 4h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1`}),`ForumOutlined`),tO=Y((0,U.jsx)(`path`,{d:`M12 5V2.21c0-.45-.54-.67-.85-.35l-3.8 3.79c-.2.2-.2.51 0 .71l3.79 3.79c.32.31.86.09.86-.36V7c3.73 0 6.68 3.42 5.86 7.29-.47 2.27-2.31 4.1-4.57 4.57-3.57.75-6.75-1.7-7.23-5.01-.07-.48-.49-.85-.98-.85-.6 0-1.08.53-1 1.13.62 4.39 4.8 7.64 9.53 6.72 3.12-.61 5.63-3.12 6.24-6.24C20.84 9.48 16.94 5 12 5`}),`ReplayRounded`),nO=(e,t,n)=>e===`vi`?t:n,rO={blocking:[`blocking`,`blocking`],major:[`major`,`major`],minor:[`minor`,`minor`]},iO={wrong_premise:[`sai giả định`,`wrong premise`],conflicts_with_request:[`conflict với yêu cầu`,`conflicts with the request`],ambiguous:[`chưa rõ ràng`,`ambiguous`],out_of_scope:[`out of scope`,`out of scope`]},aO={too_large:[`patch quá lớn`,`the patch is too large`],not_git:[`thư mục không phải git`,`not a git repository`],limit:[`subagent đã hết lượt gọi`,`the subagent ran out of calls`],failed:[`subagent lỗi`,`the subagent failed`]};function oO(e,t){let n=[];return e.outcome===`interrupted`?nO(t,`Lượt bị dừng trước khi check xong`,`The turn stopped before its checks finished`):(e.outcome===`disputed`&&n.push((e.disputes??1)>1?nO(t,`${e.disputes} conflict giữa main agent và subagent, bạn quyết định`,`${e.disputes} disagreements between the main agent and a subagent; your call`):nO(t,`Main agent và subagent conflict, bạn quyết định`,`The main agent and a subagent disagree; your call`)),e.unchanged?n.join(` · `)||nO(t,`Không đổi code`,`No code changed`):(e.verified?n.push(nO(t,`Check đã pass trên code cuối`,`A check passed on the final code`)):e.verifyPolicy!==`off`&&n.push(nO(t,`Chưa có check pass trên code cuối`,`No check passed on the final code`)),e.reviewed?n.push(e.blockingOpen?nO(t,`Còn ${e.blockingOpen} lỗi blocking chưa fix`,`${e.blockingOpen} blocking issue(s) still open`):nO(t,`Review không có lỗi blocking`,`Review found no blocking issue`)):e.reviewPolicy!==`off`&&n.push(e.outcome===`review_unavailable`?nO(t,`Không chạy được review`,`The review could not run`)+(e.reviewUnavailable&&aO[e.reviewUnavailable]?` (${nO(t,...aO[e.reviewUnavailable])})`:``):nO(t,`Chưa review`,`Not reviewed`)),e.planSkipped&&n.push(nO(t,`Đã sửa code khi chưa có plan`,`Code was changed before a plan existed`)),e.planOpen&&n.push(nO(t,`Plan còn ${e.planOpen} bước chưa xong`,`${e.planOpen} plan step(s) not completed`)),n.join(` · `)||nO(t,`Đã đổi code`,`Code changed`)))}function sO(e,t){let n=e.loop&&e.maxLoops?nO(t,` (vòng ${e.loop}/${e.maxLoops})`,` (round ${e.loop}/${e.maxLoops})`):``,r=KC(e.role??`review`,t),i=(e.findings??e.claims??e.issues??[]).length;switch(e.phase){case`plan`:return nO(t,`Harness: plan còn ${e.planOpen??0} bước chưa đánh dấu xong, yêu cầu agent cập nhật`,`Harness: ${e.planOpen??0} plan step(s) not marked completed; asked the agent to update the plan`);case`verify`:return nO(t,`Harness: chưa có check nào pass trên code hiện tại, yêu cầu agent chạy check${n}`,`Harness: no check has passed on the current code; asked the agent to run checks${n}`);case`review`:return nO(t,`Harness: review tìm thấy ${i} lỗi blocking, gửi lại agent để fix hoặc giải thích${n}`,`Harness: the review found ${i} blocking issue(s); sent back to the agent to fix or answer${n}`);case`objection`:return nO(t,`${r} phản biện brief của main agent`,`${r} objected to the main agent's brief`);case`answer`:return nO(t,`Harness: yêu cầu main agent nói rõ đã quyết định gì với phản biện của subagent`,`Harness: asked the main agent to say what it decided about the subagent's objection`);case`claims`:return nO(t,`Harness: ${r} đánh fail ${i} claim, gửi lại main agent`,`Harness: ${r} marked ${i} claim(s) as failed; sent back to the main agent`);case`rejudge`:return e.role===`verify`?nO(t,`Harness: ${r} check lại các claim cùng câu trả lời của main agent`,`Harness: ${r} checks the claims again with the main agent's answer`):nO(t,`Harness: main agent giải thích thay vì fix, ${r} xem xét lại lời giải thích`,`Harness: the main agent answered instead of fixing; ${r} judges the answer`);case`dispute`:return nO(t,`Main agent và ${r} vẫn conflict sau 2 lượt, bạn quyết định`,`The main agent and the ${r} still disagree after two rounds; your call`);default:return``}}function cO(e,t){return(e.findings??[]).map(e=>({tag:nO(t,...rO[e.severity]??[e.severity,e.severity]),tone:e.severity===`blocking`?`error`:`warning`,location:e.file?`${e.file}${e.line?`:${e.line}`:``}`:null,text:e.issue})).concat((e.claims??[]).map(e=>({tag:`fail`,tone:`error`,location:null,text:e.claim}))).concat((e.issues??[]).map(e=>({tag:nO(t,...iO[e.kind]??[e.kind,e.kind]),tone:`warning`,location:null,text:e.detail})))}var lO={clean:`success`,disputed:`warning`,blocking_open:`error`,unverified:`warning`,unreviewed:`warning`,review_unavailable:`warning`,interrupted:`warning`,no_change:`info`};function uO(e,t){return oO(e,t)}var dO=e=>e?lO[e]:`info`,fO=e=>{let t=dO(e.outcome);return t===`success`&&(e.planSkipped||e.planOpen)?`warning`:t},pO={fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:12.5};function mO({process:e,locale:t}){let n=cO(e,t).map(e=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(J,{component:`span`,sx:{fontWeight:600,...KD(e.tone)},children:[`[`,e.tag,`]`]}),e.location&&(0,U.jsxs)(J,{component:`span`,sx:pO,children:[` `,e.location]}),e.location?` — `:` `,e.text]}));return n.length>0?(0,U.jsx)(J,{component:`ol`,sx:{m:0,pl:3.5},children:n.map((e,t)=>(0,U.jsx)(X,{component:`li`,variant:`body2`,sx:{overflowWrap:`anywhere`},children:e},t))}):null}function hO({process:e,locale:t}){if(e.phase===`final`){let n=fO(e),r=n===`success`?Mw:n===`error`?QE:lT;return(0,U.jsxs)(Z,{direction:`row`,role:`status`,"aria-label":Q(t,`Tiến trình của lượt`,`Turn process`),sx:{alignItems:`flex-start`,gap:.75},children:[(0,U.jsx)(r,{sx:{fontSize:16,mt:.2,...KD(n)}}),(0,U.jsx)(X,{variant:`body2`,sx:KD(n),children:uO(e,t)})]})}let n=e.phase===`dispute`||e.phase===`objection`,r=e.phase===`dispute`?lT:e.phase===`objection`?eO:tO,i=e.phase===`dispute`?`warning`:null;return(0,U.jsxs)(Z,{spacing:.5,role:n?`status`:void 0,sx:{borderLeft:2,borderColor:i?`warning.main`:`divider`,pl:1.25},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`flex-start`,gap:.75},children:[(0,U.jsx)(r,{sx:{fontSize:16,mt:.2,...i?KD(i):{color:`text.secondary`}}}),(0,U.jsx)(X,{variant:`body2`,sx:i?{fontWeight:600,...KD(i)}:n?{fontWeight:600}:{color:`text.secondary`},children:sO(e,t)})]}),(0,U.jsx)(mO,{process:e,locale:t})]})}var gO=null,_O=()=>gO??=hx(()=>import(`./MarkdownMessage-DlbuyiQ3.js`),[]),vO=(0,v.lazy)(async()=>({default:(await _O()).MarkdownMessage}));function yO({children:e}){return(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(X,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.75},children:e}),children:(0,U.jsx)(vO,{children:e})})}function bO({attachments:e,locale:t}){return e.length?(0,U.jsx)(Z,{spacing:.75,sx:{mb:1},"aria-label":Q(t,`File đã gửi`,`Sent files`),children:e.map((e,n)=>{let r=`sourceBytes`in e?cS(e,t):`${e.kind===`document`?Q(t,`Tài liệu`,`Document`):e.kind===`image`?Q(t,`Ảnh`,`Image`):`File`}${e.truncated?` · ${Q(t,`đã cắt bớt`,`truncated`)}`:``}`;return(0,U.jsxs)(Pc,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:1.1,minWidth:220,maxWidth:440,px:1.2,py:1,borderRadius:2,bgcolor:`background.paper`},children:[e.kind===`image`?(0,U.jsx)(AD,{color:`action`}):(0,U.jsx)(MT,{color:`action`}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{variant:`body2`,noWrap:!0,sx:{fontWeight:650},children:e.displayName}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:r})]})]},`${e.displayName}:${n}`)})}):null}var xO=new Set([`assistant-response-failed`,`operation-failed`]);function SO(e,t){switch(e){case`provider-auth-expired`:return Q(t,`Phiên đăng nhập model đã hết hạn. Mở Cài đặt → Nhà cung cấp & model để kết nối lại.`,`The model sign-in expired. Open Settings → Providers & models to reconnect.`);case`provider-auth-required`:return Q(t,`Model cần đăng nhập lại. Mở Cài đặt → Nhà cung cấp & model.`,`The model needs to sign in again. Open Settings → Providers & models.`);case`provider-rate-limited`:return Q(t,`Model đang bị giới hạn lượt gọi hoặc đã hết hạn mức. Thử lại sau.`,`The model is rate limited or out of quota. Try again later.`);case`provider-unavailable`:return Q(t,`Model hoặc máy chủ trung gian đang không phục vụ yêu cầu này. Thử lại; nếu lỗi lặp lại, kiểm tra model đang dùng.`,`The model or its gateway did not serve this request. Retry; if it repeats, check the model in use.`);case`assistant-output-incomplete`:return Q(t,`Câu trả lời dừng giữa chừng vì chạm giới hạn độ dài. Gửi “tiếp tục” để model viết tiếp.`,`The answer stopped at the length limit. Send “continue” to resume.`);default:return Q(t,`Model trả lỗi và chưa có câu trả lời. Gửi lại; nếu lỗi lặp lại, kiểm tra model đang dùng.`,`The model returned an error without an answer. Send again; if it repeats, check the model in use.`)}}function CO({code:e,detail:t,locale:n,onContinue:r}){let i=qC(e,t?.code??null,n),a=r&&YC(e)?(0,U.jsx)($,{color:`inherit`,size:`small`,onClick:r,children:Q(n,`Tiếp tục`,`Continue`)}):void 0;return i?(0,U.jsxs)(pC,{severity:`error`,variant:`outlined`,icon:(0,U.jsx)(QE,{}),action:a,sx:{alignSelf:`stretch`},children:[(0,U.jsxs)(PD,{sx:{fontSize:`inherit`,fontWeight:650,mb:.25},children:[XC(t?.role??`main`,n),` `,Q(n,`lỗi`,`failed`),` · `,i.title]}),i.text,t&&(0,U.jsxs)(X,{variant:`caption`,component:`div`,color:`text.secondary`,sx:{mt:.5,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,overflowWrap:`anywhere`},title:t.requestRef??void 0,children:[Q(n,`Mã`,`Code`),`: `,t.code,t.requestRef?` · request ${t.requestRef.slice(0,8)}`:``]})]}):(0,U.jsx)(pC,{severity:`error`,variant:`outlined`,icon:(0,U.jsx)(QE,{}),action:a,sx:{alignSelf:`stretch`},children:SO(e,n)})}function wO({text:e,attachments:t,note:n,locale:r}){return(0,U.jsxs)(J,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:3,px:2,py:1.4},children:[(0,U.jsx)(bO,{attachments:t,locale:r}),e&&(0,U.jsx)(X,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:e}),n&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:n})]})}function TO({children:e}){return(0,U.jsxs)(J,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(Z,{spacing:1,sx:{minWidth:0,flex:1},children:[(0,U.jsx)(X,{sx:{fontWeight:600},children:`Piagent`}),e]})]})}function EO(e,t){return e.content.redacted?Q(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):e.content.truncated?Q(t,`Nội dung đã rút gọn`,`Content truncated`):null}function DO({turn:e,locale:t}){let n=ED(e),r=[`${e.requests} request`];e.tokens&&r.push(`${kD(e.tokens)} token`),n!==null&&n>0&&r.push(n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`);let i=DD(e);return i!==null&&r.push(`${i} tok/s`),e.model&&r.push(e.model),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,title:Q(t,`Request model, token, thời gian và tốc độ sinh token (token đầu ra mỗi giây, tính cả thời gian chờ) của lượt này`,`Model requests, tokens, time and output speed (output tokens per second, waiting included) of this turn`),children:r.join(` · `)})}function OO({turn:e,locale:t,onContinue:n}){let r=!!n&&!e.answer&&!e.failure,i=e.steps.length>0||e.answer||e.failure||r||e.process;return(0,U.jsxs)(Z,{spacing:1.5,children:[(0,U.jsx)(wO,{text:e.user.content.text,attachments:e.user.attachments??[],note:EO(e.user,t),locale:t}),i&&(0,U.jsxs)(TO,{children:[e.steps.map(e=>e.kind===`tool`?(0,U.jsx)($D,{tool:e.tool,locale:t},e.key):e.kind===`process`?(0,U.jsx)(hO,{process:e.process,locale:t},e.key):(0,U.jsx)(J,{sx:{color:`text.secondary`,fontSize:`.875rem`,"& .MuiTypography-root":{fontSize:`inherit`}},children:(0,U.jsx)(yO,{children:e.text})},e.key)),e.failure&&(0,U.jsx)(CO,{code:e.failure,detail:e.failureDetail,locale:t,onContinue:n}),r&&(0,U.jsx)(pC,{severity:`info`,variant:`outlined`,sx:{alignSelf:`stretch`},action:(0,U.jsx)($,{color:`inherit`,size:`small`,onClick:n,children:Q(t,`Tiếp tục`,`Continue`)}),children:Q(t,`Lượt này chưa có câu trả lời: nó đã bị dừng, hoặc ứng dụng hay máy tắt khi đang chạy. Các bước đã làm vẫn được giữ; bấm Tiếp tục để làm tiếp.`,`This turn has no answer: it was stopped, or the app or the machine went down while it ran. Its steps are kept; press Continue to go on.`)}),e.answer&&(0,U.jsx)(J,{children:(0,U.jsx)(yO,{children:e.answer})}),e.process&&(0,U.jsx)(hO,{process:e.process,locale:t}),e.requests>0&&(0,U.jsx)(DO,{turn:e,locale:t})]})]})}function kO(e,t){return e===`compaction`?Q(t,`Tóm tắt phần cũ của cuộc trò chuyện`,`Summarise the older part of the conversation`):e===`capacity-wait`?Q(t,`Chờ tài khoản công ty rảnh (Studio đang bận, sẽ tự gửi lại)`,`Wait for a free company account (Studio is busy; it is sent again by itself)`):e}function AO({user:e,attachments:t,activities:n,assistant:r,running:i,failure:a,status:o,locale:s}){return(0,U.jsxs)(Z,{spacing:1.5,children:[e&&(0,U.jsx)(wO,{text:e,attachments:t,locale:s}),(0,U.jsxs)(TO,{children:[n.map(e=>(0,U.jsx)($D,{live:!0,locale:s,waiting:e.toolLabel===`capacity-wait`,tool:{toolName:kO(e.toolLabel,s),state:e.state,summary:{kind:ZD(e.toolLabel),target:e.fileLabel??null,detail:null}}},e.toolCallRef)),a&&(0,U.jsx)(CO,{code:a,locale:s}),r&&(0,U.jsx)(J,{children:(0,U.jsx)(yO,{children:r})}),i&&o]})]})}function jO(e){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!e){t.current=null,r(null);return}t.current??={at:Date.now(),from:e.length},r(OD(e.length-t.current.from,Date.now()-t.current.at))},[e]),n}function MO({live:e,locale:t,onOpenActivity:n}){let[r,i]=(0,v.useState)(()=>Date.now());(0,v.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e4);return()=>window.clearInterval(e)},[]);let a=xD(e,t,r),o=jO(e.assistant??``);return(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,role:`status`,"aria-live":`polite`,sx:{alignItems:`center`,color:`text.secondary`,py:.75},children:[(0,U.jsx)(xu,{size:19,thickness:4}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{variant:`body2`,sx:{fontWeight:600},children:a.label}),(0,U.jsxs)(X,{variant:`caption`,color:`text.disabled`,children:[a.detail,o!==null&&` · ≈ ${o} tok/s`]})]}),n&&(0,U.jsx)($,{size:`small`,variant:`text`,onClick:n,sx:{ml:`auto !important`},children:Q(t,`Xem Activity`,`View Activity`)})]})}var NO=new Map,PO=96,FO=()=>document.documentElement.scrollHeight-window.innerHeight,IO=()=>FO()-window.scrollY<=PO;function LO(e,t){let n=(0,v.useRef)(null),r=(0,v.useRef)(!1),i=(0,v.useRef)(!0);return(0,v.useLayoutEffect)(()=>{if(!t||r.current)return;r.current=!0;let n=NO.get(e)??`end`;i.current=n===`end`,window.scrollTo(0,n===`end`?FO():Math.min(n,FO()))},[t,e]),(0,v.useEffect)(()=>{let t=()=>{r.current&&(i.current=IO(),NO.set(e,i.current?`end`:window.scrollY))};window.addEventListener(`scroll`,t,{passive:!0});let a=n.current,o=typeof ResizeObserver>`u`||!a?null:new ResizeObserver(()=>{r.current&&i.current&&window.scrollTo(0,FO())});return a&&o?.observe(a),()=>{window.removeEventListener(`scroll`,t),o?.disconnect()}},[e]),n}function RO({sessionRef:e,sessionRevision:t,live:n,approvals:r,locale:i,onOpenActivity:a,onContinue:o,reload:s=0}){let[c,l]=(0,v.useState)(),[u,d]=(0,v.useState)(!0),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(null);(0,v.useEffect)(()=>{_O()},[]);let y=Gx(e,t,n),{completionKey:b,user:x,assistant:S,operationRef:C,messageRequestId:w,startedAt:T}=y;(0,v.useEffect)(()=>{let t=new AbortController;d(!0),h(!1),_(null);let n=window.setTimeout(()=>{Kg(e,null,50,t.signal).then(e=>{l(e),b&&eS(e.items,x,S,{operationRef:C,messageRequestId:w,startedAt:T})&&_(b)}).catch(()=>{t.signal.aborted||h(!0)}).finally(()=>{t.signal.aborted||d(!1)})},b?100:0);return()=>{window.clearTimeout(n),t.abort()}},[y.key,s]);let E=c?.state===`ready`?c.items:[],D=(0,v.useMemo)(()=>TD(E),[E]),O=(0,v.useMemo)(()=>!!(n?.user&&tS(E,n.user,{operationRef:n.operationRef,messageRequestId:n.messageRequestId,startedAt:n.startedAt})),[E,n?.user,n?.operationRef,n?.messageRequestId,n?.startedAt]),k=!!(n&&!O&&(!n.complete||g!==b)),A=(0,v.useMemo)(()=>!!(n?.user&&$x(E,n.user,{operationRef:n.operationRef,messageRequestId:n.messageRequestId,startedAt:n.startedAt})),[E,n?.user,n?.operationRef,n?.messageRequestId,n?.startedAt]),j=async()=>{let t=c?.page.nextBeforeCursor;if(!(!t||f)){p(!0);try{let n=await Kg(e,t,c.page.limit);l(e=>e?{...e,items:Bx(e.items,n.items),page:n.page}:n)}catch{h(!0)}finally{p(!1)}}},M=n?Yx(n.assistant||``):null,N=LO(e,!!c||m);return(0,U.jsxs)(Z,{ref:N,spacing:3,children:[c?.page.hasOlder&&(0,U.jsx)(J,{sx:{textAlign:`center`},children:(0,U.jsx)($,{size:`small`,variant:`text`,startIcon:f?(0,U.jsx)(xu,{size:14}):(0,U.jsx)(Ih,{}),disabled:f,onClick:()=>void j(),children:Q(i,`Tải tin cũ hơn`,`Load older messages`)})}),u&&!c&&(0,U.jsx)(J,{sx:{py:5,textAlign:`center`},children:(0,U.jsx)(xu,{size:22})}),m&&!c&&(0,U.jsx)(pC,{severity:`warning`,icon:(0,U.jsx)(QE,{}),children:Q(i,`Chưa tải được lịch sử cuộc trò chuyện. Thử lại bằng nút làm mới.`,`Session history could not be loaded. You can retry with Refresh.`)}),D.map((e,t)=>(0,U.jsx)(OO,{turn:e,locale:i,onContinue:t===D.length-1&&!k&&!r?.pending.length?o:void 0},e.key)),(0,U.jsx)(nD,{sessionRef:e,waiting:!!(n&&!n.complete&&n.activities.some(e=>e.toolLabel===`ask_user`&&e.state===`running`))}),(0,U.jsx)(ES,{sessionRef:e,approvalRefs:r?.pending.map(e=>e.approvalRef)??[]}),k&&n&&(0,U.jsx)(AO,{user:n.user&&!A?n.user:null,attachments:n.attachments,activities:n.activities,assistant:n.error?null:M,running:!n.complete&&!n.error,failure:n.complete&&n.error&&xO.has(n.error)?n.error:null,locale:i,status:(0,U.jsx)(MO,{live:n,locale:i,onOpenActivity:a})})]})}var zO=Y((0,U.jsx)(`path`,{d:`m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27m-8.89 11.92L6.5 12H10v-2h4v2h3.5l-5.15 5.15c-.19.19-.51.19-.7 0M5.12 5l.81-1h12l.94 1z`}),`ArchiveRounded`),BO=Y((0,U.jsx)(`path`,{d:`M20 4v12H5.17L4 17.17V4zm0-2H4c-1.1 0-2 .9-2 2v15.59c0 .89 1.08 1.34 1.71.71L6 18h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2`}),`ChatBubbleOutlineRounded`),VO=Y((0,U.jsx)(`path`,{d:`M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2`}),`MoreHorizRounded`),HO=Y((0,U.jsx)(`path`,{d:`M14 4v5c0 1.12.37 2.16 1 3H9c.65-.86 1-1.9 1-3V4zm3-2H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3V4h1c.55 0 1-.45 1-1s-.45-1-1-1`}),`PushPinOutlined`),UO=Y((0,U.jsx)(`path`,{d:`M19.5 12c0-.23-.01-.45-.03-.68l1.86-1.41c.4-.3.51-.86.26-1.3l-1.87-3.23c-.25-.44-.79-.62-1.25-.42l-2.15.91c-.37-.26-.76-.49-1.17-.68l-.29-2.31c-.06-.5-.49-.88-.99-.88h-3.73c-.51 0-.94.38-1 .88l-.29 2.31c-.41.19-.8.42-1.17.68l-2.15-.91c-.46-.2-1-.02-1.25.42L2.41 8.62c-.25.44-.14.99.26 1.3l1.86 1.41c-.02.22-.03.44-.03.67s.01.45.03.68l-1.86 1.41c-.4.3-.51.86-.26 1.3l1.87 3.23c.25.44.79.62 1.25.42l2.15-.91c.37.26.76.49 1.17.68l.29 2.31c.06.5.49.88.99.88h3.73c.5 0 .93-.38.99-.88l.29-2.31c.41-.19.8-.42 1.17-.68l2.15.91c.46.2 1 .02 1.25-.42l1.87-3.23c.25-.44.14-.99-.26-1.3l-1.86-1.41c.03-.23.04-.45.04-.68m-7.46 3.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5`}),`SettingsRounded`);function WO(e){return(0,U.jsx)(cl,{viewBox:`0 0 16 16`,...e,children:(0,U.jsx)(`path`,{d:`M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Zm0 2.122a2.25 2.25 0 1 0-1.5 0v5.256a2.25 2.25 0 1 0 1.5 0V9.5h3.25a2.75 2.75 0 0 0 2.75-2.75v-1.378a2.25 2.25 0 1 0-1.5 0V6.75c0 .69-.56 1.25-1.25 1.25H5V5.372ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm7.5-9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z`})})}function GO(e,t){return e.detached?Q(t,`Git không ở nhánh nào (detached HEAD tại ${e.name})`,`Git is not on a branch (detached HEAD at ${e.name})`):Q(t,`Nhánh Git của project: ${e.name}`,`The project's Git branch: ${e.name}`)}function KO({branch:e,locale:t,maxWidth:n=220,tooltip:r=!0}){if(!e)return null;let i=(0,U.jsxs)(J,{component:`span`,"aria-label":r?GO(e,t):void 0,sx:{display:`inline-flex`,alignItems:`center`,gap:.4,minWidth:0,maxWidth:n,verticalAlign:`bottom`,color:e.detached?`warning.main`:`inherit`},children:[(0,U.jsx)(WO,{sx:{fontSize:`1.1em`,flexShrink:0}}),(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:`.95em`},children:e.name})]});return r?(0,U.jsx)(Ah,{describeChild:!0,title:GO(e,t),children:i}):i}function qO(e,t){let n=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));if(n<60)return Q(t,`Vừa mới`,`Just now`);let r=Math.floor(n/60);if(r<60)return Q(t,`${r} phút`,`${r}m`);let i=Math.floor(r/60);if(i<24)return Q(t,`${i} giờ`,`${i}h`);let a=Math.floor(i/24);return Q(t,`${a} ngày`,`${a}d`)}function JO(e,t){return t&&!t.complete?`running`:e.state===`terminal-owned`?`elsewhere`:e.state===`recovery-required`?`recovery`:e.needsAttention?`attention`:t?.complete&&t.error?`failed`:e.liveState===`running`?`running`:`idle`}function YO({activity:e,locale:t}){let n={running:`primary.main`,elsewhere:`info.main`,attention:`warning.main`,recovery:`error.main`,failed:`error.main`,idle:`transparent`}[e],r={running:Q(t,`Đang chạy`,`Running`),elsewhere:Q(t,`Đang chạy ở Terminal hoặc tiến trình khác`,`Running in Terminal or another process`),attention:Q(t,`Cần duyệt`,`Needs approval`),recovery:Q(t,`Cần khôi phục`,`Needs recovery`),failed:Q(t,`Lượt cuối lỗi`,`Last turn failed`),idle:``}[e];return(0,U.jsx)(J,{role:e===`idle`?void 0:`img`,"aria-label":r||void 0,title:r,sx:{width:8,height:8,mt:.9,ml:.75,flexShrink:0,borderRadius:`50%`,bgcolor:n,animation:e===`running`||e===`elsewhere`?`piagent-pulse 1.4s ease-in-out infinite`:`none`}})}var XO={clean:[`Đủ bước`,`All steps`],unverified:[`Chưa verify`,`Unverified`],unreviewed:[`Chưa review`,`Not reviewed`],blocking_open:[`Còn lỗi blocking`,`Blocking open`],review_unavailable:[`Không review được`,`Review unavailable`],interrupted:[`Bị dừng`,`Stopped`],disputed:[`Cần bạn quyết`,`Needs your call`]};function ZO({session:e,live:t,selected:n,locale:r,onSelect:i,onAction:a,showProject:o=!1}){let[s,c]=(0,v.useState)(null),l=e=>{c(null),a(e)},u=e.modelLabel===`agent-watch-auto`,d=JO(e,t),f=d===`running`?Q(r,`Đang chạy`,`Running`):d===`elsewhere`?Q(r,`Đang chạy ở nơi khác`,`Running elsewhere`):d===`attention`?Q(r,`Cần duyệt`,`Needs approval`):null,p=u&&e.managedProcess&&e.managedProcess.outcome!==`no_change`?e.managedProcess.outcome:null;return(0,U.jsxs)(J,{sx:{display:`flex`,alignItems:`center`,pr:.5},children:[(0,U.jsxs)(cf,{selected:n,onClick:i,sx:{minWidth:0,alignItems:`flex-start`,py:1,px:1.4},children:[(0,U.jsx)(Cf,{primary:(0,U.jsxs)(U.Fragment,{children:[e.pinned&&(0,U.jsx)(HO,{sx:{fontSize:13,mr:.5,verticalAlign:`-2px`,color:`text.disabled`}}),e.title]}),secondary:(0,U.jsxs)(U.Fragment,{children:[u&&(0,U.jsxs)(J,{component:`span`,sx:{fontWeight:650,color:`primary.main`},children:[Q(r,`Công ty`,`Company`),(0,U.jsx)(`span`,{children:` · `})]}),f??qO(e.updatedAt,r),o&&(0,U.jsxs)(`span`,{children:[` · `,e.projectLabel]}),p&&(0,U.jsxs)(J,{component:`span`,sx:KD(dO(p)),children:[` · `,Q(r,...XO[p])]})]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13.25,fontWeight:n?600:500}},secondary:{noWrap:!0,sx:{mt:.25,fontSize:11.25}}}}),(0,U.jsx)(YO,{activity:d,locale:r})]}),(0,U.jsx)(Qd,{size:`small`,"aria-label":Q(r,`Tùy chọn cuộc trò chuyện`,`Chat options`),onClick:e=>c(e.currentTarget),children:(0,U.jsx)(VO,{fontSize:`small`})}),(0,U.jsxs)(Eb,{anchorEl:s,open:!!s,onClose:()=>c(null),onClick:e=>e.stopPropagation(),children:[!e.archived&&(0,U.jsx)(bw,{onClick:()=>l(`rename`),children:Q(r,`Đổi tên`,`Rename`)}),!e.archived&&(0,U.jsx)(bw,{onClick:()=>l(`pin`),children:e.pinned?Q(r,`Bỏ ghim`,`Unpin`):Q(r,`Ghim`,`Pin`)}),!e.archived&&(0,U.jsx)(bw,{onClick:()=>l(`fork`),children:Q(r,`Tạo nhánh`,`Fork`)}),(0,U.jsx)(bw,{onClick:()=>l(e.archived?`unarchive`:`archive`),children:e.archived?Q(r,`Bỏ lưu trữ`,`Unarchive`):Q(r,`Lưu trữ`,`Archive`)})]})]})}var QO=5,$O=`piagent.sidebar.collapsed`;function ek(e){try{let t=JSON.parse(window.localStorage.getItem(e)??`[]`);return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`).slice(0,500):[])}catch{return new Set}}function tk(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t].slice(0,500)))}catch{}}function nk({locale:e,canCreate:t,query:n,onQuery:r,groups:i,count:a,selectedRef:o,showArchived:s,archivedCount:c,settingsOpen:l,connection:u,live:d,onNew:f,onSelect:p,onAction:m,onToggleArchived:h,onSettings:g,updateDot:_=!1}){let y=JE(e=>e.breakpoints.down(`md`)),[b,x]=(0,v.useState)(`all`),[S,C]=(0,v.useState)(()=>ek($O)),[w,T]=(0,v.useState)(()=>new Set),E=n.trim().length>0,D=e=>e.modelLabel===`agent-watch-auto`,O=i.flatMap(e=>e.sessions),k={company:O.filter(D).length,personal:O.filter(e=>!D(e)).length},A=(0,v.useMemo)(()=>i.map(e=>({...e,sessions:e.sessions.filter(e=>b===`all`||b===`company`===D(e))})).filter(e=>e.sessions.length>0),[i,b]),j=A.reduce((e,t)=>e+t.sessions.length,0),M=s?[]:A.flatMap(e=>e.sessions).filter(e=>JO(e,d[e.sessionRef])!==`idle`),N=(e,t,n)=>e(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),n&&tk($O,r),r});return(0,U.jsxs)(J,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,bgcolor:`background.paper`},children:[(0,U.jsxs)(up,{sx:{minHeight:`60px !important`,px:`16px !important`,gap:1.1},children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:600},children:`Piagent`}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:Q(e,`Coding agent`,`Coding agent`)})]})]}),(0,U.jsxs)(J,{sx:{px:1.25},children:[(0,U.jsx)(Ah,{title:t?Q(e,`Tạo cuộc trò chuyện mới`,`Create a new chat`):Q(e,`Gateway hiện chưa cho phép tạo cuộc trò chuyện`,`The Gateway cannot create chats right now`),children:(0,U.jsx)(`span`,{children:(0,U.jsx)($,{fullWidth:!0,disabled:!t,variant:`outlined`,onClick:f,startIcon:(0,U.jsx)(qS,{}),sx:{justifyContent:`flex-start`,py:1},children:Q(e,`Cuộc trò chuyện mới`,`New chat`)})})}),(0,U.jsx)(ux,{value:n,onChange:e=>r(e.target.value),fullWidth:!0,size:`small`,placeholder:Q(e,`Tìm cuộc trò chuyện`,`Search chats`),sx:{mt:1.1},slotProps:{input:{startAdornment:(0,U.jsx)(fy,{position:`start`,children:(0,U.jsx)(dx,{fontSize:`small`})})}}})]}),(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,px:2,pt:2,pb:.4},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:600,textTransform:`uppercase`,letterSpacing:`.08em`},children:s?Q(e,`Đã lưu trữ`,`Archived`):Q(e,`Cuộc trò chuyện`,`Chats`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:j})]}),k.company>0&&k.personal>0&&(0,U.jsx)(Z,{direction:`row`,role:`group`,"aria-label":Q(e,`Lọc theo loại`,`Filter by kind`),sx:{px:1.75,pb:.5,gap:.5,flexWrap:`wrap`},children:[`all`,`company`,`personal`].map(t=>(0,U.jsx)(lu,{size:`small`,clickable:!0,"aria-pressed":b===t,onClick:()=>x(t),color:b===t?`primary`:`default`,variant:b===t?`filled`:`outlined`,label:t===`all`?Q(e,`Tất cả`,`All`):t===`company`?Q(e,`Công ty · ${k.company}`,`Company · ${k.company}`):Q(e,`Cá nhân · ${k.personal}`,`Personal · ${k.personal}`)},t))}),(0,U.jsxs)(rf,{component:`div`,sx:{flex:1,minHeight:0,overflowY:`auto`,py:.25},children:[M.length>0&&(0,U.jsxs)(J,{component:`section`,"aria-label":Q(e,`Đang chạy hoặc cần chú ý`,`Running or needing attention`),sx:{mt:.5},children:[(0,U.jsx)(X,{component:`div`,variant:`caption`,color:`text.secondary`,sx:{px:2,py:.55,fontWeight:600},children:Q(e,`Đang chạy · cần chú ý`,`Running · needs attention`)}),M.map(t=>(0,U.jsx)(ZO,{session:t,live:d[t.sessionRef],showProject:!0,selected:o===t.sessionRef,locale:e,onSelect:()=>p(t.sessionRef),onAction:e=>m(t,e)},t.sessionRef)),(0,U.jsx)(Du,{sx:{mx:2,mt:.75}})]}),A.map(t=>{let n=t.sessions.some(e=>e.sessionRef===o),r=E||n||!S.has(t.projectRef),i=E||w.has(t.projectRef),a=i?t.sessions:t.sessions.filter((e,t)=>t<QO||e.sessionRef===o);return(0,U.jsxs)(J,{component:`section`,"aria-label":t.label,sx:{mt:.5},children:[(0,U.jsxs)(tu,{onClick:()=>N(C,t.projectRef,!0),"aria-expanded":r,sx:{width:`100%`,justifyContent:`flex-start`,gap:.7,px:2,py:.55,borderRadius:1},children:[(0,U.jsx)(CT,{sx:{fontSize:16,color:`text.disabled`,transform:r?`none`:`rotate(-90deg)`,transition:`transform .15s`}}),(0,U.jsx)(wT,{sx:{fontSize:15,color:`text.disabled`}}),(0,U.jsx)(X,{component:`div`,variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{flexShrink:1,minWidth:0,fontWeight:600,textAlign:`left`},children:t.label}),(0,U.jsx)(X,{component:`div`,variant:`caption`,color:`text.disabled`,sx:{flex:1,minWidth:0,display:`flex`,textAlign:`left`},children:t.gitBranch&&(0,U.jsx)(KO,{branch:t.gitBranch,locale:e,maxWidth:`100%`})}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:t.sessions.length})]}),r&&a.map(t=>(0,U.jsx)(ZO,{session:t,live:d[t.sessionRef],selected:o===t.sessionRef,locale:e,onSelect:()=>p(t.sessionRef),onAction:e=>m(t,e)},t.sessionRef)),r&&!E&&t.sessions.length>QO&&(0,U.jsx)($,{size:`small`,onClick:()=>N(T,t.projectRef,!1),sx:{ml:1.5,mb:.25,fontSize:12},children:i?Q(e,`Thu gọn`,`Show less`):Q(e,`Xem thêm ${t.sessions.length-QO}`,`Show ${t.sessions.length-QO} more`)})]},t.projectRef)}),j===0&&(0,U.jsxs)(Z,{sx:{alignItems:`center`,textAlign:`center`,px:3,py:5},spacing:1,children:[(0,U.jsx)(BO,{color:`disabled`}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Không tìm thấy cuộc trò chuyện`,`No conversations found`)})]})]}),(0,U.jsxs)(J,{sx:{p:1.25},children:[(0,U.jsx)(Du,{sx:{mb:1}}),(0,U.jsx)($,{fullWidth:!0,startIcon:(0,U.jsx)(zO,{}),disabled:!s&&c===0,onClick:h,sx:{justifyContent:`flex-start`},children:s?Q(e,`Quay lại cuộc trò chuyện`,`Back to chats`):Q(e,`Đã lưu trữ (${c})`,`Archived (${c})`)}),(0,U.jsxs)($,{fullWidth:!0,startIcon:(0,U.jsx)(UO,{}),onClick:g,sx:{justifyContent:`flex-start`,mt:.25},color:l?`primary`:`inherit`,children:[Q(e,`Cài đặt`,`Settings`),_&&(0,U.jsx)(J,{component:`span`,role:`img`,"aria-label":Q(e,`Có bản cập nhật`,`Update available`),sx:{ml:`auto`,width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`}})]}),y&&(0,U.jsxs)(Z,{direction:`row`,sx:{px:1.25,pt:1,alignItems:`center`,gap:1},children:[(0,U.jsx)(J,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:u===`connected`?`success.main`:`warning.main`}}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{flex:1},children:u===`connected`?`Gateway live`:u}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:`local`})]})]})]})}var rk=Y((0,U.jsx)(`path`,{d:`M18 19H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v12c0 .55-.45 1-1 1m1-16H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2`}),`CheckBoxOutlineBlankRounded`),ik=Y((0,U.jsx)(`path`,{d:`M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-8.29 13.29c-.39.39-1.02.39-1.41 0L5.71 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.41z`}),`CheckBoxRounded`),ak=Y((0,U.jsx)(`path`,{d:`m10.8 15.9 4.67-3.5c.27-.2.27-.6 0-.8L10.8 8.1c-.33-.25-.8-.01-.8.4v7c0 .41.47.65.8.4M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8`}),`PlayCircleOutlineRounded`);function ok(e){return Gr(`MuiLinearProgress`,e)}Kr(`MuiLinearProgress`,[`root`,`colorPrimary`,`colorSecondary`,`determinate`,`indeterminate`,`buffer`,`query`,`dashed`,`bar`,`bar1`,`bar2`]);var sk=4,ck={},lk=Dt`
|
|
176
|
+
`,t[0].length);return{text:r<0?``:e.slice(r+2).trimStart(),completionGate:n}}var Jx=new Set([`provider-auth-expired`,`provider-auth-required`,`provider-rate-limited`,`provider-unavailable`,`provider-response-failed`,`assistant-output-incomplete`]);function Yx(e){let t=e.content.reasonCode;return e.role===`assistant`&&e.toolCalls.length===0&&e.content.state===`unavailable`&&t&&(Jx.has(t)||t.startsWith(`company-`))?t:null}function Xx(e){let t=qx(e);return t.completionGate===null&&Gx(t.text)?t.text:null}function Zx(e,t){let n=e?.trim(),r=t.trim();return!!(n&&r&&(n===r||n.startsWith(`/`)&&n.endsWith(` ${r}`)))}function Qx(e,t){if(e.agentOperationId&&t.operationRef&&e.agentOperationId!==t.operationRef)return!1;if(e.messageRequestId&&t.messageRequestId)return e.messageRequestId===t.messageRequestId;if(e.agentOperationId&&t.operationRef)return e.agentOperationId===t.operationRef;let n=Date.parse(e.recordedAt),r=Date.parse(t.startedAt??``);return Number.isFinite(n)&&Number.isFinite(r)&&n>=r}function $x(e,t,n){let r=t.trim();if(!r)return-1;for(let t=e.length-1;t>=0;--t){let i=e[t];if(i?.role===`user`&&Zx(i.content.text,r)&&Qx(i,n))return t}return-1}function eS(e,t,n){return $x(e,t,n)>=0}function tS(e,t,n,r){let i=$x(e,t,r);if(i<0)return!1;let a=Xx(n)?.trim()??``;if(!a)return!0;let o=e[i]?.messageRef??null;for(let t=i+1;t<e.length;t+=1){let n=e[t];if(n?.role===`user`)return!1;if(!(n?.role!==`assistant`&&n?.role!==`custom`||n.toolCalls.length>0)&&!(o&&n.parentMessageRef&&n.parentMessageRef!==o)&&Xx(n.content.text??``)?.trim()===a)return!0}return!1}function nS(e,t,n){let r=$x(e,t,n);if(r<0)return!1;let i=e[r]?.messageRef??null;for(let t=r+1;t<e.length;t+=1){let n=e[t];if(n?.role===`user`)return!1;if(!(n?.role!==`assistant`&&n?.role!==`custom`||n.toolCalls.length>0)&&!(i&&n.parentMessageRef&&n.parentMessageRef!==i)&&(Xx(n.content.text??``)||Yx(n)))return!0}return!1}function rS(e){let t=[],n=new Map,r=new Set,i=null,a=!1,o=null;for(let s of e){if(s.role===`user`){n.clear(),r.add(s.messageRef),i=s.messageRef,t.push(s),a=!1,o=null;continue}if(s.role!==`assistant`&&s.role!==`custom`||(s.parentMessageRef?!r.has(s.parentMessageRef):i===null)||s.toolCalls.length>0)continue;if(Yx(s)){if(a)continue;o?t[t.indexOf(o)]=s:t.push(s),o=s;continue}let e=Xx(s.content.text??``);if(!e)continue;a=!0,o&&=(t.splice(t.indexOf(o),1),null);let c=`${s.role}:${e.trim()}`,l=n.get(c);l===void 0?(n.set(c,t.length),t.push(s)):t[l]=s}return t}function iS(e,t,n){return e===`vi`?t:n}var aS={txt:`text/plain`,text:`text/plain`,md:`text/markdown`,markdown:`text/markdown`,csv:`text/csv`,tsv:`text/tab-separated-values`,json:`application/json`,yaml:`application/yaml`,yml:`application/yaml`,pdf:`application/pdf`,docx:`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,bmp:`image/bmp`},oS=Object.keys(aS).map(e=>`.${e}`).join(`,`),sS=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]);function cS(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024).toFixed(+(e<10240))} KiB`}function lS(e,t){let n=e.truncated?` · ${iS(t,`đã cắt bớt`,`truncated`)}`:``;return e.kind===`image`?`${iS(t,`Ảnh`,`Image`)} · ${cS(e.sizeBytes)}`:e.kind===`document`?`${iS(t,`Tài liệu`,`Document`)} · ${cS(e.sourceBytes)} → ${cS(e.sizeBytes)} ${iS(t,`văn bản`,`text`)}${n}`:`File · ${cS(e.sizeBytes)}${n}`}function uS(e){return[...e,...Object.entries(aS).filter(([,t])=>e.has(t)).map(([e])=>`.${e}`)].join(`,`)}function dS(e){return!!(e&&[...e.types].includes(`Files`))}async function fS(e){let{snapshot:t,locale:n}=e,r=[...e.existing],i=null,a=Math.max(0,4-r.length);e.files.length>a&&(i=iS(n,`Chỉ nhận tối đa 4 file mỗi tin nhắn; đã bỏ qua ${e.files.length-a} file.`,`At most 4 files per message; ${e.files.length-a} skipped.`));for(let o of[...e.files].slice(0,a)){let a=aS[o.name.split(`.`).pop()?.toLowerCase()??``];if(!a){i=`${o.name}: ${iS(n,`loại file chưa được hỗ trợ.`,`unsupported file type.`)}`;continue}if(!e.allowed.has(a)){i=`${o.name}: ${a===`application/pdf`?iS(n,`host chưa cài pdftotext (poppler) nên chưa đọc được .pdf.`,`this host has no pdftotext (poppler), so .pdf cannot be read.`):iS(n,`phiên Pi hiện tại không nhận loại file này.`,`the current Pi session does not accept this file type.`)}`;continue}let s=a.startsWith(`image/`)||sS.has(a)?Math.min(t.capabilities.limits.maxAttachmentFileBytes,8388608):262144;if(o.size<1||o.size>s||r.reduce((e,t)=>e+t.sourceBytes,0)+o.size>t.capabilities.limits.maxAttachmentTotalBytes){i=`${o.name}: ${sS.has(a)?iS(n,`vượt giới hạn gửi trực tiếp ${cS(s)}. Hãy đặt tài liệu lớn trong project rồi mở ở mục Tài liệu; Pi sẽ đọc theo phần thay vì nhét cả file vào chat.`,`exceeds the ${cS(s)} direct-send limit. Put a large document in the project and open Documents; Pi can read it in parts instead of placing the whole file in chat.`):iS(n,`vượt giới hạn đính kèm (tối đa ${cS(s)}).`,`attachment limit exceeded (max ${cS(s)}).`)}`;continue}let c=new Uint8Array(await o.arrayBuffer()),l=``;for(let e=0;e<c.length;e+=32768)l+=String.fromCharCode(...c.subarray(e,e+32768));let u=await e.stage(await q_(t,e.messageRequestId,{displayName:o.name,declaredMimeType:a,dataBase64:btoa(l)}));if(u.resultCode!==`staged`||!(`attachment`in u)||!u.attachment){i=`${o.name}: ${Iv(u.error?.code??u.resultCode,n)}`;continue}r=[...r,u.attachment]}return{attachments:r,status:i}}async function pS(e){let t=await e.stage(J_(e.snapshot,e.messageRequestId,e.attachmentRef));return t.messageType===`discard-receipt`&&t.resultCode===`discarded`?{discarded:!0,status:null}:{discarded:!1,status:`${iS(e.locale,`Chưa thể bỏ file`,`Unable to remove file`)} · ${Iv(t.error?.code??t.resultCode,e.locale)}`}}function mS({snapshot:e,events:t,refreshSnapshot:n}){let{locale:r}=Kv(),[i,a]=(0,v.useState)(),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(()=>`message-request.${crypto.randomUUID()}`),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),k=(0,v.useRef)(0),A=(0,v.useMemo)(()=>Hx(t),[t]),j=[...t].reverse().find(e=>[`message.completed`,`message.failed`,`agent-operation.settled`].includes(String(e.kind)))?.eventCursor??null;(0,v.useEffect)(()=>{let e=new AbortController;return s(!0),a(void 0),b_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0).finally(()=>s(!1)),()=>e.abort()},[e.identity.sessionRef]),(0,v.useEffect)(()=>{w([]),S(`message-request.${crypto.randomUUID()}`)},[e.identity.sessionRef]),(0,v.useEffect)(()=>{let e=e=>{e.dataTransfer&&[...e.dataTransfer.types].includes(`Files`)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]),(0,v.useEffect)(()=>{if(!j)return;let e=new AbortController,t=window.setTimeout(()=>{b_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0)},80);return()=>{window.clearTimeout(t),e.abort()}},[j]);let M=async()=>{try{let e=await x_();return h(e),e}catch{return}};(0,v.useEffect)(()=>{let e=new AbortController;return x_(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[e.identity.sessionRef,e.revision.queueRevision]);let N=async()=>{let e=i?.page.nextBeforeCursor;if(e)try{let t=await b_(e,i.page.limit);a(e=>e?{...e,items:Vx(e.items,t.items),page:t.page}:t)}catch{}},P=(0,v.useMemo)(()=>i?.state===`ready`?rS(i.items):[],[i]),F=e.capabilities.capabilities[`control.chat`],I=F.status===`available`?F.actions:null,L=!!I?.send.available,R=e.capabilities.capabilities[`control.resumeAndContinue`].status===`available`,ee=L||R,te=e.capabilities.capabilities.attachments,z=te.status===`available`,B=(0,v.useMemo)(()=>new Set(te.status===`available`?te.mimeTypes:[]),[te]),V=(0,v.useMemo)(()=>uS(B),[B]),ne=z&&!u&&!T&&C.length<4,re=e.session.operation.liveness===`running`,ie=async()=>{await n?.(),await M()},ae=async t=>{let n=c.trim();if(!(!n||u||(t===`resume-and-continue`?!R:!L))){d(!0),p(null);try{let i=C.length?{messageRequestId:x,attachmentRefs:C.map(e=>e.attachmentRef)}:void 0,a=t===`resume-and-continue`?await O_(await $_(e,n,i)):await T_(await K_(e,n,t,i));[`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(l(``),w([]),S(`message-request.${crypto.randomUUID()}`),p(a.resultCode===`dispatch-observed`?Q(r,`Đã gửi vào Pi session`,`Sent to the Pi session`):Q(r,`Pi đã nhận yêu cầu`,`Pi received the request`))):a.resultCode===`held`?(l(``),p(Q(r,`Đã giữ trong hàng đợi`,`Held in the queue`))):a.resultCode===`resumed-not-dispatched`?p(Q(r,`Task đã mở lại nhưng tin nhắn chưa được gửi; nội dung vẫn được giữ để kiểm tra lại.`,`The task resumed but the message was not sent; the content remains for review.`)):p(`${Q(r,`Chưa gửi`,`Not sent`)} · ${Iv(a.resultCode,r)}`),await ie()}catch{p(Q(r,`Không thể gửi; trạng thái Pi có thể đã thay đổi.`,`Unable to send; Pi state may have changed.`))}finally{d(!1)}}},oe=async t=>{if(!(!t?.length||!z||T)){E(!0),p(null);try{let n=await fS({files:t,snapshot:e,messageRequestId:x,existing:C,allowed:B,locale:r,stage:I_});w(n.attachments),p(n.status)}catch{p(Q(r,`Không thể đính kèm; file không được gửi vào Pi.`,`Unable to attach the file; it was not sent to Pi.`))}finally{E(!1)}}},se=()=>{k.current=0,O(!1)},H=e=>{dS(e.dataTransfer)&&(e.preventDefault(),se(),ne&&oe(e.dataTransfer.files))},ce=async t=>{if(!(u||T)){E(!0),p(null);try{let n=await pS({snapshot:e,messageRequestId:x,attachmentRef:t,locale:r,stage:I_});n.discarded?w(e=>e.filter(e=>e.attachmentRef!==t)):p(n.status)}catch{p(Q(r,`Không thể bỏ file; trạng thái Pi có thể đã thay đổi.`,`Unable to remove the file; Pi state may have changed.`))}finally{E(!1)}}},le=async(t,n,i)=>{if(!u){d(!0),p(null);try{let a=await T_(await Y_(e,t,t===`queue.update`?await X_(n,i?.trim()??``):t===`queue.delete`?{queueItemRef:n}:{queueItemRef:n,messageRequestId:`message-request.${crypto.randomUUID()}`}));[`updated`,`deleted`,`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(_(null),b(``),p(Iv(a.resultCode,r))):p(`${Q(r,`Chưa thay đổi`,`Not changed`)} · ${Iv(a.resultCode,r)}`),await ie()}catch{p(Q(r,`Hàng đợi đã thay đổi; đã tải lại trạng thái mới nhất.`,`The queue changed; the latest state has been reloaded.`)),await ie()}finally{d(!1)}}};return(0,U.jsxs)(`section`,{className:`chat-panel surface`,"aria-labelledby":`chat-heading`,"data-dragging":D||void 0,onDragEnter:e=>{dS(e.dataTransfer)&&(k.current+=1,O(!0))},onDragOver:e=>{dS(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=ne?`copy`:`none`)},onDragLeave:e=>{dS(e.dataTransfer)&&(--k.current,k.current<=0&&se())},onDrop:H,children:[D&&(0,U.jsxs)(`div`,{className:`chat-drop-overlay`,role:`status`,children:[(0,U.jsx)(`strong`,{children:ne?Q(r,`Thả tài liệu vào đây`,`Drop documents here`):C.length>=4?Q(r,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):Q(r,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),ne&&(0,U.jsx)(`small`,{children:Q(r,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),(0,U.jsxs)(`header`,{className:`chat-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Đúng Pi session hiện tại`,`Exact current Pi session`)}),(0,U.jsx)(`h2`,{id:`chat-heading`,children:`Chat`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{children:[P.length,` `,Q(r,`message gần nhất`,`recent messages`)]}),(0,U.jsx)(`span`,{className:`chat-read-state`,children:Q(r,`Streaming trực tiếp`,`Live streaming`)})]})]}),(0,U.jsxs)(`div`,{className:`chat-body`,"aria-live":`polite`,children:[i?.page.hasOlder&&(0,U.jsx)(`button`,{type:`button`,className:`load-older`,onClick:()=>void N(),children:Q(r,`Tải message cũ hơn`,`Load older messages`)}),o&&(0,U.jsx)(`p`,{className:`chat-empty`,children:Q(r,`Đang tải transcript hiện tại…`,`Loading the current transcript…`)}),!o&&i?.state===`unavailable`&&(0,U.jsxs)(`p`,{className:`chat-empty`,children:[Q(r,`Transcript cần đồng bộ lại`,`Transcript needs resync`),` · `,Iv(i.reasonCode,r)]}),!o&&i?.state===`ready`&&P.length===0&&A.assistants.length===0&&(0,U.jsx)(`p`,{className:`chat-empty`,children:Q(r,`Chưa có message trong Pi session này.`,`There are no messages in this Pi session.`)}),P.map(e=>e.role===`tool-result`?(0,U.jsxs)(`article`,{className:`chat-tool-result`,children:[(0,U.jsx)(`strong`,{children:e.toolCalls[0]?.toolName??`Tool`}),(0,U.jsx)(`span`,{children:Q(r,`Kết quả chi tiết nằm trong Activity`,`Detailed output is available in Activity`)})]},e.messageRef):(0,U.jsxs)(`article`,{className:`chat-message chat-${e.role}`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.role===`user`?Q(r,`Anh`,`You`):e.role===`custom`?Q(r,`Biên nhận Piagent`,`Piagent receipt`):`Pi`}),(0,U.jsx)(`time`,{children:new Date(e.recordedAt).toLocaleTimeString(r===`vi`?`vi-VN`:`en-US`,{hour:`2-digit`,minute:`2-digit`})})]}),(0,U.jsx)(`p`,{children:e.content.text||(e.content.imageCount?`${e.content.imageCount} ${Q(r,`ảnh đính kèm`,`attached images`)}`:Q(r,`Message trống`,`Empty message`))}),(e.content.redacted||e.content.truncated)&&(0,U.jsx)(`small`,{children:e.content.redacted?Q(r,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`):Q(r,`Nội dung đã rút gọn`,`Content truncated`)})]},e.messageRef)),A.assistants.map(e=>(0,U.jsxs)(`article`,{className:`chat-message chat-assistant chat-streaming`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:`Pi`}),(0,U.jsx)(`span`,{className:`stream-indicator`,children:Q(r,`Đang trả lời`,`Responding`)})]}),(0,U.jsx)(`p`,{children:e.text||(e.thinking?Q(r,`Đang suy nghĩ…`,`Thinking…`):Q(r,`Đang chuẩn bị câu trả lời…`,`Preparing a response…`))}),e.truncated&&(0,U.jsx)(`small`,{children:Q(r,`Live preview đã đạt giới hạn`,`Live preview limit reached`)})]},e.messageRef)),A.tools.filter(e=>[`started`,`progress`].includes(e.state)).map(e=>(0,U.jsxs)(`article`,{className:`chat-tool-live`,children:[(0,U.jsx)(`span`,{className:`tool-spinner`,"aria-hidden":`true`}),(0,U.jsx)(`strong`,{children:e.toolName}),(0,U.jsx)(`span`,{children:Iv(e.state,r)})]},e.toolCallId))]}),m?.state===`ready`&&m.items.length>0&&(0,U.jsxs)(`section`,{className:`held-queue`,"aria-label":Q(r,`Tin nhắn đang giữ`,`Held messages`),children:[(0,U.jsxs)(`div`,{className:`held-queue-heading`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Đang giữ ${m.heldCount} tin`,`${m.heldCount} held messages`)}),m.quarantinedCount>0&&(0,U.jsxs)(`span`,{children:[m.quarantinedCount,` `,Q(r,`tin cần kiểm tra`,`need review`)]})]}),(0,U.jsx)(`ol`,{children:m.items.map(e=>(0,U.jsxs)(`li`,{"data-state":e.state,children:[g===e.queueItemRef?(0,U.jsx)(`textarea`,{"aria-label":Q(r,`Sửa tin nhắn đang giữ`,`Edit held message`),rows:2,maxLength:65536,value:y,onChange:e=>b(e.target.value)}):(0,U.jsx)(`p`,{children:e.preview}),(0,U.jsx)(`div`,{children:g===e.queueItemRef?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,disabled:u||!y.trim(),onClick:()=>void le(`queue.update`,e.queueItemRef,y),children:Q(r,`Lưu`,`Save`)}),(0,U.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{_(null),b(``)},children:Q(r,`Hủy`,`Cancel`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||!I?.dispatchHeld.available,onClick:()=>void le(`queue.dispatch`,e.queueItemRef),children:Q(r,`Gửi`,`Send`)}),(0,U.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||e.redacted||e.truncated||!I?.editHeld.available,title:e.redacted||e.truncated?Q(r,`Không sửa từ preview đã che hoặc rút gọn`,`Redacted or truncated previews cannot be edited`):void 0,onClick:()=>{_(e.queueItemRef),b(e.preview)},children:Q(r,`Sửa`,`Edit`)}),(0,U.jsx)(`button`,{type:`button`,disabled:u||!I?.deleteHeld.available,onClick:()=>void le(`queue.delete`,e.queueItemRef),children:Q(r,`Xóa`,`Delete`)})]})}),(e.redacted||e.truncated||e.state===`quarantined`)&&(0,U.jsx)(`small`,{children:e.state===`quarantined`?Q(r,`Lần gửi trước chưa xác định; không tự gửi lại`,`The previous dispatch is uncertain; it will not be resent automatically`):e.redacted?Q(r,`Preview đã che dữ liệu nhạy cảm`,`Sensitive data is redacted in the preview`):Q(r,`Preview đã rút gọn`,`Preview truncated`)})]},e.queueItemRef))})]}),(0,U.jsxs)(`footer`,{className:`chat-composer-preview`,children:[C.length>0&&(0,U.jsx)(`ul`,{className:`attachment-list`,"aria-label":Q(r,`File sẽ gửi cùng message`,`Files to send with the message`),children:C.map(e=>(0,U.jsxs)(`li`,{"data-kind":e.kind,children:[(0,U.jsxs)(`span`,{children:[(0,U.jsx)(`strong`,{children:e.displayName}),(0,U.jsx)(`small`,{children:lS(e,r)})]}),(0,U.jsx)(`button`,{type:`button`,disabled:u||T,"aria-label":`${Q(r,`Bỏ`,`Remove`)} ${e.displayName}`,onClick:()=>void ce(e.attachmentRef),children:Q(r,`Bỏ`,`Remove`)})]},e.attachmentRef))}),(0,U.jsx)(`textarea`,{"aria-label":Q(r,`Nội dung chat`,`Chat message`),placeholder:R?Q(r,`Nhập việc cần Pi làm ngay sau khi mở lại task…`,`Enter work for Pi immediately after the task resumes…`):L?Q(r,`Nhắn vào đúng Pi session này…`,`Message this exact Pi session…`):Q(r,`Chat control chưa khả dụng.`,`Chat control is unavailable.`),disabled:!ee||u,maxLength:65536,rows:2,value:c,onChange:e=>l(e.target.value),onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),ne&&oe(e.clipboardData.files))}}),(0,U.jsxs)(`div`,{className:`composer-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:!ee||u||!c.trim(),onClick:()=>void ae(R?`resume-and-continue`:re?`follow-up`:`new-operation`),children:u?Q(r,`Đang gửi…`,`Sending…`):R?Q(r,`Tiếp tục & gửi`,`Resume & send`):re?Q(r,`Gửi sau`,`Send next`):Q(r,`Gửi`,`Send`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!L||u||!c.trim()||C.length>0||!I?.hold.available,title:C.length?Q(r,`Bản này chưa giữ file trong hàng đợi`,`This version does not hold attachments in the queue`):void 0,onClick:()=>void ae(`hold`),children:Q(r,`Giữ lại`,`Hold`)}),re&&(0,U.jsx)(`button`,{type:`button`,className:`interrupt-send`,disabled:!L||u||!c.trim()||!I?.interruptAndSend.available,onClick:()=>void ae(`steer`),children:Q(r,`Ngắt & gửi`,`Interrupt & send`)})]}),(0,U.jsxs)(`label`,{className:`attachment-picker ${ne?``:`disabled`}`,title:Q(r,`Chọn file, hoặc kéo thả / dán thẳng vào khung chat`,`Pick a file, or drag and drop / paste straight into the chat`),children:[(0,U.jsx)(`input`,{type:`file`,multiple:!0,disabled:!ne,accept:V||void 0,onChange:e=>{oe(e.target.files),e.currentTarget.value=``}}),T?Q(r,`Đang đọc tài liệu…`,`Reading documents…`):`${Q(r,`Đính kèm hoặc kéo thả`,`Attach or drop`)} (${C.length}/4)`]}),f&&(0,U.jsx)(`small`,{role:`status`,children:f})]})]})}function hS({snapshot:e,refreshSnapshot:t}){let{locale:n}=Kv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(0),g=(0,v.useRef)({revision:0,modelDirty:!1,thinkingDirty:!1}),_=e.capabilities.capabilities[`control.sessionOptions`],y=_.status===`available`?_.actions:null,b=async e=>{let t=++h.current,n=g.current.revision;try{let r=await S_(e);return t===h.current?(i(r),r.state===`ready`&&n===g.current.revision&&(g.current.modelDirty||o(r.activeModelRef??``),g.current.thinkingDirty||c(r.activeThinkingLevel??`off`)),r):r}catch{!e?.aborted&&t===h.current&&i(void 0);return}};(0,v.useEffect)(()=>{let e=new AbortController;return b(e.signal),()=>e.abort()},[e.identity.sessionRef,e.revision.sessionOptionRevision]);let x=(0,v.useMemo)(()=>r?.models.find(e=>e.modelRef===r.activeModelRef),[r]),S=async i=>{if(!l||d||!r||r.state!==`ready`)return;let o=i===`model`?`session-options.set-model`:`session-options.set-thinking`,c=i===`model`?a:s;f(i),m(null);try{let r=await E_(await Z_(e,o,c));m(r.resultCode===`changed`?Q(n,`Đã cập nhật trong Pi và mặc định người dùng`,`Updated in Pi and user defaults`):r.resultCode===`unchanged`?Q(n,`Giá trị này đang được dùng`,`This value is already active`):r.resultCode===`effect-unknown`?Q(n,`Pi chưa xác nhận được hậu trạng thái; hãy tải lại trước khi thử tiếp`,`Pi could not confirm the resulting state; refresh before trying again`):`${Q(n,`Chưa thay đổi`,`Not changed`)} · ${Iv(r.resultCode,n)}`),u(!1),g.current.revision+=1,i===`model`?g.current.modelDirty=!1:g.current.thinkingDirty=!1,await t?.(),await b()}catch{m(Q(n,`Không thể đổi; trạng thái Pi có thể đã thay đổi.`,`Unable to change the setting; Pi state may have changed.`))}finally{f(null)}};return(0,U.jsxs)(`section`,{className:`session-options surface`,"aria-labelledby":`session-options-title`,children:[(0,U.jsxs)(`div`,{className:`session-options-copy`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Model & thinking`}),(0,U.jsx)(`h2`,{id:`session-options-title`,children:Q(n,`Thiết lập cho Pi session`,`Pi session settings`)}),(0,U.jsx)(`p`,{children:Q(n,`Chỉ thay đổi khi Pi đang chờ. Thao tác này không gọi model, nhưng Pi cũng cập nhật mặc định người dùng.`,`Settings can only change while Pi is idle. This does not call the model, but Pi also updates user defaults.`)})]}),r?.state===`ready`?(0,U.jsxs)(`div`,{className:`session-options-controls`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:`Model`}),(0,U.jsx)(`select`,{"aria-label":Q(n,`Chọn model`,`Select model`),value:a,disabled:d!==null||!y?.setModel.available,onChange:e=>{g.current.revision+=1,g.current.modelDirty=!0,o(e.target.value),u(!1),m(null)},children:r.models.map(e=>(0,U.jsxs)(`option`,{value:e.modelRef,children:[e.displayName,` · `,e.provider]},e.modelRef))})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{children:`Thinking`}),(0,U.jsx)(`select`,{"aria-label":Q(n,`Chọn thinking`,`Select thinking`),value:s,disabled:d!==null||!y?.setThinking.available,onChange:e=>{g.current.revision+=1,g.current.thinkingDirty=!0,c(e.target.value),u(!1),m(null)},children:(x?.supportedThinkingLevels??[]).map(e=>(0,U.jsx)(`option`,{value:e,children:Iv(e,n)},e))})]}),(0,U.jsxs)(`label`,{className:`effect-ack`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:l,disabled:d!==null||!y,onChange:e=>u(e.target.checked)}),(0,U.jsx)(`span`,{children:Q(n,`Tôi hiểu thay đổi này áp dụng cho session và mặc định người dùng.`,`I understand this applies to the session and user defaults.`)})]}),(0,U.jsxs)(`div`,{className:`session-option-actions`,children:[(0,U.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setModel.available||a===r.activeModelRef,onClick:()=>void S(`model`),children:d===`model`?Q(n,`Đang đổi…`,`Changing…`):Q(n,`Đổi model`,`Change model`)}),(0,U.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setThinking.available||s===r.activeThinkingLevel,onClick:()=>void S(`thinking`),children:d===`thinking`?Q(n,`Đang đổi…`,`Changing…`):Q(n,`Đổi thinking`,`Change thinking`)})]}),p&&(0,U.jsx)(`small`,{role:`status`,children:p}),!y?.setModel.available&&(0,U.jsxs)(`small`,{children:[Q(n,`Đang khóa thay đổi`,`Changes locked`),` · `,Iv(y?.setModel.reasonCode??(_.status===`unavailable`?_.reason?.code:`unavailable`),n)]})]}):(0,U.jsxs)(`div`,{className:`session-options-unavailable`,children:[(0,U.jsx)(`strong`,{children:Q(n,`Catalog model chưa sẵn sàng`,`Model catalog unavailable`)}),(0,U.jsx)(`span`,{children:Iv(r?.reasonCode??`authenticated-model-catalog-unavailable`,n)})]})]})}var gS=(e,t,n)=>e===`vi`?t:n,_S={"workspace-patch":[`Sửa trong project`,`Change in the project`],"external-provider-action":[`Tác động ra bên ngoài`,`Reaches outside this machine`]},vS={"one-shell-command":[`Đúng một lệnh`,`This one command`],"network-command-once":[`Đúng một lệnh, có mạng`,`This one command, with network`],"docker-command-once":[`Đúng một lệnh, có mạng và Docker`,`This one command, with network and Docker`],"one-external-action":[`Đúng một hành động`,`This one action`]},yS={"Run this exact command once, after the guard checks the working tree again.":[`Chạy đúng lệnh này một lần, sau khi guard kiểm tra lại thư mục làm việc.`,``],"The command does not run; the agent is told you declined.":[`Lệnh không chạy; agent được báo là bạn đã từ chối.`,``],"Run this exact action once, after the guard checks its authority again.":[`Thực hiện đúng hành động này một lần, sau khi guard kiểm tra lại quyền.`,``],"The action does not run; nothing outside changes.":[`Hành động không chạy; không có gì bên ngoài bị thay đổi.`,``],"Run this exact command once, with internet access.":[`Chạy đúng lệnh này một lần, có mạng.`,``],"Run this exact command once, with internet access; a server it starts accepts connections while it runs.":[`Chạy đúng lệnh này một lần, có mạng; server mà lệnh mở nhận kết nối trong lúc chạy.`,``],"Run this exact command once, with internet access and the Docker engine; a container it starts can read folders Docker shares from this machine and may keep running.":[`Chạy đúng lệnh này một lần, có mạng và Docker; container mà lệnh tạo đọc được các thư mục Docker chia sẻ trên máy và có thể tiếp tục chạy.`,``]},bS=(e,t,n)=>{let r=e[t];return r?gS(n,r[0],r[1]||t):null};function xS(e,t){return t===`vi`?e.split(`; `).map(e=>{let t=e.match(/^Confirmation required: the command runs (.+)$/);if(t)return`Lệnh có ${t[1]} nên cần bạn duyệt trước khi chạy.`;let n=e.match(/^External provider action (.+) requires confirmation$/);return n?`Hành động ra bên ngoài (${n[1]}) cần bạn duyệt.`:e}).join(` `):e}var SS=(e,t)=>bS(_S,e.kind,t)??Iv(e.kind,t),CS=(e,t)=>bS(vS,e.requestedScope,t)??Iv(e.requestedScope,t),wS=(e,t)=>bS(yS,e,t)??e;function TS(e,t){return{schemaVersion:1,version:`piagent-webui-approval-v1`,recordType:`decision`,approvalRef:e.approvalRef,decisionId:`decision.${crypto.randomUUID()}`,decisionToken:e.decisionToken,identity:structuredClone(e.identity),actionDigest:e.action.actionDigest,expectedRevisions:structuredClone(e.expectedRevisions),decision:t,reason:null,decidedAt:new Date().toISOString(),expiresAt:e.expiresAt,decisionSurface:`webui`,executor:`pi-guard`,directExecution:!1}}function ES({state:e,setState:t,refreshSnapshot:n,locale:r}){let i=e.request;if(!i)return(0,U.jsx)(`article`,{className:`approval-card`,children:(0,U.jsx)(`p`,{children:e.error??Q(r,`Đang tải yêu cầu phê duyệt…`,`Loading approval request…`)})});let a=i.action,o=Math.max(0,Math.ceil((Date.parse(i.expiresAt)-Date.now())/1e3)),s=async e=>{t({request:i,deciding:e});try{await w_(TS(i,e)),await n?.()}catch{t({request:i,error:Q(r,`Yêu cầu đã hết hạn, thay đổi hoặc được trả lời ở terminal. Hãy tải trạng thái mới.`,`The request expired, changed, or was answered in the terminal. Refresh status.`)})}};return(0,U.jsxs)(`article`,{className:`approval-card risk-${a.riskClass}`,"aria-labelledby":`approval-${i.approvalRef}`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(r,`Cần phê duyệt`,`Approval required`)}),(0,U.jsx)(`h2`,{id:`approval-${i.approvalRef}`,children:a.toolName})]}),(0,U.jsx)(`span`,{className:`approval-risk`,children:Iv(a.riskClass,r)})]}),(0,U.jsx)(`p`,{className:`approval-reason`,children:xS(a.reason,r)}),a.commandPreview&&(0,U.jsx)(`pre`,{className:`approval-preview`,children:(0,U.jsx)(`code`,{children:a.commandPreview})}),!a.commandPreview&&a.parameterPreview&&a.parameterPreview!==`No additional parameters`&&(0,U.jsx)(`p`,{className:`approval-preview`,children:a.parameterPreview}),(0,U.jsxs)(`dl`,{className:`approval-facts`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Hành động`,`Action`)}),(0,U.jsx)(`dd`,{children:SS(a,r)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Phạm vi`,`Scope`)}),(0,U.jsx)(`dd`,{children:CS(a,r)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Thư mục`,`Directory`)}),(0,U.jsx)(`dd`,{children:a.cwdDisplay??Q(r,`Đã ẩn`,`Hidden`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(r,`Hết hạn`,`Expires`)}),(0,U.jsxs)(`dd`,{children:[o,`s`]})]})]}),a.targetPaths.length>0&&(0,U.jsxs)(`div`,{className:`approval-targets`,children:[(0,U.jsx)(`strong`,{children:Q(r,`Đích tác động`,`Targets`)}),(0,U.jsx)(`ul`,{children:a.targetPaths.map(e=>(0,U.jsx)(`li`,{children:e===`.`?Q(r,`Cả thư mục project`,`The whole project folder`):e},e))})]}),(0,U.jsxs)(`div`,{className:`approval-consequences`,children:[(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:Q(r,`Nếu cho phép:`,`If allowed:`)}),` `,wS(a.consequences.allow,r)]}),(0,U.jsxs)(`p`,{children:[(0,U.jsx)(`strong`,{children:Q(r,`Nếu từ chối:`,`If denied:`)}),` `,wS(a.consequences.deny,r)]})]}),e.error&&(0,U.jsx)(`p`,{className:`form-error`,role:`alert`,children:e.error}),(0,U.jsxs)(`footer`,{children:[(0,U.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!e.deciding,onClick:()=>void s(`deny`),children:Q(r,`Từ chối`,`Deny`)}),(0,U.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:!!e.deciding,onClick:()=>void s(`allow`),children:e.deciding===`allow`?Q(r,`Đang kiểm tra lại…`,`Rechecking…`):Q(r,`Cho phép đúng 1 lần`,`Allow once`)})]})]})}function DS({approvalRefs:e,sessionRef:t,refreshSnapshot:n}){let{locale:r}=Kv(),i=(0,v.useMemo)(()=>e,[e.join(`\0`)]),[a,o]=(0,v.useState)({});return(0,v.useEffect)(()=>{let e=new AbortController;for(let n of i)(t?Jg(t,n,e.signal):C_(n,e.signal)).then(e=>o(t=>({...t,[n]:{request:e}})),()=>o(e=>({...e,[n]:{error:Q(r,`Không thể tải yêu cầu phê duyệt hiện tại.`,`Unable to load the current approval request.`)}})));return()=>e.abort()},[r,t,i]),i.length===0?null:(0,U.jsx)(`section`,{className:`approval-stack`,"aria-label":Q(r,`Yêu cầu phê duyệt đang chờ`,`Pending approval requests`),"aria-live":`polite`,children:i.map(e=>(0,U.jsx)(ES,{state:a[e]??{},setState:t=>o(n=>({...n,[e]:t})),refreshSnapshot:n,locale:r},e))})}function OS({snapshot:e,refreshSnapshot:t}){let n=(0,v.useMemo)(()=>e.approvals.pending.map(e=>e.approvalRef),[e.approvals.pending]);return(0,U.jsx)(DS,{approvalRefs:n,refreshSnapshot:t})}var kS={stopped:`Đã dừng lượt Pi hiện tại; task vẫn được giữ lại.`,"emergency-stop":`Đã dừng lượt Pi hiện tại.`,"stop-requested":`Đang chờ Pi xác nhận lượt hiện tại đã dừng.`,"already-idle":`Pi đang chờ, không có lượt nào cần dừng.`,"pause-requested":`Đang chờ tool hiện tại kết thúc tại điểm an toàn.`,paused:`Task đã tạm dừng an toàn.`,"already-pausing":`Task đang chờ điểm tạm dừng an toàn.`,"already-paused":`Task đang được tạm dừng.`,resumed:`Task đã hoạt động lại; chưa gửi thêm tin nhắn cho model.`,"pause-cancelled":`Đã hủy yêu cầu tạm dừng; chưa gọi model.`,"already-active":`Task đang hoạt động.`,"resume-rejected":`Chưa thể tiếp tục vì bằng chứng khôi phục chưa đủ an toàn.`,"settlement-unknown":`Chưa xác nhận được Pi đã dừng. Hãy xem trạng thái mới trước khi thử lại.`,"pause-unconfirmed":`Chưa đủ bằng chứng để xác nhận task đã tạm dừng.`},AS={stopped:`Stopped the current Pi turn; the task remains intact.`,"emergency-stop":`Stopped the current Pi turn.`,"stop-requested":`Waiting for Pi to confirm the current turn has stopped.`,"already-idle":`Pi is idle; there is no turn to stop.`,"pause-requested":`Waiting for the current tool to finish at a safe point.`,paused:`The task is safely paused.`,"already-pausing":`The task is waiting for a safe pause point.`,"already-paused":`The task is paused.`,resumed:`The task is active again; no model message was sent.`,"pause-cancelled":`Cancelled the pause request; no model call was made.`,"already-active":`The task is active.`,"resume-rejected":`Resume is blocked because recovery evidence is not yet safe.`,"settlement-unknown":`Pi stop is unconfirmed. Refresh status before trying again.`,"pause-unconfirmed":`There is not enough evidence to confirm the task is paused.`};function jS(e,t){return(t===`vi`?kS:AS)[e.resultCode]??(e.error?.message||`${Q(t,`Chưa thực hiện`,`Not executed`)} · ${Iv(e.resultCode,t)}`)}function MS({snapshot:e,refreshSnapshot:t}){let{locale:n}=Kv(),r=e.capabilities.capabilities[`control.lifecycle`],[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=r.status===`available`,l=c?r.currentPhase:`unknown`,u=c?r.stopPhaseSupport[l]:null,d=!!(u?.stop===`supported`&&e.identity.agentOperationId),f=!!(c&&r.actions.pause.available),p=!!(c&&r.actions.resume.available);(0,v.useEffect)(()=>{o?.resultCode===`pause-requested`&&e.session.controlState===`paused`&&s({action:`lifecycle.pause`,resultCode:`paused`,text:(n===`vi`?kS:AS).paused}),o?.resultCode===`stop-requested`&&e.session.operation.liveness===`idle`&&s({action:`lifecycle.stop`,resultCode:`stopped`,text:(n===`vi`?kS:AS).stopped})},[o?.resultCode,n,e.session.controlState,e.session.operation.liveness]);let m=async r=>{if(!i){a(r),s(null);try{let i=await D_(await Q_(e,r));s({action:r,resultCode:i.resultCode,text:jS(i,n)}),await t?.()}catch{s({action:r,resultCode:`request-failed`,text:Q(n,`Trạng thái Pi đã thay đổi hoặc kết nối local bị gián đoạn. Hãy tải trạng thái mới rồi thử lại.`,`Pi state changed or the local connection was interrupted. Refresh status before trying again.`)})}finally{a(null)}}};return(0,U.jsxs)(`section`,{className:`lifecycle-panel surface`,"aria-labelledby":`lifecycle-title`,children:[(0,U.jsxs)(`div`,{className:`lifecycle-copy`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(n,`Điều khiển task`,`Task controls`)}),(0,U.jsx)(`h2`,{id:`lifecycle-title`,children:`Stop, pause & resume`}),(0,U.jsx)(`p`,{children:Q(n,`Stop dừng lượt Pi đang chạy. Pause chờ tool hiện tại kết thúc rồi giữ task. Resume chỉ mở lại task, không tự gọi model. Muốn mở lại và giao việc ngay, dùng “Tiếp tục & gửi” trong Chat.`,`Stop ends the running Pi turn. Pause waits for the current tool to reach a safe point and holds the task. Resume reopens the task without calling the model. Use “Resume & send” in Chat to continue with new work.`)})]}),(0,U.jsxs)(`div`,{className:`lifecycle-state`,children:[(0,U.jsx)(`span`,{children:Q(n,`Trạng thái`,`Status`)}),(0,U.jsx)(`strong`,{children:Iv(e.session.controlState,n)}),(0,U.jsxs)(`small`,{children:[`Pi: `,Iv(e.session.operation.liveness,n),` · phase: `,Iv(l,n)]})]}),(0,U.jsxs)(`div`,{className:`lifecycle-actions`,children:[(0,U.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:i!==null||!d,onClick:()=>void m(`lifecycle.stop`),title:d?void 0:Iv(u?.reasonCode??`no-current-operation`,n),children:i===`lifecycle.stop`?Q(n,`Đang dừng…`,`Stopping…`):Q(n,`Dừng lượt hiện tại`,`Stop current turn`)}),(0,U.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:i!==null||!f,onClick:()=>void m(`lifecycle.pause`),title:!f&&c?Iv(r.actions.pause.reasonCode,n):void 0,children:i===`lifecycle.pause`?Q(n,`Đang yêu cầu…`,`Requesting…`):Q(n,`Tạm dừng task`,`Pause task`)}),(0,U.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:i!==null||!p,onClick:()=>void m(`lifecycle.resume`),title:!p&&c?Iv(r.actions.resume.reasonCode,n):void 0,children:i===`lifecycle.resume`?Q(n,`Đang mở lại…`,`Resuming…`):Q(n,`Tiếp tục task`,`Resume task`)})]}),o&&(0,U.jsx)(`p`,{className:`lifecycle-result result-${o.resultCode===`request-failed`||o.resultCode.includes(`unknown`)||o.resultCode.includes(`unconfirmed`)||o.resultCode===`resume-rejected`?`warning`:`ok`}`,role:`status`,children:o.text}),!c&&(0,U.jsxs)(`p`,{className:`lifecycle-result result-warning`,children:[Q(n,`Điều khiển chưa sẵn sàng`,`Controls unavailable`),` · `,Iv(r.reason?.code,n)]})]})}function NS(e,t){try{return new Intl.DateTimeFormat(t===`vi`?`vi-VN`:`en-US`,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e))}catch{return e}}function PS({value:e,locale:t}){return(0,U.jsxs)(`span`,{className:`status-pill tone-${Lv(e)}`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Iv(e,t)]})}function FS({snapshot:e}){let{locale:t}=Kv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),[o,s]=(0,v.useState)(`all`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(),[f,p]=(0,v.useState)(`idle`),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(`idle`),[y,b]=(0,v.useState)(),[x,S]=(0,v.useState)(`idle`),[C,w]=(0,v.useState)(),[T,E]=(0,v.useState)(`idle`);(0,v.useEffect)(()=>{let e=new AbortController;return a(`loading`),p_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`),l(e=>e&&t.runs.some(t=>t.runRef===e)?e:t.activeRunRef??t.runs[0]?.runRef??null))}).catch(()=>{e.signal.aborted||a(`error`)}),()=>e.abort()},[e.revision.taskRevision,e.revision.eventCursor]);let D=(0,v.useMemo)(()=>(n?.runs??[]).filter(e=>o===`all`||o===`current`&&e.isCurrentSession||o===`terminal`&&e.terminal),[n,o]);return(0,v.useEffect)(()=>{if(!c){d(void 0),p(`idle`);return}let e=new AbortController;return p(`loading`),m_(c,e.signal).then(t=>{e.signal.aborted||(d(t),p(`ready`))}).catch(()=>{e.signal.aborted||p(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){b(void 0),S(`idle`);return}let e=new AbortController;return S(`loading`),g_(c,e.signal).then(t=>{e.signal.aborted||(b(t),S(`ready`))}).catch(()=>{e.signal.aborted||S(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){h(void 0),_(`idle`);return}let e=new AbortController;return _(`loading`),h_(c,e.signal).then(t=>{e.signal.aborted||(h(t),_(`ready`))}).catch(()=>{e.signal.aborted||_(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){w(void 0),E(`idle`);return}let e=new AbortController;return E(`loading`),__(c,e.signal).then(t=>{e.signal.aborted||(w(t),E(`ready`))}).catch(()=>{e.signal.aborted||E(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,U.jsxs)(`section`,{className:`task-run-index surface`,"aria-labelledby":`task-run-index-title`,children:[(0,U.jsxs)(`header`,{className:`source-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Long-task dashboard`}),(0,U.jsx)(`h2`,{id:`task-run-index-title`,children:Q(t,`Task và các lần chạy gần đây`,`Tasks and recent runs`)})]}),(0,U.jsxs)(`span`,{children:[n?.page.total??0,` `,Q(t,`run từ local state`,`runs from local state`)]})]}),(0,U.jsx)(`div`,{className:`task-index-controls`,role:`group`,"aria-label":Q(t,`Lọc task run`,`Filter task runs`),children:[[`all`,Q(t,`Tất cả`,`All`)],[`current`,Q(t,`Session này`,`This session`)],[`terminal`,Q(t,`Đã kết thúc`,`Finished`)]].map(([e,t])=>(0,U.jsx)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>s(e),children:t},e))}),i===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang đọc task state bền vững…`,`Reading durable task state…`)}),(i===`error`||n?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Task history chưa sẵn sàng; Pi session hiện tại không bị ảnh hưởng.`,`Task history is unavailable; the current Pi session is unaffected.`)}),i===`ready`&&n?.state===`ready`&&(0,U.jsxs)(`div`,{className:`task-run-list`,children:[D.map(e=>(0,U.jsxs)(`article`,{className:`task-run-card`,"data-active":e.isActive,"data-selected":e.runRef===c,children:[(0,U.jsxs)(`div`,{className:`task-run-main`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.summary||e.taskId}),e.isActive&&(0,U.jsx)(`span`,{className:`active-run-tag`,children:Q(t,`Đang hoạt động`,`Active`)})]}),(0,U.jsxs)(`small`,{children:[e.taskId,` · `,Q(t,`lần`,`attempt`),` `,e.attempt,`/`,e.maxAttempts,` · `,Q(t,`cập nhật`,`updated`),` `,NS(e.updatedAt,t)]})]}),(0,U.jsxs)(`div`,{className:`task-run-meta`,children:[(0,U.jsx)(PS,{value:e.outcome,locale:t}),(0,U.jsx)(`span`,{children:e.progress.total?`${e.progress.completed}/${e.progress.total} ${Q(t,`bước`,`steps`)}`:Q(t,`Chưa có work plan`,`No work plan`)}),(0,U.jsx)(`span`,{children:e.sessionLabel??(e.isCurrentSession?Q(t,`Session hiện tại`,`Current session`):Q(t,`Session khác`,`Other session`))}),(0,U.jsx)(`button`,{type:`button`,"aria-pressed":e.runRef===c,onClick:()=>l(e.runRef),children:Q(t,`Xem timeline`,`View timeline`)})]})]},e.runRef)),D.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Không có task run trong bộ lọc này.`,`No task runs match this filter.`)})]}),n?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n?.page.truncated&&(0,U.jsxs)(`p`,{className:`task-index-warning`,children:[Q(t,`Danh sách đã rút gọn;`,`The list is truncated;`),` `,n.page.total-n.page.returned,` `,Q(t,`run cũ chưa hiển thị.`,`older runs are not shown.`)]}),(0,U.jsxs)(`section`,{className:`task-timeline`,"aria-labelledby":`task-timeline-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Recovery timeline`}),(0,U.jsx)(`h3`,{id:`task-timeline-title`,children:Q(t,`Crash, resume, pause và checkpoint`,`Crash, resume, pause, and checkpoints`)})]}),u?.state===`ready`&&(0,U.jsx)(PS,{value:u.continuity.recoveryDecision,locale:t})]}),f===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem timeline.`,`Select a run to view its timeline.`)}),f===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh chuỗi Task Journal…`,`Verifying the Task Journal chain…`)}),(f===`error`||u?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Timeline không đủ bằng chứng tin cậy; task hiện tại không bị ảnh hưởng.`,`The timeline lacks trustworthy evidence; the current task is unaffected.`)}),f===`ready`&&u?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`timeline-continuity`,children:[(0,U.jsxs)(`span`,{children:[`Crash evidence: `,(0,U.jsx)(`strong`,{children:Iv(u.continuity.crashEvidence,t)})]}),(0,U.jsxs)(`span`,{children:[`Recovery: `,(0,U.jsx)(`strong`,{children:Iv(u.continuity.recoveryDecision,t)})]})]}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:u.events.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Lv(e.state)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.title}),(0,U.jsxs)(`small`,{children:[`#`,e.sequence,` · `,NS(e.recordedAt,t)]}),e.detail&&(0,U.jsx)(`p`,{children:e.detail})]}),(0,U.jsx)(PS,{value:e.state,locale:t})]},e.eventRef))}),u.events.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Run này chưa có fact timeline bền vững.`,`This run has no durable timeline facts.`)})]}),u?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,U.jsxs)(`section`,{className:`task-timeline recovery-history`,"aria-labelledby":`recovery-history-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Compaction & recovery`}),(0,U.jsx)(`h3`,{id:`recovery-history-title`,children:Q(t,`Lịch sử rút gọn và phục hồi`,`Compaction and recovery history`)})]}),m?.state===`ready`&&(0,U.jsx)(PS,{value:m.completeness,locale:t})]}),g===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem lịch sử rút gọn.`,`Select a run to view compaction history.`)}),g===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang đọc metadata compaction an toàn…`,`Reading safe compaction metadata…`)}),(g===`error`||m?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Lịch sử compaction chưa đủ bằng chứng tin cậy; task hiện tại không bị ảnh hưởng.`,`Compaction history lacks trustworthy evidence; the current task is unaffected.`)}),g===`ready`&&m?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`timeline-continuity recovery-summary`,children:[(0,U.jsxs)(`span`,{children:[`Context compact: `,(0,U.jsx)(`strong`,{children:m.summary.contextCompactions})]}),(0,U.jsxs)(`span`,{children:[`Tool result: `,(0,U.jsx)(`strong`,{children:m.summary.toolResultCompactions})]}),(0,U.jsxs)(`span`,{children:[`Recovery: `,(0,U.jsx)(`strong`,{children:Iv(m.recovery.decision,t)})]}),(0,U.jsxs)(`span`,{children:[`Verifier: `,(0,U.jsx)(`strong`,{children:Iv(m.recovery.verifierState,t)})]})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Nội dung capture được giữ trong private runtime state và không gửi vào trình duyệt.`,`Captured content stays in private runtime state and is not sent to the browser.`)}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:m.events.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Lv(e.kind)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.title}),(0,U.jsxs)(`small`,{children:[`#`,e.sequence,` · `,NS(e.recordedAt,t)]}),e.kind===`tool-result-compaction`&&(0,U.jsxs)(`p`,{children:[e.toolName,` · `,e.originalLines??`?`,` `,Q(t,`dòng`,`lines`),` · `,e.captureCount,` capture`]}),e.detail&&(0,U.jsx)(`p`,{children:e.detail})]}),(0,U.jsx)(PS,{value:`observed`,locale:t})]},e.eventRef))}),m.events.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Run này chưa có metadata compaction đã quan sát.`,`This run has no observed compaction metadata.`)})]}),m?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,U.jsxs)(`section`,{className:`task-timeline handoff-history`,"aria-labelledby":`handoff-history-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Handoff`}),(0,U.jsx)(`h3`,{id:`handoff-history-title`,children:Q(t,`Bàn giao và việc cần làm tiếp theo`,`Handoff and next work`)})]}),y?.state===`ready`&&(0,U.jsx)(PS,{value:y.completeness,locale:t})]}),x===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem handoff.`,`Select a run to view its handoff.`)}),x===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh handoff và next action…`,`Verifying the handoff and next action…`)}),(x===`error`||y?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Handoff không đủ bằng chứng tin cậy; WebUI không đề xuất hành động.`,`The handoff lacks trustworthy evidence; WebUI will not suggest an action.`)}),x===`ready`&&y?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`next-action-card`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:Q(t,`Việc tiếp theo`,`Next work`)}),(0,U.jsx)(`strong`,{children:Iv(y.nextAction.action,t)})]}),(0,U.jsx)(`p`,{children:y.nextAction.reason}),(0,U.jsxs)(`small`,{children:[y.nextAction.exactCommandCount,` verifier command · `,Q(t,`chỉ xem, không tự chạy`,`read-only, never auto-run`)]})]}),y.current&&(0,U.jsxs)(`div`,{className:`timeline-continuity handoff-summary`,children:[(0,U.jsxs)(`span`,{children:[`Outcome: `,(0,U.jsx)(`strong`,{children:Iv(y.current.taskOutcome,t)})]}),(0,U.jsxs)(`span`,{children:[`Gate: `,(0,U.jsx)(`strong`,{children:Iv(y.current.gateDecision,t)})]}),(0,U.jsxs)(`span`,{children:[`Authority: `,(0,U.jsx)(`strong`,{children:Iv(y.current.requiredAuthority,t)})]}),(0,U.jsxs)(`span`,{children:[`Tree evidence: `,(0,U.jsx)(`strong`,{children:y.current.treeEvidenceCurrent?`current`:`not current`})]})]}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:y.events.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Lv(e.completionApproved?`completed`:`handoff`)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:Q(t,`Handoff projection đã được ghi`,`Handoff projection recorded`)}),(0,U.jsxs)(`small`,{children:[`#`,e.sequence,` · `,NS(e.recordedAt,t)]}),(0,U.jsxs)(`p`,{children:[e.phase??`unknown`,` · `,Iv(e.projectedAction,t)]})]}),(0,U.jsx)(PS,{value:e.completionApproved?`completed`:`observed`,locale:t})]},e.eventRef))}),!y.current&&y.events.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Run này chưa có handoff đã quan sát.`,`This run has no observed handoff.`)})]}),y?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,U.jsxs)(`section`,{className:`task-timeline subagent-tree`,"aria-labelledby":`subagent-tree-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Helper / subagent tree`}),(0,U.jsx)(`h3`,{id:`subagent-tree-title`,children:Q(t,`Quyền sở hữu và vòng đời helper`,`Helper ownership and lifecycle`)})]}),C?.state===`ready`&&(0,U.jsx)(PS,{value:C.evidenceState,locale:t})]}),T===`idle`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chọn một run để xem helper/subagent.`,`Select a run to view helpers and subagents.`)}),T===`loading`&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh helper ledger bền vững…`,`Verifying the durable helper ledger…`)}),(T===`error`||C?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Helper ledger không đủ tin cậy; WebUI không suy đoán cây subagent.`,`The helper ledger lacks trustworthy evidence; WebUI will not infer a subagent tree.`)}),T===`ready`&&C?.state===`ready`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`next-action-card`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{children:Q(t,`Quyết định điều phối`,`Delegation decision`)}),(0,U.jsx)(`strong`,{children:C.delegation.action===`dispatch`?Q(t,`Gửi 1 helper chỉ đọc`,`Dispatch one read-only helper`):Q(t,`Parent tự làm`,`Parent works directly`)})]}),(0,U.jsx)(`p`,{children:C.delegation.reasonCodes.map(e=>Iv(e,t)).join(` · `)}),(0,U.jsxs)(`small`,{children:[Q(t,`Tiết kiệm token dự kiến`,`Projected net token saving`),`: `,C.delegation.projectedNetSavingsRatio===null?Q(t,`chưa được chứng minh`,`not proven`):`${Math.round(C.delegation.projectedNetSavingsRatio*100)}%`,` · `,Q(t,`ngưỡng`,`threshold`),` `,Math.round(C.delegation.minimumRequiredNetSavingsRatio*100),`% · `,Q(t,`tối đa 1 helper, 0 retry, 0 writer`,`max 1 helper, 0 retries, 0 writers`)]})]}),(0,U.jsxs)(`div`,{className:`timeline-continuity subagent-summary`,children:[(0,U.jsxs)(`span`,{children:[Q(t,`Tổng helper`,`Total helpers`),`: `,(0,U.jsx)(`strong`,{children:C.summary.total})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Đang chạy`,`Running`),`: `,(0,U.jsx)(`strong`,{children:C.summary.active})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Kết quả stale`,`Stale results`),`: `,(0,U.jsx)(`strong`,{children:C.summary.staleResults})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Writer hiện tại`,`Current writer`),`: `,(0,U.jsx)(`strong`,{children:Iv(C.writer.state,t)})]})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Prompt, output, model và session ID của helper không được gửi vào trình duyệt.`,`Helper prompts, outputs, models, and session IDs are not sent to the browser.`)}),(0,U.jsx)(`ol`,{className:`timeline-events`,children:C.children.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(`span`,{className:`timeline-dot tone-${Lv(e.lifecycleState)}`,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`strong`,{children:[Iv(e.role,t),` · `,Iv(e.authority,t)]}),(0,U.jsxs)(`small`,{children:[NS(e.reservedAt,t),` → `,e.completedAt?NS(e.completedAt,t):Q(t,`đang giữ lease`,`lease active`)]}),(0,U.jsxs)(`p`,{children:[e.result.disposition?Iv(e.result.disposition,t):Q(t,`Chưa có result evidence`,`No result evidence`),e.result.calls===null?``:` · ${e.result.calls} calls · ${e.result.tokens??0} tokens`]})]}),(0,U.jsx)(PS,{value:e.result.state===`not-recorded`?e.lifecycleState:e.result.state,locale:t})]},e.nodeRef))}),C.children.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Không có lifecycle helper chi tiết cho run này.`,`No detailed helper lifecycle is available for this run.`)}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Cây lồng nhiều tầng: chưa có durable lineage; WebUI chỉ hiển thị quan hệ task cha → helper trực tiếp.`,`Nested trees: durable lineage is not yet available, so WebUI only shows parent task → direct helper relationships.`)})]}),C?.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]})]})}function IS(e,t){if(!e)return Q(t,`Chưa có`,`Not available`);try{return new Intl.DateTimeFormat(t===`vi`?`vi-VN`:`en-US`,{dateStyle:`short`,timeStyle:`short`}).format(new Date(e))}catch{return e}}function LS({value:e,locale:t}){return(0,U.jsxs)(`span`,{className:`status-pill tone-${Lv(e)}`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Iv(e,t)]})}function RS({snapshot:e}){let{locale:t}=Kv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{o.current?.abort();let e=new AbortController;o.current=e,a(`loading`),v_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`))}).catch(()=>{e.signal.aborted||a(`error`)})},[]);return(0,v.useEffect)(()=>(s(),()=>o.current?.abort()),[s,e.identity.projectRef,e.identity.runtimeInstanceId]),(0,U.jsxs)(`section`,{className:`release-monitor surface`,"aria-labelledby":`release-monitor-title`,children:[(0,U.jsxs)(`header`,{className:`source-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Benchmark & release`}),(0,U.jsx)(`h2`,{id:`release-monitor-title`,children:Q(t,`Theo dõi chất lượng và mức sẵn sàng phát hành`,`Quality and release readiness`)})]}),(0,U.jsx)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,children:i===`loading`?Q(t,`Đang đọc…`,`Loading…`):Q(t,`Làm mới`,`Refresh`)})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Màn hình chỉ đọc bằng chứng local; không tự chạy benchmark, resume, commit, tag, publish hay push.`,`This screen only reads local evidence; it never runs benchmarks, resumes, commits, tags, publishes, or pushes.`)}),(i===`error`||n?.state===`unavailable`)&&(0,U.jsx)(`p`,{className:`task-index-empty error-state`,children:Q(t,`Bằng chứng benchmark/release chưa sẵn sàng; Pi session hiện tại không bị ảnh hưởng.`,`Benchmark and release evidence is unavailable; the current Pi session is unaffected.`)}),i===`loading`&&!n&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Đang xác minh report, manifest và ledger…`,`Verifying reports, manifests, and ledgers…`)}),n&&(0,U.jsxs)(`div`,{className:`release-monitor-grid`,children:[(0,U.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`benchmark-monitor-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Benchmark runs`}),(0,U.jsx)(`h3`,{id:`benchmark-monitor-title`,children:Q(t,`Các lần đo gần đây`,`Recent runs`)})]}),(0,U.jsx)(LS,{value:n.benchmark.state,locale:t})]}),n.benchmark.runs.map(e=>(0,U.jsxs)(`article`,{className:`benchmark-run-card`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`strong`,{children:e.suiteId}),(0,U.jsx)(LS,{value:e.lifecycle,locale:t})]}),(0,U.jsxs)(`small`,{children:[IS(e.updatedAt,t),` · `,e.completedRuns,`/`,e.expectedRuns,` `,Q(t,`lượt`,`runs`),` · `,Q(t,`nguồn`,`source`),` `,Iv(e.sourceState,t)]}),(0,U.jsxs)(`div`,{className:`benchmark-run-facts`,children:[(0,U.jsxs)(`span`,{children:[`Gate `,(0,U.jsx)(`b`,{children:Iv(e.releaseGate,t)})]}),(0,U.jsxs)(`span`,{children:[Q(t,`Điểm`,`Score`),` `,(0,U.jsx)(`b`,{children:e.scores.overall??`—`})]}),(0,U.jsxs)(`span`,{children:[`Claim `,(0,U.jsx)(`b`,{children:Iv(e.claimTier,t)})]})]})]},e.runRef)),n.benchmark.runs.length===0&&(0,U.jsx)(`p`,{className:`task-index-empty`,children:Q(t,`Chưa có run thuộc repo hiện tại với bằng chứng đủ tin cậy.`,`No trustworthy runs are available for the current repository.`)}),n.benchmark.warnings.map(e=>(0,U.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n.benchmark.page.truncated&&(0,U.jsx)(`p`,{className:`task-index-warning`,children:Q(t,`Danh sách được giới hạn để giữ WebUI nhẹ và ổn định.`,`The list is bounded to keep WebUI fast and stable.`)})]}),(0,U.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`release-readiness-title`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Release readiness`}),(0,U.jsx)(`h3`,{id:`release-readiness-title`,children:Q(t,`RC hiện tại`,`Current RC`)})]}),(0,U.jsx)(LS,{value:n.release.state,locale:t})]}),(0,U.jsxs)(`dl`,{className:`release-readiness-facts`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Local safe gate`}),(0,U.jsx)(`dd`,{children:(0,U.jsx)(LS,{value:n.release.localSafeGate,locale:t})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`RC assembly`}),(0,U.jsx)(`dd`,{children:Iv(n.release.rcAssembly,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Beta`}),(0,U.jsx)(`dd`,{children:Iv(n.release.beta,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`GA`}),(0,U.jsx)(`dd`,{children:Iv(n.release.gaRelease,t)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:Q(t,`Báo cáo`,`Report`)}),(0,U.jsx)(`dd`,{children:IS(n.release.generatedAt,t)})]})]}),n.release.sourceState===`stale`&&(0,U.jsx)(`p`,{className:`task-index-warning`,children:Q(t,`Báo cáo RC thuộc phiên bản source cũ; không dùng để xác nhận tree hiện tại.`,`The RC report belongs to an older source revision and cannot validate the current tree.`)}),n.release.blockers.length>0&&(0,U.jsxs)(`div`,{className:`release-blockers`,children:[(0,U.jsxs)(`strong`,{children:[n.release.blockerCount,` blocker`]}),(0,U.jsx)(`ul`,{children:n.release.blockers.map((e,t)=>(0,U.jsx)(`li`,{children:e},`${t}-${e}`))})]}),(0,U.jsx)(`p`,{className:`retained-content-note`,children:Q(t,`Mọi quyền phát hành đều tắt. Việc phát hành vẫn cần operator phê duyệt ngoài màn hình này.`,`All release authority is disabled. Release still requires operator approval outside this screen.`)})]})]})]})}var zS=264,BS={overview:{vi:[`Tổng quan`,`Task contract, tiến độ và bằng chứng hoàn thành`],en:[`Overview`,`Task contract, progress, and completion evidence`]},chat:{vi:[`Chat & điều khiển`,`Đúng Pi session hiện tại, không tạo runtime thứ hai`],en:[`Chat & controls`,`The exact current Pi session, without a second runtime`]},documents:{vi:[`Tài liệu`,`Mở .md, .docx, .pdf, .csv trong project và thư mục đã cấp quyền`],en:[`Documents`,`Open .md, .docx, .pdf, and .csv from the project and granted directories`]},source:{vi:[`Source Changes`,`Review thay đổi theo task baseline, working tree và staged`],en:[`Source Changes`,`Review task baseline, working tree, and staged changes`]},activity:{vi:[`Activity`,`Tool call, command, verifier và log preview`],en:[`Activity`,`Tool calls, commands, verifiers, and bounded log previews`]},history:{vi:[`Lịch sử task`,`Crash, resume, checkpoint, handoff và helper`],en:[`Task history`,`Crash, resume, checkpoints, handoffs, and helpers`]},release:{vi:[`Release`,`Benchmark evidence và mức sẵn sàng phát hành`],en:[`Release`,`Benchmark evidence and release readiness`]}};function VS({value:e,text:t,locale:n=`vi`}){return(0,U.jsxs)(`span`,{className:`status-pill tone-${Lv(e)}`,children:[(0,U.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),t??Iv(e,n)]})}function HS({locale:e}){return(0,U.jsxs)(`section`,{className:`task-empty surface`,"aria-labelledby":`task-title`,children:[(0,U.jsx)(`div`,{className:`empty-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,U.jsx)(`h2`,{id:`task-title`,children:Q(e,`Chưa có task đang chạy`,`No active task`)}),(0,U.jsx)(`p`,{children:Q(e,`WebUI đang theo dõi đúng Pi session. Khi task bắt đầu, mục tiêu, tiêu chí và tiến độ sẽ xuất hiện tại đây.`,`WebUI is observing the exact Pi session. Objectives, criteria, and progress will appear here when a task begins.`)})]})]})}function US({snapshot:e,locale:t}){let n=e.task;if(!n)return(0,U.jsx)(HS,{locale:t});let r=Uv(e,t);return(0,U.jsxs)(`section`,{className:`task-dashboard surface`,"aria-labelledby":`task-title`,children:[(0,U.jsxs)(`header`,{className:`task-heading`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(t,`Task hiện tại`,`Current task`)}),(0,U.jsx)(`h2`,{id:`task-title`,children:n.summary}),(0,U.jsxs)(`div`,{className:`task-meta`,children:[(0,U.jsx)(VS,{value:n.outcome,locale:t}),(0,U.jsx)(`span`,{children:Iv(n.changeMode,t)}),(0,U.jsx)(`span`,{children:Iv(n.riskLane,t)})]})]}),(0,U.jsxs)(`div`,{className:`progress-number`,"aria-label":`${Q(t,`Tiến độ`,`Progress`)} ${r.percent}%`,children:[(0,U.jsxs)(`strong`,{children:[r.percent,`%`]}),(0,U.jsx)(`span`,{children:r.text})]})]}),(0,U.jsx)(`div`,{className:`progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.percent,"aria-label":Q(t,`Tiến độ tiêu chí`,`Criteria progress`),children:(0,U.jsx)(`span`,{style:{width:`${r.percent}%`}})}),n.blocker&&(0,U.jsxs)(`div`,{className:`blocker`,role:`status`,children:[(0,U.jsx)(`span`,{children:`Blocker`}),(0,U.jsx)(`p`,{children:n.blocker})]}),(0,U.jsxs)(`div`,{className:`criteria-heading`,children:[(0,U.jsx)(`h2`,{children:Q(t,`Tiêu chí hoàn thành`,`Completion criteria`)}),(0,U.jsxs)(`span`,{children:[n.criteria.length,` `,Q(t,`tiêu chí`,`criteria`)]})]}),(0,U.jsx)(`ol`,{className:`criteria-list`,children:n.criteria.map((e,n)=>(0,U.jsxs)(`li`,{className:`criterion-card`,children:[(0,U.jsx)(`span`,{className:`criterion-index tone-${Lv(e.state)}`,children:String(n+1).padStart(2,`0`)}),(0,U.jsxs)(`div`,{className:`criterion-copy`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{children:e.obligation}),e.priority===`critical`&&(0,U.jsx)(`span`,{className:`critical-tag`,children:Q(t,`Quan trọng`,`Critical`)})]}),(0,U.jsx)(`small`,{children:Hv(e,t)})]}),(0,U.jsx)(VS,{value:e.state,locale:t})]},e.criterionId))}),n.workPlan.length>0&&(0,U.jsxs)(`details`,{className:`work-plan`,children:[(0,U.jsxs)(`summary`,{children:[Q(t,`Kế hoạch thực hiện`,`Work plan`),` · `,n.workPlan.length,` `,Q(t,`bước`,`steps`)]}),(0,U.jsx)(`ol`,{children:n.workPlan.map(e=>(0,U.jsxs)(`li`,{children:[(0,U.jsx)(VS,{value:e.status,locale:t}),(0,U.jsx)(`span`,{children:e.summary})]},e.stepId))})]})]})}function WS({snapshot:e,locale:t}){return(0,U.jsxs)(`aside`,{className:`context-rail`,"aria-label":Q(t,`Tóm tắt phiên`,`Session summary`),children:[(0,U.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,U.jsxs)(`dl`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Task ID`}),(0,U.jsx)(`dd`,{title:e.identity.taskId??void 0,children:Rv(e.identity.taskId)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Run ID`}),(0,U.jsx)(`dd`,{title:e.identity.taskRunId??void 0,children:Rv(e.identity.taskRunId)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Verifier`}),(0,U.jsx)(`dd`,{children:(0,U.jsx)(VS,{value:e.verification.state,locale:t})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`dt`,{children:`Queue`}),(0,U.jsx)(`dd`,{children:e.session.queue.state===`known`?`${e.session.queue.heldCount??0} ${Q(t,`đang giữ`,`held`)}`:Iv(e.session.queue.state,t)})]})]})]}),(0,U.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(t,`Sức khỏe`,`Health`)}),(0,U.jsxs)(`div`,{className:`health-line`,children:[(0,U.jsx)(VS,{value:e.health.state,locale:t}),(0,U.jsxs)(`span`,{children:[e.health.issues.length,` `,Q(t,`lưu ý`,`issues`)]})]}),e.health.issues.slice(0,3).map(e=>(0,U.jsx)(`p`,{className:`health-issue`,children:e.message},e.issueRef))]})]})}function GS({snapshot:e,locale:t}){let n=[[`Runtime`,(0,U.jsx)(VS,{value:e.session.operation.liveness,locale:t})],[`Task`,(0,U.jsx)(VS,{value:e.session.controlState,locale:t})],[`Model`,(0,U.jsx)(`strong`,{children:zv(e,t)})],[`Thinking`,(0,U.jsx)(`strong`,{children:Bv(e,t)})],[Q(t,`Quyền`,`Permission`),(0,U.jsx)(`strong`,{children:Vv(e,t)})],[`Approval`,(0,U.jsx)(VS,{value:e.session.approvalState,locale:t})]];return(0,U.jsx)(Pc,{variant:`outlined`,className:`runtime-overview`,"aria-label":Q(t,`Trạng thái Pi session`,`Pi session status`),sx:{display:`grid`,gridTemplateColumns:{xs:`repeat(2, minmax(0,1fr))`,sm:`repeat(3, minmax(0,1fr))`,xl:`repeat(6, minmax(0,1fr))`},overflow:`hidden`},children:n.map(([e,t])=>(0,U.jsxs)(J,{sx:{minWidth:0,minHeight:72,px:2,py:1.5,display:`flex`,flexDirection:`column`,justifyContent:`center`,gap:.75,borderRight:1,borderBottom:{xs:1,xl:0},borderColor:`divider`,"&:last-child":{borderRight:0}},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:800,letterSpacing:`.11em`,textTransform:`uppercase`},children:e}),t]},e))})}function KS({active:e,snapshot:t,events:n,refreshSnapshot:r,locale:i}){return e===`overview`?(0,U.jsxs)(Z,{className:`workspace-stack`,spacing:2.25,children:[(0,U.jsx)(GS,{snapshot:t,locale:i}),(0,U.jsxs)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`minmax(0,1fr) 300px`},alignItems:`start`,gap:2.25},children:[(0,U.jsx)(US,{snapshot:t,locale:i}),(0,U.jsx)(WS,{snapshot:t,locale:i})]}),(0,U.jsx)(zx,{snapshot:t})]}):e===`chat`?(0,U.jsxs)(Z,{className:`workspace-stack`,spacing:2.25,children:[(0,U.jsx)(MS,{snapshot:t,refreshSnapshot:r}),(0,U.jsx)(hS,{snapshot:t,refreshSnapshot:r}),(0,U.jsx)(mS,{snapshot:t,events:n,refreshSnapshot:r})]}):e===`documents`?(0,U.jsx)(Tx,{}):e===`source`?(0,U.jsx)(oy,{snapshot:t,refreshSnapshot:r}):e===`activity`?(0,U.jsx)(Mx,{snapshot:t}):e===`history`?(0,U.jsx)(FS,{snapshot:t}):(0,U.jsx)(RS,{snapshot:t})}function qS({snapshot:e,connection:t=`connecting`,events:n=[],refreshSnapshot:r}){let{locale:i,colorMode:a,setLocale:o,setColorMode:s}=Kv(),[c,l]=(0,v.useState)(`overview`),[u,d]=(0,v.useState)(!1);if(!e)return(0,U.jsxs)(J,{className:`loading-shell`,children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsx)(`p`,{className:`section-kicker`,children:`Piagent WebUI · local`}),(0,U.jsx)(X,{variant:`h1`,children:t===`failed`?Q(i,`Không thể nối vào Pi session`,`Unable to connect to the Pi session`):Q(i,`Đang mở không gian làm việc`,`Opening the workspace`)}),(0,U.jsx)(X,{color:`text.secondary`,children:t===`failed`?Q(i,`Hãy mở lại WebUI từ Pi terminal để tạo phiên local mới.`,`Reopen WebUI from the Pi terminal to create a new local session.`):Q(i,`Đang tải task contract và trạng thái runtime hiện tại…`,`Loading the task contract and current runtime state…`)}),t!==`failed`&&(0,U.jsx)(xu,{size:22}),(0,U.jsx)(VS,{value:t,locale:i})]});let f=BS[c][i],p=(e.sourceChanges.task?.counts.files??0)+e.sourceChanges.workingTree.counts.files+e.sourceChanges.staged.counts.files,m=[{id:`overview`,label:Q(i,`Tổng quan`,`Overview`),icon:(0,U.jsx)(jh,{})},{id:`chat`,label:Q(i,`Chat & Task`,`Chat & Task`),icon:(0,U.jsx)(Mh,{}),count:e.session.queue.heldCount??0},{id:`documents`,label:Q(i,`Tài liệu`,`Documents`),icon:(0,U.jsx)(Nh,{})},{id:`source`,label:`Source Changes`,icon:(0,U.jsx)(Ph,{}),count:p},{id:`activity`,label:`Activity`,icon:(0,U.jsx)(Fh,{}),count:e.activity.running.length},{id:`history`,label:Q(i,`Lịch sử`,`History`),icon:(0,U.jsx)(Ih,{})},{id:`release`,label:`Release`,icon:(0,U.jsx)(Lh,{})}],h=e=>{l(e),d(!1)},g=(0,U.jsxs)(J,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(up,{sx:{minHeight:`72px !important`,px:`18px !important`,gap:1.25},children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:760,lineHeight:1.15},children:`Piagent`}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:`WebUI · local`})]})]}),(0,U.jsxs)(J,{sx:{mx:1.5,mb:1.25,p:1.35,border:1,borderColor:`divider`,borderRadius:2,bgcolor:`action.hover`},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textTransform:`uppercase`,letterSpacing:`.09em`},children:Q(i,`Pi session hiện tại`,`Current Pi session`)}),(0,U.jsx)(X,{variant:`body2`,noWrap:!0,title:e.session.displayName??void 0,sx:{mt:.45,fontWeight:700},children:e.session.displayName??`Pi session`}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,title:e.identity.sessionRef,children:Rv(e.identity.sessionRef)})]}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{px:2.5,pt:1,pb:.5,fontWeight:800,letterSpacing:`.1em`,textTransform:`uppercase`},children:Q(i,`Không gian làm việc`,`Workspaces`)}),(0,U.jsx)(rf,{component:`nav`,"aria-label":Q(i,`Điều hướng WebUI`,`WebUI navigation`),sx:{py:.5},children:m.map(e=>(0,U.jsxs)(cf,{selected:c===e.id,"aria-current":c===e.id?`page`:void 0,onClick:()=>h(e.id),children:[(0,U.jsx)(pf,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:e.icon}),(0,U.jsx)(Cf,{primary:e.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:c===e.id?750:600}}}}),!!e.count&&(0,U.jsx)(rl,{badgeContent:e.count,color:e.id===`activity`?`secondary`:`primary`,max:99,sx:{mr:1}})]},e.id))}),(0,U.jsxs)(J,{sx:{mt:`auto`,p:1.5},children:[(0,U.jsx)(Du,{sx:{mb:1.5}}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsxs)(op,{exclusive:!0,size:`small`,value:i,"aria-label":Q(i,`Ngôn ngữ`,`Language`),onChange:(e,t)=>t&&o(t),sx:{flex:1},children:[(0,U.jsx)(ep,{value:`vi`,"aria-label":`Tiếng Việt`,sx:{flex:1},children:`VI`}),(0,U.jsx)(ep,{value:`en`,"aria-label":`English`,sx:{flex:1},children:`EN`})]}),(0,U.jsx)(Ah,{title:a===`dark`?Q(i,`Chuyển sang giao diện sáng`,`Use light mode`):Q(i,`Chuyển sang giao diện tối`,`Use dark mode`),children:(0,U.jsx)(Qd,{"aria-label":a===`dark`?Q(i,`Dùng giao diện sáng`,`Use light mode`):Q(i,`Dùng giao diện tối`,`Use dark mode`),onClick:()=>s(a===`dark`?`light`:`dark`),sx:{border:1,borderColor:`divider`,borderRadius:1.5},children:a===`dark`?(0,U.jsx)(zh,{fontSize:`small`}):(0,U.jsx)(Bh,{fontSize:`small`})})})]})]})]});return(0,U.jsxs)(J,{className:`app-shell`,"data-contract":`snapshot-v1`,children:[(0,U.jsx)(`a`,{className:`skip-link`,href:`#main-content`,children:Q(i,`Bỏ qua điều hướng`,`Skip navigation`)}),(0,U.jsx)(zc,{position:`fixed`,color:`transparent`,elevation:0,sx:{width:{md:`calc(100% - ${zS}px)`},ml:{md:`${zS}px`},borderBottom:1,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .88)`,backdropFilter:`blur(18px)`},children:(0,U.jsxs)(up,{sx:{minHeight:`72px !important`,gap:1.5},children:[(0,U.jsx)(Qd,{edge:`start`,"aria-label":Q(i,`Mở menu`,`Open menu`),onClick:()=>d(!0),sx:{display:{md:`none`}},children:(0,U.jsx)(Rh,{})}),(0,U.jsxs)(J,{sx:{minWidth:0,flex:1},children:[(0,U.jsx)(X,{component:`h1`,variant:`h2`,noWrap:!0,children:f[0]}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{display:{xs:`none`,sm:`block`}},children:f[1]})]}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},"aria-live":`polite`,children:[(0,U.jsx)(lu,{variant:`outlined`,size:`small`,color:t===`connected`?`success`:`default`,label:t===`connected`?`Live`:Iv(t,i)}),e.approvals.pending.length>0&&(0,U.jsx)(lu,{color:`warning`,size:`small`,label:`${e.approvals.pending.length} approval`}),(0,U.jsx)(lu,{variant:`outlined`,size:`small`,sx:{display:{xs:`none`,sm:`flex`}},label:e.capabilities.capabilities[`control.chat`].status===`available`?Q(i,`Chat bật`,`Chat enabled`):Q(i,`Chỉ xem`,`Read only`)})]})]})}),(0,U.jsxs)(J,{component:`nav`,"aria-label":Q(i,`Sidebar chính`,`Primary sidebar`),sx:{width:{md:zS},flexShrink:{md:0}},children:[(0,U.jsx)(Kd,{variant:`temporary`,open:u,onClose:()=>d(!1),ModalProps:{keepMounted:!0},sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:zS}},children:g}),(0,U.jsx)(Kd,{variant:`permanent`,open:!0,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:zS,borderRight:1,borderColor:`divider`,bgcolor:`background.paper`}},children:g})]}),(0,U.jsx)(J,{component:`main`,id:`main-content`,sx:{ml:{md:`${zS}px`},minWidth:0,pt:`72px`},children:(0,U.jsxs)(J,{className:`workspace-view workspace-${c}`,sx:{width:`100%`,maxWidth:c===`source`?`none`:1580,mx:`auto`,p:{xs:1.5,sm:2.5,lg:3}},children:[e.approvals.pending.length>0&&(0,U.jsx)(J,{sx:{mb:2.25},children:(0,U.jsx)(OS,{snapshot:e,refreshSnapshot:r})}),(0,U.jsx)(KS,{active:c,snapshot:e,events:n,refreshSnapshot:r,locale:i})]})})]})}var JS=Y((0,U.jsx)(`path`,{d:`M18 13h-5v5c0 .55-.45 1-1 1s-1-.45-1-1v-5H6c-.55 0-1-.45-1-1s.45-1 1-1h5V6c0-.55.45-1 1-1s1 .45 1 1v5h5c.55 0 1 .45 1 1s-.45 1-1 1`}),`AddRounded`),YS=Y((0,U.jsx)(`path`,{d:`M16.5 6.75v10.58c0 2.09-1.53 3.95-3.61 4.15-2.39.23-4.39-1.64-4.39-3.98V5.14c0-1.31.94-2.5 2.24-2.63 1.5-.15 2.76 1.02 2.76 2.49v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75v8.61c0 1.31.94 2.5 2.24 2.63 1.5.15 2.76-1.02 2.76-2.49V5.17c0-2.09-1.53-3.95-3.61-4.15C9.01.79 7 2.66 7 5v12.27c0 2.87 2.1 5.44 4.96 5.71 3.29.3 6.04-2.26 6.04-5.48V6.75c0-.41-.34-.75-.75-.75s-.75.34-.75.75`}),`AttachFileRounded`),XS=Y((0,U.jsx)(`path`,{d:`M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2m4.3 14.3c-.39.39-1.02.39-1.41 0L12 13.41 9.11 16.3c-.39.39-1.02.39-1.41 0a.996.996 0 0 1 0-1.41L10.59 12 7.7 9.11a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0L12 10.59l2.89-2.89c.39-.39 1.02-.39 1.41 0s.39 1.02 0 1.41L13.41 12l2.89 2.89c.38.38.38 1.02 0 1.41`}),`CancelRounded`),ZS=Y((0,U.jsx)(`path`,{d:`M17.65 6.35c-1.63-1.63-3.94-2.57-6.48-2.31-3.67.37-6.69 3.35-7.1 7.02C3.52 15.91 7.27 20 12 20c3.19 0 5.93-1.87 7.21-4.56.32-.67-.16-1.44-.9-1.44-.37 0-.72.2-.88.53-1.13 2.43-3.84 3.97-6.8 3.31-2.22-.49-4.01-2.3-4.48-4.52C5.31 9.44 8.26 6 12 6c1.66 0 3.14.69 4.22 1.78l-1.51 1.51c-.63.63-.19 1.71.7 1.71H19c.55 0 1-.45 1-1V6.41c0-.89-1.08-1.34-1.71-.71z`}),`RefreshRounded`),QS=Y((0,U.jsx)(`path`,{d:`m3.4 20.4 17.45-7.48c.81-.35.81-1.49 0-1.84L3.4 3.6c-.66-.29-1.39.2-1.39.91L2 9.12c0 .5.37.93.87.99L17 12 2.87 13.88c-.5.07-.87.5-.87 1l.01 4.61c0 .71.73 1.2 1.39.91`}),`SendRounded`),$S=Y((0,U.jsx)(`path`,{d:`M2 4v16h20V4zm18 4.67h-2.5V6H20zm-2.5 2H20v2.67h-2.5zM4 6h11.5v12H4zm13.5 12v-2.67H20V18z`}),`ViewSidebarOutlined`),eC=Y((0,U.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m3 14H9c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h6c.55 0 1 .45 1 1v6c0 .55-.45 1-1 1`}),`StopCircleRounded`);function tC(e){return Gr(`MuiAlert`,e)}var nC=Kr(`MuiAlert`,[`root`,`action`,`icon`,`message`,`filled`,`colorSuccess`,`colorInfo`,`colorWarning`,`colorError`,`outlined`,`standard`]),rC=Y((0,U.jsx)(`path`,{d:`M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z`}),`SuccessOutlined`),iC=Y((0,U.jsx)(`path`,{d:`M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z`}),`ReportProblemOutlined`),aC=Y((0,U.jsx)(`path`,{d:`M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z`}),`ErrorOutline`),oC=Y((0,U.jsx)(`path`,{d:`M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z`}),`InfoOutlined`),sC=Y((0,U.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`}),`Close`),cC=e=>{let{variant:t,color:n,severity:r,classes:i}=e;return ba({root:[`root`,`color${q(n||r)}`,`${t}`],icon:[`icon`],message:[`message`],action:[`action`]},tC,i)},lC=K(Pc,{name:`MuiAlert`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant]]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`?e.darken:e.lighten,n=e.palette.mode===`light`?e.lighten:e.darken;return{...e.typography.body2,backgroundColor:`transparent`,display:`flex`,padding:`6px 16px`,variants:[...Object.entries(e.palette).filter(Ac([`light`])).map(([r])=>({props:{colorSeverity:r,variant:`standard`},style:{color:e.vars?e.vars.palette.Alert[`${r}Color`]:t(e.palette[r].light,.6),backgroundColor:e.vars?e.vars.palette.Alert[`${r}StandardBg`]:n(e.palette[r].light,.9),[`& .${nC.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}}})),...Object.entries(e.palette).filter(Ac([`light`])).map(([n])=>({props:{colorSeverity:n,variant:`outlined`},style:{color:e.vars?e.vars.palette.Alert[`${n}Color`]:t(e.palette[n].light,.6),border:`1px solid ${(e.vars||e).palette[n].light}`,[`& .${nC.icon}`]:e.vars?{color:e.vars.palette.Alert[`${n}IconColor`]}:{color:e.palette[n].main}}})),...Object.entries(e.palette).filter(Ac([`dark`])).map(([t])=>({props:{colorSeverity:t,variant:`filled`},style:{fontWeight:e.typography.fontWeightMedium,...e.vars?{color:e.vars.palette.Alert[`${t}FilledColor`],backgroundColor:e.vars.palette.Alert[`${t}FilledBg`]}:{backgroundColor:e.palette.mode===`dark`?e.palette[t].dark:e.palette[t].main,color:e.palette.getContrastText(e.palette[t].main)}}}))]}})),uC=K(`div`,{name:`MuiAlert`,slot:`Icon`})({marginRight:12,padding:`7px 0`,display:`flex`,fontSize:22,opacity:.9}),dC=K(`div`,{name:`MuiAlert`,slot:`Message`})({padding:`8px 0`,minWidth:0,overflow:`auto`}),fC=K(`div`,{name:`MuiAlert`,slot:`Action`})({display:`flex`,alignItems:`flex-start`,padding:`4px 0 0 16px`,marginLeft:`auto`,marginRight:-8}),pC={success:(0,U.jsx)(rC,{fontSize:`inherit`}),warning:(0,U.jsx)(iC,{fontSize:`inherit`}),error:(0,U.jsx)(aC,{fontSize:`inherit`}),info:(0,U.jsx)(oC,{fontSize:`inherit`})},mC=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiAlert`}),{action:r,children:i,className:a,closeText:o=`Close`,color:s,icon:c,iconMapping:l=pC,onClose:u,role:d=`alert`,severity:f=`success`,slotProps:p={},slots:m={},variant:h=`standard`,...g}=n,_={...n,color:s,severity:f,variant:h,colorSeverity:s||f},v=cC(_),y={slots:m,slotProps:p},[b,x]=Xc(`root`,{ref:t,shouldForwardComponentProp:!0,className:W(v.root,a),elementType:lC,externalForwardedProps:{...y,...g},ownerState:_,additionalProps:{role:d,elevation:0}}),[S,C]=Xc(`icon`,{className:v.icon,elementType:uC,externalForwardedProps:y,ownerState:_}),[w,T]=Xc(`message`,{className:v.message,elementType:dC,externalForwardedProps:y,ownerState:_}),[E,D]=Xc(`action`,{className:v.action,elementType:fC,externalForwardedProps:y,ownerState:_}),[O,k]=Xc(`closeButton`,{elementType:Qd,externalForwardedProps:y,ownerState:_}),[A,j]=Xc(`closeIcon`,{elementType:sC,externalForwardedProps:y,ownerState:_});return(0,U.jsxs)(b,{...x,children:[c===!1?null:(0,U.jsx)(S,{...C,children:c||l[f]||pC[f]}),(0,U.jsx)(w,{...T,children:i}),r==null?null:(0,U.jsx)(E,{...D,children:r}),r==null&&u?(0,U.jsx)(E,{...D,children:(0,U.jsx)(O,{size:`small`,"aria-label":o,title:o,color:`inherit`,onClick:u,...k,children:(0,U.jsx)(A,{fontSize:`small`,...j})})}):null]})});function hC(e){return Gr(`MuiButton`,e)}var gC=Kr(`MuiButton`,`root.text.outlined.contained.disableElevation.focusVisible.disabled.colorInherit.colorPrimary.colorSecondary.colorSuccess.colorError.colorInfo.colorWarning.sizeMedium.sizeSmall.sizeLarge.fullWidth.startIcon.endIcon.icon.loading.loadingWrapper.loadingIconPlaceholder.loadingIndicator.loadingPositionCenter.loadingPositionStart.loadingPositionEnd`.split(`.`)),_C=v.createContext({}),vC=v.createContext(void 0),yC=e=>{let{color:t,disableElevation:n,fullWidth:r,size:i,variant:a,loading:o,loadingPosition:s,classes:c}=e,l=ba({root:[`root`,o&&`loading`,a,`size${q(i)}`,`color${q(t)}`,n&&`disableElevation`,r&&`fullWidth`,o&&`loadingPosition${q(s)}`],startIcon:[`icon`,`startIcon`],endIcon:[`icon`,`endIcon`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},hC,c);return{...c,...l}},bC=[{props:{size:`small`},style:{"& > *:nth-of-type(1)":{fontSize:18}}},{props:{size:`medium`},style:{"& > *:nth-of-type(1)":{fontSize:20}}},{props:{size:`large`},style:{"& > *:nth-of-type(1)":{fontSize:22}}}],xC=K(tu,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`size${q(n.size)}`],n.color===`inherit`&&t.colorInherit,n.disableElevation&&t.disableElevation,n.fullWidth&&t.fullWidth,n.loading&&t.loading]}})(ys(({theme:e})=>{let t=e.palette.mode===`light`?e.palette.grey[300]:e.palette.grey[800],n=e.palette.mode===`light`?e.palette.grey.A100:e.palette.grey[700];return{...e.typography.button,minWidth:64,padding:`6px 16px`,border:0,borderRadius:(e.vars||e).shape.borderRadius,...Ks(e,[`background-color`,`box-shadow`,`border-color`,`color`],{duration:e.transitions.duration.short}),"&:hover":{textDecoration:`none`},[`&.${gC.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:{variant:`contained`},style:{color:`var(--variant-containedColor)`,backgroundColor:`var(--variant-containedBg)`,boxShadow:(e.vars||e).shadows[2],"&:hover":{boxShadow:(e.vars||e).shadows[4],"@media (hover: none)":{boxShadow:(e.vars||e).shadows[2]}},"&:active":{boxShadow:(e.vars||e).shadows[8]},[`&.${gC.focusVisible}`]:{boxShadow:(e.vars||e).shadows[6]},[`&.${gC.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}},{props:{variant:`outlined`},style:{padding:`5px 15px`,border:`1px solid currentColor`,borderColor:`var(--variant-outlinedBorder, currentColor)`,backgroundColor:`var(--variant-outlinedBg)`,color:`var(--variant-outlinedColor)`,[`&.${gC.disabled}`]:{border:`1px solid ${(e.vars||e).palette.action.disabledBackground}`}}},{props:{variant:`text`},style:{padding:`6px 8px`,color:`var(--variant-textColor)`,backgroundColor:`var(--variant-textBg)`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{"--variant-textColor":(e.vars||e).palette[t].main,"--variant-outlinedColor":(e.vars||e).palette[t].main,"--variant-outlinedBorder":e.alpha((e.vars||e).palette[t].main,.5),"--variant-containedColor":(e.vars||e).palette[t].contrastText,"--variant-containedBg":(e.vars||e).palette[t].main,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":(e.vars||e).palette[t].dark,"--variant-textBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBorder":(e.vars||e).palette[t].main,"--variant-outlinedBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}}}})),{props:{color:`inherit`},style:{color:`inherit`,borderColor:`currentColor`,"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedBg:t,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedHoverBg:n,"--variant-textBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity)}}}},{props:{size:`small`,variant:`text`},style:{padding:`4px 5px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`text`},style:{padding:`8px 11px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`outlined`},style:{padding:`3px 9px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`outlined`},style:{padding:`7px 21px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`contained`},style:{padding:`4px 10px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`contained`},style:{padding:`8px 22px`,fontSize:e.typography.pxToRem(15)}},{props:{disableElevation:!0},style:{boxShadow:`none`,"&:hover":{boxShadow:`none`},[`&.${gC.focusVisible}`]:{boxShadow:`none`},"&:active":{boxShadow:`none`},[`&.${gC.disabled}`]:{boxShadow:`none`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{loadingPosition:`center`},style:{...Ks(e,[`background-color`,`box-shadow`,`border-color`],{duration:e.transitions.duration.short}),[`&.${gC.loading}`]:{color:`transparent`}}}]}})),SC=K(`span`,{name:`MuiButton`,slot:`StartIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.startIcon,n.loading&&t.startIconLoadingStart]}})(({theme:e})=>({display:`inherit`,alignItems:`center`,marginRight:8,marginLeft:-4,"&::before":{content:`"\\200b"`,width:0,overflow:`hidden`},variants:[{props:{size:`small`},style:{marginLeft:-2}},{props:{loadingPosition:`start`,loading:!0},style:{...Ks(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`start`,loading:!0,fullWidth:!0},style:{marginRight:-8}},...bC]})),CC=K(`span`,{name:`MuiButton`,slot:`EndIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.endIcon,n.loading&&t.endIconLoadingEnd]}})(({theme:e})=>({display:`inherit`,marginRight:-4,marginLeft:8,variants:[{props:{size:`small`},style:{marginRight:-2}},{props:{loadingPosition:`end`,loading:!0},style:{...Ks(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`end`,loading:!0,fullWidth:!0},style:{marginLeft:-8}},...bC]})),wC=K(`span`,{name:`MuiButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,variants:[{props:{loading:!0},style:{display:`flex`}},{props:{loadingPosition:`start`},style:{left:14}},{props:{loadingPosition:`start`,size:`small`},style:{left:10}},{props:{variant:`text`,loadingPosition:`start`},style:{left:6}},{props:{loadingPosition:`center`},style:{left:`50%`,transform:`translate(-50%)`,color:(e.vars||e).palette.action.disabled}},{props:{loadingPosition:`end`},style:{right:14}},{props:{loadingPosition:`end`,size:`small`},style:{right:10}},{props:{variant:`text`,loadingPosition:`end`},style:{right:6}},{props:{loadingPosition:`start`,fullWidth:!0},style:{position:`relative`,left:-10}},{props:{loadingPosition:`end`,fullWidth:!0},style:{position:`relative`,right:-10}}]})),TC=K(`span`,{name:`MuiButton`,slot:`LoadingIconPlaceholder`})({display:`inline-block`,width:`1em`,height:`1em`}),$=v.forwardRef(function(e,t){let n=v.useContext(_C),r=v.useContext(vC),i=Xo({props:ai(n,e),name:`MuiButton`}),{children:a,color:o=`primary`,component:s=`button`,className:c,disabled:l=!1,disableElevation:u=!1,disableFocusRipple:d=!1,endIcon:f,focusVisibleClassName:p,fullWidth:m=!1,id:h,loading:g=null,loadingIndicator:_,loadingPosition:y=`center`,size:b=`medium`,startIcon:x,type:S,variant:C=`text`,...w}=i,T=Ed(h),E=_??(0,U.jsx)(xu,{"aria-labelledby":T,color:`inherit`,size:16}),D={...i,color:o,component:s,disabled:l,disableElevation:u,disableFocusRipple:d,fullWidth:m,loading:g,loadingIndicator:E,loadingPosition:y,size:b,type:S,variant:C},O=yC(D),k=(x||g&&y===`start`)&&(0,U.jsx)(SC,{className:O.startIcon,ownerState:D,children:x||(0,U.jsx)(TC,{className:O.loadingIconPlaceholder,ownerState:D})}),A=(f||g&&y===`end`)&&(0,U.jsx)(CC,{className:O.endIcon,ownerState:D,children:f||(0,U.jsx)(TC,{className:O.loadingIconPlaceholder,ownerState:D})}),j=r||``,M=typeof g==`boolean`?(0,U.jsx)(`span`,{className:O.loadingWrapper,style:{display:`contents`},children:g&&(0,U.jsx)(wC,{className:O.loadingIndicator,ownerState:D,children:E})}):null,{root:N,...P}=O;return(0,U.jsxs)(xC,{ownerState:D,className:W(n.className,O.root,c,j),component:s,disabled:l||g,focusRipple:!d,focusVisibleClassName:W(O.focusVisible,p),ref:t,internalNativeButton:!0,type:S,id:g?T:h,...w,classes:P,children:[k,y!==`end`&&M,a,y===`end`&&M,A]})});function EC(e){return Gr(`MuiCollapse`,e)}Kr(`MuiCollapse`,[`root`,`horizontal`,`vertical`,`entered`,`hidden`,`wrapper`,`wrapperInner`]);var DC={},OC=e=>{let{orientation:t,classes:n}=e;return ba({root:[`root`,t],entered:[`entered`],hidden:[`hidden`],wrapper:[`wrapper`,t],wrapperInner:[`wrapperInner`,t]},EC,n)},kC=K(`div`,{name:`MuiCollapse`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.orientation],n.state===`entered`&&t.entered,n.state===`exited`&&!n.in&&n.collapsedSize===`0px`&&t.hidden]}})(ys(({theme:e})=>({height:0,overflow:`hidden`,transition:e.transitions.create(`height`),variants:[{props:{orientation:`horizontal`},style:{height:`auto`,width:0,transition:e.transitions.create(`width`)}},{props:{state:`entered`},style:{height:`auto`,overflow:`visible`}},{props:{state:`entered`,orientation:`horizontal`},style:{width:`auto`}},{props:({ownerState:e})=>e.state===`exited`&&!e.in&&e.collapsedSize===`0px`,style:{visibility:`hidden`}}]}))),AC=K(`div`,{name:`MuiCollapse`,slot:`Wrapper`})({display:`flex`,width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),jC=K(`div`,{name:`MuiCollapse`,slot:`WrapperInner`})({width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),MC=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiCollapse`}),{addEndListener:r,children:i,className:a,collapsedSize:o=`0px`,component:s,disablePrefersReducedMotion:c=!1,easing:l,in:u,onEnter:d,onEntered:f,onEntering:p,onExit:m,onExited:h,onExiting:g,orientation:_=`vertical`,slots:y=DC,slotProps:b=DC,style:x,timeout:S=fo.standard,TransitionComponent:C=id,...w}=n,T={...n,orientation:_,collapsedSize:o},E=OC(T),D=Go(),O=v.useRef(null),k=v.useRef(null),A=typeof o==`number`?`${o}px`:o,j=_===`horizontal`,M=j?`width`:`height`,N=Ll(D.motion.reducedMotion,c),P=v.useRef(null),F=bs(t,P),I=()=>O.current?O.current[j?`clientWidth`:`clientHeight`]:0,L=Hs(P,(e,t)=>{O.current&&j&&(O.current.style.position=`absolute`),e.style[M]=A,d&&d(e,t)}),R=Hs(P,(e,t)=>{let n=I();O.current&&j&&(O.current.style.position=``);let{duration:r,easing:i}=Ws({style:x,timeout:S,easing:l},{mode:`enter`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(n);k.current=e}else k.current=null;let a=N.getTransitionTiming({duration:k.current??r,delay:void 0});e.style.transitionDuration=typeof a.duration==`string`?a.duration:`${a.duration}ms`,e.style[M]=`${n}px`,e.style.transitionTimingFunction=i,p&&p(e,t)}),ee=Hs(P,(e,t)=>{e.style[M]=`auto`,f&&f(e,t)}),te=Hs(P,e=>{e.style[M]=`${I()}px`,m&&m(e)}),z=Hs(P,h),B=Hs(P,e=>{let t=I(),{duration:n,easing:r}=Ws({style:x,timeout:S,easing:l},{mode:`exit`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(t);k.current=e}else k.current=null;let i=N.getTransitionTiming({duration:k.current??n,delay:void 0});e.style.transitionDuration=typeof i.duration==`string`?i.duration:`${i.duration}ms`,e.style[M]=A,e.style.transitionTimingFunction=r,g&&g(e)}),V=r?e=>{r(P.current,e)}:void 0,ne={slots:y,slotProps:b,component:s},[re,ie]=Xc(`root`,{ref:F,className:W(E.root,a),elementType:kC,externalForwardedProps:ne,ownerState:T,additionalProps:{style:{[j?`minWidth`:`minHeight`]:A,...x}}}),[ae,oe]=Xc(`wrapper`,{ref:O,className:E.wrapper,elementType:AC,externalForwardedProps:ne,ownerState:T}),[se,H]=Xc(`wrapperInner`,{className:E.wrapperInner,elementType:jC,externalForwardedProps:ne,ownerState:T});return(0,U.jsx)(C,{in:u,onEnter:L,onEntered:ee,onEntering:R,onExit:te,onExited:z,onExiting:B,addEndListener:V,getAutoTimeout:S===`auto`?()=>k.current:void 0,reduceMotion:N.shouldReduceMotion,nodeRef:P,timeout:S===`auto`?null:S,...w,children:(e,{ownerState:t,...n})=>{let r={...T,state:e};return(0,U.jsx)(re,{...ie,className:W(ie.className,{entered:E.entered,exited:!u&&A===`0px`&&E.hidden}[e]),ownerState:r,...n,children:(0,U.jsx)(ae,{...oe,ownerState:r,children:(0,U.jsx)(se,{...H,ownerState:r,children:i})})})}})});MC&&(MC.muiSupportAuto=!0);function NC(e){return Gr(`MuiDialog`,e)}Kr(`MuiDialog`,[`root`,`backdrop`,`scrollPaper`,`scrollBody`,`container`,`paper`,`paperWidthFalse`,`paperWidthXs`,`paperWidthSm`,`paperWidthMd`,`paperWidthLg`,`paperWidthXl`,`paperFullWidth`,`paperFullScreen`]);var PC=v.createContext({}),FC=K(dd,{name:`MuiDialog`,slot:`Backdrop`})({zIndex:-1}),IC=e=>{let{classes:t,scroll:n,maxWidth:r,fullWidth:i,fullScreen:a}=e;return ba({root:[`root`],backdrop:[`backdrop`],container:[`container`,`scroll${q(n)}`],paper:[`paper`,`paperWidth${q(String(r))}`,i&&`paperFullWidth`,a&&`paperFullScreen`]},NC,t)},LC=K(Sd,{name:`MuiDialog`,slot:`Root`})({"@media print":{position:`absolute !important`}}),RC=K(`div`,{name:`MuiDialog`,slot:`Container`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.container,t[`scroll${q(n.scroll)}`]]}})({height:`100%`,"@media print":{height:`auto`},outline:0,variants:[{props:{scroll:`paper`},style:{display:`flex`,justifyContent:`center`,alignItems:`center`}},{props:{scroll:`body`},style:{overflowY:`auto`,overflowX:`hidden`,textAlign:`center`,"&::after":{content:`""`,display:`inline-block`,verticalAlign:`middle`,height:`100%`,width:`0`}}}]}),zC=K(Pc,{name:`MuiDialog`,slot:`Paper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.paper,t[`paperWidth${q(String(n.maxWidth))}`],n.fullWidth&&t.paperFullWidth,n.fullScreen&&t.paperFullScreen]}})(ys(({theme:e})=>({margin:32,position:`relative`,overflowY:`auto`,outline:0,"@media print":{overflowY:`visible`,boxShadow:`none`},variants:[{props:{scroll:`paper`},style:{display:`flex`,flexDirection:`column`,maxHeight:`calc(100% - 64px)`}},{props:{scroll:`body`},style:{display:`inline-block`,verticalAlign:`middle`,textAlign:`initial`}},{props:({ownerState:e})=>!e.maxWidth,style:{maxWidth:`calc(100% - 64px)`}},{props:{maxWidth:`xs`},style:{maxWidth:e.breakpoints.unit===`px`?Math.max(e.breakpoints.values.xs,444):`max(${e.breakpoints.values.xs}${e.breakpoints.unit}, 444px)`}},{props:{maxWidth:`xs`,scroll:`body`},style:{[e.breakpoints.down(Math.max(e.breakpoints.values.xs,444)+64)]:{maxWidth:`calc(100% - 64px)`}}},...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t},style:{maxWidth:`${e.breakpoints.values[t]}${e.breakpoints.unit}`}})),...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t,scroll:`body`},style:{[e.breakpoints.down(e.breakpoints.values[t]+64)]:{maxWidth:`calc(100% - 64px)`}}})),{props:({ownerState:e})=>e.fullWidth,style:{width:`calc(100% - 64px)`}},{props:({ownerState:e})=>e.fullScreen,style:{margin:0,width:`100%`,maxWidth:`100%`,height:`100%`,maxHeight:`none`,borderRadius:0}},{props:({ownerState:e})=>e.fullScreen&&e.scroll===`body`,style:{margin:0,maxWidth:`100%`}}]}))),BC=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialog`}),r=Go(),i={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{"aria-describedby":a,"aria-labelledby":o,"aria-modal":s=!0,children:c,className:l,fullScreen:u=!1,fullWidth:d=!1,maxWidth:f=`sm`,onClick:p,onClose:m,open:h,PaperComponent:g=Pc,role:_=`dialog`,scroll:y=`paper`,slots:b={},slotProps:x={},transitionDuration:S=i,...C}=n,w={...n,fullScreen:u,fullWidth:d,maxWidth:f,scroll:y},T=IC(w),E=v.useRef(),D=e=>{E.current=e.target===e.currentTarget},O=e=>{p&&p(e),E.current&&(E.current=null,m&&m(e,`backdropClick`))},k=Ki(o),A=v.useMemo(()=>({titleId:k}),[k]),j={slots:b,slotProps:x},[M,N]=Xc(`root`,{elementType:LC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:W(T.root,l),ref:t}),[P,F]=Xc(`backdrop`,{elementType:FC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.backdrop}),[I,L]=Xc(`paper`,{elementType:zC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.paper,additionalProps:{elevation:24,role:_,"aria-describedby":a,"aria-labelledby":k,"aria-modal":s,tabIndex:-1,[Bu]:``}}),[R,ee]=Xc(`container`,{elementType:RC,externalForwardedProps:j,ownerState:w,className:T.container}),[te,z]=Xc(`transition`,{elementType:sd,externalForwardedProps:j,ownerState:w,additionalProps:{appear:!0,in:h,timeout:S,role:`presentation`}});return(0,U.jsx)(M,{closeAfterTransition:!0,slots:{backdrop:P},slotProps:{backdrop:{transitionDuration:S,...F}},onClose:m,open:h,onClick:O,...N,...C,children:(0,U.jsx)(te,{...z,children:(0,U.jsx)(R,{onMouseDown:D,...ee,children:(0,U.jsx)(I,{as:g,...L,children:(0,U.jsx)(PC.Provider,{value:A,children:c})})})})})}),VC=(e,[t,n])=>e===`vi`?t:n,HC={"managed-config-missing":[`Chưa nhập cấu hình công ty. Mở Agent Watch → Studio → Nhập cấu hình cho Piagent (trên Windows: Kết nối Piagent trong WSL).`,`Company configuration is not imported. Open Agent Watch → Studio and import it for Piagent (on Windows: Connect Piagent in WSL).`],"managed-keychain-approval-required":[`macOS chưa cho Agent Watch đọc key. Chọn “Luôn cho phép” khi được hỏi rồi kết nối lại.`,`macOS did not let Agent Watch read the key. Choose “Always Allow” when asked, then connect again.`],"managed-key-unavailable":[`Agent Watch không đọc được key công ty trên máy này. Mở Agent Watch, dán lại mã kết nối, bấm Kết nối Piagent trong WSL rồi kết nối lại.`,`Agent Watch cannot read the company key on this computer. Open Agent Watch, paste the connection code again, choose Connect Piagent in WSL, then connect again.`],"managed-profile-disconnected":[`Cấu hình Piagent đang thuộc key công ty đã ngắt kết nối. Nhập lại cấu hình cho Piagent trong Agent Watch (trên Windows: Kết nối Piagent trong WSL).`,`The Piagent configuration belongs to a disconnected company key. Import it again in Agent Watch (on Windows: Connect Piagent in WSL).`],"managed-launch-binding-changed":[`Agent Watch hoặc Piagent vừa cập nhật. Nhập lại cấu hình cho Piagent trong Agent Watch (trên Windows: Kết nối Piagent trong WSL).`,`Agent Watch or Piagent changed. Import the Piagent configuration again in Agent Watch (on Windows: Connect Piagent in WSL).`],"managed-launch-version-mismatch":[`Agent Watch đang dùng một bản Piagent khác với dashboard này. Mở Agent Watch → Studio, bấm Áp dụng cho Piagent rồi kết nối lại.`,`Agent Watch points at another Piagent install than this dashboard. Open Agent Watch → Studio, apply for Piagent, then connect again.`],"managed-launch-stale-runtime":[`Phiên công ty của bản Piagent cũ chưa dừng được. Thử kết nối lại sau ít giây.`,`The company runtime from the previous Piagent did not stop yet. Connect again in a few seconds.`],"managed-launch-timeout":[`Phiên công ty khởi động quá lâu. Kết nối lại.`,`The company runtime took too long to start. Connect again.`]},UC={"company-quota":{title:[`Hết hạn mức token`,`Token quota used up`],text:[`Hạn mức token của key này đã hết. Chờ kỳ hạn mức mới hoặc liên hệ quản trị viên để tăng hạn mức.`,`This key's token quota is used up. Wait for the next quota period or ask an administrator to raise it.`]},"company-provider-limit":{title:[`Tài khoản model của công ty hết lượt`,`Company model account limited`],text:[`Nhà cung cấp đang giới hạn tài khoản model của công ty (hết lượt dùng hoặc quá tải). Thử lại sau; quản trị viên có thể đổi model trong Harness.`,`The provider is limiting the company's model account (out of usage or overloaded). Try again later; an administrator can switch the harness model.`]},"company-account":{title:[`Tài khoản model cần đăng nhập lại`,`Model account must sign in again`],text:[`Tài khoản model của công ty đã hết phiên đăng nhập. Quản trị viên cần đăng nhập lại trong Studio (Tài khoản AI).`,`The company's model account is signed out. An administrator has to sign it in again in Studio (AI accounts).`]},"company-busy":{title:[`Đang quá tải`,`Busy`],text:[`Studio đang xử lý quá nhiều request của key này, hoặc tài khoản model đang bận. Chờ vài giây rồi gửi lại.`,`Studio is handling too many requests for this key, or the model account is busy. Wait a few seconds and send again.`]},"company-trial-limit":{title:[`Studio hết lượt thử nghiệm`,`Studio live-test limit reached`],text:[`Studio đã dùng hết số request thử nghiệm được cấp. Quản trị viên cần nâng trần trước khi chạy tiếp.`,`Studio has used up its live-test request ceiling. An administrator has to raise it before anything runs.`]},"company-key":{title:[`Key công ty không dùng được`,`Company key unusable`],text:[`Key công ty đã hết hạn, bị thu hồi, hoặc Agent Watch không đọc được. Nhập lại key trong Agent Watch.`,`The company key expired, was revoked, or Agent Watch cannot read it. Import the key again in Agent Watch.`]},"company-policy":{title:[`Không được phép`,`Not allowed`],text:[`Key này không được dùng model, mức suy luận hoặc độ dài trả lời đang chọn. Nếu Harness vừa đổi, gửi lại để dùng cấu hình mới; nếu vẫn lỗi, kiểm tra Harness trong Studio.`,`This key may not use this model, thinking level or answer length. If the harness just changed, send again to use the new one; otherwise check the harness in Studio.`]},"company-new-session":{title:[`Cần cuộc trò chuyện mới`,`New conversation needed`],text:[`Cuộc trò chuyện này không tiếp tục được với tài khoản model hiện tại. Nội dung cũ vẫn đọc được; tạo cuộc trò chuyện mới để làm tiếp.`,`This conversation cannot continue with the current model account. It stays readable; start a new conversation to go on.`]},"company-rejected":{title:[`Yêu cầu bị từ chối`,`Request rejected`],text:[`Model từ chối yêu cầu này, thường vì cuộc trò chuyện đã dài hơn model hiện tại nhận được. Bấm Tiếp tục: phần cũ được tóm tắt rồi mới gửi. Nếu vẫn bị từ chối, rút gọn tin nhắn hoặc tạo cuộc trò chuyện mới.`,`The model rejected this request, usually because the conversation grew longer than the current model accepts. Press Continue: the older part is summarised before sending. If it is still rejected, shorten the message or start a new conversation.`]},"company-refused":{title:[`Model từ chối yêu cầu này`,`The model declined this request`],text:[`Nhà cung cấp model từ chối yêu cầu này theo chính sách sử dụng của họ (ví dụ: in, mã hoá hoặc gửi ra ngoài thông tin bí mật). Gửi lại nguyên văn sẽ bị từ chối tiếp; hãy viết lại yêu cầu theo cách khác.`,`The model's provider declined this request under its usage policy (for example, printing, encoding or sending out secrets). The same request is declined again; ask in a different way.`]},"company-unreachable":{title:[`Lỗi kết nối`,`Connection error`],text:[`Không kết nối được tới Studio. Kiểm tra mạng hoặc VPN rồi gửi lại.`,`Studio could not be reached. Check the network or VPN and send again.`]},"company-service":{title:[`Dịch vụ model lỗi`,`Model service error`],text:[`Studio đã nhận yêu cầu nhưng dịch vụ model phía sau không trả lời. Gửi lại; nếu lặp lại, báo quản trị viên kèm mã bên dưới.`,`Studio took the request but its model service did not answer. Send again; if it repeats, give an administrator the code below.`]},"company-config-changed":{title:[`Cấu hình vừa thay đổi`,`Configuration changed`],text:[`Key hoặc Harness vừa thay đổi trong Studio. Gửi lại để chạy với cấu hình mới.`,`The key or harness just changed in Studio. Send again to run with the new one.`]},"company-update":{title:[`Cần cập nhật Piagent`,`Piagent update needed`],text:[`Harness dùng model mà bản Piagent này chưa biết. Cập nhật Piagent rồi gửi lại.`,`The harness uses a model this Piagent does not know. Update Piagent and send again.`]},"company-tool":{title:[`Công cụ lỗi`,`Tool error`],text:[`Công cụ này không chạy được ở bước này (ví dụ subagent đã chạy đủ 8 lần cho tin nhắn này).`,`This tool could not run at this step (for example, the subagent already ran 8 times for this message).`]},"company-failed":{title:[`Lỗi chưa phân loại`,`Unclassified error`],text:[`Yêu cầu không hoàn tất. Gửi lại; nếu lặp lại, báo quản trị viên kèm mã bên dưới.`,`The request did not complete. Send again; if it repeats, give an administrator the code below.`]}},WC=[`Cuộc trò chuyện này thuộc thành viên hoặc Studio khác với key đang nhập trong Agent Watch. Nội dung cũ vẫn đọc được; tạo cuộc trò chuyện mới để làm tiếp.`,`This conversation belongs to another member or Studio than the key Agent Watch holds. It stays readable; start a new conversation to go on.`],GC={harness_route_unavailable:{title:[`Không có tài khoản AI cho vai trò này`,`No AI account for this role`],text:[`Không tài khoản AI nào của công ty đang phục vụ model của vai trò này cho team (tài khoản bị ngắt, tắt cho team hoặc hết lượt). Quản trị viên cần gắn hoặc bật tài khoản trong Studio (Tài khoản AI), hoặc đổi model của vai trò trong Harness.`,`No company AI account serves this role's model for the team right now (disconnected, off for the team or out of usage). An administrator has to link or enable one in Studio (AI accounts), or change the role's model in the harness.`]},harness_profile_unavailable:{title:[`Harness không có model cho vai trò này`,`Harness has no model for this role`],text:[`Lượt này bắt đầu khi Harness của team không có model dùng được cho vai trò này. Quản trị viên kiểm tra Harness và tài khoản AI của team trong Studio, rồi gửi lại.`,`This run started while the team's harness had no usable model for this role. An administrator checks the team's harness and AI accounts in Studio; then send again.`]}};function KC(e,t,n){let r=(t?GC[t]:void 0)??UC[e]??(e.startsWith(`company-`)?UC[`company-failed`]:void 0);return r?{title:VC(n,r.title),text:VC(n,t===`managed-session-scope-changed`?WC:r.text)}:null}function qC(e,t){return e===`main`?`Main agent`:e===`scout`?VC(t,[`Subagent scout`,`Scout subagent`]):e===`research`?VC(t,[`Subagent research`,`Research subagent`]):e===`verify`?VC(t,[`Subagent verify`,`Verify subagent`]):VC(t,[`Subagent review`,`Review subagent`])}function JC(e,t,n){return KC(e,t,n)}var YC=new Set([`company-quota`,`company-provider-limit`,`company-account`,`company-busy`,`company-trial-limit`,`company-key`,`company-policy`,`company-rejected`,`company-unreachable`,`company-service`,`company-config-changed`,`company-failed`]);function XC(e){return YC.has(e)||!e.startsWith(`company-`)}function ZC(e,t){return qC(e,t)}var QC=HC,$C={"session-revision-stale":[`Danh sách cuộc trò chuyện vừa thay đổi. Gửi lại tin nhắn.`,`The conversation list just changed. Send the message again.`],"catalog-unavailable":[`Danh sách cuộc trò chuyện chưa tải xong. Thử lại sau vài giây.`,`The conversation list has not loaded yet. Try again in a few seconds.`],"session-model-mismatch":[`Cuộc trò chuyện đã tạo nhưng đang dùng model khác model đã chọn, nên tin nhắn chưa được gửi.`,`The conversation was created with a different model than the one chosen, so the message was not sent.`],"gateway-command-response-timeout":[`Piagent chưa xác nhận được cuộc trò chuyện mới sau 2 phút; nó có thể đã được tạo và đang chạy. Xem danh sách cuộc trò chuyện bên trái trước khi gửi lại.`,`Piagent could not confirm the new conversation within 2 minutes; it may have been created and be running. Check the conversation list before sending again.`],"session-command-expired":[`Yêu cầu chờ quá lâu nên đã hết hạn. Gửi lại tin nhắn.`,`The request waited too long and expired. Send the message again.`]};function ew(e,t){let n=e.startsWith(`company-`)?JC(e,null,t):null;if(n)return`${n.title}: ${n.text}`;let r=$C[e]??QC[e];return r?Q(t,...r):`${Q(t,`Chưa tạo được cuộc trò chuyện`,`The conversation could not be created`)} (${e}).`}function tw(e,t){let n=QC[e?.reasonCode??``];return n?Q(t,...n):null}var nw=(e,t)=>e?.state===`connecting`?Q(t,`Đang kết nối phiên công ty…`,`Connecting the company runtime…`):tw(e,t)??Q(t,`Chưa kết nối phiên công ty. Bấm để kết nối.`,`The company runtime is not connected. Select to connect.`);function rw({locale:e,onConnected:t}){let[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(!1),o=(0,v.useRef)(!1),s=()=>{o.current&&(o.current=!1,t())};if((0,v.useEffect)(()=>{let e=!0,t=()=>void Hg().then(t=>{e&&(r(t),t?.state===`ready`?s():t&&(o.current=!0))}).catch(()=>void 0);t();let n=window.setInterval(t,5e3);return()=>{e=!1,window.clearInterval(n)}},[]),!n||n.state===`ready`||n.state===`unconfigured`)return null;let c=async()=>{a(!0);try{let e=await Ug();r(e),e.state===`ready`&&s()}catch{r(await Hg().catch(()=>null)??n)}finally{a(!1)}},l=tw(n,e),u=i||n.state===`connecting`;return(0,U.jsxs)(mC,{severity:`warning`,role:`status`,sx:{mb:2},action:(0,U.jsx)($,{color:`inherit`,size:`small`,disabled:u,onClick:()=>void c(),sx:{whiteSpace:`nowrap`},children:u?Q(e,`Đang kết nối…`,`Connecting…`):Q(e,`Kết nối lại`,`Reconnect`)}),children:[Q(e,`Chế độ công ty đang tắt nên chưa đọc hay gửi tiếp được cuộc trò chuyện này. Bấm Kết nối lại; macOS có thể hỏi quyền đọc key một lần.`,`Company mode is not running, so this conversation cannot be read or continued yet. Select Reconnect; macOS may ask once to read the key.`),l&&(0,U.jsxs)(U.Fragment,{children:[` `,l]})]})}var iw=Y((0,U.jsx)(`path`,{d:`M13 3.87v.02c0 .67.45 1.23 1.08 1.43C16.93 6.21 19 8.86 19 12c0 .52-.06 1.01-.17 1.49-.14.64.12 1.3.69 1.64l.01.01c.86.5 1.98.05 2.21-.91.17-.72.26-1.47.26-2.23 0-4.5-2.98-8.32-7.08-9.57-.95-.29-1.92.44-1.92 1.44m-2.06 15.05c-2.99-.43-5.42-2.86-5.86-5.84-.54-3.6 1.66-6.77 4.83-7.76.64-.19 1.09-.76 1.09-1.43v-.02c0-1-.97-1.73-1.93-1.44-4.51 1.38-7.66 5.86-6.98 10.96.59 4.38 4.13 7.92 8.51 8.51 3.14.42 6.04-.61 8.13-2.53.74-.68.61-1.89-.26-2.39-.58-.34-1.3-.23-1.8.22-1.47 1.34-3.51 2.05-5.73 1.72`}),`DataUsageRounded`),aw=Y((0,U.jsx)(`path`,{d:`M8.4 18.2c.38.5.6 1.12.6 1.8 0 1.66-1.34 3-3 3s-3-1.34-3-3 1.34-3 3-3c.44 0 .85.09 1.23.26l1.41-1.77c-.92-1.03-1.29-2.39-1.09-3.69l-2.03-.68c-.54.83-1.46 1.38-2.52 1.38-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3c0 .07 0 .14-.01.21l2.03.68c.64-1.21 1.82-2.09 3.22-2.32V5.91C9.96 5.57 9 4.4 9 3c0-1.66 1.34-3 3-3s3 1.34 3 3c0 1.4-.96 2.57-2.25 2.91v2.16c1.4.23 2.58 1.11 3.22 2.32L18 9.71V9.5c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3c-1.06 0-1.98-.55-2.52-1.37l-2.03.68c.2 1.29-.16 2.65-1.09 3.69l1.41 1.77Q17.34 17 18 17c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3c0-.68.22-1.3.6-1.8l-1.41-1.77c-1.35.75-3.01.76-4.37 0z`}),`HubRounded`),ow=Y((0,U.jsx)(`path`,{d:`M15.5 13.5c0 2-2.5 3.5-2.5 5h-2c0-1.5-2.5-3-2.5-5 0-1.93 1.57-3.5 3.5-3.5s3.5 1.57 3.5 3.5m-2.5 6h-2V21h2zm6-6.5c0 1.68-.59 3.21-1.58 4.42l1.42 1.42C20.18 17.27 21 15.23 21 13c0-2.74-1.23-5.19-3.16-6.84l-1.42 1.42C17.99 8.86 19 10.82 19 13m-3-8-4-4v3c-4.97 0-9 4.03-9 9 0 2.23.82 4.27 2.16 5.84l1.42-1.42C5.59 16.21 5 14.68 5 13c0-3.86 3.14-7 7-7v3z`}),`ModelTrainingOutlined`),sw=Y((0,U.jsx)(`path`,{d:`M12 2 4 5v6.09c0 5.05 3.41 9.76 8 10.91 4.59-1.15 8-5.86 8-10.91V5zm6 9.09c0 4-2.55 7.7-6 8.83-3.45-1.13-6-4.82-6-8.83v-4.7l6-2.25 6 2.25z`}),`ShieldOutlined`);function cw(e){return Gr(`MuiListItem`,e)}Kr(`MuiListItem`,[`root`,`dense`,`alignItemsFlexStart`,`divider`,`gutters`,`padding`,`secondaryAction`]);function lw(e){return Gr(`MuiListItemSecondaryAction`,e)}Kr(`MuiListItemSecondaryAction`,[`root`,`disableGutters`]);var uw=e=>{let{disableGutters:t,classes:n}=e;return ba({root:[`root`,t&&`disableGutters`]},lw,n)},dw=K(`div`,{name:`MuiListItemSecondaryAction`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.disableGutters&&t.disableGutters]}})({position:`absolute`,right:16,top:`50%`,transform:`translateY(-50%)`,variants:[{props:({ownerState:e})=>e.disableGutters,style:{right:0}}]}),fw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItemSecondaryAction`}),{className:r,component:i,...a}=n,o=v.useContext($d),s={...n,disableGutters:o.disableGutters},c=uw(s);return(0,U.jsx)(dw,{as:i,className:W(c.root,r),ownerState:s,ref:t,...a})});fw.muiName=`ListItemSecondaryAction`;var pw=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.alignItems===`flex-start`&&t.alignItemsFlexStart,n.divider&&t.divider,!n.disableGutters&&t.gutters,!n.disablePadding&&t.padding]},mw=e=>{let{alignItems:t,classes:n,dense:r,disableGutters:i,disablePadding:a,divider:o}=e;return ba({root:[`root`,r&&`dense`,!i&&`gutters`,!a&&`padding`,o&&`divider`,t===`flex-start`&&`alignItemsFlexStart`],secondaryAction:[`secondaryAction`]},cw,n)},hw=K(`div`,{name:`MuiListItem`,slot:`Root`,overridesResolver:pw})(ys(({theme:e})=>({display:`flex`,justifyContent:`flex-start`,alignItems:`center`,position:`relative`,textDecoration:`none`,width:`100%`,boxSizing:`border-box`,textAlign:`left`,variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>!e.disablePadding&&e.dense,style:{paddingTop:4,paddingBottom:4}},{props:({ownerState:e})=>!e.disablePadding&&!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>!e.disablePadding&&!!e.secondaryAction,style:{paddingRight:48}},{props:({ownerState:e})=>!!e.secondaryAction,style:{[`& > .${fc.root}`]:{paddingRight:48}}},{props:{alignItems:`flex-start`},style:{alignItems:`flex-start`}},{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:`padding-box`}},{props:({ownerState:e})=>e.button,style:{...Ks(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}}}}]}))),gw=K(fw,{name:`MuiListItem`,slot:`secondaryAction`})({}),_w=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListItem`}),{alignItems:r=`center`,children:i,className:a,component:o=`li`,dense:s=!1,disableGutters:c=!1,disablePadding:l=!1,divider:u=!1,secondaryAction:d,slotProps:f={},slots:p={},...m}=n,h=v.useContext($d),g=v.useMemo(()=>({dense:s||h.dense||!1,alignItems:r,disableGutters:c}),[r,h.dense,s,c]),_={...n,alignItems:r,dense:g.dense,disableGutters:c,disablePadding:l,divider:u,secondaryAction:d},y=mw(_),b={slots:p,slotProps:f},[x,S]=Xc(`root`,{ref:t,elementType:hw,externalForwardedProps:{component:o,...b,...m},ownerState:_,className:W(y.root,a)}),[C,w]=Xc(`secondaryAction`,{elementType:gw,shouldForwardComponentProp:!0,externalForwardedProps:b,ownerState:_,className:y.secondaryAction});return(0,U.jsx)($d.Provider,{value:g,children:(0,U.jsxs)(x,{...S,children:[i,d&&(0,U.jsx)(C,{...w,children:d})]})})}),vw=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},yw=e=>{let{disabled:t,dense:n,divider:r,disableGutters:i,selected:a,classes:o}=e,s=ba({root:[`root`,n&&`dense`,t&&`disabled`,!i&&`gutters`,r&&`divider`,a&&`selected`]},pc,o);return{...o,...s}},bw=K(tu,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiMenuItem`,slot:`Root`,overridesResolver:vw})(ys(({theme:e})=>({...e.typography.body1,display:`flex`,justifyContent:`flex-start`,alignItems:`center`,position:`relative`,textDecoration:`none`,minHeight:48,paddingTop:6,paddingBottom:6,boxSizing:`border-box`,whiteSpace:`nowrap`,"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${mc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${mc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${mc.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${mc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${mc.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${Cu.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${Cu.inset}`]:{marginLeft:52},[`& .${bf.root}`]:{marginTop:0,marginBottom:0},[`& .${bf.inset}`]:{paddingLeft:36},[`& .${uf.root}`]:{minWidth:36},variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.divider,style:{borderBottom:`1px solid ${(e.vars||e).palette.divider}`,backgroundClip:`padding-box`}},{props:({ownerState:e})=>!e.dense,style:{[e.breakpoints.up(`sm`)]:{minHeight:`auto`}}},{props:({ownerState:e})=>e.dense,style:{minHeight:32,paddingTop:4,paddingBottom:4,...e.typography.body2,[`& .${uf.root} svg`]:{fontSize:`1.25rem`}}}]}))),xw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiMenuItem`}),{autoFocus:r=!1,component:i=`li`,dense:a=!1,divider:o=!1,disableGutters:s=!1,focusVisibleClassName:c,role:l=`menuitem`,tabIndex:u,className:d,...f}=n,p=l===`menuitemcheckbox`||l===`menuitemradio`?!!n.selected:void 0,m=nb(),h=v.useContext($d),g=v.useMemo(()=>({dense:a||h.dense||!1,disableGutters:s}),[h.dense,a,s]),_=ab(),y=Ed(),b=_.suppressInitialFocusVisible,x=_.itemsFocusableWhenDisabled,S=v.useRef(null);xs(()=>{r&&S.current&&Zy(S.current,m)},[r]);let C={...n,dense:g.dense,divider:o,disableGutters:s},w=yw(n),{root:T,...E}=w,D=Nf({id:y,ref:t,disabled:n.disabled,focusableWhenDisabled:x,selected:n.selected}),O=bs(S,D.ref),k;return u===void 0?_.variant===`selectedMenu`?k=D.tabIndex:(!n.disabled||x)&&(k=-1):k=u,(0,U.jsx)($d.Provider,{value:g,children:(0,U.jsx)(bw,{ref:O,role:l,"aria-checked":p,tabIndex:k,component:i,internalNativeButton:!1,focusableWhenDisabled:x,suppressFocusVisible:b,focusVisibleClassName:W(w.focusVisible,c),className:W(w.root,d),...f,ownerState:C,classes:E})})}),Sw=Y((0,U.jsx)(`path`,{d:`m19.46 8 .79-1.75L22 5.46c.39-.18.39-.73 0-.91l-1.75-.79L19.46 2c-.18-.39-.73-.39-.91 0l-.79 1.75-1.76.79c-.39.18-.39.73 0 .91l1.75.79.79 1.76c.18.39.74.39.92 0M11.5 9.5 9.91 6c-.35-.78-1.47-.78-1.82 0L6.5 9.5 3 11.09c-.78.36-.78 1.47 0 1.82l3.5 1.59L8.09 18c.36.78 1.47.78 1.82 0l1.59-3.5 3.5-1.59c.78-.36.78-1.47 0-1.82zm7.04 6.5-.79 1.75-1.75.79c-.39.18-.39.73 0 .91l1.75.79.79 1.76c.18.39.73.39.91 0l.79-1.75 1.76-.79c.39-.18.39-.73 0-.91l-1.75-.79-.79-1.76c-.18-.39-.74-.39-.92 0`}),`AutoAwesomeRounded`),Cw=Y((0,U.jsx)(`path`,{d:`M12 6c2.62 0 4.88 1.86 5.39 4.43l.3 1.5 1.53.11c1.56.1 2.78 1.41 2.78 2.96 0 1.65-1.35 3-3 3H6c-2.21 0-4-1.79-4-4 0-2.05 1.53-3.76 3.56-3.97l1.07-.11.5-.95C8.08 7.14 9.94 6 12 6m0-2C9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96C18.67 6.59 15.64 4 12 4`}),`CloudOutlined`),ww=Y((0,U.jsx)(`path`,{d:`M8.7 15.9 4.8 12l3.9-3.9c.39-.39.39-1.01 0-1.4a.984.984 0 0 0-1.4 0l-4.59 4.59c-.39.39-.39 1.02 0 1.41l4.59 4.6c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4m6.6 0 3.9-3.9-3.9-3.9a.984.984 0 0 1 0-1.4c.39-.39 1.01-.39 1.4 0l4.59 4.59c.39.39.39 1.02 0 1.41l-4.59 4.6c-.39.39-1.01.39-1.4 0a.984.984 0 0 1 0-1.4`}),`CodeRounded`),Tw=Y((0,U.jsx)(`path`,{d:`M7 5h10v1c0 .55.45 1 1 1s1-.45 1-1V3c0-1.1-.9-1.99-2-1.99L7 1c-1.1 0-2 .9-2 2v3c0 .55.45 1 1 1s1-.45 1-1zm9.12 10.88 3.17-3.17c.39-.39.39-1.02 0-1.41l-3.17-3.17c-.39-.39-1.03-.39-1.42 0s-.39 1.02 0 1.41L17.17 12l-2.47 2.47c-.39.39-.39 1.02 0 1.41s1.03.39 1.42 0m-6.83-1.42L6.83 12l2.46-2.46c.39-.39.39-1.02 0-1.41s-1.03-.39-1.42 0L4.7 11.3c-.39.39-.39 1.02 0 1.41l3.17 3.17c.39.39 1.03.39 1.42 0 .4-.39.39-1.03 0-1.42M17 19H7v-1c0-.55-.45-1-1-1s-1 .45-1 1v3c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2v-3c0-.55-.45-1-1-1s-1 .45-1 1z`}),`DeveloperModeRounded`),Ew=Y((0,U.jsx)(`path`,{d:`M10.59 4.59C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z`}),`FolderRounded`),Dw=Y((0,U.jsx)(`path`,{d:`M12 1.27a11 11 0 00-3.48 21.46c.55.09.73-.28.73-.55v-1.84c-3.03.64-3.67-1.46-3.67-1.46-.55-1.29-1.28-1.65-1.28-1.65-.92-.65.1-.65.1-.65 1.1 0 1.73 1.1 1.73 1.1.92 1.65 2.57 1.2 3.21.92a2 2 0 01.64-1.47c-2.47-.27-5.04-1.19-5.04-5.5 0-1.1.46-2.1 1.2-2.84a3.76 3.76 0 010-2.93s.91-.28 3.11 1.1c1.8-.49 3.7-.49 5.5 0 2.1-1.38 3.02-1.1 3.02-1.1a3.76 3.76 0 010 2.93c.83.74 1.2 1.74 1.2 2.94 0 4.21-2.57 5.13-5.04 5.4.45.37.82.92.82 2.02v3.03c0 .27.1.64.73.55A11 11 0 0012 1.27`}),`GitHub`),Ow=Y((0,U.jsx)(`path`,{d:`M4 20h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2s.9 2 2 2m0-3h2v2H4zM2 6c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2m4 1H4V5h2zm-2 7h16c1.1 0 2-.9 2-2s-.9-2-2-2H4c-1.1 0-2 .9-2 2s.9 2 2 2m0-3h2v2H4z`}),`StorageRounded`),kw={anthropic:`#d97757`,claude:`#d97757`,context7:`#7456f1`,chrome:`#4285f4`,deepseek:`#4d6bfe`,figma:`#1e1e1e`,gemini:`#4285f4`,github:`#24292f`,google:`#4285f4`,groq:`#f55036`,linear:`#5e6ad2`,mistral:`#f7a000`,notion:`#111111`,openai:`#10a37f`,slack:`#611f69`};function Aw(){return(0,U.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":`true`,children:[(0,U.jsx)(`path`,{fill:`#f24e1e`,d:`M5 2h7v7H8.5A3.5 3.5 0 0 1 5 5.5V2Z`}),(0,U.jsx)(`path`,{fill:`#ff7262`,d:`M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2Z`}),(0,U.jsx)(`path`,{fill:`#a259ff`,d:`M5 9h7v7H8.5A3.5 3.5 0 0 1 5 12.5V9Z`}),(0,U.jsx)(`circle`,{cx:`15.5`,cy:`12.5`,r:`3.5`,fill:`#1abcfe`}),(0,U.jsx)(`path`,{fill:`#0acf83`,d:`M5 16h7v3.5A3.5 3.5 0 1 1 5 16Z`})]})}function jw(e){let t=e.toLowerCase();return t.includes(`figma`)?(0,U.jsx)(Aw,{}):t.includes(`github`)?(0,U.jsx)(Dw,{fontSize:`inherit`}):t.includes(`chrome`)||t.includes(`devtools`)?(0,U.jsx)(Tw,{fontSize:`inherit`}):t.includes(`anthropic`)||t.includes(`claude`)?(0,U.jsx)(Sw,{fontSize:`inherit`}):t.includes(`file`)||t.includes(`folder`)?(0,U.jsx)(Ew,{fontSize:`inherit`}):t.includes(`postgres`)||t.includes(`database`)||t.includes(`supabase`)?(0,U.jsx)(Ow,{fontSize:`inherit`}):t.includes(`code`)||t.includes(`context7`)?(0,U.jsx)(ww,{fontSize:`inherit`}):t.includes(`google`)||t.includes(`drive`)||t.includes(`cloud`)?(0,U.jsx)(Cw,{fontSize:`inherit`}):(0,U.jsx)(aw,{fontSize:`inherit`})}function Mw({name:e,size:t=34}){let n=e.toLowerCase(),r=Object.keys(kw).find(e=>n.includes(e));return(0,U.jsx)(J,{"aria-hidden":`true`,sx:{width:t,height:t,flex:`0 0 ${t}px`,display:`grid`,placeItems:`center`,borderRadius:t>30?2:1.4,bgcolor:r?kw[r]:`action.selected`,color:r?`#fff`:`text.secondary`,fontSize:Math.round(t*.52),border:1,borderColor:r?`transparent`:`divider`},children:jw(e)})}var Nw=Y((0,U.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8m3.88-11.71L10 14.17l-1.88-1.88a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l2.59 2.59c.39.39 1.02.39 1.41 0L17.3 9.7c.39-.39.39-1.02 0-1.41s-1.03-.39-1.42 0`}),`CheckCircleOutlineRounded`),Pw=Y((0,U.jsx)(`path`,{d:`M18 19H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h5c.55 0 1-.45 1-1s-.45-1-1-1H5c-1.11 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-6c0-.55-.45-1-1-1s-1 .45-1 1v5c0 .55-.45 1-1 1M14 4c0 .55.45 1 1 1h2.59l-9.13 9.13c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0L19 6.41V9c0 .55.45 1 1 1s1-.45 1-1V3h-6c-.55 0-1 .45-1 1`}),`LaunchRounded`);function Fw(e){return Gr(`MuiDialogActions`,e)}Kr(`MuiDialogActions`,[`root`,`spacing`]);var Iw=e=>{let{classes:t,disableSpacing:n}=e;return ba({root:[`root`,!n&&`spacing`]},Fw,t)},Lw=K(`div`,{name:`MuiDialogActions`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableSpacing&&t.spacing]}})({display:`flex`,alignItems:`center`,padding:8,justifyContent:`flex-end`,flex:`0 0 auto`,variants:[{props:({ownerState:e})=>!e.disableSpacing,style:{"& > :not(style) ~ :not(style)":{marginLeft:8}}}]}),Rw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogActions`}),{className:r,disableSpacing:i=!1,...a}=n,o={...n,disableSpacing:i},s=Iw(o);return(0,U.jsx)(Lw,{className:W(s.root,r),ownerState:o,ref:t,...a})});function zw(e){return Gr(`MuiDialogContent`,e)}Kr(`MuiDialogContent`,[`root`,`dividers`]);function Bw(e){return Gr(`MuiDialogTitle`,e)}var Vw=Kr(`MuiDialogTitle`,[`root`]),Hw=e=>{let{classes:t,dividers:n}=e;return ba({root:[`root`,n&&`dividers`]},zw,t)},Uw=K(`div`,{name:`MuiDialogContent`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.dividers&&t.dividers]}})(ys(({theme:e})=>({flex:`1 1 auto`,WebkitOverflowScrolling:`touch`,overflowY:`auto`,padding:`20px 24px`,variants:[{props:({ownerState:e})=>e.dividers,style:{padding:`16px 24px`,borderTop:`1px solid ${(e.vars||e).palette.divider}`,borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>!e.dividers,style:{[`.${Vw.root} + &`]:{paddingTop:0}}}]}))),Ww=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogContent`}),{className:r,dividers:i=!1,...a}=n,o={...n,dividers:i},s=Hw(o);return(0,U.jsx)(Uw,{className:W(s.root,r),ownerState:o,ref:t,...a})}),Gw=e=>{let{classes:t}=e;return ba({root:[`root`]},Bw,t)},Kw=K(X,{name:`MuiDialogTitle`,slot:`Root`})({padding:`16px 24px`,flex:`0 0 auto`}),qw=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogTitle`}),{className:r,id:i,...a}=n,o=n,s=Gw(o),{titleId:c=i}=v.useContext(PC);return(0,U.jsx)(Kw,{component:`h2`,className:W(s.root,r),ownerState:o,ref:t,variant:`h6`,id:i??c,...a})});function Jw(e){return Gr(`PrivateSwitchBase`,e)}Kr(`PrivateSwitchBase`,[`root`,`checked`,`disabled`,`input`,`edgeStart`,`edgeEnd`]);var Yw=e=>{let{classes:t,checked:n,disabled:r,edge:i}=e;return ba({root:[`root`,n&&`checked`,r&&`disabled`,i&&`edge${q(i)}`],input:[`input`]},Jw,t)},Xw=K(tu,{name:`MuiSwitchBase`})({padding:9,borderRadius:`50%`,variants:[{props:{edge:`start`,size:`small`},style:{marginLeft:-3}},{props:({edge:e,ownerState:t})=>e===`start`&&t.size!==`small`,style:{marginLeft:-12}},{props:{edge:`end`,size:`small`},style:{marginRight:-3}},{props:({edge:e,ownerState:t})=>e===`end`&&t.size!==`small`,style:{marginRight:-12}}]}),Zw=K(`input`,{name:`MuiSwitchBase`,shouldForwardProp:Jo})({cursor:`inherit`,position:`absolute`,opacity:0,width:`100%`,height:`100%`,top:0,left:0,margin:0,padding:0,zIndex:1}),Qw=v.forwardRef(function(e,t){let{autoFocus:n,checked:r,checkedIcon:i,defaultChecked:a,disabled:o,disableFocusRipple:s=!1,edge:c=!1,icon:l,id:u,name:d,onBlur:f,onChange:p,onFocus:m,readOnly:h,required:g=!1,tabIndex:_,type:v,value:y,slots:b={},slotProps:x={},...S}=e,{nativeButton:C,...w}=S,[T,E]=Od({controlled:r,default:!!a,name:`SwitchBase`,state:`checked`}),D=_s(),O=e=>{m&&m(e),D&&D.onFocus&&D.onFocus(e)},k=e=>{f&&f(e),D&&D.onBlur&&D.onBlur(e)},A=e=>{if(e.nativeEvent.defaultPrevented||h)return;let t=e.target.checked;E(t),p&&p(e,t)},j=o;D&&j===void 0&&(j=D.disabled);let M=v===`checkbox`||v===`radio`,N={...e,checked:T,disabled:j,disableFocusRipple:s,edge:c},P=Yw(N),F={slots:b,slotProps:x},[I,L]=Xc(`root`,{ref:t,elementType:Xw,className:P.root,shouldForwardComponentProp:!0,externalForwardedProps:{...F,component:`span`,...w},getSlotProps:e=>({...e,onFocus:t=>{e.onFocus?.(t),O(t)},onBlur:t=>{e.onBlur?.(t),k(t)}}),ownerState:N,additionalProps:{centerRipple:!0,focusRipple:!s,role:void 0,tabIndex:null}}),[R,ee]=Xc(`input`,{elementType:Zw,className:P.input,externalForwardedProps:F,getSlotProps:e=>({...e,onChange:t=>{e.onChange?.(t),A(t)}}),ownerState:N,additionalProps:{autoFocus:n,checked:r,defaultChecked:a,disabled:j,id:M?u:void 0,name:d,readOnly:h,required:g,tabIndex:_,type:v,...v===`checkbox`&&y===void 0?{}:{value:y}}});return(0,U.jsxs)(I,{...L,children:[(0,U.jsx)(R,{...ee}),T?i:l]})});function $w(e){return Gr(`MuiSwitch`,e)}var eT=Kr(`MuiSwitch`,[`root`,`edgeStart`,`edgeEnd`,`switchBase`,`colorPrimary`,`colorSecondary`,`sizeSmall`,`sizeMedium`,`checked`,`disabled`,`input`,`thumb`,`track`]),tT=e=>{let{classes:t,edge:n,size:r,color:i,checked:a,disabled:o}=e,s=ba({root:[`root`,n&&`edge${q(n)}`,`size${q(r)}`],switchBase:[`switchBase`,`color${q(i)}`,a&&`checked`,o&&`disabled`],thumb:[`thumb`],track:[`track`],input:[`input`]},$w,t);return{...t,...s}},nT=K(`span`,{name:`MuiSwitch`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.edge&&t[`edge${q(n.edge)}`],t[`size${q(n.size)}`]]}})({display:`inline-flex`,width:58,height:38,overflow:`hidden`,padding:12,boxSizing:`border-box`,position:`relative`,flexShrink:0,zIndex:0,verticalAlign:`middle`,"@media print":{colorAdjust:`exact`},variants:[{props:{edge:`start`},style:{marginLeft:-8}},{props:{edge:`end`},style:{marginRight:-8}},{props:{size:`small`},style:{width:40,height:24,padding:7,[`& .${eT.thumb}`]:{width:16,height:16},[`& .${eT.switchBase}`]:{padding:4,[`&.${eT.checked}`]:{transform:`translateX(16px)`}}}}]}),rT=K(Qw,{name:`MuiSwitch`,slot:`SwitchBase`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.switchBase,{[`& .${eT.input}`]:t.input},n.color!=="default"&&t[`color${q(n.color)}`]]}})(ys(({theme:e})=>({position:`absolute`,top:0,left:0,zIndex:1,color:e.vars?e.vars.palette.Switch.defaultColor:`${e.palette.mode===`light`?e.palette.common.white:e.palette.grey[300]}`,...Ks(e,[`left`,`transform`],{duration:e.transitions.duration.shortest}),[`&.${eT.checked}`]:{transform:`translateX(20px)`},[`&.${eT.disabled}`]:{color:e.vars?e.vars.palette.Switch.defaultDisabledColor:`${e.palette.mode===`light`?e.palette.grey[100]:e.palette.grey[600]}`},[`&.${eT.checked} + .${eT.track}`]:{opacity:.5},[`&.${eT.disabled} + .${eT.track}`]:{opacity:e.vars?e.vars.opacity.switchTrackDisabled:`${e.palette.mode===`light`?.12:.2}`},[`& .${eT.input}`]:{left:`-100%`,width:`300%`}})),ys(({theme:e})=>({"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:`transparent`}},variants:[...Object.entries(e.palette).filter(Ac([`light`])).map(([t])=>({props:{color:t},style:{[`&.${eT.checked}`]:{color:(e.vars||e).palette[t].main,"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity),"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${eT.disabled}`]:{color:e.vars?e.vars.palette.Switch[`${t}DisabledColor`]:`${e.palette.mode===`light`?e.lighten(e.palette[t].main,.62):e.darken(e.palette[t].main,.55)}`}},[`&.${eT.checked} + .${eT.track}`]:{backgroundColor:(e.vars||e).palette[t].main}}}))]}))),iT=K(`span`,{name:`MuiSwitch`,slot:`Track`})(ys(({theme:e})=>({height:`100%`,width:`100%`,borderRadius:7,zIndex:-1,...Ks(e,[`opacity`,`background-color`],{duration:e.transitions.duration.shortest}),"@media (forced-colors: active)":{boxSizing:`border-box`,border:`1px solid ButtonBorder`},backgroundColor:e.vars?e.vars.palette.common.onBackground:`${e.palette.mode===`light`?e.palette.common.black:e.palette.common.white}`,opacity:e.vars?e.vars.opacity.switchTrack:`${e.palette.mode===`light`?.38:.3}`}))),aT=K(`span`,{name:`MuiSwitch`,slot:`Thumb`})(ys(({theme:e})=>({boxShadow:(e.vars||e).shadows[1],backgroundColor:`currentColor`,boxSizing:`border-box`,border:`1px solid transparent`,width:20,height:20,borderRadius:`50%`}))),oT=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiSwitch`}),{className:r,color:i=`primary`,edge:a=!1,size:o=`medium`,sx:s,slots:c={},slotProps:l={},...u}=n,d={...n,color:i,edge:a,size:o},f=tT(d),p=l.input,m={slots:c,slotProps:l},[h,g]=Xc(`root`,{className:W(f.root,r),elementType:nT,externalForwardedProps:m,ownerState:d,additionalProps:{sx:s}}),[_,v]=Xc(`thumb`,{className:f.thumb,elementType:aT,externalForwardedProps:m,ownerState:d}),y=(0,U.jsx)(_,{...v}),[b,x]=Xc(`track`,{className:f.track,elementType:iT,externalForwardedProps:m,ownerState:d});return(0,U.jsxs)(h,{...g,children:[(0,U.jsx)(rT,{type:`checkbox`,icon:y,checkedIcon:y,ref:t,ownerState:d,...u,classes:{...f,root:f.switchBase},slots:{...c.switchBase&&{root:c.switchBase},...c.input&&{input:c.input}},slotProps:{...l.switchBase&&{root:typeof l.switchBase==`function`?l.switchBase(d):l.switchBase},input:kd(typeof p==`function`?p(d):p,{role:`switch`})}}),(0,U.jsx)(b,{...x})]})});function sT(e,t){let n=e.name.toLowerCase();return n===`figma-desktop`?Q(t,`Cần bật MCP trong Figma Desktop`,`Enable MCP in Figma Desktop`):n===`figma`?e.state===`disabled`?Q(t,`Remote OAuth · chưa được Figma duyệt`,`Remote OAuth · not approved by Figma`):`Remote OAuth`:`${e.transport} · ${e.scope}`}function cT(e,t,n){return e===`mcp-oauth-client-not-approved`&&t.toLowerCase()===`figma`?Q(n,`Figma Remote chưa cho phép Piagent đăng ký OAuth. Có thể dùng kết nối Figma Desktop bên dưới.`,`Figma Remote has not approved Piagent as an OAuth client. You can use the Figma Desktop connection below.`):e===`mcp-oauth-client-not-approved`?Q(n,`Nhà cung cấp chưa cho phép client OAuth này.`,`The provider has not approved this OAuth client.`):e===`mcp-oauth-registration-rejected`?Q(n,`Nhà cung cấp từ chối đăng ký OAuth.`,`The provider rejected OAuth client registration.`):e===`mcp-oauth-cancelled`||e===`cancelled-by-user`?Q(n,`Đã hủy đăng nhập.`,`Sign in cancelled.`):Q(n,`Không thể kết nối OAuth. Vui lòng thử lại.`,`Could not connect OAuth. Please try again.`)}function lT({sessionRef:e,connection:t,onChanged:n,compact:r=!1}){let{locale:i}=Kv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,t=window.setTimeout(()=>void i_(s.jobRef,e.signal).then(e=>{c(e),e.state===`completed`&&n()}).catch(()=>u(Q(i,`Mất kết nối OAuth`,`OAuth flow disconnected`))),750);return()=>{e.abort(),window.clearTimeout(t)}},[s?.jobRef,s?.generatedAt,s?.state,i,n]);let d=async r=>{o(!0),u(null);try{let i=await r_({action:r?`mcp.enable`:`mcp.disable`,sessionRef:e,connectionRef:t.connectionRef});`connections`in i?n(i):n()}catch{u(Q(i,`Không thể cập nhật MCP`,`Could not update MCP`))}finally{o(!1)}},f=async()=>{o(!0),u(null);try{let n=await r_({action:`mcp.oauth`,sessionRef:e,connectionRef:t.connectionRef});if(`jobRef`in n)c(n);else throw Error(`mcp-oauth-job-missing`)}catch{u(Q(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{o(!1)}},p=async()=>{s?.state===`running`&&await o_(s.jobRef).catch(()=>void 0),c(void 0),u(null)};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{direction:`row`,spacing:.75,sx:{alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`},children:[t.authState===`connected`&&(0,U.jsx)(lu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,U.jsx)(Nw,{}),label:Q(i,`Đã kết nối`,`Connected`)}),t.oauthSupported&&t.authState!==`connected`&&t.state!==`disabled`&&(0,U.jsx)($,{size:`small`,variant:`outlined`,disabled:a,onClick:()=>void f(),children:`OAuth`}),t.toggleSupported&&(0,U.jsx)(Ah,{title:t.state===`disabled`?Q(i,`Bật ${t.name}`,`Enable ${t.name}`):Q(i,`Tắt ${t.name}`,`Disable ${t.name}`),arrow:!0,children:(0,U.jsx)(`span`,{children:(0,U.jsx)(oT,{size:r?`small`:`medium`,checked:t.state!==`disabled`,disabled:a,onChange:(e,t)=>void d(t),slotProps:{input:{"aria-label":t.state===`disabled`?Q(i,`Bật ${t.name}`,`Enable ${t.name}`):Q(i,`Tắt ${t.name}`,`Disable ${t.name}`)}}})})})]}),l&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,children:l}),(0,U.jsxs)(BC,{open:!!s,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,U.jsxs)(qw,{children:[t.name,` · OAuth`]}),(0,U.jsx)(Ww,{children:(0,U.jsxs)(Z,{spacing:1.25,sx:{pt:.5},children:[s?.state===`running`&&!s.authorizationUrl&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(i,`Đang chuẩn bị đăng nhập…`,`Preparing sign in…`)}),s?.authorizationUrl&&(0,U.jsx)($,{component:`a`,href:s.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,variant:`contained`,endIcon:(0,U.jsx)(Pw,{}),children:Q(i,`Mở trang đăng nhập`,`Open sign in`)}),s?.state===`completed`&&(0,U.jsx)(X,{color:`success.main`,children:Q(i,`Đã kết nối MCP`,`MCP connected`)}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,U.jsx)(X,{color:`error`,children:cT(s.reasonCode,t.name,i)})]})}),(0,U.jsx)(Rw,{children:(0,U.jsx)($,{color:`inherit`,onClick:()=>void p(),children:s?.state===`running`?Q(i,`Hủy`,`Cancel`):Q(i,`Đóng`,`Close`)})})]})]})}var uT=Y((0,U.jsx)(`path`,{d:`M12 5.99 19.53 19H4.47zM2.74 18c-.77 1.33.19 3 1.73 3h15.06c1.54 0 2.5-1.67 1.73-3L13.73 4.99c-.77-1.33-2.69-1.33-3.46 0zM11 11v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1m0 5h2v2h-2z`}),`WarningAmberRounded`);function dT(e){return Gr(`MuiDialogContentText`,e)}Kr(`MuiDialogContentText`,[`root`]);var fT=e=>{let{classes:t}=e,n=ba({root:[`root`]},dT,t);return{...t,...n}},pT=K(X,{shouldForwardProp:e=>Jo(e)||e===`classes`,name:`MuiDialogContentText`,slot:`Root`})({}),mT=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiDialogContentText`}),{children:r,className:i,...a}=n,o=fT(a);return(0,U.jsx)(pT,{component:`p`,variant:`body1`,color:`textSecondary`,ref:t,ownerState:a,className:W(o.root,i),...n,classes:o})});function hT({open:e,title:t,description:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){return(0,U.jsxs)(BC,{open:e,onClose:o,fullWidth:!0,maxWidth:`xs`,"aria-describedby":`piagent-confirm-dialog-description`,slotProps:{paper:{sx:{borderRadius:3,p:.5}}},children:[(0,U.jsxs)(qw,{sx:{display:`flex`,alignItems:`center`,gap:1.25,pb:1},children:[(0,U.jsx)(J,{sx:{width:36,height:36,borderRadius:2,display:`grid`,placeItems:`center`,bgcolor:`warning.main`,color:`warning.contrastText`},children:(0,U.jsx)(uT,{fontSize:`small`})}),(0,U.jsx)(X,{component:`span`,sx:{fontSize:`1.08rem`,fontWeight:700},children:t})]}),(0,U.jsx)(Ww,{children:(0,U.jsx)(mT,{id:`piagent-confirm-dialog-description`,sx:{color:`text.secondary`,lineHeight:1.65},children:n})}),(0,U.jsxs)(Rw,{sx:{px:2.5,pb:2,gap:.75},children:[(0,U.jsx)($,{color:`inherit`,onClick:o,autoFocus:!0,children:i}),(0,U.jsx)($,{variant:`contained`,color:`warning`,onClick:a,children:r})]})]})}function gT({name:e,value:t}){return(0,U.jsxs)(Z,{direction:`row`,sx:{justifyContent:`space-between`,gap:3,py:.65},children:[(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:e}),(0,U.jsx)(X,{variant:`body2`,sx:{fontWeight:600},children:t})]})}function _T({title:e,label:t,icon:n,active:r,badge:i,onClick:a}){let o={border:1,borderColor:r?`primary.main`:`divider`,bgcolor:r?`action.selected`:`transparent`,color:r?`primary.main`:`text.secondary`,borderRadius:2,"&:hover":{bgcolor:`action.hover`,color:`text.primary`}},s=t?(0,U.jsx)($,{size:`small`,"aria-label":e,onClick:a,startIcon:n,sx:{...o,minHeight:34,minWidth:{xs:34,md:64},maxWidth:260,px:{xs:.75,md:1.15},"& .MuiButton-startIcon":{mr:{xs:0,md:.65},ml:0},"& .MuiButton-startIcon svg":{fontSize:17}},children:(0,U.jsx)(J,{component:`span`,sx:{display:{xs:`none`,md:`inline`},overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})}):(0,U.jsx)(Qd,{size:`small`,"aria-label":e,onClick:a,sx:{...o,width:34,height:34},children:n});return(0,U.jsx)(Ah,{title:e,arrow:!0,children:i?(0,U.jsx)(rl,{badgeContent:i,color:`primary`,max:9999,sx:{"& .MuiBadge-badge":{height:16,minWidth:16,px:.4,fontSize:9,fontWeight:700}},children:s}):s})}function vT({session:e,snapshot:t,connections:n,locale:r,onOpenChanges:i,canSetModel:a,canSetThinking:o,canSetPermission:s,onSetModel:c,onSetThinking:l,onSetPermission:u,onConnectionsChanged:d,placement:f=`composer`}){let[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(f!==`header`)return;let e=new AbortController;return Pg(e.signal).then(y).catch(()=>void 0),()=>e.abort()},[f]);let E=e=>t=>{m(e),g(t.currentTarget)},D=()=>{m(null),g(null)},O=t?.sourceChanges,k=O?.workingTree.counts.files??0,A=t?.session.permissionProfile,[j,M]=(0,v.useState)(A?.state===`known`?A.value??null:null);(0,v.useEffect)(()=>{M(null)},[e.sessionRef]),(0,v.useEffect)(()=>{A?.state===`known`&&M(A.value??null)},[A?.state,A?.value]),(0,v.useEffect)(()=>{e.managedPermission&&M(e.managedPermission)},[e.managedPermission]);let N=t?.usage.context,P=N?.state===`known`,F=P?N.tokens:e.contextUsage.usedTokens,I=P?N.contextWindow:e.contextUsage.contextWindow,L=P?N.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,R=L==null?`—`:`${Math.round(L)}%`,ee=t?.session.model.state===`known`&&t.session.model.value?t.session.model.value.modelRef:``,te=_?.models.find(e=>e.modelRef===ee)??(_?.models.length===1?_.models[0]:void 0),z=e.modelLabel===`agent-watch-auto`||_?.models.length===1&&_.models[0].provider===`agent_watch_managed`,B=(0,v.useMemo)(()=>e.managedThinkingLevels??te?.thinkingLevels??(z?[]:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),[te,e.managedThinkingLevels,z]),V=async e=>{if(!(!e||!c)){x(!0),C(null);try{await c(e)}catch{C(Q(r,`Chưa thể đổi model lúc này`,`Could not change the model right now`))}finally{x(!1)}}},ne=async e=>{if(l){x(!0),C(null);try{await l(e)}catch{C(Q(r,`Chưa thể đổi thinking lúc này`,`Could not change thinking right now`))}finally{x(!1)}}},re=async e=>{if(u){x(!0),C(null);try{await u(e),M(e)}catch{C(Q(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{x(!1)}}},ie=e=>{if(e===`trusted-full-access`){D(),T(e);return}re(e)},ae=p===`model`?`Model & thinking`:p===`context`?`Context`:p===`connections`?Q(r,`MCP & kết nối`,`MCP & connections`):p===`permission`?Q(r,`Quyền`,`Access`):Q(r,`Source Changes`,`Source Changes`);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(J,{sx:{display:`flex`,gap:.65,mb:f===`composer`?.8:0,px:.1,flexWrap:f===`header`?`nowrap`:`wrap`,flexShrink:0,alignItems:`center`,justifyContent:f===`header`?`flex-end`:`flex-start`},children:[f===`header`&&z&&(e.managedHelpers?.maximum??2)>0&&(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,title:Q(r,`Subagent đang chạy trong phiên này; Studio giới hạn tổng số theo thành viên.`,`Subagents running in this session; Studio caps the total per member.`),sx:{whiteSpace:`nowrap`,display:{xs:`none`,sm:`block`},mr:.5},children:[Q(r,`Subagent`,`Subagents`),` `,e.managedHelpers?.active??0,`/`,e.managedHelpers?.maximum??2]}),f===`header`&&(0,U.jsx)(_T,{active:p===`model`,onClick:E(`model`),icon:(0,U.jsx)(ow,{fontSize:`small`}),label:`${(z?`agent-watch-auto`:e.modelLabel)??Q(r,`Model session`,`Session model`)} · ${e.thinkingLevel===`unknown`||B.length>0&&!B.includes(e.thinkingLevel)?`—`:Iv(e.thinkingLevel,r)}`,title:z?`agent-watch-auto · Thinking`:Q(r,`Đổi model và mức suy luận`,`Change model and thinking level`)}),f===`header`&&(0,U.jsx)(_T,{active:p===`permission`,onClick:E(`permission`),icon:(0,U.jsx)(sw,{fontSize:`small`}),label:z?yT(j,r):j?Iv(j,r):Q(r,`Quyền`,`Access`),title:Q(r,`Đổi quyền truy cập`,`Change access level`)}),f===`composer`&&(0,U.jsx)(_T,{active:p===`context`,onClick:E(`context`),icon:(0,U.jsx)(iw,{fontSize:`small`}),title:`Context · ${R}`}),f===`composer`&&(0,U.jsx)(_T,{active:p===`connections`,onClick:E(`connections`),icon:(0,U.jsx)(aw,{fontSize:`small`}),badge:n?.summary.configured??0,title:(n?.summary.configured??0)>0?Q(r,`MCP & kết nối · ${n?.summary.configured}`,`MCP & connections · ${n?.summary.configured}`):Q(r,`MCP & kết nối`,`MCP & connections`)}),f===`composer`&&(0,U.jsx)(_T,{active:p===`changes`,onClick:E(`changes`),icon:(0,U.jsx)(Ph,{fontSize:`small`}),badge:k,title:`Source Changes${k?` · ${k}`:``}`})]}),(0,U.jsxs)(yb,{open:p!==null,anchorEl:h,onClose:D,anchorOrigin:{vertical:f===`header`?`bottom`:`top`,horizontal:`left`},transformOrigin:{vertical:f===`header`?`top`:`bottom`,horizontal:`left`},slotProps:{paper:{sx:{width:330,maxWidth:`calc(100vw - 24px)`,borderRadius:2.5,p:1.5,mt:+(f===`header`)}}},children:[(0,U.jsx)(X,{sx:{px:.5,pb:1,fontWeight:600},children:ae}),(0,U.jsx)(Du,{}),p===`model`&&(0,U.jsxs)(Z,{sx:{px:.5,pt:1},spacing:1.25,children:[z?(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{children:`agent-watch-auto`}),(0,U.jsx)(gT,{name:`Context`,value:I?new Intl.NumberFormat().format(I):`—`})]}):(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,U.jsx)(ox,{fullWidth:!0,size:`small`,value:ee,disabled:!a||b||e.liveState===`running`,onChange:e=>void V(e.target.value),sx:{mt:.5},children:(_?.models??[]).map(e=>(0,U.jsx)(xw,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,U.jsx)(ox,{fullWidth:!0,size:`small`,inputProps:{"aria-label":`Thinking`},value:e.thinkingLevel===`unknown`?``:e.thinkingLevel,disabled:!o||b||e.liveState===`running`,onChange:e=>void ne(e.target.value),sx:{mt:.5},children:B.map(e=>(0,U.jsx)(xw,{value:e,children:Iv(e,r)},e))})]}),S&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`context`&&(0,U.jsxs)(J,{sx:{px:.5,pt:.75},children:[(0,U.jsx)(gT,{name:Q(r,`Đã dùng`,`Used`),value:R}),(0,U.jsx)(gT,{name:`Tokens`,value:F===null?`—`:new Intl.NumberFormat().format(F)}),(0,U.jsx)(gT,{name:`Window`,value:I===null?`—`:new Intl.NumberFormat().format(I)})]}),p===`connections`&&(0,U.jsxs)(rf,{dense:!0,disablePadding:!0,sx:{pt:.5},children:[(n?.connections??[]).map(t=>(0,U.jsxs)(_w,{sx:{alignItems:`center`,gap:.5},children:[(0,U.jsx)(pf,{sx:{minWidth:38},children:(0,U.jsx)(Mw,{name:t.name,size:28})}),(0,U.jsx)(Cf,{primary:t.name,secondary:sT(t,r)}),(0,U.jsx)(lT,{compact:!0,sessionRef:e.sessionRef,connection:t,onChanged:e=>d?.(e)})]},t.connectionRef)),n&&n.connections.length===0&&(0,U.jsx)(_w,{children:(0,U.jsx)(Cf,{primary:Q(r,`Chưa có MCP`,`No MCP configured`)})}),!n&&(0,U.jsx)(_w,{children:(0,U.jsx)(Cf,{primary:Q(r,`Đang đọc…`,`Loading…`)})})]}),p===`permission`&&(0,U.jsxs)(Z,{sx:{px:.5,pt:1},spacing:.75,children:[(z?[`workspace-write`,`trusted-full-access`]:[`read-only`,`workspace-write`,`trusted-full-access`]).map(t=>(0,U.jsx)($,{variant:j===t?`contained`:`outlined`,color:t===`trusted-full-access`?`warning`:`primary`,disabled:!s||b||e.liveState===`running`,onClick:()=>ie(t),sx:{justifyContent:`flex-start`},children:z?yT(t,r):Iv(t,r)},t)),S&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`changes`&&(0,U.jsxs)(J,{sx:{px:.5,pt:.75},children:[(0,U.jsx)(gT,{name:Q(r,`Task changes`,`Task changes`),value:String(O?.task?.counts.files??0)}),(0,U.jsx)(gT,{name:Q(r,`Working tree`,`Working tree`),value:String(O?.workingTree.counts.files??0)}),(0,U.jsx)(gT,{name:Q(r,`Staged`,`Staged`),value:String(O?.staged.counts.files??0)}),(0,U.jsx)($,{fullWidth:!0,variant:`outlined`,startIcon:(0,U.jsx)(Ph,{}),sx:{mt:1},onClick:()=>{D(),i()},children:Q(r,`Mở Source Changes`,`Open Source Changes`)})]})]}),(0,U.jsx)(hT,{open:w!==null,title:z?Q(r,`Bật Bypass?`,`Turn on Bypass?`):Q(r,`Bật toàn quyền?`,`Enable full access?`),description:z?bT(r):Q(r,`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:Q(r,`Hủy`,`Cancel`),confirmLabel:z?Q(r,`Bật Bypass`,`Turn on Bypass`):Q(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>T(null),onConfirm:()=>{T(null),re(`trusted-full-access`)}})]})}function yT(e,t){return e===`trusted-full-access`?`Bypass`:Q(t,`Hỏi trước`,`Ask first`)}function bT(e){return Q(e,`Lệnh cần internet (cài package, tải file, git pull, test có server hay browser) chạy luôn, không hỏi. Vẫn hỏi trước khi đẩy hoặc gửi dữ liệu ra ngoài (git push, publish, deploy, upload, ssh), chạy migration database, xóa mà không rõ đích hoặc dùng sudo.`,`Commands that need the internet (package installs, downloads, git pull, tests with a server or browser) run without asking. You are still asked before anything that pushes or sends data out (git push, publish, deploy, uploads, ssh), database migrations, deletes whose target is unknown, and sudo.`)}function xT(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229}var ST=Y((0,U.jsx)(`path`,{d:`M19 11H7.83l4.88-4.88c.39-.39.39-1.03 0-1.42a.996.996 0 0 0-1.41 0l-6.59 6.59c-.39.39-.39 1.02 0 1.41l6.59 6.59c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41L7.83 13H19c.55 0 1-.45 1-1s-.45-1-1-1`}),`ArrowBackRounded`),CT=Y((0,U.jsx)(`path`,{d:`M12 7V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2zM6 19H4v-2h2zm0-4H4v-2h2zm0-4H4V9h2zm0-4H4V5h2zm4 12H8v-2h2zm0-4H8v-2h2zm0-4H8V9h2zm0-4H8V5h2zm9 12h-7v-2h2v-2h-2v-2h2v-2h-2V9h7c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1m-1-8h-2v2h2zm0 4h-2v2h2z`}),`BusinessRounded`),wT=Y((0,U.jsx)(`path`,{d:`M15.88 9.29 12 13.17 8.12 9.29a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.59 4.59c.39.39 1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41-.39-.38-1.03-.39-1.42 0`}),`ExpandMoreRounded`),TT=Y((0,U.jsx)(`path`,{d:`M20 6h-8l-2-2H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m0 12H4V8h16z`}),`FolderOpenOutlined`),ET=Y((0,U.jsx)(`path`,{d:`m11.19 1.36-7 3.11C3.47 4.79 3 5.51 3 6.3V11c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V6.3c0-.79-.47-1.51-1.19-1.83l-7-3.11c-.51-.23-1.11-.23-1.62 0M12 11.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11z`}),`SecurityRounded`),DT=Y((0,U.jsx)(`path`,{d:`M3 18c0 .55.45 1 1 1h5v-2H4c-.55 0-1 .45-1 1M3 6c0 .55.45 1 1 1h9V5H4c-.55 0-1 .45-1 1m10 14v-1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7v-1c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1M7 10v1H4c-.55 0-1 .45-1 1s.45 1 1 1h3v1c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1s-1 .45-1 1m14 2c0-.55-.45-1-1-1h-9v2h9c.55 0 1-.45 1-1m-5-3c.55 0 1-.45 1-1V7h3c.55 0 1-.45 1-1s-.45-1-1-1h-3V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1`}),`TuneRounded`);function OT(e){return Gr(`MuiListSubheader`,e)}Kr(`MuiListSubheader`,[`root`,`colorPrimary`,`colorInherit`,`gutters`,`inset`,`sticky`]);var kT=e=>{let{classes:t,color:n,disableGutters:r,inset:i,disableSticky:a}=e;return ba({root:[`root`,n!=="default"&&`color${q(n)}`,!r&&`gutters`,i&&`inset`,!a&&`sticky`]},OT,t)},AT=K(`li`,{name:`MuiListSubheader`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color!=="default"&&t[`color${q(n.color)}`],!n.disableGutters&&t.gutters,n.inset&&t.inset,!n.disableSticky&&t.sticky]}})(ys(({theme:e})=>({boxSizing:`border-box`,lineHeight:`48px`,listStyle:`none`,color:(e.vars||e).palette.text.secondary,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(14),variants:[{props:{color:`primary`},style:{color:(e.vars||e).palette.primary.main}},{props:{color:`inherit`},style:{color:`inherit`}},{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:16,paddingRight:16}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:72}},{props:({ownerState:e})=>!e.disableSticky,style:{position:`sticky`,top:0,zIndex:1,backgroundColor:(e.vars||e).palette.background.paper}}]}))),jT=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiListSubheader`}),{className:r,color:i=`default`,component:a=`li`,disableGutters:o=!1,disableSticky:s=!1,inset:c=!1,...l}=n,u={...n,color:i,component:a,disableGutters:o,disableSticky:s,inset:c},d=kT(u);return(0,U.jsx)(AT,{as:a,className:W(d.root,r),ref:t,ownerState:u,...l})}),MT=Y((0,U.jsx)(`path`,{d:`m19 9 1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25zm0 6-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25zm-7.5-5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12zm-1.51 3.49L9 15.17l-.99-2.18L5.83 12l2.18-.99L9 8.83l.99 2.18 2.18.99z`}),`AutoAwesomeOutlined`),NT=Y((0,U.jsx)(`path`,{d:`M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm4 18H6V4h7v5h5z`}),`DescriptionOutlined`),PT=Y((0,U.jsx)(`path`,{d:`m9.17 6 2 2H20v10H4V6zM10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8z`}),`FolderOutlined`);function FT(e,t){let n=e.slice(0,t),r=/(^|[\s(])@"([^"\n]*)$/.exec(n);if(r)return{start:r.index+r[1].length,end:e[t]===`"`?t+1:t,query:r[2],quoted:!0};let i=/(^|[\s(])@([^\s"]*)$/.exec(n);return i?{start:i.index+i[1].length,end:t+(/^[^\s"]*/.exec(e.slice(t))?.[0].length??0),query:i[2],quoted:!1}:null}function IT(e,t,n){let r=t.quoted||/\s/.test(n.value),i=r?`@"${n.value}"`:`@${n.value}`,a=n.kind===`directory`,o=e.slice(t.end),s=a||/^\s/.test(o)?``:` `;return{text:e.slice(0,t.start)+i+s+o,caret:t.start+i.length+s.length-(a&&r?1:0)}}function LT(e,t){let n=e.slice(0,t);return/^\/[^\s/]*$/.test(n)?{start:0,end:t+(/^[^\s]*/.exec(e.slice(t))?.[0].length??0),query:n.slice(1),quoted:!1}:null}function RT(e,t,n){let r=n.kind===`skill`?`/skill:${n.name}`:`/${n.name}`,i=e.slice(t.end);return{text:r+(/^\s/.test(i)?``:` `)+i,caret:r.length+1}}var zT=20,BT=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase();function VT(e,t,n){let r=BT(t.replace(/^skill:/,``)),i=e=>BT(e.name).startsWith(r)?0:BT(e.name).includes(r)?1:BT(e.description).includes(r)?2:3,a=e=>`${e.scope===`user`?`~/`:``}.${e.origin===`pi`?`pi`:e.origin}`;return e.filter(e=>i(e)<3&&(!t.startsWith(`skill:`)||e.kind===`skill`)).sort((e,t)=>i(e)-i(t)||e.name.localeCompare(t.name)).slice(0,zT).map(e=>({key:`${e.kind}:${e.name}`,icon:e.kind,label:e.kind===`skill`?`/skill:${e.name}`:`/${e.name}`,hint:e.argumentHint,detail:`${e.description}${e.description?` · `:``}${e.kind===`skill`?`skill`:Q(n,`lệnh`,`command`)} ${a(e)}`,apply:(t,n)=>RT(t,n,e)}))}function HT({projectRef:e,value:t,onChange:n,locale:r}){let i=(0,v.useRef)(null),a=(0,v.useId)(),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(0),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),y=e&&o!==null&&o<=t.length?o:null,b=y===null?null:LT(t,y),x=y===null||b?null:FT(t,y),S=b??x,C=b?`command`:`path`,w=S&&`${C}:${S.start}`!==u?S:null,T=w&&C===`path`?w.query:null;(0,v.useEffect)(()=>{if(T===null||!e){h(null);return}let t=new AbortController,n=setTimeout(()=>{L_(e,T,t.signal).then(e=>{h({query:T,items:e.suggestions.map(e=>({key:e.value,label:e.label,hint:null,icon:e.kind,detail:e.detail.slice(0,Math.max(0,e.detail.length-e.label.replace(/\/$/,``).length)),apply:(t,n)=>IT(t,n,e)}))}),p(0)}).catch(()=>{t.signal.aborted||h({query:T,items:[]})})},90);return()=>{clearTimeout(n),t.abort()}},[e,T]);let E=!!(w&&C===`command`&&e&&g?.projectRef!==e);(0,v.useEffect)(()=>{if(!E||!e)return;let t=new AbortController;return R_(e,t.signal).then(t=>_({projectRef:e,list:t.commands})).catch(()=>{t.signal.aborted||_({projectRef:e,list:[]})}),()=>t.abort()},[E,e]);let D=w?C===`path`?m?.items??null:g&&g.projectRef===e?VT(g.list,w.query,r):null:null;(0,v.useEffect)(()=>{p(0)},[C,w?.query]);let O=!!(c&&w&&D&&i.current),k=O?D:[];(0,v.useEffect)(()=>{O&&document.getElementById(`${a}-${f}`)?.scrollIntoView({block:`nearest`})},[O,f,a]);let A=e=>{if(!w)return;let r=e.apply(t,w);n(r.text),s(r.caret),requestAnimationFrame(()=>{let e=i.current;e&&(e.focus(),e.setSelectionRange(r.caret,r.caret),s(r.caret))})},j=e=>!O||e.nativeEvent.isComposing||e.keyCode===229?!1:e.key===`Escape`?(e.preventDefault(),d(`${C}:${w.start}`),!0):k.length?e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),p(t=>(t+(e.key===`ArrowDown`?1:k.length-1))%k.length),!0):(e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey&&(e.preventDefault(),A(k[Math.min(f,k.length-1)]),!0):!1,M=e=>e===`directory`?(0,U.jsx)(PT,{fontSize:`small`,color:`primary`}):e===`file`?(0,U.jsx)(NT,{fontSize:`small`,color:`action`}):e===`skill`?(0,U.jsx)(MT,{fontSize:`small`,color:`secondary`}):(0,U.jsx)(Fh,{fontSize:`small`,color:`primary`}),N=C===`command`?Q(r,`Lệnh và skill`,`Commands and skills`):Q(r,`File và folder`,`Files and folders`),P=i.current,F=(0,U.jsx)(vh,{open:O,anchorEl:P,placement:`top-start`,disablePortal:!0,sx:{zIndex:1350,width:Math.min(640,P?.clientWidth??640)},modifiers:[{name:`offset`,options:{offset:[0,10]}}],children:(0,U.jsxs)(Pc,{elevation:8,sx:{borderRadius:2,overflow:`hidden`,display:`flex`,flexDirection:`column`,maxHeight:340},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{px:1.5,pt:1,pb:.5},children:C===`command`?Q(r,`Lệnh và skill của project và trên máy này · Tab để chọn`,`Commands and skills of the project and on this computer · Tab to pick`):Q(r,`File và folder · gõ ~/ hoặc / để chọn folder khác trên máy · Tab để chọn`,`Files and folders · type ~/ or / for other folders on this computer · Tab to pick`)}),k.length?(0,U.jsx)(J,{component:`ul`,role:`listbox`,id:a,"aria-label":N,sx:{listStyle:`none`,m:0,p:.5,pt:0,overflowY:`auto`},children:k.map((e,t)=>(0,U.jsxs)(J,{component:`li`,id:`${a}-${t}`,role:`option`,"aria-selected":t===f,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>p(t),onClick:()=>A(e),sx:{display:`flex`,alignItems:`center`,gap:1,minWidth:0,px:1,py:.55,borderRadius:1.5,cursor:`pointer`,bgcolor:t===f?`action.selected`:`transparent`},children:[M(e.icon),(0,U.jsx)(X,{noWrap:!0,sx:{flexShrink:0,maxWidth:`55%`,fontSize:14,fontWeight:600},children:e.label}),e.hint&&(0,U.jsx)(X,{noWrap:!0,variant:`caption`,sx:{flexShrink:0,maxWidth:`25%`,fontFamily:`monospace`},children:e.hint}),(0,U.jsx)(X,{noWrap:!0,variant:`caption`,color:`text.secondary`,sx:{minWidth:0},children:e.detail})]},e.key))}):(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,pb:1.25},children:C===`command`?Q(r,`Không có lệnh hoặc skill khớp`,`No matching command or skill`):Q(r,`Không có file hoặc folder khớp`,`No matching file or folder`)})]})}),I=e=>s(e.target.selectionStart??null);return{inputRef:i,menu:F,onKeyDown:j,track:I,inputProps:{onFocus:()=>l(!0),onBlur:()=>l(!1)},htmlInput:{onSelect:I,"aria-autocomplete":`list`,"aria-controls":O&&k.length?a:void 0,"aria-activedescendant":O&&k.length?`${a}-${f}`:void 0}}}var UT=`new-chat`,WT=`piagent.composer-drafts.v1`,GT=50,KT=32768,qT=12096e5,JT=null,YT,XT=new Map;function ZT(){if(JT)return JT;JT=new Map;try{let e=JSON.parse(window.localStorage.getItem(WT)??`{}`),t=Date.now();for(let[n,r]of Object.entries(e??{}))typeof r?.text==`string`&&typeof r.savedAt==`number`&&t-r.savedAt<qT&&JT.set(n,{text:r.text.slice(0,KT),savedAt:r.savedAt})}catch{}return JT}function QT(){YT!==void 0&&(window.clearTimeout(YT),YT=void 0);try{let e=[...ZT()].sort((e,t)=>t[1].savedAt-e[1].savedAt).slice(0,GT);window.localStorage.setItem(WT,JSON.stringify(Object.fromEntries(e)))}catch{}}var $T=!1;function eE(){$T||($T=!0,window.addEventListener(`pagehide`,QT)),YT===void 0&&(YT=window.setTimeout(QT,300))}function tE(e){return ZT().get(e)?.text??``}function nE(e,t){let n=ZT();if(t.trim())n.set(e,{text:t.slice(0,KT),savedAt:Date.now()});else if(!n.delete(e))return;eE()}function rE(e){return XT.get(e)}function iE(e,t){t===null?XT.delete(e):XT.set(e,t)}var aE=`agent_watch_managed`;function oE(e,t,n){return e===`native-project-picker-unavailable`||e===`project-import-picker-failed`?Q(n,`Không mở được hộp chọn thư mục của máy. Thử lại; nếu vẫn lỗi, mở cuộc trò chuyện từ Terminal trong thư mục đó (pi hoặc piagent studio).`,`The folder picker could not open. Try again; if it still fails, start a conversation from a Terminal in that folder (pi or piagent studio).`):e===`project-import-folder-invalid`?Q(n,`Không dùng được thư mục này: thư mục gốc của ổ đĩa hoặc một liên kết (symlink). Chọn thư mục thật của project.`,`This folder cannot be used: a drive's root or a symbolic link. Choose the project's real folder.`):t===429?Q(n,`Thao tác quá nhanh. Đợi vài giây rồi thử lại.`,`Too many attempts. Wait a few seconds and try again.`):Q(n,`Không thể thêm thư mục. Thử lại; nếu vẫn lỗi, chạy piagent dashboard doctor.`,`Could not add this folder. Try again; if it still fails, run piagent dashboard doctor.`)}function sE({active:e,defaultProjectRef:t,busy:n,error:r,onCancel:i,onCreate:a}){let{locale:o}=Kv(),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(void 0),[d,f]=(0,v.useState)(!1),p=l===null&&s?.models.length===1&&s.models[0].provider===`agent_watch_managed`,[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(`high`),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(()=>tE(UT)),k=e=>{O(e),nE(UT,e)},[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(()=>rE(`new-chat`)??[]),[P,F]=(0,v.useState)(null);(0,v.useEffect)(()=>{iE(UT,M.length?M:null)},[M]);let[I,L]=(0,v.useState)(!1),R=(0,v.useRef)(0),[ee,te]=(0,v.useState)(null),[z,B]=(0,v.useState)(null),[V,ne]=(0,v.useState)(!1),[re,ie]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e)return;let n=new AbortController;return c(void 0),h(!1),ie(null),F(null),L(!1),w(!1),R.current=0,Pg(n.signal).then(e=>{n.signal.aborted||(c(e),_(e.projects.some(e=>e.projectRef===t)?t:e.projects[0]?.projectRef??``),b(e.defaultModelRef??``),S(e.defaultThinkingLevel??`high`),E(null))}).catch(()=>{n.signal.aborted||h(!0)}),u(void 0),Hg(n.signal).then(e=>{n.signal.aborted||u(e)}).catch(()=>{n.signal.aborted||u(null)}),()=>n.abort()},[e,t]),(0,v.useEffect)(()=>{if(!e)return;let t=e=>{dS(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,t),window.addEventListener(`drop`,t),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`drop`,t)}},[e]);let ae=s?.projects.find(e=>e.projectRef===g),oe=HT({projectRef:ae?.projectRef,value:D,onChange:k,locale:o}),se=s?.models.find(e=>e.modelRef===y),H=!p&&se?.provider===aE,ce=p?[]:s?.models.filter(e=>e.provider===aE)??[],le=p?s?.models??[]:s?.models.filter(e=>e.provider!==aE)??[],ue=async()=>{f(!0);try{let e=await Ug().catch(()=>null),t=await Pg();c(t),u(e??await Hg().catch(()=>null));let n=t.models.find(e=>e.provider===aE);n&&(b(n.modelRef),me())}catch{h(!0)}finally{f(!1)}},de=s?.models.find(e=>e.modelRef===s.defaultModelRef),fe=(0,v.useMemo)(()=>se?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[se]);(0,v.useEffect)(()=>{fe.includes(x)||S(fe.includes(`high`)?`high`:fe[0]??`off`)},[y,fe]);let pe=e=>t=>{te(e),B(t.currentTarget)},me=()=>{te(null),B(null)},he=async()=>{ne(!0),ie(null);try{let e=await Vg(),t=e.projects?.length?e.projects:[e.project];c(e=>e&&{...e,projects:[...e.projects.filter(e=>!t.some(t=>t.projectRef===e.projectRef)),...t]}),_(e.project.projectRef),me()}catch(e){e instanceof kg&&e.status===409?ie(null):ie(oE(e instanceof kg?e.code:null,e instanceof kg?e.status:0,o))}finally{ne(!1)}},ge=e=>{if(!e?.length)return;let t=[...M],n=!1;for(let r of[...e])if(!t.some(e=>e.name===r.name&&e.size===r.size&&e.lastModified===r.lastModified)){if(t.length===4){n=!0;continue}t.push(r)}N(t),F(n?Q(o,`Mỗi tin nhắn nhận tối đa 4 file.`,`Each message accepts at most 4 files.`):null)},_e=!n&&!m&&M.length<4,ve=(0,v.useRef)(!1),ye=()=>{ve.current||n||!ae||!D.trim()||(ve.current=!0,Promise.resolve(a({projectRef:g,placeRef:ae.placeRef,modelRef:y||null,thinkingLevel:x,permissionMode:T,message:D,files:M})).finally(()=>{ve.current=!1}))};return(0,U.jsxs)(J,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,U.jsx)(J,{sx:{p:{xs:1.5,sm:2}},children:(0,U.jsx)(Qd,{"aria-label":Q(o,`Quay lại`,`Back`),onClick:i,children:(0,U.jsx)(ST,{})})}),(0,U.jsxs)(Z,{sx:{flex:1,alignItems:`center`,justifyContent:`center`,px:2,pb:{xs:5,md:12}},spacing:4,children:[(0,U.jsx)(X,{component:`h1`,sx:{fontSize:{xs:`2rem`,md:`2.45rem`},fontWeight:500,letterSpacing:`-.035em`,textAlign:`center`},children:Q(o,`Hôm nay làm gì?`,`What should we work on?`)}),(0,U.jsxs)(J,{sx:{position:`relative`,width:`100%`,maxWidth:820,border:1,borderColor:I?`primary.main`:`divider`,borderStyle:I?`dashed`:`solid`,borderRadius:3.5,bgcolor:`background.paper`,p:1.25,boxShadow:`0 18px 55px rgba(0,0,0,.13)`},onDragEnter:e=>{dS(e.dataTransfer)&&(R.current+=1,L(!0))},onDragOver:e=>{dS(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=_e?`copy`:`none`)},onDragLeave:e=>{dS(e.dataTransfer)&&(--R.current,R.current<=0&&(R.current=0,L(!1)))},onDrop:e=>{dS(e.dataTransfer)&&(e.preventDefault(),R.current=0,L(!1),_e&&ge(e.dataTransfer.files))},children:[I&&(0,U.jsxs)(J,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3.5,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,U.jsx)(X,{sx:{fontWeight:750},children:_e?Q(o,`Thả tài liệu vào đây`,`Drop documents here`):M.length>=4?Q(o,`Đã đủ 4 file cho tin nhắn đầu tiên`,`The first message already holds 4 files`):Q(o,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),_e&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(o,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),!s&&!m?(0,U.jsxs)(Z,{direction:`row`,spacing:1.5,sx:{minHeight:126,alignItems:`center`,justifyContent:`center`},children:[(0,U.jsx)(xu,{size:20}),(0,U.jsx)(X,{color:`text.secondary`,children:Q(o,`Đang mở…`,`Opening…`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dx,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:3,maxRows:8,value:D,disabled:n||m,inputRef:oe.inputRef,...oe.inputProps,onChange:e=>{k(e.target.value),oe.track(e)},onKeyDown:e=>{oe.onKeyDown(e)||xT(e)&&(e.preventDefault(),ye())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),_e&&ge(e.clipboardData.files))},placeholder:Q(o,`Nhắn cho Piagent… (@ để chọn file, folder)`,`Message Piagent… (@ for files and folders)`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:{maxLength:32768,...oe.htmlInput}},sx:{px:.5}}),oe.menu,M.length>0&&(0,U.jsx)(Z,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pt:.75},"aria-label":Q(o,`File sẽ gửi cùng tin nhắn đầu tiên`,`Files for the first message`),children:M.map(e=>(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:`${e.name} · ${cS(e.size)}`,onDelete:n?void 0:()=>{N(t=>t.filter(t=>t!==e)),F(null)},deleteIcon:(0,U.jsx)(XS,{"aria-label":`${Q(o,`Bỏ`,`Remove`)} ${e.name}`,role:`button`})},`${e.name}:${e.size}:${e.lastModified}`))}),(0,U.jsx)(MC,{in:C,id:`piagent-new-session-options`,children:(0,U.jsxs)(J,{sx:{mx:.35,mt:1,px:1.1,py:1,borderRadius:2,bgcolor:`action.hover`},children:[(0,U.jsx)(X,{variant:`caption`,sx:{display:`block`,mb:.75,fontWeight:750},children:Q(o,`Tùy chọn cho tin nhắn đầu tiên`,`Options for the first message`)}),(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:(0,U.jsx)(DT,{}),endIcon:(0,U.jsx)(wT,{}),onClick:pe(`thinking`),children:Iv(x,o)}),(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:(0,U.jsx)(ET,{}),endIcon:(0,U.jsx)(wT,{}),onClick:pe(`permission`),children:p||H?yT(T,o):T?Iv(T,o):Q(o,`Quyền theo profile`,`Profile access`)}),(0,U.jsxs)($,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,U.jsx)(YS,{}),disabled:!_e,"aria-label":`${Q(o,`Thêm file`,`Add files`)} (${M.length}/4)`,children:[Q(o,`Đính kèm`,`Attach`),(0,U.jsx)(`input`,{type:`file`,hidden:!0,multiple:!0,disabled:!_e,accept:oS,onChange:e=>{ge(e.target.files),e.currentTarget.value=``}})]})]}),H&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.75},children:Q(o,`Model và quyền theo Harness công ty; thinking chọn ở đây.`,`Models and access follow the company Harness; choose thinking here.`)})]})}),(0,U.jsxs)(Z,{direction:`row`,sx:{mt:1,alignItems:`center`,gap:.65,flexWrap:`nowrap`,minWidth:0},children:[(0,U.jsx)(Ah,{title:C?Q(o,`Ẩn tùy chọn`,`Hide options`):Q(o,`Thêm tùy chọn`,`More options`),children:(0,U.jsx)(Qd,{size:`small`,"aria-label":C?Q(o,`Ẩn tùy chọn`,`Hide options`):Q(o,`Thêm tùy chọn`,`More options`),"aria-expanded":C,"aria-controls":`piagent-new-session-options`,onClick:()=>w(e=>!e),sx:{flex:`0 0 auto`,bgcolor:C?`action.selected`:`transparent`},children:(0,U.jsx)(JS,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:C?`rotate(45deg)`:`none`}})})}),(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:(0,U.jsx)(TT,{}),endIcon:(0,U.jsx)(wT,{}),onClick:pe(`project`),"aria-label":`${Q(o,`Project`,`Project`)}: ${ae?.label??Q(o,`Chọn project`,`Choose project`)}`,sx:{minWidth:0,maxWidth:{xs:118,sm:250},px:{xs:.75,sm:1},"& .MuiButton-startIcon":{display:{xs:`none`,sm:`inherit`}}},children:(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:ae?.label??Q(o,`Chọn project`,`Choose project`)})}),(0,U.jsx)($,{size:`small`,color:`inherit`,startIcon:H?(0,U.jsx)(CT,{}):(0,U.jsx)(ow,{}),endIcon:(0,U.jsx)(wT,{}),onClick:pe(`model`),"aria-label":`${Q(o,`Model`,`Model`)}: ${H?Q(o,`Công ty · agent-watch-auto`,`Company · agent-watch-auto`):se?.displayName??de?.displayName??Q(o,`Mặc định của Pi`,`Pi default`)}`,sx:{minWidth:0,maxWidth:{xs:142,sm:250},px:{xs:.75,sm:1},"& .MuiButton-startIcon":{display:{xs:`none`,sm:`inherit`}}},children:(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:H?Q(o,`Công ty · agent-watch-auto`,`Company · agent-watch-auto`):se?`${se.displayName}${se.modelRef===s?.defaultModelRef?Q(o,` · mặc định`,` · default`):``}`:de?.displayName??Q(o,`Mặc định của Pi`,`Pi default`)})}),(0,U.jsx)(J,{sx:{flex:1,minWidth:0}}),(0,U.jsx)(Qd,{"aria-label":Q(o,`Gửi`,`Send`),disabled:n||m||!ae||!D.trim(),onClick:ye,sx:{flex:`0 0 auto`,bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,U.jsx)(QS,{fontSize:`small`})})]})]}),(P||re||r||m)&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,sx:{display:`block`,px:.5,pt:1},children:P??re??r??Q(o,`Không tải được lựa chọn`,`Could not load choices`)})]})]}),(0,U.jsxs)(Db,{anchorEl:z,open:ee===`project`,onClose:me,slotProps:{paper:{sx:{width:310,maxHeight:380}}},children:[(s?.projects??[]).map(e=>(0,U.jsxs)(xw,{selected:g===e.projectRef,onClick:()=>{_(e.projectRef),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(Mw,{name:`folder`,size:26})}),(0,U.jsx)(Cf,{primary:e.label,secondary:e.hint,slotProps:{secondary:{noWrap:!0,title:e.hint}}})]},e.projectRef)),(0,U.jsx)(Du,{}),(0,U.jsxs)(xw,{disabled:V||s?.projectImport?.status!==`available`,onClick:()=>void he(),children:[(0,U.jsx)(pf,{children:(0,U.jsx)(JS,{})}),(0,U.jsx)(Cf,{primary:V?Q(o,`Đang chọn…`,`Choosing…`):Q(o,`Thêm một hoặc nhiều folder`,`Add one or more folders`)})]})]}),(0,U.jsxs)(Db,{anchorEl:z,open:ee===`model`,onClose:me,slotProps:{paper:{sx:{width:360,maxHeight:440}}},children:[!p&&(ce.length>0||l?.available)&&[(0,U.jsx)(jT,{children:Q(o,`Công ty`,`Company`)},`company-heading`),...ce.length?ce.map(e=>(0,U.jsxs)(xw,{selected:y===e.modelRef,onClick:()=>{b(e.modelRef),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(CT,{})}),(0,U.jsx)(Cf,{primary:`agent-watch-auto`,secondary:Q(o,`Harness công ty · Studio quản lý model`,`Company Harness · models managed by Studio`)})]},e.modelRef)):[(0,U.jsxs)(xw,{disabled:d,onClick:()=>void ue(),children:[(0,U.jsx)(pf,{children:d?(0,U.jsx)(xu,{size:20}):(0,U.jsx)(CT,{})}),(0,U.jsx)(Cf,{primary:`agent-watch-auto`,secondary:d?Q(o,`Đang kết nối…`,`Connecting…`):nw(l,o),slotProps:{secondary:{sx:{whiteSpace:`normal`}}}})]},`company-connect`)],(0,U.jsx)(jT,{children:Q(o,`Cá nhân`,`Personal`)},`personal-heading`)],!s?.defaultModelRef&&(0,U.jsxs)(xw,{selected:!y,onClick:()=>{b(``),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ow,{})}),(0,U.jsx)(Cf,{primary:Q(o,`Model mặc định của Pi`,`Pi default model`)})]}),le.map(e=>(0,U.jsxs)(xw,{selected:y===e.modelRef,onClick:()=>{b(e.modelRef),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(Mw,{name:e.provider,size:26})}),(0,U.jsx)(Cf,{primary:e.displayName,secondary:e.modelRef===s?.defaultModelRef?Q(o,`Mặc định · ${e.provider} · High`,`Default · ${e.provider} · High`):e.provider})]},e.modelRef))]}),(0,U.jsx)(Db,{anchorEl:z,open:ee===`thinking`,onClose:me,slotProps:{paper:{sx:{width:250,maxHeight:400}}},children:fe.map(e=>(0,U.jsxs)(xw,{value:e,selected:x===e,onClick:()=>{S(e),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(DT,{})}),(0,U.jsx)(Cf,{primary:Iv(e,o)})]},e))}),(0,U.jsx)(Db,{anchorEl:z,open:ee===`permission`,onClose:me,slotProps:{paper:{sx:{width:310}}},children:p||H?[(0,U.jsxs)(xw,{selected:T!==`trusted-full-access`,onClick:()=>{E(null),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ET,{})}),(0,U.jsx)(Cf,{primary:yT(null,o),secondary:Q(o,`Hỏi trước mỗi lệnh cần internet`,`Asks before each command that needs the internet`)})]},`ask`),(0,U.jsxs)(xw,{selected:T===`trusted-full-access`,onClick:()=>{me(),j(`trusted-full-access`)},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ET,{color:`warning`})}),(0,U.jsx)(Cf,{primary:`Bypass`,secondary:Q(o,`Chỉ hỏi việc bắt buộc phải xác nhận`,`Asks only what must be confirmed`)})]},`bypass`)]:(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(xw,{selected:T===null,onClick:()=>{E(null),me()},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ET,{})}),(0,U.jsx)(Cf,{primary:Q(o,`Theo profile project`,`Project profile default`)})]}),[`read-only`,`workspace-write`,`trusted-full-access`].map(e=>(0,U.jsxs)(xw,{selected:T===e,onClick:()=>{me(),e===`trusted-full-access`?j(e):E(e)},children:[(0,U.jsx)(pf,{children:(0,U.jsx)(ET,{})}),(0,U.jsx)(Cf,{primary:Iv(e,o)})]},e))]})}),(0,U.jsx)(hT,{open:A!==null,title:p||H?Q(o,`Tạo cuộc trò chuyện với Bypass?`,`Create with Bypass?`):Q(o,`Tạo session với toàn quyền?`,`Create with full access?`),description:p||H?bT(o):Q(o,`Session mới được phép đọc, sửa file và chạy command trong runtime. Xóa dữ liệu và gửi ra ngoài vẫn cần xác nhận riêng.`,`The new session may read and edit files and run commands. Deletion and external transfer still require separate approval.`),cancelLabel:Q(o,`Hủy`,`Cancel`),confirmLabel:p||H?Q(o,`Dùng Bypass`,`Use Bypass`):Q(o,`Dùng toàn quyền`,`Use full access`),onCancel:()=>j(null),onConfirm:()=>{j(null),E(`trusted-full-access`)}})]})}var cE=`piagent dashboard`;function lE(){return(0,v.useSyncExternalStore)(Dg,Eg,Eg)}function uE({locale:e}){let[t,n]=(0,v.useState)(!1);return(0,U.jsxs)(Z,{role:`alert`,spacing:2,sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,px:2,textAlign:`center`},children:[(0,U.jsx)(X,{variant:`h6`,component:`h1`,children:Q(e,`Tab này đã hết phiên đăng nhập`,`This tab is no longer signed in`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{maxWidth:520},children:Q(e,`Piagent vừa khởi động lại, phiên đã quá 8 giờ, hoặc tab được mở từ một link cũ. Các cuộc trò chuyện vẫn còn nguyên — mở lại Piagent để vào tiếp.`,`Piagent restarted, the session is older than 8 hours, or this tab came from an old link. Your conversations are kept — open Piagent again to continue.`)}),(0,U.jsxs)(J,{sx:{display:`flex`,gap:1,alignItems:`center`,flexWrap:`wrap`,justifyContent:`center`},children:[(0,U.jsx)(J,{component:`code`,sx:{px:1.5,py:.75,borderRadius:1,bgcolor:`action.hover`,fontSize:`.9rem`},children:cE}),(0,U.jsx)($,{size:`small`,variant:`outlined`,onClick:()=>{navigator.clipboard?.writeText(cE).then(()=>n(!0),()=>n(!1))},children:t?Q(e,`Đã chép`,`Copied`):Q(e,`Chép lệnh`,`Copy command`)})]}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Chạy lệnh trên trong terminal, hoặc bấm WebUI trong Agent Watch. Sau đó có thể đóng tab này.`,`Run it in a terminal, or choose WebUI in Agent Watch. You can close this tab afterwards.`)})]})}var dE=Y((0,U.jsx)(`path`,{d:`m12.35 15.65 2.79-2.79c.31-.31.09-.85-.35-.85H13V4c0-.55-.45-1-1-1s-1 .45-1 1v8H9.21c-.45 0-.67.54-.35.85l2.79 2.79c.19.2.51.2.7.01M21 3h-5.01c-.54 0-.99.45-.99.99 0 .55.45.99.99.99H20c.55 0 1 .45 1 1v12.03c0 .55-.45 1-1 1H4c-.55 0-1-.45-1-1V5.99c0-.55.45-1 1-1h4.01c.54 0 .99-.45.99-.99 0-.55-.45-1-.99-1H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2`}),`SystemUpdateAltRounded`);function fE(e={}){let{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:r,open:i,resumeHideDuration:a}=e,o=Cl();v.useEffect(()=>{if(!i)return;function e(e){e.defaultPrevented||e.key===`Escape`&&r?.(e,`escapeKeyDown`)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[i,r]);let s=cs((e,t)=>{r?.(e,t)}),c=cs(e=>{!r||e==null||o.start(e,()=>{s(null,`timeout`)})});v.useEffect(()=>(i&&c(t),o.clear),[i,t,c,o]);let l=e=>{r?.(e,`clickaway`)},u=o.clear,d=v.useCallback(()=>{t!=null&&c(a??t*.5)},[t,a,c]),f=e=>t=>{let n=e.onBlur;n?.(t),d()},p=e=>t=>{let n=e.onFocus;n?.(t),u()},m=e=>t=>{let n=e.onMouseEnter;n?.(t),u()},h=e=>t=>{let n=e.onMouseLeave;n?.(t),d()};return v.useEffect(()=>{if(!n&&i)return window.addEventListener(`focus`,d),window.addEventListener(`blur`,u),()=>{window.removeEventListener(`focus`,d),window.removeEventListener(`blur`,u)}},[n,i,d,u]),{getRootProps:(t={})=>{let n={...qc(e),...qc(t)};return{role:`presentation`,...t,...n,onBlur:f(n),onFocus:p(n),onMouseEnter:m(n),onMouseLeave:h(n)}},onClickAway:l}}function pE(e){return e.substring(2).toLowerCase()}function mE(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}function hE(e){let{children:t,disableReactTree:n=!1,mouseEvent:r=`onClick`,onClickAway:i,touchEvent:a=`onTouchEnd`}=e,o=v.useRef(!1),s=v.useRef(null),c=v.useRef(!1),l=v.useRef(!1);v.useEffect(()=>(setTimeout(()=>{c.current=!0},0),()=>{c.current=!1}),[]);let u=ss(Lu(t),s),d=cs(e=>{let t=l.current;l.current=!1;let r=ls(s.current);if(!c.current||!s.current||`clientX`in e&&mE(e,r))return;if(o.current){o.current=!1;return}let a;a=e.composedPath?e.composedPath().includes(s.current):!Ru(r.documentElement,e.target)||Ru(s.current,e.target),!a&&(n||!t)&&i(e)}),f=e=>n=>{l.current=!0;let r=t.props[e];r&&r(n)},p={ref:u};return a!==!1&&(p[a]=f(a)),v.useEffect(()=>{if(a!==!1){let e=pE(a),t=ls(s.current),n=()=>{o.current=!0};return t.addEventListener(e,d),t.addEventListener(`touchmove`,n),()=>{t.removeEventListener(e,d),t.removeEventListener(`touchmove`,n)}}},[d,a]),r!==!1&&(p[r]=f(r)),v.useEffect(()=>{if(r!==!1){let e=pE(r),t=ls(s.current);return t.addEventListener(e,d),()=>{t.removeEventListener(e,d)}}},[d,r]),v.cloneElement(t,p)}function gE(e){return Gr(`MuiSnackbarContent`,e)}Kr(`MuiSnackbarContent`,[`root`,`message`,`action`]);var _E=e=>{let{classes:t}=e;return ba({root:[`root`],action:[`action`],message:[`message`]},gE,t)},vE=K(Pc,{name:`MuiSnackbarContent`,slot:`Root`})(ys(({theme:e})=>{let t=e.palette.mode===`light`?.8:.98;return{...e.typography.body2,color:e.vars?e.vars.palette.SnackbarContent.color:e.palette.getContrastText(ki(e.palette.background.default,t)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:ki(e.palette.background.default,t),display:`flex`,alignItems:`center`,flexWrap:`wrap`,padding:`6px 16px`,flexGrow:1,[e.breakpoints.up(`sm`)]:{flexGrow:`initial`,minWidth:288}}})),yE=K(`div`,{name:`MuiSnackbarContent`,slot:`Message`})({padding:`8px 0`}),bE=K(`div`,{name:`MuiSnackbarContent`,slot:`Action`})({display:`flex`,alignItems:`center`,marginLeft:`auto`,paddingLeft:16,marginRight:-8}),xE=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiSnackbarContent`}),{action:r,className:i,message:a,role:o=`alert`,...s}=n,c=n,l=_E(c);return(0,U.jsxs)(vE,{role:o,elevation:6,className:W(l.root,i),ownerState:c,ref:t,...s,children:[(0,U.jsx)(yE,{className:l.message,ownerState:c,children:a}),r?(0,U.jsx)(bE,{className:l.action,ownerState:c,children:r}):null]})});function SE(e){return Gr(`MuiSnackbar`,e)}Kr(`MuiSnackbar`,[`root`,`anchorOriginTopCenter`,`anchorOriginBottomCenter`,`anchorOriginTopRight`,`anchorOriginBottomRight`,`anchorOriginTopLeft`,`anchorOriginBottomLeft`]);var CE=e=>{let{classes:t,anchorOrigin:n}=e;return ba({root:[`root`,`anchorOrigin${q(n.vertical)}${q(n.horizontal)}`]},SE,t)},wE=K(`div`,{name:`MuiSnackbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`anchorOrigin${q(n.anchorOrigin.vertical)}${q(n.anchorOrigin.horizontal)}`]]}})(ys(({theme:e})=>({zIndex:(e.vars||e).zIndex.snackbar,position:`fixed`,display:`flex`,left:8,right:8,justifyContent:`center`,alignItems:`center`,variants:[{props:({ownerState:e})=>e.anchorOrigin.vertical===`top`,style:{top:8,[e.breakpoints.up(`sm`)]:{top:24}}},{props:({ownerState:e})=>e.anchorOrigin.vertical!==`top`,style:{bottom:8,[e.breakpoints.up(`sm`)]:{bottom:24}}},{props:({ownerState:e})=>e.anchorOrigin.horizontal===`left`,style:{justifyContent:`flex-start`,[e.breakpoints.up(`sm`)]:{left:24,right:`auto`}}},{props:({ownerState:e})=>e.anchorOrigin.horizontal===`right`,style:{justifyContent:`flex-end`,[e.breakpoints.up(`sm`)]:{right:24,left:`auto`}}},{props:({ownerState:e})=>e.anchorOrigin.horizontal===`center`,style:{[e.breakpoints.up(`sm`)]:{left:`50%`,right:`auto`,transform:`translateX(-50%)`}}}]}))),TE=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiSnackbar`}),r=Go(),i={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{action:a,anchorOrigin:{vertical:o,horizontal:s}={vertical:`bottom`,horizontal:`left`},autoHideDuration:c=null,children:l,className:u,disableWindowBlurListener:d=!1,message:f,onBlur:p,onClose:m,onFocus:h,onMouseEnter:g,onMouseLeave:_,open:y,resumeHideDuration:b,slots:x={},slotProps:S={},transitionDuration:C=i,...w}=n,T={...n,anchorOrigin:{vertical:o,horizontal:s},autoHideDuration:c,disableWindowBlurListener:d,transitionDuration:C},E=CE(T),{getRootProps:D,onClickAway:O}=fE(T),[k,A]=v.useState(!0),j={slots:x,slotProps:S},[M,N]=Xc(`root`,{ref:t,className:[E.root,u],elementType:wE,getSlotProps:D,externalForwardedProps:{...j,...w},ownerState:T}),[P,{ownerState:F,...I}]=Xc(`clickAwayListener`,{elementType:hE,externalForwardedProps:j,getSlotProps:e=>({onClickAway:(...t)=>{let n=t[0];e.onClickAway?.(...t),!n?.defaultMuiPrevented&&O(...t)}}),ownerState:T}),[L,R]=Xc(`content`,{elementType:xE,shouldForwardComponentProp:!0,externalForwardedProps:j,additionalProps:{message:f,action:a},ownerState:T}),[ee,te]=Xc(`transition`,{elementType:mp,externalForwardedProps:j,getSlotProps:e=>({onEnter:(...t)=>{e.onEnter?.(...t),A(!1)},onExited:(...t)=>{e.onExited?.(...t),A(!0)}}),additionalProps:{appear:!0,in:y,timeout:C,direction:o===`top`?`down`:`up`},ownerState:T});return!y&&k?null:(0,U.jsx)(P,{...I,...x.clickAwayListener&&{ownerState:F},children:(0,U.jsx)(M,{...N,children:(0,U.jsx)(ee,{...te,children:l||(0,U.jsx)(L,{...R})})})})}),EE=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function DE(e,t){let n;if(t?.method===`POST`){let r=_g();if(!r)throw new EE(403,`mutation-authority-rejected`);n=await vg(e,{...t,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r}})}else n=await fetch(e,{...t,credentials:`same-origin`,headers:{Accept:`application/json`}});n.status===401&&Og();let r=await n.json().catch(()=>null);if(!n.ok)throw new EE(n.status,typeof r?.error?.code==`string`?r.error.code:`request-${n.status}`);return r}var OE=e=>DE(`/api/v1/updates`,{signal:e}),kE=()=>DE(`/api/v1/updates/check`,{method:`POST`,body:`{}`}),AE=e=>DE(`/api/v1/updates/apply`,{method:`POST`,body:JSON.stringify({version:e})}),jE=e=>e?.job?.state===`starting`||e?.job?.state===`running`,ME=(0,v.createContext)(null);function NE({children:e}){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(!0),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),d=(0,v.useRef)(!0),f=(0,v.useCallback)(async()=>{try{if(await Sg(),Eg())return;let e=await OE();d.current&&(n(e),i(!0))}catch(e){d.current&&e instanceof EE&&e.status===404&&i(!1)}},[]),p=jE(t),m=t!==null||!r;(0,v.useEffect)(()=>{d.current=!0,f();let e=setInterval(()=>void f(),m?p?3e3:6e4:2e3);return()=>{clearInterval(e)}},[f,p,m]),(0,v.useEffect)(()=>()=>{d.current=!1},[]);let h=(0,v.useCallback)(async()=>{o(!0),u(null);try{n(await kE())}catch(e){u(e instanceof Error?e.message:`update-unavailable`)}finally{o(!1)}},[]),g=(0,v.useCallback)(async()=>{let e=t?.piagent.latest;if(e){c(!0),u(null);try{await AE(e),await f()}catch(e){u(e instanceof Error?e.message:`update-unavailable`),await f()}finally{c(!1)}}},[t?.piagent.latest,f]),_=(0,v.useMemo)(()=>({status:t,supported:r,checking:a||!!t?.checking,applying:s,error:l,refresh:f,check:h,apply:g}),[t,r,a,s,l,f,h,g]);return(0,U.jsx)(ME.Provider,{value:_,children:e})}function PE(){let e=(0,v.useContext)(ME);if(!e)throw Error(`Piagent update state is missing`);return e}var FE=`~/.pi/piagent-update-job.log`;function IE(e,t){let n={"update-blocked-running":[`Đang có cuộc trò chuyện chạy. Cập nhật khi chúng xong, hoặc bấm Dừng.`,`A conversation is running. Update when it finishes, or stop it.`],"update-already-running":[`Một lần cập nhật khác đang chạy.`,`Another update is running.`],"update-version-changed":[`Đã có bản mới hơn bản bạn thấy. Kiểm tra lại rồi cập nhật.`,`A newer release appeared. Check again, then update.`],"update-not-available":[`Máy này đã ở bản mới nhất.`,`This machine is already up to date.`],"update-not-installable":[`Bản Piagent này không tự cập nhật được từ dashboard.`,`This Piagent cannot update itself from the dashboard.`]}[t];return n?Q(e,n[0],n[1]):Q(e,`Chưa cập nhật được. Thử lại sau.`,`The update could not start. Try again later.`)}function LE(e,t){return t.state===`succeeded`?t.reason===`dashboard-restart-failed`?{severity:`warning`,text:Q(e,`Đã cập nhật lên ${t.installed??t.to}, nhưng dashboard chưa tự mở lại. Chạy \`piagent dashboard restart\`.`,`Updated to ${t.installed??t.to}, but the dashboard did not restart. Run \`piagent dashboard restart\`.`)}:{severity:`success`,text:Q(e,`Đã cập nhật Piagent ${t.from} → ${t.installed??t.to}.`,`Updated Piagent ${t.from} → ${t.installed??t.to}.`)}:t.state===`failed`?{severity:`error`,text:`${t.reason===`update-interrupted`?Q(e,`Lần cập nhật bị ngắt giữa chừng.`,`The update was interrupted.`):t.reason===`update-version-mismatch`?Q(e,`Bản cài xong không đúng bản đã chọn.`,`The installed release is not the one chosen.`):Q(e,`Lệnh cập nhật báo lỗi.`,`The update command failed.`)} ${Q(e,`Chi tiết trong ${FE}.`,`Details are in ${FE}.`)}`}:null}function RE(e,t){if(!t)return Q(e,`chưa kiểm tra`,`not checked yet`);let n=Math.max(0,Math.round((Date.now()-Date.parse(t))/6e4));if(n<1)return Q(e,`vừa xong`,`just now`);if(n<60)return Q(e,`${n} phút trước`,`${n} min ago`);let r=Math.round(n/60);return r<48?Q(e,`${r} giờ trước`,`${r} h ago`):Q(e,`${Math.round(r/24)} ngày trước`,`${Math.round(r/24)} days ago`)}function zE({name:e,detail:t,chip:n,tone:r}){return(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:760},children:e}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:t})]}),(0,U.jsx)(lu,{size:`small`,label:n,color:r,variant:r==="default"?`outlined`:`filled`,sx:{alignSelf:{xs:`flex-start`,sm:`center`}}})]})}function BE(e,t){let n=[];return t.piagent.updateAvailable&&n.push(Q(e,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`)),t.pi.updateAvailable&&n.push(Q(e,`Pi ${t.pi.installed??`?`} → ${t.pi.required} (bản Piagent ${t.piagent.latest} yêu cầu)`,`Pi ${t.pi.installed??`?`} → ${t.pi.required} (the version Piagent ${t.piagent.latest} requires)`)),n.push(Q(e,`Dashboard khởi động lại và mở trong tab mới; tab này có thể đóng.`,`The dashboard restarts and opens in a new tab; this tab can be closed.`)),n}function VE(){let{locale:e}=Kv(),{status:t,supported:n,checking:r,applying:i,error:a,check:o,apply:s}=PE(),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)(null),d=jE(t);if((0,v.useEffect)(()=>{d&&!u.current?.closest(`[role=dialog]`)?.contains(document.activeElement)&&u.current?.focus()},[d]),!n)return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:3},children:Q(e,`Cập nhật`,`Updates`)}),(0,U.jsx)(mC,{severity:`info`,children:Q(e,`Gateway này chưa hỗ trợ kiểm tra cập nhật.`,`This Gateway does not check for updates.`)})]});let f=t?.job,p=f?LE(e,f):null,m=(t?.runningConversations??0)>0,h=t?[Q(e,`Đang dùng ${t.pi.installed??`—`}`,`Using ${t.pi.installed??`—`}`),t.pi.required?Q(e,`Piagent ${t.piagent.latest} cần ${t.pi.required}`,`Piagent ${t.piagent.latest} needs ${t.pi.required}`):null].filter(Boolean).join(` · `):`—`;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,ref:u,tabIndex:-1,sx:{mb:1},children:Q(e,`Cập nhật`,`Updates`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{mb:3},children:Q(e,`Piagent và Pi được cập nhật cùng nhau: Pi luôn lên đúng bản mà Piagent mới đã kiểm chứng.`,`Piagent and Pi update together: Pi always moves to the version the new Piagent is qualified on.`)}),(0,U.jsxs)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:[(0,U.jsx)(zE,{name:`Piagent`,detail:Q(e,`Đang dùng ${t?.piagent.installed??`—`}`,`Using ${t?.piagent.installed??`—`}`),chip:t?.piagent.updateAvailable?Q(e,`Có bản ${t.piagent.latest}`,`${t.piagent.latest} available`):t?.piagent.latest?Q(e,`Mới nhất`,`Up to date`):Q(e,`Chưa rõ`,`Unknown`),tone:t?.piagent.updateAvailable?`primary`:`default`}),(0,U.jsx)(Du,{}),(0,U.jsx)(zE,{name:`Pi`,detail:h,chip:t?.pi.updateAvailable?Q(e,`Lên ${t.pi.required}`,`To ${t.pi.required}`):Q(e,`Đúng bản`,`Matches`),tone:t?.pi.updateAvailable?`primary`:`default`}),t?.pi.newerUntested&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Du,{}),(0,U.jsx)(J,{sx:{px:2.25,py:1.5},children:(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Pi đã có bản ${t.pi.latest}, nhưng Piagent chưa kiểm chứng bản đó (chưa tương thích). Pi sẽ được nâng khi một bản Piagent hỗ trợ nó.`,`Pi ${t.pi.latest} is out, but Piagent is not qualified on it yet (not compatible). Pi moves when a Piagent release supports it.`)})})]}),(0,U.jsx)(Du,{}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Kiểm tra lần cuối: ${RE(e,t?.checkedAt??null)} · tự kiểm tra ${(t?.checkEveryHours??1)===1?`mỗi giờ`:`mỗi ${t?.checkEveryHours} giờ`}`,`Last checked: ${RE(e,t?.checkedAt??null)} · checks every ${(t?.checkEveryHours??1)===1?`hour`:`${t?.checkEveryHours} hours`}`)}),(0,U.jsx)($,{variant:`outlined`,disabled:r||d||!t?.installable,onClick:()=>void o(),startIcon:r?(0,U.jsx)(xu,{size:14}):void 0,children:Q(e,`Kiểm tra ngay`,`Check now`)})]})]}),(0,U.jsxs)(J,{sx:{mt:2.5,display:`grid`,gap:1.5},children:[t&&!t.installable&&(0,U.jsx)(mC,{severity:`info`,children:t.reason===`company-runtime`?Q(e,`Đây là runtime công ty; cập nhật từ dashboard Piagent.`,`This is the company runtime; update from the Piagent dashboard.`):Q(e,`Piagent này chạy từ mã nguồn (git). Cập nhật bằng git pull rồi cài lại.`,`This Piagent runs from a source checkout. Update it with git pull and reinstall.`)}),d&&(0,U.jsx)(mC,{severity:`info`,icon:(0,U.jsx)(xu,{size:18}),children:Q(e,`Đang cập nhật lên Piagent ${f?.to}… Xong, dashboard mở lại trong tab mới; tab này có thể đóng.`,`Updating to Piagent ${f?.to}… When done, the dashboard opens in a new tab; this tab can be closed.`)}),!d&&p&&(0,U.jsx)(mC,{severity:p.severity,children:p.text}),!d&&f?.bindingChanged&&(0,U.jsx)(mC,{severity:`warning`,children:Q(e,`Bản mới đổi trình khởi chạy công ty: mở Agent Watch và kết nối lại key công ty để tiếp tục dùng chế độ công ty.`,`The new release changed the company launcher: open Agent Watch and connect the company key again to keep company mode.`)}),a&&(0,U.jsx)(mC,{severity:`error`,role:`alert`,children:IE(e,a)}),t?.installable&&t.updateAvailable&&!d&&(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},gap:1.5},children:[(0,U.jsx)($,{variant:`contained`,size:`large`,startIcon:i?(0,U.jsx)(xu,{size:16,color:`inherit`}):(0,U.jsx)(dE,{}),disabled:i||m,onClick:()=>l(!0),children:Q(e,`Cập nhật lên Piagent ${t.piagent.latest}`,`Update to Piagent ${t.piagent.latest}`)}),m&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`${t.runningConversations} cuộc trò chuyện đang chạy; nút mở lại khi chúng xong.`,`${t.runningConversations} conversation(s) running; available once they finish.`)})]})]}),(0,U.jsxs)(BC,{open:c&&!!t,onClose:()=>l(!1),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-confirm`,children:[(0,U.jsx)(qw,{id:`piagent-update-confirm`,children:Q(e,`Cập nhật Piagent?`,`Update Piagent?`)}),(0,U.jsx)(Ww,{children:(0,U.jsx)(J,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:t&&BE(e,t).map(e=>(0,U.jsx)(X,{component:`li`,variant:`body2`,children:e},e))})}),(0,U.jsxs)(Rw,{children:[(0,U.jsx)($,{onClick:()=>l(!1),children:Q(e,`Để sau`,`Later`)}),(0,U.jsx)($,{variant:`contained`,onClick:()=>{l(!1),s()},children:Q(e,`Cập nhật`,`Update`)})]})]})]})}var HE=`piagent-update-snooze`,UE=`piagent-update-job-seen`,WE=36e5;function GE(e){try{return window.localStorage.getItem(e)}catch{return null}}function KE(e,t){try{window.localStorage.setItem(e,t)}catch{}}function qE(e,t){try{let n=JSON.parse(GE(HE)??`null`);return n?.version===e&&typeof n.until==`number`&&t<n.until}catch{return!1}}function JE({locale:e,onDetails:t}){let{status:n,applying:r,error:i,apply:a}=PE(),[o,s]=(0,v.useState)(()=>Date.now()),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(null);(0,v.useEffect)(()=>{let e=window.setInterval(()=>s(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let f=n?.piagent.latest??null,p=n?.job??null;(0,v.useEffect)(()=>{!p||p.state!==`succeeded`||GE(UE)===p.startedAt||(KE(UE,p.startedAt),d(Q(e,`Đã cập nhật Piagent ${p.from} → ${p.installed??p.to}.`,`Piagent updated ${p.from} → ${p.installed??p.to}.`)))},[p,e]);let m=!!(n?.installable&&n.updateAvailable&&f&&!jE(n))&&c!==f&&!qE(f,o),h=()=>{f&&(KE(HE,JSON.stringify({version:f,until:Date.now()+WE})),l(f))},g=(n?.runningConversations??0)>0;return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(BC,{open:m,onClose:h,fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-offer`,children:[(0,U.jsxs)(qw,{id:`piagent-update-offer`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,U.jsx)(dE,{color:`primary`}),Q(e,`Có bản Piagent mới: ${f}`,`Piagent ${f} is available`)]}),(0,U.jsxs)(Ww,{sx:{display:`grid`,gap:1.5},children:[(0,U.jsx)(J,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:n&&BE(e,n).map(e=>(0,U.jsx)(X,{component:`li`,variant:`body2`,children:e},e))}),g&&(0,U.jsx)(mC,{severity:`info`,children:Q(e,`${n?.runningConversations} cuộc trò chuyện đang chạy. Cập nhật khi chúng xong — dialog này sẽ nhắc lại.`,`${n?.runningConversations} conversation(s) running. Update once they finish — this will ask again.`)}),i&&(0,U.jsx)(mC,{severity:`error`,children:IE(e,i)})]}),(0,U.jsxs)(Rw,{sx:{flexWrap:`wrap`,gap:1},children:[(0,U.jsx)($,{onClick:h,children:Q(e,`Để sau (nhắc lại sau 1 giờ)`,`Later (ask again in an hour)`)}),(0,U.jsx)($,{onClick:()=>{l(f),t()},children:Q(e,`Xem chi tiết`,`Details`)}),(0,U.jsx)($,{variant:`contained`,disabled:g||r,onClick:()=>{l(f),a().then(t)},children:Q(e,`Cập nhật ngay`,`Update now`)})]})]}),(0,U.jsx)(TE,{open:u!==null,autoHideDuration:8e3,onClose:()=>d(null),anchorOrigin:{vertical:`top`,horizontal:`center`},children:(0,U.jsx)(mC,{severity:`success`,variant:`filled`,onClose:()=>d(null),children:u})})]})}var YE=Y((0,U.jsx)(`path`,{d:`M18.3 5.71a.996.996 0 0 0-1.41 0L12 10.59 7.11 5.7a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41L10.59 12 5.7 16.89c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0L12 13.41l4.89 4.89c.39.39 1.02.39 1.41 0s.39-1.02 0-1.41L13.41 12l4.89-4.89c.38-.38.38-1.02 0-1.4`}),`CloseRounded`),XE=fi({themeId:Wo});function ZE({active:e,snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i,refresh:a}){let{locale:o}=Kv();return e===`source`?(0,U.jsx)(oy,{snapshot:t,sessionRef:n,refreshSnapshot:a}):e===`documents`?(0,U.jsx)(Tx,{sessionRef:n}):e===`activity`?(0,U.jsx)(Mx,{snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i}):(0,U.jsxs)(Z,{spacing:2.25,children:[(0,U.jsx)(GS,{snapshot:t,locale:o}),(0,U.jsx)(US,{snapshot:t,locale:o}),(0,U.jsx)(zx,{snapshot:t})]})}var QE=`min(44vw, 860px)`;function $E({open:e,active:t,snapshot:n,state:r,sessionRef:i,terminalActivities:a,liveActivities:o,onClose:s,onActive:c,refresh:l}){let{locale:u}=Kv(),d=XE(Go().breakpoints.up(`xl`)),f=n?.sourceChanges.workingTree.counts.files??0,p=o===void 0?n?.activity.running.length??0:o.filter(e=>e.state===`running`).length;return(0,U.jsxs)(Kd,{anchor:`right`,variant:d?`persistent`:`temporary`,open:e,onClose:s,sx:{"& .MuiDrawer-paper":{width:{xs:`100%`,sm:`min(88vw, 980px)`,xl:QE},bgcolor:`background.default`}},children:[(0,U.jsxs)(J,{sx:{position:`sticky`,top:0,zIndex:3,bgcolor:`background.paper`,borderBottom:1,borderColor:`divider`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{minHeight:64,px:{xs:1.5,md:2},alignItems:`center`,gap:1},children:[(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:820},children:Q(u,`Agent Inspector`,`Agent Inspector`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(u,`Task contract · Git truth · verifier`,`Task contract · Git truth · verifier`)})]}),(0,U.jsx)(Ah,{title:Q(u,`Làm mới Inspector`,`Refresh Inspector`),children:(0,U.jsx)(Qd,{onClick:()=>void l(),children:(0,U.jsx)(ZS,{fontSize:`small`})})}),(0,U.jsx)(Qd,{"aria-label":Q(u,`Đóng Inspector`,`Close Inspector`),onClick:s,children:(0,U.jsx)(YE,{})})]}),(0,U.jsxs)(pg,{value:t,onChange:(e,t)=>c(t),variant:`scrollable`,scrollButtons:`auto`,children:[(0,U.jsx)(Kh,{value:`task`,icon:(0,U.jsx)(jh,{}),iconPosition:`start`,label:n?.task?`${Q(u,`Task`,`Task`)} · ${n.task.progress.completed}/${n.task.progress.total}`:Q(u,`Task`,`Task`)}),(0,U.jsx)(Kh,{value:`source`,icon:(0,U.jsx)(Ph,{}),iconPosition:`start`,label:`Source Changes${f?` · ${f}`:``}`}),(0,U.jsx)(Kh,{value:`documents`,icon:(0,U.jsx)(Nh,{}),iconPosition:`start`,label:Q(u,`Tài liệu`,`Documents`)}),(0,U.jsx)(Kh,{value:`activity`,icon:(0,U.jsx)(Fh,{}),iconPosition:`start`,label:`${Q(u,`Activity`,`Activity`)}${p?` · ${p}`:``}`})]})]}),r===`loading`?(0,U.jsxs)(Z,{sx:{alignItems:`center`,py:12},spacing:1.5,children:[(0,U.jsx)(xu,{size:25}),(0,U.jsx)(X,{color:`text.secondary`,children:Q(u,`Đang dựng Inspector từ session và Git…`,`Building the Inspector from the session and Git…`)})]}):(r===`error`||!n)&&i&&t===`activity`&&a?.length?(0,U.jsx)(J,{sx:{p:{xs:1.5,sm:2.5,xl:3},maxWidth:1500,mx:`auto`,width:`100%`},children:(0,U.jsx)(Mx,{sessionRef:i,terminalActivities:a,liveActivities:o})}):r===`error`||!n||!i?(0,U.jsxs)(Z,{sx:{p:3,maxWidth:720},spacing:2,children:[(0,U.jsx)(mC,{severity:`warning`,children:Q(u,`Không thể dựng Inspector cho session này. Chat vẫn an toàn; hãy kiểm tra project còn tồn tại và thử làm mới.`,`The Inspector could not be built for this session. Chat remains safe; check that the project still exists and refresh.`)}),(0,U.jsx)($,{variant:`outlined`,onClick:()=>void l(),children:Q(u,`Thử lại`,`Try again`)})]}):(0,U.jsx)(J,{sx:{p:t===`source`?{xs:1,md:1.5}:{xs:1.5,sm:2.5,xl:3},maxWidth:t===`source`?`none`:1500,mx:`auto`,width:`100%`},children:(0,U.jsx)(ZE,{active:t,snapshot:n,sessionRef:i,terminalActivities:a,liveActivities:o,refresh:l})})]})}var eD=Y((0,U.jsx)(`path`,{d:`M12 7c.55 0 1 .45 1 1v4c0 .55-.45 1-1 1s-1-.45-1-1V8c0-.55.45-1 1-1m-.01-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8m1-3h-2v-2h2z`}),`ErrorOutlineRounded`),tD=e=>Array.from({length:e},()=>({selected:[],other:``,otherOn:!1})),nD=e=>e.selected.length>0||e.otherOn&&e.other.trim().length>0;function rD({sessionRef:e,pending:t,locale:n,onDone:r}){let[i,a]=(0,v.useState)(()=>tD(t.questions.length)),[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(``),u=(0,v.useRef)([]),d=(0,v.useRef)(null),f=(0,v.useRef)([]),[p,m]=(0,v.useState)(0);(0,v.useEffect)(()=>{d.current?.scrollIntoView({block:`nearest`,behavior:`smooth`}),d.current?.focus({preventScroll:!0})},[]);let h=(e,t)=>a(n=>n.map((n,r)=>r===e?t(n):n)),g=(e,n)=>h(e,r=>t.questions[e].multiSelect?{...r,selected:r.selected.includes(n)?r.selected.filter(e=>e!==n):[...r.selected,n]}:{selected:[n],other:r.other,otherOn:!1}),_=(e,n=!0)=>{h(e,r=>t.questions[e].multiSelect?{...r,otherOn:n}:{selected:[],other:r.other,otherOn:n}),n&&setTimeout(()=>u.current[e]?.focus(),0)},y=i.every(nD),b=e=>{if(e.target.tagName===`INPUT`&&e.target.type===`text`)return;if(e.key===`Enter`){y&&(e.preventDefault(),S());return}let n=Number(e.target.closest(`fieldset`)?.getAttribute(`data-question`)??NaN),r=Number.isInteger(n)?n:p,a=Number(e.key),o=t.questions[r],s=o.options.length;if(!(!Number.isInteger(a)||a<1||a>s+1)){if(e.preventDefault(),a===s+1){_(r,!o.multiSelect||!i[r].otherOn);return}g(r,a-1),!o.multiSelect&&r+1<t.questions.length&&(m(r+1),f.current[r+1]?.focus({preventScroll:!1}))}},x=async(i,a)=>{s(a),l(``);try{await B_(e,t.questionRef,i),r()}catch(e){s(null),l(e.status===409?Q(n,`Câu hỏi này đã được trả lời hoặc lượt làm việc đã dừng.`,`This question was already answered or the turn stopped.`):Q(n,`Chưa gửi được câu trả lời. Thử lại.`,`The answer could not be sent. Try again.`))}},S=()=>{!y||o||x({answers:i.map(e=>({selected:[...e.selected].sort((e,t)=>e-t),...e.otherOn&&e.other.trim()?{other:e.other.trim()}:{}}))},`answer`)},C=t.questions.length;return(0,U.jsxs)(`article`,{className:`question-card`,ref:d,tabIndex:-1,onKeyDown:b,"aria-labelledby":`question-${t.questionRef}`,children:[(0,U.jsxs)(`header`,{children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`p`,{className:`section-kicker`,children:Q(n,`Main agent cần bạn quyết định`,`The main agent needs your decision`)}),(0,U.jsx)(`h2`,{id:`question-${t.questionRef}`,children:C>1?Q(n,`${C} câu hỏi`,`${C} questions`):Q(n,`1 câu hỏi`,`1 question`)})]}),(0,U.jsx)(`span`,{className:`question-hint`,children:Q(n,`Bấm số để chọn · Enter để gửi`,`Press a number to choose · Enter to send`)})]}),t.questions.map((e,r)=>{let a=i[r],o=`${t.questionRef}-${r}`,s=e.multiSelect?`checkbox`:`radio`;return(0,U.jsxs)(`fieldset`,{className:r===p?`question-block active`:`question-block`,"data-question":r,tabIndex:-1,ref:e=>{f.current[r]=e},onFocus:()=>m(r),children:[(0,U.jsxs)(`legend`,{children:[C>1&&(0,U.jsxs)(`span`,{className:`question-number`,children:[r+1,`.`]}),e.header&&(0,U.jsx)(`span`,{className:`question-chip`,children:e.header}),(0,U.jsx)(`span`,{className:`question-text`,children:e.question})]}),e.multiSelect&&(0,U.jsx)(`p`,{className:`question-multi`,children:Q(n,`Có thể chọn nhiều đáp án.`,`You can choose more than one.`)}),(0,U.jsxs)(`ol`,{className:`question-options`,children:[e.options.map((e,t)=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`label`,{className:a.selected.includes(t)?`selected`:void 0,children:[(0,U.jsx)(`input`,{type:s,name:o,checked:a.selected.includes(t),onChange:()=>g(r,t)}),(0,U.jsx)(`span`,{className:`option-number`,"aria-hidden":`true`,children:t+1}),(0,U.jsxs)(`span`,{className:`option-body`,children:[(0,U.jsx)(`strong`,{children:e.label}),e.description&&(0,U.jsx)(`small`,{children:e.description})]})]})},t)),(0,U.jsxs)(`li`,{className:`question-other`,children:[(0,U.jsxs)(`label`,{className:a.otherOn?`selected`:void 0,children:[(0,U.jsx)(`input`,{type:s,name:o,checked:a.otherOn,onChange:()=>_(r,!e.multiSelect||!a.otherOn)}),(0,U.jsx)(`span`,{className:`option-number`,"aria-hidden":`true`,children:e.options.length+1}),(0,U.jsx)(`span`,{className:`option-body`,children:(0,U.jsx)(`strong`,{children:Q(n,`Khác`,`Other`)})})]}),a.otherOn&&(0,U.jsx)(`input`,{type:`text`,ref:e=>{u.current[r]=e},maxLength:1e3,value:a.other,"aria-label":Q(n,`Câu trả lời khác cho câu ${r+1}`,`Other answer to question ${r+1}`),placeholder:Q(n,`Nhập câu trả lời của bạn`,`Type your answer`),onChange:e=>h(r,t=>({...t,other:e.target.value})),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),S())}})]})]})]},o)}),c&&(0,U.jsx)(`p`,{className:`form-error`,role:`alert`,children:c}),(0,U.jsxs)(`footer`,{children:[(0,U.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!o,onClick:()=>void x({skipped:!0},`skip`),children:o===`skip`?Q(n,`Đang gửi…`,`Sending…`):Q(n,`Để agent tự quyết`,`Let the agent decide`)}),(0,U.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:!y||!!o,onClick:S,children:o===`answer`?Q(n,`Đang gửi…`,`Sending…`):Q(n,`Gửi câu trả lời`,`Send answer`)})]})]})}function iD({sessionRef:e,waiting:t}){let{locale:n}=Kv(),[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(0);return(0,v.useEffect)(()=>{let t=new AbortController;return z_(e,t.signal).then(e=>i(e.questions??[]),()=>void 0),()=>t.abort()},[e,t,a]),(0,v.useEffect)(()=>{if(!t&&!r.length)return;let e=setInterval(()=>o(e=>e+1),r.length?4e3:1500);return()=>clearInterval(e)},[t,r.length]),r.length?(0,U.jsx)(`section`,{className:`question-stack`,"aria-label":Q(n,`Câu hỏi đang chờ bạn trả lời`,`Questions waiting for your answer`),"aria-live":`polite`,children:r.map(t=>(0,U.jsx)(rD,{sessionRef:e,pending:t,locale:n,onDone:()=>i(e=>e.filter(e=>e.questionRef!==t.questionRef))},t.questionRef))}):null}function aD(e,t){return e?.state===`ready`&&e.gatewayInstanceRef===t&&Number.isSafeInteger(e.eventSequence)&&e.eventSequence>=0&&Array.isArray(e.operations)&&Array.isArray(e.settlements)?e.eventSequence:null}function oD(e,t){return e&&!t?`connected`:`reconnecting`}var sD=100,cD=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/,lD=/^[a-z0-9][a-z0-9.-]{0,95}$/,uD=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function dD(e,t){return typeof t==`string`&&lD.test(t)?t:e===`aborted`?`operation-aborted`:e===`blocked`?`operation-blocked`:e===`error`?`operation-failed`:`operation-settlement-unknown`}function fD(e){if(e.settlement===`completed`||typeof e.operationRef!=`string`||!cD.test(e.operationRef)||typeof e.settledAt!=`string`||!uD.test(e.settledAt)||!Number.isSafeInteger(e.sequence)||Number(e.sequence)<1)return null;let t=[`blocked`,`aborted`,`error`,`unknown`].includes(String(e.settlement))?e.settlement:`unknown`,n=t===`error`?`failed`:t;return{activityRef:e.operationRef,operationRef:e.operationRef,settlement:t,state:n,reasonCode:dD(t,e.reasonCode),settledAt:e.settledAt,sequence:Number(e.sequence)}}function pD(e,t){let n=new Map;for(let r of[...e,...t])n.has(r.operationRef)||n.set(r.operationRef,r);return[...n.values()].sort((e,t)=>t.sequence-e.sequence).slice(0,sD)}function mD(e){if(e.state!==`ready`)return{};let t={};for(let n of e.settlements??[]){let e=fD(n);e&&(t[n.sessionRef]=pD(t[n.sessionRef]??[],[e]))}return t}function hD(e,t){let n=[`completed`,`blocked`,`aborted`,`error`].includes(String(t.settlement))?t.settlement:`unknown`;return{...e,operationRef:t.operationRef,abortable:!1,complete:!0,settlement:n,activities:[],delivery:e.user?`admitted`:e.delivery,assistant:n===`completed`?e.assistant:``,error:n===`completed`?null:String(t.reasonCode??`operation-settlement-unknown`)}}function gD(e,t){return{...e??{assistant:``,activities:[],operationRef:null,complete:!0,error:null},user:t.message,assistant:``,attachments:t.attachments,activities:[],operationRef:null,abortable:!1,complete:!1,settlement:null,error:null,messageRequestId:t.messageRequestId,delivery:`submitting`,startedAt:t.submittedAt,lastEventAt:t.submittedAt}}function _D(e,t,n,r){let i=t===`admitted`&&!!n&&e.operationRef===n&&e.complete;return{...e,delivery:t,operationRef:n??e.operationRef,abortable:t===`admitted`&&!i&&!!(n??e.operationRef),complete:t===`admitted`?i:e.complete,error:null,lastEventAt:r??e.lastEventAt}}function vD(e,t,n){return!e||e.messageRequestId!==n||e.delivery===`admitted`?e:t}function yD(e,t){if(t.state!==`ready`)return{...e};let n=new Map(t.operations.map(e=>[e.sessionRef,e])),r={...e};for(let[i,a]of Object.entries(e))n.has(i)||a.complete||a.delivery!==`submitting`&&(r[i]={...a,assistant:``,activities:[],operationRef:null,abortable:!1,complete:!0,settlement:`unknown`,error:`operation-settlement-unavailable`,lastEventAt:t.generatedAt});for(let n of t.operations){let i=e[n.sessionRef],a=!(n.messageRequestId&&i?.messageRequestId&&n.messageRequestId!==i.messageRequestId)&&(i?.operationRef===n.operationRef||!!(i?.user&&[`submitting`,`unconfirmed`].includes(String(i.delivery))));r[n.sessionRef]=a?{...i,operationRef:n.operationRef,abortable:n.abortable,complete:!1,settlement:null,messageRequestId:n.messageRequestId??i?.messageRequestId,delivery:i?.user?`admitted`:i?.delivery,error:null,lastEventAt:t.generatedAt}:{user:``,assistant:``,attachments:[],activities:[],operationRef:n.operationRef,messageRequestId:n.messageRequestId??null,abortable:n.abortable,complete:!1,settlement:null,error:null,runtimeRecovery:null,startedAt:t.generatedAt,lastEventAt:t.generatedAt}}return r}function bD(e,t){let n=e.toLowerCase();return n===`compaction`?t===`vi`?`tóm tắt phần cũ của cuộc trò chuyện`:`summarising the older part of the conversation`:n===`capacity-wait`?t===`vi`?`chờ tài khoản công ty rảnh`:`waiting for a free company account`:n===`ask_user`?t===`vi`?`chờ bạn trả lời câu hỏi`:`waiting for your answer`:/(subagent|scout|delegate|agent)/.test(n)?t===`vi`?`phối hợp agent hỗ trợ`:`coordinating a helper agent`:/(bash|exec|shell|command|terminal)/.test(n)?t===`vi`?`chạy lệnh`:`running a command`:/(read|grep|find|list|glob|search_file)/.test(n)?t===`vi`?`đọc mã nguồn`:`reading source`:/(edit|write|patch|apply)/.test(n)?t===`vi`?`cập nhật file`:`updating files`:/(test|verify|check|lint)/.test(n)?t===`vi`?`kiểm tra kết quả`:`verifying results`:/(web|search|browser|fetch)/.test(n)?t===`vi`?`tìm kiếm thông tin`:`searching`:t===`vi`?`chạy công cụ`:`running a tool`}var xD=/(?:sk-(?:proj|live|test|svcacct)-[A-Za-z0-9_-]{8,}|as_(?:live|device|run)_[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}_|(?:api[_-]?key|password|secret|token)=)/i;function SD(e){if(typeof e!=`string`)return null;let t=(e.replace(/\\/g,`/`).split(`/`).at(-1)??``).trim();return!t||t===`.`||t===`..`||t.length>160||/[\u0000-\u001f\u007f/\\]/.test(t)||xD.test(t)||t.includes(`[REDACTED`)?null:t}function CD(e,t=`vi`,n=Date.now()){let r=[...e.activities].reverse().find(e=>e.state===`running`),i=r?bD(r.toolLabel,t):e.activities.length?t===`vi`?`tổng hợp bước tiếp theo`:`preparing the next step`:t===`vi`?`phân tích yêu cầu`:`analyzing the request`,a=Date.parse(e.lastEventAt??r?.startedAt??e.startedAt??``),o=Number.isFinite(a)?Math.max(0,Math.floor((n-a)/1e3)):null,s=o===null?t===`vi`?`Đang chờ cập nhật tiến trình đầu tiên`:`Waiting for the first progress update`:o<10?t===`vi`?`Tiến trình vừa cập nhật`:`Progress updated just now`:o<60?t===`vi`?`Cập nhật ${o} giây trước`:`Updated ${o}s ago`:t===`vi`?`Cập nhật ${Math.floor(o/60)} phút trước`:`Updated ${Math.floor(o/60)}m ago`,c=SD(r?.fileLabel),l=c?`${c} · ${s}`:s;return{label:t===`vi`?`Piagent đang ${i}…`:`Piagent is ${i}…`,detail:l}}function wD(e,t,n,r){if(e?.state!==`ready`||e.gatewayInstanceRef!==t)return!1;let i=e.operations.find(e=>e.sessionRef===n);return i?.operationRef===r&&i.abortable===!0}function TD(e,t){return{key:t,user:e,steps:[],answer:null,failure:null,failureDetail:null,requests:0,tokens:0,model:null,process:null,end:null,startedAt:e.recordedAt,endedAt:null,outputTokens:0,generationMs:0}}var ED=new Set([`objection`,`rejudge`,`dispute`]);function DD(e){let t=[],n=null,r=NaN;for(let i of e){let e=Date.parse(i.recordedAt),a=r;if(i.role!==`custom`&&(r=e),i.role===`user`){n=TD(i,i.messageRef),t.push(n);continue}if(!n||i.role===`tool-result`)continue;if(n.endedAt=i.recordedAt,i.role===`custom`&&i.turnEnd){n.end=i.turnEnd;continue}if(i.role===`custom`&&i.process){if(n.process&&(n.answer&&(n.steps.push({kind:`note`,key:`${i.messageRef}:round-answer`,text:n.answer}),n.answer=null),n.steps.push({kind:`process`,key:`${i.messageRef}:round`,process:n.process}),n.process=null),i.process.phase===`final`){n.process=i.process;continue}n.answer&&!ED.has(i.process.phase)&&(n.steps.push({kind:`note`,key:`${i.messageRef}:answer`,text:n.answer}),n.answer=null),n.steps.push({kind:`process`,key:i.messageRef,process:i.process});continue}i.role===`assistant`&&i.usage?.outputTokens&&e>a&&(n.outputTokens+=i.usage.outputTokens,n.generationMs+=e-a),i.role===`assistant`&&(i.failure?.local||(n.requests+=1),n.tokens+=i.usage?.totalTokens??0,n.model=i.model??n.model);let o=Yx(i);if(o){n.answer||(n.failure=o,n.failureDetail=i.failure??null);continue}for(let e of i.toolCalls)n.steps.push({kind:`tool`,key:`${i.messageRef}:${e.toolCallRef}`,tool:e});if(i.toolCalls.length)continue;let s=i.role===`assistant`?Xx(i.content.text??``):i.content.text;if(s){if(i.role===`custom`){n.steps.push({kind:`note`,key:i.messageRef,text:s});continue}n.answer&&n.answer.trim()!==s.trim()&&n.steps.push({kind:`note`,key:`${i.messageRef}:previous`,text:n.answer}),n.answer=s,n.failure=null,n.failureDetail=null}}return t}function OD(e){let t=Date.parse(e.startedAt??``),n=Date.parse(e.endedAt??``);return Number.isFinite(t)&&Number.isFinite(n)&&n>=t?Math.round((n-t)/1e3):null}function kD(e){if(e.outputTokens<50||e.generationMs<250)return null;let t=e.outputTokens/(e.generationMs/1e3);return t>=10?Math.round(t):Math.round(t*10)/10}function AD(e,t){return e<40||t<1e3?null:Math.round(e/4/(t/1e3))}function jD(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:`${(e/1e6).toFixed(1)}M`}var MD=Y((0,U.jsx)(`path`,{d:`M19 5v14H5V5zm0-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-4.86 8.86-3 3.87L9 13.14 6 17h12z`}),`ImageOutlined`);function ND(e){return Gr(`MuiAlertTitle`,e)}Kr(`MuiAlertTitle`,[`root`]);var PD=e=>{let{classes:t}=e;return ba({root:[`root`]},ND,t)},FD=K(X,{name:`MuiAlertTitle`,slot:`Root`})(ys(({theme:e})=>({fontWeight:e.typography.fontWeightMedium,marginTop:-2}))),ID=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiAlertTitle`}),{className:r,...i}=n,a=n,o=PD(a);return(0,U.jsx)(FD,{gutterBottom:!0,component:`div`,ownerState:a,ref:t,className:W(o.root,r),...i})}),LD=Y((0,U.jsx)(`path`,{d:`M22 11V3h-7v3H9V3H2v8h7V8h2v10h4v3h7v-8h-7v3h-2V8h2v3zM7 9H4V5h3zm10 6h3v4h-3zm0-10h3v4h-3z`}),`AccountTreeOutlined`),RD=Y((0,U.jsx)(`path`,{d:`m22.61 18.99-9.08-9.08c.93-2.34.45-5.1-1.44-7C9.79.61 6.21.4 3.66 2.26L7.5 6.11 6.08 7.52 2.25 3.69C.39 6.23.6 9.82 2.9 12.11c1.86 1.86 4.57 2.35 6.89 1.48l9.11 9.11c.39.39 1.02.39 1.41 0l2.3-2.3c.4-.38.4-1.01 0-1.41m-3 1.6-9.46-9.46c-.61.45-1.29.72-2 .82-1.36.2-2.79-.21-3.83-1.25C3.37 9.76 2.93 8.5 3 7.26l3.09 3.09 4.24-4.24-3.09-3.09c1.24-.07 2.49.37 3.44 1.31 1.08 1.08 1.49 2.57 1.24 3.96-.12.71-.42 1.37-.88 1.96l9.45 9.45z`}),`BuildOutlined`),zD=Y((0,U.jsx)(`path`,{d:`M22 8c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1m-9 8c0 .55.45 1 1 1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7c-.55 0-1 .45-1 1M10.47 4.63c.39.39.39 1.02 0 1.41l-4.23 4.25c-.39.39-1.02.39-1.42 0L2.7 8.16a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0l1.42 1.42 3.54-3.54c.38-.38 1.02-.38 1.4 0m.01 8.01c.39.39.39 1.02 0 1.41L6.25 18.3c-.39.39-1.02.39-1.42 0L2.7 16.16c-.39-.39-.39-1.02 0-1.41s1.02-.39 1.41 0l1.42 1.42 3.54-3.54c.38-.38 1.02-.38 1.41.01`}),`ChecklistRounded`),BD=Y((0,U.jsx)(`path`,{d:`m14.85 4.85 1.44 1.44-2.88 2.88 1.42 1.42 2.88-2.88 1.44 1.44c.31.31.85.09.85-.36V4.5c0-.28-.22-.5-.5-.5h-4.29c-.45 0-.67.54-.36.85M8.79 4H4.5c-.28 0-.5.22-.5.5v4.29c0 .45.54.67.85.35L6.29 7.7 11 12.4V19c0 .55.45 1 1 1s1-.45 1-1v-7c0-.26-.11-.52-.29-.71l-5-5.01 1.44-1.44c.31-.3.09-.84-.36-.84`}),`CallSplitRounded`),VD=Y((0,U.jsx)(`path`,{d:`M9 16.17 5.53 12.7a.996.996 0 0 0-1.41 0c-.39.39-.39 1.02 0 1.41l4.18 4.18c.39.39 1.02.39 1.41 0L20.29 7.71c.39-.39.39-1.02 0-1.41a.996.996 0 0 0-1.41 0z`}),`CheckRounded`),HD=Y((0,U.jsx)(`path`,{d:`m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z`}),`EditOutlined`),UD=Y((0,U.jsx)(`path`,{d:`M8 2c-1.1 0-2 .9-2 2v3.17c0 .53.21 1.04.59 1.42L10 12l-3.42 3.42c-.37.38-.58.89-.58 1.42V20c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2v-3.16c0-.53-.21-1.04-.58-1.41L14 12l3.41-3.4c.38-.38.59-.89.59-1.42V4c0-1.1-.9-2-2-2zm8 14.5V19c0 .55-.45 1-1 1H9c-.55 0-1-.45-1-1v-2.5l4-4zm-4-5-4-4V5c0-.55.45-1 1-1h6c.55 0 1 .45 1 1v2.5z`}),`HourglassEmptyRounded`),WD=Y((0,U.jsx)(`path`,{d:`M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56M12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96M4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2s.06 1.34.14 2zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56m2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8M12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96M14.34 14H9.66c-.09-.66-.16-1.32-.16-2s.07-1.35.16-2h4.68c.09.65.16 1.32.16 2s-.07 1.34-.16 2m.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56M16.36 14c.08-.66.14-1.32.14-2s-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2z`}),`LanguageRounded`),GD=Y((0,U.jsx)(`path`,{d:`M13 11h-2v3H8v2h3v3h2v-3h3v-2h-3zm1-9H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8zm4 18H6V4h7v5h5z`}),`NoteAddOutlined`),KD=Y((0,U.jsx)(`path`,{d:`M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m-1 17.93c-3.95-.49-7-3.85-7-7.93 0-.62.08-1.21.21-1.79L9 15v1c0 1.1.9 2 2 2zm6.9-2.54c-.26-.81-1-1.39-1.9-1.39h-1v-3c0-.55-.45-1-1-1H8v-2h2c.55 0 1-.45 1-1V7h2c1.1 0 2-.9 2-2v-.41c2.93 1.19 5 4.06 5 7.41 0 2.08-.8 3.97-2.1 5.39`}),`PublicRounded`),qD=Y((0,U.jsx)(`path`,{d:`M2 6c.55 0 1-.45 1-1V4c0-.55.45-1 1-1h1c.55 0 1-.45 1-1s-.45-1-1-1H4C2.34 1 1 2.34 1 4v1c0 .55.45 1 1 1m3 15H4c-.55 0-1-.45-1-1v-1c0-.55-.45-1-1-1s-1 .45-1 1v1c0 1.66 1.34 3 3 3h1c.55 0 1-.45 1-1s-.45-1-1-1M20 1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1c.55 0 1 .45 1 1v1c0 .55.45 1 1 1s1-.45 1-1V4c0-1.66-1.34-3-3-3m2 17c-.55 0-1 .45-1 1v1c0 .55-.45 1-1 1h-1c-.55 0-1 .45-1 1s.45 1 1 1h1c1.66 0 3-1.34 3-3v-1c0-.55-.45-1-1-1m-3-3.13V9.13c0-.72-.38-1.38-1-1.73l-5-2.88c-.31-.18-.65-.27-1-.27s-.69.09-1 .27L6 7.39c-.62.36-1 1.02-1 1.74v5.74c0 .72.38 1.38 1 1.73l5 2.88c.31.18.65.27 1 .27s.69-.09 1-.27l5-2.88c.62-.35 1-1.01 1-1.73m-8 2.3-4-2.3v-4.63l4 2.33zm1-6.33L8.04 8.53 12 6.25l3.96 2.28zm5 4.03-4 2.3v-4.6l4-2.33z`}),`ViewInArRounded`),JD=Y((0,U.jsx)(`path`,{d:`M19.3 16.9c.58-1.01.95-2.23.51-3.65-.53-1.72-2.04-3.05-3.84-3.22-2.87-.28-5.23 2.07-4.95 4.95.18 1.79 1.5 3.31 3.22 3.84 1.43.44 2.64.07 3.65-.51l2.5 2.5c.39.39 1.01.39 1.4 0s.39-1.01 0-1.4zm-3.8.1c-1.4 0-2.5-1.1-2.5-2.5s1.1-2.5 2.5-2.5 2.5 1.1 2.5 2.5-1.1 2.5-2.5 2.5M12 20v2C6.48 22 2 17.52 2 12S6.48 2 12 2c4.84 0 8.87 3.44 9.8 8h-2.07c-.64-2.46-2.4-4.47-4.73-5.41V5c0 1.1-.9 2-2 2h-2v2c0 .55-.45 1-1 1H8v2h2v3H9l-4.79-4.79C4.08 10.79 4 11.38 4 12c0 4.41 3.59 8 8 8`}),`TravelExploreRounded`);function YD(e){return{color:`${e}.dark`,'html[data-piagent-color-mode="dark"] &':{color:`${e}.main`}}}var XD=`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,ZD={read:NT,write:GD,edit:HD,command:Fh,search:fx,list:TT,"web-search":JD,"web-fetch":WD,subagent:LD,network:KD,docker:qD,git:BD,plan:zD,other:RD},QD={read:[`Đọc`,`Read`],write:[`Tạo`,`Write`],edit:[`Sửa`,`Edit`],command:[`Chạy`,`Run`],search:[`Tìm`,`Search`],list:[`Xem thư mục`,`List`],"web-search":[`Tìm web`,`Web search`],"web-fetch":[`Đọc trang`,`Fetch page`],subagent:[`Subagent`,`Subagent`],network:[`Chạy có mạng`,`Run with network`],docker:[`Chạy với Docker`,`Run with Docker`],git:[`Git`,`Git`],plan:[`Plan`,`Plan`],other:[`Công cụ`,`Tool`]},$D={read:`read`,write:`write`,edit:`edit`,apply_patch:`edit`,bash:`command`,run_experiment:`command`,grep:`search`,find:`search`,ls:`list`,web_search:`web-search`,web_fetch:`web-fetch`,delegate:`subagent`,subagent:`subagent`,run_with_network:`network`,run_with_docker:`docker`,fetch_origin:`git`,update_plan:`plan`};function eO(e){return $D[e.toLowerCase()]??`other`}function tO({preview:e}){return(0,U.jsx)(J,{component:`pre`,sx:{m:0,fontFamily:XD,fontSize:12,lineHeight:1.55,overflowX:`auto`},children:e.split(`
|
|
177
|
+
`).map((e,t)=>{let n=e[0],r=n===`+`?`success`:n===`-`?`error`:null;return(0,U.jsx)(J,{component:`div`,sx:{px:1,whiteSpace:`pre`,...r?YD(r):{color:e===`@@`?`text.disabled`:`text.secondary`},bgcolor:r?`rgba(var(--piagent-palette-${r}-mainChannel) / .12)`:`transparent`},children:e===`@@`?`⋯`:e||` `},t)})})}function nO({tool:e,locale:t,live:n,waiting:r}){let i=e.summary??{kind:`other`,target:null,detail:null},a=`change`in e?e.change:void 0,o=`result`in e?e.result:void 0,s=e.state===`failed`||o?.isError===!0,c=`failure`in e&&e.failure?{detail:e.failure,copy:JC(e.failure.reasonCode,e.failure.code,t)}:null,l=n?e.state===`running`:e.state===`requested`,[u,d]=(0,v.useState)(()=>s||(i.kind===`edit`||i.kind===`write`)&&!!a?.preview),f=!!(a?.preview||o?.text||c?.copy||i.detail&&i.kind!==`read`),p=r?UD:ZD[i.kind],m=QD[i.kind][t===`vi`?0:1],h=i.kind===`other`?e.toolName:m;return(0,U.jsxs)(J,{sx:{border:1,borderColor:s?`error.main`:`divider`,borderRadius:2,bgcolor:`background.paper`,overflow:`hidden`},children:[(0,U.jsxs)(tu,{component:`div`,disabled:!f,onClick:()=>d(e=>!e),"aria-expanded":f?u:void 0,sx:{width:`100%`,display:`flex`,alignItems:`center`,gap:1,px:1.25,py:.85,textAlign:`left`,justifyContent:`flex-start`},children:[(0,U.jsx)(p,{sx:{fontSize:17,color:s?`error.main`:`text.secondary`,flexShrink:0}}),(0,U.jsx)(X,{variant:`body2`,sx:{fontWeight:600,flexShrink:0},children:h}),i.target&&(0,U.jsx)(X,{variant:`body2`,noWrap:!0,title:i.target,sx:{fontFamily:XD,fontSize:12.5,color:`text.secondary`,minWidth:0,flex:1},children:i.target}),!i.target&&(0,U.jsx)(J,{sx:{flex:1}}),i.kind===`read`&&i.detail&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{flexShrink:0},children:Q(t,`dòng ${i.detail}`,`lines ${i.detail}`)}),a&&(a.added>0||a.removed>0)&&(0,U.jsxs)(X,{variant:`caption`,sx:{fontFamily:XD,flexShrink:0},children:[a.added>0&&(0,U.jsxs)(J,{component:`span`,sx:YD(`success`),children:[`+`,a.added,` `]}),a.removed>0&&(0,U.jsxs)(J,{component:`span`,sx:YD(`error`),children:[`−`,a.removed]})]}),s&&!l&&(0,U.jsx)(X,{variant:`caption`,sx:{flexShrink:0,fontWeight:600,...YD(`error`)},children:Q(t,`Lỗi`,`Failed`)}),l?(0,U.jsx)(xu,{size:14,thickness:5,"aria-label":Q(t,`Đang chạy`,`Running`)}):s?(0,U.jsx)(YE,{sx:{fontSize:16,color:`error.main`},"aria-hidden":`true`}):(0,U.jsx)(VD,{sx:{fontSize:16,color:`success.main`},"aria-label":Q(t,`Xong`,`Done`)}),f&&(0,U.jsx)(wT,{sx:{fontSize:18,color:`text.disabled`,transition:`transform .15s`,transform:u?`rotate(180deg)`:`none`}})]}),(0,U.jsx)(MC,{in:u&&f,unmountOnExit:!0,children:(0,U.jsxs)(J,{sx:{borderTop:1,borderColor:`divider`,bgcolor:`action.hover`,maxHeight:360,overflow:`auto`},children:[i.detail&&i.kind!==`read`&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1.25,py:.75,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,...i.kind===`command`?{fontFamily:XD,fontSize:12}:{}},children:i.detail}),c?.copy&&(0,U.jsxs)(J,{sx:{px:1.25,py:.75},children:[(0,U.jsxs)(X,{variant:`body2`,sx:{fontWeight:650,...YD(`error`)},children:[ZC(c.detail.role,t),` `,Q(t,`lỗi`,`failed`),` · `,c.copy.title]}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:c.copy.text}),(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,sx:{fontFamily:XD,overflowWrap:`anywhere`},title:c.detail.requestRef??void 0,children:[Q(t,`Mã`,`Code`),`: `,c.detail.code,c.detail.requestRef?` · request ${c.detail.requestRef.slice(0,8)}`:``]})]}),a?.preview&&(0,U.jsx)(J,{sx:{py:.5},children:(0,U.jsx)(tO,{preview:a.preview})}),o?.text&&!c?.copy&&(0,U.jsx)(J,{component:`pre`,sx:{m:0,px:1.25,py:.75,fontFamily:XD,fontSize:12,lineHeight:1.55,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,color:o.isError?`error.main`:`text.secondary`},children:o.text}),(a?.truncated||o?.truncated)&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,px:1.25,pb:.75},children:Q(t,`Đã rút gọn`,`Truncated`)})]})})]})}var rO=Y((0,U.jsx)(`path`,{d:`M15 4v7H5.17L4 12.17V4zm1-2H3c-.55 0-1 .45-1 1v14l4-4h10c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1m5 4h-2v9H6v2c0 .55.45 1 1 1h11l4 4V7c0-.55-.45-1-1-1`}),`ForumOutlined`),iO=Y((0,U.jsx)(`path`,{d:`M12 5V2.21c0-.45-.54-.67-.85-.35l-3.8 3.79c-.2.2-.2.51 0 .71l3.79 3.79c.32.31.86.09.86-.36V7c3.73 0 6.68 3.42 5.86 7.29-.47 2.27-2.31 4.1-4.57 4.57-3.57.75-6.75-1.7-7.23-5.01-.07-.48-.49-.85-.98-.85-.6 0-1.08.53-1 1.13.62 4.39 4.8 7.64 9.53 6.72 3.12-.61 5.63-3.12 6.24-6.24C20.84 9.48 16.94 5 12 5`}),`ReplayRounded`),aO=(e,t,n)=>e===`vi`?t:n,oO={blocking:[`blocking`,`blocking`],major:[`major`,`major`],minor:[`minor`,`minor`]},sO={wrong_premise:[`sai giả định`,`wrong premise`],conflicts_with_request:[`conflict với yêu cầu`,`conflicts with the request`],ambiguous:[`chưa rõ ràng`,`ambiguous`],out_of_scope:[`out of scope`,`out of scope`]},cO={too_large:[`patch quá lớn`,`the patch is too large`],not_git:[`thư mục không phải git`,`not a git repository`],limit:[`subagent đã hết lượt gọi`,`the subagent ran out of calls`],failed:[`subagent lỗi`,`the subagent failed`]};function lO(e,t){let n=[];return e.outcome===`interrupted`?aO(t,`Lượt bị dừng trước khi check xong`,`The turn stopped before its checks finished`):(e.outcome===`disputed`&&n.push((e.disputes??1)>1?aO(t,`${e.disputes} conflict giữa main agent và subagent, bạn quyết định`,`${e.disputes} disagreements between the main agent and a subagent; your call`):aO(t,`Main agent và subagent conflict, bạn quyết định`,`The main agent and a subagent disagree; your call`)),e.unchanged?n.join(` · `)||aO(t,`Không đổi code`,`No code changed`):(e.verified?n.push(aO(t,`Check đã pass trên code cuối`,`A check passed on the final code`)):e.verifyPolicy!==`off`&&n.push(aO(t,`Chưa có check pass trên code cuối`,`No check passed on the final code`)),e.reviewed?n.push(e.blockingOpen?aO(t,`Còn ${e.blockingOpen} lỗi blocking chưa fix`,`${e.blockingOpen} blocking issue(s) still open`):aO(t,`Review không có lỗi blocking`,`Review found no blocking issue`)):e.reviewPolicy!==`off`&&n.push(e.outcome===`review_unavailable`?aO(t,`Không chạy được review`,`The review could not run`)+(e.reviewUnavailable&&cO[e.reviewUnavailable]?` (${aO(t,...cO[e.reviewUnavailable])})`:``):aO(t,`Chưa review`,`Not reviewed`)),e.planSkipped&&n.push(aO(t,`Đã sửa code khi chưa có plan`,`Code was changed before a plan existed`)),e.planOpen&&n.push(aO(t,`Plan còn ${e.planOpen} bước chưa xong`,`${e.planOpen} plan step(s) not completed`)),n.join(` · `)||aO(t,`Đã đổi code`,`Code changed`)))}function uO(e,t){let n=e.loop&&e.maxLoops?aO(t,` (vòng ${e.loop}/${e.maxLoops})`,` (round ${e.loop}/${e.maxLoops})`):``,r=qC(e.role??`review`,t),i=(e.findings??e.claims??e.issues??[]).length;switch(e.phase){case`continue`:return aO(t,`Harness: checklist còn ${e.planOpen??0} bước (${e.planDone??0}/${e.planSteps??0} xong), cho main agent làm tiếp · vòng ${e.round??1}${e.idle?` (vòng trước không xong thêm bước nào)`:``}`,`Harness: the checklist has ${e.planOpen??0} open step(s) (${e.planDone??0}/${e.planSteps??0} done); sent the main agent on · round ${e.round??1}${e.idle?` (the previous round finished no step)`:``}`);case`plan`:return aO(t,`Harness: plan còn ${e.planOpen??0} bước chưa đánh dấu xong, yêu cầu agent cập nhật`,`Harness: ${e.planOpen??0} plan step(s) not marked completed; asked the agent to update the plan`);case`verify`:return aO(t,`Harness: chưa có check nào pass trên code hiện tại, yêu cầu agent chạy check${n}`,`Harness: no check has passed on the current code; asked the agent to run checks${n}`);case`review`:return aO(t,`Harness: review tìm thấy ${i} lỗi blocking, gửi lại agent để fix hoặc giải thích${n}`,`Harness: the review found ${i} blocking issue(s); sent back to the agent to fix or answer${n}`);case`objection`:return aO(t,`${r} phản biện brief của main agent`,`${r} objected to the main agent's brief`);case`answer`:return aO(t,`Harness: yêu cầu main agent nói rõ đã quyết định gì với phản biện của subagent`,`Harness: asked the main agent to say what it decided about the subagent's objection`);case`claims`:return aO(t,`Harness: ${r} đánh fail ${i} claim, gửi lại main agent`,`Harness: ${r} marked ${i} claim(s) as failed; sent back to the main agent`);case`rejudge`:return e.role===`verify`?aO(t,`Harness: ${r} check lại các claim cùng câu trả lời của main agent`,`Harness: ${r} checks the claims again with the main agent's answer`):aO(t,`Harness: main agent giải thích thay vì fix, ${r} xem xét lại lời giải thích`,`Harness: the main agent answered instead of fixing; ${r} judges the answer`);case`dispute`:return aO(t,`Main agent và ${r} vẫn conflict sau 2 lượt, bạn quyết định`,`The main agent and the ${r} still disagree after two rounds; your call`);default:return``}}function dO(e,t){return(e.findings??[]).map(e=>({tag:aO(t,...oO[e.severity]??[e.severity,e.severity]),tone:e.severity===`blocking`?`error`:`warning`,location:e.file?`${e.file}${e.line?`:${e.line}`:``}`:null,text:e.issue})).concat((e.claims??[]).map(e=>({tag:`fail`,tone:`error`,location:null,text:e.claim}))).concat((e.issues??[]).map(e=>({tag:aO(t,...sO[e.kind]??[e.kind,e.kind]),tone:`warning`,location:null,text:e.detail})))}var fO={clean:`success`,disputed:`warning`,blocking_open:`error`,unverified:`warning`,unreviewed:`warning`,review_unavailable:`warning`,interrupted:`warning`,no_change:`info`};function pO(e,t){return lO(e,t)}var mO=e=>e?fO[e]:`info`,hO=e=>{let t=mO(e.outcome);return t===`success`&&(e.planSkipped||e.planOpen)?`warning`:t},gO={fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:12.5};function _O({process:e,locale:t}){let n=dO(e,t).map(e=>(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(J,{component:`span`,sx:{fontWeight:600,...YD(e.tone)},children:[`[`,e.tag,`]`]}),e.location&&(0,U.jsxs)(J,{component:`span`,sx:gO,children:[` `,e.location]}),e.location?` — `:` `,e.text]}));return n.length>0?(0,U.jsx)(J,{component:`ol`,sx:{m:0,pl:3.5},children:n.map((e,t)=>(0,U.jsx)(X,{component:`li`,variant:`body2`,sx:{overflowWrap:`anywhere`},children:e},t))}):null}function vO({process:e,locale:t}){if(e.phase===`final`){let n=hO(e),r=n===`success`?Nw:n===`error`?eD:uT;return(0,U.jsxs)(Z,{direction:`row`,role:`status`,"aria-label":Q(t,`Tiến trình của lượt`,`Turn process`),sx:{alignItems:`flex-start`,gap:.75},children:[(0,U.jsx)(r,{sx:{fontSize:16,mt:.2,...YD(n)}}),(0,U.jsx)(X,{variant:`body2`,sx:YD(n),children:pO(e,t)})]})}let n=e.phase===`dispute`||e.phase===`objection`,r=e.phase===`dispute`?uT:e.phase===`objection`?rO:iO,i=e.phase===`dispute`?`warning`:null;return(0,U.jsxs)(Z,{spacing:.5,role:n?`status`:void 0,sx:{borderLeft:2,borderColor:i?`warning.main`:`divider`,pl:1.25},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`flex-start`,gap:.75},children:[(0,U.jsx)(r,{sx:{fontSize:16,mt:.2,...i?YD(i):{color:`text.secondary`}}}),(0,U.jsx)(X,{variant:`body2`,sx:i?{fontWeight:600,...YD(i)}:n?{fontWeight:600}:{color:`text.secondary`},children:uO(e,t)})]}),(0,U.jsx)(_O,{process:e,locale:t})]})}var yO=(e,t,n)=>e===`vi`?t:n;function bO(e,t){let n=e.planDeferred??0,r=e.planSteps-e.planDone-n,i=e.rounds?yO(t,` Harness đã cho agent làm tiếp ${e.rounds} vòng.`,` The harness sent the agent back ${e.rounds} time(s).`):``;if(e.state===`cancelled`)return{tone:`info`,continuable:!0,title:yO(t,`Bạn đã dừng lượt này`,`You stopped this turn`),text:yO(t,`Task chưa xong${e.planSteps?` (${e.planDone}/${e.planSteps} bước)`:``}. Bấm Tiếp tục để agent làm tiếp từ chỗ dừng.`,`The task is not finished${e.planSteps?` (${e.planDone}/${e.planSteps} steps)`:``}. Choose Continue to pick up where it stopped.`)};if(e.state===`failed`)return{tone:`error`,continuable:!0,title:yO(t,`Lượt dừng vì lỗi · ${qC(e.role??`main`,t)}`,`Turn stopped by a failure · ${qC(e.role??`main`,t)}`),text:yO(t,`Task chưa xong${e.planSteps?`: còn ${r}/${e.planSteps} bước`:``}. Xem lỗi phía trên; khi đã xử lý, bấm Tiếp tục để chạy lại từ chỗ dừng.`,`The task is not finished${e.planSteps?`: ${r} of ${e.planSteps} steps open`:``}. See the failure above; once it is resolved, choose Continue.`)+(e.code?` [${e.code}]`:``)};if(e.state===`midway`){let n=e.reason===`idle`?yO(t,`Main agent dừng 2 vòng liên tiếp mà không xong thêm bước nào: đọc câu trả lời cuối để biết vướng gì.`,`The main agent stopped 2 rounds in a row without finishing a step: its last answer says what is in the way.`):e.reason===`limit`?yO(t,`Đã tới giới hạn 30 vòng tự làm tiếp cho một tin nhắn.`,`The limit of 30 automatic rounds for one message was reached.`):yO(t,`Harness của team không bắt buộc plan nên không tự làm tiếp.`,`The team's Harness does not require a plan, so it does not continue on its own.`);return{tone:`warning`,continuable:!0,title:yO(t,`Dừng giữa chừng · còn ${r}/${e.planSteps} bước`,`Stopped midway · ${r} of ${e.planSteps} steps open`),text:`${n}${i} ${yO(t,`Bấm Tiếp tục để làm tiếp.`,`Choose Continue to go on.`)}`}}return n?{tone:`info`,continuable:!0,title:yO(t,`Dừng theo yêu cầu · ${e.planDone}/${e.planSteps} bước xong, ${n} bước để sau`,`Stopped as asked · ${e.planDone} of ${e.planSteps} steps done, ${n} left for later`),text:yO(t,`Các bước còn lại được để sau theo yêu cầu hoặc vì không cần nữa: câu trả lời cuối nói lý do. Bấm Tiếp tục khi muốn làm nốt.`,`The other steps were left for later as asked, or are no longer needed: the last answer says why. Choose Continue to do them.`)+i}:{tone:`success`,continuable:!1,title:e.planSteps?yO(t,`Hoàn thành · ${e.planSteps}/${e.planSteps} bước`,`Done · ${e.planSteps}/${e.planSteps} steps`):yO(t,`Xong lượt`,`Turn finished`),text:(e.planSteps?yO(t,`Mọi bước trong checklist đã xong.`,`Every checklist step is completed.`):yO(t,`Main agent đã trả lời xong; lượt này không có checklist.`,`The main agent finished its answer; this turn had no checklist.`))+i}}function xO(e,t){return e.state===`done`&&e.planDeferred?yO(t,`Xong ${e.planDone}/${e.planSteps}, để sau ${e.planDeferred}`,`Done ${e.planDone}/${e.planSteps}, ${e.planDeferred} later`):e.state===`midway`?yO(t,`Dừng giữa chừng ${e.planDone}/${e.planSteps}`,`Stopped ${e.planDone}/${e.planSteps}`):e.state===`failed`?yO(t,`Lỗi, chưa xong`,`Failed`):e.state===`cancelled`?yO(t,`Đã dừng`,`Stopped`):e.planSteps?yO(t,`Xong ${e.planSteps}/${e.planSteps}`,`Done ${e.planSteps}/${e.planSteps}`):yO(t,`Xong`,`Done`)}function SO({end:e,locale:t,onContinue:n}){let r=bO(e,t),i=n&&r.continuable?(0,U.jsx)($,{color:`inherit`,size:`small`,onClick:n,children:Q(t,`Tiếp tục`,`Continue`)}):void 0;return(0,U.jsxs)(mC,{severity:r.tone,variant:`outlined`,role:`status`,"aria-label":Q(t,`Kết quả của lượt`,`How the turn ended`),action:i,sx:{alignSelf:`stretch`},children:[(0,U.jsx)(ID,{sx:{fontSize:`inherit`,fontWeight:650,mb:.25},children:r.title}),r.text]})}var CO={done:`success`,midway:`warning`,failed:`error`,cancelled:`info`},wO=e=>e.state===`done`&&e.planDeferred?`info`:CO[e.state];function TO(e,t){return xO(e,t)}var EO=null,DO=()=>EO??=gx(()=>import(`./MarkdownMessage-nggiOt0N.js`),[]),OO=(0,v.lazy)(async()=>({default:(await DO()).MarkdownMessage}));function kO({children:e}){return(0,U.jsx)(v.Suspense,{fallback:(0,U.jsx)(X,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.75},children:e}),children:(0,U.jsx)(OO,{children:e})})}function AO({attachments:e,locale:t}){return e.length?(0,U.jsx)(Z,{spacing:.75,sx:{mb:1},"aria-label":Q(t,`File đã gửi`,`Sent files`),children:e.map((e,n)=>{let r=`sourceBytes`in e?lS(e,t):`${e.kind===`document`?Q(t,`Tài liệu`,`Document`):e.kind===`image`?Q(t,`Ảnh`,`Image`):`File`}${e.truncated?` · ${Q(t,`đã cắt bớt`,`truncated`)}`:``}`;return(0,U.jsxs)(Pc,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:1.1,minWidth:220,maxWidth:440,px:1.2,py:1,borderRadius:2,bgcolor:`background.paper`},children:[e.kind===`image`?(0,U.jsx)(MD,{color:`action`}):(0,U.jsx)(NT,{color:`action`}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{variant:`body2`,noWrap:!0,sx:{fontWeight:650},children:e.displayName}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:r})]})]},`${e.displayName}:${n}`)})}):null}var jO=new Set([`assistant-response-failed`,`operation-failed`]);function MO(e,t){switch(e){case`provider-auth-expired`:return Q(t,`Phiên đăng nhập model đã hết hạn. Mở Cài đặt → Nhà cung cấp & model để kết nối lại.`,`The model sign-in expired. Open Settings → Providers & models to reconnect.`);case`provider-auth-required`:return Q(t,`Model cần đăng nhập lại. Mở Cài đặt → Nhà cung cấp & model.`,`The model needs to sign in again. Open Settings → Providers & models.`);case`provider-rate-limited`:return Q(t,`Model đang bị giới hạn lượt gọi hoặc đã hết hạn mức. Thử lại sau.`,`The model is rate limited or out of quota. Try again later.`);case`provider-unavailable`:return Q(t,`Model hoặc máy chủ trung gian đang không phục vụ yêu cầu này. Thử lại; nếu lỗi lặp lại, kiểm tra model đang dùng.`,`The model or its gateway did not serve this request. Retry; if it repeats, check the model in use.`);case`assistant-output-incomplete`:return Q(t,`Câu trả lời dừng giữa chừng vì chạm giới hạn độ dài. Gửi “tiếp tục” để model viết tiếp.`,`The answer stopped at the length limit. Send “continue” to resume.`);default:return Q(t,`Model trả lỗi và chưa có câu trả lời. Gửi lại; nếu lỗi lặp lại, kiểm tra model đang dùng.`,`The model returned an error without an answer. Send again; if it repeats, check the model in use.`)}}function NO({code:e,detail:t,locale:n,onContinue:r}){let i=JC(e,t?.code??null,n),a=r&&XC(e)?(0,U.jsx)($,{color:`inherit`,size:`small`,onClick:r,children:Q(n,`Tiếp tục`,`Continue`)}):void 0;return i?(0,U.jsxs)(mC,{severity:`error`,variant:`outlined`,icon:(0,U.jsx)(eD,{}),action:a,sx:{alignSelf:`stretch`},children:[(0,U.jsxs)(ID,{sx:{fontSize:`inherit`,fontWeight:650,mb:.25},children:[ZC(t?.role??`main`,n),` `,Q(n,`lỗi`,`failed`),` · `,i.title]}),i.text,t&&(0,U.jsxs)(X,{variant:`caption`,component:`div`,color:`text.secondary`,sx:{mt:.5,fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,overflowWrap:`anywhere`},title:t.requestRef??void 0,children:[Q(n,`Mã`,`Code`),`: `,t.code,t.requestRef?` · request ${t.requestRef.slice(0,8)}`:``]})]}):(0,U.jsx)(mC,{severity:`error`,variant:`outlined`,icon:(0,U.jsx)(eD,{}),action:a,sx:{alignSelf:`stretch`},children:MO(e,n)})}function PO({text:e,attachments:t,note:n,locale:r}){return(0,U.jsxs)(J,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:3,px:2,py:1.4},children:[(0,U.jsx)(AO,{attachments:t,locale:r}),e&&(0,U.jsx)(X,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:e}),n&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:n})]})}function FO({children:e}){return(0,U.jsxs)(J,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(Z,{spacing:1,sx:{minWidth:0,flex:1},children:[(0,U.jsx)(X,{sx:{fontWeight:600},children:`Piagent`}),e]})]})}function IO(e,t){return e.content.redacted?Q(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):e.content.truncated?Q(t,`Nội dung đã rút gọn`,`Content truncated`):null}function LO({turn:e,locale:t}){let n=OD(e),r=[`${e.requests} request`];e.tokens&&r.push(`${jD(e.tokens)} token`),n!==null&&n>0&&r.push(n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`);let i=kD(e);return i!==null&&r.push(`${i} tok/s`),e.model&&r.push(e.model),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,title:Q(t,`Request model, token, thời gian và tốc độ sinh token (token đầu ra mỗi giây, tính cả thời gian chờ) của lượt này`,`Model requests, tokens, time and output speed (output tokens per second, waiting included) of this turn`),children:r.join(` · `)})}function RO({turn:e,locale:t,onContinue:n}){let r=!!n&&!e.answer&&!e.failure&&!e.end,i=e.steps.length>0||e.answer||e.failure||r||e.process||e.end;return(0,U.jsxs)(Z,{spacing:1.5,children:[(0,U.jsx)(PO,{text:e.user.content.text,attachments:e.user.attachments??[],note:IO(e.user,t),locale:t}),i&&(0,U.jsxs)(FO,{children:[e.steps.map(e=>e.kind===`tool`?(0,U.jsx)(nO,{tool:e.tool,locale:t},e.key):e.kind===`process`?(0,U.jsx)(vO,{process:e.process,locale:t},e.key):(0,U.jsx)(J,{sx:{color:`text.secondary`,fontSize:`.875rem`,"& .MuiTypography-root":{fontSize:`inherit`}},children:(0,U.jsx)(kO,{children:e.text})},e.key)),e.failure&&(0,U.jsx)(NO,{code:e.failure,detail:e.failureDetail,locale:t,onContinue:n}),r&&(0,U.jsx)(mC,{severity:`info`,variant:`outlined`,sx:{alignSelf:`stretch`},action:(0,U.jsx)($,{color:`inherit`,size:`small`,onClick:n,children:Q(t,`Tiếp tục`,`Continue`)}),children:Q(t,`Lượt này chưa có câu trả lời: nó đã bị dừng, hoặc ứng dụng hay máy tắt khi đang chạy. Các bước đã làm vẫn được giữ; bấm Tiếp tục để làm tiếp.`,`This turn has no answer: it was stopped, or the app or the machine went down while it ran. Its steps are kept; press Continue to go on.`)}),e.answer&&(0,U.jsx)(J,{children:(0,U.jsx)(kO,{children:e.answer})}),e.process&&(0,U.jsx)(vO,{process:e.process,locale:t}),e.end&&(0,U.jsx)(SO,{end:e.end,locale:t,onContinue:e.failure?void 0:n}),e.requests>0&&(0,U.jsx)(LO,{turn:e,locale:t})]})]})}function zO(e,t){return e===`compaction`?Q(t,`Tóm tắt phần cũ của cuộc trò chuyện`,`Summarise the older part of the conversation`):e===`capacity-wait`?Q(t,`Chờ tài khoản công ty rảnh (Studio đang bận, sẽ tự gửi lại)`,`Wait for a free company account (Studio is busy; it is sent again by itself)`):e}function BO({user:e,attachments:t,activities:n,assistant:r,running:i,failure:a,status:o,locale:s}){return(0,U.jsxs)(Z,{spacing:1.5,children:[e&&(0,U.jsx)(PO,{text:e,attachments:t,locale:s}),(0,U.jsxs)(FO,{children:[n.map(e=>(0,U.jsx)(nO,{live:!0,locale:s,waiting:e.toolLabel===`capacity-wait`,tool:{toolName:zO(e.toolLabel,s),state:e.state,summary:{kind:eO(e.toolLabel),target:e.fileLabel??null,detail:null}}},e.toolCallRef)),a&&(0,U.jsx)(NO,{code:a,locale:s}),r&&(0,U.jsx)(J,{children:(0,U.jsx)(kO,{children:r})}),i&&o]})]})}function VO(e){let t=(0,v.useRef)(null),[n,r]=(0,v.useState)(null);return(0,v.useEffect)(()=>{if(!e){t.current=null,r(null);return}t.current??={at:Date.now(),from:e.length},r(AD(e.length-t.current.from,Date.now()-t.current.at))},[e]),n}function HO({live:e,locale:t,onOpenActivity:n}){let[r,i]=(0,v.useState)(()=>Date.now());(0,v.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e4);return()=>window.clearInterval(e)},[]);let a=CD(e,t,r),o=VO(e.assistant??``);return(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,role:`status`,"aria-live":`polite`,sx:{alignItems:`center`,color:`text.secondary`,py:.75},children:[(0,U.jsx)(xu,{size:19,thickness:4}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{variant:`body2`,sx:{fontWeight:600},children:a.label}),(0,U.jsxs)(X,{variant:`caption`,color:`text.disabled`,children:[a.detail,o!==null&&` · ≈ ${o} tok/s`]})]}),n&&(0,U.jsx)($,{size:`small`,variant:`text`,onClick:n,sx:{ml:`auto !important`},children:Q(t,`Xem Activity`,`View Activity`)})]})}var UO=new Map,WO=96,GO=()=>document.documentElement.scrollHeight-window.innerHeight,KO=()=>GO()-window.scrollY<=WO;function qO(e,t){let n=(0,v.useRef)(null),r=(0,v.useRef)(!1),i=(0,v.useRef)(!0);return(0,v.useLayoutEffect)(()=>{if(!t||r.current)return;r.current=!0;let n=UO.get(e)??`end`;i.current=n===`end`,window.scrollTo(0,n===`end`?GO():Math.min(n,GO()))},[t,e]),(0,v.useEffect)(()=>{let t=()=>{r.current&&(i.current=KO(),UO.set(e,i.current?`end`:window.scrollY))};window.addEventListener(`scroll`,t,{passive:!0});let a=n.current,o=typeof ResizeObserver>`u`||!a?null:new ResizeObserver(()=>{r.current&&i.current&&window.scrollTo(0,GO())});return a&&o?.observe(a),()=>{window.removeEventListener(`scroll`,t),o?.disconnect()}},[e]),n}function JO({sessionRef:e,sessionRevision:t,live:n,approvals:r,locale:i,onOpenActivity:a,onContinue:o,reload:s=0}){let[c,l]=(0,v.useState)(),[u,d]=(0,v.useState)(!0),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(null);(0,v.useEffect)(()=>{DO()},[]);let y=Kx(e,t,n),{completionKey:b,user:x,assistant:S,operationRef:C,messageRequestId:w,startedAt:T}=y;(0,v.useEffect)(()=>{let t=new AbortController;d(!0),h(!1),_(null);let n=window.setTimeout(()=>{qg(e,null,50,t.signal).then(e=>{l(e),b&&tS(e.items,x,S,{operationRef:C,messageRequestId:w,startedAt:T})&&_(b)}).catch(()=>{t.signal.aborted||h(!0)}).finally(()=>{t.signal.aborted||d(!1)})},b?100:0);return()=>{window.clearTimeout(n),t.abort()}},[y.key,s]);let E=c?.state===`ready`?c.items:[],D=(0,v.useMemo)(()=>DD(E),[E]),O=(0,v.useMemo)(()=>!!(n?.user&&nS(E,n.user,{operationRef:n.operationRef,messageRequestId:n.messageRequestId,startedAt:n.startedAt})),[E,n?.user,n?.operationRef,n?.messageRequestId,n?.startedAt]),k=!!(n&&!O&&(!n.complete||g!==b)),A=(0,v.useMemo)(()=>!!(n?.user&&eS(E,n.user,{operationRef:n.operationRef,messageRequestId:n.messageRequestId,startedAt:n.startedAt})),[E,n?.user,n?.operationRef,n?.messageRequestId,n?.startedAt]),j=async()=>{let t=c?.page.nextBeforeCursor;if(!(!t||f)){p(!0);try{let n=await qg(e,t,c.page.limit);l(e=>e?{...e,items:Vx(e.items,n.items),page:n.page}:n)}catch{h(!0)}finally{p(!1)}}},M=n?Xx(n.assistant||``):null,N=qO(e,!!c||m);return(0,U.jsxs)(Z,{ref:N,spacing:3,children:[c?.page.hasOlder&&(0,U.jsx)(J,{sx:{textAlign:`center`},children:(0,U.jsx)($,{size:`small`,variant:`text`,startIcon:f?(0,U.jsx)(xu,{size:14}):(0,U.jsx)(Ih,{}),disabled:f,onClick:()=>void j(),children:Q(i,`Tải tin cũ hơn`,`Load older messages`)})}),u&&!c&&(0,U.jsx)(J,{sx:{py:5,textAlign:`center`},children:(0,U.jsx)(xu,{size:22})}),m&&!c&&(0,U.jsx)(mC,{severity:`warning`,icon:(0,U.jsx)(eD,{}),children:Q(i,`Chưa tải được lịch sử cuộc trò chuyện. Thử lại bằng nút làm mới.`,`Session history could not be loaded. You can retry with Refresh.`)}),D.map((e,t)=>(0,U.jsx)(RO,{turn:e,locale:i,onContinue:t===D.length-1&&!k&&!r?.pending.length?o:void 0},e.key)),(0,U.jsx)(iD,{sessionRef:e,waiting:!!(n&&!n.complete&&n.activities.some(e=>e.toolLabel===`ask_user`&&e.state===`running`))}),(0,U.jsx)(DS,{sessionRef:e,approvalRefs:r?.pending.map(e=>e.approvalRef)??[]}),k&&n&&(0,U.jsx)(BO,{user:n.user&&!A?n.user:null,attachments:n.attachments,activities:n.activities,assistant:n.error?null:M,running:!n.complete&&!n.error,failure:n.complete&&n.error&&jO.has(n.error)?n.error:null,locale:i,status:(0,U.jsx)(HO,{live:n,locale:i,onOpenActivity:a})})]})}var YO=Y((0,U.jsx)(`path`,{d:`m20.54 5.23-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.16.55L3.46 5.23C3.17 5.57 3 6.02 3 6.5V19c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.48-.17-.93-.46-1.27m-8.89 11.92L6.5 12H10v-2h4v2h3.5l-5.15 5.15c-.19.19-.51.19-.7 0M5.12 5l.81-1h12l.94 1z`}),`ArchiveRounded`),XO=Y((0,U.jsx)(`path`,{d:`M20 4v12H5.17L4 17.17V4zm0-2H4c-1.1 0-2 .9-2 2v15.59c0 .89 1.08 1.34 1.71.71L6 18h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2`}),`ChatBubbleOutlineRounded`),ZO=Y((0,U.jsx)(`path`,{d:`M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2`}),`MoreHorizRounded`),QO=Y((0,U.jsx)(`path`,{d:`M14 4v5c0 1.12.37 2.16 1 3H9c.65-.86 1-1.9 1-3V4zm3-2H7c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3V4h1c.55 0 1-.45 1-1s-.45-1-1-1`}),`PushPinOutlined`),$O=Y((0,U.jsx)(`path`,{d:`M19.5 12c0-.23-.01-.45-.03-.68l1.86-1.41c.4-.3.51-.86.26-1.3l-1.87-3.23c-.25-.44-.79-.62-1.25-.42l-2.15.91c-.37-.26-.76-.49-1.17-.68l-.29-2.31c-.06-.5-.49-.88-.99-.88h-3.73c-.51 0-.94.38-1 .88l-.29 2.31c-.41.19-.8.42-1.17.68l-2.15-.91c-.46-.2-1-.02-1.25.42L2.41 8.62c-.25.44-.14.99.26 1.3l1.86 1.41c-.02.22-.03.44-.03.67s.01.45.03.68l-1.86 1.41c-.4.3-.51.86-.26 1.3l1.87 3.23c.25.44.79.62 1.25.42l2.15-.91c.37.26.76.49 1.17.68l.29 2.31c.06.5.49.88.99.88h3.73c.5 0 .93-.38.99-.88l.29-2.31c.41-.19.8-.42 1.17-.68l2.15.91c.46.2 1 .02 1.25-.42l1.87-3.23c.25-.44.14-.99-.26-1.3l-1.86-1.41c.03-.23.04-.45.04-.68m-7.46 3.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5`}),`SettingsRounded`);function ek(e){return(0,U.jsx)(cl,{viewBox:`0 0 16 16`,...e,children:(0,U.jsx)(`path`,{d:`M5 3.25a.75.75 0 1 1-1.5 0 .75.75 0 0 1 1.5 0Zm0 2.122a2.25 2.25 0 1 0-1.5 0v5.256a2.25 2.25 0 1 0 1.5 0V9.5h3.25a2.75 2.75 0 0 0 2.75-2.75v-1.378a2.25 2.25 0 1 0-1.5 0V6.75c0 .69-.56 1.25-1.25 1.25H5V5.372ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm7.5-9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z`})})}function tk(e,t){return e.detached?Q(t,`Git không ở nhánh nào (detached HEAD tại ${e.name})`,`Git is not on a branch (detached HEAD at ${e.name})`):Q(t,`Nhánh Git của project: ${e.name}`,`The project's Git branch: ${e.name}`)}function nk({branch:e,locale:t,maxWidth:n=220,tooltip:r=!0}){if(!e)return null;let i=(0,U.jsxs)(J,{component:`span`,"aria-label":r?tk(e,t):void 0,sx:{display:`inline-flex`,alignItems:`center`,gap:.4,minWidth:0,maxWidth:n,verticalAlign:`bottom`,color:e.detached?`warning.main`:`inherit`},children:[(0,U.jsx)(ek,{sx:{fontSize:`1.1em`,flexShrink:0}}),(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:`.95em`},children:e.name})]});return r?(0,U.jsx)(Ah,{describeChild:!0,title:tk(e,t),children:i}):i}function rk(e,t){let n=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));if(n<60)return Q(t,`Vừa mới`,`Just now`);let r=Math.floor(n/60);if(r<60)return Q(t,`${r} phút`,`${r}m`);let i=Math.floor(r/60);if(i<24)return Q(t,`${i} giờ`,`${i}h`);let a=Math.floor(i/24);return Q(t,`${a} ngày`,`${a}d`)}function ik(e,t){return t&&!t.complete?`running`:e.state===`terminal-owned`?`elsewhere`:e.state===`recovery-required`?`recovery`:e.needsAttention?`attention`:t?.complete&&t.error?`failed`:e.liveState===`running`?`running`:`idle`}function ak({activity:e,locale:t}){let n={running:`primary.main`,elsewhere:`info.main`,attention:`warning.main`,recovery:`error.main`,failed:`error.main`,idle:`transparent`}[e],r={running:Q(t,`Đang chạy`,`Running`),elsewhere:Q(t,`Đang chạy ở Terminal hoặc tiến trình khác`,`Running in Terminal or another process`),attention:Q(t,`Cần duyệt`,`Needs approval`),recovery:Q(t,`Cần khôi phục`,`Needs recovery`),failed:Q(t,`Lượt cuối lỗi`,`Last turn failed`),idle:``}[e];return(0,U.jsx)(J,{role:e===`idle`?void 0:`img`,"aria-label":r||void 0,title:r,sx:{width:8,height:8,mt:.9,ml:.75,flexShrink:0,borderRadius:`50%`,bgcolor:n,animation:e===`running`||e===`elsewhere`?`piagent-pulse 1.4s ease-in-out infinite`:`none`}})}var ok={clean:[`Đủ bước`,`All steps`],unverified:[`Chưa verify`,`Unverified`],unreviewed:[`Chưa review`,`Not reviewed`],blocking_open:[`Còn lỗi blocking`,`Blocking open`],review_unavailable:[`Không review được`,`Review unavailable`],interrupted:[`Bị dừng`,`Stopped`],disputed:[`Cần bạn quyết`,`Needs your call`]};function sk({session:e,live:t,selected:n,locale:r,onSelect:i,onAction:a,showProject:o=!1}){let[s,c]=(0,v.useState)(null),l=e=>{c(null),a(e)},u=e.modelLabel===`agent-watch-auto`,d=ik(e,t),f=d===`running`?Q(r,`Đang chạy`,`Running`):d===`elsewhere`?Q(r,`Đang chạy ở nơi khác`,`Running elsewhere`):d===`attention`?Q(r,`Cần duyệt`,`Needs approval`):null,p=u&&d!==`running`&&d!==`elsewhere`?e.managedTurnEnd??null:null,m=!p&&u&&e.managedProcess&&e.managedProcess.outcome!==`no_change`?e.managedProcess.outcome:null;return(0,U.jsxs)(J,{sx:{display:`flex`,alignItems:`center`,pr:.5},children:[(0,U.jsxs)(cf,{selected:n,onClick:i,sx:{minWidth:0,alignItems:`flex-start`,py:1,px:1.4},children:[(0,U.jsx)(Cf,{primary:(0,U.jsxs)(U.Fragment,{children:[e.pinned&&(0,U.jsx)(QO,{sx:{fontSize:13,mr:.5,verticalAlign:`-2px`,color:`text.disabled`}}),e.title]}),secondary:(0,U.jsxs)(U.Fragment,{children:[u&&(0,U.jsxs)(J,{component:`span`,sx:{fontWeight:650,color:`primary.main`},children:[Q(r,`Công ty`,`Company`),(0,U.jsx)(`span`,{children:` · `})]}),f??rk(e.updatedAt,r),o&&(0,U.jsxs)(`span`,{children:[` · `,e.projectLabel]}),p&&(0,U.jsxs)(J,{component:`span`,sx:YD(wO(p)),children:[` · `,TO(p,r)]}),m&&(0,U.jsxs)(J,{component:`span`,sx:YD(mO(m)),children:[` · `,Q(r,...ok[m])]})]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13.25,fontWeight:n?600:500}},secondary:{noWrap:!0,sx:{mt:.25,fontSize:11.25}}}}),(0,U.jsx)(ak,{activity:d,locale:r})]}),(0,U.jsx)(Qd,{size:`small`,"aria-label":Q(r,`Tùy chọn cuộc trò chuyện`,`Chat options`),onClick:e=>c(e.currentTarget),children:(0,U.jsx)(ZO,{fontSize:`small`})}),(0,U.jsxs)(Db,{anchorEl:s,open:!!s,onClose:()=>c(null),onClick:e=>e.stopPropagation(),children:[!e.archived&&(0,U.jsx)(xw,{onClick:()=>l(`rename`),children:Q(r,`Đổi tên`,`Rename`)}),!e.archived&&(0,U.jsx)(xw,{onClick:()=>l(`pin`),children:e.pinned?Q(r,`Bỏ ghim`,`Unpin`):Q(r,`Ghim`,`Pin`)}),!e.archived&&(0,U.jsx)(xw,{onClick:()=>l(`fork`),children:Q(r,`Tạo nhánh`,`Fork`)}),(0,U.jsx)(xw,{onClick:()=>l(e.archived?`unarchive`:`archive`),children:e.archived?Q(r,`Bỏ lưu trữ`,`Unarchive`):Q(r,`Lưu trữ`,`Archive`)})]})]})}var ck=5,lk=`piagent.sidebar.collapsed`;function uk(e){try{let t=JSON.parse(window.localStorage.getItem(e)??`[]`);return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`).slice(0,500):[])}catch{return new Set}}function dk(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t].slice(0,500)))}catch{}}function fk({locale:e,canCreate:t,query:n,onQuery:r,groups:i,count:a,selectedRef:o,showArchived:s,archivedCount:c,settingsOpen:l,connection:u,live:d,onNew:f,onSelect:p,onAction:m,onToggleArchived:h,onSettings:g,updateDot:_=!1}){let y=XE(e=>e.breakpoints.down(`md`)),[b,x]=(0,v.useState)(`all`),[S,C]=(0,v.useState)(()=>uk(lk)),[w,T]=(0,v.useState)(()=>new Set),E=n.trim().length>0,D=e=>e.modelLabel===`agent-watch-auto`,O=i.flatMap(e=>e.sessions),k={company:O.filter(D).length,personal:O.filter(e=>!D(e)).length},A=(0,v.useMemo)(()=>i.map(e=>({...e,sessions:e.sessions.filter(e=>b===`all`||b===`company`===D(e))})).filter(e=>e.sessions.length>0),[i,b]),j=A.reduce((e,t)=>e+t.sessions.length,0),M=s?[]:A.flatMap(e=>e.sessions).filter(e=>ik(e,d[e.sessionRef])!==`idle`),N=(e,t,n)=>e(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),n&&dk(lk,r),r});return(0,U.jsxs)(J,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,bgcolor:`background.paper`},children:[(0,U.jsxs)(up,{sx:{minHeight:`60px !important`,px:`16px !important`,gap:1.1},children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:600},children:`Piagent`}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:Q(e,`Coding agent`,`Coding agent`)})]})]}),(0,U.jsxs)(J,{sx:{px:1.25},children:[(0,U.jsx)(Ah,{title:t?Q(e,`Tạo cuộc trò chuyện mới`,`Create a new chat`):Q(e,`Gateway hiện chưa cho phép tạo cuộc trò chuyện`,`The Gateway cannot create chats right now`),children:(0,U.jsx)(`span`,{children:(0,U.jsx)($,{fullWidth:!0,disabled:!t,variant:`outlined`,onClick:f,startIcon:(0,U.jsx)(JS,{}),sx:{justifyContent:`flex-start`,py:1},children:Q(e,`Cuộc trò chuyện mới`,`New chat`)})})}),(0,U.jsx)(dx,{value:n,onChange:e=>r(e.target.value),fullWidth:!0,size:`small`,placeholder:Q(e,`Tìm cuộc trò chuyện`,`Search chats`),sx:{mt:1.1},slotProps:{input:{startAdornment:(0,U.jsx)(py,{position:`start`,children:(0,U.jsx)(fx,{fontSize:`small`})})}}})]}),(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,px:2,pt:2,pb:.4},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:600,textTransform:`uppercase`,letterSpacing:`.08em`},children:s?Q(e,`Đã lưu trữ`,`Archived`):Q(e,`Cuộc trò chuyện`,`Chats`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:j})]}),k.company>0&&k.personal>0&&(0,U.jsx)(Z,{direction:`row`,role:`group`,"aria-label":Q(e,`Lọc theo loại`,`Filter by kind`),sx:{px:1.75,pb:.5,gap:.5,flexWrap:`wrap`},children:[`all`,`company`,`personal`].map(t=>(0,U.jsx)(lu,{size:`small`,clickable:!0,"aria-pressed":b===t,onClick:()=>x(t),color:b===t?`primary`:`default`,variant:b===t?`filled`:`outlined`,label:t===`all`?Q(e,`Tất cả`,`All`):t===`company`?Q(e,`Công ty · ${k.company}`,`Company · ${k.company}`):Q(e,`Cá nhân · ${k.personal}`,`Personal · ${k.personal}`)},t))}),(0,U.jsxs)(rf,{component:`div`,sx:{flex:1,minHeight:0,overflowY:`auto`,py:.25},children:[M.length>0&&(0,U.jsxs)(J,{component:`section`,"aria-label":Q(e,`Đang chạy hoặc cần chú ý`,`Running or needing attention`),sx:{mt:.5},children:[(0,U.jsx)(X,{component:`div`,variant:`caption`,color:`text.secondary`,sx:{px:2,py:.55,fontWeight:600},children:Q(e,`Đang chạy · cần chú ý`,`Running · needs attention`)}),M.map(t=>(0,U.jsx)(sk,{session:t,live:d[t.sessionRef],showProject:!0,selected:o===t.sessionRef,locale:e,onSelect:()=>p(t.sessionRef),onAction:e=>m(t,e)},t.sessionRef)),(0,U.jsx)(Du,{sx:{mx:2,mt:.75}})]}),A.map(t=>{let n=t.sessions.some(e=>e.sessionRef===o),r=E||n||!S.has(t.projectRef),i=E||w.has(t.projectRef),a=i?t.sessions:t.sessions.filter((e,t)=>t<ck||e.sessionRef===o);return(0,U.jsxs)(J,{component:`section`,"aria-label":t.label,sx:{mt:.5},children:[(0,U.jsxs)(tu,{onClick:()=>N(C,t.projectRef,!0),"aria-expanded":r,sx:{width:`100%`,justifyContent:`flex-start`,gap:.7,px:2,py:.55,borderRadius:1},children:[(0,U.jsx)(wT,{sx:{fontSize:16,color:`text.disabled`,transform:r?`none`:`rotate(-90deg)`,transition:`transform .15s`}}),(0,U.jsx)(TT,{sx:{fontSize:15,color:`text.disabled`}}),(0,U.jsx)(X,{component:`div`,variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{flexShrink:1,minWidth:0,fontWeight:600,textAlign:`left`},children:t.label}),(0,U.jsx)(X,{component:`div`,variant:`caption`,color:`text.disabled`,sx:{flex:1,minWidth:0,display:`flex`,textAlign:`left`},children:t.gitBranch?(0,U.jsx)(nk,{branch:t.gitBranch,locale:e,maxWidth:`100%`}):t.gitRepositories?.length?(0,U.jsxs)(J,{component:`span`,title:t.gitRepositories.map(e=>`${e.name} · ${e.branch?.name??`?`}`).join(`
|
|
178
|
+
`),sx:{display:`inline-flex`,alignItems:`center`,gap:.4,whiteSpace:`nowrap`},children:[(0,U.jsx)(ek,{sx:{fontSize:`1.1em`}}),Q(e,`${t.gitRepositories.length} repo`,`${t.gitRepositories.length} repos`)]}):null}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:t.sessions.length})]}),r&&a.map(t=>(0,U.jsx)(sk,{session:t,live:d[t.sessionRef],selected:o===t.sessionRef,locale:e,onSelect:()=>p(t.sessionRef),onAction:e=>m(t,e)},t.sessionRef)),r&&!E&&t.sessions.length>ck&&(0,U.jsx)($,{size:`small`,onClick:()=>N(T,t.projectRef,!1),sx:{ml:1.5,mb:.25,fontSize:12},children:i?Q(e,`Thu gọn`,`Show less`):Q(e,`Xem thêm ${t.sessions.length-ck}`,`Show ${t.sessions.length-ck} more`)})]},t.projectRef)}),j===0&&(0,U.jsxs)(Z,{sx:{alignItems:`center`,textAlign:`center`,px:3,py:5},spacing:1,children:[(0,U.jsx)(XO,{color:`disabled`}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(e,`Không tìm thấy cuộc trò chuyện`,`No conversations found`)})]})]}),(0,U.jsxs)(J,{sx:{p:1.25},children:[(0,U.jsx)(Du,{sx:{mb:1}}),(0,U.jsx)($,{fullWidth:!0,startIcon:(0,U.jsx)(YO,{}),disabled:!s&&c===0,onClick:h,sx:{justifyContent:`flex-start`},children:s?Q(e,`Quay lại cuộc trò chuyện`,`Back to chats`):Q(e,`Đã lưu trữ (${c})`,`Archived (${c})`)}),(0,U.jsxs)($,{fullWidth:!0,startIcon:(0,U.jsx)($O,{}),onClick:g,sx:{justifyContent:`flex-start`,mt:.25},color:l?`primary`:`inherit`,children:[Q(e,`Cài đặt`,`Settings`),_&&(0,U.jsx)(J,{component:`span`,role:`img`,"aria-label":Q(e,`Có bản cập nhật`,`Update available`),sx:{ml:`auto`,width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`}})]}),y&&(0,U.jsxs)(Z,{direction:`row`,sx:{px:1.25,pt:1,alignItems:`center`,gap:1},children:[(0,U.jsx)(J,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:u===`connected`?`success.main`:`warning.main`}}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{flex:1},children:u===`connected`?`Gateway live`:u}),(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,children:`local`})]})]})]})}var pk=Y((0,U.jsx)(`path`,{d:`M18 19H6c-.55 0-1-.45-1-1V6c0-.55.45-1 1-1h12c.55 0 1 .45 1 1v12c0 .55-.45 1-1 1m1-16H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2`}),`CheckBoxOutlineBlankRounded`),mk=Y((0,U.jsx)(`path`,{d:`M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-8.29 13.29c-.39.39-1.02.39-1.41 0L5.71 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.41z`}),`CheckBoxRounded`),hk=Y((0,U.jsx)(`path`,{d:`m10.8 15.9 4.67-3.5c.27-.2.27-.6 0-.8L10.8 8.1c-.33-.25-.8-.01-.8.4v7c0 .41.47.65.8.4M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8`}),`PlayCircleOutlineRounded`),gk=Y((0,U.jsx)(`path`,{d:`M7 12c0 .55.45 1 1 1h8c.55 0 1-.45 1-1s-.45-1-1-1H8c-.55 0-1 .45-1 1m5-10C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8`}),`RemoveCircleOutlineRounded`);function _k(e){return Gr(`MuiLinearProgress`,e)}Kr(`MuiLinearProgress`,[`root`,`colorPrimary`,`colorSecondary`,`determinate`,`indeterminate`,`buffer`,`query`,`dashed`,`bar`,`bar1`,`bar2`]);var vk=4,yk={},bk=Dt`
|
|
178
179
|
0% {
|
|
179
180
|
left: -35%;
|
|
180
181
|
right: 100%;
|
|
@@ -189,9 +190,9 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
189
190
|
left: 100%;
|
|
190
191
|
right: -90%;
|
|
191
192
|
}
|
|
192
|
-
`,
|
|
193
|
-
animation: ${
|
|
194
|
-
`,
|
|
193
|
+
`,xk=typeof bk==`string`?null:Et`
|
|
194
|
+
animation: ${bk} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
|
|
195
|
+
`,Sk=Dt`
|
|
195
196
|
0% {
|
|
196
197
|
left: -200%;
|
|
197
198
|
right: 100%;
|
|
@@ -206,9 +207,9 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
206
207
|
left: 107%;
|
|
207
208
|
right: -8%;
|
|
208
209
|
}
|
|
209
|
-
`,
|
|
210
|
-
animation: ${
|
|
211
|
-
`,
|
|
210
|
+
`,Ck=typeof Sk==`string`?null:Et`
|
|
211
|
+
animation: ${Sk} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite;
|
|
212
|
+
`,wk=Dt`
|
|
212
213
|
0% {
|
|
213
214
|
opacity: 1;
|
|
214
215
|
background-position: 0 -23px;
|
|
@@ -223,6 +224,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
223
224
|
opacity: 1;
|
|
224
225
|
background-position: -200px -23px;
|
|
225
226
|
}
|
|
226
|
-
`,
|
|
227
|
-
animation: ${
|
|
228
|
-
`,hk=e=>{let{classes:t,variant:n,color:r}=e;return ba({root:[`root`,`color${q(r)}`,n],dashed:[`dashed`],bar1:[`bar`,`bar1`],bar2:[`bar`,`bar2`,n===`buffer`&&`color${q(r)}`]},ok,t)},gk=(e,t)=>e.vars?e.vars.palette.LinearProgress[`${t}Bg`]:e.palette.mode===`light`?e.lighten(e.palette[t].main,.62):e.darken(e.palette[t].main,.5),_k=K(`span`,{name:`MuiLinearProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`color${q(n.color)}`],t[n.variant]]}})(ys(({theme:e})=>({position:`relative`,overflow:`hidden`,display:`block`,height:4,zIndex:0,"@media print":{colorAdjust:`exact`},variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{backgroundColor:gk(e,t)}})),{props:({ownerState:e})=>e.color===`inherit`&&e.variant!==`buffer`,style:{"&::before":{content:`""`,position:`absolute`,left:0,top:0,right:0,bottom:0,backgroundColor:`currentColor`,opacity:.3}}},{props:{variant:`buffer`},style:{backgroundColor:`transparent`}},{props:{variant:`query`},style:{transform:`rotate(180deg)`}}]}))),vk=K(`span`,{name:`MuiLinearProgress`,slot:`Dashed`})(ys(({theme:e})=>({position:`absolute`,marginTop:0,height:`100%`,width:`100%`,backgroundSize:`10px 10px`,backgroundPosition:`0 -23px`,variants:[{props:{color:`inherit`},style:{opacity:.3,backgroundImage:`radial-gradient(currentColor 0%, currentColor 16%, transparent 42%)`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>{let n=gk(e,t);return{props:{color:t},style:{backgroundImage:`radial-gradient(${n} 0%, ${n} 16%, transparent 42%)`}}})]})),mk||{animation:`${pk} 3s infinite linear`},ys(({theme:e})=>Gs(e,{animation:`none`})||ck)),yk=K(`span`,{name:`MuiLinearProgress`,slot:`Bar1`,overridesResolver:(e,t)=>[t.bar,t.bar1]})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`,left:`30%`,right:`auto`,width:`40%`});return{width:`100%`,position:`absolute`,left:0,bottom:0,top:0,...Ks(e,`transform`,{duration:`0.2s`,easing:`linear`}),transformOrigin:`left`,variants:[{props:{color:`inherit`},style:{backgroundColor:`currentColor`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{backgroundColor:(e.vars||e).palette[t].main}})),{props:{variant:`determinate`},style:{...Ks(e,`transform`,{duration:`.${sk}s`,easing:`linear`})}},{props:{variant:`buffer`},style:{zIndex:1,...Ks(e,`transform`,{duration:`.${sk}s`,easing:`linear`})}},{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:{width:`auto`}},{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:uk||{animation:`${lk} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:t}]:[]]}})),bk=K(`span`,{name:`MuiLinearProgress`,slot:`Bar2`,overridesResolver:(e,t)=>[t.bar,t.bar2]})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`,display:`none`});return{width:`100%`,position:`absolute`,left:0,bottom:0,top:0,...Ks(e,`transform`,{duration:`0.2s`,easing:`linear`}),transformOrigin:`left`,variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{"--LinearProgressBar2-barColor":(e.vars||e).palette[t].main}})),{props:({ownerState:e})=>e.variant!==`buffer`&&e.color!==`inherit`,style:{backgroundColor:`var(--LinearProgressBar2-barColor, currentColor)`}},{props:({ownerState:e})=>e.variant!==`buffer`&&e.color===`inherit`,style:{backgroundColor:`currentColor`}},{props:{color:`inherit`},style:{opacity:.3}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t,variant:`buffer`},style:{backgroundColor:gk(e,t),...Ks(e,`transform`,{duration:`.${sk}s`,easing:`linear`})}})),{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:{width:`auto`}},{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:fk||{animation:`${dk} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:t}]:[]]}})),xk=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiLinearProgress`}),{className:r,color:i=`primary`,max:a,min:o,value:s,valueBuffer:c,variant:l=`indeterminate`,...u}=n,d={...n,color:i,variant:l},f=o??0,p=a??100,m=hk(d),h=Ri(),g={},_={bar1:{},bar2:{}};if((l===`determinate`||l===`buffer`)&&s!==void 0){let e=p-f,t=(s-f)/e*100-100;h&&(t=-t),_.bar1.transform=e>0?`translateX(${t}%)`:`translateX(-100%)`,g[`aria-valuenow`]=s,g[`aria-valuemin`]=f,g[`aria-valuemax`]=p}if(l===`buffer`&&c!==void 0){let e=p-f,t=(c-f)/e*100-100;h&&(t=-t),_.bar2.transform=e>0?`translateX(${t}%)`:`translateX(-100%)`}return(0,U.jsxs)(_k,{className:W(m.root,r),ownerState:d,role:`progressbar`,...g,ref:t,...u,children:[l===`buffer`?(0,U.jsx)(vk,{className:m.dashed,ownerState:d}):null,(0,U.jsx)(yk,{className:m.bar1,ownerState:d,style:_.bar1}),l===`determinate`?null:(0,U.jsx)(bk,{className:m.bar2,ownerState:d,style:_.bar2})]})}),Sk=`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,Ck={A:`success`,M:`warning`,D:`error`,R:`info`,C:`info`,U:`success`};function wk({title:e,action:t,children:n}){return(0,U.jsxs)(J,{component:`section`,sx:{px:2,py:1.75,borderBottom:1,borderColor:`divider`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,mb:1},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{fontWeight:650,textTransform:`uppercase`,letterSpacing:`.06em`},children:e}),t]}),n]})}function Tk({session:e,snapshot:t,live:n,locale:r,onOpenReview:i,onClose:a}){let[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(!1),u=!!(n&&!n.complete);(0,v.useEffect)(()=>{if(u)return;let t=new AbortController;l(!1);let n=window.setTimeout(()=>void Jg(e.sessionRef,`working-tree`,t.signal).then(e=>s(e)).catch(()=>{t.signal.aborted||l(!0)}),250);return()=>{window.clearTimeout(n),t.abort()}},[e.sessionRef,e.sessionRevision,u]),(0,v.useEffect)(()=>{s(void 0)},[e.sessionRef]);let d=o?.files??[],f=d.reduce((e,t)=>e+(t.stats?.additions??0),0),p=d.reduce((e,t)=>e+(t.stats?.deletions??0),0),m=t?.usage.context,h=m?.state===`known`,g=h?m.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,_=h?m.contextWindow:e.contextUsage.contextWindow,y=h?m.tokens:e.contextUsage.usedTokens,b=e.managedHelpers?.maximum===0?void 0:e.managedHelpers,x=e.managedPlan,S=e.managedProcess,C=x?.steps.filter(e=>e.status===`completed`).length??0,w=(n?.activities??[]).filter(e=>ZD(e.toolLabel)===`subagent`);return(0,U.jsxs)(J,{role:`region`,sx:{height:`100%`,overflowY:`auto`,bgcolor:`background.paper`},"aria-label":Q(r,`Thay đổi và ngữ cảnh`,`Changes and context`),children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1,px:2,minHeight:60,borderBottom:1,borderColor:`divider`},children:[(0,U.jsx)(X,{sx:{fontWeight:600,flex:1},children:Q(r,`Workspace`,`Workspace`)}),a&&(0,U.jsx)(Qd,{size:`small`,"aria-label":Q(r,`Đóng khung bên`,`Close side panel`),onClick:a,children:(0,U.jsx)(qE,{fontSize:`small`})})]}),(0,U.jsxs)(wk,{title:o?Q(r,`Thay đổi · ${d.length} file`,`Changes · ${d.length} files`):Q(r,`Thay đổi`,`Changes`),action:d.length>0?(0,U.jsx)(Ah,{title:Q(r,`Xem diff đầy đủ, stage hoặc hoàn tác`,`Full diff, stage or revert`),children:(0,U.jsx)($,{size:`small`,startIcon:(0,U.jsx)(Ph,{fontSize:`small`}),onClick:i,children:Q(r,`Review`,`Review`)})}):void 0,children:[(f>0||p>0)&&(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:.75,mb:1,color:`text.secondary`},children:[(0,U.jsx)(RD,{sx:{fontSize:15}}),(0,U.jsx)(X,{variant:`caption`,children:Q(r,`Chưa commit`,`Uncommitted`)}),(0,U.jsxs)(X,{variant:`caption`,sx:{fontFamily:Sk,ml:`auto`},children:[(0,U.jsxs)(J,{component:`span`,sx:KD(`success`),children:[`+`,f]}),` `,(0,U.jsxs)(J,{component:`span`,sx:KD(`error`),children:[`−`,p]})]})]}),o===void 0&&!c&&(u?(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(r,`Cập nhật khi lượt này chạy xong.`,`Updates when this turn finishes.`)}):(0,U.jsx)(xk,{sx:{borderRadius:1}})),(c||o?.availability.state===`unavailable`)&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(r,`Chưa đọc được thay đổi (thư mục có thể không phải git repo).`,`Changes are unavailable (the folder may not be a git repository).`)}),o&&o.availability.state!==`unavailable`&&d.length===0&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(r,`Chưa có thay đổi nào chưa commit.`,`No uncommitted changes.`)}),(0,U.jsx)(Z,{spacing:.25,children:d.slice(0,200).map(e=>(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1,py:.4},children:[(0,U.jsx)(X,{variant:`caption`,sx:{fontFamily:Sk,fontWeight:700,width:12,...Ck[e.status]?KD(Ck[e.status]):{color:`text.secondary`}},children:e.status}),(0,U.jsx)(X,{variant:`body2`,noWrap:!0,title:e.path,sx:{fontFamily:Sk,fontSize:12.5,flex:1,minWidth:0},children:e.path}),(0,U.jsxs)(X,{variant:`caption`,sx:{fontFamily:Sk,flexShrink:0},children:[(e.stats?.additions??0)>0&&(0,U.jsxs)(J,{component:`span`,sx:KD(`success`),children:[`+`,e.stats.additions,` `]}),(e.stats?.deletions??0)>0&&(0,U.jsxs)(J,{component:`span`,sx:KD(`error`),children:[`−`,e.stats.deletions]})]})]},e.fileRef))})]}),(x||S)&&(0,U.jsxs)(wk,{title:x?Q(r,`Plan · ${C}/${x.steps.length}`,`Plan · ${C}/${x.steps.length}`):Q(r,`Tiến trình`,`Process`),children:[x&&(0,U.jsx)(Z,{component:`ol`,spacing:.25,sx:{m:0,p:0,listStyle:`none`},"aria-label":Q(r,`Plan của agent`,`Agent plan`),children:x.steps.map((e,t)=>{let n=e.status===`completed`?ik:e.status===`in_progress`?ak:rk;return(0,U.jsxs)(Z,{component:`li`,direction:`row`,sx:{alignItems:`flex-start`,gap:.75,py:.25},"aria-label":`${e.step}: ${e.status===`completed`?Q(r,`xong`,`done`):e.status===`in_progress`?Q(r,`đang làm`,`in progress`):Q(r,`chưa làm`,`pending`)}`,children:[(0,U.jsx)(n,{sx:{fontSize:16,mt:.2,color:e.status===`in_progress`?`primary.main`:`text.secondary`}}),(0,U.jsx)(X,{variant:`body2`,sx:{flex:1,minWidth:0,overflowWrap:`anywhere`,...e.status===`completed`?{color:`text.secondary`,textDecoration:`line-through`}:{},...e.status===`in_progress`?{fontWeight:600}:{}},children:e.step})]},t)})}),S&&S.outcome!==`no_change`&&(0,U.jsxs)(X,{variant:`body2`,role:`status`,sx:{mt:+!!x,...KD(fO(S))},children:[Q(r,`Lượt sửa code gần nhất: `,`Last code-changing turn: `),uO(S,r)]})]}),(0,U.jsxs)(wk,{title:Q(r,`Ngữ cảnh`,`Context`),children:[(0,U.jsxs)(Z,{direction:`row`,sx:{justifyContent:`space-between`,mb:.75},children:[(0,U.jsx)(X,{variant:`body2`,children:g==null?`—`:`${Math.round(g)}%`}),(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,children:[y?kD(y):`—`,_?` / ${kD(_)}`:``]})]}),(0,U.jsx)(xk,{variant:`determinate`,value:Math.min(100,Math.max(0,g??0)),sx:{height:6,borderRadius:3},color:(g??0)>85?`warning`:`primary`,"aria-label":Q(r,`Mức dùng ngữ cảnh`,`Context usage`)})]}),(b||w.length>0)&&(0,U.jsxs)(wk,{title:`Subagent`,children:[b&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:w.length?.75:0},children:Q(r,`${b.active??0}/${b.maximum} đang chạy`,`${b.active??0}/${b.maximum} running`)}),w.map(e=>(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:.75,py:.25},children:[(0,U.jsx)(FD,{sx:{fontSize:15,color:`text.secondary`}}),(0,U.jsx)(X,{variant:`body2`,sx:{flex:1},children:e.fileLabel??`subagent`}),(0,U.jsx)(X,{variant:`caption`,color:e.state===`failed`?`error`:`text.secondary`,children:e.state===`running`?Q(r,`đang chạy`,`running`):e.state===`failed`?Q(r,`lỗi`,`failed`):Q(r,`xong`,`done`)})]},e.toolCallRef))]})]})}var Ek=Y((0,U.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`),Dk=Y((0,U.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 Ok({catalog:e,refresh:t}){let{locale:n}=Gv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!r||r.state!==`running`)return;let e=new AbortController,a=window.setTimeout(()=>{Fg(r.jobRef,e.signal).then(e=>{i(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||u(Q(n,`Mất kết nối với luồng OAuth`,`OAuth flow disconnected`))})},750);return()=>{e.abort(),window.clearTimeout(a)}},[r?.jobRef,r?.generatedAt,r?.state,n]),(0,v.useEffect)(()=>o(``),[r?.prompt?.promptRef]);let d=async e=>{c(!0),u(null);try{i(await Lg(e))}catch{u(Q(n,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{c(!1)}},f=async()=>{if(!(!r?.prompt||!a)){c(!0),u(null);try{i(await Rg(r.jobRef,r.prompt.promptRef,a))}catch{u(Q(n,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{c(!1)}}},p=async()=>{r?.state===`running`&&await zg(r.jobRef).catch(()=>void 0),i(void 0),u(null)},m=r?.events.slice(-4)??[];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,U.jsx)(Pc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,U.jsx)(jw,{name:e.name,size:38}),(0,U.jsx)(X,{sx:{flex:1,fontWeight:800},children:e.name}),e.state===`connected`&&(0,U.jsx)(lu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,U.jsx)(Dk,{}),label:Q(n,`Đã kết nối`,`Connected`)}),(0,U.jsx)($,{size:`small`,variant:`outlined`,disabled:s,onClick:()=>void d(e.providerRef),children:e.state===`connected`?Q(n,`Kết nối lại`,`Reconnect`):Q(n,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(n,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),l&&!r&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:l}),(0,U.jsxs)(zC,{open:!!r,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,U.jsx)(Kw,{children:r?.providerName??`OAuth`}),(0,U.jsx)(Uw,{children:(0,U.jsxs)(Z,{spacing:1.25,sx:{pt:.5},children:[r?.state===`completed`&&(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsx)(Dk,{color:`success`}),(0,U.jsx)(X,{children:Q(n,`Đã kết nối`,`Connected`)})]}),m.map(e=>(0,U.jsxs)(J,{children:[e.message&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,U.jsx)(X,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:800,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,U.jsx)($,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,U.jsx)(Nw,{}),children:Q(n,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,U.jsx)($,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??Q(n,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),r?.prompt&&(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`body2`,sx:{mb:1},children:r.prompt.message}),r.prompt.type===`select`?(0,U.jsx)(ax,{fullWidth:!0,size:`small`,value:a,onChange:e=>o(e.target.value),children:r.prompt.options.map(e=>(0,U.jsx)(bw,{value:e.id,children:e.label},e.id))}):(0,U.jsx)(ux,{fullWidth:!0,size:`small`,value:a,placeholder:r.prompt.placeholder??void 0,onChange:e=>o(e.target.value)})]}),r&&[`failed`,`cancelled`].includes(r.state)&&(0,U.jsx)(X,{color:`error`,variant:`body2`,children:Fv(r.reasonCode??r.state,n)}),l&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`body2`,children:l})]})}),(0,U.jsxs)(Lw,{children:[(0,U.jsx)($,{color:`inherit`,onClick:()=>void p(),children:r?.state===`running`?Q(n,`Hủy`,`Cancel`):Q(n,`Đóng`,`Close`)}),r?.prompt&&(0,U.jsx)($,{variant:`contained`,disabled:s||!a,onClick:()=>void f(),children:Q(n,`Tiếp tục`,`Continue`)})]})]})]})}var kk=Y((0,U.jsx)(`path`,{d:`M10.67 21c-.35 0-.62-.31-.57-.66L11 14H7.5c-.88 0-.33-.75-.31-.78 1.26-2.23 3.15-5.53 5.65-9.93.1-.18.3-.29.5-.29.35 0 .62.31.57.66l-.9 6.34h3.51c.4 0 .62.19.4.66-3.29 5.74-5.2 9.09-5.75 10.05-.1.18-.29.29-.5.29`}),`BoltRounded`),Ak=Y((0,U.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`),jk=Y((0,U.jsx)(`path`,{d:`M14 9h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1m-1 4h-2v-2h2zm8-3c0-.55-.45-1-1-1h-1V7c0-1.1-.9-2-2-2h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v1h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v1H7c-1.1 0-2 .9-2 2v2H4c-.55 0-1 .45-1 1s.45 1 1 1h1v2H4c-.55 0-1 .45-1 1s.45 1 1 1h1v2c0 1.1.9 2 2 2h2v1c0 .55.45 1 1 1s1-.45 1-1v-1h2v1c0 .55.45 1 1 1s1-.45 1-1v-1h2c1.1 0 2-.9 2-2v-2h1c.55 0 1-.45 1-1s-.45-1-1-1h-1v-2h1c.55 0 1-.45 1-1m-5 7H8c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1h8c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1`}),`MemoryRounded`),Mk=Y([(0,U.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,U.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`),Nk=Y((0,U.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 Pk({icon:e,title:t,detail:n,children:r}){return(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,U.jsx)(J,{sx:{width:38,height:38,borderRadius:2,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{sx:{fontWeight:820},children:t}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function Fk({children:e}){return(0,U.jsx)(Z,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function Ik({session:e,options:t,connections:n,onCompleted:r}){let{locale:i}=Gv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(e?.sessionRevision??``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``);(0,v.useEffect)(()=>{f(e?.sessionRevision??``),c(void 0),u(null)},[e?.sessionRef]),(0,v.useEffect)(()=>{e?.sessionRevision&&f(e.sessionRevision)},[e?.sessionRevision]);let w=a||!e||!d||e.liveState===`running`||e.liveState===`waiting-approval`,T=t?.profiles??[],E=(0,v.useMemo)(()=>(n?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[n]),D=s?.outputs.find(e=>e.customType===`piagent-service-tier-receipt`)?.details,O=async(t,n=null,a=!1)=>{if(!(!e||!d)){o(!0),u(null);try{let i=await i_({schemaVersion:1,version:`piagent-runtime-command-v1`,messageType:`command`,requestId:`runtime_${crypto.randomUUID().replaceAll(`-`,`_`)}`,sessionRef:e.sessionRef,expectedSessionRevision:d,action:t,argument:n,confirmed:a});c(i),i.sessionRevisionAfter&&f(i.sessionRevisionAfter),i.state!==`settled`&&u(i.reasonCode??i.resultCode),await r?.()}catch{u(Q(i,`Gateway chưa thể chạy điều khiển này.`,`The Gateway could not run this control.`))}finally{o(!1)}}},k=(e,t,n,r)=>m({action:e,argument:t,title:n,description:r}),A={size:`small`,variant:`outlined`,disabled:w};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:.75},children:Q(i,`Điều khiển project`,`Project controls`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{mb:2.5},children:Q(i,`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,U.jsx)(Pc,{variant:`outlined`,sx:{p:2,borderRadius:2.5,mb:2},children:(0,U.jsx)(X,{color:`text.secondary`,children:Q(i,`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,U.jsxs)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,U.jsxs)(Pk,{icon:(0,U.jsx)(Nk,{color:`primary`}),title:Q(i,`Runtime & token`,`Runtime & tokens`),detail:Q(i,`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,U.jsxs)(Fk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`runtime.status`),children:`Pi status`}),(0,U.jsx)($,{...A,onClick:()=>void O(`runtime.inspector`),children:`Inspector`}),(0,U.jsx)($,{...A,onClick:()=>void O(`orchestration.status`),children:`Orchestration`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.live`),children:`Usage live`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.history`),children:`History`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.logs`),children:`Logs`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.efficiency`),children:`Efficiency`})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(ux,{size:`small`,fullWidth:!0,label:Q(i,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:b,onChange:e=>x(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,U.jsx)($,{...A,sx:{whiteSpace:`nowrap`},onClick:()=>void O(`usage.preflight`,b.trim()||null),children:`Preflight`})]})]}),(0,U.jsx)(Pk,{icon:(0,U.jsx)(kk,{color:`primary`}),title:Q(i,`Fast mode`,`Fast mode`),detail:Q(i,`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,U.jsxs)(Fk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`runtime.fast-status`),children:Q(i,`Trạng thái`,`Status`)}),(0,U.jsx)($,{...A,color:`primary`,onClick:()=>k(`runtime.fast-on`,null,Q(i,`Bật Fast mode?`,`Enable Fast mode?`),Q(i,`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:Q(i,`Bật Fast`,`Enable Fast`)}),(0,U.jsx)($,{...A,onClick:()=>k(`runtime.fast-off`,null,Q(i,`Tắt Fast mode?`,`Disable Fast mode?`),Q(i,`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:Q(i,`Tắt Fast`,`Disable Fast`)})]})}),(0,U.jsxs)(Pk,{icon:(0,U.jsx)(Mk,{color:`primary`}),title:Q(i,`Profile`,`Profile`),detail:Q(i,`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,U.jsxs)(Fk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`profile.status`),children:Q(i,`Profile hiện tại`,`Current profile`)}),(0,U.jsx)($,{...A,onClick:()=>void O(`profile.options`),children:Q(i,`Danh sách profile`,`Profile options`)}),(0,U.jsx)($,{...A,onClick:()=>void O(`profile.tech-options`),children:Q(i,`Tech theo vai trò`,`Tech options`)})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(ax,{size:`small`,fullWidth:!0,displayEmpty:!0,value:h,onChange:e=>g(e.target.value),disabled:w,renderValue:e=>e?T.find(t=>t.id===e)?.displayName??e:Q(i,`Chọn profile…`,`Select profile…`),children:T.map(e=>(0,U.jsx)(bw,{value:e.id,children:e.displayName},e.id))}),(0,U.jsx)($,{...A,disabled:w||!h,sx:{whiteSpace:`nowrap`},onClick:()=>k(`profile.apply`,h,Q(i,`Áp dụng profile?`,`Apply profile?`),Q(i,`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:Q(i,`Áp dụng`,`Apply`)}),(0,U.jsx)($,{...A,onClick:()=>k(`profile.auto`,null,Q(i,`Tự nhận diện profile?`,`Auto-detect profile?`),Q(i,`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,U.jsxs)(Pk,{icon:(0,U.jsx)(Ak,{color:`primary`}),title:Q(i,`Context engine`,`Context engine`),detail:Q(i,`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,U.jsxs)(Fk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`context.status`),children:`Index status`}),(0,U.jsx)($,{...A,onClick:()=>void O(`context.efficiency`),children:`Efficiency`}),(0,U.jsx)($,{...A,onClick:()=>void O(`context.impact`),children:`Impact`}),(0,U.jsx)($,{...A,color:`warning`,onClick:()=>k(`context.rebuild`,null,Q(i,`Rebuild context index?`,`Rebuild context index?`),Q(i,`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,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(ux,{size:`small`,fullWidth:!0,label:Q(i,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:_,onChange:e=>y(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,U.jsx)($,{...A,disabled:w||!_.trim(),onClick:()=>void O(`context.search`,_.trim()),children:`Search`}),(0,U.jsx)($,{...A,disabled:w||!_.trim(),onClick:()=>void O(`context.pack`,_.trim()),children:`Pack`}),(0,U.jsx)($,{...A,color:`warning`,onClick:()=>k(`context.compact`,_.trim()||null,Q(i,`Compact context bằng model?`,`Compact context with the model?`),Q(i,`Đâ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,U.jsx)(Pk,{icon:(0,U.jsx)(jk,{color:`primary`}),title:Q(i,`Memory`,`Memory`),detail:Q(i,`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,U.jsx)(Fk,{children:(0,U.jsx)($,{...A,onClick:()=>void O(`memory.status`),children:Q(i,`Kiểm tra memory`,`Check memory`)})})}),(0,U.jsxs)(Pk,{icon:(0,U.jsx)(iw,{color:`primary`}),title:Q(i,`MCP governance`,`MCP governance`),detail:Q(i,`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,U.jsxs)(Fk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`mcp.status`),children:`MCP status`}),(0,U.jsx)($,{...A,onClick:()=>void O(`mcp.doctor`),children:`Doctor`})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(ax,{size:`small`,fullWidth:!0,displayEmpty:!0,value:S,onChange:e=>C(e.target.value),disabled:w,renderValue:e=>e||Q(i,`Chọn MCP…`,`Select MCP…`),children:E.map(e=>(0,U.jsx)(bw,{value:e.name,children:e.name},e.connectionRef))}),(0,U.jsx)($,{...A,disabled:w||!S,onClick:()=>void O(`mcp.detail`,S),children:`Detail`}),(0,U.jsx)($,{...A,disabled:w||!S,onClick:()=>k(`mcp.approve`,S,Q(i,`Phê duyệt MCP?`,`Approve MCP?`),Q(i,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,U.jsx)($,{...A,disabled:w||!S,color:`warning`,onClick:()=>k(`mcp.reject`,S,Q(i,`Từ chối MCP?`,`Reject MCP?`),Q(i,`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,U.jsx)($,{...A,disabled:w||!S,color:`warning`,onClick:()=>k(`mcp.reset`,S,Q(i,`Reset quyết định MCP?`,`Reset MCP decision?`),Q(i,`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`})]})]})]}),(a||s||l)&&(0,U.jsx)(Pc,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:2.5},children:a?(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsx)(xu,{size:18}),(0,U.jsx)(X,{children:Q(i,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,U.jsx)(Mw,{color:s?.state===`settled`?`success`:`warning`}),(0,U.jsx)(X,{sx:{fontWeight:800},children:s?s.action:Q(i,`Không hoàn tất`,`Not completed`)}),s&&(0,U.jsx)(lu,{size:`small`,color:s.state===`settled`?`success`:`warning`,variant:`outlined`,label:s.resultCode}),(s?.effect===`read-only`||s?.effect===`session-setting`)&&(0,U.jsx)(lu,{size:`small`,color:s.modelCallObserved?`warning`:`success`,variant:`outlined`,label:s.modelCallObserved?Q(i,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),D&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:Q(i,`Fast: ${D.mode} · provider: ${D.provider??`unknown`} · ${D.reasonCode}`,`Fast: ${D.mode} · provider: ${D.provider??`unknown`} · ${D.reasonCode}`)}),l&&(0,U.jsx)(X,{color:`error`,variant:`body2`,sx:{mt:1},children:l}),s?.outputs.map((e,t)=>(0,U.jsx)(J,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1.5,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,U.jsx)(mT,{open:p!==null,title:p?.title??``,description:p?.description??``,cancelLabel:Q(i,`Hủy`,`Cancel`),confirmLabel:Q(i,`Xác nhận và chạy`,`Confirm and run`),onCancel:()=>m(null),onConfirm:()=>{let e=p;m(null),e&&O(e.action,e.argument,!0)}})]})}var Lk=Y((0,U.jsx)(`path`,{d:`M17 11h3c1.11 0 2-.9 2-2V5c0-1.11-.9-2-2-2h-3c-1.11 0-2 .9-2 2v1H9.01V5c0-1.11-.9-2-2-2H4c-1.1 0-2 .9-2 2v4c0 1.11.9 2 2 2h3c1.11 0 2-.9 2-2V8h2v7.01c0 1.65 1.34 2.99 2.99 2.99H15v1c0 1.11.9 2 2 2h3c1.11 0 2-.9 2-2v-4c0-1.11-.9-2-2-2h-3c-1.11 0-2 .9-2 2v1h-1.01c-.54 0-.99-.45-.99-.99V8h2v1c0 1.1.9 2 2 2`}),`AccountTreeRounded`),Rk=Y((0,U.jsx)(`path`,{d:`M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8`}),`InfoOutlined`),zk=Y((0,U.jsx)(`path`,{d:`M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-1 2H5v-2h2zm0-3H5V8h2zm8 7H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m1-4h-2v-2h2zm0-3h-2V8h2zm3 3h-2v-2h2zm0-3h-2V8h2z`}),`KeyboardRounded`),Bk=Y([(0,U.jsx)(`path`,{d:`M13 8.57c-.79 0-1.43.64-1.43 1.43s.64 1.43 1.43 1.43 1.43-.64 1.43-1.43-.64-1.43-1.43-1.43`},`0`),(0,U.jsx)(`path`,{d:`M13.21 3c-3.84-.11-7 2.87-7.19 6.64L4.1 12.2c-.25.33-.01.8.4.8H6v3c0 1.1.9 2 2 2h1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-3.68c2.44-1.16 4.1-3.68 4-6.58-.14-3.62-3.18-6.63-6.79-6.74M16 10c0 .13-.01.26-.02.39l.83.66c.08.06.1.16.05.25l-.8 1.39c-.05.09-.16.12-.24.09l-.99-.4c-.21.16-.43.29-.67.39L14 13.83c-.01.1-.1.17-.2.17h-1.6c-.1 0-.18-.07-.2-.17l-.15-1.06c-.25-.1-.47-.23-.68-.39l-.99.4c-.09.03-.2 0-.25-.09l-.8-1.39c-.05-.08-.03-.19.05-.25l.84-.66c-.01-.13-.02-.26-.02-.39s.02-.27.04-.39l-.85-.66c-.08-.06-.1-.16-.05-.26l.8-1.38c.05-.09.15-.12.24-.09l1 .4c.2-.15.43-.29.67-.39L12 6.17c.02-.1.1-.17.2-.17h1.6c.1 0 .18.07.2.17l.15 1.06c.24.1.46.23.67.39l1-.4c.09-.03.2 0 .24.09l.8 1.38c.05.09.03.2-.05.26l-.85.66c.03.12.04.25.04.39`},`1`)],`PsychologyRounded`),Vk=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).replace(/đ/g,`d`).replace(/Đ/g,`D`).toLowerCase();function Hk(e,t){let n=Vk(t).split(/\s+/).filter(Boolean),r=Vk(e).split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.every(e=>r.some(t=>t.startsWith(e)))}function Uk(e,t,n=40){return t.trim()?e.filter(e=>Hk(`${e.label} ${e.keywords??``} ${e.group}`,t)).slice(0,n):e.slice(0,n)}function Wk(e){let t=(0,v.useRef)(e);t.current=e,(0,v.useEffect)(()=>{let e=e=>{e.isComposing||!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||(e.key.toLowerCase()===`k`?(e.preventDefault(),t.current.palette()):e.key===`,`&&(e.preventDefault(),t.current.settings()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function Gk({open:e,onClose:t,commands:n,locale:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(0),c=(0,v.useMemo)(()=>Uk(n,i),[n,i]),l=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(a(``),s(0))},[e]),(0,v.useEffect)(()=>{s(0)},[i]),(0,v.useEffect)(()=>{l.current?.querySelector(`[data-index="${o}"]`)?.scrollIntoView({block:`nearest`})},[o]);let u=e=>{e&&(t(),setTimeout(()=>e.run(),0))},d=e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),s(e=>Math.min(e+1,c.length-1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),u(c[o])))},f=``;return(0,U.jsxs)(zC,{open:e,onClose:t,fullWidth:!0,maxWidth:`sm`,slotProps:{paper:{"aria-label":Q(r,`Bảng lệnh`,`Command palette`),sx:{alignSelf:`flex-start`,mt:{xs:2,sm:`12vh`},borderRadius:2.5,overflow:`hidden`}}},children:[(0,U.jsxs)(J,{sx:{display:`flex`,alignItems:`center`,gap:1,px:2,py:1.25,borderBottom:1,borderColor:`divider`},children:[(0,U.jsx)(dx,{fontSize:`small`,color:`action`}),(0,U.jsx)(nc,{autoFocus:!0,fullWidth:!0,value:i,onChange:e=>a(e.target.value),onKeyDown:d,placeholder:Q(r,`Gõ lệnh hoặc tên cuộc trò chuyện…`,`Type a command or a conversation name…`),inputProps:{role:`combobox`,"aria-expanded":!0,"aria-controls":`piagent-palette-list`,"aria-activedescendant":c[o]?`palette-${c[o].id}`:void 0,"aria-label":Q(r,`Tìm lệnh`,`Search commands`)}})]}),(0,U.jsxs)(rf,{component:`div`,id:`piagent-palette-list`,role:`listbox`,"aria-label":Q(r,`Lệnh`,`Commands`),ref:l,dense:!0,sx:{maxHeight:`min(60vh, 460px)`,overflowY:`auto`,py:.5},children:[c.map((e,t)=>{let n=e.group===f?null:e.group;return f=e.group,(0,U.jsxs)(v.Fragment,{children:[n&&(0,U.jsx)(AT,{component:`div`,"aria-hidden":!0,disableSticky:!0,sx:{lineHeight:`28px`,fontSize:11,fontWeight:800,letterSpacing:`.04em`,textTransform:`uppercase`},children:n}),(0,U.jsxs)(cf,{id:`palette-${e.id}`,role:`option`,"aria-selected":t===o,"data-index":t,selected:t===o,onMouseMove:()=>s(t),onClick:()=>u(e),sx:{mx:.5,borderRadius:1.5,gap:2},children:[(0,U.jsx)(X,{sx:{flex:1,minWidth:0,fontSize:14},noWrap:!0,children:e.label}),e.hint&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:e.hint})]})]},e.id)}),!c.length&&(0,U.jsx)(X,{sx:{px:2.5,py:3},color:`text.secondary`,children:Q(r,`Không có lệnh nào khớp.`,`No matching command.`)})]})]})}var Kk={"branch-switch-blocked-running":[`Có cuộc trò chuyện đang chạy trong folder này. Chờ chạy xong hoặc Dừng rồi chuyển nhánh.`,`A conversation is running in this folder. Wait for it to finish, or stop it, then switch.`],"branch-switch-local-changes":[`Git không chuyển được: thay đổi chưa commit sẽ bị ghi đè. Commit hoặc stash trước.`,`Git refused: uncommitted changes would be overwritten. Commit or stash them first.`],"branch-switch-unfinished-merge":[`Repo đang dở merge hoặc rebase. Xử lý xong rồi chuyển nhánh.`,`The repository is in the middle of a merge or rebase. Finish it first.`],"branch-exists":[`Đã có nhánh tên này.`,`A branch with this name already exists.`],"branch-name-invalid":[`Tên nhánh không hợp lệ với Git.`,`Git does not accept this branch name.`],"branch-not-found":[`Không còn nhánh này.`,`This branch no longer exists.`],"not-a-git-repository":[`Folder này không phải repo Git.`,`This folder is not a Git repository.`],"branch-switch-timeout":[`Git chạy quá lâu nên đã dừng.`,`Git took too long and was stopped.`]};function qk({projectRef:e,projectLabel:t,branch:n,locale:r,onSwitched:i,maxWidth:a=220}){let[o,s]=(0,v.useState)(null),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(``),[m,h]=(0,v.useState)(null),[g,_]=(0,v.useState)(null),y=(0,v.useRef)(null),b=(0,v.useRef)(null),[x,S]=(0,v.useState)(null);(0,v.useEffect)(()=>{S(null)},[n?.name,n?.detached,e]);let C=x??n,w=!!o,T=()=>{y.current?.abort();let t=new AbortController;y.current=t,d(!1),V_(e,t.signal).then(e=>{t.signal.aborted||l(e)},()=>{t.signal.aborted||d(!0)})};(0,v.useEffect)(()=>(w&&T(),()=>y.current?.abort()),[w,e]);let E=()=>{m||(y.current?.abort(),s(null),p(``),_(null),l(null),d(!1))},D=async t=>{h(t.branch),_(null);try{let n=await H_(e,t);n.head&&S(n.head),i?.(),s(null),p(``),l(null)}catch(e){_(e instanceof B_?{code:e.code,detail:e.detail}:{code:`branch-switch-failed`,detail:null}),T()}finally{h(null)}},O=c?.repository?c:null;(0,v.useEffect)(()=>{w&&O&&requestAnimationFrame(()=>b.current?.focus())},[w,O]);let k=f.trim(),A=(0,v.useMemo)(()=>(O?.branches??[]).filter(e=>!k||e.name.toLowerCase().includes(k.toLowerCase())),[O,k]),j=A.filter(e=>!e.remote),M=A.filter(e=>e.remote),N=(O?.branches??[]).some(e=>e.name===k),P=(c?.running??0)>0,F=e=>(0,U.jsxs)(cf,{dense:!0,disabled:!e.current&&(P||!!m),selected:e.current,"aria-current":e.current||void 0,onClick:()=>e.current?E():void D({branch:e.name,remote:e.remote}),sx:{borderRadius:1,py:.4},children:[(0,U.jsx)(pf,{sx:{minWidth:26},children:m===e.name?(0,U.jsx)(xu,{size:14}):e.current?(0,U.jsx)(zD,{sx:{fontSize:16}}):e.remote?(0,U.jsx)(Sw,{sx:{fontSize:15,color:`text.disabled`}}):null}),(0,U.jsx)(Cf,{primary:e.name,secondary:[e.remote,e.committedAt?qO(e.committedAt,r):null].filter(Boolean).join(` · `)||void 0,slotProps:{primary:{noWrap:!0,sx:{fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:12.5}},secondary:{noWrap:!0,sx:{fontSize:11}}}})]},`${e.remote??``}/${e.name}`);return C?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(Ah,{describeChild:!0,title:`${GO(C,r)} · ${Q(r,`bấm để đổi nhánh`,`click to switch`)}`,children:(0,U.jsx)(tu,{onClick:e=>{e.stopPropagation(),s(e.currentTarget)},"aria-haspopup":`dialog`,"aria-expanded":w,"aria-label":C.detached?Q(r,`Đổi nhánh Git của ${t} (detached HEAD tại ${C.name})`,`Switch ${t}'s Git branch (detached HEAD at ${C.name})`):Q(r,`Đổi nhánh Git của ${t} (đang ở ${C.name})`,`Switch ${t}'s Git branch (on ${C.name})`),sx:{minWidth:0,maxWidth:a,borderRadius:.75,px:.4,mx:-.4,font:`inherit`,color:`inherit`,justifyContent:`flex-start`,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`}},children:(0,U.jsx)(KO,{branch:C,locale:r,maxWidth:`100%`,tooltip:!1})})}),(0,U.jsxs)(vb,{open:w,anchorEl:o,onClose:E,anchorOrigin:{vertical:`bottom`,horizontal:`left`},slotProps:{paper:{role:`dialog`,"aria-label":Q(r,`Nhánh Git`,`Git branches`),sx:{width:`min(360px, calc(100vw - 32px))`,maxHeight:`min(520px, 70vh)`,display:`flex`,flexDirection:`column`,p:1.25,gap:1}}},children:[(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`subtitle2`,sx:{fontWeight:650},children:Q(r,`Nhánh Git`,`Git branches`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,children:t})]}),P&&(0,U.jsx)(pC,{severity:`warning`,sx:{py:0,fontSize:12.5},children:Q(r,`${c.running} cuộc trò chuyện đang chạy trong folder này. Chờ chạy xong hoặc Dừng rồi mới chuyển nhánh.`,`${c.running} conversation(s) running in this folder. Wait for them to finish, or stop them, before switching.`)}),O&&O.changedFiles>0&&!P&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(r,`${O.changedFiles} file đang sửa dở sẽ đi theo sang nhánh mới; Git từ chối nếu chúng bị ghi đè.`,`${O.changedFiles} changed file(s) come along to the new branch; Git refuses if they would be overwritten.`)}),g&&(0,U.jsxs)(pC,{severity:`error`,sx:{py:0,fontSize:12.5},children:[Q(r,...Kk[g.code]??[`Không chuyển được nhánh.`,`The branch could not be switched.`]),g.detail&&(0,U.jsx)(J,{component:`pre`,sx:{m:0,mt:.5,whiteSpace:`pre-wrap`,font:`11px ui-monospace, monospace`,opacity:.85},children:g.detail})]}),(0,U.jsx)(ux,{inputRef:b,size:`small`,value:f,onChange:e=>p(e.target.value),disabled:!O||!!m,placeholder:Q(r,`Tìm hoặc đặt tên nhánh mới`,`Find a branch or name a new one`),slotProps:{htmlInput:{maxLength:200,"aria-label":Q(r,`Tìm nhánh`,`Find a branch`)}},onKeyDown:e=>{if(e.key===`Enter`&&k&&!P&&!m){let e=O?.branches.find(e=>e.name===k);D(e?{branch:e.name,remote:e.remote}:{branch:k,create:!0})}}}),(0,U.jsxs)(J,{sx:{overflowY:`auto`,minHeight:0,mx:-.5},children:[!c&&!u&&(0,U.jsx)(J,{sx:{display:`flex`,justifyContent:`center`,py:2},children:(0,U.jsx)(xu,{size:18})}),u&&(0,U.jsx)(pC,{severity:`error`,sx:{py:0,fontSize:12.5},children:Q(r,`Không đọc được danh sách nhánh.`,`The branches could not be read.`)}),c&&!c.repository&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:Q(r,...Kk[`not-a-git-repository`])}),O&&(0,U.jsxs)(rf,{dense:!0,disablePadding:!0,children:[k&&!N&&(0,U.jsxs)(cf,{dense:!0,disabled:P||!!m,onClick:()=>void D({branch:k,create:!0}),sx:{borderRadius:1},children:[(0,U.jsx)(pf,{sx:{minWidth:26},children:m===k?(0,U.jsx)(xu,{size:14}):(0,U.jsx)(qS,{sx:{fontSize:16}})}),(0,U.jsx)(Cf,{primary:Q(r,`Tạo nhánh mới “${k}”`,`Create branch “${k}”`),secondary:Q(r,`từ ${O.head?.name??`HEAD`}`,`from ${O.head?.name??`HEAD`}`),slotProps:{primary:{noWrap:!0,sx:{fontSize:12.5}},secondary:{sx:{fontSize:11}}}})]}),j.map(F),M.length>0&&(0,U.jsx)(AT,{disableSticky:!0,sx:{lineHeight:`26px`,fontSize:11,bgcolor:`transparent`},children:Q(r,`Trên remote`,`On a remote`)}),M.map(F),A.length===0&&!k&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:Q(r,`Chưa có nhánh nào.`,`No branches yet.`)}),O.truncated&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{px:1},children:Q(r,`Chỉ hiện 200 nhánh có commit mới nhất.`,`Showing the 200 most recently committed branches.`)})]})]})]})]}):null}var Jk=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,Yk={height:28,px:1,gap:.75,fontSize:12,color:`text.secondary`,alignItems:`center`},Xk={...Yk,borderRadius:0,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`,outlineOffset:-2}};function Zk({locale:e,connection:t,running:n,session:r,onBranchSwitched:i,onUpdates:a,onPalette:o}){let{status:s,supported:c}=ME(),l=JE(e=>e.breakpoints.up(`md`)),u=kE(s),d=!!(s?.updateAvailable&&s.installable),f=s?.piagent.installed?`Piagent ${s.piagent.installed}${s.pi.installed?` · Pi ${s.pi.installed}`:``}`:`Piagent`;return l?(0,U.jsxs)(J,{component:`footer`,"aria-label":Q(e,`Thanh trạng thái`,`Status bar`),sx:{position:`fixed`,left:0,right:0,bottom:0,height:28,display:`flex`,alignItems:`stretch`,borderTop:1,borderColor:`divider`,bgcolor:`background.paper`,zIndex:e=>e.zIndex.drawer+1,whiteSpace:`nowrap`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:Yk,children:[(0,U.jsx)(J,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:t===`connected`?`success.main`:`warning.main`}}),(0,U.jsx)(`span`,{children:t===`connected`?`Gateway live`:t}),(0,U.jsx)(J,{component:`span`,sx:{color:`text.disabled`},children:`local`})]}),r?.gitBranch&&(0,U.jsx)(Z,{direction:`row`,sx:{...Yk,minWidth:0},children:(0,U.jsx)(qk,{projectRef:r.projectRef,projectLabel:r.projectLabel,branch:r.gitBranch,locale:e,maxWidth:320,onSwitched:i})}),n>0&&(0,U.jsxs)(Z,{direction:`row`,sx:Yk,children:[(0,U.jsx)(xu,{size:10,thickness:6}),(0,U.jsx)(`span`,{children:Q(e,`${n} đang chạy`,`${n} running`)})]}),(0,U.jsx)(J,{sx:{flex:1}}),c&&(0,U.jsx)(Ah,{describeChild:!0,title:d?Q(e,`Mở Cập nhật trong Cài đặt`,`Open Updates in Settings`):Q(e,`Phiên bản và cập nhật`,`Version and updates`),children:(0,U.jsx)(tu,{onClick:a,sx:{...Xk,...d&&{color:`primary.contrastText`,bgcolor:`primary.main`,fontWeight:700,"&:hover":{bgcolor:`primary.dark`,color:`primary.contrastText`}}},children:u?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xu,{size:11,thickness:6,color:`inherit`}),Q(e,`Đang cập nhật lên ${s?.job?.to}…`,`Updating to ${s?.job?.to}…`)]}):d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(lE,{sx:{fontSize:15}}),Q(e,`Cập nhật Piagent ${s?.piagent.latest}`,`Update Piagent ${s?.piagent.latest}`)]}):(0,U.jsx)(`span`,{children:f})})}),(0,U.jsxs)(tu,{onClick:o,"aria-label":Q(e,`Mở bảng lệnh`,`Open command palette`),sx:Xk,children:[(0,U.jsxs)(J,{component:`kbd`,sx:{font:`inherit`,fontSize:11,px:.6,border:1,borderColor:`divider`,borderRadius:.75},children:[Jk(),` K`]}),(0,U.jsx)(`span`,{children:Q(e,`Lệnh`,`Commands`)})]})]}):null}function Qk(e){let t=Q(e,`Chung`,`General`),n=`Agent`,r=Q(e,`Công cụ`,`Tools`),i=Q(e,`Thông tin`,`Information`);return[{id:`general`,group:t,label:Q(e,`Giao diện`,`Appearance`),icon:(0,U.jsx)(ET,{}),keywords:`ngôn ngữ language chủ đề theme sáng tối light dark tiếng việt english`},{id:`updates`,group:t,label:Q(e,`Cập nhật`,`Updates`),icon:(0,U.jsx)(lE,{}),keywords:`update phiên bản version pi piagent npm nâng cấp upgrade`},{id:`shortcuts`,group:t,label:Q(e,`Phím tắt`,`Shortcuts`),icon:(0,U.jsx)(zk,{}),keywords:`keyboard bàn phím shortcut lệnh command palette enter`},{id:`models`,group:n,label:Q(e,`Nhà cung cấp & model`,`Providers & models`),icon:(0,U.jsx)(Bk,{}),keywords:`model provider thinking đăng nhập login oauth tài khoản account công ty company`},{id:`controls`,group:n,label:Q(e,`Điều khiển project`,`Project controls`),icon:(0,U.jsx)(Lk,{}),keywords:`project runtime khởi động lại restart session`},{id:`permissions`,group:n,label:Q(e,`Quyền truy cập`,`Access`),icon:(0,U.jsx)(TT,{}),keywords:`permission quyền sandbox đọc ghi read write network mạng`},{id:`connections`,group:r,label:Q(e,`MCP & kết nối`,`MCP & connections`),icon:(0,U.jsx)(iw,{}),keywords:`mcp server tool công cụ oauth kết nối connection`},{id:`usage`,group:i,label:Q(e,`Sử dụng & context`,`Usage & context`),icon:(0,U.jsx)(jk,{}),keywords:`token usage context ngữ cảnh input output`},{id:`about`,group:i,label:`Piagent`,icon:(0,U.jsx)(Rk,{}),keywords:`gateway protocol runtime giới thiệu about`}]}function $k(e,t){return t.trim()?e.filter(e=>Hk(`${e.label} ${e.group} ${e.keywords}`,t)):e}function eA({section:e,onSection:t,onBack:n}){let{locale:r}=Gv(),{status:i}=ME(),[a,o]=(0,v.useState)(``),s=(0,v.useMemo)(()=>$k(Qk(r),a),[r,a]),c=!!(i?.updateAvailable&&i.installable),l=``;return(0,U.jsxs)(J,{component:`nav`,"aria-label":Q(r,`Mục cài đặt`,`Settings sections`),sx:{borderRight:{sm:1},borderBottom:{xs:1,sm:0},borderColor:`divider`,bgcolor:`background.paper`,p:1.25,minHeight:0,overflow:`auto`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{minHeight:48,alignItems:`center`,justifyContent:`space-between`,px:1},children:[(0,U.jsx)(X,{id:`piagent-settings-title`,sx:{fontWeight:700},children:Q(r,`Cài đặt`,`Settings`)}),(0,U.jsx)(Qd,{"aria-label":Q(r,`Đóng cài đặt`,`Close settings`),onClick:n,children:(0,U.jsx)(qE,{})})]}),(0,U.jsxs)(Pc,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:.75,px:1,mx:.5,mb:1,borderRadius:1.5},children:[(0,U.jsx)(dx,{fontSize:`small`,color:`action`}),(0,U.jsx)(nc,{value:a,onChange:e=>o(e.target.value),placeholder:Q(r,`Tìm cài đặt`,`Search settings`),inputProps:{"aria-label":Q(r,`Tìm cài đặt`,`Search settings`)},onKeyDown:e=>{e.key===`Enter`&&s[0]&&(e.preventDefault(),t(s[0].id))},sx:{flex:1,fontSize:13,py:.5}})]}),(0,U.jsxs)(rf,{component:`div`,disablePadding:!0,sx:{display:{xs:`flex`,sm:`block`},minWidth:{xs:`max-content`,sm:0},overflowX:`auto`,flex:1},children:[s.map(n=>{let i=n.group===l?null:n.group;return l=n.group,(0,U.jsxs)(J,{sx:{display:{xs:`contents`,sm:`block`}},children:[i&&(0,U.jsx)(AT,{component:`div`,disableSticky:!0,sx:{display:{xs:`none`,sm:`block`},bgcolor:`transparent`,lineHeight:`30px`,fontSize:11,fontWeight:800,letterSpacing:`.04em`,textTransform:`uppercase`,mt:.5},children:i}),(0,U.jsxs)(cf,{selected:e===n.id,onClick:()=>t(n.id),children:[(0,U.jsx)(pf,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:n.icon}),(0,U.jsx)(Cf,{primary:n.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:e===n.id?800:650}}}}),n.id===`updates`&&c&&(0,U.jsx)(J,{"aria-label":Q(r,`Có bản cập nhật`,`Update available`),role:`img`,sx:{width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`,flexShrink:0}})]})]},n.id)}),!s.length&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,py:2},children:Q(r,`Không có mục nào khớp.`,`No matching setting.`)})]}),i?.piagent.installed&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{display:{xs:`none`,sm:`block`},px:1.5,pt:1},children:`Piagent ${i.piagent.installed}${i.pi.installed?` · Pi ${i.pi.installed}`:``}`})]})}function tA(){let{locale:e}=Gv(),t=Jk(),n=[[`${t} K`,Q(e,`Mở bảng lệnh: mọi thao tác và cuộc trò chuyện theo tên`,`Open the command palette: every action and conversation by name`)],[`${t} ,`,Q(e,`Mở Cài đặt`,`Open Settings`)],[`Enter`,Q(e,`Gửi tin nhắn`,`Send the message`)],[`Shift Enter`,Q(e,`Xuống dòng trong tin nhắn`,`New line in the message`)],[`1 – 5`,Q(e,`Chọn đáp án khi main agent hỏi; Enter để gửi câu trả lời`,`Pick an answer when the main agent asks; Enter sends it`)],[`Esc`,Q(e,`Đóng hộp thoại hoặc bảng lệnh`,`Close a dialog or the palette`)]];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:3},children:Q(e,`Phím tắt`,`Shortcuts`)}),(0,U.jsx)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:n.map(([e,t],n)=>(0,U.jsxs)(Z,{direction:`row`,sx:{px:2.25,py:1.5,gap:2,alignItems:`center`,justifyContent:`space-between`,borderTop:+!!n,borderColor:`divider`},children:[(0,U.jsx)(X,{children:t}),(0,U.jsx)(J,{component:`kbd`,sx:{px:.9,py:.2,border:1,borderColor:`divider`,borderRadius:1,fontSize:12,fontFamily:`inherit`,whiteSpace:`nowrap`,bgcolor:`action.hover`},children:e})]},e))})]})}function nA(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function rA({children:e}){return(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function iA({icon:e,title:t,detail:n,action:r}){return(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,U.jsxs)(Z,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{sx:{fontWeight:760},children:t}),n&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function aA(){let{locale:e,colorMode:t,setLocale:n,setColorMode:r}=Gv();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rA,{children:Q(e,`Giao diện`,`Appearance`)}),(0,U.jsxs)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:[(0,U.jsx)(iA,{icon:(0,U.jsx)(HD,{color:`primary`}),title:Q(e,`Ngôn ngữ`,`Language`),detail:Q(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,U.jsxs)(op,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&n(t),children:[(0,U.jsx)(ep,{value:`vi`,children:`VI`}),(0,U.jsx)(ep,{value:`en`,children:`EN`})]})}),(0,U.jsx)(Du,{}),(0,U.jsx)(iA,{icon:t===`dark`?(0,U.jsx)(Bh,{color:`primary`}):(0,U.jsx)(zh,{color:`primary`}),title:Q(e,`Chủ đề`,`Theme`),detail:Q(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,U.jsxs)(op,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&r(t),children:[(0,U.jsx)(ep,{value:`light`,children:Q(e,`Sáng`,`Light`)}),(0,U.jsx)(ep,{value:`dark`,children:Q(e,`Tối`,`Dark`)})]})})]})]})}function oA({options:e,snapshot:t,activeModel:n,observedProvider:r}){let{locale:i}=Gv(),a=e?.webSearch,o=t?.capabilities.capabilities.attachments,s=o?.status===`available`?o.kinds.some(e=>e===`image`):null,c=t?.session.model.state===`known`?t.session.model.value:null,l=c?c.inputCapabilities.some(e=>e===`image`):null,u=n?.imageInput??l??s,d=(n?.provider??r??null)===`openai-codex`,f=[{key:`search`,icon:(0,U.jsx)(GD,{color:`primary`}),title:a?.route===`codex-first`?`Codex Web Search`:Q(i,`Tìm kiếm web`,`Web search`),detail:a?.route===`codex-first`?Q(i,`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.`):a?.state===`configured`?Q(i,`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.`):Q(i,`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:a?.route===`codex-first`?Q(i,`Ưu tiên Codex`,`Codex first`):a?.state===`configured`?Q(i,`Đã cấu hình`,`Configured`):Q(i,`Chưa có`,`Unavailable`),ready:a?.state===`configured`},{key:`vision`,icon:(0,U.jsx)(Ek,{color:`primary`}),title:d?`Codex Vision`:Q(i,`Vision của model`,`Model vision`),detail:u===!0?Q(i,`Ả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.`):u===!1?Q(i,`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.`):Q(i,`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:u===!0?Q(i,`Đang dùng`,`Active`):u===!1?Q(i,`Không hỗ trợ`,`Unsupported`):Q(i,`Chưa rõ`,`Unknown`),ready:u===!0}];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{variant:`h2`,sx:{mt:3,mb:.5},children:Q(i,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:Q(i,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:f.map(e=>(0,U.jsx)(Pc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,U.jsx)(J,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:2,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:800},children:e.title}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,U.jsx)(lu,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function sA({options:e,auth:t,refreshAuth:n,session:r,snapshot:i,onSetModel:a,onSetThinking:o}){let{locale:s}=Gv(),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=i?.session.model.state===`known`?i.session.model.value:null,p=(0,v.useMemo)(()=>{let t=new Map;for(let n of e?.models??[])t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t.entries()]},[e]),m=f?.modelRef??``,h=e?.models.find(e=>e.modelRef===m),g=h?m:``,_=f?.displayName??r?.modelLabel??`—`,y=r?.managedThinkingLevels??h?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],b=async e=>{if(e){l(!0),d(null);try{await e()}catch{d(Q(s,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{l(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rA,{children:Q(s,`Nhà cung cấp & model`,`Providers & models`)}),r&&(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:2.25,borderRadius:2.5,mb:2},children:[(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,U.jsx)(jw,{name:f?.provider??r.modelLabel??`model`,size:38}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:700},children:Q(s,`Model của session hiện tại`,`Current session model`)}),(0,U.jsxs)(X,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[_,` · `,Fv(r.thinkingLevel,s)]})]}),(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:Q(s,`Đang dùng`,`In use`)})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,U.jsxs)(J,{sx:{flex:1},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,U.jsx)(ax,{fullWidth:!0,size:`small`,value:g,displayEmpty:!0,renderValue:t=>t?e?.models.find(e=>e.modelRef===t)?.displayName??_:_,disabled:c||!a||r.liveState===`running`,onChange:e=>void b(()=>a?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,U.jsx)(bw,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,U.jsxs)(J,{sx:{width:{md:220}},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,U.jsx)(ax,{fullWidth:!0,size:`small`,value:r.thinkingLevel===`unknown`?`off`:r.thinkingLevel,disabled:c||!o||r.liveState===`running`,onChange:e=>void b(()=>o?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:y.map(e=>(0,U.jsx)(bw,{value:e,children:Fv(e,s)},e))})]})]}),u&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:u})]}),(0,U.jsx)(oA,{options:e,snapshot:i,activeModel:h,observedProvider:f?.provider}),(0,U.jsx)(X,{variant:`h2`,sx:{mt:3,mb:.5},children:Q(s,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:Q(s,`Kết nối tài khoản để mở khóa model tương ứng.`,`Connect an account to make its models available.`)}),(0,U.jsx)(Ok,{catalog:t,refresh:n}),(0,U.jsx)(X,{variant:`h2`,sx:{mt:3,mb:.5},children:Q(s,`Danh mục model`,`Model catalog`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:Q(s,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:p.map(([e,t])=>(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:1.5,borderRadius:2},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,U.jsx)(jw,{name:e,size:32}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{noWrap:!0,sx:{fontWeight:700,textTransform:`capitalize`},children:e}),(0,U.jsxs)(X,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,U.jsx)(lu,{size:`small`,color:`success`,variant:`outlined`,label:Q(s,`Sẵn sàng`,`Ready`)})]}),(0,U.jsxs)(J,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&p.length===0&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(s,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function cA({value:e,loading:t,sessionRef:n,onChanged:r}){let{locale:i}=Gv();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rA,{children:Q(i,`MCP & kết nối`,`MCP & connections`)}),t?(0,U.jsx)(xu,{size:22}):(0,U.jsxs)(Z,{spacing:1,children:[(e?.connections??[]).map(e=>(0,U.jsx)(Pc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,U.jsx)(jw,{name:e.name,size:38}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{noWrap:!0,sx:{fontWeight:800},children:e.name}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:oT(e,i)})]}),n?(0,U.jsx)(cT,{sessionRef:n,connection:e,onChanged:r}):(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:Q(i,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(i,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function lA({snapshot:e,session:t,onSetPermission:n}){let{locale:r}=Gv(),i=e?.session.permissionProfile,[a,o]=(0,v.useState)(i?.state===`known`?i.value??null:null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null);(0,v.useEffect)(()=>{o(null)},[t?.sessionRef]),(0,v.useEffect)(()=>{i?.state===`known`&&o(i.value??null)},[i?.state,i?.value]);let p=async e=>{if(n){c(!0),u(null);try{await n(e),o(e)}catch{u(Q(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{c(!1)}}},m=e=>{if(e===`trusted-full-access`){f(e);return}p(e)},h=[{mode:`read-only`,detail:Q(r,`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:Q(r,`Đọ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:Q(r,`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.`)}];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rA,{children:Q(r,`Quyền truy cập`,`Access`)}),(0,U.jsx)(X,{variant:`h2`,sx:{mb:.5},children:Q(r,`Hồ sơ quyền`,`Permission profile`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:Q(r,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,U.jsx)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:h.map((e,i)=>(0,U.jsxs)(J,{children:[(0,U.jsx)(iA,{icon:(0,U.jsx)(TT,{color:e.mode===`trusted-full-access`?`warning`:`primary`}),title:Fv(e.mode,r),detail:e.detail,action:(0,U.jsx)($,{size:`small`,variant:a===e.mode?`contained`:`outlined`,color:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":a===e.mode,disabled:s||!t||!n||t.liveState===`running`,onClick:()=>m(e.mode),children:Fv(e.mode,r)})}),i<h.length-1&&(0,U.jsx)(Du,{})]},e.mode))}),l&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:l}),(0,U.jsx)(mT,{open:d!==null,title:Q(r,`Bật toàn quyền?`,`Enable full access?`),description:Q(r,`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:Q(r,`Hủy`,`Cancel`),confirmLabel:Q(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>f(null),onConfirm:()=>{f(null),p(`trusted-full-access`)}})]})}function uA({session:e,snapshot:t}){let{locale:n}=Gv(),r=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),i=[[Q(n,`Context`,`Context`),r?.percent==null?`—`:`${Math.round(r.percent)}%`],[`Tokens`,`${nA(r?.tokens,n)} / ${nA(r?.contextWindow,n)}`],[Q(n,`Input`,`Input`),nA(t?.usage.sessionTotal.input,n)],[Q(n,`Output`,`Output`),nA(t?.usage.sessionTotal.output,n)],[Q(n,`Continuation`,`Continuation`),nA(t?.continuation.remaining,n)],[`Verifier`,t?.verification.state??`—`]];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rA,{children:Q(n,`Usage & context`,`Usage & context`)}),(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,sm:`repeat(2,minmax(0,1fr))`,lg:`repeat(3,minmax(0,1fr))`},gap:1},children:i.map(([e,t])=>(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:e}),(0,U.jsx)(X,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:800},children:t})]},e))})]})}function dA({capabilities:e,connection:t}){let{locale:n}=Gv(),r=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[Q(n,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(rA,{children:`Piagent`}),(0,U.jsx)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:r.map(([e,t],n)=>(0,U.jsxs)(J,{children:[(0,U.jsxs)(Z,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,U.jsx)(X,{color:`text.secondary`,children:e}),(0,U.jsx)(X,{sx:{fontWeight:760},children:String(t)})]}),n<r.length-1&&(0,U.jsx)(Du,{})]},String(e)))})]})}function fA({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}=Gv(),[f,p]=(0,v.useState)(),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(),[y,b]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=new AbortController;return Ng(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]),(0,v.useEffect)(()=>{let e=new AbortController;return Pg(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,v.useEffect)(()=>{if(!r){_(void 0);return}let e=new AbortController;return b(!0),_(void 0),t_(r.sessionRef,e.signal).then(_).catch(()=>void 0).finally(()=>{e.signal.aborted||b(!1)}),()=>e.abort()},[r?.sessionRef]),(0,U.jsxs)(J,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`236px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,U.jsx)(eA,{section:e,onSection:t,onBack:n}),(0,U.jsxs)(J,{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,U.jsx)(aA,{}),e===`updates`&&(0,U.jsx)(zE,{}),e===`shortcuts`&&(0,U.jsx)(tA,{}),e===`models`&&(0,U.jsx)(sA,{options:f,auth:m,refreshAuth:async()=>{let[e,t]=await Promise.all([Pg(),Ng()]);h(e),p(t)},session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,U.jsx)(cA,{value:g,loading:y,sessionRef:r?.sessionRef,onChanged:async e=>{if(e){_(e);return}r&&_(await t_(r.sessionRef).catch(()=>g))}}),e===`controls`&&(0,U.jsx)(Ik,{session:r,options:f,connections:g,onCompleted:u}),e===`permissions`&&(0,U.jsx)(lA,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,U.jsx)(uA,{session:r,snapshot:i}),e===`about`&&(0,U.jsx)(dA,{capabilities:a,connection:o})]})]})}function pA(e){let{locale:t,actions:n}=e,r=Q(t,`Lệnh`,`Commands`),i=Jk(),a=[];e.canCreate&&a.push({id:`new-chat`,group:r,label:Q(t,`Cuộc trò chuyện mới`,`New chat`),keywords:`new create tạo`,run:n.newChat}),e.update.available&&e.update.latest&&a.push({id:`update-now`,group:r,label:Q(t,`Cập nhật Piagent ${e.update.latest}`,`Update Piagent ${e.update.latest}`),keywords:`update upgrade nâng cấp phiên bản version`,run:()=>n.settings(`updates`)}),a.push({id:`check-updates`,group:r,label:Q(t,`Kiểm tra cập nhật`,`Check for updates`),keywords:`update version phiên bản pi piagent`,run:n.checkUpdates}),e.hasSelection&&a.push({id:`toggle-panel`,group:r,label:Q(t,`Bật/tắt khung Workspace`,`Toggle the Workspace panel`),keywords:`panel sidebar changes plan context`,run:n.togglePanel},{id:`open-changes`,group:r,label:Q(t,`Mở Source Changes`,`Open Source Changes`),keywords:`diff review thay đổi git`,run:n.openChanges}),a.push({id:`theme`,group:r,label:e.colorMode===`dark`?Q(t,`Chuyển sang chủ đề sáng`,`Switch to the light theme`):Q(t,`Chuyển sang chủ đề tối`,`Switch to the dark theme`),keywords:`theme chủ đề dark light sáng tối`,run:()=>n.setColorMode(e.colorMode===`dark`?`light`:`dark`)},{id:`language`,group:r,label:t===`vi`?`Switch the interface to English`:`Chuyển giao diện sang tiếng Việt`,keywords:`language ngôn ngữ english tiếng việt`,run:()=>n.setLocale(t===`vi`?`en`:`vi`)},{id:`refresh`,group:r,label:Q(t,`Làm mới`,`Refresh`),keywords:`reload tải lại`,run:n.refresh});let o=Q(t,`Cài đặt`,`Settings`);for(let e of Qk(t))a.push({id:`settings-${e.id}`,group:o,label:`${o}: ${e.label}`,hint:e.id===`general`?`${i} ,`:void 0,keywords:e.keywords,run:()=>n.settings(e.id)});let s=Q(t,`Cuộc trò chuyện`,`Conversations`);for(let t of e.sessions)a.push({id:`session-${t.sessionRef}`,group:s,label:t.title,hint:t.projectLabel,keywords:t.projectLabel,run:()=>n.openSession(t.sessionRef)});return a}var mA=class{#e=0;run(e,t,n){let r=++this.#e;return(async()=>{try{let n=await e();return r===this.#e&&t(n),n}catch{r===this.#e&&n();return}})()}invalidate(){this.#e+=1}},hA=class{#e;#t;#n;#r=0;#i=0;#a=!1;#o=!1;#s=[];constructor(e){this.#e=e.read,this.#t=e.commit,this.#n=e.classify}request(){if(this.#o)return Promise.resolve({state:`cancelled`,readSequence:this.#i});let e=++this.#r,t=new Promise(t=>this.#s.push({ticket:e,resolve:t}));return this.#c(),t}invalidate(){if(this.#o)return;this.#o=!0;let e={state:`cancelled`,readSequence:this.#i},t=this.#s;this.#s=[];for(let n of t)n.resolve(e)}async#c(){if(!(this.#a||this.#o)){this.#a=!0;try{for(;!this.#o&&this.#s.length>0;){let e=this.#r,t=++this.#i,n;try{let e=await this.#e();if(this.#o)return;try{this.#t(e),n={state:`committed`,value:e,readSequence:t}}catch(e){n={state:`terminal-error`,error:e,readSequence:t}}}catch(e){if(this.#o)return;n={state:this.#n(e)===`retryable`?`retryable-error`:`terminal-error`,error:e,readSequence:t}}let r=this.#s.filter(t=>t.ticket<=e);this.#s=this.#s.filter(t=>t.ticket>e);for(let e of r)e.resolve(n);if(n.state===`terminal-error`){this.#o=!0;let e={state:`cancelled`,readSequence:t},n=this.#s;this.#s=[];for(let t of n)t.resolve(e)}}}finally{this.#a=!1,!this.#o&&this.#s.length>0&&this.#c()}}}},gA=`piagent-gateway-event-cursor-v1`,_A=3e4,vA=12e4,yA=4001,bA=class extends Error{reasonCode;constructor(e){super(e),this.name=`SessionSendRejectedError`,this.reasonCode=e}};function xA(e,t){if(!e)return null;try{let n=JSON.parse(e);return n.gatewayInstanceRef===t&&Number.isSafeInteger(n.sequence)&&Number(n.sequence)>=0?Number(n.sequence):null}catch{return null}}function SA(e,t){if(t!==null)try{window.sessionStorage.setItem(gA,JSON.stringify({gatewayInstanceRef:e,sequence:t}))}catch{}}function CA(e){return`${e}_${crypto.randomUUID().replaceAll(`-`,``)}`}function wA(e){return e.phase===`rejected`&&e.resultCode===`stale-revision`&&e.error?.code===`session-revision-stale`}var TA=280,EA=320,DA=`min(44vw, 860px)`,OA=`piagent-webui-workspace-panel`;function kA({session:e,live:t,locale:n}){let r=JO(e,t),[i,a]=r===`running`?[Q(n,`Đang chạy`,`Running`),`primary`]:r===`elsewhere`?[Q(n,`Đang chạy ở nơi khác`,`Running elsewhere`),`info`]:r===`attention`?[Q(n,`Cần duyệt`,`Needs approval`),`warning`]:r===`recovery`?[Q(n,`Cần khôi phục`,`Recovery needed`),`error`]:r===`failed`?[Q(n,`Lượt cuối lỗi`,`Last turn failed`),`error`]:[Q(n,`Sẵn sàng`,`Ready`),`default`];return(0,U.jsx)(lu,{size:`small`,variant:`outlined`,color:a,label:i})}function AA({session:e,snapshot:t,locale:n,live:r,canSend:i,canRestart:a,send:o,abort:s,restart:c,onInspector:l}){let u=e.sessionRef,d=nE(u),[f,p]=(0,v.useState)(()=>eE(u)),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(),y=e=>{p(e),tE(u,e)},b=VT({projectRef:e.projectRef,value:f,locale:n,onChange:e=>{y(e),M(null)}}),[x,S]=(0,v.useState)(()=>d?.attachments??[]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(()=>d?.messageRequestId??`message-request.${crypto.randomUUID()}`),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(()=>d?.sendUnconfirmed??!1);(0,v.useEffect)(()=>{rE(u,x.length||N?{attachments:x,messageRequestId:T,sendUnconfirmed:N}:null)},[u,x,T,N]),(0,v.useEffect)(()=>{if(!N)return;let e=window.setTimeout(()=>{P(!1),M({tone:`error`,text:Q(n,`Tin nhắn chưa được gửi: phiên chưa nhận nó trong 2 phút nên nó sẽ không chạy nữa. Nội dung vẫn còn; bấm Gửi để thử lại.`,`The message was not sent: the session did not take it within 2 minutes, so it will not run. Your message is kept; send it again.`)})},vA+15e3);return()=>window.clearTimeout(e)},[N,n]);let[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)(!1),[z,B]=(0,v.useState)(0),V=(0,v.useRef)(0);(0,v.useEffect)(()=>{let e=e=>{uS(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]);let ne=t?.capabilities.capabilities.attachments,re=(0,v.useMemo)(()=>new Set(ne?.status===`available`?ne.mimeTypes:[]),[ne]),ie=(0,v.useMemo)(()=>lS(re),[re]),ae=!!t&&ne?.status===`available`&&i&&!m&&!N&&!D&&x.length<4,oe=async r=>{if(!(!r?.length||!t||ne?.status!==`available`||D)){O(!0),A(null);try{let i=await dS({files:r,snapshot:t,messageRequestId:T,existing:x,allowed:re,locale:n,stage:t=>M_(e.sessionRef,t)});S(i.attachments),A(i.status)}catch{A(Q(n,`Không thể đính kèm; file không được gửi vào Pi.`,`Unable to attach the file; it was not sent to Pi.`))}finally{O(!1)}}},se=async r=>{if(!(!t||m||D)){O(!0),A(null);try{let i=await fS({snapshot:t,messageRequestId:T,attachmentRef:r,locale:n,stage:t=>M_(e.sessionRef,t)});i.discarded?S(e=>e.filter(e=>e.attachmentRef!==r)):A(i.status)}catch{A(Q(n,`Không thể bỏ file; trạng thái session có thể đã thay đổi.`,`Unable to remove the file; session state may have changed.`))}finally{O(!1)}}};(0,v.useEffect)(()=>{let t=new AbortController;return _(void 0),t_(e.sessionRef,t.signal).then(_).catch(()=>void 0),()=>t.abort()},[e.sessionRef,e.sessionRevision]);let H=(0,v.useRef)(!1),ce=async()=>{let e=f;if(!e.trim()||m||N||H.current)return;H.current=!0,h(!0),M(null);let t=x.map(e=>e.attachmentRef);try{if((await o(e,t.length>0?{messageRequestId:T,attachmentRefs:t,attachments:x}:void 0)).state===`unconfirmed`){rE(u,{attachments:x,messageRequestId:T,sendUnconfirmed:!0}),P(!0),M({tone:`warning`,text:Q(n,`Piagent đang xác nhận lần gửi này. Nội dung và file vẫn được giữ; đừng gửi lại để tránh chạy trùng.`,`Piagent is confirming this send. Your message and files remain preserved; do not resend, to avoid a duplicate run.`)});return}y(``),S([]),A(null),E(`message-request.${crypto.randomUUID()}`),rE(u,null)}catch{M({tone:`error`,text:Q(n,`Tin nhắn chưa được gửi. Nội dung và file vẫn được giữ; có thể thử lại khi session sẵn sàng.`,`The message was not sent. Your message and files are preserved; retry when the session is ready.`)})}finally{H.current=!1,h(!1)}};(0,v.useEffect)(()=>{!N||r?.messageRequestId!==T||r.delivery!==`admitted`||(y(``),S([]),A(null),M(null),P(!1),E(`message-request.${crypto.randomUUID()}`))},[r?.delivery,r?.messageRequestId,T,N]);let le=async()=>{if(!(m||N)){h(!0),M(null);try{await o(Q(n,`tiếp tục`,`continue`))}catch{M({tone:`error`,text:Q(n,`Chưa gửi được. Thử lại khi session sẵn sàng.`,`Not sent. Retry when the session is ready.`)})}finally{h(!1)}}},ue=async t=>{if(t){_(t);return}_(await t_(e.sessionRef).catch(()=>g))},de=async()=>{if(!F){I(!0),R(null);try{await c()}catch(e){R(e instanceof Error?e.message:null)}finally{I(!1)}}},fe=r?.runtimeRecovery??(e.state===`recovery-required`?`stale`:null);return(0,U.jsxs)(J,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(J,{sx:{flex:1,width:`100%`,maxWidth:860,mx:`auto`,px:{xs:2,sm:4},py:{xs:3,md:4},display:`flex`,flexDirection:`column`,justifyContent:`center`},children:[!i&&e.modelLabel===`agent-watch-auto`&&(0,U.jsx)(nw,{locale:n,onConnected:()=>B(e=>e+1)},e.sessionRef),(0,U.jsx)(J,{sx:{width:`100%`},children:(0,U.jsx)(RO,{reload:z,sessionRef:e.sessionRef,sessionRevision:e.sessionRevision,live:r,approvals:t?.approvals,locale:n,onOpenActivity:()=>l(`activity`),onContinue:i&&!m&&!N&&e.liveState!==`running`&&(!r||r.complete)?()=>void le():void 0},e.sessionRef)})]}),(0,U.jsxs)(J,{sx:{position:`sticky`,bottom:`var(--piagent-status-bar, 0px)`,px:{xs:1.5,sm:2.5},pb:2.5,background:`linear-gradient(transparent, var(--piagent-palette-background-default) 25%)`},children:[e.state===`terminal-owned`&&(0,U.jsx)(pC,{severity:`info`,role:`status`,sx:{maxWidth:820,mx:`auto`,mb:1},children:Q(n,`Cuộc trò chuyện này đang chạy trong Terminal hoặc một tiến trình Piagent khác. Trang này tự cập nhật để bạn theo dõi; gửi tin nhắn khi nó chạy xong.`,`This conversation is running in Terminal or another Piagent process. This page follows it; send a message when it has finished.`)}),fe&&(0,U.jsx)(pC,{severity:fe===`recovered`?`success`:fe===`failed`?`error`:`warning`,action:(fe===`failed`||fe===`required`||fe===`stale`)&&a&&e.liveState!==`running`?(0,U.jsx)($,{color:`inherit`,size:`small`,disabled:F,onClick:()=>void de(),children:F?Q(n,`Đang khởi động…`,`Restarting…`):Q(n,`Khởi động lại phiên`,`Restart session`)}):void 0,sx:{maxWidth:860,mx:`auto`,mb:1},children:fe===`recovered`?Q(n,`Runtime mới đã được xác minh; lịch sử và context của session được giữ nguyên.`,`The new runtime is verified; session history and context were preserved.`):fe===`failed`?L?.startsWith(`company-`)&&qC(L,null,n)?`${qC(L,null,n).title}: ${qC(L,null,n).text}`:Q(n,`Runtime đã đổi nhưng chưa khởi động lại được. Hãy dùng nút bên cạnh hoặc restart Dashboard.`,`The runtime changed but could not restart. Use the action here or restart the Dashboard.`):fe===`stale`&&[`session-runtime-open-failed`,`session-runtime-dispose-failed`].includes(e.reasonCode??``)?Q(n,`Runtime của phiên này chưa mở được (thường do key, Harness hoặc Agent Watch lúc đó). Bấm Khởi động lại phiên để thử lại, hoặc lưu trữ phiên; lịch sử được giữ nguyên.`,`This session's runtime did not open (usually the key, the Harness or Agent Watch at the time). Restart the session to try again, or archive it; its history is kept.`):fe===`stale`?Q(n,`Phiên này chưa được đóng đúng cách và có thể đang mở ở cửa sổ Terminal khác. Đóng cửa sổ đó (nếu có) rồi bấm Khởi động lại phiên để làm tiếp; lịch sử được giữ nguyên.`,`This session was not closed cleanly and may still be open in a Terminal window. Close it (if any), then restart the session to go on; its history is kept.`):fe===`restarting`?Q(n,`Runtime vừa được cập nhật. Piagent đang khởi động lại session an toàn sau lượt hiện tại.`,`The runtime was updated. Piagent is safely restarting the session after the current turn.`):Q(n,`Phát hiện runtime mới. Piagent sẽ giữ câu trả lời hiện tại rồi tự khởi động lại session.`,`A new runtime was detected. Piagent will preserve the current response and restart the session automatically.`)}),(0,U.jsxs)(J,{sx:{position:`relative`,maxWidth:860,mx:`auto`,border:1,borderColor:ee?`primary.main`:`divider`,borderStyle:ee?`dashed`:`solid`,borderRadius:3,bgcolor:`background.paper`,p:1.15,boxShadow:`0 14px 44px rgba(0,0,0,.14)`},onDragEnter:e=>{uS(e.dataTransfer)&&(V.current+=1,te(!0))},onDragOver:e=>{uS(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=ae?`copy`:`none`)},onDragLeave:e=>{uS(e.dataTransfer)&&(--V.current,V.current<=0&&(V.current=0,te(!1)))},onDrop:e=>{uS(e.dataTransfer)&&(e.preventDefault(),V.current=0,te(!1),ae&&oe(e.dataTransfer.files))},children:[ee&&(0,U.jsxs)(J,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,U.jsx)(X,{sx:{fontWeight:750},children:ae?Q(n,`Thả tài liệu vào đây`,`Drop documents here`):x.length>=4?Q(n,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):Q(n,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),ae&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(n,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),x.length>0&&(0,U.jsx)(Z,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pb:.75},"aria-label":Q(n,`File sẽ gửi cùng tin nhắn`,`Files to send with the message`),children:x.map(e=>(0,U.jsx)(lu,{size:`small`,variant:`outlined`,color:e.kind===`document`?`success`:`default`,label:`${e.displayName} · ${cS(e,n)}`,onDelete:m||N||D?void 0:()=>void se(e.attachmentRef),deleteIcon:(0,U.jsx)(YS,{"aria-label":`${Q(n,`Bỏ`,`Remove`)} ${e.displayName}`,role:`button`})},e.attachmentRef))}),(0,U.jsx)(ux,{fullWidth:!0,multiline:!0,minRows:2,disabled:!i||m||N,value:f,inputRef:b.inputRef,...b.inputProps,onChange:e=>{y(e.target.value),M(null),b.track(e)},onKeyDown:e=>{b.onKeyDown(e)||bT(e)&&(e.preventDefault(),ce())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),ae&&oe(e.clipboardData.files))},placeholder:Q(n,`Nhắn cho Piagent… (@ để chọn file, folder)`,`Message Piagent… (@ for files and folders)`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:b.htmlInput}}),b.menu,(0,U.jsx)(jC,{in:C,id:`piagent-message-options`,children:(0,U.jsxs)(J,{sx:{mt:.65,p:.85,borderRadius:2,bgcolor:`action.hover`},children:[(0,U.jsx)(_T,{session:e,snapshot:t,connections:g,locale:n,onOpenChanges:()=>l(`source`),onConnectionsChanged:ue}),(0,U.jsx)(Z,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:.75,flexWrap:`wrap`},children:ne?.status===`available`&&(0,U.jsx)(Ah,{title:Q(n,`Chọn file, hoặc kéo thả / dán thẳng vào khung chat`,`Pick a file, or drag and drop / paste straight into the chat`),children:(0,U.jsxs)($,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,U.jsx)(JS,{}),disabled:!ae,"aria-label":`${Q(n,`Đính kèm`,`Attach`)} (${x.length}/4)`,children:[Q(n,`Đính kèm`,`Attach`),(0,U.jsx)(`input`,{type:`file`,multiple:!0,hidden:!0,disabled:!ae,accept:ie||void 0,onChange:e=>{oe(e.target.files),e.currentTarget.value=``}})]})})})]})}),(0,U.jsxs)(Z,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`,mt:.5,gap:1},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:1},children:[(0,U.jsx)(Ah,{title:C?Q(n,`Ẩn tùy chọn`,`Hide options`):Q(n,`File và công cụ`,`Files and tools`),children:(0,U.jsx)(Qd,{size:`small`,"aria-label":C?Q(n,`Ẩn tùy chọn`,`Hide options`):Q(n,`Thêm tùy chọn`,`More options`),"aria-expanded":C,"aria-controls":`piagent-message-options`,onClick:()=>w(e=>!e),sx:{bgcolor:C?`action.selected`:`transparent`},children:(0,U.jsx)(qS,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:C?`rotate(45deg)`:`none`}})})}),(0,U.jsx)(X,{variant:`caption`,color:k||j?.tone===`error`?`error`:j?`warning.main`:`text.disabled`,noWrap:!j,sx:{display:{xs:k||j||D?`block`:`none`,sm:`block`}},children:j?.text??k??(D?Q(n,`Đang đọc tài liệu…`,`Reading documents…`):r&&!r.complete?Q(n,`Piagent đang xử lý; có thể gửi việc tiếp theo khi lượt này xong.`,`Piagent is working; you can send the next task when it finishes.`):i?Q(n,`Enter để gửi · Shift+Enter xuống dòng`,`Enter to send · Shift+Enter for a new line`):Q(n,`Session hiện chỉ đọc`,`Session is currently read only`))})]}),r?.operationRef&&!r.complete&&r.abortable!==!1?(0,U.jsx)($,{color:`error`,startIcon:(0,U.jsx)($S,{}),onClick:()=>void s(),children:Q(n,`Dừng`,`Stop`)}):(0,U.jsx)(Qd,{"aria-label":Q(n,`Gửi`,`Send`),disabled:!i||m||N||!f.trim(),color:`primary`,onClick:()=>void ce(),sx:{bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,U.jsx)(ZS,{fontSize:`small`})})]})]})]})]})}function jA({locale:e,canCreate:t,onNew:n}){return(0,U.jsxs)(Z,{sx:{minHeight:`calc(100vh - 68px)`,alignItems:`center`,justifyContent:`center`,px:3,textAlign:`center`},spacing:1.5,children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,sx:{width:50,height:50,fontSize:25},children:`π`}),(0,U.jsx)(X,{variant:`h1`,children:Q(e,`Bắt đầu với Piagent`,`Start with Piagent`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{maxWidth:520},children:Q(e,`Tạo cuộc trò chuyện mới, chọn project và model; session sẽ được lưu để tiếp tục sau khi đóng Gateway.`,`Create a new chat, choose a project and model, and the session will remain available after the Gateway closes.`)}),(0,U.jsx)($,{disabled:!t,variant:`contained`,startIcon:(0,U.jsx)(qS,{}),onClick:n,children:Q(e,`Cuộc trò chuyện mới`,`New chat`)})]})}function MA({catalog:e,capabilities:t,connection:n,live:r,terminalActivities:i,refresh:a,create:o,send:s,abort:c,restart:l,setModel:u,setThinking:d,setPermission:f,rename:p,pin:m,archive:h,unarchive:g,fork:_}){let{locale:y,colorMode:b,setLocale:x,setColorMode:S}=Gv(),C=sE(),w=ME(),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(`chat`),[L,R]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(`general`),[z,B]=(0,v.useState)(!1),[V,ne]=(0,v.useState)(`task`),re=typeof window<`u`&&window.innerWidth<1200,[ie,ae]=(0,v.useState)(()=>{try{let e=window.localStorage.getItem(OA);if(e)return e===`open`}catch{}return window.innerWidth>=1200}),oe=()=>ae(e=>{try{window.localStorage.setItem(OA,e?`closed`:`open`)}catch{}return!e}),se=(0,v.useRef)(!1);se.current=z&&V===`activity`;let[H,ce]=(0,v.useState)(),le=(0,v.useRef)(null),[ue,de]=(0,v.useState)(`idle`),fe=(0,v.useRef)(null),pe=(0,v.useRef)(null);pe.current??=new mA;let[me,he]=(0,v.useState)(!1),[ge,_e]=(0,v.useState)(null),[ve,ye]=(0,v.useState)(null),[be,xe]=(0,v.useState)(``),[Se,Ce]=(0,v.useState)(!1),[we,Te]=(0,v.useState)(null),[Ee,De]=(0,v.useState)(null);(0,v.useEffect)(()=>{F===`chat`&&k||(window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0)},[F,k]);let Oe=(0,v.useMemo)(()=>(e?.sessions??[]).filter(e=>e.archived===N&&`${e.title} ${e.projectLabel} ${e.preview}`.toLowerCase().includes(D.trim().toLowerCase())),[e,D,N]),ke=(0,v.useMemo)(()=>{let e=new Map;for(let t of Oe){let n=e.get(t.projectRef)??{label:t.projectLabel,gitBranch:t.gitBranch,sessions:[]};n.gitBranch??=t.gitBranch,n.sessions.push(t),e.set(t.projectRef,n)}return[...e.entries()].map(([e,t])=>({projectRef:e,...t,sessions:t.sessions.sort((e,t)=>Number(t.pinned)-Number(e.pinned)||Date.parse(t.updatedAt)-Date.parse(e.updatedAt))})).sort((e,t)=>Date.parse(t.sessions[0]?.updatedAt??``)-Date.parse(e.sessions[0]?.updatedAt??``))},[Oe]),Ae=e?.sessions.filter(e=>e.archived).length??0;(0,v.useEffect)(()=>{(!k||!(e?.sessions??[]).some(e=>e.sessionRef===k))&&A((e?.sessions??[]).find(e=>!e.archived)?.sessionRef)},[k,e]);let je=(e?.sessions??[]).find(e=>e.sessionRef===k),Me=je?.sessionRef,Ne=je?.state===`terminal-owned`,Pe=(e?.sessions??[]).some(e=>e.state===`terminal-owned`);(0,v.useEffect)(()=>{let e=Ne?3e3:Pe?1e4:3e4,t=window.setInterval(()=>{document.visibilityState===`visible`&&a()},e);return()=>window.clearInterval(t)},[Ne,Pe,a]);let Fe=(0,v.useRef)(Me);Fe.current=Me;let Ie=le.current&&le.current.sessionRef===Me&&le.current.snapshot===H?H:void 0,Le=fe.current===Me?ue:Me?`loading`:`idle`,Re=je?r[je.sessionRef]:void 0,[ze,Be]=(0,v.useState)(null),Ve=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!e||Ve.current)return;Ve.current=!0;let t=bg();t&&(Be(t),I(`new`))},[e]);let He=e=>{Be(null),A(e),I(`chat`),M(!1)},Ue=e=>{te(e),R(!0)};Wk({palette:()=>E(!0),settings:()=>Ue(`general`)});let We=e=>{ne(e),B(!0)},Ge=async()=>{let e=Fe.current;if(!e)return;le.current?.sessionRef!==e&&(fe.current=e,de(`loading`));let t=await pe.current.run(()=>Gg(e),t=>{Fe.current===e&&(le.current={sessionRef:e,snapshot:t},fe.current=e,ce(t),de(`ready`))},()=>{Fe.current===e&&(fe.current=e,de(le.current?.sessionRef===e?`ready`:`error`))});return Fe.current===e?t:void 0};(0,v.useEffect)(()=>{if(!Me){pe.current.invalidate(),le.current=null,fe.current=null,ce(void 0),de(`idle`);return}let e=Me,t=new AbortController;return fe.current=e,le.current?.sessionRef!==e&&(le.current=null,ce(void 0),de(`loading`)),pe.current.run(()=>Gg(e,t.signal),n=>{t.signal.aborted||Fe.current!==e||(le.current={sessionRef:e,snapshot:n},fe.current=e,ce(n),de(`ready`))},()=>{t.signal.aborted||Fe.current!==e||(fe.current=e,de(le.current?.sessionRef===e?`ready`:`error`))}),()=>t.abort()},[Me,je?.sessionRevision]),(0,v.useEffect)(()=>{if(!z||V!==`activity`||!Me||!Ie||!Re?.operationRef||Re.complete)return;let e=Me,t=!1,n,r=async()=>{await pe.current.run(()=>Gg(e),n=>{t||!se.current||Fe.current!==e||(le.current={sessionRef:e,snapshot:n},fe.current=e,ce(n),de(`ready`))},()=>void 0),t||(n=window.setTimeout(()=>void r(),2e3))};return n=window.setTimeout(()=>void r(),2e3),()=>{t=!0,n!==void 0&&window.clearTimeout(n)}},[z,V,Me,!!Ie,Re?.operationRef,Re?.complete]);let Ke=n===`connected`&&t?.capabilities.sessionActions.create.status===`available`,qe=async e=>{he(!0),_e(null);let t=null;try{let n=`message-request.${crypto.randomUUID()}`,r=e.files.length>0,i=await o({projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,permissionMode:e.permissionMode,message:e.message,messageRequestId:n,deferInitialMessage:r});if(t=i.sessionRef,!t)throw Error(`session-create-result-invalid`);if(tE(HT,``),rE(HT,null),i.phase!==`settled`){A(t),I(`chat`),De({title:Q(y,`Session đã được tạo`,`The session was created`),message:Q(y,`Pi đã nhận yêu cầu và session đang tự đồng bộ. Không gửi lại để tránh chạy trùng.`,`Pi received the request and the session is resyncing. Do not resend it, to avoid a duplicate run.`)});return}if(r){let r=(await a())?.sessions.find(e=>e.sessionRef===t);if(!r)throw Error(`session-catalog-refresh-failed`);let i=await Gg(t),o=i.capabilities.capabilities.attachments;if(o.status!==`available`)throw Error(o.reason?.code??`session-attachment-unavailable`);let c=await dS({files:e.files,snapshot:i,messageRequestId:n,existing:[],allowed:new Set(o.mimeTypes),locale:y,stage:e=>M_(t,e)});if(c.status||c.attachments.length!==e.files.length)throw await Promise.all(c.attachments.map(async e=>{try{await fS({snapshot:i,messageRequestId:n,attachmentRef:e.attachmentRef,locale:y,stage:e=>M_(t,e)})}catch{}})),Error(c.status??`session-attachment-incomplete`);await s(r,e.message,{messageRequestId:n,attachmentRefs:c.attachments.map(e=>e.attachmentRef),attachments:c.attachments,workflow:e.workflow})}A(t),I(`chat`)}catch(n){let r=n instanceof Error?n.message:`session-create-failed`;t?(e.files.length>0&&tE(t,e.message),A(t),I(`chat`),De({title:Q(y,`Session đã tạo nhưng file chưa được gửi`,`The session was created, but the files were not sent`),message:r})):_e($C(r,y))}finally{he(!1)}},Je=(e,t)=>{if(t===`pin`){m(e,!e.pinned).catch(e=>De({title:Q(y,`Không thể đổi trạng thái ghim`,`Could not change pin state`),message:e instanceof Error?e.message:`session-pin-failed`}));return}if(t===`unarchive`){g(e).then(()=>P(!1)).catch(e=>De({title:Q(y,`Không thể khôi phục cuộc trò chuyện`,`Could not restore chat`),message:e instanceof Error?e.message:`session-unarchive-failed`}));return}Te(null),xe(t===`rename`?e.title:t===`fork`?`${e.title} · ${Q(y,`nhánh`,`fork`)}`:``),ye({kind:t,session:e})},Ye=async()=>{if(!(!ve||Se)){Ce(!0),Te(null);try{if(ve.kind===`rename`)await p(ve.session,be.trim());else if(ve.kind===`archive`)await h(ve.session);else{let e=await _(ve.session,be.trim()||null);e.sessionRef&&(A(e.sessionRef),I(`chat`))}ye(null)}catch(e){Te(e instanceof Error?e.message:`session-action-failed`)}finally{Ce(!1)}}},Xe=(0,U.jsx)(nk,{locale:y,canCreate:Ke,query:D,onQuery:O,groups:ke,count:Oe.length,selectedRef:F===`chat`?je?.sessionRef:void 0,showArchived:N,archivedCount:Ae,settingsOpen:L,connection:n,live:r,onSelect:He,onAction:Je,onNew:()=>{_e(null),I(`new`),M(!1)},onToggleArchived:()=>{P(e=>!e),M(!1)},updateDot:!!(w.status?.updateAvailable&&w.status.installable),onSettings:()=>{Ue(w.status?.updateAvailable&&w.status.installable?`updates`:`general`),M(!1)}}),Ze=F===`chat`&&je?(0,U.jsx)(Tk,{session:je,snapshot:Ie,live:Re,locale:y,onOpenReview:()=>We(`source`),onClose:()=>ae(!1)}):null,Qe=!!Ze&&ie&&!z;if(C)return(0,U.jsx)(cE,{locale:y});if(!e&&n!==`failed`)return(0,U.jsxs)(Z,{sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},spacing:2,children:[(0,U.jsx)(xu,{size:24}),(0,U.jsx)(X,{children:Q(y,`Đang mở Piagent…`,`Opening Piagent…`)})]});let $e=F===`new`?Q(y,`Cuộc trò chuyện mới`,`New chat`):je?.title??`Piagent`,et=pA({locale:y,colorMode:b,canCreate:Ke,hasSelection:F===`chat`&&!!je,sessions:(e?.sessions??[]).filter(e=>!e.archived),update:{available:!!(w.status?.updateAvailable&&w.status.installable&&!kE(w.status)),latest:w.status?.piagent.latest??null},actions:{newChat:()=>{_e(null),I(`new`)},togglePanel:oe,openChanges:()=>We(`source`),refresh:()=>void a(),settings:Ue,checkUpdates:()=>{Ue(`updates`),w.check()},setColorMode:S,setLocale:x,openSession:He}}),tt=Object.values(r).filter(e=>e&&!e.complete).length;return(0,U.jsxs)(J,{sx:{minHeight:`100vh`,bgcolor:`background.default`,"--piagent-status-bar":{xs:`0px`,md:`28px`}},children:[(0,U.jsx)(zc,{position:`fixed`,color:`transparent`,elevation:0,sx:{left:{md:`${TA}px`},right:{lg:Qe?`${EA}px`:0,xl:z?DA:Qe?`${EA}px`:0},width:{xs:`100%`,md:`auto`},borderBottom:1,transition:`right .2s ease`,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .9)`,backdropFilter:`blur(18px)`},children:(0,U.jsxs)(up,{sx:{minHeight:`60px !important`,gap:1},children:[(0,U.jsx)(Qd,{"aria-label":Q(y,`Mở điều hướng`,`Open navigation`),onClick:()=>M(!0),sx:{display:{md:`none`}},children:(0,U.jsx)(Rh,{})}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{component:`h1`,noWrap:!0,sx:{fontWeight:600,fontSize:`inherit`},children:$e}),F===`chat`&&je&&(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,sx:{display:`flex`,alignItems:`center`,gap:.75,minWidth:0},children:[(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,flexShrink:3,minWidth:24},children:je.projectLabel}),je.gitBranch&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{component:`span`,"aria-hidden":!0,sx:{color:`text.disabled`},children:`·`}),(0,U.jsx)(qk,{projectRef:je.projectRef,projectLabel:je.projectLabel,branch:je.gitBranch,locale:y,maxWidth:`45%`,onSwitched:()=>void a()})]})]})]}),F===`chat`&&je&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(_T,{placement:`header`,session:je,snapshot:Ie,locale:y,onOpenChanges:()=>We(`source`),canSetModel:n===`connected`&&t?.capabilities.sessionActions.setModel.status===`available`,canSetThinking:n===`connected`&&t?.capabilities.sessionActions.setThinking.status===`available`,canSetPermission:n===`connected`&&t?.capabilities.sessionActions.setPermission.status===`available`,onSetModel:e=>u(je,e),onSetThinking:e=>d(je,e),onSetPermission:e=>f(je,e)}),(0,U.jsx)(J,{sx:{display:{xs:`none`,sm:`block`}},children:(0,U.jsx)(kA,{session:je,live:Re,locale:y})}),(0,U.jsx)(Ah,{title:`Source Changes`,children:(0,U.jsx)(Qd,{"aria-label":Q(y,`Mở Source Changes Inspector`,`Open Source Changes Inspector`),onClick:()=>We(`source`),children:(0,U.jsx)(Ph,{fontSize:`small`})})}),(0,U.jsx)(Ah,{title:Q(y,`Khung Workspace: thay đổi, ngữ cảnh, subagent`,`Workspace panel: changes, context, subagents`),children:(0,U.jsx)(Qd,{"aria-label":Q(y,`Khung Workspace`,`Workspace panel`),"aria-pressed":Qe,onClick:()=>oe(),color:Qe?`primary`:`default`,children:(0,U.jsx)(QS,{fontSize:`small`,sx:{transform:`scaleX(-1)`}})})})]}),(0,U.jsx)(Ah,{title:Q(y,`Làm mới`,`Refresh`),children:(0,U.jsx)(Qd,{"aria-label":Q(y,`Làm mới`,`Refresh`),onClick:()=>void a(),children:(0,U.jsx)(XS,{fontSize:`small`})})})]})}),(0,U.jsxs)(J,{component:`nav`,sx:{width:{md:TA}},children:[(0,U.jsx)(Kd,{variant:`temporary`,open:j,onClose:()=>M(!1),sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:TA}},children:Xe}),(0,U.jsx)(Kd,{variant:`permanent`,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:TA,borderRight:1,borderColor:`divider`,height:`calc(100% - var(--piagent-status-bar, 0px))`}},children:Xe})]}),(0,U.jsx)(J,{component:`main`,sx:{ml:{md:`${TA}px`},mr:{lg:Qe?`${EA}px`:0,xl:z?DA:Qe?`${EA}px`:0},pt:`60px`,transition:`margin-right .2s ease`},children:F===`new`?(0,U.jsx)(aE,{active:!0,defaultProjectRef:ze??je?.projectRef,busy:me,error:ge,onCancel:()=>I(`chat`),onCreate:e=>qe(e)}):je?(0,U.jsx)(AA,{session:je,snapshot:Ie,locale:y,live:r[je.sessionRef],canSend:n===`connected`&&je.composerAvailable&&t?.capabilities.sessionActions.send.status===`available`&&(!Re||Re.complete)&&![`required`,`restarting`,`failed`].includes(String(r[je.sessionRef]?.runtimeRecovery)),canRestart:n===`connected`&&t?.capabilities.sessionActions.release.status===`available`&&t?.capabilities.sessionActions.acquire.status===`available`,send:(e,t)=>s(je,e,t),abort:()=>c(je).catch(e=>De({title:Q(y,`Chưa dừng được lượt này`,`This turn could not be stopped`),message:e instanceof Error&&e.message===`operation-unavailable`?Q(y,`Lượt đã kết thúc hoặc đang chuyển bước. Nếu vẫn còn chạy, bấm Dừng lần nữa.`,`The turn already ended or is between steps. If it is still running, press Stop again.`):e instanceof Error?e.message:`session-abort-failed`})),restart:()=>l(je),onInspector:We},je.sessionRef):(0,U.jsx)(jA,{locale:y,canCreate:Ke,onNew:()=>I(`new`)})}),Ze&&Qe&&!re&&(0,U.jsx)(J,{component:`aside`,sx:{display:{xs:`none`,lg:`block`},position:`fixed`,top:0,right:0,bottom:`var(--piagent-status-bar, 0px)`,width:EA,borderLeft:1,borderColor:`divider`,zIndex:e=>e.zIndex.appBar-1},children:Ze}),Ze&&(0,U.jsx)(Kd,{anchor:`right`,variant:`temporary`,open:ie&&!z&&re,onClose:()=>ae(!1),sx:{display:{xs:`block`,lg:`none`},"& .MuiDrawer-paper":{width:`min(${EA}px, 88vw)`}},children:Ze}),(0,U.jsx)(ZE,{open:z,active:V,snapshot:Ie,state:Le,sessionRef:Me,terminalActivities:je?i[je.sessionRef]:void 0,liveActivities:Re&&!Re.complete?Re.activities:void 0,onClose:()=>B(!1),onActive:ne,refresh:Ge}),(0,U.jsx)(KE,{locale:y,onDetails:()=>Ue(`updates`)}),(0,U.jsx)(Zk,{locale:y,connection:n,running:tt,session:F===`chat`?je:void 0,onBranchSwitched:()=>void a(),onUpdates:()=>Ue(`updates`),onPalette:()=>E(!0)}),(0,U.jsx)(Gk,{open:T,onClose:()=>E(!1),commands:et,locale:y}),(0,U.jsx)(zC,{open:L,onClose:()=>R(!1),fullWidth:!0,maxWidth:`lg`,"aria-labelledby":`piagent-settings-title`,slotProps:{paper:{sx:{m:{xs:0,sm:2},width:{xs:`100%`,sm:`calc(100% - 32px)`},height:{xs:`100%`,sm:`min(86vh, 840px)`},maxHeight:{xs:`100%`,sm:`86vh`},borderRadius:{xs:0,sm:2.5},overflow:`hidden`}}},children:(0,U.jsx)(fA,{section:ee,onSection:te,onBack:()=>R(!1),session:je,snapshot:Ie,capabilities:t,connection:n,onSetModel:je?e=>u(je,e):void 0,onSetThinking:je?e=>d(je,e):void 0,onSetPermission:je?e=>f(je,e):void 0,onRuntimeChanged:async()=>{await a(),await Ge()}})}),(0,U.jsx)(zC,{open:!!ve,onClose:()=>!Se&&ye(null),fullWidth:!0,maxWidth:`xs`,children:(0,U.jsxs)(Z,{spacing:2,sx:{p:3},children:[(0,U.jsx)(X,{variant:`h2`,children:ve?.kind===`rename`?Q(y,`Đổi tên cuộc trò chuyện`,`Rename chat`):ve?.kind===`fork`?Q(y,`Tạo nhánh cuộc trò chuyện`,`Fork chat`):Q(y,`Lưu trữ cuộc trò chuyện`,`Archive chat`)}),ve?.kind===`archive`?(0,U.jsx)(X,{color:`text.secondary`,children:Q(y,`Cuộc trò chuyện vẫn được lưu và có thể khôi phục từ mục Đã lưu trữ.`,`The chat remains saved and can be restored from Archived.`)}):(0,U.jsx)(ux,{autoFocus:!0,label:Q(y,`Tên`,`Title`),value:be,onChange:e=>xe(e.target.value),slotProps:{htmlInput:{maxLength:500}}}),we&&(0,U.jsx)(X,{color:`error`,children:we}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{justifyContent:`flex-end`},children:[(0,U.jsx)($,{disabled:Se,onClick:()=>ye(null),children:Q(y,`Hủy`,`Cancel`)}),(0,U.jsx)($,{variant:`contained`,disabled:Se||ve?.kind!==`archive`&&!be.trim(),onClick:()=>void Ye(),children:Q(y,`Xác nhận`,`Confirm`)})]})]})}),(0,U.jsx)(zC,{open:!!Ee,onClose:()=>De(null),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-session-notice-title`,children:(0,U.jsxs)(Z,{spacing:2,sx:{p:3},children:[(0,U.jsx)(X,{id:`piagent-session-notice-title`,variant:`h2`,children:Ee?.title}),(0,U.jsx)(X,{color:`text.secondary`,children:Ee?.message}),(0,U.jsx)(Z,{direction:`row`,sx:{justifyContent:`flex-end`},children:(0,U.jsx)($,{variant:`contained`,onClick:()=>De(null),children:Q(y,`Đóng`,`Close`)})})]})})]})}function NA(e){let t=e===`dark`,n=t?`#d8ff7a`:`#627400`,r=t?`#8be9c8`:`#14775f`;return Ho({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:e,primary:{main:n,light:t?`#e6ff9f`:`#849a17`,dark:t?`#a7cc45`:`#455400`,contrastText:t?`#111300`:`#ffffff`},secondary:{main:r},success:{main:r},warning:{main:`#efba63`},error:{main:`#ff7f86`},background:{default:t?`#050505`:`#f5f6f0`,paper:t?`#101114`:`#ffffff`},text:{primary:t?`#f4f4ef`:`#1c2018`,secondary:t?`#a4a6ad`:`#62685c`,disabled:t?`#898c95`:`#6b7165`},divider:t?`#24262d`:`#dfe2d8`},shape:{borderRadius:10},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.65rem`,fontWeight:600,letterSpacing:`-0.03em`},h2:{fontSize:`1.2rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`1rem`,fontWeight:600},button:{fontSize:`0.78rem`,fontWeight:500,textTransform:`none`},caption:{fontSize:`0.7rem`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:t?`#050505`:`#f5f6f0`},body:{minWidth:320,minHeight:`100vh`,backgroundImage:t?`radial-gradient(circle at 65% -18%, rgba(139,233,200,.12) 0, transparent 34rem)`:`radial-gradient(circle at 65% -18%, rgba(216,255,122,.22) 0, transparent 34rem)`},"::selection":{backgroundColor:Ci(n,.26)}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:34,borderRadius:8},outlined:{borderColor:t?`#32343c`:`#cfd4c8`}}},MuiChip:{styleOverrides:{root:{height:26,borderRadius:7,fontWeight:500}}},MuiListItemButton:{styleOverrides:{root:{minHeight:42,margin:`2px 10px`,borderRadius:8,color:t?`#a4a6ad`:`#62685c`,"&.Mui-selected":{color:t?`#f4f4ef`:`#1c2018`,backgroundColor:Ci(n,t?.11:.1),boxShadow:`inset 2px 0 ${n}`},"&.Mui-selected:hover":{backgroundColor:Ci(n,.15)}}}},MuiTab:{styleOverrides:{root:{minHeight:48,paddingInline:18,textTransform:`none`,fontWeight:500}}},MuiTooltip:{defaultProps:{arrow:!0}}}})}function PA(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 FA=250,IA=4e3,LA=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/;function RA(e){return Math.min(FA*2**Math.min(Math.max(0,e),16),IA)}function zA(e){return e instanceof kg?e.status===408||e.status===409||e.status===423||e.status===425||e.status===429||e.status>=500?`retryable`:`terminal`:typeof DOMException<`u`&&e instanceof DOMException&&e.name===`AbortError`?`terminal`:e instanceof TypeError?`retryable`:`terminal`}function BA(e,...t){for(let e of t)if(typeof e==`string`&&LA.test(e))return e;return e}function VA(e){if(!e||typeof e!=`object`)throw Error(`invalid-inspection-snapshot`);let t=e;if(t.schemaVersion!==1||t.version!==`piagent-webui-snapshot-v1`||typeof t.generatedAt!=`string`||[`identity`,`revision`,`capabilities`,`session`,`sourceChanges`,`activity`,`approvals`,`verification`,`usage`,`continuation`,`health`].some(e=>!t[e]||typeof t[e]!=`object`))throw Error(`invalid-inspection-snapshot`);let n=t.revision;if(typeof n.eventCursor!=`string`||!LA.test(n.eventCursor))throw Error(`invalid-inspection-snapshot-cursor`);return e}function HA(e=0){return{state:`cancelled`,readSequence:e}}async function UA(e){let t=0;for(;!e.stopped();){let n=await e.read();if(e.stopped())return HA(n.readSequence);if(n.state!==`retryable-error`)return n;await e.wait(RA(t)),t=Math.min(t+1,16)}return HA()}function WA(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(`connecting`),[i,a]=(0,v.useState)([]),o=(0,v.useRef)(()=>Promise.resolve(HA())),s=(0,v.useRef)(()=>void 0),c=(0,v.useCallback)(async()=>{let e=await o.current();if(e.state===`committed`)return s.current(e.value),e.value},[]);return(0,v.useEffect)(()=>{let e=new AbortController,n,i,c,l,u,d=0,f=0,p=0,m=0,h=null,g=!1,_=!1,v=!1,y=!1,b=!1,x=!1,S=!1,C=!1,w=()=>{window.clearTimeout(i),i=void 0},T=()=>{window.clearTimeout(c),c=void 0},E=()=>{window.clearTimeout(l),l=void 0;let e=u;u=void 0,e?.()},D=e=>new Promise(t=>{let n=()=>{u===n&&(u=void 0,l=void 0),t()};u=n,l=window.setTimeout(n,e)}),O=()=>{d+=1,E()},k,A=()=>{C||S||(S=!0,O(),w(),T(),e.abort(),k.invalidate(),n?.close(),n=void 0,y=!1,r(`failed`))};k=new hA({read:async()=>{let t=m;return{snapshot:VA(await Ag(e.signal)),eventGenerationAtStart:t}},commit:({snapshot:e,eventGenerationAtStart:n})=>{C||S||(_=!0,v=!0,m===n&&(h=BA(null,e.revision.eventCursor)),t(e),y&&r(`connected`))},classify:zA});let j=async()=>{let e=await k.request();return e.state===`committed`?{...e,value:e.value.snapshot}:(e.state===`terminal-error`&&A(),e)};o.current=j;let M=()=>void 0,N=()=>void 0,P=()=>{if(C||S||!g||!_||n)return;O();let e=h?`?after=${encodeURIComponent(h)}`:``,t;try{t=new EventSource(`/api/v1/events${e}`,{withCredentials:!0})}catch{f=Math.min(f+1,16),r(`reconnecting`),M(RA(f-1));return}n=t,y=!1,r(e=>e===`connecting`?`connecting`:`reconnecting`),t.onopen=()=>{C||S||n!==t||(y=!0,f=0,r(v?`connected`:`reconnecting`))},t.addEventListener(`runtime-event`,e=>{if(!(C||S||n!==t))try{let t=e,n=JSON.parse(t.data);if(!n||typeof n.kind!=`string`)return;let r=BA(h,t.lastEventId,n.eventCursor);r!==h&&(h=r,m+=1),a(e=>[...e,n].slice(-500)),[`message.text-delta`,`message.thinking-state`,`activity.progress`].includes(String(n.kind))||N()}catch{}}),t.addEventListener(`resync-required`,()=>{C||S||n!==t||(t.close(),n=void 0,y=!1,w(),T(),x=!1,a([]),r(`reconnecting`),M(0,!0))}),t.onerror=()=>{C||S||n!==t||(t.close(),n=void 0,y=!1,v=!1,f=Math.min(f+1,16),r(`reconnecting`),M(RA(f-1)))}};M=(e=0,t=!1)=>{if(C||S)return;let i=++d;E(),t&&a([]),r(_?`reconnecting`:`connecting`),(async()=>{if(e>0&&await D(e),C||S||d!==i||n)return;let t=await UA({read:j,wait:D,stopped:()=>C||S||d!==i||!!n});C||S||d!==i||n||t.state===`committed`&&P()})()};let F=()=>{if(C||S||!n||c!==void 0)return;let e=RA(p);p=Math.min(p+1,16),c=window.setTimeout(()=>{c=void 0,x=!0,I()},e)},I=async()=>{if(!(C||S||!n)){if(b){x=!0;return}b=!0;try{do{x=!1;let e=await j();if(C||S||!n||e.state===`cancelled`||e.state===`terminal-error`)return;if(e.state===`retryable-error`){v=!1,r(`reconnecting`),x=!0,F();return}p=0}while(x&&!C&&!S&&n)}finally{b=!1,x&&c===void 0&&i===void 0&&n&&!S&&!C&&(i=window.setTimeout(()=>{i=void 0,I()},80))}}};N=()=>{x=!0,!(C||S||b||c!==void 0||i!==void 0)&&(i=window.setTimeout(()=>{i=void 0,I()},80))};let L=e=>{!C&&!S&&g&&!n&&P()};return s.current=L,(async()=>{let e;try{e=await Sg()}catch{!C&&!S&&A();return}if(!(C||S)){if(e===`failed`){A();return}g=!0,M()}})(),()=>{C=!0,O(),e.abort(),k.invalidate(),n?.close(),w(),T(),s.current===L&&(s.current=()=>void 0),o.current===j&&(o.current=()=>Promise.resolve(HA()))}},[]),{snapshot:e,connection:n,events:i,refreshSnapshot:c}}function GA(e,t=150){let n,r=!1,i=!1,a=!1,o=()=>{if(!a){if(r||n!==void 0){i=r;return}n=setTimeout(()=>{n=void 0,r=!0,e().catch(()=>void 0).finally(()=>{r=!1,i&&(i=!1,o())})},t)}};return{request:o,stop:()=>{a=!0,n!==void 0&&clearTimeout(n),n=void 0}}}var KA=class extends Error{effectMayHaveOccurred;constructor(e,t){super(e),this.name=`GatewayCommandTransportError`,this.effectMayHaveOccurred=t}};async function qA(e,t,n=4){for(let r=1;;r+=1)try{return await e(t)}catch(e){if(r>=n||!(e instanceof KA)||e.message!==`gateway-command-response-timeout`)throw e}}function JA(e,t){return e instanceof KA?e.effectMayHaveOccurred:t}function YA(e,t,n=null,r=null){return!e||e.serial<=t||e.operationRef===n||r&&e.messageRequestId&&e.messageRequestId!==r?null:e}function XA(e,t,n=null){return e&&e.operationRef!==t&&!(n&&e.messageRequestId&&e.messageRequestId!==n)?{operationRef:e.operationRef,complete:!1}:null}function ZA(e,t){return t?`observed`:e?.phase===`settled`||e?.phase===`accepted`?`confirmed`:e?.phase===`rejected`?`rejected`:`unconfirmed`}function QA(e,t){let n=new AbortController,r=()=>void 0,i=new Promise(e=>{r=e}),a=setTimeout(()=>{n.abort(),r(null)},t);return{promise:Promise.race([e(n.signal).catch(()=>null),i]).finally(()=>clearTimeout(a)),cancel(){n.abort(),r(null),clearTimeout(a)}}}function $A(e,t,n,r,i){let a=e[t];if(!a||a.messageRequestId!==n||i===`unconfirmed`&&(a.delivery===`admitted`||a.operationRef))return e;let o=hD(a,i,r.operationRef,new Date().toISOString()),s=i===`unconfirmed`||r.complete||!!(r.operationRef&&a.operationRef===r.operationRef&&a.complete);return{...e,[t]:{...o,complete:s,abortable:i===`admitted`&&!s&&!!r.operationRef}}}async function ej(e,t={}){let n=()=>{let t=YA(e.readLocalObservation?.()??e.localObservation,e.afterSerial,e.priorOperationRef,e.messageRequestId);return t?{operationRef:t.operationRef,complete:t.complete}:null},r=n();if(r)return r;let i=t.timeoutMs??5e3,a=t.readLiveState??Mg,o=t.readTranscript??Kg,s=[QA(async t=>{let n=await a(t);return XA(n?.state===`ready`?n.operations.find(t=>t.sessionRef===e.sessionRef):void 0,e.priorOperationRef,e.messageRequestId)},i),QA(async t=>{let n=await o(e.sessionRef,null,50,t);if(n?.state!==`ready`)return null;let r=[...n.items].reverse().find(t=>t.role===`user`&&t.messageRequestId===e.messageRequestId);if(r)return{operationRef:r.agentOperationId,complete:tS(n.items,e.message,{operationRef:r.agentOperationId,messageRequestId:e.messageRequestId,startedAt:null})};let i=Date.parse(e.requestedAt),a=[...n.items].reverse().find(t=>t.role===`user`&&!t.messageRequestId&&Xx(t.content.text,e.message)&&Date.parse(t.recordedAt)>=i);return a?{operationRef:a.agentOperationId,complete:tS(n.items,e.message,{operationRef:a.agentOperationId,messageRequestId:null,startedAt:e.requestedAt})}:null},i)],c=new Map(s.map((e,t)=>[t,e.promise.then(e=>({evidence:e,index:t}))]));try{for(;c.size>0;){let e=await Promise.race(c.values());if(c.delete(e.index),e.evidence)return e.evidence;let t=n();if(t)return t}return n()}finally{for(let e of s)e.cancel()}}function tj(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`connecting`),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)({}),u=(0,v.useRef)(void 0),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)({});p.current=o;let m=(0,v.useRef)(0),h=(0,v.useRef)(new Map),g=(0,v.useRef)(null),_=(0,v.useRef)(!0),y=(0,v.useRef)(0),b=(0,v.useRef)(0),x=(0,v.useRef)(new Map),S=(0,v.useCallback)(SA,[]),C=(0,v.useCallback)(async(e={})=>{let n=++y.current;try{let[r,i]=await Promise.all([jg(),Mg().catch(()=>void 0)]),o=rD(i,r.gatewayInstanceRef),c=!1;if(n>=b.current){b.current=n,u.current=r,t(r);let p=g.current;p!==null&&p!==r.gatewayInstanceRef&&(_.current=!0),g.current=r.gatewayInstanceRef;let m=e.requireLiveState||_.current,h=d.current?.readyState===WebSocket.OPEN;if(a(iD(h,m)),!h&&i&&o!==null)f.current=o,S(r.gatewayInstanceRef,o),s(e=>_D(e,i)),l(fD(i)),_.current=!1,c=!0;else if(p!==r.gatewayInstanceRef){if(l({}),m)f.current=null;else{let e=null;try{e=window.sessionStorage.getItem(gA)}catch{}f.current=xA(e,r.gatewayInstanceRef)}}}return e.requireLiveState&&!c?void 0:u.current??r}catch{a(`reconnecting`);return}},[S]),w=(0,v.useCallback)(e=>{let t=d.current;if(!t||t.readyState!==WebSocket.OPEN)return Promise.reject(new KA(`gateway-not-connected`,!1));let n=CA(`request`);return new Promise((r,i)=>{let a=window.setTimeout(()=>{x.current.delete(n)&&i(new KA(`gateway-command-response-timeout`,!0))},_A);x.current.set(n,{resolve:r,reject:i,timeout:a});try{t.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`request`,requestId:n,method:`sessions.command`,params:{command:e}}))}catch(e){window.clearTimeout(a),x.current.delete(n),i(new KA(e instanceof Error?e.message:`gateway-request-failed`,!1))}})},[]),T=(0,v.useCallback)((e,t,n,r,i,a)=>ej({sessionRef:e,message:t,requestedAt:n,afterSerial:r,priorOperationRef:i,messageRequestId:a,readLocalObservation:()=>h.current.get(e)}),[]),E=(0,v.useCallback)(async e=>{let t=u.current,n=e.message.trim(),r=e.messageRequestId??CA(`message`);if(!t?.catalogRevision)throw Error(`catalog-unavailable`);if(!n)throw Error(`message-empty`);let i=t=>{if(!t.catalogRevision)throw Error(`catalog-unavailable`);let i=new Date;return qA(w,{schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:CA(`command`),idempotencyKey:CA(`idempotency`),action:`session.create`,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:null,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:null,payload:{projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,message:n,messageRequestId:r,...e.permissionMode?{permissionMode:e.permissionMode}:{},...e.deferInitialMessage?{deferInitialMessage:!0}:{}}})},a=await i(t);if(wA(a)){let e=await C();e?.catalogRevision&&(a=await i(e))}if(!(a.phase===`uncertain`&&a.sessionRef)&&a.phase!==`settled`||!a.sessionRef)throw Error(a.error?.code??a.resultCode);let o=a.settledAt??a.requestedAt;return a.phase===`settled`&&!e.deferInitialMessage&&s(e=>{let t=e[a.sessionRef];return{...e,[a.sessionRef]:{...t??{assistant:``,attachments:[],activities:[],complete:!1,error:null},user:n,operationRef:a.operationRef,messageRequestId:r,abortable:!t?.complete&&!!a.operationRef,startedAt:t?.startedAt??o,lastEventAt:t?.lastEventAt??o}}}),await C(),a},[C,w]),D=(0,v.useCallback)(async(e,t,n)=>{let r=u.current;if(!r?.catalogRevision)throw Error(`catalog-unavailable`);let i=t.trim();if(!i)throw Error(`message-empty`);let a=n?.messageRequestId??CA(`message`),o=n?.attachmentRefs??[],c=p.current[e.sessionRef],l=m.current,d=h.current.get(e.sessionRef)?.operationRef??c?.operationRef??null,f=new Date().toISOString();s(t=>({...t,[e.sessionRef]:mD(t[e.sessionRef],{message:i,attachments:n?.attachments??[],messageRequestId:a,submittedAt:f})}));let g=()=>s(t=>{let n=t[e.sessionRef],r=gD(n,c,a);if(r===n)return t;let i={...t};return r?i[e.sessionRef]=r:delete i[e.sessionRef],i}),_=(t,n)=>s(r=>$A(r,e.sessionRef,a,t,n)),v=f,y=!1;try{let t=t=>{let r=t.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t.catalogRevision||!r)throw Error(`session-unavailable`);let s=new Date;return v=s.toISOString(),{schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:CA(`command`),idempotencyKey:CA(`idempotency`),action:`session.send`,requestedAt:s.toISOString(),expiresAt:new Date(s.getTime()+vA).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:r.sessionRevision,payload:{delivery:`new-operation`,message:i,messageRequestId:a,expectedOperationRef:null,attachmentRefs:o,...n?.workflow?{workflow:n.workflow}:{}}}},s=t(r);y=!0;let c=await w(s);if(wA(c)){let e=await C();e?.catalogRevision&&(s=t(e),c=await w(s))}if(ZA(c,null)===`confirmed`)return _({operationRef:c.operationRef,complete:!1},`admitted`),C(),{state:`confirmed`,receipt:c};let u=await T(e.sessionRef,i,v,l,d,a),f=ZA(c,u);if(f===`observed`&&u)return _(u,`admitted`),C(),{state:`observed`,receipt:c};if(f===`unconfirmed`)return _({operationRef:null,complete:!0},`unconfirmed`),C(),{state:`unconfirmed`,receipt:c};throw g(),new bA(c.error?.code??c.resultCode)}catch(t){if(t instanceof bA)throw t;if(JA(t,y)){let t=await T(e.sessionRef,i,v,l,d,a);return ZA(null,t)===`observed`&&t?(_(t,`admitted`),C(),{state:`observed`,receipt:null}):(_({operationRef:null,complete:!0},`unconfirmed`),C(),{state:`unconfirmed`,receipt:null})}throw g(),t}},[T,C,w]),O=(0,v.useCallback)(async e=>{let t=u.current,n=o[e.sessionRef]?.operationRef,r=t?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t?.catalogRevision||!r||!n||o[e.sessionRef]?.abortable===!1)throw Error(`operation-unavailable`);let i=t=>{let r=t.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t.catalogRevision||!r)throw Error(`operation-unavailable`);let i=new Date;return w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:CA(`command`),idempotencyKey:CA(`idempotency`),action:`session.abort`,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:r.sessionRevision,payload:{operationRef:n,clearQueued:!0}})},a=await i(t);if(wA(a)){let[t,r]=await Promise.all([C(),Mg().catch(()=>void 0)]);if(!t||!SD(r,t.gatewayInstanceRef,e.sessionRef,n))throw Error(`operation-unavailable`);a=await i(t)}if(a.phase!==`settled`)throw Error(a.error?.code??a.resultCode);return C(),a},[o,C,w]),k=(0,v.useCallback)(async e=>{let t=async t=>{let n=await C(),r=n?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n?.catalogRevision||!r)throw Error(`session-unavailable`);let i=new Date,a=await w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:CA(`command`),idempotencyKey:CA(`idempotency`),action:t,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:n.catalogRevision,expectedSessionRevision:r.sessionRevision,payload:{}});if(a.phase!==`settled`)throw Error(a.error?.code??a.resultCode);return a};s(t=>({...t,[e.sessionRef]:{...t[e.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:null,complete:!0,error:null},runtimeRecovery:`restarting`}}));try{let n=(await C())?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n)throw Error(`session-unavailable`);n.state===`gateway-owned`&&await t(`session.release`);let r=await t(`session.acquire`);return s(t=>({...t,[e.sessionRef]:{...t[e.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:null,complete:!0,error:null},runtimeRecovery:`recovered`}})),await C(),r}catch(t){throw s(t=>({...t,[e.sessionRef]:{...t[e.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:null,complete:!0,error:null},runtimeRecovery:`failed`}})),t}},[C,w]),A=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:CA(`command`),idempotencyKey:CA(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await C(),o},[C,w]),j=(0,v.useCallback)((e,t)=>A(e,`session.set-model`,{modelRef:t}),[A]),M=(0,v.useCallback)((e,t)=>A(e,`session.set-thinking`,{thinkingLevel:t}),[A]),N=(0,v.useCallback)((e,t)=>A(e,`session.set-permission`,{permissionMode:t}),[A]),P=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:CA(`command`),idempotencyKey:CA(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await C(),o},[C,w]),F=(0,v.useCallback)((e,t)=>P(e,`session.rename`,{title:t}),[P]),I=(0,v.useCallback)((e,t)=>P(e,`session.pin`,{pinned:t}),[P]),L=(0,v.useCallback)(e=>P(e,`session.archive`,{}),[P]),R=(0,v.useCallback)(e=>P(e,`session.unarchive`,{}),[P]),ee=(0,v.useCallback)((e,t)=>P(e,`session.fork`,{entryRef:null,title:t}),[P]);return(0,v.useEffect)(()=>{let e=!1,t,n=0,i=!1,o=GA(()=>C()),c=o.request,p=(()=>{try{let e=window.localStorage.getItem(`piagent-gateway-client-ref`);if(e&&/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(e))return e;let t=CA(`client`);return window.localStorage.setItem(`piagent-gateway-client-ref`,t),t}catch{return CA(`client`)}})(),v=()=>{if(e||Eg())return;a(n===0?`connecting`:`reconnecting`);let o=window.location.protocol===`https:`?`wss:`:`ws:`,b=new WebSocket(`${o}//${window.location.host}/api/v1/gateway`,`piagent.gateway.v1`);d.current=b;let C=window.setTimeout(()=>b.close(1008,`hello-timeout`),5e3);b.addEventListener(`open`,()=>b.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`connect`,clientRef:p,minimumProtocol:1,maximumProtocol:1,lastEventSequence:f.current,catalogRevision:u.current?.catalogRevision??null}))),b.addEventListener(`message`,e=>{let t;try{t=JSON.parse(String(e.data))}catch{b.close(1007,`invalid-json`);return}if(!t||typeof t!=`object`){b.close(1008,`invalid-frame`);return}let o=t;if(o.messageType===`hello`){window.clearTimeout(C);let e=typeof o.capabilities?.gatewayInstanceRef==`string`?o.capabilities.gatewayInstanceRef:null;if(!e||g.current&&e!==g.current){f.current=null,_.current=!0,i=!0,b.close(yA,`gateway-epoch-changed`);return}g.current=e,n=0,r(o.capabilities),a(`connected`);return}if(o.messageType===`response`){let e=x.current.get(String(o.requestId));if(!e)return;x.current.delete(String(o.requestId)),window.clearTimeout(e.timeout),o.ok===!0&&o.result?e.resolve(o.result):e.reject(new KA(String(o.error?.code??`gateway-request-failed`),!1));return}if(o.messageType!==`event`||!Number.isSafeInteger(o.sequence))return;let u=o.payload,d=typeof o.generatedAt==`string`?o.generatedAt:new Date().toISOString(),p=typeof u.messageRequestId==`string`?u.messageRequestId:null,v=e=>e&&p&&e.messageRequestId&&e.messageRequestId!==p?void 0:e;if(o.kind===`resync.required`){_.current=!0,i=!0,b.close(yA,`canonical-resync-required`);return}let y=Number(o.sequence),w=f.current;if(!(w!==null&&y<=w)){if(w!==null&&y!==w+1){_.current=!0,i=!0,b.close(yA,`gateway-event-sequence-gap`);return}if(f.current=y,g.current&&S(g.current,y),typeof u?.sessionRef==`string`&&typeof u.operationRef==`string`&&[`runtime.changed`,`message.delta`,`tool.started`,`tool.completed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&(m.current+=1,h.current.set(u.sessionRef,{serial:m.current,operationRef:u.operationRef,messageRequestId:p,complete:[`message.completed`,`operation.settled`].includes(String(o.kind))})),o.kind===`message.delta`&&typeof u?.sessionRef==`string`&&typeof u.delta==`string`&&s(e=>{let t=v(e[u.sessionRef]);return{...e,[u.sessionRef]:{...t??{user:``,assistant:``,attachments:[],activities:[],complete:!1,error:null},operationRef:u.operationRef,messageRequestId:p??t?.messageRequestId,abortable:!0,complete:!1,delivery:t?.user?`admitted`:t?.delivery,assistant:`${t?.assistant??``}${u.delta}`,startedAt:t?.startedAt??d,lastEventAt:d}}}),[`tool.started`,`tool.completed`].includes(String(o.kind))&&typeof u?.sessionRef==`string`&&typeof u.toolCallRef==`string`&&typeof u.toolLabel==`string`&&s(e=>{let t=v(e[u.sessionRef])??{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef??null,abortable:!0,complete:!1,error:null,runtimeRecovery:null},n=o.kind===`tool.started`?`running`:u.isError===!0?`failed`:`completed`,r=t.activities.find(e=>e.toolCallRef===u.toolCallRef),i=[...t.activities.filter(e=>e.toolCallRef!==u.toolCallRef),{toolCallRef:u.toolCallRef,toolLabel:u.toolLabel,fileLabel:typeof u.fileLabel==`string`?u.fileLabel:r?.fileLabel??null,state:n,reasonCode:u.reasonCode??null,startedAt:r?.startedAt??d,finishedAt:n===`running`?null:d}].slice(-16),a=u.reasonCode===`runtime-restart-required`?`required`:t.runtimeRecovery;return{...e,[u.sessionRef]:{...t,operationRef:u.operationRef??t.operationRef,messageRequestId:p??t.messageRequestId,activities:i,complete:!1,delivery:t.user?`admitted`:t.delivery,runtimeRecovery:a,startedAt:t.startedAt??d,lastEventAt:d}}}),o.kind===`runtime.changed`&&typeof u?.sessionRef==`string`&&s(e=>{let t=[`running`,`paused`,`waiting-approval`].includes(String(u.liveState)),n=v(e[u.sessionRef])??(t&&typeof u.operationRef==`string`?{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef,messageRequestId:p,abortable:!0,complete:!1,settlement:null,error:null,runtimeRecovery:null}:null);if(!n)return e;let r=u.reasonCode===`runtime-restart-required`?`restarting`:u.reasonCode===`runtime-restart-failed`?`failed`:[`required`,`restarting`].includes(String(n.runtimeRecovery))&&u.liveState===`idle`?`recovered`:n.runtimeRecovery;return t?{...e,[u.sessionRef]:{...n,operationRef:u.operationRef??n.operationRef,messageRequestId:p??n.messageRequestId,abortable:!0,complete:!1,settlement:null,delivery:n.user?`admitted`:n.delivery,runtimeRecovery:r,startedAt:n.startedAt??d,lastEventAt:d}}:!n.complete&&u.operationRef===null?{...e,[u.sessionRef]:{...n,assistant:``,activities:[],abortable:!1,complete:!0,settlement:`unknown`,messageRequestId:p??n.messageRequestId,error:u.reasonCode??`operation-settlement-unknown`,runtimeRecovery:r,lastEventAt:d}}:r===n.runtimeRecovery?e:{...e,[u.sessionRef]:{...n,runtimeRecovery:r}}}),o.kind===`message.completed`&&typeof u?.sessionRef==`string`&&s(e=>{let t=v(e[u.sessionRef]);return{...e,[u.sessionRef]:{...t??{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef,error:null},operationRef:u.operationRef,messageRequestId:p??t?.messageRequestId,abortable:!1,complete:!0,settlement:`completed`,delivery:t?.user?`admitted`:t?.delivery,error:null,lastEventAt:d}}}),o.kind===`operation.settled`&&typeof u?.sessionRef==`string`&&typeof u.operationRef==`string`){s(e=>{let t=v(e[u.sessionRef])??{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef,complete:!1,error:null,runtimeRecovery:null};return t.operationRef&&t.operationRef!==u.operationRef?e:{...e,[u.sessionRef]:{...pD(t,{operationRef:u.operationRef,settlement:u.settlement,reasonCode:u.reasonCode}),messageRequestId:p??t.messageRequestId,lastEventAt:d}}});let e=uD({operationRef:u.operationRef,settlement:u.settlement,reasonCode:u.reasonCode,settledAt:o.generatedAt,sequence:y});e&&l(t=>({...t,[u.sessionRef]:dD(t[u.sessionRef]??[],[e])}))}[`catalog.changed`,`session.changed`,`runtime.changed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&c()}}),b.addEventListener(`close`,()=>{window.clearTimeout(C);for(let e of x.current.values())window.clearTimeout(e.timeout),e.reject(new KA(`gateway-connection-lost`,!0));if(x.current.clear(),!e){if(a(`reconnecting`),i){i=!1,y();return}n+=1,t=window.setTimeout(v,Math.min(5e3,250*2**Math.min(n,5)))}}),b.addEventListener(`error`,()=>{})},y=async()=>{if(e||Eg())return;let r=await C({requireLiveState:!0});if(!e){if(r){n=0,v();return}a(`reconnecting`),n+=1,t=window.setTimeout(()=>void y(),Math.min(5e3,250*2**Math.min(n,5)))}};(async()=>{let t=await Sg();if(!e){if(t===`failed`){a(`failed`);return}await y()}})();let b=()=>{!e&&document.visibilityState===`visible`&&C()};return document.addEventListener(`visibilitychange`,b),()=>{e=!0,t&&window.clearTimeout(t),o.stop();for(let e of x.current.values())window.clearTimeout(e.timeout),e.reject(new KA(`gateway-client-unmounted`,!0));x.current.clear(),d.current?.close(1e3,`client-unmount`),document.removeEventListener(`visibilitychange`,b)}},[S,C]),{catalog:e,capabilities:n,connection:i,live:o,terminalActivities:c,refresh:C,create:E,send:D,abort:O,restart:k,setModel:j,setThinking:M,setPermission:N,rename:F,pin:I,archive:L,unarchive:R,fork:ee}}var nj=document.getElementById(`root`);if(!nj)throw Error(`Piagent WebUI root is missing`);var rj=document.querySelector(`meta[name="csp-nonce"]`)?.content,ij=We({key:`piagent-mui`,nonce:rj&&!rj.startsWith(`__PIAGENT_`)?rj:void 0,prepend:!0});function aj(){let e=WA();return(0,U.jsx)(KS,{...e})}function oj(){let e=tj();return(0,U.jsx)(jE,{children:(0,U.jsx)(MA,{...e})})}function sj(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function cj(){let[e,t]=(0,v.useState)(()=>sj(`piagent-webui-locale`,[`vi`,`en`],PA(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,v.useState)(()=>sj(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)),i=(0,v.useMemo)(()=>NA(n),[n]);(0,v.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=n;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,n)}catch{}},[n,e]);let a=(0,v.useMemo)(()=>({locale:e,colorMode:n,setLocale:t,setColorMode:r}),[n,e]),o=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,U.jsx)(Wv,{value:a,children:(0,U.jsxs)(Dc,{theme:i,children:[(0,U.jsx)(is,{}),o===`gateway`?(0,U.jsx)(oj,{}):(0,U.jsx)(aj,{})]})})}(0,y.createRoot)(nj).render((0,U.jsx)(v.StrictMode,{children:(0,U.jsx)(gt,{value:ij,children:(0,U.jsx)(cj,{})})}));export{l as S,Cr as _,Pc as a,o as b,ys as c,Go as d,ba as f,W as g,Gr as h,J as i,Xo as l,Kr as m,Du as n,Ac as o,Ci as p,ul as r,q as s,X as t,K as u,mn as v,s as x,d as y};
|
|
227
|
+
`,Tk=typeof wk==`string`?null:Et`
|
|
228
|
+
animation: ${wk} 3s infinite linear;
|
|
229
|
+
`,Ek=e=>{let{classes:t,variant:n,color:r}=e;return ba({root:[`root`,`color${q(r)}`,n],dashed:[`dashed`],bar1:[`bar`,`bar1`],bar2:[`bar`,`bar2`,n===`buffer`&&`color${q(r)}`]},_k,t)},Dk=(e,t)=>e.vars?e.vars.palette.LinearProgress[`${t}Bg`]:e.palette.mode===`light`?e.lighten(e.palette[t].main,.62):e.darken(e.palette[t].main,.5),Ok=K(`span`,{name:`MuiLinearProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`color${q(n.color)}`],t[n.variant]]}})(ys(({theme:e})=>({position:`relative`,overflow:`hidden`,display:`block`,height:4,zIndex:0,"@media print":{colorAdjust:`exact`},variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{backgroundColor:Dk(e,t)}})),{props:({ownerState:e})=>e.color===`inherit`&&e.variant!==`buffer`,style:{"&::before":{content:`""`,position:`absolute`,left:0,top:0,right:0,bottom:0,backgroundColor:`currentColor`,opacity:.3}}},{props:{variant:`buffer`},style:{backgroundColor:`transparent`}},{props:{variant:`query`},style:{transform:`rotate(180deg)`}}]}))),kk=K(`span`,{name:`MuiLinearProgress`,slot:`Dashed`})(ys(({theme:e})=>({position:`absolute`,marginTop:0,height:`100%`,width:`100%`,backgroundSize:`10px 10px`,backgroundPosition:`0 -23px`,variants:[{props:{color:`inherit`},style:{opacity:.3,backgroundImage:`radial-gradient(currentColor 0%, currentColor 16%, transparent 42%)`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>{let n=Dk(e,t);return{props:{color:t},style:{backgroundImage:`radial-gradient(${n} 0%, ${n} 16%, transparent 42%)`}}})]})),Tk||{animation:`${wk} 3s infinite linear`},ys(({theme:e})=>Gs(e,{animation:`none`})||yk)),Ak=K(`span`,{name:`MuiLinearProgress`,slot:`Bar1`,overridesResolver:(e,t)=>[t.bar,t.bar1]})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`,left:`30%`,right:`auto`,width:`40%`});return{width:`100%`,position:`absolute`,left:0,bottom:0,top:0,...Ks(e,`transform`,{duration:`0.2s`,easing:`linear`}),transformOrigin:`left`,variants:[{props:{color:`inherit`},style:{backgroundColor:`currentColor`}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{backgroundColor:(e.vars||e).palette[t].main}})),{props:{variant:`determinate`},style:{...Ks(e,`transform`,{duration:`.${vk}s`,easing:`linear`})}},{props:{variant:`buffer`},style:{zIndex:1,...Ks(e,`transform`,{duration:`.${vk}s`,easing:`linear`})}},{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:{width:`auto`}},{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:xk||{animation:`${bk} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:t}]:[]]}})),jk=K(`span`,{name:`MuiLinearProgress`,slot:`Bar2`,overridesResolver:(e,t)=>[t.bar,t.bar2]})(ys(({theme:e})=>{let t=Gs(e,{animation:`none`,display:`none`});return{width:`100%`,position:`absolute`,left:0,bottom:0,top:0,...Ks(e,`transform`,{duration:`0.2s`,easing:`linear`}),transformOrigin:`left`,variants:[...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t},style:{"--LinearProgressBar2-barColor":(e.vars||e).palette[t].main}})),{props:({ownerState:e})=>e.variant!==`buffer`&&e.color!==`inherit`,style:{backgroundColor:`var(--LinearProgressBar2-barColor, currentColor)`}},{props:({ownerState:e})=>e.variant!==`buffer`&&e.color===`inherit`,style:{backgroundColor:`currentColor`}},{props:{color:`inherit`},style:{opacity:.3}},...Object.entries(e.palette).filter(Ac()).map(([t])=>({props:{color:t,variant:`buffer`},style:{backgroundColor:Dk(e,t),...Ks(e,`transform`,{duration:`.${vk}s`,easing:`linear`})}})),{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:{width:`auto`}},{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:Ck||{animation:`${Sk} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`||e.variant===`query`,style:t}]:[]]}})),Mk=v.forwardRef(function(e,t){let n=Xo({props:e,name:`MuiLinearProgress`}),{className:r,color:i=`primary`,max:a,min:o,value:s,valueBuffer:c,variant:l=`indeterminate`,...u}=n,d={...n,color:i,variant:l},f=o??0,p=a??100,m=Ek(d),h=Ri(),g={},_={bar1:{},bar2:{}};if((l===`determinate`||l===`buffer`)&&s!==void 0){let e=p-f,t=(s-f)/e*100-100;h&&(t=-t),_.bar1.transform=e>0?`translateX(${t}%)`:`translateX(-100%)`,g[`aria-valuenow`]=s,g[`aria-valuemin`]=f,g[`aria-valuemax`]=p}if(l===`buffer`&&c!==void 0){let e=p-f,t=(c-f)/e*100-100;h&&(t=-t),_.bar2.transform=e>0?`translateX(${t}%)`:`translateX(-100%)`}return(0,U.jsxs)(Ok,{className:W(m.root,r),ownerState:d,role:`progressbar`,...g,ref:t,...u,children:[l===`buffer`?(0,U.jsx)(kk,{className:m.dashed,ownerState:d}):null,(0,U.jsx)(Ak,{className:m.bar1,ownerState:d,style:_.bar1}),l===`determinate`?null:(0,U.jsx)(jk,{className:m.bar2,ownerState:d,style:_.bar2})]})}),Nk=`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,Pk={A:`success`,M:`warning`,D:`error`,R:`info`,C:`info`,U:`success`};function Fk({title:e,action:t,children:n}){return(0,U.jsxs)(J,{component:`section`,sx:{px:2,py:1.75,borderBottom:1,borderColor:`divider`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,mb:1},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,sx:{fontWeight:650,textTransform:`uppercase`,letterSpacing:`.06em`},children:e}),t]}),n]})}function Ik({session:e,snapshot:t,live:n,locale:r,onOpenReview:i,onClose:a}){let[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(!1),u=!!(n&&!n.complete);(0,v.useEffect)(()=>{if(u)return;let t=new AbortController;l(!1);let n=window.setTimeout(()=>void Yg(e.sessionRef,`working-tree`,t.signal).then(e=>s(e)).catch(()=>{t.signal.aborted||l(!0)}),250);return()=>{window.clearTimeout(n),t.abort()}},[e.sessionRef,e.sessionRevision,u]),(0,v.useEffect)(()=>{s(void 0)},[e.sessionRef]);let d=o?.files??[],f=d.reduce((e,t)=>e+(t.stats?.additions??0),0),p=d.reduce((e,t)=>e+(t.stats?.deletions??0),0),m=t?.usage.context,h=m?.state===`known`,g=h?m.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,_=h?m.contextWindow:e.contextUsage.contextWindow,y=h?m.tokens:e.contextUsage.usedTokens,b=e.managedHelpers?.maximum===0?void 0:e.managedHelpers,x=e.managedPlan,S=e.managedProcess,C=x?.steps.filter(e=>e.status===`completed`).length??0,w=(n?.activities??[]).filter(e=>eO(e.toolLabel)===`subagent`);return(0,U.jsxs)(J,{role:`region`,sx:{height:`100%`,overflowY:`auto`,bgcolor:`background.paper`},"aria-label":Q(r,`Thay đổi và ngữ cảnh`,`Changes and context`),children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1,px:2,minHeight:60,borderBottom:1,borderColor:`divider`},children:[(0,U.jsx)(X,{sx:{fontWeight:600,flex:1},children:Q(r,`Workspace`,`Workspace`)}),a&&(0,U.jsx)(Qd,{size:`small`,"aria-label":Q(r,`Đóng khung bên`,`Close side panel`),onClick:a,children:(0,U.jsx)(YE,{fontSize:`small`})})]}),(0,U.jsxs)(Fk,{title:o?Q(r,`Thay đổi · ${d.length} file`,`Changes · ${d.length} files`):Q(r,`Thay đổi`,`Changes`),action:d.length>0?(0,U.jsx)(Ah,{title:Q(r,`Xem diff đầy đủ, stage hoặc hoàn tác`,`Full diff, stage or revert`),children:(0,U.jsx)($,{size:`small`,startIcon:(0,U.jsx)(Ph,{fontSize:`small`}),onClick:i,children:Q(r,`Review`,`Review`)})}):void 0,children:[(f>0||p>0)&&(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:.75,mb:1,color:`text.secondary`},children:[(0,U.jsx)(BD,{sx:{fontSize:15}}),(0,U.jsx)(X,{variant:`caption`,children:Q(r,`Chưa commit`,`Uncommitted`)}),(0,U.jsxs)(X,{variant:`caption`,sx:{fontFamily:Nk,ml:`auto`},children:[(0,U.jsxs)(J,{component:`span`,sx:YD(`success`),children:[`+`,f]}),` `,(0,U.jsxs)(J,{component:`span`,sx:YD(`error`),children:[`−`,p]})]})]}),o===void 0&&!c&&(u?(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(r,`Cập nhật khi lượt này chạy xong.`,`Updates when this turn finishes.`)}):(0,U.jsx)(Mk,{sx:{borderRadius:1}})),(c||o?.availability.state===`unavailable`)&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(r,`Chưa đọc được thay đổi (thư mục có thể không phải git repo).`,`Changes are unavailable (the folder may not be a git repository).`)}),o&&o.availability.state!==`unavailable`&&d.length===0&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:Q(r,`Chưa có thay đổi nào chưa commit.`,`No uncommitted changes.`)}),(0,U.jsx)(Z,{spacing:.25,children:d.slice(0,200).map(e=>(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1,py:.4},children:[(0,U.jsx)(X,{variant:`caption`,sx:{fontFamily:Nk,fontWeight:700,width:12,...Pk[e.status]?YD(Pk[e.status]):{color:`text.secondary`}},children:e.status}),(0,U.jsx)(X,{variant:`body2`,noWrap:!0,title:e.path,sx:{fontFamily:Nk,fontSize:12.5,flex:1,minWidth:0},children:e.path}),(0,U.jsxs)(X,{variant:`caption`,sx:{fontFamily:Nk,flexShrink:0},children:[(e.stats?.additions??0)>0&&(0,U.jsxs)(J,{component:`span`,sx:YD(`success`),children:[`+`,e.stats.additions,` `]}),(e.stats?.deletions??0)>0&&(0,U.jsxs)(J,{component:`span`,sx:YD(`error`),children:[`−`,e.stats.deletions]})]})]},e.fileRef))})]}),(x||S)&&(0,U.jsxs)(Fk,{title:x?Q(r,`Plan · ${C}/${x.steps.length}`,`Plan · ${C}/${x.steps.length}`):Q(r,`Tiến trình`,`Process`),children:[x&&(0,U.jsx)(Z,{component:`ol`,spacing:.25,sx:{m:0,p:0,listStyle:`none`},"aria-label":Q(r,`Plan của agent`,`Agent plan`),children:x.steps.map((e,t)=>{let n=e.status===`completed`?mk:e.status===`in_progress`?hk:e.status===`deferred`?gk:pk;return(0,U.jsxs)(Z,{component:`li`,direction:`row`,sx:{alignItems:`flex-start`,gap:.75,py:.25},"aria-label":`${e.step}: ${e.status===`completed`?Q(r,`xong`,`done`):e.status===`in_progress`?Q(r,`đang làm`,`in progress`):e.status===`deferred`?Q(r,`để sau`,`left for later`):Q(r,`chưa làm`,`pending`)}`,children:[(0,U.jsx)(n,{sx:{fontSize:16,mt:.2,color:e.status===`in_progress`?`primary.main`:`text.secondary`}}),(0,U.jsx)(X,{variant:`body2`,sx:{flex:1,minWidth:0,overflowWrap:`anywhere`,...e.status===`completed`?{color:`text.secondary`,textDecoration:`line-through`}:e.status===`deferred`?{color:`text.disabled`,fontStyle:`italic`}:{},...e.status===`in_progress`?{fontWeight:600}:{}},children:e.step})]},t)})}),S&&S.outcome!==`no_change`&&(0,U.jsxs)(X,{variant:`body2`,role:`status`,sx:{mt:+!!x,...YD(hO(S))},children:[Q(r,`Lượt sửa code gần nhất: `,`Last code-changing turn: `),pO(S,r)]})]}),(0,U.jsxs)(Fk,{title:Q(r,`Ngữ cảnh`,`Context`),children:[(0,U.jsxs)(Z,{direction:`row`,sx:{justifyContent:`space-between`,mb:.75},children:[(0,U.jsx)(X,{variant:`body2`,children:g==null?`—`:`${Math.round(g)}%`}),(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,children:[y?jD(y):`—`,_?` / ${jD(_)}`:``]})]}),(0,U.jsx)(Mk,{variant:`determinate`,value:Math.min(100,Math.max(0,g??0)),sx:{height:6,borderRadius:3},color:(g??0)>85?`warning`:`primary`,"aria-label":Q(r,`Mức dùng ngữ cảnh`,`Context usage`)})]}),(b||w.length>0)&&(0,U.jsxs)(Fk,{title:`Subagent`,children:[b&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:w.length?.75:0},children:Q(r,`${b.active??0}/${b.maximum} đang chạy`,`${b.active??0}/${b.maximum} running`)}),w.map(e=>(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:.75,py:.25},children:[(0,U.jsx)(LD,{sx:{fontSize:15,color:`text.secondary`}}),(0,U.jsx)(X,{variant:`body2`,sx:{flex:1},children:e.fileLabel??`subagent`}),(0,U.jsx)(X,{variant:`caption`,color:e.state===`failed`?`error`:`text.secondary`,children:e.state===`running`?Q(r,`đang chạy`,`running`):e.state===`failed`?Q(r,`lỗi`,`failed`):Q(r,`xong`,`done`)})]},e.toolCallRef))]})]})}var Lk=Y((0,U.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`),Rk=Y((0,U.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 zk({catalog:e,refresh:t}){let{locale:n}=Kv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!r||r.state!==`running`)return;let e=new AbortController,a=window.setTimeout(()=>{Ig(r.jobRef,e.signal).then(e=>{i(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||u(Q(n,`Mất kết nối với luồng OAuth`,`OAuth flow disconnected`))})},750);return()=>{e.abort(),window.clearTimeout(a)}},[r?.jobRef,r?.generatedAt,r?.state,n]),(0,v.useEffect)(()=>o(``),[r?.prompt?.promptRef]);let d=async e=>{c(!0),u(null);try{i(await Rg(e))}catch{u(Q(n,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{c(!1)}},f=async()=>{if(!(!r?.prompt||!a)){c(!0),u(null);try{i(await zg(r.jobRef,r.prompt.promptRef,a))}catch{u(Q(n,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{c(!1)}}},p=async()=>{r?.state===`running`&&await Bg(r.jobRef).catch(()=>void 0),i(void 0),u(null)},m=r?.events.slice(-4)??[];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,U.jsx)(Pc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,U.jsx)(Mw,{name:e.name,size:38}),(0,U.jsx)(X,{sx:{flex:1,fontWeight:800},children:e.name}),e.state===`connected`&&(0,U.jsx)(lu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,U.jsx)(Rk,{}),label:Q(n,`Đã kết nối`,`Connected`)}),(0,U.jsx)($,{size:`small`,variant:`outlined`,disabled:s,onClick:()=>void d(e.providerRef),children:e.state===`connected`?Q(n,`Kết nối lại`,`Reconnect`):Q(n,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(n,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),l&&!r&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:l}),(0,U.jsxs)(BC,{open:!!r,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,U.jsx)(qw,{children:r?.providerName??`OAuth`}),(0,U.jsx)(Ww,{children:(0,U.jsxs)(Z,{spacing:1.25,sx:{pt:.5},children:[r?.state===`completed`&&(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsx)(Rk,{color:`success`}),(0,U.jsx)(X,{children:Q(n,`Đã kết nối`,`Connected`)})]}),m.map(e=>(0,U.jsxs)(J,{children:[e.message&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,U.jsx)(X,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:800,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,U.jsx)($,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,U.jsx)(Pw,{}),children:Q(n,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,U.jsx)($,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??Q(n,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),r?.prompt&&(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{variant:`body2`,sx:{mb:1},children:r.prompt.message}),r.prompt.type===`select`?(0,U.jsx)(ox,{fullWidth:!0,size:`small`,value:a,onChange:e=>o(e.target.value),children:r.prompt.options.map(e=>(0,U.jsx)(xw,{value:e.id,children:e.label},e.id))}):(0,U.jsx)(dx,{fullWidth:!0,size:`small`,value:a,placeholder:r.prompt.placeholder??void 0,onChange:e=>o(e.target.value)})]}),r&&[`failed`,`cancelled`].includes(r.state)&&(0,U.jsx)(X,{color:`error`,variant:`body2`,children:Iv(r.reasonCode??r.state,n)}),l&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`body2`,children:l})]})}),(0,U.jsxs)(Rw,{children:[(0,U.jsx)($,{color:`inherit`,onClick:()=>void p(),children:r?.state===`running`?Q(n,`Hủy`,`Cancel`):Q(n,`Đóng`,`Close`)}),r?.prompt&&(0,U.jsx)($,{variant:`contained`,disabled:s||!a,onClick:()=>void f(),children:Q(n,`Tiếp tục`,`Continue`)})]})]})]})}var Bk=Y((0,U.jsx)(`path`,{d:`M10.67 21c-.35 0-.62-.31-.57-.66L11 14H7.5c-.88 0-.33-.75-.31-.78 1.26-2.23 3.15-5.53 5.65-9.93.1-.18.3-.29.5-.29.35 0 .62.31.57.66l-.9 6.34h3.51c.4 0 .62.19.4.66-3.29 5.74-5.2 9.09-5.75 10.05-.1.18-.29.29-.5.29`}),`BoltRounded`),Vk=Y((0,U.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`),Hk=Y((0,U.jsx)(`path`,{d:`M14 9h-4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1h4c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1m-1 4h-2v-2h2zm8-3c0-.55-.45-1-1-1h-1V7c0-1.1-.9-2-2-2h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v1h-2V4c0-.55-.45-1-1-1s-1 .45-1 1v1H7c-1.1 0-2 .9-2 2v2H4c-.55 0-1 .45-1 1s.45 1 1 1h1v2H4c-.55 0-1 .45-1 1s.45 1 1 1h1v2c0 1.1.9 2 2 2h2v1c0 .55.45 1 1 1s1-.45 1-1v-1h2v1c0 .55.45 1 1 1s1-.45 1-1v-1h2c1.1 0 2-.9 2-2v-2h1c.55 0 1-.45 1-1s-.45-1-1-1h-1v-2h1c.55 0 1-.45 1-1m-5 7H8c-.55 0-1-.45-1-1V8c0-.55.45-1 1-1h8c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1`}),`MemoryRounded`),Uk=Y([(0,U.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,U.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`),Wk=Y((0,U.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 Gk({icon:e,title:t,detail:n,children:r}){return(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,U.jsx)(J,{sx:{width:38,height:38,borderRadius:2,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{sx:{fontWeight:820},children:t}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function Kk({children:e}){return(0,U.jsx)(Z,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function qk({session:e,options:t,connections:n,onCompleted:r}){let{locale:i}=Kv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(e?.sessionRevision??``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``);(0,v.useEffect)(()=>{f(e?.sessionRevision??``),c(void 0),u(null)},[e?.sessionRef]),(0,v.useEffect)(()=>{e?.sessionRevision&&f(e.sessionRevision)},[e?.sessionRevision]);let w=a||!e||!d||e.liveState===`running`||e.liveState===`waiting-approval`,T=t?.profiles??[],E=(0,v.useMemo)(()=>(n?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[n]),D=s?.outputs.find(e=>e.customType===`piagent-service-tier-receipt`)?.details,O=async(t,n=null,a=!1)=>{if(!(!e||!d)){o(!0),u(null);try{let i=await a_({schemaVersion:1,version:`piagent-runtime-command-v1`,messageType:`command`,requestId:`runtime_${crypto.randomUUID().replaceAll(`-`,`_`)}`,sessionRef:e.sessionRef,expectedSessionRevision:d,action:t,argument:n,confirmed:a});c(i),i.sessionRevisionAfter&&f(i.sessionRevisionAfter),i.state!==`settled`&&u(i.reasonCode??i.resultCode),await r?.()}catch{u(Q(i,`Gateway chưa thể chạy điều khiển này.`,`The Gateway could not run this control.`))}finally{o(!1)}}},k=(e,t,n,r)=>m({action:e,argument:t,title:n,description:r}),A={size:`small`,variant:`outlined`,disabled:w};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:.75},children:Q(i,`Điều khiển project`,`Project controls`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{mb:2.5},children:Q(i,`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,U.jsx)(Pc,{variant:`outlined`,sx:{p:2,borderRadius:2.5,mb:2},children:(0,U.jsx)(X,{color:`text.secondary`,children:Q(i,`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,U.jsxs)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,U.jsxs)(Gk,{icon:(0,U.jsx)(Wk,{color:`primary`}),title:Q(i,`Runtime & token`,`Runtime & tokens`),detail:Q(i,`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,U.jsxs)(Kk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`runtime.status`),children:`Pi status`}),(0,U.jsx)($,{...A,onClick:()=>void O(`runtime.inspector`),children:`Inspector`}),(0,U.jsx)($,{...A,onClick:()=>void O(`orchestration.status`),children:`Orchestration`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.live`),children:`Usage live`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.history`),children:`History`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.logs`),children:`Logs`}),(0,U.jsx)($,{...A,onClick:()=>void O(`usage.efficiency`),children:`Efficiency`})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(dx,{size:`small`,fullWidth:!0,label:Q(i,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:b,onChange:e=>x(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,U.jsx)($,{...A,sx:{whiteSpace:`nowrap`},onClick:()=>void O(`usage.preflight`,b.trim()||null),children:`Preflight`})]})]}),(0,U.jsx)(Gk,{icon:(0,U.jsx)(Bk,{color:`primary`}),title:Q(i,`Fast mode`,`Fast mode`),detail:Q(i,`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,U.jsxs)(Kk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`runtime.fast-status`),children:Q(i,`Trạng thái`,`Status`)}),(0,U.jsx)($,{...A,color:`primary`,onClick:()=>k(`runtime.fast-on`,null,Q(i,`Bật Fast mode?`,`Enable Fast mode?`),Q(i,`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:Q(i,`Bật Fast`,`Enable Fast`)}),(0,U.jsx)($,{...A,onClick:()=>k(`runtime.fast-off`,null,Q(i,`Tắt Fast mode?`,`Disable Fast mode?`),Q(i,`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:Q(i,`Tắt Fast`,`Disable Fast`)})]})}),(0,U.jsxs)(Gk,{icon:(0,U.jsx)(Uk,{color:`primary`}),title:Q(i,`Profile`,`Profile`),detail:Q(i,`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,U.jsxs)(Kk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`profile.status`),children:Q(i,`Profile hiện tại`,`Current profile`)}),(0,U.jsx)($,{...A,onClick:()=>void O(`profile.options`),children:Q(i,`Danh sách profile`,`Profile options`)}),(0,U.jsx)($,{...A,onClick:()=>void O(`profile.tech-options`),children:Q(i,`Tech theo vai trò`,`Tech options`)})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(ox,{size:`small`,fullWidth:!0,displayEmpty:!0,value:h,onChange:e=>g(e.target.value),disabled:w,renderValue:e=>e?T.find(t=>t.id===e)?.displayName??e:Q(i,`Chọn profile…`,`Select profile…`),children:T.map(e=>(0,U.jsx)(xw,{value:e.id,children:e.displayName},e.id))}),(0,U.jsx)($,{...A,disabled:w||!h,sx:{whiteSpace:`nowrap`},onClick:()=>k(`profile.apply`,h,Q(i,`Áp dụng profile?`,`Apply profile?`),Q(i,`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:Q(i,`Áp dụng`,`Apply`)}),(0,U.jsx)($,{...A,onClick:()=>k(`profile.auto`,null,Q(i,`Tự nhận diện profile?`,`Auto-detect profile?`),Q(i,`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,U.jsxs)(Gk,{icon:(0,U.jsx)(Vk,{color:`primary`}),title:Q(i,`Context engine`,`Context engine`),detail:Q(i,`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,U.jsxs)(Kk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`context.status`),children:`Index status`}),(0,U.jsx)($,{...A,onClick:()=>void O(`context.efficiency`),children:`Efficiency`}),(0,U.jsx)($,{...A,onClick:()=>void O(`context.impact`),children:`Impact`}),(0,U.jsx)($,{...A,color:`warning`,onClick:()=>k(`context.rebuild`,null,Q(i,`Rebuild context index?`,`Rebuild context index?`),Q(i,`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,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(dx,{size:`small`,fullWidth:!0,label:Q(i,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:_,onChange:e=>y(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,U.jsx)($,{...A,disabled:w||!_.trim(),onClick:()=>void O(`context.search`,_.trim()),children:`Search`}),(0,U.jsx)($,{...A,disabled:w||!_.trim(),onClick:()=>void O(`context.pack`,_.trim()),children:`Pack`}),(0,U.jsx)($,{...A,color:`warning`,onClick:()=>k(`context.compact`,_.trim()||null,Q(i,`Compact context bằng model?`,`Compact context with the model?`),Q(i,`Đâ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,U.jsx)(Gk,{icon:(0,U.jsx)(Hk,{color:`primary`}),title:Q(i,`Memory`,`Memory`),detail:Q(i,`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,U.jsx)(Kk,{children:(0,U.jsx)($,{...A,onClick:()=>void O(`memory.status`),children:Q(i,`Kiểm tra memory`,`Check memory`)})})}),(0,U.jsxs)(Gk,{icon:(0,U.jsx)(aw,{color:`primary`}),title:Q(i,`MCP governance`,`MCP governance`),detail:Q(i,`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,U.jsxs)(Kk,{children:[(0,U.jsx)($,{...A,onClick:()=>void O(`mcp.status`),children:`MCP status`}),(0,U.jsx)($,{...A,onClick:()=>void O(`mcp.doctor`),children:`Doctor`})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,U.jsx)(ox,{size:`small`,fullWidth:!0,displayEmpty:!0,value:S,onChange:e=>C(e.target.value),disabled:w,renderValue:e=>e||Q(i,`Chọn MCP…`,`Select MCP…`),children:E.map(e=>(0,U.jsx)(xw,{value:e.name,children:e.name},e.connectionRef))}),(0,U.jsx)($,{...A,disabled:w||!S,onClick:()=>void O(`mcp.detail`,S),children:`Detail`}),(0,U.jsx)($,{...A,disabled:w||!S,onClick:()=>k(`mcp.approve`,S,Q(i,`Phê duyệt MCP?`,`Approve MCP?`),Q(i,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,U.jsx)($,{...A,disabled:w||!S,color:`warning`,onClick:()=>k(`mcp.reject`,S,Q(i,`Từ chối MCP?`,`Reject MCP?`),Q(i,`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,U.jsx)($,{...A,disabled:w||!S,color:`warning`,onClick:()=>k(`mcp.reset`,S,Q(i,`Reset quyết định MCP?`,`Reset MCP decision?`),Q(i,`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`})]})]})]}),(a||s||l)&&(0,U.jsx)(Pc,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:2.5},children:a?(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,U.jsx)(xu,{size:18}),(0,U.jsx)(X,{children:Q(i,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,U.jsx)(Nw,{color:s?.state===`settled`?`success`:`warning`}),(0,U.jsx)(X,{sx:{fontWeight:800},children:s?s.action:Q(i,`Không hoàn tất`,`Not completed`)}),s&&(0,U.jsx)(lu,{size:`small`,color:s.state===`settled`?`success`:`warning`,variant:`outlined`,label:s.resultCode}),(s?.effect===`read-only`||s?.effect===`session-setting`)&&(0,U.jsx)(lu,{size:`small`,color:s.modelCallObserved?`warning`:`success`,variant:`outlined`,label:s.modelCallObserved?Q(i,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),D&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:Q(i,`Fast: ${D.mode} · provider: ${D.provider??`unknown`} · ${D.reasonCode}`,`Fast: ${D.mode} · provider: ${D.provider??`unknown`} · ${D.reasonCode}`)}),l&&(0,U.jsx)(X,{color:`error`,variant:`body2`,sx:{mt:1},children:l}),s?.outputs.map((e,t)=>(0,U.jsx)(J,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1.5,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,U.jsx)(hT,{open:p!==null,title:p?.title??``,description:p?.description??``,cancelLabel:Q(i,`Hủy`,`Cancel`),confirmLabel:Q(i,`Xác nhận và chạy`,`Confirm and run`),onCancel:()=>m(null),onConfirm:()=>{let e=p;m(null),e&&O(e.action,e.argument,!0)}})]})}var Jk=Y((0,U.jsx)(`path`,{d:`M17 11h3c1.11 0 2-.9 2-2V5c0-1.11-.9-2-2-2h-3c-1.11 0-2 .9-2 2v1H9.01V5c0-1.11-.9-2-2-2H4c-1.1 0-2 .9-2 2v4c0 1.11.9 2 2 2h3c1.11 0 2-.9 2-2V8h2v7.01c0 1.65 1.34 2.99 2.99 2.99H15v1c0 1.11.9 2 2 2h3c1.11 0 2-.9 2-2v-4c0-1.11-.9-2-2-2h-3c-1.11 0-2 .9-2 2v1h-1.01c-.54 0-.99-.45-.99-.99V8h2v1c0 1.1.9 2 2 2`}),`AccountTreeRounded`),Yk=Y((0,U.jsx)(`path`,{d:`M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8`}),`InfoOutlined`),Xk=Y((0,U.jsx)(`path`,{d:`M20 5H4c-1.1 0-1.99.9-1.99 2L2 17c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2m-9 3h2v2h-2zm0 3h2v2h-2zM8 8h2v2H8zm0 3h2v2H8zm-1 2H5v-2h2zm0-3H5V8h2zm8 7H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m1-4h-2v-2h2zm0-3h-2V8h2zm3 3h-2v-2h2zm0-3h-2V8h2z`}),`KeyboardRounded`),Zk=Y([(0,U.jsx)(`path`,{d:`M13 8.57c-.79 0-1.43.64-1.43 1.43s.64 1.43 1.43 1.43 1.43-.64 1.43-1.43-.64-1.43-1.43-1.43`},`0`),(0,U.jsx)(`path`,{d:`M13.21 3c-3.84-.11-7 2.87-7.19 6.64L4.1 12.2c-.25.33-.01.8.4.8H6v3c0 1.1.9 2 2 2h1v2c0 .55.45 1 1 1h5c.55 0 1-.45 1-1v-3.68c2.44-1.16 4.1-3.68 4-6.58-.14-3.62-3.18-6.63-6.79-6.74M16 10c0 .13-.01.26-.02.39l.83.66c.08.06.1.16.05.25l-.8 1.39c-.05.09-.16.12-.24.09l-.99-.4c-.21.16-.43.29-.67.39L14 13.83c-.01.1-.1.17-.2.17h-1.6c-.1 0-.18-.07-.2-.17l-.15-1.06c-.25-.1-.47-.23-.68-.39l-.99.4c-.09.03-.2 0-.25-.09l-.8-1.39c-.05-.08-.03-.19.05-.25l.84-.66c-.01-.13-.02-.26-.02-.39s.02-.27.04-.39l-.85-.66c-.08-.06-.1-.16-.05-.26l.8-1.38c.05-.09.15-.12.24-.09l1 .4c.2-.15.43-.29.67-.39L12 6.17c.02-.1.1-.17.2-.17h1.6c.1 0 .18.07.2.17l.15 1.06c.24.1.46.23.67.39l1-.4c.09-.03.2 0 .24.09l.8 1.38c.05.09.03.2-.05.26l-.85.66c.03.12.04.25.04.39`},`1`)],`PsychologyRounded`),Qk=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).replace(/đ/g,`d`).replace(/Đ/g,`D`).toLowerCase();function $k(e,t){let n=Qk(t).split(/\s+/).filter(Boolean),r=Qk(e).split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.every(e=>r.some(t=>t.startsWith(e)))}function eA(e,t,n=40){return t.trim()?e.filter(e=>$k(`${e.label} ${e.keywords??``} ${e.group}`,t)).slice(0,n):e.slice(0,n)}function tA(e){let t=(0,v.useRef)(e);t.current=e,(0,v.useEffect)(()=>{let e=e=>{e.isComposing||!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey||(e.key.toLowerCase()===`k`?(e.preventDefault(),t.current.palette()):e.key===`,`&&(e.preventDefault(),t.current.settings()))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[])}function nA({open:e,onClose:t,commands:n,locale:r}){let[i,a]=(0,v.useState)(``),[o,s]=(0,v.useState)(0),c=(0,v.useMemo)(()=>eA(n,i),[n,i]),l=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(a(``),s(0))},[e]),(0,v.useEffect)(()=>{s(0)},[i]),(0,v.useEffect)(()=>{l.current?.querySelector(`[data-index="${o}"]`)?.scrollIntoView({block:`nearest`})},[o]);let u=e=>{e&&(t(),setTimeout(()=>e.run(),0))},d=e=>{e.nativeEvent.isComposing||(e.key===`ArrowDown`?(e.preventDefault(),s(e=>Math.min(e+1,c.length-1))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Math.max(e-1,0))):e.key===`Enter`&&(e.preventDefault(),u(c[o])))},f=``;return(0,U.jsxs)(BC,{open:e,onClose:t,fullWidth:!0,maxWidth:`sm`,slotProps:{paper:{"aria-label":Q(r,`Bảng lệnh`,`Command palette`),sx:{alignSelf:`flex-start`,mt:{xs:2,sm:`12vh`},borderRadius:2.5,overflow:`hidden`}}},children:[(0,U.jsxs)(J,{sx:{display:`flex`,alignItems:`center`,gap:1,px:2,py:1.25,borderBottom:1,borderColor:`divider`},children:[(0,U.jsx)(fx,{fontSize:`small`,color:`action`}),(0,U.jsx)(nc,{autoFocus:!0,fullWidth:!0,value:i,onChange:e=>a(e.target.value),onKeyDown:d,placeholder:Q(r,`Gõ lệnh hoặc tên cuộc trò chuyện…`,`Type a command or a conversation name…`),inputProps:{role:`combobox`,"aria-expanded":!0,"aria-controls":`piagent-palette-list`,"aria-activedescendant":c[o]?`palette-${c[o].id}`:void 0,"aria-label":Q(r,`Tìm lệnh`,`Search commands`)}})]}),(0,U.jsxs)(rf,{component:`div`,id:`piagent-palette-list`,role:`listbox`,"aria-label":Q(r,`Lệnh`,`Commands`),ref:l,dense:!0,sx:{maxHeight:`min(60vh, 460px)`,overflowY:`auto`,py:.5},children:[c.map((e,t)=>{let n=e.group===f?null:e.group;return f=e.group,(0,U.jsxs)(v.Fragment,{children:[n&&(0,U.jsx)(jT,{component:`div`,"aria-hidden":!0,disableSticky:!0,sx:{lineHeight:`28px`,fontSize:11,fontWeight:800,letterSpacing:`.04em`,textTransform:`uppercase`},children:n}),(0,U.jsxs)(cf,{id:`palette-${e.id}`,role:`option`,"aria-selected":t===o,"data-index":t,selected:t===o,onMouseMove:()=>s(t),onClick:()=>u(e),sx:{mx:.5,borderRadius:1.5,gap:2},children:[(0,U.jsx)(X,{sx:{flex:1,minWidth:0,fontSize:14},noWrap:!0,children:e.label}),e.hint&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:e.hint})]})]},e.id)}),!c.length&&(0,U.jsx)(X,{sx:{px:2.5,py:3},color:`text.secondary`,children:Q(r,`Không có lệnh nào khớp.`,`No matching command.`)})]})]})}var rA=Y((0,U.jsx)(`path`,{d:`M9.29 6.71c-.39.39-.39 1.02 0 1.41L13.17 12l-3.88 3.88c-.39.39-.39 1.02 0 1.41s1.02.39 1.41 0l4.59-4.59c.39-.39.39-1.02 0-1.41L10.7 6.7c-.38-.38-1.02-.38-1.41.01`}),`ChevronRightRounded`),iA={"branch-switch-blocked-running":[`Có cuộc trò chuyện đang chạy trong folder này. Chờ chạy xong hoặc Dừng rồi chuyển nhánh.`,`A conversation is running in this folder. Wait for it to finish, or stop it, then switch.`],"branch-switch-local-changes":[`Git không chuyển được: thay đổi chưa commit sẽ bị ghi đè. Commit hoặc stash trước.`,`Git refused: uncommitted changes would be overwritten. Commit or stash them first.`],"branch-switch-unfinished-merge":[`Repo đang dở merge hoặc rebase. Xử lý xong rồi chuyển nhánh.`,`The repository is in the middle of a merge or rebase. Finish it first.`],"branch-exists":[`Đã có nhánh tên này.`,`A branch with this name already exists.`],"branch-name-invalid":[`Tên nhánh không hợp lệ với Git.`,`Git does not accept this branch name.`],"branch-not-found":[`Không còn nhánh này.`,`This branch no longer exists.`],"not-a-git-repository":[`Folder này không phải repo Git.`,`This folder is not a Git repository.`],"branch-switch-timeout":[`Git chạy quá lâu nên đã dừng.`,`Git took too long and was stopped.`]};function aA({projectRef:e,projectLabel:t,branch:n,repositories:r,locale:i,onSwitched:a,maxWidth:o=220}){let[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),S=(0,v.useRef)(null),C=(0,v.useRef)(null),[w,T]=(0,v.useState)(null);(0,v.useEffect)(()=>{T(null)},[n?.name,n?.detached,e]);let E=w??n,D=!!s,O=()=>{S.current?.abort();let t=new AbortController;S.current=t,m(!1),H_(e,l,t.signal).then(e=>{t.signal.aborted||f(e)},()=>{t.signal.aborted||m(!0)})};(0,v.useEffect)(()=>(D&&O(),()=>S.current?.abort()),[D,e,l]);let k=()=>{_||(S.current?.abort(),c(null),g(``),x(null),f(null),m(!1),u(null))},A=e=>{S.current?.abort(),f(null),g(``),x(null),u(e)},j=async t=>{y(t.branch),x(null);try{let n=await U_(e,l===null?t:{...t,repository:l});n.head&&l===null&&T(n.head),a?.(),c(null),g(``),f(null),u(null)}catch(e){x(e instanceof V_?{code:e.code,detail:e.detail}:{code:`branch-switch-failed`,detail:null}),O()}finally{y(null)}},M=d?.repository?d:null;(0,v.useEffect)(()=>{D&&M&&requestAnimationFrame(()=>C.current?.focus())},[D,M]);let N=h.trim(),P=(0,v.useMemo)(()=>(M?.branches??[]).filter(e=>!N||e.name.toLowerCase().includes(N.toLowerCase())),[M,N]),F=P.filter(e=>!e.remote),I=P.filter(e=>e.remote),L=(M?.branches??[]).some(e=>e.name===N),R=(d?.running??0)>0,ee=e=>(0,U.jsxs)(cf,{dense:!0,disabled:!e.current&&(R||!!_),selected:e.current,"aria-current":e.current||void 0,onClick:()=>e.current?k():void j({branch:e.name,remote:e.remote}),sx:{borderRadius:1,py:.4},children:[(0,U.jsx)(pf,{sx:{minWidth:26},children:_===e.name?(0,U.jsx)(xu,{size:14}):e.current?(0,U.jsx)(VD,{sx:{fontSize:16}}):e.remote?(0,U.jsx)(Cw,{sx:{fontSize:15,color:`text.disabled`}}):null}),(0,U.jsx)(Cf,{primary:e.name,secondary:[e.remote,e.committedAt?rk(e.committedAt,i):null].filter(Boolean).join(` · `)||void 0,slotProps:{primary:{noWrap:!0,sx:{fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:12.5}},secondary:{noWrap:!0,sx:{fontSize:11}}}})]},`${e.remote??``}/${e.name}`),te=d&&!d.repository?d.repositories??[]:[],z=!E&&!!r?.length;if(!E&&!z)return null;let B={minWidth:0,maxWidth:o,borderRadius:.75,px:.4,mx:-.4,font:`inherit`,color:`inherit`,justifyContent:`flex-start`,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`}},V=e=>{e.stopPropagation(),c(e.currentTarget)};return(0,U.jsxs)(U.Fragment,{children:[E?(0,U.jsx)(Ah,{describeChild:!0,title:`${tk(E,i)} · ${Q(i,`bấm để đổi nhánh`,`click to switch`)}`,children:(0,U.jsx)(tu,{onClick:V,"aria-haspopup":`dialog`,"aria-expanded":D,"aria-label":E.detached?Q(i,`Đổi nhánh Git của ${t} (detached HEAD tại ${E.name})`,`Switch ${t}'s Git branch (detached HEAD at ${E.name})`):Q(i,`Đổi nhánh Git của ${t} (đang ở ${E.name})`,`Switch ${t}'s Git branch (on ${E.name})`),sx:B,children:(0,U.jsx)(nk,{branch:E,locale:i,maxWidth:`100%`,tooltip:!1})})}):(0,U.jsx)(Ah,{describeChild:!0,title:r.map(e=>`${e.name} · ${e.branch?.name??`?`}`).join(`
|
|
230
|
+
`),children:(0,U.jsx)(tu,{onClick:V,"aria-haspopup":`dialog`,"aria-expanded":D,"aria-label":Q(i,`${r.length} repo Git trong ${t}`,`${r.length} Git repositories in ${t}`),sx:B,children:(0,U.jsxs)(J,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:.4,whiteSpace:`nowrap`},children:[(0,U.jsx)(ek,{sx:{fontSize:`1.1em`}}),Q(i,`${r.length} repo`,`${r.length} repos`)]})})}),(0,U.jsxs)(yb,{open:D,anchorEl:s,onClose:k,anchorOrigin:{vertical:`bottom`,horizontal:`left`},slotProps:{paper:{role:`dialog`,"aria-label":Q(i,`Nhánh Git`,`Git branches`),sx:{width:`min(360px, calc(100vw - 32px))`,maxHeight:`min(520px, 70vh)`,display:`flex`,flexDirection:`column`,p:1.25,gap:1}}},children:[(0,U.jsxs)(J,{sx:{display:`flex`,alignItems:`center`,gap:.5,minWidth:0},children:[l!==null&&(0,U.jsx)(Qd,{size:`small`,"aria-label":Q(i,`Về danh sách repo`,`Back to the repositories`),onClick:()=>A(null),children:(0,U.jsx)(ST,{sx:{fontSize:18}})}),(0,U.jsxs)(J,{sx:{minWidth:0},children:[(0,U.jsx)(X,{variant:`subtitle2`,sx:{fontWeight:650},children:z&&l===null?Q(i,`Repo Git`,`Git repositories`):Q(i,`Nhánh Git`,`Git branches`)}),(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,children:l===null?t:`${t} / ${l}`})]})]}),R&&(0,U.jsx)(mC,{severity:`warning`,sx:{py:0,fontSize:12.5},children:Q(i,`${d.running} cuộc trò chuyện đang chạy trong folder này. Chờ chạy xong hoặc Dừng rồi mới chuyển nhánh.`,`${d.running} conversation(s) running in this folder. Wait for them to finish, or stop them, before switching.`)}),M&&M.changedFiles>0&&!R&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(i,`${M.changedFiles} file đang sửa dở sẽ đi theo sang nhánh mới; Git từ chối nếu chúng bị ghi đè.`,`${M.changedFiles} changed file(s) come along to the new branch; Git refuses if they would be overwritten.`)}),b&&(0,U.jsxs)(mC,{severity:`error`,sx:{py:0,fontSize:12.5},children:[Q(i,...iA[b.code]??[`Không chuyển được nhánh.`,`The branch could not be switched.`]),b.detail&&(0,U.jsx)(J,{component:`pre`,sx:{m:0,mt:.5,whiteSpace:`pre-wrap`,font:`11px ui-monospace, monospace`,opacity:.85},children:b.detail})]}),!(d&&!d.repository)&&(0,U.jsx)(dx,{inputRef:C,size:`small`,value:h,onChange:e=>g(e.target.value),disabled:!M||!!_,placeholder:Q(i,`Tìm hoặc đặt tên nhánh mới`,`Find a branch or name a new one`),slotProps:{htmlInput:{maxLength:200,"aria-label":Q(i,`Tìm nhánh`,`Find a branch`)}},onKeyDown:e=>{if(e.key===`Enter`&&N&&!R&&!_){let e=M?.branches.find(e=>e.name===N);j(e?{branch:e.name,remote:e.remote}:{branch:N,create:!0})}}}),(0,U.jsxs)(J,{sx:{overflowY:`auto`,minHeight:0,mx:-.5},children:[!d&&!p&&(0,U.jsx)(J,{sx:{display:`flex`,justifyContent:`center`,py:2},children:(0,U.jsx)(xu,{size:18})}),p&&(0,U.jsx)(mC,{severity:`error`,sx:{py:0,fontSize:12.5},children:Q(i,`Không đọc được danh sách nhánh.`,`The branches could not be read.`)}),d&&!d.repository&&te.length>0&&(0,U.jsx)(rf,{dense:!0,disablePadding:!0,"aria-label":Q(i,`Repo trong folder`,`Repositories in the folder`),children:te.map(e=>(0,U.jsxs)(cf,{dense:!0,onClick:()=>A(e.name),sx:{borderRadius:1,py:.4},children:[(0,U.jsx)(Cf,{primary:e.name,secondary:(0,U.jsxs)(J,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.5,minWidth:0,width:`100%`},children:[e.head?(0,U.jsx)(nk,{branch:e.head,locale:i,maxWidth:`100%`,tooltip:!1}):Q(i,`chưa có commit`,`no commits`),e.changedFiles>0&&(0,U.jsxs)(J,{component:`span`,sx:{flexShrink:0},children:[`· `,Q(i,`${e.changedFiles} file đang sửa`,`${e.changedFiles} changed`)]})]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13,fontWeight:600}},secondary:{component:`div`,sx:{fontSize:11.5,minWidth:0}}},sx:{minWidth:0}}),(0,U.jsx)(rA,{sx:{fontSize:18,color:`text.disabled`}})]},e.name))}),d&&!d.repository&&te.length===0&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:Q(i,...iA[`not-a-git-repository`])}),M&&(0,U.jsxs)(rf,{dense:!0,disablePadding:!0,children:[N&&!L&&(0,U.jsxs)(cf,{dense:!0,disabled:R||!!_,onClick:()=>void j({branch:N,create:!0}),sx:{borderRadius:1},children:[(0,U.jsx)(pf,{sx:{minWidth:26},children:_===N?(0,U.jsx)(xu,{size:14}):(0,U.jsx)(JS,{sx:{fontSize:16}})}),(0,U.jsx)(Cf,{primary:Q(i,`Tạo nhánh mới “${N}”`,`Create branch “${N}”`),secondary:Q(i,`từ ${M.head?.name??`HEAD`}`,`from ${M.head?.name??`HEAD`}`),slotProps:{primary:{noWrap:!0,sx:{fontSize:12.5}},secondary:{sx:{fontSize:11}}}})]}),F.map(ee),I.length>0&&(0,U.jsx)(jT,{disableSticky:!0,sx:{lineHeight:`26px`,fontSize:11,bgcolor:`transparent`},children:Q(i,`Trên remote`,`On a remote`)}),I.map(ee),P.length===0&&!N&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:Q(i,`Chưa có nhánh nào.`,`No branches yet.`)}),M.truncated&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{px:1},children:Q(i,`Chỉ hiện 200 nhánh có commit mới nhất.`,`Showing the 200 most recently committed branches.`)})]})]})]})]})}var oA=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,sA={height:28,px:1,gap:.75,fontSize:12,color:`text.secondary`,alignItems:`center`},cA={...sA,borderRadius:0,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`,outlineOffset:-2}};function lA({locale:e,connection:t,running:n,session:r,onBranchSwitched:i,onUpdates:a,onPalette:o}){let{status:s,supported:c}=PE(),l=XE(e=>e.breakpoints.up(`md`)),u=jE(s),d=!!(s?.updateAvailable&&s.installable),f=s?.piagent.installed?`Piagent ${s.piagent.installed}${s.pi.installed?` · Pi ${s.pi.installed}`:``}`:`Piagent`;return l?(0,U.jsxs)(J,{component:`footer`,"aria-label":Q(e,`Thanh trạng thái`,`Status bar`),sx:{position:`fixed`,left:0,right:0,bottom:0,height:28,display:`flex`,alignItems:`stretch`,borderTop:1,borderColor:`divider`,bgcolor:`background.paper`,zIndex:e=>e.zIndex.drawer+1,whiteSpace:`nowrap`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:sA,children:[(0,U.jsx)(J,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:t===`connected`?`success.main`:`warning.main`}}),(0,U.jsx)(`span`,{children:t===`connected`?`Gateway live`:t}),(0,U.jsx)(J,{component:`span`,sx:{color:`text.disabled`},children:`local`})]}),(r?.gitBranch||!!r?.gitRepositories?.length)&&(0,U.jsx)(Z,{direction:`row`,sx:{...sA,minWidth:0},children:(0,U.jsx)(aA,{projectRef:r.projectRef,projectLabel:r.projectLabel,branch:r.gitBranch,repositories:r.gitRepositories,locale:e,maxWidth:320,onSwitched:i})}),n>0&&(0,U.jsxs)(Z,{direction:`row`,sx:sA,children:[(0,U.jsx)(xu,{size:10,thickness:6}),(0,U.jsx)(`span`,{children:Q(e,`${n} đang chạy`,`${n} running`)})]}),(0,U.jsx)(J,{sx:{flex:1}}),c&&(0,U.jsx)(Ah,{describeChild:!0,title:d?Q(e,`Mở Cập nhật trong Cài đặt`,`Open Updates in Settings`):Q(e,`Phiên bản và cập nhật`,`Version and updates`),children:(0,U.jsx)(tu,{onClick:a,sx:{...cA,...d&&{color:`primary.contrastText`,bgcolor:`primary.main`,fontWeight:700,"&:hover":{bgcolor:`primary.dark`,color:`primary.contrastText`}}},children:u?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(xu,{size:11,thickness:6,color:`inherit`}),Q(e,`Đang cập nhật lên ${s?.job?.to}…`,`Updating to ${s?.job?.to}…`)]}):d?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(dE,{sx:{fontSize:15}}),Q(e,`Cập nhật Piagent ${s?.piagent.latest}`,`Update Piagent ${s?.piagent.latest}`)]}):(0,U.jsx)(`span`,{children:f})})}),(0,U.jsxs)(tu,{onClick:o,"aria-label":Q(e,`Mở bảng lệnh`,`Open command palette`),sx:cA,children:[(0,U.jsxs)(J,{component:`kbd`,sx:{font:`inherit`,fontSize:11,px:.6,border:1,borderColor:`divider`,borderRadius:.75},children:[oA(),` K`]}),(0,U.jsx)(`span`,{children:Q(e,`Lệnh`,`Commands`)})]})]}):null}function uA(e){let t=Q(e,`Chung`,`General`),n=`Agent`,r=Q(e,`Công cụ`,`Tools`),i=Q(e,`Thông tin`,`Information`);return[{id:`general`,group:t,label:Q(e,`Giao diện`,`Appearance`),icon:(0,U.jsx)(DT,{}),keywords:`ngôn ngữ language chủ đề theme sáng tối light dark tiếng việt english`},{id:`updates`,group:t,label:Q(e,`Cập nhật`,`Updates`),icon:(0,U.jsx)(dE,{}),keywords:`update phiên bản version pi piagent npm nâng cấp upgrade`},{id:`shortcuts`,group:t,label:Q(e,`Phím tắt`,`Shortcuts`),icon:(0,U.jsx)(Xk,{}),keywords:`keyboard bàn phím shortcut lệnh command palette enter`},{id:`models`,group:n,label:Q(e,`Nhà cung cấp & model`,`Providers & models`),icon:(0,U.jsx)(Zk,{}),keywords:`model provider thinking đăng nhập login oauth tài khoản account công ty company`},{id:`controls`,group:n,label:Q(e,`Điều khiển project`,`Project controls`),icon:(0,U.jsx)(Jk,{}),keywords:`project runtime khởi động lại restart session`},{id:`permissions`,group:n,label:Q(e,`Quyền truy cập`,`Access`),icon:(0,U.jsx)(ET,{}),keywords:`permission quyền sandbox đọc ghi read write network mạng`},{id:`connections`,group:r,label:Q(e,`MCP & kết nối`,`MCP & connections`),icon:(0,U.jsx)(aw,{}),keywords:`mcp server tool công cụ oauth kết nối connection`},{id:`usage`,group:i,label:Q(e,`Sử dụng & context`,`Usage & context`),icon:(0,U.jsx)(Hk,{}),keywords:`token usage context ngữ cảnh input output`},{id:`about`,group:i,label:`Piagent`,icon:(0,U.jsx)(Yk,{}),keywords:`gateway protocol runtime giới thiệu about`}]}function dA(e,t){return t.trim()?e.filter(e=>$k(`${e.label} ${e.group} ${e.keywords}`,t)):e}function fA({section:e,onSection:t,onBack:n}){let{locale:r}=Kv(),{status:i}=PE(),[a,o]=(0,v.useState)(``),s=(0,v.useMemo)(()=>dA(uA(r),a),[r,a]),c=!!(i?.updateAvailable&&i.installable),l=``;return(0,U.jsxs)(J,{component:`nav`,"aria-label":Q(r,`Mục cài đặt`,`Settings sections`),sx:{borderRight:{sm:1},borderBottom:{xs:1,sm:0},borderColor:`divider`,bgcolor:`background.paper`,p:1.25,minHeight:0,overflow:`auto`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{minHeight:48,alignItems:`center`,justifyContent:`space-between`,px:1},children:[(0,U.jsx)(X,{id:`piagent-settings-title`,sx:{fontWeight:700},children:Q(r,`Cài đặt`,`Settings`)}),(0,U.jsx)(Qd,{"aria-label":Q(r,`Đóng cài đặt`,`Close settings`),onClick:n,children:(0,U.jsx)(YE,{})})]}),(0,U.jsxs)(Pc,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:.75,px:1,mx:.5,mb:1,borderRadius:1.5},children:[(0,U.jsx)(fx,{fontSize:`small`,color:`action`}),(0,U.jsx)(nc,{value:a,onChange:e=>o(e.target.value),placeholder:Q(r,`Tìm cài đặt`,`Search settings`),inputProps:{"aria-label":Q(r,`Tìm cài đặt`,`Search settings`)},onKeyDown:e=>{e.key===`Enter`&&s[0]&&(e.preventDefault(),t(s[0].id))},sx:{flex:1,fontSize:13,py:.5}})]}),(0,U.jsxs)(rf,{component:`div`,disablePadding:!0,sx:{display:{xs:`flex`,sm:`block`},minWidth:{xs:`max-content`,sm:0},overflowX:`auto`,flex:1},children:[s.map(n=>{let i=n.group===l?null:n.group;return l=n.group,(0,U.jsxs)(J,{sx:{display:{xs:`contents`,sm:`block`}},children:[i&&(0,U.jsx)(jT,{component:`div`,disableSticky:!0,sx:{display:{xs:`none`,sm:`block`},bgcolor:`transparent`,lineHeight:`30px`,fontSize:11,fontWeight:800,letterSpacing:`.04em`,textTransform:`uppercase`,mt:.5},children:i}),(0,U.jsxs)(cf,{selected:e===n.id,onClick:()=>t(n.id),children:[(0,U.jsx)(pf,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:n.icon}),(0,U.jsx)(Cf,{primary:n.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:e===n.id?800:650}}}}),n.id===`updates`&&c&&(0,U.jsx)(J,{"aria-label":Q(r,`Có bản cập nhật`,`Update available`),role:`img`,sx:{width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`,flexShrink:0}})]})]},n.id)}),!s.length&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,py:2},children:Q(r,`Không có mục nào khớp.`,`No matching setting.`)})]}),i?.piagent.installed&&(0,U.jsx)(X,{variant:`caption`,color:`text.disabled`,sx:{display:{xs:`none`,sm:`block`},px:1.5,pt:1},children:`Piagent ${i.piagent.installed}${i.pi.installed?` · Pi ${i.pi.installed}`:``}`})]})}function pA(){let{locale:e}=Kv(),t=oA(),n=[[`${t} K`,Q(e,`Mở bảng lệnh: mọi thao tác và cuộc trò chuyện theo tên`,`Open the command palette: every action and conversation by name`)],[`${t} ,`,Q(e,`Mở Cài đặt`,`Open Settings`)],[`Enter`,Q(e,`Gửi tin nhắn`,`Send the message`)],[`Shift Enter`,Q(e,`Xuống dòng trong tin nhắn`,`New line in the message`)],[`1 – 5`,Q(e,`Chọn đáp án khi main agent hỏi; Enter để gửi câu trả lời`,`Pick an answer when the main agent asks; Enter sends it`)],[`Esc`,Q(e,`Đóng hộp thoại hoặc bảng lệnh`,`Close a dialog or the palette`)]];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:3},children:Q(e,`Phím tắt`,`Shortcuts`)}),(0,U.jsx)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:n.map(([e,t],n)=>(0,U.jsxs)(Z,{direction:`row`,sx:{px:2.25,py:1.5,gap:2,alignItems:`center`,justifyContent:`space-between`,borderTop:+!!n,borderColor:`divider`},children:[(0,U.jsx)(X,{children:t}),(0,U.jsx)(J,{component:`kbd`,sx:{px:.9,py:.2,border:1,borderColor:`divider`,borderRadius:1,fontSize:12,fontFamily:`inherit`,whiteSpace:`nowrap`,bgcolor:`action.hover`},children:e})]},e))})]})}function mA(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function hA({children:e}){return(0,U.jsx)(X,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function gA({icon:e,title:t,detail:n,action:r}){return(0,U.jsxs)(Z,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,U.jsxs)(Z,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,U.jsxs)(J,{children:[(0,U.jsx)(X,{sx:{fontWeight:760},children:t}),n&&(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function _A(){let{locale:e,colorMode:t,setLocale:n,setColorMode:r}=Kv();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hA,{children:Q(e,`Giao diện`,`Appearance`)}),(0,U.jsxs)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:[(0,U.jsx)(gA,{icon:(0,U.jsx)(WD,{color:`primary`}),title:Q(e,`Ngôn ngữ`,`Language`),detail:Q(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,U.jsxs)(op,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&n(t),children:[(0,U.jsx)(ep,{value:`vi`,children:`VI`}),(0,U.jsx)(ep,{value:`en`,children:`EN`})]})}),(0,U.jsx)(Du,{}),(0,U.jsx)(gA,{icon:t===`dark`?(0,U.jsx)(Bh,{color:`primary`}):(0,U.jsx)(zh,{color:`primary`}),title:Q(e,`Chủ đề`,`Theme`),detail:Q(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,U.jsxs)(op,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&r(t),children:[(0,U.jsx)(ep,{value:`light`,children:Q(e,`Sáng`,`Light`)}),(0,U.jsx)(ep,{value:`dark`,children:Q(e,`Tối`,`Dark`)})]})})]})]})}function vA({options:e,snapshot:t,activeModel:n,observedProvider:r}){let{locale:i}=Kv(),a=e?.webSearch,o=t?.capabilities.capabilities.attachments,s=o?.status===`available`?o.kinds.some(e=>e===`image`):null,c=t?.session.model.state===`known`?t.session.model.value:null,l=c?c.inputCapabilities.some(e=>e===`image`):null,u=n?.imageInput??l??s,d=(n?.provider??r??null)===`openai-codex`,f=[{key:`search`,icon:(0,U.jsx)(JD,{color:`primary`}),title:a?.route===`codex-first`?`Codex Web Search`:Q(i,`Tìm kiếm web`,`Web search`),detail:a?.route===`codex-first`?Q(i,`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.`):a?.state===`configured`?Q(i,`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.`):Q(i,`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:a?.route===`codex-first`?Q(i,`Ưu tiên Codex`,`Codex first`):a?.state===`configured`?Q(i,`Đã cấu hình`,`Configured`):Q(i,`Chưa có`,`Unavailable`),ready:a?.state===`configured`},{key:`vision`,icon:(0,U.jsx)(Lk,{color:`primary`}),title:d?`Codex Vision`:Q(i,`Vision của model`,`Model vision`),detail:u===!0?Q(i,`Ả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.`):u===!1?Q(i,`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.`):Q(i,`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:u===!0?Q(i,`Đang dùng`,`Active`):u===!1?Q(i,`Không hỗ trợ`,`Unsupported`):Q(i,`Chưa rõ`,`Unknown`),ready:u===!0}];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(X,{variant:`h2`,sx:{mt:3,mb:.5},children:Q(i,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:Q(i,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:f.map(e=>(0,U.jsx)(Pc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,U.jsx)(J,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:2,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:800},children:e.title}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,U.jsx)(lu,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function yA({options:e,auth:t,refreshAuth:n,session:r,snapshot:i,onSetModel:a,onSetThinking:o}){let{locale:s}=Kv(),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=i?.session.model.state===`known`?i.session.model.value:null,p=(0,v.useMemo)(()=>{let t=new Map;for(let n of e?.models??[])t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t.entries()]},[e]),m=f?.modelRef??``,h=e?.models.find(e=>e.modelRef===m),g=h?m:``,_=f?.displayName??r?.modelLabel??`—`,y=r?.managedThinkingLevels??h?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],b=async e=>{if(e){l(!0),d(null);try{await e()}catch{d(Q(s,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{l(!1)}}};return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hA,{children:Q(s,`Nhà cung cấp & model`,`Providers & models`)}),r&&(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:2.25,borderRadius:2.5,mb:2},children:[(0,U.jsxs)(Z,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,U.jsx)(Mw,{name:f?.provider??r.modelLabel??`model`,size:38}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{sx:{fontWeight:700},children:Q(s,`Model của session hiện tại`,`Current session model`)}),(0,U.jsxs)(X,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[_,` · `,Iv(r.thinkingLevel,s)]})]}),(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:Q(s,`Đang dùng`,`In use`)})]}),(0,U.jsxs)(Z,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,U.jsxs)(J,{sx:{flex:1},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,U.jsx)(ox,{fullWidth:!0,size:`small`,value:g,displayEmpty:!0,renderValue:t=>t?e?.models.find(e=>e.modelRef===t)?.displayName??_:_,disabled:c||!a||r.liveState===`running`,onChange:e=>void b(()=>a?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,U.jsx)(xw,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,U.jsxs)(J,{sx:{width:{md:220}},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,U.jsx)(ox,{fullWidth:!0,size:`small`,value:r.thinkingLevel===`unknown`?`off`:r.thinkingLevel,disabled:c||!o||r.liveState===`running`,onChange:e=>void b(()=>o?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:y.map(e=>(0,U.jsx)(xw,{value:e,children:Iv(e,s)},e))})]})]}),u&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:u})]}),(0,U.jsx)(vA,{options:e,snapshot:i,activeModel:h,observedProvider:f?.provider}),(0,U.jsx)(X,{variant:`h2`,sx:{mt:3,mb:.5},children:Q(s,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:Q(s,`Kết nối tài khoản để mở khóa model tương ứng.`,`Connect an account to make its models available.`)}),(0,U.jsx)(zk,{catalog:t,refresh:n}),(0,U.jsx)(X,{variant:`h2`,sx:{mt:3,mb:.5},children:Q(s,`Danh mục model`,`Model catalog`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:Q(s,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:p.map(([e,t])=>(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:1.5,borderRadius:2},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,U.jsx)(Mw,{name:e,size:32}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{noWrap:!0,sx:{fontWeight:700,textTransform:`capitalize`},children:e}),(0,U.jsxs)(X,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,U.jsx)(lu,{size:`small`,color:`success`,variant:`outlined`,label:Q(s,`Sẵn sàng`,`Ready`)})]}),(0,U.jsxs)(J,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&p.length===0&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(s,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function bA({value:e,loading:t,sessionRef:n,onChanged:r}){let{locale:i}=Kv();return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hA,{children:Q(i,`MCP & kết nối`,`MCP & connections`)}),t?(0,U.jsx)(xu,{size:22}):(0,U.jsxs)(Z,{spacing:1,children:[(e?.connections??[]).map(e=>(0,U.jsx)(Pc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,U.jsxs)(Z,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,U.jsx)(Mw,{name:e.name,size:38}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{noWrap:!0,sx:{fontWeight:800},children:e.name}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,children:sT(e,i)})]}),n?(0,U.jsx)(lT,{sessionRef:n,connection:e,onChanged:r}):(0,U.jsx)(lu,{size:`small`,variant:`outlined`,label:Q(i,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,U.jsx)(X,{color:`text.secondary`,children:Q(i,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function xA({snapshot:e,session:t,onSetPermission:n}){let{locale:r}=Kv(),i=e?.session.permissionProfile,[a,o]=(0,v.useState)(i?.state===`known`?i.value??null:null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null);(0,v.useEffect)(()=>{o(null)},[t?.sessionRef]),(0,v.useEffect)(()=>{i?.state===`known`&&o(i.value??null)},[i?.state,i?.value]);let p=async e=>{if(n){c(!0),u(null);try{await n(e),o(e)}catch{u(Q(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{c(!1)}}},m=e=>{if(e===`trusted-full-access`){f(e);return}p(e)},h=[{mode:`read-only`,detail:Q(r,`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:Q(r,`Đọ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:Q(r,`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.`)}];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hA,{children:Q(r,`Quyền truy cập`,`Access`)}),(0,U.jsx)(X,{variant:`h2`,sx:{mb:.5},children:Q(r,`Hồ sơ quyền`,`Permission profile`)}),(0,U.jsx)(X,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:Q(r,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,U.jsx)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:h.map((e,i)=>(0,U.jsxs)(J,{children:[(0,U.jsx)(gA,{icon:(0,U.jsx)(ET,{color:e.mode===`trusted-full-access`?`warning`:`primary`}),title:Iv(e.mode,r),detail:e.detail,action:(0,U.jsx)($,{size:`small`,variant:a===e.mode?`contained`:`outlined`,color:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":a===e.mode,disabled:s||!t||!n||t.liveState===`running`,onClick:()=>m(e.mode),children:Iv(e.mode,r)})}),i<h.length-1&&(0,U.jsx)(Du,{})]},e.mode))}),l&&(0,U.jsx)(X,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:l}),(0,U.jsx)(hT,{open:d!==null,title:Q(r,`Bật toàn quyền?`,`Enable full access?`),description:Q(r,`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:Q(r,`Hủy`,`Cancel`),confirmLabel:Q(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>f(null),onConfirm:()=>{f(null),p(`trusted-full-access`)}})]})}function SA({session:e,snapshot:t}){let{locale:n}=Kv(),r=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),i=[[Q(n,`Context`,`Context`),r?.percent==null?`—`:`${Math.round(r.percent)}%`],[`Tokens`,`${mA(r?.tokens,n)} / ${mA(r?.contextWindow,n)}`],[Q(n,`Input`,`Input`),mA(t?.usage.sessionTotal.input,n)],[Q(n,`Output`,`Output`),mA(t?.usage.sessionTotal.output,n)],[Q(n,`Continuation`,`Continuation`),mA(t?.continuation.remaining,n)],[`Verifier`,t?.verification.state??`—`]];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hA,{children:Q(n,`Usage & context`,`Usage & context`)}),(0,U.jsx)(J,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,sm:`repeat(2,minmax(0,1fr))`,lg:`repeat(3,minmax(0,1fr))`},gap:1},children:i.map(([e,t])=>(0,U.jsxs)(Pc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:e}),(0,U.jsx)(X,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:800},children:t})]},e))})]})}function CA({capabilities:e,connection:t}){let{locale:n}=Kv(),r=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[Q(n,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(hA,{children:`Piagent`}),(0,U.jsx)(Pc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:r.map(([e,t],n)=>(0,U.jsxs)(J,{children:[(0,U.jsxs)(Z,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,U.jsx)(X,{color:`text.secondary`,children:e}),(0,U.jsx)(X,{sx:{fontWeight:760},children:String(t)})]}),n<r.length-1&&(0,U.jsx)(Du,{})]},String(e)))})]})}function wA({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}=Kv(),[f,p]=(0,v.useState)(),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(),[y,b]=(0,v.useState)(!1);return(0,v.useEffect)(()=>{let e=new AbortController;return Pg(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]),(0,v.useEffect)(()=>{let e=new AbortController;return Fg(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,v.useEffect)(()=>{if(!r){_(void 0);return}let e=new AbortController;return b(!0),_(void 0),n_(r.sessionRef,e.signal).then(_).catch(()=>void 0).finally(()=>{e.signal.aborted||b(!1)}),()=>e.abort()},[r?.sessionRef]),(0,U.jsxs)(J,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`236px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,U.jsx)(fA,{section:e,onSection:t,onBack:n}),(0,U.jsxs)(J,{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,U.jsx)(_A,{}),e===`updates`&&(0,U.jsx)(VE,{}),e===`shortcuts`&&(0,U.jsx)(pA,{}),e===`models`&&(0,U.jsx)(yA,{options:f,auth:m,refreshAuth:async()=>{let[e,t]=await Promise.all([Fg(),Pg()]);h(e),p(t)},session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,U.jsx)(bA,{value:g,loading:y,sessionRef:r?.sessionRef,onChanged:async e=>{if(e){_(e);return}r&&_(await n_(r.sessionRef).catch(()=>g))}}),e===`controls`&&(0,U.jsx)(qk,{session:r,options:f,connections:g,onCompleted:u}),e===`permissions`&&(0,U.jsx)(xA,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,U.jsx)(SA,{session:r,snapshot:i}),e===`about`&&(0,U.jsx)(CA,{capabilities:a,connection:o})]})]})}function TA(e){let{locale:t,actions:n}=e,r=Q(t,`Lệnh`,`Commands`),i=oA(),a=[];e.canCreate&&a.push({id:`new-chat`,group:r,label:Q(t,`Cuộc trò chuyện mới`,`New chat`),keywords:`new create tạo`,run:n.newChat}),e.update.available&&e.update.latest&&a.push({id:`update-now`,group:r,label:Q(t,`Cập nhật Piagent ${e.update.latest}`,`Update Piagent ${e.update.latest}`),keywords:`update upgrade nâng cấp phiên bản version`,run:()=>n.settings(`updates`)}),a.push({id:`check-updates`,group:r,label:Q(t,`Kiểm tra cập nhật`,`Check for updates`),keywords:`update version phiên bản pi piagent`,run:n.checkUpdates}),e.hasSelection&&a.push({id:`toggle-panel`,group:r,label:Q(t,`Bật/tắt khung Workspace`,`Toggle the Workspace panel`),keywords:`panel sidebar changes plan context`,run:n.togglePanel},{id:`open-changes`,group:r,label:Q(t,`Mở Source Changes`,`Open Source Changes`),keywords:`diff review thay đổi git`,run:n.openChanges}),a.push({id:`theme`,group:r,label:e.colorMode===`dark`?Q(t,`Chuyển sang chủ đề sáng`,`Switch to the light theme`):Q(t,`Chuyển sang chủ đề tối`,`Switch to the dark theme`),keywords:`theme chủ đề dark light sáng tối`,run:()=>n.setColorMode(e.colorMode===`dark`?`light`:`dark`)},{id:`language`,group:r,label:t===`vi`?`Switch the interface to English`:`Chuyển giao diện sang tiếng Việt`,keywords:`language ngôn ngữ english tiếng việt`,run:()=>n.setLocale(t===`vi`?`en`:`vi`)},{id:`refresh`,group:r,label:Q(t,`Làm mới`,`Refresh`),keywords:`reload tải lại`,run:n.refresh});let o=Q(t,`Cài đặt`,`Settings`);for(let e of uA(t))a.push({id:`settings-${e.id}`,group:o,label:`${o}: ${e.label}`,hint:e.id===`general`?`${i} ,`:void 0,keywords:e.keywords,run:()=>n.settings(e.id)});let s=Q(t,`Cuộc trò chuyện`,`Conversations`);for(let t of e.sessions)a.push({id:`session-${t.sessionRef}`,group:s,label:t.title,hint:t.projectLabel,keywords:t.projectLabel,run:()=>n.openSession(t.sessionRef)});return a}var EA=class{#e=0;run(e,t,n){let r=++this.#e;return(async()=>{try{let n=await e();return r===this.#e&&t(n),n}catch{r===this.#e&&n();return}})()}invalidate(){this.#e+=1}},DA=class{#e;#t;#n;#r=0;#i=0;#a=!1;#o=!1;#s=[];constructor(e){this.#e=e.read,this.#t=e.commit,this.#n=e.classify}request(){if(this.#o)return Promise.resolve({state:`cancelled`,readSequence:this.#i});let e=++this.#r,t=new Promise(t=>this.#s.push({ticket:e,resolve:t}));return this.#c(),t}invalidate(){if(this.#o)return;this.#o=!0;let e={state:`cancelled`,readSequence:this.#i},t=this.#s;this.#s=[];for(let n of t)n.resolve(e)}async#c(){if(!(this.#a||this.#o)){this.#a=!0;try{for(;!this.#o&&this.#s.length>0;){let e=this.#r,t=++this.#i,n;try{let e=await this.#e();if(this.#o)return;try{this.#t(e),n={state:`committed`,value:e,readSequence:t}}catch(e){n={state:`terminal-error`,error:e,readSequence:t}}}catch(e){if(this.#o)return;n={state:this.#n(e)===`retryable`?`retryable-error`:`terminal-error`,error:e,readSequence:t}}let r=this.#s.filter(t=>t.ticket<=e);this.#s=this.#s.filter(t=>t.ticket>e);for(let e of r)e.resolve(n);if(n.state===`terminal-error`){this.#o=!0;let e={state:`cancelled`,readSequence:t},n=this.#s;this.#s=[];for(let t of n)t.resolve(e)}}}finally{this.#a=!1,!this.#o&&this.#s.length>0&&this.#c()}}}},OA=`piagent-gateway-event-cursor-v1`,kA=3e4,AA=12e4,jA=4001,MA=class extends Error{reasonCode;constructor(e){super(e),this.name=`SessionSendRejectedError`,this.reasonCode=e}};function NA(e,t){if(!e)return null;try{let n=JSON.parse(e);return n.gatewayInstanceRef===t&&Number.isSafeInteger(n.sequence)&&Number(n.sequence)>=0?Number(n.sequence):null}catch{return null}}function PA(e,t){if(t!==null)try{window.sessionStorage.setItem(OA,JSON.stringify({gatewayInstanceRef:e,sequence:t}))}catch{}}function FA(e){return`${e}_${crypto.randomUUID().replaceAll(`-`,``)}`}function IA(e){return e.phase===`rejected`&&e.resultCode===`stale-revision`&&e.error?.code===`session-revision-stale`}var LA=280,RA=320,zA=`min(44vw, 860px)`,BA=`piagent-webui-workspace-panel`;function VA({session:e,live:t,locale:n}){let r=ik(e,t),[i,a]=r===`running`?[Q(n,`Đang chạy`,`Running`),`primary`]:r===`elsewhere`?[Q(n,`Đang chạy ở nơi khác`,`Running elsewhere`),`info`]:r===`attention`?[Q(n,`Cần duyệt`,`Needs approval`),`warning`]:r===`recovery`?[Q(n,`Cần khôi phục`,`Recovery needed`),`error`]:r===`failed`?[Q(n,`Lượt cuối lỗi`,`Last turn failed`),`error`]:[Q(n,`Sẵn sàng`,`Ready`),`default`];return(0,U.jsx)(lu,{size:`small`,variant:`outlined`,color:a,label:i})}function HA({session:e,snapshot:t,locale:n,live:r,canSend:i,canRestart:a,send:o,abort:s,restart:c,onInspector:l}){let u=e.sessionRef,d=rE(u),[f,p]=(0,v.useState)(()=>tE(u)),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(),y=e=>{p(e),nE(u,e)},b=HT({projectRef:e.projectRef,value:f,locale:n,onChange:e=>{y(e),M(null)}}),[x,S]=(0,v.useState)(()=>d?.attachments??[]),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(()=>d?.messageRequestId??`message-request.${crypto.randomUUID()}`),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)(()=>d?.sendUnconfirmed??!1);(0,v.useEffect)(()=>{iE(u,x.length||N?{attachments:x,messageRequestId:T,sendUnconfirmed:N}:null)},[u,x,T,N]),(0,v.useEffect)(()=>{if(!N)return;let e=window.setTimeout(()=>{P(!1),M({tone:`error`,text:Q(n,`Tin nhắn chưa được gửi: phiên chưa nhận nó trong 2 phút nên nó sẽ không chạy nữa. Nội dung vẫn còn; bấm Gửi để thử lại.`,`The message was not sent: the session did not take it within 2 minutes, so it will not run. Your message is kept; send it again.`)})},AA+15e3);return()=>window.clearTimeout(e)},[N,n]);let[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)(!1),[z,B]=(0,v.useState)(0),V=(0,v.useRef)(0);(0,v.useEffect)(()=>{let e=e=>{dS(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]);let ne=t?.capabilities.capabilities.attachments,re=(0,v.useMemo)(()=>new Set(ne?.status===`available`?ne.mimeTypes:[]),[ne]),ie=(0,v.useMemo)(()=>uS(re),[re]),ae=!!t&&ne?.status===`available`&&i&&!m&&!N&&!D&&x.length<4,oe=async r=>{if(!(!r?.length||!t||ne?.status!==`available`||D)){O(!0),A(null);try{let i=await fS({files:r,snapshot:t,messageRequestId:T,existing:x,allowed:re,locale:n,stage:t=>N_(e.sessionRef,t)});S(i.attachments),A(i.status)}catch{A(Q(n,`Không thể đính kèm; file không được gửi vào Pi.`,`Unable to attach the file; it was not sent to Pi.`))}finally{O(!1)}}},se=async r=>{if(!(!t||m||D)){O(!0),A(null);try{let i=await pS({snapshot:t,messageRequestId:T,attachmentRef:r,locale:n,stage:t=>N_(e.sessionRef,t)});i.discarded?S(e=>e.filter(e=>e.attachmentRef!==r)):A(i.status)}catch{A(Q(n,`Không thể bỏ file; trạng thái session có thể đã thay đổi.`,`Unable to remove the file; session state may have changed.`))}finally{O(!1)}}};(0,v.useEffect)(()=>{let t=new AbortController;return _(void 0),n_(e.sessionRef,t.signal).then(_).catch(()=>void 0),()=>t.abort()},[e.sessionRef,e.sessionRevision]);let H=(0,v.useRef)(!1),ce=async()=>{let e=f;if(!e.trim()||m||N||H.current)return;H.current=!0,h(!0),M(null);let t=x.map(e=>e.attachmentRef);try{if((await o(e,t.length>0?{messageRequestId:T,attachmentRefs:t,attachments:x}:void 0)).state===`unconfirmed`){iE(u,{attachments:x,messageRequestId:T,sendUnconfirmed:!0}),P(!0),M({tone:`warning`,text:Q(n,`Piagent đang xác nhận lần gửi này. Nội dung và file vẫn được giữ; đừng gửi lại để tránh chạy trùng.`,`Piagent is confirming this send. Your message and files remain preserved; do not resend, to avoid a duplicate run.`)});return}y(``),S([]),A(null),E(`message-request.${crypto.randomUUID()}`),iE(u,null)}catch{M({tone:`error`,text:Q(n,`Tin nhắn chưa được gửi. Nội dung và file vẫn được giữ; có thể thử lại khi session sẵn sàng.`,`The message was not sent. Your message and files are preserved; retry when the session is ready.`)})}finally{H.current=!1,h(!1)}};(0,v.useEffect)(()=>{!N||r?.messageRequestId!==T||r.delivery!==`admitted`||(y(``),S([]),A(null),M(null),P(!1),E(`message-request.${crypto.randomUUID()}`))},[r?.delivery,r?.messageRequestId,T,N]);let le=async()=>{if(!(m||N)){h(!0),M(null);try{await o(Q(n,`tiếp tục`,`continue`))}catch{M({tone:`error`,text:Q(n,`Chưa gửi được. Thử lại khi session sẵn sàng.`,`Not sent. Retry when the session is ready.`)})}finally{h(!1)}}},ue=async t=>{if(t){_(t);return}_(await n_(e.sessionRef).catch(()=>g))},de=async()=>{if(!F){I(!0),R(null);try{await c()}catch(e){R(e instanceof Error?e.message:null)}finally{I(!1)}}},fe=r?.runtimeRecovery??(e.state===`recovery-required`?`stale`:null);return(0,U.jsxs)(J,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,U.jsxs)(J,{sx:{flex:1,width:`100%`,maxWidth:860,mx:`auto`,px:{xs:2,sm:4},py:{xs:3,md:4},display:`flex`,flexDirection:`column`,justifyContent:`center`},children:[!i&&e.modelLabel===`agent-watch-auto`&&(0,U.jsx)(rw,{locale:n,onConnected:()=>B(e=>e+1)},e.sessionRef),(0,U.jsx)(J,{sx:{width:`100%`},children:(0,U.jsx)(JO,{reload:z,sessionRef:e.sessionRef,sessionRevision:e.sessionRevision,live:r,approvals:t?.approvals,locale:n,onOpenActivity:()=>l(`activity`),onContinue:i&&!m&&!N&&e.liveState!==`running`&&(!r||r.complete)?()=>void le():void 0},e.sessionRef)})]}),(0,U.jsxs)(J,{sx:{position:`sticky`,bottom:`var(--piagent-status-bar, 0px)`,px:{xs:1.5,sm:2.5},pb:2.5,background:`linear-gradient(transparent, var(--piagent-palette-background-default) 25%)`},children:[e.state===`terminal-owned`&&(0,U.jsx)(mC,{severity:`info`,role:`status`,sx:{maxWidth:820,mx:`auto`,mb:1},children:Q(n,`Cuộc trò chuyện này đang chạy trong Terminal hoặc một tiến trình Piagent khác. Trang này tự cập nhật để bạn theo dõi; gửi tin nhắn khi nó chạy xong.`,`This conversation is running in Terminal or another Piagent process. This page follows it; send a message when it has finished.`)}),fe&&(0,U.jsx)(mC,{severity:fe===`recovered`?`success`:fe===`failed`?`error`:`warning`,action:(fe===`failed`||fe===`required`||fe===`stale`)&&a&&e.liveState!==`running`?(0,U.jsx)($,{color:`inherit`,size:`small`,disabled:F,onClick:()=>void de(),children:F?Q(n,`Đang khởi động…`,`Restarting…`):Q(n,`Khởi động lại phiên`,`Restart session`)}):void 0,sx:{maxWidth:860,mx:`auto`,mb:1},children:fe===`recovered`?Q(n,`Runtime mới đã được xác minh; lịch sử và context của session được giữ nguyên.`,`The new runtime is verified; session history and context were preserved.`):fe===`failed`?L?.startsWith(`company-`)&&JC(L,null,n)?`${JC(L,null,n).title}: ${JC(L,null,n).text}`:Q(n,`Runtime đã đổi nhưng chưa khởi động lại được. Hãy dùng nút bên cạnh hoặc restart Dashboard.`,`The runtime changed but could not restart. Use the action here or restart the Dashboard.`):fe===`stale`&&[`session-runtime-open-failed`,`session-runtime-dispose-failed`].includes(e.reasonCode??``)?Q(n,`Runtime của phiên này chưa mở được (thường do key, Harness hoặc Agent Watch lúc đó). Bấm Khởi động lại phiên để thử lại, hoặc lưu trữ phiên; lịch sử được giữ nguyên.`,`This session's runtime did not open (usually the key, the Harness or Agent Watch at the time). Restart the session to try again, or archive it; its history is kept.`):fe===`stale`?Q(n,`Phiên này chưa được đóng đúng cách và có thể đang mở ở cửa sổ Terminal khác. Đóng cửa sổ đó (nếu có) rồi bấm Khởi động lại phiên để làm tiếp; lịch sử được giữ nguyên.`,`This session was not closed cleanly and may still be open in a Terminal window. Close it (if any), then restart the session to go on; its history is kept.`):fe===`restarting`?Q(n,`Runtime vừa được cập nhật. Piagent đang khởi động lại session an toàn sau lượt hiện tại.`,`The runtime was updated. Piagent is safely restarting the session after the current turn.`):Q(n,`Phát hiện runtime mới. Piagent sẽ giữ câu trả lời hiện tại rồi tự khởi động lại session.`,`A new runtime was detected. Piagent will preserve the current response and restart the session automatically.`)}),(0,U.jsxs)(J,{sx:{position:`relative`,maxWidth:860,mx:`auto`,border:1,borderColor:ee?`primary.main`:`divider`,borderStyle:ee?`dashed`:`solid`,borderRadius:3,bgcolor:`background.paper`,p:1.15,boxShadow:`0 14px 44px rgba(0,0,0,.14)`},onDragEnter:e=>{dS(e.dataTransfer)&&(V.current+=1,te(!0))},onDragOver:e=>{dS(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=ae?`copy`:`none`)},onDragLeave:e=>{dS(e.dataTransfer)&&(--V.current,V.current<=0&&(V.current=0,te(!1)))},onDrop:e=>{dS(e.dataTransfer)&&(e.preventDefault(),V.current=0,te(!1),ae&&oe(e.dataTransfer.files))},children:[ee&&(0,U.jsxs)(J,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,U.jsx)(X,{sx:{fontWeight:750},children:ae?Q(n,`Thả tài liệu vào đây`,`Drop documents here`):x.length>=4?Q(n,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):Q(n,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),ae&&(0,U.jsx)(X,{variant:`caption`,color:`text.secondary`,children:Q(n,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),x.length>0&&(0,U.jsx)(Z,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pb:.75},"aria-label":Q(n,`File sẽ gửi cùng tin nhắn`,`Files to send with the message`),children:x.map(e=>(0,U.jsx)(lu,{size:`small`,variant:`outlined`,color:e.kind===`document`?`success`:`default`,label:`${e.displayName} · ${lS(e,n)}`,onDelete:m||N||D?void 0:()=>void se(e.attachmentRef),deleteIcon:(0,U.jsx)(XS,{"aria-label":`${Q(n,`Bỏ`,`Remove`)} ${e.displayName}`,role:`button`})},e.attachmentRef))}),(0,U.jsx)(dx,{fullWidth:!0,multiline:!0,minRows:2,disabled:!i||m||N,value:f,inputRef:b.inputRef,...b.inputProps,onChange:e=>{y(e.target.value),M(null),b.track(e)},onKeyDown:e=>{b.onKeyDown(e)||xT(e)&&(e.preventDefault(),ce())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),ae&&oe(e.clipboardData.files))},placeholder:Q(n,`Nhắn cho Piagent… (@ để chọn file, folder)`,`Message Piagent… (@ for files and folders)`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:b.htmlInput}}),b.menu,(0,U.jsx)(MC,{in:C,id:`piagent-message-options`,children:(0,U.jsxs)(J,{sx:{mt:.65,p:.85,borderRadius:2,bgcolor:`action.hover`},children:[(0,U.jsx)(vT,{session:e,snapshot:t,connections:g,locale:n,onOpenChanges:()=>l(`source`),onConnectionsChanged:ue}),(0,U.jsx)(Z,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:.75,flexWrap:`wrap`},children:ne?.status===`available`&&(0,U.jsx)(Ah,{title:Q(n,`Chọn file, hoặc kéo thả / dán thẳng vào khung chat`,`Pick a file, or drag and drop / paste straight into the chat`),children:(0,U.jsxs)($,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,U.jsx)(YS,{}),disabled:!ae,"aria-label":`${Q(n,`Đính kèm`,`Attach`)} (${x.length}/4)`,children:[Q(n,`Đính kèm`,`Attach`),(0,U.jsx)(`input`,{type:`file`,multiple:!0,hidden:!0,disabled:!ae,accept:ie||void 0,onChange:e=>{oe(e.target.files),e.currentTarget.value=``}})]})})})]})}),(0,U.jsxs)(Z,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`,mt:.5,gap:1},children:[(0,U.jsxs)(Z,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:1},children:[(0,U.jsx)(Ah,{title:C?Q(n,`Ẩn tùy chọn`,`Hide options`):Q(n,`File và công cụ`,`Files and tools`),children:(0,U.jsx)(Qd,{size:`small`,"aria-label":C?Q(n,`Ẩn tùy chọn`,`Hide options`):Q(n,`Thêm tùy chọn`,`More options`),"aria-expanded":C,"aria-controls":`piagent-message-options`,onClick:()=>w(e=>!e),sx:{bgcolor:C?`action.selected`:`transparent`},children:(0,U.jsx)(JS,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:C?`rotate(45deg)`:`none`}})})}),(0,U.jsx)(X,{variant:`caption`,color:k||j?.tone===`error`?`error`:j?`warning.main`:`text.disabled`,noWrap:!j,sx:{display:{xs:k||j||D?`block`:`none`,sm:`block`}},children:j?.text??k??(D?Q(n,`Đang đọc tài liệu…`,`Reading documents…`):r&&!r.complete?Q(n,`Piagent đang xử lý; có thể gửi việc tiếp theo khi lượt này xong.`,`Piagent is working; you can send the next task when it finishes.`):i?Q(n,`Enter để gửi · Shift+Enter xuống dòng`,`Enter to send · Shift+Enter for a new line`):Q(n,`Session hiện chỉ đọc`,`Session is currently read only`))})]}),r?.operationRef&&!r.complete&&r.abortable!==!1?(0,U.jsx)($,{color:`error`,startIcon:(0,U.jsx)(eC,{}),onClick:()=>void s(),children:Q(n,`Dừng`,`Stop`)}):(0,U.jsx)(Qd,{"aria-label":Q(n,`Gửi`,`Send`),disabled:!i||m||N||!f.trim(),color:`primary`,onClick:()=>void ce(),sx:{bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,U.jsx)(QS,{fontSize:`small`})})]})]})]})]})}function UA({locale:e,canCreate:t,onNew:n}){return(0,U.jsxs)(Z,{sx:{minHeight:`calc(100vh - 68px)`,alignItems:`center`,justifyContent:`center`,px:3,textAlign:`center`},spacing:1.5,children:[(0,U.jsx)(J,{className:`brand-mark`,"aria-hidden":`true`,sx:{width:50,height:50,fontSize:25},children:`π`}),(0,U.jsx)(X,{variant:`h1`,children:Q(e,`Bắt đầu với Piagent`,`Start with Piagent`)}),(0,U.jsx)(X,{color:`text.secondary`,sx:{maxWidth:520},children:Q(e,`Tạo cuộc trò chuyện mới, chọn project và model; session sẽ được lưu để tiếp tục sau khi đóng Gateway.`,`Create a new chat, choose a project and model, and the session will remain available after the Gateway closes.`)}),(0,U.jsx)($,{disabled:!t,variant:`contained`,startIcon:(0,U.jsx)(JS,{}),onClick:n,children:Q(e,`Cuộc trò chuyện mới`,`New chat`)})]})}function WA({catalog:e,capabilities:t,connection:n,live:r,terminalActivities:i,refresh:a,create:o,send:s,abort:c,restart:l,setModel:u,setThinking:d,setPermission:f,rename:p,pin:m,archive:h,unarchive:g,fork:_}){let{locale:y,colorMode:b,setLocale:x,setColorMode:S}=Kv(),C=lE(),w=PE(),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(`chat`),[L,R]=(0,v.useState)(!1),[ee,te]=(0,v.useState)(`general`),[z,B]=(0,v.useState)(!1),[V,ne]=(0,v.useState)(`task`),re=typeof window<`u`&&window.innerWidth<1200,[ie,ae]=(0,v.useState)(()=>{try{let e=window.localStorage.getItem(BA);if(e)return e===`open`}catch{}return window.innerWidth>=1200}),oe=()=>ae(e=>{try{window.localStorage.setItem(BA,e?`closed`:`open`)}catch{}return!e}),se=(0,v.useRef)(!1);se.current=z&&V===`activity`;let[H,ce]=(0,v.useState)(),le=(0,v.useRef)(null),[ue,de]=(0,v.useState)(`idle`),fe=(0,v.useRef)(null),pe=(0,v.useRef)(null);pe.current??=new EA;let[me,he]=(0,v.useState)(!1),[ge,_e]=(0,v.useState)(null),[ve,ye]=(0,v.useState)(null),[be,xe]=(0,v.useState)(``),[Se,Ce]=(0,v.useState)(!1),[we,Te]=(0,v.useState)(null),[Ee,De]=(0,v.useState)(null);(0,v.useEffect)(()=>{F===`chat`&&k||(window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0)},[F,k]);let Oe=(0,v.useMemo)(()=>(e?.sessions??[]).filter(e=>e.archived===N&&`${e.title} ${e.projectLabel} ${e.preview}`.toLowerCase().includes(D.trim().toLowerCase())),[e,D,N]),ke=(0,v.useMemo)(()=>{let e=new Map;for(let t of Oe){let n=e.get(t.projectRef)??{label:t.projectLabel,gitBranch:t.gitBranch,sessions:[]};n.gitBranch??=t.gitBranch,n.gitRepositories??=t.gitRepositories,n.sessions.push(t),e.set(t.projectRef,n)}return[...e.entries()].map(([e,t])=>({projectRef:e,...t,sessions:t.sessions.sort((e,t)=>Number(t.pinned)-Number(e.pinned)||Date.parse(t.updatedAt)-Date.parse(e.updatedAt))})).sort((e,t)=>Date.parse(t.sessions[0]?.updatedAt??``)-Date.parse(e.sessions[0]?.updatedAt??``))},[Oe]),Ae=e?.sessions.filter(e=>e.archived).length??0;(0,v.useEffect)(()=>{(!k||!(e?.sessions??[]).some(e=>e.sessionRef===k))&&A((e?.sessions??[]).find(e=>!e.archived)?.sessionRef)},[k,e]);let je=(e?.sessions??[]).find(e=>e.sessionRef===k),Me=je?.sessionRef,Ne=je?.state===`terminal-owned`,Pe=(e?.sessions??[]).some(e=>e.state===`terminal-owned`);(0,v.useEffect)(()=>{let e=Ne?3e3:Pe?1e4:3e4,t=window.setInterval(()=>{document.visibilityState===`visible`&&a()},e);return()=>window.clearInterval(t)},[Ne,Pe,a]);let Fe=(0,v.useRef)(Me);Fe.current=Me;let Ie=le.current&&le.current.sessionRef===Me&&le.current.snapshot===H?H:void 0,Le=fe.current===Me?ue:Me?`loading`:`idle`,Re=je?r[je.sessionRef]:void 0,[ze,Be]=(0,v.useState)(null),Ve=(0,v.useRef)(!1);(0,v.useEffect)(()=>{if(!e||Ve.current)return;Ve.current=!0;let t=bg();t&&(Be(t),I(`new`))},[e]);let He=e=>{Be(null),A(e),I(`chat`),M(!1)},Ue=e=>{te(e),R(!0)};tA({palette:()=>E(!0),settings:()=>Ue(`general`)});let We=e=>{ne(e),B(!0)},Ge=async()=>{let e=Fe.current;if(!e)return;le.current?.sessionRef!==e&&(fe.current=e,de(`loading`));let t=await pe.current.run(()=>Kg(e),t=>{Fe.current===e&&(le.current={sessionRef:e,snapshot:t},fe.current=e,ce(t),de(`ready`))},()=>{Fe.current===e&&(fe.current=e,de(le.current?.sessionRef===e?`ready`:`error`))});return Fe.current===e?t:void 0};(0,v.useEffect)(()=>{if(!Me){pe.current.invalidate(),le.current=null,fe.current=null,ce(void 0),de(`idle`);return}let e=Me,t=new AbortController;return fe.current=e,le.current?.sessionRef!==e&&(le.current=null,ce(void 0),de(`loading`)),pe.current.run(()=>Kg(e,t.signal),n=>{t.signal.aborted||Fe.current!==e||(le.current={sessionRef:e,snapshot:n},fe.current=e,ce(n),de(`ready`))},()=>{t.signal.aborted||Fe.current!==e||(fe.current=e,de(le.current?.sessionRef===e?`ready`:`error`))}),()=>t.abort()},[Me,je?.sessionRevision]),(0,v.useEffect)(()=>{if(!z||V!==`activity`||!Me||!Ie||!Re?.operationRef||Re.complete)return;let e=Me,t=!1,n,r=async()=>{await pe.current.run(()=>Kg(e),n=>{t||!se.current||Fe.current!==e||(le.current={sessionRef:e,snapshot:n},fe.current=e,ce(n),de(`ready`))},()=>void 0),t||(n=window.setTimeout(()=>void r(),2e3))};return n=window.setTimeout(()=>void r(),2e3),()=>{t=!0,n!==void 0&&window.clearTimeout(n)}},[z,V,Me,!!Ie,Re?.operationRef,Re?.complete]);let Ke=n===`connected`&&t?.capabilities.sessionActions.create.status===`available`,qe=async e=>{he(!0),_e(null);let t=null;try{let n=`message-request.${crypto.randomUUID()}`,r=e.files.length>0,i=await o({projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,permissionMode:e.permissionMode,message:e.message,messageRequestId:n,deferInitialMessage:r});if(t=i.sessionRef,!t)throw Error(`session-create-result-invalid`);if(nE(UT,``),iE(UT,null),i.phase!==`settled`){A(t),I(`chat`),De({title:Q(y,`Session đã được tạo`,`The session was created`),message:Q(y,`Pi đã nhận yêu cầu và session đang tự đồng bộ. Không gửi lại để tránh chạy trùng.`,`Pi received the request and the session is resyncing. Do not resend it, to avoid a duplicate run.`)});return}if(r){let r=(await a())?.sessions.find(e=>e.sessionRef===t);if(!r)throw Error(`session-catalog-refresh-failed`);let i=await Kg(t),o=i.capabilities.capabilities.attachments;if(o.status!==`available`)throw Error(o.reason?.code??`session-attachment-unavailable`);let c=await fS({files:e.files,snapshot:i,messageRequestId:n,existing:[],allowed:new Set(o.mimeTypes),locale:y,stage:e=>N_(t,e)});if(c.status||c.attachments.length!==e.files.length)throw await Promise.all(c.attachments.map(async e=>{try{await pS({snapshot:i,messageRequestId:n,attachmentRef:e.attachmentRef,locale:y,stage:e=>N_(t,e)})}catch{}})),Error(c.status??`session-attachment-incomplete`);await s(r,e.message,{messageRequestId:n,attachmentRefs:c.attachments.map(e=>e.attachmentRef),attachments:c.attachments,workflow:e.workflow})}A(t),I(`chat`)}catch(n){let r=n instanceof Error?n.message:`session-create-failed`;t?(e.files.length>0&&nE(t,e.message),A(t),I(`chat`),De({title:Q(y,`Session đã tạo nhưng file chưa được gửi`,`The session was created, but the files were not sent`),message:r})):_e(ew(r,y))}finally{he(!1)}},Je=(e,t)=>{if(t===`pin`){m(e,!e.pinned).catch(e=>De({title:Q(y,`Không thể đổi trạng thái ghim`,`Could not change pin state`),message:e instanceof Error?e.message:`session-pin-failed`}));return}if(t===`unarchive`){g(e).then(()=>P(!1)).catch(e=>De({title:Q(y,`Không thể khôi phục cuộc trò chuyện`,`Could not restore chat`),message:e instanceof Error?e.message:`session-unarchive-failed`}));return}Te(null),xe(t===`rename`?e.title:t===`fork`?`${e.title} · ${Q(y,`nhánh`,`fork`)}`:``),ye({kind:t,session:e})},Ye=async()=>{if(!(!ve||Se)){Ce(!0),Te(null);try{if(ve.kind===`rename`)await p(ve.session,be.trim());else if(ve.kind===`archive`)await h(ve.session);else{let e=await _(ve.session,be.trim()||null);e.sessionRef&&(A(e.sessionRef),I(`chat`))}ye(null)}catch(e){Te(e instanceof Error?e.message:`session-action-failed`)}finally{Ce(!1)}}},Xe=(0,U.jsx)(fk,{locale:y,canCreate:Ke,query:D,onQuery:O,groups:ke,count:Oe.length,selectedRef:F===`chat`?je?.sessionRef:void 0,showArchived:N,archivedCount:Ae,settingsOpen:L,connection:n,live:r,onSelect:He,onAction:Je,onNew:()=>{_e(null),I(`new`),M(!1)},onToggleArchived:()=>{P(e=>!e),M(!1)},updateDot:!!(w.status?.updateAvailable&&w.status.installable),onSettings:()=>{Ue(w.status?.updateAvailable&&w.status.installable?`updates`:`general`),M(!1)}}),Ze=F===`chat`&&je?(0,U.jsx)(Ik,{session:je,snapshot:Ie,live:Re,locale:y,onOpenReview:()=>We(`source`),onClose:()=>ae(!1)}):null,Qe=!!Ze&&ie&&!z;if(C)return(0,U.jsx)(uE,{locale:y});if(!e&&n!==`failed`)return(0,U.jsxs)(Z,{sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},spacing:2,children:[(0,U.jsx)(xu,{size:24}),(0,U.jsx)(X,{children:Q(y,`Đang mở Piagent…`,`Opening Piagent…`)})]});let $e=F===`new`?Q(y,`Cuộc trò chuyện mới`,`New chat`):je?.title??`Piagent`,et=TA({locale:y,colorMode:b,canCreate:Ke,hasSelection:F===`chat`&&!!je,sessions:(e?.sessions??[]).filter(e=>!e.archived),update:{available:!!(w.status?.updateAvailable&&w.status.installable&&!jE(w.status)),latest:w.status?.piagent.latest??null},actions:{newChat:()=>{_e(null),I(`new`)},togglePanel:oe,openChanges:()=>We(`source`),refresh:()=>void a(),settings:Ue,checkUpdates:()=>{Ue(`updates`),w.check()},setColorMode:S,setLocale:x,openSession:He}}),tt=Object.values(r).filter(e=>e&&!e.complete).length;return(0,U.jsxs)(J,{sx:{minHeight:`100vh`,bgcolor:`background.default`,"--piagent-status-bar":{xs:`0px`,md:`28px`}},children:[(0,U.jsx)(zc,{position:`fixed`,color:`transparent`,elevation:0,sx:{left:{md:`${LA}px`},right:{lg:Qe?`${RA}px`:0,xl:z?zA:Qe?`${RA}px`:0},width:{xs:`100%`,md:`auto`},borderBottom:1,transition:`right .2s ease`,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .9)`,backdropFilter:`blur(18px)`},children:(0,U.jsxs)(up,{sx:{minHeight:`60px !important`,gap:1},children:[(0,U.jsx)(Qd,{"aria-label":Q(y,`Mở điều hướng`,`Open navigation`),onClick:()=>M(!0),sx:{display:{md:`none`}},children:(0,U.jsx)(Rh,{})}),(0,U.jsxs)(J,{sx:{flex:1,minWidth:0},children:[(0,U.jsx)(X,{component:`h1`,noWrap:!0,sx:{fontWeight:600,fontSize:`inherit`},children:$e}),F===`chat`&&je&&(0,U.jsxs)(X,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,sx:{display:`flex`,alignItems:`center`,gap:.75,minWidth:0},children:[(0,U.jsx)(J,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,flexShrink:3,minWidth:24},children:je.projectLabel}),(je.gitBranch||!!je.gitRepositories?.length)&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(J,{component:`span`,"aria-hidden":!0,sx:{color:`text.disabled`},children:`·`}),(0,U.jsx)(aA,{projectRef:je.projectRef,projectLabel:je.projectLabel,branch:je.gitBranch,repositories:je.gitRepositories,locale:y,maxWidth:`45%`,onSwitched:()=>void a()})]})]})]}),F===`chat`&&je&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(vT,{placement:`header`,session:je,snapshot:Ie,locale:y,onOpenChanges:()=>We(`source`),canSetModel:n===`connected`&&t?.capabilities.sessionActions.setModel.status===`available`,canSetThinking:n===`connected`&&t?.capabilities.sessionActions.setThinking.status===`available`,canSetPermission:n===`connected`&&t?.capabilities.sessionActions.setPermission.status===`available`,onSetModel:e=>u(je,e),onSetThinking:e=>d(je,e),onSetPermission:e=>f(je,e)}),(0,U.jsx)(J,{sx:{display:{xs:`none`,sm:`block`}},children:(0,U.jsx)(VA,{session:je,live:Re,locale:y})}),(0,U.jsx)(Ah,{title:`Source Changes`,children:(0,U.jsx)(Qd,{"aria-label":Q(y,`Mở Source Changes Inspector`,`Open Source Changes Inspector`),onClick:()=>We(`source`),children:(0,U.jsx)(Ph,{fontSize:`small`})})}),(0,U.jsx)(Ah,{title:Q(y,`Khung Workspace: thay đổi, ngữ cảnh, subagent`,`Workspace panel: changes, context, subagents`),children:(0,U.jsx)(Qd,{"aria-label":Q(y,`Khung Workspace`,`Workspace panel`),"aria-pressed":Qe,onClick:()=>oe(),color:Qe?`primary`:`default`,children:(0,U.jsx)($S,{fontSize:`small`,sx:{transform:`scaleX(-1)`}})})})]}),(0,U.jsx)(Ah,{title:Q(y,`Làm mới`,`Refresh`),children:(0,U.jsx)(Qd,{"aria-label":Q(y,`Làm mới`,`Refresh`),onClick:()=>void a(),children:(0,U.jsx)(ZS,{fontSize:`small`})})})]})}),(0,U.jsxs)(J,{component:`nav`,sx:{width:{md:LA}},children:[(0,U.jsx)(Kd,{variant:`temporary`,open:j,onClose:()=>M(!1),sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:LA}},children:Xe}),(0,U.jsx)(Kd,{variant:`permanent`,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:LA,borderRight:1,borderColor:`divider`,height:`calc(100% - var(--piagent-status-bar, 0px))`}},children:Xe})]}),(0,U.jsx)(J,{component:`main`,sx:{ml:{md:`${LA}px`},mr:{lg:Qe?`${RA}px`:0,xl:z?zA:Qe?`${RA}px`:0},pt:`60px`,transition:`margin-right .2s ease`},children:F===`new`?(0,U.jsx)(sE,{active:!0,defaultProjectRef:ze??je?.projectRef,busy:me,error:ge,onCancel:()=>I(`chat`),onCreate:e=>qe(e)}):je?(0,U.jsx)(HA,{session:je,snapshot:Ie,locale:y,live:r[je.sessionRef],canSend:n===`connected`&&je.composerAvailable&&t?.capabilities.sessionActions.send.status===`available`&&(!Re||Re.complete)&&![`required`,`restarting`,`failed`].includes(String(r[je.sessionRef]?.runtimeRecovery)),canRestart:n===`connected`&&t?.capabilities.sessionActions.release.status===`available`&&t?.capabilities.sessionActions.acquire.status===`available`,send:(e,t)=>s(je,e,t),abort:()=>c(je).catch(e=>De({title:Q(y,`Chưa dừng được lượt này`,`This turn could not be stopped`),message:e instanceof Error&&e.message===`operation-unavailable`?Q(y,`Lượt đã kết thúc hoặc đang chuyển bước. Nếu vẫn còn chạy, bấm Dừng lần nữa.`,`The turn already ended or is between steps. If it is still running, press Stop again.`):e instanceof Error?e.message:`session-abort-failed`})),restart:()=>l(je),onInspector:We},je.sessionRef):(0,U.jsx)(UA,{locale:y,canCreate:Ke,onNew:()=>I(`new`)})}),Ze&&Qe&&!re&&(0,U.jsx)(J,{component:`aside`,sx:{display:{xs:`none`,lg:`block`},position:`fixed`,top:0,right:0,bottom:`var(--piagent-status-bar, 0px)`,width:RA,borderLeft:1,borderColor:`divider`,zIndex:e=>e.zIndex.appBar-1},children:Ze}),Ze&&(0,U.jsx)(Kd,{anchor:`right`,variant:`temporary`,open:ie&&!z&&re,onClose:()=>ae(!1),sx:{display:{xs:`block`,lg:`none`},"& .MuiDrawer-paper":{width:`min(${RA}px, 88vw)`}},children:Ze}),(0,U.jsx)($E,{open:z,active:V,snapshot:Ie,state:Le,sessionRef:Me,terminalActivities:je?i[je.sessionRef]:void 0,liveActivities:Re&&!Re.complete?Re.activities:void 0,onClose:()=>B(!1),onActive:ne,refresh:Ge}),(0,U.jsx)(JE,{locale:y,onDetails:()=>Ue(`updates`)}),(0,U.jsx)(lA,{locale:y,connection:n,running:tt,session:F===`chat`?je:void 0,onBranchSwitched:()=>void a(),onUpdates:()=>Ue(`updates`),onPalette:()=>E(!0)}),(0,U.jsx)(nA,{open:T,onClose:()=>E(!1),commands:et,locale:y}),(0,U.jsx)(BC,{open:L,onClose:()=>R(!1),fullWidth:!0,maxWidth:`lg`,"aria-labelledby":`piagent-settings-title`,slotProps:{paper:{sx:{m:{xs:0,sm:2},width:{xs:`100%`,sm:`calc(100% - 32px)`},height:{xs:`100%`,sm:`min(86vh, 840px)`},maxHeight:{xs:`100%`,sm:`86vh`},borderRadius:{xs:0,sm:2.5},overflow:`hidden`}}},children:(0,U.jsx)(wA,{section:ee,onSection:te,onBack:()=>R(!1),session:je,snapshot:Ie,capabilities:t,connection:n,onSetModel:je?e=>u(je,e):void 0,onSetThinking:je?e=>d(je,e):void 0,onSetPermission:je?e=>f(je,e):void 0,onRuntimeChanged:async()=>{await a(),await Ge()}})}),(0,U.jsx)(BC,{open:!!ve,onClose:()=>!Se&&ye(null),fullWidth:!0,maxWidth:`xs`,children:(0,U.jsxs)(Z,{spacing:2,sx:{p:3},children:[(0,U.jsx)(X,{variant:`h2`,children:ve?.kind===`rename`?Q(y,`Đổi tên cuộc trò chuyện`,`Rename chat`):ve?.kind===`fork`?Q(y,`Tạo nhánh cuộc trò chuyện`,`Fork chat`):Q(y,`Lưu trữ cuộc trò chuyện`,`Archive chat`)}),ve?.kind===`archive`?(0,U.jsx)(X,{color:`text.secondary`,children:Q(y,`Cuộc trò chuyện vẫn được lưu và có thể khôi phục từ mục Đã lưu trữ.`,`The chat remains saved and can be restored from Archived.`)}):(0,U.jsx)(dx,{autoFocus:!0,label:Q(y,`Tên`,`Title`),value:be,onChange:e=>xe(e.target.value),slotProps:{htmlInput:{maxLength:500}}}),we&&(0,U.jsx)(X,{color:`error`,children:we}),(0,U.jsxs)(Z,{direction:`row`,spacing:1,sx:{justifyContent:`flex-end`},children:[(0,U.jsx)($,{disabled:Se,onClick:()=>ye(null),children:Q(y,`Hủy`,`Cancel`)}),(0,U.jsx)($,{variant:`contained`,disabled:Se||ve?.kind!==`archive`&&!be.trim(),onClick:()=>void Ye(),children:Q(y,`Xác nhận`,`Confirm`)})]})]})}),(0,U.jsx)(BC,{open:!!Ee,onClose:()=>De(null),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-session-notice-title`,children:(0,U.jsxs)(Z,{spacing:2,sx:{p:3},children:[(0,U.jsx)(X,{id:`piagent-session-notice-title`,variant:`h2`,children:Ee?.title}),(0,U.jsx)(X,{color:`text.secondary`,children:Ee?.message}),(0,U.jsx)(Z,{direction:`row`,sx:{justifyContent:`flex-end`},children:(0,U.jsx)($,{variant:`contained`,onClick:()=>De(null),children:Q(y,`Đóng`,`Close`)})})]})})]})}function GA(e){let t=e===`dark`,n=t?`#d8ff7a`:`#627400`,r=t?`#8be9c8`:`#14775f`;return Ho({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:e,primary:{main:n,light:t?`#e6ff9f`:`#849a17`,dark:t?`#a7cc45`:`#455400`,contrastText:t?`#111300`:`#ffffff`},secondary:{main:r},success:{main:r},warning:{main:`#efba63`},error:{main:`#ff7f86`},background:{default:t?`#050505`:`#f5f6f0`,paper:t?`#101114`:`#ffffff`},text:{primary:t?`#f4f4ef`:`#1c2018`,secondary:t?`#a4a6ad`:`#62685c`,disabled:t?`#898c95`:`#6b7165`},divider:t?`#24262d`:`#dfe2d8`},shape:{borderRadius:10},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.65rem`,fontWeight:600,letterSpacing:`-0.03em`},h2:{fontSize:`1.2rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`1rem`,fontWeight:600},button:{fontSize:`0.78rem`,fontWeight:500,textTransform:`none`},caption:{fontSize:`0.7rem`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:t?`#050505`:`#f5f6f0`},body:{minWidth:320,minHeight:`100vh`,backgroundImage:t?`radial-gradient(circle at 65% -18%, rgba(139,233,200,.12) 0, transparent 34rem)`:`radial-gradient(circle at 65% -18%, rgba(216,255,122,.22) 0, transparent 34rem)`},"::selection":{backgroundColor:Ci(n,.26)}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:34,borderRadius:8},outlined:{borderColor:t?`#32343c`:`#cfd4c8`}}},MuiChip:{styleOverrides:{root:{height:26,borderRadius:7,fontWeight:500}}},MuiListItemButton:{styleOverrides:{root:{minHeight:42,margin:`2px 10px`,borderRadius:8,color:t?`#a4a6ad`:`#62685c`,"&.Mui-selected":{color:t?`#f4f4ef`:`#1c2018`,backgroundColor:Ci(n,t?.11:.1),boxShadow:`inset 2px 0 ${n}`},"&.Mui-selected:hover":{backgroundColor:Ci(n,.15)}}}},MuiTab:{styleOverrides:{root:{minHeight:48,paddingInline:18,textTransform:`none`,fontWeight:500}}},MuiTooltip:{defaultProps:{arrow:!0}}}})}function KA(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 qA=250,JA=4e3,YA=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/;function XA(e){return Math.min(qA*2**Math.min(Math.max(0,e),16),JA)}function ZA(e){return e instanceof kg?e.status===408||e.status===409||e.status===423||e.status===425||e.status===429||e.status>=500?`retryable`:`terminal`:typeof DOMException<`u`&&e instanceof DOMException&&e.name===`AbortError`?`terminal`:e instanceof TypeError?`retryable`:`terminal`}function QA(e,...t){for(let e of t)if(typeof e==`string`&&YA.test(e))return e;return e}function $A(e){if(!e||typeof e!=`object`)throw Error(`invalid-inspection-snapshot`);let t=e;if(t.schemaVersion!==1||t.version!==`piagent-webui-snapshot-v1`||typeof t.generatedAt!=`string`||[`identity`,`revision`,`capabilities`,`session`,`sourceChanges`,`activity`,`approvals`,`verification`,`usage`,`continuation`,`health`].some(e=>!t[e]||typeof t[e]!=`object`))throw Error(`invalid-inspection-snapshot`);let n=t.revision;if(typeof n.eventCursor!=`string`||!YA.test(n.eventCursor))throw Error(`invalid-inspection-snapshot-cursor`);return e}function ej(e=0){return{state:`cancelled`,readSequence:e}}async function tj(e){let t=0;for(;!e.stopped();){let n=await e.read();if(e.stopped())return ej(n.readSequence);if(n.state!==`retryable-error`)return n;await e.wait(XA(t)),t=Math.min(t+1,16)}return ej()}function nj(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(`connecting`),[i,a]=(0,v.useState)([]),o=(0,v.useRef)(()=>Promise.resolve(ej())),s=(0,v.useRef)(()=>void 0),c=(0,v.useCallback)(async()=>{let e=await o.current();if(e.state===`committed`)return s.current(e.value),e.value},[]);return(0,v.useEffect)(()=>{let e=new AbortController,n,i,c,l,u,d=0,f=0,p=0,m=0,h=null,g=!1,_=!1,v=!1,y=!1,b=!1,x=!1,S=!1,C=!1,w=()=>{window.clearTimeout(i),i=void 0},T=()=>{window.clearTimeout(c),c=void 0},E=()=>{window.clearTimeout(l),l=void 0;let e=u;u=void 0,e?.()},D=e=>new Promise(t=>{let n=()=>{u===n&&(u=void 0,l=void 0),t()};u=n,l=window.setTimeout(n,e)}),O=()=>{d+=1,E()},k,A=()=>{C||S||(S=!0,O(),w(),T(),e.abort(),k.invalidate(),n?.close(),n=void 0,y=!1,r(`failed`))};k=new DA({read:async()=>{let t=m;return{snapshot:$A(await jg(e.signal)),eventGenerationAtStart:t}},commit:({snapshot:e,eventGenerationAtStart:n})=>{C||S||(_=!0,v=!0,m===n&&(h=QA(null,e.revision.eventCursor)),t(e),y&&r(`connected`))},classify:ZA});let j=async()=>{let e=await k.request();return e.state===`committed`?{...e,value:e.value.snapshot}:(e.state===`terminal-error`&&A(),e)};o.current=j;let M=()=>void 0,N=()=>void 0,P=()=>{if(C||S||!g||!_||n)return;O();let e=h?`?after=${encodeURIComponent(h)}`:``,t;try{t=new EventSource(`/api/v1/events${e}`,{withCredentials:!0})}catch{f=Math.min(f+1,16),r(`reconnecting`),M(XA(f-1));return}n=t,y=!1,r(e=>e===`connecting`?`connecting`:`reconnecting`),t.onopen=()=>{C||S||n!==t||(y=!0,f=0,r(v?`connected`:`reconnecting`))},t.addEventListener(`runtime-event`,e=>{if(!(C||S||n!==t))try{let t=e,n=JSON.parse(t.data);if(!n||typeof n.kind!=`string`)return;let r=QA(h,t.lastEventId,n.eventCursor);r!==h&&(h=r,m+=1),a(e=>[...e,n].slice(-500)),[`message.text-delta`,`message.thinking-state`,`activity.progress`].includes(String(n.kind))||N()}catch{}}),t.addEventListener(`resync-required`,()=>{C||S||n!==t||(t.close(),n=void 0,y=!1,w(),T(),x=!1,a([]),r(`reconnecting`),M(0,!0))}),t.onerror=()=>{C||S||n!==t||(t.close(),n=void 0,y=!1,v=!1,f=Math.min(f+1,16),r(`reconnecting`),M(XA(f-1)))}};M=(e=0,t=!1)=>{if(C||S)return;let i=++d;E(),t&&a([]),r(_?`reconnecting`:`connecting`),(async()=>{if(e>0&&await D(e),C||S||d!==i||n)return;let t=await tj({read:j,wait:D,stopped:()=>C||S||d!==i||!!n});C||S||d!==i||n||t.state===`committed`&&P()})()};let F=()=>{if(C||S||!n||c!==void 0)return;let e=XA(p);p=Math.min(p+1,16),c=window.setTimeout(()=>{c=void 0,x=!0,I()},e)},I=async()=>{if(!(C||S||!n)){if(b){x=!0;return}b=!0;try{do{x=!1;let e=await j();if(C||S||!n||e.state===`cancelled`||e.state===`terminal-error`)return;if(e.state===`retryable-error`){v=!1,r(`reconnecting`),x=!0,F();return}p=0}while(x&&!C&&!S&&n)}finally{b=!1,x&&c===void 0&&i===void 0&&n&&!S&&!C&&(i=window.setTimeout(()=>{i=void 0,I()},80))}}};N=()=>{x=!0,!(C||S||b||c!==void 0||i!==void 0)&&(i=window.setTimeout(()=>{i=void 0,I()},80))};let L=e=>{!C&&!S&&g&&!n&&P()};return s.current=L,(async()=>{let e;try{e=await Sg()}catch{!C&&!S&&A();return}if(!(C||S)){if(e===`failed`){A();return}g=!0,M()}})(),()=>{C=!0,O(),e.abort(),k.invalidate(),n?.close(),w(),T(),s.current===L&&(s.current=()=>void 0),o.current===j&&(o.current=()=>Promise.resolve(ej()))}},[]),{snapshot:e,connection:n,events:i,refreshSnapshot:c}}function rj(e,t=150){let n,r=!1,i=!1,a=!1,o=()=>{if(!a){if(r||n!==void 0){i=r;return}n=setTimeout(()=>{n=void 0,r=!0,e().catch(()=>void 0).finally(()=>{r=!1,i&&(i=!1,o())})},t)}};return{request:o,stop:()=>{a=!0,n!==void 0&&clearTimeout(n),n=void 0}}}var ij=class extends Error{effectMayHaveOccurred;constructor(e,t){super(e),this.name=`GatewayCommandTransportError`,this.effectMayHaveOccurred=t}};async function aj(e,t,n=4){for(let r=1;;r+=1)try{return await e(t)}catch(e){if(r>=n||!(e instanceof ij)||e.message!==`gateway-command-response-timeout`)throw e}}function oj(e,t){return e instanceof ij?e.effectMayHaveOccurred:t}function sj(e,t,n=null,r=null){return!e||e.serial<=t||e.operationRef===n||r&&e.messageRequestId&&e.messageRequestId!==r?null:e}function cj(e,t,n=null){return e&&e.operationRef!==t&&!(n&&e.messageRequestId&&e.messageRequestId!==n)?{operationRef:e.operationRef,complete:!1}:null}function lj(e,t){return t?`observed`:e?.phase===`settled`||e?.phase===`accepted`?`confirmed`:e?.phase===`rejected`?`rejected`:`unconfirmed`}function uj(e,t){let n=new AbortController,r=()=>void 0,i=new Promise(e=>{r=e}),a=setTimeout(()=>{n.abort(),r(null)},t);return{promise:Promise.race([e(n.signal).catch(()=>null),i]).finally(()=>clearTimeout(a)),cancel(){n.abort(),r(null),clearTimeout(a)}}}function dj(e,t,n,r,i){let a=e[t];if(!a||a.messageRequestId!==n||i===`unconfirmed`&&(a.delivery===`admitted`||a.operationRef))return e;let o=_D(a,i,r.operationRef,new Date().toISOString()),s=i===`unconfirmed`||r.complete||!!(r.operationRef&&a.operationRef===r.operationRef&&a.complete);return{...e,[t]:{...o,complete:s,abortable:i===`admitted`&&!s&&!!r.operationRef}}}async function fj(e,t={}){let n=()=>{let t=sj(e.readLocalObservation?.()??e.localObservation,e.afterSerial,e.priorOperationRef,e.messageRequestId);return t?{operationRef:t.operationRef,complete:t.complete}:null},r=n();if(r)return r;let i=t.timeoutMs??5e3,a=t.readLiveState??Ng,o=t.readTranscript??qg,s=[uj(async t=>{let n=await a(t);return cj(n?.state===`ready`?n.operations.find(t=>t.sessionRef===e.sessionRef):void 0,e.priorOperationRef,e.messageRequestId)},i),uj(async t=>{let n=await o(e.sessionRef,null,50,t);if(n?.state!==`ready`)return null;let r=[...n.items].reverse().find(t=>t.role===`user`&&t.messageRequestId===e.messageRequestId);if(r)return{operationRef:r.agentOperationId,complete:nS(n.items,e.message,{operationRef:r.agentOperationId,messageRequestId:e.messageRequestId,startedAt:null})};let i=Date.parse(e.requestedAt),a=[...n.items].reverse().find(t=>t.role===`user`&&!t.messageRequestId&&Zx(t.content.text,e.message)&&Date.parse(t.recordedAt)>=i);return a?{operationRef:a.agentOperationId,complete:nS(n.items,e.message,{operationRef:a.agentOperationId,messageRequestId:null,startedAt:e.requestedAt})}:null},i)],c=new Map(s.map((e,t)=>[t,e.promise.then(e=>({evidence:e,index:t}))]));try{for(;c.size>0;){let e=await Promise.race(c.values());if(c.delete(e.index),e.evidence)return e.evidence;let t=n();if(t)return t}return n()}finally{for(let e of s)e.cancel()}}function pj(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`connecting`),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)({}),u=(0,v.useRef)(void 0),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)({});p.current=o;let m=(0,v.useRef)(0),h=(0,v.useRef)(new Map),g=(0,v.useRef)(null),_=(0,v.useRef)(!0),y=(0,v.useRef)(0),b=(0,v.useRef)(0),x=(0,v.useRef)(new Map),S=(0,v.useCallback)(PA,[]),C=(0,v.useCallback)(async(e={})=>{let n=++y.current;try{let[r,i]=await Promise.all([Mg(),Ng().catch(()=>void 0)]),o=aD(i,r.gatewayInstanceRef),c=!1;if(n>=b.current){b.current=n,u.current=r,t(r);let p=g.current;p!==null&&p!==r.gatewayInstanceRef&&(_.current=!0),g.current=r.gatewayInstanceRef;let m=e.requireLiveState||_.current,h=d.current?.readyState===WebSocket.OPEN;if(a(oD(h,m)),!h&&i&&o!==null)f.current=o,S(r.gatewayInstanceRef,o),s(e=>yD(e,i)),l(mD(i)),_.current=!1,c=!0;else if(p!==r.gatewayInstanceRef){if(l({}),m)f.current=null;else{let e=null;try{e=window.sessionStorage.getItem(OA)}catch{}f.current=NA(e,r.gatewayInstanceRef)}}}return e.requireLiveState&&!c?void 0:u.current??r}catch{a(`reconnecting`);return}},[S]),w=(0,v.useCallback)(e=>{let t=d.current;if(!t||t.readyState!==WebSocket.OPEN)return Promise.reject(new ij(`gateway-not-connected`,!1));let n=FA(`request`);return new Promise((r,i)=>{let a=window.setTimeout(()=>{x.current.delete(n)&&i(new ij(`gateway-command-response-timeout`,!0))},kA);x.current.set(n,{resolve:r,reject:i,timeout:a});try{t.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`request`,requestId:n,method:`sessions.command`,params:{command:e}}))}catch(e){window.clearTimeout(a),x.current.delete(n),i(new ij(e instanceof Error?e.message:`gateway-request-failed`,!1))}})},[]),T=(0,v.useCallback)((e,t,n,r,i,a)=>fj({sessionRef:e,message:t,requestedAt:n,afterSerial:r,priorOperationRef:i,messageRequestId:a,readLocalObservation:()=>h.current.get(e)}),[]),E=(0,v.useCallback)(async e=>{let t=u.current,n=e.message.trim(),r=e.messageRequestId??FA(`message`);if(!t?.catalogRevision)throw Error(`catalog-unavailable`);if(!n)throw Error(`message-empty`);let i=t=>{if(!t.catalogRevision)throw Error(`catalog-unavailable`);let i=new Date;return aj(w,{schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:FA(`command`),idempotencyKey:FA(`idempotency`),action:`session.create`,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:null,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:null,payload:{projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,message:n,messageRequestId:r,...e.permissionMode?{permissionMode:e.permissionMode}:{},...e.deferInitialMessage?{deferInitialMessage:!0}:{}}})},a=await i(t);if(IA(a)){let e=await C();e?.catalogRevision&&(a=await i(e))}if(!(a.phase===`uncertain`&&a.sessionRef)&&a.phase!==`settled`||!a.sessionRef)throw Error(a.error?.code??a.resultCode);let o=a.settledAt??a.requestedAt;return a.phase===`settled`&&!e.deferInitialMessage&&s(e=>{let t=e[a.sessionRef];return{...e,[a.sessionRef]:{...t??{assistant:``,attachments:[],activities:[],complete:!1,error:null},user:n,operationRef:a.operationRef,messageRequestId:r,abortable:!t?.complete&&!!a.operationRef,startedAt:t?.startedAt??o,lastEventAt:t?.lastEventAt??o}}}),await C(),a},[C,w]),D=(0,v.useCallback)(async(e,t,n)=>{let r=u.current;if(!r?.catalogRevision)throw Error(`catalog-unavailable`);let i=t.trim();if(!i)throw Error(`message-empty`);let a=n?.messageRequestId??FA(`message`),o=n?.attachmentRefs??[],c=p.current[e.sessionRef],l=m.current,d=h.current.get(e.sessionRef)?.operationRef??c?.operationRef??null,f=new Date().toISOString();s(t=>({...t,[e.sessionRef]:gD(t[e.sessionRef],{message:i,attachments:n?.attachments??[],messageRequestId:a,submittedAt:f})}));let g=()=>s(t=>{let n=t[e.sessionRef],r=vD(n,c,a);if(r===n)return t;let i={...t};return r?i[e.sessionRef]=r:delete i[e.sessionRef],i}),_=(t,n)=>s(r=>dj(r,e.sessionRef,a,t,n)),v=f,y=!1;try{let t=t=>{let r=t.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t.catalogRevision||!r)throw Error(`session-unavailable`);let s=new Date;return v=s.toISOString(),{schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:FA(`command`),idempotencyKey:FA(`idempotency`),action:`session.send`,requestedAt:s.toISOString(),expiresAt:new Date(s.getTime()+AA).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:r.sessionRevision,payload:{delivery:`new-operation`,message:i,messageRequestId:a,expectedOperationRef:null,attachmentRefs:o,...n?.workflow?{workflow:n.workflow}:{}}}},s=t(r);y=!0;let c=await w(s);if(IA(c)){let e=await C();e?.catalogRevision&&(s=t(e),c=await w(s))}if(lj(c,null)===`confirmed`)return _({operationRef:c.operationRef,complete:!1},`admitted`),C(),{state:`confirmed`,receipt:c};let u=await T(e.sessionRef,i,v,l,d,a),f=lj(c,u);if(f===`observed`&&u)return _(u,`admitted`),C(),{state:`observed`,receipt:c};if(f===`unconfirmed`)return _({operationRef:null,complete:!0},`unconfirmed`),C(),{state:`unconfirmed`,receipt:c};throw g(),new MA(c.error?.code??c.resultCode)}catch(t){if(t instanceof MA)throw t;if(oj(t,y)){let t=await T(e.sessionRef,i,v,l,d,a);return lj(null,t)===`observed`&&t?(_(t,`admitted`),C(),{state:`observed`,receipt:null}):(_({operationRef:null,complete:!0},`unconfirmed`),C(),{state:`unconfirmed`,receipt:null})}throw g(),t}},[T,C,w]),O=(0,v.useCallback)(async e=>{let t=u.current,n=o[e.sessionRef]?.operationRef,r=t?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t?.catalogRevision||!r||!n||o[e.sessionRef]?.abortable===!1)throw Error(`operation-unavailable`);let i=t=>{let r=t.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t.catalogRevision||!r)throw Error(`operation-unavailable`);let i=new Date;return w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:FA(`command`),idempotencyKey:FA(`idempotency`),action:`session.abort`,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:r.sessionRevision,payload:{operationRef:n,clearQueued:!0}})},a=await i(t);if(IA(a)){let[t,r]=await Promise.all([C(),Ng().catch(()=>void 0)]);if(!t||!wD(r,t.gatewayInstanceRef,e.sessionRef,n))throw Error(`operation-unavailable`);a=await i(t)}if(a.phase!==`settled`)throw Error(a.error?.code??a.resultCode);return C(),a},[o,C,w]),k=(0,v.useCallback)(async e=>{let t=async t=>{let n=await C(),r=n?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n?.catalogRevision||!r)throw Error(`session-unavailable`);let i=new Date,a=await w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:FA(`command`),idempotencyKey:FA(`idempotency`),action:t,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:n.catalogRevision,expectedSessionRevision:r.sessionRevision,payload:{}});if(a.phase!==`settled`)throw Error(a.error?.code??a.resultCode);return a};s(t=>({...t,[e.sessionRef]:{...t[e.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:null,complete:!0,error:null},runtimeRecovery:`restarting`}}));try{let n=(await C())?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n)throw Error(`session-unavailable`);n.state===`gateway-owned`&&await t(`session.release`);let r=await t(`session.acquire`);return s(t=>({...t,[e.sessionRef]:{...t[e.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:null,complete:!0,error:null},runtimeRecovery:`recovered`}})),await C(),r}catch(t){throw s(t=>({...t,[e.sessionRef]:{...t[e.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:null,complete:!0,error:null},runtimeRecovery:`failed`}})),t}},[C,w]),A=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:FA(`command`),idempotencyKey:FA(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await C(),o},[C,w]),j=(0,v.useCallback)((e,t)=>A(e,`session.set-model`,{modelRef:t}),[A]),M=(0,v.useCallback)((e,t)=>A(e,`session.set-thinking`,{thinkingLevel:t}),[A]),N=(0,v.useCallback)((e,t)=>A(e,`session.set-permission`,{permissionMode:t}),[A]),P=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await w({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:FA(`command`),idempotencyKey:FA(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await C(),o},[C,w]),F=(0,v.useCallback)((e,t)=>P(e,`session.rename`,{title:t}),[P]),I=(0,v.useCallback)((e,t)=>P(e,`session.pin`,{pinned:t}),[P]),L=(0,v.useCallback)(e=>P(e,`session.archive`,{}),[P]),R=(0,v.useCallback)(e=>P(e,`session.unarchive`,{}),[P]),ee=(0,v.useCallback)((e,t)=>P(e,`session.fork`,{entryRef:null,title:t}),[P]);return(0,v.useEffect)(()=>{let e=!1,t,n=0,i=!1,o=rj(()=>C()),c=o.request,p=(()=>{try{let e=window.localStorage.getItem(`piagent-gateway-client-ref`);if(e&&/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(e))return e;let t=FA(`client`);return window.localStorage.setItem(`piagent-gateway-client-ref`,t),t}catch{return FA(`client`)}})(),v=()=>{if(e||Eg())return;a(n===0?`connecting`:`reconnecting`);let o=window.location.protocol===`https:`?`wss:`:`ws:`,b=new WebSocket(`${o}//${window.location.host}/api/v1/gateway`,`piagent.gateway.v1`);d.current=b;let C=window.setTimeout(()=>b.close(1008,`hello-timeout`),5e3);b.addEventListener(`open`,()=>b.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`connect`,clientRef:p,minimumProtocol:1,maximumProtocol:1,lastEventSequence:f.current,catalogRevision:u.current?.catalogRevision??null}))),b.addEventListener(`message`,e=>{let t;try{t=JSON.parse(String(e.data))}catch{b.close(1007,`invalid-json`);return}if(!t||typeof t!=`object`){b.close(1008,`invalid-frame`);return}let o=t;if(o.messageType===`hello`){window.clearTimeout(C);let e=typeof o.capabilities?.gatewayInstanceRef==`string`?o.capabilities.gatewayInstanceRef:null;if(!e||g.current&&e!==g.current){f.current=null,_.current=!0,i=!0,b.close(jA,`gateway-epoch-changed`);return}g.current=e,n=0,r(o.capabilities),a(`connected`);return}if(o.messageType===`response`){let e=x.current.get(String(o.requestId));if(!e)return;x.current.delete(String(o.requestId)),window.clearTimeout(e.timeout),o.ok===!0&&o.result?e.resolve(o.result):e.reject(new ij(String(o.error?.code??`gateway-request-failed`),!1));return}if(o.messageType!==`event`||!Number.isSafeInteger(o.sequence))return;let u=o.payload,d=typeof o.generatedAt==`string`?o.generatedAt:new Date().toISOString(),p=typeof u.messageRequestId==`string`?u.messageRequestId:null,v=e=>e&&p&&e.messageRequestId&&e.messageRequestId!==p?void 0:e;if(o.kind===`resync.required`){_.current=!0,i=!0,b.close(jA,`canonical-resync-required`);return}let y=Number(o.sequence),w=f.current;if(!(w!==null&&y<=w)){if(w!==null&&y!==w+1){_.current=!0,i=!0,b.close(jA,`gateway-event-sequence-gap`);return}if(f.current=y,g.current&&S(g.current,y),typeof u?.sessionRef==`string`&&typeof u.operationRef==`string`&&[`runtime.changed`,`message.delta`,`tool.started`,`tool.completed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&(m.current+=1,h.current.set(u.sessionRef,{serial:m.current,operationRef:u.operationRef,messageRequestId:p,complete:[`message.completed`,`operation.settled`].includes(String(o.kind))})),o.kind===`message.delta`&&typeof u?.sessionRef==`string`&&typeof u.delta==`string`&&s(e=>{let t=v(e[u.sessionRef]);return{...e,[u.sessionRef]:{...t??{user:``,assistant:``,attachments:[],activities:[],complete:!1,error:null},operationRef:u.operationRef,messageRequestId:p??t?.messageRequestId,abortable:!0,complete:!1,delivery:t?.user?`admitted`:t?.delivery,assistant:`${t?.assistant??``}${u.delta}`,startedAt:t?.startedAt??d,lastEventAt:d}}}),[`tool.started`,`tool.completed`].includes(String(o.kind))&&typeof u?.sessionRef==`string`&&typeof u.toolCallRef==`string`&&typeof u.toolLabel==`string`&&s(e=>{let t=v(e[u.sessionRef])??{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef??null,abortable:!0,complete:!1,error:null,runtimeRecovery:null},n=o.kind===`tool.started`?`running`:u.isError===!0?`failed`:`completed`,r=t.activities.find(e=>e.toolCallRef===u.toolCallRef),i=[...t.activities.filter(e=>e.toolCallRef!==u.toolCallRef),{toolCallRef:u.toolCallRef,toolLabel:u.toolLabel,fileLabel:typeof u.fileLabel==`string`?u.fileLabel:r?.fileLabel??null,state:n,reasonCode:u.reasonCode??null,startedAt:r?.startedAt??d,finishedAt:n===`running`?null:d}].slice(-16),a=u.reasonCode===`runtime-restart-required`?`required`:t.runtimeRecovery;return{...e,[u.sessionRef]:{...t,operationRef:u.operationRef??t.operationRef,messageRequestId:p??t.messageRequestId,activities:i,complete:!1,delivery:t.user?`admitted`:t.delivery,runtimeRecovery:a,startedAt:t.startedAt??d,lastEventAt:d}}}),o.kind===`runtime.changed`&&typeof u?.sessionRef==`string`&&s(e=>{let t=[`running`,`paused`,`waiting-approval`].includes(String(u.liveState)),n=v(e[u.sessionRef])??(t&&typeof u.operationRef==`string`?{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef,messageRequestId:p,abortable:!0,complete:!1,settlement:null,error:null,runtimeRecovery:null}:null);if(!n)return e;let r=u.reasonCode===`runtime-restart-required`?`restarting`:u.reasonCode===`runtime-restart-failed`?`failed`:[`required`,`restarting`].includes(String(n.runtimeRecovery))&&u.liveState===`idle`?`recovered`:n.runtimeRecovery;return t?{...e,[u.sessionRef]:{...n,operationRef:u.operationRef??n.operationRef,messageRequestId:p??n.messageRequestId,abortable:!0,complete:!1,settlement:null,delivery:n.user?`admitted`:n.delivery,runtimeRecovery:r,startedAt:n.startedAt??d,lastEventAt:d}}:!n.complete&&u.operationRef===null?{...e,[u.sessionRef]:{...n,assistant:``,activities:[],abortable:!1,complete:!0,settlement:`unknown`,messageRequestId:p??n.messageRequestId,error:u.reasonCode??`operation-settlement-unknown`,runtimeRecovery:r,lastEventAt:d}}:r===n.runtimeRecovery?e:{...e,[u.sessionRef]:{...n,runtimeRecovery:r}}}),o.kind===`message.completed`&&typeof u?.sessionRef==`string`&&s(e=>{let t=v(e[u.sessionRef]);return{...e,[u.sessionRef]:{...t??{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef,error:null},operationRef:u.operationRef,messageRequestId:p??t?.messageRequestId,abortable:!1,complete:!0,settlement:`completed`,delivery:t?.user?`admitted`:t?.delivery,error:null,lastEventAt:d}}}),o.kind===`operation.settled`&&typeof u?.sessionRef==`string`&&typeof u.operationRef==`string`){s(e=>{let t=v(e[u.sessionRef])??{user:``,assistant:``,attachments:[],activities:[],operationRef:u.operationRef,complete:!1,error:null,runtimeRecovery:null};return t.operationRef&&t.operationRef!==u.operationRef?e:{...e,[u.sessionRef]:{...hD(t,{operationRef:u.operationRef,settlement:u.settlement,reasonCode:u.reasonCode}),messageRequestId:p??t.messageRequestId,lastEventAt:d}}});let e=fD({operationRef:u.operationRef,settlement:u.settlement,reasonCode:u.reasonCode,settledAt:o.generatedAt,sequence:y});e&&l(t=>({...t,[u.sessionRef]:pD(t[u.sessionRef]??[],[e])}))}[`catalog.changed`,`session.changed`,`runtime.changed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&c()}}),b.addEventListener(`close`,()=>{window.clearTimeout(C);for(let e of x.current.values())window.clearTimeout(e.timeout),e.reject(new ij(`gateway-connection-lost`,!0));if(x.current.clear(),!e){if(a(`reconnecting`),i){i=!1,y();return}n+=1,t=window.setTimeout(v,Math.min(5e3,250*2**Math.min(n,5)))}}),b.addEventListener(`error`,()=>{})},y=async()=>{if(e||Eg())return;let r=await C({requireLiveState:!0});if(!e){if(r){n=0,v();return}a(`reconnecting`),n+=1,t=window.setTimeout(()=>void y(),Math.min(5e3,250*2**Math.min(n,5)))}};(async()=>{let t=await Sg();if(!e){if(t===`failed`){a(`failed`);return}await y()}})();let b=()=>{!e&&document.visibilityState===`visible`&&C()};return document.addEventListener(`visibilitychange`,b),()=>{e=!0,t&&window.clearTimeout(t),o.stop();for(let e of x.current.values())window.clearTimeout(e.timeout),e.reject(new ij(`gateway-client-unmounted`,!0));x.current.clear(),d.current?.close(1e3,`client-unmount`),document.removeEventListener(`visibilitychange`,b)}},[S,C]),{catalog:e,capabilities:n,connection:i,live:o,terminalActivities:c,refresh:C,create:E,send:D,abort:O,restart:k,setModel:j,setThinking:M,setPermission:N,rename:F,pin:I,archive:L,unarchive:R,fork:ee}}var mj=document.getElementById(`root`);if(!mj)throw Error(`Piagent WebUI root is missing`);var hj=document.querySelector(`meta[name="csp-nonce"]`)?.content,gj=We({key:`piagent-mui`,nonce:hj&&!hj.startsWith(`__PIAGENT_`)?hj:void 0,prepend:!0});function _j(){let e=nj();return(0,U.jsx)(qS,{...e})}function vj(){let e=pj();return(0,U.jsx)(NE,{children:(0,U.jsx)(WA,{...e})})}function yj(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function bj(){let[e,t]=(0,v.useState)(()=>yj(`piagent-webui-locale`,[`vi`,`en`],KA(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,v.useState)(()=>yj(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)),i=(0,v.useMemo)(()=>GA(n),[n]);(0,v.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=n;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,n)}catch{}},[n,e]);let a=(0,v.useMemo)(()=>({locale:e,colorMode:n,setLocale:t,setColorMode:r}),[n,e]),o=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,U.jsx)(Gv,{value:a,children:(0,U.jsxs)(Dc,{theme:i,children:[(0,U.jsx)(is,{}),o===`gateway`?(0,U.jsx)(vj,{}):(0,U.jsx)(_j,{})]})})}(0,y.createRoot)(mj).render((0,U.jsx)(v.StrictMode,{children:(0,U.jsx)(gt,{value:gj,children:(0,U.jsx)(bj,{})})}));export{l as S,Cr as _,Pc as a,o as b,ys as c,Go as d,ba as f,W as g,Gr as h,J as i,Xo as l,Kr as m,Du as n,Ac as o,Ci as p,ul as r,q as s,X as t,K as u,mn as v,s as x,d as y};
|