@lacneu/atrium 0.102.0 → 0.103.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/assets/AccessTab-gaTBs3lV.js +1 -0
  2. package/dist/assets/{AdminSettings-B8n1yLsD.js → AdminSettings-CMjix9zl.js} +1 -1
  3. package/dist/assets/{AdvancedFilter-Bb66m5kb.js → AdvancedFilter-5BMuHHt6.js} +1 -1
  4. package/dist/assets/AgentFilesTab-D3tMMo2R.js +3 -0
  5. package/dist/assets/AnomaliesTab-CdFgsRwT.js +1 -0
  6. package/dist/assets/AuditTab-Yw1LvjgD.js +1 -0
  7. package/dist/assets/BridgeTab-CBE4zTQ1.js +1 -0
  8. package/dist/assets/ChatDefaultsTab-CIX9WUCl.js +1 -0
  9. package/dist/assets/{ConfirmDialog-BXcki0Ee.js → ConfirmDialog-Dy8WCeAF.js} +1 -1
  10. package/dist/assets/{DataTableShell-DRFFBx_j.js → DataTableShell-2_QPZexc.js} +1 -1
  11. package/dist/assets/DeletedChatsTab-Fzk38aqT.js +1 -0
  12. package/dist/assets/{DetailChips-Cv1sxdhU.js → DetailChips-DaliQU_Q.js} +1 -1
  13. package/dist/assets/{EntitySheet-B2B48bss.js → EntitySheet-D-JZB54h.js} +1 -1
  14. package/dist/assets/FeedbacksTab-DWmslsAt.js +1 -0
  15. package/dist/assets/{FieldLabel-Tea3wyVe.js → FieldLabel-D63ry-fi.js} +1 -1
  16. package/dist/assets/FilesTab-DzHfzOnQ.js +1 -0
  17. package/dist/assets/{FilterBar-DTVwlDpF.js → FilterBar-Bynn2H7k.js} +1 -1
  18. package/dist/assets/GroupsTab-hxsjfQDc.js +1 -0
  19. package/dist/assets/InstancesTab-DsJ_BBfc.js +1 -0
  20. package/dist/assets/IntegrationsTab-Cf3lTCzz.js +1 -0
  21. package/dist/assets/KnobRow-3my9jz_H.js +1 -0
  22. package/dist/assets/KpiTab-C6dn6jVl.js +1 -0
  23. package/dist/assets/PreferencesTab-DiDi7mpY.js +1 -0
  24. package/dist/assets/ProjectPage-DDto6xkD.js +1 -0
  25. package/dist/assets/PromptInjectionsTab-D3drsS9C.js +4 -0
  26. package/dist/assets/RolesTab-DDYieLTF.js +1 -0
  27. package/dist/assets/ScheduledTab-D-yTTYHC.js +1 -0
  28. package/dist/assets/ServiceAccountsTab-fJYmH0eU.js +1 -0
  29. package/dist/assets/SubAgentReportsTab-GXHpWbrW.js +1 -0
  30. package/dist/assets/ThemeShowroom-uU3PL_6V.js +1 -0
  31. package/dist/assets/{TimeRangePicker-D3PJq1H8.js → TimeRangePicker-DzJYDik_.js} +1 -1
  32. package/dist/assets/{TimezoneCombobox-CPTpWNQm.js → TimezoneCombobox-BY91kPSf.js} +1 -1
  33. package/dist/assets/TracesTab-C7zX1NUU.js +1 -0
  34. package/dist/assets/TrashTab-BVZJggvr.js +1 -0
  35. package/dist/assets/UsersTab-HdsTBYR0.js +1 -0
  36. package/dist/assets/VoiceTab-CnZ-twTR.js +1 -0
  37. package/dist/assets/{alert-dialog-BoEv1f8g.js → alert-dialog-DRrmbZYC.js} +1 -1
  38. package/dist/assets/{api-DSJJn0d7.js → api-CUskDNHD.js} +5 -5
  39. package/dist/assets/{badge-C4po8DQ1.js → badge-TiMZiv59.js} +1 -1
  40. package/dist/assets/{button-Dio0PVrp.js → button-CbHyzXCb.js} +1 -1
  41. package/dist/assets/capabilities-CASxhKEd.js +1 -0
  42. package/dist/assets/{card-CerX9wDn.js → card-vUc-7TYj.js} +1 -1
  43. package/dist/assets/check-Da8rPJKX.js +1 -0
  44. package/dist/assets/{checkbox-CsI4ggnp.js → checkbox-Czxm5pNj.js} +1 -1
  45. package/dist/assets/chevron-left-DxPC6E1S.js +1 -0
  46. package/dist/assets/chevron-right-BjOti-z8.js +1 -0
  47. package/dist/assets/chevron-up-DfOJb3vW.js +1 -0
  48. package/dist/assets/chevrons-up-down-Bp7zuoEk.js +1 -0
  49. package/dist/assets/{compatView--1YlftIc.js → compatView-Dj1HQXxr.js} +1 -1
  50. package/dist/assets/confTabs-BzReq467.css +1 -0
  51. package/dist/assets/convexApi-BPSJUy2j.js +1 -0
  52. package/dist/assets/{copy-BaUCUMp2.js → copy-C1_4Ewod.js} +1 -1
  53. package/dist/assets/{cronDescribe-CAuRX7uW.js → cronDescribe-BC0AcJer.js} +1 -1
  54. package/dist/assets/{deliveryRecorder-C7NQZrrH.js → deliveryRecorder-CGhwQ1sg.js} +1 -1
  55. package/dist/assets/{dialog-BfrsWZiD.js → dialog-DpoEg_Ex.js} +1 -1
  56. package/dist/assets/dispatchErrorInfo-BOJ5cTZo.js +1 -0
  57. package/dist/assets/{dist-ClkJChBn.js → dist-BmXC8pZv.js} +1 -1
  58. package/dist/assets/{dist-D7doQlva.js → dist-BqsRl4o3.js} +1 -1
  59. package/dist/assets/{dist-D-RIDSJc.js → dist-CHsekWGV.js} +1 -1
  60. package/dist/assets/{dist-Cw3aN_jM.js → dist-Cv-LvOB4.js} +1 -1
  61. package/dist/assets/{dist-CkbybbG7.js → dist-DQawXTf-.js} +1 -1
  62. package/dist/assets/{dist-ChrIV8UV.js → dist-HZSdA3kh.js} +1 -1
  63. package/dist/assets/{download-DWgC7zCa.js → download-Do4pcXOL.js} +1 -1
  64. package/dist/assets/{dropdown-menu-DHMOOlaP.js → dropdown-menu-BWxfj48Z.js} +1 -1
  65. package/dist/assets/{eye-B-ipuYEd.js → eye-yUMVb9gl.js} +1 -1
  66. package/dist/assets/{format-DGKgJf2p.js → format-zM-c-1S6.js} +1 -1
  67. package/dist/assets/{groupManageView-BMBqgRhV.js → groupManageView-DY6vPM1h.js} +1 -1
  68. package/dist/assets/index-B7hQ_j0i.js +158 -0
  69. package/dist/assets/index-D8Eob_Mc.css +1 -0
  70. package/dist/assets/{input-BSpTsBA6.js → input-DCbMcJYs.js} +1 -1
  71. package/dist/assets/{list-eSch39T9.js → list-DIWFv1eJ.js} +1 -1
  72. package/dist/assets/loader-circle-BO0Lx5va.js +1 -0
  73. package/dist/assets/{lock-0lxfSnTE.js → lock-X9ZGk2P9.js} +1 -1
  74. package/dist/assets/{pencil-aUWxuLhy.js → pencil-1kZxxbnV.js} +1 -1
  75. package/dist/assets/plus-CSOLqt7C.js +1 -0
  76. package/dist/assets/{popover-DBaIbsBr.js → popover-DiT_Oo6e.js} +1 -1
  77. package/dist/assets/roleDescriptions-CmJBKAaf.js +1 -0
  78. package/dist/assets/rotate-ccw-C-v_7YX7.js +1 -0
  79. package/dist/assets/{search-BK6bzZNi.js → search-D9Un2NMX.js} +1 -1
  80. package/dist/assets/searchSchemas-Dm-Qg010.js +55 -0
  81. package/dist/assets/{select-qM3ZfTHx.js → select-DCBGpD8v.js} +1 -1
  82. package/dist/assets/{server-DLnWqkX-.js → server-BSDuYUUF.js} +1 -1
  83. package/dist/assets/{speech-CrNma2Ue.js → speech-CfxX6OY3.js} +1 -1
  84. package/dist/assets/{star-CM6J2w_J.js → star-DjK6DoNA.js} +1 -1
  85. package/dist/assets/switch-Dt_I92ZY.js +1 -0
  86. package/dist/assets/{table-D2SJC960.js → table-GXZ7yFCE.js} +1 -1
  87. package/dist/assets/{tabs-mZfLmn2f.js → tabs-dQ50HGoj.js} +1 -1
  88. package/dist/assets/{toast-xNFwDnUy.js → toast-C8rSAMgh.js} +1 -1
  89. package/dist/assets/{tooltip-v_AyOWn6.js → tooltip-D3qNpGhD.js} +1 -1
  90. package/dist/assets/{trash-2-B4WSfc7G.js → trash-2-8oRd823U.js} +1 -1
  91. package/dist/assets/trashPage-CoBMe_r-.js +1 -0
  92. package/dist/assets/{trashView-Ct0Xw-a9.js → trashView-CIgTWQjI.js} +1 -1
  93. package/dist/assets/{triangle-alert-BkDa-x8g.js → triangle-alert-DQoWKyu_.js} +1 -1
  94. package/dist/assets/{usageView-C9Y6E0Zu.js → usageView-B0Wg081i.js} +1 -1
  95. package/dist/assets/{useChart-CKFEN42T.js → useChart-xKc_wRHf.js} +1 -1
  96. package/dist/assets/{useFontScale-ByBFat3y.js → useFontScale-C03nea0B.js} +1 -1
  97. package/dist/assets/{useStartNewChat-BszDHUjD.js → useStartNewChat-B66bn5hT.js} +2 -2
  98. package/dist/assets/{use_paginated_query-CQj09xXv.js → use_paginated_query-BatXdmTn.js} +1 -1
  99. package/dist/assets/{users-BJqaWlH1.js → users-DHMAZ7v8.js} +1 -1
  100. package/dist/assets/x-6-84PEVq.js +1 -0
  101. package/dist/index.html +57 -57
  102. package/package.json +2 -2
  103. package/dist/assets/AccessTab-JmFp20Kp.js +0 -1
  104. package/dist/assets/AgentFilesTab-C3CUT4Ep.js +0 -3
  105. package/dist/assets/AnomaliesTab-BQ2Bu98W.js +0 -1
  106. package/dist/assets/AuditTab-BV-XydO_.js +0 -1
  107. package/dist/assets/BridgeTab-D4RFq-Rb.js +0 -1
  108. package/dist/assets/ChatDefaultsTab-D0d9yEow.js +0 -1
  109. package/dist/assets/DeletedChatsTab-COYSFkNf.js +0 -1
  110. package/dist/assets/FeedbacksTab-6URuFdfg.js +0 -1
  111. package/dist/assets/FilesTab-esMtHJXt.js +0 -1
  112. package/dist/assets/GroupsTab-Io16XZHz.js +0 -1
  113. package/dist/assets/InstancesTab-BevtM68H.js +0 -1
  114. package/dist/assets/IntegrationsTab-DMY6VTUC.js +0 -1
  115. package/dist/assets/KnobRow-BsOT2O6U.js +0 -1
  116. package/dist/assets/KpiTab-KPPcgUxA.js +0 -1
  117. package/dist/assets/PreferencesTab-DJ9p401L.js +0 -1
  118. package/dist/assets/ProjectPage-BxEF71jN.js +0 -1
  119. package/dist/assets/PromptInjectionsTab-Vdb1lF36.js +0 -4
  120. package/dist/assets/RolesTab-DU0g4d-R.js +0 -1
  121. package/dist/assets/ScheduledTab-B6gWc0HN.js +0 -1
  122. package/dist/assets/ServiceAccountsTab-Dmb_LH0V.js +0 -1
  123. package/dist/assets/SubAgentReportsTab-D9rclslo.js +0 -1
  124. package/dist/assets/ThemeShowroom-N4qzUtlq.js +0 -1
  125. package/dist/assets/TracesTab-DiAkOmei.js +0 -1
  126. package/dist/assets/TrashTab-BMSJ7ANC.js +0 -1
  127. package/dist/assets/UsersTab-BQaLsUCK.js +0 -1
  128. package/dist/assets/VoiceTab-BSh-05Ze.js +0 -1
  129. package/dist/assets/capabilities-BTqhMVxR.js +0 -1
  130. package/dist/assets/check-DmQzfrws.js +0 -1
  131. package/dist/assets/chevron-left-DQ9FCoo_.js +0 -1
  132. package/dist/assets/chevron-right-C_b_y922.js +0 -1
  133. package/dist/assets/chevron-up-Dsqj2Oaj.js +0 -1
  134. package/dist/assets/chevrons-up-down-Pva00Np5.js +0 -1
  135. package/dist/assets/confTabs-CCBW5ofF.css +0 -1
  136. package/dist/assets/convexApi-CyScjgcq.js +0 -1
  137. package/dist/assets/dispatchErrorInfo-Bb7JyJFO.js +0 -1
  138. package/dist/assets/index-D6RuTaB7.css +0 -1
  139. package/dist/assets/index-DQC7YnEQ.js +0 -158
  140. package/dist/assets/loader-circle-BNhIFGdg.js +0 -1
  141. package/dist/assets/plus-Djbdyc2E.js +0 -1
  142. package/dist/assets/roleDescriptions-x3mUxTcX.js +0 -1
  143. package/dist/assets/rotate-ccw-BD-9XzMC.js +0 -1
  144. package/dist/assets/searchSchemas-CS2ZgsHC.js +0 -64
  145. package/dist/assets/trashPage-WtAhGCt7.js +0 -1
  146. package/dist/assets/x-CK8d5DC1.js +0 -1
@@ -0,0 +1,158 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/pdf-EQHMWEbX.js","assets/preload-helper-Czpn1I53.js","assets/RolesTab-DDYieLTF.js","assets/bundle-mjs-C73ZY4La.js","assets/api-CUskDNHD.js","assets/lock-X9ZGk2P9.js","assets/checkbox-Czxm5pNj.js","assets/check-Da8rPJKX.js","assets/dist-DDCmobc1.js","assets/dist-CHsekWGV.js","assets/button-CbHyzXCb.js","assets/input-DCbMcJYs.js","assets/convexApi-BPSJUy2j.js","assets/toast-C8rSAMgh.js","assets/x-6-84PEVq.js","assets/badge-TiMZiv59.js","assets/ConfirmDialog-Dy8WCeAF.js","assets/alert-dialog-DRrmbZYC.js","assets/dist-DQawXTf-.js","assets/dialog-DpoEg_Ex.js","assets/EntitySheet-D-JZB54h.js","assets/loader-circle-BO0Lx5va.js","assets/roleDescriptions-CmJBKAaf.js","assets/InstancesTab-DsJ_BBfc.js","assets/FieldLabel-D63ry-fi.js","assets/tooltip-D3qNpGhD.js","assets/select-DCBGpD8v.js","assets/dist-BmXC8pZv.js","assets/chevron-up-DfOJb3vW.js","assets/dist-Cv-LvOB4.js","assets/locales-CPjguROj.js","assets/curation-CQksaIbm.js","assets/popover-DiT_Oo6e.js","assets/dist-HZSdA3kh.js","assets/groupManageView-DY6vPM1h.js","assets/DataTableShell-2_QPZexc.js","assets/chevrons-up-down-Bp7zuoEk.js","assets/dropdown-menu-BWxfj48Z.js","assets/dist-BqsRl4o3.js","assets/plus-CSOLqt7C.js","assets/trash-2-8oRd823U.js","assets/table-GXZ7yFCE.js","assets/BridgeTab-CBE4zTQ1.js","assets/useNavigate-D3GIoxyW.js","assets/chevron-right-BjOti-z8.js","assets/usageView-B0Wg081i.js","assets/server-BSDuYUUF.js","assets/triangle-alert-DQoWKyu_.js","assets/tabs-dQ50HGoj.js","assets/format-zM-c-1S6.js","assets/appHost-CH3EGcJw.js","assets/FilterBar-Bynn2H7k.js","assets/search-D9Un2NMX.js","assets/rotate-ccw-C-v_7YX7.js","assets/TimeRangePicker-DzJYDik_.js","assets/compatView-Dj1HQXxr.js","assets/dispatchErrorInfo-BOJ5cTZo.js","assets/PromptInjectionsTab-D3drsS9C.js","assets/localePickerView-C2RmOS86.js","assets/confTabs-BzReq467.css","assets/GroupsTab-hxsjfQDc.js","assets/chevron-left-DxPC6E1S.js","assets/users-DHMAZ7v8.js","assets/star-DjK6DoNA.js","assets/DetailChips-DaliQU_Q.js","assets/IntegrationsTab-Cf3lTCzz.js","assets/FeedbacksTab-DWmslsAt.js","assets/SubAgentReportsTab-GXHpWbrW.js","assets/TrashTab-BVZJggvr.js","assets/use_paginated_query-BatXdmTn.js","assets/fileMetaView-Ci5C4w9Q.js","assets/trashView-CIgTWQjI.js","assets/trashPage-CoBMe_r-.js","assets/trashPage-DfKyy5ga.css","assets/DeletedChatsTab-Fzk38aqT.js","assets/FilesTab-DzHfzOnQ.js","assets/download-Do4pcXOL.js","assets/ScheduledTab-D-yTTYHC.js","assets/list-DIWFv1eJ.js","assets/cronDescribe-BC0AcJer.js","assets/pencil-1kZxxbnV.js","assets/TimezoneCombobox-BY91kPSf.js","assets/AgentFilesTab-D3tMMo2R.js","assets/capabilities-CASxhKEd.js","assets/PreferencesTab-DiDi7mpY.js","assets/useFontScale-C03nea0B.js","assets/switch-Dt_I92ZY.js","assets/ChatDefaultsTab-CIX9WUCl.js","assets/KnobRow-3my9jz_H.js","assets/AccessTab-gaTBs3lV.js","assets/ThemeShowroom-uU3PL_6V.js","assets/useChart-xKc_wRHf.js","assets/card-vUc-7TYj.js","assets/AdvancedFilter-5BMuHHt6.js","assets/ProjectPage-DDto6xkD.js","assets/useStartNewChat-B66bn5hT.js","assets/useStartNewChat-DgQf_3y0.css","assets/eye-yUMVb9gl.js","assets/ProjectPage-BXsrYrrF.css","assets/TracesTab-C7zX1NUU.js","assets/copy-C1_4Ewod.js","assets/deliveryRecorder-CGhwQ1sg.js","assets/searchSchemas-Dm-Qg010.js","assets/VoiceTab-CnZ-twTR.js","assets/speech-CfxX6OY3.js","assets/AuditTab-Yw1LvjgD.js","assets/AnomaliesTab-CdFgsRwT.js","assets/KpiTab-C6dn6jVl.js","assets/ServiceAccountsTab-fJYmH0eU.js","assets/UsersTab-HdsTBYR0.js","assets/AdminSettings-CMjix9zl.js"])))=>i.map(i=>d[i]);
2
+ import{a as e,c as t,i as n,l as r,o as i,r as a,s as o}from"./bundle-mjs-C73ZY4La.js";import{$B as s,$D as c,$E as l,$H as u,$M as d,$O as f,$S as p,$T as m,$U as h,$V as g,$a as _,$c as v,$d as y,$g as b,$h as x,$i as S,$j as C,$l as w,$n as T,$p as E,$q as D,$r as O,$s as k,$t as A,$u as j,$y as M,AE as N,AH as P,AO as F,AT as I,AU as L,AV as R,AY as ee,AZ as z,A_ as B,Aa as V,Ac as te,Ag as ne,Ai as re,Aj as ie,An as ae,Ao as oe,Ar as se,As as ce,At as le,Aw as ue,Ay as de,Az as fe,BB as pe,BD as me,BE as he,BH as ge,BO as _e,BT as ve,BU as ye,BV as be,BY as xe,BZ as Se,B_ as Ce,Ba as we,Bc as Te,Bd as Ee,Bg as De,Bi as Oe,Bj as ke,Bl as Ae,Bm as je,Bn as Me,Br as Ne,Bs as Pe,Bt as Fe,Bw as Ie,By as Le,Bz as Re,CE as ze,CH as Be,CT as Ve,CU as He,CV as Ue,CY as We,CZ as Ge,C_ as Ke,Ca as qe,Cc as Je,Cd as Ye,Cf as Xe,Cg as Ze,Ci as Qe,Co as $e,Cr as et,Cs as tt,Ct as nt,Cu as rt,Cy as it,Cz as at,DE as ot,DH as st,DT as ct,DU as lt,DV as ut,DY as dt,DZ as ft,D_ as pt,Da as mt,Dc as ht,Dd as gt,Dg as _t,Di as vt,Do as yt,Dr as bt,Ds as xt,Dt as St,Dw as Ct,Dy as wt,Dz as Tt,E as H,EE as Et,EH as Dt,ET as Ot,EU as kt,EV as At,EY as jt,EZ as Mt,E_ as Nt,Ea as Pt,Ec as Ft,Ed as It,Eg as Lt,Ei as Rt,Eo as zt,Er as Bt,Es as Vt,Et as Ht,Ew as Ut,Ey as Wt,Ez as Gt,FB as Kt,FD as qt,FE as Jt,FH as Yt,FO as Xt,FT as Zt,FU as Qt,FV as $t,FY as en,FZ as U,F_ as tn,Fa as nn,Fc as rn,Fg as an,Fi as on,Fj as sn,Fl as cn,Fm as ln,Fn as un,Fo as dn,Fp as fn,Fr as pn,Fs as mn,Fw as hn,Fz as gn,GB as _n,GE as vn,GH as yn,GM as bn,GO as xn,GS as Sn,GT as Cn,GU as wn,GV as Tn,GY as En,GZ as Dn,G_ as On,Ga as kn,Gc as An,Gd as jn,Gg as Mn,Gh as Nn,Gi as Pn,Gj as Fn,Gl as In,Gm as Ln,Gn as Rn,Gp as zn,Gr as Bn,Gs as Vn,Gt as Hn,Gw as Un,HB as Wn,HD as Gn,HH as Kn,HO as qn,HT as Jn,HU as Yn,HV as Xn,HY as Zn,HZ as Qn,H_ as $n,Ha as er,Hc as tr,Hd as nr,Hg as rr,Hi as ir,Hj as ar,Hl as or,Hm as sr,Hn as cr,Hp as lr,Hr as ur,Hs as dr,Ht as fr,Hw as pr,Hy as mr,Hz as hr,IB as gr,ID as _r,IE as vr,IH as yr,IO as br,IT as xr,IU as Sr,IV as Cr,IY as wr,IZ as Tr,I_ as Er,Ia as Dr,Ic as Or,Ig as kr,Ii as Ar,Ij as jr,Il as Mr,Im as Nr,In as Pr,Ir as Fr,Is as Ir,Iw as Lr,Iz as Rr,JB as zr,JE as Br,JH as Vr,JM as Hr,JO as Ur,JS as Wr,JT as Gr,JU as Kr,JV as qr,J_ as Jr,Ja as Yr,Jc as Xr,Jd as Zr,Jg as Qr,Jh as $r,Ji as ei,Jj as ti,Jl as ni,Jn as ri,Jp as ii,Jr as ai,Js as oi,Jt as si,Jw as ci,Jy as li,KB as ui,KE as di,KH as fi,KM as pi,KO as mi,KS as hi,KT as gi,KU as _i,KV as vi,KY as yi,K_ as bi,Ka as xi,Kc as Si,Kd as Ci,Kg as wi,Kh as Ti,Ki as Ei,Kj as Di,Kl as Oi,Km as ki,Kn as Ai,Kp as ji,Kr as Mi,Ks as Ni,Kt as Pi,Kw as Fi,Ky as Ii,LB as Li,LD as Ri,LE as zi,LH as Bi,LO as Vi,LT as Hi,LU as Ui,LV as Wi,LY as Gi,LZ as Ki,L_ as qi,La as Ji,Lc as Yi,Lg as Xi,Li as Zi,Lj as Qi,Lm as $i,Ln as ea,Lp as ta,Lr as na,Ls as ra,Lw as ia,Lz as aa,ME as oa,MH as sa,MO as ca,MT as la,MU as ua,MV as da,MY as fa,MZ as pa,M_ as ma,Ma as ha,Mc as ga,Mg as _a,Mi as va,Mj as ya,Ml as ba,Mn as xa,Mo as Sa,Mp as Ca,Mr as wa,Mw as Ta,My as Ea,Mz as Da,NE as Oa,NH as ka,NJ as Aa,NO as ja,NT as Ma,NU as Na,NV as Pa,NY as Fa,NZ as Ia,N_ as La,Na as Ra,Nc as za,Ng as Ba,Ni as Va,Nj as Ha,Nl as Ua,Nm as Wa,Nn as Ga,No as Ka,Nr as qa,Ns as Ja,Nw as Ya,Ny as Xa,Nz as Za,OE as Qa,OH as $a,OO as eo,OT as to,OU as no,OV as ro,OY as io,OZ as ao,O_ as oo,Oa as so,Oc as co,Od as lo,Og as uo,Oi as fo,Oo as po,Or as mo,Ot as ho,Ow as go,Oy as _o,Oz as vo,PE as yo,PH as bo,PO as xo,PT as So,PU as Co,PV as wo,PY as To,PZ as W,P_ as Eo,Pa as Do,Pc as Oo,Pg as ko,Pi as Ao,Pj as jo,Pl as Mo,Pm as No,Pn as Po,Po as Fo,Pr as Io,Ps as Lo,Pw as Ro,Py as zo,Pz as Bo,QB as Vo,QD as Ho,QE as Uo,QH as Wo,QM as Go,QO as Ko,QS as qo,QT as Jo,QU as Yo,QV as Xo,Qa as Zo,Qc as Qo,Qd as $o,Qg as es,Qh as ts,Qi as ns,Qj as rs,Ql as is,Qn as as,Qp as os,Qr as ss,Qs as cs,Qt as ls,Qu as us,Qy as ds,RB as fs,RD as ps,RE as ms,RH as hs,RO as gs,RT as _s,RU as vs,RV as ys,RY as bs,RZ as xs,R_ as Ss,Ra as Cs,Rc as ws,Rg as Ts,Ri as Es,Rj as Ds,Rl as Os,Rm as ks,Rn as As,Ro as js,Rp as Ms,Rr as Ns,Rs as Ps,Rw as Fs,Rz as Is,SE as Ls,SH as Rs,ST as zs,SU as Bs,SV as Vs,SY as Hs,SZ as Us,S_ as Ws,Sa as Gs,Sc as Ks,Sd as qs,Sf as Js,Sg as Ys,Si as Xs,Sm as Zs,So as Qs,Sr as $s,Ss as ec,St as tc,Su as nc,Sz as rc,T as ic,TE as ac,TH as oc,TO as sc,TT as cc,TU as lc,TV as uc,TY as dc,TZ as fc,T_ as pc,Ta as mc,Tc as hc,Td as gc,Tg as _c,Ti as vc,To as yc,Tr as bc,Ts as xc,Tt as Sc,Tu as Cc,Tw as wc,Ty as Tc,Tz as Ec,UB as Dc,UD as Oc,UH as kc,UO as Ac,UT as jc,UU as Mc,UV as Nc,UY as Pc,UZ as Fc,U_ as Ic,Ua as Lc,Uc as Rc,Ud as zc,Ug as Bc,Ui as Vc,Uj as Hc,Ul as Uc,Um as Wc,Un as Gc,Up as Kc,Ur as qc,Us as Jc,Ut as Yc,Uw as Xc,Uz as Zc,VB as Qc,VD as $c,VE as el,VH as tl,VO as nl,VT as rl,VU as il,VV as al,VY as ol,VZ as sl,V_ as cl,Va as ll,Vc as ul,Vd as dl,Vg as fl,Vi as pl,Vj as ml,Vl as hl,Vm as gl,Vn as _l,Vo as vl,Vp as yl,Vr as bl,Vs as xl,Vt as Sl,Vw as Cl,Vz as wl,WB as Tl,WD as El,WH as Dl,WO as Ol,WT as kl,WU as Al,WV as jl,WY as Ml,WZ as Nl,W_ as Pl,Wa as Fl,Wc as Il,Wd as Ll,Wg as Rl,Wi as zl,Wj as Bl,Wl as Vl,Wm as Hl,Wn as Ul,Wo as Wl,Wp as Gl,Wr as Kl,Ws as ql,Wt as Jl,Ww as Yl,Wz as Xl,XB as Zl,XD as Ql,XE as $l,XH as eu,XM as tu,XO as nu,XS as ru,XT as iu,XU as au,XV as ou,XY as su,Xa as cu,Xc as lu,Xd as uu,Xg as du,Xh as fu,Xi as pu,Xj as mu,Xl as hu,Xn as gu,Xp as _u,Xr as vu,Xs as yu,Xt as bu,Xy as xu,YB as Su,YE as Cu,YF as wu,YH as Tu,YM as Eu,YO as Du,YS as Ou,YT as ku,YU as Au,YV as ju,YY as Mu,Y_ as Nu,Ya as Pu,Yc as Fu,Yd as Iu,Yg as Lu,Yh as Ru,Yi as zu,Yj as Bu,Yl as Vu,Yn as Hu,Yp as Uu,Yr as Wu,Ys as Gu,Yt as Ku,Yw as qu,Yy as Ju,ZB as Yu,ZD as Xu,ZE as Zu,ZH as Qu,ZM as $u,ZO as ed,ZS as td,ZT as nd,ZU as rd,ZV as id,Za as ad,Zc as od,Zd as sd,Zg as cd,Zh as ld,Zi as ud,Zj as dd,Zl as fd,Zn as pd,Zp as md,Zr as hd,Zs as gd,Zt as _d,Zy as vd,_ as yd,_C as bd,_E as xd,_H as Sd,_N as Cd,_T as wd,_U as Td,_V as Ed,_W as Dd,_Y as Od,__ as kd,_a as Ad,_d as jd,_f as Md,_i as Nd,_m as Pd,_o as Fd,_t as Id,_u as Ld,_z as Rd,aC as zd,aE as Bd,aH as Vd,aJ as Hd,aM as Ud,aN as Wd,aT as Gd,aU as Kd,aV as qd,aW as Jd,a_ as Yd,aa as Xd,ac as Zd,ad as Qd,af as $d,ag as ef,ai as tf,ak as nf,am as rf,ao as af,ap as of,ar as sf,at as cf,au as lf,ay as uf,bC as df,bE as ff,bH as pf,bT as mf,bU as hf,bV as gf,bW as _f,bY as vf,bZ as yf,b_ as bf,ba as xf,bc as Sf,bd as Cf,bf as wf,bg as Tf,bi as Ef,bm as Df,bo as Of,bt as kf,bu as Af,bw as jf,bz as Mf,cC as Nf,cE as Pf,cH as Ff,cN as If,cT as Lf,cU as Rf,cV as zf,cW as Bf,c_ as Vf,ca as Hf,cb as Uf,cc as Wf,cf as Gf,ci as Kf,cm as qf,co as Jf,cr as Yf,ct as Xf,cu as Zf,cy as Qf,cz as $f,dC as ep,dE as tp,dH as np,dN as rp,dT as ip,dU as ap,dV as op,dW as sp,dY as cp,d_ as lp,da as up,dc as dp,df as fp,di as pp,dm as mp,do as hp,dt as gp,du as _p,dy as vp,dz as yp,eC as bp,eD as xp,eE as Sp,eH as Cp,eJ as wp,eM as Tp,eN as Ep,eO as Dp,eU as Op,eV as kp,eW as Ap,e_ as jp,ea as Mp,ec as Np,ef as Pp,eg as Fp,ei as Ip,ek as Lp,el as Rp,em as zp,en as Bp,eo as Vp,ep as Hp,er as Up,es as Wp,eu as Gp,fC as Kp,fE as qp,fH as Jp,fN as Yp,fT as Xp,fU as Zp,fV as Qp,fW as $p,fY as em,f_ as tm,fa as nm,fc as rm,ff as im,fi as am,fl as om,fm as sm,fo as cm,ft as lm,fu as um,fy as dm,fz as fm,g as pm,gC as mm,gE as hm,gH as gm,gN as _m,gT as vm,gU as ym,gV as bm,gW as xm,gY as Sm,g_ as Cm,ga as wm,gd as Tm,gf as Em,gi as Dm,gm as Om,go as km,gt as Am,gu as jm,gz as Mm,hC as Nm,hE as Pm,hH as Fm,hN as Im,hO as Lm,hT as Rm,hU as zm,hV as Bm,hW as Vm,hY as eee,h_ as Hm,ha as tee,hd as nee,hf as ree,hi as iee,hm as aee,ho as oee,ht as see,hu as Um,hz as Wm,iA as Gm,iC as Km,iE as qm,iH as Jm,iJ as Ym,iM as Xm,iN as Zm,iT as Qm,iU as $m,iV as eh,iW as th,i_ as nh,ia as rh,ic as ih,if as ah,ig as oh,ii as sh,ik as ch,im as lh,io as uh,ip as dh,ir as fh,it as ph,iu as mh,iy as hh,jE as gh,jH as _h,jO as vh,jT as yh,jU as bh,jV as xh,jY as Sh,jZ as Ch,j_ as wh,ja as Th,jc as Eh,jg as Dh,ji as Oh,jj as kh,jl as Ah,jn as jh,jo as Mh,jp as Nh,jr as Ph,jw as Fh,jy as Ih,jz as Lh,kE as Rh,kH as zh,kO as Bh,kT as Vh,kU as Hh,kV as Uh,kY as Wh,kZ as Gh,k_ as Kh,ka as qh,kc as Jh,kd as Yh,kg as Xh,ki as Zh,kj as Qh,ko as $h,kr as eg,ks as tg,kt as ng,kw as rg,ky as ig,kz as ag,lC as og,lE as sg,lH as cg,lN as lg,lT as ug,lU as dg,lV as fg,lW as pg,l_ as mg,la as hg,lc as gg,lf as _g,li as vg,lm as yg,lo as bg,lr as xg,lt as Sg,lu as Cg,ly as wg,lz as Tg,mC as Eg,mE as Dg,mH as Og,mN as kg,mO as Ag,mT as jg,mU as Mg,mV as Ng,mW as Pg,mY as Fg,m_ as Ig,ma as Lg,mf as Rg,mi as zg,ml as Bg,mm as Vg,mo as Hg,mt as Ug,mu as Wg,my as Gg,mz as Kg,nC as qg,nE as Jg,nH as Yg,nJ as Xg,nM as Zg,nN as Qg,nU as $g,nV as e_,nW as t_,n_,na as r_,nc as i_,nf as a_,ng as o_,ni as s_,nk as c_,nl as l_,nm as u_,nn as d_,no as f_,np as p_,nr as m_,ns as h_,nt as g_,nu as __,oC as v_,oE as y_,oH as cee,oJ as b_,oM as x_,oN as lee,oT as uee,oU as dee,oV as S_,oW as fee,o_ as pee,oa as C_,oc as mee,of as hee,og as gee,oi as _ee,ok as vee,om as yee,oo as bee,or as w_,ot as xee,ou as See,oy as T_,pC as E_,pE as D_,pH as O_,pN as Cee,pT as wee,pU as Tee,pV as Eee,pW as Dee,pY as Oee,p_ as k_,pa as A_,pc as j_,pf as M_,pi as N_,pl as P_,pm as F_,po as I_,pt as L_,pu as R_,py as z_,pz as B_,qB as V_,qE as H_,qM as U_,qO as W_,qS as G_,qT as K_,qU as q_,qV as J_,qY as Y_,q_ as X_,qa as Z_,qc as Q_,qd as $_,qg as ev,qh as tv,qi as nv,qj as rv,ql as iv,qn as av,qp as ov,qr as sv,qs as cv,qt as lv,qw as uv,qy as dv,r as fv,rC as pv,rE as mv,rH as hv,rJ as gv,rM as _v,rN as vv,rT as yv,rU as bv,rV as xv,rW as Sv,r_ as Cv,ra as wv,rc as Tv,rf as Ev,rg as Dv,ri as Ov,rk as kv,rm as Av,rn as jv,ro as Mv,rp as Nv,rr as Pv,rs as Fv,rt as Iv,ru as Lv,sC as Rv,sE as zv,sH as Bv,sN as Vv,sT as Hv,sU as Uv,sV as Wv,sW as Gv,s_ as Kv,sa as qv,sc as Jv,sf as Yv,sg as Xv,si as Zv,sm as Qv,so as $v,sr as ey,st as ty,su as ny,sy as ry,sz as iy,t as G,tC as ay,tD as oy,tE as sy,tH as cy,tM as ly,tN as uy,tO as dy,tU as fy,tV as py,tW as my,t_ as hy,ta as gy,tc as _y,tf as vy,tg as yy,ti as by,tk as xy,tl as Sy,tm as Cy,tn as wy,to as Ty,tp as Ey,tr as Dy,ts as Oy,tu as ky,uC as Ay,uE as jy,uH as My,uN as Ny,uT as Py,uU as Fy,uV as Iy,uW as Ly,uY as Ry,u_ as zy,ua as By,uc as Vy,uf as Hy,ui as Uy,um as Wy,uo as Gy,ur as Ky,ut as qy,uu as Jy,uy as Yy,uz as Xy,v as Zy,vC as Qy,vE as $y,vH as eb,vO as tb,vT as nb,vU as rb,vV as ib,vW as ab,vY as ob,v_ as sb,va as cb,vc as lb,vd as ub,vf as db,vg as fb,vi as pb,vm as mb,vo as hb,vt as gb,vu as _b,vw as vb,vy as yb,vz as bb,wE as xb,wH as Sb,wO as Cb,wT as wb,wU as Tb,wV as Eb,wY as Db,wZ as Ob,w_ as kb,wa as Ab,wc as jb,wd as Mb,wf as Nb,wg as Pb,wi as Fb,wo as Ib,wr as Lb,ws as Rb,wt as zb,wu as Bb,wy as Vb,wz as Hb,x as Ub,xE as Wb,xH as Gb,xT as Kb,xU as qb,xV as Jb,xW as Yb,xY as Xb,xZ as Zb,x_ as Qb,xa as $b,xc as ex,xd as tx,xf as nx,xg as rx,xi as ix,xm as ax,xo as ox,xr as sx,xs as cx,xt as lx,xu as ux,xy as dx,xz as fx,y as px,yC as mx,yE as hx,yH as gx,yT as _x,yU as vx,yV as kee,yW as Aee,yY as jee,yZ as yx,y_ as bx,ya as Mee,yc as xx,yd as Nee,yf as Pee,yg as Fee,yi as Iee,ym as Sx,yo as Lee,yt as Ree,yu as zee,yw as Bee,yy as Vee,yz as Hee,zB as Uee,zD as Wee,zE as Cx,zH as Gee,zO as wx,zT as Kee,zU as qee,zV as Tx,zY as Jee,zZ as Ex,z_ as Yee,za as Xee,zc as Zee,zd as Qee,zg as $ee,zi as Dx,zj as ete,zl as tte,zm as Ox,zn as nte,zr as rte,zs as ite,zw as ate,zz as kx}from"./api-CUskDNHD.js";import{S as Ax,_ as jx,a as Mx,b as Nx,c as Px,d as Fx,f as Ix,g as Lx,h as Rx,i as zx,l as ote,m as Bx,n as Vx,o as Hx,p as Ux,r as Wx,s as Gx,t as Kx,u as qx,v as Jx,x as Yx,y as Xx}from"./useNavigate-D3GIoxyW.js";import{B as Zx,C as Qx,D as $x,E as eS,F as tS,G as nS,H as rS,I as iS,J as aS,K as oS,L as sS,M as cS,N as lS,O as uS,P as dS,R as fS,T as pS,U as mS,V as hS,_ as gS,a as _S,b as ste,c as cte,d as vS,f as yS,g as bS,h as xS,i as SS,k as CS,l as wS,m as TS,n as ES,o as DS,p as OS,q as kS,r as AS,s as jS,t as MS,v as NS,w as PS,x as FS,y as lte,z as IS}from"./useStartNewChat-B66bn5hT.js";import{a as LS,c as RS,d as zS,f as BS,i as VS,l as HS,n as US,o as WS,r as GS,s as KS,t as qS,u as JS}from"./speech-CfxX6OY3.js";import{t as YS}from"./check-Da8rPJKX.js";import{r as XS}from"./dist-BmXC8pZv.js";import{t as ZS}from"./chevron-left-DxPC6E1S.js";import{t as QS}from"./chevron-right-BjOti-z8.js";import{t as $S}from"./chevron-up-DfOJb3vW.js";import{n as eC,t as tC}from"./usageView-B0Wg081i.js";import{_ as nC,a as rC,c as iC,d as aC,f as oC,g as sC,h as cC,i as lC,l as uC,m as dC,n as fC,o as pC,p as mC,r as hC,s as gC,t as _C,u as ute}from"./dropdown-menu-BWxfj48Z.js";import{n as vC,t as yC}from"./search-D9Un2NMX.js";import{t as bC}from"./copy-C1_4Ewod.js";import{t as xC}from"./download-Do4pcXOL.js";import{n as SC,t as CC}from"./eye-yUMVb9gl.js";import{a as wC,i as TC,n as EC,o as DC,t as OC}from"./deliveryRecorder-CGhwQ1sg.js";import{t as kC}from"./loader-circle-BO0Lx5va.js";import{t as AC}from"./lock-X9ZGk2P9.js";import{t as jC}from"./checkbox-Czxm5pNj.js";import{a as MC,i as NC,n as PC,r as FC,t as IC}from"./cronDescribe-BC0AcJer.js";import{t as LC}from"./pencil-1kZxxbnV.js";import{t as RC}from"./plus-CSOLqt7C.js";import{t as zC}from"./rotate-ccw-C-v_7YX7.js";import{t as BC}from"./server-BSDuYUUF.js";import{i as VC,n as HC,r as UC,t as WC}from"./users-DHMAZ7v8.js";import{t as GC}from"./trash-2-8oRd823U.js";import{t as KC}from"./triangle-alert-DQoWKyu_.js";import{i as qC,n as JC,t as YC}from"./useChart-xKc_wRHf.js";import{t as XC}from"./x-6-84PEVq.js";import{i as ZC,n as QC,r as $C,t as ew}from"./tooltip-D3qNpGhD.js";import{a as tw,i as nw,n as rw,r as iw,t as aw}from"./select-DCBGpD8v.js";import{a as ow,c as sw,i as cw,n as lw,o as uw,r as dw,s as fw,t as pw}from"./alert-dialog-DRrmbZYC.js";import{i as mw,n as hw,r as gw,t as _w}from"./tabs-dQ50HGoj.js";import{n as vw,r as yw,t as bw}from"./popover-DiT_Oo6e.js";import{t as K}from"./button-CbHyzXCb.js";import{t as xw}from"./input-DCbMcJYs.js";import"./convexApi-BPSJUy2j.js";import{a as Sw,c as Cw,d as ww,i as Tw,l as Ew,n as Dw,o as Ow,r as kw,s as Aw}from"./useFontScale-C03nea0B.js";import{n as jw,r as Mw,t as Nw}from"./toast-C8rSAMgh.js";import{t as Pw}from"./badge-TiMZiv59.js";import{c as Fw,d as Iw,f as Lw,l as Rw,o as zw,r as Bw,s as Vw,u as Hw}from"./chunk-7TTQLYRW-ByhoRIPY.js";import{t as Uw}from"./preload-helper-Czpn1I53.js";import{a as Ww,i as Gw,n as Kw,r as qw}from"./format-zM-c-1S6.js";import{a as Jw,i as Yw,n as Xw,o as Zw,r as Qw,t as $w}from"./dialog-DpoEg_Ex.js";import{a as eT,d as tT,f as nT,h as rT,i as iT,l as aT,m as oT,p as sT,r as cT}from"./searchSchemas-Dm-Qg010.js";import{n as lT,r as uT,t as dT}from"./appHost-CH3EGcJw.js";import{n as fT,r as pT,t as mT}from"./ConfirmDialog-Dy8WCeAF.js";import{a as hT,i as gT,n as _T,o as vT,r as yT,s as bT,t as xT}from"./EntitySheet-D-JZB54h.js";import{a as ST,c as CT,d as wT,f as TT,g as ET,h as DT,i as OT,l as kT,m as AT,n as jT,o as MT,p as NT,r as PT,s as FT,u as IT}from"./KnobRow-3my9jz_H.js";import{s as LT}from"./groupManageView-DY6vPM1h.js";import{n as RT,r as zT,t as BT}from"./fileMetaView-Ci5C4w9Q.js";import{r as VT,t as dte}from"./trashView-CIgTWQjI.js";import{a as fte,c as HT,i as UT,l as WT,n as GT,r as pte,s as KT}from"./AdminSettings-CMjix9zl.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var mte=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),hte=i(((e,t)=>{t.exports=mte()})),gte=i((t=>{var r=hte(),i=e(),a=n();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function s(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function c(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function l(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function u(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(c(e)!==e)throw Error(o(188))}function f(e){var t=e.alternate;if(!t){if(t=c(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return d(i),e;if(a===r)return d(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,l=i.child;l;){if(l===n){s=!0,n=i,r=a;break}if(l===r){s=!0,r=i,n=a;break}l=l.sibling}if(!s){for(l=a.child;l;){if(l===n){s=!0,n=a,r=i;break}if(l===r){s=!0,r=a,n=i;break}l=l.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,h=Symbol.for(`react.element`),g=Symbol.for(`react.transitional.element`),_=Symbol.for(`react.portal`),v=Symbol.for(`react.fragment`),y=Symbol.for(`react.strict_mode`),b=Symbol.for(`react.profiler`),x=Symbol.for(`react.consumer`),S=Symbol.for(`react.context`),C=Symbol.for(`react.forward_ref`),w=Symbol.for(`react.suspense`),T=Symbol.for(`react.suspense_list`),E=Symbol.for(`react.memo`),D=Symbol.for(`react.lazy`),O=Symbol.for(`react.activity`),k=Symbol.for(`react.memo_cache_sentinel`),A=Symbol.iterator;function j(e){return typeof e!=`object`||!e?null:(e=A&&e[A]||e[`@@iterator`],typeof e==`function`?e:null)}var M=Symbol.for(`react.client.reference`);function N(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===M?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case v:return`Fragment`;case b:return`Profiler`;case y:return`StrictMode`;case w:return`Suspense`;case T:return`SuspenseList`;case O:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case _:return`Portal`;case S:return e.displayName||`Context`;case x:return(e._context.displayName||`Context`)+`.Consumer`;case C:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case E:return t=e.displayName||null,t===null?N(e.type)||`Memo`:t;case D:t=e._payload,e=e._init;try{return N(e(t))}catch{}}return null}var P=Array.isArray,F=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=a.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,L={pending:!1,data:null,method:null,action:null},R=[],ee=-1;function z(e){return{current:e}}function B(e){0>ee||(e.current=R[ee],R[ee]=null,ee--)}function V(e,t){ee++,R[ee]=e.current,e.current=t}var te=z(null),ne=z(null),re=z(null),ie=z(null);function ae(e,t){switch(V(re,t),V(ne,e),V(te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Yd(t),e=Xd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}B(te),V(te,e)}function oe(){B(te),B(ne),B(re)}function se(e){e.memoizedState!==null&&V(ie,e);var t=te.current,n=Xd(t,e.type);t!==n&&(V(ne,e),V(te,n))}function ce(e){ne.current===e&&(B(te),B(ne)),ie.current===e&&(B(ie),op._currentValue=L)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1<e.stack.indexOf(`
3
+ at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
+ `+le+e+ue}var fe=!1;function pe(e,t){if(!e||fe)return``;fe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
5
+ `),l=s.split(`
6
+ `);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
7
+ `+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{fe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?de(n):``}function me(e,t){switch(e.tag){case 26:case 27:case 5:return de(e.type);case 16:return de(`Lazy`);case 13:return e.child!==t&&t!==null?de(`Suspense Fallback`):de(`Suspense`);case 19:return de(`SuspenseList`);case 0:case 15:return pe(e.type,!1);case 11:return pe(e.type.render,!1);case 1:return pe(e.type,!0);case 31:return de(`Activity`);default:return``}}function he(e){try{var t=``,n=null;do t+=me(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
8
+ Error generating stack: `+e.message+`
9
+ `+e.stack}}var ge=Object.prototype.hasOwnProperty,_e=r.unstable_scheduleCallback,ve=r.unstable_cancelCallback,ye=r.unstable_shouldYield,be=r.unstable_requestPaint,xe=r.unstable_now,Se=r.unstable_getCurrentPriorityLevel,Ce=r.unstable_ImmediatePriority,we=r.unstable_UserBlockingPriority,Te=r.unstable_NormalPriority,Ee=r.unstable_LowPriority,De=r.unstable_IdlePriority,Oe=r.log,ke=r.unstable_setDisableYieldValue,Ae=null,je=null;function Me(e){if(typeof Oe==`function`&&ke(e),je&&typeof je.setStrictMode==`function`)try{je.setStrictMode(Ae,e)}catch{}}var Ne=Math.clz32?Math.clz32:Ie,Pe=Math.log,Fe=Math.LN2;function Ie(e){return e>>>=0,e===0?32:31-(Pe(e)/Fe|0)|0}var Le=256,Re=262144,ze=4194304;function Be(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ve(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Be(n))):i=Be(o):i=Be(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Be(n))):i=Be(o)):i=Be(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function He(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ue(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function We(){var e=ze;return ze<<=1,!(ze&62914560)&&(ze=4194304),e}function Ge(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ke(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function qe(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ne(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&Je(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function Je(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ne(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function Ye(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ne(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function Xe(e,t){var n=t&-t;return n=n&42?1:Ze(n),(n&(e.suspendedLanes|t))===0?n:0}function Ze(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function Qe(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function $e(){var e=I.p;return e===0?(e=window.event,e===void 0?32:Sp(e.type)):e}function et(e,t){var n=I.p;try{return I.p=e,t()}finally{I.p=n}}var tt=Math.random().toString(36).slice(2),nt=`__reactFiber$`+tt,rt=`__reactProps$`+tt,it=`__reactContainer$`+tt,at=`__reactEvents$`+tt,ot=`__reactListeners$`+tt,st=`__reactHandles$`+tt,ct=`__reactResources$`+tt,lt=`__reactMarker$`+tt;function ut(e){delete e[nt],delete e[rt],delete e[at],delete e[ot],delete e[st]}function dt(e){var t=e[nt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[it]||n[nt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=yf(e);e!==null;){if(n=e[nt])return n;e=yf(e)}return t}e=n,n=e.parentNode}return null}function ft(e){if(e=e[nt]||e[it]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function pt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(o(33))}function mt(e){var t=e[ct];return t||=e[ct]={hoistableStyles:new Map,hoistableScripts:new Map},t}function ht(e){e[lt]=!0}var gt=new Set,_t={};function vt(e,t){yt(e,t),yt(e+`Capture`,t)}function yt(e,t){for(_t[e]=t,e=0;e<t.length;e++)gt.add(t[e])}var bt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),xt={},St={};function Ct(e){return ge.call(St,e)?!0:ge.call(xt,e)?!1:bt.test(e)?St[e]=!0:(xt[e]=!0,!1)}function wt(e,t,n){if(Ct(t))if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}function Tt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function H(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Et(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Dt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Ot(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function kt(e){if(!e._valueTracker){var t=Dt(e)?`checked`:`value`;e._valueTracker=Ot(e,t,``+e[t])}}function At(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Dt(e)?e.checked?`true`:`false`:e.value),e=r,e===n?!1:(t.setValue(e),!0)}function jt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Mt=/[\n"\\]/g;function Nt(e){return e.replace(Mt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Pt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Et(t)):e.value!==``+Et(t)&&(e.value=``+Et(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):It(e,o,Et(n)):It(e,o,Et(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Et(s):e.removeAttribute(`name`)}function Ft(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){kt(e);return}n=n==null?``:``+Et(n),t=t==null?n:``+Et(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),kt(e)}function It(e,t,n){t===`number`&&jt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Lt(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Et(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function Rt(e,t,n){if(t!=null&&(t=``+Et(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Et(n)}function zt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(o(92));if(P(r)){if(1<r.length)throw Error(o(93));r=r[0]}n=r}n??=``,t=n}n=Et(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),kt(e)}function Bt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Vt=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function Ht(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||Vt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Ut(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(o(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var i in t)r=t[i],t.hasOwnProperty(i)&&n[i]!==r&&Ht(e,i,r)}else for(var a in t)t.hasOwnProperty(a)&&Ht(e,a,t[a])}function Wt(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var Gt=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),Kt=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function qt(e){return Kt.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function Jt(){}var Yt=null;function Xt(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Zt=null,Qt=null;function $t(e){var t=ft(e);if(t&&(e=t.stateNode)){var n=e[rt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Pt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Nt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=r[rt]||null;if(!i)throw Error(o(90));Pt(r,i.value,i.defaultValue,i.defaultValue,i.checked,i.defaultChecked,i.type,i.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&At(r)}break a;case`textarea`:Rt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Lt(e,!!n.multiple,t,!1)}}}var en=!1;function U(e,t,n){if(en)return e(t,n);en=!0;try{return e(t)}finally{if(en=!1,(Zt!==null||Qt!==null)&&(Tu(),Zt&&(t=Zt,e=Qt,Qt=Zt=null,$t(t),e)))for(t=0;t<e.length;t++)$t(e[t])}}function tn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[rt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=!(e===`button`||e===`input`||e===`select`||e===`textarea`)),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(o(231,t,typeof n));return n}var nn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),rn=!1;if(nn)try{var an={};Object.defineProperty(an,"passive",{get:function(){rn=!0}}),window.addEventListener(`test`,an,an),window.removeEventListener(`test`,an,an)}catch{rn=!1}var on=null,sn=null,cn=null;function ln(){if(cn)return cn;var e,t=sn,n=t.length,r,i=`value`in on?on.value:on.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return cn=i.slice(e,1<r?1-r:void 0)}function un(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function dn(){return!0}function fn(){return!1}function pn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?dn:fn,this.isPropagationStopped=fn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=dn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=dn)},persist:function(){},isPersistent:dn}),t}var mn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},hn=pn(mn),gn=m({},mn,{view:0,detail:0}),_n=pn(gn),vn,yn,bn,xn=m({},gn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Mn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==bn&&(bn&&e.type===`mousemove`?(vn=e.screenX-bn.screenX,yn=e.screenY-bn.screenY):yn=vn=0,bn=e),vn)},movementY:function(e){return`movementY`in e?e.movementY:yn}}),Sn=pn(xn),Cn=pn(m({},xn,{dataTransfer:0})),wn=pn(m({},gn,{relatedTarget:0})),Tn=pn(m({},mn,{animationName:0,elapsedTime:0,pseudoElement:0})),En=pn(m({},mn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Dn=pn(m({},mn,{data:0})),On={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},kn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},An={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function jn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=An[e])?!!t[e]:!1}function Mn(){return jn}var Nn=pn(m({},gn,{key:function(e){if(e.key){var t=On[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=un(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?kn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Mn,charCode:function(e){return e.type===`keypress`?un(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?un(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Pn=pn(m({},xn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Fn=pn(m({},gn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Mn})),In=pn(m({},mn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Ln=pn(m({},xn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),Rn=pn(m({},mn,{newState:0,oldState:0})),zn=[9,13,27,32],Bn=nn&&`CompositionEvent`in window,Vn=null;nn&&`documentMode`in document&&(Vn=document.documentMode);var Hn=nn&&`TextEvent`in window&&!Vn,Un=nn&&(!Bn||Vn&&8<Vn&&11>=Vn),Wn=` `,Gn=!1;function Kn(e,t){switch(e){case`keyup`:return zn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function qn(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var Jn=!1;function Yn(e,t){switch(e){case`compositionend`:return qn(t);case`keypress`:return t.which===32?(Gn=!0,Wn):null;case`textInput`:return e=t.data,e===Wn&&Gn?null:e;default:return null}}function Xn(e,t){if(Jn)return e===`compositionend`||!Bn&&Kn(e,t)?(e=ln(),cn=sn=on=null,Jn=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return Un&&t.locale!==`ko`?null:t.data;default:return null}}var Zn={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Qn(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!Zn[e.type]:t===`textarea`}function $n(e,t,n,r){Zt?Qt?Qt.push(r):Qt=[r]:Zt=r,t=Nd(t,`onChange`),0<t.length&&(n=new hn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var er=null,tr=null;function nr(e){Td(e,0)}function rr(e){if(At(pt(e)))return e}function ir(e,t){if(e===`change`)return t}var ar=!1;if(nn){var or;if(nn){var sr=`oninput`in document;if(!sr){var cr=document.createElement(`div`);cr.setAttribute(`oninput`,`return;`),sr=typeof cr.oninput==`function`}or=sr}else or=!1;ar=or&&(!document.documentMode||9<document.documentMode)}function lr(){er&&(er.detachEvent(`onpropertychange`,ur),tr=er=null)}function ur(e){if(e.propertyName===`value`&&rr(tr)){var t=[];$n(t,tr,e,Xt(e)),U(nr,t)}}function dr(e,t,n){e===`focusin`?(lr(),er=t,tr=n,er.attachEvent(`onpropertychange`,ur)):e===`focusout`&&lr()}function fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return rr(tr)}function pr(e,t){if(e===`click`)return rr(t)}function mr(e,t){if(e===`input`||e===`change`)return rr(t)}function hr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var gr=typeof Object.is==`function`?Object.is:hr;function _r(e,t){if(gr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!ge.call(t,i)||!gr(e[i],t[i]))return!1}return!0}function vr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function yr(e,t){var n=vr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=vr(n)}}function br(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?br(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function xr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=jt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=jt(e.document)}return t}function Sr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Cr=nn&&`documentMode`in document&&11>=document.documentMode,wr=null,Tr=null,Er=null,Dr=!1;function Or(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Dr||wr==null||wr!==jt(r)||(r=wr,`selectionStart`in r&&Sr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Er&&_r(Er,r)||(Er=r,r=Nd(Tr,`onSelect`),0<r.length&&(t=new hn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=wr)))}function kr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Ar={animationend:kr(`Animation`,`AnimationEnd`),animationiteration:kr(`Animation`,`AnimationIteration`),animationstart:kr(`Animation`,`AnimationStart`),transitionrun:kr(`Transition`,`TransitionRun`),transitionstart:kr(`Transition`,`TransitionStart`),transitioncancel:kr(`Transition`,`TransitionCancel`),transitionend:kr(`Transition`,`TransitionEnd`)},jr={},Mr={};nn&&(Mr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Ar.animationend.animation,delete Ar.animationiteration.animation,delete Ar.animationstart.animation),`TransitionEvent`in window||delete Ar.transitionend.transition);function Nr(e){if(jr[e])return jr[e];if(!Ar[e])return e;var t=Ar[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Mr)return jr[e]=t[n];return e}var Pr=Nr(`animationend`),Fr=Nr(`animationiteration`),Ir=Nr(`animationstart`),Lr=Nr(`transitionrun`),Rr=Nr(`transitionstart`),zr=Nr(`transitioncancel`),Br=Nr(`transitionend`),Vr=new Map,Hr=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);Hr.push(`scrollEnd`);function Ur(e,t){Vr.set(e,t),vt(t,[e])}var Wr=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},Gr=[],Kr=0,qr=0;function Jr(){for(var e=Kr,t=qr=Kr=0;t<e;){var n=Gr[t];Gr[t++]=null;var r=Gr[t];Gr[t++]=null;var i=Gr[t];Gr[t++]=null;var a=Gr[t];if(Gr[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Qr(n,i,a)}}function Yr(e,t,n,r){Gr[Kr++]=e,Gr[Kr++]=t,Gr[Kr++]=n,Gr[Kr++]=r,qr|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function Xr(e,t,n,r){return Yr(e,t,n,r),$r(e)}function Zr(e,t){return Yr(e,null,null,t),$r(e)}function Qr(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ne(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function $r(e){if(50<gu)throw gu=0,_u=null,Error(o(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var ei={};function ti(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ni(e,t,n,r){return new ti(e,t,n,r)}function ri(e){return e=e.prototype,!(!e||!e.isReactComponent)}function ii(e,t){var n=e.alternate;return n===null?(n=ni(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function ai(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function oi(e,t,n,r,i,a){var s=0;if(r=e,typeof e==`function`)ri(e)&&(s=1);else if(typeof e==`string`)s=Zf(e,n,te.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case O:return e=ni(31,n,t,i),e.elementType=O,e.lanes=a,e;case v:return si(n.children,i,a,t);case y:s=8,i|=24;break;case b:return e=ni(12,n,t,i|2),e.elementType=b,e.lanes=a,e;case w:return e=ni(13,n,t,i),e.elementType=w,e.lanes=a,e;case T:return e=ni(19,n,t,i),e.elementType=T,e.lanes=a,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case S:s=10;break a;case x:s=9;break a;case C:s=11;break a;case E:s=14;break a;case D:s=16,r=null;break a}s=29,n=Error(o(130,e===null?`null`:typeof e,``)),r=null}return t=ni(s,n,t,i),t.elementType=e,t.type=r,t.lanes=a,t}function si(e,t,n,r){return e=ni(7,e,r,t),e.lanes=n,e}function ci(e,t,n){return e=ni(6,e,null,t),e.lanes=n,e}function li(e){var t=ni(18,null,null,0);return t.stateNode=e,t}function ui(e,t,n){return t=ni(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var di=new WeakMap;function fi(e,t){if(typeof e==`object`&&e){var n=di.get(e);return n===void 0?(t={value:e,source:t,stack:he(t)},di.set(e,t),t):n}return{value:e,source:t,stack:he(t)}}var pi=[],mi=0,hi=null,gi=0,_i=[],vi=0,yi=null,bi=1,xi=``;function Si(e,t){pi[mi++]=gi,pi[mi++]=hi,hi=e,gi=t}function Ci(e,t,n){_i[vi++]=bi,_i[vi++]=xi,_i[vi++]=yi,yi=e;var r=bi;e=xi;var i=32-Ne(r)-1;r&=~(1<<i),n+=1;var a=32-Ne(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,bi=1<<32-Ne(t)+i|n<<i|r,xi=a+e}else bi=1<<a|n<<i|r,xi=e}function wi(e){e.return!==null&&(Si(e,1),Ci(e,1,0))}function Ti(e){for(;e===hi;)hi=pi[--mi],pi[mi]=null,gi=pi[--mi],pi[mi]=null;for(;e===yi;)yi=_i[--vi],_i[vi]=null,xi=_i[--vi],_i[vi]=null,bi=_i[--vi],_i[vi]=null}function Ei(e,t){_i[vi++]=bi,_i[vi++]=xi,_i[vi++]=yi,bi=t.id,xi=t.overflow,yi=e}var Di=null,Oi=null,ki=!1,Ai=null,ji=!1,Mi=Error(o(519));function Ni(e){throw zi(fi(Error(o(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Mi}function Pi(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[nt]=e,t[rt]=r,n){case`dialog`:Ed(`cancel`,t),Ed(`close`,t);break;case`iframe`:case`object`:case`embed`:Ed(`load`,t);break;case`video`:case`audio`:for(n=0;n<Cd.length;n++)Ed(Cd[n],t);break;case`source`:Ed(`error`,t);break;case`img`:case`image`:case`link`:Ed(`error`,t),Ed(`load`,t);break;case`details`:Ed(`toggle`,t);break;case`input`:Ed(`invalid`,t),Ft(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Ed(`invalid`,t);break;case`textarea`:Ed(`invalid`,t),zt(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||zd(t.textContent,n)?(r.popover!=null&&(Ed(`beforetoggle`,t),Ed(`toggle`,t)),r.onScroll!=null&&Ed(`scroll`,t),r.onScrollEnd!=null&&Ed(`scrollend`,t),r.onClick!=null&&(t.onclick=Jt),t=!0):t=!1,t||Ni(e,!0)}function Fi(e){for(Di=e.return;Di;)switch(Di.tag){case 5:case 31:case 13:ji=!1;return;case 27:case 3:ji=!0;return;default:Di=Di.return}}function Ii(e){if(e!==Di)return!1;if(!ki)return Fi(e),ki=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=!(n!==`form`&&n!==`button`)||Zd(e.type,e.memoizedProps)),n=!n),n&&Oi&&Ni(e),Fi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));Oi=vf(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(317));Oi=vf(e)}else t===27?(t=Oi,of(e.type)?(e=_f,_f=null,Oi=e):Oi=t):Oi=Di?gf(e.stateNode.nextSibling):null;return!0}function Li(){Oi=Di=null,ki=!1}function Ri(){var e=Ai;return e!==null&&(nu===null?nu=e:nu.push.apply(nu,e),Ai=null),e}function zi(e){Ai===null?Ai=[e]:Ai.push(e)}var Bi=z(null),Vi=null,Hi=null;function Ui(e,t,n){V(Bi,t._currentValue),t._currentValue=n}function Wi(e){e._currentValue=Bi.current,B(Bi)}function Gi(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function Ki(e,t,n,r){var i=e.child;for(i!==null&&(i.return=e);i!==null;){var a=i.dependencies;if(a!==null){var s=i.child;a=a.firstContext;a:for(;a!==null;){var c=a;a=i;for(var l=0;l<t.length;l++)if(c.context===t[l]){a.lanes|=n,c=a.alternate,c!==null&&(c.lanes|=n),Gi(a.return,n,e),r||(s=null);break a}a=c.next}}else if(i.tag===18){if(s=i.return,s===null)throw Error(o(341));s.lanes|=n,a=s.alternate,a!==null&&(a.lanes|=n),Gi(s,n,e),s=null}else s=i.child;if(s!==null)s.return=i;else for(s=i;s!==null;){if(s===e){s=null;break}if(i=s.sibling,i!==null){i.return=s.return,s=i;break}s=s.return}i=s}}function qi(e,t,n,r){e=null;for(var i=t,a=!1;i!==null;){if(!a){if(i.flags&524288)a=!0;else if(i.flags&262144)break}if(i.tag===10){var s=i.alternate;if(s===null)throw Error(o(387));if(s=s.memoizedProps,s!==null){var c=i.type;gr(i.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(i===ie.current){if(s=i.alternate,s===null)throw Error(o(387));s.memoizedState.memoizedState!==i.memoizedState.memoizedState&&(e===null?e=[op]:e.push(op))}i=i.return}e!==null&&Ki(t,e,n,r),t.flags|=262144}function Ji(e){for(e=e.firstContext;e!==null;){if(!gr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Yi(e){Vi=e,Hi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function Xi(e){return Qi(Vi,e)}function Zi(e,t){return Vi===null&&Yi(e),Qi(e,t)}function Qi(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Hi===null){if(e===null)throw Error(o(308));Hi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Hi=Hi.next=t;return n}var $i=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},ea=r.unstable_scheduleCallback,ta=r.unstable_NormalPriority,na={$$typeof:S,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ra(){return{controller:new $i,data:new Map,refCount:0}}function ia(e){e.refCount--,e.refCount===0&&ea(ta,function(){e.controller.abort()})}var aa=null,oa=0,sa=0,ca=null;function la(e,t){if(aa===null){var n=aa=[];oa=0,sa=_d(),ca={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return oa++,t.then(ua,ua),t}function ua(){if(--oa===0&&aa!==null){ca!==null&&(ca.status=`fulfilled`);var e=aa;aa=null,sa=0,ca=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function da(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var fa=F.S;F.S=function(e,t){au=xe(),typeof t==`object`&&t&&typeof t.then==`function`&&la(e,t),fa!==null&&fa(e,t)};var pa=z(null);function ma(){var e=pa.current;return e===null?Bl.pooledCache:e}function ha(e,t){t===null?V(pa,pa.current):V(pa,t.pool)}function ga(){var e=ma();return e===null?null:{parent:na._currentValue,pool:e}}var _a=Error(o(460)),va=Error(o(474)),ya=Error(o(542)),ba={then:function(){}};function xa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Sa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(Jt,Jt),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ea(e),e;default:if(typeof t.status==`string`)t.then(Jt,Jt);else{if(e=Bl,e!==null&&100<e.shellSuspendCounter)throw Error(o(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Ea(e),e}throw wa=t,_a}}function Ca(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(wa=e,_a):e}}var wa=null;function Ta(){if(wa===null)throw Error(o(459));var e=wa;return wa=null,e}function Ea(e){if(e===_a||e===ya)throw Error(o(483))}var Da=null,Oa=0;function ka(e){var t=Oa;return Oa+=1,Da===null&&(Da=[]),Sa(Da,e,t)}function Aa(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function ja(e,t){throw t.$$typeof===h?Error(o(525)):(e=Object.prototype.toString.call(t),Error(o(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ma(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function i(e,t){return e=ii(e,t),e.index=0,e.sibling=null,e}function a(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=ci(n,e.mode,r),t.return=e,t):(t=i(t,n),t.return=e,t)}function l(e,t,n,r){var a=n.type;return a===v?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===a||typeof a==`object`&&a&&a.$$typeof===D&&Ca(a)===t.type)?(t=i(t,n.props),Aa(t,n),t.return=e,t):(t=oi(n.type,n.key,n.props,null,e.mode,r),Aa(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=ui(n,e.mode,r),t.return=e,t):(t=i(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,a){return t===null||t.tag!==7?(t=si(n,e.mode,r,a),t.return=e,t):(t=i(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=ci(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case g:return n=oi(t.type,t.key,t.props,null,e.mode,n),Aa(n,t),n.return=e,n;case _:return t=ui(t,e.mode,n),t.return=e,t;case D:return t=Ca(t),f(e,t,n)}if(P(t)||j(t))return t=si(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,ka(t),n);if(t.$$typeof===S)return f(e,Zi(e,t),n);ja(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case g:return n.key===i?l(e,t,n,r):null;case _:return n.key===i?u(e,t,n,r):null;case D:return n=Ca(n),p(e,t,n,r)}if(P(n)||j(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,ka(n),r);if(n.$$typeof===S)return p(e,t,Zi(e,n),r);ja(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case g:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case _:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case D:return r=Ca(r),m(e,t,n,r,i)}if(P(r)||j(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,ka(r),i);if(r.$$typeof===S)return m(e,t,n,Zi(t,r),i);ja(t,r)}return null}function h(i,o,s,c){for(var l=null,u=null,d=o,h=o=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),ki&&Si(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(o=a(d,o,h),u===null?l=d:u.sibling=d,u=d);return ki&&Si(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),o=a(g,o,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),ki&&Si(i,h),l}function y(i,s,c,l){if(c==null)throw Error(o(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),ki&&Si(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return ki&&Si(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),ki&&Si(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===v&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case g:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===v){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===D&&Ca(l)===r.type){n(e,r.sibling),c=i(r,a.props),Aa(c,a),c.return=e,e=c;break a}n(e,r);break}else t(e,r);r=r.sibling}a.type===v?(c=si(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=oi(a.type,a.key,a.props,null,e.mode,c),Aa(c,a),c.return=e,e=c)}return s(e);case _:a:{for(l=a.key;r!==null;){if(r.key===l)if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}else{n(e,r);break}else t(e,r);r=r.sibling}c=ui(a,e.mode,c),c.return=e,e=c}return s(e);case D:return a=Ca(a),b(e,r,a,c)}if(P(a))return h(e,r,a,c);if(j(a)){if(l=j(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),y(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,ka(a),c);if(a.$$typeof===S)return b(e,r,Zi(e,a),c);ja(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=ci(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Oa=0;var i=b(e,t,n,r);return Da=null,i}catch(t){if(t===_a||t===ya)throw t;var a=ni(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Na=Ma(!0),Pa=Ma(!1),Fa=!1;function Ia(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function La(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ra(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function za(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,zl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=$r(e),Qr(e,null,n),t}return Yr(e,r,t,n),$r(e)}function Ba(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ye(e,n)}}function Va(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Ha=!1;function Ua(){if(Ha){var e=ca;if(e!==null)throw e}}function Wa(e,t,n,r){Ha=!1;var i=e.updateQueue;Fa=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(Hl&f)===f:(r&f)===f){f!==0&&f===sa&&(Ha=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Fa=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Xl|=o,e.lanes=o,e.memoizedState=d}}function Ga(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function Ka(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Ga(n[e],t)}var qa=z(null),Ja=z(0);function Ya(e,t){e=Jl,V(Ja,e),V(qa,t),Jl=e|t.baseLanes}function Xa(){V(Ja,Jl),V(qa,qa.current)}function Za(){Jl=Ja.current,B(qa),B(Ja)}var Qa=z(null),$a=null;function eo(e){var t=e.alternate;V(ao,ao.current&1),V(Qa,e),$a===null&&(t===null||qa.current!==null||t.memoizedState!==null)&&($a=e)}function to(e){V(ao,ao.current),V(Qa,e),$a===null&&($a=e)}function no(e){e.tag===22?(V(ao,ao.current),V(Qa,e),$a===null&&($a=e)):ro(e)}function ro(){V(ao,ao.current),V(Qa,Qa.current)}function io(e){B(Qa),$a===e&&($a=null),B(ao)}var ao=z(0);function oo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||pf(n)||mf(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var so=0,co=null,lo=null,uo=null,fo=!1,po=!1,mo=!1,ho=0,go=0,_o=null,vo=0;function yo(){throw Error(o(321))}function bo(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!gr(e[n],t[n]))return!1;return!0}function xo(e,t,n,r,i,a){return so=a,co=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,F.H=e===null||e.memoizedState===null?Ls:Rs,mo=!1,a=n(r,i),mo=!1,po&&(a=Co(t,n,r,i)),So(e),a}function So(e){F.H=Is;var t=lo!==null&&lo.next!==null;if(so=0,uo=lo=co=null,fo=!1,go=0,_o=null,t)throw Error(o(300));e===null||tc||(e=e.dependencies,e!==null&&Ji(e)&&(tc=!0))}function Co(e,t,n,r){co=e;var i=0;do{if(po&&(_o=null),go=0,po=!1,25<=i)throw Error(o(301));if(i+=1,uo=lo=null,e.updateQueue!=null){var a=e.updateQueue;a.lastEffect=null,a.events=null,a.stores=null,a.memoCache!=null&&(a.memoCache.index=0)}F.H=zs,a=t(n,r)}while(po);return a}function wo(){var e=F.H,t=e.useState()[0];return t=typeof t.then==`function`?Ao(t):t,e=e.useState()[0],(lo===null?null:lo.memoizedState)!==e&&(co.flags|=1024),t}function To(){var e=ho!==0;return ho=0,e}function W(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Eo(e){if(fo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}fo=!1}so=0,uo=lo=co=null,po=!1,go=ho=0,_o=null}function Do(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return uo===null?co.memoizedState=uo=e:uo=uo.next=e,uo}function Oo(){if(lo===null){var e=co.alternate;e=e===null?null:e.memoizedState}else e=lo.next;var t=uo===null?co.memoizedState:uo.next;if(t!==null)uo=t,lo=e;else{if(e===null)throw co.alternate===null?Error(o(467)):Error(o(310));lo=e,e={memoizedState:lo.memoizedState,baseState:lo.baseState,baseQueue:lo.baseQueue,queue:lo.queue,next:null},uo===null?co.memoizedState=uo=e:uo=uo.next=e}return uo}function ko(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ao(e){var t=go;return go+=1,_o===null&&(_o=[]),e=Sa(_o,e,t),t=co,(uo===null?t.memoizedState:uo.next)===null&&(t=t.alternate,F.H=t===null||t.memoizedState===null?Ls:Rs),e}function jo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Ao(e);if(e.$$typeof===S)return Xi(e)}throw Error(o(438,String(e)))}function Mo(e){var t=null,n=co.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=co.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ko(),co.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=k;return t.index++,n}function No(e,t){return typeof t==`function`?t(e):t}function Po(e){return Fo(Oo(),lo,e)}function Fo(e,t,n){var r=e.queue;if(r===null)throw Error(o(311));r.lastRenderedReducer=n;var i=e.baseQueue,a=r.pending;if(a!==null){if(i!==null){var s=i.next;i.next=a.next,a.next=s}t.baseQueue=i=a,r.pending=null}if(a=e.baseState,i===null)e.memoizedState=a;else{t=i.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(so&f)===f:(Hl&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===sa&&(d=!0);else if((so&p)===p){u=u.next,p===sa&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=a):l=l.next=f,co.lanes|=p,Xl|=p;f=u.action,mo&&n(a,f),a=u.hasEagerState?u.eagerState:n(a,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=a):l=l.next=p,co.lanes|=f,Xl|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=a:l.next=c,!gr(a,e.memoizedState)&&(tc=!0,d&&(n=ca,n!==null)))throw n;e.memoizedState=a,e.baseState=s,e.baseQueue=l,r.lastRenderedState=a}return i===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Io(e){var t=Oo(),n=t.queue;if(n===null)throw Error(o(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,a=t.memoizedState;if(i!==null){n.pending=null;var s=i=i.next;do a=e(a,s.action),s=s.next;while(s!==i);gr(a,t.memoizedState)||(tc=!0),t.memoizedState=a,t.baseQueue===null&&(t.baseState=a),n.lastRenderedState=a}return[a,r]}function Lo(e,t,n){var r=co,i=Oo(),a=ki;if(a){if(n===void 0)throw Error(o(407));n=n()}else n=t();var s=!gr((lo||i).memoizedState,n);if(s&&(i.memoizedState=n,tc=!0),i=i.queue,cs(Bo.bind(null,r,i,e),[e]),i.getSnapshot!==t||s||uo!==null&&uo.memoizedState.tag&1){if(r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,i,n,t),null),Bl===null)throw Error(o(349));a||so&127||Ro(r,t,n)}return n}function Ro(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=co.updateQueue,t===null?(t=ko(),co.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function zo(e,t,n,r){t.value=n,t.getSnapshot=r,Vo(t)&&Ho(e)}function Bo(e,t,n){return n(function(){Vo(t)&&Ho(e)})}function Vo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!gr(e,n)}catch{return!0}}function Ho(e){var t=Zr(e,2);t!==null&&bu(t,e,2)}function Uo(e){var t=Do();if(typeof e==`function`){var n=e;if(e=n(),mo){Me(!0);try{n()}finally{Me(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:e},t}function Wo(e,t,n,r){return e.baseState=n,Fo(e,lo,typeof r==`function`?r:No)}function Go(e,t,n,r,i){if(Ns(e))throw Error(o(485));if(e=t.action,e!==null){var a={payload:i,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){a.listeners.push(e)}};F.T===null?a.isTransition=!1:n(!0),r(a),n=t.pending,n===null?(a.next=t.pending=a,Ko(t,a)):(a.next=n.next,t.pending=n.next=a)}}function Ko(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=F.T,o={};F.T=o;try{var s=n(i,r),c=F.S;c!==null&&c(o,s),qo(e,t,s)}catch(n){Yo(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),F.T=a}}else try{a=n(i,r),qo(e,t,a)}catch(n){Yo(e,t,n)}}function qo(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Jo(e,t,n)},function(n){return Yo(e,t,n)}):Jo(e,t,n)}function Jo(e,t,n){t.status=`fulfilled`,t.value=n,Xo(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Ko(e,n)))}function Yo(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,Xo(t),t=t.next;while(t!==r)}e.action=null}function Xo(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function Zo(e,t){return t}function Qo(e,t){if(ki){var n=Bl.formState;if(n!==null){a:{var r=co;if(ki){if(Oi){b:{for(var i=Oi,a=ji;i.nodeType!==8;){if(!a){i=null;break b}if(i=gf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Oi=gf(i.nextSibling),r=i.data===`F!`;break a}}Ni(r)}r=!1}r&&(t=n[0])}}return n=Do(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Zo,lastRenderedState:t},n.queue=r,n=As.bind(null,co,r),r.dispatch=n,r=Uo(!1),a=Ms.bind(null,co,!1,r.queue),r=Do(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Go.bind(null,co,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function $o(e){return es(Oo(),lo,e)}function es(e,t,n){if(t=Fo(e,t,Zo)[0],e=Po(No)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Ao(t)}catch(e){throw e===_a?ya:e}else r=t;t=Oo();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(co.flags|=2048,rs(9,{destroy:void 0},ts.bind(null,i,n),null)),[r,a,e]}function ts(e,t){e.action=t}function ns(e){var t=Oo(),n=lo;if(n!==null)return es(t,n,e);Oo(),t=t.memoizedState,n=Oo();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function rs(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=co.updateQueue,t===null&&(t=ko(),co.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function is(){return Oo().memoizedState}function as(e,t,n,r){var i=Do();co.flags|=e,i.memoizedState=rs(1|t,{destroy:void 0},n,r===void 0?null:r)}function os(e,t,n,r){var i=Oo();r=r===void 0?null:r;var a=i.memoizedState.inst;lo!==null&&r!==null&&bo(r,lo.memoizedState.deps)?i.memoizedState=rs(t,a,n,r):(co.flags|=e,i.memoizedState=rs(1|t,a,n,r))}function ss(e,t){as(8390656,8,e,t)}function cs(e,t){os(2048,8,e,t)}function ls(e){co.flags|=4;var t=co.updateQueue;if(t===null)t=ko(),co.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function us(e){var t=Oo().memoizedState;return ls({ref:t,nextImpl:e}),function(){if(zl&2)throw Error(o(440));return t.impl.apply(void 0,arguments)}}function ds(e,t){return os(4,2,e,t)}function fs(e,t){return os(4,4,e,t)}function ps(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function ms(e,t,n){n=n==null?null:n.concat([e]),os(4,4,ps.bind(null,t,e),n)}function hs(){}function gs(e,t){var n=Oo();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&bo(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function _s(e,t){var n=Oo();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&bo(t,r[1]))return r[0];if(r=e(),mo){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r}function vs(e,t,n){return n===void 0||so&1073741824&&!(Hl&261930)?e.memoizedState=t:(e.memoizedState=n,e=yu(),co.lanes|=e,Xl|=e,n)}function ys(e,t,n,r){return gr(n,t)?n:qa.current===null?!(so&42)||so&1073741824&&!(Hl&261930)?(tc=!0,e.memoizedState=n):(e=yu(),co.lanes|=e,Xl|=e,t):(e=vs(e,n,r),gr(e,t)||(tc=!0),e)}function bs(e,t,n,r,i){var a=I.p;I.p=a!==0&&8>a?a:8;var o=F.T,s={};F.T=s,Ms(e,!1,t,n);try{var c=i(),l=F.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?js(e,t,da(c,r),vu(e)):js(e,t,r,vu(e))}catch(n){js(e,t,{then:function(){},status:`rejected`,reason:n},vu())}finally{I.p=a,o!==null&&s.types!==null&&(o.types=s.types),F.T=o}}function xs(){}function Ss(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Cs(e).queue;bs(e,i,t,L,n===null?xs:function(){return ws(e),n(r)})}function Cs(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:L,baseState:L,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:L},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:No,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ws(e){var t=Cs(e);t.next===null&&(t=e.alternate.memoizedState),js(e,t.next.queue,{},vu())}function Ts(){return Xi(op)}function Es(){return Oo().memoizedState}function Ds(){return Oo().memoizedState}function Os(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=vu();e=Ra(n);var r=za(t,e,n);r!==null&&(bu(r,t,n),Ba(r,t,n)),t={cache:ra()},e.payload=t;return}t=t.return}}function ks(e,t,n){var r=vu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ns(e)?Ps(t,n):(n=Xr(e,t,n,r),n!==null&&(bu(n,e,r),Fs(n,t,r)))}function As(e,t,n){js(e,t,n,vu())}function js(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ns(e))Ps(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,gr(s,o))return Yr(e,t,i,0),Bl===null&&Jr(),!1}catch{}if(n=Xr(e,t,i,r),n!==null)return bu(n,e,r),Fs(n,t,r),!0}return!1}function Ms(e,t,n,r){if(r={lane:2,revertLane:_d(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ns(e)){if(t)throw Error(o(479))}else t=Xr(e,n,r,2),t!==null&&bu(t,e,2)}function Ns(e){var t=e.alternate;return e===co||t!==null&&t===co}function Ps(e,t){po=fo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Fs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Ye(e,n)}}var Is={readContext:Xi,use:jo,useCallback:yo,useContext:yo,useEffect:yo,useImperativeHandle:yo,useLayoutEffect:yo,useInsertionEffect:yo,useMemo:yo,useReducer:yo,useRef:yo,useState:yo,useDebugValue:yo,useDeferredValue:yo,useTransition:yo,useSyncExternalStore:yo,useId:yo,useHostTransitionStatus:yo,useFormState:yo,useActionState:yo,useOptimistic:yo,useMemoCache:yo,useCacheRefresh:yo};Is.useEffectEvent=yo;var Ls={readContext:Xi,use:jo,useCallback:function(e,t){return Do().memoizedState=[e,t===void 0?null:t],e},useContext:Xi,useEffect:ss,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),as(4194308,4,ps.bind(null,t,e),n)},useLayoutEffect:function(e,t){return as(4194308,4,e,t)},useInsertionEffect:function(e,t){as(4,2,e,t)},useMemo:function(e,t){var n=Do();t=t===void 0?null:t;var r=e();if(mo){Me(!0);try{e()}finally{Me(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Do();if(n!==void 0){var i=n(t);if(mo){Me(!0);try{n(t)}finally{Me(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=ks.bind(null,co,e),[r.memoizedState,e]},useRef:function(e){var t=Do();return e={current:e},t.memoizedState=e},useState:function(e){e=Uo(e);var t=e.queue,n=As.bind(null,co,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:hs,useDeferredValue:function(e,t){return vs(Do(),e,t)},useTransition:function(){var e=Uo(!1);return e=bs.bind(null,co,e.queue,!0,!1),Do().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=co,i=Do();if(ki){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),Bl===null)throw Error(o(349));Hl&127||Ro(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,ss(Bo.bind(null,r,a,e),[e]),r.flags|=2048,rs(9,{destroy:void 0},zo.bind(null,r,a,n,t),null),n},useId:function(){var e=Do(),t=Bl.identifierPrefix;if(ki){var n=xi,r=bi;n=(r&~(1<<32-Ne(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=ho++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=vo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Ts,useFormState:Qo,useActionState:Qo,useOptimistic:function(e){var t=Do();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Ms.bind(null,co,!0,n),n.dispatch=t,[e,t]},useMemoCache:Mo,useCacheRefresh:function(){return Do().memoizedState=Os.bind(null,co)},useEffectEvent:function(e){var t=Do(),n={impl:e};return t.memoizedState=n,function(){if(zl&2)throw Error(o(440));return n.impl.apply(void 0,arguments)}}},Rs={readContext:Xi,use:jo,useCallback:gs,useContext:Xi,useEffect:cs,useImperativeHandle:ms,useInsertionEffect:ds,useLayoutEffect:fs,useMemo:_s,useReducer:Po,useRef:is,useState:function(){return Po(No)},useDebugValue:hs,useDeferredValue:function(e,t){return ys(Oo(),lo.memoizedState,e,t)},useTransition:function(){var e=Po(No)[0],t=Oo().memoizedState;return[typeof e==`boolean`?e:Ao(e),t]},useSyncExternalStore:Lo,useId:Es,useHostTransitionStatus:Ts,useFormState:$o,useActionState:$o,useOptimistic:function(e,t){return Wo(Oo(),lo,e,t)},useMemoCache:Mo,useCacheRefresh:Ds};Rs.useEffectEvent=us;var zs={readContext:Xi,use:jo,useCallback:gs,useContext:Xi,useEffect:cs,useImperativeHandle:ms,useInsertionEffect:ds,useLayoutEffect:fs,useMemo:_s,useReducer:Io,useRef:is,useState:function(){return Io(No)},useDebugValue:hs,useDeferredValue:function(e,t){var n=Oo();return lo===null?vs(n,e,t):ys(n,lo.memoizedState,e,t)},useTransition:function(){var e=Io(No)[0],t=Oo().memoizedState;return[typeof e==`boolean`?e:Ao(e),t]},useSyncExternalStore:Lo,useId:Es,useHostTransitionStatus:Ts,useFormState:ns,useActionState:ns,useOptimistic:function(e,t){var n=Oo();return lo===null?(n.baseState=e,[e,n.queue.dispatch]):Wo(n,lo,e,t)},useMemoCache:Mo,useCacheRefresh:Ds};zs.useEffectEvent=us;function Bs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Vs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=vu(),i=Ra(r);i.payload=t,n!=null&&(i.callback=n),t=za(e,i,r),t!==null&&(bu(t,e,r),Ba(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=vu(),i=Ra(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=za(e,i,r),t!==null&&(bu(t,e,r),Ba(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=vu(),r=Ra(n);r.tag=2,t!=null&&(r.callback=t),t=za(e,r,n),t!==null&&(bu(t,e,n),Ba(t,e,n))}};function Hs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!_r(n,r)||!_r(i,a):!0}function Us(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Vs.enqueueReplaceState(t,t.state,null)}function Ws(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Gs(e){Wr(e)}function Ks(e){console.error(e)}function qs(e){Wr(e)}function Js(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function Ys(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Xs(e,t,n){return n=Ra(n),n.tag=3,n.payload={element:null},n.callback=function(){Js(e,t)},n}function Zs(e){return e=Ra(e),e.tag=3,e}function Qs(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){Ys(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){Ys(t,n,r),typeof i!=`function`&&(cu===null?cu=new Set([this]):cu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function $s(e,t,n,r,i){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&qi(t,n,i,!0),n=Qa.current,n!==null){switch(n.tag){case 31:case 13:return $a===null?Mu():n.alternate===null&&Yl===0&&(Yl=3),n.flags&=-257,n.flags|=65536,n.lanes=i,r===ba?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Zu(e,r,i)),!1;case 22:return n.flags|=65536,r===ba?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Zu(e,r,i)),!1}throw Error(o(435,n.tag))}return Zu(e,r,i),Mu(),!1}if(ki)return t=Qa.current,t===null?(r!==Mi&&(t=Error(o(423),{cause:r}),zi(fi(t,n))),e=e.current.alternate,e.flags|=65536,i&=-i,e.lanes|=i,r=fi(r,n),i=Xs(e.stateNode,r,i),Va(e,i),Yl!==4&&(Yl=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=i,r!==Mi&&(e=Error(o(422),{cause:r}),zi(fi(e,n)))),!1;var a=Error(o(520),{cause:r});if(a=fi(a,n),tu===null?tu=[a]:tu.push(a),Yl!==4&&(Yl=2),t===null)return!0;r=fi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=i&-i,n.lanes|=e,e=Xs(n.stateNode,r,e),Va(n,e),!1;case 1:if(t=n.type,a=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||a!==null&&typeof a.componentDidCatch==`function`&&(cu===null||!cu.has(a))))return n.flags|=65536,i&=-i,n.lanes|=i,i=Zs(i),Qs(i,e,n,r),Va(n,i),!1}n=n.return}while(n!==null);return!1}var ec=Error(o(461)),tc=!1;function nc(e,t,n,r){t.child=e===null?Pa(t,null,n,r):Na(t,e.child,n,r)}function rc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Yi(t),r=xo(e,t,n,o,a,i),s=To(),e!==null&&!tc?(W(e,t,i),Dc(e,t,i)):(ki&&s&&wi(t),t.flags|=1,nc(e,t,r,i),t.child)}function ic(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ri(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,ac(e,t,a,r,i)):(e=oi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Oc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?_r:n,n(o,r)&&e.ref===t.ref)return Dc(e,t,i)}return t.flags|=1,e=ii(a,r),e.ref=t.ref,e.return=t,t.child=e}function ac(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(_r(a,r)&&e.ref===t.ref)if(tc=!1,t.pendingProps=r=a,Oc(e,i))e.flags&131072&&(tc=!0);else return t.lanes=e.lanes,Dc(e,t,i)}return pc(e,t,n,r,i)}function oc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return cc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&ha(t,a===null?null:a.cachePool),a===null?Xa():Ya(t,a),no(t);else return r=t.lanes=536870912,cc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&ha(t,null),Xa(),ro(t)):(ha(t,a.cachePool),Ya(t,a),ro(t),t.memoizedState=null);return nc(e,t,i,n),t.child}function sc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function cc(e,t,n,r,i){var a=ma();return a=a===null?null:{parent:na._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&ha(t,null),Xa(),no(t),e!==null&&qi(e,t,r,!0),t.childLanes=i,null}function lc(e,t){return t=Sc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function uc(e,t,n){return Na(t,e.child,null,n),e=lc(t,t.pendingProps),e.flags|=2,io(t),t.memoizedState=null,e}function dc(e,t,n){var r=t.pendingProps,i=(t.flags&128)!=0;if(t.flags&=-129,e===null){if(ki){if(r.mode===`hidden`)return e=lc(t,r),t.lanes=536870912,sc(null,e);if(to(t),(e=Oi)?(e=ff(e,ji),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:yi===null?null:{id:bi,overflow:xi},retryLane:536870912,hydrationErrors:null},n=li(e),n.return=t,t.child=n,Di=t,Oi=null)):e=null,e===null)throw Ni(t);return t.lanes=536870912,null}return lc(t,r)}var a=e.memoizedState;if(a!==null){var s=a.dehydrated;if(to(t),i)if(t.flags&256)t.flags&=-257,t=uc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(o(558));else if(tc||qi(e,t,n,!1),i=(n&e.childLanes)!==0,tc||i){if(r=Bl,r!==null&&(s=Xe(r,n),s!==0&&s!==a.retryLane))throw a.retryLane=s,Zr(e,s),bu(r,e,s),ec;Mu(),t=uc(e,t,n)}else e=a.treeContext,Oi=gf(s.nextSibling),Di=t,ki=!0,Ai=null,ji=!1,e!==null&&Ei(t,e),t=lc(t,r),t.flags|=4096;return t}return e=ii(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function fc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(o(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function pc(e,t,n,r,i){return Yi(t),n=xo(e,t,n,r,void 0,i),r=To(),e!==null&&!tc?(W(e,t,i),Dc(e,t,i)):(ki&&r&&wi(t),t.flags|=1,nc(e,t,n,i),t.child)}function mc(e,t,n,r,i,a){return Yi(t),t.updateQueue=null,n=Co(t,r,n,i),So(e),r=To(),e!==null&&!tc?(W(e,t,a),Dc(e,t,a)):(ki&&r&&wi(t),t.flags|=1,nc(e,t,n,a),t.child)}function hc(e,t,n,r,i){if(Yi(t),t.stateNode===null){var a=ei,o=n.contextType;typeof o==`object`&&o&&(a=Xi(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Vs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ia(t),o=n.contextType,a.context=typeof o==`object`&&o?Xi(o):ei,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Bs(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Vs.enqueueReplaceState(a,a.state,null),Wa(t,r,a,i),Ua(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Ws(n,s);a.props=c;var l=a.context,u=n.contextType;o=ei,typeof u==`object`&&u&&(o=Xi(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Us(t,a,r,o),Fa=!1;var f=t.memoizedState;a.state=f,Wa(t,r,a,i),Ua(),l=t.memoizedState,s||f!==l||Fa?(typeof d==`function`&&(Bs(t,n,d,r),l=t.memoizedState),(c=Fa||Hs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,La(e,t),o=t.memoizedProps,u=Ws(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=ei,typeof l==`object`&&l&&(c=Xi(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Us(t,a,r,c),Fa=!1,f=t.memoizedState,a.state=f,Wa(t,r,a,i),Ua();var p=t.memoizedState;o!==d||f!==p||Fa||e!==null&&e.dependencies!==null&&Ji(e.dependencies)?(typeof s==`function`&&(Bs(t,n,s,r),p=t.memoizedState),(u=Fa||Hs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Ji(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,fc(e,t),r=(t.flags&128)!=0,a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Na(t,e.child,null,i),t.child=Na(t,null,n,i)):nc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Dc(e,t,i),e}function gc(e,t,n,r){return Li(),t.flags|=256,nc(e,t,n,r),t.child}var _c={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function vc(e){return{baseLanes:e,cachePool:ga()}}function yc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=$l),e}function bc(e,t,n){var r=t.pendingProps,i=!1,a=(t.flags&128)!=0,s;if((s=a)||(s=e!==null&&e.memoizedState===null?!1:(ao.current&2)!=0),s&&(i=!0,t.flags&=-129),s=(t.flags&32)!=0,t.flags&=-33,e===null){if(ki){if(i?eo(t):ro(t),(e=Oi)?(e=ff(e,ji),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:yi===null?null:{id:bi,overflow:xi},retryLane:536870912,hydrationErrors:null},n=li(e),n.return=t,t.child=n,Di=t,Oi=null)):e=null,e===null)throw Ni(t);return mf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,i?(ro(t),i=t.mode,c=Sc({mode:`hidden`,children:c},i),r=si(r,i,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=vc(n),r.childLanes=yc(e,s,n),t.memoizedState=_c,sc(null,r)):(eo(t),xc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(a)t.flags&256?(eo(t),t.flags&=-257,t=Cc(e,t,n)):t.memoizedState===null?(ro(t),c=r.fallback,i=t.mode,r=Sc({mode:`visible`,children:r.children},i),c=si(c,i,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Na(t,e.child,null,n),r=t.child,r.memoizedState=vc(n),r.childLanes=yc(e,s,n),t.memoizedState=_c,t=sc(null,r)):(ro(t),t.child=e.child,t.flags|=128,t=null);else if(eo(t),mf(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(o(419)),r.stack=``,r.digest=s,zi({value:r,source:null,stack:null}),t=Cc(e,t,n)}else if(tc||qi(e,t,n,!1),s=(n&e.childLanes)!==0,tc||s){if(s=Bl,s!==null&&(r=Xe(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,Zr(e,r),bu(s,e,r),ec;pf(c)||Mu(),t=Cc(e,t,n)}else pf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Oi=gf(c.nextSibling),Di=t,ki=!0,Ai=null,ji=!1,e!==null&&Ei(t,e),t=xc(t,r.children),t.flags|=4096);return t}return i?(ro(t),c=r.fallback,i=t.mode,l=e.child,u=l.sibling,r=ii(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=si(c,i,n,null),c.flags|=2):c=ii(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,sc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=vc(n):(i=c.cachePool,i===null?i=ga():(l=na._currentValue,i=i.parent===l?i:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:i}),r.memoizedState=c,r.childLanes=yc(e,s,n),t.memoizedState=_c,sc(e.child,r)):(eo(t),n=e.child,e=n.sibling,n=ii(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function xc(e,t){return t=Sc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Sc(e,t){return e=ni(22,e,null,t),e.lanes=0,e}function Cc(e,t,n){return Na(t,e.child,null,n),e=xc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function wc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Gi(e.return,t,n)}function Tc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Ec(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ao.current,s=(o&2)!=0;if(s?(o=o&1|2,t.flags|=128):o&=1,V(ao,o),nc(e,t,r,n),r=ki?gi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&wc(e,n,t);else if(e.tag===19)wc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&oo(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Tc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&oo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Tc(t,!0,n,null,a,r);break;case`together`:Tc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Dc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),Xl|=t.lanes,(n&t.childLanes)===0)if(e!==null){if(qi(e,t,n,!1),(n&t.childLanes)===0)return null}else return null;if(e!==null&&t.child!==e.child)throw Error(o(153));if(t.child!==null){for(e=t.child,n=ii(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=ii(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Oc(e,t){return(e.lanes&t)===0?(e=e.dependencies,!!(e!==null&&Ji(e))):!0}function kc(e,t,n){switch(t.tag){case 3:ae(t,t.stateNode.containerInfo),Ui(t,na,e.memoizedState.cache),Li();break;case 27:case 5:se(t);break;case 4:ae(t,t.stateNode.containerInfo);break;case 10:Ui(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,to(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(eo(t),e=Dc(e,t,n),e===null?null:e.sibling):bc(e,t,n):(eo(t),t.flags|=128,null);eo(t);break;case 19:var i=(e.flags&128)!=0;if(r=(n&t.childLanes)!==0,r||=(qi(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Ec(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),V(ao,ao.current),r)break;return null;case 22:return t.lanes=0,oc(e,t,n,t.pendingProps);case 24:Ui(t,na,e.memoizedState.cache)}return Dc(e,t,n)}function Ac(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps)tc=!0;else{if(!Oc(e,n)&&!(t.flags&128))return tc=!1,kc(e,t,n);tc=!!(e.flags&131072)}else tc=!1,ki&&t.flags&1048576&&Ci(t,gi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ca(t.elementType),t.type=e,typeof e==`function`)ri(e)?(r=Ws(e,r),t.tag=1,t=hc(null,t,e,r,n)):(t.tag=0,t=pc(null,t,e,r,n));else{if(e!=null){var i=e.$$typeof;if(i===C){t.tag=11,t=rc(null,t,e,r,n);break a}else if(i===E){t.tag=14,t=ic(null,t,e,r,n);break a}}throw t=N(e)||e,Error(o(306,t,``))}}return t;case 0:return pc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,i=Ws(r,t.pendingProps),hc(e,t,r,i,n);case 3:a:{if(ae(t,t.stateNode.containerInfo),e===null)throw Error(o(387));r=t.pendingProps;var a=t.memoizedState;i=a.element,La(e,t),Wa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Ui(t,na,r),r!==a.cache&&Ki(t,[na],n,!0),Ua(),r=s.element,a.isDehydrated)if(a={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=a,t.memoizedState=a,t.flags&256){t=gc(e,t,r,n);break a}else if(r!==i){i=fi(Error(o(424)),t),zi(i),t=gc(e,t,r,n);break a}else{switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Oi=gf(e.firstChild),Di=t,ki=!0,Ai=null,ji=!0,n=Pa(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Li(),r===i){t=Dc(e,t,n);break a}nc(e,t,r,n)}t=t.child}return t;case 26:return fc(e,t),e===null?(n=Lf(t.type,null,t.pendingProps,null))?t.memoizedState=n:ki||(n=t.type,e=t.pendingProps,r=Jd(re.current).createElement(n),r[nt]=t,r[rt]=e,Hd(r,n,e),ht(r),t.stateNode=r):t.memoizedState=Lf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return se(t),e===null&&ki&&(r=t.stateNode=bf(t.type,t.pendingProps,re.current),Di=t,ji=!0,i=Oi,of(t.type)?(_f=i,Oi=gf(r.firstChild)):Oi=i),nc(e,t,t.pendingProps.children,n),fc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ki&&((i=r=Oi)&&(r=uf(r,t.type,t.pendingProps,ji),r===null?i=!1:(t.stateNode=r,Di=t,Oi=gf(r.firstChild),ji=!1,i=!0)),i||Ni(t)),se(t),i=t.type,a=t.pendingProps,s=e===null?null:e.memoizedProps,r=a.children,Zd(i,a)?r=null:s!==null&&Zd(i,s)&&(t.flags|=32),t.memoizedState!==null&&(i=xo(e,t,wo,null,null,n),op._currentValue=i),fc(e,t),nc(e,t,r,n),t.child;case 6:return e===null&&ki&&((e=n=Oi)&&(n=df(n,t.pendingProps,ji),n===null?e=!1:(t.stateNode=n,Di=t,Oi=null,e=!0)),e||Ni(t)),null;case 13:return bc(e,t,n);case 4:return ae(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Na(t,null,r,n):nc(e,t,r,n),t.child;case 11:return rc(e,t,t.type,t.pendingProps,n);case 7:return nc(e,t,t.pendingProps,n),t.child;case 8:return nc(e,t,t.pendingProps.children,n),t.child;case 12:return nc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Ui(t,t.type,r.value),nc(e,t,r.children,n),t.child;case 9:return i=t.type._context,r=t.pendingProps.children,Yi(t),i=Xi(i),r=r(i),t.flags|=1,nc(e,t,r,n),t.child;case 14:return ic(e,t,t.type,t.pendingProps,n);case 15:return ac(e,t,t.type,t.pendingProps,n);case 19:return Ec(e,t,n);case 31:return dc(e,t,n);case 22:return oc(e,t,n,t.pendingProps);case 24:return Yi(t),r=Xi(na),e===null?(i=ma(),i===null&&(i=Bl,a=ra(),i.pooledCache=a,a.refCount++,a!==null&&(i.pooledCacheLanes|=n),i=a),t.memoizedState={parent:r,cache:i},Ia(t),Ui(t,na,i)):((e.lanes&n)!==0&&(La(e,t),Wa(t,null,null,n),Ua()),i=e.memoizedState,a=t.memoizedState,i.parent===r?(r=a.cache,Ui(t,na,r),r!==i.cache&&Ki(t,[na],n,!0)):(i={parent:r,cache:r},t.memoizedState=i,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=i),Ui(t,na,r))),nc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(o(156,t.tag))}function jc(e){e.flags|=4}function Mc(e,t,n,r,i){if((t=(e.mode&32)!=0)&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i)if(e.stateNode.complete)e.flags|=8192;else if(ku())e.flags|=8192;else throw wa=ba,va}else e.flags&=-16777217}function Nc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Qf(t))if(ku())e.flags|=8192;else throw wa=ba,va}function Pc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:We(),e.lanes|=t,eu|=t)}function Fc(e,t){if(!ki)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Ic(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Lc(e,t,n){var r=t.pendingProps;switch(Ti(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Ic(t),null;case 1:return Ic(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),Wi(na),oe(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Ii(t)?jc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ri())),Ic(t),null;case 26:var i=t.type,a=t.memoizedState;return e===null?(jc(t),a===null?(Ic(t),Mc(t,i,null,r,n)):(Ic(t),Nc(t,a))):a?a===e.memoizedState?(Ic(t),t.flags&=-16777217):(jc(t),Ic(t),Nc(t,a)):(e=e.memoizedProps,e!==r&&jc(t),Ic(t),Mc(t,i,e,r,n)),null;case 27:if(ce(t),n=re.current,i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Ic(t),null}e=te.current,Ii(t)?Pi(t,e):(e=bf(i,r,n),t.stateNode=e,jc(t))}return Ic(t),null;case 5:if(ce(t),i=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(!r){if(t.stateNode===null)throw Error(o(166));return Ic(t),null}if(a=te.current,Ii(t))Pi(t,a);else{var s=Jd(re.current);switch(a){case 1:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case 2:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;default:switch(i){case`svg`:a=s.createElementNS(`http://www.w3.org/2000/svg`,i);break;case`math`:a=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,i);break;case`script`:a=s.createElement(`div`),a.innerHTML=`<script><\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[nt]=t,a[rt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(Hd(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&jc(t)}}return Ic(t),Mc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&jc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=re.current,Ii(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Di,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[nt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||zd(e.nodeValue,n)),e||Ni(t,!0)}else e=Jd(e).createTextNode(r),e[nt]=t,t.stateNode=e}return Ic(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Ii(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[nt]=t}else Li(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ic(t),e=!1}else n=Ri(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(io(t),t):(io(t),null);if(t.flags&128)throw Error(o(558))}return Ic(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Ii(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[nt]=t}else Li(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Ic(t),i=!1}else i=Ri(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(io(t),t):(io(t),null)}return io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Pc(t,t.updateQueue),Ic(t),null);case 4:return oe(),e===null&&kd(t.stateNode.containerInfo),Ic(t),null;case 10:return Wi(t.type),Ic(t),null;case 19:if(B(ao),r=t.memoizedState,r===null)return Ic(t),null;if(i=(t.flags&128)!=0,a=r.rendering,a===null)if(i)Fc(r,!1);else{if(Yl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=oo(e),a!==null){for(t.flags|=128,Fc(r,!1),e=a.updateQueue,t.updateQueue=e,Pc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)ai(n,e),n=n.sibling;return V(ao,ao.current&1|2),ki&&Si(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&xe()>ou&&(t.flags|=128,i=!0,Fc(r,!1),t.lanes=4194304)}else{if(!i)if(e=oo(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Pc(t,e),Fc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!ki)return Ic(t),null}else 2*xe()-r.renderingStartTime>ou&&n!==536870912&&(t.flags|=128,i=!0,Fc(r,!1),t.lanes=4194304);r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(Ic(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=xe(),e.sibling=null,n=ao.current,V(ao,i?n&1|2:n&1),ki&&Si(t,r.treeForkCount),e);case 22:case 23:return io(t),Za(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Ic(t),t.subtreeFlags&6&&(t.flags|=8192)):Ic(t),n=t.updateQueue,n!==null&&Pc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&B(pa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Wi(na),Ic(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Rc(e,t){switch(Ti(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Wi(na),oe(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ce(t),null;case 31:if(t.memoizedState!==null){if(io(t),t.alternate===null)throw Error(o(340));Li()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Li()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return B(ao),null;case 4:return oe(),null;case 10:return Wi(t.type),null;case 22:case 23:return io(t),Za(),e!==null&&B(pa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Wi(na),null;case 25:return null;default:return null}}function zc(e,t){switch(Ti(t),t.tag){case 3:Wi(na),oe();break;case 26:case 27:case 5:ce(t);break;case 4:oe();break;case 31:t.memoizedState!==null&&io(t);break;case 13:io(t);break;case 19:B(ao);break;case 10:Wi(t.type);break;case 22:case 23:io(t),Za(),e!==null&&B(pa);break;case 24:Wi(na)}}function Bc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Xu(t,t.return,e)}}function Vc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Xu(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Xu(t,t.return,e)}}function Hc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Ka(t,n)}catch(t){Xu(e,e.return,t)}}}function Uc(e,t,n){n.props=Ws(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Xu(e,t,n)}}function Wc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Xu(e,t,n)}}function Gc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null)if(typeof r==`function`)try{r()}catch(n){Xu(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Xu(e,t,n)}else n.current=null}function Kc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Xu(e,e.return,t)}}function qc(e,t,n){try{var r=e.stateNode;Ud(r,e.type,n,t),r[rt]=t}catch(t){Xu(e,e.return,t)}}function Jc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&of(e.type)||e.tag===4}function Yc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Jc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&of(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Xc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Jt));else if(r!==4&&(r===27&&of(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(Xc(e,t,n),e=e.sibling;e!==null;)Xc(e,t,n),e=e.sibling}function Zc(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&of(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(Zc(e,t,n),e=e.sibling;e!==null;)Zc(e,t,n),e=e.sibling}function Qc(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Hd(t,r,n),t[nt]=e,t[rt]=n}catch(t){Xu(e,e.return,t)}}var $c=!1,el=!1,tl=!1,nl=typeof WeakSet==`function`?WeakSet:Set,rl=null;function il(e,t){if(e=e.containerInfo,Kd=hp,e=xr(e),Sr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==a||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===a&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(qd={focusedElem:e,selectionRange:n},hp=!1,rl=t;rl!==null;)if(t=rl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,rl=e;else for(;rl!==null;){switch(t=rl,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)i=e[n],i.ref.impl=i.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&a!==null){e=void 0,n=t,i=a.memoizedProps,a=a.memoizedState,r=n.stateNode;try{var h=Ws(n.type,i);e=r.getSnapshotBeforeUpdate(h,a),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){Xu(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)lf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:lf(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(o(163))}if(e=t.sibling,e!==null){e.return=t.return,rl=e;break}rl=t.return}}function al(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:bl(e,n),r&4&&Bc(5,n);break;case 1:if(bl(e,n),r&4)if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Xu(n,n.return,e)}else{var i=Ws(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Xu(n,n.return,e)}}r&64&&Hc(n),r&512&&Wc(n,n.return);break;case 3:if(bl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{Ka(e,t)}catch(e){Xu(n,n.return,e)}}break;case 27:t===null&&r&4&&Qc(n);case 26:case 5:bl(e,n),t===null&&r&4&&Kc(n),r&512&&Wc(n,n.return);break;case 12:bl(e,n);break;case 31:bl(e,n),r&4&&dl(e,n);break;case 13:bl(e,n),r&4&&fl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=ed.bind(null,n),hf(e,n))));break;case 22:if(r=n.memoizedState!==null||$c,!r){t=t!==null&&t.memoizedState!==null||el,i=$c;var a=el;$c=r,(el=t)&&!a?Sl(e,n,(n.subtreeFlags&8772)!=0):bl(e,n),$c=i,el=a}break;case 30:break;default:bl(e,n)}}function ol(e){var t=e.alternate;t!==null&&(e.alternate=null,ol(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&ut(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var sl=null,cl=!1;function ll(e,t,n){for(n=n.child;n!==null;)ul(e,t,n),n=n.sibling}function ul(e,t,n){if(je&&typeof je.onCommitFiberUnmount==`function`)try{je.onCommitFiberUnmount(Ae,n)}catch{}switch(n.tag){case 26:el||Gc(n,t),ll(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:el||Gc(n,t);var r=sl,i=cl;of(n.type)&&(sl=n.stateNode,cl=!1),ll(e,t,n),xf(n.stateNode),sl=r,cl=i;break;case 5:el||Gc(n,t);case 6:if(r=sl,i=cl,sl=null,ll(e,t,n),sl=r,cl=i,sl!==null)if(cl)try{(sl.nodeType===9?sl.body:sl.nodeName===`HTML`?sl.ownerDocument.body:sl).removeChild(n.stateNode)}catch(e){Xu(n,t,e)}else try{sl.removeChild(n.stateNode)}catch(e){Xu(n,t,e)}break;case 18:sl!==null&&(cl?(e=sl,sf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Vp(e)):sf(sl,n.stateNode));break;case 4:r=sl,i=cl,sl=n.stateNode.containerInfo,cl=!0,ll(e,t,n),sl=r,cl=i;break;case 0:case 11:case 14:case 15:Vc(2,n,t),el||Vc(4,n,t),ll(e,t,n);break;case 1:el||(Gc(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Uc(n,t,r)),ll(e,t,n);break;case 21:ll(e,t,n);break;case 22:el=(r=el)||n.memoizedState!==null,ll(e,t,n),el=r;break;default:ll(e,t,n)}}function dl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Vp(e)}catch(e){Xu(t,t.return,e)}}}function fl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Vp(e)}catch(e){Xu(t,t.return,e)}}function pl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new nl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new nl),t;default:throw Error(o(435,e.tag))}}function ml(e,t){var n=pl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=td.bind(null,e,t);t.then(r,r)}})}function hl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r],a=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(of(c.type)){sl=c.stateNode,cl=!1;break a}break;case 5:sl=c.stateNode,cl=!1;break a;case 3:case 4:sl=c.stateNode.containerInfo,cl=!0;break a}c=c.return}if(sl===null)throw Error(o(160));ul(a,s,i),sl=null,cl=!1,a=i.alternate,a!==null&&(a.return=null),i.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)_l(t,e),t=t.sibling}var gl=null;function _l(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:hl(t,e),vl(e),r&4&&(Vc(3,e,e.return),Bc(3,e),Vc(5,e,e.return));break;case 1:hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),r&64&&$c&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var i=gl;if(hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),r&4){var a=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null)if(r===null)if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,i=i.ownerDocument||i;b:switch(r){case`title`:a=i.getElementsByTagName(`title`)[0],(!a||a[lt]||a[nt]||a.namespaceURI===`http://www.w3.org/2000/svg`||a.hasAttribute(`itemprop`))&&(a=i.createElement(r),i.head.insertBefore(a,i.querySelector(`head > title`))),Hd(a,r,n),a[nt]=e,ht(a),r=a;break a;case`link`:var s=Yf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&a.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&a.getAttribute(`title`)===(n.title==null?null:n.title)&&a.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}a=i.createElement(r),Hd(a,r,n),i.head.appendChild(a);break;case`meta`:if(s=Yf(`meta`,`content`,i).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(a=s[c],a.getAttribute(`content`)===(n.content==null?null:``+n.content)&&a.getAttribute(`name`)===(n.name==null?null:n.name)&&a.getAttribute(`property`)===(n.property==null?null:n.property)&&a.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&a.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}a=i.createElement(r),Hd(a,r,n),i.head.appendChild(a);break;default:throw Error(o(468,r))}a[nt]=e,ht(a),r=a}e.stateNode=r}else Xf(i,e.type,e.stateNode);else e.stateNode=Wf(i,r,e.memoizedProps);else a===r?r===null&&e.stateNode!==null&&qc(e,e.memoizedProps,n.memoizedProps):(a===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):a.count--,r===null?Xf(i,e.type,e.stateNode):Wf(i,r,e.memoizedProps))}break;case 27:hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),n!==null&&r&4&&qc(e,e.memoizedProps,n.memoizedProps);break;case 5:if(hl(t,e),vl(e),r&512&&(el||n===null||Gc(n,n.return)),e.flags&32){i=e.stateNode;try{Bt(i,``)}catch(t){Xu(e,e.return,t)}}r&4&&e.stateNode!=null&&(i=e.memoizedProps,qc(e,i,n===null?i:n.memoizedProps)),r&1024&&(tl=!0);break;case 6:if(hl(t,e),vl(e),r&4){if(e.stateNode===null)throw Error(o(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){Xu(e,e.return,t)}}break;case 3:if(Jf=null,i=gl,gl=wf(t.containerInfo),hl(t,e),gl=i,vl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Vp(t.containerInfo)}catch(t){Xu(e,e.return,t)}tl&&(tl=!1,yl(e));break;case 4:r=gl,gl=wf(e.stateNode.containerInfo),hl(t,e),vl(e),gl=r;break;case 12:hl(t,e),vl(e);break;case 31:hl(t,e),vl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ml(e,r)));break;case 13:hl(t,e),vl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(iu=xe()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ml(e,r)));break;case 22:i=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=$c,d=el;if($c=u||i,el=d||l,hl(t,e),el=d,$c=u,vl(e),r&8192)a:for(t=e.stateNode,t._visibility=i?t._visibility&-2:t._visibility|1,i&&(n===null||l||$c||el||xl(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(a=l.stateNode,i)s=a.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){Xu(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=i?``:l.memoizedProps}catch(e){Xu(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;i?cf(m,!0):cf(l.stateNode,!1)}catch(e){Xu(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,ml(e,n))));break;case 19:hl(t,e),vl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,ml(e,r)));break;case 30:break;case 21:break;default:hl(t,e),vl(e)}}function vl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Jc(r)){n=r;break}r=r.return}if(n==null)throw Error(o(160));switch(n.tag){case 27:var i=n.stateNode;Zc(e,Yc(e),i);break;case 5:var a=n.stateNode;n.flags&32&&(Bt(a,``),n.flags&=-33),Zc(e,Yc(e),a);break;case 3:case 4:var s=n.stateNode.containerInfo;Xc(e,Yc(e),s);break;default:throw Error(o(161))}}catch(t){Xu(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function yl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;yl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function bl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)al(e,t.alternate,t),t=t.sibling}function xl(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Vc(4,t,t.return),xl(t);break;case 1:Gc(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Uc(t,t.return,n),xl(t);break;case 27:xf(t.stateNode);case 26:case 5:Gc(t,t.return),xl(t);break;case 22:t.memoizedState===null&&xl(t);break;case 30:xl(t);break;default:xl(t)}e=e.sibling}}function Sl(e,t,n){for(n&&=(t.subtreeFlags&8772)!=0,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Sl(i,a,n),Bc(4,a);break;case 1:if(Sl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Xu(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)Ga(c[i],s)}catch(e){Xu(r,r.return,e)}}n&&o&64&&Hc(a),Wc(a,a.return);break;case 27:Qc(a);case 26:case 5:Sl(i,a,n),n&&r===null&&o&4&&Kc(a),Wc(a,a.return);break;case 12:Sl(i,a,n);break;case 31:Sl(i,a,n),n&&o&4&&dl(i,a);break;case 13:Sl(i,a,n),n&&o&4&&fl(i,a);break;case 22:a.memoizedState===null&&Sl(i,a,n),Wc(a,a.return);break;case 30:break;default:Sl(i,a,n)}t=t.sibling}}function Cl(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&ia(n))}function wl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ia(e))}function Tl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)El(e,t,n,r),t=t.sibling}function El(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Tl(e,t,n,r),i&2048&&Bc(9,t);break;case 1:Tl(e,t,n,r);break;case 3:Tl(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&ia(e)));break;case 12:if(i&2048){Tl(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){Xu(t,t.return,e)}}else Tl(e,t,n,r);break;case 31:Tl(e,t,n,r);break;case 13:Tl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Tl(e,t,n,r):(a._visibility|=2,Dl(e,t,n,r,(t.subtreeFlags&10256)!=0||!1)):a._visibility&2?Tl(e,t,n,r):Ol(e,t),i&2048&&Cl(o,t);break;case 24:Tl(e,t,n,r),i&2048&&wl(t.alternate,t);break;default:Tl(e,t,n,r)}}function Dl(e,t,n,r,i){for(i&&=(t.subtreeFlags&10256)!=0||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Dl(a,o,s,c,i),Bc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Dl(a,o,s,c,i)):u._visibility&2?Dl(a,o,s,c,i):Ol(a,o),i&&l&2048&&Cl(o.alternate,o);break;case 24:Dl(a,o,s,c,i),i&&l&2048&&wl(o.alternate,o);break;default:Dl(a,o,s,c,i)}t=t.sibling}}function Ol(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Ol(n,r),i&2048&&Cl(r.alternate,r);break;case 24:Ol(n,r),i&2048&&wl(r.alternate,r);break;default:Ol(n,r)}t=t.sibling}}var kl=8192;function Al(e,t,n){if(e.subtreeFlags&kl)for(e=e.child;e!==null;)jl(e,t,n),e=e.sibling}function jl(e,t,n){switch(e.tag){case 26:Al(e,t,n),e.flags&kl&&e.memoizedState!==null&&$f(n,gl,e.memoizedState,e.memoizedProps);break;case 5:Al(e,t,n);break;case 3:case 4:var r=gl;gl=wf(e.stateNode.containerInfo),Al(e,t,n),gl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=kl,kl=16777216,Al(e,t,n),kl=r):Al(e,t,n));break;default:Al(e,t,n)}}function Ml(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Nl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];rl=r,Il(r,e)}Ml(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Pl(e),e=e.sibling}function Pl(e){switch(e.tag){case 0:case 11:case 15:Nl(e),e.flags&2048&&Vc(9,e,e.return);break;case 3:Nl(e);break;case 12:Nl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Fl(e)):Nl(e);break;default:Nl(e)}}function Fl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];rl=r,Il(r,e)}Ml(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Vc(8,t,t.return),Fl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Fl(t));break;default:Fl(t)}e=e.sibling}}function Il(e,t){for(;rl!==null;){var n=rl;switch(n.tag){case 0:case 11:case 15:Vc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:ia(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,rl=r;else a:for(n=e;rl!==null;){r=rl;var i=r.sibling,a=r.return;if(ol(r),r===n){rl=null;break a}if(i!==null){i.return=a,rl=i;break a}rl=a}}}var Ll={getCacheForType:function(e){var t=Xi(na),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return Xi(na).controller.signal}},Rl=typeof WeakMap==`function`?WeakMap:Map,zl=0,Bl=null,Vl=null,Hl=0,Ul=0,Wl=null,Gl=!1,Kl=!1,ql=!1,Jl=0,Yl=0,Xl=0,Zl=0,Ql=0,$l=0,eu=0,tu=null,nu=null,ru=!1,iu=0,au=0,ou=1/0,su=null,cu=null,lu=0,uu=null,du=null,fu=0,pu=0,mu=null,hu=null,gu=0,_u=null;function vu(){return zl&2&&Hl!==0?Hl&-Hl:F.T===null?$e():_d()}function yu(){if($l===0)if(!(Hl&536870912)||ki){var e=Re;Re<<=1,!(Re&3932160)&&(Re=262144),$l=e}else $l=536870912;return e=Qa.current,e!==null&&(e.flags|=32),$l}function bu(e,t,n){(e===Bl&&(Ul===2||Ul===9)||e.cancelPendingCommit!==null)&&(Du(e,0),wu(e,Hl,$l,!1)),Ke(e,n),(!(zl&2)||e!==Bl)&&(e===Bl&&(!(zl&2)&&(Zl|=n),Yl===4&&wu(e,Hl,$l,!1)),ld(e))}function xu(e,t,n){if(zl&6)throw Error(o(327));var r=!n&&(t&127)==0&&(t&e.expiredLanes)===0||He(e,t),i=r?Fu(e,t):Nu(e,t,!0),a=r;do{if(i===0){Kl&&!r&&wu(e,t,0,!1);break}else{if(n=e.current.alternate,a&&!Cu(n)){i=Nu(e,t,!1),a=!1;continue}if(i===2){if(a=t,e.errorRecoveryDisabledLanes&a)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;i=tu;var l=c.current.memoizedState.isDehydrated;if(l&&(Du(c,s).flags|=256),s=Nu(c,s,!1),s!==2){if(ql&&!l){c.errorRecoveryDisabledLanes|=a,Zl|=a,i=4;break a}a=nu,nu=i,a!==null&&(nu===null?nu=a:nu.push.apply(nu,a))}i=s}if(a=!1,i!==2)continue}}if(i===1){Du(e,0),wu(e,t,0,!0);break}a:{switch(r=e,a=i,a){case 0:case 1:throw Error(o(345));case 4:if((t&4194048)!==t)break;case 6:wu(r,t,$l,!Gl);break a;case 2:nu=null;break;case 3:case 5:break;default:throw Error(o(329))}if((t&62914560)===t&&(i=iu+300-xe(),10<i)){if(wu(r,t,$l,!Gl),Ve(r,0,!0)!==0)break a;fu=t,r.timeoutHandle=ef(Su.bind(null,r,n,nu,su,ru,t,$l,Zl,eu,Gl,a,`Throttled`,-0,0),i);break a}Su(r,n,nu,su,ru,t,$l,Zl,eu,Gl,a,null,-0,0)}}break}while(1);ld(e)}function Su(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Jt},jl(t,a,d);var m=(a&62914560)===a?iu-xe():(a&4194048)===a?au-xe():0;if(m=tp(d,m),m!==null){fu=a,e.cancelPendingCommit=m(Hu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),wu(e,a,o,!l);return}}Hu(e,t,a,n,r,i,o,s,c)}function Cu(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!gr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function wu(e,t,n,r){t&=~Ql,t&=~Zl,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ne(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&Je(e,n,t)}function Tu(){return zl&6?!0:(ud(0,!1),!1)}function Eu(){if(Vl!==null){if(Ul===0)var e=Vl.return;else e=Vl,Hi=Vi=null,Eo(e),Da=null,Oa=0,e=Vl;for(;e!==null;)zc(e.alternate,e),e=e.return;Vl=null}}function Du(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,tf(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),fu=0,Eu(),Bl=e,Vl=n=ii(e.current,null),Hl=t,Ul=0,Wl=null,Gl=!1,Kl=He(e,t),ql=!1,eu=$l=Ql=Zl=Xl=Yl=0,nu=tu=null,ru=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ne(r),a=1<<i;t|=e[i],r&=~a}return Jl=t,Jr(),n}function Ou(e,t){co=null,F.H=Is,t===_a||t===ya?(t=Ta(),Ul=3):t===va?(t=Ta(),Ul=4):Ul=t===ec?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,Wl=t,Vl===null&&(Yl=1,Js(e,fi(t,e.current)))}function ku(){var e=Qa.current;return e===null?!0:(Hl&4194048)===Hl?$a===null:(Hl&62914560)===Hl||Hl&536870912?e===$a:!1}function Au(){var e=F.H;return F.H=Is,e===null?Is:e}function ju(){var e=F.A;return F.A=Ll,e}function Mu(){Yl=4,Gl||(Hl&4194048)!==Hl&&Qa.current!==null||(Kl=!0),!(Xl&134217727)&&!(Zl&134217727)||Bl===null||wu(Bl,Hl,$l,!1)}function Nu(e,t,n){var r=zl;zl|=2;var i=Au(),a=ju();(Bl!==e||Hl!==t)&&(su=null,Du(e,t)),t=!1;var o=Yl;a:do try{if(Ul!==0&&Vl!==null){var s=Vl,c=Wl;switch(Ul){case 8:Eu(),o=6;break a;case 3:case 2:case 9:case 6:Qa.current===null&&(t=!0);var l=Ul;if(Ul=0,Wl=null,zu(e,s,c,l),n&&Kl){o=0;break a}break;default:l=Ul,Ul=0,Wl=null,zu(e,s,c,l)}}Pu(),o=Yl;break}catch(t){Ou(e,t)}while(1);return t&&e.shellSuspendCounter++,Hi=Vi=null,zl=r,F.H=i,F.A=a,Vl===null&&(Bl=null,Hl=0,Jr()),o}function Pu(){for(;Vl!==null;)Lu(Vl)}function Fu(e,t){var n=zl;zl|=2;var r=Au(),i=ju();Bl!==e||Hl!==t?(su=null,ou=xe()+500,Du(e,t)):Kl=He(e,t);a:do try{if(Ul!==0&&Vl!==null){t=Vl;var a=Wl;b:switch(Ul){case 1:Ul=0,Wl=null,zu(e,t,a,1);break;case 2:case 9:if(xa(a)){Ul=0,Wl=null,Ru(t);break}t=function(){Ul!==2&&Ul!==9||Bl!==e||(Ul=7),ld(e)},a.then(t,t);break a;case 3:Ul=7;break a;case 4:Ul=5;break a;case 7:xa(a)?(Ul=0,Wl=null,Ru(t)):(Ul=0,Wl=null,zu(e,t,a,7));break;case 5:var s=null;switch(Vl.tag){case 26:s=Vl.memoizedState;case 5:case 27:var c=Vl;if(s?Qf(s):c.stateNode.complete){Ul=0,Wl=null;var l=c.sibling;if(l!==null)Vl=l;else{var u=c.return;u===null?Vl=null:(Vl=u,Bu(u))}break b}}Ul=0,Wl=null,zu(e,t,a,5);break;case 6:Ul=0,Wl=null,zu(e,t,a,6);break;case 8:Eu(),Yl=6;break a;default:throw Error(o(462))}}Iu();break}catch(t){Ou(e,t)}while(1);return Hi=Vi=null,F.H=r,F.A=i,zl=n,Vl===null?(Bl=null,Hl=0,Jr(),Yl):0}function Iu(){for(;Vl!==null&&!ye();)Lu(Vl)}function Lu(e){var t=Ac(e.alternate,e,Jl);e.memoizedProps=e.pendingProps,t===null?Bu(e):Vl=t}function Ru(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=mc(n,t,t.pendingProps,t.type,void 0,Hl);break;case 11:t=mc(n,t,t.pendingProps,t.type.render,t.ref,Hl);break;case 5:Eo(t);default:zc(n,t),t=Vl=ai(t,Jl),t=Ac(n,t,Jl)}e.memoizedProps=e.pendingProps,t===null?Bu(e):Vl=t}function zu(e,t,n,r){Hi=Vi=null,Eo(t),Da=null,Oa=0;var i=t.return;try{if($s(e,i,t,n,Hl)){Yl=1,Js(e,fi(n,e.current)),Vl=null;return}}catch(t){if(i!==null)throw Vl=i,t;Yl=1,Js(e,fi(n,e.current)),Vl=null;return}t.flags&32768?(ki||r===1?e=!0:Kl||Hl&536870912?e=!1:(Gl=e=!0,(r===2||r===9||r===3||r===6)&&(r=Qa.current,r!==null&&r.tag===13&&(r.flags|=16384))),Vu(t,e)):Bu(t)}function Bu(e){var t=e;do{if(t.flags&32768){Vu(t,Gl);return}e=t.return;var n=Lc(t.alternate,t,Jl);if(n!==null){Vl=n;return}if(t=t.sibling,t!==null){Vl=t;return}Vl=t=e}while(t!==null);Yl===0&&(Yl=5)}function Vu(e,t){do{var n=Rc(e.alternate,e);if(n!==null){n.flags&=32767,Vl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Vl=e;return}Vl=e=n}while(e!==null);Yl=6,Vl=null}function Hu(e,t,n,r,i,a,s,c,l){e.cancelPendingCommit=null;do qu();while(lu!==0);if(zl&6)throw Error(o(327));if(t!==null){if(t===e.current)throw Error(o(177));if(a=t.lanes|t.childLanes,a|=qr,qe(e,n,a,s,c,l),e===Bl&&(Vl=Bl=null,Hl=0),du=t,uu=e,fu=n,pu=a,mu=i,hu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,nd(Te,function(){return Ju(),null})):(e.callbackNode=null,e.callbackPriority=0),r=(t.flags&13878)!=0,t.subtreeFlags&13878||r){r=F.T,F.T=null,i=I.p,I.p=2,s=zl,zl|=4;try{il(e,t,n)}finally{zl=s,I.p=i,F.T=r}}lu=1,Uu(),Wu(),Gu()}}function Uu(){if(lu===1){lu=0;var e=uu,t=du,n=(t.flags&13878)!=0;if(t.subtreeFlags&13878||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=zl;zl|=4;try{_l(t,e);var a=qd,o=xr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&br(s.ownerDocument.documentElement,s)){if(c!==null&&Sr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=yr(s,h),v=yr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}hp=!!Kd,qd=Kd=null}finally{zl=i,I.p=r,F.T=n}}e.current=t,lu=2}}function Wu(){if(lu===2){lu=0;var e=uu,t=du,n=(t.flags&8772)!=0;if(t.subtreeFlags&8772||n){n=F.T,F.T=null;var r=I.p;I.p=2;var i=zl;zl|=4;try{al(e,t.alternate,t)}finally{zl=i,I.p=r,F.T=n}}lu=3}}function Gu(){if(lu===4||lu===3){lu=0,be();var e=uu,t=du,n=fu,r=hu;t.subtreeFlags&10256||t.flags&10256?lu=5:(lu=0,du=uu=null,Ku(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(cu=null),Qe(n),t=t.stateNode,je&&typeof je.onCommitFiberRoot==`function`)try{je.onCommitFiberRoot(Ae,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=F.T,i=I.p,I.p=2,F.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{F.T=t,I.p=i}}fu&3&&qu(),ld(e),i=e.pendingLanes,n&261930&&i&42?e===_u?gu++:(gu=0,_u=e):gu=0,ud(0,!1)}}function Ku(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,ia(t)))}function qu(){return Uu(),Wu(),Gu(),Ju()}function Ju(){if(lu!==5)return!1;var e=uu,t=pu;pu=0;var n=Qe(fu),r=F.T,i=I.p;try{I.p=32>n?32:n,F.T=null,n=mu,mu=null;var a=uu,s=fu;if(lu=0,du=uu=null,fu=0,zl&6)throw Error(o(331));var c=zl;if(zl|=4,Pl(a.current),El(a,a.current,s,n),zl=c,ud(0,!1),je&&typeof je.onPostCommitFiberRoot==`function`)try{je.onPostCommitFiberRoot(Ae,a)}catch{}return!0}finally{I.p=i,F.T=r,Ku(e,t)}}function Yu(e,t,n){t=fi(n,t),t=Xs(e.stateNode,t,2),e=za(e,t,2),e!==null&&(Ke(e,2),ld(e))}function Xu(e,t,n){if(e.tag===3)Yu(e,e,n);else for(;t!==null;){if(t.tag===3){Yu(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(cu===null||!cu.has(r))){e=fi(n,e),n=Zs(2),r=za(t,n,2),r!==null&&(Qs(n,r,t,e),Ke(r,2),ld(r));break}}t=t.return}}function Zu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Rl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(ql=!0,i.add(n),e=Qu.bind(null,e,t,n),t.then(e,e))}function Qu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Bl===e&&(Hl&n)===n&&(Yl===4||Yl===3&&(Hl&62914560)===Hl&&300>xe()-iu?!(zl&2)&&Du(e,0):Ql|=n,eu===Hl&&(eu=0)),ld(e)}function $u(e,t){t===0&&(t=We()),e=Zr(e,t),e!==null&&(Ke(e,t),ld(e))}function ed(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),$u(e,n)}function td(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),$u(e,n)}function nd(e,t){return _e(e,t)}var rd=null,id=null,ad=!1,od=!1,sd=!1,cd=0;function ld(e){e!==id&&e.next===null&&(id===null?rd=id=e:id=id.next=e),od=!0,ad||(ad=!0,gd())}function ud(e,t){if(!sd&&od){sd=!0;do for(var n=!1,r=rd;r!==null;){if(!t)if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ne(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,hd(r,a))}else a=Hl,a=Ve(r,r===Bl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||He(r,a)||(n=!0,hd(r,a));r=r.next}while(n);sd=!1}}function dd(){fd()}function fd(){od=ad=!1;var e=0;cd!==0&&$d()&&(e=cd);for(var t=xe(),n=null,r=rd;r!==null;){var i=r.next,a=pd(r,t);a===0?(r.next=null,n===null?rd=i:n.next=i,i===null&&(id=n)):(n=r,(e!==0||a&3)&&(od=!0)),r=i}lu!==0&&lu!==5||ud(e,!1),cd!==0&&(cd=0)}function pd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ne(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ue(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Bl,n=Hl,n=Ve(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ul===2||Ul===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&ve(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||He(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&ve(r),Qe(n)){case 2:case 8:n=we;break;case 32:n=Te;break;case 268435456:n=De;break;default:n=Te}return r=md.bind(null,e),n=_e(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&ve(r),e.callbackPriority=2,e.callbackNode=null,2}function md(e,t){if(lu!==0&&lu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(qu()&&e.callbackNode!==n)return null;var r=Hl;return r=Ve(e,e===Bl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(xu(e,r,t),pd(e,xe()),e.callbackNode!=null&&e.callbackNode===n?md.bind(null,e):null)}function hd(e,t){if(qu())return null;xu(e,t,!0)}function gd(){rf(function(){zl&6?_e(Ce,dd):fd()})}function _d(){if(cd===0){var e=sa;e===0&&(e=Le,Le<<=1,!(Le&261888)&&(Le=256)),cd=e}return cd}function vd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:qt(``+e)}function yd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function bd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=vd((i[rt]||null).action),o=r.submitter;o&&(t=(t=o[rt]||null)?vd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new hn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(cd!==0){var e=o?yd(i,o):new FormData(i);Ss(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?yd(i,o):new FormData(i),Ss(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var xd=0;xd<Hr.length;xd++){var Sd=Hr[xd];Ur(Sd.toLowerCase(),`on`+(Sd[0].toUpperCase()+Sd.slice(1)))}Ur(Pr,`onAnimationEnd`),Ur(Fr,`onAnimationIteration`),Ur(Ir,`onAnimationStart`),Ur(`dblclick`,`onDoubleClick`),Ur(`focusin`,`onFocus`),Ur(`focusout`,`onBlur`),Ur(Lr,`onTransitionRun`),Ur(Rr,`onTransitionStart`),Ur(zr,`onTransitionCancel`),Ur(Br,`onTransitionEnd`),yt(`onMouseEnter`,[`mouseout`,`mouseover`]),yt(`onMouseLeave`,[`mouseout`,`mouseover`]),yt(`onPointerEnter`,[`pointerout`,`pointerover`]),yt(`onPointerLeave`,[`pointerout`,`pointerover`]),vt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),vt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),vt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),vt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),vt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),vt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Cd=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),wd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Cd));function Td(e,t){t=(t&4)!=0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Wr(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){Wr(e)}i.currentTarget=null,a=c}}}}function Ed(e,t){var n=t[at];n===void 0&&(n=t[at]=new Set);var r=e+`__bubble`;n.has(r)||(Ad(t,e,2,!1),n.add(r))}function Dd(e,t,n){var r=0;t&&(r|=4),Ad(n,e,r,t)}var Od=`_reactListening`+Math.random().toString(36).slice(2);function kd(e){if(!e[Od]){e[Od]=!0,gt.forEach(function(t){t!==`selectionchange`&&(wd.has(t)||Dd(t,!1,e),Dd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Od]||(t[Od]=!0,Dd(`selectionchange`,!1,t))}}function Ad(e,t,n,r){switch(Sp(t)){case 2:var i=gp;break;case 8:i=_p;break;default:i=vp}n=i.bind(null,t,n,e),i=void 0,!rn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function jd(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var o=r.tag;if(o===3||o===4){var s=r.stateNode.containerInfo;if(s===i)break;if(o===4)for(o=r.return;o!==null;){var l=o.tag;if((l===3||l===4)&&o.stateNode.containerInfo===i)return;o=o.return}for(;s!==null;){if(o=dt(s),o===null)return;if(l=o.tag,l===5||l===6||l===26||l===27){r=a=o;continue a}s=s.parentNode}}r=r.return}U(function(){var r=a,i=Xt(n),o=[];a:{var s=Vr.get(e);if(s!==void 0){var l=hn,u=e;switch(e){case`keypress`:if(un(n)===0)break a;case`keydown`:case`keyup`:l=Nn;break;case`focusin`:u=`focus`,l=wn;break;case`focusout`:u=`blur`,l=wn;break;case`beforeblur`:case`afterblur`:l=wn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Sn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Cn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Fn;break;case Pr:case Fr:case Ir:l=Tn;break;case Br:l=In;break;case`scroll`:case`scrollend`:l=_n;break;case`wheel`:l=Ln;break;case`copy`:case`cut`:case`paste`:l=En;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Pn;break;case`toggle`:case`beforetoggle`:l=Rn}var d=(t&4)!=0,f=!d&&(e===`scroll`||e===`scrollend`),p=d?s===null?null:s+`Capture`:s;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=tn(m,p),g!=null&&d.push(Md(m,g,h))),f)break;m=m.return}0<d.length&&(s=new l(s,u,null,n,i),o.push({event:s,listeners:d}))}}if(!(t&7)){a:{if(s=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,s&&n!==Yt&&(u=n.relatedTarget||n.fromElement)&&(dt(u)||u[it]))break a;if((l||s)&&(s=i.window===i?i:(s=i.ownerDocument)?s.defaultView||s.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?dt(u):null,u!==null&&(f=c(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=Sn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Pn,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?s:pt(l),h=u==null?s:pt(u),s=new d(g,m+`leave`,l,n,i),s.target=f,s.relatedTarget=h,g=null,dt(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=Pd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Fd(o,s,l,d,!1),u!==null&&f!==null&&Fd(o,f,u,d,!0)}}a:{if(s=r?pt(r):window,l=s.nodeName&&s.nodeName.toLowerCase(),l===`select`||l===`input`&&s.type===`file`)var v=ir;else if(Qn(s))if(ar)v=mr;else{v=fr;var y=dr}else l=s.nodeName,!l||l.toLowerCase()!==`input`||s.type!==`checkbox`&&s.type!==`radio`?r&&Wt(r.elementType)&&(v=ir):v=pr;if(v&&=v(e,r)){$n(o,v,n,i);break a}y&&y(e,s,r),e===`focusout`&&r&&s.type===`number`&&r.memoizedProps.value!=null&&It(s,`number`,s.value)}switch(y=r?pt(r):window,e){case`focusin`:(Qn(y)||y.contentEditable===`true`)&&(wr=y,Tr=r,Er=null);break;case`focusout`:Er=Tr=wr=null;break;case`mousedown`:Dr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Dr=!1,Or(o,n,i);break;case`selectionchange`:if(Cr)break;case`keydown`:case`keyup`:Or(o,n,i)}var b;if(Bn)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else Jn?Kn(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Un&&n.locale!==`ko`&&(Jn||x!==`onCompositionStart`?x===`onCompositionEnd`&&Jn&&(b=ln()):(on=i,sn=`value`in on?on.value:on.textContent,Jn=!0)),y=Nd(r,x),0<y.length&&(x=new Dn(x,e,null,n,i),o.push({event:x,listeners:y}),b?x.data=b:(b=qn(n),b!==null&&(x.data=b)))),(b=Hn?Yn(e,n):Xn(e,n))&&(x=Nd(r,`onBeforeInput`),0<x.length&&(y=new Dn(`onBeforeInput`,`beforeinput`,null,n,i),o.push({event:y,listeners:x}),y.data=b)),bd(o,e,r,n,i)}Td(o,t)})}function Md(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Nd(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=tn(e,n),i!=null&&r.unshift(Md(e,i,a)),i=tn(e,t),i!=null&&r.push(Md(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Pd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Fd(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=tn(n,a),l!=null&&o.unshift(Md(n,l,c))):i||(l=tn(n,a),l!=null&&o.push(Md(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Id=/\r\n?/g,Ld=/\u0000|\uFFFD/g;function Rd(e){return(typeof e==`string`?e:``+e).replace(Id,`
10
+ `).replace(Ld,``)}function zd(e,t){return t=Rd(t),Rd(e)===t}function Bd(e,t,n,r,i,a){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Bt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Bt(e,``+r);break;case`className`:Tt(e,`class`,r);break;case`tabIndex`:Tt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Tt(e,n,r);break;case`style`:Ut(e,r,a);break;case`data`:if(t!==`object`){Tt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=qt(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}else typeof a==`function`&&(n===`formAction`?(t!==`input`&&Bd(e,t,`name`,i.name,i,null),Bd(e,t,`formEncType`,i.formEncType,i,null),Bd(e,t,`formMethod`,i.formMethod,i,null),Bd(e,t,`formTarget`,i.formTarget,i,null)):(Bd(e,t,`encType`,i.encType,i,null),Bd(e,t,`method`,i.method,i,null),Bd(e,t,`target`,i.target,i,null)));if(r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=qt(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=Jt);break;case`onScroll`:r!=null&&Ed(`scroll`,e);break;case`onScrollEnd`:r!=null&&Ed(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=qt(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Ed(`beforetoggle`,e),Ed(`toggle`,e),wt(e,`popover`,r);break;case`xlinkActuate`:H(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:H(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:H(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:H(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:H(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:H(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:H(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:H(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:H(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:wt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=Gt.get(n)||n,wt(e,n,r))}}function Vd(e,t,n,r,i,a){switch(n){case`style`:Ut(e,r,a);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(o(61));if(n=r.__html,n!=null){if(i.children!=null)throw Error(o(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?Bt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Bt(e,``+r);break;case`onScroll`:r!=null&&Ed(`scroll`,e);break;case`onScrollEnd`:r!=null&&Ed(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=Jt);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!_t.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(i=n.endsWith(`Capture`),t=n.slice(2,i?n.length-7:void 0),a=e[rt]||null,a=a==null?null:a[n],typeof a==`function`&&e.removeEventListener(t,a,i),typeof r==`function`)){typeof a!=`function`&&a!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,i);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):wt(e,n,r)}}}function Hd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Ed(`error`,e),Ed(`load`,e);var r=!1,i=!1,a;for(a in n)if(n.hasOwnProperty(a)){var s=n[a];if(s!=null)switch(a){case`src`:r=!0;break;case`srcSet`:i=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Bd(e,t,a,s,n,null)}}i&&Bd(e,t,`srcSet`,n.srcSet,n,null),r&&Bd(e,t,`src`,n.src,n,null);return;case`input`:Ed(`invalid`,e);var c=a=s=i=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:i=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:a=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(o(137,t));break;default:Bd(e,t,r,d,n,null)}}Ft(e,a,c,l,u,s,i,!1);return;case`select`:for(i in Ed(`invalid`,e),r=s=a=null,n)if(n.hasOwnProperty(i)&&(c=n[i],c!=null))switch(i){case`value`:a=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Bd(e,t,i,c,n,null)}t=a,n=s,e.multiple=!!r,t==null?n!=null&&Lt(e,!!r,n,!0):Lt(e,!!r,t,!1);return;case`textarea`:for(s in Ed(`invalid`,e),a=i=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:i=c;break;case`children`:a=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(o(91));break;default:Bd(e,t,s,c,n,null)}zt(e,r,i,a);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Bd(e,t,l,r,n,null)}return;case`dialog`:Ed(`beforetoggle`,e),Ed(`toggle`,e),Ed(`cancel`,e),Ed(`close`,e);break;case`iframe`:case`object`:Ed(`load`,e);break;case`video`:case`audio`:for(r=0;r<Cd.length;r++)Ed(Cd[r],e);break;case`image`:Ed(`error`,e),Ed(`load`,e);break;case`details`:Ed(`toggle`,e);break;case`embed`:case`source`:case`link`:Ed(`error`,e),Ed(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(o(137,t));default:Bd(e,t,u,r,n,null)}return;default:if(Wt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Vd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Bd(e,t,c,r,n,null))}function Ud(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var i=null,a=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Bd(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:a=m;break;case`name`:i=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(o(137,t));break;default:m!==f&&Bd(e,t,p,m,r,f)}}Pt(e,s,c,l,u,d,a,i);return;case`select`:for(a in m=s=c=p=null,n)if(l=n[a],n.hasOwnProperty(a)&&l!=null)switch(a){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(a)||Bd(e,t,a,null,r,l)}for(i in r)if(a=r[i],l=n[i],r.hasOwnProperty(i)&&(a!=null||l!=null))switch(i){case`value`:p=a;break;case`defaultValue`:c=a;break;case`multiple`:s=a;default:a!==l&&Bd(e,t,i,a,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Lt(e,!!n,n?[]:``,!1):Lt(e,!!n,t,!0)):Lt(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(i=n[c],n.hasOwnProperty(c)&&i!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Bd(e,t,c,null,r,i)}for(s in r)if(i=r[s],a=n[s],r.hasOwnProperty(s)&&(i!=null||a!=null))switch(s){case`value`:p=i;break;case`defaultValue`:m=i;break;case`children`:break;case`dangerouslySetInnerHTML`:if(i!=null)throw Error(o(91));break;default:i!==a&&Bd(e,t,s,i,r,a)}Rt(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Bd(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Bd(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Bd(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(o(137,t));break;default:Bd(e,t,u,p,r,m)}return;default:if(Wt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Vd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Vd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Bd(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Bd(e,t,f,p,r,m)}function Wd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Gd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Wd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Wd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Kd=null,qd=null;function Jd(e){return e.nodeType===9?e:e.ownerDocument}function Yd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Xd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Zd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Qd=null;function $d(){var e=window.event;return e&&e.type===`popstate`?e===Qd?!1:(Qd=e,!0):(Qd=null,!1)}var ef=typeof setTimeout==`function`?setTimeout:void 0,tf=typeof clearTimeout==`function`?clearTimeout:void 0,nf=typeof Promise==`function`?Promise:void 0,rf=typeof queueMicrotask==`function`?queueMicrotask:nf===void 0?ef:function(e){return nf.resolve(null).then(e).catch(af)};function af(e){setTimeout(function(){throw e})}function of(e){return e===`head`}function sf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Vp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)xf(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,xf(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[lt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&xf(e.ownerDocument.body);n=i}while(n);Vp(t)}function cf(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8)if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++;n=r}while(n)}function lf(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:lf(n),ut(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function uf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r)if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e;else if(!e[lt])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=gf(e.nextSibling),e===null)break}return null}function df(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=gf(e.nextSibling),e===null))return null;return e}function ff(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=gf(e.nextSibling),e===null))return null;return e}function pf(e){return e.data===`$?`||e.data===`$~`}function mf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function hf(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function gf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var _f=null;function vf(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return gf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function yf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function bf(e,t,n){switch(t=Jd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(o(452));return e;case`head`:if(e=t.head,!e)throw Error(o(453));return e;case`body`:if(e=t.body,!e)throw Error(o(454));return e;default:throw Error(o(451))}}function xf(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);ut(e)}var Sf=new Map,Cf=new Set;function wf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Tf=I.d;I.d={f:Ef,r:Df,D:Af,C:jf,L:Mf,m:Nf,X:Ff,S:Pf,M:If};function Ef(){var e=Tf.f(),t=Tu();return e||t}function Df(e){var t=ft(e);t!==null&&t.tag===5&&t.type===`form`?ws(t):Tf.r(e)}var Of=typeof document>`u`?null:document;function kf(e,t,n){var r=Of;if(r&&typeof t==`string`&&t){var i=Nt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Cf.has(i)||(Cf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Hd(t,`link`,e),ht(t),r.head.appendChild(t)))}}function Af(e){Tf.D(e),kf(`dns-prefetch`,e,null)}function jf(e,t){Tf.C(e,t),kf(`preconnect`,e,t)}function Mf(e,t,n){Tf.L(e,t,n);var r=Of;if(r&&e&&t){var i=`link[rel="preload"][as="`+Nt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Nt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Nt(n.imageSizes)+`"]`)):i+=`[href="`+Nt(e)+`"]`;var a=i;switch(t){case`style`:a=Rf(e);break;case`script`:a=Hf(e)}Sf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),Sf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(zf(a))||t===`script`&&r.querySelector(Uf(a))||(t=r.createElement(`link`),Hd(t,`link`,e),ht(t),r.head.appendChild(t)))}}function Nf(e,t){Tf.m(e,t);var n=Of;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Nt(r)+`"][href="`+Nt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Hf(e)}if(!Sf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),Sf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Uf(a)))return}r=n.createElement(`link`),Hd(r,`link`,e),ht(r),n.head.appendChild(r)}}}function Pf(e,t,n){Tf.S(e,t,n);var r=Of;if(r&&e){var i=mt(r).hoistableStyles,a=Rf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(zf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=Sf.get(a))&&Kf(e,n);var c=o=r.createElement(`link`);ht(c),Hd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Gf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Ff(e,t){Tf.X(e,t);var n=Of;if(n&&e){var r=mt(n).hoistableScripts,i=Hf(e),a=r.get(i);a||(a=n.querySelector(Uf(i)),a||(e=m({src:e,async:!0},t),(t=Sf.get(i))&&qf(e,t),a=n.createElement(`script`),ht(a),Hd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function If(e,t){Tf.M(e,t);var n=Of;if(n&&e){var r=mt(n).hoistableScripts,i=Hf(e),a=r.get(i);a||(a=n.querySelector(Uf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=Sf.get(i))&&qf(e,t),a=n.createElement(`script`),ht(a),Hd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Lf(e,t,n,r){var i=(i=re.current)?wf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Rf(n.href),n=mt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Rf(n.href);var a=mt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(zf(e)))&&!a._p&&(s.instance=a,s.state.loading=5),Sf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},Sf.set(e,n),a||Vf(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Hf(n),n=mt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Rf(e){return`href="`+Nt(e)+`"`}function zf(e){return`link[rel="stylesheet"][`+e+`]`}function Bf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Vf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Hd(t,`link`,n),ht(t),e.head.appendChild(t))}function Hf(e){return`[src="`+Nt(e)+`"]`}function Uf(e){return`script[async]`+e}function Wf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Nt(n.href)+`"]`);if(r)return t.instance=r,ht(r),r;var i=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),ht(r),Hd(r,`style`,i),Gf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Rf(n.href);var a=e.querySelector(zf(i));if(a)return t.state.loading|=4,t.instance=a,ht(a),a;r=Bf(n),(i=Sf.get(i))&&Kf(r,i),a=(e.ownerDocument||e).createElement(`link`),ht(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Hd(a,`link`,r),t.state.loading|=4,Gf(a,n.precedence,e),t.instance=a;case`script`:return a=Hf(n.src),(i=e.querySelector(Uf(a)))?(t.instance=i,ht(i),i):(r=n,(i=Sf.get(a))&&(r=m({},n),qf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),ht(i),Hd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Gf(r,n.precedence,e));return t.instance}function Gf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Kf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function qf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Jf=null;function Yf(e,t,n){if(Jf===null){var r=new Map,i=Jf=new Map;i.set(n,r)}else i=Jf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[lt]||a[nt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Xf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function Zf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Qf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function $f(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Rf(r.href),a=t.querySelector(zf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=np.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,ht(a);return}a=t.ownerDocument||t,r=Bf(r),(i=Sf.get(i))&&Kf(r,i),a=a.createElement(`link`),ht(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Hd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=np.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var ep=0;function tp(e,t){return e.stylesheets&&e.count===0&&ip(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ip(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&ep===0&&(ep=62500*Gd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ip(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>ep?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function np(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ip(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var rp=null;function ip(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,rp=new Map,t.forEach(ap,e),rp=null,np.call(e))}function ap(e,t){if(!(t.state.loading&4)){var n=rp.get(e);if(n)var r=n.get(null);else{n=new Map,rp.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=np.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var op={$$typeof:S,Provider:null,Consumer:null,_currentValue:L,_currentValue2:L,_threadCount:0};function sp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=Ge(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ge(0),this.hiddenUpdates=Ge(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function cp(e,t,n,r,i,a,o,s,c,l,u,d){return e=new sp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=ni(3,null,null,t),e.current=a,a.stateNode=e,t=ra(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Ia(a),e}function lp(e){return e?(e=ei,e):ei}function up(e,t,n,r,i,a){i=lp(i),r.context===null?r.context=i:r.pendingContext=i,r=Ra(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=za(e,r,t),n!==null&&(bu(n,e,t),Ba(n,e,t))}function dp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function fp(e,t){dp(e,t),(e=e.alternate)&&dp(e,t)}function pp(e){if(e.tag===13||e.tag===31){var t=Zr(e,67108864);t!==null&&bu(t,e,67108864),fp(e,67108864)}}function mp(e){if(e.tag===13||e.tag===31){var t=vu();t=Ze(t);var n=Zr(e,t);n!==null&&bu(n,e,t),fp(e,t)}}var hp=!0;function gp(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=2,vp(e,t,n,r)}finally{I.p=a,F.T=i}}function _p(e,t,n,r){var i=F.T;F.T=null;var a=I.p;try{I.p=8,vp(e,t,n,r)}finally{I.p=a,F.T=i}}function vp(e,t,n,r){if(hp){var i=yp(r);if(i===null)jd(e,t,r,bp,n),jp(e,r);else if(Np(i,e,t,n,r))r.stopPropagation();else if(jp(e,r),t&4&&-1<Ap.indexOf(e)){for(;i!==null;){var a=ft(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Be(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ne(o);s.entanglements[1]|=c,o&=~c}ld(a),!(zl&6)&&(ou=xe()+500,ud(0,!1))}}break;case 31:case 13:s=Zr(a,2),s!==null&&bu(s,a,2),Tu(),fp(a,2)}if(a=yp(r),a===null&&jd(e,t,r,bp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else jd(e,t,r,null,n)}}function yp(e){return e=Xt(e),xp(e)}var bp=null;function xp(e){if(bp=null,e=dt(e),e!==null){var t=c(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=l(t),e!==null)return e;e=null}else if(n===31){if(e=u(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return bp=e,null}function Sp(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`resize`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Se()){case Ce:return 2;case we:return 8;case Te:case Ee:return 32;case De:return 268435456;default:return 32}default:return 32}}var Cp=!1,wp=null,Tp=null,Ep=null,Dp=new Map,Op=new Map,kp=[],Ap=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function jp(e,t){switch(e){case`focusin`:case`focusout`:wp=null;break;case`dragenter`:case`dragleave`:Tp=null;break;case`mouseover`:case`mouseout`:Ep=null;break;case`pointerover`:case`pointerout`:Dp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Op.delete(t.pointerId)}}function Mp(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=ft(t),t!==null&&pp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Np(e,t,n,r,i){switch(t){case`focusin`:return wp=Mp(wp,e,t,n,r,i),!0;case`dragenter`:return Tp=Mp(Tp,e,t,n,r,i),!0;case`mouseover`:return Ep=Mp(Ep,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Dp.set(a,Mp(Dp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Op.set(a,Mp(Op.get(a)||null,e,t,n,r,i)),!0}return!1}function Pp(e){var t=dt(e.target);if(t!==null){var n=c(t);if(n!==null){if(t=n.tag,t===13){if(t=l(n),t!==null){e.blockedOn=t,et(e.priority,function(){mp(n)});return}}else if(t===31){if(t=u(n),t!==null){e.blockedOn=t,et(e.priority,function(){mp(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Fp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=yp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Yt=r,n.target.dispatchEvent(r),Yt=null}else return t=ft(n),t!==null&&pp(t),e.blockedOn=n,!1;t.shift()}return!0}function Ip(e,t,n){Fp(e)&&n.delete(t)}function Lp(){Cp=!1,wp!==null&&Fp(wp)&&(wp=null),Tp!==null&&Fp(Tp)&&(Tp=null),Ep!==null&&Fp(Ep)&&(Ep=null),Dp.forEach(Ip),Op.forEach(Ip)}function Rp(e,t){e.blockedOn===t&&(e.blockedOn=null,Cp||(Cp=!0,r.unstable_scheduleCallback(r.unstable_NormalPriority,Lp)))}var zp=null;function Bp(e){zp!==e&&(zp=e,r.unstable_scheduleCallback(r.unstable_NormalPriority,function(){zp===e&&(zp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(xp(r||n)===null)continue;break}var a=ft(n);a!==null&&(e.splice(t,3),t-=3,Ss(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Vp(e){function t(t){return Rp(t,e)}wp!==null&&Rp(wp,e),Tp!==null&&Rp(Tp,e),Ep!==null&&Rp(Ep,e),Dp.forEach(t),Op.forEach(t);for(var n=0;n<kp.length;n++){var r=kp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<kp.length&&(n=kp[0],n.blockedOn===null);)Pp(n),n.blockedOn===null&&kp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[rt]||null;if(typeof a==`function`)o||Bp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[rt]||null)s=o.formAction;else if(xp(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Bp(n)}}}function Hp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function Up(e){this._internalRoot=e}Wp.prototype.render=Up.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(o(409));var n=t.current;up(n,vu(),e,t,null,null)},Wp.prototype.unmount=Up.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;up(e.current,2,null,e,null,null),Tu(),t[it]=null}};function Wp(e){this._internalRoot=e}Wp.prototype.unstable_scheduleHydration=function(e){if(e){var t=$e();e={blockedOn:null,target:e,priority:t};for(var n=0;n<kp.length&&t!==0&&t<kp[n].priority;n++);kp.splice(n,0,e),n===0&&Pp(e)}};var Gp=i.version;if(Gp!==`19.2.7`)throw Error(o(527,Gp,`19.2.7`));I.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(o(188)):(e=Object.keys(e).join(`,`),Error(o(268,e)));return e=f(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var Kp={bundleType:0,version:`19.2.7`,rendererPackageName:`react-dom`,currentDispatcherRef:F,reconcilerVersion:`19.2.7`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var qp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qp.isDisabled&&qp.supportsFiber)try{Ae=qp.inject(Kp),je=qp}catch{}}t.createRoot=function(e,t){if(!s(e))throw Error(o(299));var n=!1,r=``,i=Gs,a=Ks,c=qs;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(i=t.onUncaughtError),t.onCaughtError!==void 0&&(a=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=cp(e,1,!1,null,null,n,r,null,i,a,c,Hp),e[it]=t.current,kd(e),new Up(t)}})),_te=i(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=gte()})),vte=Object.defineProperty,yte=(e,t,n)=>t in e?vte(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qT=(e,t,n)=>yte(e,typeof t==`symbol`?t:t+``,n),JT=void 0,bte=class{constructor(e,t){if(qT(this,`address`),qT(this,`auth`),qT(this,`adminAuth`),qT(this,`encodedTsPromise`),qT(this,`debug`),qT(this,`fetchOptions`),qT(this,`fetch`),qT(this,`logger`),qT(this,`mutationQueue`,[]),qT(this,`isProcessingQueue`,!1),typeof t==`boolean`)throw Error("skipConvexDeploymentUrlCheck as the second argument is no longer supported. Please pass an options object, `{ skipConvexDeploymentUrlCheck: true }`.");(t??{}).skipConvexDeploymentUrlCheck!==!0&&Dn(e),this.logger=t?.logger===!1?xs({verbose:!1}):t?.logger!==!0&&t?.logger?t.logger:Ki({verbose:!1}),this.address=e,this.debug=!0,this.auth=void 0,this.adminAuth=void 0,this.fetch=t?.fetch,t?.auth&&this.setAuth(t.auth)}backendUrl(){return`${this.address}/api`}get url(){return this.address}setAuth(e){this.clearAuth(),this.auth=e}setAdminAuth(e,t){if(this.clearAuth(),t!==void 0){let n=new TextEncoder().encode(JSON.stringify(t)),r=btoa(String.fromCodePoint(...n));this.adminAuth=`${e}:${r}`}else this.adminAuth=e}clearAuth(){this.auth=void 0,this.adminAuth=void 0}setDebug(e){this.debug=e}setFetchOptions(e){this.fetchOptions=e}async consistentQuery(e,...t){let n=Nl(t[0]),r=this.getTimestamp();return await this.queryInner(e,n,{timestampPromise:r})}async getTimestamp(){return this.encodedTsPromise?this.encodedTsPromise:this.encodedTsPromise=this.getTimestampInner()}async getTimestampInner(){let e=this.fetch||JT||fetch,t={"Content-Type":`application/json`,"Convex-Client":`npm-${Se}`},n=await e(`${this.address}/api/query_ts`,{...this.fetchOptions,method:`POST`,headers:t});if(!n.ok)throw Error(await n.text());let{ts:r}=await n.json();return r}async query(e,...t){let n=Nl(t[0]);return await this.queryInner(e,n,{})}async queryInner(e,t,n){let r=Tr(e),i=[Qn(t)],a={"Content-Type":`application/json`,"Convex-Client":`npm-${Se}`};this.adminAuth?a.Authorization=`Convex ${this.adminAuth}`:this.auth&&(a.Authorization=`Bearer ${this.auth}`);let o=this.fetch||JT||fetch,s=n.timestampPromise?await n.timestampPromise:void 0,c=JSON.stringify({path:r,format:`convex_encoded_json`,args:i,...s?{ts:s}:{}}),l=await o(s?`${this.address}/api/query_at_ts`:`${this.address}/api/query`,{...this.fetchOptions,body:c,method:`POST`,headers:a});if(!l.ok&&l.status!==560)throw Error(await l.text());let u=await l.json();if(this.debug)for(let e of u.logLines??[])Ex(this.logger,`info`,`query`,r,e);switch(u.status){case`success`:return Fc(u.value);case`error`:throw u.errorData===void 0?Error(u.errorMessage):YT(u.errorData,new sl(u.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(u)}`)}}async mutationInner(e,t){let n=Tr(e),r=JSON.stringify({path:n,format:`convex_encoded_json`,args:[Qn(t)]}),i={"Content-Type":`application/json`,"Convex-Client":`npm-${Se}`};this.adminAuth?i.Authorization=`Convex ${this.adminAuth}`:this.auth&&(i.Authorization=`Bearer ${this.auth}`);let a=await(this.fetch||JT||fetch)(`${this.address}/api/mutation`,{...this.fetchOptions,body:r,method:`POST`,headers:i});if(!a.ok&&a.status!==560)throw Error(await a.text());let o=await a.json();if(this.debug)for(let e of o.logLines??[])Ex(this.logger,`info`,`mutation`,n,e);switch(o.status){case`success`:return Fc(o.value);case`error`:throw o.errorData===void 0?Error(o.errorMessage):YT(o.errorData,new sl(o.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(o)}`)}}async processMutationQueue(){if(!this.isProcessingQueue){for(this.isProcessingQueue=!0;this.mutationQueue.length>0;){let{mutation:e,args:t,resolve:n,reject:r}=this.mutationQueue.shift();try{n(await this.mutationInner(e,t))}catch(e){r(e)}}this.isProcessingQueue=!1}}enqueueMutation(e,t){return new Promise((n,r)=>{this.mutationQueue.push({mutation:e,args:t,resolve:n,reject:r}),this.processMutationQueue()})}async mutation(e,...t){let[n,r]=t,i=Nl(n);return r?.skipQueue?await this.mutationInner(e,i):await this.enqueueMutation(e,i)}async action(e,...t){let n=Nl(t[0]),r=Tr(e),i=JSON.stringify({path:r,format:`convex_encoded_json`,args:[Qn(n)]}),a={"Content-Type":`application/json`,"Convex-Client":`npm-${Se}`};this.adminAuth?a.Authorization=`Convex ${this.adminAuth}`:this.auth&&(a.Authorization=`Bearer ${this.auth}`);let o=await(this.fetch||JT||fetch)(`${this.address}/api/action`,{...this.fetchOptions,body:i,method:`POST`,headers:a});if(!o.ok&&o.status!==560)throw Error(await o.text());let s=await o.json();if(this.debug)for(let e of s.logLines??[])Ex(this.logger,`info`,`action`,r,e);switch(s.status){case`success`:return Fc(s.value);case`error`:throw s.errorData===void 0?Error(s.errorMessage):YT(s.errorData,new sl(s.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(s)}`)}}async function(e,t,...n){let r=Nl(n[0]),i=typeof e==`string`?e:Tr(e),a=JSON.stringify({componentPath:t,path:i,format:`convex_encoded_json`,args:Qn(r)}),o={"Content-Type":`application/json`,"Convex-Client":`npm-${Se}`};this.adminAuth?o.Authorization=`Convex ${this.adminAuth}`:this.auth&&(o.Authorization=`Bearer ${this.auth}`);let s=await(this.fetch||JT||fetch)(`${this.address}/api/function`,{...this.fetchOptions,body:a,method:`POST`,headers:o});if(!s.ok&&s.status!==560)throw Error(await s.text());let c=await s.json();if(this.debug)for(let e of c.logLines??[])Ex(this.logger,`info`,`any`,i,e);switch(c.status){case`success`:return Fc(c.value);case`error`:throw c.errorData===void 0?Error(c.errorMessage):YT(c.errorData,new sl(c.errorMessage));default:throw Error(`Invalid response: ${JSON.stringify(c)}`)}}};function YT(e,t){return t.data=Fc(e),t}var q=r(e(),1),XT=(0,q.createContext)(void 0);function ZT(){let e=(0,q.useContext)(XT);if(e===void 0)throw Error("Could not find `ConvexProviderWithAuth` (or `ConvexProviderWithClerk` or `ConvexProviderWithAuth0`) as an ancestor component. This component may be missing, or you might have two instances of the `convex/react` module loaded in your project.");return e}function QT({children:e,client:t,useAuth:n}){let{isLoading:r,isAuthenticated:i,fetchAccessToken:a}=n(),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(!1);r&&o!==null&&(s(null),l(!1)),!r&&!i&&o!==!1&&(s(!1),l(!1));let u=i&&(o??!1);return q.createElement(XT.Provider,{value:{isLoading:o===null,isAuthenticated:u,isRefreshing:c&&u}},q.createElement($T,{authProviderAuthenticated:i,fetchAccessToken:a,authProviderLoading:r,client:t,setIsConvexAuthenticated:s,setIsRefreshing:l}),q.createElement(z,{client:t},e),q.createElement(eE,{authProviderAuthenticated:i,fetchAccessToken:a,authProviderLoading:r,client:t,setIsConvexAuthenticated:s,setIsRefreshing:l}))}function $T({authProviderAuthenticated:e,fetchAccessToken:t,authProviderLoading:n,client:r,setIsConvexAuthenticated:i,setIsRefreshing:a}){return(0,q.useEffect)(()=>{let n=!0;if(e)return r.setAuth(t,e=>{n&&i(()=>e)},e=>{n&&a(e)}),()=>{n=!1,i(e=>!e&&null),a(!1)}},[e,t,n,r,i,a]),null}function eE({authProviderAuthenticated:e,fetchAccessToken:t,authProviderLoading:n,client:r,setIsConvexAuthenticated:i,setIsRefreshing:a}){return(0,q.useEffect)(()=>{if(e)return()=>{r.clearAuth(),i(()=>null),a(!1)}},[e,t,n,r,i,a]),null}function tE({children:e}){let{isLoading:t,isAuthenticated:n}=ZT();return t||!n?null:q.createElement(q.Fragment,null,e)}function nE({children:e}){let{isLoading:t,isAuthenticated:n}=ZT();return t||n?null:q.createElement(q.Fragment,null,e)}function rE({children:e}){let{isLoading:t}=ZT();return t?q.createElement(q.Fragment,null,e):null}var iE=r(_te(),1),J=a(),aE=Object.prototype.toString,oE=e=>aE.call(e)===`[object Error]`,sE=new Set([`network error`,`NetworkError when attempting to fetch resource.`,`The Internet connection appears to be offline.`,`Network request failed`,`fetch failed`,`terminated`,` A network error occurred.`,`Network connection lost`]);function cE(e){if(!(e&&oE(e)&&e.name===`TypeError`&&typeof e.message==`string`))return!1;let{message:t,stack:n}=e;return t===`Load failed`||t.startsWith(`Load failed (`)&&t.endsWith(`)`)?n===void 0||`__sentry_captured__`in e:t.startsWith(`error sending request for url`)||t===`Failed to fetch`||t.startsWith(`Failed to fetch (`)&&t.endsWith(`)`)?!0:sE.has(t)}var lE=[500,2e3],uE=100,dE=(0,q.createContext)(void 0),fE=(0,q.createContext)(void 0);function pE(){return(0,q.useContext)(fE)}var mE=(0,q.createContext)(null),hE=`__convexAuthOAuthVerifier`,gE=`__convexAuthJWT`,_E=`__convexAuthRefreshToken`,vE=`__convexAuthServerStateFetchTime`;function yE({client:e,serverState:t,onChange:n,shouldHandleCode:r,storage:i,storageNamespace:a,replaceURL:o,children:s}){let c=(0,q.useRef)(t?._state.token??null),[l,u]=(0,q.useState)(c.current===null),[d,f]=(0,q.useState)(c.current),p=e.verbose??!1,m=(0,q.useCallback)(t=>{p&&(console.debug(`${new Date().toISOString()} ${t}`),e.logger?.logVerbose(t))},[p]),{storageSet:h,storageGet:g,storageRemove:_,storageKey:v}=bE(i,a),[y,b]=(0,q.useState)(!1),x=(0,q.useCallback)(async e=>{let t=c.current!==null,r;if(e.tokens===null)c.current=null,e.shouldStore&&(await _(gE),await _(_E)),r=null;else{let{token:t}=e.tokens;if(c.current=t,e.shouldStore){let{refreshToken:n}=e.tokens;await h(gE,t),await h(_E,n)}r=t}t!==(r!==null)&&await n?.(),f(r),u(!1)},[h,_]);(0,q.useEffect)(()=>{let e=async e=>{if(y)return e.preventDefault(),e.returnValue=!0,`Are you sure you want to leave? Your changes may not be saved.`};return DE(`beforeunload`,e),()=>{OE(`beforeunload`,e)}}),(0,q.useEffect)(()=>{let e=e=>{(async()=>{if(e.storageArea===i&&e.key===v(gE)){let t=e.newValue;m(`synced access token, is null: ${t===null}`),await x({shouldStore:!1,tokens:t===null?null:{token:t}})}})()};return DE(`storage`,e),()=>OE(`storage`,e)},[x]);let S=(0,q.useCallback)(async t=>{let n,r=0;for(;r<lE.length;)try{return await e.unauthenticatedCall(`auth:signIn`,`code`in t?{params:{code:t.code},verifier:t.verifier}:t)}catch(e){if(n=e,!cE(e))break;let t=lE[r]+uE*Math.random();r++,m(`verifyCode failed with network error, retry ${r} of ${lE.length} in ${t}ms`),await new Promise(e=>setTimeout(e,t))}throw n},[e]),C=(0,q.useCallback)(async e=>{let{tokens:t}=await S(e);return m(`retrieved tokens, is null: ${t===null}`),await x({shouldStore:!0,tokens:t??null}),t!==null},[e,x]),w=(0,q.useCallback)(async(t,n)=>{let r=n instanceof FormData?Array.from(n.entries()).reduce((e,[t,n])=>(e[t]=n,e),{}):n??{},i=await g(hE)??void 0;await _(hE);let a=await e.authenticatedCall(`auth:signIn`,{provider:t,params:r,verifier:i});if(a.redirect!==void 0){let e=new URL(a.redirect);return await h(hE,a.verifier),navigator.product!==`ReactNative`&&(window.location.href=e.toString()),{signingIn:!1,redirect:e}}else if(a.tokens!==void 0){let{tokens:e}=a;return m(`signed in and got tokens, is null: ${e===null}`),await x({shouldStore:!0,tokens:e}),{signingIn:a.tokens!==null}}return{signingIn:!1}},[e,x,g]),T=(0,q.useCallback)(async()=>{try{await e.authenticatedCall(`auth:signOut`)}catch{}m(`signed out, erasing tokens`),await x({shouldStore:!0,tokens:null})},[x,e]),E=(0,q.useCallback)(async({forceRefreshToken:e})=>{if(e){let e=c.current;return await SE(_E,async()=>{let t=c.current;if(t!==e)return m(`returning synced token, is null: ${t===null}`),t;let n=await g(_E)??null;return n===null?(b(!1),m(`returning null, there is no refresh token`),null):(b(!0),await C({refreshToken:n}).finally(()=>{b(!1)}),m(`returning retrieved token, is null: ${t===null}`),c.current)})}return c.current},[C,T,g]),D=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(i===void 0)throw Error("`localStorage` is not available in this environment, set the `storage` prop on `ConvexAuthProvider`!");let e=async()=>{let e=await g(gE)??null;m(`retrieved token from storage, is null: ${e===null}`),await x({shouldStore:!1,tokens:e===null?null:{token:e}})};if(t!==void 0){let n=g(vE),r=n=>{if(!n||t._timeFetched>+n){let{token:e,refreshToken:n}=t._state,r=e===null||n===null?null:{token:e,refreshToken:n};h(vE,t._timeFetched.toString()),x({tokens:r,shouldStore:!0})}else e()};n instanceof Promise?n.then(r):r(n);return}let n=window?.location?.search===void 0?null:new URLSearchParams(window.location.search).get(`code`);if(!D.current)if(n&&(r===void 0||(typeof r==`function`?r():r))){D.current=!0;let e=new URL(window.location.href);e.searchParams.delete(`code`),(async()=>{await o(e.pathname+e.search+e.hash),await w(void 0,{code:n}),D.current=!1})()}else e()},[e,g]);let O=(0,q.useMemo)(()=>({signIn:w,signOut:T}),[w,T]),k=d!==null,A=(0,q.useMemo)(()=>({isLoading:l,isAuthenticated:k,fetchAccessToken:E}),[E,l,k]);return(0,J.jsx)(fE.Provider,{value:A,children:(0,J.jsx)(dE.Provider,{value:O,children:(0,J.jsx)(mE.Provider,{value:d,children:s})})})}function bE(e,t){let n=xE(),r=(0,q.useMemo)(()=>e??n(),[e]),i=t.replace(/[^a-zA-Z0-9]/g,``),a=(0,q.useCallback)(e=>`${e}_${i}`,[t]);return{storageSet:(0,q.useCallback)((e,t)=>r.setItem(a(e),t),[r,a]),storageGet:(0,q.useCallback)(e=>r.getItem(a(e)),[r,a]),storageRemove:(0,q.useCallback)(e=>r.removeItem(a(e)),[r,a]),storageKey:a}}function xE(){let[e,t]=(0,q.useState)({});return()=>({getItem:t=>e[t],setItem:(e,n)=>{t(t=>({...t,[e]:n}))},removeItem:e=>{t(t=>{let{[e]:n,...r}=t;return r})}})}async function SE(e,t){let n=window?.navigator?.locks;return n===void 0?await EE(e,t):await n.request(e,t)}function CE(e){globalThis.__convexAuthMutexes===void 0&&(globalThis.__convexAuthMutexes={});let t=globalThis.__convexAuthMutexes[e];return t===void 0&&(globalThis.__convexAuthMutexes[e]={currentlyRunning:null,waiting:[]}),t=globalThis.__convexAuthMutexes[e],t}function wE(e,t){globalThis.__convexAuthMutexes[e]=t}async function TE(e,t){let n=CE(e);n.currentlyRunning===null?wE(e,{currentlyRunning:t().finally(()=>{let t=CE(e).waiting.shift();CE(e).currentlyRunning=null,wE(e,{...CE(e),currentlyRunning:t===void 0?null:TE(e,t)})}),waiting:[]}):wE(e,{...n,waiting:[...n.waiting,t]})}async function EE(e,t){return new Promise((n,r)=>{TE(e,()=>t().then(e=>n(e)).catch(e=>r(e)))})}function DE(e,t,n){typeof window>`u`||window.addEventListener?.(e,t,n)}function OE(e,t,n){typeof window>`u`||window.removeEventListener?.(e,t,n)}function kE(){return(0,q.useContext)(dE)}function AE(e){let{client:t,storage:n,storageNamespace:r,replaceURL:i,shouldHandleCode:a,children:o}=e;return(0,J.jsx)(yE,{client:(0,q.useMemo)(()=>({authenticatedCall(e,n){return t.action(e,n)},unauthenticatedCall(e,n){return new bte(t.address,{logger:t.logger}).action(e,n)},verbose:t.options?.verbose,logger:t.logger}),[t]),storage:n??(typeof window>`u`?void 0:window?.localStorage),storageNamespace:r??t.address,replaceURL:i??(e=>{window.history.replaceState({},``,e)}),shouldHandleCode:a,children:(0,J.jsx)(QT,{client:t,useAuth:pE,children:o})})}function jE(){return(0,q.useContext)(mE)}var ME=q.use,NE=typeof window<`u`?q.useLayoutEffect:q.useEffect;function PE(e){let t=q.useRef({value:e,prev:null}),n=t.current.value;return e!==n&&(t.current={value:e,prev:n}),t.current.prev}function FE(e,t,n={},r={}){q.useEffect(()=>{if(!e.current||r.disabled||typeof IntersectionObserver!=`function`)return;let i=new IntersectionObserver(([e])=>{t(e)},n);return i.observe(e.current),()=>{i.disconnect()}},[t,n,r.disabled,e])}function IE(e){let t=q.useRef(null);return q.useImperativeHandle(e,()=>t.current,[]),t}function LE(e){let t=new Map,n,r,i=e=>{e.next&&(e.prev?(e.prev.next=e.next,e.next.prev=e.prev,e.next=void 0,r&&(r.next=e,e.prev=r)):(e.next.prev=void 0,n=e.next,e.next=void 0,r&&(e.prev=r,r.next=e)),r=e)};return{get(e){let n=t.get(e);if(n)return i(n),n.value},set(a,o){if(t.size>=e&&n){let e=n;t.delete(e.key),e.next&&(n=e.next,e.next.prev=void 0),e===r&&(r=void 0)}let s=t.get(a);if(s)s.value=o,i(s);else{let e={key:a,value:o,prev:r};r&&(r.next=e),r=e,n||=e,t.set(a,e)}},clear(){t.clear(),n=void 0,r=void 0}}}var RE=4,zE=5;function BE(e){let t=e.indexOf(`{`);if(t===-1)return null;let n=e.indexOf(`}`,t);return n===-1||t+1>=e.length?null:[t,n]}function VE(e,t,n=new Uint16Array(6)){let r=e.indexOf(`/`,t),i=r===-1?e.length:r,a=e.substring(t,i);if(!a||!a.includes(`$`))return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n;if(a===`$`){let r=e.length;return n[0]=2,n[1]=t,n[2]=t,n[3]=r,n[4]=r,n[5]=r,n}if(a.charCodeAt(0)===36)return n[0]=1,n[1]=t,n[2]=t+1,n[3]=i,n[4]=i,n[5]=i,n;let o=BE(a);if(o){let[r,s]=o,c=a.charCodeAt(r+1);if(c===45){if(r+2<a.length&&a.charCodeAt(r+2)===36){let e=r+3,a=s;if(e<a)return n[0]=3,n[1]=t+r,n[2]=t+e,n[3]=t+a,n[4]=t+s+1,n[5]=i,n}}else if(c===36){let a=r+1,o=r+2;return o===s?(n[0]=2,n[1]=t+r,n[2]=t+a,n[3]=t+o,n[4]=t+s+1,n[5]=e.length,n):(n[0]=1,n[1]=t+r,n[2]=t+o,n[3]=t+s,n[4]=t+s+1,n[5]=i,n)}}return n[0]=0,n[1]=t,n[2]=t,n[3]=i,n[4]=i,n[5]=i,n}function HE(e,t,n,r,i,a,o){o?.(n);let s=r;{let r=n.fullPath??n.from,o=r.length,c=n.options?.caseSensitive??e,l=n.options?.params?.parse??n.options?.parseParams;for(;s<o;){let e=VE(r,s,t),o,u=s,d=e[5];switch(s=d+1,a++,e[0]){case 0:{let t=r.substring(e[2],e[3]);if(c){let e=i.static?.get(t);if(e)o=e;else{i.static??=new Map;let e=GE(n.fullPath??n.from);e.parent=i,e.depth=a,o=e,i.static.set(t,e)}}else{let e=t.toLowerCase(),r=i.staticInsensitive?.get(e);if(r)o=r;else{i.staticInsensitive??=new Map;let t=GE(n.fullPath??n.from);t.parent=i,t.depth=a,o=t,i.staticInsensitive.set(e,t)}}break}case 1:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.dynamic?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=KE(1,n.fullPath??n.from,f,p,m);o=e,e.depth=a,e.parent=i,i.dynamic??=[],i.dynamic.push(e)}break}case 3:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),f=c&&!!(t||s),p=t?f?t:t.toLowerCase():void 0,m=s?f?s:s.toLowerCase():void 0,h=!l&&i.optional?.find(e=>!e.parse&&e.caseSensitive===f&&e.prefix===p&&e.suffix===m);if(h)o=h;else{let e=KE(3,n.fullPath??n.from,f,p,m);o=e,e.parent=i,e.depth=a,i.optional??=[],i.optional.push(e)}break}case 2:{let t=r.substring(u,e[1]),s=r.substring(e[4],d),l=c&&!!(t||s),f=t?l?t:t.toLowerCase():void 0,p=s?l?s:s.toLowerCase():void 0,m=KE(2,n.fullPath??n.from,l,f,p);o=m,m.parent=i,m.depth=a,i.wildcard??=[],i.wildcard.push(m)}}i=o}if(l&&n.children&&!n.isRoot&&n.id&&n.id.charCodeAt(n.id.lastIndexOf(`/`)+1)===95){let e=GE(n.fullPath??n.from);e.kind=zE,e.parent=i,a++,e.depth=a,i.pathless??=[],i.pathless.push(e),i=e}let u=(n.path||!n.children)&&!n.isRoot;if(u&&r.endsWith(`/`)){let e=GE(n.fullPath??n.from);e.kind=RE,e.parent=i,a++,e.depth=a,i.index=e,i=e}i.parse=l??null,i.priority=n.options?.params?.priority??0,u&&!i.route&&(i.route=n,i.fullPath=n.fullPath??n.from)}if(n.children)for(let r of n.children)HE(e,t,r,s,i,a,o)}function UE(e,t){if(e.parse&&!t.parse)return-1;if(!e.parse&&t.parse)return 1;if(e.parse&&t.parse&&(e.priority||t.priority))return t.priority-e.priority;if(e.prefix&&t.prefix&&e.prefix!==t.prefix){if(e.prefix.startsWith(t.prefix))return-1;if(t.prefix.startsWith(e.prefix))return 1}if(e.suffix&&t.suffix&&e.suffix!==t.suffix){if(e.suffix.endsWith(t.suffix))return-1;if(t.suffix.endsWith(e.suffix))return 1}return e.prefix&&!t.prefix?-1:!e.prefix&&t.prefix?1:e.suffix&&!t.suffix?-1:!e.suffix&&t.suffix?1:e.caseSensitive&&!t.caseSensitive?-1:!e.caseSensitive&&t.caseSensitive?1:0}function WE(e){if(e.pathless)for(let t of e.pathless)WE(t);if(e.static)for(let t of e.static.values())WE(t);if(e.staticInsensitive)for(let t of e.staticInsensitive.values())WE(t);if(e.dynamic?.length){e.dynamic.sort(UE);for(let t of e.dynamic)WE(t)}if(e.optional?.length){e.optional.sort(UE);for(let t of e.optional)WE(t)}if(e.wildcard?.length){e.wildcard.sort(UE);for(let t of e.wildcard)WE(t)}}function GE(e){return{kind:0,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:e,parent:null,parse:null,priority:0}}function KE(e,t,n,r,i){return{kind:e,depth:0,pathless:null,index:null,static:null,staticInsensitive:null,dynamic:null,optional:null,wildcard:null,route:null,fullPath:t,parent:null,parse:null,priority:0,caseSensitive:n,prefix:r,suffix:i}}function qE(e,t){let n=GE(`/`),r=new Uint16Array(6);for(let t of e)HE(!1,r,t,1,n,0);WE(n),t.masksTree=n,t.flatCache=LE(1e3)}function JE(e,t){e||=`/`;let n=t.flatCache.get(e);if(n)return n;let r=$E(e,t.masksTree);return t.flatCache.set(e,r),r}function YE(e,t,n,r,i){e||=`/`,r||=`/`;let a=t?`case\0${e}`:e,o=i.singleCache.get(a);return o||(o=GE(`/`),HE(t,new Uint16Array(6),{from:e},1,o,0),i.singleCache.set(a,o)),$E(r,o,n)}function XE(e,t,n=!1){let r=n?e:`nofuzz\0${e}`,i=t.matchCache.get(r);if(i!==void 0)return i;e||=`/`;let a;try{a=$E(e,t.segmentTree,n)}catch(e){if(e instanceof URIError)a=null;else throw e}return a&&(a.branch=tD(a.route)),t.matchCache.set(r,a),a}function ZE(e){return e===`/`?e:e.replace(/\/{1,}$/,``)}function QE(e,t=!1,n){let r=GE(e.fullPath),i=new Uint16Array(6),a={},o={},s=0;return HE(t,i,e,1,r,0,e=>{if(n?.(e,s),e.id in a&&Px(),a[e.id]=e,s!==0&&e.path){let t=ZE(e.fullPath);(!o[t]||e.fullPath.endsWith(`/`))&&(o[t]=e)}s++}),WE(r),{processedTree:{segmentTree:r,singleCache:LE(1e3),matchCache:LE(1e3),flatCache:null,masksTree:null},routesById:a,routesByPath:o}}function $E(e,t,n=!1){let r=e.split(`/`),i=rD(e,r,t,n);if(!i)return null;let[a]=eD(e,r,i);return{route:i.node.route,rawParams:a}}function eD(e,t,n){let r=nD(n.node),i=null,a=Object.create(null),o=n.extract?.part??0,s=n.extract?.node??0,c=n.extract?.path??0,l=n.extract?.segment??0;for(;s<r.length;o++,s++,c++,l++){let u=r[s];if(u.kind===RE)break;if(u.kind===zE){l--,o--,c--;continue}let d=t[o],f=c;if(d&&(c+=d.length),u.kind===1){i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0;if(e.charCodeAt(t)===123){let n=u.suffix?.length??0,r=e.substring(t+2,e.length-n-1),i=d.substring(t,d.length-n);a[r]=decodeURIComponent(i)}else{let t=e.substring(1);a[t]=decodeURIComponent(d)}}else if(u.kind===3){if(n.skipped&1<<s){o--,c=f-1;continue}i??=n.node.fullPath.split(`/`);let e=i[l],t=u.prefix?.length??0,r=u.suffix?.length??0,p=e.substring(t+3,e.length-r-1),m=u.suffix||u.prefix?d.substring(t,d.length-r):d;m&&(a[p]=decodeURIComponent(m))}else if(u.kind===2){let t=u,n=e.substring(f+(t.prefix?.length??0),e.length-(t.suffix?.length??0)),r=decodeURIComponent(n);a[`*`]=r,a._splat=r;break}}return n.rawParams&&Object.assign(a,n.rawParams),[a,{part:o,node:s,path:c,segment:l}]}function tD(e){let t=[e];for(;e.parentRoute;)e=e.parentRoute,t.push(e);return t.reverse(),t}function nD(e){let t=Array(e.depth+1);do t[e.depth]=e,e=e.parent;while(e);return t}function rD(e,t,n,r){if(e===`/`&&n.index)return{node:n.index,skipped:0};let i=!Nx(t),a=i&&e!==`/`,o=t.length-+!!i,s=[{node:n,index:1,skipped:0,depth:1,statics:0,dynamics:0,optionals:0}],c=null,l=null;for(;s.length;){let n=s.pop(),{node:i,index:u,skipped:d,depth:f,statics:p,dynamics:m,optionals:h}=n,{extract:g,rawParams:_}=n;if(i.kind===2&&i.route&&!sD(l,n))continue;if(i.parse){if(!oD(e,t,n))continue;_=n.rawParams,g=n.extract}r&&i.route&&i.kind!==RE&&sD(c,n)&&(c=n);let v=u===o;if(v&&(i.route&&(!a||i.kind===RE||i.kind===2)&&sD(l,n)&&(l=n),!i.optional&&!i.wildcard&&!i.index&&!i.pathless))continue;let y=v?void 0:t[u],b;if(v&&i.index){let n={node:i.index,index:u,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_},r=!0;if(i.index.parse&&(oD(e,t,n)||(r=!1)),r){if(!m&&!h&&!d&&aD(p,o))return n;sD(l,n)&&(l=n)}}if(i.wildcard)for(let e=i.wildcard.length-1;e>=0;e--){let n=i.wildcard[e],{prefix:r,suffix:a}=n;if(!(r&&(v||!(n.caseSensitive?y:b??=y.toLowerCase()).startsWith(r)))){if(a){if(v)continue;let e=t.slice(u).join(`/`).slice(-a.length);if((n.caseSensitive?e:e.toLowerCase())!==a)continue}s.push({node:n,index:o,skipped:d,depth:f+1,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}if(i.optional){let e=d|1<<f,t=f+1;for(let n=i.optional.length-1;n>=0;n--){let r=i.optional[n];s.push({node:r,index:u,skipped:e,depth:t,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v)for(let e=i.optional.length-1;e>=0;e--){let n=i.optional[e],{prefix:r,suffix:a}=n;if(r||a){let e=n.caseSensitive?y:b??=y.toLowerCase();if(r&&!e.startsWith(r)||a&&!e.endsWith(a))continue}s.push({node:n,index:u+1,skipped:d,depth:t,statics:p,dynamics:m,optionals:h+iD(o,u),extract:g,rawParams:_})}}if(!v&&i.dynamic&&y)for(let e=i.dynamic.length-1;e>=0;e--){let t=i.dynamic[e],{prefix:n,suffix:r}=t;if(n||r){let e=t.caseSensitive?y:b??=y.toLowerCase();if(n&&!e.startsWith(n)||r&&!e.endsWith(r))continue}s.push({node:t,index:u+1,skipped:d,depth:f+1,statics:p,dynamics:m+iD(o,u),optionals:h,extract:g,rawParams:_})}if(!v&&i.staticInsensitive){let e=i.staticInsensitive.get(b??=y.toLowerCase());e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+iD(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(!v&&i.static){let e=i.static.get(y);e&&s.push({node:e,index:u+1,skipped:d,depth:f+1,statics:p+iD(o,u),dynamics:m,optionals:h,extract:g,rawParams:_})}if(i.pathless){let e=f+1;for(let t=i.pathless.length-1;t>=0;t--){let n=i.pathless[t];s.push({node:n,index:u,skipped:d,depth:e,statics:p,dynamics:m,optionals:h,extract:g,rawParams:_})}}}if(l)return l;if(r&&c){let n=c.index;for(let e=0;e<c.index;e++)n+=t[e].length;let r=n===e.length?`/`:e.slice(n);return c.rawParams??=Object.create(null),c.rawParams[`**`]=decodeURIComponent(r),c}return null}function iD(e,t){return 2**(e-t-1)}function aD(e,t){return e===2**(t-1)-1}function oD(e,t,n){let r,i;try{[r,i]=eD(e,t,n)}catch{return null}if(n.rawParams=r,n.extract=i,!n.node.parse)return!0;try{if(n.node.parse(r)===!1)return null}catch{}return!0}function sD(e,t){return!e||t.statics>e.statics||t.statics===e.statics&&(t.dynamics>e.dynamics||t.dynamics===e.dynamics&&(t.optionals>e.optionals||t.optionals===e.optionals&&((t.node.kind===RE)>(e.node.kind===RE)||t.node.kind===RE==(e.node.kind===RE)&&t.depth>e.depth)))}function cD(e){return lD(e.filter(e=>e!==void 0).join(`/`))}function lD(e){return e.replace(/\/{2,}/g,`/`)}function uD(e){return e===`/`?e:e.replace(/^\/{1,}/,``)}function dD(e){let t=e.length;return t>1&&e[t-1]===`/`?e.replace(/\/{1,}$/,``):e}function fD(e){return dD(uD(e))}function pD(e,t){return e?.endsWith(`/`)&&e!==`/`&&e!==`${t}/`?e.slice(0,-1):e}function mD(e,t,n){return pD(e,n)===pD(t,n)}function hD({base:e,to:t,trailingSlash:n=`never`,cache:r}){let i=t.startsWith(`/`),a=!i&&t===`.`,o;if(r){o=i?t:a?e:e+`\0`+t;let n=r.get(o);if(n)return n}let s;if(a)s=e.split(`/`);else if(i)s=t.split(`/`);else{for(s=e.split(`/`);s.length>1&&Nx(s)===``;)s.pop();let n=t.split(`/`);for(let e=0,t=n.length;e<t;e++){let r=n[e];r===``?e?e===t-1&&s.push(r):s=[r]:r===`..`?s.pop():r===`.`||s.push(r)}}s.length>1&&(Nx(s)===``?n===`never`&&s.pop():n===`always`&&s.push(``));let c=lD(s.join(`/`))||`/`;return o&&r&&r.set(o,c),c}function gD(e){let t=new Map(e.map(e=>[encodeURIComponent(e),e])),n=Array.from(t.keys()).map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`),r=new RegExp(n,`g`);return e=>e.replace(r,e=>t.get(e)??e)}function _D(e,t,n){let r=t[e];return typeof r==`string`?e===`_splat`?/^[a-zA-Z0-9\-._~!/]*$/.test(r)?r:r.split(`/`).map(e=>yD(e,n)).join(`/`):yD(r,n):r}function vD({path:e,params:t,decoder:n,...r}){let i=!1,a=Object.create(null);if(!e||e===`/`)return{interpolatedPath:`/`,usedParams:a,isMissingParams:i};if(!e.includes(`$`))return{interpolatedPath:e,usedParams:a,isMissingParams:i};let o=e.length,s=0,c,l=``;for(;s<o;){let r=s;c=VE(e,r,c);let o=c[5];if(s=o+1,r===o)continue;let u=c[0];if(u===0){l+=`/`+e.substring(r,o);continue}if(u===2){let s=t._splat;a._splat=s,a[`*`]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o);if(!s){i=!0,(u||d)&&(l+=`/`+u+d);continue}let f=_D(`_splat`,t,n);l+=`/`+u+f+d;continue}if(u===1){let s=e.substring(c[2],c[3]);!i&&!(s in t)&&(i=!0),a[s]=t[s];let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=_D(s,t,n)??`undefined`;l+=`/`+u+f+d;continue}if(u===3){let i=e.substring(c[2],c[3]),s=t[i];if(s==null)continue;a[i]=s;let u=e.substring(r,c[1]),d=e.substring(c[4],o),f=_D(i,t,n)??``;l+=`/`+u+f+d;continue}}return e.endsWith(`/`)&&(l+=`/`),{usedParams:a,interpolatedPath:l||`/`,isMissingParams:i}}function yD(e,t){let n=encodeURIComponent(e);return t?.(n)??n}function bD(e){return e?.isNotFound===!0}function xD(e,t=String){let n=new URLSearchParams;for(let r in e){let i=e[r];i!==void 0&&n.set(r,t(i))}return n.toString()}function SD(e){return e?e===`false`?!1:e===`true`?!0:e*0==0&&+e+``===e?+e:e:``}function CD(e){let t=new URLSearchParams(e),n=Object.create(null);for(let[e,r]of t.entries()){let t=n[e];t==null?n[e]=SD(r):Array.isArray(t)?t.push(SD(r)):n[e]=[t,SD(r)]}return n}var wD=ED(JSON.parse),TD=DD(JSON.stringify,JSON.parse);function ED(e){return t=>{t[0]===`?`&&(t=t.substring(1));let n=CD(t);for(let t in n){let r=n[t];if(typeof r==`string`)try{n[t]=e(r)}catch{}}return n}}function DD(e,t){let n=typeof t==`function`;function r(r){if(typeof r==`object`&&r)try{return e(r)}catch{}else if(n&&typeof r==`string`)try{return t(r),e(r)}catch{}return r}return e=>{let t=xD(e,r);return t?`?${t}`:``}}var OD=`__root__`;function kD(e){if(e.statusCode=e.statusCode||e.code||307,!e._builtLocation&&!e.reloadDocument&&typeof e.href==`string`)try{new URL(e.href),e.reloadDocument=!0}catch{}let t=new Headers(e.headers);e.href&&t.get(`Location`)===null&&t.set(`Location`,e.href);let n=new Response(null,{status:e.statusCode,headers:t});if(n.options=e,e.throw)throw n;return n}function AD(e){return e instanceof Response&&!!e.options}var jD=e=>{if(!e.rendered)return e.rendered=!0,e.onReady?.()},MD=e=>e.stores.matchesId.get().some(t=>e.stores.matchStores.get(t)?.get()._forcePending),ND=(e,t)=>!!(e.preload&&!e.router.stores.matchStores.has(t)),PD=(e,t,n=!0)=>{let r={...e.router.options.context??{}},i=n?t:t-1;for(let t=0;t<=i;t++){let n=e.matches[t];if(!n)continue;let i=e.router.getMatch(n.id);i&&Object.assign(r,i.__routeContext,i.__beforeLoadContext)}return r},FD=(e,t)=>{if(!e.matches.length)return;let n=t.routeId,r=e.matches.findIndex(t=>t.routeId===e.router.routeTree.id),i=r>=0?r:0,a=n?e.matches.findIndex(e=>e.routeId===n):e.firstBadMatchIndex??e.matches.length-1;a<0&&(a=i);for(let t=a;t>=0;t--){let n=e.matches[t];if(e.router.looseRoutesById[n.routeId].options.notFoundComponent)return t}return n?a:i},ID=(e,t,n)=>{if(!(!AD(n)&&!bD(n)))throw AD(n)&&n.redirectHandled&&!n.options.reloadDocument?n:(t&&(t._nonReactive.beforeLoadPromise?.resolve(),t._nonReactive.loaderPromise?.resolve(),t._nonReactive.beforeLoadPromise=void 0,t._nonReactive.loaderPromise=void 0,t._nonReactive.error=n,e.updateMatch(t.id,r=>({...r,status:AD(n)?`redirected`:bD(n)?`notFound`:r.status===`pending`?`success`:r.status,context:PD(e,t.index),isFetching:!1,error:n})),bD(n)&&!n.routeId&&(n.routeId=t.routeId),t._nonReactive.loadPromise?.resolve()),AD(n)&&(e.rendered=!0,n.options._fromLocation=e.location,n.redirectHandled=!0,n=e.router.resolveRedirect(n)),n)},LD=(e,t)=>{let n=e.router.getMatch(t);return!!(!n||n._nonReactive.dehydrated)},RD=(e,t,n)=>{let r=PD(e,n);e.updateMatch(t,e=>({...e,context:r}))},zD=(e,t,n)=>{let{id:r,routeId:i}=e.matches[t],a=e.router.looseRoutesById[i];if(n instanceof Promise)throw n;e.firstBadMatchIndex??=t,ID(e,e.router.getMatch(r),n);try{a.options.onError?.(n)}catch(t){n=t,ID(e,e.router.getMatch(r),n)}e.updateMatch(r,e=>(e._nonReactive.beforeLoadPromise?.resolve(),e._nonReactive.beforeLoadPromise=void 0,e._nonReactive.loadPromise?.resolve(),{...e,error:n,status:`error`,isFetching:!1,updatedAt:Date.now(),abortController:new AbortController})),!e.preload&&!AD(n)&&!bD(n)&&(e.serialError??=n)},BD=(e,t,n,r)=>{if(r._nonReactive.pendingTimeout!==void 0)return;let i=n.options.pendingMs??e.router.options.defaultPendingMs;if(e.onReady&&!ND(e,t)&&(n.options.loader||n.options.beforeLoad||ZD(n))&&typeof i==`number`&&i!==1/0&&(n.options.pendingComponent??e.router.options?.defaultPendingComponent)){let t=setTimeout(()=>{jD(e)},i);r._nonReactive.pendingTimeout=t}},VD=(e,t,n)=>{let r=e.router.getMatch(t);if(!r._nonReactive.beforeLoadPromise&&!r._nonReactive.loaderPromise)return;BD(e,t,n,r);let i=()=>{let n=e.router.getMatch(t);n.preload&&(n.status===`redirected`||n.status===`notFound`)&&ID(e,n,n.error)};return r._nonReactive.beforeLoadPromise?r._nonReactive.beforeLoadPromise.then(i):i()},HD=(e,t,n,r)=>{let i=e.router.getMatch(t),a=i._nonReactive.loadPromise;i._nonReactive.loadPromise=Fx(()=>{a?.resolve(),a=void 0});let{paramsError:o,searchError:s}=i;o&&zD(e,n,o),s&&zD(e,n,s),BD(e,t,r,i);let c=new AbortController,l=!1,u=()=>{l||(l=!0,e.updateMatch(t,e=>({...e,isFetching:`beforeLoad`,fetchCount:e.fetchCount+1,abortController:c})))},d=()=>{i._nonReactive.beforeLoadPromise?.resolve(),i._nonReactive.beforeLoadPromise=void 0,e.updateMatch(t,e=>({...e,isFetching:!1}))};if(!r.options.beforeLoad){e.router.batch(()=>{u(),d()});return}i._nonReactive.beforeLoadPromise=Fx();let f={...PD(e,n,!1),...i.__routeContext},{search:p,params:m,cause:h}=i,g=ND(e,t),_={search:p,abortController:c,params:m,preload:g,context:f,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),buildLocation:e.router.buildLocation,cause:g?`preload`:h,matches:e.matches,routeId:r.id,...e.router.options.additionalContext},v=r=>{if(r===void 0){e.router.batch(()=>{u(),d()});return}(AD(r)||bD(r))&&(u(),zD(e,n,r)),e.router.batch(()=>{u(),e.updateMatch(t,e=>({...e,__beforeLoadContext:r})),d()})},y;try{if(y=r.options.beforeLoad(_),Xx(y))return u(),y.catch(t=>{zD(e,n,t)}).then(v)}catch(t){u(),zD(e,n,t)}v(y)},UD=(e,t)=>{let{id:n,routeId:r}=e.matches[t],i=e.router.looseRoutesById[r],a=()=>s(),o=()=>HD(e,n,t,i),s=()=>{if(LD(e,n))return;let t=VD(e,n,i);return Xx(t)?t.then(o):o()};return a()},WD=(e,t,n)=>{let r=e.router.getMatch(t);if(!r||!n.options.head&&!n.options.scripts&&!n.options.headers)return;let i={ssr:e.router.options.ssr,matches:e.matches,match:r,params:r.params,loaderData:r.loaderData};return Promise.all([n.options.head?.(i),n.options.scripts?.(i),n.options.headers?.(i)]).then(([e,t,n])=>({meta:e?.meta,links:e?.links,headScripts:e?.scripts,headers:n,scripts:t,styles:e?.styles}))},GD=(e,t,n,r,i)=>{let a=t[r-1],{params:o,loaderDeps:s,abortController:c,cause:l}=e.router.getMatch(n),u=PD(e,r),d=ND(e,n);return{params:o,deps:s,preload:!!d,parentMatchPromise:a,abortController:c,context:u,location:e.location,navigate:t=>e.router.navigate({...t,_fromLocation:e.location}),cause:d?`preload`:l,route:i,...e.router.options.additionalContext}},KD=async(e,t,n,r,i)=>{try{let a=e.router.getMatch(n);try{XD(i);let o=i.options.loader,s=typeof o==`function`?o:o?.handler,c=s?.(GD(e,t,n,r,i)),l=!!s&&Xx(c);if((l||i._lazyPromise||i._componentsPromise||i.options.head||i.options.scripts||i.options.headers||a._nonReactive.minPendingPromise)&&e.updateMatch(n,e=>({...e,isFetching:`loader`})),s){let t=l?await c:c;ID(e,e.router.getMatch(n),t),t!==void 0&&e.updateMatch(n,e=>({...e,loaderData:t}))}i._lazyPromise&&await i._lazyPromise;let u=a._nonReactive.minPendingPromise;u&&await u,i._componentsPromise&&await i._componentsPromise,e.updateMatch(n,t=>({...t,error:void 0,context:PD(e,r),status:`success`,isFetching:!1,updatedAt:Date.now()}))}catch(t){let o=t;if(o?.name===`AbortError`){if(a.abortController.signal.aborted){a._nonReactive.loaderPromise?.resolve(),a._nonReactive.loaderPromise=void 0;return}e.updateMatch(n,t=>({...t,status:t.status===`pending`?`success`:t.status,isFetching:!1,context:PD(e,r)}));return}let s=a._nonReactive.minPendingPromise;s&&await s,bD(t)&&await i.options.notFoundComponent?.preload?.(),ID(e,e.router.getMatch(n),t);try{i.options.onError?.(t)}catch(t){o=t,ID(e,e.router.getMatch(n),t)}!AD(o)&&!bD(o)&&await XD(i,[`errorComponent`]),e.updateMatch(n,t=>({...t,error:o,context:PD(e,r),status:`error`,isFetching:!1}))}}catch(t){let r=e.router.getMatch(n);r&&(r._nonReactive.loaderPromise=void 0),ID(e,r,t)}},qD=async(e,t,n)=>{async function r(r,a,c,l,d){let f=Date.now()-a.updatedAt,p=r?d.options.preloadStaleTime??e.router.options.defaultPreloadStaleTime??3e4:d.options.staleTime??e.router.options.defaultStaleTime??0,m=d.options.shouldReload,h=typeof m==`function`?m(GD(e,t,i,n,d)):m,{status:g,invalid:_}=l,v=f>=p&&(!!e.forceStaleReload||l.cause===`enter`||c!==void 0&&c!==l.id);o=g===`success`&&(_||(h??v)),r&&d.options.preload===!1||(o&&!e.sync&&u?(s=!0,(async()=>{try{await KD(e,t,i,n,d);let r=e.router.getMatch(i);r._nonReactive.loaderPromise?.resolve(),r._nonReactive.loadPromise?.resolve(),r._nonReactive.loaderPromise=void 0,r._nonReactive.loadPromise=void 0}catch(t){AD(t)&&await e.router.navigate(t.options)}})()):g!==`success`||o?await KD(e,t,i,n,d):RD(e,i,n))}let{id:i,routeId:a}=e.matches[n],o=!1,s=!1,c=e.router.looseRoutesById[a],l=c.options.loader,u=((typeof l==`function`?void 0:l?.staleReloadMode)??e.router.options.defaultStaleReloadMode)!==`blocking`;if(LD(e,i)){if(!e.router.getMatch(i))return e.matches[n];RD(e,i,n)}else{let t=e.router.getMatch(i),o=e.router.stores.matchesId.get()[n],s=(o&&e.router.stores.matchStores.get(o)||null)?.routeId===a?o:e.router.stores.matches.get().find(e=>e.routeId===a)?.id,l=ND(e,i);if(t._nonReactive.loaderPromise){if(t.status===`success`&&!e.sync&&!t.preload&&u)return t;await t._nonReactive.loaderPromise;let n=e.router.getMatch(i),a=n._nonReactive.error||n.error;a&&ID(e,n,a),n.status===`pending`&&await r(l,t,s,n,c)}else{let n=l&&!e.router.stores.matchStores.has(i),a=e.router.getMatch(i);a._nonReactive.loaderPromise=Fx(),n!==a.preload&&e.updateMatch(i,e=>({...e,preload:n})),await r(l,t,s,a,c)}}let d=e.router.getMatch(i);s||(d._nonReactive.loaderPromise?.resolve(),d._nonReactive.loadPromise?.resolve(),d._nonReactive.loadPromise=void 0),clearTimeout(d._nonReactive.pendingTimeout),d._nonReactive.pendingTimeout=void 0,s||(d._nonReactive.loaderPromise=void 0),d._nonReactive.dehydrated=void 0;let f=s?d.isFetching:!1;return f!==d.isFetching||d.invalid!==!1?(e.updateMatch(i,e=>({...e,isFetching:f,invalid:!1})),e.router.getMatch(i)):d};async function JD(e){let t=e,n=[];MD(t.router)&&jD(t);let r;for(let e=0;e<t.matches.length;e++){try{let n=UD(t,e);Xx(n)&&await n}catch(e){if(AD(e))throw e;if(bD(e))r=e;else if(!t.preload)throw e;break}if(t.serialError||t.firstBadMatchIndex!=null)break}let i=t.firstBadMatchIndex??t.matches.length,a=r&&!t.preload?FD(t,r):void 0,o=r&&t.preload?0:a===void 0?i:Math.min(a+1,i),s,c;for(let e=0;e<o;e++)n.push(qD(t,n,e));try{await Promise.all(n)}catch{let e=await Promise.allSettled(n);for(let t of e){if(t.status!==`rejected`)continue;let e=t.reason;if(AD(e))throw e;bD(e)?s??=e:c??=e}if(c!==void 0)throw c}let l=s??(r&&!t.preload?r:void 0),u=t.firstBadMatchIndex===void 0?t.matches.length-1:t.firstBadMatchIndex;if(!l&&r&&t.preload)return t.matches;if(l){let e=FD(t,l);e===void 0&&Px();let n=t.matches[e],r=t.router.looseRoutesById[n.routeId],i=t.router.options?.defaultNotFoundComponent;!r.options.notFoundComponent&&i&&(r.options.notFoundComponent=i),l.routeId=n.routeId;let a=n.routeId===t.router.routeTree.id;t.updateMatch(n.id,e=>({...e,...a?{status:`success`,globalNotFound:!0,error:void 0}:{status:`notFound`,error:l},isFetching:!1})),u=e,await XD(r,[`notFoundComponent`])}else if(!t.preload){let e=t.matches[0];e.globalNotFound||t.router.getMatch(e.id)?.globalNotFound&&t.updateMatch(e.id,e=>({...e,globalNotFound:!1,error:void 0}))}if(t.serialError&&t.firstBadMatchIndex!==void 0){let e=t.router.looseRoutesById[t.matches[t.firstBadMatchIndex].routeId];await XD(e,[`errorComponent`])}for(let e=0;e<=u;e++){let{id:n,routeId:r}=t.matches[e],i=t.router.looseRoutesById[r];try{let e=WD(t,n,i);if(e){let r=await e;t.updateMatch(n,e=>({...e,...r}))}}catch(e){console.error(`Error executing head for route ${r}:`,e)}}let d=jD(t);if(Xx(d)&&await d,l)throw l;if(t.serialError&&!t.preload&&!t.onReady)throw t.serialError;return t.matches}function YD(e,t){let n=t.map(t=>e.options[t]?.preload?.()).filter(Boolean);if(n.length!==0)return Promise.all(n)}function XD(e,t=QD){!e._lazyLoaded&&e._lazyPromise===void 0&&(e.lazyFn?e._lazyPromise=e.lazyFn().then(t=>{let{id:n,...r}=t.options;Object.assign(e.options,r),e._lazyLoaded=!0,e._lazyPromise=void 0}):e._lazyLoaded=!0);let n=()=>e._componentsLoaded?void 0:t===QD?(()=>{if(e._componentsPromise===void 0){let t=YD(e,QD);t?e._componentsPromise=t.then(()=>{e._componentsLoaded=!0,e._componentsPromise=void 0}):e._componentsLoaded=!0}return e._componentsPromise})():YD(e,t);return e._lazyPromise?e._lazyPromise.then(n):n()}function ZD(e){for(let t of QD)if(e.options[t]?.preload)return!0;return!1}var QD=[`component`,`errorComponent`,`pendingComponent`,`notFoundComponent`];function $D(e){return{input:({url:t})=>{for(let n of e)t=tO(n,t);return t},output:({url:t})=>{for(let n=e.length-1;n>=0;n--)t=nO(e[n],t);return t}}}function eO(e){let t=fD(e.basepath),n=`/${t}`,r=e.caseSensitive?n:n.toLowerCase(),i=`${r}/`;return{input:({url:t})=>{let a=e.caseSensitive?t.pathname:t.pathname.toLowerCase();return a===r?t.pathname=`/`:a.startsWith(i)&&(t.pathname=t.pathname.slice(n.length)),t},output:({url:e})=>(e.pathname=cD([`/`,t,e.pathname]),e)}}function tO(e,t){let n=e?.input?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function nO(e,t){let n=e?.output?.({url:t});if(n){if(typeof n==`string`)return new URL(n);if(n instanceof URL)return n}return t}function rO(e,t){let{createMutableStore:n,createReadonlyStore:r,batch:i,init:a}=t,o=new Map,s=new Map,c=new Map,l=n(e.status),u=n(e.loadedAt),d=n(e.isLoading),f=n(e.isTransitioning),p=n(e.location),m=n(e.resolvedLocation),h=n(e.statusCode),g=n(e.redirect),_=n([]),v=n([]),y=n([]),b=r(()=>iO(o,_.get())),x=r(()=>iO(s,v.get())),S=r(()=>iO(c,y.get())),C=r(()=>_.get()[0]),w=r(()=>_.get().some(e=>o.get(e)?.get().status===`pending`)),T=r(()=>({locationHref:p.get().href,resolvedLocationHref:m.get()?.href,status:l.get()})),E=r(()=>({status:l.get(),loadedAt:u.get(),isLoading:d.get(),isTransitioning:f.get(),matches:b.get(),location:p.get(),resolvedLocation:m.get(),statusCode:h.get(),redirect:g.get()})),D=LE(64);function O(e){let t=D.get(e);return t||(t=r(()=>{let t=_.get();for(let n of t){let t=o.get(n);if(t&&t.routeId===e)return t.get()}}),D.set(e,t)),t}let k={status:l,loadedAt:u,isLoading:d,isTransitioning:f,location:p,resolvedLocation:m,statusCode:h,redirect:g,matchesId:_,pendingIds:v,cachedIds:y,matches:b,pendingMatches:x,cachedMatches:S,firstId:C,hasPending:w,matchRouteDeps:T,matchStores:o,pendingMatchStores:s,cachedMatchStores:c,__store:E,getRouteMatchStore:O,setMatches:A,setPending:j,setCached:M};A(e.matches),a?.(k);function A(e){aO(e,o,_,n,i)}function j(e){aO(e,s,v,n,i)}function M(e){aO(e,c,y,n,i)}return k}function iO(e,t){let n=[];for(let r of t){let t=e.get(r);t&&n.push(t.get())}return n}function aO(e,t,n,r,i){let a=e.map(e=>e.id),o=new Set(a);i(()=>{for(let e of t.keys())o.has(e)||t.delete(e);for(let n of e){let e=t.get(n.id);if(!e){let e=r(n);e.routeId=n.routeId,t.set(n.id,e);continue}e.routeId=n.routeId,e.get()!==n&&e.set(n)}qx(n.get(),a)||n.set(a)})}var oO=`__TSR_index`,sO=`popstate`,cO=`beforeunload`;function lO(e){let t=e.getLocation(),n=new Set,r=r=>{t=e.getLocation(),n.forEach(e=>e({location:t,action:r}))},i=n=>{e.notifyOnIndexChange??!0?r(n):t=e.getLocation()},a=async({task:n,navigateOpts:r,...i})=>{if(r?.ignoreBlocker??!1){n();return}let a=e.getBlockers?.()??[],o=i.type===`PUSH`||i.type===`REPLACE`;if(typeof document<`u`&&a.length&&o)for(let n of a){let r=pO(i.path,i.state);if(await n.blockerFn({currentLocation:t,nextLocation:r,action:i.type})){e.onBlocked?.();return}}n()};return{get location(){return t},get length(){return e.getLength()},subscribers:n,subscribe:e=>(n.add(e),()=>{n.delete(e)}),push:(n,i,o)=>{let s=t.state[oO];i=uO(s+1,i),a({task:()=>{e.pushState(n,i),r({type:`PUSH`})},navigateOpts:o,type:`PUSH`,path:n,state:i})},replace:(n,i,o)=>{let s=t.state[oO];i=uO(s,i),a({task:()=>{e.replaceState(n,i),r({type:`REPLACE`})},navigateOpts:o,type:`REPLACE`,path:n,state:i})},go:(t,n)=>{a({task:()=>{e.go(t),i({type:`GO`,index:t})},navigateOpts:n,type:`GO`})},back:t=>{a({task:()=>{e.back(t?.ignoreBlocker??!1),i({type:`BACK`})},navigateOpts:t,type:`BACK`})},forward:t=>{a({task:()=>{e.forward(t?.ignoreBlocker??!1),i({type:`FORWARD`})},navigateOpts:t,type:`FORWARD`})},canGoBack:()=>t.state[oO]!==0,createHref:t=>e.createHref(t),block:t=>{if(!e.setBlockers)return()=>{};let n=e.getBlockers?.()??[];return e.setBlockers([...n,t]),()=>{let n=e.getBlockers?.()??[];e.setBlockers?.(n.filter(e=>e!==t))}},flush:()=>e.flush?.(),destroy:()=>e.destroy?.(),notify:r}}function uO(e,t){t||={};let n=mO();return{...t,key:n,__TSR_key:n,[oO]:e}}function dO(e){let t=e?.window??(typeof document<`u`?window:void 0),n=t.history.pushState,r=t.history.replaceState,i=[],a=()=>i,o=e=>i=e,s=e?.createHref??(e=>e),c=e?.parseLocation??(()=>pO(`${t.location.pathname}${t.location.search}${t.location.hash}`,t.history.state));if(!t.history.state?.__TSR_key&&!t.history.state?.key){let e=mO();t.history.replaceState({[oO]:0,key:e,__TSR_key:e},``)}let l=c(),u,d=!1,f=!1,p=!1,m=!1,h=()=>l,g,_,v=()=>{g&&(C._ignoreSubscribers=!0,(g.isPush?t.history.pushState:t.history.replaceState)(g.state,``,g.href),C._ignoreSubscribers=!1,g=void 0,_=void 0,u=void 0)},y=(e,t,n)=>{let r=s(t);_||(u=l),l=pO(t,n),g={href:r,state:n,isPush:g?.isPush||e===`push`},_||=Promise.resolve().then(()=>v())},b=e=>{l=c(),C.notify({type:e})},x=async()=>{if(f){f=!1;return}let e=c(),n=e.state[oO]-l.state[oO],r=n===1,i=n===-1,o=!r&&!i||d;d=!1;let s=o?`GO`:i?`BACK`:`FORWARD`,u=o?{type:`GO`,index:n}:{type:i?`BACK`:`FORWARD`};if(p)p=!1;else{let n=a();if(typeof document<`u`&&n.length){for(let r of n)if(await r.blockerFn({currentLocation:l,nextLocation:e,action:s})){f=!0,t.history.go(1),C.notify(u);return}}}l=c(),C.notify(u)},S=e=>{if(m){m=!1;return}let t=!1,n=a();if(typeof document<`u`&&n.length)for(let e of n){let n=e.enableBeforeUnload??!0;if(n===!0){t=!0;break}if(typeof n==`function`&&n()===!0){t=!0;break}}if(t)return e.preventDefault(),e.returnValue=``},C=lO({getLocation:h,getLength:()=>t.history.length,pushState:(e,t)=>y(`push`,e,t),replaceState:(e,t)=>y(`replace`,e,t),back:e=>(e&&(p=!0),m=!0,t.history.back()),forward:e=>{e&&(p=!0),m=!0,t.history.forward()},go:e=>{d=!0,t.history.go(e)},createHref:e=>s(e),flush:v,destroy:()=>{t.history.pushState=n,t.history.replaceState=r,t.removeEventListener(cO,S,{capture:!0}),t.removeEventListener(sO,x)},onBlocked:()=>{u&&l!==u&&(l=u)},getBlockers:a,setBlockers:o,notifyOnIndexChange:!1});return t.addEventListener(cO,S,{capture:!0}),t.addEventListener(sO,x),t.history.pushState=function(...e){let r=n.apply(t.history,e);return C._ignoreSubscribers||b(`PUSH`),r},t.history.replaceState=function(...e){let n=r.apply(t.history,e);return C._ignoreSubscribers||b(`REPLACE`),n},C}function fO(e){let t=e.replace(/[\x00-\x1f\x7f]/g,``);return t.startsWith(`//`)&&(t=`/`+t.replace(/^\/+/,``)),t}function pO(e,t){let n=fO(e),r=n.indexOf(`#`),i=n.indexOf(`?`),a=mO();return{href:n,pathname:n.substring(0,r>0?i>0?Math.min(r,i):r:i>0?i:n.length),hash:r>-1?n.substring(r):``,search:i>-1?n.slice(i,r===-1?void 0:r):``,state:t||{[oO]:0,key:a,__TSR_key:a}}}function mO(){return(Math.random()+1).toString(36).substring(7)}function hO(e,t){let n=t,r=e;return{fromLocation:n,toLocation:r,pathChanged:n?.pathname!==r.pathname,hrefChanged:n?.href!==r.href,hashChanged:n?.hash!==r.hash}}var gO=new WeakMap,_O=class{constructor(e,t){this.tempLocationKey=`${Math.round(Math.random()*1e7)}`,this._scroll={next:!0},this.shouldViewTransition=void 0,this.isViewTransitionTypesSupported=void 0,this.subscribers=new Set,this.routeBranchCache=new WeakMap,this.startTransition=e=>e(),this.update=e=>{let t=this.options,n=this.basepath??t?.basepath??`/`,r=this.basepath===void 0,i=t?.rewrite;if(this.options={...t,...e},this.isServer=this.options.isServer??typeof document>`u`,this.protocolAllowlist=new Set(this.options.protocolAllowlist),this.options.pathParamsAllowedCharacters&&(this.pathParamsDecoder=gD(this.options.pathParamsAllowedCharacters)),(!this.history||this.options.history&&this.options.history!==this.history)&&(this.options.history?this.history=this.options.history:this.history=dO()),this.origin=this.options.origin,this.origin||(window?.origin&&window.origin!==`null`?this.origin=window.origin:this.origin=`http://localhost`),this.history&&this.updateLatestLocation(),this.options.routeTree!==this.routeTree){this.routeTree=this.options.routeTree;let e;this.resolvePathCache=LE(1e3),e=this.buildRouteTree(),this.setRoutes(e)}if(!this.stores&&this.latestLocation){let e=this.getStoreConfig(this);this.batch=e.batch,this.stores=rO(bO(this.latestLocation),e),BO(this)}let a=!1,o=this.options.basepath??`/`,s=this.options.rewrite;if(r||n!==o||i!==s){this.basepath=o;let e=[],t=fD(o);t&&t!==`/`&&e.push(eO({basepath:o})),s&&e.push(s),this.rewrite=e.length===0?void 0:e.length===1?e[0]:$D(e),this.history&&this.updateLatestLocation(),a=!0}a&&this.stores&&this.stores.location.set(this.latestLocation),typeof window<`u`&&`CSS`in window&&typeof window.CSS?.supports==`function`&&(this.isViewTransitionTypesSupported=window.CSS.supports(`selector(:active-view-transition-type(a))`))},this.updateLatestLocation=()=>{this.latestLocation=this.parseLocation(this.history.location,this.latestLocation)},this.buildRouteTree=()=>{let e=QE(this.routeTree,this.options.caseSensitive,(e,t)=>{e.init({originalIndex:t})});return this.options.routeMasks&&qE(this.options.routeMasks,e.processedTree),e},this.subscribe=(e,t)=>{let n={eventType:e,fn:t};return this.subscribers.add(n),()=>{this.subscribers.delete(n)}},this.emit=e=>{this.subscribers.forEach(t=>{t.eventType===e.type&&t.fn(e)})},this.parseLocation=(e,t)=>{let n=({pathname:e,search:n,hash:r,href:i,state:a})=>{if(!this.rewrite&&!/[ \x00-\x1f\x7f\u0080-\uffff]/.test(e)){let i=this.options.parseSearch(n),o=this.options.stringifySearch(i);return{href:e+o+r,publicHref:e+o+r,pathname:Ix(e).path,external:!1,searchStr:o,search:Yx(t?.search,i),hash:Ix(r.slice(1)).path,state:Ax(t?.state,a)}}let o=new URL(i,this.origin),s=tO(this.rewrite,o),c=this.options.parseSearch(s.search),l=this.options.stringifySearch(c);return s.search=l,{href:s.href.replace(s.origin,``),publicHref:i,pathname:Ix(s.pathname).path,external:!!this.rewrite&&s.origin!==this.origin,searchStr:l,search:Yx(t?.search,c),hash:Ix(s.hash.slice(1)).path,state:Ax(t?.state,a)}},r=n(e),{__tempLocation:i,__tempKey:a}=r.state;if(i&&(!a||a===this.tempLocationKey)){let e=n(i);return e.state.key=r.state.key,e.state.__TSR_key=r.state.__TSR_key,delete e.state.__tempLocation,{...e,maskedLocation:r}}return r},this.resolvePathWithBase=(e,t)=>hD({base:e,to:t.includes(`//`)?lD(t):t,trailingSlash:this.options.trailingSlash,cache:this.resolvePathCache}),this.matchRoutes=(e,t,n)=>typeof e==`string`?this.matchRoutesInternal({pathname:e,search:t},n):this.matchRoutesInternal(e,t),this.getMatchedRoutes=e=>SO({pathname:e,routesById:this.routesById,processedTree:this.processedTree}),this.cancelMatch=e=>{let t=this.getMatch(e);t&&(t.abortController.abort(),clearTimeout(t._nonReactive.pendingTimeout),t._nonReactive.pendingTimeout=void 0)},this.cancelMatches=()=>{this.stores.pendingIds.get().forEach(e=>{this.cancelMatch(e)}),this.stores.matchesId.get().forEach(e=>{if(this.stores.pendingMatchStores.has(e))return;let t=this.stores.matchStores.get(e)?.get();t&&(t.status===`pending`||t.isFetching===`loader`)&&this.cancelMatch(e)})},this.buildLocation=e=>{let t=(t={})=>{let n=t._fromLocation||this.pendingBuiltLocation||this.latestLocation,r=this.matchRoutesLightweight(n);t.from;let i=t.unsafeRelative===`path`?n.pathname:t.from??r.fullPath,a=t.to?`${t.to}`:void 0,o=r.search,s=Object.assign(Object.create(null),r.params),c=a?.charCodeAt(0)===47?`/`:this.resolvePathWithBase(i,`.`),l=a?this.resolvePathWithBase(c,a):c,u=t.params===!1||t.params===null?Object.create(null):(t.params??!0)===!0?s:Object.assign(s,Rx(t.params,s)),d=this.routesByPath[dD(l)],f;if(d)f=this.getRouteBranch(d);else if(l.includes(`$`))f=[];else{let e=this.getMatchedRoutes(l);f=e.matchedRoutes,this.options.notFoundRoute&&(!e.foundRoute||e.foundRoute.path!==`/`&&e.routeParams[`**`])&&(f=[...f,this.options.notFoundRoute])}if(f.length&&Lx(u))for(let e of f){let t=e.options.params?.stringify??e.options.stringifyParams;if(t)try{Object.assign(u,t(u))}catch{}}let p=e.leaveParams?l:Ix(vD({path:l,params:u,decoder:this.pathParamsDecoder,server:this.isServer}).interpolatedPath).path,m=o;if(e._includeValidateSearch&&this.options.search?.strict){let e={};f.forEach(t=>{if(t.options.validateSearch)try{Object.assign(e,xO(t.options.validateSearch,{...e,...m}))}catch{}}),m=e}m=CO({search:m,dest:t,destRoutes:f,_includeValidateSearch:e._includeValidateSearch}),m=Yx(o,m);let h=this.options.stringifySearch(m),g=t.hash===!0?n.hash:t.hash?Rx(t.hash,n.hash):void 0,_=g?`#${g}`:``,v=t.state===!0?n.state:t.state?Rx(t.state,n.state):{};v=Ax(n.state,v);let y=`${p}${h}${_}`,b,x,S=!1;if(this.rewrite){let e=new URL(y,this.origin),t=nO(this.rewrite,e);b=e.href.replace(e.origin,``),t.origin===this.origin?x=t.pathname+t.search+t.hash:(x=t.href,S=!0)}else b=Bx(y),x=b;return{publicHref:x,href:b,pathname:p,search:m,searchStr:h,state:v,hash:g??``,external:S,unmaskOnReload:t.unmaskOnReload}},n=(n={},r)=>{let i=t(n),a=r?t(r):void 0;if(!a){let n=Object.create(null);if(this.options.routeMasks){let o=JE(i.pathname,this.processedTree);if(o){Object.assign(n,o.rawParams);let{from:i,params:s,...c}=o.route,l=s===!1||s===null?Object.create(null):(s??!0)===!0?n:Object.assign(n,Rx(s,n));r={from:e.from,...c,params:l},a=t(r)}}}return a&&(i.maskedLocation=a),i};return e.mask?n(e,{from:e.from,...e.mask}):n(e)},this.commitLocation=async({viewTransition:e,ignoreBlocker:t,...n})=>{let r,i=()=>{let e=[`key`,`__TSR_key`,`__TSR_index`,`__hashScrollIntoViewOptions`];e.forEach(e=>{n.state[e]=this.latestLocation.state[e]});let t=Ux(n.state,this.latestLocation.state);return e.forEach(e=>{delete n.state[e]}),t},a=dD(this.latestLocation.href)===dD(n.href),o=this.commitLocationPromise;if(this.commitLocationPromise=Fx(()=>{o?.resolve(),o=void 0}),a&&i())this.load();else{let{maskedLocation:i,hashScrollIntoView:a,...o}=n;i&&(o={...i,state:{...i.state,__tempKey:void 0,__tempLocation:{...o,search:o.searchStr,state:{...o.state,__tempKey:void 0,__tempLocation:void 0,__TSR_key:void 0,key:void 0}}}},(o.unmaskOnReload??this.options.unmaskOnReload??!1)&&(o.state.__tempKey=this.tempLocationKey)),o.state.__hashScrollIntoViewOptions=a??this.options.defaultHashScrollIntoView??!0,this.shouldViewTransition=e,r=n.replace?`REPLACE`:`PUSH`,this.history[r===`REPLACE`?`replace`:`push`](o.publicHref,o.state,{ignoreBlocker:t})}return this._scroll.next=n.resetScroll??!0,this.history.subscribers.size||this.load(r?{action:{type:r}}:void 0),this.commitLocationPromise},this.buildAndCommitLocation=({replace:e,resetScroll:t,hashScrollIntoView:n,viewTransition:r,ignoreBlocker:i,href:a,...o}={})=>{if(a){let t=this.history.location.state.__TSR_index,n=pO(a,{__TSR_index:e?t:t+1}),r=new URL(n.pathname,this.origin);o.to=tO(this.rewrite,r).pathname,o.search=this.options.parseSearch(n.search),o.hash=n.hash.slice(1)}let s=this.buildLocation({...o,_includeValidateSearch:!0});this.pendingBuiltLocation=s;let c=this.commitLocation({...s,viewTransition:r,replace:e,resetScroll:t,hashScrollIntoView:n,ignoreBlocker:i});return Promise.resolve().then(()=>{this.pendingBuiltLocation===s&&(this.pendingBuiltLocation=void 0)}),c},this.navigate=async({to:e,reloadDocument:t,href:n,publicHref:r,...i})=>{let a=!1;if(n)try{new URL(`${n}`),a=!0}catch{}if(a&&!t&&(t=!0),t){if(e!==void 0||!n){let t=this.buildLocation({to:e,...i});n??=t.publicHref,r??=t.publicHref}let t=!a&&r?r:n;if(jx(t,this.protocolAllowlist))return Promise.resolve();if(!i.ignoreBlocker){let e=this.history.getBlockers?.()??[];for(let t of e)if(t?.blockerFn&&await t.blockerFn({currentLocation:this.latestLocation,nextLocation:this.latestLocation,action:`PUSH`}))return Promise.resolve()}return i.replace?window.location.replace(t):window.location.href=t,Promise.resolve()}return this.buildAndCommitLocation({...i,href:n,to:e,_isNavigate:!0})},this.beforeLoad=()=>{this.cancelMatches(),this.updateLatestLocation();let e=this.matchRoutes(this.latestLocation),t=this.stores.cachedMatches.get().filter(t=>!e.some(e=>e.id===t.id));this.batch(()=>{this.stores.status.set(`pending`),this.stores.statusCode.set(200),this.stores.isLoading.set(!0),this.stores.location.set(this.latestLocation),this.stores.setPending(e),this.stores.setCached(t)})},this.load=async e=>{let t=e?.action?.type,n,r,i,a=this.stores.resolvedLocation.get()??this.stores.location.get();for(i=new Promise(o=>{this.startTransition(async()=>{try{this.beforeLoad(),t?gO.set(this.latestLocation,t):gO.delete(this.latestLocation);let n=this.latestLocation,r=hO(n,this.stores.resolvedLocation.get());this.stores.redirect.get()||this.emit({type:`onBeforeNavigate`,...r}),this.emit({type:`onBeforeLoad`,...r}),await JD({router:this,sync:e?.sync,forceStaleReload:a.href===n.href,matches:this.stores.pendingMatches.get(),location:n,updateMatch:this.updateMatch,onReady:async()=>{this.startTransition(()=>{this.startViewTransition(async()=>{let e=null,t=null,n=null,r=null;this.batch(()=>{let i=this.stores.pendingMatches.get(),a=i.length,o=this.stores.matches.get();e=a?o.filter(e=>!this.stores.pendingMatchStores.has(e.id)):null;let s=new Set;for(let e of this.stores.pendingMatchStores.values())e.routeId&&s.add(e.routeId);let c=new Set;for(let e of this.stores.matchStores.values())e.routeId&&c.add(e.routeId);t=a?o.filter(e=>!s.has(e.routeId)):null,n=a?i.filter(e=>!c.has(e.routeId)):null,r=a?i.filter(e=>c.has(e.routeId)):o,this.stores.isLoading.set(!1),this.stores.loadedAt.set(Date.now()),a&&(this.stores.setMatches(i),this.stores.setPending([]),this.stores.setCached([...this.stores.cachedMatches.get(),...e.filter(e=>e.status!==`error`&&e.status!==`notFound`&&e.status!==`redirected`)]),this.clearExpiredCache())});for(let[e,i]of[[t,`onLeave`],[n,`onEnter`],[r,`onStay`]])if(e)for(let t of e)this.looseRoutesById[t.routeId].options[i]?.(t)})})}})}catch(e){AD(e)?(n=e,this.navigate({...n.options,replace:!0,ignoreBlocker:!0})):bD(e)&&(r=e);let t=n?n.status:r?404:this.stores.matches.get().some(e=>e.status===`error`)?500:200;this.batch(()=>{this.stores.statusCode.set(t),this.stores.redirect.set(n)})}this.latestLoadPromise===i&&(this.commitLocationPromise?.resolve(),this.latestLoadPromise=void 0,this.commitLocationPromise=void 0),o()})}),this.latestLoadPromise=i,await i;this.latestLoadPromise&&i!==this.latestLoadPromise;)await this.latestLoadPromise;let o;this.hasNotFoundMatch()?o=404:this.stores.matches.get().some(e=>e.status===`error`)&&(o=500),o!==void 0&&this.stores.statusCode.set(o)},this.startViewTransition=e=>{let t=this.shouldViewTransition??this.options.defaultViewTransition;if(this.shouldViewTransition=void 0,t&&typeof document<`u`&&`startViewTransition`in document&&typeof document.startViewTransition==`function`){let n;if(typeof t==`object`&&this.isViewTransitionTypesSupported){let r=this.latestLocation,i=this.stores.resolvedLocation.get(),a=typeof t.types==`function`?t.types(hO(r,i)):t.types;if(a===!1){e();return}n={update:e,types:a}}else n=e;document.startViewTransition(n)}else e()},this.updateMatch=(e,t)=>{this.startTransition(()=>{let n=this.stores.pendingMatchStores.get(e);if(n){n.set(t);return}let r=this.stores.matchStores.get(e);if(r){r.set(t);return}let i=this.stores.cachedMatchStores.get(e);if(i){let n=t(i.get());n.status===`redirected`?this.stores.cachedMatchStores.delete(e)&&this.stores.cachedIds.set(t=>t.filter(t=>t!==e)):i.set(n)}})},this.getMatch=e=>this.stores.cachedMatchStores.get(e)?.get()??this.stores.pendingMatchStores.get(e)?.get()??this.stores.matchStores.get(e)?.get(),this.invalidate=e=>{let t=t=>e?.filter?.(t)??!0?{...t,invalid:!0,...e?.forcePending||t.status===`error`||t.status===`notFound`?{status:`pending`,error:void 0}:void 0}:t;return this.batch(()=>{this.stores.setMatches(this.stores.matches.get().map(t)),this.stores.setCached(this.stores.cachedMatches.get().map(t)),this.stores.setPending(this.stores.pendingMatches.get().map(t))}),this.shouldViewTransition=!1,this.load({sync:e?.sync})},this.getParsedLocationHref=e=>e.publicHref||`/`,this.resolveRedirect=e=>{let t=e.headers.get(`Location`);if(!e.options.href||e.options._builtLocation){let t=e.options._builtLocation??this.buildLocation(e.options),n=this.getParsedLocationHref(t);e.options.href=n,e.headers.set(`Location`,n)}else if(t)try{let n=new URL(t);if(this.origin&&n.origin===this.origin){let t=n.pathname+n.search+n.hash;e.options.href=t,e.headers.set(`Location`,t)}}catch{}if(e.options.href&&!e.options._builtLocation&&jx(e.options.href,this.protocolAllowlist))throw Error(`Redirect blocked: unsafe protocol`);return e.headers.get(`Location`)||e.headers.set(`Location`,e.options.href),e},this.clearCache=e=>{let t=e?.filter;t===void 0?this.stores.setCached([]):this.stores.setCached(this.stores.cachedMatches.get().filter(e=>!t(e)))},this.clearExpiredCache=()=>{let e=Date.now();this.clearCache({filter:t=>{let n=this.looseRoutesById[t.routeId];if(!n.options.loader)return!0;let r=(t.preload?n.options.preloadGcTime??this.options.defaultPreloadGcTime:n.options.gcTime??this.options.defaultGcTime)??300*1e3;return t.status===`error`||e-t.updatedAt>=r}})},this.loadRouteChunk=XD,this.preloadRoute=async e=>{let t=e._builtLocation??this.buildLocation(e),n=this.matchRoutes(t,{throwOnError:!0,preload:!0,dest:e}),r=new Set([...this.stores.matchesId.get(),...this.stores.pendingIds.get()]),i=new Set([...r,...this.stores.cachedIds.get()]),a=n.filter(e=>!i.has(e.id));if(a.length){let e=this.stores.cachedMatches.get();this.stores.setCached([...e,...a])}try{return n=await JD({router:this,matches:n,location:t,preload:!0,updateMatch:(e,t)=>{r.has(e)?n=n.map(n=>n.id===e?t(n):n):this.updateMatch(e,t)}}),n}catch(e){if(AD(e))return e.options.reloadDocument?void 0:await this.preloadRoute({...e.options,_fromLocation:t});bD(e)||console.error(e);return}},this.matchRoute=(e,t)=>{let n={...e,to:e.to?this.resolvePathWithBase(e.from||``,e.to):void 0,params:e.params||{},leaveParams:!0},r=this.buildLocation(n);if(t?.pending&&this.stores.status.get()!==`pending`)return!1;let i=(t?.pending===void 0?!this.stores.isLoading.get():t.pending)?this.latestLocation:this.stores.resolvedLocation.get()||this.stores.location.get(),a=YE(r.pathname,t?.caseSensitive??!1,t?.fuzzy??!1,i.pathname,this.processedTree);return!a||e.params&&!Ux(a.rawParams,e.params,{partial:!0})?!1:t?.includeSearch??!0?Ux(i.search,r.search,{partial:!0})?a.rawParams:!1:a.rawParams},this.hasNotFoundMatch=()=>this.stores.matches.get().some(e=>e.status===`notFound`||e.globalNotFound),this.getStoreConfig=t,this.update({defaultPreloadDelay:50,defaultPendingMs:1e3,defaultPendingMinMs:500,context:void 0,...e,caseSensitive:e.caseSensitive??!1,notFoundMode:e.notFoundMode??`fuzzy`,stringifySearch:e.stringifySearch??TD,parseSearch:e.parseSearch??wD,protocolAllowlist:e.protocolAllowlist??ote}),typeof document<`u`&&(self.__TSR_ROUTER__=this)}isShell(){return!!this.options.isShell}isPrerendering(){return!!this.options.isPrerendering}get state(){return this.stores.__store.get()}setRoutes({routesById:e,routesByPath:t,processedTree:n}){this.routesById=e,this.routesByPath=t,this.processedTree=n;let r=this.options.notFoundRoute;r&&(r.init({originalIndex:99999999999}),this.routesById[r.id]=r)}getRouteBranch(e){let t=this.routeBranchCache.get(e);return t||(t=tD(e),this.routeBranchCache.set(e,t)),t}get looseRoutesById(){return this.routesById}getParentContext(e){return e?.id?e.context??this.options.context??void 0:this.options.context??void 0}matchRoutesInternal(e,t){let n=this.getMatchedRoutes(e.pathname),{foundRoute:r,routeParams:i}=n,{matchedRoutes:a}=n,o=!1;(r?r.path!==`/`&&i[`**`]:dD(e.pathname))&&(this.options.notFoundRoute?a=[...a,this.options.notFoundRoute]:o=!0);let s=o?TO(this.options.notFoundMode,a):void 0,c=Array(a.length),l=new Map;for(let e of this.stores.matchStores.values())e.routeId&&l.set(e.routeId,e.get());for(let n=0;n<a.length;n++){let r=a[n],o=c[n-1],u,d,f;{let n=o?.search??e.search,i=o?._strictSearch??void 0;try{let e=xO(r.options.validateSearch,{...n})??void 0;u={...n,...e},d={...i,...e},f=void 0}catch(e){let r=e;if(e instanceof vO||(r=new vO(e.message,{cause:e})),t?.throwOnError)throw r;u=n,d={},f=r}}let p=r.options.loaderDeps?.({search:u})??``,m=p?JSON.stringify(p):``,{interpolatedPath:h,usedParams:g}=vD({path:r.fullPath,params:i,decoder:this.pathParamsDecoder,server:this.isServer}),_=r.id+h+m,v=this.getMatch(_),y=l.get(r.id),b=v?._strictParams??g,x;if(!v)try{EO(r,b)}catch(e){if(x=bD(e)||AD(e)?e:new yO(e.message,{cause:e}),t?.throwOnError)throw x}Object.assign(i,b);let S=y?`stay`:`enter`,C;if(v)C={...v,cause:S,params:y?.params??i,_strictParams:b,search:Yx(y?y.search:v.search,u),_strictSearch:d};else{let e=r.options.loader||r.options.beforeLoad||r.lazyFn||ZD(r)?`pending`:`success`;C={id:_,ssr:r.options.ssr,index:n,routeId:r.id,params:y?.params??i,_strictParams:b,pathname:h,updatedAt:Date.now(),search:y?Yx(y.search,u):u,_strictSearch:d,searchError:void 0,status:e,isFetching:!1,error:void 0,paramsError:x,__routeContext:void 0,_nonReactive:{loadPromise:Fx()},__beforeLoadContext:void 0,context:{},abortController:new AbortController,fetchCount:0,cause:S,loaderDeps:y?Ax(y.loaderDeps,p):p,invalid:!1,preload:!1,links:void 0,scripts:void 0,headScripts:void 0,meta:void 0,staticData:r.options.staticData||{},fullPath:r.fullPath}}t?.preload||(C.globalNotFound=s===r.id),C.searchError=f;let w=this.getParentContext(o);C.context={...w,...C.__routeContext,...C.__beforeLoadContext},c[n]=C}for(let t=0;t<c.length;t++){let n=c[t],r=this.looseRoutesById[n.routeId],a=this.getMatch(n.id),o=l.get(n.routeId);if(n.params=o?Yx(o.params,i):i,!a){let i=c[t-1],a=this.getParentContext(i);if(r.options.context){let t={deps:n.loaderDeps,params:n.params,context:a??{},location:e,navigate:t=>this.navigate({...t,_fromLocation:e}),buildLocation:this.buildLocation,cause:n.cause,abortController:n.abortController,preload:!!n.preload,matches:c,routeId:r.id};n.__routeContext=r.options.context(t)??void 0}n.context={...a,...n.__routeContext,...n.__beforeLoadContext}}}return c}matchRoutesLightweight(e){let{matchedRoutes:t,routeParams:n}=this.getMatchedRoutes(e.pathname),r=Nx(t),i={...e.search};for(let e of t)try{Object.assign(i,xO(e.options.validateSearch,i))}catch{}let a=Nx(this.stores.matchesId.get()),o=a&&this.stores.matchStores.get(a)?.get(),s=o&&o.routeId===r.id&&o.pathname===e.pathname,c;if(s)c=o.params;else{let e=Object.assign(Object.create(null),n);for(let n of t)try{EO(n,e)}catch{}c=e}return{matchedRoutes:t,fullPath:r.fullPath,search:i,params:c}}},vO=class extends Error{},yO=class extends Error{};function bO(e){return{loadedAt:0,isLoading:!1,isTransitioning:!1,status:`idle`,resolvedLocation:void 0,location:e,matches:[],statusCode:200}}function xO(e,t){if(e==null)return{};if(`~standard`in e){let n=e[`~standard`].validate(t);if(n instanceof Promise)throw new vO(`Async validation not supported`);if(n.issues)throw new vO(JSON.stringify(n.issues,void 0,2),{cause:n});return n.value}return`parse`in e?e.parse(t):typeof e==`function`?e(t):{}}function SO({pathname:e,routesById:t,processedTree:n}){let r=Object.create(null),i=dD(e),a,o=XE(i,n,!0);return o&&(a=o.route,Object.assign(r,o.rawParams)),{matchedRoutes:o?.branch||[t.__root__],routeParams:r,foundRoute:a}}function CO({search:e,dest:t,destRoutes:n,_includeValidateSearch:r}){return wO(n)(e,t,r??!1)}function wO(e){let t,n,r=[];for(let t of e){let e=t.options;`search`in e?e.search?.middlewares&&r.push(...e.search.middlewares):(e.preSearchFilters||e.postSearchFilters)&&r.push(({search:t,next:n})=>{let r=n(e.preSearchFilters?e.preSearchFilters.reduce((e,t)=>t(e),t):t);return e.postSearchFilters?e.postSearchFilters.reduce((e,t)=>t(e),r):r});let i=e.validateSearch;i&&r.push(({search:e,next:t,meta:r})=>{let a=t(e);if(n)try{let e=xO(i,a);if(r&&e)for(let t in e)t in a||(r.defaulted||=new Map).set(t,e[t]);return{...a,...e}}catch{}return a})}let i=(e,n,a)=>{if(e>=r.length){if(!t.search)return{};if(t.search===!0)return n;let e=Rx(t.search,n);return a&&(a.explicit=e),e}return r[e]({search:n,next:(t,n)=>{if(n){let n=a||{};return{search:i(e+1,t,n),meta:n}}return i(e+1,t,a)},meta:a})};return function(e,r,a){return t=r,n=a,i(0,e)}}function TO(e,t){if(e!==`root`)for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.children)return n.id}return OD}function EO(e,t){let n=e.options.params?.parse??e.options.parseParams;if(n){let e=n(t);if(e===!1)throw Error(`Route params.parse returned false for a matched route`);Object.assign(t,e)}}function DO(){try{return sessionStorage}catch{return}}var OO=`tsr-scroll-restoration-v1_3`,kO=DO();function AO(){try{return JSON.parse(kO?.getItem(`tsr-scroll-restoration-v1_3`)||`{}`)}catch{return{}}}function jO(){try{kO?.setItem(OO,JSON.stringify(MO))}catch{}}var MO=AO(),NO=`data-scroll-restoration-id`,PO=e=>e.state.__TSR_key||e.href;function FO(e){let t=e.getAttribute(NO);if(t)return`[${NO}="${t}"]`;let n=``,r=e,i;for(;i=r.parentNode;){let e=1,t=r;for(;t=t.previousElementSibling;)e++;let a=`${r.localName}:nth-child(${e})`;n=n?`${a} > ${n}`:a,r=i}return n}var IO=!1,LO=`window`;function RO(e){try{return typeof e==`function`?e():document.querySelector(e)}catch{}}function zO(e){let t=[];for(let n of e){if(n===LO)continue;let e=RO(n);e&&t.push(e)}return t}function BO(e,t){let n=t??e.options.scrollRestoration,r=e._scroll;n&&(r.restoring=!0);let i=e.options.getScrollRestorationKey||PO,a=new Map,o=(e,t,n)=>{let r=a.get(e)||{};r.scrollX=t,r.scrollY=n,a.set(e,r)},s=e=>{if(!(IO||!r.restoring))if(e.target===document)o(LO,scrollX,scrollY);else{let t=e.target;o(t,t.scrollLeft,t.scrollTop)}},c=e=>{if(!r.restoring)return;let t=MO[e]||={};for(let[e,n]of a)e===LO?t[LO]=n:e.isConnected&&(t[FO(e)]=n)};n&&!r.restoration&&(r.restoration=!0,IO=!1,history.scrollRestoration=`manual`,document.addEventListener(`scroll`,s,!0),e.subscribe(`onBeforeLoad`,e=>{e.fromLocation&&c(i(e.fromLocation)),a.clear()}),addEventListener(`pagehide`,()=>{c(i(e.stores.resolvedLocation.get()??e.stores.location.get())),jO()})),!r.reset&&(r.reset=!0,e.subscribe(`onRendered`,t=>{let n=e.options.scrollRestorationBehavior,o=e.options.scrollToTopSelectors,s=r.next,c;if(a.clear(),s||(r.next=!0),typeof e.options.scrollRestoration==`function`&&!e.options.scrollRestoration({location:e.latestLocation}))return;let l=i(t.toLocation),u=t.fromLocation&&i(t.fromLocation);if(r.restoring&&u&&u!==l){let e=MO[u];if(e){let t=MO[l];for(let n in e){if(n===LO){if(s)continue}else{let e=RO(n);if(!e||s&&o&&(c??=zO(o),c.includes(e)))continue}t||=MO[l]={},t[n]??=e[n]}}}IO=!0;try{let e=t.toLocation.hash,i=t.toLocation.state.__hashScrollIntoViewOptions??!0,a=!1;if(s){let s=gO.get(t.toLocation),u=e&&i&&(s===`PUSH`||s===`REPLACE`),d=r.restoring?MO[l]:void 0;if(d)for(let e in d){let{scrollX:t,scrollY:r}=d[e];if(e===LO){if(u)continue;scrollTo({top:r,left:t,behavior:n}),a=!0}else{let n=RO(e);n&&(n.scrollLeft=t,n.scrollTop=r)}}if(!a&&!e){let e={top:0,left:0,behavior:n};if(scrollTo(e),o){c??=zO(o);for(let t of c)t.scrollTo(e)}}}!a&&e&&i&&document.getElementById(e)?.scrollIntoView(i)}finally{IO=!1}}))}var VO=`Error preloading route! ☝️`,HO=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e.originalIndex;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=OD:this.parentRoute||Px();let r=n?OD:t?.path;r&&r!==`/`&&(r=uD(r));let i=t?.id||r,a=n?OD:cD([this.parentRoute.id===`__root__`?``:this.parentRoute.id,i]);r===`__root__`&&(r=`/`),a!==`__root__`&&(a=cD([`/`,a]));let o=a===`__root__`?`/`:cD([this.parentRoute.fullPath,r]);this._path=r,this._id=a,this._fullPath=o,this._to=dD(o)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>kD({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},UO=class extends HO{constructor(e){super(e)}};function WO(e){let t=e.errorComponent??KO;return(0,J.jsx)(GO,{getResetKey:e.getResetKey,onCatch:e.onCatch,children:({error:n,reset:r})=>n?q.createElement(t,{error:n,reset:r}):e.children})}var GO=class extends q.Component{constructor(...e){super(...e),this.state={error:null}}static getDerivedStateFromProps(e,t){let n=e.getResetKey();return t.error&&t.resetKey!==n?{resetKey:n,error:null}:{resetKey:n}}static getDerivedStateFromError(e){return{error:e}}reset(){this.setState({error:null})}componentDidCatch(e,t){this.props.onCatch&&this.props.onCatch(e,t)}render(){return this.props.children({error:this.state.error,reset:()=>{this.reset()}})}};function KO({error:e}){let[t,n]=q.useState(!1);return(0,J.jsxs)(`div`,{style:{padding:`.5rem`,maxWidth:`100%`},children:[(0,J.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`.5rem`},children:[(0,J.jsx)(`strong`,{style:{fontSize:`1rem`},children:`Something went wrong!`}),(0,J.jsx)(`button`,{style:{appearance:`none`,fontSize:`.6em`,border:`1px solid currentColor`,padding:`.1rem .2rem`,fontWeight:`bold`,borderRadius:`.25rem`},onClick:()=>n(e=>!e),children:t?`Hide Error`:`Show Error`})]}),(0,J.jsx)(`div`,{style:{height:`.25rem`}}),t?(0,J.jsx)(`div`,{children:(0,J.jsx)(`pre`,{style:{fontSize:`.7em`,border:`1px solid red`,borderRadius:`.25rem`,padding:`.3rem`,color:`red`,overflow:`auto`},children:e.message?(0,J.jsx)(`code`,{children:e.message}):null})}):null]})}function qO({children:e,fallback:t=null}){return JO()?(0,J.jsx)(q.Fragment,{children:e}):(0,J.jsx)(q.Fragment,{children:t})}function JO(){return q.useSyncExternalStore(YO,()=>!0,()=>!1)}function YO(){return()=>{}}var XO=(e=>(e[e.None=0]=`None`,e[e.Mutable=1]=`Mutable`,e[e.Watching=2]=`Watching`,e[e.RecursedCheck=4]=`RecursedCheck`,e[e.Recursed=8]=`Recursed`,e[e.Dirty=16]=`Dirty`,e[e.Pending=32]=`Pending`,e))(XO||{});function ZO({update:e,notify:t,unwatched:n}){return{link:r,unlink:i,propagate:a,checkDirty:o,shallowPropagate:s};function r(e,t,n){let r=t.depsTail;if(r!==void 0&&r.dep===e)return;let i=r===void 0?t.deps:r.nextDep;if(i!==void 0&&i.dep===e){i.version=n,t.depsTail=i;return}let a=e.subsTail;if(a!==void 0&&a.version===n&&a.sub===t)return;let o=t.depsTail=e.subsTail={version:n,dep:e,sub:t,prevDep:r,nextDep:i,prevSub:a,nextSub:void 0};i!==void 0&&(i.prevDep=o),r===void 0?t.deps=o:r.nextDep=o,a===void 0?e.subs=o:a.nextSub=o}function i(e,t=e.sub){let r=e.dep,i=e.prevDep,a=e.nextDep,o=e.nextSub,s=e.prevSub;return a===void 0?t.depsTail=i:a.prevDep=i,i===void 0?t.deps=a:i.nextDep=a,o===void 0?r.subsTail=s:o.prevSub=s,s===void 0?(r.subs=o)===void 0&&n(r):s.nextSub=o,a}function a(e){let n=e.nextSub,r;top:do{let i=e.sub,a=i.flags;if(a&60?a&12?a&4?!(a&48)&&c(e,i)?(i.flags=a|40,a&=1):a=0:i.flags=a&-9|32:a=0:i.flags=a|32,a&2&&t(i),a&1){let t=i.subs;if(t!==void 0){let i=(e=t).nextSub;i!==void 0&&(r={value:n,prev:r},n=i);continue}}if((e=n)!==void 0){n=e.nextSub;continue}for(;r!==void 0;)if(e=r.value,r=r.prev,e!==void 0){n=e.nextSub;continue top}break}while(!0)}function o(t,n){let r,i=0,a=!1;top:do{let o=t.dep,c=o.flags;if(n.flags&16)a=!0;else if((c&17)==17){if(e(o)){let e=o.subs;e.nextSub!==void 0&&s(e),a=!0}}else if((c&33)==33){(t.nextSub!==void 0||t.prevSub!==void 0)&&(r={value:t,prev:r}),t=o.deps,n=o,++i;continue}if(!a){let e=t.nextDep;if(e!==void 0){t=e;continue}}for(;i--;){let i=n.subs,o=i.nextSub!==void 0;if(o?(t=r.value,r=r.prev):t=i,a){if(e(n)){o&&s(i),n=t.sub;continue}a=!1}else n.flags&=-33;n=t.sub;let c=t.nextDep;if(c!==void 0){t=c;continue top}}return a}while(!0)}function s(e){do{let n=e.sub,r=n.flags;(r&48)==32&&(n.flags=r|16,(r&6)==2&&t(n))}while((e=e.nextSub)!==void 0)}function c(e,t){let n=t.depsTail;for(;n!==void 0;){if(n===e)return!0;n=n.prevDep}return!1}}function QO(e,t,n){let r=typeof e==`object`,i=r?e:void 0;return{next:(r?e.next:e)?.bind(i),error:(r?e.error:t)?.bind(i),complete:(r?e.complete:n)?.bind(i)}}var $O=[],ek=0,{link:tk,unlink:nk,propagate:rk,checkDirty:ik,shallowPropagate:ak}=ZO({update(e){return e._update()},notify(e){$O[sk++]=e,e.flags&=~XO.Watching},unwatched(e){e.depsTail!==void 0&&(e.depsTail=void 0,e.flags=XO.Mutable|XO.Dirty,dk(e))}}),ok=0,sk=0,ck,lk=0;function uk(e){try{++lk,e()}finally{--lk||fk()}}function dk(e){let t=e.depsTail,n=t===void 0?e.deps:t.nextDep;for(;n!==void 0;)n=nk(n,e)}function fk(){if(!(lk>0)){for(;ok<sk;){let e=$O[ok];$O[ok++]=void 0,e.notify()}ok=0,sk=0}}function pk(e,t){let n=typeof e==`function`,r=e,i={_snapshot:n?void 0:e,subs:void 0,subsTail:void 0,deps:void 0,depsTail:void 0,flags:n?XO.None:XO.Mutable,get(){return ck!==void 0&&tk(i,ck,ek),i._snapshot},subscribe(e){let t=QO(e),n={current:!1},r=mk(()=>{i.get(),n.current?t.next?.(i._snapshot):n.current=!0});return{unsubscribe:()=>{r.stop()}}},_update(e){let a=ck,o=t?.compare??Object.is;if(n)ck=i,++ek,i.depsTail=void 0;else if(e===void 0)return!1;n&&(i.flags=XO.Mutable|XO.RecursedCheck);try{let t=i._snapshot,a=typeof e==`function`?e(t):e===void 0&&n?r(t):e;return t===void 0||!o(t,a)?(i._snapshot=a,!0):!1}finally{ck=a,n&&(i.flags&=~XO.RecursedCheck),dk(i)}}};return n?(i.flags=XO.Mutable|XO.Dirty,i.get=function(){let e=i.flags;if(e&XO.Dirty||e&XO.Pending&&ik(i.deps,i)){if(i._update()){let e=i.subs;e!==void 0&&ak(e)}}else e&XO.Pending&&(i.flags=e&~XO.Pending);return ck!==void 0&&tk(i,ck,ek),i._snapshot}):i.set=function(e){if(i._update(e)){let e=i.subs;e!==void 0&&(rk(e),ak(e),fk())}},i}function mk(e){let t=()=>{let t=ck;ck=n,++ek,n.depsTail=void 0,n.flags=XO.Watching|XO.RecursedCheck;try{return e()}finally{ck=t,n.flags&=~XO.RecursedCheck,dk(n)}},n={deps:void 0,depsTail:void 0,subs:void 0,subsTail:void 0,flags:XO.Watching|XO.RecursedCheck,notify(){let e=this.flags;e&XO.Dirty||e&XO.Pending&&ik(this.deps,this)?t():this.flags=XO.Watching},stop(){this.flags=XO.None,this.depsTail=void 0,dk(this)}};return t(),n}function hk(e){return Wx({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function gk(e){let{select:t,...n}=e;return Wx({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function _k(e){return Wx({...e,select:t=>e.select?e.select(t.context):t.context})}var vk=r(n(),1);function yk(e,t){let n=Hx(),r=IE(t),{activeProps:i,inactiveProps:a,activeOptions:o,to:s,preload:c,preloadDelay:l,preloadIntentProximity:u,hashScrollIntoView:d,replace:f,startTransition:p,resetScroll:m,viewTransition:h,children:g,target:_,disabled:v,style:y,className:b,onClick:x,onBlur:S,onFocus:C,onMouseEnter:w,onMouseLeave:T,onTouchStart:E,ignoreBlocker:D,params:O,search:k,hash:A,state:j,mask:M,reloadDocument:N,unsafeRelative:P,from:F,_fromLocation:I,...L}=e,R=JO(),ee=q.useMemo(()=>e,[n,e.from,e._fromLocation,e.hash,e.to,e.search,e.params,e.state,e.mask,e.unsafeRelative]),z=zx(n.stores.location,e=>e,(e,t)=>e.href===t.href),B=q.useMemo(()=>{let e={_fromLocation:z,...ee};return n.buildLocation(e)},[n,z,ee]),V=B.maskedLocation?B.maskedLocation.publicHref:B.publicHref,te=B.maskedLocation?B.maskedLocation.external:B.external,ne=q.useMemo(()=>Ok(V,te,n.history,v),[v,te,V,n.history]),re=q.useMemo(()=>{if(ne?.external)return jx(ne.href,n.protocolAllowlist)?void 0:ne.href;if(!kk(s)&&!(typeof s!=`string`||s.indexOf(`:`)===-1))try{return new URL(s),jx(s,n.protocolAllowlist)?void 0:s}catch{}},[s,ne,n.protocolAllowlist]),ie=q.useMemo(()=>{if(re)return!1;if(o?.exact){if(!mD(z.pathname,B.pathname,n.basepath))return!1}else{let e=pD(z.pathname,n.basepath),t=pD(B.pathname,n.basepath);if(!(e.startsWith(t)&&(e.length===t.length||e[t.length]===`/`)))return!1}return(o?.includeSearch??!0)&&!Ux(z.search,B.search,{partial:!o?.exact,ignoreUndefined:!o?.explicitUndefined})?!1:!o?.includeHash||R&&z.hash===B.hash},[o?.exact,o?.explicitUndefined,o?.includeHash,o?.includeSearch,z,re,R,B.hash,B.pathname,B.search,n.basepath]),ae=ie?Rx(i,{})??xk:bk,oe=ie?bk:Rx(a,{})??bk,se=[b,ae.className,oe.className].filter(Boolean).join(` `),ce=(y||ae.style||oe.style)&&{...y,...ae.style,...oe.style},[le,ue]=q.useState(!1),de=q.useRef(!1),fe=e.reloadDocument||re?!1:c??n.options.defaultPreload,pe=l??n.options.defaultPreloadDelay??0,me=q.useCallback(()=>{n.preloadRoute({...ee,_builtLocation:B}).catch(e=>{console.warn(e),console.warn(VO)})},[n,ee,B]);FE(r,q.useCallback(e=>{e?.isIntersecting&&me()},[me]),Ek,{disabled:!!v||fe!==`viewport`}),q.useEffect(()=>{de.current||!v&&fe===`render`&&(me(),de.current=!0)},[v,me,fe]);let he=e=>{let t=e.currentTarget.getAttribute(`target`),r=_===void 0?t:_;if(!v&&!jk(e)&&!e.defaultPrevented&&(!r||r===`_self`)&&e.button===0){e.preventDefault(),(0,vk.flushSync)(()=>{ue(!0)});let t=n.subscribe(`onResolved`,()=>{t(),ue(!1)});n.navigate({...ee,replace:f,resetScroll:m,hashScrollIntoView:d,startTransition:p,viewTransition:h,ignoreBlocker:D})}};if(re)return{...L,ref:r,href:re,...g&&{children:g},..._&&{target:_},...v&&{disabled:v},...y&&{style:y},...b&&{className:b},...x&&{onClick:x},...S&&{onBlur:S},...C&&{onFocus:C},...w&&{onMouseEnter:w},...T&&{onMouseLeave:T},...E&&{onTouchStart:E}};let ge=e=>{if(v||fe!==`intent`)return;if(!pe){me();return}let t=e.currentTarget;if(Tk.has(t))return;let n=setTimeout(()=>{Tk.delete(t),me()},pe);Tk.set(t,n)},_e=e=>{v||fe!==`intent`||me()},ve=e=>{if(v||!fe||!pe)return;let t=e.currentTarget,n=Tk.get(t);n&&(clearTimeout(n),Tk.delete(t))};return{...L,...ae,...oe,href:ne?.href,ref:r,onClick:Dk([x,he]),onBlur:Dk([S,ve]),onFocus:Dk([C,ge]),onMouseEnter:Dk([w,ge]),onMouseLeave:Dk([T,ve]),onTouchStart:Dk([E,_e]),disabled:!!v,target:_,...ce&&{style:ce},...se&&{className:se},...v&&Sk,...ie&&Ck,...R&&le&&wk}}var bk={},xk={className:`active`},Sk={role:`link`,"aria-disabled":!0},Ck={"data-status":`active`,"aria-current":`page`},wk={"data-transitioning":`transitioning`},Tk=new WeakMap,Ek={rootMargin:`100px`},Dk=e=>t=>{for(let n of e)if(n){if(t.defaultPrevented)return;n(t)}};function Ok(e,t,n,r){if(!r)return t?{href:e,external:!0}:{href:n.createHref(e)||`/`,external:!1}}function kk(e){if(typeof e!=`string`)return!1;let t=e.charCodeAt(0);return t===47?e.charCodeAt(1)!==47:t===46}var Ak=q.forwardRef((e,t)=>{let{_asChild:n,...r}=e,{type:i,...a}=yk(r,t),o=typeof r.children==`function`?r.children({isActive:a[`data-status`]===`active`}):r.children;if(!n){let{disabled:e,...t}=a;return q.createElement(`a`,t,o)}return q.createElement(n,a,o)});function jk(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}var Mk=class extends HO{constructor(e){super(e),this.useMatch=e=>Wx({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>_k({...e,from:this.id}),this.useSearch=e=>Vx({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>aS({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>gk({...e,from:this.id}),this.useLoaderData=e=>hk({...e,from:this.id}),this.useNavigate=()=>Kx({from:this.fullPath}),this.Link=q.forwardRef((e,t)=>(0,J.jsx)(Ak,{ref:t,from:this.fullPath,...e}))}};function Nk(e){return new Mk(e)}var Pk=class extends UO{constructor(e){super(e),this.useMatch=e=>Wx({select:e?.select,from:this.id,structuralSharing:e?.structuralSharing}),this.useRouteContext=e=>_k({...e,from:this.id}),this.useSearch=e=>Vx({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useParams=e=>aS({select:e?.select,structuralSharing:e?.structuralSharing,from:this.id}),this.useLoaderDeps=e=>gk({...e,from:this.id}),this.useLoaderData=e=>hk({...e,from:this.id}),this.useNavigate=()=>Kx({from:this.fullPath}),this.Link=q.forwardRef((e,t)=>(0,J.jsx)(Ak,{ref:t,from:this.fullPath,...e}))}};function Fk(e){return new Pk(e)}function Ik(e,t){let n,r,i,a,o=()=>(n||=e().then(e=>{n=void 0,r=e[t??`default`]}).catch(e=>{if(i=e,Jx(i)&&i instanceof Error&&typeof window<`u`&&typeof sessionStorage<`u`){let e=`tanstack_router_reload:${i.message}`;sessionStorage.getItem(e)||(sessionStorage.setItem(e,`1`),a=!0)}}),n),s=function(e){if(a)throw window.location.reload(),new Promise(()=>{});if(i)throw i;if(!r)if(ME)ME(o());else throw o();return q.createElement(r,e)};return s.preload=o,s}function Lk(e){let t=Hx(),n=`not-found-${zx(t.stores.location,e=>e.pathname)}-${zx(t.stores.status,e=>e)}`;return(0,J.jsx)(WO,{getResetKey:()=>n,onCatch:(t,n)=>{if(bD(t))e.onCatch?.(t,n);else throw t},errorComponent:({error:t})=>{if(bD(t))return e.fallback?.(t);throw t},children:e.children})}function Rk(){return(0,J.jsx)(`p`,{children:`Not Found`})}function zk(e){return(0,J.jsx)(J.Fragment,{children:e.children})}function Bk(e,t,n){return t.options.notFoundComponent?(0,J.jsx)(t.options.notFoundComponent,{...n}):e.options.defaultNotFoundComponent?(0,J.jsx)(e.options.defaultNotFoundComponent,{...n}):(0,J.jsx)(Rk,{})}var Vk=q.memo(function({matchId:e}){let t=Hx(),n=t.stores.matchStores.get(e);n||Px();let r=zx(t.stores.loadedAt,e=>e),i=zx(n,e=>e);return(0,J.jsx)(Hk,{router:t,matchId:e,resetKey:r,matchState:q.useMemo(()=>{let e=i.routeId,n=t.routesById[e].parentRoute?.id;return{routeId:e,ssr:i.ssr,_displayPending:i._displayPending,parentRouteId:n}},[i._displayPending,i.routeId,i.ssr,t.routesById])})});function Hk({router:e,matchId:t,resetKey:n,matchState:r}){let i=e.routesById[r.routeId],a=i.options.pendingComponent??e.options.defaultPendingComponent,o=a?(0,J.jsx)(a,{}):null,s=i.options.errorComponent??e.options.defaultErrorComponent,c=i.options.onCatch??e.options.defaultOnCatch,l=i.isRoot?i.options.notFoundComponent??e.options.notFoundRoute?.options.component:i.options.notFoundComponent,u=r.ssr===!1||r.ssr===`data-only`,d=(!i.isRoot||i.options.wrapInSuspense||u)&&(i.options.wrapInSuspense??a??(i.options.errorComponent?.preload||u))?q.Suspense:zk,f=s?WO:zk,p=l?Lk:zk;return(0,J.jsxs)(i.isRoot?i.options.shellComponent??zk:zk,{children:[(0,J.jsx)(Mx.Provider,{value:t,children:(0,J.jsx)(d,{fallback:o,children:(0,J.jsx)(f,{getResetKey:()=>n,errorComponent:s||KO,onCatch:(e,t)=>{if(bD(e))throw e.routeId??=r.routeId,e;c?.(e,t)},children:(0,J.jsx)(p,{fallback:e=>{if(e.routeId??=r.routeId,!l||e.routeId&&e.routeId!==r.routeId||!e.routeId&&!i.isRoot)throw e;return q.createElement(l,e)},children:u||r._displayPending?(0,J.jsx)(qO,{fallback:o,children:(0,J.jsx)(Wk,{matchId:t})}):(0,J.jsx)(Wk,{matchId:t})})})})}),r.parentRouteId===`__root__`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Uk,{resetKey:n}),(e.options.scrollRestoration,null)]}):null]})}function Uk({resetKey:e}){let t=Hx(),n=q.useRef(void 0);return NE(()=>{let e=t.latestLocation.href;(n.current===void 0||n.current!==e)&&(t.emit({type:`onRendered`,...hO(t.stores.location.get(),t.stores.resolvedLocation.get())}),n.current=e)},[t.latestLocation.state.__TSR_key,e,t]),null}var Wk=q.memo(function({matchId:e}){let t=Hx(),n=(e,n)=>t.getMatch(e.id)?._nonReactive[n]??e._nonReactive[n],r=t.stores.matchStores.get(e);r||Px();let i=zx(r,e=>e),a=i.routeId,o=t.routesById[a],s=q.useMemo(()=>{let e=(t.routesById[a].options.remountDeps??t.options.defaultRemountDeps)?.({routeId:a,loaderDeps:i.loaderDeps,params:i._strictParams,search:i._strictSearch});return e?JSON.stringify(e):void 0},[a,i.loaderDeps,i._strictParams,i._strictSearch,t.options.defaultRemountDeps,t.routesById]),c=q.useMemo(()=>{let e=o.options.component??t.options.defaultComponent;return e?(0,J.jsx)(e,{},s):(0,J.jsx)(Gk,{})},[s,o.options.component,t.options.defaultComponent]);if(i._displayPending)throw n(i,`displayPendingPromise`);if(i._forcePending)throw n(i,`minPendingPromise`);if(i.status===`pending`){let e=o.options.pendingMinMs??t.options.defaultPendingMinMs;if(e){let n=t.getMatch(i.id);if(n&&!n._nonReactive.minPendingPromise){let t=Fx();n._nonReactive.minPendingPromise=t,setTimeout(()=>{t.resolve(),n._nonReactive.minPendingPromise=void 0},e)}}throw n(i,`loadPromise`)}if(i.status===`notFound`)return bD(i.error)||Px(),Bk(t,o,i.error);if(i.status===`redirected`)throw AD(i.error)||Px(),n(i,`loadPromise`);if(i.status===`error`)throw i.error;return c}),Gk=q.memo(function(){let e=Hx(),t=q.useContext(Mx),n,r=!1,i;{let a=t?e.stores.matchStores.get(t):void 0;[n,r]=zx(a,e=>[e?.routeId,e?.globalNotFound??!1]),i=zx(e.stores.matchesId,e=>e[e.findIndex(e=>e===t)+1])}let a=n?e.routesById[n]:void 0,o=e.options.defaultPendingComponent?(0,J.jsx)(e.options.defaultPendingComponent,{}):null;if(r)return a||Px(),Bk(e,a,void 0);if(!i)return null;let s=(0,J.jsx)(Vk,{matchId:i});return n===`__root__`?(0,J.jsx)(q.Suspense,{fallback:o,children:s}):s});function Kk(){let e=Hx(),t=q.useRef({router:e,mounted:!1}),[n,r]=q.useState(!1),i=zx(e.stores.isLoading,e=>e),a=zx(e.stores.hasPending,e=>e),o=PE(i),s=i||n||a,c=PE(s),l=i||a,u=PE(l);return e.startTransition=e=>{r(!0),q.startTransition(()=>{e(),r(!1)})},q.useEffect(()=>{let t=e.history.subscribe(e.load),n=e.buildLocation({to:e.latestLocation.pathname,search:!0,params:!0,hash:!0,state:!0,_includeValidateSearch:!0});return dD(e.latestLocation.publicHref)!==dD(n.publicHref)&&e.commitLocation({...n,replace:!0}),()=>{t()}},[e,e.history]),NE(()=>{typeof window<`u`&&e.ssr||t.current.router===e&&t.current.mounted||(t.current={router:e,mounted:!0},(async()=>{try{await e.load()}catch(e){console.error(e)}})())},[e]),NE(()=>{o&&!i&&e.emit({type:`onLoad`,...hO(e.stores.location.get(),e.stores.resolvedLocation.get())})},[o,e,i]),NE(()=>{u&&!l&&e.emit({type:`onBeforeRouteMount`,...hO(e.stores.location.get(),e.stores.resolvedLocation.get())})},[l,u,e]),NE(()=>{if(c&&!s){let t=hO(e.stores.location.get(),e.stores.resolvedLocation.get());e.emit({type:`onResolved`,...t}),uk(()=>{e.stores.status.set(`idle`),e.stores.resolvedLocation.set(e.stores.location.get())})}},[s,c,e]),null}function qk(){let e=Hx(),t=e.routesById.__root__.options.pendingComponent??e.options.defaultPendingComponent,n=t?(0,J.jsx)(t,{}):null,r=(0,J.jsxs)(typeof document<`u`&&e.ssr?zk:q.Suspense,{fallback:n,children:[(0,J.jsx)(Kk,{}),(0,J.jsx)(Jk,{})]});return e.options.InnerWrap?(0,J.jsx)(e.options.InnerWrap,{children:r}):r}function Jk(){let e=Hx(),t=zx(e.stores.firstId,e=>e),n=zx(e.stores.loadedAt,e=>e),r=t?(0,J.jsx)(Vk,{matchId:t}):null;return(0,J.jsx)(Mx.Provider,{value:t,children:e.options.disableGlobalCatchBoundary?r:(0,J.jsx)(WO,{getResetKey:()=>n,errorComponent:KO,onCatch:void 0,children:r})})}function Yk(){let e=Hx();return zx(e.stores.matchRouteDeps,e=>e),q.useCallback(t=>{let{pending:n,caseSensitive:r,fuzzy:i,includeSearch:a,...o}=t;return e.matchRoute(o,{pending:n,caseSensitive:r,fuzzy:i,includeSearch:a})},[e])}var Xk=e=>({createMutableStore:pk,createReadonlyStore:pk,batch:uk}),Zk=e=>new Qk(e),Qk=class extends _O{constructor(e){super(e,Xk)}};function $k({router:e,children:t,...n}){Lx(n)&&e.update({...e.options,...n,context:{...e.options.context,...n.context}});let r=(0,J.jsx)(Gx.Provider,{value:e,children:t});return e.options.Wrap?(0,J.jsx)(e.options.Wrap,{children:r}):r}function eA({router:e,...t}){return(0,J.jsx)($k,{router:e,...t,children:(0,J.jsx)(qk,{})})}function tA(e){let t=Hx(),n=(0,q.useRef)(void 0);return zx(t.stores.location,r=>{let i=e?.select?e.select(r):r;if(e?.structuralSharing??t.options.defaultStructuralSharing){let e=Ax(n.current,i);return n.current=e,e}return i})}var nA=H(`arrow-left`,[[`path`,{d:`m12 19-7-7 7-7`,key:`1l729n`}],[`path`,{d:`M19 12H5`,key:`x3x0zl`}]]),rA=H(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),iA=H(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),aA=H(`at-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8`,key:`7n84p3`}]]),oA=H(`bell`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}]]),sA=H(`book-open`,[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z`,key:`ruj8y`}]]),cA=H(`bookmark`,[[`path`,{d:`M17 3a2 2 0 0 1 2 2v15a1 1 0 0 1-1.496.868l-4.512-2.578a2 2 0 0 0-1.984 0l-4.512 2.578A1 1 0 0 1 5 20V5a2 2 0 0 1 2-2z`,key:`oz39mx`}]]),lA=H(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),uA=H(`calendar-clock`,[[`path`,{d:`M16 14v2.2l1.6 1`,key:`fo4ql5`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`path`,{d:`M21 7.5V6a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h3.5`,key:`1osxxc`}],[`path`,{d:`M3 10h5`,key:`r794hk`}],[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`circle`,{cx:`16`,cy:`16`,r:`6`,key:`qoo3c4`}]]),dA=H(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),fA=H(`circle-dot`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}]]),pA=H(`circle-slash`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`9`,x2:`15`,y1:`15`,y2:`9`,key:`1dfufj`}]]),mA=H(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),hA=H(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),gA=H(`corner-down-right`,[[`path`,{d:`m15 10 5 5-5 5`,key:`qqa56n`}],[`path`,{d:`M4 4v7a4 4 0 0 0 4 4h12`,key:`z08zvw`}]]),_A=H(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),vA=H(`crown`,[[`path`,{d:`M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z`,key:`1vdc57`}],[`path`,{d:`M5 21h14`,key:`11awu3`}]]),yA=H(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),bA=H(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),xA=H(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),SA=H(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),CA=H(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),wA=H(`flag`,[[`path`,{d:`M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528`,key:`1jaruq`}]]),TA=H(`fold-vertical`,[[`path`,{d:`M12 22v-6`,key:`6o8u61`}],[`path`,{d:`M12 8V2`,key:`1wkif3`}],[`path`,{d:`M4 12H2`,key:`rhcxmi`}],[`path`,{d:`M10 12H8`,key:`s88cx1`}],[`path`,{d:`M16 12h-2`,key:`10asgb`}],[`path`,{d:`M22 12h-2`,key:`14jgyd`}],[`path`,{d:`m15 19-3-3-3 3`,key:`e37ymu`}],[`path`,{d:`m15 5-3 3-3-3`,key:`19d6lf`}]]),EA=H(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),DA=H(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),OA=H(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),kA=H(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),AA=H(`hash`,[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]),jA=H(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),MA=H(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),NA=H(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),PA=H(`inbox`,[[`polyline`,{points:`22 12 16 12 14 15 10 15 8 12 2 12`,key:`o97t9d`}],[`path`,{d:`M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z`,key:`oot6mr`}]]),FA=H(`info`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 16v-4`,key:`1dtifu`}],[`path`,{d:`M12 8h.01`,key:`e9boi3`}]]),IA=H(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),LA=H(`layout-template`,[[`rect`,{width:`18`,height:`7`,x:`3`,y:`3`,rx:`1`,key:`f1a2em`}],[`rect`,{width:`9`,height:`7`,x:`3`,y:`14`,rx:`1`,key:`jqznyg`}],[`rect`,{width:`5`,height:`7`,x:`16`,y:`14`,rx:`1`,key:`q5h2i8`}]]),RA=H(`library-big`,[[`rect`,{width:`8`,height:`18`,x:`3`,y:`3`,rx:`1`,key:`oynpb5`}],[`path`,{d:`M7 3v18`,key:`bbkbws`}],[`path`,{d:`M20.4 18.9c.2.5-.1 1.1-.6 1.3l-1.9.7c-.5.2-1.1-.1-1.3-.6L11.1 5.1c-.2-.5.1-1.1.6-1.3l1.9-.7c.5-.2 1.1.1 1.3.6Z`,key:`1qboyk`}]]),zA=H(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),BA=H(`list-end`,[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M16 12H3`,key:`1a2rj7`}],[`path`,{d:`M9 19H3`,key:`s61nz1`}],[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M21 5v12a2 2 0 0 1-2 2h-6`,key:`hey24a`}]]),VA=H(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),HA=H(`locate-fixed`,[[`line`,{x1:`2`,x2:`5`,y1:`12`,y2:`12`,key:`bvdh0s`}],[`line`,{x1:`19`,x2:`22`,y1:`12`,y2:`12`,key:`1tbv5k`}],[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`5`,key:`11lu5j`}],[`line`,{x1:`12`,x2:`12`,y1:`19`,y2:`22`,key:`x3vr5v`}],[`circle`,{cx:`12`,cy:`12`,r:`7`,key:`fim9np`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),UA=H(`log-out`,[[`path`,{d:`m16 17 5-5-5-5`,key:`1bji2h`}],[`path`,{d:`M21 12H9`,key:`dn1m92`}],[`path`,{d:`M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4`,key:`1uf3rs`}]]),WA=H(`maximize-2`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`m21 3-7 7`,key:`1l2asr`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M9 21H3v-6`,key:`wtvkvv`}]]),GA=H(`megaphone`,[[`path`,{d:`M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z`,key:`q8bfy3`}],[`path`,{d:`M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14`,key:`1853fq`}],[`path`,{d:`M8 6v8`,key:`15ugcq`}]]),KA=H(`message-circle-question-mark`,[[`path`,{d:`M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719`,key:`1sd12s`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),qA=H(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]),JA=H(`minimize-2`,[[`path`,{d:`m14 10 7-7`,key:`oa77jy`}],[`path`,{d:`M20 10h-6V4`,key:`mjg0md`}],[`path`,{d:`m3 21 7-7`,key:`tjx5ai`}],[`path`,{d:`M4 14h6v6`,key:`rmj7iw`}]]),YA=H(`monitor`,[[`rect`,{width:`20`,height:`14`,x:`2`,y:`3`,rx:`2`,key:`48i651`}],[`line`,{x1:`8`,x2:`16`,y1:`21`,y2:`21`,key:`1svkeh`}],[`line`,{x1:`12`,x2:`12`,y1:`17`,y2:`21`,key:`vw1qmm`}]]),XA=H(`moon`,[[`path`,{d:`M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401`,key:`kfwtm`}]]),ZA=H(`network`,[[`rect`,{x:`16`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`4q2zg0`}],[`rect`,{x:`2`,y:`16`,width:`6`,height:`6`,rx:`1`,key:`8cvhb9`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`6`,rx:`1`,key:`1egb70`}],[`path`,{d:`M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3`,key:`1jsf9p`}],[`path`,{d:`M12 12V8`,key:`2874zd`}]]),QA=H(`octagon-x`,[[`path`,{d:`m15 9-6 6`,key:`1uzhvr`}],[`path`,{d:`M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z`,key:`2d38gg`}],[`path`,{d:`m9 9 6 6`,key:`z0biqf`}]]),$A=H(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),ej=H(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),tj=H(`phone-off`,[[`path`,{d:`M10.1 13.9a14 14 0 0 0 3.732 2.668 1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2 18 18 0 0 1-12.728-5.272`,key:`1wngk7`}],[`path`,{d:`M22 2 2 22`,key:`y4kqgn`}],[`path`,{d:`M4.76 13.582A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 .244.473`,key:`10hv5p`}]]),nj=H(`reply`,[[`path`,{d:`M20 18v-2a4 4 0 0 0-4-4H4`,key:`5vmcpk`}],[`path`,{d:`m9 17-5-5 5-5`,key:`nvlc11`}]]),rj=H(`rotate-cw`,[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]),ij=H(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),aj=H(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),oj=H(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),sj=H(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),cj=H(`shield-alert`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]),lj=H(`shield-ellipsis`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}]]),uj=H(`shield-cog`,[[`path`,{d:`m10.929 14.467-.383.924`,key:`hdyevy`}],[`path`,{d:`M10.929 8.923 10.546 8`,key:`1nr44d`}],[`path`,{d:`M13.225 8.923 13.608 8`,key:`aewley`}],[`path`,{d:`m13.607 15.391-.382-.924`,key:`m37gf1`}],[`path`,{d:`m14.849 10.547.923-.383`,key:`1d3c4q`}],[`path`,{d:`m14.849 12.843.923.383`,key:`lmvhy3`}],[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9.305 10.547-.923-.383`,key:`1d13ox`}],[`path`,{d:`m9.305 12.843-.923.383`,key:`7wxwh5`}],[`circle`,{cx:`12.077`,cy:`11.695`,r:`3`,key:`fse9k8`}]]),dj=H(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),fj=H(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),pj=H(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),mj=H(`square`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}]]),hj=H(`sun`,[[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`m4.93 4.93 1.41 1.41`,key:`149t6j`}],[`path`,{d:`m17.66 17.66 1.41 1.41`,key:`ptbguv`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`m6.34 17.66-1.41 1.41`,key:`1m8zz5`}],[`path`,{d:`m19.07 4.93-1.41 1.41`,key:`1shlcs`}]]),gj=H(`terminal`,[[`path`,{d:`M12 19h8`,key:`baeox8`}],[`path`,{d:`m4 17 6-6-6-6`,key:`1yngyt`}]]),_j=H(`timer`,[[`line`,{x1:`10`,x2:`14`,y1:`2`,y2:`2`,key:`14vaq8`}],[`line`,{x1:`12`,x2:`15`,y1:`14`,y2:`11`,key:`17fdiu`}],[`circle`,{cx:`12`,cy:`14`,r:`8`,key:`1e1u0o`}]]),vj=H(`user`,[[`path`,{d:`M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2`,key:`975kel`}],[`circle`,{cx:`12`,cy:`7`,r:`4`,key:`17ys0d`}]]),yj=H(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),bj=H(`zoom-in`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),xj=H(`zoom-out`,[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]),Sj=`oc.detachedComposer.geom`,Cj=300,wj=200,Y=null,Tj=0,Ej=0,Dj=null,Oj=0,kj=new Set;function Aj(){for(let e of kj)e()}function jj(e){return kj.add(e),()=>kj.delete(e)}function Mj(){return Y}function Nj(e,t){let n=Math.min(Math.max(Cj,Math.min(e.w,t.w)),t.w),r=Math.min(Math.max(wj,Math.min(e.h,t.h)),t.h);return{x:Math.max(0,Math.min(e.x,t.w-n)),y:Math.max(0,Math.min(e.y,t.h-r)),w:n,h:r}}function Pj(){let e=typeof window<`u`?window.innerWidth:1200,t=typeof window<`u`?window.innerHeight:800,n=Math.min(720,Math.round(e*.72)),r=Math.min(300,Math.round(t*.42));return{x:Math.round((e-n)/2),y:t-r-28,w:n,h:r}}function Fj(){let e=null;try{let t=typeof localStorage<`u`?localStorage.getItem(Sj):null;if(t!==null){let n=JSON.parse(t);typeof n.x==`number`&&typeof n.y==`number`&&typeof n.w==`number`&&typeof n.h==`number`&&(e={x:n.x,y:n.y,w:n.w,h:n.h})}}catch{}return e===null&&(e=Pj()),typeof window<`u`&&window.innerWidth&&window.innerHeight&&(e=Nj(e,{w:window.innerWidth,h:window.innerHeight})),e}function Ij(e){try{localStorage?.setItem(Sj,JSON.stringify(e))}catch{}}function Lj(e){return Y===null?(Tj+=1,Y={holdId:Tj,sending:!1,targetChatId:e.targetChatId,targetLabel:e.targetLabel,text:e.text,interim:``,recording:e.recording??!1,geom:Fj(),pendingSend:null,pendingSendId:0,pendingRestore:null,voiceEnabled:e.voiceEnabled,voiceLang:e.voiceLang},Dj=e.stop??null,Oj++,Aj(),!0):!1}function Rj(e){Y!==null&&(Dj=e,Oj++,Y.recording||(Y={...Y,recording:!0},Aj()))}function zj(){return Oj}function Bj(e,t){Y!==null&&(Y={...Y,text:$j(Y.text,e,t)},Aj())}function Vj(e){Y===null||Y.interim===e||(Y={...Y,interim:e},Aj())}function Hj(e){Y===null||Y.text===e||(Y={...Y,text:e},Aj())}function Uj(e){if(Y===null)return;let t=Nj(e,{w:typeof window<`u`&&window.innerWidth?window.innerWidth:e.w,h:typeof window<`u`&&window.innerHeight?window.innerHeight:e.h});Y={...Y,geom:t},Ij(t),Aj()}function Wj(e){Y!==null&&(Ej+=1,Y={...Y,pendingSend:e,pendingSendId:Ej,sending:!0},Aj())}function Gj(){Y===null||Y.pendingSend===null||(Y={...Y,pendingSend:null},Aj())}function Kj(e){Y===null||Y.holdId!==e||!Y.sending||(Y={...Y,sending:!1},Aj())}function qj(e){return Y===null||Y.holdId!==e?``:Qj()}function Jj(){Y!==null&&(Y={...Y,pendingRestore:Y.text},Aj())}function Yj(){Y===null||Y.pendingRestore===null||(Y={...Y,pendingRestore:null},Aj())}function Xj(e){Y===null||!Y.recording||e!==void 0&&e!==Oj||(Y={...Y,recording:!1,interim:``},Aj())}function Zj(){try{Dj?.()}catch{}Dj=null}function Qj(){let e=Y?.text??``;try{Dj?.()}catch{}return Dj=null,Y=null,Aj(),e}function $j(e,t,n){let r=t.trim();if(r===``)return e;if(e===``)return r;let i=e.replace(/\s+$/,``);return n?`${i}\n\n${r}`:`${i} ${r}`}var eM=[],tM=new Map,nM=new Set;function rM(){for(let e of nM)e()}function iM(e){return`${e.messageId}:${e.blockIndex??`all`}`}function aM(e,t){let n=tM.get(e)??eM;return n.some(e=>iM(e)===iM(t))?`ok`:n.length>=10?`too-many`:n.reduce((e,t)=>e+t.excerpt.length,0)+t.excerpt.length>1500?`too-long`:(tM.set(e,[...n,t]),rM(),`ok`)}function oM(e,t){let n=tM.get(e);if(n===void 0)return;let r=n.filter(e=>iM(e)!==t);r.length!==n.length&&(r.length===0?tM.delete(e):tM.set(e,r),rM())}var sM=iM;function cM(e){tM.delete(e)&&rM()}function lM(e){let t=tM.get(e)??eM;return t.length>0&&(tM.delete(e),rM()),t}function uM(e,t){if(t.length===0)return{restored:0,dropped:0};let n=tM.get(e)??eM,r=new Set,i=0;for(let e of n)r.add(iM(e)),i+=e.excerpt.length;let a=[],o=0;for(let e of t)if(!r.has(iM(e))){if(n.length+a.length>=10||i+e.excerpt.length>1500){o+=1;continue}r.add(iM(e)),i+=e.excerpt.length,a.push(e)}let s=[...a,...n];return s.length===0?tM.delete(e):tM.set(e,s),rM(),{restored:a.length,dropped:o}}function dM(e,t,n){let r=t.filter(e=>!n.has(e.messageId)),{restored:i,dropped:a}=uM(e,r);return{restored:i,gone:t.length-r.length,dropped:a}}function fM(e){return(0,q.useSyncExternalStore)(e=>(nM.add(e),()=>nM.delete(e)),()=>e===null?eM:tM.get(e)??eM)}var pM=null;function mM(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=pM;pM=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{pM=n}}function hM(){if(!pM)throw Error(`No resource fiber available`);return pM}function gM(){return pM}var _M=Symbol(`tap.Context.defaultValue`),vM=e=>e,yM=new Map,bM=new Set,xM=()=>new Map(yM),SM=(e,t)=>{let n=yM;yM=e;try{return t()}finally{yM=n}},CM=(e,t)=>{e[_M]=t},wM=e=>typeof e==`object`&&!!e&&_M in e,TM=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),EM=e=>wM(e)||TM(e),DM=e=>{if(!wM(e)){if(TM(e)){CM(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},OM=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);DM(e);let r=e,i=hM(),a=bN(void 0),o=a.current===void 0||!Object.is(a.current.value,t);CN(()=>{a.current={value:t}},[t]);let s=yM.get(r),c=s!==void 0||yM.has(r);yM.set(r,{value:t,source:i});try{return kM(r,o,n)}finally{c?yM.set(r,s):yM.delete(r)}},kM=(e,t,n)=>{let r=bM.has(e);t?bM.add(e):bM.delete(e);try{return n()}finally{r?bM.add(e):bM.delete(e)}},AM=e=>{DM(e);let t=e,n=jM(t,e),r=hM();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},jM=(e,t)=>yM.get(e)??{value:vM(t)[_M],source:null},MM=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a===t||a===e||(i??=new Map).set(n,a);return i},NM=(e,t=e.wipContextDeps)=>{let n=gM();!n||!t||(n.wipContextDeps=MM(n,e,n.wipContextDeps,t))},PM=()=>bM.size>0,FM=e=>{if(!e.contextDeps||!PM())return!1;for(let t of bM.keys())if(e.contextDeps.has(t))return!0;return!1},IM=[0,1,2,3];function LM(e){let t=[];for(let n of IM){let r=e[n];if(r!==void 0)for(let e=0;e<r.length;e++)try{r[e]()}catch(e){t.push(e)}}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during commit`)}}function RM(e){let t=[];for(let n of e.cells)if(n?.type===`effect`&&(n.deps=null,n.cleanup))try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}if(t.length>0){if(t.length===1)throw t[0];for(let e of t)console.error(e);throw AggregateError(t,`Errors during cleanup`)}}var zM=typeof process<`u`&&!1,BM=e=>({version:0,committedVersion:0,context:xM(),dispatchUpdate:e,changelog:[],rollbackCallbacks:[]}),VM=e=>{e.committedVersion=e.version,e.changelog.length=0,e.rollbackCallbacks.length=0},HM=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t===e.committedVersion)e.changelog.length=0;else{if(e.committedVersion>t)throw Error(`Version is less than committed version`);for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop();for(let t=0;t<e.changelog.length;t++)UM(e.changelog[t]);VM(e)}}},UM=e=>{KM(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},WM=(e,t,n)=>{let r=e.wipCommitCallbacks;(r[t]??=[]).push(n)},GM=(e,t)=>{e.rollbackCallbacks.push(t)},KM=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),GM(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},qM=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},JM=()=>{throw Error(`Hook order changed between renders`)},YM=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState)),i),()=>(r=!0,i=!0,UM(t),e.root.changelog.push(t),!0))},XM=(e,t,n,r,i)=>{let a=r?r(n):n;zM&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=gM();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else YM(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,queued:!1},i?t:void 0)}};return o};function ZM(e,t,n,r){let i=hM(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:JM();!i.isFirstRender&&a>=i.cells.length&&qM();let s=XM(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t?(r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,zM&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):zM&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(KM(i,s),s.workInProgress=t)}return s.isDirty&&WM(i,0,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function QM(e,t,n){return ZM(e,t,n,!1)}var $M=(e,t)=>typeof t==`function`?t(e):t,eN=e=>e===void 0?void 0:typeof e==`function`?e():e;function tN(e){return ZM($M,e,eN,!0)}var nN=(e,t)=>{zM&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
11
+
12
+ Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},rN=(e,t)=>{WM(e,0,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},iN=(e,t)=>{let n=hM(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){!n.isFirstRender&&r>=n.cells.length&&qM();let a=e();return zM&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&JM();let a=i;if(nN(a.wipDeps,t))return a.isDirty&&rN(n,a),a.wip;let o=e();return zM&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,GM(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),rN(n,a),o};function aN(e){return iN(()=>({current:e}),[])}var oN=(e,t)=>iN(()=>e,t),sN=()=>({type:`effect`,cleanup:void 0,deps:null});function cN(e,t){let n=hM(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?sN():i.type===`effect`?i:JM();if(i===void 0&&(!n.isFirstRender&&r>=n.cells.length&&qM(),n.cells[r]=a),!(t&&a.deps&&nN(a.deps,t))){if(a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);WM(n,2,()=>{try{a.cleanup?.()}finally{a.cleanup=void 0}}),WM(n,3,()=>{try{let t=e();if(t!==void 0&&typeof t!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof t}`);a.cleanup=t}finally{a.deps=t}})}}function lN(e){let t=hM(),n=aN(e);return n.current!==e&&WM(t,1,()=>{n.current=e}),oN(((...e)=>{if(zM&&gM())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var uN=e=>{if(!EM(e))throw Error("A tap resource's `use()` only accepts a tap context.");return AM(e)},dN=(e,t,n=t)=>{let r=aN(!0),i=r.current?n():t();r.current=!1;let[,a]=tN(0),o=lN(()=>{Object.is(i,t())||a(e=>e+1)});return cN(()=>(o(),e(o)),[e]),i},fN=(e,t)=>{},pN=q.default;function mN(e){let t=(0,q.useRef)(e);return(0,q.useInsertionEffect)(()=>{t.current=e}),(0,q.useCallback)(((...e)=>t.current(...e)),[])}var hN=pN.useEffectEvent??mN,X=o({createContext:()=>ON,default:()=>q.default,use:()=>kN,useCallback:()=>SN,useContext:()=>AN,useDebugValue:()=>DN,useEffect:()=>CN,useEffectEvent:()=>TN,useLayoutEffect:()=>wN,useMemo:()=>xN,useReducer:()=>yN,useRef:()=>bN,useState:()=>vN,useSyncExternalStore:()=>EN});t(X,r(e(),1));var gN=()=>gM()!==null,_N=q.default,vN=e=>gN()?tN(e):_N.useState(e),yN=(e,t,n)=>gN()?QM(e,t,n):_N.useReducer(e,t,n),bN=e=>gN()?aN(e):_N.useRef(e),xN=(e,t)=>gN()?iN(e,t):_N.useMemo(e,t),SN=(e,t)=>gN()?oN(e,t):_N.useCallback(e,t),CN=(e,t)=>gN()?cN(e,t):_N.useEffect(e,t),wN=(e,t)=>gN()?cN(e,t):_N.useLayoutEffect(e,t),TN=e=>gN()?lN(e):hN(e),EN=(e,t,n)=>gN()?dN(e,t,n):_N.useSyncExternalStore(e,t,n),DN=(e,t)=>gN()?void 0:_N.useDebugValue(e,t),ON=e=>{let t=_N.createContext(e);return CM(t,e),t},kN=e=>gN()&&EM(e)?uN(e):_N.use(e),AN=e=>gN()&&EM(e)?uN(e):_N.useContext(e),jN=q.default,MN=Symbol.for(`react.memo_cache_sentinel`),NN=e=>Array(e).fill(MN),xte=e=>jN.useMemo(()=>{let t=NN(e);return t[MN]=!0,t},[]),Z=e=>{let t=gM();if(t===null)return(jN.__COMPILER_RUNTIME?.c??xte)(e);let n=t.memoCache,r=n.workInProgress;if(r===null){let e=n.current;r=e===null?[]:e.map(e=>e.slice()),n.workInProgress=r}let i=n.index++,a=r[i];return a===void 0?(a=NN(e),r[i]=a):zM&&a.length!==e&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${e} was requested.`),a};function PN(e){return(...t)=>({hook:e,args:t})}function FN(e,t,n){return n?{...t,key:e,deps:n}:{...t,key:e}}var Ste=50,IN={schedulers:new Set([]),isScheduled:!1},Cte=class{_task;_isDirty=!1;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){this._isDirty=!0,IN.schedulers.add(this),wte()}runTask(){this._isDirty=!1,this._task()}},wte=()=>{IN.isScheduled||(IN.isScheduled=!0,Tte())},LN=()=>{try{let e=[],t=0;for(let n of IN.schedulers)if(IN.schedulers.delete(n),n.isDirty){if(t++,t>Ste)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);try{n.runTask()}catch(t){e.push(t)}}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,`Errors occurred during flushSync`)}}finally{IN.schedulers.clear(),IN.isScheduled=!1}},Tte=(()=>{if(typeof MessageChannel<`u`){let e=new MessageChannel;return e.port1.onmessage=LN,()=>e.port2.postMessage(null)}return()=>setTimeout(LN,0)})(),RN=e=>{let t=IN;IN={schedulers:new Set([]),isScheduled:!0};try{let t=e();return LN(),t}finally{IN=t}},Ete={useState:tN,useReducer:QM,useRef:aN,useMemo:iN,useCallback:oN,useEffect:cN,useLayoutEffect:cN,useInsertionEffect:cN,useEffectEvent:lN,useContext:uN,use:uN,useSyncExternalStore:dN,useDebugValue:fN},zN=q.default,BN=zN.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??zN.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,VN=BN==null?null:`H`in BN?{get current(){return BN.H},set current(e){BN.H=e}}:`ReactCurrentDispatcher`in BN?{get current(){return BN.ReactCurrentDispatcher.current},set current(e){BN.ReactCurrentDispatcher.current=e}}:null;function Dte(e){if(!VN)return e();let t=VN.current;VN.current=Ete;try{return e()}finally{VN.current=t}}function HN(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],contextDeps:null,wipContextDeps:null,commitCallbacks:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function UN(e){if(!e.isMounted)throw Error(`Tried to unmount a fiber that is already unmounted`);e.isMounted=!1,RM(e)}function WN(e,t){if(e.memoCache.workInProgress=null,e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,mM(e,()=>{r=Dte(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0);return NM(e),r}function GN(e){let t=e.wipCommitCallbacks??e.commitCallbacks??[];e.wipCommitCallbacks=null,e.commitCallbacks=t,e.isMounted=!0,e.contextDeps=e.wipContextDeps,VM(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),zM&&e.isNeverMounted&&e.devStrictMode===`root`&&(e.isNeverMounted=!1,LM(t),RM(e)),e.isNeverMounted=!1,LM(t)}var Ote=()=>{let e=hM();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},kte=()=>`child`,KN=()=>null,Ate=()=>{if(!zM)return KN;let e=bN(0);return vN(()=>e.current++),e.current===2?kte:KN},qN=()=>gM()?Ote:Ate(),jte=e=>e(),Mte=e=>{let t=xN(()=>new Cte(()=>p()),[]),n=xN(()=>[],[]),r=qN(),i=xN(()=>{let e=BM((r,i)=>{if(!t.isDirty){if(!r())return;i()}HM(e,e.committedVersion+e.changelog.length),n.push(i),t.markDirty()});return HN(jte,e,void 0,r())},[n,t,r]),a=xM(),o=i.root.version-i.root.committedVersion,s=SM(a,()=>WN(i,[e])),c=bN(!1),l=bN([e]),u=bN(s),d=xN(()=>new Set,[]),f=e=>{t.isDirty||u.current===e||(u.current=e,d.forEach(e=>e()))},p=TN(()=>{HM(i.root,i.root.committedVersion),n.forEach(e=>{zM&&i.devStrictMode&&e(),e()}),HM(i.root,i.root.committedVersion+i.root.changelog.length),zM&&i.devStrictMode&&SM(i.root.context,()=>WN(i,l.current));let e=SM(i.root.context,()=>WN(i,l.current));if(t.isDirty)throw Error(`Scheduler is dirty, this should never happen`);VM(i.root),n.length=0,c.current&&GN(i),f(e)});return CN(()=>(c.current=!0,()=>{c.current=!1,UN(i)}),[i]),CN(()=>{l.current=[e],VM(i.root),n.splice(0,o),i.root.context=a,GN(i),f(s)}),xN(()=>({getValue:()=>u.current,subscribe:e=>(d.add(e),()=>d.delete(e))}),[d])},Nte=()=>{let e=bN(0),t=e.current,n=hM();return{version:t,markDirty:xN(()=>()=>{e.current++,n?.markDirty?.()},[n]),root:n.root}},Pte=()=>{let e=xN(()=>BM((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)}),[]),[t,n]=yN((t,n)=>(HM(e,t),t+ +!!n()),0),[,r]=vN(0);return HM(e,t),{root:e,version:t,markDirty:void 0}},JN=()=>{let e=qN(),{root:t,version:n,markDirty:r}=gM()?Nte():Pte();return{version:n,createFiber:SN((n,i,a)=>HN(n,t,a?()=>{a(),r?.()}:r,e()),[])}},YN=(e,t,n)=>{let r=bN(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,CN(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&nN(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function XN(e){let{version:t,createFiber:n}=JN(),r=xN(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=YN(()=>({value:WN(r,e.args)}),[r,t,e.args],FM(r));return CN(()=>()=>UN(r),[r]),CN(()=>{GN(r)},[r,i]),i.value}var ZN=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},Fte=(e,t)=>!e.isDirty&&!FM(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&nN(e.committedDeps,t),Ite=e=>{if(!PM())return!1;for(let{fiber:t}of e.values())if(FM(t))return!0;return!1};function QN(e){let t=xN(()=>new Map,[]),{version:n,createFiber:r}=JN(),i=Ite(t),a=YN(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>ZN(t,c));l={fiber:e,next:{value:WN(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>ZN(t,c)),n=WN(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(Fte(l,s.deps))l.fiber.contextDeps&&NM(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=WN(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return CN(()=>()=>{for(let e of t.keys()){let n=t.get(e).fiber;UN(n)}},[t]),CN(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(n.fiber.isMounted&&UN(n.fiber),t.delete(e)):r===`skip`||(r.remount&&(UN(n.fiber),n.fiber=r.remount),GN(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1)}},[a,t]),a}var Lte=e=>e(),Rte=e=>{let{createFiber:t}=JN(),n=xN(()=>t(Lte,void 0),[t]),r=WN(n,[e]);CN(()=>()=>{UN(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,GN(n))};return CN(a),{value:r,effects:a}},zte=PN(()=>{let e=Z(4),[t,n]=vN(Bte),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>({...n,renderers:{...n.renderers,[e]:[...n.renderers[e]??[],t]}})),()=>{n(n=>({...n,renderers:{...n.renderers,[e]:n.renderers[e]?.filter(e=>e!==t)??[]}}))}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function Bte(){return{renderers:{},fallbacks:[]}}var Vte=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n={};return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools?.[i];if(t&&t!==a){let o=n[i];if(o===r)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);let s=o>r?t:a,c=o>r?a:t;e.tools[i]={...c,...s},n[i]=Math.max(o,r);continue}e.tools||={},e.tools[i]=a,n[i]??=r}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),e},{})},$N=class{_providers=new Set;getModelContext(){return Vte(this._providers)}registerModelContextProvider(e){this._providers.add(e);let t=e.subscribe?.(()=>{this.notifySubscribers()});return this.notifySubscribers(),()=>{this._providers.delete(e),t?.(),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){for(let e of this._subscribers)e()}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},eP=[],Hte={modelName:void 0,toolNames:eP},Ute=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),tP=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():eP,a=i.length?i:eP;return r===t.modelName&&Ute(a,t.toolNames)?t:{modelName:r,toolNames:a}},nP=PN(()=>{let e=Z(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new $N,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>tP(n,Hte),e[1]=r):r=e[1];let[i,a]=vN(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>tP(n,e)),n.subscribe(()=>{a(e=>tP(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),CN(o,s);let c;e[4]===i?c=e[5]:(c=()=>tP(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),Wte=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,Gte=(e,t)=>{if(!(t.status?.type===`running`||t.status?.type===`requires-action`)){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},Kte=e=>function(t){return Gte(e,t)},rP=Symbol(`assistant-ui.store.clientIndex`),qte=e=>e[rP],iP=ON([]),aP=()=>kN(iP),Jte=(e,t)=>{let n=Z(3),r=aP(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],OM(iP,i,t)},Yte=new Set([`$$typeof`,`nodeType`,`then`]),oP=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!Yte.has(e))return!1}},sP=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!1}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},cP=Symbol(`assistant-ui.store.getValue`),Xte=e=>{let t=e[cP];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},lP=new Map;function Zte(e){let t=lP.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[cP];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},lP.set(e,t)),t}var Qte=class extends sP{outputRef;index;boundFns;cachedReceiver;constructor(e,t){super(),this.outputRef=e,this.index=t}get(e,t,n){if(t===cP)return this.outputRef.current;if(t===rP)return this.index;let r=oP(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){this.cachedReceiver!==n&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=Zte(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===cP||t===rP||t in this.outputRef.current}},uP=e=>{let t=bN(null),n=aP().length,r=xN(()=>new Proxy({},new Qte(t,n)),[n]),i=Jte(r,function(){return XN(e)});return t.current||=i,CN(()=>{t.current=i}),{methods:r,state:i.getState?.(),key:e.key}},$te=PN(uP),dP=Symbol(`assistant-ui.store.proxiedAssistantState`),fP=e=>e===`on`||e===`subscribe`||typeof e==`symbol`,pP=e=>{class t extends sP{get(t,n){let r=oP(n,`AssistantState`);if(r!==!1)return r;let i=n;if(!fP(i))return Xte(e[i]())}ownKeys(){return Object.keys(e).filter(e=>!fP(e))}has(t,n){return!fP(n)&&n in e}}return new Proxy({},new t)},mP=e=>e[dP],hP=()=>()=>{},gP=e=>{let t=(()=>{throw Error(e)});return t.source=null,t.query=null,t},_P=new Proxy({},new class extends sP{get(e,t){if(t===`subscribe`||t===`on`)return hP;if(t===dP)return vP;let n=oP(t,`DefaultAssistantClient`);return n===!1?gP(`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`):n}ownKeys(){return[`subscribe`,`on`,dP]}has(e,t){return t===`subscribe`||t===`on`||t===dP}}),vP=pP(_P),yP=()=>new Proxy({},{get(e,t){let n=oP(t,`AssistantClient`);return n===!1?gP(`The current scope does not have a "${String(t)}" property.`):n}}),bP=ON(_P),xP=Symbol(`assistant-ui.store.useEffects`),SP=()=>{},CP=e=>e[xP]??SP,wP=()=>{"use no memo";return CN(CP(TP())),null},TP=()=>AN(bP),EP=({value:e,children:t})=>{"use no memo";return(0,J.jsxs)(bP.Provider,{value:e,children:[(0,J.jsx)(wP,{}),t]})},DP=e=>null,OP=PN(DP),kP=Symbol(`assistant-ui.transform-scopes`);function AP(e,t){let n=e;if(n[kP])throw Error(`transformScopes is already attached to this resource`);n[kP]=t}function jP(e){return e[kP]}var MP=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},NP=ON(null),PP=(e,t)=>OM(NP,e,t),FP=()=>{let e=kN(NP);if(!e)throw Error(`AssistantTapContext is not available`);return e},IP=()=>FP().clientRef,LP=()=>{let e=Z(3),{emit:t}=FP(),n=aP(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],TN(r)};function RP(e,t){let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(e.hook===DP||r.has(e.hook))continue;r.add(e.hook);let a=jP(e.hook);if(a){a(n,t),i=!0;break}}}let a={},o={};for(let[e,t]of Object.entries(n))t.hook===DP?o[e]=t:a[e]=t;return{rootClients:a,derivedClients:o}}var zP=e=>xN(()=>e,[...Object.entries(e).flat()]),BP=(e,t)=>{let n=Z(6),r;n[0]!==t||n[1]!==e?(r=RP(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2];let{rootClients:i,derivedClients:a}=r,o=zP(i),s=zP(a),c;return n[3]!==o||n[4]!==s?(c={rootClients:o,derivedClients:s},n[3]=o,n[4]=s,n[5]=c):c=n[5],c},VP=PN(()=>{let e=Z(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Map,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Set,e[1]=r):r=e[1];let i=r,a;if(e[2]===Symbol.for(`react.memo_cache_sentinel`)){let t=new Set;a={on(e,t){let r=t;if(e===`*`)return i.add(r),()=>i.delete(r);let a=n.get(e);return a||(a=new Set,n.set(e,a)),a.add(r),()=>{a.delete(r),a.size===0&&n.delete(e)}},emit(e,t,r){let a=n.get(e);!a&&i.size===0||queueMicrotask(()=>{let n=[];if(a)for(let e of a)try{e(t,r)}catch(e){let t=e;n.push(t)}if(i.size>0){let a={event:e,payload:t};for(let e of i)try{e(a,r)}catch(e){let t=e;n.push(t)}}if(n.length>0){if(n.length===1)throw n[0];for(let e of n)console.error(e);throw AggregateError(n,`Errors occurred during event emission`)}})},subscribe(e){return t.add(e),()=>t.delete(e)},notifySubscribers(){for(let e of t)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}},e[2]=a}else a=e[2];return a}),HP=e=>xN(()=>e,e),UP=({element:e,emit:t,clientRef:n})=>{let{methods:r,state:i}=PP({clientRef:n,emit:t},function(){return uP(e)});return xN(()=>({state:i,methods:r}),[r,i])},WP=PN(({element:e,notifications:t,clientRef:n,name:r})=>{let i=Mte(function(){return UP({element:e,emit:t.emit,clientRef:n})});return CN(()=>i.subscribe(t.notifySubscribers),[i,t]),xN(()=>{let e=()=>i.getValue().methods;return Object.defineProperties(e,{source:{value:`root`,writable:!1},query:{value:{},writable:!1},name:{value:r,configurable:!0}}),e},[i,r])}),GP=PN(()=>{let e=Z(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=[],e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n={clients:t,subscribe:void 0,on:void 0},e[1]=n):n=e[1],n}),KP=e=>{let t=Z(14),{clients:n,clientRef:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=VP(),t[0]=i):i=t[0];let a=XN(i),o;t[1]!==r.parent||t[2]!==a.notifySubscribers?(o=()=>r.parent.subscribe(a.notifySubscribers),t[1]=r.parent,t[2]=a.notifySubscribers,t[3]=o):o=t[3];let s;t[4]!==r||t[5]!==a?(s=[r,a],t[4]=r,t[5]=a,t[6]=s):s=t[6],CN(o,s);let c;t[7]!==r||t[8]!==n||t[9]!==a?(c=Object.keys(n).map(e=>FN(e,WP({element:n[e],notifications:a,clientRef:r,name:e}))),t[7]=r,t[8]=n,t[9]=a,t[10]=c):c=t[10];let l=HP(QN(c)),u;return t[11]!==a||t[12]!==l?(u={notifications:a,results:l},t[11]=a,t[12]=l,t[13]=u):u=t[13],u},qP=PN(e=>{let{clientRef:t}=e,{notifications:n,results:r}=KP(e);return xN(()=>({clients:r,subscribe:n.subscribe,on:function(e,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=MP(e);if(i!==`*`&&this[i].source===null)throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let o=n.on(a,(e,t)=>{if(i===`*`){r(e);return}let n=this[i]();n===t[qte(n)]&&r(e)});if(i!==`*`&&t.parent[i].source===null)return o;let s=t.parent.on(e,r);return()=>{o(),s()}}}),[r,n,t])}),JP=PN(({element:e,clientRef:t,name:n})=>{let r=bN(e.args[0]);return r.current=e.args[0],xN(()=>{let e=()=>r.current.get(t.current);return Object.defineProperties(e,{source:{value:r.current.source},query:{value:r.current.query},name:{value:n,configurable:!0}}),e},[t,n])}),YP=(e,t)=>{let n;try{let e={};for(let n of Object.keys(t.query).sort())e[n]=t.query[n];n=JSON.stringify(e)}catch{n=String(t.query)}return`${e}::${t.source}::${n}`},XP=e=>{let t=Z(3),{clients:n,clientRef:r}=e,i;return t[0]!==r||t[1]!==n?(i=Object.keys(n).map(e=>{let t=e,i=n[t];return FN(YP(t,i.args[0]),JP({element:i,clientRef:r,name:t}))}),t[0]=r,t[1]=n,t[2]=i):i=t[2],HP(QN(i))},ZP=e=>{let t=Z(3),{rootClients:n,clientRef:r}=e,i;return t[0]!==r||t[1]!==n?(i=Object.keys(n).length>0?qP({clients:n,clientRef:r}):GP(),t[0]=r,t[1]=n,t[2]=i):i=t[2],XN(i)},QP=({parent:e,clients:t})=>{let{rootClients:n,derivedClients:r}=BP(t,e),i=bN({parent:e,current:null}).current;CN(()=>{i.current=s});let a=ZP({rootClients:n,clientRef:i}),o=XP({clients:r,clientRef:i}),s=xN(()=>{let t=e===_P?yP():e,n=Object.create(t);Object.assign(n,{subscribe:a.subscribe??e.subscribe,on:a.on??e.on,[dP]:pP(n)});for(let e of a.clients)n[e.name]=e;for(let e of o)n[e.name]=e;return n},[e,a,o]);return i.current===null&&(i.current=s),s},$P=e=>{let{value:t,effects:n}=Rte(function(){return QP(e)});return t[xP]=n,t};function eF(e,{parent:t}={parent:TP()}){if(e)return $P({parent:t??_P,clients:e});if(t===null)throw Error(`received null parent, this usage is not allowed`);return t}var Q=e=>{let t=Z(6),n=eF(),r;t[0]===n?r=t[1]:(r=mP(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=EN(n.subscribe,a,o);if(s===i)throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return DN(s),s},tF=e=>{let t=eF(),n=bN(!1),r=n.current?null:e(t);return Q(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},nF=Object.freeze({});function rF(e){let t=Z(3),{getItemState:n,children:r}=e,i=tF(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],iF(a)}var iF=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return xN(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?nF:t?.props])??e},aF=q.createContext(!0);function oF(){throw Error(`A function wrapped in useEffectEvent can't be called during rendering.`)}var sF=`use`in q.default?()=>{try{return q.use(aF)}catch{return!1}}:()=>!1;function cF(e){let t=q.useRef(oF);return q.useInsertionEffect(()=>{t.current=e},[e]),(...e)=>{sF()&&oF();let n=t.current;return n(...e)}}var lF=(e,t)=>{let n=Z(11),r=eF(),i=cF(t),a;n[0]===e?a=n[1]:(a=MP(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],CN(c,l)},uF=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function dF(e){let t=Z(15),n;t[0]===e?n=t[1]:(n=e.map(mF),t[0]=e,t[1]=n);let r=QN(n),i;t[2]===r?i=t[3]:(i=Object.keys(r),t[2]=r,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.reduce(pF,{}),t[4]=r,t[5]=o);let s=o,c;t[6]===r?c=t[7]:(c=r.map(fF),t[6]=r,t[7]=c);let l=c,u;t[8]!==s||t[9]!==a||t[10]!==r?(u=e=>{if(`index`in e){if(e.index<0||e.index>=a.length)throw Error(`useClientLookup: Index ${e.index} out of bounds (length: ${a.length})`);return r[e.index].methods}let t=s[e.key];if(t===void 0)throw Error(`useClientLookup: Key "${e.key}" not found`);return r[t].methods},t[8]=s,t[9]=a,t[10]=r,t[11]=u):u=t[11];let d;return t[12]!==l||t[13]!==u?(d={state:l,get:u},t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function fF(e){return e.state}function pF(e,t,n){return e[t.key]=n,e}function mF(e){return FN(uF(e),$te(e),e.deps)}var hF=e=>{let t=Z(15),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[FN(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=QN(i)[0],[o,s]=vN(_F),c;t[2]===o?c=t[3]:(c=Object.fromEntries(Object.entries(o).map(yF)),t[2]=o,t[3]=c);let l;t[4]!==a||t[5]!==c||t[6]!==o?(l={toolUIs:o,mcpApp:a,tools:c},t[4]=a,t[5]=c,t[6]=o,t[7]=l):l=t[7];let u=l,d=IP(),f;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(f=(e,t,n)=>{let r={render:t,standalone:n?.standalone??!1};return s(t=>({...t,[e]:[...t[e]??[],r]})),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[];if(n.length>0)return{...t,[e]:n};let i={...t};return delete i[e],i})}},t[8]=f):f=t[8];let p=f,m,h;t[9]!==d||t[10]!==n?(m=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?Kte(i):void 0);a&&e.push(p(t,a,{standalone:Wte(r)}))}let t=Object.entries(n).reduce(bF,{});return e.push(d.current.modelContext().register({getModelContext:()=>({tools:t})})),()=>{e.forEach(xF)}},h=[n,p,d],t[9]=d,t[10]=n,t[11]=m,t[12]=h):(m=t[11],h=t[12]),CN(m,h);let g;return t[13]===u?g=t[14]:(g={getState:()=>u,setToolUI:p},t[13]=u,t[14]=g),g},gF=PN(hF);AP(hF,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=nP())});function _F(){return{}}function vF(e){return e.render}function yF(e){let[t,n]=e;return[t,n.map(vF)]}function bF(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}function xF(e){return e()}var SF=e=>EN(e.subscribe,e.getState),CF=PN(e=>{let t=Z(8),{runtime:n}=e,r=SF(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;return t[4]!==n.remove||t[5]!==i||t[6]!==a?(o={getState:i,remove:n.remove,__internal_getRuntime:a},t[4]=n.remove,t[5]=i,t[6]=a,t[7]=o):o=t[7],o}),wF=PN(e=>{let t=Z(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=CF({runtime:a}),t[3]=a,t[4]=o),XN(o)}),TF=PN(({item:e,onSteer:t,onRemove:n})=>({getState:()=>e,steer:t,remove:n})),EF=PN(e=>{let t=Z(55),{threadIdRef:n,messageIdRef:r,runtime:i}=e,a=SF(i),o=LP(),s,c;t[0]!==o||t[1]!==r||t[2]!==i||t[3]!==n?(s=()=>{let e=[];for(let t of[`send`,`attachmentAdd`]){let a=i.unstable_on(t,()=>{o(`composer.${t}`,{threadId:n.current,...r&&{messageId:r.current}})});e.push(a)}return e.push(i.unstable_on(`attachmentAddError`,e=>{o(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message})})),()=>{for(let t of e)t()}},c=[i,o,n,r],t[0]=o,t[1]=r,t[2]=i,t[3]=n,t[4]=s,t[5]=c):(s=t[4],c=t[5]),CN(s,c);let l;if(t[6]!==i||t[7]!==a.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>FN(e.id,wF({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),l=a.attachments.map(e),t[6]=i,t[7]=a.attachments,t[8]=l}else l=t[8];let u=dF(l),d=a.queue,f;if(t[11]!==d||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>FN(e.id,TF({item:e,onSteer:()=>i.steerQueueItem(e.id),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),f=d.map(e),t[11]=d,t[12]=i,t[13]=f}else f=t[13];let p=dF(f),m=a.type??`thread`,h;t[16]!==u.state||t[17]!==d||t[18]!==a.attachmentAccept||t[19]!==a.canCancel||t[20]!==a.canSend||t[21]!==a.dictation||t[22]!==a.isEditing||t[23]!==a.isEmpty||t[24]!==a.quote||t[25]!==a.role||t[26]!==a.runConfig||t[27]!==a.text||t[28]!==m?(h={text:a.text,role:a.role,attachments:u.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,canSend:a.canSend,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:m,dictation:a.dictation,quote:a.quote,queue:d},t[16]=u.state,t[17]=d,t[18]=a.attachmentAccept,t[19]=a.canCancel,t[20]=a.canSend,t[21]=a.dictation,t[22]=a.isEditing,t[23]=a.isEmpty,t[24]=a.quote,t[25]=a.role,t[26]=a.runConfig,t[27]=a.text,t[28]=m,t[29]=h):h=t[29];let g=h,_;t[30]===g?_=t[31]:(_=()=>g,t[30]=g,t[31]=_);let v=i.beginEdit??DF,y;t[32]===u?y=t[33]:(y=e=>`id`in e?u.get({key:e.id}):u.get(e),t[32]=u,t[33]=y);let b;t[34]===p?b=t[35]:(b=e=>p.get(e),t[34]=p,t[35]=b);let x;t[36]===i?x=t[37]:(x=()=>i,t[36]=i,t[37]=x);let S;return t[38]!==i.addAttachment||t[39]!==i.cancel||t[40]!==i.clearAttachments||t[41]!==i.reset||t[42]!==i.send||t[43]!==i.setQuote||t[44]!==i.setRole||t[45]!==i.setRunConfig||t[46]!==i.setText||t[47]!==i.startDictation||t[48]!==i.stopDictation||t[49]!==b||t[50]!==x||t[51]!==_||t[52]!==v||t[53]!==y?(S={getState:_,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:i.send,cancel:i.cancel,beginEdit:v,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:y,queueItem:b,__internal_getRuntime:x},t[38]=i.addAttachment,t[39]=i.cancel,t[40]=i.clearAttachments,t[41]=i.reset,t[42]=i.send,t[43]=i.setQuote,t[44]=i.setRole,t[45]=i.setRunConfig,t[46]=i.setText,t[47]=i.startDictation,t[48]=i.stopDictation,t[49]=b,t[50]=x,t[51]=_,t[52]=v,t[53]=y,t[54]=S):S=t[54],S});function DF(){throw Error(`beginEdit is not supported in this runtime`)}var OF=e=>({get current(){return e()}}),kF=PN(e=>{let t=Z(13),{runtime:n}=e,r=SF(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),AF=PN(e=>{let t=Z(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=CF({runtime:a}),t[3]=a,t[4]=o),XN(o)}),jF=PN(e=>{let t=Z(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=kF({runtime:a}),t[3]=a,t[4]=o),XN(o)}),MF=PN(e=>{let t=Z(55),{runtime:n,threadIdRef:r}=e,i=SF(n),[a,o]=vN(!1),[s,c]=vN(!1),l;t[0]===n?l=t[1]:(l=OF(()=>n.getState().id),t[0]=n,t[1]=l);let u=l,d;t[2]!==u||t[3]!==n.composer||t[4]!==r?(d=EF({runtime:n.composer,threadIdRef:r,messageIdRef:u}),t[2]=u,t[3]=n.composer,t[4]=r,t[5]=d):d=t[5];let f=uP(d),p;if(t[6]!==n||t[7]!==i.content){let e;t[9]===n?e=t[10]:(e=(e,t)=>FN(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,jF({runtime:n,index:t}),[n,t]),t[9]=n,t[10]=e),p=i.content.map(e),t[6]=n,t[7]=i.content,t[8]=p}else p=t[8];let m=dF(p),h;t[11]===i.attachments?h=t[12]:(h=i.attachments??[],t[11]=i.attachments,t[12]=h);let g;if(t[13]!==n||t[14]!==h){let e;t[16]===n?e=t[17]:(e=(e,t)=>FN(e.id,AF({runtime:n,index:t}),[n,t]),t[16]=n,t[17]=e),g=h.map(e),t[13]=n,t[14]=h,t[15]=g}else g=t[15];let _=dF(g),v=i,y;t[18]!==f.state||t[19]!==a||t[20]!==s||t[21]!==m.state||t[22]!==v?(y={...v,parts:m.state,composer:f.state,isCopied:a,isHovering:s},t[18]=f.state,t[19]=a,t[20]=s,t[21]=m.state,t[22]=v,t[23]=y):y=t[23];let b=y,x;t[24]===b?x=t[25]:(x=()=>b,t[24]=b,t[25]=x);let S;t[26]===f.methods?S=t[27]:(S=()=>f.methods,t[26]=f.methods,t[27]=S);let C,w,T,E,D,O,k;t[28]===n?(C=t[29],w=t[30],T=t[31],E=t[32],D=t[33],O=t[34],k=t[35]):(C=()=>n.delete(),w=e=>n.reload(e),T=()=>n.speak(),E=()=>n.stopSpeaking(),D=e=>n.submitFeedback(e),O=e=>n.switchToBranch(e),k=()=>n.unstable_getCopyText(),t[28]=n,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D,t[34]=O,t[35]=k);let A;t[36]===m?A=t[37]:(A=e=>`index`in e?m.get({index:e.index}):m.get({key:`toolCallId-${e.toolCallId}`}),t[36]=m,t[37]=A);let j;t[38]===_?j=t[39]:(j=e=>`id`in e?_.get({key:e.id}):_.get(e),t[38]=_,t[39]=j);let M;t[40]===n?M=t[41]:(M=()=>n,t[40]=n,t[41]=M);let N;return t[42]!==C||t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A||t[50]!==j||t[51]!==M||t[52]!==x||t[53]!==S?(N={getState:x,composer:S,delete:C,reload:w,speak:T,stopSpeaking:E,submitFeedback:D,switchToBranch:O,getCopyText:k,part:A,attachment:j,setIsCopied:o,setIsHovering:c,__internal_getRuntime:M},t[42]=C,t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j,t[51]=M,t[52]=x,t[53]=S,t[54]=N):N=t[54],N}),NF=PN(e=>{let t=Z(6),{runtime:n,id:r,threadIdRef:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==o||t[4]!==i?(s=MF({runtime:o,threadIdRef:i}),t[3]=o,t[4]=i,t[5]=s):s=t[5],XN(s)}),PF=PN(e=>{let t=Z(58),{runtime:n}=e,r=SF(n),i=LP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),CN(a,o);let s;t[4]===n?s=t[5]:(s=OF(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==n.composer||t[7]!==c?(l=EF({runtime:n.composer,threadIdRef:c}),t[6]=n.composer,t[7]=c,t[8]=l):l=t[8];let u=uP(l),d;if(t[9]!==n||t[10]!==r.messages||t[11]!==c){let e;t[13]!==n||t[14]!==c?(e=e=>FN(e.id,NF({runtime:n,id:e.id,threadIdRef:c}),[n,e.id,c]),t[13]=n,t[14]=c,t[15]=e):e=t[15],d=r.messages.map(e),t[9]=n,t[10]=r.messages,t[11]=c,t[12]=d}else d=t[12];let f=dF(d),p=f.state.length===0&&!r.isLoading,m;t[16]!==u.state||t[17]!==f.state||t[18]!==r.capabilities||t[19]!==r.extras||t[20]!==r.isDisabled||t[21]!==r.isLoading||t[22]!==r.isRunning||t[23]!==r.speech||t[24]!==r.state||t[25]!==r.suggestions||t[26]!==r.voice||t[27]!==p?(m={isEmpty:p,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:u.state,messages:f.state},t[16]=u.state,t[17]=f.state,t[18]=r.capabilities,t[19]=r.extras,t[20]=r.isDisabled,t[21]=r.isLoading,t[22]=r.isRunning,t[23]=r.speech,t[24]=r.state,t[25]=r.suggestions,t[26]=r.voice,t[27]=p,t[28]=m):m=t[28];let h=m,g;t[29]===h?g=t[30]:(g=()=>h,t[29]=h,t[30]=g);let _;t[31]===u.methods?_=t[32]:(_=()=>u.methods,t[31]=u.methods,t[32]=_);let v;t[33]===f?v=t[34]:(v=e=>`id`in e?f.get({key:e.id}):f.get(e),t[33]=f,t[34]=v);let y;t[35]===n?y=t[36]:(y=()=>n,t[35]=n,t[36]=y);let b;return t[37]!==n.append||t[38]!==n.cancelRun||t[39]!==n.connectVoice||t[40]!==n.deleteMessage||t[41]!==n.disconnectVoice||t[42]!==n.export||t[43]!==n.getModelContext||t[44]!==n.getVoiceVolume||t[45]!==n.import||t[46]!==n.muteVoice||t[47]!==n.reset||t[48]!==n.resumeRun||t[49]!==n.startRun||t[50]!==n.stopSpeaking||t[51]!==n.subscribeVoiceVolume||t[52]!==n.unmuteVoice||t[53]!==v||t[54]!==y||t[55]!==g||t[56]!==_?(b={getState:g,composer:_,append:n.append,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:n.connectVoice,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:v,__internal_getRuntime:y},t[37]=n.append,t[38]=n.cancelRun,t[39]=n.connectVoice,t[40]=n.deleteMessage,t[41]=n.disconnectVoice,t[42]=n.export,t[43]=n.getModelContext,t[44]=n.getVoiceVolume,t[45]=n.import,t[46]=n.muteVoice,t[47]=n.reset,t[48]=n.resumeRun,t[49]=n.startRun,t[50]=n.stopSpeaking,t[51]=n.subscribeVoiceVolume,t[52]=n.unmuteVoice,t[53]=v,t[54]=y,t[55]=g,t[56]=_,t[57]=b):b=t[57],b}),FF=PN(e=>{let t=Z(20),{runtime:n}=e,r=SF(n),i=LP(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`switchedTo`,`switchedAway`]){let r=n.unstable_on(t,()=>{i(`threadListItem.${t}`,{threadId:n.getState().id})});e.push(r)}return()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),CN(a,o);let s;t[4]===r?s=t[5]:(s=()=>r,t[4]=r,t[5]=s);let c;t[6]===n?c=t[7]:(c=()=>n,t[6]=n,t[7]=c);let l;return t[8]!==n.archive||t[9]!==n.delete||t[10]!==n.detach||t[11]!==n.generateTitle||t[12]!==n.initialize||t[13]!==n.rename||t[14]!==n.switchTo||t[15]!==n.unarchive||t[16]!==n.updateCustom||t[17]!==s||t[18]!==c?(l={getState:s,switchTo:n.switchTo,rename:n.rename,updateCustom:n.updateCustom,archive:n.archive,unarchive:n.unarchive,delete:n.delete,generateTitle:n.generateTitle,initialize:n.initialize,detach:n.detach,__internal_getRuntime:c},t[8]=n.archive,t[9]=n.delete,t[10]=n.detach,t[11]=n.generateTitle,t[12]=n.initialize,t[13]=n.rename,t[14]=n.switchTo,t[15]=n.unarchive,t[16]=n.updateCustom,t[17]=s,t[18]=c,t[19]=l):l=t[19],l}),IF=PN(e=>{let t=Z(5),{runtime:n,id:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getItemById(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=FF({runtime:a}),t[3]=a,t[4]=o),XN(o)}),LF=PN(e=>{let t=Z(40),{runtime:n,__internal_assistantRuntime:r}=e,i=SF(n),a;t[0]===n.main?a=t[1]:(a=PF({runtime:n.main}),t[0]=n.main,t[1]=a);let o=uP(a),s;t[2]!==n||t[3]!==i.threadItems?(s=Object.keys(i.threadItems).map(e=>FN(e,IF({runtime:n,id:e}),[n,e])),t[2]=n,t[3]=i.threadItems,t[4]=s):s=t[4];let c=dF(s),l=i.newThreadId??null,u;t[5]!==o.state||t[6]!==i.archivedThreadIds||t[7]!==i.hasMore||t[8]!==i.isLoading||t[9]!==i.isLoadingMore||t[10]!==i.mainThreadId||t[11]!==i.threadIds||t[12]!==l||t[13]!==c.state?(u={mainThreadId:i.mainThreadId,newThreadId:l,isLoading:i.isLoading,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:c.state,main:o.state},t[5]=o.state,t[6]=i.archivedThreadIds,t[7]=i.hasMore,t[8]=i.isLoading,t[9]=i.isLoadingMore,t[10]=i.mainThreadId,t[11]=i.threadIds,t[12]=l,t[13]=c.state,t[14]=u):u=t[14];let d=u,f;t[15]===d?f=t[16]:(f=()=>d,t[15]=d,t[16]=f);let p;t[17]===o.methods?p=t[18]:(p=()=>o.methods,t[17]=o.methods,t[18]=p);let m;t[19]!==d||t[20]!==c?(m=e=>{if(e===`main`)return c.get({key:d.mainThreadId});if(`id`in e)return c.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?d.archivedThreadIds[t]:d.threadIds[t];return c.get({key:r})},t[19]=d,t[20]=c,t[21]=m):m=t[21];let h,g,_,v,y;t[22]===n?(h=t[23],g=t[24],_=t[25],v=t[26],y=t[27]):(v=async(e,t)=>{await n.switchToThread(e,t)},y=async()=>{await n.switchToNewThread()},h=()=>n.getLoadThreadsPromise(),g=()=>n.reload(),_=()=>n.loadMore(),t[22]=n,t[23]=h,t[24]=g,t[25]=_,t[26]=v,t[27]=y);let b;t[28]===r?b=t[29]:(b=()=>r,t[28]=r,t[29]=b);let x;return t[30]!==h||t[31]!==g||t[32]!==_||t[33]!==b||t[34]!==f||t[35]!==p||t[36]!==m||t[37]!==v||t[38]!==y?(x={getState:f,thread:p,item:m,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:h,reload:g,loadMore:_,__internal_getAssistantRuntime:b},t[30]=h,t[31]=g,t[32]=_,t[33]=b,t[34]=f,t[35]=p,t[36]=m,t[37]=v,t[38]=y,t[39]=x):x=t[39],x}),RF=PN(e=>({getState:()=>e})),zF=PN(e=>{let t=Z(11),n;t[0]===e?n=t[1]:(n=()=>({suggestions:(e??[]).map(BF)}),t[0]=e,t[1]=n);let[r]=vN(n),i;t[2]===r.suggestions?i=t[3]:(i=r.suggestions.map(VF),t[2]=r.suggestions,t[3]=i);let a=dF(i),o;t[4]===r?o=t[5]:(o=()=>r,t[4]=r,t[5]=o);let s;t[6]===a?s=t[7]:(s=e=>{let{index:t}=e;return a.get({index:t})},t[6]=a,t[7]=s);let c;return t[8]!==o||t[9]!==s?(c={getState:o,suggestion:s},t[8]=o,t[9]=s,t[10]=c):c=t[10],c});function BF(e){return typeof e==`string`?{title:e,label:``,prompt:e}:{title:e.title,label:e.label,prompt:e.prompt}}function VF(e,t){return FN(t,RF(e),[e])}var HF=(e,t)=>{e.thread??=OP({source:`threads`,query:{type:`main`},get:e=>e.threads().thread(`main`)}),e.threadListItem??=OP({source:`threads`,query:{type:`main`},get:e=>e.threads().item(`main`)}),e.composer??=OP({source:`thread`,query:{},get:e=>e.threads().thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=nP()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=zF())},UF=e=>{let t=Z(6),n=IP(),r,i;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),i=[e,n],t[0]=n,t[1]=e,t[2]=r,t[3]=i):(r=t[2],i=t[3]),CN(r,i);let a;return t[4]===e?a=t[5]:(a=LF({runtime:e.threads,__internal_assistantRuntime:e}),t[4]=e,t[5]=a),XN(a)},WF=PN(UF);AP(UF,(e,t)=>{HF(e,t),!e.tools&&t.tools.source===null&&(e.tools=gF({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=zte())});var GF=e=>e._core?.RenderComponent,KF=(0,X.memo)(({runtime:e,aui:t=null,children:n})=>{"use no memo";let r=eF({threads:WF(e)},{parent:t}),i=GF(e),a=(0,J.jsxs)(EP,{value:r,children:[i&&(0,J.jsx)(i,{}),n]});return t?(0,J.jsx)(EP,{value:t,children:a}):a}),qF=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},JF=(e=>e?qF(e):qF),YF=e=>e;function XF(e,t=YF){let n=q.useSyncExternalStore(e.subscribe,q.useCallback(()=>t(e.getState()),[e,t]),q.useCallback(()=>t(e.getInitialState()),[e,t]));return q.useDebugValue(n),n}var ZF=e=>{let t=JF(e),n=e=>XF(t,e);return Object.assign(n,t),n},QF=(e=>e?ZF(e):ZF),$F=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},eI=()=>{let e=[],t=!1,n,r,i=i=>{i.promise||=i.reader.read().then(({done:a,value:o})=>{i.promise=void 0,a?(e.splice(e.indexOf(i),1),t&&e.length===0&&n.close()):n.enqueue(o),r?.resolve(),r=void 0}).catch(t=>{console.error(t),e.forEach(e=>{e.reader.cancel()}),e.length=0,n.error(t),r?.reject(t),r=void 0})};return{readable:new ReadableStream({start(e){n=e},pull(){return r=$F(),e.forEach(e=>{i(e)}),r.promise},cancel(){e.forEach(e=>{e.reader.cancel()}),e.length=0}}),isSealed(){return t},seal(){t=!0,e.length===0&&n.close()},addStream(n){if(t)throw Error(`Cannot add streams after the run callback has settled.`);let r={reader:n.getReader()};e.push(r),i(r)},enqueue(e){this.addStream(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}}},tI=class{_controller;_isClosed=!1;constructor(e){this._controller=e}append(e){return this._controller.enqueue({type:`text-delta`,path:[],textDelta:e}),this}close(){this._isClosed||(this._isClosed=!0,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},nI=e=>new ReadableStream({start(t){return e.start?.(new tI(t))},pull(t){return e.pull?.(new tI(t))},cancel(t){return e.cancel?.(t)}}),rI=()=>{let e;return[nI({start(t){e=t}}),e]},iI=class{_controller;_isClosed=!1;_mergeTask;constructor(e){this._controller=e;let t=nI({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,this._controller.enqueue(e);break;case`part-finish`:n||this._controller.enqueue({type:`text-delta`,textDelta:`{}`,path:[]}),this._controller.enqueue({type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){this._argsTextController.close(),await Promise.resolve(),this._controller.enqueue({type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:e.result,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}})}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,this._controller.enqueue({type:`part-finish`,path:[]}),this._controller.close())}},aI=e=>new ReadableStream({start(t){return e.start?.(new iI(t))},pull(t){return e.pull?.(new iI(t))},cancel(t){return e.cancel?.(t)}}),oI=()=>{let e;return[aI({start(t){e=t}}),e]},sI=class{value=-1;up(){return++this.value}},cI=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var lI=class extends TransformStream{constructor(e){let t=new sI,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},uI=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},dI=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},fI=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},pI=fI(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),mI=class e{_state;_parentId;constructor(e){this._state=e||{merger:eI(),contentCounter:new sI}}get __internal_isClosed(){return this._state.merger.isSealed()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._state.merger.addStream(t.pipeThrough(new cI(this._state.contentCounter.value)))}merge(e){this._state.merger.addStream(e.pipeThrough(new lI(this._state.contentCounter)))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e){(this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart()}),this._state.append.controller.append(e)}addTextPart(){let[e,t]=rI();return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(){let[e,t]=rI();return this._addPart(this._withParentIdOption({type:`reasoning`}),e),t}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??pI(),[i,a]=oI();return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function hI(e){let t=new mI;return(async()=>{try{await e(t)}catch(e){throw t.__internal_isClosed||t.enqueue({type:`error`,path:[],error:String(e)}),e}finally{t.__internal_isClosed||t.close()}})(),t.__internal_getReadable()}function gI(){let{resolve:e,promise:t}=$F(),n;return[hI(r=>(n=r,n.__internal_subscribeToClose(e),t)),n]}function _I(e){let t=[`ROOT`],n=-1,r=null,i=[],a;function o(){a!==void 0&&(i.push(JSON.parse(`"${a}"`)),a=void 0)}function s(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),o();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),o();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),o();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),o();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),o();break}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),a=i.pop();break}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=r,t.pop(),a=i.pop();break}}for(let o=0;o<e.length;o++){let u=e[o];switch(t[t.length-1]){case`ROOT`:s(u,o,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break;case`}`:n=o,t.pop(),a=i.pop();break}break;case`INSIDE_OBJECT_AFTER_COMMA`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),a=``;break}break;case`INSIDE_OBJECT_KEY`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),a+=u;break;default:a+=u;break}break;case`INSIDE_OBJECT_AFTER_KEY`:switch(u){case`:`:t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`);break}break;case`INSIDE_OBJECT_BEFORE_VALUE`:s(u,o,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:c(u,o);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=o,a=i.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=o}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=o,t.pop(),a=i.pop();break;default:n=o,a=`0`,s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),a=(Number(a)+1).toString();break;case`]`:n=o,t.pop(),a=i.pop();break;default:n=o;break}break;case`INSIDE_ARRAY_AFTER_COMMA`:s(u,o,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),t[t.length-1]===`INSIDE_STRING`?n=o:t[t.length-1]===`INSIDE_OBJECT_KEY`&&(a+=u);break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=o;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`}`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&c(u,o);break;case`]`:t.pop(),a=i.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o);break;default:t.pop(),a=i.pop();break}break;case`INSIDE_LITERAL`:{let i=e.substring(r,o+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?c(u,o):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&l(u,o)):n=o;break}}}let u=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:u+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:u+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:u+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?u+=`true`.slice(t.length):`false`.startsWith(t)?u+=`false`.slice(t.length):`null`.startsWith(t)&&(u+=`null`.slice(t.length))}}return[u,i]}var vI=r(i(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o}))(),1),yI=Symbol(`aui.parse-partial-json-object.meta`),bI=e=>e?.[yI],xI=e=>{if(e.length===0)return{[yI]:{state:`partial`,partialPath:[]}};try{let t=vI.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[yI]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=_I(e),r=vI.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[yI]={state:`partial`,partialPath:n},r}catch{return}}},SI=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return SI(s,{state:`partial`,partialPath:o},i)},CI=(e,t)=>{let n=bI(e);if(!n)throw Error(`unable to determine object state`);return SI(e,n,t.map(String))};async function*wI(){let e=this.getReader();try{for(;;){let{done:t,value:n}=await e.read();if(t)break;yield n}}finally{e.releaseLock()}}function TI(e){return e[Symbol.asyncIterator]??=wI,e}var EI=Symbol.for(`aui.tool-response`),DI=class e{get[EI](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact),this.result=e.result,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&EI in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?`<no result>`:t})}};function OI(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function kI(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var AI=class{resolve;reject;disposed=!1;fieldPath;constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(CI(e,this.fieldPath)===`complete`){let t=kI(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=kI(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},jI=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=kI(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),CI(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},MI=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=kI(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}CI(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},NI=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=kI(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||CI(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));CI(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},PI=class{argTextDeltas;handles=new Set;args=xI(``);finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=``,t=this.argTextDeltas.getReader();for(;;){let{value:n,done:r}=await t.read();if(r)break;e+=n;let i=xI(e);if(i!==void 0){this.args=i;for(let e of this.handles)e.update(i)}}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{let r=new AI(t,n,e);if(this.args&&CI(this.args,e)===`complete`){let n=kI(this.args,e);if(n!==void 0){t(n);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){let t=e,n;return TI(new ReadableStream({start:e=>{n=new jI(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return TI(new ReadableStream({start:e=>{n=new MI(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return TI(new ReadableStream({start:e=>{n=new NI(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},FI=class{promise;constructor(e){this.promise=e}get(){return this.promise}},II=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new PI(e.readable);let{promise:t,resolve:n}=$F();this.resolve=n,this.response=new FI(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},LI=class extends uI{constructor(e){let t=new Map,n=new Map;super(r=>{let i=new TransformStream({async transform(r,i){switch((r.type!==`part-finish`||r.meta.type!==`tool-call`)&&i.enqueue(r),r.type){case`part-start`:if(r.part.type===`tool-call`){let t=new II;n.set(r.part.toolCallId,t),e.streamCall({reader:t,toolCallId:r.part.toolCallId,toolName:r.part.toolName})}break;case`text-delta`:if(r.meta.type===`tool-call`){let e=r.meta.toolCallId,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);await t.appendArgsTextDelta(r.textDelta)}break;case`result`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,t=n.get(e);if(!t)throw Error(`No controller found for tool call`);t.setResponse(new DI({result:r.result,artifact:r.artifact,isError:r.isError,modelContent:r.modelContent}));break}case`tool-call-args-text-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:a,toolName:o}=r.meta,s=n.get(a);if(!s)throw Error(`No controller found for tool call`);await s.finishArgsText();let c=!1,l=OI(()=>{let t;try{t=vI.default.parse(s.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=e.execute({toolCallId:a,toolName:o,args:t});return n!==void 0&&(c=!0,e.onExecutionStart?.(a,o)),n},t=>{if(c&&e.onExecutionEnd?.(a,o),t===void 0)return;let n=new DI({artifact:t.artifact,result:t.result,isError:t.isError,messages:t.messages,modelContent:t.modelContent});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})},t=>{c&&e.onExecutionEnd?.(a,o);let n=new DI({result:String(t),isError:!0});s.setResponse(n),i.enqueue({type:`result`,path:r.path,...n})});l&&t.set(a,l);break}case`part-finish`:{if(r.meta.type!==`tool-call`)break;let{toolCallId:e}=r.meta,a=t.get(e);a?a.then(()=>{t.delete(e),n.delete(e),i.enqueue(r)}):i.enqueue(r)}}},async flush(){await Promise.all(t.values())}});return r.pipeThrough(new dI).pipeThrough(i)})}},RI=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1;function zI(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new DI({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(RI(i.parameters)){let e=i.parameters[`~standard`].validate(n.args);e instanceof Promise&&(e=await e),e.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(e.issues)}`)}))}let o=new Promise(e=>{let n=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new DI({result:`Tool execution was cancelled.`,isError:!0}))})})};t.aborted?n():t.addEventListener(`abort`,n,{once:!0})}),s=(async()=>{let e=await a(n.args,{toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e)}),o=DI.toResponse(e);if(i.toModelOutput&&!o.isError&&o.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:o.result});return new DI({result:o.result,artifact:o.artifact,isError:o.isError,messages:o.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return o})();return Promise.race([s,o])})(i.execute):void 0}function BI(e,t,n,r,i){e?.[r.toolName]?.streamCall?.(n,{toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e)})}function VI(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t;return new LI({execute:e=>zI(i(),a(),e,n),streamCall:({reader:e,...t})=>BI(i(),a(),e,t,n),onExecutionStart:r?.onExecutionStart,onExecutionEnd:r?.onExecutionEnd})}var HI=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=OP({source:`message`,query:{type:`index`,index:n},get:e=>e.message().attachment({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={attachment:i},t[2]=i,t[3]=a);let o=eF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(EP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},UI=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=OP({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer().attachment({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={attachment:i},t[2]=i,t[3]=a);let o=eF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(EP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},WI=e=>{let t=Z(10),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=OP({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread().message({index:n})}),t[0]=n,t[1]=i);let a;t[2]===n?a=t[3]:(a=OP({source:`message`,query:{},get:e=>e.thread().message({index:n}).composer()}),t[2]=n,t[3]=a);let o;t[4]!==i||t[5]!==a?(o={message:i,composer:a},t[4]=i,t[5]=a,t[6]=o):o=t[6];let s=eF(o),c;return t[7]!==s||t[8]!==r?(c=(0,J.jsx)(EP,{value:s,children:r}),t[7]=s,t[8]=r,t[9]=c):c=t[9],c},GI=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=OP({source:`message`,query:{type:`index`,index:n},get:e=>e.message().part({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={part:i},t[2]=i,t[3]=a);let o=eF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(EP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},KI=PN(e=>{let t=Z(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:JI,resumeToolCall:YI,respondToToolApproval:XI},t[5]=o,t[6]=s),s}),qI=e=>{let t=Z(8),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o;t[0]!==a||t[1]!==n?(o=KI({text:n,isRunning:a}),t[0]=a,t[1]=n,t[2]=o):o=t[2];let s;t[3]===o?s=t[4]:(s={part:o},t[3]=o,t[4]=s);let c=eF(s),l;return t[5]!==c||t[6]!==i?(l=(0,J.jsx)(EP,{value:c,children:i}),t[5]=c,t[6]=i,t[7]=l):l=t[7],l};function JI(){throw Error(`Not supported`)}function YI(){throw Error(`Not supported`)}function XI(){throw Error(`Not supported`)}var ZI=Object.freeze({type:`complete`}),QI=PN(e=>{let t=Z(9),{parts:n,getMessagePart:r}=e,[i,a]=vN(!0),o=n[n.length-1]?.status??ZI,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={parts:n,collapsed:i,status:o},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let c=s,l;t[4]===c?l=t[5]:(l=()=>c,t[4]=c,t[5]=l);let u;return t[6]!==r||t[7]!==l?(u={getState:l,setCollapsed:a,part:r},t[6]=r,t[7]=l,t[8]=u):u=t[8],u}),$I=e=>{let t=Z(5),{startIndex:n,endIndex:r,children:i}=e,a=Q(eL).slice(n,r+1),o=eF(),s=QI({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message().part({index:n+t})}}),c;t[0]===s?c=t[1]:(c={chainOfThought:s},t[0]=s,t[1]=c);let l=eF(c),u;return t[2]!==l||t[3]!==i?(u=(0,J.jsx)(EP,{value:l,children:i}),t[2]=l,t[3]=i,t[4]=u):u=t[4],u};function eL(e){return e.message.parts}var tL=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=OP({source:`suggestions`,query:{index:n},get:e=>e.suggestions().suggestion({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={suggestion:i},t[2]=i,t[3]=a);let o=eF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(EP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},nL=e=>{let t=Z(7),{index:n,children:r}=e,i;t[0]===n?i=t[1]:(i=OP({source:`composer`,query:{index:n},get:e=>e.composer().queueItem({index:n})}),t[0]=n,t[1]=i);let a;t[2]===i?a=t[3]:(a={queueItem:i},t[2]=i,t[3]=a);let o=eF(a),s;return t[4]!==o||t[5]!==r?(s=(0,J.jsx)(EP,{value:o,children:r}),t[4]=o,t[5]=r,t[6]=s):s=t[6],s},rL=Symbol(`innerMessage`),iL=Symbol(`innerMessages`),aL=[],oL=(e,t)=>{rL in e||(e[rL]=t)},sL=e=>{let t=`messages`in e?e.messages:e,n=t[iL]||t[rL];return n?Array.isArray(n)?n:(t[iL]=[n],t[iL]):aL},cL=Symbol(`skip-update`);function lL(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;for(let n of Object.keys(e)){let r=e[n],i=t[n];if(!Object.is(r,i))return!1}return!0}var uL=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){let e=[];for(let t of this._subscribers)try{t()}catch(t){e.push(t)}if(e.length>0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e)}}},dL=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e){for(let t of this._subscriptions)t(e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},fL=class extends dL{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e;let t=e.getState();if(t===cL)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===cL||lL(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){return this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()})}},pL=class extends dL{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==cL&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){return this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()})}},mL=class extends dL{binding;get path(){return this.binding.path}constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();r!==t&&(t=r,n?.(),n=r?.subscribe(e),e())});return()=>{r?.(),n?.()}}},hL=class extends dL{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=e=>{this.notifySubscribers(e)},t=this.config.binding.getState(),n=t?.unstable_on(this.config.event,e),r=this.outerSubscribe(()=>{let r=this.config.binding.getState();r!==t&&(t=r,n?.(),n=r?.unstable_on(this.config.event,e))});return()=>{r?.(),n?.()}}},gL=class{_core;get path(){return this._core.path}constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},_L=class extends gL{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},vL=class extends _L{get source(){return`thread-composer`}},yL=class extends _L{get source(){return`edit-composer`}},bL=class extends gL{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},xL=Object.freeze([]),SL=Object.freeze({}),CL=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??xL,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??SL,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??xL,value:e?.text??``}),wL=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??xL,runConfig:e?.runConfig??SL,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??xL,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),TL=class{_core;get path(){return this._core.path}constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.steerQueueItem(e)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new hL({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},EL=class extends TL{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new pL({path:e.path,getState:()=>CL(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new vL(new fL({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:cL},subscribe:e=>this._core.subscribe(e)}),this._core)}},DL=class extends TL{_beginEdit;get path(){return this._core.path}get type(){return`edit`}_getState;constructor(e,t){let n=new pL({path:e.path,getState:()=>wL(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new yL(new fL({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:cL},subscribe:e=>this._core.subscribe(e)}),this._core)}},OL=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
13
+
14
+ `),kL={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},AL=(e,t)=>{let n,r;if(`optionId`in t){let i=e.options?.find(e=>e.id===t.optionId);if(!i)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)n=t.approved;else{if(!Object.hasOwn(kL,i.kind))throw Error(`Tool approval option "${i.id}" has a custom kind "${i.kind}"; respond with an explicit approved value instead`);n=kL[i.kind]}r=i.id}else n=t.approved;return{approvalId:e.id,approved:n,...r!==void 0&&{optionId:r},...t.reason!=null&&{reason:t.reason}}},jL=class{contentBinding;messageApi;threadApi;get path(){return this.contentBinding.path}constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=DI.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);this.threadApi.getState().respondToToolApproval(AL(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},ML=Object.freeze({type:`complete`}),NL=(e,t,n)=>{if(e.role!==`assistant`)return ML;if(n.type===`tool-call`)return n.result?ML:e.status;let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?ML:r?e.status:ML},PL=(e,t)=>{let n=e.content[t];if(!n)return cL;let r=NL(e,t,n);return Object.freeze({...n,[rL]:n[rL],status:r})},FL=class{_core;_threadBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new DL(new mL({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return OL(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new jL(new fL({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>PL(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new jL(new fL({path:{...this.path,ref:this.path.ref+`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?cL:PL(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new bL(new fL({path:{...this.path,ref:`${this.path.ref}${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:cL},subscribe:e=>this._core.subscribe(e)}))}},IL=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),LL=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),RL=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},zL=(e,t)=>{let n=e.messages.at(-1);return Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:e.isRunning??(n?.role===`assistant`&&n.status.type===`running`),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice})},BL=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;constructor(e,t){let n=new fL({path:e.path,getState:()=>zL(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new EL(new mL({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){this._threadBinding.getState().append(RL(this._threadBinding.getState().messages,e))}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._threadBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(LL(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(IL(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new FL(new fL({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return cL;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[rL]:e[rL],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new hL({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},VL=ON(null),HL=()=>AN(VL),UL=class{_core;_threadListBinding;get path(){return this._core.path}constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;n===a&&r===o||(n=a,r=o,!(e===`switchedTo`&&!a)&&(e===`switchedAway`&&a||t({})))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},WL=Promise.resolve(),GL=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),KL=(e,t)=>{if(t===void 0)return cL;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId}:cL},qL=class{_core;_runtimeFactory;_getState;constructor(e,t=BL){this._core=e,this._runtimeFactory=t;let n=new pL({path:{},getState:()=>GL(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._mainThreadListItemRuntime=new UL(new fL({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>KL(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new mL({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??WL}loadMore(){return this._core.loadMore?.()??WL}getState(){return this._getState()}subscribe(e){return this._core.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new mL({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new UL(new fL({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>KL(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new UL(new fL({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>KL(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new UL(new fL({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>KL(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},JL=class{_core;threads;_thread;constructor(e){this._core=e,this.threads=new qL(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},YL=class{_contextProvider=new $N;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},XL=Object.freeze([]),ZL=`DEFAULT_THREAD_ID`,QL=Object.freeze([ZL]),$L=Object.freeze({id:ZL,remoteId:void 0,externalId:void 0,status:`regular`}),eR=Promise.resolve(),tR=Object.freeze({[ZL]:$L}),nR=class{threadFactory;_mainThreadId=ZL;_threads=QL;_archivedThreads=XL;_threadData=tR;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return eR}_mainThread;get mainThreadId(){return this._mainThreadId}constructor(e={},t){this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??ZL,i=e.threads??XL,a=e.archivedThreads??XL,o=n.threadId??ZL,s=n.threads??XL,c=n.archivedThreads??XL;!t&&o===r&&s===i&&c===a||((s!==i||c!==a||o!==r)&&(this._threadData={...tR,...Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),...Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[])}),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??XL),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??XL),(t||o!==r)&&(this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}}),this._notifySubscribers())}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}_subscriptions=new Set;subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}_notifySubscribers(){for(let e of this._subscriptions)e()}},rR=fI(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),iR=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},aR=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>e.match(/^data:image\/(png|jpeg|jpg|gif|webp|svg\+xml);base64,(.*)$/)||/^(https:\/\/|blob:)/.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null);if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`reasoning`:return e.text.trim().length===0?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${rR()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:xI(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=iR(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=iR(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>iR(e.type,e.data)??e)})),metadata:{custom:c?.custom??{}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},oR=Symbol(`autoStatus`),sR=Object.freeze(Object.assign({type:`running`},{[oR]:!0})),cR=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[oR]:!0})),lR=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[oR]:!0})),uR=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[oR]:!0})),dR=e=>e[oR]===!0,fR=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[oR]:!0}):e&&t?sR:n?uR:r?lR:cR,pR={fromArray:e=>{let t=e.map(e=>aR(e,rR(),fR(!1,!1,!1,!1,void 0)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>{let n=fR(!1,!1,!1,!1,void 0);return{...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:aR(e,e.id,n)}})}}},mR=e=>e.next?mR(e.next):`current`in e?e:null,hR=class{func;_value=null;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},gR=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){e.level=t;for(let n of e.children){let e=this.messages.get(n);e&&this.updateLevels(e,t+1)}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(!(n===`relink`&&r===i)){if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/link): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`);i.children=[...i.children,t.current.id],(mR(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new hR(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=mR(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head,r=t.prev??this.root;r.next=t,this.head=mR(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=t=>{for(let n of t.children){let t=this.messages.get(n);t&&(e(t),this.messages.delete(n))}};e(t),t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages)t.current.metadata?.isOptimistic||e.push({message:t.current,parentId:t.prev?.current.id??null});let t=this.head;for(;t?.current.metadata?.isOptimistic;)t=t.prev;return{headId:t?.current.id??null,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},_R=Object.freeze([]);function vR(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function yR(e,t){return e.length===t.length&&e.every((e,n)=>e.id===t[n].id)}function bR(e){let t=rR();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function xR(e){let t=[];for(let n of e)n.type!==`text`&&t.push(bR(n));return t}var SR=e=>e.status.type===`complete`,CR=class extends uL{isEditing=!0;get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){if(this._text!==e){if(this._text=e,this._dictation){this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}this._notifySubscribers()}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!SR(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.length>0?Promise.all(this.attachments.map(async e=>{if(SR(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)})):[],r=this.text,i=this._quote;this._quote=void 0,this._emptyTextAndAttachments();let a={createdAt:new Date,role:this.role,content:r?[{type:`text`,text:r}]:[],attachments:await n,runConfig:this.runConfig,metadata:{custom:{...i?{quote:i}:{}}}};this.handleSend(a,e),this._notifyEventSubscribers(`send`,{})}cancel(){this.handleCancel()}get queue(){return _R}steerQueueItem(e){}removeQueueItem(e){}async addAttachment(e){if(!(e instanceof File)){let t=this.getAttachmentAdapter();if(t&&!vR({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={id:e.id??rR(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{});return}let t=e=>{let t=this._attachments.findIndex(t=>t.id===e.id);t===-1?this._attachments=[...this._attachments,e]:this._attachments=[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers()},n=this.getAttachmentAdapter();if(!n){let e=`Attachments are not supported`,t=Error(e);throw this._safeEmitAttachmentAddError(`no-adapter`,e,void 0,t),t}if(!vR({name:e.name,type:e.type},n.accept)){let t=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${n.accept}`,r=Error(t);throw this._safeEmitAttachmentAddError(`not-accepted`,t,void 0,r),r}let r;try{let i=n.add({file:e});if(Symbol.asyncIterator in i)for await(let e of i)r=e,t(e);else r=await i,t(r)}catch(e){throw r&&t({...r,status:{type:`incomplete`,reason:`error`}}),this._safeEmitAttachmentAddError(`adapter-error`,e instanceof Error?e.message:String(e),r?.id,e instanceof Error?e:void 0),e}r?.status.type===`incomplete`&&r.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,`Attachment upload did not complete successfully.`,r?.id):this._notifyEventSubscribers(`attachmentAdd`,{})}_safeEmitAttachmentAddError(e,t,n,r){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r}})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(!SR(n)){let e=this.getAttachmentAdapter();if(!e)throw Error(`Attachments are not supported`);await e.remove(n)}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId;e.stop().finally(()=>{this._cleanupDictation({sessionId:t})})}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},wR=class extends CR{runtime;_canCancel=!1;get canCancel(){return this._canCancel}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled}get queue(){return this.runtime.getQueueItems?.()??_R}steerQueueItem(e){this.runtime.steerQueueItem?.(e)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=this.runtime.isSendDisabled,t=this.queue;return this.runtime.subscribe(()=>{let n=!1;this.canCancel!==this.runtime.capabilities.cancel&&(this._canCancel=this.runtime.capabilities.cancel,n=!0),e!==this.runtime.isSendDisabled&&(e=this.runtime.isSendDisabled,n=!0),t!==this.queue&&(t=this.queue,n=!0),n&&this._notifySubscribers()})}async handleSend(e,t){this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},TR=class extends CR{runtime;endEditCallback;get canCancel(){return!0}get canSend(){return!this.isEmpty}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_previousText;_previousAttachments;_nonTextPassthrough;_parentId;_sourceId;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this._previousText=OL(r),this.setText(this._previousText),this.setRole(r.role),r.role===`user`?(this._previousAttachments=[...r.attachments??[],...xR(r.content)],this._nonTextPassthrough=[]):(this._previousAttachments=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(this._previousAttachments),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=OL(e),r=!yR(e.attachments??[],this._previousAttachments);if(n!==this._previousText||r||t?.startRun){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content;this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun})}this.handleCancel()}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},ER=class{_contextProvider;_subscriptions=new Set;_isInitialized=!1;repository=new gR;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new wR(this);constructor(e){this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new TR(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifySubscribers(){for(let e of this._subscriptions)e()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);if(n)for(let e of n)e(t)}subscribe(e){return this._subscriptions.add(e),()=>this._subscriptions.delete(e)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(OL(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e;for(let e of this._voiceVolumeSubscribers)e()})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:rR(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:rR(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0;for(let e of this._voiceVolumeSubscribers)e();this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(pR.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},DR=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}};function OR(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function kR(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>kR(e,t+1)):OR(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&kR(n,t+1)):!1}var AR=100,jR=(e,t,n)=>{if(e===t)return!0;if(n>AR||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>jR(e,t[r],n+1));if(Array.isArray(t)||!OR(e)||!OR(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&jR(e[r],t[r],n+1))},MR=(e,t)=>!kR(e)||!kR(t)?!1:jR(e,t,0),NR=e=>{try{return JSON.parse(e),!0}catch{return!1}},PR=e=>{try{return JSON.parse(e)}catch{return}},FR=(e,t)=>{let n=PR(e),r=PR(t);return n===void 0||r===void 0?!1:MR(n,r)},IR=class{_getTools;_callbacks;_entries=new Map;_skipExecuteStreamIds=new Set;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t){this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){let[e,t]=gI();this._controller=t;let n=VI(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t)=>this._onHumanInput(e,t),{onExecutionStart:e=>this._onExecutionStart(e),onExecutionEnd:e=>this._onExecutionEnd(e)});e.pipeThrough(n).pipeThrough(new dI).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort().finally(()=>{this._executing.clear()})}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(){try{return this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0?Promise.resolve():new Promise(e=>{this._settledResolvers.push(e)})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute;return n===void 0?[e,t]:[e,{...t,execute:(...[e,t])=>this._skipExecuteStreamIds.has(t.toolCallId)?new Promise(()=>{}):n(e,t)}]}))}_onHumanInput(e,t){return new Promise((n,r)=>{let i=this._humanInput.get(e);if(i)try{i.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{resolve:n,reject:r}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e){this._skipExecuteStreamIds.has(e)||(this._executing.add(e),this._setStatus(e,{type:`executing`}))}_onExecutionEnd(e){this._executing.delete(e)&&(this._deleteStatus(e),this._executing.size===0&&this._settledResolvers.splice(0).forEach(e=>{try{e()}catch{}}))}_handleResultChunk(e){let t=e.meta.toolCallId,n=this._entries.get(t);!n&&this._skipExecuteStreamIds.has(t)||n?.hasResult||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){let t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&NR(t)}_startActiveEntry(e,t,n){let r=this._controller.addToolCallPart({toolName:t,toolCallId:e});n&&this._skipExecuteStreamIds.add(e);let i={toolName:t,controller:r,argsText:``,hasResult:!1,argsComplete:!1};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)FR(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText))if(NR(e.argsText)&&NR(t.argsText)&&FR(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1;if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let n of e)if(!(!n||!Array.isArray(n.content)))for(let e of n.content){if(!e||e.type!==`tool-call`)continue;let n=this._entries.get(e.toolCallId);if(t){n?.controller||this._entries.set(e.toolCallId,{toolName:e.toolName,argsText:e.argsText,hasResult:e.result!==void 0}),e.messages&&this._processMessages(e.messages);continue}let r=n;if(r&&!r.controller){if(!(e.argsText!==r.argsText||e.result!==void 0!==r.hasResult)){e.messages&&this._processMessages(e.messages);continue}this._entries.delete(e.toolCallId),r=void 0}if(r||=this._startActiveEntry(e.toolCallId,e.toolName,e.result!==void 0),this._processArgsText(r,e),e.result!==void 0&&!r.hasResult){let{controller:t}=r;if(!t)continue;r.hasResult=!0,r.argsComplete=!0,t.setResponse(new DI({result:e.result,artifact:e.artifact,isError:e.isError,...e.modelContent===void 0?{}:{modelContent:e.modelContent}})),t.close()}e.messages&&this._processMessages(e.messages)}}},LR=Object.freeze([]),RR=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0},zR=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,BR=class extends ER{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}suggestions=[];extras=void 0;_converter=new DR;_store;_toolInvocations=null;beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){if(this._store===e)return;let t=e.isRunning??!1;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e,this.extras!==e.extras&&(this.extras=e.extras);let r=e.suggestions??LR;RR(this.suggestions,r)||(this.suggestions=r);let i={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};RR(this._capabilities,i)||(this._capabilities=i);let a;if(e.messageRepository){if(n&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository){this._notifySubscribers();return}let t=e.messageRepository.messages,r=e.messageRepository.headId??t.at(-1)?.message.id??null;if(n&&n.messageRepository===e.messageRepository)this.repository.resetHead(r),a=this.repository.getMessages();else{let e=new Set(t.map(({message:e})=>e.id));for(let{message:e,parentId:n}of t)this.repository.addOrUpdateMessage(n,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this.repository.resetHead(r),a=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new DR;else if(n.isRunning===e.isRunning&&n.messages===e.messages){this._notifySubscribers();return}}a=e.convertMessage?this._converter.convertMessages(e.messages,(n,r,i)=>{if(!e.convertMessage)return r;let a=fR(i===(e.messages?.length??0)-1,t,!1,!1,void 0);if(n&&(n.role!==`assistant`||!dR(n.status)||n.status===a))return n;let o=aR(e.convertMessage(r,i),i.toString(),a);return oL(o,r),o}):e.messages;for(let e=0;e<a.length;e++){let t=a[e],n=a[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);a.length>0&&this.ensureInitialized(),(n?.isRunning??!1)!==(e.isRunning??!1)&&(e.isRunning?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let o=null;zR(t,a)&&(o=rR(),this.repository.addOrUpdateMessage(a.at(-1)?.id??null,aR({role:`assistant`,content:[],metadata:{isOptimistic:!0}},o,{type:`running`}))),this.repository.resetHead(o??a.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._driveToolInvocations(),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new IR(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{this._store.setToolStatuses?.(Object.fromEntries(e))}}),this._toolInvocations.setState({messages:this._messages,isRunning:this._store.isRunning??!1,...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();let e=t=>{for(let n of t)if(Array.isArray(n.content))for(let t of n.content)!t||t.type!==`tool-call`||(this._toolCallToMessageId.set(t.toolCallId,n.id),t.messages&&e(t.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);this._store.isRunning||(this.repository.switchToBranch(e),this.updateMessages(this.repository.getMessages()))}async append(e){let t=e.parentId!==(this.messages.at(-1)?.id??null);if(!t&&this._store.queue){this._store.queue.enqueue(e,{steer:e.steer??!1});return}if((e.startRun??e.role===`user`)&&await this._toolInvocations?.abort(),t){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._store.queue?.clear(`edit`),await this._store.onEdit(e)}else await this._store.onNew(e)}async deleteMessage(e){if(this._store.onDelete){await this._store.onDelete(e);return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._store.isRunning&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this.updateMessages(t.filter(t=>t.id!==e))}getQueueItems(){return this._store?.queue?.items??_R}steerQueueItem(e){this._store?.queue?.steer(e)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);this._store.queue?.clear(`reload`),await this._toolInvocations?.abort(),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._toolInvocations&&(this._toolInvocations.reset(),this._store.setToolStatuses?.({})),this._store.onLoadExternalState(e)}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);this._store.queue?.clear(`cancel-run`),this._toolInvocations?.abort(),this._store.onCancel();let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id);let t=this.repository.getMessages(),n=t[t.length-1];n?.role===`user`&&n.id===t.at(-1)?.id?(this.repository.deleteMessage(n.id),this.composer.text.trim()||this.composer.setText(OL(n)),t=this.repository.getMessages()):this._notifySubscribers(),setTimeout(()=>{this.updateMessages(t)},0)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);this._store.onAddToolResult?.(e)}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);this._store.onRespondToToolApproval(e)}reset(e){let t=new gR;t.import(pR.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(sL))}},VR=e=>e.adapters?.threadList??{},HR=class extends YL{threads;constructor(e){super(),this.threads=new nR(VR(e),()=>new BR(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(VR(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},UR=e=>{let t=Z(11),n;t[0]===e?n=t[1]:(n=()=>new HR(e),t[0]=e,t[1]=n);let[r]=vN(n),i;t[2]!==r||t[3]!==e?(i=()=>{r.setAdapter(e)},t[2]=r,t[3]=e,t[4]=i):i=t[4],CN(i);let{modelContext:a}=HL()??{},o,s;t[5]!==a||t[6]!==r?(o=()=>{if(a)return r.registerModelContextProvider(a)},s=[a,r],t[5]=a,t[6]=r,t[7]=o,t[8]=s):(o=t[7],s=t[8]),CN(o,s);let c;return t[9]===r?c=t[10]:(c=new JL(r),t[9]=r,t[10]=c),c},WR=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,GR=()=>null,KR=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message:e.SystemMessage??e.Message??GR;default:throw Error(`Unknown message role: ${t}`)}},qR=e=>{let t=Z(6),{components:n}=e,r=Q(QR),i=Q($R),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=KR(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,J.jsx)(o,{}),t[4]=o,t[5]=s),s},JR=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(qR,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(WI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&WR(e.components,t.components));JR.displayName=`ThreadPrimitive.MessageByIndex`;var YR=({children:e})=>{let t=Q(e=>e.thread.messages.length);return xN(()=>t===0?null:Array.from({length:t},(t,n)=>(0,J.jsx)(WI,{index:n,children:(0,J.jsx)(rF,{getItemState:e=>e.thread().message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},XR=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(YR,{children:()=>(0,J.jsx)(qR,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(YR,{children:r}),t[2]=r,t[3]=i),i};XR.displayName=`ThreadPrimitive.Messages`;var ZR=(0,X.memo)(XR,(e,t)=>e.children||t.children?e.children===t.children:WR(e.components,t.components));function QR(e){return e.message.role}function $R(e){return e.message.composer.isEditing}var ez=e=>{let t=e.message.metadata;if(!(!t||typeof t!=`object`))return t.custom?.quote},tz=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},nz=e=>typeof e==`object`&&!!e,rz=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!nz(e)||!(`component`in e))return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,J.jsx)(n,{component:i,props:a},s??r);throw new tz(i)}let l=o?.length?o.map((e,i)=>rz(e,t,n,`${r}/${i}`)):void 0;return(0,X.createElement)(c,{...a??{},key:s??r},...l??[])},iz=e=>{if(!e||e.root===void 0||e.root===null)return[];let t=e.root;return Array.isArray(t)?t:[t]},az=e=>{let t=Z(11),{spec:n,components:r,Fallback:i}=e,a;t[0]===n?a=t[1]:(a=iz(n),t[0]=n,t[1]=a);let o=a,s;if(t[2]!==i||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>rz(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],s=o.map(e),t[2]=i,t[3]=r,t[4]=o,t[5]=s}else s=t[5];let c;return t[9]===s?c=t[10]:(c=(0,J.jsx)(J.Fragment,{children:s}),t[9]=s,t[10]=c),c};az.displayName=`GenerativeUIRender`;var oz=e=>{let t=Z(4),{components:n,spec:r,Fallback:i}=e,a=Q(sz),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,J.jsx)(az,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};oz.displayName=`MessagePrimitive.GenerativeUI`;function sz(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var cz=`ui://`,lz=e=>!!e?.startsWith(cz),uz=e=>Symbol.iterator in e,dz=e=>`entries`in e,fz=(e,t)=>{let n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(let[e,t]of n)if(!r.has(e)||!Object.is(t,r.get(e)))return!1;return!0},pz=(e,t)=>{let n=e[Symbol.iterator](),r=t[Symbol.iterator](),i=n.next(),a=r.next();for(;!i.done&&!a.done;){if(!Object.is(i.value,a.value))return!1;i=n.next(),a=r.next()}return!!i.done&&!!a.done};function mz(e,t){return Object.is(e,t)?!0:typeof e!=`object`||!e||typeof t!=`object`||!t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:uz(e)&&uz(t)?dz(e)&&dz(t)?fz(e,t):pz(e,t):fz({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function hz(e){let t=q.useRef(void 0);return n=>{let r=e(n);return mz(t.current,r)?t.current:t.current=r}}var gz=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},_z=(e,t,n)=>{let r=[];if(t){let t=gz(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=gz(`toolGroup`),n=gz(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},vz=e=>{let t=Z(10),n=Q(hz(Vz)),r=Q(hz(Uz)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=_z(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},yz=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},bz=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),xz=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>bz(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},Sz={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},Cz=e=>{let t=Z(47),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?Sz.Text:i,m=a===void 0?Sz.Reasoning:a,h=o===void 0?Sz.Image:o,g=s===void 0?Sz.Source:s,_=c===void 0?Sz.File:c,v=l===void 0?Sz.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=eF(),S=Q(Wz),C=S.type;if(C===`tool-call`){let e;t[4]===x?e=t[5]:(e=x.part(),t[4]=x,t[5]=e);let n=e.addToolResult,r;t[6]===x?r=t[7]:(r=x.part(),t[6]=x,t[7]=r);let i=r.resumeToolCall,a;t[8]===x?a=t[9]:(a=x.part(),t[8]=x,t[9]=a);let o=a.respondToToolApproval;if(`Override`in b){let e;return t[10]!==n||t[11]!==S||t[12]!==o||t[13]!==i||t[14]!==b.Override?(e=(0,J.jsx)(b.Override,{...S,addResult:n,resume:i,respondToApproval:o}),t[10]=n,t[11]=S,t[12]=o,t[13]=i,t[14]=b.Override,t[15]=e):e=t[15],e}let s=b.by_name?.[S.toolName]??b.Fallback,c;return t[16]!==s||t[17]!==n||t[18]!==S||t[19]!==o||t[20]!==i?(c=(0,J.jsx)(yz,{...S,Fallback:s,addResult:n,resume:i,respondToApproval:o}),t[16]=s,t[17]=n,t[18]=S,t[19]=o,t[20]=i,t[21]=c):c=t[21],c}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[22]!==p||t[23]!==S?(e=(0,J.jsx)(p,{...S}),t[22]=p,t[23]=S,t[24]=e):e=t[24],e}case`reasoning`:{let e;return t[25]!==m||t[26]!==S?(e=(0,J.jsx)(m,{...S}),t[25]=m,t[26]=S,t[27]=e):e=t[27],e}case`source`:{let e;return t[28]!==g||t[29]!==S?(e=(0,J.jsx)(g,{...S}),t[28]=g,t[29]=S,t[30]=e):e=t[30],e}case`image`:{let e;return t[31]!==h||t[32]!==S?(e=(0,J.jsx)(h,{...S}),t[31]=h,t[32]=S,t[33]=e):e=t[33],e}case`file`:{let e;return t[34]!==_||t[35]!==S?(e=(0,J.jsx)(_,{...S}),t[34]=_,t[35]=S,t[36]=e):e=t[36],e}case`audio`:{let e;return t[37]!==v||t[38]!==S?(e=(0,J.jsx)(v,{...S}),t[37]=v,t[38]=S,t[39]=e):e=t[39],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[40]!==e||t[41]!==S?(n=(0,J.jsx)(xz,{...S,Fallback:e}),t[40]=e,t[41]=S,t[42]=n):n=t[42],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[43]!==f.Fallback||t[44]!==f.components||t[45]!==e.spec?(n=(0,J.jsx)(az,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[43]=f.Fallback,t[44]=f.components,t[45]=e.spec,t[46]=n):n=t[46],n}default:return console.warn(`Unknown message part type: ${C}`),null}},wz=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(Cz,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(GI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);wz.displayName=`MessagePrimitive.PartByIndex`;var Tz=e=>{let t=Z(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,J.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,J.jsx)(qI,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},Ez=Object.freeze({type:`complete`}),Dz=Object.freeze({type:`running`}),Oz=(0,X.memo)(e=>{let t=Z(6),{components:n}=e,r=Q(Gz);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,J.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??Sz.Text,a;return t[3]!==r||t[4]!==i?(a=(0,J.jsx)(Tz,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),kz=(0,X.memo)(e=>{let t=Z(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!Q(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,J.jsx)(Oz,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),Az=(0,X.memo)(e=>{let t=Z(4),{Quote:n}=e,r=Q(ez);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,J.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function jz(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(lz(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var Mz=()=>{let e=Z(12),t=eF(),n=Q(Kz),r=Q(qz);if(!r||n.type!==`tool-call`)return null;let i;e[0]===t?i=e[1]:(i=t.part(),e[0]=t,e[1]=i);let a=i.addToolResult,o;e[2]===t?o=e[3]:(o=t.part(),e[2]=t,e[3]=o);let s=o.resumeToolCall,c;e[4]===t?c=e[5]:(c=t.part(),e[4]=t,e[5]=c);let l;return e[6]!==r||e[7]!==n||e[8]!==i.addToolResult||e[9]!==o.resumeToolCall||e[10]!==c.respondToToolApproval?(l=(0,J.jsx)(r,{...n,addResult:a,resume:s,respondToApproval:c.respondToToolApproval}),e[6]=r,e[7]=n,e[8]=i.addToolResult,e[9]=o.resumeToolCall,e[10]=c.respondToToolApproval,e[11]=l):l=e[11],l},Nz=()=>{let e=Z(3),t=Q(Jz),n=Q(Yz);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,J.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},Pz=()=>{let e=Z(2),t=Q(Xz);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(Mz,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,J.jsx)(Nz,{}),e[1]=t):t=e[1],t}return null},Fz=Object.freeze({type:`text`,text:``,status:Dz}),Iz=({index:e,children:t})=>{let n=eF(),r=Q(e=>e.dataRenderers);return(0,J.jsx)(GI,{index:e,children:(0,J.jsx)(rF,{getItemState:t=>t.message().part({index:e}).getState(),children:i=>t({get part(){let t=i();if(t.type===`tool-call`){let r=jz(n.tools().getState(),t)!==null,i=n.message().part({index:e});return{...t,toolUI:r?(0,J.jsx)(Mz,{}):null,addResult:i.addToolResult,resume:i.resumeToolCall,respondToApproval:i.respondToToolApproval}}if(t.type===`data`){let e=bz(r,t.name,void 0)!==void 0;return{...t,dataRendererUI:e?(0,J.jsx)(Nz,{}):null}}return t}})})})},Lz=e=>{let t=Z(9),{children:n}=e,r=Q(Zz),i=Q(Qz),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:Fz}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,J.jsx)(qI,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,J.jsx)(Iz,{index:t,children:e=>n(e)??(0,J.jsx)(Pz,{})},t),t[7]=n,t[8]=e),o=(0,J.jsx)(J.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},Rz=e=>{let t=Z(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,J.jsx)(Lz,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,J.jsx)(zz,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};Rz.displayName=`MessagePrimitive.Parts`;var zz=e=>{let t=Z(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=Q($z),{ranges:a,partIds:o}=vz(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,J.jsx)(Oz,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,J.jsx)(wz,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,J.jsx)($I,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,J.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}else if(e.type===`toolGroup`)return(0,J.jsx)(n?.ToolGroup??Sz.ToolGroup,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,J.jsx)(wz,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`);else return(0,J.jsx)(n?.ReasoningGroup??Sz.ReasoningGroup,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,J.jsx)(wz,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,J.jsx)(Az,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,J.jsx)(kz,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,J.jsxs)(J.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function Bz(e){return e.type}function Vz(e){return e.message.parts.map(Bz)}function Hz(e){return e.type===`tool-call`?e.toolCallId:void 0}function Uz(e){return e.message.parts.map(Hz)}function Wz(e){return e.part}function Gz(e){return e.message.status??Ez}function Kz(e){return e.part}function qz(e){return e.part.type===`tool-call`?jz(e.tools,e.part):null}function Jz(e){return e.part}function Yz(e){return e.part.type===`data`?bz(e.dataRenderers,e.part.name,void 0)??null:null}function Xz(e){return e.part.type}function Zz(e){return e.message.parts.length}function Qz(e){return(e.message.status?.type??`complete`)===`running`}function $z(e){return e.message.parts.length}var eB=Symbol.for(`@assistant-ui/groupBy.memoKey`),tB=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},nB=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},rB=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:nB(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:tB(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:tB(s),idKey:nB(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},iB=Object.freeze({type:`complete`}),aB=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},oB=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},sB=(e,t,n)=>{if(e.type===`part`)return(0,J.jsx)(Iz,{index:e.index,children:({part:e})=>n({part:e,children:(0,J.jsx)(oB,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let r=t[e.indices.at(-1)]?.status??iB;return(0,J.jsx)(X.Fragment,{children:n({part:{type:e.key,status:r,indices:e.indices},children:(0,J.jsx)(J.Fragment,{children:e.children.map(e=>sB(e,t,n))})})},e.idKey??e.nodeKey)},cB=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=Q(hz(e=>e.message.parts)),i=Q(e=>e.tools.toolUIs),a=Q(e=>t!==`never`&&e.message.status?.type===`running`);return(0,J.jsxs)(J.Fragment,{children:[xN(()=>{let t={toolUIs:i};return rB(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[eB]??e,i]).map(e=>sB(e,r,n)),aB(t,r,a)&&n({part:{type:`indicator`},children:(0,J.jsx)(oB,{})})]})};cB.displayName=`MessagePrimitive.GroupedParts`;var lB=(0,X.memo)(e=>{let t=Z(5),{children:n}=e,r=Q(ez);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,J.jsx)(J.Fragment,{children:i}),t[3]=i,t[4]=a),a});lB.displayName=`MessagePrimitive.Quote`;var uB=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},dB=e=>{let t=Z(5),{components:n}=e,r=Q(hB);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=uB(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,J.jsx)(o,{}),t[3]=o,t[4]=s),s},fB=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(dB,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(HI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);fB.displayName=`MessagePrimitive.AttachmentByIndex`;var pB=({children:e})=>{let t=Q(e=>e.message.role===`user`?(e.message.attachments??[]).length:0);return xN(()=>Array.from({length:t},(t,n)=>(0,J.jsx)(HI,{index:n,children:(0,J.jsx)(rF,{getItemState:e=>e.message().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},mB=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(pB,{children:e=>{let{attachment:t}=e,r=uB(n,t);return r?(0,J.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(pB,{children:r}),t[2]=r,t[3]=i),i};mB.displayName=`MessagePrimitive.Attachments`;function hB(e){return e.attachment}var gB=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},_B=e=>{let t=Z(5),{components:n}=e,r=Q(xB);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=gB(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,J.jsx)(a,{}),t[3]=a,t[4]=o),o},vB=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(_B,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(UI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);vB.displayName=`ComposerPrimitive.AttachmentByIndex`;var yB=({children:e})=>{let t=Q(e=>e.composer.attachments.length);return xN(()=>Array.from({length:t},(t,n)=>(0,J.jsx)(UI,{index:n,children:(0,J.jsx)(rF,{getItemState:e=>e.composer().attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},n)),[t,e])},bB=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(yB,{children:e=>{let{attachment:t}=e,r=gB(n,t);return r?(0,J.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(yB,{children:r}),t[2]=r,t[3]=i),i};bB.displayName=`ComposerPrimitive.Attachments`;function xB(e){return e.attachment}var SB=(0,X.memo)(({children:e})=>{let t=Q(e=>e.composer.queue.length);return xN(()=>Array.from({length:t},(t,n)=>(0,J.jsx)(nL,{index:n,children:(0,J.jsx)(rF,{getItemState:e=>e.composer().queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},n)),[t,e])});SB.displayName=`ComposerPrimitive.Queue`;var CB=e=>{let{children:t}=e;return Q(wB)?t:null};CB.displayName=`MessagePartPrimitive.InProgress`;function wB(e){return e.part.status.type===`running`}var TB=e=>{let t=Z(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,J.jsx)(r,{}),t[0]=r,t[1]=i),i},EB=(0,X.memo)(e=>{let t=Z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(TB,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(tL,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);EB.displayName=`ThreadPrimitive.SuggestionByIndex`;var DB=({children:e})=>{let t=Q(e=>e.suggestions.suggestions.length);return xN(()=>t===0?null:Array.from({length:t},(t,n)=>(0,J.jsx)(tL,{index:n,children:(0,J.jsx)(rF,{getItemState:e=>e.suggestions().suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},OB=e=>{let t=Z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)(DB,{children:()=>(0,J.jsx)(TB,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,J.jsx)(DB,{children:r}),t[2]=r,t[3]=i),i};OB.displayName=`ThreadPrimitive.Suggestions`;var kB=(0,X.memo)(OB,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),AB=e=>{let t=Z(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],Q(n)},jB=e=>{let t=Z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),AB(r)?n:null};jB.displayName=`ComposerPrimitive.If`;var MB=()=>{let e=Z(5),t=eF(),n=Q(NB),r;e[0]===t?r=e[1]:(r=e=>{t.composer().send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function NB(e){return!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue}var PB=()=>{let e=Z(5),t=eF(),n=Q(FB),r;e[0]===t?r=e[1]:(r=()=>{t.composer().cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function FB(e){return!e.composer.canCancel}var IB=()=>{let e=Z(5),t=eF(),n=Q(LB),r;e[0]===t?r=e[1]:(r=()=>{t.composer().startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function LB(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var RB=()=>{let e=Z(5),t=eF(),n=Q(zB),r;e[0]===t?r=e[1]:(r=e=>t.composer().addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function zB(e){return!e.composer.isEditing}var BB=e=>{let t=Z(12),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=eF(),s=Q(HB),c=Q(UB),l=Q(WB),u=Q(GB),d;t[2]!==o||t[3]!==u||t[4]!==a||t[5]!==i||t[6]!==l?(d=()=>{let e=l?u:o.message().getCopyText();if(!e)return;let t=i??KB;Promise.resolve(t(e)).then(()=>{o.message().setIsCopied(!0),setTimeout(()=>o.message().setIsCopied(!1),a)},qB)},t[2]=o,t[3]=u,t[4]=a,t[5]=i,t[6]=l,t[7]=d):d=t[7];let f=d,p;return t[8]!==f||t[9]!==s||t[10]!==c?(p={copy:f,disabled:s,isCopied:c},t[8]=f,t[9]=s,t[10]=c,t[11]=p):p=t[11],p};function VB(e){return e.type===`text`&&e.text.length>0}function HB(e){return!((e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(VB))}function UB(e){return e.message.isCopied}function WB(e){return e.composer.isEditing}function GB(e){return e.composer.text}function KB(){}function qB(){}var JB=()=>{let e=Z(5),t=eF(),n=Q(YB),r;e[0]===t?r=e[1]:(r=()=>{t.composer().beginEdit()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={edit:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function YB(e){return e.composer.isEditing}var XB=()=>{let e=Z(5),t=eF(),n=Q(ZB),r;e[0]===t?r=e[1]:(r=()=>{t.message().reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function ZB(e){return e.thread.isRunning||e.thread.isDisabled||e.message.role!==`assistant`}var QB=()=>{let e=Z(5),t=eF(),n=Q(eV),r;e[0]===t?r=e[1]:(r=()=>{t.message().submitFeedback({type:`positive`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},$B=()=>{let e=Z(5),t=eF(),n=Q(tV),r;e[0]===t?r=e[1]:(r=()=>{t.message().submitFeedback({type:`negative`})},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={submit:i,isSubmitted:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function eV(e){return e.message.metadata.submittedFeedback?.type===`positive`}function tV(e){return e.message.metadata.submittedFeedback?.type===`negative`}var nV=()=>{let e=Z(5),t=eF(),n=Q(iV),r;e[0]===t?r=e[1]:(r=async()=>{t.message().speak()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={speak:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function rV(e){return e.type===`text`&&e.text.length>0}function iV(e){return!((e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(rV))}var aV=()=>{let e=Z(5),t=eF(),n=Q(oV),r;e[0]===t?r=e[1]:(r=()=>{t.message().stopSpeaking()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={stopSpeaking:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function oV(e){return e.message.speech==null}var sV=e=>{let t=Z(8),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=eF(),s=Q(cV),c=r??!1,l;t[0]!==o||t[1]!==a||t[2]!==n||t[3]!==c?(l=()=>{let e=o.thread().getState().isRunning;if(c&&!e)o.thread().append({content:[{type:`text`,text:n}],runConfig:o.composer().getState().runConfig}),a&&o.composer().setText(``);else if(a)o.composer().setText(n);else{let e=o.composer().getState().text;o.composer().setText(e.trim()?`${e} ${n}`:n)}},t[0]=o,t[1]=a,t[2]=n,t[3]=c,t[4]=l):l=t[4];let u=l,d;return t[5]!==s||t[6]!==u?(d={trigger:u,disabled:s},t[5]=s,t[6]=u,t[7]=d):d=t[7],d};function cV(e){return e.thread.isDisabled}var lV=()=>Q(uV);function uV(e){return e.message.status?.type===`incomplete`&&e.message.status.reason===`error`?e.message.status.error??`An error occurred`:void 0}var dV=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,fV={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll(dV)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}};function pV(e,t){function n(n){let r=AN(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function mV(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var hV=ON(null),{useThreadViewport:gV,useThreadViewportStore:_V}=mV(pV(hV,`ThreadPrimitive.Viewport`),`useThreadViewport`),vV=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},yV=(e={})=>{let t=new Set,n=vV(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=vV(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=QF(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},bV=e=>e,xV=e=>{let t=Z(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=_V(n),i;t[1]===e?i=t[2]:(i=()=>yV(e),t[1]=e,t[2]=i);let[a]=vN(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(()=>{a.getState().scrollToBottom()}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),CN(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&bV(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),CN(c,l),a},SV=e=>{let t=Z(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=xV(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=vN(o),c;return t[4]!==n||t[5]!==s?(c=(0,J.jsx)(hV.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},CV=()=>{let e=Z(3),t=eF(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),CN(n,r),null},wV=(0,X.memo)(e=>{let t=Z(7),{children:n,aui:r,runtime:i}=e,a=r??null,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,J.jsx)(CV,{}),t[0]=o):o=t[0];let s;t[1]===n?s=t[2]:(s=(0,J.jsx)(SV,{children:n}),t[1]=n,t[2]=s);let c;return t[3]!==i||t[4]!==a||t[5]!==s?(c=(0,J.jsxs)(KF,{runtime:i,aui:a,children:[o,s]}),t[3]=i,t[4]=a,t[5]=s,t[6]=c):c=t[6],c}),TV=e=>{let t=e;t.__isBound||=(t.__internal_bindMethods?.(),!0)};function EV(e,t){let n=Z(4),r=t===void 0?DV:t;TV(e);let i,a;n[0]!==e||n[1]!==r?(i=()=>r(e.getState()),a=()=>r(e.getState()),n[0]=e,n[1]=r,n[2]=i,n[3]=a):(i=n[2],a=n[3]);let o=EN(e.subscribe,i,a);return DN(o),o}var DV=e=>e;function OV(e){function t(t){let n=!1,r;typeof t==`function`?r=t:t&&(n=!!t.optional,r=t.selector);let i=e({optional:n});return i?EV(i,r):null}return t}function kV(e){let t=Z(2),n=eF(),r;t[0]===n?r=t[1]:(r=()=>n.attachment.source?n.attachment().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`AttachmentRuntime is not available`);return i}var AV=OV(kV);function jV(e){let t=Z(2),n=eF(),r;t[0]===n?r=t[1]:(r=()=>n.composer.source?n.composer().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`ComposerRuntime is not available`);return i}var MV=OV(jV);function NV(e){let t=Z(2),n=eF(),r;t[0]===n?r=t[1]:(r=()=>n.message.source?n.message().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`MessageRuntime is not available`);return i}var $=OV(NV);function PV(e){let t=Z(2),n=eF(),r;t[0]===n?r=t[1]:(r=()=>n.thread.source?n.thread().__internal_getRuntime?.()??null:null,t[0]=n,t[1]=r);let i=Q(r);if(!i&&!e?.optional)throw Error(`ThreadRuntime is not available`);return i}var FV=OV(PV),IV=Object.defineProperty,LV=(e,t)=>{let n={};for(var r in e)IV(n,r,{get:e[r],enumerable:!0});return t||IV(n,Symbol.toStringTag,{value:`Module`}),n},RV=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function zV(e){let t=(0,X.forwardRef)((t,n)=>{let r=Z(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&(0,X.isValidElement)(o)){let e=a===void 0?o.props.children:a,t=s,i;r[5]!==o||r[6]!==e?(i=(0,X.cloneElement)(o,void 0,e),r[5]=o,r[6]=e,r[7]=i):i=r[7];let l;return r[8]!==n||r[9]!==t||r[10]!==i?(l=(0,J.jsx)(c,{...t,asChild:!0,ref:n,children:i}),r[8]=n,r[9]=t,r[10]=i,r[11]=l):l=r[11],l}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,J.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function BV(e){let t=px[e],n=zV(t);return n.displayName=`Primitive.${e}`,n}var VV=RV.reduce((e,t)=>(e[t]=BV(t),e),{}),HV=e=>{let t=Z(5),{hideWhenRunning:n,autohide:r,autohideFloat:i,forceVisible:a}=e,o;return t[0]!==r||t[1]!==i||t[2]!==a||t[3]!==n?(o=e=>{if(n&&e.thread.isRunning)return`hidden`;let t=r===`always`||r===`not-last`&&!e.message.isLast,o=a||e.message.isHovering;return t?o?i===`always`||i===`single-branch`&&e.message.branchCount<=1?`floating`:`normal`:`hidden`:`normal`},t[0]=r,t[1]=i,t[2]=a,t[3]=n,t[4]=o):o=t[4],Q(o)},UV=ON(null),WV=()=>AN(UV),GV=(0,X.forwardRef)((e,t)=>{let n=Z(18),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({hideWhenRunning:a,autohide:r,autohideFloat:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let[s,c]=vN(0),l;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>{let e=!1;return c(KV),()=>{e||(e=!0,c(qV))}},n[5]=l):l=n[5];let u=l,d;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(d={acquireInteractionLock:u},n[6]=d):d=n[6];let f=d,p=s>0,m;n[7]!==r||n[8]!==i||n[9]!==a||n[10]!==p?(m={hideWhenRunning:a,autohide:r,autohideFloat:i,forceVisible:p},n[7]=r,n[8]=i,n[9]=a,n[10]=p,n[11]=m):m=n[11];let h=HV(m);if(h===`hidden`)return null;let g;n[12]===h?g=n[13]:(g=h===`floating`?{"data-floating":`true`}:null,n[12]=h,n[13]=g);let _;return n[14]!==t||n[15]!==o||n[16]!==g?(_=(0,J.jsx)(UV.Provider,{value:f,children:(0,J.jsx)(VV.div,{...g,...o,ref:t})}),n[14]=t,n[15]=o,n[16]=g,n[17]=_):_=n[17],_});GV.displayName=`ActionBarPrimitive.Root`;function KV(e){return e+1}function qV(e){return Math.max(0,e-1)}var JV=e=>{let t=Z(4),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r}=n,i=r===void 0?3e3:r,a;t[2]===i?a=t[3]:(a={copiedDuration:i,copyToClipboard:XV},t[2]=i,t[3]=a);let{copy:o,disabled:s}=BB(a);return s?null:o},YV=(0,X.forwardRef)((e,t)=>{let n=Z(20),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({copiedDuration:r,onClick:a,disabled:i,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=Q(ZV),c;n[5]===r?c=n[6]:(c={copiedDuration:r},n[5]=r,n[6]=c);let l=JV(c),u;n[7]===s?u=n[8]:(u=s?{"data-copied":`true`}:{},n[7]=s,n[8]=u);let d=i||!l,f;n[9]===l?f=n[10]:(f=()=>{l?.()},n[9]=l,n[10]=f);let p;n[11]!==a||n[12]!==f?(p=Zy(a,f),n[11]=a,n[12]=f,n[13]=p):p=n[13];let m;return n[14]!==t||n[15]!==o||n[16]!==u||n[17]!==d||n[18]!==p?(m=(0,J.jsx)(VV.button,{type:`button`,...u,...o,ref:t,disabled:d,onClick:p}),n[14]=t,n[15]=o,n[16]=u,n[17]=d,n[18]=p,n[19]=m):m=n[19],m});YV.displayName=`ActionBarPrimitive.Copy`;function XV(e){return typeof navigator>`u`||!navigator.clipboard?Promise.reject(Error(`Clipboard API is unavailable`)):navigator.clipboard.writeText(e)}function ZV(e){return e.message.isCopied}var QV=(e,t,n=[])=>{let r=(0,X.forwardRef)((e,r)=>{let i=Z(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=VV,l=o.disabled||!s,u=Zy(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,J.jsx)(c.button,{...o,type:`button`,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},$V=QV(`ActionBarPrimitive.Reload`,()=>{let{disabled:e,reload:t}=XB();return e?null:t}),eH=QV(`ActionBarPrimitive.Edit`,()=>{let{disabled:e,edit:t}=JB();return e?null:t}),tH=QV(`ActionBarPrimitive.Speak`,()=>{let{disabled:e,speak:t}=nV();return e?null:t}),nH=()=>{let{disabled:e,stopSpeaking:t}=aV();return e?null:t},rH=(0,X.forwardRef)((e,t)=>{let n=Z(12),r=nH(),i;n[0]===r?i=n[1]:(i=e=>{r&&(e.preventDefault(),r())},n[0]=r,n[1]=i),pm(i);let a=!r,o;n[2]===r?o=n[3]:(o=()=>{r?.()},n[2]=r,n[3]=o);let s;n[4]!==e.onClick||n[5]!==o?(s=Zy(e.onClick,o),n[4]=e.onClick,n[5]=o,n[6]=s):s=n[6];let c;return n[7]!==e||n[8]!==t||n[9]!==a||n[10]!==s?(c=(0,J.jsx)(VV.button,{type:`button`,disabled:a,...e,ref:t,onClick:s}),n[7]=e,n[8]=t,n[9]=a,n[10]=s,n[11]=c):c=n[11],c});rH.displayName=`ActionBarPrimitive.StopSpeaking`;var iH=()=>{let{submit:e}=QB();return e},aH=(0,X.forwardRef)((e,t)=>{let n=Z(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=Q(oH),s=iH(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=Zy(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,J.jsx)(VV.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});aH.displayName=`ActionBarPrimitive.FeedbackPositive`;function oH(e){return e.message.metadata.submittedFeedback?.type===`positive`}var sH=()=>{let{submit:e}=$B();return e},cH=(0,X.forwardRef)((e,t)=>{let n=Z(17),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({onClick:i,disabled:r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=Q(lH),s=sH(),c;n[4]===o?c=n[5]:(c=o?{"data-submitted":`true`}:{},n[4]=o,n[5]=c);let l=r||!s,u;n[6]===s?u=n[7]:(u=()=>{s?.()},n[6]=s,n[7]=u);let d;n[8]!==i||n[9]!==u?(d=Zy(i,u),n[8]=i,n[9]=u,n[10]=d):d=n[10];let f;return n[11]!==t||n[12]!==a||n[13]!==c||n[14]!==l||n[15]!==d?(f=(0,J.jsx)(VV.button,{type:`button`,...c,...a,ref:t,disabled:l,onClick:d}),n[11]=t,n[12]=a,n[13]=c,n[14]=l,n[15]=d,n[16]=f):f=n[16],f});cH.displayName=`ActionBarPrimitive.FeedbackNegative`;function lH(e){return e.message.metadata.submittedFeedback?.type===`negative`}var uH=e=>{let t=Z(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{filename:r,onExport:i}=n,a=eF(),o=Q(pH),s;return t[2]!==a||t[3]!==r||t[4]!==i?(s=async()=>{let e=a.message().getCopyText();if(!e)return;if(i){await i(e);return}let t=new Blob([e],{type:`text/markdown`}),n=URL.createObjectURL(t),o=document.createElement(`a`);o.href=n,o.download=r??`message-${Date.now()}.md`,o.click(),URL.revokeObjectURL(n)},t[2]=a,t[3]=r,t[4]=i,t[5]=s):s=t[5],o?s:null},dH=(0,X.forwardRef)((e,t)=>{let n=Z(19),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({filename:i,onExport:o,onClick:a,disabled:r,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let c;n[6]!==i||n[7]!==o?(c={filename:i,onExport:o},n[6]=i,n[7]=o,n[8]=c):c=n[8];let l=uH(c),u=r||!l,d;n[9]===l?d=n[10]:(d=()=>{l?.()},n[9]=l,n[10]=d);let f;n[11]!==a||n[12]!==d?(f=Zy(a,d),n[11]=a,n[12]=d,n[13]=f):f=n[13];let p;return n[14]!==t||n[15]!==s||n[16]!==u||n[17]!==f?(p=(0,J.jsx)(VV.button,{type:`button`,...s,ref:t,disabled:u,onClick:f}),n[14]=t,n[15]=s,n[16]=u,n[17]=f,n[18]=p):p=n[18],p});dH.displayName=`ActionBarPrimitive.ExportMarkdown`;function fH(e){return e.type===`text`&&e.text.length>0}function pH(e){return(e.message.role!==`assistant`||e.message.status?.type!==`running`)&&e.message.parts.some(fH)}var mH=LV({Copy:()=>YV,Edit:()=>eH,ExportMarkdown:()=>dH,FeedbackNegative:()=>cH,FeedbackPositive:()=>aH,Reload:()=>$V,Root:()=>GV,Speak:()=>tH,StopSpeaking:()=>rH}),hH=cC(),gH=e=>{let t=Z(25),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({__scopeActionBarMore:n,open:i,onOpenChange:r,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let o=hH(n),s=WV(),c=bN(null),l=i!==void 0,u;t[5]===s?u=t[6]:(u=e=>{if(e){if(c.current)return;c.current=s?.acquireInteractionLock()??null;return}c.current?.(),c.current=null},t[5]=s,t[6]=u);let d=u,f;t[7]!==l||t[8]!==r||t[9]!==d?(f=e=>{l||d(e),r?.(e)},t[7]=l,t[8]=r,t[9]=d,t[10]=f):f=t[10];let p=f,m,h;t[11]!==l||t[12]!==i||t[13]!==d?(m=()=>{l&&d(!!i)},h=[l,i,d],t[11]=l,t[12]=i,t[13]=d,t[14]=m,t[15]=h):(m=t[14],h=t[15]),CN(m,h);let g,_;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>()=>{c.current?.(),c.current=null},_=[],t[16]=g,t[17]=_):(g=t[16],_=t[17]),CN(g,_);let v;t[18]===i?v=t[19]:(v=i===void 0?null:{open:i},t[18]=i,t[19]=v);let y;return t[20]!==p||t[21]!==a||t[22]!==o||t[23]!==v?(y=(0,J.jsx)(oC,{...o,...a,...v,onOpenChange:p}),t[20]=p,t[21]=a,t[22]=o,t[23]=v,t[24]=y):y=t[24],y};gH.displayName=`ActionBarMorePrimitive.Root`;var _H=zV(dC),vH=zV(uC),yH=zV(ute),bH=zV(mC),xH=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=hH(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,J.jsx)(_H,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});xH.displayName=`ActionBarMorePrimitive.Trigger`;var SH=(0,X.forwardRef)((e,t)=>{let n=Z(14),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({__scopeActionBarMore:r,portalProps:i,sideOffset:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=o===void 0?4:o,c=hH(r),l;n[5]!==t||n[6]!==a||n[7]!==c||n[8]!==s?(l=(0,J.jsx)(vH,{...c,...a,ref:t,sideOffset:s}),n[5]=t,n[6]=a,n[7]=c,n[8]=s,n[9]=l):l=n[9];let u;return n[10]!==i||n[11]!==c||n[12]!==l?(u=(0,J.jsx)(aC,{...c,...i,children:l}),n[10]=i,n[11]=c,n[12]=l,n[13]=u):u=n[13],u});SH.displayName=`ActionBarMorePrimitive.Content`;var CH=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=hH(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,J.jsx)(yH,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});CH.displayName=`ActionBarMorePrimitive.Item`;var wH=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({__scopeActionBarMore:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=hH(r),o;return n[3]!==t||n[4]!==i||n[5]!==a?(o=(0,J.jsx)(bH,{...a,...i,ref:t}),n[3]=t,n[4]=i,n[5]=a,n[6]=o):o=n[6],o});wH.displayName=`ActionBarMorePrimitive.Separator`;var TH=LV({Content:()=>SH,Item:()=>CH,Root:()=>gH,Separator:()=>wH,Trigger:()=>xH}),EH=(0,X.forwardRef)((e,t)=>{let n=Z(3),r;return n[0]!==e||n[1]!==t?(r=(0,J.jsx)(VV.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});EH.displayName=`AttachmentPrimitive.Root`;var DH=(0,X.forwardRef)((e,t)=>{let n=Z(4),r=Q(OH),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=(0,J.jsxs)(VV.div,{...e,ref:t,children:[`.`,r]}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i});DH.displayName=`AttachmentPrimitive.unstable_Thumb`;function OH(e){let t=e.attachment.name.split(`.`);return t.length>1?t.pop():``}var kH=()=>{let e=Z(2),t=Q(AH),n;return e[0]===t?n=e[1]:(n=(0,J.jsx)(J.Fragment,{children:t}),e[0]=t,e[1]=n),n};kH.displayName=`AttachmentPrimitive.Name`;function AH(e){return e.attachment.name}var jH=QV(`AttachmentPrimitive.Remove`,()=>{let e=Z(2),t=eF(),n;return e[0]===t?n=e[1]:(n=()=>{t.attachment().remove()},e[0]=t,e[1]=n),n}),MH=LV({Name:()=>kH,Remove:()=>jH,Root:()=>EH,unstable_Thumb:()=>DH}),NH=e=>{let t=Z(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],Q(n)},PH=e=>{let t=Z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),NH(r)?n:null};PH.displayName=`MessagePrimitive.If`;var FH=ON(null),IH=()=>AN(FH),LH=e=>{let t=Z(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=bN(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=bN(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(RH),o.current=e.map(zH)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,J.jsx)(FH.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function RH(e,t){return t[1]-e[1]}function zH(e){let[t]=e;return t}var BH=ON(null),VH=ON(null),HH=()=>{let e=AN(BH);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},UH=()=>AN(BH),WH=()=>{let e=AN(VH);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},GH=()=>{let e=HH();return EN(e.subscribe,e.getTriggers,e.getTriggers)},KH=new Map,qH=()=>()=>{},JH=()=>KH,YH=()=>{let e=UH();return EN(e?e.subscribe:qH,e?e.getTriggers:JH,e?e.getTriggers:JH)},XH=()=>null,ZH=()=>{let e=UH();return EN(e?e.subscribeAria:qH,e?e.getActiveAria:XH,e?e.getActiveAria:XH)};function QH(){let e=Z(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=bN(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var $H=e=>{let t=Z(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=bN(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=bN(a),{notify:s,subscribe:c}=QH(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return tU;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=bN(null),g=bN(null),{notify:_,subscribe:v}=QH(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;g.current===e&&n!==null&&n.popoverId===t.popoverId&&n.highlightedItemId===t.highlightedItemId||(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,J.jsx)(VH.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,J.jsx)(BH.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},eU=e=>{let t=Z(4),{children:n}=e;if(IH()){let e;return t[0]===n?e=t[1]:(e=(0,J.jsx)($H,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,J.jsx)(LH,{children:(0,J.jsx)($H,{children:n})}),t[2]=n,t[3]=r),r};eU.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function tU(){}var nU=/\s/u;function rU(e,t,n){let r=e.slice(0,n);for(let e=r.length-1;e>=0;e--){let n=r[e];if(nU.test(n))return null;if(r.startsWith(t,e)){if(e>0&&!nU.test(r[e-1]))continue;return{query:r.slice(e+t.length),offset:e}}}return null}var iU=PN(e=>{let t=Z(7),{text:n,triggerChar:r}=e,[i,a]=vN(n.length),o=Math.min(i,n.length),s;t[0]!==o||t[1]!==n||t[2]!==r?(s=rU(n,r,o),t[0]=o,t[1]=n,t[2]=r,t[3]=s):s=t[3];let c=s,l=c?.query??``,u;return t[4]!==l||t[5]!==c?(u={trigger:c,query:l,setCursorPosition:a},t[4]=l,t[5]=c,t[6]=u):u=t[6],u});function aU(e){return`type`in e}var oU=PN(e=>{let t=Z(25),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=vN(0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{p(0)},t[0]=m):m=t[0];let h;t[1]===n?h=t[2]:(h=[n],t[1]=n,t[2]=h),CN(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p(0)},t[3]=g):g=t[3];let _;t[4]!==i||t[5]!==r?(_=[r,i],t[4]=i,t[5]=r,t[6]=_):_=t[6],CN(g,_);let v;t[7]!==f||t[8]!==n.length?(v=e=>{e<0||e>=n.length||e!==f&&p(e)},t[7]=f,t[8]=n.length,t[9]=v):v=t[9];let y=TN(v),b;t[10]!==i||t[11]!==d||t[12]!==u||t[13]!==f||t[14]!==n||t[15]!==s||t[16]!==a||t[17]!==l||t[18]!==c?(b=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(aU(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[10]=i,t[11]=d,t[12]=u,t[13]=f,t[14]=n,t[15]=s,t[16]=a,t[17]=l,t[18]=c,t[19]=b):b=t[19];let x=TN(b),S=n[f],C=s&&S?`${o}-option-${S.id}`:void 0,w;return t[20]!==x||t[21]!==y||t[22]!==f||t[23]!==C?(w={highlightedIndex:f,highlightedItemId:C,highlightIndex:y,handleKeyDown:x},t[20]=x,t[21]=y,t[22]=f,t[23]=C,t[24]=w):w=t[24],w});function sU(e,t){return e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var cU=PN(e=>{let t=Z(38),{adapter:n,query:r,open:i}=e,[a,o]=vN(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{i||o(null)},c=[i],t[0]=i,t[1]=s,t[2]=c),CN(s,c);let l;bb0:{if(!i||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],l=e;break bb0}let e;t[4]===n?e=t[5]:(e=n.categories(),t[4]=n,t[5]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],f=e;break bb1}let e;t[7]!==n||t[8]!==d?(e=n.categoryItems(d),t[7]=n,t[8]=d,t[9]=e):e=t[9],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[10]!==n||t[11]!==r?(e=n.search(r),t[10]=n,t[11]=r,t[12]=e):e=t[12],m=e;break bb2}let e;if(t[13]!==n||t[14]!==u||t[15]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))sU(r,i)&&e.push(r);t[13]=n,t[14]=u,t[15]=r,t[16]=e}else e=t[16];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[17]=e):e=t[17],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[18]!==u||t[19]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[18]=u,t[19]=r,t[20]=e}else e=t[20];_=e}let v=_,y;bb4:{if(g){let e;t[21]===h?e=t[22]:(e=h??[],t[21]=h,t[22]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[23]!==p||t[24]!==r){let n=r.toLowerCase();e=p.filter(e=>sU(e,n)),t[23]=p,t[24]=r,t[25]=e}else e=t[25];y=e}let b=y,x;bb5:{if(g){let e;t[26]===h?e=t[27]:(e=h??[],t[26]=h,t[27]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[28]=C):C=t[28];let w=TN(C),T;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[29]=T):T=t[29];let E=TN(T),D;return t[30]!==d||t[31]!==v||t[32]!==b||t[33]!==E||t[34]!==g||t[35]!==S||t[36]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[30]=d,t[31]=v,t[32]=b,t[33]=E,t[34]=g,t[35]=S,t[36]=w,t[37]=D):D=t[37],D}),lU=PN(e=>{let t=Z(15),{behavior:n,trigger:r,aui:i,triggerChar:a,setCursorPosition:o,onSelected:s}=e,c=bN(null),l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=e=>(c.current=e,()=>{c.current===e&&(c.current=null)}),t[0]=l):l=t[0];let u=TN(l),d;t[1]!==i||t[2]!==n||t[3]!==s||t[4]!==r||t[5]!==a?(d=e=>{if(!r||!n)return;if(c.current?.(e)){s();return}let t=i.composer().getState().text,o=t.slice(0,r.offset),l=t.slice(r.offset+a.length+r.query.length),u=()=>{let t=n.formatter.serialize(e);i.composer().setText(o+t+(l.startsWith(` `)?l:` ${l}`))};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?i.composer().setText(o+(l.startsWith(` `)?l.slice(1):l)):u(),n.onExecute(e)),s()},t[1]=i,t[2]=n,t[3]=s,t[4]=r,t[5]=a,t[6]=d):d=t[6];let f=TN(d),p;t[7]!==s||t[8]!==o||t[9]!==r?(p=()=>{s(),r&&o(r.offset)},t[7]=s,t[8]=o,t[9]=r,t[10]=p):p=t[10];let m=TN(p),h;return t[11]!==m||t[12]!==u||t[13]!==f?(h={selectItem:f,close:m,registerSelectItemOverride:u},t[11]=m,t[12]=u,t[13]=f,t[14]=h):h=t[14],h}),uU=PN(e=>{let t=Z(46),{adapter:n,text:r,triggerChar:i,behavior:a,aui:o,popoverId:s,isLoading:c}=e,l;t[0]!==r||t[1]!==i?(l=iU({text:r,triggerChar:i}),t[0]=r,t[1]=i,t[2]=l):l=t[2];let u=XN(l),d=u.trigger!==null&&n!==void 0&&a!==void 0,f;t[3]!==n||t[4]!==u.query||t[5]!==d?(f=cU({adapter:n,query:u.query,open:d}),t[3]=n,t[4]=u.query,t[5]=d,t[6]=f):f=t[6];let p=XN(f),m;t[7]===p?m=t[8]:(m=()=>{p.goBack()},t[7]=p,t[8]=m);let h=TN(m),g;t[9]!==o||t[10]!==a||t[11]!==u.setCursorPosition||t[12]!==u.trigger||t[13]!==h||t[14]!==i?(g=lU({behavior:a,trigger:u.trigger,aui:o,triggerChar:i,setCursorPosition:u.setCursorPosition,onSelected:h}),t[9]=o,t[10]=a,t[11]=u.setCursorPosition,t[12]=u.trigger,t[13]=h,t[14]=i,t[15]=g):g=t[15];let _=XN(g),v;t[16]!==u.query||t[17]!==p.activeCategoryId||t[18]!==p.goBack||t[19]!==p.isSearchMode||t[20]!==p.navigableList||t[21]!==p.selectCategory||t[22]!==d||t[23]!==s||t[24]!==_.close||t[25]!==_.selectItem?(v=oU({navigableList:p.navigableList,isSearchMode:p.isSearchMode,activeCategoryId:p.activeCategoryId,query:u.query,popoverId:s,open:d,selectItem:_.selectItem,selectCategory:p.selectCategory,goBack:p.goBack,close:_.close}),t[16]=u.query,t[17]=p.activeCategoryId,t[18]=p.goBack,t[19]=p.isSearchMode,t[20]=p.navigableList,t[21]=p.selectCategory,t[22]=d,t[23]=s,t[24]=_.close,t[25]=_.selectItem,t[26]=v):v=t[26];let y=XN(v),b;return t[27]!==u.query||t[28]!==u.setCursorPosition||t[29]!==c||t[30]!==y.handleKeyDown||t[31]!==y.highlightIndex||t[32]!==y.highlightedIndex||t[33]!==y.highlightedItemId||t[34]!==p.activeCategoryId||t[35]!==p.categories||t[36]!==p.goBack||t[37]!==p.isSearchMode||t[38]!==p.items||t[39]!==p.selectCategory||t[40]!==d||t[41]!==s||t[42]!==_.close||t[43]!==_.registerSelectItemOverride||t[44]!==_.selectItem?(b={open:d,query:u.query,activeCategoryId:p.activeCategoryId,categories:p.categories,items:p.items,highlightedIndex:y.highlightedIndex,isSearchMode:p.isSearchMode,isLoading:c,popoverId:s,highlightedItemId:y.highlightedItemId,selectCategory:p.selectCategory,goBack:p.goBack,selectItem:_.selectItem,close:_.close,highlightIndex:y.highlightIndex,handleKeyDown:y.handleKeyDown,setCursorPosition:u.setCursorPosition,registerSelectItemOverride:_.registerSelectItemOverride},t[27]=u.query,t[28]=u.setCursorPosition,t[29]=c,t[30]=y.handleKeyDown,t[31]=y.highlightIndex,t[32]=y.highlightedIndex,t[33]=y.highlightedItemId,t[34]=p.activeCategoryId,t[35]=p.categories,t[36]=p.goBack,t[37]=p.isSearchMode,t[38]=p.items,t[39]=p.selectCategory,t[40]=d,t[41]=s,t[42]=_.close,t[43]=_.registerSelectItemOverride,t[44]=_.selectItem,t[45]=b):b=t[45],b}),dU=ON(null),fU=()=>{let e=AN(dU);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},pU=()=>AN(dU),mU=ON(null),hU=()=>{let e=AN(mU);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},gU=(0,X.forwardRef)((e,t)=>{let n=Z(61),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({char:a,adapter:r,isLoading:c,"aria-label":i,children:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=c!==void 0&&c,u=eF(),d=Q(_U),f=(0,X.useId)(),p=bN(null),[m,h]=vN(null),g=bN(0),_;n[7]===a?_=n[8]:(_=e=>(g.current+=1,p.current=e,h(e),()=>{g.current=Math.max(0,g.current-1),p.current===e&&(p.current=null,h(null))}),n[7]=a,n[8]=_);let v=_,y;n[9]===v?y=n[10]:(y={register:v},n[9]=v,n[10]=y);let b=y,x=m??void 0,S;n[11]!==r||n[12]!==u||n[13]!==a||n[14]!==l||n[15]!==f||n[16]!==x||n[17]!==d?(S=uU({adapter:r,text:d,triggerChar:a,behavior:x,aui:u,popoverId:f,isLoading:l}),n[11]=r,n[12]=u,n[13]=a,n[14]=l,n[15]=f,n[16]=x,n[17]=d,n[18]=S):S=n[18];let C=XN(S),w;n[19]===C?w=n[20]:(w=()=>C,n[19]=C,n[20]=w);let T=TN(w),E=HH(),D;n[21]!==m||n[22]!==a||n[23]!==T||n[24]!==E?(D=()=>E.register({char:a,...m?{behavior:m}:{},resource:T()}),n[21]=m,n[22]=a,n[23]=T,n[24]=E,n[25]=D):D=n[25];let O;n[26]!==m||n[27]!==a||n[28]!==E?(O=[E,a,m],n[26]=m,n[27]=a,n[28]=E,n[29]=O):O=n[29],CN(D,O);let k=IH(),A;n[30]!==T||n[31]!==k?(A=()=>{if(k)return k.register(T())},n[30]=T,n[31]=k,n[32]=A):A=n[32];let j;n[33]===k?j=n[34]:(j=[k],n[33]=k,n[34]=j),CN(A,j);let M=m!==null&&C.open,N=WH(),P,F;n[35]!==N||n[36]!==a||n[37]!==M?(P=()=>{if(M)return()=>{N.setActiveAria(a,null)}},F=[N,a,M],n[35]=N,n[36]=a,n[37]=M,n[38]=P,n[39]=F):(P=n[38],F=n[39]),CN(P,F);let I,L;n[40]!==N||n[41]!==a||n[42]!==M||n[43]!==f||n[44]!==C.highlightedItemId?(I=()=>{M&&N.setActiveAria(a,{popoverId:f,highlightedItemId:C.highlightedItemId})},L=[N,a,f,M,C.highlightedItemId],n[40]=N,n[41]=a,n[42]=M,n[43]=f,n[44]=C.highlightedItemId,n[45]=I,n[46]=L):(I=n[45],L=n[46]),CN(I,L);let R;n[47]!==i||n[48]!==o||n[49]!==t||n[50]!==M||n[51]!==f||n[52]!==s||n[53]!==C.highlightedItemId?(R=M?(0,J.jsx)(VV.div,{role:`listbox`,id:f,"aria-label":i??`Suggestions`,"aria-activedescendant":C.highlightedItemId,"data-state":`open`,...s,ref:t,children:o}):o,n[47]=i,n[48]=o,n[49]=t,n[50]=M,n[51]=f,n[52]=s,n[53]=C.highlightedItemId,n[54]=R):R=n[54];let ee;n[55]!==C||n[56]!==R?(ee=(0,J.jsx)(dU.Provider,{value:C,children:R}),n[55]=C,n[56]=R,n[57]=ee):ee=n[57];let z;return n[58]!==b||n[59]!==ee?(z=(0,J.jsx)(mU.Provider,{value:b,children:ee}),n[58]=b,n[59]=ee,n[60]=z):z=n[60],z});gU.displayName=`ComposerPrimitive.TriggerPopover`;function _U(e){return e.composer.text}var vU=()=>{let e=Z(2),{disabled:t,send:n}=MB(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},yU=QV(`ComposerPrimitive.Send`,vU),bU=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onSubmit:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=vU(),o;n[3]===a?o=n[4]:(o=e=>{e.preventDefault(),a&&a()},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=Zy(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,J.jsx)(VV.form,{...i,ref:t,onSubmit:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});bU.displayName=`ComposerPrimitive.Root`;var xU=e=>{let t=Z(4),n=yd(e),r=gV(SU),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),CN(i,a)};function SU(e){return e.onScrollToBottom}var CU=()=>!1,wU=()=>{},TU=e=>{let t=Z(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null)return wU;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),EN(r,i,CU)};function EU(){return EU=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},EU.apply(null,arguments)}function DU(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var OU=q.useLayoutEffect,kU=function(e){var t=q.useRef(e);return OU(function(){t.current=e}),t},AU=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},jU=function(e,t){var n=q.useRef();return q.useCallback(function(r){e.current=r,n.current&&AU(n.current,null),n.current=t,t&&AU(t,r)},[t])},MU={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},NU=function(e){Object.keys(MU).forEach(function(t){e.style.setProperty(t,MU[t],`important`)})},PU=null,FU=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function IU(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),PU||(PU=document.createElement(`textarea`),PU.setAttribute(`tabindex`,`-1`),PU.setAttribute(`aria-hidden`,`true`),NU(PU)),PU.parentNode===null&&document.body.appendChild(PU);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;PU.style[t]=o[t]}),NU(PU),PU.value=t;var c=FU(PU,e);PU.value=t,c=FU(PU,e),PU.value=`x`;var l=PU.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var LU=function(){},RU=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},zU=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],BU=!!document.documentElement.currentStyle,VU=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=RU(zU,t),r=n.boxSizing;return r===``?null:(BU&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function HU(e,t,n){var r=kU(n);q.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var UU=function(e,t){HU(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},WU=function(e){HU(window,`resize`,e)},GU=function(e){HU(document.fonts,`loadingdone`,e)},KU=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],qU=q.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?LU:a,s=e.onHeightChange,c=s===void 0?LU:s,l=DU(e,KU),u=l.value!==void 0,d=q.useRef(null),f=jU(d,t),p=q.useRef(0),m=q.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:VU(e);if(t){m.current=t;var a=IU(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return q.useLayoutEffect(h),UU(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),WU(h),GU(h),q.createElement(`textarea`,EU({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),JU=`(pointer: coarse) and (not (any-pointer: fine))`,YU=(0,X.forwardRef)(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:h=!0,...g},_)=>{let v=eF(),y=IH(),b=ZH(),x=l??(c===!1?`none`:`enter`),S=TU(m?JU:null),C=m&&S&&x===`enter`?`none`:x,w=Q(e=>e.composer.isEditing?e.composer.text:``),T=Q(e=>e.thread.isDisabled||e.composer.dictation?.inputDisabled)||r,E=bN(null),D=ic(_,E),O=bN(!1);pm(e=>{if(!E.current?.contains(e.target))return;if(y){for(let t of y.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=v.composer();t.getState().canCancel&&(t.cancel(),e.preventDefault())});let k=e=>{if(!T&&!e.nativeEvent.isComposing){if(y){for(let t of y.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=v.thread().getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&x!==`none`&&v.composer().getState().canSend){e.preventDefault(),v.composer().send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;C===`ctrlEnter`?r=e.ctrlKey||e.metaKey:C===`enter`&&(r=!0),r&&(e.preventDefault(),E.current?.closest(`form`)?.requestSubmit())}}},A=async e=>{if(!h)return;let t=v.thread().getState().capabilities,n=Array.from(e.clipboardData?.files||[]);if(t.attachments&&n.length>0)try{e.preventDefault(),await Promise.all(n.map(e=>v.composer().addAttachment(e)))}catch(e){console.error(`Error adding attachment:`,e)}},j=e&&!T,M=SN(()=>{let e=E.current;!e||!j||(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[j]);CN(()=>M(),[M]),xU(()=>{v.composer().getState().type===`thread`&&f&&M()}),CN(()=>{if(!(v.composer().getState().type!==`thread`||!d))return v.on(`thread.runStart`,M)},[d,M,v]),CN(()=>{if(!(v.composer().getState().type!==`thread`||!p))return v.on(`threadListItem.switchedTo`,M)},[p,M,v]);let N=b?{"aria-controls":b.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":b.highlightedItemId}:{},P={name:`input`,value:w,...g,...N,ref:D,disabled:T,onChange:Zy(i,e=>{if(!v.composer().getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;O.current&&!t&&(O.current=!1);let n=t||O.current;if(RN(()=>{v.composer().setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(y)for(let e of y.getPlugins())e.setCursorPosition(r)}),onKeyDown:Zy(a,k),onCompositionStart:Zy(g.onCompositionStart,()=>{O.current=!0}),onCompositionEnd:Zy(g.onCompositionEnd,e=>{if(O.current=!1,!v.composer().getState().isEditing)return;let t=e.target;RN(()=>{v.composer().setText(t.value)});let n=t.selectionStart??t.value.length;if(y)for(let e of y.getPlugins())e.setCursorPosition(n)}),onSelect:Zy(s,e=>{if(O.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(y)for(let e of y.getPlugins())e.setCursorPosition(n)}),onPaste:Zy(o,A)};if(n&&(0,X.isValidElement)(n)){let e=g.children===void 0?n.props.children:g.children;return(0,J.jsx)(Ub,{...P,children:(0,X.cloneElement)(n,void 0,e)})}return(0,J.jsx)(t?Ub:qU,{...P})});YU.displayName=`ComposerPrimitive.Input`;var XU=QV(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=PB();return e?null:t}),ZU=QV(`ComposerPrimitive.AddAttachment`,e=>{let t=Z(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=RB(),s=eF(),c;return t[2]!==o||t[3]!==s||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer().getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=t=>{let n=t.target.files;if(n){for(let e of n)o(e);document.body.removeChild(e)}},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),QU=(0,X.forwardRef)((e,t)=>{let n=Z(30),{disabled:r,asChild:i,render:a,children:o,...s}=e,c=i!==void 0&&i,[l,u]=vN(!1),d=eF(),f;n[0]===r?f=n[1]:(f=e=>{r||(e.preventDefault(),u(!0))},n[0]=r,n[1]=f);let p=f,m;n[2]!==r||n[3]!==l?(m=e=>{r||(e.preventDefault(),l||u(!0))},n[2]=r,n[3]=l,n[4]=m):m=n[4];let h=m,g;n[5]===r?g=n[6]:(g=e=>{if(r)return;e.preventDefault();let t=e.relatedTarget;t&&e.currentTarget.contains(t)||u(!1)},n[5]=r,n[6]=g);let _=g,v;n[7]!==d||n[8]!==r?(v=async e=>{if(r)return;e.preventDefault(),u(!1);let t=Array.from(e.dataTransfer.files);await Promise.all(t.map(async e=>{try{await d.composer().addAttachment(e)}catch(e){console.error(`Failed to add attachment:`,e)}}))},n[7]=d,n[8]=r,n[9]=v):v=n[9];let y=v,b;n[10]===l?b=n[11]:(b=l?{"data-dragging":`true`}:null,n[10]=l,n[11]=b);let x=Zy(s.onDragEnterCapture,p),S=Zy(s.onDragOverCapture,h),C=Zy(s.onDragLeaveCapture,_),w=Zy(s.onDropCapture,y),T;n[12]!==t||n[13]!==s||n[14]!==w||n[15]!==b||n[16]!==x||n[17]!==S||n[18]!==C?(T={...b,...s,onDragEnterCapture:x,onDragOverCapture:S,onDragLeaveCapture:C,onDropCapture:w,ref:t},n[12]=t,n[13]=s,n[14]=w,n[15]=b,n[16]=x,n[17]=S,n[18]=C,n[19]=T):T=n[19];let E=T;if(a&&(0,X.isValidElement)(a)){let e=o===void 0?a.props.children:o,t;n[20]!==a||n[21]!==e?(t=(0,X.cloneElement)(a,void 0,e),n[20]=a,n[21]=e,n[22]=t):t=n[22];let r;return n[23]!==E||n[24]!==t?(r=(0,J.jsx)(Ub,{...E,children:t}),n[23]=E,n[24]=t,n[25]=r):r=n[25],r}let D=c?Ub:`div`,O;return n[26]!==D||n[27]!==o||n[28]!==E?(O=(0,J.jsx)(D,{...E,children:o}),n[26]=D,n[27]=o,n[28]=E,n[29]=O):O=n[29],O});QU.displayName=`ComposerPrimitive.AttachmentDropzone`;var $U=QV(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=IB();return e?null:t}),eW=QV(`ComposerPrimitive.StopDictation`,()=>{let e=Z(2),t=eF(),n=Q(tW),r;return e[0]===t?r=e[1]:(r=()=>{t.composer().stopDictation()},e[0]=t,e[1]=r),n?r:null});function tW(e){return e.composer.dictation!=null}var nW=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(rW);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(VV.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});nW.displayName=`ComposerPrimitive.DictationTranscript`;function rW(e){return e.composer.dictation?.transcript}var iW=(0,X.forwardRef)((e,t)=>{let n=Z(3);if(!Q(sW))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,J.jsx)(VV.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});iW.displayName=`ComposerPrimitive.Quote`;var aW=(0,X.forwardRef)((e,t)=>{let n=Z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=Q(cW);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,J.jsx)(VV.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});aW.displayName=`ComposerPrimitive.QuoteText`;var oW=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=eF(),o;n[3]===a?o=n[4]:(o=()=>{a.composer().setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=Zy(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,J.jsx)(VV.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});oW.displayName=`ComposerPrimitive.QuoteDismiss`;function sW(e){return e.composer.quote}function cW(e){return e.composer.quote?.text}var lW=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=fU();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,J.jsx)(VV.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});lW.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var uW=(0,X.forwardRef)((e,t)=>{let n=Z(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=fU(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=Zy(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=Zy(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,J.jsx)(VV.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});uW.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var dW=(0,X.forwardRef)((e,t)=>{let n=Z(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=fU();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,J.jsx)(VV.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});dW.displayName=`ComposerPrimitive.TriggerPopoverItems`;var fW=(0,X.forwardRef)((e,t)=>{let n=Z(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=fU(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=Zy(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=Zy(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,J.jsx)(VV.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});fW.displayName=`ComposerPrimitive.TriggerPopoverItem`;var pW=(0,X.forwardRef)((e,t)=>{let n=Z(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=fU();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=Zy(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,J.jsx)(VV.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});pW.displayName=`ComposerPrimitive.TriggerPopoverBack`;var mW=({formatter:e,onExecute:t,removeOnExecute:n})=>{let{register:r}=hU(),i=bN(t);return i.current=t,CN(()=>r({kind:`action`,formatter:e??fV,onExecute:e=>i.current(e),...n===void 0?{}:{removeOnExecute:n}}),[r,e,n]),null};mW.displayName=`ComposerPrimitive.TriggerPopoverAction`;var hW=({formatter:e,onInserted:t})=>{let{register:n}=hU(),r=bN(t);return r.current=t,CN(()=>n({kind:`directive`,formatter:e??fV,onInserted:e=>r.current?.(e)}),[n,e]),null};hW.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var gW=Object.assign(gU,{Directive:hW,Action:mW}),_W=LV({AddAttachment:()=>ZU,AttachmentByIndex:()=>vB,AttachmentDropzone:()=>QU,Attachments:()=>bB,Cancel:()=>XU,Dictate:()=>$U,DictationTranscript:()=>nW,If:()=>jB,Input:()=>YU,Queue:()=>SB,Quote:()=>iW,QuoteDismiss:()=>oW,QuoteText:()=>aW,Root:()=>bU,Send:()=>yU,StopDictation:()=>eW,Unstable_TriggerPopover:()=>gW,Unstable_TriggerPopoverBack:()=>pW,Unstable_TriggerPopoverCategories:()=>lW,Unstable_TriggerPopoverCategoryItem:()=>uW,Unstable_TriggerPopoverItem:()=>fW,Unstable_TriggerPopoverItems:()=>dW,Unstable_TriggerPopoverRoot:()=>eU,unstable_useTriggerPopoverRootContext:()=>HH,unstable_useTriggerPopoverRootContextOptional:()=>UH,unstable_useTriggerPopoverScopeContext:()=>fU,unstable_useTriggerPopoverScopeContextOptional:()=>pU,unstable_useTriggerPopoverTriggers:()=>GH,unstable_useTriggerPopoverTriggersOptional:()=>YH}),vW=()=>Q(yW);function yW(e){if(e.part.type!==`text`&&e.part.type!==`reasoning`)throw Error(`MessagePartText can only be used inside text or reasoning message parts.`);return e.part}var bW=ON(null);function xW(e){let t=AN(bW);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:ene,useSmoothStatusStore:SW}=mV(xW,`useSmoothStatus`),CW=250,wW=5,TW=class{currentText;setText;animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=CW;maxCharIntervalMs=wW;maxCharsPerFrame=1/0;minCommitMs=0;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),a===n?this.animationFrameId=null:this.animationFrameId=requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},EW=Object.freeze({type:`running`}),DW=(e,t)=>e!==void 0&&e>0?e:t,OW=(e,t=!1)=>{let{text:n}=e,r=typeof t==`object`&&t?t:void 0,i=t!==!1&&t!==null,a=DW(r?.drainMs,CW),o=DW(r?.maxCharIntervalMs,wW),s=DW(r?.maxCharsPerFrame,1/0),c=DW(r?.minCommitMs,0),[l,u]=vN(e.status.type===`running`?``:n),d=eF(),f=Q(()=>d.part()),[p,m]=vN(f);(f!==p||!n.startsWith(l))&&(m(f),u(e.status.type===`running`?``:n));let h=SW({optional:!0}),g=yd(t=>{if(u(t),h){let n=l!==t||e.status.type===`running`?EW:e.status;bV(h).setState(n,!0)}});CN(()=>{if(h){let t=i&&(l!==n||e.status.type===`running`)?EW:e.status;bV(h).setState(t,!0)}},[h,i,n,l,e.status]);let[_]=vN(new TW(l,g));CN(()=>{_.drainMs=a,_.maxCharIntervalMs=o,_.maxCharsPerFrame=s,_.minCommitMs=c},[_,a,o,s,c]);let v=bN(f);return CN(()=>{if(!i){_.stop();return}let t=v.current!==f;if(v.current=f,t||!n.startsWith(_.targetText)){e.status.type===`running`?(_.currentText=``,_.targetText=n,_.lastCommitTime=0,_.start()):(_.currentText=n,_.targetText=n,_.stop());return}_.targetText=n,_.start()},[_,i,n,e.status.type,f]),CN(()=>()=>{_.stop()},[_]),xN(()=>i?{...e,text:l,status:n===l?e.status:EW}:e,[i,l,e,n])},kW=()=>Q(AW);function AW(e){if(e.part.type!==`image`)throw Error(`MessagePartImage can only be used inside image message parts.`);return e.part}var jW=(0,X.forwardRef)((e,t)=>{let n=Z(10),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({smooth:i,component:a,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i===void 0||i,s=a===void 0?`span`:a,{text:c,status:l}=OW(vW(),o),u;return n[4]!==s||n[5]!==t||n[6]!==r||n[7]!==l.type||n[8]!==c?(u=(0,J.jsx)(s,{"data-status":l.type,...r,ref:t,children:c}),n[4]=s,n[5]=t,n[6]=r,n[7]=l.type,n[8]=c,n[9]=u):u=n[9],u});jW.displayName=`MessagePartPrimitive.Text`;var MW=(0,X.forwardRef)((e,t)=>{let n=Z(4),{image:r}=kW(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,J.jsx)(VV.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});MW.displayName=`MessagePartPrimitive.Image`;var NW=e=>{let t=Z(2),n=bN(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},PW=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},FW=e=>e.dataset.messageId,IW=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},LW=(e,t)=>{let n=`${t}px`;return e.style.height===n?!1:(e.style.height=n,!0)},RW=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},zW=()=>{let e=Z(4),t=eF(),n;e[0]===t?n=e[1]:(n=()=>t.message(),e[0]=t,e[1]=n);let r=Q(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),NW(i)},BW=()=>{let e=Z(2),t=gV(qW),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),Q(n)},VW=()=>{let e=Z(2),t=gV(JW),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),Q(n)},HW=(e,t)=>{let n=Z(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],NW(r)},UW=e=>{let t=Z(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:PW(i.tallerThan,e),visibleHeight:PW(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],NW(i)},WW=e=>{let t=Z(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=zW(),a=ic(n,i),o=Q(YW),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,J.jsx)(VV.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},GW=e=>{let t=Z(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=zW(),o=BW(),s=VW(),c=HW(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=UW(l),d=ic(n,a,c,u),f=Q(XW),p=o?``:void 0,m=s?``:void 0,h;return t[7]!==f||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==m?(h=(0,J.jsx)(VV.div,{...r,ref:d,"data-message-id":f,"data-aui-top-anchor-user":p,"data-aui-top-anchor-target":m}),t[7]=f,t[8]=r,t[9]=d,t[10]=p,t[11]=m,t[12]=h):h=t[12],h},KW=(0,X.forwardRef)((e,t)=>{let n=Z(7),r=_V();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,J.jsx)(GW,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,J.jsx)(WW,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});KW.displayName=`MessagePrimitive.Root`;function qW(e){return e.topAnchorTurn?.anchorId}function JW(e){return e.topAnchorTurn?.targetId}function YW(e){return e.message.id}function XW(e){return e.message.id}var ZW={...Sz,Text:()=>(0,J.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,J.jsx)(jW,{}),(0,J.jsx)(CB,{children:(0,J.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,J.jsx)(MW,{})},QW=e=>{let t=Z(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,J.jsx)(Rz,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{Text:n.Text??ZW.Text,Image:n.Image??ZW.Image,Reasoning:n.Reasoning??Sz.Reasoning,Source:n.Source??Sz.Source,File:n.File??Sz.File,Unstable_Audio:n.Unstable_Audio??Sz.Unstable_Audio,...`ChainOfThought`in n?{ChainOfThought:n.ChainOfThought}:{tools:n.tools,data:n.data,ToolGroup:n.ToolGroup??Sz.ToolGroup,ReasoningGroup:n.ReasoningGroup??Sz.ReasoningGroup},Empty:n.Empty,Quote:n.Quote,generativeUI:n.generativeUI}:ZW,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,J.jsx)(Rz,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};QW.displayName=`MessagePrimitive.Parts`;var $W=e=>{let{children:t}=e;return lV()===void 0?null:t};$W.displayName=`MessagePrimitive.Error`;var eG=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??`__ungrouped_${n}`,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=e.startsWith(`__ungrouped_`)?void 0:e;n.push({groupKey:t,indices:r})}return n},tG=e=>{let t=Z(4),n=Q(fG),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},nG=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>{let t=e.tools.tools[r.toolName]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},rG=e=>{let t=Z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=Q(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,J.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},iG={Text:()=>(0,J.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,J.jsx)(jW,{}),(0,J.jsx)(CB,{children:(0,J.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,J.jsx)(MW,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},aG=e=>{let t=Z(43),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?iG.Text:i,p=a===void 0?iG.Reasoning:a,m=o===void 0?iG.Image:o,h=s===void 0?iG.Source:s,g=c===void 0?iG.File:c,_=l===void 0?iG.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=eF(),x=Q(pG),S=x.type;if(S===`tool-call`){let e;t[4]===b?e=t[5]:(e=b.part(),t[4]=b,t[5]=e);let n=e.addToolResult,r;t[6]===b?r=t[7]:(r=b.part(),t[6]=b,t[7]=r);let i=r.resumeToolCall,a;t[8]===b?a=t[9]:(a=b.part(),t[8]=b,t[9]=a);let o=a.respondToToolApproval;if(`Override`in y){let e;return t[10]!==n||t[11]!==x||t[12]!==o||t[13]!==i||t[14]!==y.Override?(e=(0,J.jsx)(y.Override,{...x,addResult:n,resume:i,respondToApproval:o}),t[10]=n,t[11]=x,t[12]=o,t[13]=i,t[14]=y.Override,t[15]=e):e=t[15],e}let s=y.by_name?.[x.toolName]??y.Fallback,c;return t[16]!==s||t[17]!==n||t[18]!==x||t[19]!==o||t[20]!==i?(c=(0,J.jsx)(nG,{...x,Fallback:s,addResult:n,resume:i,respondToApproval:o}),t[16]=s,t[17]=n,t[18]=x,t[19]=o,t[20]=i,t[21]=c):c=t[21],c}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[22]!==f||t[23]!==x?(e=(0,J.jsx)(f,{...x}),t[22]=f,t[23]=x,t[24]=e):e=t[24],e}case`reasoning`:{let e;return t[25]!==p||t[26]!==x?(e=(0,J.jsx)(p,{...x}),t[25]=p,t[26]=x,t[27]=e):e=t[27],e}case`source`:{let e;return t[28]!==h||t[29]!==x?(e=(0,J.jsx)(h,{...x}),t[28]=h,t[29]=x,t[30]=e):e=t[30],e}case`image`:{let e;return t[31]!==m||t[32]!==x?(e=(0,J.jsx)(m,{...x}),t[31]=m,t[32]=x,t[33]=e):e=t[33],e}case`file`:{let e;return t[34]!==g||t[35]!==x?(e=(0,J.jsx)(g,{...x}),t[34]=g,t[35]=x,t[36]=e):e=t[36],e}case`audio`:{let e;return t[37]!==_||t[38]!==x?(e=(0,J.jsx)(_,{...x}),t[37]=_,t[38]=x,t[39]=e):e=t[39],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[40]!==e||t[41]!==x?(n=(0,J.jsx)(rG,{...x,Fallback:e}),t[40]=e,t[41]=x,t[42]=n):n=t[42],n}default:return console.warn(`Unknown message part type: ${S}`),null}},oG=(0,X.memo)(e=>{let t=Z(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,J.jsx)(aG,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,J.jsx)(GI,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),sG=e=>{let t=Z(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,J.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,J.jsx)(qI,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},cG=Object.freeze({type:`complete`}),lG=(0,X.memo)(e=>{let t=Z(6),{components:n}=e,r=Q(mG);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,J.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??iG.Text,a;return t[3]!==r||t[4]!==i?(a=(0,J.jsx)(sG,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),uG=e=>{let t=Z(9),{groupingFunction:n,components:r}=e,i=Q(hG),a=tG(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,J.jsx)(lG,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>(0,J.jsx)(r?.Group??iG.Group,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,J.jsx)(oG,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`),t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,J.jsx)(J.Fragment,{children:s}),t[7]=s,t[8]=c),c};uG.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var dG=e=>{let t=Z(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,J.jsx)(uG,{...r,components:n,groupingFunction:eG}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};dG.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function fG(e){return e.message.parts}function pG(e){return e.part}function mG(e){return e.message.status??cG}function hG(e){return e.message.parts.length}var gG=LV({AttachmentByIndex:()=>fB,Attachments:()=>mB,Content:()=>QW,Error:()=>$W,GenerativeUI:()=>oz,GroupedParts:()=>cB,If:()=>PH,PartByIndex:()=>wz,Parts:()=>QW,Quote:()=>lB,Root:()=>KW,Unstable_PartsGrouped:()=>uG,Unstable_PartsGroupedByParentId:()=>dG}),_G=e=>{let t=Z(2),n=yd(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(vG)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),NW(r)};function vG(e){return e.type!==`attributes`||e.attributeName!==`style`}var yG=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=bN(null),a=Q(e=>e.thread.messages.length>0),o=bN(!1),s=bN(null),c=_V();e===void 0&&(e=c.getState().turnAnchor!==`top`);let l=bN(0),u=bN(0),d=bN(0),f=bN(0),p=bN(null),m=SN(e=>{let t=i.current;t&&(p.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),h=SN(e=>{p.current=e,s.current!==null&&cancelAnimationFrame(s.current),s.current=requestAnimationFrame(()=>{s.current=null,m(e)})},[m]);wN(()=>()=>{s.current!==null&&cancelAnimationFrame(s.current)},[]);let g=SN(()=>{let e=c.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[c]),_=()=>{let e=i.current;if(!e)return;let t=c.getState().isAtBottom,n=Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight;!n&&l.current<e.scrollTop||(n?e.scrollHeight>e.clientHeight+1&&(p.current=null):l.current>e.scrollTop&&u.current===e.scrollHeight&&(p.current=null),(n||p.current===null)&&n!==t&&bV(c).setState({isAtBottom:n})),l.current=e.scrollTop,u.current=e.scrollHeight},v=_G(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===d.current&&r===f.current)return;d.current=n,f.current=r;let a=p.current;a&&g()?p.current=null:a?m(a):e&&c.getState().isAtBottom&&m(`instant`),_()}),y=NW(e=>{let t=()=>{p.current=null};return e.addEventListener(`scroll`,_),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,_),e.removeEventListener(`pointerdown`,t)}});return wN(()=>{if(n){if(!a){o.current=!1;return}o.current||(o.current=!0,p.current===null&&h(`instant`))}},[a,h,n]),xU(({behavior:e})=>{m(e)}),lF(`thread.runStart`,()=>{t&&c.getState().turnAnchor!==`top`&&h(`auto`)}),lF(`threadListItem.switchedTo`,()=>{r&&h(`instant`)}),ic(v,y,i)},bG=(0,X.forwardRef)((e,t)=>{let n=Z(3),r;return n[0]!==e||n[1]!==t?(r=(0,J.jsx)(VV.div,{...e,ref:t}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});bG.displayName=`ThreadPrimitive.Root`;var xG=e=>{let{children:t}=e;return Q(SG)?t:null};xG.displayName=`ThreadPrimitive.Empty`;function SG(e){return e.thread.isEmpty}var CG=e=>{let t=Z(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],Q(n)},wG=e=>{let t=Z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),CG(r)?n:null};wG.displayName=`ThreadPrimitive.If`;var TG=(e,t)=>{let n=Z(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],NW(r)},EG=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},DG=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:EG(e)-EG(t)},OG=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=DG(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},kG=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=OG(t)+n.clientHeight;return Math.max(0,r-e)},AG=({viewport:e,reserve:t,...n})=>kG({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),jG=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{r===e&&i===s&&a===c||(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},MG=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},NG=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o||!s||!c||!l){a.disconnect(),t&&(LW(t,0),t.remove());return}if(t??=IW(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),LW(t,AG({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=FW(s);if(u!==void 0&&n===u)return;let d=RW(OG({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=MG(r),a=jG(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},PG=e=>{let t=Z(4),n=_V(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return NG(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),wN(r,i)},FG=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},IG=e=>FG(e)?.anchorId,LG=e=>FG(e)?.targetId,RG=()=>TG(gV(UG),WG),zG=()=>NW(gV(GG)),BG=e=>{let t=Z(13),n=_V(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return IG(t.thread)},t[0]=e,t[1]=r);let i=Q(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return LG(t.thread)},t[2]=e,t[3]=a);let o=Q(a),s;bb0:{if(!i||!o){s=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],s=e}let c=s,l,u;t[7]!==c||t[8]!==n?(l=()=>{if(!c)return;let e=n.getState(),t=e.topAnchorTurn;t?.anchorId===c.anchorId&&t.targetId===c.targetId||e.setTopAnchorTurn(c)},u=[c,n],t[7]=c,t[8]=n,t[9]=l,t[10]=u):(l=t[9],u=t[10]),wN(l,u);let d;t[11]===n?d=t[12]:(d=()=>{n.getState().setTopAnchorTurn(null)},t[11]=n,t[12]=d);let f=d;lF(`thread.initialize`,f),lF(`threadListItem.switchedTo`,f)},VG=(0,X.forwardRef)((e,t)=>{let n=Z(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=yG(l),d=RG(),f=zG(),p=_V(),m;n[12]===p?m=n[13]:(m=p.getState(),n[12]=p,n[13]=m);let h=m.turnAnchor===`top`;BG(h),PG(h);let g=ic(t,u,d,f),_;return n[14]!==i||n[15]!==g||n[16]!==a?(_=(0,J.jsx)(VV.div,{...a,ref:g,children:i}),n[14]=i,n[15]=g,n[16]=a,n[17]=_):_=n[17],_});VG.displayName=`ThreadPrimitive.ViewportScrollable`;var HG=(0,X.forwardRef)((e,t)=>{let n=Z(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,J.jsx)(VG,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,J.jsx)(SV,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});HG.displayName=`ThreadPrimitive.Viewport`;function UG(e){return e.registerViewport}function WG(e){return e.clientHeight}function GG(e){return e.registerViewportElement}var KG=(0,X.forwardRef)((e,t)=>{let n=Z(3),r=ic(t,TG(gV(qG),JG)),i;return n[0]!==e||n[1]!==r?(i=(0,J.jsx)(VV.div,{...e,ref:r}),n[0]=e,n[1]=r,n[2]=i):i=n[2],i});KG.displayName=`ThreadPrimitive.ViewportFooter`;function qG(e){return e.registerContentInset}function JG(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var YG=QV(`ThreadPrimitive.ScrollToBottom`,e=>{let t=Z(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=gV(XG),a=_V(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function XG(e){return e.isAtBottom}var ZG=QV(`ThreadPrimitive.Suggestion`,e=>{let t=Z(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=sV(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),QG=LV({Empty:()=>xG,If:()=>wG,MessageByIndex:()=>JR,Messages:()=>ZR,Root:()=>bG,ScrollToBottom:()=>YG,Suggestion:()=>ZG,SuggestionByIndex:()=>EB,Suggestions:()=>kB,Viewport:()=>HG,ViewportFooter:()=>KG,ViewportProvider:()=>SV});function $G(e,t){let n=[],r=0;for(let i of e)t.has(i.messageId)?n.push(i):r++;return n.sort((e,n)=>{let r=t.get(e.messageId),i=t.get(n.messageId);if(r!==i)return r-i;let a=e.blockIndex??-1,o=n.blockIndex??-1;return a===o?e.createdAt-n.createdAt:a-o}),{ordered:n,unreachableCount:r}}function eK(e,t,n){if(e.length===0)return null;let r=t===null?-1:e.indexOf(t);return r===-1?n===1?e[0]:e[e.length-1]:e[(r+n+e.length)%e.length]}function tK(e){let t=[];for(let n of e.querySelectorAll(`.oc-md`))if(n.closest(`.oc-msg__meta`)===null)for(let e of n.children)e.tagName===`OL`||e.tagName===`UL`?t.push(...e.children):t.push(e);return t}function nK(e,t){return t===null?e:tK(e)[t]??e}function rK(e,t){let n=null,r=1/0;for(let i of e){let e=Math.abs(i.center-t);e<r&&(r=e,n=i.id)}return n}function iK(e,t=48){let n=e.replace(/\s+/g,` `).trim(),r=Array.from(n);if(r.length<=t)return n;let i=r.slice(0,t).join(``),a=i.lastIndexOf(` `);return(a>t*.6?i.slice(0,a):i)+`…`}var aK=(0,q.createContext)(null);function oK(){return(0,q.useContext)(aK)}function sK(e,t,n,r){let i=!1,a=0,o=0,s=()=>{if(i)return;let c=document.querySelector(`[data-message-id="${CSS.escape(e)}"]`);if(c){let e=nK(c,t),i=c.closest(`.oc-thread__viewport`);if(!(()=>{if(!r?.skipScrollIfVisible||!i)return!1;let t=e.getBoundingClientRect(),n=i.getBoundingClientRect();return t.top>=n.top&&t.top<=n.bottom-48})())if(i){let t=e.getBoundingClientRect().top-i.getBoundingClientRect().top;i.scrollTo({top:i.scrollTop+t-Math.max(24,i.clientHeight*.3),behavior:n})}else e.scrollIntoView({block:`center`,behavior:n});let a=t===null?c:e,o=t===null?`oc-msg--highlight`:`oc-anchor--flash`;a.classList.remove(o),a.offsetWidth,a.classList.add(o),window.setTimeout(()=>a.classList.remove(o),2400);return}a++<40&&(o=window.setTimeout(s,150))};return o=window.setTimeout(s,0),()=>{i=!0,window.clearTimeout(o)}}function cK({chatId:e,focusMessageId:t,children:n}){let r=U(G.chatBookmarks.getBookmarks,{chatId:e}),i=W(G.chatBookmarks.toggleBookmark),a=W(G.chatBookmarks.removeBookmark),o=W(G.chatBookmarks.renameBookmark),s=W(G.chatBookmarks.setActiveBookmark),[c,l]=(0,q.useState)(null);(0,q.useEffect)(()=>{l(null)},[e]);let u=r?.activeBookmarkId??null;(0,q.useEffect)(()=>{c!==null&&u===c&&l(null)},[u,c]);let d=(0,q.useMemo)(()=>(r?.bookmarks??[]).map(e=>({id:e._id,messageId:e.messageId,blockIndex:e.blockIndex,label:e.label,createdAt:e.createdAt})),[r?.bookmarks]),f=c??u,p=(0,q.useMemo)(()=>{let e=new Map;for(let t of d){let n=e.get(t.messageId);n?n.push(t):e.set(t.messageId,[t])}return e},[d]),m=(0,q.useCallback)(t=>{l(t.id),sK(t.messageId,t.blockIndex,`smooth`),s({chatId:e,bookmarkId:t.id})},[e,s]),h=(0,q.useCallback)(t=>{l(t),s({chatId:e,bookmarkId:t})},[e,s]),g=(0,q.useMemo)(()=>({rows:d,activeId:f,byMessage:p,toggle:(t,n)=>void i({chatId:e,messageId:t,...n===null?{}:{blockIndex:n}}).then(e=>{e?.placed===!0&&sK(t,n,`smooth`,{skipScrollIfVisible:!0})}),remove:e=>void a({bookmarkId:e}),rename:(e,t)=>void o({bookmarkId:e,label:t}),jumpTo:m,setActiveQuiet:h}),[d,f,p,e,i,a,o,m,h]),_=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(_.current===e||r===void 0||(_.current=e,t!==null)||f===null)return;let n=d.find(e=>e.id===f);if(n!==void 0)return sK(n.messageId,n.blockIndex,`auto`)},[e,r===void 0]),(0,J.jsx)(aK.Provider,{value:g,children:n})}function lK(e){let t=e.target;return t instanceof HTMLElement?t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable:!1}function uK(e){if(e.label!==null&&e.label.length>0)return e.label;let t=document.querySelector(`[data-message-id="${CSS.escape(e.messageId)}"]`);if(t){let n=iK(nK(t,e.blockIndex).textContent??``);if(n.length>0)return n}return Fu()}function dK(){let e=oK(),t=FV(e=>e.messages.length),[n,r]=(0,q.useState)([]),[i,a]=(0,q.useState)(0),o=e?.rows;(0,q.useEffect)(()=>{if(!o||o.length===0){r([]),a(0);return}let e=!1,t=0,n=0,i=()=>{if(e)return;let s=new Map;document.querySelectorAll(`.oc-thread__viewport [data-message-id]`).forEach((e,t)=>s.set(e.dataset.messageId??``,t));let c=$G(o,s);r(c.ordered),a(c.unreachableCount),c.ordered.length===0&&t++<40&&(n=window.setTimeout(i,150))};return i(),()=>{e=!0,window.clearTimeout(n)}},[o,t]);let[s,c]=(0,q.useState)(null),l=(0,q.useRef)(0),u=(0,q.useRef)(null),d=s!==null&&n.some(e=>e.id===s)?s:e?.activeId??null;(0,q.useEffect)(()=>{if(!e||n.length===0)return;let t=document.querySelector(`.oc-thread__viewport`);if(!t)return;let r=0,i=0,a=()=>{r===0&&(r=window.requestAnimationFrame(()=>{if(r=0,Date.now()-l.current<1200)return;let a=t.getBoundingClientRect(),o=a.top+a.height/2,s=[];for(let e of n){let n=t.querySelector(`[data-message-id="${CSS.escape(e.messageId)}"]`);if(!n)continue;let r=nK(n,e.blockIndex).getBoundingClientRect();s.push({id:e.id,center:(r.top+r.bottom)/2})}let d=rK(s,o);d!==null&&(c(d),u.current=d===e.activeId?null:d,window.clearTimeout(i),i=window.setTimeout(()=>{let t=u.current;u.current=null,t!==null&&e.setActiveQuiet(t)},800))}))};return t.addEventListener(`scroll`,a,{passive:!0}),()=>{t.removeEventListener(`scroll`,a),r!==0&&window.cancelAnimationFrame(r),window.clearTimeout(i);let n=u.current;u.current=null,n!==null&&e.setActiveQuiet(n)}},[e,n]);let f=(0,q.useCallback)(t=>{e&&(l.current=Date.now(),c(t.id),e.jumpTo(t))},[e]),p=(0,q.useCallback)(e=>{let t=eK(n.map(e=>e.id),d,e),r=n.find(e=>e.id===t);r&&f(r)},[n,d,f]);if((0,q.useEffect)(()=>{if(n.length===0)return;let e=e=>{lK(e)||(Ew(e,Sw)?(e.preventDefault(),p(-1)):Ew(e,Tw)&&(e.preventDefault(),p(1)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n.length,p]),!e||e.rows.length===0)return null;let m=n.findIndex(e=>e.id===d),h=`${m===-1?`–`:m+1}/${n.length}`;return(0,J.jsxs)(`div`,{className:`oc-bmk-rail`,role:`navigation`,"aria-label":Si(),title:i>0?An({count:String(i)}):void 0,children:[(0,J.jsx)(K,{variant:`ghost`,size:`icon`,className:`oc-bmk-rail__btn`,onClick:()=>p(-1),disabled:n.length===0,title:`${Xr()} (${ww(Sw,Cw())})`,"aria-label":Xr(),children:(0,J.jsx)($S,{size:14})}),(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-bmk-rail__count`,title:Rc(),"aria-label":Rc(),children:[(0,J.jsx)(cA,{size:11,"aria-hidden":!0}),(0,J.jsx)(`span`,{"aria-live":`polite`,children:h})]})}),(0,J.jsxs)(fC,{side:`left`,align:`center`,className:`oc-bmk-menu`,children:[n.map(e=>(0,J.jsxs)(hC,{className:e.id===d?`oc-bmk-menu__item--current`:void 0,onSelect:()=>f(e),children:[(0,J.jsx)(cA,{size:12,"aria-hidden":!0,className:`oc-bmk-menu__flag`}),(0,J.jsx)(`span`,{className:`oc-bmk-menu__text`,children:uK(e)})]},e.id)),i>0?(0,J.jsx)(`div`,{className:`oc-bmk-menu__foot`,children:An({count:String(i)})}):null]})]}),(0,J.jsx)(K,{variant:`ghost`,size:`icon`,className:`oc-bmk-rail__btn`,onClick:()=>p(1),disabled:n.length===0,title:`${Q_()} (${ww(Tw,Cw())})`,"aria-label":Q_(),children:(0,J.jsx)(XS,{size:14})})]})}var fK=class extends q.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){}render(){return this.state.failed?null:this.props.children}};function pK(e={}){return(0,J.jsx)(fK,{children:(0,J.jsx)(mK,{...e})})}function mK({messageLevelMarkers:e=!0,onReplyToBlock:t}={}){let n=oK(),r=$(e=>e.id),i=$(e=>e.status?.type===`running`),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),[u,d]=(0,q.useState)(new Map),f=n?.byMessage.get(r),p=(0,q.useMemo)(()=>e?f:f?.filter(e=>e.blockIndex!==null),[f,e]);if((0,q.useEffect)(()=>{let e=a.current?.closest(`.oc-msg`);s(e?.querySelector(`.oc-msg__body`)??e?.querySelector(`.oc-msg__bubble`)??null)},[r]),(0,q.useEffect)(()=>{if(!o||i||!n)return;let e=o.closest(`.oc-msg`)??o,t=0,r=e=>{t===0&&(t=window.requestAnimationFrame(()=>{t=0;let n=tK(o),r=o.getBoundingClientRect().top,i=null,a=1/0;for(let t=0;t<n.length;t++){let o=n[t].getBoundingClientRect();if(e.clientY>=o.top&&e.clientY<=o.bottom){l({top:o.top-r,blockIndex:t});return}let s=e.clientY<o.top?o.top-e.clientY:e.clientY-o.bottom;s<a&&(a=s,i={top:o.top-r,blockIndex:t})}l(a<=16?i:null)}))},a=()=>{t!==0&&(window.cancelAnimationFrame(t),t=0),l(null)};return e.addEventListener(`mousemove`,r),e.addEventListener(`mouseleave`,a),()=>{e.removeEventListener(`mousemove`,r),e.removeEventListener(`mouseleave`,a),t!==0&&window.cancelAnimationFrame(t)}},[o,i,n]),(0,q.useEffect)(()=>{if(!o||!p||p.length===0){d(new Map);return}let e=()=>{let e=o.getBoundingClientRect().top,t=new Map;for(let n of p){let r=nK(o,n.blockIndex);t.set(n.id,r.getBoundingClientRect().top-e)}d(t)};e();let t=new ResizeObserver(e);return t.observe(o),()=>t.disconnect()},[o,p]),!n||!o)return(0,J.jsx)(`span`,{ref:a,hidden:!0});let m=c!==null&&(p??[]).some(e=>e.blockIndex===c.blockIndex);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{ref:a,hidden:!0}),(0,vk.createPortal)((0,J.jsxs)(J.Fragment,{children:[c!==null&&!i?(0,J.jsxs)(`span`,{className:`oc-bmk-gutterrow`,style:{top:c.top},children:[t?(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-gutter oc-bmk-gutter--reply`,title:of(),"aria-label":of(),onClick:()=>{let e=iK(nK(o,c.blockIndex).textContent??``,280);e!==``&&t(c.blockIndex,e)},children:(0,J.jsx)(nj,{size:14})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-gutter${m?` is-set`:``}`,title:m?v():Rp(),"aria-label":m?v():Rp(),onClick:()=>n.toggle(r,c.blockIndex),children:(0,J.jsx)(cA,{size:14})})]}):null,(p??[]).map(e=>{let t=u.get(e.id);return t===void 0?null:(0,J.jsx)(gK,{bookmark:e,top:t},e.id)})]}),o)]})}function hK({bookmark:e,trigger:t}){let n=oK(),[r,i]=(0,q.useState)(e.label??``),[a,o]=(0,q.useState)(!1);return n?(0,J.jsxs)(bw,{open:a,onOpenChange:t=>{o(t),t&&i(e.label??``)},children:[(0,J.jsx)(yw,{asChild:!0,children:t}),(0,J.jsx)(vw,{side:`left`,align:`start`,className:`oc-bmk-pop`,children:(0,J.jsxs)(`form`,{className:`oc-bmk-pop__form`,onSubmit:t=>{t.preventDefault(),n.rename(e.id,r),o(!1)},children:[(0,J.jsx)(xw,{value:r,onChange:e=>i(e.target.value),placeholder:lu(),maxLength:60,autoFocus:!0}),(0,J.jsxs)(`div`,{className:`oc-bmk-pop__actions`,children:[(0,J.jsx)(K,{type:`submit`,size:`sm`,variant:`secondary`,children:Qo()}),(0,J.jsxs)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{n.remove(e.id),o(!1)},children:[(0,J.jsx)(GC,{size:14,"aria-hidden":!0}),od()]})]})]})})]}):null}function gK({bookmark:e,top:t}){return(0,J.jsx)(hK,{bookmark:e,trigger:(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-marker`,style:{top:t},title:e.label??Fu(),"aria-label":e.label??Fu(),children:(0,J.jsx)(cA,{size:14})})})}function _K(e){return(0,J.jsx)(fK,{children:(0,J.jsx)(vK,{...e})})}function vK({header:e=!1}){let t=oK(),n=$(e=>e.id),r=t?.byMessage.get(n)?.find(e=>e.blockIndex===null)??null;if(!t)return null;let i=r!==null,a=e?`oc-bmk-headbtn${i?` is-set`:``}`:`oc-iconbtn${i?` oc-iconbtn--bmk-set`:``}`;return e&&r!==null?(0,J.jsx)(hK,{bookmark:r,trigger:(0,J.jsx)(`button`,{type:`button`,className:a,title:r.label??Fu(),"aria-label":r.label??Fu(),children:(0,J.jsx)(cA,{size:13})})}):(0,J.jsx)(`button`,{type:`button`,className:a,title:i?v():Rp(),"aria-label":i?v():Rp(),onClick:()=>t.toggle(n,null),children:(0,J.jsx)(cA,{size:e?13:15})})}function yK(e){let t=(0,q.useRef)(null),n=(0,q.useRef)(e);return n.current=e,(0,q.useEffect)(()=>{let e=e=>{t.current!==null&&(n.current(e.clientX-t.current.x,e.clientY-t.current.y),t.current={x:e.clientX,y:e.clientY})},r=()=>{t.current=null};return window.addEventListener(`pointermove`,e),window.addEventListener(`pointerup`,r),()=>{window.removeEventListener(`pointermove`,e),window.removeEventListener(`pointerup`,r)}},[]),e=>{t.current={x:e.clientX,y:e.clientY}}}function bK(){let e=(0,q.useSyncExternalStore)(jj,Mj),t=Kx(),n=Mw();(0,q.useEffect)(()=>()=>void Qj(),[]);let r=(0,q.useCallback)((e,t)=>{let n=Mj()?.geom;n!==void 0&&Uj({...n,x:n.x+e,y:n.y+t})},[]),i=(0,q.useCallback)((e,t)=>{let n=Mj()?.geom;n!==void 0&&Uj({...n,w:n.w+e,h:n.h+t})},[]),a=yK(r),o=yK(i);(0,q.useEffect)(()=>{let e=()=>{let e=Mj()?.geom;e!==void 0&&Uj(e)};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let s=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>s.current?.stop(),[]);let c=e?.recording??!1,l=(0,q.useCallback)(()=>{if(Mj()?.recording===!0){let e=zj();s.current?.stop(),s.current=null,Zj(),window.setTimeout(()=>Xj(e),1500);return}if(!qS())return;let e=Mj()?.voiceLang||GS(``,ft()),t={h:null,gen:0},r=()=>{s.current===t.h&&(s.current=null),Xj(t.gen)},i=LS({lang:e,onText:(e,n)=>{t.gen===zj()&&Bj(e,n.paragraph)},onInterim:e=>{t.gen===zj()&&Vj(e)},onEnd:r,onError:e=>{r(),e===`not-allowed`||e===`service-not-allowed`?n.error(Ua()):e!==`no-speech`&&e!==`aborted`&&n.error(Ah({code:e}))}});if(i===null){n.error(ba());return}t.h=i,s.current=i,Rj(()=>i.stop()),t.gen=zj()},[n]),u=fM(e?.targetChatId??null);if(e===null)return null;let d=Nj(e.geom,{w:window.innerWidth,h:window.innerHeight});return(0,vk.createPortal)((0,J.jsxs)(`div`,{className:`oc-detach${c?` oc-detach--live`:``}`,style:{left:`${d.x}px`,top:`${d.y}px`,width:`${d.w}px`,height:`${d.h}px`},role:`dialog`,"aria-label":_p(),children:[(0,J.jsx)(`div`,{className:`oc-detach__handle`,onPointerDown:a,title:um(),"aria-label":um(),children:(0,J.jsx)(kA,{size:16,"aria-hidden":!0})}),(0,J.jsxs)(`div`,{className:`oc-detach__head`,onPointerDown:a,children:[c?(0,J.jsxs)(`span`,{className:`oc-detach__wave`,"aria-hidden":!0,children:[(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{}),(0,J.jsx)(`i`,{})]}):null,(0,J.jsx)(`span`,{className:`oc-detach__chip`,title:e.targetLabel,children:e.targetLabel||_p()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__close`,title:Jy(),"aria-label":Jy(),onPointerDown:e=>e.stopPropagation(),onClick:()=>{cM(e.targetChatId),Qj()},children:(0,J.jsx)(XC,{size:14,"aria-hidden":!0})})]}),u.length>0?(0,J.jsx)(`div`,{className:`oc-detach__quotes`,children:u.map(n=>(0,J.jsxs)(`div`,{className:`oc-detach__quote`,role:`group`,"aria-label":Ey(),children:[(0,J.jsx)(nj,{size:12,"aria-hidden":!0,className:`oc-detach__quote-ico`}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__quote-text`,title:p_(),onClick:()=>{sK(n.messageId,n.blockIndex,`smooth`),t({to:`/chat/$chatId`,params:{chatId:e.targetChatId}})},children:n.excerpt}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__quote-x`,"aria-label":Hp(),onClick:()=>oM(e.targetChatId,sM(n)),children:(0,J.jsx)(XC,{size:12,"aria-hidden":!0})})]},sM(n)))}):null,(0,J.jsx)(`textarea`,{className:`oc-detach__input`,value:e.text,placeholder:_p(),onChange:e=>Hj(e.target.value),readOnly:e.sending,autoFocus:!0}),c&&e.interim!==``?(0,J.jsx)(`div`,{className:`oc-detach__interim`,"aria-hidden":!0,children:e.interim}):null,(0,J.jsxs)(`div`,{className:`oc-detach__bar`,children:[e.voiceEnabled&&qS()?(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__icon${c?` oc-detach__icon--rec`:``}`,title:c?Mo():cn(),"aria-label":c?Mo():cn(),"aria-pressed":c,disabled:e.sending,onClick:l,children:c?(0,J.jsx)(qA,{size:16,"aria-hidden":!0}):(0,J.jsx)(zS,{size:16,"aria-hidden":!0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__icon`,title:c?Zf():Cg(),"aria-label":Cg(),disabled:e.sending||c,onClick:()=>{Jj(),t({to:`/chat/$chatId`,params:{chatId:e.targetChatId}})},children:(0,J.jsx)(IS,{size:16,"aria-hidden":!0})}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-detach__send`,disabled:e.text.trim()===``||c||e.sending,title:c?Zf():Wg(),"aria-label":Wg(),onClick:()=>{Wj(e.text),t({to:`/chat/$chatId`,params:{chatId:e.targetChatId}})},children:[(0,J.jsx)(aj,{size:15,"aria-hidden":!0}),Wg()]})]}),(0,J.jsx)(`button`,{type:`button`,className:`oc-detach__resize`,"aria-label":R_(),onPointerDown:o})]}),document.body)}function xK({icon:e,label:t,sublabel:n,trailing:r,tone:i=`default`,active:a,open:o,onClick:s,title:c,ariaLabel:l,ariaExpanded:u,ariaControls:d,ariaHasPopup:f,inert:p=!1}){return p?(0,J.jsxs)(`div`,{className:`oc-actrow oc-actrow--${i} oc-actrow--inert`,title:c,children:[(0,J.jsxs)(`span`,{className:`oc-actrow__top`,children:[(0,J.jsx)(`span`,{className:`oc-actrow__icon`,"aria-hidden":!0,children:e}),(0,J.jsx)(`span`,{className:`oc-actrow__label`,children:t}),r?(0,J.jsx)(`span`,{className:`oc-actrow__trail`,children:r}):null]}),n?(0,J.jsx)(`span`,{className:`oc-actrow__sub`,children:n}):null]}):(0,J.jsxs)(`button`,{type:`button`,className:`oc-actrow oc-actrow--${i}${a?` is-active`:``}${o?` is-open`:``}`,onClick:s,title:c,"aria-label":l,"aria-expanded":u,"aria-controls":d,"aria-haspopup":f?`dialog`:void 0,children:[(0,J.jsxs)(`span`,{className:`oc-actrow__top`,children:[(0,J.jsx)(`span`,{className:`oc-actrow__icon`,"aria-hidden":!0,children:e}),(0,J.jsx)(`span`,{className:`oc-actrow__label`,children:t}),r?(0,J.jsx)(`span`,{className:`oc-actrow__trail`,children:r}):null,(0,J.jsx)(QS,{size:14,className:`oc-actrow__chev`,"aria-hidden":!0})]}),n?(0,J.jsx)(`span`,{className:`oc-actrow__sub`,children:n}):null]})}var SK=(0,q.createContext)(null),CK=[];function wK(e){return e===`created`?(0,J.jsx)(RC,{size:12,"aria-hidden":!0}):e===`removed`?(0,J.jsx)(GC,{size:12,"aria-hidden":!0}):e===`unchanged`?(0,J.jsx)(fA,{size:12,"aria-hidden":!0}):(0,J.jsx)(LC,{size:12,"aria-hidden":!0})}function TK(e){return e===`created`?Pc():e===`removed`?ol():e===`unchanged`?xe():Zn()}function EK(){let e=$(e=>e.metadata?.custom?.cronParts??CK),t=$(e=>e.metadata?.custom?.routedInstanceName??null),n=$(e=>e.id),r=(0,q.useContext)(SK),[i,a]=(0,q.useState)(!0);return e.length===0?null:(0,J.jsxs)(`div`,{className:`oc-cronact`,children:[(0,J.jsx)(xK,{icon:(0,J.jsx)(uA,{size:14}),label:Y_({count:e.length}),open:i,ariaExpanded:i,title:yi(),onClick:()=>a(!i)}),i?(0,J.jsx)(`div`,{className:`oc-cronact__list`,children:e.map((e,i)=>(0,J.jsxs)(`button`,{type:`button`,className:`oc-cronact__item${r?.active!==null&&r?.active!==void 0&&r.active.jobId===(e.jobId??null)&&r.active.occurrenceId===`${n}#${i}`?` oc-cronact__item--active`:``}`,onClick:()=>r?.openFor(e,t,`${n}#${i}`),title:En(),children:[(0,J.jsxs)(`span`,{className:`oc-cronact__op oc-cronact__op--${e.op}`,children:[wK(e.op),TK(e.op)]}),(0,J.jsx)(`span`,{className:`oc-cronact__name`,children:e.name??e.jobId??Ml()}),e.schedule===void 0?null:(0,J.jsx)(`span`,{className:`oc-cronact__sched`,children:e.schedule})]},`${e.jobId??`job`}-${i}`))}):null]})}function DK(e){return typeof e==`number`?new Intl.DateTimeFormat(ft(),{dateStyle:`medium`,timeStyle:`short`}).format(e):`—`}function OK(e){return e===`ok`?(0,J.jsx)(Pw,{variant:`secondary`,children:em()}):e===`error`?(0,J.jsx)(Pw,{variant:`destructive`,children:Ry()}):e===`skipped`?(0,J.jsx)(Pw,{variant:`outline`,children:Aa()}):(0,J.jsx)(Pw,{variant:`outline`,children:e??`—`})}function kK({instanceName:e,part:t,onClose:n,onChanged:r}){let i=pa(G.scheduled.getCronDetail),a=pa(G.scheduled.listCronRuns),o=pa(G.scheduled.updateCron),s=pa(G.scheduled.removeCron),c=pa(G.scheduled.runCronNow),l=Mw(),u=t.jobId??null,[d,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(null),[_,v]=(0,q.useState)(`loading`),[y,b]=(0,q.useState)(null),[x,S]=(0,q.useState)(!1),C=(0,q.useRef)(0),w=(0,q.useCallback)(async()=>{let n=++C.current;if(f(null),m(null),g(null),u===null||t.op===`removed`){v(t.op===`removed`?`gone`:`error`);return}v(`loading`);try{let t=await i({instanceName:e,jobId:u});if(n!==C.current)return;if(f(t.job),m(t.capabilities),v(`ready`),t.capabilities.canHistory)try{let t=await a({instanceName:e,jobId:u,limit:5});if(n!==C.current)return;g(t)}catch{n===C.current&&g(null)}}catch(e){if(n!==C.current)return;let t=e?.data?.code;v(t===`not_found`?`gone`:`error`)}},[i,a,e,u,t.op]);(0,q.useEffect)(()=>{w()},[w]);let T=(0,q.useRef)(``);(0,q.useEffect)(()=>{T.current=`${e}:${u??``}`,b(null)},[e,u]);let E=async(t,n,i)=>{let a=`${e}:${u??``}`;b(t);try{if(await n(),T.current!==a)return;l.success(i),r?.(),await w()}catch(e){let t=e?.data?.code??`unknown`;l.toast({variant:`error`,title:Hs({code:t})})}finally{T.current===a&&b(e=>e===t?null:e)}},D=d??{id:u,name:t.name??null,enabled:t.enabled??null,schedule:t.schedule??null,message:t.message??null,deliveryMode:t.deliveryMode??null,agentId:t.agentId??null,nextRunAtMs:t.nextRunAtMs??null,lastRunStatus:null,lastDelivered:null,lastDeliveryError:null,updatedAtMs:null};return(0,J.jsxs)(`div`,{className:`oc-cronpanel`,children:[(0,J.jsxs)(`div`,{className:`oc-cronpanel__head`,children:[(0,J.jsx)(uA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-cronpanel__title`,title:D.name??void 0,children:D.name??Ml()}),(0,J.jsx)(Pw,{variant:`outline`,children:TK(t.op)}),(0,J.jsx)(K,{variant:`ghost`,size:`icon`,onClick:n,"aria-label":Jee(),children:(0,J.jsx)(XC,{"aria-hidden":!0})})]}),_===`loading`?(0,J.jsxs)(`div`,{className:`oc-cronpanel__loading`,children:[(0,J.jsx)(kC,{size:16,className:`oc-actrow__spin`,"aria-hidden":!0}),bs()]}):null,_===`gone`?(0,J.jsx)(`div`,{className:`oc-cronpanel__notice`,children:Gi()}):null,_===`error`?(0,J.jsx)(`div`,{className:`oc-cronpanel__notice`,children:wr()}):null,(0,J.jsxs)(`dl`,{className:`oc-cronpanel__facts`,children:[(0,J.jsx)(`dt`,{children:en()}),(0,J.jsx)(`dd`,{children:D.enabled===!0?(0,J.jsx)(Pw,{variant:`secondary`,children:Mu()}):D.enabled===!1?(0,J.jsx)(Pw,{variant:`outline`,children:su()}):`—`}),(0,J.jsx)(`dt`,{children:To()}),(0,J.jsxs)(`dd`,{children:[(0,J.jsx)(`span`,{className:`oc-cronpanel__mono`,children:D.schedule??`—`}),(()=>{let e=IC(D.schedule),t=e===null?null:PC(e);return t===null?null:(0,J.jsx)(`span`,{className:`oc-cronpanel__plain`,children:t})})()]}),(0,J.jsx)(`dt`,{children:Fa()}),(0,J.jsx)(`dd`,{children:DK(D.nextRunAtMs)}),(0,J.jsx)(`dt`,{children:fa()}),(0,J.jsx)(`dd`,{children:D.agentId??`—`}),D.deliveryMode===null?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:Sh()}),(0,J.jsx)(`dd`,{children:D.deliveryMode})]}),D.lastDelivered===!1?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`dt`,{children:ee()}),(0,J.jsxs)(`dd`,{className:`oc-cronpanel__undelivered`,children:[Wh(),D.lastDeliveryError===null?null:(0,J.jsx)(`span`,{className:`oc-cronpanel__plain`,children:D.lastDeliveryError})]})]}):null]}),D.message===null?null:(0,J.jsxs)(`div`,{className:`oc-cronpanel__message`,children:[(0,J.jsx)(`div`,{className:`oc-cronpanel__message-label`,children:io()}),(0,J.jsx)(`div`,{className:`oc-cronpanel__message-body`,children:D.message})]}),_===`ready`&&p!==null&&u!==null?(0,J.jsxs)(`div`,{className:`oc-cronpanel__actions`,children:[p.canRunNow?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:y!==null,onClick:()=>E(`run`,async()=>{let t=await c({instanceName:e,jobId:u});if(t.ran!==!0&&t.runId===null)throw{data:{code:t.reason??`run_not_started`}}},Xb()),children:[y===`run`?(0,J.jsx)(kC,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(FC,{size:14,"aria-hidden":!0}),dt()]}):null,p.canToggle&&D.enabled!==null?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:y!==null,onClick:()=>E(`toggle`,()=>o({instanceName:e,jobId:u,patch:{enabled:!(D.enabled??!1)}}),D.enabled===!0?vf():jee()),children:[D.enabled===!0?(0,J.jsx)(MC,{size:14,"aria-hidden":!0}):(0,J.jsx)(NC,{size:14,"aria-hidden":!0}),D.enabled===!0?jt():dc()]}):null,p.canDelete?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:y!==null,onClick:()=>S(!0),children:[(0,J.jsx)(GC,{size:14,"aria-hidden":!0}),Db()]}):null,(0,J.jsx)(K,{variant:`ghost`,size:`sm`,asChild:!0,children:(0,J.jsxs)(Ak,{to:`/settings/$tab`,params:{tab:`scheduled`},search:u===null?void 0:{job:u},children:[(0,J.jsx)(bA,{size:14,"aria-hidden":!0}),We()]})})]}):null,h!==null&&h.length>0?(0,J.jsxs)(`div`,{className:`oc-cronpanel__runs`,children:[(0,J.jsx)(`div`,{className:`oc-cronpanel__runs-label`,children:Oee()}),h.map((e,t)=>(0,J.jsxs)(`div`,{className:`oc-cronpanel__run`,children:[(0,J.jsxs)(`div`,{className:`oc-cronpanel__run-head`,children:[OK(e.status),(0,J.jsx)(`span`,{children:DK(e.runAtMs??e.ts)}),typeof e.durationMs==`number`?(0,J.jsxs)(`span`,{className:`oc-cronpanel__run-dur`,children:[Math.round(e.durationMs/1e3),`s`]}):null]}),e.summary===null?null:(0,J.jsx)(`div`,{className:`oc-cronpanel__run-summary`,children:e.summary}),e.error===null?null:(0,J.jsx)(`div`,{className:`oc-cronpanel__run-error`,children:e.error}),e.delivered===!1?(0,J.jsxs)(`div`,{className:`oc-cronpanel__run-undelivered`,children:[cp({channel:e.deliveryChannel??`—`}),e.deliveryError===null?null:(0,J.jsx)(`span`,{className:`oc-cronpanel__plain`,children:e.deliveryError})]}):null]},t))]}):null,(0,J.jsx)(pw,{open:x,onOpenChange:S,children:(0,J.jsxs)(cw,{children:[(0,J.jsxs)(fw,{children:[(0,J.jsx)(sw,{children:Od()}),(0,J.jsx)(ow,{children:Sm({name:D.name??u??``})})]}),(0,J.jsxs)(uw,{children:[(0,J.jsx)(dw,{children:eee()}),(0,J.jsx)(lw,{onClick:()=>{u!==null&&E(`delete`,()=>s({instanceName:e,jobId:u}),ob())},children:Fg()})]})]})})]})}var AK=class extends q.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(){}render(){return this.state.failed?(0,J.jsxs)(`div`,{className:`oc-panel-failed`,children:[(0,J.jsx)(`p`,{children:jl()}),this.props.onClose===void 0?null:(0,J.jsx)(`button`,{type:`button`,className:`oc-panel-failed__close`,onClick:this.props.onClose,children:Nc()})]}):this.props.children}},jK=[`github-light`,`github-dark`],MK=[`code`,`math`,`cjk`];function NK(e,t){let n={};for(let r of MK){let i=e?.[r];if(i===!1)continue;let a=i||t[r];a&&(n[r]=a)}let r=e?.mermaid;return r&&r!==!1&&(n.mermaid=r),n}function PK(e){return typeof e==`object`&&!!e&&`type`in e&&`key`in e}function FK(e,t){return e===t?!0:!PK(e)||!PK(t)?!1:e.type===t.type&&e.key===t.key}function IK(e,t){let n=Object.keys(e).filter(e=>e!==`children`),r=Object.keys(t).filter(e=>e!==`children`);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return FK(e.children,t.children)}var LK=(0,q.createContext)(null),RK=(0,q.memo)(function({children:e,node:t,...n}){let r=(0,q.isValidElement)(e)?(0,q.cloneElement)(e,{"data-block":`true`}):e;return(0,J.jsx)(LK.Provider,{value:{node:t,...n},children:r})},IK),zK=96,BK=126,VK=32,HK=9,UK=13,WK=92,GK=e=>e===VK||e===HK||e===UK;function KK(e,t,n){for(let r=t;r<n;r+=1)if(!GK(e.charCodeAt(r)))return!1;return!0}function qK(e){let t=e.length,n=!1,r=0,i=0,a=!1,o=0,s=-1;for(let c=0;c<=t;){let l=e.indexOf(`
15
+ `,c);l===-1&&(l=t);let u=c;for(;u<l&&GK(e.charCodeAt(u));)u+=1;let d=u<l?e.charCodeAt(u):-1,f=!1;if((d===zK||d===BK)&&u-c<=3){let t=u;for(;t<l&&e.charCodeAt(t)===d;)t+=1;t-u>=3&&(f=!0,n?d===r&&t-u>=i&&KK(e,t,l)&&(n=!1):(n=!0,r=d,i=t-u))}if(!n&&!f)for(let t=e.indexOf(`$$`,c);t!==-1&&t<l-1;t=e.indexOf(`$$`,t+2))(t===0||e.charCodeAt(t-1)!==WK)&&(a=!a);d===-1&&!n&&!a?s=l+1:s!==-1&&(o=s,s=-1),c=l+1}return o}function JK(e,t){let n=qK(e);return n<=0?Lw(e,t):e.slice(0,n)+Lw(e.slice(n),t)}var YK=/language-([^\s]+)/;function XK(e){if(typeof e==`string`)return e;if(!(0,q.isValidElement)(e))return``;let t=e.props;return t&&typeof t.children==`string`?t.children:``}function ZK({node:e,...t}){return(0,J.jsx)(`pre`,{...t})}function QK({node:e,...t}){return(0,J.jsx)(`code`,{...t})}function $K(e){let{SyntaxHighlighter:t,CodeHeader:n,componentsByLanguage:r={}}=e;function i({node:e,className:i,children:a,"data-block":o,...s}){if(!o)return(0,J.jsx)(`code`,{className:`aui-streamdown-inline-code ${i??``}`.trim(),...s,children:a});let c=i?.match(YK)?.[1]??``,l=XK(a),u=r[c]?.SyntaxHighlighter??t,d=r[c]?.CodeHeader??n,f=d?(0,J.jsx)(d,{node:e,language:c,code:l}):null;return u?(0,J.jsxs)(J.Fragment,{children:[f,(0,J.jsx)(u,{node:e,components:{Pre:ZK,Code:QK},language:c,code:l})]}):(0,J.jsxs)(J.Fragment,{children:[f,(0,J.jsx)(ZK,{node:e,children:(0,J.jsx)(`code`,{className:i,...s,children:a})})]})}let a=(0,q.memo)(i,(e,t)=>e.className===t.className&&e[`data-block`]===t[`data-block`]&&e.children===t.children&&e.node?.position?.start.line===t.node?.position?.start.line&&e.node?.position?.end.line===t.node?.position?.end.line);return a.displayName=`AdaptedCode`,a}function eq(e){return!!(e.SyntaxHighlighter||e.CodeHeader||e.componentsByLanguage&&Object.keys(e.componentsByLanguage).length>0)}function tq({components:e,componentsByLanguage:t}){return(0,q.useMemo)(()=>{let{SyntaxHighlighter:n,CodeHeader:r,...i}=e??{},a={SyntaxHighlighter:n,CodeHeader:r,componentsByLanguage:t},o={pre:RK};if(!eq(a))return{...i,...o};let s=$K(a);return{...i,...o,code:s}},[e,t])}function nq(e){return[Hw,[Rw,{}],[Iw,{allowedImagePrefixes:e.allowedImagePrefixes??[`*`],allowedLinkPrefixes:e.allowedLinkPrefixes??[`*`],allowedProtocols:e.allowedProtocols??[`*`],allowDataImages:e.allowDataImages??!0,defaultOrigin:e.defaultOrigin,blockedLinkClass:e.blockedLinkClass,blockedImageClass:e.blockedImageClass}]]}var rq=(0,q.forwardRef)(({components:e,componentsByLanguage:t,preprocess:n,defer:r=!1,smooth:i=!1,plugins:a,containerProps:o,containerClassName:s,caret:c,controls:l,linkSafety:u,remend:d,mermaid:f,parseIncompleteMarkdown:p,allowedTags:m,remarkRehypeOptions:h,security:g,BlockComponent:_,parseMarkdownIntoBlocksFn:v,mode:y=`streaming`,className:b,shikiTheme:x,...S},C)=>{let w=vW(),{text:T,status:E}=OW((0,q.useMemo)(()=>n?{...w,text:n(w.text)}:w,[w,n]),i),D=(0,q.useDeferredValue)(T),O=r?D:T,k=y===`streaming`&&p!==!1&&!v,A=(0,q.useMemo)(()=>k?JK(O,d):O,[k,O,d]),j=!k&&p,M=(0,q.useMemo)(()=>{let e=NK(a,{});return Object.keys(e).length>0?e:void 0},[a]),N=(0,q.useMemo)(()=>x??(M?.code?jK:void 0),[x,M?.code]),P=tq({components:e,componentsByLanguage:t}),F=(0,q.useMemo)(()=>{let{SyntaxHighlighter:t,CodeHeader:n,...r}=e??{};return{...r,...P}},[e,P]),I=(0,q.useMemo)(()=>[s,o?.className].filter(Boolean).join(` `)||void 0,[s,o?.className]),L=(0,q.useMemo)(()=>g?nq(g):void 0,[g]),R={...b&&{className:b},...c&&{caret:c},...l!==void 0&&{controls:l},...u&&{linkSafety:u},...d&&{remend:d},...f&&{mermaid:f},...j!==void 0&&{parseIncompleteMarkdown:j},...m&&{allowedTags:m},...M&&{plugins:M},...N&&{shikiTheme:N},...h&&{remarkRehypeOptions:h},...L&&{rehypePlugins:L},..._&&{BlockComponent:_},...v&&{parseMarkdownIntoBlocksFn:v}};return(0,J.jsx)(`div`,{ref:C,"data-status":E.type,...o,className:I,children:(0,J.jsx)(Bw,{mode:y,isAnimating:E.type===`running`,components:F,...R,...S,children:A})})});rq.displayName=`StreamdownTextPrimitive`;function iq(e){return typeof e==`string`&&/^(https?:|mailto:)/i.test(e.trim())}function aq({href:e,children:t,node:n,...r}){return iq(e)?(0,J.jsx)(`a`,{...r,href:e,target:`_blank`,rel:`noopener noreferrer`,children:t}):(0,J.jsx)(`span`,{...r,children:t})}var oq={a:aq},sq={a:aq};function cq({text:e}){return(0,J.jsx)(Bw,{className:`oc-md`,components:sq,children:e})}var lq=(0,q.memo)(function(){return(0,J.jsx)(rq,{className:`oc-md`,smooth:!$(e=>e.metadata?.custom?.hasMergedRuns===!0),components:oq})}),uq=new Set(`txt.md.markdown.csv.tsv.log.json.yaml.yml.xml.html.css.js.ts.tsx.jsx.py.rb.go.rs.java.c.h.cpp.hpp.sh.bash.sql.toml.ini.env`.split(`.`)),dq=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`avif`,`bmp`]),fq=new Set([`application/vnd.openxmlformats-officedocument.presentationml.presentation`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`,`application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`,`application/vnd.ms-powerpoint`,`application/msword`,`application/vnd.ms-excel`,`application/vnd.oasis.opendocument.text`,`application/vnd.oasis.opendocument.presentation`,`application/vnd.oasis.opendocument.spreadsheet`,`application/rtf`]),pq=new Set([`pptx`,`ppt`,`docx`,`doc`,`xlsx`,`xls`,`odt`,`odp`,`ods`,`rtf`]);function mq(e,t){let n=(e??``).toLowerCase();if(fq.has(n))return!0;let r=hq(t);return r!==null&&pq.has(r)}function hq(e){if(!e)return null;let t=e.lastIndexOf(`.`);return t<=0||t===e.length-1?null:e.slice(t+1).toLowerCase()}function gq(e,t){let n=(e??``).split(`;`)[0].trim().toLowerCase(),r=hq(t);if(n===`application/pdf`)return`pdf`;if(n.startsWith(`image/`))return`image`;if(n.startsWith(`video/`))return`video`;if(n.startsWith(`audio/`))return`audio`;if(n===`text/markdown`)return`markdown`;if(n===`text/csv`||n===`text/tab-separated-values`)return`csv`;if(n===`application/json`||n.endsWith(`+json`))return`json`;if(n===`text/x-log`)return`log`;if(n===``||n===`text/plain`||n===`application/octet-stream`||n===`binary/octet-stream`){if(r===`md`||r===`markdown`)return`markdown`;if(r===`csv`||r===`tsv`)return`csv`;if(r===`json`)return`json`;if(r===`log`)return`log`}return n.startsWith(`text/`)||n===`application/json`||n===`application/xml`||n===`application/x-yaml`?`text`:r===`pdf`?`pdf`:r!==null&&dq.has(r)?`image`:r!==null&&uq.has(r)?`text`:`none`}var _q=[`fit`,.5,.75,1,1.5,2];function vq(e,t){return Number.isFinite(e)?Math.min(Math.max(1,Math.floor(e)),Math.max(1,Math.floor(t))):1}var yq=512*1024,bq=1e3,xq=5e3;function Sq(e,t){if((e??``).split(`;`)[0].trim().toLowerCase()===`text/tab-separated-values`||hq(t)===`tsv`)return` `}function Cq(e){let t=`,`,n=0;for(let r of[`,`,`;`,` `]){let i=wq(e,r).length;i>n&&(t=r,n=i)}return t}function wq(e,t){let n=[],r=``,i=!1;for(let a=0;a<e.length;a++){let o=e[a];i?o===`"`?e[a+1]===`"`?(r+=`"`,a++):i=!1:r+=o:o===`"`?i=!0:o===t?(n.push(r),r=``):r+=o}return n.push(r),n}function Tq(e,t=bq,n){let r=[],i=``,a=!1,o=e.replace(/\r\n/g,`
16
+ `).replace(/\r/g,`
17
+ `);for(let e of o)e===`"`&&(a=!a),e===`
18
+ `&&!a?(r.push(i),i=``):i+=e;i!==``&&r.push(i);let s=r.findIndex(e=>e.trim()!==``);if(s===-1)return{header:[],rows:[],totalRows:0,truncatedRows:!1,delimiter:`,`};let c=n??Cq(r[s]),l=wq(r[s],c),u=r.slice(s+1);return{header:l,rows:u.slice(0,t).map(e=>wq(e,c)),totalRows:u.length,truncatedRows:u.length>t,delimiter:c}}function Eq(e,t){let n=e.trim(),r=t.trim();if(/^-?\d+$/.test(n)&&/^-?\d+$/.test(r)){let e=BigInt(n),t=BigInt(r);return e<t?-1:+(e>t)}let i=Number(e),a=Number(t);return n!==``&&r!==``&&!Number.isNaN(i)&&!Number.isNaN(a)?i-a:e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`})}function Dq(e){return/\b(error|err|fatal|critical|panic)\b/i.test(e)?`error`:/\b(warn|warning)\b/i.test(e)?`warn`:/\b(info|notice)\b/i.test(e)?`info`:/\b(debug|trace|verbose)\b/i.test(e)?`debug`:`plain`}var Oq=60;function kq({url:e,filename:t}){let[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(1),[c,l]=(0,q.useState)(`fit`);if((0,q.useEffect)(()=>{let t=!1,n=null;return r(null),a(!1),s(1),(async()=>{try{let i=await Uw(()=>import(`./pdf-EQHMWEbX.js`),__vite__mapDeps([0,1]));i.GlobalWorkerOptions.workerSrc=new URL(`/assets/pdf.worker.min-CHFwMXne.mjs`,``+import.meta.url).toString();let a=i.getDocument({url:e}),o=await a.promise;if(t){a.destroy().catch(()=>{});return}n=a,r(o)}catch(e){console.error(`[docviewer] pdf load failed:`,e?.message??e),t||a(!0)}})(),()=>{t=!0,n&&n.destroy().catch(()=>{})}},[e]),i)return(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:$_()}),(0,J.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:sd()})]});if(n===null)return(0,J.jsx)(`div`,{className:`oc-docviewer__loading`,children:Zr()});let u=n.numPages,d=vq(o,u);return(0,J.jsxs)(`div`,{className:`oc-docviewer__pdf`,children:[(0,J.jsxs)(`div`,{className:`oc-docviewer__toolbar`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>vq(e-1,u)),disabled:d<=1,"aria-label":dl(),children:(0,J.jsx)(ZS,{size:15})}),(0,J.jsxs)(`span`,{className:`oc-docviewer__pageinfo`,children:[d,` / `,u]}),(0,J.jsx)(`button`,{type:`button`,className:`oc-docviewer__navbtn`,onClick:()=>s(e=>vq(e+1,u)),disabled:d>=u,"aria-label":Ee(),children:(0,J.jsx)(QS,{size:15})}),(0,J.jsx)(`select`,{className:`oc-docviewer__zoom`,value:String(c),onChange:e=>{let t=e.target.value;l(t===`fit`?`fit`:Number(t))},"aria-label":Iu(),children:_q.map(e=>(0,J.jsx)(`option`,{value:String(e),children:e===`fit`?uu():`${Math.round(e*100)}%`},String(e)))})]}),(0,J.jsxs)(`div`,{className:`oc-docviewer__pdfbody`,children:[u>1?(0,J.jsxs)(`div`,{className:`oc-docviewer__rail`,"aria-label":nr(),children:[Array.from({length:Math.min(u,Oq)},(e,t)=>(0,J.jsx)(jq,{doc:n,page:t+1,active:t+1===d,onClick:()=>s(t+1)},t+1)),u>Oq?(0,J.jsxs)(`span`,{className:`oc-docviewer__railmore`,children:[`+`,u-Oq]}):null]}):null,(0,J.jsx)(Aq,{doc:n,page:d,zoom:c,filename:t})]})]})}function Aq({doc:e,page:t,zoom:n,filename:r}){let i=(0,q.useRef)(null),a=(0,q.useRef)(null),[o,s]=(0,q.useState)(0);return(0,q.useEffect)(()=>{let e=i.current;if(!e)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width??0;s(e=>Math.abs(e-t)>1?t:e)});return t.observe(e),()=>t.disconnect()},[]),(0,q.useEffect)(()=>{let r=!1,i=null;return(async()=>{try{let s=await e.getPage(t),c=a.current;if(r||!c)return;let l=s.getViewport({scale:1}),u=n===`fit`?Math.max(.1,(o-16)/l.width):n,d=window.devicePixelRatio||1,f=s.getViewport({scale:u*d});c.width=Math.floor(f.width),c.height=Math.floor(f.height),c.style.width=`${Math.floor(f.width/d)}px`,c.style.height=`${Math.floor(f.height/d)}px`;let p=s.render({canvas:c,viewport:f});i=p,await p.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] page render failed:`,e?.message??e)}})(),()=>{r=!0,i?.cancel()}},[e,t,n,o]),(0,J.jsx)(`div`,{ref:i,className:`oc-docviewer__main`,children:(0,J.jsx)(`canvas`,{ref:a,className:`oc-docviewer__canvas`,"aria-label":r})})}function jq({doc:e,page:t,active:n,onClick:r}){let i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{let n=!1,r=null;return(async()=>{try{let a=await e.getPage(t),o=i.current;if(n||!o)return;let s=104/a.getViewport({scale:1}).width,c=a.getViewport({scale:s});o.width=Math.floor(c.width),o.height=Math.floor(c.height);let l=a.render({canvas:o,viewport:c});r=l,await l.promise}catch(e){e?.name!==`RenderingCancelledException`&&console.error(`[docviewer] thumbnail render failed:`,e?.message??e)}})(),()=>{n=!0,r?.cancel()}},[e,t]),(0,J.jsxs)(`button`,{type:`button`,className:`oc-docviewer__thumb${n?` is-active`:``}`,onClick:r,"aria-label":Qee({page:t}),"aria-current":n?`true`:void 0,children:[(0,J.jsx)(`canvas`,{ref:i,className:`oc-docviewer__thumbcanvas`}),(0,J.jsx)(`span`,{className:`oc-docviewer__thumbnum`,children:t})]})}var Mq={current:null},Nq=(0,q.createContext)(Mq);function Pq(e){let t=0,n=e.match(/`+/g);if(n!==null)for(let e of n)t=Math.max(t,e.length);return"`".repeat(Math.max(3,t+1))}function Fq(e,t,n){let r=Pq(t);return`\n${e} ${n}\n${r}\n${t}\n${r}\n`}function Iq(e,t){let n=e.length,r=1;for(let t=0;t<e.length;t++)e.charCodeAt(t)===10&&r++;return n<=8e3&&r<=150?{kind:`inline`,lines:r,chars:n}:{kind:`file`,filename:`texte-colle-${t}.txt`,lines:r,chars:n}}var Lq=new WeakSet;function Rq(e){Lq.add(e)}function zq(e){return Lq.has(e)}var Bq=(0,q.createContext)({activeDoc:null,openFor:()=>{},openNewerVersion:()=>{},close:()=>{}});function Vq(){return(0,q.useContext)(Bq)}function Hq({doc:e,chatId:t,onClose:n}){let r=gq(e.mimeType,e.filename),i=r===`none`&&e.sourceStorageId!==void 0,a=Vq(),o=U(G.documentDrafts.latestDeliveredFile,t===null?`skip`:{chatId:t,filename:e.filename,...e.storageId===void 0?{}:{currentStorageId:e.storageId}}),s=o!=null&&(e.storageId===void 0?o.url!==e.url:o.storageId!==e.storageId)?o:null;return(0,J.jsxs)(`div`,{className:`oc-docviewer`,children:[(0,J.jsxs)(`header`,{className:`oc-docviewer__header`,children:[(0,J.jsx)(SA,{size:15,"aria-hidden":!0,className:`oc-docviewer__icon`}),(0,J.jsx)(`span`,{className:`oc-docviewer__name`,title:e.filename,children:e.filename}),(0,J.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,title:sd(),"aria-label":sd(),children:(0,J.jsx)(bA,{size:14})}),(0,J.jsx)(`a`,{className:`oc-docviewer__action`,href:e.url,download:e.filename,title:im(),"aria-label":im(),children:(0,J.jsx)(xC,{size:14})}),(0,J.jsx)(K,{type:`button`,size:`icon-sm`,variant:`ghost`,onClick:n,"aria-label":M_(),children:(0,J.jsx)(XC,{size:15})})]}),(0,J.jsxs)(`div`,{className:`oc-docviewer__body`,children:[s===null?null:(0,J.jsxs)(`div`,{className:`oc-docviewer__newversion`,role:`status`,children:[(0,J.jsx)(`span`,{children:jb()}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>a.openNewerVersion({url:s.url,filename:e.filename,mimeType:s.mimeType||null,storageId:s.storageId,sourceStorageId:mq(s.mimeType,e.filename)?s.storageId:void 0}),children:Je()})]}),r===`pdf`?(0,J.jsx)(kq,{url:e.url,filename:e.filename}):r===`image`?(0,J.jsx)(`div`,{className:`oc-docviewer__imagewrap`,children:(0,J.jsx)(`img`,{src:e.url,alt:e.filename,className:`oc-docviewer__image`})}):r===`video`?(0,J.jsx)(`video`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__video`}):r===`audio`?(0,J.jsx)(`div`,{className:`oc-docviewer__audiowrap`,children:(0,J.jsx)(`audio`,{controls:!0,preload:`metadata`,src:e.url,className:`oc-docviewer__audio`})}):r===`text`?(0,J.jsx)(Kq,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null},e.url):r===`markdown`||r===`csv`||r===`log`||r===`json`?(0,J.jsx)(Kq,{url:e.url,chatId:t,filename:e.filename,mimeType:e.mimeType,storageId:e.storageId??null,rich:r,csvDelimiter:r===`csv`?Sq(e.mimeType,e.filename):void 0},e.url):i?(0,J.jsx)(Uq,{sourceStorageId:e.sourceStorageId,chatId:t,downloadUrl:e.url,filename:e.filename}):(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:Ci()}),(0,J.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:im()})]})]})]})}function Uq({sourceStorageId:e,chatId:t,downloadUrl:n,filename:r}){let i=t===null?{}:{chatId:t},a=U(G.fileRenditions.getRendition,{sourceStorageId:e,...i}),o=W(G.fileRenditions.requestRendition),s=(0,q.useRef)(null);return(0,q.useEffect)(()=>{s.current=null},[e]),(0,q.useEffect)(()=>{a?.status===`pending`&&s.current!==e&&(s.current=e,o({sourceStorageId:e,...i}).catch(e=>{console.error(`[docviewer] rendition request failed:`,e)}))},[a?.status,e,o]),a===void 0?(0,J.jsx)(`div`,{className:`oc-docviewer__loading`,children:Zr()}):a.status===`ready`?(0,J.jsx)(kq,{url:a.pdfUrl,filename:a.filename}):a.status===`pending`?(0,J.jsxs)(`div`,{className:`oc-docviewer__preparing`,children:[(0,J.jsx)(`span`,{className:`oc-docviewer__spinner`,"aria-hidden":!0}),(0,J.jsx)(`p`,{children:jn()}),(0,J.jsx)(`a`,{href:n,download:r,className:`oc-docviewer__fallbacklink`,children:im()})]}):(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:a.status===`unconfigured`?Ci():Ll()}),(0,J.jsx)(`a`,{href:n,download:r,className:`oc-docviewer__fallbacklink`,children:im()})]})}function Wq(e){switch(e){case`markdown`:return _g();case`csv`:return Gf();case`log`:return Yv();case`json`:return hee()}}var Gq=e=>`oc.docviewer.raw.${e}`;function Kq({url:e,chatId:t,filename:n,mimeType:r,storageId:i,rich:a,csvDelimiter:o}){let[s,c]=(0,q.useState)({phase:`loading`}),[l,u]=(0,q.useState)(()=>a?localStorage.getItem(Gq(a))===`1`:!1),d=e=>{u(e),a&&localStorage.setItem(Gq(a),e?`1`:`0`)},[f,p]=(0,q.useState)(!1),m=U(G.documentDrafts.getDraft,t===null?`skip`:{chatId:t,filename:n}),h=t!==null&&s.phase===`ready`&&!s.truncated&&m!==void 0;if((0,q.useEffect)(()=>{let t=!1;return c({phase:`loading`}),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=await n.blob(),i=r.size>yq,a=await(i?r.slice(0,yq):r).text();t||c({phase:`ready`,text:a,truncated:i})}catch(e){console.error(`[docviewer] text fetch failed:`,e?.message??e),t||c({phase:`error`})}})(),()=>{t=!0}},[e]),s.phase===`loading`)return(0,J.jsx)(`div`,{className:`oc-docviewer__loading`,children:Zr()});if(s.phase===`error`)return(0,J.jsxs)(`div`,{className:`oc-docviewer__fallback`,children:[(0,J.jsx)(`p`,{children:$_()}),(0,J.jsx)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:`oc-docviewer__fallbacklink`,children:sd()})]});let g=a!==void 0&&!l,_=s.truncated?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:zc()}):null,v=m?.text??s.text,y=m==null?null:(0,J.jsx)(qq,{chatId:t,filename:n,diverged:m.sourceStorageId!==null&&i!==null&&m.sourceStorageId!==i}),b=f?(0,J.jsx)(Jq,{chatId:t,filename:n,mimeType:r,sourceStorageId:i,initialText:v,hasDraft:m!=null,onExit:()=>p(!1)}):g&&a===`markdown`?(0,J.jsx)(`div`,{className:`oc-docviewer__mdwrap`,children:(0,J.jsx)(cq,{text:v})}):g&&a===`csv`?(0,J.jsx)(Yq,{text:v,textTruncated:s.truncated,delimiter:o}):g&&a===`log`?(0,J.jsx)(Xq,{text:v,textTruncated:s.truncated}):g&&a===`json`?(0,J.jsx)(Zq,{text:v}):(0,J.jsx)(`pre`,{className:`oc-docviewer__text`,children:v});return a===void 0&&!h?(0,J.jsxs)(`div`,{className:`oc-docviewer__textwrap`,children:[_,y,b]}):(0,J.jsxs)(`div`,{className:`oc-docviewer__textwrap oc-docviewer__textwrap--bar`,children:[(0,J.jsxs)(`div`,{className:`oc-docviewer__mdbar`,role:`group`,"aria-label":fp(),children:[a===void 0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{type:`button`,size:`sm`,variant:g&&!f?`secondary`:`ghost`,"aria-pressed":g&&!f,onClick:()=>{p(!1),d(!1)},children:Wq(a)}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:l&&!f?`secondary`:`ghost`,"aria-pressed":l&&!f,onClick:()=>{p(!1),d(!0)},children:Hy()})]}),h?(0,J.jsxs)(K,{type:`button`,size:`sm`,variant:f?`secondary`:`ghost`,"aria-pressed":f,onClick:()=>p(e=>!e),className:`oc-docviewer__editbtn`,children:[(0,J.jsx)(LC,{size:13,"aria-hidden":!0}),Yi(),m==null?null:(0,J.jsx)(`span`,{className:`oc-docviewer__draftdot`,"aria-hidden":!0})]}):null]}),f?b:(0,J.jsx)(`div`,{className:`oc-docviewer__textscroll`,children:(0,J.jsxs)(`div`,{className:`oc-docviewer__scrollpad`,children:[_,y,b]})})]})}function qq({chatId:e,filename:t,diverged:n}){let r=W(G.documentDrafts.deleteDraft),i=Mw();return(0,J.jsxs)(`p`,{className:`oc-docviewer__draftnote`,children:[n?hc():Ft(),(0,J.jsx)(`button`,{type:`button`,className:`oc-docviewer__draftnote-discard`,onClick:()=>void r({chatId:e,filename:t}).then(e=>{e.applied===!1&&i.error(xx())}).catch(()=>i.error(Sf())),children:ga()})]})}function Jq({chatId:e,filename:t,mimeType:n,sourceStorageId:r,initialText:i,hasDraft:a,onExit:o}){let s=W(G.documentDrafts.saveDraft),c=W(G.documentDrafts.deleteDraft),l=(0,q.useContext)(Nq),u=Mw(),d=`oc.docdraft.fallback.${e}.${t}`,[f,p]=(0,q.useState)(()=>{try{let e=localStorage.getItem(d);if(e!==null)return e}catch{}return i}),[m,h]=(0,q.useState)(`idle`),g=(0,q.useRef)(0),_=(0,q.useRef)(f);_.current=f;let v=(0,q.useRef)(!1),y=(0,q.useRef)(!1),b=(0,q.useCallback)(n=>{h(`saving`),s({chatId:e,filename:t,text:n,...r!==null&&(y.current||!a)?{sourceStorageId:r}:{}}).then(e=>{if(e.applied===!1){u.error(xx()),h(`idle`);return}h(`saved`)}).catch(e=>{console.error(`[docviewer] draft save failed:`,e),u.error(String(e?.message??e).includes(`draft_limit_reached`)?za():Oo()),h(`idle`)})},[s,e,t,r,a,u]),x=e=>{y.current=!0,p(e),window.clearTimeout(g.current),g.current=window.setTimeout(()=>b(e),800)};return(0,q.useEffect)(()=>{try{localStorage.getItem(d)!==null&&(y.current=!0,s({chatId:e,filename:t,text:_.current,...r===null?{}:{sourceStorageId:r}}).then(()=>localStorage.removeItem(d)))}catch{}let n=()=>{if(!(!y.current||v.current))try{localStorage.setItem(d,_.current)}catch{}};return window.addEventListener(`pagehide`,n),()=>{if(window.removeEventListener(`pagehide`,n),window.clearTimeout(g.current),!v.current&&y.current){try{localStorage.setItem(d,_.current)}catch{}s({chatId:e,filename:t,text:_.current,...r===null?{}:{sourceStorageId:r}}).then(()=>{try{localStorage.removeItem(d)}catch{}}).catch(()=>{})}}},[]),(0,J.jsxs)(`div`,{className:`oc-docviewer__editor`,children:[(0,J.jsx)(`textarea`,{className:`oc-docviewer__editarea`,value:f,onChange:e=>x(e.target.value),spellCheck:!1,"aria-label":Yi()}),(0,J.jsxs)(`div`,{className:`oc-docviewer__editbar`,children:[(0,J.jsx)(`span`,{className:`oc-docviewer__savestate`,role:`status`,children:m===`saving`?Or():m===`saved`?rn():`\xA0`}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>{v.current=!0,window.clearTimeout(g.current);try{localStorage.removeItem(d)}catch{}c({chatId:e,filename:t}).then(e=>{if(e.applied===!1){v.current=!1,u.error(xx());return}o()}).catch(e=>{console.error(`[docviewer] draft discard failed:`,e),v.current=!1,u.error(Sf())})},children:ga()}),(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`secondary`,onClick:()=>{let e=l?.current??null;if(e===null){u.error(ht());return}if(window.clearTimeout(g.current),b(f),e.canAttach){let r=(n??`text/plain`).split(`;`)[0].trim(),i=new File([f],t,{type:`${r}; charset=utf-8`});e.attachFile(i).catch(e=>{console.error(`[docviewer] attach failed:`,e),u.error(co())})}else{if(f.length>8e3){u.error(ex());return}e.insertText(Fq(t,f,Ks()))}},children:Eh()})]})]})}function Yq({text:e,textTruncated:t,delimiter:n}){let r=(0,q.useMemo)(()=>Tq(e,void 0,n),[e,n]),[i,a]=(0,q.useState)(null),o=(0,q.useMemo)(()=>i?[...r.rows].sort((e,t)=>Eq(e[i.col]??``,t[i.col]??``)*i.dir):r.rows,[r.rows,i]);if(r.header.length===0)return(0,J.jsx)(`pre`,{className:`oc-docviewer__text`,children:e});let s=r.header.slice(0,100),c=r.header.length>s.length;return(0,J.jsxs)(`div`,{className:`oc-docviewer__csvwrap`,children:[r.truncatedRows?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?ah({shown:r.rows.length}):$d({shown:r.rows.length,total:r.totalRows})}):null,c?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:Ev({shown:s.length,total:r.header.length})}):null,(0,J.jsxs)(`table`,{className:`oc-docviewer__csv`,children:[(0,J.jsx)(`thead`,{children:(0,J.jsx)(`tr`,{children:s.map((e,t)=>(0,J.jsx)(`th`,{children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-docviewer__csvsort`,onClick:()=>a(e=>e?.col===t?e.dir===1?{col:t,dir:-1}:null:{col:t,dir:1}),"aria-label":a_({column:e}),children:[e,i?.col===t?i.dir===1?` ▲`:` ▼`:``]})},t))})}),(0,J.jsx)(`tbody`,{children:o.map((e,t)=>(0,J.jsx)(`tr`,{children:s.map((t,n)=>(0,J.jsx)(`td`,{children:e[n]??``},n))},t))})]})]})}function Xq({text:e,textTruncated:t}){let n=(0,q.useMemo)(()=>{let t=e.split(`
19
+ `);return t.length>1&&t[t.length-1]===``&&t.pop(),t},[e]),r=(0,q.useMemo)(()=>n.slice(0,xq),[n]);return(0,J.jsxs)(J.Fragment,{children:[n.length>r.length?(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:t?Pp({shown:r.length}):vy({shown:r.length,total:n.length})}):null,(0,J.jsx)(`pre`,{className:`oc-docviewer__text oc-docviewer__logview`,children:r.map((e,t)=>(0,J.jsxs)(`span`,{className:`oc-logline oc-logline--${Dq(e)}`,children:[e,`
20
+ `]},t))})]})}function Zq({text:e}){let t=(0,q.useMemo)(()=>{try{return{ok:!0,value:JSON.parse(e,(e,t,n)=>{if(typeof t==`number`&&Number.isInteger(t)&&!Number.isSafeInteger(t)&&typeof n?.source==`string`&&/^-?\d+$/.test(n.source))try{return BigInt(n.source)}catch{return t}return t})}}catch{return{ok:!1}}},[e]);return t.ok?(0,J.jsx)(`div`,{className:`oc-docviewer__jsonwrap`,children:(0,J.jsx)(eJ,{value:t.value,depth:0})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`p`,{className:`oc-docviewer__truncated`,children:y()}),(0,J.jsx)(`pre`,{className:`oc-docviewer__text`,children:e})]})}function Qq(e){if(Array.isArray(e))return e.length;let t=0;for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}function $q(e,t){if(Array.isArray(e))return e.slice(0,t).map((e,t)=>[String(t),e]);let n=[];for(let r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(n.length>=t)break;n.push([r,e[r]])}return n}function eJ({value:e,depth:t,name:n}){let r=typeof e==`object`&&!!e,i=r?Qq(e):0,[a,o]=(0,q.useState)(t<2&&i<=100),s=n===void 0?null:(0,J.jsxs)(`span`,{className:`oc-json__key`,children:[n,`: `]});if(!r)return(0,J.jsxs)(`div`,{className:`oc-json__leaf`,children:[s,(0,J.jsx)(`span`,{className:`oc-json__val oc-json__val--${e===null?`null`:typeof e==`bigint`?`number`:typeof e}`,children:typeof e==`bigint`?e.toString():JSON.stringify(e)})]});let c=a?$q(e,500):[];return(0,J.jsxs)(`details`,{className:`oc-json__node`,open:a,onToggle:e=>o(e.target.open),children:[(0,J.jsxs)(`summary`,{children:[s,(0,J.jsx)(`span`,{className:`oc-json__summary`,children:Array.isArray(e)?`[${i}]`:`{${i}}`})]}),a?(0,J.jsxs)(`div`,{className:`oc-json__children`,children:[c.map(([e,n])=>(0,J.jsx)(eJ,{name:e,value:n,depth:t+1},e)),i>c.length?(0,J.jsx)(`div`,{className:`oc-json__more`,children:$o({count:i-c.length})}):null]}):null]})}var tJ=(0,q.createContext)(null);function nJ(){return(0,q.useContext)(tJ)??{open:()=>{}}}function rJ({children:e}){let[t,n]=(0,q.useState)(null),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),c=(0,q.useCallback)(e=>{n(e),i(!1)},[]),l=(0,q.useCallback)(()=>{document.fullscreenElement&&document.exitFullscreen().catch(()=>{}),n(null),o(!1)},[]);(0,q.useEffect)(()=>{if(t===null)return;let e=e=>{e.key===`Escape`&&l()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,l]),(0,q.useEffect)(()=>{let e=()=>o(document.fullscreenElement!==null);return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let u=(0,q.useCallback)(()=>{let e=s.current;e&&(document.fullscreenElement?document.exitFullscreen().catch(()=>{}):e.requestFullscreen().catch(()=>{}))},[]);return(0,J.jsxs)(tJ.Provider,{value:{open:c},children:[e,t===null?null:(0,vk.createPortal)((0,J.jsxs)(`div`,{ref:s,className:`oc-lightbox`,role:`dialog`,"aria-modal":`true`,"aria-label":t.name,onClick:e=>{e.target===e.currentTarget&&l()},children:[(0,J.jsxs)(`div`,{className:`oc-lightbox__bar`,children:[(0,J.jsx)(`span`,{className:`oc-lightbox__name`,title:t.name,children:t.name}),(0,J.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:()=>i(e=>!e),"aria-label":r?md():_u(),title:r?md():_u(),children:r?(0,J.jsx)(xj,{size:18}):(0,J.jsx)(bj,{size:18})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:u,"aria-label":a?ii():Uu(),title:a?ii():Uu(),children:a?(0,J.jsx)(JA,{size:18}):(0,J.jsx)(WA,{size:18})}),(0,J.jsx)(`a`,{className:`oc-lightbox__btn`,href:t.url,target:`_blank`,rel:`noopener noreferrer`,"aria-label":ov(),title:ov(),children:(0,J.jsx)(bA,{size:18})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-lightbox__btn`,onClick:l,"aria-label":ji(),title:ji(),children:(0,J.jsx)(XC,{size:18})})]}),(0,J.jsx)(`div`,{className:`oc-lightbox__stage${r?` oc-lightbox__stage--scroll`:``}`,onClick:e=>{e.target===e.currentTarget&&l()},children:(0,J.jsx)(`img`,{src:t.url,alt:t.name,className:r?`oc-lightbox__img--actual`:`oc-lightbox__img--fit`,decoding:`async`})})]}),document.body)]})}function iJ(e,t){return t===`memory`?`memory`:e.context===!0||!e.file_name?`context`:`document`}function aJ(e){let t={memory:0,documents:0,context:0};for(let n of e)for(let e of n.items){let r=iJ(e,n.group);r===`memory`?t.memory+=1:r===`document`?t.documents+=1:t.context+=1}return t}function oJ(e){return e.memory+e.documents+e.context>0}function sJ(e){let t=[];return e.memory>0&&t.push(e.memory===1?st():Dt({count:e.memory})),e.documents>0&&t.push(e.documents===1?oc():Sb({count:e.documents})),e.context>0&&t.push(e.context===1?pf():gx({count:e.context})),t.join(` · `)}function cJ(e){return e.title??e.file_name??e.id??e.type??gm()}function lJ(e){return e.title&&e.file_name?e.file_name:void 0}function uJ(e){return e.file_name??cJ(e)}function dJ(e){let t=[];return e.type&&cJ(e)!==e.type&&t.push(e.type),e.date&&t.push(e.date),e.collection&&t.push(e.collection),typeof e.score==`number`&&t.push(Sd({score:e.score.toFixed(2)})),t}function fJ(e,t){let n=[];return e.forEach((e,r)=>{e.group===t&&e.items.forEach((t,i)=>{n.push({key:`${e.pluginId}|${e.group}|${t.id??t.file_name??`?`}|${r}.${i}`,group:e.group,pluginId:e.pluginId,source:e.source,item:t})})}),n.sort((e,t)=>(t.item.score??0)-(e.item.score??0))}function pJ(e,t){let n=t.trim().toLowerCase();return n===``||[gJ(e),e.item.file_name??``,e.item.text??``,...dJ(e.item)].join(` `).toLowerCase().includes(n)}function mJ(e){return iJ(e.item,e.group)===`document`}function hJ(e){return iJ(e.item,e.group)===`context`}function gJ(e){return hJ(e)?eb():cJ(e.item)}var _J=(0,q.createContext)(null),vJ=[];function yJ(){let e=$(e=>e.metadata?.custom?.provenanceParts??vJ),t=$(e=>e.metadata?.custom?.messageId),n=$(e=>e.metadata?.custom?.attachedDocCount??0),r=(0,q.useContext)(_J),i=aJ(e);if(e.length===0||!oJ(i))return null;let a=r?.activeMessageId===t&&t!==void 0,o=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-actrow__counts`,children:sJ(i)}),n>0?(0,J.jsxs)(`span`,{className:`oc-actrow__badge`,title:Bv({count:n}),children:[(0,J.jsx)(xC,{size:12,"aria-hidden":!0}),n]}):null]});return(0,J.jsx)(xK,{icon:(0,J.jsx)(SA,{size:14}),label:$a(),trailing:o,active:a,ariaExpanded:a,ariaHasPopup:!0,ariaLabel:Og(),onClick:()=>t&&r?.openFor(t)})}function bJ({messageId:e,onClose:t}){let n=U(G.messages.getProvenanceParts,{messageId:e}),r=(0,q.useMemo)(()=>n??[],[n]),i=U(G.agents.documentaryAvailable,{}),a=U(G.documentAttachments.getDocumentAttachments,{sourceMessageId:e}),o=W(G.documentAttachments.attachDocuments),s=Mw(),c=(0,q.useMemo)(()=>{let e=new Map;for(let t of a??[])e.set(t.entryKey,t);return e},[a]),l=(a??[]).some(e=>e.status===`pending`),[u,d]=(0,q.useState)(``),[f,p]=(0,q.useState)(!1),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(new Set);(0,q.useEffect)(()=>{d(``),p(!1),h(!1),_(!1),y(new Set)},[e]);let b=(0,q.useMemo)(()=>fJ(r,`documents`).filter(e=>mJ(e)&&pJ(e,u)),[r,u]),x=(0,q.useMemo)(()=>fJ(r,`documents`).filter(e=>hJ(e)&&pJ(e,u)),[r,u]),S=(0,q.useMemo)(()=>fJ(r,`memory`).filter(e=>pJ(e,u)),[r,u]),C=aJ(r),w=e=>y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),T=(e,t)=>y(n=>{let r=new Set(n);for(let n of e)t?r.add(n):r.delete(n);return r}),E=(0,q.useMemo)(()=>fJ(r,`documents`).filter(e=>mJ(e)&&v.has(e.key)),[r,v]),D=i!=null&&E.length>0&&!l;async function O(){if(D)try{await o({sourceMessageId:e,items:E.map(e=>({entryKey:e.key,reference:uJ(e.item)}))}),s.success(hv())}catch(e){let t=jw(e);t.includes(`fetch_in_flight`)?s.error(Jm()):t.includes(`no_documentary_agent`)?s.error(Vd()):s.error(Yg(),e)}}let k=n===void 0;return(0,J.jsxs)(`div`,{className:`oc-sources-panel`,children:[(0,J.jsxs)(`div`,{className:`oc-sources-panel__head`,children:[(0,J.jsxs)(`div`,{className:`oc-sources-panel__heading`,children:[(0,J.jsx)(`h2`,{className:`oc-sources-panel__title`,children:Fm()}),(0,J.jsx)(`p`,{className:`oc-sources-panel__sub`,children:sJ(C)})]}),(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,onClick:t,"aria-label":ou(),title:ou(),children:(0,J.jsx)(XC,{size:16,"aria-hidden":!0})})]}),(0,J.jsxs)(`div`,{className:`oc-sources-panel__search`,children:[(0,J.jsx)(yC,{size:15,"aria-hidden":!0}),(0,J.jsx)(xw,{value:u,onChange:e=>d(e.target.value),placeholder:O_(),"aria-label":O_()})]}),(0,J.jsx)(`div`,{className:`oc-sources-panel__body`,children:k?(0,J.jsx)(`p`,{className:`oc-sources-panel__empty`,children:(0,J.jsx)(kC,{size:14,className:`oc-iconbtn__spin`,"aria-hidden":!0})}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(xJ,{icon:(0,J.jsx)(SA,{size:14,"aria-hidden":!0}),label:Rs(),count:b.length,expanded:f,onToggle:()=>p(e=>!e),entries:b,selectable:!0,selected:v,onToggle1:w,onToggleAll:e=>T(b.map(e=>e.key),e),attachmentByKey:c}),(0,J.jsx)(xJ,{icon:(0,J.jsx)(ZA,{size:14,"aria-hidden":!0}),label:Gb(),count:x.length,expanded:m,onToggle:()=>h(e=>!e),entries:x,selectable:!1,selected:v,onToggle1:w,onToggleAll:e=>T(x.map(e=>e.key),e),attachmentByKey:c}),(0,J.jsx)(xJ,{icon:(0,J.jsx)(lA,{size:14,"aria-hidden":!0}),label:Be(),count:S.length,expanded:g,onToggle:()=>_(e=>!e),entries:S,selectable:!1,selected:v,onToggle1:w,onToggleAll:e=>T(S.map(e=>e.key),e),attachmentByKey:c}),b.length===0&&x.length===0&&S.length===0?(0,J.jsx)(`p`,{className:`oc-sources-panel__empty`,children:Jp()}):null]})}),E.length>0?(0,J.jsxs)(`div`,{className:`oc-sources-panel__actions`,children:[(0,J.jsxs)(`div`,{className:`oc-sources-panel__actrow`,children:[(0,J.jsx)(`span`,{className:`oc-sources-panel__selcount`,children:My({count:E.length})}),(0,J.jsxs)(K,{variant:`outline`,size:`sm`,disabled:!D,onClick:()=>void O(),children:[l?(0,J.jsx)(kC,{size:14,className:`oc-iconbtn__spin`,"aria-hidden":!0}):(0,J.jsx)(dj,{size:14,"aria-hidden":!0}),cg()]})]}),(0,J.jsx)(`p`,{className:`oc-sources-panel__acthint`,children:i==null?Vd():l?Jm():Ff()})]}):null]})}function xJ({icon:e,label:t,count:n,expanded:r,onToggle:i,entries:a,selectable:o,selected:s,onToggle1:c,onToggleAll:l,attachmentByKey:u}){if(n===0)return null;let d=a.every(e=>s.has(e.key));return(0,J.jsxs)(`section`,{className:`oc-srcsec${r?` is-open`:``}`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-srcsec__head`,"aria-expanded":r,onClick:i,children:[r?(0,J.jsx)(XS,{size:14,"aria-hidden":!0}):(0,J.jsx)(QS,{size:14,"aria-hidden":!0}),e,(0,J.jsx)(`span`,{className:`oc-srcsec__label`,children:t}),(0,J.jsx)(`span`,{className:`oc-srcsec__count`,children:n})]}),r?(0,J.jsxs)(`div`,{className:`oc-srcsec__body`,children:[o?(0,J.jsxs)(`label`,{className:`oc-srcsec__all`,children:[(0,J.jsx)(jC,{checked:d,onCheckedChange:e=>l(e===!0)}),(0,J.jsx)(`span`,{children:np()})]}):null,a.map(e=>(0,J.jsx)(SJ,{entry:e,selectable:o,selected:s.has(e.key),onToggle:()=>c(e.key),attachment:u.get(e.key)},e.key))]}):null]})}function SJ({entry:e,selectable:t,selected:n,onToggle:r,attachment:i}){let[a,o]=(0,q.useState)(!1),s=(0,q.useRef)(null),[c,l]=(0,q.useState)(!1),{item:u}=e;(0,q.useEffect)(()=>{let e=s.current;if(!e)return;let t=()=>l(e.scrollHeight>e.clientHeight+1);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[u.text]);let d=dJ(u),f=typeof u.score==`number`?Math.max(0,Math.min(1,u.score)):null,p=mJ(e);return(0,J.jsxs)(`div`,{className:`oc-srccard${t&&n?` is-selected`:``}`,children:[t?(0,J.jsx)(`label`,{className:`oc-srccard__pick`,children:(0,J.jsx)(jC,{checked:n,onCheckedChange:r})}):null,(0,J.jsxs)(`div`,{className:`oc-srccard__body`,children:[(0,J.jsx)(`div`,{className:`oc-srccard__title`,children:gJ(e)}),p&&lJ(e.item)?(0,J.jsx)(`div`,{className:`oc-srccard__subid`,title:lJ(e.item),children:lJ(e.item)}):null,d.length>0||f!==null?(0,J.jsxs)(`div`,{className:`oc-srccard__meta`,children:[d.map(e=>(0,J.jsx)(`span`,{className:`oc-srccard__chip`,children:e},e)),f===null?null:(0,J.jsx)(`span`,{className:`oc-srccard__relev`,title:Sd({score:f.toFixed(2)}),children:(0,J.jsx)(`span`,{className:`oc-srccard__relev-track`,"aria-hidden":!0,children:(0,J.jsx)(`span`,{className:`oc-srccard__relev-fill`,style:{width:`${Math.round(f*100)}%`}})})})]}):null,u.text?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`blockquote`,{ref:s,className:`oc-srccard__excerpt${a?` is-full`:``}`,children:u.text}),c||a?(0,J.jsx)(`button`,{type:`button`,className:`oc-srccard__more`,onClick:()=>o(e=>!e),children:a?id():Xo()}):null]}):null,p?(0,J.jsx)(CJ,{attachment:i}):null]})]})}function CJ({attachment:e}){if(e?.status===`ready`&&e.url){let t=e.filename??Cp();return(0,J.jsxs)(`a`,{className:`oc-srccard__origin oc-srccard__origin--ready`,href:e.url,download:e.filename??void 0,target:`_blank`,rel:`noreferrer`,title:Cp(),children:[(0,J.jsx)(xC,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-srccard__origin-name`,children:t})]})}return e?.status===`pending`?(0,J.jsxs)(`div`,{className:`oc-srccard__origin oc-srccard__origin--pending`,children:[(0,J.jsx)(kC,{size:13,"aria-hidden":!0}),cy()]}):e?.status===`not_found`||e?.status===`failed`?(0,J.jsxs)(`div`,{className:`oc-srccard__origin oc-srccard__origin--missing`,"aria-disabled":!0,children:[(0,J.jsx)(XC,{size:13,"aria-hidden":!0}),g()]}):(0,J.jsxs)(`div`,{className:`oc-srccard__origin`,"aria-disabled":!0,children:[(0,J.jsx)(xC,{size:13,"aria-hidden":!0}),cee()]})}function wJ(e){return typeof e==`string`&&e.trim()||null}function TJ(e){return wJ(e)??void 0}function EJ(e){return TJ(e)?.toLowerCase()}function DJ(e){return EJ(e)??``}var OJ=new Set(`token.key.api_key.apikey.secret.access_token.auth_token.password.pass.passwd.auth.jwt.session.id_token.code.client_secret.app_secret.hook_token.refresh_token.signature.x_amz_signature.x_amz_security_token.private_key.credential.authorization.sig.x_api_key.x_access_token.x_auth_token`.split(`.`)),kJ=/[\p{C}\p{Z}\u115F\u1160\u3164\uFFA0+]/gu,AJ=/(?:^|_)token(?:_[a-f0-9]{16,})?$/u,jJ=8;function MJ(e){let t=e.replace(kJ,``);for(let e=0;e<=jJ;e+=1){let e;try{e=decodeURIComponent(t).replace(kJ,``)}catch{break}if(e===t)return{value:DJ(t).replaceAll(`-`,`_`),unresolvedEncoding:!1};t=e}return{value:DJ(t).replaceAll(`-`,`_`),unresolvedEncoding:t.includes(`%`)}}function NJ(e){let t=MJ(e);return t.unresolvedEncoding||OJ.has(t.value)||AJ.test(t.value)}function PJ(e){return e>=55296&&e<=56319}function FJ(e){return e>=56320&&e<=57343}function IJ(e,t,n){let r=e.length,i=t<0?Math.max(r+t,0):Math.min(t,r),a=n===void 0?r:n<0?Math.max(r+n,0):Math.min(n,r);return a<=i?``:(i>0&&i<r&&FJ(e.charCodeAt(i))&&PJ(e.charCodeAt(i-1))&&(i+=1),a>0&&a<r&&PJ(e.charCodeAt(a-1))&&FJ(e.charCodeAt(a))&&--a,e.slice(i,a))}function LJ(e){let t=e.match(/^\/(.+)\/([gimsuy]*)$/);if(!t)return[e,`gi`];let n=t[1]??``,r=t[2]??``;return[n,r.includes(`g`)?r:`${r}g`]}function RJ(e){let t=e.length>0&&typeof e[e.length-1]==`object`&&e[e.length-1]!==null?e.length-2:e.length-1,n=t-1,r=typeof e[0]==`string`?e[0]:``,i=e.slice(1,n).map(e=>typeof e==`string`?e:``),a=typeof e[n]==`number`?e[n]:-1;return{match:r,groups:i,input:typeof e[t]==`string`?e[t]:``,offset:a}}var zJ=new WeakMap;function*BJ(e,t){if(!(t instanceof RegExp)){yield*t.exec(e);return}let n=t;if(!t.global){let e=zJ.get(t);n=e??new RegExp(t.source,`${t.flags}g`),e||zJ.set(t,n)}let r=n.unicode||n.flags.includes(`v`),i=0;for(;i<=e.length;){let t=n.lastIndex,a;try{n.lastIndex=i,a=n.exec(e)}finally{n.lastIndex=t}if(!a)return;if(i=a.index+a[0].length,!a[0]){let t=e.codePointAt(i);i+=r&&t!==void 0&&t>65535?2:1}yield{match:a[0],groups:a.slice(1).map(e=>e??``),input:e,offset:a.index}}}function VJ(e,t,n,r){if(t instanceof RegExp)return e.replace(t,r??((...e)=>n(RJ(e))));let i=[],a=0;for(let r of BJ(e,t))i.push(e.slice(a,r.offset),n(r)),a=r.offset+r.match.length;return i.length?i.join(``)+e.slice(a):e}function HJ(e,t){let n=e.split(/\r?\n/).filter(Boolean);return n.length<2?`***`:`${n[0]}\n${t}\n${n[n.length-1]}`}var UJ="[A-Za-z0-9!#$%&'*+.^_`|~-]+",WJ=String.raw`(?:\[REDACTED\]|[^\s\\"',;&#?<>)}\]]+)`,GJ=String.raw`\\{1,64}t`,KJ=String.raw`(?:[ \t]+|${GJ})`,qJ=String.raw`(?:[ \t]*\r?\n${KJ}|[ \t]*\\{1,64}r\\{1,64}n${KJ}|[ \t]*\\{1,64}n${KJ}|[ \t]*${GJ}[ \t]*|[ \t]*)`,JJ=String.raw`(?:[ \t]*\r?\n${KJ}|[ \t]*\\{1,64}r\\{1,64}n${KJ}|[ \t]*\\{1,64}n${KJ}|[ \t]*${GJ}[ \t]*|[ \t]+)`,YJ=String.raw`(?:[ \t\r\n]*|[ \t]*\\{1,64}r\\{1,64}n(?:[ \t]*|${GJ})|[ \t]*\\{1,64}n(?:[ \t]*|${GJ})|[ \t]*${GJ}[ \t]*)`,XJ=String.raw`(^|[^A-Za-z0-9_-]|\\{1,64}[rn])`,ZJ=String.raw`(?:\\{1,64}["']|["']|)`;String.raw`${XJ}(?:x-goog-api-key|api-key|apikey|x-api-token|x-access-token)${ZJ}[ \t]*[:=]${qJ}${ZJ}([^\s\\"',;]+)`,new RegExp(String.raw`${XJ}(?:Proxy-)?Authorization${ZJ}[ \t]*[:=]${qJ}${ZJ}(${UJ})${JJ}`,`giu`);var QJ=String.raw`-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]+?-----END [A-Z ]*PRIVATE KEY-----`,$J=String.raw`CARD[_-]?NUMBER|CARD[_-]?CVC|CARD[_-]?CVV|CVC|CVV|SECURITY[_-]?CODE|PAYMENT[_-]?CREDENTIAL|SHARED[_-]?PAYMENT[_-]?TOKEN`,eY=String.raw`card[-_]?number|card[-_]?cvc|card[-_]?cvv|cvc|cvv|security[-_]?code|payment[-_]?credential|shared[-_]?payment[-_]?token`,tY=String.raw`cardNumber|card_number|cardCvc|card_cvc|cardCvv|card_cvv|cvc|cvv|securityCode|security_code|paymentCredential|payment_credential|sharedPaymentToken|shared_payment_token`,nY=String.raw`aws[-_]?secret[-_]?access[-_]?key|awsSecretAccessKey|SecretAccessKey`,rY=String.raw`access[-_]?token|auth[-_]?token|hook[-_]?token|refresh[-_]?token|id[-_]?token|api[-_]?key|apikey|client[-_]?secret|app[-_]?secret|private[-_]?key|${nY}|credential|authorization|token|key|secret|password|pass|passwd|auth|jwt|session|code|signature|x[-_]?amz[-_]?(?:signature|security[-_]?token)`,iY=String.raw`${rY}|app[-_]?secret|credential|${eY}`,aY=String.raw`access_token|refresh_token|id_token|auth[-_]?token|hook[-_]?token|api[-_]?key|client[-_]?secret|app[-_]?secret|private[-_]?key|authorization|jwt|token|secret|password|pass|passwd|credential|${eY}`,oY=String.raw`access[-_]?token|refresh[-_]?token|id[-_]?token|auth[-_]?token|hook[-_]?token|api[-_]?(?:key|secret)|client[-_]?secret|app[-_]?secret|private[-_]?key|secret[-_]?key|key[-_]?material|authorization|jwt|token|secret|password|passphrase|pass|passwd|credential|${eY}`,sY=String.raw`access-token|refresh-token|id-token|auth-token|hook-token|api[-_]?(?:key|secret)|secret[-_]?key|key[-_]?material|passphrase`,cY=String.raw`password|passphrase|pass|passwd`,lY=String.raw`${nY}|api[-_]?key|hook[-_]?token|access[-_]?token|refresh[-_]?token|id[-_]?token|token|secret|password|passwd|credential|private[-_]?key|client[-_]?secret|${eY}`;String.raw`\p{C}\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000\u115F\u1160\u3164\uFFA0`;var uY=String.raw`/\b[A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|${$J})\b\s*[=:]\s*(["']?)([^\s"'\\]+)\1/g`,dY=String.raw`/\b[A-Z0-9_]*(?:KEY|TOKEN|SECRET|PASSWORD|PASSWD|${$J})\b\s*[=:]\s*\\+(["'])([^\s"'\\]+)\\+\1/g`,fY=String.raw`(^|[\s,;({\["])(?:${aY})=(["'\x60])((?:(?!\2)[^\r\n])+)\2`,pY=String.raw`(^|[\s,;({\["])(?:${aY})=(["'\x60]?[^\s&#"'\x60<>]+)`,mY=String.raw`access[-_]?token|refresh[-_]?token|id[-_]?token|auth[-_]?token|hook[-_]?token|api[-_]?(?:key|secret)|secret[-_]?key|key[-_]?material|authorization|jwt|token|secret|password|passphrase|pass|passwd|${eY}`,hY=String.raw`/(^|[\s,{])(?:(?:${mY})(?:\s*:\s*|\s+=\s*|=\s*)|[a-z0-9][a-z0-9._-]{0,79}[-_](?:${cY})\s*[:=]\s*|[a-z0-9_.-]{1,80}\.(?:${oY})\s*[:=]\s*)(["'\x60])((?:(?!\2)[^\r\n])+)\2/g`,gY=String.raw`/(^|[\s,{])(?:${oY})(?:\s*:\s*|\s+=\s*|=\s+)([^\s#"'\x60<>]+)/g`,_Y=String.raw`/(^|[\s,{])(?:${sY})=([^\s#"'\x60<>]+)/g`,vY=String.raw`/(^|[\s,{])[a-z0-9][a-z0-9._-]{0,79}[-_](?:${cY})\s*[:=]\s*([^\s#"'\x60<>]+)/g`,yY=String.raw`/(^|[\s,{])[a-z0-9_.-]{1,80}\.(?:${oY})\s*[:=]\s*([^\s#"'\x60<>]+)/g`,bY=String.raw`"(?:apiKey|api_key|apiToken|api_token|bearerToken|bearer_token|token|secret|password|passwd|${nY}|credential|authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token|accessToken|access_token|refreshToken|refresh_token|idToken|id_token|authToken|auth_token|clientSecret|client_secret|privateKey|private_key|secret_value|raw_secret|secret_input|key_material)"\s*:\s*"([^"]+)"`,xY=String.raw`"(?:${tY})"\s*:\s*"([^"]+)"`,SY=String.raw`(^|[\s,{])["']?(?:api[-_]key|access[-_]token|refresh[-_]token|id[-_]token|authToken|auth[-_]token|clientSecret|client[-_]secret|appSecret|app[-_]secret|private[-_]key|credential|authorization|secret[-_]value|raw[-_]secret|secret[-_]input|key[-_]material)["']?\s*[:=]\s*(["'])([^"'\r\n]+)\2`,CY=String.raw`(^|[\s,{])["']?(?:authorization|proxy-authorization|cookie|set-cookie|x-api-key|x-auth-token)["']?\s*[:=]\s*(["'])([^"'\r\n]+)\2`,wY=String.raw`(^|[^A-Za-z0-9])(?<!;base64,[A-Za-z0-9+/=]*)`,TY=String.raw`(^|[^A-Za-z0-9_])`;function EY(e){let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||e===`/`||e===`+`||e===`=`}var DY=/(?=[A-Za-z0-9/+=]{0,39}[A-Z])(?=[A-Za-z0-9/+=]{0,39}[a-z])(?=[A-Za-z0-9/+=]{0,39}[0-9/+=])(?=[A-Za-z0-9/+=]{0,39}[G-Zg-z/+=])[A-Za-z0-9/+=]{40}/u,OY=/[A-Za-z0-9/+=]{40}/u;function kY(e){return e.length>=40&&OY.test(e)&&DY.test(e)}var AY=/\s/,jY=/[A-Za-z0-9+.-]/,MY=/[A-Za-z]/;function*NY(e){if(!kY(e))return;let t={'"':`"`,"'":`'`,"`":"`","<":`>`,"(":`)`,"[":`]`,"{":`}`},n=-1,r=-1,i,a=0,o=[];for(let s=0;s<=e.length;s++){let c=e[s]??``,l=s===e.length||AY.test(c),u=a;if(a=c===`\\`?a+1:0,c&&EY(c)?n===-1&&(n=s):n!==-1&&(s-n===40?o.push({start:n,end:s,origin:n,url:i}):s-n>40&&c===`@`&&e[s-41]===`/`&&o.push({start:s-40,end:s,origin:n,url:i}),n=-1),l){i&&(i.end=Math.min(i.end,s));for(let t of o){let n=t.url,r=n&&!n.hasAt&&n.portValid&&(n.portStart===-1||(n.authorityEnd===-1?n.end:n.authorityEnd)>n.portStart+1),i=e[t.start-1]??``,a=e[t.end]??``,o=t.start!==t.origin,s=n&&n.portStart!==-1&&t.origin===n.portStart+1&&n.authorityEnd>t.origin&&t.end>n.authorityEnd&&a===`@`;if(!o&&(i===`_`||EY(i))||a===`_`||e.slice(t.origin-8,t.origin)===`;base64,`||r&&!s&&t.start>=n.start&&t.end<=n.end)continue;let c=e.slice(t.start,t.end);DY.test(c)&&(yield{match:c,groups:[c],input:e,offset:t.start})}o.length=0,r=-1,i=void 0;continue}if(i&&s>=i.start&&(c===i.closing&&u===i.closingEscapeDepth?(i.end=Math.min(i.end,s),i=void 0):(`?#"'<>\`|()[]{}`.includes(c)&&(i.end=Math.min(i.end,s)),i.queryOrFragment||=c===`?`||c===`#`,i.authorityEnd===-1&&(i.hasAt||=c===`@`,`/?#`.includes(c)?i.authorityEnd=s:s<i.end&&(c===`:`?(i.portValid&&=i.portStart===-1,i.portStart=s):i.portStart!==-1&&(c<`0`||c>`9`)&&(i.portValid=!1))))),jY.test(c))r===-1&&(r=s);else{if((!i||s>=i.end&&!i.queryOrFragment)&&c===`:`&&e.startsWith(`//`,s+1)&&r!==-1&&MY.test(e[r])){let n=e[r-1],a=0;for(let t=r-2;t>=0&&e[t]===`\\`;t--)a++;i={start:s+3,end:e.length,authorityEnd:-1,portStart:-1,portValid:!0,hasAt:!1,queryOrFragment:!1,closing:n?t[n]:void 0,closingEscapeDepth:a}}r=-1}}}var PY=Object.freeze({source:`aws-secret-access-key`,exec:NY,couldMatch:kY}),FY=String.raw`\bbot(\d{6,}:[A-Za-z0-9_-]{20,})\b`,IY=String.raw`\b(\d{6,}:[A-Za-z0-9_-]{20,})\b`,LY=`x-goog-api-key|api-key|apikey|x-api-token|x-access-token`,RY=`X-OpenClaw-Token|x-pomerium-jwt-assertion|X-Api-Key|X-Auth-Token`;RegExp(`^(?:${LY}|${RY})$`,`i`);var zY=String.raw`(^|[^A-Za-z0-9_?&-]|\\{1,64}[rn])`,BY=String.raw`${zY}(?:${LY})${ZJ}[ \t]*:${qJ}${ZJ}([^\s\\"',;]+)`,VY=String.raw`${zY}(?:${LY})${ZJ}[ \t]*=${qJ}${ZJ}([^\s\\"',;]+)`,HY=String.raw`${zY}(?:${RY})\s*:\s*([^\s"',;]+)`,UY=String.raw`${zY}(?:${RY})\s*=\s*([^\s"',;]+)`,WY=[String.raw`${XJ}Proxy-Authorization${ZJ}[ \t]*[:=]${qJ}${ZJ}${UJ}${JJ}(${WJ})`,String.raw`${XJ}Proxy-Authorization${ZJ}[ \t]*[:=]${qJ}${ZJ}(${WJ})[ \t]*(?=${ZJ}(?:$|[,;)}\]]|\r?\n(?![ \t])))`,String.raw`${XJ}Authorization${ZJ}[ \t]*[:=]${qJ}${ZJ}(?!(?:Bearer|Basic|Bot)(?=${JJ}))${UJ}${JJ}(${WJ})`,String.raw`${XJ}Authorization${ZJ}[ \t]*[:=]${qJ}${ZJ}(?!(?:Bearer|Basic|Bot)(?=${JJ}))(${WJ})[ \t]*(?=${ZJ}(?:$|[,;)}\]]|\r?\n(?![ \t])))`,BY,VY],GY=String.raw`Authorization${ZJ}[ \t]*[:=]${YJ}${ZJ}Bearer${JJ}(${WJ})`,KY=String.raw`Authorization${ZJ}[ \t]*[:=]${YJ}${ZJ}Basic${JJ}(${WJ})`,qY=String.raw`Authorization${ZJ}[ \t]*[:=]${YJ}${ZJ}Bot${JJ}(${WJ})`,JY=String.raw`\bBearer\s+([-A-Za-z0-9._~+/=]{18,})(?![-A-Za-z0-9._~+/=])`;[...WY];var YY=[uY,dY,bY,xY,SY,CY,String.raw`--(?:${lY})=([^\s"']+)`,String.raw`--(?:${lY})\s+(?!(?:or|and)\b(?=\s+--))(["']?)([^\s"']+)\1`,GY,KY,qY,...WY,HY,UY,JY,String.raw`\b(?:https?|wss?|ftp):\/\/[^\/\s:@]*:([^\/\s@]+)@`,String.raw`\b(?:postgres(?:ql)?|mysql|mongodb(?:\+srv)?|rediss?|amqps?):\/\/[^:\s/@]*:([^@\s]+)@`,String.raw`(^|[\s,;])(?:${iY})=([^&\s]+)(?=&[A-Za-z_][A-Za-z0-9_.-]*=)`,fY,pY,hY,gY,_Y,vY,yY,QJ,String.raw`(^|[\s,{])["']?(?:${nY})["']?\s*[:=]\s*(["']?)([A-Za-z0-9/+=]{40})(?![A-Za-z0-9/+=])\2`],XY=[String.raw`\b(sk-[A-Za-z0-9_-]{8,})\b`,String.raw`(ghp_[A-Za-z0-9]{10,})`,String.raw`(github_pat_[A-Za-z0-9_]{10,})`,String.raw`(gho_[A-Za-z0-9]{10,})`,String.raw`(ghu_[A-Za-z0-9]{10,})`,String.raw`(ghs_[A-Za-z0-9]{10,})`,String.raw`(ghr_[A-Za-z0-9]{10,})`,String.raw`(glpat-[A-Za-z0-9._=\-]{20,})`,String.raw`(gloas-(?:[A-Fa-f0-9]{65,}|[A-Za-z0-9_-]{64}|[A-Fa-f0-9]{32,}))`,String.raw`(gldt-[A-Za-z0-9_-]{20,})`,String.raw`(glcbt-[A-Za-z0-9]{1,5}_[A-Za-z0-9_-]{20,})`,String.raw`(glptt-[A-Za-z0-9_-]{40,})`,String.raw`(glft-(?:[A-Za-z0-9_-]{20,}|[a-h0-9]+-[0-9]+_))`,String.raw`(glimt-[A-Za-z0-9_-]{25,})`,String.raw`(glagent-[A-Za-z0-9_-]{50,})`,String.raw`(glwt-[A-Za-z0-9_-]{20,})`,String.raw`(glsoat-[A-Za-z0-9_-]{20,})`,String.raw`(glffct-[A-Za-z0-9_-]{20,})`,String.raw`(glrt-[A-Za-z0-9._-]{20,})`,String.raw`(glrtr?-[A-Za-z0-9_-]{27,300}\.[0-9a-z]{2}\.[0-9a-z]{9})`,String.raw`(GR1348941[A-Za-z0-9_-]{20,})`,String.raw`(_gitlab_session=[A-Za-z0-9%._-]{20,})`,String.raw`(xox[baprs]-[A-Za-z0-9-]{10,})`,String.raw`(xapp-[A-Za-z0-9-]{10,})`,String.raw`(https:\/\/hooks\.slack\.com\/(?:services\/T[A-Z0-9]+\/B[A-Z0-9]+|workflows\/T[A-Z0-9]+\/A[A-Z0-9]+\/[0-9]{17,19})\/[A-Za-z0-9]{20,})`,String.raw`(https:\/\/discord(?:app)?\.com\/api\/webhooks\/[0-9]{17,20}\/[A-Za-z0-9_-]{60,})`,String.raw`discord(?:.|\n|\r){0,40}?\b([A-Za-z0-9_-]{24}\.[A-Za-z0-9_-]{6}\.[A-Za-z0-9_-]{27})\b`,String.raw`(gsk_[A-Za-z0-9_-]{10,})`,String.raw`(AIza[0-9A-Za-z\-_]{20,})`,String.raw`(ya29\.[0-9A-Za-z_\-./+=]{10,})`,String.raw`(1//0[0-9A-Za-z_\-./+=]{10,})`,String.raw`(eyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})`,String.raw`(pplx-[A-Za-z0-9_-]{10,})`,String.raw`(fal_[A-Za-z0-9_-]{10,})`,String.raw`${TY}(fc-[A-Za-z0-9]{10,})`,String.raw`(bb_live_[A-Za-z0-9_-]{10,})`,String.raw`${wY}(gAAAA[A-Za-z0-9_=-]{20,})`,String.raw`(sk_live_[A-Za-z0-9]{10,})`,String.raw`(sk_test_[A-Za-z0-9]{10,})`,String.raw`(rk_live_[A-Za-z0-9]{10,})`,String.raw`(SG\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,})`,String.raw`(npm_[A-Za-z0-9]{10,})`,String.raw`(pypi-[A-Za-z0-9_-]{10,})`,String.raw`(dop_v1_[A-Za-z0-9]{10,})`,String.raw`(doo_v1_[A-Za-z0-9]{10,})`,String.raw`(dor_v1_[A-Za-z0-9]{10,})`,String.raw`(dp\.(?:ct|pt|sa|scim|audit)\.[A-Za-z0-9]{40,44})`,String.raw`(dp\.st\.[A-Za-z0-9]{40,44})`,String.raw`(dp\.st\.[a-z0-9_-]{2,35}\.[A-Za-z0-9]{40,44})`,String.raw`(dckr_(?:pat|oat)_[A-Za-z0-9_-]{27,32})`,String.raw`(bkua_[a-z0-9]{40})`,String.raw`(CCIPAT_[A-Za-z0-9]{22}_[A-Fa-f0-9]{40})`,String.raw`(sbp_[a-z0-9]{40})`,String.raw`${wY}(dapi[0-9a-f]{32}(?:-\d)?)`,String.raw`(dd[pw]_[A-Za-z0-9]{36})`,String.raw`(glsa_[A-Za-z0-9_]{41})`,String.raw`(glc_eyJ[A-Za-z0-9+/=]{60,160})`,String.raw`(nfp_[A-Za-z0-9_]{36})`,String.raw`(CFPAT-[A-Za-z0-9_\-]{40,})`,String.raw`${wY}(ATCTT3xFfG[A-Za-z0-9+/=_-]+=[A-Za-z0-9]{8})`,String.raw`${wY}(ATATT[A-Za-z0-9+/=_-]+=[A-Za-z0-9]{8})`,String.raw`${wY}(ATBB[A-Za-z0-9_=.-]{16,})`,String.raw`(BBDC-[A-Za-z0-9+/@_-]{40,50})`,String.raw`(HRKU-AA[A-Za-z0-9_-]{20,})`,String.raw`(pat-(?:eu|na)1-[A-Za-z0-9]{8}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{4}\-[A-Za-z0-9]{12})`,String.raw`(apify_api_[A-Za-z0-9\-]{20,})`,String.raw`(FlyV1 fm\d+_[A-Za-z0-9+/=,_-]{100,})`,String.raw`(fio-u-[A-Za-z0-9_-]{40,})`,String.raw`(^|[^A-Za-z0-9_])(am_[A-Za-z0-9_-]{10,})`,String.raw`(^|[^A-Za-z0-9_])(sk_[A-Za-z0-9_]{10,})`,String.raw`(tvly-[A-Za-z0-9]{10,})`,String.raw`(exa_[A-Za-z0-9]{10,})`,String.raw`(syt_[A-Za-z0-9]{10,})`,String.raw`(retaindb_[A-Za-z0-9]{10,})`,String.raw`(hsk-[A-Za-z0-9]{10,})`,String.raw`(mem0_[A-Za-z0-9]{10,})`,String.raw`(brv_[A-Za-z0-9]{10,})`,String.raw`(xai-[A-Za-z0-9]{30,})`,String.raw`${TY}(fw-[A-Za-z0-9]{30,})`,String.raw`${TY}(fw_[A-Za-z0-9]{30,})`,String.raw`${TY}(fpk_[A-Za-z0-9]{30,})`,String.raw`${wY}(AKIA[A-Z0-9]{16})`,String.raw`${wY}(ASIA[A-Z0-9]{16})`,String.raw`(AKID[A-Za-z0-9]{10,})`,String.raw`(LTAI[A-Za-z0-9]{10,})`,String.raw`(hf_[A-Za-z0-9]{10,})`,String.raw`(api_org_[A-Za-z0-9]{20,})`,String.raw`(r8_[A-Za-z0-9]{10,})`,FY,IY],ZY=[...YY,...XY,PY],QY=new Set([uY,dY,bY,SY,CY,fY,pY,hY,gY,_Y,vY,yY]);ZY.filter(e=>typeof e!=`string`||!QY.has(e));var $Y=/([?&])([^=&#\s]+)=([^&#\s"'<>]+)/gu,eX=ZY.map(e=>typeof e==`string`?new RegExp(...LJ(e)):e),tX=[[/\b(Authorization|Cookie|Set-Cookie)\s*:\s*[^\n\r]+/gi,`$1: [redacted]`],[/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{12,}/gi,`$1[redacted]`],[/\b(api[_.-]?key|token|secret|password|passwd|authorization)\b(["'])(\s*:\s*)"(?:\\.|[^"\\\r\n])*"/gi,`$1$2$3"[redacted]"`],[/\b(api[_.-]?key|token|secret|password|passwd|authorization)\b(["'])(\s*:\s*)'(?:\\.|[^'\\\r\n])*'/gi,`$1$2$3'[redacted]'`],[/\b(api[_.-]?key|token|secret|password|passwd|authorization)\b(\s*[:=]\s*)["']?[^"',\s}]+/gi,`$1$2[redacted]`],[/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?-----END [A-Z ]*PRIVATE KEY-----/g,`[redacted private key]`]];function nX(e){return e.length<=10?`***`:`${IJ(e,0,6)}...${IJ(e,-4)}`}function rX({match:e,groups:t,input:n,offset:r}){let i=r<0?``:n.slice(r+e.length);if(e.includes(`PRIVATE KEY-----`))return HJ(e,`...redacted...`);let a=t.findLast(e=>typeof e==`string`&&e.length>0)??e;if(a===`$`&&i.startsWith("`"))return e;let o=nX(a);if(a===e)return o;let s=e.lastIndexOf(a);return s<0?`***`:`${e.slice(0,s)}${o}${e.slice(s+a.length)}`}function iX(e){return e.replace($Y,(e,t,n,r)=>NJ(n)?`${t}${n}=${nX(r)}`:e)}function aX(e){let t=iX(e);for(let e of eX)t=VJ(t,e,rX);return tX.reduce((e,[t,n])=>e.replace(t,n),t)}var oX=aX,sX=new Set([`status`,`exitCode`,`durationMs`]);function cX(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function lX(e){if(typeof e==`string`)return{kind:`text`,text:e};if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e,n=Object.keys(t);if(typeof t.exitCode==`number`&&n.every(e=>sX.has(e)))return{kind:`outcome`,status:typeof t.status==`string`?t.status:null,exitCode:t.exitCode,durationMs:typeof t.durationMs==`number`?t.durationMs:null}}return{kind:`json`,text:cX(e)}}function uX(e){let t=[(e.exitCode===null?e.status===`completed`:e.exitCode===0)?Wn():Qc()];return e.exitCode!==null&&t.push(pe({code:e.exitCode})),e.durationMs!==null&&t.push(Uee({ms:e.durationMs})),t.join(` · `)}var dX=new Set([`complete`,`error`,`aborted`]),fX=new Set([`completed`,`error`]);function pX(e,t){if(e.length===0)return!1;if(t===`streaming`)return!0;if(t!==void 0&&dX.has(t))return!1;let n=e[e.length-1];return n.phase!==void 0&&fX.has(n.phase)?!1:n.result===void 0||n.result===null}var mX=[`command`,`query`,`url`,`path`,`pattern`,`file`,`cmd`,`prompt`];function hX(e,t){let n=``;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e;for(let e of mX){let r=t[e];if(typeof r==`string`&&r.trim()){n=r;break}}}return n||=t??(typeof e==`string`?e:``),n}function gX(e){if(e==null)return``;if(typeof e==`string`)return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function _X(e){let t=e.argsText??gX(e.args),n=hX(e.args,e.argsText);return e.inputFromTranscript===!0?{inputText:oX(t.trim()),preview:oX(n).replace(/\s+/g,` `).trim()}:{inputText:t,preview:n.replace(/\s+/g,` `).trim()}}function vX(e,t){let n=e.length,r=n===1?Tl({count:n}):Dc({count:n});return{count:n,running:pX(e,t),label:r}}function yX({text:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsx)(`button`,{type:`button`,className:`oc-copybtn`,title:Nb(),"aria-label":Xe(),onClick:()=>{navigator.clipboard?.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1200)})},children:t?(0,J.jsx)(YS,{size:13,"aria-hidden":!0}):(0,J.jsx)(bC,{size:13,"aria-hidden":!0})})}function bX(e,t,n){let r=typeof e==`string`?e:void 0;return r===`error`?`error`:t||r===`completed`||n?`completed`:`running`}function xX({toolName:e,args:t,argsText:n,inputFromTranscript:r,result:i,status:a,turnSettled:o,nested:s}){let c=i!=null,l=bX(a?.type,c,o),{inputText:u,preview:d}=_X({args:t,argsText:n,inputFromTranscript:r}),f=c?lX(i):null,p=l===`running`?kC:l===`error`?dA:fA;return(0,J.jsxs)(`details`,{className:`oc-tool oc-tool--${l}`,children:[(0,J.jsxs)(`summary`,{className:`oc-tool__header`,children:[(0,J.jsx)(p,{className:`oc-tool__status${l===`running`?` oc-tool__status--spin`:``}`,size:14,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-tool__name`,children:e}),d?(0,J.jsx)(`span`,{className:`oc-tool__preview`,title:d,children:d}):null,(0,J.jsx)(`span`,{className:`oc-tool__phase`,children:l}),(0,J.jsx)(QS,{size:15,className:`oc-tool__chevron`,"aria-hidden":!0})]}),(0,J.jsxs)(`div`,{className:`oc-tool__body`,children:[u?(0,J.jsxs)(`details`,{className:`oc-tool__io`,children:[(0,J.jsx)(`summary`,{children:`input`}),(0,J.jsxs)(`div`,{className:`oc-tool__prewrap`,children:[(0,J.jsx)(`pre`,{className:`oc-tool__pre`,children:u}),(0,J.jsx)(yX,{text:u})]})]}):null,f&&f.kind===`outcome`?(0,J.jsxs)(`div`,{className:`oc-tool__outcome`,children:[(0,J.jsx)(`span`,{className:`oc-tool__outcome-label`,children:uX(f)}),(0,J.jsx)(`span`,{className:`oc-tool__outcome-note`,children:fs()})]}):f?(0,J.jsxs)(`details`,{className:`oc-tool__io`,open:!0,children:[(0,J.jsx)(`summary`,{children:`output`}),(0,J.jsxs)(`div`,{className:`oc-tool__prewrap`,children:[(0,J.jsx)(`pre`,{className:`oc-tool__pre`,children:f.text}),(0,J.jsx)(yX,{text:f.text})]})]}):null,s?(0,J.jsx)(`div`,{className:`oc-tool__nested`,children:s}):null]})]})}var SX=1e3;function CX(){return[{id:`hung`,label:Fp()},{id:`wrong_result`,label:x()},{id:`error`,label:ts()},{id:`other`,label:ld()}]}function wX({target:e,onClose:t}){let n=W(G.subAgentReports.createSubAgentReport),[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(!1);(0,q.useEffect)(()=>{e&&(i(``),o(``),c(!1),u(!1))},[e]);function d(e){e||t()}async function f(){if(!(!e||s)){c(!0);try{await n({subAgentId:e.subAgentId,category:r||void 0,comment:a.trim()||void 0}),u(!0)}catch{c(!1)}}}return(0,J.jsx)($w,{open:e!==null,onOpenChange:d,children:e?(0,J.jsxs)(Xw,{className:`sm:max-w-md`,children:[(0,J.jsxs)(Jw,{children:[(0,J.jsx)(Zw,{children:gee()}),(0,J.jsx)(Qw,{children:l?oh():ef({label:e.label})})]}),l?(0,J.jsx)(`div`,{className:`oc-feedback__result`,role:`status`,children:(0,J.jsx)(`p`,{className:`oc-feedback__fidelity is-ok`,children:Dv()})}):(0,J.jsxs)(`div`,{className:`oc-feedback__form`,children:[(0,J.jsx)(`label`,{className:`oc-feedback__label`,children:o_()}),(0,J.jsxs)(aw,{value:r,onValueChange:i,children:[(0,J.jsx)(nw,{children:(0,J.jsx)(tw,{placeholder:yy()})}),(0,J.jsx)(rw,{children:CX().map(e=>(0,J.jsx)(iw,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(`label`,{className:`oc-feedback__label`,htmlFor:`oc-subagentreport-comment`,children:fu()}),(0,J.jsx)(`textarea`,{id:`oc-subagentreport-comment`,className:`oc-feedback__textarea`,placeholder:Ru(),value:a,maxLength:SX,onChange:e=>o(e.target.value.slice(0,SX)),rows:4}),(0,J.jsxs)(`div`,{className:`oc-feedback__count`,children:[a.length,`/`,SX]})]}),(0,J.jsx)(Yw,{children:l?(0,J.jsx)(K,{onClick:()=>d(!1),children:Nn()}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{variant:`outline`,onClick:()=>d(!1),children:$r()}),(0,J.jsx)(K,{onClick:()=>void f(),disabled:s,children:s?Ti():tv()})]})})]}):null})}function TX(e,t=`md`){let n=(e??``).trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,40);return`sous-agent${n?`-${n}`:``}.${t}`}function EX(e){return JSON.stringify({kind:`sub-agent`,taskName:e.taskName??null,status:e.status,exportedAt:new Date(e.exportedAt).toISOString(),parentAgent:e.parentAgentLabel??null,config:e.sessionMeta??null,telemetry:e.telemetry??null,tools:e.tools.map(e=>({name:e.name,status:e.status,input:e.argsText??null,output:e.resultText??null})),result:e.result??null,error:e.error??null},null,2)}function DX(e){let t=[],n=e.taskName?.trim()||wh();t.push(`# ${wh()} — ${n}`,``);let r=[];e.parentAgentLabel&&r.push(`- ${Kv()} : ${e.parentAgentLabel}`);let i=e.sessionMeta;if(i?.model&&r.push(`- ${Cm()} : ${i.model}${i.modelProvider?` (${i.modelProvider})`:``}`),i?.thinkingLevel&&r.push(`- ${Ig()} : ${i.thinkingLevel}`),i?.fastMode!==void 0&&r.push(`- ${k_()} : ${i.fastMode?tm():lp()}`),i?.controlScope&&r.push(`- ${zy()} : ${i.controlScope}`),i?.subagentRole&&r.push(`- ${mg()} : ${i.subagentRole}`),i?.spawnDepth!==void 0&&r.push(`- ${Vf()} : ${i.spawnDepth}`),r.length&&t.push(...r,``),e.tools.length>0){t.push(`## ${pt()} (${e.tools.length})`,``);for(let n of e.tools)t.push(`### ${n.name} — ${n.status}`,``),n.argsText&&t.push(`**Input**`,``,"```",n.argsText,"```",``),n.resultText&&t.push(`**Output**`,``,"```",n.resultText,"```",``)}return e.error&&t.push(`## ${Nt()}`,``,e.error,``),e.result&&t.push(`## ${kb()}`,``,e.result,``),`${t.join(`
21
+ `).trim()}\n`}function OX(e,t,n=!1){if(e===void 0)return`thinking`;switch(e){case`streaming`:return t?`generating`:`thinking`;case`error`:return`error`;case`aborted`:return`aborted`;default:return n?`aborted`:null}}function kX(e){return e?e.some(e=>e?.type===`text`&&typeof e.text==`string`&&e.text.trim().length>0):!1}var AX=/\b(?:profile|api\s*key)\s+"/i;function jX(e){if(typeof e!=`string`||!AX.test(e))return e;let t=e.indexOf(`"`);return t===-1?e:`${e.slice(0,t+1)}…`}var MX=/(?:^|[\s:(\[])401(?=[:)\s,.{]|$)/,NX=/(?:^|[\s:(\[])403(?=[:)\s,.{]|$)/,PX=/api[_ ]?key[_ ]?(?:revoked|deactivated|deleted)|deactivated[_ ]workspace|key has been (?:disabled|revoked)|account has been deactivated|not allowed for this organization/i,FX=/forbidden|permission|not allowed|access denied|access to this|unsupported[_ ](?:country|region)|region|territory|deactivated|re-authenticate with:/i,IX=/context overflow|prompt too large|maximum context length|context[- ]length exceeded|request_too_large|request too large|input (?:token count )?exceeds the maximum number of (?:input )?tokens|input is too long for the model|too many tokens|reduce the length|exceeds? (?:the )?(?:model'?s )?(?:maximum )?context/i,LX=/\btpm\b|tokens per (?:minute|day)|rate[_ -]?limit|too many requests|requests per (?:minute|hour|day)|throttl|please wait before trying again|\bquota\b|resource[_ -]?exhausted|usage limit|^(?:throttling error|service unavailable):|payment required|insufficient (?:credits|balance|funds)|insufficient[_ ]quota|credit balance|billing/i,RX=/(?:\btpm\b|tokens per minute)[^.\n]{0,120}?\blimit\s+([\d,]{1,12})[^.\n]{0,120}?\brequested\s+([\d,]{1,12})/i,zX=/reply session initialization conflicted/i,BX=/session file changed while embedded prompt lock/i,VX=/session writer claim changed before transcript persistence/i,HX=/the transcript writer no longer owned this session/i,UX=/session .* already has an active turn claim/i,WX=/session .* (?:changed|was deleted) while starting work/i,GX=/session transcript is rebuilding;?\s*retry shortly/i,KX=/is still initializing\.?\s*retry after initialization completes/i,qX=/database is locked|database table is locked|state database was (?:busy|locked)\b|sqlite transaction admission remained busy/i,JX=/database or disk is full|attempt to write a readonly database|disk i\/o error|state database was (?:full|read-only)|state database had an i\/o error/i,YX=/\benospc\b|\bedquot\b|no space left on device|disk quota exceeded|could not write local session data because the disk is full|free disk space\/quota or set xdg_cache_home to a writable filesystem/i,XX=/agent database execution admission is closed|sessions remain unavailable|preserve and inspect this database before accepting a fresh agent/i,ZX=/pending input is no longer active in its admitted transcript/i,QX=/^\s*all (?:[a-z][\w -]{0,60}? )?models failed \(\d+\):\s*/i,$X=/^[^\s/|]+\/\S+?:\s+/,eZ=/\.\s+(?:re-authenticate with:\s|authenticate in gemini cli directly, or configure a supported google api key with:\s)[\s\S]*$/i,tZ=/\s\(([a-z_]+)\)\s*\.?\s*$/,nZ=/^[\s⚠️]*context is too large and auto-compaction could not recover this turn\.\s*/i,rZ=/^[\s⚠️]*context is too large and auto-compaction timed out before it could finish\.\s*/i,iZ=/^reason:\s*/i,aZ=/\.?\s*try again, use \/compact, or use \/new to start a fresh session\.?\s*$/i,oZ=/^[\s⚠️]*context compaction succeeded, but the later model request still failed\.\s*/i,sZ=/^[\s⚠️]*agent failed before reply:\s*/i,cZ=/\.?\s*please try again, or use \/new to start a fresh session\.?\s*$/i,lZ=/^\s*this turn ended before a reply:\s*/i,uZ=/^[\s⚠️]*something went wrong while processing your request\./i,dZ=/\.\.\.\s*$/,fZ=/the ai service returned an (?:internal )?error|the ai service is temporarily (?:overloaded|unavailable)|returned an html error page|malformed_streaming_fragment|malformed fragment|an error occurred while processing your request|http\s*5\d\d\b|\b5\d\d\s+(?:internal server error|bad gateway|service unavailable|gateway timeout)|internal server error|\bupstream (?:error|connect)|server_error|overloaded_error|fetch failed|socket hang ?up|network error|econnreset|econnrefused|etimedout|enotfound|eai_again|epipe|und_err|terminated unexpectedly/i,pZ=/rate[- ]?limit|too many requests|http\s*4\d\d\b|unauthorized|forbidden|invalid[_ ](?:api[_ ]?key|request|model)|api[_ ]?key|authentication|billing|quota|insufficient|not[_ ]found|unsupported|refus|content[_ ]policy|context overflow|prompt too large/i,mZ=/is paused as a precaution\.?\s*review the provider findings|provider review changed\.?\s*refresh the findings/i,hZ=/is archived\.?\s*restore it before starting new work/i,gZ=/\bauth profile\s+"[\s\S]*?"\s+is temporarily unavailable\s+for\b/i,_Z=/\bre-authenticate with:\s/i,vZ=/(?:^|[\s:(\[])401[:)\s][^|\n]{0,120}?(?:\b(?:invalidated|expired|revoked)\b[^|\n]{0,60}?\btokens?\b|\btokens?\s+(?:has|have)\s+(?:been\s+)?(?:invalidated|expired|revoked)\b|\btokens?\s+(?:was|were|is|are)\s+(?:invalidated|expired|revoked)\b)/i,yZ=/\b(?:invalidated|revoked)\b[^|\n]{0,60}?\btokens?\b|\btokens?\s+(?:has|have)\s+been\s+(?:invalidated|expired|revoked)\b|\b(?:refresh|access|oauth)\s+tokens?\s+(?:is|was|has)\s+(?:been\s+)?(?:invalidated|expired|revoked)\b/i,bZ=/\bmodel login expired on the gateway\b/i,xZ=/\breturned a billing error\b/i,SZ=/\bthe selected model was not found by the provider\b|\bcan'?t find the model you'?re using right now\b/i,CZ=/\bapi rate limit reached\b|\bthe model request was rate-limited\b/i,wZ=/(?:^|[\s:(\[|])(?:http\s*)?[45]\d\d\b[^{"\n|]{0,40}?\{/gi,TZ=/(?:auto-compaction|preflight compaction)(?:[^\n.!?;,:—-]{0,200}?failed\s*:\s*|[^\n.!?;,:—-]{0,200}?[.!?]\s*reason\s*:\s*)(?:no conversation found|conversation (?:not found|does not exist|expired|invalid)|session (?:not found|does not exist|expired|invalid)|no such session|invalid session|(?:session|conversation) id not found)(?=[.,;:!)\]]|\s*$|\s+(?:for|on|in|with)\b|\s+[—-]\s)/,EZ=RegExp(`${NX.source}[^|\\n]{0,200}?(?:${FX.source})`,`i`),DZ=`message|type|code|status|reason|detail|error`,OZ=RegExp(`"(?:${DZ})"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)"`,`gi`),kZ=RegExp(`"(?:${DZ})"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)$`,`i`),AZ=new Set([`auth`,`auth_permanent`,`format`,`rate_limit`,`overloaded`,`billing`,`server_error`,`timeout`,`tls_certificate`,`context_overflow`,`model_not_found`,`session_expired`,`empty_response`,`no_error_details`,`unclassified`,`unknown`]),jZ=[`gateway_storage_unavailable`,`gateway_agent_db_closed`,`gateway_storage_busy`,`pending_input_dropped`,`session_gone`,`provider_auth_revoked`,`provider_permission_denied`,`provider_billing`,`provider_auth_failed`,`auth_profile_cooldown`,`model_not_found`,`context_length`,`session_write_conflict`,`session_init_conflict`,`session_archived`,`session_paused_review`,`rate_limit`,`provider_internal`],MZ=new Set([`gateway_storage_unavailable`,`gateway_agent_db_closed`,`gateway_storage_busy`,`pending_input_dropped`,`session_gone`,`auth_profile_cooldown`,`session_write_conflict`,`session_init_conflict`,`session_archived`,`session_paused_review`]),NZ=new Set([`pending_input_dropped`,`auth_profile_cooldown`]);function PZ(e){return/\b(?:profile|api\s*key)\s+"/i.test(e)}function FZ(e,t){let n=0,r=!1;for(let i=t;i<e.length;i++){let t=e[i];if(r){t===`\\`?i++:t===`"`&&(r=!1);continue}if(t===`"`)r=!0;else if(t===`{`)n++;else if(t===`}`&&--n===0)return i}return-1}function IZ(e){return e.replace(/\\(.)/g,`$1`).replace(/"/g,``)}function LZ(e){let t=``,n=0,r=new RegExp(wZ.source,wZ.flags);for(let i=r.exec(e);i!==null;i=r.exec(e)){let a=i.index+i[0].length-1;if(a<n)continue;let o=FZ(e,a),s=o===-1?e.length-1:o,c=e.slice(a,s+1),l=[],u=new RegExp(OZ.source,OZ.flags);for(let e=u.exec(c);e!==null;e=u.exec(c))l.push(IZ(e[1]??``));if(o===-1){let e=kZ.exec(c);e!==null&&l.push(IZ(e[1]??``))}t+=`${e.slice(n,a)}${l.join(` `)}`,n=s+1,r.lastIndex=n}return n===0?e:t+e.slice(n)}function RZ(e){let t=e;return(t.match(/"/g)??[]).length%2==1&&(t=t.replace(/"[^"]*$/,`"…`)),t.replace(/"[^"]*"/g,`"…"`)}function zZ(e){if(!PZ(e))return RZ(LZ(e));let t=e.indexOf(`"`),n=t===-1?e:e.slice(0,t);if(/\bauth profile\s+$/i.test(n)){let t=e.replace(/(\bauth profile\s+")[\s\S]*?("\s+is temporarily unavailable\s+for\b)[\s\S]*$/i,`$1…$2 …`);if(t!==e)return t}return t===-1?e:`${e.slice(0,t+1)}…`}function BZ(e){if(!IX.test(e))return!1;let t=RX.exec(e);if(t!==null){let e=Number(t[1]?.replaceAll(`,`,``)),n=Number(t[2]?.replaceAll(`,`,``));if(e>0&&n>e)return!0}return!LX.test(e)}function VZ(e){return zX.test(e)||BX.test(e)||WX.test(e)||UX.test(e)||GX.test(e)||KX.test(zZ(e))}function HZ(e){let t=zZ(e).toLowerCase();return!t.includes(`auto-compaction`)&&!t.includes(`preflight compaction`)?!1:TZ.test(t)}function UZ(e){return vZ.test(e)||bZ.test(e)?`provider_auth_revoked`:PX.test(e)||EZ.test(e)?`provider_permission_denied`:_Z.test(e)?`provider_auth_failed`:null}function WZ(e,t){if(e===`auth_permanent`)return`provider_permission_denied`;let n=MX.test(t),r=NX.test(t);return r&&!n||PX.test(t)?`provider_permission_denied`:n&&!r||vZ.test(t)||yZ.test(t)?`provider_auth_revoked`:`provider_auth_failed`}function GZ(e,t){switch(e){case`auth`:case`auth_permanent`:return WZ(e,t);case`billing`:return`provider_billing`;case`rate_limit`:return`rate_limit`;case`overloaded`:case`server_error`:case`timeout`:return`provider_internal`;case`context_overflow`:return`context_length`;case`model_not_found`:return`model_not_found`;default:return null}}function KZ(e){let t=zZ(e);if(JX.test(t)||YX.test(t))return`gateway_storage_unavailable`;if(XX.test(t))return`gateway_agent_db_closed`;if(qX.test(t))return`gateway_storage_busy`;if(ZX.test(t))return`pending_input_dropped`;if(HZ(t))return`session_gone`;let n=UZ(t);return n===`provider_auth_revoked`||n===`provider_permission_denied`?n:xZ.test(t)?`provider_billing`:n===null?gZ.test(t)?`auth_profile_cooldown`:SZ.test(t)?`model_not_found`:BZ(t)?`context_length`:VX.test(t)||HX.test(t)?`session_write_conflict`:VZ(t)?`session_init_conflict`:hZ.test(zZ(t))?`session_archived`:mZ.test(zZ(t))?`session_paused_review`:CZ.test(t)?`rate_limit`:fZ.test(t)&&!pZ.test(t)?`provider_internal`:null:n}function qZ(e){let t=jZ.indexOf(e);return t===-1?jZ.length:t}function JZ(e){let t=null;for(let n of e)n!==null&&(t===null||qZ(n)<qZ(t))&&(t=n);return t}function YZ(e){let t=QX.exec(e);if(t===null)return null;let n=e.slice(t[0].length),r=eZ.exec(n);r!==null&&(n=n.slice(0,r.index));let i=n.split(` | `).map(e=>e.trim()).filter(e=>$X.test(e)).map(e=>{let t=e.replace($X,``),n=tZ.exec(t),r=n?.[1];return n!==null&&r!==void 0&&AZ.has(r)?{text:t.slice(0,n.index),reason:r}:{text:t,reason:null}});return i.length>0?{attempts:i,authHint:r!==null}:null}function XZ(e){let t=KZ(e.text);return t!==null&&MZ.has(t)?t:(e.reason===null?null:GZ(e.reason,zZ(e.text)))??t}function ZZ(e){let t=YZ(e);if(t===null)return KZ(e);let n=t.attempts.map(XZ),r=t.authHint?`provider_auth_failed`:null;return n.includes(`pending_input_dropped`)?n.every(e=>e!==null&&NZ.has(e))?`pending_input_dropped`:JZ([...n.filter(e=>e!==`pending_input_dropped`),r]):JZ([...n,r])}function QZ(e){let t=null,n=e.replace(dZ,``);for(let e=0;e<4&&n!==null;e++){let e,r,i=nZ.exec(n),a=i===null?rZ.exec(n):null,o=i??a;if(o!==null){r=i===null?`compaction_timeout`:`preflight_compaction`;let t=n.slice(o[0].length),a=iZ.exec(t);e=a===null?null:t.slice(a[0].length).replace(aZ,``)}else oZ.test(n)?(r=`run_failure`,e=n.replace(oZ,``)):sZ.test(n)?(r=`run_failure`,e=n.replace(sZ,``).replace(cZ,``)):lZ.test(n)?(r=`run_failure`,e=n.replace(lZ,``)):uZ.test(n)&&(r=`run_failure`,e=null);if(r===void 0)break;t??=r,n=e==null||e.trim()===``?null:e.trim()}return t===null?{wrapper:null,inner:e}:{wrapper:t,inner:n}}function $Z(e){if(!e)return null;let{wrapper:t,inner:n}=QZ(e),r=n===null?null:ZZ(n);return HZ(e)&&(r=JZ([r,`session_gone`])),r===null?t===`compaction_timeout`?`compaction_timeout`:t===`preflight_compaction`?`compaction_failed_no_cause`:t===`run_failure`?`run_failed_no_cause`:null:r}var eQ=new Set([`awaiting_approval`,`awaiting_input`]),tQ={thinking:Uo,generating:he,error:tp,aborted:yv},nQ={processing_history:Zu,compacting:$l,querying_gateway:Cu,awaiting_subagents:Br,post_processing:H_,awaiting_approval:el,awaiting_input:Vc,retrying:di},rQ=[[`read`,/^(read|read_file|cat|open|view|notebook_read)$/i],[`exec`,/^(exec|bash|shell|run|command|terminal)$/i],[`search`,/^(web_search|search|grep|find|glob|rg)$/i],[`fetch`,/^(web_fetch|fetch|browser|http_get)$/i],[`write`,/^(write|write_file|apply_patch|edit|str_replace|notebook_edit)$/i]];function iQ(e){for(let[t,n]of rQ)if(n.test(e))return t;return`other`}var aQ={read:()=>Cx(),exec:()=>ms(),search:()=>zi(),fetch:()=>vr(),write:()=>Jt(),other:e=>yo({tool:e})};function oQ(e){if(!e||e.length===0)return null;let t=e=>e.toolCallId??e.toolName,n=new Set;for(let r=e.length-1;r>=0;r--){let i=e[r],a=i.phase??`completed`;if(a===`completed`||a===`error`){n.add(t(i));continue}if((a===`start`||a===`started`||a===`running`)&&!n.has(t(i)))return{name:i.toolName,family:iQ(i.toolName)}}return null}function sQ(e,t,n,r,i,a,o){let s=OX(e,t,i??!1);if(s===null)return null;if(s===`thinking`||s===`generating`){if(o&&!(n&&eQ.has(n)))return{kind:s,label:sS(o),phased:!0,struggling:!0};if(r)return{kind:s,label:aQ[r.family](r.name),phased:!0};if(n===`retrying`&&a)return{kind:s,label:vn({attempt:String(a.attempt),maxAttempts:String(a.maxAttempts)}),phased:!0};if(n&&nQ[n])return{kind:s,label:nQ[n](),phased:!0}}return{kind:s,label:tQ[s]()}}function cQ(e,t){return!t||e!==`thinking`&&e!==`generating`?null:l()}var lQ=new Set([`context_length`,`context_length_compacted`,`context_length_presend`]),uQ=new Set([`session_gone`,`session_archived`,`session_archived_historic`,`session_paused_review`,`gateway_agent_db_closed`,`provider_auth_revoked`,`provider_permission_denied`,`provider_auth_failed`]),dQ=new Set([`provider_billing`,`model_not_found`,`compaction_failed_no_cause`,`run_failed_no_cause`,`compaction_timeout`]),fQ={context_length:Bd,context_length_compacted:qm,context_length_presend:mv,rate_limit:uee,timeout:Gd,refusal:Qm,stream_orphaned:jy,connection_lost:sg,gateway_restarting:Pf,connection_saturated:zv,GATEWAY_RESTARTING:Pf,CONNECTION_SATURATED:zv,response_timeout:y_,compaction_timeout:ku,empty_response:Gr,msgtool_args_unreadable:K_,awaiting_approval:gi,empty_response_silent:Cn,unclassified_error:kl,provider_internal:jc,session_init_conflict:So,session_write_conflict:Ma,session_gone:la,session_archived:yh,session_archived_historic:I,session_paused_review:Vh,session_visibility_refused:to,session_settings_changed:ct,permission_mode_not_applied:cc,knowledge_policy_not_applied:Dy,gateway_version_unsupported:wb,auth_profile_cooldown:Ve,provider_auth_revoked:zs,provider_permission_denied:Kb,provider_auth_failed:mf,provider_billing:_x,model_not_found:nb,provider_access_removed:wd,compaction_failed_no_cause:vm,run_failed_no_cause:Rm,pending_input_dropped:Ot,gateway_storage_busy:ip,gateway_state_contention:Py,gateway_storage_unavailable:Lf,gateway_agent_db_closed:Hv,not_configured:tx,no_agent:Cf,agent_restricted:Nee,AGENT_LEFT_ROOM:ub,send_failed:jd,DISPATCH_STALLED:lb,ATTACHMENT_TOO_LARGE:Tm,ATTACHMENT_REJECTED:nee,attachment_name_too_long:Wl,attachment_path_refused:Oy,attachment_staging_failed:Oy,attachment_cleanup_unconfirmed:Oy,message_too_large:js,subagent_reply_pending:vl,gateway_media_unavailable:Wp},pQ=/^\s*all (?:[a-z][\w -]{0,60}? )?models failed \(\d+\):\s*/i,mQ=/^[^\s/|]+\/\S+?:\s+/,hQ=/pending input is no longer active in its admitted transcript/i;function gQ(e){let t=pQ.exec(e);if(t===null)return hQ.test(e);let n=e.slice(t[0].length).split(` | `).map(e=>e.trim()).filter(e=>mQ.test(e)).map(e=>e.replace(mQ,``));return n.length>0&&n.every(e=>hQ.test(e))}var _Q=new Set([`session_gone`,`session_paused_review`,`provider_auth_revoked`,`provider_permission_denied`,`provider_auth_failed`,`provider_billing`,`model_not_found`,`rate_limit`,`context_length`,`compaction_timeout`,`compaction_failed_no_cause`,`run_failed_no_cause`]),vQ=new Set([`provider_auth_revoked`,`provider_permission_denied`,`provider_auth_failed`]);function yQ(e){let t=$Z(e);return t===null?null:t===`session_archived`?`session_archived_historic`:t===`pending_input_dropped`?gQ(e)?`pending_input_dropped`:null:_Q.has(t)?t:null}var bQ=new Set([`stream_orphaned`,`connection_lost`,`gateway_restarting`,`connection_saturated`,`response_timeout`,`not_configured`,`no_agent`,`agent_restricted`,`send_failed`,`ATTACHMENT_TOO_LARGE`,`ATTACHMENT_REJECTED`,`attachment_path_refused`,`attachment_name_too_long`,`attachment_staging_failed`,`attachment_cleanup_unconfirmed`,`message_too_large`,`subagent_reply_pending`,`gateway_media_unavailable`,`provider_access_removed`]);function xQ(e,t){let n=jX((e??``).trim()),r=n===``?null:yQ(n),i;i=t&&fQ[t]&&t!==`unclassified_error`?t===`provider_auth_revoked`&&r!==null&&r!==t&&vQ.has(r)?r:t:bQ.has(n)?n:r??t??null;let a=i===null?null:fQ[i]?.()??null,o=n===``||n===i||bQ.has(n),s=i!==null&&uQ.has(i),c=!o&&!s&&(QZ(n).wrapper!==null||i!==null&&dQ.has(i));return{headline:a,detail:o||s||c?null:n,rawDetail:c?n:null,code:i}}var SQ=kX,CQ=new Set([`chat_busy`,`not_last_message`,`no_preceding_user_turn`]);function wQ(e){return e==null?null:e.outcome===`exhausted`?ve({attempt:String(e.attempt),max:String(e.maxAttempts)}):e.reason===`another_turn_streaming`?Kee():e.reason===`delegated_work`?_s():e.reason===`concurrent_writer`?Hi():e.reason!==void 0&&CQ.has(e.reason)?xr():Zt()}var TQ=new Map([[`gateway_state_contention`,ug]]);function EQ(e){switch(e){case`queued`:case`live`:case`running`:return`running`;case`done`:return`done`;case`failed`:case`timeout`:return`error`;case`killed`:case`interrupted`:return`aborted`;case`idle`:case`unknown`:return null}}function DQ(e){let t=e.trim();if(t===``)return``;let n=t.slice(t.lastIndexOf(`:`)+1)||t;return n.length>10?`${n.slice(0,8)}…`:n}var OQ=RegExp(`^agent:(.+?):(?:${[`subagent`,`dashboard`].join(`|`)}):`);function kQ(e){return OQ.exec(e.trim())?.[1]?.trim()||void 0}function AQ(e){if(!Number.isFinite(e)||e<0)return``;if(e<1e3)return`< 1 s`;let t=Math.round(e/1e3);if(t<60)return`${t} s`;let n=Math.floor(t/60),r=t%60;if(n<60)return r>0?`${n} min ${r} s`:`${n} min`;let i=Math.floor(n/60),a=n%60;return a>0?`${i} h ${String(a).padStart(2,`0`)} min`:`${i} h`}function jQ(e){if(!Number.isFinite(e)||e<0)return``;let t=e>0&&e<.01?4:2;return`${e.toFixed(t).replace(`.`,`,`)} $`}function MQ(e){return e.moaRole===`moa_aggregator`?us():e.moaRole===`moa_reference`?j():wh()}function NQ(e){return e.kind===`task`?Xg({tool:e.taskName?.trim()||`task`}):e.taskName?.trim()||DQ(e.childSessionKey)||ma()}function PQ(e){return e.some(e=>e.status===`running`&&e.kind!==`task`)}function FQ(e,t){return e===`running`?`running`:e===`done`?`done`:e===`aborted`?t===`killed`?`failed`:`aborted`:`failed`}function IQ(e,t){return e===`running`?X_():e===`done`?bi():e===`error`?t===`timeout`?Pl():On():t===`killed`?Ic():t===`interrupted`?$n():cl()}var LQ={queued:()=>({tone:`running`,label:Ce()}),live:()=>({tone:`running`,label:X_()}),running:()=>({tone:`running`,label:X_()}),idle:()=>({tone:`aborted`,label:Yee()}),unknown:()=>({tone:`aborted`,label:Ss()}),done:()=>({tone:`done`,label:bi()}),failed:()=>({tone:`failed`,label:On()}),timeout:()=>({tone:`failed`,label:Pl()}),killed:()=>({tone:`failed`,label:Ic()}),interrupted:()=>({tone:`aborted`,label:$n()})};function RQ(e){let t=e.stoppedRunId??e.childRunId,n=e.gatewayRow?.runId!==void 0&&t!==void 0&&e.gatewayRow.runId!==t;if(e.stopRequestedAt!==void 0&&e.status!==`running`&&!n)return{tone:`aborted`,label:cl()};let r=e.gatewayRow?.display,i=r===void 0?void 0:LQ[r];return i!==void 0&&(EQ(r)??e.status)===e.status?i():{tone:FQ(e.status,e.providerStatus),label:IQ(e.status,e.providerStatus)}}function zQ(e){return e!==`running`}function BQ(e){return e!==void 0&&e.tone!==`running`&&e.sessionMeta?.cleanup===`delete`}function VQ(e){return e.startsWith(`fork:`)}function HQ(e){let{tone:t,label:n}=RQ(e),r=e.sessionMeta?.subagentRole;return{id:e._id,childSessionKey:e.childSessionKey,...e.kind===`task`?{isTask:!0}:{},...r===`moa_reference`||r===`moa_aggregator`?{moaRole:r}:{},taskName:e.taskName?.trim()||void 0,label:NQ(e),status:e.status,tone:t,statusLabel:n,failure:t===`failed`,phase:e.status===`running`?e.phase:void 0,errorMessage:e.errorMessage,errorCode:e.errorCode,runTimeoutSeconds:e.runTimeoutSeconds,resultText:e.resultText,tools:e.tools?.map(e=>({name:e.name,status:e.status,toolCallId:e.toolCallId})),sessionMeta:e.sessionMeta,telemetry:e.telemetry,childAgentId:kQ(e.childSessionKey)}}function UQ(e){let t=[...e].sort((e,t)=>t.createdAt-e.createdAt).map(HQ).sort((e,t)=>{let n=e=>e.moaRole===`moa_aggregator`?0:e.moaRole===`moa_reference`?1:2,r=e=>e.moaRole?e.childSessionKey.replace(/:(ref\d+|aggregate)$/,``):``,i=r(e).localeCompare(r(t));if(e.moaRole&&t.moaRole&&i!==0)return i;let a=n(e),o=n(t);if(a!==o)return a-o;if(a===1){let n=e=>{let t=/ref(\d+)$/.exec(e.childSessionKey);return t?.[1]?Number.parseInt(t[1],10):0};return n(e)-n(t)}return 0});return{cards:t,total:t.length,done:t.filter(e=>e.tone===`done`).length,running:t.filter(e=>e.tone===`running`).length,failed:t.filter(e=>e.tone===`failed`).length,aborted:t.filter(e=>e.tone===`aborted`).length}}function WQ(e){if(e.total<=1)return[];let t={done:e.done,running:e.running,failed:e.failed,aborted:e.aborted};return[`done`,`running`,`failed`,`aborted`].filter(e=>t[e]>0).map(e=>({tone:e,count:t[e]}))}function GQ(e,t,n){let r=new Set(t);return e.filter(e=>n!==void 0&&e.parentMessageId===n||r.has(e.childSessionKey))}function KQ(e){return e===1?Nu({count:e}):Jr({count:e})}var qQ=120,JQ=/EXTERNAL_UNTRUSTED_CONTENT|SECURITY\s*NOTICE|UNTRUSTED\s*CONTENT/i,YQ=/DO NOT/;function XQ(e){return JQ.test(e)||YQ.test(e)}function ZQ(e){return e.length<=qQ?e:`${e.slice(0,qQ-1)}…`}function QQ(e){for(let t of e.split(/\r?\n/)){let e=t.replace(/\s+/g,` `).trim();if(!(e.length<3)&&/[\p{L}\p{N}]/u.test(e)&&!XQ(e))return e}return null}function $Q(e,t,n){let r=qi();if(t===`timeout`)return ZQ(typeof n==`number`&&Number.isInteger(n)&&n>0?Er({seconds:n}):tn());if(t===`subagent_no_activity`)return ZQ(La());if(t===`spawn_refused`)return ZQ(Eo());if(t){let e=fQ[t]?.();if(e)return ZQ(e)}if(e==null)return r;let i=e.trim();if(i===``)return r;let a=/([A-Za-z][\w.-]*)\s+failed\s*\(([^)]{1,40})\)/i.exec(i);if(a)return ZQ(`${a[1]} (${a[2].trim()})`);let o=QQ(i);return o&&!XQ(o)?ZQ(o):r}function e$(e,t){if(!t||t!==`timeout`&&t!==`spawn_refused`&&fQ[t]===void 0)return null;let n=e?.trim()??``;return n===``||QQ(n)===null?null:n}function t$(e){return e===`message_too_large`?js():e===`attachment_too_large`?Tm():e??ko()}function n$(e){let t=document.querySelector(`[data-message-id="${CSS.escape(e)}"]`);if(!t)return;let n=t.closest(`.oc-thread__viewport`);if(n){let e=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTo({top:n.scrollTop+e-12,behavior:`smooth`})}else t.scrollIntoView({block:`start`,behavior:`smooth`});t.classList.remove(`oc-msg--highlight`),t.offsetWidth,t.classList.add(`oc-msg--highlight`),window.setTimeout(()=>t.classList.remove(`oc-msg--highlight`),2400)}function tne(e,t){let n=new Blob([t],{type:`text/markdown;charset=utf-8`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=e,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var r$=(0,q.createContext)(null);function i$({card:e}){return(0,J.jsxs)(`span`,{className:`oc-subpanel__status oc-subpanel__status--${e.tone}`,children:[e.statusLabel,e.tone===`running`?(0,J.jsx)(kC,{size:13,className:`oc-subagent__spin`,"aria-hidden":!0}):e.tone===`failed`?(0,J.jsx)(dA,{size:13,"aria-hidden":!0}):e.tone===`aborted`?(0,J.jsx)(pA,{size:13,"aria-hidden":!0}):(0,J.jsx)(YS,{size:13,"aria-hidden":!0})]})}function a$(e){if(e)try{return JSON.parse(e)}catch{return}}function o$(e){return{type:e===`error`?`error`:e===`done`?`completed`:`running`}}function s$(e){return e.toolCallId??`name:${e.name}`}function c$({summary:e,parts:t,subAgentRunning:n}){let[r,i]=(0,q.useState)(!1),a=n,o=e.length===1?Tl({count:e.length}):Dc({count:e.length}),s=a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kC,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}),Xl()]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(YS,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-sr-only`,children:Zc()})]}),c=new Map;for(let e of t??[])c.set(e.toolCallId,e);return(0,J.jsxs)(`div`,{className:`oc-toolact`,children:[(0,J.jsx)(xK,{icon:(0,J.jsx)(yj,{size:14}),label:o,trailing:s,open:r,ariaExpanded:r,title:r?wl():hr(),onClick:()=>i(!r)}),r?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:e.map((e,t)=>{let r=c.get(s$(e));return(0,J.jsx)(xX,{toolName:e.name,args:r?a$(r.argsText):void 0,argsText:r?.argsText,result:r?.resultText,status:o$(r?.status??e.status),turnSettled:!n},`${s$(e)}-${t}`)})}):null]})}function l$({meta:e,telemetry:t,childAgentId:n,instanceName:r,parentAgentLabel:i,onExport:a}){let[o,s]=(0,q.useState)(!1),c=!!e&&Object.values(e).some(e=>e!==void 0)||!!t&&Object.values(t).some(e=>e!==void 0)||n!==void 0;if(!c&&!i&&!a)return(0,J.jsx)(`div`,{className:`oc-subpanel__barslot`,"aria-hidden":!0});let l=e?.fastMode===void 0?null:e.fastMode?tm():lp();return(0,J.jsxs)(`div`,{className:`oc-subpanel__bar`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__bar-chips`,children:[e?.model?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:e.modelProvider?Sv({provider:e.modelProvider}):Cm(),children:[(0,J.jsx)(_A,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:e.model})]}):null,e?.thinkingLevel?(0,J.jsxs)(`span`,{className:`oc-chip`,title:Ig(),children:[(0,J.jsx)(lA,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:e.thinkingLevel})]}):null,l?(0,J.jsxs)(`span`,{className:`oc-chip`,title:k_(),children:[(0,J.jsx)(DC,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:l})]}):null,e?.context?(0,J.jsxs)(`span`,{className:`oc-chip`,title:e.context===`fork`?nh():Yd(),children:[(0,J.jsx)(fj,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:e.context})]}):null,i?(0,J.jsxs)(`span`,{className:`oc-chip`,title:Kv(),children:[(0,J.jsx)(kS,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:i})]}):null,a?(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-chip oc-chip--btn oc-subpanel__bar-export`,title:kd(),children:[(0,J.jsx)(xC,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:sb()}),(0,J.jsx)(XS,{size:12,className:`oc-chip__chev`,"aria-hidden":!0})]})}),(0,J.jsxs)(fC,{align:`end`,className:`w-44`,children:[(0,J.jsx)(lC,{children:sb()}),(0,J.jsx)(hC,{onClick:()=>a(`md`),children:kc()}),(0,J.jsx)(hC,{onClick:()=>a(`json`),children:Kn()})]})]}):null]}),c?(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__adv-toggle${o?` is-open`:``}`,"aria-expanded":o,onClick:()=>s(e=>!e),children:[(0,J.jsx)(UC,{size:13,"aria-hidden":!0}),pee(),(0,J.jsx)(QS,{size:13,className:`oc-subpanel__adv-chevron`,"aria-hidden":!0})]}):null,o&&c?(0,J.jsx)(d$,{meta:e??{},telemetry:t,childAgentId:n,instanceName:r}):null]})}function u$(e){return e===`leaf`?De():e===`orchestrator`?$ee():null}function d$({meta:e,telemetry:t,childAgentId:n,instanceName:r}){let i=[];e.model&&i.push([Cm(),e.model]),e.modelProvider&&i.push([Hm(),e.modelProvider]);let a=e.agentId??n;a&&i.push([cd(),a]),r&&i.push([ig(),r]),e.label&&i.push([du(),e.label]),e.thinkingLevel&&i.push([Ig(),e.thinkingLevel]),e.fastMode!==void 0&&i.push([k_(),e.fastMode?tm():lp()]),e.context&&i.push([Yd(),e.context]),e.lightContext!==void 0&&i.push([Lu(),e.lightContext?Qr():ev()]),e.runtime&&i.push([Cv(),e.runtime]),e.mode&&i.push([n_(),e.mode]),e.cleanup&&i.push([hy(),e.cleanup]),e.sandbox&&i.push([jp(),e.sandbox]),e.controlScope&&i.push([zy(),e.controlScope]),e.subagentRole&&i.push([mg(),e.subagentRole]),e.spawnDepth!==void 0&&i.push([Vf(),String(e.spawnDepth)]);let o=u$(e.subagentRole);if(o&&i.push([es(),o]),e.sessionId&&i.push([wi(),e.sessionId]),e.gatewayKind&&i.push([b(),e.gatewayKind]),t?.runtimeMs!==void 0){let e=AQ(t.runtimeMs);e&&i.push([Mn(),e])}if(t?.totalTokens!==void 0&&i.push([Rl(),Gw(t.totalTokens)]),t?.estimatedCostUsd!==void 0){let e=typeof t.totalTokens==`number`&&t.totalTokens>0;if(t.estimatedCostUsd<=0&&e)i.push([Bc(),Qv()]);else{let e=jQ(t.estimatedCostUsd);e&&i.push([Bc(),e])}}return(0,J.jsx)(`dl`,{className:`oc-subpanel__adv-list`,children:i.map(([e,t])=>(0,J.jsxs)(`div`,{className:`oc-subpanel__adv-row`,children:[(0,J.jsx)(`dt`,{children:e}),(0,J.jsx)(`dd`,{children:t})]},e))})}function f$({chatId:e,childKey:t,onClose:n,parentAgentLabel:r}){let i=U(G.subAgents.listSubAgents,{chatId:e}),a=U(G.agents.getChatAgent,{chatId:e}),o=U(G.messages.getSessionMeta,{chatId:e}),s=o?.viewerRole===`participant`,c=o?.perTurnRouting===!0?void 0:a?.agent?.instanceName,l=(i??[]).find(e=>e.childSessionKey===t),u=l?UQ([l]).cards[0]:void 0,d=l?.taskName?.trim(),f=BQ(u),p=u?.failure?e$(u.errorMessage,u.errorCode):null,m=VQ(t),h=U(G.subAgentReports.myReportedSubAgentIds,{chatId:e}),g=U(G.subAgents.listSubAgentToolParts,{chatId:e,childSessionKey:t}),_=U(G.subAgentInteractions.listSubAgentInteractions,{chatId:e,childSessionKey:t}),v=pa(G.subAgentInteractions.sendToSubAgent),y=W(G.chats.generateUploadUrl),b=W(G.uploads.registerUpload),[x,S]=(0,q.useState)(!1),[C,w]=(0,q.useState)(!0),[T,E]=(0,q.useState)(!1),[D,O]=(0,q.useState)(``),[k,A]=(0,q.useState)(!1),[j,M]=(0,q.useState)([]),[N,P]=(0,q.useState)(!1),[F,I]=(0,q.useState)(!0),L=(0,q.useRef)(null),R=(0,q.useRef)(null),ee=(0,q.useCallback)(async e=>{if(!(!e||e.length===0)){P(!0);try{for(let t of Array.from(e)){if(j.length>=6)break;let e=await y(),{storageId:n}=await(await fetch(e,{method:`POST`,headers:{"Content-Type":t.type||`application/octet-stream`},body:t})).json();await b({storageId:n}),M(e=>e.length>=6?e:[...e,{storageId:n,filename:t.name,mimeType:t.type||`application/octet-stream`}])}}finally{P(!1),L.current&&(L.current.value=``)}}},[j.length,y,b]),[z,B]=(0,q.useState)(null),V=u?(h??[]).includes(u.id):!1,te=(0,q.useCallback)(e=>{if(!u)return;let t=g&&g.length>0?g.map(e=>({name:e.name,status:e.status,argsText:e.argsText,resultText:e.resultText})):(u.tools??[]).map(e=>({name:e.name,status:e.status})),n={taskName:d,status:u.status,parentAgentLabel:r,sessionMeta:u.sessionMeta,telemetry:u.telemetry,result:u.resultText,error:u.failure?$Q(u.errorMessage,u.errorCode,u.runTimeoutSeconds):void 0,tools:t};tne(TX(d,e),e===`md`?DX(n):EX({...n,exportedAt:Date.now()}))},[u,g,d,r]);(0,q.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,q.useEffect)(()=>{i!==void 0&&!l&&n()},[i,l,n]);let re=_&&_.length>0?`${_.length}:${_[_.length-1].status}`:``;(0,q.useEffect)(()=>{if(!re)return;let e=R.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[re]);let ie=Mw(),ae=async()=>{let n=D.trim();if(!(f||m)&&!(!n&&j.length===0||x||N)){S(!0);try{await v({chatId:e,childSessionKey:t,text:n,...j.length>0?{attachments:j.map(e=>({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType}))}:{}}),O(``),M([])}catch(e){let t=String(e?.message??``);ie.error(t.includes(`TALK_CALL_ACTIVE`)?$f():t.includes(`SUBAGENT_RECOVERING`)?kr():iy())}finally{S(!1)}}};return(0,J.jsxs)(`div`,{className:`oc-subpanel`,children:[(0,J.jsxs)(`header`,{className:`oc-subpanel__head`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__avatar oc-subpanel__back${u?` oc-subpanel__avatar--${u.tone}`:``}`,disabled:!l?.parentMessageId,title:Qb(),"aria-label":Ws(),onClick:()=>l?.parentMessageId&&n$(l.parentMessageId),children:(0,J.jsx)(nA,{size:16})}),(0,J.jsxs)(`div`,{className:`oc-subpanel__headmain`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__head-top`,children:[(0,J.jsx)(`span`,{className:`oc-subpanel__kind`,children:u?MQ(u):wh()}),(0,J.jsxs)(`div`,{className:`oc-subpanel__head-ctrls`,children:[u?(0,J.jsx)(i$,{card:u}):null,u&&zQ(u.status)&&!s?(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-subpanel__report${V?` is-on`:``}`,title:V?Xv():bx(),"aria-label":bx(),disabled:V,onClick:()=>B({subAgentId:u.id,label:u.label}),children:(0,J.jsx)(wA,{size:15,"aria-hidden":!0})}):null,(0,J.jsx)(K,{variant:`ghost`,size:`icon-sm`,onClick:n,"aria-label":Kh(),className:`oc-subpanel__close`,children:(0,J.jsx)(XC,{size:16})})]})]}),d?(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__task${k?` is-expanded`:``}`,title:bf(),"aria-expanded":k,onClick:()=>A(e=>!e),children:d}):null]})]}),(0,J.jsx)(l$,{meta:u?.sessionMeta,telemetry:u?.telemetry,childAgentId:u?.childAgentId,instanceName:c,parentAgentLabel:r,onExport:u?te:void 0}),(0,J.jsx)(`div`,{className:`oc-subpanel__body`,ref:R,children:u?(0,J.jsxs)(J.Fragment,{children:[u.tools&&u.tools.length>0&&F?(0,J.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,J.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:pt()}),(0,J.jsx)(c$,{summary:u.tools,parts:g,subAgentRunning:u.tone===`running`})]}):null,u.failure?(0,J.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,J.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:Nt()}),(0,J.jsx)(`p`,{className:`oc-subpanel__error`,children:$Q(u.errorMessage,u.errorCode,u.runTimeoutSeconds)}),p===null?null:(0,J.jsxs)(`details`,{className:`oc-subpanel__error-detail`,children:[(0,J.jsx)(`summary`,{children:pc()}),(0,J.jsx)(`p`,{className:`oc-subpanel__muted`,children:p})]})]}):null,u.resultText?(0,J.jsxs)(`section`,{className:`oc-subpanel__section oc-subpanel__result${C?` is-open`:``}`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__result-toggle`,"aria-expanded":C,onClick:()=>w(!C),children:[(0,J.jsx)(QS,{size:13,className:`oc-subpanel__result-chevron`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subpanel__section-title`,children:kb()})]}),C?(0,J.jsx)(cq,{text:u.resultText}):null]}):u.tone===`running`?(0,J.jsxs)(`p`,{className:`oc-subpanel__muted oc-subpanel__working`,children:[(0,J.jsx)(kC,{size:14,className:`oc-subagent__spin`,"aria-hidden":!0}),Ke()]}):null,_&&_.length>0?(0,J.jsxs)(`section`,{className:`oc-subpanel__section`,children:[(0,J.jsx)(`h3`,{className:`oc-subpanel__section-title`,children:Ts()}),(0,J.jsx)(`div`,{className:`oc-subpanel__thread`,children:_.map(e=>(0,J.jsxs)(`div`,{className:`oc-subpanel__exchange`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--user`,children:[e.userText,e.attachments&&e.attachments.length>0?(0,J.jsx)(`div`,{className:`oc-subpanel__msg-atts`,children:e.attachments.map((t,n)=>(0,J.jsxs)(`span`,{className:`oc-subpanel__attchip oc-subpanel__attchip--sent`,title:t.filename,children:[(0,J.jsx)(ej,{size:11,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subpanel__attchip-name`,children:t.filename})]},`${e._id}-att-${n}`))}):null]}),e.status===`pending`?(0,J.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--pending`,children:[(0,J.jsx)(kC,{size:13,className:`oc-actrow__spin`,"aria-hidden":!0}),Xi()]}):e.status===`error`?(0,J.jsx)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--err`,children:t$(e.errorMessage)}):(0,J.jsxs)(`div`,{className:`oc-subpanel__msg oc-subpanel__msg--reply`,children:[(0,J.jsx)(cq,{text:e.replyText??``}),e.widgetOmitted===!0?(0,J.jsx)(`p`,{className:`oc-subpanel__note`,children:an()}):null]})]},e._id))})]}):null]}):(0,J.jsx)(`p`,{className:`oc-subpanel__muted`,children:oo()})}),s?null:(0,J.jsx)(`footer`,{className:`oc-subpanel__foot`,children:T?(0,J.jsxs)(`div`,{className:`oc-subpanel__prompt`,children:[j.length>0?(0,J.jsx)(`div`,{className:`oc-subpanel__attstrip`,children:j.map((e,t)=>(0,J.jsxs)(`span`,{className:`oc-subpanel__attchip`,title:e.filename,children:[(0,J.jsx)(ej,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subpanel__attchip-name`,children:e.filename}),(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__attchip-x`,"aria-label":Xh(),onClick:()=>M(e=>e.filter((e,n)=>n!==t)),children:(0,J.jsx)(XC,{size:11,"aria-hidden":!0})})]},`${e.storageId}-${t}`))}):null,(0,J.jsx)(`textarea`,{className:`oc-subpanel__prompt-input`,rows:2,value:D,onChange:e=>O(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ae())},placeholder:_t(),autoFocus:!0}),(0,J.jsxs)(`div`,{className:`oc-subpanel__prompt-bar`,children:[(0,J.jsxs)(`div`,{className:`oc-subpanel__composer-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-subpanel__composer-btn`,title:Dh(),"aria-label":Dh(),disabled:N||j.length>=6,onClick:()=>L.current?.click(),children:N?(0,J.jsx)(kC,{size:15,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(RC,{size:15,"aria-hidden":!0})}),u?.tools&&u.tools.length>0?(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__composer-btn oc-subpanel__composer-btn--label${F?` is-on`:``}`,title:ne(),"aria-pressed":F,onClick:()=>I(e=>!e),children:[(0,J.jsx)(yj,{size:14,"aria-hidden":!0}),pt()]}):null]}),u?.tone===`running`?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:Ba()}):m?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:fl()}):f?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:rr()}):(_??[]).some(e=>e.status===`pending`)?(0,J.jsx)(`span`,{className:`oc-subpanel__prompt-hint`,children:_a()}):null,(0,J.jsxs)(K,{variant:`default`,size:`sm`,className:`gap-1.5`,disabled:!D.trim()&&j.length===0||x||N||u?.tone===`running`||f||m||(_??[]).some(e=>e.status===`pending`),onClick:()=>void ae(),children:[x?(0,J.jsx)(kC,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(ij,{size:14,"aria-hidden":!0}),Lt()]})]}),(0,J.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`oc-subpanel__fileinput`,onChange:e=>void ee(e.target.files)})]}):(0,J.jsxs)(`button`,{type:`button`,className:`oc-subpanel__interact`,onClick:()=>E(!0),children:[(0,J.jsx)(mS,{size:15,"aria-hidden":!0}),uo()]})}),(0,J.jsx)(wX,{target:z,onClose:()=>B(null)})]})}var p$=[`op`,`jobId`,`name`,`enabled`,`schedule`,`message`,`deliveryMode`,`agentId`,`nextRunAtMs`],m$=null,h$=1,g$=new Set;function _$(){for(let e of[...g$])e()}function v$(e){return g$.add(e),()=>g$.delete(e)}function y$(){return m$}function b$(e){return m$={pinId:h$++,kind:e.kind,ownerUserId:e.ownerUserId,originChatId:e.originChatId,originLabel:e.originLabel,params:e.params,pinned:!1},_$(),m$}function x$(e,t){m$===null||m$.pinId!==e||m$.pinned!==t&&(m$={...m$,pinned:t},_$())}function S$(e){m$!==null&&(e!==void 0&&e!==m$.pinId||(m$=null,_$()))}function C$(e,t){m$===null||m$.pinId!==e||(m$={...m$,params:t},_$())}function w$(e,t){return e===null||e.ownerUserId!==t.userId?`none`:e.pinned||O$(e,t)?`dock`:`none`}function T$(e,t){switch(e){case`sources`:return`sources:${String(t.messageId??``)}`;case`subagent`:return`subagent:${String(t.childKey??``)}`;case`cron`:{let e=t.part??{};return`cron:${JSON.stringify([String(t.instanceName??``),String(t.jobId??``),String(t.occurrenceId??``),p$.map(t=>e[t]??null)])}`}case`document`:{let e=t.doc??{};return`document:${JSON.stringify([e.filename??null,e.storageId??e.url??null])}`}}}function E$(e,t){return e-420>=t}function D$(e,t,n){return Math.max(n,Math.min(e,t-420))}function O$(e,t){return e===null||e.ownerUserId!==t.userId?!1:e.originChatId!==null&&e.originChatId===t.chatId}function k$(e,t){return e===null||e.ownerUserId!==t.userId?!1:!e.pinned&&!O$(e,t)}function A$(e,t){return O$(e,t)?`keep`:`close`}function j$(e,t){return O$(e,t)?e:null}function M$(){let[e,t]=(0,q.useState)(()=>window.innerWidth);return(0,q.useLayoutEffect)(()=>{let e=()=>{let e=document.querySelector(`.oc-workspace`);if(e===null)return;let n=e.querySelector(`.oc-sidebar-col`),r=n===null?0:n.getBoundingClientRect().width,i=e.getBoundingClientRect().width-r;i>0&&t(i)},n=new ResizeObserver(e);n.observe(document.documentElement);let r=new Set,i=()=>{let t=document.querySelector(`.oc-workspace`),i=new Set;if(t!==null){let e=t.querySelector(`.oc-sidebar-col`);e!==null&&i.add(e)}for(let e of r)i.has(e)||n.unobserve(e);for(let e of i)r.has(e)||n.observe(e);r.clear();for(let e of i)r.add(e);e()};i();let a=new MutationObserver(i);return a.observe(document.body,{childList:!0,subtree:!0}),()=>{n.disconnect(),a.disconnect()}},[]),e}var N$=`oc.sidebar.width`,P$=`oc.sidebar.collapsed`,F$=200,I$=520,L$=260,R$=`(max-width: 767px)`;function z$(){let[e,t]=(0,q.useState)(()=>typeof window<`u`&&window.matchMedia(R$).matches);return(0,q.useEffect)(()=>{let e=window.matchMedia(R$),n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var B$=new Map;function V$(e,t,n){let r=B$.get(e);if(r!==void 0)for(let e of[...r])e!==n&&e(t)}function H$(e){let{storageKey:t,defaultWidth:n,min:r,max:i,edge:a,maxViewportFraction:o}=e,s=e.fit??(e=>e),c=(0,q.useRef)(s);c.current=s;let l=(0,q.useCallback)(e=>Math.min(i,Math.max(r,e)),[r,i]),[u,d]=(0,q.useState)(()=>{let e=Number(localStorage.getItem(t));return l(e||n)}),[f,p]=(0,q.useState)(()=>window.innerWidth);(0,q.useEffect)(()=>{let e=()=>p(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let m=(0,q.useCallback)(e=>{let t=o===void 0?1/0:Math.round(f*o);return Math.min(Math.max(r,Math.min(i,t)),Math.max(r,e))},[r,i,o,f]),h=(0,q.useRef)(m);h.current=m;let g=(0,q.useRef)(u);g.current=u;let[_,v]=(0,q.useState)(null),y=s(m(_??u)),b=(0,q.useRef)(()=>{});(0,q.useEffect)(()=>{localStorage.setItem(t,String(u)),V$(t,u,b.current)},[t,u]);let x=(0,q.useCallback)(e=>{localStorage.setItem(t,String(e)),V$(t,e,b.current),d(e)},[t]);(0,q.useEffect)(()=>{let e=e=>d(e);b.current=e;let n=B$.get(t)??new Set;return n.add(e),B$.set(t,n),()=>{n.delete(e),n.size===0&&B$.delete(t)}},[t]);let S=(0,q.useRef)(!1),C=(0,q.useRef)(null),w=(0,q.useRef)(null);return(0,q.useEffect)(()=>()=>w.current?.(),[]),{width:y,startResize:(0,q.useCallback)(e=>{if(w.current!==null)return;e.preventDefault(),S.current=!0;let t=e.pointerId,n=e.currentTarget;try{n.setPointerCapture(t)}catch{}let r=e.clientX,i=y,o=!1,s=a===`left`?1:-1,u=i,d=0,f=e=>c.current(h.current(e)),p=()=>{d=0;let e=C.current;if(e){let t=f(u);e.style.width=`${t}px`,e.style.flex=`0 0 ${t}px`}},m=e=>{if(!S.current||e.pointerId!==t)return;let n=l(i+s*(e.clientX-r));f(n)!==f(u)&&(o=!0),u=n,C.current?d===0&&(d=requestAnimationFrame(p)):v(u)},_=e=>{if(e instanceof PointerEvent&&e.pointerId!==t)return;S.current=!1,d!==0&&cancelAnimationFrame(d),v(null),window.removeEventListener(`pointermove`,m),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_),window.removeEventListener(`blur`,_),document.removeEventListener(`lostpointercapture`,_);try{n.hasPointerCapture(t)&&n.releasePointerCapture(t)}catch{}w.current=null,document.body.style.cursor=``,document.body.style.userSelect=``;let r=o&&u!==i,a=r?u:g.current,s=C.current;if(s){let e=f(a);s.style.width=`${e}px`,s.style.flex=`0 0 ${e}px`}r&&x(u)};w.current=_,window.addEventListener(`pointermove`,m),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_),window.addEventListener(`blur`,_),document.addEventListener(`lostpointercapture`,_),document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`},[y,a,m,l,x]),setWidth:d,columnRef:C}}function U$(){let{width:e,startResize:t,columnRef:n}=H$({storageKey:N$,defaultWidth:L$,min:F$,max:I$,edge:`left`}),[r,i]=(0,q.useState)(()=>localStorage.getItem(P$)===`1`),a=z$();return(0,q.useEffect)(()=>{localStorage.setItem(P$,r?`1`:`0`)},[r]),(0,q.useEffect)(()=>{a&&i(!0)},[a]),{width:e,columnRef:n,collapsed:r,toggleCollapsed:(0,q.useCallback)(()=>i(e=>!e),[]),collapse:(0,q.useCallback)(()=>i(!0),[]),startResize:t,isMobile:a,MIN_WIDTH:F$,MAX_WIDTH:I$}}function W$(e){let t=H$({storageKey:`oc.sources.width`,fit:e(300),defaultWidth:380,min:300,max:680,edge:`right`}),n=H$({storageKey:`oc.subagent.width`,fit:e(320),defaultWidth:460,min:320,max:720,edge:`right`}),r=H$({storageKey:`oc.docviewer.width`,fit:e(380),defaultWidth:560,min:380,max:1800,maxViewportFraction:.72,edge:`right`}),i={...t,min:300},a={...r,min:380};return{sources:i,subagent:{...n,min:320},cron:i,document:a}}function G$({viewerUserId:e,currentChatId:t}){let n=(0,q.useSyncExternalStore)(v$,y$,y$),r=Kx(),i=z$(),a=M$(),o=W$((0,q.useCallback)(e=>t=>D$(t,a,e),[a])),s={userId:e,chatId:t};(0,q.useEffect)(()=>()=>S$(),[]);let c=k$(n,s),l=n?.pinId;if((0,q.useEffect)(()=>{c&&l!==void 0&&S$(l)},[c,l]),n===null||w$(n,s)!==`dock`)return null;let u=n.params,d=()=>S$(n.pinId),{width:f,startResize:p,columnRef:m,min:h}=o[n.kind],g=i||!E$(a,h);if(g&&!n.pinned)return null;let _=D$(f,a,h);return(0,J.jsx)(rJ,{children:(0,J.jsxs)(`aside`,{className:`oc-pinpanel`,ref:m,hidden:g,style:g?{display:`none`}:{width:_,flex:`0 0 ${_}px`},"aria-label":ju({origin:n.originLabel}),children:[(0,J.jsx)(`div`,{className:`oc-pinpanel__resizer`,onPointerDown:p,role:`separator`,"aria-orientation":`vertical`,"aria-label":J_()}),(0,J.jsxs)(`div`,{className:`oc-pinpanel__head`,children:[(0,J.jsx)(`span`,{className:`oc-pinpanel__origin`,title:n.originLabel,children:n.originLabel}),(0,J.jsxs)(`span`,{className:`oc-pinpanel__ctrls`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-pinpanel__btn${n.pinned?` is-on`:``}`,"aria-pressed":n.pinned,title:n.pinned?vi():Tn(),"aria-label":n.pinned?vi():Tn(),onClick:()=>{if(!n.pinned){x$(n.pinId,!0);return}A$(n,s)===`close`?d():x$(n.pinId,!1)},children:n.pinned?(0,J.jsx)(IS,{size:14,"aria-hidden":!0}):(0,J.jsx)(Zx,{size:14,"aria-hidden":!0})}),n.originChatId!==null&&!O$(n,s)?(0,J.jsx)(`button`,{type:`button`,className:`oc-pinpanel__btn`,title:qr(),"aria-label":qr(),onClick:()=>void r({to:`/chat/$chatId`,params:{chatId:n.originChatId}}),children:(0,J.jsx)(bA,{size:14,"aria-hidden":!0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-pinpanel__btn`,title:Nc(),"aria-label":Nc(),onClick:d,children:(0,J.jsx)(XC,{size:14,"aria-hidden":!0})})]})]}),(0,J.jsx)(AK,{onClose:d,children:(0,J.jsx)(`div`,{className:`oc-pinpanel__body`,children:n.kind===`cron`?(0,J.jsx)(kK,{instanceName:u.instanceName,part:u.part,onClose:d}):n.kind===`document`?(0,J.jsx)(Bq.Provider,{value:{activeDoc:u.doc,openFor:e=>C$(n.pinId,{...u,doc:e}),openNewerVersion:e=>C$(n.pinId,{...u,doc:e}),close:d},children:(0,J.jsx)(Hq,{doc:u.doc,chatId:n.originChatId,onClose:d})}):n.kind===`subagent`?(0,J.jsx)(f$,{chatId:n.originChatId,childKey:u.childKey,onClose:d,parentAgentLabel:u.parentAgentLabel??``}):(0,J.jsx)(bJ,{messageId:u.messageId,onClose:d})})},n.pinId)]})})}var K$=`atrium:lastChatId`;function q$(e){try{localStorage.setItem(K$,e)}catch{}}function J$(){try{return localStorage.getItem(K$)}catch{return null}}function Y$(e){let t=e instanceof Error?`${e.name}: ${e.message}`:String(e??``);return t.includes(`Failed to fetch dynamically imported module`)||t.includes(`Importing a module script failed`)||t.includes(`error loading dynamically imported module`)||t.includes(`Unable to preload CSS`)}var X$=`atrium:chunkReloadAt`,Z$=6e4;function Q$(){try{return typeof sessionStorage>`u`?null:sessionStorage}catch{return null}}function $$(e,t=Q$()){if(t===null)return!1;try{let n=Number(t.getItem(X$)??0);return Number.isFinite(n)&&e-n<Z$?!1:(t.setItem(X$,String(e)),!0)}catch{return!1}}var e1=null,t1=null,n1=null;async function r1(){try{let e=await fetch(`/config.json`,{cache:`no-store`});if(e.ok){let t=await e.json(),n=t?.convexSiteUrl;typeof n==`string`&&n.trim()&&(t1=n.trim());let r=t?.widgetSandboxOrigin;typeof r==`string`&&r.trim()&&(n1=r.trim());let i=t?.convexUrl;if(typeof i==`string`&&i.trim())return e1=i.trim(),e1}}catch{}throw Error(`No Convex URL configured: serve /config.json {"convexUrl":"…"} (production) or set VITE_CONVEX_URL (local dev).`)}function i1(e){try{let t=new URL(e);return t.hostname.endsWith(`.convex.cloud`)?(t.hostname=t.hostname.replace(/\.convex\.cloud$/,`.convex.site`),t.origin):t.port?(t.port=String(Number(t.port)+1),t.origin):e}catch{return e}}function a1(){return t1||(e1?i1(e1):null)}function o1(){return e1||null}function s1(){return n1||null}var c1=`<!doctype html>
22
+ <meta charset="utf-8" />
23
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
24
+ <title>MCP App sandbox</title>
25
+ <style>html,body{height:100%;margin:0;background:transparent}iframe{display:block;width:100%;height:100%;border:0;background:transparent}</style>
26
+ <body>
27
+ <script>
28
+ (() => {
29
+ if (window.self === window.top) throw new Error("invalid MCP App sandbox host");
30
+ let hostOrigin;
31
+ try {
32
+ const referrer = new URL(document.referrer);
33
+ if (referrer.protocol !== "http:" && referrer.protocol !== "https:") throw new Error();
34
+ hostOrigin = referrer.origin;
35
+ } catch { throw new Error("invalid MCP App sandbox parent"); }
36
+ try { void window.top.document; throw new Error("MCP App sandbox isolation failed"); } catch (error) {
37
+ if (error instanceof Error && error.message === "MCP App sandbox isolation failed") throw error;
38
+ }
39
+ const createInner = (allowScripts = true) => {
40
+ const frame = document.createElement("iframe");
41
+ // Block native popups here without reserving widget globals such as open.
42
+ frame.setAttribute("sandbox", allowScripts ? "allow-scripts allow-forms" : "");
43
+ return frame;
44
+ };
45
+ let inner = createInner();
46
+ document.body.appendChild(inner);
47
+ const widgetPortsOffered = new Set();
48
+ const blockDescendantFrames = true;
49
+ const descendantSelector = "iframe,frame,object,embed,portal,fencedframe,webview,browser";
50
+ const hasBlockedDescendant = root => {
51
+ if (root.querySelector(descendantSelector)) return true;
52
+ for (const template of root.querySelectorAll("template")) {
53
+ if (hasBlockedDescendant(template.content)) return true;
54
+ }
55
+ return false;
56
+ };
57
+ const documentGuard = "\\u003cscript>(()=>{\\n const blocked=[\\"iframe\\",\\"frame\\",\\"object\\",\\"embed\\",\\"portal\\",\\"fencedframe\\",\\"webview\\",\\"browser\\"];\\n const apply=Reflect.apply;\\n const defineProperty=Object.defineProperty;\\n const getOwnPropertyDescriptor=Object.getOwnPropertyDescriptor;\\n const toString=String;\\n const toLowerCase=String.prototype.toLowerCase;\\n const lastIndexOf=String.prototype.lastIndexOf;\\n const slice=String.prototype.slice;\\n const includes=Array.prototype.includes;\\n const regexpTest=RegExp.prototype.test;\\n const descendantMarkup=/\\u003c\\\\s*(?:iframe|frame|object|embed|portal|fencedframe|webview|browser)\\\\b/iu;\\n const reject=()=>{throw new Error(\\"sandbox descendant browsing contexts are disabled\\");};\\n const assertName=name=>{const value=apply(toLowerCase,toString(name),[]);const separator=apply(lastIndexOf,value,[\\":\\"]);const localName=separator\\u003c0?value:apply(slice,value,[separator+1]);if(apply(includes,blocked,[localName]))reject();};\\n const assertMarkup=value=>{if(apply(regexpTest,descendantMarkup,[toString(value)]))reject();};\\n const lock=(target,name,value)=>{try{defineProperty(target,name,{value,writable:false,configurable:false});}catch{}};\\n for(const name of [\\"RTCPeerConnection\\",\\"webkitRTCPeerConnection\\",\\"RTCIceGatherer\\",\\"RTCIceTransport\\",\\"RTCDtlsTransport\\",\\"RTCSctpTransport\\",\\"RTCDataChannel\\"])lock(globalThis,name,undefined);\\n const createElement=Document.prototype.createElement;\\n lock(Document.prototype,\\"createElement\\",function(name,...args){assertName(name);return Reflect.apply(createElement,this,[name,...args]);});\\n const createElementNS=Document.prototype.createElementNS;\\n lock(Document.prototype,\\"createElementNS\\",function(namespace,name,...args){assertName(name);return Reflect.apply(createElementNS,this,[namespace,name,...args]);});\\n const wrapSetter=(target,name)=>{const descriptor=getOwnPropertyDescriptor(target,name);if(!descriptor?.set)return;try{defineProperty(target,name,{get:descriptor.get,set(value){assertMarkup(value);return apply(descriptor.set,this,[value]);},enumerable:descriptor.enumerable,configurable:false});}catch{}};\\n wrapSetter(Element.prototype,\\"innerHTML\\");wrapSetter(Element.prototype,\\"outerHTML\\");\\n if(globalThis.ShadowRoot)wrapSetter(ShadowRoot.prototype,\\"innerHTML\\");\\n const wrapMethod=(target,name,indexes)=>{const original=target?.[name];if(typeof original!==\\"function\\")return;lock(target,name,function(...args){if(indexes){for(let index=0;index\\u003cindexes.length;index+=1)assertMarkup(args[indexes[index]]);}else{for(let index=0;index\\u003cargs.length;index+=1)assertMarkup(args[index]);}return apply(original,this,args);});};\\n wrapMethod(Element.prototype,\\"insertAdjacentHTML\\",[1]);wrapMethod(Document.prototype,\\"write\\");wrapMethod(Document.prototype,\\"writeln\\");wrapMethod(Range.prototype,\\"createContextualFragment\\",[0]);wrapMethod(DOMParser.prototype,\\"parseFromString\\",[0]);\\n wrapMethod(Element.prototype,\\"setHTMLUnsafe\\",[0]);wrapMethod(Element.prototype,\\"setHTML\\",[0]);\\n if(globalThis.ShadowRoot){wrapMethod(ShadowRoot.prototype,\\"setHTMLUnsafe\\",[0]);wrapMethod(ShadowRoot.prototype,\\"setHTML\\",[0]);}\\n})();\\u003c/script>";
58
+ const resolveLeadingDoctypeEnd = (html) => {
59
+ let index = html.charCodeAt(0) === 0xfeff ? 1 : 0;
60
+ const whitespace = new Set([9, 10, 12, 13, 32]);
61
+ while (true) {
62
+ while (index < html.length && whitespace.has(html.charCodeAt(index))) index += 1;
63
+ if (html.slice(index, index + 4) !== "<!--") break;
64
+ const commentEnd = html.indexOf("-->", index + 4);
65
+ if (commentEnd < 0) return 0;
66
+ index = commentEnd + 3;
67
+ }
68
+ if (html.slice(index, index + 9).toLowerCase() !== "<!doctype") return 0;
69
+ let quote = "";
70
+ for (let cursor = index + 9; cursor < html.length; cursor += 1) {
71
+ const char = html[cursor];
72
+ if (quote) { if (char === quote) quote = ""; continue; }
73
+ if (char === '"' || char === "'") { quote = char; continue; }
74
+ if (char === ">") return cursor + 1;
75
+ }
76
+ return 0;
77
+ };
78
+ const guardDocument = html => {
79
+ if (!blockDescendantFrames) return html;
80
+ if (hasBlockedDescendant(new DOMParser().parseFromString(html, "text/html"))) {
81
+ throw new Error("sandbox descendant browsing contexts are disabled");
82
+ }
83
+ const doctypeEnd = resolveLeadingDoctypeEnd(html);
84
+ return html.slice(0, doctypeEnd) + documentGuard + html.slice(doctypeEnd);
85
+ };
86
+ window.addEventListener("message", (event) => {
87
+ if (event.source === window.parent) {
88
+ if (event.origin !== hostOrigin) return;
89
+ if (event.data?.method === "ui/notifications/sandbox-resource-ready") {
90
+ const params = event.data.params ?? {};
91
+ if (typeof params.html === "string") {
92
+ const guardedHtml = guardDocument(params.html);
93
+ // Replace the browsing context so a superseded document cannot race
94
+ // the new wrapper's first private bridge-port offer.
95
+ const nextInner = createInner(params.allowScripts !== false);
96
+ nextInner.addEventListener("load", () => {
97
+ if (inner !== nextInner || typeof params.renderId !== "string") return;
98
+ window.parent.postMessage({
99
+ jsonrpc: "2.0",
100
+ method: "ui/notifications/sandbox-resource-loaded",
101
+ params: { renderId: params.renderId },
102
+ }, hostOrigin);
103
+ }, { once: true });
104
+ widgetPortsOffered.clear();
105
+ nextInner.srcdoc = guardedHtml;
106
+ inner.replaceWith(nextInner);
107
+ inner = nextInner;
108
+ }
109
+ return;
110
+ }
111
+ if (typeof event.data?.method === "string" && event.data.method.startsWith("ui/notifications/sandbox-")) return;
112
+ inner.contentWindow?.postMessage(event.data, "*");
113
+ return;
114
+ }
115
+ if (event.source === inner.contentWindow) {
116
+ if (typeof event.data?.method === "string" && event.data.method.startsWith("ui/notifications/sandbox-")) return;
117
+ if (event.data?.type === "openclaw:widget-bridge-port-offer" || event.data?.type === "openclaw:widget-prompt-offer") {
118
+ const port = event.ports[0];
119
+ // Each wrapper offers its private channels before untrusted code runs.
120
+ // Only the first offer of each kind belongs to this document instance.
121
+ if (!widgetPortsOffered.has(event.data.type) && port) {
122
+ widgetPortsOffered.add(event.data.type);
123
+ window.parent.postMessage(event.data, hostOrigin, [port]);
124
+ } else {
125
+ port?.close();
126
+ }
127
+ return;
128
+ }
129
+ window.parent.postMessage(event.data, hostOrigin);
130
+ }
131
+ });
132
+ window.parent.postMessage({
133
+ jsonrpc: "2.0",
134
+ method: "ui/notifications/sandbox-proxy-ready",
135
+ params: { sandboxUrl: window.location.href },
136
+ }, hostOrigin);
137
+ })();
138
+ <\/script>
139
+ </body>`,l1={"Content-Type":`text/html; charset=utf-8`,"Content-Security-Policy":`default-src 'none'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; style-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; img-src 'self' data: https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; media-src 'self' data: https: blob:; font-src 'self' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net https://esm.sh https://unpkg.com https://fonts.googleapis.com https://fonts.gstatic.com https://fonts.bunny.net; connect-src 'none'; webrtc 'block'; frame-src 'none'; base-uri 'self'; object-src 'none'; form-action 'none'; frame-ancestors http: https:`,"Permissions-Policy":`camera=(), microphone=(), geolocation=(), clipboard-write=()`,"Cross-Origin-Resource-Policy":`cross-origin`,"Origin-Agent-Cluster":`?1`,"Referrer-Policy":`no-referrer`,"X-Content-Type-Options":`nosniff`},u1=`openclaw:widget-size`,d1=`openclaw:widget-theme`,f1=`openclaw:widget-chat-host`,p1=`openclaw:widget-bridge-ready`,m1=`openclaw:widget-prompt-offer`,h1=`openclaw:widget-prompt-host-ready`,g1=`openclaw:widget-bridge-port-offer`,_1=`openclaw:widget-runtime-error`,v1=`ui/notifications/sandbox-resource-ready`,y1=`allow-scripts allow-forms`,b1=`allow-scripts allow-same-origin allow-forms`,x1=8e3,S1=1e4;function C1(e){return typeof e!=`number`||!Number.isFinite(e)||e<=0?null:Math.min(x1,Math.max(48,Math.trunc(e)))}function w1(e,t,n){return t!=null&&e.source===t&&e.origin===n}function T1(e,t,n=[]){if(!e||!e.trim())return{mode:`simple`,reason:`unset`};let r;try{r=new URL(e.trim())}catch{return{mode:`simple`,reason:`invalid`}}if(r.protocol!==`https:`&&r.protocol!==`http:`||r.username!==``||r.password!==``||r.pathname!==`/`&&r.pathname!==``||r.search!==``||r.hash!==``)return{mode:`simple`,reason:`invalid`};let i=r.origin,a=e=>{if(!e)return!1;try{return new URL(e).origin===i}catch{return!1}};return a(t)||n.some(a)?{mode:`simple`,reason:`same-origin`}:r.protocol===`http:`&&t.startsWith(`https:`)?{mode:`simple`,reason:`insecure`}:{mode:`dedicated`,origin:i}}function E1(e){return e.mode===`dedicated`?`frame-src ${e.origin}`:`frame-src 'none'`}var D1=`data-atrium-frame-policy`;function O1(e,t){if(e.head.querySelector(`meta[data-atrium-frame-policy]`))return;let n=e.createElement(`meta`);n.httpEquiv=`Content-Security-Policy`,n.content=t,n.setAttribute(D1,``),e.head.prepend(n)}function k1(e){return`${e}/`}function A1(e,t){let n=e;return n?.method===`ui/notifications/sandbox-proxy-ready`&&n.params?.sandboxUrl===t}function j1(e,t){return{jsonrpc:`2.0`,method:v1,params:{html:e,renderId:t}}}function M1(){let e=/const documentGuard = ("(?:[^"\\]|\\.)*");/.exec(c1);if(!e)throw Error(`vendored widget sandbox proxy has no documentGuard`);return JSON.parse(e[1])}var N1=M1(),P1=`media-src 'self' data: blob:`;function F1(e){let t=e.split(`;`).map(e=>e.trim()).filter(e=>e!==``),n=!1,r=t.map(e=>e.split(/\s+/)[0].toLowerCase()===`media-src`?(n=!0,P1):e);return n||r.push(P1),r.join(`; `)}var I1={...l1,"Content-Security-Policy":F1(l1[`Content-Security-Policy`])}[`Content-Security-Policy`].split(`;`).map(e=>e.trim()).filter(e=>e!==``&&!e.startsWith(`frame-ancestors`)).join(`; `),L1=`iframe,frame,object,embed,portal,fencedframe,webview,browser`;function R1(e){let t=+(e.charCodeAt(0)===65279),n=new Set([9,10,12,13,32]);for(;;){for(;t<e.length&&n.has(e.charCodeAt(t));)t+=1;if(e.slice(t,t+4)!==`<!--`)break;let r=e.indexOf(`-->`,t+4);if(r<0)return 0;t=r+3}if(e.slice(t,t+9).toLowerCase()!==`<!doctype`)return 0;let r=``;for(let n=t+9;n<e.length;n+=1){let t=e[n];if(r){t===r&&(r=``);continue}if(t===`"`||t===`'`){r=t;continue}if(t===`>`)return n+1}return 0}var z1=class extends Error{};function B1(e){if(e.querySelector(L1))return!0;for(let t of e.querySelectorAll(`template`))if(B1(t.content))return!0;return!1}function V1(e,t){if(B1(t(e)))throw new z1(`widget documents may not embed frames`);let n=R1(e),r=`<meta http-equiv="Content-Security-Policy" content="${I1.replaceAll(`"`,`&quot;`)}">`;return e.slice(0,n)+r+N1+e.slice(n)}var H1=[`surface`,`card`,`elevated`,`text`,`text-strong`,`muted`,`border`,`border-strong`,`accent`,`accent-fill`,`accent-fg`,`ok`,`warn`,`danger`,`info`,`radius`,`radius-full`,`scrollbar-size`,`scrollbar-thumb-inset`,`scrollbar-thumb`,`scrollbar-thumb-hover`,`font-body`,`font-mono`],U1={surface:{cssVar:`--background`},card:{cssVar:`--card`},elevated:{cssVar:`--popover`},text:{cssVar:`--foreground`},"text-strong":{cssVar:`--foreground`},muted:{cssVar:`--muted-foreground`},border:{cssVar:`--border`},"border-strong":{cssVar:`--ring`},accent:{cssVar:`--primary`},"accent-fill":{cssVar:`--primary`},"accent-fg":{cssVar:`--primary-foreground`},ok:{light:`#15803d`,dark:`#22c55e`},warn:{light:`#b45309`,dark:`#f59e0b`},danger:{cssVar:`--destructive`},info:{light:`#2563eb`,dark:`#3b82f6`},radius:{cssVar:`--radius`},"radius-full":{value:`9999px`},"scrollbar-size":{value:`12px`},"scrollbar-thumb-inset":{value:`3px`},"scrollbar-thumb":{value:`color-mix(in srgb,var(--muted) 32%,transparent)`},"scrollbar-thumb-hover":{value:`color-mix(in srgb,var(--muted) 64%,transparent)`},"font-body":{cssVar:`--ui-font-sans`},"font-mono":{cssVar:`--ui-font-mono`}};function W1(e,t){let n={};for(let r of H1){let i=U1[r],a=`cssVar`in i?e(i.cssVar).trim():`value`in i?i.value:i[t];a&&a.length<=256&&(n[r]=a)}return{type:d1,mode:t,tokens:n}}var G1=6e4,K1=100;function q1(e){if(typeof e!=`string`)return null;let t=e.trim();return!t||t.length>4e3||t.startsWith(`/`)||t.startsWith(`!`)?null:t}var J1=new class{byKey=new Map;allow(e,t){let n=t-G1,r=(this.byKey.get(e)??[]).filter(e=>e>n);if(!this.byKey.has(e)&&this.byKey.size>=K1){let e=this.byKey.keys().next().value;e!==void 0&&this.byKey.delete(e)}return r.length>=10?(this.byKey.set(e,r),!1):(r.push(t),this.byKey.set(e,r),!0)}};function Y1(e,t,n,r,i=J1){let a=q1(e);return a===null?{ok:!1,reason:`text`}:!t.connected||!t.visible||!t.focused?{ok:!1,reason:`not-interactable`}:i.allow(n,r)?{ok:!0,text:a}:{ok:!1,reason:`rate`}}var X1=class{offered=!1;loaded=!1;pending=null;adopted=null;offer(e){return e?this.offered?(e.close(),null):(this.offered=!0,this.loaded?(this.adopted=e,e):(this.pending=e,null)):null}load(){return this.loaded=!0,this.pending&&!this.adopted?(this.adopted=this.pending,this.pending=null,this.adopted):null}dispose(){this.pending?.close(),this.adopted?.close(),this.pending=null,this.adopted=null}},Z1=class{deps;pendingText=null;constructor(e){this.deps=e}get pending(){return this.pendingText}offer(e){return this.pendingText===null?this.deps.mustConfirm()?(this.pendingText=e,this.deps.onPending(e),`pending`):(this.dispatch(e),`sent`):`ignored`}confirm(){let e=this.pendingText;e!==null&&(this.pendingText=null,this.deps.onPending(null),this.dispatch(e))}cancel(){this.pendingText!==null&&(this.pendingText=null,this.deps.onPending(null))}dispatch(e){this.deps.send(e).then(e=>{e||this.deps.onFailed()},()=>this.deps.onFailed())}};function Q1(e,t,n,r){return{chatId:e,text:t,clientMessageId:r,...n?{routedAgent:n}:{}}}function $1(){let e=document.documentElement,t=getComputedStyle(e);return W1(e=>t.getPropertyValue(e),e.classList.contains(`dark`)?`dark`:`light`)}function e0(e){return new DOMParser().parseFromString(e,`text/html`)}async function t0(e,t,n){let r=a1();if(!r)return{ok:!1,unavailable:!1};let i=new URLSearchParams(t),a=await fetch(`${r.replace(/\/$/,``)}/api/v1/widget-view?${i}`,{headers:{Authorization:`Bearer ${e}`},cache:`no-store`,signal:n});return a.ok?{ok:!0,html:await a.text()}:{ok:!1,unavailable:a.status===404}}function n0({data:e}){let t=e?.viewId??``,n=e?.title?.trim()||jv(),r=$(e=>e.metadata?.custom?.chatId??``),i=$(e=>e.metadata?.custom?.messageId??``),a=$(e=>{let t=e.metadata?.custom;return t?.routedInstanceName&&t.routedAgentId?`${t.routedInstanceName}\u0000${t.routedAgentId}`:null}),o=jE(),s=(0,q.useRef)(o);s.current=o;let c=o!=null&&o!==``,l=U(G.widgets.widgetConfigForMessage,r&&i?{chatId:r,messageId:i}:`skip`),u=l?.effective===!0,d=W(G.send.sendMessage),[f,p]=(0,q.useState)(0),[m,h]=(0,q.useState)({state:`loading`}),[g,_]=(0,q.useState)(e?.preferredHeight??320),[v,y]=(0,q.useState)(null),[b,x]=(0,q.useState)(null),[S,C]=(0,q.useState)(null),w=(0,q.useRef)(null),T=(0,q.useMemo)(()=>T1(s1(),window.location.origin,[a1(),o1()]),[]),E=T.mode===`dedicated`?T.origin:`null`,D=T.mode===`dedicated`?k1(T.origin):null;(0,q.useEffect)(()=>{let e=s.current;if(!u||!e||!r||!i||!t)return;let n=new AbortController,a=!1,o=window.setTimeout(()=>n.abort(),S1*2);return h({state:`loading`}),t0(e,{chatId:r,messageId:i,viewId:t},n.signal).then(e=>{a||h(e.ok?{state:`ready`,html:e.html}:{state:`error`,unavailable:e.unavailable})}).catch(()=>{a||h({state:`error`,unavailable:!1})}).finally(()=>window.clearTimeout(o)),()=>{a=!0,window.clearTimeout(o),n.abort()}},[u,c,r,i,t,f]);let O=(0,q.useMemo)(()=>{if(m.state!==`ready`||T.mode!==`simple`)return null;try{return V1(m.html,e0)}catch(e){return e instanceof z1?``:null}},[m,T.mode]),k=(0,q.useRef)(new X1),j=(0,q.useRef)(null),M=(0,q.useCallback)(()=>{let e=w.current?.contentWindow;if(!e)return;let t=T.mode===`dedicated`?T.origin:`*`;e.postMessage($1(),t),e.postMessage({type:f1},t)},[T]),N=`${r}\u0000${t}\u0000${f}`,P=(0,q.useRef)(!1);P.current=l?.promptConfirm===!0;let F=(0,q.useRef)(async()=>!1);F.current=async e=>{if(!r)return!1;let[t,n]=a?.split(`\0`)??[];try{let i=Q1(r,e,t&&n?{instanceName:t,agentId:n}:null,crypto.randomUUID());return await d({...i,chatId:i.chatId}),!0}catch{return!1}};let[I]=(0,q.useState)(()=>new Z1({mustConfirm:()=>P.current,send:e=>F.current(e),onPending:e=>x(e),onFailed:()=>C(Hn())})),L=(0,q.useCallback)(e=>{let t=w.current,n=Y1(e,{connected:t?.isConnected===!0,visible:t!==null&&(typeof t.checkVisibility==`function`?t.checkVisibility():t.getClientRects().length>0),focused:t!==null&&t.ownerDocument.activeElement===t},N,Date.now());n.ok&&I.offer(n.text)},[N,I]),R=(0,q.useCallback)(e=>{e&&(e.addEventListener(`message`,e=>{let t=e.data;t?.type===`openclaw:widget-prompt`&&L(t.prompt)}),e.start(),e.postMessage({type:h1}))},[L]);(0,q.useEffect)(()=>{let e=new X1;return k.current=e,()=>e.dispose()},[m,f]),(0,q.useEffect)(()=>{if(m.state!==`ready`)return;let e=e=>{let t=w.current;if(!w1(e,t?.contentWindow,E))return;let n=e.data;if(!(!n||typeof n!=`object`)){if(T.mode===`dedicated`&&D){if(A1(n,D)){let e=crypto.randomUUID();j.current=e,t.contentWindow.postMessage(j1(m.html,e),T.origin),R(k.current.load()),M();return}if(n.method===`ui/notifications/sandbox-resource-loaded`)return}switch(n.type){case u1:{let e=C1(n.height);e!==null&&_(e);return}case p1:M();return;case m1:R(k.current.offer(e.ports[0]));return;case g1:e.ports[0]?.close();return;case _1:typeof n.message==`string`&&y(e=>e??n.message.toString().slice(0,300));return}}};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[m,E,T,D,R,M]),(0,q.useEffect)(()=>{if(m.state!==`ready`)return;let e=new MutationObserver(()=>M());return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`,`style`]}),()=>e.disconnect()},[m.state,M]);let ee=(0,q.useCallback)(()=>{T.mode===`simple`&&(R(k.current.load()),M())},[T.mode,R,M]);return t?l===void 0?(0,J.jsx)(`figure`,{className:`oc-widget`,"aria-label":n,children:(0,J.jsx)(`div`,{className:`oc-widget__skeleton`,role:`status`,"aria-label":d_(),style:{minHeight:e?.preferredHeight??320}})}):u?(0,J.jsxs)(`figure`,{className:`oc-widget`,"aria-label":n,children:[(0,J.jsxs)(`figcaption`,{className:`oc-widget__title`,children:[(0,J.jsx)(LA,{className:`size-4`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:n})]}),m.state===`loading`?(0,J.jsx)(`div`,{className:`oc-widget__skeleton`,role:`status`,"aria-label":d_(),style:{minHeight:e?.preferredHeight??320}}):m.state===`error`||O===``?(0,J.jsxs)(`div`,{className:`oc-widget__error`,role:`alert`,children:[(0,J.jsx)(KC,{className:`size-4`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:O===``?A():m.state===`error`&&m.unavailable?wy():Bp()}),(0,J.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>p(e=>e+1),children:[(0,J.jsx)(rj,{className:`size-4`,"aria-hidden":`true`}),ls()]})]}):(0,J.jsxs)(J.Fragment,{children:[v?(0,J.jsxs)(`details`,{className:`oc-widget__notice`,role:`status`,children:[(0,J.jsx)(`summary`,{children:_d()}),(0,J.jsx)(`code`,{className:`oc-widget__notice-detail`,children:v})]}):null,T.mode===`simple`?O===null?null:(0,J.jsx)(`iframe`,{ref:w,className:`oc-widget__frame`,title:n,sandbox:y1,referrerPolicy:`no-referrer`,srcDoc:O,style:{height:g},onLoad:ee},`${t}:${f}`):(0,J.jsx)(`iframe`,{ref:w,className:`oc-widget__frame`,title:n,sandbox:b1,referrerPolicy:`origin`,src:D,style:{height:g}},`${t}:${f}`),b===null?null:(0,J.jsxs)(`div`,{className:`oc-widget__confirm`,role:`alertdialog`,"aria-label":Ku(),children:[(0,J.jsx)(`p`,{className:`oc-widget__confirm-text`,children:si()}),(0,J.jsx)(`blockquote`,{className:`oc-widget__confirm-quote`,children:b}),(0,J.jsxs)(`div`,{className:`oc-widget__confirm-actions`,children:[(0,J.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>I.cancel(),children:lv()}),(0,J.jsx)(K,{size:`sm`,onClick:()=>I.confirm(),children:Pi()})]})]}),S?(0,J.jsx)(`p`,{className:`oc-widget__notice`,role:`status`,children:S}):null]})]}):(0,J.jsxs)(`div`,{className:`oc-widget oc-widget--off`,role:`note`,children:[(0,J.jsx)(LA,{className:`size-4`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{children:bu()})]}):null}var r0=new Map,i0={active:!1,percent:0,count:0},a0=new Set;function o0(){let e=0,t=0;for(let n of r0.values())e+=n.loaded,t+=n.total;let n=r0.size;i0={active:n>0,percent:t>0?Math.min(100,Math.round(e/t*100)):0,count:n};for(let e of a0)e()}var s0={subscribe(e){return a0.add(e),()=>a0.delete(e)},getSnapshot(){return i0},report(e,t,n){r0.set(e,{loaded:t,total:n}),o0()},clear(e){r0.delete(e)&&o0()}},c0=0;function l0(){c0+=1}function u0(){c0=Math.max(0,c0-1)}function d0(){return c0>0}var f0={phase:`idle`,model:null,voice:null,muted:!1,errorCode:null};function p0(e,t){switch(t){case`start`:return e===`idle`?`minting`:null;case`minted`:return e===`minting`?`connecting`:null;case`connected`:return e===`connecting`?`live`:null;case`hangup`:return e===`minting`||e===`connecting`||e===`live`?`ending`:null;case`failed`:return e===`minting`||e===`connecting`||e===`live`?`ending`:null;case`ended`:return e===`ending`?`idle`:null}}function m0(e,t){return t===null||t===``?e:`${e}${e.includes(`?`)?`&`:`?`}model=${encodeURIComponent(t)}`}function h0(e,t){return t?`connect`:`hangup-now`}var g0=new Set([`authorization`,`content-type`]);async function _0(e,t=[1e3,3e3],n=e=>new Promise(t=>setTimeout(t,e))){for(let r=0;;r+=1){try{if((await e()).ok)return!0}catch{}if(r>=t.length)return!1;await n(t[r])}}async function v0(e,t,n=fetch,r){if(e.offerRelay){if(!r)return{ok:!1,code:`relay_unavailable`};try{let n=await r(e.offerRelay.relayId,t);return n.ok&&n.answerSdp.trim()===``?{ok:!1,code:`sdp_empty`}:n}catch{return{ok:!1,code:`relay_failed`}}}if(!e.offerUrl||!e.clientSecret)return{ok:!1,code:`talk_malformed`};try{let r=Object.fromEntries(Object.entries(e.offerHeaders??{}).filter(([e])=>!g0.has(e.toLowerCase()))),i=await n(m0(e.offerUrl,e.model??null),{method:`POST`,headers:{...r,Authorization:`Bearer ${e.clientSecret}`,"Content-Type":`application/sdp`},body:t});if(!i.ok)return{ok:!1,code:i.status===401?`talk_secret_expired`:`sdp_${i.status}`};let a=await i.text();return a.trim()===``?{ok:!1,code:`sdp_empty`}:{ok:!0,answerSdp:a}}catch{return{ok:!1,code:`sdp_unreachable`}}}var y0=[`marin`,`cedar`,`alloy`,`ash`,`ballad`,`coral`,`echo`,`sage`,`shimmer`,`verse`],b0=`oc.talk.voice`,x0=`oc.talk.vad`,S0=[{id:`low`,threshold:.8},{id:`medium`,threshold:.5},{id:`high`,threshold:.3}];function C0(e){return S0.some(t=>t.id===e)?e:``}function w0(e){let t=S0.find(t=>t.id===e);return t?t.threshold:null}function T0(){try{return C0(localStorage.getItem(x0))}catch{return``}}function E0(e){try{C0(e)===``?localStorage.removeItem(x0):localStorage.setItem(x0,e)}catch{}}function D0(e){return y0.includes(e??``)?e:``}function O0(){try{return D0(localStorage.getItem(b0))}catch{return``}}function k0(e){try{D0(e)===``?localStorage.removeItem(b0):localStorage.setItem(b0,e)}catch{}}function A0(e){let t;try{let n=JSON.parse(e);if(typeof n!=`object`||!n)return null;t=n}catch{return null}let n,r,i;if(t.type===`response.output_item.done`){let e=t.item;if(!e||e.type!==`function_call`)return null;n=e.call_id,r=e.name,i=e.arguments}else if(t.type===`response.function_call_arguments.done`)n=t.call_id,r=t.name,i=t.arguments;else return null;if(typeof n!=`string`||n===``||typeof r!=`string`||r===``)return null;let a={};if(typeof i==`string`&&i!==``)try{let e=JSON.parse(i);typeof e==`object`&&e&&(a=e)}catch{}return{callId:n,name:r,args:a}}function j0(e){return e.phase!==`idle`||e.serverCall===!0?!1:e.available!==!0}var M0=new Set([`talk_session_stale`,`agent_restricted`,`talk_disabled`,`talk_unsupported`,`provider_unsupported`,`no_agent`]);function N0(e){return M0.has(e)}function P0(e){switch(e){case`talk_disabled`:return`talk_error_disabled`;case`call_active`:case`talk_call_active`:return`talk_error_call_active`;case`turn_in_flight`:return`talk_error_turn_in_flight`;case`talk_session_stale`:return`talk_error_session_stale`;case`talk_unsupported`:case`provider_unsupported`:return`talk_error_unsupported`;case`mic_denied`:return`talk_error_mic_denied`;case`talk_secret_expired`:return`talk_error_secret_expired`;default:return`talk_error_generic`}}function F0(e){switch(P0(e)){case`talk_error_disabled`:return w();case`talk_error_unsupported`:return fd();case`talk_error_mic_denied`:return Ua();case`talk_error_secret_expired`:return hu();case`talk_error_session_stale`:return ni();case`talk_error_call_active`:return Vu();case`talk_error_turn_in_flight`:return is();case`talk_error_generic`:return`${Oi()} (${e})`}}function I0({chatId:e,routedAgent:t=null,onCallActiveChange:n,serverCallSessionId:r=null}){let[i,a]=(0,q.useState)(f0),[o,s]=(0,q.useState)(()=>O0()),[c,l]=(0,q.useState)(()=>T0()),u=U(G.talk.talkAvailable,{chatId:e,...t?{routedAgent:t}:{}}),d=pa(G.talk.mintTalkSession),f=pa(G.talk.relayTalkToolCall),p=pa(G.talk.relayTalkOffer),m=pa(G.talk.hangupTalkSession),h=(0,q.useRef)(null),g=Mw(),_=(0,q.useRef)(0),v=(0,q.useRef)(null),y=(0,q.useRef)(`idle`),b=(0,q.useRef)({pc:null,mic:null}),x=(0,q.useRef)(null),S=(0,q.useCallback)(e=>{let t=p0(y.current,e);return t===null?null:(y.current=t,a(e=>({...e,phase:t})),t)},[]),C=(0,q.useCallback)(()=>{let e=b.current;try{e.mic?.getTracks().forEach(e=>e.stop())}catch{}try{e.pc?.close()}catch{}e.mic=null,e.pc=null,v.current=null,D(null),x.current&&(x.current.srcObject=null)},[]),w=(0,q.useCallback)(()=>{let t=h.current;h.current=null,t!==null&&_0(()=>m({chatId:e,sessionId:t.sessionId}))},[e,m]),T=(0,q.useCallback)(()=>{S(`hangup`)!==null&&(_.current++,w(),C(),S(`ended`),a(e=>({...e,muted:!1})))},[S,w,C]),[E,D]=(0,q.useState)(null),O=U(G.talk.talkCallLive,E===null?`skip`:{sessionId:E}),k=y.current!==`idle`&&O===!1;(0,q.useEffect)(()=>{k&&(_.current++,w(),C(),S(`ended`),a(e=>({...e,muted:!1})),g.error(iv()))},[k,S,w,C,g]),(0,q.useEffect)(()=>()=>{_.current++,w(),C()},[w,C]);let A=(0,q.useCallback)(async()=>{if(S(`start`)===null)return;let n=++_.current;a(e=>({...e,errorCode:null,muted:!1}));let r=e=>{_.current===n&&(S(`failed`),w(),C(),S(`ended`),a(t=>({...t,errorCode:e})),g.error(F0(e)))},i=w0(c),s=await d({chatId:e,...o===``?{}:{voice:o},...i===null?{}:{vadThreshold:i},...t?{routedAgent:t}:{}}).catch(()=>({ok:!1,code:`mint_failed`}));if(s.ok){if(h0(s.session,_.current===n)===`hangup-now`){_0(()=>m({chatId:e,sessionId:s.sessionId}));return}}else if(_.current!==n)return;if(!s.ok){r(s.code);return}v.current=s.sessionId,D(s.sessionId),h.current={sessionId:s.sessionId};let l;try{l=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{r(`mic_denied`);return}if(_.current!==n){l.getTracks().forEach(e=>e.stop());return}b.current.mic=l,a(e=>({...e,model:s.session.model,voice:s.session.voice})),S(`minted`);let u=new RTCPeerConnection;b.current.pc=u;for(let e of l.getTracks())u.addTrack(e,l);u.ontrack=e=>{_.current!==n||x.current===null||(x.current.srcObject=e.streams[0]??null)};let y=u.createDataChannel(`oai-events`),E=e=>{try{y.send(JSON.stringify(e))}catch{}},O=async t=>{if(t.name!==`openclaw_agent_consult`){E({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:t.callId,output:`Task-control is not available in this interface yet; tell the user so.`}}),E({type:`response.create`});return}E({type:`response.create`,response:{instructions:`Briefly tell the user, in their language, that you are checking with the agent. Do not invent the result.`}});let r=await f({chatId:e,callId:t.callId,...v.current?{sessionId:v.current}:{},args:{question:typeof t.args.question==`string`?t.args.question:``,...typeof t.args.context==`string`?{context:t.args.context}:{},...typeof t.args.responseStyle==`string`?{responseStyle:t.args.responseStyle}:{}}}).catch(()=>({ok:!1,code:`relay_failed`}));if(_.current!==n)return;if(!r.ok&&N0(r.code)){T(),a(e=>({...e,errorCode:r.code})),g.error(F0(r.code));return}let i=r.ok?r.pending?`The agent is still working on it. Tell the user the task continues and its result will arrive in the conversation.`:typeof r.errorText==`string`?`The agent run failed: ${r.errorText}`:r.resultText??``:`The agent could not be reached (${r.code}). Tell the user and suggest typing the request in the conversation instead.`;E({type:`conversation.item.create`,item:{type:`function_call_output`,call_id:t.callId,output:i===``?`(the agent returned an empty result)`:i}}),E({type:`response.create`})},k=new Set;y.onmessage=e=>{if(_.current!==n)return;let t=A0(typeof e.data==`string`?e.data:``);t===null||k.has(t.callId)||(k.add(t.callId),O(t))},u.onconnectionstatechange=()=>{_.current===n&&u.connectionState===`failed`&&r(`rtc_lost`)};try{let t=await u.createOffer();if(await u.setLocalDescription(t),_.current!==n)return;let i=await v0(s.session,t.sdp??``,fetch,(t,n)=>p({chatId:e,sessionId:s.sessionId,relayId:t,sdp:n}));if(_.current!==n)return;if(!i.ok){r(i.code);return}await u.setRemoteDescription({type:`answer`,sdp:i.answerSdp})}catch{r(`rtc_setup`);return}_.current===n&&S(`connected`)},[S,e,m,d,p,w,C,o,c,t]),j=(0,q.useCallback)(()=>{let e=b.current.mic;if(e===null)return;let t=!i.muted;for(let n of e.getAudioTracks())n.enabled=!t;a(e=>({...e,muted:t}))},[i.muted]),M=i.phase,N=M!==`idle`;return(0,q.useEffect)(()=>{n?.(N)},[N,n]),(0,q.useEffect)(()=>()=>{n?.(!1)},[n]),j0({phase:M,available:u,serverCall:r!==null})?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`audio`,{ref:x,autoPlay:!0,className:`oc-talk__audio`}),M===`idle`&&r!==null?(0,J.jsx)(`span`,{className:`oc-talk__pill`,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__pillmain`,title:mh(),"aria-label":mh(),onClick:()=>{_0(()=>m({chatId:e,sessionId:r}))},children:(0,J.jsx)(tj,{size:16,"aria-hidden":!0})})}):M===`idle`?(0,J.jsxs)(`span`,{className:`oc-talk__pill`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__pillmain`,title:lf(),"aria-label":lf(),onClick:()=>void A(),children:(0,J.jsx)(BS,{size:16,"aria-hidden":!0})}),(0,J.jsxs)(bw,{children:[(0,J.jsx)(yw,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__pillchev`,title:Uc(),"aria-label":Uc(),children:(0,J.jsx)(XS,{size:13,"aria-hidden":!0})})}),(0,J.jsxs)(vw,{align:`end`,className:`oc-talk__settings`,children:[(0,J.jsxs)(`label`,{className:`oc-talk__setting`,children:[(0,J.jsx)(`span`,{className:`oc-talk__settinglabel`,children:In()}),(0,J.jsxs)(aw,{value:o===``?`__default__`:o,onValueChange:e=>{let t=e===`__default__`?``:e;s(t),k0(t)},children:[(0,J.jsx)(nw,{size:`sm`,"aria-label":In(),children:(0,J.jsx)(tw,{})}),(0,J.jsxs)(rw,{children:[(0,J.jsx)(iw,{value:`__default__`,children:Vl()}),y0.map(e=>(0,J.jsx)(iw,{value:e,children:e},e))]})]})]}),(0,J.jsxs)(`label`,{className:`oc-talk__setting`,children:[(0,J.jsx)(`span`,{className:`oc-talk__settinglabel`,children:or()}),(0,J.jsxs)(aw,{value:c===``?`__default__`:c,onValueChange:e=>{let t=e===`__default__`?``:e;l(t),E0(t)},children:[(0,J.jsx)(nw,{size:`sm`,"aria-label":or(),children:(0,J.jsx)(tw,{})}),(0,J.jsxs)(rw,{children:[(0,J.jsx)(iw,{value:`__default__`,children:hl()}),S0.map(e=>(0,J.jsx)(iw,{value:e.id,children:e.id===`low`?Ae():e.id===`medium`?tte():Os()},e.id))]})]})]})]})]})]}):(0,J.jsxs)(`span`,{className:`oc-talk${M===`live`?` oc-talk--live`:``}`,role:`status`,children:[(0,J.jsx)(`i`,{className:`oc-talk__dot`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-talk__label`,children:M===`live`?i.voice||__():Lv()}),M===`live`?(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__btn`,title:i.muted?Gp():ky(),"aria-label":i.muted?Gp():ky(),"aria-pressed":i.muted,onClick:j,children:i.muted?(0,J.jsx)(qA,{size:14,"aria-hidden":!0}):(0,J.jsx)(zS,{size:14,"aria-hidden":!0})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-talk__btn oc-talk__btn--end`,title:mh(),"aria-label":mh(),onClick:T,children:(0,J.jsx)(tj,{size:14,"aria-hidden":!0})})]})]})}function L0(e,t){if(!e)return null;let n=e.logoLightHasAlpha&&e.logoLightUrl||e.logoDarkHasAlpha&&e.logoDarkUrl||null;if(n)return{url:n,masked:!0};let r=R0(e,t);return r?{url:r,masked:!1}:null}function R0(e,t){return(t===`dark`?e?.logoDarkUrl:e?.logoLightUrl)??(t===`dark`?e?.logoLightUrl:e?.logoDarkUrl)??null}function z0(e){if(!e)return null;let t=/oklch\(\s*([0-9]*\.?[0-9]+)(%?)/i.exec(e);if(!t)return null;let n=parseFloat(t[1]);return Number.isFinite(n)?t[2]===`%`?n/100:n:null}function B0(e,t,n){let r=z0(e),i=z0(t);return r===null||i===null?n:i>r?`dark`:`light`}function V0(e){let t=e.trim().split(/\s+/).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function H0({className:e}){return(0,J.jsxs)(`svg`,{className:e,viewBox:`0 0 64 64`,fill:`none`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{d:`M25 15H15V49H25`,stroke:`currentColor`,strokeWidth:`6.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,J.jsx)(`path`,{d:`M39 15H49V49H39`,stroke:`currentColor`,strokeWidth:`6.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,J.jsx)(`polyline`,{points:`20 33 26 33 29 25 33 41 37 29 41 33 44 33`,stroke:`currentColor`,strokeWidth:`3.4`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}var U0=(0,q.createContext)({label:`Atrium`,logoUrl:null,logoMasked:!1,isDefault:!0,initials:`A`,agentName:null,agentEmoji:null});function W0(){return(0,q.useContext)(U0)}function G0(e){return e.agentName??e.label}function K0(e){return e.agentName?R({name:e.agentName}):xh({name:e.label})}var q0=[`viewer`,`member`,`manager`];function J0(e){return e===`owner`||e===`manager`}function Y0(e,t,n){return e===`owner`?[...q0]:e!==`manager`||n||t===`manager`?[]:q0.filter(e=>e!==`manager`)}function X0(e,t,n){return n?!1:e===`owner`||e===`manager`&&t!==`manager`}function Z0(e,t){return t.roomRole!==`owner`&&X0(e,t.roomRole,t.isSelf)}function Q0(e){return e===`owner`?[...q0]:e===`manager`?[`viewer`,`member`]:[]}function $0(e,t){return Q0(t).includes(e)?e:`member`}function e2(e,t){return e===null||t===null?e===t:e.instanceName===t.instanceName&&e.agentId===t.agentId}function t2(e){return e.routedInstanceName&&e.routedAgentId?{instanceName:e.routedInstanceName,agentId:e.routedAgentId}:null}function n2(e){let t=new Map,n=null;for(let r of e){let e=t2(r);r.role===`user`?(n=e,t.set(r._id,e)):r.role===`assistant`?t.set(r._id,e??n):t.set(r._id,e)}return t}function r2(e){for(let t=e.length-1;t>=0;t--){let n=t2(e[t]);if(n)return n}return null}function i2(e,t){if(!t)return!1;let n=e.find(e=>e2(e,t));return n!==void 0&&n.state!==`deleted`}function a2(e){let{lastRouted:t,primary:n,pool:r}=e,i=e=>({instanceName:e.instanceName,agentId:e.agentId});if(i2(r,t))return i(t);if(i2(r,n))return i(n);let a=r.filter(e=>e.state!==`deleted`);return a.length===0?null:i(a.find(e=>e.isDefault)??a[0])}function o2(e){let{selected:t,lastRouted:n,primary:r,pool:i,poolLoading:a,messagesLoading:o,canRoute:s}=e;if(!s)return null;let c=t??n;return a||o?c??r:a2({lastRouted:c,primary:r,pool:i})}function s2(e){let{readOnly:t,multiAgent:n,poolSize:r}=e,i=r===0||!n;return e.callActive===!0?{hidden:i,disabled:!0,reason:`call-active`,onCall:e.onCall??null}:t?{hidden:i,disabled:!0,reason:`read-only`}:{hidden:i,disabled:!1}}function c2(e,t){if(!t)return null;let n=e.find(e=>e2(e,t));return n?{displayName:n.displayName,emoji:n.emoji}:null}function l2(e){let{mentioned:t,primary:n,severalAgents:r,perTurnRouting:i,canRoute:a}=e;if(!a)return;let o=t[0];if(o!==void 0)return{instanceName:o.instanceName,agentId:o.agentId};if(!(n===null||!(r||i)))return{instanceName:n.instanceName,agentId:n.agentId}}function u2(e){let t=new Map,n=null;for(let r of e){if(r.role===`user`){n=r.importedAgentLabel??null,t.set(r._id,n??r.chatImportedAgentLabel??null);continue}t.set(r._id,r.importedAgentLabel??n??r.chatImportedAgentLabel??null)}return t}function d2(e,t,n){let r=e.find(e=>e2(e,t))??null,i=n.map(t=>e.find(e=>e2(e,t))??null).filter(e=>e!==null&&!e2(e,t)),a=e=>e2(e,t)||i.some(t=>e2(t,e)),o=new Intl.Collator(void 0,{numeric:!0,sensitivity:`base`}),s=e=>e.displayName??e.agentId,c=e.filter(e=>!a(e)).sort((e,t)=>o.compare(s(e),s(t))||o.compare(e.instanceName,t.instanceName));return i.length===0?{room:[],others:r?[r,...c]:c}:{room:r?[r,...i]:i,others:c}}function f2(e){let t=e=>(e.displayName??e.agentId).trim().toLocaleLowerCase(),n=new Map;for(let r of e){let e=n.get(t(r))??new Set;e.add(`${r.instanceName}\u0000${r.agentId}`),n.set(t(r),e)}let r=new Set;for(let e of n.values())if(e.size>1)for(let t of e)r.add(t);return r}function p2(e,t,n,r){return!J0(e)||e2(t,n)?!1:r.some(e=>e2(e,t))}function m2(e,t){let n=[];for(let r of t)r===null||e.some(e=>e2(e,r))||n.push({instanceName:r.instanceName,agentId:r.agentId,isDefault:r.role===`primary`,displayName:r.displayName,emoji:r.emoji,model:r.model,description:r.description,kind:r.kind,state:`deleted`});return n.length===0?e:[...e,...n]}function h2(e,t){return e.every(e=>e.isSelf)&&t.length<=1?null:{people:e,agents:t}}function g2(e,t){if(t===null)return[...e];let n=new Set(t.filter(e=>e!==null).map(e=>`${e.instanceName}\u0000${e.agentId}`));return e.filter(e=>n.has(`${e.instanceName}\u0000${e.agentId}`))}function _2(e){return e.unfolded||e.searching||e.hereCount===0}var v2=e=>`${e.instanceName}\u0000${e.agentId}`;function y2(e,t,n){let r=new Set(e.map(v2)),i=n.trim().toLocaleLowerCase();return t.filter(e=>!r.has(v2(e))).filter(e=>i===``||[e.displayName,e.agentId,e.instanceName].filter(e=>!!e).some(e=>e.toLocaleLowerCase().includes(i)))}var b2={user:Un(),assistant:`OpenClaw`,system:Yl()},x2=Xc();function S2(e){return new Date(e).toISOString().slice(0,16).replace(`T`,` `)+` UTC`}function C2(e){return e?e.filter(e=>e.kind===`file`||e.kind===`media`).map(e=>e.filename).filter(e=>typeof e==`string`&&e.length>0):[]}function w2(e,t={}){let n=[];n.push(`# ${t.title?.trim()||pr()}`),t.exportedAt!=null&&(n.push(``),n.push(`_${Cl({date:S2(t.exportedAt)})}_`)),t.truncated&&(n.push(``),n.push(x2));for(let t of e){n.push(``),n.push(`## ${b2[t.role]} · ${S2(t.createdAt)}`);for(let e of t.quotedExcerpts??[])e!==``&&(n.push(``),n.push(`> ${p_()} : ${e}`));let e=t.text.trim();e.length>0&&(n.push(``),n.push(e));for(let e of C2(t.parts))n.push(``),n.push(Ie({name:e}))}return n.join(`
140
+ `)+`
141
+ `}function T2(e,t={}){let n={title:t.title?.trim()||pr(),exportedAt:t.exportedAt??null,truncated:!!t.truncated,messageCount:e.length,messages:e.map(e=>({role:e.role,createdAt:e.createdAt,text:e.text,...e.quotedExcerpts!==void 0&&e.quotedExcerpts.length>0?{quotedExcerpts:e.quotedExcerpts.filter(e=>e!==``)}:{},attachments:C2(e.parts)}))};return JSON.stringify(n,null,2)+`
142
+ `}function E2(e){return((e??``).trim()||`conversation`).toLowerCase().normalize(`NFD`).replace(/[̀-ͯ]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`conversation`}var D2=null,O2=new Set,k2=null,A2=4e3;function j2(){for(let e of O2)e()}function M2(e,t){D2={chatId:e,expand:t?.expand===!0},k2!==null&&clearTimeout(k2),k2=setTimeout(()=>{k2=null,D2=null,j2()},A2),j2()}function N2(e){D2?.chatId===e&&(k2!==null&&(clearTimeout(k2),k2=null),D2=null,j2())}function P2(){return(0,q.useSyncExternalStore)(e=>(O2.add(e),()=>{O2.delete(e)}),()=>D2)}function F2(e){let t=-1,n=-1/0,r=-1/0;for(let i=0;i<e.length;i++){let a=e[i]?.stamp,o=a??r;o>=n&&(t=i,n=o),a!==void 0&&a>r&&(r=a)}return t}function I2(e){let t=e[F2(e)];return t===void 0||t.steps.length===0?null:t}var L2=[];function R2({status:e,settled:t}){return e===`completed`?(0,J.jsx)(YS,{size:13,className:`oc-planact__icon oc-planact__icon--done`,"aria-hidden":!0}):e===`in_progress`&&!t?(0,J.jsx)(kC,{size:13,className:`oc-planact__icon oc-planact__icon--current oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(nC,{size:13,className:`oc-planact__icon`,"aria-hidden":!0})}function z2(){let e=$(e=>e.metadata?.custom?.planParts??L2),t=$(e=>e.metadata?.custom?.status!==`streaming`),[n,r]=(0,q.useState)(null),i=I2(e);if(i===null)return null;let a=i.steps.length,o=i.steps.filter(e=>e.status===`completed`).length,s=n??o!==a,c=i.steps.find(e=>e.status===`in_progress`);return(0,J.jsxs)(`div`,{className:`oc-planact`,children:[(0,J.jsx)(xK,{icon:(0,J.jsx)(VA,{size:14}),label:i.estimated?`${b_({done:o,total:a})} \u00b7 ${Hd()}`:b_({done:o,total:a}),sublabel:!s&&c!==void 0?c.step:void 0,trailing:(0,J.jsx)(`span`,{className:`oc-planact__bar`,role:`progressbar`,"aria-valuemin":0,"aria-valuemax":a,"aria-valuenow":o,children:(0,J.jsx)(`span`,{className:`oc-planact__bar-fill`,style:{width:`${a>0?o/a*100:0}%`}})}),open:s,ariaExpanded:s,title:s?gv():Ym(),onClick:()=>r(!s)}),s?(0,J.jsx)(`ol`,{className:`oc-planact__steps`,children:i.steps.map((e,n)=>(0,J.jsxs)(`li`,{className:`oc-planact__step oc-planact__step--${e.status}`,children:[(0,J.jsx)(R2,{status:e.status,settled:t}),(0,J.jsx)(`span`,{className:`oc-planact__step-text`,children:e.step})]},n))}):null,s&&i.explanation!==void 0?(0,J.jsx)(`div`,{className:`oc-planact__note`,children:i.explanation}):null]})}function B2(e){let t=e.split(/[\s._-]+/).map(e=>e.trim()).filter(e=>e.length>0);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function V2(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)>>>0;return t%8}function H2({userId:e,name:t,showTitle:n=!0}){return(0,J.jsx)(`span`,{className:`oc-avatar`,"data-tone":V2(e),title:n?t:void 0,"aria-hidden":!0,children:B2(t)})}function U2({kind:e,size:t=16,className:n}){let r=e===`hermes`?`Hermes`:`OpenClaw`;return e===`hermes`?(0,J.jsx)(xA,{size:t,className:n,"aria-label":r,role:`img`}):(0,J.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:n,role:`img`,"aria-label":r,children:[(0,J.jsx)(`path`,{d:`M4 20l3-3`}),(0,J.jsx)(`path`,{d:`M7 17a4 4 0 0 1 0-6l1-1`}),(0,J.jsx)(`path`,{d:`M8 10c1-4 5-6.5 11-6-2.5 3-5 4.5-8 5.5`}),(0,J.jsx)(`path`,{d:`M11 12.5c3 0 6 1 8.5 3.5-3 1-6 .5-8.5-1.5`}),(0,J.jsx)(`path`,{d:`M7 17a4 4 0 0 0 5.5-1.5`})]})}var W2=2.4;function G2(e,t,n=W2,r=56){return t===null||!Number.isFinite(t)?e.map(()=>1):e.map(e=>{let i=Math.abs(e-t);return i>=r?1:1+(n-1)*Math.cos(i/r*(Math.PI/2))})}function K2(e){let t=-1,n=1;return e.forEach((e,r)=>{e>n&&(t=r,n=e)}),t===-1?null:t}function q2(e,t,n){return e.map((r,i)=>{let a=0;return e.forEach((e,o)=>{if(o===i)return;let s=((t[o]??1)-1)*n;a+=s/2*(r>e?1:r<e?-1:0)}),a})}var J2=e=>e===`owner`?Kl():e===`manager`?qc():e===`member`?ur():bl(),Y2=e=>{let t=J2(e);return t.charAt(0).toUpperCase()+t.slice(1)},X2=e=>e===`manager`?Ne():e===`member`?rte():Ns();function Z2({agent:e}){return(0,J.jsx)(`span`,{className:`oc-convpanel__face`,"aria-hidden":!0,children:e.emoji?e.emoji:(0,J.jsx)(kS,{size:14})})}var Q2=e=>e.displayName??e.agentId;function $2(e,t){let n=e.trim().toLowerCase();return n===``||t.some(e=>(e??``).toLowerCase().includes(n))}function e4({open:e,onOpenChange:t,title:n,description:r,items:i,keyOf:a,searchFields:o,render:s,actionLabel:c,onPick:l,closeOnPick:u=!1,empty:d,header:f}){let[p,m]=(0,q.useState)(``),[h,g]=(0,q.useState)(new Set),[_,v]=(0,q.useState)(null),y=(0,q.useRef)(null);(0,q.useEffect)(()=>{e||(m(``),g(new Set))},[e]);let b=(i??[]).filter(e=>$2(p,o(e)));return(0,J.jsx)($w,{open:e,onOpenChange:t,children:(0,J.jsxs)(Xw,{className:`oc-convpicker`,onOpenAutoFocus:e=>{e.preventDefault(),y.current?.focus()},children:[(0,J.jsxs)(Jw,{children:[(0,J.jsx)(Zw,{children:n}),(0,J.jsx)(Qw,{children:r})]}),(0,J.jsx)(xw,{ref:y,value:p,onChange:e=>m(e.target.value),placeholder:na(),"aria-label":na()}),f,(0,J.jsx)(`ul`,{className:`oc-convpicker__list`,children:i===void 0?(0,J.jsx)(`li`,{className:`oc-convpicker__empty`,children:tt()}):b.length===0?(0,J.jsx)(`li`,{className:`oc-convpicker__empty`,children:d}):b.map(e=>{let n=a(e),r=h.has(n);return(0,J.jsxs)(`li`,{className:`oc-convpicker__row`,children:[s(e),(0,J.jsxs)(K,{variant:r?`ghost`:`outline`,size:`sm`,disabled:r||_!==null,onClick:()=>{v(n),l(e).then(()=>{g(e=>new Set(e).add(n)),u&&t(!1)}).catch(()=>{}).finally(()=>v(null))},children:[r?(0,J.jsx)(YS,{size:14,"aria-hidden":!0}):null,r?Zv():c]})]},n)})})]})})}var t4=6;function n4({chatId:e,onOpen:t}){let n=U(G.chatParticipants.listMembers,{chatId:e}),r=U(G.chatAgents.listChatAgents,{chatId:e}),i=(0,q.useRef)([]),a=(0,q.useRef)([]),o=(0,q.useRef)(20),[s,c]=(0,q.useState)(null),l=(0,q.useRef)(0),u=h2(n??[],r?[r.primary,...r.agents].filter(e=>e!==null):[]);if(u===null)return null;let{people:d,agents:f}=u,p=[...d.map(e=>({kind:`person`,key:`p/${String(e.userId)}`,name:e.isSelf?`${e.name} (${vt()})`:e.name,userId:String(e.userId),role:J2(e.roomRole),self:e.isSelf})),...f.map(e=>({kind:`agent`,key:`a/${e.instanceName}/${e.agentId}`,name:e.displayName??e.agentId,gateway:e.kind,primary:e.role===`primary`}))],m=p.slice(0,t4),h=p.slice(t4),g=typeof window<`u`&&window.matchMedia?.(`(prefers-reduced-motion: reduce)`).matches===!0?m.map(()=>1):G2(a.current.slice(0,m.length),s),_=K2(g),v=q2(a.current.slice(0,m.length),g,o.current);return(0,J.jsxs)(`button`,{type:`button`,className:`oc-presence`,onClick:t,onMouseEnter:e=>{let t=e.currentTarget.getBoundingClientRect();l.current=t.left,a.current=i.current.slice(0,m.length).map(e=>{let n=e?.getBoundingClientRect();return n?n.left+n.width/2-t.left:NaN}),o.current=i.current[0]?.getBoundingClientRect().width||20,c(e.clientX-t.left)},onMouseMove:e=>c(e.clientX-l.current),onMouseLeave:()=>c(null),"aria-label":se({people:d.length,agents:f.length}),children:[m.map((e,t)=>e.kind===`person`?(0,J.jsx)(`span`,{ref:e=>{i.current[t]=e},className:`oc-presence__face${e.self?` is-self`:``}${_===t?` is-focus`:``}`,style:{"--dock-s":g[t]??1,"--dock-x":`${v[t]??0}px`},"data-name":`${e.name} · ${e.role}`,children:(0,J.jsx)(H2,{userId:e.userId,name:e.name,showTitle:!1})},e.key):(0,J.jsxs)(`span`,{ref:e=>{i.current[t]=e},className:`oc-presence__face oc-presence__agent${e.primary?` is-primary`:``}${_===t?` is-focus`:``}`,style:{"--dock-s":g[t]??1,"--dock-x":`${v[t]??0}px`},"data-name":e.name,children:[(0,J.jsx)(U2,{kind:e.gateway,size:12}),e.primary?(0,J.jsx)(vA,{size:8,className:`oc-presence__crown`,"aria-hidden":!0}):null]},e.key)),h.length>0?(0,J.jsxs)(`span`,{className:`oc-presence__more`,title:h.map(e=>e.name).join(`
143
+ `),children:[`+`,h.length]}):null]})}function r4({chatId:e,routing:t,open:n,onOpenChange:r,tab:i,onTabChange:a,intent:o,onIntentDone:s}){let c=U(G.chatAgents.listChatAgents,n?{chatId:e}:`skip`),l=U(G.chatParticipants.listMembers,n?{chatId:e}:`skip`),u=c?.viewerRoomRole,d=c?c.agents.length+ +!!c.primary:0;return(0,J.jsx)(_T,{open:n,onOpenChange:r,children:(0,J.jsxs)(yT,{side:`right`,className:`oc-spanel oc-convpanel`,children:[(0,J.jsxs)(vT,{children:[(0,J.jsx)(bT,{children:ir()}),(0,J.jsx)(gT,{children:u===void 0?``:J0(u)?pl():Oe({role:J2(u)})})]}),(0,J.jsx)(`div`,{className:`oc-spanel__body`,children:c===void 0?(0,J.jsx)(`p`,{className:`oc-spanel__loading`,children:fc()}):c===null?null:(0,J.jsxs)(_w,{value:i,onValueChange:e=>a(e),children:[(0,J.jsxs)(gw,{className:`oc-convpanel__tabs`,children:[(0,J.jsxs)(mw,{value:`agents`,children:[(0,J.jsx)(kS,{size:14,"aria-hidden":!0}),` `,Fr(),(0,J.jsx)(`span`,{className:`oc-convpanel__count`,children:d})]}),(0,J.jsxs)(mw,{value:`people`,children:[(0,J.jsx)(WC,{size:14,"aria-hidden":!0}),` `,pn(),(0,J.jsx)(`span`,{className:`oc-convpanel__count`,children:l?.length??``})]})]}),(0,J.jsx)(hw,{value:`agents`,children:(0,J.jsx)(i4,{chatId:e,routing:t,room:c,intent:o,onIntentDone:s})}),(0,J.jsx)(hw,{value:`people`,children:(0,J.jsx)(a4,{chatId:e,viewer:c.viewerRoomRole,authMode:c.authMode,participantIdentity:c.participantIdentity,intent:o,onIntentDone:s,onLeft:()=>r(!1)})})]})})]})})}function i4({chatId:e,routing:t,room:n,intent:r,onIntentDone:i}){let a=Mw(),o=J0(n.viewerRoomRole),s=n.viewerRoomRole===`owner`,[c,l]=(0,q.useState)(!1),[u,d]=(0,q.useState)(!1),[f,p]=(0,q.useState)(!1);(0,q.useEffect)(()=>{r===`add-agent`?(l(!0),i()):r===`primary`&&(d(!0),i())},[r,i]);let m=U(G.chatAgents.listAddableAgents,c&&o?{chatId:e}:`skip`),h=W(G.chatAgents.addChatAgent),g=W(G.chatAgents.removeChatAgent),_=W(G.chats.rebindChatAgent),v=W(G.chatAgents.setPrimaryAgent),y=t=>void v({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).then(e=>{!e.changed&&e.reason===`busy`&&a.error(Ar()),!e.changed&&e.reason===`preparing`&&a.error(on())}).catch(e=>{let t=e instanceof Error?e.message:String(e);a.error(t.includes(`TALK_CALL_ACTIVE`)?Gv():LT(e)?Uf():Rt())}),b=U(G.messages.getSessionMeta,s?{chatId:e}:`skip`),x=b?.sessionMeta??null,S=b?.sessionSettings??null,C=t?.emptyThread===!0,w=(0,q.useMemo)(()=>(t?.pool??[]).filter(e=>e.state!==`deleted`&&!e2(e,n.primary)),[t?.pool,n.primary]),T=e=>{let t=e instanceof Error?e.message:String(e),n=/chat_agents_limit:(\d+)/.exec(t);throw a.error(n===null?LT(e)?Uf():Rt():Va({count:Number(n[1])})),e},E=(t,n)=>(0,J.jsxs)(`li`,{className:`oc-convpanel__member${t.gone?` is-gone`:``}`,children:[(0,J.jsx)(Z2,{agent:t}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsxs)(`span`,{className:`oc-convpanel__name`,children:[Q2(t),n?(0,J.jsx)(vA,{size:12,className:`oc-convpanel__crown`,"aria-label":Pv(),children:(0,J.jsx)(`title`,{children:Pv()})}):null,t.gone?(0,J.jsx)(`span`,{className:`oc-convpanel__badge is-warn`,children:Zh()}):t.usable?null:(0,J.jsx)(`span`,{className:`oc-convpanel__badge is-muted`,children:fo()})]}),(0,J.jsxs)(`span`,{className:`oc-convpanel__sub`,children:[(0,J.jsx)(BC,{size:10,"aria-hidden":!0}),` `,t.instanceName,t.model?` · ${t.model}`:``]})]}),!n&&o?(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":vg(),children:(0,J.jsx)(yA,{})})}),(0,J.jsxs)(fC,{align:`end`,children:[s&&t.usable&&!t.gone?(0,J.jsxs)(hC,{onSelect:()=>y(t),children:[(0,J.jsx)(vA,{"aria-hidden":!0}),Es()]}):null,(0,J.jsx)(hC,{variant:`destructive`,onSelect:()=>void g({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(()=>a.error(Rt())),children:Oh()})]})]}):null]},`${t.instanceName}/${t.agentId}`);return(0,J.jsxs)(`div`,{className:`oc-convpanel__tab`,children:[(0,J.jsxs)(`ul`,{className:`oc-convpanel__members`,children:[n.primary?E(n.primary,!0):null,n.agents.map(e=>E(e,!1))]}),s&&n.primary?C?w.length>0?(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-convpanel__link`,onClick:()=>d(!0),children:Dx()}):null:(0,J.jsx)(`p`,{className:`oc-convpanel__hint`,children:Zi()}):null,s&&b?(0,J.jsxs)(`div`,{className:`oc-convpanel__settings`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-convpanel__disclosure`,"aria-expanded":f,onClick:()=>p(e=>!e),children:[f?(0,J.jsx)(XS,{size:14,"aria-hidden":!0}):(0,J.jsx)(QS,{size:14,"aria-hidden":!0}),Bn()]}),f?(0,J.jsx)(`div`,{className:`oc-convpanel__knobs`,children:(0,J.jsx)(jT,{chatId:e,sm:x,settings:S})}):null]}):null,o?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,className:`oc-convpanel__add`,disabled:n.agents.length>=n.limit,onClick:()=>l(!0),children:[(0,J.jsx)(RC,{size:14,"aria-hidden":!0}),va(),(0,J.jsxs)(`span`,{className:`oc-convpanel__count`,children:[n.agents.length,`/`,n.limit]})]}):null,(0,J.jsx)(`p`,{className:`oc-convpanel__hint`,children:tf()}),(0,J.jsx)(e4,{open:c,onOpenChange:l,title:va(),description:_ee(),items:o?m:[],keyOf:e=>`${e.instanceName}/${e.agentId}`,searchFields:e=>[e.displayName,e.agentId,e.instanceName,e.description],render:e=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z2,{agent:e}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsx)(`span`,{className:`oc-convpanel__name`,children:Q2(e)}),(0,J.jsxs)(`span`,{className:`oc-convpanel__sub`,children:[(0,J.jsx)(BC,{size:10,"aria-hidden":!0}),` `,e.instanceName,e.description?` · ${e.description}`:``]})]})]}),actionLabel:Kf(),onPick:t=>h({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(T),empty:re()}),(0,J.jsx)(e4,{open:u,onOpenChange:d,title:Dx(),description:Mi(),items:w,keyOf:e=>`${e.instanceName}/${e.agentId}`,searchFields:e=>[e.displayName,e.agentId,e.instanceName],render:e=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Z2,{agent:e}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsx)(`span`,{className:`oc-convpanel__name`,children:Q2(e)}),(0,J.jsxs)(`span`,{className:`oc-convpanel__sub`,children:[(0,J.jsx)(BC,{size:10,"aria-hidden":!0}),` `,e.instanceName]})]})]}),actionLabel:sh(),closeOnPick:!0,onPick:t=>_({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(e=>{throw a.error(LT(e)?Uf():Jd()),e}),empty:re()})]})}function a4({chatId:e,viewer:t,authMode:n,participantIdentity:r,intent:i,onIntentDone:a,onLeft:o}){let s=Mw(),c=J0(t),[l,u]=(0,q.useState)(!1),[d,f]=(0,q.useState)(`member`),p=$0(d,t);(0,q.useEffect)(()=>{f(`member`)},[e]),(0,q.useEffect)(()=>{i===`invite`&&(u(!0),a())},[i,a]);let m=U(G.chatParticipants.listMembers,{chatId:e}),h=U(G.chatParticipants.listInvitable,l&&c?{chatId:e}:`skip`),g=W(G.chatParticipants.addMember),_=W(G.chatParticipants.removeMember),v=W(G.chatParticipants.setMemberRole),y=W(G.chatParticipants.leaveChat),b=e=>{let t=e instanceof Error?e.message:String(e),n=/participants_limit:(\d+)/.exec(t);throw s.error(n===null?h_():Fv({count:Number(n[1])})),e};return(0,J.jsxs)(`div`,{className:`oc-convpanel__tab`,children:[(0,J.jsx)(`ul`,{className:`oc-convpanel__members`,children:(m??[]).map(n=>{let r=n.roomRole===`owner`?null:n.roomRole,i=r===null?[]:Y0(t,r,n.isSelf),a=Z0(t,n);return(0,J.jsxs)(`li`,{className:`oc-convpanel__member`,children:[(0,J.jsx)(H2,{userId:String(n.userId),name:n.name}),(0,J.jsxs)(`span`,{className:`oc-convpanel__who`,children:[(0,J.jsxs)(`span`,{className:`oc-convpanel__name`,children:[n.name,n.isSelf?(0,J.jsx)(`span`,{className:`oc-convpanel__you`,children:vt()}):null]}),i.length===0?(0,J.jsx)(`span`,{className:`oc-convpanel__sub`,children:Y2(n.roomRole)}):null]}),r!==null&&i.length>0?(0,J.jsxs)(aw,{value:r,onValueChange:t=>void v({chatId:e,memberId:n.userId,role:t}).catch(()=>s.error(h_())),children:[(0,J.jsx)(nw,{size:`sm`,className:`oc-convpanel__role`,children:(0,J.jsx)(tw,{})}),(0,J.jsx)(rw,{align:`end`,children:i.map(e=>(0,J.jsx)(iw,{value:e,children:Y2(e)},e))})]}):null,a?(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":vg(),children:(0,J.jsx)(yA,{})})}),(0,J.jsx)(fC,{align:`end`,children:(0,J.jsx)(hC,{variant:`destructive`,onSelect:()=>void _({chatId:e,memberId:n.userId}).catch(()=>s.error(h_())),children:xc()})})]}):null]},String(n.userId))})}),c?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,className:`oc-convpanel__add`,onClick:()=>u(!0),children:[(0,J.jsx)(HC,{size:14,"aria-hidden":!0}),Ov()]}):null,(0,J.jsxs)(`div`,{className:`oc-convpanel__callout`,children:[(0,J.jsx)(VC,{size:14,"aria-hidden":!0}),(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`p`,{className:`oc-convpanel__callout-title`,children:n===`mixed`?hd():n===`trusted-proxy`?ai():ss()}),(0,J.jsx)(`p`,{children:n===`mixed`?vu():n===`trusted-proxy`?r===`self`?Ky():sv():Wu()}),(0,J.jsx)(`dl`,{className:`oc-convpanel__roles`,children:[`viewer`,`member`,`manager`].map(e=>(0,J.jsxs)(`div`,{children:[(0,J.jsx)(`dt`,{children:Y2(e)}),(0,J.jsx)(`dd`,{children:X2(e)})]},e))})]})]}),t===`owner`?null:(0,J.jsxs)(K,{variant:`ghost`,size:`sm`,className:`oc-convpanel__leave`,onClick:()=>void y({chatId:e}).then(o).catch(()=>s.error(h_())),children:[(0,J.jsx)(UA,{size:14,"aria-hidden":!0}),Rb()]}),(0,J.jsx)(e4,{open:l,onOpenChange:u,title:Ov(),description:Ip(),items:c?h:[],keyOf:e=>String(e.userId),searchFields:e=>[e.name],header:(0,J.jsxs)(`label`,{className:`oc-convpicker__role`,children:[(0,J.jsx)(`span`,{children:by()}),(0,J.jsxs)(aw,{value:p,onValueChange:e=>f(e),children:[(0,J.jsx)(nw,{size:`sm`,className:`w-40`,children:(0,J.jsx)(tw,{})}),(0,J.jsx)(rw,{children:Q0(t).map(e=>(0,J.jsx)(iw,{value:e,children:Y2(e)},e))})]})]}),render:e=>(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(H2,{userId:String(e.userId),name:e.name}),(0,J.jsx)(`span`,{className:`oc-convpanel__who`,children:(0,J.jsx)(`span`,{className:`oc-convpanel__name`,children:e.name})})]}),actionLabel:s_(),onPick:t=>g({chatId:e,memberId:t.userId,role:p}).catch(b),empty:ec()})]})}function o4(e){let t=e.trim().replace(/\s+/g,`.`);return`@${t.length>0?t:`?`}`}var s4=/[\p{L}\p{N}_\-]/u;function c4(e,t,n=[],r=0){if(t.length===0)return null;for(let i=e.indexOf(t,r);i!==-1;i=e.indexOf(t,i+1)){let r=i+t.length,a=i>0?e[i-1]:``;if(a!==``&&(s4.test(a)||a===`@`))continue;let o=e[r]??``;if(!s4.test(o)&&!((o===`.`||o===`'`)&&s4.test(e[r+1]??``))&&!n.some(e=>i<e.end&&r>e.start))return{start:i,end:r}}return null}var l4=e=>`agent`in e;function u4(e){return l4(e)?`agent\u0000${e.agent.instanceName}\u0000${e.agent.agentId}`:`user\u0000${e.userId}`}var d4=[],f4=new Map,p4=new Set;function m4(){for(let e of p4)e()}function h4(e){return p4.add(e),()=>p4.delete(e)}function g4(e){return f4.get(e)??d4}function _4(e,t){let n=f4.get(e)??[],r=n.findIndex(e=>u4(e)===u4(t));r!==-1&&n[r].token===t.token||(f4.set(e,r===-1?[...n,t]:n.map((e,n)=>n===r?t:e)),m4())}function v4(e){let t=f4.get(e)??d4;return t.length>0&&(f4.delete(e),m4()),t}function y4(e,t){if(t.length===0)return;let n=f4.get(e)??[],r=new Set(n.map(u4)),i=[...n];for(let e of t)r.has(u4(e))||i.push(e);f4.set(e,i),m4()}function b4(e,t){let n=[],r=[],i=[];for(let a of t){let t=c4(e,a.token,i);t!==null&&(l4(a)?r.push({...a.agent,start:t.start,end:t.end}):n.push({userId:a.userId,start:t.start,end:t.end}),i.push(t))}return{people:n.sort((e,t)=>e.start-t.start),agents:r.sort((e,t)=>e.start-t.start)}}function x4(e,t){let n=v4(e),{people:r,agents:i}=b4(t,n);return{staged:n,mentions:r,agentMentions:i}}function S4(e){return e.filter(l4).map(e=>({...e.agent}))}function C4(e,t,n,r){return T4(e,t,{userId:n,token:r})}function w4(e,t,n,r){return T4(e,t,{agent:{instanceName:n.instanceName,agentId:n.agentId},token:r})}function T4(e,t,n){let r=u4(n),i=n.token,a=g4(e),o=a.find(e=>u4(e)===r);if(o!==void 0&&c4(t,o.token)!==null)return null;let s=new Set(a.filter(e=>u4(e)!==r).map(e=>e.token)),c=i;for(let e=2;s.has(c);e+=1)c=`${i}-${e}`;return _4(e,{...n,token:c}),`${t}${t.length===0||t.endsWith(` `)?``:` `}${c} `}function E4(e){return e.kind===`tool`}function D4(e){return e.kind===`media`}function O4(e){return e.kind===`file`}function k4(e){return e.kind===`reasoning`}function A4(e){return e.kind===`plan`}function j4(e){return e.kind===`cron`}function M4(e){return e.kind===`widget`}function N4(e){return e.kind===`compaction`}function P4(e){let t=[],n=/^ {0,3}(`{3,}|~{3,})(.*)$/gm,r=-1,i=``,a=0;for(let o=n.exec(e);o!==null;o=n.exec(e)){let e=o[1][0];r===-1?(r=o.index,i=e,a=o[1].length):e===i&&o[1].length>=a&&/^[ \t]*$/.test(o[2])&&(t.push([r,o.index+o[1].length]),r=-1)}return r!==-1&&t.push([r,e.length]),t}function F4(e,t){let n=Math.max(0,t);if(n===0)return 0;if(n>=e.length)return n;for(let[t,r]of P4(e))if(n>t&&n<r)return t;return n}function I4(e,t,n){if((n?.settled??!0)||(t=t.filter(t=>t.offset<=e.length)),t.length===0)return e.length>0?[{kind:`text`,text:e}]:[];let r=[],i=0;for(let n of t){let t=Math.max(i,F4(e,n.offset));if(i=t,n.note!==void 0){r.push({cut:t,note:n.note});continue}let a=r[r.length-1];a!==void 0&&a.parts!==void 0&&a.cut===t?a.parts.push(n.activity):r.push({cut:t,parts:[n.activity]})}let a=[];for(let t of r){let n=a[a.length-1];n!==void 0&&n.parts!==void 0&&t.parts!==void 0&&e.slice(Math.min(n.cut,e.length),Math.min(t.cut,e.length)).trim()===``?n.parts.push(...t.parts):a.push(t)}let o=[],s=0;for(let t of a){let n=Math.min(t.cut,e.length),r=e.slice(s,n);r.trim()!==``&&o.push({kind:`text`,text:r}),t.note===void 0?o.push({kind:`activity`,parts:t.parts,cut:t.cut}):o.push({kind:`note`,key:t.note.key,text:t.note.text,cut:t.cut}),s=Math.max(s,n)}let c=e.slice(s);return c.trim()!==``&&o.push({kind:`text`,text:c}),o}var L4=[`read`,`exec`,`search`,`fetch`,`write`,`other`],R4={read:{one:()=>Rh(),many:e=>Qa({count:String(e)})},exec:{one:()=>ot(),many:e=>Et({count:String(e)})},search:{one:()=>ac(),many:e=>xb({count:String(e)})},fetch:{one:()=>ze(),many:e=>Ls({count:String(e)})},write:{one:()=>Wb(),many:e=>ff({count:String(e)})},other:{one:e=>hx({tool:e}),many:e=>$y({count:String(e)})}};function z4(e){return e===`started`||e===`running`||e===`start`}function B4(e){let t=new Map;for(let n of e){let e=iQ(n.toolName);t.set(e,(t.get(e)??0)+1)}let n=`other`,r=-1;for(let e of L4){let i=t.get(e)??0;i>r&&(n=e,r=i)}return n}function V4(e,t){let n=t?.live===!1?void 0:[...e].reverse().find(e=>z4(e.phase));if(n!==void 0)switch(iQ(n.toolName)){case`read`:return Cx();case`exec`:return ms();case`search`:return zi();case`fetch`:return vr();case`write`:return Jt();default:return yo({tool:n.toolName})}let r=new Map;for(let t of e){let e=iQ(t.toolName),n=r.get(e)??[];n.push(t),r.set(e,n)}let i=[];for(let e of L4){let t=r.get(e);t!==void 0&&i.push(t.length===1?R4[e].one(t[0].toolName):R4[e].many(t.length))}let a=i.length===1?i[0]:i.slice(0,-1).join(gh())+N()+i[i.length-1],o=oa()+a;return o.charAt(0).toUpperCase()+o.slice(1)}var H4=/---[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}(?=\.[^.]+$|$)/i;function U4(e){return e.replace(H4,``)}var W4={disable:{null:[`htmlFlow`,`htmlText`]}};function G4(e){if(!e)return[];let t=zw(e,{extensions:[W4,Vw()],mdastExtensions:[Fw()]}),n=[];for(let e of t.children??[]){let t=[e];for(;t.length>0;){let e=t.pop(),r=e.position?.start?.offset,i=e.position?.end?.offset;(e.type===`code`||e.type===`inlineCode`)&&r!==void 0&&i!==void 0&&n.push({start:r,end:i,block:e.type===`code`});for(let n of[...e.children??[]].reverse())t.push(n)}}return n.sort((e,t)=>e.start-t.start),n}function K4(e){return/[`~\t]| {4}/u.test(e)?G4(e):[]}function q4(e,t){return t.some(t=>e>=t.start&&e<t.end)}var J4=`/__openclaw__/canvas/documents/`,Y4=/^cv_[A-Za-z0-9._-]{1,253}$/;function X4(e){let t={},n=/([A-Za-z_][A-Za-z0-9_-]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g,r;for(;r=n.exec(e);){let e=r[1]?.trim().toLowerCase(),n=(r[2]??r[3]??``).trim();e&&n&&(t[e]=n)}return t}function Z4(e){if(e.target&&e.target!==`assistant_message`)return null;let t=e.ref?.trim();if(!t||!Y4.test(t))return null;let n=e.url?.trim()||`${J4}${encodeURIComponent(t)}/index.html`;try{let e=new URL(n,`http://localhost`);if(e.origin!==`http://localhost`||!e.pathname.startsWith(J4))return null;let[r,i]=e.pathname.slice(31).split(`/`,2);if(!r||!i)return null;let a=decodeURIComponent(r);return/^[A-Za-z0-9._-]+$/u.test(a)&&a===t?t:null}catch{return null}}function Q4(e){if(!e.trim()||!e.toLowerCase().includes(`[embed`))return[];let t=K4(e),n=[];for(let r of[/\[embed\s+([^\]]*?[^\]/]|)\]([\s\S]*?)\[\/embed\]/gi,/\[embed\s+([^\]]*?)\/\]/gi]){let i;for(;i=r.exec(e);){let e=i.index;q4(e,t)||n.push({start:e,end:e+i[0].length,viewId:Z4(X4(i[1]??``))})}}n.sort((e,t)=>e.start-t.start);let r=[],i=0;for(let e of n)e.start<i||(r.push(e),i=e.end);return r}function $4(e){let t=e.toLowerCase(),n=t=>q4(t,K4(e))?e:e.slice(0,t),r=e.lastIndexOf(`[`);if(r!==-1){let e=t.slice(r);if(e.length<6&&`[embed`.startsWith(e))return n(r)}let i=t.lastIndexOf(`[embed`);if(i===-1)return e;let a=e.slice(i);if(!/^\[embed(?:\s|$)/i.test(a))return e;let o=a.indexOf(`]`);return o===-1?n(i):a[o-1]===`/`||/\[\/embed\]/i.test(a)?e:n(i)}function e3(e,t,n){let r=e;if(t.size>0){let n=Q4(e).filter(e=>e.viewId!==null&&t.has(e.viewId));if(n.length>0){r=``;let t=0;for(let i of n)r+=e.slice(t,i.start),t=i.end;r+=e.slice(t)}}return n?$4(r):r}var t3=e=>e.kind===`media`||e.kind===`file`;function n3(e,t,n,r){let i=t?.find(e=>e.entryId===n&&e.blockIndex===r),a=i?.fileId===void 0?void 0:e.parts.filter(t3).find(e=>e.transcriptFileId===i.fileId),o=a?.filename??i?.label??`file`,s=a?.mimeType??i?.mimeType??`application/octet-stream`;if(i?.state===`remote`&&i.url!==void 0)return{kind:`file`,entryId:n,blockIndex:r,file:{kind:`remote`,url:i.url,filename:o,mimeType:s}};let c=a?.url??(i?.state===`copied`?i.url:void 0),l=a?.storageId??i?.storageId;return i?.state===`copied`&&c&&l!==void 0?{kind:`file`,entryId:n,blockIndex:r,file:{kind:`copied`,url:c,filename:o,mimeType:s,storageId:l}}:{kind:`file`,entryId:n,blockIndex:r,file:{kind:`unavailable`,state:i===void 0||i.state===`copied`||i.state===`remote`?`pending`:i.state,...i?.reason===void 0?{}:{reason:i.reason},filename:o,mimeType:s}}}function r3(e){let t=e.rowLayout;if(e.role!==`assistant`||t===void 0||t.length===0)return null;let n=new Set,r=new Set;for(let t of e.displayHidden??[])t.rule===`repeated_text_in_group`?n.add(t.entryId):`entryId`in t&&r.add(`${t.entryId}\u0000${t.blockIndex}`);let i=[],a=e.text??``,o=(t,n)=>{r.has(`${t}\u0000${n}`)||i.push(n3(e,e.rowFiles,t,n))};for(let e of t){e.thinking===!0&&i.push({kind:`thinking`,entryId:e.entryId});let t=e.commentary===!0?{commentary:!0}:{};if(e.items!==void 0){for(let r of e.items)if(r.kind===`file`)o(e.entryId,r.blockIndex);else if(!n.has(e.entryId)){let n=a.slice(r.start,r.end);n.trim()!==``&&i.push({kind:`text`,entryId:e.entryId,text:n,...r.capped===!0?{capped:!0}:{},...t})}}else{let r=a.slice(e.start,e.end);r.trim()!==``&&!n.has(e.entryId)&&i.push({kind:`text`,entryId:e.entryId,text:r,...t});for(let t of e.files??[])o(e.entryId,t.blockIndex)}let r=e.tools??[];if(r.length>0){let t=i[i.length-1],n=t?.kind===`tools`?t:{kind:`tools`,entryId:e.entryId,toolCallIds:[]};n!==t&&i.push(n);for(let e of r)n.toolCallIds.push(e.toolCallId),e.parentToolCallId!==void 0&&((n.parents??={})[e.toolCallId]=e.parentToolCallId)}}let s=t[t.length-1]?.cut,c=(s?.rows??0)+(s?.files??0)+(s?.tools??0)+(s?.widgets??0);return c>0&&i.push({kind:`cut`,count:c}),i}function i3(e){let t=e.rowLayout??[];return{cardsOfBlockRows:new Set(t.flatMap(e=>e.blocks===!0?(e.tools??[]).map(e=>e.toolCallId):[])),rowsWithoutBlocks:t.some(e=>e.blocks!==!0)}}function a3(e){return new Set((e.displayHidden??[]).flatMap(e=>e.rule===`same_sha256_in_group`&&`storageId`in e?[e.storageId]:[]))}function o3(e){return new Set((e.rowFiles??[]).flatMap(e=>e.fileId===void 0?[]:[e.fileId]))}var s3=RegExp(`^([a-z][a-z0-9_]*):((?:tool:[a-z][a-z0-9_]*:)?[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}):(ok|error)(?::agent-loop)?$`),c3=[`agent-loop`,`wake`];function l3(e){return typeof e==`string`&&e.startsWith(`announce:requester-settle:`)}var u3=/^[A-Za-z0-9_-]{1,128}$/,d3=32;function f3(e){if(!l3(e))return null;let t=e.split(`:`);/^retry-\d+$/.test(t[t.length-1]??``)&&t.pop();let n=null,r=/^yield-(\d+)$/.exec(t[t.length-1]??``);r!==null&&r[1]!==void 0&&(n=Number(r[1]),t.pop());let i=(t.pop()??``).split(`,`);return t.length<4||i.length===0||i.length>d3||!i.every(e=>u3.test(e))?null:{childRunIds:i,yieldGeneration:n}}function p3(e){if(l3(e))return null;if(e.startsWith(`announce:`)){let t=e.split(`:`),n=t[t.length-1];if(n!==void 0&&c3.includes(n)&&t.pop(),t.length<4)return null;let r=t.slice(2,-1).join(`:`);return r===``?null:r}let t=s3.exec(e);return t!==null&&t[2]!==void 0?`task:${t[2]}`:null}var m3={childRunIds:[],childKeys:[],lastUserAt:null};function h3(e,t=!1){let n=new Set,r=new Set,i=null;for(let t of e){if(t.role===`user`){let e=t.orderTime??t._creationTime;(i===null||e>i)&&(i=e);continue}if(t.role!==`assistant`||typeof t.runId!=`string`)continue;let e=f3(t.runId);if(e!==null){for(let t of e.childRunIds)n.add(t);continue}let a=p3(t.runId);a!==null&&r.add(a)}return n.size===0&&r.size===0&&i===null&&!t?m3:{childRunIds:[...n].sort(),childKeys:[...r].sort(),lastUserAt:i,...t?{projected:!0}:{}}}function g3(e,t){if(e.role!==`assistant`||e.rowLayout===void 0)return;let n=e.orderTime??e._creationTime;return{projected:!0,resumedChildRunIds:t.childRunIds,resumedChildKeys:t.childKeys,laterUserTurn:t.lastUserAt!==null&&t.lastUserAt>n}}function _3(e,t=e.length){for(let n=Math.min(t,e.length)-1;n>=0;--n)if(e[n].role===`user`)return n;return-1}function v3(e,t,n,r=e.length,i){let a=-1;for(let o=0;o<r;o+=1){let r=e[o],s=r.commentaryItemId!==void 0&&(i===void 0||i.has(r.commentaryItemId)),c=r.runId===n&&!s?r.text:null;if(r.role===`assistant`&&c&&(t.startsWith(c)||c.startsWith(t))){a=o;break}}let o=a>=0?a:_3(e,r)+1;return y3(e.slice(o,r).map(e=>{let t=e.commentaryItemId!==void 0&&(i===void 0||i.has(e.commentaryItemId));return{text:e.role===`assistant`&&(!e.runId||e.runId===n)&&!t?e.text:null,skipOnMismatch:e.commentaryItemId!==void 0}}),t)}function y3(e,t){let n=0;for(let{text:r,skipOnMismatch:i}of e){if(!r)continue;let e=t.slice(n);if(e.startsWith(r)){n+=r.length;continue}if(r.startsWith(e))return null;let a=n>0?/^\s+/u.exec(e)?.[0]:void 0;if(a&&e.slice(a.length).startsWith(r)){n+=a.length+r.length;continue}if(a&&r.startsWith(e.slice(a.length)))return null;if(!i&&n>0)break}return t.slice(n)}function b3(e,t,n){return v3(e,t,n,e.length,new Set)}function x3(e){return e.file.kind===`copied`?{type:`file`,mimeType:e.file.mimeType,data:e.file.url,filename:k3(e.file.filename),storageId:e.file.storageId}:e.file.kind===`remote`?{type:`file`,mimeType:e.file.mimeType,data:e.file.url,filename:k3(e.file.filename),remote:!0}:{type:`file`,mimeType:e.file.mimeType,data:``,filename:k3(e.file.filename),unavailable:e.file.state,...e.file.reason===void 0?{}:{reason:e.file.reason}}}function S3(e){let t=e.activeRows;if(e.status!==`streaming`||t===void 0)return{message:e,liveTail:null};let n=e.text??``,r=n===t.text||e.runId===void 0?null:b3(t.persisted,n,e.runId);return{message:{...e,text:t.text},liveTail:r!==null&&r.trim()!==``?r:null}}function C3(e,t){return{type:`data-thinking`,data:{key:e,...t,open:!1}}}function w3(e,t,n=!1){return{type:`data-commentary`,data:{key:e,text:t,...n?{capped:!0}:{}}}}function T3(e,t){let n=!1;for(let r=e.length-1;r>=0;r--){let i=e[r];i.type===`text`&&(i.text??``).trim()!==``?n=!0:i.type===`data-thinking`&&i.data!==void 0&&(e[r]={...i,data:{...i.data,open:t&&!n}})}}function E3(e){return Li({size:String(Math.round((e??0)/1024))})}function D3(e,t){let n=e.runId??`norun`;return`${e._id}:${n}:${t}`}function O3(e,t,n){return{toolCallId:n.toolCallId??D3(e,t),toolName:n.name,args:n.input??{},result:n.outputOmitted?E3(n.outputBytes):n.output,...n.outputDetails===void 0?{}:{resultDetails:n.outputDetails},argsText:n.inputOmitted?E3(n.inputBytes):n.input===void 0?void 0:P3(n.input),phase:typeof n.phase==`string`?n.phase:void 0,...n.inputFromTranscript===!0?{inputFromTranscript:!0}:{},...n.parentToolCallId===void 0?{}:{parentToolCallId:n.parentToolCallId}}}function k3(e){return e&&U4(e)}function A3(e){return e.url?{type:`file`,mimeType:e.mimeType,data:e.url,filename:k3(e.filename),storageId:e.storageId}:null}function j3(e,t,n){return t.length>0?I4(e,t,{settled:n}):e.length>0?[{kind:`text`,text:e}]:[]}function M3(e,t,n,r){let i=[...n].sort((e,t)=>e.at-t.at),a=[],o=0;for(let n=0;n<=i.length;n++){let s=i[n],c=s===void 0?1/0:s.at,l=Math.max(0,Math.min(o,e.length)),u=Math.max(l,Math.min(c,e.length));a.push(...j3(e.slice(l,u),t.filter(e=>e.offset>=o&&e.offset<c).map(e=>({...e,offset:e.offset-l})),r).map(e=>e.kind===`activity`||e.kind===`note`?{...e,cut:e.cut+l}:e)),s!==void 0&&(a.push({kind:`delegated`,key:s.key,...s.slot===void 0?{}:{slot:s.slot}}),o=Math.max(o,s.at))}return a}function N3(e){if(e.role!==`assistant`)return[];let t=e.continuations??[];if(t.length===0)return e.continuationAt===void 0?[]:[{at:e.continuationAt,key:``}];let n=t.flatMap(e=>e.childRunIds);return[...t.map((e,t)=>({at:e.at,key:String(t),slot:{kind:`batch`,childRunIds:e.childRunIds}})),{at:e.continuationAt??1/0,key:`rest`,slot:{kind:`rest`,claimed:n}}]}function P3(e){try{return typeof e==`string`?e:JSON.stringify(e,null,2)}catch{return String(e)}}function F3(e,t,n,r,i){let{message:a,liveTail:o}=S3(e),s=[],c=[],l=[],u=[],d=[],f=[],p=[],m=null,h=r3(a),g=h===null?null:i3(a),_=new Map,v=[],y=new Set((a.rowLayout??[]).flatMap(e=>{let t=e.entryId.lastIndexOf(`:segment:`);return t<0?[]:[e.entryId.slice(t+9)]}));a.parts.forEach((e,t)=>{if(k4(e)){let n=e.textOmitted?E3(e.textBytes):e.text??``;if(n.trim()===``&&!(e.nature===`thinking`&&e.textCapped===!0))return;if(e.nature===`thinking`){s.push(C3(`p${t}`,{text:n,...e.textCapped===!0?{capped:!0}:{}}));return}let r=e.itemKey??`p${t}`;h===null?e.textOffset===void 0?s.push(w3(r,n)):l.push({offset:e.textOffset,note:{key:r,text:n}}):a.status===`streaming`&&e.itemKey!==void 0&&!y.has(e.itemKey)&&v.push({key:r,text:n})}else if(E4(e)){let n=O3(a,t,e);u.push(n),g===null?e.textOffset===void 0?c.push(n):l.push({offset:e.textOffset,activity:n}):e.toolCallId!==void 0&&g.cardsOfBlockRows.has(e.toolCallId)?_.set(e.toolCallId,n):(g.rowsWithoutBlocks||a.status===`streaming`)&&c.push(n)}else e.kind===`provenance`?d.push(e):j4(e)?f.push(e):A4(e)?p.push(e):N4(e)&&m===null&&(m={phase:e.phase,at:e.at,...typeof e.reason==`string`&&e.reason?{reason:e.reason}:{}})});let b=a.status!==`streaming`,x=N3(a),S=x.length>0?M3(a.text??``,l,x,b):l.length>0?I4(a.text??``,l,{settled:b}):a.text&&a.text.length>0?[{kind:`text`,text:a.text}]:[],C=new Set(a.role===`assistant`?a.parts.filter(M4).map(e=>e.viewId):[]),w=a.role===`assistant`&&!b&&S[S.length-1]?.kind===`text`?S.length-1:-1;if(h!==null)for(let e of h)if(e.kind===`thinking`)s.push(C3(`row:${e.entryId}`,{row:{messageId:a._id,entryId:e.entryId}}));else if(e.kind===`text`&&e.commentary===!0)s.push(w3(`row:${e.entryId}`,e3(e.text,C,!1),e.capped===!0));else if(e.kind===`text`)s.push({type:`text`,text:e3(e.text,C,!1)}),e.capped===!0&&s.push({type:`text`,text:`_${gr()}_`});else if(e.kind===`cut`)s.push({type:`text`,text:`_${Kt({count:String(e.count)})}_`});else if(e.kind===`file`)s.push(x3(e));else{let t=e.toolCallIds.flatMap(t=>{let n=_.get(t);if(n===void 0)return[];let r=e.parents?.[t];return[r===void 0?n:{...n,parentToolCallId:r}]});t.length>0&&s.push({type:`tool-call`,toolCallId:`flow:${a._id}:row:${e.entryId}`,toolName:`__turn_flow__`,args:{parts:t,rows:!0}})}let T=new Map;(h===null?S:[]).forEach((e,t)=>{e.kind===`text`?s.push({type:`text`,text:a.role===`assistant`?e3(e.text,C,t===w):e.text}):e.kind===`note`?s.push(w3(e.key,e.text)):e.kind===`delegated`?s.push({type:`tool-call`,toolCallId:e.key===``?`delegated:${a._id}`:`delegated:${a._id}:${e.key}`,toolName:`__delegated_reply__`,args:e.slot===void 0?{}:{slot:e.slot}}):s.push({type:`tool-call`,toolCallId:(()=>{let t=T.get(e.cut)??0;return T.set(e.cut,t+1),t===0?`flow:${a._id}:${e.cut}`:`flow:${a._id}:${e.cut}:${t}`})(),toolName:`__turn_flow__`,args:{parts:e.parts,...i?.projected===!0?{rows:!0}:{}}})});for(let e of v)s.push(w3(e.key,e.text));o!==null&&s.push({type:`text`,text:e3(o,C,!0)}),T3(s,a.status===`streaming`),a.role===`assistant`&&a.parts.forEach(e=>{M4(e)&&s.push({type:`data-widget`,data:{viewId:e.viewId,...e.title===void 0?{}:{title:e.title},...e.preferredHeight===void 0?{}:{preferredHeight:e.preferredHeight}}})});let E=h===null?new Set:o3(a),D=a3(a);a.parts.forEach(e=>{if(D4(e)||O4(e)){if(e.transcriptFileId!==void 0&&E.has(e.transcriptFileId)||D.has(String(e.storageId)))return;let t=A3(e);t&&s.push(t)}}),s.length===0&&s.push({type:`text`,text:``});let O=a.role===`assistant`?a.status===`streaming`?{type:`running`}:a.status===`complete`?{type:`complete`,reason:`stop`}:a.status===`error`?{type:`incomplete`,reason:`error`,error:a.error??a.errorCode??`error`}:a.status===`aborted`?{type:`incomplete`,reason:`cancelled`}:void 0:void 0;return{id:a._id,role:a.role,createdAt:new Date(a.updatedAt??a._creationTime),...O===void 0?{}:{status:O},content:s,metadata:{custom:{messageId:a._id,authorName:a.authorName??null,mentions:a.mentions??null,importedAgentLabel:n??null,sentAt:a.orderTime??a._creationTime,settledAt:a.finalizedAt??a.updatedAt??null,generationMs:a.role===`assistant`&&(a.status===`complete`||a.status===`aborted`)&&a.orderTime===void 0&&typeof a.finalizedAt==`number`?Math.max(0,a.finalizedAt-a._creationTime):null,chatId:a.chatId,status:a.status,runId:a.runId??null,hasMergedRuns:a.hasMergedRuns??!1,continuationAt:a.continuationAt??null,hasContinuation:N3(a).length>0,answeredChildRunIds:a.role===`assistant`?[...a.followedUpChildRunIds??[]]:[],...(a.displayHidden??[]).some(e=>e.rule===`repeated_text_in_group`)?{repeatWithheld:!0}:{},...i!==void 0&&a.status===`complete`?(()=>{let e=g3(a,i);return e===void 0?{}:{handOff:e}})():{},error:a.error??null,errorCode:a.errorCode??null,autoRetry:a.autoRetry??null,autoRetryOutcome:a.autoRetryOutcome??null,interruptedAt:a.interruptedAt??null,phase:a.phase??null,phaseRetry:a.phaseRetry??null,toolParts:c,allToolParts:u,activeToolName:oQ(u)?.name??null,provenanceParts:d,cronParts:f,planParts:p,routedInstanceName:t?.instanceName??a.routedInstanceName??null,routedAgentId:t?.agentId??a.routedAgentId??null,compaction:m,attachedDocCount:a.attachedDocCount??0,queued:a.role===`user`&&a.outbox?.status===`queued`,custody:a.role===`user`?a.custody??null:null,steerSegment:a.steerSegment===!0,groupFollows:r?.follows===!0,groupContinues:r?.continues===!0,groupText:r?.groupText??null,groupFirstId:r?.firstId??null,rawText:a.text,quotedRefs:a.quotedRefs??null}}}}function I3(e){let t=new Map,n=[],r=()=>{if(n.length>1){let e=n.map(e=>e.text.trim()).filter(e=>e!==``).join(`
144
+
145
+ `),r=n[0]._id;n.forEach((i,a)=>{t.set(i._id,{follows:a>0,continues:a<n.length-1,firstId:r,groupText:e})})}n=[]};for(let t of e)t.role===`assistant`&&t.displayGroupId!==void 0&&n.length>0&&n[n.length-1].displayGroupId===t.displayGroupId||r(),t.role===`assistant`&&t.displayGroupId!==void 0&&n.push(t);return r(),t}function L3(e){let t=e.filter(e=>e.displayGroupId!==void 0);return{key:e.map(e=>e.displayGroupId===void 0?e._id:`${e._id}:${e.displayGroupId}:${e.status===`streaming`?`live`:``}`).join(`|`),texts:t.map(e=>e.status===`streaming`?null:e.text)}}function R3(e,t){if(e===null||e.key!==t.key||e.texts.length!==t.texts.length)return!0;for(let n=0;n<t.texts.length;n++)if(e.texts[n]!==t.texts[n])return!0;return!1}function z3(e){return e?.messageId}var B3=128*1024;function V3(e){let t=e-B3;return t<=0?0:Math.floor(t/4)*3}var H3=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function U3(e){if(typeof e!=`string`)return!1;let t=e.toLowerCase().split(`;`)[0]?.trim()??``;return H3.has(t)}function W3(e){let t=e.split(`;`)[0]?.trim().toLowerCase()??``;return!(t.startsWith(`text/`)||t===`application/json`||t===`application/xml`||t===`image/svg+xml`)||e.toLowerCase().includes(`charset`)?e:`${e}; charset=utf-8`}function G3(){return`att_${Math.random().toString(36).slice(2)}_${Date.now()}`}function K3(e){if(!e)return[];let t=[];for(let n of e){let e=n.convex;e?.storageId&&t.push({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType,...e.origin?{origin:e.origin}:{}})}return t}var q3=`image/*`;function J3(e,t,n,r){return{accept:`*`,async add({file:i}){l0();try{let a=null;try{let t=r?.()??null;a=(await e.query(G.bridgeHealth.getBridgeAvailability,n?{chatId:n,...t?{routedAgent:t}:{}}:{}))?.maxInboundBytes??null}catch{}let o=a??V3(26214400);if(n&&!U3(i.type))try{let t=r?.()??null,i=await e.query(G.bridge.getChatInboundPolicy,{chatId:n,...t?{routedAgent:t}:{}});i?.inboundMediaMode===`shared-fs`&&(o=i.sharedFsMaxBytes)}catch{}if(i.size>o){let e=e=>Math.floor(e/1024/1024),n=Mt({size:e(i.size),max:e(o)});throw t?.(n),Error(n)}return{id:G3(),type:Y3(i.type),name:i.name,contentType:i.type||`application/octet-stream`,file:i,status:{type:`running`,reason:`uploading`,progress:0}}}finally{u0()}},async send(t){let n=t.file;s0.report(t.id,0,n.size||1);try{let r;try{r=await e.mutation(G.chats.generateUploadUrl,{})}catch(e){throw console.error(`[attach] generateUploadUrl failed:`,e),e}let i=await new Promise((e,i)=>{let a=new XMLHttpRequest;a.open(`POST`,r),a.setRequestHeader(`Content-Type`,W3(n.type||`application/octet-stream`)),a.upload.onprogress=e=>{e.lengthComputable&&s0.report(t.id,e.loaded,e.total)},a.onload=()=>{if(a.status>=200&&a.status<300)try{e(JSON.parse(a.responseText).storageId)}catch(e){i(e)}else i(Error(`Upload failed (${a.status})`))},a.onerror=()=>{console.error(`[attach] upload POST failed (network/CORS/CSP)`),i(Error(`Upload failed (network)`))},a.send(n)});return await e.mutation(G.uploads.registerUpload,{storageId:i}),{id:t.id,type:t.type,name:t.name,contentType:t.contentType,status:{type:`complete`},content:[{type:`text`,text:n.name}],convex:{storageId:i,filename:n.name,mimeType:n.type||`application/octet-stream`,...zq(n)?{origin:`pasted`}:{}}}}finally{s0.clear(t.id)}},async remove(){}}}function Y3(e){return e.startsWith(`image/`)?`image`:`document`}function X3(e){let t=[],n=e.replace(/\r\n/g,`
146
+ `).split(`
147
+
148
+ `),r=n.pop()??``;for(let e of n){if(e.trim()===``)continue;let n={data:``},r=[];for(let t of e.split(`
149
+ `))if(t.startsWith(`id:`)){let e=Number.parseInt(t.slice(3).trim(),10);Number.isFinite(e)&&(n.id=e)}else t.startsWith(`event:`)?n.event=t.slice(6).trim():t.startsWith(`data:`)&&r.push(t.slice(5).trim());n.data=r.join(`
150
+ `),t.push(n)}return{events:t,rest:r}}var Z3={text:``,lastSeq:0,done:!1};function Q3(e){if(e.event===`done`||e.event===`final`||e.data===``)return null;try{let t=JSON.parse(e.data);return typeof t.recTimingId==`string`?t.recTimingId:null}catch{return null}}function $3(e,t){if(t.event===`done`)return{...e,done:!0};if(t.event===`final`){try{let n=JSON.parse(t.data);if(typeof n.text==`string`)return{...e,text:n.text}}catch{}return e}if(t.data===``)return e;try{let n=JSON.parse(t.data);if(typeof n.text!=`string`)return e;let r=n.kind===`replace`?n.text:e.text+n.text;return{...e,text:r,lastSeq:t.id??e.lastSeq}}catch{return e}}function e6(){return!1}function t6(e,t,n,r){let i=jE(),a=(0,q.useRef)(r);a.current=r;let[o,s]=(0,q.useState)(null);return(0,q.useEffect)(()=>{let r=a1();if(!n||!e||!i||!r){s(null);return}let o=!1,c=new AbortController,l=Z3;return s(null),(async()=>{for(;!o&&!l.done;){try{let n=await fetch(`${r}/api/v1/message-stream?messageId=${encodeURIComponent(e)}`,{headers:{Authorization:`Bearer ${i}`,...l.lastSeq>0?{"Last-Event-ID":String(l.lastSeq)}:{}},signal:c.signal});if(!n.ok||!n.body){s(null);return}let u=n.body.getReader(),d=new TextDecoder,f=``;for(;!o;){let{value:n,done:r}=await u.read();if(r)break;f+=d.decode(n,{stream:!0});let i=X3(f);f=i.rest;for(let e of i.events){l=$3(l,e);let t=Q3(e);t!==null&&a.current?.(t,e.id??0)}if(o||s({text:l.text,lastSeq:l.lastSeq,messageId:e,generationKey:t}),l.done)break}}catch{if(o)return;s(null)}if(l.done||o)break;await new Promise(e=>setTimeout(e,500))}})(),()=>{o=!0,c.abort()}},[n,e,i,t]),o}var n6=1e3,r6=2e3,i6=500;function a6(e,t){let n=U(G.messages.getStreamingText,e?{chatId:e}:`skip`),r=W(G.deliveryTiming.recordFrontendTiming),i=W(G.deliveryTiming.calibrateClock),a=(0,q.useRef)(new Map),o=(0,q.useRef)(new Set),s=(0,q.useRef)([]),c=(0,q.useRef)(void 0),l=(0,q.useRef)(!1),u=(0,q.useCallback)(()=>{if(c.current!==void 0||l.current)return;l.current=!0;let e=Date.now();i({clientSentAt:e}).then(t=>{c.current=wC(e,t.serverNow,Date.now())}).catch(()=>{l.current=!1})},[i]);(0,q.useEffect)(()=>{n&&(EC(a.current,TC(n,Date.now()),o.current),a.current.size>0&&u(),o.current.size>0&&!n.some(e=>e.recTimingId!==void 0)&&o.current.clear())},[n,u]),(0,q.useEffect)(()=>{let e=()=>{EC(a.current,t.current??[],o.current),t.current&&(t.current.length=0),a.current.size>0&&u();for(let[e,t]of a.current)s.current.push({timingId:e,t4:t,clientSkew:c.current}),o.current.add(e);a.current.clear(),s.current.length>r6&&s.current.splice(0,s.current.length-r6);let e=OC(s.current,c.current,i6);e!==null&&(s.current.splice(0,e.length),r({samples:e}).catch(()=>{}))},n=window.setInterval(e,n6);return()=>{for(window.clearInterval(n),e();OC(s.current,c.current,i6)!==null;)e()}},[r,t,u])}function o6(e,t){return e===null?{kind:t===`steer`?`steer`:`send`,mode:void 0}:{kind:e,mode:e}}function s6(e){return e.kind===`queue`?`steer`:`queue`}function c6(e){switch(e){case`queued`:case`steered`:case`cancelled`:case`interrupted`:return e;default:return null}}function l6(e,t,n){return e!==null&&e>n&&t===`user`}function u6(e){return e instanceof Error?null:e}function d6(e,t){let n=t===`skip`,r=Gh((0,q.useMemo)(()=>t===`skip`?{}:{q:{query:e,args:t}},[Tr(e),n?``:JSON.stringify(Qn(t)),n])).q;return r instanceof Error&&console.warn(`[follow-up] state unavailable:`,r.message),u6(r)}function f6(e,t,n){return!e||t==null?[]:t.sessions.filter(e=>e.count>0&&n<e.until)}function p6(e){return new Set(e.flatMap(e=>e.sendIds))}function m6(e,t,n){return e.role===`user`?e.outbox?.status===`queued`||t.has(String(e._id))?`atrium`:e.custody===`queued`&&typeof e.queuedSendId==`string`&&n.has(e.queuedSendId)?`gateway`:`thread`:`thread`}function h6(e,t){let n=0;for(let r of e){let e=r.sendIds.filter(e=>t.has(e)).length;n+=Math.max(0,r.count-e)}return n}var g6=[];function _6(e){let t=e instanceof Error?e.message:``;return new Set([...t.matchAll(/Invalid: quote target gone \[([^\]]+)\]/g)].map(e=>e[1]))}function v6(e){let t=e instanceof Error?e.message:``;return _6(e).size>0?!1:/Invalid:.*quote/i.test(t)}function y6(e){let t=e instanceof Error?e.message:String(e??``);return t.includes(`agent_mentions_invalid:too_many_agents`)?`too_many`:t.includes(`agent_mentions_invalid:`)||t.includes(`Forbidden: agent is not part of this conversation`)||t.includes(`Forbidden: routed agent is not dispatchable`)?`invalid`:null}function b6(e){return(e instanceof Error?e.message:String(e??``)).includes(`COMMAND_WITH_ATTACHMENTS`)}function x6({chatId:e}){let t=Ia(),n=Mw(),r=W(G.send.sendMessage).withOptimisticUpdate((e,t)=>{let n={chatId:t.chatId},r=e.getQuery(G.messages.listByChat,n)??[],i=`optimistic-${t.clientMessageId}`;if(r.some(e=>e._id===i))return;let a=Date.now(),o={_id:i,chatId:t.chatId,_creationTime:a,orderTime:void 0,role:`user`,status:`complete`,runId:void 0,error:void 0,errorCode:void 0,attachedDocCount:void 0,finalizedAt:void 0,text:t.text,updatedAt:a,routedInstanceName:t.routedAgent?.instanceName??t.agentMentions?.[0]?.instanceName,routedAgentId:t.routedAgent?.agentId??t.agentMentions?.[0]?.agentId,quotedRefs:t.quotes,hasMergedRuns:!1,hasAnnouncePrefix:!1,mergedIntoTurn:void 0,continuationAt:void 0,continuations:void 0,followedUpChildRunIds:void 0,autoRetry:void 0,autoRetryOutcome:void 0,interruptedAt:void 0,parts:[],outbox:null,finalizeCause:void 0,priorFinalizeCauses:void 0,importedAgentLabel:void 0,chatImportedAgentLabel:void 0};e.setQuery(G.messages.listByChat,n,[...r,o])}),i=U(G.messages.listByChat,e?{chatId:e}:`skip`),a=U(G.messages.getStreamingText,e?{chatId:e}:`skip`),o=a&&a.length>0?a[0].messageId:null,s=U(G.messages.getChatStreamTransport,e?{chatId:e}:`skip`)===`sse`||e6(),c=(0,q.useRef)([]),l=(0,q.useRef)(0),u=(0,q.useCallback)((e,t)=>{t<l.current||c.current.push({timingId:e,t4:Date.now()})},[]),d=a&&a.length>0?a[0].streamRowId??null:null,f=t6(o,d,s,u);l.current=(a?.[0]?.chunkSeq??1)-1,a6(e,c);let p=U(G.agents.getChatAgent,e?{chatId:e}:`skip`),m=U(G.messages.getSessionMeta,e?{chatId:e}:`skip`),h=U(G.agents.listMyAgents,e?{}:`skip`),g=U(G.chatAgents.listChatAgents,e?{chatId:e}:`skip`),_=(g?.viewerRole??m?.viewerRole)===`participant`,v=g?[g.primary,...g.agents].filter(e=>e!==null).map(e=>`${e.instanceName}\0${e.agentId}`).join(`|`):``,y=(0,q.useMemo)(()=>(g?.agents??[]).map(e=>({instanceName:e.instanceName,agentId:e.agentId})),[v]),b=h===void 0||e!==null&&g===void 0,x=(0,q.useMemo)(()=>e!==null&&g===void 0?[]:!_||!g?h??[]:[g.primary,...g.agents].filter(e=>e!==null).map(e=>({instanceName:e.instanceName,agentId:e.agentId,isDefault:e.role===`primary`,displayName:e.displayName,emoji:e.emoji,model:e.model,description:e.description,kind:e.kind,state:e.usable?`ok`:`deleted`})),[e,h,_,v,g]),S=(0,q.useMemo)(()=>g2(x,g?[g.primary,...g.agents]:null),[x,v,g===void 0]),C=p?.multiAgent===!0,w=m?.perTurnRouting===!0,T=C||w,E=(0,q.useMemo)(()=>p?.agent?{instanceName:p.agent.instanceName,agentId:p.agent.agentId}:null,[p?.agent?`${p.agent.instanceName}\0${p.agent.agentId}`:``]),D=(0,q.useMemo)(()=>m?.lastRoutedInstanceName&&m?.lastRoutedAgentId?{instanceName:m.lastRoutedInstanceName,agentId:m.lastRoutedAgentId}:null,[m?.lastRoutedInstanceName&&m?.lastRoutedAgentId?`${m.lastRoutedInstanceName}\0${m.lastRoutedAgentId}`:``]),O=(0,q.useSyncExternalStore)(h4,()=>e?g4(e):g6),k=S4(O).map(e=>`${e.instanceName}\0${e.agentId}`).join(`|`),A=y.length>0,j=i===void 0,M=(0,q.useMemo)(()=>n2(i??[]),[i]),N=(0,q.useMemo)(()=>(i?r2(i):null)??D,[i,D]),P=(0,q.useMemo)(()=>o2({selected:null,lastRouted:N,primary:E,pool:S,poolLoading:b,messagesLoading:j,canRoute:T}),[N,E,S,b,j,T]),F=(0,q.useMemo)(()=>l2({mentioned:S4(O),primary:E,severalAgents:A,perTurnRouting:w,canRoute:T})??null,[k,E,A,w,T]),I=i!==void 0&&i.length===0,L=(0,q.useRef)({primary:null,severalAgents:!1,perTurnRouting:!1,canRoute:!1,nextTarget:null});L.current={primary:E,severalAgents:A,perTurnRouting:w,canRoute:T,nextTarget:F};let R=(0,q.useCallback)(e=>{let t=L.current;if(e.length>0&&t.canRoute)return{agentMentions:e.map(e=>({instanceName:e.instanceName,agentId:e.agentId,start:e.start,end:e.end}))};let n=l2({mentioned:[],primary:t.primary,severalAgents:t.severalAgents,perTurnRouting:t.perTurnRouting,canRoute:t.canRoute});return n?{routedAgent:n}:{}},[]),ee=(0,q.useMemo)(()=>J3(t,e=>n.error(e),e,()=>L.current.nextTarget),[t,n,e]),z=(0,q.useMemo)(()=>{let e=i??[];if(!a||a.length===0)return e;let t=new Map(a.map(e=>[e.messageId,{text:e.text,chunkSeq:e.chunkSeq,phase:e.phase,phaseRetry:e.phaseRetry}]));return e.map(e=>{if(e.status!==`streaming`)return e;let n=e._id,r=t.get(n);if(typeof e.runId==`string`&&e.runId.startsWith(`announce:v1:`)){let t=r?.phase,n=r?.phaseRetry;return t===void 0?e:{...e,phase:t,phaseRetry:n}}if(f!==null&&f.messageId===o&&f.generationKey===d&&n===o){let t=(r?.chunkSeq??1)-1,n=f.lastSeq>=t;return{...e,text:n?f.text:r?.text??f.text,...r?.phase===void 0?{}:{phase:r.phase},...r?.phaseRetry===void 0?{}:{phaseRetry:r.phaseRetry}}}return r===void 0?e:{...e,text:r.text,...r.phase===void 0?{}:{phase:r.phase},...r.phaseRetry===void 0?{}:{phaseRetry:r.phaseRetry}}})},[i,a,f,o]),B=(0,q.useRef)(new Set),V=d6(G.followUp.followUpState,e?{chatId:e}:`skip`),te=V?.projection===!0?V.gatewayQueue:null,[,ne]=(0,q.useState)(0),re=(te?.sessions??[]).map(e=>e.until).filter(e=>e>Date.now()).reduce((e,t)=>e===null||t<e?t:e,null);(0,q.useEffect)(()=>{if(re===null)return;let e=re-Date.now();if(e<=0)return;let t=window.setTimeout(()=>ne(e=>e+1),e+50);return()=>window.clearTimeout(t)},[re]);let ie=f6(V?.projection===!0,te,Date.now()),ae=p6(ie),oe=[...ae].sort().join(`,`),se=e=>m6(e,B.current,ae),ce=e=>se(e)!==`thread`,le=z.filter(ce).map(e=>{let t=se(e)===`gateway`;return{messageId:String(e._id),text:e.text,mine:!t&&e.mine!==!1,canCancel:e.mine!==!1||!_,pending:String(e._id).startsWith(`optimistic-`),gateway:t,sendId:e.queuedSendId}}),ue=h6(ie,new Set(le.flatMap(e=>e.gateway&&e.sendId!==void 0?[e.sendId]:[]))),de=(0,q.useMemo)(()=>z.filter(e=>!ce(e)),[z,oe]),fe=de.length>0?de[de.length-1].role:null,pe=de.some(e=>e.status===`streaming`),[me,he]=(0,q.useState)(null);(0,q.useEffect)(()=>{he(null)},[e]),(0,q.useEffect)(()=>{fe===`assistant`&&he(null)},[fe,z]),(0,q.useEffect)(()=>{if(me===null)return;let e=window.setTimeout(()=>he(null),12e4);return()=>window.clearTimeout(e)},[me]);let ge=V?.projection===!0&&typeof V.workingUntil==`number`?V.workingUntil:null,[,_e]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(ge===null)return;let e=ge-Date.now();if(e<=0)return;let t=window.setTimeout(()=>_e(e=>e+1),e+50);return()=>window.clearTimeout(t)},[ge]);let ve=l6(ge,fe,Date.now()),ye=me!==null||pe||ve,be=le.length>0&&!pe,xe=(0,q.useMemo)(()=>u2(i??[]),[i]),Se=L3(de),Ce=(0,q.useRef)(null);(Ce.current===null||R3(Ce.current.inputs,Se))&&(Ce.current={inputs:Se,places:I3(de)});let we=Ce.current.places,Te=h3(de,V?.projection===!0),Ee=(0,q.useRef)(null),De=JSON.stringify(Te);(Ee.current===null||Ee.current.key!==De)&&(Ee.current={key:De,index:Te});let Oe=Ee.current.index,ke=(0,q.useCallback)(e=>F3(e,M.get(e._id)??null,xe.get(e._id)??null,we.get(e._id)??null,Oe),[M,xe,we,Oe]),Ae=(0,q.useMemo)(()=>({messages:de,isRunning:ye,convertMessage:ke,onNew:async t=>{if(!e)throw Error(`No chat selected`);let i=t.content.filter(e=>e.type===`text`).map(e=>e.text).join(``),a=K3(t.attachments).map(e=>({storageId:e.storageId,filename:e.filename,mimeType:e.mimeType,...e.origin?{origin:e.origin}:{}})),o=lM(e),{staged:s,mentions:c,agentMentions:l}=x4(e,i),u=c.map(e=>({userId:e.userId,start:e.start,end:e.end})),d=R(l);he(Date.now());try{await r({chatId:e,text:i,clientMessageId:crypto.randomUUID(),attachments:a,...d,...o.length>0?{quotes:o.map(e=>({messageId:e.messageId,blockIndex:e.blockIndex,excerpt:e.excerpt}))}:{},...u.length>0?{mentions:u}:{}})}catch(t){if(y4(e,s),!v6(t)){let r=dM(e,o,_6(t));r.gone>0&&n.error(xt({count:r.gone})),r.dropped>0&&n.error(Vt({count:r.dropped}))}let r=y6(t);throw r!==null&&n.error(r===`too_many`?xv():e_()),b6(t)&&n.error(Tg()),he(null),t}},adapters:{attachments:ee}}),[z,ye,e,r,ee,R]),je=(0,q.useMemo)(()=>({begin:()=>he(Date.now()),cancel:()=>he(null)}),[]),Me=W(G.messages.abortTurn),Ne=W(G.send.cancelQueuedMessage),Pe=W(G.followUp.cancelGatewayQueuedInput),Fe=(0,q.useCallback)(async e=>{try{let t=await Pe({messageId:e});return t.ok||n.error(Kg()),t.ok}catch{return n.error(Kg()),!1}},[Pe,n]),Ie=(0,q.useCallback)(async e=>{try{return await Ne({messageId:e}),!0}catch{return n.error(qp()),!1}},[Ne,n]),Le=(0,q.useCallback)(async(t,i)=>{let a=t.trim();if(!e||a===``)return!1;let o=lM(e),{staged:s,mentions:c,agentMentions:l}=x4(e,t),u=R(l),d=c.map(e=>({userId:e.userId,start:e.start,end:e.end})),f=crypto.randomUUID();i?.immediate!==!0&&B.current.add(`optimistic-${f}`);try{return await r({chatId:e,text:t,clientMessageId:f,...i?.mode===void 0?{}:{followUpMode:i.mode},...u,...o.length>0?{quotes:o.map(e=>({messageId:e.messageId,blockIndex:e.blockIndex,excerpt:e.excerpt}))}:{},...d.length>0?{mentions:d}:{}}),!0}catch(t){if(y4(e,s),!v6(t)){let r=dM(e,o,_6(t));r.gone>0&&n.error(xt({count:r.gone})),r.dropped>0&&n.error(Vt({count:r.dropped}))}let r=t?.message??``,i=y6(t);return n.error(i===`too_many`?xv():i===`invalid`?e_():r.includes(`QUEUE_FULL`)?Xy():b6(t)?Tg():r.includes(`TALK_CALL_ACTIVE`)?$f():iy()),!1}},[e,r,n,R]),Re=(0,q.useMemo)(()=>({pool:x,roomAgents:y,multiAgent:C,perTurnRouting:w,emptyThread:I,primary:E,nextTarget:F,messageAgents:M,fallbackAgent:P}),[x,y,C,w,I,E,F,M,P]),ze=(0,q.useCallback)(async()=>{if(e)try{if((await Me({chatId:e})).ok){he(null);return}n.error(gn())}catch(e){n.error(Rr(),e)}},[e,Me,n]);return{runtime:UR(Ae),turnGate:je,queueSend:Le,abortTurn:ze,routing:Re,lastUserTurnQueued:be,queuedTurns:le,cancelQueued:Ie,withdrawGatewayQueued:Fe,gatewayOthers:ue,initialLoading:j}}function S6(e,t,n=-1/0){let r=t.displayGroupId;if(t.role!==`assistant`||r===void 0||r===t._id)return t;let i=e.findIndex(e=>e._id===t._id),a=e.findIndex(e=>e._id===r);if(i<0||a<0||a>=i)return t;let o=e[a];if(o._creationTime!==void 0&&Math.min(o._creationTime,o.orderTime??o._creationTime)<n)return t;for(let n=a;n<i;n++){let i=e[n];if(i.role!==`assistant`||i.displayGroupId!==r)return t}return e[a]}function C6(e,{messageId:t}){for(let{args:n,value:r}of e.getAllQueries(G.messages.listByChat)){if(r===void 0)continue;let i=r.find(e=>e._id===t);if(i===void 0)continue;let a=S6(r,i,r.reduce((e,t)=>Math.min(e,t._creationTime),1/0))._creationTime;e.setQuery(G.messages.listByChat,n,r.filter(e=>e._creationTime<a))}}function w6(e){let t=e instanceof Error?e.message:typeof e?.data==`string`?String(e.data):String(e??``);return/compact_refused|already_active|already_in_flight|deferred_compaction_not_scheduled|below_threshold|already_compacted_recently|unsupported_harness_compaction|no transcript|no sessionId/i.test(t)}function T6(e){let t=pa(G.agentFiles.compactSession),n=W(G.chatFork.forkChat),r=U(G.messages.getSessionMeta,{chatId:e.chatId})?.viewerRole===`participant`,[i,a]=(0,q.useState)(null),[o,s]=(0,q.useState)(null),[c,l]=(0,q.useState)(null),u=async()=>{a(`compact`),s(null);try{await t({chatId:e.chatId}),l(`compact`),s(Sp())}catch(e){s(w6(e)?iu():nd())}finally{a(null)}},d=async()=>{if(e.messageId!==null){a(`branch`),s(null);try{let{chatId:t}=await n({branchMessageId:e.messageId});M2(t,{expand:!0}),l(`branch`),s(m())}catch{s(nd())}finally{a(null)}}};return r?null:(0,J.jsxs)(`div`,{className:`oc-error-card__actions`,children:[(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:i!==null||c!==null,onClick:()=>void u(),children:i===`compact`?Jo():Jg()}),e.messageId===null?null:(0,J.jsx)(K,{type:`button`,size:`sm`,variant:`outline`,disabled:i!==null||c===`branch`,onClick:()=>void d(),children:i===`branch`?Jo():sy()}),o===null?null:(0,J.jsx)(`p`,{className:`oc-error-card__notice`,role:`status`,children:o})]})}var E6=(0,q.createContext)(!1);function D6({text:e}){let[t,n]=(0,q.useState)(!1);return(0,J.jsxs)(`details`,{className:`oc-error-card__details`,children:[(0,J.jsx)(`summary`,{children:jg()}),(0,J.jsx)(`pre`,{children:e}),(0,J.jsxs)(K,{type:`button`,variant:`ghost`,size:`xs`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),window.setTimeout(()=>n(!1),1500)})},children:[t?(0,J.jsx)(YS,{"aria-hidden":!0}):(0,J.jsx)(bC,{"aria-hidden":!0}),t?Xp():wee()]})]})}function O6({retry:e}){let[,t]=(0,q.useState)(0);(0,q.useEffect)(()=>{let e=window.setInterval(()=>t(e=>e+1),1e3);return()=>window.clearInterval(e)},[]);let n=Math.max(0,Math.ceil((e.firesAt-Date.now())/1e3));return(0,J.jsxs)(`span`,{className:`oc-error-card__retry`,role:`status`,children:[(0,J.jsx)(rj,{size:13,className:`oc-error-card__retry-spin`,"aria-hidden":!0}),n>0?Jn({attempt:String(e.attempt),max:String(e.maxAttempts),seconds:String(n)}):rl({attempt:String(e.attempt),max:String(e.maxAttempts)})]})}function k6(){let e=W0(),t=$(e=>e.metadata?.custom?.status),n=$(e=>e.metadata?.custom?.runId),r=$(e=>e.metadata?.custom?.error),i=$(e=>e.metadata?.custom?.errorCode),a=$(e=>e.metadata?.custom?.autoRetry??null),o=$(e=>wQ(e.metadata?.custom?.autoRetryOutcome)),s=$(e=>e.metadata?.custom?.chatId),c=$(e=>e.metadata?.custom?.messageId??e.id),l=$(e=>SQ(e.content)),u=$(e=>e.metadata?.custom?.phase),d=$(e=>e.metadata?.custom?.phaseRetry),f=$(e=>{let t=e.metadata?.custom;return t?.activeToolName??oQ(t?.toolParts)?.name??null}),p=f===null?null:{name:f,family:iQ(f)},m=(0,q.useContext)(E6),h=$(e=>e.metadata?.custom?.interruptedAt!=null),{byMessage:g}=fS(t===`streaming`&&s?[s]:null),_=sQ(t,l,u,p,h,d,g.get(c??``)??null),v=_?.kind===`thinking`,[y,b]=(0,q.useState)(!1);if((0,q.useEffect)(()=>{if(!v){b(!1);return}let e=window.setTimeout(()=>b(!0),6e3);return()=>window.clearTimeout(e)},[v]),!_)return null;if(_.kind===`error`){let{headline:e,detail:t,rawDetail:l,code:u}=xQ(r,i),d=u===null?void 0:TQ.get(u);return(0,J.jsxs)(`div`,{className:d?`oc-error-card oc-error-card--status`:`oc-error-card`,role:d?`status`:`alert`,title:n?`run ${n}`:void 0,children:[(0,J.jsx)(dA,{size:18,className:`oc-error-card__icon`,"aria-hidden":!0}),(0,J.jsxs)(`div`,{className:`oc-error-card__body`,children:[(0,J.jsx)(`span`,{className:`oc-error-card__title`,children:d?d():_.label}),e?(0,J.jsx)(`span`,{className:`oc-error-card__msg`,children:e}):null,t?(0,J.jsx)(`span`,{className:e?`oc-error-card__msg oc-error-card__msg--detail`:`oc-error-card__msg`,children:t}):null,l?(0,J.jsx)(D6,{text:l}):null,a?(0,J.jsx)(O6,{retry:a}):o?(0,J.jsx)(`span`,{className:`oc-error-card__msg oc-error-card__msg--detail`,children:o}):null,u&&lQ.has(u)&&s?(0,J.jsx)(T6,{chatId:s,messageId:c??null}):null]})]})}return(0,J.jsxs)(`div`,{className:`oc-run-status oc-run-status--${_.kind}${_.struggling?` oc-run-status--struggling`:``}`,role:`status`,title:n?`run ${n}`:void 0,children:[_.kind===`thinking`?(0,J.jsxs)(`span`,{className:`oc-dots`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}):_.kind===`generating`?(0,J.jsx)(`span`,{className:`oc-run-status__pulse`,"aria-hidden":!0}):(0,J.jsx)(mj,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:_.phased&&!m?`oc-run-status__label oc-shimmer-text`:`oc-run-status__label`,children:cQ(_.kind,m)??(_.kind===`thinking`&&y&&!_.phased?K0(e):_.label)})]})}function A6(e,t){return Math.max(0,t-e)}function j6(e,t,n){return e+Math.max(0,n-t)}function M6(e,t,n){return e?!0:n!==void 0&&t===n}function N6(e){return qw(e)}var P6=(0,q.createContext)(null);function F6(e){return e!==void 0&&e.some(e=>e.status===`streaming`)}function I6(e,t,n,r){return t===null||n===null||n<=0?!1:!(r?.chatId===e&&r.key===t)}function L6(){let e=$(e=>e.metadata?.custom?.status),t=$(e=>e.metadata?.custom?.messageId),n=$(e=>e.metadata?.custom?.sentAt),r=M6(e===`streaming`,(0,q.useContext)(P6)?.messageId??null,t),i=(0,q.useRef)(null);if(r&&t!==void 0&&n!==void 0&&i.current?.id!==t){let e=Date.now();i.current={id:t,baselineMs:A6(n,e),firstLocalMs:e}}let[,a]=(0,q.useState)(0);if((0,q.useEffect)(()=>{if(!r)return;let e=window.setInterval(()=>a(e=>e+1),1e3);return()=>window.clearInterval(e)},[r]),!r||i.current===null||i.current.id!==t)return null;let o=N6(j6(i.current.baselineMs,i.current.firstLocalMs,Date.now()));return o===null?null:(0,J.jsx)(`div`,{className:`oc-turn-clock`,role:`timer`,children:(0,J.jsx)(`span`,{className:`oc-turn-clock__label`,children:Oa({duration:o})})})}function R6(e){let t=null;for(let n of e??[]){if(n.role!==`user`)continue;let e=n.orderTime??n._creationTime;e!==void 0&&(t===null||e>t)&&(t=e)}return t}function z6(e,t,n,r){return e===null||n===null||n<=r?!1:!(t!==null&&t>e)}function B6(e,t,n){return!e&&t!==null&&n!==null&&n>0}function V6({chatId:e,projected:t,anyStreaming:n,runningLive:r,deliveringSince:i,deliveringTtlRemainingMs:a,lastUserAt:o,gatewayWorkingUntil:s,runningSince:c=null,now:l=Date.now()}){let[u,d]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(!B6(t,i,a)||i===null||a===null)return;let n=window.setTimeout(()=>d({chatId:e,key:i}),a);return()=>window.clearTimeout(n)},[t,i,a,e]);let[,f]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(!t||s===null)return;let e=s-Date.now();if(e<=0)return;let n=window.setTimeout(()=>f(e=>e+1),e+50);return()=>window.clearTimeout(n)},[t,s]);let p=t?z6(i,o,s,l):I6(e,i,a,u),m=t?H6(r,c,o):r;return{deliveringFresh:p,showTurnActivity:!n&&(m||p)}}function H6(e,t,n){return e?!(t!==null&&n!==null&&n>t):!1}function U6(e){let t=e.map(e=>({card:e,children:[]})),n=new Map;for(let e of t){let{runId:t,callId:r}=e.card;if(t&&r){let i=JSON.stringify([t,r]);n.set(i,n.has(i)?null:e)}}let r=new Map;for(let e of t){let{runId:t,callId:i,parentToolCallId:a}=e.card;if(!t||!a||a===i||i&&n.get(JSON.stringify([t,i]))!==e)continue;let o=n.get(JSON.stringify([t,a]));o&&r.set(e,o)}let i=new Set;for(let e of t){let t=[],n=e;for(;n&&!i.has(n);)i.add(n),t.push(n),n=r.get(n);let a=n?t.indexOf(n):-1;if(a>=0)for(let e of t.slice(a))r.delete(e)}let a=[];for(let e of t){let t=r.get(e);(t?t.children:a).push(e)}return a}function W6(e){let t=new Set,n=U6(e);for(;n.length>0;){let e=n.pop();e.children.length>0&&e.card.activity?.status===`completed`&&t.add(e.card);for(let t of e.children)n.push(t)}return t}var G6=e=>typeof e==`object`&&e&&!Array.isArray(e)?e:void 0,K6=new Set([`progress_card`,`update_plan`]);function q6(e){return K6.has(e?.trim().toLowerCase()??``)}function J6(e){let t=G6(e);return!!(t&&typeof t.sessionId==`string`&&(t.status===`running`||t.status===`completed`)&&(typeof t.aggregated==`string`||t.persistedDetailsTruncated===!0&&Array.isArray(t.originalDetailKeys)&&t.originalDetailKeys.includes(`aggregated`)))}function Y6(e,t={}){if(e.kind===`analysis`)return{...e,hideFromChannelProgress:!0};let n=(e.name??``).toLowerCase(),r=G6(G6(t.result)?.details);return e.phase===`end`&&e.status===`completed`&&(n===`exec`||n===`bash`||n===`process`)&&r?.status===`completed`&&r.exitReason!==`manual-cancel`&&typeof r.exitCode==`number`&&Number.isFinite(r.exitCode)&&r.exitCode!==0?{...e,status:`failed`}:(t.nativeOperation===`wait`||t.nativeOperation===`process.poll`||q6(n)||n===`sessions_yield`||n===`process`&&G6(t.args)?.action===`poll`)&&(e.status===`running`||e.status===`completed`)?{...e,hideFromChannelProgress:!0}:e}function X6(e){let t=new Map(e.filter(e=>!e.suppressChannelProgress).map(e=>[e.toolCallId??e.itemId,e])),n={commands:0,reads:0,edits:0,writes:0,searches:0,fetches:0,other:0},r={failed:0,blocked:0,skipped:0,unknown:0},i=0;for(let e of t.values()){if(e.hideFromChannelProgress||e.suppressChannelProgress)continue;let t=(e.name??``).toLowerCase(),a=e.commandBearing?`commands`:Z6.get(t)??`other`;n[a]+=1,i+=1,e.status===`failed`||e.status===`blocked`||e.status===`skipped`?r[e.status]+=1:e.status||(r.unknown+=1)}return{total:i,counts:n,outcomes:r}}var Z6=new Map([[`exec`,`commands`],[`bash`,`commands`],[`shell`,`commands`],[`run_command`,`commands`],[`run_terminal_cmd`,`commands`],[`read`,`reads`],[`read_file`,`reads`],[`readfile`,`reads`],[`notebookread`,`reads`],[`notebook_read`,`reads`],[`edit`,`edits`],[`apply_patch`,`edits`],[`applypatch`,`edits`],[`patch`,`edits`],[`edit_file`,`edits`],[`multiedit`,`edits`],[`multi_edit`,`edits`],[`notebookedit`,`edits`],[`notebook_edit`,`edits`],[`write`,`writes`],[`write_file`,`writes`],[`create_file`,`writes`],[`grep`,`searches`],[`glob`,`searches`],[`find`,`searches`],[`ls`,`searches`],[`list`,`searches`],[`codebase_search`,`searches`],[`web_search`,`searches`],[`web_fetch`,`fetches`],[`webfetch`,`fetches`],[`fetch`,`fetches`]]),Q6={commands:e=>e===1?le():ng({count:String(e)}),reads:e=>e===1?ho():St({count:String(e)}),edits:e=>e===1?Ht():Sc({count:String(e)}),writes:e=>e===1?zb():nt({count:String(e)}),searches:e=>e===1?tc():lx({count:String(e)}),fetches:e=>e===1?kf():Ree({count:String(e)}),other:e=>e===1?gb():Id({count:String(e)})},$6={failed:e=>Am({count:String(e)}),blocked:e=>see({count:String(e)}),skipped:e=>Ug({count:String(e)}),unknown:e=>L_({count:String(e)})};function e8(e){let t=X6(e),n=Object.entries(t.counts).filter(([,e])=>e>0).map(([e,t])=>Q6[e](t)).join(` · `),r=Object.entries(t.outcomes).filter(([,e])=>e>0).map(([e,t])=>({kind:e,label:$6[e](t)}));return{total:t.total,label:n,outcomes:r}}function t8(e,t={}){let n=e8(e);return[n.label,...n.outcomes.filter(({kind:e})=>t.includeInlineOutcomes!==!1||e!==`failed`&&e!==`skipped`).map(({label:e})=>e)].filter(Boolean).join(` · `)||lm()}var n8=`block`;function r8(e){return e===`error`?`failed`:e===`completed`?`completed`:`running`}function i8(e){return e?.details}function a8(e){let t=e.result;if(typeof t==`object`&&t&&!Array.isArray(t)){if(`details`in t)return t;if(`exitCode`in t&&`status`in t)return{details:t}}return e.resultDetails===void 0?void 0:{details:e.resultDetails}}function o8(e,t){let n=e.map(e=>{let t=r8(e.phase),n=a8(e),r=e.toolName,i=Y6({kind:`tool`,name:r,status:t,phase:t===`running`?`start`:`end`},{args:e.args,result:n,...r===`collab.wait`?{nativeOperation:`wait`}:r===`process`&&J6(i8(n))?{nativeOperation:`process.poll`}:{}});return{runId:n8,callId:e.toolCallId,...e.parentToolCallId===void 0?{}:{parentToolCallId:e.parentToolCallId},part:e,activity:i}}),r=e=>({part:e.card.part,children:e.children.map(r)}),i=U6(n).map(r),a=W6(n),o=n.map(e=>({itemId:e.callId,toolCallId:e.callId,title:e.part.toolName,name:e.part.toolName,status:e.activity.status,...a.has(e)||e.activity.hideFromChannelProgress===!0?{hideFromChannelProgress:!0}:{}}));return{roots:i,visible:n.filter(e=>!a.has(e)).map(e=>e.part),summary:t8(o)}}var s8={read:sA,exec:gj,search:yC,fetch:OA,write:LC,other:yj};function c8({node:e,settled:t}){let n=e.part;return(0,J.jsx)(xX,{toolName:n.toolName,args:n.args,argsText:n.argsText,inputFromTranscript:n.inputFromTranscript,result:n.result,status:n.phase?{type:n.phase}:void 0,turnSettled:t,nested:e.children.length>0?e.children.map(e=>(0,J.jsx)(c8,{node:e,settled:t},e.part.toolCallId)):void 0})}function l8(e){let t=$(e=>e.metadata?.custom?.status),[n,r]=(0,q.useState)(!1),{showTools:i}=D7(),a=e.args?.parts??[];if(!i||a.length===0)return null;let o=t===`streaming`&&a.some(e=>z4(e.phase)),s=t!==void 0&&t!==`streaming`,c=e.args?.rows===!0?o8(a,s):null,l=c?.visible??a,u=c===null||o||l.length<=1?V4(c===null||o?a:l,{live:o}):c.summary,d=s8[B4(l)],f=o?(0,J.jsx)(kC,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsxs)(J.Fragment,{children:[l.length>1?(0,J.jsx)(`span`,{className:`oc-flowact__count`,children:l.length}):null,(0,J.jsx)(YS,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0})]});return(0,J.jsxs)(`div`,{className:`oc-msg__meta oc-flowact`,role:`group`,"aria-label":xd(),children:[(0,J.jsx)(xK,{icon:(0,J.jsx)(d,{size:14}),label:u,trailing:f,open:n,ariaExpanded:n,title:n?wl():hr(),onClick:()=>r(!n)}),n&&c!==null?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:c.roots.map(e=>(0,J.jsx)(c8,{node:e,settled:s},e.part.toolCallId))}):n?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:a.map(e=>(0,J.jsx)(xX,{toolName:e.toolName,args:e.args,argsText:e.argsText,inputFromTranscript:e.inputFromTranscript,result:e.result,status:e.phase?{type:e.phase}:void 0,turnSettled:t!==void 0&&t!==`streaming`},e.toolCallId))}):null]})}function u8(e){if(e.writing)return qy();if(e.generationMs!==null&&Number.isFinite(e.generationMs)&&!e.hasToolActivity){let t=qw(e.generationMs);if(t!==null)return Sg({duration:t})}return gp()}function d8({data:e}){let t=e?.row,n=e?.capped===!0,r=(e?.text??``).trim(),i=e?.open===!0,[a,o]=(0,q.useState)(null),s=a??i,c=(0,q.useId)(),l=$(e=>{let t=e.metadata?.custom;return`${t?.status??``}|${t?.generationMs??``}|${(t?.allToolParts??[]).length}`});if(t===void 0&&r===``&&!n)return null;let[u,d,f]=l.split(`|`),p=u8({writing:i&&u===`streaming`,generationMs:d===``?null:Number(d),hasToolActivity:Number(f)>0});return(0,J.jsxs)(`div`,{className:`oc-msg__meta oc-thinking`,"data-open":s?`true`:`false`,children:[(0,J.jsx)(xK,{icon:(0,J.jsx)(lA,{size:14}),label:p,open:s,ariaExpanded:s,ariaControls:s?c:void 0,title:s?ty():Xf(),onClick:()=>o(!s)}),s?(0,J.jsxs)(`div`,{id:c,className:`oc-thinking__body`,role:`region`,"aria-label":xee(),children:[t===void 0?r===``?null:(0,J.jsx)(cq,{text:r}):(0,J.jsx)(f8,{messageId:t.messageId,entryId:t.entryId}),n?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:Iv()}):null]}):null]})}function f8({messageId:e,entryId:t}){let n=e,r=U(G.messages.getRowReasoning,{messageId:n,entryId:t});return r===void 0?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:cf()}):r===null?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:ph()}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(cq,{text:r.text}),r.truncated===!0?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:Iv()}):null]})}function p8({data:e}){let t=(e?.text??``).trim();return t===``?null:(0,J.jsxs)(`div`,{className:`oc-msg__meta oc-msg__note`,role:`note`,"aria-label":g_(),children:[(0,J.jsx)(cq,{text:t}),e?.capped===!0?(0,J.jsx)(`p`,{className:`oc-thinking__status`,children:gr()}):null]})}function m8(){let e=(0,q.useContext)(A7),t=PV(),n=(0,q.useRef)(null),r=e?.gatewayOthers??0,i=(e?.queuedTurns.length??0)+ +(r>0);if((0,q.useLayoutEffect)(()=>{let e=n.current,t=document.querySelector(`.oc-thread__viewport`);if(!t)return;if(!e||i===0){t.style.removeProperty(`--oc-dock-pad`);return}let r=()=>t.style.setProperty(`--oc-dock-pad`,`${e.offsetHeight}px`);r();let a=new ResizeObserver(r);return a.observe(e),()=>{a.disconnect(),t.style.removeProperty(`--oc-dock-pad`)}},[i]),e===null||i===0)return null;let{queuedTurns:a,cancelQueued:o,withdrawGatewayQueued:s,canWithdrawGateway:c}=e;return(0,J.jsxs)(`div`,{ref:n,className:`oc-queue-dock`,role:`status`,"aria-label":hm(),children:[a.map(e=>e.gateway===!0?(0,J.jsxs)(`div`,{className:`oc-queue-card oc-queue-card--gateway`,children:[(0,J.jsx)(jA,{size:16,"aria-hidden":!0,className:`oc-queue-card__icon`}),(0,J.jsx)(`span`,{className:`oc-queue-card__text`,title:e.text,children:e.text}),(0,J.jsx)(`span`,{className:`oc-queue-card__state`,children:Mf()}),e.canCancel&&c===!0&&s?(0,J.jsx)(`button`,{type:`button`,className:`oc-queue-card__btn oc-queue-card__btn--danger`,title:Wm(),"aria-label":Wm(),disabled:e.pending,onClick:()=>void s(e.messageId),children:(0,J.jsx)(GC,{size:15})}):null]},e.messageId):(0,J.jsxs)(`div`,{className:`oc-queue-card`,children:[(0,J.jsx)(gA,{size:16,"aria-hidden":!0,className:`oc-queue-card__icon`}),(0,J.jsx)(`span`,{className:`oc-queue-card__text`,title:e.text,children:e.text}),e.mine?(0,J.jsx)(`button`,{type:`button`,className:`oc-queue-card__btn`,title:Dg(),"aria-label":Dg(),disabled:e.pending,onClick:()=>{o(e.messageId).then(n=>{n&&t.composer.setText(e.text)})},children:(0,J.jsx)(LC,{size:15})}):null,e.canCancel?(0,J.jsx)(`button`,{type:`button`,className:`oc-queue-card__btn oc-queue-card__btn--danger`,title:D_(),"aria-label":D_(),disabled:e.pending,onClick:()=>void o(e.messageId),children:(0,J.jsx)(GC,{size:15})}):null]},e.messageId)),r>0?(0,J.jsxs)(`div`,{className:`oc-queue-card oc-queue-card--gateway oc-queue-card--others`,children:[(0,J.jsx)(jA,{size:16,"aria-hidden":!0,className:`oc-queue-card__icon`}),(0,J.jsx)(`span`,{className:`oc-queue-card__text`,children:Pm({count:String(r)})})]}):null]})}var h8=(0,q.createContext)(!1);function g8(e){let t=d6(G.followUp.followUpState,{chatId:e});return t==null||t.projection!==!0?null:{preference:t.preference??null,serverMode:t.serverMode??null,workingUntil:typeof t.workingUntil==`number`?t.workingUntil:null}}function _8({chatId:e,queueSend:t}){let n=g8(e),r=W(G.followUp.setFollowUpMode),i=jV(),a=MV(e=>e.text).trim().length>0,o=o6(n?.preference??null,n?.serverMode??null),s=e=>{if(t===null)return;let n=i.getState().text;n.trim()!==``&&t(n,e).then(e=>{e&&i.setText(``)})},c=o.kind===`queue`?Da():o.kind===`steer`?fe():ag();return(0,J.jsxs)(`div`,{className:`oc-composer__followup`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,disabled:!a||t===null,"aria-label":o.kind===`queue`?Za():o.kind===`steer`?Lh():kx(),title:a?c:Bo(),onClick:()=>s(o.mode),children:(0,J.jsx)(iA,{size:18,"aria-hidden":!0})}),(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-composer__followup-menu`,"aria-label":vo(),title:vo(),children:(0,J.jsx)(XS,{size:14,"aria-hidden":!0})})}),(0,J.jsxs)(fC,{align:`end`,side:`top`,className:`w-64`,children:[(0,J.jsxs)(hC,{disabled:!a,onClick:()=>s(`steer`),children:[(0,J.jsx)(gA,{}),` `,Tt()]}),(0,J.jsxs)(hC,{disabled:!a,onClick:()=>s(`queue`),children:[(0,J.jsx)(BA,{}),` `,Gt()]}),(0,J.jsxs)(hC,{disabled:!a,onClick:()=>s(`interrupt`),children:[(0,J.jsx)(QA,{}),` `,Ec()]}),(0,J.jsx)(gC,{}),(0,J.jsx)(lC,{children:Hb()}),(0,J.jsxs)(rC,{value:n?.preference??`server`,onValueChange:e=>void r({mode:e===`server`?null:e}),children:[(0,J.jsx)(pC,{value:`server`,children:at()}),(0,J.jsx)(pC,{value:`steer`,children:rc()}),(0,J.jsx)(pC,{value:`queue`,children:fx()})]})]})]})]})}function v8({custody:e,messageId:t,canWithdraw:n}){let r=c6(e),i=W(G.followUp.cancelGatewayQueuedInput),a=Mw();if(r===null)return null;let o=r===`queued`?Mf():r===`steered`?Hee():r===`cancelled`?bb():Rd();return(0,J.jsxs)(`span`,{className:`oc-msg__custody oc-msg__custody--${r}`,role:`status`,children:[r===`queued`?(0,J.jsx)(vC,{size:12,"aria-hidden":!0}):r===`steered`?(0,J.jsx)(gA,{size:12,"aria-hidden":!0}):(0,J.jsx)(QA,{size:12,"aria-hidden":!0}),o,r===`queued`&&n?(0,J.jsx)(`button`,{type:`button`,className:`oc-msg__custody-action`,"aria-label":Wm(),onClick:()=>void i({messageId:t}).then(e=>{e.ok||a.error(Kg())},()=>a.error(Kg())),children:Mm()}):null]})}function y8(){let e=$(e=>e.metadata?.custom?.toolParts),t=$(e=>e.metadata?.custom?.status),[n,r]=(0,q.useState)(!1);if(!e||e.length===0)return null;let i=n,a=vX(e,t),o=a.running?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(kC,{size:13,className:`oc-actrow__status-icon oc-actrow__spin`,"aria-hidden":!0}),Xl()]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(YS,{size:13,className:`oc-actrow__status-icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-sr-only`,children:Zc()})]});return(0,J.jsxs)(`div`,{className:`oc-toolact`,children:[(0,J.jsx)(xK,{icon:(0,J.jsx)(yj,{size:14}),label:a.label,trailing:o,open:i,ariaExpanded:i,title:i?wl():hr(),onClick:()=>r(!i)}),i?(0,J.jsx)(`div`,{className:`oc-toolact__detail`,children:e.map(e=>(0,J.jsx)(xX,{toolName:e.toolName,args:e.args,argsText:e.argsText,inputFromTranscript:e.inputFromTranscript,result:e.result,status:e.phase?{type:e.phase}:void 0,turnSettled:t!==void 0&&t!==`streaming`},e.toolCallId))}):null]})}function b8(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function x8(e){if(!b8(e))return null;let t=e.details;if(b8(t)&&typeof t.status==`string`)return t.status;if(typeof e.status==`string`)return e.status;for(let t of[`content`,`contentItems`]){let n=e[t];if(Array.isArray(n)){for(let e of n)if(!(!b8(e)||typeof e.text!=`string`))try{let t=JSON.parse(e.text);if(b8(t)&&typeof t.status==`string`)return t.status}catch{}}}return null}function S8(e,t){if(e!==`completed`)return!1;let n=x8(t);return n===null||n===`yielded`}var C8=18e4,w8=3e4;function T8(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function E8(e){let t=[];for(let n of e){if(n.toolName!==`sessions_spawn`)continue;let e=n.resultDetails?.childSessionKey;if(typeof e==`string`&&e!==``){t.push(e);continue}let r=n.result;if(!T8(r))continue;let i=r.details?.childSessionKey;if(typeof i==`string`&&i!==``){t.push(i);continue}let a=Array.isArray(r.content)?r.content:Array.isArray(r.contentItems)?r.contentItems:null;if(a!==null)for(let e of a){let n=T8(e)?e.text:void 0;if(typeof n==`string`)try{let e=JSON.parse(n),r=T8(e)?e.childSessionKey:void 0;typeof r==`string`&&r!==``&&t.push(r)}catch{}}}return t}var D8=new Set([`sessions_spawn`,`delegate_task`,`mixture_of_agents`]),O8=new Set([`accepted`,`ok`,`started`,`running`]);function k8(e){return e.some(e=>{if(!D8.has(e.toolName))return!1;let t=x8(e.resultDetails??e.result);return t===`error`||t===`forbidden`?!1:E8([e]).length>0?!0:e.phase===`error`?!1:t===null||O8.has(t)})}function A8(e){return e.some(e=>D8.has(e.toolName))}function j8(e){return e.some(e=>{let t=e.result;if(typeof t!=`object`||!t)return!1;let n=t.details;if(typeof n!=`object`||!n)return!1;let r=n;return r.async===!0&&typeof r.taskId==`string`})}function M8(e){return e?.trim()||void 0}function N8(e,t,n,r){let i=e.childRunId;return i===void 0?!1:(r??[]).includes(i)?!0:n!==void 0&&t.some(e=>e.parentMessageId===n&&e.kind!==`task`&&(e.status===`running`||e.status===`done`)&&(f3(e.bornOfRun)?.childRunIds.includes(i)??!1))}function P8(e,t,n,r){let i=e.filter(e=>e.status===`error`&&!N8(e,t,n,r)),a=i[0];return a===void 0?null:{task:NQ(a),reason:$Q(a.errorMessage,a.errorCode,a.runTimeoutSeconds),more:i.length-1}}function F8(e,t,n,r,i=Date.now()){let a=n??[],o=e.hasText||e.hasMedia,s=t.some(e=>e.toolName===`sessions_yield`&&S8(e.phase,e.resultDetails??e.result))&&(k8(t)||j8(t));if(o&&!s||e.status!==`complete`)return{kind:`none`};let c=new Set(E8(t)),l=a.filter(e=>r!==void 0&&e.parentMessageId===r||c.has(e.childSessionKey)),u=l.find(e=>e.status===`running`);if(u)return{kind:`waiting`,taskName:M8(u.taskName)};let d=l.filter(e=>e.kind!==`task`),f=d.find(t=>(t.status===`error`||t.status===`aborted`)&&!N8(t,a,r,e.answeredChildRunIds));if(f)return{kind:`failed`,taskName:M8(f.taskName),reason:$Q(f.errorMessage,f.errorCode,f.runTimeoutSeconds),...f.status===`aborted`&&f.stopRequestedAt===void 0?{cardSilent:!0}:{}};if(o)return{kind:`none`};let p=d.find(e=>e.status===`done`);if(p&&e.projected===!0){let t=t=>t.childRunId!==void 0&&(e.resumedChildRunIds??[]).includes(t.childRunId)||(e.resumedChildKeys??[]).includes(t.childSessionKey),n=d.filter(e=>e.status===`done`);return e.laterUserTurn===!0||n.every(t)?{kind:`none`}:{kind:`composing`,taskName:M8(n.find(e=>!t(e))?.taskName)}}if(p){let t=p.updatedAt+C8;return i<t?{kind:`composing`,taskName:M8(p.taskName),recheckAt:t}:e.delegatedInline===!0?{kind:`none`}:{kind:`done`,taskName:M8(p.taskName),resultText:p.resultText,agentId:kQ(p.childSessionKey)}}if(s&&l.length===0){if(n===void 0)return{kind:`none`};if(e.settledAt!==void 0){let t=e.settledAt+w8;if(i<t)return{kind:`waiting`,recheckAt:t}}}return{kind:`generic`}}function I8(e,t,n){return e===void 0||t===void 0?[]:e.filter(e=>e.parentMessageId===t&&e.kind!==`task`&&e.status===`done`&&typeof e.resultText==`string`&&e.resultText.trim()!==``&&L8(e,n)).slice().sort((e,t)=>e.createdAt-t.createdAt).map(e=>({childSessionKey:e.childSessionKey,agentId:kQ(e.childSessionKey),resultText:e.resultText}))}function L8(e,t){if(t===void 0)return!0;let n=e.childRunId;return t.kind===`batch`?n!==void 0&&t.childRunIds.includes(n):n===void 0||!t.claimed.includes(n)}function R8(e,t){return e===`done`?sm({count:t}):e===`running`?mp({count:t}):Wy({count:t})}function z8({card:e}){let t=e.tone===`running`?kC:e.tone===`failed`?dA:e.tone===`aborted`?pA:YS,n=(0,q.useContext)(r$),r=e.tools?.length??0,i=n?.activeChildKey===e.childSessionKey,a=(0,J.jsxs)(J.Fragment,{children:[r>0?(0,J.jsx)(`span`,{className:`oc-actrow__toolcount`,children:r===1?Tl({count:r}):Dc({count:r})}):null,(0,J.jsx)(t,{size:13,className:`oc-actrow__status-icon${e.tone===`running`?` oc-actrow__spin`:``}`,"aria-hidden":!0})]});return(0,J.jsxs)(`div`,{className:`oc-subagent oc-subagent--${e.tone}${e.moaRole===`moa_reference`?` oc-subagent--nested`:``}`,children:[(0,J.jsx)(xK,{tone:e.tone,icon:e.isTask?(0,J.jsx)(FC,{size:15}):(0,J.jsx)(kS,{size:15}),label:e.isTask?e.label:MQ(e),sublabel:e.isTask?void 0:e.taskName,trailing:a,active:i,ariaExpanded:e.isTask?void 0:i,ariaHasPopup:!e.isTask,title:e.isTask?void 0:B(),ariaLabel:e.isTask?void 0:B(),inert:e.isTask,onClick:()=>{e.isTask||n?.openFor(e.childSessionKey)}}),e.failure?(0,J.jsx)(`p`,{className:`oc-subagent__error`,role:`status`,children:$Q(e.errorMessage,e.errorCode,e.runTimeoutSeconds)}):null]})}var B8=[],V8=[];function H8(){let e=$(e=>e.metadata?.custom?.chatId),t=$(e=>{let t=e.metadata?.custom;return t?.allToolParts??t?.toolParts??B8}),n=(0,q.useMemo)(()=>E8(t),[t]),r=(0,q.useMemo)(()=>A8(t)||j8(t),[t]),i=$(e=>e.metadata?.custom?.messageId),a=$(e=>e.metadata?.custom?.answeredChildRunIds??V8),o=r&&e?e:null,{can:s}=PT(o),c=U(G.subAgents.listSubAgents,o?{chatId:o}:`skip`),[l,u]=(0,q.useState)(!1);if(!r||!s(`subagents`))return null;let d=GQ(c??[],n,i),f=UQ(d),p=[...f.cards];if(p.length===0)return null;let m=WQ(f),h=m.length>0&&!l?P8([...d].sort((e,t)=>t.createdAt-e.createdAt),c??[],i,a):null;return(0,J.jsxs)(`div`,{className:`oc-msg-subagents`,children:[m.length>0?(0,J.jsx)(xK,{icon:(0,J.jsx)(kS,{size:15}),label:KQ(f.total),trailing:m.map(e=>(0,J.jsxs)(`span`,{className:`oc-subagent-badge oc-subagent-badge--${e.tone}`,title:R8(e.tone,e.count),"aria-label":R8(e.tone,e.count),children:[e.tone===`done`?(0,J.jsx)(YS,{size:12,"aria-hidden":!0}):e.tone===`running`?(0,J.jsx)(kC,{size:12,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(dA,{size:12,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-subagent-badge__count`,children:e.count})]},e.tone)),open:l,ariaExpanded:l,title:l?wl():hr(),onClick:()=>u(!l)}):null,h?(0,J.jsxs)(`p`,{className:`oc-subagent__error`,role:`status`,children:[yg({task:h.task,reason:h.reason}),h.more>0?` ${qf({count:String(h.more)})}`:null]}):null,(m.length===0||l)&&p.map(e=>(0,J.jsx)(`div`,{className:`oc-msg-subagents__anchor`,"data-subagent-id":e.id,"data-subagent-failed":e.failure?``:void 0,children:(0,J.jsx)(z8,{card:e})},e.id))]})}function U8(){return $(e=>e.metadata?.custom?.compaction??null)}function W8(e){switch(e){case`overflow`:return Cy();case`manual`:return E();case`heap_threshold`:case`rss_threshold`:case`pre_compaction`:case`non_manual_trigger`:return zp();case`already_active`:case`already_in_flight`:case`deferred_compaction_not_scheduled`:case`unsupported_harness_compaction`:return os();default:return``}}function G8(){let e=U8();if(!e)return null;let t=e.phase===`failed`,n=`${t?u_():e.phase===`midturn`?lh():rf()}${W8(e.reason)}`;return(0,J.jsx)($C,{delayDuration:150,children:(0,J.jsxs)(ew,{children:[(0,J.jsx)(ZC,{asChild:!0,children:(0,J.jsxs)(`div`,{className:`oc-compaction${t?` oc-compaction--failed`:``}`,role:`note`,"aria-label":n,children:[(0,J.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0}),(0,J.jsxs)(`span`,{className:`oc-compaction__label`,children:[(0,J.jsx)(TA,{size:12,"aria-hidden":!0}),t?Av():yee()]}),(0,J.jsx)(`span`,{className:`oc-compaction__rule`,"aria-hidden":!0})]})}),(0,J.jsx)(QC,{className:`oc-compaction__tip`,children:n})]})})}var K8=new Set([`widget`,`commentary`,`thinking`]);function q8(e,t){return e&&!SQ(t)&&!t.some(e=>e?.type===`file`||e?.type===`data`&&K8.has(e.name))}var J8=/^(?:[a-z0-9][a-z0-9_.]{0,15}-)?[a-z0-9]{25,40}$/;function Y8(e){let t=e.trim();return J8.test(t)?t:null}function X8(e){return e.readOnly?`read_only`:e.unavailable?`unavailable`:e.degraded?`degraded`:e.beyondValidated?`beyond_validated`:null}function Z8(e){return e.turnRunning?{mode:`queue`,reason:`turn`}:e.hasRunningSubAgent?{mode:`queue`,reason:`subagent`}:{mode:`send`,reason:null}}function Q8(e,t,n){return t===`pending`?wf({name:e}):t===`gone`?Pee({name:e}):n===`too_large`?db({name:e}):n===`media_disabled`?Md({name:e}):n===`remote_source`?Em({name:e}):ree({name:e})}function $8({mimeType:e,data:t,filename:n,storageId:r,unavailable:i,reason:a}){let o=e??``,s=t??``,c=n??`attachment`;return i===void 0?s?o.startsWith(`audio/`)?(0,J.jsxs)(`div`,{className:`oc-media oc-media--audio`,children:[(0,J.jsx)(`audio`,{controls:!0,preload:`metadata`,src:s,className:`oc-media__audio`,children:(0,J.jsx)(`a`,{href:s,download:c,children:nx()})}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:c})]}):o.startsWith(`image/`)?(0,J.jsx)(r5,{url:s,name:c}):o.startsWith(`video/`)?(0,J.jsxs)(`div`,{className:`oc-media oc-media--video`,children:[(0,J.jsx)(`video`,{controls:!0,preload:`metadata`,src:s,className:`oc-media__video`}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:c})]}):(0,J.jsx)(e5,{url:s,name:c,mime:o,storageId:r}):null:(0,J.jsxs)(`div`,{className:`oc-media oc-media--unavailable oc-media--${i}`,role:`note`,children:[(0,J.jsx)(FA,{className:`oc-media__icon`,"aria-hidden":`true`}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:Q8(c,i,a)})]})}function e5({url:e,name:t,mime:n,storageId:r}){let i=Vq(),a=gq(n,t)!==`none`,o=!!r&&mq(n,t),s=a||o,c=n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0||(n.preventDefault(),(async()=>{try{let n=await fetch(e);if(!n.ok)throw Error(`HTTP ${n.status}`);let r=URL.createObjectURL(await n.blob()),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),3e4)}catch{let t=window.open(``,`_blank`);t?(t.opener=null,t.location.href=e):window.location.href=e}})())};return(0,J.jsxs)(`span`,{className:`oc-media oc-media--file oc-filechip`,title:t,children:[(0,J.jsxs)(`a`,{className:`oc-filechip__main`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,"aria-label":Vs({name:t}),children:[(0,J.jsx)(`span`,{className:`oc-media__icon`,"aria-hidden":!0,children:`📄`}),(0,J.jsx)(`span`,{className:`oc-media__name`,children:t})]}),(0,J.jsx)(`a`,{className:`oc-filechip__btn`,href:e,target:`_blank`,rel:`noopener noreferrer`,onClick:c,title:Vs({name:t}),"aria-label":Vs({name:t}),children:(0,J.jsx)(xC,{size:14,"aria-hidden":!0})}),s?(0,J.jsx)(`button`,{type:`button`,className:`oc-filechip__btn`,onClick:()=>i.openFor({url:e,filename:t,mimeType:n||null,storageId:r,sourceStorageId:o?r:void 0}),title:Rg({name:t}),"aria-label":Rg({name:t}),children:(0,J.jsx)(rA,{size:14,"aria-hidden":!0})}):null,r?(0,J.jsx)(t5,{storageId:r,name:t}):null]})}function t5({storageId:e,name:t}){let[n,r]=(0,q.useState)(!1),i=$(e=>e.id),a=U(G.files.metadata,n&&i?{storageId:e,messageId:i}:`skip`),o=ft();return(0,J.jsxs)(bw,{open:n,onOpenChange:r,children:[(0,J.jsx)(yw,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-filechip__btn`,title:Jb({name:t}),"aria-label":Jb({name:t}),children:(0,J.jsx)(FA,{size:14,"aria-hidden":!0})})}),(0,J.jsxs)(vw,{side:`top`,align:`end`,className:`oc-filemeta`,children:[(0,J.jsx)(`div`,{className:`oc-filemeta__title`,children:gf()}),a===void 0?(0,J.jsx)(`div`,{className:`oc-filemeta__note`,children:zf()}):a===null?(0,J.jsx)(`div`,{className:`oc-filemeta__note`,children:fg()}):(0,J.jsxs)(`dl`,{className:`oc-filemeta__rows`,children:[(0,J.jsx)(n5,{label:kee(),value:k3(a.filename)??a.filename}),(0,J.jsx)(n5,{label:ib(),value:a.contentType??Iy()}),(0,J.jsx)(n5,{label:Ed(),value:`${zT(a.bytes,o)} (${bm({count:RT(a.bytes,o)})})`}),(0,J.jsx)(n5,{label:Ng(),value:a.direction===`inbound`?Eee():Qp()}),(0,J.jsx)(n5,{label:op(),value:new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(a.createdAt))}),BT(a.sha256)?(0,J.jsxs)(`div`,{className:`oc-filemeta__row oc-filemeta__row--digest`,children:[(0,J.jsx)(`dt`,{children:Bm()}),(0,J.jsxs)(`dd`,{children:[(0,J.jsx)(`code`,{className:`oc-filemeta__digest`,children:BT(a.sha256)}),(0,J.jsx)(`button`,{type:`button`,className:`oc-filemeta__copy`,title:Wv(),"aria-label":Wv(),onClick:()=>{navigator.clipboard?.writeText(BT(a.sha256)??``)},children:(0,J.jsx)(bC,{size:12,"aria-hidden":!0})})]})]}):null]})]})]})}function n5({label:e,value:t}){return(0,J.jsxs)(`div`,{className:`oc-filemeta__row`,children:[(0,J.jsx)(`dt`,{children:e}),(0,J.jsx)(`dd`,{children:t})]})}function r5({url:e,name:t}){let{open:n}=nJ();return(0,J.jsx)(`button`,{type:`button`,className:`oc-media oc-media--thumb`,onClick:()=>n({url:e,name:t}),title:t,"aria-label":t,children:(0,J.jsx)(`img`,{src:e,alt:t,className:`oc-media__thumbimg`,loading:`lazy`,decoding:`async`})})}function i5(e,t,n=!1){let r=e.closest(`.oc-msg`)?.querySelector(`.oc-msg__source-pre`),i=r?.textContent;return r&&i!=null&&i!==`(aucun texte)`?{displayedText:n?t:i,sourceWasOpen:!0}:{displayedText:t,sourceWasOpen:!1}}var a5=1e3;function o5(){return[{id:`incorrect`,label:Cd()},{id:`incoherence`,label:_m()},{id:`altered_words`,label:Im()},{id:`formatting`,label:kg()},{id:`latency`,label:Cee()},{id:`api_error`,label:Yp()},{id:`other`,label:rp()}]}function s5(){return[{id:`altered_words`,label:Ny()},{id:`formatting`,label:lg()},{id:`other`,label:rp()}]}function c5(e){return e===`user`?s5():o5()}var l5=[{name:`Grammarly`,selector:`grammarly-desktop-integration, grammarly-extension, [data-grammarly-shadow-root]`},{name:`LanguageTool`,selector:`[data-lt-installed], .lt-toolbar`},{name:`DeepL`,selector:`deepl-inline-translate, .deepl-translator`},{name:`ProWritingAad`,selector:`pwa-shadow-host, .pwa-tag`}];function u5(){let e=[];try{e=Array.from(navigator.plugins??[]).map(e=>e.name).slice(0,40)}catch{e=[]}let t=[];for(let{name:e,selector:n}of l5)try{document.querySelector(n)&&t.push(e)}catch{}return{plugins:e,extensionsDetected:t}}var d5=q.createContext(null);function f5(){let e=q.useContext(d5);if(!e)throw Error(`useFeedback must be used within <FeedbackProvider>`);return e}function p5({children:e}){let t=W(G.feedback.submitFeedback),[n,r]=(0,q.useState)(null),[i,a]=(0,q.useState)(``),[o,s]=(0,q.useState)(``),[c,l]=(0,q.useState)(!1),[u,f]=(0,q.useState)(null),[p,m]=(0,q.useState)(null),[h,g]=(0,q.useState)(!1),_=q.useCallback(e=>{a(``),s(``),l(!1),f(null),m(null),g(!1),r(e)},[]);function v(e){e||r(null)}async function y(){if(!(!n||!i||c)){l(!0);try{let e=await t({chatId:n.chatId,messageId:n.messageId,category:i,comment:o.trim()||void 0,client:{displayedText:n.displayedText,sourceWasOpen:n.sourceWasOpen,userAgent:navigator.userAgent,language:navigator.language,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,theme:document.documentElement.classList.contains(`dark`)?`dark`:`light`,...u5()}});f(e.displayedMatchesStored),m(String(e.reference??e.feedbackId))}catch{l(!1)}}}let b=u!==null,x=n?.role===`user`;return(0,J.jsxs)(d5.Provider,{value:_,children:[e,(0,J.jsx)($w,{open:n!==null,onOpenChange:v,children:n?(0,J.jsxs)(Xw,{className:`sm:max-w-md`,children:[(0,J.jsxs)(Jw,{children:[(0,J.jsx)(Zw,{children:If()}),(0,J.jsx)(Qw,{children:b?Vv():x?lee():Wd()})]}),b?(0,J.jsxs)(`div`,{className:`oc-feedback__result`,role:`status`,children:[n.sourceWasOpen?u===!0?(0,J.jsx)(`p`,{className:`oc-feedback__fidelity is-ok`,children:Zm()}):(0,J.jsx)(`p`,{className:`oc-feedback__fidelity is-warn`,children:vv()}):(0,J.jsx)(`p`,{className:`oc-feedback__fidelity`,children:Qg()}),p?(0,J.jsxs)(`div`,{className:`oc-feedback__ref`,children:[(0,J.jsx)(`span`,{className:`oc-feedback__ref-label`,children:zn()}),(0,J.jsx)(`code`,{className:`oc-feedback__ref-id`,title:p,children:p}),(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Gl(),"aria-label":Gl(),onClick:()=>{navigator.clipboard.writeText(p).then(()=>{g(!0),window.setTimeout(()=>g(!1),1500)})},children:h?(0,J.jsx)(YS,{size:14}):(0,J.jsx)(bC,{size:14})})]}):null]}):(0,J.jsxs)(`div`,{className:`oc-feedback__form`,children:[(0,J.jsx)(`label`,{className:`oc-feedback__label`,children:uy()}),(0,J.jsxs)(aw,{value:i,onValueChange:a,children:[(0,J.jsx)(nw,{children:(0,J.jsx)(tw,{placeholder:Ep()})}),(0,J.jsx)(rw,{children:c5(n.role).map(e=>(0,J.jsx)(iw,{value:e.id,children:e.label},e.id))})]}),(0,J.jsx)(`label`,{className:`oc-feedback__label`,htmlFor:`oc-feedback-comment`,children:d()}),(0,J.jsx)(`textarea`,{id:`oc-feedback-comment`,className:`oc-feedback__textarea`,placeholder:Go(),value:o,maxLength:a5,onChange:e=>s(e.target.value.slice(0,a5)),rows:4}),(0,J.jsxs)(`div`,{className:`oc-feedback__count`,children:[o.length,`/`,a5]})]}),(0,J.jsx)(Yw,{children:b?(0,J.jsx)(K,{onClick:()=>v(!1),children:$u()}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{variant:`outline`,onClick:()=>v(!1),children:tu()}),(0,J.jsx)(K,{onClick:()=>void y(),disabled:!i||c,children:c?Eu():Hr()})]})})]}):null})]})}function m5(){let e=f5(),t=$(e=>z3(e.metadata?.custom)),n=$(e=>e.metadata?.custom?.chatId),r=$(e=>e.role),i=$(e=>e.metadata?.custom?.groupText??e.metadata?.custom?.rawText??``),a=$(e=>(e.metadata?.custom?.groupText??null)!==null),o=U(G.feedback.myReportedMessageIds,n?{chatId:n}:`skip`);if(!t||!n)return null;let s=(o??[]).includes(t);function c(o){let s=i5(o.currentTarget,i,a);e({chatId:n,messageId:t,role:r,...s})}return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn${s?` is-on`:``}`,title:s?U_():pi(),"aria-label":bn(),onClick:c,children:(0,J.jsx)(wA,{size:15,"aria-hidden":!0})})}function h5(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function g5({label:e,state:t,destructive:n,disabled:r,disabledHint:i,onClick:a,onRetry:o}){return(0,J.jsxs)(`div`,{className:`oc-spanel__action`,children:[(0,J.jsxs)(K,{variant:n?`destructive`:`outline`,size:`sm`,disabled:t===`pending`||r===!0,onClick:a,children:[t===`pending`?(0,J.jsx)(kC,{className:`oc-spanel__spin`,"aria-hidden":!0}):null,e]}),t===`done`?(0,J.jsx)(`p`,{className:`oc-spanel__action-note`,role:`status`,children:uf()}):null,t===`error`?(0,J.jsxs)(`p`,{className:`oc-spanel__error`,role:`alert`,children:[hh(),(0,J.jsx)(`button`,{type:`button`,className:`oc-spanel__retry`,onClick:o,children:Le()})]}):null,r===!0&&i?(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:i}):null]})}function _5({chatId:e,open:t,onOpenChange:n}){let r=U(G.messages.getSessionMeta,t?{chatId:e}:`skip`),i=U(G.chatSummaries.getChatSummary,t?{chatId:e}:`skip`),a=U(G.agents.getChatAgent,t?{chatId:e}:`skip`),o=(U(G.messages.getStreamingText,t?{chatId:e}:`skip`)?.length??0)>0,s=r?.sessionMeta??null,c=r?.sessionSettings??null,{can:l}=PT(t?e:null),u=fT(),d=pa(G.agentFiles.compactSession),f=W(G.chats.resetSession),p=W(G.chatSummaries.requestSummarize),[m,h]=(0,q.useState)(`idle`),[g,_]=(0,q.useState)(`idle`),[v,y]=(0,q.useState)(`idle`),[x,S]=(0,q.useState)(null),[C,w]=(0,q.useState)(null),[T,E]=(0,q.useState)(!1),[D,O]=(0,q.useState)(!1),[k,A]=(0,q.useState)(null),[j,M]=(0,q.useState)(`idle`),N=W(G.chatSummaries.updateSummary);(0,q.useEffect)(()=>{A(null),M(`idle`),O(!1),E(!1),S(null),y(`idle`),w(null),_(`idle`)},[e]);async function P(){if(i?.summary)try{await navigator.clipboard.writeText(i.summary),E(!0),window.setTimeout(()=>E(!1),2e3)}catch{}}async function F(){if(!(k===null||k.trim().length===0)){M(`saving`);try{await N({chatId:e,summary:k}),A(null),M(`idle`)}catch{M(`error`)}}}let[I,L]=(0,q.useState)(()=>Date.now()),R=i?.jobInFlight===!0;(0,q.useEffect)(()=>{if(!R)return;let e=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(e)},[R]);async function ee(){h(`pending`);try{await d({chatId:e}),h(`done`)}catch{h(`error`)}}async function z(){y(`pending`),S(null);try{let{outcome:t}=await p({chatId:e});S(({dispatched:gl,in_flight:je,nothing_to_do:Ox,scanning:Zs,bridge_outdated:F_,engine_off:ks,no_agent:$i,backoff:Ox}[t]??Ox)()),y(t===`dispatched`||t===`scanning`?`done`:`idle`)}catch{y(`error`)}}async function B(){_(`pending`),w(null);try{let t=await f({chatId:e});if(t!==void 0&&t.ok===!1){_(`idle`),w(T_());return}_(`done`)}catch{_(`error`)}}async function V(){await u({title:z_(),description:dm(),confirmLabel:vp(),cancelLabel:yr()})&&await ee()}async function te(){await u({title:wg(),description:Qf(),confirmLabel:ry(),cancelLabel:yr(),destructive:!0})&&await B()}let ne=TT(s),re=NT(s),ie=CT(ne??void 0,re??void 0),ae=ie==null?``:ie>=90?`is-critical`:ie>=75?`is-warn`:`is-ok`,oe=MT(ne??void 0,re??void 0),se=FT(s),ce=wT(s?.estimatedCostUsd,s?.totalTokens),le=a?.agent??null,ue=OT([le?le.displayName??le.agentId:null,s?.agentRuntime,s?.model]);return(0,J.jsx)(_T,{open:t,onOpenChange:n,children:(0,J.jsxs)(yT,{side:`right`,className:`oc-spanel`,children:[(0,J.jsxs)(vT,{children:[(0,J.jsx)(bT,{children:Xa()}),(0,J.jsx)(gT,{children:Ea()})]}),(0,J.jsx)(`div`,{className:`oc-spanel__body`,children:r===void 0?(0,J.jsx)(`p`,{className:`oc-spanel__loading`,children:fc()}):(0,J.jsxs)(J.Fragment,{children:[r===null?null:(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:Ih()}),(0,J.jsx)(jT,{chatId:e,sm:s,settings:c})]}),(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:de()}),oe!==null&&ie!==null?(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:Tc()}),(0,J.jsxs)(`span`,{className:`oc-meter oc-spanel__meter ${ae}`,children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(ie,100)}%`}})}),(0,J.jsx)(`span`,{className:`oc-meter__label`,children:oe})]})]}):null,se===null?null:(0,J.jsx)(`p`,{className:`oc-spanel__help oc-spanel__help--warn`,children:se===`compaction_failed`?it():Vb()}),(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:dx()}),(0,J.jsx)(`span`,{className:`oc-spanel__value`,children:ET(s?.verboseLevel)}),(0,J.jsx)(`p`,{className:`oc-spanel__help`,children:Vee()})]}),ce===null?null:(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:yb()}),(0,J.jsx)(`span`,{className:`oc-spanel__value`,children:ce})]})]}),ue!==null||s?(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:wt()}),(0,J.jsxs)(`dl`,{className:`oc-spanel__kv`,children:[le?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:cd()}),(0,J.jsxs)(`dd`,{children:[le.emoji?`${le.emoji} `:``,le.displayName??le.agentId]})]}):null,le?.instanceName?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:ig()}),(0,J.jsx)(`dd`,{children:le.instanceName})]}):null,s?.model?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:Cm()}),(0,J.jsx)(`dd`,{children:s.model})]}):null,s?.modelProvider?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:Hm()}),(0,J.jsx)(`dd`,{children:s.modelProvider})]}):null,s?.agentRuntime?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:b()}),(0,J.jsx)(`dd`,{children:s.agentRuntime})]}):null,s?.thinkingLevel?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:Ig()}),(0,J.jsx)(`dd`,{children:s.thinkingLevel})]}):null,s?.thinkingDefault?(0,J.jsxs)(`div`,{className:`oc-spanel__kv-row`,children:[(0,J.jsx)(`dt`,{children:_o()}),(0,J.jsx)(`dd`,{children:s.thinkingDefault})]}):null]})]}):null,(0,J.jsxs)(`section`,{children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:ki()}),i?(0,J.jsxs)(`div`,{className:`oc-spanel__static`,children:[(0,J.jsx)(`span`,{className:`oc-spanel__label`,children:ln()}),(0,J.jsxs)(`span`,{className:`oc-meter oc-spanel__meter is-ok`,children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(i.pendingChars/Math.max(i.thresholdChars,1)*100,100)}%`}})}),(0,J.jsx)(`span`,{className:`oc-meter__label`,children:No({pending:`${h5(i.pendingChars)}${i.pendingApprox?`+`:``}`,threshold:h5(i.thresholdChars)})})]})]}):null,i&&!i.jobInFlight&&i.pendingChars>=i.thresholdChars?(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:Wa()}):null,i?.jobInFlight?(0,J.jsxs)(`p`,{className:`oc-spanel__hint oc-spanel__job`,role:`status`,children:[(0,J.jsx)(kC,{size:13,className:`oc-spanel__job-spin`,"aria-hidden":!0}),i.jobStreaming?Df():ax(),i.jobStartedAt?` · ${Math.max(0,Math.round((I-i.jobStartedAt)/1e3))} s`:``]}):null,i&&i.summary.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`p`,{className:`oc-spanel__hint`,children:[Ln({count:String(i.coveredCount),date:Kw(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}),i.lastAgentId?` ${Nr({agent:i.lastInstanceName?`${i.lastAgentId} (${i.lastInstanceName})`:i.lastAgentId})}`:``]}),i.failureCount>0?(0,J.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:Hl({count:String(i.failureCount)})}):null,(0,J.jsxs)(`div`,{className:`oc-spanel__summary-tools`,children:[(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>void P(),title:Sx(),"aria-label":Sx(),children:T?(0,J.jsx)(YS,{size:14,"aria-hidden":!0}):(0,J.jsx)(bC,{size:14,"aria-hidden":!0})}),(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>O(!0),title:mb(),"aria-label":mb(),children:(0,J.jsx)(WA,{size:14,"aria-hidden":!0})}),i.jobInFlight?null:(0,J.jsx)(K,{variant:`ghost`,size:`sm`,className:`oc-spanel__summary-tool`,onClick:()=>{A(i.summary),O(!0)},title:Pd(),"aria-label":Pd(),children:(0,J.jsx)(LC,{size:14,"aria-hidden":!0})})]}),(0,J.jsx)(`div`,{className:`oc-spanel__summary`,children:i.summary})]}):i&&i.failureCount>0?(0,J.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:Hl({count:String(i.failureCount)})}):i?.jobInFlight?null:(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:Wc()})]})]})}),(0,J.jsx)($w,{open:D,onOpenChange:e=>{O(e),e||(A(null),M(`idle`))},children:(0,J.jsxs)(Xw,{className:`oc-summary-dialog`,children:[(0,J.jsxs)(Jw,{children:[(0,J.jsx)(Zw,{children:ki()}),(0,J.jsx)(Qw,{children:k===null?i&&i.summary.length>0?Ln({count:String(i.coveredCount),date:Kw(i.updatedAt,{dateStyle:`short`,timeStyle:`short`})}):``:Vg()})]}),k===null?(0,J.jsx)(`div`,{className:`oc-summary-dialog__body`,children:i?.summary??``}):(0,J.jsx)(`textarea`,{className:`oc-summary-dialog__body oc-summary-dialog__edit`,value:k,onChange:e=>A(e.target.value)}),j===`error`?(0,J.jsx)(`p`,{className:`oc-spanel__hint oc-spanel__hint--warn`,children:aee()}):null,(0,J.jsx)(`div`,{className:`oc-summary-dialog__actions`,children:k===null?(0,J.jsxs)(J.Fragment,{children:[i&&i.summary.length>0&&!i.jobInFlight?(0,J.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>A(i.summary),children:[(0,J.jsx)(LC,{size:14,"aria-hidden":!0}),Pd()]}):null,(0,J.jsxs)(K,{variant:`outline`,size:`sm`,onClick:()=>void P(),children:[T?(0,J.jsx)(YS,{size:14,"aria-hidden":!0}):(0,J.jsx)(bC,{size:14,"aria-hidden":!0}),Sx()]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(K,{variant:`ghost`,size:`sm`,onClick:()=>{A(null),M(`idle`)},children:yr()}),(0,J.jsx)(K,{size:`sm`,disabled:k.trim().length===0||j===`saving`,onClick:()=>void F(),children:j===`saving`?mr():Om()})]})})]})}),(0,J.jsxs)(hT,{className:`oc-spanel__actions`,children:[(0,J.jsx)(`h3`,{className:`oc-spanel__cat`,children:Wt()}),l(`sessionCompact`)?(0,J.jsx)(g5,{label:Gg(),state:m,onClick:()=>void V(),onRetry:()=>void ee()}):null,(0,J.jsx)(g5,{label:sr(),state:R?`pending`:v,onClick:()=>void z(),onRetry:()=>void z()}),x===null?null:(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:x}),(0,J.jsx)(g5,{label:Yy(),state:g,destructive:!0,disabled:o,disabledHint:T_(),onClick:()=>void te(),onRetry:()=>void B()}),!o&&C!==null?(0,J.jsx)(`p`,{className:`oc-spanel__hint`,children:C}):null]})]})})}function v5(e){let t=null;for(let n of e)(t===null||n.createdAt>=t.createdAt)&&(t=n);return t===null?{kind:`bottom`}:{kind:`bookmark`,messageId:t.messageId,blockIndex:t.blockIndex}}var y5=class{last=-1;stable=0;observe(e){return e===this.last?(this.stable+=1,this.stable>=3):(this.last=e,this.stable=0,!1)}};function b5(e){if(e.kind===`bottom`)return Math.max(0,e.scrollHeight-e.clientHeight);if(e.anchorDelta===void 0)return null;let t=Math.max(24,e.clientHeight*.3);return Math.max(0,e.scrollTop+e.anchorDelta-t)}function x5(e,t,n=()=>performance.now()){let r=n(),i=new y5,a=0,o=!1,s=()=>{o||(o=!0,a&&cancelAnimationFrame(a),a=0,e.removeAttribute(`data-oc-landing`))},c=()=>{if(t.kind!==`bookmark`)return;let n=e.querySelector(`[data-message-id="${CSS.escape(t.messageId)}"]`);if(n)return(t.blockIndex===null?n:n.querySelector(`[data-block-index="${t.blockIndex}"]`)??n).getBoundingClientRect().top-e.getBoundingClientRect().top},l=()=>{if(o)return;let u=b5({kind:t.kind,scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,anchorDelta:c()});if(u!==null&&(e.scrollTop=u),u!==null&&i.observe(e.scrollHeight)||n()-r>=1200){s();return}a=requestAnimationFrame(l)};return a=requestAnimationFrame(l),s}function S5(e){let t=oK()?.rows;(0,q.useEffect)(()=>{if(!e.ready||e.focusMessageId)return;let n=document.querySelector(`.oc-thread__viewport`);if(!n)return;n.setAttribute(`data-oc-landing`,``);let r=x5(n,v5(t??[]));return()=>{r()}},[e.chatId,e.ready,e.focusMessageId])}var C5=[`read-only`,`guarded`,`workspace`,`full`],w5=[`admin`,`owner`,`member`,`viewer`];function T5(e){return typeof e==`string`&&C5.includes(e)}function E5(e){return typeof e==`string`&&w5.includes(e)}function D5(e){switch(e){case`admin`:return u();case`owner`:return Wo();case`member`:return Qu();case`viewer`:return eu()}}function O5(e){let t=e?.visibility;if(t!==`read-only`&&t!==`suggest`&&t!==`draft`)return null;let n=e?.sharingRole,r=E5(n)?n:null,[i,a]=t===`read-only`?[dee(),bv()]:t===`suggest`?[Kd(),$g()]:[$m(),fy()],o=[a];return r!==null&&o.push(Op({role:D5(r)})),{visibility:t,role:r,label:i,title:o.join(`
151
+ `)}}var k5=`https://docs.openclaw.ai/gateway/permission-modes`,A5=[`default`,`read-only`,`guarded`,`workspace`,`full`];function j5(e){return typeof e==`string`&&A5.includes(e)}function M5(e){switch(e){case`read-only`:return`ellipsis`;case`guarded`:return`lock`;case`workspace`:return`cog`;case`full`:return`alert`;default:return`check`}}function N5(e){switch(e){case`read-only`:return il();case`guarded`:return qee();case`workspace`:return Ui();case`full`:return Qt()}}function P5(e){switch(e){case`read-only`:return ye();case`guarded`:return vs();case`workspace`:return Sr();case`full`:return Co()}}function F5(e,t){return e==="default"?t===null?Al():Mc({mode:N5(t)}):N5(e)}function I5(e){switch(e){case`scope_refused`:return qb();case`active_run`:return hf();case`unsupported_gateway`:return vx();case`full_not_authorized`:return rb();case`session_not_established`:return Td();case`bridge_unreachable`:return ym();case`no_agent`:return zm();case`not_managed`:return dg();case`reapply_exhausted`:return Rf();default:return Mg()}}function L5(e){let t=T5(e.agentDefault)?e.agentDefault:null,n=T5(e.sessionMode)?e.sessionMode:`default`,r=e.managed?e.choice??`default`:n,i=F5(r,t),a=r===`full`||r==="default"&&t===`full`,o=e.viewerRole===`owner`,s=e.viewerRole===void 0||e.target===`hermes`&&!e.multiAgent&&e.choice===null||e.target===`unknown`&&e.choice===null&&!T5(e.sessionMode)&&e.sessionMode!==null,c=e.choice!==null&&e.apply!==null&&e.apply.mode===e.choice&&e.apply.status===`pending`||e.sessionModePending,l=null;e.anyManaged?o?e.target===`unknown`?l=lt():e.target===`unsupported`?l=no():e.target===`hermes`&&!e.multiAgent&&(l=L()):l=bh():l=ap();let u=l!==null,d=A5.map((n,i)=>{let a=n===`full`&&!e.viewerIsAdmin;return{value:n,label:F5(n,t),description:n==="default"?Yn():P5(n),icon:M5(n),shortcut:i+1,selected:n===r,disabled:u||c||a,disabledReason:a?ua():null}}),f=null,p=!1;o&&e.choice===`full`&&!e.viewerIsAdmin?(f=Tee(),p=!0):e.choice!==null&&e.apply!==null&&e.apply.mode===e.choice&&(e.apply.status===`failed`?(f=Bs({reason:I5(e.apply.reason)}),p=!0):e.apply.status===`deferred`?f=Tb():e.apply.status===`applied`&&e.apply.reason===`saved_not_applied`&&(f=He()));let m=[`${q_()}: ${i}`];m.push(l??_i()),e.multiAgent&&m.push(kt()),e.target===`hermes`&&e.multiAgent&&m.push(Hh()),e.anyManaged&&!e.managed&&e.target!==`hermes`&&m.push(Fy()),a&&m.push(Zp()),c&&m.push(lc()),f!==null&&m.push(f),e.sessionRoot&&m.push(Uv({root:e.sessionRoot}));let h=c?lc():e.target===`hermes`&&e.multiAgent?Hh():e.anyManaged&&!e.managed&&e.target!==`hermes`?Fy():null;return{hidden:s,current:r,label:i,icon:M5(r),alert:a,pending:c,locked:u,lockReason:l,note:h,status:f,statusIsError:p,title:m.join(`
152
+ `),ariaLabel:Na({label:q_(),mode:i}),items:d}}function R5(e,t){if(!/^[1-5]$/.test(e))return null;let n=t.find(t=>t.shortcut===Number(e));return n&&!n.disabled?n.value:null}function z5(e,t,n){let r=t.items.find(t=>t.value===e);return!r||r.disabled?!1:e!==n}function B5({size:e=14}){return(0,J.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:e,height:e,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,J.jsx)(`path`,{d:`M20 9.807V6a1 1 0 0 0-1-1c-2 0-4.49-1.19-6.24-2.72a1.17 1.17 0 0 0-1.52 0C9.5 3.8 7 5 5 5a1 1 0 0 0-1 1v7c0 3.88 2.107 6.254 5 7.796`}),(0,J.jsx)(`path`,{d:`M19 17v-2a2 2 0 0 0-4 0v2`}),(0,J.jsx)(`rect`,{x:`13`,y:`17`,width:`8`,height:`5`,rx:`1`})]})}function V5({icon:e,size:t=14}){switch(e){case`ellipsis`:return(0,J.jsx)(lj,{size:t,"aria-hidden":!0});case`lock`:return(0,J.jsx)(B5,{size:t});case`cog`:return(0,J.jsx)(uj,{size:t,"aria-hidden":!0});case`alert`:return(0,J.jsx)(cj,{size:t,"aria-hidden":!0});default:return(0,J.jsx)(VC,{size:t,"aria-hidden":!0})}}function H5(e,t,n){let r=U(G.permissionMode.permissionControl,{chatId:e,...t?{routedAgent:t}:{}}),i=U(G.messages.getSessionMeta,{chatId:e}),a=PT(e,t),o=W(G.permissionMode.setPermissionMode),s=Mw(),c=(0,q.useCallback)(t=>{o({chatId:e,mode:t}).catch(e=>{s.error(Bs({reason:Mg()}),e)})},[e,o,s]);if(r==null)return null;let l=a.loading||!a.resolved?`unknown`:a.provider===`hermes`?`hermes`:a.can(`permissionModes`)?`openclaw`:`unsupported`,u=i?.sessionMeta??null,d=j5(r.choice)?r.choice:null,f=L5({viewerRole:r.viewerRole,viewerIsAdmin:r.viewerIsAdmin,choice:d,apply:r.apply,sessionMode:u?.permissionMode,sessionModePending:u?.permissionModePending===!0,sessionRoot:typeof u?.sessionRoot==`string`?u.sessionRoot:null,agentDefault:r.agentDefault,target:l,multiAgent:n,managed:r.managed,anyManaged:r.anyManaged});return{view:f,choice:d,pick:e=>{z5(e,f,d)&&c(e)}}}function U5({item:e}){return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(V5,{icon:e.icon})}),(0,J.jsxs)(`span`,{className:`oc-perm__opt-copy`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:e.label}),(0,J.jsx)(`span`,{className:`oc-perm__opt-desc`,children:e.description}),e.disabledReason===null?null:(0,J.jsx)(`span`,{className:`oc-perm__opt-reason`,children:e.disabledReason})]}),(0,J.jsx)(`span`,{className:`oc-perm__opt-state`,"aria-hidden":!0,children:e.selected&&e.disabledReason===null?(0,J.jsx)(YS,{size:14}):e.disabledReason===null?(0,J.jsx)(`span`,{className:`oc-perm__shortcut`,children:e.shortcut}):(0,J.jsx)(AC,{size:13})})]})}function W5(){return(0,J.jsxs)(`div`,{className:`oc-perm__heading`,children:[(0,J.jsx)(`span`,{children:q_()}),(0,J.jsx)(`a`,{className:`oc-perm__learn`,href:k5,target:`_blank`,rel:`noopener noreferrer`,children:wn()})]})}function G5({chatId:e,routedAgent:t,multiAgent:n}){let r=H5(e,t,n),[i,a]=(0,q.useState)(!1);if(r===null||r.view.hidden)return null;let{view:o,pick:s}=r;return(0,J.jsxs)(_C,{open:i,onOpenChange:a,children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__perm${o.alert?` is-alert`:``}${o.pending?` is-pending`:``}${r.choice===null?` is-default`:``}`,title:o.title,"aria-label":o.ariaLabel,"data-permission-mode":o.current,children:[(0,J.jsx)(V5,{icon:o.icon,size:15}),(0,J.jsx)(`span`,{className:`oc-composer__perm-label`,children:o.label}),(0,J.jsx)(XS,{size:13,"aria-hidden":!0,className:`oc-composer__perm-chev`})]})}),(0,J.jsxs)(fC,{align:`start`,side:`top`,className:`oc-perm__menu w-80`,onKeyDown:e=>{let t=R5(e.key,o.items);t!==null&&(e.preventDefault(),e.stopPropagation(),s(t),a(!1))},children:[(0,J.jsx)(W5,{}),o.items.map(e=>(0,J.jsx)(hC,{className:`oc-perm__opt${e.selected?` is-selected`:``}${e.value===`full`?` is-full`:``}`,role:`menuitemradio`,"aria-checked":e.selected,"aria-keyshortcuts":String(e.shortcut),disabled:e.disabled,title:e.disabledReason??void 0,"data-permission-option":e.value,onSelect:()=>s(e.value),children:(0,J.jsx)(U5,{item:e})},e.value)),o.status===null?null:(0,J.jsx)(`p`,{className:`oc-perm__status${o.statusIsError?` is-error`:``}`,role:o.statusIsError?`alert`:`status`,children:o.status}),o.lockReason===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:o.lockReason}),o.note===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:o.note})]})]})}function K5({chatId:e,routedAgent:t,multiAgent:n}){let r=H5(e,t,n);if(r===null||r.view.hidden)return null;let{view:i,pick:a}=r;return(0,J.jsxs)(`section`,{className:`oc-perm__section`,"aria-label":q_(),title:i.title,children:[(0,J.jsx)(W5,{}),(0,J.jsx)(`div`,{role:`radiogroup`,"aria-label":q_(),className:`oc-perm__list`,children:i.items.map(e=>(0,J.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.selected,disabled:e.disabled,title:e.disabledReason??void 0,className:`oc-perm__opt${e.selected?` is-selected`:``}${e.value===`full`?` is-full`:``}`,"data-permission-option":e.value,onClick:()=>a(e.value),children:(0,J.jsx)(U5,{item:e})},e.value))}),i.status===null?null:(0,J.jsx)(`p`,{className:`oc-perm__status${i.statusIsError?` is-error`:``}`,role:i.statusIsError?`alert`:`status`,children:i.status}),i.lockReason===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:i.lockReason}),i.note===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:i.note})]})}function q5(e){let t=U(G.widgets.widgetConfigForChat,e===null?`skip`:{chatId:e}),{can:n}=PT(e),r=W(G.widgets.setChatWidgets),i=Mw(),[a,o]=(0,q.useState)(null),s=t?.canToggle===!0&&n(`inlineWidgets`),c=a??t?.chatDisabled!==!0,l=(0,q.useCallback)(t=>{e!==null&&(o(t),r({chatId:e,enabled:t}).catch(e=>i.error(Jl(),e)).finally(()=>o(null)))},[e,r,i]);return{offered:s,enabled:c,pending:a!==null,set:l}}function J5(e,t){return e===null||e.kind==="default"?{off:t.injection===`off`,sources:t.injection===`off`?[]:[...t.defaultSources]}:e.kind===`off`?{off:!0,sources:[]}:{off:!1,sources:[...e.sources]}}var Y5={hidden:!0,items:[],readOnlyReason:null,origin:`agent`,originLabel:``,allOff:!1,canReset:!1,emptyNote:null,status:null,statusIsError:!1};function X5(e){switch(e){case`plugin_absent`:return Pr();case`overrides_disabled`:return un();case`source_not_allowed`:case`unknown_source`:return Po();case`unsupported_gateway`:return Ga();case`scope_refused`:return xa();default:return jh()}}function Z5(e){if(e==null||e.provider!==`openclaw`||!e.supported)return Y5;let t=e.facts;if(t===null||!t.available)return Y5;let n=e.choice,r=n!==null&&n.kind!=="default";if(t.sources.length===0&&!r)return Y5;let i=J5(n,{injection:t.injection,defaultSources:t.defaultSources}),a=e.viewerRole===`owner`?t.overridesAllowed?null:Me():_l(),o=null,s=!1,c=e.apply?.status===`clamped`&&n!==null&&Array.isArray(e.apply.dropped)?e.apply.dropped:[];if(e.apply!==null&&n!==null){if(e.apply.status===`pending`)o=nte();else if(e.apply.status===`deferred`)o=As();else if(e.apply.status===`failed`)o=ea({reason:X5(e.apply.reason)}),s=!0;else if(e.apply.status===`clamped`&&c.length>0){let e=c.map(e=>t.sources.find(t=>t.id===e)?.label??e);o=e.length===1?ri({source:e[0]}):av({sources:e.join(`, `)})}}return{hidden:!1,items:t.sources.map(e=>({id:e.id,label:e.label,description:e.description,checked:!i.off&&i.sources.includes(e.id)&&!c.includes(e.id),unavailable:c.includes(e.id)})),readOnlyReason:a,origin:r?`conversation`:`agent`,originLabel:r?n.kind===`sources`&&t.injection===`off`?Ul():Hu():gu(),allOff:i.off||i.sources.length===0,canReset:e.viewerRole===`owner`&&r,status:o,statusIsError:s,emptyNote:t.sources.length===0?Ai():null}}function Q5(e,t){let n=e.facts,r=J5(e.choice,{injection:n?.injection??null,defaultSources:n?.defaultSources??[]}),i=r.off?[]:r.sources,a=new Set((n?.sources??[]).map(e=>e.id)),o=(i.includes(t)?i.filter(e=>e!==t):[...i,t]).filter(e=>a.has(e));return o.length===0?{kind:`off`}:{kind:`sources`,sources:(n?.sources??[]).map(e=>e.id).filter(e=>o.includes(e)),...n?.injection===`off`?{injection:`auto`}:{}}}function $5(e,t){return e===null||t===null?e===t:e.kind===t.kind?e.kind!==`sources`||t.kind!==`sources`||e.injection===t.injection&&e.sources.length===t.sources.length&&e.sources.every(e=>t.sources.includes(e)):!1}function e7(e,t){return t===null?e:{...e,choice:t}}function t7(e){return`${e.instanceName}\u0000${e.agentId}`}function nne(e,t){return e[t]?.choice??null}function rne(e,t,n,r){let i=e[t];return{...e,[t]:{choice:n,inFlight:(i?.inFlight??0)+1,gen:r}}}function n7(e,t,n,r,i){let a=e[t];if(a===void 0)return e;let o=Math.max(0,a.inFlight-1);return!r&&a.gen===n||r&&o===0&&t!==i?r7(e,t):{...e,[t]:{...a,inFlight:o}}}function ine(e,t,n){let r=e[t];return r===void 0||ane(n,r.choice,r.inFlight)!==null?e:r7(e,t)}function r7(e,t){let n={};for(let[r,i]of Object.entries(e))r!==t&&(n[r]=i);return n}function ane(e,t,n){return t===null?null:n>0?t:$5(e,t)?null:t}function one({chatId:e,routedAgent:t,attachmentsSupported:n,attachDisabled:r}){let i=jV(),a=Mw(),o=(0,q.useRef)(null),s=(0,q.useRef)(null),c=U(G.knowledge.knowledgeControl,e===null?`skip`:{chatId:e,...t?{routedAgent:t}:{}}),l=W(G.knowledge.setKnowledgeChoice),u=c==null?``:t7(c.target),[d,f]=(0,q.useState)({}),p=(0,q.useRef)(new Map),m=(0,q.useRef)(u);m.current=u;let h=nne(d,u),g=c?.choice??null;(0,q.useEffect)(()=>{c!=null&&f(e=>ine(e,u,g))},[c,g,u,d]);let _=Z5(c==null?c:e7(c,h)),v=q5(e),y=(0,q.useCallback)(e=>{let t=Array.from(e.target.files??[]);e.target.value=``;for(let e of t)i.addAttachment(e).catch(()=>{})},[i]),b=(0,q.useCallback)(t=>{if(c==null)return;let n=t7(c.target),r=(p.current.get(n)??0)+1;p.current.set(n,r),f(e=>rne(e,n,t,r)),l({chatId:e,instanceName:c.target.instanceName,agentId:c.target.agentId,choice:t}).then(()=>f(e=>n7(e,n,r,!0,m.current))).catch(e=>{f(e=>n7(e,n,r,!1,m.current));let t=/overrides_disabled|source_not_allowed|unavailable|not_openclaw/.exec(String(e?.message??``))?.[0];a.error(ae({reason:X5(t===`unavailable`?`plugin_absent`:t)}),e)})},[e,c,l,a]);if(!n&&_.hidden&&!v.offered)return null;let x=_.readOnlyReason===null;return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`input`,{ref:o,type:`file`,multiple:!0,hidden:!0,onChange:y,"data-testid":`composer-add-file-input`}),(0,J.jsx)(`input`,{ref:s,type:`file`,accept:q3,multiple:!0,hidden:!0,onChange:y,"data-testid":`composer-add-image-input`}),(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon`,"aria-label":Up(),title:Up(),children:(0,J.jsx)(RC,{size:18,"aria-hidden":!0})})}),(0,J.jsxs)(fC,{align:`start`,side:`top`,className:`oc-perm__menu w-80`,children:[n?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(hC,{className:`oc-perm__opt`,disabled:r,onSelect:()=>o.current?.click(),"data-add-option":`file`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(CA,{size:14})}),(0,J.jsx)(`span`,{className:`oc-perm__opt-copy`,children:(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:T()})})]}),(0,J.jsxs)(hC,{className:`oc-perm__opt`,disabled:r,onSelect:()=>s.current?.click(),"data-add-option":`image`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(MA,{size:14})}),(0,J.jsx)(`span`,{className:`oc-perm__opt-copy`,children:(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:as()})})]})]}):null,_.hidden||c==null?null:(0,J.jsxs)(J.Fragment,{children:[n?(0,J.jsx)(gC,{}):null,(0,J.jsxs)(lC,{className:`oc-perm__heading`,"data-knowledge-origin":_.origin,children:[(0,J.jsx)(`span`,{children:pd()}),(0,J.jsx)(`span`,{className:`oc-knowledge__origin`,children:_.originLabel})]}),_.items.map(e=>(0,J.jsxs)(hC,{className:`oc-perm__opt${e.checked?` is-selected`:``}`,role:`menuitemcheckbox`,"aria-checked":e.checked,disabled:!x||e.unavailable,title:e.unavailable?Rn():_.readOnlyReason??void 0,"data-knowledge-source":e.id,onSelect:t=>{t.preventDefault(),x&&!e.unavailable&&b(Q5(e7(c,h),e.id))},children:[(0,J.jsxs)(`span`,{className:`oc-perm__opt-copy`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:e.label}),e.description===``?null:(0,J.jsx)(`span`,{className:`oc-perm__opt-desc`,children:e.description})]}),(0,J.jsx)(`span`,{className:`oc-perm__opt-state`,"aria-hidden":!0,children:!x||e.unavailable?e.checked?(0,J.jsx)(YS,{size:14}):(0,J.jsx)(AC,{size:13}):e.checked?(0,J.jsx)(YS,{size:14}):null})]},e.id)),_.emptyNote===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:_.emptyNote}),_.allOff&&_.emptyNote===null?(0,J.jsx)(`p`,{className:`oc-perm__note`,children:cr()}):null,_.canReset?(0,J.jsxs)(hC,{className:`oc-perm__opt`,onSelect:()=>b({kind:`default`}),"data-knowledge-reset":!0,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(zC,{size:14})}),(0,J.jsx)(`span`,{className:`oc-perm__opt-copy`,children:(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:Gc()})})]}):null,_.status===null?null:(0,J.jsx)(`p`,{className:`oc-perm__status${_.statusIsError?` is-error`:``}`,role:_.statusIsError?`alert`:`status`,children:_.status}),_.readOnlyReason===null?null:(0,J.jsx)(`p`,{className:`oc-perm__note`,children:_.readOnlyReason})]}),v.offered?(0,J.jsxs)(J.Fragment,{children:[n||!_.hidden?(0,J.jsx)(gC,{}):null,(0,J.jsxs)(hC,{className:`oc-perm__opt${v.enabled?` is-selected`:``}`,role:`menuitemcheckbox`,"aria-checked":v.enabled,disabled:v.pending,"data-widgets-toggle":!0,onSelect:e=>{e.preventDefault(),v.set(!v.enabled)},children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-icon`,"aria-hidden":!0,children:(0,J.jsx)(LA,{size:14})}),(0,J.jsxs)(`span`,{className:`oc-perm__opt-copy`,children:[(0,J.jsx)(`span`,{className:`oc-perm__opt-title`,children:Yc()}),(0,J.jsx)(`span`,{className:`oc-perm__opt-desc`,children:fr()})]}),(0,J.jsx)(`span`,{className:`oc-perm__opt-state`,"aria-hidden":!0,children:v.enabled?(0,J.jsx)(YS,{size:14}):null})]})]}):null]})]})]})}function i7(e){return e.kind===`credential`?`credential`:e.kind===`question`?e.questions?.some(e=>e.secret)?`credential`:`question`:e.approval?.severity===`critical`?`critical`:`approval`}function a7(e){return e===`pending`||e===`submitting`}function o7(e,t){return a7(e.status)&&e.expiresAt>t}function sne(e){return e.source!==`hermes.approval`&&e.answerById!==!0}function cne(e,t){let n=e-t;if(n<=0)return{unit:`expired`,value:0,urgent:!0};let r=Math.ceil(n/1e3);if(r<60)return{unit:`seconds`,value:r,urgent:!0};let i=Math.ceil(r/60);return i<60?{unit:`minutes`,value:i,urgent:i<=2}:{unit:`hours`,value:Math.round(i/60),urgent:!1}}function lne(e){if(e.kind===`question`||e.kind===`credential`&&e.questions)return e.questions?.[0]?.text??``;if(e.kind===`approval`){let t=e.approval;return t?.title??t?.command??t?.description??``}return e.credential?.prompt??e.credential?.envVar??``}function s7(){return{selected:[],other:``}}function une(e,t,n){let r=t.selected.includes(n);return e.multiSelect?{...t,selected:r?t.selected.filter(e=>e!==n):[...t.selected,n]}:{selected:r?[]:[n],other:r?t.other:``}}function c7(e,t,n){return e.multiSelect?{...t,other:n}:{selected:n.trim()===``?t.selected:[],other:n}}function dne(e,t){let n=[];for(let r of e){let e=t[r.id]??s7(),i=r.secret?e.other:e.other.trim(),a=[...e.selected];(r.allowOther||r.options.length===0)&&i!==``&&a.push(i);let o=r.multiSelect?a:a.slice(-1);if(o.length===0)return{ok:!1,problem:{code:`missing`,questionId:r.id}};if(o.some(e=>e.length>8e3))return{ok:!1,problem:{code:`too_long`,questionId:r.id}};n.push({id:r.id,values:o})}return{ok:!0,answers:n}}function l7(e,t){return e.filter(e=>o7(e,t)).sort((e,t)=>e.expiresAt-t.expiresAt)}function fne(e,t){if(e.source!==`hermes.approval`||e.answerById)return null;let n=e.seq??e.createdAt;return t.filter(t=>t._id!==e._id&&t.source===`hermes.approval`&&!t.answerById&&!t.answerById&&t.queueKey===e.queueKey&&(t.status===`pending`||t.status===`submitting`)&&(t.seq??t.createdAt)<n).sort((e,t)=>(e.seq??e.createdAt)-(t.seq??t.createdAt))[0]??null}function pne(e,t){return e.source!==`hermes.approval`||e.answerById?!1:t.some(t=>t._id!==e._id&&t.source===`hermes.approval`&&!t.answerById&&t.queueKey===e.queueKey&&(t.status===`pending`||t.status===`submitting`))}function mne(e,t){let n=l7(e,t),r=new Set(n.map(e=>e._id));return{waiting:n,history:e.filter(e=>!r.has(e._id)).sort((e,t)=>(t.resolvedAt??t.createdAt)-(e.resolvedAt??e.createdAt))}}function hne(e,t){if(a7(e.status)&&e.expiresAt<=t)return`expired`;switch(e.status){case`answered`:return e.resolvedElsewhere?`answered_elsewhere`:`answered`;case`allowed`:return e.resolvedElsewhere?`allowed_elsewhere`:e.decision===`allow-always`?`allowed_always`:e.decision===`allow-session`?`allowed_session`:`allowed_once`;case`denied`:return e.resolvedElsewhere?`denied_elsewhere`:`denied`;case`expired`:return`expired`;case`cancelled`:return e.answeredByMe?`skipped`:`cancelled`;case`failed`:return`failed`;default:return null}}function u7(e){return e===null?`none`:e===`not_configured`||e===`instance_not_served`||e===`provider_mismatch`?`config`:`retry`}var d7=(0,q.createContext)(null);function f7(){return(0,q.useContext)(d7)}function gne(e){let[t,n]=(0,q.useState)(()=>Date.now());return(0,q.useEffect)(()=>{let t=window.setInterval(()=>n(Date.now()),e?1e3:3e4);return()=>window.clearInterval(t)},[e]),t}function _ne(e){let t=document.querySelector(`.oc-thread__viewport [data-agent-request-id="${CSS.escape(e._id)}"]`)??(e.messageId===null?null:document.querySelector(`[data-message-id="${CSS.escape(e.messageId)}"]`));if(!t)return;let n=t.closest(`.oc-thread__viewport`);if(n){let e=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTo({top:n.scrollTop+e-Math.max(24,n.clientHeight*.25),behavior:`smooth`})}else t.scrollIntoView({block:`center`,behavior:`smooth`});t.classList.remove(`oc-areq--flash`),t.offsetWidth,t.classList.add(`oc-areq--flash`),window.setTimeout(()=>t.classList.remove(`oc-areq--flash`),2200)}function vne({chatId:e,children:t}){let n=U(G.agentRequests.listForChat,{chatId:e}),r=(0,q.useMemo)(()=>n??[],[n]),i=gne(r.some(e=>a7(e.status))),a=pa(G.agentRequests.answer),[o,s]=(0,q.useState)(!1),c=(0,q.useCallback)(async(e,t)=>{try{let n=await a({requestId:e,...t});return n.ok?{ok:!0}:{ok:!1,reason:n.reason}}catch{return{ok:!1,reason:`unreachable`}}},[a]),l=(0,q.useMemo)(()=>{let e=new Map;for(let t of[...r].sort((e,t)=>e.createdAt-t.createdAt)){if(t.messageId===null)continue;let n=e.get(t.messageId)??[];n.push(t),e.set(t.messageId,n)}return e},[r]),u=(0,q.useMemo)(()=>l7(r,i),[r,i]),d=(0,q.useMemo)(()=>({rows:r,now:i,byMessage:l,waiting:u,answer:c,openPanel:()=>s(!0),jumpTo:e=>{s(!1),window.setTimeout(()=>_ne(e),120)}}),[r,i,l,u,c]);return(0,J.jsxs)(d7.Provider,{value:d,children:[t,(0,J.jsx)(Nne,{open:o,onOpenChange:s})]})}var p7=`atrium.agentRequests.folded`;function m7(){try{let e=window.localStorage.getItem(p7),t=e?JSON.parse(e):[];return new Set(Array.isArray(t)?t.filter(e=>typeof e==`string`):[])}catch{return new Set}}function yne(e){try{window.localStorage.setItem(p7,JSON.stringify([...e].slice(-200)))}catch{}}function bne(e,t){let[n,r]=(0,q.useState)(()=>t&&m7().has(e)?!1:null);return[n??t,(0,q.useCallback)(n=>{if(r(n),!t)return;let i=m7();n?i.delete(e):i.add(e),yne(i)},[e,t])]}var h7={question:KA,approval:VC,critical:cj,credential:IA};function g7(e){switch(e){case`question`:return dn();case`approval`:return Fo();case`critical`:return Ka();case`credential`:return Sa()}}function xne(e,t){let n=cne(e,t);switch(n.unit){case`expired`:return{text:po(),urgent:!0};case`seconds`:return{text:Mh({value:String(n.value)}),urgent:!0};case`minutes`:return{text:oe({value:String(n.value)}),urgent:n.urgent};case`hours`:return{text:$h({value:String(n.value)}),urgent:!1}}}var Sne={answered:()=>Xee(),answered_elsewhere:()=>Cs(),skipped:()=>Ji(),allowed_once:()=>Dr(),allowed_session:()=>nn(),allowed_always:()=>Do(),allowed_elsewhere:()=>Ra(),denied:()=>ha(),denied_elsewhere:()=>Th(),expired:()=>V(),cancelled:()=>qh(),failed:()=>so()},_7={"allow-once":()=>Of(),"allow-session":()=>Lee(),"allow-always":()=>hb(),deny:()=>Fd()},Cne={"message-send":()=>Jf(),payment:()=>$v(),"external-post":()=>bee(),"standing-grant":()=>af()};function v7(e){if(e.startsWith(`AGENT_REQUEST_INVALID_ANSWER`))return zu();switch(e){case`AGENT_REQUEST_EXPIRED`:return hg();case`request_gone`:case`AGENT_REQUEST_NOT_PENDING`:return Hf();case`AGENT_REQUEST_OWNER_ONLY`:return By();case`AGENT_REQUEST_READ_ONLY`:return xg();case`AGENT_REQUEST_AGENT_NOT_IN_ROOM`:return Yf();case`AGENT_REQUEST_IMPERSONATING`:return qv();case`AGENT_REQUEST_ANSWER_OLDEST_FIRST`:return up();case`AGENT_REQUEST_DECISION_NOT_OFFERED`:return rh();case`session_mismatch`:return gy();case`approval_order_unknown`:return Mp();case`approval_ambiguous`:return pu();case`AGENT_REQUEST_CLIPPED`:return ns();case`invalid_answer`:return zu();default:return u7(e)===`config`?wv():r_()}}function wne(e){if(e.status!==`answered`||e.answers===null)return null;if(e.kind===`credential`||e.questions?.some(e=>e.secret))return mt();let t=e.answers.flatMap(e=>e.values).filter(e=>e!==``);return t.length>0?t.join(` · `):null}function y7({request:e,mode:t,open:n,onToggle:r}){let i=f7(),a=i?.now??Date.now(),o=i7(e),s=h7[o],c=o7(e,a),[l,u]=bne(e._id,c),d=n??l,f=r??u,p=(0,q.useId)(),m=hne(e,a),h=c&&sne(e)?xne(e.expiresAt,a):null,g=i&&c?fne(e,i.rows):null,_=lne(e),v=wne(e);return(0,J.jsxs)(`section`,{className:[`oc-areq`,`oc-areq--${o}`,`oc-areq--${t}`,c?`oc-areq--waiting`:`oc-areq--settled`,d?`oc-areq--open`:``].join(` `),"data-agent-request-id":e._id,"aria-label":`${g7(o)} — ${_}`,children:[(0,J.jsxs)(`header`,{className:`oc-areq__head`,children:[(0,J.jsx)(`span`,{className:`oc-areq__icon`,"aria-hidden":!0,children:(0,J.jsx)(s,{size:15})}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-areq__toggle`,"aria-expanded":d,"aria-controls":p,title:d?Ab():mc(),onClick:()=>f(!d),children:[(0,J.jsx)(`span`,{className:`oc-areq__kind`,children:g7(o)}),!d||!c?(0,J.jsx)(`span`,{className:`oc-areq__summary`,children:_}):null]}),m===null?null:(0,J.jsxs)(`span`,{className:`oc-areq__outcome oc-areq__outcome--${m}`,children:[m.startsWith(`allowed`)||m===`answered`?(0,J.jsx)(YS,{size:12,"aria-hidden":!0}):m.startsWith(`denied`)?(0,J.jsx)(XC,{size:12,"aria-hidden":!0}):null,Sne[m](),v!==null&&!d?(0,J.jsx)(`span`,{className:`oc-areq__outcome-detail`,children:v}):null]}),e.status===`submitting`?(0,J.jsx)(`span`,{className:`oc-areq__outcome oc-areq__outcome--sending`,children:Pt()}):null,h!==null&&e.status===`pending`?(0,J.jsxs)(`span`,{className:`oc-areq__timer${h.urgent?` oc-areq__timer--urgent`:``}`,title:new Date(e.expiresAt).toLocaleTimeString(),children:[(0,J.jsx)(_j,{size:12,"aria-hidden":!0}),h.text]}):null,t!==`inline`&&i?(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:qe(),"aria-label":qe(),onClick:()=>i.jumpTo(e),children:(0,J.jsx)(HA,{size:14})}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,"aria-hidden":!0,tabIndex:-1,onClick:()=>f(!d),children:d?(0,J.jsx)($S,{size:14}):(0,J.jsx)(XS,{size:14})})]}),d?(0,J.jsx)(`div`,{className:`oc-areq__body`,id:p,children:(0,J.jsx)(Tne,{request:e,waiting:c,blocker:g})}):null]})}function Tne({request:e,waiting:t,blocker:n}){let r=f7(),i=r!==null&&pne(e,r.rows),a=t&&e.status===`pending`&&e.canAnswer&&n===null&&!i,o=t?e.canAnswer?i?pu():n===null?null:up():By():null;return(0,J.jsxs)(J.Fragment,{children:[e.kind===`approval`&&e.approval?(0,J.jsx)(kne,{request:e,answerable:a}):e.questions===null?(0,J.jsx)(Ane,{request:e,answerable:a}):(0,J.jsx)(Ene,{request:e,answerable:a}),o===null?null:(0,J.jsx)(`p`,{className:`oc-areq__note`,children:o})]})}function b7(e){let t=f7(),[n,r]=(0,q.useState)(!1),[i,a]=(0,q.useState)(null),o=(0,q.useCallback)(async n=>{if(!t)return!1;r(!0),a(null);let i=await t.answer(e._id,n);return r(!1),i.ok||a(v7(i.reason)),i.ok},[t,e._id]),s=e.status===`pending`&&u7(e.failureCode)!==`none`?v7(e.failureCode):null;return{busy:n||e.status===`submitting`,sending:n,error:i??s,setError:a,submit:o}}function Ene({request:e,answerable:t}){let n=e.questions??[],[r,i]=(0,q.useState)({}),{busy:a,sending:o,error:s,setError:c,submit:l}=b7(e),u=e.answers,d=a7(e.status),f=!d||!t&&!o;(0,q.useEffect)(()=>{f&&i({})},[f]);let p=async()=>{let e=dne(n,r);if(!e.ok){c(e.problem.code===`missing`?C_():Xd());return}await l({answers:e.answers})&&i({})};return(0,J.jsxs)(`form`,{className:`oc-areq__form`,onSubmit:e=>{e.preventDefault(),p()},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),p())},children:[n.map(e=>(0,J.jsx)(Dne,{question:e,draft:r[e.id]??s7(),disabled:!t||a,closed:!d,settled:u?.find(t=>t.id===e.id)?.values??null,onChange:t=>{c(null),i(n=>({...n,[e.id]:t}))}},e.id)),s===null?null:(0,J.jsx)(`p`,{className:`oc-areq__error`,role:`alert`,children:s}),t?(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:a,title:yc(),onClick:()=>{i({}),l({skip:!0})},children:zt()}),(0,J.jsx)(K,{type:`submit`,size:`sm`,disabled:a,children:a?Pt():yt()})]}):null]})}function Dne({question:e,draft:t,disabled:n,closed:r,settled:i,onChange:a}){let o=(0,q.useId)(),s=e.options.length===0,[c,l]=(0,q.useState)(!1),u=i??t.selected;return(0,J.jsxs)(`fieldset`,{className:`oc-areq__q`,"aria-labelledby":o,disabled:n,children:[(0,J.jsxs)(`div`,{className:`oc-areq__qhead`,id:o,children:[e.header?(0,J.jsx)(`span`,{className:`oc-areq__qchip`,children:e.header}):null,(0,J.jsx)(`span`,{className:`oc-areq__qtext`,children:e.text})]}),e.store?(0,J.jsx)(One,{store:e.store}):null,e.url?(0,J.jsxs)(`a`,{className:`oc-areq__link`,href:e.url,target:`_blank`,rel:`noopener noreferrer`,children:[(0,J.jsx)(bA,{size:13,"aria-hidden":!0}),ox()]}):null,e.options.length>0?(0,J.jsxs)(`div`,{className:`oc-areq__options`,role:e.multiSelect?`group`:`radiogroup`,"aria-labelledby":o,children:[e.options.map(r=>{let o=u.includes(r.label);return(0,J.jsxs)(`button`,{type:`button`,className:`oc-areq__option${o?` oc-areq__option--on`:``}`,role:e.multiSelect?`checkbox`:`radio`,"aria-checked":o,disabled:n||i!==null,onClick:()=>a(une(e,t,r.label)),children:[(0,J.jsx)(`span`,{className:`oc-areq__option-mark`,"aria-hidden":!0,children:o?(0,J.jsx)(YS,{size:11}):null}),(0,J.jsxs)(`span`,{className:`oc-areq__option-text`,children:[(0,J.jsx)(`span`,{className:`oc-areq__option-label`,title:r.label.length>120?r.label:void 0,children:r.label}),r.description?(0,J.jsx)(`span`,{className:`oc-areq__option-desc`,children:r.description}):null]})]},r.label)}),e.multiSelect?(0,J.jsx)(`span`,{className:`oc-areq__hint`,children:Qs()}):null]}):null,!r&&i===null&&(e.allowOther||s)?e.secret?(0,J.jsxs)(`div`,{className:`oc-areq__secret`,children:[(0,J.jsx)(`input`,{className:`oc-areq__input`,type:c?`text`:`password`,autoComplete:`off`,spellCheck:!1,placeholder:Zo(),value:t.other,onChange:n=>a(c7(e,t,n.target.value))}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:c?Pu():cu(),"aria-label":c?Pu():cu(),onClick:()=>l(e=>!e),children:c?(0,J.jsx)(SC,{size:14}):(0,J.jsx)(CC,{size:14})})]}):s?(0,J.jsx)(`textarea`,{className:`oc-areq__input oc-areq__input--area`,rows:2,placeholder:$e(),value:t.other,onChange:n=>a(c7(e,t,n.target.value))}):(0,J.jsx)(`input`,{className:`oc-areq__input`,type:`text`,placeholder:Ib(),value:t.other,onChange:n=>a(c7(e,t,n.target.value))}):null,i!==null&&i.length>0&&e.options.length===0&&!e.secret?(0,J.jsx)(`p`,{className:`oc-areq__given`,children:i.join(` · `)}):null,e.secret?(0,J.jsx)(`p`,{className:`oc-areq__hint`,children:e.store?Fl():Yr()}):null]})}function One({store:e}){return(0,J.jsxs)(`div`,{className:`oc-areq__facts`,children:[(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--mono`,children:Z_({name:e.name})}),e.allowedHosts?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:xi({hosts:e.allowedHosts.join(`, `)})}):null,e.replacesSinceMs===void 0?null:(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--warning`,children:kn({date:new Date(e.replacesSinceMs).toLocaleDateString()})}),e.reason?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:e.reason}):null]})}function kne({request:e,answerable:t}){let n=e.approval,{busy:r,error:i,submit:a}=b7(e),[o,s]=(0,q.useState)(!1),c=n.decisions.filter(e=>e!==`deny`);return(0,J.jsxs)(`div`,{className:`oc-areq__approval`,children:[n.title?(0,J.jsx)(`p`,{className:`oc-areq__title`,children:n.title}):null,n.description?(0,J.jsx)(`p`,{className:`oc-areq__desc`,children:n.description}):null,n.command?(0,J.jsxs)(`pre`,{className:`oc-areq__command`,"aria-label":I_(),children:[(0,J.jsx)(pj,{size:13,"aria-hidden":!0,className:`oc-areq__command-icon`}),(0,J.jsx)(`code`,{children:n.command})]}):null,n.warning?(0,J.jsxs)(`p`,{className:`oc-areq__warning`,children:[(0,J.jsx)(cj,{size:13,"aria-hidden":!0}),n.warning]}):null,n.clipped?(0,J.jsxs)(`p`,{className:`oc-areq__warning`,role:`note`,children:[(0,J.jsx)(cj,{size:13,"aria-hidden":!0}),S()]}):null,n.detail?(0,J.jsxs)(`details`,{className:`oc-areq__detail`,children:[(0,J.jsx)(`summary`,{children:cm()}),(0,J.jsx)(`pre`,{children:n.detail})]}):null,(0,J.jsxs)(`div`,{className:`oc-areq__facts`,children:[n.severity&&n.severity!==`info`?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--${n.severity}`,children:n.severity===`critical`?Vp():Ty()}):null,n.scope?(0,J.jsxs)(`span`,{className:`oc-areq__fact`,children:[(Cne[n.scope.kind]??(()=>n.scope.kind))(),` · `,n.scope.summary]}):null,n.scope?.external?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--warning`,children:uh()}):null,n.scope?.grantDays===void 0?null:(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:Mv({days:String(n.scope.grantDays)})}),n.host?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:bg({host:n.host})}):null,n.nodeId?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:hp({node:n.nodeId})}):null,n.pluginId?(0,J.jsx)(`span`,{className:`oc-areq__fact`,children:Gy({plugin:n.pluginId})}):null,n.toolName?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--mono`,children:n.toolName}):null]}),i===null?null:(0,J.jsx)(`p`,{className:`oc-areq__error`,role:`alert`,children:i}),t?o?(0,J.jsxs)(`div`,{className:`oc-areq__confirm`,role:`group`,"aria-label":km(),children:[(0,J.jsx)(`p`,{children:n.scope?.grantDays===void 0?oee():f_({days:String(n.scope.grantDays)})}),(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:r,onClick:()=>s(!1),children:Hg()}),(0,J.jsx)(K,{type:`button`,size:`sm`,disabled:r,onClick:()=>void a({decision:`allow-always`}),children:km()})]})]}):(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`destructive`,size:`sm`,disabled:r,onClick:()=>void a({decision:`deny`}),children:_7.deny()}),(0,J.jsx)(`span`,{className:`oc-areq__spacer`}),c.filter(e=>e!==`allow-once`).map(e=>(0,J.jsx)(K,{type:`button`,variant:`outline`,size:`sm`,disabled:r,onClick:()=>e===`allow-always`?s(!0):void a({decision:e}),children:_7[e]()},e)),c.includes(`allow-once`)?(0,J.jsx)(K,{type:`button`,size:`sm`,disabled:r,onClick:()=>void a({decision:`allow-once`}),children:r?Pt():_7[`allow-once`]()}):null]}):null]})}function Ane({request:e,answerable:t}){let n=e.credential,[r,i]=(0,q.useState)(``),[a,o]=(0,q.useState)(!1),{busy:s,sending:c,error:l,setError:u,submit:d}=b7(e),f=n?.mode===`password`,p=!a7(e.status)||!t&&!c;(0,q.useEffect)(()=>{p&&i(``)},[p]);let m=(0,q.useRef)(null);return(0,J.jsxs)(`form`,{className:`oc-areq__form`,onSubmit:e=>{if(e.preventDefault(),r.length===0){u(C_());return}d({secret:r}).then(e=>{e&&i(``)})},children:[(0,J.jsx)(`p`,{className:`oc-areq__desc`,children:n?.prompt??(f?ll():we())}),n?.command?(0,J.jsxs)(`pre`,{className:`oc-areq__command`,"aria-label":I_(),children:[(0,J.jsx)(pj,{size:13,"aria-hidden":!0,className:`oc-areq__command-icon`}),(0,J.jsx)(`code`,{children:n.command})]}):null,n?.envVar?(0,J.jsx)(`span`,{className:`oc-areq__fact oc-areq__fact--mono`,children:_({name:n.envVar})}):null,n?.clipped||n?.commandMissing?(0,J.jsxs)(`p`,{className:`oc-areq__warning`,role:`note`,children:[(0,J.jsx)(cj,{size:13,"aria-hidden":!0}),n.clipped?ns():ud()]}):null,t&&!n?.clipped&&!n?.commandMissing?(0,J.jsxs)(`div`,{className:`oc-areq__secret`,children:[(0,J.jsx)(`input`,{ref:m,className:`oc-areq__input`,type:a?`text`:`password`,autoComplete:f?`current-password`:`off`,spellCheck:!1,placeholder:f?ad():Zo(),value:r,onChange:e=>{u(null),i(e.target.value)}}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:a?Pu():cu(),"aria-label":a?Pu():cu(),onClick:()=>{o(e=>!e),m.current?.focus()},children:a?(0,J.jsx)(SC,{size:14}):(0,J.jsx)(CC,{size:14})})]}):null,(0,J.jsx)(`p`,{className:`oc-areq__hint`,children:Yr()}),l===null?null:(0,J.jsx)(`p`,{className:`oc-areq__error`,role:`alert`,children:l}),t?(0,J.jsxs)(`div`,{className:`oc-areq__actions`,children:[(0,J.jsx)(K,{type:`button`,variant:`ghost`,size:`sm`,disabled:s,onClick:()=>{i(``),d({skip:!0})},children:er()}),n?.clipped||n?.commandMissing?null:(0,J.jsx)(K,{type:`submit`,size:`sm`,disabled:s,children:s?Pt():Lc()})]}):null]})}function jne(){let e=f7(),t=$(e=>e.id),n=e?.byMessage.get(t);return!n||n.length===0?null:(0,J.jsx)(`div`,{className:`oc-areq-inline`,children:n.map(e=>(0,J.jsx)(y7,{request:e,mode:`inline`},e._id))})}function Mne(){let e=f7(),[t,n]=(0,q.useState)(!1),[r,i]=(0,q.useState)(null),a=e?.waiting??[];if((0,q.useEffect)(()=>{r!==null&&!a.some(e=>e._id===r)&&i(null)},[r,a]),!e||a.length===0)return null;let o=a[0],s=i7(o),c=h7[s],l=t?a:[o],u=a.length-1;return(0,J.jsxs)(`div`,{className:`oc-areq-dock oc-areq-dock--${s}`,role:`region`,"aria-label":Gs(),children:[(0,J.jsxs)(`div`,{className:`oc-areq-dock__bar`,children:[(0,J.jsx)(`span`,{className:`oc-areq-dock__pulse`,"aria-hidden":!0,children:(0,J.jsx)(c,{size:14})}),(0,J.jsx)(`span`,{className:`oc-areq-dock__title`,children:Gs()}),u>0?(0,J.jsxs)(`button`,{type:`button`,className:`oc-areq-dock__count`,"aria-expanded":t,title:t?Ab():mc(),onClick:()=>n(e=>!e),children:[$b({count:String(a.length)}),t?(0,J.jsx)(XS,{size:12,"aria-hidden":!0}):(0,J.jsx)($S,{size:12,"aria-hidden":!0})]}):null,(0,J.jsx)(`span`,{className:`oc-areq__spacer`}),(0,J.jsx)(`button`,{type:`button`,className:`oc-areq__iconbtn`,title:xf(),"aria-label":xf(),onClick:e.openPanel,children:(0,J.jsx)(PA,{size:14})})]}),(0,J.jsx)(`div`,{className:`oc-areq-dock__list`,children:l.map(e=>(0,J.jsx)(y7,{request:e,mode:`dock`,open:r===e._id,onToggle:t=>i(t?e._id:null)},e._id))})]})}function Nne({open:e,onOpenChange:t}){let n=f7(),[r,i]=(0,q.useState)(`all`),a=(0,q.useMemo)(()=>n?mne(n.rows,n.now):{waiting:[],history:[]},[n]),o=e=>{if(r===`all`)return!0;let t=i7(e);return r===`approval`?t===`approval`||t===`critical`:t===r},s=a.waiting.filter(o),c=a.history.filter(o);return(0,J.jsx)(_T,{open:e,onOpenChange:t,children:(0,J.jsxs)(yT,{side:`right`,className:`oc-areq-panel`,children:[(0,J.jsxs)(vT,{children:[(0,J.jsx)(bT,{children:xf()}),(0,J.jsx)(gT,{children:Mee()})]}),(0,J.jsx)(`div`,{className:`oc-areq-panel__filters`,role:`tablist`,"aria-label":tee(),children:[`all`,`question`,`approval`,`credential`].map(e=>(0,J.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===e,className:`oc-areq-panel__filter${r===e?` oc-areq-panel__filter--on`:``}${e===`all`?``:` oc-areq-panel__filter--${e}`}`,onClick:()=>i(e),children:e===`all`?Lg():g7(e)},e))}),(0,J.jsxs)(`div`,{className:`oc-areq-panel__body`,children:[s.length===0&&c.length===0?(0,J.jsx)(`p`,{className:`oc-areq-panel__empty`,children:wm()}):null,s.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`h3`,{className:`oc-areq-panel__section`,children:[cb(),` `,(0,J.jsx)(`span`,{className:`oc-areq-panel__n`,children:s.length})]}),s.map(e=>(0,J.jsx)(y7,{request:e,mode:`panel`},e._id))]}):null,c.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`h3`,{className:`oc-areq-panel__section`,children:Ad()}),c.map(e=>(0,J.jsx)(y7,{request:e,mode:`panel`},e._id))]}):null]})]})})}function Pne({compact:e=!1,ghost:t=!1}){let n=f7();if(!n||n.rows.length===0)return null;let r=n.waiting.length,i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(PA,{size:13,"aria-hidden":!0}),e?null:(0,J.jsx)(`span`,{className:`oc-chip__label`,children:A_()}),r>0?(0,J.jsx)(`span`,{className:`oc-areq-headbadge`,children:r}):null]}),a=`oc-chip oc-chip--btn${r>0?` oc-chip--areq`:``}`;return t?(0,J.jsx)(`span`,{className:a,children:i}):(0,J.jsx)(`button`,{type:`button`,className:a,title:r>0?nm({count:String(r)}):xf(),onClick:n.openPanel,children:i})}var x7={showSource:!0,showReport:!0,copyAssistant:!0,copyUser:!0,showDelete:!0,showTools:!1,voiceInput:!1,showUsage:!0,autoReadAloud:!0},S7=(0,q.createContext)({enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1}),C7=(0,q.createContext)({active:null,setActive:()=>{},clearIf:()=>{}}),w7=0;function T7(){w7++,KS(),WS()}var E7=(0,q.createContext)(x7);function D7(){return(0,q.useContext)(E7)}var O7=(0,q.createContext)(null),k7=(0,q.createContext)(null),A7=(0,q.createContext)(null),j7=(0,q.createContext)(null),M7=(0,q.createContext)(!0),N7=(0,q.createContext)(null),P7=(0,q.createContext)(null);function F7(){return(0,q.useContext)(P7)}function I7({className:e}){let t=W0();return(0,J.jsx)(`div`,{className:e,"aria-hidden":!0,children:t.logoUrl?t.logoMasked?(0,J.jsx)(`span`,{className:`oc-avatar__img oc-avatar__img--mask`,style:{"--oc-logo-url":`url("${t.logoUrl}")`}}):(0,J.jsx)(`img`,{className:`oc-avatar__img`,src:t.logoUrl,alt:``}):t.isDefault?(0,J.jsx)(H0,{className:`oc-avatar__mark`}):t.initials})}function L7({chatId:e,focusMessageId:t}){let{runtime:n,turnGate:r,queueSend:i,abortTurn:a,routing:o,lastUserTurnQueued:s,queuedTurns:c,cancelQueued:l,withdrawGatewayQueued:u,gatewayOthers:d,initialLoading:f}=x6({chatId:e}),{can:p}=PT(e),m=U(G.me.getMe,{host:dT}),h=m?.ui?.effective??x7,g=U(G.messages.getSessionMeta,e?{chatId:e}:`skip`)?.viewerRole===`participant`,_=(0,q.useMemo)(()=>g?{...h,showDelete:!1,showReport:!1}:h,[g,h]),v=h.showTools,y=JC(m?.resolvedThemeMode),b=m?.resolvedChartBrand,x=m?.resolvedChartTokens,S=U(G.agents.getChatAgent,e?{chatId:e}:`skip`),C=S?.multiAgent?S.agent:null,w=(0,q.useMemo)(()=>{let e=b?.label??`Atrium`,t=x?.colors?.[y],n=B0(t?.primary,t?.[`primary-foreground`],y),r=L0(b,n);return{label:e,logoUrl:r?.url??null,logoMasked:r?.masked??!1,isDefault:b?.isDefault??!0,initials:V0(e),agentName:C?.displayName??C?.agentId??null,agentEmoji:C?.emoji??null}},[b,y,x,C]),T=W(G.me.setUiPref).withOptimisticUpdate(kw),E=U(G.messages.getSessionMeta,e?{chatId:e}:`skip`),D=e!==null&&E===null,O=m?.userId??``,k=e??null,A=z$(),j=M$(),M=j$((0,q.useSyncExternalStore)(v$,y$,y$),{userId:O,chatId:k}),N=S?.agent?.instanceName??null,P=(0,q.useCallback)((e,t)=>{b$({kind:e,ownerUserId:O,originChatId:k,originLabel:E?.title||pg(),params:t})},[O,k,E?.title]),F=(0,q.useCallback)(()=>{M!==null&&S$(M.pinId)},[M]),I=M?.kind===`sources`?M.params.messageId:null,L=M?.kind===`subagent`?M.params.childKey:null,R=M?.kind===`document`?M.params.doc:null,ee=M?.kind===`cron`?M.params:null,z=(0,q.useMemo)(()=>({activeMessageId:I,openFor:e=>P(`sources`,{messageId:e}),close:F}),[I,P,F]),B=G0(w),V=(0,q.useMemo)(()=>({activeChildKey:L,openFor:e=>P(`subagent`,{childKey:e,parentAgentLabel:B}),close:F}),[L,B,P,F]),te=Mq;(0,q.useEffect)(()=>()=>{te.current=null},[te]);let ne=(0,q.useMemo)(()=>({activeDoc:R,openFor:e=>P(`document`,{doc:e}),openNewerVersion:e=>{M===null?P(`document`,{doc:e}):C$(M.pinId,{doc:e})},close:F}),[R,M,P,F]),re=(0,q.useMemo)(()=>({active:ee,openFor:(e,t,n)=>{let r=t??N;r!==null&&P(`cron`,{instanceName:r,jobId:e.jobId??null,part:e,occurrenceId:n})},close:F}),[ee,N,P,F]),ie=I!==null,ae=L!==null,oe=R!==null,se=ee!==null,ce=M?.kind??null,le=M?.params??null,ue=ce===null?null:T$(ce,le??{}),de=se||oe||ae||ie,fe=ce===null||E$(j,oe?380:ae?320:300),pe=de&&(A||!fe)&&M?.pinned!==!0,me=U(G.voice.voiceConfigForChat,e?{chatId:e}:`skip`),[he,ge]=(0,q.useState)(null),_e=(0,q.useMemo)(()=>({active:he,setActive:ge,clearIf:e=>ge(t=>t?.messageId===e?null:t)}),[he]);(0,q.useEffect)(()=>{T7(),ge(null)},[e]);let ve=(0,q.useMemo)(()=>me?{...me,loaded:!0}:{enabled:!1,lang:`auto`,rate:1,autoRead:!1,engine:`browser`,loaded:!1},[me]);return(0,J.jsx)(wV,{runtime:n,children:(0,J.jsx)(S7.Provider,{value:ve,children:(0,J.jsx)(C7.Provider,{value:_e,children:(0,J.jsx)(O7.Provider,{value:r,children:(0,J.jsx)(k7.Provider,{value:i,children:(0,J.jsx)(A7.Provider,{value:{queuedTurns:c,cancelQueued:l,withdrawGatewayQueued:u,canWithdrawGateway:p(`discardPendingInput`),gatewayOthers:d},children:(0,J.jsx)(N7.Provider,{value:e,children:(0,J.jsx)(j7.Provider,{value:g?null:a,children:(0,J.jsx)(M7.Provider,{value:!g,children:(0,J.jsx)(h8.Provider,{value:s,children:(0,J.jsx)(P7.Provider,{value:o,children:(0,J.jsx)(E7.Provider,{value:_,children:(0,J.jsx)(U0.Provider,{value:w,children:(0,J.jsx)(_J.Provider,{value:z,children:(0,J.jsx)(r$.Provider,{value:V,children:(0,J.jsx)(SK.Provider,{value:re,children:(0,J.jsx)(Nq.Provider,{value:te,children:(0,J.jsx)(Bq.Provider,{value:ne,children:(0,J.jsxs)(rJ,{children:[(0,J.jsx)(`div`,{className:`oc-chat`,children:(0,J.jsx)(`div`,{className:`oc-chat__convo`,children:e?D?(0,J.jsx)(Fne,{}):(0,J.jsx)(Bne,{chatId:e,showTools:v,onToggleTools:()=>void T({key:`showTools`,value:!v}),focusMessageId:t??null,initialLoading:f}):(0,J.jsx)(`div`,{className:`oc-empty`,children:Yb()})})}),ie&&pe?(0,J.jsx)(_T,{open:!0,onOpenChange:e=>{e||z.close()},children:(0,J.jsx)(yT,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,J.jsx)(AK,{onClose:F,children:(0,J.jsx)(bJ,{messageId:I,onClose:z.close})},ue??`none`)})}):null,ae&&pe?(0,J.jsx)(_T,{open:!0,onOpenChange:e=>{e||V.close()},children:(0,J.jsx)(yT,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,J.jsx)(AK,{onClose:F,children:(0,J.jsx)(f$,{chatId:e,childKey:L,onClose:V.close,parentAgentLabel:G0(w)})},ue??`none`)})}):null,se&&pe?(0,J.jsx)(_T,{open:!0,onOpenChange:e=>{e||re.close()},children:(0,J.jsx)(yT,{side:`right`,className:`oc-sources-panel-sheet`,children:(0,J.jsx)(AK,{onClose:F,children:(0,J.jsx)(kK,{instanceName:ee.instanceName,part:ee.part,onClose:re.close})},ue??`none`)})}):null,oe&&pe?(0,J.jsx)(_T,{open:!0,onOpenChange:e=>{e||ne.close()},children:(0,J.jsx)(yT,{side:`right`,className:`oc-sources-panel-sheet oc-docviewer-sheet`,children:(0,J.jsx)(AK,{onClose:F,children:(0,J.jsx)(Hq,{doc:R,chatId:e,onClose:ne.close})},ue??`none`)})}):null]})})})})})})})})})})})})})})})})})})})}function Fne(){let e=Kx();return(0,J.jsxs)(`div`,{className:`oc-notfound`,role:`status`,children:[(0,J.jsx)(`div`,{className:`oc-notfound__icon`,"aria-hidden":!0,children:(0,J.jsx)(yC,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-notfound__title`,children:_f()}),(0,J.jsx)(`p`,{className:`oc-notfound__body`,children:Aee()}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-notfound__cta`,onClick:()=>void e({to:`/`}),children:[(0,J.jsx)(RC,{size:16,"aria-hidden":!0}),ab()]})]})}function Ine(e,t){let n=CSS.highlights,r=window.Highlight;if(!n||!r)return null;let i=t.map(e=>e.toLowerCase()).filter(e=>e.length>=2);if(i.length===0)return null;let a=[],o=document.createTreeWalker(e,NodeFilter.SHOW_TEXT);for(let e=o.nextNode();e;e=o.nextNode()){let t=(e.textContent??``).toLowerCase();for(let n of i){let r=t.indexOf(n);for(;r!==-1;){let i=document.createRange();if(i.setStart(e,r),i.setEnd(e,r+n.length),a.push(i),a.length>=200)break;r=t.indexOf(n,r+n.length)}if(a.length>=200)break}if(a.length>=200)break}return a.length===0?null:(n.set(`oc-search-terms`,new r(...a)),()=>n.delete(`oc-search-terms`))}function Lne(e,t){(0,q.useEffect)(()=>{if(!t)return;let e=!1,n=0,r=0,i=null,a=()=>{if(e)return;let o=document.querySelector(`[data-message-id="${CSS.escape(t)}"]`);if(o){o.scrollIntoView({block:`center`,behavior:`smooth`}),o.classList.remove(`oc-msg--highlight`),o.offsetWidth,o.classList.add(`oc-msg--highlight`),window.setTimeout(()=>o.classList.remove(`oc-msg--highlight`),2400);let e=uS(t);e&&(i=Ine(o,e.split(/\s+/).filter(Boolean)));return}n++<40&&(r=window.setTimeout(a,150))};return r=window.setTimeout(a,0),()=>{e=!0,window.clearTimeout(r),i?.()}},[e,t])}function Rne(){return(0,J.jsx)(`div`,{className:`oc-thread-skeleton`,role:`status`,"aria-label":Su(),children:[72,38,84,56,64].map((e,t)=>(0,J.jsx)(`div`,{className:`oc-thread-skeleton__row${t%2?` oc-thread-skeleton__row--user`:``}`,children:(0,J.jsx)(`span`,{className:`oc-thread-skeleton__bubble`,style:{width:`${e}%`}})},t))})}function zne(e){return S5({chatId:e.chatId,ready:e.ready,focusMessageId:e.focusMessageId}),null}function Bne({chatId:e,showTools:t,onToggleTools:n,focusMessageId:r,initialLoading:i}){let a=U(G.bridgeHealth.getBridgeAvailability,{chatId:e}),o=F7(),s=o?.nextTarget??null,c=U(G.bridgeHealth.getBridgeAvailability,{chatId:e,...s?{routedAgent:{instanceName:s.instanceName,agentId:s.agentId}}:{}}),l=c&&!c.available?c:null,{beyondValidated:u,gatewayVersion:d}=PT(e,s?{instanceName:s.instanceName,agentId:s.agentId}:null),f=a?.available===!0&&a.degraded===!0,p=c?.available===!0&&c.degraded===!0,m=U(G.agents.getChatAgent,{chatId:e}),h=m?.readOnly===!0,g=U(G.messages.getSessionMeta,{chatId:e})?.viewerRole===`participant`,[_,v]=(0,q.useState)(!1),y=U(G.talk.chatCallState,{chatId:e}),b=s2({callActive:_||y?.active===!0,onCall:y?.active===!0&&y.instanceName!==void 0&&y.agentId!==void 0?{instanceName:y.instanceName,agentId:y.agentId}:null,unavailable:l!==null,readOnly:h,multiAgent:o?.multiAgent===!0,poolSize:(o?.pool??[]).filter(e=>e.state!==`deleted`).length}),x=!b.hidden&&!b.disabled,S=X8({readOnly:h,unavailable:l!==null,degraded:p,beyondValidated:u}),C=U(G.messages.getSessionMeta,{chatId:e})?.title??``,w=U(G.subAgents.listSubAgents,{chatId:e}),T=PQ(w??[]),E=pa(G.subAgents.reconcileTaskEngagements),D=(w??[]).some(e=>e.kind===`task`&&e.status===`running`),O=4*6e4,k=(w??[]).reduce((e,t)=>t.kind===`task`&&t.updatedAt>e?t.updatedAt:e,0),A=(0,q.useRef)({chatId:null,seenStamp:0,armedAtLocal:0});if(A.current.chatId!==(e??null)&&(A.current={chatId:e??null,seenStamp:0,armedAtLocal:0}),k>0&&A.current.seenStamp!==k){let t=A.current.seenStamp===0,n=Date.now()-k<10*6e4;A.current={chatId:e??null,seenStamp:k,armedAtLocal:t&&!n?0:Date.now()}}let j=A.current.armedAtLocal>0&&Date.now()-A.current.armedAtLocal<O;(0,q.useEffect)(()=>{if(!D&&!j||!e)return;let t=!1,n=!1,r,i=()=>{if(t||n)return;let r=A.current.armedAtLocal+O;!D&&Date.now()>r||(n=!0,E({chatId:e}).catch(()=>{}).finally(()=>{n=!1}))};return i(),r=window.setInterval(i,3e4),()=>{t=!0,window.clearInterval(r)}},[D,j,e,E]);let M=U(G.subAgents.turnActivity,{chatId:e}),N=g8(e),P=N!==null,F=U(G.messages.listByChat,{chatId:e}),I=F6(F),L=M?.runningTtlRemainingMs??null,[R,ee]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(ee(!1),M?.running!==!0||L===null)return;let e=window.setTimeout(()=>ee(!0),L);return()=>window.clearTimeout(e)},[M?.running,L,e]);let z=M?.running===!0&&!R,B=M?.detachedTask===!0?null:M?.workingSince??null,{showTurnActivity:V}=V6({chatId:e,projected:P,anyStreaming:I,runningLive:z,deliveringSince:M?.deliveringSince??null,deliveringTtlRemainingMs:M?.deliveringTtlRemainingMs??null,lastUserAt:R6(F),gatewayWorkingUntil:N?.workingUntil??null,runningSince:B}),te=M?.anchorMessageId??null,[ne,re]=(0,q.useState)(!1);(0,q.useEffect)(()=>{if(!V||te===null){re(!1);return}let e=()=>re(document.querySelector(`[data-message-id="${CSS.escape(te)}"]`)!==null);e();let t=window.setInterval(e,2e3);return()=>window.clearInterval(t)},[V,te]);let ie=V&&te!==null&&ne?{messageId:te,running:z,workingSince:B,quiet:P,progressSummary:M?.progressSummary??null}:null;return Lne(e,r),(0,J.jsx)(E6.Provider,{value:f,children:(0,J.jsx)(P6.Provider,{value:ie,children:(0,J.jsx)(cK,{chatId:e,focusMessageId:r,children:(0,J.jsx)(vne,{chatId:e,children:(0,J.jsxs)(QG.Root,{className:`oc-thread`,children:[(0,J.jsx)(qne,{chatId:e}),(0,J.jsx)(Gne,{chatId:e}),i?(0,J.jsx)(Rne,{}):null,(0,J.jsx)(zne,{chatId:e,ready:!i,focusMessageId:r}),(0,J.jsxs)(QG.Viewport,{className:`oc-thread__viewport`,style:i?{display:`none`}:void 0,children:[(0,J.jsx)(QG.Empty,{children:(0,J.jsx)(Kne,{})}),(0,J.jsx)(QG.Messages,{components:{UserMessage:dre,AssistantMessage:gre,SystemMessage:_re}}),V&&ie===null?(0,J.jsx)(R7,{quiet:P,running:z,since:B,progress:M?.progressSummary??null}):null]}),(0,J.jsx)(dK,{}),(0,J.jsx)(`div`,{className:`oc-scrolldown-anchor`,children:(0,J.jsx)(QG.If,{empty:!1,children:(0,J.jsxs)(QG.ScrollToBottom,{className:`oc-scrolldown`,children:[(0,J.jsx)(Qne,{}),(0,J.jsx)(`span`,{children:Dd()})]})})}),S===`read_only`?(0,J.jsx)(Wne,{reason:m?.readOnlyReason??null,guest:g}):S===`unavailable`?(0,J.jsx)(Une,{reason:l?.reason??null,canSwitchAgent:x}):S===`degraded`?(0,J.jsx)(Hne,{}):S===`beyond_validated`?(0,J.jsx)(Vne,{version:d}):null,(0,J.jsx)(m8,{}),(0,J.jsx)(Mne,{}),(0,J.jsx)(Ere,{chatId:e,chatTitle:C,showTools:t,onToggleTools:n,unavailable:l!==null||h,agentGate:b,onTalkCallActiveChange:v,serverCallSessionId:_?null:y?.sessionId??null,subAgentBusy:T})]})})})})})}function R7({running:e,since:t=null,anchored:n=!1,progress:r=null,quiet:i=!1}){let a=(0,q.useRef)(null);if(t!==null&&a.current?.key!==t){let e=Date.now();a.current={key:t,baselineMs:A6(t,e),firstLocalMs:e}}let[,o]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(t===null)return;let e=window.setInterval(()=>o(e=>e+1),1e3);return()=>window.clearInterval(e)},[t]);let s=!n&&t!==null&&a.current!==null&&a.current.key===t?N6(j6(a.current.baselineMs,a.current.firstLocalMs,Date.now())):null;return(0,J.jsxs)(`div`,{className:`oc-turn-activity${n?` oc-turn-activity--anchored`:``}`,children:[i?(0,J.jsx)(vC,{size:13,className:`oc-turn-activity__mark`,"aria-hidden":!0}):(0,J.jsxs)(`span`,{className:`oc-dots`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{}),(0,J.jsx)(`span`,{})]}),(0,J.jsx)(`span`,{role:`status`,className:r===null?void 0:`oc-sr-only`,children:e?wp():D()}),r===null?null:(0,J.jsx)(`span`,{className:`oc-turn-activity__progress`,title:r,children:r}),s===null?null:(0,J.jsx)(`span`,{className:`oc-turn-activity__clock`,role:`timer`,children:s})]})}function Vne({version:e}){return(0,J.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--warn`,role:`status`,children:[(0,J.jsx)(dA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e===null?Vm():xm({version:e})})]})}function Hne(){return(0,J.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--warn`,role:`status`,children:[(0,J.jsx)(dA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:Pg()})]})}function Une({reason:e,canSwitchAgent:t}){let n=e===`instance_unreachable`?t?Sy():l_():Dee();return(0,J.jsxs)(`div`,{className:`oc-chat-banner oc-chat-banner--error`,role:`status`,children:[(0,J.jsx)(dA,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n})]})}function Wne({reason:e,guest:t}){let n=e===`viewer`?pp():t?Uy():$p();return(0,J.jsxs)(`div`,{className:`oc-chat-banner ${e===`viewer`?`oc-chat-banner--info`:`oc-chat-banner--error`}`,role:`status`,children:[(0,J.jsx)(AC,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:n})]})}function Gne({chatId:e}){let t=U(G.messages.listByChat,{chatId:e}),[n,r]=(0,q.useState)(``),i=(0,q.useRef)(null);return(0,q.useEffect)(()=>{i.current=null,r(``)},[e]),(0,q.useEffect)(()=>{if(!t)return;let e;for(let n of t)n.role===`assistant`&&(e=n);if(!(!e||e.status!==`complete`)){if(i.current===null){i.current=e._id;return}i.current!==e._id&&(i.current=e._id,r(e=>e===sp()?`${sp()} `:sp()))}},[t]),(0,J.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:`oc-sr-only`,children:n})}function Kne(){return(0,J.jsxs)(`div`,{className:`oc-emptystate`,children:[(0,J.jsx)(I7,{className:`oc-emptystate__avatar`}),(0,J.jsx)(`h2`,{className:`oc-emptystate__title`,children:Ly()})]})}function z7({chatId:e,viewerRole:t}){let n=F7()?.nextTarget??null,r=tC(U(G.agents.usageForChat,t===`participant`?`skip`:{chatId:e,...n?{routedAgent:{instanceName:n.instanceName,agentId:n.agentId}}:{}})?.usage??null,Date.now());if(!r)return null;let i=r.windows.map(e=>`${e.provider} ${e.label}: ${e.percentLeft}%`+(e.resetText?` ⏱${e.resetText}`:``)).join(` · `);return(0,J.jsxs)(`span`,{className:`oc-meter ${r.level}`,title:Vr({detail:i}),children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${r.percentLeft}%`}})}),(0,J.jsx)(`span`,{className:`oc-meter__label`,children:Tu({pct:r.percentLeft})})]})}function B7({sm:e,detail:t=!0}){let n=TT(e),r=IT(e),i=NT(e),a=n!=null&&i?Math.round(n/i*100):null;if(a==null||n==null)return i?(0,J.jsx)(`span`,{className:`oc-meter is-unknown`,title:Kr(),role:`status`,children:(0,J.jsx)(`span`,{className:`oc-meter__label`,children:`—`})}):null;let o=a>=90?`is-critical`:a>=75?`is-warn`:`is-ok`,s=kT(e);return(0,J.jsxs)(`span`,{className:`oc-meter ${o}`,title:`${Yo({pct:a,used:AT(n),total:AT(i)})}\n${r===`budget_estimate`?rd():au()}${s?`\n${Au({gateway:s.gateway,delta:s.delta})}`:``}`,children:[(0,J.jsx)(`span`,{className:`oc-meter__track`,children:(0,J.jsx)(`span`,{className:`oc-meter__fill`,style:{width:`${Math.min(a,100)}%`}})}),(0,J.jsxs)(`span`,{className:`oc-meter__label`,children:[a,`%`,t?(0,J.jsxs)(`span`,{className:`oc-meter__detail`,children:[` · `,AT(n),`/`,AT(i)]}):null]})]})}function qne({chatId:e}){let t=U(G.messages.getSessionMeta,{chatId:e}),n=Kx(),r=U(G.projects.listProjects,{}),i=(0,q.useMemo)(()=>{let e=t?.projectId??null;return e===null||r===void 0?[]:cS(r,e)},[t?.projectId,r]),a=t?.sessionMeta??null,o=t?.sessionSettings??null,s=D7(),c=f7(),[l,u]=(0,q.useState)(!1),d=(0,q.useRef)(null),f=(0,q.useRef)(null),p=(0,q.useRef)(null),[m,g]=(0,q.useState)(!1),_=O5(a),v=!DT(o,`thinkingLevel`),y=(n,r)=>(0,J.jsxs)(J.Fragment,{children:[s.showTools&&!n&&a?.model?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:a.modelProvider?Sv({provider:a.modelProvider}):th(),children:[(0,J.jsx)(Xne,{}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:a.model})]}):null,s.showTools&&!n&&a?.thinkingLevel?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:v?t_():my(),children:[(0,J.jsx)(Zne,{}),(0,J.jsxs)(`span`,{className:`oc-chip__label`,children:[Ap(),`\xA0: `,ST(a.thinkingLevel)]}),v?(0,J.jsx)(`span`,{className:`oc-chip__hint`,children:h()}):null]}):null,_?(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--info`,title:_.title,children:[(0,J.jsx)(AC,{size:13,"aria-hidden":!0}),n?(0,J.jsx)(`span`,{className:`sr-only`,children:_.label}):(0,J.jsx)(`span`,{className:`oc-chip__label`,children:_.label})]}):null,s.showTools&&a?(0,J.jsx)(B7,{sm:a,detail:!n}):null,s.showUsage&&!a?(0,J.jsx)(z7,{chatId:e,viewerRole:t?.viewerRole}):null,(0,J.jsx)(Pne,{compact:n,ghost:r}),(0,J.jsx)(Jne,{chatId:e,title:t?.title??null,compact:n,ghost:r}),t?.viewerRole===`owner`?(0,J.jsx)(Yne,{chatId:e,viewerRole:t?.viewerRole,sm:a,settings:o,onOpenPanel:()=>u(!0),compact:n,ghost:r,showUsage:s.showUsage&&a!==null}):null]});return(0,q.useLayoutEffect)(()=>{let e=d.current;if(!e)return;let t=()=>{let t=p.current?.offsetWidth??0;if(t===0)return;let n=Math.min(f.current?.scrollWidth??0,360),r=e.clientWidth-n-16<t;g(e=>e===r?e:r)};t();let n=new ResizeObserver(t);return n.observe(e),p.current&&n.observe(p.current),()=>n.disconnect()},[[Dl(),c===null?``:`${+(c.rows.length>0)}:${c.waiting.length}`,ge(),t?.viewerRole??``,a?.model??``,a?.thinkingLevel??``,_?.label??``,t?.title??``,i.map(e=>e.name).join(`/`),s.showTools?`1`:`0`].join(`|`)]),(0,J.jsxs)(`header`,{className:`oc-chathead`,ref:d,children:[(0,J.jsxs)(`div`,{className:`oc-chathead__titlebox`,ref:f,children:[i.length>0?(0,J.jsx)(`nav`,{className:`oc-chathead__crumbs`,"aria-label":dy(),children:i.map((e,t)=>(0,J.jsxs)(`span`,{className:`oc-chathead__crumb`,children:[t>0?(0,J.jsx)(`span`,{className:`oc-chathead__crumbsep`,"aria-hidden":!0,children:`›`}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-chathead__crumblink`,onClick:()=>void n({to:`/project/$projectId`,params:{projectId:e._id}}),children:e.name})]},e._id))}):null,(0,J.jsx)(`div`,{className:`oc-chathead__title`,title:t?.title??void 0,children:t?.title||pg()})]}),(0,J.jsx)(`div`,{className:`oc-chathead__meta`,children:y(m,!1)}),(0,J.jsx)(`div`,{className:`oc-chathead-ghost`,"aria-hidden":!0,ref:p,children:y(!1,!0)}),t?.viewerRole===`owner`?(0,J.jsx)(_5,{chatId:e,open:l,onOpenChange:u}):null]})}function V7(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}function Jne({chatId:e,title:t,compact:n=!1,ghost:r=!1}){let i=Ia();async function a(n){let[r,a]=await Promise.all([i.query(G.messages.listByChat,{chatId:e}),i.query(G.messages.getStreamingText,{chatId:e})]),o=new Map(a.map(e=>[e.messageId,e.text])),s=r.map(e=>({role:e.role,text:e.status===`streaming`?o.get(e._id)??e.text:e.text,createdAt:e.updatedAt??e._creationTime,...e.quotedRefs!==void 0&&e.quotedRefs.length>0?{quotedExcerpts:e.quotedRefs.map(e=>e.excerpt)}:{},parts:e.parts.map(e=>({kind:e.kind,filename:`filename`in e?e.filename:void 0,name:`name`in e?e.name:void 0}))})),c=r.length>=200,l={title:t??void 0,truncated:c,exportedAt:Date.now()},u=E2(t);n===`md`?V7(w2(s,l),`${u}.md`,`text/markdown`):V7(T2(s,l),`${u}.json`,`application/json`)}let o=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(xC,{size:13,"aria-hidden":!0}),n?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-chip__label`,children:Dl()}),(0,J.jsx)(XS,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return r?(0,J.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:o}):(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:yn(),children:o})}),(0,J.jsxs)(fC,{align:`end`,className:`w-44`,children:[(0,J.jsx)(lC,{children:Dl()}),(0,J.jsx)(hC,{onClick:()=>void a(`md`),children:kc()}),(0,J.jsx)(hC,{onClick:()=>void a(`json`),children:Kn()})]})]})}function Yne({chatId:e,viewerRole:t,sm:n,settings:r,onOpenPanel:i,compact:a=!1,ghost:o=!1,showUsage:s=!1}){let[c,l]=(0,q.useState)(!1),u=F7(),d=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(UC,{size:13,"aria-hidden":!0}),a?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-chip__label`,children:ge()}),(0,J.jsx)(XS,{size:13,className:`oc-chip__chev`,"aria-hidden":!0})]})]});return o?(0,J.jsx)(`span`,{className:`oc-chip oc-chip--btn`,children:d}):(0,J.jsxs)(bw,{open:c,onOpenChange:l,children:[(0,J.jsx)(yw,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-chip oc-chip--btn`,title:tl(),children:d})}),(0,J.jsxs)(vw,{align:`end`,className:`oc-spanel-pop w-80 p-2`,children:[n!==null&&NT(n)?(0,J.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,J.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:fi()}),(0,J.jsx)(B7,{sm:n})]}):null,s?(0,J.jsxs)(`div`,{className:`oc-spanel-pop__usage`,children:[(0,J.jsx)(`span`,{className:`oc-spanel-pop__usage-label`,children:Qd()}),(0,J.jsx)(z7,{chatId:e,viewerRole:t})]}):null,(0,J.jsx)(jT,{chatId:e,sm:n,settings:r}),(0,J.jsx)(K5,{chatId:e,routedAgent:u?.nextTarget?{instanceName:u.nextTarget.instanceName,agentId:u.nextTarget.agentId}:null,multiAgent:u?.perTurnRouting===!0||(u?.roomAgents?.length??0)>0}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-spanel-pop__all`,onClick:()=>{l(!1),i()},children:[(0,J.jsx)(UC,{size:13,"aria-hidden":!0}),zo(),(0,J.jsx)(QS,{size:13,"aria-hidden":!0})]})]})]})}function Xne(){return(0,J.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,J.jsx)(`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`}),(0,J.jsx)(`rect`,{x:`9`,y:`9`,width:`6`,height:`6`}),(0,J.jsx)(`path`,{d:`M9 1v3M15 1v3M9 20v3M15 20v3M20 9h3M20 14h3M1 9h3M1 14h3`})]})}function Zne(){return(0,J.jsxs)(`svg`,{className:`oc-chip__icon`,viewBox:`0 0 24 24`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:[(0,J.jsx)(`path`,{d:`M12 5a3 3 0 1 0-5.997.142 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z`}),(0,J.jsx)(`path`,{d:`M12 5a3 3 0 1 1 5.997.142 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z`})]})}function H7({children:e}){return(0,J.jsx)(`svg`,{viewBox:`0 0 24 24`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0,children:e})}function Qne(){return(0,J.jsx)(H7,{children:(0,J.jsx)(`path`,{d:`M12 5v14M19 12l-7 7-7-7`})})}var $ne=`bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 oc-overlay-layer min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border p-1 shadow-md`,U7=`focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`;function ere({sourceShown:e,sourceActive:t,onToggleSource:n}){let r=$(e=>e.metadata?.custom?.messageId),i=$(e=>e.metadata?.custom?.sentAt),a=$(e=>e.metadata?.custom?.generationMs??null),o=$(e=>e.metadata?.custom?.status===`streaming`),s=W(G.chatFork.forkChat),c=(0,q.useContext)(M7),l=pT(),u=Mw(),[d,f]=(0,q.useState)(!1);if(!r)return null;let p=async()=>{let e=await l({title:ro(),description:uc(),label:xp(),placeholder:Eb(),confirmLabel:ut(),allowEmpty:!0});if(e!==null){f(!0);try{let{chatId:t}=await s({branchMessageId:r,...e.trim()?{title:e.trim()}:{}});M2(t,{expand:!0}),u.success(At())}catch(e){u.error(Ue(),e)}finally{f(!1)}}};return(0,J.jsxs)(TH.Root,{children:[(0,J.jsx)(TH.Trigger,{className:`oc-iconbtn`,title:S_(),"aria-label":S_(),disabled:d,children:(0,J.jsx)(yA,{size:15})}),(0,J.jsxs)(TH.Content,{align:`end`,sideOffset:4,className:$ne,children:[i===void 0?null:(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`oc-msgmenu__when px-2 py-1.5 text-sm`,children:[Kw(i,{dateStyle:`medium`,timeStyle:`short`}),(()=>{let e=a===null?null:qw(a);return e===null?null:(0,J.jsxs)(`span`,{className:`oc-msgmenu__duration`,children:[(0,J.jsx)(_j,{size:12,"aria-hidden":!0}),wu({duration:e})]})})()]}),(0,J.jsx)(TH.Separator,{className:`bg-border -mx-1 my-1 h-px`})]}),e?(0,J.jsxs)(TH.Item,{className:U7,onSelect:n,children:[(0,J.jsx)(mA,{size:14,"aria-hidden":!0}),t?Wi():Cr()]}):null,c?(0,J.jsxs)(TH.Item,{className:U7,disabled:d||o,onSelect:()=>void p(),children:[(0,J.jsx)(DA,{size:14,"aria-hidden":!0}),ro()]}):null,(0,J.jsx)(tre,{})]})]})}function tre(){let e=oK(),t=$(e=>e.id);if(!e)return null;let n=e.byMessage.get(t)?.some(e=>e.blockIndex===null)??!1;return(0,J.jsxs)(TH.Item,{className:U7,onSelect:()=>e.toggle(t,null),children:[(0,J.jsx)(cA,{size:14,"aria-hidden":!0}),n?v():Rp()]})}function nre(){let[e,t]=(0,q.useState)(!1),n=$(e=>e.content.filter(e=>e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(`
153
+ `)),r=$(e=>e.metadata?.custom?.groupText??null),i=r!==null&&r.trim()!==``?r:n,a=xQ($(e=>e.metadata?.custom?.error??null),$(e=>e.metadata?.custom?.errorCode??null)),o=i.trim()||[a.headline,a.detail,a.rawDetail].filter(Boolean).join(`
154
+ `),s=o.length===0;return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Uh(),"aria-label":Uh(),disabled:s,onClick:()=>{navigator.clipboard.writeText(o).then(()=>{t(!0),window.setTimeout(()=>t(!1),1500)})},children:e?(0,J.jsx)(G7,{}):(0,J.jsx)(W7,{})})}function rre(e){let t=(0,q.useContext)(S7),n=(0,q.useContext)(C7),r=$(e=>e.metadata?.custom?.messageId??e.id),i=D7().autoReadAloud,a=$(e=>e.metadata?.custom?.status??``),o=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t.loaded)return;let s=o.current;o.current=a,!(!t.enabled||!t.autoRead||t.engine===`gateway`||!i||!HS())&&(a!==`complete`||s===null||s===`complete`||e.trim()&&VS(RS(e),{lang:GS(t.lang,ft()),rate:t.rate,onEnd:()=>n.clearIf(r)})&&n.setActive({messageId:r,phase:`playing`}))},[a,e,t,n,r,i])}function ire(){let e=(0,q.useContext)(S7),t=(0,q.useContext)(C7),n=pa(G.voice.gatewayTts),r=Mw(),i=$(e=>e.metadata?.custom?.messageId??e.id),a=$(e=>e.metadata?.custom?.chatId??null),o=$(e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
155
+ `)),s=$(e=>e.metadata?.custom?.groupText??null),c=s!==null&&s.trim()!==``?s:o,l=e.engine!==`gateway`;if(!e.enabled||!c.trim()||l&&!HS())return null;let u=GS(e.lang,ft()),d=t.active?.messageId===i,f=d&&t.active?.phase===`loading`,p=d&&t.active?.phase===`playing`,m=()=>{T7();let o=RS(c);if(l){let n=VS(o,{lang:u,rate:e.rate,onEnd:()=>t.clearIf(i)});t.setActive(n?{messageId:i,phase:`playing`}:null);return}if(!a)return;let s=w7;t.setActive({messageId:i,phase:`loading`}),n({chatId:a,text:o.slice(0,1500)}).then(({mime:n,audioBase64:r})=>{if(s!==w7)return;let a=US(r,n,{rate:e.rate,onEnd:()=>t.clearIf(i)});t.setActive(a?{messageId:i,phase:`playing`}:null)}).catch(e=>{s===w7&&(r.error(Bg(),e),t.setActive(null))})};return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn${d?` oc-iconbtn--reading`:``}`,title:d?Bb():Cc(),"aria-label":d?Bb():Cc(),"aria-pressed":d,"aria-busy":f,onClick:()=>{if(d){T7(),t.setActive(null);return}m()},children:f?(0,J.jsx)(kC,{size:16,className:`oc-actrow__spin`,"aria-hidden":!0}):p?(0,J.jsx)(sre,{}):(0,J.jsx)(ore,{})})}function are(){let e=(0,q.useContext)(C7);if(!e.active)return null;let t=e.active.phase===`loading`;return(0,J.jsxs)(`div`,{className:`oc-reading-banner`,role:`status`,children:[t?(0,J.jsx)(kC,{size:14,className:`oc-actrow__spin`,"aria-hidden":!0}):(0,J.jsx)(JS,{size:14,className:`oc-reading-banner__pulse`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:t?P_():om()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-reading-banner__stop`,onClick:()=>{T7(),e.setActive(null)},children:Bb()})]})}function ore(){return(0,J.jsxs)(H7,{children:[(0,J.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5z`}),(0,J.jsx)(`path`,{d:`M15.5 8.5a5 5 0 0 1 0 7`})]})}function sre(){return(0,J.jsxs)(H7,{children:[(0,J.jsx)(`path`,{d:`M11 5 6 9H2v6h4l5 4V5z`}),(0,J.jsx)(`line`,{x1:`22`,y1:`9`,x2:`16`,y2:`15`}),(0,J.jsx)(`line`,{x1:`16`,y1:`9`,x2:`22`,y2:`15`})]})}function W7(){return(0,J.jsxs)(H7,{children:[(0,J.jsx)(`rect`,{x:`9`,y:`9`,width:`13`,height:`13`,rx:`2`}),(0,J.jsx)(`path`,{d:`M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1`})]})}function G7(){return(0,J.jsx)(H7,{children:(0,J.jsx)(`path`,{d:`M20 6 9 17l-5-5`})})}function cre({text:e}){let t=$(e=>e.metadata?.custom?.mentions??null);if(t===null||t.length===0)return(0,J.jsx)(J.Fragment,{children:e});let n=[],r=0;for(let[i,a]of t.entries())a.start<r||a.end>e.length||(a.start>r&&n.push(e.slice(r,a.start)),n.push((0,J.jsx)(`span`,{className:`oc-mention${a.isViewer?` oc-mention--self`:``}${a.isAgent===!0?` oc-mention--agent`:``}`,title:a.name,children:e.slice(a.start,a.end)},`${a.start}-${i}`)),r=a.end);return r<e.length&&n.push(e.slice(r)),(0,J.jsx)(J.Fragment,{children:n})}var K7={File:$8,Text:cre},lre={...K7,Text:lq,data:{by_name:{widget:n0,thinking:d8,commentary:p8}},tools:{by_name:{__turn_flow__:l8,__delegated_reply__:mre}}};function q7({kind:e}){let t=$(e=>z3(e.metadata?.custom)),n=W(G.messages.deleteMessage).withOptimisticUpdate(C6),r=fT(),i=Mw(),a=(0,q.useContext)(O7),[o,s]=(0,q.useState)(!1),c=FV(e=>e.isRunning);if(!t)return null;async function l(){if(await r(e===`assistant`?{title:Gee(),description:hs(),confirmLabel:Bi(),cancelLabel:yr(),destructive:!0}:{title:Yt(),description:bo(),confirmLabel:ka(),cancelLabel:yr(),destructive:!0})){s(!0),e===`assistant`&&a?.begin();try{await n({messageId:t})}catch(t){e===`assistant`&&a?.cancel(),i.error(zh(),t)}finally{s(!1)}}}return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn oc-iconbtn--danger`,title:c?Ms():e===`assistant`?sa():_h(),"aria-label":P(),"aria-busy":o,disabled:o||c,onClick:()=>void l(),children:o?(0,J.jsx)(kC,{size:15,className:`oc-iconbtn__spin`,"aria-hidden":!0}):(0,J.jsx)(GC,{size:15,"aria-hidden":!0})})}function J7(){let e=$(e=>e.metadata?.custom?.rawText??``),t=$(e=>e.metadata?.custom?.chatId),n=$(e=>e.metadata?.custom?.messageId),r=$(e=>e.metadata?.custom?.allToolParts??e.metadata?.custom?.toolParts??Y7),i=U(G.subAgents.listSubAgents,e===``&&t?{chatId:t}:`skip`),a=e===``?GQ(i??[],E8(r),n).find(e=>e.status===`done`&&e.resultText)?.resultText??``:``,o=e===``&&a!==``,s=e===``?a:e,[c,l]=(0,q.useState)(!1),u=[...s].length;return(0,J.jsxs)(`div`,{className:`oc-msg__source`,children:[(0,J.jsxs)(`div`,{className:`oc-msg__source-head`,children:[(0,J.jsx)(`span`,{className:`oc-msg__source-label`,children:o?be({count:u}):u>1?al({count:u}):Xn({count:u})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn`,title:Tx(),"aria-label":Tx(),onClick:()=>{navigator.clipboard?.writeText(s).then(()=>{l(!0),window.setTimeout(()=>l(!1),1200)})},children:c?(0,J.jsx)(G7,{}):(0,J.jsx)(W7,{})})]}),(0,J.jsx)(`pre`,{className:`oc-msg__source-pre`,children:s.length>0?s:ys()})]})}function ure({active:e,onToggle:t}){return(0,J.jsx)(`button`,{type:`button`,className:`oc-iconbtn${e?` is-on`:``}`,onClick:t,"aria-pressed":e,title:e?Wi():Cr(),"aria-label":$t(),children:(0,J.jsx)(mA,{size:15,"aria-hidden":!0})})}function dre(){let[e,t]=(0,q.useState)(!1),n=D7(),r=$(e=>e.id.startsWith(`optimistic-`)),i=$(e=>e.metadata?.custom?.queued===!0),a=$(e=>e.id),o=$(e=>e.metadata?.custom?.custody??null),s=$(e=>e.metadata?.custom?.chatId??null),{can:c}=PT(o===`queued`?s:null),l=$(e=>e.metadata?.custom?.quotedRefs??null),u=Mw(),d=$(e=>e.metadata?.custom?.authorName??null);return(0,J.jsx)(gG.Root,{className:`oc-msg oc-msg--user${r?` is-sending`:``}${i?` is-queued`:``}`,"data-message-id":a,children:(0,J.jsxs)(`div`,{className:`oc-msg__col oc-msg__col--user`,children:[(0,J.jsx)(pK,{}),d===null?null:(0,J.jsx)(`div`,{className:`oc-msg__author`,children:cx({name:d})}),l?.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,className:`oc-msg__quote`,title:p_(),onClick:e.messageId?()=>Z7(e.messageId,e.blockIndex,u):void 0,children:[(0,J.jsx)(nj,{size:12,"aria-hidden":!0,className:`oc-msg__quote-ico`}),(0,J.jsx)(`span`,{className:`oc-msg__quote-text`,children:e.excerpt})]},`${e.messageId??`orphan`}:${e.blockIndex??`all`}:${t}`))??null,(0,J.jsx)(`div`,{className:`oc-msg__bubble`,children:e?(0,J.jsx)(J7,{}):(0,J.jsx)(gG.Parts,{components:K7})}),r?(0,J.jsxs)(`span`,{className:`oc-msg__sending`,role:`status`,children:[(0,J.jsx)(`span`,{className:`oc-msg__sending-spin`,"aria-hidden":!0}),Pa()]}):i?(0,J.jsxs)(`span`,{className:`oc-msg__queued`,role:`status`,children:[(0,J.jsx)(vC,{size:12,"aria-hidden":!0}),da()]}):(0,J.jsxs)(J.Fragment,{children:[c6(o)===null?null:(0,J.jsx)(v8,{custody:o,messageId:a,canWithdraw:c(`discardPendingInput`)}),(0,J.jsxs)(mH.Root,{className:`oc-msg__actions oc-msg__actions--user`,autohide:`not-last`,children:[(0,J.jsx)(_K,{}),n.copyUser?(0,J.jsxs)(mH.Copy,{className:`oc-iconbtn`,title:wo(),children:[(0,J.jsx)(gG.If,{copied:!0,children:(0,J.jsx)(G7,{})}),(0,J.jsx)(gG.If,{copied:!1,children:(0,J.jsx)(W7,{})})]}):null,n.showSource?(0,J.jsx)(ure,{active:e,onToggle:()=>t(e=>!e)}):null,n.showReport?(0,J.jsx)(m5,{}):null,n.showDelete?(0,J.jsx)(q7,{kind:`user`}):null]})]})]})})}function fre({pool:e,agent:t}){let n=c2(e,t),r=n?.displayName??t.agentId;return(0,J.jsxs)(`span`,{className:`oc-chip oc-chip--agent oc-msg__agent`,title:Bf({name:r}),children:[n?.emoji?(0,J.jsx)(`span`,{className:`oc-chip__emoji`,"aria-hidden":!0,children:n.emoji}):(0,J.jsx)(kS,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-chip__label`,children:r})]})}var Y7=[],pre=[];function X7(){let e=(0,q.useRef)(null),[t,n]=(0,q.useState)(null);return(0,q.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>{let e=0;try{e=t.getTotalLength()}catch{e=0}if(!e){let n=t.getBoundingClientRect();e=2*(n.width+n.height)}e>0&&n(Math.round(e))};r();let i=new ResizeObserver(r);return i.observe(t.ownerSVGElement??t),()=>i.disconnect()},[]),(0,J.jsxs)(`svg`,{className:`oc-empty-answer__ants`,"aria-hidden":!0,children:[(0,J.jsx)(`rect`,{ref:e}),t===null?null:(0,J.jsx)(`rect`,{className:`oc-ants-accent`,style:{strokeDasharray:`3 3 3 3 3 ${Math.max(t-15,6)}`,animationDuration:`${Math.max(t*4,800)}ms`,animationTimingFunction:`steps(${Math.max(Math.round(t/6),8)}, end)`,"--oc-ants-p":`${t}px`}})]})}function mre(e){let t=$(e=>e.metadata?.custom?.chatId),n=$(e=>e.metadata?.custom?.messageId),r=I8(U(G.subAgents.listSubAgents,t?{chatId:t}:`skip`),n,e.args?.slot);return r.length===0?null:(0,J.jsx)(J.Fragment,{children:r.map(e=>(0,J.jsxs)(`div`,{className:`oc-delegated-reply`,children:[e.agentId?(0,J.jsxs)(`div`,{className:`oc-empty-answer__from`,role:`note`,children:[(0,J.jsx)(gA,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:fb({agent:e.agentId})})]}):null,(0,J.jsx)(cq,{text:e.resultText})]},e.childSessionKey))})}function hre({show:e}){let t=$(e=>e.metadata?.custom?.status),n=$(e=>e.metadata?.custom?.steerSegment===!0),r=$(e=>e.metadata?.custom?.chatId),i=$(e=>SQ(e.content)),a=$(e=>e.content.some(e=>e?.type===`file`||e?.type===`data`&&e.name===`widget`)),o=$(e=>e.metadata?.custom?.allToolParts??e.metadata?.custom?.toolParts??Y7),s=U(G.subAgents.listSubAgents,r?{chatId:r}:`skip`),c=$(e=>e.metadata?.custom?.messageId),l=$(e=>e.metadata?.custom?.settledAt??void 0),u=$(e=>e.metadata?.custom?.hasContinuation===!0),d=$(e=>e.metadata?.custom?.answeredChildRunIds??pre),f=$(e=>e.metadata?.custom?.handOff??null),p=$(e=>e.metadata?.custom?.repeatWithheld===!0),[,m]=(0,q.useState)(0),h=F8({status:t,hasText:i||p,hasMedia:a,settledAt:l,delegatedInline:u,answeredChildRunIds:d,...f===null?{}:{projected:f.projected,resumedChildRunIds:f.resumedChildRunIds,resumedChildKeys:f.resumedChildKeys,laterUserTurn:f.laterUserTurn}},o,s,c),g=h.kind===`composing`||h.kind===`waiting`?h.recheckAt??null:null;return(0,q.useEffect)(()=>{if(g===null)return;let e=window.setTimeout(()=>m(e=>e+1),Math.max(g-Date.now(),0)+250);return()=>window.clearTimeout(e)},[g]),h.kind===`none`||n||f?.projected===!0&&(h.kind===`composing`||h.kind===`waiting`)?null:h.kind===`composing`?(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--waiting`,role:`status`,children:[(0,J.jsx)(X7,{}),(0,J.jsx)(kC,{size:15,className:`oc-empty-answer__spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:h.taskName?Ys({task:h.taskName}):Ze()})]}):h.kind===`failed`?e&&h.cardSilent!==!0?null:(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--failed`,role:`status`,children:[(0,J.jsx)(kS,{size:15,className:`oc-empty-answer__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:h.taskName?Tf({task:h.taskName,reason:h.reason}):rx({reason:h.reason})})]}):h.kind===`waiting`?e&&h.recheckAt===void 0?null:(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--waiting`,role:`status`,children:[(0,J.jsx)(X7,{}),(0,J.jsx)(kC,{size:15,className:`oc-empty-answer__spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:h.taskName?Pb({task:h.taskName}):_c()})]}):h.kind===`done`?h.resultText?(0,J.jsxs)(J.Fragment,{children:[h.agentId?(0,J.jsxs)(`div`,{className:`oc-empty-answer__from`,role:`note`,children:[(0,J.jsx)(gA,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:fb({agent:h.agentId})})]}):null,(0,J.jsx)(cq,{text:h.resultText})]}):null:(0,J.jsxs)(`div`,{className:`oc-empty-answer oc-empty-answer--generic`,role:`status`,children:[(0,J.jsx)(kS,{size:15,className:`oc-empty-answer__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-empty-answer__text`,children:Fee()})]})}function gre(){let[e,t]=(0,q.useState)(!1),n=D7(),r=W0(),i=$(e=>e.id),a=(0,q.useContext)(N7),o=Mw(),s=(0,q.useCallback)((e,t)=>{let n=aM(e,t);n===`too-many`?o.error(ce({count:10})):n===`too-long`&&o.error(tg())},[o]),c=$(e=>e.metadata?.custom?.groupText??e.metadata?.custom?.rawText??``),l=$(e=>e.status?.type===`running`),u=$(e=>e.metadata?.custom?.chatId),d=$(e=>e.metadata?.custom?.messageId),f=$(e=>e.metadata?.custom?.status),p=$(e=>e.content.some(e=>e?.type===`file`)),m=$(e=>e.metadata?.custom?.allToolParts??e.metadata?.custom?.toolParts??Y7),h=U(G.subAgents.listSubAgents,c===``&&u?{chatId:u}:`skip`),g=c===``?F8({status:f,hasText:!1,hasMedia:p},m,h,d):null,_=c===``?g?.kind===`done`?g.resultText??``:``:c,v=(0,q.useContext)(P6),y=v!==null&&v.messageId===i?v:null,b=$(e=>e.metadata?.custom?.status),x=(0,q.useContext)(h8),S=$(e=>q8(e.metadata?.custom?.steerSegment===!0,e.content)),C=$(e=>e.metadata?.custom?.groupFollows===!0),w=$(e=>e.metadata?.custom?.groupContinues===!0);rre($(e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
156
+ `)));let T=F7(),E=T&&T.perTurnRouting?T.messageAgents.has(i)?T.messageAgents.get(i)??T.primary:T.fallbackAgent:null,D=T?.pool,O=$(e=>e.metadata?.custom?.importedAgentLabel??null),k=(0,q.useMemo)(()=>{if(O!==null)return{...r,agentName:O,agentEmoji:null};if(!E)return r;let e=c2(D??[],E);return{...r,agentName:e?.displayName??E.agentId,agentEmoji:e?.emoji??null}},[O,E,r,D]);return b===void 0&&x||S&&!n.showTools?null:(0,J.jsxs)(gG.Root,{className:`oc-msg oc-msg--assistant${C?` oc-msg--group-follow`:``}${w?` oc-msg--group-continues`:``}`,"data-message-id":i,children:[C?(0,J.jsx)(`span`,{className:`oc-msg__avatar oc-msg__avatar--group`,"aria-hidden":!0}):(0,J.jsx)(I7,{className:`oc-msg__avatar`}),(0,J.jsxs)(`div`,{className:`oc-msg__col`,children:[C?null:(0,J.jsxs)(`div`,{className:`oc-msg__name`,children:[E?(0,J.jsx)(fre,{pool:T.pool,agent:E}):(0,J.jsxs)(J.Fragment,{children:[r.agentEmoji?(0,J.jsx)(`span`,{className:`oc-msg__name-emoji`,"aria-hidden":!0,children:r.agentEmoji}):null,G0(r)]}),(0,J.jsx)(_K,{header:!0}),a!==null&&!i.startsWith(`optimistic-`)&&!l&&_!==``?(0,J.jsx)(`button`,{type:`button`,className:`oc-bmk-headbtn`,title:dh(),"aria-label":dh(),onClick:()=>{let e=iK(_,280);e!==``&&s(a,{messageId:i,blockIndex:null,excerpt:e})},children:(0,J.jsx)(nj,{size:13})}):null]}),(0,J.jsxs)(`div`,{className:`oc-msg__body`,children:[(0,J.jsx)(L6,{}),(0,J.jsx)(`div`,{className:`oc-msg__meta oc-msg__meta--cron`,children:(0,J.jsx)(EK,{})}),n.showTools?(0,J.jsxs)(`div`,{className:`oc-msg__meta`,children:[(0,J.jsx)(z2,{}),(0,J.jsx)(H8,{}),(0,J.jsx)(y8,{}),(0,J.jsx)(yJ,{})]}):null,(0,J.jsx)(G8,{}),e?(0,J.jsx)(J7,{}):(0,J.jsx)(gG.Parts,{components:lre}),e?null:(0,J.jsx)(hre,{show:n.showTools}),(0,J.jsx)(jne,{}),(0,J.jsx)(U0.Provider,{value:k,children:(0,J.jsx)(k6,{})}),y===null?null:(0,J.jsx)(R7,{quiet:y.quiet===!0,running:y.running,since:y.workingSince,progress:y.progressSummary??null,anchored:!0})]}),(0,J.jsx)(pK,{messageLevelMarkers:!1,onReplyToBlock:a!==null&&!i.startsWith(`optimistic-`)?(e,t)=>s(a,{messageId:i,blockIndex:e,excerpt:t}):void 0}),w?null:(0,J.jsxs)(mH.Root,{className:`oc-msg__actions`,autohide:`not-last`,children:[n.copyAssistant?(0,J.jsx)(nre,{}):null,(0,J.jsx)(ire,{}),n.showReport?(0,J.jsx)(m5,{}):null,n.showDelete?(0,J.jsx)(q7,{kind:`assistant`}):null,(0,J.jsx)(ere,{sourceShown:n.showSource,sourceActive:e,onToggleSource:()=>t(e=>!e)})]})]})]})}function _re(){let e=$(e=>e.id);return(0,J.jsx)(gG.Root,{className:`oc-msg oc-msg--system`,"data-message-id":e,children:(0,J.jsx)(`div`,{className:`oc-msg__body`,children:(0,J.jsx)(gG.Parts,{components:K7})})})}function Z7(e,t,n){if(document.querySelector(`[data-message-id="${CSS.escape(e)}"]`)===null&&document.querySelector(`[data-message-id]`)!==null){n.error(Nv());return}sK(e,t,`smooth`)}function vre({chatId:e}){let t=fM(e),n=Mw();return t.length===0?null:(0,J.jsx)(`div`,{className:`oc-composer__quotes`,role:`group`,"aria-label":Ey(),children:t.map(t=>(0,J.jsxs)(`div`,{className:`oc-composer__quote`,children:[(0,J.jsx)(nj,{size:13,"aria-hidden":!0,className:`oc-composer__quote-ico`}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__quote-text`,title:p_(),onClick:()=>Z7(t.messageId,t.blockIndex,n),children:t.excerpt}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__quote-x`,"aria-label":Hp(),onClick:()=>oM(e,sM(t)),children:(0,J.jsx)(XC,{size:13,"aria-hidden":!0})})]},sM(t)))})}function yre(){let e=AV(e=>e.status?.type),t=AV(e=>e.type),n=AV(e=>e.file??null),[r,i]=(0,q.useState)(null);(0,q.useEffect)(()=>{if(t!==`image`||!n){i(null);return}let e=URL.createObjectURL(n);return i(e),()=>URL.revokeObjectURL(e)},[t,n]);let a=e===`incomplete`,o=n!==null&&zq(n),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(null),d=(0,q.useRef)(null);d.current=n;let f=n!==null&&(n.type.startsWith(`text/`)||/\.(txt|md|json|csv|log|xml|yaml|yml)$/i.test(n.name));return(0,J.jsxs)(MH.Root,{className:`oc-attach${a?` oc-attach--error`:``}${r&&!a?` oc-attach--image`:``}${o?` oc-attach--flash`:``}`,"data-status":e,children:[r&&!a?(0,J.jsx)(`img`,{src:r,alt:``,className:`oc-attach__thumb`}):(0,J.jsx)(`span`,{className:`oc-attach__icon`,"aria-hidden":!0,children:a?(0,J.jsx)(dA,{size:14}):t===`image`?(0,J.jsx)(NA,{size:14}):(0,J.jsx)(ej,{size:14})}),r&&!a?null:(0,J.jsx)(`span`,{className:`oc-attach__name`,children:(0,J.jsx)(MH.Name,{})}),a?(0,J.jsx)(`span`,{className:`oc-attach__state`,children:kp()}):null,!a&&(f||r)?(0,J.jsx)(`button`,{type:`button`,className:`oc-attach__view`,"aria-label":Zl(),title:Zl(),onClick:()=>{if(c(!0),u(null),f&&n){let e=n,t=2e5;e.slice(0,t).text().then(n=>{d.current===e&&u(e.size>t?n+`
157
+
158
+ `+zr():n)}).catch(()=>{d.current===e&&u(null)})}},children:(0,J.jsx)(CC,{size:13,"aria-hidden":!0})}):null,(0,J.jsx)(MH.Remove,{className:`oc-attach__remove`,"aria-label":Yu(),children:(0,J.jsx)(XC,{size:13,"aria-hidden":!0})}),(0,J.jsx)($w,{open:s,onOpenChange:c,children:(0,J.jsxs)(Xw,{className:`oc-attach__dialog`,children:[(0,J.jsx)(Jw,{children:(0,J.jsx)(Zw,{className:`oc-attach__dialog-title`,children:n?.name??Zl()})}),r?(0,J.jsx)(`img`,{src:r,alt:``,className:`oc-attach__dialog-img`}):l===null?(0,J.jsx)(`p`,{className:`oc-attach__dialog-text`,children:`…`}):(0,J.jsx)(`pre`,{className:`oc-attach__dialog-text`,children:l})]})})]})}function bre(){let e=(0,q.useSyncExternalStore)(s0.subscribe,s0.getSnapshot);return e.active?(0,J.jsxs)(`div`,{className:`oc-upload`,role:`status`,"aria-live":`polite`,children:[(0,J.jsxs)(`div`,{className:`oc-upload__head`,children:[(0,J.jsx)(kC,{className:`oc-upload__spin`,size:14,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:e.count>1?Vo({count:e.count,percent:e.percent}):s({percent:e.percent})})]}),(0,J.jsx)(`div`,{className:`oc-upload__track`,"aria-hidden":!0,children:(0,J.jsx)(`div`,{className:`oc-upload__bar`,style:{width:`${e.percent}%`}})})]}):null}function xre({reason:e}){let t=(0,q.useContext)(k7),n=jV(),r=MV(e=>e.text).trim().length>0,i=e===`subagent`;return(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,disabled:!r||t===null,"aria-label":i?fm():Za(),title:r?i?yp():Da():i?B_():Bo(),onClick:()=>{if(t===null)return;let e=n.getState().text;e.trim()!==``&&t(e).then(e=>{e&&n.setText(``)})},children:(0,J.jsx)(iA,{size:18,"aria-hidden":!0})})}function Q7(){let e=(0,q.useContext)(j7);return e===null?null:(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send oc-composer__stop`,"aria-label":Is(),title:aa(),onClick:()=>void e(),children:(0,J.jsx)(mj,{size:14,"aria-hidden":!0})})}function Sre({chatId:e,gate:t,onManage:n}){let r=F7(),i=U(G.chatAgents.listChatAgents,{chatId:e}),a=i?J0(i.viewerRoomRole):!1,o=Mw(),[s,c]=(0,q.useState)(!1),[l,u]=(0,q.useState)(`agents`),[d,f]=(0,q.useState)(``),[p,m]=(0,q.useState)(`member`),h=Q0(i?.viewerRoomRole),g=$0(p,i?.viewerRoomRole),[_,v]=(0,q.useState)(!1),[y,b]=(0,q.useState)(!1);(0,q.useEffect)(()=>{m(`member`),f(``),v(!1),b(!1)},[e]);let x=U(G.chatParticipants.listInvitable,a&&s&&l===`people`?{chatId:e}:`skip`),S=W(G.chatParticipants.addMember),C=W(G.chatParticipants.removeMember),w=t=>{C({chatId:e,memberId:t.userId}).then(()=>o.success(sf({name:t.name}))).catch(()=>o.error(h_()))},T=U(G.chatAgents.listAddableAgents,a&&s&&l===`agents`?{chatId:e}:`skip`),E=W(G.chatAgents.addChatAgent),D=W(G.chatAgents.removeChatAgent),k=t=>{let n=t.displayName??t.agentId;D({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).then(e=>{e.removed&&o.success(sf({name:n}))}).catch(()=>o.error(Rt()))},A=t=>{E({chatId:e,instanceName:t.instanceName,agentId:t.agentId}).catch(e=>{let t=e instanceof Error?e.message:String(e),n=/chat_agents_limit:(\d+)/.exec(t);o.error(n===null?LT(e)?Uf():mo():Va({count:Number(n[1])}))})},[j,M]=(0,q.useState)(``),N=U(G.chatParticipants.listMembers,{chatId:e}),P=jV(),F=r?.pool??[],I=r?.roomAgents??[],L=i==null?r?.primary??null:i.primary?{instanceName:i.primary.instanceName,agentId:i.primary.agentId}:null,R=(0,q.useMemo)(()=>m2(F,i?[i.primary,...i.agents]:[]),[F,i]),{room:ee,others:z}=(0,q.useMemo)(()=>d2(CS(R,j),L,I),[R,j,I,L]),B=(0,q.useMemo)(()=>f2([...R,...T??[]]),[R,T]),V=t.onCall!=null&&!F.some(e=>e2(e,t.onCall));if(!r||t.hidden&&!n)return null;let te=!t.hidden,{disabled:ne}=t,re=t=>{let n=w4(String(e),P.getState().text,{instanceName:t.instanceName,agentId:t.agentId},o4(t.displayName??t.agentId));n!==null&&P.setText(n)},ie=t.onCall??r.primary,ae=c2(F,ie),oe=new Set((T??[]).map(e=>`${e.instanceName}\u0000${e.agentId}`)),se=j.trim().toLocaleLowerCase(),ce=y2(R,T??[],j),le=ce.slice(0,8),ue=z.length+ce.length,de=_2({unfolded:_,searching:se!==``,hereCount:ee.length}),fe=e=>{let t=B.has(`${e.instanceName}\u0000${e.agentId}`),n=oe.has(`${e.instanceName}\u0000${e.agentId}`),r=p2(i?.viewerRoomRole,e,L,I),a=(0,J.jsxs)(`button`,{type:`button`,role:`option`,className:`oc-agentrow`,disabled:e.state===`deleted`||ne||!te,title:e.state===`deleted`?vb():fh({name:e.displayName??e.agentId}),onClick:()=>{re(e),c(!1),M(``)},children:[(0,J.jsx)(`span`,{className:`oc-agentrow__glyph`,title:e.kind===`hermes`?`Hermes`:`OpenClaw`,children:(0,J.jsx)(U2,{kind:e.kind,size:16})}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId,e2(e,L)?(0,J.jsx)(vA,{size:12,className:`oc-agentrow__primary`,"aria-label":Pv(),children:(0,J.jsx)(`title`,{children:Pv()})}):null]}),t?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(`span`,{className:`oc-agentrow__inst`,children:e.instanceName})}):null]}),(0,J.jsx)(aA,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},`${e.instanceName}/${e.agentId}`);if(!n&&!r)return a;let o=e.displayName??e.agentId;return(0,J.jsxs)(`div`,{className:`oc-agentrow-wrap`,children:[a,n?(0,J.jsx)(`button`,{type:`button`,className:`oc-agentrow__add`,title:eg(),"aria-label":eg(),onClick:()=>A(e),children:(0,J.jsx)(RC,{size:14,"aria-hidden":!0})}):null,r?(0,J.jsx)(`button`,{type:`button`,className:`oc-agentrow__remove`,title:w_({name:o}),"aria-label":w_({name:o}),onClick:()=>k(e),children:(0,J.jsx)(XC,{size:14,"aria-hidden":!0})}):null]},`${e.instanceName}/${e.agentId}`)},pe=+!!L+I.length,me=N?.length??1,he=Io({agents:pe,people:me,next:ie?`${ae?.displayName??ie.agentId}${(B.has(`${ie.instanceName}\u0000${ie.agentId}`)||V)&&ie?` (${ie.instanceName})`:``}`:`—`}),ge=(0,J.jsxs)(J.Fragment,{children:[te&&F.length>6||a?(0,J.jsxs)(`div`,{className:`oc-agentlist__search`,children:[(0,J.jsx)(yC,{size:14,"aria-hidden":!0}),(0,J.jsx)(`input`,{autoFocus:!0,value:j,onChange:e=>M(e.target.value),placeholder:jf(),"aria-label":Bee()})]}):null,ne?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:t.reason===`call-active`?Gv():fee()}):null,(0,J.jsxs)(`div`,{className:`oc-agentlist`,role:`listbox`,children:[ee.map(e=>fe(e)),ee.length>0&&ue>0?(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentlist__divider oc-agentlist__toggle`,"aria-expanded":de,onClick:()=>v(!de),children:[(0,J.jsx)(QS,{size:13,"aria-hidden":!0,className:`oc-agentlist__chev`}),(0,J.jsx)(`span`,{children:Ao()}),(0,J.jsx)(`span`,{className:`oc-agentlist__togglecount`,children:ue})]}):null,de?(0,J.jsx)(J.Fragment,{children:z.map(e=>{let t=`${e.instanceName}\u0000${e.agentId}`,n=oe.has(t);return(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentrow oc-agentrow--outside`,disabled:!n,onClick:()=>A(e),title:n?eg():m_(),children:[(0,J.jsx)(`span`,{className:`oc-agentrow__glyph`,children:(0,J.jsx)(U2,{kind:e.kind,size:16})}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),B.has(t)?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(`span`,{className:`oc-agentrow__inst`,children:e.instanceName})}):null]}),n?(0,J.jsx)(RC,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`}):null]},`other/${e.instanceName}/${e.agentId}`)})}):null,de&&le.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`oc-agentlist__divider`,role:`presentation`,children:bt()}),le.map(e=>(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentrow`,onClick:()=>A(e),title:eg(),children:[(0,J.jsx)(`span`,{className:`oc-agentrow__glyph`,children:(0,J.jsx)(U2,{kind:e.kind,size:16})}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.emoji?`${e.emoji} `:``,e.displayName??e.agentId]}),B.has(`${e.instanceName}\u0000${e.agentId}`)?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(`span`,{className:`oc-agentrow__inst`,children:e.instanceName})}):null]}),(0,J.jsx)(RC,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},`add/${e.instanceName}/${e.agentId}`))]}):null]})]}),_e=(t,n)=>{let r=C4(String(e),P.getState().text,String(n),o4(t));r!==null&&P.setText(r),c(!1)},ve=d.trim().toLocaleLowerCase(),ye=(N??[]).filter(e=>ve===``||e.name.toLocaleLowerCase().includes(ve)),be=(x??[]).filter(e=>e.name.toLocaleLowerCase().includes(ve)||(e.detail??``).toLocaleLowerCase().includes(ve)),xe=be.slice(0,8),Se=_2({unfolded:y,searching:ve!==``,hereCount:ye.filter(e=>!e.isSelf).length}),Ce=t=>{S({chatId:e,memberId:t.userId,role:g}).then(()=>f(``)).catch(e=>{let t=e instanceof Error?e.message:String(e),n=/participants_limit:(\d+)/.exec(t);o.error(n===null?h_():Fv({count:Number(n[1])}))})},we=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`oc-agentlist__search`,children:[(0,J.jsx)(yC,{size:14,"aria-hidden":!0}),(0,J.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:a?bc():Bt(),"aria-label":a?bc():Bt()})]}),(0,J.jsx)(`div`,{className:`oc-agentlist__caption`,children:wa()}),(0,J.jsxs)(`div`,{className:`oc-agentlist`,role:`list`,children:[ye.map(e=>{let t=(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`oc-agentrow oc-agentrow--person`,disabled:e.isSelf,onClick:()=>_e(e.name,e.userId),title:e.isSelf?void 0:Ph({name:e.name}),children:[(0,J.jsx)(H2,{userId:String(e.userId),name:e.name}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsxs)(`span`,{className:`oc-agentrow__name`,children:[e.name,e.isSelf?(0,J.jsx)(`span`,{className:`oc-agentrow__tag`,children:sx()}):null]}),(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,children:(0,J.jsx)(Cre,{role:e.roomRole})})]}),(0,J.jsx)(aA,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},String(e.userId));return Z0(i?.viewerRoomRole,e)?(0,J.jsxs)(`div`,{className:`oc-agentrow-wrap`,children:[t,(0,J.jsx)(`button`,{type:`button`,className:`oc-agentrow__remove`,title:w_({name:e.name}),"aria-label":w_({name:e.name}),onClick:()=>w(e),children:(0,J.jsx)(XC,{size:14,"aria-hidden":!0})})]},String(e.userId)):t}),a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{className:`oc-agentlist__divider oc-agentlist__divider--invite`,role:`presentation`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-agentlist__toggle`,"aria-expanded":Se,onClick:()=>b(!Se),children:[(0,J.jsx)(QS,{size:13,"aria-hidden":!0,className:`oc-agentlist__chev`}),(0,J.jsx)(`span`,{children:Lb()}),x!==void 0&&be.length>0?(0,J.jsx)(`span`,{className:`oc-agentlist__togglecount`,children:be.length}):null]}),Se?(0,J.jsxs)(`label`,{className:`oc-invite-as`,children:[(0,J.jsx)(`span`,{children:by()}),(0,J.jsxs)(aw,{value:g,onValueChange:e=>m(e),children:[(0,J.jsx)(nw,{size:`sm`,className:`oc-invite-as__trigger`,children:(0,J.jsx)(tw,{})}),(0,J.jsx)(rw,{children:h.map(e=>(0,J.jsx)(iw,{value:e,children:Y2(e)},e))})]})]}):null]}),Se?x===void 0?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:et()}):xe.length===0?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:ec()}):xe.map(e=>(0,J.jsxs)(`button`,{type:`button`,role:`listitem`,className:`oc-agentrow oc-agentrow--person`,onClick:()=>Ce(e),title:$s({name:e.name,role:Y2(g)}),children:[(0,J.jsx)(H2,{userId:String(e.userId),name:e.name}),(0,J.jsxs)(`span`,{className:`oc-agentrow__text`,children:[(0,J.jsx)(`span`,{className:`oc-agentrow__name`,children:e.name}),e.detail?(0,J.jsx)(`span`,{className:`oc-agentrow__meta`,title:e.detail,children:(0,J.jsx)(`span`,{className:`oc-agentrow__model`,children:e.detail})}):null]}),(0,J.jsx)(HC,{size:14,"aria-hidden":!0,className:`oc-agentrow__hover`})]},String(e.userId))):null,Se&&be.length>xe.length?(0,J.jsx)(`p`,{className:`oc-agentpicker__hint`,children:ey({count:be.length-xe.length})}):null]}):null]})]});return(0,J.jsxs)(`span`,{className:`oc-roompill`,children:[(0,J.jsxs)(bw,{open:s,onOpenChange:e=>{c(e),e||(M(``),v(!1),b(!1))},children:[(0,J.jsx)(yw,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-roompill__main`,title:t.reason===`call-active`?Gv():he,"aria-label":he,children:[(0,J.jsx)(WC,{size:16,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-roompill__count`,children:pe+me})]})}),(0,J.jsxs)(vw,{align:`start`,className:`oc-composer__agent-pop p-0`,children:[(0,J.jsxs)(`div`,{className:`oc-roomtabs`,role:`tablist`,children:[(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":l===`agents`,className:`oc-roomtabs__tab`,onClick:()=>u(`agents`),children:[(0,J.jsx)(kS,{size:14,"aria-hidden":!0}),Fr(),(0,J.jsx)(`span`,{className:`oc-roomtabs__count`,children:pe})]}),(0,J.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":l===`people`,className:`oc-roomtabs__tab`,onClick:()=>u(`people`),children:[(0,J.jsx)(WC,{size:14,"aria-hidden":!0}),pn(),(0,J.jsx)(`span`,{className:`oc-roomtabs__count`,children:me})]})]}),l===`agents`?ge:we]})]}),n?(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-roompill__chev`,title:qa(),"aria-label":qa(),children:(0,J.jsx)(XS,{size:13,"aria-hidden":!0})})}),(0,J.jsx)(fC,{align:`end`,className:`oc-roommenu`,children:(0,J.jsxs)(hC,{onSelect:()=>n(`agents`,null),children:[(0,J.jsx)(oj,{"aria-hidden":!0}),O()]})})]}):null]})}function Cre({role:e}){let t=e===`owner`?Kl():e===`manager`?qc():e===`viewer`?bl():ur();return(0,J.jsxs)(`span`,{className:`oc-rolemark`,title:t,children:[(0,J.jsx)(e===`owner`?vA:e===`manager`?VC:e===`viewer`?CC:vj,{size:13,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:t})]})}function wre(e){let t=(0,q.useContext)(S7),n=jV(),r=Mw(),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(``),c=(0,q.useRef)(null),l=(0,q.useRef)(null),u=(0,q.useRef)(e);u.current=e;let d=(0,q.useSyncExternalStore)(jj,Mj),f=d!==null&&d.targetChatId===e.chatId;(0,q.useEffect)(()=>()=>{c.current?.stop(),c.current=null,a(!1),s(``)},[e.chatId]);let p=(0,q.useCallback)(()=>{requestAnimationFrame(()=>{let t=e.rootRef.current?.querySelector(`.oc-composer__input`);t&&(t.scrollTop=t.scrollHeight)})},[]),m=GS(t.lang,ft()),h=(0,q.useRef)(m);h.current=m;let g=(0,q.useRef)(e.voiceInput);g.current=e.voiceInput;let _=(0,q.useCallback)(()=>{let e=Mj();e!==null&&e.targetChatId===u.current.chatId&&Qj(),c.current?.stop(),c.current=null,a(!1),s(``)},[]),v=(0,q.useCallback)(()=>{if(!qS()){r.error(ba());return}let e=Mj();if(e!==null&&e.targetChatId!==u.current.chatId&&e.recording){r.error(See());return}let t=u.current.chatId,i={h:null,boundToHold:!1};l.current=i;let o=LS({lang:m,onText:(e,r)=>{if(i.holdGen!==void 0&&i.holdGen!==zj())return;let a=Mj();if(a!==null&&a.targetChatId===t){if(Bj(e,r.paragraph),u.current.chatId===t){let e=Mj();e!==null&&(n.setText(e.text),p())}return}if(u.current.chatId!==t)return;let o=n.getState().text;n.setText($j(o,e,r.paragraph)),p()},onInterim:e=>{if(i.holdGen!==void 0&&i.holdGen!==zj())return;let n=Mj();n!==null&&n.targetChatId===t&&Vj(e),s(e)},onEnd:()=>{i.boundToHold&&Xj(i.holdGen),!(c.current!==null&&c.current!==i.h)&&(c.current=null,a(!1),s(``))},onError:e=>{i.boundToHold&&Xj(i.holdGen),!(c.current!==null&&c.current!==i.h)&&(c.current=null,a(!1),s(``),e===`not-allowed`||e===`service-not-allowed`?r.error(Ua()):e!==`no-speech`&&e!==`aborted`&&r.error(Ah({code:e})))}});if(o===null){r.error(ba());return}i.h=o;let d=Mj();if(d!==null&&d.targetChatId===t){i.boundToHold=!0,Rj(()=>o.stop()),i.holdGen=zj(),a(!0);return}c.current=o,a(!0)},[m,r]),y=(0,q.useCallback)(()=>{if(n.getState().attachments.length>0||d0()){r.error(ny());return}let e=c.current;Lj({targetChatId:u.current.chatId,targetLabel:u.current.chatTitle,text:n.getState().text,voiceEnabled:g.current,voiceLang:h.current,recording:e!==null,...e===null?{}:{stop:()=>e.stop()}})&&(e!==null&&l.current?.h===e&&(l.current.boundToHold=!0,l.current.holdGen=zj()),c.current=null,a(!1),s(``),n.setText(``))},[r]);return{recording:i||f&&d!==null&&d.recording,interim:f&&d!==null?d.interim:o,held:f,canPin:d===null,pinned:d!==null,pinnedHere:f,pinnedLabel:d?.targetLabel??``,pinnedTargetChatId:d?.targetChatId??null,pendingSend:f?d?.pendingSend??null:null,pendingSendId:f?d?.pendingSendId??0:0,pendingRestore:f?d?.pendingRestore??null:null,start:v,stop:_,hold:y}}function Tre({recording:e,onStart:t,onStop:n}){let r=U(G.me.getMe,{host:dT})?.dictationShortcut??null,i=(0,q.useRef)(()=>{});(0,q.useEffect)(()=>{if(!r)return;let e=e=>{e.repeat||Ew(e,r)&&(e.preventDefault(),i.current())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let a=r?` (${ww(r,Cw())})`:``;return(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon${e?` oc-composer__icon--rec`:``}`,title:(e?Mo():cn())+a,"aria-label":e?Mo():cn(),"aria-pressed":e,ref:e=>{i.current=()=>e?.click()},onClick:()=>e?n():t(),children:(0,J.jsx)(zS,{size:18,"aria-hidden":!0})})}function Ere({chatId:e,chatTitle:t=``,showTools:n,onToggleTools:r,unavailable:i=!1,agentGate:a,onTalkCallActiveChange:o,serverCallSessionId:s,subAgentBusy:c=!1}){let{can:l,loading:u,resolved:d}=PT(e),f=u||!d||l(`inboundAttachments`),p=D7().voiceInput,m=W0(),h=F7(),[g,_]=(0,q.useState)(!1),[v,y]=(0,q.useState)(`agents`),[b,x]=(0,q.useState)(null),S=(0,q.useCallback)(()=>x(null),[]),C=(0,q.useCallback)((e,t)=>{y(e),x(t),_(!0)},[]),w=h?.nextTarget??null,T=h?.primary??null,E=(h?.roomAgents.length??0)>0,D=E&&T?c2(h?.pool??[],T)?.displayName??T.agentId:G0(m),O=FV(e=>e.isRunning),k=g8(e),A=k!==null&&l(`followUpModes`),j=Z8({turnRunning:O,hasRunningSubAgent:!A&&c}),M=j.mode===`queue`,N=(0,q.useContext)(k7),P=jV(),F=Ia(),I=(0,q.useRef)(null),L=Kx(),R=wre({chatId:e,chatTitle:t===``?D:t,voiceInput:p,rootRef:I}),[ee,z]=(0,q.useState)(!1),B=R.pendingSendId,V=Mw(),ne=(0,q.useRef)(0);(0,q.useEffect)(()=>{if(B===0||ne.current===B)return;ne.current=B;let e=Mj(),t=e?.pendingSend??``,n=e?.holdId??-1;if(Gj(),i){Kj(n),V.error(qd());return}if(t.trim()===``){qj(n);return}M&&N!==null?N(t).then(e=>{e?Mj()?.holdId===n&&(Qj(),P.setText(``)):Kj(n)}):Mj()?.holdId===n&&(Qj(),P.setText(t),P.send())},[B]);let re=R.pendingRestore;(0,q.useEffect)(()=>{re!==null&&(P.setText(re),Yj(),Qj())},[re]),(0,q.useEffect)(()=>{if(!ee)return;let e=e=>{e.key===`Escape`&&(e.stopPropagation(),z(!1))};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[ee]);let ie=(0,q.useContext)(Nq);(0,q.useEffect)(()=>{if(ie!==null)return ie.current={canAttach:f&&!M&&!R.pinned,attachFile:e=>R.pinned?Promise.resolve():(ce(e=>e+1),P.addAttachment(e).then(()=>{ue(``),requestAnimationFrame(()=>ue(te()))}).finally(()=>ce(e=>Math.max(0,e-1)))),insertText:e=>{let t=P.getState();P.setText(t.text+e),ue(``),requestAnimationFrame(()=>ue(Jh()))}},()=>{ie.current=null}},[ie,f,M,P,R.pinned]);let ae=(0,q.useRef)(1),oe=Mw(),[se,ce]=(0,q.useState)(0),[le,ue]=(0,q.useState)(``),de=se>0,fe=(0,J.jsxs)(J.Fragment,{children:[ee?(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__backdrop`,"aria-label":jm(),onClick:()=>z(!1)}):null,(0,J.jsxs)(_W.Root,{ref:I,className:`oc-composer${i?` oc-composer--disabled`:``}${R.recording?` oc-composer--dictation`:``}${ee?` oc-composer--expanded`:``}`,children:[ee?(0,J.jsxs)(`div`,{className:`oc-composer__exphead`,children:[(0,J.jsx)(`span`,{className:`oc-composer__exptitle`,children:rt()}),(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__expclose`,title:jm(),onClick:()=>z(!1),children:[(0,J.jsx)(JA,{size:15,"aria-hidden":!0}),jm()]})]}):null,e?(0,J.jsx)(n4,{chatId:e,onOpen:()=>C(`people`,null)}):null,e?(0,J.jsx)(r4,{chatId:e,routing:h,open:g,onOpenChange:_,tab:v,onTabChange:y,intent:b,onIntentDone:S}):null,(0,J.jsx)(vre,{chatId:e}),(0,J.jsx)(`div`,{className:`oc-attachrow`,children:(0,J.jsx)(_W.Attachments,{components:{Attachment:yre}})}),(0,J.jsx)(`span`,{className:`oc-sr-only`,role:`status`,"aria-live":`polite`,children:le}),(0,J.jsx)(bre,{}),(0,J.jsx)(_W.Input,{className:`oc-composer__input`,placeholder:i?qd():E?py({name:D}):eh({name:D}),autoFocus:!0,rows:1,disabled:i,onKeyDownCapture:e=>{if(de&&e.key===`Enter`&&!e.shiftKey){e.preventDefault(),e.stopPropagation();return}if(!M||N===null||e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing)return;e.preventDefault(),e.stopPropagation();let t=P.getState().text;if(t.trim()===``)return;let n=A?o6(k?.preference??null,k?.serverMode??null):null,r=n===null?void 0:e.metaKey||e.ctrlKey?s6(n):n.mode;N(t,n===null?void 0:{...r?{mode:r}:{},immediate:r!==`queue`}).then(e=>{e&&P.setText(``)})},onPaste:e=>{if((e.clipboardData?.files?.length??0)>0)return;let t=e.clipboardData?.getData(`text/plain`)??``;if(!t)return;let n=Y8(t);if(n!==null&&f&&!M){e.preventDefault();let r=e.currentTarget,i=r.selectionStart??null,a=r.selectionEnd??null,o=P.getState().text,s=()=>{let e=P.getState();e.text===o&&i!==null&&a!==null?P.setText(o.slice(0,i)+t+o.slice(a)):P.setText(e.text+t)};ce(e=>e+1),F.query(G.chatExport.exportByReference,{reference:n}).then(e=>{let t=e;if(t===null){s();return}let n=new File([t.markdown],t.filename,{type:`text/markdown; charset=utf-8`});return Rq(n),P.addAttachment(n).then(()=>{ue(``),requestAnimationFrame(()=>ue(Zee()))})}).catch(()=>{s(),oe.error(ws())}).finally(()=>ce(e=>Math.max(0,e-1)));return}let r=Iq(t,ae.current);if(r.kind!==`file`||!f)return;if(e.preventDefault(),M){oe.error(Kc());return}ae.current+=1;let i=new File([t],r.filename??`texte-colle.txt`,{type:`text/plain; charset=utf-8`});Rq(i),ce(e=>e+1),P.addAttachment(i).then(()=>{ue(``),requestAnimationFrame(()=>ue(yl({lines:String(r.lines)})))}).catch(e=>{console.error(`[paste] attachment routing failed:`,e),oe.error(lr())}).finally(()=>ce(e=>Math.max(0,e-1)))},autoCorrect:`off`,autoCapitalize:`off`,autoComplete:`off`,"data-gramm":`false`,"data-gramm_editor":`false`,"data-enable-grammarly":`false`}),R.recording&&R.interim!==``?(0,J.jsxs)(`div`,{className:`oc-composer__interim`,"aria-hidden":!0,children:[(0,J.jsx)(`span`,{className:`oc-composer__interim-dot`}),R.interim]}):null,(0,J.jsxs)(`div`,{className:`oc-composer__bar`,children:[(0,J.jsxs)(`div`,{className:`oc-composer__group`,children:[(0,J.jsx)(one,{chatId:e,routedAgent:w?{instanceName:w.instanceName,agentId:w.agentId}:null,attachmentsSupported:f,attachDisabled:M||i}),ee?null:(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__tools${n?` is-on`:``}`,onClick:r,"aria-pressed":n,title:n?V_():ui(),children:[(0,J.jsx)(UC,{size:15,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-composer__tools-label`,children:_n()})]}),(0,J.jsx)(Sre,{chatId:e,gate:a,onManage:C}),(0,J.jsx)(G5,{chatId:e,routedAgent:w?{instanceName:w.instanceName,agentId:w.agentId}:null,multiAgent:h?.perTurnRouting===!0||(h?.roomAgents?.length??0)>0})]}),(0,J.jsxs)(`div`,{className:`oc-composer__group`,children:[(0,J.jsx)(`span`,{className:`oc-composer__voiceslot${R.canPin||R.held?` is-shown`:``}`,"aria-hidden":!R.canPin&&!R.held,children:R.held?(0,J.jsxs)(`button`,{type:`button`,className:`oc-composer__heldchip`,title:Mr(),"aria-label":Mr(),onClick:()=>Qj(),children:[(0,J.jsx)(Zx,{size:12,"aria-hidden":!0}),Um(),(0,J.jsx)(XC,{size:11,"aria-hidden":!0})]}):(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon oc-composer__hold`,title:nc(),"aria-label":nc(),onClick:R.hold,disabled:!R.canPin||de,tabIndex:!R.canPin||de?-1:0,children:(0,J.jsx)(Zx,{size:16,"aria-hidden":!0})})}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__icon${ee?` is-on`:``}`,title:ee?jm():Ld(),"aria-label":ee?jm():Ld(),"aria-pressed":ee,onClick:()=>z(e=>!e),children:ee?(0,J.jsx)(JA,{size:16,"aria-hidden":!0}):(0,J.jsx)(WA,{size:16,"aria-hidden":!0})}),p?(0,J.jsx)(Tre,{recording:R.recording,onStart:R.start,onStop:R.stop}):null,(0,J.jsx)(I0,{chatId:e,onCallActiveChange:o,serverCallSessionId:s,routedAgent:w?{instanceName:w.instanceName,agentId:w.agentId}:null},e),i?(0,J.jsxs)(J.Fragment,{children:[j.mode===`queue`?(0,J.jsx)(Q7,{}):null,(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__send`,disabled:!0,"aria-label":Re(),children:(0,J.jsx)(iA,{size:18,"aria-hidden":!0})})]}):j.mode===`queue`?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q7,{}),A?(0,J.jsx)(_8,{chatId:e,queueSend:N===null?null:(e,t)=>N(e,{...t?{mode:t}:{},immediate:t!==`queue`})}):(0,J.jsx)(xre,{reason:j.reason})]}):A&&c?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Q7,{}),(0,J.jsx)(_W.Send,{className:`oc-composer__send`,"aria-label":kx(),disabled:de,children:(0,J.jsx)(iA,{size:18,"aria-hidden":!0})})]}):(0,J.jsx)(_W.Send,{className:`oc-composer__send`,"aria-label":kx(),disabled:de,children:(0,J.jsx)(iA,{size:18,"aria-hidden":!0})})]})]})]})]});return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(are,{}),R.pinned?(0,J.jsxs)(`div`,{className:`oc-composer__pinnednote`,role:`note`,children:[(0,J.jsx)(Zx,{size:14,"aria-hidden":!0}),R.pinnedHere?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:ux()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__pinnedgoto`,onClick:()=>Jj(),children:Af()})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{children:zee({chat:R.pinnedLabel||_p()})}),R.pinnedTargetChatId?(0,J.jsx)(`button`,{type:`button`,className:`oc-composer__pinnedgoto`,onClick:()=>{L({to:`/chat/$chatId`,params:{chatId:R.pinnedTargetChatId}})},children:_b()}):null]})]}):ee?(0,vk.createPortal)(fe,document.body):fe]})}function Dre({chatId:e}){let t=q5(e);return t.offered?(0,J.jsxs)(hC,{disabled:t.pending,"data-widgets-toggle":!0,onSelect:()=>t.set(!t.enabled),children:[(0,J.jsx)(LA,{}),t.enabled?Sl():Fe()]}):null}var $7=67324752,e9=33639248,t9=101010256,n9=0,r9=2048,i9=class extends Error{reason;constructor(e,t){super(t===void 0?e:`${e}: ${t}`),this.reason=e,this.name=`ZipError`}},Ore=(()=>{let e=new Uint32Array(256);for(let t=0;t<256;t+=1){let n=t;for(let e=0;e<8;e+=1)n=n&1?3988292384^n>>>1:n>>>1;e[t]=n>>>0}return e})();function a9(e){let t=4294967295;for(let n of e)t=Ore[(t^n)&255]^t>>>8;return(t^4294967295)>>>0}function kre(e){if(e.length>65535)throw new i9(`too_many_entries`,String(e.length));let t=new TextEncoder,n=[],r=[],i=0;for(let a of e){let e=t.encode(a.name),o=a9(a.bytes),s=new Uint8Array(30+e.length),c=new DataView(s.buffer);c.setUint32(0,$7,!0),c.setUint16(4,20,!0),c.setUint16(6,r9,!0),c.setUint16(8,n9,!0),c.setUint16(10,0,!0),c.setUint16(12,33,!0),c.setUint32(14,o,!0),c.setUint32(18,a.bytes.length,!0),c.setUint32(22,a.bytes.length,!0),c.setUint16(26,e.length,!0),c.setUint16(28,0,!0),s.set(e,30);let l=new Uint8Array(46+e.length),u=new DataView(l.buffer);u.setUint32(0,e9,!0),u.setUint16(4,20,!0),u.setUint16(6,20,!0),u.setUint16(8,r9,!0),u.setUint16(10,n9,!0),u.setUint16(12,0,!0),u.setUint16(14,33,!0),u.setUint32(16,o,!0),u.setUint32(20,a.bytes.length,!0),u.setUint32(24,a.bytes.length,!0),u.setUint16(28,e.length,!0),u.setUint32(42,i,!0),l.set(e,46),n.push(s,a.bytes),r.push(l),i+=s.length+a.bytes.length}let a=r.reduce((e,t)=>e+t.length,0),o=new Uint8Array(22),s=new DataView(o.buffer);s.setUint32(0,t9,!0),s.setUint16(8,e.length,!0),s.setUint16(10,e.length,!0),s.setUint32(12,a,!0),s.setUint32(16,i,!0);let c=n.reduce((e,t)=>e+t.length,0)+a+22,l=new Uint8Array(c),u=0;for(let e of[...n,...r,o])l.set(e,u),u+=e.length;return l}function Are(e){let t=new DataView(e.buffer,e.byteOffset,e.length),n=new TextDecoder,r=-1;for(let n=e.length-22;n>=0;--n)if(t.getUint32(n,!0)===t9){r=n;break}if(r===-1)throw new i9(`not_a_zip`);let i=t.getUint16(r+10,!0),a=t.getUint32(r+16,!0),o=[];for(let r=0;r<i;r+=1){if(a+46>e.length||t.getUint32(a,!0)!==e9)throw new i9(`corrupt`,`central directory`);let r=t.getUint16(a+8,!0),i=t.getUint16(a+10,!0),s=t.getUint32(a+16,!0),c=t.getUint32(a+24,!0),l=t.getUint16(a+28,!0),u=t.getUint16(a+30,!0),d=t.getUint16(a+32,!0),f=t.getUint32(a+42,!0),p=n.decode(e.subarray(a+46,a+46+l));if(i!==n9)throw new i9(`unsupported_method`,p);if((r&r9)===0)throw new i9(`unsupported_encoding`,p);if(f+30>e.length||t.getUint32(f,!0)!==$7)throw new i9(`corrupt`,p);let m=t.getUint16(f+26,!0),h=t.getUint16(f+28,!0),g=f+30+m+h;if(g+c>e.length)throw new i9(`corrupt`,p);let _=e.slice(g,g+c);if(a9(_)!==s)throw new i9(`checksum_mismatch`,p);o.push({name:p,bytes:_}),a+=46+l+u+d}return o}var o9=`manifest.json`,s9=`chats/`,jre=`sections/`,c9=`blobs/`,Mre=512*1024*1024,Nre=1e4,Pre=76,Fre=600*1e3;function Ire(e,t){return e.filter(e=>t-e.updatedAt>Fre)}var Lre=class extends Error{bytes;constructor(e){super(`archive exceeds ${Mre} bytes`),this.bytes=e,this.name=`ArchiveTooLarge`}};async function l9(e,t,n){let r=new TextEncoder,i=await e.manifest(),a=[],o=0,s=0,c=0,l=new Set,u=(e,t)=>{if(o+=t.length+Pre+2*e.length,o>536870912)throw new Lre(o);a.push({name:e,bytes:t})},d=[];for(let a of t){let t=await e.chat(a);u(`${s9}${a}.json`,r.encode(JSON.stringify(t)));for(let t of i.sections){let i=null,o=0;do{let f=await e.section(a,t,i);f.rows.length>0&&u(`${jre}${a}/${t}/${o}.json`,r.encode(JSON.stringify(f.rows)));for(let t of f.blobs){if(t.url===null){d.push(t.key);continue}l.has(t.key)||(l.add(t.key),u(`${c9}${t.key}`,await e.blob(t.url)),s+=1,n?.({phase:`blobs`,done:s,total:null}))}i=f.cursor,o+=1,c+=1,n?.({phase:`sections`,done:c,total:null})}while(i!==null&&o<1e4);if(i!==null)throw Error(`export of ${t} did not finish within ${Nre} pages`)}}return n?.({phase:`packing`,done:a.length,total:a.length}),a.unshift({name:o9,bytes:r.encode(JSON.stringify({...i,missingBlobs:d}))}),{archive:kre(a),manifest:i,blobCount:s,missingBlobs:d}}async function Rre(e,t,n,r){let i=new TextDecoder,a=Are(t);r?.({phase:`reading`,done:a.length,total:a.length});let o=new Map(a.map(e=>[e.name,e.bytes])).get(o9);if(o===void 0)throw Error(`archive has no manifest`);let s=JSON.parse(i.decode(o)),c=await e.begin({formatVersion:s.formatVersion,origin:s.origin??null},n),l=0,u=!1,d=new Map,f=new Set;try{let t=a.filter(e=>e.name.startsWith(c9)).length;for(let n of a){if(!n.name.startsWith(`blobs/`))continue;let i=n.name.slice(6);if(d.has(i))throw Error(`archive names the same blob twice: ${i}`);let a=await e.upload(n.bytes,i);await e.registerBlob(c,a),d.set(i,a),r?.({phase:`uploading`,done:d.size,total:t})}let n=a.filter(e=>e.name.startsWith(s9));for(let t of n){let n=JSON.parse(i.decode(t.bytes)),r=await e.batch(c,`chats`,[n],u9([n],d));l+=r.written,d9([n],r.writtenIds,f)}for(let t of s.sections){let n=a.filter(e=>e.name.startsWith(`sections/`)&&e.name.includes(`/${t}/`)).sort((e,t)=>f9(e.name)-f9(t.name));for(let a of n){let n=JSON.parse(i.decode(a.bytes)),o=await e.batch(c,t,n,u9(n,d));l+=o.written,r?.({phase:`writing`,done:l,total:null}),d9(n,o.writtenIds,f)}}for(let[t,n]of d)f.has(t)||await e.discardUpload(c,n);let o=Math.ceil(l/100)+100;for(let t=0;t<o&&!u;t+=1)u=(await e.finish(c)).done}catch(t){try{let t=!1;for(let n=0;n<1e4&&!t;n+=1)t=(await e.abandon(c)).done;for(let t of d.values())await e.discardUpload(c,t)}catch{}throw t}return{importId:c,written:l,purged:u}}function u9(e,t){let n=new Set;for(let t of e){let e=t.archiveBlobKey;typeof e==`string`&&n.add(e);let r=t.archiveBlobKeys;if(Array.isArray(r))for(let e of r)typeof e==`string`&&n.add(e)}let r=[];for(let e of n){let n=t.get(e);n!==void 0&&r.push({key:e,storageId:n})}return r}function d9(e,t,n){let r=new Set(t);for(let t of e){if(typeof t._id!=`string`||!r.has(t._id))continue;let e=t.archiveBlobKey;typeof e==`string`&&n.add(e);let i=t.archiveBlobKeys;if(Array.isArray(i))for(let e of i)typeof e==`string`&&n.add(e)}}function f9(e){let t=/\/(\d+)\.json$/.exec(e);return t===null?0:Number(t[1])}function p9(e){return`atrium-${e.normalize(`NFKD`).replace(/[^\p{Letter}\p{Number}]+/gu,`-`).replace(/^-+|-+$/g,``).slice(0,60)||`conversation`}.zip`}function m9(e,t){let n=URL.createObjectURL(new Blob([e],{type:`application/zip`})),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),setTimeout(()=>URL.revokeObjectURL(n),6e4)}function zre(){let e=Ia(),[t,n]=(0,q.useState)({running:!1,progress:null}),r=(0,q.useRef)(!1),i=(0,q.useCallback)(()=>({manifest:()=>e.action(G.archiveExport.exportManifest,{}),chat:t=>e.query(G.archiveExport.exportChat,{chatId:t}),section:(t,n,r)=>e.query(G.archiveExport.exportChatSection,{chatId:t,section:n,cursor:r}),blob:async e=>{let t=await fetch(e);if(!t.ok)throw Error(`attachment could not be read (${t.status})`);return new Uint8Array(await t.arrayBuffer())}}),[e]),a=(0,q.useCallback)(()=>({begin:(t,n)=>e.mutation(G.archiveImport.beginImport,{manifest:t,targetProjectId:n??null}),batch:(t,n,r,i)=>e.mutation(G.archiveImport.importBatch,{importId:t,section:n,rows:r,blobs:i.map(e=>({key:e.key,storageId:e.storageId}))}),finish:t=>e.mutation(G.archiveImport.finishImport,{importId:t}),abandon:t=>e.mutation(G.archiveImport.abandonImport,{importId:t}),upload:async t=>{let n=await e.mutation(G.chats.generateUploadUrl,{}),{storageId:r}=await(await fetch(n,{method:`POST`,headers:{"Content-Type":`application/octet-stream`},body:new Blob([t])})).json();return await e.mutation(G.uploads.registerUpload,{storageId:r}),r},registerBlob:async(t,n)=>{await e.mutation(G.archiveImport.registerImportBlob,{importId:t,storageId:n})},discardUpload:async(t,n)=>{await e.mutation(G.archiveImport.discardUpload,{importId:t,storageId:n})}}),[e]),o=(0,q.useCallback)(async e=>{if(r.current)throw Error(`a transfer is already running`);r.current=!0,n({running:!0,progress:null});try{return await e(e=>n({running:!0,progress:e}))}finally{r.current=!1,n({running:!1,progress:null})}},[]),s=(0,q.useCallback)((e,t)=>o(async n=>{let{archive:r,missingBlobs:a}=await l9(i(),e,n);return m9(r,p9(t)),{missingBlobs:a}}),[o,i]),c=(0,q.useCallback)((t,n)=>o(async r=>{let a=await e.query(G.archiveExport.exportFolderTree,{projectId:t});if(!a.complete)throw Error(`folder_too_large`);let o=[];for(let t of a.folders){let n=null;do{let r=await e.query(G.archiveExport.exportFolderChats,{projectId:t._id,cursor:n});o.push(...r.chatIds),n=r.cursor}while(n!==null)}let{archive:s,missingBlobs:c}=await l9(i(),o,r);return m9(s,p9(n)),{missingBlobs:c,chatCount:o.length}}),[e,o,i]),l=(0,q.useCallback)((e,t)=>o(async n=>{if(e.size>536870912)throw Error(`archive_too_large`);return Rre(a(),new Uint8Array(await e.arrayBuffer()),t,n)}),[o,a]);return(0,q.useEffect)(()=>{let t=!1;return(async()=>{try{let n=await e.query(G.archiveImport.listOpenImports,{});for(let r of Ire(n,Date.now())){let n=!1;for(let i=0;i<1e3&&!n&&!t;i+=1)n=(await e.mutation(G.archiveImport.abandonImport,{importId:r.importId})).done}}catch{}})(),()=>{t=!0}},[e]),{state:t,exportChats:s,exportFolder:c,importArchive:l}}var h9=(0,q.createContext)(null);function Bre({children:e}){let t=zre(),n=Mw(),r=(e,t)=>{let r=e instanceof Error?e.message:String(e);if(r.includes(`folder_too_large`)){n.error(ite());return}if(r.includes(`already running`)){n.error(Ps());return}if(r.includes(`archive_too_large`)){n.error(Lo());return}if(r.includes(`not_a_zip`)||r.includes(`no manifest`)){n.error(mn());return}n.error(t,e)},i={state:t.state,exportChat:(e,i)=>{t.exportChats([e],i).then(({missingBlobs:e})=>{e.length>0?n.error(dr({count:e.length})):n.success(Jc())}).catch(e=>r(e,Ir()))},exportFolder:(e,i)=>{t.exportFolder(e,i).then(({missingBlobs:e})=>{e.length>0?n.error(dr({count:e.length})):n.success(Jc())}).catch(e=>r(e,Ir()))},importArchive:(e,i)=>{t.importArchive(e,i).then(({written:e,purged:t})=>{n.success(xl({count:e}),t?void 0:Pe())}).catch(e=>r(e,ra()))}},a={...i,pickAndImport:e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=`.zip,application/zip`,t.addEventListener(`change`,()=>{let n=t.files?.[0];n!==void 0&&i.importArchive(n,e)}),t.click()}};return(0,J.jsx)(h9.Provider,{value:a,children:e})}function g9(){return(0,q.useContext)(h9)}function Vre(e){if(!e.running)return null;let t=e.progress;if(t===null)return cv();switch(t.phase){case`sections`:return Gu({count:t.done});case`blobs`:return oi({count:t.done});case`packing`:return cv();case`reading`:return Ni({count:t.done});case`uploading`:return Vn({done:t.done,total:t.total??t.done});case`writing`:return ql({count:t.done})}}function Hre(e,t){return e===null?t:`${e}-${t}`}var Ure=e=>{let{transform:t}=e;return{...t,y:0}};function Wre(e,t,n){let r={...e};return t.top+e.y<=n.top?r.y=n.top-t.top:t.bottom+e.y>=n.top+n.height&&(r.y=n.top+n.height-t.bottom),t.left+e.x<=n.left?r.x=n.left-t.left:t.right+e.x>=n.left+n.width&&(r.x=n.left+n.width-t.right),r}var Gre=e=>{let{draggingNodeRect:t,transform:n,scrollableAncestorRects:r}=e,i=r[0];return!t||!i?n:Wre(n,t,i)},Kre=e=>{let{transform:t}=e;return{...t,x:0}},_9=`project:none`,qre=e=>`project:${e}`,v9=`projhead:`,y9=e=>`${v9}${e}`,b9=`oc.noproject.collapsed`,x9=`oc.shared.collapsed`;function S9(){return(0,J.jsx)(`div`,{className:`oc-sidebar__skeleton`,"aria-hidden":`true`,children:Array.from({length:7}).map((e,t)=>(0,J.jsx)(`div`,{className:`oc-skel oc-skel--row`},t))})}var C9=(0,q.createContext)(new Map);function Jre({activeChatId:e,onSelect:t,onNewChat:n,newChatShortcut:r}){let i=U(G.messages.listChats,{}),a=U(G.projects.listProjects,{}),o=U(G.me.getMe,{host:dT})?.ui?.effective?.showChatAge??!0,s=U(G.chatReads.myChatReads,{}),c=(0,q.useMemo)(()=>{let e=new Map;for(let t of s??[])e.set(t.chatId,t.lastSeenAt);return e},[s]),l=U(G.chatReads.myBusyChats,{}),u=(0,q.useMemo)(()=>new Set(l??[]),[l]),{byChat:d}=fS(l??null),f=U(G.agentRequests.pendingByChat,{}),p=(0,q.useMemo)(()=>{let e=new Map;for(let t of f??[])e.set(t.chatId,t.kinds.includes(`approval`)?`approval`:t.kinds.includes(`credential`)?`credential`:`question`);return e},[f]),m=U(G.chatBookmarks.myBookmarkedChats,{}),h=U(G.chatExport.referenceLabel,{}),g=(0,q.useMemo)(()=>new Set(m??[]),[m]),_=(0,q.useMemo)(()=>{let t=new Set;for(let n of i??[]){if(n._id===e)continue;let r=c.get(n._id);r!==void 0&&n.lastAssistantAt!==null&&n.lastAssistantAt>r&&t.add(n._id)}return t},[i,c,e]),[v,y]=(0,q.useState)(0);(0,q.useEffect)(()=>{if(!o)return;let e=window.setInterval(()=>y(e=>e+1),6e4);return()=>window.clearInterval(e)},[o]);let b=W(G.projects.createProject),x=W(G.projects.setProjectCollapsed),S=W(G.projects.setProjectSidebar),C=W(G.chats.reorderChat),w=W(G.projects.reorderProject),T=W(G.chats.moveChatToProject),E=pT(),D=mi(),O=(0,q.useRef)(null),k=(0,q.useRef)(null),A=(0,q.useRef)(null),[j,M]=(0,q.useState)(`full`);(0,q.useLayoutEffect)(()=>{let e=O.current;if(!e)return;let t=()=>{let t=e.clientWidth,n=k.current?.offsetWidth??0,r=A.current?.offsetWidth??0,i=n===0||t>=n?`full`:t>=r?`label`:`icon`;M(e=>e===i?e:i)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[D,r]);let[N,P]=(0,q.useState)(null),F=(0,q.useRef)(!1);(0,q.useEffect)(()=>{!F.current&&i&&P(i)},[i]);let I=N??i??[],L=I.filter(e=>e.sidebarHidden!==!0),R=I.filter(e=>e.sidebarHidden===!0),ee=i===void 0&&N===null,[z,B]=(0,q.useState)(null),[V,te]=(0,q.useState)(()=>localStorage.getItem(b9)===`1`),[ne,re]=(0,q.useState)(()=>localStorage.getItem(x9)===`1`);function ie(){re(e=>(localStorage.setItem(x9,e?`0`:`1`),!e))}function ae(){te(e=>(localStorage.setItem(b9,e?`0`:`1`),!e))}let oe=P2();(0,q.useEffect)(()=>{if(!oe?.expand)return;let e=L.find(e=>e._id===oe.chatId);if(!e)return;let t=e.projectId??null;if(t===null){V&&(localStorage.setItem(b9,`0`),te(!1));return}let n=(a??[]).find(e=>e._id===t);n&&n.parentId!==null||n?.collapsed&&x({projectId:t,collapsed:!1})},[oe,L,a,V,x]);let se=pS(PS(gS,{activationConstraint:{distance:4}}),PS(lte,{activationConstraint:{delay:250,tolerance:8}}),PS(bS,{coordinateGetter:vS})),ce=(0,q.useRef)(!1),le=()=>{ce.current=!0,setTimeout(()=>{ce.current=!1},0)},ue=(0,q.useCallback)(e=>String(e.active.id).startsWith(v9)?FS({...e,droppableContainers:e.droppableContainers.filter(e=>String(e.id).startsWith(v9))}):FS(e),[]),de=L.filter(e=>e.pinned),fe=L.filter(e=>!e.pinned&&e.role===`participant`),pe=L.filter(e=>!e.pinned&&e.role!==`participant`),me=e=>pe.filter(t=>(t.projectId??null)===e),he=Kx(),ge=(0,q.useMemo)(()=>dS(a??[]),[a]),ve=(0,q.useMemo)(()=>ge.filter(e=>!e.sidebarHidden),[ge]),ye=(0,q.useMemo)(()=>ge.filter(e=>e.sidebarHidden),[ge]),be=(0,q.useMemo)(()=>{let e=a??[];return new Map(e.map(t=>[t._id,lS(e,t._id)]))},[a]),xe=(0,q.useMemo)(()=>new Map((a??[]).map(e=>[e._id,e.name])),[a]),Se=e=>pe.filter(t=>t.projectId!==null&&(be.get(t.projectId)??t.projectId)===e);function Ce(e){return L.find(t=>t._id===e)}async function we(e){B(null),le();let{active:t,over:n}=e;if(!n)return;let r=String(t.id),i=String(n.id);if(r.startsWith(v9)){let e=r.slice(9),t=ve,n=null;if(i.startsWith(v9))n=i.slice(9);else if(i.startsWith(`project:`)&&i!==_9)n=i.slice(8);else{let e=Ce(i);n=e&&!e.pinned?e.projectId??null:null}if(n===null||n===e)return;let a=t.findIndex(t=>t._id===e),o=t.findIndex(e=>e._id===n);if(a<0||o<0)return;let s=[...t],[c]=s.splice(a,1);s.splice(o,0,c);let l=s[o-1]??null,u=s[o+1]??null;await w({projectId:e,prevKey:l?l.sortKey:null,nextKey:u?u.sortKey:null});return}let a=Ce(r);if(!a||a.role===`participant`)return;if(i.startsWith(v9)){let e=i.slice(9);if((a.projectId??null)===e)return;F.current=!0,P(t=>(t??L).map(t=>t._id===a._id?{...t,projectId:e}:t));try{await T({chatId:a._id,projectId:e})}finally{F.current=!1}return}if(i.startsWith(`project:`)){let e=i===_9?null:i.slice(8);if((a.projectId??null)===e)return;F.current=!0,P(t=>(t??L).map(t=>t._id===a._id?{...t,projectId:e}:t));try{await T({chatId:a._id,projectId:e})}finally{F.current=!1}return}let o=Ce(i);if(!o||t.id===n.id)return;if((o.projectId??null)!==(a.projectId??null)||o.pinned!==a.pinned){if(a.pinned||o.pinned)return;F.current=!0,P(e=>(e??L).map(e=>e._id===a._id?{...e,projectId:o.projectId??null}:e));try{await T({chatId:a._id,projectId:o.projectId??null})}finally{F.current=!1}return}let s=o.pinned?de:me(o.projectId??null),c=s.map(e=>e._id),l=c.indexOf(a._id),u=c.indexOf(o._id);if(l<0||u<0)return;let d=[...s];d.splice(l,1),d.splice(u,0,a);let f=d[u-1]??null,p=d[u+1]??null;F.current=!0,P(e=>[...(e??L).filter(e=>!s.some(t=>t._id===e._id)),...d]);try{await C({chatId:a._id,prevKey:f?f.sortKey:null,nextKey:p?p.sortKey:null})}finally{F.current=!1}}let Te=g9(),Ee=Te?Vre(Te.state):null,[De,Oe]=(0,q.useState)(!1),ke=z?Ce(z):null;return(0,J.jsx)(C9.Provider,{value:p,children:(0,J.jsx)(tS.Provider,{value:d,children:(0,J.jsxs)(`aside`,{className:`oc-sidebar`+(De?` oc-sidebar--archivedrop`:``),onDragOver:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),Oe(!0))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||Oe(!1)},onDrop:e=>{if(!e.dataTransfer.types.includes(`Files`))return;e.preventDefault(),Oe(!1);let t=e.dataTransfer.files[0];t!==void 0&&Te?.importArchive(t,null)},children:[De?(0,J.jsxs)(`div`,{className:`oc-sidebar__droparchive`,"aria-hidden":!0,children:[(0,J.jsx)(qC,{className:`size-4`}),(0,J.jsx)(`span`,{children:yu()})]}):null,Ee===null?null:(0,J.jsxs)(`div`,{className:`oc-sidebar__transfer`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(`span`,{className:`oc-sidebar__transfer-spin`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-sidebar__transfer-label`,children:Ee})]}),(0,J.jsxs)(`div`,{className:`oc-sidebar__top`,ref:O,children:[(0,J.jsxs)(K,{className:j===`icon`?`oc-newchat flex-1 justify-center`:`oc-newchat flex-1 justify-start`,onClick:n,title:`${D} (${r})`,"aria-label":D,children:[(0,J.jsx)(RC,{}),j===`icon`?null:(0,J.jsx)(`span`,{className:`oc-newchat__label`,children:D}),j===`full`?(0,J.jsx)(`kbd`,{className:`oc-newchat__kbd`,"aria-hidden":!0,children:r}):null]}),(0,J.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,J.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:k,children:[(0,J.jsxs)(K,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,J.jsx)(RC,{}),(0,J.jsx)(`span`,{className:`oc-newchat__label`,children:D}),(0,J.jsx)(`kbd`,{className:`oc-newchat__kbd`,children:r})]}),(0,J.jsx)(K,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,J.jsx)(nS,{})})]})}),(0,J.jsx)(`div`,{className:`oc-newchat-ghost`,"aria-hidden":!0,children:(0,J.jsxs)(`div`,{className:`oc-newchat-ghost__row`,ref:A,children:[(0,J.jsxs)(K,{className:`oc-newchat justify-start`,tabIndex:-1,children:[(0,J.jsx)(RC,{}),(0,J.jsx)(`span`,{className:`oc-newchat__label`,children:D})]}),(0,J.jsx)(K,{variant:`outline`,size:`icon`,tabIndex:-1,children:(0,J.jsx)(nS,{})})]})}),(0,J.jsx)(K,{className:`oc-newproject`,variant:`outline`,size:`icon`,"aria-label":xn(),title:xn(),onClick:async()=>{let e=await E({title:xn(),label:Ol(),placeholder:Ac(),confirmLabel:qn()});e&&await b({name:e})},children:(0,J.jsx)(nS,{})})]}),(0,J.jsxs)(TS,{sensors:se,collisionDetection:ue,modifiers:[Kre,Gre],onDragStart:e=>B(String(e.active.id)),onDragCancel:()=>{B(null),le()},onDragEnd:we,children:[(0,J.jsx)(`div`,{className:`oc-sidebar__scroll`,children:ee?(0,J.jsx)(S9,{}):(0,J.jsxs)(J.Fragment,{children:[de.length>0?(0,J.jsx)(w9,{label:nl(),chats:de,children:de.map(n=>(0,J.jsx)(T9,{chat:n,active:n._id===e,unread:_.has(n._id),busy:u.has(n._id),bookmarked:g.has(n._id),referenceLabel:h,ageTick:v,suppressClick:ce,onSelect:t},n._id))}):null,(0,J.jsx)(jS,{items:ve.map(e=>y9(e._id)),strategy:OS,children:ve.map(n=>{let r=Se(n._id);return(0,J.jsx)(w9,{label:n.name,dropId:qre(n._id),sortId:y9(n._id),suppressClick:ce,projectId:n._id,project:n,chats:r,collapsible:!0,collapsed:n.collapsed,busy:r.some(e=>u.has(e._id)),unread:r.some(e=>_.has(e._id)),onToggle:()=>void x({projectId:n._id,collapsed:!n.collapsed}),onOpen:()=>void he({to:`/project/$projectId`,params:{projectId:n._id}}),children:n.collapsed?null:r.length===0?(0,J.jsx)(`div`,{className:`oc-sidebar__empty`,children:_e()}):r.map(r=>(0,J.jsx)(T9,{chat:r,active:r._id===e,unread:_.has(r._id),busy:u.has(r._id),bookmarked:g.has(r._id),referenceLabel:h,domainLabel:r.projectId!==null&&r.projectId!==n._id?xe.get(r.projectId)??null:null,ageTick:v,suppressClick:ce,onSelect:t},r._id))},n._id)})}),ye.length>0?(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsxs)(`button`,{className:`oc-sidebar__hiddenfolders`,children:[(0,J.jsx)(SC,{className:`size-3.5`,"aria-hidden":!0}),(0,J.jsx)(`span`,{children:Ja({count:ye.length})})]})}),(0,J.jsx)(fC,{align:`start`,className:`w-56`,children:ye.map(e=>(0,J.jsxs)(hC,{onSelect:()=>void S({projectId:e._id,hidden:!1}),children:[(0,J.jsx)(oS,{}),` `,e.name]},e._id))})]}):null,fe.length>0||R.length>0?(0,J.jsxs)(w9,{label:Dm(),chats:fe,collapsible:!0,collapsed:ne,busy:fe.some(e=>u.has(e._id)),unread:fe.some(e=>_.has(e._id)),onToggle:ie,children:[ne?null:fe.map(n=>(0,J.jsx)(T9,{chat:n,active:n._id===e,unread:_.has(n._id),busy:u.has(n._id),bookmarked:g.has(n._id),referenceLabel:h,ageTick:v,suppressClick:ce,onSelect:t},n._id)),!ne&&R.length>0?(0,J.jsx)(Yre,{chats:R}):null]}):null,(0,J.jsx)(w9,{label:wx(),dropId:_9,chats:me(null),collapsible:!0,collapsed:V,busy:me(null).some(e=>u.has(e._id)),unread:me(null).some(e=>_.has(e._id)),onToggle:ae,children:V?null:me(null).map(n=>(0,J.jsx)(T9,{chat:n,active:n._id===e,unread:_.has(n._id),busy:u.has(n._id),bookmarked:g.has(n._id),referenceLabel:h,ageTick:v,suppressClick:ce,onSelect:t},n._id))})]})}),(0,J.jsxs)(xS,{children:[z?.startsWith(v9)?(()=>{let e=(a??[]).find(e=>y9(e._id)===z);return e?(0,J.jsxs)(`div`,{className:`oc-sidebar__group-head oc-chatitem--overlay`,style:{"--proj-hue":DS(e)},children:[(0,J.jsx)(XS,{className:`size-3.5 shrink-0 oc-sidebar__group-chev`}),(0,J.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e.name})]}):null})():null,ke?(0,J.jsxs)(`div`,{className:`oc-chatitem oc-chatitem--overlay`,children:[_S(ke.color)?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:_S(ke.color)}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsx)(`span`,{className:`oc-chatitem__label`,children:ke.title||gs()})]}):null]})]})]})})})}function w9({label:e,dropId:t,sortId:n,suppressClick:r,projectId:i,project:a,chats:o,collapsible:s,collapsed:c,busy:l,unread:u,onToggle:d,onOpen:f,children:p}){let m=W(G.projects.setProjectSidebar),h=g9(),g=(0,q.useContext)(tS),_=o.map(e=>g.get(e._id)).find(e=>e!==void 0)??null,v=W(G.projects.deleteProject),y=W(G.projects.renameProject),b=W(G.projects.setProjectColor),x=W(G.projects.moveProject),S=fT(),C=VT(),[w,T]=(0,q.useState)(!1),[E,D]=(0,q.useState)(e),[O,k]=(0,q.useState)(!1),A=U(G.projects.projectTreeCount,i?{projectId:i}:`skip`),{setNodeRef:j,isOver:M}=Qx({id:t??`static:${e}`}),N=yS({id:n??`static-sort:${e}`,disabled:!n}),{onKeyDown:P,...F}=N.listeners??{},I=f??d,L=e=>{e.target===e.currentTarget&&s&&I&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),I())},R=a?DS(a):null;return(0,J.jsxs)(`div`,{ref:e=>{t&&j(e),n&&N.setNodeRef(e)},className:`oc-sidebar__group`+(M?` oc-sidebar__group--over`:``)+(a?` oc-sidebar__group--project`:``),style:{...R?{"--proj-hue":R}:{},...n?{transform:eS.Transform.toString(N.transform),transition:N.transition,opacity:N.isDragging?.35:1}:{}},children:[(0,J.jsxs)(`div`,{className:`oc-sidebar__group-head group/head`+(s?` oc-sidebar__group-head--btn`:``),title:c&&l&&_?sS(_):void 0,...s?{role:`button`,tabIndex:0,onClick:()=>{r?.current||I?.()},onKeyDown:L}:{},...n?F:{},children:[s?f?(0,J.jsx)(`button`,{type:`button`,className:`oc-sidebar__group-chevbtn`,"aria-label":c?Lm():Ag(),"aria-expanded":!c,onClick:e=>{e.stopPropagation(),!r?.current&&d?.()},onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:c?(0,J.jsx)(QS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):(0,J.jsx)(XS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)})}):c?(0,J.jsx)(QS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):(0,J.jsx)(XS,{className:`size-3.5 shrink-0`+(a?` oc-sidebar__group-chev`:``)}):null,(0,J.jsx)(`span`,{className:`oc-sidebar__group-label`,children:e}),n?(0,J.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":Oc(),onClick:e=>e.stopPropagation(),...N.attributes,onKeyDown:P,children:(0,J.jsx)(kA,{className:`size-3.5`})}):null,c&&l?(0,J.jsx)(`span`,{className:iS(_,Vi()).className,title:iS(_,Vi()).label,"aria-label":iS(_,Vi()).label}):null,c&&u?(0,J.jsx)(`span`,{className:`oc-chatitem__unread`,title:vh(),"aria-label":vh()}):null,i?(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":Xt(),className:`oc-sidebar__group-menu opacity-0 group-hover/head:opacity-100 group-focus-within/head:opacity-100 aria-expanded:opacity-100`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,J.jsx)(sC,{})})}),(0,J.jsxs)(fC,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[f?(0,J.jsxs)(hC,{onSelect:()=>f(),children:[(0,J.jsx)(oS,{}),` `,sc()]}):null,(0,J.jsxs)(hC,{onSelect:()=>{D(e),T(!0)},children:[(0,J.jsx)(LC,{}),` `,$c()]}),(0,J.jsxs)(hC,{onSelect:()=>k(!0),children:[(0,J.jsx)(nS,{}),` `,Ho()]}),a!==void 0&&a.parentId===null?(0,J.jsxs)(hC,{onSelect:()=>void m({projectId:a._id,hidden:!0}),children:[(0,J.jsx)(SC,{}),` `,Cb()]}):null,h&&a?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(hC,{disabled:h.state.running,onSelect:()=>h.exportFolder(a._id,e),children:[(0,J.jsx)(xC,{}),` `,cs()]}),(0,J.jsxs)(hC,{disabled:h.state.running,onSelect:()=>h.pickAndImport(a._id),children:[(0,J.jsx)(qC,{}),` `,gd()]})]}):null,(0,J.jsx)(lC,{children:ps()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void b({projectId:i,color:null}),"aria-label":Ri(),children:`✕`}),SS.map(e=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(a?.color===e.value?` is-selected`:``),style:{background:e.hue},"aria-label":e.value,onClick:()=>void b({projectId:i,color:e.value})},e.value))]}),(0,J.jsx)(gC,{}),(0,J.jsxs)(hC,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{let t=A?.folders??0,n=A?.chats??0;await S({title:eo({name:e}),description:dte({folders:t,chats:n,days:C}),confirmWord:El(),confirmLabel:Bh(),destructive:!0})&&await v({projectId:i})})},children:[(0,J.jsx)(GC,{}),` `,El()]})]})]}):null]}),(0,J.jsx)(`div`,{className:a&&!c?`oc-sidebar__group-body`:void 0,children:(0,J.jsx)(jS,{items:o.map(e=>e._id),strategy:OS,children:p})}),i?(0,J.jsx)(xT,{open:w,onOpenChange:T,title:xo(),canSubmit:E.trim().length>0,onSubmit:async()=>{await y({projectId:i,name:E.trim()}),T(!1)},children:(0,J.jsx)(`div`,{className:`oc-form`,children:(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:xp()}),(0,J.jsx)(xw,{value:E,onChange:e=>D(e.target.value),autoFocus:!0})]})})}):null,i&&O?(0,J.jsx)(AS,{open:O,onOpenChange:k,title:Ql(),movingFolderId:i,currentId:a?.parentId??null,onPick:e=>void x({projectId:i,parentId:e})}):null]})}var T9=(0,q.memo)(function({chat:e,active:t,unread:n,busy:r,bookmarked:i,referenceLabel:a,domainLabel:o,suppressClick:s,onSelect:l}){let u=(0,q.useContext)(C9).get(e._id),d=(0,q.useContext)(tS).get(e._id)??null,f=g9(),{attributes:p,listeners:m,setNodeRef:h,transform:g,transition:_,isDragging:v}=yS({id:e._id}),{onKeyDown:y,...b}=m??{},x=W(G.chats.renameChat),S=Mw(),C=()=>{if(a===void 0)return;let t=Hre(a,e._id);navigator.clipboard.writeText(t).then(()=>S.success(ul({reference:t})),()=>S.error(Te()))},w=W(G.chats.deleteChat),T=W(G.chats.pinChat),E=W(G.chats.setChatColor),D=W(G.chats.moveChatToProject),O=W(G.chats.setChatSidebar),A=W(G.chatParticipants.leaveChat),j=e.role===`participant`,M=Kx(),[N,P]=(0,q.useState)(!1),I=U(G.me.getMe,{host:dT})?.ui?.effective?.showChatAge??!0,L=fT(),R=VT(),[ee,z]=(0,q.useState)(!1),[B,V]=(0,q.useState)(e.title??``),te=P2()?.chatId===e._id,ne=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!te)return;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;ne.current?.scrollIntoView({block:`nearest`,behavior:t?`auto`:`smooth`});let n=setTimeout(()=>N2(e._id),2600);return()=>clearTimeout(n)},[te,e._id]);let re={transform:eS.Transform.toString(g),transition:_,opacity:+!v},ie=_S(e.color);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`div`,{ref:e=>{h(e),ne.current=e},style:re,className:`oc-chatitem group/row`+(t?` oc-chatitem--active`:``)+(te?` oc-chatitem--flash`:``),title:r&&d?sS(d):void 0,onClick:()=>{s.current||l(e._id)},...b,onAnimationEnd:t=>{te&&t.animationName===`oc-chatitem-flash`&&N2(e._id)},children:[(0,J.jsx)(`button`,{className:`oc-drag-a11y`,"aria-label":Oc(),onClick:e=>e.stopPropagation(),...p,onKeyDown:y,children:(0,J.jsx)(kA,{className:`size-3.5`})}),ie?(0,J.jsx)(`span`,{className:`oc-chatitem__dot`,style:{background:ie}}):(0,J.jsx)(`span`,{className:`oc-chatitem__dot oc-chatitem__dot--empty`}),(0,J.jsxs)(`button`,{className:`oc-chatitem__label`,onClick:t=>{t.stopPropagation(),!s.current&&l(e._id)},children:[(0,J.jsxs)(`span`,{className:`oc-chatitem__title`,children:[e.group?(0,J.jsx)(WC,{className:`oc-chatitem__group`,size:12,"aria-label":am()}):null,e.title||gs()]}),e.role===`participant`&&e.ownerName?(0,J.jsx)(`span`,{className:`oc-chatitem__domain`,children:N_({name:e.ownerName})}):o?(0,J.jsx)(`span`,{className:`oc-chatitem__domain`,children:o}):null]}),u===void 0?null:(0,J.jsx)(`span`,{className:`oc-areq-sidebadge oc-areq-sidebadge--${u}`,title:ei(),"aria-label":ei(),children:u===`approval`?(0,J.jsx)(VC,{size:11,"aria-hidden":!0}):u===`credential`?(0,J.jsx)(IA,{size:11,"aria-hidden":!0}):(0,J.jsx)(KA,{size:11,"aria-hidden":!0})}),r?(0,J.jsx)(`span`,{className:iS(d,br()).className,title:iS(d,br()).label,"aria-label":iS(d,br()).label}):null,n?(0,J.jsx)(`span`,{className:`oc-chatitem__unread`,title:vh(),"aria-label":vh()}):null,e.readOnly?(0,J.jsx)(`span`,{className:`oc-chatitem__readonly`,title:F(),children:(0,J.jsx)(AC,{size:12,"aria-label":F()})}):null,i?(0,J.jsx)(`span`,{className:`oc-chatitem__bookmark group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:Il(),children:(0,J.jsx)(cA,{size:12,"aria-label":Il()})}):null,I?(0,J.jsx)(`span`,{className:`oc-chatitem__age group-hover/row:opacity-0 group-focus-within/row:opacity-0`,title:Kw(e.updatedAt),children:ES(e.updatedAt,Date.now())}):null,(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsx)(K,{variant:`ghost`,size:`icon-xs`,"aria-label":Gn(),className:`opacity-0 group-hover/row:opacity-100 group-focus-within/row:opacity-100 aria-expanded:opacity-100`,onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),onTouchStart:e=>e.stopPropagation(),children:(0,J.jsx)(sC,{})})}),(0,J.jsxs)(fC,{align:`end`,className:`w-48`,onClick:e=>e.stopPropagation(),children:[j?null:(0,J.jsxs)(hC,{onSelect:()=>{V(e.title??``),z(!0)},children:[(0,J.jsx)(LC,{}),` `,$c()]}),f&&!j?(0,J.jsxs)(hC,{disabled:f.state.running,onSelect:()=>f.exportChat(e._id,e.title??wx()),children:[(0,J.jsx)(xC,{}),` `,k()]}):null,(0,J.jsxs)(hC,{onSelect:()=>void T({chatId:e._id,pinned:!e.pinned}),children:[e.pinned?(0,J.jsx)(IS,{}):(0,J.jsx)(Zx,{}),e.pinned?me():Wee()]}),j?null:(0,J.jsx)(Dre,{chatId:e._id}),j?null:(0,J.jsxs)(hC,{onSelect:C,disabled:a===void 0,children:[(0,J.jsx)(zA,{}),` `,tr()]}),j?null:(0,J.jsxs)(hC,{onSelect:()=>P(!0),children:[(0,J.jsx)(oS,{}),` `,c()]}),e.projectId===null?null:(0,J.jsxs)(hC,{onSelect:()=>void M({to:`/project/$projectId`,params:{projectId:e.projectId},search:{c:e._id}}),children:[(0,J.jsx)(EA,{}),` `,tb()]}),e.pinned?null:(0,J.jsxs)(hC,{onSelect:()=>void O({chatId:e._id,hidden:!0}),children:[(0,J.jsx)(hS,{}),` `,Cb()]}),j?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(gC,{}),(0,J.jsxs)(hC,{variant:`destructive`,onSelect:()=>void A({chatId:e._id}),children:[(0,J.jsx)(UA,{}),` `,Rb()]})]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lC,{children:ps()}),(0,J.jsxs)(`div`,{className:`oc-colorgrid`,onClick:e=>e.stopPropagation(),children:[(0,J.jsx)(`button`,{className:`oc-colorgrid__none`,onClick:()=>void E({chatId:e._id,color:null}),"aria-label":Ri(),children:`✕`}),SS.map(t=>(0,J.jsx)(`button`,{className:`oc-colorgrid__dot`+(e.color===t.value?` is-selected`:``),style:{background:t.hue},"aria-label":t.value,onClick:()=>void E({chatId:e._id,color:t.value})},t.value))]}),(0,J.jsx)(gC,{}),(0,J.jsxs)(hC,{variant:`destructive`,onSelect:()=>{requestAnimationFrame(async()=>{await L({title:_r(),description:qt({days:R}),confirmLabel:El(),destructive:!0})&&await w({chatId:e._id})})},children:[(0,J.jsx)(GC,{}),` `,El()]})]})]})]})]}),(0,J.jsx)(xT,{open:ee,onOpenChange:z,title:oy(),canSubmit:B.trim().length>0,onSubmit:async()=>{await x({chatId:e._id,title:B.trim()}),z(!1)},children:(0,J.jsx)(`div`,{className:`oc-form`,children:(0,J.jsxs)(`label`,{className:`oc-field`,children:[(0,J.jsx)(`span`,{className:`oc-field__label`,children:xp()}),(0,J.jsx)(xw,{value:B,onChange:e=>V(e.target.value),autoFocus:!0})]})})}),N?(0,J.jsx)(AS,{open:N,onOpenChange:P,title:Xu(),currentId:e.projectId,onPick:t=>void D({chatId:e._id,projectId:t})}):null]})});function Yre({chats:e}){let[t,n]=(0,q.useState)(!1),r=W(G.chats.setChatSidebar);return(0,J.jsxs)(`div`,{className:`oc-hiddenshared`,children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-hiddenshared__toggle`,"aria-expanded":t,onClick:()=>n(e=>!e),children:[t?(0,J.jsx)(XS,{size:12,"aria-hidden":!0}):(0,J.jsx)(QS,{size:12,"aria-hidden":!0}),iee({count:e.length})]}),t?(0,J.jsx)(`ul`,{className:`oc-hiddenshared__list`,children:e.map(e=>(0,J.jsxs)(`li`,{className:`oc-hiddenshared__row`,children:[(0,J.jsx)(`span`,{className:`oc-hiddenshared__title`,children:e.title??wx()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-hiddenshared__show`,onClick:()=>void r({chatId:e._id,hidden:!1}),children:zg()})]},e._id))}):null]})}var E9=null,D9=0,Xre=400;function Zre(){if(typeof window>`u`)return null;let e=window.AudioContext??window.webkitAudioContext;if(!e)return null;if(!E9)try{E9=new e}catch{return null}return E9}function O9(e,t,n,r,i){let a=e.createOscillator(),o=e.createGain();a.type=`sine`,a.frequency.value=t;let s=e.currentTime+n;o.gain.setValueAtTime(1e-4,s),o.gain.linearRampToValueAtTime(i,s+.015),o.gain.exponentialRampToValueAtTime(1e-4,s+r),a.connect(o).connect(e.destination),a.start(s),a.stop(s+r+.02)}function k9(e){let t=Date.now();if(t-D9<Xre)return;let n=Zre();if(!n)return;D9=t;let r=()=>{try{e(n)}catch{}};n.state===`suspended`?n.resume().then(r,()=>{}):r()}function Qre(){k9(e=>{O9(e,660,0,.16,.12),O9(e,440,.14,.2,.1)})}function $re(){k9(e=>{O9(e,880,0,.14,.08)})}function eie({activeChatId:e}){let t=U(G.messages.listChats,{}),n=W(G.chatReads.markChatSeen),r=U(G.me.getMe,{host:dT}),i=r?.ui?.effective?.replySound===!0,a=r?.userId??null,o=(0,q.useRef)(null),s=(0,q.useRef)(null);return(0,q.useEffect)(()=>{if(!t)return;s.current!==String(a)&&(s.current=String(a),o.current=null);let r=new Map;for(let e of t)e.lastAssistantAt!==null&&r.set(e._id,e.lastAssistantAt);let c=o.current;if(o.current=r,c===null)return;let l=!1;for(let[t,i]of r){let r=c.get(t);r!==void 0&&i<=r||r===void 0&&Date.now()-i>3e4||(l=!0,t===e&&document.visibilityState===`visible`?n({chatId:t}):t!==e&&M2(t))}l&&i&&$re()},[t,e,i,n,a]),(0,q.useEffect)(()=>{e&&document.visibilityState===`visible`&&n({chatId:e})},[e,n]),(0,q.useEffect)(()=>{let t=()=>{document.visibilityState===`visible`&&e&&n({chatId:e})};return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[e,n]),null}var A9=[`admin`,`user`,`pending`];function j9(){let e=U(G.me.authProviders)?.anonymous===!0,[t,n]=(0,q.useState)(!1),r=U(G.dev.listUsersDev,e?{}:`skip`),i=U(G.me.getImpersonation),a=W(G.dev.setMyRole),o=W(G.dev.setRole),s=W(G.admin.startImpersonation),c=W(G.admin.stopImpersonation);if(!e)return null;let l=r?.find(e=>e.isMe),u=l?.role===`admin`,d=i?.impersonating===!0,p=(r??[]).filter(e=>!e.isMe);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-devfab`,onClick:()=>n(!0),title:vee(),children:[(0,J.jsx)(yj,{size:13}),`DEV`]}),(0,J.jsx)($w,{open:t,onOpenChange:n,children:(0,J.jsxs)(Xw,{children:[(0,J.jsxs)(Jw,{children:[(0,J.jsx)(Zw,{children:nf()}),(0,J.jsx)(Qw,{children:ch()})]}),(0,J.jsxs)(`div`,{className:`oc-devsw__me`,children:[(0,J.jsxs)(`span`,{className:`oc-devsw__melabel`,children:[kv({canonical:l?.canonical??`…`}),` `,(0,J.jsx)(Pw,{variant:`outline`,children:l?.role??`…`})]}),(0,J.jsx)(`div`,{className:`oc-devsw__roles`,children:A9.map(e=>(0,J.jsx)(K,{type:`button`,size:`xs`,variant:l?.role===e?`secondary`:`ghost`,disabled:l?.role===e,onClick:()=>void a({role:e}),children:e===`admin`?c_():e===`user`?xy():Lp()},e))})]}),d?(0,J.jsxs)(`div`,{className:`oc-devsw__imp`,children:[f(),` `,(0,J.jsx)(`strong`,{children:i.targetLabel}),`.`,(0,J.jsx)(K,{type:`button`,size:`xs`,variant:`outline`,onClick:()=>void c(),children:Ko()})]}):null,(0,J.jsx)(`div`,{className:`oc-devsw__list`,children:p.length===0?(0,J.jsx)(`p`,{className:`oc-devsw__empty`,children:ed()}):p.map(e=>(0,J.jsxs)(`div`,{className:`oc-devsw__row`,children:[(0,J.jsx)(`span`,{className:`oc-devsw__label`,children:e.name||e.email||e.canonical||e.userId.slice(0,8)}),(0,J.jsx)(`select`,{className:`oc-devsw__select`,value:e.role,disabled:!e.canonical,onChange:t=>e.canonical&&void o({canonical:e.canonical,role:t.target.value}),children:A9.map(e=>(0,J.jsx)(`option`,{value:e,children:e},e))}),(0,J.jsx)(K,{type:`button`,size:`xs`,variant:`ghost`,disabled:!u||e.role===`pending`,title:u?e.role===`pending`?Du():Ur():nu(),onClick:()=>{s({profileId:e.profileId}),n(!1)},children:W_()})]},e.profileId))})]})})]})}var M9=`atrium.authelia-login`;function tie(e){let t=new URL(e.href);if(t.origin!==e.origin)throw Error(`Invalid login return origin.`);for(let e of[`code`,`state`,`error`,`error_description`])t.searchParams.delete(e);return`${t.pathname}${t.search}${t.hash}`}function nie(e,t){let n;return{start(r,i=!1){if(n)return n;try{let t=e.getItem(M9);if(!i&&t!==null)return Promise.resolve(t===`signed-out`?`signed-out`:`failed`);e.setItem(M9,`attempted`)}catch{return Promise.resolve(`failed`)}return n=(async()=>{try{let e=await r(`authelia`,{redirectTo:t()});return e.redirect||e.signingIn?`redirecting`:`failed`}catch{return`failed`}})().finally(()=>{n=void 0}),n},signedOut(){try{e.setItem(M9,`signed-out`)}catch{}},authenticated(){try{e.removeItem(M9)}catch{}}}}var N9;function P9(){return N9??=nie({getItem:e=>window.sessionStorage.getItem(e),setItem:(e,t)=>window.sessionStorage.setItem(e,t),removeItem:e=>window.sessionStorage.removeItem(e)},()=>tie(window.location)),N9}function F9({label:e,mode:t,minimal:n=!1}){let{signOut:r}=kE();async function i(){P9().signedOut(),await r()}let a=W(G.me.setThemeMode).withOptimisticUpdate((e,{mode:t})=>{let n=e.getQuery(G.me.getMe,{host:dT});if(!n)return;let r=t===null?n.defaultThemeMode??`system`:t;e.setQuery(G.me.getMe,{host:dT},{...n,themeMode:t,resolvedThemeMode:r})}),o=t??`default`;return(0,J.jsxs)(_C,{children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsxs)(K,{variant:`ghost`,size:`sm`,className:`gap-1.5`,children:[e,(0,J.jsx)(XS,{className:`opacity-60`})]})}),(0,J.jsx)(fC,{align:`end`,className:`w-52`,children:n?(0,J.jsxs)(hC,{onClick:()=>void i(),children:[(0,J.jsx)(UA,{}),` `,yx()]}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(lC,{children:Ob()}),(0,J.jsxs)(rC,{value:o,onValueChange:e=>void a({mode:e==="default"?null:e}),children:[(0,J.jsxs)(pC,{value:`light`,children:[(0,J.jsx)(hj,{}),` `,Ge()]}),(0,J.jsxs)(pC,{value:`dark`,children:[(0,J.jsx)(XA,{}),` `,Us()]}),(0,J.jsxs)(pC,{value:`system`,children:[(0,J.jsx)(YA,{}),` `,Zb()]}),(0,J.jsx)(pC,{value:`default`,children:yf()})]}),(0,J.jsx)(gC,{}),(0,J.jsxs)(hC,{onClick:()=>void i(),children:[(0,J.jsx)(UA,{}),` `,yx()]})]})})]})}function rie({providers:e,children:t}){return e===void 0?(0,J.jsx)(`div`,{className:`oc-boot`,children:x_()}):e.autheliaOnly?(0,J.jsx)(aie,{enabled:e.authelia}):t}function iie({state:e,retry:t}){return(0,J.jsx)(`div`,{className:`oc-signin`,children:(0,J.jsxs)(`div`,{className:`oc-signin__card`,role:`status`,"aria-live":`polite`,children:[(0,J.jsx)(`p`,{className:`oc-signin__subtitle`,children:e===`redirecting`?Tp():e===`signed-out`?C():e===`unavailable`?mu():rs()}),e===`failed`||e===`signed-out`?(0,J.jsx)(`button`,{type:`button`,className:`oc-provider`,onClick:t,children:ly()}):null]})})}function aie({enabled:e}){let{signIn:t}=kE(),[n,r]=(0,q.useState)(e?`redirecting`:`unavailable`);return(0,q.useEffect)(()=>{let n=!0;return e?P9().start(t).then(e=>{n&&r(e)}):r(`unavailable`),()=>{n=!1}},[e,t]),(0,J.jsx)(iie,{state:n,retry:()=>{r(`redirecting`),P9().start(t,!0).then(r)}})}var oie={altered_words:()=>td(),incorrect:()=>ru(),incoherence:()=>Ou(),formatting:()=>Wr(),latency:()=>G_(),api_error:()=>hi(),other:()=>Sn()},I9=e=>oie[e]?.()??e,sie={anomaly_open:KC,anomaly_resolved:eC,feedback_reply:rS,feedback_resolved:rS,feedback_new:rS,curation:SA,operator_announcement:GA,mention:aA,agent_request:KA,chat_added:WC,group_invite:HC},cie={atrium:()=>Zd(),assistants:()=>ih(),platform:()=>Tv()},lie={investigating:()=>i_(),monitoring:()=>_y(),resolved:()=>Np()},L9=e=>(e?cie[e]:void 0)?.()??`?`,uie=e=>(e?lie[e]:void 0)?.()??`?`,R9=e=>{let t=e===void 0?NaN:Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(ft()):`?`},die={notif_feedback_reply_admin:()=>({title:ay(),body:bp()}),notif_feedback_reply:()=>({title:ay(),body:bp()}),notif_feedback_resolved:()=>({title:Ca(),body:Nh()}),notif_feedback_new:e=>({title:p(),body:qo({reference:e.reference??`?`,category:I9(e.category??`other`)})}),notif_mention:e=>({title:vc(),body:Nd({chat:e.chat??``})}),notif_chat_added:e=>({title:Fb({by:e.by??`?`}),body:Nd({chat:e.chat??``})}),notif_group_invite_request:e=>({title:Qe(),body:Xs({by:e.by??`?`,group:e.group??`?`})}),notif_group_invite_approved:e=>({title:ix(),body:Ef({email:e.email??`?`,group:e.group??`?`})}),notif_group_invite_rejected:e=>({title:Iee(),body:pb({email:e.email??`?`,group:e.group??`?`})}),notif_agent_request_question:e=>({title:nv(),body:zl({chat:e.chat??``})}),notif_agent_request_approval:e=>({title:Ei(),body:zl({chat:e.chat??``})}),notif_agent_request_credential:e=>({title:Pn(),body:zl({chat:e.chat??``})}),notif_curation_proposed:e=>({title:Yh(),body:lo({name:e.name??`?`,agentId:e.agentId??`?`})}),notif_curation_failed:e=>({title:gt(),body:It({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_curation_relaunch_refused:e=>({title:gc(),body:Mb({name:e.name??`?`,reason:e.reason??`unknown`})}),notif_anomaly_open:(e,t)=>({title:Ye({kind:e.kind??`?`}),body:t.body}),notif_anomaly_resolved:(e,t)=>({title:qs({kind:e.kind??`?`}),body:t.body}),notif_operator_maintenance_scheduled:e=>({title:j_(),body:rm({service:L9(e.service),startsAt:R9(e.starts_at),endsAt:R9(e.ends_at)})}),notif_operator_maintenance_completed:e=>({title:dp(),body:Vy({service:L9(e.service),completedAt:R9(e.completed_at)})}),notif_operator_incident_update:e=>({title:gg(),body:Wf({service:L9(e.service),status:uie(e.status),reference:e.reference??`?`})}),notif_operator_subscription_notice:e=>({title:Jv(),body:mee({plan:e.plan??`?`,effectiveAt:R9(e.effective_at)})})};function z9(e){let t=e.messageKey?die[e.messageKey]:void 0;return t?t(e.params??{},e):e.kind===`feedback_reply`?{title:ay(),body:bp()}:e.kind===`feedback_resolved`?{title:Ca(),body:Nh()}:{title:e.title,body:e.body}}function fie(){let e=U(G.notifications.myUnreadCount)??0,t=U(G.notifications.myNotifications),n=U(G.feedback.myFeedback),r=W(G.notifications.markRead),i=W(G.notifications.markAllRead),a=W(G.notifications.clearOne),o=W(G.notifications.clearAll),s=W(G.feedback.closeMyFeedback),c=Kx(),[l,u]=(0,q.useState)(!1),d=U(G.me.getMe,{host:dT}),f=d?.ui?.effective?.notifSound===!0,p=d?.ui?.effective?.notifSystem===!0,m=d?.userId??null,h=(0,q.useRef)(null),g=(0,q.useRef)(0),_=(0,q.useRef)(null);(0,q.useEffect)(()=>{if(!t)return;_.current!==String(m)&&(_.current=String(m),h.current=null,g.current=0);let e=t.reduce((e,t)=>Math.max(e,t.creationTime??0),0);if(h.current===null){h.current=new Set(t.map(e=>String(e._id))),g.current=e;return}let n=h.current,r=t.filter(e=>!n.has(String(e._id))&&(e.creationTime??0)>g.current);for(let e of t)n.add(String(e._id));if(g.current=Math.max(g.current,e),n.size>500){let e=new Set(t.map(e=>String(e._id)));for(let t of n)e.has(t)||n.delete(t)}if(r.length!==0&&(f&&Qre(),p&&typeof Notification<`u`&&Notification.permission===`granted`&&document.visibilityState!==`visible`)){let e=r[0],{title:t,body:n}=z9(e);try{let r=new Notification(t,{body:n,tag:String(e._id)});r.onclick=()=>window.focus()}catch{}}},[t,f,p,m]);let v=e=>{if(e.unread&&r({notificationId:e._id}),!e.href)return;if(u(!1),e.href.startsWith(`/chat/`)){c({to:`/chat/$chatId`,params:{chatId:e.href.slice(6)}});return}let[t,n]=e.href.split(`?`);c({to:t,search:Object.fromEntries(new URLSearchParams(n??``))})};return(0,J.jsxs)(_C,{open:l,onOpenChange:u,children:[(0,J.jsx)(iC,{asChild:!0,children:(0,J.jsxs)(`button`,{type:`button`,className:`oc-bell`,"aria-label":e>0?df({count:e}):mx(),children:[(0,J.jsx)(oA,{size:18,"aria-hidden":!0}),e>0?(0,J.jsx)(`span`,{className:`oc-bell__badge`,"aria-hidden":!0,children:e>9?`9+`:e}):null]})}),(0,J.jsxs)(fC,{align:`end`,className:`oc-notif`,children:[(0,J.jsxs)(`div`,{className:`oc-notif__head`,children:[(0,J.jsx)(`span`,{children:Qy()}),t&&t.length>0?(0,J.jsxs)(`span`,{className:`oc-notif__bulk`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__act`,disabled:e===0,onClick:()=>void i({}),children:bd()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__act`,onClick:()=>void o({}),children:mm()})]}):null]}),t===void 0?(0,J.jsx)(`div`,{className:`oc-notif__empty`,children:fc()}):t.length===0?(0,J.jsx)(`div`,{className:`oc-notif__empty`,children:Nm()}):(0,J.jsx)(`div`,{className:`oc-notif__list`,children:t.map(e=>{let t=sie[e.kind]??oA,{title:n,body:i}=z9(e);return(0,J.jsxs)(`div`,{className:`oc-notif__item${e.unread?` is-unread`:``}${e.href?` is-link`:``}`,role:e.href?`button`:void 0,tabIndex:e.href?0:void 0,onClick:e.href?()=>v(e):void 0,children:[(0,J.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,J.jsx)(t,{size:14,className:`oc-notif__kind oc-notif__kind--${e.kind}`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-notif__title`,children:n}),(0,J.jsxs)(`span`,{className:`oc-notif__row-actions`,children:[e.unread?(0,J.jsx)(`button`,{type:`button`,title:Eg(),"aria-label":Eg(),onClick:t=>{t.stopPropagation(),r({notificationId:e._id})},children:(0,J.jsx)(YS,{size:13})}):null,(0,J.jsx)(`button`,{type:`button`,title:E_(),"aria-label":E_(),onClick:t=>{t.stopPropagation(),a({notificationId:e._id})},children:(0,J.jsx)(XC,{size:13})})]})]}),(0,J.jsx)(`p`,{className:`oc-notif__body`,children:i}),(0,J.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.createdAt).toLocaleString(ft())})]},e._id)})}),n&&n.length>0?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`div`,{className:`oc-notif__head oc-notif__head--sub`,children:Kp()}),(0,J.jsx)(`div`,{className:`oc-notif__list`,children:n.map(e=>(0,J.jsx)(pie,{it:e,onClose:t=>s({feedbackId:e._id,reason:t}),onNavigate:()=>u(!1)},e._id))})]}):null]})]})}function pie({it:e,onClose:t,onNavigate:n}){let r=Mw(),[i,a]=(0,q.useState)(!1),[o,s]=(0,q.useState)(!1),[c,l]=(0,q.useState)(``),[u,d]=(0,q.useState)(!1);async function f(){d(!0);try{await t(c.trim()||void 0)}catch(e){r.error(zd(),e)}finally{d(!1)}}return(0,J.jsxs)(`div`,{className:`oc-notif__item`,children:[(0,J.jsxs)(`div`,{className:`oc-notif__item-head`,children:[(0,J.jsx)(`span`,{className:`oc-notif__title`,children:I9(e.category)}),(0,J.jsx)(`span`,{className:`oc-notif__status${e.answered||e.resolvedAt?` is-answered`:``}`,children:e.resolvedAt?fn():e.answered?ep():Ay()})]}),(0,J.jsx)(`div`,{className:`oc-notif__when`,children:new Date(e.at).toLocaleString(ft())}),e.thread.length>0?(0,J.jsx)(`div`,{className:`oc-notif__thread`,children:e.thread.map((e,t)=>(0,J.jsxs)(`div`,{className:`oc-notif__msg oc-notif__msg--${e.authorRole}`,children:[(0,J.jsx)(`span`,{className:`oc-notif__msg-who`,children:e.authorRole===`admin`?og():e.authorRole===`agent`?ta():Nf()}),(0,J.jsx)(`span`,{className:`oc-notif__msg-text`,children:e.text})]},t))}):null,e.messageText?(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-notif__report-toggle`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[i?(0,J.jsx)(XS,{size:13,"aria-hidden":!0}):(0,J.jsx)(QS,{size:13,"aria-hidden":!0}),v_()]}),i?(0,J.jsx)(`div`,{className:`oc-notif__report-msg`,children:e.messageText}):null]}):null,(0,J.jsxs)(`div`,{className:`oc-notif__report-actions`,children:[(0,J.jsx)(Ak,{to:`/chat/$chatId`,params:{chatId:e.chatId},search:{m:e.messageId},className:`oc-notif__link`,onClick:n,children:Rv()}),o?null:(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__link oc-notif__link--muted`,onClick:()=>s(!0),children:zd()})]}),o?(0,J.jsxs)(`div`,{className:`oc-notif__close-form`,children:[(0,J.jsx)(`textarea`,{className:`oc-notif__close-input`,rows:2,value:c,onChange:e=>l(e.target.value),placeholder:Km()}),(0,J.jsxs)(`div`,{className:`oc-notif__close-actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__close-confirm`,disabled:u,onClick:()=>void f(),children:pv()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-notif__close-cancel`,onClick:()=>{s(!1),l(``)},children:qg()})]})]}):null]})}var B9=2,mie=180;function hie(){let e=Kx(),t=(0,q.useRef)(null),n=(0,q.useRef)(null),[r,i]=(0,q.useState)(!1),[a,o]=(0,q.useState)(``),[s,c]=(0,q.useState)(``),[l,u]=(0,q.useState)(0),d=(0,q.useMemo)(()=>ww(Aw,Cw()),[]);(0,q.useEffect)(()=>{let e=setTimeout(()=>c(a),mie);return()=>clearTimeout(e)},[a]);let f=s.trim(),p=U(G.search.searchConversations,f.length>=B9?{query:f}:`skip`),m=p??[],h=f.length>=B9&&p===void 0;(0,q.useEffect)(()=>{let e=e=>{Ew(e,Aw)&&(e.preventDefault(),i(!0))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),(0,q.useEffect)(()=>{r&&(o(``),c(``),u(0))},[r]),(0,q.useEffect)(()=>{u(0)},[p]),(0,q.useEffect)(()=>{(n.current?.querySelector(`[data-index="${l}"]`))?.scrollIntoView({block:`nearest`})},[l]);let g=(0,q.useCallback)((t,n)=>{i(!1),n&&a.trim()&&$x(n,a.trim()),e({to:`/chat/$chatId`,params:{chatId:t},...n?{search:{m:n}}:{}})},[e,a]);return(0,J.jsxs)(J.Fragment,{children:[(0,J.jsxs)(`button`,{type:`button`,className:`oc-search-trigger`,onClick:()=>i(!0),"aria-label":ate(),children:[(0,J.jsx)(yC,{className:`oc-search-trigger__icon`,"aria-hidden":!0}),(0,J.jsx)(`span`,{className:`oc-search-trigger__label`,children:Fs()}),(0,J.jsx)(`kbd`,{className:`oc-search-trigger__kbd`,children:d})]}),(0,J.jsx)($w,{open:r,onOpenChange:i,children:(0,J.jsxs)(Xw,{showCloseButton:!1,className:`oc-search-palette top-[12vh] translate-y-0 max-w-xl gap-0 overflow-hidden p-0`,onOpenAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,J.jsx)(Zw,{className:`sr-only`,children:ia()}),(0,J.jsxs)(`div`,{className:`oc-search-palette__head`,children:[(0,J.jsx)(yC,{className:`oc-search-palette__head-icon`,"aria-hidden":!0}),(0,J.jsx)(`input`,{ref:t,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`)e.preventDefault(),u(e=>Math.min(e+1,m.length-1));else if(e.key===`ArrowUp`)e.preventDefault(),u(e=>Math.max(e-1,0));else if(e.key===`Enter`){e.preventDefault();let t=m[l];t&&g(t.chatId,t.messageId)}},placeholder:Lr(),className:`oc-search-palette__field`,autoComplete:`off`,spellCheck:!1,"aria-label":hn()})]}),(0,J.jsx)(`div`,{className:`oc-search-palette__results`,ref:n,role:`listbox`,children:f.length<B9?(0,J.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ro({count:B9})}):h?(0,J.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ya()}):m.length===0?(0,J.jsx)(`div`,{className:`oc-search-palette__hint`,children:Ta({term:f})}):m.map((e,t)=>(0,J.jsxs)(`button`,{type:`button`,"data-index":t,role:`option`,"aria-selected":t===l,className:fv(`oc-search-result`,t===l&&`is-active`),onMouseMove:()=>u(t),onClick:()=>g(e.chatId,e.messageId),children:[(0,J.jsx)(`span`,{className:`oc-search-result__icon`,"aria-hidden":!0,children:e.matchedIn===`title`?(0,J.jsx)(AA,{size:15}):(0,J.jsx)(rS,{size:15})}),(0,J.jsxs)(`span`,{className:`oc-search-result__body`,children:[(0,J.jsx)(`span`,{className:`oc-search-result__title`,children:e.title||Fh()}),e.projectPath&&e.projectPath.length>0?(0,J.jsx)(`span`,{className:`oc-search-result__path`,"aria-label":Dp(),children:e.projectPath.join(` › `)}):null,e.snippet?(0,J.jsx)(`span`,{className:`oc-search-result__snippet`,children:e.snippet}):null]}),(0,J.jsx)(`span`,{className:`oc-search-result__tag`,children:e.matchedIn===`title`?ue():rg()})]},e.chatId))}),(0,J.jsxs)(`div`,{className:`oc-search-palette__footer`,children:[(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`kbd`,{children:`↑`}),(0,J.jsx)(`kbd`,{children:`↓`}),` `,go()]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`kbd`,{children:`↵`}),` `,Ct()]}),(0,J.jsxs)(`span`,{children:[(0,J.jsx)(`kbd`,{children:Ut()}),` `,wc()]})]})]})})]})}var V9=[{id:`personal`,label:()=>Ju(),tabs:[`preferences`,`theme`,`files`,`scheduled`,`deletedChats`]},{id:`agents`,label:()=>li(),tabs:[`instances`,`agentFiles`,`chatDefaults`,`voice`,`bridge`,`injections`]},{id:`access`,label:()=>dv(),tabs:[`users`,`groups`,`access`,`roles`,`serviceAccounts`,`trash`]},{id:`observability`,label:()=>Ii(),tabs:[`traces`,`kpi`,`anomalies`,`audit`,`feedbacks`,`subagentReports`,`integrations`]}],gie=new Map(V9.flatMap(e=>e.tabs.map(t=>[t,e.id])));function H9(e){let t=gie.get(e);if(!t)throw Error(`Settings tab "${e}" belongs to no group`);return t}function _ie(e,t){return e.find(e=>H9(e)===t)}V9.flatMap(e=>[...e.tabs]);function vie(){let e=U(G.bridgeHealth.getBridgeAvailability,{});if(e===void 0)return null;let t=e.gatewaysUnreachable??0,n=e.known?e.available?t>0?`warn`:`ok`:`error`:`idle`,r=e.known?e.available?t>0?Gm({count:t}):`${ci()}${e.checkedAt?uv({time:Ww(e.checkedAt)}):``}`:Fi({reason:e.reason??`?`}):qu();return(0,J.jsx)($C,{delayDuration:150,children:(0,J.jsxs)(ew,{children:[(0,J.jsx)(ZC,{asChild:!0,children:(0,J.jsx)(`span`,{className:`oc-bridge-dot oc-bridge-dot--${n}`,role:`img`,"aria-label":r})}),(0,J.jsx)(QC,{children:r})]})})}function U9(e){let t=new Set(UT),n=new Set,r=[];for(let i of e??[])t.has(i)&&!n.has(i)&&(r.push(i),n.add(i));for(let e of UT)n.has(e)||r.push(e);return r}function yie(e,t){let n=new Set(t),r=[...t];return e.map(e=>n.has(e)?r.shift():e)}function bie({tab:e,active:t}){let n=fte[e](),r=`oc-settings-tabs__tab`+(t?` is-active`:``),i=(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(`span`,{className:`oc-settings-tabs__label`,children:n}),e===`bridge`?(0,J.jsx)(vie,{}):null]});return GT.includes(e)?(0,J.jsx)(Ak,{to:`/settings/$tab`,params:{tab:e},className:r,role:`tab`,"aria-selected":t,children:i}):(0,J.jsx)(Ak,{to:`/settings/${e}`,className:r,role:`tab`,"aria-selected":t,children:i})}function xie({tab:e,active:t}){let{attributes:n,listeners:r,setNodeRef:i,transform:a,transition:o,isDragging:s}=yS({id:e});return(0,J.jsxs)(`div`,{ref:i,style:{transform:eS.Transform.toString(a),transition:o,opacity:s?.5:1},className:`oc-settings-tabs__item`,role:`presentation`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-settings-tabs__grip`,"aria-label":M(),...n,...r,children:(0,J.jsx)(kA,{size:14,"aria-hidden":!0})}),(0,J.jsx)(bie,{tab:e,active:t})]})}function Sie(){let e=U(G.me.getMe,{host:dT}),t=W(G.me.setSettingsTabOrder),n=HT(tA({select:e=>e.pathname})),r=n===void 0?void 0:H9(n),i=(0,q.useMemo)(()=>U9(e?.settingsTabOrder??null),[e?.settingsTabOrder]),[a,o]=(0,q.useState)(i);(0,q.useEffect)(()=>o(i),[i]);let s=(0,q.useMemo)(()=>new Set(WT(e?.permissions??[])),[e?.permissions]),c=(0,q.useMemo)(()=>r===void 0?[]:a.filter(e=>s.has(e)&&H9(e)===r),[a,s,r]),l=pS(PS(NS,{activationConstraint:{distance:5}}),PS(bS,{coordinateGetter:vS}));if(r===void 0||c.length===0)return null;let u=V9.find(e=>e.id===r);function d(e){let{active:n,over:r}=e;if(!r||n.id===r.id)return;let i=c.indexOf(n.id),s=c.indexOf(r.id);if(i<0||s<0)return;let l=yie(a,cte(c,i,s));o(l),t({order:l})}return(0,J.jsx)(`div`,{className:`oc-settings-tabs`,role:`tablist`,"aria-label":u?.label(),children:(0,J.jsx)(TS,{sensors:l,collisionDetection:ste,modifiers:[Ure],onDragEnd:d,children:(0,J.jsx)(jS,{items:c,strategy:wS,children:c.map(e=>(0,J.jsx)(xie,{tab:e,active:e===n},e))})})})}function Cie(){let e=U(G.me.getMe,{host:dT}),t=Kx(),n=HT(tA({select:e=>e.pathname})),r=n===void 0?void 0:H9(n),i=(0,q.useMemo)(()=>new Set(WT(e?.permissions??[])),[e?.permissions]),a=(0,q.useMemo)(()=>U9(e?.settingsTabOrder??null).filter(e=>i.has(e)),[e?.settingsTabOrder,i]),o=V9.filter(e=>e.tabs.some(e=>i.has(e)));function s(e){let n=_ie(a,e.id);n&&t({to:KT(n)})}return(0,J.jsxs)(`nav`,{className:`oc-settings-nav`,"aria-label":ds(),children:[(0,J.jsx)(Ak,{to:`/`,className:`oc-settings-nav__back`,children:vd()}),(0,J.jsx)(`div`,{className:`oc-settings-nav__title`,children:xu()}),(0,J.jsx)(`div`,{className:`oc-settings-nav__list`,children:o.map(e=>(0,J.jsx)(`button`,{type:`button`,className:`oc-settings-nav__group`+(e.id===r?` is-active`:``),"aria-current":e.id===r?`true`:void 0,onClick:()=>s(e),children:e.label()},e.id))})]})}var wie=`trash`,Tie=`deletedChats`;function Eie(){throw kD({to:`/settings/$tab`,params:{tab:Tie},replace:!0})}var W9=`oc.theme`;function G9(e){let t=e===`dark`||e===`system`&&window.matchMedia(`(prefers-color-scheme: dark)`).matches;document.documentElement.classList.toggle(`dark`,t)}function K9(e){(0,q.useEffect)(()=>{let t=e??localStorage.getItem(W9)??`system`;if(localStorage.setItem(W9,t),G9(t),t===`system`){let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>G9(`system`);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)}},[e])}function Die(e){(0,q.useEffect)(()=>{if(!e)return;document.documentElement.lang=e;let t;try{t=ft()}catch{t=void 0}t!==e&&ao(e)},[e])}var Oie=(0,q.lazy)(()=>Uw(()=>import(`./RolesTab-DDYieLTF.js`).then(e=>({default:e.RolesTab})),__vite__mapDeps([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22]))),kie=(0,q.lazy)(()=>Uw(()=>import(`./InstancesTab-DsJ_BBfc.js`).then(e=>({default:e.InstancesTab})),__vite__mapDeps([23,3,4,24,25,26,7,27,28,8,29,9,30,31,6,32,33,10,11,12,13,14,15,19,18,16,17,20,21,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56]))),Aie=(0,q.lazy)(()=>Uw(()=>import(`./PromptInjectionsTab-D3drsS9C.js`).then(e=>({default:e.PromptInjectionsTab})),__vite__mapDeps([57,3,4,24,25,26,7,27,28,8,29,9,30,31,6,10,13,14,50,58,59]))),jie=(0,q.lazy)(()=>Uw(()=>import(`./GroupsTab-hxsjfQDc.js`).then(e=>({default:e.GroupsTab})),__vite__mapDeps([60,3,4,61,44,6,7,8,9,46,62,63,14,26,27,28,29,48,38,10,11,12,13,15,19,18,50,16,17,20,21,34,51,52,53,54,33,49,35,36,37,39,40,41,64]))),Mie=(0,q.lazy)(()=>Uw(()=>import(`./IntegrationsTab-Cf3lTCzz.js`).then(e=>({default:e.IntegrationsTab})),__vite__mapDeps([65,3,4,6,7,8,9,26,27,28,29,10,11,12,15]))),Nie=(0,q.lazy)(()=>Uw(()=>import(`./FeedbacksTab-DWmslsAt.js`).then(e=>({default:e.FeedbacksTab})),__vite__mapDeps([66,3,4,10,12,49,16,17,18,11,19,14,35,27,28,36,37,29,9,38,6,7,8,39,40,41]))),Pie=(0,q.lazy)(()=>Uw(()=>import(`./SubAgentReportsTab-GXHpWbrW.js`).then(e=>({default:e.SubAgentReportsTab})),__vite__mapDeps([67,3,4,10,12,49,16,17,18,11,19,14,35,27,28,36,37,29,9,38,6,7,8,39,40,41]))),Fie=(0,q.lazy)(()=>Uw(()=>import(`./TrashTab-BVZJggvr.js`).then(e=>({default:e.TrashTab})),__vite__mapDeps([68,3,4,69,40,10,12,13,14,49,16,17,18,11,19,70,71,72,53,73]))),Iie=(0,q.lazy)(()=>Uw(()=>import(`./DeletedChatsTab-Fzk38aqT.js`).then(e=>({default:e.DeletedChatsTab})),__vite__mapDeps([74,3,4,69,10,12,16,17,18,11,19,14,71,72,53,40,49,73]))),Lie=(0,q.lazy)(()=>Uw(()=>import(`./FilesTab-DzHfzOnQ.js`).then(e=>({default:e.FilesTab})),__vite__mapDeps([75,3,4,37,27,29,9,38,76,6,7,8,53,40,26,28,17,18,10,12,13,14,15,41]))),Rie=(0,q.lazy)(()=>Uw(()=>import(`./ScheduledTab-D-yTTYHC.js`).then(e=>({default:e.ScheduledTab})),__vite__mapDeps([77,3,4,61,44,78,21,79,80,53,40,26,7,27,28,8,29,9,17,18,10,32,33,11,12,13,14,15,19,50,41,51,52,54,49,81,36,59]))),zie=(0,q.lazy)(()=>Uw(()=>import(`./AgentFilesTab-D3tMMo2R.js`).then(e=>({default:e.AgentFilesTab})),__vite__mapDeps([82,3,4,47,26,7,27,28,8,29,9,17,18,10,12,13,14,15,19,50,83,31,55,59]))),Bie=(0,q.lazy)(()=>Uw(()=>import(`./PreferencesTab-DiDi7mpY.js`).then(e=>({default:e.PreferencesTab})),__vite__mapDeps([84,3,4,6,7,8,9,26,27,28,29,10,11,12,85,50,13,14,15,58,30,86,81,36,32,33,59]))),Vie=(0,q.lazy)(()=>Uw(()=>import(`./ChatDefaultsTab-CIX9WUCl.js`).then(e=>({default:e.ChatDefaultsTab})),__vite__mapDeps([87,3,4,69,21,6,7,8,9,39,47,26,27,28,29,32,33,10,11,12,88,53,83,55,86,59]))),Hie=(0,q.lazy)(()=>Uw(()=>import(`./AccessTab-gaTBs3lV.js`).then(e=>({default:e.AccessTab})),__vite__mapDeps([89,3,4,26,7,27,28,8,29,9,12,15]))),Uie=(0,q.lazy)(()=>Uw(()=>import(`./ThemeShowroom-uU3PL_6V.js`).then(e=>({default:e.ThemeShowroom})),__vite__mapDeps([90,3,4,7,37,27,29,9,38,76,6,8,91,14,26,28,10,11,12,15,50,58,30,92,41,54,52,33,49,51,53,93,39])));function Wie(){let{isAuthenticated:e}=ZT();return(0,q.useEffect)(()=>{e&&P9().authenticated()},[e]),(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(rE,{children:(0,J.jsx)(`div`,{className:`oc-boot`,children:x_()})}),(0,J.jsx)(nE,{children:(0,J.jsx)(Kie,{})}),(0,J.jsx)(tE,{children:(0,J.jsx)(Nw,{children:(0,J.jsx)(Bre,{children:(0,J.jsx)(Jie,{})})})})]})}function Gie(){return(0,J.jsxs)(`svg`,{className:`oc-provider__logo`,viewBox:`0 0 48 48`,"aria-hidden":`true`,children:[(0,J.jsx)(`path`,{fill:`#EA4335`,d:`M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z`}),(0,J.jsx)(`path`,{fill:`#4285F4`,d:`M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z`}),(0,J.jsx)(`path`,{fill:`#FBBC05`,d:`M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z`}),(0,J.jsx)(`path`,{fill:`#34A853`,d:`M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z`})]})}function Kie(){let{signIn:e}=kE();K9(void 0),Dw(void 0);let t=U(G.charts.brandForHost,{host:dT}),n=lT(dT),r=t??n??null,i=JC(void 0);YC(r?.tokens??null,i),(0,q.useEffect)(()=>{t&&uT(dT,t)},[t]);let a=r?.brand,o=a&&!a.isDefault?R0(a,i):null,s=a?.label??`Atrium`,c=U(G.me.authProviders),[l,u]=(0,q.useState)(null);async function d(t){u(null);try{await e(t)}catch{u(Ud())}}let f=c!==void 0&&!c.google&&!c.microsoft&&!c.authelia&&!c.anonymous;return(0,J.jsx)(rie,{providers:c,children:(0,J.jsxs)(`div`,{className:`oc-signin`,children:[(0,J.jsxs)(`svg`,{className:`oc-signin__motif`,viewBox:`0 0 1200 1000`,preserveAspectRatio:`none`,"aria-hidden":`true`,children:[(0,J.jsx)(`polyline`,{className:`oc-signin__line`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,vectorEffect:`non-scaling-stroke`}),(0,J.jsx)(`polyline`,{className:`oc-signin__pulse`,points:`0,860 470,860 522,790 574,940 626,810 678,860 1200,860`,pathLength:`100`,vectorEffect:`non-scaling-stroke`})]}),(0,J.jsxs)(`div`,{className:`oc-signin__brand`,children:[o?(0,J.jsx)(`img`,{className:`oc-signin__brandlogo`,src:o,alt:``}):null,(0,J.jsx)(`span`,{className:`oc-signin__wordmark`,children:s})]}),(0,J.jsxs)(`div`,{className:`oc-signin__card`,children:[(0,J.jsx)(`h1`,{className:`oc-signin__title`,children:Xm()}),(0,J.jsx)(`p`,{className:`oc-signin__subtitle`,children:_v()}),(0,J.jsxs)(`div`,{className:`oc-signin__providers`,children:[c?.google?(0,J.jsxs)(`button`,{type:`button`,className:`oc-provider oc-provider--google`,onClick:()=>void d(`google`),children:[(0,J.jsx)(Gie,{}),(0,J.jsx)(`span`,{children:Zg()})]}):null,c?.microsoft?(0,J.jsx)(`button`,{type:`button`,className:`oc-provider oc-provider--microsoft`,onClick:()=>void d(`microsoft-entra-id`),children:(0,J.jsx)(`span`,{children:dd()})}):null,c?.authelia?(0,J.jsx)(`button`,{type:`button`,className:`oc-provider oc-provider--authelia`,onClick:()=>void d(`authelia`),children:(0,J.jsx)(`span`,{children:ly()})}):null]}),l?(0,J.jsx)(`p`,{className:`oc-signin__error`,children:l}):null,f?(0,J.jsx)(`p`,{className:`oc-signin__error`,children:mu()}):null,c?.anonymous?(0,J.jsx)(`button`,{type:`button`,className:`oc-signin__dev`,onClick:()=>void e(`anonymous`),children:Bu()}):null]})]})})}function qie(){let{width:e,collapsed:t,isMobile:n}=U$();return(0,J.jsxs)(`div`,{className:`oc-shell`,children:[(0,J.jsxs)(`header`,{className:`oc-topbar`,children:[(0,J.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`}}),(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`5.5rem`,height:`1.1rem`}})]}),(0,J.jsx)(`div`,{className:`oc-topbar__search`,children:(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`100%`,height:`2.25rem`}})}),(0,J.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,J.jsx)(`div`,{className:`oc-skel`,style:{width:`1.75rem`,height:`1.75rem`,borderRadius:`999px`}})})]}),(0,J.jsxs)(`div`,{className:n?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[!t&&!n?(0,J.jsx)(`div`,{className:`oc-sidebar-col`,style:{width:e,flex:`0 0 ${e}px`},children:(0,J.jsxs)(`aside`,{className:`oc-sidebar`,children:[(0,J.jsx)(`div`,{className:`oc-skel`,style:{height:`2.25rem`,margin:`0.25rem 0.25rem 0`}}),(0,J.jsx)(S9,{})]})}):null,(0,J.jsx)(`main`,{className:`oc-main`})]})]})}function Jie(){let e=U(G.me.getMe,{host:dT}),t=W(G.me.bootstrap),n=Kx();(0,q.useEffect)(()=>{e&&!e.hasProfile&&t()},[e,t]),K9(e?.resolvedThemeMode),Dw(e?.resolvedFontScale);let r=JC(e?.resolvedThemeMode);YC(e?.resolvedChartTokens,r),Die(e?.resolvedLocale);let i=(0,q.useRef)(null);if((0,q.useEffect)(()=>{e&&(i.current!==null&&i.current!==e.userId&&n({to:`/`}),i.current=e.userId)},[e,n]),e===void 0)return(0,J.jsx)(qie,{});let a=e.name||e.email||ti();return e.role===`pending`?(0,J.jsxs)(`div`,{className:`oc-shell`,children:[(0,J.jsx)(q9,{}),(0,J.jsx)(j9,{}),(0,J.jsxs)(`header`,{className:`oc-topbar`,children:[(0,J.jsx)(`span`,{className:`oc-topbar__brand`,children:(0,J.jsx)(J9,{brand:e.resolvedChartBrand,resolvedThemeMode:e.resolvedThemeMode})}),(0,J.jsx)(`div`,{className:`oc-topbar__actions`,children:(0,J.jsx)(F9,{label:a,mode:e.themeMode,minimal:!0})})]}),(0,J.jsxs)(`div`,{className:`oc-pending`,children:[(0,J.jsx)(`h1`,{className:`oc-pending__title`,children:rv()}),(0,J.jsx)(`p`,{className:`oc-pending__body`,children:Di()})]})]}):(0,J.jsx)(Xie,{canOpenSettings:WT(e.permissions??[]).length>0,viewerUserId:e.userId,userLabel:a,themeMode:e.themeMode,resolvedThemeMode:e.resolvedThemeMode,brand:e.resolvedChartBrand},e.userId)}function q9(){let e=U(G.me.getImpersonation),t=W(G.admin.stopImpersonation);return!e||!e.impersonating?null:(0,J.jsxs)(`div`,{className:`oc-imp`,role:`alert`,children:[(0,J.jsx)(CC,{className:`size-4 shrink-0`}),(0,J.jsxs)(`span`,{className:`oc-imp__text`,children:[Fn(),` `,(0,J.jsx)(`strong`,{children:e.targetLabel}),Bl(),(0,J.jsx)(`strong`,{children:e.realLabel}),Hc()]}),(0,J.jsx)(K,{size:`sm`,variant:`outline`,className:`oc-imp__exit`,onClick:()=>void t(),children:ar()})]})}function J9({brand:e,resolvedThemeMode:t}){let n=JC(t),r=e?.label??`Atrium`,i=e?.isDefault??!0,a=R0(e,n),[o,s]=(0,q.useState)(!1);return(0,q.useEffect)(()=>s(!1),[a]),(0,J.jsxs)(J.Fragment,{children:[a!==null&&!o?(0,J.jsx)(`img`,{className:`oc-brand__logo`,src:a,alt:``,"aria-hidden":`true`,onError:()=>s(!0)}):i?(0,J.jsx)(H0,{className:`oc-brand__logo`}):null,(0,J.jsx)(`span`,{className:`oc-brand__label`,children:r})]})}function Yie({userLabel:e,themeMode:t,resolvedThemeMode:n,brand:r,collapsed:i,onToggleSidebar:a}){return(0,J.jsxs)(`header`,{className:`oc-topbar`,children:[(0,J.jsxs)(`div`,{className:`oc-topbar__left`,children:[(0,J.jsx)(K,{variant:`ghost`,size:`icon-sm`,"aria-label":i?ml():ke(),onClick:a,children:i?(0,J.jsx)($A,{}):(0,J.jsx)(hS,{})}),(0,J.jsx)(Ak,{to:`/`,className:`oc-topbar__brand`,children:(0,J.jsx)(J9,{brand:r,resolvedThemeMode:n})})]}),(0,J.jsx)(`div`,{className:`oc-topbar__search`,children:(0,J.jsx)(hie,{})}),(0,J.jsxs)(`div`,{className:`oc-topbar__actions`,children:[(0,J.jsx)(fie,{}),(0,J.jsx)(F9,{label:e,mode:t})]})]})}function Xie({canOpenSettings:e,viewerUserId:t,userLabel:n,themeMode:r,resolvedThemeMode:i,brand:a}){let{width:o,columnRef:s,collapsed:c,toggleCollapsed:l,collapse:u,startResize:d,isMobile:f}=U$(),p=Yk(),m=aS({strict:!1}),h=Kx(),g=!!p({to:`/settings`,fuzzy:!0});(0,q.useEffect)(()=>{f&&u()},[tA({select:e=>e.pathname}),f,u]);let _=(0,q.useCallback)(e=>{h({to:`/chat/$chatId`,params:{chatId:e}})},[h]),{startNewChat:v,picker:y}=MS(_),b=(0,q.useMemo)(()=>ww(Ow,Cw()),[]);return(0,q.useEffect)(()=>{let e=e=>{Ew(e,Ow)&&(e.preventDefault(),v())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v]),(0,J.jsxs)(`div`,{className:`oc-shell`,children:[y,(0,J.jsx)(eie,{activeChatId:m.chatId??null}),(0,J.jsx)(q9,{}),(0,J.jsx)(j9,{}),(0,J.jsx)(Yie,{userLabel:n,themeMode:r,resolvedThemeMode:i,brand:a,collapsed:c,onToggleSidebar:l}),(0,J.jsxs)(`div`,{className:f?`oc-workspace oc-workspace--mobile`:`oc-workspace`,children:[f&&!c?(0,J.jsx)(`div`,{className:`oc-sidebar-backdrop`,onClick:u,"aria-hidden":!0}):null,c?null:(0,J.jsxs)(`div`,{className:`oc-sidebar-col`,ref:e=>{s.current=f?null:e},style:f?void 0:{width:o,flex:`0 0 ${o}px`},children:[g?(0,J.jsx)(Cie,{}):(0,J.jsxs)(J.Fragment,{children:[(0,J.jsx)(Jre,{activeChatId:m.chatId??null,onSelect:_,onNewChat:()=>void v(),newChatShortcut:b}),(0,J.jsx)(K,{variant:`ghost`,className:`mx-2 justify-start`,asChild:!0,children:(0,J.jsxs)(Ak,{to:`/settings/$tab`,params:{tab:`scheduled`},children:[(0,J.jsx)(uA,{"aria-hidden":!0}),ca()]})}),(0,J.jsx)(K,{variant:`ghost`,className:`mx-2 justify-start`,asChild:!0,children:(0,J.jsxs)(Ak,{to:`/settings/$tab`,params:{tab:`files`},children:[(0,J.jsx)(RA,{"aria-hidden":!0}),ja()]})}),e?(0,J.jsx)(K,{variant:`ghost`,className:`mx-2 mb-2 justify-start`,asChild:!0,children:(0,J.jsxs)(Ak,{to:`/settings`,children:[(0,J.jsx)(sj,{"aria-hidden":!0}),ete()]})}):null]}),(0,J.jsx)(`div`,{className:`oc-sidebar-resizer`,onPointerDown:d,role:`separator`,"aria-orientation":`vertical`,"aria-label":Ds()})]}),(0,J.jsx)(`main`,{className:`oc-main`,children:(0,J.jsx)(Gk,{})}),(0,J.jsx)(G$,{viewerUserId:t,currentChatId:m.chatId??null})]}),(0,J.jsx)(bK,{})]})}function Zie(){let e=U(G.me.getMe,{host:dT}),t=Kx(),n=tA({select:e=>e.pathname}),r=(0,q.useMemo)(()=>e?WT(e.permissions??[]):[],[e]),i=e!==void 0&&r.length===0;if((0,q.useEffect)(()=>{i&&t({to:`/`})},[i,t]),e===void 0)return(0,J.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:x_()});if(i)return null;let a=HT(n),o=a!==void 0&&!r.includes(a);return(0,J.jsxs)(`div`,{className:`oc-admin`,children:[(0,J.jsx)(Sie,{}),(0,J.jsx)(`div`,{className:`oc-admin__body`,children:o?(0,J.jsx)(Qie,{}):(0,J.jsx)(Gk,{})})]})}function Qie(){return(0,J.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,J.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,J.jsx)(KC,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-route-error__title`,children:Qi()}),(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:jr()})]})}function $ie(){let e=U(G.me.getMe,{host:dT}),t=Kx();return(0,q.useEffect)(()=>{if(e===void 0)return;let n=WT(e.permissions??[]),r=n.includes(`files`)?KT(`files`):n.length>0?KT(n[0]):`/`;t({to:r,replace:!0})},[e,t]),(0,J.jsx)(`div`,{className:`oc-admin__hint`,style:{padding:16},children:x_()})}function eae(e){switch(e){case`groups`:return(0,J.jsx)(jie,{});case`integrations`:return(0,J.jsx)(Mie,{});case`instances`:return(0,J.jsx)(kie,{});case`injections`:return(0,J.jsx)(Aie,{});case`theme`:return(0,J.jsx)(Uie,{});case`feedbacks`:return(0,J.jsx)(Nie,{});case`subagentReports`:return(0,J.jsx)(Pie,{});case`files`:return(0,J.jsx)(Lie,{});case`scheduled`:return(0,J.jsx)(Rie,{});case`agentFiles`:return(0,J.jsx)(zie,{});case`preferences`:return(0,J.jsx)(Bie,{});case`chatDefaults`:return(0,J.jsx)(Vie,{});case`access`:return(0,J.jsx)(Hie,{});case`trash`:return(0,J.jsx)(Fie,{});case`deletedChats`:return(0,J.jsx)(Iie,{});default:return(0,J.jsx)(Oie,{})}}function tae(){let{tab:e}=aS({from:`/settings/$tab`});return(0,J.jsx)(q.Suspense,{fallback:(0,J.jsx)(`div`,{className:`oc-settings__tab-loading`,"aria-busy":`true`}),children:eae(e)})}function nae(){let{chatId:e}=aS({from:`/chat/$chatId`}),{m:t}=Vx({from:`/chat/$chatId`});return(0,q.useEffect)(()=>{q$(e)},[e]),(0,J.jsx)(L7,{chatId:e,focusMessageId:t??null})}function rae(){let e=Kx(),t=J$(),n=U(G.messages.listChats,{}),r=t!==null&&n!==void 0&&n.some(e=>e._id===t);return(0,q.useEffect)(()=>{r&&t&&e({to:`/chat/$chatId`,params:{chatId:t},replace:!0})},[r,t,e]),t!==null&&(n===void 0||r)?(0,J.jsx)(`div`,{className:`oc-boot`,children:x_()}):(0,J.jsx)(L7,{chatId:null})}var Y9=Fk({component:Wie}),iae=Nk({getParentRoute:()=>Y9,path:`/`,component:rae}),aae=Nk({getParentRoute:()=>Y9,path:`chat/$chatId`,component:nae,validateSearch:e=>({m:typeof e.m==`string`?e.m:void 0})}),oae=Nk({getParentRoute:()=>Y9,path:`project/$projectId`,component:Ik(()=>Uw(()=>import(`./ProjectPage-DDto6xkD.js`),__vite__mapDeps([94,3,4,43,95,7,46,63,11,12,15,19,14,18,10,96,27,44,37,29,9,38,97,78,80,40,13,16,17,20,21,71,98])),`ProjectPage`),validateSearch:e=>({c:typeof e.c==`string`?e.c:void 0})}),sae=Nk({getParentRoute:()=>Y9,path:wie,beforeLoad:Eie}),X9=Nk({getParentRoute:()=>Y9,path:`settings`,component:Zie}),cae=Nk({getParentRoute:()=>X9,path:`/`,component:$ie}),lae=Nk({getParentRoute:()=>X9,path:`traces`,validateSearch:nT,component:Ik(()=>Uw(()=>import(`./TracesTab-C7zX1NUU.js`),__vite__mapDeps([99,3,4,43,7,100,97,101,14,26,27,28,8,29,9,48,38,10,12,15,49,19,18,102,50,54,52,33,11,51,53,93,39,35,36,37,6,40,41])),`TracesTab`)}),uae=Nk({getParentRoute:()=>X9,path:`bridge`,validateSearch:eT,component:Ik(()=>Uw(()=>import(`./BridgeTab-CBE4zTQ1.js`),__vite__mapDeps([42,3,4,24,25,26,7,27,28,8,29,9,30,31,43,44,36,45,21,6,46,47,48,38,32,33,10,11,12,13,14,15,49,19,18,50,41,51,52,53,54,55,56])),`BridgeTab`)}),dae=Nk({getParentRoute:()=>X9,path:`voice`,validateSearch:oT,component:Ik(()=>Uw(()=>import(`./VoiceTab-CnZ-twTR.js`),__vite__mapDeps([103,3,4,43,104,6,7,8,9,26,27,28,29,48,38,10,12,15,50,59])),`VoiceTab`)}),fae=Nk({getParentRoute:()=>X9,path:`audit`,validateSearch:iT,component:Ik(()=>Uw(()=>import(`./AuditTab-Yw1LvjgD.js`),__vite__mapDeps([105,3,4,43,26,7,27,28,8,29,9,12,49,102,54,52,33,10,11,51,53,93,39,14,35,36,37,38,6,40,41])),`AuditTab`)}),pae=Nk({getParentRoute:()=>X9,path:`anomalies`,validateSearch:cT,component:Ik(()=>Uw(()=>import(`./AnomaliesTab-CdFgsRwT.js`),__vite__mapDeps([106,3,4,43,26,7,27,28,8,29,9,12,13,14,15,49,19,18,10,102,50,16,17,11,54,52,33,51,53,35,36,37,38,6,39,40,41,56])),`AnomaliesTab`)}),mae=Nk({getParentRoute:()=>X9,path:`kpi`,validateSearch:aT,component:Ik(()=>Uw(()=>import(`./KpiTab-C6dn6jVl.js`),__vite__mapDeps([107,3,4,43,12,102,50,92,54,52,33,29,9,10,11,49])),`KpiTab`)}),hae=Nk({getParentRoute:()=>X9,path:`serviceAccounts`,validateSearch:tT,component:Ik(()=>Uw(()=>import(`./ServiceAccountsTab-fJYmH0eU.js`),__vite__mapDeps([108,3,4,43,7,27,44,100,26,28,8,29,9,10,11,12,13,14,15,49,19,18,16,17,20,21,51,52,53,54,33,35,36,37,38,6,39,40,41,22])),`ServiceAccountsTab`)}),gae=Nk({getParentRoute:()=>X9,path:`users`,validateSearch:sT,component:Ik(()=>Uw(()=>import(`./UsersTab-HdsTBYR0.js`),__vite__mapDeps([109,3,4,43,37,27,29,9,38,6,7,8,46,63,26,28,10,12,13,14,15,19,18,50,16,17,11,34,110,51,52,53,54,33,49,35,36,39,40,41,64])),`UsersTab`)}),_ae=Nk({getParentRoute:()=>X9,path:`uiprefs`,beforeLoad:()=>{throw kD({to:`/settings/$tab`,params:{tab:pte.uiprefs},replace:!0})}}),vae=Nk({getParentRoute:()=>X9,path:`$tab`,parseParams:e=>({tab:rT([...GT]).catch(`roles`).parse(e.tab)}),component:tae});function yae({error:e,reset:t}){let n=Kx(),r=Y$(e),[i]=(0,q.useState)(()=>r&&$$(Date.now()));return(0,q.useEffect)(()=>{i&&window.location.reload()},[i]),i?(0,J.jsx)(`div`,{className:`oc-route-error`,role:`status`,children:(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:sn()})}):(0,J.jsxs)(`div`,{className:`oc-route-error`,role:`alert`,children:[(0,J.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,J.jsx)(KC,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-route-error__title`,children:jo()}),(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:Ha()}),(0,J.jsxs)(`div`,{className:`oc-route-error__actions`,children:[(0,J.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>{r?window.location.reload():t()},children:ya()}),(0,J.jsx)(`button`,{type:`button`,className:`oc-route-error__cta oc-route-error__cta--ghost`,onClick:()=>void n({to:`/`}),children:kh()})]})]})}function bae(){let e=Kx();return(0,J.jsxs)(`div`,{className:`oc-route-error`,role:`status`,children:[(0,J.jsx)(`div`,{className:`oc-route-error__icon`,"aria-hidden":!0,children:(0,J.jsx)(hA,{size:28})}),(0,J.jsx)(`h2`,{className:`oc-route-error__title`,children:ie()}),(0,J.jsx)(`p`,{className:`oc-route-error__body`,children:Qh()}),(0,J.jsx)(`div`,{className:`oc-route-error__actions`,children:(0,J.jsx)(`button`,{type:`button`,className:`oc-route-error__cta`,onClick:()=>void e({to:`/`}),children:kh()})})]})}var Z9=Zk({routeTree:Y9.addChildren([iae,aae,oae,sae,X9.addChildren([cae,lae,dae,uae,fae,pae,mae,hae,gae,_ae,vae])]),defaultPreload:`intent`,defaultErrorComponent:yae,defaultNotFoundComponent:bae}),xae=()=>null;function Q9({children:e}){return(0,J.jsx)(`div`,{style:{display:`flex`,minHeight:`100vh`,alignItems:`center`,justifyContent:`center`,padding:`2rem`,textAlign:`center`,font:`14px system-ui, sans-serif`,opacity:.6},children:e})}var $9=iE.createRoot(document.getElementById(`root`));$9.render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(Q9,{children:fc()})})),r1().then(e=>{O1(document,E1(T1(s1(),window.location.origin,[a1(),o1()])));let t=new Ch(e);$9.render((0,J.jsx)(q.StrictMode,{children:(0,J.jsx)(AE,{client:t,children:(0,J.jsxs)(mT,{children:[(0,J.jsx)(p5,{children:(0,J.jsx)(eA,{router:Z9})}),(0,J.jsx)(q.Suspense,{fallback:null,children:(0,J.jsx)(xae,{router:Z9,position:`bottom-right`})})]})})}))}).catch(e=>{console.error(`Boot failed:`,e),$9.render((0,J.jsx)(q.StrictMode,{children:(0,J.jsxs)(Q9,{children:[Js(),` `,e instanceof Error?e.message:String(e)]})}))});