@piagent/platform 1.38.1 → 1.38.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -1
  3. package/README.vi.md +1 -1
  4. package/docs/command-reference-vietnamese.md +2 -2
  5. package/docs/distribution-standard.md +6 -6
  6. package/docs/languages.json +2 -2
  7. package/docs/operator-manual-vietnamese.md +7 -7
  8. package/docs/publishing-for-teams.md +1 -0
  9. package/docs/release-install-policy.md +2 -2
  10. package/docs/team-onboarding.md +2 -2
  11. package/docs-site/architecture.html +1 -1
  12. package/docs-site/benchmark.html +1 -1
  13. package/docs-site/commands.html +1 -1
  14. package/docs-site/content/en/index.html +4 -4
  15. package/docs-site/content/en/whats-new.html +6 -0
  16. package/docs-site/content/index.html +4 -4
  17. package/docs-site/content/whats-new.html +6 -0
  18. package/docs-site/context-engine.html +1 -1
  19. package/docs-site/ecosystem.html +1 -1
  20. package/docs-site/en/architecture.html +1 -1
  21. package/docs-site/en/benchmark.html +1 -1
  22. package/docs-site/en/commands.html +1 -1
  23. package/docs-site/en/context-engine.html +1 -1
  24. package/docs-site/en/ecosystem.html +1 -1
  25. package/docs-site/en/index.html +5 -5
  26. package/docs-site/en/mcp-approval.html +1 -1
  27. package/docs-site/en/mcp-auth.html +1 -1
  28. package/docs-site/en/mcp-servers.html +1 -1
  29. package/docs-site/en/mcp.html +1 -1
  30. package/docs-site/en/permissions.html +1 -1
  31. package/docs-site/en/profiles.html +1 -1
  32. package/docs-site/en/quickstart.html +1 -1
  33. package/docs-site/en/runtime.html +1 -1
  34. package/docs-site/en/scope.html +1 -1
  35. package/docs-site/en/security.html +1 -1
  36. package/docs-site/en/team.html +1 -1
  37. package/docs-site/en/whats-new.html +7 -1
  38. package/docs-site/en/windows.html +1 -1
  39. package/docs-site/en/workflows.html +1 -1
  40. package/docs-site/index.html +5 -5
  41. package/docs-site/mcp-approval.html +1 -1
  42. package/docs-site/mcp-auth.html +1 -1
  43. package/docs-site/mcp-servers.html +1 -1
  44. package/docs-site/mcp.html +1 -1
  45. package/docs-site/permissions.html +1 -1
  46. package/docs-site/profiles.html +1 -1
  47. package/docs-site/quickstart.html +1 -1
  48. package/docs-site/runtime.html +1 -1
  49. package/docs-site/scope.html +1 -1
  50. package/docs-site/security.html +1 -1
  51. package/docs-site/team.html +1 -1
  52. package/docs-site/whats-new.html +7 -1
  53. package/docs-site/windows.html +1 -1
  54. package/docs-site/workflows.html +1 -1
  55. package/evals/private-holdout-v1/public-exposure.v2.json +2 -2
  56. package/package.json +1 -1
  57. package/packages/piagent-core/package.json +1 -1
  58. package/packages/piagent-webui/dist/client/assets/Alert-DGWhP2MM.js +1 -0
  59. package/packages/piagent-webui/dist/client/assets/Button-QItfZUNj.js +1 -0
  60. package/packages/piagent-webui/dist/client/assets/{DialogTitle-CL-fzCnT.js → DialogTitle-CyaFPaiW.js} +3 -3
  61. package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-k4tq1y8s.js → MarkdownMessage-DtEwqme0.js} +2 -2
  62. package/packages/piagent-webui/dist/client/assets/TerminalPanel-C3vkzjQ6.js +2 -0
  63. package/packages/piagent-webui/dist/client/assets/{TerminalView-B_a16moC.js → TerminalView-TNjhBGfa.js} +3 -3
  64. package/packages/piagent-webui/dist/client/assets/Typography-B9om7Evq.js +1 -0
  65. package/packages/piagent-webui/dist/client/assets/WorkspaceCodeEditor-BAhYwQNM.js +2 -0
  66. package/packages/piagent-webui/dist/client/assets/WorkspaceExplorer-Coh_GWCO.js +5 -0
  67. package/packages/piagent-webui/dist/client/assets/WorkspaceQuickOpen-Bn4miZq4.js +1 -0
  68. package/packages/piagent-webui/dist/client/assets/{dist-_JsfplOG.js → dist-B5MCHZv5.js} +2 -2
  69. package/packages/piagent-webui/dist/client/assets/dist-BM_LL1o9.js +1 -0
  70. package/packages/piagent-webui/dist/client/assets/dist-C2TMLUTo.js +23 -0
  71. package/packages/piagent-webui/dist/client/assets/dist-CqL3udNu.js +1 -0
  72. package/packages/piagent-webui/dist/client/assets/{dist-nvgpa2Us.js → dist-D4df0jLQ.js} +1 -1
  73. package/packages/piagent-webui/dist/client/assets/{dist-B1M7IjfA.js → dist-D6i5SpQu.js} +1 -1
  74. package/packages/piagent-webui/dist/client/assets/dist-DfjUS8LS.js +6 -0
  75. package/packages/piagent-webui/dist/client/assets/{dist-idN8f9Fc.js → dist-IRUjhd1P.js} +1 -1
  76. package/packages/piagent-webui/dist/client/assets/{dist-DcEu_WYV.js → dist-sNhoSseW.js} +1 -1
  77. package/packages/piagent-webui/dist/client/assets/index-a-perpOX.js +102 -0
  78. package/packages/piagent-webui/dist/client/assets/tab-close-nAxrK7Lq.js +1 -0
  79. package/packages/piagent-webui/dist/client/assets/ui-preferences-BO3AV7QE.js +10 -0
  80. package/packages/piagent-webui/dist/client/assets/useId-DEefKUAT.js +124 -0
  81. package/packages/piagent-webui/dist/client/index.html +7 -7
  82. package/packages/piagent-webui/package.json +1 -0
  83. package/packages/piagent-webui/dist/client/assets/Alert-DXF8-XqE.js +0 -1
  84. package/packages/piagent-webui/dist/client/assets/Button-DZJosXQi.js +0 -1
  85. package/packages/piagent-webui/dist/client/assets/TerminalPanel-DvOPgrGI.js +0 -2
  86. package/packages/piagent-webui/dist/client/assets/Typography-DMZL1kLS.js +0 -1
  87. package/packages/piagent-webui/dist/client/assets/WorkspaceCodeEditor-BCiYM9NA.js +0 -2
  88. package/packages/piagent-webui/dist/client/assets/WorkspaceExplorer-DttpQtpf.js +0 -5
  89. package/packages/piagent-webui/dist/client/assets/WorkspaceQuickOpen-fgXwQ46B.js +0 -1
  90. package/packages/piagent-webui/dist/client/assets/dist-BUYtGaUP.js +0 -1
  91. package/packages/piagent-webui/dist/client/assets/dist-C82AtDDT.js +0 -6
  92. package/packages/piagent-webui/dist/client/assets/dist-D9b8j6pJ.js +0 -1
  93. package/packages/piagent-webui/dist/client/assets/dist-DLfpWwLs.js +0 -23
  94. package/packages/piagent-webui/dist/client/assets/index-BW8-BUMx.js +0 -102
  95. package/packages/piagent-webui/dist/client/assets/tab-close-HE0XxoJf.js +0 -1
  96. package/packages/piagent-webui/dist/client/assets/ui-preferences-DiddStu0.js +0 -124
  97. package/packages/piagent-webui/dist/client/assets/useTheme-_ESOj7MI.js +0 -10
@@ -1,102 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkdownMessage-k4tq1y8s.js","assets/rolldown-runtime-hePW80VL.js","assets/useTheme-_ESOj7MI.js","assets/ui-preferences-DiddStu0.js","assets/Typography-DMZL1kLS.js","assets/WorkspaceQuickOpen-fgXwQ46B.js","assets/DialogTitle-CL-fzCnT.js","assets/Alert-DXF8-XqE.js","assets/workspace-api-O7auv_td.js","assets/bootstrap-CedkNtRG.js","assets/TerminalPanel-DvOPgrGI.js","assets/Button-DZJosXQi.js","assets/tab-close-HE0XxoJf.js","assets/WorkspaceExplorer-DttpQtpf.js"])))=>i.map(i=>d[i]);
2
- import{r as e,t}from"./rolldown-runtime-hePW80VL.js";import{C as n,D as r,E as i,F as a,H as o,N as s,O as c,S as l,T as u,U as d,b as f,c as p,d as m,f as h,g,h as _,i as v,l as y,m as b,n as x,o as S,p as C,s as w,t as T,u as E,x as D,y as O}from"./useTheme-_ESOj7MI.js";import{C as k,D as A,E as j,O as M,S as N,T as P,_ as F,a as I,b as L,c as R,d as z,f as B,g as V,h as ee,i as te,k as ne,l as re,m as ie,n as ae,o as oe,p as se,r as ce,s as le,t as ue,u as de,v as fe,w as pe,y as me}from"./DialogTitle-CL-fzCnT.js";import{A as he,C as ge,D as H,E as _e,F as ve,L as ye,M as be,N as xe,O as Se,P as Ce,R as we,S as U,T as Te,_ as Ee,a as De,b as Oe,c as ke,d as Ae,f as je,g as Me,i as Ne,j as Pe,l as Fe,m as Ie,n as W,o as Le,p as Re,r as ze,s as Be,t as Ve,v as G,w as He,x as Ue,y as We}from"./ui-preferences-DiddStu0.js";import{C as Ge,D as Ke,E as qe,_ as Je,a as Ye,b as Xe,c as Ze,f as Qe,g as $e,h as et,i as tt,l as nt,m as K,n as rt,o as it,p as at,s as ot,t as st,u as ct,x as lt,y as ut}from"./Alert-DXF8-XqE.js";import{n as dt,r as ft,t as q}from"./Typography-DMZL1kLS.js";import{t as J}from"./Button-DZJosXQi.js";import{a as pt,i as mt,n as ht,o as gt,r as _t,s as vt,t as yt}from"./bootstrap-CedkNtRG.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var bt=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),xt=t(((e,t)=>{t.exports=bt()})),St=t((e=>{var t=xt(),n=d(),r=ne();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var p=Object.assign,m=Symbol.for(`react.element`),h=Symbol.for(`react.transitional.element`),g=Symbol.for(`react.portal`),_=Symbol.for(`react.fragment`),v=Symbol.for(`react.strict_mode`),y=Symbol.for(`react.profiler`),b=Symbol.for(`react.consumer`),x=Symbol.for(`react.context`),S=Symbol.for(`react.forward_ref`),C=Symbol.for(`react.suspense`),w=Symbol.for(`react.suspense_list`),T=Symbol.for(`react.memo`),E=Symbol.for(`react.lazy`),D=Symbol.for(`react.activity`),O=Symbol.for(`react.memo_cache_sentinel`),k=Symbol.iterator;function A(e){return typeof e!=`object`||!e?null:(e=k&&e[k]||e[`@@iterator`],typeof e==`function`?e:null)}var j=Symbol.for(`react.client.reference`);function M(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===j?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case _:return`Fragment`;case y:return`Profiler`;case v:return`StrictMode`;case C:return`Suspense`;case w:return`SuspenseList`;case D:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case g:return`Portal`;case x:return e.displayName||`Context`;case b:return(e._context.displayName||`Context`)+`.Consumer`;case S:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case T:return t=e.displayName||null,t===null?M(e.type)||`Memo`:t;case E:t=e._payload,e=e._init;try{return M(e(t))}catch{}}return null}var N=Array.isArray,P=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I={pending:!1,data:null,method:null,action:null},L=[],R=-1;function z(e){return{current:e}}function B(e){0>R||(e.current=L[R],L[R]=null,R--)}function V(e,t){R++,L[R]=e.current,e.current=t}var ee=z(null),te=z(null),re=z(null),ie=z(null);function ae(e,t){switch(V(re,t),V(te,e),V(ee,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(ee),V(ee,e)}function oe(){B(ee),B(te),B(re)}function se(e){e.memoizedState!==null&&V(ie,e);var t=ee.current,n=Hd(t,e.type);t!==n&&(V(te,e),V(ee,n))}function ce(e){te.current===e&&(B(ee),B(te)),ie.current===e&&(B(ie),Qf._currentValue=I)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
3
- at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
- `+le+e+ue}var fe=!1;function pe(e,t){if(!e||fe)return``;fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
- `),l=s.split(`
6
- `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
- `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?de(n):``}function me(e,t){switch(e.tag){case 26:case 27:case 5:return de(e.type);case 16:return de(`Lazy`);case 13:return e.child!==t&&t!==null?de(`Suspense Fallback`):de(`Suspense`);case 19:return de(`SuspenseList`);case 0:case 15:return pe(e.type,!1);case 11:return pe(e.type.render,!1);case 1:return pe(e.type,!0);case 31:return de(`Activity`);default:return``}}function he(e){try{var t=``,n=null;do t+=me(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
- Error generating stack: `+e.message+`
9
- `+e.stack}}var ge=Object.prototype.hasOwnProperty,H=t.unstable_scheduleCallback,_e=t.unstable_cancelCallback,ve=t.unstable_shouldYield,ye=t.unstable_requestPaint,be=t.unstable_now,xe=t.unstable_getCurrentPriorityLevel,Se=t.unstable_ImmediatePriority,Ce=t.unstable_UserBlockingPriority,we=t.unstable_NormalPriority,U=t.unstable_LowPriority,Te=t.unstable_IdlePriority,Ee=t.log,De=t.unstable_setDisableYieldValue,Oe=null,ke=null;function Ae(e){if(typeof Ee==`function`&&De(e),ke&&typeof ke.setStrictMode==`function`)try{ke.setStrictMode(Oe,e)}catch{}}var je=Math.clz32?Math.clz32:Pe,Me=Math.log,Ne=Math.LN2;function Pe(e){return e>>>=0,e===0?32:31-(Me(e)/Ne|0)|0}var Fe=256,Ie=262144,W=4194304;function Le(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Re(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Le(n))):i=Le(o):i=Le(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Le(n))):i=Le(o)):i=Le(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function ze(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Be(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ve(){var e=W;return W<<=1,!(W&62914560)&&(W=4194304),e}function G(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function He(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function Ue(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-je(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&We(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function We(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-je(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ge(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-je(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Ke(e,t){var n=t&-t;return n=n&42?1:qe(n),(n&(e.suspendedLanes|t))===0?n:0}function qe(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Je(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function Ye(){var e=F.p;return e===0?(e=window.event,e===void 0?32:mp(e.type)):e}function Xe(e,t){var n=F.p;try{return F.p=e,t()}finally{F.p=n}}var Ze=Math.random().toString(36).slice(2),Qe=`__reactFiber$`+Ze,$e=`__reactProps$`+Ze,et=`__reactContainer$`+Ze,tt=`__reactEvents$`+Ze,nt=`__reactListeners$`+Ze,K=`__reactHandles$`+Ze,rt=`__reactResources$`+Ze,it=`__reactMarker$`+Ze;function at(e){delete e[Qe],delete e[$e],delete e[tt],delete e[nt],delete e[K]}function ot(e){var t=e[Qe];if(t)return t;for(var n=e.parentNode;n;){if(t=n[et]||n[Qe]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=df(e);e!==null;){if(n=e[Qe])return n;e=df(e)}return t}e=n,n=e.parentNode}return null}function st(e){if(e=e[Qe]||e[et]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function ct(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function lt(e){var t=e[rt];return t||=e[rt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function ut(e){e[it]=!0}var dt=new Set,ft={};function q(e,t){J(e,t),J(e+`Capture`,t)}function J(e,t){for(ft[e]=t,e=0;e<t.length;e++)dt.add(t[e])}var pt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),mt={},ht={};function gt(e){return ge.call(ht,e)?!0:ge.call(mt,e)?!1:pt.test(e)?ht[e]=!0:(mt[e]=!0,!1)}function _t(e,t,n){if(gt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}}function vt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function yt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function bt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function St(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ct(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Y(e){if(!e._valueTracker){var t=St(e)?`checked`:`value`;e._valueTracker=Ct(e,t,``+e[t])}}function X(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=St(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function wt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Tt=/[\n"\\]/g;function Et(e){return e.replace(Tt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Dt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+bt(t)):e.value!==``+bt(t)&&(e.value=``+bt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):kt(e,o,bt(n)):kt(e,o,bt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+bt(s):e.removeAttribute(`name`)}function Ot(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Y(e);return}n=n==null?``:``+bt(n),t=t==null?n:``+bt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Y(e)}function kt(e,t,n){t===`number`&&wt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function At(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+bt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function jt(e,t,n){if(t!=null&&(t=``+bt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+bt(n)}function Mt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(N(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=bt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Y(e)}function Nt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Pt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Ft(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Pt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function It(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&Ft(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Ft(e,o,t[o])}function Lt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Rt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),zt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function Bt(e){return zt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Vt(){}var Ht=null;function Ut(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Wt=null,Gt=null;function Kt(e){var t=st(e);if(t&&(e=t.stateNode)){var n=e[$e]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Dt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Et(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[$e]||null;if(!a)throw Error(i(90));Dt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&X(r)}break a;case`textarea`:jt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&At(e,!!n.multiple,t,!1)}}}var qt=!1;function Jt(e,t,n){if(qt)return e(t,n);qt=!0;try{return e(t)}finally{if(qt=!1,(Wt!==null||Gt!==null)&&(_u(),Wt&&(t=Wt,e=Gt,Gt=Wt=null,Kt(t),e)))for(t=0;t<e.length;t++)Kt(e[t])}}function Yt(e,t){var n=e.stateNode;if(n===null)return null;var r=n[$e]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Xt=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Zt=!1;if(Xt)try{var Qt={};Object.defineProperty(Qt,"passive",{get:function(){Zt=!0}}),window.addEventListener(`test`,Qt,Qt),window.removeEventListener(`test`,Qt,Qt)}catch{Zt=!1}var $t=null,en=null,tn=null;function nn(){if(tn)return tn;var e,t=en,n=t.length,r,i=`value`in $t?$t.value:$t.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return tn=i.slice(e,1<r?1-r:void 0)}function rn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function an(){return!0}function on(){return!1}function sn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?an:on,this.isPropagationStopped=on,this}return p(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=an)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=an)},persist:function(){},isPersistent:an}),t}var cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},ln=sn(cn),un=p({},cn,{view:0,detail:0}),dn=sn(un),fn,pn,mn,hn=p({},un,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:En,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==mn&&(mn&&e.type===`mousemove`?(fn=e.screenX-mn.screenX,pn=e.screenY-mn.screenY):pn=fn=0,mn=e),fn)},movementY:function(e){return`movementY`in e?e.movementY:pn}}),gn=sn(hn),_n=sn(p({},hn,{dataTransfer:0})),vn=sn(p({},un,{relatedTarget:0})),yn=sn(p({},cn,{animationName:0,elapsedTime:0,pseudoElement:0})),bn=sn(p({},cn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),xn=sn(p({},cn,{data:0})),Sn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Cn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},wn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Tn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=wn[e])?!!t[e]:!1}function En(){return Tn}var Dn=sn(p({},un,{key:function(e){if(e.key){var t=Sn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=rn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Cn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:En,charCode:function(e){return e.type===`keypress`?rn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?rn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),On=sn(p({},hn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),kn=sn(p({},un,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:En})),An=sn(p({},cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),jn=sn(p({},hn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Mn=sn(p({},cn,{newState:0,oldState:0})),Nn=[9,13,27,32],Pn=Xt&&`CompositionEvent`in window,Fn=null;Xt&&`documentMode`in document&&(Fn=document.documentMode);var In=Xt&&`TextEvent`in window&&!Fn,Ln=Xt&&(!Pn||Fn&&8<Fn&&11>=Fn),Rn=` `,zn=!1;function Bn(e,t){switch(e){case`keyup`:return Nn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function Vn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Hn=!1;function Un(e,t){switch(e){case`compositionend`:return Vn(t);case`keypress`:return t.which===32?(zn=!0,Rn):null;case`textInput`:return e=t.data,e===Rn&&zn?null:e;default:return null}}function Wn(e,t){if(Hn)return e===`compositionend`||!Pn&&Bn(e,t)?(e=nn(),tn=en=$t=null,Hn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Ln&&t.locale!==`ko`?null:t.data;default:return null}}var Gn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Kn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Gn[e.type]:t===`textarea`}function Z(e,t,n,r){Wt?Gt?Gt.push(r):Gt=[r]:Wt=r,t=Td(t,`onChange`),0<t.length&&(n=new ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var qn=null,Jn=null;function Yn(e){_d(e,0)}function Xn(e){if(X(ct(e)))return e}function Zn(e,t){if(e===`change`)return t}var Qn=!1;if(Xt){var $n;if(Xt){var er=`oninput`in document;if(!er){var tr=document.createElement(`div`);tr.setAttribute(`oninput`,`return;`),er=typeof tr.oninput==`function`}$n=er}else $n=!1;Qn=$n&&(!document.documentMode||9<document.documentMode)}function nr(){qn&&(qn.detachEvent(`onpropertychange`,rr),Jn=qn=null)}function rr(e){if(e.propertyName===`value`&&Xn(Jn)){var t=[];Z(t,Jn,e,Ut(e)),Jt(Yn,t)}}function ir(e,t,n){e===`focusin`?(nr(),qn=t,Jn=n,qn.attachEvent(`onpropertychange`,rr)):e===`focusout`&&nr()}function ar(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Xn(Jn)}function or(e,t){if(e===`click`)return Xn(t)}function sr(e,t){if(e===`input`||e===`change`)return Xn(t)}function cr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var lr=typeof Object.is==`function`?Object.is:cr;function ur(e,t){if(lr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ge.call(t,i)||!lr(e[i],t[i]))return!1}return!0}function dr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function fr(e,t){var n=dr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=dr(n)}}function pr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?pr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function mr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=wt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=wt(e.document)}return t}function hr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var gr=Xt&&`documentMode`in document&&11>=document.documentMode,_r=null,vr=null,yr=null,br=!1;function xr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;br||_r==null||_r!==wt(r)||(r=_r,`selectionStart`in r&&hr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),yr&&ur(yr,r)||(yr=r,r=Td(vr,`onSelect`),0<r.length&&(t=new ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=_r)))}function Sr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Cr={animationend:Sr(`Animation`,`AnimationEnd`),animationiteration:Sr(`Animation`,`AnimationIteration`),animationstart:Sr(`Animation`,`AnimationStart`),transitionrun:Sr(`Transition`,`TransitionRun`),transitionstart:Sr(`Transition`,`TransitionStart`),transitioncancel:Sr(`Transition`,`TransitionCancel`),transitionend:Sr(`Transition`,`TransitionEnd`)},wr={},Tr={};Xt&&(Tr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Cr.animationend.animation,delete Cr.animationiteration.animation,delete Cr.animationstart.animation),`TransitionEvent`in window||delete Cr.transitionend.transition);function Er(e){if(wr[e])return wr[e];if(!Cr[e])return e;var t=Cr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Tr)return wr[e]=t[n];return e}var Dr=Er(`animationend`),Or=Er(`animationiteration`),kr=Er(`animationstart`),Ar=Er(`transitionrun`),jr=Er(`transitionstart`),Mr=Er(`transitioncancel`),Nr=Er(`transitionend`),Pr=new Map,Fr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Fr.push(`scrollEnd`);function Ir(e,t){Pr.set(e,t),q(t,[e])}var Lr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Q=[],Rr=0,zr=0;function Br(){for(var e=Rr,t=zr=Rr=0;t<e;){var n=Q[t];Q[t++]=null;var r=Q[t];Q[t++]=null;var i=Q[t];Q[t++]=null;var a=Q[t];if(Q[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Wr(n,i,a)}}function Vr(e,t,n,r){Q[Rr++]=e,Q[Rr++]=t,Q[Rr++]=n,Q[Rr++]=r,zr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Hr(e,t,n,r){return Vr(e,t,n,r),Gr(e)}function Ur(e,t){return Vr(e,null,null,t),Gr(e)}function Wr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-je(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Gr(e){if(50<cu)throw cu=0,lu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Kr={};function qr(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Jr(e,t,n,r){return new qr(e,t,n,r)}function Yr(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Xr(e,t){var n=e.alternate;return n===null?(n=Jr(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Zr(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Qr(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)Yr(e)&&(s=1);else if(typeof e==`string`)s=Uf(e,n,ee.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case D:return e=Jr(31,n,t,a),e.elementType=D,e.lanes=o,e;case _:return $r(n.children,a,o,t);case v:s=8,a|=24;break;case y:return e=Jr(12,n,t,a|2),e.elementType=y,e.lanes=o,e;case C:return e=Jr(13,n,t,a),e.elementType=C,e.lanes=o,e;case w:return e=Jr(19,n,t,a),e.elementType=w,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case x:s=10;break a;case b:s=9;break a;case S:s=11;break a;case T:s=14;break a;case E:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Jr(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function $r(e,t,n,r){return e=Jr(7,e,r,t),e.lanes=n,e}function ei(e,t,n){return e=Jr(6,e,null,t),e.lanes=n,e}function ti(e){var t=Jr(18,null,null,0);return t.stateNode=e,t}function ni(e,t,n){return t=Jr(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var ri=new WeakMap;function ii(e,t){if(typeof e==`object`&&e){var n=ri.get(e);return n===void 0?(t={value:e,source:t,stack:he(t)},ri.set(e,t),t):n}return{value:e,source:t,stack:he(t)}}var ai=[],oi=0,si=null,ci=0,li=[],ui=0,di=null,fi=1,pi=``;function mi(e,t){ai[oi++]=ci,ai[oi++]=si,si=e,ci=t}function hi(e,t,n){li[ui++]=fi,li[ui++]=pi,li[ui++]=di,di=e;var r=fi;e=pi;var i=32-je(r)-1;r&=~(1<<i),n+=1;var a=32-je(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,fi=1<<32-je(t)+i|n<<i|r,pi=a+e}else fi=1<<a|n<<i|r,pi=e}function gi(e){e.return!==null&&(mi(e,1),hi(e,1,0))}function _i(e){for(;e===si;)si=ai[--oi],ai[oi]=null,ci=ai[--oi],ai[oi]=null;for(;e===di;)di=li[--ui],li[ui]=null,pi=li[--ui],li[ui]=null,fi=li[--ui],li[ui]=null}function vi(e,t){li[ui++]=fi,li[ui++]=pi,li[ui++]=di,fi=t.id,pi=t.overflow,di=e}var yi=null,bi=null,xi=!1,Si=null,Ci=!1,wi=Error(i(519));function Ti(e){throw ji(ii(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),wi}function Ei(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[Qe]=e,t[$e]=r,n){case`dialog`:vd(`cancel`,t),vd(`close`,t);break;case`iframe`:case`object`:case`embed`:vd(`load`,t);break;case`video`:case`audio`:for(n=0;n<hd.length;n++)vd(hd[n],t);break;case`source`:vd(`error`,t);break;case`img`:case`image`:case`link`:vd(`error`,t),vd(`load`,t);break;case`details`:vd(`toggle`,t);break;case`input`:vd(`invalid`,t),Ot(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:vd(`invalid`,t);break;case`textarea`:vd(`invalid`,t),Mt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||jd(t.textContent,n)?(r.popover!=null&&(vd(`beforetoggle`,t),vd(`toggle`,t)),r.onScroll!=null&&vd(`scroll`,t),r.onScrollEnd!=null&&vd(`scrollend`,t),r.onClick!=null&&(t.onclick=Vt),t=!0):t=!1,t||Ti(e,!0)}function Di(e){for(yi=e.return;yi;)switch(yi.tag){case 5:case 31:case 13:Ci=!1;return;case 27:case 3:Ci=!0;return;default:yi=yi.return}}function Oi(e){if(e!==yi)return!1;if(!xi)return Di(e),xi=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||Ud(e.type,e.memoizedProps)),n=!n),n&&bi&&Ti(e),Di(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));bi=uf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));bi=uf(e)}else t===27?(t=bi,Zd(e.type)?(e=lf,lf=null,bi=e):bi=t):bi=yi?cf(e.stateNode.nextSibling):null;return!0}function ki(){bi=yi=null,xi=!1}function Ai(){var e=Si;return e!==null&&(Jl===null?Jl=e:Jl.push.apply(Jl,e),Si=null),e}function ji(e){Si===null?Si=[e]:Si.push(e)}var Mi=z(null),Ni=null,Pi=null;function Fi(e,t,n){V(Mi,t._currentValue),t._currentValue=n}function Ii(e){e._currentValue=Mi.current,B(Mi)}function Li(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ri(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),Li(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),Li(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function zi(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;lr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===ie.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[Qf]:e.push(Qf))}a=a.return}e!==null&&Ri(t,e,n,r),t.flags|=262144}function Bi(e){for(e=e.firstContext;e!==null;){if(!lr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Vi(e){Ni=e,Pi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Hi(e){return Wi(Ni,e)}function Ui(e,t){return Ni===null&&Vi(e),Wi(e,t)}function Wi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Pi===null){if(e===null)throw Error(i(308));Pi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Pi=Pi.next=t;return n}var Gi=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Ki=t.unstable_scheduleCallback,qi=t.unstable_NormalPriority,Ji={$$typeof:x,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Yi(){return{controller:new Gi,data:new Map,refCount:0}}function Xi(e){e.refCount--,e.refCount===0&&Ki(qi,function(){e.controller.abort()})}var Zi=null,Qi=0,$i=0,ea=null;function ta(e,t){if(Zi===null){var n=Zi=[];Qi=0,$i=ld(),ea={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return Qi++,t.then(na,na),t}function na(){if(--Qi===0&&Zi!==null){ea!==null&&(ea.status=`fulfilled`);var e=Zi;Zi=null,$i=0,ea=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ra(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var ia=P.S;P.S=function(e,t){Zl=be(),typeof t==`object`&&t&&typeof t.then==`function`&&ta(e,t),ia!==null&&ia(e,t)};var aa=z(null);function oa(){var e=aa.current;return e===null?Nl.pooledCache:e}function sa(e,t){t===null?V(aa,aa.current):V(aa,t.pool)}function ca(){var e=oa();return e===null?null:{parent:Ji._currentValue,pool:e}}var la=Error(i(460)),ua=Error(i(474)),da=Error(i(542)),fa={then:function(){}};function pa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ma(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Vt,Vt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,va(e),e;default:if(typeof t.status==`string`)t.then(Vt,Vt);else{if(e=Nl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,va(e),e}throw ga=t,la}}function ha(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(ga=e,la):e}}var ga=null;function _a(){if(ga===null)throw Error(i(459));var e=ga;return ga=null,e}function va(e){if(e===la||e===da)throw Error(i(483))}var ya=null,ba=0;function xa(e){var t=ba;return ba+=1,ya===null&&(ya=[]),ma(ya,e,t)}function Sa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ca(e,t){throw t.$$typeof===m?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function wa(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Xr(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ei(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===_?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===E&&ha(i)===t.type)?(t=a(t,n.props),Sa(t,n),t.return=e,t):(t=Qr(n.type,n.key,n.props,null,e.mode,r),Sa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ni(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=$r(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ei(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case h:return n=Qr(t.type,t.key,t.props,null,e.mode,n),Sa(n,t),n.return=e,n;case g:return t=ni(t,e.mode,n),t.return=e,t;case E:return t=ha(t),f(e,t,n)}if(N(t)||A(t))return t=$r(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,xa(t),n);if(t.$$typeof===x)return f(e,Ui(e,t),n);Ca(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case h:return n.key===i?l(e,t,n,r):null;case g:return n.key===i?u(e,t,n,r):null;case E:return n=ha(n),p(e,t,n,r)}if(N(n)||A(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,xa(n),r);if(n.$$typeof===x)return p(e,t,Ui(e,n),r);Ca(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case h:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case g:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case E:return r=ha(r),m(e,t,n,r,i)}if(N(r)||A(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,xa(r),i);if(r.$$typeof===x)return m(e,t,n,Ui(t,r),i);Ca(t,r)}return null}function v(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),xi&&mi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return xi&&mi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),xi&&mi(i,h),l}function y(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),xi&&mi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return xi&&mi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),xi&&mi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===_&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case h:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===_){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===E&&ha(l)===r.type){n(e,r.sibling),c=a(r,o.props),Sa(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===_?(c=$r(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=Qr(o.type,o.key,o.props,null,e.mode,c),Sa(c,o),c.return=e,e=c)}return s(e);case g:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=ni(o,e.mode,c),c.return=e,e=c}return s(e);case E:return o=ha(o),b(e,r,o,c)}if(N(o))return v(e,r,o,c);if(A(o)){if(l=A(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),y(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,xa(o),c);if(o.$$typeof===x)return b(e,r,Ui(e,o),c);Ca(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=ei(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ba=0;var i=b(e,t,n,r);return ya=null,i}catch(t){if(t===la||t===da)throw t;var a=Jr(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ta=wa(!0),Ea=wa(!1),Da=!1;function Oa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ka(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Aa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function ja(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ml&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Gr(e),Wr(e,null,n),t}return Vr(e,r,t,n),Gr(e)}function Ma(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}function Na(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Pa=!1;function Fa(){if(Pa){var e=ea;if(e!==null)throw e}}function Ia(e,t,n,r){Pa=!1;var i=e.updateQueue;Da=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,m=f!==s.lane;if(m?(Fl&f)===f:(r&f)===f){f!==0&&f===$i&&(Pa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=p({},d,f);break a;case 2:Da=!0}}f=s.callback,f!==null&&(e.flags|=64,m&&(e.flags|=8192),m=i.callbacks,m===null?i.callbacks=[f]:m.push(f))}else m={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=m,c=d):u=u.next=m,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;m=s,s=m.next,m.next=null,i.lastBaseUpdate=m,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),$|=o,e.lanes=o,e.memoizedState=d}}function La(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function Ra(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)La(n[e],t)}var za=z(null),Ba=z(0);function Va(e,t){e=Vl,V(Ba,e),V(za,t),Vl=e|t.baseLanes}function Ha(){V(Ba,Vl),V(za,za.current)}function Ua(){Vl=Ba.current,B(za),B(Ba)}var Wa=z(null),Ga=null;function Ka(e){var t=e.alternate;V(Za,Za.current&1),V(Wa,e),Ga===null&&(t===null||za.current!==null||t.memoizedState!==null)&&(Ga=e)}function qa(e){V(Za,Za.current),V(Wa,e),Ga===null&&(Ga=e)}function Ja(e){e.tag===22?(V(Za,Za.current),V(Wa,e),Ga===null&&(Ga=e)):Ya(e)}function Ya(){V(Za,Za.current),V(Wa,Wa.current)}function Xa(e){B(Wa),Ga===e&&(Ga=null),B(Za)}var Za=z(0);function Qa(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||af(n)||of(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var $a=0,eo=null,to=null,no=null,ro=!1,io=!1,ao=!1,oo=0,so=0,co=null,lo=0;function uo(){throw Error(i(321))}function fo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!lr(e[n],t[n]))return!1;return!0}function po(e,t,n,r,i,a){return $a=a,eo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,P.H=e===null||e.memoizedState===null?As:js,ao=!1,a=n(r,i),ao=!1,io&&(a=ho(t,n,r,i)),mo(e),a}function mo(e){P.H=ks;var t=to!==null&&to.next!==null;if($a=0,no=to=eo=null,ro=!1,so=0,co=null,t)throw Error(i(300));e===null||Js||(e=e.dependencies,e!==null&&Bi(e)&&(Js=!0))}function ho(e,t,n,r){eo=e;var a=0;do{if(io&&(co=null),so=0,io=!1,25<=a)throw Error(i(301));if(a+=1,no=to=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}P.H=Ms,o=t(n,r)}while(io);return o}function go(){var e=P.H,t=e.useState()[0];return t=typeof t.then==`function`?Co(t):t,e=e.useState()[0],(to===null?null:to.memoizedState)!==e&&(eo.flags|=1024),t}function _o(){var e=oo!==0;return oo=0,e}function vo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function yo(e){if(ro){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}ro=!1}$a=0,no=to=eo=null,io=!1,so=oo=0,co=null}function bo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return no===null?eo.memoizedState=no=e:no=no.next=e,no}function xo(){if(to===null){var e=eo.alternate;e=e===null?null:e.memoizedState}else e=to.next;var t=no===null?eo.memoizedState:no.next;if(t!==null)no=t,to=e;else{if(e===null)throw eo.alternate===null?Error(i(467)):Error(i(310));to=e,e={memoizedState:to.memoizedState,baseState:to.baseState,baseQueue:to.baseQueue,queue:to.queue,next:null},no===null?eo.memoizedState=no=e:no=no.next=e}return no}function So(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Co(e){var t=so;return so+=1,co===null&&(co=[]),e=ma(co,e,t),t=eo,(no===null?t.memoizedState:no.next)===null&&(t=t.alternate,P.H=t===null||t.memoizedState===null?As:js),e}function wo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Co(e);if(e.$$typeof===x)return Hi(e)}throw Error(i(438,String(e)))}function To(e){var t=null,n=eo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=eo.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=So(),eo.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=O;return t.index++,n}function Eo(e,t){return typeof t==`function`?t(e):t}function Do(e){return Oo(xo(),to,e)}function Oo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?($a&f)===f:(Fl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===$i&&(d=!0);else if(($a&p)===p){u=u.next,p===$i&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,eo.lanes|=p,$|=p;f=u.action,ao&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,eo.lanes|=f,$|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!lr(o,e.memoizedState)&&(Js=!0,d&&(n=ea,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function ko(e){var t=xo(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);lr(o,t.memoizedState)||(Js=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Ao(e,t,n){var r=eo,a=xo(),o=xi;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!lr((to||a).memoizedState,n);if(s&&(a.memoizedState=n,Js=!0),a=a.queue,ts(No.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||no!==null&&no.memoizedState.tag&1){if(r.flags|=2048,Xo(9,{destroy:void 0},Mo.bind(null,r,a,n,t),null),Nl===null)throw Error(i(349));o||$a&127||jo(r,t,n)}return n}function jo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=eo.updateQueue,t===null?(t=So(),eo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Mo(e,t,n,r){t.value=n,t.getSnapshot=r,Po(t)&&Fo(e)}function No(e,t,n){return n(function(){Po(t)&&Fo(e)})}function Po(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!lr(e,n)}catch{return!0}}function Fo(e){var t=Ur(e,2);t!==null&&fu(t,e,2)}function Io(e){var t=bo();if(typeof e==`function`){var n=e;if(e=n(),ao){Ae(!0);try{n()}finally{Ae(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:e},t}function Lo(e,t,n,r){return e.baseState=n,Oo(e,to,typeof r==`function`?r:Eo)}function Ro(e,t,n,r,a){if(Es(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};P.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,zo(t,o)):(o.next=n.next,t.pending=n.next=o)}}function zo(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=P.T,o={};P.T=o;try{var s=n(i,r),c=P.S;c!==null&&c(o,s),Bo(e,t,s)}catch(n){Ho(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),P.T=a}}else try{a=n(i,r),Bo(e,t,a)}catch(n){Ho(e,t,n)}}function Bo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Vo(e,t,n)},function(n){return Ho(e,t,n)}):Vo(e,t,n)}function Vo(e,t,n){t.status=`fulfilled`,t.value=n,Uo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,zo(e,n)))}function Ho(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Uo(t),t=t.next;while(t!==r)}e.action=null}function Uo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Wo(e,t){return t}function Go(e,t){if(xi){var n=Nl.formState;if(n!==null){a:{var r=eo;if(xi){if(bi){b:{for(var i=bi,a=Ci;i.nodeType!==8;){if(!a){i=null;break b}if(i=cf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){bi=cf(i.nextSibling),r=i.data===`F!`;break a}}Ti(r)}r=!1}r&&(t=n[0])}}return n=bo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wo,lastRenderedState:t},n.queue=r,n=Cs.bind(null,eo,r),r.dispatch=n,r=Io(!1),a=Ts.bind(null,eo,!1,r.queue),r=bo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Ro.bind(null,eo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ko(e){return qo(xo(),to,e)}function qo(e,t,n){if(t=Oo(e,t,Wo)[0],e=Do(Eo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Co(t)}catch(e){throw e===la?da:e}else r=t;t=xo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(eo.flags|=2048,Xo(9,{destroy:void 0},Jo.bind(null,i,n),null)),[r,a,e]}function Jo(e,t){e.action=t}function Yo(e){var t=xo(),n=to;if(n!==null)return qo(t,n,e);xo(),t=t.memoizedState,n=xo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Xo(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=eo.updateQueue,t===null&&(t=So(),eo.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Zo(){return xo().memoizedState}function Qo(e,t,n,r){var i=bo();eo.flags|=e,i.memoizedState=Xo(1|t,{destroy:void 0},n,r===void 0?null:r)}function $o(e,t,n,r){var i=xo();r=r===void 0?null:r;var a=i.memoizedState.inst;to!==null&&r!==null&&fo(r,to.memoizedState.deps)?i.memoizedState=Xo(t,a,n,r):(eo.flags|=e,i.memoizedState=Xo(1|t,a,n,r))}function es(e,t){Qo(8390656,8,e,t)}function ts(e,t){$o(2048,8,e,t)}function ns(e){eo.flags|=4;var t=eo.updateQueue;if(t===null)t=So(),eo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function rs(e){var t=xo().memoizedState;return ns({ref:t,nextImpl:e}),function(){if(Ml&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function is(e,t){return $o(4,2,e,t)}function as(e,t){return $o(4,4,e,t)}function os(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ss(e,t,n){n=n==null?null:n.concat([e]),$o(4,4,os.bind(null,t,e),n)}function cs(){}function ls(e,t){var n=xo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&fo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function us(e,t){var n=xo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&fo(t,r[1]))return r[0];if(r=e(),ao){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r}function ds(e,t,n){return n===void 0||$a&1073741824&&!(Fl&261930)?e.memoizedState=t:(e.memoizedState=n,e=du(),eo.lanes|=e,$|=e,n)}function fs(e,t,n,r){return lr(n,t)?n:za.current===null?!($a&42)||$a&1073741824&&!(Fl&261930)?(Js=!0,e.memoizedState=n):(e=du(),eo.lanes|=e,$|=e,t):(e=ds(e,n,r),lr(e,t)||(Js=!0),e)}function ps(e,t,n,r,i){var a=F.p;F.p=a!==0&&8>a?a:8;var o=P.T,s={};P.T=s,Ts(e,!1,t,n);try{var c=i(),l=P.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?ws(e,t,ra(c,r),uu(e)):ws(e,t,r,uu(e))}catch(n){ws(e,t,{then:function(){},status:`rejected`,reason:n},uu())}finally{F.p=a,o!==null&&s.types!==null&&(o.types=s.types),P.T=o}}function ms(){}function hs(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=gs(e).queue;ps(e,a,t,I,n===null?ms:function(){return _s(e),n(r)})}function gs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:I,baseState:I,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:I},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Eo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function _s(e){var t=gs(e);t.next===null&&(t=e.alternate.memoizedState),ws(e,t.next.queue,{},uu())}function vs(){return Hi(Qf)}function ys(){return xo().memoizedState}function bs(){return xo().memoizedState}function xs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=uu();e=Aa(n);var r=ja(t,e,n);r!==null&&(fu(r,t,n),Ma(r,t,n)),t={cache:Yi()},e.payload=t;return}t=t.return}}function Ss(e,t,n){var r=uu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Es(e)?Ds(t,n):(n=Hr(e,t,n,r),n!==null&&(fu(n,e,r),Os(n,t,r)))}function Cs(e,t,n){ws(e,t,n,uu())}function ws(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Es(e))Ds(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,lr(s,o))return Vr(e,t,i,0),Nl===null&&Br(),!1}catch{}if(n=Hr(e,t,i,r),n!==null)return fu(n,e,r),Os(n,t,r),!0}return!1}function Ts(e,t,n,r){if(r={lane:2,revertLane:ld(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Es(e)){if(t)throw Error(i(479))}else t=Hr(e,n,r,2),t!==null&&fu(t,e,2)}function Es(e){var t=e.alternate;return e===eo||t!==null&&t===eo}function Ds(e,t){io=ro=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Os(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ge(e,n)}}var ks={readContext:Hi,use:wo,useCallback:uo,useContext:uo,useEffect:uo,useImperativeHandle:uo,useLayoutEffect:uo,useInsertionEffect:uo,useMemo:uo,useReducer:uo,useRef:uo,useState:uo,useDebugValue:uo,useDeferredValue:uo,useTransition:uo,useSyncExternalStore:uo,useId:uo,useHostTransitionStatus:uo,useFormState:uo,useActionState:uo,useOptimistic:uo,useMemoCache:uo,useCacheRefresh:uo};ks.useEffectEvent=uo;var As={readContext:Hi,use:wo,useCallback:function(e,t){return bo().memoizedState=[e,t===void 0?null:t],e},useContext:Hi,useEffect:es,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),Qo(4194308,4,os.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Qo(4194308,4,e,t)},useInsertionEffect:function(e,t){Qo(4,2,e,t)},useMemo:function(e,t){var n=bo();t=t===void 0?null:t;var r=e();if(ao){Ae(!0);try{e()}finally{Ae(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=bo();if(n!==void 0){var i=n(t);if(ao){Ae(!0);try{n(t)}finally{Ae(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ss.bind(null,eo,e),[r.memoizedState,e]},useRef:function(e){var t=bo();return e={current:e},t.memoizedState=e},useState:function(e){e=Io(e);var t=e.queue,n=Cs.bind(null,eo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:cs,useDeferredValue:function(e,t){return ds(bo(),e,t)},useTransition:function(){var e=Io(!1);return e=ps.bind(null,eo,e.queue,!0,!1),bo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=eo,a=bo();if(xi){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Nl===null)throw Error(i(349));Fl&127||jo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,es(No.bind(null,r,o,e),[e]),r.flags|=2048,Xo(9,{destroy:void 0},Mo.bind(null,r,o,n,t),null),n},useId:function(){var e=bo(),t=Nl.identifierPrefix;if(xi){var n=pi,r=fi;n=(r&~(1<<32-je(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=oo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=lo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:vs,useFormState:Go,useActionState:Go,useOptimistic:function(e){var t=bo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ts.bind(null,eo,!0,n),n.dispatch=t,[e,t]},useMemoCache:To,useCacheRefresh:function(){return bo().memoizedState=xs.bind(null,eo)},useEffectEvent:function(e){var t=bo(),n={impl:e};return t.memoizedState=n,function(){if(Ml&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},js={readContext:Hi,use:wo,useCallback:ls,useContext:Hi,useEffect:ts,useImperativeHandle:ss,useInsertionEffect:is,useLayoutEffect:as,useMemo:us,useReducer:Do,useRef:Zo,useState:function(){return Do(Eo)},useDebugValue:cs,useDeferredValue:function(e,t){return fs(xo(),to.memoizedState,e,t)},useTransition:function(){var e=Do(Eo)[0],t=xo().memoizedState;return[typeof e==`boolean`?e:Co(e),t]},useSyncExternalStore:Ao,useId:ys,useHostTransitionStatus:vs,useFormState:Ko,useActionState:Ko,useOptimistic:function(e,t){return Lo(xo(),to,e,t)},useMemoCache:To,useCacheRefresh:bs};js.useEffectEvent=rs;var Ms={readContext:Hi,use:wo,useCallback:ls,useContext:Hi,useEffect:ts,useImperativeHandle:ss,useInsertionEffect:is,useLayoutEffect:as,useMemo:us,useReducer:ko,useRef:Zo,useState:function(){return ko(Eo)},useDebugValue:cs,useDeferredValue:function(e,t){var n=xo();return to===null?ds(n,e,t):fs(n,to.memoizedState,e,t)},useTransition:function(){var e=ko(Eo)[0],t=xo().memoizedState;return[typeof e==`boolean`?e:Co(e),t]},useSyncExternalStore:Ao,useId:ys,useHostTransitionStatus:vs,useFormState:Yo,useActionState:Yo,useOptimistic:function(e,t){var n=xo();return to===null?(n.baseState=e,[e,n.queue.dispatch]):Lo(n,to,e,t)},useMemoCache:To,useCacheRefresh:bs};Ms.useEffectEvent=rs;function Ns(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:p({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ps={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=uu(),i=Aa(r);i.payload=t,n!=null&&(i.callback=n),t=ja(e,i,r),t!==null&&(fu(t,e,r),Ma(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=uu(),i=Aa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=ja(e,i,r),t!==null&&(fu(t,e,r),Ma(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=uu(),r=Aa(n);r.tag=2,t!=null&&(r.callback=t),t=ja(e,r,n),t!==null&&(fu(t,e,n),Ma(t,e,n))}};function Fs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!ur(n,r)||!ur(i,a):!0}function Is(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ps.enqueueReplaceState(t,t.state,null)}function Ls(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=p({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Rs(e){Lr(e)}function zs(e){console.error(e)}function Bs(e){Lr(e)}function Vs(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Hs(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Us(e,t,n){return n=Aa(n),n.tag=3,n.payload={element:null},n.callback=function(){Vs(e,t)},n}function Ws(e){return e=Aa(e),e.tag=3,e}function Gs(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Hs(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Hs(t,n,r),typeof i!=`function`&&(eu===null?eu=new Set([this]):eu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Ks(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&zi(t,n,a,!0),n=Wa.current,n!==null){switch(n.tag){case 31:case 13:return Ga===null?wu():n.alternate===null&&Hl===0&&(Hl=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===fa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Uu(e,r,a)),!1;case 22:return n.flags|=65536,r===fa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Uu(e,r,a)),!1}throw Error(i(435,n.tag))}return Uu(e,r,a),wu(),!1}if(xi)return t=Wa.current,t===null?(r!==wi&&(t=Error(i(423),{cause:r}),ji(ii(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=ii(r,n),a=Us(e.stateNode,r,a),Na(e,a),Hl!==4&&(Hl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==wi&&(e=Error(i(422),{cause:r}),ji(ii(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=ii(o,n),ql===null?ql=[o]:ql.push(o),Hl!==4&&(Hl=2),t===null)return!0;r=ii(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Us(n.stateNode,r,e),Na(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(eu===null||!eu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=Ws(a),Gs(a,e,n,r),Na(n,a),!1}n=n.return}while(n!==null);return!1}var qs=Error(i(461)),Js=!1;function Ys(e,t,n,r){t.child=e===null?Ea(t,null,n,r):Ta(t,e.child,n,r)}function Xs(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Vi(t),r=po(e,t,n,o,a,i),s=_o(),e!==null&&!Js?(vo(e,t,i),bc(e,t,i)):(xi&&s&&gi(t),t.flags|=1,Ys(e,t,r,i),t.child)}function Zs(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!Yr(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,Qs(e,t,a,r,i)):(e=Qr(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!xc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?ur:n,n(o,r)&&e.ref===t.ref)return bc(e,t,i)}return t.flags|=1,e=Xr(a,r),e.ref=t.ref,e.return=t,t.child=e}function Qs(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(ur(a,r)&&e.ref===t.ref){if(Js=!1,t.pendingProps=r=a,xc(e,i))e.flags&131072&&(Js=!0);else return t.lanes=e.lanes,bc(e,t,i)}}return oc(e,t,n,r,i)}function $s(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return tc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&sa(t,a===null?null:a.cachePool),a===null?Ha():Va(t,a),Ja(t);else return r=t.lanes=536870912,tc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&sa(t,null),Ha(),Ya(t)):(sa(t,a.cachePool),Va(t,a),Ya(t),t.memoizedState=null);return Ys(e,t,i,n),t.child}function ec(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function tc(e,t,n,r,i){var a=oa();return a=a===null?null:{parent:Ji._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&sa(t,null),Ha(),Ja(t),e!==null&&zi(e,t,r,!0),t.childLanes=i,null}function nc(e,t){return t=hc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function rc(e,t,n){return Ta(t,e.child,null,n),e=nc(t,t.pendingProps),e.flags|=2,Xa(t),t.memoizedState=null,e}function ic(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(xi){if(r.mode===`hidden`)return e=nc(t,r),t.lanes=536870912,ec(null,e);if(qa(t),(e=bi)?(e=rf(e,Ci),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:di===null?null:{id:fi,overflow:pi},retryLane:536870912,hydrationErrors:null},n=ti(e),n.return=t,t.child=n,yi=t,bi=null)):e=null,e===null)throw Ti(t);return t.lanes=536870912,null}return nc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(qa(t),a){if(t.flags&256)t.flags&=-257,t=rc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Js||zi(e,t,n,!1),a=(n&e.childLanes)!==0,Js||a){if(r=Nl,r!==null&&(s=Ke(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Ur(e,s),fu(r,e,s),qs;wu(),t=rc(e,t,n)}else e=o.treeContext,bi=cf(s.nextSibling),yi=t,xi=!0,Si=null,Ci=!1,e!==null&&vi(t,e),t=nc(t,r),t.flags|=4096;return t}return e=Xr(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function ac(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function oc(e,t,n,r,i){return Vi(t),n=po(e,t,n,r,void 0,i),r=_o(),e!==null&&!Js?(vo(e,t,i),bc(e,t,i)):(xi&&r&&gi(t),t.flags|=1,Ys(e,t,n,i),t.child)}function sc(e,t,n,r,i,a){return Vi(t),t.updateQueue=null,n=ho(t,r,n,i),mo(e),r=_o(),e!==null&&!Js?(vo(e,t,a),bc(e,t,a)):(xi&&r&&gi(t),t.flags|=1,Ys(e,t,n,a),t.child)}function cc(e,t,n,r,i){if(Vi(t),t.stateNode===null){var a=Kr,o=n.contextType;typeof o==`object`&&o&&(a=Hi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ps,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Oa(t),o=n.contextType,a.context=typeof o==`object`&&o?Hi(o):Kr,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Ns(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ps.enqueueReplaceState(a,a.state,null),Ia(t,r,a,i),Fa(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Ls(n,s);a.props=c;var l=a.context,u=n.contextType;o=Kr,typeof u==`object`&&u&&(o=Hi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Is(t,a,r,o),Da=!1;var f=t.memoizedState;a.state=f,Ia(t,r,a,i),Fa(),l=t.memoizedState,s||f!==l||Da?(typeof d==`function`&&(Ns(t,n,d,r),l=t.memoizedState),(c=Da||Fs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ka(e,t),o=t.memoizedProps,u=Ls(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Kr,typeof l==`object`&&l&&(c=Hi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Is(t,a,r,c),Da=!1,f=t.memoizedState,a.state=f,Ia(t,r,a,i),Fa();var p=t.memoizedState;o!==d||f!==p||Da||e!==null&&e.dependencies!==null&&Bi(e.dependencies)?(typeof s==`function`&&(Ns(t,n,s,r),p=t.memoizedState),(u=Da||Fs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Bi(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,ac(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Ta(t,e.child,null,i),t.child=Ta(t,null,n,i)):Ys(e,t,n,i),t.memoizedState=a.state,e=t.child):e=bc(e,t,i),e}function lc(e,t,n,r){return ki(),t.flags|=256,Ys(e,t,n,r),t.child}var uc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function dc(e){return{baseLanes:e,cachePool:ca()}}function fc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=Gl),e}function pc(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(Za.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(xi){if(a?Ka(t):Ya(t),(e=bi)?(e=rf(e,Ci),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:di===null?null:{id:fi,overflow:pi},retryLane:536870912,hydrationErrors:null},n=ti(e),n.return=t,t.child=n,yi=t,bi=null)):e=null,e===null)throw Ti(t);return of(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(Ya(t),a=t.mode,c=hc({mode:`hidden`,children:c},a),r=$r(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=dc(n),r.childLanes=fc(e,s,n),t.memoizedState=uc,ec(null,r)):(Ka(t),mc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(Ka(t),t.flags&=-257,t=gc(e,t,n)):t.memoizedState===null?(Ya(t),c=r.fallback,a=t.mode,r=hc({mode:`visible`,children:r.children},a),c=$r(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ta(t,e.child,null,n),r=t.child,r.memoizedState=dc(n),r.childLanes=fc(e,s,n),t.memoizedState=uc,t=ec(null,r)):(Ya(t),t.child=e.child,t.flags|=128,t=null);else if(Ka(t),of(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,ji({value:r,source:null,stack:null}),t=gc(e,t,n)}else if(Js||zi(e,t,n,!1),s=(n&e.childLanes)!==0,Js||s){if(s=Nl,s!==null&&(r=Ke(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Ur(e,r),fu(s,e,r),qs;af(c)||wu(),t=gc(e,t,n)}else af(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,bi=cf(c.nextSibling),yi=t,xi=!0,Si=null,Ci=!1,e!==null&&vi(t,e),t=mc(t,r.children),t.flags|=4096);return t}return a?(Ya(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=Xr(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=$r(c,a,n,null),c.flags|=2):c=Xr(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,ec(null,r),r=t.child,c=e.child.memoizedState,c===null?c=dc(n):(a=c.cachePool,a===null?a=ca():(l=Ji._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=fc(e,s,n),t.memoizedState=uc,ec(e.child,r)):(Ka(t),n=e.child,e=n.sibling,n=Xr(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function mc(e,t){return t=hc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function hc(e,t){return e=Jr(22,e,null,t),e.lanes=0,e}function gc(e,t,n){return Ta(t,e.child,null,n),e=mc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _c(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Li(e.return,t,n)}function vc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function yc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Za.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,V(Za,o),Ys(e,t,r,n),r=xi?ci:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&_c(e,n,t);else if(e.tag===19)_c(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&Qa(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),vc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Qa(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}vc(t,!0,n,null,a,r);break;case`together`:vc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function bc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),$|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(zi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Xr(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Xr(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function xc(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Bi(e)))}function Sc(e,t,n){switch(t.tag){case 3:ae(t,t.stateNode.containerInfo),Fi(t,Ji,e.memoizedState.cache),ki();break;case 27:case 5:se(t);break;case 4:ae(t,t.stateNode.containerInfo);break;case 10:Fi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,qa(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(Ka(t),e=bc(e,t,n),e===null?null:e.sibling):pc(e,t,n):(Ka(t),t.flags|=128,null);Ka(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(zi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return yc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(Za,Za.current),r)break;return null;case 22:return t.lanes=0,$s(e,t,n,t.pendingProps);case 24:Fi(t,Ji,e.memoizedState.cache)}return bc(e,t,n)}function Cc(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Js=!0;else{if(!xc(e,n)&&!(t.flags&128))return Js=!1,Sc(e,t,n);Js=!!(e.flags&131072)}}else Js=!1,xi&&t.flags&1048576&&hi(t,ci,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ha(t.elementType),t.type=e,typeof e==`function`)Yr(e)?(r=Ls(e,r),t.tag=1,t=cc(null,t,e,r,n)):(t.tag=0,t=oc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===S){t.tag=11,t=Xs(null,t,e,r,n);break a}if(a===T){t.tag=14,t=Zs(null,t,e,r,n);break a}}throw t=M(e)||e,Error(i(306,t,``))}}return t;case 0:return oc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Ls(r,t.pendingProps),cc(e,t,r,a,n);case 3:a:{if(ae(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ka(e,t),Ia(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Fi(t,Ji,r),r!==o.cache&&Ri(t,[Ji],n,!0),Fa(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=lc(e,t,r,n);break a}if(r!==a){a=ii(Error(i(424)),t),ji(a),t=lc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(bi=cf(e.firstChild),yi=t,xi=!0,Si=null,Ci=!0,n=Ea(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(ki(),r===a){t=bc(e,t,n);break a}Ys(e,t,r,n)}t=t.child}return t;case 26:return ac(e,t),e===null?(n=kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:xi||(n=t.type,e=t.pendingProps,r=Bd(re.current).createElement(n),r[Qe]=t,r[$e]=e,Pd(r,n,e),ut(r),t.stateNode=r):t.memoizedState=kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return se(t),e===null&&xi&&(r=t.stateNode=ff(t.type,t.pendingProps,re.current),yi=t,Ci=!0,a=bi,Zd(t.type)?(lf=a,bi=cf(r.firstChild)):bi=a),Ys(e,t,t.pendingProps.children,n),ac(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&xi&&((a=r=bi)&&(r=tf(r,t.type,t.pendingProps,Ci),r===null?a=!1:(t.stateNode=r,yi=t,bi=cf(r.firstChild),Ci=!1,a=!0)),a||Ti(t)),se(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Ud(a,o)?r=null:s!==null&&Ud(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=po(e,t,go,null,null,n),Qf._currentValue=a),ac(e,t),Ys(e,t,r,n),t.child;case 6:return e===null&&xi&&((e=n=bi)&&(n=nf(n,t.pendingProps,Ci),n===null?e=!1:(t.stateNode=n,yi=t,bi=null,e=!0)),e||Ti(t)),null;case 13:return pc(e,t,n);case 4:return ae(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ta(t,null,r,n):Ys(e,t,r,n),t.child;case 11:return Xs(e,t,t.type,t.pendingProps,n);case 7:return Ys(e,t,t.pendingProps,n),t.child;case 8:return Ys(e,t,t.pendingProps.children,n),t.child;case 12:return Ys(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Fi(t,t.type,r.value),Ys(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,Vi(t),a=Hi(a),r=r(a),t.flags|=1,Ys(e,t,r,n),t.child;case 14:return Zs(e,t,t.type,t.pendingProps,n);case 15:return Qs(e,t,t.type,t.pendingProps,n);case 19:return yc(e,t,n);case 31:return ic(e,t,n);case 22:return $s(e,t,n,t.pendingProps);case 24:return Vi(t),r=Hi(Ji),e===null?(a=oa(),a===null&&(a=Nl,o=Yi(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Oa(t),Fi(t,Ji,a)):((e.lanes&n)!==0&&(ka(e,t),Ia(t,null,null,n),Fa()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Fi(t,Ji,r),r!==a.cache&&Ri(t,[Ji],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Fi(t,Ji,r))),Ys(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function wc(e){e.flags|=4}function Tc(e,t,n,r,i){if((t=!!(e.mode&32))&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(xu())e.flags|=8192;else throw ga=fa,ua}}else e.flags&=-16777217}function Ec(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Wf(t)){if(xu())e.flags|=8192;else throw ga=fa,ua}}function Dc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Ve(),e.lanes|=t,Kl|=t)}function Oc(e,t){if(!xi)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function kc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Ac(e,t,n){var r=t.pendingProps;switch(_i(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return kc(t),null;case 1:return kc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Ii(Ji),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Oi(t)?wc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ai())),kc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(wc(t),o===null?(kc(t),Tc(t,a,null,r,n)):(kc(t),Ec(t,o))):o?o===e.memoizedState?(kc(t),t.flags&=-16777217):(wc(t),kc(t),Ec(t,o)):(e=e.memoizedProps,e!==r&&wc(t),kc(t),Tc(t,a,e,r,n)),null;case 27:if(ce(t),n=re.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return kc(t),null}e=ee.current,Oi(t)?Ei(t,e):(e=ff(a,r,n),t.stateNode=e,wc(t))}return kc(t),null;case 5:if(ce(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return kc(t),null}if(o=ee.current,Oi(t))Ei(t,o);else{var s=Bd(re.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[Qe]=t,o[$e]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(Pd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&wc(t)}}return kc(t),Tc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&wc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=re.current,Oi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=yi,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[Qe]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||jd(e.nodeValue,n)),e||Ti(t,!0)}else e=Bd(e).createTextNode(r),e[Qe]=t,t.stateNode=e}return kc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Oi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[Qe]=t}else ki(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kc(t),e=!1}else n=Ai(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Xa(t),t):(Xa(t),null);if(t.flags&128)throw Error(i(558))}return kc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Oi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[Qe]=t}else ki(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;kc(t),a=!1}else a=Ai(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Xa(t),t):(Xa(t),null)}return Xa(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Dc(t,t.updateQueue),kc(t),null);case 4:return oe(),e===null&&xd(t.stateNode.containerInfo),kc(t),null;case 10:return Ii(t.type),kc(t),null;case 19:if(B(Za),r=t.memoizedState,r===null)return kc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Oc(r,!1);else{if(Hl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Qa(e),o!==null){for(t.flags|=128,Oc(r,!1),e=o.updateQueue,t.updateQueue=e,Dc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Zr(n,e),n=n.sibling;return V(Za,Za.current&1|2),xi&&mi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&be()>Ql&&(t.flags|=128,a=!0,Oc(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Qa(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Dc(t,e),Oc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!xi)return kc(t),null}else 2*be()-r.renderingStartTime>Ql&&n!==536870912&&(t.flags|=128,a=!0,Oc(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(kc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=be(),e.sibling=null,n=Za.current,V(Za,a?n&1|2:n&1),xi&&mi(t,r.treeForkCount),e);case 22:case 23:return Xa(t),Ua(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(kc(t),t.subtreeFlags&6&&(t.flags|=8192)):kc(t),n=t.updateQueue,n!==null&&Dc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(aa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Ii(Ji),kc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function jc(e,t){switch(_i(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ii(Ji),oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ce(t),null;case 31:if(t.memoizedState!==null){if(Xa(t),t.alternate===null)throw Error(i(340));ki()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Xa(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));ki()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(Za),null;case 4:return oe(),null;case 10:return Ii(t.type),null;case 22:case 23:return Xa(t),Ua(),e!==null&&B(aa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Ii(Ji),null;case 25:return null;default:return null}}function Mc(e,t){switch(_i(t),t.tag){case 3:Ii(Ji),oe();break;case 26:case 27:case 5:ce(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&Xa(t);break;case 13:Xa(t);break;case 19:B(Za);break;case 10:Ii(t.type);break;case 22:case 23:Xa(t),Ua(),e!==null&&B(aa);break;case 24:Ii(Ji)}}function Nc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Hu(t,t.return,e)}}function Pc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Hu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Hu(t,t.return,e)}}function Fc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ra(t,n)}catch(t){Hu(e,e.return,t)}}}function Ic(e,t,n){n.props=Ls(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Hu(e,t,n)}}function Lc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Hu(e,t,n)}}function Rc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Hu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Hu(e,t,n)}else n.current=null}}function zc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Hu(e,e.return,t)}}function Bc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[$e]=t}catch(t){Hu(e,e.return,t)}}function Vc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Hc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Vc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Uc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Vt));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Uc(e,t,n),e=e.sibling;e!==null;)Uc(e,t,n),e=e.sibling}function Wc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Wc(e,t,n),e=e.sibling;e!==null;)Wc(e,t,n),e=e.sibling}function Gc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[Qe]=e,t[$e]=n}catch(t){Hu(e,e.return,t)}}var Kc=!1,qc=!1,Jc=!1,Yc=typeof WeakSet==`function`?WeakSet:Set,Xc=null;function Zc(e,t){if(e=e.containerInfo,Rd=sp,e=mr(e),hr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,Xc=t;Xc!==null;)if(t=Xc,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,Xc=e;else for(;Xc!==null;){switch(t=Xc,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Ls(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Hu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)ef(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:ef(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,Xc=e;break}Xc=t.return}}function Qc(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:pl(e,n),r&4&&Nc(5,n);break;case 1:if(pl(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Hu(n,n.return,e)}else{var i=Ls(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Hu(n,n.return,e)}}}r&64&&Fc(n),r&512&&Lc(n,n.return);break;case 3:if(pl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ra(e,t)}catch(e){Hu(n,n.return,e)}}break;case 27:t===null&&r&4&&Gc(n);case 26:case 5:pl(e,n),t===null&&r&4&&zc(n),r&512&&Lc(n,n.return);break;case 12:pl(e,n);break;case 31:pl(e,n),r&4&&il(e,n);break;case 13:pl(e,n),r&4&&al(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ku.bind(null,n),sf(e,n))));break;case 22:if(r=n.memoizedState!==null||Kc,!r){t=t!==null&&t.memoizedState!==null||qc,i=Kc;var a=qc;Kc=r,(qc=t)&&!a?hl(e,n,!!(n.subtreeFlags&8772)):pl(e,n),Kc=i,qc=a}break;case 30:break;default:pl(e,n)}}function $c(e){var t=e.alternate;t!==null&&(e.alternate=null,$c(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&at(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var el=null,tl=!1;function nl(e,t,n){for(n=n.child;n!==null;)rl(e,t,n),n=n.sibling}function rl(e,t,n){if(ke&&typeof ke.onCommitFiberUnmount==`function`)try{ke.onCommitFiberUnmount(Oe,n)}catch{}switch(n.tag){case 26:qc||Rc(n,t),nl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:qc||Rc(n,t);var r=el,i=tl;Zd(n.type)&&(el=n.stateNode,tl=!1),nl(e,t,n),pf(n.stateNode),el=r,tl=i;break;case 5:qc||Rc(n,t);case 6:if(r=el,i=tl,el=null,nl(e,t,n),el=r,tl=i,el!==null){if(tl)try{(el.nodeType===9?el.body:el.nodeName===`HTML`?el.ownerDocument.body:el).removeChild(n.stateNode)}catch(e){Hu(n,t,e)}else try{el.removeChild(n.stateNode)}catch(e){Hu(n,t,e)}}break;case 18:el!==null&&(tl?(e=el,Qd(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Np(e)):Qd(el,n.stateNode));break;case 4:r=el,i=tl,el=n.stateNode.containerInfo,tl=!0,nl(e,t,n),el=r,tl=i;break;case 0:case 11:case 14:case 15:Pc(2,n,t),qc||Pc(4,n,t),nl(e,t,n);break;case 1:qc||(Rc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Ic(n,t,r)),nl(e,t,n);break;case 21:nl(e,t,n);break;case 22:qc=(r=qc)||n.memoizedState!==null,nl(e,t,n),qc=r;break;default:nl(e,t,n)}}function il(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Np(e)}catch(e){Hu(t,t.return,e)}}}function al(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Np(e)}catch(e){Hu(t,t.return,e)}}function ol(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new Yc),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new Yc),t;default:throw Error(i(435,e.tag))}}function sl(e,t){var n=ol(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=qu.bind(null,e,t);t.then(r,r)}})}function cl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(Zd(c.type)){el=c.stateNode,tl=!1;break a}break;case 5:el=c.stateNode,tl=!1;break a;case 3:case 4:el=c.stateNode.containerInfo,tl=!0;break a}c=c.return}if(el===null)throw Error(i(160));rl(o,s,a),el=null,tl=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)ul(t,e),t=t.sibling}var ll=null;function ul(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:cl(t,e),dl(e),r&4&&(Pc(3,e,e.return),Nc(3,e),Pc(5,e,e.return));break;case 1:cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),r&64&&Kc&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=ll;if(cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null){if(r===null){if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[it]||o[Qe]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),Pd(o,r,n),o[Qe]=e,ut(o),r=o;break a;case`link`:var s=Vf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Vf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),Pd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[Qe]=e,ut(o),r=o}e.stateNode=r}else Hf(a,e.type,e.stateNode)}else e.stateNode=If(a,r,e.memoizedProps)}else o===r?r===null&&e.stateNode!==null&&Bc(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Hf(a,e.type,e.stateNode):If(a,r,e.memoizedProps))}break;case 27:cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),n!==null&&r&4&&Bc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(cl(t,e),dl(e),r&512&&(qc||n===null||Rc(n,n.return)),e.flags&32){a=e.stateNode;try{Nt(a,``)}catch(t){Hu(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,Bc(e,a,n===null?a:n.memoizedProps)),r&1024&&(Jc=!0);break;case 6:if(cl(t,e),dl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Hu(e,e.return,t)}}break;case 3:if(Bf=null,a=ll,ll=gf(t.containerInfo),cl(t,e),ll=a,dl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Np(t.containerInfo)}catch(t){Hu(e,e.return,t)}Jc&&(Jc=!1,fl(e));break;case 4:r=ll,ll=gf(e.stateNode.containerInfo),cl(t,e),dl(e),ll=r;break;case 12:cl(t,e),dl(e);break;case 31:cl(t,e),dl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,sl(e,r)));break;case 13:cl(t,e),dl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(Xl=be()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,sl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=Kc,d=qc;if(Kc=u||a,qc=d||l,cl(t,e),qc=d,Kc=u,dl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||Kc||qc||ml(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Hu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){Hu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?$d(m,!0):$d(l.stateNode,!1)}catch(e){Hu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,sl(e,n))));break;case 19:cl(t,e),dl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,sl(e,r)));break;case 30:break;case 21:break;default:cl(t,e),dl(e)}}function dl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Vc(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;Wc(e,Hc(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Nt(o,``),n.flags&=-33),Wc(e,Hc(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;Uc(e,Hc(e),s);break;default:throw Error(i(161))}}catch(t){Hu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function fl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;fl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function pl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)Qc(e,t.alternate,t),t=t.sibling}function ml(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Pc(4,t,t.return),ml(t);break;case 1:Rc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Ic(t,t.return,n),ml(t);break;case 27:pf(t.stateNode);case 26:case 5:Rc(t,t.return),ml(t);break;case 22:t.memoizedState===null&&ml(t);break;case 30:ml(t);break;default:ml(t)}e=e.sibling}}function hl(e,t,n){for(n&&=!!(t.subtreeFlags&8772),t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:hl(i,a,n),Nc(4,a);break;case 1:if(hl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Hu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)La(c[i],s)}catch(e){Hu(r,r.return,e)}}n&&o&64&&Fc(a),Lc(a,a.return);break;case 27:Gc(a);case 26:case 5:hl(i,a,n),n&&r===null&&o&4&&zc(a),Lc(a,a.return);break;case 12:hl(i,a,n);break;case 31:hl(i,a,n),n&&o&4&&il(i,a);break;case 13:hl(i,a,n),n&&o&4&&al(i,a);break;case 22:a.memoizedState===null&&hl(i,a,n),Lc(a,a.return);break;case 30:break;default:hl(i,a,n)}t=t.sibling}}function gl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Xi(n))}function _l(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Xi(e))}function vl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)yl(e,t,n,r),t=t.sibling}function yl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:vl(e,t,n,r),i&2048&&Nc(9,t);break;case 1:vl(e,t,n,r);break;case 3:vl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Xi(e)));break;case 12:if(i&2048){vl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Hu(t,t.return,e)}}else vl(e,t,n,r);break;case 31:vl(e,t,n,r);break;case 13:vl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?vl(e,t,n,r):(a._visibility|=2,bl(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?vl(e,t,n,r):xl(e,t),i&2048&&gl(o,t);break;case 24:vl(e,t,n,r),i&2048&&_l(t.alternate,t);break;default:vl(e,t,n,r)}}function bl(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:bl(a,o,s,c,i),Nc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,bl(a,o,s,c,i)):u._visibility&2?bl(a,o,s,c,i):xl(a,o),i&&l&2048&&gl(o.alternate,o);break;case 24:bl(a,o,s,c,i),i&&l&2048&&_l(o.alternate,o);break;default:bl(a,o,s,c,i)}t=t.sibling}}function xl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:xl(n,r),i&2048&&gl(r.alternate,r);break;case 24:xl(n,r),i&2048&&_l(r.alternate,r);break;default:xl(n,r)}t=t.sibling}}var Sl=8192;function Cl(e,t,n){if(e.subtreeFlags&Sl)for(e=e.child;e!==null;)wl(e,t,n),e=e.sibling}function wl(e,t,n){switch(e.tag){case 26:Cl(e,t,n),e.flags&Sl&&e.memoizedState!==null&&Gf(n,ll,e.memoizedState,e.memoizedProps);break;case 5:Cl(e,t,n);break;case 3:case 4:var r=ll;ll=gf(e.stateNode.containerInfo),Cl(e,t,n),ll=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Sl,Sl=16777216,Cl(e,t,n),Sl=r):Cl(e,t,n));break;default:Cl(e,t,n)}}function Tl(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function El(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Xc=r,kl(r,e)}Tl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Dl(e),e=e.sibling}function Dl(e){switch(e.tag){case 0:case 11:case 15:El(e),e.flags&2048&&Pc(9,e,e.return);break;case 3:El(e);break;case 12:El(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Ol(e)):El(e);break;default:El(e)}}function Ol(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];Xc=r,kl(r,e)}Tl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Pc(8,t,t.return),Ol(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Ol(t));break;default:Ol(t)}e=e.sibling}}function kl(e,t){for(;Xc!==null;){var n=Xc;switch(n.tag){case 0:case 11:case 15:Pc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Xi(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,Xc=r;else a:for(n=e;Xc!==null;){r=Xc;var i=r.sibling,a=r.return;if($c(r),r===n){Xc=null;break a}if(i!==null){i.return=a,Xc=i;break a}Xc=a}}}var Al={getCacheForType:function(e){var t=Hi(Ji),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Hi(Ji).controller.signal}},jl=typeof WeakMap==`function`?WeakMap:Map,Ml=0,Nl=null,Pl=null,Fl=0,Il=0,Ll=null,Rl=!1,zl=!1,Bl=!1,Vl=0,Hl=0,$=0,Ul=0,Wl=0,Gl=0,Kl=0,ql=null,Jl=null,Yl=!1,Xl=0,Zl=0,Ql=1/0,$l=null,eu=null,tu=0,nu=null,ru=null,iu=0,au=0,ou=null,su=null,cu=0,lu=null;function uu(){return Ml&2&&Fl!==0?Fl&-Fl:P.T===null?Ye():ld()}function du(){if(Gl===0){if(!(Fl&536870912)||xi){var e=Ie;Ie<<=1,!(Ie&3932160)&&(Ie=262144),Gl=e}else Gl=536870912}return e=Wa.current,e!==null&&(e.flags|=32),Gl}function fu(e,t,n){(e===Nl&&(Il===2||Il===9)||e.cancelPendingCommit!==null)&&(yu(e,0),gu(e,Fl,Gl,!1)),He(e,n),(!(Ml&2)||e!==Nl)&&(e===Nl&&(!(Ml&2)&&(Ul|=n),Hl===4&&gu(e,Fl,Gl,!1)),td(e))}function pu(e,t,n){if(Ml&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||ze(e,t),a=r?Du(e,t):Tu(e,t,!0),o=r;do{if(a===0){zl&&!r&&gu(e,t,0,!1);break}if(n=e.current.alternate,o&&!hu(n)){a=Tu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=ql;var l=c.current.memoizedState.isDehydrated;if(l&&(yu(c,s).flags|=256),s=Tu(c,s,!1),s!==2){if(Bl&&!l){c.errorRecoveryDisabledLanes|=o,Ul|=o,a=4;break a}o=Jl,Jl=a,o!==null&&(Jl===null?Jl=o:Jl.push.apply(Jl,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){yu(e,0),gu(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:gu(r,t,Gl,!Rl);break a;case 2:Jl=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Xl+300-be(),10<a)){if(gu(r,t,Gl,!Rl),Re(r,0,!0)!==0)break a;iu=t,r.timeoutHandle=Kd(mu.bind(null,r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Rl,o,`Throttled`,-0,0),a);break a}mu(r,n,Jl,$l,Yl,t,Gl,Ul,Kl,Rl,o,null,-0,0)}break}while(1);td(e)}function mu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Vt},wl(t,a,d);var m=(a&62914560)===a?Xl-be():(a&4194048)===a?Zl-be():0;if(m=qf(d,m),m!==null){iu=a,e.cancelPendingCommit=m(Pu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),gu(e,a,o,!l);return}}Pu(e,t,a,n,r,i,o,s,c)}function hu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!lr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function gu(e,t,n,r){t&=~Wl,t&=~Ul,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-je(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&We(e,n,t)}function _u(){return Ml&6?!0:(nd(0,!1),!1)}function vu(){if(Pl!==null){if(Il===0)var e=Pl.return;else e=Pl,Pi=Ni=null,yo(e),ya=null,ba=0,e=Pl;for(;e!==null;)Mc(e.alternate,e),e=e.return;Pl=null}}function yu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),iu=0,vu(),Nl=e,Pl=n=Xr(e.current,null),Fl=t,Il=0,Ll=null,Rl=!1,zl=ze(e,t),Bl=!1,Kl=Gl=Wl=Ul=$=Hl=0,Jl=ql=null,Yl=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-je(r),a=1<<i;t|=e[i],r&=~a}return Vl=t,Br(),n}function bu(e,t){eo=null,P.H=ks,t===la||t===da?(t=_a(),Il=3):t===ua?(t=_a(),Il=4):Il=t===qs?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Ll=t,Pl===null&&(Hl=1,Vs(e,ii(t,e.current)))}function xu(){var e=Wa.current;return e===null?!0:(Fl&4194048)===Fl?Ga===null:(Fl&62914560)===Fl||Fl&536870912?e===Ga:!1}function Su(){var e=P.H;return P.H=ks,e===null?ks:e}function Cu(){var e=P.A;return P.A=Al,e}function wu(){Hl=4,Rl||(Fl&4194048)!==Fl&&Wa.current!==null||(zl=!0),!($&134217727)&&!(Ul&134217727)||Nl===null||gu(Nl,Fl,Gl,!1)}function Tu(e,t,n){var r=Ml;Ml|=2;var i=Su(),a=Cu();(Nl!==e||Fl!==t)&&($l=null,yu(e,t)),t=!1;var o=Hl;a:do try{if(Il!==0&&Pl!==null){var s=Pl,c=Ll;switch(Il){case 8:vu(),o=6;break a;case 3:case 2:case 9:case 6:Wa.current===null&&(t=!0);var l=Il;if(Il=0,Ll=null,ju(e,s,c,l),n&&zl){o=0;break a}break;default:l=Il,Il=0,Ll=null,ju(e,s,c,l)}}Eu(),o=Hl;break}catch(t){bu(e,t)}while(1);return t&&e.shellSuspendCounter++,Pi=Ni=null,Ml=r,P.H=i,P.A=a,Pl===null&&(Nl=null,Fl=0,Br()),o}function Eu(){for(;Pl!==null;)ku(Pl)}function Du(e,t){var n=Ml;Ml|=2;var r=Su(),a=Cu();Nl!==e||Fl!==t?($l=null,Ql=be()+500,yu(e,t)):zl=ze(e,t);a:do try{if(Il!==0&&Pl!==null){t=Pl;var o=Ll;b:switch(Il){case 1:Il=0,Ll=null,ju(e,t,o,1);break;case 2:case 9:if(pa(o)){Il=0,Ll=null,Au(t);break}t=function(){Il!==2&&Il!==9||Nl!==e||(Il=7),td(e)},o.then(t,t);break a;case 3:Il=7;break a;case 4:Il=5;break a;case 7:pa(o)?(Il=0,Ll=null,Au(t)):(Il=0,Ll=null,ju(e,t,o,7));break;case 5:var s=null;switch(Pl.tag){case 26:s=Pl.memoizedState;case 5:case 27:var c=Pl;if(s?Wf(s):c.stateNode.complete){Il=0,Ll=null;var l=c.sibling;if(l!==null)Pl=l;else{var u=c.return;u===null?Pl=null:(Pl=u,Mu(u))}break b}}Il=0,Ll=null,ju(e,t,o,5);break;case 6:Il=0,Ll=null,ju(e,t,o,6);break;case 8:vu(),Hl=6;break a;default:throw Error(i(462))}}Ou();break}catch(t){bu(e,t)}while(1);return Pi=Ni=null,P.H=r,P.A=a,Ml=n,Pl===null?(Nl=null,Fl=0,Br(),Hl):0}function Ou(){for(;Pl!==null&&!ve();)ku(Pl)}function ku(e){var t=Cc(e.alternate,e,Vl);e.memoizedProps=e.pendingProps,t===null?Mu(e):Pl=t}function Au(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=sc(n,t,t.pendingProps,t.type,void 0,Fl);break;case 11:t=sc(n,t,t.pendingProps,t.type.render,t.ref,Fl);break;case 5:yo(t);default:Mc(n,t),t=Pl=Zr(t,Vl),t=Cc(n,t,Vl)}e.memoizedProps=e.pendingProps,t===null?Mu(e):Pl=t}function ju(e,t,n,r){Pi=Ni=null,yo(t),ya=null,ba=0;var i=t.return;try{if(Ks(e,i,t,n,Fl)){Hl=1,Vs(e,ii(n,e.current)),Pl=null;return}}catch(t){if(i!==null)throw Pl=i,t;Hl=1,Vs(e,ii(n,e.current)),Pl=null;return}t.flags&32768?(xi||r===1?e=!0:zl||Fl&536870912?e=!1:(Rl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Wa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Nu(t,e)):Mu(t)}function Mu(e){var t=e;do{if(t.flags&32768){Nu(t,Rl);return}e=t.return;var n=Ac(t.alternate,t,Vl);if(n!==null){Pl=n;return}if(t=t.sibling,t!==null){Pl=t;return}Pl=t=e}while(t!==null);Hl===0&&(Hl=5)}function Nu(e,t){do{var n=jc(e.alternate,e);if(n!==null){n.flags&=32767,Pl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Pl=e;return}Pl=e=n}while(e!==null);Hl=6,Pl=null}function Pu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do zu();while(tu!==0);if(Ml&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=zr,Ue(e,n,o,s,c,l),e===Nl&&(Pl=Nl=null,Fl=0),ru=t,nu=e,iu=n,au=o,ou=a,su=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,Ju(we,function(){return Bu(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=P.T,P.T=null,a=F.p,F.p=2,s=Ml,Ml|=4;try{Zc(e,t,n)}finally{Ml=s,F.p=a,P.T=r}}tu=1,Fu(),Iu(),Lu()}}function Fu(){if(tu===1){tu=0;var e=nu,t=ru,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Ml;Ml|=4;try{ul(t,e);var a=zd,o=mr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&pr(s.ownerDocument.documentElement,s)){if(c!==null&&hr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=fr(s,h),v=fr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}sp=!!Rd,zd=Rd=null}finally{Ml=i,F.p=r,P.T=n}}e.current=t,tu=2}}function Iu(){if(tu===2){tu=0;var e=nu,t=ru,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=P.T,P.T=null;var r=F.p;F.p=2;var i=Ml;Ml|=4;try{Qc(e,t.alternate,t)}finally{Ml=i,F.p=r,P.T=n}}tu=3}}function Lu(){if(tu===4||tu===3){tu=0,ye();var e=nu,t=ru,n=iu,r=su;t.subtreeFlags&10256||t.flags&10256?tu=5:(tu=0,ru=nu=null,Ru(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(eu=null),Je(n),t=t.stateNode,ke&&typeof ke.onCommitFiberRoot==`function`)try{ke.onCommitFiberRoot(Oe,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=P.T,i=F.p,F.p=2,P.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{P.T=t,F.p=i}}iu&3&&zu(),td(e),i=e.pendingLanes,n&261930&&i&42?e===lu?cu++:(cu=0,lu=e):cu=0,nd(0,!1)}}function Ru(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Xi(t)))}function zu(){return Fu(),Iu(),Lu(),Bu()}function Bu(){if(tu!==5)return!1;var e=nu,t=au;au=0;var n=Je(iu),r=P.T,a=F.p;try{F.p=32>n?32:n,P.T=null,n=ou,ou=null;var o=nu,s=iu;if(tu=0,ru=nu=null,iu=0,Ml&6)throw Error(i(331));var c=Ml;if(Ml|=4,Dl(o.current),yl(o,o.current,s,n),Ml=c,nd(0,!1),ke&&typeof ke.onPostCommitFiberRoot==`function`)try{ke.onPostCommitFiberRoot(Oe,o)}catch{}return!0}finally{F.p=a,P.T=r,Ru(e,t)}}function Vu(e,t,n){t=ii(n,t),t=Us(e.stateNode,t,2),e=ja(e,t,2),e!==null&&(He(e,2),td(e))}function Hu(e,t,n){if(e.tag===3)Vu(e,e,n);else for(;t!==null;){if(t.tag===3){Vu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(eu===null||!eu.has(r))){e=ii(n,e),n=Ws(2),r=ja(t,n,2),r!==null&&(Gs(n,r,t,e),He(r,2),td(r));break}}t=t.return}}function Uu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new jl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Bl=!0,i.add(n),e=Wu.bind(null,e,t,n),t.then(e,e))}function Wu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Nl===e&&(Fl&n)===n&&(Hl===4||Hl===3&&(Fl&62914560)===Fl&&300>be()-Xl?!(Ml&2)&&yu(e,0):Wl|=n,Kl===Fl&&(Kl=0)),td(e)}function Gu(e,t){t===0&&(t=Ve()),e=Ur(e,t),e!==null&&(He(e,t),td(e))}function Ku(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Gu(e,n)}function qu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Gu(e,n)}function Ju(e,t){return H(e,t)}var Yu=null,Xu=null,Zu=!1,Qu=!1,$u=!1,ed=0;function td(e){e!==Xu&&e.next===null&&(Xu===null?Yu=Xu=e:Xu=Xu.next=e),Qu=!0,Zu||(Zu=!0,cd())}function nd(e,t){if(!$u&&Qu){$u=!0;do for(var n=!1,r=Yu;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-je(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,sd(r,a))}else a=Fl,a=Re(r,r===Nl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||ze(r,a)||(n=!0,sd(r,a))}r=r.next}while(n);$u=!1}}function rd(){id()}function id(){Qu=Zu=!1;var e=0;ed!==0&&Gd()&&(e=ed);for(var t=be(),n=null,r=Yu;r!==null;){var i=r.next,a=ad(r,t);a===0?(r.next=null,n===null?Yu=i:n.next=i,i===null&&(Xu=n)):(n=r,(e!==0||a&3)&&(Qu=!0)),r=i}tu!==0&&tu!==5||nd(e,!1),ed!==0&&(ed=0)}function ad(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-je(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Be(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Nl,n=Fl,n=Re(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Il===2||Il===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&_e(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||ze(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&_e(r),Je(n)){case 2:case 8:n=Ce;break;case 32:n=we;break;case 268435456:n=Te;break;default:n=we}return r=od.bind(null,e),n=H(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&_e(r),e.callbackPriority=2,e.callbackNode=null,2}function od(e,t){if(tu!==0&&tu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(zu()&&e.callbackNode!==n)return null;var r=Fl;return r=Re(e,e===Nl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(pu(e,r,t),ad(e,be()),e.callbackNode!=null&&e.callbackNode===n?od.bind(null,e):null)}function sd(e,t){if(zu())return null;pu(e,t,!0)}function cd(){Yd(function(){Ml&6?H(Se,rd):id()})}function ld(){if(ed===0){var e=$i;e===0&&(e=Fe,Fe<<=1,!(Fe&261888)&&(Fe=256)),ed=e}return ed}function ud(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:Bt(``+e)}function dd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function fd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=ud((i[$e]||null).action),o=r.submitter;o&&(t=(t=o[$e]||null)?ud(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ed!==0){var e=o?dd(i,o):new FormData(i);hs(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?dd(i,o):new FormData(i),hs(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var pd=0;pd<Fr.length;pd++){var md=Fr[pd];Ir(md.toLowerCase(),`on`+(md[0].toUpperCase()+md.slice(1)))}Ir(Dr,`onAnimationEnd`),Ir(Or,`onAnimationIteration`),Ir(kr,`onAnimationStart`),Ir(`dblclick`,`onDoubleClick`),Ir(`focusin`,`onFocus`),Ir(`focusout`,`onBlur`),Ir(Ar,`onTransitionRun`),Ir(jr,`onTransitionStart`),Ir(Mr,`onTransitionCancel`),Ir(Nr,`onTransitionEnd`),J(`onMouseEnter`,[`mouseout`,`mouseover`]),J(`onMouseLeave`,[`mouseout`,`mouseover`]),J(`onPointerEnter`,[`pointerout`,`pointerover`]),J(`onPointerLeave`,[`pointerout`,`pointerover`]),q(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),q(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),q(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),q(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),q(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),q(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var hd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),gd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(hd));function _d(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Lr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Lr(e)}i.currentTarget=null,a=c}}}}function vd(e,t){var n=t[tt];n===void 0&&(n=t[tt]=new Set);var r=e+`__bubble`;n.has(r)||(Sd(t,e,2,!1),n.add(r))}function yd(e,t,n){var r=0;t&&(r|=4),Sd(n,e,r,t)}var bd=`_reactListening`+Math.random().toString(36).slice(2);function xd(e){if(!e[bd]){e[bd]=!0,dt.forEach(function(t){t!==`selectionchange`&&(gd.has(t)||yd(t,!1,e),yd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[bd]||(t[bd]=!0,yd(`selectionchange`,!1,t))}}function Sd(e,t,n,r){switch(mp(t)){case 2:var i=cp;break;case 8:i=lp;break;default:i=up}n=i.bind(null,t,n,e),i=void 0,!Zt||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Cd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=ot(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Jt(function(){var r=a,i=Ut(n),s=[];a:{var c=Pr.get(e);if(c!==void 0){var l=ln,u=e;switch(e){case`keypress`:if(rn(n)===0)break a;case`keydown`:case`keyup`:l=Dn;break;case`focusin`:u=`focus`,l=vn;break;case`focusout`:u=`blur`,l=vn;break;case`beforeblur`:case`afterblur`:l=vn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=gn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=_n;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=kn;break;case Dr:case Or:case kr:l=yn;break;case Nr:l=An;break;case`scroll`:case`scrollend`:l=dn;break;case`wheel`:l=jn;break;case`copy`:case`cut`:case`paste`:l=bn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=On;break;case`toggle`:case`beforetoggle`:l=Mn}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=Yt(m,p),g!=null&&d.push(wd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==Ht&&(u=n.relatedTarget||n.fromElement)&&(ot(u)||u[et]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?ot(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=gn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=On,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:ct(l),h=u==null?c:ct(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,ot(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Ed,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Dd(s,c,l,d,!1),u!==null&&f!==null&&Dd(s,f,u,d,!0)}}a:{if(c=r?ct(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=Zn;else if(Kn(c)){if(Qn)v=sr;else{v=ar;var y=ir}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Lt(r.elementType)&&(v=Zn):v=or;if(v&&=v(e,r)){Z(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&kt(c,`number`,c.value)}switch(y=r?ct(r):window,e){case`focusin`:(Kn(y)||y.contentEditable===`true`)&&(_r=y,vr=r,yr=null);break;case`focusout`:yr=vr=_r=null;break;case`mousedown`:br=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:br=!1,xr(s,n,i);break;case`selectionchange`:if(gr)break;case`keydown`:case`keyup`:xr(s,n,i)}var b;if(Pn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Hn?Bn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Ln&&n.locale!==`ko`&&(Hn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Hn&&(b=nn()):($t=i,en=`value`in $t?$t.value:$t.textContent,Hn=!0)),y=Td(r,x),0<y.length&&(x=new xn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=Vn(n),b!==null&&(x.data=b)))),(b=In?Un(e,n):Wn(e,n))&&(x=Td(r,`onBeforeInput`),0<x.length&&(y=new xn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),fd(s,e,r,n,i)}_d(s,t)})}function wd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Td(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=Yt(e,n),i!=null&&r.unshift(wd(e,i,a)),i=Yt(e,t),i!=null&&r.push(wd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ed(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Dd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=Yt(n,a),l!=null&&o.unshift(wd(n,l,c))):i||(l=Yt(n,a),l!=null&&o.push(wd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Od=/\r\n?/g,kd=/\u0000|\uFFFD/g;function Ad(e){return(typeof e==`string`?e:``+e).replace(Od,`
10
- `).replace(kd,``)}function jd(e,t){return t=Ad(t),Ad(e)===t}function Md(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Nt(e,``+r);break;case`className`:vt(e,`class`,r);break;case`tabIndex`:vt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:vt(e,n,r);break;case`style`:It(e,r,o);break;case`data`:if(t!==`object`){vt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&Md(e,t,`name`,a.name,a,null),Md(e,t,`formEncType`,a.formEncType,a,null),Md(e,t,`formMethod`,a.formMethod,a,null),Md(e,t,`formTarget`,a.formTarget,a,null)):(Md(e,t,`encType`,a.encType,a,null),Md(e,t,`method`,a.method,a,null),Md(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=Bt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=Bt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:vd(`beforetoggle`,e),vd(`toggle`,e),_t(e,`popover`,r);break;case`xlinkActuate`:yt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:yt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:yt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:yt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:yt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:yt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:yt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:yt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:yt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:_t(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Rt.get(n)||n,_t(e,n,r))}}function Nd(e,t,n,r,a,o){switch(n){case`style`:It(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Nt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Nt(e,``+r);break;case`onScroll`:r!=null&&vd(`scroll`,e);break;case`onScrollEnd`:r!=null&&vd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Vt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!ft.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[$e]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):_t(e,n,r)}}}function Pd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:vd(`error`,e),vd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,o,s,n,null)}}a&&Md(e,t,`srcSet`,n.srcSet,n,null),r&&Md(e,t,`src`,n.src,n,null);return;case`input`:vd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Md(e,t,r,d,n,null)}}Ot(e,o,c,l,u,s,a,!1);return;case`select`:for(a in vd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Md(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&At(e,!!r,n,!0):At(e,!!r,t,!1);return;case`textarea`:for(s in vd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Md(e,t,s,c,n,null)}Mt(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Md(e,t,l,r,n,null)}return;case`dialog`:vd(`beforetoggle`,e),vd(`toggle`,e),vd(`cancel`,e),vd(`close`,e);break;case`iframe`:case`object`:vd(`load`,e);break;case`video`:case`audio`:for(r=0;r<hd.length;r++)vd(hd[r],e);break;case`image`:vd(`error`,e),vd(`load`,e);break;case`details`:vd(`toggle`,e);break;case`embed`:case`source`:case`link`:vd(`error`,e),vd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Md(e,t,u,r,n,null)}return;default:if(Lt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Nd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Md(e,t,c,r,n,null))}function Fd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Md(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Md(e,t,p,m,r,f)}}Dt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Md(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Md(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?At(e,!!n,n?[]:``,!1):At(e,!!n,t,!0)):At(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Md(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Md(e,t,s,a,r,o)}jt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Md(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Md(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Md(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Md(e,t,u,p,r,m)}return;default:if(Lt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Nd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Nd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Md(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Md(e,t,f,p,r,m)}function Id(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Ld(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Id(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Rd=null,zd=null;function Bd(e){return e.nodeType===9?e:e.ownerDocument}function Vd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Hd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Ud(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Wd=null;function Gd(){var e=window.event;return e&&e.type===`popstate`?e!==Wd&&(Wd=e,!0):(Wd=null,!1)}var Kd=typeof setTimeout==`function`?setTimeout:void 0,qd=typeof clearTimeout==`function`?clearTimeout:void 0,Jd=typeof Promise==`function`?Promise:void 0,Yd=typeof queueMicrotask==`function`?queueMicrotask:Jd===void 0?Kd:function(e){return Jd.resolve(null).then(e).catch(Xd)};function Xd(e){setTimeout(function(){throw e})}function Zd(e){return e===`head`}function Qd(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Np(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)pf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,pf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[it]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&pf(e.ownerDocument.body)}n=i}while(n);Np(t)}function $d(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function ef(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:ef(n),at(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function tf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[it])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=cf(e.nextSibling),e===null)break}return null}function nf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=cf(e.nextSibling),e===null))return null;return e}function rf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=cf(e.nextSibling),e===null))return null;return e}function af(e){return e.data===`$?`||e.data===`$~`}function of(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function sf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function cf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var lf=null;function uf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return cf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function df(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function ff(e,t,n){switch(t=Bd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function pf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);at(e)}var mf=new Map,hf=new Set;function gf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var _f=F.d;F.d={f:vf,r:yf,D:Sf,C:Cf,L:wf,m:Tf,X:Df,S:Ef,M:Of};function vf(){var e=_f.f(),t=_u();return e||t}function yf(e){var t=st(e);t!==null&&t.tag===5&&t.type===`form`?_s(t):_f.r(e)}var bf=typeof document>`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Et(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),ut(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Et(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Et(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Et(n.imageSizes)+`"]`)):i+=`[href="`+Et(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=p({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),ut(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Et(r)+`"][href="`+Et(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=p({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),ut(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=lt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=p({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);ut(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=p({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),ut(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=lt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=p({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),ut(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var a=(a=re.current)?gf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=lt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var o=lt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),o||Nf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=lt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Af(e){return`href="`+Et(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return p({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),ut(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Et(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Et(n.href)+`"]`);if(r)return t.instance=r,ut(r),r;var a=p({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),ut(r),Pd(r,`style`,a),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Af(n.href);var o=e.querySelector(jf(a));if(o)return t.state.loading|=4,t.instance=o,ut(o),o;r=Mf(n),(a=mf.get(a))&&Rf(r,a),o=(e.ownerDocument||e).createElement(`link`),ut(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(o,`link`,r),t.state.loading|=4,Lf(o,n.precedence,e),t.instance=o;case`script`:return o=Pf(n.src),(a=e.querySelector(Ff(o)))?(t.instance=a,ut(a),a):(r=n,(a=mf.get(o))&&(r=p({},n),zf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),ut(a),Pd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Rf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function zf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Bf=null;function Vf(e,t,n){if(Bf===null){var r=new Map,i=Bf=new Map;i.set(n,r)}else i=Bf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[it]||a[Qe]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Hf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,ut(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),ut(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Kf===0&&(Kf=62500*Ld());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&Xf(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Jf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var Qf={$$typeof:x,Provider:null,Consumer:null,_currentValue:I,_currentValue2:I,_threadCount:0};function $f(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=G(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=G(0),this.hiddenUpdates=G(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ep(e,t,n,r,i,a,o,s,c,l,u,d){return e=new $f(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Jr(3,null,null,t),e.current=a,a.stateNode=e,t=Yi(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Oa(a),e}function tp(e){return e?(e=Kr,e):Kr}function np(e,t,n,r,i,a){i=tp(i),r.context===null?r.context=i:r.pendingContext=i,r=Aa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=ja(e,r,t),n!==null&&(fu(n,e,t),Ma(n,e,t))}function rp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function ip(e,t){rp(e,t),(e=e.alternate)&&rp(e,t)}function ap(e){if(e.tag===13||e.tag===31){var t=Ur(e,67108864);t!==null&&fu(t,e,67108864),ip(e,67108864)}}function op(e){if(e.tag===13||e.tag===31){var t=uu();t=qe(t);var n=Ur(e,t);n!==null&&fu(n,e,t),ip(e,t)}}var sp=!0;function cp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=2,up(e,t,n,r)}finally{F.p=a,P.T=i}}function lp(e,t,n,r){var i=P.T;P.T=null;var a=F.p;try{F.p=8,up(e,t,n,r)}finally{F.p=a,P.T=i}}function up(e,t,n,r){if(sp){var i=dp(r);if(i===null)Cd(e,t,r,fp,n),Cp(e,r);else if(Tp(i,e,t,n,r))r.stopPropagation();else if(Cp(e,r),t&4&&-1<Sp.indexOf(e)){for(;i!==null;){var a=st(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Le(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-je(o);s.entanglements[1]|=c,o&=~c}td(a),!(Ml&6)&&(Ql=be()+500,nd(0,!1))}}break;case 31:case 13:s=Ur(a,2),s!==null&&fu(s,a,2),_u(),ip(a,2)}if(a=dp(r),a===null&&Cd(e,t,r,fp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Cd(e,t,r,null,n)}}function dp(e){return e=Ut(e),pp(e)}var fp=null;function pp(e){if(fp=null,e=ot(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return fp=e,null}function mp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(xe()){case Se:return 2;case Ce:return 8;case we:case U:return 32;case Te:return 268435456;default:return 32}default:return 32}}var hp=!1,gp=null,_p=null,vp=null,yp=new Map,bp=new Map,xp=[],Sp=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Cp(e,t){switch(e){case`focusin`:case`focusout`:gp=null;break;case`dragenter`:case`dragleave`:_p=null;break;case`mouseover`:case`mouseout`:vp=null;break;case`pointerover`:case`pointerout`:yp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:bp.delete(t.pointerId)}}function wp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=st(t),t!==null&&ap(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Tp(e,t,n,r,i){switch(t){case`focusin`:return gp=wp(gp,e,t,n,r,i),!0;case`dragenter`:return _p=wp(_p,e,t,n,r,i),!0;case`mouseover`:return vp=wp(vp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return yp.set(a,wp(yp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,bp.set(a,wp(bp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ep(e){var t=ot(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,Xe(e.priority,function(){op(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Dp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Ht=r,n.target.dispatchEvent(r),Ht=null}else return t=st(n),t!==null&&ap(t),e.blockedOn=n,!1;t.shift()}return!0}function Op(e,t,n){Dp(e)&&n.delete(t)}function kp(){hp=!1,gp!==null&&Dp(gp)&&(gp=null),_p!==null&&Dp(_p)&&(_p=null),vp!==null&&Dp(vp)&&(vp=null),yp.forEach(Op),bp.forEach(Op)}function Ap(e,n){e.blockedOn===n&&(e.blockedOn=null,hp||(hp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,kp)))}var jp=null;function Mp(e){jp!==e&&(jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){jp===e&&(jp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(pp(r||n)===null)continue;break}var a=st(n);a!==null&&(e.splice(t,3),t-=3,hs(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Np(e){function t(t){return Ap(t,e)}gp!==null&&Ap(gp,e),_p!==null&&Ap(_p,e),vp!==null&&Ap(vp,e),yp.forEach(t),bp.forEach(t);for(var n=0;n<xp.length;n++){var r=xp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<xp.length&&(n=xp[0],n.blockedOn===null);)Ep(n),n.blockedOn===null&&xp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[$e]||null;if(typeof a==`function`)o||Mp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[$e]||null)s=o.formAction;else if(pp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Mp(n)}}}function Pp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Fp(e){this._internalRoot=e}Ip.prototype.render=Fp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;np(n,uu(),e,t,null,null)},Ip.prototype.unmount=Fp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;np(e.current,2,null,e,null,null),_u(),t[et]=null}};function Ip(e){this._internalRoot=e}Ip.prototype.unstable_scheduleHydration=function(e){if(e){var t=Ye();e={blockedOn:null,target:e,priority:t};for(var n=0;n<xp.length&&t!==0&&t<xp[n].priority;n++);xp.splice(n,0,e),n===0&&Ep(e)}};var Lp=n.version;if(Lp!==`19.2.8`)throw Error(i(527,Lp,`19.2.8`));F.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Rp={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:P,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var zp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zp.isDisabled&&zp.supportsFiber)try{Oe=zp.inject(Rp),ke=zp}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Rs,s=zs,c=Bs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ep(e,1,!1,null,null,n,r,null,o,s,c,Pp),e[et]=t.current,xd(e),new Fp(t)}})),Ct=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=St()})),Y=e(d(),1),X=f();function wt(e={}){let{themeId:t,defaultTheme:n,defaultClassName:r=`MuiBox-root`,generateClassName:i}=e,a=O(`div`,{shouldForwardProp:e=>e!==`theme`&&e!==`sx`&&e!==`as`})(D);return Y.forwardRef(function(e,o){let s=b(n),{className:c,component:l=`div`,...u}=e;return(0,X.jsx)(a,{as:l,ref:o,className:h(c,i?i(r):r),theme:t&&s[t]||s,...u})})}var Tt=ve();function Et(e){let{theme:t,name:n,props:r}=e;return!t||!t.components||!t.components[n]||!t.components[n].defaultProps?r:Ce(t.components[n].defaultProps,r)}function Dt(e){let{props:t,name:n,defaultTheme:r,themeId:i}=e,a=b(r);return i&&(a=a[i]||a),Et({theme:a,name:n,props:t})}function Ot(e,t,n,r,i){let[a,o]=Y.useState(()=>i&&n?n(e).matches:r?r(e).matches:t);return xe(()=>{if(!n)return;let t=n(e),r=()=>{o(t.matches)};return r(),t.addEventListener(`change`,r),()=>{t.removeEventListener(`change`,r)}},[e,n]),a}var kt={...Y}.useSyncExternalStore;function At(e,t,n,r,i){let a=Y.useCallback(()=>t,[t]),o=Y.useMemo(()=>{if(i&&n)return()=>n(e).matches;if(r!==null){let{matches:t}=r(e);return()=>t}return a},[a,e,r,i,n]),[s,c]=Y.useMemo(()=>{if(n===null)return[a,()=>()=>{}];let t=n(e);return[()=>t.matches,e=>(t.addEventListener(`change`,e),()=>{t.removeEventListener(`change`,e)})]},[a,n,e]);return kt(c,s,o)}function jt(e={}){let{themeId:t}=e;return function(e,n={}){let r=_();r&&t&&(r=r[t]||r);let i=typeof window<`u`&&window.matchMedia!==void 0?window.matchMedia:null,{defaultMatches:a=!1,matchMedia:o,ssrMatchMedia:s=null,noSsr:c=!1}=Et({name:`MuiUseMediaQuery`,props:n,theme:r}),l=Y.useMemo(()=>o===void 0?i===null?null:i.bind(window):o,[o,i]),u=typeof e==`function`?e(r):e;return u=u.replace(/^@media( ?)/m,``),u.includes(`print`)&&console.warn(["MUI: You have provided a `print` query to the `useMediaQuery` hook.",`Using the print media query to modify print styles can lead to unexpected results.`,"Consider using the `displayPrint` field in the `sx` prop instead.","More information about `displayPrint` on our docs: https://mui.com/system/display/#display-in-print."].join(`
11
- `)),(kt===void 0?Ot:At)(u,a,l,s,c)}}jt();var Mt=Y.createContext(null);function Nt(){return Y.useContext(Mt)}var Pt=typeof Symbol==`function`&&Symbol.for?Symbol.for(`mui.nested`):`__THEME_NESTED__`;function Ft(e,t){return typeof t==`function`?t(e):{...e,...t}}function It(e){let{children:t,theme:n}=e,r=Nt(),i=Y.useMemo(()=>{let e=r===null?{...n}:Ft(r,n);return e!=null&&(e[Pt]=r!==null),e},[n,r]);return(0,X.jsx)(Mt.Provider,{value:i,children:t})}function Lt(e){let t=_(),n=Pe()||``,{modularCssLayers:r}=e,i=`mui.global, mui.components, mui.theme, mui.custom, mui.sx`;return i=!r||t!==null?``:typeof r==`string`?r.replace(/mui(?!\.)/g,i):`@layer ${i};`,xe(()=>{let e=document.querySelector(`head`);if(!e)return;let t=e.firstChild;if(i){if(t&&t.hasAttribute?.(`data-mui-layer-order`)&&t.getAttribute(`data-mui-layer-order`)===n)return;let r=document.createElement(`style`);r.setAttribute(`data-mui-layer-order`,n),r.textContent=i,e.prepend(r)}else e.querySelector(`style[data-mui-layer-order="${n}"]`)?.remove()},[i,n]),i?(0,X.jsx)(A,{styles:i}):null}var Rt={};function zt(e,t,n,r=!1){return Y.useMemo(()=>{let i=e&&t[e]||t;if(typeof n==`function`){let a=n(i),o=e?{...t,[e]:a}:a;return r?()=>o:o}return e?{...t,[e]:n}:{...t,...n}},[e,t,n,r])}function Bt(e){let{children:t,theme:n,themeId:r}=e,i=_(Rt),o=Nt()||Rt,s=zt(r,i,n),c=zt(r,o,n,!0),l=(r?s[r]:s).direction===`rtl`,u=Lt(s);return(0,X.jsx)(It,{theme:c,children:(0,X.jsx)(a.Provider,{value:s,children:(0,X.jsx)(qe,{value:l,children:(0,X.jsxs)(be,{value:r?s[r].components:s.components,children:[u,t]})})})})}var Vt=`mode`,Ht=`color-scheme`,Ut=`data-color-scheme`;({...Y}).useSyncExternalStore;function Wt(e){let{defaultMode:t=`system`,defaultLightColorScheme:n=`light`,defaultDarkColorScheme:r=`dark`,modeStorageKey:i=Vt,colorSchemeStorageKey:a=Ht,attribute:o=Ut,colorSchemeNode:s=`document.documentElement`,nonce:c}=e||{},l=``,u=o;if(o===`class`&&(u=`.%s`),o===`data`&&(u=`[data-%s]`),u.startsWith(`.`)){let e=u.substring(1);l+=`${s}.classList.remove('${e}'.replace('%s', light), '${e}'.replace('%s', dark));
12
- ${s}.classList.add('${e}'.replace('%s', colorScheme));`}let d=u.match(/\[([^[\]]+)\]/);if(d){let[e,t]=d[1].split(`=`);t||(l+=`${s}.removeAttribute('${e}'.replace('%s', light));
13
- ${s}.removeAttribute('${e}'.replace('%s', dark));`),l+=`
14
- ${s}.setAttribute('${e}'.replace('%s', colorScheme), ${t?`${t}.replace('%s', colorScheme)`:`""`});`}else u!==`.%s`&&(l+=`${s}.setAttribute('${u}', colorScheme);`);return(0,X.jsx)(`script`,{suppressHydrationWarning:!0,nonce:typeof window>`u`?c:``,dangerouslySetInnerHTML:{__html:`(function() {
15
- try {
16
- let colorScheme = '';
17
- const mode = localStorage.getItem('${i}') || '${t}';
18
- const dark = localStorage.getItem('${a}-dark') || '${r}';
19
- const light = localStorage.getItem('${a}-light') || '${n}';
20
- if (mode === 'system') {
21
- // handle system mode
22
- const mql = window.matchMedia('(prefers-color-scheme: dark)');
23
- if (mql.matches) {
24
- colorScheme = dark
25
- } else {
26
- colorScheme = light
27
- }
28
- }
29
- if (mode === 'light') {
30
- colorScheme = light;
31
- }
32
- if (mode === 'dark') {
33
- colorScheme = dark;
34
- }
35
- if (colorScheme) {
36
- ${l}
37
- }
38
- } catch(e){}})();`}},`mui-color-scheme-init`)}function Gt(){}var Kt=({key:e,storageWindow:t})=>(!t&&typeof window<`u`&&(t=window),{get(n){if(typeof window>`u`)return;if(!t)return n;let r;try{r=t.localStorage.getItem(e)}catch{}return r||n},set:n=>{if(t)try{t.localStorage.setItem(e,n)}catch{}},subscribe:n=>{if(!t)return Gt;let r=t=>{let r=t.newValue;t.key===e&&n(r)};return t.addEventListener(`storage`,r),()=>{t.removeEventListener(`storage`,r)}}});function qt(){}function Jt(e){if(typeof window<`u`&&typeof window.matchMedia==`function`&&e===`system`)return window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function Yt(e,t){if(e.mode===`light`||e.mode===`system`&&e.systemMode===`light`)return t(`light`);if(e.mode===`dark`||e.mode===`system`&&e.systemMode===`dark`)return t(`dark`)}function Xt(e){return Yt(e,t=>{if(t===`light`)return e.lightColorScheme;if(t===`dark`)return e.darkColorScheme})}function Zt(e){let{defaultMode:t=`light`,defaultLightColorScheme:n,defaultDarkColorScheme:r,supportedColorSchemes:i=[],modeStorageKey:a=Vt,colorSchemeStorageKey:o=Ht,storageWindow:s=typeof window>`u`?void 0:window,storageManager:c=Kt,noSsr:l=!1}=e,u=i.join(`,`),d=i.length>1,f=Y.useMemo(()=>c?.({key:a,storageWindow:s}),[c,a,s]),p=Y.useMemo(()=>c?.({key:`${o}-light`,storageWindow:s}),[c,o,s]),m=Y.useMemo(()=>c?.({key:`${o}-dark`,storageWindow:s}),[c,o,s]),[h,g]=Y.useState(()=>{let e=f?.get(t)||t,i=p?.get(n)||n,a=m?.get(r)||r;return{mode:e,systemMode:Jt(e),lightColorScheme:i,darkColorScheme:a}}),[_,v]=Y.useState(l||!d);Y.useEffect(()=>{v(!0)},[]);let y=Xt(h),b=Y.useCallback(e=>{g(n=>{if(e===n.mode)return n;let r=e??t;return f?.set(r),{...n,mode:r,systemMode:Jt(r)}})},[f,t]),x=Y.useCallback(e=>{e?typeof e==`string`?e&&!u.includes(e)?console.error(`\`${e}\` does not exist in \`theme.colorSchemes\`.`):g(t=>{let n={...t};return Yt(t,t=>{t===`light`&&(p?.set(e),n.lightColorScheme=e),t===`dark`&&(m?.set(e),n.darkColorScheme=e)}),n}):g(t=>{let i={...t},a=e.light===null?n:e.light,o=e.dark===null?r:e.dark;return a&&(u.includes(a)?(i.lightColorScheme=a,p?.set(a)):console.error(`\`${a}\` does not exist in \`theme.colorSchemes\`.`)),o&&(u.includes(o)?(i.darkColorScheme=o,m?.set(o)):console.error(`\`${o}\` does not exist in \`theme.colorSchemes\`.`)),i}):g(e=>(p?.set(n),m?.set(r),{...e,lightColorScheme:n,darkColorScheme:r}))},[u,p,m,n,r]),S=Y.useCallback(e=>{h.mode===`system`&&g(t=>{let n=e?.matches?`dark`:`light`;return t.systemMode===n?t:{...t,systemMode:n}})},[h.mode]),C=Y.useRef(S);return C.current=S,Y.useEffect(()=>{if(typeof window.matchMedia!=`function`||!d)return;let e=(...e)=>C.current(...e),t=window.matchMedia(`(prefers-color-scheme: dark)`);return t.addListener(e),e(t),()=>{t.removeListener(e)}},[d]),Y.useEffect(()=>{if(d){let e=f?.subscribe(e=>{(!e||[`light`,`dark`,`system`].includes(e))&&b(e||t)})||qt,n=p?.subscribe(e=>{(!e||u.match(e))&&x({light:e})})||qt,r=m?.subscribe(e=>{(!e||u.match(e))&&x({dark:e})})||qt;return()=>{e(),n(),r()}}},[x,b,u,t,s,d,f,p,m]),{...h,mode:_?h.mode:void 0,systemMode:_?h.systemMode:void 0,colorScheme:_?y:void 0,setMode:b,setColorScheme:x}}var Qt=`*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`;function $t(e){let{themeId:t,theme:n={},modeStorageKey:r=Vt,colorSchemeStorageKey:i=Ht,disableTransitionOnChange:a=!1,defaultColorScheme:o,resolveTheme:s}=e,c={allColorSchemes:[],colorScheme:void 0,darkColorScheme:void 0,lightColorScheme:void 0,mode:void 0,setColorScheme:()=>{},setMode:()=>{},systemMode:void 0},l=Y.createContext(void 0),u=()=>Y.useContext(l)||c,d={},f={};function p(e){let{children:c,theme:u,modeStorageKey:p=r,colorSchemeStorageKey:m=i,disableTransitionOnChange:h=a,storageManager:g,storageWindow:_=typeof window>`u`?void 0:window,documentNode:v=typeof document>`u`?void 0:document,colorSchemeNode:y=typeof document>`u`?void 0:document.documentElement,disableNestedContext:b=!1,disableStyleSheetGeneration:x=!1,defaultMode:S=`system`,forceThemeRerender:C=!1,noSsr:w}=e,T=Y.useRef(!1),E=Nt(),D=Y.useContext(l),O=!!D&&!b,k=Y.useMemo(()=>u||(typeof n==`function`?n():n),[u]),A=k[t],j=A||k,{colorSchemes:N=d,components:P=f,cssVarPrefix:F}=j,I=Object.keys(N).filter(e=>!!N[e]).join(`,`),L=Y.useMemo(()=>I.split(`,`),[I]),R=typeof o==`string`?o:o.light,z=typeof o==`string`?o:o.dark,{mode:B,setMode:V,systemMode:ee,lightColorScheme:te,darkColorScheme:ne,colorScheme:re,setColorScheme:ie}=Zt({supportedColorSchemes:L,defaultLightColorScheme:R,defaultDarkColorScheme:z,modeStorageKey:p,colorSchemeStorageKey:m,defaultMode:N[R]&&N[z]?S:N[j.defaultColorScheme]?.palette?.mode||j.palette?.mode,storageManager:g,storageWindow:_,noSsr:w}),ae=B,oe=re;O&&(ae=D.mode,oe=D.colorScheme);let se=oe||j.defaultColorScheme;j.vars&&!C&&(se=j.defaultColorScheme);let ce=Y.useMemo(()=>{let e=j.generateThemeVars?.()||j.vars,t={...j,components:P,colorSchemes:N,cssVarPrefix:F,vars:e};if(typeof t.generateSpacing==`function`&&(t.spacing=t.generateSpacing()),se){let e=N[se];e&&typeof e==`object`&&Object.keys(e).forEach(n=>{e[n]&&typeof e[n]==`object`?t[n]={...t[n],...e[n]}:t[n]=e[n]})}return s?s(t):t},[j,se,P,N,F]),le=j.colorSchemeSelector;xe(()=>{if(oe&&y&&le&&le!==`media`){let e=le,t=le;if(e===`class`&&(t=`.%s`),e===`data`&&(t=`[data-%s]`),e?.startsWith(`data-`)&&!e.includes(`%s`)&&(t=`[${e}="%s"]`),t.startsWith(`.`))y.classList.remove(...L.map(e=>t.substring(1).replace(`%s`,e))),y.classList.add(t.substring(1).replace(`%s`,oe));else{let e=t.replace(`%s`,oe).match(/\[([^\]]+)\]/);if(e){let[t,n]=e[1].split(`=`);n||L.forEach(e=>{y.removeAttribute(t.replace(oe,e))}),y.setAttribute(t,n?n.replace(/"|'/g,``):``)}else y.setAttribute(t,oe)}}},[oe,le,y,L]),Y.useEffect(()=>{let e;if(h&&T.current&&v){let t=v.createElement(`style`);t.appendChild(v.createTextNode(Qt)),v.head.appendChild(t),window.getComputedStyle(v.body),e=setTimeout(()=>{v.head.removeChild(t)},1)}return()=>{clearTimeout(e)}},[oe,h,v]),Y.useEffect(()=>(T.current=!0,()=>{T.current=!1}),[]);let ue=Y.useMemo(()=>({allColorSchemes:L,colorScheme:oe,darkColorScheme:ne,lightColorScheme:te,mode:ae,setColorScheme:ie,setMode:V,systemMode:ee}),[L,oe,ne,te,ae,ie,V,ee,ce.colorSchemeSelector]),de=!0;(x||j.cssVariables===!1||O&&E?.cssVarPrefix===F)&&(de=!1);let fe=(0,X.jsxs)(Y.Fragment,{children:[(0,X.jsx)(Bt,{themeId:A?t:void 0,theme:ce,children:c}),de&&(0,X.jsx)(M,{styles:ce.generateStyleSheets?.()||[]})]});return O?fe:(0,X.jsx)(l.Provider,{value:ue,children:fe})}let m=typeof o==`string`?o:o.light,h=typeof o==`string`?o:o.dark;return{CssVarsProvider:p,useColorScheme:u,getInitColorSchemeScript:e=>Wt({colorSchemeStorageKey:i,defaultLightColorScheme:m,defaultDarkColorScheme:h,modeStorageKey:r,...e})}}var en=g(),tn=Tt(`div`,{name:`MuiStack`,slot:`Root`});function nn(e){return Dt({props:e,name:`MuiStack`,defaultTheme:en})}function rn(e,t){let n=Y.Children.toArray(e).filter(Boolean);return n.reduce((e,r,i)=>(e.push(r),i<n.length-1&&e.push(Y.cloneElement(t,{key:`separator-${i}`})),e),[])}var an=e=>({row:`Left`,"row-reverse":`Right`,column:`Top`,"column-reverse":`Bottom`})[e],on=({ownerState:e,theme:t})=>{let a={display:`flex`,flexDirection:`column`,...u({theme:t},r({values:e.direction,breakpoints:t.breakpoints.values}),e=>({flexDirection:e}))};if(e.spacing){let i=l(t),o=Object.keys(t.breakpoints.values).reduce((t,n)=>((typeof e.spacing==`object`&&e.spacing[n]!=null||typeof e.direction==`object`&&e.direction[n]!=null)&&(t[n]=!0),t),{}),s=r({values:e.direction,base:o}),d=r({values:e.spacing,base:o});typeof s==`object`&&Object.keys(s).forEach((e,t,n)=>{if(!s[e]){let r=t>0?s[n[t-1]]:`column`;s[e]=r}}),a=c(a,u({theme:t},d,(t,r)=>e.useFlexGap?{gap:n(i,t)}:{"& > :not(style):not(style)":{margin:0},"& > :not(style) ~ :not(style)":{[`margin${an(r?s[r]:e.direction)}`]:n(i,t)}}))}return a=i(t.breakpoints,a),a};function sn(e={}){let{createStyledComponent:t=tn,useThemeProps:n=nn,componentName:r=`MuiStack`}=e,i=()=>he({root:[`root`]},e=>m(r,e),{}),a=t(on);return Y.forwardRef(function(e,t){let{component:r=`div`,direction:o=`column`,spacing:s=0,divider:c,children:l,className:u,useFlexGap:d=!1,...f}=n(e),p={direction:o,spacing:s,useFlexGap:d},m=i();return(0,X.jsx)(a,{as:r,ownerState:p,ref:t,className:h(m.root,u),...f,children:c?rn(l,c):l})})}var cn=typeof j({})==`function`,ln=(e,t)=>({WebkitFontSmoothing:`antialiased`,MozOsxFontSmoothing:`grayscale`,boxSizing:`border-box`,WebkitTextSizeAdjust:`100%`,...t&&!e.vars&&{colorScheme:e.palette.mode}}),un=e=>({color:(e.vars||e).palette.text.primary,...e.typography.body1,backgroundColor:(e.vars||e).palette.background.default,"@media print":{backgroundColor:(e.vars||e).palette.common.white}}),dn=(e,t=!1)=>{let n={};t&&e.colorSchemes&&typeof e.getColorSchemeSelector==`function`&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={":root":{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={colorScheme:r.palette?.mode}});let r={html:ln(e,t),"*, *::before, *::after":{boxSizing:`inherit`},"strong, b":{fontWeight:e.typography.fontWeightBold},body:{margin:0,...un(e),"&::backdrop":{backgroundColor:(e.vars||e).palette.background.default}},...n},i=e.components?.MuiCssBaseline?.styleOverrides;return i&&(r=[r,i]),r},fn=`mui-ecs`,pn=e=>{let t=dn(e,!1),n=Array.isArray(t)?t[0]:t;return!e.vars&&n&&(n.html[`:root:has(${fn})`]={colorScheme:e.palette.mode}),e.colorSchemes&&Object.entries(e.colorSchemes).forEach(([t,r])=>{let i=e.getColorSchemeSelector(t);i.startsWith(`@`)?n[i]={[`:root:not(:has(.${fn}))`]:{colorScheme:r.palette?.mode}}:n[i.replace(/\s*&/,``)]={[`&:not(:has(.${fn}))`]:{colorScheme:r.palette?.mode}}}),t},mn=j(cn?({theme:e,enableColorScheme:t})=>dn(e,t):({theme:e})=>pn(e));function hn(e){let{children:t,enableColorScheme:n=!1}=_e({props:e,name:`MuiCssBaseline`});return(0,X.jsxs)(Y.Fragment,{children:[cn&&(0,X.jsx)(mn,{enableColorScheme:n}),!cn&&!n&&(0,X.jsx)(`span`,{className:fn,style:{display:`none`}}),t]})}function gn(e){return m(`MuiListItemButton`,e)}var _n=E(`MuiListItemButton`,[`root`,`focusVisible`,`dense`,`alignItemsFlexStart`,`disabled`,`divider`,`gutters`,`selected`]);function vn(e){return m(`MuiMenuItem`,e)}var yn=E(`MuiMenuItem`,[`root`,`focusVisible`,`dense`,`disabled`,`divider`,`gutters`,`selected`]);function bn(e){return m(`MuiToggleButton`,e)}var xn=E(`MuiToggleButton`,[`root`,`disabled`,`selected`,`standard`,`primary`,`secondary`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`fullWidth`]);function Sn({theme:e,...t}){let n=`$$material`in e?e[x]:void 0;return(0,X.jsx)(Bt,{...t,themeId:n?x:void 0,theme:n||e})}var Cn={attribute:`data-mui-color-scheme`,colorSchemeStorageKey:`mui-color-scheme`,defaultLightColorScheme:`light`,defaultDarkColorScheme:`dark`,modeStorageKey:`mui-mode`},{CssVarsProvider:wn,useColorScheme:Tn,getInitColorSchemeScript:En}=$t({themeId:x,theme:()=>v({cssVariables:!0}),colorSchemeStorageKey:Cn.colorSchemeStorageKey,modeStorageKey:Cn.modeStorageKey,defaultColorScheme:{light:Cn.defaultLightColorScheme,dark:Cn.defaultDarkColorScheme},resolveTheme:e=>{let t={...e,typography:w(e.palette,e.typography)};return t.unstable_sx=function(e){return D({sx:e,theme:this})},t}}),Dn=wn;function On({theme:e,...t}){let n=Y.useMemo(()=>{if(typeof e==`function`)return e;let t=`$$material`in e?e[x]:e;return`colorSchemes`in t?null:`vars`in t?e:{...e,vars:null}},[e]);return n?(0,X.jsx)(Sn,{theme:n,...t}):(0,X.jsx)(Dn,{theme:e,...t})}function kn(e){return m(`MuiAppBar`,e)}E(`MuiAppBar`,[`root`,`positionFixed`,`positionAbsolute`,`positionSticky`,`positionStatic`,`positionRelative`,`colorDefault`,`colorPrimary`,`colorSecondary`,`colorInherit`,`colorTransparent`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`]);var An=e=>{let{color:t,position:n,classes:r}=e,i={root:[`root`,`color${U(t)}`,`position${U(n)}`]};return he(i,kn,r)},jn=(e,t)=>e?`${e.replace(`)`,``)}, ${t})`:t,Mn=H(ft,{name:`MuiAppBar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${U(n.position)}`],t[`color${U(n.color)}`]]}})(ge(({theme:e})=>({display:`flex`,flexDirection:`column`,width:`100%`,boxSizing:`border-box`,flexShrink:0,variants:[{props:{position:`fixed`},style:{position:`fixed`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0,"@media print":{position:`absolute`}}},{props:{position:`absolute`},style:{position:`absolute`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0}},{props:{position:`sticky`},style:{position:`sticky`,zIndex:(e.vars||e).zIndex.appBar,top:0,left:`auto`,right:0}},{props:{position:`static`},style:{position:`static`}},{props:{position:`relative`},style:{position:`relative`}},{props:{color:`inherit`},style:{"--AppBar-color":`inherit`,color:`var(--AppBar-color)`}},{props:{color:`default`},style:{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[100],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[100]),...e.applyStyles(`dark`,{"--AppBar-background":e.vars?e.vars.palette.AppBar.defaultBg:e.palette.grey[900],"--AppBar-color":e.vars?e.vars.palette.text.primary:e.palette.getContrastText(e.palette.grey[900])})}},...Object.entries(e.palette).filter(Re([`contrastText`])).map(([t])=>({props:{color:t},style:{"--AppBar-background":(e.vars??e).palette[t].main,"--AppBar-color":(e.vars??e).palette[t].contrastText}})),{props:e=>e.enableColorOnDark===!0&&![`inherit`,`transparent`].includes(e.color),style:{backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`}},{props:e=>e.enableColorOnDark===!1&&![`inherit`,`transparent`].includes(e.color),style:{backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`,...e.applyStyles(`dark`,{backgroundColor:e.vars?jn(e.vars.palette.AppBar.darkBg,`var(--AppBar-background)`):null,color:e.vars?jn(e.vars.palette.AppBar.darkColor,`var(--AppBar-color)`):null})}},{props:{color:`transparent`},style:{"--AppBar-background":`transparent`,"--AppBar-color":`inherit`,backgroundColor:`var(--AppBar-background)`,color:`var(--AppBar-color)`,...e.applyStyles(`dark`,{backgroundImage:`none`})}}]}))),Nn=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiAppBar`}),{className:r,color:i=`primary`,enableColorOnDark:a=!1,position:o=`fixed`,...s}=n,c={...n,color:i,position:o,enableColorOnDark:a},l=An(c);return(0,X.jsx)(Mn,{square:!0,component:`header`,ownerState:c,elevation:4,className:h(l.root,r,o===`fixed`&&`mui-fixed`),ref:t,...s})});function Pn(e){let t=Y.useRef({});return Y.useEffect(()=>{t.current=e}),t.current}function Fn(e){let{badgeContent:t,invisible:n=!1,max:r=99,showZero:i=!1}=e,a=Pn({badgeContent:t,max:r}),o=n;n===!1&&t===0&&!i&&(o=!0);let{badgeContent:s,max:c=r}=o?a:e,l=s&&Number(s)>c?`${c}+`:s;return{badgeContent:s,invisible:o,max:c,displayValue:l}}function In(e){return m(`MuiBadge`,e)}var Ln=E(`MuiBadge`,[`root`,`badge`,`dot`,`standard`,`anchorOriginTopRight`,`anchorOriginBottomRight`,`anchorOriginTopLeft`,`anchorOriginBottomLeft`,`invisible`,`colorError`,`colorInfo`,`colorPrimary`,`colorSecondary`,`colorSuccess`,`colorWarning`,`overlapRectangular`,`overlapCircular`,`anchorOriginTopLeftCircular`,`anchorOriginTopLeftRectangular`,`anchorOriginTopRightCircular`,`anchorOriginTopRightRectangular`,`anchorOriginBottomLeftCircular`,`anchorOriginBottomLeftRectangular`,`anchorOriginBottomRightCircular`,`anchorOriginBottomRightRectangular`]),Rn=10,zn=4,Bn=e=>{let{color:t,anchorOrigin:n,invisible:r,overlap:i,variant:a,classes:o={}}=e,s={root:[`root`],badge:[`badge`,a,r&&`invisible`,`anchorOrigin${U(n.vertical)}${U(n.horizontal)}`,`anchorOrigin${U(n.vertical)}${U(n.horizontal)}${U(i)}`,`overlap${U(i)}`,t!=="default"&&`color${U(t)}`]};return he(s,In,o)},Vn=H(`span`,{name:`MuiBadge`,slot:`Root`})({position:`relative`,display:`inline-flex`,verticalAlign:`middle`,flexShrink:0}),Hn=H(`span`,{name:`MuiBadge`,slot:`Badge`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.badge,t[n.variant],t[`anchorOrigin${U(n.anchorOrigin.vertical)}${U(n.anchorOrigin.horizontal)}${U(n.overlap)}`],n.color!=="default"&&t[`color${U(n.color)}`],n.invisible&&t.invisible]}})(ge(({theme:e})=>({display:`flex`,flexDirection:`row`,flexWrap:`wrap`,justifyContent:`center`,alignContent:`center`,alignItems:`center`,position:`absolute`,boxSizing:`border-box`,fontFamily:e.typography.fontFamily,fontWeight:e.typography.fontWeightMedium,fontSize:e.typography.pxToRem(12),minWidth:20,lineHeight:1,padding:`0 6px`,height:20,borderRadius:Rn,zIndex:1,"@media (forced-colors: active)":{border:`1px solid ButtonBorder`},...Ee(e,`transform`,{easing:e.transitions.easing.easeInOut,duration:e.transitions.duration.enteringScreen}),variants:[...Object.entries(e.palette).filter(Re([`contrastText`])).map(([t])=>({props:{color:t},style:{backgroundColor:(e.vars||e).palette[t].main,color:(e.vars||e).palette[t].contrastText}})),{props:{variant:`dot`},style:{borderRadius:zn,height:8,minWidth:8,padding:0}},{props:{invisible:!0},style:{...Ee(e,`transform`,{easing:e.transitions.easing.easeInOut,duration:e.transitions.duration.leavingScreen})}},{style:{inset:`var(--Badge-inset)`,transform:`scale(1) translate(var(--Badge-translate))`,transformOrigin:`var(--Badge-origin)`,[`&.${Ln.invisible}`]:{transform:`scale(0) translate(var(--Badge-translate))`}}}]})));function Un(e){return{vertical:e?.vertical??`top`,horizontal:e?.horizontal??`right`}}var Wn=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiBadge`}),{anchorOrigin:r,className:i,classes:a,component:o,children:s,overlap:c=`rectangular`,color:l=`default`,invisible:u=!1,max:d=99,badgeContent:f,slots:p,slotProps:m,showZero:g=!1,variant:_=`standard`,...v}=n,{badgeContent:y,invisible:b,max:x,displayValue:S}=Fn({max:d,invisible:u,badgeContent:f,showZero:g}),C=Pn({anchorOrigin:Un(r),color:l,overlap:c,variant:_,badgeContent:f}),w=b||y==null&&_!==`dot`,{color:T=l,overlap:E=c,anchorOrigin:D,variant:O=_}=w?C:n,k=Un(D),A=O===`dot`?void 0:S,j={...n,badgeContent:y,invisible:w,max:x,displayValue:A,showZero:g,anchorOrigin:k,color:T,overlap:E,variant:O},M=Bn(j),N={slots:p,slotProps:m},[P,F]=$e(`root`,{elementType:Vn,externalForwardedProps:{...N,...v},ownerState:j,className:h(M.root,i),ref:t,additionalProps:{as:o}}),{vertical:I,horizontal:L}=k,R=E===`circular`?`14%`:`0`,z=I===`top`?R:`auto`,B=I===`bottom`?R:`auto`,V=L===`right`?R:`auto`,ee=L===`left`?R:`auto`,[te,ne]=$e(`badge`,{elementType:Hn,externalForwardedProps:N,ownerState:j,className:M.badge,additionalProps:{"aria-hidden":!0,style:{"--Badge-translate":`${L===`right`?`50%`:`-50%`}, ${I===`top`?`-50%`:`50%`}`,"--Badge-inset":`${z} ${V} ${B} ${ee}`,"--Badge-origin":`${L===`right`?`100%`:`0%`} ${I===`top`?`0%`:`100%`}`}}});return(0,X.jsxs)(P,{...F,children:[s,(0,X.jsx)(te,{...ne,children:A})]})}),Gn=E(`MuiBox`,[`root`]),Kn=v(),Z=wt({themeId:x,defaultTheme:Kn,defaultClassName:Gn.root,generateClassName:C.generate}),qn=K((0,X.jsx)(`path`,{d:`M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z`}),`Cancel`);function Jn(e){return m(`MuiChip`,e)}var Yn=E(`MuiChip`,[`root`,`sizeSmall`,`sizeMedium`,`colorDefault`,`colorError`,`colorInfo`,`colorPrimary`,`colorSecondary`,`colorSuccess`,`colorWarning`,`disabled`,`clickable`,`deletable`,`outlined`,`filled`,`avatar`,`icon`,`label`,`deleteIcon`,`focusVisible`]),Xn=e=>{let{classes:t,disabled:n,size:r,color:i,onDelete:a,clickable:o,variant:s}=e,c={root:[`root`,s,n&&`disabled`,`size${U(r)}`,`color${U(i)}`,o&&`clickable`,a&&`deletable`],label:[`label`],avatar:[`avatar`],icon:[`icon`],deleteIcon:[`deleteIcon`]};return he(c,Jn,t)},Zn=H(`div`,{name:`MuiChip`,slot:`Root`,shouldForwardProp:e=>Se(e)&&e!==`focusableWhenDisabled`&&e!==`skipFocusWhenDisabled`,overridesResolver:(e,t)=>{let{ownerState:n}=e,{color:r,clickable:i,onDelete:a,size:o,variant:s}=n;return[{[`& .${Yn.avatar}`]:t.avatar},{[`& .${Yn.icon}`]:t.icon},{[`& .${Yn.deleteIcon}`]:t.deleteIcon},t.root,t[`size${U(o)}`],t[`color${U(r)}`],i&&t.clickable,a&&t.deletable,t[s]]}})(ge(({theme:e})=>{let t=e.palette.mode===`light`?e.palette.grey[700]:e.palette.grey[300];return{maxWidth:`100%`,fontFamily:e.typography.fontFamily,fontSize:e.typography.pxToRem(13),display:`inline-flex`,alignItems:`center`,justifyContent:`center`,height:32,lineHeight:1.5,color:(e.vars||e).palette.text.primary,backgroundColor:(e.vars||e).palette.action.selected,borderRadius:16,whiteSpace:`nowrap`,...Ee(e,[`background-color`,`box-shadow`]),cursor:`unset`,outline:0,textDecoration:`none`,border:0,padding:0,verticalAlign:`middle`,boxSizing:`border-box`,[`&.${Yn.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity,pointerEvents:`none`},[`& .${Yn.avatar}`]:{marginLeft:5,marginRight:-6,width:24,height:24,color:e.vars?e.vars.palette.Chip.defaultAvatarColor:t,fontSize:e.typography.pxToRem(12)},[`& .${Yn.icon}`]:{marginLeft:5,marginRight:-6},[`& .${Yn.deleteIcon}`]:{WebkitTapHighlightColor:`transparent`,color:e.alpha((e.vars||e).palette.text.primary,.26),fontSize:22,cursor:`pointer`,margin:`0 5px 0 -6px`,"&:hover":{color:e.alpha((e.vars||e).palette.text.primary,.4)}},variants:[{props:{color:`primary`},style:{[`& .${Yn.avatar}`]:{color:(e.vars||e).palette.primary.contrastText,backgroundColor:(e.vars||e).palette.primary.dark}}},{props:{color:`secondary`},style:{[`& .${Yn.avatar}`]:{color:(e.vars||e).palette.secondary.contrastText,backgroundColor:(e.vars||e).palette.secondary.dark}}},{props:{size:`small`},style:{height:24,[`& .${Yn.avatar}`]:{marginLeft:4,marginRight:-4,width:18,height:18,fontSize:e.typography.pxToRem(10)},[`& .${Yn.icon}`]:{fontSize:18,marginLeft:4,marginRight:-4},[`& .${Yn.deleteIcon}`]:{fontSize:16,marginRight:4,marginLeft:-4}}},...Object.entries(e.palette).filter(Re([`contrastText`])).map(([t])=>({props:{color:t},style:{backgroundColor:(e.vars||e).palette[t].main,color:(e.vars||e).palette[t].contrastText,[`& .${Yn.deleteIcon}`]:{color:e.alpha((e.vars||e).palette[t].contrastText,.7),"&:hover, &:active":{color:(e.vars||e).palette[t].contrastText}}}})),{props:e=>e.iconColor===e.color,style:{[`& .${Yn.icon}`]:{color:e.vars?e.vars.palette.Chip.defaultIconColor:t}}},{props:e=>e.iconColor===e.color&&e.color!=="default",style:{[`& .${Yn.icon}`]:{color:`inherit`}}},{props:{onDelete:!0},style:{[`&.${Yn.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.action.selected,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}}},...Object.entries(e.palette).filter(Re([`dark`])).map(([t])=>({props:{color:t,onDelete:!0},style:{[`&.${Yn.focusVisible}`]:{background:(e.vars||e).palette[t].dark}}})),{props:{clickable:!0},style:{userSelect:`none`,WebkitTapHighlightColor:`transparent`,cursor:`pointer`,"&:hover":{backgroundColor:e.alpha((e.vars||e).palette.action.selected,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`)},[`&.${Yn.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.action.selected,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)},"&:active":{boxShadow:(e.vars||e).shadows[1]}}},...Object.entries(e.palette).filter(Re([`dark`])).map(([t])=>({props:{color:t,clickable:!0},style:{[`&:hover, &.${Yn.focusVisible}`]:{backgroundColor:(e.vars||e).palette[t].dark}}})),{props:{variant:`outlined`},style:{backgroundColor:`transparent`,border:e.vars?`1px solid ${e.vars.palette.Chip.defaultBorder}`:`1px solid ${e.palette.mode===`light`?e.palette.grey[400]:e.palette.grey[700]}`,[`&.${Yn.clickable}:hover`]:{backgroundColor:(e.vars||e).palette.action.hover},[`&.${Yn.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`& .${Yn.avatar}`]:{marginLeft:4},[`& .${Yn.icon}`]:{marginLeft:4},[`& .${Yn.deleteIcon}`]:{marginRight:5}}},{props:{size:`small`,variant:`outlined`},style:{[`& .${Yn.avatar}`]:{marginLeft:2},[`& .${Yn.icon}`]:{marginLeft:2},[`& .${Yn.deleteIcon}`]:{marginRight:3}}},...Object.entries(e.palette).filter(Re()).map(([t])=>({props:{variant:`outlined`,color:t},style:{color:(e.vars||e).palette[t].main,border:`1px solid ${e.alpha((e.vars||e).palette[t].main,.7)}`,[`&.${Yn.clickable}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)},[`&.${Yn.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.focusOpacity)},[`& .${Yn.deleteIcon}`]:{color:e.alpha((e.vars||e).palette[t].main,.7),"&:hover, &:active":{color:(e.vars||e).palette[t].main}}}}))]}})),Qn=H(`span`,{name:`MuiChip`,slot:`Label`})({overflow:`hidden`,textOverflow:`ellipsis`,paddingLeft:12,paddingRight:12,whiteSpace:`nowrap`,variants:[{props:{variant:`outlined`},style:{paddingLeft:11,paddingRight:11}},{props:{size:`small`},style:{paddingLeft:8,paddingRight:8}},{props:{size:`small`,variant:`outlined`},style:{paddingLeft:7,paddingRight:7}}]});function $n(e){return e.key===`Backspace`||e.key===`Delete`}var er=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiChip`}),{avatar:r,className:i,clickable:a,color:o=`default`,component:s,deleteIcon:c,disabled:l=!1,icon:u,label:d,onClick:f,onDelete:p,onKeyDown:m,onKeyUp:g,size:_=`medium`,variant:v=`filled`,tabIndex:y,skipFocusWhenDisabled:b=!1,slots:x={},slotProps:S={},...C}=n,{nativeButton:w,...T}=C,E=Y.useRef(null),D=Ue(E,t),O=e=>{e.stopPropagation(),p(e)},k=e=>{e.currentTarget===e.target&&$n(e)&&e.preventDefault(),m&&m(e)},A=e=>{e.currentTarget===e.target&&p&&$n(e)&&p(e),g&&g(e)},j=a!==!1&&f?!0:a,M=j||p?Le:s||`div`,N={...n,component:M,disabled:l,size:_,color:o,iconColor:Y.isValidElement(u)&&u.props.color||o,onDelete:!!p,clickable:j,variant:v},P=Xn(N),F=M===Le?{component:s||`div`,internalNativeButton:!1,focusVisibleClassName:P.focusVisible,...p&&{disableRipple:!0},...w!==void 0&&{nativeButton:w}}:{},I=null;p&&(I=c&&Y.isValidElement(c)?Y.cloneElement(c,{className:h(c.props.className,P.deleteIcon),onClick:O}):(0,X.jsx)(qn,{className:P.deleteIcon,onClick:O}));let L=null;r&&Y.isValidElement(r)&&(L=Y.cloneElement(r,{className:h(P.avatar,r.props.className)}));let R=null;u&&Y.isValidElement(u)&&(R=Y.cloneElement(u,{className:h(P.icon,u.props.className)}));let z={slots:x,slotProps:S},[B,V]=$e(`root`,{elementType:Zn,externalForwardedProps:{...z,...T},ownerState:N,shouldForwardComponentProp:!0,ref:D,className:h(P.root,i),additionalProps:{disabled:j&&l?!0:void 0,tabIndex:b&&l?-1:y,...F},getSlotProps:e=>({...e,onClick:t=>{e.onClick?.(t),f?.(t)},onKeyDown:t=>{e.onKeyDown?.(t),k(t)},onKeyUp:t=>{e.onKeyUp?.(t),A(t)}})}),[ee,te]=$e(`label`,{elementType:Qn,externalForwardedProps:z,ownerState:N,className:P.label});return(0,X.jsxs)(B,{as:M,...V,children:[L||R,(0,X.jsx)(ee,{...te,children:d}),I]})});function tr(e){return m(`MuiDivider`,e)}var nr=E(`MuiDivider`,[`root`,`absolute`,`fullWidth`,`inset`,`middle`,`flexItem`,`vertical`,`withChildren`,`textAlignRight`,`textAlignLeft`,`wrapper`,`wrapperVertical`]),rr=e=>{let{absolute:t,children:n,classes:r,flexItem:i,orientation:a,textAlign:o,variant:s}=e;return he({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`]},tr,r)},ir=H(`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]}})(ge(({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%`}}}]}))),ar=H(`span`,{name:`MuiDivider`,slot:`Wrapper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.wrapper,n.orientation===`vertical`&&t.wrapperVertical]}})(ge(({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)`}}]}))),or=Y.forwardRef(function(e,t){let n=_e({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=rr(p);return(0,X.jsx)(ir,{as:s,className:h(m.root,a),role:l,ref:t,ownerState:p,"aria-orientation":l===`separator`&&(s!==`hr`||o===`vertical`)?o:void 0,...f,children:i?(0,X.jsx)(ar,{className:m.wrapper,ownerState:p,children:i}):null})}),sr={visibility:`hidden`},cr={};function lr(e){return typeof e==`string`&&/^translate\(.+,\s*.+\)$/.test(e)}function ur(e,t,n,r=cr){let{resetInlineTransform:i=!0}=r,a=n&&n.getBoundingClientRect(),o=nt(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}=G(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 dr(e){return typeof e==`function`?e():e}function fr(e,t,n,r){let i=ur(e,t,dr(n),r);i&&(t.style.transform=i)}var pr=Y.forwardRef(function(e,t){let n=T(),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:v,style:y,timeout:b=i,...x}=e,S=Be(n.motion.reducedMotion,l),C=Y.useRef(null),w=Y.useRef(!1),E=Ue(N(s),C,t),D=We(C,(e,t)=>{fr(u,e,c),S.shouldReduceMotion||Oe(e),p&&p(e,t)}),O=We(C,(e,t)=>{let r=Me({timeout:b,style:y,easing:d},{mode:`enter`}),i=S.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=We(C,m),A=We(C,v),j=We(C,e=>{let t=Me({timeout:b,style:y,easing:d},{mode:`exit`}),r=S.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=lr(e.style.transform);w.current=i,fr(u,e,c,{resetInlineTransform:!i}),g&&g(e)}),M=We(C,e=>{w.current=!1,e.style.transition=``,_&&_(e)}),P=a?e=>{a(C.current,e)}:void 0,F=Y.useCallback(()=>{C.current&&fr(u,C.current,c)},[u,c]);return Y.useEffect(()=>{if(f||u===`down`||u===`right`)return;let e=ct(()=>{C.current&&fr(u,C.current,c)}),t=nt(C.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[u,f,c]),Y.useEffect(()=>{!f&&!w.current&&F()},[f,F]),(0,X.jsx)(me,{nodeRef:C,onEnter:D,onEntered:k,onEntering:O,onExit:j,onExited:M,onExiting:A,addEndListener:P,appear:o,in:f,reduceMotion:S.shouldReduceMotion,timeout:b,...x,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!f?y||s.props.style?{visibility:`hidden`,...y,...s.props.style}:sr:y&&s.props.style?{...y,...s.props.style}:y||s.props.style,Y.cloneElement(s,{ref:E,style:r,...n})}})});function mr(e){return m(`MuiDrawer`,e)}E(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`modal`]);var hr=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},gr=e=>{let{classes:t,anchor:n,variant:r}=e,i={root:[`root`,`anchor${U(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`]};return he(i,mr,t)},_r=H(fe,{name:`MuiDrawer`,slot:`Root`,overridesResolver:hr})(ge(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),vr=H(`div`,{shouldForwardProp:Se,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:hr})({flex:`0 0 auto`}),yr=H(ft,{name:`MuiDrawer`,slot:`Paper`})(ge(({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}`}}]}))),br={left:`right`,right:`left`,top:`down`,bottom:`up`};function xr(e){return[`left`,`right`].includes(e)}function Sr({direction:e},t){return e===`rtl`&&xr(t)?br[t]:t}var Cr=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiDrawer`}),r=T(),i=Ke(),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:g=`temporary`,slots:_={},slotProps:v={},...y}=n,b=Y.useRef(!1),x=Y.useRef(null),S=Ue(t,x);Y.useEffect(()=>{b.current=!0},[]);let C=Y.useCallback(()=>x.current,[]),w=Sr({direction:i?`rtl`:`ltr`},o),E=o,D={...n,anchor:E,elevation:l,open:p,variant:g,...y},O=gr(D),k={slots:_,slotProps:{...v,backdrop:V(v.backdrop,{transitionDuration:m})}},[A,j]=$e(`root`,{ref:S,elementType:_r,className:h(O.root,O.modal,c),shouldForwardComponentProp:!0,ownerState:D,externalForwardedProps:{...k,...y,...d},additionalProps:{closeAfterTransition:!0,open:p,onClose:f,hideBackdrop:u,slots:{backdrop:k.slots.backdrop},slotProps:{backdrop:k.slotProps.backdrop}}}),[M,N]=$e(`paper`,{elementType:yr,shouldForwardComponentProp:!0,className:O.paper,ownerState:D,externalForwardedProps:k,additionalProps:{elevation:g===`temporary`?l:0,square:!0,...g===`temporary`&&{role:`dialog`,"aria-modal":`true`,"data-mui-focusable":``,tabIndex:-1}}}),[P,F]=$e(`docked`,{elementType:vr,ref:S,className:h(O.root,O.docked,c),ownerState:D,externalForwardedProps:k,additionalProps:y}),[I,L]=$e(`transition`,{elementType:pr,ownerState:D,externalForwardedProps:k,additionalProps:{in:p,direction:br[w],timeout:m,appear:b.current,...g===`temporary`&&(_.transition==null||_.transition===pr)&&{container:C}}}),R=(0,X.jsx)(M,{...N,children:s});if(g===`permanent`)return(0,X.jsx)(P,{...F,children:R});let z=(0,X.jsx)(I,{...L,children:R});return g===`persistent`?(0,X.jsx)(P,{...F,children:z}):(0,X.jsx)(A,{...j,children:z})}),wr=(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]},Tr=e=>{let{alignItems:t,classes:n,dense:r,disabled:i,disableGutters:a,divider:o,selected:s}=e,c=he({root:[`root`,r&&`dense`,!a&&`gutters`,o&&`divider`,i&&`disabled`,t===`flex-start`&&`alignItemsFlexStart`,s&&`selected`]},gn,n);return{...n,...c}},Er=H(Le,{shouldForwardProp:e=>Se(e)||e===`classes`,name:`MuiListItemButton`,slot:`Root`,overridesResolver:wr})(ge(({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,...Ee(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${_n.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${_n.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${_n.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)}},[`&.${_n.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${_n.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}}]}))),Dr=Y.forwardRef(function(e,t){let n=_e({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=Y.useContext(ee),g=Y.useMemo(()=>({dense:s||m.dense||!1,alignItems:r,disableGutters:c}),[r,m.dense,s,c]),_=Y.useRef(null);lt(()=>{i&&_.current&&_.current.focus()},[i]);let v={...n,alignItems:r,dense:g.dense,disableGutters:c,divider:l,selected:d},y=Tr(v),{root:b,...x}=y,S=Ue(_,t);return(0,X.jsx)(ee.Provider,{value:g,children:(0,X.jsx)(Er,{ref:S,href:p.href||p.to,component:(p.href||p.to)&&a===`div`?`button`:a,internalNativeButton:!1,focusVisibleClassName:h(y.focusVisible,u),ownerState:v,className:h(y.root,f),...p,classes:x,children:o})})});function Or(e){return m(`MuiListItemIcon`,e)}var kr=E(`MuiListItemIcon`,[`root`,`alignItemsFlexStart`]),Ar=e=>{let{alignItems:t,classes:n}=e;return he({root:[`root`,t===`flex-start`&&`alignItemsFlexStart`]},Or,n)},jr=H(`div`,{name:`MuiListItemIcon`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.alignItems===`flex-start`&&t.alignItemsFlexStart]}})(ge(({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}}]}))),Mr=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiListItemIcon`}),{className:r,...i}=n,a=Y.useContext(ee),o={...n,alignItems:a.alignItems},s=Ar(o);return(0,X.jsx)(jr,{className:h(s.root,r),ownerState:o,ref:t,...i})});function Nr(e){return m(`MuiListItemText`,e)}var Pr=E(`MuiListItemText`,[`root`,`multiline`,`dense`,`inset`,`primary`,`secondary`]),Fr=e=>{let{classes:t,inset:n,primary:r,secondary:i,dense:a}=e;return he({root:[`root`,n&&`inset`,a&&`dense`,r&&i&&`multiline`],primary:[`primary`],secondary:[`secondary`]},Nr,t)},Ir=H(`div`,{name:`MuiListItemText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${Pr.primary}`]:t.primary},{[`& .${Pr.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,[`.${dt.root}:where(& .${Pr.primary})`]:{display:`block`},[`.${dt.root}:where(& .${Pr.secondary})`]:{display:`block`},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),Lr=Y.forwardRef(function(e,t){let n=_e({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}=Y.useContext(ee),p=s??r,m=c,g={...n,disableTypography:a,inset:o,primary:!!p,secondary:!!m,dense:f},_=Fr(g),v={slots:l,slotProps:u},[y,b]=$e(`root`,{className:h(_.root,i),elementType:Ir,externalForwardedProps:{...v,...d},ownerState:g,ref:t}),[x,S]=$e(`primary`,{className:_.primary,elementType:q,externalForwardedProps:v,ownerState:g}),[C,w]=$e(`secondary`,{className:_.secondary,elementType:q,externalForwardedProps:v,ownerState:g});return p!=null&&p.type!==q&&!a&&(p=(0,X.jsx)(x,{variant:f?`body2`:`body1`,component:S?.variant?void 0:`span`,...S,children:p})),m!=null&&m.type!==q&&!a&&(m=(0,X.jsx)(C,{variant:`body2`,color:`textSecondary`,...w,children:m})),(0,X.jsxs)(y,{...b,children:[p,m]})}),Q=sn({createStyledComponent:H(`div`,{name:`MuiStack`,slot:`Root`}),useThemeProps:e=>_e({props:e,name:`MuiStack`})}),Rr=Y.createContext({}),zr=Y.createContext(void 0);function Br(e,t){return t===void 0||e===void 0?!1:Array.isArray(t)?t.includes(e):e===t}function Vr(e,t){let{children:n,disabled:r=!1,selected:i=!1,value:a}=e,o=ot(),s=tt({id:a,ref:t,disabled:r,selected:i}),c=o.getItemMap().size===0&&i?0:s.tabIndex;return Y.cloneElement(Y.Children.only(n),{...s,tabIndex:n.props.tabIndex??c})}var Hr=Y.forwardRef(Vr),Ur=e=>{let{classes:t,fullWidth:n,selected:r,disabled:i,size:a,color:o}=e,s={root:[`root`,r&&`selected`,i&&`disabled`,n&&`fullWidth`,`size${U(a)}`,o]};return he(s,bn,t)},Wr=H(Le,{name:`MuiToggleButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`size${U(n.size)}`]]}})(ge(({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,[`&.${xn.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:{[`&.${xn.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(Re()).map(([t])=>({props:{color:t},style:{[`&.${xn.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)}}]}))),Gr=Y.forwardRef(function(e,t){let{value:n,isRovingTabIndex:r,...i}=Y.useContext(Rr),a=Y.useContext(zr),o=Ce({...i,selected:Br(e.value,n)},e),s=_e({props:o,name:`MuiToggleButton`}),{children:c,className:l,color:u=`standard`,disabled:d=!1,disableFocusRipple:f=!1,fullWidth:p=!1,onChange:m,onClick:g,selected:_,size:v=`medium`,value:y,...b}=s,x={...s,color:u,disabled:d,disableFocusRipple:f,fullWidth:p,size:v},S=Ur(x),C=e=>{g&&(g(e,y),e.defaultPrevented)||m&&m(e,y)},w=a||``,T=(0,X.jsx)(Wr,{className:h(i.className,S.root,l,w),internalNativeButton:!0,disabled:d,focusRipple:!f,ref:r?void 0:t,onClick:C,onChange:m,value:y,ownerState:x,"aria-pressed":_,...b,children:c});return r?(0,X.jsx)(Hr,{disabled:d,selected:_,ref:t,value:y,children:T}):T});function Kr(e){return Y.Children.toArray(e).filter(e=>Y.isValidElement(e))}function qr(e){return m(`MuiToggleButtonGroup`,e)}var Jr=E(`MuiToggleButtonGroup`,[`root`,`selected`,`horizontal`,`vertical`,`disabled`,`grouped`,`fullWidth`,`firstButton`,`lastButton`,`middleButton`]),Yr=e=>{let{classes:t,orientation:n,fullWidth:r,disabled:i}=e;return he({root:[`root`,n,r&&`fullWidth`],grouped:[`grouped`,i&&`disabled`],firstButton:[`firstButton`],lastButton:[`lastButton`],middleButton:[`middleButton`]},qr,t)},Xr=H(`div`,{name:`MuiToggleButtonGroup`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${Jr.grouped}`]:t.grouped},{[`& .${Jr.firstButton}`]:t.firstButton},{[`& .${Jr.lastButton}`]:t.lastButton},{[`& .${Jr.middleButton}`]:t.middleButton},t.root,n.orientation===`vertical`&&t.vertical,n.fullWidth&&t.fullWidth]}})(ge(({theme:e})=>({display:`inline-flex`,borderRadius:(e.vars||e).shape.borderRadius,variants:[{props:{orientation:`vertical`},style:{flexDirection:`column`,[`& .${Jr.grouped}`]:{[`&.${Jr.selected} + .${Jr.grouped}.${Jr.selected}`]:{borderTop:0,marginTop:0}},[`& .${Jr.firstButton},& .${Jr.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${Jr.lastButton},& .${Jr.middleButton}`]:{marginTop:-1,borderTop:`1px solid transparent`,borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${Jr.lastButton}.${xn.disabled},& .${Jr.middleButton}.${xn.disabled}`]:{borderTop:`1px solid transparent`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{orientation:`horizontal`},style:{[`& .${Jr.grouped}`]:{[`&.${Jr.selected} + .${Jr.grouped}.${Jr.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${Jr.firstButton},& .${Jr.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${Jr.lastButton},& .${Jr.middleButton}`]:{marginLeft:-1,borderLeft:`1px solid transparent`,borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${Jr.lastButton}.${xn.disabled},& .${Jr.middleButton}.${xn.disabled}`]:{borderLeft:`1px solid transparent`}}}]}))),Zr=Y.forwardRef(function(e,t){let n=_e({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},g=Yr(m),_=Ke(),v=Y.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=Y.useCallback((e,t)=>{l&&l(e,f===t?null:t)},[l,f]),b=Y.useMemo(()=>({className:g.grouped,onChange:s?y:v,value:f,size:d,fullWidth:c,color:a,disabled:o,isRovingTabIndex:!0}),[g.grouped,s,y,v,f,d,c,a,o]),x=Kr(r),S=x.length,C=e=>{let t=e===0,n=e===S-1;return t&&n?``:t?g.firstButton:n?g.lastButton:g.middleButton},w=Ye({orientation:u,isRtl:_}),T=w.getContainerProps(t,p.onFocus,p.onKeyDown);return(0,X.jsx)(Xr,{role:`group`,className:h(g.root,i),ownerState:m,...p,...T,children:(0,X.jsx)(it.Provider,{value:w,children:(0,X.jsx)(Rr.Provider,{value:b,children:x.map((e,t)=>(0,X.jsx)(zr.Provider,{value:C(t),children:e},t))})})})});function Qr(e){return m(`MuiToolbar`,e)}E(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var $r=e=>{let{classes:t,disableGutters:n,variant:r}=e;return he({root:[`root`,!n&&`gutters`,r]},Qr,t)},ei=H(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(ge(({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}]}))),ti=Y.forwardRef(function(e,t){let n=_e({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=$r(c);return(0,X.jsx)(ei,{as:i,className:h(l.root,r),ref:t,ownerState:c,...s})}),ni=`bottom`,ri=`right`,ii=`left`,ai=`auto`,oi=[`top`,ni,ri,ii],si=`start`,ci=`clippingParents`,li=`viewport`,ui=`popper`,di=`reference`,fi=oi.reduce(function(e,t){return e.concat([t+`-`+si,t+`-end`])},[]),pi=[].concat(oi,[ai]).reduce(function(e,t){return e.concat([t,t+`-`+si,t+`-end`])},[]),mi=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function hi(e){return e?(e.nodeName||``).toLowerCase():null}function gi(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function _i(e){return e instanceof gi(e).Element||e instanceof Element}function vi(e){return e instanceof gi(e).HTMLElement||e instanceof HTMLElement}function yi(e){return typeof ShadowRoot>`u`?!1:e instanceof gi(e).ShadowRoot||e instanceof ShadowRoot}function bi(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];!vi(i)||!hi(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 xi(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},{});!vi(r)||!hi(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Si={name:`applyStyles`,enabled:!0,phase:`write`,fn:bi,effect:xi,requires:[`computeStyles`]};function Ci(e){return e.split(`-`)[0]}var wi=Math.max,Ti=Math.min,Ei=Math.round;function Di(){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 Oi(){return!/^((?!chrome|android).)*safari/i.test(Di())}function ki(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&vi(e)&&(i=e.offsetWidth>0&&Ei(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&Ei(r.height)/e.offsetHeight||1);var o=(_i(e)?gi(e):window).visualViewport,s=!Oi()&&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 Ai(e){var t=ki(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 ji(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&yi(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Mi(e){return gi(e).getComputedStyle(e)}function Ni(e){return[`table`,`td`,`th`].indexOf(hi(e))>=0}function Pi(e){return((_i(e)?e.ownerDocument:e.document)||window.document).documentElement}function Fi(e){return hi(e)===`html`?e:e.assignedSlot||e.parentNode||(yi(e)?e.host:null)||Pi(e)}function Ii(e){return!vi(e)||Mi(e).position===`fixed`?null:e.offsetParent}function Li(e){var t=/firefox/i.test(Di());if(/Trident/i.test(Di())&&vi(e)&&Mi(e).position===`fixed`)return null;var n=Fi(e);for(yi(n)&&(n=n.host);vi(n)&&[`html`,`body`].indexOf(hi(n))<0;){var r=Mi(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 Ri(e){for(var t=gi(e),n=Ii(e);n&&Ni(n)&&Mi(n).position===`static`;)n=Ii(n);return n&&(hi(n)===`html`||hi(n)===`body`&&Mi(n).position===`static`)?t:n||Li(e)||t}function zi(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function Bi(e,t,n){return wi(e,Ti(t,n))}function Vi(e,t,n){var r=Bi(e,t,n);return r>n?n:r}function Hi(){return{top:0,right:0,bottom:0,left:0}}function Ui(e){return Object.assign({},Hi(),e)}function Wi(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var Gi=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,Ui(typeof e==`number`?Wi(e,oi):e)};function Ki(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=Ci(n.placement),c=zi(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=Gi(i.padding,n),d=Ai(a),f=c===`y`?`top`:ii,p=c===`y`?ni:ri,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=Ri(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=Bi(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function qi(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)||ji(t.elements.popper,r)&&(t.elements.arrow=r))}var Ji={name:`arrow`,enabled:!0,phase:`main`,fn:Ki,effect:qi,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function Yi(e){return e.split(`-`)[1]}var Xi={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function Zi(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:Ei(n*i)/i||0,y:Ei(r*i)/i||0}}function Qi(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=ii,b=`top`,x=window;if(l){var S=Ri(n),C=`clientHeight`,w=`clientWidth`;if(S===gi(n)&&(S=Pi(n),Mi(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=ni;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=ri;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&&Xi),O=u===!0?Zi({x:p,y:h},gi(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 $i(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:Ci(t.placement),variation:Yi(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,Qi(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,Qi(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 ea={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:$i,data:{}},ta={passive:!0};function na(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=gi(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,ta)}),s&&c.addEventListener(`resize`,n.update,ta),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,ta)}),s&&c.removeEventListener(`resize`,n.update,ta)}}var ra={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:na,data:{}},ia={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function aa(e){return e.replace(/left|right|bottom|top/g,function(e){return ia[e]})}var oa={start:`end`,end:`start`};function sa(e){return e.replace(/start|end/g,function(e){return oa[e]})}function ca(e){var t=gi(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function la(e){return ki(Pi(e)).left+ca(e).scrollLeft}function ua(e,t){var n=gi(e),r=Pi(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=Oi();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+la(e),y:c}}function da(e){var t=Pi(e),n=ca(e),r=e.ownerDocument?.body,i=wi(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=wi(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+la(e),s=-n.scrollTop;return Mi(r||t).direction===`rtl`&&(o+=wi(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function fa(e){var t=Mi(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function pa(e){return[`html`,`body`,`#document`].indexOf(hi(e))>=0?e.ownerDocument.body:vi(e)&&fa(e)?e:pa(Fi(e))}function ma(e,t){t===void 0&&(t=[]);var n=pa(e),r=n===e.ownerDocument?.body,i=gi(n),a=r?[i].concat(i.visualViewport||[],fa(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(ma(Fi(a)))}function ha(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function ga(e,t){var n=ki(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 _a(e,t,n){return t===`viewport`?ha(ua(e,n)):_i(t)?ga(t,n):ha(da(Pi(e)))}function va(e){var t=ma(Fi(e)),n=[`absolute`,`fixed`].indexOf(Mi(e).position)>=0&&vi(e)?Ri(e):e;return _i(n)?t.filter(function(e){return _i(e)&&ji(e,n)&&hi(e)!==`body`}):[]}function ya(e,t,n,r){var i=t===`clippingParents`?va(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=_a(e,n,r);return t.top=wi(i.top,t.top),t.right=Ti(i.right,t.right),t.bottom=Ti(i.bottom,t.bottom),t.left=wi(i.left,t.left),t},_a(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 ba(e){var t=e.reference,n=e.element,r=e.placement,i=r?Ci(r):null,a=r?Yi(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 ni:c={x:o,y:t.y+t.height};break;case ri:c={x:t.x+t.width,y:s};break;case ii:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?zi(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case si: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 xa(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?ci:s,l=n.rootBoundary,u=l===void 0?li:l,d=n.elementContext,f=d===void 0?ui:d,p=n.altBoundary,m=p!==void 0&&p,h=n.padding,g=h===void 0?0:h,_=Ui(typeof g==`number`?Wi(g,oi):g),v=f===`popper`?di:ui,y=e.rects.popper,b=e.elements[m?v:f],x=ya(_i(b)?b:b.contextElement||Pi(e.elements.popper),c,u,o),S=ki(e.elements.reference),C=ba({reference:S,element:y,strategy:`absolute`,placement:i}),w=ha(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 Sa(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?pi:c,u=Yi(r),d=u?s?fi:fi.filter(function(e){return Yi(e)===u}):oi,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]=xa(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[Ci(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function Ca(e){if(Ci(e)===`auto`)return[];var t=aa(e);return[sa(e),t,sa(t)]}function wa(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,_=Ci(g)===g,v=c||(_||!m?[aa(g)]:Ca(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(Ci(n)===`auto`?Sa(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=Ci(E),O=Yi(E)===si,k=[`top`,ni].indexOf(D)>=0,A=k?`width`:`height`,j=xa(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?ri:ii:O?ni:`top`;b[A]>x[A]&&(M=aa(M));var N=aa(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 Ta={name:`flip`,enabled:!0,phase:`main`,fn:wa,requiresIfExists:[`offset`],data:{_skip:!1}};function Ea(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 Da(e){return[`top`,ri,ni,ii].some(function(t){return e[t]>=0})}function Oa(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=xa(t,{elementContext:`reference`}),s=xa(t,{altBoundary:!0}),c=Ea(o,r),l=Ea(s,i,a),u=Da(c),d=Da(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 ka={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Oa};function Aa(e,t,n){var r=Ci(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 ja(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=pi.reduce(function(e,n){return e[n]=Aa(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 Ma={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:ja};function Na(e){var t=e.state,n=e.name;t.modifiersData[n]=ba({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var Pa={name:`popperOffsets`,enabled:!0,phase:`read`,fn:Na,data:{}};function Fa(e){return e===`x`?`y`:`x`}function Ia(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=xa(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=Ci(t.placement),v=Yi(t.placement),y=!v,b=zi(_),x=Fa(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`:ii,A=b===`y`?ni:ri,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,z=p&&R?Ai(R):{width:0,height:0},B=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:Hi(),V=B[k],ee=B[A],te=Bi(0,C[j],z[j]),ne=y?C[j]/2-F-te-V-E.mainAxis:I-te-V-E.mainAxis,re=y?-C[j]/2+F+te+ee+E.mainAxis:L+te+ee+E.mainAxis,ie=t.elements.arrow&&Ri(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+ne-oe-ae,ce=M+re-oe,le=Bi(p?Ti(N,se):N,M,p?wi(P,ce):P);S[b]=le,O[b]=le-M}if(s){var ue=b===`x`?`top`:ii,de=b===`x`?ni:ri,fe=S[x],pe=x===`y`?`height`:`width`,me=fe+g[ue],he=fe-g[de],ge=[`top`,ii].indexOf(_)!==-1,H=D?.[x]??0,_e=ge?me:fe-C[pe]-w[pe]-H+E.altAxis,ve=ge?fe+C[pe]+w[pe]-H-E.altAxis:he,ye=p&&ge?Vi(_e,fe,ve):Bi(p?_e:me,fe,p?ve:he);S[x]=ye,O[x]=ye-fe}t.modifiersData[r]=O}}var La={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Ia,requiresIfExists:[`offset`]};function Ra(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function za(e){return e===gi(e)||!vi(e)?ca(e):Ra(e)}function Ba(e){var t=e.getBoundingClientRect(),n=Ei(t.width)/e.offsetWidth||1,r=Ei(t.height)/e.offsetHeight||1;return n!==1||r!==1}function Va(e,t,n){n===void 0&&(n=!1);var r=vi(t),i=vi(t)&&Ba(t),a=Pi(t),o=ki(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((hi(t)!==`body`||fa(a))&&(s=za(t)),vi(t)?(c=ki(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=la(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function Ha(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 Ua(e){var t=Ha(e);return mi.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function Wa(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function Ga(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 Ka={placement:`bottom`,modifiers:[],strategy:`absolute`};function qa(){return![...arguments].some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function Ja(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?Ka:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},Ka,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:_i(e)?ma(e):e.contextElement?ma(e.contextElement):[],popper:ma(t)};var s=Ua(Ga([].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(qa(t,n)){i.rects={reference:Va(t,Ri(n),i.options.strategy===`fixed`),popper:Ai(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:Wa(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!qa(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 Ya=Ja({defaultModifiers:[ra,Pa,ea,Si,Ma,Ta,La,Ji,ka]});function Xa(e){return m(`MuiPopper`,e)}E(`MuiPopper`,[`root`]);function Za(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 Qa(e){return typeof e==`function`?e():e}function $a(e){return e.nodeType!==void 0}var eo=e=>{let{classes:t}=e;return he({root:[`root`]},Xa,t)},to={},no=Y.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=Y.useRef(null),_=Te(g,t),v=Y.useRef(null),y=Te(v,u),b=Y.useRef(y);xe(()=>{b.current=y},[y]),Y.useImperativeHandle(u,()=>v.current,[]);let x=Za(c,i),[S,C]=Y.useState(x),w=Y.useMemo(()=>Qa(n),[n]);Y.useEffect(()=>{v.current&&v.current.forceUpdate()}),xe(()=>{if(!w||!s)return;let e=e=>{C(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=Ya(w,g.current,{placement:x,...l,modifiers:t});b.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();b.current(null)}},[w,a,o,s,l,x]);let T={placement:S};p!==null&&(T.TransitionProps=p);let E=eo(e),D=f.root??`div`,O=rt({elementType:D,externalSlotProps:d.root,externalForwardedProps:h,additionalProps:{role:`tooltip`,ref:_},ownerState:e,className:E.root});return(0,X.jsx)(D,{...O,children:typeof r==`function`?r(T):r})}),ro=H(Y.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=to,popperRef:f,style:p,transition:m=!1,slotProps:h={},slots:g={},..._}=e,[v,y]=Y.useState(!0),b=()=>{y(!1)},x=()=>{y(!0)};if(!s&&!l&&(!m||v))return null;let S;if(i)S=i;else if(n){let e=Qa(n);S=e&&$a(e)?Ge(e).body:Ge(null).body}let C=!l&&s&&(!m||v)?`none`:void 0,w=m?{in:l,onEnter:b,onExited:x}:void 0;return(0,X.jsx)(L,{disablePortal:o,container:S,children:(0,X.jsx)(no,{anchorEl:n,direction:a,disablePortal:o,modifiers:c,ref:t,open:m?!v:l,placement:u,popperOptions:d,popperRef:f,slotProps:h,slots:g,..._,style:{position:`fixed`,top:0,left:0,display:C,...p},TransitionProps:w,children:r})})}),{name:`MuiPopper`,slot:`Root`})({}),io=Y.forwardRef(function(e,t){let n=Ke(),{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}=_e({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,X.jsx)(ro,{as:i,direction:n?`rtl`:`ltr`,slots:m,slotProps:h,..._,ref:t})});function ao(e){return m(`MuiTooltip`,e)}var oo=E(`MuiTooltip`,[`popper`,`popperInteractive`,`popperArrow`,`popperClose`,`tooltip`,`tooltipArrow`,`touch`,`tooltipPlacementLeft`,`tooltipPlacementRight`,`tooltipPlacementTop`,`tooltipPlacementBottom`,`arrow`]);function so(e){return Math.round(e*1e5)/1e5}var co=e=>{let{classes:t,disableInteractive:n,arrow:r,touch:i,placement:a}=e,o={popper:[`popper`,!n&&`popperInteractive`,r&&`popperArrow`],tooltip:[`tooltip`,r&&`tooltipArrow`,i&&`touch`,`tooltipPlacement${U(a.split(`-`)[0])}`],arrow:[`arrow`]};return he(o,ao,t)},lo=H(io,{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]}})(ge(({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"] .${oo.arrow}`]:{top:0,marginTop:`-0.71em`,"&::before":{transformOrigin:`0 100%`}},[`&[data-popper-placement*="top"] .${oo.arrow}`]:{bottom:0,marginBottom:`-0.71em`,"&::before":{transformOrigin:`100% 0`}},[`&[data-popper-placement*="right"] .${oo.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineStart:0,marginInlineStart:`-0.71em`,"&::before":{transformOrigin:`100% 100%`}},[`&[data-popper-placement*="left"] .${oo.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineEnd:0,marginInlineEnd:`-0.71em`,"&::before":{transformOrigin:`0 0`}}}}]}))),uo=H(`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${U(n.placement.split(`-`)[0])}`]]}})(ge(({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,[`.${oo.popper}[data-popper-placement*="left"] &`]:{transformOrigin:`right center`,marginInlineEnd:`14px`},[`.${oo.popper}[data-popper-placement*="right"] &`]:{transformOrigin:`left center`,marginInlineStart:`14px`},[`.${oo.popper}[data-popper-placement*="top"] &`]:{transformOrigin:`center bottom`,marginBottom:`14px`},[`.${oo.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:`${so(16/14)}em`,fontWeight:e.typography.fontWeightRegular}},{props:({ownerState:e})=>e.touch,style:{[`.${oo.popper}[data-popper-placement*="left"] &`]:{marginInlineEnd:`24px`},[`.${oo.popper}[data-popper-placement*="right"] &`]:{marginInlineStart:`24px`},[`.${oo.popper}[data-popper-placement*="top"] &`]:{marginBottom:`24px`},[`.${oo.popper}[data-popper-placement*="bottom"] &`]:{marginTop:`24px`}}}]}))),fo=H(`span`,{name:`MuiTooltip`,slot:`Arrow`})(ge(({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)`}}))),po=!1,mo=new ke,ho={x:0,y:0};function go(e,t){return(n,...r)=>{t&&t(n,...r),e(n,...r)}}var _o=Y.forwardRef(function(e,t){let n=_e({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:g,leaveDelay:_=0,leaveTouchDelay:v=1500,onClose:y,onOpen:b,open:x,placement:S=`bottom`,slotProps:C={},slots:w={},title:E,...D}=n,O=Y.isValidElement(i)?i:(0,X.jsx)(`span`,{children:i}),k=T(),[A,j]=Y.useState(),[M,P]=Y.useState(null),I=Y.useRef(!1),L=l||m,R=Fe(),z=Fe(),B=Fe(),V=Fe(),[ee,te]=F({controlled:x,default:!1,name:`Tooltip`,state:`open`}),ne=ee,re=Ne(g),ie=Y.useRef(),ae=Ae(()=>{ie.current!==void 0&&(document.body.style.WebkitUserSelect=ie.current,ie.current=void 0),V.clear()});Y.useEffect(()=>ae,[ae]);let oe=e=>{mo.clear(),po=!0,te(!0),b&&!ne&&b(e)},ce=Ae(e=>{mo.start(800+_,()=>{po=!1}),te(!1),y&&ne&&y(e),R.start(k.transitions.duration.shortest,()=>{I.current=!1})}),le=e=>{A?.disabled||I.current&&e.type!==`touchstart`||(A&&A.removeAttribute(`title`),z.clear(),B.clear(),d||po&&f?z.start(po?f:d,()=>{oe(e)}):oe(e))},ue=e=>{z.clear(),B.start(_,()=>{ce(e)})},[,de]=Y.useState(!1),fe=e=>{let t=e?.target??A;if(!t||t.disabled||!je(t)){de(!1);let n=e??new Event(`blur`);!e&&t&&(Object.defineProperty(n,"target",{value:t}),Object.defineProperty(n,"currentTarget",{value:t})),ue(n)}},pe=e=>{if(A||j(e.currentTarget),je(e.target)){let t=e=>{e.target.disabled&&fe(e),e.target.removeEventListener(`blur`,t)};e.target.addEventListener(`blur`,t),de(!0),le(e)}},me=e=>{I.current=!0;let t=O.props;t.onTouchStart&&t.onTouchStart(e)},he=e=>{me(e),B.clear(),R.clear(),ae(),ie.current=document.body.style.WebkitUserSelect,document.body.style.WebkitUserSelect=`none`,V.start(p,()=>{document.body.style.WebkitUserSelect=ie.current,le(e)})},ge=e=>{O.props.onTouchEnd&&O.props.onTouchEnd(e),ae(),B.start(v,()=>{ce(e)})};Y.useEffect(()=>{if(!ne)return;function e(e){e.key===`Escape`&&ce(e)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[ce,ne]);let H=Ue(N(O),j,t);!E&&E!==0&&(ne=!1);let ve=Y.useRef(),ye=e=>{let t=O.props;t.onMouseMove&&t.onMouseMove(e),ho={x:e.clientX,y:e.clientY},ve.current&&ve.current.update()},be={},xe=typeof E==`string`;o?(be.title=!ne&&xe&&!c?E:null,be[`aria-describedby`]=ne?re:null):(be[`aria-label`]=xe?E:null,be[`aria-labelledby`]=ne&&!xe?re:null);let Se={...be,...D,...O.props,className:h(D.className,O.props.className),onTouchStart:me,ref:H,...m?{onMouseMove:ye}:{}},Ce={};u||(Se.onTouchStart=he,Se.onTouchEnd=ge),c||(Se.onMouseOver=go(le,Se.onMouseOver),Se.onMouseLeave=go(ue,Se.onMouseLeave),L||(Ce.onMouseOver=le,Ce.onMouseLeave=ue)),s||(Se.onFocus=go(pe,Se.onFocus),Se.onBlur=go(fe,Se.onBlur),L||(Ce.onFocus=pe,Ce.onBlur=fe));let we={...n,arrow:r,disableInteractive:L,placement:S,touch:I.current},U=typeof C.popper==`function`?C.popper(we):C.popper,Te=Y.useMemo(()=>{let e=[{name:`arrow`,enabled:!!M,options:{element:M,padding:4}}];return U?.popperOptions?.modifiers&&(e=e.concat(U.popperOptions.modifiers)),{...U?.popperOptions,modifiers:e}},[M,U?.popperOptions]),Ee=co(we),De={slots:w,slotProps:{arrow:C.arrow,popper:U,tooltip:C.tooltip,transition:C.transition}},[Oe,ke]=$e(`popper`,{elementType:lo,externalForwardedProps:De,ownerState:we,className:Ee.popper}),[Me,Pe]=$e(`transition`,{elementType:se,externalForwardedProps:De,ownerState:we}),[Ie,W]=$e(`tooltip`,{elementType:uo,className:Ee.tooltip,externalForwardedProps:De,ownerState:we}),[Le,Re]=$e(`arrow`,{elementType:fo,className:Ee.arrow,externalForwardedProps:De,ownerState:we,ref:P});return(0,X.jsxs)(Y.Fragment,{children:[Y.cloneElement(O,Se),(0,X.jsx)(Oe,{as:io,placement:S,anchorEl:m?{getBoundingClientRect:()=>({top:ho.y,left:ho.x,right:ho.x,bottom:ho.y,width:0,height:0})}:A,popperRef:ve,open:A?ne:!1,id:re,transition:!0,...Ce,...ke,popperOptions:Te,children:({TransitionProps:e})=>(0,X.jsx)(Me,{timeout:k.transitions.duration.shorter,...e,...Pe,children:(0,X.jsxs)(Ie,{...W,children:[E,r?(0,X.jsx)(Le,{...Re}):null]})})})]})}),vo=Ct(),yo=K((0,X.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`),bo=K((0,X.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`),xo=K((0,X.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`),So=K((0,X.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`),Co=K((0,X.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`),wo=K((0,X.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`),To=K((0,X.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`),Eo=K((0,X.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`),Do=K((0,X.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`),Oo=K((0,X.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`),ko=`piagent-workspace-open`;function Ao(e,t=1){let n=/^(.+?)(?::(\d+)(?::\d+)?)?$/.exec(e.replace(/^@/,``)),r=n?.[1];return!r||r.length>4096||/^[~/]/.test(r)||/[\\\x00-\x1f\x7f:]/.test(r)||r.split(`/`).some(e=>!e||e===`.`||e===`..`)?null:{path:r,line:Math.max(1,Math.min(1e6,Number(n?.[2])||t||1))}}var jo=(0,Y.createContext)(null);function Mo({sessionRef:e,onOpen:t,children:n}){return(0,X.jsx)(jo.Provider,{value:e?n=>{t(),window.dispatchEvent(new CustomEvent(ko,{detail:{sessionRef:e,...n}}))}:null,children:n})}function No({path:e,line:t,children:n}){let r=(0,Y.useContext)(jo),{locale:i}=ze(),a=Ao(e,t);return!r||!a?n?(0,X.jsx)(X.Fragment,{children:n}):null:(0,X.jsx)(J,{size:`small`,onClick:()=>r(a),sx:{textTransform:`none`,verticalAlign:`baseline`},children:n??W(i,`Mở trong editor`,`Open in editor`)})}function Po({children:e}){return(0,X.jsx)(X.Fragment,{children:Y.Children.map(e,e=>typeof e==`string`?e.split(/((?<![\w@])@[\w./-]+\.[\w]+(?::\d+)?)/g).map((e,t)=>e.startsWith(`@`)&&Ao(e)?(0,X.jsx)(No,{path:e,children:e},t):e):e)})}var Fo=K((0,X.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 Io(e){return m(`MuiTab`,e)}var Lo=E(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`icon`]),Ro=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e,l={root:[`root`,a&&o&&`labelIcon`,`textColor${U(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`icon`]};return he(l,Io,t)},zo=H(Le,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${U(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${Lo.icon}`]:t.icon}]}})(ge(({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:{[`& > .${Lo.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${Lo.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${Lo.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${Lo.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${Lo.selected}`]:{opacity:1},[`&.${Lo.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Lo.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${Lo.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Lo.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${Lo.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)}}]}))),Bo=Y.forwardRef(function(e,t){let n=_e({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:g,textColor:_=`inherit`,value:v,wrapped:y=!1,...b}=n,x=ot(),S=tt({id:v,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:_,wrapped:y},T=Ro(w),E=s&&u&&Y.isValidElement(s)?Y.cloneElement(s,{className:h(T.icon,s.props.className)}):s;return(0,X.jsxs)(zo,{internalNativeButton:!0,focusRipple:!a,className:h(T.root,r),ref:S.ref,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,v),f&&f(e)},onFocus:e=>{g&&!m&&d&&d(e,v),p&&p(e)},tabIndex:C,ownerState:w,...b,children:[c===`top`||c===`start`?(0,X.jsxs)(Y.Fragment,{children:[E,u]}):(0,X.jsxs)(Y.Fragment,{children:[u,E]}),l]})});function Vo(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function Ho(e,t,n,r={},i=()=>{}){let{ease:a=Vo,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 Uo={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`,pointerEvents:`none`};function Wo(e){let{onChange:t,...n}=e,r=Y.useRef(),i=Y.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return lt(()=>{let e=ct(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=nt(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),Y.useEffect(()=>{a(),t(r.current)},[t]),(0,X.jsx)(`div`,{style:Uo,...n,ref:i})}var Go=K((0,X.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Ko=K((0,X.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function qo(e){return m(`MuiTabScrollButton`,e)}var Jo=E(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),Yo=e=>{let{classes:t,orientation:n,disabled:r}=e;return he({root:[`root`,n,r&&`disabled`]},qo,t)},Xo=H(Le,{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,[`&.${Jo.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),Zo=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,{nativeButton:u,...d}=l,f=Ke(),p={isRtl:f,...n},m=Yo(p),g=i.StartScrollButtonIcon??Go,_=i.EndScrollButtonIcon??Ko,v=rt({elementType:g,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p}),y=rt({elementType:_,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p});return(0,X.jsx)(Xo,{component:`div`,className:h(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,X.jsx)(g,{...v}):(0,X.jsx)(_,{...y})})});function Qo(e){return m(`MuiTabs`,e)}var $o=E(`MuiTabs`,[`root`,`vertical`,`list`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),es=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return he({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`]},Qo,c)},ts=H(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${$o.scrollButtons}`]:t.scrollButtons},{[`& .${$o.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(ge(({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:{[`& .${$o.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),ns=H(`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`}}]}),rs=H(`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`}}]}),is=H(`span`,{name:`MuiTabs`,slot:`Indicator`})(ge(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,...Ee(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}}]}))),as=H(Wo)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),os={},ss=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiTabs`}),r=T(),i=Ke(),a=Be(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:g,orientation:_=`horizontal`,scrollButtons:v=`auto`,selectionFollowsFocus:y,slots:b={},slotProps:x={},textColor:S=`primary`,value:C,variant:w=`standard`,visibleScrollbar:E=!1,...D}=n,O=w===`scrollable`,k=_===`vertical`,A=k?`scrollTop`:`scrollLeft`,j=k?`top`:`left`,M=k?`bottom`:`right`,N=k?`clientHeight`:`clientWidth`,P=k?`height`:`width`,F={...n,component:f,allowScrollButtonsMobile:p,indicatorColor:m,orientation:_,vertical:k,scrollButtons:v,textColor:S,variant:w,visibleScrollbar:E,fixed:!O,hideScrollbar:O&&!E,scrollableX:O&&!k,scrollableY:O&&k,centered:l&&!O,scrollButtonsHideMobile:!p},I=es(F),L=rt({elementType:b.startScrollButtonIcon,externalSlotProps:x.startScrollButtonIcon,ownerState:F}),R=rt({elementType:b.endScrollButtonIcon,externalSlotProps:x.endScrollButtonIcon,ownerState:F}),[z,B]=Y.useState(!1),[V,ee]=Y.useState(os),[te,ne]=Y.useState(!1),[re,ie]=Y.useState(!1),[ae,oe]=Y.useState(!1),se=C===!1?null:C,[ce,le]=Y.useState(!1),[ue,de]=Y.useState({overflow:`hidden`,scrollbarWidth:0}),fe=new Map,pe=Y.useRef(null),me=Y.useRef(null),he={slots:b,slotProps:x},ge=()=>{let e=pe.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=me.current.children;if(e.length>0){let t=e[fe.get(C)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},H=Ae(()=>{let{tabsMeta:e,tabMeta:t}=ge(),n=0,r;k?(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,[P]:t?t[P]:0};if(typeof V[r]!=`number`||typeof V[P]!=`number`)ee(a);else{let e=Math.abs(V[r]-a[r]),t=Math.abs(V[P]-a[P]);(e>=1||t>=1)&&ee(a)}}),ve=(e,{animation:t=!0}={})=>{t&&!a.shouldReduceMotion?Ho(A,pe.current,e,{duration:r.transitions.duration.standard}):pe.current[A]=e},ye=e=>{let t=pe.current[A];t+=k?e:e*(i?-1:1),ve(t)},be=()=>{let e=pe.current[N],t=0,n=Array.from(me.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[N]>e){r===0&&(t=e);break}t+=i[N]}return t},xe=()=>{ye(-1*be())},Se=()=>{ye(be())},[Ce,{onChange:we,...U}]=$e(`scrollbar`,{className:h(I.scrollableX,I.hideScrollbar),elementType:as,shouldForwardComponentProp:!0,externalForwardedProps:he,ownerState:F}),Te=Y.useCallback(e=>{we?.(e),de({overflow:null,scrollbarWidth:e})},[we]),[Ee,De]=$e(`scrollButtons`,{className:I.scrollButtons,elementType:Zo,externalForwardedProps:he,ownerState:F,additionalProps:{orientation:_,slots:{StartScrollButtonIcon:b.startScrollButtonIcon,EndScrollButtonIcon:b.endScrollButtonIcon},slotProps:{startScrollButtonIcon:L,endScrollButtonIcon:R}}}),Oe=()=>{let e={};e.scrollbarSizeListener=O?(0,X.jsx)(Ce,{...U,onChange:Te}):null;let t=O&&(v===`auto`&&(te||re)||v===!0);return e.scrollButtonStart=t?(0,X.jsx)(Ee,{direction:i?`right`:`left`,onClick:xe,disabled:!te,...De}):null,e.scrollButtonEnd=t?(0,X.jsx)(Ee,{direction:i?`left`:`right`,onClick:Se,disabled:!re,...De}):null,e},ke=Ae(e=>{let{tabsMeta:t,tabMeta:n}=ge();if(!(!n||!t)){if(n[j]<t[j]){let r=t[A]+(n[j]-t[j]);ve(r,{animation:e})}else if(n[M]>t[M]){let r=t[A]+(n[M]-t[M]);ve(r,{animation:e})}}}),je=Ae(()=>{O&&v!==!1&&oe(!ae)});Y.useEffect(()=>{let e=ct(()=>{pe.current&&H()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),je()},r=nt(pe.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(me.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(me.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[H,je]),Y.useEffect(()=>{let e=Array.from(me.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&O&&v!==!1){let n=e[0],r=e[t-1],i={root:pe.current,threshold:.99},a=new IntersectionObserver(e=>{ne(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{ie(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[O,v,ae,u?.length]),Y.useEffect(()=>{B(!0)},[]),Y.useEffect(()=>{H()}),Y.useEffect(()=>{ke(os!==V)},[ke,V]),Y.useImperativeHandle(c,()=>({updateIndicator:H,updateScrollButtons:je}),[H,je]);let[Me,Ne]=$e(`indicator`,{className:I.indicator,elementType:is,externalForwardedProps:he,ownerState:F,additionalProps:{style:V}}),Pe=(0,X.jsx)(Me,{...Ne}),Fe=Ye({activeItemId:ce?void 0:se,orientation:_,isRtl:i}),Ie=Fe.getContainerProps(),W=Y.Children.toArray(u).filter(Y.isValidElement).map((e,t)=>{let n=e.props.value===void 0?t:e.props.value;return fe.set(n,t),{child:e,index:t,childValue:n}}).map(({child:e,childValue:t})=>{let n=t===C;return Y.cloneElement(e,{fullWidth:w===`fullWidth`,indicator:n&&!z&&Pe,selected:n,selectionFollowsFocus:y,onChange:g,textColor:S,value:t})}),Le=Oe(),[Re,ze]=$e(`root`,{ref:t,className:h(I.root,d),elementType:ts,externalForwardedProps:{...he,...D,component:f},ownerState:F}),[Ve,G]=$e(`scroller`,{ref:pe,className:I.scroller,elementType:ns,externalForwardedProps:he,ownerState:F,additionalProps:{style:{overflow:ue.overflow,[k?`margin${i?`Left`:`Right`}`:`marginBottom`]:E?void 0:-ue.scrollbarWidth}}}),He=Ue(Ie.ref,me),We=e=>{let t=me.current;ut(Xe(t))?.getAttribute(`role`)===`tab`&&Ie.onKeyDown(e)},[Ge,qe]=$e(`list`,{ref:He,className:I.list,elementType:rs,externalForwardedProps:he,ownerState:F,getSlotProps:e=>({...e,onBlur:t=>{Qe(t.currentTarget,t.relatedTarget)||le(!1),e.onBlur?.(t)},onKeyDown:t=>{We(t),e.onKeyDown?.(t)},onFocus:t=>{le(!0),Ie.onFocus(t),e.onFocus?.(t)}})});return(0,X.jsxs)(Re,{...ze,children:[Le.scrollButtonStart,Le.scrollbarSizeListener,(0,X.jsxs)(Ve,{...G,children:[(0,X.jsx)(Ge,{"aria-label":o,"aria-labelledby":s,"aria-orientation":_===`vertical`?`vertical`:null,role:`tablist`,...qe,children:(0,X.jsx)(it.Provider,{value:Fe,children:W})}),z&&Pe]}),Le.scrollButtonEnd]})}),cs=class extends Error{status;code;constructor(e,t=null){super(`webui-request-${e}`),this.status=e,this.code=t}};async function ls(e){try{let t=await e.json();return typeof t.error?.code==`string`?t.error.code:null}catch{return null}}async function us(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new cs(t.status);return await t.json()}function ds(e){return Cs(`/api/v1/session-catalog`,e)}function fs(e){return Cs(`/api/v1/session-live-state`,e)}function ps(e){return Cs(`/api/v1/session-creation-options`,e)}function ms(e){return Cs(`/api/v1/provider-auth`,e)}function hs(e,t){return Cs(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function gs(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}function _s(e,t){return gs({action:`provider-auth.start`,providerRef:e},t)}function vs(e,t,n,r){return gs({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function ys(e,t){return gs({action:`provider-auth.cancel`,jobRef:e},t)}async function bs(e){let t=ht();if(!t)throw new cs(403);let n=await mt(`/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 cs(n.status,await ls(n));return await n.json()}async function xs(e){try{return await Cs(`/api/v1/managed`,e)}catch(e){if(e instanceof cs&&e.status===404)return null;throw e}}async function Ss(e){let t=ht();if(!t)throw new cs(403);let n=await mt(`/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 cs(n.status);return await n.json()}async function Cs(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(n.status===401&&gt(),!n.ok)throw new cs(n.status);return await n.json()}function ws(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function Ts(e,t){return Cs(ws(e,`/api/v1/snapshot`),t)}function Es(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),Cs(ws(e,`/api/v1/transcript?${i}`),r)}function Ds(e,t,n){return Cs(ws(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function Os(e,t,n){return Cs(ws(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function ks(e,t,n,r){return Cs(ws(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function As(e,t,n,r){return Cs(ws(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function js(e,t,n,r){return Cs(ws(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function Ms(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return Cs(`/api/v1/sessions/${encodeURIComponent(e)}/source-reverts/${encodeURIComponent(t)}${i}`,r)}function Ns(e,t){return Cs(ws(e,`/api/v1/commit-summary`),t)}function Ps(e,t,n){return Cs(ws(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function Fs(e,t){return Cs(ws(e,`/api/v1/connections`),t)}async function Is(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}function Ls(e,t){return Cs(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function Rs(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function zs(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}function Bs(e,t){return Cs(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function Vs(e,t,n){return Cs(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function Hs(e,t,n){return Cs(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function Us(e,t,n){return Cs(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function Ws(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return Cs(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function Gs(e){return Cs(`/api/v1/commit-summary`,e)}function Ks(e){return Cs(`/api/v1/tasks`,e)}function qs(e,t){return Cs(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function Js(e,t){return Cs(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function Ys(e,t){return Cs(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function Xs(e,t){return Cs(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function Zs(e){return Cs(`/api/v1/monitoring/release`,e)}function Qs(e,t){return Cs(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function $s(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),Cs(`/api/v1/transcript?${r}`,n)}function ec(e){return Cs(`/api/v1/chat/queue`,e)}function tc(e){return Cs(`/api/v1/session-options/models`,e)}function nc(e,t){return Cs(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function rc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function ic(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function ac(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function oc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function sc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function cc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function lc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function uc(e,t,n){let r=ht();if(!r)throw new cs(403);let i=await mt(n?`/api/v1/sessions/${encodeURIComponent(n)}/source-reverts`:`/api/v1/source-mutations`,{method:`POST`,credentials:`same-origin`,signal:t,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":r},body:JSON.stringify(e)});if(!i.ok)throw new cs(i.status);return await i.json()}async function dc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}async function fc(e,t,n){let r=ht();if(!r)throw new cs(403);let i=await mt(`/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 cs(i.status);return await i.json()}function pc(e,t){return Cs(e?ws(e,`/api/v1/documents`):`/api/v1/documents`,t)}function mc(e,t,n){let r=`/api/v1/documents/${encodeURIComponent(t)}`;return Cs(e?ws(e,r):r,n)}async function hc(e,t){let n=ht();if(!n)throw new cs(403);let r=await mt(`/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 cs(r.status);return await r.json()}function gc(e,t,n){return Cs(`/api/v1/projects/${encodeURIComponent(e)}/paths?query=${encodeURIComponent(t)}`,n)}function _c(e,t){return Cs(`/api/v1/projects/${encodeURIComponent(e)}/commands`,t)}function vc(e,t){return Cs(`/api/v1/sessions/${encodeURIComponent(e)}/questions`,t)}async function yc(e,t,n,r){let i=ht();if(!i)throw new cs(403);let a=await mt(`/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 cs(a.status)}var bc=class extends Error{status;code;detail;constructor(e,t,n){super(t),this.status=e,this.code=t,this.detail=n}};function xc(e,t=null,n){return Cs(`/api/v1/projects/${encodeURIComponent(e)}/branches${t===null?``:`?repository=${encodeURIComponent(t)}`}`,n)}async function Sc(e,t,n){let r=ht();if(!r)throw new bc(403,`mutation-authority-rejected`,null);let i=await mt(`/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&&gt(),!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 bc(i.status,e,t)}return await i.json()}function Cc(e){return Array.isArray(e)?`[${e.map(Cc).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Cc(t)}`).join(`,`)}}`:JSON.stringify(e)}async function wc(e){let t=new TextEncoder().encode(typeof e==`string`?e:Cc(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 Tc(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 wc({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 wc({action:l.action,identity:l.identity,expectedRevisions:c,payload:s}),l}async function Ec(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 Dc(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 Oc(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 wc({action:t,identity:o.identity,expectedRevisions:a,payload:n}),o}async function kc(e,t){let n=[];return{queueItemRef:e,text:t,attachmentRefs:n,contentDigest:await wc({attachmentRefs:n,text:t})}}async function Ac(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 wc({action:t,identity:s.identity,expectedRevisions:a,payload:o}),s}async function jc(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 wc({action:t,identity:o.identity,expectedRevisions:i,payload:a}),o}async function Mc(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 wc({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 wc({action:c.action,identity:c.identity,expectedRevisions:s,payload:o}),c}function Nc(e){return Array.isArray(e)?`[${e.map(Nc).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Nc(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Pc(e){let t=new TextEncoder().encode(Nc(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 Fc(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 Pc({action:l.action,identity:o,expectedRevisions:s,payload:c}),l}function Ic(e){return Array.isArray(e)?`[${e.map(Ic).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Ic(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Lc(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(Ic(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function Rc(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))||Ic(n)!==Ic(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 Lc({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}function zc(e){return Array.isArray(e)?`[${e.map(zc).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${zc(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Bc(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(zc(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function Vc(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(t.commandBinding?t.identity:e.identity),agentOperationId:null,toolCallId:null},a={runtimeRevision:t.commandBinding?.runtimeRevision??e.revision.runtimeRevision,taskRevision:r.taskRevision,controlRevision:t.commandBinding?.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 Bc({action:s.action,identity:i,expectedRevisions:a,payload:o}),s}function Hc(e){if(!e.commandBinding||!e.target)throw Error(`source-revert-binding-unavailable`);return Vc({identity:e.identity,revision:{...e.commandBinding,approvalRevision:null,sessionOptionRevision:null,queueRevision:null}},e)}function Uc(e){return Array.isArray(e)?`[${e.map(Uc).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Uc(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Wc(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(Uc(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function Gc(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 Wc({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}var Kc=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(`.`)),qc=new Set([`false`,`nil`,`null`,`None`,`true`,`undefined`]),Jc=new Set([`py`,`rb`,`sh`,`bash`,`zsh`,`yaml`,`yml`,`toml`]);function Yc(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<0?``:t.slice(n+1).toLowerCase()}function Xc(e){return/[A-Za-z_$]/.test(e)}function Zc(e){return/[A-Za-z0-9_$-]/.test(e)}function Qc(e){return e>=`0`&&e<=`9`}function $c(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 el(e,t){let n=[],r=Yc(t),i=0;for(;i<e.length;){if(e.startsWith(`//`,i)||e.startsWith(`/*`,i)||e[i]===`#`&&Jc.has(r)){$c(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);$c(n,e.slice(a).match(/^\s*:/)&&r===`"`?`property`:`string`,o),i=a;continue}if(Qc(t)||t===`.`&&Qc(e[i+1]??``)){let t=i+1;for(;t<e.length&&/[0-9A-Fa-f_xXob.+-]/.test(e[t]??``);)t+=1;$c(n,`number`,e.slice(i,t)),i=t;continue}if(Xc(t)){let t=i+1;for(;t<e.length&&Zc(e[t]??``);)t+=1;let r=e.slice(i,t);$c(n,Kc.has(r)?`keyword`:qc.has(r)?`literal`:`plain`,r),i=t;continue}$c(n,`plain`,t),i+=1}return n}var tl=`piagent-line-comments-changed`,nl=50,rl=2e3,il=400,al=e=>`piagent-line-comments:${e}`,ol=(e,t,n)=>`${t}:${n}:${e}`,sl=e=>ol(e.path,e.side,e.line);function cl(e){let t=e;return!!t&&typeof t.path==`string`&&t.path.length>0&&Number.isSafeInteger(t.line)&&t.line>0&&(t.side===`new`||t.side===`old`)&&typeof t.code==`string`&&typeof t.text==`string`&&t.text.trim().length>0}function ll(e){try{let t=JSON.parse(sessionStorage.getItem(al(e))??`[]`);return Array.isArray(t)?t.filter(cl).slice(0,nl):[]}catch{return[]}}function ul(e,t){try{t.length?sessionStorage.setItem(al(e),JSON.stringify(t.slice(0,nl))):sessionStorage.removeItem(al(e))}catch{}typeof window<`u`&&window.dispatchEvent(new CustomEvent(tl,{detail:e}))}function dl(e,t){let n=e.filter(e=>sl(e)!==sl(t)),r=t.text.trim().slice(0,rl);return r?[...n,{...t,text:r,code:t.code.slice(0,il),at:Date.now()}].slice(-50):n}var fl=e=>[...e].sort((e,t)=>e.path.localeCompare(t.path)||e.line-t.line||e.side.localeCompare(t.side));function pl(e,t){let n=fl(e);return[t?`Review comments on the diff (${n.length}). Address each one at its file and line:`:`Review comment trên diff (${n.length}). Xử lý từng comment đúng file và dòng:`,...n.map((e,n)=>{let r=`${e.path}:${e.line}${e.side===`old`?t?` (removed line)`:` (dòng đã xóa)`:``}`,i=e.code.includes("```")?"````":"```";return`${n+1}. ${r}\n${i}\n${e.code}\n${i}\n${e.text}`})].join(`
39
-
40
- `)}var ml=e=>e.replace(/\\/g,`/`).replace(/^\.\//,``).replace(/^\/+/,``);function hl(e,t){let n=ml(e),r=ml(t);return n.length>0&&(n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`))}function gl(e,t,n){return(e??[]).filter(e=>e.line===n&&hl(e.file,t))}function _l(e,t,n){return(e??[]).filter(e=>hl(e.file,t)&&(e.line===null||!n.has(e.line)))}function vl(e,t){if(!t)return!1;let n=t.get(sl(e));return n===void 0||n!==e.code}var yl=(0,Y.createContext)(null),bl=()=>(0,Y.useContext)(yl),xl={blocking:[`Chặn`,`Blocking`],major:[`Nặng`,`Major`],minor:[`Nhẹ`,`Minor`]};function Sl({finding:e,locale:t}){return(0,X.jsxs)(`div`,{className:`line-finding severity-${e.severity}`,role:`note`,children:[(0,X.jsxs)(`strong`,{children:[`Review · `,W(t,...xl[e.severity])]}),(0,X.jsx)(`span`,{children:e.issue})]})}function Cl({initial:e,locale:t,onSave:n,onCancel:r}){let[i,a]=(0,Y.useState)(e);return(0,X.jsxs)(`form`,{className:`line-comment-editor`,onSubmit:e=>{e.preventDefault(),n(i)},children:[(0,X.jsx)(`textarea`,{autoFocus:!0,rows:3,maxLength:2e3,value:i,"aria-label":W(t,`Comment cho dòng này`,`Comment on this line`),placeholder:W(t,`Agent cần sửa gì ở dòng này?`,`What should the agent change here?`),onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Escape`&&r(),e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&n(i)}}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:r,children:W(t,`Hủy`,`Cancel`)}),(0,X.jsx)(`button`,{type:`submit`,disabled:!i.trim(),children:W(t,`Lưu comment`,`Save comment`)})]})]})}function wl({path:e,side:t,line:n}){let r=bl();if(!r||n===null)return null;let i=ol(e,t,n),a=r.comments.find(e=>sl(e)===i),o=t===`new`?gl(r.findings,e,n):[];return!o.length&&!a&&r.editing!==i?null:(0,X.jsxs)(`div`,{className:`line-notes`,children:[o.map((e,t)=>(0,X.jsx)(Sl,{finding:e,locale:r.locale},t)),r.editing===i?(0,X.jsx)(Cl,{initial:a?.text??``,locale:r.locale,onSave:r.save,onCancel:r.cancel}):a&&(0,X.jsxs)(`div`,{className:`line-comment`,children:[(0,X.jsx)(`span`,{children:a.text}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r.open(e,t,n,a.code),children:W(r.locale,`Sửa`,`Edit`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>r.remove(i),children:W(r.locale,`Xóa`,`Delete`)})]})]})}function Tl({path:e,side:t,line:n,code:r}){let i=bl();return!i||n===null?(0,X.jsx)(`span`,{children:n??``}):(0,X.jsx)(`span`,{children:(0,X.jsx)(`button`,{type:`button`,className:`line-comment-anchor`,onClick:()=>i.open(e,t,n,r),"aria-label":W(i.locale,`Comment dòng ${n}`,`Comment on line ${n}`),children:n})})}function El({path:e,shownLines:t}){let n=bl(),r=n?_l(n.findings,e,t):[];return!n||!r.length?null:(0,X.jsx)(`div`,{className:`line-notes file-findings`,children:r.map((e,t)=>(0,X.jsxs)(`div`,{className:`line-finding severity-${e.severity}`,role:`note`,children:[(0,X.jsxs)(`strong`,{children:[`Review · `,W(n.locale,...xl[e.severity]),e.line?` · ${W(n.locale,`dòng`,`line`)} ${e.line}`:``]}),(0,X.jsx)(`span`,{children:e.issue})]},t))})}function Dl({comments:e,lines:t,linesPath:n,locale:r,onSend:i,onClear:a}){let[o,s]=(0,Y.useState)(!1);if((0,Y.useEffect)(()=>{e.length||s(!1)},[e.length]),!e.length)return null;let c=e=>e.path===n&&vl(e,t),l=e.filter(c).length;return(0,X.jsxs)(`section`,{className:`line-comment-bar`,"aria-label":W(r,`Comment chờ gửi`,`Comments to send`),children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:W(r,`${e.length} comment chờ gửi`,`${e.length} comments to send`)}),l>0&&(0,X.jsx)(`small`,{children:W(r,`${l} dòng đã đổi sau khi comment`,`${l} lines changed since commented`)})]}),(0,X.jsx)(`ul`,{children:e.map(e=>(0,X.jsxs)(`li`,{className:c(e)?`changed`:void 0,children:[(0,X.jsxs)(`code`,{children:[e.path,`:`,e.line]}),(0,X.jsx)(`span`,{children:e.text}),c(e)&&(0,X.jsx)(`em`,{children:W(r,`đã đổi`,`changed`)})]},sl(e)))}),(0,X.jsxs)(`div`,{className:`line-comment-actions`,children:[o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{children:W(r,`Xóa hết comment?`,`Delete every comment?`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(!1),children:W(r,`Không`,`No`)}),(0,X.jsx)(`button`,{type:`button`,onClick:a,children:W(r,`Xóa hết`,`Delete all`)})]}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>s(!0),children:W(r,`Xóa hết`,`Delete all`)}),(0,X.jsx)(`button`,{type:`button`,className:`primary`,onClick:i,children:W(r,`Đưa vào ô chat`,`Put in the composer`)})]})]})}var Ol=[{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 kl(e){return e===`vi`?Ol:[{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 Al={"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 jl(e,t=`vi`){return t===`vi`?Al[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 Ml(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 Nl(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 Pl(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 Fl(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 Il(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 Ll(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 Rl(e,t,n,r,i,a){return t===n&&Il(e,a,r,i)?e??null:null}function zl(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 Bl(e,t){return t&&e.some(e=>e.fileRef===t)?t:e[0]?.fileRef??null}var Vl={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`,bypass:`Bypass`,"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":`Nội dung file không phải văn bản (file nhị phân), chưa gửi vào chat được`,"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`},Hl={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`,bypass:`Bypass`,"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 is not text (binary), so it cannot go into the chat`,"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 $(e,t=`vi`){return e?(t===`vi`?Vl:Hl)[e]??e.replaceAll(`-`,` `):t===`vi`?`Chưa có`:`Not available`}function Ul(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 Wl(e){return e?e.length>22?`${e.slice(0,10)}…${e.slice(-7)}`:e:`—`}function Gl(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 Kl(e,t=`vi`){return e.session.thinking.state===`known`&&e.session.thinking.value?$(e.session.thinking.value,t):t===`vi`?`Chưa xác định`:`Unknown`}function ql(e,t=`vi`){let n=e.session.permissionProfile;return n.state===`known`&&n.value?$(n.value,t):t===`vi`?`Quyền chưa xác định`:`Unknown permission`}function Jl(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 Yl(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`}}function Xl(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 Zl(e){return e?[Xl(e),e.state,e.recordedState??``,e.recordedAt??``,e.evidenceRef??``].join(``):`no-review-state`}function Ql(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 $l(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&&Ql(e,t)&&typeof t.settledAt==`string`&&typeof t.settlementEvidenceRef==`string`}function eu(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 tu(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 nu(e,t,n,r,i,a,o){return!e||!eu(e.identity,a.identity)?!1:e.target?tu(e.target,t,n,r,i,a):e.state===`unavailable`&&!Ll(e,o)}async function ru(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 iu({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,X.jsxs)(`section`,{className:`commit-summary-panel`,"aria-labelledby":`commit-summary-title`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Commit summary`}),(0,X.jsx)(`h3`,{id:`commit-summary-title`,children:W(a,`Tóm tắt phần đã stage`,`Staged changes summary`)}),(0,X.jsx)(`span`,{children:W(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,X.jsxs)(`div`,{className:`commit-summary-output`,children:[(0,X.jsx)(`strong`,{children:l.title}),l.bodyLines.map((e,t)=>(0,X.jsx)(`code`,{children:e},`${l.summaryRef}.${t}`)),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:s,children:`Copy`}),(0,X.jsx)(`button`,{type:`button`,disabled:!i||t,onClick:c,children:W(a,`Nhờ Pi viết lại · tốn model token`,`Ask Pi to rewrite · uses model tokens`)})]})]}):(0,X.jsx)(`button`,{type:`button`,disabled:!r||t,onClick:o,children:t?W(a,`Đang tạo…`,`Generating…`):W(a,`Tạo summary · 0 token`,`Generate summary · 0 tokens`)}),n&&(0,X.jsx)(`p`,{className:`commit-summary-status`,role:`status`,children:n})]})}function au({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,X.jsxs)(Dr,{component:`button`,className:`file-row`,selected:t,"data-selected":t,onClick:n,type:`button`,"aria-label":`${e.status} ${e.path} ${Ml(e,r)}`,"aria-pressed":t,children:[(0,X.jsx)(`span`,{className:`file-status status-${e.status}`,children:e.status}),(0,X.jsxs)(`span`,{className:`file-name`,children:[(0,X.jsx)(`strong`,{children:a}),e.oldPath&&(0,X.jsxs)(`small`,{children:[W(r,`từ`,`from`),` `,e.oldPath]})]}),(0,X.jsx)(`span`,{className:`file-provenance`,children:jl(e,r)}),(0,X.jsx)(`span`,{className:`file-evidence`,children:Pl(e,r)}),(0,X.jsx)(`span`,{className:`file-stats`,children:Ml(e,r)})]})}function ou({text:e,path:t}){return(0,X.jsx)(X.Fragment,{children:el(e,t).map((e,t)=>(0,X.jsx)(`span`,{className:`syntax-${e.kind}`,children:e.text},`${t}.${e.kind}`))})}function su({line:e,side:t,path:n}){let r=e.kind===`deleted`?`old`:`new`,i=r===`old`?e.oldLineNumber??null:e.newLineNumber??null,a=r===`old`?(0,X.jsx)(Tl,{path:n,side:`old`,line:i,code:e.text}):(0,X.jsx)(`span`,{children:e.oldLineNumber??``}),o=r===`new`?(0,X.jsx)(Tl,{path:n,side:`new`,line:i,code:e.text}):(0,X.jsx)(`span`,{children:e.newLineNumber??``}),s=(0,X.jsx)(wl,{path:n,side:r,line:i});if(t===`inline`)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`diff-line diff-${e.kind}`,children:[a,o,(0,X.jsx)(`b`,{children:e.marker}),(0,X.jsx)(`code`,{children:(0,X.jsx)(ou,{text:e.text,path:n})})]}),s]});let c=e.kind===`added`?``:e.text,l=e.kind===`deleted`?``:e.text;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`split-line diff-${e.kind}`,children:[a,(0,X.jsx)(`code`,{children:(0,X.jsx)(ou,{text:c,path:n})}),o,(0,X.jsx)(`code`,{children:(0,X.jsx)(ou,{text:l,path:n})})]}),s]})}function cu({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,X.jsx)(`div`,{className:`diff-empty`,children:(0,X.jsx)(`p`,{children:W(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,X.jsx)(`div`,{className:`diff-empty`,children:(0,X.jsx)(`p`,{children:W(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,X.jsxs)(`div`,{className:`diff-empty error-state`,children:[(0,X.jsx)(`p`,{children:W(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,X.jsx)(`button`,{type:`button`,onClick:S,children:W(C,`Thử đồng bộ lại`,`Retry reconciliation`)})]});let w=e.value;return(0,X.jsxs)(Z,{className:`diff-viewer`,sx:{minWidth:0,bgcolor:`background.paper`},children:[(0,X.jsxs)(Z,{component:`header`,className:`diff-toolbar`,sx:{position:`sticky`,top:0,zIndex:2,bgcolor:`background.paper`},children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:w.file.path}),(0,X.jsx)(er,{size:`small`,variant:`outlined`,className:`access-badge tone-${Ul(w.availability.state)}`,label:$(w.availability.state,C)})]}),(0,X.jsxs)(`div`,{className:`diff-actions`,children:[t.state===`ready`&&t.value&&(0,X.jsxs)(`div`,{className:`review-state review-${t.value.state}`,children:[(0,X.jsx)(`span`,{children:t.value.state===`reviewed`?W(C,`Đã review`,`Reviewed`):t.value.state===`stale`?W(C,`Review đã cũ`,`Review stale`):t.value.state===`unavailable`?W(C,`Không thể review`,`Review unavailable`):W(C,`Chưa review`,`Not reviewed`)}),t.value.target&&t.value.state!==`unavailable`&&(0,X.jsx)(`button`,{type:`button`,disabled:!i||a,onClick:()=>v(t.value.state===`reviewed`?`unreviewed`:`reviewed`),children:a?W(C,`Đang ghi…`,`Saving…`):t.value.state===`reviewed`?W(C,`Bỏ dấu review`,`Mark unreviewed`):t.value.state===`stale`?W(C,`Review lại`,`Review again`):W(C,`Đánh dấu đã review`,`Mark reviewed`)})]}),n.state===`ready`&&n.value?.state===`ready`&&n.value.target&&(0,X.jsxs)(`div`,{className:`source-mutation-preview`,children:[(0,X.jsx)(`span`,{children:n.value.action===`source.stage`?W(C,`Chuẩn bị đúng thay đổi file này để commit`,`Prepare this exact file change for commit`):W(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,X.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>y([]),children:c?W(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,X.jsxs)(`div`,{className:`source-revert-preview`,children:[(0,X.jsx)(`span`,{children:W(C,`Hoàn tác phần chưa stage; giữ nguyên index`,`Revert unstaged changes while preserving the index`)}),(0,X.jsx)(`button`,{type:`button`,disabled:!u||d,onClick:()=>b(null),children:d?W(C,`Đang dựng preview…`,`Building preview…`):`Revert file`})]}),(0,X.jsx)(No,{path:w.file.path}),f&&(0,X.jsx)(`div`,{className:`source-open-action`,children:(0,X.jsx)(`button`,{type:`button`,disabled:p,onClick:x,children:p?W(C,`Đang mở…`,`Opening…`):W(C,`Mở trong VS Code`,`Open in VS Code`)})}),(0,X.jsxs)(Zr,{className:`mode-switch`,exclusive:!0,size:`small`,value:g,"aria-label":W(C,`Kiểu hiển thị diff`,`Diff layout`),onChange:(e,t)=>t&&_(t),children:[(0,X.jsx)(Gr,{value:`inline`,"aria-label":`Inline`,children:`Inline`}),(0,X.jsx)(Gr,{value:`split`,"aria-label":W(C,`Hai cột`,`Side by side`),children:W(C,`Hai cột`,`Side by side`)})]})]})]}),o&&(0,X.jsx)(`div`,{className:`review-error`,role:`status`,children:o}),l&&(0,X.jsx)(`div`,{className:`review-error`,role:`status`,children:l}),m&&(0,X.jsx)(`div`,{className:`source-open-status`,role:`status`,children:m}),h&&(0,X.jsxs)(`div`,{className:`detail-reconciliation-warning`,role:`status`,children:[(0,X.jsx)(`span`,{children:W(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,X.jsx)(`button`,{type:`button`,onClick:S,children:W(C,`Thử đồng bộ lại`,`Retry reconciliation`)})]}),(0,X.jsxs)(`div`,{className:`diff-context`,children:[(0,X.jsx)(`span`,{children:jl(w.file,C)}),(0,X.jsx)(`span`,{children:Pl(w.file,C)}),(0,X.jsxs)(`span`,{className:`additions`,children:[`+`,w.file.stats.additions??`?`]}),(0,X.jsxs)(`span`,{className:`deletions`,children:[`−`,w.file.stats.deletions??`?`]})]}),w.fallback.kind!==`none`&&(0,X.jsxs)(`div`,{className:`diff-fallback`,children:[(0,X.jsx)(`strong`,{children:$(w.fallback.kind,C)}),(0,X.jsx)(`span`,{children:w.fallback.message??w.fallback.reasonCode??W(C,`Nội dung diff không sẵn sàng`,`Diff content unavailable`)})]}),w.hunks.map((e,t)=>(0,X.jsxs)(`section`,{className:`diff-hunk`,"aria-label":`${W(C,`Vùng thay đổi`,`Change region`)} ${t+1}`,children:[(0,X.jsxs)(`div`,{className:`hunk-header`,children:[(0,X.jsx)(`span`,{children:e.header}),(0,X.jsxs)(`span`,{className:`hunk-actions`,children:[n.value?.state===`ready`&&n.value.target?.hunkRefs.includes(e.hunkRef)&&(0,X.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,X.jsx)(`button`,{className:`revert-action`,type:`button`,disabled:!u||d,onClick:()=>b(e.hunkRef),children:`Revert hunk`})]})]}),(0,X.jsx)(`div`,{className:g===`split`?`split-code`:`inline-code`,children:e.lines.map(e=>(0,X.jsx)(su,{line:e,side:g,path:w.file.path},e.lineRef))}),w.unchangedRegions[t]&&(0,X.jsxs)(`div`,{className:`unchanged-region`,children:[`… `,w.unchangedRegions[t].lineCount,` `,W(C,`dòng không đổi đã thu gọn`,`unchanged lines collapsed`),` …`]})]},e.hunkRef)),(0,X.jsx)(El,{path:w.file.path,shownLines:new Set(w.hunks.flatMap(e=>e.lines.map(e=>e.newLineNumber).filter(e=>typeof e==`number`)))}),w.truncation.truncated&&(0,X.jsxs)(`div`,{className:`diff-fallback`,children:[(0,X.jsx)(`strong`,{children:W(C,`Diff đã rút gọn`,`Diff truncated`)}),(0,X.jsxs)(`span`,{children:[W(C,`Còn`,`Another`),` `,w.truncation.omittedLines,` `,W(C,`dòng chưa hiển thị.`,`lines are not shown.`)]})]})]})}function lu({snapshot:e,refreshSnapshot:t,sessionRef:n,findings:r,onSendComments:i}){let{locale:a}=ze(),[o,s]=(0,Y.useState)(()=>n?ll(n):[]),[c,l]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{s(n?ll(n):[]),l(null)},[n]),(0,Y.useEffect)(()=>{let e=e=>{n&&e.detail===n&&s(ll(n))};return window.addEventListener(tl,e),()=>window.removeEventListener(tl,e)},[n]);let u=(0,Y.useCallback)(e=>{s(e),n&&ul(n,e)},[n]),d=!!(e.task&&e.sourceChanges.task?.state!==`unavailable`&&e.sourceChanges.task?.revision),f=(0,Y.useMemo)(()=>kl(a),[a]),[p,m]=(0,Y.useState)(()=>d?`task`:`working-tree`),[h,g]=(0,Y.useState)({}),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)({state:`idle`}),[x,S]=(0,Y.useState)({state:`idle`}),[C,w]=(0,Y.useState)({state:`idle`}),[T,E]=(0,Y.useState)({state:`idle`}),[D,O]=(0,Y.useState)(null),[k,A]=(0,Y.useState)(!1),[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(!1),[F,I]=(0,Y.useState)(null),[L,R]=(0,Y.useState)(!1),[z,B]=(0,Y.useState)(null),[V,ee]=(0,Y.useState)(!1),[te,ne]=(0,Y.useState)(null),[re,ie]=(0,Y.useState)(null),[ae,oe]=(0,Y.useState)({state:`idle`}),[se,ce]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(null),[de,fe]=(0,Y.useState)(!1),[pe,me]=(0,Y.useState)(0),[he,ge]=(0,Y.useState)(`inline`),H={sourceProjectionRevision:e.sourceChanges.projectionRevision??null,taskViewRevision:e.sourceChanges.task.revision,workspaceRevision:e.sourceChanges.workingTree.revision,indexRevision:e.sourceChanges.staged.revision},_e=Fl(H,e.identity),ve=[_e,pe].join(``),ye=[_e,e.revision.taskRevision??`no-task-revision`].join(``),be=[n??`default-session`,p,e.identity.projectRef,e.identity.runtimeInstanceId,e.identity.sessionRef,e.identity.taskId??`no-task`,e.identity.taskRunId??`no-run`].join(``),xe=(0,Y.useRef)(be);xe.current=be;let Se=(0,Y.useRef)(0),Ce=(0,Y.useRef)(be);Ce.current!==be&&(Ce.current=be,Se.current+=1);let we=Se.current,U=(0,Y.useRef)(null),Te=h[p],Ee=Te?.state===`ready`?Rl(Te.value,Te.revisionKey,ve,H,e.identity,p):null,De=Te?.state===`ready`&&!Ee?{state:`loading`}:Te,Oe=Ee?.files??[],ke=Bl(Oe,_),Ae=ke?Oe.find(e=>e.fileRef===ke)??null:null,je=!!(Ee&&Ae),Me=e.capabilities.capabilities.reviewActions,Ne=JSON.stringify(Me),Pe=p===`working-tree`?`source.stage`:p===`staged`?`source.unstage`:null,Fe=Me.status===`available`&&Me.actions.reviewMark.available,Ie=Pe===`source.stage`?Me.status===`available`&&Me.actions.stage.available:Pe===`source.unstage`&&Me.status===`available`&&Me.actions.unstage.available,Le=p===`working-tree`&&Me.status===`available`&&Me.actions.revert.available,Re=je?[n??`default-session`,p,ke,Ee.viewRevision,Ae.fileRevision,ye,pe,Ne].join(``):`no-detail-request`,Be=!!(je&&y.requestKey===Re&&y.state===`ready`&&zl(y.value,p,ke,Ee.viewRevision,Ae.fileRevision,e)),Ve=!!(je&&x.requestKey===Re&&x.state===`ready`&&nu(x.value,p,ke,Ee.viewRevision,Ae.fileRevision,e,Be?y.value:void 0)),G=!!(je&&C.requestKey===Re&&C.state===`ready`&&nu(C.value,p,ke,Ee.viewRevision,Ae.fileRevision,e,Be?y.value:void 0)),He=!!(je&&T.requestKey===Re&&T.state===`ready`&&nu(T.value,p,ke,Ee.viewRevision,Ae.fileRevision,e,Be?y.value:void 0)),Ue=!!(je&&y.requestKey===Re&&y.state===`ready`&&!Be),We=!!(je&&x.requestKey===Re&&x.state===`ready`&&!Ve),Ge=!!(je&&C.requestKey===Re&&C.state===`ready`&&!G),Ke=!!(je&&T.requestKey===Re&&T.state===`ready`&&!He),qe=!!(je&&y.requestKey===Re&&y.state===`error`),Je=!!(je&&Fe&&x.requestKey===Re&&x.state===`error`),Ye=!!(je&&Ie&&C.requestKey===Re&&C.state===`error`),Xe=!!(je&&Le&&T.requestKey===Re&&T.state===`error`),Ze=Ue||We||Ge||Ke||qe||Je||Ye||Xe,Qe=!!(je&&Be&&(!Fe||Ve)&&(!Ie||G)&&(!Le||He)),$e=(0,Y.useRef)(null);ke&&($e.current={sourceScope:be,fileRef:ke});let et=[be,ke??($e.current?.sourceScope===be?$e.current.fileRef:`no-file`)].join(``),tt=(0,Y.useRef)(et);tt.current=et;let nt=(0,Y.useRef)(new Set),K=(0,Y.useRef)(0),rt=(0,Y.useRef)(et);rt.current!==et&&(rt.current=et,K.current+=1);let it=K.current,[at,ot]=(0,Y.useState)(null),st=!!(Ze&&t&&(!nt.current.has(et)||at?.scope===et&&at.generation===it&&at.requestKey===Re)),ct=je?y.requestKey===Re?(Ue||qe)&&st?{state:`loading`}:Ue||qe?{state:`error`}:y:{state:`loading`}:{state:`idle`},lt=ct.state===`ready`?ct.value:void 0,ut=new Map;for(let e of lt?.hunks.flatMap(e=>e.lines)??[]){let t=e.kind===`deleted`?`old`:`new`,n=t===`old`?e.oldLineNumber:e.newLineNumber;typeof n==`number`&&lt&&ut.set(ol(lt.file.path,t,n),e.text)}let dt=n&&i?{locale:a,findings:r,comments:o,editing:c?.key??null,open:(e,t,n,r)=>l({key:ol(e,t,n),path:e,side:t,line:n,code:r}),save:e=>{c&&u(dl(o,{path:c.path,side:c.side,line:c.line,code:c.code,text:e})),l(null)},cancel:()=>l(null),remove:e=>u(o.filter(t=>ol(t.path,t.side,t.line)!==e))}:null,J=je&&Fe?x.requestKey===Re?st?{state:`loading`}:We||Je?{state:`error`}:x:{state:`loading`}:{state:`idle`},pt=je&&Ie?C.requestKey===Re?st?{state:`loading`}:Ge||Ye?{state:`error`}:C:{state:`loading`}:{state:`idle`},mt=je&&Le?T.requestKey===Re?st?{state:`loading`}:Ke||Xe?{state:`error`}:T:{state:`loading`}:{state:`idle`},ht=je?[n??`default-session`,p,ke,Ee.viewRevision,Ae.fileRevision,ye].join(``):`no-source-authority`,gt=(0,Y.useRef)(ht);gt.current=ht;let _t=[ht,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(``),vt=(0,Y.useRef)(_t);vt.current=_t;let yt=[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(``),bt=(0,Y.useRef)(yt);bt.current=yt;let xt=(0,Y.useRef)(``),St=(0,Y.useRef)(``);xt.current=[ht,Xl(J.value)].join(``),St.current=Zl(J.value),(0,Y.useEffect)(()=>{oe({state:`idle`}),ue(null),fe(!1)},[yt]),(0,Y.useEffect)(()=>{!d&&p===`task`&&(m(`working-tree`),v(null))},[d,p]),(0,Y.useEffect)(()=>{U.current=null,ie(null)},[be,we]),(0,Y.useEffect)(()=>{Qe&&(nt.current.delete(et),ot(e=>e?.scope===et?null:e))},[Qe,et]),(0,Y.useEffect)(()=>{let r=new AbortController,i=ve;return g(e=>({...e,[p]:{state:`loading`,revisionKey:i}})),(n?Os(n,p,r.signal):Bs(p,r.signal)).then(n=>{if(!n){r.signal.aborted||g(e=>({...e,[p]:{state:`error`,revisionKey:i}}));return}if(!Il(n,p,H,e.identity)){if(r.signal.aborted)return;if(!t||U.current===be){g(e=>({...e,[p]:{state:`error`,revisionKey:i}}));return}U.current=be,g(e=>({...e,[p]:{state:`loading`,revisionKey:i}})),t().then(e=>{if(!r.signal.aborted){if(!e){g(e=>({...e,[p]:{state:`error`,revisionKey:i}}));return}me(e=>e+1)}}).catch(()=>{r.signal.aborted||g(e=>({...e,[p]:{state:`error`,revisionKey:i}}))});return}U.current=null,r.signal.aborted||g(e=>({...e,[p]:{state:`ready`,value:n,revisionKey:i}}))}).catch(()=>{r.signal.aborted||g(e=>({...e,[p]:{state:`error`,revisionKey:i}}))}),()=>r.abort()},[p,ve,n]);let Ct=(0,Y.useCallback)(()=>{let e=be,n=we,r=_e;U.current=null,g(e=>({...e,[p]:{state:`loading`,revisionKey:ve}})),(async()=>{let i;try{i=await t?.()}catch{}if(xe.current!==e||Se.current!==n)return;U.current=e;let a=i?Fl({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)&&me(e=>e+1)})()},[t,_e,we,be,ve,p]);(0,Y.useEffect)(()=>{if(!ke){b({state:`idle`}),S({state:`idle`}),w({state:`idle`}),E({state:`idle`}),M(null),I(null),B(null),O(null),ne(null);return}let e=new AbortController,t=Re;return b({state:`loading`,requestKey:t}),M(null),I(null),B(null),O(null),ne(null),S(Fe?{state:`loading`,requestKey:t}:{state:`idle`}),w(Ie?{state:`loading`,requestKey:t}:{state:`idle`}),E(Le?{state:`loading`,requestKey:t}:{state:`idle`}),(n?ks(n,p,ke,e.signal):Vs(p,ke,e.signal)).then(n=>{e.signal.aborted||b({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||b({state:`error`,requestKey:t})}),Fe&&(n?As(n,p,ke,e.signal):Hs(p,ke,e.signal)).then(n=>{e.signal.aborted||S({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||S({state:`error`,requestKey:t})}),Ie&&Pe&&(n?js(n,Pe,ke,e.signal):Us(Pe,ke,e.signal)).then(n=>{e.signal.aborted||w({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||w({state:`error`,requestKey:t})}),Le&&(n?Ms(n,ke,null,e.signal):Ws(ke,null,e.signal)).then(n=>{e.signal.aborted||E({state:`ready`,value:n,requestKey:t})}).catch(()=>{e.signal.aborted||E({state:`error`,requestKey:t})}),()=>e.abort()},[ke,p,ye,pe,n,Ne,Re]);let wt=(0,Y.useCallback)(e=>{if(!je||!t)return;let n=et,r=it,i=Re;!e&&nt.current.has(n)||(nt.current.add(n),ot({scope:n,generation:r,requestKey:i}),t().then(e=>{e&&tt.current===n&&K.current===r&&me(e=>e+1)}).catch(()=>void 0).finally(()=>{ot(e=>e?.scope===n&&e.generation===r&&e.requestKey===i?null:e)}))},[je,it,et,Re,t]);(0,Y.useEffect)(()=>{!je||!Ze||!t||nt.current.has(et)||wt(!1)},[wt,je,Ze,et,t]);let Tt=Oe,Et=(0,Y.useMemo)(()=>{let e=new Map;for(let t of Tt){let n=t.path.lastIndexOf(`/`),r=n<0?W(a,`Gốc project`,`Project root`):t.path.slice(0,n);e.set(r,[...e.get(r)??[],t])}return[...e.entries()]},[Tt,a]),Dt=(0,Y.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=h[n];return(r?.state===`ready`?Rl(r.value,r.revisionKey,ve,H,e.identity,n):null)?.page.total??t[n]};return{task:n(`task`),"working-tree":n(`working-tree`),staged:n(`staged`)}},[h,ve,e.sourceChanges.task.counts.files,e.sourceChanges.workingTree.counts.files,e.sourceChanges.staged.counts.files]),Ot=e=>{ie(null),m(e),v(null)},kt=Me.status===`available`&&Me.actions.reviewMark.available,At=pt.value?.action===`source.stage`?Me.status===`available`&&Me.actions.stage.available:pt.value?.action===`source.unstage`&&Me.status===`available`&&Me.actions.unstage.available,jt=Me.status===`available`&&Me.actions.revert.available,Mt=p===`working-tree`&&Me.status===`available`&&Me.actions.openInVsCode.available&&ct.state===`ready`&&ct.value?.availability.state===`current`&&ct.value.fallback.kind===`none`,Nt=p===`staged`&&Tt.length>0,Pt=Nt&&Me.status===`available`&&Me.actions.generateCommitSummaryDeterministic.available,Ft=Nt&&Me.status===`available`&&Me.actions.generateCommitSummaryModel.available,It=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`,Lt=async t=>{if(!ke||!J.value||k)return;let r=J.value,i=Zl(r),o=xt.current,s=vt.current,c=be,l=we,u=et,d=it,f=_e,m=!1;A(!0),M(null),ie(null);try{let h=await Fc(e,r,t);if(xt.current!==o||St.current!==i||vt.current!==s)return;let g=await ru(h.idempotencyKey);if(xt.current!==o||St.current!==i||vt.current!==s)return;m=!0;let _=await cc(h);if(!$l(h,_,t,g)){if(_.phase!==`rejected`){await Rt(c,l,u,d,f,W(a,`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}xt.current===o&&St.current===i&&M(_.error?.message??W(a,`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(xt.current!==o||St.current!==i)return;S(e=>xt.current===o&&Zl(e.value)===i?{state:`ready`,requestKey:e.requestKey,value:{...r,generatedAt:_.settledAt,state:_.resultCode,recordedState:_.resultCode,recordedAt:_.settledAt,evidenceRef:_.settlementEvidenceRef,reasonCode:null,health:{state:`ok`,reasonCode:null,message:null}}}:e),(n?As(n,p,ke):Hs(p,ke)).then(e=>S(t=>xt.current===o&&t.state===`ready`&&t.value?.evidenceRef===_.settlementEvidenceRef?{state:`ready`,value:e,requestKey:t.requestKey}:t)).catch(()=>void 0)}catch{m?await Rt(c,l,u,d,f,W(a,`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.`)):xt.current===o&&St.current===i&&M(W(a,`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{A(!1)}},Rt=async(e,n,r,i,a,o)=>{tt.current===r&&K.current===i&&(b({state:`idle`}),S({state:`idle`}),w({state:`idle`}),E({state:`idle`}),O(null),M(null),I(null),B(null),ne(null),ie(null));let s;try{s=await t?.()}catch{}if(xe.current!==e||Se.current!==n)return;let c=s?Fl({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)&&me(e=>e+1),ie({scope:e,generation:n,message:o})},zt=async(n=[])=>{if(!ke||!Ee||!pt.value||pt.value.state!==`ready`||N)return;let r=gt.current,i=vt.current,o=pt.value,s=be,c=we,l=et,u=it,d=_e,f=!1;P(!0),I(null),ie(null);try{let p=await Rc(e,o,n);if(gt.current!==r||vt.current!==i)return;f=!0;let m=await lc(p);if(m.phase===`uncertain`){await Rt(s,c,l,u,d,W(a,`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(m.phase!==`settled`||![`staged`,`unstaged`].includes(m.resultCode)){gt.current===r&&I(m.error?.message??W(a,`File hoặc Git index đã thay đổi; hãy tải lại preview.`,`The file or Git index changed; reload the preview.`));return}gt.current===r&&v(null),await t?.(),me(e=>e+1)}catch{f?await Rt(s,c,l,u,d,W(a,`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.`)):gt.current===r&&I(W(a,`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{P(!1)}},Bt=async e=>{if(!ke||!Ee||!jt||L)return;let t=gt.current,r=ke;R(!0),B(null),ie(null);try{let i=n?await Ms(n,r,e):await Ws(r,e);if(gt.current!==t)return;if(i.state!==`ready`||!i.target){B(W(a,`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}O(i)}catch{gt.current===t&&B(W(a,`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{R(!1)}},Vt=async()=>{if(!D?.target||!ke||!Ee||!Ae||L||!tu(D.target,p,ke,Ee.viewRevision,Ae.fileRevision,e))return;let r=gt.current,i=vt.current,o=D,s=be,c=we,l=et,u=it,d=_e,f=!1;R(!0),B(null),ie(null);try{let p=await Vc(e,o);if(gt.current!==r||vt.current!==i)return;f=!0;let m=await uc(p,void 0,n);if(m.phase===`uncertain`){await Rt(s,c,l,u,d,W(a,`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`){gt.current===r&&B(m.error?.message??W(a,`Preview đã cũ; hãy mở lại trước khi xác nhận.`,`The preview is stale; reopen it before confirming.`));return}gt.current===r&&(O(null),v(null)),await t?.(),me(e=>e+1)}catch{f?await Rt(s,c,l,u,d,W(a,`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.`)):gt.current===r&&B(W(a,`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{R(!1)}},Ht=async()=>{if(!ke||!Mt||V)return;let t=gt.current,n=vt.current,r=ke;ee(!0),ne(null);try{let i=await Gc(e,r);if(gt.current!==t||vt.current!==n)return;let o=await dc(i);if(gt.current!==t)return;o.phase===`settled`&&o.resultCode===`opened`?ne(W(a,`VS Code đã nhận yêu cầu mở file.`,`VS Code received the open-file request.`)):ne(o.phase===`uncertain`?W(a,`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??W(a,`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{gt.current===t&&ne(W(a,`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{ee(!1)}},Ut=async()=>{if(!Pt||se)return;let e=bt.current;ce(!0),ue(null),oe({state:`loading`});try{let t=n?await Ns(n):await Gs();if(bt.current!==e)return;if(!It(t)){oe({state:`error`}),ue(W(a,`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}oe({state:`ready`,value:t}),t.state!==`ready`&&ue(W(a,`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{bt.current===e&&(oe({state:`error`}),ue(W(a,`Không thể dựng commit summary từ index hiện tại.`,`Unable to generate a commit summary from the current index.`)))}finally{ce(!1)}},Wt=async()=>{let e=ae.value?.summary;if(!e||!It(ae.value))return;let t=bt.current;try{await navigator.clipboard.writeText([e.title,``,...e.bodyLines].join(`
41
- `)),bt.current===t&&ue(W(a,`Đã copy summary. Chưa có commit nào được tạo.`,`Summary copied. No commit was created.`))}catch{bt.current===t&&ue(W(a,`Trình duyệt không cho phép copy tự động.`,`The browser did not allow automatic copying.`))}},Gt=async()=>{let t=ae.value?.summary;if(!t||!It(ae.value)||!Ft||se)return;let n=bt.current;ce(!0),ue(null);try{let r=await Tc(e,t.modelPrompt,`new-operation`);if(bt.current!==n||!It(ae.value))return;let i=await ic(r);if(bt.current!==n)return;i.phase===`settled`&&i.resultCode===`dispatch-observed`?ue(W(a,`Đã 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.`)):ue(i.phase===`uncertain`?W(a,`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.`):i.error?.message??W(a,`Không thể bắt đầu model work từ session hiện tại.`,`Unable to start model work from the current session.`))}catch{bt.current===n&&ue(W(a,`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{ce(!1),fe(!1)}},Kt=re?.scope===be&&re.generation===we?re.message:null;return(0,X.jsxs)(ft,{component:`section`,variant:`outlined`,className:`source-workspace`,"aria-labelledby":`source-title`,sx:{overflow:`hidden`,minHeight:`calc(100vh - 120px)`,display:`flex`,flexDirection:`column`},children:[(0,X.jsxs)(Z,{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,X.jsxs)(Z,{children:[(0,X.jsx)(q,{variant:`overline`,color:`primary.main`,sx:{fontWeight:800,letterSpacing:`.14em`,lineHeight:1},children:`Source changes`}),(0,X.jsx)(q,{variant:`h2`,id:`source-title`,sx:{mt:.5},children:W(a,`Thay đổi trong project`,`Project changes`)})]}),(0,X.jsx)(er,{label:`Git + task baseline`,variant:`outlined`,size:`small`})]}),(0,X.jsx)(ss,{className:`source-tabs`,value:p,onChange:(e,t)=>Ot(t),selectionFollowsFocus:!0,variant:`scrollable`,scrollButtons:`auto`,"aria-label":W(a,`Nguồn thay đổi`,`Change sources`),sx:{borderBottom:1,borderColor:`divider`,minHeight:48},children:f.map(e=>(0,X.jsx)(Bo,{id:`source-tab-${e.view}`,value:e.view,"aria-controls":`source-tabpanel`,disabled:e.view===`task`&&!d,title:e.view===`task`&&!d?W(a,`Session này chưa có task baseline`,`This session has no task baseline`):void 0,label:(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,X.jsx)(`span`,{children:e.label}),Dt[e.view]>0&&(0,X.jsx)(er,{size:`small`,label:Dt[e.view],sx:{height:20,minWidth:24,"& .MuiChip-label":{px:.75}}})]})},e.view))}),p===`staged`&&(0,X.jsx)(iu,{state:ae,busy:se,status:le,locale:a,deterministicEnabled:Pt,modelEnabled:Ft,onGenerate:()=>{Ut()},onCopy:()=>{Wt()},onModel:()=>fe(!0)}),dt&&(0,X.jsx)(Dl,{comments:o,lines:ut,linesPath:lt?.file.path,locale:a,onSend:()=>{i?.(pl(o,a===`en`)),u([])},onClear:()=>u([])}),(0,X.jsxs)(Z,{className:`source-body`,sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`minmax(286px, 330px) minmax(0, 1fr)`},flex:1,minHeight:620},children:[(0,X.jsxs)(Z,{className:`file-panel`,id:`source-tabpanel`,role:`tabpanel`,"aria-labelledby":`source-tab-${p}`,sx:{minWidth:0,borderRight:{md:1},borderBottom:{xs:1,md:0},borderColor:`divider`,bgcolor:`background.default`},children:[(0,X.jsxs)(Z,{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,X.jsx)(`span`,{"aria-live":`polite`,children:De?.state===`ready`&&De.value?Nl(De.value,a):De?.state===`error`?W(a,`Không thể tải danh sách file`,`Unable to load files`):W(a,`Đang tải…`,`Loading…`)}),(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[De?.state===`error`&&(0,X.jsx)(`button`,{className:`source-list-retry`,type:`button`,onClick:Ct,children:W(a,`Thử tải lại`,`Retry`)}),(0,X.jsx)(`small`,{children:f.find(e=>e.view===p)?.shortLabel})]})]}),(0,X.jsxs)(Z,{className:`file-list`,sx:{maxHeight:{xs:300,md:`calc(100vh - 270px)`},overflow:`auto`,p:.75},children:[Et.map(([e,t])=>(0,X.jsxs)(Z,{children:[(0,X.jsxs)(Q,{direction:`row`,className:`file-group-label`,children:[(0,X.jsx)(Fo,{}),(0,X.jsx)(q,{component:`span`,noWrap:!0,children:e})]}),t.map(e=>(0,X.jsx)(au,{file:e,selected:e.fileRef===ke,onSelect:()=>{ie(null),v(e.fileRef)},locale:a},e.fileRef))]},e)),De?.state===`ready`&&Tt.length===0&&(0,X.jsx)(`div`,{className:`files-empty`,children:W(a,`Không có thay đổi trong view này.`,`No changes in this view.`)})]})]}),(0,X.jsx)(yl.Provider,{value:dt,children:(0,X.jsx)(cu,{state:ct,review:J,mutation:pt,revert:mt,reviewEnabled:kt,reviewBusy:k,reviewError:j,mutationEnabled:At,mutationBusy:N,mutationError:F,revertEnabled:jt,revertBusy:L,openEnabled:Mt,openBusy:V,openStatus:te,detailError:Ze&&!st,mode:he,onMode:ge,onReview:e=>{Lt(e)},onMutation:e=>{zt(e)},onRevert:e=>{Bt(e)},onOpen:()=>{Ht()},onRetry:je&&t?()=>wt(!0):void 0,locale:a})})]}),Kt&&(0,X.jsx)(`div`,{className:`source-action-warning`,role:`status`,children:Kt}),z&&(0,X.jsx)(`div`,{className:`source-revert-error`,role:`status`,children:z}),D?.target&&ke&&Ee&&Ae&&tu(D.target,p,ke,Ee.viewRevision,Ae.fileRevision,e)&&(0,X.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,X.jsxs)(`section`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`revert-dialog-title`,"aria-describedby":`revert-dialog-description`,children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(a,`Xác nhận hoàn tác`,`Confirm revert`)}),(0,X.jsxs)(`h3`,{id:`revert-dialog-title`,children:[`Revert `,D.target.hunkRefs.length?`hunk`:`file`,`?`]}),(0,X.jsxs)(`p`,{id:`revert-dialog-description`,children:[W(a,`Thao tác sẽ bỏ`,`This will discard`),` `,(0,X.jsxs)(`strong`,{children:[D.target.summary.additionsDiscarded,` `,W(a,`dòng thêm`,`added lines`)]}),` `,W(a,`và khôi phục`,`and restore`),` `,(0,X.jsxs)(`strong`,{children:[D.target.summary.deletionsRestored,` `,W(a,`dòng xóa`,`deleted lines`)]}),` `,W(a,`trong`,`in`),` `,(0,X.jsx)(`code`,{children:D.target.path}),`.`]}),(0,X.jsx)(`div`,{className:`revert-diff`,"aria-label":W(a,`Các dòng chính xác sẽ được hoàn tác`,`Exact lines to revert`),children:D.preview?.hunks.map(e=>(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`div`,{children:e.header}),e.lines.map((t,n)=>(0,X.jsxs)(`code`,{className:`revert-line revert-${t.kind}`,children:[(0,X.jsx)(`b`,{children:t.marker}),t.text]},`${e.hunkRef}.${n}`))]},e.hunkRef))}),(0,X.jsxs)(`div`,{className:`revert-safety`,children:[(0,X.jsx)(`strong`,{children:W(a,`Phần đã stage được giữ nguyên.`,`Staged content is preserved.`)}),(0,X.jsx)(`span`,{children:W(a,`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,X.jsxs)(`div`,{className:`confirm-actions`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:L,onClick:()=>O(null),children:W(a,`Hủy`,`Cancel`)}),(0,X.jsx)(`button`,{className:`danger-action`,type:`button`,disabled:L,onClick:()=>{Vt()},children:L?W(a,`Đang hoàn tác…`,`Reverting…`):W(a,`Xác nhận revert`,`Confirm revert`)})]})]})}),de&&It(ae.value)&&(0,X.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,X.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,X.jsx)(`p`,{className:`section-kicker`,children:W(a,`Model work có tính phí`,`Token-consuming model work`)}),(0,X.jsx)(`h3`,{id:`model-summary-dialog-title`,children:W(a,`Nhờ Pi viết lại commit summary?`,`Ask Pi to rewrite the commit summary?`)}),(0,X.jsx)(`p`,{id:`model-summary-dialog-description`,children:W(a,`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,X.jsxs)(`div`,{className:`revert-safety`,children:[(0,X.jsx)(`strong`,{children:W(a,`Không tự commit hoặc push.`,`Does not commit or push.`)}),(0,X.jsx)(`span`,{children:W(a,`Kết quả sẽ xuất hiện trong Chat để review và copy.`,`The result will appear in Chat for review and copying.`)})]}),(0,X.jsxs)(`div`,{className:`confirm-actions`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:se,onClick:()=>fe(!1),children:W(a,`Hủy`,`Cancel`)}),(0,X.jsx)(`button`,{type:`button`,disabled:se,onClick:()=>{Gt()},children:se?W(a,`Đang gửi…`,`Sending…`):W(a,`Xác nhận và gửi sang Pi`,`Confirm and send to Pi`)})]})]})})]})}var uu,du=(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${U(n.position)}`],n.disablePointerEvents===!0&&t.disablePointerEvents,t[n.variant]]},fu=e=>{let{classes:t,disablePointerEvents:n,hiddenLabel:r,position:i,size:a,variant:o}=e,s={root:[`root`,n&&`disablePointerEvents`,i&&`position${U(i)}`,o,r&&`hiddenLabel`,a&&`size${U(a)}`]};return he(s,z,t)},pu=H(`div`,{name:`MuiInputAdornment`,slot:`Root`,overridesResolver:du})(ge(({theme:e})=>({display:`flex`,maxHeight:`2em`,alignItems:`center`,whiteSpace:`nowrap`,color:(e.vars||e).palette.action.active,variants:[{props:{variant:`filled`},style:{[`&.${B.positionStart}&:not(.${B.hiddenLabel})`]:{marginTop:16}}},{props:{position:`start`},style:{marginRight:8}},{props:{position:`end`},style:{marginLeft:8}},{props:{disablePointerEvents:!0},style:{pointerEvents:`none`}}]}))),mu=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiInputAdornment`}),{children:r,className:i,component:a=`div`,disablePointerEvents:o=!1,disableTypography:s=!1,position:c,variant:l,...u}=n,d=pe()||{},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=fu(p);return(0,X.jsx)(P.Provider,{value:null,children:(0,X.jsx)(pu,{as:a,ownerState:p,className:h(m.root,i),ref:t,...u,children:typeof r==`string`&&!s?(0,X.jsx)(q,{color:`textSecondary`,children:r}):(0,X.jsxs)(Y.Fragment,{children:[c===`start`?uu||=(0,X.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):null,r]})})})}),hu=K((0,X.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`),gu=`modulepreload`,_u=function(e){return`/`+e},vu={},yu=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=_u(t,n),t=s(t),t in vu)return;vu[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`:gu,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)})},bu=(0,Y.lazy)(async()=>({default:(await yu(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-k4tq1y8s.js`);return{MarkdownMessage:e}},__vite__mapDeps([0,1,2,3,4]))).MarkdownMessage})),xu=new Set([`md`,`markdown`]),Su=new Set([`csv`,`tsv`]);function Cu(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function wu(e,t){return e.source===`project`?W(t,`Project`,`Project`):W(t,`Thư mục đã cấp quyền`,`Granted directory`)}function Tu(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===`
42
- `||n===`\r`){c(),n===`\r`&&e[o+1]===`
43
- `&&(o+=1),o+=1;continue}i+=n,o+=1}return n.length<500&&(i.length>0||r.length>0)&&c(),n}function Eu({text:e,separator:t}){let n=(0,Y.useMemo)(()=>Tu(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,X.jsx)(Z,{sx:{overflowX:`auto`},children:(0,X.jsxs)(Z,{component:`table`,className:`document-table`,children:[(0,X.jsx)(Z,{component:`thead`,children:(0,X.jsx)(Z,{component:`tr`,children:Array.from({length:a},(e,t)=>(0,X.jsx)(Z,{component:`th`,children:r[t]??``},t))})}),(0,X.jsx)(Z,{component:`tbody`,children:i.map((e,t)=>(0,X.jsx)(Z,{component:`tr`,children:Array.from({length:a},(t,n)=>(0,X.jsx)(Z,{component:`td`,children:e[n]??``},n))},t))})]})})}function Du({document:e,extension:t}){let n=e.text??``;return xu.has(t??``)?(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(Z,{component:`pre`,className:`document-plain`,children:n}),children:(0,X.jsx)(bu,{children:n})}):Su.has(t??``)?(0,X.jsx)(Eu,{text:n,separator:t===`tsv`?` `:`,`}):(0,X.jsx)(Z,{component:`pre`,className:`document-plain`,children:n})}function Ou({sessionRef:e=null}){let{locale:t}=ze(),[n,r]=(0,Y.useState)({state:`idle`}),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)({state:`idle`}),[c,l]=(0,Y.useState)(``),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{let t=new AbortController;return r({state:`loading`}),a(null),s({state:`idle`}),pc(e,t.signal).then(e=>r({state:`ready`,value:e})).catch(()=>{t.signal.aborted||r({state:`error`})}),()=>t.abort()},[e]),(0,Y.useEffect)(()=>{if(!i){s({state:`idle`});return}let t=new AbortController;return s({state:`loading`}),mc(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,Y.useMemo)(()=>(d?.documents??[]).filter(e=>!f||e.relativePath.toLowerCase().includes(f)),[d,f]),m=(0,Y.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,X.jsxs)(`section`,{className:`document-workspace surface`,"aria-labelledby":`documents-heading`,children:[(0,X.jsxs)(`header`,{className:`document-heading`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(t,`Chỉ đọc · không sửa file`,`Read only · never writes`)}),(0,X.jsx)(`h2`,{id:`documents-heading`,children:W(t,`Tài liệu`,`Documents`)})]}),(0,X.jsx)(`span`,{children:d?`${d.documents.length}${d.truncated?`+`:``} ${W(t,`tài liệu`,`documents`)}`:`—`})]}),(0,X.jsxs)(`div`,{className:`document-body`,children:[(0,X.jsxs)(`aside`,{className:`document-list`,"aria-label":W(t,`Danh sách tài liệu`,`Document list`),children:[(0,X.jsx)(te,{size:`small`,fullWidth:!0,value:c,onChange:e=>l(e.target.value),placeholder:W(t,`Lọc theo tên hoặc thư mục…`,`Filter by name or folder…`),slotProps:{htmlInput:{"aria-label":W(t,`Lọc tài liệu`,`Filter documents`)},input:{startAdornment:(0,X.jsx)(mu,{position:`start`,children:(0,X.jsx)(hu,{fontSize:`small`})})}}}),n.state===`loading`&&(0,X.jsx)(`p`,{className:`document-empty`,children:W(t,`Đang quét tài liệu…`,`Scanning for documents…`)}),n.state===`error`&&(0,X.jsx)(`p`,{className:`document-empty`,children:W(t,`Không đọc được danh sách tài liệu.`,`The document list could not be read.`)}),d?.state===`unavailable`&&(0,X.jsx)(`p`,{className:`document-empty`,children:$(d.reasonCode,t)}),n.state===`ready`&&d?.state===`ready`&&m.length===0&&(0,X.jsx)(`p`,{className:`document-empty`,children:f?W(t,`Không có tài liệu nào khớp bộ lọc.`,`No document matches the filter.`):W(t,`Chưa tìm thấy tài liệu nào.`,`No documents were found.`)}),m.map(e=>(0,X.jsxs)(`div`,{className:`document-group`,children:[(0,X.jsxs)(`div`,{className:`document-group-heading`,children:[(0,X.jsx)(`strong`,{children:wu(e.root,t)}),(0,X.jsx)(`span`,{title:e.root.path,children:e.root.path})]}),e.entries.map(e=>(0,X.jsxs)(Dr,{component:`button`,type:`button`,className:`document-row`,selected:e.documentRef===i,onClick:()=>a(e.documentRef),children:[(0,X.jsx)(xo,{fontSize:`small`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{className:`document-row-copy`,children:[(0,X.jsx)(`strong`,{children:e.name}),(0,X.jsx)(`small`,{children:e.relativePath})]}),(0,X.jsxs)(`span`,{className:`document-row-meta`,children:[e.extension,` · `,Cu(e.sizeBytes)]})]},e.documentRef))]},e.root.rootRef)),d?.truncated&&(0,X.jsx)(`p`,{className:`document-empty`,children:W(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,X.jsxs)(`div`,{className:`document-viewer`,ref:u,children:[!i&&(0,X.jsxs)(`div`,{className:`document-placeholder`,children:[(0,X.jsx)(xo,{"aria-hidden":`true`}),(0,X.jsx)(q,{variant:`body2`,children:W(t,`Chọn một tài liệu để đọc nội dung tại đây.`,`Pick a document to read it here.`)}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,children:W(t,`Hỗ trợ .md .txt .csv .json .yaml .docx .pdf`,`Supports .md .txt .csv .json .yaml .docx .pdf`)})]}),i&&o.state===`loading`&&(0,X.jsx)(`p`,{className:`document-empty`,children:W(t,`Đang mở tài liệu…`,`Opening the document…`)}),i&&o.state===`error`&&(0,X.jsx)(`p`,{className:`document-empty`,children:W(t,`Không mở được tài liệu này.`,`This document could not be opened.`)}),o.state===`ready`&&o.value&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`document-toolbar`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:o.value.name??h?.name??`—`}),(0,X.jsx)(`small`,{children:o.value.relativePath??h?.relativePath??``})]}),(0,X.jsxs)(`div`,{className:`document-badges`,children:[o.value.format&&(0,X.jsx)(er,{size:`small`,variant:`outlined`,label:o.value.format}),o.value.truncated&&(0,X.jsx)(er,{size:`small`,color:`warning`,variant:`outlined`,label:W(t,`Đã cắt bớt`,`Truncated`)}),o.value.redacted&&(0,X.jsx)(er,{size:`small`,color:`warning`,variant:`outlined`,label:W(t,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`)})]})]}),o.value.state===`unavailable`?(0,X.jsx)(`p`,{className:`document-empty`,children:$(o.value.reasonCode,t)}):(0,X.jsx)(`article`,{className:`document-content`,children:(0,X.jsx)(Du,{document:o.value,extension:h?.extension})})]})]})]})]})}function ku(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 Au(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 ju(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=>Au(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=>ku(e,r));return{rows:[...c,...s,...t],terminalCount:s.length,runningCount:c.length}}function Mu(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 Nu(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 Pu({activity:e,preview:t,onPreview:n,locale:r}){return(0,X.jsxs)(`article`,{className:`activity-row`,children:[(0,X.jsx)(`span`,{className:`activity-state tone-${Ul(e.state)}`,"aria-label":e.state}),(0,X.jsxs)(`div`,{className:`activity-copy`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:e.label}),(0,X.jsx)(`span`,{children:e.kind})]}),(0,X.jsx)(`p`,{children:e.preview||W(r,`Không có mô tả ngắn`,`No short description`)}),t&&(0,X.jsxs)(`div`,{className:`log-preview ${t.state===`error`?`error-state`:``}`,children:[t.state===`loading`?W(r,`Đang tải log ngắn…`,`Loading log preview…`):t.state===`error`?W(r,`Log preview không còn sẵn sàng.`,`Log preview is no longer available.`):t.value?.preview??`${W(r,`Không có nội dung log`,`No log content`)} · ${t.value?.reasonCode??`unavailable`}`,t.value?.truncated&&(0,X.jsx)(`small`,{children:W(r,`Preview đã được rút gọn`,`Preview truncated`)})]})]}),(0,X.jsxs)(`div`,{className:`activity-result`,children:[(0,X.jsx)(`strong`,{children:Mu(e,r)}),(0,X.jsx)(`span`,{children:Nu(e,r)}),e.logRef&&n&&(0,X.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":!!t,children:t?W(r,`Ẩn log`,`Hide log`):W(r,`Xem log`,`View log`)})]})]})}function Fu({snapshot:e,sessionRef:t,terminalActivities:n=[],liveActivities:r}){let{locale:i}=ze(),[a,o]=(0,Y.useState)({}),s=e?.activity.running??[],c=e?.activity.recent??[],{rows:l,terminalCount:u,runningCount:d}=ju(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?Ps(t,e.activityRef):Qs(e.activityRef)).then(t=>o(n=>({...n,[e.activityRef]:{state:`ready`,value:t}}))).catch(()=>o(t=>({...t,[e.activityRef]:{state:`error`}})))};return(0,X.jsxs)(`section`,{className:`activity-panel surface`,"aria-labelledby":`activity-title`,children:[(0,X.jsxs)(`header`,{className:`panel-heading`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Activity`}),(0,X.jsx)(`h2`,{id:`activity-title`,children:W(i,`Tool, command và kết quả lượt chạy`,`Tools, commands, and operation outcomes`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`span`,{className:`running-count`,children:[d,` `,W(i,`đang chạy`,`running`)]}),(0,X.jsxs)(`span`,{children:[c.length+u,` `,W(i,`gần đây`,`recent`)]})]})]}),(0,X.jsxs)(`div`,{className:`activity-list`,children:[l.map(e=>(0,X.jsx)(Pu,{activity:e,preview:a[e.activityRef],onPreview:e.logRef?()=>f(e):void 0,locale:i},e.activityRef)),l.length===0&&(0,X.jsx)(`div`,{className:`activity-empty`,children:W(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,X.jsx)(`footer`,{className:`panel-footnote`,children:W(i,`Timeline đã được rút gọn theo giới hạn local.`,`The timeline was truncated to local limits.`)})]})}function Iu(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 Lu(e,t=`vi`){return e.state!==`known`||e.tokens===null||e.percent===null?t===`vi`?`Context chưa xác định`:`Unknown context`:`${Iu(e.tokens,t)} / ${Iu(e.contextWindow,t)} · ${e.percent.toFixed(1)}%`}function Ru(e,t=`vi`){return e.state===`known`?`↑ ${Iu(e.input,t)} · ↓ ${Iu(e.output,t)}`:t===`vi`?`Không có dữ liệu`:`No data`}function zu(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 Bu(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 Vu({kicker:e,title:t,children:n}){return(0,X.jsxs)(`section`,{className:`evidence-card surface`,children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:e}),(0,X.jsx)(`h3`,{children:t}),n]})}function Hu({snapshot:e}){let{locale:t}=ze(),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,X.jsxs)(`section`,{className:`evidence-section`,"aria-labelledby":`evidence-title`,children:[(0,X.jsxs)(`header`,{className:`section-title-row`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Completion evidence`}),(0,X.jsx)(`h2`,{id:`evidence-title`,children:W(t,`Verifier, usage và handoff`,`Verifier, usage, and handoff`)})]}),(0,X.jsx)(`span`,{children:Bu(e,t)})]}),(0,X.jsxs)(`div`,{className:`evidence-grid`,children:[(0,X.jsx)(Vu,{kicker:W(t,`Verifier gần nhất`,`Latest verifier`),title:zu(n,t),children:n?(0,X.jsxs)(`dl`,{className:`evidence-list`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Command`}),(0,X.jsx)(`dd`,{title:n.command,children:n.command})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Exact`}),(0,X.jsx)(`dd`,{children:n.exact?W(t,`Có`,`Yes`):W(t,`Không`,`No`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Tree digest`}),(0,X.jsx)(`dd`,{title:n.treeDigest??void 0,children:Wl(n.treeDigest)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(t,`File làm stale`,`Stale files`)}),(0,X.jsx)(`dd`,{children:n.staleFilesKnown?n.staleByPaths.length:W(t,`Chưa biết`,`Unknown`)})]})]}):(0,X.jsx)(`p`,{className:`card-empty`,children:e.verification.reasonCode?$(e.verification.reasonCode,t):W(t,`Task chưa chạy verifier.`,`The task has not run a verifier.`)})}),(0,X.jsxs)(Vu,{kicker:`Token & context`,title:Lu(r,t),children:[(0,X.jsx)(`div`,{className:`context-meter`,role:`progressbar`,"aria-label":W(t,`Mức sử dụng context`,`Context usage`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:(0,X.jsx)(`span`,{style:{width:`${o}%`}})}),(0,X.jsxs)(`dl`,{className:`evidence-list`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(t,`Turn gần nhất`,`Latest turn`)}),(0,X.jsx)(`dd`,{children:Ru(e.usage.latestTurn,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Task total`}),(0,X.jsx)(`dd`,{children:Ru(e.usage.taskTotal,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Session total`}),(0,X.jsx)(`dd`,{children:Ru(e.usage.sessionTotal,t)})]})]})]}),(0,X.jsxs)(Vu,{kicker:`Continuation budget`,title:$(i.state,t),children:[(0,X.jsxs)(`dl`,{className:`budget-grid`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(t,`Còn lại`,`Remaining`)}),(0,X.jsx)(`dd`,{children:Iu(i.remaining,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(t,`Đã dùng`,`Used`)}),(0,X.jsx)(`dd`,{children:Iu(i.consumed,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(t,`Tối đa`,`Maximum`)}),(0,X.jsx)(`dd`,{children:Iu(i.maximum,t)})]})]}),i.reasonCode&&(0,X.jsx)(`p`,{className:`card-note`,children:$(i.reasonCode,t)})]}),(0,X.jsx)(Vu,{kicker:`Handoff`,title:a?$(a.state,t):W(t,`Chưa có handoff`,`No handoff`),children:a?(0,X.jsxs)(`div`,{className:`handoff-copy`,children:[(0,X.jsx)(`p`,{children:a.summary}),a.blocker&&(0,X.jsxs)(`div`,{className:`handoff-blocker`,children:[(0,X.jsx)(`strong`,{children:`Blocker`}),(0,X.jsx)(`span`,{children:a.blocker})]}),a.nextSafeAction&&(0,X.jsxs)(`div`,{className:`next-action`,children:[(0,X.jsx)(`strong`,{children:W(t,`Bước an toàn tiếp theo`,`Next safe action`)}),(0,X.jsx)(`span`,{children:a.nextSafeAction})]})]}):(0,X.jsx)(`p`,{className:`card-empty`,children:W(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 Uu=16384;function Wu(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 Gu(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,Uu),truncated:e.truncated||n.length>Uu})}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 Ku=/^(?:\p{White_Space}|\p{Cc}|\p{Default_Ignorable_Code_Point})$/u,qu=/\u001b(?:\[[0-?]*[ -/]*[@-~]|[@-_])/g;function Ju(e){for(let t of e.replace(qu,``))if(!Ku.test(t))return!0;return!1}function Yu(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 Xu(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(`
44
-
45
- `,t[0].length);return{text:r<0?``:e.slice(r+2).trimStart(),completionGate:n}}var Zu=new Set([`provider-auth-expired`,`provider-auth-required`,`provider-rate-limited`,`provider-unavailable`,`provider-response-failed`,`assistant-output-incomplete`]);function Qu(e){let t=e.content.reasonCode;return e.role===`assistant`&&e.toolCalls.length===0&&e.content.state===`unavailable`&&t&&(Zu.has(t)||t.startsWith(`company-`))?t:null}function $u(e){let t=Xu(e);return t.completionGate===null&&Ju(t.text)?t.text:null}function ed(e,t){let n=e?.trim(),r=t.trim();return!!(n&&r&&(n===r||n.startsWith(`/`)&&n.endsWith(` ${r}`)))}function td(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 nd(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`&&ed(i.content.text,r)&&td(i,n))return t}return-1}function rd(e,t,n){return nd(e,t,n)>=0}function id(e,t,n,r){let i=nd(e,t,r);if(i<0)return!1;let a=$u(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)&&$u(n.content.text??``)?.trim()===a)return!0}return!1}function ad(e,t,n){let r=nd(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)&&($u(n.content.text??``)||Qu(n)))return!0}return!1}function od(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(Qu(s)){if(a)continue;o?t[t.indexOf(o)]=s:t.push(s),o=s;continue}let e=$u(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 sd(e,t,n){return e===`vi`?t:n}var cd={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`},ld={xls:`sheet`,xlsx:`sheet`,xlsm:`sheet`,numbers:`sheet`,ods:`sheet`,ppt:`slides`,pptx:`slides`,key:`slides`,odp:`slides`,doc:`word`,pages:`word`,odt:`word`,rtf:`word`,...Object.fromEntries(`zip.gz.tgz.bz2.xz.rar.7z.tar.jar.war.exe.dmg.pkg.msi.deb.rpm.apk.ipa.bin.so.dylib.dll.o.a.lib.class.pyc.wasm.node.iso.img.sqlite.sqlite3.db.mdb.mp3.mp4.m4a.m4v.mov.avi.mkv.wav.flac.ogg.webm.aac.woff.woff2.ttf.otf.eot.ico.icns.heic.heif.tif.tiff.psd.ai.sketch.fig.xd.avif.raw.cr2.nef.dng.blend.fbx.glb`.split(`.`).map(e=>[e,`binary`]))};function ud(e){let t=e.lastIndexOf(`.`),n=t>0||t===0&&e.length>1?e.slice(t+1).toLowerCase():``,r=cd[n];if(r)return{mime:r};let i=ld[n];return i?{refused:i}:{mime:`text/plain`}}var dd=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]);function fd(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024).toFixed(+(e<10240))} KiB`}function pd(e,t){let n=e.truncated?` · ${sd(t,`đã cắt bớt`,`truncated`)}`:``;return e.kind===`image`?`${sd(t,`Ảnh`,`Image`)} · ${fd(e.sizeBytes)}`:e.kind===`document`?`${sd(t,`Tài liệu`,`Document`)} · ${fd(e.sourceBytes)} → ${fd(e.sizeBytes)} ${sd(t,`văn bản`,`text`)}${n}`:`File · ${fd(e.sizeBytes)}${n}`}function md(e){return e.has(`text/plain`)?``:[...e,...Object.entries(cd).filter(([,t])=>e.has(t)).map(([e])=>`.${e}`)].join(`,`)}function hd(e){return!!(e&&[...e.types].includes(`Files`))}function gd(e,t){switch(e){case`sheet`:return sd(t,`bảng tính chưa đọc trực tiếp được; hãy xuất sang .csv rồi đính kèm.`,`spreadsheets cannot be read directly; export to .csv and attach that.`);case`slides`:return sd(t,`file trình chiếu chưa đọc trực tiếp được; hãy xuất sang .pdf rồi đính kèm.`,`slide decks cannot be read directly; export to .pdf and attach that.`);case`word`:return sd(t,`định dạng này chưa đọc được; hãy lưu sang .docx, .pdf hoặc .txt.`,`this format cannot be read; save it as .docx, .pdf or .txt.`);default:return sd(t,`file nhị phân không gửi vào chat được; hãy để file trong project để agent tự đọc bằng tool.`,`binary files cannot go into the chat; keep it in the project and the agent can use its tools on it.`)}}async function _d(e){let{snapshot:t,locale:n}=e,r=[...e.existing],i=null,a=Math.max(0,4-r.length);e.files.length>a&&(i=sd(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=ud(o.name);if(`refused`in a){i=`${o.name}: ${gd(a.refused,n)}`;continue}let s=a.mime;if(!e.allowed.has(s)){i=`${o.name}: ${s===`application/pdf`?sd(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.`):sd(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 c=s.startsWith(`image/`)||dd.has(s)?Math.min(t.capabilities.limits.maxAttachmentFileBytes,8388608):262144;if(o.size<1||o.size>c||r.reduce((e,t)=>e+t.sourceBytes,0)+o.size>t.capabilities.limits.maxAttachmentTotalBytes){i=`${o.name}: ${dd.has(s)?sd(n,`vượt giới hạn gửi trực tiếp ${fd(c)}. 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 ${fd(c)} 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.`):sd(n,`vượt giới hạn đính kèm (tối đa ${fd(c)}).`,`attachment limit exceeded (max ${fd(c)}).`)}`;continue}let l=new Uint8Array(await o.arrayBuffer()),u=``;for(let e=0;e<l.length;e+=32768)u+=String.fromCharCode(...l.subarray(e,e+32768));let d=await e.stage(await Ec(t,e.messageRequestId,{displayName:o.name,declaredMimeType:s,dataBase64:btoa(u)}));if(d.resultCode!==`staged`||!(`attachment`in d)||!d.attachment){i=`${o.name}: ${$(d.error?.code??d.resultCode,n)}`;continue}r=[...r,d.attachment]}return{attachments:r,status:i}}async function vd(e){let t=await e.stage(Dc(e.snapshot,e.messageRequestId,e.attachmentRef));return t.messageType===`discard-receipt`&&t.resultCode===`discarded`?{discarded:!0,status:null}:{discarded:!1,status:`${sd(e.locale,`Chưa thể bỏ file`,`Unable to remove file`)} · ${$(t.error?.code??t.resultCode,e.locale)}`}}function yd({snapshot:e,events:t,refreshSnapshot:n}){let{locale:r}=ze(),[i,a]=(0,Y.useState)(),[o,s]=(0,Y.useState)(!0),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(()=>`message-request.${crypto.randomUUID()}`),[S,C]=(0,Y.useState)([]),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(!1),O=(0,Y.useRef)(0),k=(0,Y.useMemo)(()=>Gu(t),[t]),A=[...t].reverse().find(e=>[`message.completed`,`message.failed`,`agent-operation.settled`].includes(String(e.kind)))?.eventCursor??null;(0,Y.useEffect)(()=>{let e=new AbortController;return s(!0),a(void 0),$s(null,50,e.signal).then(e=>a(e)).catch(()=>void 0).finally(()=>s(!1)),()=>e.abort()},[e.identity.sessionRef]),(0,Y.useEffect)(()=>{C([]),x(`message-request.${crypto.randomUUID()}`)},[e.identity.sessionRef]),(0,Y.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,Y.useEffect)(()=>{if(!A)return;let e=new AbortController,t=window.setTimeout(()=>{$s(null,50,e.signal).then(e=>a(e)).catch(()=>void 0)},80);return()=>{window.clearTimeout(t),e.abort()}},[A]);let j=async()=>{try{let e=await ec();return h(e),e}catch{return}};(0,Y.useEffect)(()=>{let e=new AbortController;return ec(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[e.identity.sessionRef,e.revision.queueRevision]);let M=async()=>{let e=i?.page.nextBeforeCursor;if(e)try{let t=await $s(e,i.page.limit);a(e=>e?{...e,items:Wu(e.items,t.items),page:t.page}:t)}catch{}},N=(0,Y.useMemo)(()=>i?.state===`ready`?od(i.items):[],[i]),P=e.capabilities.capabilities[`control.chat`],F=P.status===`available`?P.actions:null,I=!!F?.send.available,L=e.capabilities.capabilities[`control.resumeAndContinue`].status===`available`,R=I||L,z=e.capabilities.capabilities.attachments,B=z.status===`available`,V=(0,Y.useMemo)(()=>new Set(z.status===`available`?z.mimeTypes:[]),[z]),ee=(0,Y.useMemo)(()=>md(V),[V]),te=B&&!u&&!w&&S.length<4,ne=e.session.operation.liveness===`running`,re=async()=>{await n?.(),await j()},ie=async t=>{let n=c.trim();if(!(!n||u||(t===`resume-and-continue`?!L:!I))){d(!0),p(null);try{let i=S.length?{messageRequestId:b,attachmentRefs:S.map(e=>e.attachmentRef)}:void 0,a=t===`resume-and-continue`?await sc(await Mc(e,n,i)):await ic(await Tc(e,n,t,i));[`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(l(``),C([]),x(`message-request.${crypto.randomUUID()}`),p(a.resultCode===`dispatch-observed`?W(r,`Đã gửi vào Pi session`,`Sent to the Pi session`):W(r,`Pi đã nhận yêu cầu`,`Pi received the request`))):a.resultCode===`held`?(l(``),p(W(r,`Đã giữ trong hàng đợi`,`Held in the queue`))):a.resultCode===`resumed-not-dispatched`?p(W(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(`${W(r,`Chưa gửi`,`Not sent`)} · ${$(a.resultCode,r)}`),await re()}catch{p(W(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)}}},ae=async t=>{if(!(!t?.length||!B||w)){T(!0),p(null);try{let n=await _d({files:t,snapshot:e,messageRequestId:b,existing:S,allowed:V,locale:r,stage:hc});C(n.attachments),p(n.status)}catch{p(W(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{T(!1)}}},oe=()=>{O.current=0,D(!1)},se=e=>{hd(e.dataTransfer)&&(e.preventDefault(),oe(),te&&ae(e.dataTransfer.files))},ce=async t=>{if(!(u||w)){T(!0),p(null);try{let n=await vd({snapshot:e,messageRequestId:b,attachmentRef:t,locale:r,stage:hc});n.discarded?C(e=>e.filter(e=>e.attachmentRef!==t)):p(n.status)}catch{p(W(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{T(!1)}}},le=async(t,n,i)=>{if(!u){d(!0),p(null);try{let a=await ic(await Oc(e,t,t===`queue.update`?await kc(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),y(``),p($(a.resultCode,r))):p(`${W(r,`Chưa thay đổi`,`Not changed`)} · ${$(a.resultCode,r)}`),await re()}catch{p(W(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 re()}finally{d(!1)}}};return(0,X.jsxs)(`section`,{className:`chat-panel surface`,"aria-labelledby":`chat-heading`,"data-dragging":E||void 0,onDragEnter:e=>{hd(e.dataTransfer)&&(O.current+=1,D(!0))},onDragOver:e=>{hd(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=te?`copy`:`none`)},onDragLeave:e=>{hd(e.dataTransfer)&&(--O.current,O.current<=0&&oe())},onDrop:se,children:[E&&(0,X.jsxs)(`div`,{className:`chat-drop-overlay`,role:`status`,children:[(0,X.jsx)(`strong`,{children:te?W(r,`Thả tài liệu vào đây`,`Drop documents here`):S.length>=4?W(r,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):W(r,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),te&&(0,X.jsx)(`small`,{children:W(r,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),(0,X.jsxs)(`header`,{className:`chat-heading`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(r,`Đúng Pi session hiện tại`,`Exact current Pi session`)}),(0,X.jsx)(`h2`,{id:`chat-heading`,children:`Chat`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`span`,{children:[N.length,` `,W(r,`message gần nhất`,`recent messages`)]}),(0,X.jsx)(`span`,{className:`chat-read-state`,children:W(r,`Streaming trực tiếp`,`Live streaming`)})]})]}),(0,X.jsxs)(`div`,{className:`chat-body`,"aria-live":`polite`,children:[i?.page.hasOlder&&(0,X.jsx)(`button`,{type:`button`,className:`load-older`,onClick:()=>void M(),children:W(r,`Tải message cũ hơn`,`Load older messages`)}),o&&(0,X.jsx)(`p`,{className:`chat-empty`,children:W(r,`Đang tải transcript hiện tại…`,`Loading the current transcript…`)}),!o&&i?.state===`unavailable`&&(0,X.jsxs)(`p`,{className:`chat-empty`,children:[W(r,`Transcript cần đồng bộ lại`,`Transcript needs resync`),` · `,$(i.reasonCode,r)]}),!o&&i?.state===`ready`&&N.length===0&&k.assistants.length===0&&(0,X.jsx)(`p`,{className:`chat-empty`,children:W(r,`Chưa có message trong Pi session này.`,`There are no messages in this Pi session.`)}),N.map(e=>e.role===`tool-result`?(0,X.jsxs)(`article`,{className:`chat-tool-result`,children:[(0,X.jsx)(`strong`,{children:e.toolCalls[0]?.toolName??`Tool`}),(0,X.jsx)(`span`,{children:W(r,`Kết quả chi tiết nằm trong Activity`,`Detailed output is available in Activity`)})]},e.messageRef):(0,X.jsxs)(`article`,{className:`chat-message chat-${e.role}`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:e.role===`user`?W(r,`Anh`,`You`):e.role===`custom`?W(r,`Biên nhận Piagent`,`Piagent receipt`):`Pi`}),(0,X.jsx)(`time`,{children:new Date(e.recordedAt).toLocaleTimeString(r===`vi`?`vi-VN`:`en-US`,{hour:`2-digit`,minute:`2-digit`})})]}),(0,X.jsx)(`p`,{children:e.content.text||(e.content.imageCount?`${e.content.imageCount} ${W(r,`ảnh đính kèm`,`attached images`)}`:W(r,`Message trống`,`Empty message`))}),(e.content.redacted||e.content.truncated)&&(0,X.jsx)(`small`,{children:e.content.redacted?W(r,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`):W(r,`Nội dung đã rút gọn`,`Content truncated`)})]},e.messageRef)),k.assistants.map(e=>(0,X.jsxs)(`article`,{className:`chat-message chat-assistant chat-streaming`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:`Pi`}),(0,X.jsx)(`span`,{className:`stream-indicator`,children:W(r,`Đang trả lời`,`Responding`)})]}),(0,X.jsx)(`p`,{children:e.text||(e.thinking?W(r,`Đang suy nghĩ…`,`Thinking…`):W(r,`Đang chuẩn bị câu trả lời…`,`Preparing a response…`))}),e.truncated&&(0,X.jsx)(`small`,{children:W(r,`Live preview đã đạt giới hạn`,`Live preview limit reached`)})]},e.messageRef)),k.tools.filter(e=>[`started`,`progress`].includes(e.state)).map(e=>(0,X.jsxs)(`article`,{className:`chat-tool-live`,children:[(0,X.jsx)(`span`,{className:`tool-spinner`,"aria-hidden":`true`}),(0,X.jsx)(`strong`,{children:e.toolName}),(0,X.jsx)(`span`,{children:$(e.state,r)})]},e.toolCallId))]}),m?.state===`ready`&&m.items.length>0&&(0,X.jsxs)(`section`,{className:`held-queue`,"aria-label":W(r,`Tin nhắn đang giữ`,`Held messages`),children:[(0,X.jsxs)(`div`,{className:`held-queue-heading`,children:[(0,X.jsx)(`strong`,{children:W(r,`Đang giữ ${m.heldCount} tin`,`${m.heldCount} held messages`)}),m.quarantinedCount>0&&(0,X.jsxs)(`span`,{children:[m.quarantinedCount,` `,W(r,`tin cần kiểm tra`,`need review`)]})]}),(0,X.jsx)(`ol`,{children:m.items.map(e=>(0,X.jsxs)(`li`,{"data-state":e.state,children:[g===e.queueItemRef?(0,X.jsx)(`textarea`,{"aria-label":W(r,`Sửa tin nhắn đang giữ`,`Edit held message`),rows:2,maxLength:65536,value:v,onChange:e=>y(e.target.value)}):(0,X.jsx)(`p`,{children:e.preview}),(0,X.jsx)(`div`,{children:g===e.queueItemRef?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:u||!v.trim(),onClick:()=>void le(`queue.update`,e.queueItemRef,v),children:W(r,`Lưu`,`Save`)}),(0,X.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{_(null),y(``)},children:W(r,`Hủy`,`Cancel`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||!F?.dispatchHeld.available,onClick:()=>void le(`queue.dispatch`,e.queueItemRef),children:W(r,`Gửi`,`Send`)}),(0,X.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||e.redacted||e.truncated||!F?.editHeld.available,title:e.redacted||e.truncated?W(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),y(e.preview)},children:W(r,`Sửa`,`Edit`)}),(0,X.jsx)(`button`,{type:`button`,disabled:u||!F?.deleteHeld.available,onClick:()=>void le(`queue.delete`,e.queueItemRef),children:W(r,`Xóa`,`Delete`)})]})}),(e.redacted||e.truncated||e.state===`quarantined`)&&(0,X.jsx)(`small`,{children:e.state===`quarantined`?W(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?W(r,`Preview đã che dữ liệu nhạy cảm`,`Sensitive data is redacted in the preview`):W(r,`Preview đã rút gọn`,`Preview truncated`)})]},e.queueItemRef))})]}),(0,X.jsxs)(`footer`,{className:`chat-composer-preview`,children:[S.length>0&&(0,X.jsx)(`ul`,{className:`attachment-list`,"aria-label":W(r,`File sẽ gửi cùng message`,`Files to send with the message`),children:S.map(e=>(0,X.jsxs)(`li`,{"data-kind":e.kind,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.displayName}),(0,X.jsx)(`small`,{children:pd(e,r)})]}),(0,X.jsx)(`button`,{type:`button`,disabled:u||w,"aria-label":`${W(r,`Bỏ`,`Remove`)} ${e.displayName}`,onClick:()=>void ce(e.attachmentRef),children:W(r,`Bỏ`,`Remove`)})]},e.attachmentRef))}),(0,X.jsx)(`textarea`,{"aria-label":W(r,`Nội dung chat`,`Chat message`),placeholder:L?W(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…`):I?W(r,`Nhắn vào đúng Pi session này…`,`Message this exact Pi session…`):W(r,`Chat control chưa khả dụng.`,`Chat control is unavailable.`),disabled:!R||u,maxLength:65536,rows:2,value:c,onChange:e=>l(e.target.value),onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),te&&ae(e.clipboardData.files))}}),(0,X.jsxs)(`div`,{className:`composer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:!R||u||!c.trim(),onClick:()=>void ie(L?`resume-and-continue`:ne?`follow-up`:`new-operation`),children:u?W(r,`Đang gửi…`,`Sending…`):L?W(r,`Tiếp tục & gửi`,`Resume & send`):ne?W(r,`Gửi sau`,`Send next`):W(r,`Gửi`,`Send`)}),(0,X.jsx)(`button`,{type:`button`,disabled:!I||u||!c.trim()||S.length>0||!F?.hold.available,title:S.length?W(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 ie(`hold`),children:W(r,`Giữ lại`,`Hold`)}),ne&&(0,X.jsx)(`button`,{type:`button`,className:`interrupt-send`,disabled:!I||u||!c.trim()||!F?.interruptAndSend.available,onClick:()=>void ie(`steer`),children:W(r,`Ngắt & gửi`,`Interrupt & send`)})]}),(0,X.jsxs)(`label`,{className:`attachment-picker ${te?``:`disabled`}`,title:W(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,X.jsx)(`input`,{type:`file`,multiple:!0,disabled:!te,accept:ee||void 0,onChange:e=>{ae(e.target.files),e.currentTarget.value=``}}),w?W(r,`Đang đọc tài liệu…`,`Reading documents…`):`${W(r,`Đính kèm hoặc kéo thả`,`Attach or drop`)} (${S.length}/4)`]}),f&&(0,X.jsx)(`small`,{role:`status`,children:f})]})]})}function bd({snapshot:e,refreshSnapshot:t}){let{locale:n}=ze(),[r,i]=(0,Y.useState)(),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(0),g=(0,Y.useRef)({revision:0,modelDirty:!1,thinkingDirty:!1}),_=e.capabilities.capabilities[`control.sessionOptions`],v=_.status===`available`?_.actions:null,y=async e=>{let t=++h.current,n=g.current.revision;try{let r=await tc(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,Y.useEffect)(()=>{let e=new AbortController;return y(e.signal),()=>e.abort()},[e.identity.sessionRef,e.revision.sessionOptionRevision]);let b=(0,Y.useMemo)(()=>r?.models.find(e=>e.modelRef===r.activeModelRef),[r]),x=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 ac(await Ac(e,o,c));m(r.resultCode===`changed`?W(n,`Đã cập nhật trong Pi và mặc định người dùng`,`Updated in Pi and user defaults`):r.resultCode===`unchanged`?W(n,`Giá trị này đang được dùng`,`This value is already active`):r.resultCode===`effect-unknown`?W(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`):`${W(n,`Chưa thay đổi`,`Not changed`)} · ${$(r.resultCode,n)}`),u(!1),g.current.revision+=1,i===`model`?g.current.modelDirty=!1:g.current.thinkingDirty=!1,await t?.(),await y()}catch{m(W(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,X.jsxs)(`section`,{className:`session-options surface`,"aria-labelledby":`session-options-title`,children:[(0,X.jsxs)(`div`,{className:`session-options-copy`,children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Model & thinking`}),(0,X.jsx)(`h2`,{id:`session-options-title`,children:W(n,`Thiết lập cho Pi session`,`Pi session settings`)}),(0,X.jsx)(`p`,{children:W(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,X.jsxs)(`div`,{className:`session-options-controls`,children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Model`}),(0,X.jsx)(`select`,{"aria-label":W(n,`Chọn model`,`Select model`),value:a,disabled:d!==null||!v?.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,X.jsxs)(`option`,{value:e.modelRef,children:[e.displayName,` · `,e.provider]},e.modelRef))})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Thinking`}),(0,X.jsx)(`select`,{"aria-label":W(n,`Chọn thinking`,`Select thinking`),value:s,disabled:d!==null||!v?.setThinking.available,onChange:e=>{g.current.revision+=1,g.current.thinkingDirty=!0,c(e.target.value),u(!1),m(null)},children:(b?.supportedThinkingLevels??[]).map(e=>(0,X.jsx)(`option`,{value:e,children:$(e,n)},e))})]}),(0,X.jsxs)(`label`,{className:`effect-ack`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:l,disabled:d!==null||!v,onChange:e=>u(e.target.checked)}),(0,X.jsx)(`span`,{children:W(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,X.jsxs)(`div`,{className:`session-option-actions`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!v?.setModel.available||a===r.activeModelRef,onClick:()=>void x(`model`),children:d===`model`?W(n,`Đang đổi…`,`Changing…`):W(n,`Đổi model`,`Change model`)}),(0,X.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!v?.setThinking.available||s===r.activeThinkingLevel,onClick:()=>void x(`thinking`),children:d===`thinking`?W(n,`Đang đổi…`,`Changing…`):W(n,`Đổi thinking`,`Change thinking`)})]}),p&&(0,X.jsx)(`small`,{role:`status`,children:p}),!v?.setModel.available&&(0,X.jsxs)(`small`,{children:[W(n,`Đang khóa thay đổi`,`Changes locked`),` · `,$(v?.setModel.reasonCode??(_.status===`unavailable`?_.reason?.code:`unavailable`),n)]})]}):(0,X.jsxs)(`div`,{className:`session-options-unavailable`,children:[(0,X.jsx)(`strong`,{children:W(n,`Catalog model chưa sẵn sàng`,`Model catalog unavailable`)}),(0,X.jsx)(`span`,{children:$(r?.reasonCode??`authenticated-model-catalog-unavailable`,n)})]})]})}var xd=(e,t,n)=>e===`vi`?t:n,Sd={"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`]},Cd={"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`],"host-command-once":[`Đúng một lệnh, chạy trên máy bạn (ngoài sandbox)`,`This one command, on your machine (outside the sandbox)`],"start-docker-once":[`Mở Docker trên máy`,`Start Docker on this machine`],"one-external-action":[`Đúng một hành động`,`This one action`]},wd={"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.`,``],"Run this exact command once on this machine, outside the sandbox, as you: it can read and change your files and use your sign-ins.":[`Chạy đúng lệnh này một lần trên máy bạn, ngoài sandbox, bằng quyền của bạn: lệnh đọc/sửa được file và dùng được tài khoản đã đăng nhập trên máy.`,``],"Docker is not started; the agent is told you declined.":[`Không mở Docker; agent được báo là bạn đã từ chối.`,``]},Td=(e,t,n)=>{let r=e[t];return r?xd(n,r[0],r[1]||t):null};function Ed(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 Dd=(e,t)=>Td(Sd,e.kind,t)??$(e.kind,t),Od=(e,t)=>Td(Cd,e.requestedScope,t)??$(e.requestedScope,t);function kd(e,t){let n=t===`vi`?/^Start (.+) on this machine; it keeps running after the conversation\.$/.exec(e):null;return n?`Mở ${n[1]} trên máy; nó vẫn chạy sau cuộc trò chuyện.`:Td(wd,e,t)??e}function Ad(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 jd({state:e,setState:t,refreshSnapshot:n,locale:r,asker:i}){let a=e.request;if(!a)return(0,X.jsx)(`article`,{className:`approval-card`,children:(0,X.jsx)(`p`,{children:e.error??W(r,`Đang tải yêu cầu phê duyệt…`,`Loading approval request…`)})});let o=a.action,s=Math.max(0,Math.ceil((Date.parse(a.expiresAt)-Date.now())/1e3)),c=async e=>{t({request:a,deciding:e});try{await rc(Ad(a,e)),await n?.()}catch{t({request:a,error:W(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,X.jsxs)(`article`,{className:`approval-card risk-${o.riskClass}`,"aria-labelledby":`approval-${a.approvalRef}`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:i?W(r,`${i} cần bạn duyệt`,`${i} needs your approval`):W(r,`Cần phê duyệt`,`Approval required`)}),(0,X.jsx)(`h2`,{id:`approval-${a.approvalRef}`,children:o.toolName})]}),(0,X.jsx)(`span`,{className:`approval-risk`,children:$(o.riskClass,r)})]}),(0,X.jsx)(`p`,{className:`approval-reason`,children:Ed(o.reason,r)}),o.commandPreview&&(0,X.jsx)(`pre`,{className:`approval-preview`,children:(0,X.jsx)(`code`,{children:o.commandPreview})}),!o.commandPreview&&o.parameterPreview&&o.parameterPreview!==`No additional parameters`&&(0,X.jsx)(`p`,{className:`approval-preview`,children:o.parameterPreview}),(0,X.jsxs)(`dl`,{className:`approval-facts`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(r,`Hành động`,`Action`)}),(0,X.jsx)(`dd`,{children:Dd(o,r)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(r,`Phạm vi`,`Scope`)}),(0,X.jsx)(`dd`,{children:Od(o,r)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(r,`Thư mục`,`Directory`)}),(0,X.jsx)(`dd`,{children:o.cwdDisplay??W(r,`Đã ẩn`,`Hidden`)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(r,`Hết hạn`,`Expires`)}),(0,X.jsxs)(`dd`,{children:[s,`s`]})]})]}),o.targetPaths.length>0&&(0,X.jsxs)(`div`,{className:`approval-targets`,children:[(0,X.jsx)(`strong`,{children:W(r,`Đích tác động`,`Targets`)}),(0,X.jsx)(`ul`,{children:o.targetPaths.map(e=>(0,X.jsx)(`li`,{children:e===`.`?W(r,`Cả thư mục project`,`The whole project folder`):e},e))})]}),(0,X.jsxs)(`div`,{className:`approval-consequences`,children:[(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`strong`,{children:W(r,`Nếu cho phép:`,`If allowed:`)}),` `,kd(o.consequences.allow,r)]}),(0,X.jsxs)(`p`,{children:[(0,X.jsx)(`strong`,{children:W(r,`Nếu từ chối:`,`If denied:`)}),` `,kd(o.consequences.deny,r)]})]}),e.error&&(0,X.jsx)(`p`,{className:`form-error`,role:`alert`,children:e.error}),(0,X.jsxs)(`footer`,{children:[(0,X.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!e.deciding,onClick:()=>void c(`deny`),children:W(r,`Từ chối`,`Deny`)}),(0,X.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:!!e.deciding,onClick:()=>void c(`allow`),children:e.deciding===`allow`?W(r,`Đang kiểm tra lại…`,`Rechecking…`):W(r,`Cho phép đúng 1 lần`,`Allow once`)})]})]})}function Md(e,t,n){let r=(0,Y.useMemo)(()=>e,[e.join(`\0`)]),[i,a]=(0,Y.useState)({});return(0,Y.useEffect)(()=>{let e=new AbortController;for(let i of r)(t?Ds(t,i,e.signal):nc(i,e.signal)).then(e=>a(t=>({...t,[i]:{request:e}})),()=>a(e=>({...e,[i]:{error:W(n,`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()},[n,t,r]),{refs:r,states:i,set:(e,t)=>a(n=>({...n,[e]:t}))}}function Nd({approvalRefs:e,sessionRef:t,refreshSnapshot:n}){let{locale:r}=ze(),{refs:i,states:a,set:o}=Md(e,t,r);return i.length===0?null:(0,X.jsx)(`section`,{className:`approval-stack`,"aria-label":W(r,`Yêu cầu phê duyệt đang chờ`,`Pending approval requests`),"aria-live":`polite`,children:i.map(e=>(0,X.jsx)(jd,{state:a[e]??{},setState:t=>o(e,t),refreshSnapshot:n,locale:r},e))})}function Pd({snapshot:e,refreshSnapshot:t}){let n=(0,Y.useMemo)(()=>e.approvals.pending.map(e=>e.approvalRef),[e.approvals.pending]);return(0,X.jsx)(Nd,{approvalRefs:n,refreshSnapshot:t})}var Fd={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.`},Id={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 Ld(e,t){return(t===`vi`?Fd:Id)[e.resultCode]??(e.error?.message||`${W(t,`Chưa thực hiện`,`Not executed`)} · ${$(e.resultCode,t)}`)}function Rd({snapshot:e,refreshSnapshot:t}){let{locale:n}=ze(),r=e.capabilities.capabilities[`control.lifecycle`],[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.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,Y.useEffect)(()=>{o?.resultCode===`pause-requested`&&e.session.controlState===`paused`&&s({action:`lifecycle.pause`,resultCode:`paused`,text:(n===`vi`?Fd:Id).paused}),o?.resultCode===`stop-requested`&&e.session.operation.liveness===`idle`&&s({action:`lifecycle.stop`,resultCode:`stopped`,text:(n===`vi`?Fd:Id).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 oc(await jc(e,r));s({action:r,resultCode:i.resultCode,text:Ld(i,n)}),await t?.()}catch{s({action:r,resultCode:`request-failed`,text:W(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,X.jsxs)(`section`,{className:`lifecycle-panel surface`,"aria-labelledby":`lifecycle-title`,children:[(0,X.jsxs)(`div`,{className:`lifecycle-copy`,children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(n,`Điều khiển task`,`Task controls`)}),(0,X.jsx)(`h2`,{id:`lifecycle-title`,children:`Stop, pause & resume`}),(0,X.jsx)(`p`,{children:W(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,X.jsxs)(`div`,{className:`lifecycle-state`,children:[(0,X.jsx)(`span`,{children:W(n,`Trạng thái`,`Status`)}),(0,X.jsx)(`strong`,{children:$(e.session.controlState,n)}),(0,X.jsxs)(`small`,{children:[`Pi: `,$(e.session.operation.liveness,n),` · phase: `,$(l,n)]})]}),(0,X.jsxs)(`div`,{className:`lifecycle-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:i!==null||!d,onClick:()=>void m(`lifecycle.stop`),title:d?void 0:$(u?.reasonCode??`no-current-operation`,n),children:i===`lifecycle.stop`?W(n,`Đang dừng…`,`Stopping…`):W(n,`Dừng lượt hiện tại`,`Stop current turn`)}),(0,X.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:i!==null||!f,onClick:()=>void m(`lifecycle.pause`),title:!f&&c?$(r.actions.pause.reasonCode,n):void 0,children:i===`lifecycle.pause`?W(n,`Đang yêu cầu…`,`Requesting…`):W(n,`Tạm dừng task`,`Pause task`)}),(0,X.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:i!==null||!p,onClick:()=>void m(`lifecycle.resume`),title:!p&&c?$(r.actions.resume.reasonCode,n):void 0,children:i===`lifecycle.resume`?W(n,`Đang mở lại…`,`Resuming…`):W(n,`Tiếp tục task`,`Resume task`)})]}),o&&(0,X.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,X.jsxs)(`p`,{className:`lifecycle-result result-warning`,children:[W(n,`Điều khiển chưa sẵn sàng`,`Controls unavailable`),` · `,$(r.reason?.code,n)]})]})}function zd(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 Bd({value:e,locale:t}){return(0,X.jsxs)(`span`,{className:`status-pill tone-${Ul(e)}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),$(e,t)]})}function Vd({snapshot:e}){let{locale:t}=ze(),[n,r]=(0,Y.useState)(),[i,a]=(0,Y.useState)(`loading`),[o,s]=(0,Y.useState)(`all`),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(),[f,p]=(0,Y.useState)(`idle`),[m,h]=(0,Y.useState)(),[g,_]=(0,Y.useState)(`idle`),[v,y]=(0,Y.useState)(),[b,x]=(0,Y.useState)(`idle`),[S,C]=(0,Y.useState)(),[w,T]=(0,Y.useState)(`idle`);(0,Y.useEffect)(()=>{let e=new AbortController;return a(`loading`),Ks(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 E=(0,Y.useMemo)(()=>(n?.runs??[]).filter(e=>o===`all`||o===`current`&&e.isCurrentSession||o===`terminal`&&e.terminal),[n,o]);return(0,Y.useEffect)(()=>{if(!c){d(void 0),p(`idle`);return}let e=new AbortController;return p(`loading`),qs(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,Y.useEffect)(()=>{if(!c){y(void 0),x(`idle`);return}let e=new AbortController;return x(`loading`),Ys(c,e.signal).then(t=>{e.signal.aborted||(y(t),x(`ready`))}).catch(()=>{e.signal.aborted||x(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,Y.useEffect)(()=>{if(!c){h(void 0),_(`idle`);return}let e=new AbortController;return _(`loading`),Js(c,e.signal).then(t=>{e.signal.aborted||(h(t),_(`ready`))}).catch(()=>{e.signal.aborted||_(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,Y.useEffect)(()=>{if(!c){C(void 0),T(`idle`);return}let e=new AbortController;return T(`loading`),Xs(c,e.signal).then(t=>{e.signal.aborted||(C(t),T(`ready`))}).catch(()=>{e.signal.aborted||T(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,X.jsxs)(`section`,{className:`task-run-index surface`,"aria-labelledby":`task-run-index-title`,children:[(0,X.jsxs)(`header`,{className:`source-heading`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Long-task dashboard`}),(0,X.jsx)(`h2`,{id:`task-run-index-title`,children:W(t,`Task và các lần chạy gần đây`,`Tasks and recent runs`)})]}),(0,X.jsxs)(`span`,{children:[n?.page.total??0,` `,W(t,`run từ local state`,`runs from local state`)]})]}),(0,X.jsx)(`div`,{className:`task-index-controls`,role:`group`,"aria-label":W(t,`Lọc task run`,`Filter task runs`),children:[[`all`,W(t,`Tất cả`,`All`)],[`current`,W(t,`Session này`,`This session`)],[`terminal`,W(t,`Đã kết thúc`,`Finished`)]].map(([e,t])=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>s(e),children:t},e))}),i===`loading`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Đang đọc task state bền vững…`,`Reading durable task state…`)}),(i===`error`||n?.state===`unavailable`)&&(0,X.jsx)(`p`,{className:`task-index-empty error-state`,children:W(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,X.jsxs)(`div`,{className:`task-run-list`,children:[E.map(e=>(0,X.jsxs)(`article`,{className:`task-run-card`,"data-active":e.isActive,"data-selected":e.runRef===c,children:[(0,X.jsxs)(`div`,{className:`task-run-main`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:e.summary||e.taskId}),e.isActive&&(0,X.jsx)(`span`,{className:`active-run-tag`,children:W(t,`Đang hoạt động`,`Active`)})]}),(0,X.jsxs)(`small`,{children:[e.taskId,` · `,W(t,`lần`,`attempt`),` `,e.attempt,`/`,e.maxAttempts,` · `,W(t,`cập nhật`,`updated`),` `,zd(e.updatedAt,t)]})]}),(0,X.jsxs)(`div`,{className:`task-run-meta`,children:[(0,X.jsx)(Bd,{value:e.outcome,locale:t}),(0,X.jsx)(`span`,{children:e.progress.total?`${e.progress.completed}/${e.progress.total} ${W(t,`bước`,`steps`)}`:W(t,`Chưa có work plan`,`No work plan`)}),(0,X.jsx)(`span`,{children:e.sessionLabel??(e.isCurrentSession?W(t,`Session hiện tại`,`Current session`):W(t,`Session khác`,`Other session`))}),(0,X.jsx)(`button`,{type:`button`,"aria-pressed":e.runRef===c,onClick:()=>l(e.runRef),children:W(t,`Xem timeline`,`View timeline`)})]})]},e.runRef)),E.length===0&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Không có task run trong bộ lọc này.`,`No task runs match this filter.`)})]}),n?.warnings.map(e=>(0,X.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n?.page.truncated&&(0,X.jsxs)(`p`,{className:`task-index-warning`,children:[W(t,`Danh sách đã rút gọn;`,`The list is truncated;`),` `,n.page.total-n.page.returned,` `,W(t,`run cũ chưa hiển thị.`,`older runs are not shown.`)]}),(0,X.jsxs)(`section`,{className:`task-timeline`,"aria-labelledby":`task-timeline-title`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Recovery timeline`}),(0,X.jsx)(`h3`,{id:`task-timeline-title`,children:W(t,`Crash, resume, pause và checkpoint`,`Crash, resume, pause, and checkpoints`)})]}),u?.state===`ready`&&(0,X.jsx)(Bd,{value:u.continuity.recoveryDecision,locale:t})]}),f===`idle`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Chọn một run để xem timeline.`,`Select a run to view its timeline.`)}),f===`loading`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Đang xác minh chuỗi Task Journal…`,`Verifying the Task Journal chain…`)}),(f===`error`||u?.state===`unavailable`)&&(0,X.jsx)(`p`,{className:`task-index-empty error-state`,children:W(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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`timeline-continuity`,children:[(0,X.jsxs)(`span`,{children:[`Crash evidence: `,(0,X.jsx)(`strong`,{children:$(u.continuity.crashEvidence,t)})]}),(0,X.jsxs)(`span`,{children:[`Recovery: `,(0,X.jsx)(`strong`,{children:$(u.continuity.recoveryDecision,t)})]})]}),(0,X.jsx)(`ol`,{className:`timeline-events`,children:u.events.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`timeline-dot tone-${Ul(e.state)}`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:e.title}),(0,X.jsxs)(`small`,{children:[`#`,e.sequence,` · `,zd(e.recordedAt,t)]}),e.detail&&(0,X.jsx)(`p`,{children:e.detail})]}),(0,X.jsx)(Bd,{value:e.state,locale:t})]},e.eventRef))}),u.events.length===0&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(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,X.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,X.jsxs)(`section`,{className:`task-timeline recovery-history`,"aria-labelledby":`recovery-history-title`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Compaction & recovery`}),(0,X.jsx)(`h3`,{id:`recovery-history-title`,children:W(t,`Lịch sử rút gọn và phục hồi`,`Compaction and recovery history`)})]}),m?.state===`ready`&&(0,X.jsx)(Bd,{value:m.completeness,locale:t})]}),g===`idle`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Chọn một run để xem lịch sử rút gọn.`,`Select a run to view compaction history.`)}),g===`loading`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Đang đọc metadata compaction an toàn…`,`Reading safe compaction metadata…`)}),(g===`error`||m?.state===`unavailable`)&&(0,X.jsx)(`p`,{className:`task-index-empty error-state`,children:W(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,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`timeline-continuity recovery-summary`,children:[(0,X.jsxs)(`span`,{children:[`Context compact: `,(0,X.jsx)(`strong`,{children:m.summary.contextCompactions})]}),(0,X.jsxs)(`span`,{children:[`Tool result: `,(0,X.jsx)(`strong`,{children:m.summary.toolResultCompactions})]}),(0,X.jsxs)(`span`,{children:[`Recovery: `,(0,X.jsx)(`strong`,{children:$(m.recovery.decision,t)})]}),(0,X.jsxs)(`span`,{children:[`Verifier: `,(0,X.jsx)(`strong`,{children:$(m.recovery.verifierState,t)})]})]}),(0,X.jsx)(`p`,{className:`retained-content-note`,children:W(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,X.jsx)(`ol`,{className:`timeline-events`,children:m.events.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`timeline-dot tone-${Ul(e.kind)}`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:e.title}),(0,X.jsxs)(`small`,{children:[`#`,e.sequence,` · `,zd(e.recordedAt,t)]}),e.kind===`tool-result-compaction`&&(0,X.jsxs)(`p`,{children:[e.toolName,` · `,e.originalLines??`?`,` `,W(t,`dòng`,`lines`),` · `,e.captureCount,` capture`]}),e.detail&&(0,X.jsx)(`p`,{children:e.detail})]}),(0,X.jsx)(Bd,{value:`observed`,locale:t})]},e.eventRef))}),m.events.length===0&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Run này chưa có metadata compaction đã quan sát.`,`This run has no observed compaction metadata.`)})]}),m?.warnings.map(e=>(0,X.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,X.jsxs)(`section`,{className:`task-timeline handoff-history`,"aria-labelledby":`handoff-history-title`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Handoff`}),(0,X.jsx)(`h3`,{id:`handoff-history-title`,children:W(t,`Bàn giao và việc cần làm tiếp theo`,`Handoff and next work`)})]}),v?.state===`ready`&&(0,X.jsx)(Bd,{value:v.completeness,locale:t})]}),b===`idle`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Chọn một run để xem handoff.`,`Select a run to view its handoff.`)}),b===`loading`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Đang xác minh handoff và next action…`,`Verifying the handoff and next action…`)}),(b===`error`||v?.state===`unavailable`)&&(0,X.jsx)(`p`,{className:`task-index-empty error-state`,children:W(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.`)}),b===`ready`&&v?.state===`ready`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`next-action-card`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:W(t,`Việc tiếp theo`,`Next work`)}),(0,X.jsx)(`strong`,{children:$(v.nextAction.action,t)})]}),(0,X.jsx)(`p`,{children:v.nextAction.reason}),(0,X.jsxs)(`small`,{children:[v.nextAction.exactCommandCount,` verifier command · `,W(t,`chỉ xem, không tự chạy`,`read-only, never auto-run`)]})]}),v.current&&(0,X.jsxs)(`div`,{className:`timeline-continuity handoff-summary`,children:[(0,X.jsxs)(`span`,{children:[`Outcome: `,(0,X.jsx)(`strong`,{children:$(v.current.taskOutcome,t)})]}),(0,X.jsxs)(`span`,{children:[`Gate: `,(0,X.jsx)(`strong`,{children:$(v.current.gateDecision,t)})]}),(0,X.jsxs)(`span`,{children:[`Authority: `,(0,X.jsx)(`strong`,{children:$(v.current.requiredAuthority,t)})]}),(0,X.jsxs)(`span`,{children:[`Tree evidence: `,(0,X.jsx)(`strong`,{children:v.current.treeEvidenceCurrent?`current`:`not current`})]})]}),(0,X.jsx)(`ol`,{className:`timeline-events`,children:v.events.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`timeline-dot tone-${Ul(e.completionApproved?`completed`:`handoff`)}`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:W(t,`Handoff projection đã được ghi`,`Handoff projection recorded`)}),(0,X.jsxs)(`small`,{children:[`#`,e.sequence,` · `,zd(e.recordedAt,t)]}),(0,X.jsxs)(`p`,{children:[e.phase??`unknown`,` · `,$(e.projectedAction,t)]})]}),(0,X.jsx)(Bd,{value:e.completionApproved?`completed`:`observed`,locale:t})]},e.eventRef))}),!v.current&&v.events.length===0&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Run này chưa có handoff đã quan sát.`,`This run has no observed handoff.`)})]}),v?.warnings.map(e=>(0,X.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,X.jsxs)(`section`,{className:`task-timeline subagent-tree`,"aria-labelledby":`subagent-tree-title`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Helper / subagent tree`}),(0,X.jsx)(`h3`,{id:`subagent-tree-title`,children:W(t,`Quyền sở hữu và vòng đời helper`,`Helper ownership and lifecycle`)})]}),S?.state===`ready`&&(0,X.jsx)(Bd,{value:S.evidenceState,locale:t})]}),w===`idle`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Chọn một run để xem helper/subagent.`,`Select a run to view helpers and subagents.`)}),w===`loading`&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Đang xác minh helper ledger bền vững…`,`Verifying the durable helper ledger…`)}),(w===`error`||S?.state===`unavailable`)&&(0,X.jsx)(`p`,{className:`task-index-empty error-state`,children:W(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.`)}),w===`ready`&&S?.state===`ready`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`next-action-card`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:W(t,`Quyết định điều phối`,`Delegation decision`)}),(0,X.jsx)(`strong`,{children:S.delegation.action===`dispatch`?W(t,`Gửi 1 helper chỉ đọc`,`Dispatch one read-only helper`):W(t,`Parent tự làm`,`Parent works directly`)})]}),(0,X.jsx)(`p`,{children:S.delegation.reasonCodes.map(e=>$(e,t)).join(` · `)}),(0,X.jsxs)(`small`,{children:[W(t,`Tiết kiệm token dự kiến`,`Projected net token saving`),`: `,S.delegation.projectedNetSavingsRatio===null?W(t,`chưa được chứng minh`,`not proven`):`${Math.round(S.delegation.projectedNetSavingsRatio*100)}%`,` · `,W(t,`ngưỡng`,`threshold`),` `,Math.round(S.delegation.minimumRequiredNetSavingsRatio*100),`% · `,W(t,`tối đa 1 helper, 0 retry, 0 writer`,`max 1 helper, 0 retries, 0 writers`)]})]}),(0,X.jsxs)(`div`,{className:`timeline-continuity subagent-summary`,children:[(0,X.jsxs)(`span`,{children:[W(t,`Tổng helper`,`Total helpers`),`: `,(0,X.jsx)(`strong`,{children:S.summary.total})]}),(0,X.jsxs)(`span`,{children:[W(t,`Đang chạy`,`Running`),`: `,(0,X.jsx)(`strong`,{children:S.summary.active})]}),(0,X.jsxs)(`span`,{children:[W(t,`Kết quả stale`,`Stale results`),`: `,(0,X.jsx)(`strong`,{children:S.summary.staleResults})]}),(0,X.jsxs)(`span`,{children:[W(t,`Writer hiện tại`,`Current writer`),`: `,(0,X.jsx)(`strong`,{children:$(S.writer.state,t)})]})]}),(0,X.jsx)(`p`,{className:`retained-content-note`,children:W(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,X.jsx)(`ol`,{className:`timeline-events`,children:S.children.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`timeline-dot tone-${Ul(e.lifecycleState)}`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`strong`,{children:[$(e.role,t),` · `,$(e.authority,t)]}),(0,X.jsxs)(`small`,{children:[zd(e.reservedAt,t),` → `,e.completedAt?zd(e.completedAt,t):W(t,`đang giữ lease`,`lease active`)]}),(0,X.jsxs)(`p`,{children:[e.result.disposition?$(e.result.disposition,t):W(t,`Chưa có result evidence`,`No result evidence`),e.result.calls===null?``:` · ${e.result.calls} calls · ${e.result.tokens??0} tokens`]})]}),(0,X.jsx)(Bd,{value:e.result.state===`not-recorded`?e.lifecycleState:e.result.state,locale:t})]},e.nodeRef))}),S.children.length===0&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Không có lifecycle helper chi tiết cho run này.`,`No detailed helper lifecycle is available for this run.`)}),(0,X.jsx)(`p`,{className:`retained-content-note`,children:W(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.`)})]}),S?.warnings.map(e=>(0,X.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]})]})}function Hd(e,t){if(!e)return W(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 Ud({value:e,locale:t}){return(0,X.jsxs)(`span`,{className:`status-pill tone-${Ul(e)}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),$(e,t)]})}function Wd({snapshot:e}){let{locale:t}=ze(),[n,r]=(0,Y.useState)(),[i,a]=(0,Y.useState)(`loading`),o=(0,Y.useRef)(null),s=(0,Y.useCallback)(()=>{o.current?.abort();let e=new AbortController;o.current=e,a(`loading`),Zs(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`))}).catch(()=>{e.signal.aborted||a(`error`)})},[]);return(0,Y.useEffect)(()=>(s(),()=>o.current?.abort()),[s,e.identity.projectRef,e.identity.runtimeInstanceId]),(0,X.jsxs)(`section`,{className:`release-monitor surface`,"aria-labelledby":`release-monitor-title`,children:[(0,X.jsxs)(`header`,{className:`source-heading`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Benchmark & release`}),(0,X.jsx)(`h2`,{id:`release-monitor-title`,children:W(t,`Theo dõi chất lượng và mức sẵn sàng phát hành`,`Quality and release readiness`)})]}),(0,X.jsx)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,children:i===`loading`?W(t,`Đang đọc…`,`Loading…`):W(t,`Làm mới`,`Refresh`)})]}),(0,X.jsx)(`p`,{className:`retained-content-note`,children:W(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,X.jsx)(`p`,{className:`task-index-empty error-state`,children:W(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,X.jsx)(`p`,{className:`task-index-empty`,children:W(t,`Đang xác minh report, manifest và ledger…`,`Verifying reports, manifests, and ledgers…`)}),n&&(0,X.jsxs)(`div`,{className:`release-monitor-grid`,children:[(0,X.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`benchmark-monitor-title`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Benchmark runs`}),(0,X.jsx)(`h3`,{id:`benchmark-monitor-title`,children:W(t,`Các lần đo gần đây`,`Recent runs`)})]}),(0,X.jsx)(Ud,{value:n.benchmark.state,locale:t})]}),n.benchmark.runs.map(e=>(0,X.jsxs)(`article`,{className:`benchmark-run-card`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`strong`,{children:e.suiteId}),(0,X.jsx)(Ud,{value:e.lifecycle,locale:t})]}),(0,X.jsxs)(`small`,{children:[Hd(e.updatedAt,t),` · `,e.completedRuns,`/`,e.expectedRuns,` `,W(t,`lượt`,`runs`),` · `,W(t,`nguồn`,`source`),` `,$(e.sourceState,t)]}),(0,X.jsxs)(`div`,{className:`benchmark-run-facts`,children:[(0,X.jsxs)(`span`,{children:[`Gate `,(0,X.jsx)(`b`,{children:$(e.releaseGate,t)})]}),(0,X.jsxs)(`span`,{children:[W(t,`Điểm`,`Score`),` `,(0,X.jsx)(`b`,{children:e.scores.overall??`—`})]}),(0,X.jsxs)(`span`,{children:[`Claim `,(0,X.jsx)(`b`,{children:$(e.claimTier,t)})]})]})]},e.runRef)),n.benchmark.runs.length===0&&(0,X.jsx)(`p`,{className:`task-index-empty`,children:W(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,X.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n.benchmark.page.truncated&&(0,X.jsx)(`p`,{className:`task-index-warning`,children:W(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,X.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`release-readiness-title`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Release readiness`}),(0,X.jsx)(`h3`,{id:`release-readiness-title`,children:W(t,`RC hiện tại`,`Current RC`)})]}),(0,X.jsx)(Ud,{value:n.release.state,locale:t})]}),(0,X.jsxs)(`dl`,{className:`release-readiness-facts`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Local safe gate`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(Ud,{value:n.release.localSafeGate,locale:t})})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`RC assembly`}),(0,X.jsx)(`dd`,{children:$(n.release.rcAssembly,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Beta`}),(0,X.jsx)(`dd`,{children:$(n.release.beta,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`GA`}),(0,X.jsx)(`dd`,{children:$(n.release.gaRelease,t)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:W(t,`Báo cáo`,`Report`)}),(0,X.jsx)(`dd`,{children:Hd(n.release.generatedAt,t)})]})]}),n.release.sourceState===`stale`&&(0,X.jsx)(`p`,{className:`task-index-warning`,children:W(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,X.jsxs)(`div`,{className:`release-blockers`,children:[(0,X.jsxs)(`strong`,{children:[n.release.blockerCount,` blocker`]}),(0,X.jsx)(`ul`,{children:n.release.blockers.map((e,t)=>(0,X.jsx)(`li`,{children:e},`${t}-${e}`))})]}),(0,X.jsx)(`p`,{className:`retained-content-note`,children:W(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 Gd=264,Kd={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 qd({value:e,text:t,locale:n=`vi`}){return(0,X.jsxs)(`span`,{className:`status-pill tone-${Ul(e)}`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),t??$(e,n)]})}function Jd({locale:e}){return(0,X.jsxs)(`section`,{className:`task-empty surface`,"aria-labelledby":`task-title`,children:[(0,X.jsx)(`div`,{className:`empty-mark`,"aria-hidden":`true`,children:`π`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,X.jsx)(`h2`,{id:`task-title`,children:W(e,`Chưa có task đang chạy`,`No active task`)}),(0,X.jsx)(`p`,{children:W(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 Yd({snapshot:e,locale:t}){let n=e.task;if(!n)return(0,X.jsx)(Jd,{locale:t});let r=Yl(e,t);return(0,X.jsxs)(`section`,{className:`task-dashboard surface`,"aria-labelledby":`task-title`,children:[(0,X.jsxs)(`header`,{className:`task-heading`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(t,`Task hiện tại`,`Current task`)}),(0,X.jsx)(`h2`,{id:`task-title`,children:n.summary}),(0,X.jsxs)(`div`,{className:`task-meta`,children:[(0,X.jsx)(qd,{value:n.outcome,locale:t}),(0,X.jsx)(`span`,{children:$(n.changeMode,t)}),(0,X.jsx)(`span`,{children:$(n.riskLane,t)})]})]}),(0,X.jsxs)(`div`,{className:`progress-number`,"aria-label":`${W(t,`Tiến độ`,`Progress`)} ${r.percent}%`,children:[(0,X.jsxs)(`strong`,{children:[r.percent,`%`]}),(0,X.jsx)(`span`,{children:r.text})]})]}),(0,X.jsx)(`div`,{className:`progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.percent,"aria-label":W(t,`Tiến độ tiêu chí`,`Criteria progress`),children:(0,X.jsx)(`span`,{style:{width:`${r.percent}%`}})}),n.blocker&&(0,X.jsxs)(`div`,{className:`blocker`,role:`status`,children:[(0,X.jsx)(`span`,{children:`Blocker`}),(0,X.jsx)(`p`,{children:n.blocker})]}),(0,X.jsxs)(`div`,{className:`criteria-heading`,children:[(0,X.jsx)(`h2`,{children:W(t,`Tiêu chí hoàn thành`,`Completion criteria`)}),(0,X.jsxs)(`span`,{children:[n.criteria.length,` `,W(t,`tiêu chí`,`criteria`)]})]}),(0,X.jsx)(`ol`,{className:`criteria-list`,children:n.criteria.map((e,n)=>(0,X.jsxs)(`li`,{className:`criterion-card`,children:[(0,X.jsx)(`span`,{className:`criterion-index tone-${Ul(e.state)}`,children:String(n+1).padStart(2,`0`)}),(0,X.jsxs)(`div`,{className:`criterion-copy`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{children:e.obligation}),e.priority===`critical`&&(0,X.jsx)(`span`,{className:`critical-tag`,children:W(t,`Quan trọng`,`Critical`)})]}),(0,X.jsx)(`small`,{children:Jl(e,t)})]}),(0,X.jsx)(qd,{value:e.state,locale:t})]},e.criterionId))}),n.workPlan.length>0&&(0,X.jsxs)(`details`,{className:`work-plan`,children:[(0,X.jsxs)(`summary`,{children:[W(t,`Kế hoạch thực hiện`,`Work plan`),` · `,n.workPlan.length,` `,W(t,`bước`,`steps`)]}),(0,X.jsx)(`ol`,{children:n.workPlan.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(qd,{value:e.status,locale:t}),(0,X.jsx)(`span`,{children:e.summary})]},e.stepId))})]})]})}function Xd({snapshot:e,locale:t}){return(0,X.jsxs)(`aside`,{className:`context-rail`,"aria-label":W(t,`Tóm tắt phiên`,`Session summary`),children:[(0,X.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,X.jsxs)(`dl`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Task ID`}),(0,X.jsx)(`dd`,{title:e.identity.taskId??void 0,children:Wl(e.identity.taskId)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Run ID`}),(0,X.jsx)(`dd`,{title:e.identity.taskRunId??void 0,children:Wl(e.identity.taskRunId)})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Verifier`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(qd,{value:e.verification.state,locale:t})})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{children:`Queue`}),(0,X.jsx)(`dd`,{children:e.session.queue.state===`known`?`${e.session.queue.heldCount??0} ${W(t,`đang giữ`,`held`)}`:$(e.session.queue.state,t)})]})]})]}),(0,X.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(t,`Sức khỏe`,`Health`)}),(0,X.jsxs)(`div`,{className:`health-line`,children:[(0,X.jsx)(qd,{value:e.health.state,locale:t}),(0,X.jsxs)(`span`,{children:[e.health.issues.length,` `,W(t,`lưu ý`,`issues`)]})]}),e.health.issues.slice(0,3).map(e=>(0,X.jsx)(`p`,{className:`health-issue`,children:e.message},e.issueRef))]})]})}function Zd({snapshot:e,locale:t}){let n=[[`Runtime`,(0,X.jsx)(qd,{value:e.session.operation.liveness,locale:t})],[`Task`,(0,X.jsx)(qd,{value:e.session.controlState,locale:t})],[`Model`,(0,X.jsx)(`strong`,{children:Gl(e,t)})],[`Thinking`,(0,X.jsx)(`strong`,{children:Kl(e,t)})],[W(t,`Quyền`,`Permission`),(0,X.jsx)(`strong`,{children:ql(e,t)})],[`Approval`,(0,X.jsx)(qd,{value:e.session.approvalState,locale:t})]];return(0,X.jsx)(ft,{variant:`outlined`,className:`runtime-overview`,"aria-label":W(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,X.jsxs)(Z,{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,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:800,letterSpacing:`.11em`,textTransform:`uppercase`},children:e}),t]},e))})}function Qd({active:e,snapshot:t,events:n,refreshSnapshot:r,locale:i}){return e===`overview`?(0,X.jsxs)(Q,{className:`workspace-stack`,spacing:2.25,children:[(0,X.jsx)(Zd,{snapshot:t,locale:i}),(0,X.jsxs)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`minmax(0,1fr) 300px`},alignItems:`start`,gap:2.25},children:[(0,X.jsx)(Yd,{snapshot:t,locale:i}),(0,X.jsx)(Xd,{snapshot:t,locale:i})]}),(0,X.jsx)(Hu,{snapshot:t})]}):e===`chat`?(0,X.jsxs)(Q,{className:`workspace-stack`,spacing:2.25,children:[(0,X.jsx)(Rd,{snapshot:t,refreshSnapshot:r}),(0,X.jsx)(bd,{snapshot:t,refreshSnapshot:r}),(0,X.jsx)(yd,{snapshot:t,events:n,refreshSnapshot:r})]}):e===`documents`?(0,X.jsx)(Ou,{}):e===`source`?(0,X.jsx)(lu,{snapshot:t,refreshSnapshot:r}):e===`activity`?(0,X.jsx)(Fu,{snapshot:t}):e===`history`?(0,X.jsx)(Vd,{snapshot:t}):(0,X.jsx)(Wd,{snapshot:t})}function $d({snapshot:e,connection:t=`connecting`,events:n=[],refreshSnapshot:r}){let{locale:i,colorMode:a,setLocale:o,setColorMode:s}=ze(),[c,l]=(0,Y.useState)(`overview`),[u,d]=(0,Y.useState)(!1);if(!e)return(0,X.jsxs)(Z,{className:`loading-shell`,children:[(0,X.jsx)(Z,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,X.jsx)(`p`,{className:`section-kicker`,children:`Piagent WebUI · local`}),(0,X.jsx)(q,{variant:`h1`,children:t===`failed`?W(i,`Không thể nối vào Pi session`,`Unable to connect to the Pi session`):W(i,`Đang mở không gian làm việc`,`Opening the workspace`)}),(0,X.jsx)(q,{color:`text.secondary`,children:t===`failed`?W(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.`):W(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,X.jsx)(De,{size:22}),(0,X.jsx)(qd,{value:t,locale:i})]});let f=Kd[c][i],p=(e.sourceChanges.task?.counts.files??0)+e.sourceChanges.workingTree.counts.files+e.sourceChanges.staged.counts.files,m=[{id:`overview`,label:W(i,`Tổng quan`,`Overview`),icon:(0,X.jsx)(yo,{})},{id:`chat`,label:W(i,`Chat & Task`,`Chat & Task`),icon:(0,X.jsx)(bo,{}),count:e.session.queue.heldCount??0},{id:`documents`,label:W(i,`Tài liệu`,`Documents`),icon:(0,X.jsx)(xo,{})},{id:`source`,label:`Source Changes`,icon:(0,X.jsx)(So,{}),count:p},{id:`activity`,label:`Activity`,icon:(0,X.jsx)(Co,{}),count:e.activity.running.length},{id:`history`,label:W(i,`Lịch sử`,`History`),icon:(0,X.jsx)(wo,{})},{id:`release`,label:`Release`,icon:(0,X.jsx)(To,{})}],h=e=>{l(e),d(!1)},g=(0,X.jsxs)(Z,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,X.jsxs)(ti,{sx:{minHeight:`72px !important`,px:`18px !important`,gap:1.25},children:[(0,X.jsx)(Z,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,X.jsxs)(Z,{sx:{minWidth:0},children:[(0,X.jsx)(q,{sx:{fontWeight:760,lineHeight:1.15},children:`Piagent`}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,children:`WebUI · local`})]})]}),(0,X.jsxs)(Z,{sx:{mx:1.5,mb:1.25,p:1.35,border:1,borderColor:`divider`,borderRadius:1,bgcolor:`action.hover`},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textTransform:`uppercase`,letterSpacing:`.09em`},children:W(i,`Pi session hiện tại`,`Current Pi session`)}),(0,X.jsx)(q,{variant:`body2`,noWrap:!0,title:e.session.displayName??void 0,sx:{mt:.45,fontWeight:700},children:e.session.displayName??`Pi session`}),(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,title:e.identity.sessionRef,children:Wl(e.identity.sessionRef)})]}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{px:2.5,pt:1,pb:.5,fontWeight:800,letterSpacing:`.1em`,textTransform:`uppercase`},children:W(i,`Không gian làm việc`,`Workspaces`)}),(0,X.jsx)(ie,{component:`nav`,"aria-label":W(i,`Điều hướng WebUI`,`WebUI navigation`),sx:{py:.5},children:m.map(e=>(0,X.jsxs)(Dr,{selected:c===e.id,"aria-current":c===e.id?`page`:void 0,onClick:()=>h(e.id),children:[(0,X.jsx)(Mr,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:e.icon}),(0,X.jsx)(Lr,{primary:e.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:c===e.id?750:600}}}}),!!e.count&&(0,X.jsx)(Wn,{badgeContent:e.count,color:e.id===`activity`?`secondary`:`primary`,max:99,sx:{mr:1}})]},e.id))}),(0,X.jsxs)(Z,{sx:{mt:`auto`,p:1.5},children:[(0,X.jsx)(or,{sx:{mb:1.5}}),(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,X.jsxs)(Zr,{exclusive:!0,size:`small`,value:i,"aria-label":W(i,`Ngôn ngữ`,`Language`),onChange:(e,t)=>t&&o(t),sx:{flex:1},children:[(0,X.jsx)(Gr,{value:`vi`,"aria-label":`Tiếng Việt`,sx:{flex:1},children:`VI`}),(0,X.jsx)(Gr,{value:`en`,"aria-label":`English`,sx:{flex:1},children:`EN`})]}),(0,X.jsx)(_o,{title:a===`dark`?W(i,`Chuyển sang giao diện sáng`,`Use light mode`):W(i,`Chuyển sang giao diện tối`,`Use dark mode`),children:(0,X.jsx)(Ze,{"aria-label":a===`dark`?W(i,`Dùng giao diện sáng`,`Use light mode`):W(i,`Dùng giao diện tối`,`Use dark mode`),onClick:()=>s(a===`dark`?`light`:`dark`),sx:{border:1,borderColor:`divider`,borderRadius:1},children:a===`dark`?(0,X.jsx)(Do,{fontSize:`small`}):(0,X.jsx)(Oo,{fontSize:`small`})})})]})]})]});return(0,X.jsxs)(Z,{className:`app-shell`,"data-contract":`snapshot-v1`,children:[(0,X.jsx)(`a`,{className:`skip-link`,href:`#main-content`,children:W(i,`Bỏ qua điều hướng`,`Skip navigation`)}),(0,X.jsx)(Nn,{position:`fixed`,color:`transparent`,elevation:0,sx:{width:{md:`calc(100% - ${Gd}px)`},ml:{md:`${Gd}px`},borderBottom:1,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .88)`,backdropFilter:`blur(18px)`},children:(0,X.jsxs)(ti,{sx:{minHeight:`72px !important`,gap:1.5},children:[(0,X.jsx)(Ze,{edge:`start`,"aria-label":W(i,`Mở menu`,`Open menu`),onClick:()=>d(!0),sx:{display:{md:`none`}},children:(0,X.jsx)(Eo,{})}),(0,X.jsxs)(Z,{sx:{minWidth:0,flex:1},children:[(0,X.jsx)(q,{component:`h1`,variant:`h2`,noWrap:!0,children:f[0]}),(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{display:{xs:`none`,sm:`block`}},children:f[1]})]}),(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{alignItems:`center`},"aria-live":`polite`,children:[(0,X.jsx)(er,{variant:`outlined`,size:`small`,color:t===`connected`?`success`:`default`,label:t===`connected`?`Live`:$(t,i)}),e.approvals.pending.length>0&&(0,X.jsx)(er,{color:`warning`,size:`small`,label:`${e.approvals.pending.length} approval`}),(0,X.jsx)(er,{variant:`outlined`,size:`small`,sx:{display:{xs:`none`,sm:`flex`}},label:e.capabilities.capabilities[`control.chat`].status===`available`?W(i,`Chat bật`,`Chat enabled`):W(i,`Chỉ xem`,`Read only`)})]})]})}),(0,X.jsxs)(Z,{component:`nav`,"aria-label":W(i,`Sidebar chính`,`Primary sidebar`),sx:{width:{md:Gd},flexShrink:{md:0}},children:[(0,X.jsx)(Cr,{variant:`temporary`,open:u,onClose:()=>d(!1),ModalProps:{keepMounted:!0},sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:Gd}},children:g}),(0,X.jsx)(Cr,{variant:`permanent`,open:!0,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:Gd,borderRight:1,borderColor:`divider`,bgcolor:`background.paper`}},children:g})]}),(0,X.jsx)(Z,{component:`main`,id:`main-content`,sx:{ml:{md:`${Gd}px`},minWidth:0,pt:`72px`},children:(0,X.jsxs)(Z,{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,X.jsx)(Z,{sx:{mb:2.25},children:(0,X.jsx)(Pd,{snapshot:e,refreshSnapshot:r})}),(0,X.jsx)(Qd,{active:c,snapshot:e,events:n,refreshSnapshot:r,locale:i})]})})]})}function ef({value:e,onChange:t}){let{locale:n}=ze();return(0,X.jsxs)(ss,{value:e,onChange:(e,n)=>t(n),variant:`fullWidth`,"aria-label":W(n,`Thanh bên`,`Sidebar`),children:[(0,X.jsx)(Bo,{value:`sessions`,label:W(n,`Phiên`,`Sessions`)}),(0,X.jsx)(Bo,{value:`files`,label:W(n,`Tệp`,`Files`)}),(0,X.jsx)(Bo,{value:`search`,label:W(n,`Tìm kiếm`,`Search`)})]})}var tf=jt({themeId:x}),nf=(0,Y.lazy)(()=>yu(()=>import(`./WorkspaceQuickOpen-fgXwQ46B.js`),__vite__mapDeps([5,1,2,6,3,7,4,8,9]))),rf=(0,Y.lazy)(()=>yu(()=>import(`./TerminalPanel-DvOPgrGI.js`),__vite__mapDeps([10,1,2,3,7,4,11,12]))),af=(0,Y.lazy)(()=>yu(()=>import(`./WorkspaceExplorer-DttpQtpf.js`),__vite__mapDeps([13,1,2,6,3,7,4,11,9,12,8])));function of({sessionRef:e,children:t,navigationHost:n,sidebarMode:r,onSection:i}){let{locale:a}=ze(),o=tf(T().breakpoints.up(`lg`)),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)();(0,Y.useEffect)(()=>{let t=e=>{(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&e.key.toLowerCase()===`p`&&(e.preventDefault(),u(!0))},n=t=>{let n=t.detail;n?.sessionRef===e&&(m({path:n.path,line:n.line}),c(!0),i(`files`))};return window.addEventListener(`keydown`,t),window.addEventListener(ko,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(ko,n)}},[e]),(0,Y.useEffect)(()=>{r!==`sessions`&&c(!0)},[r]);let h=(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(De,{size:24}),children:(0,X.jsx)(af,{sessionRef:e,target:p,navigationHost:o?n:null,sidebarMode:r,onHide:()=>{c(!1),i(`sessions`)},fill:o})}),g=(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(De,{size:24}),children:(0,X.jsx)(rf,{sessionRef:e,onHide:()=>f(!1)})});return(0,X.jsxs)(X.Fragment,{children:[l&&(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(De,{size:20}),children:(0,X.jsx)(nf,{sessionRef:e,onClose:()=>u(!1),onOpen:e=>{u(!1),c(!0),i(`files`),m({path:e})}})}),(0,X.jsx)(J,{"aria-expanded":s,onClick:()=>{c(e=>!e),i(s?`sessions`:`files`)},children:W(a,`Tệp`,`Files`)}),(0,X.jsx)(J,{"aria-expanded":d,onClick:()=>f(e=>!e),children:`Terminal`}),(0,X.jsxs)(Z,{sx:{display:`flex`,minWidth:0},children:[o&&(s||d)&&(0,X.jsxs)(Z,{component:`section`,sx:{width:`58%`,minWidth:0,borderRight:1,borderColor:`divider`,height:`calc(100vh - 110px)`,display:`flex`,flexDirection:`column`},children:[s&&(0,X.jsx)(Z,{sx:{flex:1,minHeight:0,overflow:`hidden`},children:h}),d&&(0,X.jsx)(Z,{sx:{flexShrink:0,maxHeight:s?`60%`:`100%`,overflow:`auto`},children:g})]}),(0,X.jsx)(Z,{sx:{flex:1,minWidth:0},children:t})]}),!o&&(0,X.jsxs)(Cr,{anchor:`bottom`,open:d,onClose:()=>f(!1),children:[(0,X.jsx)(J,{onClick:()=>f(!1),children:W(a,`Ẩn terminal`,`Hide terminal`)}),d&&g]}),!o&&(0,X.jsxs)(Cr,{anchor:`left`,open:s,onClose:()=>c(!1),slotProps:{paper:{sx:{width:`min(96vw, 800px)`}}},children:[(0,X.jsx)(J,{onClick:()=>c(!1),children:W(a,`Đóng`,`Close`)}),s&&h]})]})}var sf=K((0,X.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`),cf=K((0,X.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`),lf=K((0,X.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`),uf=K((0,X.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`),df=K((0,X.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`),ff=K((0,X.jsx)(`path`,{d:`M2 4v16h20V4zm18 4.67h-2.5V6H20zm-2.5 2H20v2.67h-2.5zM4 6h11.5v12H4zm13.5 12v-2.67H20V18z`}),`ViewSidebarOutlined`),pf=K((0,X.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 mf(e){return m(`MuiCollapse`,e)}E(`MuiCollapse`,[`root`,`horizontal`,`vertical`,`entered`,`hidden`,`wrapper`,`wrapperInner`]);var hf={},gf=e=>{let{orientation:t,classes:n}=e;return he({root:[`root`,t],entered:[`entered`],hidden:[`hidden`],wrapper:[`wrapper`,t],wrapperInner:[`wrapperInner`,t]},mf,n)},_f=H(`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]}})(ge(({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`}}]}))),vf=H(`div`,{name:`MuiCollapse`,slot:`Wrapper`})({display:`flex`,width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),yf=H(`div`,{name:`MuiCollapse`,slot:`WrapperInner`})({width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),bf=Y.forwardRef(function(e,t){let n=_e({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:g,onExiting:_,orientation:v=`vertical`,slots:y=hf,slotProps:b=hf,style:x,timeout:C=S.standard,TransitionComponent:w=me,...E}=n,D={...n,orientation:v,collapsedSize:o},O=gf(D),k=T(),A=Y.useRef(null),j=Y.useRef(null),M=typeof o==`number`?`${o}px`:o,N=v===`horizontal`,P=N?`width`:`height`,F=Be(k.motion.reducedMotion,c),I=Y.useRef(null),L=Ue(t,I),R=()=>A.current?A.current[N?`clientWidth`:`clientHeight`]:0,z=We(I,(e,t)=>{A.current&&N&&(A.current.style.position=`absolute`),e.style[P]=M,d&&d(e,t)}),B=We(I,(e,t)=>{let n=R();A.current&&N&&(A.current.style.position=``);let{duration:r,easing:i}=Me({style:x,timeout:C,easing:l},{mode:`enter`});if(C===`auto`&&!F.shouldReduceMotion){let e=k.transitions.getAutoHeightDuration(n);j.current=e}else j.current=null;let a=F.getTransitionTiming({duration:j.current??r,delay:void 0});e.style.transitionDuration=typeof a.duration==`string`?a.duration:`${a.duration}ms`,e.style[P]=`${n}px`,e.style.transitionTimingFunction=i,p&&p(e,t)}),V=We(I,(e,t)=>{e.style[P]=`auto`,f&&f(e,t)}),ee=We(I,e=>{e.style[P]=`${R()}px`,m&&m(e)}),te=We(I,g),ne=We(I,e=>{let t=R(),{duration:n,easing:r}=Me({style:x,timeout:C,easing:l},{mode:`exit`});if(C===`auto`&&!F.shouldReduceMotion){let e=k.transitions.getAutoHeightDuration(t);j.current=e}else j.current=null;let i=F.getTransitionTiming({duration:j.current??n,delay:void 0});e.style.transitionDuration=typeof i.duration==`string`?i.duration:`${i.duration}ms`,e.style[P]=M,e.style.transitionTimingFunction=r,_&&_(e)}),re=r?e=>{r(I.current,e)}:void 0,ie={slots:y,slotProps:b,component:s},[ae,oe]=$e(`root`,{ref:L,className:h(O.root,a),elementType:_f,externalForwardedProps:ie,ownerState:D,additionalProps:{style:{[N?`minWidth`:`minHeight`]:M,...x}}}),[se,ce]=$e(`wrapper`,{ref:A,className:O.wrapper,elementType:vf,externalForwardedProps:ie,ownerState:D}),[le,ue]=$e(`wrapperInner`,{className:O.wrapperInner,elementType:yf,externalForwardedProps:ie,ownerState:D});return(0,X.jsx)(w,{in:u,onEnter:z,onEntered:V,onEntering:B,onExit:ee,onExited:te,onExiting:ne,addEndListener:re,getAutoTimeout:C===`auto`?()=>j.current:void 0,reduceMotion:F.shouldReduceMotion,nodeRef:I,timeout:C===`auto`?null:C,...E,children:(e,{ownerState:t,...n})=>{let r={...D,state:e};return(0,X.jsx)(ae,{...oe,className:h(oe.className,{entered:O.entered,exited:!u&&M===`0px`&&O.hidden}[e]),ownerState:r,...n,children:(0,X.jsx)(se,{...ce,ownerState:r,children:(0,X.jsx)(le,{...ue,ownerState:r,children:i})})})}})});bf&&(bf.muiSupportAuto=!0);var xf=(e,[t,n])=>e===`vi`?t:n,Sf={"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-project-contains-config":[`Không mở Piagent công ty ở thư mục này (thường là thư mục home ~) vì nó chứa cấu hình công ty. Vào thư mục dự án rồi chạy lại: cd ~/đường-dẫn-dự-án && piagent studio, hoặc piagent studio --project ~/đường-dẫn-dự-án.`,`The company Piagent cannot open this folder (usually your home folder ~) because it holds the company configuration. Go to a project folder and run it again: cd ~/your-project && piagent studio, or piagent studio --project ~/your-project.`],"managed-binding-update-pending":[`Agent Watch đang chạy nhưng chưa cập nhật cấu hình sau bản Piagent hoặc Agent Watch mới. Mở Agent Watch → Studio, bấm Áp dụng cho Piagent rồi mở lại.`,`Agent Watch is running but has not updated the configuration after the Piagent or Agent Watch update yet. Open Agent Watch → Studio, apply for Piagent, then open it again.`],"managed-binding-watch-not-running":[`Piagent hoặc Agent Watch vừa cập nhật nhưng Agent Watch không chạy nên chưa cập nhật cấu hình. Mở Agent Watch, chờ vài giây rồi mở lại.`,`Piagent or Agent Watch was updated but Agent Watch is not running, so the configuration was not updated. Open Agent Watch, wait a few seconds, then open it again.`],"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.`],"company-gateway-timeout":["Phiên công ty đang chạy nhưng không trả lời. Đóng Piagent, chạy `pkill -f piagent-studio.mjs` trong Terminal (Windows: trong Ubuntu), rồi mở lại.","The company runtime is running but does not answer. Close Piagent, run `pkill -f piagent-studio.mjs` in a terminal (Windows: in Ubuntu), then open it again."]},Cf={"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.`]}},wf=[`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.`],Tf={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 Ef(e,t,n){let r=(t?Tf[t]:void 0)??Cf[e]??(e.startsWith(`company-`)?Cf[`company-failed`]:void 0);return r?{title:xf(n,r.title),text:xf(n,t===`managed-session-scope-changed`?wf:r.text)}:null}function Df(e,t){return e===`main`?`Main agent`:e===`scout`?xf(t,[`Subagent scout`,`Scout subagent`]):e===`research`?xf(t,[`Subagent research`,`Research subagent`]):e===`verify`?xf(t,[`Subagent verify`,`Verify subagent`]):xf(t,[`Subagent review`,`Review subagent`])}function Of(e,t,n){return Ef(e,t,n)}var kf=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 Af(e){return kf.has(e)||!e.startsWith(`company-`)}function jf(e,t){return Df(e,t)}var Mf=Sf,Nf={"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 Pf(e,t){let n=e.startsWith(`company-`)?Of(e,null,t):null;if(n)return`${n.title}: ${n.text}`;let r=Nf[e]??Mf[e];return r?W(t,...r):`${W(t,`Chưa tạo được cuộc trò chuyện`,`The conversation could not be created`)} (${e}).`}function Ff(e,t){let n=Mf[e?.reasonCode??``];return n?W(t,...n):null}var If=(e,t)=>e?.state===`connecting`?W(t,`Đang kết nối phiên công ty…`,`Connecting the company runtime…`):Ff(e,t)??W(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 Lf({locale:e,onConnected:t}){let[n,r]=(0,Y.useState)(),[i,a]=(0,Y.useState)(!1),o=(0,Y.useRef)(!1),s=()=>{o.current&&(o.current=!1,t())};if((0,Y.useEffect)(()=>{let e=!0,t=()=>void xs().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 Ss();r(e),e.state===`ready`&&s()}catch{r(await xs().catch(()=>null)??n)}finally{a(!1)}},l=Ff(n,e),u=i||n.state===`connecting`;return(0,X.jsxs)(st,{severity:`warning`,role:`status`,sx:{mb:2},action:(0,X.jsx)(J,{color:`inherit`,size:`small`,disabled:u,onClick:()=>void c(),sx:{whiteSpace:`nowrap`},children:u?W(e,`Đang kết nối…`,`Connecting…`):W(e,`Kết nối lại`,`Reconnect`)}),children:[W(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,X.jsxs)(X.Fragment,{children:[` `,l]})]})}var Rf=K((0,X.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`),zf=K((0,X.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`),Bf=K((0,X.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`),Vf=K((0,X.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`),Hf=K((0,X.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 Uf(e){return m(`MuiListItem`,e)}E(`MuiListItem`,[`root`,`dense`,`alignItemsFlexStart`,`divider`,`gutters`,`padding`,`secondaryAction`]);function Wf(e){return m(`MuiListItemSecondaryAction`,e)}E(`MuiListItemSecondaryAction`,[`root`,`disableGutters`]);var Gf=e=>{let{disableGutters:t,classes:n}=e;return he({root:[`root`,t&&`disableGutters`]},Wf,n)},Kf=H(`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}}]}),qf=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiListItemSecondaryAction`}),{className:r,component:i,...a}=n,o=Y.useContext(ee),s={...n,disableGutters:o.disableGutters},c=Gf(s);return(0,X.jsx)(Kf,{as:i,className:h(c.root,r),ownerState:s,ref:t,...a})});qf.muiName=`ListItemSecondaryAction`;var Jf=(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]},Yf=e=>{let{alignItems:t,classes:n,dense:r,disableGutters:i,disablePadding:a,divider:o}=e;return he({root:[`root`,r&&`dense`,!i&&`gutters`,!a&&`padding`,o&&`divider`,t===`flex-start`&&`alignItemsFlexStart`],secondaryAction:[`secondaryAction`]},Uf,n)},Xf=H(`div`,{name:`MuiListItem`,slot:`Root`,overridesResolver:Jf})(ge(({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:{[`& > .${_n.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:{...Ee(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}}}}]}))),Zf=H(qf,{name:`MuiListItem`,slot:`secondaryAction`})({}),Qf=Y.forwardRef(function(e,t){let n=_e({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,g=Y.useContext(ee),_=Y.useMemo(()=>({dense:s||g.dense||!1,alignItems:r,disableGutters:c}),[r,g.dense,s,c]),v={...n,alignItems:r,dense:_.dense,disableGutters:c,disablePadding:l,divider:u,secondaryAction:d},y=Yf(v),b={slots:p,slotProps:f},[x,S]=$e(`root`,{ref:t,elementType:Xf,externalForwardedProps:{component:o,...b,...m},ownerState:v,className:h(y.root,a)}),[C,w]=$e(`secondaryAction`,{elementType:Zf,shouldForwardComponentProp:!0,externalForwardedProps:b,ownerState:v,className:y.secondaryAction});return(0,X.jsx)(ee.Provider,{value:_,children:(0,X.jsxs)(x,{...S,children:[i,d&&(0,X.jsx)(C,{...w,children:d})]})})}),$f=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},ep=e=>{let{disabled:t,dense:n,divider:r,disableGutters:i,selected:a,classes:o}=e,s=he({root:[`root`,n&&`dense`,t&&`disabled`,!i&&`gutters`,r&&`divider`,a&&`selected`]},vn,o);return{...o,...s}},tp=H(Le,{shouldForwardProp:e=>Se(e)||e===`classes`,name:`MuiMenuItem`,slot:`Root`,overridesResolver:$f})(ge(({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`}},[`&.${yn.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${yn.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${yn.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)}},[`&.${yn.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${yn.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${nr.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${nr.inset}`]:{marginLeft:52},[`& .${Pr.root}`]:{marginTop:0,marginBottom:0},[`& .${Pr.inset}`]:{paddingLeft:36},[`& .${kr.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,[`& .${kr.root} svg`]:{fontSize:`1.25rem`}}}]}))),np=Y.forwardRef(function(e,t){let n=_e({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=re(),g=Y.useContext(ee),_=Y.useMemo(()=>({dense:a||g.dense||!1,disableGutters:s}),[g.dense,a,s]),v=R(),y=Ne(),b=v.suppressInitialFocusVisible,x=v.itemsFocusableWhenDisabled,S=Y.useRef(null);lt(()=>{r&&S.current&&de(S.current,m)},[r]);let C={...n,dense:_.dense,divider:o,disableGutters:s},w=ep(n),{root:T,...E}=w,D=tt({id:y,ref:t,disabled:n.disabled,focusableWhenDisabled:x,selected:n.selected}),O=Ue(S,D.ref),k;return u===void 0?v.variant===`selectedMenu`?k=D.tabIndex:(!n.disabled||x)&&(k=-1):k=u,(0,X.jsx)(ee.Provider,{value:_,children:(0,X.jsx)(tp,{ref:O,role:l,"aria-checked":p,tabIndex:k,component:i,internalNativeButton:!1,focusableWhenDisabled:x,suppressFocusVisible:b,focusVisibleClassName:h(w.focusVisible,c),className:h(w.root,d),...f,ownerState:C,classes:E})})});function rp(e={}){let{autoHideDuration:t=null,disableWindowBlurListener:n=!1,onClose:r,open:i,resumeHideDuration:a}=e,o=Fe();Y.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=He((e,t)=>{r?.(e,t)}),c=He(e=>{!r||e==null||o.start(e,()=>{s(null,`timeout`)})});Y.useEffect(()=>(i&&c(t),o.clear),[i,t,c,o]);let l=e=>{r?.(e,`clickaway`)},u=o.clear,d=Y.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 Y.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={...Je(e),...Je(t)};return{role:`presentation`,...t,...n,onBlur:f(n),onFocus:p(n),onMouseEnter:m(n),onMouseLeave:h(n)}},onClickAway:l}}function ip(e){return e.substring(2).toLowerCase()}function ap(e,t){return t.documentElement.clientWidth<e.clientX||t.documentElement.clientHeight<e.clientY}function op(e){let{children:t,disableReactTree:n=!1,mouseEvent:r=`onClick`,onClickAway:i,touchEvent:a=`onTouchEnd`}=e,o=Y.useRef(!1),s=Y.useRef(null),c=Y.useRef(!1),l=Y.useRef(!1);Y.useEffect(()=>(setTimeout(()=>{c.current=!0},0),()=>{c.current=!1}),[]);let u=Te(N(t),s),d=He(e=>{let t=l.current;l.current=!1;let r=Ge(s.current);if(!c.current||!s.current||`clientX`in e&&ap(e,r))return;if(o.current){o.current=!1;return}let a;a=e.composedPath?e.composedPath().includes(s.current):!at(r.documentElement,e.target)||at(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)),Y.useEffect(()=>{if(a!==!1){let e=ip(a),t=Ge(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)),Y.useEffect(()=>{if(r!==!1){let e=ip(r),t=Ge(s.current);return t.addEventListener(e,d),()=>{t.removeEventListener(e,d)}}},[d,r]),Y.cloneElement(t,p)}function sp(e){return m(`MuiSnackbarContent`,e)}E(`MuiSnackbarContent`,[`root`,`message`,`action`]);var cp=e=>{let{classes:t}=e;return he({root:[`root`],action:[`action`],message:[`message`]},sp,t)},lp=H(ft,{name:`MuiSnackbarContent`,slot:`Root`})(ge(({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(y(e.palette.background.default,t)),backgroundColor:e.vars?e.vars.palette.SnackbarContent.bg:y(e.palette.background.default,t),display:`flex`,alignItems:`center`,flexWrap:`wrap`,padding:`6px 16px`,flexGrow:1,[e.breakpoints.up(`sm`)]:{flexGrow:`initial`,minWidth:288}}})),up=H(`div`,{name:`MuiSnackbarContent`,slot:`Message`})({padding:`8px 0`}),dp=H(`div`,{name:`MuiSnackbarContent`,slot:`Action`})({display:`flex`,alignItems:`center`,marginLeft:`auto`,paddingLeft:16,marginRight:-8}),fp=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiSnackbarContent`}),{action:r,className:i,message:a,role:o=`alert`,...s}=n,c=n,l=cp(c);return(0,X.jsxs)(lp,{role:o,elevation:6,className:h(l.root,i),ownerState:c,ref:t,...s,children:[(0,X.jsx)(up,{className:l.message,ownerState:c,children:a}),r?(0,X.jsx)(dp,{className:l.action,ownerState:c,children:r}):null]})});function pp(e){return m(`MuiSnackbar`,e)}E(`MuiSnackbar`,[`root`,`anchorOriginTopCenter`,`anchorOriginBottomCenter`,`anchorOriginTopRight`,`anchorOriginBottomRight`,`anchorOriginTopLeft`,`anchorOriginBottomLeft`]);var mp=e=>{let{classes:t,anchorOrigin:n}=e,r={root:[`root`,`anchorOrigin${U(n.vertical)}${U(n.horizontal)}`]};return he(r,pp,t)},hp=H(`div`,{name:`MuiSnackbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`anchorOrigin${U(n.anchorOrigin.vertical)}${U(n.anchorOrigin.horizontal)}`]]}})(ge(({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%)`}}}]}))),gp=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiSnackbar`}),r=T(),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:v,resumeHideDuration:y,slots:b={},slotProps:x={},transitionDuration:S=i,...C}=n,w={...n,anchorOrigin:{vertical:o,horizontal:s},autoHideDuration:c,disableWindowBlurListener:d,transitionDuration:S},E=mp(w),{getRootProps:D,onClickAway:O}=rp(w),[k,A]=Y.useState(!0),j={slots:b,slotProps:x},[M,N]=$e(`root`,{ref:t,className:[E.root,u],elementType:hp,getSlotProps:D,externalForwardedProps:{...j,...C},ownerState:w}),[P,{ownerState:F,...I}]=$e(`clickAwayListener`,{elementType:op,externalForwardedProps:j,getSlotProps:e=>({onClickAway:(...t)=>{let n=t[0];e.onClickAway?.(...t),!n?.defaultMuiPrevented&&O(...t)}}),ownerState:w}),[L,R]=$e(`content`,{elementType:fp,shouldForwardComponentProp:!0,externalForwardedProps:j,additionalProps:{message:f,action:a},ownerState:w}),[z,B]=$e(`transition`,{elementType:se,externalForwardedProps:j,getSlotProps:e=>({onEnter:(...t)=>{e.onEnter?.(...t),A(!1)},onExited:(...t)=>{e.onExited?.(...t),A(!0)}}),additionalProps:{appear:!0,in:v,timeout:S,direction:o===`top`?`down`:`up`},ownerState:w});return!v&&k?null:(0,X.jsx)(P,{...I,...b.clickAwayListener&&{ownerState:F},children:(0,X.jsx)(M,{...N,children:(0,X.jsx)(z,{...B,children:l||(0,X.jsx)(L,{...R})})})})}),_p=K((0,X.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`),vp=K((0,X.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`),yp=K((0,X.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`),bp=K((0,X.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`),xp=K((0,X.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`),Sp=K((0,X.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`),Cp=K((0,X.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`),wp={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 Tp(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{fill:`#f24e1e`,d:`M5 2h7v7H8.5A3.5 3.5 0 0 1 5 5.5V2Z`}),(0,X.jsx)(`path`,{fill:`#ff7262`,d:`M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2Z`}),(0,X.jsx)(`path`,{fill:`#a259ff`,d:`M5 9h7v7H8.5A3.5 3.5 0 0 1 5 12.5V9Z`}),(0,X.jsx)(`circle`,{cx:`15.5`,cy:`12.5`,r:`3.5`,fill:`#1abcfe`}),(0,X.jsx)(`path`,{fill:`#0acf83`,d:`M5 16h7v3.5A3.5 3.5 0 1 1 5 16Z`})]})}function Ep(e){let t=e.toLowerCase();return t.includes(`figma`)?(0,X.jsx)(Tp,{}):t.includes(`github`)?(0,X.jsx)(Sp,{fontSize:`inherit`}):t.includes(`chrome`)||t.includes(`devtools`)?(0,X.jsx)(bp,{fontSize:`inherit`}):t.includes(`anthropic`)||t.includes(`claude`)?(0,X.jsx)(_p,{fontSize:`inherit`}):t.includes(`file`)||t.includes(`folder`)?(0,X.jsx)(xp,{fontSize:`inherit`}):t.includes(`postgres`)||t.includes(`database`)||t.includes(`supabase`)?(0,X.jsx)(Cp,{fontSize:`inherit`}):t.includes(`code`)||t.includes(`context7`)?(0,X.jsx)(yp,{fontSize:`inherit`}):t.includes(`google`)||t.includes(`drive`)||t.includes(`cloud`)?(0,X.jsx)(vp,{fontSize:`inherit`}):(0,X.jsx)(Bf,{fontSize:`inherit`})}function Dp({name:e,size:t=34}){let n=e.toLowerCase(),r=Object.keys(wp).find(e=>n.includes(e));return(0,X.jsx)(Z,{"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?wp[r]:`action.selected`,color:r?`#fff`:`text.secondary`,fontSize:Math.round(t*.52),border:1,borderColor:r?`transparent`:`divider`},children:Ep(e)})}var Op=K((0,X.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`),kp=K((0,X.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 Ap(e){return m(`MuiDialogActions`,e)}E(`MuiDialogActions`,[`root`,`spacing`]);var jp=e=>{let{classes:t,disableSpacing:n}=e;return he({root:[`root`,!n&&`spacing`]},Ap,t)},Mp=H(`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}}}]}),Np=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiDialogActions`}),{className:r,disableSpacing:i=!1,...a}=n,o={...n,disableSpacing:i},s=jp(o);return(0,X.jsx)(Mp,{className:h(s.root,r),ownerState:o,ref:t,...a})});function Pp(e){return m(`PrivateSwitchBase`,e)}E(`PrivateSwitchBase`,[`root`,`checked`,`disabled`,`input`,`edgeStart`,`edgeEnd`]);var Fp=e=>{let{classes:t,checked:n,disabled:r,edge:i}=e,a={root:[`root`,n&&`checked`,r&&`disabled`,i&&`edge${U(i)}`],input:[`input`]};return he(a,Pp,t)},Ip=H(Le,{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}}]}),Lp=H(`input`,{name:`MuiSwitchBase`,shouldForwardProp:Se})({cursor:`inherit`,position:`absolute`,opacity:0,width:`100%`,height:`100%`,top:0,left:0,margin:0,padding:0,zIndex:1}),Rp=Y.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]=F({controlled:r,default:!!a,name:`SwitchBase`,state:`checked`}),D=pe(),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=Fp(N),I={slots:b,slotProps:x},[L,R]=$e(`root`,{ref:t,elementType:Ip,className:P.root,shouldForwardComponentProp:!0,externalForwardedProps:{...I,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}}),[z,B]=$e(`input`,{elementType:Lp,className:P.input,externalForwardedProps:I,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,X.jsxs)(L,{...R,children:[(0,X.jsx)(z,{...B}),T?i:l]})});function zp(e){return m(`MuiSwitch`,e)}var Bp=E(`MuiSwitch`,[`root`,`edgeStart`,`edgeEnd`,`switchBase`,`colorPrimary`,`colorSecondary`,`sizeSmall`,`sizeMedium`,`checked`,`disabled`,`input`,`thumb`,`track`]),Vp=e=>{let{classes:t,edge:n,size:r,color:i,checked:a,disabled:o}=e,s={root:[`root`,n&&`edge${U(n)}`,`size${U(r)}`],switchBase:[`switchBase`,`color${U(i)}`,a&&`checked`,o&&`disabled`],thumb:[`thumb`],track:[`track`],input:[`input`]},c=he(s,zp,t);return{...t,...c}},Hp=H(`span`,{name:`MuiSwitch`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.edge&&t[`edge${U(n.edge)}`],t[`size${U(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,[`& .${Bp.thumb}`]:{width:16,height:16},[`& .${Bp.switchBase}`]:{padding:4,[`&.${Bp.checked}`]:{transform:`translateX(16px)`}}}}]}),Up=H(Rp,{name:`MuiSwitch`,slot:`SwitchBase`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.switchBase,{[`& .${Bp.input}`]:t.input},n.color!=="default"&&t[`color${U(n.color)}`]]}})(ge(({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]}`,...Ee(e,[`left`,`transform`],{duration:e.transitions.duration.shortest}),[`&.${Bp.checked}`]:{transform:`translateX(20px)`},[`&.${Bp.disabled}`]:{color:e.vars?e.vars.palette.Switch.defaultDisabledColor:`${e.palette.mode===`light`?e.palette.grey[100]:e.palette.grey[600]}`},[`&.${Bp.checked} + .${Bp.track}`]:{opacity:.5},[`&.${Bp.disabled} + .${Bp.track}`]:{opacity:e.vars?e.vars.opacity.switchTrackDisabled:`${e.palette.mode===`light`?.12:.2}`},[`& .${Bp.input}`]:{left:`-100%`,width:`300%`}})),ge(({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(Re([`light`])).map(([t])=>({props:{color:t},style:{[`&.${Bp.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`}},[`&.${Bp.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)}`}},[`&.${Bp.checked} + .${Bp.track}`]:{backgroundColor:(e.vars||e).palette[t].main}}}))]}))),Wp=H(`span`,{name:`MuiSwitch`,slot:`Track`})(ge(({theme:e})=>({height:`100%`,width:`100%`,borderRadius:7,zIndex:-1,...Ee(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}`}))),Gp=H(`span`,{name:`MuiSwitch`,slot:`Thumb`})(ge(({theme:e})=>({boxShadow:(e.vars||e).shadows[1],backgroundColor:`currentColor`,boxSizing:`border-box`,border:`1px solid transparent`,width:20,height:20,borderRadius:`50%`}))),Kp=Y.forwardRef(function(e,t){let n=_e({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=Vp(d),p=l.input,m={slots:c,slotProps:l},[g,_]=$e(`root`,{className:h(f.root,r),elementType:Hp,externalForwardedProps:m,ownerState:d,additionalProps:{sx:s}}),[v,y]=$e(`thumb`,{className:f.thumb,elementType:Gp,externalForwardedProps:m,ownerState:d}),b=(0,X.jsx)(v,{...y}),[x,S]=$e(`track`,{className:f.track,elementType:Wp,externalForwardedProps:m,ownerState:d});return(0,X.jsxs)(g,{..._,children:[(0,X.jsx)(Up,{type:`checkbox`,icon:b,checkedIcon:b,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:V(typeof p==`function`?p(d):p,{role:`switch`})}}),(0,X.jsx)(x,{...S})]})});function qp(e,t){let n=e.name.toLowerCase();return n===`figma-desktop`?W(t,`Cần bật MCP trong Figma Desktop`,`Enable MCP in Figma Desktop`):n===`figma`?e.state===`disabled`?W(t,`Remote OAuth · chưa được Figma duyệt`,`Remote OAuth · not approved by Figma`):`Remote OAuth`:`${e.transport} · ${e.scope}`}function Jp(e,t,n){return e===`mcp-oauth-client-not-approved`&&t.toLowerCase()===`figma`?W(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`?W(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`?W(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`?W(n,`Đã hủy đăng nhập.`,`Sign in cancelled.`):W(n,`Không thể kết nối OAuth. Vui lòng thử lại.`,`Could not connect OAuth. Please try again.`)}function Yp({sessionRef:e,connection:t,onChanged:n,compact:r=!1}){let{locale:i}=ze(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,t=window.setTimeout(()=>void Ls(s.jobRef,e.signal).then(e=>{c(e),e.state===`completed`&&n()}).catch(()=>u(W(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 Is({action:r?`mcp.enable`:`mcp.disable`,sessionRef:e,connectionRef:t.connectionRef});`connections`in i?n(i):n()}catch{u(W(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 Is({action:`mcp.oauth`,sessionRef:e,connectionRef:t.connectionRef});if(`jobRef`in n)c(n);else throw Error(`mcp-oauth-job-missing`)}catch{u(W(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{o(!1)}},p=async()=>{s?.state===`running`&&await zs(s.jobRef).catch(()=>void 0),c(void 0),u(null)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Q,{direction:`row`,spacing:.75,sx:{alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`},children:[t.authState===`connected`&&(0,X.jsx)(er,{size:`small`,color:`success`,variant:`outlined`,icon:(0,X.jsx)(Op,{}),label:W(i,`Đã kết nối`,`Connected`)}),t.oauthSupported&&t.authState!==`connected`&&t.state!==`disabled`&&(0,X.jsx)(J,{size:`small`,variant:`outlined`,disabled:a,onClick:()=>void f(),children:`OAuth`}),t.toggleSupported&&(0,X.jsx)(_o,{title:t.state===`disabled`?W(i,`Bật ${t.name}`,`Enable ${t.name}`):W(i,`Tắt ${t.name}`,`Disable ${t.name}`),arrow:!0,children:(0,X.jsx)(`span`,{children:(0,X.jsx)(Kp,{size:r?`small`:`medium`,checked:t.state!==`disabled`,disabled:a,onChange:(e,t)=>void d(t),slotProps:{input:{"aria-label":t.state===`disabled`?W(i,`Bật ${t.name}`,`Enable ${t.name}`):W(i,`Tắt ${t.name}`,`Disable ${t.name}`)}}})})})]}),l&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`caption`,children:l}),(0,X.jsxs)(ce,{open:!!s,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,X.jsxs)(ue,{children:[t.name,` · OAuth`]}),(0,X.jsx)(ae,{children:(0,X.jsxs)(Q,{spacing:1.25,sx:{pt:.5},children:[s?.state===`running`&&!s.authorizationUrl&&(0,X.jsx)(q,{color:`text.secondary`,children:W(i,`Đang chuẩn bị đăng nhập…`,`Preparing sign in…`)}),s?.authorizationUrl&&(0,X.jsx)(J,{component:`a`,href:s.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,variant:`contained`,endIcon:(0,X.jsx)(kp,{}),children:W(i,`Mở trang đăng nhập`,`Open sign in`)}),s?.state===`completed`&&(0,X.jsx)(q,{color:`success.main`,children:W(i,`Đã kết nối MCP`,`MCP connected`)}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,X.jsx)(q,{color:`error`,children:Jp(s.reasonCode,t.name,i)})]})}),(0,X.jsx)(Np,{children:(0,X.jsx)(J,{color:`inherit`,onClick:()=>void p(),children:s?.state===`running`?W(i,`Hủy`,`Cancel`):W(i,`Đóng`,`Close`)})})]})]})}var Xp=K((0,X.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 Zp(e){return m(`MuiDialogContentText`,e)}E(`MuiDialogContentText`,[`root`]);var Qp=e=>{let{classes:t}=e,n=he({root:[`root`]},Zp,t);return{...t,...n}},$p=H(q,{shouldForwardProp:e=>Se(e)||e===`classes`,name:`MuiDialogContentText`,slot:`Root`})({}),em=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiDialogContentText`}),{children:r,className:i,...a}=n,o=Qp(a);return(0,X.jsx)($p,{component:`p`,variant:`body1`,color:`textSecondary`,ref:t,ownerState:a,className:h(o.root,i),...n,classes:o})});function tm({open:e,title:t,description:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){return(0,X.jsxs)(ce,{open:e,onClose:o,fullWidth:!0,maxWidth:`xs`,"aria-describedby":`piagent-confirm-dialog-description`,slotProps:{paper:{sx:{borderRadius:1,p:.5}}},children:[(0,X.jsxs)(ue,{sx:{display:`flex`,alignItems:`center`,gap:1.25,pb:1},children:[(0,X.jsx)(Z,{sx:{width:36,height:36,borderRadius:1,display:`grid`,placeItems:`center`,bgcolor:`warning.main`,color:`warning.contrastText`},children:(0,X.jsx)(Xp,{fontSize:`small`})}),(0,X.jsx)(q,{component:`span`,sx:{fontSize:`1.08rem`,fontWeight:700},children:t})]}),(0,X.jsx)(ae,{children:(0,X.jsx)(em,{id:`piagent-confirm-dialog-description`,sx:{color:`text.secondary`,lineHeight:1.65},children:n})}),(0,X.jsxs)(Np,{sx:{px:2.5,pb:2,gap:.75},children:[(0,X.jsx)(J,{color:`inherit`,onClick:o,autoFocus:!0,children:i}),(0,X.jsx)(J,{variant:`contained`,color:`warning`,onClick:a,children:r})]})]})}function nm({name:e,value:t}){return(0,X.jsxs)(Q,{direction:`row`,sx:{justifyContent:`space-between`,gap:3,py:.65},children:[(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:e}),(0,X.jsx)(q,{variant:`body2`,sx:{fontWeight:600},children:t})]})}var rm=(e,t)=>e?W(t,`Fast: bật`,`Fast: on`):W(t,`Fast: tắt`,`Fast: off`),im=e=>W(e,`Fast: main agent trả lời nhanh hơn trên model GPT (Codex); token tính vào quota gấp 2,5 lần. Model và mức suy luận không đổi.`,`Fast: the main agent answers faster on GPT (Codex) models; its tokens count 2.5 times toward the quota. Model and thinking level are unchanged.`),am={borderColor:`warning.main`,color:`warning.main`,fontWeight:700,bgcolor:e=>p(e.palette.warning.main,.14),"&:hover":{bgcolor:e=>p(e.palette.warning.main,.22),color:`warning.main`}};function om({title:e,label:t,icon:n,active:r,badge:i,tone:a,onClick:o}){let s={border:1,borderColor:r?`primary.main`:`divider`,bgcolor:r?`action.selected`:`transparent`,color:r?`primary.main`:`text.secondary`,borderRadius:1,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},...r&&a===`warning`?am:{}},c=t?(0,X.jsx)(J,{size:`small`,"aria-label":e,onClick:o,startIcon:n,sx:{...s,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,X.jsx)(Z,{component:`span`,sx:{display:{xs:`none`,md:`inline`},overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})}):(0,X.jsx)(Ze,{size:`small`,"aria-label":e,onClick:o,sx:{...s,width:34,height:34},children:n});return(0,X.jsx)(_o,{title:e,arrow:!0,children:i?(0,X.jsx)(Wn,{badgeContent:i,color:`primary`,max:9999,sx:{"& .MuiBadge-badge":{height:16,minWidth:16,px:.4,fontSize:9,fontWeight:700}},children:c}):c})}function sm({session:e,snapshot:t,connections:n,locale:r,onOpenChanges:i,canSetModel:a,canSetThinking:o,canSetPermission:s,onSetModel:c,onSetThinking:l,onSetPermission:u,onSetFast:d,onConnectionsChanged:f,placement:p=`composer`}){let[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(p!==`header`)return;let e=new AbortController;return ps(e.signal).then(y).catch(()=>void 0),()=>e.abort()},[p]);let O=e=>t=>{h(e),_(t.currentTarget)},k=()=>{h(null),_(null)},A=t?.sourceChanges,j=A?.workingTree.counts.files??0,M=t?.session.permissionProfile,[N,P]=(0,Y.useState)(M?.state===`known`?M.value??null:null);(0,Y.useEffect)(()=>{P(e.managedPermission??(M?.state===`known`?M.value??null:null))},[e.sessionRef,e.managedPermission,M?.state,M?.value]);let F=t?.usage.context,L=F?.state===`known`,R=L?F.tokens:e.contextUsage.usedTokens,z=L?F.contextWindow:e.contextUsage.contextWindow,B=L?F.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,V=B==null?`—`:`${Math.round(B)}%`,ee=t?.session.model.state===`known`&&t.session.model.value?t.session.model.value.modelRef:``,te=v?.models.find(e=>e.modelRef===ee)??(v?.models.length===1?v.models[0]:void 0),ne=e.modelLabel===`agent-watch-auto`||v?.models.length===1&&v.models[0].provider===`agent_watch_managed`,re=(0,Y.useMemo)(()=>e.managedThinkingLevels??te?.thinkingLevels??(ne?[]:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),[te,e.managedThinkingLevels,ne]),ae=async e=>{if(!(!e||!c)){x(!0),C(null);try{await c(e)}catch{C(W(r,`Chưa thể đổi model lúc này`,`Could not change the model right now`))}finally{x(!1)}}},oe=async e=>{if(l){x(!0),C(null);try{await l(e)}catch{C(W(r,`Chưa thể đổi thinking lúc này`,`Could not change thinking right now`))}finally{x(!1)}}},se=e.managedFast===`on`,ce=async()=>{if(!(!d||b)){x(!0);try{await d(!se),D({tone:`success`,text:se?W(r,`Đã tắt Fast. Các lượt sau chạy tốc độ thường.`,`Fast is off. The next calls run at standard speed.`):W(r,`Đã bật Fast: main agent trả lời nhanh hơn trên model GPT, token tính vào quota gấp 2,5 lần. Model và mức suy luận không đổi.`,`Fast is on: the main agent answers faster on GPT models, and its tokens count 2.5 times toward the quota. Model and thinking level are unchanged.`)})}catch(e){let t=e instanceof Error&&/managed-fast-unavailable|unavailable/.test(e.message);D({tone:`error`,text:t?W(r,`Harness của team không cho phép Fast.`,`The team's Harness does not allow Fast.`):W(r,`Chưa đổi được Fast. Thử lại.`,`Fast not changed. Try again.`)})}finally{x(!1)}}},ue=async t=>{if(!u)return;x(!0),C(null);let n=ne?cm(t,r):$(t,r);try{await u(t),P(t),D(ne&&e.liveState===`waiting-approval`?{tone:`info`,text:W(r,`Đã chuyển sang ${n}. Lệnh đang chờ vẫn cần bạn bấm Cho phép hoặc Từ chối; các lệnh sau theo ${n}.`,`Switched to ${n}. The command already waiting still needs Allow or Deny; the next ones follow ${n}.`)}:{tone:`success`,text:W(r,`Đã chuyển sang ${n}.`,`Switched to ${n}.`)})}catch(e){let t=e instanceof Error&&e.message===`session-runtime-busy`?W(r,`Chưa đổi được quyền: lượt này đang chạy. Đổi lại sau khi lượt xong.`,`Access not changed: this turn is running. Change it after the turn ends.`):W(r,`Chưa đổi được quyền. Thử lại.`,`Access not changed. Try again.`);C(t),D({tone:`error`,text:t})}finally{x(!1)}},de=e=>{if(e===`trusted-full-access`||e===`bypass`){k(),T(e);return}ue(e)},fe=m===`model`?`Model & thinking`:m===`context`?`Context`:m===`connections`?W(r,`MCP & kết nối`,`MCP & connections`):m===`permission`?W(r,`Quyền`,`Access`):W(r,`Source Changes`,`Source Changes`);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Z,{sx:{display:`flex`,gap:.65,mb:p===`composer`?.8:0,px:.1,flexWrap:p===`header`?`nowrap`:`wrap`,flexShrink:0,alignItems:`center`,justifyContent:p===`header`?`flex-end`:`flex-start`},children:[p===`header`&&ne&&(e.managedHelpers?.maximum??2)>0&&(0,X.jsxs)(q,{variant:`caption`,color:`text.secondary`,title:W(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:[W(r,`Subagent`,`Subagents`),` `,e.managedHelpers?.active??0,`/`,e.managedHelpers?.maximum??2]}),p===`header`&&(0,X.jsx)(om,{active:m===`model`,onClick:O(`model`),icon:(0,X.jsx)(Vf,{fontSize:`small`}),label:`${(ne?`agent-watch-auto`:e.modelLabel)??W(r,`Model session`,`Session model`)} · ${e.thinkingLevel===`unknown`||re.length>0&&!re.includes(e.thinkingLevel)?`—`:$(e.thinkingLevel,r)}`,title:ne?`agent-watch-auto · Thinking`:W(r,`Đổi model và mức suy luận`,`Change model and thinking level`)}),p===`header`&&(0,X.jsx)(om,{active:m===`permission`,onClick:O(`permission`),icon:(0,X.jsx)(Hf,{fontSize:`small`}),label:ne?cm(N,r):N?$(N,r):W(r,`Quyền`,`Access`),title:W(r,`Đổi quyền truy cập`,`Change access level`)}),p===`header`&&ne&&e.managedFast&&d&&(0,X.jsx)(om,{active:se,tone:`warning`,onClick:()=>void ce(),icon:(0,X.jsx)(Rf,{fontSize:`small`}),label:rm(se,r),title:se?W(r,`Fast đang bật: bấm để tắt (về tốc độ thường). Token tính vào quota gấp 2,5 lần.`,`Fast is on: click to turn it off (standard speed). Tokens count 2.5 times toward the quota.`):W(r,`Bật Fast: trả lời nhanh hơn, token tính vào quota gấp 2,5 lần`,`Turn Fast on: faster answers, tokens count 2.5 times toward the quota`)}),p===`composer`&&(0,X.jsx)(om,{active:m===`context`,onClick:O(`context`),icon:(0,X.jsx)(zf,{fontSize:`small`}),title:`Context · ${V}`}),p===`composer`&&(0,X.jsx)(om,{active:m===`connections`,onClick:O(`connections`),icon:(0,X.jsx)(Bf,{fontSize:`small`}),badge:n?.summary.configured??0,title:(n?.summary.configured??0)>0?W(r,`MCP & kết nối · ${n?.summary.configured}`,`MCP & connections · ${n?.summary.configured}`):W(r,`MCP & kết nối`,`MCP & connections`)}),p===`composer`&&(0,X.jsx)(om,{active:m===`changes`,onClick:O(`changes`),icon:(0,X.jsx)(So,{fontSize:`small`}),badge:j,title:`Source Changes${j?` · ${j}`:``}`})]}),(0,X.jsxs)(le,{open:m!==null,anchorEl:g,onClose:k,anchorOrigin:{vertical:p===`header`?`bottom`:`top`,horizontal:`left`},transformOrigin:{vertical:p===`header`?`top`:`bottom`,horizontal:`left`},slotProps:{paper:{sx:{width:330,maxWidth:`calc(100vw - 24px)`,borderRadius:1,p:1.5,mt:+(p===`header`)}}},children:[(0,X.jsx)(q,{sx:{px:.5,pb:1,fontWeight:600},children:fe}),(0,X.jsx)(or,{}),m===`model`&&(0,X.jsxs)(Q,{sx:{px:.5,pt:1},spacing:1.25,children:[ne?(0,X.jsxs)(Z,{children:[(0,X.jsx)(q,{children:`agent-watch-auto`}),(0,X.jsx)(nm,{name:`Context`,value:z?new Intl.NumberFormat().format(z):`—`})]}):(0,X.jsxs)(Z,{children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,X.jsx)(I,{fullWidth:!0,size:`small`,value:ee,disabled:!a||b||e.liveState===`running`,onChange:e=>void ae(e.target.value),sx:{mt:.5},children:(v?.models??[]).map(e=>(0,X.jsx)(np,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,X.jsxs)(Z,{children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,X.jsx)(I,{fullWidth:!0,size:`small`,inputProps:{"aria-label":`Thinking`},value:e.thinkingLevel===`unknown`?``:e.thinkingLevel,disabled:!o||b||e.liveState===`running`,onChange:e=>void oe(e.target.value),sx:{mt:.5},children:re.map(e=>(0,X.jsx)(np,{value:e,children:$(e,r)},e))})]}),S&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`caption`,children:S})]}),m===`context`&&(0,X.jsxs)(Z,{sx:{px:.5,pt:.75},children:[(0,X.jsx)(nm,{name:W(r,`Đã dùng`,`Used`),value:V}),(0,X.jsx)(nm,{name:`Tokens`,value:R===null?`—`:new Intl.NumberFormat().format(R)}),(0,X.jsx)(nm,{name:`Window`,value:z===null?`—`:new Intl.NumberFormat().format(z)})]}),m===`connections`&&(0,X.jsxs)(ie,{dense:!0,disablePadding:!0,sx:{pt:.5},children:[(n?.connections??[]).map(t=>(0,X.jsxs)(Qf,{sx:{alignItems:`center`,gap:.5},children:[(0,X.jsx)(Mr,{sx:{minWidth:38},children:(0,X.jsx)(Dp,{name:t.name,size:28})}),(0,X.jsx)(Lr,{primary:t.name,secondary:qp(t,r)}),(0,X.jsx)(Yp,{compact:!0,sessionRef:e.sessionRef,connection:t,onChanged:e=>f?.(e)})]},t.connectionRef)),n&&n.connections.length===0&&(0,X.jsx)(Qf,{children:(0,X.jsx)(Lr,{primary:W(r,`Chưa có MCP`,`No MCP configured`)})}),!n&&(0,X.jsx)(Qf,{children:(0,X.jsx)(Lr,{primary:W(r,`Đang đọc…`,`Loading…`)})})]}),m===`permission`&&(0,X.jsxs)(Q,{sx:{px:.5,pt:1},spacing:.75,children:[(ne?[`workspace-write`,`trusted-full-access`,...e.managedBypass?[`bypass`]:[]]:[`read-only`,`workspace-write`,`trusted-full-access`,`bypass`]).map(t=>(0,X.jsx)(J,{variant:N===t?`contained`:`outlined`,color:t===`bypass`?`error`:t===`trusted-full-access`?`warning`:`primary`,disabled:!s||b||!ne&&e.liveState===`running`,onClick:()=>de(t),sx:{justifyContent:`flex-start`},children:ne?cm(t,r):$(t,r)},t)),S&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`caption`,children:S})]}),m===`changes`&&(0,X.jsxs)(Z,{sx:{px:.5,pt:.75},children:[(0,X.jsx)(nm,{name:W(r,`Task changes`,`Task changes`),value:String(A?.task?.counts.files??0)}),(0,X.jsx)(nm,{name:W(r,`Working tree`,`Working tree`),value:String(A?.workingTree.counts.files??0)}),(0,X.jsx)(nm,{name:W(r,`Staged`,`Staged`),value:String(A?.staged.counts.files??0)}),(0,X.jsx)(J,{fullWidth:!0,variant:`outlined`,startIcon:(0,X.jsx)(So,{}),sx:{mt:1},onClick:()=>{k(),i()},children:W(r,`Mở Source Changes`,`Open Source Changes`)})]})]}),(0,X.jsx)(tm,{open:w!==null,title:w===`bypass`?W(r,`Bật Bypass?`,`Turn on Bypass?`):W(r,`Bật toàn quyền?`,`Enable full access?`),description:w===`bypass`?ne?um(r):lm(r):ne?dm(r):W(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:W(r,`Hủy`,`Cancel`),confirmLabel:w===`bypass`?W(r,`Bật Bypass`,`Turn on Bypass`):W(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>T(null),onConfirm:()=>{let e=w;T(null),e&&ue(e)}}),(0,X.jsx)(gp,{open:E!==null,autoHideDuration:E?.tone===`success`?4e3:12e3,onClose:()=>D(null),anchorOrigin:{vertical:`top`,horizontal:`center`},children:(0,X.jsx)(st,{severity:E?.tone??`info`,variant:`filled`,onClose:()=>D(null),role:E?.tone===`error`?`alert`:`status`,children:E?.text})})]})}function cm(e,t){return e===`bypass`?`Bypass`:e===`trusted-full-access`?W(t,`Toàn quyền`,`Full access`):W(t,`Hỏi trước`,`Ask first`)}function lm(e){return W(e,`Không hỏi, không chặn gì trong cuộc trò chuyện personal này: xoá, push, gửi ra ngoài, file được bảo vệ đều chạy luôn, như chế độ bypass của Codex. Output vẫn được che secret và /undo vẫn hoàn tác được từng lượt. Cuộc trò chuyện company theo công tắc Bypass trong Harness của Studio.`,`Nothing is asked or blocked in this personal conversation: deletes, pushes, external sends and protected files all run, as with Codex's bypass mode. Output is still redacted and /undo can still revert each turn. Company conversations follow the Bypass switch of the Studio Harness.`)}function um(e){return W(e,`Không hỏi gì nữa trong cuộc trò chuyện này: lệnh cần internet, Docker, chạy trên máy, push, deploy, migration đều chạy luôn, như bypass của Codex. Lệnh thường vẫn chạy trong sandbox, output vẫn che secret và /undo vẫn hoàn tác được. Admin Studio có thể tắt Bypass trong Harness.`,`Nothing is asked in this conversation any more: commands that need the internet, Docker or this machine, pushes, deploys and migrations all run, as with Codex's bypass. Plain commands still run in the sandbox, output is still redacted and /undo still works. A Studio administrator can turn Bypass off in the Harness.`)}function dm(e){return W(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 fm(e){return e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&e.keyCode!==229}var pm=K((0,X.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`),mm=K((0,X.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`),hm=K((0,X.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`),gm=K((0,X.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`),_m=K((0,X.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`),vm=K((0,X.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 ym(e){return m(`MuiListSubheader`,e)}E(`MuiListSubheader`,[`root`,`colorPrimary`,`colorInherit`,`gutters`,`inset`,`sticky`]);var bm=e=>{let{classes:t,color:n,disableGutters:r,inset:i,disableSticky:a}=e,o={root:[`root`,n!=="default"&&`color${U(n)}`,!r&&`gutters`,i&&`inset`,!a&&`sticky`]};return he(o,ym,t)},xm=H(`li`,{name:`MuiListSubheader`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color!=="default"&&t[`color${U(n.color)}`],!n.disableGutters&&t.gutters,n.inset&&t.inset,!n.disableSticky&&t.sticky]}})(ge(({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}}]}))),Sm=Y.forwardRef(function(e,t){let n=_e({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=bm(u);return(0,X.jsx)(xm,{as:a,className:h(d.root,r),ref:t,ownerState:u,...l})}),Cm=K((0,X.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`),wm=K((0,X.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`),Tm=K((0,X.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 Em(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 Dm(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 Om(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 km(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 Am=20,jm=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).toLowerCase();function Mm(e,t,n){let r=jm(t.replace(/^skill:/,``)),i=e=>jm(e.name).startsWith(r)?0:jm(e.name).includes(r)?1:jm(e.description).includes(r)?2:3,a=e=>e.origin===`piagent`?`Piagent`:`${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,Am).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`:W(n,`lệnh`,`command`)} ${a(e)}`,apply:(t,n)=>km(t,n,e)}))}function Nm({projectRef:e,value:t,onChange:n,locale:r,builtIns:i=[]}){let a=(0,Y.useRef)(null),o=(0,Y.useId)(),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(0),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null),y=e&&s!==null&&s<=t.length?s:null,b=y===null?null:Om(t,y),x=y===null||b?null:Em(t,y),S=b??x,C=b?`command`:`path`,w=S&&`${C}:${S.start}`!==d?S:null,T=w&&C===`path`?w.query:null;(0,Y.useEffect)(()=>{if(T===null||!e){g(null);return}let t=new AbortController,n=setTimeout(()=>{gc(e,T,t.signal).then(e=>{g({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)=>Dm(t,n,e)}))}),m(0)}).catch(()=>{t.signal.aborted||g({query:T,items:[]})})},90);return()=>{clearTimeout(n),t.abort()}},[e,T]);let E=!!(w&&C===`command`&&e&&_?.projectRef!==e);(0,Y.useEffect)(()=>{if(!E||!e)return;let t=new AbortController;return _c(e,t.signal).then(t=>v({projectRef:e,list:t.commands})).catch(()=>{t.signal.aborted||v({projectRef:e,list:[]})}),()=>t.abort()},[E,e]);let D=w?C===`path`?h?.items??null:_&&_.projectRef===e?Mm([...i,..._.list.filter(e=>!i.some(t=>t.name===e.name))],w.query,r):null:null;(0,Y.useEffect)(()=>{m(0)},[C,w?.query]);let O=!!(l&&w&&D&&a.current),k=O?D:[];(0,Y.useEffect)(()=>{O&&document.getElementById(`${o}-${p}`)?.scrollIntoView({block:`nearest`})},[O,p,o]);let A=(0,Y.useRef)(null);(0,Y.useLayoutEffect)(()=>{let e=A.current,n=a.current;!e||!n||e.text!==t||(A.current=null,n.focus(),n.setSelectionRange(e.caret,e.caret),c(e.caret))},[t]);let j=e=>{if(!w)return;let r=e.apply(t,w);A.current=r,n(r.text),c(r.caret)},M=e=>!O||e.nativeEvent.isComposing||e.keyCode===229?!1:e.key===`Escape`?(e.preventDefault(),f(`${C}:${w.start}`),!0):k.length?e.key===`ArrowDown`||e.key===`ArrowUp`?(e.preventDefault(),m(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(),j(k[Math.min(p,k.length-1)]),!0):!1,N=e=>e===`directory`?(0,X.jsx)(Tm,{fontSize:`small`,color:`primary`}):e===`file`?(0,X.jsx)(wm,{fontSize:`small`,color:`action`}):e===`skill`?(0,X.jsx)(Cm,{fontSize:`small`,color:`secondary`}):(0,X.jsx)(Co,{fontSize:`small`,color:`primary`}),P=C===`command`?W(r,`Lệnh và skill`,`Commands and skills`):W(r,`File và folder`,`Files and folders`),F=a.current,I=(0,X.jsx)(io,{open:O,anchorEl:F,placement:`top-start`,disablePortal:!0,sx:{zIndex:1350,width:Math.min(640,F?.clientWidth??640)},modifiers:[{name:`offset`,options:{offset:[0,10]}}],children:(0,X.jsxs)(ft,{elevation:8,sx:{borderRadius:1,overflow:`hidden`,display:`flex`,flexDirection:`column`,maxHeight:340},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,sx:{px:1.5,pt:1,pb:.5},children:C===`command`?W(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`):W(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,X.jsx)(Z,{component:`ul`,role:`listbox`,id:o,"aria-label":P,sx:{listStyle:`none`,m:0,p:.5,pt:0,overflowY:`auto`},children:k.map((e,t)=>(0,X.jsxs)(Z,{component:`li`,id:`${o}-${t}`,role:`option`,"aria-selected":t===p,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>m(t),onClick:()=>j(e),sx:{display:`flex`,alignItems:`center`,gap:1,minWidth:0,px:1,py:.55,borderRadius:1,cursor:`pointer`,bgcolor:t===p?`action.selected`:`transparent`},children:[N(e.icon),(0,X.jsx)(q,{noWrap:!0,sx:{flexShrink:0,maxWidth:`55%`,fontSize:14,fontWeight:600},children:e.label}),e.hint&&(0,X.jsx)(q,{noWrap:!0,variant:`caption`,sx:{flexShrink:0,maxWidth:`25%`,fontFamily:`monospace`},children:e.hint}),(0,X.jsx)(q,{noWrap:!0,variant:`caption`,color:`text.secondary`,sx:{minWidth:0},children:e.detail})]},e.key))}):(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,pb:1.25},children:C===`command`?W(r,`Không có lệnh hoặc skill khớp`,`No matching command or skill`):W(r,`Không có file hoặc folder khớp`,`No matching file or folder`)})]})}),L=e=>c(e.target.selectionStart??null);return{inputRef:a,menu:I,onKeyDown:M,track:L,inputProps:{onFocus:()=>u(!0),onBlur:()=>u(!1)},htmlInput:{onSelect:L,"aria-autocomplete":`list`,"aria-controls":O&&k.length?o:void 0,"aria-activedescendant":O&&k.length?`${o}-${p}`:void 0}}}var Pm=`new-chat`,Fm=`piagent.composer-drafts.v1`,Im=50,Lm=32768,Rm=12096e5,zm=null,Bm,Vm=new Map;function Hm(){if(zm)return zm;zm=new Map;try{let e=JSON.parse(window.localStorage.getItem(Fm)??`{}`),t=Date.now();for(let[n,r]of Object.entries(e??{}))typeof r?.text==`string`&&typeof r.savedAt==`number`&&t-r.savedAt<Rm&&zm.set(n,{text:r.text.slice(0,Lm),savedAt:r.savedAt})}catch{}return zm}function Um(){Bm!==void 0&&(window.clearTimeout(Bm),Bm=void 0);try{let e=[...Hm()].sort((e,t)=>t[1].savedAt-e[1].savedAt).slice(0,Im);window.localStorage.setItem(Fm,JSON.stringify(Object.fromEntries(e)))}catch{}}var Wm=!1;function Gm(){Wm||(Wm=!0,window.addEventListener(`pagehide`,Um)),Bm===void 0&&(Bm=window.setTimeout(Um,300))}function Km(e){return Hm().get(e)?.text??``}function qm(e,t){let n=Hm();if(t.trim())n.set(e,{text:t.slice(0,Lm),savedAt:Date.now()});else if(!n.delete(e))return;Gm()}function Jm(e){return Vm.get(e)}function Ym(e,t){t===null?Vm.delete(e):Vm.set(e,t)}var Xm=`piagent-composer-appended`;function Zm(e,t){let n=Km(e);qm(e,n.trim()?`${n.trimEnd()}\n\n${t}`:t),window.dispatchEvent(new CustomEvent(Xm,{detail:e}))}var Qm=`agent_watch_managed`;function $m(e,t,n){return e===`native-project-picker-unavailable`||e===`project-import-picker-failed`?W(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`?W(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?W(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.`):W(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 eh({active:e,defaultProjectRef:t,busy:n,error:r,onCancel:i,onCreate:a}){let{locale:o}=ze(),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(void 0),[d,f]=(0,Y.useState)(!1),p=l===null&&s?.models.length===1&&s.models[0].provider===`agent_watch_managed`,[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(``),[v,y]=(0,Y.useState)(``),[b,x]=(0,Y.useState)(`high`),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)(()=>Km(Pm)),A=e=>{k(e),qm(Pm,e)},[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(()=>Jm(`new-chat`)??[]),[F,I]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{Ym(Pm,N.length?N:null)},[N]);let[L,R]=(0,Y.useState)(!1),z=(0,Y.useRef)(0),[B,V]=(0,Y.useState)(null),[ee,ne]=(0,Y.useState)(null),[re,ie]=(0,Y.useState)(!1),[ae,se]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!e)return;let n=new AbortController;return c(void 0),h(!1),se(null),I(null),R(!1),C(!1),z.current=0,ps(n.signal).then(e=>{n.signal.aborted||(c(e),_(e.projects.some(e=>e.projectRef===t)?t:e.projects[0]?.projectRef??``),y(e.defaultModelRef??``),x(e.defaultThinkingLevel??`high`),D(null),T(!1))}).catch(()=>{n.signal.aborted||h(!0)}),u(void 0),xs(n.signal).then(e=>{n.signal.aborted||u(e)}).catch(()=>{n.signal.aborted||u(null)}),()=>n.abort()},[e,t]),(0,Y.useEffect)(()=>{if(!e)return;let t=e=>{hd(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,t),window.addEventListener(`drop`,t),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`drop`,t)}},[e]);let ce=s?.projects.find(e=>e.projectRef===g),le=Nm({projectRef:ce?.projectRef,value:O,onChange:A,locale:o}),ue=s?.models.find(e=>e.modelRef===v),de=!p&&ue?.provider===Qm,fe=p?[]:s?.models.filter(e=>e.provider===Qm)??[],pe=(p||de)&&ue?.managedFast===!0,me=p?s?.models??[]:s?.models.filter(e=>e.provider!==Qm)??[],he=async()=>{f(!0);try{let e=await Ss().catch(()=>null),t=await ps();c(t),u(e??await xs().catch(()=>null));let n=t.models.find(e=>e.provider===Qm);n&&(y(n.modelRef),ve())}catch{h(!0)}finally{f(!1)}},ge=s?.models.find(e=>e.modelRef===s.defaultModelRef),H=(0,Y.useMemo)(()=>ue?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[ue]);(0,Y.useEffect)(()=>{H.includes(b)||x(H.includes(`high`)?`high`:H[0]??`off`)},[v,H]);let _e=e=>t=>{V(e),ne(t.currentTarget)},ve=()=>{V(null),ne(null)},ye=async()=>{ie(!0),se(null);try{let e=await bs(),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),ve()}catch(e){e instanceof cs&&e.status===409?se(null):se($m(e instanceof cs?e.code:null,e instanceof cs?e.status:0,o))}finally{ie(!1)}},be=e=>{if(!e?.length)return;let t=[...N],n=!1,r=null;for(let i of[...e]){if(t.some(e=>e.name===i.name&&e.size===i.size&&e.lastModified===i.lastModified))continue;let e=ud(i.name);if(`refused`in e){r=`${i.name}: ${gd(e.refused,o)}`;continue}if(t.length===4){n=!0;continue}t.push(i)}P(t),I(r??(n?W(o,`Mỗi tin nhắn nhận tối đa 4 file.`,`Each message accepts at most 4 files.`):null))},xe=!n&&!m&&N.length<4,Se=(0,Y.useRef)(!1),Ce=()=>{Se.current||n||!ce||!O.trim()||(Se.current=!0,Promise.resolve(a({projectRef:g,placeRef:ce.placeRef,modelRef:v||null,thinkingLevel:b,permissionMode:E,...pe&&w?{fast:!0}:{},message:O,files:N})).finally(()=>{Se.current=!1}))};return(0,X.jsxs)(Z,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,X.jsx)(Z,{sx:{p:{xs:1.5,sm:2}},children:(0,X.jsx)(Ze,{"aria-label":W(o,`Quay lại`,`Back`),onClick:i,children:(0,X.jsx)(pm,{})})}),(0,X.jsxs)(Q,{sx:{flex:1,alignItems:`center`,justifyContent:`center`,px:2,pb:{xs:5,md:12}},spacing:4,children:[(0,X.jsx)(q,{component:`h1`,sx:{fontSize:{xs:`2rem`,md:`2.45rem`},fontWeight:500,letterSpacing:`-.035em`,textAlign:`center`},children:W(o,`Hôm nay làm gì?`,`What should we work on?`)}),(0,X.jsxs)(Z,{sx:{position:`relative`,width:`100%`,maxWidth:820,border:1,borderColor:L?`primary.main`:`divider`,borderStyle:L?`dashed`:`solid`,borderRadius:1,bgcolor:`background.paper`,p:1.25,boxShadow:`0 18px 55px rgba(0,0,0,.13)`},onDragEnter:e=>{hd(e.dataTransfer)&&(z.current+=1,R(!0))},onDragOver:e=>{hd(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=xe?`copy`:`none`)},onDragLeave:e=>{hd(e.dataTransfer)&&(--z.current,z.current<=0&&(z.current=0,R(!1)))},onDrop:e=>{hd(e.dataTransfer)&&(e.preventDefault(),z.current=0,R(!1),xe&&be(e.dataTransfer.files))},children:[L&&(0,X.jsxs)(Z,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:1,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,X.jsx)(q,{sx:{fontWeight:750},children:xe?W(o,`Thả tài liệu vào đây`,`Drop documents here`):N.length>=4?W(o,`Đã đủ 4 file cho tin nhắn đầu tiên`,`The first message already holds 4 files`):W(o,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),xe&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:W(o,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),!s&&!m?(0,X.jsxs)(Q,{direction:`row`,spacing:1.5,sx:{minHeight:126,alignItems:`center`,justifyContent:`center`},children:[(0,X.jsx)(De,{size:20}),(0,X.jsx)(q,{color:`text.secondary`,children:W(o,`Đang mở…`,`Opening…`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(te,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:3,maxRows:8,value:O,disabled:n||m,inputRef:le.inputRef,...le.inputProps,onChange:e=>{A(e.target.value),le.track(e)},onKeyDown:e=>{le.onKeyDown(e)||fm(e)&&(e.preventDefault(),Ce())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),xe&&be(e.clipboardData.files))},placeholder:W(o,`Nhắn cho Piagent… (@ để chọn file, folder)`,`Message Piagent… (@ for files and folders)`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:{maxLength:32768,...le.htmlInput}},sx:{px:.5}}),le.menu,N.length>0&&(0,X.jsx)(Q,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pt:.75},"aria-label":W(o,`File sẽ gửi cùng tin nhắn đầu tiên`,`Files for the first message`),children:N.map(e=>(0,X.jsx)(er,{size:`small`,variant:`outlined`,label:`${e.name} · ${fd(e.size)}`,onDelete:n?void 0:()=>{P(t=>t.filter(t=>t!==e)),I(null)},deleteIcon:(0,X.jsx)(lf,{"aria-label":`${W(o,`Bỏ`,`Remove`)} ${e.name}`,role:`button`})},`${e.name}:${e.size}:${e.lastModified}`))}),(0,X.jsx)(bf,{in:S,id:`piagent-new-session-options`,children:(0,X.jsxs)(Z,{sx:{mx:.35,mt:1,px:1.1,py:1,borderRadius:1,bgcolor:`action.hover`},children:[(0,X.jsx)(q,{variant:`caption`,sx:{display:`block`,mb:.75,fontWeight:750},children:W(o,`Tùy chọn cho tin nhắn đầu tiên`,`Options for the first message`)}),(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,X.jsx)(J,{size:`small`,color:`inherit`,startIcon:(0,X.jsx)(vm,{}),endIcon:(0,X.jsx)(hm,{}),onClick:_e(`thinking`),children:$(b,o)}),(0,X.jsx)(J,{size:`small`,color:`inherit`,startIcon:(0,X.jsx)(_m,{}),endIcon:(0,X.jsx)(hm,{}),onClick:_e(`permission`),children:p||de?cm(E,o):E?$(E,o):W(o,`Quyền theo profile`,`Profile access`)}),(0,X.jsxs)(J,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,X.jsx)(cf,{}),disabled:!xe,"aria-label":`${W(o,`Thêm file`,`Add files`)} (${N.length}/4)`,children:[W(o,`Đính kèm`,`Attach`),(0,X.jsx)(`input`,{type:`file`,hidden:!0,multiple:!0,disabled:!xe,accept:``,onChange:e=>{be(e.target.files),e.currentTarget.value=``}})]})]}),de&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.75},children:W(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,X.jsxs)(Q,{direction:`row`,sx:{mt:1,alignItems:`center`,gap:.65,flexWrap:`nowrap`,minWidth:0},children:[(0,X.jsx)(_o,{title:S?W(o,`Ẩn tùy chọn`,`Hide options`):W(o,`Thêm tùy chọn`,`More options`),children:(0,X.jsx)(Ze,{size:`small`,"aria-label":S?W(o,`Ẩn tùy chọn`,`Hide options`):W(o,`Thêm tùy chọn`,`More options`),"aria-expanded":S,"aria-controls":`piagent-new-session-options`,onClick:()=>C(e=>!e),sx:{flex:`0 0 auto`,bgcolor:S?`action.selected`:`transparent`},children:(0,X.jsx)(sf,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:S?`rotate(45deg)`:`none`}})})}),(0,X.jsx)(J,{size:`small`,color:`inherit`,startIcon:(0,X.jsx)(gm,{}),endIcon:(0,X.jsx)(hm,{}),onClick:_e(`project`),"aria-label":`${W(o,`Project`,`Project`)}: ${ce?.label??W(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,X.jsx)(Z,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:ce?.label??W(o,`Chọn project`,`Choose project`)})}),(0,X.jsx)(J,{size:`small`,color:`inherit`,startIcon:de?(0,X.jsx)(mm,{}):(0,X.jsx)(Vf,{}),endIcon:(0,X.jsx)(hm,{}),onClick:_e(`model`),"aria-label":`${W(o,`Model`,`Model`)}: ${de?W(o,`Công ty · agent-watch-auto`,`Company · agent-watch-auto`):ue?.displayName??ge?.displayName??W(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,X.jsx)(Z,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:de?W(o,`Công ty · agent-watch-auto`,`Company · agent-watch-auto`):ue?`${ue.displayName}${ue.modelRef===s?.defaultModelRef?W(o,` · mặc định`,` · default`):``}`:ge?.displayName??W(o,`Mặc định của Pi`,`Pi default`)})}),pe&&(0,X.jsx)(_o,{title:im(o),arrow:!0,children:(0,X.jsx)(J,{size:`small`,color:`inherit`,variant:`outlined`,startIcon:(0,X.jsx)(Rf,{}),"aria-pressed":w,"aria-label":`${rm(w,o)}. ${im(o)}`,onClick:()=>T(e=>!e),sx:{flex:`0 0 auto`,minWidth:0,px:{xs:.75,sm:1},borderRadius:1,borderColor:`divider`,color:`text.secondary`,"& .MuiButton-startIcon":{mr:{xs:0,sm:.65},ml:0},...w?am:{}},children:(0,X.jsx)(Z,{component:`span`,sx:{display:{xs:`none`,sm:`inline`},whiteSpace:`nowrap`},children:rm(w,o)})})}),(0,X.jsx)(Z,{sx:{flex:1,minWidth:0}}),(0,X.jsx)(Ze,{"aria-label":W(o,`Gửi`,`Send`),disabled:n||m||!ce||!O.trim(),onClick:Ce,sx:{flex:`0 0 auto`,bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,X.jsx)(df,{fontSize:`small`})})]}),pe&&w&&(0,X.jsx)(q,{variant:`caption`,sx:{display:`block`,px:.5,pt:.75,color:`warning.main`},children:im(o)})]}),(F||ae||r||m)&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`caption`,sx:{display:`block`,px:.5,pt:1},children:F??ae??r??W(o,`Không tải được lựa chọn`,`Could not load choices`)})]})]}),(0,X.jsxs)(oe,{anchorEl:ee,open:B===`project`,onClose:ve,slotProps:{paper:{sx:{width:310,maxHeight:380}}},children:[(s?.projects??[]).map(e=>(0,X.jsxs)(np,{selected:g===e.projectRef,onClick:()=>{_(e.projectRef),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(Dp,{name:`folder`,size:26})}),(0,X.jsx)(Lr,{primary:e.label,secondary:e.hint,slotProps:{secondary:{noWrap:!0,title:e.hint}}})]},e.projectRef)),(0,X.jsx)(or,{}),(0,X.jsxs)(np,{disabled:re||s?.projectImport?.status!==`available`,onClick:()=>void ye(),children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(sf,{})}),(0,X.jsx)(Lr,{primary:re?W(o,`Đang chọn…`,`Choosing…`):W(o,`Thêm một hoặc nhiều folder`,`Add one or more folders`)})]})]}),(0,X.jsxs)(oe,{anchorEl:ee,open:B===`model`,onClose:ve,slotProps:{paper:{sx:{width:360,maxHeight:440}}},children:[!p&&(fe.length>0||l?.available)&&[(0,X.jsx)(Sm,{children:W(o,`Công ty`,`Company`)},`company-heading`),...fe.length?fe.map(e=>(0,X.jsxs)(np,{selected:v===e.modelRef,onClick:()=>{y(e.modelRef),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(mm,{})}),(0,X.jsx)(Lr,{primary:`agent-watch-auto`,secondary:W(o,`Harness công ty · Studio quản lý model`,`Company Harness · models managed by Studio`)})]},e.modelRef)):[(0,X.jsxs)(np,{disabled:d,onClick:()=>void he(),children:[(0,X.jsx)(Mr,{children:d?(0,X.jsx)(De,{size:20}):(0,X.jsx)(mm,{})}),(0,X.jsx)(Lr,{primary:`agent-watch-auto`,secondary:d?W(o,`Đang kết nối…`,`Connecting…`):If(l,o),slotProps:{secondary:{sx:{whiteSpace:`normal`}}}})]},`company-connect`)],(0,X.jsx)(Sm,{children:W(o,`Cá nhân`,`Personal`)},`personal-heading`)],!s?.defaultModelRef&&(0,X.jsxs)(np,{selected:!v,onClick:()=>{y(``),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(Vf,{})}),(0,X.jsx)(Lr,{primary:W(o,`Model mặc định của Pi`,`Pi default model`)})]}),me.map(e=>(0,X.jsxs)(np,{selected:v===e.modelRef,onClick:()=>{y(e.modelRef),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(Dp,{name:e.provider,size:26})}),(0,X.jsx)(Lr,{primary:e.displayName,secondary:e.modelRef===s?.defaultModelRef?W(o,`Mặc định · ${e.provider} · High`,`Default · ${e.provider} · High`):e.provider})]},e.modelRef))]}),(0,X.jsx)(oe,{anchorEl:ee,open:B===`thinking`,onClose:ve,slotProps:{paper:{sx:{width:250,maxHeight:400}}},children:H.map(e=>(0,X.jsxs)(np,{value:e,selected:b===e,onClick:()=>{x(e),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(vm,{})}),(0,X.jsx)(Lr,{primary:$(e,o)})]},e))}),(0,X.jsx)(oe,{anchorEl:ee,open:B===`permission`,onClose:ve,slotProps:{paper:{sx:{width:310}}},children:p||de?[(0,X.jsxs)(np,{selected:E!==`trusted-full-access`&&E!==`bypass`,onClick:()=>{D(null),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(_m,{})}),(0,X.jsx)(Lr,{primary:cm(null,o),secondary:W(o,`Hỏi trước mỗi lệnh cần internet`,`Asks before each command that needs the internet`)})]},`ask`),(0,X.jsxs)(np,{selected:E===`trusted-full-access`,onClick:()=>{ve(),M(`trusted-full-access`)},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(_m,{color:`warning`})}),(0,X.jsx)(Lr,{primary:cm(`trusted-full-access`,o),secondary:W(o,`Chỉ hỏi việc bắt buộc phải xác nhận`,`Asks only what must be confirmed`)})]},`full`),...ue?.managedBypass?[(0,X.jsxs)(np,{selected:E===`bypass`,onClick:()=>{ve(),M(`bypass`)},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(_m,{color:`error`})}),(0,X.jsx)(Lr,{primary:`Bypass`,secondary:W(o,`Không hỏi gì; admin Studio có thể tắt`,`Asks nothing; a Studio administrator can turn it off`)})]},`bypass`)]:[]]:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(np,{selected:E===null,onClick:()=>{D(null),ve()},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(_m,{})}),(0,X.jsx)(Lr,{primary:W(o,`Theo profile project`,`Project profile default`)})]}),[`read-only`,`workspace-write`,`trusted-full-access`,`bypass`].map(e=>(0,X.jsxs)(np,{selected:E===e,onClick:()=>{ve(),e===`trusted-full-access`||e===`bypass`?M(e):D(e)},children:[(0,X.jsx)(Mr,{children:(0,X.jsx)(_m,{color:e===`bypass`?`error`:e===`trusted-full-access`?`warning`:void 0})}),(0,X.jsx)(Lr,{primary:$(e,o)})]},e))]})}),(0,X.jsx)(tm,{open:j!==null,title:j===`bypass`?W(o,`Tạo cuộc trò chuyện với Bypass?`,`Create with Bypass?`):W(o,`Tạo session với toàn quyền?`,`Create with full access?`),description:j===`bypass`?p||de?um(o):lm(o):p||de?dm(o):W(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:W(o,`Hủy`,`Cancel`),confirmLabel:j===`bypass`?W(o,`Dùng Bypass`,`Use Bypass`):W(o,`Dùng toàn quyền`,`Use full access`),onCancel:()=>M(null),onConfirm:()=>{let e=j;M(null),e&&D(e)}})]})}var th=(e,t,n)=>e===`vi`?t:n,nh=[[`⌘K`,`Mở bảng lệnh`,`Open the command palette`],[`⌘⇧O`,`Cuộc trò chuyện mới`,`New chat`],[`⌘,`,`Cài đặt`,`Settings`],[`⌘/`,`Phím tắt và lệnh /`,`Shortcuts and / commands`],[`Esc`,`Dừng lượt đang chạy (trong ô nhập)`,`Stop the running turn (in the composer)`]];function rh(e,t){let n=/^\/([a-z][a-z-]*)(?:\s+([\s\S]*))?$/.exec(e.trim()),r=n?t.find(e=>e.name===n[1]):void 0;return r?{command:r,argument:(n[2]??``).trim()}:null}var ih=(e,t,n,r)=>({tone:`error`,text:t instanceof Error&&t.message===`session-runtime-busy`?th(e,`${n}: lượt này đang chạy, thử lại khi xong.`,`${r}: this turn is running; try again when it ends.`):th(e,`${n}. Thử lại.`,`${r}. Try again.`)});async function ah(e,t,n,r,i){try{return await t(),n}catch(t){return ih(e,t,r,i)}}function oh(e){let{locale:t,actions:n}=e,r=(e,n)=>th(t,e,n),i=(e,t)=>({tone:`success`,text:r(e,t)}),a=(e,t)=>({tone:`warning`,text:r(e,t)}),o=[],s=(e,t,n,i,a)=>o.push({name:e,argumentHint:t,description:r(n,i),run:a});return s(`help`,null,`Danh sách lệnh / và phím tắt`,`The / commands and keyboard shortcuts`,async()=>({tone:`info`,text:[...o.map(e=>`/${e.name}${e.argumentHint?` ${e.argumentHint}`:``} — ${e.description}`),...nh.map(([e,t,n])=>`${e} — ${r(t,n)}`)].join(`
46
- `)})),s(`new`,null,`Cuộc trò chuyện mới`,`New chat`,async()=>(n.newChat(),i(`Đã mở cuộc trò chuyện mới.`,`Opened a new chat.`))),s(`stop`,null,`Dừng lượt đang chạy`,`Stop the running turn`,async()=>e.running?ah(t,n.stop,i(`Đã dừng lượt đang chạy.`,`Stopped the running turn.`),`Chưa dừng được`,`Could not stop`):{tone:`info`,text:r(`Không có lượt nào đang chạy.`,`No turn is running.`)}),s(`name`,`<tên>`,`Đổi tên cuộc trò chuyện`,`Rename the conversation`,async e=>e?ah(t,()=>n.rename(e.slice(0,200)),i(`Đã đổi tên thành “${e.slice(0,200)}”.`,`Renamed to “${e.slice(0,200)}”.`),`Chưa đổi được tên`,`Could not rename`):a(`Cách dùng: /name <tên mới>`,`Usage: /name <new name>`)),s(`fork`,null,`Tạo cuộc trò chuyện mới từ cuộc này`,`Fork this conversation`,async()=>ah(t,n.fork,i(`Đã tạo bản sao của cuộc trò chuyện.`,`Forked the conversation.`),`Chưa tạo được bản sao`,`Could not fork`)),s(`pin`,null,e.pinned?`Bỏ ghim cuộc trò chuyện`:`Ghim cuộc trò chuyện`,e.pinned?`Unpin the conversation`:`Pin the conversation`,async()=>ah(t,()=>n.pin(!e.pinned),e.pinned?i(`Đã bỏ ghim.`,`Unpinned.`):i(`Đã ghim.`,`Pinned.`),`Chưa đổi được ghim`,`Could not change the pin`)),s(`archive`,null,`Lưu trữ cuộc trò chuyện`,`Archive the conversation`,async()=>ah(t,n.archive,i(`Đã lưu trữ cuộc trò chuyện.`,`Archived the conversation.`),`Chưa lưu trữ được`,`Could not archive`)),e.thinkingLevels.length&&s(`thinking`,`<${e.thinkingLevels.join(`|`)}>`,`Đổi mức suy luận`,`Change the thinking level`,async r=>e.thinkingLevels.includes(r)?ah(t,()=>n.setThinking(r),i(`Đã đổi thinking sang ${r}.`,`Thinking is now ${r}.`),`Chưa đổi được thinking`,`Could not change thinking`):a(`Cách dùng: /thinking ${e.thinkingLevels.join(`|`)}`,`Usage: /thinking ${e.thinkingLevels.join(`|`)}`)),e.company?(s(`undo`,null,`Hoàn tác file mà lượt trước của agent đã sửa`,`Undo the files the agent's last turn changed`,async()=>({send:!0})),e.fast&&s(`fast`,`[on|off]`,`Bật/tắt Fast (Harness cho phép)`,`Turn Fast on or off (where the Harness allows it)`,async r=>{let o=r===`on`?!0:r===`off`?!1:r?null:e.fast!==`on`;return o===null?a(`Cách dùng: /fast on|off`,`Usage: /fast on|off`):ah(t,()=>n.setFast(o),o?i(`Đã bật Fast.`,`Fast is on.`):i(`Đã tắt Fast.`,`Fast is off.`),`Chưa đổi được Fast`,`Could not change Fast`)}),s(`bypass`,`<on|full|off>`,`Bypass (không hỏi gì), Toàn quyền (chỉ hỏi việc bắt buộc) hoặc Hỏi trước`,`Bypass (asks nothing), Full access (asks only what must be asked) or Ask first`,async o=>o===`off`?ah(t,()=>n.setPermission(`workspace-write`),i(`Đã chuyển sang Hỏi trước.`,`Switched to Ask first.`),`Chưa đổi được quyền`,`Access not changed`):o===`full`?{confirm:{title:r(`Bật Toàn quyền?`,`Turn on Full access?`),confirmLabel:r(`Bật Toàn quyền`,`Turn on Full access`),description:r(`Lệnh cần internet hoặc Docker chạy không hỏi; push, deploy và lệnh trên máy vẫn hỏi.`,`Commands that need the internet or Docker run without asking; pushes, deploys and commands on this machine still ask.`),run:()=>ah(t,()=>n.setPermission(`trusted-full-access`),i(`Đã bật Toàn quyền.`,`Full access is on.`),`Chưa đổi được quyền`,`Access not changed`)}}:o===`on`?e.bypass?{confirm:{title:r(`Bật Bypass?`,`Turn on Bypass?`),confirmLabel:r(`Bật Bypass`,`Turn on Bypass`),description:r(`Không hỏi gì nữa: internet, Docker, lệnh trên máy, push, deploy, migration đều chạy luôn. Lệnh thường vẫn trong sandbox; /undo vẫn dùng được.`,`Nothing is asked any more: internet, Docker, commands on this machine, pushes, deploys and migrations all run. Plain commands stay in the sandbox; /undo still works.`),run:()=>ah(t,()=>n.setPermission(`bypass`),i(`Đã bật Bypass.`,`Bypass is on.`),`Chưa đổi được quyền`,`Access not changed`)}}:a(`Harness của team đã tắt Bypass (admin Studio). Dùng /bypass full cho Toàn quyền.`,`The team's Harness has Bypass off (Studio administrator). Use /bypass full for Full access.`):a(`Cách dùng: /bypass on|full|off`,`Usage: /bypass on|full|off`))):(s(`model`,`<tên model>`,`Đổi model`,`Change the model`,async r=>{let o=await e.loadModels().catch(()=>[]),s=r.toLowerCase(),c=s?o.filter(e=>e.label.toLowerCase()===s||e.modelRef.toLowerCase()===s):[],l=c.length?c:s?o.filter(e=>e.label.toLowerCase().includes(s)||e.modelRef.toLowerCase().includes(s)):[];return l.length===1?ah(t,()=>n.setModel(l[0].modelRef),i(`Đã đổi model sang ${l[0].label}.`,`The model is now ${l[0].label}.`),`Chưa đổi được model`,`Could not change the model`):a(`Cách dùng: /model <tên>. Có: ${o.map(e=>e.label).slice(0,12).join(`, `)||`—`}`,`Usage: /model <name>. Available: ${o.map(e=>e.label).slice(0,12).join(`, `)||`—`}`)}),s(`permission`,`<read-only|ask|full|bypass>`,`Đổi quyền của cuộc trò chuyện`,`Change the conversation's access`,async e=>{let o=e===`read-only`?`read-only`:e===`ask`?`workspace-write`:e===`full`?`trusted-full-access`:e===`bypass`?`bypass`:null;if(!o)return a(`Cách dùng: /permission read-only|ask|full|bypass`,`Usage: /permission read-only|ask|full|bypass`);let s=()=>ah(t,()=>n.setPermission(o),i(`Đã đổi quyền sang ${e}.`,`Access is now ${e}.`),`Chưa đổi được quyền`,`Access not changed`);return o===`bypass`?{confirm:{title:r(`Bật Bypass?`,`Turn on Bypass?`),confirmLabel:r(`Bật Bypass`,`Turn on Bypass`),description:r(`Không hỏi, không chặn gì trong cuộc trò chuyện này (xoá, push, file được bảo vệ đều chạy luôn). Output vẫn che secret, /undo vẫn hoàn tác được.`,`Nothing is asked or blocked in this conversation (deletes, pushes and protected files all run). Output is still redacted and /undo still works.`),run:s}}:o===`trusted-full-access`?{confirm:{title:r(`Bật toàn quyền?`,`Enable full access?`),confirmLabel:r(`Bật toàn quyền`,`Enable full access`),description:r(`Session được đọc, sửa file và chạy command trong phạm vi runtime; xoá hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`The session may read and edit files and run commands within the runtime; destructive actions and external transfers still ask.`),run:s}}:s()})),s(`changes`,null,`Mở Source Changes`,`Open Source Changes`,async()=>(n.openChanges(),i(`Đã mở Source Changes.`,`Opened Source Changes.`))),s(`settings`,null,`Mở Cài đặt`,`Open Settings`,async()=>(n.openSettings(),i(`Đã mở Cài đặt.`,`Opened Settings.`))),o}var sh=`piagent dashboard`;function ch(){return(0,Y.useSyncExternalStore)(vt,_t,_t)}function lh({locale:e}){let[t,n]=(0,Y.useState)(!1);return(0,X.jsxs)(Q,{role:`alert`,spacing:2,sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,px:2,textAlign:`center`},children:[(0,X.jsx)(q,{variant:`h6`,component:`h1`,children:W(e,`Tab này đã hết phiên đăng nhập`,`This tab is no longer signed in`)}),(0,X.jsx)(q,{color:`text.secondary`,sx:{maxWidth:520},children:W(e,`Piagent vừa khởi động lại, tab không được dùng 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, this tab was unused for over 8 hours, or this tab came from an old link. Your conversations are kept — open Piagent again to continue.`)}),(0,X.jsxs)(Z,{sx:{display:`flex`,gap:1,alignItems:`center`,flexWrap:`wrap`,justifyContent:`center`},children:[(0,X.jsx)(Z,{component:`code`,sx:{px:1.5,py:.75,borderRadius:1,bgcolor:`action.hover`,fontSize:`.9rem`},children:sh}),(0,X.jsx)(J,{size:`small`,variant:`outlined`,onClick:()=>{navigator.clipboard?.writeText(sh).then(()=>n(!0),()=>n(!1))},children:t?W(e,`Đã chép`,`Copied`):W(e,`Chép lệnh`,`Copy command`)})]}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(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 uh=K((0,X.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`),dh=class extends Error{status;constructor(e,t){super(t),this.status=e}};async function fh(e,t){let n;if(t?.method===`POST`){let r=ht();if(!r)throw new dh(403,`mutation-authority-rejected`);n=await mt(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&&gt();let r=await n.json().catch(()=>null);if(!n.ok)throw new dh(n.status,typeof r?.error?.code==`string`?r.error.code:`request-${n.status}`);return r}var ph=e=>fh(`/api/v1/updates`,{signal:e}),mh=()=>fh(`/api/v1/updates/check`,{method:`POST`,body:`{}`}),hh=e=>fh(`/api/v1/updates/apply`,{method:`POST`,body:JSON.stringify({version:e})}),gh=e=>e?.job?.state===`starting`||e?.job?.state===`running`,_h=(0,Y.createContext)(null);function vh({children:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(!0),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),d=(0,Y.useRef)(!0),f=(0,Y.useCallback)(async()=>{try{if(await yt(),_t())return;let e=await ph();d.current&&(n(e),i(!0))}catch(e){d.current&&e instanceof dh&&e.status===404&&i(!1)}},[]),p=gh(t),m=t!==null||!r;(0,Y.useEffect)(()=>{d.current=!0,f();let e=setInterval(()=>void f(),m?p?3e3:6e4:2e3);return()=>{clearInterval(e)}},[f,p,m]),(0,Y.useEffect)(()=>()=>{d.current=!1},[]);let h=(0,Y.useCallback)(async()=>{o(!0),u(null);try{n(await mh())}catch(e){u(e instanceof Error?e.message:`update-unavailable`)}finally{o(!1)}},[]),g=(0,Y.useCallback)(async()=>{let e=t?.piagent.latest;if(e){c(!0),u(null);try{await hh(e),await f()}catch(e){u(e instanceof Error?e.message:`update-unavailable`),await f()}finally{c(!1)}}},[t?.piagent.latest,f]),_=(0,Y.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,X.jsx)(_h.Provider,{value:_,children:e})}function yh(){let e=(0,Y.useContext)(_h);if(!e)throw Error(`Piagent update state is missing`);return e}var bh=`~/.pi/piagent-update-job.log`;function xh(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?W(e,n[0],n[1]):W(e,`Chưa cập nhật được. Thử lại sau.`,`The update could not start. Try again later.`)}function Sh(e,t){return t.state===`succeeded`?t.reason===`dashboard-restart-failed`?{severity:`warning`,text:W(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:W(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`?W(e,`Lần cập nhật bị ngắt giữa chừng.`,`The update was interrupted.`):t.reason===`update-version-mismatch`?W(e,`Bản cài xong không đúng bản đã chọn.`,`The installed release is not the one chosen.`):W(e,`Lệnh cập nhật báo lỗi.`,`The update command failed.`)} ${W(e,`Chi tiết trong ${bh}.`,`Details are in ${bh}.`)}`}:null}function Ch(e,t){if(!t)return W(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 W(e,`vừa xong`,`just now`);if(n<60)return W(e,`${n} phút trước`,`${n} min ago`);let r=Math.round(n/60);return r<48?W(e,`${r} giờ trước`,`${r} h ago`):W(e,`${Math.round(r/24)} ngày trước`,`${Math.round(r/24)} days ago`)}function wh({name:e,detail:t,chip:n,tone:r}){return(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,X.jsxs)(Z,{sx:{minWidth:0},children:[(0,X.jsx)(q,{sx:{fontWeight:760},children:e}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:t})]}),(0,X.jsx)(er,{size:`small`,label:n,color:r,variant:r==="default"?`outlined`:`filled`,sx:{alignSelf:{xs:`flex-start`,sm:`center`}}})]})}function Th(e,t){let n=[];return t.piagent.updateAvailable&&n.push(W(e,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`,`Piagent ${t.piagent.installed} → ${t.piagent.latest}`)),t.pi.updateAvailable&&n.push(W(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(W(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 Eh(){let{locale:e}=ze(),{status:t,supported:n,checking:r,applying:i,error:a,check:o,apply:s}=yh(),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null),d=gh(t);if((0,Y.useEffect)(()=>{d&&!u.current?.closest(`[role=dialog]`)?.contains(document.activeElement)&&u.current?.focus()},[d]),!n)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{component:`h1`,variant:`h1`,sx:{mb:3},children:W(e,`Cập nhật`,`Updates`)}),(0,X.jsx)(st,{severity:`info`,children:W(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?Sh(e,f):null,m=(t?.runningConversations??0)>0,h=t?[W(e,`Đang dùng ${t.pi.installed??`—`}`,`Using ${t.pi.installed??`—`}`),t.pi.required?W(e,`Piagent ${t.piagent.latest} cần ${t.pi.required}`,`Piagent ${t.piagent.latest} needs ${t.pi.required}`):null].filter(Boolean).join(` · `):`—`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{component:`h1`,variant:`h1`,ref:u,tabIndex:-1,sx:{mb:1},children:W(e,`Cập nhật`,`Updates`)}),(0,X.jsx)(q,{color:`text.secondary`,sx:{mb:3},children:W(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,X.jsxs)(ft,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:[(0,X.jsx)(wh,{name:`Piagent`,detail:W(e,`Đang dùng ${t?.piagent.installed??`—`}`,`Using ${t?.piagent.installed??`—`}`),chip:t?.piagent.updateAvailable?W(e,`Có bản ${t.piagent.latest}`,`${t.piagent.latest} available`):t?.piagent.latest?W(e,`Mới nhất`,`Up to date`):W(e,`Chưa rõ`,`Unknown`),tone:t?.piagent.updateAvailable?`primary`:`default`}),(0,X.jsx)(or,{}),(0,X.jsx)(wh,{name:`Pi`,detail:h,chip:t?.pi.updateAvailable?W(e,`Lên ${t.pi.required}`,`To ${t.pi.required}`):W(e,`Đúng bản`,`Matches`),tone:t?.pi.updateAvailable?`primary`:`default`}),t?.pi.newerUntested&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(or,{}),(0,X.jsx)(Z,{sx:{px:2.25,py:1.5},children:(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(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,X.jsx)(or,{}),(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:1.5,p:2.25},children:[(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(e,`Kiểm tra lần cuối: ${Ch(e,t?.checkedAt??null)} · tự kiểm tra ${(t?.checkEveryHours??1)===1?`mỗi giờ`:`mỗi ${t?.checkEveryHours} giờ`}`,`Last checked: ${Ch(e,t?.checkedAt??null)} · checks every ${(t?.checkEveryHours??1)===1?`hour`:`${t?.checkEveryHours} hours`}`)}),(0,X.jsx)(J,{variant:`outlined`,disabled:r||d||!t?.installable,onClick:()=>void o(),startIcon:r?(0,X.jsx)(De,{size:14}):void 0,children:W(e,`Kiểm tra ngay`,`Check now`)})]})]}),(0,X.jsxs)(Z,{sx:{mt:2.5,display:`grid`,gap:1.5},children:[t&&!t.installable&&(0,X.jsx)(st,{severity:`info`,children:t.reason===`company-runtime`?W(e,`Đây là runtime công ty; cập nhật từ dashboard Piagent.`,`This is the company runtime; update from the Piagent dashboard.`):W(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,X.jsx)(st,{severity:`info`,icon:(0,X.jsx)(De,{size:18}),children:W(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,X.jsx)(st,{severity:p.severity,children:p.text}),!d&&f?.bindingChanged&&(0,X.jsx)(st,{severity:`warning`,children:W(e,`Bản mới đổi trình khởi chạy công ty: Agent Watch tự cập nhật cấu hình trong vài phút (cần Agent Watch đang chạy), rồi chế độ công ty dùng lại được.`,`The new release changed the company launcher: Agent Watch updates the configuration within a few minutes (it must be running), then company mode works again.`)}),a&&(0,X.jsx)(st,{severity:`error`,role:`alert`,children:xh(e,a)}),t?.installable&&t.updateAvailable&&!d&&(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},gap:1.5},children:[(0,X.jsx)(J,{variant:`contained`,size:`large`,startIcon:i?(0,X.jsx)(De,{size:16,color:`inherit`}):(0,X.jsx)(uh,{}),disabled:i||m,onClick:()=>l(!0),children:W(e,`Cập nhật lên Piagent ${t.piagent.latest}`,`Update to Piagent ${t.piagent.latest}`)}),m&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(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,X.jsxs)(ce,{open:c&&!!t,onClose:()=>l(!1),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-confirm`,children:[(0,X.jsx)(ue,{id:`piagent-update-confirm`,children:W(e,`Cập nhật Piagent?`,`Update Piagent?`)}),(0,X.jsx)(ae,{children:(0,X.jsx)(Z,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:t&&Th(e,t).map(e=>(0,X.jsx)(q,{component:`li`,variant:`body2`,children:e},e))})}),(0,X.jsxs)(Np,{children:[(0,X.jsx)(J,{onClick:()=>l(!1),children:W(e,`Để sau`,`Later`)}),(0,X.jsx)(J,{variant:`contained`,onClick:()=>{l(!1),s()},children:W(e,`Cập nhật`,`Update`)})]})]})]})}var Dh=`piagent-update-snooze`,Oh=`piagent-update-job-seen`,kh=36e5;function Ah(e){try{return window.localStorage.getItem(e)}catch{return null}}function jh(e,t){try{window.localStorage.setItem(e,t)}catch{}}function Mh(e,t){try{let n=JSON.parse(Ah(Dh)??`null`);return n?.version===e&&typeof n.until==`number`&&t<n.until}catch{return!1}}function Nh({locale:e,onDetails:t}){let{status:n,applying:r,error:i,apply:a}=yh(),[o,s]=(0,Y.useState)(()=>Date.now()),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=window.setInterval(()=>s(Date.now()),6e4);return()=>window.clearInterval(e)},[]);let f=n?.piagent.latest??null,p=n?.job??null;(0,Y.useEffect)(()=>{!p||p.state!==`succeeded`||Ah(Oh)===p.startedAt||(jh(Oh,p.startedAt),d(W(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&&!gh(n))&&c!==f&&!Mh(f,o),h=()=>{f&&(jh(Dh,JSON.stringify({version:f,until:Date.now()+kh})),l(f))},g=(n?.runningConversations??0)>0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(ce,{open:m,onClose:h,fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-update-offer`,children:[(0,X.jsxs)(ue,{id:`piagent-update-offer`,sx:{display:`flex`,alignItems:`center`,gap:1},children:[(0,X.jsx)(uh,{color:`primary`}),W(e,`Có bản Piagent mới: ${f}`,`Piagent ${f} is available`)]}),(0,X.jsxs)(ae,{sx:{display:`grid`,gap:1.5},children:[(0,X.jsx)(Z,{component:`ul`,sx:{m:0,pl:2.5,display:`grid`,gap:.75},children:n&&Th(e,n).map(e=>(0,X.jsx)(q,{component:`li`,variant:`body2`,children:e},e))}),g&&(0,X.jsx)(st,{severity:`info`,children:W(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,X.jsx)(st,{severity:`error`,children:xh(e,i)})]}),(0,X.jsxs)(Np,{sx:{flexWrap:`wrap`,gap:1},children:[(0,X.jsx)(J,{onClick:h,children:W(e,`Để sau (nhắc lại sau 1 giờ)`,`Later (ask again in an hour)`)}),(0,X.jsx)(J,{onClick:()=>{l(f),t()},children:W(e,`Xem chi tiết`,`Details`)}),(0,X.jsx)(J,{variant:`contained`,disabled:g||r,onClick:()=>{l(f),a().then(t)},children:W(e,`Cập nhật ngay`,`Update now`)})]})]}),(0,X.jsx)(gp,{open:u!==null,autoHideDuration:8e3,onClose:()=>d(null),anchorOrigin:{vertical:`top`,horizontal:`center`},children:(0,X.jsx)(st,{severity:`success`,variant:`filled`,onClose:()=>d(null),children:u})})]})}var Ph=K((0,X.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`);function Fh({active:e,snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i,refresh:a,findings:o,onSendComments:s}){let{locale:c}=ze();return(0,Y.useEffect)(()=>{let e=e=>{e.detail?.sessionRef===n&&a()};return window.addEventListener(`piagent-workspace-saved`,e),()=>window.removeEventListener(`piagent-workspace-saved`,e)},[n,a]),e===`source`?(0,X.jsx)(lu,{snapshot:t,sessionRef:n,refreshSnapshot:a,findings:o,onSendComments:s}):e===`documents`?(0,X.jsx)(Ou,{sessionRef:n}):e===`activity`?(0,X.jsx)(Fu,{snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i}):(0,X.jsxs)(Q,{spacing:2.25,children:[(0,X.jsx)(Zd,{snapshot:t,locale:c}),(0,X.jsx)(Yd,{snapshot:t,locale:c}),(0,X.jsx)(Hu,{snapshot:t})]})}var Ih=`min(44vw, 860px)`;function Lh({open:e,active:t,snapshot:n,state:r,sessionRef:i,terminalActivities:a,liveActivities:o,onClose:s,onActive:c,refresh:l,findings:u,onSendComments:d}){let{locale:f}=ze(),p=tf(T().breakpoints.up(`xl`)),m=n?.sourceChanges.workingTree.counts.files??0,h=o===void 0?n?.activity.running.length??0:o.filter(e=>e.state===`running`).length;return(0,X.jsxs)(Cr,{anchor:`right`,variant:p?`persistent`:`temporary`,open:e,onClose:s,sx:{"& .MuiDrawer-paper":{width:{xs:`100%`,sm:`min(88vw, 980px)`,xl:Ih},bgcolor:`background.default`}},children:[(0,X.jsxs)(Z,{sx:{position:`sticky`,top:0,zIndex:3,bgcolor:`background.paper`,borderBottom:1,borderColor:`divider`},children:[(0,X.jsxs)(Q,{direction:`row`,sx:{minHeight:64,px:{xs:1.5,md:2},alignItems:`center`,gap:1},children:[(0,X.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,X.jsx)(q,{sx:{fontWeight:820},children:W(f,`Agent Inspector`,`Agent Inspector`)}),(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:W(f,`Task contract · Git truth · verifier`,`Task contract · Git truth · verifier`)})]}),(0,X.jsx)(_o,{title:W(f,`Làm mới Inspector`,`Refresh Inspector`),children:(0,X.jsx)(Ze,{onClick:()=>void l(),children:(0,X.jsx)(uf,{fontSize:`small`})})}),(0,X.jsx)(Ze,{"aria-label":W(f,`Đóng Inspector`,`Close Inspector`),onClick:s,children:(0,X.jsx)(Ph,{})})]}),(0,X.jsxs)(ss,{value:t,onChange:(e,t)=>c(t),variant:`scrollable`,scrollButtons:`auto`,children:[(0,X.jsx)(Bo,{value:`task`,icon:(0,X.jsx)(yo,{}),iconPosition:`start`,label:n?.task?`${W(f,`Task`,`Task`)} · ${n.task.progress.completed}/${n.task.progress.total}`:W(f,`Task`,`Task`)}),(0,X.jsx)(Bo,{value:`source`,icon:(0,X.jsx)(So,{}),iconPosition:`start`,label:`Source Changes${m?` · ${m}`:``}`}),(0,X.jsx)(Bo,{value:`documents`,icon:(0,X.jsx)(xo,{}),iconPosition:`start`,label:W(f,`Tài liệu`,`Documents`)}),(0,X.jsx)(Bo,{value:`activity`,icon:(0,X.jsx)(Co,{}),iconPosition:`start`,label:`${W(f,`Activity`,`Activity`)}${h?` · ${h}`:``}`})]})]}),r===`loading`?(0,X.jsxs)(Q,{sx:{alignItems:`center`,py:12},spacing:1.5,children:[(0,X.jsx)(De,{size:25}),(0,X.jsx)(q,{color:`text.secondary`,children:W(f,`Đ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,X.jsx)(Z,{sx:{p:{xs:1.5,sm:2.5,xl:3},maxWidth:1500,mx:`auto`,width:`100%`},children:(0,X.jsx)(Fu,{sessionRef:i,terminalActivities:a,liveActivities:o})}):r===`error`||!n||!i?(0,X.jsxs)(Q,{sx:{p:3,maxWidth:720},spacing:2,children:[(0,X.jsx)(st,{severity:`warning`,children:W(f,`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,X.jsx)(J,{variant:`outlined`,onClick:()=>void l(),children:W(f,`Thử lại`,`Try again`)})]}):(0,X.jsx)(Z,{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,X.jsx)(Fh,{active:t,snapshot:n,sessionRef:i,terminalActivities:a,liveActivities:o,refresh:l,findings:u,onSendComments:d})})]})}var Rh=K((0,X.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`),zh=e=>Array.from({length:e},()=>({selected:[],other:``,otherOn:!1})),Bh=e=>e.selected.length>0||e.otherOn&&e.other.trim().length>0,Vh=(e,t)=>!e||e===`main`?W(t,`Main agent`,`Main agent`):W(t,`Subagent ${e}`,`Subagent ${e}`);function Hh({sessionRef:e,pending:t,locale:n,onDone:r}){let[i,a]=(0,Y.useState)(()=>zh(t.questions.length)),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(``),u=(0,Y.useRef)([]),d=(0,Y.useRef)(null),f=(0,Y.useRef)([]),[p,m]=(0,Y.useState)(0);(0,Y.useEffect)(()=>{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)},v=i.every(Bh),y=e=>{if(e.target.tagName===`INPUT`&&e.target.type===`text`)return;if(e.key===`Enter`){v&&(e.preventDefault(),x());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}))}},b=async(i,a)=>{s(a),l(``);try{await yc(e,t.questionRef,i),r()}catch(e){s(null),l(e.status===409?W(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.`):W(n,`Chưa gửi được câu trả lời. Thử lại.`,`The answer could not be sent. Try again.`))}},x=()=>{!v||o||b({answers:i.map(e=>({selected:[...e.selected].sort((e,t)=>e-t),...e.otherOn&&e.other.trim()?{other:e.other.trim()}:{}}))},`answer`)},S=t.questions.length;return(0,X.jsxs)(`article`,{className:`question-card`,ref:d,tabIndex:-1,onKeyDown:y,"aria-labelledby":`question-${t.questionRef}`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`section-kicker`,children:W(n,`${Vh(t.role,n)} cần bạn quyết định`,`${Vh(t.role,n)} needs your decision`)}),(0,X.jsx)(`h2`,{id:`question-${t.questionRef}`,children:S>1?W(n,`${S} câu hỏi`,`${S} questions`):W(n,`1 câu hỏi`,`1 question`)})]}),(0,X.jsx)(`span`,{className:`question-hint`,children:W(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,X.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,X.jsxs)(`legend`,{children:[S>1&&(0,X.jsxs)(`span`,{className:`question-number`,children:[r+1,`.`]}),e.header&&(0,X.jsx)(`span`,{className:`question-chip`,children:e.header}),(0,X.jsx)(`span`,{className:`question-text`,children:e.question})]}),e.multiSelect&&(0,X.jsx)(`p`,{className:`question-multi`,children:W(n,`Có thể chọn nhiều đáp án.`,`You can choose more than one.`)}),(0,X.jsxs)(`ol`,{className:`question-options`,children:[e.options.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`label`,{className:a.selected.includes(t)?`selected`:void 0,children:[(0,X.jsx)(`input`,{type:s,name:o,checked:a.selected.includes(t),onChange:()=>g(r,t)}),(0,X.jsx)(`span`,{className:`option-number`,"aria-hidden":`true`,children:t+1}),(0,X.jsxs)(`span`,{className:`option-body`,children:[(0,X.jsx)(`strong`,{children:e.label}),e.description&&(0,X.jsx)(`small`,{children:e.description})]})]})},t)),(0,X.jsxs)(`li`,{className:`question-other`,children:[(0,X.jsxs)(`label`,{className:a.otherOn?`selected`:void 0,children:[(0,X.jsx)(`input`,{type:s,name:o,checked:a.otherOn,onChange:()=>_(r,!e.multiSelect||!a.otherOn)}),(0,X.jsx)(`span`,{className:`option-number`,"aria-hidden":`true`,children:e.options.length+1}),(0,X.jsx)(`span`,{className:`option-body`,children:(0,X.jsx)(`strong`,{children:W(n,`Khác`,`Other`)})})]}),a.otherOn&&(0,X.jsx)(`input`,{type:`text`,ref:e=>{u.current[r]=e},maxLength:1e3,value:a.other,"aria-label":W(n,`Câu trả lời khác cho câu ${r+1}`,`Other answer to question ${r+1}`),placeholder:W(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(),x())}})]})]})]},o)}),c&&(0,X.jsx)(`p`,{className:`form-error`,role:`alert`,children:c}),(0,X.jsxs)(`footer`,{children:[(0,X.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!o,onClick:()=>void b({skipped:!0},`skip`),children:o===`skip`?W(n,`Đang gửi…`,`Sending…`):W(n,`Để agent tự quyết`,`Let the agent decide`)}),(0,X.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:!v||!!o,onClick:x,children:o===`answer`?W(n,`Đang gửi…`,`Sending…`):W(n,`Gửi câu trả lời`,`Send answer`)})]})]})}function Uh(e,t){let[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(0);return(0,Y.useEffect)(()=>{let t=new AbortController;return vc(e,t.signal).then(e=>r(e.questions??[]),()=>void 0),()=>t.abort()},[e,t,i]),(0,Y.useEffect)(()=>{if(!t&&!n.length)return;let e=setInterval(()=>a(e=>e+1),n.length?4e3:1500);return()=>clearInterval(e)},[t,n.length]),{pending:n,done:e=>r(t=>t.filter(t=>t.questionRef!==e))}}var Wh={main:0,scout:1,research:2,verify:3,review:4},Gh=e=>Wh[e]??5;function Kh(e){return[...e].sort((e,t)=>Gh(e.role)-Gh(t.role)||Date.parse(e.askedAt)-Date.parse(t.askedAt))}function qh(e){return!!(e&&!e.complete&&e.activities.some(e=>e.toolLabel===`ask_user`&&e.state===`running`))}function Jh(e,t){return qh(t)?`question`:e.liveState===`waiting-approval`?`approval`:e.needsAttention&&(e.liveState===`running`||e.liveState===`idle`)?`question`:null}function Yh(e,t){let n={};for(let r of e){if(r.archived)continue;let e=t[r.sessionRef];n[r.sessionRef]={running:!!(e&&!e.complete),need:Jh(r,e),operationRef:e?.operationRef??null}}return n}function Xh(e,t,n,r){let i=[];for(let a of n){let n=e[a.sessionRef],o=t[a.sessionRef];if(!n||!o)continue;let s=r[a.sessionRef],c=o.operationRef??n.operationRef??`turn`;if(o.need&&o.need!==n.need&&i.push({id:`${a.sessionRef}:${c}:${o.need}:${Date.now()}`,sessionRef:a.sessionRef,title:a.title,kind:o.need}),n.running&&!o.running){let e=s?.settlement===`aborted`?`stopped`:s?.error||s?.settlement===`error`||s?.settlement===`blocked`?`failed`:`done`;i.push({id:`${a.sessionRef}:${c}:${e}`,sessionRef:a.sessionRef,title:a.title,kind:e})}}return i}function Zh({sessionRef:e,waiting:t,approvalRefs:n}){let{locale:r}=ze(),i=Uh(e,t),a=Md(n,e,r),[o,s]=(0,Y.useState)(null),c=Kh([...i.pending.map(e=>({key:e.questionRef,kind:`question`,role:e.role??`main`,askedAt:e.askedAt,label:e.questions[0]?.header||e.questions[0]?.question||W(r,`Câu hỏi`,`Question`)})),...a.refs.map(e=>{let t=a.states[e]?.request;return{key:e,kind:`approval`,role:`main`,askedAt:t?.requestedAt??new Date(864e13).toISOString(),expiresAt:t?.expiresAt??null,label:t?t.action.commandPreview?.split(`
47
- `)[0]||t.action.toolName:W(r,`Yêu cầu duyệt`,`Approval`)}})]),l=c.find(e=>e.key===o)??c[0];(0,Y.useEffect)(()=>{o&&!c.some(e=>e.key===o)&&s(null)},[o,c.map(e=>e.key).join(`\0`)]);let u=l?.key??null;if((0,Y.useLayoutEffect)(()=>{if(!u)return;let e=requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight-window.innerHeight,behavior:`smooth`}));return()=>cancelAnimationFrame(e)},[u]),!l)return null;let d=c.indexOf(l);return(0,X.jsxs)(`section`,{className:`decision-queue`,"aria-label":W(r,`Việc đang chờ bạn quyết định`,`Decisions waiting for you`),"aria-live":`polite`,children:[c.length>1&&(0,X.jsxs)(`nav`,{className:`decision-steps`,"aria-label":W(r,`Các việc đang chờ`,`Waiting decisions`),children:[(0,X.jsx)(`strong`,{children:W(r,`Việc cần bạn quyết · ${d+1}/${c.length}`,`Needs your decision · ${d+1}/${c.length}`)}),(0,X.jsx)(`ol`,{children:c.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,"aria-current":e===l?`step`:void 0,className:e===l?`decision-step current`:`decision-step`,onClick:()=>s(e.key),title:`${Vh(e.role,r)} · ${e.label}`,children:[(0,X.jsx)(`span`,{className:`decision-step-number`,children:t+1}),(0,X.jsx)(`span`,{className:`decision-step-kind`,children:e.kind===`question`?W(r,`Hỏi`,`Ask`):W(r,`Duyệt`,`Approve`)}),(0,X.jsx)(`span`,{className:`decision-step-role`,children:Vh(e.role,r)}),(0,X.jsx)(`span`,{className:`decision-step-label`,children:e.label})]})},e.key))})]}),l.kind===`question`?(0,X.jsx)(Hh,{sessionRef:e,locale:r,onDone:()=>i.done(l.key),pending:i.pending.find(e=>e.questionRef===l.key)},l.key):(0,X.jsx)(jd,{state:a.states[l.key]??{},locale:r,asker:Vh(l.role,r),setState:e=>a.set(l.key,e)},l.key)]})}function Qh(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 $h(e,t){return e&&!t?`connected`:`reconnecting`}var eg=100,tg=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/,ng=/^[a-z0-9][a-z0-9.-]{0,95}$/,rg=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function ig(e,t){return typeof t==`string`&&ng.test(t)?t:e===`aborted`?`operation-aborted`:e===`blocked`?`operation-blocked`:e===`error`?`operation-failed`:`operation-settlement-unknown`}function ag(e){if(e.settlement===`completed`||typeof e.operationRef!=`string`||!tg.test(e.operationRef)||typeof e.settledAt!=`string`||!rg.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:ig(t,e.reasonCode),settledAt:e.settledAt,sequence:Number(e.sequence)}}function og(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,eg)}function sg(e){if(e.state!==`ready`)return{};let t={};for(let n of e.settlements??[]){let e=ag(n);e&&(t[n.sessionRef]=og(t[n.sessionRef]??[],[e]))}return t}function cg(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 lg(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 ug(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 dg(e,t,n){return!e||e.messageRequestId!==n||e.delivery===`admitted`?e:t}function fg(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 pg(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 mg=/(?: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 hg(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)||mg.test(t)||t.includes(`[REDACTED`)?null:t}function gg(e,t=`vi`,n=Date.now()){let r=[...e.activities].reverse().find(e=>e.state===`running`),i=r?pg(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=hg(r?.fileLabel),l=c?`${c} · ${s}`:s;return{label:t===`vi`?`Piagent đang ${i}…`:`Piagent is ${i}…`,detail:l}}function _g(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 vg(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 yg=new Set([`objection`,`rejudge`,`dispute`]);function bg(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=vg(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&&!yg.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=Qu(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`?$u(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 xg(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 Sg(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 Cg(e,t){return e<40||t<1e3?null:Math.round(e/4/(t/1e3))}function wg(e){return e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(+(e<1e4))}k`:`${(e/1e6).toFixed(1)}M`}var Tg=e=>`/api/v1/sessions/${encodeURIComponent(e)}/checkpoints`,Eg=`piagent-webui-checkpoint-v1`;function Dg(e){return Array.isArray(e)?`[${e.map(Dg).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${Dg(t)}`).join(`,`)}}`:JSON.stringify(e)}async function Og(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(e));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}var kg=e=>typeof e==`string`&&/^[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/.test(e),Ag=e=>typeof e==`string`&&/^[a-f0-9]{64}$/.test(e),jg=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,Mg=e=>Array.isArray(e)&&e.length<=1e4&&e.every(e=>jg(e,4096)),Ng=e=>typeof e==`string`&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(e)&&Number.isFinite(Date.parse(e));function Pg(e){return e&&[`projectRef`,`runtimeInstanceId`,`sessionRef`].every(t=>typeof e[t]==`string`&&/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(e[t]))&&[`taskId`,`taskRunId`,`agentOperationId`,`toolCallId`].every(t=>e[t]===null||typeof e[t]==`string`&&/^[A-Za-z0-9][A-Za-z0-9._:@~-]{0,159}$/.test(e[t]))}function Fg(e){return kg(e.targetId)&&[`ready`,`conflict`,`busy`,`none`,`unavailable`].includes(e.result)&&(e.previewDigest===null||Ag(e.previewDigest))&&(e.tree===null||typeof e.tree==`string`&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(e.tree))&&Array.isArray(e.steps)&&e.steps.length<=64&&e.steps.every(e=>e&&kg(e.id)&&jg(e.turnRef,256)&&Mg(e.restore)&&Mg(e.remove))&&Mg(e.files)&&Mg(e.conflicts)&&(e.stoppedAt===null||kg(e.stoppedAt))}async function Ig(e,t,n){let r=await fetch(Tg(e)+(t?`/${encodeURIComponent(t)}`:``),{credentials:`same-origin`,signal:n,headers:{Accept:`application/json`}});if(r.status===401&&gt(),!r.ok)throw Error(`checkpoint-unavailable`);let i=await r.json();if(!i||i.schemaVersion!==1||i.version!==Eg||i.identity?.sessionRef!==e||!Pg(i.identity)||i.messageType!==(t?`preview`:`state`)||!/^[a-f0-9]{64}$/.test(i.revisions?.checkpointRevision??``)||i.messageType===`state`&&(typeof i.available!=`boolean`||typeof i.agentRunning!=`boolean`||!Array.isArray(i.points)||i.points.length>64||!i.points.every(e=>e&&kg(e.id)&&jg(e.turnRef,256)&&Number.isSafeInteger(e.at)&&e.at>=0))||i.messageType===`preview`&&(i.targetId!==t||!Fg(i)))throw Error(`checkpoint-response-invalid`);return i}var Lg=(e,t)=>Ig(e,null,t),Rg=(e,t,n)=>Ig(e,t,n);async function zg(e){if(!Fg(e)||!Pg(e.identity)||!Ag(e.revisions?.checkpointRevision)||!e.previewDigest||!e.tree||!e.steps.length||![`ready`,`conflict`].includes(e.result))throw Error(`checkpoint-preview-unavailable`);let t=Date.now(),n=`checkpoint.restore`,r={...e.identity},i={...e.revisions},a={targetId:e.targetId,previewDigest:e.previewDigest,expectedTree:e.tree,confirmed:!0};return{schemaVersion:1,version:Eg,messageType:`command`,action:n,identity:r,expectedRevisions:i,payload:a,commandId:crypto.randomUUID(),idempotencyKey:crypto.randomUUID(),requestedAt:new Date(t).toISOString(),expiresAt:new Date(t+6e4).toISOString(),actionDigest:await Og(Dg({action:n,identity:r,expectedRevisions:i,payload:a}))}}async function Bg(e,t){let{action:n,identity:r,expectedRevisions:i,payload:a}=e;return e.schemaVersion===1&&e.version===Eg&&e.messageType===`command`&&n===`checkpoint.restore`&&Pg(r)&&r.sessionRef===t&&Ag(i?.checkpointRevision)&&a?.confirmed===!0&&kg(a.targetId)&&Ag(a.previewDigest)&&typeof a.expectedTree==`string`&&/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/.test(a.expectedTree)&&typeof e.commandId==`string`&&/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(e.commandId)&&typeof e.idempotencyKey==`string`&&/^[A-Za-z0-9._~-]{32,128}$/.test(e.idempotencyKey)&&Ng(e.requestedAt)&&Ng(e.expiresAt)&&e.actionDigest===await Og(Dg({action:n,identity:r,expectedRevisions:i,payload:a}))}async function Vg(e,t){if(!await Bg(t,e))throw Error(`checkpoint-command-invalid`);let n=ht();if(!n)throw Error(`checkpoint-unavailable`);let r=await mt(Tg(e),{method:`POST`,credentials:`same-origin`,headers:{Accept:`application/json`,"Content-Type":`application/json`,"X-Piagent-CSRF":n},body:JSON.stringify(t)});if(r.status===401&&gt(),!r.ok)throw Error(`checkpoint-unavailable`);let i=await r.json();if(!i||i.schemaVersion!==1||i.version!==Eg||i.messageType!==`receipt`||i.commandId!==t.commandId||i.actionDigest!==t.actionDigest||i.action!==t.action||i.targetId!==t.payload.targetId||i.idempotencyKeyDigest!==await Og(t.idempotencyKey)||Dg(i.identity)!==Dg(t.identity)||![`settled`,`rejected`,`uncertain`].includes(i.phase)||![`restored`,`conflict`,`stale-revision`,`identity-mismatch`,`read-only`,`busy`,`unavailable`,`expired`,`idempotency-payload-mismatch`,`effect-unknown`].includes(i.resultCode)||i.requestedAt!==t.requestedAt||!Ng(i.settledAt)||typeof i.deduplicated!=`boolean`||!Ag(i.observedRevisionsBefore?.checkpointRevision)||!Ag(i.observedRevisionsAfter?.checkpointRevision)||!Array.isArray(i.completed)||i.completed.length>64||!i.completed.every(kg)||!Mg(i.files)||!Mg(i.conflicts)||!(i.stoppedAt===null||kg(i.stoppedAt))||i.phase===`uncertain`!=(i.resultCode===`effect-unknown`)||i.resultCode===`restored`&&i.phase!==`settled`)throw Error(`checkpoint-receipt-invalid`);return i}var Hg=`piagent.checkpoint.pending.v1`,Ug=64;function Wg(e){let t=e.getItem(Hg);if(t===null)return Object.create(null);if(t.length>262144)throw Error(`checkpoint-pending-invalid`);let n=JSON.parse(t);if(!Array.isArray(n)||n.length>Ug)throw Error(`checkpoint-pending-invalid`);let r=Object.create(null);for(let e of n){if(!Array.isArray(e)||e.length!==2)throw Error(`checkpoint-pending-invalid`);let[t,n]=e;if(typeof t!=`string`||!/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(t)||r[t]||!n||n.schemaVersion!==1||n.version!==`piagent-webui-checkpoint-v1`||n.messageType!==`command`||n.action!==`checkpoint.restore`||n.identity?.sessionRef!==t||n.payload?.confirmed!==!0||typeof n.payload.targetId!=`string`||typeof n.commandId!=`string`||typeof n.idempotencyKey!=`string`)throw Error(`checkpoint-pending-invalid`);r[t]=n}return r}function Gg(e,t=window.sessionStorage){return Wg(t)[e]}function Kg(e,t,n=window.sessionStorage){let r=Wg(n),i=r[e];if(i&&JSON.stringify(i)!==JSON.stringify(t))throw Error(`checkpoint-pending-exists`);if(!i&&Object.keys(r).length>=Ug)throw Error(`checkpoint-pending-capacity`);if(t.identity.sessionRef!==e)throw Error(`checkpoint-pending-session`);r[e]=t;let a=JSON.stringify(Object.entries(r));if(a.length>262144)throw Error(`checkpoint-pending-capacity`);if(n.setItem(Hg,a),n.getItem(Hg)!==a)throw Error(`checkpoint-pending-write-failed`)}function qg(e,t,n=window.sessionStorage){let r=Wg(n);if(r[e]){if(JSON.stringify(r[e])!==JSON.stringify(t))throw Error(`checkpoint-pending-replaced`);delete r[e],n.setItem(Hg,JSON.stringify(Object.entries(r)))}}var Jg=(0,Y.createContext)(null);function Yg({turnRef:e}){let t=(0,Y.useContext)(Jg),n=t?.state?.points.find(t=>t.turnRef===e);return!t||!n?null:(0,X.jsx)(J,{size:`small`,disabled:t.busy||t.state?.agentRunning,onClick:()=>t.open(n.id),sx:{alignSelf:`flex-start`},children:W(t.locale,`Khôi phục về trước lượt này`,`Restore before this turn`)})}function Xg({sessionRef:e,refresh:t,running:n,locale:r,children:i}){let[a,o]=(0,Y.useState)(),[s,c]=(0,Y.useState)(0),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(),[_,v]=(0,Y.useState)(),[y,b]=(0,Y.useState)(!1),[x]=(0,Y.useState)(()=>{try{return{command:Gg(e),failed:!1}}catch{return{command:void 0,failed:!0}}}),[S,C]=(0,Y.useState)(x.command),[w,T]=(0,Y.useState)(x.failed),E=(0,Y.useRef)(null),D=(0,Y.useRef)(!1),O=(0,Y.useRef)(!0);(0,Y.useEffect)(()=>(O.current=!0,()=>{O.current=!1,E.current?.abort()}),[]),(0,Y.useEffect)(()=>{let t=new AbortController;return Lg(e,t.signal).then(e=>{t.signal.aborted||o(e)}).catch(()=>{}),()=>t.abort()},[e,t,s]);let k=t=>{if(u(!0),v(void 0),b(!1),S)return;E.current?.abort();let n=new AbortController;E.current=n,g(void 0),f(!0),Rg(e,t,n.signal).then(e=>{n.signal.aborted||g(e)}).catch(()=>{n.signal.aborted||b(!0)}).finally(()=>{n.signal.aborted||f(!1)})},A=async()=>{if(!(w||D.current||!S&&(!h||n||a?.agentRunning||![`ready`,`conflict`].includes(h.result)))){D.current=!0,m(!0),b(!1);try{let t=S??await zg(h);try{Kg(e,t)}catch{T(!0);return}C(t);let n=await Vg(e,t);if(n.phase!==`uncertain`&&qg(e,t),!O.current)return;v(n),n.phase!==`uncertain`&&C(void 0),c(e=>e+1)}catch{O.current&&b(!0)}finally{window.dispatchEvent(new CustomEvent(`piagent-workspace-changed`,{detail:{sessionRef:e}})),D.current=!1,O.current&&m(!1)}}},j=()=>{D.current||(E.current?.abort(),u(!1),f(!1))},M=_?.conflicts??h?.conflicts??[],N=_?.phase===`uncertain`||y&&!!S;return(0,X.jsxs)(Jg.Provider,{value:{state:a,busy:n||p||w,open:k,locale:r},children:[a&&!a.available&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:W(r,`Project không dùng Git nên không có checkpoint để khôi phục.`,`This project has no Git repository, so checkpoints are unavailable.`)}),S&&!l&&(0,X.jsx)(st,{severity:`warning`,action:(0,X.jsx)(J,{color:`inherit`,onClick:()=>k(S.payload.targetId),children:W(r,`Xem kết quả`,`Check result`)}),children:W(r,`Một lần khôi phục chưa có kết quả xác nhận.`,`A restore is awaiting a confirmed result.`)}),w&&!l&&(0,X.jsx)(st,{severity:`error`,children:W(r,`Không đọc hoặc lưu được yêu cầu khôi phục đang chờ trong trình duyệt. Chưa gửi yêu cầu mới; hãy kiểm tra file trước khi tiếp tục.`,`The browser could not read or save the pending restore. No new request was sent; inspect your files before continuing.`)}),i,(0,X.jsxs)(ce,{open:l,onClose:j,fullWidth:!0,maxWidth:`sm`,"aria-labelledby":`checkpoint-dialog-title`,children:[(0,X.jsx)(ue,{id:`checkpoint-dialog-title`,children:W(r,`Khôi phục về trước lượt này`,`Restore before this turn`)}),(0,X.jsx)(ae,{children:(0,X.jsxs)(Q,{spacing:2,children:[w&&(0,X.jsx)(st,{severity:`error`,children:W(r,`Không đọc hoặc lưu được yêu cầu khôi phục đang chờ trong trình duyệt. Chưa gửi yêu cầu mới; hãy kiểm tra file trước khi tiếp tục.`,`The browser could not read or save the pending restore. No new request was sent; inspect your files before continuing.`)}),d&&(0,X.jsx)(q,{children:W(r,`Đang xem trước…`,`Loading preview…`)}),h&&!_&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{children:W(r,`Sẽ hoàn tác ${h.steps.length} lượt từ mới nhất về lượt đã chọn. Commit và vùng stage được giữ nguyên.`,`Undo ${h.steps.length} turns from newest to the selected turn. Commits and staged changes are preserved.`)}),(0,X.jsx)(q,{variant:`body2`,sx:{whiteSpace:`pre-wrap`,maxHeight:240,overflow:`auto`},children:h.files.join(`
48
- `)}),![`ready`,`conflict`].includes(h.result)&&(0,X.jsx)(st,{severity:`info`,children:W(r,`Checkpoint hiện không thể khôi phục. Đóng hộp thoại rồi xem trước lại khi lượt chạy kết thúc.`,`This checkpoint cannot be restored now. Close this dialog and preview again after the running turn ends.`)})]}),M.length>0&&(0,X.jsxs)(st,{severity:`warning`,children:[W(r,`Sẽ dừng trước file đã thay đổi sau lượt: `,`Stop before files changed after the turn: `),M.join(`, `)]}),_&&!N&&(0,X.jsx)(st,{severity:_.resultCode===`restored`?`success`:`warning`,children:_.resultCode===`restored`?W(r,`Đã khôi phục ${_.completed.length} lượt.`,`Restored ${_.completed.length} turns.`):_.resultCode===`conflict`?W(r,`Đã khôi phục ${_.completed.length} lượt và dừng để giữ thay đổi của bạn.`,`Restored ${_.completed.length} turns and stopped to preserve your changes.`):W(r,`Chưa khôi phục: trạng thái hoặc quyền đã thay đổi. Đóng hộp thoại và xem trước lại.`,`Not restored: state or permissions changed. Close this dialog and preview again.`)}),N&&(0,X.jsx)(st,{severity:`warning`,children:W(r,`Chưa xác nhận được kết quả; một số file có thể đã thay đổi. Kiểm tra file trước khi tiếp tục. Nút bên dưới chỉ kiểm tra lại cùng yêu cầu.`,`The result is unconfirmed; some files may have changed. Inspect them before continuing. The button below checks the same request.`)}),y&&!S&&(0,X.jsx)(st,{severity:`error`,children:W(r,`Không tải được preview. Đóng hộp thoại và thử lại.`,`Could not load the preview. Close this dialog and try again.`)})]})}),(0,X.jsxs)(Np,{children:[(0,X.jsx)(J,{disabled:p,onClick:j,children:W(r,`Đóng`,`Close`)}),(!_||N)&&(0,X.jsx)(J,{variant:`contained`,disabled:w||p||d||!S&&(n||a?.agentRunning||!h?.steps.length||![`ready`,`conflict`].includes(h?.result??``)),onClick:()=>void A(),children:S?W(r,`Kiểm tra lại kết quả`,`Check result again`):W(r,`Xác nhận khôi phục`,`Confirm restore`)})]})]})]})}var Zg=K((0,X.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 Qg(e){return m(`MuiAlertTitle`,e)}E(`MuiAlertTitle`,[`root`]);var $g=e=>{let{classes:t}=e;return he({root:[`root`]},Qg,t)},e_=H(q,{name:`MuiAlertTitle`,slot:`Root`})(ge(({theme:e})=>({fontWeight:e.typography.fontWeightMedium,marginTop:-2}))),t_=Y.forwardRef(function(e,t){let n=_e({props:e,name:`MuiAlertTitle`}),{className:r,...i}=n,a=n,o=$g(a);return(0,X.jsx)(e_,{gutterBottom:!0,component:`div`,ownerState:a,ref:t,className:h(o.root,r),...i})}),n_=K((0,X.jsx)(`path`,{d:`M22 11V3h-7v3H9V3H2v8h7V8h2v10h4v3h7v-8h-7v3h-2V8h2v3zM7 9H4V5h3zm10 6h3v4h-3zm0-10h3v4h-3z`}),`AccountTreeOutlined`),r_=K((0,X.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`),i_=K((0,X.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`),a_=K((0,X.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`),o_=K((0,X.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`),s_=K((0,X.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`),c_=K((0,X.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`),l_=K((0,X.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`),u_=K((0,X.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`),d_=K((0,X.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`),f_=K((0,X.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`),p_=K((0,X.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 m_(e){return{color:`${e}.dark`,'html[data-piagent-color-mode="dark"] &':{color:`${e}.main`}}}var h_=`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,g_={read:wm,write:u_,edit:s_,command:Co,search:hu,list:gm,"web-search":p_,"web-fetch":l_,subagent:n_,network:d_,docker:f_,git:a_,plan:i_,other:r_},__={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`]},v_={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 y_(e){return v_[e.toLowerCase()]??`other`}function b_({preview:e}){return(0,X.jsx)(Z,{component:`pre`,sx:{m:0,fontFamily:h_,fontSize:12,lineHeight:1.55,overflowX:`auto`},children:e.split(`
49
- `).map((e,t)=>{let n=e[0],r=n===`+`?`success`:n===`-`?`error`:null;return(0,X.jsx)(Z,{component:`div`,sx:{px:1,whiteSpace:`pre`,...r?m_(r):{color:e===`@@`?`text.disabled`:`text.secondary`},bgcolor:r?`rgba(var(--piagent-palette-${r}-mainChannel) / .12)`:`transparent`},children:e===`@@`?`⋯`:e||` `},t)})})}function x_({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:Of(e.failure.reasonCode,e.failure.code,t)}:null,l=n?e.state===`running`:e.state===`requested`,[u,d]=(0,Y.useState)(()=>s||(i.kind===`edit`||i.kind===`write`)&&!!a?.preview),f=!!(a?.preview||o?.text||c?.copy||i.detail&&i.kind!==`read`),p=r?c_:g_[i.kind],m=__[i.kind][t===`vi`?0:1],h=i.kind===`other`?e.toolName:m;return(0,X.jsxs)(Z,{sx:{border:1,borderColor:s?`error.main`:`divider`,borderRadius:1,bgcolor:`background.paper`,overflow:`hidden`},children:[(0,X.jsxs)(Le,{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,X.jsx)(p,{sx:{fontSize:17,color:s?`error.main`:`text.secondary`,flexShrink:0}}),(0,X.jsx)(q,{variant:`body2`,sx:{fontWeight:600,flexShrink:0},children:h}),i.target&&(0,X.jsx)(q,{variant:`body2`,noWrap:!0,title:i.target,sx:{fontFamily:h_,fontSize:12.5,color:`text.secondary`,minWidth:0,flex:1},children:i.target}),!i.target&&(0,X.jsx)(Z,{sx:{flex:1}}),i.kind===`read`&&i.detail&&(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{flexShrink:0},children:W(t,`dòng ${i.detail}`,`lines ${i.detail}`)}),a&&(a.added>0||a.removed>0)&&(0,X.jsxs)(q,{variant:`caption`,sx:{fontFamily:h_,flexShrink:0},children:[a.added>0&&(0,X.jsxs)(Z,{component:`span`,sx:m_(`success`),children:[`+`,a.added,` `]}),a.removed>0&&(0,X.jsxs)(Z,{component:`span`,sx:m_(`error`),children:[`−`,a.removed]})]}),s&&!l&&(0,X.jsx)(q,{variant:`caption`,sx:{flexShrink:0,fontWeight:600,...m_(`error`)},children:W(t,`Lỗi`,`Failed`)}),l?(0,X.jsx)(De,{size:14,thickness:5,"aria-label":W(t,`Đang chạy`,`Running`)}):s?(0,X.jsx)(Ph,{sx:{fontSize:16,color:`error.main`},"aria-hidden":`true`}):(0,X.jsx)(o_,{sx:{fontSize:16,color:`success.main`},"aria-label":W(t,`Xong`,`Done`)}),f&&(0,X.jsx)(hm,{sx:{fontSize:18,color:`text.disabled`,transition:`transform .15s`,transform:u?`rotate(180deg)`:`none`}})]}),i.target&&[`read`,`write`,`edit`].includes(i.kind)&&(0,X.jsx)(No,{path:i.target,line:Number.parseInt(i.detail??`1`,10)||1}),(0,X.jsx)(bf,{in:u&&f,unmountOnExit:!0,children:(0,X.jsxs)(Z,{sx:{borderTop:1,borderColor:`divider`,bgcolor:`action.hover`,maxHeight:360,overflow:`auto`},children:[i.detail&&i.kind!==`read`&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{px:1.25,py:.75,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,...i.kind===`command`?{fontFamily:h_,fontSize:12}:{}},children:i.detail}),c?.copy&&(0,X.jsxs)(Z,{sx:{px:1.25,py:.75},children:[(0,X.jsxs)(q,{variant:`body2`,sx:{fontWeight:650,...m_(`error`)},children:[jf(c.detail.role,t),` `,W(t,`lỗi`,`failed`),` · `,c.copy.title]}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:c.copy.text}),(0,X.jsxs)(q,{variant:`caption`,color:`text.secondary`,sx:{fontFamily:h_,overflowWrap:`anywhere`},title:c.detail.requestRef??void 0,children:[W(t,`Mã`,`Code`),`: `,c.detail.code,c.detail.requestRef?` · request ${c.detail.requestRef.slice(0,8)}`:``]})]}),a?.preview&&(0,X.jsx)(Z,{sx:{py:.5},children:(0,X.jsx)(b_,{preview:a.preview})}),o?.text&&!c?.copy&&(0,X.jsx)(Z,{component:`pre`,sx:{m:0,px:1.25,py:.75,fontFamily:h_,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,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,px:1.25,pb:.75},children:W(t,`Đã rút gọn`,`Truncated`)})]})})]})}var S_=K((0,X.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`),C_=K((0,X.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`),w_=(e,t,n)=>e===`vi`?t:n,T_={blocking:[`blocking`,`blocking`],major:[`major`,`major`],minor:[`minor`,`minor`]},E_={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`]},D_={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 O_(e,t){let n=[];return e.outcome===`interrupted`?w_(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?w_(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`):w_(t,`Main agent và subagent conflict, bạn quyết định`,`The main agent and a subagent disagree; your call`)),e.unchanged?n.join(` · `)||w_(t,`Không đổi code`,`No code changed`):(e.verified?n.push(w_(t,`Check đã pass trên code cuối`,`A check passed on the final code`)):e.verifyPolicy!==`off`&&n.push(w_(t,`Chưa có check pass trên code cuối`,`No check passed on the final code`)),e.reviewed?n.push(e.blockingOpen?w_(t,`Còn ${e.blockingOpen} lỗi blocking chưa fix`,`${e.blockingOpen} blocking issue(s) still open`):w_(t,`Review không có lỗi blocking`,`Review found no blocking issue`)):e.reviewPolicy!==`off`&&n.push(e.outcome===`review_unavailable`?w_(t,`Không chạy được review`,`The review could not run`)+(e.reviewUnavailable&&D_[e.reviewUnavailable]?` (${w_(t,...D_[e.reviewUnavailable])})`:``):w_(t,`Chưa review`,`Not reviewed`)),e.planSkipped&&n.push(w_(t,`Đã sửa code khi chưa có plan`,`Code was changed before a plan existed`)),e.planOpen&&n.push(w_(t,`Plan còn ${e.planOpen} bước chưa xong`,`${e.planOpen} plan step(s) not completed`)),n.join(` · `)||w_(t,`Đã đổi code`,`Code changed`)))}function k_(e,t){let n=e.loop&&e.maxLoops?w_(t,` (vòng ${e.loop}/${e.maxLoops})`,` (round ${e.loop}/${e.maxLoops})`):``,r=Df(e.role??`review`,t),i=(e.findings??e.claims??e.issues??[]).length;switch(e.phase){case`continue`:return w_(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 w_(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 w_(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 w_(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 w_(t,`${r} phản biện brief của main agent`,`${r} objected to the main agent's brief`);case`answer`:return w_(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 w_(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`?w_(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`):w_(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`undo`:{let n=e.undo,r=n?.files?.length?` (${n.files.join(`, `)})`:``;return n?.result===`done`?w_(t,`Đã hoàn tác lượt trước: ${n.restored} file trả về như trước, ${n.removed} file lượt đó tạo đã xoá${r}.${n.more?` Gửi /undo lần nữa để hoàn tác lượt trước nữa.`:``} Commit trong lượt đó vẫn giữ.`,`Undid the last turn: ${n.restored} file(s) restored, ${n.removed} file(s) it created removed${r}.${n.more?` Send /undo again to undo the turn before.`:``} Commits made in that turn stay.`):n?.result===`refused`?w_(t,`Không hoàn tác: file lượt trước đã sửa lại bị đổi tiếp sau đó${r}; hoàn tác sẽ ghi đè thay đổi đó.`,`Not undone: a file the last turn changed was changed again since${r}; undoing would overwrite that change.`):n?.result===`busy`?w_(t,`Đang có một lượt chạy: chờ nó xong (hoặc dừng nó) rồi /undo.`,`A turn is running: wait for it (or stop it), then /undo.`):n?.result===`none`?w_(t,`Không có lượt nào để hoàn tác (chỉ áp dụng cho project là git repository, từ khi mở cuộc trò chuyện).`,`There is no turn to undo (git repositories only, since the conversation opened).`):w_(t,`Không đọc được trạng thái project; không hoàn tác.`,`The project's state could not be read; nothing was undone.`)}case`dispute`:return w_(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 A_(e,t){return(e.findings??[]).map(e=>({tag:w_(t,...T_[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:w_(t,...E_[e.kind]??[e.kind,e.kind]),tone:`warning`,location:null,text:e.detail})))}var j_={clean:`success`,disputed:`warning`,blocking_open:`error`,unverified:`warning`,unreviewed:`warning`,review_unavailable:`warning`,interrupted:`warning`,no_change:`info`};function M_(e,t){return O_(e,t)}var N_=e=>e?j_[e]:`info`,P_=e=>{let t=N_(e.outcome);return t===`success`&&(e.planSkipped||e.planOpen)?`warning`:t},F_={fontFamily:`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,fontSize:12.5};function I_({process:e,locale:t}){let n=A_(e,t).map(e=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Z,{component:`span`,sx:{fontWeight:600,...m_(e.tone)},children:[`[`,e.tag,`]`]}),e.location&&(0,X.jsxs)(Z,{component:`span`,sx:F_,children:[` `,e.location]}),e.location?` — `:` `,e.text]}));return n.length>0?(0,X.jsx)(Z,{component:`ol`,sx:{m:0,pl:3.5},children:n.map((e,t)=>(0,X.jsx)(q,{component:`li`,variant:`body2`,sx:{overflowWrap:`anywhere`},children:e},t))}):null}function L_({process:e,locale:t}){if(e.phase===`final`){let n=P_(e),r=n===`success`?Op:n===`error`?Rh:Xp;return(0,X.jsxs)(Q,{direction:`row`,role:`status`,"aria-label":W(t,`Tiến trình của lượt`,`Turn process`),sx:{alignItems:`flex-start`,gap:.75},children:[(0,X.jsx)(r,{sx:{fontSize:16,mt:.2,...m_(n)}}),(0,X.jsx)(q,{variant:`body2`,sx:m_(n),children:M_(e,t)})]})}let n=e.phase===`dispute`||e.phase===`objection`,r=e.phase===`dispute`?Xp:e.phase===`objection`?S_:C_,i=e.phase===`dispute`?`warning`:null;return(0,X.jsxs)(Q,{spacing:.5,role:n?`status`:void 0,sx:{borderLeft:2,borderColor:i?`warning.main`:`divider`,pl:1.25},children:[(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`flex-start`,gap:.75},children:[(0,X.jsx)(r,{sx:{fontSize:16,mt:.2,...i?m_(i):{color:`text.secondary`}}}),(0,X.jsx)(q,{variant:`body2`,sx:i?{fontWeight:600,...m_(i)}:n?{fontWeight:600}:{color:`text.secondary`},children:k_(e,t)})]}),(0,X.jsx)(I_,{process:e,locale:t})]})}var R_=(e,t,n)=>e===`vi`?t:n;function z_(e,t){let n=e.planDeferred??0,r=e.planSteps-e.planDone-n,i=e.rounds?R_(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:R_(t,`Bạn đã dừng lượt này`,`You stopped this turn`),text:R_(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:R_(t,`Lượt dừng vì lỗi · ${Df(e.role??`main`,t)}`,`Turn stopped by a failure · ${Df(e.role??`main`,t)}`),text:R_(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`?R_(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`?R_(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.`):R_(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:R_(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} ${R_(t,`Bấm Tiếp tục để làm tiếp.`,`Choose Continue to go on.`)}`}}return n?{tone:`info`,continuable:!0,title:R_(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:R_(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?R_(t,`Hoàn thành · ${e.planSteps}/${e.planSteps} bước`,`Done · ${e.planSteps}/${e.planSteps} steps`):R_(t,`Xong lượt`,`Turn finished`),text:(e.planSteps?R_(t,`Mọi bước trong checklist đã xong.`,`Every checklist step is completed.`):R_(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 B_(e,t){return e.state===`done`&&e.planDeferred?R_(t,`Xong ${e.planDone}/${e.planSteps}, để sau ${e.planDeferred}`,`Done ${e.planDone}/${e.planSteps}, ${e.planDeferred} later`):e.state===`midway`?R_(t,`Dừng giữa chừng ${e.planDone}/${e.planSteps}`,`Stopped ${e.planDone}/${e.planSteps}`):e.state===`failed`?R_(t,`Lỗi, chưa xong`,`Failed`):e.state===`cancelled`?R_(t,`Đã dừng`,`Stopped`):e.planSteps?R_(t,`Xong ${e.planSteps}/${e.planSteps}`,`Done ${e.planSteps}/${e.planSteps}`):R_(t,`Xong`,`Done`)}function V_({end:e,locale:t,onContinue:n}){let r=z_(e,t),i=n&&r.continuable?(0,X.jsx)(J,{color:`inherit`,size:`small`,onClick:n,children:W(t,`Tiếp tục`,`Continue`)}):void 0;return(0,X.jsxs)(st,{severity:r.tone,variant:`outlined`,role:`status`,"aria-label":W(t,`Kết quả của lượt`,`How the turn ended`),action:i,sx:{alignSelf:`stretch`},children:[(0,X.jsx)(t_,{sx:{fontSize:`inherit`,fontWeight:650,mb:.25},children:r.title}),r.text]})}var H_={done:`success`,midway:`warning`,failed:`error`,cancelled:`info`},U_=e=>e.state===`done`&&e.planDeferred?`info`:H_[e.state];function W_(e,t){return B_(e,t)}var G_=null,K_=()=>G_??=yu(()=>import(`./MarkdownMessage-k4tq1y8s.js`),__vite__mapDeps([0,1,2,3,4])),q_=(0,Y.lazy)(async()=>({default:(await K_()).MarkdownMessage}));function J_({children:e}){return(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(q,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.75},children:e}),children:(0,X.jsx)(q_,{children:e})})}function Y_({attachments:e,locale:t}){return e.length?(0,X.jsx)(Q,{spacing:.75,sx:{mb:1},"aria-label":W(t,`File đã gửi`,`Sent files`),children:e.map((e,n)=>{let r=`sourceBytes`in e?pd(e,t):`${e.kind===`document`?W(t,`Tài liệu`,`Document`):e.kind===`image`?W(t,`Ảnh`,`Image`):`File`}${e.truncated?` · ${W(t,`đã cắt bớt`,`truncated`)}`:``}`;return(0,X.jsxs)(ft,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:1.1,minWidth:220,maxWidth:440,px:1.2,py:1,borderRadius:1,bgcolor:`background.paper`},children:[e.kind===`image`?(0,X.jsx)(Zg,{color:`action`}):(0,X.jsx)(wm,{color:`action`}),(0,X.jsxs)(Z,{sx:{minWidth:0},children:[(0,X.jsx)(q,{variant:`body2`,noWrap:!0,sx:{fontWeight:650},children:e.displayName}),(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:r})]})]},`${e.displayName}:${n}`)})}):null}var X_=new Set([`assistant-response-failed`,`operation-failed`]);function Z_(e,t){switch(e){case`provider-auth-expired`:return W(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 W(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 W(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 W(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 W(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 W(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 Q_({code:e,detail:t,locale:n,onContinue:r}){let i=Of(e,t?.code??null,n),a=r&&Af(e)?(0,X.jsx)(J,{color:`inherit`,size:`small`,onClick:r,children:W(n,`Tiếp tục`,`Continue`)}):void 0;return i?(0,X.jsxs)(st,{severity:`error`,variant:`outlined`,icon:(0,X.jsx)(Rh,{}),action:a,sx:{alignSelf:`stretch`},children:[(0,X.jsxs)(t_,{sx:{fontSize:`inherit`,fontWeight:650,mb:.25},children:[jf(t?.role??`main`,n),` `,W(n,`lỗi`,`failed`),` · `,i.title]}),i.text,t&&(0,X.jsxs)(q,{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:[W(n,`Mã`,`Code`),`: `,t.code,t.requestRef?` · request ${t.requestRef.slice(0,8)}`:``]})]}):(0,X.jsx)(st,{severity:`error`,variant:`outlined`,icon:(0,X.jsx)(Rh,{}),action:a,sx:{alignSelf:`stretch`},children:Z_(e,n)})}function $_({text:e,attachments:t,note:n,locale:r}){return(0,X.jsxs)(Z,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:1,px:2,py:1.4},children:[(0,X.jsx)(Y_,{attachments:t,locale:r}),e&&(0,X.jsx)(q,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:(0,X.jsx)(Po,{children:e})}),n&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:n})]})}function ev({children:e}){return(0,X.jsxs)(Z,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,X.jsx)(Z,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,X.jsxs)(Q,{spacing:1,sx:{minWidth:0,flex:1},children:[(0,X.jsx)(q,{sx:{fontWeight:600},children:`Piagent`}),e]})]})}function tv(e,t){return e.content.redacted?W(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):e.content.truncated?W(t,`Nội dung đã rút gọn`,`Content truncated`):null}function nv({turn:e,locale:t}){let n=xg(e),r=[`${e.requests} request`];e.tokens&&r.push(`${wg(e.tokens)} token`),n!==null&&n>0&&r.push(n<60?`${n}s`:`${Math.floor(n/60)}m ${n%60}s`);let i=Sg(e);return i!==null&&r.push(`${i} tok/s`),e.model&&r.push(e.model),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,title:W(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 rv({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,X.jsxs)(Q,{spacing:1.5,children:[(0,X.jsx)($_,{text:e.user.content.text,attachments:e.user.attachments??[],note:tv(e.user,t),locale:t}),i&&(0,X.jsxs)(ev,{children:[e.steps.map(e=>e.kind===`tool`?(0,X.jsx)(x_,{tool:e.tool,locale:t},e.key):e.kind===`process`?(0,X.jsx)(L_,{process:e.process,locale:t},e.key):(0,X.jsx)(Z,{sx:{color:`text.secondary`,fontSize:`.875rem`,"& .MuiTypography-root":{fontSize:`inherit`}},children:(0,X.jsx)(J_,{children:e.text})},e.key)),e.failure&&(0,X.jsx)(Q_,{code:e.failure,detail:e.failureDetail,locale:t,onContinue:n}),r&&(0,X.jsx)(st,{severity:`info`,variant:`outlined`,sx:{alignSelf:`stretch`},action:(0,X.jsx)(J,{color:`inherit`,size:`small`,onClick:n,children:W(t,`Tiếp tục`,`Continue`)}),children:W(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,X.jsx)(Z,{children:(0,X.jsx)(J_,{children:e.answer})}),e.process&&(0,X.jsx)(L_,{process:e.process,locale:t}),e.end&&(0,X.jsx)(V_,{end:e.end,locale:t,onContinue:e.failure?void 0:n}),e.requests>0&&(0,X.jsx)(nv,{turn:e,locale:t})]}),(0,X.jsx)(Yg,{turnRef:e.user.messageRef})]})}function iv(e,t){return e===`compaction`?W(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`?W(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 av({user:e,attachments:t,activities:n,assistant:r,running:i,failure:a,status:o,locale:s}){return(0,X.jsxs)(Q,{spacing:1.5,children:[e&&(0,X.jsx)($_,{text:e,attachments:t,locale:s}),(0,X.jsxs)(ev,{children:[n.map(e=>(0,X.jsx)(x_,{live:!0,locale:s,waiting:e.toolLabel===`capacity-wait`,tool:{toolName:iv(e.toolLabel,s),state:e.state,summary:{kind:y_(e.toolLabel),target:e.fileLabel??null,detail:null}}},e.toolCallRef)),a&&(0,X.jsx)(Q_,{code:a,locale:s}),r&&(0,X.jsx)(Z,{children:(0,X.jsx)(J_,{children:r})}),i&&o]})]})}function ov(e){let t=(0,Y.useRef)(null),[n,r]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{if(!e){t.current=null,r(null);return}t.current??={at:Date.now(),from:e.length},r(Cg(e.length-t.current.from,Date.now()-t.current.at))},[e]),n}function sv({live:e,locale:t,onOpenActivity:n}){let[r,i]=(0,Y.useState)(()=>Date.now());(0,Y.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e4);return()=>window.clearInterval(e)},[]);let a=gg(e,t,r),o=ov(e.assistant??``);return(0,X.jsxs)(Q,{direction:`row`,spacing:1.25,role:`status`,"aria-live":`polite`,sx:{alignItems:`center`,color:`text.secondary`,py:.75},children:[(0,X.jsx)(De,{size:19,thickness:4}),(0,X.jsxs)(Z,{sx:{minWidth:0},children:[(0,X.jsx)(q,{variant:`body2`,sx:{fontWeight:600},children:a.label}),(0,X.jsxs)(q,{variant:`caption`,color:`text.disabled`,children:[a.detail,o!==null&&` · ≈ ${o} tok/s`]})]}),n&&(0,X.jsx)(J,{size:`small`,variant:`text`,onClick:n,sx:{ml:`auto !important`},children:W(t,`Xem Activity`,`View Activity`)})]})}var cv=new Map,lv=96,uv=()=>document.documentElement.scrollHeight-window.innerHeight,dv=()=>uv()-window.scrollY<=lv;function fv(e,t){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(!1),i=(0,Y.useRef)(!0);return(0,Y.useLayoutEffect)(()=>{if(!t||r.current)return;r.current=!0;let n=cv.get(e)??`end`;i.current=n===`end`,window.scrollTo(0,n===`end`?uv():Math.min(n,uv()))},[t,e]),(0,Y.useEffect)(()=>{let t=()=>{r.current&&(i.current=dv(),cv.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,uv())});return a&&o?.observe(a),()=>{window.removeEventListener(`scroll`,t),o?.disconnect()}},[e]),n}function pv({sessionRef:e,sessionRevision:t,live:n,approvals:r,locale:i,onOpenActivity:a,onContinue:o,reload:s=0}){let[c,l]=(0,Y.useState)(),[u,d]=(0,Y.useState)(!0),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{K_()},[]);let v=Yu(e,t,n),{completionKey:y,user:b,assistant:x,operationRef:S,messageRequestId:C,startedAt:w}=v;(0,Y.useEffect)(()=>{let t=new AbortController;d(!0),h(!1),_(null);let n=window.setTimeout(()=>{Es(e,null,50,t.signal).then(e=>{l(e),y&&id(e.items,b,x,{operationRef:S,messageRequestId:C,startedAt:w})&&_(y)}).catch(()=>{t.signal.aborted||h(!0)}).finally(()=>{t.signal.aborted||d(!1)})},y?100:0);return()=>{window.clearTimeout(n),t.abort()}},[v.key,s]);let T=c?.state===`ready`?c.items:[],E=(0,Y.useMemo)(()=>bg(T),[T]),D=(0,Y.useMemo)(()=>!!(n?.user&&ad(T,n.user,{operationRef:n.operationRef,messageRequestId:n.messageRequestId,startedAt:n.startedAt})),[T,n?.user,n?.operationRef,n?.messageRequestId,n?.startedAt]),O=!!(n&&!D&&(!n.complete||g!==y)),k=(0,Y.useMemo)(()=>!!(n?.user&&rd(T,n.user,{operationRef:n.operationRef,messageRequestId:n.messageRequestId,startedAt:n.startedAt})),[T,n?.user,n?.operationRef,n?.messageRequestId,n?.startedAt]),A=async()=>{let t=c?.page.nextBeforeCursor;if(!(!t||f)){p(!0);try{let n=await Es(e,t,c.page.limit);l(e=>e?{...e,items:Wu(e.items,n.items),page:n.page}:n)}catch{h(!0)}finally{p(!1)}}},j=n?$u(n.assistant||``):null,M=fv(e,!!c||m);return(0,X.jsx)(Xg,{sessionRef:e,refresh:`${v.key}:${s}`,running:!!n&&!n.complete&&!n.error,locale:i,children:(0,X.jsxs)(Q,{ref:M,spacing:3,children:[c?.page.hasOlder&&(0,X.jsx)(Z,{sx:{textAlign:`center`},children:(0,X.jsx)(J,{size:`small`,variant:`text`,startIcon:f?(0,X.jsx)(De,{size:14}):(0,X.jsx)(wo,{}),disabled:f,onClick:()=>void A(),children:W(i,`Tải tin cũ hơn`,`Load older messages`)})}),u&&!c&&(0,X.jsx)(Z,{sx:{py:5,textAlign:`center`},children:(0,X.jsx)(De,{size:22})}),m&&!c&&(0,X.jsx)(st,{severity:`warning`,icon:(0,X.jsx)(Rh,{}),children:W(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.`)}),E.map((e,t)=>(0,X.jsx)(rv,{turn:e,locale:i,onContinue:t===E.length-1&&!O&&!r?.pending.length?o:void 0},e.key)),O&&n&&(0,X.jsx)(av,{user:n.user&&!k?n.user:null,attachments:n.attachments,activities:n.activities,assistant:n.error?null:j,running:!n.complete&&!n.error,failure:n.complete&&n.error&&X_.has(n.error)?n.error:null,locale:i,status:(0,X.jsx)(sv,{live:n,locale:i,onOpenActivity:a})}),(0,X.jsx)(Zh,{sessionRef:e,waiting:qh(n),approvalRefs:r?.pending.map(e=>e.approvalRef)??[]})]})})}var mv=K((0,X.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`),hv=K((0,X.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`),gv=K((0,X.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`),_v=K((0,X.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`),vv=K((0,X.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 yv(e){return(0,X.jsx)(et,{viewBox:`0 0 16 16`,...e,children:(0,X.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 bv(e,t){return e.detached?W(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})`):W(t,`Nhánh Git của project: ${e.name}`,`The project's Git branch: ${e.name}`)}function xv({branch:e,locale:t,maxWidth:n=220,tooltip:r=!0}){if(!e)return null;let i=(0,X.jsxs)(Z,{component:`span`,"aria-label":r?bv(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,X.jsx)(yv,{sx:{fontSize:`1.1em`,flexShrink:0}}),(0,X.jsx)(Z,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:`.95em`},children:e.name})]});return r?(0,X.jsx)(_o,{describeChild:!0,title:bv(e,t),children:i}):i}function Sv(e,t){let n=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));if(n<60)return W(t,`Vừa mới`,`Just now`);let r=Math.floor(n/60);if(r<60)return W(t,`${r} phút`,`${r}m`);let i=Math.floor(r/60);if(i<24)return W(t,`${i} giờ`,`${i}h`);let a=Math.floor(i/24);return W(t,`${a} ngày`,`${a}d`)}function Cv(e,t){return Jh(e,t)?`attention`: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 wv({activity:e,locale:t,fresh:n=!1,question:r=!1}){let i={running:`primary.main`,elsewhere:`info.main`,attention:`warning.main`,recovery:`error.main`,failed:`error.main`,idle:n?`success.main`:`transparent`}[e],a={running:W(t,`Đang chạy`,`Running`),elsewhere:W(t,`Đang chạy ở Terminal hoặc tiến trình khác`,`Running in Terminal or another process`),attention:r?W(t,`Cần bạn trả lời`,`Needs your answer`):W(t,`Cần duyệt`,`Needs approval`),recovery:W(t,`Cần khôi phục`,`Needs recovery`),failed:W(t,`Lượt cuối lỗi`,`Last turn failed`),idle:n?W(t,`Xong, chưa xem`,`Done, not seen`):``}[e];return(0,X.jsx)(Z,{role:e===`idle`&&!n?void 0:`img`,"aria-label":a||void 0,title:a,sx:{width:8,height:8,mt:.9,ml:.75,flexShrink:0,borderRadius:`50%`,bgcolor:i,animation:e===`running`||e===`elsewhere`||e===`attention`?`piagent-pulse 1.4s ease-in-out infinite`:`none`}})}var Tv={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 Ev({session:e,live:t,selected:n,locale:r,onSelect:i,onAction:a,showProject:o=!1,fresh:s=!1}){let[c,l]=(0,Y.useState)(null),u=e=>{l(null),a(e)},d=e.modelLabel===`agent-watch-auto`,f=Cv(e,t),p=f===`running`?W(r,`Đang chạy`,`Running`):f===`elsewhere`?W(r,`Đang chạy ở nơi khác`,`Running elsewhere`):f===`attention`?Jh(e,t)===`question`?W(r,`Cần bạn trả lời`,`Needs your answer`):W(r,`Cần duyệt`,`Needs approval`):s?f===`failed`?W(r,`Lỗi · chưa xem`,`Failed · not seen`):W(r,`Xong · chưa xem`,`Done · not seen`):null,m=d&&!s&&f!==`running`&&f!==`elsewhere`?e.managedTurnEnd??null:null,h=!m&&d&&e.managedProcess&&e.managedProcess.outcome!==`no_change`?e.managedProcess.outcome:null;return(0,X.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,pr:.5},className:f===`attention`?`session-item attention`:s?`session-item fresh`:`session-item`,children:[(0,X.jsxs)(Dr,{selected:n,onClick:i,sx:{minWidth:0,alignItems:`flex-start`,py:1,px:1.4},children:[(0,X.jsx)(Lr,{primary:(0,X.jsxs)(X.Fragment,{children:[e.pinned&&(0,X.jsx)(_v,{sx:{fontSize:13,mr:.5,verticalAlign:`-2px`,color:`text.disabled`}}),e.title]}),secondary:(0,X.jsxs)(X.Fragment,{children:[d&&(0,X.jsxs)(Z,{component:`span`,sx:{fontWeight:650,color:`primary.main`},children:[W(r,`Công ty`,`Company`),(0,X.jsx)(`span`,{children:` · `})]}),p??Sv(e.updatedAt,r),o&&(0,X.jsxs)(`span`,{children:[` · `,e.projectLabel]}),m&&(0,X.jsxs)(Z,{component:`span`,sx:m_(U_(m)),children:[` · `,W_(m,r)]}),h&&(0,X.jsxs)(Z,{component:`span`,sx:m_(N_(h)),children:[` · `,W(r,...Tv[h])]})]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13.25,fontWeight:n?600:500}},secondary:{noWrap:!0,sx:{mt:.25,fontSize:11.25,...f===`attention`?{color:`warning.main`,fontWeight:650}:s?{color:f===`failed`?`error.main`:`success.main`,fontWeight:650}:{}}}}}),(0,X.jsx)(wv,{activity:f,locale:r,fresh:s,question:Jh(e,t)===`question`})]}),(0,X.jsx)(Ze,{size:`small`,"aria-label":W(r,`Tùy chọn cuộc trò chuyện`,`Chat options`),onClick:e=>l(e.currentTarget),children:(0,X.jsx)(gv,{fontSize:`small`})}),(0,X.jsxs)(oe,{anchorEl:c,open:!!c,onClose:()=>l(null),onClick:e=>e.stopPropagation(),children:[!e.archived&&(0,X.jsx)(np,{onClick:()=>u(`rename`),children:W(r,`Đổi tên`,`Rename`)}),!e.archived&&(0,X.jsx)(np,{onClick:()=>u(`pin`),children:e.pinned?W(r,`Bỏ ghim`,`Unpin`):W(r,`Ghim`,`Pin`)}),!e.archived&&(0,X.jsx)(np,{onClick:()=>u(`fork`),children:W(r,`Tạo nhánh`,`Fork`)}),(0,X.jsx)(np,{onClick:()=>u(e.archived?`unarchive`:`archive`),children:e.archived?W(r,`Bỏ lưu trữ`,`Unarchive`):W(r,`Lưu trữ`,`Archive`)})]})]})}var Dv=5,Ov=`piagent.sidebar.collapsed`;function kv(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 Av(e,t){try{window.localStorage.setItem(e,JSON.stringify([...t].slice(0,500)))}catch{}}var jv=new Set,Mv={attention:0,recovery:1,failed:2,idle:3,running:4,elsewhere:5};function Nv({locale:e,canCreate:t,query:n,onQuery:r,groups:i,count:a,selectedRef:o,showArchived:s,archivedCount:c,settingsOpen:l,connection:u,live:d,unseen:f=jv,onNew:p,onSelect:m,onAction:h,onToggleArchived:g,onSettings:_,updateDot:v=!1}){let y=tf(e=>e.breakpoints.down(`md`)),[b,x]=(0,Y.useState)(`all`),[S,C]=(0,Y.useState)(()=>kv(Ov)),[w,T]=(0,Y.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,Y.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=>Cv(e,d[e.sessionRef])!==`idle`||f.has(e.sessionRef)).sort((e,t)=>Mv[Cv(e,d[e.sessionRef])]-Mv[Cv(t,d[t.sessionRef])]),N=(e,t,n)=>e(e=>{let r=new Set(e);return r.has(t)?r.delete(t):r.add(t),n&&Av(Ov,r),r});return(0,X.jsxs)(Z,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,bgcolor:`background.paper`},children:[(0,X.jsxs)(ti,{sx:{minHeight:`60px !important`,px:`16px !important`,gap:1.1},children:[(0,X.jsx)(Z,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,X.jsxs)(Z,{sx:{minWidth:0},children:[(0,X.jsx)(q,{sx:{fontWeight:600},children:`Piagent`}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,children:W(e,`Coding agent`,`Coding agent`)})]})]}),(0,X.jsxs)(Z,{sx:{px:1.25},children:[(0,X.jsx)(_o,{title:t?W(e,`Tạo cuộc trò chuyện mới`,`Create a new chat`):W(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,X.jsx)(`span`,{children:(0,X.jsx)(J,{fullWidth:!0,disabled:!t,variant:`outlined`,onClick:p,startIcon:(0,X.jsx)(sf,{}),sx:{justifyContent:`flex-start`,py:1},children:W(e,`Cuộc trò chuyện mới`,`New chat`)})})}),(0,X.jsx)(te,{value:n,onChange:e=>r(e.target.value),fullWidth:!0,size:`small`,placeholder:W(e,`Tìm cuộc trò chuyện`,`Search chats`),sx:{mt:1.1},slotProps:{input:{startAdornment:(0,X.jsx)(mu,{position:`start`,children:(0,X.jsx)(hu,{fontSize:`small`})})}}})]}),(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,px:2,pt:2,pb:.4},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:600,textTransform:`uppercase`,letterSpacing:`.08em`},children:s?W(e,`Đã lưu trữ`,`Archived`):W(e,`Cuộc trò chuyện`,`Chats`)}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,children:j})]}),k.company>0&&k.personal>0&&(0,X.jsx)(Q,{direction:`row`,role:`group`,"aria-label":W(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,X.jsx)(er,{size:`small`,clickable:!0,"aria-pressed":b===t,onClick:()=>x(t),color:b===t?`primary`:`default`,variant:b===t?`filled`:`outlined`,label:t===`all`?W(e,`Tất cả`,`All`):t===`company`?W(e,`Công ty · ${k.company}`,`Company · ${k.company}`):W(e,`Cá nhân · ${k.personal}`,`Personal · ${k.personal}`)},t))}),(0,X.jsxs)(ie,{component:`div`,sx:{flex:1,minHeight:0,overflowY:`auto`,py:.25},children:[M.length>0&&(0,X.jsxs)(Z,{component:`section`,"aria-label":W(e,`Đang chạy hoặc cần chú ý`,`Running or needing attention`),sx:{mt:.5},children:[(0,X.jsx)(q,{component:`div`,variant:`caption`,color:`text.secondary`,sx:{px:2,py:.55,fontWeight:600},children:W(e,`Đang chạy · cần chú ý`,`Running · needs attention`)}),M.map(t=>(0,X.jsx)(Ev,{session:t,live:d[t.sessionRef],showProject:!0,fresh:f.has(t.sessionRef),selected:o===t.sessionRef,locale:e,onSelect:()=>m(t.sessionRef),onAction:e=>h(t,e)},t.sessionRef)),(0,X.jsx)(or,{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<Dv||e.sessionRef===o);return(0,X.jsxs)(Z,{component:`section`,"aria-label":t.label,sx:{mt:.5},children:[(0,X.jsxs)(Le,{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,X.jsx)(hm,{sx:{fontSize:16,color:`text.disabled`,transform:r?`none`:`rotate(-90deg)`,transition:`transform .15s`}}),(0,X.jsx)(gm,{sx:{fontSize:15,color:`text.disabled`}}),(0,X.jsx)(q,{component:`div`,variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{flexShrink:1,minWidth:0,fontWeight:600,textAlign:`left`},children:t.label}),(0,X.jsx)(q,{component:`div`,variant:`caption`,color:`text.disabled`,sx:{flex:1,minWidth:0,display:`flex`,textAlign:`left`},children:t.gitBranch?(0,X.jsx)(xv,{branch:t.gitBranch,locale:e,maxWidth:`100%`}):t.gitRepositories?.length?(0,X.jsxs)(Z,{component:`span`,title:t.gitRepositories.map(e=>`${e.name} · ${e.branch?.name??`?`}`).join(`
50
- `),sx:{display:`inline-flex`,alignItems:`center`,gap:.4,whiteSpace:`nowrap`},children:[(0,X.jsx)(yv,{sx:{fontSize:`1.1em`}}),W(e,`${t.gitRepositories.length} repo`,`${t.gitRepositories.length} repos`)]}):null}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,children:t.sessions.length})]}),r&&a.map(t=>(0,X.jsx)(Ev,{session:t,live:d[t.sessionRef],fresh:f.has(t.sessionRef),selected:o===t.sessionRef,locale:e,onSelect:()=>m(t.sessionRef),onAction:e=>h(t,e)},t.sessionRef)),r&&!E&&t.sessions.length>Dv&&(0,X.jsx)(J,{size:`small`,onClick:()=>N(T,t.projectRef,!1),sx:{ml:1.5,mb:.25,fontSize:12},children:i?W(e,`Thu gọn`,`Show less`):W(e,`Xem thêm ${t.sessions.length-Dv}`,`Show ${t.sessions.length-Dv} more`)})]},t.projectRef)}),j===0&&(0,X.jsxs)(Q,{sx:{alignItems:`center`,textAlign:`center`,px:3,py:5},spacing:1,children:[(0,X.jsx)(hv,{color:`disabled`}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(e,`Không tìm thấy cuộc trò chuyện`,`No conversations found`)})]})]}),(0,X.jsxs)(Z,{sx:{p:1.25},children:[(0,X.jsx)(or,{sx:{mb:1}}),(0,X.jsx)(J,{fullWidth:!0,startIcon:(0,X.jsx)(mv,{}),disabled:!s&&c===0,onClick:g,sx:{justifyContent:`flex-start`},children:s?W(e,`Quay lại cuộc trò chuyện`,`Back to chats`):W(e,`Đã lưu trữ (${c})`,`Archived (${c})`)}),(0,X.jsxs)(J,{fullWidth:!0,startIcon:(0,X.jsx)(vv,{}),onClick:_,sx:{justifyContent:`flex-start`,mt:.25},color:l?`primary`:`inherit`,children:[W(e,`Cài đặt`,`Settings`),v&&(0,X.jsx)(Z,{component:`span`,role:`img`,"aria-label":W(e,`Có bản cập nhật`,`Update available`),sx:{ml:`auto`,width:8,height:8,borderRadius:`50%`,bgcolor:`primary.main`}})]}),y&&(0,X.jsxs)(Q,{direction:`row`,sx:{px:1.25,pt:1,alignItems:`center`,gap:1},children:[(0,X.jsx)(Z,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:u===`connected`?`success.main`:`warning.main`}}),(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,sx:{flex:1},children:u===`connected`?`Gateway live`:u}),(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,children:`local`})]})]})]})}var Pv=9e3,Fv=4,Iv={done:[`Xong`,`Done`,`Agent đã trả lời xong.`,`The agent finished its answer.`],failed:[`Lượt bị lỗi`,`Turn failed`,`Mở để xem lỗi và gửi “tiếp tục”.`,`Open it to see the error and continue.`],stopped:[`Đã dừng`,`Stopped`,`Lượt làm việc đã dừng giữa chừng.`,`The turn stopped midway.`],question:[`Cần bạn trả lời`,`Needs your answer`,`Main agent đang chờ bạn chọn phương án.`,`The main agent is waiting for your choice.`],approval:[`Cần bạn duyệt`,`Needs your approval`,`Main agent xin chạy một lệnh và đang chờ bạn duyệt.`,`The main agent asked to run a command and is waiting.`]},Lv={done:`success`,failed:`error`,stopped:`neutral`,question:`warning`,approval:`warning`};function Rv({sessions:e,live:t,selectedRef:n,onOpen:r,locale:i}){let a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(()=>new Set);(0,Y.useEffect)(()=>{let r=Yh(e,t);if(a.current){let i=document.visibilityState===`visible`,o=Xh(a.current,r,e,t).filter(e=>!(i&&e.sessionRef===n));if(o.length){s(e=>[...o,...e.filter(e=>!o.some(t=>t.sessionRef===e.sessionRef))].slice(0,12));let e=o.filter(e=>[`done`,`failed`,`stopped`].includes(e.kind)).map(e=>e.sessionRef);e.length&&l(t=>new Set([...t,...e]))}}a.current=r,s(e=>{let t=e.filter(e=>![`question`,`approval`].includes(e.kind)||r[e.sessionRef]?.need===e.kind);return t.length===e.length?e:t})},[e,t,n]),(0,Y.useEffect)(()=>{n&&(l(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t}),s(e=>e.filter(e=>e.sessionRef!==n)))},[n]);let u=e.filter(e=>!e.archived&&Jh(e,t[e.sessionRef])).length;(0,Y.useEffect)(()=>{let e=document.title.replace(/^\(\d+\) /,``);document.title=u?`(${u}) ${e}`:e},[u]);let d=e=>s(t=>t.filter(t=>t.id!==e));return{unseen:c,view:(0,X.jsx)(zv,{toasts:o.slice(0,Fv),more:Math.max(0,o.length-Fv),locale:i,onClose:d,onOpen:e=>{d(e.id),r(e.sessionRef)}})}}function zv({toasts:e,more:t,locale:n,onClose:r,onOpen:i}){return(0,X.jsxs)(`section`,{className:`attention-toasts`,"aria-label":W(n,`Thông báo cuộc trò chuyện`,`Chat notifications`),"aria-live":`polite`,children:[e.map(e=>(0,X.jsx)(Bv,{event:e,locale:n,onClose:()=>r(e.id),onOpen:()=>i(e)},e.id)),t>0&&(0,X.jsx)(`p`,{className:`attention-more`,children:W(n,`và ${t} thông báo khác`,`and ${t} more`)})]})}function Bv({event:e,locale:t,onClose:n,onOpen:r}){let i=e.kind===`question`||e.kind===`approval`,[a,o,s,c]=Iv[e.kind];return(0,Y.useEffect)(()=>{if(i)return;let e=window.setTimeout(n,Pv);return()=>window.clearTimeout(e)},[i]),(0,X.jsxs)(`article`,{className:`attention-toast tone-${Lv[e.kind]}`,role:i?`alert`:`status`,children:[(0,X.jsx)(`span`,{className:`attention-toast-mark`,"aria-hidden":`true`}),(0,X.jsxs)(`div`,{className:`attention-toast-body`,children:[(0,X.jsxs)(`strong`,{children:[W(t,a,o),` · `,(0,X.jsx)(`span`,{className:`attention-toast-title`,children:e.title})]}),(0,X.jsx)(`small`,{children:W(t,s,c)})]}),(0,X.jsxs)(`div`,{className:`attention-toast-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`attention-open`,onClick:r,children:W(t,`Mở`,`Open`)}),(0,X.jsx)(`button`,{type:`button`,className:`attention-close`,"aria-label":W(t,`Đóng thông báo`,`Close notification`),onClick:n,children:`×`})]})]})}var Vv=K((0,X.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`),Hv=K((0,X.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`),Uv=K((0,X.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`),Wv=K((0,X.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 Gv(e){return m(`MuiLinearProgress`,e)}E(`MuiLinearProgress`,[`root`,`colorPrimary`,`colorSecondary`,`determinate`,`indeterminate`,`buffer`,`query`,`dashed`,`bar`,`bar1`,`bar2`]);var Kv=4,qv={},Jv=we`
51
- 0% {
52
- left: -35%;
53
- right: 100%;
54
- }
55
-
56
- 60% {
57
- left: 100%;
58
- right: -90%;
59
- }
60
-
61
- 100% {
62
- left: 100%;
63
- right: -90%;
64
- }
65
- `,Yv=typeof Jv==`string`?null:ye`
66
- animation: ${Jv} 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
67
- `,Xv=we`
68
- 0% {
69
- left: -200%;
70
- right: 100%;
71
- }
72
-
73
- 60% {
74
- left: 107%;
75
- right: -8%;
76
- }
77
-
78
- 100% {
79
- left: 107%;
80
- right: -8%;
81
- }
82
- `,Zv=typeof Xv==`string`?null:ye`
83
- animation: ${Xv} 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) 1.15s infinite;
84
- `,Qv=we`
85
- 0% {
86
- opacity: 1;
87
- background-position: 0 -23px;
88
- }
89
-
90
- 60% {
91
- opacity: 0;
92
- background-position: 0 -23px;
93
- }
94
-
95
- 100% {
96
- opacity: 1;
97
- background-position: -200px -23px;
98
- }
99
- `,$v=typeof Qv==`string`?null:ye`
100
- animation: ${Qv} 3s infinite linear;
101
- `,ey=e=>{let{classes:t,variant:n,color:r}=e,i={root:[`root`,`color${U(r)}`,n],dashed:[`dashed`],bar1:[`bar`,`bar1`],bar2:[`bar`,`bar2`,n===`buffer`&&`color${U(r)}`]};return he(i,Gv,t)},ty=(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),ny=H(`span`,{name:`MuiLinearProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`color${U(n.color)}`],t[n.variant]]}})(ge(({theme:e})=>({position:`relative`,overflow:`hidden`,display:`block`,height:4,zIndex:0,"@media print":{colorAdjust:`exact`},variants:[...Object.entries(e.palette).filter(Re()).map(([t])=>({props:{color:t},style:{backgroundColor:ty(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)`}}]}))),ry=H(`span`,{name:`MuiLinearProgress`,slot:`Dashed`})(ge(({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(Re()).map(([t])=>{let n=ty(e,t);return{props:{color:t},style:{backgroundImage:`radial-gradient(${n} 0%, ${n} 16%, transparent 42%)`}}})]})),$v||{animation:`${Qv} 3s infinite linear`},ge(({theme:e})=>Ie(e,{animation:`none`})||qv)),iy=H(`span`,{name:`MuiLinearProgress`,slot:`Bar1`,overridesResolver:(e,t)=>[t.bar,t.bar1]})(ge(({theme:e})=>{let t=Ie(e,{animation:`none`,left:`30%`,right:`auto`,width:`40%`});return{width:`100%`,position:`absolute`,left:0,bottom:0,top:0,...Ee(e,`transform`,{duration:`0.2s`,easing:`linear`}),transformOrigin:`left`,variants:[{props:{color:`inherit`},style:{backgroundColor:`currentColor`}},...Object.entries(e.palette).filter(Re()).map(([t])=>({props:{color:t},style:{backgroundColor:(e.vars||e).palette[t].main}})),{props:{variant:`determinate`},style:{...Ee(e,`transform`,{duration:`.${Kv}s`,easing:`linear`})}},{props:{variant:`buffer`},style:{zIndex:1,...Ee(e,`transform`,{duration:`.${Kv}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:Yv||{animation:`${Jv} 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}]:[]]}})),ay=H(`span`,{name:`MuiLinearProgress`,slot:`Bar2`,overridesResolver:(e,t)=>[t.bar,t.bar2]})(ge(({theme:e})=>{let t=Ie(e,{animation:`none`,display:`none`});return{width:`100%`,position:`absolute`,left:0,bottom:0,top:0,...Ee(e,`transform`,{duration:`0.2s`,easing:`linear`}),transformOrigin:`left`,variants:[...Object.entries(e.palette).filter(Re()).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(Re()).map(([t])=>({props:{color:t,variant:`buffer`},style:{backgroundColor:ty(e,t),...Ee(e,`transform`,{duration:`.${Kv}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:Zv||{animation:`${Xv} 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}]:[]]}})),oy=Y.forwardRef(function(e,t){let n=_e({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=ey(d),g=Ke(),_={},v={bar1:{},bar2:{}};if((l===`determinate`||l===`buffer`)&&s!==void 0){let e=p-f,t=(s-f)/e*100-100;g&&(t=-t),v.bar1.transform=e>0?`translateX(${t}%)`:`translateX(-100%)`,_[`aria-valuenow`]=s,_[`aria-valuemin`]=f,_[`aria-valuemax`]=p}if(l===`buffer`&&c!==void 0){let e=p-f,t=(c-f)/e*100-100;g&&(t=-t),v.bar2.transform=e>0?`translateX(${t}%)`:`translateX(-100%)`}return(0,X.jsxs)(ny,{className:h(m.root,r),ownerState:d,role:`progressbar`,..._,ref:t,...u,children:[l===`buffer`?(0,X.jsx)(ry,{className:m.dashed,ownerState:d}):null,(0,X.jsx)(iy,{className:m.bar1,ownerState:d,style:v.bar1}),l===`determinate`?null:(0,X.jsx)(ay,{className:m.bar2,ownerState:d,style:v.bar2})]})}),sy=`ui-monospace, SFMono-Regular, Menlo, Consolas, monospace`,cy={A:`success`,M:`warning`,D:`error`,R:`info`,C:`info`,U:`success`};function ly({title:e,action:t,children:n}){return(0,X.jsxs)(Z,{component:`section`,sx:{px:2,py:1.75,borderBottom:1,borderColor:`divider`},children:[(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,mb:1},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,sx:{fontWeight:650,textTransform:`uppercase`,letterSpacing:`.06em`},children:e}),t]}),n]})}function uy({session:e,snapshot:t,live:n,locale:r,onOpenReview:i,onClose:a}){let[o,s]=(0,Y.useState)(),[c,l]=(0,Y.useState)(!1),u=!!(n&&!n.complete);(0,Y.useEffect)(()=>{if(u)return;let t=new AbortController;l(!1);let n=window.setTimeout(()=>void Os(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,Y.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,v=h?m.tokens:e.contextUsage.usedTokens,y=e.managedHelpers?.maximum===0?void 0:e.managedHelpers,b=e.managedPlan,x=e.managedProcess,S=b?.steps.filter(e=>e.status===`completed`).length??0,C=(n?.activities??[]).filter(e=>y_(e.toolLabel)===`subagent`);return(0,X.jsxs)(Z,{role:`region`,sx:{height:`100%`,overflowY:`auto`,bgcolor:`background.paper`},"aria-label":W(r,`Thay đổi và ngữ cảnh`,`Changes and context`),children:[(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:1,px:2,minHeight:60,borderBottom:1,borderColor:`divider`},children:[(0,X.jsx)(q,{sx:{fontWeight:600,flex:1},children:W(r,`Workspace`,`Workspace`)}),a&&(0,X.jsx)(Ze,{size:`small`,"aria-label":W(r,`Đóng khung bên`,`Close side panel`),onClick:a,children:(0,X.jsx)(Ph,{fontSize:`small`})})]}),(0,X.jsxs)(ly,{title:o?W(r,`Thay đổi · ${d.length} file`,`Changes · ${d.length} files`):W(r,`Thay đổi`,`Changes`),action:d.length>0?(0,X.jsx)(_o,{title:W(r,`Xem diff đầy đủ, stage hoặc hoàn tác`,`Full diff, stage or revert`),children:(0,X.jsx)(J,{size:`small`,startIcon:(0,X.jsx)(So,{fontSize:`small`}),onClick:i,children:W(r,`Review`,`Review`)})}):void 0,children:[(f>0||p>0)&&(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:.75,mb:1,color:`text.secondary`},children:[(0,X.jsx)(a_,{sx:{fontSize:15}}),(0,X.jsx)(q,{variant:`caption`,children:W(r,`Chưa commit`,`Uncommitted`)}),(0,X.jsxs)(q,{variant:`caption`,sx:{fontFamily:sy,ml:`auto`},children:[(0,X.jsxs)(Z,{component:`span`,sx:m_(`success`),children:[`+`,f]}),` `,(0,X.jsxs)(Z,{component:`span`,sx:m_(`error`),children:[`−`,p]})]})]}),o===void 0&&!c&&(u?(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(r,`Cập nhật khi lượt này chạy xong.`,`Updates when this turn finishes.`)}):(0,X.jsx)(oy,{sx:{borderRadius:1}})),(c||o?.availability.state===`unavailable`)&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(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,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:W(r,`Chưa có thay đổi nào chưa commit.`,`No uncommitted changes.`)}),(0,X.jsx)(Q,{spacing:.25,children:d.slice(0,200).map(e=>(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:1,py:.4},children:[(0,X.jsx)(q,{variant:`caption`,sx:{fontFamily:sy,fontWeight:700,width:12,...cy[e.status]?m_(cy[e.status]):{color:`text.secondary`}},children:e.status}),(0,X.jsx)(q,{variant:`body2`,noWrap:!0,title:e.path,sx:{fontFamily:sy,fontSize:12.5,flex:1,minWidth:0},children:e.path}),(0,X.jsxs)(q,{variant:`caption`,sx:{fontFamily:sy,flexShrink:0},children:[(e.stats?.additions??0)>0&&(0,X.jsxs)(Z,{component:`span`,sx:m_(`success`),children:[`+`,e.stats.additions,` `]}),(e.stats?.deletions??0)>0&&(0,X.jsxs)(Z,{component:`span`,sx:m_(`error`),children:[`−`,e.stats.deletions]})]})]},e.fileRef))})]}),(b||x)&&(0,X.jsxs)(ly,{title:b?W(r,`Plan · ${S}/${b.steps.length}`,`Plan · ${S}/${b.steps.length}`):W(r,`Tiến trình`,`Process`),children:[b&&(0,X.jsx)(Q,{component:`ol`,spacing:.25,sx:{m:0,p:0,listStyle:`none`},"aria-label":W(r,`Plan của agent`,`Agent plan`),children:b.steps.map((e,t)=>{let n=e.status===`completed`?Hv:e.status===`in_progress`?Uv:e.status===`deferred`?Wv:Vv;return(0,X.jsxs)(Q,{component:`li`,direction:`row`,sx:{alignItems:`flex-start`,gap:.75,py:.25},"aria-label":`${e.step}: ${e.status===`completed`?W(r,`xong`,`done`):e.status===`in_progress`?W(r,`đang làm`,`in progress`):e.status===`deferred`?W(r,`để sau`,`left for later`):W(r,`chưa làm`,`pending`)}`,children:[(0,X.jsx)(n,{sx:{fontSize:16,mt:.2,color:e.status===`in_progress`?`primary.main`:`text.secondary`}}),(0,X.jsx)(q,{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)})}),x&&x.outcome!==`no_change`&&(0,X.jsxs)(q,{variant:`body2`,role:`status`,sx:{mt:+!!b,...m_(P_(x))},children:[W(r,`Lượt sửa code gần nhất: `,`Last code-changing turn: `),M_(x,r)]})]}),(0,X.jsxs)(ly,{title:W(r,`Ngữ cảnh`,`Context`),children:[(0,X.jsxs)(Q,{direction:`row`,sx:{justifyContent:`space-between`,mb:.75},children:[(0,X.jsx)(q,{variant:`body2`,children:g==null?`—`:`${Math.round(g)}%`}),(0,X.jsxs)(q,{variant:`caption`,color:`text.secondary`,children:[v?wg(v):`—`,_?` / ${wg(_)}`:``]})]}),(0,X.jsx)(oy,{variant:`determinate`,value:Math.min(100,Math.max(0,g??0)),sx:{height:6,borderRadius:1},color:(g??0)>85?`warning`:`primary`,"aria-label":W(r,`Mức dùng ngữ cảnh`,`Context usage`)})]}),(y||C.length>0)&&(0,X.jsxs)(ly,{title:`Subagent`,children:[y&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{mb:C.length?.75:0},children:W(r,`${y.active??0}/${y.maximum} đang chạy`,`${y.active??0}/${y.maximum} running`)}),C.map(e=>(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:.75,py:.25},children:[(0,X.jsx)(n_,{sx:{fontSize:15,color:`text.secondary`}}),(0,X.jsx)(q,{variant:`body2`,sx:{flex:1},children:e.fileLabel??`subagent`}),(0,X.jsx)(q,{variant:`caption`,color:e.state===`failed`?`error`:`text.secondary`,children:e.state===`running`?W(r,`đang chạy`,`running`):e.state===`failed`?W(r,`lỗi`,`failed`):W(r,`xong`,`done`)})]},e.toolCallRef))]})]})}var dy=K((0,X.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`),fy=K((0,X.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 py({catalog:e,refresh:t}){let{locale:n}=ze(),[r,i]=(0,Y.useState)(),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!r||r.state!==`running`)return;let e=new AbortController,a=window.setTimeout(()=>{hs(r.jobRef,e.signal).then(e=>{i(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||u(W(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,Y.useEffect)(()=>o(``),[r?.prompt?.promptRef]);let d=async e=>{c(!0),u(null);try{i(await _s(e))}catch{u(W(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 vs(r.jobRef,r.prompt.promptRef,a))}catch{u(W(n,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{c(!1)}}},p=async()=>{r?.state===`running`&&await ys(r.jobRef).catch(()=>void 0),i(void 0),u(null)},m=r?.events.slice(-4)??[];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,X.jsx)(ft,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,X.jsx)(Dp,{name:e.name,size:38}),(0,X.jsx)(q,{sx:{flex:1,fontWeight:800},children:e.name}),e.state===`connected`&&(0,X.jsx)(er,{size:`small`,color:`success`,variant:`outlined`,icon:(0,X.jsx)(fy,{}),label:W(n,`Đã kết nối`,`Connected`)}),(0,X.jsx)(J,{size:`small`,variant:`outlined`,disabled:s,onClick:()=>void d(e.providerRef),children:e.state===`connected`?W(n,`Kết nối lại`,`Reconnect`):W(n,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,X.jsx)(q,{color:`text.secondary`,children:W(n,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),l&&!r&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:l}),(0,X.jsxs)(ce,{open:!!r,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,X.jsx)(ue,{children:r?.providerName??`OAuth`}),(0,X.jsx)(ae,{children:(0,X.jsxs)(Q,{spacing:1.25,sx:{pt:.5},children:[r?.state===`completed`&&(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,X.jsx)(fy,{color:`success`}),(0,X.jsx)(q,{children:W(n,`Đã kết nối`,`Connected`)})]}),m.map(e=>(0,X.jsxs)(Z,{children:[e.message&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,X.jsx)(q,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:800,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,X.jsx)(J,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,X.jsx)(kp,{}),children:W(n,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,X.jsx)(J,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??W(n,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),r?.prompt&&(0,X.jsxs)(Z,{children:[(0,X.jsx)(q,{variant:`body2`,sx:{mb:1},children:r.prompt.message}),r.prompt.type===`select`?(0,X.jsx)(I,{fullWidth:!0,size:`small`,value:a,onChange:e=>o(e.target.value),children:r.prompt.options.map(e=>(0,X.jsx)(np,{value:e.id,children:e.label},e.id))}):(0,X.jsx)(te,{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,X.jsx)(q,{color:`error`,variant:`body2`,children:$(r.reasonCode??r.state,n)}),l&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`body2`,children:l})]})}),(0,X.jsxs)(Np,{children:[(0,X.jsx)(J,{color:`inherit`,onClick:()=>void p(),children:r?.state===`running`?W(n,`Hủy`,`Cancel`):W(n,`Đóng`,`Close`)}),r?.prompt&&(0,X.jsx)(J,{variant:`contained`,disabled:s||!a,onClick:()=>void f(),children:W(n,`Tiếp tục`,`Continue`)})]})]})]})}var my=K((0,X.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`),hy=K((0,X.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`),gy=K([(0,X.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,X.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`),_y=K((0,X.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 vy({icon:e,title:t,detail:n,children:r}){return(0,X.jsxs)(ft,{variant:`outlined`,sx:{p:2,borderRadius:1},children:[(0,X.jsxs)(Q,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,X.jsx)(Z,{sx:{width:38,height:38,borderRadius:1,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,X.jsxs)(Z,{children:[(0,X.jsx)(q,{sx:{fontWeight:820},children:t}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function yy({children:e}){return(0,X.jsx)(Q,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function by({session:e,options:t,connections:n,onCompleted:r}){let{locale:i}=ze(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(e?.sessionRevision??``),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),[_,v]=(0,Y.useState)(``),[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{f(e?.sessionRevision??``),c(void 0),u(null)},[e?.sessionRef]),(0,Y.useEffect)(()=>{e?.sessionRevision&&f(e.sessionRevision)},[e?.sessionRevision]);let C=a||!e||!d||e.liveState===`running`||e.liveState===`waiting-approval`,w=t?.profiles??[],T=(0,Y.useMemo)(()=>(n?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[n]),E=s?.outputs.find(e=>e.customType===`piagent-service-tier-receipt`)?.details,D=async(t,n=null,a=!1)=>{if(!(!e||!d)){o(!0),u(null);try{let i=await Rs({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(W(i,`Gateway chưa thể chạy điều khiển này.`,`The Gateway could not run this control.`))}finally{o(!1)}}},O=(e,t,n,r)=>m({action:e,argument:t,title:n,description:r}),k={size:`small`,variant:`outlined`,disabled:C};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{component:`h1`,variant:`h1`,sx:{mb:.75},children:W(i,`Điều khiển project`,`Project controls`)}),(0,X.jsx)(q,{color:`text.secondary`,sx:{mb:2.5},children:W(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,X.jsx)(ft,{variant:`outlined`,sx:{p:2,borderRadius:1,mb:2},children:(0,X.jsx)(q,{color:`text.secondary`,children:W(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,X.jsxs)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,X.jsxs)(vy,{icon:(0,X.jsx)(_y,{color:`primary`}),title:W(i,`Runtime & token`,`Runtime & tokens`),detail:W(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,X.jsxs)(yy,{children:[(0,X.jsx)(J,{...k,onClick:()=>void D(`runtime.status`),children:`Pi status`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`runtime.inspector`),children:`Inspector`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`orchestration.status`),children:`Orchestration`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`usage.live`),children:`Usage live`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`usage.history`),children:`History`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`usage.logs`),children:`Logs`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`usage.efficiency`),children:`Efficiency`})]}),(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,X.jsx)(te,{size:`small`,fullWidth:!0,label:W(i,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:y,onChange:e=>b(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,X.jsx)(J,{...k,sx:{whiteSpace:`nowrap`},onClick:()=>void D(`usage.preflight`,y.trim()||null),children:`Preflight`})]})]}),(0,X.jsx)(vy,{icon:(0,X.jsx)(Rf,{color:`primary`}),title:W(i,`Fast mode`,`Fast mode`),detail:W(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,X.jsxs)(yy,{children:[(0,X.jsx)(J,{...k,onClick:()=>void D(`runtime.fast-status`),children:W(i,`Trạng thái`,`Status`)}),(0,X.jsx)(J,{...k,color:`primary`,onClick:()=>O(`runtime.fast-on`,null,W(i,`Bật Fast mode?`,`Enable Fast mode?`),W(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:W(i,`Bật Fast`,`Enable Fast`)}),(0,X.jsx)(J,{...k,onClick:()=>O(`runtime.fast-off`,null,W(i,`Tắt Fast mode?`,`Disable Fast mode?`),W(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:W(i,`Tắt Fast`,`Disable Fast`)})]})}),(0,X.jsxs)(vy,{icon:(0,X.jsx)(gy,{color:`primary`}),title:W(i,`Profile`,`Profile`),detail:W(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,X.jsxs)(yy,{children:[(0,X.jsx)(J,{...k,onClick:()=>void D(`profile.status`),children:W(i,`Profile hiện tại`,`Current profile`)}),(0,X.jsx)(J,{...k,onClick:()=>void D(`profile.options`),children:W(i,`Danh sách profile`,`Profile options`)}),(0,X.jsx)(J,{...k,onClick:()=>void D(`profile.tech-options`),children:W(i,`Tech theo vai trò`,`Tech options`)})]}),(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,X.jsx)(I,{size:`small`,fullWidth:!0,displayEmpty:!0,value:h,onChange:e=>g(e.target.value),disabled:C,renderValue:e=>e?w.find(t=>t.id===e)?.displayName??e:W(i,`Chọn profile…`,`Select profile…`),children:w.map(e=>(0,X.jsx)(np,{value:e.id,children:e.displayName},e.id))}),(0,X.jsx)(J,{...k,disabled:C||!h,sx:{whiteSpace:`nowrap`},onClick:()=>O(`profile.apply`,h,W(i,`Áp dụng profile?`,`Apply profile?`),W(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:W(i,`Áp dụng`,`Apply`)}),(0,X.jsx)(J,{...k,onClick:()=>O(`profile.auto`,null,W(i,`Tự nhận diện profile?`,`Auto-detect profile?`),W(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,X.jsxs)(vy,{icon:(0,X.jsx)(my,{color:`primary`}),title:W(i,`Context engine`,`Context engine`),detail:W(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,X.jsxs)(yy,{children:[(0,X.jsx)(J,{...k,onClick:()=>void D(`context.status`),children:`Index status`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`context.efficiency`),children:`Efficiency`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`context.impact`),children:`Impact`}),(0,X.jsx)(J,{...k,color:`warning`,onClick:()=>O(`context.rebuild`,null,W(i,`Rebuild context index?`,`Rebuild context index?`),W(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,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,X.jsx)(te,{size:`small`,fullWidth:!0,label:W(i,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:_,onChange:e=>v(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,X.jsx)(J,{...k,disabled:C||!_.trim(),onClick:()=>void D(`context.search`,_.trim()),children:`Search`}),(0,X.jsx)(J,{...k,disabled:C||!_.trim(),onClick:()=>void D(`context.pack`,_.trim()),children:`Pack`}),(0,X.jsx)(J,{...k,color:`warning`,onClick:()=>O(`context.compact`,_.trim()||null,W(i,`Compact context bằng model?`,`Compact context with the model?`),W(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,X.jsx)(vy,{icon:(0,X.jsx)(hy,{color:`primary`}),title:W(i,`Memory`,`Memory`),detail:W(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,X.jsx)(yy,{children:(0,X.jsx)(J,{...k,onClick:()=>void D(`memory.status`),children:W(i,`Kiểm tra memory`,`Check memory`)})})}),(0,X.jsxs)(vy,{icon:(0,X.jsx)(Bf,{color:`primary`}),title:W(i,`MCP governance`,`MCP governance`),detail:W(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,X.jsxs)(yy,{children:[(0,X.jsx)(J,{...k,onClick:()=>void D(`mcp.status`),children:`MCP status`}),(0,X.jsx)(J,{...k,onClick:()=>void D(`mcp.doctor`),children:`Doctor`})]}),(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,X.jsx)(I,{size:`small`,fullWidth:!0,displayEmpty:!0,value:x,onChange:e=>S(e.target.value),disabled:C,renderValue:e=>e||W(i,`Chọn MCP…`,`Select MCP…`),children:T.map(e=>(0,X.jsx)(np,{value:e.name,children:e.name},e.connectionRef))}),(0,X.jsx)(J,{...k,disabled:C||!x,onClick:()=>void D(`mcp.detail`,x),children:`Detail`}),(0,X.jsx)(J,{...k,disabled:C||!x,onClick:()=>O(`mcp.approve`,x,W(i,`Phê duyệt MCP?`,`Approve MCP?`),W(i,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,X.jsx)(J,{...k,disabled:C||!x,color:`warning`,onClick:()=>O(`mcp.reject`,x,W(i,`Từ chối MCP?`,`Reject MCP?`),W(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,X.jsx)(J,{...k,disabled:C||!x,color:`warning`,onClick:()=>O(`mcp.reset`,x,W(i,`Reset quyết định MCP?`,`Reset MCP decision?`),W(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,X.jsx)(ft,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:1},children:a?(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,X.jsx)(De,{size:18}),(0,X.jsx)(q,{children:W(i,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,X.jsx)(Op,{color:s?.state===`settled`?`success`:`warning`}),(0,X.jsx)(q,{sx:{fontWeight:800},children:s?s.action:W(i,`Không hoàn tất`,`Not completed`)}),s&&(0,X.jsx)(er,{size:`small`,color:s.state===`settled`?`success`:`warning`,variant:`outlined`,label:s.resultCode}),(s?.effect===`read-only`||s?.effect===`session-setting`)&&(0,X.jsx)(er,{size:`small`,color:s.modelCallObserved?`warning`:`success`,variant:`outlined`,label:s.modelCallObserved?W(i,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),E&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{mt:1},children:W(i,`Fast: ${E.mode} · provider: ${E.provider??`unknown`} · ${E.reasonCode}`,`Fast: ${E.mode} · provider: ${E.provider??`unknown`} · ${E.reasonCode}`)}),l&&(0,X.jsx)(q,{color:`error`,variant:`body2`,sx:{mt:1},children:l}),s?.outputs.map((e,t)=>(0,X.jsx)(Z,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,X.jsx)(tm,{open:p!==null,title:p?.title??``,description:p?.description??``,cancelLabel:W(i,`Hủy`,`Cancel`),confirmLabel:W(i,`Xác nhận và chạy`,`Confirm and run`),onCancel:()=>m(null),onConfirm:()=>{let e=p;m(null),e&&D(e.action,e.argument,!0)}})]})}var xy=K((0,X.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`),Sy=K((0,X.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`),Cy=K((0,X.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`),wy=K([(0,X.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,X.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`),Ty=e=>e.normalize(`NFD`).replace(/\p{M}/gu,``).replace(/đ/g,`d`).replace(/Đ/g,`D`).toLowerCase();function Ey(e,t){let n=Ty(t).split(/\s+/).filter(Boolean),r=Ty(e).split(/[^\p{L}\p{N}]+/u).filter(Boolean);return n.every(e=>r.some(t=>t.startsWith(e)))}function Dy(e,t,n=40){return t.trim()?e.filter(e=>Ey(`${e.label} ${e.keywords??``} ${e.group}`,t)).slice(0,n):e.slice(0,n)}function Oy(e){let t=(0,Y.useRef)(e);t.current=e,(0,Y.useEffect)(()=>{let e=e=>{if(!(e.isComposing||!(e.metaKey||e.ctrlKey)||e.altKey)){if(e.shiftKey){e.key.toLowerCase()===`o`&&t.current.newChat&&(e.preventDefault(),t.current.newChat());return}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 ky({open:e,onClose:t,commands:n,locale:r}){let[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(0),c=(0,Y.useMemo)(()=>Dy(n,i),[n,i]),l=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e&&(a(``),s(0))},[e]),(0,Y.useEffect)(()=>{s(0)},[i]),(0,Y.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,X.jsxs)(ce,{open:e,onClose:t,fullWidth:!0,maxWidth:`sm`,slotProps:{paper:{"aria-label":W(r,`Bảng lệnh`,`Command palette`),sx:{alignSelf:`flex-start`,mt:{xs:2,sm:`12vh`},borderRadius:1,overflow:`hidden`}}},children:[(0,X.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:1,px:2,py:1.25,borderBottom:1,borderColor:`divider`},children:[(0,X.jsx)(hu,{fontSize:`small`,color:`action`}),(0,X.jsx)(k,{autoFocus:!0,fullWidth:!0,value:i,onChange:e=>a(e.target.value),onKeyDown:d,placeholder:W(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":W(r,`Tìm lệnh`,`Search commands`)}})]}),(0,X.jsxs)(ie,{component:`div`,id:`piagent-palette-list`,role:`listbox`,"aria-label":W(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,X.jsxs)(Y.Fragment,{children:[n&&(0,X.jsx)(Sm,{component:`div`,"aria-hidden":!0,disableSticky:!0,sx:{lineHeight:`28px`,fontSize:11,fontWeight:800,letterSpacing:`.04em`,textTransform:`uppercase`},children:n}),(0,X.jsxs)(Dr,{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,gap:2},children:[(0,X.jsx)(q,{sx:{flex:1,minWidth:0,fontSize:14},noWrap:!0,children:e.label}),e.hint&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:e.hint})]})]},e.id)}),!c.length&&(0,X.jsx)(q,{sx:{px:2.5,py:3},color:`text.secondary`,children:W(r,`Không có lệnh nào khớp.`,`No matching command.`)})]})]})}var Ay=K((0,X.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`),jy={"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 My({projectRef:e,projectLabel:t,branch:n,repositories:r,locale:i,onSwitched:a,maxWidth:o=220}){let[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(``),[_,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),x=(0,Y.useRef)(null),S=(0,Y.useRef)(null),[C,w]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{w(null)},[n?.name,n?.detached,e]);let T=C??n,E=!!s,D=()=>{x.current?.abort();let t=new AbortController;x.current=t,m(!1),xc(e,l,t.signal).then(e=>{t.signal.aborted||f(e)},()=>{t.signal.aborted||m(!0)})};(0,Y.useEffect)(()=>(E&&D(),()=>x.current?.abort()),[E,e,l]);let O=()=>{_||(x.current?.abort(),c(null),g(``),b(null),f(null),m(!1),u(null))},k=e=>{x.current?.abort(),f(null),g(``),b(null),u(e)},A=async t=>{v(t.branch),b(null);try{let n=await Sc(e,l===null?t:{...t,repository:l});n.head&&l===null&&w(n.head),a?.(),c(null),g(``),f(null),u(null)}catch(e){b(e instanceof bc?{code:e.code,detail:e.detail}:{code:`branch-switch-failed`,detail:null}),D()}finally{v(null)}},j=d?.repository?d:null;(0,Y.useEffect)(()=>{E&&j&&requestAnimationFrame(()=>S.current?.focus())},[E,j]);let M=h.trim(),N=(0,Y.useMemo)(()=>(j?.branches??[]).filter(e=>!M||e.name.toLowerCase().includes(M.toLowerCase())),[j,M]),P=N.filter(e=>!e.remote),F=N.filter(e=>e.remote),I=(j?.branches??[]).some(e=>e.name===M),L=(d?.running??0)>0,R=e=>(0,X.jsxs)(Dr,{dense:!0,disabled:!e.current&&(L||!!_),selected:e.current,"aria-current":e.current||void 0,onClick:()=>e.current?O():void A({branch:e.name,remote:e.remote}),sx:{borderRadius:1,py:.4},children:[(0,X.jsx)(Mr,{sx:{minWidth:26},children:_===e.name?(0,X.jsx)(De,{size:14}):e.current?(0,X.jsx)(o_,{sx:{fontSize:16}}):e.remote?(0,X.jsx)(vp,{sx:{fontSize:15,color:`text.disabled`}}):null}),(0,X.jsx)(Lr,{primary:e.name,secondary:[e.remote,e.committedAt?Sv(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}`),z=d&&!d.repository?d.repositories??[]:[],B=!T&&!!r?.length;if(!T&&!B)return null;let V={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`}},ee=e=>{e.stopPropagation(),c(e.currentTarget)};return(0,X.jsxs)(X.Fragment,{children:[T?(0,X.jsx)(_o,{describeChild:!0,title:`${bv(T,i)} · ${W(i,`bấm để đổi nhánh`,`click to switch`)}`,children:(0,X.jsx)(Le,{onClick:ee,"aria-haspopup":`dialog`,"aria-expanded":E,"aria-label":T.detached?W(i,`Đổi nhánh Git của ${t} (detached HEAD tại ${T.name})`,`Switch ${t}'s Git branch (detached HEAD at ${T.name})`):W(i,`Đổi nhánh Git của ${t} (đang ở ${T.name})`,`Switch ${t}'s Git branch (on ${T.name})`),sx:V,children:(0,X.jsx)(xv,{branch:T,locale:i,maxWidth:`100%`,tooltip:!1})})}):(0,X.jsx)(_o,{describeChild:!0,title:r.map(e=>`${e.name} · ${e.branch?.name??`?`}`).join(`
102
- `),children:(0,X.jsx)(Le,{onClick:ee,"aria-haspopup":`dialog`,"aria-expanded":E,"aria-label":W(i,`${r.length} repo Git trong ${t}`,`${r.length} Git repositories in ${t}`),sx:V,children:(0,X.jsxs)(Z,{component:`span`,sx:{display:`inline-flex`,alignItems:`center`,gap:.4,whiteSpace:`nowrap`},children:[(0,X.jsx)(yv,{sx:{fontSize:`1.1em`}}),W(i,`${r.length} repo`,`${r.length} repos`)]})})}),(0,X.jsxs)(le,{open:E,anchorEl:s,onClose:O,anchorOrigin:{vertical:`bottom`,horizontal:`left`},slotProps:{paper:{role:`dialog`,"aria-label":W(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,X.jsxs)(Z,{sx:{display:`flex`,alignItems:`center`,gap:.5,minWidth:0},children:[l!==null&&(0,X.jsx)(Ze,{size:`small`,"aria-label":W(i,`Về danh sách repo`,`Back to the repositories`),onClick:()=>k(null),children:(0,X.jsx)(pm,{sx:{fontSize:18}})}),(0,X.jsxs)(Z,{sx:{minWidth:0},children:[(0,X.jsx)(q,{variant:`subtitle2`,sx:{fontWeight:650},children:B&&l===null?W(i,`Repo Git`,`Git repositories`):W(i,`Nhánh Git`,`Git branches`)}),(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,children:l===null?t:`${t} / ${l}`})]})]}),L&&(0,X.jsx)(st,{severity:`warning`,sx:{py:0,fontSize:12.5},children:W(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.`)}),j&&j.changedFiles>0&&!L&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:W(i,`${j.changedFiles} file đang sửa dở sẽ đi theo sang nhánh mới; Git từ chối nếu chúng bị ghi đè.`,`${j.changedFiles} changed file(s) come along to the new branch; Git refuses if they would be overwritten.`)}),y&&(0,X.jsxs)(st,{severity:`error`,sx:{py:0,fontSize:12.5},children:[W(i,...jy[y.code]??[`Không chuyển được nhánh.`,`The branch could not be switched.`]),y.detail&&(0,X.jsx)(Z,{component:`pre`,sx:{m:0,mt:.5,whiteSpace:`pre-wrap`,font:`11px ui-monospace, monospace`,opacity:.85},children:y.detail})]}),!(d&&!d.repository)&&(0,X.jsx)(te,{inputRef:S,size:`small`,value:h,onChange:e=>g(e.target.value),disabled:!j||!!_,placeholder:W(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":W(i,`Tìm nhánh`,`Find a branch`)}},onKeyDown:e=>{if(e.key===`Enter`&&M&&!L&&!_){let e=j?.branches.find(e=>e.name===M);A(e?{branch:e.name,remote:e.remote}:{branch:M,create:!0})}}}),(0,X.jsxs)(Z,{sx:{overflowY:`auto`,minHeight:0,mx:-.5},children:[!d&&!p&&(0,X.jsx)(Z,{sx:{display:`flex`,justifyContent:`center`,py:2},children:(0,X.jsx)(De,{size:18})}),p&&(0,X.jsx)(st,{severity:`error`,sx:{py:0,fontSize:12.5},children:W(i,`Không đọc được danh sách nhánh.`,`The branches could not be read.`)}),d&&!d.repository&&z.length>0&&(0,X.jsx)(ie,{dense:!0,disablePadding:!0,"aria-label":W(i,`Repo trong folder`,`Repositories in the folder`),children:z.map(e=>(0,X.jsxs)(Dr,{dense:!0,onClick:()=>k(e.name),sx:{borderRadius:1,py:.4},children:[(0,X.jsx)(Lr,{primary:e.name,secondary:(0,X.jsxs)(Z,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.5,minWidth:0,width:`100%`},children:[e.head?(0,X.jsx)(xv,{branch:e.head,locale:i,maxWidth:`100%`,tooltip:!1}):W(i,`chưa có commit`,`no commits`),e.changedFiles>0&&(0,X.jsxs)(Z,{component:`span`,sx:{flexShrink:0},children:[`· `,W(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,X.jsx)(Ay,{sx:{fontSize:18,color:`text.disabled`}})]},e.name))}),d&&!d.repository&&z.length===0&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:W(i,...jy[`not-a-git-repository`])}),j&&(0,X.jsxs)(ie,{dense:!0,disablePadding:!0,children:[M&&!I&&(0,X.jsxs)(Dr,{dense:!0,disabled:L||!!_,onClick:()=>void A({branch:M,create:!0}),sx:{borderRadius:1},children:[(0,X.jsx)(Mr,{sx:{minWidth:26},children:_===M?(0,X.jsx)(De,{size:14}):(0,X.jsx)(sf,{sx:{fontSize:16}})}),(0,X.jsx)(Lr,{primary:W(i,`Tạo nhánh mới “${M}”`,`Create branch “${M}”`),secondary:W(i,`từ ${j.head?.name??`HEAD`}`,`from ${j.head?.name??`HEAD`}`),slotProps:{primary:{noWrap:!0,sx:{fontSize:12.5}},secondary:{sx:{fontSize:11}}}})]}),P.map(R),F.length>0&&(0,X.jsx)(Sm,{disableSticky:!0,sx:{lineHeight:`26px`,fontSize:11,bgcolor:`transparent`},children:W(i,`Trên remote`,`On a remote`)}),F.map(R),N.length===0&&!M&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{px:1},children:W(i,`Chưa có nhánh nào.`,`No branches yet.`)}),j.truncated&&(0,X.jsx)(q,{variant:`caption`,color:`text.disabled`,sx:{px:1},children:W(i,`Chỉ hiện 200 nhánh có commit mới nhất.`,`Showing the 200 most recently committed branches.`)})]})]})]})]})}var Ny=()=>typeof navigator<`u`&&/Mac|iPhone|iPad/.test(navigator.platform)?`⌘`:`Ctrl`,Py={height:28,px:1,gap:.75,fontSize:12,color:`text.secondary`,alignItems:`center`},Fy={...Py,borderRadius:0,"&:hover":{bgcolor:`action.hover`,color:`text.primary`},"&.Mui-focusVisible":{outline:`2px solid`,outlineColor:`primary.main`,outlineOffset:-2}};function Iy({locale:e,connection:t,running:n,session:r,onBranchSwitched:i,onUpdates:a,onPalette:o}){let{status:s,supported:c}=yh(),l=tf(e=>e.breakpoints.up(`md`)),u=gh(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,X.jsxs)(Z,{component:`footer`,"aria-label":W(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,X.jsxs)(Q,{direction:`row`,sx:Py,children:[(0,X.jsx)(Z,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:t===`connected`?`success.main`:`warning.main`}}),(0,X.jsx)(`span`,{children:t===`connected`?`Gateway live`:t}),(0,X.jsx)(Z,{component:`span`,sx:{color:`text.disabled`},children:`local`})]}),(r?.gitBranch||!!r?.gitRepositories?.length)&&(0,X.jsx)(Q,{direction:`row`,sx:{...Py,minWidth:0},children:(0,X.jsx)(My,{projectRef:r.projectRef,projectLabel:r.projectLabel,branch:r.gitBranch,repositories:r.gitRepositories,locale:e,maxWidth:320,onSwitched:i})}),n>0&&(0,X.jsxs)(Q,{direction:`row`,sx:Py,children:[(0,X.jsx)(De,{size:10,thickness:6}),(0,X.jsx)(`span`,{children:W(e,`${n} đang chạy`,`${n} running`)})]}),(0,X.jsx)(Z,{sx:{flex:1}}),c&&(0,X.jsx)(_o,{describeChild:!0,title:d?W(e,`Mở Cập nhật trong Cài đặt`,`Open Updates in Settings`):W(e,`Phiên bản và cập nhật`,`Version and updates`),children:(0,X.jsx)(Le,{onClick:a,sx:{...Fy,...d&&{color:`primary.contrastText`,bgcolor:`primary.main`,fontWeight:700,"&:hover":{bgcolor:`primary.dark`,color:`primary.contrastText`}}},children:u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(De,{size:11,thickness:6,color:`inherit`}),W(e,`Đang cập nhật lên ${s?.job?.to}…`,`Updating to ${s?.job?.to}…`)]}):d?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(uh,{sx:{fontSize:15}}),W(e,`Cập nhật Piagent ${s?.piagent.latest}`,`Update Piagent ${s?.piagent.latest}`)]}):(0,X.jsx)(`span`,{children:f})})}),(0,X.jsxs)(Le,{onClick:o,"aria-label":W(e,`Mở bảng lệnh`,`Open command palette`),sx:Fy,children:[(0,X.jsxs)(Z,{component:`kbd`,sx:{font:`inherit`,fontSize:11,px:.6,border:1,borderColor:`divider`,borderRadius:.75},children:[Ny(),` K`]}),(0,X.jsx)(`span`,{children:W(e,`Lệnh`,`Commands`)})]})]}):null}function Ly(e){let t=W(e,`Chung`,`General`),n=`Agent`,r=W(e,`Công cụ`,`Tools`),i=W(e,`Thông tin`,`Information`);return[{id:`general`,group:t,label:W(e,`Giao diện`,`Appearance`),icon:(0,X.jsx)(vm,{}),keywords:`ngôn ngữ language chủ đề theme sáng tối light dark tiếng việt english`},{id:`updates`,group:t,label:W(e,`Cập nhật`,`Updates`),icon:(0,X.jsx)(uh,{}),keywords:`update phiên bản version pi piagent npm nâng cấp upgrade`},{id:`shortcuts`,group:t,label:W(e,`Phím tắt`,`Shortcuts`),icon:(0,X.jsx)(Cy,{}),keywords:`keyboard bàn phím shortcut lệnh command palette enter`},{id:`models`,group:n,label:W(e,`Nhà cung cấp & model`,`Providers & models`),icon:(0,X.jsx)(wy,{}),keywords:`model provider thinking đăng nhập login oauth tài khoản account công ty company`},{id:`controls`,group:n,label:W(e,`Điều khiển project`,`Project controls`),icon:(0,X.jsx)(xy,{}),keywords:`project runtime khởi động lại restart session`},{id:`permissions`,group:n,label:W(e,`Quyền truy cập`,`Access`),icon:(0,X.jsx)(_m,{}),keywords:`permission quyền sandbox đọc ghi read write network mạng`},{id:`connections`,group:r,label:W(e,`MCP & kết nối`,`MCP & connections`),icon:(0,X.jsx)(Bf,{}),keywords:`mcp server tool công cụ oauth kết nối connection`},{id:`usage`,group:i,label:W(e,`Sử dụng & context`,`Usage & context`),icon:(0,X.jsx)(hy,{}),keywords:`token usage context ngữ cảnh input output`},{id:`about`,group:i,label:`Piagent`,icon:(0,X.jsx)(Sy,{}),keywords:`gateway protocol runtime giới thiệu about`}]}function Ry(e,t){return t.trim()?e.filter(e=>Ey(`${e.label} ${e.group} ${e.keywords}`,t)):e}function zy({section:e,onSection:t,onBack:n}){let{locale:r}=ze(),{status:i}=yh(),[a,o]=(0,Y.useState)(``),s=(0,Y.useMemo)(()=>Ry(Ly(r),a),[r,a]),c=!!(i?.updateAvailable&&i.installable),l=``;return(0,X.jsxs)(Z,{component:`nav`,"aria-label":W(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,X.jsxs)(Q,{direction:`row`,sx:{minHeight:48,alignItems:`center`,justifyContent:`space-between`,px:1},children:[(0,X.jsx)(q,{id:`piagent-settings-title`,sx:{fontWeight:700},children:W(r,`Cài đặt`,`Settings`)}),(0,X.jsx)(Ze,{"aria-label":W(r,`Đóng cài đặt`,`Close settings`),onClick:n,children:(0,X.jsx)(Ph,{})})]}),(0,X.jsxs)(ft,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:.75,px:1,mx:.5,mb:1,borderRadius:1},children:[(0,X.jsx)(hu,{fontSize:`small`,color:`action`}),(0,X.jsx)(k,{value:a,onChange:e=>o(e.target.value),placeholder:W(r,`Tìm cài đặt`,`Search settings`),inputProps:{"aria-label":W(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,X.jsxs)(ie,{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,X.jsxs)(Z,{sx:{display:{xs:`contents`,sm:`block`}},children:[i&&(0,X.jsx)(Sm,{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,X.jsxs)(Dr,{selected:e===n.id,onClick:()=>t(n.id),children:[(0,X.jsx)(Mr,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:n.icon}),(0,X.jsx)(Lr,{primary:n.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:e===n.id?800:650}}}}),n.id===`updates`&&c&&(0,X.jsx)(Z,{"aria-label":W(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,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{px:1.5,py:2},children:W(r,`Không có mục nào khớp.`,`No matching setting.`)})]}),i?.piagent.installed&&(0,X.jsx)(q,{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 By(){let{locale:e}=ze(),t=Ny(),n=[[`${t} K`,W(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} ,`,W(e,`Mở Cài đặt`,`Open Settings`)],[`Enter`,W(e,`Gửi tin nhắn`,`Send the message`)],[`Shift Enter`,W(e,`Xuống dòng trong tin nhắn`,`New line in the message`)],[`1 – 5`,W(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`,W(e,`Đóng hộp thoại hoặc bảng lệnh`,`Close a dialog or the palette`)]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{component:`h1`,variant:`h1`,sx:{mb:3},children:W(e,`Phím tắt`,`Shortcuts`)}),(0,X.jsx)(ft,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:n.map(([e,t],n)=>(0,X.jsxs)(Q,{direction:`row`,sx:{px:2.25,py:1.5,gap:2,alignItems:`center`,justifyContent:`space-between`,borderTop:+!!n,borderColor:`divider`},children:[(0,X.jsx)(q,{children:t}),(0,X.jsx)(Z,{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 Vy(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function Hy({children:e}){return(0,X.jsx)(q,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function Uy({icon:e,title:t,detail:n,action:r}){return(0,X.jsxs)(Q,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,X.jsxs)(Q,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,X.jsxs)(Z,{children:[(0,X.jsx)(q,{sx:{fontWeight:760},children:t}),n&&(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function Wy(){let{locale:e,colorMode:t,setLocale:n,setColorMode:r}=ze();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hy,{children:W(e,`Giao diện`,`Appearance`)}),(0,X.jsxs)(ft,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:[(0,X.jsx)(Uy,{icon:(0,X.jsx)(l_,{color:`primary`}),title:W(e,`Ngôn ngữ`,`Language`),detail:W(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,X.jsxs)(Zr,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&n(t),children:[(0,X.jsx)(Gr,{value:`vi`,children:`VI`}),(0,X.jsx)(Gr,{value:`en`,children:`EN`})]})}),(0,X.jsx)(or,{}),(0,X.jsx)(Uy,{icon:t===`dark`?(0,X.jsx)(Oo,{color:`primary`}):(0,X.jsx)(Do,{color:`primary`}),title:W(e,`Chủ đề`,`Theme`),detail:W(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,X.jsxs)(Zr,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&r(t),children:[(0,X.jsx)(Gr,{value:`light`,children:W(e,`Sáng`,`Light`)}),(0,X.jsx)(Gr,{value:`dark`,children:W(e,`Tối`,`Dark`)})]})})]})]})}function Gy({options:e,snapshot:t,activeModel:n,observedProvider:r}){let{locale:i}=ze(),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,X.jsx)(p_,{color:`primary`}),title:a?.route===`codex-first`?`Codex Web Search`:W(i,`Tìm kiếm web`,`Web search`),detail:a?.route===`codex-first`?W(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`?W(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.`):W(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`?W(i,`Ưu tiên Codex`,`Codex first`):a?.state===`configured`?W(i,`Đã cấu hình`,`Configured`):W(i,`Chưa có`,`Unavailable`),ready:a?.state===`configured`},{key:`vision`,icon:(0,X.jsx)(dy,{color:`primary`}),title:d?`Codex Vision`:W(i,`Vision của model`,`Model vision`),detail:u===!0?W(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?W(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.`):W(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?W(i,`Đang dùng`,`Active`):u===!1?W(i,`Không hỗ trợ`,`Unsupported`):W(i,`Chưa rõ`,`Unknown`),ready:u===!0}];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(q,{variant:`h2`,sx:{mt:3,mb:.5},children:W(i,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:W(i,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,X.jsx)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:f.map(e=>(0,X.jsx)(ft,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,X.jsxs)(Q,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,X.jsx)(Z,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:1,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,X.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,X.jsx)(q,{sx:{fontWeight:800},children:e.title}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,X.jsx)(er,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function Ky({options:e,auth:t,refreshAuth:n,session:r,snapshot:i,onSetModel:a,onSetThinking:o}){let{locale:s}=ze(),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),f=i?.session.model.state===`known`?i.session.model.value:null,p=(0,Y.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??`—`,v=r?.managedThinkingLevels??h?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],y=async e=>{if(e){l(!0),d(null);try{await e()}catch{d(W(s,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{l(!1)}}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hy,{children:W(s,`Nhà cung cấp & model`,`Providers & models`)}),r&&(0,X.jsxs)(ft,{variant:`outlined`,sx:{p:2.25,borderRadius:1,mb:2},children:[(0,X.jsxs)(Q,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,X.jsx)(Dp,{name:f?.provider??r.modelLabel??`model`,size:38}),(0,X.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,X.jsx)(q,{sx:{fontWeight:700},children:W(s,`Model của session hiện tại`,`Current session model`)}),(0,X.jsxs)(q,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[_,` · `,$(r.thinkingLevel,s)]})]}),(0,X.jsx)(er,{size:`small`,variant:`outlined`,label:W(s,`Đang dùng`,`In use`)})]}),(0,X.jsxs)(Q,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,X.jsxs)(Z,{sx:{flex:1},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,X.jsx)(I,{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 y(()=>a?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,X.jsx)(np,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,X.jsxs)(Z,{sx:{width:{md:220}},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,X.jsx)(I,{fullWidth:!0,size:`small`,value:r.thinkingLevel===`unknown`?`off`:r.thinkingLevel,disabled:c||!o||r.liveState===`running`,onChange:e=>void y(()=>o?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:v.map(e=>(0,X.jsx)(np,{value:e,children:$(e,s)},e))})]})]}),u&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:u})]}),(0,X.jsx)(Gy,{options:e,snapshot:i,activeModel:h,observedProvider:f?.provider}),(0,X.jsx)(q,{variant:`h2`,sx:{mt:3,mb:.5},children:W(s,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:W(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,X.jsx)(py,{catalog:t,refresh:n}),(0,X.jsx)(q,{variant:`h2`,sx:{mt:3,mb:.5},children:W(s,`Danh mục model`,`Model catalog`)}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:W(s,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,X.jsx)(Z,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:p.map(([e,t])=>(0,X.jsxs)(ft,{variant:`outlined`,sx:{p:1.5,borderRadius:1},children:[(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,X.jsx)(Dp,{name:e,size:32}),(0,X.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,X.jsx)(q,{noWrap:!0,sx:{fontWeight:700,textTransform:`capitalize`},children:e}),(0,X.jsxs)(q,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,X.jsx)(er,{size:`small`,color:`success`,variant:`outlined`,label:W(s,`Sẵn sàng`,`Ready`)})]}),(0,X.jsxs)(Z,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,X.jsx)(er,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,X.jsx)(er,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&p.length===0&&(0,X.jsx)(q,{color:`text.secondary`,children:W(s,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function qy({value:e,loading:t,sessionRef:n,onChanged:r}){let{locale:i}=ze();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hy,{children:W(i,`MCP & kết nối`,`MCP & connections`)}),t?(0,X.jsx)(De,{size:22}):(0,X.jsxs)(Q,{spacing:1,children:[(e?.connections??[]).map(e=>(0,X.jsx)(ft,{variant:`outlined`,sx:{p:1.75,borderRadius:1},children:(0,X.jsxs)(Q,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,X.jsx)(Dp,{name:e.name,size:38}),(0,X.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,X.jsx)(q,{noWrap:!0,sx:{fontWeight:800},children:e.name}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,children:qp(e,i)})]}),n?(0,X.jsx)(Yp,{sessionRef:n,connection:e,onChanged:r}):(0,X.jsx)(er,{size:`small`,variant:`outlined`,label:W(i,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,X.jsx)(q,{color:`text.secondary`,children:W(i,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function Jy({snapshot:e,session:t,onSetPermission:n}){let{locale:r}=ze(),i=e?.session.permissionProfile,[a,o]=(0,Y.useState)(i?.state===`known`?i.value??null:null),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{o(t?.managedPermission??(i?.state===`known`?i.value??null:null))},[t?.sessionRef,t?.managedPermission,i?.state,i?.value]);let p=async e=>{if(n){c(!0),u(null);try{await n(e),o(e)}catch{u(W(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`||e===`bypass`){f(e);return}p(e)},h=[{mode:`read-only`,detail:W(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:W(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:W(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.`)},...!t?.managed||t.managedBypass?[{mode:`bypass`,detail:lm(r)}]:[]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hy,{children:W(r,`Quyền truy cập`,`Access`)}),(0,X.jsx)(q,{variant:`h2`,sx:{mb:.5},children:W(r,`Hồ sơ quyền`,`Permission profile`)}),(0,X.jsx)(q,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:W(r,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,X.jsx)(ft,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:h.map((e,i)=>(0,X.jsxs)(Z,{children:[(0,X.jsx)(Uy,{icon:(0,X.jsx)(_m,{color:e.mode===`bypass`?`error`:e.mode===`trusted-full-access`?`warning`:`primary`}),title:$(e.mode,r),detail:e.detail,action:(0,X.jsx)(J,{size:`small`,variant:a===e.mode?`contained`:`outlined`,color:e.mode===`bypass`?`error`:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":a===e.mode,disabled:s||!t||!n||t.liveState===`running`,onClick:()=>m(e.mode),children:$(e.mode,r)})}),i<h.length-1&&(0,X.jsx)(or,{})]},e.mode))}),l&&(0,X.jsx)(q,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:l}),(0,X.jsx)(tm,{open:d!==null,title:d===`bypass`?W(r,`Bật Bypass?`,`Turn on Bypass?`):W(r,`Bật toàn quyền?`,`Enable full access?`),description:d===`bypass`?lm(r):W(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:W(r,`Hủy`,`Cancel`),confirmLabel:d===`bypass`?W(r,`Bật Bypass`,`Turn on Bypass`):W(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>f(null),onConfirm:()=>{let e=d;f(null),e&&p(e)}})]})}function Yy({session:e,snapshot:t}){let{locale:n}=ze(),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=[[W(n,`Context`,`Context`),r?.percent==null?`—`:`${Math.round(r.percent)}%`],[`Tokens`,`${Vy(r?.tokens,n)} / ${Vy(r?.contextWindow,n)}`],[W(n,`Input`,`Input`),Vy(t?.usage.sessionTotal.input,n)],[W(n,`Output`,`Output`),Vy(t?.usage.sessionTotal.output,n)],[W(n,`Continuation`,`Continuation`),Vy(t?.continuation.remaining,n)],[`Verifier`,t?.verification.state??`—`]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hy,{children:W(n,`Usage & context`,`Usage & context`)}),(0,X.jsx)(Z,{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,X.jsxs)(ft,{variant:`outlined`,sx:{p:2,borderRadius:1},children:[(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:e}),(0,X.jsx)(q,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:800},children:t})]},e))})]})}function Xy({capabilities:e,connection:t}){let{locale:n}=ze(),r=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[W(n,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Hy,{children:`Piagent`}),(0,X.jsx)(ft,{variant:`outlined`,sx:{borderRadius:1,overflow:`hidden`},children:r.map(([e,t],n)=>(0,X.jsxs)(Z,{children:[(0,X.jsxs)(Q,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,X.jsx)(q,{color:`text.secondary`,children:e}),(0,X.jsx)(q,{sx:{fontWeight:760},children:String(t)})]}),n<r.length-1&&(0,X.jsx)(or,{})]},String(e)))})]})}function Zy({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}=ze(),[f,p]=(0,Y.useState)(),[m,h]=(0,Y.useState)(),[g,_]=(0,Y.useState)(),[v,y]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{let e=new AbortController;return ps(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]),(0,Y.useEffect)(()=>{let e=new AbortController;return ms(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,Y.useEffect)(()=>{if(!r){_(void 0);return}let e=new AbortController;return y(!0),_(void 0),Fs(r.sessionRef,e.signal).then(_).catch(()=>void 0).finally(()=>{e.signal.aborted||y(!1)}),()=>e.abort()},[r?.sessionRef]),(0,X.jsxs)(Z,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`236px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,X.jsx)(zy,{section:e,onSection:t,onBack:n}),(0,X.jsxs)(Z,{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,X.jsx)(Wy,{}),e===`updates`&&(0,X.jsx)(Eh,{}),e===`shortcuts`&&(0,X.jsx)(By,{}),e===`models`&&(0,X.jsx)(Ky,{options:f,auth:m,refreshAuth:async()=>{let[e,t]=await Promise.all([ms(),ps()]);h(e),p(t)},session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,X.jsx)(qy,{value:g,loading:v,sessionRef:r?.sessionRef,onChanged:async e=>{if(e){_(e);return}r&&_(await Fs(r.sessionRef).catch(()=>g))}}),e===`controls`&&(0,X.jsx)(by,{session:r,options:f,connections:g,onCompleted:u}),e===`permissions`&&(0,X.jsx)(Jy,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,X.jsx)(Yy,{session:r,snapshot:i}),e===`about`&&(0,X.jsx)(Xy,{capabilities:a,connection:o})]})]})}function Qy(e){let{locale:t,actions:n}=e,r=W(t,`Lệnh`,`Commands`),i=Ny(),a=[];e.canCreate&&a.push({id:`new-chat`,group:r,label:W(t,`Cuộc trò chuyện mới`,`New chat`),hint:`${i} ⇧ O`,keywords:`new create tạo`,run:n.newChat}),e.update.available&&e.update.latest&&a.push({id:`update-now`,group:r,label:W(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:W(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:W(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:W(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`?W(t,`Chuyển sang chủ đề sáng`,`Switch to the light theme`):W(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:W(t,`Làm mới`,`Refresh`),keywords:`reload tải lại`,run:n.refresh});let o=W(t,`Cài đặt`,`Settings`);for(let e of Ly(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=W(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 $y=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}},eb=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()}}}},tb=`piagent-gateway-event-cursor-v1`,nb=3e4,rb=12e4,ib=4001,ab=class extends Error{reasonCode;constructor(e){super(e),this.name=`SessionSendRejectedError`,this.reasonCode=e}};function ob(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 sb(e,t){if(t!==null)try{window.sessionStorage.setItem(tb,JSON.stringify({gatewayInstanceRef:e,sequence:t}))}catch{}}function cb(e){return`${e}_${crypto.randomUUID().replaceAll(`-`,``)}`}function lb(e){return e.phase===`rejected`&&e.resultCode===`stale-revision`&&e.error?.code===`session-revision-stale`}var ub=280,db=320,fb=`min(44vw, 860px)`,pb=`piagent-webui-workspace-panel`;function mb({session:e,live:t,locale:n}){let r=Cv(e,t),[i,a]=r===`running`?[W(n,`Đang chạy`,`Running`),`primary`]:r===`elsewhere`?[W(n,`Đang chạy ở nơi khác`,`Running elsewhere`),`info`]:r===`attention`?Jh(e,t)===`question`?[W(n,`Cần bạn trả lời`,`Needs your answer`),`warning`]:[W(n,`Cần duyệt`,`Needs approval`),`warning`]:r===`recovery`?[W(n,`Cần khôi phục`,`Recovery needed`),`error`]:r===`failed`?[W(n,`Lượt cuối lỗi`,`Last turn failed`),`error`]:[W(n,`Sẵn sàng`,`Ready`),`default`];return(0,X.jsx)(er,{size:`small`,variant:`outlined`,color:a,label:i})}function hb({session:e,snapshot:t,locale:n,live:r,canSend:i,canRestart:a,send:o,abort:s,restart:c,onInspector:l,commandActions:u}){let d=e.sessionRef,f=Jm(d),[p,m]=(0,Y.useState)(()=>Km(d)),[h,g]=(0,Y.useState)(!1),[_,v]=(0,Y.useState)(),y=e=>{m(e),qm(d,e)},b=e.modelLabel===`agent-watch-auto`,x=!!(r&&!r.complete),S=oh({locale:n,company:b,running:x,pinned:e.pinned,bypass:e.managedBypass===!0,fast:e.managedFast===`on`||e.managedFast===`off`?e.managedFast:null,thinkingLevels:e.managedThinkingLevels??(b?[]:[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),loadModels:()=>ps().then(e=>e.models.map(e=>({modelRef:e.modelRef,label:e.displayName}))),actions:{...u,stop:s}}),C=S.map(e=>({kind:`command`,name:e.name,argumentHint:e.argumentHint,origin:`piagent`,scope:`project`,description:e.description})),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=e=>{e.isComposing||E||(e.key===`Escape`&&x&&!e.metaKey&&!e.ctrlKey?(e.preventDefault(),s()):e.key===`/`&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&i&&(e.preventDefault(),y(`/`),requestAnimationFrame(()=>{let e=O.inputRef.current;e?.focus(),e?.setSelectionRange(1,1)})))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});let O=Nm({projectRef:e.projectRef,value:p,locale:n,builtIns:C,onChange:e=>{y(e),B(null)}});(0,Y.useEffect)(()=>{let e=e=>{e.detail===d&&(m(Km(d)),requestAnimationFrame(()=>O.inputRef.current?.focus()))};return window.addEventListener(Xm,e),()=>window.removeEventListener(Xm,e)},[d]);let[k,A]=(0,Y.useState)(()=>f?.attachments??[]),[j,M]=(0,Y.useState)(!1),[N,P]=(0,Y.useState)(()=>f?.messageRequestId??`message-request.${crypto.randomUUID()}`),[F,I]=(0,Y.useState)(!1),[L,R]=(0,Y.useState)(null),[z,B]=(0,Y.useState)(null),[V,ee]=(0,Y.useState)(()=>f?.sendUnconfirmed??!1);(0,Y.useEffect)(()=>{Ym(d,k.length||V?{attachments:k,messageRequestId:N,sendUnconfirmed:V}:null)},[d,k,N,V]),(0,Y.useEffect)(()=>{if(!V)return;let e=window.setTimeout(()=>{ee(!1),B({tone:`error`,text:W(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.`)})},rb+15e3);return()=>window.clearTimeout(e)},[V,n]);let[ne,re]=(0,Y.useState)(!1),[ie,ae]=(0,Y.useState)(null),[oe,se]=(0,Y.useState)(!1),[ce,le]=(0,Y.useState)(0),ue=(0,Y.useRef)(0);(0,Y.useEffect)(()=>{let e=e=>{hd(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]);let de=t?.capabilities.capabilities.attachments,fe=(0,Y.useMemo)(()=>new Set(de?.status===`available`?de.mimeTypes:[]),[de]),pe=(0,Y.useMemo)(()=>md(fe),[fe]),me=!!t&&de?.status===`available`&&i&&!h&&!V&&!F&&k.length<4,he=async r=>{if(!(!r?.length||!t||de?.status!==`available`||F)){I(!0),R(null);try{let i=await _d({files:r,snapshot:t,messageRequestId:N,existing:k,allowed:fe,locale:n,stage:t=>fc(e.sessionRef,t)});A(i.attachments),R(i.status)}catch{R(W(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{I(!1)}}},ge=async r=>{if(!(!t||h||F)){I(!0),R(null);try{let i=await vd({snapshot:t,messageRequestId:N,attachmentRef:r,locale:n,stage:t=>fc(e.sessionRef,t)});i.discarded?A(e=>e.filter(e=>e.attachmentRef!==r)):R(i.status)}catch{R(W(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{I(!1)}}};(0,Y.useEffect)(()=>{let t=new AbortController;return v(void 0),Fs(e.sessionRef,t.signal).then(v).catch(()=>void 0),()=>t.abort()},[e.sessionRef,e.sessionRevision]);let H=(0,Y.useRef)(!1),_e=async()=>{let e=p;if(!e.trim()||h||V||H.current)return;let t=k.length===0?rh(e,S):null;if(t){B(null),T(null);let e=await t.command.run(t.argument);if(`confirm`in e){D(e.confirm),y(``);return}if(!(`send`in e)){T(e),e.tone!==`warning`&&y(``);return}}H.current=!0,g(!0),B(null);let r=k.map(e=>e.attachmentRef);try{if((await o(e,r.length>0?{messageRequestId:N,attachmentRefs:r,attachments:k}:void 0)).state===`unconfirmed`){Ym(d,{attachments:k,messageRequestId:N,sendUnconfirmed:!0}),ee(!0),B({tone:`warning`,text:W(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(``),A([]),R(null),P(`message-request.${crypto.randomUUID()}`),Ym(d,null)}catch{B({tone:`error`,text:W(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,g(!1)}};(0,Y.useEffect)(()=>{!V||r?.messageRequestId!==N||r.delivery!==`admitted`||(y(``),A([]),R(null),B(null),ee(!1),P(`message-request.${crypto.randomUUID()}`))},[r?.delivery,r?.messageRequestId,N,V]);let ve=async()=>{if(!(h||V)){g(!0),B(null);try{await o(W(n,`tiếp tục`,`continue`))}catch{B({tone:`error`,text:W(n,`Chưa gửi được. Thử lại khi session sẵn sàng.`,`Not sent. Retry when the session is ready.`)})}finally{g(!1)}}},ye=async t=>{if(t){v(t);return}v(await Fs(e.sessionRef).catch(()=>_))},be=async()=>{if(!ne){re(!0),ae(null);try{await c()}catch(e){ae(e instanceof Error?e.message:null)}finally{re(!1)}}},xe=r?.runtimeRecovery??(e.state===`recovery-required`?`stale`:null);return(0,X.jsxs)(Z,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,X.jsxs)(Z,{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,X.jsx)(Lf,{locale:n,onConnected:()=>le(e=>e+1)},e.sessionRef),(0,X.jsx)(Z,{sx:{width:`100%`},children:(0,X.jsx)(pv,{reload:ce,sessionRef:e.sessionRef,sessionRevision:e.sessionRevision,live:r,approvals:t?.approvals,locale:n,onOpenActivity:()=>l(`activity`),onContinue:i&&!h&&!V&&e.liveState!==`running`&&(!r||r.complete)?()=>void ve():void 0},e.sessionRef)})]}),(0,X.jsxs)(Z,{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,X.jsx)(st,{severity:`info`,role:`status`,sx:{maxWidth:820,mx:`auto`,mb:1},children:W(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.`)}),xe&&(0,X.jsx)(st,{severity:xe===`recovered`?`success`:xe===`failed`?`error`:`warning`,action:(xe===`failed`||xe===`required`||xe===`stale`)&&a&&e.liveState!==`running`?(0,X.jsx)(J,{color:`inherit`,size:`small`,disabled:ne,onClick:()=>void be(),children:ne?W(n,`Đang khởi động…`,`Restarting…`):W(n,`Khởi động lại phiên`,`Restart session`)}):void 0,sx:{maxWidth:860,mx:`auto`,mb:1},children:xe===`recovered`?W(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.`):xe===`failed`?ie?.startsWith(`company-`)&&Of(ie,null,n)?`${Of(ie,null,n).title}: ${Of(ie,null,n).text}`:W(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.`):xe===`stale`&&[`session-runtime-open-failed`,`session-runtime-dispose-failed`].includes(e.reasonCode??``)?W(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.`):xe===`stale`?W(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.`):xe===`restarting`?W(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.`):W(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,X.jsxs)(Z,{sx:{position:`relative`,maxWidth:860,mx:`auto`,border:1,borderColor:oe?`primary.main`:`divider`,borderStyle:oe?`dashed`:`solid`,borderRadius:1,bgcolor:`background.paper`,p:1.15,boxShadow:`0 14px 44px rgba(0,0,0,.14)`},onDragEnter:e=>{hd(e.dataTransfer)&&(ue.current+=1,se(!0))},onDragOver:e=>{hd(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=me?`copy`:`none`)},onDragLeave:e=>{hd(e.dataTransfer)&&(--ue.current,ue.current<=0&&(ue.current=0,se(!1)))},onDrop:e=>{hd(e.dataTransfer)&&(e.preventDefault(),ue.current=0,se(!1),me&&he(e.dataTransfer.files))},children:[oe&&(0,X.jsxs)(Z,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:1,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,X.jsx)(q,{sx:{fontWeight:750},children:me?W(n,`Thả tài liệu vào đây`,`Drop documents here`):k.length>=4?W(n,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):W(n,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),me&&(0,X.jsx)(q,{variant:`caption`,color:`text.secondary`,children:W(n,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),k.length>0&&(0,X.jsx)(Q,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pb:.75},"aria-label":W(n,`File sẽ gửi cùng tin nhắn`,`Files to send with the message`),children:k.map(e=>(0,X.jsx)(er,{size:`small`,variant:`outlined`,color:e.kind===`document`?`success`:`default`,label:`${e.displayName} · ${pd(e,n)}`,onDelete:h||V||F?void 0:()=>void ge(e.attachmentRef),deleteIcon:(0,X.jsx)(lf,{"aria-label":`${W(n,`Bỏ`,`Remove`)} ${e.displayName}`,role:`button`})},e.attachmentRef))}),w&&(0,X.jsx)(st,{severity:w.tone,onClose:()=>T(null),sx:{mb:.75,whiteSpace:`pre-line`},children:w.text}),(0,X.jsx)(te,{fullWidth:!0,multiline:!0,minRows:2,disabled:!i||h||V,value:p,inputRef:O.inputRef,...O.inputProps,onChange:e=>{y(e.target.value),B(null),O.track(e)},onKeyDown:e=>{O.onKeyDown(e)||fm(e)&&(e.preventDefault(),_e())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),me&&he(e.clipboardData.files))},placeholder:W(n,`Nhắn cho Piagent… (@ để chọn file, folder)`,`Message Piagent… (@ for files and folders)`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:O.htmlInput}}),O.menu,(0,X.jsx)(tm,{open:E!==null,title:E?.title??``,description:E?.description??``,confirmLabel:E?.confirmLabel??``,cancelLabel:W(n,`Huỷ`,`Cancel`),onCancel:()=>D(null),onConfirm:()=>{let e=E;D(null),e&&e.run().then(T)}}),(0,X.jsx)(bf,{in:j,id:`piagent-message-options`,children:(0,X.jsxs)(Z,{sx:{mt:.65,p:.85,borderRadius:1,bgcolor:`action.hover`},children:[(0,X.jsx)(sm,{session:e,snapshot:t,connections:_,locale:n,onOpenChanges:()=>l(`source`),onConnectionsChanged:ye}),(0,X.jsx)(Q,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:.75,flexWrap:`wrap`},children:de?.status===`available`&&(0,X.jsx)(_o,{title:W(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,X.jsxs)(J,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,X.jsx)(cf,{}),disabled:!me,"aria-label":`${W(n,`Đính kèm`,`Attach`)} (${k.length}/4)`,children:[W(n,`Đính kèm`,`Attach`),(0,X.jsx)(`input`,{type:`file`,multiple:!0,hidden:!0,disabled:!me,accept:pe||void 0,onChange:e=>{he(e.target.files),e.currentTarget.value=``}})]})})})]})}),(0,X.jsxs)(Q,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`,mt:.5,gap:1},children:[(0,X.jsxs)(Q,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:1},children:[(0,X.jsx)(_o,{title:j?W(n,`Ẩn tùy chọn`,`Hide options`):W(n,`File và công cụ`,`Files and tools`),children:(0,X.jsx)(Ze,{size:`small`,"aria-label":j?W(n,`Ẩn tùy chọn`,`Hide options`):W(n,`Thêm tùy chọn`,`More options`),"aria-expanded":j,"aria-controls":`piagent-message-options`,onClick:()=>M(e=>!e),sx:{bgcolor:j?`action.selected`:`transparent`},children:(0,X.jsx)(sf,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:j?`rotate(45deg)`:`none`}})})}),(0,X.jsx)(q,{variant:`caption`,color:L||z?.tone===`error`?`error`:z?`warning.main`:`text.disabled`,noWrap:!z,sx:{display:{xs:L||z||F?`block`:`none`,sm:`block`}},children:z?.text??L??(F?W(n,`Đang đọc tài liệu…`,`Reading documents…`):r&&!r.complete?W(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?W(n,`Enter để gửi · Shift+Enter xuống dòng`,`Enter to send · Shift+Enter for a new line`):W(n,`Session hiện chỉ đọc`,`Session is currently read only`))})]}),r?.operationRef&&!r.complete&&r.abortable!==!1?(0,X.jsx)(J,{color:`error`,startIcon:(0,X.jsx)(pf,{}),onClick:()=>void s(),children:W(n,`Dừng`,`Stop`)}):(0,X.jsx)(Ze,{"aria-label":W(n,`Gửi`,`Send`),disabled:!i||h||V||!p.trim(),color:`primary`,onClick:()=>void _e(),sx:{bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,X.jsx)(df,{fontSize:`small`})})]})]})]})]})}function gb({locale:e,canCreate:t,onNew:n}){return(0,X.jsxs)(Q,{sx:{minHeight:`calc(100vh - 68px)`,alignItems:`center`,justifyContent:`center`,px:3,textAlign:`center`},spacing:1.5,children:[(0,X.jsx)(Z,{className:`brand-mark`,"aria-hidden":`true`,sx:{width:50,height:50,fontSize:25},children:`π`}),(0,X.jsx)(q,{variant:`h1`,children:W(e,`Bắt đầu với Piagent`,`Start with Piagent`)}),(0,X.jsx)(q,{color:`text.secondary`,sx:{maxWidth:520},children:W(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,X.jsx)(J,{disabled:!t,variant:`contained`,startIcon:(0,X.jsx)(sf,{}),onClick:n,children:W(e,`Cuộc trò chuyện mới`,`New chat`)})]})}function _b({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,setFast:p,rename:m,pin:h,archive:g,unarchive:_,fork:v}){let{locale:y,colorMode:b,setLocale:x,setColorMode:S}=ze(),C=ch(),w=yh(),[E,D]=(0,Y.useState)(!1),[O,k]=(0,Y.useState)(`sessions`),A=tf(T().breakpoints.up(`lg`)),[j,M]=(0,Y.useState)(null),[N,P]=(0,Y.useState)(``),[F,I]=(0,Y.useState)(),[L,R]=(0,Y.useState)(!1),[z,B]=(0,Y.useState)(!1),[V,ee]=(0,Y.useState)(`chat`),[ne,re]=(0,Y.useState)(!1),[ie,ae]=(0,Y.useState)(`general`),[oe,se]=(0,Y.useState)(!1),[le,ue]=(0,Y.useState)(`task`),de=!A,[fe,pe]=(0,Y.useState)(()=>{try{let e=window.localStorage.getItem(pb);if(e)return e===`open`}catch{}return window.innerWidth>=1200}),[me,he]=(0,Y.useState)(!1),ge=()=>de?he(e=>!e):pe(e=>{try{window.localStorage.setItem(pb,e?`closed`:`open`)}catch{}return!e}),H=(0,Y.useRef)(!1);H.current=oe&&le===`activity`;let[_e,ve]=(0,Y.useState)(),ye=(0,Y.useRef)(null),[be,xe]=(0,Y.useState)(`idle`),Se=(0,Y.useRef)(null),Ce=(0,Y.useRef)(null);Ce.current??=new $y;let[we,U]=(0,Y.useState)(!1),[Te,Ee]=(0,Y.useState)(null),[Oe,ke]=(0,Y.useState)(null),[Ae,je]=(0,Y.useState)(``),[Me,Ne]=(0,Y.useState)(!1),[Pe,Fe]=(0,Y.useState)(null),[Ie,Le]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{V===`chat`&&F||(window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0)},[V,F]);let Re=(0,Y.useMemo)(()=>(e?.sessions??[]).filter(e=>e.archived===z&&`${e.title} ${e.projectLabel} ${e.preview}`.toLowerCase().includes(N.trim().toLowerCase())),[e,N,z]),Be=(0,Y.useMemo)(()=>{let e=new Map;for(let t of Re){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??``))},[Re]),Ve=e?.sessions.filter(e=>e.archived).length??0;(0,Y.useEffect)(()=>{(!F||!(e?.sessions??[]).some(e=>e.sessionRef===F))&&I((e?.sessions??[]).find(e=>!e.archived)?.sessionRef)},[F,e]);let G=(e?.sessions??[]).find(e=>e.sessionRef===F),He=G?.sessionRef,Ue=G?.state===`terminal-owned`,We=(e?.sessions??[]).some(e=>e.state===`terminal-owned`);(0,Y.useEffect)(()=>{let e=Ue?3e3:We?1e4:3e4,t=window.setInterval(()=>{document.visibilityState===`visible`&&a()},e);return()=>window.clearInterval(t)},[Ue,We,a]);let Ge=(0,Y.useRef)(He);Ge.current=He;let Ke=ye.current&&ye.current.sessionRef===He&&ye.current.snapshot===_e?_e:void 0,qe=Se.current===He?be:He?`loading`:`idle`,Je=G?r[G.sessionRef]:void 0,[Ye,Xe]=(0,Y.useState)(null),Qe=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{if(!e||Qe.current)return;Qe.current=!0;let t=pt();t&&(Xe(t),ee(`new`))},[e]);let $e=e=>{Xe(null),I(e),ee(`chat`),R(!1)},et=Rv({sessions:(0,Y.useMemo)(()=>e?.sessions??[],[e]),live:r,selectedRef:V===`chat`?He:void 0,onOpen:$e,locale:y}),tt=e=>{ae(e),re(!0)};Oy({palette:()=>D(!0),settings:()=>tt(`general`),newChat:()=>{rt&&(Ee(null),ee(`new`))}});let nt=e=>{ue(e),se(!0)},K=async()=>{let e=Ge.current;if(!e)return;ye.current?.sessionRef!==e&&(Se.current=e,xe(`loading`));let t=await Ce.current.run(()=>Ts(e),t=>{Ge.current===e&&(ye.current={sessionRef:e,snapshot:t},Se.current=e,ve(t),xe(`ready`))},()=>{Ge.current===e&&(Se.current=e,xe(ye.current?.sessionRef===e?`ready`:`error`))});return Ge.current===e?t:void 0};(0,Y.useEffect)(()=>{if(!He){Ce.current.invalidate(),ye.current=null,Se.current=null,ve(void 0),xe(`idle`);return}let e=He,t=new AbortController;return Se.current=e,ye.current?.sessionRef!==e&&(ye.current=null,ve(void 0),xe(`loading`)),Ce.current.run(()=>Ts(e,t.signal),n=>{t.signal.aborted||Ge.current!==e||(ye.current={sessionRef:e,snapshot:n},Se.current=e,ve(n),xe(`ready`))},()=>{t.signal.aborted||Ge.current!==e||(Se.current=e,xe(ye.current?.sessionRef===e?`ready`:`error`))}),()=>t.abort()},[He,G?.sessionRevision]),(0,Y.useEffect)(()=>{if(!oe||le!==`activity`||!He||!Ke||!Je?.operationRef||Je.complete)return;let e=He,t=!1,n,r=async()=>{await Ce.current.run(()=>Ts(e),n=>{t||!H.current||Ge.current!==e||(ye.current={sessionRef:e,snapshot:n},Se.current=e,ve(n),xe(`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)}},[oe,le,He,!!Ke,Je?.operationRef,Je?.complete]);let rt=n===`connected`&&t?.capabilities.sessionActions.create.status===`available`,it=async e=>{U(!0),Ee(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,fast:e.fast,message:e.message,messageRequestId:n,deferInitialMessage:r});if(t=i.sessionRef,!t)throw Error(`session-create-result-invalid`);if(qm(Pm,``),Ym(Pm,null),i.phase!==`settled`){I(t),ee(`chat`),Le({title:W(y,`Session đã được tạo`,`The session was created`),message:W(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 Ts(t),o=i.capabilities.capabilities.attachments;if(o.status!==`available`)throw Error(o.reason?.code??`session-attachment-unavailable`);let c=await _d({files:e.files,snapshot:i,messageRequestId:n,existing:[],allowed:new Set(o.mimeTypes),locale:y,stage:e=>fc(t,e)});if(c.status||c.attachments.length!==e.files.length)throw await Promise.all(c.attachments.map(async e=>{try{await vd({snapshot:i,messageRequestId:n,attachmentRef:e.attachmentRef,locale:y,stage:e=>fc(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})}I(t),ee(`chat`)}catch(n){let r=n instanceof Error?n.message:`session-create-failed`;t?(e.files.length>0&&qm(t,e.message),I(t),ee(`chat`),Le({title:W(y,`Session đã tạo nhưng file chưa được gửi`,`The session was created, but the files were not sent`),message:r})):Ee(Pf(r,y))}finally{U(!1)}},at=(e,t)=>{if(t===`pin`){h(e,!e.pinned).catch(e=>Le({title:W(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`){_(e).then(()=>B(!1)).catch(e=>Le({title:W(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}Fe(null),je(t===`rename`?e.title:t===`fork`?`${e.title} · ${W(y,`nhánh`,`fork`)}`:``),ke({kind:t,session:e})},ot=async()=>{if(!(!Oe||Me)){Ne(!0),Fe(null);try{if(Oe.kind===`rename`)await m(Oe.session,Ae.trim());else if(Oe.kind===`archive`)await g(Oe.session);else{let e=await v(Oe.session,Ae.trim()||null);e.sessionRef&&(I(e.sessionRef),ee(`chat`))}ke(null)}catch(e){Fe(bb(Oe.kind,e instanceof Error?e.message:`session-action-failed`,y))}finally{Ne(!1)}}},st=(0,X.jsx)(Nv,{locale:y,canCreate:rt,query:N,onQuery:P,groups:Be,count:Re.length,selectedRef:V===`chat`?G?.sessionRef:void 0,showArchived:z,archivedCount:Ve,settingsOpen:ne,connection:n,live:r,unseen:et.unseen,onSelect:$e,onAction:at,onNew:()=>{Ee(null),ee(`new`),R(!1)},onToggleArchived:()=>{B(e=>!e),R(!1)},updateDot:!!(w.status?.updateAvailable&&w.status.installable),onSettings:()=>{tt(w.status?.updateAvailable&&w.status.installable?`updates`:`general`),R(!1)}}),ct=V===`chat`&&G?(0,X.jsx)(uy,{session:G,snapshot:Ke,live:Je,locale:y,onOpenReview:()=>nt(`source`),onClose:()=>de?he(!1):pe(!1)}):null,lt=!!ct&&(de?me:fe)&&!oe;if(C)return(0,X.jsx)(lh,{locale:y});if(!e&&n!==`failed`)return(0,X.jsxs)(Q,{sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},spacing:2,children:[(0,X.jsx)(De,{size:24}),(0,X.jsx)(q,{children:W(y,`Đang mở Piagent…`,`Opening Piagent…`)})]});let ut=V===`new`?W(y,`Cuộc trò chuyện mới`,`New chat`):G?.title??`Piagent`,dt=Qy({locale:y,colorMode:b,canCreate:rt,hasSelection:V===`chat`&&!!G,sessions:(e?.sessions??[]).filter(e=>!e.archived),update:{available:!!(w.status?.updateAvailable&&w.status.installable&&!gh(w.status)),latest:w.status?.piagent.latest??null},actions:{newChat:()=>{Ee(null),ee(`new`)},togglePanel:ge,openChanges:()=>nt(`source`),refresh:()=>void a(),settings:tt,checkUpdates:()=>{tt(`updates`),w.check()},setColorMode:S,setLocale:x,openSession:$e}}),ft=Object.values(r).filter(e=>e&&!e.complete).length;return(0,X.jsx)(Mo,{sessionRef:V===`chat`?He:void 0,onOpen:()=>se(!1),children:(0,X.jsxs)(Z,{sx:{minHeight:`100vh`,bgcolor:`background.default`,"--piagent-status-bar":{xs:`0px`,md:`28px`}},children:[(0,X.jsx)(Nn,{position:`fixed`,color:`transparent`,elevation:0,sx:{left:{md:`${ub}px`},right:{lg:lt?`${db}px`:0,xl:oe?fb:lt?`${db}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,X.jsxs)(ti,{sx:{minHeight:`60px !important`,gap:1},children:[(0,X.jsx)(Ze,{"aria-label":W(y,`Mở điều hướng`,`Open navigation`),onClick:()=>R(!0),sx:{display:{md:`none`}},children:(0,X.jsx)(Eo,{})}),(0,X.jsxs)(Z,{sx:{flex:1,minWidth:0},children:[(0,X.jsx)(q,{component:`h1`,noWrap:!0,sx:{fontWeight:600,fontSize:`inherit`},children:ut}),V===`chat`&&G&&(0,X.jsxs)(q,{variant:`caption`,color:`text.secondary`,noWrap:!0,component:`div`,sx:{display:`flex`,alignItems:`center`,gap:.75,minWidth:0},children:[(0,X.jsx)(Z,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,flexShrink:3,minWidth:24},children:G.projectLabel}),(G.gitBranch||!!G.gitRepositories?.length)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Z,{component:`span`,"aria-hidden":!0,sx:{color:`text.disabled`},children:`·`}),(0,X.jsx)(My,{projectRef:G.projectRef,projectLabel:G.projectLabel,branch:G.gitBranch,repositories:G.gitRepositories,locale:y,maxWidth:`45%`,onSwitched:()=>void a()})]})]})]}),V===`chat`&&G&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sm,{placement:`header`,session:G,snapshot:Ke,locale:y,onOpenChanges:()=>nt(`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(G,e),onSetThinking:e=>d(G,e),onSetPermission:e=>f(G,e),onSetFast:e=>p(G,e)}),(0,X.jsx)(Z,{sx:{display:{xs:`none`,sm:`block`}},children:(0,X.jsx)(mb,{session:G,live:Je,locale:y})}),(0,X.jsx)(_o,{title:`Source Changes`,children:(0,X.jsx)(Ze,{"aria-label":W(y,`Mở Source Changes Inspector`,`Open Source Changes Inspector`),onClick:()=>nt(`source`),children:(0,X.jsx)(So,{fontSize:`small`})})}),(0,X.jsx)(_o,{title:W(y,`Khung Workspace: thay đổi, ngữ cảnh, subagent`,`Workspace panel: changes, context, subagents`),children:(0,X.jsx)(Ze,{"aria-label":W(y,`Khung Workspace`,`Workspace panel`),"aria-pressed":lt,onClick:()=>ge(),color:lt?`primary`:`default`,children:(0,X.jsx)(ff,{fontSize:`small`,sx:{transform:`scaleX(-1)`}})})})]}),(0,X.jsx)(_o,{title:W(y,`Làm mới`,`Refresh`),children:(0,X.jsx)(Ze,{"aria-label":W(y,`Làm mới`,`Refresh`),onClick:()=>void a(),children:(0,X.jsx)(uf,{fontSize:`small`})})})]})}),(0,X.jsxs)(Z,{component:`nav`,sx:{width:{md:ub}},children:[(0,X.jsx)(Cr,{variant:`temporary`,open:L,onClose:()=>R(!1),sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:ub}},children:st}),(0,X.jsxs)(Cr,{variant:`permanent`,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:ub,borderRight:1,borderColor:`divider`,height:`calc(100% - var(--piagent-status-bar, 0px))`}},children:[A&&G&&V===`chat`&&(0,X.jsx)(ef,{value:O,onChange:k}),!A||O===`sessions`||!G||V!==`chat`?st:(0,X.jsx)(Z,{ref:M,sx:{overflow:`auto`,flex:1}})]})]}),(0,X.jsx)(Z,{component:`main`,sx:{ml:{md:`${ub}px`},mr:{lg:lt?`${db}px`:0,xl:oe?fb:lt?`${db}px`:0},pt:`60px`,transition:`margin-right .2s ease`},children:V===`new`?(0,X.jsx)(eh,{active:!0,defaultProjectRef:Ye??G?.projectRef,busy:we,error:Te,onCancel:()=>ee(`chat`),onCreate:e=>it(e)}):G?(0,X.jsx)(of,{sessionRef:G.sessionRef,navigationHost:j,sidebarMode:O,onSection:k,children:(0,X.jsx)(hb,{session:G,snapshot:Ke,locale:y,live:r[G.sessionRef],commandActions:{setModel:e=>u(G,e),setThinking:e=>d(G,e),setFast:e=>p(G,e),setPermission:e=>f(G,e),rename:e=>m(G,e),fork:()=>v(G,null),pin:e=>h(G,e),archive:()=>g(G),newChat:()=>{Ee(null),ee(`new`)},openChanges:()=>nt(`source`),openSettings:()=>tt(`general`)},canSend:n===`connected`&&G.composerAvailable&&t?.capabilities.sessionActions.send.status===`available`&&(!Je||Je.complete)&&![`required`,`restarting`,`failed`].includes(String(r[G.sessionRef]?.runtimeRecovery)),canRestart:n===`connected`&&t?.capabilities.sessionActions.release.status===`available`&&t?.capabilities.sessionActions.acquire.status===`available`,send:(e,t)=>s(G,e,t),abort:()=>c(G).catch(e=>Le({title:W(y,`Chưa dừng được lượt này`,`This turn could not be stopped`),message:e instanceof Error&&e.message===`operation-unavailable`?W(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(G),onInspector:nt},G.sessionRef)},G.sessionRef):(0,X.jsx)(gb,{locale:y,canCreate:rt,onNew:()=>ee(`new`)})}),ct&&lt&&!de&&(0,X.jsx)(Z,{component:`aside`,sx:{display:{xs:`none`,lg:`block`},position:`fixed`,top:0,right:0,bottom:`var(--piagent-status-bar, 0px)`,width:db,borderLeft:1,borderColor:`divider`,zIndex:e=>e.zIndex.appBar-1},children:ct}),ct&&(0,X.jsx)(Cr,{anchor:`right`,variant:`temporary`,open:me&&!oe&&de,onClose:()=>he(!1),sx:{display:{xs:`block`,lg:`none`},"& .MuiDrawer-paper":{width:`min(${db}px, 88vw)`}},children:ct}),(0,X.jsx)(Lh,{open:oe,active:le,snapshot:Ke,state:qe,sessionRef:He,terminalActivities:G?i[G.sessionRef]:void 0,liveActivities:Je&&!Je.complete?Je.activities:void 0,onClose:()=>se(!1),onActive:ue,refresh:K,findings:G?.managedReview?.findings,onSendComments:G&&G.composerAvailable?e=>{Zm(G.sessionRef,e),se(!1)}:void 0}),(0,X.jsx)(Nh,{locale:y,onDetails:()=>tt(`updates`)}),et.view,(0,X.jsx)(Iy,{locale:y,connection:n,running:ft,session:V===`chat`?G:void 0,onBranchSwitched:()=>void a(),onUpdates:()=>tt(`updates`),onPalette:()=>D(!0)}),(0,X.jsx)(ky,{open:E,onClose:()=>D(!1),commands:dt,locale:y}),(0,X.jsx)(ce,{open:ne,onClose:()=>re(!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,X.jsx)(Zy,{section:ie,onSection:ae,onBack:()=>re(!1),session:G,snapshot:Ke,capabilities:t,connection:n,onSetModel:G?e=>u(G,e):void 0,onSetThinking:G?e=>d(G,e):void 0,onSetPermission:G?e=>f(G,e):void 0,onRuntimeChanged:async()=>{await a(),await K()}})}),(0,X.jsx)(ce,{open:!!Oe,onClose:()=>!Me&&ke(null),fullWidth:!0,maxWidth:`xs`,children:(0,X.jsxs)(Q,{spacing:2,sx:{p:3},children:[(0,X.jsx)(q,{variant:`h2`,children:Oe?.kind===`rename`?W(y,`Đổi tên cuộc trò chuyện`,`Rename chat`):Oe?.kind===`fork`?W(y,`Tạo nhánh cuộc trò chuyện`,`Fork chat`):W(y,`Lưu trữ cuộc trò chuyện`,`Archive chat`)}),Oe?.kind===`archive`?(0,X.jsx)(q,{color:`text.secondary`,children:W(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,X.jsx)(te,{autoFocus:!0,label:W(y,`Tên`,`Title`),value:Ae,onChange:e=>je(e.target.value),slotProps:{htmlInput:{maxLength:500}}}),Pe&&(0,X.jsx)(q,{color:`error`,children:Pe}),(0,X.jsxs)(Q,{direction:`row`,spacing:1,sx:{justifyContent:`flex-end`},children:[(0,X.jsx)(J,{disabled:Me,onClick:()=>ke(null),children:W(y,`Hủy`,`Cancel`)}),(0,X.jsx)(J,{variant:`contained`,disabled:Me||Oe?.kind!==`archive`&&!Ae.trim(),onClick:()=>void ot(),children:W(y,`Xác nhận`,`Confirm`)})]})]})}),(0,X.jsx)(ce,{open:!!Ie,onClose:()=>Le(null),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-session-notice-title`,children:(0,X.jsxs)(Q,{spacing:2,sx:{p:3},children:[(0,X.jsx)(q,{id:`piagent-session-notice-title`,variant:`h2`,children:Ie?.title}),(0,X.jsx)(q,{color:`text.secondary`,children:Ie?.message}),(0,X.jsx)(Q,{direction:`row`,sx:{justifyContent:`flex-end`},children:(0,X.jsx)(J,{variant:`contained`,onClick:()=>Le(null),children:W(y,`Đóng`,`Close`)})})]})})]})})}var vb={"session-revision-stale":[`Cuộc trò chuyện vừa thay đổi trong lúc gửi. Bấm Xác nhận lần nữa.`,`The chat changed while this was sent. Select Confirm again.`],"session-runtime-busy":[`Cuộc trò chuyện đang bận. Thử lại khi lượt này xong.`,`The chat is busy. Try again when this turn ends.`],"session-runtime-unavailable":[`Cuộc trò chuyện chưa mở được. Mở lại cuộc trò chuyện rồi thử lại.`,`The chat is not open. Open it again and retry.`],"session-unavailable":[`Không còn thấy cuộc trò chuyện này trong danh sách. Tải lại trang rồi thử lại.`,`This chat is no longer in the list. Reload the page and retry.`],"session-archived":[`Cuộc trò chuyện đã được lưu trữ. Bỏ lưu trữ trước.`,`The chat is archived. Unarchive it first.`],"session-command-expired":[`Yêu cầu chờ quá lâu nên đã hết hạn. Thử lại.`,`The request waited too long and expired. Try again.`],"gateway-command-response-timeout":[`Piagent chưa trả lời. Xem lại danh sách trước khi thử lại.`,`Piagent did not answer. Check the list before trying again.`]},yb={rename:[`Chưa đổi được tên`,`Could not rename`],fork:[`Chưa tạo được nhánh`,`Could not fork`],archive:[`Chưa lưu trữ được`,`Could not archive`]};function bb(e,t,n){let r=vb[t];return`${W(n,...yb[e])}: ${r?W(n,...r):W(n,`thử lại.`,`try again.`)} (${t})`}function xb(e){let t=e===`dark`,n=t?`#d8ff7a`:`#627400`,r=t?`#8be9c8`:`#14775f`;return v({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:2},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:p(n,.26)}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:32,borderRadius:2},outlined:{borderColor:t?`#32343c`:`#cfd4c8`}}},MuiChip:{styleOverrides:{root:{height:24,borderRadius:2,fontWeight:500}}},MuiListItemButton:{styleOverrides:{root:{minHeight:42,margin:`1px 6px`,borderRadius:2,color:t?`#a4a6ad`:`#62685c`,"&.Mui-selected":{color:t?`#f4f4ef`:`#1c2018`,backgroundColor:p(n,t?.11:.1),boxShadow:`inset 2px 0 ${n}`},"&.Mui-selected:hover":{backgroundColor:p(n,.15)}}}},MuiTab:{styleOverrides:{root:{minHeight:48,paddingInline:18,textTransform:`none`,fontWeight:500}}},MuiTooltip:{defaultProps:{arrow:!0}}}})}function Sb(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 Cb=250,wb=4e3,Tb=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/;function Eb(e){return Math.min(Cb*2**Math.min(Math.max(0,e),16),wb)}function Db(e){return e instanceof cs?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 Ob(e,...t){for(let e of t)if(typeof e==`string`&&Tb.test(e))return e;return e}function kb(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`||!Tb.test(n.eventCursor))throw Error(`invalid-inspection-snapshot-cursor`);return e}function Ab(e=0){return{state:`cancelled`,readSequence:e}}async function jb(e){let t=0;for(;!e.stopped();){let n=await e.read();if(e.stopped())return Ab(n.readSequence);if(n.state!==`retryable-error`)return n;await e.wait(Eb(t)),t=Math.min(t+1,16)}return Ab()}function Mb(){let[e,t]=(0,Y.useState)(),[n,r]=(0,Y.useState)(`connecting`),[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(()=>Promise.resolve(Ab())),s=(0,Y.useRef)(()=>void 0),c=(0,Y.useCallback)(async()=>{let e=await o.current();if(e.state===`committed`)return s.current(e.value),e.value},[]);return(0,Y.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 eb({read:async()=>{let t=m;return{snapshot:kb(await us(e.signal)),eventGenerationAtStart:t}},commit:({snapshot:e,eventGenerationAtStart:n})=>{C||S||(_=!0,v=!0,m===n&&(h=Ob(null,e.revision.eventCursor)),t(e),y&&r(`connected`))},classify:Db});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(Eb(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=Ob(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(Eb(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 jb({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=Eb(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 yt()}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(Ab()))}},[]),{snapshot:e,connection:n,events:i,refreshSnapshot:c}}var Nb=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Pb=e=>typeof e==`string`&&/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(e),Fb=(e,t)=>Object.keys(e).length===t.length&&Object.keys(e).every(e=>t.includes(e));function Ib(e){if(!Nb(e)||e.schemaVersion!==1||e.version!==`piagent-terminal-v1`||!Nb(e.identity)||!Fb(e.identity,[`gatewayInstanceRef`,`runtimeInstanceRef`,`sessionRef`])||![`gatewayInstanceRef`,`runtimeInstanceRef`,`sessionRef`].every(t=>Pb(e.identity[t])))return!1;let t=[`schemaVersion`,`version`,`messageType`,`identity`];return e.messageType===`state`?Fb(e,[...t,`revisions`,`available`,`reasonCode`,`terminals`])&&Nb(e.revisions)&&Fb(e.revisions,[`terminalRevision`])&&typeof e.revisions.terminalRevision==`string`&&typeof e.available==`boolean`&&(e.reasonCode===null||typeof e.reasonCode==`string`)&&Array.isArray(e.terminals)&&e.terminals.length<=4&&e.terminals.every(e=>Nb(e)&&Fb(e,[`terminalRef`,`number`,`state`,`cols`,`rows`,`sequence`,`exitCode`])&&Pb(e.terminalRef)&&Number.isSafeInteger(e.number)&&e.number>0&&[`running`,`exited`].includes(e.state)&&Number.isSafeInteger(e.sequence)&&e.sequence>=0&&Number.isInteger(e.cols)&&e.cols>=2&&e.cols<=500&&Number.isInteger(e.rows)&&e.rows>=1&&e.rows<=200&&(e.exitCode===null||Number.isInteger(e.exitCode))):!Pb(e.terminalRef)||!Number.isSafeInteger(e.sequence)||e.sequence<0?!1:e.messageType===`output`?Fb(e,[...t,`terminalRef`,`sequence`,`data`,`replay`,`reset`,`complete`,`truncated`])&&typeof e.data==`string`&&e.data.length<=8192&&[`replay`,`reset`,`complete`,`truncated`].every(t=>typeof e[t]==`boolean`):e.messageType===`exit`&&Fb(e,[...t,`terminalRef`,`sequence`,`exitCode`,`signal`])&&(e.exitCode===null||Number.isInteger(e.exitCode))&&(e.signal===null||Number.isInteger(e.signal))}var Lb=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Rb=e=>typeof e==`string`&&/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/.test(e);function zb(e){return Ib(e)}var Bb=new class{#e=null;#t=!1;#n=new Map;#r=new Set;#i=new Set;#a;constructor(e=ht){this.#a=e}get ready(){return this.#t}#o(e){this.#t=e;for(let t of this.#i)t(e)}attach(e){this.#s(),this.#e=e,e.addEventListener(`message`,t=>{if(e!==this.#e)return;let n;try{n=JSON.parse(String(t.data))}catch{return}if(Lb(n)){if(n.messageType===`hello`&&n.version===`piagent-gateway-protocol-v1`){this.#o(!0);return}if(n.messageType===`response`&&n.version===`piagent-gateway-protocol-v1`){let e=this.#n.get(n.requestId);if(!e)return;this.#n.delete(n.requestId),clearTimeout(e.timer),n.method===e.method?n.ok===!0?e.resolve(n.result):e.reject(Error(String(n.error?.code??`terminal-request-failed`))):e.reject(Error(`terminal-response-invalid`));return}if(zb(n))for(let e of this.#r)e(n)}}),e.addEventListener(`close`,()=>{e===this.#e&&this.#s()})}#s(){this.#e=null,this.#o(!1);for(let e of this.#n.values())clearTimeout(e.timer),e.reject(Error(`terminal-connection-lost`));this.#n.clear()}subscribe(e){return this.#r.add(e),()=>{this.#r.delete(e)}}connection(e){return this.#i.add(e),()=>{this.#i.delete(e)}}#c(e,t){let n=this.#e,r=this.#a();if(!this.#t||!n||n.readyState!==1||!r)return Promise.reject(Error(`terminal-not-connected`));if(this.#n.size>=64)return Promise.reject(Error(`terminal-request-capacity`));let i=`terminal_${crypto.randomUUID().replaceAll(`-`,``)}`;return new Promise((a,o)=>{let s=setTimeout(()=>{this.#n.delete(i),o(Error(`terminal-response-timeout`))},15e3);this.#n.set(i,{method:e,resolve:a,reject:o,timer:s});try{n.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`request`,requestId:i,method:e,params:{...t,csrfToken:r}}))}catch{clearTimeout(s),this.#n.delete(i),o(Error(`terminal-send-failed`))}})}async state(e){let t=await this.#c(`terminals.state`,{sessionRef:e});if(!zb(t)||t.messageType!==`state`||t.identity.sessionRef!==e)throw Error(`terminal-state-invalid`);return t}async execute(e){let t=await this.#c(`terminals.command`,{command:e});if(!Lb(t)||t.schemaVersion!==1||t.version!==e.version||t.messageType!==`receipt`||t.commandId!==e.commandId||t.idempotencyKey!==e.idempotencyKey||t.actionDigest!==e.actionDigest||t.action!==e.action||!Lb(t.identity)||!Object.entries(e.identity).every(([e,n])=>t.identity[e]===n)||!Lb(t.observedRevisions)||typeof t.observedRevisions.terminalRevision!=`string`||![`settled`,`rejected`,`uncertain`].includes(t.phase)||typeof t.deduplicated!=`boolean`||!(t.terminalRef===null||Rb(t.terminalRef))||t.reasonCode!==null&&typeof t.reasonCode!=`string`)throw Error(`terminal-receipt-invalid`);return t}};function Vb(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 Hb=class extends Error{effectMayHaveOccurred;constructor(e,t){super(e),this.name=`GatewayCommandTransportError`,this.effectMayHaveOccurred=t}};async function Ub(e,t,n=4){for(let r=1;;r+=1)try{return await e(t)}catch(e){if(r>=n||!(e instanceof Hb)||e.message!==`gateway-command-response-timeout`)throw e}}function Wb(e,t){return e instanceof Hb?e.effectMayHaveOccurred:t}function Gb(e,t,n=null,r=null){return!e||e.serial<=t||e.operationRef===n||r&&e.messageRequestId&&e.messageRequestId!==r?null:e}function Kb(e,t,n=null){return e&&e.operationRef!==t&&!(n&&e.messageRequestId&&e.messageRequestId!==n)?{operationRef:e.operationRef,complete:!1}:null}function qb(e,t){return t?`observed`:e?.phase===`settled`||e?.phase===`accepted`?`confirmed`:e?.phase===`rejected`?`rejected`:`unconfirmed`}function Jb(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 Yb(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=ug(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 Xb(e,t={}){let n=()=>{let t=Gb(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??fs,o=t.readTranscript??Es,s=[Jb(async t=>{let n=await a(t);return Kb(n?.state===`ready`?n.operations.find(t=>t.sessionRef===e.sessionRef):void 0,e.priorOperationRef,e.messageRequestId)},i),Jb(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:ad(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&&ed(t.content.text,e.message)&&Date.parse(t.recordedAt)>=i);return a?{operationRef:a.agentOperationId,complete:ad(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 Zb(){let[e,t]=(0,Y.useState)(),[n,r]=(0,Y.useState)(),[i,a]=(0,Y.useState)(`connecting`),[o,s]=(0,Y.useState)({}),[c,l]=(0,Y.useState)({}),u=(0,Y.useRef)(void 0),d=(0,Y.useRef)(null),f=(0,Y.useRef)(null),p=(0,Y.useRef)({});p.current=o;let m=(0,Y.useRef)(0),h=(0,Y.useRef)(new Map),g=(0,Y.useRef)(null),_=(0,Y.useRef)(!0),v=(0,Y.useRef)(0),y=(0,Y.useRef)(0),b=(0,Y.useRef)(new Map),x=(0,Y.useCallback)(sb,[]),S=(0,Y.useCallback)(async(e={})=>{let n=++v.current;try{let[r,i]=await Promise.all([ds(),fs().catch(()=>void 0)]),o=Qh(i,r.gatewayInstanceRef),c=!1;if(n>=y.current){y.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($h(h,m)),!h&&i&&o!==null)f.current=o,x(r.gatewayInstanceRef,o),s(e=>fg(e,i)),l(sg(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(tb)}catch{}f.current=ob(e,r.gatewayInstanceRef)}}}return e.requireLiveState&&!c?void 0:u.current??r}catch{a(`reconnecting`);return}},[x]),C=(0,Y.useCallback)(e=>{let t=d.current;if(!t||t.readyState!==WebSocket.OPEN)return Promise.reject(new Hb(`gateway-not-connected`,!1));let n=cb(`request`);return new Promise((r,i)=>{let a=window.setTimeout(()=>{b.current.delete(n)&&i(new Hb(`gateway-command-response-timeout`,!0))},nb);b.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),b.current.delete(n),i(new Hb(e instanceof Error?e.message:`gateway-request-failed`,!1))}})},[]),w=(0,Y.useCallback)((e,t,n,r,i,a)=>Xb({sessionRef:e,message:t,requestedAt:n,afterSerial:r,priorOperationRef:i,messageRequestId:a,readLocalObservation:()=>h.current.get(e)}),[]),T=(0,Y.useCallback)(async e=>{let t=u.current,n=e.message.trim(),r=e.messageRequestId??cb(`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 Ub(C,{schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:cb(`command`),idempotencyKey:cb(`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.fast?{fast:!0}:{},...e.deferInitialMessage?{deferInitialMessage:!0}:{}}})},a=await i(t);if(lb(a)){let e=await S();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 S(),a},[S,C]),E=(0,Y.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??cb(`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]:lg(t[e.sessionRef],{message:i,attachments:n?.attachments??[],messageRequestId:a,submittedAt:f})}));let g=()=>s(t=>{let n=t[e.sessionRef],r=dg(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=>Yb(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:cb(`command`),idempotencyKey:cb(`idempotency`),action:`session.send`,requestedAt:s.toISOString(),expiresAt:new Date(s.getTime()+rb).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 C(s);if(lb(c)){let e=await S();e?.catalogRevision&&(s=t(e),c=await C(s))}if(qb(c,null)===`confirmed`)return _({operationRef:c.operationRef,complete:!1},`admitted`),S(),{state:`confirmed`,receipt:c};let u=await w(e.sessionRef,i,v,l,d,a),f=qb(c,u);if(f===`observed`&&u)return _(u,`admitted`),S(),{state:`observed`,receipt:c};if(f===`unconfirmed`)return _({operationRef:null,complete:!0},`unconfirmed`),S(),{state:`unconfirmed`,receipt:c};throw g(),new ab(c.error?.code??c.resultCode)}catch(t){if(t instanceof ab)throw t;if(Wb(t,y)){let t=await w(e.sessionRef,i,v,l,d,a);return qb(null,t)===`observed`&&t?(_(t,`admitted`),S(),{state:`observed`,receipt:null}):(_({operationRef:null,complete:!0},`unconfirmed`),S(),{state:`unconfirmed`,receipt:null})}throw g(),t}},[w,S,C]),D=(0,Y.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 C({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:cb(`command`),idempotencyKey:cb(`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(lb(a)){let[t,r]=await Promise.all([S(),fs().catch(()=>void 0)]);if(!t||!_g(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 S(),a},[o,S,C]),O=(0,Y.useCallback)(async e=>{let t=async t=>{let n=await S(),r=n?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n?.catalogRevision||!r)throw Error(`session-unavailable`);let i=new Date,a=await C({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:cb(`command`),idempotencyKey:cb(`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 S())?.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 S(),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}},[S,C]),k=(0,Y.useCallback)(async(e,t,n)=>{let r=r=>{let i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date;return C({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:cb(`command`),idempotencyKey:cb(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n})},i=await r(u.current);for(let e=0;[`session.set-permission`,`session.set-fast`].includes(t)&&lb(i)&&e<2;e++)i=await r(await S());if(i.phase!==`settled`)throw Error(i.error?.code??i.resultCode);return await S(),i},[S,C]),A=(0,Y.useCallback)((e,t)=>k(e,`session.set-model`,{modelRef:t}),[k]),j=(0,Y.useCallback)((e,t)=>k(e,`session.set-thinking`,{thinkingLevel:t}),[k]),M=(0,Y.useCallback)((e,t)=>k(e,`session.set-permission`,{permissionMode:t}),[k]),N=(0,Y.useCallback)((e,t)=>k(e,`session.set-fast`,{fast:t}),[k]),P=(0,Y.useCallback)(async(e,t,n)=>{let r=r=>{let i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date;return C({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:cb(`command`),idempotencyKey:cb(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n})},i=await r(u.current);for(let e=0;t===`session.rename`&&lb(i)&&e<2;e++)i=await r(await S());if(i.phase!==`settled`)throw Error(i.error?.code??i.resultCode);return await S(),i},[S,C]),F=(0,Y.useCallback)((e,t)=>P(e,`session.rename`,{title:t}),[P]),I=(0,Y.useCallback)((e,t)=>P(e,`session.pin`,{pinned:t}),[P]),L=(0,Y.useCallback)(e=>P(e,`session.archive`,{}),[P]),R=(0,Y.useCallback)(e=>P(e,`session.unarchive`,{}),[P]),z=(0,Y.useCallback)((e,t)=>P(e,`session.fork`,{entryRef:null,title:t}),[P]);return(0,Y.useEffect)(()=>{let e=!1,t,n=0,i=!1,o=Vb(()=>S()),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=cb(`client`);return window.localStorage.setItem(`piagent-gateway-client-ref`,t),t}catch{return cb(`client`)}})(),v=()=>{if(e||_t())return;a(n===0?`connecting`:`reconnecting`);let o=window.location.protocol===`https:`?`wss:`:`ws:`,S=new WebSocket(`${o}//${window.location.host}/api/v1/gateway`,`piagent.gateway.v1`);d.current=S,Bb.attach(S);let C=window.setTimeout(()=>S.close(1008,`hello-timeout`),5e3);S.addEventListener(`open`,()=>S.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}))),S.addEventListener(`message`,e=>{let t;try{t=JSON.parse(String(e.data))}catch{S.close(1007,`invalid-json`);return}if(!t||typeof t!=`object`){S.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,S.close(ib,`gateway-epoch-changed`);return}g.current=e,n=0,r(o.capabilities),a(`connected`);return}if(o.messageType===`response`){let e=b.current.get(String(o.requestId));if(!e)return;b.current.delete(String(o.requestId)),window.clearTimeout(e.timeout),o.ok===!0&&o.result?e.resolve(o.result):e.reject(new Hb(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,S.close(ib,`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,S.close(ib,`gateway-event-sequence-gap`);return}if(f.current=y,g.current&&x(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]:{...cg(t,{operationRef:u.operationRef,settlement:u.settlement,reasonCode:u.reasonCode}),messageRequestId:p??t.messageRequestId,lastEventAt:d}}});let e=ag({operationRef:u.operationRef,settlement:u.settlement,reasonCode:u.reasonCode,settledAt:o.generatedAt,sequence:y});e&&l(t=>({...t,[u.sessionRef]:og(t[u.sessionRef]??[],[e])}))}[`catalog.changed`,`session.changed`,`runtime.changed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&c(),[`session.changed`,`tool.completed`,`operation.settled`].includes(String(o.kind))&&typeof u?.sessionRef==`string`&&window.dispatchEvent(new CustomEvent(`piagent-workspace-changed`,{detail:{sessionRef:u.sessionRef}}))}}),S.addEventListener(`close`,()=>{window.clearTimeout(C);for(let e of b.current.values())window.clearTimeout(e.timeout),e.reject(new Hb(`gateway-connection-lost`,!0));if(b.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)))}}),S.addEventListener(`error`,()=>{})},y=async()=>{if(e||_t())return;let r=await S({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 yt();if(!e){if(t===`failed`){a(`failed`);return}await y()}})();let C=()=>{!e&&document.visibilityState===`visible`&&S()};return document.addEventListener(`visibilitychange`,C),()=>{e=!0,t&&window.clearTimeout(t),o.stop();for(let e of b.current.values())window.clearTimeout(e.timeout),e.reject(new Hb(`gateway-client-unmounted`,!0));b.current.clear(),d.current?.close(1e3,`client-unmount`),document.removeEventListener(`visibilitychange`,C)}},[x,S]),{catalog:e,capabilities:n,connection:i,live:o,terminalActivities:c,refresh:S,create:T,send:E,abort:D,restart:O,setModel:A,setThinking:j,setPermission:M,setFast:N,rename:F,pin:I,archive:L,unarchive:R,fork:z}}var Qb=document.getElementById(`root`);if(!Qb)throw Error(`Piagent WebUI root is missing`);var $b=document.querySelector(`meta[name="csp-nonce"]`)?.content,ex=o({key:`piagent-mui`,nonce:$b&&!$b.startsWith(`__PIAGENT_`)?$b:void 0,prepend:!0});function tx(){let e=Mb();return(0,X.jsx)($d,{...e})}function nx(){let e=Zb();return(0,X.jsx)(vh,{children:(0,X.jsx)(_b,{...e})})}function rx(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function ix(){let[e,t]=(0,Y.useState)(()=>rx(`piagent-webui-locale`,[`vi`,`en`],Sb(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,Y.useState)(()=>rx(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)),i=(0,Y.useMemo)(()=>xb(n),[n]);(0,Y.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,Y.useMemo)(()=>({locale:e,colorMode:n,setLocale:t,setColorMode:r}),[n,e]),o=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,X.jsx)(Ve,{value:a,children:(0,X.jsxs)(On,{theme:i,children:[(0,X.jsx)(hn,{}),o===`gateway`?(0,X.jsx)(nx,{}):(0,X.jsx)(tx,{})]})})}(0,vo.createRoot)(Qb).render((0,X.jsx)(Y.StrictMode,{children:(0,X.jsx)(s,{value:ex,children:(0,X.jsx)(ix,{})})}));export{or as C,Dr as S,ss as _,Dl as a,Ao as b,tl as c,pl as d,dl as f,uc as g,Ms as h,yu as i,ol as l,Hc as m,Zm as n,wl as o,ul as p,Np as r,yl as s,Bb as t,ll as u,Bo as v,Z as w,Q as x,Po as y};