@piagent/platform 1.6.0 → 1.6.1

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 (213) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +17 -14
  3. package/README.vi.md +26 -1
  4. package/benchmarks/production-v1/spend-control.v1.json +27 -3
  5. package/benchmarks/production-v1/suite.json +5 -1
  6. package/catalog/capabilities.json +16 -16
  7. package/docs/authority-manifest.md +1 -1
  8. package/docs/auto-delegation-policy.md +38 -73
  9. package/docs/command-reference-vietnamese.md +23 -31
  10. package/docs/context-engine.md +5 -3
  11. package/docs/context-window-policy.md +37 -1
  12. package/docs/distribution-standard.md +7 -7
  13. package/docs/en/architecture.md +26 -13
  14. package/docs/languages.json +4 -4
  15. package/docs/operator-manual-vietnamese.md +21 -41
  16. package/docs/publishing-for-teams.md +5 -0
  17. package/docs/quality-benchmark.md +179 -23
  18. package/docs/release-install-policy.md +6 -6
  19. package/docs/runtime-harness-standard.md +3 -3
  20. package/docs/security-threat-model.md +1 -1
  21. package/docs/subagent-orchestration-capabilities.md +19 -51
  22. package/docs/subagents-and-multiagent.md +21 -47
  23. package/docs/task-implementation-contract.md +3 -3
  24. package/docs/task-lifecycle-vietnamese.md +1 -1
  25. package/docs/team-onboarding.md +2 -2
  26. package/docs/vi/architecture.md +26 -13
  27. package/docs-site/architecture.html +1 -1
  28. package/docs-site/benchmark.html +89 -95
  29. package/docs-site/commands.html +1 -1
  30. package/docs-site/content/benchmark.html +88 -94
  31. package/docs-site/content/en/benchmark.html +134 -90
  32. package/docs-site/content/en/index.html +19 -19
  33. package/docs-site/content/en/runtime.html +4 -4
  34. package/docs-site/content/en/whats-new.html +12 -1
  35. package/docs-site/content/en/workflows.html +2 -2
  36. package/docs-site/content/index.html +19 -19
  37. package/docs-site/content/runtime.html +4 -4
  38. package/docs-site/content/whats-new.html +12 -1
  39. package/docs-site/content/workflows.html +2 -2
  40. package/docs-site/context-engine.html +1 -1
  41. package/docs-site/en/architecture.html +1 -1
  42. package/docs-site/en/benchmark.html +135 -91
  43. package/docs-site/en/commands.html +1 -1
  44. package/docs-site/en/context-engine.html +1 -1
  45. package/docs-site/en/index.html +20 -20
  46. package/docs-site/en/mcp-approval.html +1 -1
  47. package/docs-site/en/mcp-auth.html +1 -1
  48. package/docs-site/en/mcp-servers.html +1 -1
  49. package/docs-site/en/mcp.html +1 -1
  50. package/docs-site/en/permissions.html +1 -1
  51. package/docs-site/en/profiles.html +1 -1
  52. package/docs-site/en/quickstart.html +1 -1
  53. package/docs-site/en/runtime.html +5 -5
  54. package/docs-site/en/scope.html +1 -1
  55. package/docs-site/en/security.html +1 -1
  56. package/docs-site/en/team.html +1 -1
  57. package/docs-site/en/whats-new.html +13 -2
  58. package/docs-site/en/workflows.html +3 -3
  59. package/docs-site/index.html +20 -20
  60. package/docs-site/mcp-approval.html +1 -1
  61. package/docs-site/mcp-auth.html +1 -1
  62. package/docs-site/mcp-servers.html +1 -1
  63. package/docs-site/mcp.html +1 -1
  64. package/docs-site/permissions.html +1 -1
  65. package/docs-site/profiles.html +1 -1
  66. package/docs-site/quickstart.html +1 -1
  67. package/docs-site/runtime.html +5 -5
  68. package/docs-site/scope.html +1 -1
  69. package/docs-site/security.html +1 -1
  70. package/docs-site/team.html +1 -1
  71. package/docs-site/whats-new.html +13 -2
  72. package/docs-site/workflows.html +3 -3
  73. package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
  74. package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
  75. package/evals/fixtures/codex-relative-efficiency-v1.invalid.json +4 -0
  76. package/evals/fixtures/codex-relative-efficiency-v1.valid.json +94 -0
  77. package/evals/fixtures/helper-request.invalid.json +1 -1
  78. package/evals/fixtures/helper-request.valid.json +1 -1
  79. package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +7 -0
  80. package/evals/fixtures/task-authority-snapshot.valid.json +4 -4
  81. package/evals/fs4-readiness-matrix.v1.json +2 -2
  82. package/evals/fs5-causal-arm.v1.json +2 -2
  83. package/evals/fs5-pilot-protocol.v1.json +3 -3
  84. package/evals/fs5-pilot-protocol.v2.json +8 -8
  85. package/evals/fs5-pilot-protocol.v3.json +8 -8
  86. package/evals/fs5-pilot-protocol.v4.json +6 -6
  87. package/evals/fs5-pilot-protocol.v5.json +7 -6
  88. package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
  89. package/evals/runtime-conformance-v1/README.md +43 -0
  90. package/evals/runtime-conformance-v1/evaluate-paid-canary.mjs +198 -0
  91. package/evals/runtime-conformance-v1/lane.json +57 -0
  92. package/evals/runtime-conformance-v1/paid-canary.json +31 -0
  93. package/evals/runtime-conformance-v1/runner.mjs +456 -0
  94. package/package.json +1 -1
  95. package/packages/piagent-core/README.md +13 -4
  96. package/packages/piagent-core/benchmark/benchmark-codex-relative-efficiency.js +698 -0
  97. package/packages/piagent-core/benchmark/benchmark-core.js +4 -3
  98. package/packages/piagent-core/benchmark/benchmark-forensics.js +4 -2
  99. package/packages/piagent-core/benchmark/benchmark-preflight.js +3 -1
  100. package/packages/piagent-core/benchmark/benchmark-provider-free-evidence.js +345 -0
  101. package/packages/piagent-core/benchmark/benchmark-record-validation.js +74 -5
  102. package/packages/piagent-core/benchmark/benchmark-report.js +15 -1
  103. package/packages/piagent-core/benchmark/benchmark-runtime-causal.js +244 -0
  104. package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +201 -4
  105. package/packages/piagent-core/benchmark/benchmark-suite.js +22 -1
  106. package/packages/piagent-core/benchmark/benchmark-summary-support.js +4 -0
  107. package/packages/piagent-core/benchmark/benchmark-usage.js +15 -4
  108. package/packages/piagent-core/capabilities/runtime-integrity.js +3 -0
  109. package/packages/piagent-core/extensions/acceptance-behavior-proof.js +806 -0
  110. package/packages/piagent-core/extensions/acceptance-receipt.js +89 -48
  111. package/packages/piagent-core/extensions/context-engine.js +1 -11
  112. package/packages/piagent-core/extensions/context-index-policy.js +4 -0
  113. package/packages/piagent-core/extensions/context-query-paths.js +57 -0
  114. package/packages/piagent-core/extensions/criterion-context-pack.js +16 -3
  115. package/packages/piagent-core/extensions/criterion-graph.js +4 -1
  116. package/packages/piagent-core/extensions/fallback-base-policy.ts +101 -0
  117. package/packages/piagent-core/extensions/guard-types.ts +4 -0
  118. package/packages/piagent-core/extensions/piagent-guard.ts +194 -226
  119. package/packages/piagent-core/extensions/task-lifecycle.js +32 -0
  120. package/packages/piagent-core/extensions/task-state.js +69 -8
  121. package/packages/piagent-core/extensions/verification-intelligence.js +49 -12
  122. package/packages/piagent-core/extensions/workspace-evidence-roots.js +52 -16
  123. package/packages/piagent-core/package.json +1 -1
  124. package/packages/piagent-core/policies/base-policy.json +42 -2
  125. package/packages/piagent-core/policy/authority-manifest.v1.json +3 -3
  126. package/packages/piagent-core/prompts/be-to-fe.md +2 -8
  127. package/packages/piagent-core/prompts/plan.md +1 -1
  128. package/packages/piagent-core/prompts/platform-improve.md +2 -6
  129. package/packages/piagent-core/prompts/review.md +2 -7
  130. package/packages/piagent-core/prompts/scout.md +1 -1
  131. package/packages/piagent-core/prompts/task.md +4 -3
  132. package/packages/piagent-core/runtime/hooks/completion-hook.ts +7 -6
  133. package/packages/piagent-core/runtime/hooks/input-hook.ts +6 -0
  134. package/packages/piagent-core/runtime/hooks/session-start-hook.ts +100 -1
  135. package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +58 -72
  136. package/packages/piagent-core/runtime/hooks/tool-result-value-helpers.ts +66 -0
  137. package/packages/piagent-core/runtime/inspection/bounded-emission-guard.ts +286 -0
  138. package/packages/piagent-core/runtime/inspection/runtime-event-store.ts +37 -7
  139. package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +27 -4
  140. package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +20 -3
  141. package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +47 -11
  142. package/packages/piagent-core/runtime/orchestration/helper-lifecycle.ts +16 -12
  143. package/packages/piagent-core/runtime/orchestration/minimal-delegation-policy.ts +71 -0
  144. package/packages/piagent-core/runtime/orchestration/owned-work-budget.ts +28 -20
  145. package/packages/piagent-core/runtime/orchestration/role-policy.ts +27 -9
  146. package/packages/piagent-core/runtime/orchestration/subagent-tool-policy.ts +329 -0
  147. package/packages/piagent-core/runtime/policy/block-remedy.ts +0 -4
  148. package/packages/piagent-core/runtime/product/efficiency-metrics.ts +3 -0
  149. package/packages/piagent-core/runtime/quality/edit-freshness-guard.ts +102 -0
  150. package/packages/piagent-core/runtime/quality/exact-output-contract.ts +20 -10
  151. package/packages/piagent-core/runtime/quality/performance-assurance.ts +3 -3
  152. package/packages/piagent-core/runtime/recovery/continuation-budget.ts +1 -1
  153. package/packages/piagent-core/runtime/recovery/handoff-projection.ts +4 -1
  154. package/packages/piagent-core/runtime/recovery/pristine-task-policy-refresh.ts +91 -0
  155. package/packages/piagent-core/runtime/recovery/recovery-policy.ts +7 -4
  156. package/packages/piagent-core/runtime/recovery/resume-state.ts +112 -14
  157. package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +7 -13
  158. package/packages/piagent-core/runtime/recovery/task-evidence-coverage-refresh.ts +217 -0
  159. package/packages/piagent-core/runtime/registration/context-commands.ts +16 -2
  160. package/packages/piagent-core/runtime/registration/knowledge-tools.ts +9 -5
  161. package/packages/piagent-core/runtime/registration/operator-request-intake.ts +49 -0
  162. package/packages/piagent-core/runtime/registration/policy-tools.ts +4 -4
  163. package/packages/piagent-core/runtime/registration/session-commands.ts +1 -1
  164. package/packages/piagent-core/runtime/registration/task-completion-tools.ts +12 -9
  165. package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +21 -12
  166. package/packages/piagent-core/runtime/registration/task-start-guidance.ts +19 -13
  167. package/packages/piagent-core/runtime/registration/task-start-manifest.ts +54 -0
  168. package/packages/piagent-core/runtime/registration/task-start-tool.ts +57 -57
  169. package/packages/piagent-core/runtime/runtime-limits.ts +16 -2
  170. package/packages/piagent-core/runtime/session/adaptive-context-analysis.ts +461 -0
  171. package/packages/piagent-core/runtime/session/adaptive-context-governor.ts +464 -0
  172. package/packages/piagent-core/runtime/session/adaptive-context-ledger.ts +265 -0
  173. package/packages/piagent-core/runtime/session/message-signals.ts +7 -3
  174. package/packages/piagent-core/runtime/session/operator-request-carry.ts +44 -0
  175. package/packages/piagent-core/runtime/session/runtime-state.ts +11 -7
  176. package/packages/piagent-core/runtime/session/source-checkout-read-grants.ts +35 -0
  177. package/packages/piagent-core/runtime/session/system-prompt.ts +76 -14
  178. package/packages/piagent-core/runtime/session/task-contract-presentation.ts +39 -0
  179. package/packages/piagent-core/runtime/tools/phase-tools.ts +8 -8
  180. package/packages/piagent-core/runtime/tools/tool-groups.ts +12 -2
  181. package/packages/piagent-core/runtime/verification/exact-verifier-reuse.ts +101 -0
  182. package/packages/piagent-core/runtime/workflows/runtime-intake-compaction.ts +164 -0
  183. package/packages/piagent-core/runtime/workflows/task-intake.ts +167 -39
  184. package/packages/piagent-core/subagents/piagent-oracle.md +5 -3
  185. package/packages/piagent-core/subagents/piagent-planner.md +6 -4
  186. package/packages/piagent-core/subagents/piagent-reviewer.md +5 -3
  187. package/packages/piagent-core/subagents/piagent-scout.md +4 -2
  188. package/packages/piagent-core/subagents/piagent-worker.md +6 -4
  189. package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-CxeZqTte.js → MarkdownMessage-B4XehTCU.js} +1 -1
  190. package/packages/piagent-webui/dist/client/assets/{index-DynIMe8I.js → index-CgOEyRPG.js} +4 -4
  191. package/packages/piagent-webui/dist/client/index.html +1 -1
  192. package/packages/piagent-webui/extension/piagent-webui.ts +3 -1
  193. package/packages/piagent-webui/extension/same-session-bridge.ts +1 -1
  194. package/packages/piagent-webui/extension/session-stream-adapter.ts +33 -10
  195. package/packages/piagent-webui/gateway/gateway-session-stream.ts +37 -21
  196. package/packages/piagent-webui/gateway/session-operation-lifecycle.ts +237 -0
  197. package/packages/piagent-webui/gateway/session-operation-retry-control.ts +38 -0
  198. package/packages/piagent-webui/gateway/session-operation-watchdog.ts +9 -2
  199. package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +8 -7
  200. package/packages/piagent-webui/ownership/session-lease-store.ts +5 -2
  201. package/packages/piagent-webui/server/core-inspection-provider.ts +2 -1
  202. package/packages/piagent-webui/server/transcript-projection.ts +91 -5
  203. package/schemas/codex-relative-efficiency-v1.schema.json +155 -0
  204. package/schemas/piagent-webui/runtime-event-v2.schema.json +15 -5
  205. package/schemas/piagent-webui/subagent-tree-v1.schema.json +11 -1
  206. package/schemas/project-profile.schema.json +1 -1
  207. package/schemas/task-contract.schema.json +15 -0
  208. package/scripts/benchmark-runner-core.mjs +14 -6
  209. package/scripts/benchmark-runner-finalization.mjs +4 -0
  210. package/scripts/configure-subagents.sh +42 -34
  211. package/scripts/helper-evaluation.mjs +1 -1
  212. package/scripts/team-doctor.sh +1 -1
  213. package/scripts/verify-local.sh +5 -0
@@ -168,9 +168,9 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
168
168
  animation: ${du} 1.4s linear infinite;
169
169
  `,mu=typeof fu==`string`?null:Tt`
170
170
  animation: ${fu} 1.4s ease-in-out infinite;
171
- `,hu=e=>{let{classes:t,variant:n,color:r,disableShrink:i}=e;return va({root:[`root`,n,`color${Y(r)}`],svg:[`svg`],track:[`track`],circle:[`circle`,i&&`circleDisableShrink`]},lu,t)},gu=J(`span`,{name:`MuiCircularProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`color${Y(n.color)}`]]}})(_s(({theme:e})=>{let t=Us(e,{animation:`none`});return{display:`inline-block`,variants:[{props:{variant:`determinate`},style:{...Ws(e,`transform`)}},{props:{variant:`indeterminate`},style:pu||{animation:`${du} 1.4s linear infinite`}},...t?[{props:{variant:`indeterminate`},style:t}]:[],...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}}))]}})),_u=J(`svg`,{name:`MuiCircularProgress`,slot:`Svg`})({display:`block`}),vu=J(`circle`,{name:`MuiCircularProgress`,slot:`Circle`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.circle,n.disableShrink&&t.circleDisableShrink]}})(_s(({theme:e})=>{let t=Us(e,{animation:`none`});return{stroke:`currentColor`,variants:[{props:{variant:`determinate`},style:{...Ws(e,`stroke-dashoffset`)}},{props:{variant:`indeterminate`},style:{strokeDasharray:`80px, 200px`,strokeDashoffset:0}},{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:mu||{animation:`${fu} 1.4s ease-in-out infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:t}]:[]]}})),yu=J(`circle`,{name:`MuiCircularProgress`,slot:`Track`})(_s(({theme:e})=>({stroke:`currentColor`,opacity:(e.vars||e).palette.action.activatedOpacity}))),bu=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiCircularProgress`}),{className:r,color:i=`primary`,disableShrink:a=!1,enableTrackSlot:o=!1,min:s,max:c,size:l=40,style:u,thickness:d=3.6,value:f=n.min??0,variant:p=`indeterminate`,...m}=n,h=s??0,g=c??100,_={...n,color:i,disableShrink:a,size:l,thickness:d,value:f,variant:p,enableTrackSlot:o},v=hu(_),y={},b={},x={};if(p===`determinate`){let e=2*Math.PI*((uu-d)/2),t=g-h;y.strokeDasharray=e.toFixed(3),y.strokeDashoffset=t>0?`${((g-f)/t*e).toFixed(3)}px`:`${e.toFixed(3)}px`,b.transform=`rotate(-90deg)`,x[`aria-valuenow`]=f,x[`aria-valuemin`]=h,x[`aria-valuemax`]=g}return(0,W.jsx)(gu,{className:G(v.root,r),style:{width:l,height:l,...b,...u},ownerState:_,ref:t,role:`progressbar`,...x,...m,children:(0,W.jsxs)(_u,{className:v.svg,ownerState:_,viewBox:`${uu/2} ${uu/2} ${uu} ${uu}`,children:[o?(0,W.jsx)(yu,{className:v.track,ownerState:_,cx:uu,cy:uu,r:(uu-d)/2,fill:`none`,strokeWidth:d,"aria-hidden":`true`}):null,(0,W.jsx)(vu,{className:v.circle,style:y,ownerState:_,cx:uu,cy:uu,r:(uu-d)/2,fill:`none`,strokeWidth:d})]})})});function xu(e){return K(`MuiDivider`,e)}var Su=Wr(`MuiDivider`,[`root`,`absolute`,`fullWidth`,`inset`,`middle`,`flexItem`,`vertical`,`withChildren`,`textAlignRight`,`textAlignLeft`,`wrapper`,`wrapperVertical`]),Cu=e=>{let{absolute:t,children:n,classes:r,flexItem:i,orientation:a,textAlign:o,variant:s}=e;return va({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`]},xu,r)},wu=J(`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]}})(_s(({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%`}}}]}))),Tu=J(`span`,{name:`MuiDivider`,slot:`Wrapper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.wrapper,n.orientation===`vertical`&&t.wrapperVertical]}})(_s(({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)`}}]}))),Eu=v.forwardRef(function(e,t){let n=Jo({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=Cu(p);return(0,W.jsx)(wu,{as:s,className:G(m.root,a),role:l,ref:t,ownerState:p,"aria-orientation":l===`separator`&&(s!==`hr`||o===`vertical`)?o:void 0,...f,children:i?(0,W.jsx)(Tu,{className:m.wrapper,ownerState:p,children:i}):null})});function Du(e=window){let t=e.document.documentElement.clientWidth;return e.innerWidth-t}function Ou(e){let t=ss(e);return e===t.body||e===t.documentElement?cs(e).innerWidth>t.documentElement.clientWidth:e.scrollHeight>e.clientHeight}function ku(e,t){t?e.setAttribute(`aria-hidden`,`true`):e.removeAttribute(`aria-hidden`)}function Au(e){return parseFloat(cs(e).getComputedStyle(e).paddingRight)||0}function ju(e){let t=[`TEMPLATE`,`SCRIPT`,`STYLE`,`LINK`,`MAP`,`META`,`NOSCRIPT`,`PICTURE`,`COL`,`COLGROUP`,`PARAM`,`SLOT`,`SOURCE`,`TRACK`].includes(e.tagName),n=e.tagName===`INPUT`&&e.getAttribute(`type`)===`hidden`;return t||n}function Mu(e,t,n,r,i){let a=[t,n,...r];[].forEach.call(e.children,e=>{let t=!a.includes(e),n=!ju(e);t&&n&&ku(e,i)})}function Nu(e,t){let n=[],r=e.container;if(!t.disableScrollLock){let e;if(r.parentNode instanceof DocumentFragment)e=ss(r).body;else{let t=r.parentElement,n=cs(r);e=t?.nodeName===`HTML`&&n.getComputedStyle(t).overflowY===`scroll`?t:r}if(Ou(e)){let t=Du(cs(e));n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${Au(e)+t}px`;let i=ss(r).querySelectorAll(`.mui-fixed`);[].forEach.call(i,e=>{n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${Au(e)+t}px`})}n.push({value:e.style.overflow,property:`overflow`,el:e},{value:e.style.overflowX,property:`overflow-x`,el:e},{value:e.style.overflowY,property:`overflow-y`,el:e}),e.style.overflow=`hidden`}return()=>{n.forEach(({value:e,el:t,property:n})=>{e?t.style.setProperty(n,e):t.style.removeProperty(n)})}}function Pu(e){let t=[];return[].forEach.call(e.children,e=>{e.getAttribute(`aria-hidden`)===`true`&&t.push(e)}),t}var Fu=class{constructor(){this.modals=[],this.containers=[]}add(e,t){let n=this.modals.indexOf(e);if(n!==-1)return n;n=this.modals.length,this.modals.push(e),e.modalRef&&ku(e.modalRef,!1);let r=Pu(t);Mu(t,e.mount,e.modalRef,r,!0);let i=this.containers.findIndex(e=>e.container===t);return i===-1?(this.containers.push({modals:[e],container:t,restore:null,hiddenSiblings:r}),n):(this.containers[i].modals.push(e),n)}mount(e,t){let n=this.containers.findIndex(t=>t.modals.includes(e)),r=this.containers[n];r.restore||=Nu(r,t)}remove(e,t=!0){let n=this.modals.indexOf(e);if(n===-1)return n;let r=this.containers.findIndex(t=>t.modals.includes(e)),i=this.containers[r];if(i.modals.splice(i.modals.indexOf(e),1),this.modals.splice(n,1),i.modals.length===0)i.restore&&i.restore(),e.modalRef&&ku(e.modalRef,t),Mu(i.container,e.mount,e.modalRef,i.hiddenSiblings,!1),this.containers.splice(r,1);else{let e=i.modals[i.modals.length-1];e.modalRef&&ku(e.modalRef,!1)}return n}isTopModal(e){return this.modals.length>0&&this.modals[this.modals.length-1]===e}};function Iu(e){return e?.props?.ref||null}function Lu(e,t){if(!e||!t)return!1;if(e.contains(t))return!0;let n=t.getRootNode?.();if(n&&n instanceof ShadowRoot){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode??n.host??null}}return!1}var Ru=Lu,zu=`data-mui-focusable`;function Bu(e){return e?e.hasAttribute(`data-mui-focusable`)?e:e.querySelector(`[${zu}]`):null}var Vu=[`input`,`select`,`textarea`,`a[href]`,`button`,`[tabindex]`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function Hu(e){let t=parseInt(e.getAttribute(`tabindex`)||``,10);return Number.isNaN(t)?e.contentEditable===`true`||(e.nodeName===`AUDIO`||e.nodeName===`VIDEO`||e.nodeName===`DETAILS`)&&e.getAttribute(`tabindex`)===null?0:e.tabIndex:t}function Uu(e){if(e.tagName!==`INPUT`||e.type!==`radio`||!e.name)return!1;let t=t=>e.ownerDocument.querySelector(`input[type="radio"]${t}`),n=t(`[name="${e.name}"]:checked`);return n||=t(`[name="${e.name}"]`),n!==e}function Wu(e){return!(e.disabled||e.tagName===`INPUT`&&e.type===`hidden`||Uu(e))}function Gu(e){let t=[],n=[];return Array.from(e.querySelectorAll(Vu)).forEach((e,r)=>{let i=Hu(e);i===-1||!Wu(e)||(i===0?t.push(e):n.push({documentOrder:r,tabIndex:i,node:e}))}),n.sort((e,t)=>e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex).map(e=>e.node).concat(t)}function Ku(){return!0}function qu(e){let{children:t,disableAutoFocus:n=!1,disableEnforceFocus:r=!1,disableRestoreFocus:i=!1,getTabbable:a=Gu,isEnabled:o=Ku,open:s}=e,c=v.useRef(!1),l=v.useRef(null),u=v.useRef(null),d=v.useRef(null),f=v.useRef(null),p=v.useRef(!1),m=v.useRef(null),h=as(Iu(t),m),g=v.useRef(null);v.useEffect(()=>{!s||!m.current||(p.current=!n)},[n,s]),v.useEffect(()=>{if(c.current=!1,!s||!m.current)return;let e=Ss(ss(m.current)),t=Bu(m.current)??m.current;return Ru(m.current,e)||(t.hasAttribute(`tabIndex`)||t.setAttribute(`tabIndex`,`-1`),p.current&&t.focus()),()=>{!i&&d.current&&(c.current=!0,d.current.focus(),d.current=null)}},[s]),v.useEffect(()=>{if(!s||!m.current)return;let e=ss(m.current),t=t=>{if(g.current=t,r||!o()||t.key!==`Tab`)return;let n=m.current,i=Ss(e);if(n===null)return;let s=Bu(n);if(i===n||i===s){let e=a(n);if(e.length===0)return;t.preventDefault(),t.shiftKey?e[e.length-1].focus():e[0].focus();return}if(Ru(n,i)){let e=a(n),r=e.indexOf(i);if(r===-1||!e.some(e=>Hu(e)>0))return;t.preventDefault();let o=0;o=t.shiftKey?r<=0?e.length-1:r-1:r===e.length-1?0:r+1,e[o].focus()}},n=()=>{let t=m.current;if(t===null)return;let n=Ss(e);if(!e.hasFocus()||!o()||c.current){c.current=!1;return}if(Ru(t,n)||r&&n!==l.current&&n!==u.current)return;if(n!==f.current)f.current=null;else if(f.current!==null)return;if(!p.current)return;let i=[];if((n===l.current||n===u.current)&&(i=a(m.current)),i.length>0){let e=!!(g.current?.shiftKey&&g.current?.key===`Tab`),t=i[0],n=i[i.length-1];typeof t!=`string`&&typeof n!=`string`&&(e?n.focus():t.focus())}else t.focus()};e.addEventListener(`focusin`,n),e.addEventListener(`keydown`,t,!0);let i=setInterval(()=>{let t=Ss(e);t&&t.tagName===`BODY`&&n()},50);return()=>{clearInterval(i),e.removeEventListener(`focusin`,n),e.removeEventListener(`keydown`,t,!0)}},[n,r,i,o,s,a]);let _=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0,f.current=e.target;let n=t.props.onFocus;n&&n(e)},y=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0};return(0,W.jsxs)(v.Fragment,{children:[(0,W.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:l,"data-testid":`sentinelStart`}),v.cloneElement(t,{ref:h,onFocus:_}),(0,W.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:u,"data-testid":`sentinelEnd`})]})}function Ju(e,t){typeof e==`function`?e(t):e&&(e.current=t)}var Yu=l(h(),1);function Xu(e){return typeof e==`function`?e():e}var Zu=v.forwardRef(function(e,t){let{children:n,container:r,disablePortal:i=!1}=e,[a,o]=v.useState(null),s=as(v.isValidElement(n)?Iu(n):null,t);if(oi(()=>{i||o(Xu(r)||document.body)},[r,i]),oi(()=>{if(a&&!i)return Ju(t,a),()=>{Ju(t,null)}},[t,a,i]),i){if(v.isValidElement(n)){let e={ref:s};return v.cloneElement(n,e)}return n}return a&&Yu.createPortal(n,a)});function Qu(e){let t=hl(()=>$u(e)).current;return t.next=e,oi(t.effect),t}function $u(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var ed=v.createContext(null);function td(e){if(e==null)return{appear:void 0,enter:void 0,exit:void 0};if(typeof e==`number`)return{appear:e,enter:e,exit:e};let t=e.enter,n=e.exit;return{appear:e.appear===void 0?t:e.appear,enter:t,exit:n}}function nd(e){if(e.autoTimeout!=null)return e.autoTimeout;let t=td(e.timeout);return e.currentStatus===`entering`?e.isAppearing?t.appear??t.enter??null:t.enter??null:t.exit??null}function rd(e){let{in:t=!1,appear:n=!1,enter:r=!0,exit:i=!0,mountOnEnter:a=!1,unmountOnExit:o=!1,timeout:s,addEndListener:c,reduceMotion:l=!1,getAutoTimeout:u,nodeRef:d,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,children:y,...b}=e,x=v.useContext(ed),S=x&&!x.isMounting?r:n,[C,w]=v.useState(()=>t?S?`exited`:`entered`:a||o?`unmounted`:`exited`),T=v.useRef(C);T.current=C,t&&C===`unmounted`&&(T.current=`exited`,w(`exited`));let E=v.useRef(t&&S),D=v.useRef(!1),O=v.useRef(null),k=v.useRef(C),A=v.useRef(!1),j=v.useRef(l),M=Qu({timeout:s,addEndListener:c,reduceMotion:l,getAutoTimeout:u,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,enter:r,exit:i,mountOnEnter:a,unmountOnExit:o,nodeRef:d,parentGroup:x}),N=v.useCallback(()=>{O.current!==null&&(O.current.cancel(),O.current=null)},[]),P=v.useCallback(e=>{let t=!0,n=()=>{t&&(t=!1,O.current=null,e())};return n.cancel=()=>{t=!1},O.current=n,n},[]),F=v.useCallback((e,t)=>{let n,r=()=>{n!==void 0&&(clearTimeout(n),n=void 0)},i=P(()=>{r(),T.current=e,w(e)}),a=i.cancel;i.cancel=()=>{r(),a()};let o=M.current.nodeRef.current,s=M.current.addEndListener,c=M.current.getAutoTimeout!==void 0,l=M.current.getAutoTimeout?.(),u=nd({currentStatus:t,isAppearing:A.current,timeout:M.current.timeout,autoTimeout:l}),d=j.current,f=u??(d&&c?0:null),p=e=>{n=setTimeout(i,e)};if(!o){p(0);return}if(s){f!=null&&p(d?0:f),s.length>=2?s(o,i):s(i);return}p(d?0:u??0)},[P,M]),I=v.useCallback(e=>{let t=M.current,n=t.parentGroup?t.parentGroup.isMounting:e;if(A.current=n,!e&&!t.enter){T.current=`entered`,w(`entered`);return}j.current=t.reduceMotion,t.onEnter?.(n),T.current=`entering`,w(`entering`)},[M]),L=v.useCallback(()=>{let e=M.current;if(!e.exit){T.current=`exited`,w(`exited`);return}j.current=e.reduceMotion,e.onExit?.(),T.current=`exiting`,w(`exiting`)},[M]),R=v.useCallback((e,t)=>{if(N(),t===`entering`){let t=M.current;if(t.mountOnEnter||t.unmountOnExit){let e=t.nodeRef.current;e&&As(e)}I(e)}else L()},[N,I,L,M]);return oi(()=>(D.current=!0,E.current&&(E.current=!1,R(!0,`entering`)),()=>{D.current=!1,N()}),[N,R]),oi(()=>{if(!D.current)return;let e=T.current;t?e!==`entering`&&e!==`entered`&&R(!1,`entering`):e===`entering`||e===`entered`?R(!1,`exiting`):e===`exited`&&o&&(T.current=`unmounted`,w(`unmounted`))},[t,C,o,R]),oi(()=>{if(C===`unmounted`||k.current===`unmounted`){k.current=C;return}let e=k.current!==C;e&&(k.current=C);let t=M.current;C===`entering`?(e&&t.onEntering?.(A.current),O.current===null&&T.current===C&&F(`entered`,`entering`)):C===`exiting`?(e&&t.onExiting?.(),O.current===null&&T.current===C&&F(`exited`,`exiting`)):C===`entered`&&e?t.onEntered?.(A.current):C===`exited`&&e&&t.onExited?.()},[M,F,C]),C===`unmounted`?null:(0,W.jsx)(ed.Provider,{value:null,children:y(C,b)})}var id={entering:{opacity:1},entered:{opacity:1},exiting:{opacity:0},exited:{opacity:0}},ad={opacity:0,visibility:`hidden`},od=v.forwardRef(function(e,t){let n=Uo(),r={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:i,appear:a=!0,children:o,disablePrefersReducedMotion:s=!1,easing:c,in:l,onEnter:u,onEntered:d,onEntering:f,onExit:p,onExited:m,onExiting:h,style:g,timeout:_=r,...y}=e,b=Il(n.motion.reducedMotion,s),x=v.useRef(null),S=vs(x,Iu(o),t),C=Bs(x,f),w=Bs(x,(e,t)=>{b.shouldReduceMotion||As(e);let r=Hs({style:g,timeout:_,easing:c},{mode:`enter`}),i=b.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`opacity`,{duration:i.duration,easing:r.easing,delay:i.delay}),u&&u(e,t)}),T=Bs(x,d),E=Bs(x,h),D=Bs(x,e=>{let t=Hs({style:g,timeout:_,easing:c},{mode:`exit`}),r=b.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`opacity`,{duration:r.duration,easing:t.easing,delay:r.delay}),p&&p(e)}),O=Bs(x,e=>{e.style.transition=``,m&&m(e)});return(0,W.jsx)(rd,{appear:a,in:l,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:i?e=>{i(x.current,e)}:void 0,reduceMotion:b.shouldReduceMotion,timeout:_,...y,children:(e,{ownerState:t,...n})=>{let r=Vs(e,l,id,ad,g,o.props.style);return v.cloneElement(o,{style:r,ref:S,...n})}})});function sd(e){return K(`MuiBackdrop`,e)}Wr(`MuiBackdrop`,[`root`,`invisible`]);var cd=e=>{let{classes:t,invisible:n}=e;return va({root:[`root`,n&&`invisible`]},sd,t)},ld=J(`div`,{name:`MuiBackdrop`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.invisible&&t.invisible]}})({position:`fixed`,display:`flex`,alignItems:`center`,justifyContent:`center`,right:0,bottom:0,top:0,left:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,WebkitTapHighlightColor:`transparent`,variants:[{props:{invisible:!0},style:{backgroundColor:`transparent`}}]}),ud=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiBackdrop`}),{children:r,className:i,component:a=`div`,invisible:o=!1,open:s,slotProps:c={},slots:l={},transitionDuration:u,...d}=n,f={...n,component:a,invisible:o},p=cd(f),m={component:a,slots:l,slotProps:c},[h,g]=Jc(`root`,{elementType:ld,externalForwardedProps:m,className:G(p.root,i),ownerState:f}),[_,v]=Jc(`transition`,{elementType:od,externalForwardedProps:m,ownerState:f});return(0,W.jsx)(_,{in:s,timeout:u,...d,...v,children:(0,W.jsx)(h,{...g,ref:t,children:r})})});function dd(...e){return e.reduce((e,t)=>t==null?e:function(...n){e.apply(this,n),t.apply(this,n)},()=>{})}function fd(e){return typeof e==`function`?e():e}function pd(e){return e?e.props.hasOwnProperty(`in`):!1}var md=()=>{},hd=new Fu;function gd(e){let{container:t,disableScrollLock:n=!1,closeAfterTransition:r=!1,onTransitionEnter:i,onTransitionExited:a,children:o,onClose:s,open:c,rootRef:l}=e,u=v.useRef({}),d=v.useRef(null),f=v.useRef(null),p=v.useRef(null),m=as(p,l),[h,g]=v.useState(!c),_=pd(o),y=!0;(e[`aria-hidden`]===`false`||e[`aria-hidden`]===!1)&&(y=!1);let b=()=>ss(d.current),x=()=>(u.current.modalRef=p.current,u.current.mount=d.current,u.current),S=()=>{hd.mount(x(),{disableScrollLock:n}),p.current&&(p.current.scrollTop=0)},C=os(()=>{let e=fd(t)||b().body;hd.add(x(),e),p.current&&S()}),w=()=>hd.isTopModal(x()),T=os(e=>{d.current=e,e&&(f.current=e,c&&w()?S():p.current&&ku(p.current,y))}),E=v.useCallback(()=>{hd.remove(x(),y)},[y]);v.useEffect(()=>()=>{E()},[E]),v.useEffect(()=>{c?C():(!_||!r)&&E()},[c,E,_,r,C]);let D=e=>t=>{e.onKeyDown?.(t),!(t.key!==`Escape`||t.which===229||!w())&&(t.stopPropagation(),s&&s(t,`escapeKeyDown`))},O=e=>t=>{e.onClick?.(t),t.target===t.currentTarget&&s&&s(t,`backdropClick`)};return{getRootProps:(t={})=>{let n=Gc(e);delete n.onTransitionEnter,delete n.onTransitionExited;let r={...n,...t};return{role:`presentation`,...r,onKeyDown:D(r),ref:m}},getBackdropProps:(e={})=>{let t=e;return{"aria-hidden":!0,...t,onClick:O(t),open:c}},getTransitionProps:()=>({onEnter:dd(()=>{g(!1),i&&i()},o?.props.onEnter??md),onExited:dd(()=>{g(!0),a&&a(),r&&E()},o?.props.onExited??md)}),rootRef:m,portalRef:T,portalContainer:!c&&_&&!h?f.current??t:t,isTopModal:w,exited:h,hasTransition:_}}function _d(e){return K(`MuiModal`,e)}Wr(`MuiModal`,[`root`,`hidden`,`backdrop`]);var vd=e=>{let{open:t,exited:n,classes:r}=e;return va({root:[`root`,!t&&n&&`hidden`],backdrop:[`backdrop`]},_d,r)},yd=J(`div`,{name:`MuiModal`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.open&&n.exited&&t.hidden]}})(_s(({theme:e})=>({position:`fixed`,zIndex:(e.vars||e).zIndex.modal,right:0,bottom:0,top:0,left:0,variants:[{props:({ownerState:e})=>!e.open&&e.exited,style:{visibility:`hidden`}}]}))),bd=J(ud,{name:`MuiModal`,slot:`Backdrop`})({zIndex:-1}),xd=v.forwardRef(function(e,t){let n=Jo({name:`MuiModal`,props:e}),{classes:r,className:i,closeAfterTransition:a=!1,children:o,container:s,component:c,disableAutoFocus:l=!1,disableEnforceFocus:u=!1,disablePortal:d=!1,disableRestoreFocus:f=!1,disableScrollLock:p=!1,hideBackdrop:m=!1,keepMounted:h=!1,onClose:g,onTransitionEnter:_,onTransitionExited:y,open:b,slotProps:x={},slots:S={},theme:C,...w}=n,T={...n,closeAfterTransition:a,disableAutoFocus:l,disableEnforceFocus:u,disablePortal:d,disableRestoreFocus:f,disableScrollLock:p,hideBackdrop:m,keepMounted:h},{getRootProps:E,getBackdropProps:D,getTransitionProps:O,portalRef:k,portalContainer:A,isTopModal:j,exited:M,hasTransition:N}=gd({...T,rootRef:t}),P={...T,exited:M},F=vd(P),I={};if(o.props.tabIndex===void 0&&(I.tabIndex=`-1`),N){let{onEnter:e,onExited:t}=O();I.onEnter=e,I.onExited=t}let L={slots:S,slotProps:x},[R,ee]=Jc(`root`,{ref:t,elementType:yd,externalForwardedProps:{...L,...w,component:c},getSlotProps:E,ownerState:P,className:G(i,F?.root,!P.open&&P.exited&&F?.hidden)}),[te,ne]=Jc(`backdrop`,{elementType:bd,externalForwardedProps:L,shouldForwardComponentProp:!0,getSlotProps:e=>D({...e,onClick:t=>{e?.onClick&&e.onClick(t)}}),className:F?.backdrop,ownerState:P});return!h&&!b&&(!N||M)?null:(0,W.jsx)(Zu,{ref:k,container:A,disablePortal:d,children:(0,W.jsxs)(R,{...ee,children:[m?null:(0,W.jsx)(te,{...ne}),(0,W.jsx)(qu,{disableEnforceFocus:u,disableAutoFocus:l,disableRestoreFocus:f,isEnabled:j,open:b,children:v.cloneElement(o,I)})]})})}),Sd=is,Cd=ya,wd=cs,Td=Wi;function Ed(e){let{controlled:t,default:n,name:r,state:i=`value`}=e,{current:a}=v.useRef(t!==void 0),[o,s]=v.useState(n);return[a?t:o,v.useCallback(e=>{a||s(e)},[])]}var Dd=Ed;function Od(e,t){if(!e)return t;function n(e,t){let n={};return Object.keys(t).forEach(r=>{Wc(r,t[r])&&typeof e[r]==`function`&&(n[r]=(...n)=>{e[r](...n),t[r](...n)})}),n}if(typeof e==`function`||typeof t==`function`)return r=>{let i=typeof t==`function`?t(r):t,a=typeof e==`function`?e({...r,...i}):e,o=G(r?.className,i?.className,a?.className),s=n(a,i);return{...i,...a,...s,...!!o&&{className:o},...i?.style&&a?.style&&{style:{...i.style,...a.style}},...i?.sx&&a?.sx&&{sx:[...Array.isArray(i.sx)?i.sx:[i.sx],...Array.isArray(a.sx)?a.sx:[a.sx]]}}};let r=t,i=n(e,r),a=G(r?.className,e?.className);return{...t,...e,...i,...!!a&&{className:a},...r?.style&&e?.style&&{style:{...r.style,...e.style}},...r?.sx&&e?.sx&&{sx:[...Array.isArray(r.sx)?r.sx:[r.sx],...Array.isArray(e.sx)?e.sx:[e.sx]]}}}var kd={visibility:`hidden`},Ad={};function jd(e){return typeof e==`string`&&/^translate\(.+,\s*.+\)$/.test(e)}function Md(e,t,n,r=Ad){let{resetInlineTransform:i=!0}=r,a=n&&n.getBoundingClientRect(),o=wd(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}=zs(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 Nd(e){return typeof e==`function`?e():e}function Pd(e,t,n,r){let i=Md(e,t,Nd(n),r);i&&(t.style.transform=i)}var Fd=v.forwardRef(function(e,t){let n=Uo(),r={enter:n.transitions.easing.easeOut,exit:n.transitions.easing.sharp},i={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:a,appear:o=!0,children:s,container:c,disablePrefersReducedMotion:l=!1,direction:u=`down`,easing:d=r,in:f,onEnter:p,onEntered:m,onEntering:h,onExit:g,onExited:_,onExiting:y,style:b,timeout:x=i,...S}=e,C=Il(n.motion.reducedMotion,l),w=v.useRef(null),T=v.useRef(!1),E=vs(Iu(s),w,t),D=Bs(w,(e,t)=>{Pd(u,e,c),C.shouldReduceMotion||As(e),p&&p(e,t)}),O=Bs(w,(e,t)=>{let r=Hs({timeout:x,style:b,easing:d},{mode:`enter`}),i=C.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`transform`,{duration:i.duration,easing:r.easing,delay:i.delay}),e.style.transform=`none`,h&&h(e,t)}),k=Bs(w,m),A=Bs(w,y),j=Bs(w,e=>{let t=Hs({timeout:x,style:b,easing:d},{mode:`exit`}),r=C.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`transform`,{duration:r.duration,easing:t.easing,delay:r.delay});let i=jd(e.style.transform);T.current=i,Pd(u,e,c,{resetInlineTransform:!i}),g&&g(e)}),M=Bs(w,e=>{T.current=!1,e.style.transition=``,_&&_(e)}),N=a?e=>{a(w.current,e)}:void 0,P=v.useCallback(()=>{w.current&&Pd(u,w.current,c)},[u,c]);return v.useEffect(()=>{if(f||u===`down`||u===`right`)return;let e=Sd(()=>{w.current&&Pd(u,w.current,c)}),t=wd(w.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[u,f,c]),v.useEffect(()=>{!f&&!T.current&&P()},[f,P]),(0,W.jsx)(rd,{nodeRef:w,onEnter:D,onEntered:k,onEntering:O,onExit:j,onExited:M,onExiting:A,addEndListener:N,appear:o,in:f,reduceMotion:C.shouldReduceMotion,timeout:x,...S,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!f?b||s.props.style?{visibility:`hidden`,...b,...s.props.style}:kd:b&&s.props.style?{...b,...s.props.style}:b||s.props.style,v.cloneElement(s,{ref:E,style:r,...n})}})});function Id(e){return K(`MuiDrawer`,e)}Wr(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`modal`]);var Ld=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},Rd=e=>{let{classes:t,anchor:n,variant:r}=e;return va({root:[`root`,`anchor${Y(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`]},Id,t)},zd=J(xd,{name:`MuiDrawer`,slot:`Root`,overridesResolver:Ld})(_s(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),Bd=J(`div`,{shouldForwardProp:Ko,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:Ld})({flex:`0 0 auto`}),Vd=J(Mc,{name:`MuiDrawer`,slot:`Paper`})(_s(({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}`}}]}))),Hd={left:`right`,right:`left`,top:`down`,bottom:`up`};function Ud(e){return[`left`,`right`].includes(e)}function Wd({direction:e},t){return e===`rtl`&&Ud(t)?Hd[t]:t}var Gd=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDrawer`}),r=Uo(),i=Ii(),a={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{anchor:o=`left`,children:s,className:c,elevation:l=16,hideBackdrop:u=!1,ModalProps:d={},onClose:f,open:p=!1,transitionDuration:m=a,variant:h=`temporary`,slots:g={},slotProps:_={},...y}=n,b=v.useRef(!1),x=v.useRef(null),S=vs(t,x);v.useEffect(()=>{b.current=!0},[]);let C=v.useCallback(()=>x.current,[]),w=Wd({direction:i?`rtl`:`ltr`},o),T=o,E={...n,anchor:T,elevation:l,open:p,variant:h,...y},D=Rd(E),O={slots:g,slotProps:{..._,backdrop:Od(_.backdrop,{transitionDuration:m})}},[k,A]=Jc(`root`,{ref:S,elementType:zd,className:G(D.root,D.modal,c),shouldForwardComponentProp:!0,ownerState:E,externalForwardedProps:{...O,...y,...d},additionalProps:{closeAfterTransition:!0,open:p,onClose:f,hideBackdrop:u,slots:{backdrop:O.slots.backdrop},slotProps:{backdrop:O.slotProps.backdrop}}}),[j,M]=Jc(`paper`,{elementType:Vd,shouldForwardComponentProp:!0,className:D.paper,ownerState:E,externalForwardedProps:O,additionalProps:{elevation:h===`temporary`?l:0,square:!0,...h===`temporary`&&{role:`dialog`,"aria-modal":`true`,"data-mui-focusable":``,tabIndex:-1}}}),[N,P]=Jc(`docked`,{elementType:Bd,ref:S,className:G(D.root,D.docked,c),ownerState:E,externalForwardedProps:O,additionalProps:y}),[F,I]=Jc(`transition`,{elementType:Fd,ownerState:E,externalForwardedProps:O,additionalProps:{in:p,direction:Hd[w],timeout:m,appear:b.current,...h===`temporary`&&(g.transition==null||g.transition===Fd)&&{container:C}}}),L=(0,W.jsx)(j,{...M,children:s});if(h===`permanent`)return(0,W.jsx)(N,{...P,children:L});let R=(0,W.jsx)(F,{...I,children:L});return h===`persistent`?(0,W.jsx)(N,{...P,children:R}):(0,W.jsx)(k,{...A,children:R})});function Kd(e){return K(`MuiIconButton`,e)}var qd=Wr(`MuiIconButton`,[`root`,`disabled`,`colorInherit`,`colorPrimary`,`colorSecondary`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`,`edgeStart`,`edgeEnd`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`loading`,`loadingIndicator`,`loadingWrapper`]),Jd=e=>{let{classes:t,disabled:n,color:r,edge:i,size:a,loading:o}=e;return va({root:[`root`,o&&`loading`,n&&`disabled`,r!=="default"&&`color${Y(r)}`,i&&`edge${Y(i)}`,`size${Y(a)}`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},Kd,t)},Yd=J(eu,{name:`MuiIconButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.loading&&t.loading,n.color!=="default"&&t[`color${Y(n.color)}`],n.edge&&t[`edge${Y(n.edge)}`],t[`size${Y(n.size)}`]]}})(_s(({theme:e})=>({textAlign:`center`,flex:`0 0 auto`,fontSize:e.typography.pxToRem(24),padding:8,borderRadius:`50%`,color:(e.vars||e).palette.action.active,...Ws(e,`background-color`,{duration:e.transitions.duration.shortest}),variants:[{props:e=>!e.disableRipple,style:{"--IconButton-hoverBg":e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity),"&:hover":{backgroundColor:`var(--IconButton-hoverBg)`,"@media (hover: none)":{backgroundColor:`transparent`}}}},{props:{edge:`start`},style:{marginLeft:-12}},{props:{edge:`start`,size:`small`},style:{marginLeft:-3}},{props:{edge:`end`},style:{marginRight:-12}},{props:{edge:`end`,size:`small`},style:{marginRight:-3}}]})),_s(({theme:e})=>({variants:[{props:{color:`inherit`},style:{color:`inherit`}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main,"--IconButton-hoverBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}})),{props:{size:`small`},style:{padding:5,fontSize:e.typography.pxToRem(18)}},{props:{size:`large`},style:{padding:12,fontSize:e.typography.pxToRem(28)}}],[`&.${qd.disabled}`]:{backgroundColor:`transparent`,color:(e.vars||e).palette.action.disabled},[`&.${qd.loading}`]:{color:`transparent`}}))),Xd=J(`span`,{name:`MuiIconButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,color:(e.vars||e).palette.action.disabled,variants:[{props:{loading:!0},style:{display:`flex`}}]})),Zd=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiIconButton`}),{edge:r=!1,children:i,className:a,color:o=`default`,disabled:s=!1,disableFocusRipple:c=!1,size:l=`medium`,id:u,loading:d=null,loadingIndicator:f,...p}=n,m=Td(u),h=f??(0,W.jsx)(bu,{"aria-labelledby":m,color:`inherit`,size:16}),g={...n,edge:r,color:o,disabled:s,disableFocusRipple:c,loading:d,loadingIndicator:h,size:l},_=Jd(g);return(0,W.jsxs)(Yd,{id:d?m:u,className:G(_.root,a),centerRipple:!0,internalNativeButton:!0,focusRipple:!c,disabled:s||d,ref:t,...p,ownerState:g,children:[typeof d==`boolean`&&(0,W.jsx)(`span`,{className:_.loadingWrapper,style:{display:`contents`},children:(0,W.jsx)(Xd,{className:_.loadingIndicator,ownerState:g,children:d&&h})}),i]})}),Qd=v.createContext({});function $d(e){return K(`MuiList`,e)}Wr(`MuiList`,[`root`,`padding`,`dense`,`subheader`]);var ef=e=>{let{classes:t,disablePadding:n,dense:r,subheader:i}=e;return va({root:[`root`,!n&&`padding`,r&&`dense`,i&&`subheader`]},$d,t)},tf=J(`ul`,{name:`MuiList`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disablePadding&&t.padding,n.dense&&t.dense,n.subheader&&t.subheader]}})({listStyle:`none`,margin:0,padding:0,position:`relative`,variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>e.subheader,style:{paddingTop:0,isolation:`isolate`}}]}),nf=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiList`}),{children:r,className:i,component:a=`ul`,dense:o=!1,disablePadding:s=!1,subheader:c,...l}=n,u=v.useMemo(()=>({dense:o}),[o]),d={...n,component:a,dense:o,disablePadding:s},f=ef(d);return(0,W.jsx)(Qd.Provider,{value:u,children:(0,W.jsxs)(tf,{as:a,className:G(f.root,i),ref:t,ownerState:d,...l,children:[c,r]})})}),rf=(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]},af=e=>{let{alignItems:t,classes:n,dense:r,disabled:i,disableGutters:a,divider:o,selected:s}=e,c=va({root:[`root`,r&&`dense`,!a&&`gutters`,o&&`divider`,i&&`disabled`,t===`flex-start`&&`alignItemsFlexStart`,s&&`selected`]},lc,n);return{...n,...c}},of=J(eu,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiListItemButton`,slot:`Root`,overridesResolver:rf})(_s(({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,...Ws(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${uc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${uc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${uc.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)}},[`&.${uc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${uc.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}}]}))),sf=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemButton`}),{alignItems:r=`center`,autoFocus:i=!1,component:a=`div`,children:o,dense:s=!1,disableGutters:c=!1,divider:l=!1,focusVisibleClassName:u,selected:d=!1,className:f,...p}=n,m=v.useContext(Qd),h=v.useMemo(()=>({dense:s||m.dense||!1,alignItems:r,disableGutters:c}),[r,m.dense,s,c]),g=v.useRef(null);ys(()=>{i&&g.current&&g.current.focus()},[i]);let _={...n,alignItems:r,dense:h.dense,disableGutters:c,divider:l,selected:d},y=af(_),{root:b,...x}=y,S=vs(g,t);return(0,W.jsx)(Qd.Provider,{value:h,children:(0,W.jsx)(of,{ref:S,href:p.href||p.to,component:(p.href||p.to)&&a===`div`?`button`:a,internalNativeButton:!1,focusVisibleClassName:G(y.focusVisible,u),ownerState:_,className:G(y.root,f),...p,classes:x,children:o})})});function cf(e){return K(`MuiListItemIcon`,e)}var lf=Wr(`MuiListItemIcon`,[`root`,`alignItemsFlexStart`]),uf=e=>{let{alignItems:t,classes:n}=e;return va({root:[`root`,t===`flex-start`&&`alignItemsFlexStart`]},cf,n)},df=J(`div`,{name:`MuiListItemIcon`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.alignItems===`flex-start`&&t.alignItemsFlexStart]}})(_s(({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}}]}))),ff=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemIcon`}),{className:r,...i}=n,a=v.useContext(Qd),o={...n,alignItems:a.alignItems},s=uf(o);return(0,W.jsx)(df,{className:G(s.root,r),ownerState:o,ref:t,...i})});function pf(e){return K(`MuiTypography`,e)}var mf=Wr(`MuiTypography`,[`root`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`subtitle1`,`subtitle2`,`body1`,`body2`,`inherit`,`button`,`caption`,`overline`,`alignLeft`,`alignRight`,`alignCenter`,`alignJustify`,`noWrap`,`gutterBottom`]),hf=e=>{let{align:t,gutterBottom:n,noWrap:r,variant:i,classes:a}=e;return va({root:[`root`,i,e.align!==`inherit`&&`align${Y(t)}`,n&&`gutterBottom`,r&&`noWrap`]},pf,a)},gf=J(`span`,{name:`MuiTypography`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!==`inherit`&&t[`align${Y(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom]}})(_s(({theme:e})=>({margin:0,variants:[{props:{variant:`inherit`},style:{font:`inherit`,lineHeight:`inherit`,letterSpacing:`inherit`}},...Object.entries(e.typography).filter(([e,t])=>e!==`inherit`&&t&&typeof t==`object`).map(([e,t])=>({props:{variant:e},style:t})),...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}})),...Object.entries(e.palette?.text||{}).filter(([,e])=>typeof e==`string`).map(([t])=>({props:{color:`text${Y(t)}`},style:{color:(e.vars||e).palette.text[t]}})),{props:({ownerState:e})=>e.align!==`inherit`,style:{textAlign:`var(--Typography-textAlign)`}},{props:({ownerState:e})=>e.noWrap,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},{props:({ownerState:e})=>e.gutterBottom,style:{marginBottom:`0.35em`}}]}))),_f={h1:`h1`,h2:`h2`,h3:`h3`,h4:`h4`,h5:`h5`,h6:`h6`,subtitle1:`h6`,subtitle2:`h6`,body1:`p`,body2:`p`,inherit:`p`},Z=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTypography`}),{color:r,align:i=`inherit`,className:a,component:o,gutterBottom:s=!1,noWrap:c=!1,variant:l=`body1`,variantMapping:u=_f,...d}=n,f={...n,align:i,color:r,className:a,component:o,gutterBottom:s,noWrap:c,variant:l,variantMapping:u},p=o||u[l]||_f[l]||`span`,m=hf(f);return(0,W.jsx)(gf,{as:p,ref:t,className:G(m.root,a),...d,ownerState:f,style:{...i!==`inherit`&&{"--Typography-textAlign":i},...d.style}})});function vf(e){return K(`MuiListItemText`,e)}var yf=Wr(`MuiListItemText`,[`root`,`multiline`,`dense`,`inset`,`primary`,`secondary`]),bf=e=>{let{classes:t,inset:n,primary:r,secondary:i,dense:a}=e;return va({root:[`root`,n&&`inset`,a&&`dense`,r&&i&&`multiline`],primary:[`primary`],secondary:[`secondary`]},vf,t)},xf=J(`div`,{name:`MuiListItemText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${yf.primary}`]:t.primary},{[`& .${yf.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,[`.${mf.root}:where(& .${yf.primary})`]:{display:`block`},[`.${mf.root}:where(& .${yf.secondary})`]:{display:`block`},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),Sf=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemText`}),{children:r,className:i,disableTypography:a=!1,inset:o=!1,primary:s,secondary:c,slots:l={},slotProps:u={},...d}=n,{dense:f}=v.useContext(Qd),p=s??r,m=c,h={...n,disableTypography:a,inset:o,primary:!!p,secondary:!!m,dense:f},g=bf(h),_={slots:l,slotProps:u},[y,b]=Jc(`root`,{className:G(g.root,i),elementType:xf,externalForwardedProps:{..._,...d},ownerState:h,ref:t}),[x,S]=Jc(`primary`,{className:g.primary,elementType:Z,externalForwardedProps:_,ownerState:h}),[C,w]=Jc(`secondary`,{className:g.secondary,elementType:Z,externalForwardedProps:_,ownerState:h});return p!=null&&p.type!==Z&&!a&&(p=(0,W.jsx)(x,{variant:f?`body2`:`body1`,component:S?.variant?void 0:`span`,...S,children:p})),m!=null&&m.type!==Z&&!a&&(m=(0,W.jsx)(C,{variant:`body2`,color:`textSecondary`,...w,children:m})),(0,W.jsxs)(y,{...b,children:[p,m]})}),Cf=Ea({createStyledComponent:J(`div`,{name:`MuiStack`,slot:`Root`}),useThemeProps:e=>Jo({props:e,name:`MuiStack`})}),wf=v.createContext({}),Tf=v.createContext(void 0);function Ef(e,t){return t===void 0||e===void 0?!1:Array.isArray(t)?t.includes(e):e===t}var Df=v.createContext(void 0);function Of(){let e=v.useContext(Df);if(e===void 0)throw Error(`MUI: RovingTabIndexContext is missing. Roving tab index items must be placed within a roving tab index provider.`);return e}var kf=Object.is;function Af(e,t){if(e===t)return!0;if(!(e instanceof Object)||!(t instanceof Object))return!1;let n=0,r=0;for(let r in e)if(n+=1,!kf(e[r],t[r])||!(r in t))return!1;for(let e in t)r+=1;return n===r}var jf=[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function Mf(e){let{activeItemId:t,getDefaultActiveItemId:n,orientation:r,isRtl:i=!1,isItemFocusable:a=Kf,wrap:o=!0}=e,[s,c]=v.useState(t),[l,u]=v.useState(t),d=s;t!==l&&(u(t),t!==void 0&&t!==s&&(d=t,c(t)));let f=v.useRef(null),p=v.useRef(new Map),[m,h]=v.useState(0),g=v.useMemo(()=>Uf(p.current),[m]),_=Pf(d,g,a,n),y=v.useRef(_);y.current=_;let b=v.useCallback(()=>{let e=Uf(p.current);return Bf(e,Pf(y.current,e,a,n))},[n,a]),x=v.useCallback(()=>p.current,[]),S=os(e=>{Af(p.current.get(e.id)??null,e)||(p.current.set(e.id,e),h(e=>e+1))}),C=os(e=>{p.current.delete(e)&&h(e=>e+1)}),w=os(e=>{c(e)}),T=v.useCallback(e=>y.current===e,[]),E=v.useCallback((e,t,n,r)=>{let i=Rf(Wf(p.current),e,t,n,r??a);return i?(i.element?.focus(),c(i.id),i):null},[a]),D=v.useCallback((e,t,n)=>({onFocus:e=>{t?.(e);let n=Wf(p.current),r=Hf(n,e.target);r!==-1&&c(n[r].id)},onKeyDown:e=>{if(n?.(e),e.defaultPrevented||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||!jf.includes(e.key))return;let t=r===`horizontal`?`ArrowLeft`:`ArrowUp`,a=r===`horizontal`?`ArrowRight`:`ArrowDown`;r===`horizontal`&&i&&(t=`ArrowRight`,a=`ArrowLeft`);let s=Wf(p.current),c=xs(ss(f.current)),l=c===f.current,u=Lf(s,c,y.current),d=`next`;switch(e.key){case t:d=`previous`,e.preventDefault(),l&&(u=s.length);break;case a:e.preventDefault(),l&&(u=-1);break;case`Home`:e.preventDefault(),u=-1;break;case`End`:e.preventDefault(),d=`previous`,u=s.length;break;default:return}E(u,d,o)},ref:Yf(e,e=>{f.current=e})}),[E,i,r,o]),O=v.useCallback(e=>{let t=Wf(p.current),n=xs(ss(f.current)),r=n===f.current?-1:Lf(t,n,y.current);return E(r,`next`,!0,e)?.id??null},[E]);return v.useMemo(()=>({activeItemId:_,focusNext:O,getActiveItem:b,getContainerProps:D,getItemMap:x,isItemActive:T,registerItem:S,setActiveItemId:w,unregisterItem:C}),[_,O,b,D,x,T,S,w,C])}function Nf(e){let{activeItemId:t,registerItem:n,unregisterItem:r}=Of(),i=v.useRef(null),a=v.useMemo(()=>({disabled:e.disabled??!1,element:null,focusableWhenDisabled:e.focusableWhenDisabled??!1,id:e.id,selected:e.selected??!1,textValue:e.textValue}),[e.disabled,e.focusableWhenDisabled,e.id,e.selected,e.textValue]),o=v.useRef(a);o.current=a;let s=v.useCallback(t=>{if(i.current=t,t==null){queueMicrotask(()=>{i.current??r(e.id)});return}n({...o.current,element:t})},[e.id,n,r]),c=as(e.ref,s);return oi(()=>{i.current&&n({...a,element:i.current})},[a,n]),oi(()=>{let t=e.id;return()=>{r(t)}},[e.id,r]),{ref:c,tabIndex:t===e.id?0:-1}}function Pf(e,t,n,r){return e==null?If(t,n,r):Ff(e,t,n)}function Ff(e,t,n){let r=Vf(t,e);return r===-1?zf(t,n):n(t[r])?t[r].id:Rf(t,r,`next`,!1,n)?.id??null}function If(e,t,n){let r=n?.(e);if(r!=null){let n=Bf(e,r);if(n&&t(n))return n.id}return zf(e,t)}function Lf(e,t,n){if(t){let n=Hf(e,t);if(n!==-1)return n}return Vf(e,n)}function Rf(e,t,n,r,i){let a=e.length-1;if(a===-1)return null;let o=!1,s=Gf(t,a,n,r),c=s;for(;s!==-1;){if(s===c){if(o)return null;o=!0}let t=e[s];if(!t||!i(t))s=Gf(s,a,n,r);else return t}return null}function zf(e,t){return e.find(e=>t(e))?.id??null}function Bf(e,t){return t==null?null:e.find(e=>e.id===t)??null}function Vf(e,t){return t==null?-1:e.findIndex(e=>e.id===t)}function Hf(e,t){return t?e.findIndex(e=>e.element===t||e.element?.contains(t)):-1}function Uf(e){let t=Array.from(e.values());if(t.every(e=>e.element==null))return t;let n=t.filter(qf).sort((e,t)=>Jf(e.element,t.element)),r=t.filter(e=>!qf(e));return[...n,...r]}function Wf(e){return Uf(e).filter(qf)}function Gf(e,t,n,r=!0){return n===`next`?e===t?r?0:-1:e+1:e===0?r?t:-1:e-1}function Kf(e){return e.element?e.focusableWhenDisabled?!0:!e.disabled&&!e.element.hasAttribute(`disabled`)&&e.element.getAttribute(`aria-disabled`)!==`true`&&e.element.hasAttribute(`tabindex`):!1}function qf(e){return e.element!=null&&e.element.isConnected}function Jf(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function Yf(...e){return t=>{e.forEach(e=>{Ju(e??null,t)})}}function Xf(e,t){let{children:n,disabled:r=!1,selected:i=!1,value:a}=e,o=Of(),s=Nf({id:a,ref:t,disabled:r,selected:i}),c=o.getItemMap().size===0&&i?0:s.tabIndex;return v.cloneElement(v.Children.only(n),{...s,tabIndex:n.props.tabIndex??c})}var Zf=v.forwardRef(Xf),Qf=e=>{let{classes:t,fullWidth:n,selected:r,disabled:i,size:a,color:o}=e;return va({root:[`root`,r&&`selected`,i&&`disabled`,n&&`fullWidth`,`size${Y(a)}`,o]},_c,t)},$f=J(eu,{name:`MuiToggleButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`size${Y(n.size)}`]]}})(_s(({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,[`&.${vc.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:{[`&.${vc.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(Oc()).map(([t])=>({props:{color:t},style:{[`&.${vc.selected}`]:{color:(e.vars||e).palette[t].main,backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity),"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity)}}}}})),{props:{fullWidth:!0},style:{width:`100%`}},{props:{size:`small`},style:{padding:7,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`},style:{padding:15,fontSize:e.typography.pxToRem(15)}}]}))),ep=v.forwardRef(function(e,t){let{value:n,isRovingTabIndex:r,...i}=v.useContext(wf),a=v.useContext(Tf),o=Jo({props:ri({...i,selected:Ef(e.value,n)},e),name:`MuiToggleButton`}),{children:s,className:c,color:l=`standard`,disabled:u=!1,disableFocusRipple:d=!1,fullWidth:f=!1,onChange:p,onClick:m,selected:h,size:g=`medium`,value:_,...y}=o,b={...o,color:l,disabled:u,disableFocusRipple:d,fullWidth:f,size:g},x=Qf(b),S=e=>{m&&(m(e,_),e.defaultPrevented)||p&&p(e,_)},C=a||``,w=(0,W.jsx)($f,{className:G(i.className,x.root,c,C),internalNativeButton:!0,disabled:u,focusRipple:!d,ref:r?void 0:t,onClick:S,onChange:p,value:_,ownerState:b,"aria-pressed":h,...y,children:s});return r?(0,W.jsx)(Zf,{disabled:u,selected:h,ref:t,value:_,children:w}):w});function tp(e){return v.Children.toArray(e).filter(e=>v.isValidElement(e))}function np(e){return K(`MuiToggleButtonGroup`,e)}var rp=Wr(`MuiToggleButtonGroup`,[`root`,`selected`,`horizontal`,`vertical`,`disabled`,`grouped`,`fullWidth`,`firstButton`,`lastButton`,`middleButton`]),ip=e=>{let{classes:t,orientation:n,fullWidth:r,disabled:i}=e;return va({root:[`root`,n,r&&`fullWidth`],grouped:[`grouped`,i&&`disabled`],firstButton:[`firstButton`],lastButton:[`lastButton`],middleButton:[`middleButton`]},np,t)},ap=J(`div`,{name:`MuiToggleButtonGroup`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${rp.grouped}`]:t.grouped},{[`& .${rp.firstButton}`]:t.firstButton},{[`& .${rp.lastButton}`]:t.lastButton},{[`& .${rp.middleButton}`]:t.middleButton},t.root,n.orientation===`vertical`&&t.vertical,n.fullWidth&&t.fullWidth]}})(_s(({theme:e})=>({display:`inline-flex`,borderRadius:(e.vars||e).shape.borderRadius,variants:[{props:{orientation:`vertical`},style:{flexDirection:`column`,[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderTop:0,marginTop:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginTop:-1,borderTop:`1px solid transparent`,borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${rp.lastButton}.${vc.disabled},& .${rp.middleButton}.${vc.disabled}`]:{borderTop:`1px solid transparent`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{orientation:`horizontal`},style:{[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginLeft:-1,borderLeft:`1px solid transparent`,borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${rp.lastButton}.${vc.disabled},& .${rp.middleButton}.${vc.disabled}`]:{borderLeft:`1px solid transparent`}}}]}))),op=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiToggleButtonGroup`}),{children:r,className:i,color:a=`standard`,disabled:o=!1,exclusive:s=!1,fullWidth:c=!1,onChange:l,orientation:u=`horizontal`,size:d=`medium`,value:f,...p}=n,m={...n,disabled:o,fullWidth:c,orientation:u,size:d},h=ip(m),g=Ii(),_=v.useCallback((e,t)=>{if(!l)return;let n=f&&f.indexOf(t),r;f&&n>=0?(r=f.slice(),r.splice(n,1)):r=f?f.concat(t):[t],l(e,r)},[l,f]),y=v.useCallback((e,t)=>{l&&l(e,f===t?null:t)},[l,f]),b=v.useMemo(()=>({className:h.grouped,onChange:s?y:_,value:f,size:d,fullWidth:c,color:a,disabled:o,isRovingTabIndex:!0}),[h.grouped,s,y,_,f,d,c,a,o]),x=tp(r),S=x.length,C=e=>{let t=e===0,n=e===S-1;return t&&n?``:t?h.firstButton:n?h.lastButton:h.middleButton},w=Mf({orientation:u,isRtl:g}),T=w.getContainerProps(t,p.onFocus,p.onKeyDown);return(0,W.jsx)(ap,{role:`group`,className:G(h.root,i),ownerState:m,...p,...T,children:(0,W.jsx)(Df.Provider,{value:w,children:(0,W.jsx)(wf.Provider,{value:b,children:x.map((e,t)=>(0,W.jsx)(Tf.Provider,{value:C(t),children:e},t))})})})});function sp(e){return K(`MuiToolbar`,e)}Wr(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var cp=e=>{let{classes:t,disableGutters:n,variant:r}=e;return va({root:[`root`,!n&&`gutters`,r]},sp,t)},lp=J(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(_s(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up(`sm`)]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:`dense`},style:{minHeight:48}},{props:{variant:`regular`},style:e.mixins.toolbar}]}))),up=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiToolbar`}),{className:r,component:i=`div`,disableGutters:a=!1,variant:o=`regular`,...s}=n,c={...n,component:i,disableGutters:a,variant:o},l=cp(c);return(0,W.jsx)(lp,{as:i,className:G(l.root,r),ref:t,ownerState:c,...s})});function dp(e){return`scale(${e}, ${e**2})`}var fp={entering:{opacity:1,transform:dp(1)},entered:{opacity:1,transform:`none`},exiting:{opacity:0,transform:dp(.75)},exited:{opacity:0,transform:dp(.75)}},pp={opacity:0,transform:dp(.75),visibility:`hidden`},mp=v.forwardRef(function(e,t){let{addEndListener:n,appear:r=!0,children:i,disablePrefersReducedMotion:a=!1,easing:o,in:s,onEnter:c,onEntered:l,onEntering:u,onExit:d,onExited:f,onExiting:p,style:m,timeout:h=`auto`,...g}=e,_=v.useRef(null),y=Uo(),b=Il(y.motion.reducedMotion,a),x=v.useRef(null),S=vs(x,Iu(i),t),C=Bs(x,u),w=Bs(x,(e,t)=>{b.shouldReduceMotion||As(e);let{duration:n,delay:r,easing:i}=Hs({style:m,timeout:h,easing:o},{mode:`enter`}),a;h===`auto`&&!b.shouldReduceMotion?(a=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=a):(a=n,_.current=null);let s=b.getTransitionTiming({duration:a,delay:r});e.style.transition=[y.transitions.create(`opacity`,{duration:s.duration,delay:s.delay}),y.transitions.create(`transform`,{duration:typeof s.duration==`string`?s.duration:s.duration*.666,delay:s.delay,easing:i})].join(`,`),c&&c(e,t)}),T=Bs(x,l),E=Bs(x,p),D=Bs(x,e=>{let{duration:t,delay:n,easing:r}=Hs({style:m,timeout:h,easing:o},{mode:`exit`}),i;h===`auto`&&!b.shouldReduceMotion?(i=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=i):(i=t,_.current=null);let a=b.getTransitionTiming({duration:i,delay:n});e.style.transition=[y.transitions.create(`opacity`,{duration:a.duration,delay:a.delay}),y.transitions.create(`transform`,{duration:typeof a.duration==`string`?a.duration:a.duration*.666,delay:a.delay||(typeof a.duration==`string`?a.duration:a.duration*.333),easing:r})].join(`,`),e.style.opacity=0,e.style.transform=dp(.75),d&&d(e)}),O=Bs(x,e=>{e.style.transition=``,f&&f(e)});return(0,W.jsx)(rd,{appear:r,in:s,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:n?e=>{n(x.current,e)}:void 0,getAutoTimeout:h===`auto`?()=>_.current:void 0,reduceMotion:b.shouldReduceMotion,timeout:h===`auto`?null:h,...g,children:(e,{ownerState:t,...n})=>{let r=Vs(e,s,fp,pp,m,i.props.style);return v.cloneElement(i,{style:r,ref:S,...n})}})});mp&&(mp.muiSupportAuto=!0);var hp=`bottom`,gp=`right`,_p=`left`,vp=`auto`,yp=[`top`,hp,gp,_p],bp=`start`,xp=`clippingParents`,Sp=`viewport`,Cp=`popper`,wp=`reference`,Tp=yp.reduce(function(e,t){return e.concat([t+`-`+bp,t+`-end`])},[]),Ep=[].concat(yp,[vp]).reduce(function(e,t){return e.concat([t,t+`-`+bp,t+`-end`])},[]),Dp=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function Op(e){return e?(e.nodeName||``).toLowerCase():null}function kp(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ap(e){return e instanceof kp(e).Element||e instanceof Element}function jp(e){return e instanceof kp(e).HTMLElement||e instanceof HTMLElement}function Mp(e){return typeof ShadowRoot>`u`?!1:e instanceof kp(e).ShadowRoot||e instanceof ShadowRoot}function Np(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];!jp(i)||!Op(i)||(Object.assign(i.style,n),Object.keys(r).forEach(function(e){var t=r[e];t===!1?i.removeAttribute(e):i.setAttribute(e,t===!0?``:t)}))})}function Pp(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],i=t.attributes[e]||{},a=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]=``,e},{});!jp(r)||!Op(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Fp={name:`applyStyles`,enabled:!0,phase:`write`,fn:Np,effect:Pp,requires:[`computeStyles`]};function Ip(e){return e.split(`-`)[0]}var Lp=Math.max,Rp=Math.min,zp=Math.round;function Bp(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+`/`+e.version}).join(` `):navigator.userAgent}function Vp(){return!/^((?!chrome|android).)*safari/i.test(Bp())}function Hp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&jp(e)&&(i=e.offsetWidth>0&&zp(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&zp(r.height)/e.offsetHeight||1);var o=(Ap(e)?kp(e):window).visualViewport,s=!Vp()&&n,c=(r.left+(s&&o?o.offsetLeft:0))/i,l=(r.top+(s&&o?o.offsetTop:0))/a,u=r.width/i,d=r.height/a;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c,x:c,y:l}}function Up(e){var t=Hp(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Wp(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Mp(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Gp(e){return kp(e).getComputedStyle(e)}function Kp(e){return[`table`,`td`,`th`].indexOf(Op(e))>=0}function qp(e){return((Ap(e)?e.ownerDocument:e.document)||window.document).documentElement}function Jp(e){return Op(e)===`html`?e:e.assignedSlot||e.parentNode||(Mp(e)?e.host:null)||qp(e)}function Yp(e){return!jp(e)||Gp(e).position===`fixed`?null:e.offsetParent}function Xp(e){var t=/firefox/i.test(Bp());if(/Trident/i.test(Bp())&&jp(e)&&Gp(e).position===`fixed`)return null;var n=Jp(e);for(Mp(n)&&(n=n.host);jp(n)&&[`html`,`body`].indexOf(Op(n))<0;){var r=Gp(n);if(r.transform!==`none`||r.perspective!==`none`||r.contain===`paint`||[`transform`,`perspective`].indexOf(r.willChange)!==-1||t&&r.willChange===`filter`||t&&r.filter&&r.filter!==`none`)return n;n=n.parentNode}return null}function Zp(e){for(var t=kp(e),n=Yp(e);n&&Kp(n)&&Gp(n).position===`static`;)n=Yp(n);return n&&(Op(n)===`html`||Op(n)===`body`&&Gp(n).position===`static`)?t:n||Xp(e)||t}function Qp(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function $p(e,t,n){return Lp(e,Rp(t,n))}function em(e,t,n){var r=$p(e,t,n);return r>n?n:r}function tm(){return{top:0,right:0,bottom:0,left:0}}function nm(e){return Object.assign({},tm(),e)}function rm(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var im=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,nm(typeof e==`number`?rm(e,yp):e)};function am(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=Ip(n.placement),c=Qp(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=im(i.padding,n),d=Up(a),f=c===`y`?`top`:_p,p=c===`y`?hp:gp,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=Zp(a),_=g?c===`y`?g.clientHeight||0:g.clientWidth||0:0,v=m/2-h/2,y=u[f],b=_-d[l]-u[p],x=_/2-d[l]/2+v,S=$p(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function om(e){var t=e.state,n=e.options.element,r=n===void 0?`[data-popper-arrow]`:n;r!=null&&(typeof r==`string`&&(r=t.elements.popper.querySelector(r),!r)||Wp(t.elements.popper,r)&&(t.elements.arrow=r))}var sm={name:`arrow`,enabled:!0,phase:`main`,fn:am,effect:om,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function cm(e){return e.split(`-`)[1]}var lm={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function um(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:zp(n*i)/i||0,y:zp(r*i)/i||0}}function dm(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,o=e.offsets,s=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,p=f===void 0?0:f,m=o.y,h=m===void 0?0:m,g=typeof u==`function`?u({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var _=o.hasOwnProperty(`x`),v=o.hasOwnProperty(`y`),y=_p,b=`top`,x=window;if(l){var S=Zp(n),C=`clientHeight`,w=`clientWidth`;if(S===kp(n)&&(S=qp(n),Gp(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=hp;var T=d&&S===x&&x.visualViewport?x.visualViewport.height:S[C];h-=T-r.height,h*=c?1:-1}if(i===`left`||(i===`top`||i===`bottom`)&&a===`end`){y=gp;var E=d&&S===x&&x.visualViewport?x.visualViewport.width:S[w];p-=E-r.width,p*=c?1:-1}}var D=Object.assign({position:s},l&&lm),O=u===!0?um({x:p,y:h},kp(n)):{x:p,y:h};if(p=O.x,h=O.y,c){var k;return Object.assign({},D,(k={},k[b]=v?`0`:``,k[y]=_?`0`:``,k.transform=(x.devicePixelRatio||1)<=1?`translate(`+p+`px, `+h+`px)`:`translate3d(`+p+`px, `+h+`px, 0)`,k))}return Object.assign({},D,(t={},t[b]=v?h+`px`:``,t[y]=_?p+`px`:``,t.transform=``,t))}function fm(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0||r,a=n.adaptive,o=a===void 0||a,s=n.roundOffsets,c=s===void 0||s,l={placement:Ip(t.placement),variation:cm(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy===`fixed`};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,dm(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,dm(Object.assign({},l,{offsets:t.modifiersData.arrow,position:`absolute`,adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}var pm={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:fm,data:{}},mm={passive:!0};function hm(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0||i,o=r.resize,s=o===void 0||o,c=kp(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,mm)}),s&&c.addEventListener(`resize`,n.update,mm),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,mm)}),s&&c.removeEventListener(`resize`,n.update,mm)}}var gm={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:hm,data:{}},_m={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vm(e){return e.replace(/left|right|bottom|top/g,function(e){return _m[e]})}var ym={start:`end`,end:`start`};function bm(e){return e.replace(/start|end/g,function(e){return ym[e]})}function xm(e){var t=kp(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Sm(e){return Hp(qp(e)).left+xm(e).scrollLeft}function Cm(e,t){var n=kp(e),r=qp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=Vp();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+Sm(e),y:c}}function wm(e){var t=qp(e),n=xm(e),r=e.ownerDocument?.body,i=Lp(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=Lp(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+Sm(e),s=-n.scrollTop;return Gp(r||t).direction===`rtl`&&(o+=Lp(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function Tm(e){var t=Gp(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Em(e){return[`html`,`body`,`#document`].indexOf(Op(e))>=0?e.ownerDocument.body:jp(e)&&Tm(e)?e:Em(Jp(e))}function Dm(e,t){t===void 0&&(t=[]);var n=Em(e),r=n===e.ownerDocument?.body,i=kp(n),a=r?[i].concat(i.visualViewport||[],Tm(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(Dm(Jp(a)))}function Om(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function km(e,t){var n=Hp(e,!1,t===`fixed`);return n.top+=e.clientTop,n.left+=e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Am(e,t,n){return t===`viewport`?Om(Cm(e,n)):Ap(t)?km(t,n):Om(wm(qp(e)))}function jm(e){var t=Dm(Jp(e)),n=[`absolute`,`fixed`].indexOf(Gp(e).position)>=0&&jp(e)?Zp(e):e;return Ap(n)?t.filter(function(e){return Ap(e)&&Wp(e,n)&&Op(e)!==`body`}):[]}function Mm(e,t,n,r){var i=t===`clippingParents`?jm(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=Am(e,n,r);return t.top=Lp(i.top,t.top),t.right=Rp(i.right,t.right),t.bottom=Rp(i.bottom,t.bottom),t.left=Lp(i.left,t.left),t},Am(e,o,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Nm(e){var t=e.reference,n=e.element,r=e.placement,i=r?Ip(r):null,a=r?cm(r):null,o=t.x+t.width/2-n.width/2,s=t.y+t.height/2-n.height/2,c;switch(i){case`top`:c={x:o,y:t.y-n.height};break;case hp:c={x:o,y:t.y+t.height};break;case gp:c={x:t.x+t.width,y:s};break;case _p:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?Qp(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case bp:c[l]=c[l]-(t[u]/2-n[u]/2);break;case`end`:c[l]=c[l]+(t[u]/2-n[u]/2)}}return c}function Pm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,o=a===void 0?e.strategy:a,s=n.boundary,c=s===void 0?xp:s,l=n.rootBoundary,u=l===void 0?Sp:l,d=n.elementContext,f=d===void 0?Cp:d,p=n.altBoundary,m=p!==void 0&&p,h=n.padding,g=h===void 0?0:h,_=nm(typeof g==`number`?rm(g,yp):g),v=f===`popper`?wp:Cp,y=e.rects.popper,b=e.elements[m?v:f],x=Mm(Ap(b)?b:b.contextElement||qp(e.elements.popper),c,u,o),S=Hp(e.elements.reference),C=Nm({reference:S,element:y,strategy:`absolute`,placement:i}),w=Om(Object.assign({},y,C)),T=f===`popper`?w:S,E={top:x.top-T.top+_.top,bottom:T.bottom-x.bottom+_.bottom,left:x.left-T.left+_.left,right:T.right-x.right+_.right},D=e.modifiersData.offset;if(f===`popper`&&D){var O=D[i];Object.keys(E).forEach(function(e){var t=[`right`,`bottom`].indexOf(e)>=0?1:-1,n=[`top`,`bottom`].indexOf(e)>=0?`y`:`x`;E[e]+=O[n]*t})}return E}function Fm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,o=n.padding,s=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?Ep:c,u=cm(r),d=u?s?Tp:Tp.filter(function(e){return cm(e)===u}):yp,f=d.filter(function(e){return l.indexOf(e)>=0});f.length===0&&(f=d);var p=f.reduce(function(t,n){return t[n]=Pm(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[Ip(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function Im(e){if(Ip(e)===`auto`)return[];var t=vm(e);return[bm(e),t,bm(t)]}function Lm(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o===void 0||o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0||p,h=n.allowedAutoPlacements,g=t.options.placement,_=Ip(g)===g,v=c||(_||!m?[vm(g)]:Im(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(Ip(n)===`auto`?Fm(t,{placement:n,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:h}):n)},[]),b=t.rects.reference,x=t.rects.popper,S=new Map,C=!0,w=y[0],T=0;T<y.length;T++){var E=y[T],D=Ip(E),O=cm(E)===bp,k=[`top`,hp].indexOf(D)>=0,A=k?`width`:`height`,j=Pm(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?gp:_p:O?hp:`top`;b[A]>x[A]&&(M=vm(M));var N=vm(M),P=[];if(a&&P.push(j[D]<=0),s&&P.push(j[M]<=0,j[N]<=0),P.every(function(e){return e})){w=E,C=!1;break}S.set(E,P)}if(C)for(var F=m?3:1,I=function(e){var t=y.find(function(t){var n=S.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return w=t,`break`},L=F;L>0&&I(L)!==`break`;L--);t.placement!==w&&(t.modifiersData[r]._skip=!0,t.placement=w,t.reset=!0)}}var Rm={name:`flip`,enabled:!0,phase:`main`,fn:Lm,requiresIfExists:[`offset`],data:{_skip:!1}};function zm(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Bm(e){return[`top`,gp,hp,_p].some(function(t){return e[t]>=0})}function Vm(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=Pm(t,{elementContext:`reference`}),s=Pm(t,{altBoundary:!0}),c=zm(o,r),l=zm(s,i,a),u=Bm(c),d=Bm(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var Hm={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Vm};function Um(e,t,n){var r=Ip(e),i=[`left`,`top`].indexOf(r)>=0?-1:1,a=typeof n==`function`?n(Object.assign({},t,{placement:e})):n,o=a[0],s=a[1];return o||=0,s=(s||0)*i,[`left`,`right`].indexOf(r)>=0?{x:s,y:o}:{x:o,y:s}}function Wm(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=Ep.reduce(function(e,n){return e[n]=Um(n,t.rects,a),e},{}),s=o[t.placement],c=s.x,l=s.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}var Gm={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:Wm};function Km(e){var t=e.state,n=e.name;t.modifiersData[n]=Nm({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var qm={name:`popperOffsets`,enabled:!0,phase:`read`,fn:Km,data:{}};function Jm(e){return e===`x`?`y`:`x`}function Ym(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o!==void 0&&o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0||f,m=n.tetherOffset,h=m===void 0?0:m,g=Pm(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=Ip(t.placement),v=cm(t.placement),y=!v,b=Qp(_),x=Jm(b),S=t.modifiersData.popperOffsets,C=t.rects.reference,w=t.rects.popper,T=typeof h==`function`?h(Object.assign({},t.rects,{placement:t.placement})):h,E=typeof T==`number`?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(a){var k=b===`y`?`top`:_p,A=b===`y`?hp:gp,j=b===`y`?`height`:`width`,M=S[b],N=M+g[k],P=M-g[A],F=p?-w[j]/2:0,I=v===`start`?C[j]:w[j],L=v===`start`?-w[j]:-C[j],R=t.elements.arrow,ee=p&&R?Up(R):{width:0,height:0},te=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:tm(),ne=te[k],z=te[A],B=$p(0,C[j],ee[j]),V=y?C[j]/2-F-B-ne-E.mainAxis:I-B-ne-E.mainAxis,re=y?-C[j]/2+F+B+z+E.mainAxis:L+B+z+E.mainAxis,ie=t.elements.arrow&&Zp(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+V-oe-ae,H=M+re-oe,ce=$p(p?Rp(N,se):N,M,p?Lp(P,H):P);S[b]=ce,O[b]=ce-M}if(s){var le=b===`x`?`top`:_p,ue=b===`x`?hp:gp,de=S[x],fe=x===`y`?`height`:`width`,pe=de+g[le],me=de-g[ue],he=[`top`,_p].indexOf(_)!==-1,U=D?.[x]??0,ge=he?pe:de-C[fe]-w[fe]-U+E.altAxis,_e=he?de+C[fe]+w[fe]-U-E.altAxis:me,ve=p&&he?em(ge,de,_e):$p(p?ge:pe,de,p?_e:me);S[x]=ve,O[x]=ve-de}t.modifiersData[r]=O}}var Xm={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Ym,requiresIfExists:[`offset`]};function Zm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Qm(e){return e===kp(e)||!jp(e)?xm(e):Zm(e)}function $m(e){var t=e.getBoundingClientRect(),n=zp(t.width)/e.offsetWidth||1,r=zp(t.height)/e.offsetHeight||1;return n!==1||r!==1}function eh(e,t,n){n===void 0&&(n=!1);var r=jp(t),i=jp(t)&&$m(t),a=qp(t),o=Hp(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Op(t)!==`body`||Tm(a))&&(s=Qm(t)),jp(t)?(c=Hp(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=Sm(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function th(e){var t=new Map,n=new Set,r=[];e.forEach(function(e){t.set(e.name,e)});function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}}),r.push(e)}return e.forEach(function(e){n.has(e.name)||i(e)}),r}function nh(e){var t=th(e);return Dp.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function rh(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function ih(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}var ah={placement:`bottom`,modifiers:[],strategy:`absolute`};function oh(){return![...arguments].some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function sh(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?ah:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},ah,a),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},o=[],s=!1,c={state:i,setOptions:function(n){var o=typeof n==`function`?n(i.options):n;u(),i.options=Object.assign({},a,i.options,o),i.scrollParents={reference:Ap(e)?Dm(e):e.contextElement?Dm(e.contextElement):[],popper:Dm(t)};var s=nh(ih([].concat(r,i.options.modifiers)));return i.orderedModifiers=s.filter(function(e){return e.enabled}),l(),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if(oh(t,n)){i.rects={reference:eh(t,Zp(n),i.options.strategy===`fixed`),popper:Up(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach(function(e){return i.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<i.orderedModifiers.length;r++){if(i.reset===!0){i.reset=!1,r=-1;continue}var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=l===void 0?{}:l,d=a.name;typeof o==`function`&&(i=o({state:i,options:u,name:d,instance:c})||i)}}}},update:rh(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!oh(e,t))return c;c.setOptions(n).then(function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)});function l(){i.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=n===void 0?{}:n,a=e.effect;if(typeof a==`function`){var s=a({state:i,name:t,instance:c,options:r});o.push(s||function(){})}})}function u(){o.forEach(function(e){return e()}),o=[]}return c}}var ch=sh({defaultModifiers:[gm,qm,pm,Fp,Gm,Rm,Xm,sm,Hm]});function lh(e){let{elementType:t,externalSlotProps:n,ownerState:r,skipResolvingSlotProps:i=!1,...a}=e,o=i?{}:Uc(n,r),{props:s,internalRef:c}=qc({...a,externalSlotProps:o}),l=as(c,o?.ref,e.additionalProps?.ref);return Hc(t,{...s,ref:l},r)}function uh(e){return K(`MuiPopper`,e)}Wr(`MuiPopper`,[`root`]);function dh(e,t){if(t===`ltr`)return e;switch(e){case`bottom-end`:return`bottom-start`;case`bottom-start`:return`bottom-end`;case`top-end`:return`top-start`;case`top-start`:return`top-end`;default:return e}}function fh(e){return typeof e==`function`?e():e}function ph(e){return e.nodeType!==void 0}var mh=e=>{let{classes:t}=e;return va({root:[`root`]},uh,t)},hh={},gh=v.forwardRef(function(e,t){let{anchorEl:n,children:r,direction:i,disablePortal:a,modifiers:o,open:s,placement:c,popperOptions:l,popperRef:u,slotProps:d={},slots:f={},TransitionProps:p,ownerState:m,...h}=e,g=v.useRef(null),_=as(g,t),y=v.useRef(null),b=as(y,u),x=v.useRef(b);oi(()=>{x.current=b},[b]),v.useImperativeHandle(u,()=>y.current,[]);let S=dh(c,i),[C,w]=v.useState(S),T=v.useMemo(()=>fh(n),[n]);v.useEffect(()=>{y.current&&y.current.forceUpdate()}),oi(()=>{if(!T||!s)return;let e=e=>{w(e.placement)},t=[{name:`preventOverflow`,options:{altBoundary:a}},{name:`flip`,options:{altBoundary:a}},{name:`onUpdate`,enabled:!0,phase:`afterWrite`,fn:({state:t})=>{e(t)}}];o!=null&&(t=t.concat(o)),l&&l.modifiers!=null&&(t=t.concat(l.modifiers));let n=ch(T,g.current,{placement:S,...l,modifiers:t});x.current(n);let r=g.current;return()=>{if(r){let{style:e}=r,t=e.position,i=e.top,a=e.left,o=e.transform;n.destroy(),e.position=t,e.top=i,e.left=a,e.transform=o}else n.destroy();x.current(null)}},[T,a,o,s,l,S]);let E={placement:C};p!==null&&(E.TransitionProps=p);let D=mh(e),O=f.root??`div`,k=lh({elementType:O,externalSlotProps:d.root,externalForwardedProps:h,additionalProps:{role:`tooltip`,ref:_},ownerState:e,className:D.root});return(0,W.jsx)(O,{...k,children:typeof r==`function`?r(E):r})}),_h=J(v.forwardRef(function(e,t){let{anchorEl:n,children:r,container:i,direction:a=`ltr`,disablePortal:o=!1,keepMounted:s=!1,modifiers:c,open:l,placement:u=`bottom`,popperOptions:d=hh,popperRef:f,style:p,transition:m=!1,slotProps:h={},slots:g={},..._}=e,[y,b]=v.useState(!0),x=()=>{b(!1)},S=()=>{b(!0)};if(!s&&!l&&(!m||y))return null;let C;if(i)C=i;else if(n){let e=fh(n);C=e&&ph(e)?ss(e).body:ss(null).body}let w=!l&&s&&(!m||y)?`none`:void 0,T=m?{in:l,onEnter:x,onExited:S}:void 0;return(0,W.jsx)(Zu,{disablePortal:o,container:C,children:(0,W.jsx)(gh,{anchorEl:n,direction:a,disablePortal:o,modifiers:c,ref:t,open:m?!y:l,placement:u,popperOptions:d,popperRef:f,slotProps:h,slots:g,..._,style:{position:`fixed`,top:0,left:0,display:w,...p},TransitionProps:T,children:r})})}),{name:`MuiPopper`,slot:`Root`})({}),vh=v.forwardRef(function(e,t){let n=Ii(),{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}=Jo({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,W.jsx)(_h,{as:i,direction:n?`rtl`:`ltr`,slots:m,slotProps:h,..._,ref:t})});function yh(e){return K(`MuiTooltip`,e)}var bh=Wr(`MuiTooltip`,[`popper`,`popperInteractive`,`popperArrow`,`popperClose`,`tooltip`,`tooltipArrow`,`touch`,`tooltipPlacementLeft`,`tooltipPlacementRight`,`tooltipPlacementTop`,`tooltipPlacementBottom`,`arrow`]);function xh(e){return Math.round(e*1e5)/1e5}var Sh=e=>{let{classes:t,disableInteractive:n,arrow:r,touch:i,placement:a}=e;return va({popper:[`popper`,!n&&`popperInteractive`,r&&`popperArrow`],tooltip:[`tooltip`,r&&`tooltipArrow`,i&&`touch`,`tooltipPlacement${Y(a.split(`-`)[0])}`],arrow:[`arrow`]},yh,t)},Ch=J(vh,{name:`MuiTooltip`,slot:`Popper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.popper,!n.disableInteractive&&t.popperInteractive,n.arrow&&t.popperArrow,!n.open&&t.popperClose]}})(_s(({theme:e})=>({zIndex:(e.vars||e).zIndex.tooltip,pointerEvents:`none`,variants:[{props:({ownerState:e,open:t})=>t&&!e.disableInteractive,style:{pointerEvents:`auto`}},{props:({ownerState:e})=>e.arrow,style:{[`&[data-popper-placement*="bottom"] .${bh.arrow}`]:{top:0,marginTop:`-0.71em`,"&::before":{transformOrigin:`0 100%`}},[`&[data-popper-placement*="top"] .${bh.arrow}`]:{bottom:0,marginBottom:`-0.71em`,"&::before":{transformOrigin:`100% 0`}},[`&[data-popper-placement*="right"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineStart:0,marginInlineStart:`-0.71em`,"&::before":{transformOrigin:`100% 100%`}},[`&[data-popper-placement*="left"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineEnd:0,marginInlineEnd:`-0.71em`,"&::before":{transformOrigin:`0 0`}}}}]}))),wh=J(`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${Y(n.placement.split(`-`)[0])}`]]}})(_s(({theme:e})=>({backgroundColor:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.92),borderRadius:(e.vars||e).shape.borderRadius,color:(e.vars||e).palette.common.white,fontFamily:e.typography.fontFamily,padding:`4px 8px`,fontSize:e.typography.pxToRem(11),maxWidth:300,margin:2,wordWrap:`break-word`,fontWeight:e.typography.fontWeightMedium,[`.${bh.popper}[data-popper-placement*="left"] &`]:{transformOrigin:`right center`,marginInlineEnd:`14px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{transformOrigin:`left center`,marginInlineStart:`14px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{transformOrigin:`center bottom`,marginBottom:`14px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{transformOrigin:`center top`,marginTop:`14px`},variants:[{props:({ownerState:e})=>e.arrow,style:{position:`relative`,marginBlock:0}},{props:({ownerState:e})=>e.touch,style:{padding:`8px 16px`,fontSize:e.typography.pxToRem(14),lineHeight:`${xh(16/14)}em`,fontWeight:e.typography.fontWeightRegular}},{props:({ownerState:e})=>e.touch,style:{[`.${bh.popper}[data-popper-placement*="left"] &`]:{marginInlineEnd:`24px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{marginInlineStart:`24px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{marginBottom:`24px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{marginTop:`24px`}}}]}))),Th=J(`span`,{name:`MuiTooltip`,slot:`Arrow`})(_s(({theme:e})=>({overflow:`hidden`,position:`absolute`,width:`1em`,height:`0.71em`,boxSizing:`border-box`,color:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.9),"&::before":{content:`""`,margin:`auto`,display:`block`,width:`100%`,height:`100%`,backgroundColor:`currentColor`,transform:`rotate(45deg)`}}))),Eh=!1,Dh=new xl,Oh={x:0,y:0};function kh(e,t){return(n,...r)=>{t&&t(n,...r),e(n,...r)}}var Ah=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTooltip`}),{arrow:r=!1,children:i,classes:a,describeChild:o=!1,disableFocusListener:s=!1,disableHoverListener:c=!1,disableInteractive:l=!1,disableTouchListener:u=!1,enterDelay:d=100,enterNextDelay:f=0,enterTouchDelay:p=700,followCursor:m=!1,id:h,leaveDelay:g=0,leaveTouchDelay:_=1500,onClose:y,onOpen:b,open:x,placement:S=`bottom`,slotProps:C={},slots:w={},title:T,...E}=n,D=v.isValidElement(i)?i:(0,W.jsx)(`span`,{children:i}),O=Uo(),[k,A]=v.useState(),[j,M]=v.useState(null),N=v.useRef(!1),P=l||m,F=Sl(),I=Sl(),L=Sl(),R=Sl(),[ee,te]=Dd({controlled:x,default:!1,name:`Tooltip`,state:`open`}),ne=ee,z=Td(h),B=v.useRef(),V=ul(()=>{B.current!==void 0&&(document.body.style.WebkitUserSelect=B.current,B.current=void 0),R.clear()});v.useEffect(()=>V,[V]);let re=e=>{Dh.clear(),Eh=!0,te(!0),b&&!ne&&b(e)},ie=ul(e=>{Dh.start(800+g,()=>{Eh=!1}),te(!1),y&&ne&&y(e),F.start(O.transitions.duration.shortest,()=>{N.current=!1})}),ae=e=>{k?.disabled||N.current&&e.type!==`touchstart`||(k&&k.removeAttribute(`title`),I.clear(),L.clear(),d||Eh&&f?I.start(Eh?f:d,()=>{re(e)}):re(e))},oe=e=>{I.clear(),L.start(g,()=>{ie(e)})},[,se]=v.useState(!1),H=e=>{let t=e?.target??k;if(!t||t.disabled||!ll(t)){se(!1);let n=e??new Event(`blur`);!e&&t&&(Object.defineProperty(n,"target",{value:t}),Object.defineProperty(n,"currentTarget",{value:t})),oe(n)}},ce=e=>{if(k||A(e.currentTarget),ll(e.target)){let t=e=>{e.target.disabled&&H(e),e.target.removeEventListener(`blur`,t)};e.target.addEventListener(`blur`,t),se(!0),ae(e)}},le=e=>{N.current=!0;let t=D.props;t.onTouchStart&&t.onTouchStart(e)},ue=e=>{le(e),L.clear(),F.clear(),V(),B.current=document.body.style.WebkitUserSelect,document.body.style.WebkitUserSelect=`none`,R.start(p,()=>{document.body.style.WebkitUserSelect=B.current,ae(e)})},de=e=>{D.props.onTouchEnd&&D.props.onTouchEnd(e),V(),L.start(_,()=>{ie(e)})};v.useEffect(()=>{if(!ne)return;function e(e){e.key===`Escape`&&ie(e)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[ie,ne]);let fe=vs(Iu(D),A,t);!T&&T!==0&&(ne=!1);let pe=v.useRef(),me=e=>{let t=D.props;t.onMouseMove&&t.onMouseMove(e),Oh={x:e.clientX,y:e.clientY},pe.current&&pe.current.update()},he={},U=typeof T==`string`;o?(he.title=!ne&&U&&!c?T:null,he[`aria-describedby`]=ne?z:null):(he[`aria-label`]=U?T:null,he[`aria-labelledby`]=ne&&!U?z:null);let ge={...he,...E,...D.props,className:G(E.className,D.props.className),onTouchStart:le,ref:fe,...m?{onMouseMove:me}:{}},_e={};u||(ge.onTouchStart=ue,ge.onTouchEnd=de),c||(ge.onMouseOver=kh(ae,ge.onMouseOver),ge.onMouseLeave=kh(oe,ge.onMouseLeave),P||(_e.onMouseOver=ae,_e.onMouseLeave=oe)),s||(ge.onFocus=kh(ce,ge.onFocus),ge.onBlur=kh(H,ge.onBlur),P||(_e.onFocus=ce,_e.onBlur=H));let ve={...n,arrow:r,disableInteractive:P,placement:S,touch:N.current},ye=typeof C.popper==`function`?C.popper(ve):C.popper,be=v.useMemo(()=>{let e=[{name:`arrow`,enabled:!!j,options:{element:j,padding:4}}];return ye?.popperOptions?.modifiers&&(e=e.concat(ye.popperOptions.modifiers)),{...ye?.popperOptions,modifiers:e}},[j,ye?.popperOptions]),xe=Sh(ve),Se={slots:w,slotProps:{arrow:C.arrow,popper:ye,tooltip:C.tooltip,transition:C.transition}},[Ce,we]=Jc(`popper`,{elementType:Ch,externalForwardedProps:Se,ownerState:ve,className:xe.popper}),[Te,Ee]=Jc(`transition`,{elementType:mp,externalForwardedProps:Se,ownerState:ve}),[De,Oe]=Jc(`tooltip`,{elementType:wh,className:xe.tooltip,externalForwardedProps:Se,ownerState:ve}),[ke,Ae]=Jc(`arrow`,{elementType:Th,className:xe.arrow,externalForwardedProps:Se,ownerState:ve,ref:M});return(0,W.jsxs)(v.Fragment,{children:[v.cloneElement(D,ge),(0,W.jsx)(Ce,{as:vh,placement:S,anchorEl:m?{getBoundingClientRect:()=>({top:Oh.y,left:Oh.x,right:Oh.x,bottom:Oh.y,width:0,height:0})}:k,popperRef:pe,open:k?ne:!1,id:z,transition:!0,..._e,...we,popperOptions:be,children:({TransitionProps:e})=>(0,W.jsx)(Te,{timeout:O.transitions.duration.shorter,...e,...Ee,children:(0,W.jsxs)(De,{...Oe,children:[T,r?(0,W.jsx)(ke,{...Ae}):null]})})})]})}),jh=sl((0,W.jsx)(`path`,{d:`M4 13h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1m0 8h6c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1m10 0h6c.55 0 1-.45 1-1v-8c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1M13 4v4c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1`}),`DashboardRounded`),Mh=sl((0,W.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2`}),`ChatBubbleRounded`),Nh=sl((0,W.jsx)(`path`,{d:`M14.59 2.59c-.38-.38-.89-.59-1.42-.59H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8.83c0-.53-.21-1.04-.59-1.41zM15 18H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m0-4H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m-2-6V3.5L18.5 9H14c-.55 0-1-.45-1-1`}),`DescriptionRounded`),Ph=sl((0,W.jsx)(`path`,{d:`M3 7c.55 0 1 .45 1 1v13h13c.55 0 1 .45 1 1s-.45 1-1 1H4c-1.1 0-2-.9-2-2V8c0-.55.45-1 1-1m12.59-5.41c-.38-.38-.89-.59-1.42-.59H8c-1.1 0-1.99.9-1.99 2L6 17c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V7.83c0-.53-.21-1.04-.59-1.41zM15.5 15h-4c-.55 0-1-.45-1-1s.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1m0-6h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V9h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V6c0-.55.45-1 1-1s1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1`}),`DifferenceRounded`),Fh=sl((0,W.jsx)(`path`,{d:`M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2m0 14H4V8h16zm-8-2c0-.55.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1M6.79 9.71c.39-.39 1.02-.39 1.41 0l2.59 2.59c.39.39.39 1.02 0 1.41L8.2 16.3c-.39.39-1.02.39-1.41 0a.996.996 0 0 1 0-1.41L8.67 13l-1.88-1.88a.996.996 0 0 1 0-1.41`}),`TerminalRounded`),Ih=sl((0,W.jsx)(`path`,{d:`M13.26 3C8.17 2.86 4 6.95 4 12H2.21c-.45 0-.67.54-.35.85l2.79 2.8c.2.2.51.2.71 0l2.79-2.8c.31-.31.09-.85-.36-.85H6c0-3.9 3.18-7.05 7.1-7 3.72.05 6.85 3.18 6.9 6.9.05 3.91-3.1 7.1-7 7.1-1.61 0-3.1-.55-4.28-1.48-.4-.31-.96-.28-1.32.08-.42.42-.39 1.13.08 1.49C9 20.29 10.91 21 13 21c5.05 0 9.14-4.17 9-9.26-.13-4.69-4.05-8.61-8.74-8.74m-.51 5c-.41 0-.75.34-.75.75v3.68c0 .35.19.68.49.86l3.12 1.85c.36.21.82.09 1.03-.26.21-.36.09-.82-.26-1.03l-2.88-1.71v-3.4c0-.4-.34-.74-.75-.74`}),`HistoryRounded`),Lh=sl((0,W.jsx)(`path`,{d:`M9.19 6.35c-2.04 2.29-3.44 5.58-3.57 5.89l-2.26-.97c-.65-.28-.81-1.13-.31-1.63l3.01-3.01c.47-.47 1.15-.68 1.81-.55zm1.49 10.16c.3.3.74.38 1.12.2 1.16-.54 3.65-1.81 5.26-3.42 4.59-4.59 4.63-8.33 4.36-9.93-.07-.4-.39-.72-.79-.79-1.6-.27-5.34-.23-9.93 4.36-1.61 1.61-2.87 4.1-3.42 5.26-.18.38-.09.83.2 1.12zm6.97-1.7c-2.29 2.04-5.58 3.44-5.89 3.57l.97 2.26c.28.65 1.13.81 1.63.31l3.01-3.01c.47-.47.68-1.15.55-1.81zm-8.71 2.6c.2 1.06-.15 2.04-.82 2.71-.77.77-3.16 1.34-4.71 1.64-.69.13-1.3-.48-1.17-1.17.3-1.55.86-3.94 1.64-4.71.67-.67 1.65-1.02 2.71-.82 1.17.22 2.13 1.18 2.35 2.35M13 9c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2`}),`RocketLaunchRounded`),Rh=sl((0,W.jsx)(`path`,{d:`M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1m0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1`}),`MenuRounded`),zh=sl((0,W.jsx)(`path`,{d:`M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5M2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1m18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1M11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1m0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1M5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0z`}),`LightModeRounded`),Bh=sl((0,W.jsx)(`path`,{d:`M11.01 3.05C6.51 3.54 3 7.36 3 12c0 4.97 4.03 9 9 9 4.63 0 8.45-3.5 8.95-8 .09-.79-.78-1.42-1.54-.95-.84.54-1.84.85-2.91.85-2.98 0-5.4-2.42-5.4-5.4 0-1.06.31-2.06.84-2.89.45-.67-.04-1.63-.93-1.56`}),`DarkModeRounded`),Vh=sl((0,W.jsx)(`path`,{d:`M20 6h-8l-1.41-1.41C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m-1 12H5c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1`}),`FolderOpenRounded`);function Hh(e){return K(`MuiTab`,e)}var Uh=Wr(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`icon`]),Wh=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e;return va({root:[`root`,a&&o&&`labelIcon`,`textColor${Y(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`icon`]},Hh,t)},Gh=J(eu,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${Y(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${Uh.icon}`]:t.icon}]}})(_s(({theme:e})=>({...e.typography.button,maxWidth:360,minWidth:90,position:`relative`,minHeight:48,flexShrink:0,padding:`12px 16px`,overflow:`hidden`,whiteSpace:`normal`,textAlign:`center`,lineHeight:1.25,variants:[{props:({ownerState:e})=>e.label&&(e.iconPosition===`top`||e.iconPosition===`bottom`),style:{flexDirection:`column`}},{props:({ownerState:e})=>e.label&&e.iconPosition!==`top`&&e.iconPosition!==`bottom`,style:{flexDirection:`row`}},{props:({ownerState:e})=>e.icon&&e.label,style:{minHeight:72,paddingTop:9,paddingBottom:9}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`top`,style:{[`& > .${Uh.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${Uh.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${Uh.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${Uh.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${Uh.selected}`]:{opacity:1},[`&.${Uh.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:({ownerState:e})=>e.fullWidth,style:{flexShrink:1,flexGrow:1,flexBasis:0,maxWidth:`none`}},{props:({ownerState:e})=>e.wrapped,style:{fontSize:e.typography.pxToRem(12)}}]}))),Kh=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTab`}),{className:r,disabled:i=!1,disableFocusRipple:a=!1,fullWidth:o,icon:s,iconPosition:c=`top`,indicator:l,label:u,onChange:d,onClick:f,onFocus:p,selected:m,selectionFollowsFocus:h,textColor:g=`inherit`,value:_,wrapped:y=!1,...b}=n,x=Of(),S=Nf({id:_,ref:t,disabled:i,selected:m}),C=x.getItemMap().size===0&&m?0:S.tabIndex,w={...n,disabled:i,disableFocusRipple:a,selected:m,icon:!!s,iconPosition:c,label:!!u,fullWidth:o,textColor:g,wrapped:y},T=Wh(w),E=s&&u&&v.isValidElement(s)?v.cloneElement(s,{className:G(T.icon,s.props.className)}):s;return(0,W.jsxs)(Gh,{internalNativeButton:!0,focusRipple:!a,className:G(T.root,r),ref:S.ref,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,_),f&&f(e)},onFocus:e=>{h&&!m&&d&&d(e,_),p&&p(e)},tabIndex:C,ownerState:w,...b,children:[c===`top`||c===`start`?(0,W.jsxs)(v.Fragment,{children:[E,u]}):(0,W.jsxs)(v.Fragment,{children:[u,E]}),l]})});function qh(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function Jh(e,t,n,r={},i=()=>{}){let{ease:a=qh,duration:o=300}=r,s=null,c=t[e],l=!1,u=()=>{l=!0},d=r=>{if(l){i(Error(`Animation cancelled`));return}s===null&&(s=r);let u=Math.min(1,(r-s)/o);if(t[e]=a(u)*(n-c)+c,u>=1){requestAnimationFrame(()=>{i(null)});return}requestAnimationFrame(d)};return c===n?(i(Error(`Element already at target position`)),u):(requestAnimationFrame(d),u)}var Yh={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`,pointerEvents:`none`};function Xh(e){let{onChange:t,...n}=e,r=v.useRef(),i=v.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return ys(()=>{let e=Sd(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=wd(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),v.useEffect(()=>{a(),t(r.current)},[t]),(0,W.jsx)(`div`,{style:Yh,...n,ref:i})}var Zh=sl((0,W.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Qh=sl((0,W.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function $h(e){return K(`MuiTabScrollButton`,e)}var eg=Wr(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),tg=e=>{let{classes:t,orientation:n,disabled:r}=e;return va({root:[`root`,n,r&&`disabled`]},$h,t)},ng=J(eu,{name:`MuiTabScrollButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.orientation&&t[n.orientation]]}})({width:40,flexShrink:0,opacity:.8,[`&.${eg.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),rg=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,{nativeButton:u,...d}=l,f=Ii(),p={isRtl:f,...n},m=tg(p),h=i.StartScrollButtonIcon??Zh,g=i.EndScrollButtonIcon??Qh,_=lh({elementType:h,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p}),v=lh({elementType:g,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p});return(0,W.jsx)(ng,{component:`div`,className:G(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,W.jsx)(h,{..._}):(0,W.jsx)(g,{...v})})});function ig(e){return K(`MuiTabs`,e)}var ag=Wr(`MuiTabs`,[`root`,`vertical`,`list`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),og=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return va({root:[`root`,t&&`vertical`],scroller:[`scroller`,n&&`fixed`,r&&`hideScrollbar`,i&&`scrollableX`,a&&`scrollableY`],list:[`list`,t&&`vertical`,o&&`centered`],indicator:[`indicator`],scrollButtons:[`scrollButtons`,s&&`scrollButtonsHideMobile`],scrollableX:[i&&`scrollableX`],hideScrollbar:[r&&`hideScrollbar`]},ig,c)},sg=J(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${ag.scrollButtons}`]:t.scrollButtons},{[`& .${ag.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(_s(({theme:e})=>({overflow:`hidden`,minHeight:48,WebkitOverflowScrolling:`touch`,display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.scrollButtonsHideMobile,style:{[`& .${ag.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),cg=J(`div`,{name:`MuiTabs`,slot:`Scroller`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.scroller,n.fixed&&t.fixed,n.hideScrollbar&&t.hideScrollbar,n.scrollableX&&t.scrollableX,n.scrollableY&&t.scrollableY]}})({position:`relative`,display:`inline-block`,flex:`1 1 auto`,whiteSpace:`nowrap`,variants:[{props:({ownerState:e})=>e.fixed,style:{overflowX:`hidden`,width:`100%`}},{props:({ownerState:e})=>e.hideScrollbar,style:{scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}},{props:({ownerState:e})=>e.scrollableX,style:{overflowX:`auto`,overflowY:`hidden`}},{props:({ownerState:e})=>e.scrollableY,style:{overflowY:`auto`,overflowX:`hidden`}}]}),lg=J(`div`,{name:`MuiTabs`,slot:`List`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.list,n.centered&&t.centered]}})({display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.centered,style:{justifyContent:`center`}}]}),ug=J(`span`,{name:`MuiTabs`,slot:`Indicator`})(_s(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,...Ws(e),variants:[{props:{indicatorColor:`primary`},style:{backgroundColor:(e.vars||e).palette.primary.main}},{props:{indicatorColor:`secondary`},style:{backgroundColor:(e.vars||e).palette.secondary.main}},{props:({ownerState:e})=>e.vertical,style:{height:`100%`,width:2,right:0}}]}))),dg=J(Xh)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),fg={},pg=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTabs`}),r=Uo(),i=Ii(),a=Il(r.motion.reducedMotion,!1),{"aria-label":o,"aria-labelledby":s,action:c,centered:l=!1,children:u,className:d,component:f=`div`,allowScrollButtonsMobile:p=!1,indicatorColor:m=`primary`,onChange:h,orientation:g=`horizontal`,scrollButtons:_=`auto`,selectionFollowsFocus:y,slots:b={},slotProps:x={},textColor:S=`primary`,value:C,variant:w=`standard`,visibleScrollbar:T=!1,...E}=n,D=w===`scrollable`,O=g===`vertical`,k=O?`scrollTop`:`scrollLeft`,A=O?`top`:`left`,j=O?`bottom`:`right`,M=O?`clientHeight`:`clientWidth`,N=O?`height`:`width`,P={...n,component:f,allowScrollButtonsMobile:p,indicatorColor:m,orientation:g,vertical:O,scrollButtons:_,textColor:S,variant:w,visibleScrollbar:T,fixed:!D,hideScrollbar:D&&!T,scrollableX:D&&!O,scrollableY:D&&O,centered:l&&!D,scrollButtonsHideMobile:!p},F=og(P),I=lh({elementType:b.startScrollButtonIcon,externalSlotProps:x.startScrollButtonIcon,ownerState:P}),L=lh({elementType:b.endScrollButtonIcon,externalSlotProps:x.endScrollButtonIcon,ownerState:P}),[R,ee]=v.useState(!1),[te,ne]=v.useState(fg),[z,B]=v.useState(!1),[V,re]=v.useState(!1),[ie,ae]=v.useState(!1),oe=C===!1?null:C,[se,H]=v.useState(!1),[ce,le]=v.useState({overflow:`hidden`,scrollbarWidth:0}),ue=new Map,de=v.useRef(null),fe=v.useRef(null),pe={slots:b,slotProps:x},me=()=>{let e=de.current,t;if(e){let n=e.getBoundingClientRect();t={clientWidth:e.clientWidth,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}let n;if(e&&C!==!1){let e=fe.current.children;if(e.length>0){let t=e[ue.get(C)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},he=ul(()=>{let{tabsMeta:e,tabMeta:t}=me(),n=0,r;O?(r=`top`,t&&e&&(n=t.top-e.top+e.scrollTop)):(r=i?`right`:`left`,t&&e&&(n=(i?-1:1)*(t[r]-e[r]+e.scrollLeft)));let a={[r]:n,[N]:t?t[N]:0};if(typeof te[r]!=`number`||typeof te[N]!=`number`)ne(a);else{let e=Math.abs(te[r]-a[r]),t=Math.abs(te[N]-a[N]);(e>=1||t>=1)&&ne(a)}}),U=(e,{animation:t=!0}={})=>{t&&!a.shouldReduceMotion?Jh(k,de.current,e,{duration:r.transitions.duration.standard}):de.current[k]=e},ge=e=>{let t=de.current[k];t+=O?e:e*(i?-1:1),U(t)},_e=()=>{let e=de.current[M],t=0,n=Array.from(fe.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[M]>e){r===0&&(t=e);break}t+=i[M]}return t},ve=()=>{ge(-1*_e())},ye=()=>{ge(_e())},[be,{onChange:xe,...Se}]=Jc(`scrollbar`,{className:G(F.scrollableX,F.hideScrollbar),elementType:dg,shouldForwardComponentProp:!0,externalForwardedProps:pe,ownerState:P}),Ce=v.useCallback(e=>{xe?.(e),le({overflow:null,scrollbarWidth:e})},[xe]),[we,Te]=Jc(`scrollButtons`,{className:F.scrollButtons,elementType:rg,externalForwardedProps:pe,ownerState:P,additionalProps:{orientation:g,slots:{StartScrollButtonIcon:b.startScrollButtonIcon,EndScrollButtonIcon:b.endScrollButtonIcon},slotProps:{startScrollButtonIcon:I,endScrollButtonIcon:L}}}),Ee=()=>{let e={};e.scrollbarSizeListener=D?(0,W.jsx)(be,{...Se,onChange:Ce}):null;let t=D&&(_===`auto`&&(z||V)||_===!0);return e.scrollButtonStart=t?(0,W.jsx)(we,{direction:i?`right`:`left`,onClick:ve,disabled:!z,...Te}):null,e.scrollButtonEnd=t?(0,W.jsx)(we,{direction:i?`left`:`right`,onClick:ye,disabled:!V,...Te}):null,e},De=ul(e=>{let{tabsMeta:t,tabMeta:n}=me();if(!(!n||!t)){if(n[A]<t[A]){let r=t[k]+(n[A]-t[A]);U(r,{animation:e})}else if(n[j]>t[j]){let r=t[k]+(n[j]-t[j]);U(r,{animation:e})}}}),Oe=ul(()=>{D&&_!==!1&&ae(!ie)});v.useEffect(()=>{let e=Sd(()=>{de.current&&he()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),Oe()},r=wd(de.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(fe.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(fe.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[he,Oe]),v.useEffect(()=>{let e=Array.from(fe.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&D&&_!==!1){let n=e[0],r=e[t-1],i={root:de.current,threshold:.99},a=new IntersectionObserver(e=>{B(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{re(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[D,_,ie,u?.length]),v.useEffect(()=>{ee(!0)},[]),v.useEffect(()=>{he()}),v.useEffect(()=>{De(fg!==te)},[De,te]),v.useImperativeHandle(c,()=>({updateIndicator:he,updateScrollButtons:Oe}),[he,Oe]);let[ke,Ae]=Jc(`indicator`,{className:F.indicator,elementType:ug,externalForwardedProps:pe,ownerState:P,additionalProps:{style:te}}),je=(0,W.jsx)(ke,{...Ae}),Me=Mf({activeItemId:se?void 0:oe,orientation:g,isRtl:i}),Ne=Me.getContainerProps(),Pe=v.Children.toArray(u).filter(v.isValidElement).map((e,t)=>{let n=e.props.value===void 0?t:e.props.value;return ue.set(n,t),{child:e,index:t,childValue:n}}).map(({child:e,childValue:t})=>{let n=t===C;return v.cloneElement(e,{fullWidth:w===`fullWidth`,indicator:n&&!R&&je,selected:n,selectionFollowsFocus:y,onChange:h,textColor:S,value:t})}),Fe=Ee(),[Ie,Le]=Jc(`root`,{ref:t,className:G(F.root,d),elementType:sg,externalForwardedProps:{...pe,...E,component:f},ownerState:P}),[Re,ze]=Jc(`scroller`,{ref:de,className:F.scroller,elementType:cg,externalForwardedProps:pe,ownerState:P,additionalProps:{style:{overflow:ce.overflow,[O?`margin${i?`Left`:`Right`}`:`marginBottom`]:T?void 0:-ce.scrollbarWidth}}}),Be=vs(Ne.ref,fe),Ve=e=>{let t=fe.current;Ss(bs(t))?.getAttribute(`role`)===`tab`&&Ne.onKeyDown(e)},[He,Ue]=Jc(`list`,{ref:Be,className:F.list,elementType:lg,externalForwardedProps:pe,ownerState:P,getSlotProps:e=>({...e,onBlur:t=>{Ru(t.currentTarget,t.relatedTarget)||H(!1),e.onBlur?.(t)},onKeyDown:t=>{Ve(t),e.onKeyDown?.(t)},onFocus:t=>{H(!0),Ne.onFocus(t),e.onFocus?.(t)}})});return(0,W.jsxs)(Ie,{...Le,children:[Fe.scrollButtonStart,Fe.scrollbarSizeListener,(0,W.jsxs)(Re,{...ze,children:[(0,W.jsx)(He,{"aria-label":o,"aria-labelledby":s,"aria-orientation":g===`vertical`?`vertical`:null,role:`tablist`,...Ue,children:(0,W.jsx)(Df.Provider,{value:Me,children:Pe})}),R&&je]}),Fe.scrollButtonEnd]})}),mg=null,hg=null;async function gg(e){if(!e.ok)return!1;try{let t=await e.json();return typeof t.csrfToken!=`string`||!/^[A-Za-z0-9_-]{43}$/.test(t.csrfToken)?!1:(mg=t.csrfToken,!0)}catch{return!1}}function _g(){return mg}async function vg(){let e=new URLSearchParams(window.location.hash.slice(1)).get(`bootstrap`);if(!e)try{return await gg(await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`}}))?`existing-session`:`failed`}catch{return`failed`}window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);try{return await gg(await fetch(`/api/v1/bootstrap`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({capability:e})}))?`authenticated`:`failed`}catch{return`failed`}}function yg(){return hg??=vg(),hg}var bg=class extends Error{status;constructor(e){super(`webui-request-${e}`),this.status=e}};async function xg(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new bg(t.status);return await t.json()}function Sg(e){return Mg(`/api/v1/session-catalog`,e)}function Cg(e){return Mg(`/api/v1/session-live-state`,e)}function wg(e){return Mg(`/api/v1/session-creation-options`,e)}function Tg(e){return Mg(`/api/v1/provider-auth`,e)}function Eg(e,t){return Mg(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function Dg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function Og(e,t){return Dg({action:`provider-auth.start`,providerRef:e},t)}function kg(e,t,n,r){return Dg({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function Ag(e,t){return Dg({action:`provider-auth.cancel`,jobRef:e},t)}async function jg(e){let t=_g();if(!t)throw new bg(403);let n=await fetch(`/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 bg(n.status);return await n.json()}async function Mg(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(!n.ok)throw new bg(n.status);return await n.json()}function Ng(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function Pg(e,t){return Mg(Ng(e,`/api/v1/snapshot`),t)}function Fg(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),Mg(Ng(e,`/api/v1/transcript?${i}`),r)}function Ig(e,t,n){return Mg(Ng(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function Lg(e,t,n){return Mg(Ng(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function Rg(e,t,n,r){return Mg(Ng(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function zg(e,t,n,r){return Mg(Ng(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function Bg(e,t,n,r){return Mg(Ng(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function Vg(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return Mg(Ng(e,`/api/v1/source-reverts/${encodeURIComponent(t)}${i}`),r)}function Hg(e,t){return Mg(Ng(e,`/api/v1/commit-summary`),t)}function Ug(e,t,n){return Mg(Ng(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function Wg(e,t){return Mg(Ng(e,`/api/v1/connections`),t)}async function Gg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function Kg(e,t){return Mg(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function qg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function Jg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function Yg(e,t){return Mg(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function Xg(e,t,n){return Mg(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function Zg(e,t,n){return Mg(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function Qg(e,t,n){return Mg(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function $g(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return Mg(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function e_(e){return Mg(`/api/v1/commit-summary`,e)}function t_(e){return Mg(`/api/v1/tasks`,e)}function n_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function r_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function i_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function a_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function o_(e){return Mg(`/api/v1/monitoring/release`,e)}function s_(e,t){return Mg(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function c_(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),Mg(`/api/v1/transcript?${r}`,n)}function l_(e){return Mg(`/api/v1/chat/queue`,e)}function u_(e){return Mg(`/api/v1/session-options/models`,e)}function d_(e,t){return Mg(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function f_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function p_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function m_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function h_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function g_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function __(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function v_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function y_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function b_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function x_(e,t,n){let r=_g();if(!r)throw new bg(403);let i=await fetch(`/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 bg(i.status);return await i.json()}function S_(e,t){return Mg(e?Ng(e,`/api/v1/documents`):`/api/v1/documents`,t)}function C_(e,t,n){let r=`/api/v1/documents/${encodeURIComponent(t)}`;return Mg(e?Ng(e,r):r,n)}async function w_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function T_(e){return Array.isArray(e)?`[${e.map(T_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${T_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function E_(e){let t=new TextEncoder().encode(typeof e==`string`?e:T_(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 D_(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 E_({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 E_({action:l.action,identity:l.identity,expectedRevisions:c,payload:s}),l}async function O_(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 k_(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 A_(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 E_({action:t,identity:o.identity,expectedRevisions:a,payload:n}),o}async function j_(e,t){let n=[];return{queueItemRef:e,text:t,attachmentRefs:n,contentDigest:await E_({attachmentRefs:n,text:t})}}async function M_(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 E_({action:t,identity:s.identity,expectedRevisions:a,payload:o}),s}async function N_(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 E_({action:t,identity:o.identity,expectedRevisions:i,payload:a}),o}async function P_(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 E_({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 E_({action:c.action,identity:c.identity,expectedRevisions:s,payload:o}),c}function F_(e){return Array.isArray(e)?`[${e.map(F_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${F_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function I_(e){let t=new TextEncoder().encode(F_(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 L_(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 I_({action:l.action,identity:o,expectedRevisions:s,payload:c}),l}function R_(e){return Array.isArray(e)?`[${e.map(R_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${R_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function z_(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(R_(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function B_(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))||R_(n)!==R_(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 z_({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}function V_(e){return Array.isArray(e)?`[${e.map(V_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${V_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function H_(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(V_(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function U_(e,t){if(t.state!==`ready`||!t.target)throw Error(`source-revert-preview-unavailable`);let n=new Date,r=t.target;if(Date.parse(r.expiresAt)<=n.getTime())throw Error(`source-revert-preview-expired`);let i={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},a={runtimeRevision:e.revision.runtimeRevision,taskRevision:r.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:r.workspaceRevision,indexRevision:r.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:r.workspacePreimage,indexPreimage:r.indexPreimage,patchPreimage:r.patchPreimage},o={fileRef:r.fileRef,hunkRefs:[...r.hunkRefs],previewRef:r.previewRef,confirmedPreviewDigest:r.confirmedPreviewDigest,contentDigest:r.contentDigest},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-revert.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.expiresAt,capabilityScope:`reviewActions`,action:`source.revert`,actionDigest:``,identity:i,expectedRevisions:a,payload:o};return s.actionDigest=await H_({action:s.action,identity:i,expectedRevisions:a,payload:o}),s}function W_(e){return Array.isArray(e)?`[${e.map(W_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${W_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function G_(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(W_(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function K_(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 G_({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}var q_=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(`.`)),J_=new Set([`false`,`nil`,`null`,`None`,`true`,`undefined`]),Y_=new Set([`py`,`rb`,`sh`,`bash`,`zsh`,`yaml`,`yml`,`toml`]);function X_(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<0?``:t.slice(n+1).toLowerCase()}function Z_(e){return/[A-Za-z_$]/.test(e)}function Q_(e){return/[A-Za-z0-9_$-]/.test(e)}function $_(e){return e>=`0`&&e<=`9`}function ev(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 tv(e,t){let n=[],r=X_(t),i=0;for(;i<e.length;){if(e.startsWith(`//`,i)||e.startsWith(`/*`,i)||e[i]===`#`&&Y_.has(r)){ev(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);ev(n,e.slice(a).match(/^\s*:/)&&r===`"`?`property`:`string`,o),i=a;continue}if($_(t)||t===`.`&&$_(e[i+1]??``)){let t=i+1;for(;t<e.length&&/[0-9A-Fa-f_xXob.+-]/.test(e[t]??``);)t+=1;ev(n,`number`,e.slice(i,t)),i=t;continue}if(Z_(t)){let t=i+1;for(;t<e.length&&Q_(e[t]??``);)t+=1;let r=e.slice(i,t);ev(n,q_.has(r)?`keyword`:J_.has(r)?`literal`:`plain`,r),i=t;continue}ev(n,`plain`,t),i+=1}return n}var nv=[{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 rv(e){return e===`vi`?nv:[{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 iv={"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 av(e,t=`vi`){return t===`vi`?iv[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 ov(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 sv(e,t=`vi`){let n=e.page.total;return 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 cv(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 lv(e,t){return t&&e.some(e=>e.fileRef===t)?t:e[0]?.fileRef??null}var uv={active:`Đang hoạt động`,"pause-requested":`Đang yêu cầu tạm dừng`,paused:`Đã tạm dừng`,terminal:`Đã kết thúc`,idle:`Đang chờ`,running:`Đang chạy`,stopping:`Đang dừng`,settled:`Đã ổn định`,unknown:`Chưa xác định`,pending:`Chưa xong`,completed:`Hoàn thành`,blocked:`Bị chặn`,partial:`Một phần`,failed:`Thất bại`,satisfied:`Đã đạt`,unavailable:`Không có dữ liệu`,connected:`Đã kết nối`,disconnected:`Mất kết nối`,reconnecting:`Đang kết nối lại`,"resync-required":`Cần đồng bộ lại`,none:`Không có`,waiting:`Đang chờ duyệt`,current:`Mới nhất`,stale:`Đã cũ`,"not-run":`Chưa chạy`,"in-progress":`Đang làm`,done:`Đã xong`,skipped:`Bỏ qua`,resume:`Tiếp tục`,retry:`Thử lại`,observed:`Đã ghi nhận`,requested:`Đã yêu cầu`,"possible-interruption":`Có thể bị gián đoạn`,complete:`Đầy đủ`,"aggregate-only":`Chỉ có dữ liệu tổng hợp`,off:`Tắt`,minimal:`Tối thiểu`,low:`Thấp`,medium:`Trung bình`,high:`Cao`,xhigh:`Rất cao`,max:`Tối đa`,orphaned:`Mất owner`,cancelled:`Đã hủy`,succeeded:`Thành công`,"stale-result":`Kết quả đến muộn`,accepted:`Đã nhận`,rejected:`Không nhận`,"not-recorded":`Chưa có kết quả`,parent:`Task cha`,helper:`Helper`,"read-only":`Chỉ đọc`,"workspace-write":`Ghi trong project`,"trusted-full-access":`Toàn quyền`,"single-writer":`Một writer`,retriever:`Truy xuất`,scout:`Khảo sát`,planner:`Lập kế hoạch`,worker:`Thực thi`,reviewer:`Rà soát`,oracle:`Đối chứng`,researcher:`Nghiên cứu`,ready:`Sẵn sàng`,missing:`Chưa có bằng chứng`,interrupted:`Bị gián đoạn`,stopped:`Đã dừng`,aborted:`Đã hủy do lỗi`,incomplete:`Chưa có kết luận`,passed:`Đạt`,"not-applicable":`Không áp dụng`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"pdf-text-unavailable":`PDF này không có text bóc được; nhiều khả năng là bản scan, cần OCR trước`,"pdf-extraction-failed":`Không chuyển được PDF này sang text`,"docx-unreadable":`File .docx này hỏng, bị mã hóa, hoặc không phải file Word thật`,"document-text-empty":`Tài liệu không có chữ nào để đọc`,"document-size-limit":`Tài liệu vượt giới hạn dung lượng`,"text-size-limit":`File text vượt giới hạn dung lượng`,"text-content-invalid":`File có đuôi text nhưng nội dung không phải text`,"image-mime-mismatch":`Nội dung ảnh không khớp với đuôi file`,"model-image-input-unavailable":`Model hiện tại không nhận ảnh`,"attachment-capacity-limit":`Đã chạm giới hạn số file hoặc dung lượng đính kèm`,"no-readable-root":`Chưa có thư mục nào đọc được`,"document-roots-unavailable":`Không xác định được thư mục tài liệu`,"document-not-listed":`Tài liệu không còn trong danh sách; hãy tải lại`,"document-unavailable":`Không mở được tài liệu này`,"document-protected":`Tài liệu nằm trong protectedPaths nên không được đọc`,"document-changed":`File đã thay đổi sau khi liệt kê; chưa đọc gì cả`,"document-unreadable":`Không đọc được nội dung tài liệu`,"document-needs-ocr":`Tài liệu là bản scan, cần OCR trước khi đọc được chữ`,"document-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"session-command-effect-unknown":`Pi đã nhận yêu cầu nhưng đang đồng bộ trạng thái; không gửi lại để tránh chạy trùng`},dv={active:`Active`,"pause-requested":`Pause requested`,paused:`Paused`,terminal:`Finished`,idle:`Idle`,running:`Running`,stopping:`Stopping`,settled:`Settled`,unknown:`Unknown`,pending:`Pending`,completed:`Completed`,blocked:`Blocked`,partial:`Partial`,failed:`Failed`,satisfied:`Satisfied`,unavailable:`Unavailable`,connected:`Connected`,disconnected:`Disconnected`,reconnecting:`Reconnecting`,"resync-required":`Resync required`,none:`None`,waiting:`Awaiting approval`,current:`Current`,stale:`Stale`,"not-run":`Not run`,"in-progress":`In progress`,done:`Done`,skipped:`Skipped`,resume:`Resume`,retry:`Retry`,observed:`Observed`,requested:`Requested`,"possible-interruption":`Possible interruption`,complete:`Complete`,"aggregate-only":`Aggregate only`,off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,orphaned:`Owner missing`,cancelled:`Cancelled`,succeeded:`Succeeded`,"stale-result":`Stale result`,accepted:`Accepted`,rejected:`Rejected`,"not-recorded":`Not recorded`,parent:`Parent task`,helper:`Helper`,"read-only":`Read only`,"workspace-write":`Workspace write`,"trusted-full-access":`Full access`,"single-writer":`Single writer`,retriever:`Retriever`,scout:`Scout`,planner:`Planner`,worker:`Worker`,reviewer:`Reviewer`,oracle:`Oracle`,researcher:`Researcher`,ready:`Ready`,missing:`Evidence missing`,interrupted:`Interrupted`,stopped:`Stopped`,aborted:`Aborted`,incomplete:`Incomplete`,passed:`Passed`,"not-applicable":`Not applicable`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"pdf-text-unavailable":`This PDF holds no extractable text; it is probably scanned and needs OCR first`,"pdf-extraction-failed":`The PDF could not be converted to text`,"docx-unreadable":`This .docx is corrupt, encrypted, or not really a Word document`,"document-text-empty":`The document contains no readable text`,"document-size-limit":`The document is over the size limit`,"text-size-limit":`The text file is over the size limit`,"text-content-invalid":`The file has a text extension but its bytes are not text`,"image-mime-mismatch":`The image content does not match its file extension`,"model-image-input-unavailable":`The current model does not accept images`,"attachment-capacity-limit":`The attachment count or size limit was reached`,"no-readable-root":`No readable directory is available`,"document-roots-unavailable":`The document directories could not be resolved`,"document-not-listed":`The document is no longer listed; reload the list`,"document-unavailable":`This document could not be opened`,"document-protected":`The document is under protectedPaths and is not readable`,"document-changed":`The file changed after it was listed; nothing was read`,"document-unreadable":`The document content could not be read`,"document-needs-ocr":`The document is scanned and needs OCR before it holds text`,"document-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"session-command-effect-unknown":`Pi received the request and is resyncing; do not resend it, to avoid a duplicate run`};function Q(e,t=`vi`){return e?(t===`vi`?uv:dv)[e]??e.replaceAll(`-`,` `):t===`vi`?`Chưa có`:`Not available`}function fv(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 pv(e){return e?e.length>22?`${e.slice(0,10)}…${e.slice(-7)}`:e:`—`}function mv(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 hv(e,t=`vi`){return e.session.thinking.state===`known`&&e.session.thinking.value?Q(e.session.thinking.value,t):t===`vi`?`Chưa xác định`:`Unknown`}function gv(e,t=`vi`){let n=e.session.permissionProfile;return n.state===`known`&&n.value?Q(n.value,t):t===`vi`?`Quyền chưa xác định`:`Unknown permission`}function _v(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 vv(e,t=`vi`){let n=e.task;return n?{completed:n.progress.completed,total:n.progress.total,percent:Math.max(0,Math.min(100,n.progress.percent)),text:t===`vi`?`${n.progress.completed}/${n.progress.total} tiêu chí`:`${n.progress.completed}/${n.progress.total} criteria`}:{completed:0,total:0,percent:0,text:t===`vi`?`Chưa có task đang chạy`:`No active task`}}var yv=(0,v.createContext)(null);function bv({value:e,children:t}){return(0,W.jsx)(yv.Provider,{value:e,children:t})}function xv(){let e=(0,v.useContext)(yv);if(!e)throw Error(`Piagent UI preferences are missing`);return e}function $(e,t,n){return e===`vi`?t:n}function Sv({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,W.jsxs)(`section`,{className:`commit-summary-panel`,"aria-labelledby":`commit-summary-title`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Commit summary`}),(0,W.jsx)(`h3`,{id:`commit-summary-title`,children:$(a,`Tóm tắt phần đã stage`,`Staged changes summary`)}),(0,W.jsx)(`span`,{children:$(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,W.jsxs)(`div`,{className:`commit-summary-output`,children:[(0,W.jsx)(`strong`,{children:l.title}),l.bodyLines.map((e,t)=>(0,W.jsx)(`code`,{children:e},`${l.summaryRef}.${t}`)),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`button`,{type:`button`,onClick:s,children:`Copy`}),(0,W.jsx)(`button`,{type:`button`,disabled:!i||t,onClick:c,children:$(a,`Nhờ Pi viết lại · tốn model token`,`Ask Pi to rewrite · uses model tokens`)})]})]}):(0,W.jsx)(`button`,{type:`button`,disabled:!r||t,onClick:o,children:t?$(a,`Đang tạo…`,`Generating…`):$(a,`Tạo summary · 0 token`,`Generate summary · 0 tokens`)}),n&&(0,W.jsx)(`p`,{className:`commit-summary-status`,role:`status`,children:n})]})}function Cv({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,W.jsxs)(sf,{component:`button`,className:`file-row`,selected:t,"data-selected":t,onClick:n,type:`button`,"aria-label":`${e.status} ${e.path} ${ov(e,r)}`,"aria-pressed":t,children:[(0,W.jsx)(`span`,{className:`file-status status-${e.status}`,children:e.status}),(0,W.jsxs)(`span`,{className:`file-name`,children:[(0,W.jsx)(`strong`,{children:a}),e.oldPath&&(0,W.jsxs)(`small`,{children:[$(r,`từ`,`from`),` `,e.oldPath]})]}),(0,W.jsx)(`span`,{className:`file-provenance`,children:av(e,r)}),(0,W.jsx)(`span`,{className:`file-evidence`,children:cv(e,r)}),(0,W.jsx)(`span`,{className:`file-stats`,children:ov(e,r)})]})}function wv({text:e,path:t}){return(0,W.jsx)(W.Fragment,{children:tv(e,t).map((e,t)=>(0,W.jsx)(`span`,{className:`syntax-${e.kind}`,children:e.text},`${t}.${e.kind}`))})}function Tv({line:e,side:t,path:n}){let r=e.oldLineNumber??``,i=e.newLineNumber??``;if(t===`inline`)return(0,W.jsxs)(`div`,{className:`diff-line diff-${e.kind}`,children:[(0,W.jsx)(`span`,{children:r}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(`b`,{children:e.marker}),(0,W.jsx)(`code`,{children:(0,W.jsx)(wv,{text:e.text,path:n})})]});let a=e.kind===`added`?``:e.text,o=e.kind===`deleted`?``:e.text;return(0,W.jsxs)(`div`,{className:`split-line diff-${e.kind}`,children:[(0,W.jsx)(`span`,{children:r}),(0,W.jsx)(`code`,{children:(0,W.jsx)(wv,{text:a,path:n})}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(`code`,{children:(0,W.jsx)(wv,{text:o,path:n})})]})}function Ev({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,mode:h,onMode:g,onReview:_,onMutation:v,onRevert:y,onOpen:b,locale:x}){if(e.state===`idle`)return(0,W.jsx)(`div`,{className:`diff-empty`,children:(0,W.jsx)(`p`,{children:$(x,`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,W.jsx)(`div`,{className:`diff-empty`,children:(0,W.jsx)(`p`,{children:$(x,`Đ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,W.jsx)(`div`,{className:`diff-empty error-state`,children:(0,W.jsx)(`p`,{children:$(x,`Diff không còn khớp revision hiện tại. Hãy chọn lại file sau khi danh sách cập nhật.`,`The diff no longer matches the current revision. Select the file again after the list refreshes.`)})});let S=e.value;return(0,W.jsxs)(X,{className:`diff-viewer`,sx:{minWidth:0,bgcolor:`background.paper`},children:[(0,W.jsxs)(X,{component:`header`,className:`diff-toolbar`,sx:{position:`sticky`,top:0,zIndex:2,bgcolor:`background.paper`},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:S.file.path}),(0,W.jsx)(cu,{size:`small`,variant:`outlined`,className:`access-badge tone-${fv(S.availability.state)}`,label:Q(S.availability.state,x)})]}),(0,W.jsxs)(`div`,{className:`diff-actions`,children:[t.state===`ready`&&t.value&&(0,W.jsxs)(`div`,{className:`review-state review-${t.value.state}`,children:[(0,W.jsx)(`span`,{children:t.value.state===`reviewed`?$(x,`Đã review`,`Reviewed`):t.value.state===`stale`?$(x,`Review đã cũ`,`Review stale`):t.value.state===`unavailable`?$(x,`Không thể review`,`Review unavailable`):$(x,`Chưa review`,`Not reviewed`)}),t.value.target&&t.value.state!==`unavailable`&&(0,W.jsx)(`button`,{type:`button`,disabled:!i||a,onClick:()=>_(t.value.state===`reviewed`?`unreviewed`:`reviewed`),children:a?$(x,`Đang ghi…`,`Saving…`):t.value.state===`reviewed`?$(x,`Bỏ dấu review`,`Mark unreviewed`):t.value.state===`stale`?$(x,`Review lại`,`Review again`):$(x,`Đánh dấu đã review`,`Mark reviewed`)})]}),n.state===`ready`&&n.value?.state===`ready`&&n.value.target&&(0,W.jsxs)(`div`,{className:`source-mutation-preview`,children:[(0,W.jsx)(`span`,{children:n.value.action===`source.stage`?$(x,`Chuẩn bị đúng thay đổi file này để commit`,`Prepare this exact file change for commit`):$(x,`Bỏ khỏi vùng commit; giữ nguyên file đang làm việc`,`Remove from commit while keeping the working file`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>v([]),children:c?$(x,`Đ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,W.jsxs)(`div`,{className:`source-revert-preview`,children:[(0,W.jsx)(`span`,{children:$(x,`Hoàn tác phần chưa stage; giữ nguyên index`,`Revert unstaged changes while preserving the index`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!u||d,onClick:()=>y(null),children:d?$(x,`Đang dựng preview…`,`Building preview…`):`Revert file`})]}),f&&(0,W.jsx)(`div`,{className:`source-open-action`,children:(0,W.jsx)(`button`,{type:`button`,disabled:p,onClick:b,children:p?$(x,`Đang mở…`,`Opening…`):$(x,`Mở trong VS Code`,`Open in VS Code`)})}),(0,W.jsxs)(op,{className:`mode-switch`,exclusive:!0,size:`small`,value:h,"aria-label":$(x,`Kiểu hiển thị diff`,`Diff layout`),onChange:(e,t)=>t&&g(t),children:[(0,W.jsx)(ep,{value:`inline`,"aria-label":`Inline`,children:`Inline`}),(0,W.jsx)(ep,{value:`split`,"aria-label":$(x,`Hai cột`,`Side by side`),children:$(x,`Hai cột`,`Side by side`)})]})]})]}),o&&(0,W.jsx)(`div`,{className:`review-error`,role:`status`,children:o}),l&&(0,W.jsx)(`div`,{className:`review-error`,role:`status`,children:l}),m&&(0,W.jsx)(`div`,{className:`source-open-status`,role:`status`,children:m}),(0,W.jsxs)(`div`,{className:`diff-context`,children:[(0,W.jsx)(`span`,{children:av(S.file,x)}),(0,W.jsx)(`span`,{children:cv(S.file,x)}),(0,W.jsxs)(`span`,{className:`additions`,children:[`+`,S.file.stats.additions??`?`]}),(0,W.jsxs)(`span`,{className:`deletions`,children:[`−`,S.file.stats.deletions??`?`]})]}),S.fallback.kind!==`none`&&(0,W.jsxs)(`div`,{className:`diff-fallback`,children:[(0,W.jsx)(`strong`,{children:Q(S.fallback.kind,x)}),(0,W.jsx)(`span`,{children:S.fallback.message??S.fallback.reasonCode??$(x,`Nội dung diff không sẵn sàng`,`Diff content unavailable`)})]}),S.hunks.map((e,t)=>(0,W.jsxs)(`section`,{className:`diff-hunk`,"aria-label":`${$(x,`Vùng thay đổi`,`Change region`)} ${t+1}`,children:[(0,W.jsxs)(`div`,{className:`hunk-header`,children:[(0,W.jsx)(`span`,{children:e.header}),(0,W.jsxs)(`span`,{className:`hunk-actions`,children:[n.value?.state===`ready`&&n.value.target?.hunkRefs.includes(e.hunkRef)&&(0,W.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>v([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,W.jsx)(`button`,{className:`revert-action`,type:`button`,disabled:!u||d,onClick:()=>y(e.hunkRef),children:`Revert hunk`})]})]}),(0,W.jsx)(`div`,{className:h===`split`?`split-code`:`inline-code`,children:e.lines.map(e=>(0,W.jsx)(Tv,{line:e,side:h,path:S.file.path},e.lineRef))}),S.unchangedRegions[t]&&(0,W.jsxs)(`div`,{className:`unchanged-region`,children:[`… `,S.unchangedRegions[t].lineCount,` `,$(x,`dòng không đổi đã thu gọn`,`unchanged lines collapsed`),` …`]})]},e.hunkRef)),S.truncation.truncated&&(0,W.jsxs)(`div`,{className:`diff-fallback`,children:[(0,W.jsx)(`strong`,{children:$(x,`Diff đã rút gọn`,`Diff truncated`)}),(0,W.jsxs)(`span`,{children:[$(x,`Còn`,`Another`),` `,S.truncation.omittedLines,` `,$(x,`dòng chưa hiển thị.`,`lines are not shown.`)]})]})]})}function Dv({snapshot:e,refreshSnapshot:t,sessionRef:n}){let{locale:r}=xv(),i=!!(e.task&&e.sourceChanges.task?.state!==`unavailable`&&e.sourceChanges.task?.revision),a=(0,v.useMemo)(()=>rv(r),[r]),[o,s]=(0,v.useState)(()=>i?`task`:`working-tree`),[c,l]=(0,v.useState)({}),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)({state:`idle`}),[m,h]=(0,v.useState)({state:`idle`}),[g,_]=(0,v.useState)({state:`idle`}),[y,b]=(0,v.useState)({state:`idle`}),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)({state:`idle`}),[ne,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(null),[re,ie]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(0),[se,H]=(0,v.useState)(`inline`),ce=`${e.sourceChanges.task?.revision??`no-task`}:${e.sourceChanges.workingTree.revision}:${e.sourceChanges.staged.revision}`,le=c[o],ue=lv(le?.state===`ready`?le.value?.files??[]:[],u);(0,v.useEffect)(()=>{te({state:`idle`}),V(null),ie(!1)},[ce]),(0,v.useEffect)(()=>{!i&&o===`task`&&(s(`working-tree`),d(null))},[i,o]),(0,v.useEffect)(()=>{let e=new AbortController;return l(e=>({...e,[o]:{state:`loading`}})),(n?Lg(n,o,e.signal):Yg(o,e.signal)).then(t=>{if(!t){e.signal.aborted||l(e=>({...e,[o]:{state:`error`}}));return}l(e=>({...e,[o]:{state:`ready`,value:t}}))}).catch(()=>{e.signal.aborted||l(e=>({...e,[o]:{state:`error`}}))}),()=>e.abort()},[o,ce,ae,n]),(0,v.useEffect)(()=>{if(!ue){p({state:`idle`}),h({state:`idle`}),_({state:`idle`}),b({state:`idle`});return}let t=new AbortController;p({state:`loading`}),E(null),A(null),P(null),S(null),R(null);let r=o===`working-tree`?`source.stage`:o===`staged`?`source.unstage`:null,i=e.capabilities.capabilities.reviewActions,a=i.status===`available`&&i.actions.reviewMark.available,s=r===`source.stage`?i.status===`available`&&i.actions.stage.available:r===`source.unstage`&&i.status===`available`&&i.actions.unstage.available,c=o===`working-tree`&&i.status===`available`&&i.actions.revert.available;return h(a?{state:`loading`}:{state:`idle`}),_(s?{state:`loading`}:{state:`idle`}),b(c?{state:`loading`}:{state:`idle`}),(n?Rg(n,o,ue,t.signal):Xg(o,ue,t.signal)).then(e=>{t.signal.aborted||p({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||p({state:`error`})}),a&&(n?zg(n,o,ue,t.signal):Zg(o,ue,t.signal)).then(e=>{t.signal.aborted||h({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||h({state:`error`})}),s&&r&&(n?Bg(n,r,ue,t.signal):Qg(r,ue,t.signal)).then(e=>{t.signal.aborted||_({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||_({state:`error`})}),c&&(n?Vg(n,ue,null,t.signal):$g(ue,null,t.signal)).then(e=>{t.signal.aborted||b({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||b({state:`error`})}),()=>t.abort()},[ue,o,ce,n,e.capabilities.capabilities.reviewActions]);let de=c[o],fe=de?.value?.files??[],pe=(0,v.useMemo)(()=>{let e=new Map;for(let t of fe){let n=t.path.lastIndexOf(`/`),i=n<0?$(r,`Gốc project`,`Project root`):t.path.slice(0,n);e.set(i,[...e.get(i)??[],t])}return[...e.entries()]},[fe,r]),me=(0,v.useMemo)(()=>({task:c.task?.state===`ready`?c.task.value?.page.total??0:e.sourceChanges.task?.counts.files??0,"working-tree":c[`working-tree`]?.state===`ready`?c[`working-tree`].value?.page.total??0:e.sourceChanges.workingTree.counts.files,staged:c.staged?.state===`ready`?c.staged.value?.page.total??0:e.sourceChanges.staged.counts.files}),[c,e]),he=e=>{s(e),d(null)},U=e.capabilities.capabilities.reviewActions,ge=U.status===`available`&&U.actions.reviewMark.available,_e=g.value?.action===`source.stage`?U.status===`available`&&U.actions.stage.available:g.value?.action===`source.unstage`&&U.status===`available`&&U.actions.unstage.available,ve=U.status===`available`&&U.actions.revert.available,ye=o===`working-tree`&&U.status===`available`&&U.actions.openInVsCode.available&&f.state===`ready`&&f.value?.availability.state===`current`&&f.value.fallback.kind===`none`,be=o===`staged`&&fe.length>0,xe=be&&U.status===`available`&&U.actions.generateCommitSummaryDeterministic.available,Se=be&&U.status===`available`&&U.actions.generateCommitSummaryModel.available,Ce=async t=>{if(!(!ue||!m.value||C)){w(!0),E(null);try{let i=await __(await L_(e,m.value,t));if(i.phase!==`settled`||![`reviewed`,`unreviewed`].includes(i.resultCode)){E(i.error?.message??$(r,`File đã thay đổi; hãy tải lại diff trước khi review.`,`The file changed; reload the diff before reviewing.`));return}h({state:`ready`,value:n?await zg(n,o,ue):await Zg(o,ue)})}catch{E($(r,`Không thể ghi trạng thái review. Nội dung source không bị thay đổi.`,`Unable to save review state. Source content was not changed.`))}finally{w(!1)}}},we=async(n=[])=>{if(!(!g.value||g.value.state!==`ready`||D)){O(!0),A(null);try{let i=await v_(await B_(e,g.value,n));if(i.phase!==`settled`||![`staged`,`unstaged`].includes(i.resultCode)){A(i.phase===`uncertain`?$(r,`Không xác nhận được trạng thái Git. Hãy kiểm tra lại ba tab trước khi làm tiếp.`,`Git state could not be confirmed. Check all three tabs before continuing.`):i.error?.message??$(r,`File hoặc Git index đã thay đổi; hãy tải lại preview.`,`The file or Git index changed; reload the preview.`));return}d(null),await t?.(),oe(e=>e+1)}catch{A($(r,`Không thể cập nhật Git index. File đang làm việc không bị thay đổi.`,`Unable to update the Git index. The working file was not changed.`))}finally{O(!1)}}},Te=async e=>{if(!(!ue||!ve||j)){M(!0),P(null);try{let t=n?await Vg(n,ue,e):await $g(ue,e);if(t.state!==`ready`||!t.target){P($(r,`Không thể hoàn tác an toàn: provenance hoặc diff hiện tại không còn đủ bằng chứng.`,`Safe revert is unavailable because provenance or the current diff lacks evidence.`));return}S(t)}catch{P($(r,`Không thể dựng preview hoàn tác. Source chưa bị thay đổi.`,`Unable to build a revert preview. Source was not changed.`))}finally{M(!1)}}},Ee=async()=>{if(!(!x||j)){M(!0),P(null);try{let n=await y_(await U_(e,x));if(n.phase!==`settled`||n.resultCode!==`reverted`){P(n.phase===`uncertain`?$(r,`Không xác nhận được kết quả. Hãy kiểm tra lại Working Tree và Staged Changes.`,`The result could not be confirmed. Check Working Tree and Staged Changes.`):n.error?.message??$(r,`Preview đã cũ; hãy mở lại trước khi xác nhận.`,`The preview is stale; reopen it before confirming.`));return}S(null),d(null),await t?.(),oe(e=>e+1)}catch{P($(r,`Không thể hoàn tác. Hãy kiểm tra lại source trước khi thử lại.`,`Unable to revert. Check the source before trying again.`))}finally{M(!1)}}},De=async()=>{if(!(!ue||!ye||F)){I(!0),R(null);try{let t=await b_(await K_(e,ue));t.phase===`settled`&&t.resultCode===`opened`?R($(r,`VS Code đã nhận yêu cầu mở file.`,`VS Code received the open-file request.`)):R(t.phase===`uncertain`?$(r,`Không xác nhận được VS Code đã nhận file. Piagent sẽ không tự mở lại.`,`It is unknown whether VS Code received the file. Piagent will not retry automatically.`):t.error?.message??$(r,`File hoặc phiên làm việc đã thay đổi; hãy tải lại trước khi mở.`,`The file or session changed; refresh before opening.`))}catch{R($(r,`Không thể mở file trong VS Code. Diff hiện tại vẫn được giữ nguyên.`,`Unable to open the file in VS Code. The current diff remains available.`))}finally{I(!1)}}},Oe=async()=>{if(!(!xe||ne)){z(!0),V(null),te({state:`loading`});try{let e=n?await Hg(n):await e_();te({state:`ready`,value:e}),e.state!==`ready`&&V($(r,`Staged Changes đã thay đổi hoặc chưa có dữ liệu để tóm tắt.`,`Staged Changes changed or has no data to summarize.`))}catch{te({state:`error`}),V($(r,`Không thể dựng commit summary từ index hiện tại.`,`Unable to generate a commit summary from the current index.`))}finally{z(!1)}}},ke=async()=>{let e=ee.value?.summary;if(e)try{await navigator.clipboard.writeText([e.title,``,...e.bodyLines].join(`
172
- `)),V($(r,`Đã copy summary. Chưa có commit nào được tạo.`,`Summary copied. No commit was created.`))}catch{V($(r,`Trình duyệt không cho phép copy tự động.`,`The browser did not allow automatic copying.`))}},Ae=async()=>{let t=ee.value?.summary;if(!(!t||!Se||ne)){z(!0),V(null);try{let n=await p_(await D_(e,t.modelPrompt,`new-operation`));n.phase===`settled`&&n.resultCode===`dispatch-observed`?V($(r,`Đã gửi yêu cầu sang Chat. Pi sẽ trả commit summary ở hội thoại; chưa commit hoặc push.`,`Request sent to Chat. Pi will return the commit summary in the conversation; nothing was committed or pushed.`)):V(n.phase===`uncertain`?$(r,`Không xác nhận được yêu cầu đã tới Pi; hệ thống sẽ không tự gửi lại.`,`It is unknown whether the request reached Pi; it will not be resent automatically.`):n.error?.message??$(r,`Không thể bắt đầu model work từ session hiện tại.`,`Unable to start model work from the current session.`))}catch{V($(r,`Không thể gửi yêu cầu sang Pi session hiện tại.`,`Unable to send the request to the current Pi session.`))}finally{z(!1),ie(!1)}}};return(0,W.jsxs)(Mc,{component:`section`,variant:`outlined`,className:`source-workspace`,"aria-labelledby":`source-title`,sx:{overflow:`hidden`,minHeight:`calc(100vh - 120px)`,display:`flex`,flexDirection:`column`},children:[(0,W.jsxs)(X,{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,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`overline`,color:`primary.main`,sx:{fontWeight:800,letterSpacing:`.14em`,lineHeight:1},children:`Source changes`}),(0,W.jsx)(Z,{variant:`h2`,id:`source-title`,sx:{mt:.5},children:$(r,`Thay đổi trong project`,`Project changes`)})]}),(0,W.jsx)(cu,{label:`Git + task baseline`,variant:`outlined`,size:`small`})]}),(0,W.jsx)(pg,{className:`source-tabs`,value:o,onChange:(e,t)=>he(t),selectionFollowsFocus:!0,variant:`scrollable`,scrollButtons:`auto`,"aria-label":$(r,`Nguồn thay đổi`,`Change sources`),sx:{borderBottom:1,borderColor:`divider`,minHeight:48},children:a.map(e=>(0,W.jsx)(Kh,{id:`source-tab-${e.view}`,value:e.view,"aria-controls":`source-tabpanel`,disabled:e.view===`task`&&!i,title:e.view===`task`&&!i?$(r,`Session này chưa có task baseline`,`This session has no task baseline`):void 0,label:(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsx)(`span`,{children:e.label}),me[e.view]>0&&(0,W.jsx)(cu,{size:`small`,label:me[e.view],sx:{height:20,minWidth:24,"& .MuiChip-label":{px:.75}}})]})},e.view))}),o===`staged`&&(0,W.jsx)(Sv,{state:ee,busy:ne,status:B,locale:r,deterministicEnabled:xe,modelEnabled:Se,onGenerate:()=>{Oe()},onCopy:()=>{ke()},onModel:()=>ie(!0)}),(0,W.jsxs)(X,{className:`source-body`,sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`minmax(286px, 330px) minmax(0, 1fr)`},flex:1,minHeight:620},children:[(0,W.jsxs)(X,{className:`file-panel`,id:`source-tabpanel`,role:`tabpanel`,"aria-labelledby":`source-tab-${o}`,sx:{minWidth:0,borderRight:{md:1},borderBottom:{xs:1,md:0},borderColor:`divider`,bgcolor:`background.default`},children:[(0,W.jsxs)(X,{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,W.jsx)(`span`,{"aria-live":`polite`,children:de?.state===`ready`&&de.value?sv(de.value,r):de?.state===`error`?$(r,`Không thể tải danh sách file`,`Unable to load files`):$(r,`Đang tải…`,`Loading…`)}),(0,W.jsx)(`small`,{children:a.find(e=>e.view===o)?.shortLabel})]}),(0,W.jsxs)(X,{className:`file-list`,sx:{maxHeight:{xs:300,md:`calc(100vh - 270px)`},overflow:`auto`,p:.75},children:[pe.map(([e,t])=>(0,W.jsxs)(X,{children:[(0,W.jsxs)(Cf,{direction:`row`,className:`file-group-label`,children:[(0,W.jsx)(Vh,{}),(0,W.jsx)(Z,{component:`span`,noWrap:!0,children:e})]}),t.map(e=>(0,W.jsx)(Cv,{file:e,selected:e.fileRef===ue,onSelect:()=>d(e.fileRef),locale:r},e.fileRef))]},e)),de?.state===`ready`&&fe.length===0&&(0,W.jsx)(`div`,{className:`files-empty`,children:$(r,`Không có thay đổi trong view này.`,`No changes in this view.`)})]})]}),(0,W.jsx)(Ev,{state:f,review:m,mutation:g,revert:y,reviewEnabled:ge,reviewBusy:C,reviewError:T,mutationEnabled:_e,mutationBusy:D,mutationError:k,revertEnabled:ve,revertBusy:j,openEnabled:ye,openBusy:F,openStatus:L,mode:se,onMode:H,onReview:e=>{Ce(e)},onMutation:e=>{we(e)},onRevert:e=>{Te(e)},onOpen:()=>{De()},locale:r})]}),N&&(0,W.jsx)(`div`,{className:`source-revert-error`,role:`status`,children:N}),x?.target&&(0,W.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,W.jsxs)(`section`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`revert-dialog-title`,"aria-describedby":`revert-dialog-description`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Xác nhận hoàn tác`,`Confirm revert`)}),(0,W.jsxs)(`h3`,{id:`revert-dialog-title`,children:[`Revert `,x.target.hunkRefs.length?`hunk`:`file`,`?`]}),(0,W.jsxs)(`p`,{id:`revert-dialog-description`,children:[$(r,`Thao tác sẽ bỏ`,`This will discard`),` `,(0,W.jsxs)(`strong`,{children:[x.target.summary.additionsDiscarded,` `,$(r,`dòng thêm`,`added lines`)]}),` `,$(r,`và khôi phục`,`and restore`),` `,(0,W.jsxs)(`strong`,{children:[x.target.summary.deletionsRestored,` `,$(r,`dòng xóa`,`deleted lines`)]}),` `,$(r,`trong`,`in`),` `,(0,W.jsx)(`code`,{children:x.target.path}),`.`]}),(0,W.jsx)(`div`,{className:`revert-diff`,"aria-label":$(r,`Các dòng chính xác sẽ được hoàn tác`,`Exact lines to revert`),children:x.preview?.hunks.map(e=>(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`div`,{children:e.header}),e.lines.map((t,n)=>(0,W.jsxs)(`code`,{className:`revert-line revert-${t.kind}`,children:[(0,W.jsx)(`b`,{children:t.marker}),t.text]},`${e.hunkRef}.${n}`))]},e.hunkRef))}),(0,W.jsxs)(`div`,{className:`revert-safety`,children:[(0,W.jsx)(`strong`,{children:$(r,`Phần đã stage được giữ nguyên.`,`Staged content is preserved.`)}),(0,W.jsx)(`span`,{children:$(r,`Không auto-commit. Khả năng khôi phục sau thao tác không được bảo đảm.`,`No auto-commit. Recovery after this action is not guaranteed.`)})]}),(0,W.jsxs)(`div`,{className:`confirm-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>S(null),children:$(r,`Hủy`,`Cancel`)}),(0,W.jsx)(`button`,{className:`danger-action`,type:`button`,disabled:j,onClick:()=>{Ee()},children:j?$(r,`Đang hoàn tác…`,`Reverting…`):$(r,`Xác nhận revert`,`Confirm revert`)})]})]})}),re&&(0,W.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,W.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,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Model work có tính phí`,`Token-consuming model work`)}),(0,W.jsx)(`h3`,{id:`model-summary-dialog-title`,children:$(r,`Nhờ Pi viết lại commit summary?`,`Ask Pi to rewrite the commit summary?`)}),(0,W.jsx)(`p`,{id:`model-summary-dialog-description`,children:$(r,`Thao tác này gửi một message vào đúng Pi session hiện tại, bắt đầu một Pi operation và tiêu token theo model/thinking đang chọn. Chỉ staged summary đã rút gọn được gửi; source text không được đính kèm.`,`This sends a message to the exact current Pi session, starts a Pi operation, and consumes tokens using the selected model and thinking level. Only the bounded staged summary is sent; source text is not attached.`)}),(0,W.jsxs)(`div`,{className:`revert-safety`,children:[(0,W.jsx)(`strong`,{children:$(r,`Không tự commit hoặc push.`,`Does not commit or push.`)}),(0,W.jsx)(`span`,{children:$(r,`Kết quả sẽ xuất hiện trong Chat để anh review và copy.`,`The result will appear in Chat for review and copying.`)})]}),(0,W.jsxs)(`div`,{className:`confirm-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:ne,onClick:()=>ie(!1),children:$(r,`Hủy`,`Cancel`)}),(0,W.jsx)(`button`,{type:`button`,disabled:ne,onClick:()=>{Ae()},children:ne?$(r,`Đang gửi…`,`Sending…`):$(r,`Xác nhận và gửi sang Pi`,`Confirm and send to Pi`)})]})]})})]})}function Ov(e){return K(`MuiInputAdornment`,e)}var kv=Wr(`MuiInputAdornment`,[`root`,`filled`,`standard`,`outlined`,`positionStart`,`positionEnd`,`disablePointerEvents`,`hiddenLabel`,`sizeSmall`]),Av,jv=(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${Y(n.position)}`],n.disablePointerEvents===!0&&t.disablePointerEvents,t[n.variant]]},Mv=e=>{let{classes:t,disablePointerEvents:n,hiddenLabel:r,position:i,size:a,variant:o}=e;return va({root:[`root`,n&&`disablePointerEvents`,i&&`position${Y(i)}`,o,r&&`hiddenLabel`,a&&`size${Y(a)}`]},Ov,t)},Nv=J(`div`,{name:`MuiInputAdornment`,slot:`Root`,overridesResolver:jv})(_s(({theme:e})=>({display:`flex`,maxHeight:`2em`,alignItems:`center`,whiteSpace:`nowrap`,color:(e.vars||e).palette.action.active,variants:[{props:{variant:`filled`},style:{[`&.${kv.positionStart}&:not(.${kv.hiddenLabel})`]:{marginTop:16}}},{props:{position:`start`},style:{marginRight:8}},{props:{position:`end`},style:{marginLeft:8}},{props:{disablePointerEvents:!0},style:{pointerEvents:`none`}}]}))),Pv=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiInputAdornment`}),{children:r,className:i,component:a=`div`,disablePointerEvents:o=!1,disableTypography:s=!1,position:c,variant:l,...u}=n,d=hs()||{},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=Mv(p);return(0,W.jsx)(ms.Provider,{value:null,children:(0,W.jsx)(Nv,{as:a,ownerState:p,className:G(m.root,i),ref:t,...u,children:typeof r==`string`&&!s?(0,W.jsx)(Z,{color:`textSecondary`,children:r}):(0,W.jsxs)(v.Fragment,{children:[c===`start`?Av||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):null,r]})})})});function Fv(e){return K(`MuiInputLabel`,e)}var Iv=Wr(`MuiInputLabel`,[`root`,`focused`,`disabled`,`error`,`required`,`asterisk`,`formControl`,`sizeSmall`,`shrink`,`animated`,`standard`,`filled`,`outlined`]),Lv=e=>{let{classes:t,disableUnderline:n}=e,r=va({root:[`root`,!n&&`underline`],input:[`input`]},sc,t);return{...t,...r}},Rv=J(Zs,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Js(e,t),!n.disableUnderline&&t.underline]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`;return e.vars&&(t=e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline)),{position:`relative`,variants:[{props:({ownerState:e})=>e.formControl,style:{[`label + &, .${Iv.root} + &`]:{marginTop:16}}},{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ws(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${cc.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${cc.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${t}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ws(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${cc.disabled}, .${cc.error}):before`]:{borderBottom:`2px solid ${(e.vars||e).palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},[`&.${cc.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t,disableUnderline:!1},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t].main}`}}}))]}})),zv=J(Qs,{name:`MuiInput`,slot:`Input`,overridesResolver:Ys})({}),Bv=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiInput`}),{disableUnderline:r=!1,fullWidth:i=!1,inputComponent:a=`input`,multiline:o=!1,notched:s,slotProps:c,slots:l={},type:u=`text`,...d}=n,f=Lv(n),p={root:{ownerState:{disableUnderline:r}}},m=c?Ut(c,p):p,h=l.root??Rv,g=l.input??zv;return(0,W.jsx)(ec,{slots:{root:h,input:g},slotProps:m,fullWidth:i,inputComponent:a,multiline:o,ref:t,type:u,...d,classes:f})});Bv.muiName=`Input`;function Vv(e){return K(`MuiSelect`,e)}var Hv=Wr(`MuiSelect`,[`root`,`select`,`multiple`,`filled`,`outlined`,`standard`,`disabled`,`focused`,`icon`,`iconOpen`,`nativeInput`,`error`]),Uv=e=>{let{classes:t,disableUnderline:n,startAdornment:r,endAdornment:i,size:a,hiddenLabel:o,multiline:s}=e,c=va({root:[`root`,!n&&`underline`,r&&`adornedStart`,i&&`adornedEnd`,a===`small`&&`size${Y(a)}`,o&&`hiddenLabel`,s&&`multiline`],input:[`input`]},tc,t);return{...t,...c}},Wv=J(Zs,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiFilledInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Js(e,t),!n.disableUnderline&&t.underline]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`,n=t?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`,r=t?`rgba(0, 0, 0, 0.06)`:`rgba(255, 255, 255, 0.09)`,i=t?`rgba(0, 0, 0, 0.09)`:`rgba(255, 255, 255, 0.13)`,a=t?`rgba(0, 0, 0, 0.12)`:`rgba(255, 255, 255, 0.12)`;return{position:`relative`,backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r,borderTopLeftRadius:(e.vars||e).shape.borderRadius,borderTopRightRadius:(e.vars||e).shape.borderRadius,...Ws(e,`background-color`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),"&:hover":{backgroundColor:e.vars?e.vars.palette.FilledInput.hoverBg:i,"@media (hover: none)":{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r}},[`&.${nc.focused}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r},[`&.${nc.disabled}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.disabledBg:a},variants:[{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ws(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${nc.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${nc.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${e.vars?e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline):n}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ws(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${nc.disabled}, .${nc.error}):before`]:{borderBottom:`1px solid ${(e.vars||e).palette.text.primary}`},[`&.${nc.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{disableUnderline:!1,color:t},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t]?.main}`}}})),{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:12}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`12px`,paddingRight:`var(--_trailingPad)`,[`&.${Hv.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`25px 12px 8px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}}]}})),Gv=J(Qs,{name:`MuiFilledInput`,slot:`Input`,overridesResolver:Ys})(_s(({theme:e})=>({paddingTop:25,paddingRight:12,paddingBottom:8,paddingLeft:12,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderTopLeftRadius:`inherit`,borderTopRightRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}},{props:({ownerState:e})=>e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}},{props:({ownerState:e})=>e.multiline,style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}}]}))),Kv=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFilledInput`}),{disableUnderline:r=!1,fullWidth:i=!1,hiddenLabel:a,inputComponent:o=`input`,multiline:s=!1,notched:c,slotProps:l,slots:u={},type:d=`text`,...f}=n,p={...n,disableUnderline:r,fullWidth:i,inputComponent:o,multiline:s,type:d},m=Uv(n),h={root:{ownerState:p},input:{ownerState:p}},g=l?Ut(h,l):h,_=u.root??Wv,v=u.input??Gv;return(0,W.jsx)(ec,{slots:{root:_,input:v},slotProps:g,fullWidth:i,inputComponent:o,multiline:s,ref:t,type:d,...f,classes:m})});Kv.muiName=`Input`;var qv,Jv=J(`fieldset`,{name:`MuiNotchedOutlined`,shouldForwardProp:Ko})({textAlign:`left`,position:`absolute`,bottom:0,right:0,top:-5,left:0,margin:0,padding:`0 8px`,pointerEvents:`none`,borderRadius:`inherit`,borderStyle:`solid`,borderWidth:1,overflow:`hidden`,minWidth:`0%`}),Yv=J(`legend`,{name:`MuiNotchedOutlined`,shouldForwardProp:Ko})(_s(({theme:e})=>({float:`unset`,width:`auto`,overflow:`hidden`,variants:[{props:({ownerState:e})=>!e.withLabel,style:{padding:0,lineHeight:`11px`,...Ws(e,`width`,{duration:150,easing:e.transitions.easing.easeOut})}},{props:({ownerState:e})=>e.withLabel,style:{display:`block`,padding:0,height:11,fontSize:`0.75em`,visibility:`hidden`,maxWidth:.01,...Ws(e,`max-width`,{duration:50,easing:e.transitions.easing.easeOut}),whiteSpace:`nowrap`,"& > span":{paddingLeft:5,paddingRight:5,display:`inline-block`,opacity:0,visibility:`visible`}}},{props:({ownerState:e})=>e.withLabel&&e.notched,style:{maxWidth:`100%`,...Ws(e,`max-width`,{duration:100,easing:e.transitions.easing.easeOut,delay:50})}}]})));function Xv(e){let{children:t,classes:n,className:r,label:i,notched:a,...o}=e,s=i!=null&&i!==``,c={...e,notched:a,withLabel:s};return(0,W.jsx)(Jv,{"aria-hidden":!0,className:r,ownerState:c,...o,children:(0,W.jsx)(Yv,{ownerState:c,children:s?(0,W.jsx)(`span`,{children:i}):qv||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`})})})}var Zv=e=>{let{classes:t}=e,n=va({root:[`root`],notchedOutline:[`notchedOutline`],input:[`input`]},hc,t);return{...t,...n}},Qv=J(Zs,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiOutlinedInput`,slot:`Root`,overridesResolver:Js})(_s(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{position:`relative`,borderRadius:(e.vars||e).shape.borderRadius,[`&:hover .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${gc.notchedOutline}`]:{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}},[`&.${gc.focused} .${gc.notchedOutline}`]:{borderWidth:2},variants:[...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{[`&.${gc.focused} .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${gc.error} .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette.error.main},[`&.${gc.disabled} .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled}}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:14}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`14px`,paddingRight:`var(--_trailingPad)`,[`&.${Hv.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`16.5px 14px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{padding:`8.5px 14px`}}]}})),$v=J(Xv,{name:`MuiOutlinedInput`,slot:`NotchedOutline`})(_s(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}})),ey=J(Qs,{name:`MuiOutlinedInput`,slot:`Input`,overridesResolver:Ys})(_s(({theme:e})=>({padding:`16.5px 14px`,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{padding:`8.5px 14px`}},{props:({ownerState:e})=>e.multiline,style:{padding:0}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}}]}))),ty=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiOutlinedInput`}),{fullWidth:r=!1,inputComponent:i=`input`,label:a,multiline:o=!1,notched:s,slots:c={},slotProps:l={},type:u=`text`,...d}=n,f=Zv(n),[p,m]=gs({props:n,states:[`color`,`disabled`,`error`,`focused`,`hiddenLabel`,`size`,`required`]}),h={...n,color:p.color||`primary`,disabled:p.disabled,error:p.error,focused:p.focused,formControl:m,fullWidth:r,hiddenLabel:p.hiddenLabel,multiline:o,size:p.size,type:u},g=c.root??Qv,_=c.input??ey,[y,b]=Jc(`notchedOutline`,{elementType:$v,className:f.notchedOutline,shouldForwardComponentProp:!0,ownerState:h,externalForwardedProps:{slots:c,slotProps:l},additionalProps:{label:a!=null&&a!==``&&p.required?(0,W.jsxs)(v.Fragment,{children:[a,` `,`*`]}):a}});return(0,W.jsx)(ec,{slots:{root:g,input:_},slotProps:l,renderSuffix:e=>(0,W.jsx)(y,{...b,notched:s===void 0?!!(e.startAdornment||e.filled||e.focused):s}),fullWidth:r,inputComponent:i,multiline:o,ref:t,type:u,...d,classes:{...f,notchedOutline:null}})});ty.muiName=`Input`;var ny=e=>{let{classes:t,color:n,focused:r,disabled:i,error:a,filled:o,required:s}=e;return va({root:[`root`,`color${Y(n)}`,i&&`disabled`,a&&`error`,o&&`filled`,r&&`focused`,s&&`required`],asterisk:[`asterisk`,a&&`error`]},ac,t)},ry=J(`label`,{name:`MuiFormLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color===`secondary`&&t.colorSecondary,n.filled&&t.filled]}})(_s(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.body1,lineHeight:`1.4375em`,padding:0,position:`relative`,variants:[...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{[`&.${oc.focused}`]:{color:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${oc.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${oc.error}`]:{color:(e.vars||e).palette.error.main}}}]}))),iy=J(`span`,{name:`MuiFormLabel`,slot:`Asterisk`})(_s(({theme:e})=>({[`&.${oc.error}`]:{color:(e.vars||e).palette.error.main}}))),ay=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFormLabel`}),{children:r,className:i,color:a,component:o=`label`,disabled:s,error:c,filled:l,focused:u,required:d,...f}=n,[p]=gs({props:n,states:[`color`,`required`,`focused`,`disabled`,`error`,`filled`]}),m={...n,color:p.color||`primary`,component:o,disabled:p.disabled,error:p.error,filled:p.filled,focused:p.focused,required:p.required},h=ny(m);return(0,W.jsxs)(ry,{as:o,ownerState:m,className:G(h.root,i),ref:t,...f,children:[r,p.required&&(0,W.jsxs)(iy,{ownerState:m,"aria-hidden":!0,className:h.asterisk,children:[` `,`*`]})]})}),oy=e=>{let{classes:t,formControl:n,size:r,shrink:i,disableAnimation:a,variant:o,required:s}=e,c=va({root:[`root`,n&&`formControl`,!a&&`animated`,i&&`shrink`,r&&r!==`medium`&&`size${Y(r)}`,o],asterisk:[s&&`asterisk`]},Fv,t);return{...t,...c}},sy=J(ay,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiInputLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${oc.asterisk}`]:t.asterisk},t.root,n.formControl&&t.formControl,n.size===`small`&&t.sizeSmall,n.shrink&&t.shrink,!n.disableAnimation&&t.animated,n.focused&&t.focused,t[n.variant]]}})(_s(({theme:e})=>({display:`block`,transformOrigin:`top left`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,variants:[{props:({ownerState:e})=>e.formControl,style:{position:`absolute`,left:0,top:0,transform:`translate(0, 20px) scale(1)`}},{props:{size:`small`},style:{transform:`translate(0, 17px) scale(1)`}},{props:({ownerState:e})=>e.shrink,style:{transform:`translate(0, -1.5px) scale(0.75)`,transformOrigin:`top left`,maxWidth:`133%`}},{props:({ownerState:e})=>!e.disableAnimation,style:{...Ws(e,[`color`,`transform`,`max-width`],{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut})}},{props:{variant:`filled`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(12px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`filled`,size:`small`},style:{transform:`translate(12px, 13px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`filled`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,transform:`translate(12px, 7px) scale(0.75)`,maxWidth:`calc(133% - 24px)`}},{props:({variant:e,ownerState:t,size:n})=>e===`filled`&&t.shrink&&n===`small`,style:{transform:`translate(12px, 4px) scale(0.75)`}},{props:{variant:`outlined`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(14px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`outlined`,size:`small`},style:{transform:`translate(14px, 9px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`outlined`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,maxWidth:`calc(133% - 32px)`,transform:`translate(14px, -9px) scale(0.75)`}}]}))),cy=v.forwardRef(function(e,t){let n=Jo({name:`MuiInputLabel`,props:e}),{disableAnimation:r=!1,margin:i,shrink:a,variant:o,className:s,...c}=n,[l,u]=gs({props:n,states:[`size`,`variant`,`required`,`focused`]}),d=a;d===void 0&&u&&(d=u.filled||u.focused||u.adornedStart);let f={...n,disableAnimation:r,formControl:u,shrink:d,size:l.size,variant:l.variant,required:l.required,focused:l.focused},p=oy(f);return(0,W.jsx)(sy,{"data-shrink":d,ref:t,className:G(p.root,s),...c,ownerState:f,classes:p})});function ly(e){return K(`MuiFormControl`,e)}Wr(`MuiFormControl`,[`root`,`marginNone`,`marginNormal`,`marginDense`,`fullWidth`,`disabled`]);var uy=e=>{let{classes:t,margin:n,fullWidth:r}=e;return va({root:[`root`,n!==`none`&&`margin${Y(n)}`,r&&`fullWidth`]},ly,t)},dy=J(`div`,{name:`MuiFormControl`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`margin${Y(n.margin)}`],n.fullWidth&&t.fullWidth]}})({display:`inline-flex`,flexDirection:`column`,position:`relative`,minWidth:0,padding:0,margin:0,border:0,verticalAlign:`top`,variants:[{props:{margin:`normal`},style:{marginTop:16,marginBottom:8}},{props:{margin:`dense`},style:{marginTop:8,marginBottom:4}},{props:{fullWidth:!0},style:{width:`100%`}}]}),fy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFormControl`}),{children:r,className:i,color:a=`primary`,component:o=`div`,disabled:s=!1,error:c=!1,focused:l,fullWidth:u=!1,hiddenLabel:d=!1,margin:f=`none`,required:p=!1,size:m=`medium`,variant:h=`outlined`,...g}=n,_={...n,color:a,component:o,disabled:s,error:c,fullWidth:u,hiddenLabel:d,margin:f,required:p,size:m,variant:h},y=uy(_),[b,x]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{if(!Cd(t,[`Input`,`Select`]))return;let n=Cd(t,[`Select`])?t.props.input:t;n&&Ts(n.props)&&(e=!0)}),e}),[S,C]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{Cd(t,[`Input`,`Select`])&&(ws(t.props,!0)||ws(t.props.inputProps,!0))&&(e=!0)}),e}),[w,T]=v.useState(!1);s&&w&&T(!1);let E=l!==void 0&&!s?l:w,D;v.useRef(!1);let O=v.useCallback(()=>{C(!0)},[]),k=v.useCallback(()=>{C(!1)},[]),A=v.useMemo(()=>({adornedStart:b,setAdornedStart:x,color:a,disabled:s,error:c,filled:S,focused:E,fullWidth:u,hiddenLabel:d,size:m,onBlur:()=>{T(!1)},onFocus:()=>{T(!0)},onEmpty:k,onFilled:O,registerEffect:D,required:p,variant:h}),[b,a,s,c,S,E,u,d,D,k,O,p,m,h]);return(0,W.jsx)(ms.Provider,{value:A,children:(0,W.jsx)(dy,{as:o,ownerState:_,className:G(y.root,i),ref:t,...g,children:r})})}),py,my=e=>{let{classes:t,contained:n,size:r,disabled:i,error:a,filled:o,focused:s,required:c}=e;return va({root:[`root`,i&&`disabled`,a&&`error`,r&&`size${Y(r)}`,n&&`contained`,s&&`focused`,o&&`filled`,c&&`required`]},rc,t)},hy=J(`p`,{name:`MuiFormHelperText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.size&&t[`size${Y(n.size)}`],n.contained&&t.contained,n.filled&&t.filled]}})(_s(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.caption,textAlign:`left`,marginTop:3,marginRight:0,marginBottom:0,marginLeft:0,[`&.${ic.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${ic.error}`]:{color:(e.vars||e).palette.error.main},variants:[{props:{size:`small`},style:{marginTop:4}},{props:({ownerState:e})=>e.contained,style:{marginLeft:14,marginRight:14}}]}))),gy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFormHelperText`}),{children:r,className:i,component:a=`p`,disabled:o,error:s,filled:c,focused:l,margin:u,required:d,variant:f,...p}=n,[m]=gs({props:n,states:[`variant`,`size`,`disabled`,`error`,`filled`,`focused`,`required`]}),h={...n,component:a,contained:m.variant===`filled`||m.variant===`outlined`,variant:m.variant,size:m.size,disabled:m.disabled,error:m.error,filled:m.filled,focused:m.focused,required:m.required};delete h.ownerState;let g=my(h);return(0,W.jsx)(hy,{as:a,className:G(g.root,i),ref:t,...p,ownerState:h,children:r===` `?py||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):r})}),_y=Du;function vy(e,t){if(t==null){e.focus();return}try{e.focus({focusVisible:t===`keyboard`})}catch{e.focus()}}function yy(e){return e?e.type===`mousedown`||e.type===`pointerdown`||e.type===`touchstart`?`pointer`:e.type===`keydown`||e.type===`click`&&e.detail===0?`keyboard`:null:null}function by(e){return e==null||typeof e==`string`&&!e.trim()}function xy(e,t){return typeof t==`object`&&t?e===t:String(e)===String(t)}var Sy=v.createContext(null);function Cy(){return v.useContext(Sy)}var wy=Sy.Provider,Ty=v.createContext(void 0);function Ey(){let e=v.useContext(Ty);if(e===void 0)throw Error(`MUI: MenuListContext is missing. MenuItems must be placed within Menu or MenuList.`);return e}function Dy(e){let t=e?.element??e;if(!t)return``;if(e?.textValue!==void 0)return e.textValue;let n=t.innerText;return n===void 0&&(n=t.textContent),n??``}function Oy(e,t){if(t===void 0)return!0;let n=Dy(e);return n=n.trim().toLowerCase(),n.length===0?!1:t.repeating?n[0]===t.keys[0]:n.startsWith(t.keys.join(``))}function ky(e,t){return Oy(e,t)?Kf(e):!1}function Ay(e,t){vy(e,t)}var jy=v.forwardRef(function(e,t){let{actions:n,autoFocus:r=!1,autoFocusItem:i=!1,children:a,className:o,disabledItemsFocusable:s=!1,disableListWrap:c=!1,onKeyDown:l,variant:u=`selectedMenu`,...d}=e,f=v.useRef(null),p=v.useRef(!1),[m,h]=v.useState(!1),g=Cy(),_=v.useRef({keys:[],repeating:!0,previousKeyMatched:!0,lastTime:null}),y=Mf({activeItemId:void 0,getDefaultActiveItemId:v.useCallback(e=>u===`selectedMenu`?e.find(e=>e.selected&&Kf(e))?.id??e.find(e=>Kf(e))?.id??null:e.find(e=>Kf(e))?.id??null,[u]),orientation:`vertical`,wrap:!c}),{activeItemId:b,focusNext:x,getActiveItem:S,getContainerProps:C,getItemMap:w}=y,T=ul((e=!1)=>{if(!f.current||!e&&p.current)return null;if(i){let e=S();if(e?.element){let t=Array.from(w().values()).some(e=>e.selected),n=u===`menu`&&t&&!e.selected&&g==null;return h(n),Ay(e.element,g),p.current=!0,e.element}return r?(h(!1),f.current.focus(),f.current):null}return r?(h(!1),f.current.focus(),p.current=!0,f.current):(h(!1),null)});ys(()=>{if(!r&&!i){p.current=!1,h(!1);return}T()},[b,i,r,T]),v.useImperativeHandle(n,()=>({adjustStyleForScrollbar:(e,{direction:t})=>{let n=!f.current.style.width;if(e.clientHeight<f.current.clientHeight&&n){let n=`${_y(wd(e))}px`;f.current.style[t===`rtl`?`paddingLeft`:`paddingRight`]=n,f.current.style.width=`calc(100% + ${n})`}return f.current},focusInitialTarget:()=>{if(!f.current)return null;let e=Ss(bs(f.current));return e&&Ru(f.current,e)?e:T(!0)}}),[T]);let E=C(void 0,d.onFocus),D=vs(f,E.ref,t),O=v.useMemo(()=>({itemsFocusableWhenDisabled:s,suppressInitialFocusVisible:m,variant:u}),[s,m,u]),k=ul(e=>{if(m&&h(!1),(e.ctrlKey||e.metaKey||e.altKey)&&l){l(e);return}if(E.onKeyDown(e),e.key.length===1){let t=_.current,n=e.key.toLowerCase(),r=performance.now();t.keys.length>0&&(r-t.lastTime>500?(t.keys=[],t.repeating=!0,t.previousKeyMatched=!0):t.repeating&&n!==t.keys[0]&&(t.repeating=!1)),t.lastTime=r,t.keys.push(n);let i=Ss(bs(f.current)),a=i&&!t.repeating&&Oy(i,t);t.previousKeyMatched&&(a||x(e=>ky(e,t))!=null)?e.preventDefault():t.previousKeyMatched=!1}l&&l(e)});return(0,W.jsx)(nf,{role:`menu`,ref:D,className:o,onKeyDown:k,tabIndex:-1,...d,onFocus:E.onFocus,children:(0,W.jsx)(Ty.Provider,{value:O,children:(0,W.jsx)(Df.Provider,{value:y,children:a})})})});function My(e){return K(`MuiPopover`,e)}Wr(`MuiPopover`,[`root`,`paper`]);function Ny(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.height/2:t===`bottom`&&(n=e.height),n}function Py(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.width/2:t===`right`&&(n=e.width),n}function Fy(e){return[e.horizontal,e.vertical].map(e=>typeof e==`number`?`${e}px`:e).join(` `)}function Iy(e){return typeof e==`function`?e():e}var Ly=e=>{let{classes:t}=e;return va({root:[`root`],paper:[`paper`]},My,t)},Ry=J(xd,{name:`MuiPopover`,slot:`Root`})({}),zy=J(Mc,{name:`MuiPopover`,slot:`Paper`})({position:`absolute`,overflowY:`auto`,overflowX:`hidden`,minWidth:16,minHeight:16,maxWidth:`calc(100% - 32px)`,maxHeight:`calc(100% - 32px)`,outline:0}),By=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiPopover`}),{action:r,anchorEl:i,anchorOrigin:a={vertical:`top`,horizontal:`left`},anchorPosition:o,anchorReference:s=`anchorEl`,children:c,className:l,container:u,disableAutoFocus:d=!1,elevation:f=8,marginThreshold:p=16,open:m,slots:h={},slotProps:g={},transformOrigin:_={vertical:`top`,horizontal:`left`},transitionDuration:y=`auto`,disableScrollLock:b=!1,...x}=n,S=v.useRef(),C={...n,anchorOrigin:a,anchorReference:s,elevation:f,marginThreshold:p,transformOrigin:_,transitionDuration:y},w=Ly(C),T=v.useCallback(()=>{if(s===`anchorPosition`)return o;let e=Iy(i),t=(e&&e.nodeType===1?e:bs(S.current).body).getBoundingClientRect();return{top:t.top+Ny(t,a.vertical),left:t.left+Py(t,a.horizontal)}},[i,a.horizontal,a.vertical,o,s]),E=v.useCallback(e=>({vertical:Ny(e,_.vertical),horizontal:Py(e,_.horizontal)}),[_.horizontal,_.vertical]),D=v.useCallback(e=>{let t={width:e.offsetWidth,height:e.offsetHeight},n=E(t);if(s===`none`)return{top:null,left:null,transformOrigin:Fy(n)};let r=T(),a=r.top-n.vertical,o=r.left-n.horizontal,c=a+t.height,l=o+t.width,u=wd(Iy(i)),d=u.innerHeight-p,f=u.innerWidth-p;if(p!=null&&a<p){let e=a-p;a-=e,n.vertical+=e}else if(p!=null&&c>d){let e=c-d;a-=e,n.vertical+=e}if(p!=null&&o<p){let e=o-p;o-=e,n.horizontal+=e}else if(l>f){let e=l-f;o-=e,n.horizontal+=e}return{top:`${Math.round(a)}px`,left:`${Math.round(o)}px`,transformOrigin:Fy(n)}},[i,s,T,E,p]),[O,k]=v.useState(m),A=v.useCallback(()=>{let e=S.current;if(!e)return;let t=D(e);t.top!=null&&e.style.setProperty(`top`,t.top),t.left!=null&&(e.style.left=t.left),e.style.transformOrigin=t.transformOrigin,k(!0)},[D]);v.useEffect(()=>(b&&window.addEventListener(`scroll`,A),()=>window.removeEventListener(`scroll`,A)),[i,b,A]);let j=()=>{A()},M=()=>{k(!1)};v.useEffect(()=>{m&&A()}),v.useImperativeHandle(r,()=>m?{updatePosition:()=>{A()}}:null,[m,A]),v.useEffect(()=>{if(!m)return;let e=Sd(()=>{A()}),t=wd(Iy(i));return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[i,m,A]);let N=y,P={slots:h,slotProps:g},[F,I]=Jc(`transition`,{elementType:mp,externalForwardedProps:P,ownerState:C,getSlotProps:e=>({...e,onEntering:(t,n)=>{e.onEntering?.(t,n),j()},onExited:t=>{e.onExited?.(t),M()}}),additionalProps:{appear:!0,in:m}});y===`auto`&&!F.muiSupportAuto&&(N=void 0);let L=u||(i?bs(Iy(i)).body:void 0),[R,{slots:ee,slotProps:te,...ne}]=Jc(`root`,{ref:t,elementType:Ry,externalForwardedProps:{...P,...x},shouldForwardComponentProp:!0,additionalProps:{slots:{backdrop:h.backdrop},slotProps:{backdrop:Od(typeof g.backdrop==`function`?g.backdrop(C):g.backdrop,{invisible:!0})},container:L,open:m},ownerState:C,className:G(w.root,l)}),[z,B]=Jc(`paper`,{ref:S,className:w.paper,elementType:zy,externalForwardedProps:P,shouldForwardComponentProp:!0,additionalProps:{elevation:f,style:O?void 0:{opacity:0}},ownerState:C});return(0,W.jsx)(R,{...ne,...!rs(R)&&{slots:ee,slotProps:te,disableAutoFocus:d,disableScrollLock:b},children:(0,W.jsx)(F,{...I,timeout:N,children:(0,W.jsx)(z,{...B,children:c})})})});function Vy(e){return K(`MuiMenu`,e)}Wr(`MuiMenu`,[`root`,`paper`,`list`]);var Hy={vertical:`top`,horizontal:`right`},Uy={vertical:`top`,horizontal:`left`},Wy=e=>{let{classes:t}=e;return va({root:[`root`],paper:[`paper`],list:[`list`]},Vy,t)},Gy=J(By,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiMenu`,slot:`Root`})({}),Ky=J(zy,{name:`MuiMenu`,slot:`Paper`})({maxHeight:`calc(100% - 96px)`,WebkitOverflowScrolling:`touch`}),qy=J(jy,{name:`MuiMenu`,slot:`List`})({outline:0}),Jy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiMenu`}),{autoFocus:r=!0,children:i,className:a,disableAutoFocusItem:o=!1,onClose:s,open:c,PopoverClasses:l,transitionDuration:u=`auto`,variant:d=`selectedMenu`,slots:f={},slotProps:p={},...m}=n,h=Ii(),g={...n,autoFocus:r,disableAutoFocusItem:o,transitionDuration:u,variant:d},_=Wy(g),y=r&&c,b=y&&!o,x=v.useRef(null),S=(e,t)=>{x.current&&(x.current.adjustStyleForScrollbar(e,{direction:h?`rtl`:`ltr`}),y&&x.current.focusInitialTarget?.())},C=e=>{e.key===`Tab`&&(e.preventDefault(),s&&s(e,`tabKeyDown`))},w={slots:f,slotProps:p},T=lh({elementType:f.root,externalSlotProps:p.root,ownerState:g,className:[_.root,a]}),[E,D]=Jc(`paper`,{className:_.paper,elementType:Ky,externalForwardedProps:w,shouldForwardComponentProp:!0,ownerState:g}),[O,k]=Jc(`list`,{className:_.list,elementType:qy,shouldForwardComponentProp:!0,externalForwardedProps:w,getSlotProps:e=>({...e,onKeyDown:t=>{C(t),e.onKeyDown?.(t)}}),ownerState:g}),A=typeof p.transition==`function`?p.transition(g):p.transition;return(0,W.jsx)(Gy,{disableAutoFocus:r,onClose:s,anchorOrigin:{vertical:`bottom`,horizontal:h?`right`:`left`},transformOrigin:h?Hy:Uy,slots:{root:f.root,paper:E,backdrop:f.backdrop,transition:f.transition},slotProps:{root:T,paper:D,backdrop:typeof p.backdrop==`function`?p.backdrop(g):p.backdrop,transition:{...A,onEntering:(...e)=>{S(...e),A?.onEntering?.(...e)}}},open:c,ref:t,transitionDuration:u,ownerState:g,...m,classes:l,children:(0,W.jsx)(O,{actions:x,autoFocus:y,autoFocusItem:b,variant:d,...k,children:i})})}),Yy=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return va({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,`icon${Y(n)}`,a&&`iconOpen`,r&&`disabled`]},pc,t)},Xy=J(`select`,{name:`MuiNativeSelect`})(({theme:e})=>({MozAppearance:`none`,WebkitAppearance:`none`,userSelect:`none`,borderRadius:0,cursor:`pointer`,"&:focus":{borderRadius:0},[`&.${mc.disabled}`]:{cursor:`default`},"&[multiple]":{height:`auto`},"&:not([multiple]) option, &:not([multiple]) optgroup":{backgroundColor:(e.vars||e).palette.background.paper},[`& ~ .${kv.root}`]:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,right:`calc(var(--_caret, 24px) + (var(--_endAdornment, 28px) - 1.5rem)/2)`},[`.${Ds.root}:has(> &)`]:{"--_endAdornment":`0px`},variants:[{props:({ownerState:e})=>e.variant!==`filled`&&e.variant!==`outlined`,style:{[`.${Ds.root}:has(> &)`]:{"--_caret":`24px`},[`.${Ds.root}:has(> & ~ .${kv.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 24px) + var(--_endAdornment, 0px))`,minWidth:16}}},{props:{variant:`filled`},style:{[`.${Ds.root}:has(> &)`]:{"--_caret":`32px`},[`.${Ds.root}:has(> & ~ .${kv.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}},{props:{variant:`outlined`},style:{[`.${Ds.root}:has(> &)`]:{"--_caret":`32px`},[`.${Ds.root}:has(> & ~ .${kv.root})`]:{"--_endAdornment":`28px`},borderRadius:(e.vars||e).shape.borderRadius,"&:focus":{borderRadius:(e.vars||e).shape.borderRadius},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}}]})),Zy=J(Xy,{name:`MuiNativeSelect`,slot:`Select`,shouldForwardProp:Ko,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.select,t[n.variant],n.error&&t.error,{[`&.${mc.multiple}`]:t.multiple}]}})({}),Qy=J(`svg`,{name:`MuiNativeSelect`})(({theme:e})=>({position:`absolute`,right:0,top:`calc(50% - .5em)`,pointerEvents:`none`,color:(e.vars||e).palette.action.active,[`&.${mc.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:({ownerState:e})=>e.open,style:{transform:`rotate(180deg)`}},{props:{variant:`filled`},style:{right:7}},{props:{variant:`outlined`},style:{right:7}}]})),$y=J(Qy,{name:`MuiNativeSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.variant&&t[`icon${Y(n.variant)}`],n.open&&t.iconOpen]}})({}),eb=v.forwardRef(function(e,t){let{className:n,disabled:r,error:i,IconComponent:a,inputRef:o,variant:s=`standard`,...c}=e,l={...e,disabled:r,variant:s,error:i},u=Yy(l);return(0,W.jsxs)(v.Fragment,{children:[(0,W.jsx)(Zy,{ownerState:l,className:G(u.select,n),disabled:r,ref:o||t,...c}),e.multiple?null:(0,W.jsx)($y,{as:a,ownerState:l,className:u.icon})]})});function tb(e){return Object.prototype.hasOwnProperty.call(e.props,`value`)}function nb(e){if(typeof e==`string`||typeof e==`number`)return String(e);let t=``;return v.Children.forEach(e,e=>{typeof e==`string`||typeof e==`number`?t+=String(e):v.isValidElement(e)&&(t+=nb(e.props.children))}),t}function rb(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length;for(let n=0;n<e.length;n+=1){let i=(r+n)%e.length;if(e[i].label.startsWith(t))return i}return-1}function ib(e,t){return!e.some(e=>e.label[0]===t&&e.label[1]===t)}function ab(e,t){let n=[],r=-1;for(let i=0;i<e.length;i+=1){let a=e[i];if(!v.isValidElement(a)||!tb(a)||a.props.disabled)continue;let o=nb(a.props.children).trim().toLowerCase();o!==``&&(r===-1&&xy(t,a.props.value)&&(r=n.length),n.push({child:a,label:o,value:a.props.value}))}return{options:n,selectedIndex:r}}var ob,sb=2,cb=400,lb=200,ub=750,db=` `,fb=`ArrowUp`,pb=`ArrowDown`,mb=`Enter`;function hb(e,t){if(!t)return!1;if(e.composedPath().includes(t)||e.target?.nodeType&&t.contains(e.target))return!0;let n=t.getBoundingClientRect();return n.width===0&&n.height===0?!1:e.clientX>=n.left-sb&&e.clientX<=n.right+sb&&e.clientY>=n.top-sb&&e.clientY<=n.bottom+sb}var gb=J(Xy,{name:`MuiSelect`,slot:`Select`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`&.${Hv.select}`]:t.select},{[`&.${Hv.select}`]:t[n.variant]},{[`&.${Hv.error}`]:t.error},{[`&.${Hv.multiple}`]:t.multiple}]}})({[`&.${Hv.select}`]:{height:`auto`,minHeight:`1.4375em`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`}}),_b=J(Qy,{name:`MuiSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.open&&t.iconOpen]}})({}),vb=J(`input`,{shouldForwardProp:e=>Go(e)&&e!==`classes`,name:`MuiSelect`,slot:`NativeInput`})({bottom:0,left:0,position:`absolute`,opacity:0,pointerEvents:`none`,width:`100%`,boxSizing:`border-box`}),yb=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return va({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,a&&`iconOpen`,r&&`disabled`],nativeInput:[`nativeInput`]},Vv,t)},bb=v.forwardRef(function(e,t){let{"aria-describedby":n,"aria-label":r,autoFocus:i,autoWidth:a,children:o,className:s,defaultOpen:c,defaultValue:l,disabled:u,displayEmpty:d,error:f=!1,IconComponent:p,inputRef:m,labelId:h,MenuProps:g={},multiple:_,name:y,onBlur:b,onChange:x,onClose:S,onFocus:C,onKeyDown:w,onMouseDown:T,onOpen:E,open:D,readOnly:O,renderValue:k,required:A,SelectDisplayProps:j={},tabIndex:M,type:N,value:P,variant:F=`standard`,...I}=e,[L,R]=Dd({controlled:P,default:l,name:`Select`}),[ee,te]=Dd({controlled:D,default:c,name:`Select`}),ne=v.useRef(null),z=v.useRef(null),B=v.useRef(null),V=v.useRef(!1),re=v.useRef(!1),ie=v.useRef(null),ae=v.useRef(!1),oe=v.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),se=v.useRef({buffer:``,previousSearchIndex:null,matchedIndex:null}),H=Sl(),ce=Sl(),le=Sl(),[ue,de]=v.useState(null),{current:fe}=v.useRef(D!=null),[pe,me]=v.useState(),[he,U]=v.useState(null),ge=vs(t,m),_e=v.useCallback(e=>{z.current=e,e&&de(e)},[]),ve=ue?.parentNode;v.useImperativeHandle(ge,()=>({focus:()=>{z.current.focus()},node:ne.current,value:L}),[L]);let ye=ue!==null&&ee,be=v.useCallback(()=>{le.clear(),se.current.buffer=``,se.current.previousSearchIndex=null,se.current.matchedIndex=null},[le]);ys(()=>{V.current=ye,ye&&be()},[ye,be]);let xe=v.useCallback(()=>{H.clear(),ce.clear()},[H,ce]),Se=v.useCallback(()=>{xe(),ae.current=!1,oe.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},[xe]),Ce=v.useCallback(()=>{ie.current&&=(ie.current(),null)},[]);v.useEffect(()=>{ye||(Se(),Ce())},[ye,Se,Ce]),v.useEffect(()=>()=>{Se(),Ce(),be()},[Se,Ce,be]),v.useEffect(()=>{if(!ye||!ve||a||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{me(ve.clientWidth)});return e.observe(ve),()=>{e.disconnect()}},[ye,ve,a]),v.useEffect(()=>{c&&ee&&ue&&!fe&&(me(a?null:ve.clientWidth),z.current.focus())},[ue,a]),v.useEffect(()=>{i&&z.current.focus()},[i]),v.useEffect(()=>{if(!h)return;let e=bs(z.current).getElementById(h);if(e){let t=()=>{getSelection().isCollapsed&&z.current.focus()};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}},[h]);let we=ul((e,t)=>{e||(Se(),Ce()),e?(be(),U(yy(t)),E&&E(t)):(U(null),S&&S(t)),fe||(V.current=e,me(a?null:ve.clientWidth),te(e))}),Te=()=>{Se(),re.current?ce.start(lb,()=>{oe.current.allowUnselectedMouseUp=!0,H.start(lb,()=>{oe.current.allowSelectedMouseUp=!0})}):H.start(cb,()=>{oe.current.allowSelectedMouseUp=!0,oe.current.allowUnselectedMouseUp=!0})},Ee=e=>{if(T?.(e),e.button!==0||(e.preventDefault(),!z.current))return;z.current.focus();let t=bs(e.currentTarget);Te(),Ce();let n=e=>{ie.current=null,z.current&&(hb(e,z.current)||hb(e,B.current)||!V.current&&fe||we(!1,e))};t.addEventListener(`mouseup`,n,{capture:!0,once:!0}),ie.current=()=>{t.removeEventListener(`mouseup`,n,!0)},we(!0,e)},De=e=>{we(!1,e)},Oe=v.Children.toArray(o),ke=e=>{let t=Oe.find(t=>t.props.value===e.target.value);t!==void 0&&(R(t.props.value),x&&x(e,t))},Ae=(e,t,n)=>{if(R(n),x){let r=e.nativeEvent||e,i=new r.constructor(r.type,r);Object.defineProperty(i,"target",{writable:!0,value:{value:n,name:y}}),x(i,t)}},je=e=>t=>{ae.current=!1;let n;if(t.currentTarget.hasAttribute(`tabindex`)){if(_){n=Array.isArray(L)?L.slice():[];let t=L.indexOf(e.props.value);t===-1?n.push(e.props.value):n.splice(t,1)}else n=e.props.value;e.props.onClick&&e.props.onClick(t),L!==n&&Ae(t,e,n),_||we(!1,t)}},Me=(e,t)=>n=>{if(e.props.onMouseUp?.(n),ae.current){ae.current=!1;return}let r=!oe.current.allowSelectedMouseUp&&t,i=!oe.current.allowUnselectedMouseUp&&!t;r||i||n.currentTarget.click()},Ne=e=>{let t=se.current,n=t.buffer!==``;if(ye||_||u||e.defaultPrevented||e.nativeEvent?.isComposing||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||e.key===db&&!n)return!1;e.key===db&&e.preventDefault();let r=t.buffer===``,{options:i,selectedIndex:a}=ab(Oe,L);if(i.length===0)return e.key!==db&&be(),!0;r&&(t.previousSearchIndex=a);let o=e.key.toLowerCase();t.buffer===o&&ib(i,o)&&(t.buffer=``,t.previousSearchIndex=t.matchedIndex),t.buffer+=o,le.start(ub,be);let s=rb(i,t.buffer,(t.previousSearchIndex??-1)+1);if(s!==-1){let n=i[s];return t.matchedIndex=s,xy(L,n.value)||Ae(e,n.child,n.value),!0}return e.key!==db&&be(),!0},Pe=e=>{if(!O){let t=Ne(e),n=e.key===db||e.key===fb||e.key===pb||e.key===mb;!t&&n&&(e.preventDefault(),we(!0,e)),w?.(e)}},Fe=e=>{be(),!ye&&b&&(Object.defineProperty(e,"target",{writable:!0,value:{value:L,name:y}}),b(e))},Ie=e=>t=>{e?.props?.onKeyDown?.(t),t.key===db&&t.target===t.currentTarget&&!t.defaultPrevented&&(t.preventDefault(),t.repeat||t.currentTarget.click())};delete I[`aria-invalid`];let Le,Re,ze=[],Be=!1,Ve=!1;(ws({value:L})||d)&&(k?Le=k(L):Be=!0);let He=Oe.map(e=>{if(!v.isValidElement(e))return null;let t;if(_){if(!Array.isArray(L))throw Error(It(2));t=L.some(t=>xy(t,e.props.value)),t&&Be&&ze.push(e.props.children)}else t=xy(L,e.props.value),t&&Be&&(Re=e.props.children);return t&&(Ve=!0),v.cloneElement(e,{"aria-selected":t?`true`:`false`,onMouseDown:t=>{ae.current=!0,e.props.onMouseDown?.(t)},onPointerDown:t=>{ae.current=!0,e.props.onPointerDown?.(t)},onClick:je(e),onMouseUp:Me(e,t),onKeyUp:t=>{t.key===db&&t.preventDefault(),e.props.onKeyUp&&e.props.onKeyUp(t)},onKeyDown:Ie(e),role:`option`,selected:t,value:void 0,"data-value":e.props.value})});ys(()=>{re.current=Ve,!ye&&!_&&!Ve&&be()},[Ve,_,ye,be]),Be&&(Le=_?ze.length===0?null:ze.reduce((e,t,n)=>(e.push(t),n<ze.length-1&&e.push(`, `),e),[]):Re);let Ue=pe;!a&&fe&&ue&&(Ue=ve.clientWidth);let We;We=M===void 0?u?null:0:M;let Ge=j.id||(y?`mui-component-select-${y}`:void 0),Ke={...e,variant:F,value:L,open:ye,error:f},qe=yb(Ke),Je=typeof g.slotProps?.paper==`function`?g.slotProps.paper(Ke):g.slotProps?.paper,Ye=vs(Je?.ref,B),Xe=typeof g.slotProps?.list==`function`?g.slotProps.list(Ke):g.slotProps?.list,Ze=Wi(),Qe=Wi();return(0,W.jsxs)(v.Fragment,{children:[(0,W.jsx)(gb,{as:`div`,ref:_e,tabIndex:We,role:`combobox`,"aria-controls":ye?Ze:void 0,"aria-disabled":u?`true`:void 0,"aria-expanded":ye?`true`:`false`,"aria-haspopup":`listbox`,"aria-readonly":O?`true`:void 0,"aria-label":r,"aria-labelledby":h,"aria-describedby":n,"aria-required":A?`true`:void 0,"aria-invalid":f?`true`:void 0,onKeyDown:Pe,onMouseDown:u||O?null:Ee,onBlur:Fe,onFocus:C,...j,ownerState:Ke,className:G(j.className,qe.select,s),id:Ge,children:by(Le)?ob||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):Le}),(0,W.jsx)(vb,{"aria-invalid":f,value:Array.isArray(L)?L.join(`,`):L,name:y,ref:ne,"aria-hidden":!0,onChange:ke,tabIndex:-1,disabled:u,readOnly:O,className:qe.nativeInput,autoFocus:i,required:A,...I,id:I.id??Qe,ownerState:Ke}),(0,W.jsx)(_b,{as:p,className:qe.icon,ownerState:Ke}),(0,W.jsx)(wy,{value:he,children:(0,W.jsx)(Jy,{id:`menu-${y||``}`,anchorEl:ve,open:ye,onClose:De,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},...g,slotProps:{...g.slotProps,list:{"aria-labelledby":h,role:`listbox`,"aria-multiselectable":_?`true`:void 0,disableListWrap:!0,id:Ze,...Xe},paper:{...Je,ref:Ye,style:{minWidth:Ue,...Je?.style}}},children:He})})]})}),xb=sl((0,W.jsx)(`path`,{d:`M7 10l5 5 5-5z`}),`ArrowDropDown`),Sb=e=>{let{classes:t}=e,n=va({root:[`root`]},Vv,t);return{...t,...n}},Cb={name:`MuiSelect`,slot:`Root`,shouldForwardProp:e=>Ko(e)&&e!==`variant`},wb=J(Bv,Cb)(``),Tb=J(ty,Cb)(``),Eb=J(Kv,Cb)(``),Db=v.forwardRef(function(e,t){let n=Jo({name:`MuiSelect`,props:e}),{autoWidth:r=!1,children:i,classes:a={},className:o,defaultOpen:s=!1,displayEmpty:c=!1,IconComponent:l=xb,id:u,input:d,inputProps:f,label:p,labelId:m,MenuProps:h,multiple:g=!1,native:_=!1,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:C,variant:w=`outlined`,...T}=n,E=_?eb:bb,[D]=gs({props:n,states:[`variant`,`error`]}),O=D.variant||w,k={...n,variant:O,classes:a},A=Sb(k),{root:j,...M}=A,N=d||{standard:(0,W.jsx)(wb,{ownerState:k}),outlined:(0,W.jsx)(Tb,{label:p,ownerState:k}),filled:(0,W.jsx)(Eb,{ownerState:k})}[O],P=vs(t,Iu(N));return(0,W.jsx)(v.Fragment,{children:v.cloneElement(N,{inputComponent:E,inputProps:{children:i,error:D.error,IconComponent:l,variant:O,type:void 0,multiple:g,..._?{id:u}:{autoWidth:r,defaultOpen:s,displayEmpty:c,labelId:m,MenuProps:h,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:{id:u,...C}},...f,classes:f?Ut(M,f.classes):M,...d?d.props.inputProps:{}},...(g&&_||c)&&O===`outlined`?{notched:!0}:{},ref:P,className:G(N.props.className,o,A.root),...!d&&{variant:O},...T})})});Db.muiName=`Select`;function Ob(e){return K(`MuiTextField`,e)}Wr(`MuiTextField`,[`root`]);var kb={standard:Bv,filled:Kv,outlined:ty},Ab=e=>{let{classes:t}=e;return va({root:[`root`]},Ob,t)},jb=J(fy,{name:`MuiTextField`,slot:`Root`})({}),Mb=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTextField`}),{autoComplete:r,autoFocus:i=!1,children:a,className:o,color:s=`primary`,defaultValue:c,disabled:l=!1,error:u=!1,fullWidth:d=!1,helperText:f,id:p,inputRef:m,label:h,maxRows:g,minRows:_,multiline:v=!1,name:y,onBlur:b,onChange:x,onFocus:S,placeholder:C,required:w=!1,rows:T,select:E=!1,slots:D={},slotProps:O={},type:k,value:A,variant:j=`outlined`,...M}=n,N={...n,autoFocus:i,color:s,disabled:l,error:u,fullWidth:d,multiline:v,required:w,select:E,variant:j},P=Ab(N),F=Wi(p),I=f&&F?`${F}-helper-text`:void 0,L=h&&F?`${F}-label`:void 0,R=kb[j],ee={slots:D,slotProps:O},[te,ne]=Jc(`select`,{elementType:Db,externalForwardedProps:ee,ownerState:N}),z=E&&ne.native,B={},V=ee.slotProps.inputLabel;j===`outlined`&&(V&&V.shrink!==void 0&&(B.notched=V.shrink),B.label=h),E&&(z||(B.id=void 0),B[`aria-describedby`]=void 0);let[re,ie]=Jc(`root`,{elementType:jb,shouldForwardComponentProp:!0,externalForwardedProps:{...ee,...M},ownerState:N,className:G(P.root,o),ref:t,additionalProps:{disabled:l,error:u,fullWidth:d,required:w,color:s,variant:j}}),[ae,oe]=Jc(`input`,{elementType:R,externalForwardedProps:ee,additionalProps:B,ownerState:N}),[se,H]=Jc(`inputLabel`,{elementType:cy,externalForwardedProps:ee,ownerState:N}),[ce,le]=Jc(`htmlInput`,{elementType:`input`,externalForwardedProps:ee,ownerState:N}),[ue,de]=Jc(`formHelperText`,{elementType:gy,externalForwardedProps:ee,ownerState:N}),fe=(0,W.jsx)(ae,{"aria-describedby":I,autoComplete:r,autoFocus:i,defaultValue:c,fullWidth:d,multiline:v,name:y,rows:T,maxRows:g,minRows:_,type:k,value:A,id:F,inputRef:m,onBlur:b,onChange:x,onFocus:S,placeholder:C,inputProps:le,slots:{input:D.htmlInput?ce:void 0},...oe});return(0,W.jsxs)(re,{...ie,children:[h!=null&&h!==``&&(0,W.jsx)(se,{htmlFor:E&&!z?void 0:F,id:L,...E&&!z&&{component:`div`},...H,children:h}),E?(0,W.jsx)(te,{"aria-describedby":I,id:F,labelId:L,value:A,input:fe,...ne,children:a}):fe,f&&(0,W.jsx)(ue,{id:I,...de,children:f})]})}),Nb=sl((0,W.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`),Pb=`modulepreload`,Fb=function(e){return`/`+e},Ib={},Lb=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=Fb(t,n),t=s(t),t in Ib)return;Ib[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`:Pb,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)})},Rb=(0,v.lazy)(async()=>({default:(await Lb(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-CxeZqTte.js`);return{MarkdownMessage:e}},[])).MarkdownMessage})),zb=new Set([`md`,`markdown`]),Bb=new Set([`csv`,`tsv`]);function Vb(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function Hb(e,t){return e.source===`project`?$(t,`Project`,`Project`):$(t,`Thư mục đã cấp quyền`,`Granted directory`)}function Ub(e,t){let n=[],r=[],i=``,a=!1,o=0,s=()=>{r.length<40&&r.push(i),i=``},c=()=>{s(),r.some(e=>e.length>0)&&n.push(r),r=[]};for(;o<e.length&&n.length<500;){let n=e[o];if(a){if(n===`"`&&e[o+1]===`"`){i+=`"`,o+=2;continue}if(n===`"`){a=!1,o+=1;continue}i+=n,o+=1;continue}if(n===`"`&&i.length===0){a=!0,o+=1;continue}if(n===t){s(),o+=1;continue}if(n===`
171
+ `,hu=e=>{let{classes:t,variant:n,color:r,disableShrink:i}=e;return va({root:[`root`,n,`color${Y(r)}`],svg:[`svg`],track:[`track`],circle:[`circle`,i&&`circleDisableShrink`]},lu,t)},gu=J(`span`,{name:`MuiCircularProgress`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`color${Y(n.color)}`]]}})(_s(({theme:e})=>{let t=Us(e,{animation:`none`});return{display:`inline-block`,variants:[{props:{variant:`determinate`},style:{...Ws(e,`transform`)}},{props:{variant:`indeterminate`},style:pu||{animation:`${du} 1.4s linear infinite`}},...t?[{props:{variant:`indeterminate`},style:t}]:[],...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}}))]}})),_u=J(`svg`,{name:`MuiCircularProgress`,slot:`Svg`})({display:`block`}),vu=J(`circle`,{name:`MuiCircularProgress`,slot:`Circle`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.circle,n.disableShrink&&t.circleDisableShrink]}})(_s(({theme:e})=>{let t=Us(e,{animation:`none`});return{stroke:`currentColor`,variants:[{props:{variant:`determinate`},style:{...Ws(e,`stroke-dashoffset`)}},{props:{variant:`indeterminate`},style:{strokeDasharray:`80px, 200px`,strokeDashoffset:0}},{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:mu||{animation:`${fu} 1.4s ease-in-out infinite`}},...t?[{props:({ownerState:e})=>e.variant===`indeterminate`&&!e.disableShrink,style:t}]:[]]}})),yu=J(`circle`,{name:`MuiCircularProgress`,slot:`Track`})(_s(({theme:e})=>({stroke:`currentColor`,opacity:(e.vars||e).palette.action.activatedOpacity}))),bu=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiCircularProgress`}),{className:r,color:i=`primary`,disableShrink:a=!1,enableTrackSlot:o=!1,min:s,max:c,size:l=40,style:u,thickness:d=3.6,value:f=n.min??0,variant:p=`indeterminate`,...m}=n,h=s??0,g=c??100,_={...n,color:i,disableShrink:a,size:l,thickness:d,value:f,variant:p,enableTrackSlot:o},v=hu(_),y={},b={},x={};if(p===`determinate`){let e=2*Math.PI*((uu-d)/2),t=g-h;y.strokeDasharray=e.toFixed(3),y.strokeDashoffset=t>0?`${((g-f)/t*e).toFixed(3)}px`:`${e.toFixed(3)}px`,b.transform=`rotate(-90deg)`,x[`aria-valuenow`]=f,x[`aria-valuemin`]=h,x[`aria-valuemax`]=g}return(0,W.jsx)(gu,{className:G(v.root,r),style:{width:l,height:l,...b,...u},ownerState:_,ref:t,role:`progressbar`,...x,...m,children:(0,W.jsxs)(_u,{className:v.svg,ownerState:_,viewBox:`${uu/2} ${uu/2} ${uu} ${uu}`,children:[o?(0,W.jsx)(yu,{className:v.track,ownerState:_,cx:uu,cy:uu,r:(uu-d)/2,fill:`none`,strokeWidth:d,"aria-hidden":`true`}):null,(0,W.jsx)(vu,{className:v.circle,style:y,ownerState:_,cx:uu,cy:uu,r:(uu-d)/2,fill:`none`,strokeWidth:d})]})})});function xu(e){return K(`MuiDivider`,e)}var Su=Wr(`MuiDivider`,[`root`,`absolute`,`fullWidth`,`inset`,`middle`,`flexItem`,`vertical`,`withChildren`,`textAlignRight`,`textAlignLeft`,`wrapper`,`wrapperVertical`]),Cu=e=>{let{absolute:t,children:n,classes:r,flexItem:i,orientation:a,textAlign:o,variant:s}=e;return va({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`]},xu,r)},wu=J(`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]}})(_s(({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%`}}}]}))),Tu=J(`span`,{name:`MuiDivider`,slot:`Wrapper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.wrapper,n.orientation===`vertical`&&t.wrapperVertical]}})(_s(({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)`}}]}))),Eu=v.forwardRef(function(e,t){let n=Jo({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=Cu(p);return(0,W.jsx)(wu,{as:s,className:G(m.root,a),role:l,ref:t,ownerState:p,"aria-orientation":l===`separator`&&(s!==`hr`||o===`vertical`)?o:void 0,...f,children:i?(0,W.jsx)(Tu,{className:m.wrapper,ownerState:p,children:i}):null})});function Du(e=window){let t=e.document.documentElement.clientWidth;return e.innerWidth-t}function Ou(e){let t=ss(e);return e===t.body||e===t.documentElement?cs(e).innerWidth>t.documentElement.clientWidth:e.scrollHeight>e.clientHeight}function ku(e,t){t?e.setAttribute(`aria-hidden`,`true`):e.removeAttribute(`aria-hidden`)}function Au(e){return parseFloat(cs(e).getComputedStyle(e).paddingRight)||0}function ju(e){let t=[`TEMPLATE`,`SCRIPT`,`STYLE`,`LINK`,`MAP`,`META`,`NOSCRIPT`,`PICTURE`,`COL`,`COLGROUP`,`PARAM`,`SLOT`,`SOURCE`,`TRACK`].includes(e.tagName),n=e.tagName===`INPUT`&&e.getAttribute(`type`)===`hidden`;return t||n}function Mu(e,t,n,r,i){let a=[t,n,...r];[].forEach.call(e.children,e=>{let t=!a.includes(e),n=!ju(e);t&&n&&ku(e,i)})}function Nu(e,t){let n=[],r=e.container;if(!t.disableScrollLock){let e;if(r.parentNode instanceof DocumentFragment)e=ss(r).body;else{let t=r.parentElement,n=cs(r);e=t?.nodeName===`HTML`&&n.getComputedStyle(t).overflowY===`scroll`?t:r}if(Ou(e)){let t=Du(cs(e));n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${Au(e)+t}px`;let i=ss(r).querySelectorAll(`.mui-fixed`);[].forEach.call(i,e=>{n.push({value:e.style.paddingRight,property:`padding-right`,el:e}),e.style.paddingRight=`${Au(e)+t}px`})}n.push({value:e.style.overflow,property:`overflow`,el:e},{value:e.style.overflowX,property:`overflow-x`,el:e},{value:e.style.overflowY,property:`overflow-y`,el:e}),e.style.overflow=`hidden`}return()=>{n.forEach(({value:e,el:t,property:n})=>{e?t.style.setProperty(n,e):t.style.removeProperty(n)})}}function Pu(e){let t=[];return[].forEach.call(e.children,e=>{e.getAttribute(`aria-hidden`)===`true`&&t.push(e)}),t}var Fu=class{constructor(){this.modals=[],this.containers=[]}add(e,t){let n=this.modals.indexOf(e);if(n!==-1)return n;n=this.modals.length,this.modals.push(e),e.modalRef&&ku(e.modalRef,!1);let r=Pu(t);Mu(t,e.mount,e.modalRef,r,!0);let i=this.containers.findIndex(e=>e.container===t);return i===-1?(this.containers.push({modals:[e],container:t,restore:null,hiddenSiblings:r}),n):(this.containers[i].modals.push(e),n)}mount(e,t){let n=this.containers.findIndex(t=>t.modals.includes(e)),r=this.containers[n];r.restore||=Nu(r,t)}remove(e,t=!0){let n=this.modals.indexOf(e);if(n===-1)return n;let r=this.containers.findIndex(t=>t.modals.includes(e)),i=this.containers[r];if(i.modals.splice(i.modals.indexOf(e),1),this.modals.splice(n,1),i.modals.length===0)i.restore&&i.restore(),e.modalRef&&ku(e.modalRef,t),Mu(i.container,e.mount,e.modalRef,i.hiddenSiblings,!1),this.containers.splice(r,1);else{let e=i.modals[i.modals.length-1];e.modalRef&&ku(e.modalRef,!1)}return n}isTopModal(e){return this.modals.length>0&&this.modals[this.modals.length-1]===e}};function Iu(e){return e?.props?.ref||null}function Lu(e,t){if(!e||!t)return!1;if(e.contains(t))return!0;let n=t.getRootNode?.();if(n&&n instanceof ShadowRoot){let n=t;for(;n;){if(e===n)return!0;n=n.parentNode??n.host??null}}return!1}var Ru=Lu,zu=`data-mui-focusable`;function Bu(e){return e?e.hasAttribute(`data-mui-focusable`)?e:e.querySelector(`[${zu}]`):null}var Vu=[`input`,`select`,`textarea`,`a[href]`,`button`,`[tabindex]`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable="false"])`].join(`,`);function Hu(e){let t=parseInt(e.getAttribute(`tabindex`)||``,10);return Number.isNaN(t)?e.contentEditable===`true`||(e.nodeName===`AUDIO`||e.nodeName===`VIDEO`||e.nodeName===`DETAILS`)&&e.getAttribute(`tabindex`)===null?0:e.tabIndex:t}function Uu(e){if(e.tagName!==`INPUT`||e.type!==`radio`||!e.name)return!1;let t=t=>e.ownerDocument.querySelector(`input[type="radio"]${t}`),n=t(`[name="${e.name}"]:checked`);return n||=t(`[name="${e.name}"]`),n!==e}function Wu(e){return!(e.disabled||e.tagName===`INPUT`&&e.type===`hidden`||Uu(e))}function Gu(e){let t=[],n=[];return Array.from(e.querySelectorAll(Vu)).forEach((e,r)=>{let i=Hu(e);i===-1||!Wu(e)||(i===0?t.push(e):n.push({documentOrder:r,tabIndex:i,node:e}))}),n.sort((e,t)=>e.tabIndex===t.tabIndex?e.documentOrder-t.documentOrder:e.tabIndex-t.tabIndex).map(e=>e.node).concat(t)}function Ku(){return!0}function qu(e){let{children:t,disableAutoFocus:n=!1,disableEnforceFocus:r=!1,disableRestoreFocus:i=!1,getTabbable:a=Gu,isEnabled:o=Ku,open:s}=e,c=v.useRef(!1),l=v.useRef(null),u=v.useRef(null),d=v.useRef(null),f=v.useRef(null),p=v.useRef(!1),m=v.useRef(null),h=as(Iu(t),m),g=v.useRef(null);v.useEffect(()=>{!s||!m.current||(p.current=!n)},[n,s]),v.useEffect(()=>{if(c.current=!1,!s||!m.current)return;let e=Ss(ss(m.current)),t=Bu(m.current)??m.current;return Ru(m.current,e)||(t.hasAttribute(`tabIndex`)||t.setAttribute(`tabIndex`,`-1`),p.current&&t.focus()),()=>{!i&&d.current&&(c.current=!0,d.current.focus(),d.current=null)}},[s]),v.useEffect(()=>{if(!s||!m.current)return;let e=ss(m.current),t=t=>{if(g.current=t,r||!o()||t.key!==`Tab`)return;let n=m.current,i=Ss(e);if(n===null)return;let s=Bu(n);if(i===n||i===s){let e=a(n);if(e.length===0)return;t.preventDefault(),t.shiftKey?e[e.length-1].focus():e[0].focus();return}if(Ru(n,i)){let e=a(n),r=e.indexOf(i);if(r===-1||!e.some(e=>Hu(e)>0))return;t.preventDefault();let o=0;o=t.shiftKey?r<=0?e.length-1:r-1:r===e.length-1?0:r+1,e[o].focus()}},n=()=>{let t=m.current;if(t===null)return;let n=Ss(e);if(!e.hasFocus()||!o()||c.current){c.current=!1;return}if(Ru(t,n)||r&&n!==l.current&&n!==u.current)return;if(n!==f.current)f.current=null;else if(f.current!==null)return;if(!p.current)return;let i=[];if((n===l.current||n===u.current)&&(i=a(m.current)),i.length>0){let e=!!(g.current?.shiftKey&&g.current?.key===`Tab`),t=i[0],n=i[i.length-1];typeof t!=`string`&&typeof n!=`string`&&(e?n.focus():t.focus())}else t.focus()};e.addEventListener(`focusin`,n),e.addEventListener(`keydown`,t,!0);let i=setInterval(()=>{let t=Ss(e);t&&t.tagName===`BODY`&&n()},50);return()=>{clearInterval(i),e.removeEventListener(`focusin`,n),e.removeEventListener(`keydown`,t,!0)}},[n,r,i,o,s,a]);let _=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0,f.current=e.target;let n=t.props.onFocus;n&&n(e)},y=e=>{d.current===null&&(d.current=e.relatedTarget),p.current=!0};return(0,W.jsxs)(v.Fragment,{children:[(0,W.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:l,"data-testid":`sentinelStart`}),v.cloneElement(t,{ref:h,onFocus:_}),(0,W.jsx)(`div`,{tabIndex:s?0:-1,onFocus:y,ref:u,"data-testid":`sentinelEnd`})]})}function Ju(e,t){typeof e==`function`?e(t):e&&(e.current=t)}var Yu=l(h(),1);function Xu(e){return typeof e==`function`?e():e}var Zu=v.forwardRef(function(e,t){let{children:n,container:r,disablePortal:i=!1}=e,[a,o]=v.useState(null),s=as(v.isValidElement(n)?Iu(n):null,t);if(oi(()=>{i||o(Xu(r)||document.body)},[r,i]),oi(()=>{if(a&&!i)return Ju(t,a),()=>{Ju(t,null)}},[t,a,i]),i){if(v.isValidElement(n)){let e={ref:s};return v.cloneElement(n,e)}return n}return a&&Yu.createPortal(n,a)});function Qu(e){let t=hl(()=>$u(e)).current;return t.next=e,oi(t.effect),t}function $u(e){let t={current:e,next:e,effect:()=>{t.current=t.next}};return t}var ed=v.createContext(null);function td(e){if(e==null)return{appear:void 0,enter:void 0,exit:void 0};if(typeof e==`number`)return{appear:e,enter:e,exit:e};let t=e.enter,n=e.exit;return{appear:e.appear===void 0?t:e.appear,enter:t,exit:n}}function nd(e){if(e.autoTimeout!=null)return e.autoTimeout;let t=td(e.timeout);return e.currentStatus===`entering`?e.isAppearing?t.appear??t.enter??null:t.enter??null:t.exit??null}function rd(e){let{in:t=!1,appear:n=!1,enter:r=!0,exit:i=!0,mountOnEnter:a=!1,unmountOnExit:o=!1,timeout:s,addEndListener:c,reduceMotion:l=!1,getAutoTimeout:u,nodeRef:d,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,children:y,...b}=e,x=v.useContext(ed),S=x&&!x.isMounting?r:n,[C,w]=v.useState(()=>t?S?`exited`:`entered`:a||o?`unmounted`:`exited`),T=v.useRef(C);T.current=C,t&&C===`unmounted`&&(T.current=`exited`,w(`exited`));let E=v.useRef(t&&S),D=v.useRef(!1),O=v.useRef(null),k=v.useRef(C),A=v.useRef(!1),j=v.useRef(l),M=Qu({timeout:s,addEndListener:c,reduceMotion:l,getAutoTimeout:u,onEnter:f,onEntering:p,onEntered:m,onExit:h,onExiting:g,onExited:_,enter:r,exit:i,mountOnEnter:a,unmountOnExit:o,nodeRef:d,parentGroup:x}),N=v.useCallback(()=>{O.current!==null&&(O.current.cancel(),O.current=null)},[]),P=v.useCallback(e=>{let t=!0,n=()=>{t&&(t=!1,O.current=null,e())};return n.cancel=()=>{t=!1},O.current=n,n},[]),F=v.useCallback((e,t)=>{let n,r=()=>{n!==void 0&&(clearTimeout(n),n=void 0)},i=P(()=>{r(),T.current=e,w(e)}),a=i.cancel;i.cancel=()=>{r(),a()};let o=M.current.nodeRef.current,s=M.current.addEndListener,c=M.current.getAutoTimeout!==void 0,l=M.current.getAutoTimeout?.(),u=nd({currentStatus:t,isAppearing:A.current,timeout:M.current.timeout,autoTimeout:l}),d=j.current,f=u??(d&&c?0:null),p=e=>{n=setTimeout(i,e)};if(!o){p(0);return}if(s){f!=null&&p(d?0:f),s.length>=2?s(o,i):s(i);return}p(d?0:u??0)},[P,M]),I=v.useCallback(e=>{let t=M.current,n=t.parentGroup?t.parentGroup.isMounting:e;if(A.current=n,!e&&!t.enter){T.current=`entered`,w(`entered`);return}j.current=t.reduceMotion,t.onEnter?.(n),T.current=`entering`,w(`entering`)},[M]),L=v.useCallback(()=>{let e=M.current;if(!e.exit){T.current=`exited`,w(`exited`);return}j.current=e.reduceMotion,e.onExit?.(),T.current=`exiting`,w(`exiting`)},[M]),R=v.useCallback((e,t)=>{if(N(),t===`entering`){let t=M.current;if(t.mountOnEnter||t.unmountOnExit){let e=t.nodeRef.current;e&&As(e)}I(e)}else L()},[N,I,L,M]);return oi(()=>(D.current=!0,E.current&&(E.current=!1,R(!0,`entering`)),()=>{D.current=!1,N()}),[N,R]),oi(()=>{if(!D.current)return;let e=T.current;t?e!==`entering`&&e!==`entered`&&R(!1,`entering`):e===`entering`||e===`entered`?R(!1,`exiting`):e===`exited`&&o&&(T.current=`unmounted`,w(`unmounted`))},[t,C,o,R]),oi(()=>{if(C===`unmounted`||k.current===`unmounted`){k.current=C;return}let e=k.current!==C;e&&(k.current=C);let t=M.current;C===`entering`?(e&&t.onEntering?.(A.current),O.current===null&&T.current===C&&F(`entered`,`entering`)):C===`exiting`?(e&&t.onExiting?.(),O.current===null&&T.current===C&&F(`exited`,`exiting`)):C===`entered`&&e?t.onEntered?.(A.current):C===`exited`&&e&&t.onExited?.()},[M,F,C]),C===`unmounted`?null:(0,W.jsx)(ed.Provider,{value:null,children:y(C,b)})}var id={entering:{opacity:1},entered:{opacity:1},exiting:{opacity:0},exited:{opacity:0}},ad={opacity:0,visibility:`hidden`},od=v.forwardRef(function(e,t){let n=Uo(),r={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:i,appear:a=!0,children:o,disablePrefersReducedMotion:s=!1,easing:c,in:l,onEnter:u,onEntered:d,onEntering:f,onExit:p,onExited:m,onExiting:h,style:g,timeout:_=r,...y}=e,b=Il(n.motion.reducedMotion,s),x=v.useRef(null),S=vs(x,Iu(o),t),C=Bs(x,f),w=Bs(x,(e,t)=>{b.shouldReduceMotion||As(e);let r=Hs({style:g,timeout:_,easing:c},{mode:`enter`}),i=b.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`opacity`,{duration:i.duration,easing:r.easing,delay:i.delay}),u&&u(e,t)}),T=Bs(x,d),E=Bs(x,h),D=Bs(x,e=>{let t=Hs({style:g,timeout:_,easing:c},{mode:`exit`}),r=b.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`opacity`,{duration:r.duration,easing:t.easing,delay:r.delay}),p&&p(e)}),O=Bs(x,e=>{e.style.transition=``,m&&m(e)});return(0,W.jsx)(rd,{appear:a,in:l,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:i?e=>{i(x.current,e)}:void 0,reduceMotion:b.shouldReduceMotion,timeout:_,...y,children:(e,{ownerState:t,...n})=>{let r=Vs(e,l,id,ad,g,o.props.style);return v.cloneElement(o,{style:r,ref:S,...n})}})});function sd(e){return K(`MuiBackdrop`,e)}Wr(`MuiBackdrop`,[`root`,`invisible`]);var cd=e=>{let{classes:t,invisible:n}=e;return va({root:[`root`,n&&`invisible`]},sd,t)},ld=J(`div`,{name:`MuiBackdrop`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.invisible&&t.invisible]}})({position:`fixed`,display:`flex`,alignItems:`center`,justifyContent:`center`,right:0,bottom:0,top:0,left:0,backgroundColor:`rgba(0, 0, 0, 0.5)`,WebkitTapHighlightColor:`transparent`,variants:[{props:{invisible:!0},style:{backgroundColor:`transparent`}}]}),ud=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiBackdrop`}),{children:r,className:i,component:a=`div`,invisible:o=!1,open:s,slotProps:c={},slots:l={},transitionDuration:u,...d}=n,f={...n,component:a,invisible:o},p=cd(f),m={component:a,slots:l,slotProps:c},[h,g]=Jc(`root`,{elementType:ld,externalForwardedProps:m,className:G(p.root,i),ownerState:f}),[_,v]=Jc(`transition`,{elementType:od,externalForwardedProps:m,ownerState:f});return(0,W.jsx)(_,{in:s,timeout:u,...d,...v,children:(0,W.jsx)(h,{...g,ref:t,children:r})})});function dd(...e){return e.reduce((e,t)=>t==null?e:function(...n){e.apply(this,n),t.apply(this,n)},()=>{})}function fd(e){return typeof e==`function`?e():e}function pd(e){return e?e.props.hasOwnProperty(`in`):!1}var md=()=>{},hd=new Fu;function gd(e){let{container:t,disableScrollLock:n=!1,closeAfterTransition:r=!1,onTransitionEnter:i,onTransitionExited:a,children:o,onClose:s,open:c,rootRef:l}=e,u=v.useRef({}),d=v.useRef(null),f=v.useRef(null),p=v.useRef(null),m=as(p,l),[h,g]=v.useState(!c),_=pd(o),y=!0;(e[`aria-hidden`]===`false`||e[`aria-hidden`]===!1)&&(y=!1);let b=()=>ss(d.current),x=()=>(u.current.modalRef=p.current,u.current.mount=d.current,u.current),S=()=>{hd.mount(x(),{disableScrollLock:n}),p.current&&(p.current.scrollTop=0)},C=os(()=>{let e=fd(t)||b().body;hd.add(x(),e),p.current&&S()}),w=()=>hd.isTopModal(x()),T=os(e=>{d.current=e,e&&(f.current=e,c&&w()?S():p.current&&ku(p.current,y))}),E=v.useCallback(()=>{hd.remove(x(),y)},[y]);v.useEffect(()=>()=>{E()},[E]),v.useEffect(()=>{c?C():(!_||!r)&&E()},[c,E,_,r,C]);let D=e=>t=>{e.onKeyDown?.(t),!(t.key!==`Escape`||t.which===229||!w())&&(t.stopPropagation(),s&&s(t,`escapeKeyDown`))},O=e=>t=>{e.onClick?.(t),t.target===t.currentTarget&&s&&s(t,`backdropClick`)};return{getRootProps:(t={})=>{let n=Gc(e);delete n.onTransitionEnter,delete n.onTransitionExited;let r={...n,...t};return{role:`presentation`,...r,onKeyDown:D(r),ref:m}},getBackdropProps:(e={})=>{let t=e;return{"aria-hidden":!0,...t,onClick:O(t),open:c}},getTransitionProps:()=>({onEnter:dd(()=>{g(!1),i&&i()},o?.props.onEnter??md),onExited:dd(()=>{g(!0),a&&a(),r&&E()},o?.props.onExited??md)}),rootRef:m,portalRef:T,portalContainer:!c&&_&&!h?f.current??t:t,isTopModal:w,exited:h,hasTransition:_}}function _d(e){return K(`MuiModal`,e)}Wr(`MuiModal`,[`root`,`hidden`,`backdrop`]);var vd=e=>{let{open:t,exited:n,classes:r}=e;return va({root:[`root`,!t&&n&&`hidden`],backdrop:[`backdrop`]},_d,r)},yd=J(`div`,{name:`MuiModal`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.open&&n.exited&&t.hidden]}})(_s(({theme:e})=>({position:`fixed`,zIndex:(e.vars||e).zIndex.modal,right:0,bottom:0,top:0,left:0,variants:[{props:({ownerState:e})=>!e.open&&e.exited,style:{visibility:`hidden`}}]}))),bd=J(ud,{name:`MuiModal`,slot:`Backdrop`})({zIndex:-1}),xd=v.forwardRef(function(e,t){let n=Jo({name:`MuiModal`,props:e}),{classes:r,className:i,closeAfterTransition:a=!1,children:o,container:s,component:c,disableAutoFocus:l=!1,disableEnforceFocus:u=!1,disablePortal:d=!1,disableRestoreFocus:f=!1,disableScrollLock:p=!1,hideBackdrop:m=!1,keepMounted:h=!1,onClose:g,onTransitionEnter:_,onTransitionExited:y,open:b,slotProps:x={},slots:S={},theme:C,...w}=n,T={...n,closeAfterTransition:a,disableAutoFocus:l,disableEnforceFocus:u,disablePortal:d,disableRestoreFocus:f,disableScrollLock:p,hideBackdrop:m,keepMounted:h},{getRootProps:E,getBackdropProps:D,getTransitionProps:O,portalRef:k,portalContainer:A,isTopModal:j,exited:M,hasTransition:N}=gd({...T,rootRef:t}),P={...T,exited:M},F=vd(P),I={};if(o.props.tabIndex===void 0&&(I.tabIndex=`-1`),N){let{onEnter:e,onExited:t}=O();I.onEnter=e,I.onExited=t}let L={slots:S,slotProps:x},[R,ee]=Jc(`root`,{ref:t,elementType:yd,externalForwardedProps:{...L,...w,component:c},getSlotProps:E,ownerState:P,className:G(i,F?.root,!P.open&&P.exited&&F?.hidden)}),[te,ne]=Jc(`backdrop`,{elementType:bd,externalForwardedProps:L,shouldForwardComponentProp:!0,getSlotProps:e=>D({...e,onClick:t=>{e?.onClick&&e.onClick(t)}}),className:F?.backdrop,ownerState:P});return!h&&!b&&(!N||M)?null:(0,W.jsx)(Zu,{ref:k,container:A,disablePortal:d,children:(0,W.jsxs)(R,{...ee,children:[m?null:(0,W.jsx)(te,{...ne}),(0,W.jsx)(qu,{disableEnforceFocus:u,disableAutoFocus:l,disableRestoreFocus:f,isEnabled:j,open:b,children:v.cloneElement(o,I)})]})})}),Sd=is,Cd=ya,wd=cs,Td=Wi;function Ed(e){let{controlled:t,default:n,name:r,state:i=`value`}=e,{current:a}=v.useRef(t!==void 0),[o,s]=v.useState(n);return[a?t:o,v.useCallback(e=>{a||s(e)},[])]}var Dd=Ed;function Od(e,t){if(!e)return t;function n(e,t){let n={};return Object.keys(t).forEach(r=>{Wc(r,t[r])&&typeof e[r]==`function`&&(n[r]=(...n)=>{e[r](...n),t[r](...n)})}),n}if(typeof e==`function`||typeof t==`function`)return r=>{let i=typeof t==`function`?t(r):t,a=typeof e==`function`?e({...r,...i}):e,o=G(r?.className,i?.className,a?.className),s=n(a,i);return{...i,...a,...s,...!!o&&{className:o},...i?.style&&a?.style&&{style:{...i.style,...a.style}},...i?.sx&&a?.sx&&{sx:[...Array.isArray(i.sx)?i.sx:[i.sx],...Array.isArray(a.sx)?a.sx:[a.sx]]}}};let r=t,i=n(e,r),a=G(r?.className,e?.className);return{...t,...e,...i,...!!a&&{className:a},...r?.style&&e?.style&&{style:{...r.style,...e.style}},...r?.sx&&e?.sx&&{sx:[...Array.isArray(r.sx)?r.sx:[r.sx],...Array.isArray(e.sx)?e.sx:[e.sx]]}}}var kd={visibility:`hidden`},Ad={};function jd(e){return typeof e==`string`&&/^translate\(.+,\s*.+\)$/.test(e)}function Md(e,t,n,r=Ad){let{resetInlineTransform:i=!0}=r,a=n&&n.getBoundingClientRect(),o=wd(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}=zs(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 Nd(e){return typeof e==`function`?e():e}function Pd(e,t,n,r){let i=Md(e,t,Nd(n),r);i&&(t.style.transform=i)}var Fd=v.forwardRef(function(e,t){let n=Uo(),r={enter:n.transitions.easing.easeOut,exit:n.transitions.easing.sharp},i={enter:n.transitions.duration.enteringScreen,exit:n.transitions.duration.leavingScreen},{addEndListener:a,appear:o=!0,children:s,container:c,disablePrefersReducedMotion:l=!1,direction:u=`down`,easing:d=r,in:f,onEnter:p,onEntered:m,onEntering:h,onExit:g,onExited:_,onExiting:y,style:b,timeout:x=i,...S}=e,C=Il(n.motion.reducedMotion,l),w=v.useRef(null),T=v.useRef(!1),E=vs(Iu(s),w,t),D=Bs(w,(e,t)=>{Pd(u,e,c),C.shouldReduceMotion||As(e),p&&p(e,t)}),O=Bs(w,(e,t)=>{let r=Hs({timeout:x,style:b,easing:d},{mode:`enter`}),i=C.getTransitionTiming({duration:r.duration,delay:r.delay});e.style.transition=n.transitions.create(`transform`,{duration:i.duration,easing:r.easing,delay:i.delay}),e.style.transform=`none`,h&&h(e,t)}),k=Bs(w,m),A=Bs(w,y),j=Bs(w,e=>{let t=Hs({timeout:x,style:b,easing:d},{mode:`exit`}),r=C.getTransitionTiming({duration:t.duration,delay:t.delay});e.style.transition=n.transitions.create(`transform`,{duration:r.duration,easing:t.easing,delay:r.delay});let i=jd(e.style.transform);T.current=i,Pd(u,e,c,{resetInlineTransform:!i}),g&&g(e)}),M=Bs(w,e=>{T.current=!1,e.style.transition=``,_&&_(e)}),N=a?e=>{a(w.current,e)}:void 0,P=v.useCallback(()=>{w.current&&Pd(u,w.current,c)},[u,c]);return v.useEffect(()=>{if(f||u===`down`||u===`right`)return;let e=Sd(()=>{w.current&&Pd(u,w.current,c)}),t=wd(w.current);return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[u,f,c]),v.useEffect(()=>{!f&&!T.current&&P()},[f,P]),(0,W.jsx)(rd,{nodeRef:w,onEnter:D,onEntered:k,onEntering:O,onExit:j,onExited:M,onExiting:A,addEndListener:N,appear:o,in:f,reduceMotion:C.shouldReduceMotion,timeout:x,...S,children:(e,{ownerState:t,...n})=>{let r;return r=e===`exited`&&!f?b||s.props.style?{visibility:`hidden`,...b,...s.props.style}:kd:b&&s.props.style?{...b,...s.props.style}:b||s.props.style,v.cloneElement(s,{ref:E,style:r,...n})}})});function Id(e){return K(`MuiDrawer`,e)}Wr(`MuiDrawer`,[`root`,`docked`,`paper`,`anchorLeft`,`anchorRight`,`anchorTop`,`anchorBottom`,`modal`]);var Ld=(e,t)=>{let{ownerState:n}=e;return[t.root,(n.variant===`permanent`||n.variant===`persistent`)&&t.docked,n.variant===`temporary`&&t.modal]},Rd=e=>{let{classes:t,anchor:n,variant:r}=e;return va({root:[`root`,`anchor${Y(n)}`],docked:[(r===`permanent`||r===`persistent`)&&`docked`],modal:[`modal`],paper:[`paper`]},Id,t)},zd=J(xd,{name:`MuiDrawer`,slot:`Root`,overridesResolver:Ld})(_s(({theme:e})=>({zIndex:(e.vars||e).zIndex.drawer}))),Bd=J(`div`,{shouldForwardProp:Ko,name:`MuiDrawer`,slot:`Docked`,skipVariantsResolver:!1,overridesResolver:Ld})({flex:`0 0 auto`}),Vd=J(Mc,{name:`MuiDrawer`,slot:`Paper`})(_s(({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}`}}]}))),Hd={left:`right`,right:`left`,top:`down`,bottom:`up`};function Ud(e){return[`left`,`right`].includes(e)}function Wd({direction:e},t){return e===`rtl`&&Ud(t)?Hd[t]:t}var Gd=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDrawer`}),r=Uo(),i=Ii(),a={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{anchor:o=`left`,children:s,className:c,elevation:l=16,hideBackdrop:u=!1,ModalProps:d={},onClose:f,open:p=!1,transitionDuration:m=a,variant:h=`temporary`,slots:g={},slotProps:_={},...y}=n,b=v.useRef(!1),x=v.useRef(null),S=vs(t,x);v.useEffect(()=>{b.current=!0},[]);let C=v.useCallback(()=>x.current,[]),w=Wd({direction:i?`rtl`:`ltr`},o),T=o,E={...n,anchor:T,elevation:l,open:p,variant:h,...y},D=Rd(E),O={slots:g,slotProps:{..._,backdrop:Od(_.backdrop,{transitionDuration:m})}},[k,A]=Jc(`root`,{ref:S,elementType:zd,className:G(D.root,D.modal,c),shouldForwardComponentProp:!0,ownerState:E,externalForwardedProps:{...O,...y,...d},additionalProps:{closeAfterTransition:!0,open:p,onClose:f,hideBackdrop:u,slots:{backdrop:O.slots.backdrop},slotProps:{backdrop:O.slotProps.backdrop}}}),[j,M]=Jc(`paper`,{elementType:Vd,shouldForwardComponentProp:!0,className:D.paper,ownerState:E,externalForwardedProps:O,additionalProps:{elevation:h===`temporary`?l:0,square:!0,...h===`temporary`&&{role:`dialog`,"aria-modal":`true`,"data-mui-focusable":``,tabIndex:-1}}}),[N,P]=Jc(`docked`,{elementType:Bd,ref:S,className:G(D.root,D.docked,c),ownerState:E,externalForwardedProps:O,additionalProps:y}),[F,I]=Jc(`transition`,{elementType:Fd,ownerState:E,externalForwardedProps:O,additionalProps:{in:p,direction:Hd[w],timeout:m,appear:b.current,...h===`temporary`&&(g.transition==null||g.transition===Fd)&&{container:C}}}),L=(0,W.jsx)(j,{...M,children:s});if(h===`permanent`)return(0,W.jsx)(N,{...P,children:L});let R=(0,W.jsx)(F,{...I,children:L});return h===`persistent`?(0,W.jsx)(N,{...P,children:R}):(0,W.jsx)(k,{...A,children:R})});function Kd(e){return K(`MuiIconButton`,e)}var qd=Wr(`MuiIconButton`,[`root`,`disabled`,`colorInherit`,`colorPrimary`,`colorSecondary`,`colorError`,`colorInfo`,`colorSuccess`,`colorWarning`,`edgeStart`,`edgeEnd`,`sizeSmall`,`sizeMedium`,`sizeLarge`,`loading`,`loadingIndicator`,`loadingWrapper`]),Jd=e=>{let{classes:t,disabled:n,color:r,edge:i,size:a,loading:o}=e;return va({root:[`root`,o&&`loading`,n&&`disabled`,r!=="default"&&`color${Y(r)}`,i&&`edge${Y(i)}`,`size${Y(a)}`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},Kd,t)},Yd=J(eu,{name:`MuiIconButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.loading&&t.loading,n.color!=="default"&&t[`color${Y(n.color)}`],n.edge&&t[`edge${Y(n.edge)}`],t[`size${Y(n.size)}`]]}})(_s(({theme:e})=>({textAlign:`center`,flex:`0 0 auto`,fontSize:e.typography.pxToRem(24),padding:8,borderRadius:`50%`,color:(e.vars||e).palette.action.active,...Ws(e,`background-color`,{duration:e.transitions.duration.shortest}),variants:[{props:e=>!e.disableRipple,style:{"--IconButton-hoverBg":e.alpha((e.vars||e).palette.action.active,(e.vars||e).palette.action.hoverOpacity),"&:hover":{backgroundColor:`var(--IconButton-hoverBg)`,"@media (hover: none)":{backgroundColor:`transparent`}}}},{props:{edge:`start`},style:{marginLeft:-12}},{props:{edge:`start`,size:`small`},style:{marginLeft:-3}},{props:{edge:`end`},style:{marginRight:-12}},{props:{edge:`end`,size:`small`},style:{marginRight:-3}}]})),_s(({theme:e})=>({variants:[{props:{color:`inherit`},style:{color:`inherit`}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main,"--IconButton-hoverBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}})),{props:{size:`small`},style:{padding:5,fontSize:e.typography.pxToRem(18)}},{props:{size:`large`},style:{padding:12,fontSize:e.typography.pxToRem(28)}}],[`&.${qd.disabled}`]:{backgroundColor:`transparent`,color:(e.vars||e).palette.action.disabled},[`&.${qd.loading}`]:{color:`transparent`}}))),Xd=J(`span`,{name:`MuiIconButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,top:`50%`,left:`50%`,transform:`translate(-50%, -50%)`,color:(e.vars||e).palette.action.disabled,variants:[{props:{loading:!0},style:{display:`flex`}}]})),Zd=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiIconButton`}),{edge:r=!1,children:i,className:a,color:o=`default`,disabled:s=!1,disableFocusRipple:c=!1,size:l=`medium`,id:u,loading:d=null,loadingIndicator:f,...p}=n,m=Td(u),h=f??(0,W.jsx)(bu,{"aria-labelledby":m,color:`inherit`,size:16}),g={...n,edge:r,color:o,disabled:s,disableFocusRipple:c,loading:d,loadingIndicator:h,size:l},_=Jd(g);return(0,W.jsxs)(Yd,{id:d?m:u,className:G(_.root,a),centerRipple:!0,internalNativeButton:!0,focusRipple:!c,disabled:s||d,ref:t,...p,ownerState:g,children:[typeof d==`boolean`&&(0,W.jsx)(`span`,{className:_.loadingWrapper,style:{display:`contents`},children:(0,W.jsx)(Xd,{className:_.loadingIndicator,ownerState:g,children:d&&h})}),i]})}),Qd=v.createContext({});function $d(e){return K(`MuiList`,e)}Wr(`MuiList`,[`root`,`padding`,`dense`,`subheader`]);var ef=e=>{let{classes:t,disablePadding:n,dense:r,subheader:i}=e;return va({root:[`root`,!n&&`padding`,r&&`dense`,i&&`subheader`]},$d,t)},tf=J(`ul`,{name:`MuiList`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disablePadding&&t.padding,n.dense&&t.dense,n.subheader&&t.subheader]}})({listStyle:`none`,margin:0,padding:0,position:`relative`,variants:[{props:({ownerState:e})=>!e.disablePadding,style:{paddingTop:8,paddingBottom:8}},{props:({ownerState:e})=>e.subheader,style:{paddingTop:0,isolation:`isolate`}}]}),nf=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiList`}),{children:r,className:i,component:a=`ul`,dense:o=!1,disablePadding:s=!1,subheader:c,...l}=n,u=v.useMemo(()=>({dense:o}),[o]),d={...n,component:a,dense:o,disablePadding:s},f=ef(d);return(0,W.jsx)(Qd.Provider,{value:u,children:(0,W.jsxs)(tf,{as:a,className:G(f.root,i),ref:t,ownerState:d,...l,children:[c,r]})})}),rf=(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]},af=e=>{let{alignItems:t,classes:n,dense:r,disabled:i,disableGutters:a,divider:o,selected:s}=e,c=va({root:[`root`,r&&`dense`,!a&&`gutters`,o&&`divider`,i&&`disabled`,t===`flex-start`&&`alignItemsFlexStart`,s&&`selected`]},lc,n);return{...n,...c}},of=J(eu,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiListItemButton`,slot:`Root`,overridesResolver:rf})(_s(({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,...Ws(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}},[`&.${uc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${uc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${uc.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)}},[`&.${uc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${uc.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}}]}))),sf=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemButton`}),{alignItems:r=`center`,autoFocus:i=!1,component:a=`div`,children:o,dense:s=!1,disableGutters:c=!1,divider:l=!1,focusVisibleClassName:u,selected:d=!1,className:f,...p}=n,m=v.useContext(Qd),h=v.useMemo(()=>({dense:s||m.dense||!1,alignItems:r,disableGutters:c}),[r,m.dense,s,c]),g=v.useRef(null);ys(()=>{i&&g.current&&g.current.focus()},[i]);let _={...n,alignItems:r,dense:h.dense,disableGutters:c,divider:l,selected:d},y=af(_),{root:b,...x}=y,S=vs(g,t);return(0,W.jsx)(Qd.Provider,{value:h,children:(0,W.jsx)(of,{ref:S,href:p.href||p.to,component:(p.href||p.to)&&a===`div`?`button`:a,internalNativeButton:!1,focusVisibleClassName:G(y.focusVisible,u),ownerState:_,className:G(y.root,f),...p,classes:x,children:o})})});function cf(e){return K(`MuiListItemIcon`,e)}var lf=Wr(`MuiListItemIcon`,[`root`,`alignItemsFlexStart`]),uf=e=>{let{alignItems:t,classes:n}=e;return va({root:[`root`,t===`flex-start`&&`alignItemsFlexStart`]},cf,n)},df=J(`div`,{name:`MuiListItemIcon`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.alignItems===`flex-start`&&t.alignItemsFlexStart]}})(_s(({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}}]}))),ff=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemIcon`}),{className:r,...i}=n,a=v.useContext(Qd),o={...n,alignItems:a.alignItems},s=uf(o);return(0,W.jsx)(df,{className:G(s.root,r),ownerState:o,ref:t,...i})});function pf(e){return K(`MuiTypography`,e)}var mf=Wr(`MuiTypography`,[`root`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`subtitle1`,`subtitle2`,`body1`,`body2`,`inherit`,`button`,`caption`,`overline`,`alignLeft`,`alignRight`,`alignCenter`,`alignJustify`,`noWrap`,`gutterBottom`]),hf=e=>{let{align:t,gutterBottom:n,noWrap:r,variant:i,classes:a}=e;return va({root:[`root`,i,e.align!==`inherit`&&`align${Y(t)}`,n&&`gutterBottom`,r&&`noWrap`]},pf,a)},gf=J(`span`,{name:`MuiTypography`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.variant&&t[n.variant],n.align!==`inherit`&&t[`align${Y(n.align)}`],n.noWrap&&t.noWrap,n.gutterBottom&&t.gutterBottom]}})(_s(({theme:e})=>({margin:0,variants:[{props:{variant:`inherit`},style:{font:`inherit`,lineHeight:`inherit`,letterSpacing:`inherit`}},...Object.entries(e.typography).filter(([e,t])=>e!==`inherit`&&t&&typeof t==`object`).map(([e,t])=>({props:{variant:e},style:t})),...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{color:(e.vars||e).palette[t].main}})),...Object.entries(e.palette?.text||{}).filter(([,e])=>typeof e==`string`).map(([t])=>({props:{color:`text${Y(t)}`},style:{color:(e.vars||e).palette.text[t]}})),{props:({ownerState:e})=>e.align!==`inherit`,style:{textAlign:`var(--Typography-textAlign)`}},{props:({ownerState:e})=>e.noWrap,style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`}},{props:({ownerState:e})=>e.gutterBottom,style:{marginBottom:`0.35em`}}]}))),_f={h1:`h1`,h2:`h2`,h3:`h3`,h4:`h4`,h5:`h5`,h6:`h6`,subtitle1:`h6`,subtitle2:`h6`,body1:`p`,body2:`p`,inherit:`p`},Z=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTypography`}),{color:r,align:i=`inherit`,className:a,component:o,gutterBottom:s=!1,noWrap:c=!1,variant:l=`body1`,variantMapping:u=_f,...d}=n,f={...n,align:i,color:r,className:a,component:o,gutterBottom:s,noWrap:c,variant:l,variantMapping:u},p=o||u[l]||_f[l]||`span`,m=hf(f);return(0,W.jsx)(gf,{as:p,ref:t,className:G(m.root,a),...d,ownerState:f,style:{...i!==`inherit`&&{"--Typography-textAlign":i},...d.style}})});function vf(e){return K(`MuiListItemText`,e)}var yf=Wr(`MuiListItemText`,[`root`,`multiline`,`dense`,`inset`,`primary`,`secondary`]),bf=e=>{let{classes:t,inset:n,primary:r,secondary:i,dense:a}=e;return va({root:[`root`,n&&`inset`,a&&`dense`,r&&i&&`multiline`],primary:[`primary`],secondary:[`secondary`]},vf,t)},xf=J(`div`,{name:`MuiListItemText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${yf.primary}`]:t.primary},{[`& .${yf.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,[`.${mf.root}:where(& .${yf.primary})`]:{display:`block`},[`.${mf.root}:where(& .${yf.secondary})`]:{display:`block`},variants:[{props:({ownerState:e})=>e.primary&&e.secondary,style:{marginTop:6,marginBottom:6}},{props:({ownerState:e})=>e.inset,style:{paddingLeft:56}}]}),Sf=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemText`}),{children:r,className:i,disableTypography:a=!1,inset:o=!1,primary:s,secondary:c,slots:l={},slotProps:u={},...d}=n,{dense:f}=v.useContext(Qd),p=s??r,m=c,h={...n,disableTypography:a,inset:o,primary:!!p,secondary:!!m,dense:f},g=bf(h),_={slots:l,slotProps:u},[y,b]=Jc(`root`,{className:G(g.root,i),elementType:xf,externalForwardedProps:{..._,...d},ownerState:h,ref:t}),[x,S]=Jc(`primary`,{className:g.primary,elementType:Z,externalForwardedProps:_,ownerState:h}),[C,w]=Jc(`secondary`,{className:g.secondary,elementType:Z,externalForwardedProps:_,ownerState:h});return p!=null&&p.type!==Z&&!a&&(p=(0,W.jsx)(x,{variant:f?`body2`:`body1`,component:S?.variant?void 0:`span`,...S,children:p})),m!=null&&m.type!==Z&&!a&&(m=(0,W.jsx)(C,{variant:`body2`,color:`textSecondary`,...w,children:m})),(0,W.jsxs)(y,{...b,children:[p,m]})}),Cf=Ea({createStyledComponent:J(`div`,{name:`MuiStack`,slot:`Root`}),useThemeProps:e=>Jo({props:e,name:`MuiStack`})}),wf=v.createContext({}),Tf=v.createContext(void 0);function Ef(e,t){return t===void 0||e===void 0?!1:Array.isArray(t)?t.includes(e):e===t}var Df=v.createContext(void 0);function Of(){let e=v.useContext(Df);if(e===void 0)throw Error(`MUI: RovingTabIndexContext is missing. Roving tab index items must be placed within a roving tab index provider.`);return e}var kf=Object.is;function Af(e,t){if(e===t)return!0;if(!(e instanceof Object)||!(t instanceof Object))return!1;let n=0,r=0;for(let r in e)if(n+=1,!kf(e[r],t[r])||!(r in t))return!1;for(let e in t)r+=1;return n===r}var jf=[`ArrowRight`,`ArrowLeft`,`ArrowUp`,`ArrowDown`,`Home`,`End`];function Mf(e){let{activeItemId:t,getDefaultActiveItemId:n,orientation:r,isRtl:i=!1,isItemFocusable:a=Kf,wrap:o=!0}=e,[s,c]=v.useState(t),[l,u]=v.useState(t),d=s;t!==l&&(u(t),t!==void 0&&t!==s&&(d=t,c(t)));let f=v.useRef(null),p=v.useRef(new Map),[m,h]=v.useState(0),g=v.useMemo(()=>Uf(p.current),[m]),_=Pf(d,g,a,n),y=v.useRef(_);y.current=_;let b=v.useCallback(()=>{let e=Uf(p.current);return Bf(e,Pf(y.current,e,a,n))},[n,a]),x=v.useCallback(()=>p.current,[]),S=os(e=>{Af(p.current.get(e.id)??null,e)||(p.current.set(e.id,e),h(e=>e+1))}),C=os(e=>{p.current.delete(e)&&h(e=>e+1)}),w=os(e=>{c(e)}),T=v.useCallback(e=>y.current===e,[]),E=v.useCallback((e,t,n,r)=>{let i=Rf(Wf(p.current),e,t,n,r??a);return i?(i.element?.focus(),c(i.id),i):null},[a]),D=v.useCallback((e,t,n)=>({onFocus:e=>{t?.(e);let n=Wf(p.current),r=Hf(n,e.target);r!==-1&&c(n[r].id)},onKeyDown:e=>{if(n?.(e),e.defaultPrevented||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey||!jf.includes(e.key))return;let t=r===`horizontal`?`ArrowLeft`:`ArrowUp`,a=r===`horizontal`?`ArrowRight`:`ArrowDown`;r===`horizontal`&&i&&(t=`ArrowRight`,a=`ArrowLeft`);let s=Wf(p.current),c=xs(ss(f.current)),l=c===f.current,u=Lf(s,c,y.current),d=`next`;switch(e.key){case t:d=`previous`,e.preventDefault(),l&&(u=s.length);break;case a:e.preventDefault(),l&&(u=-1);break;case`Home`:e.preventDefault(),u=-1;break;case`End`:e.preventDefault(),d=`previous`,u=s.length;break;default:return}E(u,d,o)},ref:Yf(e,e=>{f.current=e})}),[E,i,r,o]),O=v.useCallback(e=>{let t=Wf(p.current),n=xs(ss(f.current)),r=n===f.current?-1:Lf(t,n,y.current);return E(r,`next`,!0,e)?.id??null},[E]);return v.useMemo(()=>({activeItemId:_,focusNext:O,getActiveItem:b,getContainerProps:D,getItemMap:x,isItemActive:T,registerItem:S,setActiveItemId:w,unregisterItem:C}),[_,O,b,D,x,T,S,w,C])}function Nf(e){let{activeItemId:t,registerItem:n,unregisterItem:r}=Of(),i=v.useRef(null),a=v.useMemo(()=>({disabled:e.disabled??!1,element:null,focusableWhenDisabled:e.focusableWhenDisabled??!1,id:e.id,selected:e.selected??!1,textValue:e.textValue}),[e.disabled,e.focusableWhenDisabled,e.id,e.selected,e.textValue]),o=v.useRef(a);o.current=a;let s=v.useCallback(t=>{if(i.current=t,t==null){queueMicrotask(()=>{i.current??r(e.id)});return}n({...o.current,element:t})},[e.id,n,r]),c=as(e.ref,s);return oi(()=>{i.current&&n({...a,element:i.current})},[a,n]),oi(()=>{let t=e.id;return()=>{r(t)}},[e.id,r]),{ref:c,tabIndex:t===e.id?0:-1}}function Pf(e,t,n,r){return e==null?If(t,n,r):Ff(e,t,n)}function Ff(e,t,n){let r=Vf(t,e);return r===-1?zf(t,n):n(t[r])?t[r].id:Rf(t,r,`next`,!1,n)?.id??null}function If(e,t,n){let r=n?.(e);if(r!=null){let n=Bf(e,r);if(n&&t(n))return n.id}return zf(e,t)}function Lf(e,t,n){if(t){let n=Hf(e,t);if(n!==-1)return n}return Vf(e,n)}function Rf(e,t,n,r,i){let a=e.length-1;if(a===-1)return null;let o=!1,s=Gf(t,a,n,r),c=s;for(;s!==-1;){if(s===c){if(o)return null;o=!0}let t=e[s];if(!t||!i(t))s=Gf(s,a,n,r);else return t}return null}function zf(e,t){return e.find(e=>t(e))?.id??null}function Bf(e,t){return t==null?null:e.find(e=>e.id===t)??null}function Vf(e,t){return t==null?-1:e.findIndex(e=>e.id===t)}function Hf(e,t){return t?e.findIndex(e=>e.element===t||e.element?.contains(t)):-1}function Uf(e){let t=Array.from(e.values());if(t.every(e=>e.element==null))return t;let n=t.filter(qf).sort((e,t)=>Jf(e.element,t.element)),r=t.filter(e=>!qf(e));return[...n,...r]}function Wf(e){return Uf(e).filter(qf)}function Gf(e,t,n,r=!0){return n===`next`?e===t?r?0:-1:e+1:e===0?r?t:-1:e-1}function Kf(e){return e.element?e.focusableWhenDisabled?!0:!e.disabled&&!e.element.hasAttribute(`disabled`)&&e.element.getAttribute(`aria-disabled`)!==`true`&&e.element.hasAttribute(`tabindex`):!1}function qf(e){return e.element!=null&&e.element.isConnected}function Jf(e,t){if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function Yf(...e){return t=>{e.forEach(e=>{Ju(e??null,t)})}}function Xf(e,t){let{children:n,disabled:r=!1,selected:i=!1,value:a}=e,o=Of(),s=Nf({id:a,ref:t,disabled:r,selected:i}),c=o.getItemMap().size===0&&i?0:s.tabIndex;return v.cloneElement(v.Children.only(n),{...s,tabIndex:n.props.tabIndex??c})}var Zf=v.forwardRef(Xf),Qf=e=>{let{classes:t,fullWidth:n,selected:r,disabled:i,size:a,color:o}=e;return va({root:[`root`,r&&`selected`,i&&`disabled`,n&&`fullWidth`,`size${Y(a)}`,o]},_c,t)},$f=J(eu,{name:`MuiToggleButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`size${Y(n.size)}`]]}})(_s(({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,[`&.${vc.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:{[`&.${vc.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(Oc()).map(([t])=>({props:{color:t},style:{[`&.${vc.selected}`]:{color:(e.vars||e).palette[t].main,backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity),"&:hover":{backgroundColor:e.alpha((e.vars||e).palette[t].main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.selectedOpacity)}}}}})),{props:{fullWidth:!0},style:{width:`100%`}},{props:{size:`small`},style:{padding:7,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`},style:{padding:15,fontSize:e.typography.pxToRem(15)}}]}))),ep=v.forwardRef(function(e,t){let{value:n,isRovingTabIndex:r,...i}=v.useContext(wf),a=v.useContext(Tf),o=Jo({props:ri({...i,selected:Ef(e.value,n)},e),name:`MuiToggleButton`}),{children:s,className:c,color:l=`standard`,disabled:u=!1,disableFocusRipple:d=!1,fullWidth:f=!1,onChange:p,onClick:m,selected:h,size:g=`medium`,value:_,...y}=o,b={...o,color:l,disabled:u,disableFocusRipple:d,fullWidth:f,size:g},x=Qf(b),S=e=>{m&&(m(e,_),e.defaultPrevented)||p&&p(e,_)},C=a||``,w=(0,W.jsx)($f,{className:G(i.className,x.root,c,C),internalNativeButton:!0,disabled:u,focusRipple:!d,ref:r?void 0:t,onClick:S,onChange:p,value:_,ownerState:b,"aria-pressed":h,...y,children:s});return r?(0,W.jsx)(Zf,{disabled:u,selected:h,ref:t,value:_,children:w}):w});function tp(e){return v.Children.toArray(e).filter(e=>v.isValidElement(e))}function np(e){return K(`MuiToggleButtonGroup`,e)}var rp=Wr(`MuiToggleButtonGroup`,[`root`,`selected`,`horizontal`,`vertical`,`disabled`,`grouped`,`fullWidth`,`firstButton`,`lastButton`,`middleButton`]),ip=e=>{let{classes:t,orientation:n,fullWidth:r,disabled:i}=e;return va({root:[`root`,n,r&&`fullWidth`],grouped:[`grouped`,i&&`disabled`],firstButton:[`firstButton`],lastButton:[`lastButton`],middleButton:[`middleButton`]},np,t)},ap=J(`div`,{name:`MuiToggleButtonGroup`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${rp.grouped}`]:t.grouped},{[`& .${rp.firstButton}`]:t.firstButton},{[`& .${rp.lastButton}`]:t.lastButton},{[`& .${rp.middleButton}`]:t.middleButton},t.root,n.orientation===`vertical`&&t.vertical,n.fullWidth&&t.fullWidth]}})(_s(({theme:e})=>({display:`inline-flex`,borderRadius:(e.vars||e).shape.borderRadius,variants:[{props:{orientation:`vertical`},style:{flexDirection:`column`,[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderTop:0,marginTop:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderBottomLeftRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginTop:-1,borderTop:`1px solid transparent`,borderTopLeftRadius:0,borderTopRightRadius:0},[`& .${rp.lastButton}.${vc.disabled},& .${rp.middleButton}.${vc.disabled}`]:{borderTop:`1px solid transparent`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{orientation:`horizontal`},style:{[`& .${rp.grouped}`]:{[`&.${rp.selected} + .${rp.grouped}.${rp.selected}`]:{borderLeft:0,marginLeft:0}},[`& .${rp.firstButton},& .${rp.middleButton}`]:{borderTopRightRadius:0,borderBottomRightRadius:0},[`& .${rp.lastButton},& .${rp.middleButton}`]:{marginLeft:-1,borderLeft:`1px solid transparent`,borderTopLeftRadius:0,borderBottomLeftRadius:0},[`& .${rp.lastButton}.${vc.disabled},& .${rp.middleButton}.${vc.disabled}`]:{borderLeft:`1px solid transparent`}}}]}))),op=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiToggleButtonGroup`}),{children:r,className:i,color:a=`standard`,disabled:o=!1,exclusive:s=!1,fullWidth:c=!1,onChange:l,orientation:u=`horizontal`,size:d=`medium`,value:f,...p}=n,m={...n,disabled:o,fullWidth:c,orientation:u,size:d},h=ip(m),g=Ii(),_=v.useCallback((e,t)=>{if(!l)return;let n=f&&f.indexOf(t),r;f&&n>=0?(r=f.slice(),r.splice(n,1)):r=f?f.concat(t):[t],l(e,r)},[l,f]),y=v.useCallback((e,t)=>{l&&l(e,f===t?null:t)},[l,f]),b=v.useMemo(()=>({className:h.grouped,onChange:s?y:_,value:f,size:d,fullWidth:c,color:a,disabled:o,isRovingTabIndex:!0}),[h.grouped,s,y,_,f,d,c,a,o]),x=tp(r),S=x.length,C=e=>{let t=e===0,n=e===S-1;return t&&n?``:t?h.firstButton:n?h.lastButton:h.middleButton},w=Mf({orientation:u,isRtl:g}),T=w.getContainerProps(t,p.onFocus,p.onKeyDown);return(0,W.jsx)(ap,{role:`group`,className:G(h.root,i),ownerState:m,...p,...T,children:(0,W.jsx)(Df.Provider,{value:w,children:(0,W.jsx)(wf.Provider,{value:b,children:x.map((e,t)=>(0,W.jsx)(Tf.Provider,{value:C(t),children:e},t))})})})});function sp(e){return K(`MuiToolbar`,e)}Wr(`MuiToolbar`,[`root`,`gutters`,`regular`,`dense`]);var cp=e=>{let{classes:t,disableGutters:n,variant:r}=e;return va({root:[`root`,!n&&`gutters`,r]},sp,t)},lp=J(`div`,{name:`MuiToolbar`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,!n.disableGutters&&t.gutters,t[n.variant]]}})(_s(({theme:e})=>({position:`relative`,display:`flex`,alignItems:`center`,variants:[{props:({ownerState:e})=>!e.disableGutters,style:{paddingLeft:e.spacing(2),paddingRight:e.spacing(2),[e.breakpoints.up(`sm`)]:{paddingLeft:e.spacing(3),paddingRight:e.spacing(3)}}},{props:{variant:`dense`},style:{minHeight:48}},{props:{variant:`regular`},style:e.mixins.toolbar}]}))),up=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiToolbar`}),{className:r,component:i=`div`,disableGutters:a=!1,variant:o=`regular`,...s}=n,c={...n,component:i,disableGutters:a,variant:o},l=cp(c);return(0,W.jsx)(lp,{as:i,className:G(l.root,r),ref:t,ownerState:c,...s})});function dp(e){return`scale(${e}, ${e**2})`}var fp={entering:{opacity:1,transform:dp(1)},entered:{opacity:1,transform:`none`},exiting:{opacity:0,transform:dp(.75)},exited:{opacity:0,transform:dp(.75)}},pp={opacity:0,transform:dp(.75),visibility:`hidden`},mp=v.forwardRef(function(e,t){let{addEndListener:n,appear:r=!0,children:i,disablePrefersReducedMotion:a=!1,easing:o,in:s,onEnter:c,onEntered:l,onEntering:u,onExit:d,onExited:f,onExiting:p,style:m,timeout:h=`auto`,...g}=e,_=v.useRef(null),y=Uo(),b=Il(y.motion.reducedMotion,a),x=v.useRef(null),S=vs(x,Iu(i),t),C=Bs(x,u),w=Bs(x,(e,t)=>{b.shouldReduceMotion||As(e);let{duration:n,delay:r,easing:i}=Hs({style:m,timeout:h,easing:o},{mode:`enter`}),a;h===`auto`&&!b.shouldReduceMotion?(a=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=a):(a=n,_.current=null);let s=b.getTransitionTiming({duration:a,delay:r});e.style.transition=[y.transitions.create(`opacity`,{duration:s.duration,delay:s.delay}),y.transitions.create(`transform`,{duration:typeof s.duration==`string`?s.duration:s.duration*.666,delay:s.delay,easing:i})].join(`,`),c&&c(e,t)}),T=Bs(x,l),E=Bs(x,p),D=Bs(x,e=>{let{duration:t,delay:n,easing:r}=Hs({style:m,timeout:h,easing:o},{mode:`exit`}),i;h===`auto`&&!b.shouldReduceMotion?(i=y.transitions.getAutoHeightDuration(e.clientHeight),_.current=i):(i=t,_.current=null);let a=b.getTransitionTiming({duration:i,delay:n});e.style.transition=[y.transitions.create(`opacity`,{duration:a.duration,delay:a.delay}),y.transitions.create(`transform`,{duration:typeof a.duration==`string`?a.duration:a.duration*.666,delay:a.delay||(typeof a.duration==`string`?a.duration:a.duration*.333),easing:r})].join(`,`),e.style.opacity=0,e.style.transform=dp(.75),d&&d(e)}),O=Bs(x,e=>{e.style.transition=``,f&&f(e)});return(0,W.jsx)(rd,{appear:r,in:s,nodeRef:x,onEnter:w,onEntered:T,onEntering:C,onExit:D,onExited:O,onExiting:E,addEndListener:n?e=>{n(x.current,e)}:void 0,getAutoTimeout:h===`auto`?()=>_.current:void 0,reduceMotion:b.shouldReduceMotion,timeout:h===`auto`?null:h,...g,children:(e,{ownerState:t,...n})=>{let r=Vs(e,s,fp,pp,m,i.props.style);return v.cloneElement(i,{style:r,ref:S,...n})}})});mp&&(mp.muiSupportAuto=!0);var hp=`bottom`,gp=`right`,_p=`left`,vp=`auto`,yp=[`top`,hp,gp,_p],bp=`start`,xp=`clippingParents`,Sp=`viewport`,Cp=`popper`,wp=`reference`,Tp=yp.reduce(function(e,t){return e.concat([t+`-`+bp,t+`-end`])},[]),Ep=[].concat(yp,[vp]).reduce(function(e,t){return e.concat([t,t+`-`+bp,t+`-end`])},[]),Dp=[`beforeRead`,`read`,`afterRead`,`beforeMain`,`main`,`afterMain`,`beforeWrite`,`write`,`afterWrite`];function Op(e){return e?(e.nodeName||``).toLowerCase():null}function kp(e){if(e==null)return window;if(e.toString()!==`[object Window]`){var t=e.ownerDocument;return t&&t.defaultView||window}return e}function Ap(e){return e instanceof kp(e).Element||e instanceof Element}function jp(e){return e instanceof kp(e).HTMLElement||e instanceof HTMLElement}function Mp(e){return typeof ShadowRoot>`u`?!1:e instanceof kp(e).ShadowRoot||e instanceof ShadowRoot}function Np(e){var t=e.state;Object.keys(t.elements).forEach(function(e){var n=t.styles[e]||{},r=t.attributes[e]||{},i=t.elements[e];!jp(i)||!Op(i)||(Object.assign(i.style,n),Object.keys(r).forEach(function(e){var t=r[e];t===!1?i.removeAttribute(e):i.setAttribute(e,t===!0?``:t)}))})}function Pp(e){var t=e.state,n={popper:{position:t.options.strategy,left:`0`,top:`0`,margin:`0`},arrow:{position:`absolute`},reference:{}};return Object.assign(t.elements.popper.style,n.popper),t.styles=n,t.elements.arrow&&Object.assign(t.elements.arrow.style,n.arrow),function(){Object.keys(t.elements).forEach(function(e){var r=t.elements[e],i=t.attributes[e]||{},a=Object.keys(t.styles.hasOwnProperty(e)?t.styles[e]:n[e]).reduce(function(e,t){return e[t]=``,e},{});!jp(r)||!Op(r)||(Object.assign(r.style,a),Object.keys(i).forEach(function(e){r.removeAttribute(e)}))})}}var Fp={name:`applyStyles`,enabled:!0,phase:`write`,fn:Np,effect:Pp,requires:[`computeStyles`]};function Ip(e){return e.split(`-`)[0]}var Lp=Math.max,Rp=Math.min,zp=Math.round;function Bp(){var e=navigator.userAgentData;return e!=null&&e.brands&&Array.isArray(e.brands)?e.brands.map(function(e){return e.brand+`/`+e.version}).join(` `):navigator.userAgent}function Vp(){return!/^((?!chrome|android).)*safari/i.test(Bp())}function Hp(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!1);var r=e.getBoundingClientRect(),i=1,a=1;t&&jp(e)&&(i=e.offsetWidth>0&&zp(r.width)/e.offsetWidth||1,a=e.offsetHeight>0&&zp(r.height)/e.offsetHeight||1);var o=(Ap(e)?kp(e):window).visualViewport,s=!Vp()&&n,c=(r.left+(s&&o?o.offsetLeft:0))/i,l=(r.top+(s&&o?o.offsetTop:0))/a,u=r.width/i,d=r.height/a;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c,x:c,y:l}}function Up(e){var t=Hp(e),n=e.offsetWidth,r=e.offsetHeight;return Math.abs(t.width-n)<=1&&(n=t.width),Math.abs(t.height-r)<=1&&(r=t.height),{x:e.offsetLeft,y:e.offsetTop,width:n,height:r}}function Wp(e,t){var n=t.getRootNode&&t.getRootNode();if(e.contains(t))return!0;if(n&&Mp(n)){var r=t;do{if(r&&e.isSameNode(r))return!0;r=r.parentNode||r.host}while(r)}return!1}function Gp(e){return kp(e).getComputedStyle(e)}function Kp(e){return[`table`,`td`,`th`].indexOf(Op(e))>=0}function qp(e){return((Ap(e)?e.ownerDocument:e.document)||window.document).documentElement}function Jp(e){return Op(e)===`html`?e:e.assignedSlot||e.parentNode||(Mp(e)?e.host:null)||qp(e)}function Yp(e){return!jp(e)||Gp(e).position===`fixed`?null:e.offsetParent}function Xp(e){var t=/firefox/i.test(Bp());if(/Trident/i.test(Bp())&&jp(e)&&Gp(e).position===`fixed`)return null;var n=Jp(e);for(Mp(n)&&(n=n.host);jp(n)&&[`html`,`body`].indexOf(Op(n))<0;){var r=Gp(n);if(r.transform!==`none`||r.perspective!==`none`||r.contain===`paint`||[`transform`,`perspective`].indexOf(r.willChange)!==-1||t&&r.willChange===`filter`||t&&r.filter&&r.filter!==`none`)return n;n=n.parentNode}return null}function Zp(e){for(var t=kp(e),n=Yp(e);n&&Kp(n)&&Gp(n).position===`static`;)n=Yp(n);return n&&(Op(n)===`html`||Op(n)===`body`&&Gp(n).position===`static`)?t:n||Xp(e)||t}function Qp(e){return[`top`,`bottom`].indexOf(e)>=0?`x`:`y`}function $p(e,t,n){return Lp(e,Rp(t,n))}function em(e,t,n){var r=$p(e,t,n);return r>n?n:r}function tm(){return{top:0,right:0,bottom:0,left:0}}function nm(e){return Object.assign({},tm(),e)}function rm(e,t){return t.reduce(function(t,n){return t[n]=e,t},{})}var im=function(e,t){return e=typeof e==`function`?e(Object.assign({},t.rects,{placement:t.placement})):e,nm(typeof e==`number`?rm(e,yp):e)};function am(e){var t,n=e.state,r=e.name,i=e.options,a=n.elements.arrow,o=n.modifiersData.popperOffsets,s=Ip(n.placement),c=Qp(s),l=[`left`,`right`].indexOf(s)>=0?`height`:`width`;if(!(!a||!o)){var u=im(i.padding,n),d=Up(a),f=c===`y`?`top`:_p,p=c===`y`?hp:gp,m=n.rects.reference[l]+n.rects.reference[c]-o[c]-n.rects.popper[l],h=o[c]-n.rects.reference[c],g=Zp(a),_=g?c===`y`?g.clientHeight||0:g.clientWidth||0:0,v=m/2-h/2,y=u[f],b=_-d[l]-u[p],x=_/2-d[l]/2+v,S=$p(y,x,b),C=c;n.modifiersData[r]=(t={},t[C]=S,t.centerOffset=S-x,t)}}function om(e){var t=e.state,n=e.options.element,r=n===void 0?`[data-popper-arrow]`:n;r!=null&&(typeof r==`string`&&(r=t.elements.popper.querySelector(r),!r)||Wp(t.elements.popper,r)&&(t.elements.arrow=r))}var sm={name:`arrow`,enabled:!0,phase:`main`,fn:am,effect:om,requires:[`popperOffsets`],requiresIfExists:[`preventOverflow`]};function cm(e){return e.split(`-`)[1]}var lm={top:`auto`,right:`auto`,bottom:`auto`,left:`auto`};function um(e,t){var n=e.x,r=e.y,i=t.devicePixelRatio||1;return{x:zp(n*i)/i||0,y:zp(r*i)/i||0}}function dm(e){var t,n=e.popper,r=e.popperRect,i=e.placement,a=e.variation,o=e.offsets,s=e.position,c=e.gpuAcceleration,l=e.adaptive,u=e.roundOffsets,d=e.isFixed,f=o.x,p=f===void 0?0:f,m=o.y,h=m===void 0?0:m,g=typeof u==`function`?u({x:p,y:h}):{x:p,y:h};p=g.x,h=g.y;var _=o.hasOwnProperty(`x`),v=o.hasOwnProperty(`y`),y=_p,b=`top`,x=window;if(l){var S=Zp(n),C=`clientHeight`,w=`clientWidth`;if(S===kp(n)&&(S=qp(n),Gp(S).position!==`static`&&s===`absolute`&&(C=`scrollHeight`,w=`scrollWidth`)),S=S,i===`top`||(i===`left`||i===`right`)&&a===`end`){b=hp;var T=d&&S===x&&x.visualViewport?x.visualViewport.height:S[C];h-=T-r.height,h*=c?1:-1}if(i===`left`||(i===`top`||i===`bottom`)&&a===`end`){y=gp;var E=d&&S===x&&x.visualViewport?x.visualViewport.width:S[w];p-=E-r.width,p*=c?1:-1}}var D=Object.assign({position:s},l&&lm),O=u===!0?um({x:p,y:h},kp(n)):{x:p,y:h};if(p=O.x,h=O.y,c){var k;return Object.assign({},D,(k={},k[b]=v?`0`:``,k[y]=_?`0`:``,k.transform=(x.devicePixelRatio||1)<=1?`translate(`+p+`px, `+h+`px)`:`translate3d(`+p+`px, `+h+`px, 0)`,k))}return Object.assign({},D,(t={},t[b]=v?h+`px`:``,t[y]=_?p+`px`:``,t.transform=``,t))}function fm(e){var t=e.state,n=e.options,r=n.gpuAcceleration,i=r===void 0||r,a=n.adaptive,o=a===void 0||a,s=n.roundOffsets,c=s===void 0||s,l={placement:Ip(t.placement),variation:cm(t.placement),popper:t.elements.popper,popperRect:t.rects.popper,gpuAcceleration:i,isFixed:t.options.strategy===`fixed`};t.modifiersData.popperOffsets!=null&&(t.styles.popper=Object.assign({},t.styles.popper,dm(Object.assign({},l,{offsets:t.modifiersData.popperOffsets,position:t.options.strategy,adaptive:o,roundOffsets:c})))),t.modifiersData.arrow!=null&&(t.styles.arrow=Object.assign({},t.styles.arrow,dm(Object.assign({},l,{offsets:t.modifiersData.arrow,position:`absolute`,adaptive:!1,roundOffsets:c})))),t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-placement":t.placement})}var pm={name:`computeStyles`,enabled:!0,phase:`beforeWrite`,fn:fm,data:{}},mm={passive:!0};function hm(e){var t=e.state,n=e.instance,r=e.options,i=r.scroll,a=i===void 0||i,o=r.resize,s=o===void 0||o,c=kp(t.elements.popper),l=[].concat(t.scrollParents.reference,t.scrollParents.popper);return a&&l.forEach(function(e){e.addEventListener(`scroll`,n.update,mm)}),s&&c.addEventListener(`resize`,n.update,mm),function(){a&&l.forEach(function(e){e.removeEventListener(`scroll`,n.update,mm)}),s&&c.removeEventListener(`resize`,n.update,mm)}}var gm={name:`eventListeners`,enabled:!0,phase:`write`,fn:function(){},effect:hm,data:{}},_m={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vm(e){return e.replace(/left|right|bottom|top/g,function(e){return _m[e]})}var ym={start:`end`,end:`start`};function bm(e){return e.replace(/start|end/g,function(e){return ym[e]})}function xm(e){var t=kp(e);return{scrollLeft:t.pageXOffset,scrollTop:t.pageYOffset}}function Sm(e){return Hp(qp(e)).left+xm(e).scrollLeft}function Cm(e,t){var n=kp(e),r=qp(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;var l=Vp();(l||!l&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}return{width:a,height:o,x:s+Sm(e),y:c}}function wm(e){var t=qp(e),n=xm(e),r=e.ownerDocument?.body,i=Lp(t.scrollWidth,t.clientWidth,r?r.scrollWidth:0,r?r.clientWidth:0),a=Lp(t.scrollHeight,t.clientHeight,r?r.scrollHeight:0,r?r.clientHeight:0),o=-n.scrollLeft+Sm(e),s=-n.scrollTop;return Gp(r||t).direction===`rtl`&&(o+=Lp(t.clientWidth,r?r.clientWidth:0)-i),{width:i,height:a,x:o,y:s}}function Tm(e){var t=Gp(e),n=t.overflow,r=t.overflowX,i=t.overflowY;return/auto|scroll|overlay|hidden/.test(n+i+r)}function Em(e){return[`html`,`body`,`#document`].indexOf(Op(e))>=0?e.ownerDocument.body:jp(e)&&Tm(e)?e:Em(Jp(e))}function Dm(e,t){t===void 0&&(t=[]);var n=Em(e),r=n===e.ownerDocument?.body,i=kp(n),a=r?[i].concat(i.visualViewport||[],Tm(n)?n:[]):n,o=t.concat(a);return r?o:o.concat(Dm(Jp(a)))}function Om(e){return Object.assign({},e,{left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height})}function km(e,t){var n=Hp(e,!1,t===`fixed`);return n.top+=e.clientTop,n.left+=e.clientLeft,n.bottom=n.top+e.clientHeight,n.right=n.left+e.clientWidth,n.width=e.clientWidth,n.height=e.clientHeight,n.x=n.left,n.y=n.top,n}function Am(e,t,n){return t===`viewport`?Om(Cm(e,n)):Ap(t)?km(t,n):Om(wm(qp(e)))}function jm(e){var t=Dm(Jp(e)),n=[`absolute`,`fixed`].indexOf(Gp(e).position)>=0&&jp(e)?Zp(e):e;return Ap(n)?t.filter(function(e){return Ap(e)&&Wp(e,n)&&Op(e)!==`body`}):[]}function Mm(e,t,n,r){var i=t===`clippingParents`?jm(e):[].concat(t),a=[].concat(i,[n]),o=a[0],s=a.reduce(function(t,n){var i=Am(e,n,r);return t.top=Lp(i.top,t.top),t.right=Rp(i.right,t.right),t.bottom=Rp(i.bottom,t.bottom),t.left=Lp(i.left,t.left),t},Am(e,o,r));return s.width=s.right-s.left,s.height=s.bottom-s.top,s.x=s.left,s.y=s.top,s}function Nm(e){var t=e.reference,n=e.element,r=e.placement,i=r?Ip(r):null,a=r?cm(r):null,o=t.x+t.width/2-n.width/2,s=t.y+t.height/2-n.height/2,c;switch(i){case`top`:c={x:o,y:t.y-n.height};break;case hp:c={x:o,y:t.y+t.height};break;case gp:c={x:t.x+t.width,y:s};break;case _p:c={x:t.x-n.width,y:s};break;default:c={x:t.x,y:t.y}}var l=i?Qp(i):null;if(l!=null){var u=l===`y`?`height`:`width`;switch(a){case bp:c[l]=c[l]-(t[u]/2-n[u]/2);break;case`end`:c[l]=c[l]+(t[u]/2-n[u]/2)}}return c}function Pm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=r===void 0?e.placement:r,a=n.strategy,o=a===void 0?e.strategy:a,s=n.boundary,c=s===void 0?xp:s,l=n.rootBoundary,u=l===void 0?Sp:l,d=n.elementContext,f=d===void 0?Cp:d,p=n.altBoundary,m=p!==void 0&&p,h=n.padding,g=h===void 0?0:h,_=nm(typeof g==`number`?rm(g,yp):g),v=f===`popper`?wp:Cp,y=e.rects.popper,b=e.elements[m?v:f],x=Mm(Ap(b)?b:b.contextElement||qp(e.elements.popper),c,u,o),S=Hp(e.elements.reference),C=Nm({reference:S,element:y,strategy:`absolute`,placement:i}),w=Om(Object.assign({},y,C)),T=f===`popper`?w:S,E={top:x.top-T.top+_.top,bottom:T.bottom-x.bottom+_.bottom,left:x.left-T.left+_.left,right:T.right-x.right+_.right},D=e.modifiersData.offset;if(f===`popper`&&D){var O=D[i];Object.keys(E).forEach(function(e){var t=[`right`,`bottom`].indexOf(e)>=0?1:-1,n=[`top`,`bottom`].indexOf(e)>=0?`y`:`x`;E[e]+=O[n]*t})}return E}function Fm(e,t){t===void 0&&(t={});var n=t,r=n.placement,i=n.boundary,a=n.rootBoundary,o=n.padding,s=n.flipVariations,c=n.allowedAutoPlacements,l=c===void 0?Ep:c,u=cm(r),d=u?s?Tp:Tp.filter(function(e){return cm(e)===u}):yp,f=d.filter(function(e){return l.indexOf(e)>=0});f.length===0&&(f=d);var p=f.reduce(function(t,n){return t[n]=Pm(e,{placement:n,boundary:i,rootBoundary:a,padding:o})[Ip(n)],t},{});return Object.keys(p).sort(function(e,t){return p[e]-p[t]})}function Im(e){if(Ip(e)===`auto`)return[];var t=vm(e);return[bm(e),t,bm(t)]}function Lm(e){var t=e.state,n=e.options,r=e.name;if(!t.modifiersData[r]._skip){for(var i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o===void 0||o,c=n.fallbackPlacements,l=n.padding,u=n.boundary,d=n.rootBoundary,f=n.altBoundary,p=n.flipVariations,m=p===void 0||p,h=n.allowedAutoPlacements,g=t.options.placement,_=Ip(g)===g,v=c||(_||!m?[vm(g)]:Im(g)),y=[g].concat(v).reduce(function(e,n){return e.concat(Ip(n)===`auto`?Fm(t,{placement:n,boundary:u,rootBoundary:d,padding:l,flipVariations:m,allowedAutoPlacements:h}):n)},[]),b=t.rects.reference,x=t.rects.popper,S=new Map,C=!0,w=y[0],T=0;T<y.length;T++){var E=y[T],D=Ip(E),O=cm(E)===bp,k=[`top`,hp].indexOf(D)>=0,A=k?`width`:`height`,j=Pm(t,{placement:E,boundary:u,rootBoundary:d,altBoundary:f,padding:l}),M=k?O?gp:_p:O?hp:`top`;b[A]>x[A]&&(M=vm(M));var N=vm(M),P=[];if(a&&P.push(j[D]<=0),s&&P.push(j[M]<=0,j[N]<=0),P.every(function(e){return e})){w=E,C=!1;break}S.set(E,P)}if(C)for(var F=m?3:1,I=function(e){var t=y.find(function(t){var n=S.get(t);if(n)return n.slice(0,e).every(function(e){return e})});if(t)return w=t,`break`},L=F;L>0&&I(L)!==`break`;L--);t.placement!==w&&(t.modifiersData[r]._skip=!0,t.placement=w,t.reset=!0)}}var Rm={name:`flip`,enabled:!0,phase:`main`,fn:Lm,requiresIfExists:[`offset`],data:{_skip:!1}};function zm(e,t,n){return n===void 0&&(n={x:0,y:0}),{top:e.top-t.height-n.y,right:e.right-t.width+n.x,bottom:e.bottom-t.height+n.y,left:e.left-t.width-n.x}}function Bm(e){return[`top`,gp,hp,_p].some(function(t){return e[t]>=0})}function Vm(e){var t=e.state,n=e.name,r=t.rects.reference,i=t.rects.popper,a=t.modifiersData.preventOverflow,o=Pm(t,{elementContext:`reference`}),s=Pm(t,{altBoundary:!0}),c=zm(o,r),l=zm(s,i,a),u=Bm(c),d=Bm(l);t.modifiersData[n]={referenceClippingOffsets:c,popperEscapeOffsets:l,isReferenceHidden:u,hasPopperEscaped:d},t.attributes.popper=Object.assign({},t.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var Hm={name:`hide`,enabled:!0,phase:`main`,requiresIfExists:[`preventOverflow`],fn:Vm};function Um(e,t,n){var r=Ip(e),i=[`left`,`top`].indexOf(r)>=0?-1:1,a=typeof n==`function`?n(Object.assign({},t,{placement:e})):n,o=a[0],s=a[1];return o||=0,s=(s||0)*i,[`left`,`right`].indexOf(r)>=0?{x:s,y:o}:{x:o,y:s}}function Wm(e){var t=e.state,n=e.options,r=e.name,i=n.offset,a=i===void 0?[0,0]:i,o=Ep.reduce(function(e,n){return e[n]=Um(n,t.rects,a),e},{}),s=o[t.placement],c=s.x,l=s.y;t.modifiersData.popperOffsets!=null&&(t.modifiersData.popperOffsets.x+=c,t.modifiersData.popperOffsets.y+=l),t.modifiersData[r]=o}var Gm={name:`offset`,enabled:!0,phase:`main`,requires:[`popperOffsets`],fn:Wm};function Km(e){var t=e.state,n=e.name;t.modifiersData[n]=Nm({reference:t.rects.reference,element:t.rects.popper,strategy:`absolute`,placement:t.placement})}var qm={name:`popperOffsets`,enabled:!0,phase:`read`,fn:Km,data:{}};function Jm(e){return e===`x`?`y`:`x`}function Ym(e){var t=e.state,n=e.options,r=e.name,i=n.mainAxis,a=i===void 0||i,o=n.altAxis,s=o!==void 0&&o,c=n.boundary,l=n.rootBoundary,u=n.altBoundary,d=n.padding,f=n.tether,p=f===void 0||f,m=n.tetherOffset,h=m===void 0?0:m,g=Pm(t,{boundary:c,rootBoundary:l,padding:d,altBoundary:u}),_=Ip(t.placement),v=cm(t.placement),y=!v,b=Qp(_),x=Jm(b),S=t.modifiersData.popperOffsets,C=t.rects.reference,w=t.rects.popper,T=typeof h==`function`?h(Object.assign({},t.rects,{placement:t.placement})):h,E=typeof T==`number`?{mainAxis:T,altAxis:T}:Object.assign({mainAxis:0,altAxis:0},T),D=t.modifiersData.offset?t.modifiersData.offset[t.placement]:null,O={x:0,y:0};if(S){if(a){var k=b===`y`?`top`:_p,A=b===`y`?hp:gp,j=b===`y`?`height`:`width`,M=S[b],N=M+g[k],P=M-g[A],F=p?-w[j]/2:0,I=v===`start`?C[j]:w[j],L=v===`start`?-w[j]:-C[j],R=t.elements.arrow,ee=p&&R?Up(R):{width:0,height:0},te=t.modifiersData[`arrow#persistent`]?t.modifiersData[`arrow#persistent`].padding:tm(),ne=te[k],z=te[A],B=$p(0,C[j],ee[j]),V=y?C[j]/2-F-B-ne-E.mainAxis:I-B-ne-E.mainAxis,re=y?-C[j]/2+F+B+z+E.mainAxis:L+B+z+E.mainAxis,ie=t.elements.arrow&&Zp(t.elements.arrow),ae=ie?b===`y`?ie.clientTop||0:ie.clientLeft||0:0,oe=D?.[b]??0,se=M+V-oe-ae,H=M+re-oe,ce=$p(p?Rp(N,se):N,M,p?Lp(P,H):P);S[b]=ce,O[b]=ce-M}if(s){var le=b===`x`?`top`:_p,ue=b===`x`?hp:gp,de=S[x],fe=x===`y`?`height`:`width`,pe=de+g[le],me=de-g[ue],he=[`top`,_p].indexOf(_)!==-1,U=D?.[x]??0,ge=he?pe:de-C[fe]-w[fe]-U+E.altAxis,_e=he?de+C[fe]+w[fe]-U-E.altAxis:me,ve=p&&he?em(ge,de,_e):$p(p?ge:pe,de,p?_e:me);S[x]=ve,O[x]=ve-de}t.modifiersData[r]=O}}var Xm={name:`preventOverflow`,enabled:!0,phase:`main`,fn:Ym,requiresIfExists:[`offset`]};function Zm(e){return{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}}function Qm(e){return e===kp(e)||!jp(e)?xm(e):Zm(e)}function $m(e){var t=e.getBoundingClientRect(),n=zp(t.width)/e.offsetWidth||1,r=zp(t.height)/e.offsetHeight||1;return n!==1||r!==1}function eh(e,t,n){n===void 0&&(n=!1);var r=jp(t),i=jp(t)&&$m(t),a=qp(t),o=Hp(e,i,n),s={scrollLeft:0,scrollTop:0},c={x:0,y:0};return(r||!r&&!n)&&((Op(t)!==`body`||Tm(a))&&(s=Qm(t)),jp(t)?(c=Hp(t,!0),c.x+=t.clientLeft,c.y+=t.clientTop):a&&(c.x=Sm(a))),{x:o.left+s.scrollLeft-c.x,y:o.top+s.scrollTop-c.y,width:o.width,height:o.height}}function th(e){var t=new Map,n=new Set,r=[];e.forEach(function(e){t.set(e.name,e)});function i(e){n.add(e.name),[].concat(e.requires||[],e.requiresIfExists||[]).forEach(function(e){if(!n.has(e)){var r=t.get(e);r&&i(r)}}),r.push(e)}return e.forEach(function(e){n.has(e.name)||i(e)}),r}function nh(e){var t=th(e);return Dp.reduce(function(e,n){return e.concat(t.filter(function(e){return e.phase===n}))},[])}function rh(e){var t;return function(){return t||=new Promise(function(n){Promise.resolve().then(function(){t=void 0,n(e())})}),t}}function ih(e){var t=e.reduce(function(e,t){var n=e[t.name];return e[t.name]=n?Object.assign({},n,t,{options:Object.assign({},n.options,t.options),data:Object.assign({},n.data,t.data)}):t,e},{});return Object.keys(t).map(function(e){return t[e]})}var ah={placement:`bottom`,modifiers:[],strategy:`absolute`};function oh(){return![...arguments].some(function(e){return!(e&&typeof e.getBoundingClientRect==`function`)})}function sh(e){e===void 0&&(e={});var t=e,n=t.defaultModifiers,r=n===void 0?[]:n,i=t.defaultOptions,a=i===void 0?ah:i;return function(e,t,n){n===void 0&&(n=a);var i={placement:`bottom`,orderedModifiers:[],options:Object.assign({},ah,a),modifiersData:{},elements:{reference:e,popper:t},attributes:{},styles:{}},o=[],s=!1,c={state:i,setOptions:function(n){var o=typeof n==`function`?n(i.options):n;u(),i.options=Object.assign({},a,i.options,o),i.scrollParents={reference:Ap(e)?Dm(e):e.contextElement?Dm(e.contextElement):[],popper:Dm(t)};var s=nh(ih([].concat(r,i.options.modifiers)));return i.orderedModifiers=s.filter(function(e){return e.enabled}),l(),c.update()},forceUpdate:function(){if(!s){var e=i.elements,t=e.reference,n=e.popper;if(oh(t,n)){i.rects={reference:eh(t,Zp(n),i.options.strategy===`fixed`),popper:Up(n)},i.reset=!1,i.placement=i.options.placement,i.orderedModifiers.forEach(function(e){return i.modifiersData[e.name]=Object.assign({},e.data)});for(var r=0;r<i.orderedModifiers.length;r++){if(i.reset===!0){i.reset=!1,r=-1;continue}var a=i.orderedModifiers[r],o=a.fn,l=a.options,u=l===void 0?{}:l,d=a.name;typeof o==`function`&&(i=o({state:i,options:u,name:d,instance:c})||i)}}}},update:rh(function(){return new Promise(function(e){c.forceUpdate(),e(i)})}),destroy:function(){u(),s=!0}};if(!oh(e,t))return c;c.setOptions(n).then(function(e){!s&&n.onFirstUpdate&&n.onFirstUpdate(e)});function l(){i.orderedModifiers.forEach(function(e){var t=e.name,n=e.options,r=n===void 0?{}:n,a=e.effect;if(typeof a==`function`){var s=a({state:i,name:t,instance:c,options:r});o.push(s||function(){})}})}function u(){o.forEach(function(e){return e()}),o=[]}return c}}var ch=sh({defaultModifiers:[gm,qm,pm,Fp,Gm,Rm,Xm,sm,Hm]});function lh(e){let{elementType:t,externalSlotProps:n,ownerState:r,skipResolvingSlotProps:i=!1,...a}=e,o=i?{}:Uc(n,r),{props:s,internalRef:c}=qc({...a,externalSlotProps:o}),l=as(c,o?.ref,e.additionalProps?.ref);return Hc(t,{...s,ref:l},r)}function uh(e){return K(`MuiPopper`,e)}Wr(`MuiPopper`,[`root`]);function dh(e,t){if(t===`ltr`)return e;switch(e){case`bottom-end`:return`bottom-start`;case`bottom-start`:return`bottom-end`;case`top-end`:return`top-start`;case`top-start`:return`top-end`;default:return e}}function fh(e){return typeof e==`function`?e():e}function ph(e){return e.nodeType!==void 0}var mh=e=>{let{classes:t}=e;return va({root:[`root`]},uh,t)},hh={},gh=v.forwardRef(function(e,t){let{anchorEl:n,children:r,direction:i,disablePortal:a,modifiers:o,open:s,placement:c,popperOptions:l,popperRef:u,slotProps:d={},slots:f={},TransitionProps:p,ownerState:m,...h}=e,g=v.useRef(null),_=as(g,t),y=v.useRef(null),b=as(y,u),x=v.useRef(b);oi(()=>{x.current=b},[b]),v.useImperativeHandle(u,()=>y.current,[]);let S=dh(c,i),[C,w]=v.useState(S),T=v.useMemo(()=>fh(n),[n]);v.useEffect(()=>{y.current&&y.current.forceUpdate()}),oi(()=>{if(!T||!s)return;let e=e=>{w(e.placement)},t=[{name:`preventOverflow`,options:{altBoundary:a}},{name:`flip`,options:{altBoundary:a}},{name:`onUpdate`,enabled:!0,phase:`afterWrite`,fn:({state:t})=>{e(t)}}];o!=null&&(t=t.concat(o)),l&&l.modifiers!=null&&(t=t.concat(l.modifiers));let n=ch(T,g.current,{placement:S,...l,modifiers:t});x.current(n);let r=g.current;return()=>{if(r){let{style:e}=r,t=e.position,i=e.top,a=e.left,o=e.transform;n.destroy(),e.position=t,e.top=i,e.left=a,e.transform=o}else n.destroy();x.current(null)}},[T,a,o,s,l,S]);let E={placement:C};p!==null&&(E.TransitionProps=p);let D=mh(e),O=f.root??`div`,k=lh({elementType:O,externalSlotProps:d.root,externalForwardedProps:h,additionalProps:{role:`tooltip`,ref:_},ownerState:e,className:D.root});return(0,W.jsx)(O,{...k,children:typeof r==`function`?r(E):r})}),_h=J(v.forwardRef(function(e,t){let{anchorEl:n,children:r,container:i,direction:a=`ltr`,disablePortal:o=!1,keepMounted:s=!1,modifiers:c,open:l,placement:u=`bottom`,popperOptions:d=hh,popperRef:f,style:p,transition:m=!1,slotProps:h={},slots:g={},..._}=e,[y,b]=v.useState(!0),x=()=>{b(!1)},S=()=>{b(!0)};if(!s&&!l&&(!m||y))return null;let C;if(i)C=i;else if(n){let e=fh(n);C=e&&ph(e)?ss(e).body:ss(null).body}let w=!l&&s&&(!m||y)?`none`:void 0,T=m?{in:l,onEnter:x,onExited:S}:void 0;return(0,W.jsx)(Zu,{disablePortal:o,container:C,children:(0,W.jsx)(gh,{anchorEl:n,direction:a,disablePortal:o,modifiers:c,ref:t,open:m?!y:l,placement:u,popperOptions:d,popperRef:f,slotProps:h,slots:g,..._,style:{position:`fixed`,top:0,left:0,display:w,...p},TransitionProps:T,children:r})})}),{name:`MuiPopper`,slot:`Root`})({}),vh=v.forwardRef(function(e,t){let n=Ii(),{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}=Jo({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,W.jsx)(_h,{as:i,direction:n?`rtl`:`ltr`,slots:m,slotProps:h,..._,ref:t})});function yh(e){return K(`MuiTooltip`,e)}var bh=Wr(`MuiTooltip`,[`popper`,`popperInteractive`,`popperArrow`,`popperClose`,`tooltip`,`tooltipArrow`,`touch`,`tooltipPlacementLeft`,`tooltipPlacementRight`,`tooltipPlacementTop`,`tooltipPlacementBottom`,`arrow`]);function xh(e){return Math.round(e*1e5)/1e5}var Sh=e=>{let{classes:t,disableInteractive:n,arrow:r,touch:i,placement:a}=e;return va({popper:[`popper`,!n&&`popperInteractive`,r&&`popperArrow`],tooltip:[`tooltip`,r&&`tooltipArrow`,i&&`touch`,`tooltipPlacement${Y(a.split(`-`)[0])}`],arrow:[`arrow`]},yh,t)},Ch=J(vh,{name:`MuiTooltip`,slot:`Popper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.popper,!n.disableInteractive&&t.popperInteractive,n.arrow&&t.popperArrow,!n.open&&t.popperClose]}})(_s(({theme:e})=>({zIndex:(e.vars||e).zIndex.tooltip,pointerEvents:`none`,variants:[{props:({ownerState:e,open:t})=>t&&!e.disableInteractive,style:{pointerEvents:`auto`}},{props:({ownerState:e})=>e.arrow,style:{[`&[data-popper-placement*="bottom"] .${bh.arrow}`]:{top:0,marginTop:`-0.71em`,"&::before":{transformOrigin:`0 100%`}},[`&[data-popper-placement*="top"] .${bh.arrow}`]:{bottom:0,marginBottom:`-0.71em`,"&::before":{transformOrigin:`100% 0`}},[`&[data-popper-placement*="right"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineStart:0,marginInlineStart:`-0.71em`,"&::before":{transformOrigin:`100% 100%`}},[`&[data-popper-placement*="left"] .${bh.arrow}`]:{height:`1em`,width:`0.71em`,insetInlineEnd:0,marginInlineEnd:`-0.71em`,"&::before":{transformOrigin:`0 0`}}}}]}))),wh=J(`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${Y(n.placement.split(`-`)[0])}`]]}})(_s(({theme:e})=>({backgroundColor:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.92),borderRadius:(e.vars||e).shape.borderRadius,color:(e.vars||e).palette.common.white,fontFamily:e.typography.fontFamily,padding:`4px 8px`,fontSize:e.typography.pxToRem(11),maxWidth:300,margin:2,wordWrap:`break-word`,fontWeight:e.typography.fontWeightMedium,[`.${bh.popper}[data-popper-placement*="left"] &`]:{transformOrigin:`right center`,marginInlineEnd:`14px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{transformOrigin:`left center`,marginInlineStart:`14px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{transformOrigin:`center bottom`,marginBottom:`14px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{transformOrigin:`center top`,marginTop:`14px`},variants:[{props:({ownerState:e})=>e.arrow,style:{position:`relative`,marginBlock:0}},{props:({ownerState:e})=>e.touch,style:{padding:`8px 16px`,fontSize:e.typography.pxToRem(14),lineHeight:`${xh(16/14)}em`,fontWeight:e.typography.fontWeightRegular}},{props:({ownerState:e})=>e.touch,style:{[`.${bh.popper}[data-popper-placement*="left"] &`]:{marginInlineEnd:`24px`},[`.${bh.popper}[data-popper-placement*="right"] &`]:{marginInlineStart:`24px`},[`.${bh.popper}[data-popper-placement*="top"] &`]:{marginBottom:`24px`},[`.${bh.popper}[data-popper-placement*="bottom"] &`]:{marginTop:`24px`}}}]}))),Th=J(`span`,{name:`MuiTooltip`,slot:`Arrow`})(_s(({theme:e})=>({overflow:`hidden`,position:`absolute`,width:`1em`,height:`0.71em`,boxSizing:`border-box`,color:e.vars?e.vars.palette.Tooltip.bg:e.alpha(e.palette.grey[700],.9),"&::before":{content:`""`,margin:`auto`,display:`block`,width:`100%`,height:`100%`,backgroundColor:`currentColor`,transform:`rotate(45deg)`}}))),Eh=!1,Dh=new xl,Oh={x:0,y:0};function kh(e,t){return(n,...r)=>{t&&t(n,...r),e(n,...r)}}var Ah=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTooltip`}),{arrow:r=!1,children:i,classes:a,describeChild:o=!1,disableFocusListener:s=!1,disableHoverListener:c=!1,disableInteractive:l=!1,disableTouchListener:u=!1,enterDelay:d=100,enterNextDelay:f=0,enterTouchDelay:p=700,followCursor:m=!1,id:h,leaveDelay:g=0,leaveTouchDelay:_=1500,onClose:y,onOpen:b,open:x,placement:S=`bottom`,slotProps:C={},slots:w={},title:T,...E}=n,D=v.isValidElement(i)?i:(0,W.jsx)(`span`,{children:i}),O=Uo(),[k,A]=v.useState(),[j,M]=v.useState(null),N=v.useRef(!1),P=l||m,F=Sl(),I=Sl(),L=Sl(),R=Sl(),[ee,te]=Dd({controlled:x,default:!1,name:`Tooltip`,state:`open`}),ne=ee,z=Td(h),B=v.useRef(),V=ul(()=>{B.current!==void 0&&(document.body.style.WebkitUserSelect=B.current,B.current=void 0),R.clear()});v.useEffect(()=>V,[V]);let re=e=>{Dh.clear(),Eh=!0,te(!0),b&&!ne&&b(e)},ie=ul(e=>{Dh.start(800+g,()=>{Eh=!1}),te(!1),y&&ne&&y(e),F.start(O.transitions.duration.shortest,()=>{N.current=!1})}),ae=e=>{k?.disabled||N.current&&e.type!==`touchstart`||(k&&k.removeAttribute(`title`),I.clear(),L.clear(),d||Eh&&f?I.start(Eh?f:d,()=>{re(e)}):re(e))},oe=e=>{I.clear(),L.start(g,()=>{ie(e)})},[,se]=v.useState(!1),H=e=>{let t=e?.target??k;if(!t||t.disabled||!ll(t)){se(!1);let n=e??new Event(`blur`);!e&&t&&(Object.defineProperty(n,"target",{value:t}),Object.defineProperty(n,"currentTarget",{value:t})),oe(n)}},ce=e=>{if(k||A(e.currentTarget),ll(e.target)){let t=e=>{e.target.disabled&&H(e),e.target.removeEventListener(`blur`,t)};e.target.addEventListener(`blur`,t),se(!0),ae(e)}},le=e=>{N.current=!0;let t=D.props;t.onTouchStart&&t.onTouchStart(e)},ue=e=>{le(e),L.clear(),F.clear(),V(),B.current=document.body.style.WebkitUserSelect,document.body.style.WebkitUserSelect=`none`,R.start(p,()=>{document.body.style.WebkitUserSelect=B.current,ae(e)})},de=e=>{D.props.onTouchEnd&&D.props.onTouchEnd(e),V(),L.start(_,()=>{ie(e)})};v.useEffect(()=>{if(!ne)return;function e(e){e.key===`Escape`&&ie(e)}return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},[ie,ne]);let fe=vs(Iu(D),A,t);!T&&T!==0&&(ne=!1);let pe=v.useRef(),me=e=>{let t=D.props;t.onMouseMove&&t.onMouseMove(e),Oh={x:e.clientX,y:e.clientY},pe.current&&pe.current.update()},he={},U=typeof T==`string`;o?(he.title=!ne&&U&&!c?T:null,he[`aria-describedby`]=ne?z:null):(he[`aria-label`]=U?T:null,he[`aria-labelledby`]=ne&&!U?z:null);let ge={...he,...E,...D.props,className:G(E.className,D.props.className),onTouchStart:le,ref:fe,...m?{onMouseMove:me}:{}},_e={};u||(ge.onTouchStart=ue,ge.onTouchEnd=de),c||(ge.onMouseOver=kh(ae,ge.onMouseOver),ge.onMouseLeave=kh(oe,ge.onMouseLeave),P||(_e.onMouseOver=ae,_e.onMouseLeave=oe)),s||(ge.onFocus=kh(ce,ge.onFocus),ge.onBlur=kh(H,ge.onBlur),P||(_e.onFocus=ce,_e.onBlur=H));let ve={...n,arrow:r,disableInteractive:P,placement:S,touch:N.current},ye=typeof C.popper==`function`?C.popper(ve):C.popper,be=v.useMemo(()=>{let e=[{name:`arrow`,enabled:!!j,options:{element:j,padding:4}}];return ye?.popperOptions?.modifiers&&(e=e.concat(ye.popperOptions.modifiers)),{...ye?.popperOptions,modifiers:e}},[j,ye?.popperOptions]),xe=Sh(ve),Se={slots:w,slotProps:{arrow:C.arrow,popper:ye,tooltip:C.tooltip,transition:C.transition}},[Ce,we]=Jc(`popper`,{elementType:Ch,externalForwardedProps:Se,ownerState:ve,className:xe.popper}),[Te,Ee]=Jc(`transition`,{elementType:mp,externalForwardedProps:Se,ownerState:ve}),[De,Oe]=Jc(`tooltip`,{elementType:wh,className:xe.tooltip,externalForwardedProps:Se,ownerState:ve}),[ke,Ae]=Jc(`arrow`,{elementType:Th,className:xe.arrow,externalForwardedProps:Se,ownerState:ve,ref:M});return(0,W.jsxs)(v.Fragment,{children:[v.cloneElement(D,ge),(0,W.jsx)(Ce,{as:vh,placement:S,anchorEl:m?{getBoundingClientRect:()=>({top:Oh.y,left:Oh.x,right:Oh.x,bottom:Oh.y,width:0,height:0})}:k,popperRef:pe,open:k?ne:!1,id:z,transition:!0,..._e,...we,popperOptions:be,children:({TransitionProps:e})=>(0,W.jsx)(Te,{timeout:O.transitions.duration.shorter,...e,...Ee,children:(0,W.jsxs)(De,{...Oe,children:[T,r?(0,W.jsx)(ke,{...Ae}):null]})})})]})}),jh=sl((0,W.jsx)(`path`,{d:`M4 13h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1m0 8h6c.55 0 1-.45 1-1v-4c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v4c0 .55.45 1 1 1m10 0h6c.55 0 1-.45 1-1v-8c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1v8c0 .55.45 1 1 1M13 4v4c0 .55.45 1 1 1h6c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1h-6c-.55 0-1 .45-1 1`}),`DashboardRounded`),Mh=sl((0,W.jsx)(`path`,{d:`M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2`}),`ChatBubbleRounded`),Nh=sl((0,W.jsx)(`path`,{d:`M14.59 2.59c-.38-.38-.89-.59-1.42-.59H6c-1.1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8.83c0-.53-.21-1.04-.59-1.41zM15 18H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m0-4H9c-.55 0-1-.45-1-1s.45-1 1-1h6c.55 0 1 .45 1 1s-.45 1-1 1m-2-6V3.5L18.5 9H14c-.55 0-1-.45-1-1`}),`DescriptionRounded`),Ph=sl((0,W.jsx)(`path`,{d:`M3 7c.55 0 1 .45 1 1v13h13c.55 0 1 .45 1 1s-.45 1-1 1H4c-1.1 0-2-.9-2-2V8c0-.55.45-1 1-1m12.59-5.41c-.38-.38-.89-.59-1.42-.59H8c-1.1 0-1.99.9-1.99 2L6 17c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V7.83c0-.53-.21-1.04-.59-1.41zM15.5 15h-4c-.55 0-1-.45-1-1s.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1m0-6h-1v1c0 .55-.45 1-1 1s-1-.45-1-1V9h-1c-.55 0-1-.45-1-1s.45-1 1-1h1V6c0-.55.45-1 1-1s1 .45 1 1v1h1c.55 0 1 .45 1 1s-.45 1-1 1`}),`DifferenceRounded`),Fh=sl((0,W.jsx)(`path`,{d:`M20 4H4c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2m0 14H4V8h16zm-8-2c0-.55.45-1 1-1h4c.55 0 1 .45 1 1s-.45 1-1 1h-4c-.55 0-1-.45-1-1M6.79 9.71c.39-.39 1.02-.39 1.41 0l2.59 2.59c.39.39.39 1.02 0 1.41L8.2 16.3c-.39.39-1.02.39-1.41 0a.996.996 0 0 1 0-1.41L8.67 13l-1.88-1.88a.996.996 0 0 1 0-1.41`}),`TerminalRounded`),Ih=sl((0,W.jsx)(`path`,{d:`M13.26 3C8.17 2.86 4 6.95 4 12H2.21c-.45 0-.67.54-.35.85l2.79 2.8c.2.2.51.2.71 0l2.79-2.8c.31-.31.09-.85-.36-.85H6c0-3.9 3.18-7.05 7.1-7 3.72.05 6.85 3.18 6.9 6.9.05 3.91-3.1 7.1-7 7.1-1.61 0-3.1-.55-4.28-1.48-.4-.31-.96-.28-1.32.08-.42.42-.39 1.13.08 1.49C9 20.29 10.91 21 13 21c5.05 0 9.14-4.17 9-9.26-.13-4.69-4.05-8.61-8.74-8.74m-.51 5c-.41 0-.75.34-.75.75v3.68c0 .35.19.68.49.86l3.12 1.85c.36.21.82.09 1.03-.26.21-.36.09-.82-.26-1.03l-2.88-1.71v-3.4c0-.4-.34-.74-.75-.74`}),`HistoryRounded`),Lh=sl((0,W.jsx)(`path`,{d:`M9.19 6.35c-2.04 2.29-3.44 5.58-3.57 5.89l-2.26-.97c-.65-.28-.81-1.13-.31-1.63l3.01-3.01c.47-.47 1.15-.68 1.81-.55zm1.49 10.16c.3.3.74.38 1.12.2 1.16-.54 3.65-1.81 5.26-3.42 4.59-4.59 4.63-8.33 4.36-9.93-.07-.4-.39-.72-.79-.79-1.6-.27-5.34-.23-9.93 4.36-1.61 1.61-2.87 4.1-3.42 5.26-.18.38-.09.83.2 1.12zm6.97-1.7c-2.29 2.04-5.58 3.44-5.89 3.57l.97 2.26c.28.65 1.13.81 1.63.31l3.01-3.01c.47-.47.68-1.15.55-1.81zm-8.71 2.6c.2 1.06-.15 2.04-.82 2.71-.77.77-3.16 1.34-4.71 1.64-.69.13-1.3-.48-1.17-1.17.3-1.55.86-3.94 1.64-4.71.67-.67 1.65-1.02 2.71-.82 1.17.22 2.13 1.18 2.35 2.35M13 9c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2`}),`RocketLaunchRounded`),Rh=sl((0,W.jsx)(`path`,{d:`M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1m0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1`}),`MenuRounded`),zh=sl((0,W.jsx)(`path`,{d:`M12 7c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5M2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1m18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1M11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1m0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1M5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0z`}),`LightModeRounded`),Bh=sl((0,W.jsx)(`path`,{d:`M11.01 3.05C6.51 3.54 3 7.36 3 12c0 4.97 4.03 9 9 9 4.63 0 8.45-3.5 8.95-8 .09-.79-.78-1.42-1.54-.95-.84.54-1.84.85-2.91.85-2.98 0-5.4-2.42-5.4-5.4 0-1.06.31-2.06.84-2.89.45-.67-.04-1.63-.93-1.56`}),`DarkModeRounded`),Vh=sl((0,W.jsx)(`path`,{d:`M20 6h-8l-1.41-1.41C10.21 4.21 9.7 4 9.17 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2m-1 12H5c-.55 0-1-.45-1-1V9c0-.55.45-1 1-1h14c.55 0 1 .45 1 1v8c0 .55-.45 1-1 1`}),`FolderOpenRounded`);function Hh(e){return K(`MuiTab`,e)}var Uh=Wr(`MuiTab`,[`root`,`labelIcon`,`textColorInherit`,`textColorPrimary`,`textColorSecondary`,`selected`,`disabled`,`fullWidth`,`wrapped`,`icon`]),Wh=e=>{let{classes:t,textColor:n,fullWidth:r,wrapped:i,icon:a,label:o,selected:s,disabled:c}=e;return va({root:[`root`,a&&o&&`labelIcon`,`textColor${Y(n)}`,r&&`fullWidth`,i&&`wrapped`,s&&`selected`,c&&`disabled`],icon:[`icon`]},Hh,t)},Gh=J(eu,{name:`MuiTab`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.label&&n.icon&&t.labelIcon,t[`textColor${Y(n.textColor)}`],n.fullWidth&&t.fullWidth,n.wrapped&&t.wrapped,{[`& .${Uh.icon}`]:t.icon}]}})(_s(({theme:e})=>({...e.typography.button,maxWidth:360,minWidth:90,position:`relative`,minHeight:48,flexShrink:0,padding:`12px 16px`,overflow:`hidden`,whiteSpace:`normal`,textAlign:`center`,lineHeight:1.25,variants:[{props:({ownerState:e})=>e.label&&(e.iconPosition===`top`||e.iconPosition===`bottom`),style:{flexDirection:`column`}},{props:({ownerState:e})=>e.label&&e.iconPosition!==`top`&&e.iconPosition!==`bottom`,style:{flexDirection:`row`}},{props:({ownerState:e})=>e.icon&&e.label,style:{minHeight:72,paddingTop:9,paddingBottom:9}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`top`,style:{[`& > .${Uh.icon}`]:{marginBottom:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`bottom`,style:{[`& > .${Uh.icon}`]:{marginTop:6}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`start`,style:{[`& > .${Uh.icon}`]:{marginRight:e.spacing(1)}}},{props:({ownerState:e,iconPosition:t})=>e.icon&&e.label&&t===`end`,style:{[`& > .${Uh.icon}`]:{marginLeft:e.spacing(1)}}},{props:{textColor:`inherit`},style:{color:`inherit`,opacity:.6,[`&.${Uh.selected}`]:{opacity:1},[`&.${Uh.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity}}},{props:{textColor:`primary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.primary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:{textColor:`secondary`},style:{color:(e.vars||e).palette.text.secondary,[`&.${Uh.selected}`]:{color:(e.vars||e).palette.secondary.main},[`&.${Uh.disabled}`]:{color:(e.vars||e).palette.text.disabled}}},{props:({ownerState:e})=>e.fullWidth,style:{flexShrink:1,flexGrow:1,flexBasis:0,maxWidth:`none`}},{props:({ownerState:e})=>e.wrapped,style:{fontSize:e.typography.pxToRem(12)}}]}))),Kh=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTab`}),{className:r,disabled:i=!1,disableFocusRipple:a=!1,fullWidth:o,icon:s,iconPosition:c=`top`,indicator:l,label:u,onChange:d,onClick:f,onFocus:p,selected:m,selectionFollowsFocus:h,textColor:g=`inherit`,value:_,wrapped:y=!1,...b}=n,x=Of(),S=Nf({id:_,ref:t,disabled:i,selected:m}),C=x.getItemMap().size===0&&m?0:S.tabIndex,w={...n,disabled:i,disableFocusRipple:a,selected:m,icon:!!s,iconPosition:c,label:!!u,fullWidth:o,textColor:g,wrapped:y},T=Wh(w),E=s&&u&&v.isValidElement(s)?v.cloneElement(s,{className:G(T.icon,s.props.className)}):s;return(0,W.jsxs)(Gh,{internalNativeButton:!0,focusRipple:!a,className:G(T.root,r),ref:S.ref,role:`tab`,"aria-selected":m,disabled:i,onClick:e=>{!m&&d&&d(e,_),f&&f(e)},onFocus:e=>{h&&!m&&d&&d(e,_),p&&p(e)},tabIndex:C,ownerState:w,...b,children:[c===`top`||c===`start`?(0,W.jsxs)(v.Fragment,{children:[E,u]}):(0,W.jsxs)(v.Fragment,{children:[u,E]}),l]})});function qh(e){return(1+Math.sin(Math.PI*e-Math.PI/2))/2}function Jh(e,t,n,r={},i=()=>{}){let{ease:a=qh,duration:o=300}=r,s=null,c=t[e],l=!1,u=()=>{l=!0},d=r=>{if(l){i(Error(`Animation cancelled`));return}s===null&&(s=r);let u=Math.min(1,(r-s)/o);if(t[e]=a(u)*(n-c)+c,u>=1){requestAnimationFrame(()=>{i(null)});return}requestAnimationFrame(d)};return c===n?(i(Error(`Element already at target position`)),u):(requestAnimationFrame(d),u)}var Yh={width:99,height:99,position:`absolute`,top:-9999,overflow:`scroll`,pointerEvents:`none`};function Xh(e){let{onChange:t,...n}=e,r=v.useRef(),i=v.useRef(null),a=()=>{r.current=i.current.offsetHeight-i.current.clientHeight};return ys(()=>{let e=Sd(()=>{let e=r.current;a(),e!==r.current&&t(r.current)}),n=wd(i.current);return n.addEventListener(`resize`,e),()=>{e.clear(),n.removeEventListener(`resize`,e)}},[t]),v.useEffect(()=>{a(),t(r.current)},[t]),(0,W.jsx)(`div`,{style:Yh,...n,ref:i})}var Zh=sl((0,W.jsx)(`path`,{d:`M15.41 16.09l-4.58-4.59 4.58-4.59L14 5.5l-6 6 6 6z`}),`KeyboardArrowLeft`),Qh=sl((0,W.jsx)(`path`,{d:`M8.59 16.34l4.58-4.59-4.58-4.59L10 5.75l6 6-6 6z`}),`KeyboardArrowRight`);function $h(e){return K(`MuiTabScrollButton`,e)}var eg=Wr(`MuiTabScrollButton`,[`root`,`vertical`,`horizontal`,`disabled`]),tg=e=>{let{classes:t,orientation:n,disabled:r}=e;return va({root:[`root`,n,r&&`disabled`]},$h,t)},ng=J(eu,{name:`MuiTabScrollButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.orientation&&t[n.orientation]]}})({width:40,flexShrink:0,opacity:.8,[`&.${eg.disabled}`]:{opacity:0},variants:[{props:{orientation:`vertical`},style:{width:`100%`,height:40,"& svg":{transform:`var(--TabScrollButton-svgRotate)`}}}]}),rg=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTabScrollButton`}),{className:r,slots:i={},slotProps:a={},direction:o,orientation:s,disabled:c,...l}=n,{nativeButton:u,...d}=l,f=Ii(),p={isRtl:f,...n},m=tg(p),h=i.StartScrollButtonIcon??Zh,g=i.EndScrollButtonIcon??Qh,_=lh({elementType:h,externalSlotProps:a.startScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p}),v=lh({elementType:g,externalSlotProps:a.endScrollButtonIcon,additionalProps:{fontSize:`small`},ownerState:p});return(0,W.jsx)(ng,{component:`div`,className:G(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,W.jsx)(h,{..._}):(0,W.jsx)(g,{...v})})});function ig(e){return K(`MuiTabs`,e)}var ag=Wr(`MuiTabs`,[`root`,`vertical`,`list`,`centered`,`scroller`,`fixed`,`scrollableX`,`scrollableY`,`hideScrollbar`,`scrollButtons`,`scrollButtonsHideMobile`,`indicator`]),og=e=>{let{vertical:t,fixed:n,hideScrollbar:r,scrollableX:i,scrollableY:a,centered:o,scrollButtonsHideMobile:s,classes:c}=e;return va({root:[`root`,t&&`vertical`],scroller:[`scroller`,n&&`fixed`,r&&`hideScrollbar`,i&&`scrollableX`,a&&`scrollableY`],list:[`list`,t&&`vertical`,o&&`centered`],indicator:[`indicator`],scrollButtons:[`scrollButtons`,s&&`scrollButtonsHideMobile`],scrollableX:[i&&`scrollableX`],hideScrollbar:[r&&`hideScrollbar`]},ig,c)},sg=J(`div`,{name:`MuiTabs`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${ag.scrollButtons}`]:t.scrollButtons},{[`& .${ag.scrollButtons}`]:n.scrollButtonsHideMobile&&t.scrollButtonsHideMobile},t.root,n.vertical&&t.vertical]}})(_s(({theme:e})=>({overflow:`hidden`,minHeight:48,WebkitOverflowScrolling:`touch`,display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.scrollButtonsHideMobile,style:{[`& .${ag.scrollButtons}`]:{[e.breakpoints.down(`sm`)]:{display:`none`}}}}]}))),cg=J(`div`,{name:`MuiTabs`,slot:`Scroller`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.scroller,n.fixed&&t.fixed,n.hideScrollbar&&t.hideScrollbar,n.scrollableX&&t.scrollableX,n.scrollableY&&t.scrollableY]}})({position:`relative`,display:`inline-block`,flex:`1 1 auto`,whiteSpace:`nowrap`,variants:[{props:({ownerState:e})=>e.fixed,style:{overflowX:`hidden`,width:`100%`}},{props:({ownerState:e})=>e.hideScrollbar,style:{scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}},{props:({ownerState:e})=>e.scrollableX,style:{overflowX:`auto`,overflowY:`hidden`}},{props:({ownerState:e})=>e.scrollableY,style:{overflowY:`auto`,overflowX:`hidden`}}]}),lg=J(`div`,{name:`MuiTabs`,slot:`List`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.list,n.centered&&t.centered]}})({display:`flex`,variants:[{props:({ownerState:e})=>e.vertical,style:{flexDirection:`column`}},{props:({ownerState:e})=>e.centered,style:{justifyContent:`center`}}]}),ug=J(`span`,{name:`MuiTabs`,slot:`Indicator`})(_s(({theme:e})=>({position:`absolute`,height:2,bottom:0,width:`100%`,...Ws(e),variants:[{props:{indicatorColor:`primary`},style:{backgroundColor:(e.vars||e).palette.primary.main}},{props:{indicatorColor:`secondary`},style:{backgroundColor:(e.vars||e).palette.secondary.main}},{props:({ownerState:e})=>e.vertical,style:{height:`100%`,width:2,right:0}}]}))),dg=J(Xh)({overflowX:`auto`,overflowY:`hidden`,scrollbarWidth:`none`,"&::-webkit-scrollbar":{display:`none`}}),fg={},pg=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTabs`}),r=Uo(),i=Ii(),a=Il(r.motion.reducedMotion,!1),{"aria-label":o,"aria-labelledby":s,action:c,centered:l=!1,children:u,className:d,component:f=`div`,allowScrollButtonsMobile:p=!1,indicatorColor:m=`primary`,onChange:h,orientation:g=`horizontal`,scrollButtons:_=`auto`,selectionFollowsFocus:y,slots:b={},slotProps:x={},textColor:S=`primary`,value:C,variant:w=`standard`,visibleScrollbar:T=!1,...E}=n,D=w===`scrollable`,O=g===`vertical`,k=O?`scrollTop`:`scrollLeft`,A=O?`top`:`left`,j=O?`bottom`:`right`,M=O?`clientHeight`:`clientWidth`,N=O?`height`:`width`,P={...n,component:f,allowScrollButtonsMobile:p,indicatorColor:m,orientation:g,vertical:O,scrollButtons:_,textColor:S,variant:w,visibleScrollbar:T,fixed:!D,hideScrollbar:D&&!T,scrollableX:D&&!O,scrollableY:D&&O,centered:l&&!D,scrollButtonsHideMobile:!p},F=og(P),I=lh({elementType:b.startScrollButtonIcon,externalSlotProps:x.startScrollButtonIcon,ownerState:P}),L=lh({elementType:b.endScrollButtonIcon,externalSlotProps:x.endScrollButtonIcon,ownerState:P}),[R,ee]=v.useState(!1),[te,ne]=v.useState(fg),[z,B]=v.useState(!1),[V,re]=v.useState(!1),[ie,ae]=v.useState(!1),oe=C===!1?null:C,[se,H]=v.useState(!1),[ce,le]=v.useState({overflow:`hidden`,scrollbarWidth:0}),ue=new Map,de=v.useRef(null),fe=v.useRef(null),pe={slots:b,slotProps:x},me=()=>{let e=de.current,t;if(e){let n=e.getBoundingClientRect();t={clientWidth:e.clientWidth,scrollLeft:e.scrollLeft,scrollTop:e.scrollTop,scrollWidth:e.scrollWidth,top:n.top,bottom:n.bottom,left:n.left,right:n.right}}let n;if(e&&C!==!1){let e=fe.current.children;if(e.length>0){let t=e[ue.get(C)];n=t?t.getBoundingClientRect():null}}return{tabsMeta:t,tabMeta:n}},he=ul(()=>{let{tabsMeta:e,tabMeta:t}=me(),n=0,r;O?(r=`top`,t&&e&&(n=t.top-e.top+e.scrollTop)):(r=i?`right`:`left`,t&&e&&(n=(i?-1:1)*(t[r]-e[r]+e.scrollLeft)));let a={[r]:n,[N]:t?t[N]:0};if(typeof te[r]!=`number`||typeof te[N]!=`number`)ne(a);else{let e=Math.abs(te[r]-a[r]),t=Math.abs(te[N]-a[N]);(e>=1||t>=1)&&ne(a)}}),U=(e,{animation:t=!0}={})=>{t&&!a.shouldReduceMotion?Jh(k,de.current,e,{duration:r.transitions.duration.standard}):de.current[k]=e},ge=e=>{let t=de.current[k];t+=O?e:e*(i?-1:1),U(t)},_e=()=>{let e=de.current[M],t=0,n=Array.from(fe.current.children);for(let r=0;r<n.length;r+=1){let i=n[r];if(t+i[M]>e){r===0&&(t=e);break}t+=i[M]}return t},ve=()=>{ge(-1*_e())},ye=()=>{ge(_e())},[be,{onChange:xe,...Se}]=Jc(`scrollbar`,{className:G(F.scrollableX,F.hideScrollbar),elementType:dg,shouldForwardComponentProp:!0,externalForwardedProps:pe,ownerState:P}),Ce=v.useCallback(e=>{xe?.(e),le({overflow:null,scrollbarWidth:e})},[xe]),[we,Te]=Jc(`scrollButtons`,{className:F.scrollButtons,elementType:rg,externalForwardedProps:pe,ownerState:P,additionalProps:{orientation:g,slots:{StartScrollButtonIcon:b.startScrollButtonIcon,EndScrollButtonIcon:b.endScrollButtonIcon},slotProps:{startScrollButtonIcon:I,endScrollButtonIcon:L}}}),Ee=()=>{let e={};e.scrollbarSizeListener=D?(0,W.jsx)(be,{...Se,onChange:Ce}):null;let t=D&&(_===`auto`&&(z||V)||_===!0);return e.scrollButtonStart=t?(0,W.jsx)(we,{direction:i?`right`:`left`,onClick:ve,disabled:!z,...Te}):null,e.scrollButtonEnd=t?(0,W.jsx)(we,{direction:i?`left`:`right`,onClick:ye,disabled:!V,...Te}):null,e},De=ul(e=>{let{tabsMeta:t,tabMeta:n}=me();if(!(!n||!t)){if(n[A]<t[A]){let r=t[k]+(n[A]-t[A]);U(r,{animation:e})}else if(n[j]>t[j]){let r=t[k]+(n[j]-t[j]);U(r,{animation:e})}}}),Oe=ul(()=>{D&&_!==!1&&ae(!ie)});v.useEffect(()=>{let e=Sd(()=>{de.current&&he()}),t,n=n=>{n.forEach(e=>{e.removedNodes.forEach(e=>{t?.unobserve(e)}),e.addedNodes.forEach(e=>{t?.observe(e)})}),e(),Oe()},r=wd(de.current);r.addEventListener(`resize`,e);let i;return typeof ResizeObserver<`u`&&(t=new ResizeObserver(e),Array.from(fe.current.children).forEach(e=>{t.observe(e)})),typeof MutationObserver<`u`&&(i=new MutationObserver(n),i.observe(fe.current,{childList:!0})),()=>{e.clear(),r.removeEventListener(`resize`,e),i?.disconnect(),t?.disconnect()}},[he,Oe]),v.useEffect(()=>{let e=Array.from(fe.current.children),t=e.length;if(typeof IntersectionObserver<`u`&&t>0&&D&&_!==!1){let n=e[0],r=e[t-1],i={root:de.current,threshold:.99},a=new IntersectionObserver(e=>{B(!e[0].isIntersecting)},i);a.observe(n);let o=new IntersectionObserver(e=>{re(!e[0].isIntersecting)},i);return o.observe(r),()=>{a.disconnect(),o.disconnect()}}},[D,_,ie,u?.length]),v.useEffect(()=>{ee(!0)},[]),v.useEffect(()=>{he()}),v.useEffect(()=>{De(fg!==te)},[De,te]),v.useImperativeHandle(c,()=>({updateIndicator:he,updateScrollButtons:Oe}),[he,Oe]);let[ke,Ae]=Jc(`indicator`,{className:F.indicator,elementType:ug,externalForwardedProps:pe,ownerState:P,additionalProps:{style:te}}),je=(0,W.jsx)(ke,{...Ae}),Me=Mf({activeItemId:se?void 0:oe,orientation:g,isRtl:i}),Ne=Me.getContainerProps(),Pe=v.Children.toArray(u).filter(v.isValidElement).map((e,t)=>{let n=e.props.value===void 0?t:e.props.value;return ue.set(n,t),{child:e,index:t,childValue:n}}).map(({child:e,childValue:t})=>{let n=t===C;return v.cloneElement(e,{fullWidth:w===`fullWidth`,indicator:n&&!R&&je,selected:n,selectionFollowsFocus:y,onChange:h,textColor:S,value:t})}),Fe=Ee(),[Ie,Le]=Jc(`root`,{ref:t,className:G(F.root,d),elementType:sg,externalForwardedProps:{...pe,...E,component:f},ownerState:P}),[Re,ze]=Jc(`scroller`,{ref:de,className:F.scroller,elementType:cg,externalForwardedProps:pe,ownerState:P,additionalProps:{style:{overflow:ce.overflow,[O?`margin${i?`Left`:`Right`}`:`marginBottom`]:T?void 0:-ce.scrollbarWidth}}}),Be=vs(Ne.ref,fe),Ve=e=>{let t=fe.current;Ss(bs(t))?.getAttribute(`role`)===`tab`&&Ne.onKeyDown(e)},[He,Ue]=Jc(`list`,{ref:Be,className:F.list,elementType:lg,externalForwardedProps:pe,ownerState:P,getSlotProps:e=>({...e,onBlur:t=>{Ru(t.currentTarget,t.relatedTarget)||H(!1),e.onBlur?.(t)},onKeyDown:t=>{Ve(t),e.onKeyDown?.(t)},onFocus:t=>{H(!0),Ne.onFocus(t),e.onFocus?.(t)}})});return(0,W.jsxs)(Ie,{...Le,children:[Fe.scrollButtonStart,Fe.scrollbarSizeListener,(0,W.jsxs)(Re,{...ze,children:[(0,W.jsx)(He,{"aria-label":o,"aria-labelledby":s,"aria-orientation":g===`vertical`?`vertical`:null,role:`tablist`,...Ue,children:(0,W.jsx)(Df.Provider,{value:Me,children:Pe})}),R&&je]}),Fe.scrollButtonEnd]})}),mg=null,hg=null;async function gg(e){if(!e.ok)return!1;try{let t=await e.json();return typeof t.csrfToken!=`string`||!/^[A-Za-z0-9_-]{43}$/.test(t.csrfToken)?!1:(mg=t.csrfToken,!0)}catch{return!1}}function _g(){return mg}async function vg(){let e=new URLSearchParams(window.location.hash.slice(1)).get(`bootstrap`);if(!e)try{return await gg(await fetch(`/api/v1/browser-session`,{credentials:`same-origin`,headers:{Accept:`application/json`}}))?`existing-session`:`failed`}catch{return`failed`}window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}`);try{return await gg(await fetch(`/api/v1/bootstrap`,{method:`POST`,credentials:`same-origin`,headers:{"Content-Type":`application/json`},body:JSON.stringify({capability:e})}))?`authenticated`:`failed`}catch{return`failed`}}function yg(){return hg??=vg(),hg}var bg=class extends Error{status;constructor(e){super(`webui-request-${e}`),this.status=e}};async function xg(e){let t=await fetch(`/api/v1/snapshot`,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:e});if(!t.ok)throw new bg(t.status);return await t.json()}function Sg(e){return Mg(`/api/v1/session-catalog`,e)}function Cg(e){return Mg(`/api/v1/session-live-state`,e)}function wg(e){return Mg(`/api/v1/session-creation-options`,e)}function Tg(e){return Mg(`/api/v1/provider-auth`,e)}function Eg(e,t){return Mg(`/api/v1/provider-auth/jobs/${encodeURIComponent(e)}`,t)}async function Dg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function Og(e,t){return Dg({action:`provider-auth.start`,providerRef:e},t)}function kg(e,t,n,r){return Dg({action:`provider-auth.respond`,jobRef:e,promptRef:t,value:n},r)}function Ag(e,t){return Dg({action:`provider-auth.cancel`,jobRef:e},t)}async function jg(e){let t=_g();if(!t)throw new bg(403);let n=await fetch(`/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 bg(n.status);return await n.json()}async function Mg(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{Accept:`application/json`},signal:t});if(!n.ok)throw new bg(n.status);return await n.json()}function Ng(e,t){if(!t.startsWith(`/api/v1/`))throw Error(`invalid-inspection-path`);return`/api/v1/sessions/${encodeURIComponent(e)}/inspection/${t.slice(8)}`}function Pg(e,t){return Mg(Ng(e,`/api/v1/snapshot`),t)}function Fg(e,t=null,n=50,r){let i=new URLSearchParams({limit:String(n)});return t&&i.set(`before`,t),Mg(Ng(e,`/api/v1/transcript?${i}`),r)}function Ig(e,t,n){return Mg(Ng(e,`/api/v1/approvals/${encodeURIComponent(t)}`),n)}function Lg(e,t,n){return Mg(Ng(e,`/api/v1/source-changes?view=${encodeURIComponent(t)}`),n)}function Rg(e,t,n,r){return Mg(Ng(e,`/api/v1/diffs/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function zg(e,t,n,r){return Mg(Ng(e,`/api/v1/reviews/${encodeURIComponent(n)}?view=${encodeURIComponent(t)}`),r)}function Bg(e,t,n,r){return Mg(Ng(e,`/api/v1/source-mutations/${encodeURIComponent(n)}?action=${encodeURIComponent(t)}`),r)}function Vg(e,t,n=null,r){let i=n?`?hunkRef=${encodeURIComponent(n)}`:``;return Mg(Ng(e,`/api/v1/source-reverts/${encodeURIComponent(t)}${i}`),r)}function Hg(e,t){return Mg(Ng(e,`/api/v1/commit-summary`),t)}function Ug(e,t,n){return Mg(Ng(e,`/api/v1/log-previews/${encodeURIComponent(t)}`),n)}function Wg(e,t){return Mg(Ng(e,`/api/v1/connections`),t)}async function Gg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function Kg(e,t){return Mg(`/api/v1/mcp-auth/jobs/${encodeURIComponent(e)}`,t)}async function qg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function Jg(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function Yg(e,t){return Mg(`/api/v1/source-changes?view=${encodeURIComponent(e)}`,t)}function Xg(e,t,n){return Mg(`/api/v1/diffs/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function Zg(e,t,n){return Mg(`/api/v1/reviews/${encodeURIComponent(t)}?view=${encodeURIComponent(e)}`,n)}function Qg(e,t,n){return Mg(`/api/v1/source-mutations/${encodeURIComponent(t)}?action=${encodeURIComponent(e)}`,n)}function $g(e,t=null,n){let r=t?`?hunkRef=${encodeURIComponent(t)}`:``;return Mg(`/api/v1/source-reverts/${encodeURIComponent(e)}${r}`,n)}function e_(e){return Mg(`/api/v1/commit-summary`,e)}function t_(e){return Mg(`/api/v1/tasks`,e)}function n_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/timeline`,t)}function r_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/recovery-history`,t)}function i_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/handoff-history`,t)}function a_(e,t){return Mg(`/api/v1/tasks/${encodeURIComponent(e)}/subagent-tree`,t)}function o_(e){return Mg(`/api/v1/monitoring/release`,e)}function s_(e,t){return Mg(`/api/v1/log-previews/${encodeURIComponent(e)}`,t)}function c_(e=null,t=50,n){let r=new URLSearchParams({limit:String(t)});return e&&r.set(`before`,e),Mg(`/api/v1/transcript?${r}`,n)}function l_(e){return Mg(`/api/v1/chat/queue`,e)}function u_(e){return Mg(`/api/v1/session-options/models`,e)}function d_(e,t){return Mg(`/api/v1/approvals/${encodeURIComponent(e)}`,t)}async function f_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function p_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function m_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function h_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function g_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function __(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function v_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function y_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function b_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}async function x_(e,t,n){let r=_g();if(!r)throw new bg(403);let i=await fetch(`/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 bg(i.status);return await i.json()}function S_(e,t){return Mg(e?Ng(e,`/api/v1/documents`):`/api/v1/documents`,t)}function C_(e,t,n){let r=`/api/v1/documents/${encodeURIComponent(t)}`;return Mg(e?Ng(e,r):r,n)}async function w_(e,t){let n=_g();if(!n)throw new bg(403);let r=await fetch(`/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 bg(r.status);return await r.json()}function T_(e){return Array.isArray(e)?`[${e.map(T_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${T_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function E_(e){let t=new TextEncoder().encode(typeof e==`string`?e:T_(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 D_(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 E_({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 E_({action:l.action,identity:l.identity,expectedRevisions:c,payload:s}),l}async function O_(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 k_(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 A_(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 E_({action:t,identity:o.identity,expectedRevisions:a,payload:n}),o}async function j_(e,t){let n=[];return{queueItemRef:e,text:t,attachmentRefs:n,contentDigest:await E_({attachmentRefs:n,text:t})}}async function M_(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 E_({action:t,identity:s.identity,expectedRevisions:a,payload:o}),s}async function N_(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 E_({action:t,identity:o.identity,expectedRevisions:i,payload:a}),o}async function P_(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 E_({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 E_({action:c.action,identity:c.identity,expectedRevisions:s,payload:o}),c}function F_(e){return Array.isArray(e)?`[${e.map(F_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${F_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function I_(e){let t=new TextEncoder().encode(F_(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 L_(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 I_({action:l.action,identity:o,expectedRevisions:s,payload:c}),l}function R_(e){return Array.isArray(e)?`[${e.map(R_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${R_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function z_(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(R_(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function B_(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))||R_(n)!==R_(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 z_({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}function V_(e){return Array.isArray(e)?`[${e.map(V_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${V_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function H_(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(V_(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function U_(e,t){if(t.state!==`ready`||!t.target)throw Error(`source-revert-preview-unavailable`);let n=new Date,r=t.target;if(Date.parse(r.expiresAt)<=n.getTime())throw Error(`source-revert-preview-expired`);let i={...structuredClone(e.identity),agentOperationId:null,toolCallId:null},a={runtimeRevision:e.revision.runtimeRevision,taskRevision:r.taskRevision,controlRevision:e.revision.controlRevision,workspaceRevision:r.workspaceRevision,indexRevision:r.indexRevision,approvalRevision:e.revision.approvalRevision,sessionOptionRevision:e.revision.sessionOptionRevision,queueRevision:e.revision.queueRevision,workspacePreimage:r.workspacePreimage,indexPreimage:r.indexPreimage,patchPreimage:r.patchPreimage},o={fileRef:r.fileRef,hunkRefs:[...r.hunkRefs],previewRef:r.previewRef,confirmedPreviewDigest:r.confirmedPreviewDigest,contentDigest:r.contentDigest},s={schemaVersion:1,version:`piagent-webui-control-v1`,messageType:`command`,commandId:`source-revert.${crypto.randomUUID()}`,idempotencyKey:crypto.randomUUID(),requestedAt:n.toISOString(),expiresAt:r.expiresAt,capabilityScope:`reviewActions`,action:`source.revert`,actionDigest:``,identity:i,expectedRevisions:a,payload:o};return s.actionDigest=await H_({action:s.action,identity:i,expectedRevisions:a,payload:o}),s}function W_(e){return Array.isArray(e)?`[${e.map(W_).join(`,`)}]`:e&&typeof e==`object`?`{${Object.entries(e).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>`${JSON.stringify(e)}:${W_(t)}`).join(`,`)}}`:JSON.stringify(e)}async function G_(e){let t=await crypto.subtle.digest(`SHA-256`,new TextEncoder().encode(W_(e)));return`sha256:${[...new Uint8Array(t)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}async function K_(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 G_({action:c.action,identity:a,expectedRevisions:o,payload:s}),c}var q_=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(`.`)),J_=new Set([`false`,`nil`,`null`,`None`,`true`,`undefined`]),Y_=new Set([`py`,`rb`,`sh`,`bash`,`zsh`,`yaml`,`yml`,`toml`]);function X_(e){let t=e.split(`/`).pop()??e,n=t.lastIndexOf(`.`);return n<0?``:t.slice(n+1).toLowerCase()}function Z_(e){return/[A-Za-z_$]/.test(e)}function Q_(e){return/[A-Za-z0-9_$-]/.test(e)}function $_(e){return e>=`0`&&e<=`9`}function ev(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 tv(e,t){let n=[],r=X_(t),i=0;for(;i<e.length;){if(e.startsWith(`//`,i)||e.startsWith(`/*`,i)||e[i]===`#`&&Y_.has(r)){ev(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);ev(n,e.slice(a).match(/^\s*:/)&&r===`"`?`property`:`string`,o),i=a;continue}if($_(t)||t===`.`&&$_(e[i+1]??``)){let t=i+1;for(;t<e.length&&/[0-9A-Fa-f_xXob.+-]/.test(e[t]??``);)t+=1;ev(n,`number`,e.slice(i,t)),i=t;continue}if(Z_(t)){let t=i+1;for(;t<e.length&&Q_(e[t]??``);)t+=1;let r=e.slice(i,t);ev(n,q_.has(r)?`keyword`:J_.has(r)?`literal`:`plain`,r),i=t;continue}ev(n,`plain`,t),i+=1}return n}var nv=[{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 rv(e){return e===`vi`?nv:[{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 iv={"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 av(e,t=`vi`){return t===`vi`?iv[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 ov(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 sv(e,t=`vi`){let n=e.page.total;return 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 cv(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 lv(e,t){return t&&e.some(e=>e.fileRef===t)?t:e[0]?.fileRef??null}var uv={active:`Đang hoạt động`,"pause-requested":`Đang yêu cầu tạm dừng`,paused:`Đã tạm dừng`,terminal:`Đã kết thúc`,idle:`Đang chờ`,running:`Đang chạy`,stopping:`Đang dừng`,settled:`Đã ổn định`,unknown:`Chưa xác định`,pending:`Chưa xong`,completed:`Hoàn thành`,blocked:`Bị chặn`,partial:`Một phần`,failed:`Thất bại`,satisfied:`Đã đạt`,unavailable:`Không có dữ liệu`,connected:`Đã kết nối`,disconnected:`Mất kết nối`,reconnecting:`Đang kết nối lại`,"resync-required":`Cần đồng bộ lại`,none:`Không có`,waiting:`Đang chờ duyệt`,current:`Mới nhất`,stale:`Đã cũ`,"not-run":`Chưa chạy`,"in-progress":`Đang làm`,done:`Đã xong`,skipped:`Bỏ qua`,resume:`Tiếp tục`,retry:`Thử lại`,observed:`Đã ghi nhận`,requested:`Đã yêu cầu`,"possible-interruption":`Có thể bị gián đoạn`,complete:`Đầy đủ`,"aggregate-only":`Chỉ có dữ liệu tổng hợp`,off:`Tắt`,minimal:`Tối thiểu`,low:`Thấp`,medium:`Trung bình`,high:`Cao`,xhigh:`Rất cao`,max:`Tối đa`,orphaned:`Mất owner`,cancelled:`Đã hủy`,succeeded:`Thành công`,"stale-result":`Kết quả đến muộn`,accepted:`Đã nhận`,rejected:`Không nhận`,"not-recorded":`Chưa có kết quả`,parent:`Task cha`,helper:`Helper`,"read-only":`Chỉ đọc`,"workspace-write":`Ghi trong project`,"trusted-full-access":`Toàn quyền`,"single-writer":`Một writer`,retriever:`Truy xuất`,scout:`Khảo sát`,planner:`Lập kế hoạch`,worker:`Thực thi`,reviewer:`Rà soát`,oracle:`Đối chứng`,researcher:`Nghiên cứu`,ready:`Sẵn sàng`,missing:`Chưa có bằng chứng`,interrupted:`Bị gián đoạn`,stopped:`Đã dừng`,aborted:`Đã hủy do lỗi`,incomplete:`Chưa có kết luận`,passed:`Đạt`,"not-applicable":`Không áp dụng`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"pdf-text-unavailable":`PDF này không có text bóc được; nhiều khả năng là bản scan, cần OCR trước`,"pdf-extraction-failed":`Không chuyển được PDF này sang text`,"docx-unreadable":`File .docx này hỏng, bị mã hóa, hoặc không phải file Word thật`,"document-text-empty":`Tài liệu không có chữ nào để đọc`,"document-size-limit":`Tài liệu vượt giới hạn dung lượng`,"text-size-limit":`File text vượt giới hạn dung lượng`,"text-content-invalid":`File có đuôi text nhưng nội dung không phải text`,"image-mime-mismatch":`Nội dung ảnh không khớp với đuôi file`,"model-image-input-unavailable":`Model hiện tại không nhận ảnh`,"attachment-capacity-limit":`Đã chạm giới hạn số file hoặc dung lượng đính kèm`,"no-readable-root":`Chưa có thư mục nào đọc được`,"document-roots-unavailable":`Không xác định được thư mục tài liệu`,"document-not-listed":`Tài liệu không còn trong danh sách; hãy tải lại`,"document-unavailable":`Không mở được tài liệu này`,"document-protected":`Tài liệu nằm trong protectedPaths nên không được đọc`,"document-changed":`File đã thay đổi sau khi liệt kê; chưa đọc gì cả`,"document-unreadable":`Không đọc được nội dung tài liệu`,"document-needs-ocr":`Tài liệu là bản scan, cần OCR trước khi đọc được chữ`,"document-converter-unavailable":`Host chưa cài pdftotext (poppler) nên chưa đọc được .pdf`,"session-command-effect-unknown":`Pi đã nhận yêu cầu nhưng đang đồng bộ trạng thái; không gửi lại để tránh chạy trùng`},dv={active:`Active`,"pause-requested":`Pause requested`,paused:`Paused`,terminal:`Finished`,idle:`Idle`,running:`Running`,stopping:`Stopping`,settled:`Settled`,unknown:`Unknown`,pending:`Pending`,completed:`Completed`,blocked:`Blocked`,partial:`Partial`,failed:`Failed`,satisfied:`Satisfied`,unavailable:`Unavailable`,connected:`Connected`,disconnected:`Disconnected`,reconnecting:`Reconnecting`,"resync-required":`Resync required`,none:`None`,waiting:`Awaiting approval`,current:`Current`,stale:`Stale`,"not-run":`Not run`,"in-progress":`In progress`,done:`Done`,skipped:`Skipped`,resume:`Resume`,retry:`Retry`,observed:`Observed`,requested:`Requested`,"possible-interruption":`Possible interruption`,complete:`Complete`,"aggregate-only":`Aggregate only`,off:`Off`,minimal:`Minimal`,low:`Low`,medium:`Medium`,high:`High`,xhigh:`Extra high`,max:`Maximum`,orphaned:`Owner missing`,cancelled:`Cancelled`,succeeded:`Succeeded`,"stale-result":`Stale result`,accepted:`Accepted`,rejected:`Rejected`,"not-recorded":`Not recorded`,parent:`Parent task`,helper:`Helper`,"read-only":`Read only`,"workspace-write":`Workspace write`,"trusted-full-access":`Full access`,"single-writer":`Single writer`,retriever:`Retriever`,scout:`Scout`,planner:`Planner`,worker:`Worker`,reviewer:`Reviewer`,oracle:`Oracle`,researcher:`Researcher`,ready:`Ready`,missing:`Evidence missing`,interrupted:`Interrupted`,stopped:`Stopped`,aborted:`Aborted`,incomplete:`Incomplete`,passed:`Passed`,"not-applicable":`Not applicable`,smoke:`Smoke`,"public-regression":`Public regression`,capability:`Capability`,"private-holdout":`Private holdout`,"production-shadow":`Production shadow`,"pdf-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"pdf-text-unavailable":`This PDF holds no extractable text; it is probably scanned and needs OCR first`,"pdf-extraction-failed":`The PDF could not be converted to text`,"docx-unreadable":`This .docx is corrupt, encrypted, or not really a Word document`,"document-text-empty":`The document contains no readable text`,"document-size-limit":`The document is over the size limit`,"text-size-limit":`The text file is over the size limit`,"text-content-invalid":`The file has a text extension but its bytes are not text`,"image-mime-mismatch":`The image content does not match its file extension`,"model-image-input-unavailable":`The current model does not accept images`,"attachment-capacity-limit":`The attachment count or size limit was reached`,"no-readable-root":`No readable directory is available`,"document-roots-unavailable":`The document directories could not be resolved`,"document-not-listed":`The document is no longer listed; reload the list`,"document-unavailable":`This document could not be opened`,"document-protected":`The document is under protectedPaths and is not readable`,"document-changed":`The file changed after it was listed; nothing was read`,"document-unreadable":`The document content could not be read`,"document-needs-ocr":`The document is scanned and needs OCR before it holds text`,"document-converter-unavailable":`This host has no pdftotext (poppler), so .pdf cannot be read`,"session-command-effect-unknown":`Pi received the request and is resyncing; do not resend it, to avoid a duplicate run`};function Q(e,t=`vi`){return e?(t===`vi`?uv:dv)[e]??e.replaceAll(`-`,` `):t===`vi`?`Chưa có`:`Not available`}function fv(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 pv(e){return e?e.length>22?`${e.slice(0,10)}…${e.slice(-7)}`:e:`—`}function mv(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 hv(e,t=`vi`){return e.session.thinking.state===`known`&&e.session.thinking.value?Q(e.session.thinking.value,t):t===`vi`?`Chưa xác định`:`Unknown`}function gv(e,t=`vi`){let n=e.session.permissionProfile;return n.state===`known`&&n.value?Q(n.value,t):t===`vi`?`Quyền chưa xác định`:`Unknown permission`}function _v(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 vv(e,t=`vi`){let n=e.task;return n?{completed:n.progress.completed,total:n.progress.total,percent:Math.max(0,Math.min(100,n.progress.percent)),text:t===`vi`?`${n.progress.completed}/${n.progress.total} tiêu chí`:`${n.progress.completed}/${n.progress.total} criteria`}:{completed:0,total:0,percent:0,text:t===`vi`?`Chưa có task đang chạy`:`No active task`}}var yv=(0,v.createContext)(null);function bv({value:e,children:t}){return(0,W.jsx)(yv.Provider,{value:e,children:t})}function xv(){let e=(0,v.useContext)(yv);if(!e)throw Error(`Piagent UI preferences are missing`);return e}function $(e,t,n){return e===`vi`?t:n}function Sv(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 Cv(e){return e?[Sv(e),e.state,e.recordedState??``,e.recordedAt??``,e.evidenceRef??``].join(``):`no-review-state`}function wv(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 Tv(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&&wv(e,t)&&typeof t.settledAt==`string`&&typeof t.settlementEvidenceRef==`string`}async function Ev(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest(`SHA-256`,t);return`sha256:${[...new Uint8Array(n)].map(e=>e.toString(16).padStart(2,`0`)).join(``)}`}function Dv({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,W.jsxs)(`section`,{className:`commit-summary-panel`,"aria-labelledby":`commit-summary-title`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Commit summary`}),(0,W.jsx)(`h3`,{id:`commit-summary-title`,children:$(a,`Tóm tắt phần đã stage`,`Staged changes summary`)}),(0,W.jsx)(`span`,{children:$(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,W.jsxs)(`div`,{className:`commit-summary-output`,children:[(0,W.jsx)(`strong`,{children:l.title}),l.bodyLines.map((e,t)=>(0,W.jsx)(`code`,{children:e},`${l.summaryRef}.${t}`)),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`button`,{type:`button`,onClick:s,children:`Copy`}),(0,W.jsx)(`button`,{type:`button`,disabled:!i||t,onClick:c,children:$(a,`Nhờ Pi viết lại · tốn model token`,`Ask Pi to rewrite · uses model tokens`)})]})]}):(0,W.jsx)(`button`,{type:`button`,disabled:!r||t,onClick:o,children:t?$(a,`Đang tạo…`,`Generating…`):$(a,`Tạo summary · 0 token`,`Generate summary · 0 tokens`)}),n&&(0,W.jsx)(`p`,{className:`commit-summary-status`,role:`status`,children:n})]})}function Ov({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,W.jsxs)(sf,{component:`button`,className:`file-row`,selected:t,"data-selected":t,onClick:n,type:`button`,"aria-label":`${e.status} ${e.path} ${ov(e,r)}`,"aria-pressed":t,children:[(0,W.jsx)(`span`,{className:`file-status status-${e.status}`,children:e.status}),(0,W.jsxs)(`span`,{className:`file-name`,children:[(0,W.jsx)(`strong`,{children:a}),e.oldPath&&(0,W.jsxs)(`small`,{children:[$(r,`từ`,`from`),` `,e.oldPath]})]}),(0,W.jsx)(`span`,{className:`file-provenance`,children:av(e,r)}),(0,W.jsx)(`span`,{className:`file-evidence`,children:cv(e,r)}),(0,W.jsx)(`span`,{className:`file-stats`,children:ov(e,r)})]})}function kv({text:e,path:t}){return(0,W.jsx)(W.Fragment,{children:tv(e,t).map((e,t)=>(0,W.jsx)(`span`,{className:`syntax-${e.kind}`,children:e.text},`${t}.${e.kind}`))})}function Av({line:e,side:t,path:n}){let r=e.oldLineNumber??``,i=e.newLineNumber??``;if(t===`inline`)return(0,W.jsxs)(`div`,{className:`diff-line diff-${e.kind}`,children:[(0,W.jsx)(`span`,{children:r}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(`b`,{children:e.marker}),(0,W.jsx)(`code`,{children:(0,W.jsx)(kv,{text:e.text,path:n})})]});let a=e.kind===`added`?``:e.text,o=e.kind===`deleted`?``:e.text;return(0,W.jsxs)(`div`,{className:`split-line diff-${e.kind}`,children:[(0,W.jsx)(`span`,{children:r}),(0,W.jsx)(`code`,{children:(0,W.jsx)(kv,{text:a,path:n})}),(0,W.jsx)(`span`,{children:i}),(0,W.jsx)(`code`,{children:(0,W.jsx)(kv,{text:o,path:n})})]})}function jv({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,mode:h,onMode:g,onReview:_,onMutation:v,onRevert:y,onOpen:b,locale:x}){if(e.state===`idle`)return(0,W.jsx)(`div`,{className:`diff-empty`,children:(0,W.jsx)(`p`,{children:$(x,`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,W.jsx)(`div`,{className:`diff-empty`,children:(0,W.jsx)(`p`,{children:$(x,`Đ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,W.jsx)(`div`,{className:`diff-empty error-state`,children:(0,W.jsx)(`p`,{children:$(x,`Diff không còn khớp revision hiện tại. Hãy chọn lại file sau khi danh sách cập nhật.`,`The diff no longer matches the current revision. Select the file again after the list refreshes.`)})});let S=e.value;return(0,W.jsxs)(X,{className:`diff-viewer`,sx:{minWidth:0,bgcolor:`background.paper`},children:[(0,W.jsxs)(X,{component:`header`,className:`diff-toolbar`,sx:{position:`sticky`,top:0,zIndex:2,bgcolor:`background.paper`},children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:S.file.path}),(0,W.jsx)(cu,{size:`small`,variant:`outlined`,className:`access-badge tone-${fv(S.availability.state)}`,label:Q(S.availability.state,x)})]}),(0,W.jsxs)(`div`,{className:`diff-actions`,children:[t.state===`ready`&&t.value&&(0,W.jsxs)(`div`,{className:`review-state review-${t.value.state}`,children:[(0,W.jsx)(`span`,{children:t.value.state===`reviewed`?$(x,`Đã review`,`Reviewed`):t.value.state===`stale`?$(x,`Review đã cũ`,`Review stale`):t.value.state===`unavailable`?$(x,`Không thể review`,`Review unavailable`):$(x,`Chưa review`,`Not reviewed`)}),t.value.target&&t.value.state!==`unavailable`&&(0,W.jsx)(`button`,{type:`button`,disabled:!i||a,onClick:()=>_(t.value.state===`reviewed`?`unreviewed`:`reviewed`),children:a?$(x,`Đang ghi…`,`Saving…`):t.value.state===`reviewed`?$(x,`Bỏ dấu review`,`Mark unreviewed`):t.value.state===`stale`?$(x,`Review lại`,`Review again`):$(x,`Đánh dấu đã review`,`Mark reviewed`)})]}),n.state===`ready`&&n.value?.state===`ready`&&n.value.target&&(0,W.jsxs)(`div`,{className:`source-mutation-preview`,children:[(0,W.jsx)(`span`,{children:n.value.action===`source.stage`?$(x,`Chuẩn bị đúng thay đổi file này để commit`,`Prepare this exact file change for commit`):$(x,`Bỏ khỏi vùng commit; giữ nguyên file đang làm việc`,`Remove from commit while keeping the working file`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>v([]),children:c?$(x,`Đ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,W.jsxs)(`div`,{className:`source-revert-preview`,children:[(0,W.jsx)(`span`,{children:$(x,`Hoàn tác phần chưa stage; giữ nguyên index`,`Revert unstaged changes while preserving the index`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!u||d,onClick:()=>y(null),children:d?$(x,`Đang dựng preview…`,`Building preview…`):`Revert file`})]}),f&&(0,W.jsx)(`div`,{className:`source-open-action`,children:(0,W.jsx)(`button`,{type:`button`,disabled:p,onClick:b,children:p?$(x,`Đang mở…`,`Opening…`):$(x,`Mở trong VS Code`,`Open in VS Code`)})}),(0,W.jsxs)(op,{className:`mode-switch`,exclusive:!0,size:`small`,value:h,"aria-label":$(x,`Kiểu hiển thị diff`,`Diff layout`),onChange:(e,t)=>t&&g(t),children:[(0,W.jsx)(ep,{value:`inline`,"aria-label":`Inline`,children:`Inline`}),(0,W.jsx)(ep,{value:`split`,"aria-label":$(x,`Hai cột`,`Side by side`),children:$(x,`Hai cột`,`Side by side`)})]})]})]}),o&&(0,W.jsx)(`div`,{className:`review-error`,role:`status`,children:o}),l&&(0,W.jsx)(`div`,{className:`review-error`,role:`status`,children:l}),m&&(0,W.jsx)(`div`,{className:`source-open-status`,role:`status`,children:m}),(0,W.jsxs)(`div`,{className:`diff-context`,children:[(0,W.jsx)(`span`,{children:av(S.file,x)}),(0,W.jsx)(`span`,{children:cv(S.file,x)}),(0,W.jsxs)(`span`,{className:`additions`,children:[`+`,S.file.stats.additions??`?`]}),(0,W.jsxs)(`span`,{className:`deletions`,children:[`−`,S.file.stats.deletions??`?`]})]}),S.fallback.kind!==`none`&&(0,W.jsxs)(`div`,{className:`diff-fallback`,children:[(0,W.jsx)(`strong`,{children:Q(S.fallback.kind,x)}),(0,W.jsx)(`span`,{children:S.fallback.message??S.fallback.reasonCode??$(x,`Nội dung diff không sẵn sàng`,`Diff content unavailable`)})]}),S.hunks.map((e,t)=>(0,W.jsxs)(`section`,{className:`diff-hunk`,"aria-label":`${$(x,`Vùng thay đổi`,`Change region`)} ${t+1}`,children:[(0,W.jsxs)(`div`,{className:`hunk-header`,children:[(0,W.jsx)(`span`,{children:e.header}),(0,W.jsxs)(`span`,{className:`hunk-actions`,children:[n.value?.state===`ready`&&n.value.target?.hunkRefs.includes(e.hunkRef)&&(0,W.jsx)(`button`,{type:`button`,disabled:!s||c,onClick:()=>v([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,W.jsx)(`button`,{className:`revert-action`,type:`button`,disabled:!u||d,onClick:()=>y(e.hunkRef),children:`Revert hunk`})]})]}),(0,W.jsx)(`div`,{className:h===`split`?`split-code`:`inline-code`,children:e.lines.map(e=>(0,W.jsx)(Av,{line:e,side:h,path:S.file.path},e.lineRef))}),S.unchangedRegions[t]&&(0,W.jsxs)(`div`,{className:`unchanged-region`,children:[`… `,S.unchangedRegions[t].lineCount,` `,$(x,`dòng không đổi đã thu gọn`,`unchanged lines collapsed`),` …`]})]},e.hunkRef)),S.truncation.truncated&&(0,W.jsxs)(`div`,{className:`diff-fallback`,children:[(0,W.jsx)(`strong`,{children:$(x,`Diff đã rút gọn`,`Diff truncated`)}),(0,W.jsxs)(`span`,{children:[$(x,`Còn`,`Another`),` `,S.truncation.omittedLines,` `,$(x,`dòng chưa hiển thị.`,`lines are not shown.`)]})]})]})}function Mv({snapshot:e,refreshSnapshot:t,sessionRef:n}){let{locale:r}=xv(),i=!!(e.task&&e.sourceChanges.task?.state!==`unavailable`&&e.sourceChanges.task?.revision),a=(0,v.useMemo)(()=>rv(r),[r]),[o,s]=(0,v.useState)(()=>i?`task`:`working-tree`),[c,l]=(0,v.useState)({}),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)({state:`idle`}),[m,h]=(0,v.useState)({state:`idle`}),[g,_]=(0,v.useState)({state:`idle`}),[y,b]=(0,v.useState)({state:`idle`}),[x,S]=(0,v.useState)(null),[C,w]=(0,v.useState)(!1),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(null),[F,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)({state:`idle`}),[ne,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(null),[re,ie]=(0,v.useState)(!1),[ae,oe]=(0,v.useState)(0),[se,H]=(0,v.useState)(`inline`),ce=`${e.sourceChanges.task?.revision??`no-task`}:${e.sourceChanges.workingTree.revision}:${e.sourceChanges.staged.revision}`,le=c[o],ue=lv(le?.state===`ready`?le.value?.files??[]:[],u),de=(0,v.useRef)(``),fe=(0,v.useRef)(``);de.current=[o,ue??`no-selection`,ce,Sv(m.value)].join(``),fe.current=Cv(m.value),(0,v.useEffect)(()=>{te({state:`idle`}),V(null),ie(!1)},[ce]),(0,v.useEffect)(()=>{!i&&o===`task`&&(s(`working-tree`),d(null))},[i,o]),(0,v.useEffect)(()=>{let e=new AbortController;return l(e=>({...e,[o]:{state:`loading`}})),(n?Lg(n,o,e.signal):Yg(o,e.signal)).then(t=>{if(!t){e.signal.aborted||l(e=>({...e,[o]:{state:`error`}}));return}l(e=>({...e,[o]:{state:`ready`,value:t}}))}).catch(()=>{e.signal.aborted||l(e=>({...e,[o]:{state:`error`}}))}),()=>e.abort()},[o,ce,ae,n]),(0,v.useEffect)(()=>{if(!ue){p({state:`idle`}),h({state:`idle`}),_({state:`idle`}),b({state:`idle`});return}let t=new AbortController;p({state:`loading`}),E(null),A(null),P(null),S(null),R(null);let r=o===`working-tree`?`source.stage`:o===`staged`?`source.unstage`:null,i=e.capabilities.capabilities.reviewActions,a=i.status===`available`&&i.actions.reviewMark.available,s=r===`source.stage`?i.status===`available`&&i.actions.stage.available:r===`source.unstage`&&i.status===`available`&&i.actions.unstage.available,c=o===`working-tree`&&i.status===`available`&&i.actions.revert.available;return h(a?{state:`loading`}:{state:`idle`}),_(s?{state:`loading`}:{state:`idle`}),b(c?{state:`loading`}:{state:`idle`}),(n?Rg(n,o,ue,t.signal):Xg(o,ue,t.signal)).then(e=>{t.signal.aborted||p({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||p({state:`error`})}),a&&(n?zg(n,o,ue,t.signal):Zg(o,ue,t.signal)).then(e=>{t.signal.aborted||h({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||h({state:`error`})}),s&&r&&(n?Bg(n,r,ue,t.signal):Qg(r,ue,t.signal)).then(e=>{t.signal.aborted||_({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||_({state:`error`})}),c&&(n?Vg(n,ue,null,t.signal):$g(ue,null,t.signal)).then(e=>{t.signal.aborted||b({state:`ready`,value:e})}).catch(()=>{t.signal.aborted||b({state:`error`})}),()=>t.abort()},[ue,o,ce,n,e.capabilities.capabilities.reviewActions]);let pe=c[o],me=pe?.value?.files??[],he=(0,v.useMemo)(()=>{let e=new Map;for(let t of me){let n=t.path.lastIndexOf(`/`),i=n<0?$(r,`Gốc project`,`Project root`):t.path.slice(0,n);e.set(i,[...e.get(i)??[],t])}return[...e.entries()]},[me,r]),U=(0,v.useMemo)(()=>({task:c.task?.state===`ready`?c.task.value?.page.total??0:e.sourceChanges.task?.counts.files??0,"working-tree":c[`working-tree`]?.state===`ready`?c[`working-tree`].value?.page.total??0:e.sourceChanges.workingTree.counts.files,staged:c.staged?.state===`ready`?c.staged.value?.page.total??0:e.sourceChanges.staged.counts.files}),[c,e]),ge=e=>{s(e),d(null)},_e=e.capabilities.capabilities.reviewActions,ve=_e.status===`available`&&_e.actions.reviewMark.available,ye=g.value?.action===`source.stage`?_e.status===`available`&&_e.actions.stage.available:g.value?.action===`source.unstage`&&_e.status===`available`&&_e.actions.unstage.available,be=_e.status===`available`&&_e.actions.revert.available,xe=o===`working-tree`&&_e.status===`available`&&_e.actions.openInVsCode.available&&f.state===`ready`&&f.value?.availability.state===`current`&&f.value.fallback.kind===`none`,Se=o===`staged`&&me.length>0,Ce=Se&&_e.status===`available`&&_e.actions.generateCommitSummaryDeterministic.available,we=Se&&_e.status===`available`&&_e.actions.generateCommitSummaryModel.available,Te=async t=>{if(!ue||!m.value||C)return;let i=m.value,a=Cv(i),s=de.current;w(!0),E(null);try{let c=await L_(e,i,t);if(de.current!==s||fe.current!==a)return;let l=await Ev(c.idempotencyKey);if(de.current!==s||fe.current!==a)return;let u=await __(c);if(!Tv(c,u,t,l)){de.current===s&&fe.current===a&&E(u.error?.message??$(r,`Không xác nhận được trạng thái review chính xác; hãy tải lại diff.`,`The exact review state could not be confirmed; reload the diff.`));return}if(de.current!==s||fe.current!==a)return;h(e=>de.current===s&&Cv(e.value)===a?{state:`ready`,value:{...i,generatedAt:u.settledAt,state:u.resultCode,recordedState:u.resultCode,recordedAt:u.settledAt,evidenceRef:u.settlementEvidenceRef,reasonCode:null,health:{state:`ok`,reasonCode:null,message:null}}}:e),(n?zg(n,o,ue):Zg(o,ue)).then(e=>h(t=>de.current===s&&t.state===`ready`&&t.value?.evidenceRef===u.settlementEvidenceRef?{state:`ready`,value:e}:t)).catch(()=>void 0)}catch{de.current===s&&fe.current===a&&E($(r,`Không thể ghi trạng thái review. Nội dung source không bị thay đổi.`,`Unable to save review state. Source content was not changed.`))}finally{w(!1)}},Ee=async(n=[])=>{if(!(!g.value||g.value.state!==`ready`||D)){O(!0),A(null);try{let i=await v_(await B_(e,g.value,n));if(i.phase!==`settled`||![`staged`,`unstaged`].includes(i.resultCode)){A(i.phase===`uncertain`?$(r,`Không xác nhận được trạng thái Git. Hãy kiểm tra lại ba tab trước khi làm tiếp.`,`Git state could not be confirmed. Check all three tabs before continuing.`):i.error?.message??$(r,`File hoặc Git index đã thay đổi; hãy tải lại preview.`,`The file or Git index changed; reload the preview.`));return}d(null),await t?.(),oe(e=>e+1)}catch{A($(r,`Không thể cập nhật Git index. File đang làm việc không bị thay đổi.`,`Unable to update the Git index. The working file was not changed.`))}finally{O(!1)}}},De=async e=>{if(!(!ue||!be||j)){M(!0),P(null);try{let t=n?await Vg(n,ue,e):await $g(ue,e);if(t.state!==`ready`||!t.target){P($(r,`Không thể hoàn tác an toàn: provenance hoặc diff hiện tại không còn đủ bằng chứng.`,`Safe revert is unavailable because provenance or the current diff lacks evidence.`));return}S(t)}catch{P($(r,`Không thể dựng preview hoàn tác. Source chưa bị thay đổi.`,`Unable to build a revert preview. Source was not changed.`))}finally{M(!1)}}},Oe=async()=>{if(!(!x||j)){M(!0),P(null);try{let n=await y_(await U_(e,x));if(n.phase!==`settled`||n.resultCode!==`reverted`){P(n.phase===`uncertain`?$(r,`Không xác nhận được kết quả. Hãy kiểm tra lại Working Tree và Staged Changes.`,`The result could not be confirmed. Check Working Tree and Staged Changes.`):n.error?.message??$(r,`Preview đã cũ; hãy mở lại trước khi xác nhận.`,`The preview is stale; reopen it before confirming.`));return}S(null),d(null),await t?.(),oe(e=>e+1)}catch{P($(r,`Không thể hoàn tác. Hãy kiểm tra lại source trước khi thử lại.`,`Unable to revert. Check the source before trying again.`))}finally{M(!1)}}},ke=async()=>{if(!(!ue||!xe||F)){I(!0),R(null);try{let t=await b_(await K_(e,ue));t.phase===`settled`&&t.resultCode===`opened`?R($(r,`VS Code đã nhận yêu cầu mở file.`,`VS Code received the open-file request.`)):R(t.phase===`uncertain`?$(r,`Không xác nhận được VS Code đã nhận file. Piagent sẽ không tự mở lại.`,`It is unknown whether VS Code received the file. Piagent will not retry automatically.`):t.error?.message??$(r,`File hoặc phiên làm việc đã thay đổi; hãy tải lại trước khi mở.`,`The file or session changed; refresh before opening.`))}catch{R($(r,`Không thể mở file trong VS Code. Diff hiện tại vẫn được giữ nguyên.`,`Unable to open the file in VS Code. The current diff remains available.`))}finally{I(!1)}}},Ae=async()=>{if(!(!Ce||ne)){z(!0),V(null),te({state:`loading`});try{let e=n?await Hg(n):await e_();te({state:`ready`,value:e}),e.state!==`ready`&&V($(r,`Staged Changes đã thay đổi hoặc chưa có dữ liệu để tóm tắt.`,`Staged Changes changed or has no data to summarize.`))}catch{te({state:`error`}),V($(r,`Không thể dựng commit summary từ index hiện tại.`,`Unable to generate a commit summary from the current index.`))}finally{z(!1)}}},je=async()=>{let e=ee.value?.summary;if(e)try{await navigator.clipboard.writeText([e.title,``,...e.bodyLines].join(`
172
+ `)),V($(r,`Đã copy summary. Chưa có commit nào được tạo.`,`Summary copied. No commit was created.`))}catch{V($(r,`Trình duyệt không cho phép copy tự động.`,`The browser did not allow automatic copying.`))}},Me=async()=>{let t=ee.value?.summary;if(!(!t||!we||ne)){z(!0),V(null);try{let n=await p_(await D_(e,t.modelPrompt,`new-operation`));n.phase===`settled`&&n.resultCode===`dispatch-observed`?V($(r,`Đã gửi yêu cầu sang Chat. Pi sẽ trả commit summary ở hội thoại; chưa commit hoặc push.`,`Request sent to Chat. Pi will return the commit summary in the conversation; nothing was committed or pushed.`)):V(n.phase===`uncertain`?$(r,`Không xác nhận được yêu cầu đã tới Pi; hệ thống sẽ không tự gửi lại.`,`It is unknown whether the request reached Pi; it will not be resent automatically.`):n.error?.message??$(r,`Không thể bắt đầu model work từ session hiện tại.`,`Unable to start model work from the current session.`))}catch{V($(r,`Không thể gửi yêu cầu sang Pi session hiện tại.`,`Unable to send the request to the current Pi session.`))}finally{z(!1),ie(!1)}}};return(0,W.jsxs)(Mc,{component:`section`,variant:`outlined`,className:`source-workspace`,"aria-labelledby":`source-title`,sx:{overflow:`hidden`,minHeight:`calc(100vh - 120px)`,display:`flex`,flexDirection:`column`},children:[(0,W.jsxs)(X,{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,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`overline`,color:`primary.main`,sx:{fontWeight:800,letterSpacing:`.14em`,lineHeight:1},children:`Source changes`}),(0,W.jsx)(Z,{variant:`h2`,id:`source-title`,sx:{mt:.5},children:$(r,`Thay đổi trong project`,`Project changes`)})]}),(0,W.jsx)(cu,{label:`Git + task baseline`,variant:`outlined`,size:`small`})]}),(0,W.jsx)(pg,{className:`source-tabs`,value:o,onChange:(e,t)=>ge(t),selectionFollowsFocus:!0,variant:`scrollable`,scrollButtons:`auto`,"aria-label":$(r,`Nguồn thay đổi`,`Change sources`),sx:{borderBottom:1,borderColor:`divider`,minHeight:48},children:a.map(e=>(0,W.jsx)(Kh,{id:`source-tab-${e.view}`,value:e.view,"aria-controls":`source-tabpanel`,disabled:e.view===`task`&&!i,title:e.view===`task`&&!i?$(r,`Session này chưa có task baseline`,`This session has no task baseline`):void 0,label:(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsx)(`span`,{children:e.label}),U[e.view]>0&&(0,W.jsx)(cu,{size:`small`,label:U[e.view],sx:{height:20,minWidth:24,"& .MuiChip-label":{px:.75}}})]})},e.view))}),o===`staged`&&(0,W.jsx)(Dv,{state:ee,busy:ne,status:B,locale:r,deterministicEnabled:Ce,modelEnabled:we,onGenerate:()=>{Ae()},onCopy:()=>{je()},onModel:()=>ie(!0)}),(0,W.jsxs)(X,{className:`source-body`,sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`minmax(286px, 330px) minmax(0, 1fr)`},flex:1,minHeight:620},children:[(0,W.jsxs)(X,{className:`file-panel`,id:`source-tabpanel`,role:`tabpanel`,"aria-labelledby":`source-tab-${o}`,sx:{minWidth:0,borderRight:{md:1},borderBottom:{xs:1,md:0},borderColor:`divider`,bgcolor:`background.default`},children:[(0,W.jsxs)(X,{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,W.jsx)(`span`,{"aria-live":`polite`,children:pe?.state===`ready`&&pe.value?sv(pe.value,r):pe?.state===`error`?$(r,`Không thể tải danh sách file`,`Unable to load files`):$(r,`Đang tải…`,`Loading…`)}),(0,W.jsx)(`small`,{children:a.find(e=>e.view===o)?.shortLabel})]}),(0,W.jsxs)(X,{className:`file-list`,sx:{maxHeight:{xs:300,md:`calc(100vh - 270px)`},overflow:`auto`,p:.75},children:[he.map(([e,t])=>(0,W.jsxs)(X,{children:[(0,W.jsxs)(Cf,{direction:`row`,className:`file-group-label`,children:[(0,W.jsx)(Vh,{}),(0,W.jsx)(Z,{component:`span`,noWrap:!0,children:e})]}),t.map(e=>(0,W.jsx)(Ov,{file:e,selected:e.fileRef===ue,onSelect:()=>d(e.fileRef),locale:r},e.fileRef))]},e)),pe?.state===`ready`&&me.length===0&&(0,W.jsx)(`div`,{className:`files-empty`,children:$(r,`Không có thay đổi trong view này.`,`No changes in this view.`)})]})]}),(0,W.jsx)(jv,{state:f,review:m,mutation:g,revert:y,reviewEnabled:ve,reviewBusy:C,reviewError:T,mutationEnabled:ye,mutationBusy:D,mutationError:k,revertEnabled:be,revertBusy:j,openEnabled:xe,openBusy:F,openStatus:L,mode:se,onMode:H,onReview:e=>{Te(e)},onMutation:e=>{Ee(e)},onRevert:e=>{De(e)},onOpen:()=>{ke()},locale:r})]}),N&&(0,W.jsx)(`div`,{className:`source-revert-error`,role:`status`,children:N}),x?.target&&(0,W.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,W.jsxs)(`section`,{className:`confirm-dialog`,role:`alertdialog`,"aria-modal":`true`,"aria-labelledby":`revert-dialog-title`,"aria-describedby":`revert-dialog-description`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Xác nhận hoàn tác`,`Confirm revert`)}),(0,W.jsxs)(`h3`,{id:`revert-dialog-title`,children:[`Revert `,x.target.hunkRefs.length?`hunk`:`file`,`?`]}),(0,W.jsxs)(`p`,{id:`revert-dialog-description`,children:[$(r,`Thao tác sẽ bỏ`,`This will discard`),` `,(0,W.jsxs)(`strong`,{children:[x.target.summary.additionsDiscarded,` `,$(r,`dòng thêm`,`added lines`)]}),` `,$(r,`và khôi phục`,`and restore`),` `,(0,W.jsxs)(`strong`,{children:[x.target.summary.deletionsRestored,` `,$(r,`dòng xóa`,`deleted lines`)]}),` `,$(r,`trong`,`in`),` `,(0,W.jsx)(`code`,{children:x.target.path}),`.`]}),(0,W.jsx)(`div`,{className:`revert-diff`,"aria-label":$(r,`Các dòng chính xác sẽ được hoàn tác`,`Exact lines to revert`),children:x.preview?.hunks.map(e=>(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`div`,{children:e.header}),e.lines.map((t,n)=>(0,W.jsxs)(`code`,{className:`revert-line revert-${t.kind}`,children:[(0,W.jsx)(`b`,{children:t.marker}),t.text]},`${e.hunkRef}.${n}`))]},e.hunkRef))}),(0,W.jsxs)(`div`,{className:`revert-safety`,children:[(0,W.jsx)(`strong`,{children:$(r,`Phần đã stage được giữ nguyên.`,`Staged content is preserved.`)}),(0,W.jsx)(`span`,{children:$(r,`Không auto-commit. Khả năng khôi phục sau thao tác không được bảo đảm.`,`No auto-commit. Recovery after this action is not guaranteed.`)})]}),(0,W.jsxs)(`div`,{className:`confirm-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:j,onClick:()=>S(null),children:$(r,`Hủy`,`Cancel`)}),(0,W.jsx)(`button`,{className:`danger-action`,type:`button`,disabled:j,onClick:()=>{Oe()},children:j?$(r,`Đang hoàn tác…`,`Reverting…`):$(r,`Xác nhận revert`,`Confirm revert`)})]})]})}),re&&(0,W.jsx)(`div`,{className:`dialog-backdrop`,role:`presentation`,children:(0,W.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,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Model work có tính phí`,`Token-consuming model work`)}),(0,W.jsx)(`h3`,{id:`model-summary-dialog-title`,children:$(r,`Nhờ Pi viết lại commit summary?`,`Ask Pi to rewrite the commit summary?`)}),(0,W.jsx)(`p`,{id:`model-summary-dialog-description`,children:$(r,`Thao tác này gửi một message vào đúng Pi session hiện tại, bắt đầu một Pi operation và tiêu token theo model/thinking đang chọn. Chỉ staged summary đã rút gọn được gửi; source text không được đính kèm.`,`This sends a message to the exact current Pi session, starts a Pi operation, and consumes tokens using the selected model and thinking level. Only the bounded staged summary is sent; source text is not attached.`)}),(0,W.jsxs)(`div`,{className:`revert-safety`,children:[(0,W.jsx)(`strong`,{children:$(r,`Không tự commit hoặc push.`,`Does not commit or push.`)}),(0,W.jsx)(`span`,{children:$(r,`Kết quả sẽ xuất hiện trong Chat để anh review và copy.`,`The result will appear in Chat for review and copying.`)})]}),(0,W.jsxs)(`div`,{className:`confirm-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:ne,onClick:()=>ie(!1),children:$(r,`Hủy`,`Cancel`)}),(0,W.jsx)(`button`,{type:`button`,disabled:ne,onClick:()=>{Me()},children:ne?$(r,`Đang gửi…`,`Sending…`):$(r,`Xác nhận và gửi sang Pi`,`Confirm and send to Pi`)})]})]})})]})}function Nv(e){return K(`MuiInputAdornment`,e)}var Pv=Wr(`MuiInputAdornment`,[`root`,`filled`,`standard`,`outlined`,`positionStart`,`positionEnd`,`disablePointerEvents`,`hiddenLabel`,`sizeSmall`]),Fv,Iv=(e,t)=>{let{ownerState:n}=e;return[t.root,t[`position${Y(n.position)}`],n.disablePointerEvents===!0&&t.disablePointerEvents,t[n.variant]]},Lv=e=>{let{classes:t,disablePointerEvents:n,hiddenLabel:r,position:i,size:a,variant:o}=e;return va({root:[`root`,n&&`disablePointerEvents`,i&&`position${Y(i)}`,o,r&&`hiddenLabel`,a&&`size${Y(a)}`]},Nv,t)},Rv=J(`div`,{name:`MuiInputAdornment`,slot:`Root`,overridesResolver:Iv})(_s(({theme:e})=>({display:`flex`,maxHeight:`2em`,alignItems:`center`,whiteSpace:`nowrap`,color:(e.vars||e).palette.action.active,variants:[{props:{variant:`filled`},style:{[`&.${Pv.positionStart}&:not(.${Pv.hiddenLabel})`]:{marginTop:16}}},{props:{position:`start`},style:{marginRight:8}},{props:{position:`end`},style:{marginLeft:8}},{props:{disablePointerEvents:!0},style:{pointerEvents:`none`}}]}))),zv=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiInputAdornment`}),{children:r,className:i,component:a=`div`,disablePointerEvents:o=!1,disableTypography:s=!1,position:c,variant:l,...u}=n,d=hs()||{},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=Lv(p);return(0,W.jsx)(ms.Provider,{value:null,children:(0,W.jsx)(Rv,{as:a,ownerState:p,className:G(m.root,i),ref:t,...u,children:typeof r==`string`&&!s?(0,W.jsx)(Z,{color:`textSecondary`,children:r}):(0,W.jsxs)(v.Fragment,{children:[c===`start`?Fv||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):null,r]})})})});function Bv(e){return K(`MuiInputLabel`,e)}var Vv=Wr(`MuiInputLabel`,[`root`,`focused`,`disabled`,`error`,`required`,`asterisk`,`formControl`,`sizeSmall`,`shrink`,`animated`,`standard`,`filled`,`outlined`]),Hv=e=>{let{classes:t,disableUnderline:n}=e,r=va({root:[`root`,!n&&`underline`],input:[`input`]},sc,t);return{...t,...r}},Uv=J(Zs,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Js(e,t),!n.disableUnderline&&t.underline]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`;return e.vars&&(t=e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline)),{position:`relative`,variants:[{props:({ownerState:e})=>e.formControl,style:{[`label + &, .${Vv.root} + &`]:{marginTop:16}}},{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ws(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${cc.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${cc.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${t}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ws(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${cc.disabled}, .${cc.error}):before`]:{borderBottom:`2px solid ${(e.vars||e).palette.text.primary}`,"@media (hover: none)":{borderBottom:`1px solid ${t}`}},[`&.${cc.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t,disableUnderline:!1},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t].main}`}}}))]}})),Wv=J(Qs,{name:`MuiInput`,slot:`Input`,overridesResolver:Ys})({}),Gv=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiInput`}),{disableUnderline:r=!1,fullWidth:i=!1,inputComponent:a=`input`,multiline:o=!1,notched:s,slotProps:c,slots:l={},type:u=`text`,...d}=n,f=Hv(n),p={root:{ownerState:{disableUnderline:r}}},m=c?Ut(c,p):p,h=l.root??Uv,g=l.input??Wv;return(0,W.jsx)(ec,{slots:{root:h,input:g},slotProps:m,fullWidth:i,inputComponent:a,multiline:o,ref:t,type:u,...d,classes:f})});Gv.muiName=`Input`;function Kv(e){return K(`MuiSelect`,e)}var qv=Wr(`MuiSelect`,[`root`,`select`,`multiple`,`filled`,`outlined`,`standard`,`disabled`,`focused`,`icon`,`iconOpen`,`nativeInput`,`error`]),Jv=e=>{let{classes:t,disableUnderline:n,startAdornment:r,endAdornment:i,size:a,hiddenLabel:o,multiline:s}=e,c=va({root:[`root`,!n&&`underline`,r&&`adornedStart`,i&&`adornedEnd`,a===`small`&&`size${Y(a)}`,o&&`hiddenLabel`,s&&`multiline`],input:[`input`]},tc,t);return{...t,...c}},Yv=J(Zs,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiFilledInput`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[...Js(e,t),!n.disableUnderline&&t.underline]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`,n=t?`rgba(0, 0, 0, 0.42)`:`rgba(255, 255, 255, 0.7)`,r=t?`rgba(0, 0, 0, 0.06)`:`rgba(255, 255, 255, 0.09)`,i=t?`rgba(0, 0, 0, 0.09)`:`rgba(255, 255, 255, 0.13)`,a=t?`rgba(0, 0, 0, 0.12)`:`rgba(255, 255, 255, 0.12)`;return{position:`relative`,backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r,borderTopLeftRadius:(e.vars||e).shape.borderRadius,borderTopRightRadius:(e.vars||e).shape.borderRadius,...Ws(e,`background-color`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),"&:hover":{backgroundColor:e.vars?e.vars.palette.FilledInput.hoverBg:i,"@media (hover: none)":{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r}},[`&.${nc.focused}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.bg:r},[`&.${nc.disabled}`]:{backgroundColor:e.vars?e.vars.palette.FilledInput.disabledBg:a},variants:[{props:({ownerState:e})=>!e.disableUnderline,style:{"&::after":{left:0,bottom:0,content:`""`,position:`absolute`,right:0,transform:`scaleX(0)`,...Ws(e,`transform`,{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut}),pointerEvents:`none`},[`&.${nc.focused}:after`]:{transform:`scaleX(1) translateX(0)`},[`&.${nc.error}`]:{"&::before, &::after":{borderBottomColor:(e.vars||e).palette.error.main}},"&::before":{borderBottom:`1px solid ${e.vars?e.alpha(e.vars.palette.common.onBackground,e.vars.opacity.inputUnderline):n}`,left:0,bottom:0,content:`""`,position:`absolute`,right:0,...Ws(e,`border-bottom-color`,{duration:e.transitions.duration.shorter}),pointerEvents:`none`},[`&:hover:not(.${nc.disabled}, .${nc.error}):before`]:{borderBottom:`1px solid ${(e.vars||e).palette.text.primary}`},[`&.${nc.disabled}:before`]:{borderBottomStyle:`dotted`}}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{disableUnderline:!1,color:t},style:{"&::after":{borderBottom:`2px solid ${(e.vars||e).palette[t]?.main}`}}})),{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:12}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`12px`,paddingRight:`var(--_trailingPad)`,[`&.${qv.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`25px 12px 8px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.multiline&&e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}}]}})),Xv=J(Qs,{name:`MuiFilledInput`,slot:`Input`,overridesResolver:Ys})(_s(({theme:e})=>({paddingTop:25,paddingRight:12,paddingBottom:8,paddingLeft:12,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderTopLeftRadius:`inherit`,borderTopRightRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{paddingTop:21,paddingBottom:4}},{props:({ownerState:e})=>e.hiddenLabel,style:{paddingTop:16,paddingBottom:17}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}},{props:({ownerState:e})=>e.hiddenLabel&&e.size===`small`,style:{paddingTop:8,paddingBottom:9}},{props:({ownerState:e})=>e.multiline,style:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0}}]}))),Zv=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFilledInput`}),{disableUnderline:r=!1,fullWidth:i=!1,hiddenLabel:a,inputComponent:o=`input`,multiline:s=!1,notched:c,slotProps:l,slots:u={},type:d=`text`,...f}=n,p={...n,disableUnderline:r,fullWidth:i,inputComponent:o,multiline:s,type:d},m=Jv(n),h={root:{ownerState:p},input:{ownerState:p}},g=l?Ut(h,l):h,_=u.root??Yv,v=u.input??Xv;return(0,W.jsx)(ec,{slots:{root:_,input:v},slotProps:g,fullWidth:i,inputComponent:o,multiline:s,ref:t,type:d,...f,classes:m})});Zv.muiName=`Input`;var Qv,$v=J(`fieldset`,{name:`MuiNotchedOutlined`,shouldForwardProp:Ko})({textAlign:`left`,position:`absolute`,bottom:0,right:0,top:-5,left:0,margin:0,padding:`0 8px`,pointerEvents:`none`,borderRadius:`inherit`,borderStyle:`solid`,borderWidth:1,overflow:`hidden`,minWidth:`0%`}),ey=J(`legend`,{name:`MuiNotchedOutlined`,shouldForwardProp:Ko})(_s(({theme:e})=>({float:`unset`,width:`auto`,overflow:`hidden`,variants:[{props:({ownerState:e})=>!e.withLabel,style:{padding:0,lineHeight:`11px`,...Ws(e,`width`,{duration:150,easing:e.transitions.easing.easeOut})}},{props:({ownerState:e})=>e.withLabel,style:{display:`block`,padding:0,height:11,fontSize:`0.75em`,visibility:`hidden`,maxWidth:.01,...Ws(e,`max-width`,{duration:50,easing:e.transitions.easing.easeOut}),whiteSpace:`nowrap`,"& > span":{paddingLeft:5,paddingRight:5,display:`inline-block`,opacity:0,visibility:`visible`}}},{props:({ownerState:e})=>e.withLabel&&e.notched,style:{maxWidth:`100%`,...Ws(e,`max-width`,{duration:100,easing:e.transitions.easing.easeOut,delay:50})}}]})));function ty(e){let{children:t,classes:n,className:r,label:i,notched:a,...o}=e,s=i!=null&&i!==``,c={...e,notched:a,withLabel:s};return(0,W.jsx)($v,{"aria-hidden":!0,className:r,ownerState:c,...o,children:(0,W.jsx)(ey,{ownerState:c,children:s?(0,W.jsx)(`span`,{children:i}):Qv||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`})})})}var ny=e=>{let{classes:t}=e,n=va({root:[`root`],notchedOutline:[`notchedOutline`],input:[`input`]},hc,t);return{...t,...n}},ry=J(Zs,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiOutlinedInput`,slot:`Root`,overridesResolver:Js})(_s(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{position:`relative`,borderRadius:(e.vars||e).shape.borderRadius,[`&:hover .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette.text.primary},"@media (hover: none)":{[`&:hover .${gc.notchedOutline}`]:{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}},[`&.${gc.focused} .${gc.notchedOutline}`]:{borderWidth:2},variants:[...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{[`&.${gc.focused} .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${gc.error} .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette.error.main},[`&.${gc.disabled} .${gc.notchedOutline}`]:{borderColor:(e.vars||e).palette.action.disabled}}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:14}},{props:({ownerState:e})=>e.endAdornment,style:{"--_trailingPad":`14px`,paddingRight:`var(--_trailingPad)`,[`&.${qv.root}`]:{"--_trailingPad":`0px`}}},{props:({ownerState:e})=>e.multiline,style:{padding:`16.5px 14px`}},{props:({ownerState:e,size:t})=>e.multiline&&t===`small`,style:{padding:`8.5px 14px`}}]}})),iy=J(ty,{name:`MuiOutlinedInput`,slot:`NotchedOutline`})(_s(({theme:e})=>{let t=e.palette.mode===`light`?`rgba(0, 0, 0, 0.23)`:`rgba(255, 255, 255, 0.23)`;return{borderColor:e.vars?e.alpha(e.vars.palette.common.onBackground,.23):t}})),ay=J(Qs,{name:`MuiOutlinedInput`,slot:`Input`,overridesResolver:Ys})(_s(({theme:e})=>({padding:`16.5px 14px`,"&:-webkit-autofill":{...!e.vars&&{WebkitBoxShadow:e.palette.mode===`light`?null:`0 0 0 100px #266798 inset`,WebkitTextFillColor:e.palette.mode===`light`?null:`#fff`,caretColor:e.palette.mode===`light`?null:`#fff`},borderRadius:`inherit`,...e.vars&&e.applyStyles(`dark`,{WebkitBoxShadow:`0 0 0 100px #266798 inset`,WebkitTextFillColor:`#fff`,caretColor:`#fff`})},variants:[{props:{size:`small`},style:{padding:`8.5px 14px`}},{props:({ownerState:e})=>e.multiline,style:{padding:0}},{props:({ownerState:e})=>e.startAdornment,style:{paddingLeft:0}},{props:({ownerState:e})=>e.endAdornment,style:{paddingRight:0}}]}))),oy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiOutlinedInput`}),{fullWidth:r=!1,inputComponent:i=`input`,label:a,multiline:o=!1,notched:s,slots:c={},slotProps:l={},type:u=`text`,...d}=n,f=ny(n),[p,m]=gs({props:n,states:[`color`,`disabled`,`error`,`focused`,`hiddenLabel`,`size`,`required`]}),h={...n,color:p.color||`primary`,disabled:p.disabled,error:p.error,focused:p.focused,formControl:m,fullWidth:r,hiddenLabel:p.hiddenLabel,multiline:o,size:p.size,type:u},g=c.root??ry,_=c.input??ay,[y,b]=Jc(`notchedOutline`,{elementType:iy,className:f.notchedOutline,shouldForwardComponentProp:!0,ownerState:h,externalForwardedProps:{slots:c,slotProps:l},additionalProps:{label:a!=null&&a!==``&&p.required?(0,W.jsxs)(v.Fragment,{children:[a,` `,`*`]}):a}});return(0,W.jsx)(ec,{slots:{root:g,input:_},slotProps:l,renderSuffix:e=>(0,W.jsx)(y,{...b,notched:s===void 0?!!(e.startAdornment||e.filled||e.focused):s}),fullWidth:r,inputComponent:i,multiline:o,ref:t,type:u,...d,classes:{...f,notchedOutline:null}})});oy.muiName=`Input`;var sy=e=>{let{classes:t,color:n,focused:r,disabled:i,error:a,filled:o,required:s}=e;return va({root:[`root`,`color${Y(n)}`,i&&`disabled`,a&&`error`,o&&`filled`,r&&`focused`,s&&`required`],asterisk:[`asterisk`,a&&`error`]},ac,t)},cy=J(`label`,{name:`MuiFormLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.color===`secondary`&&t.colorSecondary,n.filled&&t.filled]}})(_s(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.body1,lineHeight:`1.4375em`,padding:0,position:`relative`,variants:[...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{[`&.${oc.focused}`]:{color:(e.vars||e).palette[t].main}}})),{props:{},style:{[`&.${oc.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${oc.error}`]:{color:(e.vars||e).palette.error.main}}}]}))),ly=J(`span`,{name:`MuiFormLabel`,slot:`Asterisk`})(_s(({theme:e})=>({[`&.${oc.error}`]:{color:(e.vars||e).palette.error.main}}))),uy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFormLabel`}),{children:r,className:i,color:a,component:o=`label`,disabled:s,error:c,filled:l,focused:u,required:d,...f}=n,[p]=gs({props:n,states:[`color`,`required`,`focused`,`disabled`,`error`,`filled`]}),m={...n,color:p.color||`primary`,component:o,disabled:p.disabled,error:p.error,filled:p.filled,focused:p.focused,required:p.required},h=sy(m);return(0,W.jsxs)(cy,{as:o,ownerState:m,className:G(h.root,i),ref:t,...f,children:[r,p.required&&(0,W.jsxs)(ly,{ownerState:m,"aria-hidden":!0,className:h.asterisk,children:[` `,`*`]})]})}),dy=e=>{let{classes:t,formControl:n,size:r,shrink:i,disableAnimation:a,variant:o,required:s}=e,c=va({root:[`root`,n&&`formControl`,!a&&`animated`,i&&`shrink`,r&&r!==`medium`&&`size${Y(r)}`,o],asterisk:[s&&`asterisk`]},Bv,t);return{...t,...c}},fy=J(uy,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiInputLabel`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`& .${oc.asterisk}`]:t.asterisk},t.root,n.formControl&&t.formControl,n.size===`small`&&t.sizeSmall,n.shrink&&t.shrink,!n.disableAnimation&&t.animated,n.focused&&t.focused,t[n.variant]]}})(_s(({theme:e})=>({display:`block`,transformOrigin:`top left`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`,variants:[{props:({ownerState:e})=>e.formControl,style:{position:`absolute`,left:0,top:0,transform:`translate(0, 20px) scale(1)`}},{props:{size:`small`},style:{transform:`translate(0, 17px) scale(1)`}},{props:({ownerState:e})=>e.shrink,style:{transform:`translate(0, -1.5px) scale(0.75)`,transformOrigin:`top left`,maxWidth:`133%`}},{props:({ownerState:e})=>!e.disableAnimation,style:{...Ws(e,[`color`,`transform`,`max-width`],{duration:e.transitions.duration.shorter,easing:e.transitions.easing.easeOut})}},{props:{variant:`filled`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(12px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`filled`,size:`small`},style:{transform:`translate(12px, 13px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`filled`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,transform:`translate(12px, 7px) scale(0.75)`,maxWidth:`calc(133% - 24px)`}},{props:({variant:e,ownerState:t,size:n})=>e===`filled`&&t.shrink&&n===`small`,style:{transform:`translate(12px, 4px) scale(0.75)`}},{props:{variant:`outlined`},style:{zIndex:1,pointerEvents:`none`,transform:`translate(14px, 16px) scale(1)`,maxWidth:`calc(100% - 24px)`}},{props:{variant:`outlined`,size:`small`},style:{transform:`translate(14px, 9px) scale(1)`}},{props:({variant:e,ownerState:t})=>e===`outlined`&&t.shrink,style:{userSelect:`none`,pointerEvents:`auto`,maxWidth:`calc(133% - 32px)`,transform:`translate(14px, -9px) scale(0.75)`}}]}))),py=v.forwardRef(function(e,t){let n=Jo({name:`MuiInputLabel`,props:e}),{disableAnimation:r=!1,margin:i,shrink:a,variant:o,className:s,...c}=n,[l,u]=gs({props:n,states:[`size`,`variant`,`required`,`focused`]}),d=a;d===void 0&&u&&(d=u.filled||u.focused||u.adornedStart);let f={...n,disableAnimation:r,formControl:u,shrink:d,size:l.size,variant:l.variant,required:l.required,focused:l.focused},p=dy(f);return(0,W.jsx)(fy,{"data-shrink":d,ref:t,className:G(p.root,s),...c,ownerState:f,classes:p})});function my(e){return K(`MuiFormControl`,e)}Wr(`MuiFormControl`,[`root`,`marginNone`,`marginNormal`,`marginDense`,`fullWidth`,`disabled`]);var hy=e=>{let{classes:t,margin:n,fullWidth:r}=e;return va({root:[`root`,n!==`none`&&`margin${Y(n)}`,r&&`fullWidth`]},my,t)},gy=J(`div`,{name:`MuiFormControl`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[`margin${Y(n.margin)}`],n.fullWidth&&t.fullWidth]}})({display:`inline-flex`,flexDirection:`column`,position:`relative`,minWidth:0,padding:0,margin:0,border:0,verticalAlign:`top`,variants:[{props:{margin:`normal`},style:{marginTop:16,marginBottom:8}},{props:{margin:`dense`},style:{marginTop:8,marginBottom:4}},{props:{fullWidth:!0},style:{width:`100%`}}]}),_y=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFormControl`}),{children:r,className:i,color:a=`primary`,component:o=`div`,disabled:s=!1,error:c=!1,focused:l,fullWidth:u=!1,hiddenLabel:d=!1,margin:f=`none`,required:p=!1,size:m=`medium`,variant:h=`outlined`,...g}=n,_={...n,color:a,component:o,disabled:s,error:c,fullWidth:u,hiddenLabel:d,margin:f,required:p,size:m,variant:h},y=hy(_),[b,x]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{if(!Cd(t,[`Input`,`Select`]))return;let n=Cd(t,[`Select`])?t.props.input:t;n&&Ts(n.props)&&(e=!0)}),e}),[S,C]=v.useState(()=>{let e=!1;return r&&v.Children.forEach(r,t=>{Cd(t,[`Input`,`Select`])&&(ws(t.props,!0)||ws(t.props.inputProps,!0))&&(e=!0)}),e}),[w,T]=v.useState(!1);s&&w&&T(!1);let E=l!==void 0&&!s?l:w,D;v.useRef(!1);let O=v.useCallback(()=>{C(!0)},[]),k=v.useCallback(()=>{C(!1)},[]),A=v.useMemo(()=>({adornedStart:b,setAdornedStart:x,color:a,disabled:s,error:c,filled:S,focused:E,fullWidth:u,hiddenLabel:d,size:m,onBlur:()=>{T(!1)},onFocus:()=>{T(!0)},onEmpty:k,onFilled:O,registerEffect:D,required:p,variant:h}),[b,a,s,c,S,E,u,d,D,k,O,p,m,h]);return(0,W.jsx)(ms.Provider,{value:A,children:(0,W.jsx)(gy,{as:o,ownerState:_,className:G(y.root,i),ref:t,...g,children:r})})}),vy,yy=e=>{let{classes:t,contained:n,size:r,disabled:i,error:a,filled:o,focused:s,required:c}=e;return va({root:[`root`,i&&`disabled`,a&&`error`,r&&`size${Y(r)}`,n&&`contained`,s&&`focused`,o&&`filled`,c&&`required`]},rc,t)},by=J(`p`,{name:`MuiFormHelperText`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.size&&t[`size${Y(n.size)}`],n.contained&&t.contained,n.filled&&t.filled]}})(_s(({theme:e})=>({color:(e.vars||e).palette.text.secondary,...e.typography.caption,textAlign:`left`,marginTop:3,marginRight:0,marginBottom:0,marginLeft:0,[`&.${ic.disabled}`]:{color:(e.vars||e).palette.text.disabled},[`&.${ic.error}`]:{color:(e.vars||e).palette.error.main},variants:[{props:{size:`small`},style:{marginTop:4}},{props:({ownerState:e})=>e.contained,style:{marginLeft:14,marginRight:14}}]}))),xy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiFormHelperText`}),{children:r,className:i,component:a=`p`,disabled:o,error:s,filled:c,focused:l,margin:u,required:d,variant:f,...p}=n,[m]=gs({props:n,states:[`variant`,`size`,`disabled`,`error`,`filled`,`focused`,`required`]}),h={...n,component:a,contained:m.variant===`filled`||m.variant===`outlined`,variant:m.variant,size:m.size,disabled:m.disabled,error:m.error,filled:m.filled,focused:m.focused,required:m.required};delete h.ownerState;let g=yy(h);return(0,W.jsx)(by,{as:a,className:G(g.root,i),ref:t,...p,ownerState:h,children:r===` `?vy||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):r})}),Sy=Du;function Cy(e,t){if(t==null){e.focus();return}try{e.focus({focusVisible:t===`keyboard`})}catch{e.focus()}}function wy(e){return e?e.type===`mousedown`||e.type===`pointerdown`||e.type===`touchstart`?`pointer`:e.type===`keydown`||e.type===`click`&&e.detail===0?`keyboard`:null:null}function Ty(e){return e==null||typeof e==`string`&&!e.trim()}function Ey(e,t){return typeof t==`object`&&t?e===t:String(e)===String(t)}var Dy=v.createContext(null);function Oy(){return v.useContext(Dy)}var ky=Dy.Provider,Ay=v.createContext(void 0);function jy(){let e=v.useContext(Ay);if(e===void 0)throw Error(`MUI: MenuListContext is missing. MenuItems must be placed within Menu or MenuList.`);return e}function My(e){let t=e?.element??e;if(!t)return``;if(e?.textValue!==void 0)return e.textValue;let n=t.innerText;return n===void 0&&(n=t.textContent),n??``}function Ny(e,t){if(t===void 0)return!0;let n=My(e);return n=n.trim().toLowerCase(),n.length===0?!1:t.repeating?n[0]===t.keys[0]:n.startsWith(t.keys.join(``))}function Py(e,t){return Ny(e,t)?Kf(e):!1}function Fy(e,t){Cy(e,t)}var Iy=v.forwardRef(function(e,t){let{actions:n,autoFocus:r=!1,autoFocusItem:i=!1,children:a,className:o,disabledItemsFocusable:s=!1,disableListWrap:c=!1,onKeyDown:l,variant:u=`selectedMenu`,...d}=e,f=v.useRef(null),p=v.useRef(!1),[m,h]=v.useState(!1),g=Oy(),_=v.useRef({keys:[],repeating:!0,previousKeyMatched:!0,lastTime:null}),y=Mf({activeItemId:void 0,getDefaultActiveItemId:v.useCallback(e=>u===`selectedMenu`?e.find(e=>e.selected&&Kf(e))?.id??e.find(e=>Kf(e))?.id??null:e.find(e=>Kf(e))?.id??null,[u]),orientation:`vertical`,wrap:!c}),{activeItemId:b,focusNext:x,getActiveItem:S,getContainerProps:C,getItemMap:w}=y,T=ul((e=!1)=>{if(!f.current||!e&&p.current)return null;if(i){let e=S();if(e?.element){let t=Array.from(w().values()).some(e=>e.selected),n=u===`menu`&&t&&!e.selected&&g==null;return h(n),Fy(e.element,g),p.current=!0,e.element}return r?(h(!1),f.current.focus(),f.current):null}return r?(h(!1),f.current.focus(),p.current=!0,f.current):(h(!1),null)});ys(()=>{if(!r&&!i){p.current=!1,h(!1);return}T()},[b,i,r,T]),v.useImperativeHandle(n,()=>({adjustStyleForScrollbar:(e,{direction:t})=>{let n=!f.current.style.width;if(e.clientHeight<f.current.clientHeight&&n){let n=`${Sy(wd(e))}px`;f.current.style[t===`rtl`?`paddingLeft`:`paddingRight`]=n,f.current.style.width=`calc(100% + ${n})`}return f.current},focusInitialTarget:()=>{if(!f.current)return null;let e=Ss(bs(f.current));return e&&Ru(f.current,e)?e:T(!0)}}),[T]);let E=C(void 0,d.onFocus),D=vs(f,E.ref,t),O=v.useMemo(()=>({itemsFocusableWhenDisabled:s,suppressInitialFocusVisible:m,variant:u}),[s,m,u]),k=ul(e=>{if(m&&h(!1),(e.ctrlKey||e.metaKey||e.altKey)&&l){l(e);return}if(E.onKeyDown(e),e.key.length===1){let t=_.current,n=e.key.toLowerCase(),r=performance.now();t.keys.length>0&&(r-t.lastTime>500?(t.keys=[],t.repeating=!0,t.previousKeyMatched=!0):t.repeating&&n!==t.keys[0]&&(t.repeating=!1)),t.lastTime=r,t.keys.push(n);let i=Ss(bs(f.current)),a=i&&!t.repeating&&Ny(i,t);t.previousKeyMatched&&(a||x(e=>Py(e,t))!=null)?e.preventDefault():t.previousKeyMatched=!1}l&&l(e)});return(0,W.jsx)(nf,{role:`menu`,ref:D,className:o,onKeyDown:k,tabIndex:-1,...d,onFocus:E.onFocus,children:(0,W.jsx)(Ay.Provider,{value:O,children:(0,W.jsx)(Df.Provider,{value:y,children:a})})})});function Ly(e){return K(`MuiPopover`,e)}Wr(`MuiPopover`,[`root`,`paper`]);function Ry(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.height/2:t===`bottom`&&(n=e.height),n}function zy(e,t){let n=0;return typeof t==`number`?n=t:t===`center`?n=e.width/2:t===`right`&&(n=e.width),n}function By(e){return[e.horizontal,e.vertical].map(e=>typeof e==`number`?`${e}px`:e).join(` `)}function Vy(e){return typeof e==`function`?e():e}var Hy=e=>{let{classes:t}=e;return va({root:[`root`],paper:[`paper`]},Ly,t)},Uy=J(xd,{name:`MuiPopover`,slot:`Root`})({}),Wy=J(Mc,{name:`MuiPopover`,slot:`Paper`})({position:`absolute`,overflowY:`auto`,overflowX:`hidden`,minWidth:16,minHeight:16,maxWidth:`calc(100% - 32px)`,maxHeight:`calc(100% - 32px)`,outline:0}),Gy=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiPopover`}),{action:r,anchorEl:i,anchorOrigin:a={vertical:`top`,horizontal:`left`},anchorPosition:o,anchorReference:s=`anchorEl`,children:c,className:l,container:u,disableAutoFocus:d=!1,elevation:f=8,marginThreshold:p=16,open:m,slots:h={},slotProps:g={},transformOrigin:_={vertical:`top`,horizontal:`left`},transitionDuration:y=`auto`,disableScrollLock:b=!1,...x}=n,S=v.useRef(),C={...n,anchorOrigin:a,anchorReference:s,elevation:f,marginThreshold:p,transformOrigin:_,transitionDuration:y},w=Hy(C),T=v.useCallback(()=>{if(s===`anchorPosition`)return o;let e=Vy(i),t=(e&&e.nodeType===1?e:bs(S.current).body).getBoundingClientRect();return{top:t.top+Ry(t,a.vertical),left:t.left+zy(t,a.horizontal)}},[i,a.horizontal,a.vertical,o,s]),E=v.useCallback(e=>({vertical:Ry(e,_.vertical),horizontal:zy(e,_.horizontal)}),[_.horizontal,_.vertical]),D=v.useCallback(e=>{let t={width:e.offsetWidth,height:e.offsetHeight},n=E(t);if(s===`none`)return{top:null,left:null,transformOrigin:By(n)};let r=T(),a=r.top-n.vertical,o=r.left-n.horizontal,c=a+t.height,l=o+t.width,u=wd(Vy(i)),d=u.innerHeight-p,f=u.innerWidth-p;if(p!=null&&a<p){let e=a-p;a-=e,n.vertical+=e}else if(p!=null&&c>d){let e=c-d;a-=e,n.vertical+=e}if(p!=null&&o<p){let e=o-p;o-=e,n.horizontal+=e}else if(l>f){let e=l-f;o-=e,n.horizontal+=e}return{top:`${Math.round(a)}px`,left:`${Math.round(o)}px`,transformOrigin:By(n)}},[i,s,T,E,p]),[O,k]=v.useState(m),A=v.useCallback(()=>{let e=S.current;if(!e)return;let t=D(e);t.top!=null&&e.style.setProperty(`top`,t.top),t.left!=null&&(e.style.left=t.left),e.style.transformOrigin=t.transformOrigin,k(!0)},[D]);v.useEffect(()=>(b&&window.addEventListener(`scroll`,A),()=>window.removeEventListener(`scroll`,A)),[i,b,A]);let j=()=>{A()},M=()=>{k(!1)};v.useEffect(()=>{m&&A()}),v.useImperativeHandle(r,()=>m?{updatePosition:()=>{A()}}:null,[m,A]),v.useEffect(()=>{if(!m)return;let e=Sd(()=>{A()}),t=wd(Vy(i));return t.addEventListener(`resize`,e),()=>{e.clear(),t.removeEventListener(`resize`,e)}},[i,m,A]);let N=y,P={slots:h,slotProps:g},[F,I]=Jc(`transition`,{elementType:mp,externalForwardedProps:P,ownerState:C,getSlotProps:e=>({...e,onEntering:(t,n)=>{e.onEntering?.(t,n),j()},onExited:t=>{e.onExited?.(t),M()}}),additionalProps:{appear:!0,in:m}});y===`auto`&&!F.muiSupportAuto&&(N=void 0);let L=u||(i?bs(Vy(i)).body:void 0),[R,{slots:ee,slotProps:te,...ne}]=Jc(`root`,{ref:t,elementType:Uy,externalForwardedProps:{...P,...x},shouldForwardComponentProp:!0,additionalProps:{slots:{backdrop:h.backdrop},slotProps:{backdrop:Od(typeof g.backdrop==`function`?g.backdrop(C):g.backdrop,{invisible:!0})},container:L,open:m},ownerState:C,className:G(w.root,l)}),[z,B]=Jc(`paper`,{ref:S,className:w.paper,elementType:Wy,externalForwardedProps:P,shouldForwardComponentProp:!0,additionalProps:{elevation:f,style:O?void 0:{opacity:0}},ownerState:C});return(0,W.jsx)(R,{...ne,...!rs(R)&&{slots:ee,slotProps:te,disableAutoFocus:d,disableScrollLock:b},children:(0,W.jsx)(F,{...I,timeout:N,children:(0,W.jsx)(z,{...B,children:c})})})});function Ky(e){return K(`MuiMenu`,e)}Wr(`MuiMenu`,[`root`,`paper`,`list`]);var qy={vertical:`top`,horizontal:`right`},Jy={vertical:`top`,horizontal:`left`},Yy=e=>{let{classes:t}=e;return va({root:[`root`],paper:[`paper`],list:[`list`]},Ky,t)},Xy=J(Gy,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiMenu`,slot:`Root`})({}),Zy=J(Wy,{name:`MuiMenu`,slot:`Paper`})({maxHeight:`calc(100% - 96px)`,WebkitOverflowScrolling:`touch`}),Qy=J(Iy,{name:`MuiMenu`,slot:`List`})({outline:0}),$y=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiMenu`}),{autoFocus:r=!0,children:i,className:a,disableAutoFocusItem:o=!1,onClose:s,open:c,PopoverClasses:l,transitionDuration:u=`auto`,variant:d=`selectedMenu`,slots:f={},slotProps:p={},...m}=n,h=Ii(),g={...n,autoFocus:r,disableAutoFocusItem:o,transitionDuration:u,variant:d},_=Yy(g),y=r&&c,b=y&&!o,x=v.useRef(null),S=(e,t)=>{x.current&&(x.current.adjustStyleForScrollbar(e,{direction:h?`rtl`:`ltr`}),y&&x.current.focusInitialTarget?.())},C=e=>{e.key===`Tab`&&(e.preventDefault(),s&&s(e,`tabKeyDown`))},w={slots:f,slotProps:p},T=lh({elementType:f.root,externalSlotProps:p.root,ownerState:g,className:[_.root,a]}),[E,D]=Jc(`paper`,{className:_.paper,elementType:Zy,externalForwardedProps:w,shouldForwardComponentProp:!0,ownerState:g}),[O,k]=Jc(`list`,{className:_.list,elementType:Qy,shouldForwardComponentProp:!0,externalForwardedProps:w,getSlotProps:e=>({...e,onKeyDown:t=>{C(t),e.onKeyDown?.(t)}}),ownerState:g}),A=typeof p.transition==`function`?p.transition(g):p.transition;return(0,W.jsx)(Xy,{disableAutoFocus:r,onClose:s,anchorOrigin:{vertical:`bottom`,horizontal:h?`right`:`left`},transformOrigin:h?qy:Jy,slots:{root:f.root,paper:E,backdrop:f.backdrop,transition:f.transition},slotProps:{root:T,paper:D,backdrop:typeof p.backdrop==`function`?p.backdrop(g):p.backdrop,transition:{...A,onEntering:(...e)=>{S(...e),A?.onEntering?.(...e)}}},open:c,ref:t,transitionDuration:u,ownerState:g,...m,classes:l,children:(0,W.jsx)(O,{actions:x,autoFocus:y,autoFocusItem:b,variant:d,...k,children:i})})}),eb=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return va({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,`icon${Y(n)}`,a&&`iconOpen`,r&&`disabled`]},pc,t)},tb=J(`select`,{name:`MuiNativeSelect`})(({theme:e})=>({MozAppearance:`none`,WebkitAppearance:`none`,userSelect:`none`,borderRadius:0,cursor:`pointer`,"&:focus":{borderRadius:0},[`&.${mc.disabled}`]:{cursor:`default`},"&[multiple]":{height:`auto`},"&:not([multiple]) option, &:not([multiple]) optgroup":{backgroundColor:(e.vars||e).palette.background.paper},[`& ~ .${Pv.root}`]:{position:`absolute`,top:`50%`,transform:`translateY(-50%)`,right:`calc(var(--_caret, 24px) + (var(--_endAdornment, 28px) - 1.5rem)/2)`},[`.${Ds.root}:has(> &)`]:{"--_endAdornment":`0px`},variants:[{props:({ownerState:e})=>e.variant!==`filled`&&e.variant!==`outlined`,style:{[`.${Ds.root}:has(> &)`]:{"--_caret":`24px`},[`.${Ds.root}:has(> & ~ .${Pv.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 24px) + var(--_endAdornment, 0px))`,minWidth:16}}},{props:{variant:`filled`},style:{[`.${Ds.root}:has(> &)`]:{"--_caret":`32px`},[`.${Ds.root}:has(> & ~ .${Pv.root})`]:{"--_endAdornment":`28px`},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}},{props:{variant:`outlined`},style:{[`.${Ds.root}:has(> &)`]:{"--_caret":`32px`},[`.${Ds.root}:has(> & ~ .${Pv.root})`]:{"--_endAdornment":`28px`},borderRadius:(e.vars||e).shape.borderRadius,"&:focus":{borderRadius:(e.vars||e).shape.borderRadius},"&&&":{paddingRight:`calc(var(--_caret, 32px) + var(--_endAdornment, 0px))`}}}]})),nb=J(tb,{name:`MuiNativeSelect`,slot:`Select`,shouldForwardProp:Ko,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.select,t[n.variant],n.error&&t.error,{[`&.${mc.multiple}`]:t.multiple}]}})({}),rb=J(`svg`,{name:`MuiNativeSelect`})(({theme:e})=>({position:`absolute`,right:0,top:`calc(50% - .5em)`,pointerEvents:`none`,color:(e.vars||e).palette.action.active,[`&.${mc.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:({ownerState:e})=>e.open,style:{transform:`rotate(180deg)`}},{props:{variant:`filled`},style:{right:7}},{props:{variant:`outlined`},style:{right:7}}]})),ib=J(rb,{name:`MuiNativeSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.variant&&t[`icon${Y(n.variant)}`],n.open&&t.iconOpen]}})({}),ab=v.forwardRef(function(e,t){let{className:n,disabled:r,error:i,IconComponent:a,inputRef:o,variant:s=`standard`,...c}=e,l={...e,disabled:r,variant:s,error:i},u=eb(l);return(0,W.jsxs)(v.Fragment,{children:[(0,W.jsx)(nb,{ownerState:l,className:G(u.select,n),disabled:r,ref:o||t,...c}),e.multiple?null:(0,W.jsx)(ib,{as:a,ownerState:l,className:u.icon})]})});function ob(e){return Object.prototype.hasOwnProperty.call(e.props,`value`)}function sb(e){if(typeof e==`string`||typeof e==`number`)return String(e);let t=``;return v.Children.forEach(e,e=>{typeof e==`string`||typeof e==`number`?t+=String(e):v.isValidElement(e)&&(t+=sb(e.props.children))}),t}function cb(e,t,n=0){if(e.length===0)return-1;let r=(n%e.length+e.length)%e.length;for(let n=0;n<e.length;n+=1){let i=(r+n)%e.length;if(e[i].label.startsWith(t))return i}return-1}function lb(e,t){return!e.some(e=>e.label[0]===t&&e.label[1]===t)}function ub(e,t){let n=[],r=-1;for(let i=0;i<e.length;i+=1){let a=e[i];if(!v.isValidElement(a)||!ob(a)||a.props.disabled)continue;let o=sb(a.props.children).trim().toLowerCase();o!==``&&(r===-1&&Ey(t,a.props.value)&&(r=n.length),n.push({child:a,label:o,value:a.props.value}))}return{options:n,selectedIndex:r}}var db,fb=2,pb=400,mb=200,hb=750,gb=` `,_b=`ArrowUp`,vb=`ArrowDown`,yb=`Enter`;function bb(e,t){if(!t)return!1;if(e.composedPath().includes(t)||e.target?.nodeType&&t.contains(e.target))return!0;let n=t.getBoundingClientRect();return n.width===0&&n.height===0?!1:e.clientX>=n.left-fb&&e.clientX<=n.right+fb&&e.clientY>=n.top-fb&&e.clientY<=n.bottom+fb}var xb=J(tb,{name:`MuiSelect`,slot:`Select`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[{[`&.${qv.select}`]:t.select},{[`&.${qv.select}`]:t[n.variant]},{[`&.${qv.error}`]:t.error},{[`&.${qv.multiple}`]:t.multiple}]}})({[`&.${qv.select}`]:{height:`auto`,minHeight:`1.4375em`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`}}),Sb=J(rb,{name:`MuiSelect`,slot:`Icon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.icon,n.open&&t.iconOpen]}})({}),Cb=J(`input`,{shouldForwardProp:e=>Go(e)&&e!==`classes`,name:`MuiSelect`,slot:`NativeInput`})({bottom:0,left:0,position:`absolute`,opacity:0,pointerEvents:`none`,width:`100%`,boxSizing:`border-box`}),wb=e=>{let{classes:t,variant:n,disabled:r,multiple:i,open:a,error:o}=e;return va({select:[`select`,n,r&&`disabled`,i&&`multiple`,o&&`error`],icon:[`icon`,a&&`iconOpen`,r&&`disabled`],nativeInput:[`nativeInput`]},Kv,t)},Tb=v.forwardRef(function(e,t){let{"aria-describedby":n,"aria-label":r,autoFocus:i,autoWidth:a,children:o,className:s,defaultOpen:c,defaultValue:l,disabled:u,displayEmpty:d,error:f=!1,IconComponent:p,inputRef:m,labelId:h,MenuProps:g={},multiple:_,name:y,onBlur:b,onChange:x,onClose:S,onFocus:C,onKeyDown:w,onMouseDown:T,onOpen:E,open:D,readOnly:O,renderValue:k,required:A,SelectDisplayProps:j={},tabIndex:M,type:N,value:P,variant:F=`standard`,...I}=e,[L,R]=Dd({controlled:P,default:l,name:`Select`}),[ee,te]=Dd({controlled:D,default:c,name:`Select`}),ne=v.useRef(null),z=v.useRef(null),B=v.useRef(null),V=v.useRef(!1),re=v.useRef(!1),ie=v.useRef(null),ae=v.useRef(!1),oe=v.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}),se=v.useRef({buffer:``,previousSearchIndex:null,matchedIndex:null}),H=Sl(),ce=Sl(),le=Sl(),[ue,de]=v.useState(null),{current:fe}=v.useRef(D!=null),[pe,me]=v.useState(),[he,U]=v.useState(null),ge=vs(t,m),_e=v.useCallback(e=>{z.current=e,e&&de(e)},[]),ve=ue?.parentNode;v.useImperativeHandle(ge,()=>({focus:()=>{z.current.focus()},node:ne.current,value:L}),[L]);let ye=ue!==null&&ee,be=v.useCallback(()=>{le.clear(),se.current.buffer=``,se.current.previousSearchIndex=null,se.current.matchedIndex=null},[le]);ys(()=>{V.current=ye,ye&&be()},[ye,be]);let xe=v.useCallback(()=>{H.clear(),ce.clear()},[H,ce]),Se=v.useCallback(()=>{xe(),ae.current=!1,oe.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1}},[xe]),Ce=v.useCallback(()=>{ie.current&&=(ie.current(),null)},[]);v.useEffect(()=>{ye||(Se(),Ce())},[ye,Se,Ce]),v.useEffect(()=>()=>{Se(),Ce(),be()},[Se,Ce,be]),v.useEffect(()=>{if(!ye||!ve||a||typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>{me(ve.clientWidth)});return e.observe(ve),()=>{e.disconnect()}},[ye,ve,a]),v.useEffect(()=>{c&&ee&&ue&&!fe&&(me(a?null:ve.clientWidth),z.current.focus())},[ue,a]),v.useEffect(()=>{i&&z.current.focus()},[i]),v.useEffect(()=>{if(!h)return;let e=bs(z.current).getElementById(h);if(e){let t=()=>{getSelection().isCollapsed&&z.current.focus()};return e.addEventListener(`click`,t),()=>{e.removeEventListener(`click`,t)}}},[h]);let we=ul((e,t)=>{e||(Se(),Ce()),e?(be(),U(wy(t)),E&&E(t)):(U(null),S&&S(t)),fe||(V.current=e,me(a?null:ve.clientWidth),te(e))}),Te=()=>{Se(),re.current?ce.start(mb,()=>{oe.current.allowUnselectedMouseUp=!0,H.start(mb,()=>{oe.current.allowSelectedMouseUp=!0})}):H.start(pb,()=>{oe.current.allowSelectedMouseUp=!0,oe.current.allowUnselectedMouseUp=!0})},Ee=e=>{if(T?.(e),e.button!==0||(e.preventDefault(),!z.current))return;z.current.focus();let t=bs(e.currentTarget);Te(),Ce();let n=e=>{ie.current=null,z.current&&(bb(e,z.current)||bb(e,B.current)||!V.current&&fe||we(!1,e))};t.addEventListener(`mouseup`,n,{capture:!0,once:!0}),ie.current=()=>{t.removeEventListener(`mouseup`,n,!0)},we(!0,e)},De=e=>{we(!1,e)},Oe=v.Children.toArray(o),ke=e=>{let t=Oe.find(t=>t.props.value===e.target.value);t!==void 0&&(R(t.props.value),x&&x(e,t))},Ae=(e,t,n)=>{if(R(n),x){let r=e.nativeEvent||e,i=new r.constructor(r.type,r);Object.defineProperty(i,"target",{writable:!0,value:{value:n,name:y}}),x(i,t)}},je=e=>t=>{ae.current=!1;let n;if(t.currentTarget.hasAttribute(`tabindex`)){if(_){n=Array.isArray(L)?L.slice():[];let t=L.indexOf(e.props.value);t===-1?n.push(e.props.value):n.splice(t,1)}else n=e.props.value;e.props.onClick&&e.props.onClick(t),L!==n&&Ae(t,e,n),_||we(!1,t)}},Me=(e,t)=>n=>{if(e.props.onMouseUp?.(n),ae.current){ae.current=!1;return}let r=!oe.current.allowSelectedMouseUp&&t,i=!oe.current.allowUnselectedMouseUp&&!t;r||i||n.currentTarget.click()},Ne=e=>{let t=se.current,n=t.buffer!==``;if(ye||_||u||e.defaultPrevented||e.nativeEvent?.isComposing||e.key.length!==1||e.ctrlKey||e.metaKey||e.altKey||e.key===gb&&!n)return!1;e.key===gb&&e.preventDefault();let r=t.buffer===``,{options:i,selectedIndex:a}=ub(Oe,L);if(i.length===0)return e.key!==gb&&be(),!0;r&&(t.previousSearchIndex=a);let o=e.key.toLowerCase();t.buffer===o&&lb(i,o)&&(t.buffer=``,t.previousSearchIndex=t.matchedIndex),t.buffer+=o,le.start(hb,be);let s=cb(i,t.buffer,(t.previousSearchIndex??-1)+1);if(s!==-1){let n=i[s];return t.matchedIndex=s,Ey(L,n.value)||Ae(e,n.child,n.value),!0}return e.key!==gb&&be(),!0},Pe=e=>{if(!O){let t=Ne(e),n=e.key===gb||e.key===_b||e.key===vb||e.key===yb;!t&&n&&(e.preventDefault(),we(!0,e)),w?.(e)}},Fe=e=>{be(),!ye&&b&&(Object.defineProperty(e,"target",{writable:!0,value:{value:L,name:y}}),b(e))},Ie=e=>t=>{e?.props?.onKeyDown?.(t),t.key===gb&&t.target===t.currentTarget&&!t.defaultPrevented&&(t.preventDefault(),t.repeat||t.currentTarget.click())};delete I[`aria-invalid`];let Le,Re,ze=[],Be=!1,Ve=!1;(ws({value:L})||d)&&(k?Le=k(L):Be=!0);let He=Oe.map(e=>{if(!v.isValidElement(e))return null;let t;if(_){if(!Array.isArray(L))throw Error(It(2));t=L.some(t=>Ey(t,e.props.value)),t&&Be&&ze.push(e.props.children)}else t=Ey(L,e.props.value),t&&Be&&(Re=e.props.children);return t&&(Ve=!0),v.cloneElement(e,{"aria-selected":t?`true`:`false`,onMouseDown:t=>{ae.current=!0,e.props.onMouseDown?.(t)},onPointerDown:t=>{ae.current=!0,e.props.onPointerDown?.(t)},onClick:je(e),onMouseUp:Me(e,t),onKeyUp:t=>{t.key===gb&&t.preventDefault(),e.props.onKeyUp&&e.props.onKeyUp(t)},onKeyDown:Ie(e),role:`option`,selected:t,value:void 0,"data-value":e.props.value})});ys(()=>{re.current=Ve,!ye&&!_&&!Ve&&be()},[Ve,_,ye,be]),Be&&(Le=_?ze.length===0?null:ze.reduce((e,t,n)=>(e.push(t),n<ze.length-1&&e.push(`, `),e),[]):Re);let Ue=pe;!a&&fe&&ue&&(Ue=ve.clientWidth);let We;We=M===void 0?u?null:0:M;let Ge=j.id||(y?`mui-component-select-${y}`:void 0),Ke={...e,variant:F,value:L,open:ye,error:f},qe=wb(Ke),Je=typeof g.slotProps?.paper==`function`?g.slotProps.paper(Ke):g.slotProps?.paper,Ye=vs(Je?.ref,B),Xe=typeof g.slotProps?.list==`function`?g.slotProps.list(Ke):g.slotProps?.list,Ze=Wi(),Qe=Wi();return(0,W.jsxs)(v.Fragment,{children:[(0,W.jsx)(xb,{as:`div`,ref:_e,tabIndex:We,role:`combobox`,"aria-controls":ye?Ze:void 0,"aria-disabled":u?`true`:void 0,"aria-expanded":ye?`true`:`false`,"aria-haspopup":`listbox`,"aria-readonly":O?`true`:void 0,"aria-label":r,"aria-labelledby":h,"aria-describedby":n,"aria-required":A?`true`:void 0,"aria-invalid":f?`true`:void 0,onKeyDown:Pe,onMouseDown:u||O?null:Ee,onBlur:Fe,onFocus:C,...j,ownerState:Ke,className:G(j.className,qe.select,s),id:Ge,children:Ty(Le)?db||=(0,W.jsx)(`span`,{className:`notranslate`,"aria-hidden":!0,children:`​`}):Le}),(0,W.jsx)(Cb,{"aria-invalid":f,value:Array.isArray(L)?L.join(`,`):L,name:y,ref:ne,"aria-hidden":!0,onChange:ke,tabIndex:-1,disabled:u,readOnly:O,className:qe.nativeInput,autoFocus:i,required:A,...I,id:I.id??Qe,ownerState:Ke}),(0,W.jsx)(Sb,{as:p,className:qe.icon,ownerState:Ke}),(0,W.jsx)(ky,{value:he,children:(0,W.jsx)($y,{id:`menu-${y||``}`,anchorEl:ve,open:ye,onClose:De,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},...g,slotProps:{...g.slotProps,list:{"aria-labelledby":h,role:`listbox`,"aria-multiselectable":_?`true`:void 0,disableListWrap:!0,id:Ze,...Xe},paper:{...Je,ref:Ye,style:{minWidth:Ue,...Je?.style}}},children:He})})]})}),Eb=sl((0,W.jsx)(`path`,{d:`M7 10l5 5 5-5z`}),`ArrowDropDown`),Db=e=>{let{classes:t}=e,n=va({root:[`root`]},Kv,t);return{...t,...n}},Ob={name:`MuiSelect`,slot:`Root`,shouldForwardProp:e=>Ko(e)&&e!==`variant`},kb=J(Gv,Ob)(``),Ab=J(oy,Ob)(``),jb=J(Zv,Ob)(``),Mb=v.forwardRef(function(e,t){let n=Jo({name:`MuiSelect`,props:e}),{autoWidth:r=!1,children:i,classes:a={},className:o,defaultOpen:s=!1,displayEmpty:c=!1,IconComponent:l=Eb,id:u,input:d,inputProps:f,label:p,labelId:m,MenuProps:h,multiple:g=!1,native:_=!1,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:C,variant:w=`outlined`,...T}=n,E=_?ab:Tb,[D]=gs({props:n,states:[`variant`,`error`]}),O=D.variant||w,k={...n,variant:O,classes:a},A=Db(k),{root:j,...M}=A,N=d||{standard:(0,W.jsx)(kb,{ownerState:k}),outlined:(0,W.jsx)(Ab,{label:p,ownerState:k}),filled:(0,W.jsx)(jb,{ownerState:k})}[O],P=vs(t,Iu(N));return(0,W.jsx)(v.Fragment,{children:v.cloneElement(N,{inputComponent:E,inputProps:{children:i,error:D.error,IconComponent:l,variant:O,type:void 0,multiple:g,..._?{id:u}:{autoWidth:r,defaultOpen:s,displayEmpty:c,labelId:m,MenuProps:h,onClose:y,onOpen:b,open:x,renderValue:S,SelectDisplayProps:{id:u,...C}},...f,classes:f?Ut(M,f.classes):M,...d?d.props.inputProps:{}},...(g&&_||c)&&O===`outlined`?{notched:!0}:{},ref:P,className:G(N.props.className,o,A.root),...!d&&{variant:O},...T})})});Mb.muiName=`Select`;function Nb(e){return K(`MuiTextField`,e)}Wr(`MuiTextField`,[`root`]);var Pb={standard:Gv,filled:Zv,outlined:oy},Fb=e=>{let{classes:t}=e;return va({root:[`root`]},Nb,t)},Ib=J(_y,{name:`MuiTextField`,slot:`Root`})({}),Lb=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiTextField`}),{autoComplete:r,autoFocus:i=!1,children:a,className:o,color:s=`primary`,defaultValue:c,disabled:l=!1,error:u=!1,fullWidth:d=!1,helperText:f,id:p,inputRef:m,label:h,maxRows:g,minRows:_,multiline:v=!1,name:y,onBlur:b,onChange:x,onFocus:S,placeholder:C,required:w=!1,rows:T,select:E=!1,slots:D={},slotProps:O={},type:k,value:A,variant:j=`outlined`,...M}=n,N={...n,autoFocus:i,color:s,disabled:l,error:u,fullWidth:d,multiline:v,required:w,select:E,variant:j},P=Fb(N),F=Wi(p),I=f&&F?`${F}-helper-text`:void 0,L=h&&F?`${F}-label`:void 0,R=Pb[j],ee={slots:D,slotProps:O},[te,ne]=Jc(`select`,{elementType:Mb,externalForwardedProps:ee,ownerState:N}),z=E&&ne.native,B={},V=ee.slotProps.inputLabel;j===`outlined`&&(V&&V.shrink!==void 0&&(B.notched=V.shrink),B.label=h),E&&(z||(B.id=void 0),B[`aria-describedby`]=void 0);let[re,ie]=Jc(`root`,{elementType:Ib,shouldForwardComponentProp:!0,externalForwardedProps:{...ee,...M},ownerState:N,className:G(P.root,o),ref:t,additionalProps:{disabled:l,error:u,fullWidth:d,required:w,color:s,variant:j}}),[ae,oe]=Jc(`input`,{elementType:R,externalForwardedProps:ee,additionalProps:B,ownerState:N}),[se,H]=Jc(`inputLabel`,{elementType:py,externalForwardedProps:ee,ownerState:N}),[ce,le]=Jc(`htmlInput`,{elementType:`input`,externalForwardedProps:ee,ownerState:N}),[ue,de]=Jc(`formHelperText`,{elementType:xy,externalForwardedProps:ee,ownerState:N}),fe=(0,W.jsx)(ae,{"aria-describedby":I,autoComplete:r,autoFocus:i,defaultValue:c,fullWidth:d,multiline:v,name:y,rows:T,maxRows:g,minRows:_,type:k,value:A,id:F,inputRef:m,onBlur:b,onChange:x,onFocus:S,placeholder:C,inputProps:le,slots:{input:D.htmlInput?ce:void 0},...oe});return(0,W.jsxs)(re,{...ie,children:[h!=null&&h!==``&&(0,W.jsx)(se,{htmlFor:E&&!z?void 0:F,id:L,...E&&!z&&{component:`div`},...H,children:h}),E?(0,W.jsx)(te,{"aria-describedby":I,id:F,labelId:L,value:A,input:fe,...ne,children:a}):fe,f&&(0,W.jsx)(ue,{id:I,...de,children:f})]})}),Rb=sl((0,W.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`),zb=`modulepreload`,Bb=function(e){return`/`+e},Vb={},Hb=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=Bb(t,n),t=s(t),t in Vb)return;Vb[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`:zb,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)})},Ub=(0,v.lazy)(async()=>({default:(await Hb(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-B4XehTCU.js`);return{MarkdownMessage:e}},[])).MarkdownMessage})),Wb=new Set([`md`,`markdown`]),Gb=new Set([`csv`,`tsv`]);function Kb(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MB`:`${Math.max(1,Math.round(e/1024))} KB`}function qb(e,t){return e.source===`project`?$(t,`Project`,`Project`):$(t,`Thư mục đã cấp quyền`,`Granted directory`)}function Jb(e,t){let n=[],r=[],i=``,a=!1,o=0,s=()=>{r.length<40&&r.push(i),i=``},c=()=>{s(),r.some(e=>e.length>0)&&n.push(r),r=[]};for(;o<e.length&&n.length<500;){let n=e[o];if(a){if(n===`"`&&e[o+1]===`"`){i+=`"`,o+=2;continue}if(n===`"`){a=!1,o+=1;continue}i+=n,o+=1;continue}if(n===`"`&&i.length===0){a=!0,o+=1;continue}if(n===t){s(),o+=1;continue}if(n===`
173
173
  `||n===`\r`){c(),n===`\r`&&e[o+1]===`
174
- `&&(o+=1),o+=1;continue}i+=n,o+=1}return n.length<500&&(i.length>0||r.length>0)&&c(),n}function Wb({text:e,separator:t}){let n=(0,v.useMemo)(()=>Ub(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,W.jsx)(X,{sx:{overflowX:`auto`},children:(0,W.jsxs)(X,{component:`table`,className:`document-table`,children:[(0,W.jsx)(X,{component:`thead`,children:(0,W.jsx)(X,{component:`tr`,children:Array.from({length:a},(e,t)=>(0,W.jsx)(X,{component:`th`,children:r[t]??``},t))})}),(0,W.jsx)(X,{component:`tbody`,children:i.map((e,t)=>(0,W.jsx)(X,{component:`tr`,children:Array.from({length:a},(t,n)=>(0,W.jsx)(X,{component:`td`,children:e[n]??``},n))},t))})]})})}function Gb({document:e,extension:t}){let n=e.text??``;return zb.has(t??``)?(0,W.jsx)(v.Suspense,{fallback:(0,W.jsx)(X,{component:`pre`,className:`document-plain`,children:n}),children:(0,W.jsx)(Rb,{children:n})}):Bb.has(t??``)?(0,W.jsx)(Wb,{text:n,separator:t===`tsv`?` `:`,`}):(0,W.jsx)(X,{component:`pre`,className:`document-plain`,children:n})}function Kb({sessionRef:e=null}){let{locale:t}=xv(),[n,r]=(0,v.useState)({state:`idle`}),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({state:`idle`}),[c,l]=(0,v.useState)(``),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=new AbortController;return r({state:`loading`}),a(null),s({state:`idle`}),S_(e,t.signal).then(e=>r({state:`ready`,value:e})).catch(()=>{t.signal.aborted||r({state:`error`})}),()=>t.abort()},[e]),(0,v.useEffect)(()=>{if(!i){s({state:`idle`});return}let t=new AbortController;return s({state:`loading`}),C_(e,i,t.signal).then(e=>{s({state:`ready`,value:e}),u.current?.scrollTo({top:0})}).catch(()=>{t.signal.aborted||s({state:`error`})}),()=>t.abort()},[e,i]);let d=n.value,f=c.trim().toLowerCase(),p=(0,v.useMemo)(()=>(d?.documents??[]).filter(e=>!f||e.relativePath.toLowerCase().includes(f)),[d,f]),m=(0,v.useMemo)(()=>(d?.roots??[]).map(e=>({root:e,entries:p.filter(t=>t.rootRef===e.rootRef)})).filter(e=>e.entries.length>0),[d,p]),h=p.find(e=>e.documentRef===i)??d?.documents.find(e=>e.documentRef===i);return(0,W.jsxs)(`section`,{className:`document-workspace surface`,"aria-labelledby":`documents-heading`,children:[(0,W.jsxs)(`header`,{className:`document-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(t,`Chỉ đọc · không sửa file`,`Read only · never writes`)}),(0,W.jsx)(`h2`,{id:`documents-heading`,children:$(t,`Tài liệu`,`Documents`)})]}),(0,W.jsx)(`span`,{children:d?`${d.documents.length}${d.truncated?`+`:``} ${$(t,`tài liệu`,`documents`)}`:`—`})]}),(0,W.jsxs)(`div`,{className:`document-body`,children:[(0,W.jsxs)(`aside`,{className:`document-list`,"aria-label":$(t,`Danh sách tài liệu`,`Document list`),children:[(0,W.jsx)(Mb,{size:`small`,fullWidth:!0,value:c,onChange:e=>l(e.target.value),placeholder:$(t,`Lọc theo tên hoặc thư mục…`,`Filter by name or folder…`),slotProps:{htmlInput:{"aria-label":$(t,`Lọc tài liệu`,`Filter documents`)},input:{startAdornment:(0,W.jsx)(Pv,{position:`start`,children:(0,W.jsx)(Nb,{fontSize:`small`})})}}}),n.state===`loading`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Đang quét tài liệu…`,`Scanning for documents…`)}),n.state===`error`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Không đọc được danh sách tài liệu.`,`The document list could not be read.`)}),d?.state===`unavailable`&&(0,W.jsx)(`p`,{className:`document-empty`,children:Q(d.reasonCode,t)}),n.state===`ready`&&d?.state===`ready`&&m.length===0&&(0,W.jsx)(`p`,{className:`document-empty`,children:f?$(t,`Không có tài liệu nào khớp bộ lọc.`,`No document matches the filter.`):$(t,`Chưa tìm thấy tài liệu nào.`,`No documents were found.`)}),m.map(e=>(0,W.jsxs)(`div`,{className:`document-group`,children:[(0,W.jsxs)(`div`,{className:`document-group-heading`,children:[(0,W.jsx)(`strong`,{children:Hb(e.root,t)}),(0,W.jsx)(`span`,{title:e.root.path,children:e.root.path})]}),e.entries.map(e=>(0,W.jsxs)(sf,{component:`button`,type:`button`,className:`document-row`,selected:e.documentRef===i,onClick:()=>a(e.documentRef),children:[(0,W.jsx)(Nh,{fontSize:`small`,"aria-hidden":`true`}),(0,W.jsxs)(`span`,{className:`document-row-copy`,children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`small`,{children:e.relativePath})]}),(0,W.jsxs)(`span`,{className:`document-row-meta`,children:[e.extension,` · `,Vb(e.sizeBytes)]})]},e.documentRef))]},e.root.rootRef)),d?.truncated&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(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,W.jsxs)(`div`,{className:`document-viewer`,ref:u,children:[!i&&(0,W.jsxs)(`div`,{className:`document-placeholder`,children:[(0,W.jsx)(Nh,{"aria-hidden":`true`}),(0,W.jsx)(Z,{variant:`body2`,children:$(t,`Chọn một tài liệu để đọc nội dung tại đây.`,`Pick a document to read it here.`)}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:$(t,`Hỗ trợ .md .txt .csv .json .yaml .docx .pdf`,`Supports .md .txt .csv .json .yaml .docx .pdf`)})]}),i&&o.state===`loading`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Đang mở tài liệu…`,`Opening the document…`)}),i&&o.state===`error`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Không mở được tài liệu này.`,`This document could not be opened.`)}),o.state===`ready`&&o.value&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`document-toolbar`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:o.value.name??h?.name??`—`}),(0,W.jsx)(`small`,{children:o.value.relativePath??h?.relativePath??``})]}),(0,W.jsxs)(`div`,{className:`document-badges`,children:[o.value.format&&(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:o.value.format}),o.value.truncated&&(0,W.jsx)(cu,{size:`small`,color:`warning`,variant:`outlined`,label:$(t,`Đã cắt bớt`,`Truncated`)}),o.value.redacted&&(0,W.jsx)(cu,{size:`small`,color:`warning`,variant:`outlined`,label:$(t,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`)})]})]}),o.value.state===`unavailable`?(0,W.jsx)(`p`,{className:`document-empty`,children:Q(o.value.reasonCode,t)}):(0,W.jsx)(`article`,{className:`document-content`,children:(0,W.jsx)(Gb,{document:o.value,extension:h?.extension})})]})]})]})]})}function qb(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 Jb(e,t,n,r=`vi`){let i=[...e,...t],a=new Set(i.map(e=>e.activityRef)),o=n.filter(e=>!a.has(e.activityRef)).map(e=>qb(e,r));return{rows:[...e,...o,...t],terminalCount:o.length}}function Yb(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 Xb(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 Zb({activity:e,preview:t,onPreview:n,locale:r}){return(0,W.jsxs)(`article`,{className:`activity-row`,children:[(0,W.jsx)(`span`,{className:`activity-state tone-${fv(e.state)}`,"aria-label":e.state}),(0,W.jsxs)(`div`,{className:`activity-copy`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`span`,{children:e.kind})]}),(0,W.jsx)(`p`,{children:e.preview||$(r,`Không có mô tả ngắn`,`No short description`)}),t&&(0,W.jsxs)(`div`,{className:`log-preview ${t.state===`error`?`error-state`:``}`,children:[t.state===`loading`?$(r,`Đang tải log ngắn…`,`Loading log preview…`):t.state===`error`?$(r,`Log preview không còn sẵn sàng.`,`Log preview is no longer available.`):t.value?.preview??`${$(r,`Không có nội dung log`,`No log content`)} · ${t.value?.reasonCode??`unavailable`}`,t.value?.truncated&&(0,W.jsx)(`small`,{children:$(r,`Preview đã được rút gọn`,`Preview truncated`)})]})]}),(0,W.jsxs)(`div`,{className:`activity-result`,children:[(0,W.jsx)(`strong`,{children:Yb(e,r)}),(0,W.jsx)(`span`,{children:Xb(e,r)}),e.logRef&&n&&(0,W.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":!!t,children:t?$(r,`Ẩn log`,`Hide log`):$(r,`Xem log`,`View log`)})]})]})}function Qb({snapshot:e,sessionRef:t,terminalActivities:n=[]}){let{locale:r}=xv(),[i,a]=(0,v.useState)({}),o=e?.activity.running??[],{rows:s,terminalCount:c}=Jb(o,e?.activity.recent??[],n,r),l=e=>{if(i[e.activityRef]){a(t=>({...t,[e.activityRef]:void 0}));return}a(t=>({...t,[e.activityRef]:{state:`loading`}})),(t?Ug(t,e.activityRef):s_(e.activityRef)).then(t=>a(n=>({...n,[e.activityRef]:{state:`ready`,value:t}}))).catch(()=>a(t=>({...t,[e.activityRef]:{state:`error`}})))};return(0,W.jsxs)(`section`,{className:`activity-panel surface`,"aria-labelledby":`activity-title`,children:[(0,W.jsxs)(`header`,{className:`panel-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Activity`}),(0,W.jsx)(`h2`,{id:`activity-title`,children:$(r,`Tool, command và kết quả lượt chạy`,`Tools, commands, and operation outcomes`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{className:`running-count`,children:[o.length,` `,$(r,`đang chạy`,`running`)]}),(0,W.jsxs)(`span`,{children:[(e?.activity.page.total??0)+c,` `,$(r,`gần đây`,`recent`)]})]})]}),(0,W.jsxs)(`div`,{className:`activity-list`,children:[s.map(e=>(0,W.jsx)(Zb,{activity:e,preview:i[e.activityRef],onPreview:e.logRef?()=>l(e):void 0,locale:r},e.activityRef)),s.length===0&&(0,W.jsx)(`div`,{className:`activity-empty`,children:$(r,`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,W.jsx)(`footer`,{className:`panel-footnote`,children:$(r,`Timeline đã được rút gọn theo giới hạn local.`,`The timeline was truncated to local limits.`)})]})}function $b(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 ex(e,t=`vi`){return e.state!==`known`||e.tokens===null||e.percent===null?t===`vi`?`Context chưa xác định`:`Unknown context`:`${$b(e.tokens,t)} / ${$b(e.contextWindow,t)} · ${e.percent.toFixed(1)}%`}function tx(e,t=`vi`){return e.state===`known`?`↑ ${$b(e.input,t)} · ↓ ${$b(e.output,t)}`:t===`vi`?`Không có dữ liệu`:`No data`}function nx(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 rx(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 ix({kicker:e,title:t,children:n}){return(0,W.jsxs)(`section`,{className:`evidence-card surface`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:e}),(0,W.jsx)(`h3`,{children:t}),n]})}function ax({snapshot:e}){let{locale:t}=xv(),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,W.jsxs)(`section`,{className:`evidence-section`,"aria-labelledby":`evidence-title`,children:[(0,W.jsxs)(`header`,{className:`section-title-row`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Completion evidence`}),(0,W.jsx)(`h2`,{id:`evidence-title`,children:$(t,`Verifier, usage và handoff`,`Verifier, usage, and handoff`)})]}),(0,W.jsx)(`span`,{children:rx(e,t)})]}),(0,W.jsxs)(`div`,{className:`evidence-grid`,children:[(0,W.jsx)(ix,{kicker:$(t,`Verifier gần nhất`,`Latest verifier`),title:nx(n,t),children:n?(0,W.jsxs)(`dl`,{className:`evidence-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Command`}),(0,W.jsx)(`dd`,{title:n.command,children:n.command})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Exact`}),(0,W.jsx)(`dd`,{children:n.exact?$(t,`Có`,`Yes`):$(t,`Không`,`No`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Tree digest`}),(0,W.jsx)(`dd`,{title:n.treeDigest??void 0,children:pv(n.treeDigest)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`File làm stale`,`Stale files`)}),(0,W.jsx)(`dd`,{children:n.staleFilesKnown?n.staleByPaths.length:$(t,`Chưa biết`,`Unknown`)})]})]}):(0,W.jsx)(`p`,{className:`card-empty`,children:e.verification.reasonCode?Q(e.verification.reasonCode,t):$(t,`Task chưa chạy verifier.`,`The task has not run a verifier.`)})}),(0,W.jsxs)(ix,{kicker:`Token & context`,title:ex(r,t),children:[(0,W.jsx)(`div`,{className:`context-meter`,role:`progressbar`,"aria-label":$(t,`Mức sử dụng context`,`Context usage`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:(0,W.jsx)(`span`,{style:{width:`${o}%`}})}),(0,W.jsxs)(`dl`,{className:`evidence-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Turn gần nhất`,`Latest turn`)}),(0,W.jsx)(`dd`,{children:tx(e.usage.latestTurn,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Task total`}),(0,W.jsx)(`dd`,{children:tx(e.usage.taskTotal,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Session total`}),(0,W.jsx)(`dd`,{children:tx(e.usage.sessionTotal,t)})]})]})]}),(0,W.jsxs)(ix,{kicker:`Continuation budget`,title:Q(i.state,t),children:[(0,W.jsxs)(`dl`,{className:`budget-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Còn lại`,`Remaining`)}),(0,W.jsx)(`dd`,{children:$b(i.remaining,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Đã dùng`,`Used`)}),(0,W.jsx)(`dd`,{children:$b(i.consumed,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Tối đa`,`Maximum`)}),(0,W.jsx)(`dd`,{children:$b(i.maximum,t)})]})]}),i.reasonCode&&(0,W.jsx)(`p`,{className:`card-note`,children:Q(i.reasonCode,t)})]}),(0,W.jsx)(ix,{kicker:`Handoff`,title:a?Q(a.state,t):$(t,`Chưa có handoff`,`No handoff`),children:a?(0,W.jsxs)(`div`,{className:`handoff-copy`,children:[(0,W.jsx)(`p`,{children:a.summary}),a.blocker&&(0,W.jsxs)(`div`,{className:`handoff-blocker`,children:[(0,W.jsx)(`strong`,{children:`Blocker`}),(0,W.jsx)(`span`,{children:a.blocker})]}),a.nextSafeAction&&(0,W.jsxs)(`div`,{className:`next-action`,children:[(0,W.jsx)(`strong`,{children:$(t,`Bước an toàn tiếp theo`,`Next safe action`)}),(0,W.jsx)(`span`,{children:a.nextSafeAction})]})]}):(0,W.jsx)(`p`,{className:`card-empty`,children:$(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 ox=16384;function sx(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 cx(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(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,ox),truncated:e.truncated||n.length>ox})}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)}}function lx(e,t,n){return e===`vi`?t:n}var ux={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`},dx=Object.keys(ux).map(e=>`.${e}`).join(`,`),fx=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]);function px(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024).toFixed(+(e<10240))} KiB`}function mx(e,t){let n=e.truncated?` · ${lx(t,`đã cắt bớt`,`truncated`)}`:``;return e.kind===`image`?`${lx(t,`Ảnh`,`Image`)} · ${px(e.sizeBytes)}`:e.kind===`document`?`${lx(t,`Tài liệu`,`Document`)} · ${px(e.sourceBytes)} → ${px(e.sizeBytes)} ${lx(t,`văn bản`,`text`)}${n}`:`File · ${px(e.sizeBytes)}${n}`}function hx(e){return[...e,...Object.entries(ux).filter(([,t])=>e.has(t)).map(([e])=>`.${e}`)].join(`,`)}function gx(e){return!!(e&&[...e.types].includes(`Files`))}async function _x(e){let{snapshot:t,locale:n}=e,r=[...e.existing],i=null,a=Math.max(0,4-r.length);e.files.length>a&&(i=lx(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=ux[o.name.split(`.`).pop()?.toLowerCase()??``];if(!a){i=`${o.name}: ${lx(n,`loại file chưa được hỗ trợ.`,`unsupported file type.`)}`;continue}if(!e.allowed.has(a)){i=`${o.name}: ${a===`application/pdf`?lx(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.`):lx(n,`phiên Pi hiện tại không nhận loại file này.`,`the current Pi session does not accept this file type.`)}`;continue}let s=a.startsWith(`image/`)||fx.has(a)?Math.min(t.capabilities.limits.maxAttachmentFileBytes,8388608):262144;if(o.size<1||o.size>s||r.reduce((e,t)=>e+t.sourceBytes,0)+o.size>t.capabilities.limits.maxAttachmentTotalBytes){i=`${o.name}: ${fx.has(a)?lx(n,`vượt giới hạn gửi trực tiếp ${px(s)}. Hãy đặt tài liệu lớn trong project rồi mở ở mục Tài liệu; Pi sẽ đọc theo phần thay vì nhét cả file vào chat.`,`exceeds the ${px(s)} direct-send limit. Put a large document in the project and open Documents; Pi can read it in parts instead of placing the whole file in chat.`):lx(n,`vượt giới hạn đính kèm (tối đa ${px(s)}).`,`attachment limit exceeded (max ${px(s)}).`)}`;continue}let c=new Uint8Array(await o.arrayBuffer()),l=``;for(let e=0;e<c.length;e+=32768)l+=String.fromCharCode(...c.subarray(e,e+32768));let u=await e.stage(await O_(t,e.messageRequestId,{displayName:o.name,declaredMimeType:a,dataBase64:btoa(l)}));if(u.resultCode!==`staged`||!(`attachment`in u)||!u.attachment){i=`${o.name}: ${Q(u.error?.code??u.resultCode,n)}`;continue}r=[...r,u.attachment]}return{attachments:r,status:i}}async function vx(e){let t=await e.stage(k_(e.snapshot,e.messageRequestId,e.attachmentRef));return t.messageType===`discard-receipt`&&t.resultCode===`discarded`?{discarded:!0,status:null}:{discarded:!1,status:`${lx(e.locale,`Chưa thể bỏ file`,`Unable to remove file`)} · ${Q(t.error?.code??t.resultCode,e.locale)}`}}function yx({snapshot:e,events:t,refreshSnapshot:n}){let{locale:r}=xv(),[i,a]=(0,v.useState)(),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(()=>`message-request.${crypto.randomUUID()}`),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),k=(0,v.useRef)(0),A=(0,v.useMemo)(()=>cx(t),[t]),j=[...t].reverse().find(e=>[`message.completed`,`message.failed`,`agent-operation.settled`].includes(String(e.kind)))?.eventCursor??null;(0,v.useEffect)(()=>{let e=new AbortController;return s(!0),a(void 0),c_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0).finally(()=>s(!1)),()=>e.abort()},[e.identity.sessionRef]),(0,v.useEffect)(()=>{w([]),S(`message-request.${crypto.randomUUID()}`)},[e.identity.sessionRef]),(0,v.useEffect)(()=>{let e=e=>{e.dataTransfer&&[...e.dataTransfer.types].includes(`Files`)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]),(0,v.useEffect)(()=>{if(!j)return;let e=new AbortController,t=window.setTimeout(()=>{c_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0)},80);return()=>{window.clearTimeout(t),e.abort()}},[j]);let M=async()=>{try{let e=await l_();return h(e),e}catch{return}};(0,v.useEffect)(()=>{let e=new AbortController;return l_(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[e.identity.sessionRef,e.revision.queueRevision]);let N=async()=>{let e=i?.page.nextBeforeCursor;if(e)try{let t=await c_(e,i.page.limit);a(e=>e?{...e,items:sx(e.items,t.items),page:t.page}:t)}catch{}},P=i?.state===`ready`?i.items:[],F=e.capabilities.capabilities[`control.chat`],I=F.status===`available`?F.actions:null,L=!!I?.send.available,R=e.capabilities.capabilities[`control.resumeAndContinue`].status===`available`,ee=L||R,te=e.capabilities.capabilities.attachments,ne=te.status===`available`,z=(0,v.useMemo)(()=>new Set(te.status===`available`?te.mimeTypes:[]),[te]),B=(0,v.useMemo)(()=>hx(z),[z]),V=ne&&!u&&!T&&C.length<4,re=e.session.operation.liveness===`running`,ie=async()=>{await n?.(),await M()},ae=async t=>{let n=c.trim();if(!(!n||u||(t===`resume-and-continue`?!R:!L))){d(!0),p(null);try{let i=C.length?{messageRequestId:x,attachmentRefs:C.map(e=>e.attachmentRef)}:void 0,a=t===`resume-and-continue`?await g_(await P_(e,n,i)):await p_(await D_(e,n,t,i));[`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(l(``),w([]),S(`message-request.${crypto.randomUUID()}`),p(a.resultCode===`dispatch-observed`?$(r,`Đã gửi vào Pi session`,`Sent to the Pi session`):$(r,`Pi đã nhận yêu cầu`,`Pi received the request`))):a.resultCode===`held`?(l(``),p($(r,`Đã giữ trong hàng đợi`,`Held in the queue`))):a.resultCode===`resumed-not-dispatched`?p($(r,`Task đã mở lại nhưng tin nhắn chưa được gửi; nội dung vẫn được giữ để anh kiểm tra.`,`The task resumed but the message was not sent; the content remains for review.`)):p(`${$(r,`Chưa gửi`,`Not sent`)} · ${Q(a.resultCode,r)}`),await ie()}catch{p($(r,`Không thể gửi; trạng thái Pi có thể đã thay đổi.`,`Unable to send; Pi state may have changed.`))}finally{d(!1)}}},oe=async t=>{if(!(!t?.length||!ne||T)){E(!0),p(null);try{let n=await _x({files:t,snapshot:e,messageRequestId:x,existing:C,allowed:z,locale:r,stage:w_});w(n.attachments),p(n.status)}catch{p($(r,`Không thể đính kèm; file không được gửi vào Pi.`,`Unable to attach the file; it was not sent to Pi.`))}finally{E(!1)}}},se=()=>{k.current=0,O(!1)},H=e=>{gx(e.dataTransfer)&&(e.preventDefault(),se(),V&&oe(e.dataTransfer.files))},ce=async t=>{if(!(u||T)){E(!0),p(null);try{let n=await vx({snapshot:e,messageRequestId:x,attachmentRef:t,locale:r,stage:w_});n.discarded?w(e=>e.filter(e=>e.attachmentRef!==t)):p(n.status)}catch{p($(r,`Không thể bỏ file; trạng thái Pi có thể đã thay đổi.`,`Unable to remove the file; Pi state may have changed.`))}finally{E(!1)}}},le=async(t,n,i)=>{if(!u){d(!0),p(null);try{let a=await p_(await A_(e,t,t===`queue.update`?await j_(n,i?.trim()??``):t===`queue.delete`?{queueItemRef:n}:{queueItemRef:n,messageRequestId:`message-request.${crypto.randomUUID()}`}));[`updated`,`deleted`,`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(_(null),b(``),p(Q(a.resultCode,r))):p(`${$(r,`Chưa thay đổi`,`Not changed`)} · ${Q(a.resultCode,r)}`),await ie()}catch{p($(r,`Hàng đợi đã thay đổi; đã tải lại trạng thái mới nhất.`,`The queue changed; the latest state has been reloaded.`)),await ie()}finally{d(!1)}}};return(0,W.jsxs)(`section`,{className:`chat-panel surface`,"aria-labelledby":`chat-heading`,"data-dragging":D||void 0,onDragEnter:e=>{gx(e.dataTransfer)&&(k.current+=1,O(!0))},onDragOver:e=>{gx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=V?`copy`:`none`)},onDragLeave:e=>{gx(e.dataTransfer)&&(--k.current,k.current<=0&&se())},onDrop:H,children:[D&&(0,W.jsxs)(`div`,{className:`chat-drop-overlay`,role:`status`,children:[(0,W.jsx)(`strong`,{children:V?$(r,`Thả tài liệu vào đây`,`Drop documents here`):C.length>=4?$(r,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):$(r,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),V&&(0,W.jsx)(`small`,{children:$(r,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),(0,W.jsxs)(`header`,{className:`chat-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Đúng Pi session hiện tại`,`Exact current Pi session`)}),(0,W.jsx)(`h2`,{id:`chat-heading`,children:`Chat`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{children:[P.length,` `,$(r,`message gần nhất`,`recent messages`)]}),(0,W.jsx)(`span`,{className:`chat-read-state`,children:$(r,`Streaming trực tiếp`,`Live streaming`)})]})]}),(0,W.jsxs)(`div`,{className:`chat-body`,"aria-live":`polite`,children:[i?.page.hasOlder&&(0,W.jsx)(`button`,{type:`button`,className:`load-older`,onClick:()=>void N(),children:$(r,`Tải message cũ hơn`,`Load older messages`)}),o&&(0,W.jsx)(`p`,{className:`chat-empty`,children:$(r,`Đang tải transcript hiện tại…`,`Loading the current transcript…`)}),!o&&i?.state===`unavailable`&&(0,W.jsxs)(`p`,{className:`chat-empty`,children:[$(r,`Transcript cần đồng bộ lại`,`Transcript needs resync`),` · `,Q(i.reasonCode,r)]}),!o&&i?.state===`ready`&&P.length===0&&A.assistants.length===0&&(0,W.jsx)(`p`,{className:`chat-empty`,children:$(r,`Chưa có message trong Pi session này.`,`There are no messages in this Pi session.`)}),P.map(e=>e.role===`tool-result`?(0,W.jsxs)(`article`,{className:`chat-tool-result`,children:[(0,W.jsx)(`strong`,{children:e.toolCalls[0]?.toolName??`Tool`}),(0,W.jsx)(`span`,{children:$(r,`Kết quả chi tiết nằm trong Activity`,`Detailed output is available in Activity`)})]},e.messageRef):(0,W.jsxs)(`article`,{className:`chat-message chat-${e.role}`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.role===`user`?$(r,`Anh`,`You`):`Pi`}),(0,W.jsx)(`time`,{children:new Date(e.recordedAt).toLocaleTimeString(r===`vi`?`vi-VN`:`en-US`,{hour:`2-digit`,minute:`2-digit`})})]}),(0,W.jsx)(`p`,{children:e.content.text||(e.content.imageCount?`${e.content.imageCount} ${$(r,`ảnh đính kèm`,`attached images`)}`:$(r,`Message trống`,`Empty message`))}),(e.content.redacted||e.content.truncated)&&(0,W.jsx)(`small`,{children:e.content.redacted?$(r,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`):$(r,`Nội dung đã rút gọn`,`Content truncated`)})]},e.messageRef)),A.assistants.map(e=>(0,W.jsxs)(`article`,{className:`chat-message chat-assistant chat-streaming`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Pi`}),(0,W.jsx)(`span`,{className:`stream-indicator`,children:$(r,`Đang trả lời`,`Responding`)})]}),(0,W.jsx)(`p`,{children:e.text||(e.thinking?$(r,`Đang suy nghĩ…`,`Thinking…`):$(r,`Đang chuẩn bị câu trả lời…`,`Preparing a response…`))}),e.truncated&&(0,W.jsx)(`small`,{children:$(r,`Live preview đã đạt giới hạn`,`Live preview limit reached`)})]},e.messageRef)),A.tools.filter(e=>[`started`,`progress`].includes(e.state)).map(e=>(0,W.jsxs)(`article`,{className:`chat-tool-live`,children:[(0,W.jsx)(`span`,{className:`tool-spinner`,"aria-hidden":`true`}),(0,W.jsx)(`strong`,{children:e.toolName}),(0,W.jsx)(`span`,{children:Q(e.state,r)})]},e.toolCallId))]}),m?.state===`ready`&&m.items.length>0&&(0,W.jsxs)(`section`,{className:`held-queue`,"aria-label":$(r,`Tin nhắn đang giữ`,`Held messages`),children:[(0,W.jsxs)(`div`,{className:`held-queue-heading`,children:[(0,W.jsx)(`strong`,{children:$(r,`Đang giữ ${m.heldCount} tin`,`${m.heldCount} held messages`)}),m.quarantinedCount>0&&(0,W.jsxs)(`span`,{children:[m.quarantinedCount,` `,$(r,`tin cần kiểm tra`,`need review`)]})]}),(0,W.jsx)(`ol`,{children:m.items.map(e=>(0,W.jsxs)(`li`,{"data-state":e.state,children:[g===e.queueItemRef?(0,W.jsx)(`textarea`,{"aria-label":$(r,`Sửa tin nhắn đang giữ`,`Edit held message`),rows:2,maxLength:65536,value:y,onChange:e=>b(e.target.value)}):(0,W.jsx)(`p`,{children:e.preview}),(0,W.jsx)(`div`,{children:g===e.queueItemRef?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,disabled:u||!y.trim(),onClick:()=>void le(`queue.update`,e.queueItemRef,y),children:$(r,`Lưu`,`Save`)}),(0,W.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{_(null),b(``)},children:$(r,`Hủy`,`Cancel`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||!I?.dispatchHeld.available,onClick:()=>void le(`queue.dispatch`,e.queueItemRef),children:$(r,`Gửi`,`Send`)}),(0,W.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||e.redacted||e.truncated||!I?.editHeld.available,title:e.redacted||e.truncated?$(r,`Không sửa từ preview đã che hoặc rút gọn`,`Redacted or truncated previews cannot be edited`):void 0,onClick:()=>{_(e.queueItemRef),b(e.preview)},children:$(r,`Sửa`,`Edit`)}),(0,W.jsx)(`button`,{type:`button`,disabled:u||!I?.deleteHeld.available,onClick:()=>void le(`queue.delete`,e.queueItemRef),children:$(r,`Xóa`,`Delete`)})]})}),(e.redacted||e.truncated||e.state===`quarantined`)&&(0,W.jsx)(`small`,{children:e.state===`quarantined`?$(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?$(r,`Preview đã che dữ liệu nhạy cảm`,`Sensitive data is redacted in the preview`):$(r,`Preview đã rút gọn`,`Preview truncated`)})]},e.queueItemRef))})]}),(0,W.jsxs)(`footer`,{className:`chat-composer-preview`,children:[C.length>0&&(0,W.jsx)(`ul`,{className:`attachment-list`,"aria-label":$(r,`File sẽ gửi cùng message`,`Files to send with the message`),children:C.map(e=>(0,W.jsxs)(`li`,{"data-kind":e.kind,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.displayName}),(0,W.jsx)(`small`,{children:mx(e,r)})]}),(0,W.jsx)(`button`,{type:`button`,disabled:u||T,"aria-label":`${$(r,`Bỏ`,`Remove`)} ${e.displayName}`,onClick:()=>void ce(e.attachmentRef),children:$(r,`Bỏ`,`Remove`)})]},e.attachmentRef))}),(0,W.jsx)(`textarea`,{"aria-label":$(r,`Nội dung chat`,`Chat message`),placeholder:R?$(r,`Nhập việc cần Pi làm ngay sau khi mở lại task…`,`Enter work for Pi immediately after the task resumes…`):L?$(r,`Nhắn vào đúng Pi session này…`,`Message this exact Pi session…`):$(r,`Chat control chưa khả dụng.`,`Chat control is unavailable.`),disabled:!ee||u,maxLength:65536,rows:2,value:c,onChange:e=>l(e.target.value),onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),V&&oe(e.clipboardData.files))}}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:!ee||u||!c.trim(),onClick:()=>void ae(R?`resume-and-continue`:re?`follow-up`:`new-operation`),children:u?$(r,`Đang gửi…`,`Sending…`):R?$(r,`Tiếp tục & gửi`,`Resume & send`):re?$(r,`Gửi sau`,`Send next`):$(r,`Gửi`,`Send`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!L||u||!c.trim()||C.length>0||!I?.hold.available,title:C.length?$(r,`Bản này chưa giữ file trong hàng đợi`,`This version does not hold attachments in the queue`):void 0,onClick:()=>void ae(`hold`),children:$(r,`Giữ lại`,`Hold`)}),re&&(0,W.jsx)(`button`,{type:`button`,className:`interrupt-send`,disabled:!L||u||!c.trim()||!I?.interruptAndSend.available,onClick:()=>void ae(`steer`),children:$(r,`Ngắt & gửi`,`Interrupt & send`)})]}),(0,W.jsxs)(`label`,{className:`attachment-picker ${V?``:`disabled`}`,title:$(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,W.jsx)(`input`,{type:`file`,multiple:!0,disabled:!V,accept:B||void 0,onChange:e=>{oe(e.target.files),e.currentTarget.value=``}}),T?$(r,`Đang đọc tài liệu…`,`Reading documents…`):`${$(r,`Đính kèm hoặc kéo thả`,`Attach or drop`)} (${C.length}/4)`]}),f&&(0,W.jsx)(`small`,{role:`status`,children:f})]})]})}function bx({snapshot:e,refreshSnapshot:t}){let{locale:n}=xv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(0),g=(0,v.useRef)({revision:0,modelDirty:!1,thinkingDirty:!1}),_=e.capabilities.capabilities[`control.sessionOptions`],y=_.status===`available`?_.actions:null,b=async e=>{let t=++h.current,n=g.current.revision;try{let r=await u_(e);return t===h.current?(i(r),r.state===`ready`&&n===g.current.revision&&(g.current.modelDirty||o(r.activeModelRef??``),g.current.thinkingDirty||c(r.activeThinkingLevel??`off`)),r):r}catch{!e?.aborted&&t===h.current&&i(void 0);return}};(0,v.useEffect)(()=>{let e=new AbortController;return b(e.signal),()=>e.abort()},[e.identity.sessionRef,e.revision.sessionOptionRevision]);let x=(0,v.useMemo)(()=>r?.models.find(e=>e.modelRef===r.activeModelRef),[r]),S=async i=>{if(!l||d||!r||r.state!==`ready`)return;let o=i===`model`?`session-options.set-model`:`session-options.set-thinking`,c=i===`model`?a:s;f(i),m(null);try{let r=await m_(await M_(e,o,c));m(r.resultCode===`changed`?$(n,`Đã cập nhật trong Pi và mặc định người dùng`,`Updated in Pi and user defaults`):r.resultCode===`unchanged`?$(n,`Giá trị này đang được dùng`,`This value is already active`):r.resultCode===`effect-unknown`?$(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`):`${$(n,`Chưa thay đổi`,`Not changed`)} · ${Q(r.resultCode,n)}`),u(!1),g.current.revision+=1,i===`model`?g.current.modelDirty=!1:g.current.thinkingDirty=!1,await t?.(),await b()}catch{m($(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,W.jsxs)(`section`,{className:`session-options surface`,"aria-labelledby":`session-options-title`,children:[(0,W.jsxs)(`div`,{className:`session-options-copy`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Model & thinking`}),(0,W.jsx)(`h2`,{id:`session-options-title`,children:$(n,`Thiết lập cho Pi session`,`Pi session settings`)}),(0,W.jsx)(`p`,{children:$(n,`Chỉ thay đổi khi Pi đang chờ. Thao tác này không gọi model, nhưng Pi 0.84.1 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 0.84.1 also updates user defaults.`)})]}),r?.state===`ready`?(0,W.jsxs)(`div`,{className:`session-options-controls`,children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:`Model`}),(0,W.jsx)(`select`,{"aria-label":$(n,`Chọn model`,`Select model`),value:a,disabled:d!==null||!y?.setModel.available,onChange:e=>{g.current.revision+=1,g.current.modelDirty=!0,o(e.target.value),u(!1),m(null)},children:r.models.map(e=>(0,W.jsxs)(`option`,{value:e.modelRef,children:[e.displayName,` · `,e.provider]},e.modelRef))})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:`Thinking`}),(0,W.jsx)(`select`,{"aria-label":$(n,`Chọn thinking`,`Select thinking`),value:s,disabled:d!==null||!y?.setThinking.available,onChange:e=>{g.current.revision+=1,g.current.thinkingDirty=!0,c(e.target.value),u(!1),m(null)},children:(x?.supportedThinkingLevels??[]).map(e=>(0,W.jsx)(`option`,{value:e,children:Q(e,n)},e))})]}),(0,W.jsxs)(`label`,{className:`effect-ack`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:l,disabled:d!==null||!y,onChange:e=>u(e.target.checked)}),(0,W.jsx)(`span`,{children:$(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,W.jsxs)(`div`,{className:`session-option-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setModel.available||a===r.activeModelRef,onClick:()=>void S(`model`),children:d===`model`?$(n,`Đang đổi…`,`Changing…`):$(n,`Đổi model`,`Change model`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setThinking.available||s===r.activeThinkingLevel,onClick:()=>void S(`thinking`),children:d===`thinking`?$(n,`Đang đổi…`,`Changing…`):$(n,`Đổi thinking`,`Change thinking`)})]}),p&&(0,W.jsx)(`small`,{role:`status`,children:p}),!y?.setModel.available&&(0,W.jsxs)(`small`,{children:[$(n,`Đang khóa thay đổi`,`Changes locked`),` · `,Q(y?.setModel.reasonCode??(_.status===`unavailable`?_.reason?.code:`unavailable`),n)]})]}):(0,W.jsxs)(`div`,{className:`session-options-unavailable`,children:[(0,W.jsx)(`strong`,{children:$(n,`Catalog model chưa sẵn sàng`,`Model catalog unavailable`)}),(0,W.jsx)(`span`,{children:Q(r?.reasonCode??`authenticated-model-catalog-unavailable`,n)})]})]})}function xx(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 Sx({state:e,setState:t,refreshSnapshot:n,locale:r}){let i=e.request;if(!i)return(0,W.jsx)(`article`,{className:`approval-card`,children:(0,W.jsx)(`p`,{children:e.error??$(r,`Đang tải yêu cầu phê duyệt…`,`Loading approval request…`)})});let a=i.action,o=Math.max(0,Math.ceil((Date.parse(i.expiresAt)-Date.now())/1e3)),s=async e=>{t({request:i,deciding:e});try{await f_(xx(i,e)),await n?.()}catch{t({request:i,error:$(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,W.jsxs)(`article`,{className:`approval-card risk-${a.riskClass}`,"aria-labelledby":`approval-${i.approvalRef}`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Cần anh phê duyệt`,`Approval required`)}),(0,W.jsx)(`h2`,{id:`approval-${i.approvalRef}`,children:a.toolName})]}),(0,W.jsx)(`span`,{className:`approval-risk`,children:Q(a.riskClass,r)})]}),(0,W.jsx)(`p`,{className:`approval-reason`,children:a.reason}),a.commandPreview&&(0,W.jsx)(`pre`,{className:`approval-preview`,children:(0,W.jsx)(`code`,{children:a.commandPreview})}),!a.commandPreview&&a.parameterPreview&&(0,W.jsx)(`p`,{className:`approval-preview`,children:a.parameterPreview}),(0,W.jsxs)(`dl`,{className:`approval-facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Hành động`,`Action`)}),(0,W.jsx)(`dd`,{children:Q(a.kind,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Phạm vi`,`Scope`)}),(0,W.jsx)(`dd`,{children:Q(a.requestedScope,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Thư mục`,`Directory`)}),(0,W.jsx)(`dd`,{children:a.cwdDisplay??$(r,`Đã ẩn`,`Hidden`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Hết hạn`,`Expires`)}),(0,W.jsxs)(`dd`,{children:[o,`s`]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Task`}),(0,W.jsxs)(`dd`,{children:[pv(i.identity.taskId),` · `,pv(i.identity.taskRunId)]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Tool call`}),(0,W.jsx)(`dd`,{children:pv(i.identity.toolCallId)})]})]}),a.targetPaths.length>0&&(0,W.jsxs)(`div`,{className:`approval-targets`,children:[(0,W.jsx)(`strong`,{children:$(r,`Đích tác động`,`Targets`)}),(0,W.jsx)(`ul`,{children:a.targetPaths.map(e=>(0,W.jsx)(`li`,{children:e},e))})]}),a.providerRef&&(0,W.jsxs)(`p`,{className:`approval-targets`,children:[(0,W.jsx)(`strong`,{children:`Provider:`}),` `,pv(a.providerRef)]}),(0,W.jsxs)(`div`,{className:`approval-consequences`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:$(r,`Nếu cho phép:`,`If allowed:`)}),` `,a.consequences.allow]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:$(r,`Nếu từ chối:`,`If denied:`)}),` `,a.consequences.deny]})]}),e.error&&(0,W.jsx)(`p`,{className:`form-error`,role:`alert`,children:e.error}),(0,W.jsxs)(`footer`,{children:[(0,W.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!e.deciding,onClick:()=>void s(`deny`),children:$(r,`Từ chối`,`Deny`)}),(0,W.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:!!e.deciding,onClick:()=>void s(`allow`),children:e.deciding===`allow`?$(r,`Đang kiểm tra lại…`,`Rechecking…`):$(r,`Cho phép đúng 1 lần`,`Allow once`)})]})]})}function Cx({approvalRefs:e,sessionRef:t,refreshSnapshot:n}){let{locale:r}=xv(),i=(0,v.useMemo)(()=>e,[e.join(`\0`)]),[a,o]=(0,v.useState)({});return(0,v.useEffect)(()=>{let e=new AbortController;for(let n of i)(t?Ig(t,n,e.signal):d_(n,e.signal)).then(e=>o(t=>({...t,[n]:{request:e}})),()=>o(e=>({...e,[n]:{error:$(r,`Không thể tải yêu cầu phê duyệt hiện tại.`,`Unable to load the current approval request.`)}})));return()=>e.abort()},[r,t,i]),i.length===0?null:(0,W.jsx)(`section`,{className:`approval-stack`,"aria-label":$(r,`Yêu cầu phê duyệt đang chờ`,`Pending approval requests`),"aria-live":`polite`,children:i.map(e=>(0,W.jsx)(Sx,{state:a[e]??{},setState:t=>o(n=>({...n,[e]:t})),refreshSnapshot:n,locale:r},e))})}function wx({snapshot:e,refreshSnapshot:t}){let n=(0,v.useMemo)(()=>e.approvals.pending.map(e=>e.approvalRef),[e.approvals.pending]);return(0,W.jsx)(Cx,{approvalRefs:n,refreshSnapshot:t})}var Tx={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.`},Ex={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 Dx(e,t){return(t===`vi`?Tx:Ex)[e.resultCode]??(e.error?.message||`${$(t,`Chưa thực hiện`,`Not executed`)} · ${Q(e.resultCode,t)}`)}function Ox({snapshot:e,refreshSnapshot:t}){let{locale:n}=xv(),r=e.capabilities.capabilities[`control.lifecycle`],[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=r.status===`available`,l=c?r.currentPhase:`unknown`,u=c?r.stopPhaseSupport[l]:null,d=!!(u?.stop===`supported`&&e.identity.agentOperationId),f=!!(c&&r.actions.pause.available),p=!!(c&&r.actions.resume.available);(0,v.useEffect)(()=>{o?.resultCode===`pause-requested`&&e.session.controlState===`paused`&&s({action:`lifecycle.pause`,resultCode:`paused`,text:(n===`vi`?Tx:Ex).paused}),o?.resultCode===`stop-requested`&&e.session.operation.liveness===`idle`&&s({action:`lifecycle.stop`,resultCode:`stopped`,text:(n===`vi`?Tx:Ex).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 h_(await N_(e,r));s({action:r,resultCode:i.resultCode,text:Dx(i,n)}),await t?.()}catch{s({action:r,resultCode:`request-failed`,text:$(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,W.jsxs)(`section`,{className:`lifecycle-panel surface`,"aria-labelledby":`lifecycle-title`,children:[(0,W.jsxs)(`div`,{className:`lifecycle-copy`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(n,`Điều khiển task`,`Task controls`)}),(0,W.jsx)(`h2`,{id:`lifecycle-title`,children:`Stop, pause & resume`}),(0,W.jsx)(`p`,{children:$(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,W.jsxs)(`div`,{className:`lifecycle-state`,children:[(0,W.jsx)(`span`,{children:$(n,`Trạng thái`,`Status`)}),(0,W.jsx)(`strong`,{children:Q(e.session.controlState,n)}),(0,W.jsxs)(`small`,{children:[`Pi: `,Q(e.session.operation.liveness,n),` · phase: `,Q(l,n)]})]}),(0,W.jsxs)(`div`,{className:`lifecycle-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:i!==null||!d,onClick:()=>void m(`lifecycle.stop`),title:d?void 0:Q(u?.reasonCode??`no-current-operation`,n),children:i===`lifecycle.stop`?$(n,`Đang dừng…`,`Stopping…`):$(n,`Dừng lượt hiện tại`,`Stop current turn`)}),(0,W.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:i!==null||!f,onClick:()=>void m(`lifecycle.pause`),title:!f&&c?Q(r.actions.pause.reasonCode,n):void 0,children:i===`lifecycle.pause`?$(n,`Đang yêu cầu…`,`Requesting…`):$(n,`Tạm dừng task`,`Pause task`)}),(0,W.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:i!==null||!p,onClick:()=>void m(`lifecycle.resume`),title:!p&&c?Q(r.actions.resume.reasonCode,n):void 0,children:i===`lifecycle.resume`?$(n,`Đang mở lại…`,`Resuming…`):$(n,`Tiếp tục task`,`Resume task`)})]}),o&&(0,W.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,W.jsxs)(`p`,{className:`lifecycle-result result-warning`,children:[$(n,`Điều khiển chưa sẵn sàng`,`Controls unavailable`),` · `,Q(r.reason?.code,n)]})]})}function kx(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 Ax({value:e,locale:t}){return(0,W.jsxs)(`span`,{className:`status-pill tone-${fv(e)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Q(e,t)]})}function jx({snapshot:e}){let{locale:t}=xv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),[o,s]=(0,v.useState)(`all`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(),[f,p]=(0,v.useState)(`idle`),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(`idle`),[y,b]=(0,v.useState)(),[x,S]=(0,v.useState)(`idle`),[C,w]=(0,v.useState)(),[T,E]=(0,v.useState)(`idle`);(0,v.useEffect)(()=>{let e=new AbortController;return a(`loading`),t_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`),l(e=>e&&t.runs.some(t=>t.runRef===e)?e:t.activeRunRef??t.runs[0]?.runRef??null))}).catch(()=>{e.signal.aborted||a(`error`)}),()=>e.abort()},[e.revision.taskRevision,e.revision.eventCursor]);let D=(0,v.useMemo)(()=>(n?.runs??[]).filter(e=>o===`all`||o===`current`&&e.isCurrentSession||o===`terminal`&&e.terminal),[n,o]);return(0,v.useEffect)(()=>{if(!c){d(void 0),p(`idle`);return}let e=new AbortController;return p(`loading`),n_(c,e.signal).then(t=>{e.signal.aborted||(d(t),p(`ready`))}).catch(()=>{e.signal.aborted||p(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){b(void 0),S(`idle`);return}let e=new AbortController;return S(`loading`),i_(c,e.signal).then(t=>{e.signal.aborted||(b(t),S(`ready`))}).catch(()=>{e.signal.aborted||S(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){h(void 0),_(`idle`);return}let e=new AbortController;return _(`loading`),r_(c,e.signal).then(t=>{e.signal.aborted||(h(t),_(`ready`))}).catch(()=>{e.signal.aborted||_(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){w(void 0),E(`idle`);return}let e=new AbortController;return E(`loading`),a_(c,e.signal).then(t=>{e.signal.aborted||(w(t),E(`ready`))}).catch(()=>{e.signal.aborted||E(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,W.jsxs)(`section`,{className:`task-run-index surface`,"aria-labelledby":`task-run-index-title`,children:[(0,W.jsxs)(`header`,{className:`source-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Long-task dashboard`}),(0,W.jsx)(`h2`,{id:`task-run-index-title`,children:$(t,`Task và các lần chạy gần đây`,`Tasks and recent runs`)})]}),(0,W.jsxs)(`span`,{children:[n?.page.total??0,` `,$(t,`run từ local state`,`runs from local state`)]})]}),(0,W.jsx)(`div`,{className:`task-index-controls`,role:`group`,"aria-label":$(t,`Lọc task run`,`Filter task runs`),children:[[`all`,$(t,`Tất cả`,`All`)],[`current`,$(t,`Session này`,`This session`)],[`terminal`,$(t,`Đã kết thúc`,`Finished`)]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>s(e),children:t},e))}),i===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang đọc task state bền vững…`,`Reading durable task state…`)}),(i===`error`||n?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsxs)(`div`,{className:`task-run-list`,children:[D.map(e=>(0,W.jsxs)(`article`,{className:`task-run-card`,"data-active":e.isActive,"data-selected":e.runRef===c,children:[(0,W.jsxs)(`div`,{className:`task-run-main`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.summary||e.taskId}),e.isActive&&(0,W.jsx)(`span`,{className:`active-run-tag`,children:$(t,`Đang hoạt động`,`Active`)})]}),(0,W.jsxs)(`small`,{children:[e.taskId,` · `,$(t,`lần`,`attempt`),` `,e.attempt,`/`,e.maxAttempts,` · `,$(t,`cập nhật`,`updated`),` `,kx(e.updatedAt,t)]})]}),(0,W.jsxs)(`div`,{className:`task-run-meta`,children:[(0,W.jsx)(Ax,{value:e.outcome,locale:t}),(0,W.jsx)(`span`,{children:e.progress.total?`${e.progress.completed}/${e.progress.total} ${$(t,`bước`,`steps`)}`:$(t,`Chưa có work plan`,`No work plan`)}),(0,W.jsx)(`span`,{children:e.sessionLabel??(e.isCurrentSession?$(t,`Session hiện tại`,`Current session`):$(t,`Session khác`,`Other session`))}),(0,W.jsx)(`button`,{type:`button`,"aria-pressed":e.runRef===c,onClick:()=>l(e.runRef),children:$(t,`Xem timeline`,`View timeline`)})]})]},e.runRef)),D.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Không có task run trong bộ lọc này.`,`No task runs match this filter.`)})]}),n?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n?.page.truncated&&(0,W.jsxs)(`p`,{className:`task-index-warning`,children:[$(t,`Danh sách đã rút gọn;`,`The list is truncated;`),` `,n.page.total-n.page.returned,` `,$(t,`run cũ chưa hiển thị.`,`older runs are not shown.`)]}),(0,W.jsxs)(`section`,{className:`task-timeline`,"aria-labelledby":`task-timeline-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Recovery timeline`}),(0,W.jsx)(`h3`,{id:`task-timeline-title`,children:$(t,`Crash, resume, pause và checkpoint`,`Crash, resume, pause, and checkpoints`)})]}),u?.state===`ready`&&(0,W.jsx)(Ax,{value:u.continuity.recoveryDecision,locale:t})]}),f===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem timeline.`,`Select a run to view its timeline.`)}),f===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh chuỗi Task Journal…`,`Verifying the Task Journal chain…`)}),(f===`error`||u?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`timeline-continuity`,children:[(0,W.jsxs)(`span`,{children:[`Crash evidence: `,(0,W.jsx)(`strong`,{children:Q(u.continuity.crashEvidence,t)})]}),(0,W.jsxs)(`span`,{children:[`Recovery: `,(0,W.jsx)(`strong`,{children:Q(u.continuity.recoveryDecision,t)})]})]}),(0,W.jsx)(`ol`,{className:`timeline-events`,children:u.events.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.state)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.title}),(0,W.jsxs)(`small`,{children:[`#`,e.sequence,` · `,kx(e.recordedAt,t)]}),e.detail&&(0,W.jsx)(`p`,{children:e.detail})]}),(0,W.jsx)(Ax,{value:e.state,locale:t})]},e.eventRef))}),u.events.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(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,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,W.jsxs)(`section`,{className:`task-timeline recovery-history`,"aria-labelledby":`recovery-history-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Compaction & recovery`}),(0,W.jsx)(`h3`,{id:`recovery-history-title`,children:$(t,`Lịch sử rút gọn và phục hồi`,`Compaction and recovery history`)})]}),m?.state===`ready`&&(0,W.jsx)(Ax,{value:m.completeness,locale:t})]}),g===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem lịch sử rút gọn.`,`Select a run to view compaction history.`)}),g===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang đọc metadata compaction an toàn…`,`Reading safe compaction metadata…`)}),(g===`error`||m?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`timeline-continuity recovery-summary`,children:[(0,W.jsxs)(`span`,{children:[`Context compact: `,(0,W.jsx)(`strong`,{children:m.summary.contextCompactions})]}),(0,W.jsxs)(`span`,{children:[`Tool result: `,(0,W.jsx)(`strong`,{children:m.summary.toolResultCompactions})]}),(0,W.jsxs)(`span`,{children:[`Recovery: `,(0,W.jsx)(`strong`,{children:Q(m.recovery.decision,t)})]}),(0,W.jsxs)(`span`,{children:[`Verifier: `,(0,W.jsx)(`strong`,{children:Q(m.recovery.verifierState,t)})]})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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,W.jsx)(`ol`,{className:`timeline-events`,children:m.events.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.kind)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.title}),(0,W.jsxs)(`small`,{children:[`#`,e.sequence,` · `,kx(e.recordedAt,t)]}),e.kind===`tool-result-compaction`&&(0,W.jsxs)(`p`,{children:[e.toolName,` · `,e.originalLines??`?`,` `,$(t,`dòng`,`lines`),` · `,e.captureCount,` capture`]}),e.detail&&(0,W.jsx)(`p`,{children:e.detail})]}),(0,W.jsx)(Ax,{value:`observed`,locale:t})]},e.eventRef))}),m.events.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Run này chưa có metadata compaction đã quan sát.`,`This run has no observed compaction metadata.`)})]}),m?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,W.jsxs)(`section`,{className:`task-timeline handoff-history`,"aria-labelledby":`handoff-history-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Handoff`}),(0,W.jsx)(`h3`,{id:`handoff-history-title`,children:$(t,`Bàn giao và việc cần làm tiếp theo`,`Handoff and next work`)})]}),y?.state===`ready`&&(0,W.jsx)(Ax,{value:y.completeness,locale:t})]}),x===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem handoff.`,`Select a run to view its handoff.`)}),x===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh handoff và next action…`,`Verifying the handoff and next action…`)}),(x===`error`||y?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(t,`Handoff không đủ bằng chứng tin cậy; WebUI không đề xuất hành động.`,`The handoff lacks trustworthy evidence; WebUI will not suggest an action.`)}),x===`ready`&&y?.state===`ready`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`next-action-card`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:$(t,`Việc tiếp theo`,`Next work`)}),(0,W.jsx)(`strong`,{children:Q(y.nextAction.action,t)})]}),(0,W.jsx)(`p`,{children:y.nextAction.reason}),(0,W.jsxs)(`small`,{children:[y.nextAction.exactCommandCount,` verifier command · `,$(t,`chỉ xem, không tự chạy`,`read-only, never auto-run`)]})]}),y.current&&(0,W.jsxs)(`div`,{className:`timeline-continuity handoff-summary`,children:[(0,W.jsxs)(`span`,{children:[`Outcome: `,(0,W.jsx)(`strong`,{children:Q(y.current.taskOutcome,t)})]}),(0,W.jsxs)(`span`,{children:[`Gate: `,(0,W.jsx)(`strong`,{children:Q(y.current.gateDecision,t)})]}),(0,W.jsxs)(`span`,{children:[`Authority: `,(0,W.jsx)(`strong`,{children:Q(y.current.requiredAuthority,t)})]}),(0,W.jsxs)(`span`,{children:[`Tree evidence: `,(0,W.jsx)(`strong`,{children:y.current.treeEvidenceCurrent?`current`:`not current`})]})]}),(0,W.jsx)(`ol`,{className:`timeline-events`,children:y.events.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.completionApproved?`completed`:`handoff`)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:$(t,`Handoff projection đã được ghi`,`Handoff projection recorded`)}),(0,W.jsxs)(`small`,{children:[`#`,e.sequence,` · `,kx(e.recordedAt,t)]}),(0,W.jsxs)(`p`,{children:[e.phase??`unknown`,` · `,Q(e.projectedAction,t)]})]}),(0,W.jsx)(Ax,{value:e.completionApproved?`completed`:`observed`,locale:t})]},e.eventRef))}),!y.current&&y.events.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Run này chưa có handoff đã quan sát.`,`This run has no observed handoff.`)})]}),y?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,W.jsxs)(`section`,{className:`task-timeline subagent-tree`,"aria-labelledby":`subagent-tree-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Helper / subagent tree`}),(0,W.jsx)(`h3`,{id:`subagent-tree-title`,children:$(t,`Quyền sở hữu và vòng đời helper`,`Helper ownership and lifecycle`)})]}),C?.state===`ready`&&(0,W.jsx)(Ax,{value:C.evidenceState,locale:t})]}),T===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem helper/subagent.`,`Select a run to view helpers and subagents.`)}),T===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh helper ledger bền vững…`,`Verifying the durable helper ledger…`)}),(T===`error`||C?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(t,`Helper ledger không đủ tin cậy; WebUI không suy đoán cây subagent.`,`The helper ledger lacks trustworthy evidence; WebUI will not infer a subagent tree.`)}),T===`ready`&&C?.state===`ready`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`timeline-continuity subagent-summary`,children:[(0,W.jsxs)(`span`,{children:[$(t,`Tổng helper`,`Total helpers`),`: `,(0,W.jsx)(`strong`,{children:C.summary.total})]}),(0,W.jsxs)(`span`,{children:[$(t,`Đang chạy`,`Running`),`: `,(0,W.jsx)(`strong`,{children:C.summary.active})]}),(0,W.jsxs)(`span`,{children:[$(t,`Kết quả stale`,`Stale results`),`: `,(0,W.jsx)(`strong`,{children:C.summary.staleResults})]}),(0,W.jsxs)(`span`,{children:[$(t,`Writer hiện tại`,`Current writer`),`: `,(0,W.jsx)(`strong`,{children:Q(C.writer.state,t)})]})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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,W.jsx)(`ol`,{className:`timeline-events`,children:C.children.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.lifecycleState)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[Q(e.role,t),` · `,Q(e.authority,t)]}),(0,W.jsxs)(`small`,{children:[kx(e.reservedAt,t),` → `,e.completedAt?kx(e.completedAt,t):$(t,`đang giữ lease`,`lease active`)]}),(0,W.jsxs)(`p`,{children:[e.result.disposition?Q(e.result.disposition,t):$(t,`Chưa có result evidence`,`No result evidence`),e.result.calls===null?``:` · ${e.result.calls} calls · ${e.result.tokens??0} tokens`]})]}),(0,W.jsx)(Ax,{value:e.result.state===`not-recorded`?e.lifecycleState:e.result.state,locale:t})]},e.nodeRef))}),C.children.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Không có lifecycle helper chi tiết cho run này.`,`No detailed helper lifecycle is available for this run.`)}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(t,`Cây lồng nhiều tầng: chưa có durable lineage; WebUI chỉ hiển thị quan hệ task cha → helper trực tiếp.`,`Nested trees: durable lineage is not yet available, so WebUI only shows parent task → direct helper relationships.`)})]}),C?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]})]})}function Mx(e,t){if(!e)return $(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 Nx({value:e,locale:t}){return(0,W.jsxs)(`span`,{className:`status-pill tone-${fv(e)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Q(e,t)]})}function Px({snapshot:e}){let{locale:t}=xv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{o.current?.abort();let e=new AbortController;o.current=e,a(`loading`),o_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`))}).catch(()=>{e.signal.aborted||a(`error`)})},[]);return(0,v.useEffect)(()=>(s(),()=>o.current?.abort()),[s,e.identity.projectRef,e.identity.runtimeInstanceId]),(0,W.jsxs)(`section`,{className:`release-monitor surface`,"aria-labelledby":`release-monitor-title`,children:[(0,W.jsxs)(`header`,{className:`source-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Benchmark & release`}),(0,W.jsx)(`h2`,{id:`release-monitor-title`,children:$(t,`Theo dõi chất lượng và mức sẵn sàng phát hành`,`Quality and release readiness`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,children:i===`loading`?$(t,`Đang đọc…`,`Loading…`):$(t,`Làm mới`,`Refresh`)})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh report, manifest và ledger…`,`Verifying reports, manifests, and ledgers…`)}),n&&(0,W.jsxs)(`div`,{className:`release-monitor-grid`,children:[(0,W.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`benchmark-monitor-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Benchmark runs`}),(0,W.jsx)(`h3`,{id:`benchmark-monitor-title`,children:$(t,`Các lần đo gần đây`,`Recent runs`)})]}),(0,W.jsx)(Nx,{value:n.benchmark.state,locale:t})]}),n.benchmark.runs.map(e=>(0,W.jsxs)(`article`,{className:`benchmark-run-card`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.suiteId}),(0,W.jsx)(Nx,{value:e.lifecycle,locale:t})]}),(0,W.jsxs)(`small`,{children:[Mx(e.updatedAt,t),` · `,e.completedRuns,`/`,e.expectedRuns,` `,$(t,`lượt`,`runs`),` · `,$(t,`nguồn`,`source`),` `,Q(e.sourceState,t)]}),(0,W.jsxs)(`div`,{className:`benchmark-run-facts`,children:[(0,W.jsxs)(`span`,{children:[`Gate `,(0,W.jsx)(`b`,{children:Q(e.releaseGate,t)})]}),(0,W.jsxs)(`span`,{children:[$(t,`Điểm`,`Score`),` `,(0,W.jsx)(`b`,{children:e.scores.overall??`—`})]}),(0,W.jsxs)(`span`,{children:[`Claim `,(0,W.jsx)(`b`,{children:Q(e.claimTier,t)})]})]})]},e.runRef)),n.benchmark.runs.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(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,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n.benchmark.page.truncated&&(0,W.jsx)(`p`,{className:`task-index-warning`,children:$(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,W.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`release-readiness-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Release readiness`}),(0,W.jsx)(`h3`,{id:`release-readiness-title`,children:$(t,`RC hiện tại`,`Current RC`)})]}),(0,W.jsx)(Nx,{value:n.release.state,locale:t})]}),(0,W.jsxs)(`dl`,{className:`release-readiness-facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Local safe gate`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(Nx,{value:n.release.localSafeGate,locale:t})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`RC assembly`}),(0,W.jsx)(`dd`,{children:Q(n.release.rcAssembly,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Beta`}),(0,W.jsx)(`dd`,{children:Q(n.release.beta,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`GA`}),(0,W.jsx)(`dd`,{children:Q(n.release.gaRelease,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Báo cáo`,`Report`)}),(0,W.jsx)(`dd`,{children:Mx(n.release.generatedAt,t)})]})]}),n.release.sourceState===`stale`&&(0,W.jsx)(`p`,{className:`task-index-warning`,children:$(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,W.jsxs)(`div`,{className:`release-blockers`,children:[(0,W.jsxs)(`strong`,{children:[n.release.blockerCount,` blocker`]}),(0,W.jsx)(`ul`,{children:n.release.blockers.map((e,t)=>(0,W.jsx)(`li`,{children:e},`${t}-${e}`))})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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 Fx=264,Ix={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 Lx({value:e,text:t,locale:n=`vi`}){return(0,W.jsxs)(`span`,{className:`status-pill tone-${fv(e)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),t??Q(e,n)]})}function Rx({locale:e}){return(0,W.jsxs)(`section`,{className:`task-empty surface`,"aria-labelledby":`task-title`,children:[(0,W.jsx)(`div`,{className:`empty-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,W.jsx)(`h2`,{id:`task-title`,children:$(e,`Chưa có task đang chạy`,`No active task`)}),(0,W.jsx)(`p`,{children:$(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 zx({snapshot:e,locale:t}){let n=e.task;if(!n)return(0,W.jsx)(Rx,{locale:t});let r=vv(e,t);return(0,W.jsxs)(`section`,{className:`task-dashboard surface`,"aria-labelledby":`task-title`,children:[(0,W.jsxs)(`header`,{className:`task-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(t,`Task hiện tại`,`Current task`)}),(0,W.jsx)(`h2`,{id:`task-title`,children:n.summary}),(0,W.jsxs)(`div`,{className:`task-meta`,children:[(0,W.jsx)(Lx,{value:n.outcome,locale:t}),(0,W.jsx)(`span`,{children:Q(n.changeMode,t)}),(0,W.jsx)(`span`,{children:Q(n.riskLane,t)})]})]}),(0,W.jsxs)(`div`,{className:`progress-number`,"aria-label":`${$(t,`Tiến độ`,`Progress`)} ${r.percent}%`,children:[(0,W.jsxs)(`strong`,{children:[r.percent,`%`]}),(0,W.jsx)(`span`,{children:r.text})]})]}),(0,W.jsx)(`div`,{className:`progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.percent,"aria-label":$(t,`Tiến độ tiêu chí`,`Criteria progress`),children:(0,W.jsx)(`span`,{style:{width:`${r.percent}%`}})}),n.blocker&&(0,W.jsxs)(`div`,{className:`blocker`,role:`status`,children:[(0,W.jsx)(`span`,{children:`Blocker`}),(0,W.jsx)(`p`,{children:n.blocker})]}),(0,W.jsxs)(`div`,{className:`criteria-heading`,children:[(0,W.jsx)(`h2`,{children:$(t,`Tiêu chí hoàn thành`,`Completion criteria`)}),(0,W.jsxs)(`span`,{children:[n.criteria.length,` `,$(t,`tiêu chí`,`criteria`)]})]}),(0,W.jsx)(`ol`,{className:`criteria-list`,children:n.criteria.map((e,n)=>(0,W.jsxs)(`li`,{className:`criterion-card`,children:[(0,W.jsx)(`span`,{className:`criterion-index tone-${fv(e.state)}`,children:String(n+1).padStart(2,`0`)}),(0,W.jsxs)(`div`,{className:`criterion-copy`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{children:e.obligation}),e.priority===`critical`&&(0,W.jsx)(`span`,{className:`critical-tag`,children:$(t,`Quan trọng`,`Critical`)})]}),(0,W.jsx)(`small`,{children:_v(e,t)})]}),(0,W.jsx)(Lx,{value:e.state,locale:t})]},e.criterionId))}),n.workPlan.length>0&&(0,W.jsxs)(`details`,{className:`work-plan`,children:[(0,W.jsxs)(`summary`,{children:[$(t,`Kế hoạch thực hiện`,`Work plan`),` · `,n.workPlan.length,` `,$(t,`bước`,`steps`)]}),(0,W.jsx)(`ol`,{children:n.workPlan.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(Lx,{value:e.status,locale:t}),(0,W.jsx)(`span`,{children:e.summary})]},e.stepId))})]})]})}function Bx({snapshot:e,locale:t}){return(0,W.jsxs)(`aside`,{className:`context-rail`,"aria-label":$(t,`Tóm tắt phiên`,`Session summary`),children:[(0,W.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Task ID`}),(0,W.jsx)(`dd`,{title:e.identity.taskId??void 0,children:pv(e.identity.taskId)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Run ID`}),(0,W.jsx)(`dd`,{title:e.identity.taskRunId??void 0,children:pv(e.identity.taskRunId)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Verifier`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(Lx,{value:e.verification.state,locale:t})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Queue`}),(0,W.jsx)(`dd`,{children:e.session.queue.state===`known`?`${e.session.queue.heldCount??0} ${$(t,`đang giữ`,`held`)}`:Q(e.session.queue.state,t)})]})]})]}),(0,W.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(t,`Sức khỏe`,`Health`)}),(0,W.jsxs)(`div`,{className:`health-line`,children:[(0,W.jsx)(Lx,{value:e.health.state,locale:t}),(0,W.jsxs)(`span`,{children:[e.health.issues.length,` `,$(t,`lưu ý`,`issues`)]})]}),e.health.issues.slice(0,3).map(e=>(0,W.jsx)(`p`,{className:`health-issue`,children:e.message},e.issueRef))]})]})}function Vx({snapshot:e,locale:t}){let n=[[`Runtime`,(0,W.jsx)(Lx,{value:e.session.operation.liveness,locale:t})],[`Task`,(0,W.jsx)(Lx,{value:e.session.controlState,locale:t})],[`Model`,(0,W.jsx)(`strong`,{children:mv(e,t)})],[`Thinking`,(0,W.jsx)(`strong`,{children:hv(e,t)})],[$(t,`Quyền`,`Permission`),(0,W.jsx)(`strong`,{children:gv(e,t)})],[`Approval`,(0,W.jsx)(Lx,{value:e.session.approvalState,locale:t})]];return(0,W.jsx)(Mc,{variant:`outlined`,className:`runtime-overview`,"aria-label":$(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,W.jsxs)(X,{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,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:800,letterSpacing:`.11em`,textTransform:`uppercase`},children:e}),t]},e))})}function Hx({active:e,snapshot:t,events:n,refreshSnapshot:r,locale:i}){return e===`overview`?(0,W.jsxs)(Cf,{className:`workspace-stack`,spacing:2.25,children:[(0,W.jsx)(Vx,{snapshot:t,locale:i}),(0,W.jsxs)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`minmax(0,1fr) 300px`},alignItems:`start`,gap:2.25},children:[(0,W.jsx)(zx,{snapshot:t,locale:i}),(0,W.jsx)(Bx,{snapshot:t,locale:i})]}),(0,W.jsx)(ax,{snapshot:t})]}):e===`chat`?(0,W.jsxs)(Cf,{className:`workspace-stack`,spacing:2.25,children:[(0,W.jsx)(Ox,{snapshot:t,refreshSnapshot:r}),(0,W.jsx)(bx,{snapshot:t,refreshSnapshot:r}),(0,W.jsx)(yx,{snapshot:t,events:n,refreshSnapshot:r})]}):e===`documents`?(0,W.jsx)(Kb,{}):e===`source`?(0,W.jsx)(Dv,{snapshot:t,refreshSnapshot:r}):e===`activity`?(0,W.jsx)(Qb,{snapshot:t}):e===`history`?(0,W.jsx)(jx,{snapshot:t}):(0,W.jsx)(Px,{snapshot:t})}function Ux({snapshot:e,connection:t=`connecting`,events:n=[],refreshSnapshot:r}){let{locale:i,colorMode:a,setLocale:o,setColorMode:s}=xv(),[c,l]=(0,v.useState)(`overview`),[u,d]=(0,v.useState)(!1);if(!e)return(0,W.jsxs)(X,{className:`loading-shell`,children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsx)(`p`,{className:`section-kicker`,children:`Piagent WebUI · local`}),(0,W.jsx)(Z,{variant:`h1`,children:t===`failed`?$(i,`Không thể nối vào Pi session`,`Unable to connect to the Pi session`):$(i,`Đang mở không gian làm việc`,`Opening the workspace`)}),(0,W.jsx)(Z,{color:`text.secondary`,children:t===`failed`?$(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.`):$(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,W.jsx)(bu,{size:22}),(0,W.jsx)(Lx,{value:t,locale:i})]});let f=Ix[c][i],p=(e.sourceChanges.task?.counts.files??0)+e.sourceChanges.workingTree.counts.files+e.sourceChanges.staged.counts.files,m=[{id:`overview`,label:$(i,`Tổng quan`,`Overview`),icon:(0,W.jsx)(jh,{})},{id:`chat`,label:$(i,`Chat & Task`,`Chat & Task`),icon:(0,W.jsx)(Mh,{}),count:e.session.queue.heldCount??0},{id:`documents`,label:$(i,`Tài liệu`,`Documents`),icon:(0,W.jsx)(Nh,{})},{id:`source`,label:`Source Changes`,icon:(0,W.jsx)(Ph,{}),count:p},{id:`activity`,label:`Activity`,icon:(0,W.jsx)(Fh,{}),count:e.activity.running.length},{id:`history`,label:$(i,`Lịch sử`,`History`),icon:(0,W.jsx)(Ih,{})},{id:`release`,label:`Release`,icon:(0,W.jsx)(Lh,{})}],h=e=>{l(e),d(!1)},g=(0,W.jsxs)(X,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,W.jsxs)(up,{sx:{minHeight:`72px !important`,px:`18px !important`,gap:1.25},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:760,lineHeight:1.15},children:`Piagent`}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:`WebUI · local`})]})]}),(0,W.jsxs)(X,{sx:{mx:1.5,mb:1.25,p:1.35,border:1,borderColor:`divider`,borderRadius:2,bgcolor:`action.hover`},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textTransform:`uppercase`,letterSpacing:`.09em`},children:$(i,`Pi session hiện tại`,`Current Pi session`)}),(0,W.jsx)(Z,{variant:`body2`,noWrap:!0,title:e.session.displayName??void 0,sx:{mt:.45,fontWeight:700},children:e.session.displayName??`Pi session`}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,title:e.identity.sessionRef,children:pv(e.identity.sessionRef)})]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{px:2.5,pt:1,pb:.5,fontWeight:800,letterSpacing:`.1em`,textTransform:`uppercase`},children:$(i,`Không gian làm việc`,`Workspaces`)}),(0,W.jsx)(nf,{component:`nav`,"aria-label":$(i,`Điều hướng WebUI`,`WebUI navigation`),sx:{py:.5},children:m.map(e=>(0,W.jsxs)(sf,{selected:c===e.id,"aria-current":c===e.id?`page`:void 0,onClick:()=>h(e.id),children:[(0,W.jsx)(ff,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:e.icon}),(0,W.jsx)(Sf,{primary:e.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:c===e.id?750:600}}}}),!!e.count&&(0,W.jsx)(tl,{badgeContent:e.count,color:e.id===`activity`?`secondary`:`primary`,max:99,sx:{mr:1}})]},e.id))}),(0,W.jsxs)(X,{sx:{mt:`auto`,p:1.5},children:[(0,W.jsx)(Eu,{sx:{mb:1.5}}),(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsxs)(op,{exclusive:!0,size:`small`,value:i,"aria-label":$(i,`Ngôn ngữ`,`Language`),onChange:(e,t)=>t&&o(t),sx:{flex:1},children:[(0,W.jsx)(ep,{value:`vi`,"aria-label":`Tiếng Việt`,sx:{flex:1},children:`VI`}),(0,W.jsx)(ep,{value:`en`,"aria-label":`English`,sx:{flex:1},children:`EN`})]}),(0,W.jsx)(Ah,{title:a===`dark`?$(i,`Chuyển sang giao diện sáng`,`Use light mode`):$(i,`Chuyển sang giao diện tối`,`Use dark mode`),children:(0,W.jsx)(Zd,{"aria-label":a===`dark`?$(i,`Dùng giao diện sáng`,`Use light mode`):$(i,`Dùng giao diện tối`,`Use dark mode`),onClick:()=>s(a===`dark`?`light`:`dark`),sx:{border:1,borderColor:`divider`,borderRadius:1.5},children:a===`dark`?(0,W.jsx)(zh,{fontSize:`small`}):(0,W.jsx)(Bh,{fontSize:`small`})})})]})]})]});return(0,W.jsxs)(X,{className:`app-shell`,"data-contract":`snapshot-v1`,children:[(0,W.jsx)(`a`,{className:`skip-link`,href:`#main-content`,children:$(i,`Bỏ qua điều hướng`,`Skip navigation`)}),(0,W.jsx)(Lc,{position:`fixed`,color:`transparent`,elevation:0,sx:{width:{md:`calc(100% - ${Fx}px)`},ml:{md:`${Fx}px`},borderBottom:1,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .88)`,backdropFilter:`blur(18px)`},children:(0,W.jsxs)(up,{sx:{minHeight:`72px !important`,gap:1.5},children:[(0,W.jsx)(Zd,{edge:`start`,"aria-label":$(i,`Mở menu`,`Open menu`),onClick:()=>d(!0),sx:{display:{md:`none`}},children:(0,W.jsx)(Rh,{})}),(0,W.jsxs)(X,{sx:{minWidth:0,flex:1},children:[(0,W.jsx)(Z,{component:`h1`,variant:`h2`,noWrap:!0,children:f[0]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{display:{xs:`none`,sm:`block`}},children:f[1]})]}),(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},"aria-live":`polite`,children:[(0,W.jsx)(cu,{variant:`outlined`,size:`small`,color:t===`connected`?`success`:`default`,label:t===`connected`?`Live`:Q(t,i)}),e.approvals.pending.length>0&&(0,W.jsx)(cu,{color:`warning`,size:`small`,label:`${e.approvals.pending.length} approval`}),(0,W.jsx)(cu,{variant:`outlined`,size:`small`,sx:{display:{xs:`none`,sm:`flex`}},label:e.capabilities.capabilities[`control.chat`].status===`available`?$(i,`Chat bật`,`Chat enabled`):$(i,`Chỉ xem`,`Read only`)})]})]})}),(0,W.jsxs)(X,{component:`nav`,"aria-label":$(i,`Sidebar chính`,`Primary sidebar`),sx:{width:{md:Fx},flexShrink:{md:0}},children:[(0,W.jsx)(Gd,{variant:`temporary`,open:u,onClose:()=>d(!1),ModalProps:{keepMounted:!0},sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:Fx}},children:g}),(0,W.jsx)(Gd,{variant:`permanent`,open:!0,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:Fx,borderRight:1,borderColor:`divider`,bgcolor:`background.paper`}},children:g})]}),(0,W.jsx)(X,{component:`main`,id:`main-content`,sx:{ml:{md:`${Fx}px`},minWidth:0,pt:`72px`},children:(0,W.jsxs)(X,{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,W.jsx)(X,{sx:{mb:2.25},children:(0,W.jsx)(wx,{snapshot:e,refreshSnapshot:r})}),(0,W.jsx)(Hx,{active:c,snapshot:e,events:n,refreshSnapshot:r,locale:i})]})})]})}var Wx=sl((0,W.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`),Gx=sl((0,W.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`),Kx=sl((0,W.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`),qx=sl((0,W.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`),Jx=sl((0,W.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`),Yx=sl((0,W.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`),Xx=sl((0,W.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`),Zx=sl((0,W.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`),Qx=sl((0,W.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`),$x=sl((0,W.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`),eS=sl((0,W.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`),tS=sl((0,W.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 nS(e){return K(`MuiAlert`,e)}var rS=Wr(`MuiAlert`,[`root`,`action`,`icon`,`message`,`filled`,`colorSuccess`,`colorInfo`,`colorWarning`,`colorError`,`outlined`,`standard`]),iS=sl((0,W.jsx)(`path`,{d:`M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z`}),`SuccessOutlined`),aS=sl((0,W.jsx)(`path`,{d:`M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z`}),`ReportProblemOutlined`),oS=sl((0,W.jsx)(`path`,{d:`M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z`}),`ErrorOutline`),sS=sl((0,W.jsx)(`path`,{d:`M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z`}),`InfoOutlined`),cS=sl((0,W.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`}),`Close`),lS=e=>{let{variant:t,color:n,severity:r,classes:i}=e;return va({root:[`root`,`color${Y(n||r)}`,`${t}`],icon:[`icon`],message:[`message`],action:[`action`]},nS,i)},uS=J(Mc,{name:`MuiAlert`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant]]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`?e.darken:e.lighten,n=e.palette.mode===`light`?e.lighten:e.darken;return{...e.typography.body2,backgroundColor:`transparent`,display:`flex`,padding:`6px 16px`,variants:[...Object.entries(e.palette).filter(Oc([`light`])).map(([r])=>({props:{colorSeverity:r,variant:`standard`},style:{color:e.vars?e.vars.palette.Alert[`${r}Color`]:t(e.palette[r].light,.6),backgroundColor:e.vars?e.vars.palette.Alert[`${r}StandardBg`]:n(e.palette[r].light,.9),[`& .${rS.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}}})),...Object.entries(e.palette).filter(Oc([`light`])).map(([n])=>({props:{colorSeverity:n,variant:`outlined`},style:{color:e.vars?e.vars.palette.Alert[`${n}Color`]:t(e.palette[n].light,.6),border:`1px solid ${(e.vars||e).palette[n].light}`,[`& .${rS.icon}`]:e.vars?{color:e.vars.palette.Alert[`${n}IconColor`]}:{color:e.palette[n].main}}})),...Object.entries(e.palette).filter(Oc([`dark`])).map(([t])=>({props:{colorSeverity:t,variant:`filled`},style:{fontWeight:e.typography.fontWeightMedium,...e.vars?{color:e.vars.palette.Alert[`${t}FilledColor`],backgroundColor:e.vars.palette.Alert[`${t}FilledBg`]}:{backgroundColor:e.palette.mode===`dark`?e.palette[t].dark:e.palette[t].main,color:e.palette.getContrastText(e.palette[t].main)}}}))]}})),dS=J(`div`,{name:`MuiAlert`,slot:`Icon`})({marginRight:12,padding:`7px 0`,display:`flex`,fontSize:22,opacity:.9}),fS=J(`div`,{name:`MuiAlert`,slot:`Message`})({padding:`8px 0`,minWidth:0,overflow:`auto`}),pS=J(`div`,{name:`MuiAlert`,slot:`Action`})({display:`flex`,alignItems:`flex-start`,padding:`4px 0 0 16px`,marginLeft:`auto`,marginRight:-8}),mS={success:(0,W.jsx)(iS,{fontSize:`inherit`}),warning:(0,W.jsx)(aS,{fontSize:`inherit`}),error:(0,W.jsx)(oS,{fontSize:`inherit`}),info:(0,W.jsx)(sS,{fontSize:`inherit`})},hS=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiAlert`}),{action:r,children:i,className:a,closeText:o=`Close`,color:s,icon:c,iconMapping:l=mS,onClose:u,role:d=`alert`,severity:f=`success`,slotProps:p={},slots:m={},variant:h=`standard`,...g}=n,_={...n,color:s,severity:f,variant:h,colorSeverity:s||f},v=lS(_),y={slots:m,slotProps:p},[b,x]=Jc(`root`,{ref:t,shouldForwardComponentProp:!0,className:G(v.root,a),elementType:uS,externalForwardedProps:{...y,...g},ownerState:_,additionalProps:{role:d,elevation:0}}),[S,C]=Jc(`icon`,{className:v.icon,elementType:dS,externalForwardedProps:y,ownerState:_}),[w,T]=Jc(`message`,{className:v.message,elementType:fS,externalForwardedProps:y,ownerState:_}),[E,D]=Jc(`action`,{className:v.action,elementType:pS,externalForwardedProps:y,ownerState:_}),[O,k]=Jc(`closeButton`,{elementType:Zd,externalForwardedProps:y,ownerState:_}),[A,j]=Jc(`closeIcon`,{elementType:cS,externalForwardedProps:y,ownerState:_});return(0,W.jsxs)(b,{...x,children:[c===!1?null:(0,W.jsx)(S,{...C,children:c||l[f]||mS[f]}),(0,W.jsx)(w,{...T,children:i}),r==null?null:(0,W.jsx)(E,{...D,children:r}),r==null&&u?(0,W.jsx)(E,{...D,children:(0,W.jsx)(O,{size:`small`,"aria-label":o,title:o,color:`inherit`,onClick:u,...k,children:(0,W.jsx)(A,{fontSize:`small`,...j})})}):null]})});function gS(e){return K(`MuiButton`,e)}var _S=Wr(`MuiButton`,`root.text.outlined.contained.disableElevation.focusVisible.disabled.colorInherit.colorPrimary.colorSecondary.colorSuccess.colorError.colorInfo.colorWarning.sizeMedium.sizeSmall.sizeLarge.fullWidth.startIcon.endIcon.icon.loading.loadingWrapper.loadingIconPlaceholder.loadingIndicator.loadingPositionCenter.loadingPositionStart.loadingPositionEnd`.split(`.`)),vS=v.createContext({}),yS=v.createContext(void 0),bS=e=>{let{color:t,disableElevation:n,fullWidth:r,size:i,variant:a,loading:o,loadingPosition:s,classes:c}=e,l=va({root:[`root`,o&&`loading`,a,`size${Y(i)}`,`color${Y(t)}`,n&&`disableElevation`,r&&`fullWidth`,o&&`loadingPosition${Y(s)}`],startIcon:[`icon`,`startIcon`],endIcon:[`icon`,`endIcon`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},gS,c);return{...c,...l}},xS=[{props:{size:`small`},style:{"& > *:nth-of-type(1)":{fontSize:18}}},{props:{size:`medium`},style:{"& > *:nth-of-type(1)":{fontSize:20}}},{props:{size:`large`},style:{"& > *:nth-of-type(1)":{fontSize:22}}}],SS=J(eu,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`size${Y(n.size)}`],n.color===`inherit`&&t.colorInherit,n.disableElevation&&t.disableElevation,n.fullWidth&&t.fullWidth,n.loading&&t.loading]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`?e.palette.grey[300]:e.palette.grey[800],n=e.palette.mode===`light`?e.palette.grey.A100:e.palette.grey[700];return{...e.typography.button,minWidth:64,padding:`6px 16px`,border:0,borderRadius:(e.vars||e).shape.borderRadius,...Ws(e,[`background-color`,`box-shadow`,`border-color`,`color`],{duration:e.transitions.duration.short}),"&:hover":{textDecoration:`none`},[`&.${_S.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:{variant:`contained`},style:{color:`var(--variant-containedColor)`,backgroundColor:`var(--variant-containedBg)`,boxShadow:(e.vars||e).shadows[2],"&:hover":{boxShadow:(e.vars||e).shadows[4],"@media (hover: none)":{boxShadow:(e.vars||e).shadows[2]}},"&:active":{boxShadow:(e.vars||e).shadows[8]},[`&.${_S.focusVisible}`]:{boxShadow:(e.vars||e).shadows[6]},[`&.${_S.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}},{props:{variant:`outlined`},style:{padding:`5px 15px`,border:`1px solid currentColor`,borderColor:`var(--variant-outlinedBorder, currentColor)`,backgroundColor:`var(--variant-outlinedBg)`,color:`var(--variant-outlinedColor)`,[`&.${_S.disabled}`]:{border:`1px solid ${(e.vars||e).palette.action.disabledBackground}`}}},{props:{variant:`text`},style:{padding:`6px 8px`,color:`var(--variant-textColor)`,backgroundColor:`var(--variant-textBg)`}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{"--variant-textColor":(e.vars||e).palette[t].main,"--variant-outlinedColor":(e.vars||e).palette[t].main,"--variant-outlinedBorder":e.alpha((e.vars||e).palette[t].main,.5),"--variant-containedColor":(e.vars||e).palette[t].contrastText,"--variant-containedBg":(e.vars||e).palette[t].main,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":(e.vars||e).palette[t].dark,"--variant-textBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBorder":(e.vars||e).palette[t].main,"--variant-outlinedBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}}}})),{props:{color:`inherit`},style:{color:`inherit`,borderColor:`currentColor`,"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedBg:t,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedHoverBg:n,"--variant-textBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity)}}}},{props:{size:`small`,variant:`text`},style:{padding:`4px 5px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`text`},style:{padding:`8px 11px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`outlined`},style:{padding:`3px 9px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`outlined`},style:{padding:`7px 21px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`contained`},style:{padding:`4px 10px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`contained`},style:{padding:`8px 22px`,fontSize:e.typography.pxToRem(15)}},{props:{disableElevation:!0},style:{boxShadow:`none`,"&:hover":{boxShadow:`none`},[`&.${_S.focusVisible}`]:{boxShadow:`none`},"&:active":{boxShadow:`none`},[`&.${_S.disabled}`]:{boxShadow:`none`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{loadingPosition:`center`},style:{...Ws(e,[`background-color`,`box-shadow`,`border-color`],{duration:e.transitions.duration.short}),[`&.${_S.loading}`]:{color:`transparent`}}}]}})),CS=J(`span`,{name:`MuiButton`,slot:`StartIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.startIcon,n.loading&&t.startIconLoadingStart]}})(({theme:e})=>({display:`inherit`,alignItems:`center`,marginRight:8,marginLeft:-4,"&::before":{content:`"\\200b"`,width:0,overflow:`hidden`},variants:[{props:{size:`small`},style:{marginLeft:-2}},{props:{loadingPosition:`start`,loading:!0},style:{...Ws(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`start`,loading:!0,fullWidth:!0},style:{marginRight:-8}},...xS]})),wS=J(`span`,{name:`MuiButton`,slot:`EndIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.endIcon,n.loading&&t.endIconLoadingEnd]}})(({theme:e})=>({display:`inherit`,marginRight:-4,marginLeft:8,variants:[{props:{size:`small`},style:{marginRight:-2}},{props:{loadingPosition:`end`,loading:!0},style:{...Ws(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`end`,loading:!0,fullWidth:!0},style:{marginLeft:-8}},...xS]})),TS=J(`span`,{name:`MuiButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,variants:[{props:{loading:!0},style:{display:`flex`}},{props:{loadingPosition:`start`},style:{left:14}},{props:{loadingPosition:`start`,size:`small`},style:{left:10}},{props:{variant:`text`,loadingPosition:`start`},style:{left:6}},{props:{loadingPosition:`center`},style:{left:`50%`,transform:`translate(-50%)`,color:(e.vars||e).palette.action.disabled}},{props:{loadingPosition:`end`},style:{right:14}},{props:{loadingPosition:`end`,size:`small`},style:{right:10}},{props:{variant:`text`,loadingPosition:`end`},style:{right:6}},{props:{loadingPosition:`start`,fullWidth:!0},style:{position:`relative`,left:-10}},{props:{loadingPosition:`end`,fullWidth:!0},style:{position:`relative`,right:-10}}]})),ES=J(`span`,{name:`MuiButton`,slot:`LoadingIconPlaceholder`})({display:`inline-block`,width:`1em`,height:`1em`}),DS=v.forwardRef(function(e,t){let n=v.useContext(vS),r=v.useContext(yS),i=Jo({props:ri(n,e),name:`MuiButton`}),{children:a,color:o=`primary`,component:s=`button`,className:c,disabled:l=!1,disableElevation:u=!1,disableFocusRipple:d=!1,endIcon:f,focusVisibleClassName:p,fullWidth:m=!1,id:h,loading:g=null,loadingIndicator:_,loadingPosition:y=`center`,size:b=`medium`,startIcon:x,type:S,variant:C=`text`,...w}=i,T=Td(h),E=_??(0,W.jsx)(bu,{"aria-labelledby":T,color:`inherit`,size:16}),D={...i,color:o,component:s,disabled:l,disableElevation:u,disableFocusRipple:d,fullWidth:m,loading:g,loadingIndicator:E,loadingPosition:y,size:b,type:S,variant:C},O=bS(D),k=(x||g&&y===`start`)&&(0,W.jsx)(CS,{className:O.startIcon,ownerState:D,children:x||(0,W.jsx)(ES,{className:O.loadingIconPlaceholder,ownerState:D})}),A=(f||g&&y===`end`)&&(0,W.jsx)(wS,{className:O.endIcon,ownerState:D,children:f||(0,W.jsx)(ES,{className:O.loadingIconPlaceholder,ownerState:D})}),j=r||``,M=typeof g==`boolean`?(0,W.jsx)(`span`,{className:O.loadingWrapper,style:{display:`contents`},children:g&&(0,W.jsx)(TS,{className:O.loadingIndicator,ownerState:D,children:E})}):null,{root:N,...P}=O;return(0,W.jsxs)(SS,{ownerState:D,className:G(n.className,O.root,c,j),component:s,disabled:l||g,focusRipple:!d,focusVisibleClassName:G(O.focusVisible,p),ref:t,internalNativeButton:!0,type:S,id:g?T:h,...w,classes:P,children:[k,y!==`end`&&M,a,y===`end`&&M,A]})});function OS(e){return K(`MuiCollapse`,e)}Wr(`MuiCollapse`,[`root`,`horizontal`,`vertical`,`entered`,`hidden`,`wrapper`,`wrapperInner`]);var kS={},AS=e=>{let{orientation:t,classes:n}=e;return va({root:[`root`,t],entered:[`entered`],hidden:[`hidden`],wrapper:[`wrapper`,t],wrapperInner:[`wrapperInner`,t]},OS,n)},jS=J(`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]}})(_s(({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`}}]}))),MS=J(`div`,{name:`MuiCollapse`,slot:`Wrapper`})({display:`flex`,width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),NS=J(`div`,{name:`MuiCollapse`,slot:`WrapperInner`})({width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),PS=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiCollapse`}),{addEndListener:r,children:i,className:a,collapsedSize:o=`0px`,component:s,disablePrefersReducedMotion:c=!1,easing:l,in:u,onEnter:d,onEntered:f,onEntering:p,onExit:m,onExited:h,onExiting:g,orientation:_=`vertical`,slots:y=kS,slotProps:b=kS,style:x,timeout:S=lo.standard,TransitionComponent:C=rd,...w}=n,T={...n,orientation:_,collapsedSize:o},E=AS(T),D=Uo(),O=v.useRef(null),k=v.useRef(null),A=typeof o==`number`?`${o}px`:o,j=_===`horizontal`,M=j?`width`:`height`,N=Il(D.motion.reducedMotion,c),P=v.useRef(null),F=vs(t,P),I=()=>O.current?O.current[j?`clientWidth`:`clientHeight`]:0,L=Bs(P,(e,t)=>{O.current&&j&&(O.current.style.position=`absolute`),e.style[M]=A,d&&d(e,t)}),R=Bs(P,(e,t)=>{let n=I();O.current&&j&&(O.current.style.position=``);let{duration:r,easing:i}=Hs({style:x,timeout:S,easing:l},{mode:`enter`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(n);k.current=e}else k.current=null;let a=N.getTransitionTiming({duration:k.current??r,delay:void 0});e.style.transitionDuration=typeof a.duration==`string`?a.duration:`${a.duration}ms`,e.style[M]=`${n}px`,e.style.transitionTimingFunction=i,p&&p(e,t)}),ee=Bs(P,(e,t)=>{e.style[M]=`auto`,f&&f(e,t)}),te=Bs(P,e=>{e.style[M]=`${I()}px`,m&&m(e)}),ne=Bs(P,h),z=Bs(P,e=>{let t=I(),{duration:n,easing:r}=Hs({style:x,timeout:S,easing:l},{mode:`exit`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(t);k.current=e}else k.current=null;let i=N.getTransitionTiming({duration:k.current??n,delay:void 0});e.style.transitionDuration=typeof i.duration==`string`?i.duration:`${i.duration}ms`,e.style[M]=A,e.style.transitionTimingFunction=r,g&&g(e)}),B=r?e=>{r(P.current,e)}:void 0,V={slots:y,slotProps:b,component:s},[re,ie]=Jc(`root`,{ref:F,className:G(E.root,a),elementType:jS,externalForwardedProps:V,ownerState:T,additionalProps:{style:{[j?`minWidth`:`minHeight`]:A,...x}}}),[ae,oe]=Jc(`wrapper`,{ref:O,className:E.wrapper,elementType:MS,externalForwardedProps:V,ownerState:T}),[se,H]=Jc(`wrapperInner`,{className:E.wrapperInner,elementType:NS,externalForwardedProps:V,ownerState:T});return(0,W.jsx)(C,{in:u,onEnter:L,onEntered:ee,onEntering:R,onExit:te,onExited:ne,onExiting:z,addEndListener:B,getAutoTimeout:S===`auto`?()=>k.current:void 0,reduceMotion:N.shouldReduceMotion,nodeRef:P,timeout:S===`auto`?null:S,...w,children:(e,{ownerState:t,...n})=>{let r={...T,state:e};return(0,W.jsx)(re,{...ie,className:G(ie.className,{entered:E.entered,exited:!u&&A===`0px`&&E.hidden}[e]),ownerState:r,...n,children:(0,W.jsx)(ae,{...oe,ownerState:r,children:(0,W.jsx)(se,{...H,ownerState:r,children:i})})})}})});PS&&(PS.muiSupportAuto=!0);function FS(e){return K(`MuiDialog`,e)}Wr(`MuiDialog`,[`root`,`backdrop`,`scrollPaper`,`scrollBody`,`container`,`paper`,`paperWidthFalse`,`paperWidthXs`,`paperWidthSm`,`paperWidthMd`,`paperWidthLg`,`paperWidthXl`,`paperFullWidth`,`paperFullScreen`]);var IS=v.createContext({}),LS=J(ud,{name:`MuiDialog`,slot:`Backdrop`})({zIndex:-1}),RS=e=>{let{classes:t,scroll:n,maxWidth:r,fullWidth:i,fullScreen:a}=e;return va({root:[`root`],backdrop:[`backdrop`],container:[`container`,`scroll${Y(n)}`],paper:[`paper`,`paperWidth${Y(String(r))}`,i&&`paperFullWidth`,a&&`paperFullScreen`]},FS,t)},zS=J(xd,{name:`MuiDialog`,slot:`Root`})({"@media print":{position:`absolute !important`}}),BS=J(`div`,{name:`MuiDialog`,slot:`Container`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.container,t[`scroll${Y(n.scroll)}`]]}})({height:`100%`,"@media print":{height:`auto`},outline:0,variants:[{props:{scroll:`paper`},style:{display:`flex`,justifyContent:`center`,alignItems:`center`}},{props:{scroll:`body`},style:{overflowY:`auto`,overflowX:`hidden`,textAlign:`center`,"&::after":{content:`""`,display:`inline-block`,verticalAlign:`middle`,height:`100%`,width:`0`}}}]}),VS=J(Mc,{name:`MuiDialog`,slot:`Paper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.paper,t[`paperWidth${Y(String(n.maxWidth))}`],n.fullWidth&&t.paperFullWidth,n.fullScreen&&t.paperFullScreen]}})(_s(({theme:e})=>({margin:32,position:`relative`,overflowY:`auto`,outline:0,"@media print":{overflowY:`visible`,boxShadow:`none`},variants:[{props:{scroll:`paper`},style:{display:`flex`,flexDirection:`column`,maxHeight:`calc(100% - 64px)`}},{props:{scroll:`body`},style:{display:`inline-block`,verticalAlign:`middle`,textAlign:`initial`}},{props:({ownerState:e})=>!e.maxWidth,style:{maxWidth:`calc(100% - 64px)`}},{props:{maxWidth:`xs`},style:{maxWidth:e.breakpoints.unit===`px`?Math.max(e.breakpoints.values.xs,444):`max(${e.breakpoints.values.xs}${e.breakpoints.unit}, 444px)`}},{props:{maxWidth:`xs`,scroll:`body`},style:{[e.breakpoints.down(Math.max(e.breakpoints.values.xs,444)+64)]:{maxWidth:`calc(100% - 64px)`}}},...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t},style:{maxWidth:`${e.breakpoints.values[t]}${e.breakpoints.unit}`}})),...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t,scroll:`body`},style:{[e.breakpoints.down(e.breakpoints.values[t]+64)]:{maxWidth:`calc(100% - 64px)`}}})),{props:({ownerState:e})=>e.fullWidth,style:{width:`calc(100% - 64px)`}},{props:({ownerState:e})=>e.fullScreen,style:{margin:0,width:`100%`,maxWidth:`100%`,height:`100%`,maxHeight:`none`,borderRadius:0}},{props:({ownerState:e})=>e.fullScreen&&e.scroll===`body`,style:{margin:0,maxWidth:`100%`}}]}))),HS=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialog`}),r=Uo(),i={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{"aria-describedby":a,"aria-labelledby":o,"aria-modal":s=!0,children:c,className:l,fullScreen:u=!1,fullWidth:d=!1,maxWidth:f=`sm`,onClick:p,onClose:m,open:h,PaperComponent:g=Mc,role:_=`dialog`,scroll:y=`paper`,slots:b={},slotProps:x={},transitionDuration:S=i,...C}=n,w={...n,fullScreen:u,fullWidth:d,maxWidth:f,scroll:y},T=RS(w),E=v.useRef(),D=e=>{E.current=e.target===e.currentTarget},O=e=>{p&&p(e),E.current&&(E.current=null,m&&m(e,`backdropClick`))},k=Wi(o),A=v.useMemo(()=>({titleId:k}),[k]),j={slots:b,slotProps:x},[M,N]=Jc(`root`,{elementType:zS,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:G(T.root,l),ref:t}),[P,F]=Jc(`backdrop`,{elementType:LS,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.backdrop}),[I,L]=Jc(`paper`,{elementType:VS,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.paper,additionalProps:{elevation:24,role:_,"aria-describedby":a,"aria-labelledby":k,"aria-modal":s,tabIndex:-1,[zu]:``}}),[R,ee]=Jc(`container`,{elementType:BS,externalForwardedProps:j,ownerState:w,className:T.container}),[te,ne]=Jc(`transition`,{elementType:od,externalForwardedProps:j,ownerState:w,additionalProps:{appear:!0,in:h,timeout:S,role:`presentation`}});return(0,W.jsx)(M,{closeAfterTransition:!0,slots:{backdrop:P},slotProps:{backdrop:{transitionDuration:S,...F}},onClose:m,open:h,onClick:O,...N,...C,children:(0,W.jsx)(te,{...ne,children:(0,W.jsx)(R,{onMouseDown:D,...ee,children:(0,W.jsx)(I,{as:g,...L,children:(0,W.jsx)(IS.Provider,{value:A,children:c})})})})})}),US=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},WS=e=>{let{disabled:t,dense:n,divider:r,disableGutters:i,selected:a,classes:o}=e,s=va({root:[`root`,n&&`dense`,t&&`disabled`,!i&&`gutters`,r&&`divider`,a&&`selected`]},dc,o);return{...o,...s}},GS=J(eu,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiMenuItem`,slot:`Root`,overridesResolver:US})(_s(({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`}},[`&.${fc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${fc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${fc.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${fc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${fc.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${Su.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${Su.inset}`]:{marginLeft:52},[`& .${yf.root}`]:{marginTop:0,marginBottom:0},[`& .${yf.inset}`]:{paddingLeft:36},[`& .${lf.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,[`& .${lf.root} svg`]:{fontSize:`1.25rem`}}}]}))),KS=v.forwardRef(function(e,t){let n=Jo({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=Cy(),h=v.useContext(Qd),g=v.useMemo(()=>({dense:a||h.dense||!1,disableGutters:s}),[h.dense,a,s]),_=Ey(),y=Td(),b=_.suppressInitialFocusVisible,x=_.itemsFocusableWhenDisabled,S=v.useRef(null);ys(()=>{r&&S.current&&vy(S.current,m)},[r]);let C={...n,dense:g.dense,divider:o,disableGutters:s},w=WS(n),{root:T,...E}=w,D=Nf({id:y,ref:t,disabled:n.disabled,focusableWhenDisabled:x,selected:n.selected}),O=vs(S,D.ref),k;return u===void 0?_.variant===`selectedMenu`?k=D.tabIndex:(!n.disabled||x)&&(k=-1):k=u,(0,W.jsx)(Qd.Provider,{value:g,children:(0,W.jsx)(GS,{ref:O,role:l,"aria-checked":p,tabIndex:k,component:i,internalNativeButton:!1,focusableWhenDisabled:x,suppressFocusVisible:b,focusVisibleClassName:G(w.focusVisible,c),className:G(w.root,d),...f,ownerState:C,classes:E})})}),qS=sl((0,W.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`),JS=sl((0,W.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`),YS=sl((0,W.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`),XS=sl((0,W.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`),ZS=sl((0,W.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`),QS=sl((0,W.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`),$S=sl((0,W.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`),eC=sl((0,W.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`),tC=sl((0,W.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`),nC=sl((0,W.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`),rC=sl((0,W.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`),iC=sl((0,W.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`),aC=sl((0,W.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`),oC={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 sC(){return(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{fill:`#f24e1e`,d:`M5 2h7v7H8.5A3.5 3.5 0 0 1 5 5.5V2Z`}),(0,W.jsx)(`path`,{fill:`#ff7262`,d:`M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2Z`}),(0,W.jsx)(`path`,{fill:`#a259ff`,d:`M5 9h7v7H8.5A3.5 3.5 0 0 1 5 12.5V9Z`}),(0,W.jsx)(`circle`,{cx:`15.5`,cy:`12.5`,r:`3.5`,fill:`#1abcfe`}),(0,W.jsx)(`path`,{fill:`#0acf83`,d:`M5 16h7v3.5A3.5 3.5 0 1 1 5 16Z`})]})}function cC(e){let t=e.toLowerCase();return t.includes(`figma`)?(0,W.jsx)(sC,{}):t.includes(`github`)?(0,W.jsx)(rC,{fontSize:`inherit`}):t.includes(`chrome`)||t.includes(`devtools`)?(0,W.jsx)(tC,{fontSize:`inherit`}):t.includes(`anthropic`)||t.includes(`claude`)?(0,W.jsx)(QS,{fontSize:`inherit`}):t.includes(`file`)||t.includes(`folder`)?(0,W.jsx)(nC,{fontSize:`inherit`}):t.includes(`postgres`)||t.includes(`database`)||t.includes(`supabase`)?(0,W.jsx)(aC,{fontSize:`inherit`}):t.includes(`code`)||t.includes(`context7`)?(0,W.jsx)(eC,{fontSize:`inherit`}):t.includes(`google`)||t.includes(`drive`)||t.includes(`cloud`)?(0,W.jsx)($S,{fontSize:`inherit`}):(0,W.jsx)(iC,{fontSize:`inherit`})}function lC({name:e,size:t=34}){let n=e.toLowerCase(),r=Object.keys(oC).find(e=>n.includes(e));return(0,W.jsx)(X,{"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?oC[r]:`action.selected`,color:r?`#fff`:`text.secondary`,fontSize:Math.round(t*.52),border:1,borderColor:r?`transparent`:`divider`},children:cC(e)})}var uC=sl((0,W.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 dC(e){return K(`MuiDialogActions`,e)}Wr(`MuiDialogActions`,[`root`,`spacing`]);var fC=e=>{let{classes:t,disableSpacing:n}=e;return va({root:[`root`,!n&&`spacing`]},dC,t)},pC=J(`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}}}]}),mC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogActions`}),{className:r,disableSpacing:i=!1,...a}=n,o={...n,disableSpacing:i},s=fC(o);return(0,W.jsx)(pC,{className:G(s.root,r),ownerState:o,ref:t,...a})});function hC(e){return K(`MuiDialogContent`,e)}Wr(`MuiDialogContent`,[`root`,`dividers`]);function gC(e){return K(`MuiDialogTitle`,e)}var _C=Wr(`MuiDialogTitle`,[`root`]),vC=e=>{let{classes:t,dividers:n}=e;return va({root:[`root`,n&&`dividers`]},hC,t)},yC=J(`div`,{name:`MuiDialogContent`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.dividers&&t.dividers]}})(_s(({theme:e})=>({flex:`1 1 auto`,WebkitOverflowScrolling:`touch`,overflowY:`auto`,padding:`20px 24px`,variants:[{props:({ownerState:e})=>e.dividers,style:{padding:`16px 24px`,borderTop:`1px solid ${(e.vars||e).palette.divider}`,borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>!e.dividers,style:{[`.${_C.root} + &`]:{paddingTop:0}}}]}))),bC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogContent`}),{className:r,dividers:i=!1,...a}=n,o={...n,dividers:i},s=vC(o);return(0,W.jsx)(yC,{className:G(s.root,r),ownerState:o,ref:t,...a})});function xC(e){return K(`MuiDialogContentText`,e)}Wr(`MuiDialogContentText`,[`root`]);var SC=e=>{let{classes:t}=e,n=va({root:[`root`]},xC,t);return{...t,...n}},CC=J(Z,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiDialogContentText`,slot:`Root`})({}),wC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogContentText`}),{children:r,className:i,...a}=n,o=SC(a);return(0,W.jsx)(CC,{component:`p`,variant:`body1`,color:`textSecondary`,ref:t,ownerState:a,className:G(o.root,i),...n,classes:o})}),TC=e=>{let{classes:t}=e;return va({root:[`root`]},gC,t)},EC=J(Z,{name:`MuiDialogTitle`,slot:`Root`})({padding:`16px 24px`,flex:`0 0 auto`}),DC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogTitle`}),{className:r,id:i,...a}=n,o=n,s=TC(o),{titleId:c=i}=v.useContext(IS);return(0,W.jsx)(EC,{component:`h2`,className:G(s.root,r),ownerState:o,ref:t,variant:`h6`,id:i??c,...a})});function OC({open:e,title:t,description:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){return(0,W.jsxs)(HS,{open:e,onClose:o,fullWidth:!0,maxWidth:`xs`,"aria-describedby":`piagent-confirm-dialog-description`,slotProps:{paper:{sx:{borderRadius:3,p:.5}}},children:[(0,W.jsxs)(DC,{sx:{display:`flex`,alignItems:`center`,gap:1.25,pb:1},children:[(0,W.jsx)(X,{sx:{width:36,height:36,borderRadius:2,display:`grid`,placeItems:`center`,bgcolor:`warning.main`,color:`warning.contrastText`},children:(0,W.jsx)(uC,{fontSize:`small`})}),(0,W.jsx)(Z,{component:`span`,sx:{fontSize:`1.08rem`,fontWeight:700},children:t})]}),(0,W.jsx)(bC,{children:(0,W.jsx)(wC,{id:`piagent-confirm-dialog-description`,sx:{color:`text.secondary`,lineHeight:1.65},children:n})}),(0,W.jsxs)(mC,{sx:{px:2.5,pb:2,gap:.75},children:[(0,W.jsx)(DS,{color:`inherit`,onClick:o,autoFocus:!0,children:i}),(0,W.jsx)(DS,{variant:`contained`,color:`warning`,onClick:a,children:r})]})]})}var kC=[{id:`task`,changeMode:`source-change`,modelUse:`required`,recommendedFreshSession:!0},{id:`scout`,changeMode:`read-only`,modelUse:`required`,recommendedFreshSession:!0},{id:`be-to-fe`,changeMode:`source-change`,modelUse:`required`,recommendedFreshSession:!0},{id:`discuss`,changeMode:`clarification`,modelUse:`required`,recommendedFreshSession:!1},{id:`plan`,changeMode:`plan-only`,modelUse:`required`,recommendedFreshSession:!1},{id:`review`,changeMode:`read-only`,modelUse:`required`,recommendedFreshSession:!1},{id:`commit`,changeMode:`git`,modelUse:`required`,recommendedFreshSession:!1},{id:`pr`,changeMode:`git`,modelUse:`required`,recommendedFreshSession:!1},{id:`onboard`,changeMode:`onboarding`,modelUse:`required`,recommendedFreshSession:!0},{id:`platform-improve`,changeMode:`platform`,modelUse:`required`,recommendedFreshSession:!0}];function AC(e,t){return[{task:[`Thực hiện task`,`Implement task`],scout:[`Khảo sát chỉ đọc`,`Read-only scout`],"be-to-fe":[`Backend → Frontend`,`Backend → Frontend`],discuss:[`Làm rõ ý tưởng`,`Clarify idea`],plan:[`Lập kế hoạch`,`Plan`],review:[`Review thay đổi`,`Review changes`],commit:[`Chuẩn bị commit`,`Prepare commit`],pr:[`Chuẩn bị pull request`,`Prepare pull request`],onboard:[`Onboard project`,`Onboard project`],"platform-improve":[`Cải tiến Piagent`,`Improve Piagent`]}[e][t===`vi`?0:1],e]}function jC({active:e,defaultProjectRef:t,busy:n,error:r,onCancel:i,onCreate:a}){let{locale:o}=xv(),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(`high`),[_,y]=(0,v.useState)(`task`),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)([]),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(!1),P=(0,v.useRef)(0),[F,I]=(0,v.useState)(null),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)(!1),[ne,z]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e)return;let n=new AbortController;return c(void 0),u(!1),T(``),z(null),k([]),j(null),N(!1),x(!1),P.current=0,wg(n.signal).then(e=>{n.signal.aborted||(c(e),f(e.projects.some(e=>e.projectRef===t)?t:e.projects[0]?.projectRef??``),m(e.defaultModelRef??``),g(e.defaultThinkingLevel??`high`),y(`task`),C(null))}).catch(()=>{n.signal.aborted||u(!0)}),()=>n.abort()},[e,t]),(0,v.useEffect)(()=>{if(!e)return;let t=e=>{gx(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,t),window.addEventListener(`drop`,t),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`drop`,t)}},[e]);let B=s?.projects.find(e=>e.projectRef===d),V=s?.models.find(e=>e.modelRef===p),re=s?.models.find(e=>e.modelRef===s.defaultModelRef),ie=s?.workflows?.length?s.workflows:kC,ae=(0,v.useMemo)(()=>V?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[V]);(0,v.useEffect)(()=>{ae.includes(h)||g(ae.includes(`high`)?`high`:ae[0]??`off`)},[p,ae]);let oe=e=>t=>{I(e),R(t.currentTarget)},se=()=>{I(null),R(null)},H=async()=>{te(!0),z(null);try{let e=await jg(),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]}),f(e.project.projectRef),se()}catch(e){e instanceof bg&&e.status===409?z(null):z($(o,`Không thể thêm thư mục`,`Could not add this folder`))}finally{te(!1)}},ce=e=>{if(!e?.length)return;let t=[...O],n=!1;for(let r of[...e])if(!t.some(e=>e.name===r.name&&e.size===r.size&&e.lastModified===r.lastModified)){if(t.length===4){n=!0;continue}t.push(r)}k(t),j(n?$(o,`Mỗi tin nhắn nhận tối đa 4 file.`,`Each message accepts at most 4 files.`):null)},le=!n&&!l&&O.length<4,ue=()=>B&&w.trim()&&a({projectRef:d,placeRef:B.placeRef,modelRef:p||null,thinkingLevel:h,permissionMode:S,workflow:_,message:w.trim(),files:O});return(0,W.jsxs)(X,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,W.jsx)(X,{sx:{p:{xs:1.5,sm:2}},children:(0,W.jsx)(Zd,{"aria-label":$(o,`Quay lại`,`Back`),onClick:i,children:(0,W.jsx)(qS,{})})}),(0,W.jsxs)(Cf,{sx:{flex:1,alignItems:`center`,justifyContent:`center`,px:2,pb:{xs:5,md:12}},spacing:4,children:[(0,W.jsx)(Z,{component:`h1`,sx:{fontSize:{xs:`2rem`,md:`2.45rem`},fontWeight:500,letterSpacing:`-.035em`,textAlign:`center`},children:$(o,`Anh muốn làm gì?`,`What should we work on?`)}),(0,W.jsxs)(X,{sx:{position:`relative`,width:`100%`,maxWidth:820,border:1,borderColor:M?`primary.main`:`divider`,borderStyle:M?`dashed`:`solid`,borderRadius:3.5,bgcolor:`background.paper`,p:1.25,boxShadow:`0 18px 55px rgba(0,0,0,.13)`},onDragEnter:e=>{gx(e.dataTransfer)&&(P.current+=1,N(!0))},onDragOver:e=>{gx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=le?`copy`:`none`)},onDragLeave:e=>{gx(e.dataTransfer)&&(--P.current,P.current<=0&&(P.current=0,N(!1)))},onDrop:e=>{gx(e.dataTransfer)&&(e.preventDefault(),P.current=0,N(!1),le&&ce(e.dataTransfer.files))},children:[M&&(0,W.jsxs)(X,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3.5,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,W.jsx)(Z,{sx:{fontWeight:750},children:le?$(o,`Thả tài liệu vào đây`,`Drop documents here`):O.length>=4?$(o,`Đã đủ 4 file cho tin nhắn đầu tiên`,`The first message already holds 4 files`):$(o,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),le&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:$(o,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),!s&&!l?(0,W.jsxs)(Cf,{direction:`row`,spacing:1.5,sx:{minHeight:126,alignItems:`center`,justifyContent:`center`},children:[(0,W.jsx)(bu,{size:20}),(0,W.jsx)(Z,{color:`text.secondary`,children:$(o,`Đang mở…`,`Opening…`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Mb,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:3,maxRows:8,value:w,disabled:n||l,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ue())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),le&&ce(e.clipboardData.files))},placeholder:$(o,`Nhắn cho Piagent…`,`Message Piagent…`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:{maxLength:32768}},sx:{px:.5}}),O.length>0&&(0,W.jsx)(Cf,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pt:.75},"aria-label":$(o,`File sẽ gửi cùng tin nhắn đầu tiên`,`Files for the first message`),children:O.map(e=>(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:`${e.name} · ${px(e.size)}`,onDelete:n?void 0:()=>{k(t=>t.filter(t=>t!==e)),j(null)},deleteIcon:(0,W.jsx)(Jx,{"aria-label":`${$(o,`Bỏ`,`Remove`)} ${e.name}`,role:`button`})},`${e.name}:${e.size}:${e.lastModified}`))}),(0,W.jsx)(PS,{in:b,id:`piagent-new-session-options`,children:(0,W.jsxs)(X,{sx:{mx:.35,mt:1,px:1.1,py:1,borderRadius:2,bgcolor:`action.hover`},children:[(0,W.jsx)(Z,{variant:`caption`,sx:{display:`block`,mb:.75,fontWeight:750},children:$(o,`Tùy chọn cho tin nhắn đầu tiên`,`Options for the first message`)}),(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,W.jsx)(DS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(Gx,{}),endIcon:(0,W.jsx)(JS,{}),onClick:oe(`workflow`),children:AC(_,o)[0]}),(0,W.jsx)(DS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(ZS,{}),endIcon:(0,W.jsx)(JS,{}),onClick:oe(`thinking`),children:Q(h,o)}),(0,W.jsx)(DS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(XS,{}),endIcon:(0,W.jsx)(JS,{}),onClick:oe(`permission`),children:S?Q(S,o):$(o,`Quyền theo profile`,`Profile access`)}),(0,W.jsxs)(DS,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,W.jsx)(Kx,{}),disabled:!le,"aria-label":`${$(o,`Thêm file`,`Add files`)} (${O.length}/4)`,children:[$(o,`Đính kèm`,`Attach`),(0,W.jsx)(`input`,{type:`file`,hidden:!0,multiple:!0,disabled:!le,accept:dx,onChange:e=>{ce(e.target.files),e.currentTarget.value=``}})]})]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.75},children:$(o,`Workflow “${AC(_,o)[0]}” chỉ áp dụng cho tin nhắn đầu tiên. Trong session này anh vẫn có thể gửi việc khác hoặc chọn workflow khác ở từng tin nhắn.`,`“${AC(_,o)[0]}” applies only to the first message. You can send different work or choose another workflow for any later message in this session.`)})]})}),(0,W.jsxs)(Cf,{direction:`row`,sx:{mt:1,alignItems:`center`,gap:.65,flexWrap:`nowrap`,minWidth:0},children:[(0,W.jsx)(Ah,{title:b?$(o,`Ẩn tùy chọn`,`Hide options`):$(o,`Thêm tùy chọn`,`More options`),children:(0,W.jsx)(Zd,{size:`small`,"aria-label":b?$(o,`Ẩn tùy chọn`,`Hide options`):$(o,`Thêm tùy chọn`,`More options`),"aria-expanded":b,"aria-controls":`piagent-new-session-options`,onClick:()=>x(e=>!e),sx:{flex:`0 0 auto`,bgcolor:b?`action.selected`:`transparent`},children:(0,W.jsx)(Wx,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:b?`rotate(45deg)`:`none`}})})}),(0,W.jsx)(DS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(Xx,{}),endIcon:(0,W.jsx)(JS,{}),onClick:oe(`project`),"aria-label":`${$(o,`Project`,`Project`)}: ${B?.label??$(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,W.jsx)(X,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:B?.label??$(o,`Chọn project`,`Choose project`)})}),(0,W.jsx)(DS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(YS,{}),endIcon:(0,W.jsx)(JS,{}),onClick:oe(`model`),"aria-label":`${$(o,`Model`,`Model`)}: ${V?.displayName??re?.displayName??$(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,W.jsx)(X,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:V?`${V.displayName}${V.modelRef===s?.defaultModelRef?$(o,` · mặc định`,` · default`):``}`:re?.displayName??$(o,`Mặc định của Pi`,`Pi default`)})}),(0,W.jsx)(X,{sx:{flex:1,minWidth:0}}),(0,W.jsx)(Zd,{"aria-label":$(o,`Gửi`,`Send`),disabled:n||l||!B||!w.trim(),onClick:ue,sx:{flex:`0 0 auto`,bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,W.jsx)($x,{fontSize:`small`})})]})]}),(A||ne||r||l)&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,sx:{display:`block`,px:.5,pt:1},children:A??ne??r??$(o,`Không tải được lựa chọn`,`Could not load choices`)})]})]}),(0,W.jsxs)(Jy,{anchorEl:L,open:F===`project`,onClose:se,slotProps:{paper:{sx:{width:310,maxHeight:380}}},children:[(s?.projects??[]).map(e=>(0,W.jsxs)(KS,{selected:d===e.projectRef,onClick:()=>{f(e.projectRef),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(lC,{name:`folder`,size:26})}),(0,W.jsx)(Sf,{primary:e.label})]},e.projectRef)),(0,W.jsx)(Eu,{}),(0,W.jsxs)(KS,{disabled:ee||s?.projectImport?.status!==`available`,onClick:()=>void H(),children:[(0,W.jsx)(ff,{children:(0,W.jsx)(Wx,{})}),(0,W.jsx)(Sf,{primary:ee?$(o,`Đang chọn…`,`Choosing…`):$(o,`Thêm một hoặc nhiều folder`,`Add one or more folders`)})]})]}),(0,W.jsxs)(Jy,{anchorEl:L,open:F===`model`,onClose:se,slotProps:{paper:{sx:{width:360,maxHeight:440}}},children:[!s?.defaultModelRef&&(0,W.jsxs)(KS,{selected:!p,onClick:()=>{m(``),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(YS,{})}),(0,W.jsx)(Sf,{primary:$(o,`Model mặc định của Pi`,`Pi default model`)})]}),(s?.models??[]).map(e=>(0,W.jsxs)(KS,{selected:p===e.modelRef,onClick:()=>{m(e.modelRef),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(lC,{name:e.provider,size:26})}),(0,W.jsx)(Sf,{primary:e.displayName,secondary:e.modelRef===s?.defaultModelRef?$(o,`Mặc định · ${e.provider} · High`,`Default · ${e.provider} · High`):e.provider})]},e.modelRef))]}),(0,W.jsx)(Jy,{anchorEl:L,open:F===`workflow`,onClose:se,slotProps:{paper:{sx:{width:360,maxHeight:470}}},children:ie.map(e=>(0,W.jsxs)(KS,{selected:_===e.id,onClick:()=>{y(e.id),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(Gx,{})}),(0,W.jsx)(Sf,{primary:AC(e.id,o)[0],secondary:`${Q(e.changeMode,o)} · ${$(o,`chỉ cho tin nhắn này`,`this message only`)}`})]},e.id))}),(0,W.jsx)(Jy,{anchorEl:L,open:F===`thinking`,onClose:se,slotProps:{paper:{sx:{width:250,maxHeight:400}}},children:ae.map(e=>(0,W.jsxs)(KS,{value:e,selected:h===e,onClick:()=>{g(e),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(ZS,{})}),(0,W.jsx)(Sf,{primary:Q(e,o)})]},e))}),(0,W.jsxs)(Jy,{anchorEl:L,open:F===`permission`,onClose:se,slotProps:{paper:{sx:{width:310}}},children:[(0,W.jsxs)(KS,{selected:S===null,onClick:()=>{C(null),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(XS,{})}),(0,W.jsx)(Sf,{primary:$(o,`Theo profile project`,`Project profile default`)})]}),[`read-only`,`workspace-write`,`trusted-full-access`].map(e=>(0,W.jsxs)(KS,{selected:S===e,onClick:()=>{se(),e===`trusted-full-access`?D(e):C(e)},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(XS,{})}),(0,W.jsx)(Sf,{primary:Q(e,o)})]},e))]}),(0,W.jsx)(OC,{open:E!==null,title:$(o,`Tạo session với toàn quyền?`,`Create with full access?`),description:$(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:$(o,`Hủy`,`Cancel`),confirmLabel:$(o,`Dùng toàn quyền`,`Use full access`),onCancel:()=>D(null),onConfirm:()=>{D(null),C(`trusted-full-access`)}})]})}var MC=sl((0,W.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`),NC=sl((0,W.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 PC(e){return K(`MuiListItem`,e)}Wr(`MuiListItem`,[`root`,`dense`,`alignItemsFlexStart`,`divider`,`gutters`,`padding`,`secondaryAction`]);function FC(e){return K(`MuiListItemSecondaryAction`,e)}Wr(`MuiListItemSecondaryAction`,[`root`,`disableGutters`]);var IC=e=>{let{disableGutters:t,classes:n}=e;return va({root:[`root`,t&&`disableGutters`]},FC,n)},LC=J(`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}}]}),RC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemSecondaryAction`}),{className:r,component:i,...a}=n,o=v.useContext(Qd),s={...n,disableGutters:o.disableGutters},c=IC(s);return(0,W.jsx)(LC,{as:i,className:G(c.root,r),ownerState:s,ref:t,...a})});RC.muiName=`ListItemSecondaryAction`;var zC=(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]},BC=e=>{let{alignItems:t,classes:n,dense:r,disableGutters:i,disablePadding:a,divider:o}=e;return va({root:[`root`,r&&`dense`,!i&&`gutters`,!a&&`padding`,o&&`divider`,t===`flex-start`&&`alignItemsFlexStart`],secondaryAction:[`secondaryAction`]},PC,n)},VC=J(`div`,{name:`MuiListItem`,slot:`Root`,overridesResolver:zC})(_s(({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:{[`& > .${uc.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:{...Ws(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}}}}]}))),HC=J(RC,{name:`MuiListItem`,slot:`secondaryAction`})({}),UC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItem`}),{alignItems:r=`center`,children:i,className:a,component:o=`li`,dense:s=!1,disableGutters:c=!1,disablePadding:l=!1,divider:u=!1,secondaryAction:d,slotProps:f={},slots:p={},...m}=n,h=v.useContext(Qd),g=v.useMemo(()=>({dense:s||h.dense||!1,alignItems:r,disableGutters:c}),[r,h.dense,s,c]),_={...n,alignItems:r,dense:g.dense,disableGutters:c,disablePadding:l,divider:u,secondaryAction:d},y=BC(_),b={slots:p,slotProps:f},[x,S]=Jc(`root`,{ref:t,elementType:VC,externalForwardedProps:{component:o,...b,...m},ownerState:_,className:G(y.root,a)}),[C,w]=Jc(`secondaryAction`,{elementType:HC,shouldForwardComponentProp:!0,externalForwardedProps:b,ownerState:_,className:y.secondaryAction});return(0,W.jsx)(Qd.Provider,{value:g,children:(0,W.jsxs)(x,{...S,children:[i,d&&(0,W.jsx)(C,{...w,children:d})]})})}),WC=sl((0,W.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`),GC=sl((0,W.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 KC(e){return K(`PrivateSwitchBase`,e)}Wr(`PrivateSwitchBase`,[`root`,`checked`,`disabled`,`input`,`edgeStart`,`edgeEnd`]);var qC=e=>{let{classes:t,checked:n,disabled:r,edge:i}=e;return va({root:[`root`,n&&`checked`,r&&`disabled`,i&&`edge${Y(i)}`],input:[`input`]},KC,t)},JC=J(eu,{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}}]}),YC=J(`input`,{name:`MuiSwitchBase`,shouldForwardProp:Ko})({cursor:`inherit`,position:`absolute`,opacity:0,width:`100%`,height:`100%`,top:0,left:0,margin:0,padding:0,zIndex:1}),XC=v.forwardRef(function(e,t){let{autoFocus:n,checked:r,checkedIcon:i,defaultChecked:a,disabled:o,disableFocusRipple:s=!1,edge:c=!1,icon:l,id:u,name:d,onBlur:f,onChange:p,onFocus:m,readOnly:h,required:g=!1,tabIndex:_,type:v,value:y,slots:b={},slotProps:x={},...S}=e,{nativeButton:C,...w}=S,[T,E]=Dd({controlled:r,default:!!a,name:`SwitchBase`,state:`checked`}),D=hs(),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=qC(N),F={slots:b,slotProps:x},[I,L]=Jc(`root`,{ref:t,elementType:JC,className:P.root,shouldForwardComponentProp:!0,externalForwardedProps:{...F,component:`span`,...w},getSlotProps:e=>({...e,onFocus:t=>{e.onFocus?.(t),O(t)},onBlur:t=>{e.onBlur?.(t),k(t)}}),ownerState:N,additionalProps:{centerRipple:!0,focusRipple:!s,role:void 0,tabIndex:null}}),[R,ee]=Jc(`input`,{elementType:YC,className:P.input,externalForwardedProps:F,getSlotProps:e=>({...e,onChange:t=>{e.onChange?.(t),A(t)}}),ownerState:N,additionalProps:{autoFocus:n,checked:r,defaultChecked:a,disabled:j,id:M?u:void 0,name:d,readOnly:h,required:g,tabIndex:_,type:v,...v===`checkbox`&&y===void 0?{}:{value:y}}});return(0,W.jsxs)(I,{...L,children:[(0,W.jsx)(R,{...ee}),T?i:l]})});function ZC(e){return K(`MuiSwitch`,e)}var QC=Wr(`MuiSwitch`,[`root`,`edgeStart`,`edgeEnd`,`switchBase`,`colorPrimary`,`colorSecondary`,`sizeSmall`,`sizeMedium`,`checked`,`disabled`,`input`,`thumb`,`track`]),$C=e=>{let{classes:t,edge:n,size:r,color:i,checked:a,disabled:o}=e,s=va({root:[`root`,n&&`edge${Y(n)}`,`size${Y(r)}`],switchBase:[`switchBase`,`color${Y(i)}`,a&&`checked`,o&&`disabled`],thumb:[`thumb`],track:[`track`],input:[`input`]},ZC,t);return{...t,...s}},ew=J(`span`,{name:`MuiSwitch`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.edge&&t[`edge${Y(n.edge)}`],t[`size${Y(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,[`& .${QC.thumb}`]:{width:16,height:16},[`& .${QC.switchBase}`]:{padding:4,[`&.${QC.checked}`]:{transform:`translateX(16px)`}}}}]}),tw=J(XC,{name:`MuiSwitch`,slot:`SwitchBase`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.switchBase,{[`& .${QC.input}`]:t.input},n.color!=="default"&&t[`color${Y(n.color)}`]]}})(_s(({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]}`,...Ws(e,[`left`,`transform`],{duration:e.transitions.duration.shortest}),[`&.${QC.checked}`]:{transform:`translateX(20px)`},[`&.${QC.disabled}`]:{color:e.vars?e.vars.palette.Switch.defaultDisabledColor:`${e.palette.mode===`light`?e.palette.grey[100]:e.palette.grey[600]}`},[`&.${QC.checked} + .${QC.track}`]:{opacity:.5},[`&.${QC.disabled} + .${QC.track}`]:{opacity:e.vars?e.vars.opacity.switchTrackDisabled:`${e.palette.mode===`light`?.12:.2}`},[`& .${QC.input}`]:{left:`-100%`,width:`300%`}})),_s(({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(Oc([`light`])).map(([t])=>({props:{color:t},style:{[`&.${QC.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`}},[`&.${QC.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)}`}},[`&.${QC.checked} + .${QC.track}`]:{backgroundColor:(e.vars||e).palette[t].main}}}))]}))),nw=J(`span`,{name:`MuiSwitch`,slot:`Track`})(_s(({theme:e})=>({height:`100%`,width:`100%`,borderRadius:7,zIndex:-1,...Ws(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}`}))),rw=J(`span`,{name:`MuiSwitch`,slot:`Thumb`})(_s(({theme:e})=>({boxShadow:(e.vars||e).shadows[1],backgroundColor:`currentColor`,boxSizing:`border-box`,border:`1px solid transparent`,width:20,height:20,borderRadius:`50%`}))),iw=v.forwardRef(function(e,t){let n=Jo({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=$C(d),p=l.input,m={slots:c,slotProps:l},[h,g]=Jc(`root`,{className:G(f.root,r),elementType:ew,externalForwardedProps:m,ownerState:d,additionalProps:{sx:s}}),[_,v]=Jc(`thumb`,{className:f.thumb,elementType:rw,externalForwardedProps:m,ownerState:d}),y=(0,W.jsx)(_,{...v}),[b,x]=Jc(`track`,{className:f.track,elementType:nw,externalForwardedProps:m,ownerState:d});return(0,W.jsxs)(h,{...g,children:[(0,W.jsx)(tw,{type:`checkbox`,icon:y,checkedIcon:y,ref:t,ownerState:d,...u,classes:{...f,root:f.switchBase},slots:{...c.switchBase&&{root:c.switchBase},...c.input&&{input:c.input}},slotProps:{...l.switchBase&&{root:typeof l.switchBase==`function`?l.switchBase(d):l.switchBase},input:Od(typeof p==`function`?p(d):p,{role:`switch`})}}),(0,W.jsx)(b,{...x})]})});function aw(e,t){let n=e.name.toLowerCase();return n===`figma-desktop`?$(t,`Cần bật MCP trong Figma Desktop`,`Enable MCP in Figma Desktop`):n===`figma`?e.state===`disabled`?$(t,`Remote OAuth · chưa được Figma duyệt`,`Remote OAuth · not approved by Figma`):`Remote OAuth`:`${e.transport} · ${e.scope}`}function ow(e,t,n){return e===`mcp-oauth-client-not-approved`&&t.toLowerCase()===`figma`?$(n,`Figma Remote chưa cho phép Piagent đăng ký OAuth. Anh 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`?$(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`?$(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`?$(n,`Đã hủy đăng nhập.`,`Sign in cancelled.`):$(n,`Không thể kết nối OAuth. Vui lòng thử lại.`,`Could not connect OAuth. Please try again.`)}function sw({sessionRef:e,connection:t,onChanged:n,compact:r=!1}){let{locale:i}=xv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,t=window.setTimeout(()=>void Kg(s.jobRef,e.signal).then(e=>{c(e),e.state===`completed`&&n()}).catch(()=>u($(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 Gg({action:r?`mcp.enable`:`mcp.disable`,sessionRef:e,connectionRef:t.connectionRef});`connections`in i?n(i):n()}catch{u($(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 Gg({action:`mcp.oauth`,sessionRef:e,connectionRef:t.connectionRef});if(`jobRef`in n)c(n);else throw Error(`mcp-oauth-job-missing`)}catch{u($(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{o(!1)}},p=async()=>{s?.state===`running`&&await Jg(s.jobRef).catch(()=>void 0),c(void 0),u(null)};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:.75,sx:{alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`},children:[t.authState===`connected`&&(0,W.jsx)(cu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,W.jsx)(WC,{}),label:$(i,`Đã kết nối`,`Connected`)}),t.oauthSupported&&t.authState!==`connected`&&t.state!==`disabled`&&(0,W.jsx)(DS,{size:`small`,variant:`outlined`,disabled:a,onClick:()=>void f(),children:`OAuth`}),t.toggleSupported&&(0,W.jsx)(Ah,{title:t.state===`disabled`?$(i,`Bật ${t.name}`,`Enable ${t.name}`):$(i,`Tắt ${t.name}`,`Disable ${t.name}`),arrow:!0,children:(0,W.jsx)(`span`,{children:(0,W.jsx)(iw,{size:r?`small`:`medium`,checked:t.state!==`disabled`,disabled:a,onChange:(e,t)=>void d(t),slotProps:{input:{"aria-label":t.state===`disabled`?$(i,`Bật ${t.name}`,`Enable ${t.name}`):$(i,`Tắt ${t.name}`,`Disable ${t.name}`)}}})})})]}),l&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,children:l}),(0,W.jsxs)(HS,{open:!!s,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,W.jsxs)(DC,{children:[t.name,` · OAuth`]}),(0,W.jsx)(bC,{children:(0,W.jsxs)(Cf,{spacing:1.25,sx:{pt:.5},children:[s?.state===`running`&&!s.authorizationUrl&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(i,`Đang chuẩn bị đăng nhập…`,`Preparing sign in…`)}),s?.authorizationUrl&&(0,W.jsx)(DS,{component:`a`,href:s.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,variant:`contained`,endIcon:(0,W.jsx)(GC,{}),children:$(i,`Mở trang đăng nhập`,`Open sign in`)}),s?.state===`completed`&&(0,W.jsx)(Z,{color:`success.main`,children:$(i,`Đã kết nối MCP`,`MCP connected`)}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,W.jsx)(Z,{color:`error`,children:ow(s.reasonCode,t.name,i)})]})}),(0,W.jsx)(mC,{children:(0,W.jsx)(DS,{color:`inherit`,onClick:()=>void p(),children:s?.state===`running`?$(i,`Hủy`,`Cancel`):$(i,`Đóng`,`Close`)})})]})]})}function cw({name:e,value:t}){return(0,W.jsxs)(Cf,{direction:`row`,sx:{justifyContent:`space-between`,gap:3,py:.65},children:[(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:e}),(0,W.jsx)(Z,{variant:`body2`,sx:{fontWeight:600},children:t})]})}function lw({title:e,label:t,icon:n,active:r,badge:i,onClick:a}){let o={border:1,borderColor:r?`primary.main`:`divider`,bgcolor:r?`action.selected`:`transparent`,color:r?`primary.main`:`text.secondary`,borderRadius:2,"&:hover":{bgcolor:`action.hover`,color:`text.primary`}},s=t?(0,W.jsx)(DS,{size:`small`,"aria-label":e,onClick:a,startIcon:n,sx:{...o,minHeight:34,maxWidth:260,px:1.15,"& .MuiButton-startIcon":{mr:.65},"& .MuiButton-startIcon svg":{fontSize:17}},children:(0,W.jsx)(X,{component:`span`,sx:{display:{xs:`none`,md:`inline`},overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})}):(0,W.jsx)(Zd,{size:`small`,"aria-label":e,onClick:a,sx:{...o,width:34,height:34},children:n});return(0,W.jsx)(Ah,{title:e,arrow:!0,children:i?(0,W.jsx)(tl,{badgeContent:i,color:`primary`,max:9999,sx:{"& .MuiBadge-badge":{height:16,minWidth:16,px:.4,fontSize:9,fontWeight:700}},children:s}):s})}function uw({session:e,snapshot:t,connections:n,locale:r,onOpenChanges:i,canSetModel:a,canSetThinking:o,canSetPermission:s,onSetModel:c,onSetThinking:l,onSetPermission:u,onConnectionsChanged:d,placement:f=`composer`}){let[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(f!==`header`)return;let e=new AbortController;return wg(e.signal).then(y).catch(()=>void 0),()=>e.abort()},[f]);let E=e=>t=>{m(e),g(t.currentTarget)},D=()=>{m(null),g(null)},O=t?.sourceChanges,k=O?.workingTree.counts.files??0,A=t?.session.permissionProfile,[j,M]=(0,v.useState)(A?.state===`known`?A.value??null:null);(0,v.useEffect)(()=>{M(null)},[e.sessionRef]),(0,v.useEffect)(()=>{A?.state===`known`&&M(A.value??null)},[A?.state,A?.value]);let N=t?.usage.context,P=N?.state===`known`,F=P?N.tokens:e.contextUsage.usedTokens,I=P?N.contextWindow:e.contextUsage.contextWindow,L=P?N.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,R=L==null?`—`:`${Math.round(L)}%`,ee=t?.session.model.state===`known`&&t.session.model.value?t.session.model.value.modelRef:``,te=_?.models.find(e=>e.modelRef===ee),ne=(0,v.useMemo)(()=>te?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[te]),z=async e=>{if(!(!e||!c)){x(!0),C(null);try{await c(e)}catch{C($(r,`Chưa thể đổi model lúc này`,`Could not change the model right now`))}finally{x(!1)}}},B=async e=>{if(l){x(!0),C(null);try{await l(e)}catch{C($(r,`Chưa thể đổi thinking lúc này`,`Could not change thinking right now`))}finally{x(!1)}}},V=async e=>{if(u){x(!0),C(null);try{await u(e),M(e)}catch{C($(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{x(!1)}}},re=e=>{if(e===`trusted-full-access`){D(),T(e);return}V(e)},ie=p===`model`?`Model & thinking`:p===`context`?`Context`:p===`connections`?$(r,`MCP & kết nối`,`MCP & connections`):p===`permission`?$(r,`Quyền`,`Access`):$(r,`Source Changes`,`Source Changes`);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(X,{sx:{display:`flex`,gap:.65,mb:f===`composer`?.8:0,px:.1,flexWrap:`wrap`,alignItems:`center`,justifyContent:f===`header`?`flex-end`:`flex-start`},children:[f===`header`&&(0,W.jsx)(lw,{active:p===`model`,onClick:E(`model`),icon:(0,W.jsx)(YS,{fontSize:`small`}),label:`${e.modelLabel??$(r,`Model session`,`Session model`)} · ${Q(e.thinkingLevel,r)}`,title:$(r,`Đổi model và mức suy luận`,`Change model and thinking level`)}),f===`header`&&(0,W.jsx)(lw,{active:p===`permission`,onClick:E(`permission`),icon:(0,W.jsx)(NC,{fontSize:`small`}),label:j?Q(j,r):$(r,`Quyền`,`Access`),title:$(r,`Đổi quyền truy cập`,`Change access level`)}),f===`composer`&&(0,W.jsx)(lw,{active:p===`context`,onClick:E(`context`),icon:(0,W.jsx)(MC,{fontSize:`small`}),title:`Context · ${R}`}),f===`composer`&&(0,W.jsx)(lw,{active:p===`connections`,onClick:E(`connections`),icon:(0,W.jsx)(iC,{fontSize:`small`}),badge:n?.summary.configured??0,title:(n?.summary.configured??0)>0?$(r,`MCP & kết nối · ${n?.summary.configured}`,`MCP & connections · ${n?.summary.configured}`):$(r,`MCP & kết nối`,`MCP & connections`)}),f===`composer`&&(0,W.jsx)(lw,{active:p===`changes`,onClick:E(`changes`),icon:(0,W.jsx)(Ph,{fontSize:`small`}),badge:k,title:`Source Changes${k?` · ${k}`:``}`})]}),(0,W.jsxs)(By,{open:p!==null,anchorEl:h,onClose:D,anchorOrigin:{vertical:f===`header`?`bottom`:`top`,horizontal:`left`},transformOrigin:{vertical:f===`header`?`top`:`bottom`,horizontal:`left`},slotProps:{paper:{sx:{width:330,maxWidth:`calc(100vw - 24px)`,borderRadius:2.5,p:1.5,mt:+(f===`header`)}}},children:[(0,W.jsx)(Z,{sx:{px:.5,pb:1,fontWeight:600},children:ie}),(0,W.jsx)(Eu,{}),p===`model`&&(0,W.jsxs)(Cf,{sx:{px:.5,pt:1},spacing:1.25,children:[(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,W.jsx)(Db,{fullWidth:!0,size:`small`,value:ee,disabled:!a||b||e.liveState===`running`,onChange:e=>void z(e.target.value),sx:{mt:.5},children:(_?.models??[]).map(e=>(0,W.jsx)(KS,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,W.jsx)(Db,{fullWidth:!0,size:`small`,value:e.thinkingLevel===`unknown`?`off`:e.thinkingLevel,disabled:!o||b||e.liveState===`running`,onChange:e=>void B(e.target.value),sx:{mt:.5},children:ne.map(e=>(0,W.jsx)(KS,{value:e,children:Q(e,r)},e))})]}),S&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`context`&&(0,W.jsxs)(X,{sx:{px:.5,pt:.75},children:[(0,W.jsx)(cw,{name:$(r,`Đã dùng`,`Used`),value:R}),(0,W.jsx)(cw,{name:`Tokens`,value:F===null?`—`:new Intl.NumberFormat().format(F)}),(0,W.jsx)(cw,{name:`Window`,value:I===null?`—`:new Intl.NumberFormat().format(I)})]}),p===`connections`&&(0,W.jsxs)(nf,{dense:!0,disablePadding:!0,sx:{pt:.5},children:[(n?.connections??[]).map(t=>(0,W.jsxs)(UC,{sx:{alignItems:`center`,gap:.5},children:[(0,W.jsx)(ff,{sx:{minWidth:38},children:(0,W.jsx)(lC,{name:t.name,size:28})}),(0,W.jsx)(Sf,{primary:t.name,secondary:aw(t,r)}),(0,W.jsx)(sw,{compact:!0,sessionRef:e.sessionRef,connection:t,onChanged:e=>d?.(e)})]},t.connectionRef)),n&&n.connections.length===0&&(0,W.jsx)(UC,{children:(0,W.jsx)(Sf,{primary:$(r,`Chưa có MCP`,`No MCP configured`)})}),!n&&(0,W.jsx)(UC,{children:(0,W.jsx)(Sf,{primary:$(r,`Đang đọc…`,`Loading…`)})})]}),p===`permission`&&(0,W.jsxs)(Cf,{sx:{px:.5,pt:1},spacing:.75,children:[[`read-only`,`workspace-write`,`trusted-full-access`].map(t=>(0,W.jsx)(DS,{variant:j===t?`contained`:`outlined`,color:t===`trusted-full-access`?`warning`:`primary`,disabled:!s||b||e.liveState===`running`,onClick:()=>re(t),sx:{justifyContent:`flex-start`},children:Q(t,r)},t)),S&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`changes`&&(0,W.jsxs)(X,{sx:{px:.5,pt:.75},children:[(0,W.jsx)(cw,{name:$(r,`Task changes`,`Task changes`),value:String(O?.task?.counts.files??0)}),(0,W.jsx)(cw,{name:$(r,`Working tree`,`Working tree`),value:String(O?.workingTree.counts.files??0)}),(0,W.jsx)(cw,{name:$(r,`Staged`,`Staged`),value:String(O?.staged.counts.files??0)}),(0,W.jsx)(DS,{fullWidth:!0,variant:`outlined`,startIcon:(0,W.jsx)(Ph,{}),sx:{mt:1},onClick:()=>{D(),i()},children:$(r,`Mở Source Changes`,`Open Source Changes`)})]})]}),(0,W.jsx)(OC,{open:w!==null,title:$(r,`Bật toàn quyền?`,`Enable full access?`),description:$(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 anh 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:$(r,`Hủy`,`Cancel`),confirmLabel:$(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>T(null),onConfirm:()=>{T(null),V(`trusted-full-access`)}})]})}var dw=sl((0,W.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`),fw=ui({themeId:Ho});function pw({active:e,snapshot:t,sessionRef:n,terminalActivities:r,refresh:i}){let{locale:a}=xv();return e===`source`?(0,W.jsx)(Dv,{snapshot:t,sessionRef:n,refreshSnapshot:i}):e===`documents`?(0,W.jsx)(Kb,{sessionRef:n}):e===`activity`?(0,W.jsx)(Qb,{snapshot:t,sessionRef:n,terminalActivities:r}):(0,W.jsxs)(Cf,{spacing:2.25,children:[(0,W.jsx)(Vx,{snapshot:t,locale:a}),(0,W.jsx)(zx,{snapshot:t,locale:a}),(0,W.jsx)(ax,{snapshot:t})]})}var mw=`min(44vw, 860px)`;function hw({open:e,active:t,snapshot:n,state:r,sessionRef:i,terminalActivities:a,onClose:o,onActive:s,refresh:c}){let{locale:l}=xv(),u=fw(Uo().breakpoints.up(`xl`)),d=n?.sourceChanges.workingTree.counts.files??0;return(0,W.jsxs)(Gd,{anchor:`right`,variant:u?`persistent`:`temporary`,open:e,onClose:o,sx:{"& .MuiDrawer-paper":{width:{xs:`100%`,sm:`min(88vw, 980px)`,xl:mw},bgcolor:`background.default`}},children:[(0,W.jsxs)(X,{sx:{position:`sticky`,top:0,zIndex:3,bgcolor:`background.paper`,borderBottom:1,borderColor:`divider`},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{minHeight:64,px:{xs:1.5,md:2},alignItems:`center`,gap:1},children:[(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:820},children:$(l,`Agent Inspector`,`Agent Inspector`)}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:$(l,`Task contract · Git truth · verifier`,`Task contract · Git truth · verifier`)})]}),(0,W.jsx)(Ah,{title:$(l,`Làm mới Inspector`,`Refresh Inspector`),children:(0,W.jsx)(Zd,{onClick:()=>void c(),children:(0,W.jsx)(Qx,{fontSize:`small`})})}),(0,W.jsx)(Zd,{"aria-label":$(l,`Đóng Inspector`,`Close Inspector`),onClick:o,children:(0,W.jsx)(dw,{})})]}),(0,W.jsxs)(pg,{value:t,onChange:(e,t)=>s(t),variant:`scrollable`,scrollButtons:`auto`,children:[(0,W.jsx)(Kh,{value:`task`,icon:(0,W.jsx)(jh,{}),iconPosition:`start`,label:n?.task?`${$(l,`Task`,`Task`)} · ${n.task.progress.completed}/${n.task.progress.total}`:$(l,`Task`,`Task`)}),(0,W.jsx)(Kh,{value:`source`,icon:(0,W.jsx)(Ph,{}),iconPosition:`start`,label:`Source Changes${d?` · ${d}`:``}`}),(0,W.jsx)(Kh,{value:`documents`,icon:(0,W.jsx)(Nh,{}),iconPosition:`start`,label:$(l,`Tài liệu`,`Documents`)}),(0,W.jsx)(Kh,{value:`activity`,icon:(0,W.jsx)(Fh,{}),iconPosition:`start`,label:`${$(l,`Activity`,`Activity`)}${n?.activity.running.length?` · ${n.activity.running.length}`:``}`})]})]}),r===`loading`?(0,W.jsxs)(Cf,{sx:{alignItems:`center`,py:12},spacing:1.5,children:[(0,W.jsx)(bu,{size:25}),(0,W.jsx)(Z,{color:`text.secondary`,children:$(l,`Đ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,W.jsx)(X,{sx:{p:{xs:1.5,sm:2.5,xl:3},maxWidth:1500,mx:`auto`,width:`100%`},children:(0,W.jsx)(Qb,{sessionRef:i,terminalActivities:a})}):r===`error`||!n||!i?(0,W.jsxs)(Cf,{sx:{p:3,maxWidth:720},spacing:2,children:[(0,W.jsx)(hS,{severity:`warning`,children:$(l,`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,W.jsx)(DS,{variant:`outlined`,onClick:()=>void c(),children:$(l,`Thử lại`,`Try again`)})]}):(0,W.jsx)(X,{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,W.jsx)(pw,{active:t,snapshot:n,sessionRef:i,terminalActivities:a,refresh:c})})]})}var gw=sl((0,W.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`),_w=sl((0,W.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`),vw=sl((0,W.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`),yw=/^(?:\p{White_Space}|\p{Cc}|\p{Default_Ignorable_Code_Point})$/u,bw=/\u001b(?:\[[0-?]*[ -/]*[@-~]|[@-_])/g;function xw(e){for(let t of e.replace(bw,``))if(!yw.test(t))return!0;return!1}function Sw(e){let t=/^\[Piagent completion gate: (CONTINUING|NOT APPROVED)\][\t ]*/i.exec(e);if(!t)return{text:e,completionGate:null};let n=t[1]?.toUpperCase()===`CONTINUING`?`continuing`:`not-approved`,r=e.indexOf(`
174
+ `&&(o+=1),o+=1;continue}i+=n,o+=1}return n.length<500&&(i.length>0||r.length>0)&&c(),n}function Yb({text:e,separator:t}){let n=(0,v.useMemo)(()=>Jb(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,W.jsx)(X,{sx:{overflowX:`auto`},children:(0,W.jsxs)(X,{component:`table`,className:`document-table`,children:[(0,W.jsx)(X,{component:`thead`,children:(0,W.jsx)(X,{component:`tr`,children:Array.from({length:a},(e,t)=>(0,W.jsx)(X,{component:`th`,children:r[t]??``},t))})}),(0,W.jsx)(X,{component:`tbody`,children:i.map((e,t)=>(0,W.jsx)(X,{component:`tr`,children:Array.from({length:a},(t,n)=>(0,W.jsx)(X,{component:`td`,children:e[n]??``},n))},t))})]})})}function Xb({document:e,extension:t}){let n=e.text??``;return Wb.has(t??``)?(0,W.jsx)(v.Suspense,{fallback:(0,W.jsx)(X,{component:`pre`,className:`document-plain`,children:n}),children:(0,W.jsx)(Ub,{children:n})}):Gb.has(t??``)?(0,W.jsx)(Yb,{text:n,separator:t===`tsv`?` `:`,`}):(0,W.jsx)(X,{component:`pre`,className:`document-plain`,children:n})}function Zb({sessionRef:e=null}){let{locale:t}=xv(),[n,r]=(0,v.useState)({state:`idle`}),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({state:`idle`}),[c,l]=(0,v.useState)(``),u=(0,v.useRef)(null);(0,v.useEffect)(()=>{let t=new AbortController;return r({state:`loading`}),a(null),s({state:`idle`}),S_(e,t.signal).then(e=>r({state:`ready`,value:e})).catch(()=>{t.signal.aborted||r({state:`error`})}),()=>t.abort()},[e]),(0,v.useEffect)(()=>{if(!i){s({state:`idle`});return}let t=new AbortController;return s({state:`loading`}),C_(e,i,t.signal).then(e=>{s({state:`ready`,value:e}),u.current?.scrollTo({top:0})}).catch(()=>{t.signal.aborted||s({state:`error`})}),()=>t.abort()},[e,i]);let d=n.value,f=c.trim().toLowerCase(),p=(0,v.useMemo)(()=>(d?.documents??[]).filter(e=>!f||e.relativePath.toLowerCase().includes(f)),[d,f]),m=(0,v.useMemo)(()=>(d?.roots??[]).map(e=>({root:e,entries:p.filter(t=>t.rootRef===e.rootRef)})).filter(e=>e.entries.length>0),[d,p]),h=p.find(e=>e.documentRef===i)??d?.documents.find(e=>e.documentRef===i);return(0,W.jsxs)(`section`,{className:`document-workspace surface`,"aria-labelledby":`documents-heading`,children:[(0,W.jsxs)(`header`,{className:`document-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(t,`Chỉ đọc · không sửa file`,`Read only · never writes`)}),(0,W.jsx)(`h2`,{id:`documents-heading`,children:$(t,`Tài liệu`,`Documents`)})]}),(0,W.jsx)(`span`,{children:d?`${d.documents.length}${d.truncated?`+`:``} ${$(t,`tài liệu`,`documents`)}`:`—`})]}),(0,W.jsxs)(`div`,{className:`document-body`,children:[(0,W.jsxs)(`aside`,{className:`document-list`,"aria-label":$(t,`Danh sách tài liệu`,`Document list`),children:[(0,W.jsx)(Lb,{size:`small`,fullWidth:!0,value:c,onChange:e=>l(e.target.value),placeholder:$(t,`Lọc theo tên hoặc thư mục…`,`Filter by name or folder…`),slotProps:{htmlInput:{"aria-label":$(t,`Lọc tài liệu`,`Filter documents`)},input:{startAdornment:(0,W.jsx)(zv,{position:`start`,children:(0,W.jsx)(Rb,{fontSize:`small`})})}}}),n.state===`loading`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Đang quét tài liệu…`,`Scanning for documents…`)}),n.state===`error`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Không đọc được danh sách tài liệu.`,`The document list could not be read.`)}),d?.state===`unavailable`&&(0,W.jsx)(`p`,{className:`document-empty`,children:Q(d.reasonCode,t)}),n.state===`ready`&&d?.state===`ready`&&m.length===0&&(0,W.jsx)(`p`,{className:`document-empty`,children:f?$(t,`Không có tài liệu nào khớp bộ lọc.`,`No document matches the filter.`):$(t,`Chưa tìm thấy tài liệu nào.`,`No documents were found.`)}),m.map(e=>(0,W.jsxs)(`div`,{className:`document-group`,children:[(0,W.jsxs)(`div`,{className:`document-group-heading`,children:[(0,W.jsx)(`strong`,{children:qb(e.root,t)}),(0,W.jsx)(`span`,{title:e.root.path,children:e.root.path})]}),e.entries.map(e=>(0,W.jsxs)(sf,{component:`button`,type:`button`,className:`document-row`,selected:e.documentRef===i,onClick:()=>a(e.documentRef),children:[(0,W.jsx)(Nh,{fontSize:`small`,"aria-hidden":`true`}),(0,W.jsxs)(`span`,{className:`document-row-copy`,children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`small`,{children:e.relativePath})]}),(0,W.jsxs)(`span`,{className:`document-row-meta`,children:[e.extension,` · `,Kb(e.sizeBytes)]})]},e.documentRef))]},e.root.rootRef)),d?.truncated&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(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,W.jsxs)(`div`,{className:`document-viewer`,ref:u,children:[!i&&(0,W.jsxs)(`div`,{className:`document-placeholder`,children:[(0,W.jsx)(Nh,{"aria-hidden":`true`}),(0,W.jsx)(Z,{variant:`body2`,children:$(t,`Chọn một tài liệu để đọc nội dung tại đây.`,`Pick a document to read it here.`)}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:$(t,`Hỗ trợ .md .txt .csv .json .yaml .docx .pdf`,`Supports .md .txt .csv .json .yaml .docx .pdf`)})]}),i&&o.state===`loading`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Đang mở tài liệu…`,`Opening the document…`)}),i&&o.state===`error`&&(0,W.jsx)(`p`,{className:`document-empty`,children:$(t,`Không mở được tài liệu này.`,`This document could not be opened.`)}),o.state===`ready`&&o.value&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`document-toolbar`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:o.value.name??h?.name??`—`}),(0,W.jsx)(`small`,{children:o.value.relativePath??h?.relativePath??``})]}),(0,W.jsxs)(`div`,{className:`document-badges`,children:[o.value.format&&(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:o.value.format}),o.value.truncated&&(0,W.jsx)(cu,{size:`small`,color:`warning`,variant:`outlined`,label:$(t,`Đã cắt bớt`,`Truncated`)}),o.value.redacted&&(0,W.jsx)(cu,{size:`small`,color:`warning`,variant:`outlined`,label:$(t,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`)})]})]}),o.value.state===`unavailable`?(0,W.jsx)(`p`,{className:`document-empty`,children:Q(o.value.reasonCode,t)}):(0,W.jsx)(`article`,{className:`document-content`,children:(0,W.jsx)(Xb,{document:o.value,extension:h?.extension})})]})]})]})]})}function Qb(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 $b(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 ex(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=>$b(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=>Qb(e,r));return{rows:[...c,...s,...t],terminalCount:s.length,runningCount:c.length}}function tx(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 nx(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 rx({activity:e,preview:t,onPreview:n,locale:r}){return(0,W.jsxs)(`article`,{className:`activity-row`,children:[(0,W.jsx)(`span`,{className:`activity-state tone-${fv(e.state)}`,"aria-label":e.state}),(0,W.jsxs)(`div`,{className:`activity-copy`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.label}),(0,W.jsx)(`span`,{children:e.kind})]}),(0,W.jsx)(`p`,{children:e.preview||$(r,`Không có mô tả ngắn`,`No short description`)}),t&&(0,W.jsxs)(`div`,{className:`log-preview ${t.state===`error`?`error-state`:``}`,children:[t.state===`loading`?$(r,`Đang tải log ngắn…`,`Loading log preview…`):t.state===`error`?$(r,`Log preview không còn sẵn sàng.`,`Log preview is no longer available.`):t.value?.preview??`${$(r,`Không có nội dung log`,`No log content`)} · ${t.value?.reasonCode??`unavailable`}`,t.value?.truncated&&(0,W.jsx)(`small`,{children:$(r,`Preview đã được rút gọn`,`Preview truncated`)})]})]}),(0,W.jsxs)(`div`,{className:`activity-result`,children:[(0,W.jsx)(`strong`,{children:tx(e,r)}),(0,W.jsx)(`span`,{children:nx(e,r)}),e.logRef&&n&&(0,W.jsx)(`button`,{type:`button`,onClick:n,"aria-expanded":!!t,children:t?$(r,`Ẩn log`,`Hide log`):$(r,`Xem log`,`View log`)})]})]})}function ix({snapshot:e,sessionRef:t,terminalActivities:n=[],liveActivities:r}){let{locale:i}=xv(),[a,o]=(0,v.useState)({}),s=e?.activity.running??[],c=e?.activity.recent??[],{rows:l,terminalCount:u,runningCount:d}=ex(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?Ug(t,e.activityRef):s_(e.activityRef)).then(t=>o(n=>({...n,[e.activityRef]:{state:`ready`,value:t}}))).catch(()=>o(t=>({...t,[e.activityRef]:{state:`error`}})))};return(0,W.jsxs)(`section`,{className:`activity-panel surface`,"aria-labelledby":`activity-title`,children:[(0,W.jsxs)(`header`,{className:`panel-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Activity`}),(0,W.jsx)(`h2`,{id:`activity-title`,children:$(i,`Tool, command và kết quả lượt chạy`,`Tools, commands, and operation outcomes`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{className:`running-count`,children:[d,` `,$(i,`đang chạy`,`running`)]}),(0,W.jsxs)(`span`,{children:[c.length+u,` `,$(i,`gần đây`,`recent`)]})]})]}),(0,W.jsxs)(`div`,{className:`activity-list`,children:[l.map(e=>(0,W.jsx)(rx,{activity:e,preview:a[e.activityRef],onPreview:e.logRef?()=>f(e):void 0,locale:i},e.activityRef)),l.length===0&&(0,W.jsx)(`div`,{className:`activity-empty`,children:$(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,W.jsx)(`footer`,{className:`panel-footnote`,children:$(i,`Timeline đã được rút gọn theo giới hạn local.`,`The timeline was truncated to local limits.`)})]})}function ax(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 ox(e,t=`vi`){return e.state!==`known`||e.tokens===null||e.percent===null?t===`vi`?`Context chưa xác định`:`Unknown context`:`${ax(e.tokens,t)} / ${ax(e.contextWindow,t)} · ${e.percent.toFixed(1)}%`}function sx(e,t=`vi`){return e.state===`known`?`↑ ${ax(e.input,t)} · ↓ ${ax(e.output,t)}`:t===`vi`?`Không có dữ liệu`:`No data`}function cx(e,t=`vi`){return e?e.state===`passed`?e.exitCodeExact?`Pass · exit ${e.exitCode??0}`:t===`vi`?`Pass · exit chưa xác định`:`Pass · unknown exit`:e.state===`failed`?e.exitCodeExact?`Fail · exit ${e.exitCode??`?`}`:t===`vi`?`Fail · exit chưa xác định`:`Fail · unknown exit`:e.state===`stale`?e.staleFilesKnown?`Stale · ${e.staleByPaths.length} file`:t===`vi`?`Stale · file chưa xác định`:`Stale · unknown files`:e.state.replaceAll(`-`,` `):t===`vi`?`Chưa có verifier gần nhất`:`No recent verifier`}function lx(e,t=`vi`){return e.task?.blocker??e.task?.reasonCode??e.verification.reasonCode??e.health.issues.find(e=>e.severity===`error`)?.message??(t===`vi`?`Không có blocker được ghi nhận`:`No recorded blocker`)}function ux({kicker:e,title:t,children:n}){return(0,W.jsxs)(`section`,{className:`evidence-card surface`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:e}),(0,W.jsx)(`h3`,{children:t}),n]})}function dx({snapshot:e}){let{locale:t}=xv(),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,W.jsxs)(`section`,{className:`evidence-section`,"aria-labelledby":`evidence-title`,children:[(0,W.jsxs)(`header`,{className:`section-title-row`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Completion evidence`}),(0,W.jsx)(`h2`,{id:`evidence-title`,children:$(t,`Verifier, usage và handoff`,`Verifier, usage, and handoff`)})]}),(0,W.jsx)(`span`,{children:lx(e,t)})]}),(0,W.jsxs)(`div`,{className:`evidence-grid`,children:[(0,W.jsx)(ux,{kicker:$(t,`Verifier gần nhất`,`Latest verifier`),title:cx(n,t),children:n?(0,W.jsxs)(`dl`,{className:`evidence-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Command`}),(0,W.jsx)(`dd`,{title:n.command,children:n.command})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Exact`}),(0,W.jsx)(`dd`,{children:n.exact?$(t,`Có`,`Yes`):$(t,`Không`,`No`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Tree digest`}),(0,W.jsx)(`dd`,{title:n.treeDigest??void 0,children:pv(n.treeDigest)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`File làm stale`,`Stale files`)}),(0,W.jsx)(`dd`,{children:n.staleFilesKnown?n.staleByPaths.length:$(t,`Chưa biết`,`Unknown`)})]})]}):(0,W.jsx)(`p`,{className:`card-empty`,children:e.verification.reasonCode?Q(e.verification.reasonCode,t):$(t,`Task chưa chạy verifier.`,`The task has not run a verifier.`)})}),(0,W.jsxs)(ux,{kicker:`Token & context`,title:ox(r,t),children:[(0,W.jsx)(`div`,{className:`context-meter`,role:`progressbar`,"aria-label":$(t,`Mức sử dụng context`,`Context usage`),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":o,children:(0,W.jsx)(`span`,{style:{width:`${o}%`}})}),(0,W.jsxs)(`dl`,{className:`evidence-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Turn gần nhất`,`Latest turn`)}),(0,W.jsx)(`dd`,{children:sx(e.usage.latestTurn,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Task total`}),(0,W.jsx)(`dd`,{children:sx(e.usage.taskTotal,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Session total`}),(0,W.jsx)(`dd`,{children:sx(e.usage.sessionTotal,t)})]})]})]}),(0,W.jsxs)(ux,{kicker:`Continuation budget`,title:Q(i.state,t),children:[(0,W.jsxs)(`dl`,{className:`budget-grid`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Còn lại`,`Remaining`)}),(0,W.jsx)(`dd`,{children:ax(i.remaining,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Đã dùng`,`Used`)}),(0,W.jsx)(`dd`,{children:ax(i.consumed,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Tối đa`,`Maximum`)}),(0,W.jsx)(`dd`,{children:ax(i.maximum,t)})]})]}),i.reasonCode&&(0,W.jsx)(`p`,{className:`card-note`,children:Q(i.reasonCode,t)})]}),(0,W.jsx)(ux,{kicker:`Handoff`,title:a?Q(a.state,t):$(t,`Chưa có handoff`,`No handoff`),children:a?(0,W.jsxs)(`div`,{className:`handoff-copy`,children:[(0,W.jsx)(`p`,{children:a.summary}),a.blocker&&(0,W.jsxs)(`div`,{className:`handoff-blocker`,children:[(0,W.jsx)(`strong`,{children:`Blocker`}),(0,W.jsx)(`span`,{children:a.blocker})]}),a.nextSafeAction&&(0,W.jsxs)(`div`,{className:`next-action`,children:[(0,W.jsx)(`strong`,{children:$(t,`Bước an toàn tiếp theo`,`Next safe action`)}),(0,W.jsx)(`span`,{children:a.nextSafeAction})]})]}):(0,W.jsx)(`p`,{className:`card-empty`,children:$(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 fx=16384;function px(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 mx(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(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,fx),truncated:e.truncated||n.length>fx})}else if(e===`message.thinking-state`&&typeof a==`string`){let e=t.get(a);if(!e)continue;t.set(a,{...e,thinking:i.state!==`completed`})}else[`message.completed`,`message.failed`].includes(String(e))&&typeof a==`string`&&t.delete(a);[`activity.started`,`activity.progress`,`activity.finished`,`activity.failed`,`activity.blocked`,`activity.aborted`].includes(String(e))&&typeof r.toolCallId==`string`&&typeof i.activityRef==`string`&&typeof i.toolName==`string`&&n.set(r.toolCallId,{toolCallId:r.toolCallId,activityRef:i.activityRef,toolName:i.toolName,state:String(i.state??`unknown`)})}return{assistants:[...t.values()].slice(-2),tools:[...n.values()].slice(-8)}}var hx=/^(?:\p{White_Space}|\p{Cc}|\p{Default_Ignorable_Code_Point})$/u,gx=/\u001b(?:\[[0-?]*[ -/]*[@-~]|[@-_])/g;function _x(e){for(let t of e.replace(gx,``))if(!hx.test(t))return!0;return!1}function vx(e){let t=/^\[Piagent completion gate: (CONTINUING|NOT APPROVED)\][\t ]*/i.exec(e);if(!t)return{text:e,completionGate:null};let n=t[1]?.toUpperCase()===`CONTINUING`?`continuing`:`not-approved`,r=e.indexOf(`
175
175
 
176
- `,t[0].length);return{text:r<0?``:e.slice(r+2).trimStart(),completionGate:n}}function Cw(e){let t=Sw(e);return t.completionGate===null&&xw(t.text)?t.text:null}function ww(e){let t=[],n=new Map;for(let r of e){if(r.role===`user`){n.clear(),t.push(r);continue}if(r.role!==`assistant`||r.toolCalls.length>0)continue;let e=Cw(r.content.text??``);if(!e)continue;let i=n.get(e.trim());i===void 0?(n.set(e.trim(),t.length),t.push(r)):t[i]=r}return t}var Tw=(0,v.lazy)(async()=>({default:(await Lb(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-CxeZqTte.js`);return{MarkdownMessage:e}},[])).MarkdownMessage}));function Ew({children:e}){return(0,W.jsx)(v.Suspense,{fallback:(0,W.jsx)(Z,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.75},children:e}),children:(0,W.jsx)(Tw,{children:e})})}function Dw({attachments:e,locale:t}){return e.length?(0,W.jsx)(Cf,{spacing:.75,sx:{mb:1},"aria-label":$(t,`File đã gửi`,`Sent files`),children:e.map((e,n)=>{let r=`sourceBytes`in e?mx(e,t):`${e.kind===`document`?$(t,`Tài liệu`,`Document`):e.kind===`image`?$(t,`Ảnh`,`Image`):`File`}${e.truncated?` · ${$(t,`đã cắt bớt`,`truncated`)}`:``}`;return(0,W.jsxs)(Mc,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:1.1,minWidth:220,maxWidth:440,px:1.2,py:1,borderRadius:2,bgcolor:`background.paper`},children:[e.kind===`image`?(0,W.jsx)(vw,{color:`action`}):(0,W.jsx)(gw,{color:`action`}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{variant:`body2`,noWrap:!0,sx:{fontWeight:650},children:e.displayName}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:r})]})]},`${e.displayName}:${n}`)})}):null}function Ow({item:e,locale:t}){let n=e.role===`assistant`?Cw(e.content.text??``):e.content.text;return e.role===`user`?(0,W.jsxs)(X,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:3,px:2,py:1.4},children:[(0,W.jsx)(Dw,{attachments:e.attachments??[],locale:t}),n&&(0,W.jsx)(Z,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:n}),(e.content.redacted||e.content.truncated)&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:e.content.redacted?$(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):$(t,`Nội dung đã rút gọn`,`Content truncated`)})]}):n?(0,W.jsxs)(X,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0,flex:1},children:[(0,W.jsx)(Z,{sx:{fontWeight:600},children:`Piagent`}),n&&(0,W.jsx)(X,{sx:{mt:.6},children:(0,W.jsx)(Ew,{children:n})}),(e.content.redacted||e.content.truncated)&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.8},children:e.content.redacted?$(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):$(t,`Nội dung đã rút gọn`,`Content truncated`)})]})]}):null}function kw({locale:e,onOpenActivity:t}){return(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,role:`status`,"aria-live":`polite`,sx:{alignItems:`center`,color:`text.secondary`,py:.75},children:[(0,W.jsx)(bu,{size:19,thickness:4}),(0,W.jsx)(Z,{variant:`body2`,sx:{fontWeight:600},children:$(e,`Piagent đang xử lý…`,`Piagent is working…`)}),t&&(0,W.jsx)(DS,{size:`small`,variant:`text`,onClick:t,sx:{ml:`auto !important`},children:$(e,`Xem Activity`,`View Activity`)})]})}function Aw(e,t){let n=e?.trim(),r=t.trim();return!!(n&&r&&(n===r||n.startsWith(`/`)&&n.endsWith(` ${r}`)))}function jw({sessionRef:e,sessionRevision:t,live:n,approvals:r,locale:i,onOpenActivity:a}){let[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=n?.complete?`${n.operationRef??`unknown`}:${n.user}:${n.assistant.length}`:null;(0,v.useEffect)(()=>{let t=new AbortController;l(!0),p(!1),h(null);let r=window.setTimeout(()=>{Fg(e,null,50,t.signal).then(e=>{if(s(e),g&&n){let t=!n.user||e.items.some(e=>e.role===`user`&&Aw(e.content.text,n.user)),r=!n.assistant||e.items.some(e=>e.role===`assistant`&&e.content.text?.trim()===n.assistant.trim());t&&r&&h(g)}}).catch(()=>{t.signal.aborted||p(!0)}).finally(()=>{t.signal.aborted||l(!1)})},g?100:0);return()=>{window.clearTimeout(r),t.abort()}},[e,t,g,n]);let _=o?.state===`ready`?o.items:[],y=(0,v.useMemo)(()=>ww(_),[_]),b=!!(n&&(!n.complete||m!==g)),x=(0,v.useMemo)(()=>!n?.user||!_.length?!1:Aw([..._].reverse().find(e=>e.role===`user`)?.content.text,n.user),[_,n?.user]),S=async()=>{let t=o?.page.nextBeforeCursor;if(!(!t||u)){d(!0);try{let n=await Fg(e,t,o.page.limit);s(e=>e?{...e,items:sx(e.items,n.items),page:n.page}:n)}catch{p(!0)}finally{d(!1)}}};return(0,W.jsxs)(Cf,{spacing:2.5,children:[o?.page.hasOlder&&(0,W.jsx)(X,{sx:{textAlign:`center`},children:(0,W.jsx)(DS,{size:`small`,variant:`text`,startIcon:u?(0,W.jsx)(bu,{size:14}):(0,W.jsx)(Ih,{}),disabled:u,onClick:()=>void S(),children:$(i,`Tải tin cũ hơn`,`Load older messages`)})}),c&&!o&&(0,W.jsx)(X,{sx:{py:5,textAlign:`center`},children:(0,W.jsx)(bu,{size:22})}),f&&!o&&(0,W.jsx)(hS,{severity:`warning`,icon:(0,W.jsx)(_w,{}),children:$(i,`Chưa tải được lịch sử session. Anh vẫn có thể thử lại bằng nút làm mới.`,`Session history could not be loaded. You can retry with Refresh.`)}),y.map(e=>(0,W.jsx)(Ow,{item:e,locale:i},e.messageRef)),(0,W.jsx)(Cx,{sessionRef:e,approvalRefs:r?.pending.map(e=>e.approvalRef)??[]}),b&&n&&(0,W.jsxs)(W.Fragment,{children:[n.user&&!x&&(0,W.jsxs)(X,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:3,px:2,py:1.4},children:[(0,W.jsx)(Dw,{attachments:n.attachments,locale:i}),(0,W.jsx)(Z,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:n.user})]}),!n.complete&&!n.error&&(0,W.jsx)(kw,{locale:i,onOpenActivity:a}),n.complete&&!n.error&&Cw(n.assistant||``)&&(0,W.jsxs)(X,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0,flex:1},children:[(0,W.jsx)(Z,{sx:{fontWeight:600},children:`Piagent`}),(0,W.jsx)(X,{sx:{mt:.6},children:(0,W.jsx)(Ew,{children:Cw(n.assistant||``)})})]})]})]})]})}var Mw=sl((0,W.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`),Nw=sl((0,W.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`),Pw=sl((0,W.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`),Fw=sl((0,W.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`),Iw=sl([(0,W.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,W.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`),Lw=sl((0,W.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`),Rw=sl((0,W.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 zw({catalog:e,refresh:t}){let{locale:n}=xv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!r||r.state!==`running`)return;let e=new AbortController,a=window.setTimeout(()=>{Eg(r.jobRef,e.signal).then(e=>{i(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||u($(n,`Mất kết nối với luồng OAuth`,`OAuth flow disconnected`))})},750);return()=>{e.abort(),window.clearTimeout(a)}},[r?.jobRef,r?.generatedAt,r?.state,n]),(0,v.useEffect)(()=>o(``),[r?.prompt?.promptRef]);let d=async e=>{c(!0),u(null);try{i(await Og(e))}catch{u($(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 kg(r.jobRef,r.prompt.promptRef,a))}catch{u($(n,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{c(!1)}}},p=async()=>{r?.state===`running`&&await Ag(r.jobRef).catch(()=>void 0),i(void 0),u(null)},m=r?.events.slice(-4)??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,W.jsx)(Mc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,W.jsx)(lC,{name:e.name,size:38}),(0,W.jsx)(Z,{sx:{flex:1,fontWeight:800},children:e.name}),e.state===`connected`&&(0,W.jsx)(cu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,W.jsx)(Rw,{}),label:$(n,`Đã kết nối`,`Connected`)}),(0,W.jsx)(DS,{size:`small`,variant:`outlined`,disabled:s,onClick:()=>void d(e.providerRef),children:e.state===`connected`?$(n,`Kết nối lại`,`Reconnect`):$(n,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(n,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),l&&!r&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:l}),(0,W.jsxs)(HS,{open:!!r,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,W.jsx)(DC,{children:r?.providerName??`OAuth`}),(0,W.jsx)(bC,{children:(0,W.jsxs)(Cf,{spacing:1.25,sx:{pt:.5},children:[r?.state===`completed`&&(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsx)(Rw,{color:`success`}),(0,W.jsx)(Z,{children:$(n,`Đã kết nối`,`Connected`)})]}),m.map(e=>(0,W.jsxs)(X,{children:[e.message&&(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,W.jsx)(Z,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:800,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,W.jsx)(DS,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,W.jsx)(GC,{}),children:$(n,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,W.jsx)(DS,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??$(n,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),r?.prompt&&(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`body2`,sx:{mb:1},children:r.prompt.message}),r.prompt.type===`select`?(0,W.jsx)(Db,{fullWidth:!0,size:`small`,value:a,onChange:e=>o(e.target.value),children:r.prompt.options.map(e=>(0,W.jsx)(KS,{value:e.id,children:e.label},e.id))}):(0,W.jsx)(Mb,{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,W.jsx)(Z,{color:`error`,variant:`body2`,children:Q(r.reasonCode??r.state,n)}),l&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`body2`,children:l})]})}),(0,W.jsxs)(mC,{children:[(0,W.jsx)(DS,{color:`inherit`,onClick:()=>void p(),children:r?.state===`running`?$(n,`Hủy`,`Cancel`):$(n,`Đóng`,`Close`)}),r?.prompt&&(0,W.jsx)(DS,{variant:`contained`,disabled:s||!a,onClick:()=>void f(),children:$(n,`Tiếp tục`,`Continue`)})]})]})]})}var Bw=sl((0,W.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`),Vw=sl([(0,W.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,W.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`),Hw=sl((0,W.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 Uw({icon:e,title:t,detail:n,children:r}){return(0,W.jsxs)(Mc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,W.jsx)(X,{sx:{width:38,height:38,borderRadius:2,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{sx:{fontWeight:820},children:t}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function Ww({children:e}){return(0,W.jsx)(Cf,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function Gw({session:e,options:t,connections:n,onCompleted:r}){let{locale:i}=xv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(e?.sessionRevision??``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``);(0,v.useEffect)(()=>{f(e?.sessionRevision??``),c(void 0),u(null)},[e?.sessionRef]),(0,v.useEffect)(()=>{e?.sessionRevision&&f(e.sessionRevision)},[e?.sessionRevision]);let w=a||!e||!d||e.liveState===`running`||e.liveState===`waiting-approval`,T=t?.profiles??[],E=(0,v.useMemo)(()=>(n?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[n]),D=async(t,n=null,a=!1)=>{if(!(!e||!d)){o(!0),u(null);try{let i=await qg({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($(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:w};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Z,{component:`h1`,variant:`h1`,sx:{mb:.75},children:$(i,`Điều khiển project`,`Project controls`)}),(0,W.jsx)(Z,{color:`text.secondary`,sx:{mb:2.5},children:$(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,W.jsx)(Mc,{variant:`outlined`,sx:{p:2,borderRadius:2.5,mb:2},children:(0,W.jsx)(Z,{color:`text.secondary`,children:$(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,W.jsxs)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,W.jsxs)(Uw,{icon:(0,W.jsx)(Hw,{color:`primary`}),title:$(i,`Runtime & token`,`Runtime & tokens`),detail:$(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,W.jsxs)(Ww,{children:[(0,W.jsx)(DS,{...k,onClick:()=>void D(`runtime.status`),children:`Pi status`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`runtime.inspector`),children:`Inspector`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`orchestration.status`),children:`Orchestration`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`usage.live`),children:`Usage live`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`usage.history`),children:`History`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`usage.logs`),children:`Logs`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`usage.efficiency`),children:`Efficiency`})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Mb,{size:`small`,fullWidth:!0,label:$(i,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:b,onChange:e=>x(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,W.jsx)(DS,{...k,sx:{whiteSpace:`nowrap`},onClick:()=>void D(`usage.preflight`,b.trim()||null),children:`Preflight`})]})]}),(0,W.jsxs)(Uw,{icon:(0,W.jsx)(Vw,{color:`primary`}),title:$(i,`Onboarding & profile`,`Onboarding & profile`),detail:$(i,`Kiểm tra project và áp dụng profile dùng chung có kiểm soát.`,`Inspect the project and apply a controlled reusable profile.`),children:[(0,W.jsxs)(Ww,{children:[(0,W.jsx)(DS,{...k,onClick:()=>void D(`onboarding.status`),children:`Onboard status`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`onboarding.profile`),children:`Profile check`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`onboarding.tech`),children:`Tech check`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`profile.status`),children:$(i,`Profile hiện tại`,`Current profile`)})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Db,{size:`small`,fullWidth:!0,displayEmpty:!0,value:h,onChange:e=>g(e.target.value),disabled:w,renderValue:e=>e?T.find(t=>t.id===e)?.displayName??e:$(i,`Chọn profile…`,`Select profile…`),children:T.map(e=>(0,W.jsx)(KS,{value:e.id,children:e.displayName},e.id))}),(0,W.jsx)(DS,{...k,disabled:w||!h,sx:{whiteSpace:`nowrap`},onClick:()=>O(`profile.apply`,h,$(i,`Áp dụng profile?`,`Apply profile?`),$(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:$(i,`Áp dụng`,`Apply`)}),(0,W.jsx)(DS,{...k,onClick:()=>O(`profile.auto`,null,$(i,`Tự nhận diện profile?`,`Auto-detect profile?`),$(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,W.jsxs)(Uw,{icon:(0,W.jsx)(Bw,{color:`primary`}),title:$(i,`Context engine`,`Context engine`),detail:$(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,W.jsxs)(Ww,{children:[(0,W.jsx)(DS,{...k,onClick:()=>void D(`context.status`),children:`Index status`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`context.efficiency`),children:`Efficiency`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`context.impact`),children:`Impact`}),(0,W.jsx)(DS,{...k,color:`warning`,onClick:()=>O(`context.rebuild`,null,$(i,`Rebuild context index?`,`Rebuild context index?`),$(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,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Mb,{size:`small`,fullWidth:!0,label:$(i,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:_,onChange:e=>y(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,W.jsx)(DS,{...k,disabled:w||!_.trim(),onClick:()=>void D(`context.search`,_.trim()),children:`Search`}),(0,W.jsx)(DS,{...k,disabled:w||!_.trim(),onClick:()=>void D(`context.pack`,_.trim()),children:`Pack`}),(0,W.jsx)(DS,{...k,color:`warning`,onClick:()=>O(`context.compact`,_.trim()||null,$(i,`Compact context bằng model?`,`Compact context with the model?`),$(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,W.jsx)(Uw,{icon:(0,W.jsx)(Fw,{color:`primary`}),title:$(i,`Memory`,`Memory`),detail:$(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,W.jsx)(Ww,{children:(0,W.jsx)(DS,{...k,onClick:()=>void D(`memory.status`),children:$(i,`Kiểm tra memory`,`Check memory`)})})}),(0,W.jsxs)(Uw,{icon:(0,W.jsx)(iC,{color:`primary`}),title:$(i,`MCP governance`,`MCP governance`),detail:$(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,W.jsxs)(Ww,{children:[(0,W.jsx)(DS,{...k,onClick:()=>void D(`mcp.status`),children:`MCP status`}),(0,W.jsx)(DS,{...k,onClick:()=>void D(`mcp.doctor`),children:`Doctor`})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Db,{size:`small`,fullWidth:!0,displayEmpty:!0,value:S,onChange:e=>C(e.target.value),disabled:w,renderValue:e=>e||$(i,`Chọn MCP…`,`Select MCP…`),children:E.map(e=>(0,W.jsx)(KS,{value:e.name,children:e.name},e.connectionRef))}),(0,W.jsx)(DS,{...k,disabled:w||!S,onClick:()=>void D(`mcp.detail`,S),children:`Detail`}),(0,W.jsx)(DS,{...k,disabled:w||!S,onClick:()=>O(`mcp.approve`,S,$(i,`Phê duyệt MCP?`,`Approve MCP?`),$(i,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,W.jsx)(DS,{...k,disabled:w||!S,color:`warning`,onClick:()=>O(`mcp.reject`,S,$(i,`Từ chối MCP?`,`Reject MCP?`),$(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,W.jsx)(DS,{...k,disabled:w||!S,color:`warning`,onClick:()=>O(`mcp.reset`,S,$(i,`Reset quyết định MCP?`,`Reset MCP decision?`),$(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,W.jsx)(Mc,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:2.5},children:a?(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsx)(bu,{size:18}),(0,W.jsx)(Z,{children:$(i,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,W.jsx)(WC,{color:s?.state===`settled`?`success`:`warning`}),(0,W.jsx)(Z,{sx:{fontWeight:800},children:s?s.action:$(i,`Không hoàn tất`,`Not completed`)}),s&&(0,W.jsx)(cu,{size:`small`,color:s.state===`settled`?`success`:`warning`,variant:`outlined`,label:s.resultCode}),s?.effect===`read-only`&&(0,W.jsx)(cu,{size:`small`,color:s.modelCallObserved?`warning`:`success`,variant:`outlined`,label:s.modelCallObserved?$(i,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),l&&(0,W.jsx)(Z,{color:`error`,variant:`body2`,sx:{mt:1},children:l}),s?.outputs.map((e,t)=>(0,W.jsx)(X,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1.5,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,W.jsx)(OC,{open:p!==null,title:p?.title??``,description:p?.description??``,cancelLabel:$(i,`Hủy`,`Cancel`),confirmLabel:$(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)}})]})}function Kw(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function qw({children:e}){return(0,W.jsx)(Z,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function Jw({icon:e,title:t,detail:n,action:r}){return(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{sx:{fontWeight:760},children:t}),n&&(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function Yw(){let{locale:e,colorMode:t,setLocale:n,setColorMode:r}=xv();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qw,{children:$(e,`Giao diện`,`Appearance`)}),(0,W.jsxs)(Mc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:[(0,W.jsx)(Jw,{icon:(0,W.jsx)(Pw,{color:`primary`}),title:$(e,`Ngôn ngữ`,`Language`),action:(0,W.jsxs)(op,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&n(t),children:[(0,W.jsx)(ep,{value:`vi`,children:`VI`}),(0,W.jsx)(ep,{value:`en`,children:`EN`})]})}),(0,W.jsx)(Eu,{}),(0,W.jsx)(Jw,{icon:t===`dark`?(0,W.jsx)(Bh,{color:`primary`}):(0,W.jsx)(zh,{color:`primary`}),title:$(e,`Chủ đề`,`Theme`),action:(0,W.jsxs)(op,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&r(t),children:[(0,W.jsx)(ep,{value:`light`,children:$(e,`Sáng`,`Light`)}),(0,W.jsx)(ep,{value:`dark`,children:$(e,`Tối`,`Dark`)})]})})]})]})}function Xw({options:e,snapshot:t,activeModel:n,observedProvider:r}){let{locale:i}=xv(),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,W.jsx)(Lw,{color:`primary`}),title:a?.route===`codex-first`?`Codex Web Search`:$(i,`Tìm kiếm web`,`Web search`),detail:a?.route===`codex-first`?$(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`?$(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.`):$(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`?$(i,`Ưu tiên Codex`,`Codex first`):a?.state===`configured`?$(i,`Đã cấu hình`,`Configured`):$(i,`Chưa có`,`Unavailable`),ready:a?.state===`configured`},{key:`vision`,icon:(0,W.jsx)(Mw,{color:`primary`}),title:d?`Codex Vision`:$(i,`Vision của model`,`Model vision`),detail:u===!0?$(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?$(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.`):$(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?$(i,`Đang dùng`,`Active`):u===!1?$(i,`Không hỗ trợ`,`Unsupported`):$(i,`Chưa rõ`,`Unknown`),ready:u===!0}];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Z,{variant:`h2`,sx:{mt:3,mb:.5},children:$(i,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:$(i,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,W.jsx)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:f.map(e=>(0,W.jsx)(Mc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,W.jsx)(X,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:2,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:800},children:e.title}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,W.jsx)(cu,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function Zw({options:e,auth:t,refreshAuth:n,session:r,snapshot:i,onSetModel:a,onSetThinking:o}){let{locale:s}=xv(),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=i?.session.model.state===`known`?i.session.model.value:null,p=(0,v.useMemo)(()=>{let t=new Map;for(let n of e?.models??[])t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t.entries()]},[e]),m=f?.modelRef??``,h=e?.models.find(e=>e.modelRef===m),g=h?m:``,_=f?.displayName??r?.modelLabel??`—`,y=h?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],b=async e=>{if(e){l(!0),d(null);try{await e()}catch{d($(s,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{l(!1)}}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qw,{children:$(s,`Nhà cung cấp & model`,`Providers & models`)}),r&&(0,W.jsxs)(Mc,{variant:`outlined`,sx:{p:2.25,borderRadius:2.5,mb:2},children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,W.jsx)(lC,{name:f?.provider??r.modelLabel??`model`,size:38}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:700},children:$(s,`Model của session hiện tại`,`Current session model`)}),(0,W.jsxs)(Z,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[_,` · `,Q(r.thinkingLevel,s)]})]}),(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:$(s,`Đang dùng`,`In use`)})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,W.jsxs)(X,{sx:{flex:1},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,W.jsx)(Db,{fullWidth:!0,size:`small`,value:g,displayEmpty:!0,renderValue:t=>t?e?.models.find(e=>e.modelRef===t)?.displayName??_:_,disabled:c||!a||r.liveState===`running`,onChange:e=>void b(()=>a?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,W.jsx)(KS,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,W.jsxs)(X,{sx:{width:{md:220}},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,W.jsx)(Db,{fullWidth:!0,size:`small`,value:r.thinkingLevel===`unknown`?`off`:r.thinkingLevel,disabled:c||!o||r.liveState===`running`,onChange:e=>void b(()=>o?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:y.map(e=>(0,W.jsx)(KS,{value:e,children:Q(e,s)},e))})]})]}),u&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:u})]}),(0,W.jsx)(Xw,{options:e,snapshot:i,activeModel:h,observedProvider:f?.provider}),(0,W.jsx)(Z,{variant:`h2`,sx:{mt:3,mb:.5},children:$(s,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:$(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,W.jsx)(zw,{catalog:t,refresh:n}),(0,W.jsx)(Z,{variant:`h2`,sx:{mt:3,mb:.5},children:$(s,`Danh mục model`,`Model catalog`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:$(s,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,W.jsx)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:p.map(([e,t])=>(0,W.jsxs)(Mc,{variant:`outlined`,sx:{p:1.5,borderRadius:2},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,W.jsx)(lC,{name:e,size:32}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{noWrap:!0,sx:{fontWeight:700,textTransform:`capitalize`},children:e}),(0,W.jsxs)(Z,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,W.jsx)(cu,{size:`small`,color:`success`,variant:`outlined`,label:$(s,`Sẵn sàng`,`Ready`)})]}),(0,W.jsxs)(X,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&p.length===0&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(s,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function Qw({value:e,loading:t,sessionRef:n,onChanged:r}){let{locale:i}=xv();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qw,{children:$(i,`MCP & kết nối`,`MCP & connections`)}),t?(0,W.jsx)(bu,{size:22}):(0,W.jsxs)(Cf,{spacing:1,children:[(e?.connections??[]).map(e=>(0,W.jsx)(Mc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,W.jsx)(lC,{name:e.name,size:38}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{noWrap:!0,sx:{fontWeight:800},children:e.name}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:aw(e,i)})]}),n?(0,W.jsx)(sw,{sessionRef:n,connection:e,onChanged:r}):(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:$(i,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(i,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function $w({snapshot:e,session:t,onSetPermission:n}){let{locale:r}=xv(),i=e?.session.permissionProfile,[a,o]=(0,v.useState)(i?.state===`known`?i.value??null:null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null);(0,v.useEffect)(()=>{o(null)},[t?.sessionRef]),(0,v.useEffect)(()=>{i?.state===`known`&&o(i.value??null)},[i?.state,i?.value]);let p=async e=>{if(n){c(!0),u(null);try{await n(e),o(e)}catch{u($(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{c(!1)}}},m=e=>{if(e===`trusted-full-access`){f(e);return}p(e)},h=[{mode:`read-only`,detail:$(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:$(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:$(r,`Quyền rộng hơn trong runtime; xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`Broader runtime access; deleting or sending data externally still requires separate confirmation.`)}];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qw,{children:$(r,`Quyền truy cập`,`Access`)}),(0,W.jsx)(Z,{variant:`h2`,sx:{mb:.5},children:$(r,`Hồ sơ quyền`,`Permission profile`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:$(r,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,W.jsx)(Mc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:h.map((e,i)=>(0,W.jsxs)(X,{children:[(0,W.jsx)(Jw,{icon:(0,W.jsx)(XS,{color:e.mode===`trusted-full-access`?`warning`:`primary`}),title:Q(e.mode,r),detail:e.detail,action:(0,W.jsx)(DS,{size:`small`,variant:a===e.mode?`contained`:`outlined`,color:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":a===e.mode,disabled:s||!t||!n||t.liveState===`running`,onClick:()=>m(e.mode),children:Q(e.mode,r)})}),i<h.length-1&&(0,W.jsx)(Eu,{})]},e.mode))}),l&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:l}),(0,W.jsx)(OC,{open:d!==null,title:$(r,`Bật toàn quyền?`,`Enable full access?`),description:$(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 anh 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:$(r,`Hủy`,`Cancel`),confirmLabel:$(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>f(null),onConfirm:()=>{f(null),p(`trusted-full-access`)}})]})}function eT({session:e,snapshot:t}){let{locale:n}=xv(),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=[[$(n,`Context`,`Context`),r?.percent==null?`—`:`${Math.round(r.percent)}%`],[`Tokens`,`${Kw(r?.tokens,n)} / ${Kw(r?.contextWindow,n)}`],[$(n,`Input`,`Input`),Kw(t?.usage.sessionTotal.input,n)],[$(n,`Output`,`Output`),Kw(t?.usage.sessionTotal.output,n)],[$(n,`Continuation`,`Continuation`),Kw(t?.continuation.remaining,n)],[`Verifier`,t?.verification.state??`—`]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qw,{children:$(n,`Usage & context`,`Usage & context`)}),(0,W.jsx)(X,{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,W.jsxs)(Mc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:e}),(0,W.jsx)(Z,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:800},children:t})]},e))})]})}function tT({capabilities:e,connection:t}){let{locale:n}=xv(),r=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[$(n,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(qw,{children:`Piagent`}),(0,W.jsx)(Mc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:r.map(([e,t],n)=>(0,W.jsxs)(X,{children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,W.jsx)(Z,{color:`text.secondary`,children:e}),(0,W.jsx)(Z,{sx:{fontWeight:760},children:String(t)})]}),n<r.length-1&&(0,W.jsx)(Eu,{})]},String(e)))})]})}function nT({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}=xv(),[f,p]=(0,v.useState)(),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(),[y,b]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=new AbortController;return wg(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]);let x=async()=>{let[e,t]=await Promise.all([Tg(),wg()]);h(e),p(t)};(0,v.useEffect)(()=>{let e=new AbortController;return Tg(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,v.useEffect)(()=>{if(!r){_(void 0);return}let e=new AbortController;return b(!0),_(void 0),Wg(r.sessionRef,e.signal).then(_).catch(()=>void 0).finally(()=>{e.signal.aborted||b(!1)}),()=>e.abort()},[r?.sessionRef]);let S=async e=>{if(e){_(e);return}r&&_(await Wg(r.sessionRef).catch(()=>g))},C=[{id:`general`,label:$(d,`Giao diện`,`Appearance`),icon:(0,W.jsx)(ZS,{})},{id:`models`,label:$(d,`Nhà cung cấp & model`,`Providers & models`),icon:(0,W.jsx)(Iw,{})},{id:`controls`,label:$(d,`Điều khiển project`,`Project controls`),icon:(0,W.jsx)(Gx,{})},{id:`connections`,label:$(d,`MCP & kết nối`,`MCP & connections`),icon:(0,W.jsx)(iC,{})},{id:`permissions`,label:$(d,`Quyền truy cập`,`Access`),icon:(0,W.jsx)(XS,{})},{id:`usage`,label:$(d,`Sử dụng & context`,`Usage & context`),icon:(0,W.jsx)(Fw,{})},{id:`about`,label:`Piagent`,icon:(0,W.jsx)(Nw,{})}];return(0,W.jsxs)(X,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`220px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,W.jsxs)(X,{component:`nav`,"aria-label":$(d,`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`},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{minHeight:48,alignItems:`center`,justifyContent:`space-between`,px:1,mb:{sm:1}},children:[(0,W.jsx)(Z,{id:`piagent-settings-title`,sx:{fontWeight:700},children:$(d,`Cài đặt`,`Settings`)}),(0,W.jsx)(Zd,{"aria-label":$(d,`Đóng cài đặt`,`Close settings`),onClick:n,children:(0,W.jsx)(dw,{})})]}),(0,W.jsx)(nf,{component:`div`,disablePadding:!0,sx:{display:{xs:`flex`,sm:`block`},minWidth:{xs:`max-content`,sm:0},overflowX:`auto`},children:C.map(n=>(0,W.jsxs)(sf,{selected:e===n.id,onClick:()=>t(n.id),children:[(0,W.jsx)(ff,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:n.icon}),(0,W.jsx)(Sf,{primary:n.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:e===n.id?800:650}}}})]},n.id))})]}),(0,W.jsxs)(X,{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,W.jsx)(Yw,{}),e===`models`&&(0,W.jsx)(Zw,{options:f,auth:m,refreshAuth:x,session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,W.jsx)(Qw,{value:g,loading:y,sessionRef:r?.sessionRef,onChanged:S}),e===`controls`&&(0,W.jsx)(Gw,{session:r,options:f,connections:g,onCompleted:u}),e===`permissions`&&(0,W.jsx)($w,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,W.jsx)(eT,{session:r,snapshot:i}),e===`about`&&(0,W.jsx)(tT,{capabilities:a,connection:o})]})]})}var rT=288,iT=`min(44vw, 860px)`;function aT(e,t){let n=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));if(n<60)return $(t,`Vừa xong`,`Just now`);let r=Math.floor(n/60);if(r<60)return $(t,`${r} phút`,`${r}m`);let i=Math.floor(r/60);if(i<24)return $(t,`${i} giờ`,`${i}h`);let a=Math.floor(i/24);return $(t,`${a} ngày`,`${a}d`)}function oT({session:e}){let t=e.needsAttention?`warning.main`:e.liveState===`running`?`primary.main`:e.state===`gateway-owned`||e.state===`terminal-owned`?`success.main`:`text.disabled`;return(0,W.jsx)(X,{"aria-hidden":`true`,sx:{width:7,height:7,mt:.8,ml:.75,borderRadius:`50%`,bgcolor:t,boxShadow:e.liveState===`running`?`0 0 0 4px rgba(216,255,122,.12)`:`none`}})}function sT({session:e,selected:t,locale:n,onSelect:r,onAction:i}){let[a,o]=(0,v.useState)(null),s=e=>{o(null),i(e)};return(0,W.jsxs)(X,{sx:{display:`flex`,alignItems:`center`,pr:.5},children:[(0,W.jsxs)(sf,{selected:t,onClick:r,sx:{minWidth:0,alignItems:`flex-start`,py:1.1,px:1.4},children:[(0,W.jsx)(Sf,{primary:e.title,secondary:(0,W.jsxs)(W.Fragment,{children:[e.preview||e.projectLabel,(0,W.jsx)(`span`,{children:` · `}),aT(e.updatedAt,n)]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13.25,fontWeight:t?600:500}},secondary:{noWrap:!0,sx:{mt:.3,fontSize:11.25}}}}),(0,W.jsx)(oT,{session:e})]}),(0,W.jsx)(Zd,{size:`small`,"aria-label":$(n,`Tùy chọn cuộc trò chuyện`,`Chat options`),onClick:e=>o(e.currentTarget),children:(0,W.jsx)(Zx,{fontSize:`small`})}),(0,W.jsxs)(Jy,{anchorEl:a,open:!!a,onClose:()=>o(null),onClick:e=>e.stopPropagation(),children:[!e.archived&&(0,W.jsx)(KS,{onClick:()=>s(`rename`),children:$(n,`Đổi tên`,`Rename`)}),!e.archived&&(0,W.jsx)(KS,{onClick:()=>s(`pin`),children:e.pinned?$(n,`Bỏ ghim`,`Unpin`):$(n,`Ghim`,`Pin`)}),!e.archived&&(0,W.jsx)(KS,{onClick:()=>s(`fork`),children:$(n,`Tạo nhánh`,`Fork`)}),(0,W.jsx)(KS,{onClick:()=>s(e.archived?`unarchive`:`archive`),children:e.archived?$(n,`Bỏ lưu trữ`,`Unarchive`):$(n,`Lưu trữ`,`Archive`)})]})]})}function cT({session:e,locale:t}){let n=e.state===`gateway-owned`||e.state===`terminal-owned`;return(0,W.jsx)(cu,{size:`small`,variant:`outlined`,color:n?`success`:e.needsAttention?`warning`:`default`,label:e.liveState===`running`?$(t,`Đang chạy`,`Running`):n?$(t,`Đang hoạt động`,`Active`):e.state===`recovery-required`?$(t,`Cần khôi phục`,`Recovery needed`):$(t,`Đã lưu`,`Saved`)})}function lT({session:e,snapshot:t,locale:n,live:r,canSend:i,canRestart:a,send:o,abort:s,restart:c,onInspector:l}){let[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(`continue`),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(()=>`message-request.${crypto.randomUUID()}`),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),F=(0,v.useRef)(0);(0,v.useEffect)(()=>{d(``),b(`continue`),S(!1),_([]),O(null),A(null),w(`message-request.${crypto.randomUUID()}`)},[e.sessionRef]),(0,v.useEffect)(()=>{let e=e=>{gx(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]);let I=t?.capabilities.capabilities.attachments,L=(0,v.useMemo)(()=>new Set(I?.status===`available`?I.mimeTypes:[]),[I]),R=(0,v.useMemo)(()=>hx(L),[L]),ee=!!t&&I?.status===`available`&&i&&!f&&!T&&g.length<4,te=async r=>{if(!(!r?.length||!t||I?.status!==`available`||T)){E(!0),O(null);try{let i=await _x({files:r,snapshot:t,messageRequestId:C,existing:g,allowed:L,locale:n,stage:t=>x_(e.sessionRef,t)});_(i.attachments),O(i.status)}catch{O($(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{E(!1)}}},ne=async r=>{if(!(!t||f||T)){E(!0),O(null);try{let i=await vx({snapshot:t,messageRequestId:C,attachmentRef:r,locale:n,stage:t=>x_(e.sessionRef,t)});i.discarded?_(e=>e.filter(e=>e.attachmentRef!==r)):O(i.status)}catch{O($(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{E(!1)}}};(0,v.useEffect)(()=>{let t=new AbortController;return h(void 0),Wg(e.sessionRef,t.signal).then(h).catch(()=>void 0),()=>t.abort()},[e.sessionRef,e.sessionRevision]);let z=async()=>{let e=u.trim();if(!e||f)return;p(!0),A(null);let t=g.map(e=>e.attachmentRef);try{await o(e,t.length>0||y!==`continue`?{messageRequestId:C,attachmentRefs:t,attachments:g,...y===`continue`?{}:{workflow:y}}:void 0),d(``),b(`continue`),_([]),O(null),w(`message-request.${crypto.randomUUID()}`)}catch{A($(n,`Chưa xác nhận gửi được. Nội dung và file vẫn được giữ; hãy kiểm tra trạng thái session trước khi gửi lại.`,`Send was not confirmed. Your message and files are preserved; check the session state before sending again.`))}finally{p(!1)}},B=async t=>{if(t){h(t);return}h(await Wg(e.sessionRef).catch(()=>m))},V=async()=>{if(!j){M(!0);try{await c()}catch{}finally{M(!1)}}},re=r?.runtimeRecovery??null;return(0,W.jsxs)(X,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,W.jsx)(X,{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:(0,W.jsx)(X,{sx:{width:`100%`},children:(0,W.jsx)(jw,{sessionRef:e.sessionRef,sessionRevision:e.sessionRevision,live:r,approvals:t?.approvals,locale:n,onOpenActivity:()=>l(`activity`)})})}),(0,W.jsxs)(X,{sx:{position:`sticky`,bottom:0,px:{xs:1.5,sm:2.5},pb:2.5,background:`linear-gradient(transparent, var(--piagent-palette-background-default) 25%)`},children:[re&&(0,W.jsx)(hS,{severity:re===`recovered`?`success`:re===`failed`?`error`:`warning`,action:(re===`failed`||re===`required`)&&a&&e.liveState!==`running`?(0,W.jsx)(DS,{color:`inherit`,size:`small`,disabled:j,onClick:()=>void V(),children:j?$(n,`Đang khởi động…`,`Restarting…`):$(n,`Khởi động lại phiên`,`Restart session`)}):void 0,sx:{maxWidth:860,mx:`auto`,mb:1},children:re===`recovered`?$(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.`):re===`failed`?$(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.`):re===`restarting`?$(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.`):$(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,W.jsxs)(X,{sx:{position:`relative`,maxWidth:860,mx:`auto`,border:1,borderColor:N?`primary.main`:`divider`,borderStyle:N?`dashed`:`solid`,borderRadius:3,bgcolor:`background.paper`,p:1.15,boxShadow:`0 14px 44px rgba(0,0,0,.14)`},onDragEnter:e=>{gx(e.dataTransfer)&&(F.current+=1,P(!0))},onDragOver:e=>{gx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=ee?`copy`:`none`)},onDragLeave:e=>{gx(e.dataTransfer)&&(--F.current,F.current<=0&&(F.current=0,P(!1)))},onDrop:e=>{gx(e.dataTransfer)&&(e.preventDefault(),F.current=0,P(!1),ee&&te(e.dataTransfer.files))},children:[N&&(0,W.jsxs)(X,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,W.jsx)(Z,{sx:{fontWeight:750},children:ee?$(n,`Thả tài liệu vào đây`,`Drop documents here`):g.length>=4?$(n,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):$(n,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),ee&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:$(n,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),g.length>0&&(0,W.jsx)(Cf,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pb:.75},"aria-label":$(n,`File sẽ gửi cùng tin nhắn`,`Files to send with the message`),children:g.map(e=>(0,W.jsx)(cu,{size:`small`,variant:`outlined`,color:e.kind===`document`?`success`:`default`,label:`${e.displayName} · ${mx(e,n)}`,onDelete:f||T?void 0:()=>void ne(e.attachmentRef),deleteIcon:(0,W.jsx)(Jx,{"aria-label":`${$(n,`Bỏ`,`Remove`)} ${e.displayName}`,role:`button`})},e.attachmentRef))}),(0,W.jsx)(Mb,{fullWidth:!0,multiline:!0,minRows:2,disabled:!i||f,value:u,onChange:e=>{d(e.target.value),A(null)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),z())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),ee&&te(e.clipboardData.files))},placeholder:$(n,`Nhắn cho Piagent…`,`Message Piagent…`),variant:`standard`,slotProps:{input:{disableUnderline:!0}}}),(0,W.jsx)(PS,{in:x,id:`piagent-message-options`,children:(0,W.jsxs)(X,{sx:{mt:.65,p:.85,borderRadius:2,bgcolor:`action.hover`},children:[(0,W.jsx)(uw,{session:e,snapshot:t,connections:m,locale:n,onOpenChanges:()=>l(`source`),onConnectionsChanged:B}),(0,W.jsxs)(Cf,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,W.jsxs)(Db,{size:`small`,value:y,disabled:!i||f,onChange:e=>b(e.target.value),"aria-label":$(n,`Workflow cho tin nhắn này`,`Workflow for this message`),startAdornment:(0,W.jsx)(Gx,{sx:{mr:.75,fontSize:18}}),sx:{minWidth:{xs:150,sm:190},height:34,fontSize:12.5},children:[(0,W.jsx)(KS,{value:`continue`,children:$(n,`Tự do · không workflow`,`Freeform · no workflow`)}),(0,W.jsx)(KS,{value:`task`,children:`Task`}),(0,W.jsx)(KS,{value:`scout`,children:`Scout`}),(0,W.jsx)(KS,{value:`be-to-fe`,children:`BE → FE`}),(0,W.jsx)(KS,{value:`discuss`,children:`Discuss`}),(0,W.jsx)(KS,{value:`plan`,children:`Plan`}),(0,W.jsx)(KS,{value:`review`,children:`Review`}),(0,W.jsx)(KS,{value:`commit`,children:`Commit`}),(0,W.jsx)(KS,{value:`pr`,children:`PR`}),(0,W.jsx)(KS,{value:`onboard`,children:`Onboard`}),(0,W.jsx)(KS,{value:`platform-improve`,children:`Platform improve`})]}),I?.status===`available`&&(0,W.jsx)(Ah,{title:$(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,W.jsxs)(DS,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,W.jsx)(Kx,{}),disabled:!ee,"aria-label":`${$(n,`Đính kèm`,`Attach`)} (${g.length}/4)`,children:[$(n,`Đính kèm`,`Attach`),(0,W.jsx)(`input`,{type:`file`,multiple:!0,hidden:!0,disabled:!ee,accept:R||void 0,onChange:e=>{te(e.target.files),e.currentTarget.value=``}})]})})]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.65},children:$(n,`Workflow chỉ áp dụng cho tin nhắn này và tự trở về Tự do sau khi gửi. Anh có thể đổi sang việc khác ngay trong cùng session.`,`A workflow applies only to this message and resets to Freeform after send. You can switch to different work in the same session.`)})]})}),(0,W.jsxs)(Cf,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`,mt:.5,gap:1},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:1},children:[(0,W.jsx)(Ah,{title:x?$(n,`Ẩn tùy chọn`,`Hide options`):$(n,`Workflow, file và công cụ`,`Workflow, files and tools`),children:(0,W.jsx)(Zd,{size:`small`,"aria-label":x?$(n,`Ẩn tùy chọn`,`Hide options`):$(n,`Thêm tùy chọn`,`More options`),"aria-expanded":x,"aria-controls":`piagent-message-options`,onClick:()=>S(e=>!e),sx:{bgcolor:x?`action.selected`:`transparent`},children:(0,W.jsx)(Wx,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:x?`rotate(45deg)`:`none`}})})}),y!==`continue`&&(0,W.jsx)(cu,{size:`small`,variant:`outlined`,icon:(0,W.jsx)(Gx,{}),label:`${y.toUpperCase()} · ${$(n,`tin nhắn này`,`this message`)}`}),(0,W.jsx)(Z,{variant:`caption`,color:D||k?`error`:`text.disabled`,noWrap:!k,sx:{display:{xs:D||k||T?`block`:`none`,sm:`block`}},children:k??D??(T?$(n,`Đang đọc tài liệu…`,`Reading documents…`):r&&!r.complete?$(n,`Piagent đang xử lý; anh có thể gửi việc tiếp theo khi hoàn tất.`,`Piagent is working; you can send the next task when it finishes.`):i?$(n,`Enter để gửi · Shift+Enter xuống dòng`,`Enter to send · Shift+Enter for a new line`):$(n,`Session hiện chỉ đọc`,`Session is currently read only`))})]}),r?.operationRef&&!r.complete&&r.abortable!==!1?(0,W.jsx)(DS,{color:`error`,startIcon:(0,W.jsx)(tS,{}),onClick:()=>void s(),children:$(n,`Dừng`,`Stop`)}):(0,W.jsx)(Zd,{"aria-label":$(n,`Gửi`,`Send`),disabled:!i||f||!u.trim(),color:`primary`,onClick:()=>void z(),sx:{bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,W.jsx)($x,{fontSize:`small`})})]})]})]})]})}function uT({locale:e,canCreate:t,onNew:n}){return(0,W.jsxs)(Cf,{sx:{minHeight:`calc(100vh - 68px)`,alignItems:`center`,justifyContent:`center`,px:3,textAlign:`center`},spacing:1.5,children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,sx:{width:50,height:50,fontSize:25},children:`π`}),(0,W.jsx)(Z,{variant:`h1`,children:$(e,`Bắt đầu với Piagent`,`Start with Piagent`)}),(0,W.jsx)(Z,{color:`text.secondary`,sx:{maxWidth:520},children:$(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,W.jsx)(DS,{disabled:!t,variant:`contained`,startIcon:(0,W.jsx)(Wx,{}),onClick:n,children:$(e,`Cuộc trò chuyện mới`,`New chat`)})]})}function dT({catalog:e,capabilities:t,connection:n,live:r,terminalActivities:i,refresh:a,create:o,send:s,abort:c,restart:l,setModel:u,setThinking:d,setPermission:f,rename:p,pin:m,archive:h,unarchive:g,fork:_}){let{locale:y}=xv(),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(`chat`),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(`general`),[P,F]=(0,v.useState)(!1),[I,L]=(0,v.useState)(`task`),[R,ee]=(0,v.useState)(),[te,ne]=(0,v.useState)(`idle`),[z,B]=(0,v.useState)(!1),[V,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(null),[oe,se]=(0,v.useState)(``),[H,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(null),[de,fe]=(0,v.useState)(null);(0,v.useEffect)(()=>{window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0},[O,S]);let pe=(0,v.useMemo)(()=>(e?.sessions??[]).filter(e=>e.archived===E&&`${e.title} ${e.projectLabel} ${e.preview}`.toLowerCase().includes(b.trim().toLowerCase())),[e,b,E]),me=(0,v.useMemo)(()=>{let e=new Map;for(let t of pe){let n=e.get(t.projectRef)??{label:t.projectLabel,sessions:[]};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??``))},[pe]),he=e?.sessions.filter(e=>e.archived).length??0;(0,v.useEffect)(()=>{(!S||!(e?.sessions??[]).some(e=>e.sessionRef===S))&&C((e?.sessions??[]).find(e=>!e.archived)?.sessionRef)},[S,e]);let U=(e?.sessions??[]).find(e=>e.sessionRef===S),ge=U?r[U.sessionRef]:void 0,_e=e=>{C(e),k(`chat`),T(!1)},ve=e=>{N(e),j(!0)},ye=e=>{L(e),F(!0)},be=async()=>{if(U){ne(`loading`);try{let e=await Pg(U.sessionRef);return ee(e),ne(`ready`),e}catch{ne(`error`);return}}};(0,v.useEffect)(()=>{if(!U){ee(void 0),ne(`idle`);return}let e=new AbortController;return ee(void 0),ne(`loading`),Pg(U.sessionRef,e.signal).then(t=>{e.signal.aborted||(ee(t),ne(`ready`))}).catch(()=>{e.signal.aborted||ne(`error`)}),()=>e.abort()},[U?.sessionRef,U?.sessionRevision]),(0,v.useEffect)(()=>{if(!P||I!==`activity`||!U||!ge?.operationRef||ge.complete)return;let e=!1,t,n=new AbortController,r=async()=>{try{let t=await Pg(U.sessionRef,n.signal);e||(ee(t),ne(`ready`))}catch{}e||(t=window.setTimeout(()=>void r(),2e3))};return t=window.setTimeout(()=>void r(),2e3),()=>{e=!0,t!==void 0&&window.clearTimeout(t),n.abort()}},[P,I,U?.sessionRef,ge?.operationRef,ge?.complete]);let xe=n===`connected`&&t?.capabilities.sessionActions.create.status===`available`,Se=async e=>{B(!0),re(null);let t=null;try{let n=`message-request.${crypto.randomUUID()}`,r=e.files.length>0,i=await o({projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,permissionMode:e.permissionMode,message:e.message,messageRequestId:n,deferInitialMessage:r});if(t=i.sessionRef,!t)throw Error(`session-create-result-invalid`);if(i.phase!==`settled`){C(t),k(`chat`),fe({title:$(y,`Session đã được tạo`,`The session was created`),message:$(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 Pg(t),o=i.capabilities.capabilities.attachments;if(o.status!==`available`)throw Error(o.reason?.code??`session-attachment-unavailable`);let c=await _x({files:e.files,snapshot:i,messageRequestId:n,existing:[],allowed:new Set(o.mimeTypes),locale:y,stage:e=>x_(t,e)});if(c.status||c.attachments.length!==e.files.length)throw await Promise.all(c.attachments.map(async e=>{try{await vx({snapshot:i,messageRequestId:n,attachmentRef:e.attachmentRef,locale:y,stage:e=>x_(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})}C(t),k(`chat`)}catch(e){let n=e instanceof Error?e.message:`session-create-failed`;t?(C(t),k(`chat`),fe({title:$(y,`Session đã tạo nhưng file chưa được gửi`,`The session was created, but the files were not sent`),message:n})):re(n)}finally{B(!1)}},Ce=(e,t)=>{if(t===`pin`){m(e,!e.pinned).catch(e=>fe({title:$(y,`Không thể đổi trạng thái ghim`,`Could not change pin state`),message:e instanceof Error?e.message:`session-pin-failed`}));return}if(t===`unarchive`){g(e).then(()=>D(!1)).catch(e=>fe({title:$(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}ue(null),se(t===`rename`?e.title:t===`fork`?`${e.title} · ${$(y,`nhánh`,`fork`)}`:``),ae({kind:t,session:e})},we=async()=>{if(!(!ie||H)){ce(!0),ue(null);try{if(ie.kind===`rename`)await p(ie.session,oe.trim());else if(ie.kind===`archive`)await h(ie.session);else{let e=await _(ie.session,oe.trim()||null);e.sessionRef&&(C(e.sessionRef),k(`chat`))}ae(null)}catch(e){ue(e instanceof Error?e.message:`session-action-failed`)}finally{ce(!1)}}},Te=(0,W.jsxs)(X,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,bgcolor:`background.paper`},children:[(0,W.jsxs)(up,{sx:{minHeight:`68px !important`,px:`16px !important`,gap:1.1},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:600},children:`Piagent`}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:`Local agent workspace`})]})]}),(0,W.jsxs)(X,{sx:{px:1.25},children:[(0,W.jsx)(Ah,{title:xe?$(y,`Tạo session mới`,`Create a new session`):$(y,`Gateway hiện chưa cho phép tạo session`,`The Gateway cannot create sessions right now`),children:(0,W.jsx)(`span`,{children:(0,W.jsx)(DS,{fullWidth:!0,disabled:!xe,variant:`outlined`,onClick:()=>{re(null),k(`new`),T(!1)},startIcon:(0,W.jsx)(Wx,{}),sx:{justifyContent:`flex-start`,py:1},children:$(y,`Cuộc trò chuyện mới`,`New chat`)})})}),(0,W.jsx)(Mb,{value:b,onChange:e=>x(e.target.value),fullWidth:!0,size:`small`,placeholder:$(y,`Tìm cuộc trò chuyện`,`Search chats`),sx:{mt:1.1},slotProps:{input:{startAdornment:(0,W.jsx)(Pv,{position:`start`,children:(0,W.jsx)(Nb,{fontSize:`small`})})}}})]}),(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,px:2,pt:2,pb:.4},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:600,textTransform:`uppercase`,letterSpacing:`.08em`},children:E?$(y,`Đã lưu trữ`,`Archived`):$(y,`Cuộc trò chuyện`,`Chats`)}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:pe.length})]}),(0,W.jsxs)(nf,{component:`div`,sx:{flex:1,minHeight:0,overflowY:`auto`,py:.25},children:[me.map(e=>(0,W.jsxs)(X,{sx:{mt:.75},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:.7,px:2,py:.55},children:[(0,W.jsx)(Xx,{sx:{fontSize:15,color:`text.disabled`}}),(0,W.jsx)(Z,{component:`div`,variant:`caption`,color:`text.disabled`,noWrap:!0,sx:{flex:1,fontWeight:600},children:e.label}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:e.sessions.length})]}),e.sessions.map(e=>(0,W.jsx)(sT,{session:e,selected:O===`chat`&&U?.sessionRef===e.sessionRef,locale:y,onSelect:()=>_e(e.sessionRef),onAction:t=>Ce(e,t)},e.sessionRef))]},e.projectRef)),pe.length===0&&(0,W.jsxs)(Cf,{sx:{alignItems:`center`,textAlign:`center`,px:3,py:5},spacing:1,children:[(0,W.jsx)(Yx,{color:`disabled`}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:$(y,`Không tìm thấy cuộc trò chuyện`,`No conversations found`)})]})]}),(0,W.jsxs)(X,{sx:{p:1.25},children:[(0,W.jsx)(Eu,{sx:{mb:1}}),(0,W.jsx)(DS,{fullWidth:!0,startIcon:(0,W.jsx)(qx,{}),disabled:!E&&he===0,onClick:()=>{D(e=>!e),T(!1)},sx:{justifyContent:`flex-start`},children:E?$(y,`Quay lại cuộc trò chuyện`,`Back to chats`):$(y,`Đã lưu trữ (${he})`,`Archived (${he})`)}),(0,W.jsx)(DS,{fullWidth:!0,startIcon:(0,W.jsx)(eS,{}),onClick:()=>{ve(`general`),T(!1)},sx:{justifyContent:`flex-start`,mt:.25},color:A?`primary`:`inherit`,children:$(y,`Cài đặt`,`Settings`)}),(0,W.jsxs)(Cf,{direction:`row`,sx:{px:1.25,pt:1,alignItems:`center`,gap:1},children:[(0,W.jsx)(X,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:n===`connected`?`success.main`:`warning.main`}}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{flex:1},children:n===`connected`?`Gateway live`:n}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:`local`})]})]})]});if(!e&&n!==`failed`)return(0,W.jsxs)(Cf,{sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},spacing:2,children:[(0,W.jsx)(bu,{size:24}),(0,W.jsx)(Z,{children:$(y,`Đang mở Piagent…`,`Opening Piagent…`)})]});let Ee=O===`new`?$(y,`Cuộc trò chuyện mới`,`New chat`):U?.title??`Piagent`;return(0,W.jsxs)(X,{sx:{minHeight:`100vh`,bgcolor:`background.default`},children:[(0,W.jsx)(Lc,{position:`fixed`,color:`transparent`,elevation:0,sx:{left:{md:`${rT}px`},right:{xl:P?iT: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,W.jsxs)(up,{sx:{minHeight:`68px !important`,gap:1},children:[(0,W.jsx)(Zd,{"aria-label":$(y,`Mở điều hướng`,`Open navigation`),onClick:()=>T(!0),sx:{display:{md:`none`}},children:(0,W.jsx)(Rh,{})}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{component:`h1`,noWrap:!0,sx:{fontWeight:600,fontSize:`inherit`},children:Ee}),O===`chat`&&U&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:U.projectLabel})]}),O===`chat`&&U&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(uw,{placement:`header`,session:U,snapshot:R,locale:y,onOpenChanges:()=>ye(`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(U,e),onSetThinking:e=>d(U,e),onSetPermission:e=>f(U,e)}),(0,W.jsx)(cT,{session:U,locale:y}),(0,W.jsx)(Ah,{title:`Source Changes`,children:(0,W.jsx)(Zd,{"aria-label":$(y,`Mở Source Changes Inspector`,`Open Source Changes Inspector`),onClick:()=>ye(`source`),children:(0,W.jsx)(Ph,{fontSize:`small`})})})]}),(0,W.jsx)(Ah,{title:$(y,`Làm mới`,`Refresh`),children:(0,W.jsx)(Zd,{"aria-label":$(y,`Làm mới`,`Refresh`),onClick:()=>void a(),children:(0,W.jsx)(Qx,{fontSize:`small`})})})]})}),(0,W.jsxs)(X,{component:`nav`,sx:{width:{md:rT}},children:[(0,W.jsx)(Gd,{variant:`temporary`,open:w,onClose:()=>T(!1),sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:rT}},children:Te}),(0,W.jsx)(Gd,{variant:`permanent`,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:rT,borderRight:1,borderColor:`divider`}},children:Te})]}),(0,W.jsx)(X,{component:`main`,sx:{ml:{md:`${rT}px`},mr:{xl:P?iT:0},pt:`68px`,transition:`margin-right .2s ease`},children:O===`new`?(0,W.jsx)(jC,{active:!0,defaultProjectRef:U?.projectRef,busy:z,error:V,onCancel:()=>k(`chat`),onCreate:e=>{Se(e)}}):U?(0,W.jsx)(lT,{session:U,snapshot:R,locale:y,live:r[U.sessionRef],canSend:n===`connected`&&U.composerAvailable&&t?.capabilities.sessionActions.send.status===`available`&&(!ge||ge.complete)&&![`required`,`restarting`,`failed`].includes(String(r[U.sessionRef]?.runtimeRecovery)),canRestart:n===`connected`&&t?.capabilities.sessionActions.release.status===`available`&&t?.capabilities.sessionActions.acquire.status===`available`,send:(e,t)=>s(U,e,t),abort:()=>c(U),restart:()=>l(U),onInspector:ye}):(0,W.jsx)(uT,{locale:y,canCreate:xe,onNew:()=>k(`new`)})}),(0,W.jsx)(hw,{open:P,active:I,snapshot:R,state:te,sessionRef:U?.sessionRef,terminalActivities:U?i[U.sessionRef]:void 0,onClose:()=>F(!1),onActive:L,refresh:be}),(0,W.jsx)(HS,{open:A,onClose:()=>j(!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,W.jsx)(nT,{section:M,onSection:N,onBack:()=>j(!1),session:U,snapshot:R,capabilities:t,connection:n,onSetModel:U?e=>u(U,e):void 0,onSetThinking:U?e=>d(U,e):void 0,onSetPermission:U?e=>f(U,e):void 0,onRuntimeChanged:async()=>{await a(),await be()}})}),(0,W.jsx)(HS,{open:!!ie,onClose:()=>!H&&ae(null),fullWidth:!0,maxWidth:`xs`,children:(0,W.jsxs)(Cf,{spacing:2,sx:{p:3},children:[(0,W.jsx)(Z,{variant:`h2`,children:ie?.kind===`rename`?$(y,`Đổi tên cuộc trò chuyện`,`Rename chat`):ie?.kind===`fork`?$(y,`Tạo nhánh cuộc trò chuyện`,`Fork chat`):$(y,`Lưu trữ cuộc trò chuyện`,`Archive chat`)}),ie?.kind===`archive`?(0,W.jsx)(Z,{color:`text.secondary`,children:$(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,W.jsx)(Mb,{autoFocus:!0,label:$(y,`Tên`,`Title`),value:oe,onChange:e=>se(e.target.value),slotProps:{htmlInput:{maxLength:500}}}),le&&(0,W.jsx)(Z,{color:`error`,children:le}),(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{justifyContent:`flex-end`},children:[(0,W.jsx)(DS,{disabled:H,onClick:()=>ae(null),children:$(y,`Hủy`,`Cancel`)}),(0,W.jsx)(DS,{variant:`contained`,disabled:H||ie?.kind!==`archive`&&!oe.trim(),onClick:()=>void we(),children:$(y,`Xác nhận`,`Confirm`)})]})]})}),(0,W.jsx)(HS,{open:!!de,onClose:()=>fe(null),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-session-notice-title`,children:(0,W.jsxs)(Cf,{spacing:2,sx:{p:3},children:[(0,W.jsx)(Z,{id:`piagent-session-notice-title`,variant:`h2`,children:de?.title}),(0,W.jsx)(Z,{color:`text.secondary`,children:de?.message}),(0,W.jsx)(Cf,{direction:`row`,sx:{justifyContent:`flex-end`},children:(0,W.jsx)(DS,{variant:`contained`,onClick:()=>fe(null),children:$(y,`Đóng`,`Close`)})})]})})]})}function fT(e){let t=e===`dark`,n=t?`#d8ff7a`:`#627400`,r=t?`#8be9c8`:`#14775f`;return Bo({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:e,primary:{main:n,light:t?`#e6ff9f`:`#849a17`,dark:t?`#a7cc45`:`#455400`,contrastText:t?`#111300`:`#ffffff`},secondary:{main:r},success:{main:r},warning:{main:`#efba63`},error:{main:`#ff7f86`},background:{default:t?`#050505`:`#f5f6f0`,paper:t?`#101114`:`#ffffff`},text:{primary:t?`#f4f4ef`:`#1c2018`,secondary:t?`#a4a6ad`:`#62685c`,disabled:t?`#898c95`:`#6b7165`},divider:t?`#24262d`:`#dfe2d8`},shape:{borderRadius:10},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.65rem`,fontWeight:600,letterSpacing:`-0.03em`},h2:{fontSize:`1.2rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`1rem`,fontWeight:600},button:{fontSize:`0.78rem`,fontWeight:500,textTransform:`none`},caption:{fontSize:`0.7rem`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:t?`#050505`:`#f5f6f0`},body:{minWidth:320,minHeight:`100vh`,backgroundImage:t?`radial-gradient(circle at 65% -18%, rgba(139,233,200,.12) 0, transparent 34rem)`:`radial-gradient(circle at 65% -18%, rgba(216,255,122,.22) 0, transparent 34rem)`},"::selection":{backgroundColor:xi(n,.26)}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:34,borderRadius:8},outlined:{borderColor:t?`#32343c`:`#cfd4c8`}}},MuiChip:{styleOverrides:{root:{height:26,borderRadius:7,fontWeight:500}}},MuiListItemButton:{styleOverrides:{root:{minHeight:42,margin:`2px 10px`,borderRadius:8,color:t?`#a4a6ad`:`#62685c`,"&.Mui-selected":{color:t?`#f4f4ef`:`#1c2018`,backgroundColor:xi(n,t?.11:.1),boxShadow:`inset 2px 0 ${n}`},"&.Mui-selected:hover":{backgroundColor:xi(n,.15)}}}},MuiTab:{styleOverrides:{root:{minHeight:48,paddingInline:18,textTransform:`none`,fontWeight:500}}},MuiTooltip:{defaultProps:{arrow:!0}}}})}function pT(e){for(let t of e??[]){let e=String(t).toLowerCase().split(`-`)[0];if(e===`vi`)return`vi`;if(e)return`en`}return`en`}function mT(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(`connecting`),[i,a]=(0,v.useState)([]),o=(0,v.useCallback)(async()=>{try{let e=await xg();return t(e),r(`connected`),e}catch{r(`reconnecting`);return}},[]);return(0,v.useEffect)(()=>{let e=new AbortController,n,i,o=!1,s=async(n=!0)=>{try{let i=await xg(e.signal);return o||(t(i),n&&r(`connected`)),i}catch{!o&&!e.signal.aborted&&r(`reconnecting`);return}},c=()=>{window.clearTimeout(i),i=window.setTimeout(()=>{s()},80)},l=e=>{n?.close();let t=e?`?after=${encodeURIComponent(e)}`:``;n=new EventSource(`/api/v1/events${t}`,{withCredentials:!0}),n.onopen=()=>{o||r(`connected`)},n.addEventListener(`runtime-event`,e=>{try{let t=JSON.parse(e.data);t&&typeof t.kind==`string`&&a(e=>[...e,t].slice(-500)),[`message.text-delta`,`message.thinking-state`,`activity.progress`].includes(String(t.kind))||c()}catch{}}),n.addEventListener(`resync-required`,()=>{(async()=>{n?.close(),a([]),o||r(`reconnecting`);let e=await s(!1);e&&!o&&l(e.revision.eventCursor)})()}),n.onerror=()=>{o||r(`reconnecting`)}};return(async()=>{let e=await yg();if(o)return;if(e===`failed`){r(`failed`);return}let t=await s();if(!t||o){r(`failed`);return}l(t.revision.eventCursor)})(),()=>{o=!0,e.abort(),n?.close(),window.clearTimeout(i)}},[]),{snapshot:e,connection:n,events:i,refreshSnapshot:o}}function hT(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 gT(e,t){return e&&!t?`connected`:`reconnecting`}var _T=100,vT=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/,yT=/^[a-z0-9][a-z0-9.-]{0,95}$/,bT=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function xT(e,t){return typeof t==`string`&&yT.test(t)?t:e===`aborted`?`operation-aborted`:e===`blocked`?`operation-blocked`:e===`error`?`operation-failed`:`operation-settlement-unknown`}function ST(e){if(e.settlement===`completed`||typeof e.operationRef!=`string`||!vT.test(e.operationRef)||typeof e.settledAt!=`string`||!bT.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:xT(t,e.reasonCode),settledAt:e.settledAt,sequence:Number(e.sequence)}}function CT(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,_T)}function wT(e){if(e.state!==`ready`)return{};let t={};for(let n of e.settlements??[]){let e=ST(n);e&&(t[n.sessionRef]=CT(t[n.sessionRef]??[],[e]))}return t}function TT(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,assistant:n===`completed`?e.assistant:``,error:n===`completed`?null:String(t.reasonCode??`operation-settlement-unknown`)}}function ET(e,t){if(t.state!==`ready`)return{...e};let n=new Map(t.operations.map(e=>[e.sessionRef,e])),r={...e};for(let[t,i]of Object.entries(e))n.has(t)||i.complete||(r[t]={...i,user:``,assistant:``,attachments:[],activities:[],operationRef:null,abortable:!1,complete:!0,settlement:`unknown`,error:`operation-settlement-unavailable`});for(let n of t.operations){let t=e[n.sessionRef],i=t?.operationRef===n.operationRef;r[n.sessionRef]=i?{...t,operationRef:n.operationRef,abortable:n.abortable,complete:!1,settlement:null,error:null}:{user:``,assistant:``,attachments:[],activities:[],operationRef:n.operationRef,abortable:n.abortable,complete:!1,settlement:null,error:null,runtimeRecovery:null}}return r}function DT(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}var OT=`piagent-gateway-event-cursor-v1`,kT=3e4,AT=4001;function jT(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 MT(e){return`${e}_${crypto.randomUUID().replaceAll(`-`,``)}`}function NT(e){return e.phase===`rejected`&&e.resultCode===`stale-revision`&&e.error?.code===`session-revision-stale`}function PT(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`connecting`),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)({}),u=(0,v.useRef)(void 0),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useRef)(!0),h=(0,v.useRef)(0),g=(0,v.useRef)(0),_=(0,v.useRef)(new Map),y=(0,v.useCallback)((e,t)=>{if(t!==null)try{window.sessionStorage.setItem(OT,JSON.stringify({gatewayInstanceRef:e,sequence:t}))}catch{}},[]),b=(0,v.useCallback)(async(e={})=>{let n=++h.current;try{let[r,i]=await Promise.all([Sg(),Cg().catch(()=>void 0)]),o=hT(i,r.gatewayInstanceRef),c=!1;if(n>=g.current){g.current=n,u.current=r,t(r);let h=p.current;h!==null&&h!==r.gatewayInstanceRef&&(m.current=!0),p.current=r.gatewayInstanceRef;let _=e.requireLiveState||m.current,v=d.current?.readyState===WebSocket.OPEN;if(a(gT(v,_)),!v&&i&&o!==null)f.current=o,y(r.gatewayInstanceRef,o),s(e=>ET(e,i)),l(wT(i)),m.current=!1,c=!0;else if(h!==r.gatewayInstanceRef){if(l({}),_)f.current=null;else{let e=null;try{e=window.sessionStorage.getItem(OT)}catch{}f.current=jT(e,r.gatewayInstanceRef)}}}return e.requireLiveState&&!c?void 0:u.current??r}catch{a(`reconnecting`);return}},[y]),x=(0,v.useCallback)(e=>{let t=d.current;if(!t||t.readyState!==WebSocket.OPEN)return Promise.reject(Error(`gateway-not-connected`));let n=MT(`request`);return new Promise((r,i)=>{let a=window.setTimeout(()=>{_.current.delete(n)&&i(Error(`gateway-command-response-timeout`))},kT);_.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),_.current.delete(n),i(e instanceof Error?e:Error(`gateway-request-failed`))}})},[]),S=(0,v.useCallback)(async e=>{let t=u.current,n=e.message.trim(),r=e.messageRequestId??MT(`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 x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:MT(`command`),idempotencyKey:MT(`idempotency`),action:`session.create`,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:null,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:null,payload:{projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,message:n,messageRequestId:r,...e.permissionMode?{permissionMode:e.permissionMode}:{},...e.deferInitialMessage?{deferInitialMessage:!0}:{}}})},a=await i(t);if(NT(a)){let e=await b();e?.catalogRevision&&(a=await i(e))}if(!(a.phase===`uncertain`&&a.sessionRef)&&a.phase!==`settled`||!a.sessionRef)throw Error(a.error?.code??a.resultCode);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,abortable:!t?.complete&&!!a.operationRef}}}),await b(),a},[b,x]),C=(0,v.useCallback)(async(e,t,n)=>{let r=u.current;if(!r?.catalogRevision)throw Error(`catalog-unavailable`);let i=t.trim();if(!i)throw Error(`message-empty`);let a=n?.messageRequestId??MT(`message`),o=n?.attachmentRefs??[];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 x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:MT(`command`),idempotencyKey:MT(`idempotency`),action:`session.send`,requestedAt:s.toISOString(),expiresAt:new Date(s.getTime()+3e5).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}:{}}})},c=await t(r);if(NT(c)){let e=await b();e?.catalogRevision&&(c=await t(e))}if(c.phase!==`settled`)throw Error(c.error?.code??c.resultCode);return s(t=>{let r=t[e.sessionRef];return{...t,[e.sessionRef]:{...r??{assistant:``,activities:[],complete:!1,error:null},user:i,attachments:n?.attachments??[],operationRef:c.operationRef,abortable:!r?.complete&&!!c.operationRef}}}),b(),c}catch(e){throw e}},[b,x]),w=(0,v.useCallback)(async e=>{let t=u.current,n=o[e.sessionRef]?.operationRef,r=t?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t?.catalogRevision||!r||!n||o[e.sessionRef]?.abortable===!1)throw Error(`operation-unavailable`);let i=t=>{let r=t.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t.catalogRevision||!r)throw Error(`operation-unavailable`);let i=new Date;return x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:MT(`command`),idempotencyKey:MT(`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(NT(a)){let[t,r]=await Promise.all([b(),Cg().catch(()=>void 0)]);if(!t||!DT(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 b(),a},[o,b,x]),T=(0,v.useCallback)(async e=>{let t=async t=>{let n=await b(),r=n?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n?.catalogRevision||!r)throw Error(`session-unavailable`);let i=new Date,a=await x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:MT(`command`),idempotencyKey:MT(`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 b())?.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 b(),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}},[b,x]),E=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:MT(`command`),idempotencyKey:MT(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await b(),o},[b,x]),D=(0,v.useCallback)((e,t)=>E(e,`session.set-model`,{modelRef:t}),[E]),O=(0,v.useCallback)((e,t)=>E(e,`session.set-thinking`,{thinkingLevel:t}),[E]),k=(0,v.useCallback)((e,t)=>E(e,`session.set-permission`,{permissionMode:t}),[E]),A=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:MT(`command`),idempotencyKey:MT(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await b(),o},[b,x]),j=(0,v.useCallback)((e,t)=>A(e,`session.rename`,{title:t}),[A]),M=(0,v.useCallback)((e,t)=>A(e,`session.pin`,{pinned:t}),[A]),N=(0,v.useCallback)(e=>A(e,`session.archive`,{}),[A]),P=(0,v.useCallback)(e=>A(e,`session.unarchive`,{}),[A]),F=(0,v.useCallback)((e,t)=>A(e,`session.fork`,{entryRef:null,title:t}),[A]);return(0,v.useEffect)(()=>{let e=!1,t,n=0,i=!1,o=(()=>{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=MT(`client`);return window.localStorage.setItem(`piagent-gateway-client-ref`,t),t}catch{return MT(`client`)}})(),c=()=>{if(e)return;a(n===0?`connecting`:`reconnecting`);let g=window.location.protocol===`https:`?`wss:`:`ws:`,v=new WebSocket(`${g}//${window.location.host}/api/v1/gateway`,`piagent.gateway.v1`);d.current=v;let x=window.setTimeout(()=>v.close(1008,`hello-timeout`),5e3);v.addEventListener(`open`,()=>v.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`connect`,clientRef:o,minimumProtocol:1,maximumProtocol:1,lastEventSequence:f.current,catalogRevision:u.current?.catalogRevision??null}))),v.addEventListener(`message`,e=>{let t;try{t=JSON.parse(String(e.data))}catch{v.close(1007,`invalid-json`);return}if(!t||typeof t!=`object`){v.close(1008,`invalid-frame`);return}let o=t;if(o.messageType===`hello`){window.clearTimeout(x);let e=typeof o.capabilities?.gatewayInstanceRef==`string`?o.capabilities.gatewayInstanceRef:null;if(!e||p.current&&e!==p.current){f.current=null,m.current=!0,i=!0,v.close(AT,`gateway-epoch-changed`);return}p.current=e,n=0,r(o.capabilities),a(`connected`);return}if(o.messageType===`response`){let e=_.current.get(String(o.requestId));if(!e)return;_.current.delete(String(o.requestId)),window.clearTimeout(e.timeout),o.ok===!0&&o.result?e.resolve(o.result):e.reject(Error(String(o.error?.code??`gateway-request-failed`)));return}if(o.messageType!==`event`||!Number.isSafeInteger(o.sequence))return;let c=o.payload;if(o.kind===`resync.required`){m.current=!0,i=!0,v.close(AT,`canonical-resync-required`);return}let u=Number(o.sequence),d=f.current;if(!(d!==null&&u<=d)){if(d!==null&&u!==d+1){m.current=!0,i=!0,v.close(AT,`gateway-event-sequence-gap`);return}if(f.current=u,p.current&&y(p.current,u),o.kind===`message.delta`&&typeof c?.sessionRef==`string`&&typeof c.delta==`string`&&s(e=>({...e,[c.sessionRef]:{...e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],complete:!1,error:null},operationRef:c.operationRef,abortable:!0,assistant:`${e[c.sessionRef]?.assistant??``}${c.delta}`}})),[`tool.started`,`tool.completed`].includes(String(o.kind))&&typeof c?.sessionRef==`string`&&typeof c.toolCallRef==`string`&&typeof c.toolLabel==`string`&&s(e=>{let t=e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef??null,abortable:!0,complete:!1,error:null,runtimeRecovery:null},n=o.kind===`tool.started`?`running`:c.isError===!0?`failed`:`completed`,r=[...t.activities.filter(e=>e.toolCallRef!==c.toolCallRef),{toolCallRef:c.toolCallRef,toolLabel:c.toolLabel,state:n,reasonCode:c.reasonCode??null}].slice(-16),i=c.reasonCode===`runtime-restart-required`?`required`:t.runtimeRecovery;return{...e,[c.sessionRef]:{...t,operationRef:c.operationRef??t.operationRef,activities:r,runtimeRecovery:i}}}),o.kind===`runtime.changed`&&typeof c?.sessionRef==`string`&&s(e=>{let t=[`running`,`paused`,`waiting-approval`].includes(String(c.liveState)),n=e[c.sessionRef]??(t&&typeof c.operationRef==`string`?{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef,abortable:!0,complete:!1,settlement:null,error:null,runtimeRecovery:null}:null);if(!n)return e;let r=c.reasonCode===`runtime-restart-required`?`restarting`:c.reasonCode===`runtime-restart-failed`?`failed`:[`required`,`restarting`].includes(String(n.runtimeRecovery))&&c.liveState===`idle`?`recovered`:n.runtimeRecovery;return t?{...e,[c.sessionRef]:{...n,operationRef:c.operationRef??n.operationRef,abortable:!0,complete:!1,settlement:null,runtimeRecovery:r}}:!n.complete&&c.operationRef===null?{...e,[c.sessionRef]:{...n,assistant:``,abortable:!1,complete:!0,settlement:`unknown`,error:c.reasonCode??`operation-settlement-unknown`,runtimeRecovery:r}}:r===n.runtimeRecovery?e:{...e,[c.sessionRef]:{...n,runtimeRecovery:r}}}),o.kind===`message.completed`&&typeof c?.sessionRef==`string`&&s(e=>({...e,[c.sessionRef]:{...e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef,error:null},operationRef:c.operationRef,abortable:!1,complete:!0,settlement:`completed`,error:null}})),o.kind===`operation.settled`&&typeof c?.sessionRef==`string`&&typeof c.operationRef==`string`){s(e=>{let t=e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef,complete:!1,error:null,runtimeRecovery:null};return t.operationRef&&t.operationRef!==c.operationRef?e:{...e,[c.sessionRef]:TT(t,{operationRef:c.operationRef,settlement:c.settlement,reasonCode:c.reasonCode})}});let e=ST({operationRef:c.operationRef,settlement:c.settlement,reasonCode:c.reasonCode,settledAt:o.generatedAt,sequence:u});e&&l(t=>({...t,[c.sessionRef]:CT(t[c.sessionRef]??[],[e])}))}[`catalog.changed`,`session.changed`,`runtime.changed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&b()}}),v.addEventListener(`close`,()=>{window.clearTimeout(x);for(let e of _.current.values())window.clearTimeout(e.timeout),e.reject(Error(`gateway-connection-lost`));if(_.current.clear(),!e){if(a(`reconnecting`),i){i=!1,h();return}n+=1,t=window.setTimeout(c,Math.min(5e3,250*2**Math.min(n,5)))}}),v.addEventListener(`error`,()=>{})},h=async()=>{if(e)return;let r=await b({requireLiveState:!0});if(!e){if(r){n=0,c();return}a(`reconnecting`),n+=1,t=window.setTimeout(()=>void h(),Math.min(5e3,250*2**Math.min(n,5)))}};(async()=>{let t=await yg();if(!e){if(t===`failed`){a(`failed`);return}await h()}})();let g=()=>{!e&&document.visibilityState===`visible`&&b()};return document.addEventListener(`visibilitychange`,g),()=>{e=!0,t&&window.clearTimeout(t);for(let e of _.current.values())window.clearTimeout(e.timeout),e.reject(Error(`gateway-client-unmounted`));_.current.clear(),d.current?.close(1e3,`client-unmount`),document.removeEventListener(`visibilitychange`,g)}},[y,b]),{catalog:e,capabilities:n,connection:i,live:o,terminalActivities:c,refresh:b,create:S,send:C,abort:w,restart:T,setModel:D,setThinking:O,setPermission:k,rename:j,pin:M,archive:N,unarchive:P,fork:F}}var FT=document.getElementById(`root`);if(!FT)throw Error(`Piagent WebUI root is missing`);var IT=document.querySelector(`meta[name="csp-nonce"]`)?.content,LT=Ue({key:`piagent-mui`,nonce:IT&&!IT.startsWith(`__PIAGENT_`)?IT:void 0,prepend:!0});function RT(){let e=mT();return(0,W.jsx)(Ux,{...e})}function zT(){let e=PT();return(0,W.jsx)(dT,{...e})}function BT(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function VT(){let[e,t]=(0,v.useState)(()=>BT(`piagent-webui-locale`,[`vi`,`en`],pT(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,v.useState)(()=>BT(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)),i=(0,v.useMemo)(()=>fT(n),[n]);(0,v.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=n;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,n)}catch{}},[n,e]);let a=(0,v.useMemo)(()=>({locale:e,colorMode:n,setLocale:t,setColorMode:r}),[n,e]),o=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,W.jsx)(bv,{value:a,children:(0,W.jsxs)(Tc,{theme:i,children:[(0,W.jsx)(ns,{}),o===`gateway`?(0,W.jsx)(zT,{}):(0,W.jsx)(RT,{})]})})}(0,y.createRoot)(FT).render((0,W.jsx)(v.StrictMode,{children:(0,W.jsx)(ht,{value:LT,children:(0,W.jsx)(VT,{})})}));export{l as S,Sr as _,Mc as a,o as b,_s as c,Uo as d,va as f,G as g,K as h,X as i,Jo as l,Wr as m,Eu as n,Oc as o,xi as p,ll as r,Y as s,Z as t,J as u,pn as v,s as x,d as y};
176
+ `,t[0].length);return{text:r<0?``:e.slice(r+2).trimStart(),completionGate:n}}function yx(e){let t=vx(e);return t.completionGate===null&&_x(t.text)?t.text:null}function bx(e,t){let n=e?.trim(),r=t.trim();return!!(n&&r&&(n===r||n.startsWith(`/`)&&n.endsWith(` ${r}`)))}function xx(e,t,n){let r=t.trim(),i=yx(n)?.trim()??``,a=-1;if(r){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.role===`user`&&bx(n.content.text,r)){a=t;break}}if(a<0)return!1}if(!i)return!0;let o=a>=0?e[a]?.messageRef??null:null;for(let t=a+1;t<e.length;t+=1){let n=e[t];if(!(n?.role!==`assistant`||n.toolCalls.length>0)&&!(o&&n.parentMessageRef&&n.parentMessageRef!==o)&&yx(n.content.text??``)?.trim()===i)return!0}return!1}function Sx(e,t){let n=t.trim();if(!n)return!1;let r=-1;for(let t=e.length-1;t>=0;--t){let i=e[t];if(i?.role===`user`&&bx(i.content.text,n)){r=t;break}}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.toolCalls.length>0)&&!(i&&n.parentMessageRef&&n.parentMessageRef!==i)&&yx(n.content.text??``))return!0}return!1}function Cx(e){let t=[],n=new Map,r=new Set,i=null;for(let a of e){if(a.role===`user`){n.clear(),r.add(a.messageRef),i=a.messageRef,t.push(a);continue}if(a.role!==`assistant`||(a.parentMessageRef?!r.has(a.parentMessageRef):i===null)||a.toolCalls.length>0)continue;let e=yx(a.content.text??``);if(!e)continue;let o=n.get(e.trim());o===void 0?(n.set(e.trim(),t.length),t.push(a)):t[o]=a}return t}function wx(e,t,n){return e===`vi`?t:n}var Tx={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`},Ex=Object.keys(Tx).map(e=>`.${e}`).join(`,`),Dx=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]);function Ox(e){return e>=1048576?`${(e/1024/1024).toFixed(1)} MiB`:`${(e/1024).toFixed(+(e<10240))} KiB`}function kx(e,t){let n=e.truncated?` · ${wx(t,`đã cắt bớt`,`truncated`)}`:``;return e.kind===`image`?`${wx(t,`Ảnh`,`Image`)} · ${Ox(e.sizeBytes)}`:e.kind===`document`?`${wx(t,`Tài liệu`,`Document`)} · ${Ox(e.sourceBytes)} → ${Ox(e.sizeBytes)} ${wx(t,`văn bản`,`text`)}${n}`:`File · ${Ox(e.sizeBytes)}${n}`}function Ax(e){return[...e,...Object.entries(Tx).filter(([,t])=>e.has(t)).map(([e])=>`.${e}`)].join(`,`)}function jx(e){return!!(e&&[...e.types].includes(`Files`))}async function Mx(e){let{snapshot:t,locale:n}=e,r=[...e.existing],i=null,a=Math.max(0,4-r.length);e.files.length>a&&(i=wx(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=Tx[o.name.split(`.`).pop()?.toLowerCase()??``];if(!a){i=`${o.name}: ${wx(n,`loại file chưa được hỗ trợ.`,`unsupported file type.`)}`;continue}if(!e.allowed.has(a)){i=`${o.name}: ${a===`application/pdf`?wx(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.`):wx(n,`phiên Pi hiện tại không nhận loại file này.`,`the current Pi session does not accept this file type.`)}`;continue}let s=a.startsWith(`image/`)||Dx.has(a)?Math.min(t.capabilities.limits.maxAttachmentFileBytes,8388608):262144;if(o.size<1||o.size>s||r.reduce((e,t)=>e+t.sourceBytes,0)+o.size>t.capabilities.limits.maxAttachmentTotalBytes){i=`${o.name}: ${Dx.has(a)?wx(n,`vượt giới hạn gửi trực tiếp ${Ox(s)}. Hãy đặt tài liệu lớn trong project rồi mở ở mục Tài liệu; Pi sẽ đọc theo phần thay vì nhét cả file vào chat.`,`exceeds the ${Ox(s)} direct-send limit. Put a large document in the project and open Documents; Pi can read it in parts instead of placing the whole file in chat.`):wx(n,`vượt giới hạn đính kèm (tối đa ${Ox(s)}).`,`attachment limit exceeded (max ${Ox(s)}).`)}`;continue}let c=new Uint8Array(await o.arrayBuffer()),l=``;for(let e=0;e<c.length;e+=32768)l+=String.fromCharCode(...c.subarray(e,e+32768));let u=await e.stage(await O_(t,e.messageRequestId,{displayName:o.name,declaredMimeType:a,dataBase64:btoa(l)}));if(u.resultCode!==`staged`||!(`attachment`in u)||!u.attachment){i=`${o.name}: ${Q(u.error?.code??u.resultCode,n)}`;continue}r=[...r,u.attachment]}return{attachments:r,status:i}}async function Nx(e){let t=await e.stage(k_(e.snapshot,e.messageRequestId,e.attachmentRef));return t.messageType===`discard-receipt`&&t.resultCode===`discarded`?{discarded:!0,status:null}:{discarded:!1,status:`${wx(e.locale,`Chưa thể bỏ file`,`Unable to remove file`)} · ${Q(t.error?.code??t.resultCode,e.locale)}`}}function Px({snapshot:e,events:t,refreshSnapshot:n}){let{locale:r}=xv(),[i,a]=(0,v.useState)(),[o,s]=(0,v.useState)(!0),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(null),[y,b]=(0,v.useState)(``),[x,S]=(0,v.useState)(()=>`message-request.${crypto.randomUUID()}`),[C,w]=(0,v.useState)([]),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(!1),k=(0,v.useRef)(0),A=(0,v.useMemo)(()=>mx(t),[t]),j=[...t].reverse().find(e=>[`message.completed`,`message.failed`,`agent-operation.settled`].includes(String(e.kind)))?.eventCursor??null;(0,v.useEffect)(()=>{let e=new AbortController;return s(!0),a(void 0),c_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0).finally(()=>s(!1)),()=>e.abort()},[e.identity.sessionRef]),(0,v.useEffect)(()=>{w([]),S(`message-request.${crypto.randomUUID()}`)},[e.identity.sessionRef]),(0,v.useEffect)(()=>{let e=e=>{e.dataTransfer&&[...e.dataTransfer.types].includes(`Files`)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]),(0,v.useEffect)(()=>{if(!j)return;let e=new AbortController,t=window.setTimeout(()=>{c_(null,50,e.signal).then(e=>a(e)).catch(()=>void 0)},80);return()=>{window.clearTimeout(t),e.abort()}},[j]);let M=async()=>{try{let e=await l_();return h(e),e}catch{return}};(0,v.useEffect)(()=>{let e=new AbortController;return l_(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[e.identity.sessionRef,e.revision.queueRevision]);let N=async()=>{let e=i?.page.nextBeforeCursor;if(e)try{let t=await c_(e,i.page.limit);a(e=>e?{...e,items:px(e.items,t.items),page:t.page}:t)}catch{}},P=(0,v.useMemo)(()=>i?.state===`ready`?Cx(i.items):[],[i]),F=e.capabilities.capabilities[`control.chat`],I=F.status===`available`?F.actions:null,L=!!I?.send.available,R=e.capabilities.capabilities[`control.resumeAndContinue`].status===`available`,ee=L||R,te=e.capabilities.capabilities.attachments,ne=te.status===`available`,z=(0,v.useMemo)(()=>new Set(te.status===`available`?te.mimeTypes:[]),[te]),B=(0,v.useMemo)(()=>Ax(z),[z]),V=ne&&!u&&!T&&C.length<4,re=e.session.operation.liveness===`running`,ie=async()=>{await n?.(),await M()},ae=async t=>{let n=c.trim();if(!(!n||u||(t===`resume-and-continue`?!R:!L))){d(!0),p(null);try{let i=C.length?{messageRequestId:x,attachmentRefs:C.map(e=>e.attachmentRef)}:void 0,a=t===`resume-and-continue`?await g_(await P_(e,n,i)):await p_(await D_(e,n,t,i));[`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(l(``),w([]),S(`message-request.${crypto.randomUUID()}`),p(a.resultCode===`dispatch-observed`?$(r,`Đã gửi vào Pi session`,`Sent to the Pi session`):$(r,`Pi đã nhận yêu cầu`,`Pi received the request`))):a.resultCode===`held`?(l(``),p($(r,`Đã giữ trong hàng đợi`,`Held in the queue`))):a.resultCode===`resumed-not-dispatched`?p($(r,`Task đã mở lại nhưng tin nhắn chưa được gửi; nội dung vẫn được giữ để anh kiểm tra.`,`The task resumed but the message was not sent; the content remains for review.`)):p(`${$(r,`Chưa gửi`,`Not sent`)} · ${Q(a.resultCode,r)}`),await ie()}catch{p($(r,`Không thể gửi; trạng thái Pi có thể đã thay đổi.`,`Unable to send; Pi state may have changed.`))}finally{d(!1)}}},oe=async t=>{if(!(!t?.length||!ne||T)){E(!0),p(null);try{let n=await Mx({files:t,snapshot:e,messageRequestId:x,existing:C,allowed:z,locale:r,stage:w_});w(n.attachments),p(n.status)}catch{p($(r,`Không thể đính kèm; file không được gửi vào Pi.`,`Unable to attach the file; it was not sent to Pi.`))}finally{E(!1)}}},se=()=>{k.current=0,O(!1)},H=e=>{jx(e.dataTransfer)&&(e.preventDefault(),se(),V&&oe(e.dataTransfer.files))},ce=async t=>{if(!(u||T)){E(!0),p(null);try{let n=await Nx({snapshot:e,messageRequestId:x,attachmentRef:t,locale:r,stage:w_});n.discarded?w(e=>e.filter(e=>e.attachmentRef!==t)):p(n.status)}catch{p($(r,`Không thể bỏ file; trạng thái Pi có thể đã thay đổi.`,`Unable to remove the file; Pi state may have changed.`))}finally{E(!1)}}},le=async(t,n,i)=>{if(!u){d(!0),p(null);try{let a=await p_(await A_(e,t,t===`queue.update`?await j_(n,i?.trim()??``):t===`queue.delete`?{queueItemRef:n}:{queueItemRef:n,messageRequestId:`message-request.${crypto.randomUUID()}`}));[`updated`,`deleted`,`dispatch-observed`,`dispatch-requested`].includes(a.resultCode)?(_(null),b(``),p(Q(a.resultCode,r))):p(`${$(r,`Chưa thay đổi`,`Not changed`)} · ${Q(a.resultCode,r)}`),await ie()}catch{p($(r,`Hàng đợi đã thay đổi; đã tải lại trạng thái mới nhất.`,`The queue changed; the latest state has been reloaded.`)),await ie()}finally{d(!1)}}};return(0,W.jsxs)(`section`,{className:`chat-panel surface`,"aria-labelledby":`chat-heading`,"data-dragging":D||void 0,onDragEnter:e=>{jx(e.dataTransfer)&&(k.current+=1,O(!0))},onDragOver:e=>{jx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=V?`copy`:`none`)},onDragLeave:e=>{jx(e.dataTransfer)&&(--k.current,k.current<=0&&se())},onDrop:H,children:[D&&(0,W.jsxs)(`div`,{className:`chat-drop-overlay`,role:`status`,children:[(0,W.jsx)(`strong`,{children:V?$(r,`Thả tài liệu vào đây`,`Drop documents here`):C.length>=4?$(r,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):$(r,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),V&&(0,W.jsx)(`small`,{children:$(r,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),(0,W.jsxs)(`header`,{className:`chat-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Đúng Pi session hiện tại`,`Exact current Pi session`)}),(0,W.jsx)(`h2`,{id:`chat-heading`,children:`Chat`})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`span`,{children:[P.length,` `,$(r,`message gần nhất`,`recent messages`)]}),(0,W.jsx)(`span`,{className:`chat-read-state`,children:$(r,`Streaming trực tiếp`,`Live streaming`)})]})]}),(0,W.jsxs)(`div`,{className:`chat-body`,"aria-live":`polite`,children:[i?.page.hasOlder&&(0,W.jsx)(`button`,{type:`button`,className:`load-older`,onClick:()=>void N(),children:$(r,`Tải message cũ hơn`,`Load older messages`)}),o&&(0,W.jsx)(`p`,{className:`chat-empty`,children:$(r,`Đang tải transcript hiện tại…`,`Loading the current transcript…`)}),!o&&i?.state===`unavailable`&&(0,W.jsxs)(`p`,{className:`chat-empty`,children:[$(r,`Transcript cần đồng bộ lại`,`Transcript needs resync`),` · `,Q(i.reasonCode,r)]}),!o&&i?.state===`ready`&&P.length===0&&A.assistants.length===0&&(0,W.jsx)(`p`,{className:`chat-empty`,children:$(r,`Chưa có message trong Pi session này.`,`There are no messages in this Pi session.`)}),P.map(e=>e.role===`tool-result`?(0,W.jsxs)(`article`,{className:`chat-tool-result`,children:[(0,W.jsx)(`strong`,{children:e.toolCalls[0]?.toolName??`Tool`}),(0,W.jsx)(`span`,{children:$(r,`Kết quả chi tiết nằm trong Activity`,`Detailed output is available in Activity`)})]},e.messageRef):(0,W.jsxs)(`article`,{className:`chat-message chat-${e.role}`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.role===`user`?$(r,`Anh`,`You`):`Pi`}),(0,W.jsx)(`time`,{children:new Date(e.recordedAt).toLocaleTimeString(r===`vi`?`vi-VN`:`en-US`,{hour:`2-digit`,minute:`2-digit`})})]}),(0,W.jsx)(`p`,{children:e.content.text||(e.content.imageCount?`${e.content.imageCount} ${$(r,`ảnh đính kèm`,`attached images`)}`:$(r,`Message trống`,`Empty message`))}),(e.content.redacted||e.content.truncated)&&(0,W.jsx)(`small`,{children:e.content.redacted?$(r,`Đã che dữ liệu nhạy cảm`,`Sensitive data redacted`):$(r,`Nội dung đã rút gọn`,`Content truncated`)})]},e.messageRef)),A.assistants.map(e=>(0,W.jsxs)(`article`,{className:`chat-message chat-assistant chat-streaming`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:`Pi`}),(0,W.jsx)(`span`,{className:`stream-indicator`,children:$(r,`Đang trả lời`,`Responding`)})]}),(0,W.jsx)(`p`,{children:e.text||(e.thinking?$(r,`Đang suy nghĩ…`,`Thinking…`):$(r,`Đang chuẩn bị câu trả lời…`,`Preparing a response…`))}),e.truncated&&(0,W.jsx)(`small`,{children:$(r,`Live preview đã đạt giới hạn`,`Live preview limit reached`)})]},e.messageRef)),A.tools.filter(e=>[`started`,`progress`].includes(e.state)).map(e=>(0,W.jsxs)(`article`,{className:`chat-tool-live`,children:[(0,W.jsx)(`span`,{className:`tool-spinner`,"aria-hidden":`true`}),(0,W.jsx)(`strong`,{children:e.toolName}),(0,W.jsx)(`span`,{children:Q(e.state,r)})]},e.toolCallId))]}),m?.state===`ready`&&m.items.length>0&&(0,W.jsxs)(`section`,{className:`held-queue`,"aria-label":$(r,`Tin nhắn đang giữ`,`Held messages`),children:[(0,W.jsxs)(`div`,{className:`held-queue-heading`,children:[(0,W.jsx)(`strong`,{children:$(r,`Đang giữ ${m.heldCount} tin`,`${m.heldCount} held messages`)}),m.quarantinedCount>0&&(0,W.jsxs)(`span`,{children:[m.quarantinedCount,` `,$(r,`tin cần kiểm tra`,`need review`)]})]}),(0,W.jsx)(`ol`,{children:m.items.map(e=>(0,W.jsxs)(`li`,{"data-state":e.state,children:[g===e.queueItemRef?(0,W.jsx)(`textarea`,{"aria-label":$(r,`Sửa tin nhắn đang giữ`,`Edit held message`),rows:2,maxLength:65536,value:y,onChange:e=>b(e.target.value)}):(0,W.jsx)(`p`,{children:e.preview}),(0,W.jsx)(`div`,{children:g===e.queueItemRef?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,disabled:u||!y.trim(),onClick:()=>void le(`queue.update`,e.queueItemRef,y),children:$(r,`Lưu`,`Save`)}),(0,W.jsx)(`button`,{type:`button`,disabled:u,onClick:()=>{_(null),b(``)},children:$(r,`Hủy`,`Cancel`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||!I?.dispatchHeld.available,onClick:()=>void le(`queue.dispatch`,e.queueItemRef),children:$(r,`Gửi`,`Send`)}),(0,W.jsx)(`button`,{type:`button`,disabled:u||e.state!==`held`||e.redacted||e.truncated||!I?.editHeld.available,title:e.redacted||e.truncated?$(r,`Không sửa từ preview đã che hoặc rút gọn`,`Redacted or truncated previews cannot be edited`):void 0,onClick:()=>{_(e.queueItemRef),b(e.preview)},children:$(r,`Sửa`,`Edit`)}),(0,W.jsx)(`button`,{type:`button`,disabled:u||!I?.deleteHeld.available,onClick:()=>void le(`queue.delete`,e.queueItemRef),children:$(r,`Xóa`,`Delete`)})]})}),(e.redacted||e.truncated||e.state===`quarantined`)&&(0,W.jsx)(`small`,{children:e.state===`quarantined`?$(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?$(r,`Preview đã che dữ liệu nhạy cảm`,`Sensitive data is redacted in the preview`):$(r,`Preview đã rút gọn`,`Preview truncated`)})]},e.queueItemRef))})]}),(0,W.jsxs)(`footer`,{className:`chat-composer-preview`,children:[C.length>0&&(0,W.jsx)(`ul`,{className:`attachment-list`,"aria-label":$(r,`File sẽ gửi cùng message`,`Files to send with the message`),children:C.map(e=>(0,W.jsxs)(`li`,{"data-kind":e.kind,children:[(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`strong`,{children:e.displayName}),(0,W.jsx)(`small`,{children:kx(e,r)})]}),(0,W.jsx)(`button`,{type:`button`,disabled:u||T,"aria-label":`${$(r,`Bỏ`,`Remove`)} ${e.displayName}`,onClick:()=>void ce(e.attachmentRef),children:$(r,`Bỏ`,`Remove`)})]},e.attachmentRef))}),(0,W.jsx)(`textarea`,{"aria-label":$(r,`Nội dung chat`,`Chat message`),placeholder:R?$(r,`Nhập việc cần Pi làm ngay sau khi mở lại task…`,`Enter work for Pi immediately after the task resumes…`):L?$(r,`Nhắn vào đúng Pi session này…`,`Message this exact Pi session…`):$(r,`Chat control chưa khả dụng.`,`Chat control is unavailable.`),disabled:!ee||u,maxLength:65536,rows:2,value:c,onChange:e=>l(e.target.value),onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),V&&oe(e.clipboardData.files))}}),(0,W.jsxs)(`div`,{className:`composer-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:!ee||u||!c.trim(),onClick:()=>void ae(R?`resume-and-continue`:re?`follow-up`:`new-operation`),children:u?$(r,`Đang gửi…`,`Sending…`):R?$(r,`Tiếp tục & gửi`,`Resume & send`):re?$(r,`Gửi sau`,`Send next`):$(r,`Gửi`,`Send`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!L||u||!c.trim()||C.length>0||!I?.hold.available,title:C.length?$(r,`Bản này chưa giữ file trong hàng đợi`,`This version does not hold attachments in the queue`):void 0,onClick:()=>void ae(`hold`),children:$(r,`Giữ lại`,`Hold`)}),re&&(0,W.jsx)(`button`,{type:`button`,className:`interrupt-send`,disabled:!L||u||!c.trim()||!I?.interruptAndSend.available,onClick:()=>void ae(`steer`),children:$(r,`Ngắt & gửi`,`Interrupt & send`)})]}),(0,W.jsxs)(`label`,{className:`attachment-picker ${V?``:`disabled`}`,title:$(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,W.jsx)(`input`,{type:`file`,multiple:!0,disabled:!V,accept:B||void 0,onChange:e=>{oe(e.target.files),e.currentTarget.value=``}}),T?$(r,`Đang đọc tài liệu…`,`Reading documents…`):`${$(r,`Đính kèm hoặc kéo thả`,`Attach or drop`)} (${C.length}/4)`]}),f&&(0,W.jsx)(`small`,{role:`status`,children:f})]})]})}function Fx({snapshot:e,refreshSnapshot:t}){let{locale:n}=xv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(``),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(null),[p,m]=(0,v.useState)(null),h=(0,v.useRef)(0),g=(0,v.useRef)({revision:0,modelDirty:!1,thinkingDirty:!1}),_=e.capabilities.capabilities[`control.sessionOptions`],y=_.status===`available`?_.actions:null,b=async e=>{let t=++h.current,n=g.current.revision;try{let r=await u_(e);return t===h.current?(i(r),r.state===`ready`&&n===g.current.revision&&(g.current.modelDirty||o(r.activeModelRef??``),g.current.thinkingDirty||c(r.activeThinkingLevel??`off`)),r):r}catch{!e?.aborted&&t===h.current&&i(void 0);return}};(0,v.useEffect)(()=>{let e=new AbortController;return b(e.signal),()=>e.abort()},[e.identity.sessionRef,e.revision.sessionOptionRevision]);let x=(0,v.useMemo)(()=>r?.models.find(e=>e.modelRef===r.activeModelRef),[r]),S=async i=>{if(!l||d||!r||r.state!==`ready`)return;let o=i===`model`?`session-options.set-model`:`session-options.set-thinking`,c=i===`model`?a:s;f(i),m(null);try{let r=await m_(await M_(e,o,c));m(r.resultCode===`changed`?$(n,`Đã cập nhật trong Pi và mặc định người dùng`,`Updated in Pi and user defaults`):r.resultCode===`unchanged`?$(n,`Giá trị này đang được dùng`,`This value is already active`):r.resultCode===`effect-unknown`?$(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`):`${$(n,`Chưa thay đổi`,`Not changed`)} · ${Q(r.resultCode,n)}`),u(!1),g.current.revision+=1,i===`model`?g.current.modelDirty=!1:g.current.thinkingDirty=!1,await t?.(),await b()}catch{m($(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,W.jsxs)(`section`,{className:`session-options surface`,"aria-labelledby":`session-options-title`,children:[(0,W.jsxs)(`div`,{className:`session-options-copy`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Model & thinking`}),(0,W.jsx)(`h2`,{id:`session-options-title`,children:$(n,`Thiết lập cho Pi session`,`Pi session settings`)}),(0,W.jsx)(`p`,{children:$(n,`Chỉ thay đổi khi Pi đang chờ. Thao tác này không gọi model, nhưng Pi 0.84.1 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 0.84.1 also updates user defaults.`)})]}),r?.state===`ready`?(0,W.jsxs)(`div`,{className:`session-options-controls`,children:[(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:`Model`}),(0,W.jsx)(`select`,{"aria-label":$(n,`Chọn model`,`Select model`),value:a,disabled:d!==null||!y?.setModel.available,onChange:e=>{g.current.revision+=1,g.current.modelDirty=!0,o(e.target.value),u(!1),m(null)},children:r.models.map(e=>(0,W.jsxs)(`option`,{value:e.modelRef,children:[e.displayName,` · `,e.provider]},e.modelRef))})]}),(0,W.jsxs)(`label`,{children:[(0,W.jsx)(`span`,{children:`Thinking`}),(0,W.jsx)(`select`,{"aria-label":$(n,`Chọn thinking`,`Select thinking`),value:s,disabled:d!==null||!y?.setThinking.available,onChange:e=>{g.current.revision+=1,g.current.thinkingDirty=!0,c(e.target.value),u(!1),m(null)},children:(x?.supportedThinkingLevels??[]).map(e=>(0,W.jsx)(`option`,{value:e,children:Q(e,n)},e))})]}),(0,W.jsxs)(`label`,{className:`effect-ack`,children:[(0,W.jsx)(`input`,{type:`checkbox`,checked:l,disabled:d!==null||!y,onChange:e=>u(e.target.checked)}),(0,W.jsx)(`span`,{children:$(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,W.jsxs)(`div`,{className:`session-option-actions`,children:[(0,W.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setModel.available||a===r.activeModelRef,onClick:()=>void S(`model`),children:d===`model`?$(n,`Đang đổi…`,`Changing…`):$(n,`Đổi model`,`Change model`)}),(0,W.jsx)(`button`,{type:`button`,disabled:!l||d!==null||!y?.setThinking.available||s===r.activeThinkingLevel,onClick:()=>void S(`thinking`),children:d===`thinking`?$(n,`Đang đổi…`,`Changing…`):$(n,`Đổi thinking`,`Change thinking`)})]}),p&&(0,W.jsx)(`small`,{role:`status`,children:p}),!y?.setModel.available&&(0,W.jsxs)(`small`,{children:[$(n,`Đang khóa thay đổi`,`Changes locked`),` · `,Q(y?.setModel.reasonCode??(_.status===`unavailable`?_.reason?.code:`unavailable`),n)]})]}):(0,W.jsxs)(`div`,{className:`session-options-unavailable`,children:[(0,W.jsx)(`strong`,{children:$(n,`Catalog model chưa sẵn sàng`,`Model catalog unavailable`)}),(0,W.jsx)(`span`,{children:Q(r?.reasonCode??`authenticated-model-catalog-unavailable`,n)})]})]})}function Ix(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 Lx({state:e,setState:t,refreshSnapshot:n,locale:r}){let i=e.request;if(!i)return(0,W.jsx)(`article`,{className:`approval-card`,children:(0,W.jsx)(`p`,{children:e.error??$(r,`Đang tải yêu cầu phê duyệt…`,`Loading approval request…`)})});let a=i.action,o=Math.max(0,Math.ceil((Date.parse(i.expiresAt)-Date.now())/1e3)),s=async e=>{t({request:i,deciding:e});try{await f_(Ix(i,e)),await n?.()}catch{t({request:i,error:$(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,W.jsxs)(`article`,{className:`approval-card risk-${a.riskClass}`,"aria-labelledby":`approval-${i.approvalRef}`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(r,`Cần anh phê duyệt`,`Approval required`)}),(0,W.jsx)(`h2`,{id:`approval-${i.approvalRef}`,children:a.toolName})]}),(0,W.jsx)(`span`,{className:`approval-risk`,children:Q(a.riskClass,r)})]}),(0,W.jsx)(`p`,{className:`approval-reason`,children:a.reason}),a.commandPreview&&(0,W.jsx)(`pre`,{className:`approval-preview`,children:(0,W.jsx)(`code`,{children:a.commandPreview})}),!a.commandPreview&&a.parameterPreview&&(0,W.jsx)(`p`,{className:`approval-preview`,children:a.parameterPreview}),(0,W.jsxs)(`dl`,{className:`approval-facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Hành động`,`Action`)}),(0,W.jsx)(`dd`,{children:Q(a.kind,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Phạm vi`,`Scope`)}),(0,W.jsx)(`dd`,{children:Q(a.requestedScope,r)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Thư mục`,`Directory`)}),(0,W.jsx)(`dd`,{children:a.cwdDisplay??$(r,`Đã ẩn`,`Hidden`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(r,`Hết hạn`,`Expires`)}),(0,W.jsxs)(`dd`,{children:[o,`s`]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Task`}),(0,W.jsxs)(`dd`,{children:[pv(i.identity.taskId),` · `,pv(i.identity.taskRunId)]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Tool call`}),(0,W.jsx)(`dd`,{children:pv(i.identity.toolCallId)})]})]}),a.targetPaths.length>0&&(0,W.jsxs)(`div`,{className:`approval-targets`,children:[(0,W.jsx)(`strong`,{children:$(r,`Đích tác động`,`Targets`)}),(0,W.jsx)(`ul`,{children:a.targetPaths.map(e=>(0,W.jsx)(`li`,{children:e},e))})]}),a.providerRef&&(0,W.jsxs)(`p`,{className:`approval-targets`,children:[(0,W.jsx)(`strong`,{children:`Provider:`}),` `,pv(a.providerRef)]}),(0,W.jsxs)(`div`,{className:`approval-consequences`,children:[(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:$(r,`Nếu cho phép:`,`If allowed:`)}),` `,a.consequences.allow]}),(0,W.jsxs)(`p`,{children:[(0,W.jsx)(`strong`,{children:$(r,`Nếu từ chối:`,`If denied:`)}),` `,a.consequences.deny]})]}),e.error&&(0,W.jsx)(`p`,{className:`form-error`,role:`alert`,children:e.error}),(0,W.jsxs)(`footer`,{children:[(0,W.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:!!e.deciding,onClick:()=>void s(`deny`),children:$(r,`Từ chối`,`Deny`)}),(0,W.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:!!e.deciding,onClick:()=>void s(`allow`),children:e.deciding===`allow`?$(r,`Đang kiểm tra lại…`,`Rechecking…`):$(r,`Cho phép đúng 1 lần`,`Allow once`)})]})]})}function Rx({approvalRefs:e,sessionRef:t,refreshSnapshot:n}){let{locale:r}=xv(),i=(0,v.useMemo)(()=>e,[e.join(`\0`)]),[a,o]=(0,v.useState)({});return(0,v.useEffect)(()=>{let e=new AbortController;for(let n of i)(t?Ig(t,n,e.signal):d_(n,e.signal)).then(e=>o(t=>({...t,[n]:{request:e}})),()=>o(e=>({...e,[n]:{error:$(r,`Không thể tải yêu cầu phê duyệt hiện tại.`,`Unable to load the current approval request.`)}})));return()=>e.abort()},[r,t,i]),i.length===0?null:(0,W.jsx)(`section`,{className:`approval-stack`,"aria-label":$(r,`Yêu cầu phê duyệt đang chờ`,`Pending approval requests`),"aria-live":`polite`,children:i.map(e=>(0,W.jsx)(Lx,{state:a[e]??{},setState:t=>o(n=>({...n,[e]:t})),refreshSnapshot:n,locale:r},e))})}function zx({snapshot:e,refreshSnapshot:t}){let n=(0,v.useMemo)(()=>e.approvals.pending.map(e=>e.approvalRef),[e.approvals.pending]);return(0,W.jsx)(Rx,{approvalRefs:n,refreshSnapshot:t})}var Bx={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.`},Vx={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 Hx(e,t){return(t===`vi`?Bx:Vx)[e.resultCode]??(e.error?.message||`${$(t,`Chưa thực hiện`,`Not executed`)} · ${Q(e.resultCode,t)}`)}function Ux({snapshot:e,refreshSnapshot:t}){let{locale:n}=xv(),r=e.capabilities.capabilities[`control.lifecycle`],[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)(null),c=r.status===`available`,l=c?r.currentPhase:`unknown`,u=c?r.stopPhaseSupport[l]:null,d=!!(u?.stop===`supported`&&e.identity.agentOperationId),f=!!(c&&r.actions.pause.available),p=!!(c&&r.actions.resume.available);(0,v.useEffect)(()=>{o?.resultCode===`pause-requested`&&e.session.controlState===`paused`&&s({action:`lifecycle.pause`,resultCode:`paused`,text:(n===`vi`?Bx:Vx).paused}),o?.resultCode===`stop-requested`&&e.session.operation.liveness===`idle`&&s({action:`lifecycle.stop`,resultCode:`stopped`,text:(n===`vi`?Bx:Vx).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 h_(await N_(e,r));s({action:r,resultCode:i.resultCode,text:Hx(i,n)}),await t?.()}catch{s({action:r,resultCode:`request-failed`,text:$(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,W.jsxs)(`section`,{className:`lifecycle-panel surface`,"aria-labelledby":`lifecycle-title`,children:[(0,W.jsxs)(`div`,{className:`lifecycle-copy`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(n,`Điều khiển task`,`Task controls`)}),(0,W.jsx)(`h2`,{id:`lifecycle-title`,children:`Stop, pause & resume`}),(0,W.jsx)(`p`,{children:$(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,W.jsxs)(`div`,{className:`lifecycle-state`,children:[(0,W.jsx)(`span`,{children:$(n,`Trạng thái`,`Status`)}),(0,W.jsx)(`strong`,{children:Q(e.session.controlState,n)}),(0,W.jsxs)(`small`,{children:[`Pi: `,Q(e.session.operation.liveness,n),` · phase: `,Q(l,n)]})]}),(0,W.jsxs)(`div`,{className:`lifecycle-actions`,children:[(0,W.jsx)(`button`,{type:`button`,className:`danger-action`,disabled:i!==null||!d,onClick:()=>void m(`lifecycle.stop`),title:d?void 0:Q(u?.reasonCode??`no-current-operation`,n),children:i===`lifecycle.stop`?$(n,`Đang dừng…`,`Stopping…`):$(n,`Dừng lượt hiện tại`,`Stop current turn`)}),(0,W.jsx)(`button`,{type:`button`,className:`secondary-action`,disabled:i!==null||!f,onClick:()=>void m(`lifecycle.pause`),title:!f&&c?Q(r.actions.pause.reasonCode,n):void 0,children:i===`lifecycle.pause`?$(n,`Đang yêu cầu…`,`Requesting…`):$(n,`Tạm dừng task`,`Pause task`)}),(0,W.jsx)(`button`,{type:`button`,className:`primary-action`,disabled:i!==null||!p,onClick:()=>void m(`lifecycle.resume`),title:!p&&c?Q(r.actions.resume.reasonCode,n):void 0,children:i===`lifecycle.resume`?$(n,`Đang mở lại…`,`Resuming…`):$(n,`Tiếp tục task`,`Resume task`)})]}),o&&(0,W.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,W.jsxs)(`p`,{className:`lifecycle-result result-warning`,children:[$(n,`Điều khiển chưa sẵn sàng`,`Controls unavailable`),` · `,Q(r.reason?.code,n)]})]})}function Wx(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 Gx({value:e,locale:t}){return(0,W.jsxs)(`span`,{className:`status-pill tone-${fv(e)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Q(e,t)]})}function Kx({snapshot:e}){let{locale:t}=xv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),[o,s]=(0,v.useState)(`all`),[c,l]=(0,v.useState)(null),[u,d]=(0,v.useState)(),[f,p]=(0,v.useState)(`idle`),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(`idle`),[y,b]=(0,v.useState)(),[x,S]=(0,v.useState)(`idle`),[C,w]=(0,v.useState)(),[T,E]=(0,v.useState)(`idle`);(0,v.useEffect)(()=>{let e=new AbortController;return a(`loading`),t_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`),l(e=>e&&t.runs.some(t=>t.runRef===e)?e:t.activeRunRef??t.runs[0]?.runRef??null))}).catch(()=>{e.signal.aborted||a(`error`)}),()=>e.abort()},[e.revision.taskRevision,e.revision.eventCursor]);let D=(0,v.useMemo)(()=>(n?.runs??[]).filter(e=>o===`all`||o===`current`&&e.isCurrentSession||o===`terminal`&&e.terminal),[n,o]);return(0,v.useEffect)(()=>{if(!c){d(void 0),p(`idle`);return}let e=new AbortController;return p(`loading`),n_(c,e.signal).then(t=>{e.signal.aborted||(d(t),p(`ready`))}).catch(()=>{e.signal.aborted||p(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){b(void 0),S(`idle`);return}let e=new AbortController;return S(`loading`),i_(c,e.signal).then(t=>{e.signal.aborted||(b(t),S(`ready`))}).catch(()=>{e.signal.aborted||S(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){h(void 0),_(`idle`);return}let e=new AbortController;return _(`loading`),r_(c,e.signal).then(t=>{e.signal.aborted||(h(t),_(`ready`))}).catch(()=>{e.signal.aborted||_(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,v.useEffect)(()=>{if(!c){w(void 0),E(`idle`);return}let e=new AbortController;return E(`loading`),a_(c,e.signal).then(t=>{e.signal.aborted||(w(t),E(`ready`))}).catch(()=>{e.signal.aborted||E(`error`)}),()=>e.abort()},[c,e.revision.eventCursor]),(0,W.jsxs)(`section`,{className:`task-run-index surface`,"aria-labelledby":`task-run-index-title`,children:[(0,W.jsxs)(`header`,{className:`source-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Long-task dashboard`}),(0,W.jsx)(`h2`,{id:`task-run-index-title`,children:$(t,`Task và các lần chạy gần đây`,`Tasks and recent runs`)})]}),(0,W.jsxs)(`span`,{children:[n?.page.total??0,` `,$(t,`run từ local state`,`runs from local state`)]})]}),(0,W.jsx)(`div`,{className:`task-index-controls`,role:`group`,"aria-label":$(t,`Lọc task run`,`Filter task runs`),children:[[`all`,$(t,`Tất cả`,`All`)],[`current`,$(t,`Session này`,`This session`)],[`terminal`,$(t,`Đã kết thúc`,`Finished`)]].map(([e,t])=>(0,W.jsx)(`button`,{type:`button`,"aria-pressed":o===e,onClick:()=>s(e),children:t},e))}),i===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang đọc task state bền vững…`,`Reading durable task state…`)}),(i===`error`||n?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsxs)(`div`,{className:`task-run-list`,children:[D.map(e=>(0,W.jsxs)(`article`,{className:`task-run-card`,"data-active":e.isActive,"data-selected":e.runRef===c,children:[(0,W.jsxs)(`div`,{className:`task-run-main`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.summary||e.taskId}),e.isActive&&(0,W.jsx)(`span`,{className:`active-run-tag`,children:$(t,`Đang hoạt động`,`Active`)})]}),(0,W.jsxs)(`small`,{children:[e.taskId,` · `,$(t,`lần`,`attempt`),` `,e.attempt,`/`,e.maxAttempts,` · `,$(t,`cập nhật`,`updated`),` `,Wx(e.updatedAt,t)]})]}),(0,W.jsxs)(`div`,{className:`task-run-meta`,children:[(0,W.jsx)(Gx,{value:e.outcome,locale:t}),(0,W.jsx)(`span`,{children:e.progress.total?`${e.progress.completed}/${e.progress.total} ${$(t,`bước`,`steps`)}`:$(t,`Chưa có work plan`,`No work plan`)}),(0,W.jsx)(`span`,{children:e.sessionLabel??(e.isCurrentSession?$(t,`Session hiện tại`,`Current session`):$(t,`Session khác`,`Other session`))}),(0,W.jsx)(`button`,{type:`button`,"aria-pressed":e.runRef===c,onClick:()=>l(e.runRef),children:$(t,`Xem timeline`,`View timeline`)})]})]},e.runRef)),D.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Không có task run trong bộ lọc này.`,`No task runs match this filter.`)})]}),n?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n?.page.truncated&&(0,W.jsxs)(`p`,{className:`task-index-warning`,children:[$(t,`Danh sách đã rút gọn;`,`The list is truncated;`),` `,n.page.total-n.page.returned,` `,$(t,`run cũ chưa hiển thị.`,`older runs are not shown.`)]}),(0,W.jsxs)(`section`,{className:`task-timeline`,"aria-labelledby":`task-timeline-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Recovery timeline`}),(0,W.jsx)(`h3`,{id:`task-timeline-title`,children:$(t,`Crash, resume, pause và checkpoint`,`Crash, resume, pause, and checkpoints`)})]}),u?.state===`ready`&&(0,W.jsx)(Gx,{value:u.continuity.recoveryDecision,locale:t})]}),f===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem timeline.`,`Select a run to view its timeline.`)}),f===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh chuỗi Task Journal…`,`Verifying the Task Journal chain…`)}),(f===`error`||u?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`timeline-continuity`,children:[(0,W.jsxs)(`span`,{children:[`Crash evidence: `,(0,W.jsx)(`strong`,{children:Q(u.continuity.crashEvidence,t)})]}),(0,W.jsxs)(`span`,{children:[`Recovery: `,(0,W.jsx)(`strong`,{children:Q(u.continuity.recoveryDecision,t)})]})]}),(0,W.jsx)(`ol`,{className:`timeline-events`,children:u.events.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.state)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.title}),(0,W.jsxs)(`small`,{children:[`#`,e.sequence,` · `,Wx(e.recordedAt,t)]}),e.detail&&(0,W.jsx)(`p`,{children:e.detail})]}),(0,W.jsx)(Gx,{value:e.state,locale:t})]},e.eventRef))}),u.events.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(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,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,W.jsxs)(`section`,{className:`task-timeline recovery-history`,"aria-labelledby":`recovery-history-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Compaction & recovery`}),(0,W.jsx)(`h3`,{id:`recovery-history-title`,children:$(t,`Lịch sử rút gọn và phục hồi`,`Compaction and recovery history`)})]}),m?.state===`ready`&&(0,W.jsx)(Gx,{value:m.completeness,locale:t})]}),g===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem lịch sử rút gọn.`,`Select a run to view compaction history.`)}),g===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang đọc metadata compaction an toàn…`,`Reading safe compaction metadata…`)}),(g===`error`||m?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`timeline-continuity recovery-summary`,children:[(0,W.jsxs)(`span`,{children:[`Context compact: `,(0,W.jsx)(`strong`,{children:m.summary.contextCompactions})]}),(0,W.jsxs)(`span`,{children:[`Tool result: `,(0,W.jsx)(`strong`,{children:m.summary.toolResultCompactions})]}),(0,W.jsxs)(`span`,{children:[`Recovery: `,(0,W.jsx)(`strong`,{children:Q(m.recovery.decision,t)})]}),(0,W.jsxs)(`span`,{children:[`Verifier: `,(0,W.jsx)(`strong`,{children:Q(m.recovery.verifierState,t)})]})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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,W.jsx)(`ol`,{className:`timeline-events`,children:m.events.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.kind)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.title}),(0,W.jsxs)(`small`,{children:[`#`,e.sequence,` · `,Wx(e.recordedAt,t)]}),e.kind===`tool-result-compaction`&&(0,W.jsxs)(`p`,{children:[e.toolName,` · `,e.originalLines??`?`,` `,$(t,`dòng`,`lines`),` · `,e.captureCount,` capture`]}),e.detail&&(0,W.jsx)(`p`,{children:e.detail})]}),(0,W.jsx)(Gx,{value:`observed`,locale:t})]},e.eventRef))}),m.events.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Run này chưa có metadata compaction đã quan sát.`,`This run has no observed compaction metadata.`)})]}),m?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,W.jsxs)(`section`,{className:`task-timeline handoff-history`,"aria-labelledby":`handoff-history-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Handoff`}),(0,W.jsx)(`h3`,{id:`handoff-history-title`,children:$(t,`Bàn giao và việc cần làm tiếp theo`,`Handoff and next work`)})]}),y?.state===`ready`&&(0,W.jsx)(Gx,{value:y.completeness,locale:t})]}),x===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem handoff.`,`Select a run to view its handoff.`)}),x===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh handoff và next action…`,`Verifying the handoff and next action…`)}),(x===`error`||y?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(t,`Handoff không đủ bằng chứng tin cậy; WebUI không đề xuất hành động.`,`The handoff lacks trustworthy evidence; WebUI will not suggest an action.`)}),x===`ready`&&y?.state===`ready`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`next-action-card`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:$(t,`Việc tiếp theo`,`Next work`)}),(0,W.jsx)(`strong`,{children:Q(y.nextAction.action,t)})]}),(0,W.jsx)(`p`,{children:y.nextAction.reason}),(0,W.jsxs)(`small`,{children:[y.nextAction.exactCommandCount,` verifier command · `,$(t,`chỉ xem, không tự chạy`,`read-only, never auto-run`)]})]}),y.current&&(0,W.jsxs)(`div`,{className:`timeline-continuity handoff-summary`,children:[(0,W.jsxs)(`span`,{children:[`Outcome: `,(0,W.jsx)(`strong`,{children:Q(y.current.taskOutcome,t)})]}),(0,W.jsxs)(`span`,{children:[`Gate: `,(0,W.jsx)(`strong`,{children:Q(y.current.gateDecision,t)})]}),(0,W.jsxs)(`span`,{children:[`Authority: `,(0,W.jsx)(`strong`,{children:Q(y.current.requiredAuthority,t)})]}),(0,W.jsxs)(`span`,{children:[`Tree evidence: `,(0,W.jsx)(`strong`,{children:y.current.treeEvidenceCurrent?`current`:`not current`})]})]}),(0,W.jsx)(`ol`,{className:`timeline-events`,children:y.events.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.completionApproved?`completed`:`handoff`)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:$(t,`Handoff projection đã được ghi`,`Handoff projection recorded`)}),(0,W.jsxs)(`small`,{children:[`#`,e.sequence,` · `,Wx(e.recordedAt,t)]}),(0,W.jsxs)(`p`,{children:[e.phase??`unknown`,` · `,Q(e.projectedAction,t)]})]}),(0,W.jsx)(Gx,{value:e.completionApproved?`completed`:`observed`,locale:t})]},e.eventRef))}),!y.current&&y.events.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Run này chưa có handoff đã quan sát.`,`This run has no observed handoff.`)})]}),y?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]}),(0,W.jsxs)(`section`,{className:`task-timeline subagent-tree`,"aria-labelledby":`subagent-tree-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Helper / subagent tree`}),(0,W.jsx)(`h3`,{id:`subagent-tree-title`,children:$(t,`Quyền sở hữu và vòng đời helper`,`Helper ownership and lifecycle`)})]}),C?.state===`ready`&&(0,W.jsx)(Gx,{value:C.evidenceState,locale:t})]}),T===`idle`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Chọn một run để xem helper/subagent.`,`Select a run to view helpers and subagents.`)}),T===`loading`&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh helper ledger bền vững…`,`Verifying the durable helper ledger…`)}),(T===`error`||C?.state===`unavailable`)&&(0,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(t,`Helper ledger không đủ tin cậy; WebUI không suy đoán cây subagent.`,`The helper ledger lacks trustworthy evidence; WebUI will not infer a subagent tree.`)}),T===`ready`&&C?.state===`ready`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`next-action-card`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`span`,{children:$(t,`Quyết định điều phối`,`Delegation decision`)}),(0,W.jsx)(`strong`,{children:C.delegation.action===`dispatch`?$(t,`Gửi 1 helper chỉ đọc`,`Dispatch one read-only helper`):$(t,`Parent tự làm`,`Parent works directly`)})]}),(0,W.jsx)(`p`,{children:C.delegation.reasonCodes.map(e=>Q(e,t)).join(` · `)}),(0,W.jsxs)(`small`,{children:[$(t,`Tiết kiệm token dự kiến`,`Projected net token saving`),`: `,C.delegation.projectedNetSavingsRatio===null?$(t,`chưa được chứng minh`,`not proven`):`${Math.round(C.delegation.projectedNetSavingsRatio*100)}%`,` · `,$(t,`ngưỡng`,`threshold`),` `,Math.round(C.delegation.minimumRequiredNetSavingsRatio*100),`% · `,$(t,`tối đa 1 helper, 0 retry, 0 writer`,`max 1 helper, 0 retries, 0 writers`)]})]}),(0,W.jsxs)(`div`,{className:`timeline-continuity subagent-summary`,children:[(0,W.jsxs)(`span`,{children:[$(t,`Tổng helper`,`Total helpers`),`: `,(0,W.jsx)(`strong`,{children:C.summary.total})]}),(0,W.jsxs)(`span`,{children:[$(t,`Đang chạy`,`Running`),`: `,(0,W.jsx)(`strong`,{children:C.summary.active})]}),(0,W.jsxs)(`span`,{children:[$(t,`Kết quả stale`,`Stale results`),`: `,(0,W.jsx)(`strong`,{children:C.summary.staleResults})]}),(0,W.jsxs)(`span`,{children:[$(t,`Writer hiện tại`,`Current writer`),`: `,(0,W.jsx)(`strong`,{children:Q(C.writer.state,t)})]})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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,W.jsx)(`ol`,{className:`timeline-events`,children:C.children.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`span`,{className:`timeline-dot tone-${fv(e.lifecycleState)}`,"aria-hidden":`true`}),(0,W.jsxs)(`div`,{children:[(0,W.jsxs)(`strong`,{children:[Q(e.role,t),` · `,Q(e.authority,t)]}),(0,W.jsxs)(`small`,{children:[Wx(e.reservedAt,t),` → `,e.completedAt?Wx(e.completedAt,t):$(t,`đang giữ lease`,`lease active`)]}),(0,W.jsxs)(`p`,{children:[e.result.disposition?Q(e.result.disposition,t):$(t,`Chưa có result evidence`,`No result evidence`),e.result.calls===null?``:` · ${e.result.calls} calls · ${e.result.tokens??0} tokens`]})]}),(0,W.jsx)(Gx,{value:e.result.state===`not-recorded`?e.lifecycleState:e.result.state,locale:t})]},e.nodeRef))}),C.children.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Không có lifecycle helper chi tiết cho run này.`,`No detailed helper lifecycle is available for this run.`)}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(t,`Cây lồng nhiều tầng: chưa có durable lineage; WebUI chỉ hiển thị quan hệ task cha → helper trực tiếp.`,`Nested trees: durable lineage is not yet available, so WebUI only shows parent task → direct helper relationships.`)})]}),C?.warnings.map(e=>(0,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code))]})]})}function qx(e,t){if(!e)return $(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 Jx({value:e,locale:t}){return(0,W.jsxs)(`span`,{className:`status-pill tone-${fv(e)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),Q(e,t)]})}function Yx({snapshot:e}){let{locale:t}=xv(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`loading`),o=(0,v.useRef)(null),s=(0,v.useCallback)(()=>{o.current?.abort();let e=new AbortController;o.current=e,a(`loading`),o_(e.signal).then(t=>{e.signal.aborted||(r(t),a(`ready`))}).catch(()=>{e.signal.aborted||a(`error`)})},[]);return(0,v.useEffect)(()=>(s(),()=>o.current?.abort()),[s,e.identity.projectRef,e.identity.runtimeInstanceId]),(0,W.jsxs)(`section`,{className:`release-monitor surface`,"aria-labelledby":`release-monitor-title`,children:[(0,W.jsxs)(`header`,{className:`source-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Benchmark & release`}),(0,W.jsx)(`h2`,{id:`release-monitor-title`,children:$(t,`Theo dõi chất lượng và mức sẵn sàng phát hành`,`Quality and release readiness`)})]}),(0,W.jsx)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,children:i===`loading`?$(t,`Đang đọc…`,`Loading…`):$(t,`Làm mới`,`Refresh`)})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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,W.jsx)(`p`,{className:`task-index-empty error-state`,children:$(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,W.jsx)(`p`,{className:`task-index-empty`,children:$(t,`Đang xác minh report, manifest và ledger…`,`Verifying reports, manifests, and ledgers…`)}),n&&(0,W.jsxs)(`div`,{className:`release-monitor-grid`,children:[(0,W.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`benchmark-monitor-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Benchmark runs`}),(0,W.jsx)(`h3`,{id:`benchmark-monitor-title`,children:$(t,`Các lần đo gần đây`,`Recent runs`)})]}),(0,W.jsx)(Jx,{value:n.benchmark.state,locale:t})]}),n.benchmark.runs.map(e=>(0,W.jsxs)(`article`,{className:`benchmark-run-card`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`strong`,{children:e.suiteId}),(0,W.jsx)(Jx,{value:e.lifecycle,locale:t})]}),(0,W.jsxs)(`small`,{children:[qx(e.updatedAt,t),` · `,e.completedRuns,`/`,e.expectedRuns,` `,$(t,`lượt`,`runs`),` · `,$(t,`nguồn`,`source`),` `,Q(e.sourceState,t)]}),(0,W.jsxs)(`div`,{className:`benchmark-run-facts`,children:[(0,W.jsxs)(`span`,{children:[`Gate `,(0,W.jsx)(`b`,{children:Q(e.releaseGate,t)})]}),(0,W.jsxs)(`span`,{children:[$(t,`Điểm`,`Score`),` `,(0,W.jsx)(`b`,{children:e.scores.overall??`—`})]}),(0,W.jsxs)(`span`,{children:[`Claim `,(0,W.jsx)(`b`,{children:Q(e.claimTier,t)})]})]})]},e.runRef)),n.benchmark.runs.length===0&&(0,W.jsx)(`p`,{className:`task-index-empty`,children:$(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,W.jsx)(`p`,{className:`task-index-warning`,role:`status`,children:e.message},e.code)),n.benchmark.page.truncated&&(0,W.jsx)(`p`,{className:`task-index-warning`,children:$(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,W.jsxs)(`section`,{className:`release-monitor-column`,"aria-labelledby":`release-readiness-title`,children:[(0,W.jsxs)(`header`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Release readiness`}),(0,W.jsx)(`h3`,{id:`release-readiness-title`,children:$(t,`RC hiện tại`,`Current RC`)})]}),(0,W.jsx)(Jx,{value:n.release.state,locale:t})]}),(0,W.jsxs)(`dl`,{className:`release-readiness-facts`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Local safe gate`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(Jx,{value:n.release.localSafeGate,locale:t})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`RC assembly`}),(0,W.jsx)(`dd`,{children:Q(n.release.rcAssembly,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Beta`}),(0,W.jsx)(`dd`,{children:Q(n.release.beta,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`GA`}),(0,W.jsx)(`dd`,{children:Q(n.release.gaRelease,t)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:$(t,`Báo cáo`,`Report`)}),(0,W.jsx)(`dd`,{children:qx(n.release.generatedAt,t)})]})]}),n.release.sourceState===`stale`&&(0,W.jsx)(`p`,{className:`task-index-warning`,children:$(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,W.jsxs)(`div`,{className:`release-blockers`,children:[(0,W.jsxs)(`strong`,{children:[n.release.blockerCount,` blocker`]}),(0,W.jsx)(`ul`,{children:n.release.blockers.map((e,t)=>(0,W.jsx)(`li`,{children:e},`${t}-${e}`))})]}),(0,W.jsx)(`p`,{className:`retained-content-note`,children:$(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 Xx=264,Zx={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 Qx({value:e,text:t,locale:n=`vi`}){return(0,W.jsxs)(`span`,{className:`status-pill tone-${fv(e)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,className:`status-dot`}),t??Q(e,n)]})}function $x({locale:e}){return(0,W.jsxs)(`section`,{className:`task-empty surface`,"aria-labelledby":`task-title`,children:[(0,W.jsx)(`div`,{className:`empty-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,W.jsx)(`h2`,{id:`task-title`,children:$(e,`Chưa có task đang chạy`,`No active task`)}),(0,W.jsx)(`p`,{children:$(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 eS({snapshot:e,locale:t}){let n=e.task;if(!n)return(0,W.jsx)($x,{locale:t});let r=vv(e,t);return(0,W.jsxs)(`section`,{className:`task-dashboard surface`,"aria-labelledby":`task-title`,children:[(0,W.jsxs)(`header`,{className:`task-heading`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(t,`Task hiện tại`,`Current task`)}),(0,W.jsx)(`h2`,{id:`task-title`,children:n.summary}),(0,W.jsxs)(`div`,{className:`task-meta`,children:[(0,W.jsx)(Qx,{value:n.outcome,locale:t}),(0,W.jsx)(`span`,{children:Q(n.changeMode,t)}),(0,W.jsx)(`span`,{children:Q(n.riskLane,t)})]})]}),(0,W.jsxs)(`div`,{className:`progress-number`,"aria-label":`${$(t,`Tiến độ`,`Progress`)} ${r.percent}%`,children:[(0,W.jsxs)(`strong`,{children:[r.percent,`%`]}),(0,W.jsx)(`span`,{children:r.text})]})]}),(0,W.jsx)(`div`,{className:`progress-track`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.percent,"aria-label":$(t,`Tiến độ tiêu chí`,`Criteria progress`),children:(0,W.jsx)(`span`,{style:{width:`${r.percent}%`}})}),n.blocker&&(0,W.jsxs)(`div`,{className:`blocker`,role:`status`,children:[(0,W.jsx)(`span`,{children:`Blocker`}),(0,W.jsx)(`p`,{children:n.blocker})]}),(0,W.jsxs)(`div`,{className:`criteria-heading`,children:[(0,W.jsx)(`h2`,{children:$(t,`Tiêu chí hoàn thành`,`Completion criteria`)}),(0,W.jsxs)(`span`,{children:[n.criteria.length,` `,$(t,`tiêu chí`,`criteria`)]})]}),(0,W.jsx)(`ol`,{className:`criteria-list`,children:n.criteria.map((e,n)=>(0,W.jsxs)(`li`,{className:`criterion-card`,children:[(0,W.jsx)(`span`,{className:`criterion-index tone-${fv(e.state)}`,children:String(n+1).padStart(2,`0`)}),(0,W.jsxs)(`div`,{className:`criterion-copy`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{children:e.obligation}),e.priority===`critical`&&(0,W.jsx)(`span`,{className:`critical-tag`,children:$(t,`Quan trọng`,`Critical`)})]}),(0,W.jsx)(`small`,{children:_v(e,t)})]}),(0,W.jsx)(Qx,{value:e.state,locale:t})]},e.criterionId))}),n.workPlan.length>0&&(0,W.jsxs)(`details`,{className:`work-plan`,children:[(0,W.jsxs)(`summary`,{children:[$(t,`Kế hoạch thực hiện`,`Work plan`),` · `,n.workPlan.length,` `,$(t,`bước`,`steps`)]}),(0,W.jsx)(`ol`,{children:n.workPlan.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(Qx,{value:e.status,locale:t}),(0,W.jsx)(`span`,{children:e.summary})]},e.stepId))})]})]})}function tS({snapshot:e,locale:t}){return(0,W.jsxs)(`aside`,{className:`context-rail`,"aria-label":$(t,`Tóm tắt phiên`,`Session summary`),children:[(0,W.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:`Task contract`}),(0,W.jsxs)(`dl`,{children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Task ID`}),(0,W.jsx)(`dd`,{title:e.identity.taskId??void 0,children:pv(e.identity.taskId)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Run ID`}),(0,W.jsx)(`dd`,{title:e.identity.taskRunId??void 0,children:pv(e.identity.taskRunId)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Verifier`}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(Qx,{value:e.verification.state,locale:t})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:`Queue`}),(0,W.jsx)(`dd`,{children:e.session.queue.state===`known`?`${e.session.queue.heldCount??0} ${$(t,`đang giữ`,`held`)}`:Q(e.session.queue.state,t)})]})]})]}),(0,W.jsxs)(`section`,{className:`surface compact-panel`,children:[(0,W.jsx)(`p`,{className:`section-kicker`,children:$(t,`Sức khỏe`,`Health`)}),(0,W.jsxs)(`div`,{className:`health-line`,children:[(0,W.jsx)(Qx,{value:e.health.state,locale:t}),(0,W.jsxs)(`span`,{children:[e.health.issues.length,` `,$(t,`lưu ý`,`issues`)]})]}),e.health.issues.slice(0,3).map(e=>(0,W.jsx)(`p`,{className:`health-issue`,children:e.message},e.issueRef))]})]})}function nS({snapshot:e,locale:t}){let n=[[`Runtime`,(0,W.jsx)(Qx,{value:e.session.operation.liveness,locale:t})],[`Task`,(0,W.jsx)(Qx,{value:e.session.controlState,locale:t})],[`Model`,(0,W.jsx)(`strong`,{children:mv(e,t)})],[`Thinking`,(0,W.jsx)(`strong`,{children:hv(e,t)})],[$(t,`Quyền`,`Permission`),(0,W.jsx)(`strong`,{children:gv(e,t)})],[`Approval`,(0,W.jsx)(Qx,{value:e.session.approvalState,locale:t})]];return(0,W.jsx)(Mc,{variant:`outlined`,className:`runtime-overview`,"aria-label":$(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,W.jsxs)(X,{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,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:800,letterSpacing:`.11em`,textTransform:`uppercase`},children:e}),t]},e))})}function rS({active:e,snapshot:t,events:n,refreshSnapshot:r,locale:i}){return e===`overview`?(0,W.jsxs)(Cf,{className:`workspace-stack`,spacing:2.25,children:[(0,W.jsx)(nS,{snapshot:t,locale:i}),(0,W.jsxs)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`minmax(0,1fr) 300px`},alignItems:`start`,gap:2.25},children:[(0,W.jsx)(eS,{snapshot:t,locale:i}),(0,W.jsx)(tS,{snapshot:t,locale:i})]}),(0,W.jsx)(dx,{snapshot:t})]}):e===`chat`?(0,W.jsxs)(Cf,{className:`workspace-stack`,spacing:2.25,children:[(0,W.jsx)(Ux,{snapshot:t,refreshSnapshot:r}),(0,W.jsx)(Fx,{snapshot:t,refreshSnapshot:r}),(0,W.jsx)(Px,{snapshot:t,events:n,refreshSnapshot:r})]}):e===`documents`?(0,W.jsx)(Zb,{}):e===`source`?(0,W.jsx)(Mv,{snapshot:t,refreshSnapshot:r}):e===`activity`?(0,W.jsx)(ix,{snapshot:t}):e===`history`?(0,W.jsx)(Kx,{snapshot:t}):(0,W.jsx)(Yx,{snapshot:t})}function iS({snapshot:e,connection:t=`connecting`,events:n=[],refreshSnapshot:r}){let{locale:i,colorMode:a,setLocale:o,setColorMode:s}=xv(),[c,l]=(0,v.useState)(`overview`),[u,d]=(0,v.useState)(!1);if(!e)return(0,W.jsxs)(X,{className:`loading-shell`,children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsx)(`p`,{className:`section-kicker`,children:`Piagent WebUI · local`}),(0,W.jsx)(Z,{variant:`h1`,children:t===`failed`?$(i,`Không thể nối vào Pi session`,`Unable to connect to the Pi session`):$(i,`Đang mở không gian làm việc`,`Opening the workspace`)}),(0,W.jsx)(Z,{color:`text.secondary`,children:t===`failed`?$(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.`):$(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,W.jsx)(bu,{size:22}),(0,W.jsx)(Qx,{value:t,locale:i})]});let f=Zx[c][i],p=(e.sourceChanges.task?.counts.files??0)+e.sourceChanges.workingTree.counts.files+e.sourceChanges.staged.counts.files,m=[{id:`overview`,label:$(i,`Tổng quan`,`Overview`),icon:(0,W.jsx)(jh,{})},{id:`chat`,label:$(i,`Chat & Task`,`Chat & Task`),icon:(0,W.jsx)(Mh,{}),count:e.session.queue.heldCount??0},{id:`documents`,label:$(i,`Tài liệu`,`Documents`),icon:(0,W.jsx)(Nh,{})},{id:`source`,label:`Source Changes`,icon:(0,W.jsx)(Ph,{}),count:p},{id:`activity`,label:`Activity`,icon:(0,W.jsx)(Fh,{}),count:e.activity.running.length},{id:`history`,label:$(i,`Lịch sử`,`History`),icon:(0,W.jsx)(Ih,{})},{id:`release`,label:`Release`,icon:(0,W.jsx)(Lh,{})}],h=e=>{l(e),d(!1)},g=(0,W.jsxs)(X,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[(0,W.jsxs)(up,{sx:{minHeight:`72px !important`,px:`18px !important`,gap:1.25},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:760,lineHeight:1.15},children:`Piagent`}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:`WebUI · local`})]})]}),(0,W.jsxs)(X,{sx:{mx:1.5,mb:1.25,p:1.35,border:1,borderColor:`divider`,borderRadius:2,bgcolor:`action.hover`},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{display:`block`,textTransform:`uppercase`,letterSpacing:`.09em`},children:$(i,`Pi session hiện tại`,`Current Pi session`)}),(0,W.jsx)(Z,{variant:`body2`,noWrap:!0,title:e.session.displayName??void 0,sx:{mt:.45,fontWeight:700},children:e.session.displayName??`Pi session`}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,title:e.identity.sessionRef,children:pv(e.identity.sessionRef)})]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{px:2.5,pt:1,pb:.5,fontWeight:800,letterSpacing:`.1em`,textTransform:`uppercase`},children:$(i,`Không gian làm việc`,`Workspaces`)}),(0,W.jsx)(nf,{component:`nav`,"aria-label":$(i,`Điều hướng WebUI`,`WebUI navigation`),sx:{py:.5},children:m.map(e=>(0,W.jsxs)(sf,{selected:c===e.id,"aria-current":c===e.id?`page`:void 0,onClick:()=>h(e.id),children:[(0,W.jsx)(ff,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:e.icon}),(0,W.jsx)(Sf,{primary:e.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:c===e.id?750:600}}}}),!!e.count&&(0,W.jsx)(tl,{badgeContent:e.count,color:e.id===`activity`?`secondary`:`primary`,max:99,sx:{mr:1}})]},e.id))}),(0,W.jsxs)(X,{sx:{mt:`auto`,p:1.5},children:[(0,W.jsx)(Eu,{sx:{mb:1.5}}),(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsxs)(op,{exclusive:!0,size:`small`,value:i,"aria-label":$(i,`Ngôn ngữ`,`Language`),onChange:(e,t)=>t&&o(t),sx:{flex:1},children:[(0,W.jsx)(ep,{value:`vi`,"aria-label":`Tiếng Việt`,sx:{flex:1},children:`VI`}),(0,W.jsx)(ep,{value:`en`,"aria-label":`English`,sx:{flex:1},children:`EN`})]}),(0,W.jsx)(Ah,{title:a===`dark`?$(i,`Chuyển sang giao diện sáng`,`Use light mode`):$(i,`Chuyển sang giao diện tối`,`Use dark mode`),children:(0,W.jsx)(Zd,{"aria-label":a===`dark`?$(i,`Dùng giao diện sáng`,`Use light mode`):$(i,`Dùng giao diện tối`,`Use dark mode`),onClick:()=>s(a===`dark`?`light`:`dark`),sx:{border:1,borderColor:`divider`,borderRadius:1.5},children:a===`dark`?(0,W.jsx)(zh,{fontSize:`small`}):(0,W.jsx)(Bh,{fontSize:`small`})})})]})]})]});return(0,W.jsxs)(X,{className:`app-shell`,"data-contract":`snapshot-v1`,children:[(0,W.jsx)(`a`,{className:`skip-link`,href:`#main-content`,children:$(i,`Bỏ qua điều hướng`,`Skip navigation`)}),(0,W.jsx)(Lc,{position:`fixed`,color:`transparent`,elevation:0,sx:{width:{md:`calc(100% - ${Xx}px)`},ml:{md:`${Xx}px`},borderBottom:1,borderColor:`divider`,bgcolor:`rgba(var(--piagent-palette-background-defaultChannel) / .88)`,backdropFilter:`blur(18px)`},children:(0,W.jsxs)(up,{sx:{minHeight:`72px !important`,gap:1.5},children:[(0,W.jsx)(Zd,{edge:`start`,"aria-label":$(i,`Mở menu`,`Open menu`),onClick:()=>d(!0),sx:{display:{md:`none`}},children:(0,W.jsx)(Rh,{})}),(0,W.jsxs)(X,{sx:{minWidth:0,flex:1},children:[(0,W.jsx)(Z,{component:`h1`,variant:`h2`,noWrap:!0,children:f[0]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,noWrap:!0,sx:{display:{xs:`none`,sm:`block`}},children:f[1]})]}),(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},"aria-live":`polite`,children:[(0,W.jsx)(cu,{variant:`outlined`,size:`small`,color:t===`connected`?`success`:`default`,label:t===`connected`?`Live`:Q(t,i)}),e.approvals.pending.length>0&&(0,W.jsx)(cu,{color:`warning`,size:`small`,label:`${e.approvals.pending.length} approval`}),(0,W.jsx)(cu,{variant:`outlined`,size:`small`,sx:{display:{xs:`none`,sm:`flex`}},label:e.capabilities.capabilities[`control.chat`].status===`available`?$(i,`Chat bật`,`Chat enabled`):$(i,`Chỉ xem`,`Read only`)})]})]})}),(0,W.jsxs)(X,{component:`nav`,"aria-label":$(i,`Sidebar chính`,`Primary sidebar`),sx:{width:{md:Xx},flexShrink:{md:0}},children:[(0,W.jsx)(Gd,{variant:`temporary`,open:u,onClose:()=>d(!1),ModalProps:{keepMounted:!0},sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:Xx}},children:g}),(0,W.jsx)(Gd,{variant:`permanent`,open:!0,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:Xx,borderRight:1,borderColor:`divider`,bgcolor:`background.paper`}},children:g})]}),(0,W.jsx)(X,{component:`main`,id:`main-content`,sx:{ml:{md:`${Xx}px`},minWidth:0,pt:`72px`},children:(0,W.jsxs)(X,{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,W.jsx)(X,{sx:{mb:2.25},children:(0,W.jsx)(zx,{snapshot:e,refreshSnapshot:r})}),(0,W.jsx)(rS,{active:c,snapshot:e,events:n,refreshSnapshot:r,locale:i})]})})]})}var aS=sl((0,W.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`),oS=sl((0,W.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`),sS=sl((0,W.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`),cS=sl((0,W.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`),lS=sl((0,W.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`),uS=sl((0,W.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`),dS=sl((0,W.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`),fS=sl((0,W.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`),pS=sl((0,W.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`),mS=sl((0,W.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`),hS=sl((0,W.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`),gS=sl((0,W.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 _S(e){return K(`MuiAlert`,e)}var vS=Wr(`MuiAlert`,[`root`,`action`,`icon`,`message`,`filled`,`colorSuccess`,`colorInfo`,`colorWarning`,`colorError`,`outlined`,`standard`]),yS=sl((0,W.jsx)(`path`,{d:`M20,12A8,8 0 0,1 12,20A8,8 0 0,1 4,12A8,8 0 0,1 12,4C12.76,4 13.5,4.11 14.2, 4.31L15.77,2.74C14.61,2.26 13.34,2 12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0, 0 22,12M7.91,10.08L6.5,11.5L11,16L21,6L19.59,4.58L11,13.17L7.91,10.08Z`}),`SuccessOutlined`),bS=sl((0,W.jsx)(`path`,{d:`M12 5.99L19.53 19H4.47L12 5.99M12 2L1 21h22L12 2zm1 14h-2v2h2v-2zm0-6h-2v4h2v-4z`}),`ReportProblemOutlined`),xS=sl((0,W.jsx)(`path`,{d:`M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z`}),`ErrorOutline`),SS=sl((0,W.jsx)(`path`,{d:`M11,9H13V7H11M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20, 12C20,16.41 16.41,20 12,20M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10, 10 0 0,0 12,2M11,17H13V11H11V17Z`}),`InfoOutlined`),CS=sl((0,W.jsx)(`path`,{d:`M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`}),`Close`),wS=e=>{let{variant:t,color:n,severity:r,classes:i}=e;return va({root:[`root`,`color${Y(n||r)}`,`${t}`],icon:[`icon`],message:[`message`],action:[`action`]},_S,i)},TS=J(Mc,{name:`MuiAlert`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant]]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`?e.darken:e.lighten,n=e.palette.mode===`light`?e.lighten:e.darken;return{...e.typography.body2,backgroundColor:`transparent`,display:`flex`,padding:`6px 16px`,variants:[...Object.entries(e.palette).filter(Oc([`light`])).map(([r])=>({props:{colorSeverity:r,variant:`standard`},style:{color:e.vars?e.vars.palette.Alert[`${r}Color`]:t(e.palette[r].light,.6),backgroundColor:e.vars?e.vars.palette.Alert[`${r}StandardBg`]:n(e.palette[r].light,.9),[`& .${vS.icon}`]:e.vars?{color:e.vars.palette.Alert[`${r}IconColor`]}:{color:e.palette[r].main}}})),...Object.entries(e.palette).filter(Oc([`light`])).map(([n])=>({props:{colorSeverity:n,variant:`outlined`},style:{color:e.vars?e.vars.palette.Alert[`${n}Color`]:t(e.palette[n].light,.6),border:`1px solid ${(e.vars||e).palette[n].light}`,[`& .${vS.icon}`]:e.vars?{color:e.vars.palette.Alert[`${n}IconColor`]}:{color:e.palette[n].main}}})),...Object.entries(e.palette).filter(Oc([`dark`])).map(([t])=>({props:{colorSeverity:t,variant:`filled`},style:{fontWeight:e.typography.fontWeightMedium,...e.vars?{color:e.vars.palette.Alert[`${t}FilledColor`],backgroundColor:e.vars.palette.Alert[`${t}FilledBg`]}:{backgroundColor:e.palette.mode===`dark`?e.palette[t].dark:e.palette[t].main,color:e.palette.getContrastText(e.palette[t].main)}}}))]}})),ES=J(`div`,{name:`MuiAlert`,slot:`Icon`})({marginRight:12,padding:`7px 0`,display:`flex`,fontSize:22,opacity:.9}),DS=J(`div`,{name:`MuiAlert`,slot:`Message`})({padding:`8px 0`,minWidth:0,overflow:`auto`}),OS=J(`div`,{name:`MuiAlert`,slot:`Action`})({display:`flex`,alignItems:`flex-start`,padding:`4px 0 0 16px`,marginLeft:`auto`,marginRight:-8}),kS={success:(0,W.jsx)(yS,{fontSize:`inherit`}),warning:(0,W.jsx)(bS,{fontSize:`inherit`}),error:(0,W.jsx)(xS,{fontSize:`inherit`}),info:(0,W.jsx)(SS,{fontSize:`inherit`})},AS=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiAlert`}),{action:r,children:i,className:a,closeText:o=`Close`,color:s,icon:c,iconMapping:l=kS,onClose:u,role:d=`alert`,severity:f=`success`,slotProps:p={},slots:m={},variant:h=`standard`,...g}=n,_={...n,color:s,severity:f,variant:h,colorSeverity:s||f},v=wS(_),y={slots:m,slotProps:p},[b,x]=Jc(`root`,{ref:t,shouldForwardComponentProp:!0,className:G(v.root,a),elementType:TS,externalForwardedProps:{...y,...g},ownerState:_,additionalProps:{role:d,elevation:0}}),[S,C]=Jc(`icon`,{className:v.icon,elementType:ES,externalForwardedProps:y,ownerState:_}),[w,T]=Jc(`message`,{className:v.message,elementType:DS,externalForwardedProps:y,ownerState:_}),[E,D]=Jc(`action`,{className:v.action,elementType:OS,externalForwardedProps:y,ownerState:_}),[O,k]=Jc(`closeButton`,{elementType:Zd,externalForwardedProps:y,ownerState:_}),[A,j]=Jc(`closeIcon`,{elementType:CS,externalForwardedProps:y,ownerState:_});return(0,W.jsxs)(b,{...x,children:[c===!1?null:(0,W.jsx)(S,{...C,children:c||l[f]||kS[f]}),(0,W.jsx)(w,{...T,children:i}),r==null?null:(0,W.jsx)(E,{...D,children:r}),r==null&&u?(0,W.jsx)(E,{...D,children:(0,W.jsx)(O,{size:`small`,"aria-label":o,title:o,color:`inherit`,onClick:u,...k,children:(0,W.jsx)(A,{fontSize:`small`,...j})})}):null]})});function jS(e){return K(`MuiButton`,e)}var MS=Wr(`MuiButton`,`root.text.outlined.contained.disableElevation.focusVisible.disabled.colorInherit.colorPrimary.colorSecondary.colorSuccess.colorError.colorInfo.colorWarning.sizeMedium.sizeSmall.sizeLarge.fullWidth.startIcon.endIcon.icon.loading.loadingWrapper.loadingIconPlaceholder.loadingIndicator.loadingPositionCenter.loadingPositionStart.loadingPositionEnd`.split(`.`)),NS=v.createContext({}),PS=v.createContext(void 0),FS=e=>{let{color:t,disableElevation:n,fullWidth:r,size:i,variant:a,loading:o,loadingPosition:s,classes:c}=e,l=va({root:[`root`,o&&`loading`,a,`size${Y(i)}`,`color${Y(t)}`,n&&`disableElevation`,r&&`fullWidth`,o&&`loadingPosition${Y(s)}`],startIcon:[`icon`,`startIcon`],endIcon:[`icon`,`endIcon`],loadingIndicator:[`loadingIndicator`],loadingWrapper:[`loadingWrapper`]},jS,c);return{...c,...l}},IS=[{props:{size:`small`},style:{"& > *:nth-of-type(1)":{fontSize:18}}},{props:{size:`medium`},style:{"& > *:nth-of-type(1)":{fontSize:20}}},{props:{size:`large`},style:{"& > *:nth-of-type(1)":{fontSize:22}}}],LS=J(eu,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiButton`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,t[n.variant],t[`size${Y(n.size)}`],n.color===`inherit`&&t.colorInherit,n.disableElevation&&t.disableElevation,n.fullWidth&&t.fullWidth,n.loading&&t.loading]}})(_s(({theme:e})=>{let t=e.palette.mode===`light`?e.palette.grey[300]:e.palette.grey[800],n=e.palette.mode===`light`?e.palette.grey.A100:e.palette.grey[700];return{...e.typography.button,minWidth:64,padding:`6px 16px`,border:0,borderRadius:(e.vars||e).shape.borderRadius,...Ws(e,[`background-color`,`box-shadow`,`border-color`,`color`],{duration:e.transitions.duration.short}),"&:hover":{textDecoration:`none`},[`&.${MS.disabled}`]:{color:(e.vars||e).palette.action.disabled},variants:[{props:{variant:`contained`},style:{color:`var(--variant-containedColor)`,backgroundColor:`var(--variant-containedBg)`,boxShadow:(e.vars||e).shadows[2],"&:hover":{boxShadow:(e.vars||e).shadows[4],"@media (hover: none)":{boxShadow:(e.vars||e).shadows[2]}},"&:active":{boxShadow:(e.vars||e).shadows[8]},[`&.${MS.focusVisible}`]:{boxShadow:(e.vars||e).shadows[6]},[`&.${MS.disabled}`]:{color:(e.vars||e).palette.action.disabled,boxShadow:(e.vars||e).shadows[0],backgroundColor:(e.vars||e).palette.action.disabledBackground}}},{props:{variant:`outlined`},style:{padding:`5px 15px`,border:`1px solid currentColor`,borderColor:`var(--variant-outlinedBorder, currentColor)`,backgroundColor:`var(--variant-outlinedBg)`,color:`var(--variant-outlinedColor)`,[`&.${MS.disabled}`]:{border:`1px solid ${(e.vars||e).palette.action.disabledBackground}`}}},{props:{variant:`text`},style:{padding:`6px 8px`,color:`var(--variant-textColor)`,backgroundColor:`var(--variant-textBg)`}},...Object.entries(e.palette).filter(Oc()).map(([t])=>({props:{color:t},style:{"--variant-textColor":(e.vars||e).palette[t].main,"--variant-outlinedColor":(e.vars||e).palette[t].main,"--variant-outlinedBorder":e.alpha((e.vars||e).palette[t].main,.5),"--variant-containedColor":(e.vars||e).palette[t].contrastText,"--variant-containedBg":(e.vars||e).palette[t].main,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":(e.vars||e).palette[t].dark,"--variant-textBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBorder":(e.vars||e).palette[t].main,"--variant-outlinedBg":e.alpha((e.vars||e).palette[t].main,(e.vars||e).palette.action.hoverOpacity)}}}})),{props:{color:`inherit`},style:{color:`inherit`,borderColor:`currentColor`,"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedBg:t,"@media (hover: hover)":{"&:hover":{"--variant-containedBg":e.vars?e.vars.palette.Button.inheritContainedHoverBg:n,"--variant-textBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity),"--variant-outlinedBg":e.alpha((e.vars||e).palette.text.primary,(e.vars||e).palette.action.hoverOpacity)}}}},{props:{size:`small`,variant:`text`},style:{padding:`4px 5px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`text`},style:{padding:`8px 11px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`outlined`},style:{padding:`3px 9px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`outlined`},style:{padding:`7px 21px`,fontSize:e.typography.pxToRem(15)}},{props:{size:`small`,variant:`contained`},style:{padding:`4px 10px`,fontSize:e.typography.pxToRem(13)}},{props:{size:`large`,variant:`contained`},style:{padding:`8px 22px`,fontSize:e.typography.pxToRem(15)}},{props:{disableElevation:!0},style:{boxShadow:`none`,"&:hover":{boxShadow:`none`},[`&.${MS.focusVisible}`]:{boxShadow:`none`},"&:active":{boxShadow:`none`},[`&.${MS.disabled}`]:{boxShadow:`none`}}},{props:{fullWidth:!0},style:{width:`100%`}},{props:{loadingPosition:`center`},style:{...Ws(e,[`background-color`,`box-shadow`,`border-color`],{duration:e.transitions.duration.short}),[`&.${MS.loading}`]:{color:`transparent`}}}]}})),RS=J(`span`,{name:`MuiButton`,slot:`StartIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.startIcon,n.loading&&t.startIconLoadingStart]}})(({theme:e})=>({display:`inherit`,alignItems:`center`,marginRight:8,marginLeft:-4,"&::before":{content:`"\\200b"`,width:0,overflow:`hidden`},variants:[{props:{size:`small`},style:{marginLeft:-2}},{props:{loadingPosition:`start`,loading:!0},style:{...Ws(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`start`,loading:!0,fullWidth:!0},style:{marginRight:-8}},...IS]})),zS=J(`span`,{name:`MuiButton`,slot:`EndIcon`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.endIcon,n.loading&&t.endIconLoadingEnd]}})(({theme:e})=>({display:`inherit`,marginRight:-4,marginLeft:8,variants:[{props:{size:`small`},style:{marginRight:-2}},{props:{loadingPosition:`end`,loading:!0},style:{...Ws(e,[`opacity`],{duration:e.transitions.duration.short}),opacity:0}},{props:{loadingPosition:`end`,loading:!0,fullWidth:!0},style:{marginLeft:-8}},...IS]})),BS=J(`span`,{name:`MuiButton`,slot:`LoadingIndicator`})(({theme:e})=>({display:`none`,position:`absolute`,visibility:`visible`,variants:[{props:{loading:!0},style:{display:`flex`}},{props:{loadingPosition:`start`},style:{left:14}},{props:{loadingPosition:`start`,size:`small`},style:{left:10}},{props:{variant:`text`,loadingPosition:`start`},style:{left:6}},{props:{loadingPosition:`center`},style:{left:`50%`,transform:`translate(-50%)`,color:(e.vars||e).palette.action.disabled}},{props:{loadingPosition:`end`},style:{right:14}},{props:{loadingPosition:`end`,size:`small`},style:{right:10}},{props:{variant:`text`,loadingPosition:`end`},style:{right:6}},{props:{loadingPosition:`start`,fullWidth:!0},style:{position:`relative`,left:-10}},{props:{loadingPosition:`end`,fullWidth:!0},style:{position:`relative`,right:-10}}]})),VS=J(`span`,{name:`MuiButton`,slot:`LoadingIconPlaceholder`})({display:`inline-block`,width:`1em`,height:`1em`}),HS=v.forwardRef(function(e,t){let n=v.useContext(NS),r=v.useContext(PS),i=Jo({props:ri(n,e),name:`MuiButton`}),{children:a,color:o=`primary`,component:s=`button`,className:c,disabled:l=!1,disableElevation:u=!1,disableFocusRipple:d=!1,endIcon:f,focusVisibleClassName:p,fullWidth:m=!1,id:h,loading:g=null,loadingIndicator:_,loadingPosition:y=`center`,size:b=`medium`,startIcon:x,type:S,variant:C=`text`,...w}=i,T=Td(h),E=_??(0,W.jsx)(bu,{"aria-labelledby":T,color:`inherit`,size:16}),D={...i,color:o,component:s,disabled:l,disableElevation:u,disableFocusRipple:d,fullWidth:m,loading:g,loadingIndicator:E,loadingPosition:y,size:b,type:S,variant:C},O=FS(D),k=(x||g&&y===`start`)&&(0,W.jsx)(RS,{className:O.startIcon,ownerState:D,children:x||(0,W.jsx)(VS,{className:O.loadingIconPlaceholder,ownerState:D})}),A=(f||g&&y===`end`)&&(0,W.jsx)(zS,{className:O.endIcon,ownerState:D,children:f||(0,W.jsx)(VS,{className:O.loadingIconPlaceholder,ownerState:D})}),j=r||``,M=typeof g==`boolean`?(0,W.jsx)(`span`,{className:O.loadingWrapper,style:{display:`contents`},children:g&&(0,W.jsx)(BS,{className:O.loadingIndicator,ownerState:D,children:E})}):null,{root:N,...P}=O;return(0,W.jsxs)(LS,{ownerState:D,className:G(n.className,O.root,c,j),component:s,disabled:l||g,focusRipple:!d,focusVisibleClassName:G(O.focusVisible,p),ref:t,internalNativeButton:!0,type:S,id:g?T:h,...w,classes:P,children:[k,y!==`end`&&M,a,y===`end`&&M,A]})});function US(e){return K(`MuiCollapse`,e)}Wr(`MuiCollapse`,[`root`,`horizontal`,`vertical`,`entered`,`hidden`,`wrapper`,`wrapperInner`]);var WS={},GS=e=>{let{orientation:t,classes:n}=e;return va({root:[`root`,t],entered:[`entered`],hidden:[`hidden`],wrapper:[`wrapper`,t],wrapperInner:[`wrapperInner`,t]},US,n)},KS=J(`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]}})(_s(({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`}}]}))),qS=J(`div`,{name:`MuiCollapse`,slot:`Wrapper`})({display:`flex`,width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),JS=J(`div`,{name:`MuiCollapse`,slot:`WrapperInner`})({width:`100%`,variants:[{props:{orientation:`horizontal`},style:{width:`auto`,height:`100%`}}]}),YS=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiCollapse`}),{addEndListener:r,children:i,className:a,collapsedSize:o=`0px`,component:s,disablePrefersReducedMotion:c=!1,easing:l,in:u,onEnter:d,onEntered:f,onEntering:p,onExit:m,onExited:h,onExiting:g,orientation:_=`vertical`,slots:y=WS,slotProps:b=WS,style:x,timeout:S=lo.standard,TransitionComponent:C=rd,...w}=n,T={...n,orientation:_,collapsedSize:o},E=GS(T),D=Uo(),O=v.useRef(null),k=v.useRef(null),A=typeof o==`number`?`${o}px`:o,j=_===`horizontal`,M=j?`width`:`height`,N=Il(D.motion.reducedMotion,c),P=v.useRef(null),F=vs(t,P),I=()=>O.current?O.current[j?`clientWidth`:`clientHeight`]:0,L=Bs(P,(e,t)=>{O.current&&j&&(O.current.style.position=`absolute`),e.style[M]=A,d&&d(e,t)}),R=Bs(P,(e,t)=>{let n=I();O.current&&j&&(O.current.style.position=``);let{duration:r,easing:i}=Hs({style:x,timeout:S,easing:l},{mode:`enter`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(n);k.current=e}else k.current=null;let a=N.getTransitionTiming({duration:k.current??r,delay:void 0});e.style.transitionDuration=typeof a.duration==`string`?a.duration:`${a.duration}ms`,e.style[M]=`${n}px`,e.style.transitionTimingFunction=i,p&&p(e,t)}),ee=Bs(P,(e,t)=>{e.style[M]=`auto`,f&&f(e,t)}),te=Bs(P,e=>{e.style[M]=`${I()}px`,m&&m(e)}),ne=Bs(P,h),z=Bs(P,e=>{let t=I(),{duration:n,easing:r}=Hs({style:x,timeout:S,easing:l},{mode:`exit`});if(S===`auto`&&!N.shouldReduceMotion){let e=D.transitions.getAutoHeightDuration(t);k.current=e}else k.current=null;let i=N.getTransitionTiming({duration:k.current??n,delay:void 0});e.style.transitionDuration=typeof i.duration==`string`?i.duration:`${i.duration}ms`,e.style[M]=A,e.style.transitionTimingFunction=r,g&&g(e)}),B=r?e=>{r(P.current,e)}:void 0,V={slots:y,slotProps:b,component:s},[re,ie]=Jc(`root`,{ref:F,className:G(E.root,a),elementType:KS,externalForwardedProps:V,ownerState:T,additionalProps:{style:{[j?`minWidth`:`minHeight`]:A,...x}}}),[ae,oe]=Jc(`wrapper`,{ref:O,className:E.wrapper,elementType:qS,externalForwardedProps:V,ownerState:T}),[se,H]=Jc(`wrapperInner`,{className:E.wrapperInner,elementType:JS,externalForwardedProps:V,ownerState:T});return(0,W.jsx)(C,{in:u,onEnter:L,onEntered:ee,onEntering:R,onExit:te,onExited:ne,onExiting:z,addEndListener:B,getAutoTimeout:S===`auto`?()=>k.current:void 0,reduceMotion:N.shouldReduceMotion,nodeRef:P,timeout:S===`auto`?null:S,...w,children:(e,{ownerState:t,...n})=>{let r={...T,state:e};return(0,W.jsx)(re,{...ie,className:G(ie.className,{entered:E.entered,exited:!u&&A===`0px`&&E.hidden}[e]),ownerState:r,...n,children:(0,W.jsx)(ae,{...oe,ownerState:r,children:(0,W.jsx)(se,{...H,ownerState:r,children:i})})})}})});YS&&(YS.muiSupportAuto=!0);function XS(e){return K(`MuiDialog`,e)}Wr(`MuiDialog`,[`root`,`backdrop`,`scrollPaper`,`scrollBody`,`container`,`paper`,`paperWidthFalse`,`paperWidthXs`,`paperWidthSm`,`paperWidthMd`,`paperWidthLg`,`paperWidthXl`,`paperFullWidth`,`paperFullScreen`]);var ZS=v.createContext({}),QS=J(ud,{name:`MuiDialog`,slot:`Backdrop`})({zIndex:-1}),$S=e=>{let{classes:t,scroll:n,maxWidth:r,fullWidth:i,fullScreen:a}=e;return va({root:[`root`],backdrop:[`backdrop`],container:[`container`,`scroll${Y(n)}`],paper:[`paper`,`paperWidth${Y(String(r))}`,i&&`paperFullWidth`,a&&`paperFullScreen`]},XS,t)},eC=J(xd,{name:`MuiDialog`,slot:`Root`})({"@media print":{position:`absolute !important`}}),tC=J(`div`,{name:`MuiDialog`,slot:`Container`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.container,t[`scroll${Y(n.scroll)}`]]}})({height:`100%`,"@media print":{height:`auto`},outline:0,variants:[{props:{scroll:`paper`},style:{display:`flex`,justifyContent:`center`,alignItems:`center`}},{props:{scroll:`body`},style:{overflowY:`auto`,overflowX:`hidden`,textAlign:`center`,"&::after":{content:`""`,display:`inline-block`,verticalAlign:`middle`,height:`100%`,width:`0`}}}]}),nC=J(Mc,{name:`MuiDialog`,slot:`Paper`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.paper,t[`paperWidth${Y(String(n.maxWidth))}`],n.fullWidth&&t.paperFullWidth,n.fullScreen&&t.paperFullScreen]}})(_s(({theme:e})=>({margin:32,position:`relative`,overflowY:`auto`,outline:0,"@media print":{overflowY:`visible`,boxShadow:`none`},variants:[{props:{scroll:`paper`},style:{display:`flex`,flexDirection:`column`,maxHeight:`calc(100% - 64px)`}},{props:{scroll:`body`},style:{display:`inline-block`,verticalAlign:`middle`,textAlign:`initial`}},{props:({ownerState:e})=>!e.maxWidth,style:{maxWidth:`calc(100% - 64px)`}},{props:{maxWidth:`xs`},style:{maxWidth:e.breakpoints.unit===`px`?Math.max(e.breakpoints.values.xs,444):`max(${e.breakpoints.values.xs}${e.breakpoints.unit}, 444px)`}},{props:{maxWidth:`xs`,scroll:`body`},style:{[e.breakpoints.down(Math.max(e.breakpoints.values.xs,444)+64)]:{maxWidth:`calc(100% - 64px)`}}},...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t},style:{maxWidth:`${e.breakpoints.values[t]}${e.breakpoints.unit}`}})),...Object.keys(e.breakpoints.values).filter(e=>e!==`xs`).map(t=>({props:{maxWidth:t,scroll:`body`},style:{[e.breakpoints.down(e.breakpoints.values[t]+64)]:{maxWidth:`calc(100% - 64px)`}}})),{props:({ownerState:e})=>e.fullWidth,style:{width:`calc(100% - 64px)`}},{props:({ownerState:e})=>e.fullScreen,style:{margin:0,width:`100%`,maxWidth:`100%`,height:`100%`,maxHeight:`none`,borderRadius:0}},{props:({ownerState:e})=>e.fullScreen&&e.scroll===`body`,style:{margin:0,maxWidth:`100%`}}]}))),rC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialog`}),r=Uo(),i={enter:r.transitions.duration.enteringScreen,exit:r.transitions.duration.leavingScreen},{"aria-describedby":a,"aria-labelledby":o,"aria-modal":s=!0,children:c,className:l,fullScreen:u=!1,fullWidth:d=!1,maxWidth:f=`sm`,onClick:p,onClose:m,open:h,PaperComponent:g=Mc,role:_=`dialog`,scroll:y=`paper`,slots:b={},slotProps:x={},transitionDuration:S=i,...C}=n,w={...n,fullScreen:u,fullWidth:d,maxWidth:f,scroll:y},T=$S(w),E=v.useRef(),D=e=>{E.current=e.target===e.currentTarget},O=e=>{p&&p(e),E.current&&(E.current=null,m&&m(e,`backdropClick`))},k=Wi(o),A=v.useMemo(()=>({titleId:k}),[k]),j={slots:b,slotProps:x},[M,N]=Jc(`root`,{elementType:eC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:G(T.root,l),ref:t}),[P,F]=Jc(`backdrop`,{elementType:QS,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.backdrop}),[I,L]=Jc(`paper`,{elementType:nC,shouldForwardComponentProp:!0,externalForwardedProps:j,ownerState:w,className:T.paper,additionalProps:{elevation:24,role:_,"aria-describedby":a,"aria-labelledby":k,"aria-modal":s,tabIndex:-1,[zu]:``}}),[R,ee]=Jc(`container`,{elementType:tC,externalForwardedProps:j,ownerState:w,className:T.container}),[te,ne]=Jc(`transition`,{elementType:od,externalForwardedProps:j,ownerState:w,additionalProps:{appear:!0,in:h,timeout:S,role:`presentation`}});return(0,W.jsx)(M,{closeAfterTransition:!0,slots:{backdrop:P},slotProps:{backdrop:{transitionDuration:S,...F}},onClose:m,open:h,onClick:O,...N,...C,children:(0,W.jsx)(te,{...ne,children:(0,W.jsx)(R,{onMouseDown:D,...ee,children:(0,W.jsx)(I,{as:g,...L,children:(0,W.jsx)(ZS.Provider,{value:A,children:c})})})})})}),iC=(e,t)=>{let{ownerState:n}=e;return[t.root,n.dense&&t.dense,n.divider&&t.divider,!n.disableGutters&&t.gutters]},aC=e=>{let{disabled:t,dense:n,divider:r,disableGutters:i,selected:a,classes:o}=e,s=va({root:[`root`,n&&`dense`,t&&`disabled`,!i&&`gutters`,r&&`divider`,a&&`selected`]},dc,o);return{...o,...s}},oC=J(eu,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiMenuItem`,slot:`Root`,overridesResolver:iC})(_s(({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`}},[`&.${fc.selected}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity),[`&.${fc.focusVisible}`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.focusOpacity}`)}},[`&.${fc.selected}:hover`]:{backgroundColor:e.alpha((e.vars||e).palette.primary.main,`${(e.vars||e).palette.action.selectedOpacity} + ${(e.vars||e).palette.action.hoverOpacity}`),"@media (hover: none)":{backgroundColor:e.alpha((e.vars||e).palette.primary.main,(e.vars||e).palette.action.selectedOpacity)}},[`&.${fc.focusVisible}`]:{backgroundColor:(e.vars||e).palette.action.focus},[`&.${fc.disabled}`]:{opacity:(e.vars||e).palette.action.disabledOpacity},[`& + .${Su.root}`]:{marginTop:e.spacing(1),marginBottom:e.spacing(1)},[`& + .${Su.inset}`]:{marginLeft:52},[`& .${yf.root}`]:{marginTop:0,marginBottom:0},[`& .${yf.inset}`]:{paddingLeft:36},[`& .${lf.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,[`& .${lf.root} svg`]:{fontSize:`1.25rem`}}}]}))),sC=v.forwardRef(function(e,t){let n=Jo({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=Oy(),h=v.useContext(Qd),g=v.useMemo(()=>({dense:a||h.dense||!1,disableGutters:s}),[h.dense,a,s]),_=jy(),y=Td(),b=_.suppressInitialFocusVisible,x=_.itemsFocusableWhenDisabled,S=v.useRef(null);ys(()=>{r&&S.current&&Cy(S.current,m)},[r]);let C={...n,dense:g.dense,divider:o,disableGutters:s},w=aC(n),{root:T,...E}=w,D=Nf({id:y,ref:t,disabled:n.disabled,focusableWhenDisabled:x,selected:n.selected}),O=vs(S,D.ref),k;return u===void 0?_.variant===`selectedMenu`?k=D.tabIndex:(!n.disabled||x)&&(k=-1):k=u,(0,W.jsx)(Qd.Provider,{value:g,children:(0,W.jsx)(oC,{ref:O,role:l,"aria-checked":p,tabIndex:k,component:i,internalNativeButton:!1,focusableWhenDisabled:x,suppressFocusVisible:b,focusVisibleClassName:G(w.focusVisible,c),className:G(w.root,d),...f,ownerState:C,classes:E})})}),cC=sl((0,W.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`),lC=sl((0,W.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`),uC=sl((0,W.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`),dC=sl((0,W.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`),fC=sl((0,W.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`),pC=sl((0,W.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`),mC=sl((0,W.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`),hC=sl((0,W.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`),gC=sl((0,W.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`),_C=sl((0,W.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`),vC=sl((0,W.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`),yC=sl((0,W.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`),bC=sl((0,W.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`),xC={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 SC(){return(0,W.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`1em`,height:`1em`,"aria-hidden":`true`,children:[(0,W.jsx)(`path`,{fill:`#f24e1e`,d:`M5 2h7v7H8.5A3.5 3.5 0 0 1 5 5.5V2Z`}),(0,W.jsx)(`path`,{fill:`#ff7262`,d:`M12 2h3.5a3.5 3.5 0 1 1 0 7H12V2Z`}),(0,W.jsx)(`path`,{fill:`#a259ff`,d:`M5 9h7v7H8.5A3.5 3.5 0 0 1 5 12.5V9Z`}),(0,W.jsx)(`circle`,{cx:`15.5`,cy:`12.5`,r:`3.5`,fill:`#1abcfe`}),(0,W.jsx)(`path`,{fill:`#0acf83`,d:`M5 16h7v3.5A3.5 3.5 0 1 1 5 16Z`})]})}function CC(e){let t=e.toLowerCase();return t.includes(`figma`)?(0,W.jsx)(SC,{}):t.includes(`github`)?(0,W.jsx)(vC,{fontSize:`inherit`}):t.includes(`chrome`)||t.includes(`devtools`)?(0,W.jsx)(gC,{fontSize:`inherit`}):t.includes(`anthropic`)||t.includes(`claude`)?(0,W.jsx)(pC,{fontSize:`inherit`}):t.includes(`file`)||t.includes(`folder`)?(0,W.jsx)(_C,{fontSize:`inherit`}):t.includes(`postgres`)||t.includes(`database`)||t.includes(`supabase`)?(0,W.jsx)(bC,{fontSize:`inherit`}):t.includes(`code`)||t.includes(`context7`)?(0,W.jsx)(hC,{fontSize:`inherit`}):t.includes(`google`)||t.includes(`drive`)||t.includes(`cloud`)?(0,W.jsx)(mC,{fontSize:`inherit`}):(0,W.jsx)(yC,{fontSize:`inherit`})}function wC({name:e,size:t=34}){let n=e.toLowerCase(),r=Object.keys(xC).find(e=>n.includes(e));return(0,W.jsx)(X,{"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?xC[r]:`action.selected`,color:r?`#fff`:`text.secondary`,fontSize:Math.round(t*.52),border:1,borderColor:r?`transparent`:`divider`},children:CC(e)})}var TC=sl((0,W.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 EC(e){return K(`MuiDialogActions`,e)}Wr(`MuiDialogActions`,[`root`,`spacing`]);var DC=e=>{let{classes:t,disableSpacing:n}=e;return va({root:[`root`,!n&&`spacing`]},EC,t)},OC=J(`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}}}]}),kC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogActions`}),{className:r,disableSpacing:i=!1,...a}=n,o={...n,disableSpacing:i},s=DC(o);return(0,W.jsx)(OC,{className:G(s.root,r),ownerState:o,ref:t,...a})});function AC(e){return K(`MuiDialogContent`,e)}Wr(`MuiDialogContent`,[`root`,`dividers`]);function jC(e){return K(`MuiDialogTitle`,e)}var MC=Wr(`MuiDialogTitle`,[`root`]),NC=e=>{let{classes:t,dividers:n}=e;return va({root:[`root`,n&&`dividers`]},AC,t)},PC=J(`div`,{name:`MuiDialogContent`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.dividers&&t.dividers]}})(_s(({theme:e})=>({flex:`1 1 auto`,WebkitOverflowScrolling:`touch`,overflowY:`auto`,padding:`20px 24px`,variants:[{props:({ownerState:e})=>e.dividers,style:{padding:`16px 24px`,borderTop:`1px solid ${(e.vars||e).palette.divider}`,borderBottom:`1px solid ${(e.vars||e).palette.divider}`}},{props:({ownerState:e})=>!e.dividers,style:{[`.${MC.root} + &`]:{paddingTop:0}}}]}))),FC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogContent`}),{className:r,dividers:i=!1,...a}=n,o={...n,dividers:i},s=NC(o);return(0,W.jsx)(PC,{className:G(s.root,r),ownerState:o,ref:t,...a})});function IC(e){return K(`MuiDialogContentText`,e)}Wr(`MuiDialogContentText`,[`root`]);var LC=e=>{let{classes:t}=e,n=va({root:[`root`]},IC,t);return{...t,...n}},RC=J(Z,{shouldForwardProp:e=>Ko(e)||e===`classes`,name:`MuiDialogContentText`,slot:`Root`})({}),zC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogContentText`}),{children:r,className:i,...a}=n,o=LC(a);return(0,W.jsx)(RC,{component:`p`,variant:`body1`,color:`textSecondary`,ref:t,ownerState:a,className:G(o.root,i),...n,classes:o})}),BC=e=>{let{classes:t}=e;return va({root:[`root`]},jC,t)},VC=J(Z,{name:`MuiDialogTitle`,slot:`Root`})({padding:`16px 24px`,flex:`0 0 auto`}),HC=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiDialogTitle`}),{className:r,id:i,...a}=n,o=n,s=BC(o),{titleId:c=i}=v.useContext(ZS);return(0,W.jsx)(VC,{component:`h2`,className:G(s.root,r),ownerState:o,ref:t,variant:`h6`,id:i??c,...a})});function UC({open:e,title:t,description:n,confirmLabel:r,cancelLabel:i,onConfirm:a,onCancel:o}){return(0,W.jsxs)(rC,{open:e,onClose:o,fullWidth:!0,maxWidth:`xs`,"aria-describedby":`piagent-confirm-dialog-description`,slotProps:{paper:{sx:{borderRadius:3,p:.5}}},children:[(0,W.jsxs)(HC,{sx:{display:`flex`,alignItems:`center`,gap:1.25,pb:1},children:[(0,W.jsx)(X,{sx:{width:36,height:36,borderRadius:2,display:`grid`,placeItems:`center`,bgcolor:`warning.main`,color:`warning.contrastText`},children:(0,W.jsx)(TC,{fontSize:`small`})}),(0,W.jsx)(Z,{component:`span`,sx:{fontSize:`1.08rem`,fontWeight:700},children:t})]}),(0,W.jsx)(FC,{children:(0,W.jsx)(zC,{id:`piagent-confirm-dialog-description`,sx:{color:`text.secondary`,lineHeight:1.65},children:n})}),(0,W.jsxs)(kC,{sx:{px:2.5,pb:2,gap:.75},children:[(0,W.jsx)(HS,{color:`inherit`,onClick:o,autoFocus:!0,children:i}),(0,W.jsx)(HS,{variant:`contained`,color:`warning`,onClick:a,children:r})]})]})}var WC=[{id:`task`,changeMode:`source-change`,modelUse:`required`,recommendedFreshSession:!0},{id:`scout`,changeMode:`read-only`,modelUse:`required`,recommendedFreshSession:!0},{id:`be-to-fe`,changeMode:`source-change`,modelUse:`required`,recommendedFreshSession:!0},{id:`discuss`,changeMode:`clarification`,modelUse:`required`,recommendedFreshSession:!1},{id:`plan`,changeMode:`plan-only`,modelUse:`required`,recommendedFreshSession:!1},{id:`review`,changeMode:`read-only`,modelUse:`required`,recommendedFreshSession:!1},{id:`commit`,changeMode:`git`,modelUse:`required`,recommendedFreshSession:!1},{id:`pr`,changeMode:`git`,modelUse:`required`,recommendedFreshSession:!1},{id:`onboard`,changeMode:`onboarding`,modelUse:`required`,recommendedFreshSession:!0},{id:`platform-improve`,changeMode:`platform`,modelUse:`required`,recommendedFreshSession:!0}];function GC(e,t){return[{task:[`Thực hiện task`,`Implement task`],scout:[`Khảo sát chỉ đọc`,`Read-only scout`],"be-to-fe":[`Backend → Frontend`,`Backend → Frontend`],discuss:[`Làm rõ ý tưởng`,`Clarify idea`],plan:[`Lập kế hoạch`,`Plan`],review:[`Review thay đổi`,`Review changes`],commit:[`Chuẩn bị commit`,`Prepare commit`],pr:[`Chuẩn bị pull request`,`Prepare pull request`],onboard:[`Onboard project`,`Onboard project`],"platform-improve":[`Cải tiến Piagent`,`Improve Piagent`]}[e][t===`vi`?0:1],e]}function KC({active:e,defaultProjectRef:t,busy:n,error:r,onCancel:i,onCreate:a}){let{locale:o}=xv(),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(!1),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(`high`),[_,y]=(0,v.useState)(`task`),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)([]),[A,j]=(0,v.useState)(null),[M,N]=(0,v.useState)(!1),P=(0,v.useRef)(0),[F,I]=(0,v.useState)(null),[L,R]=(0,v.useState)(null),[ee,te]=(0,v.useState)(!1),[ne,z]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!e)return;let n=new AbortController;return c(void 0),u(!1),T(``),z(null),k([]),j(null),N(!1),x(!1),P.current=0,wg(n.signal).then(e=>{n.signal.aborted||(c(e),f(e.projects.some(e=>e.projectRef===t)?t:e.projects[0]?.projectRef??``),m(e.defaultModelRef??``),g(e.defaultThinkingLevel??`high`),y(`task`),C(null))}).catch(()=>{n.signal.aborted||u(!0)}),()=>n.abort()},[e,t]),(0,v.useEffect)(()=>{if(!e)return;let t=e=>{jx(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,t),window.addEventListener(`drop`,t),()=>{window.removeEventListener(`dragover`,t),window.removeEventListener(`drop`,t)}},[e]);let B=s?.projects.find(e=>e.projectRef===d),V=s?.models.find(e=>e.modelRef===p),re=s?.models.find(e=>e.modelRef===s.defaultModelRef),ie=s?.workflows?.length?s.workflows:WC,ae=(0,v.useMemo)(()=>V?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[V]);(0,v.useEffect)(()=>{ae.includes(h)||g(ae.includes(`high`)?`high`:ae[0]??`off`)},[p,ae]);let oe=e=>t=>{I(e),R(t.currentTarget)},se=()=>{I(null),R(null)},H=async()=>{te(!0),z(null);try{let e=await jg(),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]}),f(e.project.projectRef),se()}catch(e){e instanceof bg&&e.status===409?z(null):z($(o,`Không thể thêm thư mục`,`Could not add this folder`))}finally{te(!1)}},ce=e=>{if(!e?.length)return;let t=[...O],n=!1;for(let r of[...e])if(!t.some(e=>e.name===r.name&&e.size===r.size&&e.lastModified===r.lastModified)){if(t.length===4){n=!0;continue}t.push(r)}k(t),j(n?$(o,`Mỗi tin nhắn nhận tối đa 4 file.`,`Each message accepts at most 4 files.`):null)},le=!n&&!l&&O.length<4,ue=()=>B&&w.trim()&&a({projectRef:d,placeRef:B.placeRef,modelRef:p||null,thinkingLevel:h,permissionMode:S,workflow:_,message:w.trim(),files:O});return(0,W.jsxs)(X,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,W.jsx)(X,{sx:{p:{xs:1.5,sm:2}},children:(0,W.jsx)(Zd,{"aria-label":$(o,`Quay lại`,`Back`),onClick:i,children:(0,W.jsx)(cC,{})})}),(0,W.jsxs)(Cf,{sx:{flex:1,alignItems:`center`,justifyContent:`center`,px:2,pb:{xs:5,md:12}},spacing:4,children:[(0,W.jsx)(Z,{component:`h1`,sx:{fontSize:{xs:`2rem`,md:`2.45rem`},fontWeight:500,letterSpacing:`-.035em`,textAlign:`center`},children:$(o,`Anh muốn làm gì?`,`What should we work on?`)}),(0,W.jsxs)(X,{sx:{position:`relative`,width:`100%`,maxWidth:820,border:1,borderColor:M?`primary.main`:`divider`,borderStyle:M?`dashed`:`solid`,borderRadius:3.5,bgcolor:`background.paper`,p:1.25,boxShadow:`0 18px 55px rgba(0,0,0,.13)`},onDragEnter:e=>{jx(e.dataTransfer)&&(P.current+=1,N(!0))},onDragOver:e=>{jx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=le?`copy`:`none`)},onDragLeave:e=>{jx(e.dataTransfer)&&(--P.current,P.current<=0&&(P.current=0,N(!1)))},onDrop:e=>{jx(e.dataTransfer)&&(e.preventDefault(),P.current=0,N(!1),le&&ce(e.dataTransfer.files))},children:[M&&(0,W.jsxs)(X,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3.5,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,W.jsx)(Z,{sx:{fontWeight:750},children:le?$(o,`Thả tài liệu vào đây`,`Drop documents here`):O.length>=4?$(o,`Đã đủ 4 file cho tin nhắn đầu tiên`,`The first message already holds 4 files`):$(o,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),le&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:$(o,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),!s&&!l?(0,W.jsxs)(Cf,{direction:`row`,spacing:1.5,sx:{minHeight:126,alignItems:`center`,justifyContent:`center`},children:[(0,W.jsx)(bu,{size:20}),(0,W.jsx)(Z,{color:`text.secondary`,children:$(o,`Đang mở…`,`Opening…`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Lb,{autoFocus:!0,fullWidth:!0,multiline:!0,minRows:3,maxRows:8,value:w,disabled:n||l,onChange:e=>T(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ue())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),le&&ce(e.clipboardData.files))},placeholder:$(o,`Nhắn cho Piagent…`,`Message Piagent…`),variant:`standard`,slotProps:{input:{disableUnderline:!0},htmlInput:{maxLength:32768}},sx:{px:.5}}),O.length>0&&(0,W.jsx)(Cf,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pt:.75},"aria-label":$(o,`File sẽ gửi cùng tin nhắn đầu tiên`,`Files for the first message`),children:O.map(e=>(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:`${e.name} · ${Ox(e.size)}`,onDelete:n?void 0:()=>{k(t=>t.filter(t=>t!==e)),j(null)},deleteIcon:(0,W.jsx)(lS,{"aria-label":`${$(o,`Bỏ`,`Remove`)} ${e.name}`,role:`button`})},`${e.name}:${e.size}:${e.lastModified}`))}),(0,W.jsx)(YS,{in:b,id:`piagent-new-session-options`,children:(0,W.jsxs)(X,{sx:{mx:.35,mt:1,px:1.1,py:1,borderRadius:2,bgcolor:`action.hover`},children:[(0,W.jsx)(Z,{variant:`caption`,sx:{display:`block`,mb:.75,fontWeight:750},children:$(o,`Tùy chọn cho tin nhắn đầu tiên`,`Options for the first message`)}),(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,W.jsx)(HS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(oS,{}),endIcon:(0,W.jsx)(lC,{}),onClick:oe(`workflow`),children:GC(_,o)[0]}),(0,W.jsx)(HS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(fC,{}),endIcon:(0,W.jsx)(lC,{}),onClick:oe(`thinking`),children:Q(h,o)}),(0,W.jsx)(HS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(dC,{}),endIcon:(0,W.jsx)(lC,{}),onClick:oe(`permission`),children:S?Q(S,o):$(o,`Quyền theo profile`,`Profile access`)}),(0,W.jsxs)(HS,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,W.jsx)(sS,{}),disabled:!le,"aria-label":`${$(o,`Thêm file`,`Add files`)} (${O.length}/4)`,children:[$(o,`Đính kèm`,`Attach`),(0,W.jsx)(`input`,{type:`file`,hidden:!0,multiple:!0,disabled:!le,accept:Ex,onChange:e=>{ce(e.target.files),e.currentTarget.value=``}})]})]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.75},children:$(o,`Workflow “${GC(_,o)[0]}” chỉ áp dụng cho tin nhắn đầu tiên. Trong session này anh vẫn có thể gửi việc khác hoặc chọn workflow khác ở từng tin nhắn.`,`“${GC(_,o)[0]}” applies only to the first message. You can send different work or choose another workflow for any later message in this session.`)})]})}),(0,W.jsxs)(Cf,{direction:`row`,sx:{mt:1,alignItems:`center`,gap:.65,flexWrap:`nowrap`,minWidth:0},children:[(0,W.jsx)(Ah,{title:b?$(o,`Ẩn tùy chọn`,`Hide options`):$(o,`Thêm tùy chọn`,`More options`),children:(0,W.jsx)(Zd,{size:`small`,"aria-label":b?$(o,`Ẩn tùy chọn`,`Hide options`):$(o,`Thêm tùy chọn`,`More options`),"aria-expanded":b,"aria-controls":`piagent-new-session-options`,onClick:()=>x(e=>!e),sx:{flex:`0 0 auto`,bgcolor:b?`action.selected`:`transparent`},children:(0,W.jsx)(aS,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:b?`rotate(45deg)`:`none`}})})}),(0,W.jsx)(HS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(dS,{}),endIcon:(0,W.jsx)(lC,{}),onClick:oe(`project`),"aria-label":`${$(o,`Project`,`Project`)}: ${B?.label??$(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,W.jsx)(X,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:B?.label??$(o,`Chọn project`,`Choose project`)})}),(0,W.jsx)(HS,{size:`small`,color:`inherit`,startIcon:(0,W.jsx)(uC,{}),endIcon:(0,W.jsx)(lC,{}),onClick:oe(`model`),"aria-label":`${$(o,`Model`,`Model`)}: ${V?.displayName??re?.displayName??$(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,W.jsx)(X,{component:`span`,sx:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:V?`${V.displayName}${V.modelRef===s?.defaultModelRef?$(o,` · mặc định`,` · default`):``}`:re?.displayName??$(o,`Mặc định của Pi`,`Pi default`)})}),(0,W.jsx)(X,{sx:{flex:1,minWidth:0}}),(0,W.jsx)(Zd,{"aria-label":$(o,`Gửi`,`Send`),disabled:n||l||!B||!w.trim(),onClick:ue,sx:{flex:`0 0 auto`,bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,W.jsx)(mS,{fontSize:`small`})})]})]}),(A||ne||r||l)&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,sx:{display:`block`,px:.5,pt:1},children:A??ne??r??$(o,`Không tải được lựa chọn`,`Could not load choices`)})]})]}),(0,W.jsxs)($y,{anchorEl:L,open:F===`project`,onClose:se,slotProps:{paper:{sx:{width:310,maxHeight:380}}},children:[(s?.projects??[]).map(e=>(0,W.jsxs)(sC,{selected:d===e.projectRef,onClick:()=>{f(e.projectRef),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(wC,{name:`folder`,size:26})}),(0,W.jsx)(Sf,{primary:e.label})]},e.projectRef)),(0,W.jsx)(Eu,{}),(0,W.jsxs)(sC,{disabled:ee||s?.projectImport?.status!==`available`,onClick:()=>void H(),children:[(0,W.jsx)(ff,{children:(0,W.jsx)(aS,{})}),(0,W.jsx)(Sf,{primary:ee?$(o,`Đang chọn…`,`Choosing…`):$(o,`Thêm một hoặc nhiều folder`,`Add one or more folders`)})]})]}),(0,W.jsxs)($y,{anchorEl:L,open:F===`model`,onClose:se,slotProps:{paper:{sx:{width:360,maxHeight:440}}},children:[!s?.defaultModelRef&&(0,W.jsxs)(sC,{selected:!p,onClick:()=>{m(``),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(uC,{})}),(0,W.jsx)(Sf,{primary:$(o,`Model mặc định của Pi`,`Pi default model`)})]}),(s?.models??[]).map(e=>(0,W.jsxs)(sC,{selected:p===e.modelRef,onClick:()=>{m(e.modelRef),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(wC,{name:e.provider,size:26})}),(0,W.jsx)(Sf,{primary:e.displayName,secondary:e.modelRef===s?.defaultModelRef?$(o,`Mặc định · ${e.provider} · High`,`Default · ${e.provider} · High`):e.provider})]},e.modelRef))]}),(0,W.jsx)($y,{anchorEl:L,open:F===`workflow`,onClose:se,slotProps:{paper:{sx:{width:360,maxHeight:470}}},children:ie.map(e=>(0,W.jsxs)(sC,{selected:_===e.id,onClick:()=>{y(e.id),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(oS,{})}),(0,W.jsx)(Sf,{primary:GC(e.id,o)[0],secondary:`${Q(e.changeMode,o)} · ${$(o,`chỉ cho tin nhắn này`,`this message only`)}`})]},e.id))}),(0,W.jsx)($y,{anchorEl:L,open:F===`thinking`,onClose:se,slotProps:{paper:{sx:{width:250,maxHeight:400}}},children:ae.map(e=>(0,W.jsxs)(sC,{value:e,selected:h===e,onClick:()=>{g(e),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(fC,{})}),(0,W.jsx)(Sf,{primary:Q(e,o)})]},e))}),(0,W.jsxs)($y,{anchorEl:L,open:F===`permission`,onClose:se,slotProps:{paper:{sx:{width:310}}},children:[(0,W.jsxs)(sC,{selected:S===null,onClick:()=>{C(null),se()},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(dC,{})}),(0,W.jsx)(Sf,{primary:$(o,`Theo profile project`,`Project profile default`)})]}),[`read-only`,`workspace-write`,`trusted-full-access`].map(e=>(0,W.jsxs)(sC,{selected:S===e,onClick:()=>{se(),e===`trusted-full-access`?D(e):C(e)},children:[(0,W.jsx)(ff,{children:(0,W.jsx)(dC,{})}),(0,W.jsx)(Sf,{primary:Q(e,o)})]},e))]}),(0,W.jsx)(UC,{open:E!==null,title:$(o,`Tạo session với toàn quyền?`,`Create with full access?`),description:$(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:$(o,`Hủy`,`Cancel`),confirmLabel:$(o,`Dùng toàn quyền`,`Use full access`),onCancel:()=>D(null),onConfirm:()=>{D(null),C(`trusted-full-access`)}})]})}var qC=sl((0,W.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`),JC=sl((0,W.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 YC(e){return K(`MuiListItem`,e)}Wr(`MuiListItem`,[`root`,`dense`,`alignItemsFlexStart`,`divider`,`gutters`,`padding`,`secondaryAction`]);function XC(e){return K(`MuiListItemSecondaryAction`,e)}Wr(`MuiListItemSecondaryAction`,[`root`,`disableGutters`]);var ZC=e=>{let{disableGutters:t,classes:n}=e;return va({root:[`root`,t&&`disableGutters`]},XC,n)},QC=J(`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}}]}),$C=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItemSecondaryAction`}),{className:r,component:i,...a}=n,o=v.useContext(Qd),s={...n,disableGutters:o.disableGutters},c=ZC(s);return(0,W.jsx)(QC,{as:i,className:G(c.root,r),ownerState:s,ref:t,...a})});$C.muiName=`ListItemSecondaryAction`;var ew=(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]},tw=e=>{let{alignItems:t,classes:n,dense:r,disableGutters:i,disablePadding:a,divider:o}=e;return va({root:[`root`,r&&`dense`,!i&&`gutters`,!a&&`padding`,o&&`divider`,t===`flex-start`&&`alignItemsFlexStart`],secondaryAction:[`secondaryAction`]},YC,n)},nw=J(`div`,{name:`MuiListItem`,slot:`Root`,overridesResolver:ew})(_s(({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:{[`& > .${uc.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:{...Ws(e,`background-color`,{duration:e.transitions.duration.shortest}),"&:hover":{textDecoration:`none`,backgroundColor:(e.vars||e).palette.action.hover,"@media (hover: none)":{backgroundColor:`transparent`}}}}]}))),rw=J($C,{name:`MuiListItem`,slot:`secondaryAction`})({}),iw=v.forwardRef(function(e,t){let n=Jo({props:e,name:`MuiListItem`}),{alignItems:r=`center`,children:i,className:a,component:o=`li`,dense:s=!1,disableGutters:c=!1,disablePadding:l=!1,divider:u=!1,secondaryAction:d,slotProps:f={},slots:p={},...m}=n,h=v.useContext(Qd),g=v.useMemo(()=>({dense:s||h.dense||!1,alignItems:r,disableGutters:c}),[r,h.dense,s,c]),_={...n,alignItems:r,dense:g.dense,disableGutters:c,disablePadding:l,divider:u,secondaryAction:d},y=tw(_),b={slots:p,slotProps:f},[x,S]=Jc(`root`,{ref:t,elementType:nw,externalForwardedProps:{component:o,...b,...m},ownerState:_,className:G(y.root,a)}),[C,w]=Jc(`secondaryAction`,{elementType:rw,shouldForwardComponentProp:!0,externalForwardedProps:b,ownerState:_,className:y.secondaryAction});return(0,W.jsx)(Qd.Provider,{value:g,children:(0,W.jsxs)(x,{...S,children:[i,d&&(0,W.jsx)(C,{...w,children:d})]})})}),aw=sl((0,W.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`),ow=sl((0,W.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 sw(e){return K(`PrivateSwitchBase`,e)}Wr(`PrivateSwitchBase`,[`root`,`checked`,`disabled`,`input`,`edgeStart`,`edgeEnd`]);var cw=e=>{let{classes:t,checked:n,disabled:r,edge:i}=e;return va({root:[`root`,n&&`checked`,r&&`disabled`,i&&`edge${Y(i)}`],input:[`input`]},sw,t)},lw=J(eu,{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}}]}),uw=J(`input`,{name:`MuiSwitchBase`,shouldForwardProp:Ko})({cursor:`inherit`,position:`absolute`,opacity:0,width:`100%`,height:`100%`,top:0,left:0,margin:0,padding:0,zIndex:1}),dw=v.forwardRef(function(e,t){let{autoFocus:n,checked:r,checkedIcon:i,defaultChecked:a,disabled:o,disableFocusRipple:s=!1,edge:c=!1,icon:l,id:u,name:d,onBlur:f,onChange:p,onFocus:m,readOnly:h,required:g=!1,tabIndex:_,type:v,value:y,slots:b={},slotProps:x={},...S}=e,{nativeButton:C,...w}=S,[T,E]=Dd({controlled:r,default:!!a,name:`SwitchBase`,state:`checked`}),D=hs(),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=cw(N),F={slots:b,slotProps:x},[I,L]=Jc(`root`,{ref:t,elementType:lw,className:P.root,shouldForwardComponentProp:!0,externalForwardedProps:{...F,component:`span`,...w},getSlotProps:e=>({...e,onFocus:t=>{e.onFocus?.(t),O(t)},onBlur:t=>{e.onBlur?.(t),k(t)}}),ownerState:N,additionalProps:{centerRipple:!0,focusRipple:!s,role:void 0,tabIndex:null}}),[R,ee]=Jc(`input`,{elementType:uw,className:P.input,externalForwardedProps:F,getSlotProps:e=>({...e,onChange:t=>{e.onChange?.(t),A(t)}}),ownerState:N,additionalProps:{autoFocus:n,checked:r,defaultChecked:a,disabled:j,id:M?u:void 0,name:d,readOnly:h,required:g,tabIndex:_,type:v,...v===`checkbox`&&y===void 0?{}:{value:y}}});return(0,W.jsxs)(I,{...L,children:[(0,W.jsx)(R,{...ee}),T?i:l]})});function fw(e){return K(`MuiSwitch`,e)}var pw=Wr(`MuiSwitch`,[`root`,`edgeStart`,`edgeEnd`,`switchBase`,`colorPrimary`,`colorSecondary`,`sizeSmall`,`sizeMedium`,`checked`,`disabled`,`input`,`thumb`,`track`]),mw=e=>{let{classes:t,edge:n,size:r,color:i,checked:a,disabled:o}=e,s=va({root:[`root`,n&&`edge${Y(n)}`,`size${Y(r)}`],switchBase:[`switchBase`,`color${Y(i)}`,a&&`checked`,o&&`disabled`],thumb:[`thumb`],track:[`track`],input:[`input`]},fw,t);return{...t,...s}},hw=J(`span`,{name:`MuiSwitch`,slot:`Root`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.root,n.edge&&t[`edge${Y(n.edge)}`],t[`size${Y(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,[`& .${pw.thumb}`]:{width:16,height:16},[`& .${pw.switchBase}`]:{padding:4,[`&.${pw.checked}`]:{transform:`translateX(16px)`}}}}]}),gw=J(dw,{name:`MuiSwitch`,slot:`SwitchBase`,overridesResolver:(e,t)=>{let{ownerState:n}=e;return[t.switchBase,{[`& .${pw.input}`]:t.input},n.color!=="default"&&t[`color${Y(n.color)}`]]}})(_s(({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]}`,...Ws(e,[`left`,`transform`],{duration:e.transitions.duration.shortest}),[`&.${pw.checked}`]:{transform:`translateX(20px)`},[`&.${pw.disabled}`]:{color:e.vars?e.vars.palette.Switch.defaultDisabledColor:`${e.palette.mode===`light`?e.palette.grey[100]:e.palette.grey[600]}`},[`&.${pw.checked} + .${pw.track}`]:{opacity:.5},[`&.${pw.disabled} + .${pw.track}`]:{opacity:e.vars?e.vars.opacity.switchTrackDisabled:`${e.palette.mode===`light`?.12:.2}`},[`& .${pw.input}`]:{left:`-100%`,width:`300%`}})),_s(({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(Oc([`light`])).map(([t])=>({props:{color:t},style:{[`&.${pw.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`}},[`&.${pw.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)}`}},[`&.${pw.checked} + .${pw.track}`]:{backgroundColor:(e.vars||e).palette[t].main}}}))]}))),_w=J(`span`,{name:`MuiSwitch`,slot:`Track`})(_s(({theme:e})=>({height:`100%`,width:`100%`,borderRadius:7,zIndex:-1,...Ws(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}`}))),vw=J(`span`,{name:`MuiSwitch`,slot:`Thumb`})(_s(({theme:e})=>({boxShadow:(e.vars||e).shadows[1],backgroundColor:`currentColor`,boxSizing:`border-box`,border:`1px solid transparent`,width:20,height:20,borderRadius:`50%`}))),yw=v.forwardRef(function(e,t){let n=Jo({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=mw(d),p=l.input,m={slots:c,slotProps:l},[h,g]=Jc(`root`,{className:G(f.root,r),elementType:hw,externalForwardedProps:m,ownerState:d,additionalProps:{sx:s}}),[_,v]=Jc(`thumb`,{className:f.thumb,elementType:vw,externalForwardedProps:m,ownerState:d}),y=(0,W.jsx)(_,{...v}),[b,x]=Jc(`track`,{className:f.track,elementType:_w,externalForwardedProps:m,ownerState:d});return(0,W.jsxs)(h,{...g,children:[(0,W.jsx)(gw,{type:`checkbox`,icon:y,checkedIcon:y,ref:t,ownerState:d,...u,classes:{...f,root:f.switchBase},slots:{...c.switchBase&&{root:c.switchBase},...c.input&&{input:c.input}},slotProps:{...l.switchBase&&{root:typeof l.switchBase==`function`?l.switchBase(d):l.switchBase},input:Od(typeof p==`function`?p(d):p,{role:`switch`})}}),(0,W.jsx)(b,{...x})]})});function bw(e,t){let n=e.name.toLowerCase();return n===`figma-desktop`?$(t,`Cần bật MCP trong Figma Desktop`,`Enable MCP in Figma Desktop`):n===`figma`?e.state===`disabled`?$(t,`Remote OAuth · chưa được Figma duyệt`,`Remote OAuth · not approved by Figma`):`Remote OAuth`:`${e.transport} · ${e.scope}`}function xw(e,t,n){return e===`mcp-oauth-client-not-approved`&&t.toLowerCase()===`figma`?$(n,`Figma Remote chưa cho phép Piagent đăng ký OAuth. Anh 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`?$(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`?$(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`?$(n,`Đã hủy đăng nhập.`,`Sign in cancelled.`):$(n,`Không thể kết nối OAuth. Vui lòng thử lại.`,`Could not connect OAuth. Please try again.`)}function Sw({sessionRef:e,connection:t,onChanged:n,compact:r=!1}){let{locale:i}=xv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!s||s.state!==`running`)return;let e=new AbortController,t=window.setTimeout(()=>void Kg(s.jobRef,e.signal).then(e=>{c(e),e.state===`completed`&&n()}).catch(()=>u($(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 Gg({action:r?`mcp.enable`:`mcp.disable`,sessionRef:e,connectionRef:t.connectionRef});`connections`in i?n(i):n()}catch{u($(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 Gg({action:`mcp.oauth`,sessionRef:e,connectionRef:t.connectionRef});if(`jobRef`in n)c(n);else throw Error(`mcp-oauth-job-missing`)}catch{u($(i,`Không thể bắt đầu OAuth`,`Could not start OAuth`))}finally{o(!1)}},p=async()=>{s?.state===`running`&&await Jg(s.jobRef).catch(()=>void 0),c(void 0),u(null)};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:.75,sx:{alignItems:`center`,flexWrap:`wrap`,justifyContent:`flex-end`},children:[t.authState===`connected`&&(0,W.jsx)(cu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,W.jsx)(aw,{}),label:$(i,`Đã kết nối`,`Connected`)}),t.oauthSupported&&t.authState!==`connected`&&t.state!==`disabled`&&(0,W.jsx)(HS,{size:`small`,variant:`outlined`,disabled:a,onClick:()=>void f(),children:`OAuth`}),t.toggleSupported&&(0,W.jsx)(Ah,{title:t.state===`disabled`?$(i,`Bật ${t.name}`,`Enable ${t.name}`):$(i,`Tắt ${t.name}`,`Disable ${t.name}`),arrow:!0,children:(0,W.jsx)(`span`,{children:(0,W.jsx)(yw,{size:r?`small`:`medium`,checked:t.state!==`disabled`,disabled:a,onChange:(e,t)=>void d(t),slotProps:{input:{"aria-label":t.state===`disabled`?$(i,`Bật ${t.name}`,`Enable ${t.name}`):$(i,`Tắt ${t.name}`,`Disable ${t.name}`)}}})})})]}),l&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,children:l}),(0,W.jsxs)(rC,{open:!!s,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,W.jsxs)(HC,{children:[t.name,` · OAuth`]}),(0,W.jsx)(FC,{children:(0,W.jsxs)(Cf,{spacing:1.25,sx:{pt:.5},children:[s?.state===`running`&&!s.authorizationUrl&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(i,`Đang chuẩn bị đăng nhập…`,`Preparing sign in…`)}),s?.authorizationUrl&&(0,W.jsx)(HS,{component:`a`,href:s.authorizationUrl,target:`_blank`,rel:`noopener noreferrer`,variant:`contained`,endIcon:(0,W.jsx)(ow,{}),children:$(i,`Mở trang đăng nhập`,`Open sign in`)}),s?.state===`completed`&&(0,W.jsx)(Z,{color:`success.main`,children:$(i,`Đã kết nối MCP`,`MCP connected`)}),s&&[`failed`,`cancelled`].includes(s.state)&&(0,W.jsx)(Z,{color:`error`,children:xw(s.reasonCode,t.name,i)})]})}),(0,W.jsx)(kC,{children:(0,W.jsx)(HS,{color:`inherit`,onClick:()=>void p(),children:s?.state===`running`?$(i,`Hủy`,`Cancel`):$(i,`Đóng`,`Close`)})})]})]})}function Cw({name:e,value:t}){return(0,W.jsxs)(Cf,{direction:`row`,sx:{justifyContent:`space-between`,gap:3,py:.65},children:[(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:e}),(0,W.jsx)(Z,{variant:`body2`,sx:{fontWeight:600},children:t})]})}function ww({title:e,label:t,icon:n,active:r,badge:i,onClick:a}){let o={border:1,borderColor:r?`primary.main`:`divider`,bgcolor:r?`action.selected`:`transparent`,color:r?`primary.main`:`text.secondary`,borderRadius:2,"&:hover":{bgcolor:`action.hover`,color:`text.primary`}},s=t?(0,W.jsx)(HS,{size:`small`,"aria-label":e,onClick:a,startIcon:n,sx:{...o,minHeight:34,maxWidth:260,px:1.15,"& .MuiButton-startIcon":{mr:.65},"& .MuiButton-startIcon svg":{fontSize:17}},children:(0,W.jsx)(X,{component:`span`,sx:{display:{xs:`none`,md:`inline`},overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:t})}):(0,W.jsx)(Zd,{size:`small`,"aria-label":e,onClick:a,sx:{...o,width:34,height:34},children:n});return(0,W.jsx)(Ah,{title:e,arrow:!0,children:i?(0,W.jsx)(tl,{badgeContent:i,color:`primary`,max:9999,sx:{"& .MuiBadge-badge":{height:16,minWidth:16,px:.4,fontSize:9,fontWeight:700}},children:s}):s})}function Tw({session:e,snapshot:t,connections:n,locale:r,onOpenChanges:i,canSetModel:a,canSetThinking:o,canSetPermission:s,onSetModel:c,onSetThinking:l,onSetPermission:u,onConnectionsChanged:d,placement:f=`composer`}){let[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(f!==`header`)return;let e=new AbortController;return wg(e.signal).then(y).catch(()=>void 0),()=>e.abort()},[f]);let E=e=>t=>{m(e),g(t.currentTarget)},D=()=>{m(null),g(null)},O=t?.sourceChanges,k=O?.workingTree.counts.files??0,A=t?.session.permissionProfile,[j,M]=(0,v.useState)(A?.state===`known`?A.value??null:null);(0,v.useEffect)(()=>{M(null)},[e.sessionRef]),(0,v.useEffect)(()=>{A?.state===`known`&&M(A.value??null)},[A?.state,A?.value]);let N=t?.usage.context,P=N?.state===`known`,F=P?N.tokens:e.contextUsage.usedTokens,I=P?N.contextWindow:e.contextUsage.contextWindow,L=P?N.percent:e.contextUsage.ratio===null?null:e.contextUsage.ratio*100,R=L==null?`—`:`${Math.round(L)}%`,ee=t?.session.model.state===`known`&&t.session.model.value?t.session.model.value.modelRef:``,te=_?.models.find(e=>e.modelRef===ee),ne=(0,v.useMemo)(()=>te?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],[te]),z=async e=>{if(!(!e||!c)){x(!0),C(null);try{await c(e)}catch{C($(r,`Chưa thể đổi model lúc này`,`Could not change the model right now`))}finally{x(!1)}}},B=async e=>{if(l){x(!0),C(null);try{await l(e)}catch{C($(r,`Chưa thể đổi thinking lúc này`,`Could not change thinking right now`))}finally{x(!1)}}},V=async e=>{if(u){x(!0),C(null);try{await u(e),M(e)}catch{C($(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{x(!1)}}},re=e=>{if(e===`trusted-full-access`){D(),T(e);return}V(e)},ie=p===`model`?`Model & thinking`:p===`context`?`Context`:p===`connections`?$(r,`MCP & kết nối`,`MCP & connections`):p===`permission`?$(r,`Quyền`,`Access`):$(r,`Source Changes`,`Source Changes`);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(X,{sx:{display:`flex`,gap:.65,mb:f===`composer`?.8:0,px:.1,flexWrap:`wrap`,alignItems:`center`,justifyContent:f===`header`?`flex-end`:`flex-start`},children:[f===`header`&&(0,W.jsx)(ww,{active:p===`model`,onClick:E(`model`),icon:(0,W.jsx)(uC,{fontSize:`small`}),label:`${e.modelLabel??$(r,`Model session`,`Session model`)} · ${Q(e.thinkingLevel,r)}`,title:$(r,`Đổi model và mức suy luận`,`Change model and thinking level`)}),f===`header`&&(0,W.jsx)(ww,{active:p===`permission`,onClick:E(`permission`),icon:(0,W.jsx)(JC,{fontSize:`small`}),label:j?Q(j,r):$(r,`Quyền`,`Access`),title:$(r,`Đổi quyền truy cập`,`Change access level`)}),f===`composer`&&(0,W.jsx)(ww,{active:p===`context`,onClick:E(`context`),icon:(0,W.jsx)(qC,{fontSize:`small`}),title:`Context · ${R}`}),f===`composer`&&(0,W.jsx)(ww,{active:p===`connections`,onClick:E(`connections`),icon:(0,W.jsx)(yC,{fontSize:`small`}),badge:n?.summary.configured??0,title:(n?.summary.configured??0)>0?$(r,`MCP & kết nối · ${n?.summary.configured}`,`MCP & connections · ${n?.summary.configured}`):$(r,`MCP & kết nối`,`MCP & connections`)}),f===`composer`&&(0,W.jsx)(ww,{active:p===`changes`,onClick:E(`changes`),icon:(0,W.jsx)(Ph,{fontSize:`small`}),badge:k,title:`Source Changes${k?` · ${k}`:``}`})]}),(0,W.jsxs)(Gy,{open:p!==null,anchorEl:h,onClose:D,anchorOrigin:{vertical:f===`header`?`bottom`:`top`,horizontal:`left`},transformOrigin:{vertical:f===`header`?`top`:`bottom`,horizontal:`left`},slotProps:{paper:{sx:{width:330,maxWidth:`calc(100vw - 24px)`,borderRadius:2.5,p:1.5,mt:+(f===`header`)}}},children:[(0,W.jsx)(Z,{sx:{px:.5,pb:1,fontWeight:600},children:ie}),(0,W.jsx)(Eu,{}),p===`model`&&(0,W.jsxs)(Cf,{sx:{px:.5,pt:1},spacing:1.25,children:[(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,W.jsx)(Mb,{fullWidth:!0,size:`small`,value:ee,disabled:!a||b||e.liveState===`running`,onChange:e=>void z(e.target.value),sx:{mt:.5},children:(_?.models??[]).map(e=>(0,W.jsx)(sC,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,W.jsx)(Mb,{fullWidth:!0,size:`small`,value:e.thinkingLevel===`unknown`?`off`:e.thinkingLevel,disabled:!o||b||e.liveState===`running`,onChange:e=>void B(e.target.value),sx:{mt:.5},children:ne.map(e=>(0,W.jsx)(sC,{value:e,children:Q(e,r)},e))})]}),S&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`context`&&(0,W.jsxs)(X,{sx:{px:.5,pt:.75},children:[(0,W.jsx)(Cw,{name:$(r,`Đã dùng`,`Used`),value:R}),(0,W.jsx)(Cw,{name:`Tokens`,value:F===null?`—`:new Intl.NumberFormat().format(F)}),(0,W.jsx)(Cw,{name:`Window`,value:I===null?`—`:new Intl.NumberFormat().format(I)})]}),p===`connections`&&(0,W.jsxs)(nf,{dense:!0,disablePadding:!0,sx:{pt:.5},children:[(n?.connections??[]).map(t=>(0,W.jsxs)(iw,{sx:{alignItems:`center`,gap:.5},children:[(0,W.jsx)(ff,{sx:{minWidth:38},children:(0,W.jsx)(wC,{name:t.name,size:28})}),(0,W.jsx)(Sf,{primary:t.name,secondary:bw(t,r)}),(0,W.jsx)(Sw,{compact:!0,sessionRef:e.sessionRef,connection:t,onChanged:e=>d?.(e)})]},t.connectionRef)),n&&n.connections.length===0&&(0,W.jsx)(iw,{children:(0,W.jsx)(Sf,{primary:$(r,`Chưa có MCP`,`No MCP configured`)})}),!n&&(0,W.jsx)(iw,{children:(0,W.jsx)(Sf,{primary:$(r,`Đang đọc…`,`Loading…`)})})]}),p===`permission`&&(0,W.jsxs)(Cf,{sx:{px:.5,pt:1},spacing:.75,children:[[`read-only`,`workspace-write`,`trusted-full-access`].map(t=>(0,W.jsx)(HS,{variant:j===t?`contained`:`outlined`,color:t===`trusted-full-access`?`warning`:`primary`,disabled:!s||b||e.liveState===`running`,onClick:()=>re(t),sx:{justifyContent:`flex-start`},children:Q(t,r)},t)),S&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,children:S})]}),p===`changes`&&(0,W.jsxs)(X,{sx:{px:.5,pt:.75},children:[(0,W.jsx)(Cw,{name:$(r,`Task changes`,`Task changes`),value:String(O?.task?.counts.files??0)}),(0,W.jsx)(Cw,{name:$(r,`Working tree`,`Working tree`),value:String(O?.workingTree.counts.files??0)}),(0,W.jsx)(Cw,{name:$(r,`Staged`,`Staged`),value:String(O?.staged.counts.files??0)}),(0,W.jsx)(HS,{fullWidth:!0,variant:`outlined`,startIcon:(0,W.jsx)(Ph,{}),sx:{mt:1},onClick:()=>{D(),i()},children:$(r,`Mở Source Changes`,`Open Source Changes`)})]})]}),(0,W.jsx)(UC,{open:w!==null,title:$(r,`Bật toàn quyền?`,`Enable full access?`),description:$(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 anh 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:$(r,`Hủy`,`Cancel`),confirmLabel:$(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>T(null),onConfirm:()=>{T(null),V(`trusted-full-access`)}})]})}var Ew=sl((0,W.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`),Dw=ui({themeId:Ho});function Ow({active:e,snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i,refresh:a}){let{locale:o}=xv();return e===`source`?(0,W.jsx)(Mv,{snapshot:t,sessionRef:n,refreshSnapshot:a}):e===`documents`?(0,W.jsx)(Zb,{sessionRef:n}):e===`activity`?(0,W.jsx)(ix,{snapshot:t,sessionRef:n,terminalActivities:r,liveActivities:i}):(0,W.jsxs)(Cf,{spacing:2.25,children:[(0,W.jsx)(nS,{snapshot:t,locale:o}),(0,W.jsx)(eS,{snapshot:t,locale:o}),(0,W.jsx)(dx,{snapshot:t})]})}var kw=`min(44vw, 860px)`;function Aw({open:e,active:t,snapshot:n,state:r,sessionRef:i,terminalActivities:a,liveActivities:o,onClose:s,onActive:c,refresh:l}){let{locale:u}=xv(),d=Dw(Uo().breakpoints.up(`xl`)),f=n?.sourceChanges.workingTree.counts.files??0,p=o===void 0?n?.activity.running.length??0:o.filter(e=>e.state===`running`).length;return(0,W.jsxs)(Gd,{anchor:`right`,variant:d?`persistent`:`temporary`,open:e,onClose:s,sx:{"& .MuiDrawer-paper":{width:{xs:`100%`,sm:`min(88vw, 980px)`,xl:kw},bgcolor:`background.default`}},children:[(0,W.jsxs)(X,{sx:{position:`sticky`,top:0,zIndex:3,bgcolor:`background.paper`,borderBottom:1,borderColor:`divider`},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{minHeight:64,px:{xs:1.5,md:2},alignItems:`center`,gap:1},children:[(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:820},children:$(u,`Agent Inspector`,`Agent Inspector`)}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:$(u,`Task contract · Git truth · verifier`,`Task contract · Git truth · verifier`)})]}),(0,W.jsx)(Ah,{title:$(u,`Làm mới Inspector`,`Refresh Inspector`),children:(0,W.jsx)(Zd,{onClick:()=>void l(),children:(0,W.jsx)(pS,{fontSize:`small`})})}),(0,W.jsx)(Zd,{"aria-label":$(u,`Đóng Inspector`,`Close Inspector`),onClick:s,children:(0,W.jsx)(Ew,{})})]}),(0,W.jsxs)(pg,{value:t,onChange:(e,t)=>c(t),variant:`scrollable`,scrollButtons:`auto`,children:[(0,W.jsx)(Kh,{value:`task`,icon:(0,W.jsx)(jh,{}),iconPosition:`start`,label:n?.task?`${$(u,`Task`,`Task`)} · ${n.task.progress.completed}/${n.task.progress.total}`:$(u,`Task`,`Task`)}),(0,W.jsx)(Kh,{value:`source`,icon:(0,W.jsx)(Ph,{}),iconPosition:`start`,label:`Source Changes${f?` · ${f}`:``}`}),(0,W.jsx)(Kh,{value:`documents`,icon:(0,W.jsx)(Nh,{}),iconPosition:`start`,label:$(u,`Tài liệu`,`Documents`)}),(0,W.jsx)(Kh,{value:`activity`,icon:(0,W.jsx)(Fh,{}),iconPosition:`start`,label:`${$(u,`Activity`,`Activity`)}${p?` · ${p}`:``}`})]})]}),r===`loading`?(0,W.jsxs)(Cf,{sx:{alignItems:`center`,py:12},spacing:1.5,children:[(0,W.jsx)(bu,{size:25}),(0,W.jsx)(Z,{color:`text.secondary`,children:$(u,`Đang dựng Inspector từ session và Git…`,`Building the Inspector from the session and Git…`)})]}):(r===`error`||!n)&&i&&t===`activity`&&a?.length?(0,W.jsx)(X,{sx:{p:{xs:1.5,sm:2.5,xl:3},maxWidth:1500,mx:`auto`,width:`100%`},children:(0,W.jsx)(ix,{sessionRef:i,terminalActivities:a,liveActivities:o})}):r===`error`||!n||!i?(0,W.jsxs)(Cf,{sx:{p:3,maxWidth:720},spacing:2,children:[(0,W.jsx)(AS,{severity:`warning`,children:$(u,`Không thể dựng Inspector cho session này. Chat vẫn an toàn; hãy kiểm tra project còn tồn tại và thử làm mới.`,`The Inspector could not be built for this session. Chat remains safe; check that the project still exists and refresh.`)}),(0,W.jsx)(HS,{variant:`outlined`,onClick:()=>void l(),children:$(u,`Thử lại`,`Try again`)})]}):(0,W.jsx)(X,{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,W.jsx)(Ow,{active:t,snapshot:n,sessionRef:i,terminalActivities:a,liveActivities:o,refresh:l})})]})}var jw=sl((0,W.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`),Mw=sl((0,W.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`),Nw=sl((0,W.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 Pw(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 Fw(e,t){return e&&!t?`connected`:`reconnecting`}var Iw=100,Lw=/^[A-Za-z0-9][A-Za-z0-9._~-]{0,159}$/,Rw=/^[a-z0-9][a-z0-9.-]{0,95}$/,zw=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;function Bw(e,t){return typeof t==`string`&&Rw.test(t)?t:e===`aborted`?`operation-aborted`:e===`blocked`?`operation-blocked`:e===`error`?`operation-failed`:`operation-settlement-unknown`}function Vw(e){if(e.settlement===`completed`||typeof e.operationRef!=`string`||!Lw.test(e.operationRef)||typeof e.settledAt!=`string`||!zw.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:Bw(t,e.reasonCode),settledAt:e.settledAt,sequence:Number(e.sequence)}}function Hw(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,Iw)}function Uw(e){if(e.state!==`ready`)return{};let t={};for(let n of e.settlements??[]){let e=Vw(n);e&&(t[n.sessionRef]=Hw(t[n.sessionRef]??[],[e]))}return t}function Ww(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,assistant:n===`completed`?e.assistant:``,error:n===`completed`?null:String(t.reasonCode??`operation-settlement-unknown`)}}function Gw(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||(r[i]={...a,user:``,assistant:``,attachments:[],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=i?.operationRef===n.operationRef;r[n.sessionRef]=a?{...i,operationRef:n.operationRef,abortable:n.abortable,complete:!1,settlement:null,error:null,lastEventAt:t.generatedAt}:{user:``,assistant:``,attachments:[],activities:[],operationRef:n.operationRef,abortable:n.abortable,complete:!1,settlement:null,error:null,runtimeRecovery:null,startedAt:t.generatedAt,lastEventAt:t.generatedAt}}return r}function Kw(e,t){let n=e.toLowerCase();return/(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`}function qw(e,t=`vi`,n=Date.now()){let r=[...e.activities].reverse().find(e=>e.state===`running`),i=r?Kw(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`;return{label:t===`vi`?`Piagent đang ${i}…`:`Piagent is ${i}…`,detail:s}}function Jw(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}var Yw=(0,v.lazy)(async()=>({default:(await Hb(async()=>{let{MarkdownMessage:e}=await import(`./MarkdownMessage-B4XehTCU.js`);return{MarkdownMessage:e}},[])).MarkdownMessage}));function Xw({children:e}){return(0,W.jsx)(v.Suspense,{fallback:(0,W.jsx)(Z,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.75},children:e}),children:(0,W.jsx)(Yw,{children:e})})}function Zw({attachments:e,locale:t}){return e.length?(0,W.jsx)(Cf,{spacing:.75,sx:{mb:1},"aria-label":$(t,`File đã gửi`,`Sent files`),children:e.map((e,n)=>{let r=`sourceBytes`in e?kx(e,t):`${e.kind===`document`?$(t,`Tài liệu`,`Document`):e.kind===`image`?$(t,`Ảnh`,`Image`):`File`}${e.truncated?` · ${$(t,`đã cắt bớt`,`truncated`)}`:``}`;return(0,W.jsxs)(Mc,{variant:`outlined`,sx:{display:`flex`,alignItems:`center`,gap:1.1,minWidth:220,maxWidth:440,px:1.2,py:1,borderRadius:2,bgcolor:`background.paper`},children:[e.kind===`image`?(0,W.jsx)(Nw,{color:`action`}):(0,W.jsx)(jw,{color:`action`}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{variant:`body2`,noWrap:!0,sx:{fontWeight:650},children:e.displayName}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:r})]})]},`${e.displayName}:${n}`)})}):null}function Qw({item:e,locale:t}){let n=e.role===`assistant`?yx(e.content.text??``):e.content.text;return e.role===`user`?(0,W.jsxs)(X,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:3,px:2,py:1.4},children:[(0,W.jsx)(Zw,{attachments:e.attachments??[],locale:t}),n&&(0,W.jsx)(Z,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:n}),(e.content.redacted||e.content.truncated)&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:e.content.redacted?$(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):$(t,`Nội dung đã rút gọn`,`Content truncated`)})]}):n?(0,W.jsxs)(X,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0,flex:1},children:[(0,W.jsx)(Z,{sx:{fontWeight:600},children:`Piagent`}),n&&(0,W.jsx)(X,{sx:{mt:.6},children:(0,W.jsx)(Xw,{children:n})}),(e.content.redacted||e.content.truncated)&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.8},children:e.content.redacted?$(t,`Đã ẩn dữ liệu nhạy cảm`,`Sensitive data hidden`):$(t,`Nội dung đã rút gọn`,`Content truncated`)})]})]}):null}function $w({live:e,locale:t,onOpenActivity:n}){let[r,i]=(0,v.useState)(()=>Date.now());(0,v.useEffect)(()=>{let e=window.setInterval(()=>i(Date.now()),1e4);return()=>window.clearInterval(e)},[]);let a=qw(e,t,r);return(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,role:`status`,"aria-live":`polite`,sx:{alignItems:`center`,color:`text.secondary`,py:.75},children:[(0,W.jsx)(bu,{size:19,thickness:4}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{variant:`body2`,sx:{fontWeight:600},children:a.label}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:a.detail})]}),n&&(0,W.jsx)(HS,{size:`small`,variant:`text`,onClick:n,sx:{ml:`auto !important`},children:$(t,`Xem Activity`,`View Activity`)})]})}function eT({sessionRef:e,sessionRevision:t,live:n,approvals:r,locale:i,onOpenActivity:a}){let[o,s]=(0,v.useState)(),[c,l]=(0,v.useState)(!0),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(null),g=n?.complete?`${n.operationRef??`unknown`}:${n.user}:${n.assistant.length}`:null;(0,v.useEffect)(()=>{let t=new AbortController;l(!0),p(!1),h(null);let r=window.setTimeout(()=>{Fg(e,null,50,t.signal).then(e=>{s(e),g&&n&&xx(e.items,n.user,n.assistant)&&h(g)}).catch(()=>{t.signal.aborted||p(!0)}).finally(()=>{t.signal.aborted||l(!1)})},g?100:0);return()=>{window.clearTimeout(r),t.abort()}},[e,t,g,n]);let _=o?.state===`ready`?o.items:[],y=(0,v.useMemo)(()=>Cx(_),[_]),b=(0,v.useMemo)(()=>!!(n?.user&&Sx(_,n.user)),[_,n?.user]),x=!!(n&&!b&&(!n.complete||m!==g)),S=(0,v.useMemo)(()=>!n?.user||!_.length?!1:bx([..._].reverse().find(e=>e.role===`user`)?.content.text,n.user),[_,n?.user]),C=async()=>{let t=o?.page.nextBeforeCursor;if(!(!t||u)){d(!0);try{let n=await Fg(e,t,o.page.limit);s(e=>e?{...e,items:px(e.items,n.items),page:n.page}:n)}catch{p(!0)}finally{d(!1)}}};return(0,W.jsxs)(Cf,{spacing:2.5,children:[o?.page.hasOlder&&(0,W.jsx)(X,{sx:{textAlign:`center`},children:(0,W.jsx)(HS,{size:`small`,variant:`text`,startIcon:u?(0,W.jsx)(bu,{size:14}):(0,W.jsx)(Ih,{}),disabled:u,onClick:()=>void C(),children:$(i,`Tải tin cũ hơn`,`Load older messages`)})}),c&&!o&&(0,W.jsx)(X,{sx:{py:5,textAlign:`center`},children:(0,W.jsx)(bu,{size:22})}),f&&!o&&(0,W.jsx)(AS,{severity:`warning`,icon:(0,W.jsx)(Mw,{}),children:$(i,`Chưa tải được lịch sử session. Anh vẫn có thể thử lại bằng nút làm mới.`,`Session history could not be loaded. You can retry with Refresh.`)}),y.map(e=>(0,W.jsx)(Qw,{item:e,locale:i},e.messageRef)),(0,W.jsx)(Rx,{sessionRef:e,approvalRefs:r?.pending.map(e=>e.approvalRef)??[]}),x&&n&&(0,W.jsxs)(W.Fragment,{children:[n.user&&!S&&(0,W.jsxs)(X,{sx:{alignSelf:`flex-end`,maxWidth:`82%`,bgcolor:`action.selected`,borderRadius:3,px:2,py:1.4},children:[(0,W.jsx)(Zw,{attachments:n.attachments,locale:i}),(0,W.jsx)(Z,{sx:{whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,lineHeight:1.7},children:n.user})]}),!n.complete&&!n.error&&(0,W.jsx)($w,{live:n,locale:i,onOpenActivity:a}),n.complete&&!n.error&&yx(n.assistant||``)&&(0,W.jsxs)(X,{sx:{display:`flex`,gap:1.5,alignItems:`flex-start`},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0,flex:1},children:[(0,W.jsx)(Z,{sx:{fontWeight:600},children:`Piagent`}),(0,W.jsx)(X,{sx:{mt:.6},children:(0,W.jsx)(Xw,{children:yx(n.assistant||``)})})]})]})]})]})}var tT=sl((0,W.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`),nT=sl((0,W.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`),rT=sl((0,W.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`),iT=sl((0,W.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`),aT=sl([(0,W.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,W.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`),oT=sl((0,W.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`),sT=sl((0,W.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 cT({catalog:e,refresh:t}){let{locale:n}=xv(),[r,i]=(0,v.useState)(),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null);(0,v.useEffect)(()=>{if(!r||r.state!==`running`)return;let e=new AbortController,a=window.setTimeout(()=>{Eg(r.jobRef,e.signal).then(e=>{i(e),e.state===`completed`&&t()}).catch(()=>{e.signal.aborted||u($(n,`Mất kết nối với luồng OAuth`,`OAuth flow disconnected`))})},750);return()=>{e.abort(),window.clearTimeout(a)}},[r?.jobRef,r?.generatedAt,r?.state,n]),(0,v.useEffect)(()=>o(``),[r?.prompt?.promptRef]);let d=async e=>{c(!0),u(null);try{i(await Og(e))}catch{u($(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 kg(r.jobRef,r.prompt.promptRef,a))}catch{u($(n,`Bước xác thực đã hết hạn`,`Authentication step expired`))}finally{c(!1)}}},p=async()=>{r?.state===`running`&&await Ag(r.jobRef).catch(()=>void 0),i(void 0),u(null)},m=r?.events.slice(-4)??[];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:(e?.providers??[]).map(e=>(0,W.jsx)(Mc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,W.jsx)(wC,{name:e.name,size:38}),(0,W.jsx)(Z,{sx:{flex:1,fontWeight:800},children:e.name}),e.state===`connected`&&(0,W.jsx)(cu,{size:`small`,color:`success`,variant:`outlined`,icon:(0,W.jsx)(sT,{}),label:$(n,`Đã kết nối`,`Connected`)}),(0,W.jsx)(HS,{size:`small`,variant:`outlined`,disabled:s,onClick:()=>void d(e.providerRef),children:e.state===`connected`?$(n,`Kết nối lại`,`Reconnect`):$(n,`Kết nối`,`Connect`)})]})},e.providerRef))}),e&&e.providers.length===0&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(n,`Pi chưa có provider OAuth`,`No OAuth providers available`)}),l&&!r&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`body2`,sx:{mt:1},children:l}),(0,W.jsxs)(rC,{open:!!r,onClose:()=>void p(),fullWidth:!0,maxWidth:`xs`,children:[(0,W.jsx)(HC,{children:r?.providerName??`OAuth`}),(0,W.jsx)(FC,{children:(0,W.jsxs)(Cf,{spacing:1.25,sx:{pt:.5},children:[r?.state===`completed`&&(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsx)(sT,{color:`success`}),(0,W.jsx)(Z,{children:$(n,`Đã kết nối`,`Connected`)})]}),m.map(e=>(0,W.jsxs)(X,{children:[e.message&&(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:e.message}),e.userCode&&(0,W.jsx)(Z,{sx:{my:1,fontFamily:`monospace`,fontSize:`1.35rem`,fontWeight:800,letterSpacing:`.12em`},children:e.userCode}),e.url&&(0,W.jsx)(HS,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,variant:`outlined`,size:`small`,endIcon:(0,W.jsx)(ow,{}),children:$(n,`Mở trang xác thực`,`Open authentication`)}),e.links.map(e=>(0,W.jsx)(HS,{component:`a`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,size:`small`,children:e.label??$(n,`Mở liên kết`,`Open link`)},e.url))]},e.sequence)),r?.prompt&&(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{variant:`body2`,sx:{mb:1},children:r.prompt.message}),r.prompt.type===`select`?(0,W.jsx)(Mb,{fullWidth:!0,size:`small`,value:a,onChange:e=>o(e.target.value),children:r.prompt.options.map(e=>(0,W.jsx)(sC,{value:e.id,children:e.label},e.id))}):(0,W.jsx)(Lb,{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,W.jsx)(Z,{color:`error`,variant:`body2`,children:Q(r.reasonCode??r.state,n)}),l&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`body2`,children:l})]})}),(0,W.jsxs)(kC,{children:[(0,W.jsx)(HS,{color:`inherit`,onClick:()=>void p(),children:r?.state===`running`?$(n,`Hủy`,`Cancel`):$(n,`Đóng`,`Close`)}),r?.prompt&&(0,W.jsx)(HS,{variant:`contained`,disabled:s||!a,onClick:()=>void f(),children:$(n,`Tiếp tục`,`Continue`)})]})]})]})}var lT=sl((0,W.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`),uT=sl([(0,W.jsx)(`circle`,{cx:`10`,cy:`8`,r:`4`},`0`),(0,W.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`),dT=sl((0,W.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 fT({icon:e,title:t,detail:n,children:r}){return(0,W.jsxs)(Mc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`,mb:1.5},children:[(0,W.jsx)(X,{sx:{width:38,height:38,borderRadius:2,bgcolor:`action.selected`,display:`grid`,placeItems:`center`,flex:`0 0 auto`},children:e}),(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{sx:{fontWeight:820},children:t}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function pT({children:e}){return(0,W.jsx)(Cf,{direction:`row`,sx:{gap:.75,flexWrap:`wrap`},children:e})}function mT({session:e,options:t,connections:n,onCompleted:r}){let{locale:i}=xv(),[a,o]=(0,v.useState)(!1),[s,c]=(0,v.useState)(),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(e?.sessionRevision??``),[p,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(``);(0,v.useEffect)(()=>{f(e?.sessionRevision??``),c(void 0),u(null)},[e?.sessionRef]),(0,v.useEffect)(()=>{e?.sessionRevision&&f(e.sessionRevision)},[e?.sessionRevision]);let w=a||!e||!d||e.liveState===`running`||e.liveState===`waiting-approval`,T=t?.profiles??[],E=(0,v.useMemo)(()=>(n?.connections??[]).filter(e=>/^[A-Za-z0-9][A-Za-z0-9._-]{0,119}$/.test(e.name)),[n]),D=async(t,n=null,a=!1)=>{if(!(!e||!d)){o(!0),u(null);try{let i=await qg({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($(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:w};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Z,{component:`h1`,variant:`h1`,sx:{mb:.75},children:$(i,`Điều khiển project`,`Project controls`)}),(0,W.jsx)(Z,{color:`text.secondary`,sx:{mb:2.5},children:$(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,W.jsx)(Mc,{variant:`outlined`,sx:{p:2,borderRadius:2.5,mb:2},children:(0,W.jsx)(Z,{color:`text.secondary`,children:$(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,W.jsxs)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1.25},children:[(0,W.jsxs)(fT,{icon:(0,W.jsx)(dT,{color:`primary`}),title:$(i,`Runtime & token`,`Runtime & tokens`),detail:$(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,W.jsxs)(pT,{children:[(0,W.jsx)(HS,{...k,onClick:()=>void D(`runtime.status`),children:`Pi status`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`runtime.inspector`),children:`Inspector`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`orchestration.status`),children:`Orchestration`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`usage.live`),children:`Usage live`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`usage.history`),children:`History`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`usage.logs`),children:`Logs`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`usage.efficiency`),children:`Efficiency`})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Lb,{size:`small`,fullWidth:!0,label:$(i,`Mô tả tác vụ sắp chạy`,`Upcoming task`),value:b,onChange:e=>x(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,W.jsx)(HS,{...k,sx:{whiteSpace:`nowrap`},onClick:()=>void D(`usage.preflight`,b.trim()||null),children:`Preflight`})]})]}),(0,W.jsxs)(fT,{icon:(0,W.jsx)(uT,{color:`primary`}),title:$(i,`Onboarding & profile`,`Onboarding & profile`),detail:$(i,`Kiểm tra project và áp dụng profile dùng chung có kiểm soát.`,`Inspect the project and apply a controlled reusable profile.`),children:[(0,W.jsxs)(pT,{children:[(0,W.jsx)(HS,{...k,onClick:()=>void D(`onboarding.status`),children:`Onboard status`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`onboarding.profile`),children:`Profile check`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`onboarding.tech`),children:`Tech check`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`profile.status`),children:$(i,`Profile hiện tại`,`Current profile`)})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Mb,{size:`small`,fullWidth:!0,displayEmpty:!0,value:h,onChange:e=>g(e.target.value),disabled:w,renderValue:e=>e?T.find(t=>t.id===e)?.displayName??e:$(i,`Chọn profile…`,`Select profile…`),children:T.map(e=>(0,W.jsx)(sC,{value:e.id,children:e.displayName},e.id))}),(0,W.jsx)(HS,{...k,disabled:w||!h,sx:{whiteSpace:`nowrap`},onClick:()=>O(`profile.apply`,h,$(i,`Áp dụng profile?`,`Apply profile?`),$(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:$(i,`Áp dụng`,`Apply`)}),(0,W.jsx)(HS,{...k,onClick:()=>O(`profile.auto`,null,$(i,`Tự nhận diện profile?`,`Auto-detect profile?`),$(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,W.jsxs)(fT,{icon:(0,W.jsx)(lT,{color:`primary`}),title:$(i,`Context engine`,`Context engine`),detail:$(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,W.jsxs)(pT,{children:[(0,W.jsx)(HS,{...k,onClick:()=>void D(`context.status`),children:`Index status`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`context.efficiency`),children:`Efficiency`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`context.impact`),children:`Impact`}),(0,W.jsx)(HS,{...k,color:`warning`,onClick:()=>O(`context.rebuild`,null,$(i,`Rebuild context index?`,`Rebuild context index?`),$(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,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Lb,{size:`small`,fullWidth:!0,label:$(i,`Câu hỏi hoặc mục tiêu`,`Question or goal`),value:_,onChange:e=>y(e.target.value),slotProps:{htmlInput:{maxLength:2048}}}),(0,W.jsx)(HS,{...k,disabled:w||!_.trim(),onClick:()=>void D(`context.search`,_.trim()),children:`Search`}),(0,W.jsx)(HS,{...k,disabled:w||!_.trim(),onClick:()=>void D(`context.pack`,_.trim()),children:`Pack`}),(0,W.jsx)(HS,{...k,color:`warning`,onClick:()=>O(`context.compact`,_.trim()||null,$(i,`Compact context bằng model?`,`Compact context with the model?`),$(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,W.jsx)(fT,{icon:(0,W.jsx)(iT,{color:`primary`}),title:$(i,`Memory`,`Memory`),detail:$(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,W.jsx)(pT,{children:(0,W.jsx)(HS,{...k,onClick:()=>void D(`memory.status`),children:$(i,`Kiểm tra memory`,`Check memory`)})})}),(0,W.jsxs)(fT,{icon:(0,W.jsx)(yC,{color:`primary`}),title:$(i,`MCP governance`,`MCP governance`),detail:$(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,W.jsxs)(pT,{children:[(0,W.jsx)(HS,{...k,onClick:()=>void D(`mcp.status`),children:`MCP status`}),(0,W.jsx)(HS,{...k,onClick:()=>void D(`mcp.doctor`),children:`Doctor`})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{mt:1,gap:.75},children:[(0,W.jsx)(Mb,{size:`small`,fullWidth:!0,displayEmpty:!0,value:S,onChange:e=>C(e.target.value),disabled:w,renderValue:e=>e||$(i,`Chọn MCP…`,`Select MCP…`),children:E.map(e=>(0,W.jsx)(sC,{value:e.name,children:e.name},e.connectionRef))}),(0,W.jsx)(HS,{...k,disabled:w||!S,onClick:()=>void D(`mcp.detail`,S),children:`Detail`}),(0,W.jsx)(HS,{...k,disabled:w||!S,onClick:()=>O(`mcp.approve`,S,$(i,`Phê duyệt MCP?`,`Approve MCP?`),$(i,`Project sẽ tin cậy cấu hình MCP đã chọn.`,`The project will trust the selected MCP configuration.`)),children:`Approve`}),(0,W.jsx)(HS,{...k,disabled:w||!S,color:`warning`,onClick:()=>O(`mcp.reject`,S,$(i,`Từ chối MCP?`,`Reject MCP?`),$(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,W.jsx)(HS,{...k,disabled:w||!S,color:`warning`,onClick:()=>O(`mcp.reset`,S,$(i,`Reset quyết định MCP?`,`Reset MCP decision?`),$(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,W.jsx)(Mc,{"aria-live":`polite`,variant:`outlined`,sx:{mt:2,p:2,borderRadius:2.5},children:a?(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{alignItems:`center`},children:[(0,W.jsx)(bu,{size:18}),(0,W.jsx)(Z,{children:$(i,`Đang chạy trong Pi runtime…`,`Running in the Pi runtime…`)})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1,flexWrap:`wrap`},children:[(0,W.jsx)(aw,{color:s?.state===`settled`?`success`:`warning`}),(0,W.jsx)(Z,{sx:{fontWeight:800},children:s?s.action:$(i,`Không hoàn tất`,`Not completed`)}),s&&(0,W.jsx)(cu,{size:`small`,color:s.state===`settled`?`success`:`warning`,variant:`outlined`,label:s.resultCode}),s?.effect===`read-only`&&(0,W.jsx)(cu,{size:`small`,color:s.modelCallObserved?`warning`:`success`,variant:`outlined`,label:s.modelCallObserved?$(i,`Đã phát hiện model call`,`Model call detected`):`0 model token`})]}),l&&(0,W.jsx)(Z,{color:`error`,variant:`body2`,sx:{mt:1},children:l}),s?.outputs.map((e,t)=>(0,W.jsx)(X,{component:`pre`,sx:{m:0,mt:1,p:1.25,borderRadius:1.5,bgcolor:`action.hover`,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`,fontSize:12.5,maxHeight:260,overflow:`auto`},children:e.content},`${e.customType}-${t}`))]})}),(0,W.jsx)(UC,{open:p!==null,title:p?.title??``,description:p?.description??``,cancelLabel:$(i,`Hủy`,`Cancel`),confirmLabel:$(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)}})]})}function hT(e,t){return e==null?`—`:new Intl.NumberFormat(t===`vi`?`vi-VN`:`en-US`).format(e)}function gT({children:e}){return(0,W.jsx)(Z,{component:`h1`,variant:`h1`,sx:{mb:3},children:e})}function _T({icon:e,title:t,detail:n,action:r}){return(0,W.jsxs)(Cf,{direction:{xs:`column`,sm:`row`},sx:{alignItems:{sm:`center`},justifyContent:`space-between`,gap:2,p:2.25},children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:1.4,sx:{alignItems:`center`},children:[e,(0,W.jsxs)(X,{children:[(0,W.jsx)(Z,{sx:{fontWeight:760},children:t}),n&&(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:n})]})]}),r]})}function vT(){let{locale:e,colorMode:t,setLocale:n,setColorMode:r}=xv();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gT,{children:$(e,`Giao diện`,`Appearance`)}),(0,W.jsxs)(Mc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:[(0,W.jsx)(_T,{icon:(0,W.jsx)(rT,{color:`primary`}),title:$(e,`Ngôn ngữ`,`Language`),action:(0,W.jsxs)(op,{exclusive:!0,size:`small`,value:e,onChange:(e,t)=>t&&n(t),children:[(0,W.jsx)(ep,{value:`vi`,children:`VI`}),(0,W.jsx)(ep,{value:`en`,children:`EN`})]})}),(0,W.jsx)(Eu,{}),(0,W.jsx)(_T,{icon:t===`dark`?(0,W.jsx)(Bh,{color:`primary`}):(0,W.jsx)(zh,{color:`primary`}),title:$(e,`Chủ đề`,`Theme`),action:(0,W.jsxs)(op,{exclusive:!0,size:`small`,value:t,onChange:(e,t)=>t&&r(t),children:[(0,W.jsx)(ep,{value:`light`,children:$(e,`Sáng`,`Light`)}),(0,W.jsx)(ep,{value:`dark`,children:$(e,`Tối`,`Dark`)})]})})]})]})}function yT({options:e,snapshot:t,activeModel:n,observedProvider:r}){let{locale:i}=xv(),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,W.jsx)(oT,{color:`primary`}),title:a?.route===`codex-first`?`Codex Web Search`:$(i,`Tìm kiếm web`,`Web search`),detail:a?.route===`codex-first`?$(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`?$(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.`):$(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`?$(i,`Ưu tiên Codex`,`Codex first`):a?.state===`configured`?$(i,`Đã cấu hình`,`Configured`):$(i,`Chưa có`,`Unavailable`),ready:a?.state===`configured`},{key:`vision`,icon:(0,W.jsx)(tT,{color:`primary`}),title:d?`Codex Vision`:$(i,`Vision của model`,`Model vision`),detail:u===!0?$(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?$(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.`):$(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?$(i,`Đang dùng`,`Active`):u===!1?$(i,`Không hỗ trợ`,`Unsupported`):$(i,`Chưa rõ`,`Unknown`),ready:u===!0}];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Z,{variant:`h2`,sx:{mt:3,mb:.5},children:$(i,`Tìm kiếm & hình ảnh`,`Search & vision`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:$(i,`Capability thực tế của Pi runtime và model đang chọn.`,`Capabilities reported by the Pi runtime and selected model.`)}),(0,W.jsx)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,md:`repeat(2,minmax(0,1fr))`},gap:1},children:f.map(e=>(0,W.jsx)(Mc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,sx:{alignItems:`flex-start`},children:[(0,W.jsx)(X,{sx:{width:36,height:36,display:`grid`,placeItems:`center`,borderRadius:2,bgcolor:`action.selected`,flex:`0 0 auto`},children:e.icon}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:800},children:e.title}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:e.detail})]}),(0,W.jsx)(cu,{size:`small`,color:e.ready?`success`:`default`,variant:`outlined`,label:e.status})]})},e.key))})]})}function bT({options:e,auth:t,refreshAuth:n,session:r,snapshot:i,onSetModel:a,onSetThinking:o}){let{locale:s}=xv(),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(null),f=i?.session.model.state===`known`?i.session.model.value:null,p=(0,v.useMemo)(()=>{let t=new Map;for(let n of e?.models??[])t.set(n.provider,[...t.get(n.provider)??[],n]);return[...t.entries()]},[e]),m=f?.modelRef??``,h=e?.models.find(e=>e.modelRef===m),g=h?m:``,_=f?.displayName??r?.modelLabel??`—`,y=h?.thinkingLevels??[`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`],b=async e=>{if(e){l(!0),d(null);try{await e()}catch{d($(s,`Chưa thể áp dụng thay đổi`,`Could not apply this change`))}finally{l(!1)}}};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gT,{children:$(s,`Nhà cung cấp & model`,`Providers & models`)}),r&&(0,W.jsxs)(Mc,{variant:`outlined`,sx:{p:2.25,borderRadius:2.5,mb:2},children:[(0,W.jsxs)(Cf,{direction:`row`,spacing:1.25,sx:{alignItems:`center`,mb:2},children:[(0,W.jsx)(wC,{name:f?.provider??r.modelLabel??`model`,size:38}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:700},children:$(s,`Model của session hiện tại`,`Current session model`)}),(0,W.jsxs)(Z,{variant:`body2`,color:`text.secondary`,noWrap:!0,children:[_,` · `,Q(r.thinkingLevel,s)]})]}),(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:$(s,`Đang dùng`,`In use`)})]}),(0,W.jsxs)(Cf,{direction:{xs:`column`,md:`row`},spacing:1.5,children:[(0,W.jsxs)(X,{sx:{flex:1},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Model`}),(0,W.jsx)(Mb,{fullWidth:!0,size:`small`,value:g,displayEmpty:!0,renderValue:t=>t?e?.models.find(e=>e.modelRef===t)?.displayName??_:_,disabled:c||!a||r.liveState===`running`,onChange:e=>void b(()=>a?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:(e?.models??[]).map(e=>(0,W.jsx)(sC,{value:e.modelRef,children:e.displayName},e.modelRef))})]}),(0,W.jsxs)(X,{sx:{width:{md:220}},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:`Thinking`}),(0,W.jsx)(Mb,{fullWidth:!0,size:`small`,value:r.thinkingLevel===`unknown`?`off`:r.thinkingLevel,disabled:c||!o||r.liveState===`running`,onChange:e=>void b(()=>o?.(e.target.value)??Promise.resolve()),sx:{mt:.5},children:y.map(e=>(0,W.jsx)(sC,{value:e,children:Q(e,s)},e))})]})]}),u&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:u})]}),(0,W.jsx)(yT,{options:e,snapshot:i,activeModel:h,observedProvider:f?.provider}),(0,W.jsx)(Z,{variant:`h2`,sx:{mt:3,mb:.5},children:$(s,`Kết nối nhà cung cấp`,`Provider connections`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:$(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,W.jsx)(cT,{catalog:t,refresh:n}),(0,W.jsx)(Z,{variant:`h2`,sx:{mt:3,mb:.5},children:$(s,`Danh mục model`,`Model catalog`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.25},children:$(s,`Các model hiện có từ những provider đã xác thực.`,`Models currently available from authenticated providers.`)}),(0,W.jsx)(X,{sx:{display:`grid`,gridTemplateColumns:{xs:`1fr`,lg:`repeat(2,minmax(0,1fr))`},gap:1},children:p.map(([e,t])=>(0,W.jsxs)(Mc,{variant:`outlined`,sx:{p:1.5,borderRadius:2},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1},children:[(0,W.jsx)(wC,{name:e,size:32}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{noWrap:!0,sx:{fontWeight:700,textTransform:`capitalize`},children:e}),(0,W.jsxs)(Z,{variant:`body2`,color:`text.secondary`,children:[t.length,` model`]})]}),(0,W.jsx)(cu,{size:`small`,color:`success`,variant:`outlined`,label:$(s,`Sẵn sàng`,`Ready`)})]}),(0,W.jsxs)(X,{sx:{display:`flex`,gap:.6,mt:1.25,flexWrap:`wrap`},children:[t.slice(0,6).map(e=>(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:e.displayName},e.modelRef)),t.length>6&&(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:`+${t.length-6}`})]})]},e))}),e&&p.length===0&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(s,`Chưa có model đã xác thực`,`No authenticated models`)})]})}function xT({value:e,loading:t,sessionRef:n,onChanged:r}){let{locale:i}=xv();return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gT,{children:$(i,`MCP & kết nối`,`MCP & connections`)}),t?(0,W.jsx)(bu,{size:22}):(0,W.jsxs)(Cf,{spacing:1,children:[(e?.connections??[]).map(e=>(0,W.jsx)(Mc,{variant:`outlined`,sx:{p:1.75,borderRadius:2.5},children:(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:1.25},children:[(0,W.jsx)(wC,{name:e.name,size:38}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{noWrap:!0,sx:{fontWeight:800},children:e.name}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:bw(e,i)})]}),n?(0,W.jsx)(Sw,{sessionRef:n,connection:e,onChanged:r}):(0,W.jsx)(cu,{size:`small`,variant:`outlined`,label:$(i,`Đã cấu hình`,`Configured`)})]})},e.connectionRef)),!e?.connections.length&&(0,W.jsx)(Z,{color:`text.secondary`,children:$(i,`Chưa có MCP trong project này`,`No MCP configured for this project`)})]})]})}function ST({snapshot:e,session:t,onSetPermission:n}){let{locale:r}=xv(),i=e?.session.permissionProfile,[a,o]=(0,v.useState)(i?.state===`known`?i.value??null:null),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(null);(0,v.useEffect)(()=>{o(null)},[t?.sessionRef]),(0,v.useEffect)(()=>{i?.state===`known`&&o(i.value??null)},[i?.state,i?.value]);let p=async e=>{if(n){c(!0),u(null);try{await n(e),o(e)}catch{u($(r,`Chưa thể đổi quyền lúc này`,`Could not change access right now`))}finally{c(!1)}}},m=e=>{if(e===`trusted-full-access`){f(e);return}p(e)},h=[{mode:`read-only`,detail:$(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:$(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:$(r,`Quyền rộng hơn trong runtime; xóa hoặc gửi dữ liệu ra ngoài vẫn cần xác nhận riêng.`,`Broader runtime access; deleting or sending data externally still requires separate confirmation.`)}];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gT,{children:$(r,`Quyền truy cập`,`Access`)}),(0,W.jsx)(Z,{variant:`h2`,sx:{mb:.5},children:$(r,`Hồ sơ quyền`,`Permission profile`)}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,sx:{mb:1.5},children:$(r,`Áp dụng cho session hiện tại.`,`Applies to the current session.`)}),(0,W.jsx)(Mc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:h.map((e,i)=>(0,W.jsxs)(X,{children:[(0,W.jsx)(_T,{icon:(0,W.jsx)(dC,{color:e.mode===`trusted-full-access`?`warning`:`primary`}),title:Q(e.mode,r),detail:e.detail,action:(0,W.jsx)(HS,{size:`small`,variant:a===e.mode?`contained`:`outlined`,color:e.mode===`trusted-full-access`?`warning`:`primary`,"aria-pressed":a===e.mode,disabled:s||!t||!n||t.liveState===`running`,onClick:()=>m(e.mode),children:Q(e.mode,r)})}),i<h.length-1&&(0,W.jsx)(Eu,{})]},e.mode))}),l&&(0,W.jsx)(Z,{role:`status`,color:`error`,variant:`caption`,sx:{mt:1},children:l}),(0,W.jsx)(UC,{open:d!==null,title:$(r,`Bật toàn quyền?`,`Enable full access?`),description:$(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 anh 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:$(r,`Hủy`,`Cancel`),confirmLabel:$(r,`Bật toàn quyền`,`Enable full access`),onCancel:()=>f(null),onConfirm:()=>{f(null),p(`trusted-full-access`)}})]})}function CT({session:e,snapshot:t}){let{locale:n}=xv(),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=[[$(n,`Context`,`Context`),r?.percent==null?`—`:`${Math.round(r.percent)}%`],[`Tokens`,`${hT(r?.tokens,n)} / ${hT(r?.contextWindow,n)}`],[$(n,`Input`,`Input`),hT(t?.usage.sessionTotal.input,n)],[$(n,`Output`,`Output`),hT(t?.usage.sessionTotal.output,n)],[$(n,`Continuation`,`Continuation`),hT(t?.continuation.remaining,n)],[`Verifier`,t?.verification.state??`—`]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gT,{children:$(n,`Usage & context`,`Usage & context`)}),(0,W.jsx)(X,{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,W.jsxs)(Mc,{variant:`outlined`,sx:{p:2,borderRadius:2.5},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:e}),(0,W.jsx)(Z,{sx:{mt:.6,fontSize:`1.25rem`,fontWeight:800},children:t})]},e))})]})}function wT({capabilities:e,connection:t}){let{locale:n}=xv(),r=[[`Gateway`,t],[`Mode`,e?.mode??`unknown`],[`Protocol`,e?.protocol.selected??`—`],[$(n,`Runtime`,`Runtime`),e?.capabilities.sessionRuntime.status??`unknown`]];return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(gT,{children:`Piagent`}),(0,W.jsx)(Mc,{variant:`outlined`,sx:{borderRadius:2.5,overflow:`hidden`},children:r.map(([e,t],n)=>(0,W.jsxs)(X,{children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{px:2.25,py:1.6,justifyContent:`space-between`,gap:2},children:[(0,W.jsx)(Z,{color:`text.secondary`,children:e}),(0,W.jsx)(Z,{sx:{fontWeight:760},children:String(t)})]}),n<r.length-1&&(0,W.jsx)(Eu,{})]},String(e)))})]})}function TT({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}=xv(),[f,p]=(0,v.useState)(),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)(),[y,b]=(0,v.useState)(!1);(0,v.useEffect)(()=>{let e=new AbortController;return wg(e.signal).then(p).catch(()=>void 0),()=>e.abort()},[]);let x=async()=>{let[e,t]=await Promise.all([Tg(),wg()]);h(e),p(t)};(0,v.useEffect)(()=>{let e=new AbortController;return Tg(e.signal).then(h).catch(()=>void 0),()=>e.abort()},[]),(0,v.useEffect)(()=>{if(!r){_(void 0);return}let e=new AbortController;return b(!0),_(void 0),Wg(r.sessionRef,e.signal).then(_).catch(()=>void 0).finally(()=>{e.signal.aborted||b(!1)}),()=>e.abort()},[r?.sessionRef]);let S=async e=>{if(e){_(e);return}r&&_(await Wg(r.sessionRef).catch(()=>g))},C=[{id:`general`,label:$(d,`Giao diện`,`Appearance`),icon:(0,W.jsx)(fC,{})},{id:`models`,label:$(d,`Nhà cung cấp & model`,`Providers & models`),icon:(0,W.jsx)(aT,{})},{id:`controls`,label:$(d,`Điều khiển project`,`Project controls`),icon:(0,W.jsx)(oS,{})},{id:`connections`,label:$(d,`MCP & kết nối`,`MCP & connections`),icon:(0,W.jsx)(yC,{})},{id:`permissions`,label:$(d,`Quyền truy cập`,`Access`),icon:(0,W.jsx)(dC,{})},{id:`usage`,label:$(d,`Sử dụng & context`,`Usage & context`),icon:(0,W.jsx)(iT,{})},{id:`about`,label:`Piagent`,icon:(0,W.jsx)(nT,{})}];return(0,W.jsxs)(X,{sx:{height:`100%`,minHeight:0,display:{sm:`grid`},gridTemplateColumns:{sm:`220px minmax(0,1fr)`},bgcolor:`background.default`},children:[(0,W.jsxs)(X,{component:`nav`,"aria-label":$(d,`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`},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{minHeight:48,alignItems:`center`,justifyContent:`space-between`,px:1,mb:{sm:1}},children:[(0,W.jsx)(Z,{id:`piagent-settings-title`,sx:{fontWeight:700},children:$(d,`Cài đặt`,`Settings`)}),(0,W.jsx)(Zd,{"aria-label":$(d,`Đóng cài đặt`,`Close settings`),onClick:n,children:(0,W.jsx)(Ew,{})})]}),(0,W.jsx)(nf,{component:`div`,disablePadding:!0,sx:{display:{xs:`flex`,sm:`block`},minWidth:{xs:`max-content`,sm:0},overflowX:`auto`},children:C.map(n=>(0,W.jsxs)(sf,{selected:e===n.id,onClick:()=>t(n.id),children:[(0,W.jsx)(ff,{sx:{minWidth:36,color:`inherit`,"& .MuiSvgIcon-root":{fontSize:19}},children:n.icon}),(0,W.jsx)(Sf,{primary:n.label,slotProps:{primary:{sx:{fontSize:13,fontWeight:e===n.id?800:650}}}})]},n.id))})]}),(0,W.jsxs)(X,{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,W.jsx)(vT,{}),e===`models`&&(0,W.jsx)(bT,{options:f,auth:m,refreshAuth:x,session:r,snapshot:i,onSetModel:s,onSetThinking:c}),e===`connections`&&(0,W.jsx)(xT,{value:g,loading:y,sessionRef:r?.sessionRef,onChanged:S}),e===`controls`&&(0,W.jsx)(mT,{session:r,options:f,connections:g,onCompleted:u}),e===`permissions`&&(0,W.jsx)(ST,{snapshot:i,session:r,onSetPermission:l}),e===`usage`&&(0,W.jsx)(CT,{session:r,snapshot:i}),e===`about`&&(0,W.jsx)(wT,{capabilities:a,connection:o})]})]})}var ET=288,DT=`min(44vw, 860px)`;function OT(e,t){let n=Math.max(0,Math.floor((Date.now()-Date.parse(e))/1e3));if(n<60)return $(t,`Vừa xong`,`Just now`);let r=Math.floor(n/60);if(r<60)return $(t,`${r} phút`,`${r}m`);let i=Math.floor(r/60);if(i<24)return $(t,`${i} giờ`,`${i}h`);let a=Math.floor(i/24);return $(t,`${a} ngày`,`${a}d`)}function kT({session:e}){let t=e.needsAttention?`warning.main`:e.liveState===`running`?`primary.main`:e.state===`gateway-owned`||e.state===`terminal-owned`?`success.main`:`text.disabled`;return(0,W.jsx)(X,{"aria-hidden":`true`,sx:{width:7,height:7,mt:.8,ml:.75,borderRadius:`50%`,bgcolor:t,boxShadow:e.liveState===`running`?`0 0 0 4px rgba(216,255,122,.12)`:`none`}})}function AT({session:e,selected:t,locale:n,onSelect:r,onAction:i}){let[a,o]=(0,v.useState)(null),s=e=>{o(null),i(e)};return(0,W.jsxs)(X,{sx:{display:`flex`,alignItems:`center`,pr:.5},children:[(0,W.jsxs)(sf,{selected:t,onClick:r,sx:{minWidth:0,alignItems:`flex-start`,py:1.1,px:1.4},children:[(0,W.jsx)(Sf,{primary:e.title,secondary:(0,W.jsxs)(W.Fragment,{children:[e.preview||e.projectLabel,(0,W.jsx)(`span`,{children:` · `}),OT(e.updatedAt,n)]}),slotProps:{primary:{noWrap:!0,sx:{fontSize:13.25,fontWeight:t?600:500}},secondary:{noWrap:!0,sx:{mt:.3,fontSize:11.25}}}}),(0,W.jsx)(kT,{session:e})]}),(0,W.jsx)(Zd,{size:`small`,"aria-label":$(n,`Tùy chọn cuộc trò chuyện`,`Chat options`),onClick:e=>o(e.currentTarget),children:(0,W.jsx)(fS,{fontSize:`small`})}),(0,W.jsxs)($y,{anchorEl:a,open:!!a,onClose:()=>o(null),onClick:e=>e.stopPropagation(),children:[!e.archived&&(0,W.jsx)(sC,{onClick:()=>s(`rename`),children:$(n,`Đổi tên`,`Rename`)}),!e.archived&&(0,W.jsx)(sC,{onClick:()=>s(`pin`),children:e.pinned?$(n,`Bỏ ghim`,`Unpin`):$(n,`Ghim`,`Pin`)}),!e.archived&&(0,W.jsx)(sC,{onClick:()=>s(`fork`),children:$(n,`Tạo nhánh`,`Fork`)}),(0,W.jsx)(sC,{onClick:()=>s(e.archived?`unarchive`:`archive`),children:e.archived?$(n,`Bỏ lưu trữ`,`Unarchive`):$(n,`Lưu trữ`,`Archive`)})]})]})}function jT({session:e,locale:t}){let n=e.state===`gateway-owned`||e.state===`terminal-owned`;return(0,W.jsx)(cu,{size:`small`,variant:`outlined`,color:n?`success`:e.needsAttention?`warning`:`default`,label:e.liveState===`running`?$(t,`Đang chạy`,`Running`):n?$(t,`Đang hoạt động`,`Active`):e.state===`recovery-required`?$(t,`Cần khôi phục`,`Recovery needed`):$(t,`Đã lưu`,`Saved`)})}function MT({session:e,snapshot:t,locale:n,live:r,canSend:i,canRestart:a,send:o,abort:s,restart:c,onInspector:l}){let[u,d]=(0,v.useState)(``),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(),[g,_]=(0,v.useState)([]),[y,b]=(0,v.useState)(`continue`),[x,S]=(0,v.useState)(!1),[C,w]=(0,v.useState)(()=>`message-request.${crypto.randomUUID()}`),[T,E]=(0,v.useState)(!1),[D,O]=(0,v.useState)(null),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),F=(0,v.useRef)(0);(0,v.useEffect)(()=>{d(``),b(`continue`),S(!1),_([]),O(null),A(null),w(`message-request.${crypto.randomUUID()}`)},[e.sessionRef]),(0,v.useEffect)(()=>{let e=e=>{jx(e.dataTransfer)&&e.preventDefault()};return window.addEventListener(`dragover`,e),window.addEventListener(`drop`,e),()=>{window.removeEventListener(`dragover`,e),window.removeEventListener(`drop`,e)}},[]);let I=t?.capabilities.capabilities.attachments,L=(0,v.useMemo)(()=>new Set(I?.status===`available`?I.mimeTypes:[]),[I]),R=(0,v.useMemo)(()=>Ax(L),[L]),ee=!!t&&I?.status===`available`&&i&&!f&&!T&&g.length<4,te=async r=>{if(!(!r?.length||!t||I?.status!==`available`||T)){E(!0),O(null);try{let i=await Mx({files:r,snapshot:t,messageRequestId:C,existing:g,allowed:L,locale:n,stage:t=>x_(e.sessionRef,t)});_(i.attachments),O(i.status)}catch{O($(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{E(!1)}}},ne=async r=>{if(!(!t||f||T)){E(!0),O(null);try{let i=await Nx({snapshot:t,messageRequestId:C,attachmentRef:r,locale:n,stage:t=>x_(e.sessionRef,t)});i.discarded?_(e=>e.filter(e=>e.attachmentRef!==r)):O(i.status)}catch{O($(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{E(!1)}}};(0,v.useEffect)(()=>{let t=new AbortController;return h(void 0),Wg(e.sessionRef,t.signal).then(h).catch(()=>void 0),()=>t.abort()},[e.sessionRef,e.sessionRevision]);let z=async()=>{let e=u.trim();if(!e||f)return;p(!0),A(null);let t=g.map(e=>e.attachmentRef);try{await o(e,t.length>0||y!==`continue`?{messageRequestId:C,attachmentRefs:t,attachments:g,...y===`continue`?{}:{workflow:y}}:void 0),d(``),b(`continue`),_([]),O(null),w(`message-request.${crypto.randomUUID()}`)}catch{A($(n,`Chưa xác nhận gửi được. Nội dung và file vẫn được giữ; hãy kiểm tra trạng thái session trước khi gửi lại.`,`Send was not confirmed. Your message and files are preserved; check the session state before sending again.`))}finally{p(!1)}},B=async t=>{if(t){h(t);return}h(await Wg(e.sessionRef).catch(()=>m))},V=async()=>{if(!j){M(!0);try{await c()}catch{}finally{M(!1)}}},re=r?.runtimeRecovery??(e.state===`recovery-required`?`required`:null);return(0,W.jsxs)(X,{sx:{minHeight:`calc(100vh - 68px)`,display:`flex`,flexDirection:`column`},children:[(0,W.jsx)(X,{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:(0,W.jsx)(X,{sx:{width:`100%`},children:(0,W.jsx)(eT,{sessionRef:e.sessionRef,sessionRevision:e.sessionRevision,live:r,approvals:t?.approvals,locale:n,onOpenActivity:()=>l(`activity`)})})}),(0,W.jsxs)(X,{sx:{position:`sticky`,bottom:0,px:{xs:1.5,sm:2.5},pb:2.5,background:`linear-gradient(transparent, var(--piagent-palette-background-default) 25%)`},children:[re&&(0,W.jsx)(AS,{severity:re===`recovered`?`success`:re===`failed`?`error`:`warning`,action:(re===`failed`||re===`required`)&&a&&e.liveState!==`running`?(0,W.jsx)(HS,{color:`inherit`,size:`small`,disabled:j,onClick:()=>void V(),children:j?$(n,`Đang khởi động…`,`Restarting…`):$(n,`Khởi động lại phiên`,`Restart session`)}):void 0,sx:{maxWidth:860,mx:`auto`,mb:1},children:re===`recovered`?$(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.`):re===`failed`?$(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.`):re===`restarting`?$(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.`):$(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,W.jsxs)(X,{sx:{position:`relative`,maxWidth:860,mx:`auto`,border:1,borderColor:N?`primary.main`:`divider`,borderStyle:N?`dashed`:`solid`,borderRadius:3,bgcolor:`background.paper`,p:1.15,boxShadow:`0 14px 44px rgba(0,0,0,.14)`},onDragEnter:e=>{jx(e.dataTransfer)&&(F.current+=1,P(!0))},onDragOver:e=>{jx(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=ee?`copy`:`none`)},onDragLeave:e=>{jx(e.dataTransfer)&&(--F.current,F.current<=0&&(F.current=0,P(!1)))},onDrop:e=>{jx(e.dataTransfer)&&(e.preventDefault(),F.current=0,P(!1),ee&&te(e.dataTransfer.files))},children:[N&&(0,W.jsxs)(X,{role:`status`,sx:{position:`absolute`,inset:0,zIndex:3,display:`grid`,alignContent:`center`,justifyItems:`center`,gap:.5,borderRadius:3,bgcolor:`background.paper`,opacity:.96,pointerEvents:`none`,textAlign:`center`},children:[(0,W.jsx)(Z,{sx:{fontWeight:750},children:ee?$(n,`Thả tài liệu vào đây`,`Drop documents here`):g.length>=4?$(n,`Đã đủ 4 file cho tin nhắn này`,`This message already holds 4 files`):$(n,`Chưa nhận file lúc này`,`Files cannot be attached right now`)}),ee&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,children:$(n,`.md .txt .csv .json .yaml .docx .pdf và ảnh`,`.md .txt .csv .json .yaml .docx .pdf and images`)})]}),g.length>0&&(0,W.jsx)(Cf,{direction:`row`,sx:{flexWrap:`wrap`,gap:.75,px:.5,pb:.75},"aria-label":$(n,`File sẽ gửi cùng tin nhắn`,`Files to send with the message`),children:g.map(e=>(0,W.jsx)(cu,{size:`small`,variant:`outlined`,color:e.kind===`document`?`success`:`default`,label:`${e.displayName} · ${kx(e,n)}`,onDelete:f||T?void 0:()=>void ne(e.attachmentRef),deleteIcon:(0,W.jsx)(lS,{"aria-label":`${$(n,`Bỏ`,`Remove`)} ${e.displayName}`,role:`button`})},e.attachmentRef))}),(0,W.jsx)(Lb,{fullWidth:!0,multiline:!0,minRows:2,disabled:!i||f,value:u,onChange:e=>{d(e.target.value),A(null)},onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),z())},onPaste:e=>{e.clipboardData?.files.length&&(e.preventDefault(),ee&&te(e.clipboardData.files))},placeholder:$(n,`Nhắn cho Piagent…`,`Message Piagent…`),variant:`standard`,slotProps:{input:{disableUnderline:!0}}}),(0,W.jsx)(YS,{in:x,id:`piagent-message-options`,children:(0,W.jsxs)(X,{sx:{mt:.65,p:.85,borderRadius:2,bgcolor:`action.hover`},children:[(0,W.jsx)(Tw,{session:e,snapshot:t,connections:m,locale:n,onOpenChanges:()=>l(`source`),onConnectionsChanged:B}),(0,W.jsxs)(Cf,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:.75,flexWrap:`wrap`},children:[(0,W.jsxs)(Mb,{size:`small`,value:y,disabled:!i||f,onChange:e=>b(e.target.value),"aria-label":$(n,`Workflow cho tin nhắn này`,`Workflow for this message`),startAdornment:(0,W.jsx)(oS,{sx:{mr:.75,fontSize:18}}),sx:{minWidth:{xs:150,sm:190},height:34,fontSize:12.5},children:[(0,W.jsx)(sC,{value:`continue`,children:$(n,`Tự do · không workflow`,`Freeform · no workflow`)}),(0,W.jsx)(sC,{value:`task`,children:`Task`}),(0,W.jsx)(sC,{value:`scout`,children:`Scout`}),(0,W.jsx)(sC,{value:`be-to-fe`,children:`BE → FE`}),(0,W.jsx)(sC,{value:`discuss`,children:`Discuss`}),(0,W.jsx)(sC,{value:`plan`,children:`Plan`}),(0,W.jsx)(sC,{value:`review`,children:`Review`}),(0,W.jsx)(sC,{value:`commit`,children:`Commit`}),(0,W.jsx)(sC,{value:`pr`,children:`PR`}),(0,W.jsx)(sC,{value:`onboard`,children:`Onboard`}),(0,W.jsx)(sC,{value:`platform-improve`,children:`Platform improve`})]}),I?.status===`available`&&(0,W.jsx)(Ah,{title:$(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,W.jsxs)(HS,{component:`label`,size:`small`,color:`inherit`,startIcon:(0,W.jsx)(sS,{}),disabled:!ee,"aria-label":`${$(n,`Đính kèm`,`Attach`)} (${g.length}/4)`,children:[$(n,`Đính kèm`,`Attach`),(0,W.jsx)(`input`,{type:`file`,multiple:!0,hidden:!0,disabled:!ee,accept:R||void 0,onChange:e=>{te(e.target.files),e.currentTarget.value=``}})]})})]}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{display:`block`,mt:.65},children:$(n,`Workflow chỉ áp dụng cho tin nhắn này và tự trở về Tự do sau khi gửi. Anh có thể đổi sang việc khác ngay trong cùng session.`,`A workflow applies only to this message and resets to Freeform after send. You can switch to different work in the same session.`)})]})}),(0,W.jsxs)(Cf,{direction:`row`,sx:{justifyContent:`space-between`,alignItems:`center`,mt:.5,gap:1},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{minWidth:0,alignItems:`center`,gap:1},children:[(0,W.jsx)(Ah,{title:x?$(n,`Ẩn tùy chọn`,`Hide options`):$(n,`Workflow, file và công cụ`,`Workflow, files and tools`),children:(0,W.jsx)(Zd,{size:`small`,"aria-label":x?$(n,`Ẩn tùy chọn`,`Hide options`):$(n,`Thêm tùy chọn`,`More options`),"aria-expanded":x,"aria-controls":`piagent-message-options`,onClick:()=>S(e=>!e),sx:{bgcolor:x?`action.selected`:`transparent`},children:(0,W.jsx)(aS,{fontSize:`small`,sx:{transition:`transform .16s ease`,transform:x?`rotate(45deg)`:`none`}})})}),y!==`continue`&&(0,W.jsx)(cu,{size:`small`,variant:`outlined`,icon:(0,W.jsx)(oS,{}),label:`${y.toUpperCase()} · ${$(n,`tin nhắn này`,`this message`)}`}),(0,W.jsx)(Z,{variant:`caption`,color:D||k?`error`:`text.disabled`,noWrap:!k,sx:{display:{xs:D||k||T?`block`:`none`,sm:`block`}},children:k??D??(T?$(n,`Đang đọc tài liệu…`,`Reading documents…`):r&&!r.complete?$(n,`Piagent đang xử lý; anh có thể gửi việc tiếp theo khi hoàn tất.`,`Piagent is working; you can send the next task when it finishes.`):i?$(n,`Enter để gửi · Shift+Enter xuống dòng`,`Enter to send · Shift+Enter for a new line`):$(n,`Session hiện chỉ đọc`,`Session is currently read only`))})]}),r?.operationRef&&!r.complete&&r.abortable!==!1?(0,W.jsx)(HS,{color:`error`,startIcon:(0,W.jsx)(gS,{}),onClick:()=>void s(),children:$(n,`Dừng`,`Stop`)}):(0,W.jsx)(Zd,{"aria-label":$(n,`Gửi`,`Send`),disabled:!i||f||!u.trim(),color:`primary`,onClick:()=>void z(),sx:{bgcolor:`primary.main`,color:`primary.contrastText`,"&:hover":{bgcolor:`primary.dark`},"&.Mui-disabled":{bgcolor:`action.disabledBackground`}},children:(0,W.jsx)(mS,{fontSize:`small`})})]})]})]})]})}function NT({locale:e,canCreate:t,onNew:n}){return(0,W.jsxs)(Cf,{sx:{minHeight:`calc(100vh - 68px)`,alignItems:`center`,justifyContent:`center`,px:3,textAlign:`center`},spacing:1.5,children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,sx:{width:50,height:50,fontSize:25},children:`π`}),(0,W.jsx)(Z,{variant:`h1`,children:$(e,`Bắt đầu với Piagent`,`Start with Piagent`)}),(0,W.jsx)(Z,{color:`text.secondary`,sx:{maxWidth:520},children:$(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,W.jsx)(HS,{disabled:!t,variant:`contained`,startIcon:(0,W.jsx)(aS,{}),onClick:n,children:$(e,`Cuộc trò chuyện mới`,`New chat`)})]})}function PT({catalog:e,capabilities:t,connection:n,live:r,terminalActivities:i,refresh:a,create:o,send:s,abort:c,restart:l,setModel:u,setThinking:d,setPermission:f,rename:p,pin:m,archive:h,unarchive:g,fork:_}){let{locale:y}=xv(),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(),[w,T]=(0,v.useState)(!1),[E,D]=(0,v.useState)(!1),[O,k]=(0,v.useState)(`chat`),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(`general`),[P,F]=(0,v.useState)(!1),[I,L]=(0,v.useState)(`task`),[R,ee]=(0,v.useState)(),[te,ne]=(0,v.useState)(`idle`),[z,B]=(0,v.useState)(!1),[V,re]=(0,v.useState)(null),[ie,ae]=(0,v.useState)(null),[oe,se]=(0,v.useState)(``),[H,ce]=(0,v.useState)(!1),[le,ue]=(0,v.useState)(null),[de,fe]=(0,v.useState)(null);(0,v.useEffect)(()=>{window.scrollTo(0,0),document.documentElement.scrollTop=0,document.body.scrollTop=0},[O,S]);let pe=(0,v.useMemo)(()=>(e?.sessions??[]).filter(e=>e.archived===E&&`${e.title} ${e.projectLabel} ${e.preview}`.toLowerCase().includes(b.trim().toLowerCase())),[e,b,E]),me=(0,v.useMemo)(()=>{let e=new Map;for(let t of pe){let n=e.get(t.projectRef)??{label:t.projectLabel,sessions:[]};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??``))},[pe]),he=e?.sessions.filter(e=>e.archived).length??0;(0,v.useEffect)(()=>{(!S||!(e?.sessions??[]).some(e=>e.sessionRef===S))&&C((e?.sessions??[]).find(e=>!e.archived)?.sessionRef)},[S,e]);let U=(e?.sessions??[]).find(e=>e.sessionRef===S),ge=U?r[U.sessionRef]:void 0,_e=e=>{C(e),k(`chat`),T(!1)},ve=e=>{N(e),j(!0)},ye=e=>{L(e),F(!0)},be=async()=>{if(U){ne(`loading`);try{let e=await Pg(U.sessionRef);return ee(e),ne(`ready`),e}catch{ne(`error`);return}}};(0,v.useEffect)(()=>{if(!U){ee(void 0),ne(`idle`);return}let e=new AbortController;return ee(void 0),ne(`loading`),Pg(U.sessionRef,e.signal).then(t=>{e.signal.aborted||(ee(t),ne(`ready`))}).catch(()=>{e.signal.aborted||ne(`error`)}),()=>e.abort()},[U?.sessionRef,U?.sessionRevision]),(0,v.useEffect)(()=>{if(!P||I!==`activity`||!U||!ge?.operationRef||ge.complete)return;let e=!1,t,n=new AbortController,r=async()=>{try{let t=await Pg(U.sessionRef,n.signal);e||(ee(t),ne(`ready`))}catch{}e||(t=window.setTimeout(()=>void r(),2e3))};return t=window.setTimeout(()=>void r(),2e3),()=>{e=!0,t!==void 0&&window.clearTimeout(t),n.abort()}},[P,I,U?.sessionRef,ge?.operationRef,ge?.complete]);let xe=n===`connected`&&t?.capabilities.sessionActions.create.status===`available`,Se=async e=>{B(!0),re(null);let t=null;try{let n=`message-request.${crypto.randomUUID()}`,r=e.files.length>0,i=await o({projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,permissionMode:e.permissionMode,message:e.message,messageRequestId:n,deferInitialMessage:r});if(t=i.sessionRef,!t)throw Error(`session-create-result-invalid`);if(i.phase!==`settled`){C(t),k(`chat`),fe({title:$(y,`Session đã được tạo`,`The session was created`),message:$(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 Pg(t),o=i.capabilities.capabilities.attachments;if(o.status!==`available`)throw Error(o.reason?.code??`session-attachment-unavailable`);let c=await Mx({files:e.files,snapshot:i,messageRequestId:n,existing:[],allowed:new Set(o.mimeTypes),locale:y,stage:e=>x_(t,e)});if(c.status||c.attachments.length!==e.files.length)throw await Promise.all(c.attachments.map(async e=>{try{await Nx({snapshot:i,messageRequestId:n,attachmentRef:e.attachmentRef,locale:y,stage:e=>x_(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})}C(t),k(`chat`)}catch(e){let n=e instanceof Error?e.message:`session-create-failed`;t?(C(t),k(`chat`),fe({title:$(y,`Session đã tạo nhưng file chưa được gửi`,`The session was created, but the files were not sent`),message:n})):re(n)}finally{B(!1)}},Ce=(e,t)=>{if(t===`pin`){m(e,!e.pinned).catch(e=>fe({title:$(y,`Không thể đổi trạng thái ghim`,`Could not change pin state`),message:e instanceof Error?e.message:`session-pin-failed`}));return}if(t===`unarchive`){g(e).then(()=>D(!1)).catch(e=>fe({title:$(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}ue(null),se(t===`rename`?e.title:t===`fork`?`${e.title} · ${$(y,`nhánh`,`fork`)}`:``),ae({kind:t,session:e})},we=async()=>{if(!(!ie||H)){ce(!0),ue(null);try{if(ie.kind===`rename`)await p(ie.session,oe.trim());else if(ie.kind===`archive`)await h(ie.session);else{let e=await _(ie.session,oe.trim()||null);e.sessionRef&&(C(e.sessionRef),k(`chat`))}ae(null)}catch(e){ue(e instanceof Error?e.message:`session-action-failed`)}finally{ce(!1)}}},Te=(0,W.jsxs)(X,{sx:{height:`100%`,display:`flex`,flexDirection:`column`,bgcolor:`background.paper`},children:[(0,W.jsxs)(up,{sx:{minHeight:`68px !important`,px:`16px !important`,gap:1.1},children:[(0,W.jsx)(X,{className:`brand-mark`,"aria-hidden":`true`,children:`π`}),(0,W.jsxs)(X,{sx:{minWidth:0},children:[(0,W.jsx)(Z,{sx:{fontWeight:600},children:`Piagent`}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:`Local agent workspace`})]})]}),(0,W.jsxs)(X,{sx:{px:1.25},children:[(0,W.jsx)(Ah,{title:xe?$(y,`Tạo session mới`,`Create a new session`):$(y,`Gateway hiện chưa cho phép tạo session`,`The Gateway cannot create sessions right now`),children:(0,W.jsx)(`span`,{children:(0,W.jsx)(HS,{fullWidth:!0,disabled:!xe,variant:`outlined`,onClick:()=>{re(null),k(`new`),T(!1)},startIcon:(0,W.jsx)(aS,{}),sx:{justifyContent:`flex-start`,py:1},children:$(y,`Cuộc trò chuyện mới`,`New chat`)})})}),(0,W.jsx)(Lb,{value:b,onChange:e=>x(e.target.value),fullWidth:!0,size:`small`,placeholder:$(y,`Tìm cuộc trò chuyện`,`Search chats`),sx:{mt:1.1},slotProps:{input:{startAdornment:(0,W.jsx)(zv,{position:`start`,children:(0,W.jsx)(Rb,{fontSize:`small`})})}}})]}),(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,justifyContent:`space-between`,px:2,pt:2,pb:.4},children:[(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,sx:{fontWeight:600,textTransform:`uppercase`,letterSpacing:`.08em`},children:E?$(y,`Đã lưu trữ`,`Archived`):$(y,`Cuộc trò chuyện`,`Chats`)}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:pe.length})]}),(0,W.jsxs)(nf,{component:`div`,sx:{flex:1,minHeight:0,overflowY:`auto`,py:.25},children:[me.map(e=>(0,W.jsxs)(X,{sx:{mt:.75},children:[(0,W.jsxs)(Cf,{direction:`row`,sx:{alignItems:`center`,gap:.7,px:2,py:.55},children:[(0,W.jsx)(dS,{sx:{fontSize:15,color:`text.disabled`}}),(0,W.jsx)(Z,{component:`div`,variant:`caption`,color:`text.disabled`,noWrap:!0,sx:{flex:1,fontWeight:600},children:e.label}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:e.sessions.length})]}),e.sessions.map(e=>(0,W.jsx)(AT,{session:e,selected:O===`chat`&&U?.sessionRef===e.sessionRef,locale:y,onSelect:()=>_e(e.sessionRef),onAction:t=>Ce(e,t)},e.sessionRef))]},e.projectRef)),pe.length===0&&(0,W.jsxs)(Cf,{sx:{alignItems:`center`,textAlign:`center`,px:3,py:5},spacing:1,children:[(0,W.jsx)(uS,{color:`disabled`}),(0,W.jsx)(Z,{variant:`body2`,color:`text.secondary`,children:$(y,`Không tìm thấy cuộc trò chuyện`,`No conversations found`)})]})]}),(0,W.jsxs)(X,{sx:{p:1.25},children:[(0,W.jsx)(Eu,{sx:{mb:1}}),(0,W.jsx)(HS,{fullWidth:!0,startIcon:(0,W.jsx)(cS,{}),disabled:!E&&he===0,onClick:()=>{D(e=>!e),T(!1)},sx:{justifyContent:`flex-start`},children:E?$(y,`Quay lại cuộc trò chuyện`,`Back to chats`):$(y,`Đã lưu trữ (${he})`,`Archived (${he})`)}),(0,W.jsx)(HS,{fullWidth:!0,startIcon:(0,W.jsx)(hS,{}),onClick:()=>{ve(`general`),T(!1)},sx:{justifyContent:`flex-start`,mt:.25},color:A?`primary`:`inherit`,children:$(y,`Cài đặt`,`Settings`)}),(0,W.jsxs)(Cf,{direction:`row`,sx:{px:1.25,pt:1,alignItems:`center`,gap:1},children:[(0,W.jsx)(X,{sx:{width:7,height:7,borderRadius:`50%`,bgcolor:n===`connected`?`success.main`:`warning.main`}}),(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,sx:{flex:1},children:n===`connected`?`Gateway live`:n}),(0,W.jsx)(Z,{variant:`caption`,color:`text.disabled`,children:`local`})]})]})]});if(!e&&n!==`failed`)return(0,W.jsxs)(Cf,{sx:{minHeight:`100vh`,alignItems:`center`,justifyContent:`center`},spacing:2,children:[(0,W.jsx)(bu,{size:24}),(0,W.jsx)(Z,{children:$(y,`Đang mở Piagent…`,`Opening Piagent…`)})]});let Ee=O===`new`?$(y,`Cuộc trò chuyện mới`,`New chat`):U?.title??`Piagent`;return(0,W.jsxs)(X,{sx:{minHeight:`100vh`,bgcolor:`background.default`},children:[(0,W.jsx)(Lc,{position:`fixed`,color:`transparent`,elevation:0,sx:{left:{md:`${ET}px`},right:{xl:P?DT: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,W.jsxs)(up,{sx:{minHeight:`68px !important`,gap:1},children:[(0,W.jsx)(Zd,{"aria-label":$(y,`Mở điều hướng`,`Open navigation`),onClick:()=>T(!0),sx:{display:{md:`none`}},children:(0,W.jsx)(Rh,{})}),(0,W.jsxs)(X,{sx:{flex:1,minWidth:0},children:[(0,W.jsx)(Z,{component:`h1`,noWrap:!0,sx:{fontWeight:600,fontSize:`inherit`},children:Ee}),O===`chat`&&U&&(0,W.jsx)(Z,{variant:`caption`,color:`text.secondary`,noWrap:!0,children:U.projectLabel})]}),O===`chat`&&U&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Tw,{placement:`header`,session:U,snapshot:R,locale:y,onOpenChanges:()=>ye(`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(U,e),onSetThinking:e=>d(U,e),onSetPermission:e=>f(U,e)}),(0,W.jsx)(jT,{session:U,locale:y}),(0,W.jsx)(Ah,{title:`Source Changes`,children:(0,W.jsx)(Zd,{"aria-label":$(y,`Mở Source Changes Inspector`,`Open Source Changes Inspector`),onClick:()=>ye(`source`),children:(0,W.jsx)(Ph,{fontSize:`small`})})})]}),(0,W.jsx)(Ah,{title:$(y,`Làm mới`,`Refresh`),children:(0,W.jsx)(Zd,{"aria-label":$(y,`Làm mới`,`Refresh`),onClick:()=>void a(),children:(0,W.jsx)(pS,{fontSize:`small`})})})]})}),(0,W.jsxs)(X,{component:`nav`,sx:{width:{md:ET}},children:[(0,W.jsx)(Gd,{variant:`temporary`,open:w,onClose:()=>T(!1),sx:{display:{xs:`block`,md:`none`},"& .MuiDrawer-paper":{width:ET}},children:Te}),(0,W.jsx)(Gd,{variant:`permanent`,sx:{display:{xs:`none`,md:`block`},"& .MuiDrawer-paper":{width:ET,borderRight:1,borderColor:`divider`}},children:Te})]}),(0,W.jsx)(X,{component:`main`,sx:{ml:{md:`${ET}px`},mr:{xl:P?DT:0},pt:`68px`,transition:`margin-right .2s ease`},children:O===`new`?(0,W.jsx)(KC,{active:!0,defaultProjectRef:U?.projectRef,busy:z,error:V,onCancel:()=>k(`chat`),onCreate:e=>{Se(e)}}):U?(0,W.jsx)(MT,{session:U,snapshot:R,locale:y,live:r[U.sessionRef],canSend:n===`connected`&&U.composerAvailable&&t?.capabilities.sessionActions.send.status===`available`&&(!ge||ge.complete)&&![`required`,`restarting`,`failed`].includes(String(r[U.sessionRef]?.runtimeRecovery)),canRestart:n===`connected`&&t?.capabilities.sessionActions.release.status===`available`&&t?.capabilities.sessionActions.acquire.status===`available`,send:(e,t)=>s(U,e,t),abort:()=>c(U),restart:()=>l(U),onInspector:ye}):(0,W.jsx)(NT,{locale:y,canCreate:xe,onNew:()=>k(`new`)})}),(0,W.jsx)(Aw,{open:P,active:I,snapshot:R,state:te,sessionRef:U?.sessionRef,terminalActivities:U?i[U.sessionRef]:void 0,liveActivities:ge&&!ge.complete?ge.activities:void 0,onClose:()=>F(!1),onActive:L,refresh:be}),(0,W.jsx)(rC,{open:A,onClose:()=>j(!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,W.jsx)(TT,{section:M,onSection:N,onBack:()=>j(!1),session:U,snapshot:R,capabilities:t,connection:n,onSetModel:U?e=>u(U,e):void 0,onSetThinking:U?e=>d(U,e):void 0,onSetPermission:U?e=>f(U,e):void 0,onRuntimeChanged:async()=>{await a(),await be()}})}),(0,W.jsx)(rC,{open:!!ie,onClose:()=>!H&&ae(null),fullWidth:!0,maxWidth:`xs`,children:(0,W.jsxs)(Cf,{spacing:2,sx:{p:3},children:[(0,W.jsx)(Z,{variant:`h2`,children:ie?.kind===`rename`?$(y,`Đổi tên cuộc trò chuyện`,`Rename chat`):ie?.kind===`fork`?$(y,`Tạo nhánh cuộc trò chuyện`,`Fork chat`):$(y,`Lưu trữ cuộc trò chuyện`,`Archive chat`)}),ie?.kind===`archive`?(0,W.jsx)(Z,{color:`text.secondary`,children:$(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,W.jsx)(Lb,{autoFocus:!0,label:$(y,`Tên`,`Title`),value:oe,onChange:e=>se(e.target.value),slotProps:{htmlInput:{maxLength:500}}}),le&&(0,W.jsx)(Z,{color:`error`,children:le}),(0,W.jsxs)(Cf,{direction:`row`,spacing:1,sx:{justifyContent:`flex-end`},children:[(0,W.jsx)(HS,{disabled:H,onClick:()=>ae(null),children:$(y,`Hủy`,`Cancel`)}),(0,W.jsx)(HS,{variant:`contained`,disabled:H||ie?.kind!==`archive`&&!oe.trim(),onClick:()=>void we(),children:$(y,`Xác nhận`,`Confirm`)})]})]})}),(0,W.jsx)(rC,{open:!!de,onClose:()=>fe(null),fullWidth:!0,maxWidth:`xs`,"aria-labelledby":`piagent-session-notice-title`,children:(0,W.jsxs)(Cf,{spacing:2,sx:{p:3},children:[(0,W.jsx)(Z,{id:`piagent-session-notice-title`,variant:`h2`,children:de?.title}),(0,W.jsx)(Z,{color:`text.secondary`,children:de?.message}),(0,W.jsx)(Cf,{direction:`row`,sx:{justifyContent:`flex-end`},children:(0,W.jsx)(HS,{variant:`contained`,onClick:()=>fe(null),children:$(y,`Đóng`,`Close`)})})]})})]})}function FT(e){let t=e===`dark`,n=t?`#d8ff7a`:`#627400`,r=t?`#8be9c8`:`#14775f`;return Bo({cssVariables:{cssVarPrefix:`piagent`},palette:{mode:e,primary:{main:n,light:t?`#e6ff9f`:`#849a17`,dark:t?`#a7cc45`:`#455400`,contrastText:t?`#111300`:`#ffffff`},secondary:{main:r},success:{main:r},warning:{main:`#efba63`},error:{main:`#ff7f86`},background:{default:t?`#050505`:`#f5f6f0`,paper:t?`#101114`:`#ffffff`},text:{primary:t?`#f4f4ef`:`#1c2018`,secondary:t?`#a4a6ad`:`#62685c`,disabled:t?`#898c95`:`#6b7165`},divider:t?`#24262d`:`#dfe2d8`},shape:{borderRadius:10},typography:{fontFamily:`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`,fontWeightRegular:400,fontWeightMedium:500,fontWeightBold:600,h1:{fontSize:`1.65rem`,fontWeight:600,letterSpacing:`-0.03em`},h2:{fontSize:`1.2rem`,fontWeight:600,letterSpacing:`-0.02em`},h3:{fontSize:`1rem`,fontWeight:600},button:{fontSize:`0.78rem`,fontWeight:500,textTransform:`none`},caption:{fontSize:`0.7rem`}},components:{MuiCssBaseline:{styleOverrides:{html:{backgroundColor:t?`#050505`:`#f5f6f0`},body:{minWidth:320,minHeight:`100vh`,backgroundImage:t?`radial-gradient(circle at 65% -18%, rgba(139,233,200,.12) 0, transparent 34rem)`:`radial-gradient(circle at 65% -18%, rgba(216,255,122,.22) 0, transparent 34rem)`},"::selection":{backgroundColor:xi(n,.26)}}},MuiPaper:{defaultProps:{elevation:0},styleOverrides:{root:{backgroundImage:`none`}}},MuiButton:{defaultProps:{disableElevation:!0},styleOverrides:{root:{minHeight:34,borderRadius:8},outlined:{borderColor:t?`#32343c`:`#cfd4c8`}}},MuiChip:{styleOverrides:{root:{height:26,borderRadius:7,fontWeight:500}}},MuiListItemButton:{styleOverrides:{root:{minHeight:42,margin:`2px 10px`,borderRadius:8,color:t?`#a4a6ad`:`#62685c`,"&.Mui-selected":{color:t?`#f4f4ef`:`#1c2018`,backgroundColor:xi(n,t?.11:.1),boxShadow:`inset 2px 0 ${n}`},"&.Mui-selected:hover":{backgroundColor:xi(n,.15)}}}},MuiTab:{styleOverrides:{root:{minHeight:48,paddingInline:18,textTransform:`none`,fontWeight:500}}},MuiTooltip:{defaultProps:{arrow:!0}}}})}function IT(e){for(let t of e??[]){let e=String(t).toLowerCase().split(`-`)[0];if(e===`vi`)return`vi`;if(e)return`en`}return`en`}function LT(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(`connecting`),[i,a]=(0,v.useState)([]),o=(0,v.useCallback)(async()=>{try{let e=await xg();return t(e),r(`connected`),e}catch{r(`reconnecting`);return}},[]);return(0,v.useEffect)(()=>{let e=new AbortController,n,i,o=!1,s=async(n=!0)=>{try{let i=await xg(e.signal);return o||(t(i),n&&r(`connected`)),i}catch{!o&&!e.signal.aborted&&r(`reconnecting`);return}},c=()=>{window.clearTimeout(i),i=window.setTimeout(()=>{s()},80)},l=e=>{n?.close();let t=e?`?after=${encodeURIComponent(e)}`:``;n=new EventSource(`/api/v1/events${t}`,{withCredentials:!0}),n.onopen=()=>{o||r(`connected`)},n.addEventListener(`runtime-event`,e=>{try{let t=JSON.parse(e.data);t&&typeof t.kind==`string`&&a(e=>[...e,t].slice(-500)),[`message.text-delta`,`message.thinking-state`,`activity.progress`].includes(String(t.kind))||c()}catch{}}),n.addEventListener(`resync-required`,()=>{(async()=>{n?.close(),a([]),o||r(`reconnecting`);let e=await s(!1);e&&!o&&l(e.revision.eventCursor)})()}),n.onerror=()=>{o||r(`reconnecting`)}};return(async()=>{let e=await yg();if(o)return;if(e===`failed`){r(`failed`);return}let t=await s();if(!t||o){r(`failed`);return}l(t.revision.eventCursor)})(),()=>{o=!0,e.abort(),n?.close(),window.clearTimeout(i)}},[]),{snapshot:e,connection:n,events:i,refreshSnapshot:o}}var RT=`piagent-gateway-event-cursor-v1`,zT=3e4,BT=4001;function VT(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 HT(e){return`${e}_${crypto.randomUUID().replaceAll(`-`,``)}`}function UT(e){return e.phase===`rejected`&&e.resultCode===`stale-revision`&&e.error?.code===`session-revision-stale`}function WT(){let[e,t]=(0,v.useState)(),[n,r]=(0,v.useState)(),[i,a]=(0,v.useState)(`connecting`),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)({}),u=(0,v.useRef)(void 0),d=(0,v.useRef)(null),f=(0,v.useRef)(null),p=(0,v.useRef)(null),m=(0,v.useRef)(!0),h=(0,v.useRef)(0),g=(0,v.useRef)(0),_=(0,v.useRef)(new Map),y=(0,v.useCallback)((e,t)=>{if(t!==null)try{window.sessionStorage.setItem(RT,JSON.stringify({gatewayInstanceRef:e,sequence:t}))}catch{}},[]),b=(0,v.useCallback)(async(e={})=>{let n=++h.current;try{let[r,i]=await Promise.all([Sg(),Cg().catch(()=>void 0)]),o=Pw(i,r.gatewayInstanceRef),c=!1;if(n>=g.current){g.current=n,u.current=r,t(r);let h=p.current;h!==null&&h!==r.gatewayInstanceRef&&(m.current=!0),p.current=r.gatewayInstanceRef;let _=e.requireLiveState||m.current,v=d.current?.readyState===WebSocket.OPEN;if(a(Fw(v,_)),!v&&i&&o!==null)f.current=o,y(r.gatewayInstanceRef,o),s(e=>Gw(e,i)),l(Uw(i)),m.current=!1,c=!0;else if(h!==r.gatewayInstanceRef){if(l({}),_)f.current=null;else{let e=null;try{e=window.sessionStorage.getItem(RT)}catch{}f.current=VT(e,r.gatewayInstanceRef)}}}return e.requireLiveState&&!c?void 0:u.current??r}catch{a(`reconnecting`);return}},[y]),x=(0,v.useCallback)(e=>{let t=d.current;if(!t||t.readyState!==WebSocket.OPEN)return Promise.reject(Error(`gateway-not-connected`));let n=HT(`request`);return new Promise((r,i)=>{let a=window.setTimeout(()=>{_.current.delete(n)&&i(Error(`gateway-command-response-timeout`))},zT);_.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),_.current.delete(n),i(e instanceof Error?e:Error(`gateway-request-failed`))}})},[]),S=(0,v.useCallback)(async e=>{let t=u.current,n=e.message.trim(),r=e.messageRequestId??HT(`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 x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:HT(`command`),idempotencyKey:HT(`idempotency`),action:`session.create`,requestedAt:i.toISOString(),expiresAt:new Date(i.getTime()+3e5).toISOString(),sessionRef:null,expectedCatalogRevision:t.catalogRevision,expectedSessionRevision:null,payload:{projectRef:e.projectRef,placeRef:e.placeRef,modelRef:e.modelRef,thinkingLevel:e.thinkingLevel,workflow:e.workflow,message:n,messageRequestId:r,...e.permissionMode?{permissionMode:e.permissionMode}:{},...e.deferInitialMessage?{deferInitialMessage:!0}:{}}})},a=await i(t);if(UT(a)){let e=await b();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,abortable:!t?.complete&&!!a.operationRef,startedAt:t?.startedAt??o,lastEventAt:t?.lastEventAt??o}}}),await b(),a},[b,x]),C=(0,v.useCallback)(async(e,t,n)=>{let r=u.current;if(!r?.catalogRevision)throw Error(`catalog-unavailable`);let i=t.trim();if(!i)throw Error(`message-empty`);let a=n?.messageRequestId??HT(`message`),o=n?.attachmentRefs??[];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 x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:HT(`command`),idempotencyKey:HT(`idempotency`),action:`session.send`,requestedAt:s.toISOString(),expiresAt:new Date(s.getTime()+3e5).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}:{}}})},c=await t(r);if(UT(c)){let e=await b();e?.catalogRevision&&(c=await t(e))}if(c.phase!==`settled`)throw Error(c.error?.code??c.resultCode);let l=c.settledAt??c.requestedAt;return s(t=>{let r=t[e.sessionRef];return{...t,[e.sessionRef]:{...r??{assistant:``,activities:[],complete:!1,error:null},user:i,attachments:n?.attachments??[],operationRef:c.operationRef,abortable:!r?.complete&&!!c.operationRef,startedAt:r?.startedAt??l,lastEventAt:r?.lastEventAt??l}}}),b(),c}catch(e){throw e}},[b,x]),w=(0,v.useCallback)(async e=>{let t=u.current,n=o[e.sessionRef]?.operationRef,r=t?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t?.catalogRevision||!r||!n||o[e.sessionRef]?.abortable===!1)throw Error(`operation-unavailable`);let i=t=>{let r=t.sessions.find(t=>t.sessionRef===e.sessionRef);if(!t.catalogRevision||!r)throw Error(`operation-unavailable`);let i=new Date;return x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:HT(`command`),idempotencyKey:HT(`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(UT(a)){let[t,r]=await Promise.all([b(),Cg().catch(()=>void 0)]);if(!t||!Jw(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 b(),a},[o,b,x]),T=(0,v.useCallback)(async e=>{let t=async t=>{let n=await b(),r=n?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!n?.catalogRevision||!r)throw Error(`session-unavailable`);let i=new Date,a=await x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:HT(`command`),idempotencyKey:HT(`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 b())?.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 b(),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}},[b,x]),E=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:HT(`command`),idempotencyKey:HT(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await b(),o},[b,x]),D=(0,v.useCallback)((e,t)=>E(e,`session.set-model`,{modelRef:t}),[E]),O=(0,v.useCallback)((e,t)=>E(e,`session.set-thinking`,{thinkingLevel:t}),[E]),k=(0,v.useCallback)((e,t)=>E(e,`session.set-permission`,{permissionMode:t}),[E]),A=(0,v.useCallback)(async(e,t,n)=>{let r=u.current,i=r?.sessions.find(t=>t.sessionRef===e.sessionRef);if(!r?.catalogRevision||!i)throw Error(`session-unavailable`);let a=new Date,o=await x({schemaVersion:1,version:`piagent-session-command-v1`,messageType:`command`,commandId:HT(`command`),idempotencyKey:HT(`idempotency`),action:t,requestedAt:a.toISOString(),expiresAt:new Date(a.getTime()+3e5).toISOString(),sessionRef:e.sessionRef,expectedCatalogRevision:r.catalogRevision,expectedSessionRevision:i.sessionRevision,payload:n});if(o.phase!==`settled`)throw Error(o.error?.code??o.resultCode);return await b(),o},[b,x]),j=(0,v.useCallback)((e,t)=>A(e,`session.rename`,{title:t}),[A]),M=(0,v.useCallback)((e,t)=>A(e,`session.pin`,{pinned:t}),[A]),N=(0,v.useCallback)(e=>A(e,`session.archive`,{}),[A]),P=(0,v.useCallback)(e=>A(e,`session.unarchive`,{}),[A]),F=(0,v.useCallback)((e,t)=>A(e,`session.fork`,{entryRef:null,title:t}),[A]);return(0,v.useEffect)(()=>{let e=!1,t,n=0,i=!1,o=(()=>{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=HT(`client`);return window.localStorage.setItem(`piagent-gateway-client-ref`,t),t}catch{return HT(`client`)}})(),c=()=>{if(e)return;a(n===0?`connecting`:`reconnecting`);let g=window.location.protocol===`https:`?`wss:`:`ws:`,v=new WebSocket(`${g}//${window.location.host}/api/v1/gateway`,`piagent.gateway.v1`);d.current=v;let x=window.setTimeout(()=>v.close(1008,`hello-timeout`),5e3);v.addEventListener(`open`,()=>v.send(JSON.stringify({schemaVersion:1,version:`piagent-gateway-protocol-v1`,messageType:`connect`,clientRef:o,minimumProtocol:1,maximumProtocol:1,lastEventSequence:f.current,catalogRevision:u.current?.catalogRevision??null}))),v.addEventListener(`message`,e=>{let t;try{t=JSON.parse(String(e.data))}catch{v.close(1007,`invalid-json`);return}if(!t||typeof t!=`object`){v.close(1008,`invalid-frame`);return}let o=t;if(o.messageType===`hello`){window.clearTimeout(x);let e=typeof o.capabilities?.gatewayInstanceRef==`string`?o.capabilities.gatewayInstanceRef:null;if(!e||p.current&&e!==p.current){f.current=null,m.current=!0,i=!0,v.close(BT,`gateway-epoch-changed`);return}p.current=e,n=0,r(o.capabilities),a(`connected`);return}if(o.messageType===`response`){let e=_.current.get(String(o.requestId));if(!e)return;_.current.delete(String(o.requestId)),window.clearTimeout(e.timeout),o.ok===!0&&o.result?e.resolve(o.result):e.reject(Error(String(o.error?.code??`gateway-request-failed`)));return}if(o.messageType!==`event`||!Number.isSafeInteger(o.sequence))return;let c=o.payload,u=typeof o.generatedAt==`string`?o.generatedAt:new Date().toISOString();if(o.kind===`resync.required`){m.current=!0,i=!0,v.close(BT,`canonical-resync-required`);return}let d=Number(o.sequence),h=f.current;if(!(h!==null&&d<=h)){if(h!==null&&d!==h+1){m.current=!0,i=!0,v.close(BT,`gateway-event-sequence-gap`);return}if(f.current=d,p.current&&y(p.current,d),o.kind===`message.delta`&&typeof c?.sessionRef==`string`&&typeof c.delta==`string`&&s(e=>({...e,[c.sessionRef]:{...e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],complete:!1,error:null},operationRef:c.operationRef,abortable:!0,assistant:`${e[c.sessionRef]?.assistant??``}${c.delta}`,startedAt:e[c.sessionRef]?.startedAt??u,lastEventAt:u}})),[`tool.started`,`tool.completed`].includes(String(o.kind))&&typeof c?.sessionRef==`string`&&typeof c.toolCallRef==`string`&&typeof c.toolLabel==`string`&&s(e=>{let t=e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef??null,abortable:!0,complete:!1,error:null,runtimeRecovery:null},n=o.kind===`tool.started`?`running`:c.isError===!0?`failed`:`completed`,r=t.activities.find(e=>e.toolCallRef===c.toolCallRef),i=[...t.activities.filter(e=>e.toolCallRef!==c.toolCallRef),{toolCallRef:c.toolCallRef,toolLabel:c.toolLabel,state:n,reasonCode:c.reasonCode??null,startedAt:r?.startedAt??u,finishedAt:n===`running`?null:u}].slice(-16),a=c.reasonCode===`runtime-restart-required`?`required`:t.runtimeRecovery;return{...e,[c.sessionRef]:{...t,operationRef:c.operationRef??t.operationRef,activities:i,runtimeRecovery:a,startedAt:t.startedAt??u,lastEventAt:u}}}),o.kind===`runtime.changed`&&typeof c?.sessionRef==`string`&&s(e=>{let t=[`running`,`paused`,`waiting-approval`].includes(String(c.liveState)),n=e[c.sessionRef]??(t&&typeof c.operationRef==`string`?{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef,abortable:!0,complete:!1,settlement:null,error:null,runtimeRecovery:null}:null);if(!n)return e;let r=c.reasonCode===`runtime-restart-required`?`restarting`:c.reasonCode===`runtime-restart-failed`?`failed`:[`required`,`restarting`].includes(String(n.runtimeRecovery))&&c.liveState===`idle`?`recovered`:n.runtimeRecovery;return t?{...e,[c.sessionRef]:{...n,operationRef:c.operationRef??n.operationRef,abortable:!0,complete:!1,settlement:null,runtimeRecovery:r,startedAt:n.startedAt??u,lastEventAt:u}}:!n.complete&&c.operationRef===null?{...e,[c.sessionRef]:{...n,assistant:``,abortable:!1,complete:!0,settlement:`unknown`,error:c.reasonCode??`operation-settlement-unknown`,runtimeRecovery:r,lastEventAt:u}}:r===n.runtimeRecovery?e:{...e,[c.sessionRef]:{...n,runtimeRecovery:r}}}),o.kind===`message.completed`&&typeof c?.sessionRef==`string`&&s(e=>({...e,[c.sessionRef]:{...e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef,error:null},operationRef:c.operationRef,abortable:!1,complete:!0,settlement:`completed`,error:null,lastEventAt:u}})),o.kind===`operation.settled`&&typeof c?.sessionRef==`string`&&typeof c.operationRef==`string`){s(e=>{let t=e[c.sessionRef]??{user:``,assistant:``,attachments:[],activities:[],operationRef:c.operationRef,complete:!1,error:null,runtimeRecovery:null};return t.operationRef&&t.operationRef!==c.operationRef?e:{...e,[c.sessionRef]:{...Ww(t,{operationRef:c.operationRef,settlement:c.settlement,reasonCode:c.reasonCode}),lastEventAt:u}}});let e=Vw({operationRef:c.operationRef,settlement:c.settlement,reasonCode:c.reasonCode,settledAt:o.generatedAt,sequence:d});e&&l(t=>({...t,[c.sessionRef]:Hw(t[c.sessionRef]??[],[e])}))}[`catalog.changed`,`session.changed`,`runtime.changed`,`message.completed`,`operation.settled`].includes(String(o.kind))&&b()}}),v.addEventListener(`close`,()=>{window.clearTimeout(x);for(let e of _.current.values())window.clearTimeout(e.timeout),e.reject(Error(`gateway-connection-lost`));if(_.current.clear(),!e){if(a(`reconnecting`),i){i=!1,h();return}n+=1,t=window.setTimeout(c,Math.min(5e3,250*2**Math.min(n,5)))}}),v.addEventListener(`error`,()=>{})},h=async()=>{if(e)return;let r=await b({requireLiveState:!0});if(!e){if(r){n=0,c();return}a(`reconnecting`),n+=1,t=window.setTimeout(()=>void h(),Math.min(5e3,250*2**Math.min(n,5)))}};(async()=>{let t=await yg();if(!e){if(t===`failed`){a(`failed`);return}await h()}})();let g=()=>{!e&&document.visibilityState===`visible`&&b()};return document.addEventListener(`visibilitychange`,g),()=>{e=!0,t&&window.clearTimeout(t);for(let e of _.current.values())window.clearTimeout(e.timeout),e.reject(Error(`gateway-client-unmounted`));_.current.clear(),d.current?.close(1e3,`client-unmount`),document.removeEventListener(`visibilitychange`,g)}},[y,b]),{catalog:e,capabilities:n,connection:i,live:o,terminalActivities:c,refresh:b,create:S,send:C,abort:w,restart:T,setModel:D,setThinking:O,setPermission:k,rename:j,pin:M,archive:N,unarchive:P,fork:F}}var GT=document.getElementById(`root`);if(!GT)throw Error(`Piagent WebUI root is missing`);var KT=document.querySelector(`meta[name="csp-nonce"]`)?.content,qT=Ue({key:`piagent-mui`,nonce:KT&&!KT.startsWith(`__PIAGENT_`)?KT:void 0,prepend:!0});function JT(){let e=LT();return(0,W.jsx)(iS,{...e})}function YT(){let e=WT();return(0,W.jsx)(PT,{...e})}function XT(e,t,n){try{let r=window.localStorage.getItem(e);return r&&t.includes(r)?r:n}catch{return n}}function ZT(){let[e,t]=(0,v.useState)(()=>XT(`piagent-webui-locale`,[`vi`,`en`],IT(window.navigator?.languages??[window.navigator?.language??``]))),[n,r]=(0,v.useState)(()=>XT(`piagent-webui-color-mode`,[`light`,`dark`],window.matchMedia?.(`(prefers-color-scheme: light)`).matches?`light`:`dark`)),i=(0,v.useMemo)(()=>FT(n),[n]);(0,v.useEffect)(()=>{document.documentElement.lang=e,document.documentElement.dataset.piagentColorMode=n;try{window.localStorage.setItem(`piagent-webui-locale`,e),window.localStorage.setItem(`piagent-webui-color-mode`,n)}catch{}},[n,e]);let a=(0,v.useMemo)(()=>({locale:e,colorMode:n,setLocale:t,setColorMode:r}),[n,e]),o=document.querySelector(`meta[name="piagent-webui-mode"]`)?.content;return(0,W.jsx)(bv,{value:a,children:(0,W.jsxs)(Tc,{theme:i,children:[(0,W.jsx)(ns,{}),o===`gateway`?(0,W.jsx)(YT,{}):(0,W.jsx)(JT,{})]})})}(0,y.createRoot)(GT).render((0,W.jsx)(v.StrictMode,{children:(0,W.jsx)(ht,{value:qT,children:(0,W.jsx)(ZT,{})})}));export{l as S,Sr as _,Mc as a,o as b,_s as c,Uo as d,va as f,G as g,K as h,X as i,Jo as l,Wr as m,Eu as n,Oc as o,xi as p,ll as r,Y as s,Z as t,J as u,pn as v,s as x,d as y};