efficient-shell 8.34.0 → 8.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/README.md +9 -0
  2. package/dist/{Browser-QBAMRKYI.js → Browser-F67PEY2U.js} +14 -14
  3. package/dist/Calculator-6ZU5MKTQ.js +29 -0
  4. package/dist/CurrencyConverter-Z6L7QAZU.js +21 -0
  5. package/dist/{Documents-E3GMXALJ.js → Documents-MQDSI27F.js} +25 -25
  6. package/dist/{Files-2DWPYRM5.js → Files-DEC4KVQM.js} +43 -43
  7. package/dist/Notepad-2IRVJ7MB.js +25 -0
  8. package/dist/PdfViewer-KSLOYXMD.js +1 -0
  9. package/dist/{PomodoroTimer-2HPCAEI5.js → PomodoroTimer-TRGMI4YT.js} +44 -44
  10. package/dist/{Preview-VZYFOH2U.js → Preview-PXOEKXSR.js} +17 -17
  11. package/dist/Sidebar-QQFJJWE2.js +43 -0
  12. package/dist/Spreadsheet-WROI4P6D.js +37 -0
  13. package/dist/Stock-SUDCDSUL.js +16 -0
  14. package/dist/{Weather-DS4YZ6SH.js → Weather-WQE4ZQAL.js} +18 -18
  15. package/dist/{WorldClock-7S4TITSF.js → WorldClock-2AGEYLZP.js} +6 -6
  16. package/dist/ai/index.d.ts +47 -9
  17. package/dist/ai/index.js +38 -33
  18. package/dist/ai.css +1 -1
  19. package/dist/apps/index.js +1 -1
  20. package/dist/bin/media-host-check.js +1 -1
  21. package/dist/bin/ui-check.js +1 -1
  22. package/dist/charts/BoxPlotChart.js +1 -1
  23. package/dist/charts/CandlestickChart.js +1 -1
  24. package/dist/charts/CartesianPlot.js +1 -1
  25. package/dist/charts/ChordChart.js +1 -1
  26. package/dist/charts/ColumnChart.js +1 -1
  27. package/dist/charts/HeatmapChart.js +1 -1
  28. package/dist/charts/HistogramChart.js +1 -1
  29. package/dist/charts/RadarChart.js +1 -1
  30. package/dist/charts/RangeChart.js +1 -1
  31. package/dist/charts/SankeyChart.js +1 -1
  32. package/dist/charts/ScatterChart.js +1 -1
  33. package/dist/charts/SpecChart.js +1 -1
  34. package/dist/charts/SunburstChart.js +1 -1
  35. package/dist/charts/TimeSeriesChart.js +1 -1
  36. package/dist/charts/TreemapChart.js +1 -1
  37. package/dist/charts/WaterfallChart.js +1 -1
  38. package/dist/{chunk-Z2YGQBLZ.js → chunk-2C6IG7LG.js} +1 -1
  39. package/dist/chunk-2EOQDYGM.js +29 -0
  40. package/dist/{chunk-7CFH6Y4T.js → chunk-2F7ZOMKK.js} +1 -1
  41. package/dist/chunk-2PWZNFFP.js +19 -0
  42. package/dist/{chunk-KIBL6M3T.js → chunk-2SHYR3RA.js} +4 -3
  43. package/dist/{chunk-G433MKIN.js → chunk-2U2GJCSP.js} +5 -5
  44. package/dist/{chunk-EYX6KLCZ.js → chunk-37CCKGHU.js} +1 -1
  45. package/dist/{chunk-BQ2IPQNR.js → chunk-3RPIPYLU.js} +1 -1
  46. package/dist/chunk-4AJRHTTB.js +1 -0
  47. package/dist/{chunk-XWLWG4HS.js → chunk-4GVH4ZUH.js} +1 -1
  48. package/dist/{chunk-GIM2422N.js → chunk-4HCRZHIX.js} +1 -1
  49. package/dist/{chunk-MXHEREC6.js → chunk-4MO375G3.js} +3 -3
  50. package/dist/chunk-5FCEBKT2.js +7 -0
  51. package/dist/{chunk-DGLCMYSQ.js → chunk-5N5DBTTF.js} +11 -11
  52. package/dist/{chunk-PNQ4EYYM.js → chunk-5YELPBUT.js} +3 -3
  53. package/dist/{chunk-QDOTMA3W.js → chunk-64ZHCEZN.js} +1 -1
  54. package/dist/{chunk-Y2D2YMFY.js → chunk-6ANFVX4M.js} +12 -12
  55. package/dist/{chunk-T5SEGUCJ.js → chunk-7ACSSYEZ.js} +13 -13
  56. package/dist/{chunk-GI7FOLDX.js → chunk-ACW3J77L.js} +1 -1
  57. package/dist/{chunk-ERMZ75FO.js → chunk-AF7R2MV4.js} +1 -1
  58. package/dist/{chunk-QQK3XS6H.js → chunk-AZU7YOES.js} +8 -8
  59. package/dist/{chunk-NFR4QZL2.js → chunk-BHMUOWAE.js} +4 -4
  60. package/dist/{chunk-TFMC2WAS.js → chunk-BKZGI76S.js} +1 -1
  61. package/dist/{chunk-UB4BTRSB.js → chunk-BYCOB6WT.js} +1 -1
  62. package/dist/{chunk-LCM5U6BY.js → chunk-CCPNMYCK.js} +1 -1
  63. package/dist/{chunk-RAAUW5OZ.js → chunk-DG2WU3BU.js} +2 -2
  64. package/dist/chunk-DIN3EFOM.js +14 -0
  65. package/dist/{chunk-WJ3XSJ6B.js → chunk-EBC4XFL2.js} +1 -1
  66. package/dist/{chunk-37JDUDCO.js → chunk-ECCUEG3J.js} +1 -1
  67. package/dist/{chunk-4C4SQ4YW.js → chunk-EM6BEHAD.js} +8 -8
  68. package/dist/{chunk-W5M6P4DZ.js → chunk-ETF7LAYZ.js} +5 -5
  69. package/dist/{chunk-LEC4SZIV.js → chunk-EVB35JP5.js} +1 -1
  70. package/dist/{chunk-FL2PUQX7.js → chunk-EW6FRPFJ.js} +1 -1
  71. package/dist/{chunk-JCMP5KMS.js → chunk-EZY4CO4A.js} +6 -6
  72. package/dist/chunk-F2AEP37B.js +4 -0
  73. package/dist/{chunk-PJCVNFWM.js → chunk-FKZEGBLK.js} +10 -10
  74. package/dist/{chunk-DTSCO7VM.js → chunk-FMKTVZAO.js} +1 -1
  75. package/dist/{chunk-IZCODCSC.js → chunk-FTKKGGOQ.js} +1 -1
  76. package/dist/{chunk-FFJVCLGH.js → chunk-G2MJTE6X.js} +11 -11
  77. package/dist/{chunk-3BPF6PP3.js → chunk-G2V2ADJQ.js} +2 -2
  78. package/dist/{chunk-EZGY6CFN.js → chunk-GK3QH63P.js} +1 -1
  79. package/dist/{chunk-3WC6ITJ3.js → chunk-H33Z4ZIY.js} +6 -6
  80. package/dist/{chunk-CPXHU3Y2.js → chunk-HAIMJAI4.js} +2 -2
  81. package/dist/chunk-HMHL27AU.js +6 -0
  82. package/dist/{chunk-RSO67DWS.js → chunk-I4VD5D43.js} +4 -4
  83. package/dist/{chunk-BIYL7CEI.js → chunk-IFDW5QW6.js} +2 -2
  84. package/dist/{chunk-4AAGZQX7.js → chunk-IHEEJO5S.js} +1 -1
  85. package/dist/{chunk-WQNIXV4T.js → chunk-IUCIYWTT.js} +8 -8
  86. package/dist/chunk-JBQWR4SX.js +8 -0
  87. package/dist/{chunk-AX7KPMDV.js → chunk-JDKRQG7X.js} +2 -2
  88. package/dist/chunk-JE6TBZGY.js +8 -0
  89. package/dist/{chunk-LBLV64XG.js → chunk-JUGPTBMS.js} +1 -1
  90. package/dist/{chunk-BUGAWNOC.js → chunk-JVIOAZHW.js} +4 -4
  91. package/dist/{chunk-B2XDNBR3.js → chunk-L3G3YHVN.js} +1 -1
  92. package/dist/{chunk-ZEKM6HAA.js → chunk-M2AIC7IK.js} +2 -2
  93. package/dist/{chunk-KDZUWQEG.js → chunk-M2KV4WKR.js} +1 -1
  94. package/dist/{chunk-H3BC4KDE.js → chunk-M2LLVSBR.js} +1 -1
  95. package/dist/{chunk-SAKHGHF5.js → chunk-MC43PRTL.js} +1 -1
  96. package/dist/{chunk-USYNZGY4.js → chunk-MICWRC72.js} +7 -7
  97. package/dist/{chunk-ZN3O2KJ7.js → chunk-MOD4PGVF.js} +10 -10
  98. package/dist/{chunk-WTY3SXO7.js → chunk-MY755PTJ.js} +1 -1
  99. package/dist/chunk-NKZNPYDB.js +3 -0
  100. package/dist/{chunk-YSFLXPUS.js → chunk-NUSSZJF2.js} +5 -5
  101. package/dist/{chunk-RGBX3EVC.js → chunk-O2YAB6WK.js} +8 -8
  102. package/dist/{chunk-3J5QUHPO.js → chunk-OFKWTOXK.js} +3 -3
  103. package/dist/{chunk-ZT5Y5JZB.js → chunk-P42YNSKI.js} +4 -4
  104. package/dist/{chunk-L3NYH4QV.js → chunk-PAB2ZU4F.js} +37 -37
  105. package/dist/{chunk-KKSW5IZ7.js → chunk-PCKYNZ5Y.js} +5 -5
  106. package/dist/{chunk-RUQEB2ZC.js → chunk-R4C3GGCS.js} +3 -3
  107. package/dist/{chunk-3V5Z2BJY.js → chunk-RB2F65YJ.js} +12 -12
  108. package/dist/{chunk-KNVE7CMS.js → chunk-RJZYORCR.js} +1 -1
  109. package/dist/{chunk-BZV4K6GR.js → chunk-RPJ2GC3K.js} +20 -20
  110. package/dist/{chunk-PBMZJXSZ.js → chunk-S4J4B7LY.js} +5 -5
  111. package/dist/{chunk-HVX37PKU.js → chunk-SEXLHFMR.js} +1 -1
  112. package/dist/{chunk-NWP6IJYK.js → chunk-TANR67XF.js} +2 -2
  113. package/dist/{chunk-4F3IKYUO.js → chunk-TOVHLONK.js} +6 -6
  114. package/dist/{chunk-JOIWDQRJ.js → chunk-TRD22FC7.js} +6 -6
  115. package/dist/{chunk-YGZMD6TZ.js → chunk-TTY62G5D.js} +16 -16
  116. package/dist/{chunk-B55IXYDR.js → chunk-TZHWF3P5.js} +2 -2
  117. package/dist/{chunk-IAQC775L.js → chunk-UZ3CZQA4.js} +1 -1
  118. package/dist/chunk-WAZTGEMG.js +1 -0
  119. package/dist/{chunk-V4KQUOUP.js → chunk-WKRFD4E4.js} +8 -8
  120. package/dist/{chunk-PDXD6DT7.js → chunk-WME5DFB6.js} +1 -1
  121. package/dist/{chunk-OSA24YH6.js → chunk-WSPO4N72.js} +14 -14
  122. package/dist/{chunk-3C67XRVJ.js → chunk-XB2YPUKR.js} +8 -8
  123. package/dist/{chunk-VB7Z3HXO.js → chunk-XDDTFV32.js} +1 -1
  124. package/dist/{chunk-XC55NMXR.js → chunk-XNJMLHGK.js} +1 -1
  125. package/dist/{chunk-UQBPKZUR.js → chunk-XZL3HCWH.js} +1 -1
  126. package/dist/{chunk-CRYEG7OT.js → chunk-YBB56N6X.js} +1 -1
  127. package/dist/{chunk-FRPNTDP4.js → chunk-ZNCU3UIW.js} +4 -4
  128. package/dist/{chunk-ZOSIPTXM.js → chunk-ZNXBKFV7.js} +5 -5
  129. package/dist/{chunk-RCMP37VO.js → chunk-ZRHQGFO5.js} +3 -3
  130. package/dist/{chunk-MEFXMUWI.js → chunk-ZXSMSVLU.js} +3 -3
  131. package/dist/data/ListLoadError.js +1 -1
  132. package/dist/format/index.js +1 -1
  133. package/dist/forms/BorderInput.js +1 -1
  134. package/dist/forms/BrandAssetEditor.js +1 -1
  135. package/dist/forms/Calendar.js +1 -1
  136. package/dist/forms/ColorPicker.js +1 -1
  137. package/dist/forms/ComposerAttachments.js +1 -1
  138. package/dist/forms/CornersInput.js +1 -1
  139. package/dist/forms/DatePicker.js +1 -1
  140. package/dist/forms/DateRangePicker.js +1 -1
  141. package/dist/forms/DisplayChips.js +1 -1
  142. package/dist/forms/FilePicker.js +1 -1
  143. package/dist/forms/IconPicker.js +1 -1
  144. package/dist/forms/InputNumber.js +1 -1
  145. package/dist/forms/LinkPicker.js +1 -1
  146. package/dist/forms/MediaLibrary.js +1 -1
  147. package/dist/forms/MediaUploadField.js +1 -1
  148. package/dist/forms/MediaUploadGrid.js +1 -1
  149. package/dist/forms/MediaUsedInList.js +1 -1
  150. package/dist/forms/PositionInput.js +1 -1
  151. package/dist/forms/Select.js +1 -1
  152. package/dist/forms/SidesInput.js +1 -1
  153. package/dist/forms/Slider.js +1 -1
  154. package/dist/forms/Snippet.js +1 -1
  155. package/dist/forms/SplitButton.js +1 -1
  156. package/dist/forms/TagInput.js +1 -1
  157. package/dist/forms/TextToolbar.js +1 -1
  158. package/dist/forms/WidthsBar.js +1 -1
  159. package/dist/forms/mediaLibraryMenu.js +1 -1
  160. package/dist/forms/textAlign.js +1 -1
  161. package/dist/icons/index.js +1 -1
  162. package/dist/index.js +136 -136
  163. package/dist/map/index.js +6 -6
  164. package/dist/markdown/index.js +1 -1
  165. package/dist/page-tabs/index.js +5 -5
  166. package/dist/pdf/index.js +1 -1
  167. package/dist/shell/Accordion.js +1 -1
  168. package/dist/shell/AppUpdateBanner.js +1 -1
  169. package/dist/shell/Banner.js +1 -1
  170. package/dist/shell/Breadcrumbs.js +1 -1
  171. package/dist/shell/ColoredBadge.js +1 -1
  172. package/dist/shell/ConfirmDialog.js +1 -1
  173. package/dist/shell/ContextMenu.js +1 -1
  174. package/dist/shell/Dialog.d.ts +2 -2
  175. package/dist/shell/Dialog.js +1 -1
  176. package/dist/shell/Drawer.d.ts +2 -2
  177. package/dist/shell/Drawer.js +1 -1
  178. package/dist/shell/DropdownMenu.js +1 -1
  179. package/dist/shell/EmptyState.js +1 -1
  180. package/dist/shell/HelpCenter.js +1 -1
  181. package/dist/shell/ImageLightbox.js +1 -1
  182. package/dist/shell/LanguageSelect.js +1 -1
  183. package/dist/shell/Markdown.js +1 -1
  184. package/dist/shell/PageHeader.js +1 -1
  185. package/dist/shell/PopupMenu.js +1 -1
  186. package/dist/shell/ProductionTimeline.js +1 -1
  187. package/dist/shell/Result.js +1 -1
  188. package/dist/shell/SearchableSelect.js +1 -1
  189. package/dist/shell/SettingReset.js +1 -1
  190. package/dist/shell/SettingRow.js +1 -1
  191. package/dist/shell/SidebarLayout.js +1 -1
  192. package/dist/shell/SidebarNav.js +1 -1
  193. package/dist/shell/SortableList.js +1 -1
  194. package/dist/shell/StepChain.js +1 -1
  195. package/dist/shell/Stepper.js +1 -1
  196. package/dist/shell/TopNav.js +1 -1
  197. package/dist/shell/Tree.js +1 -1
  198. package/dist/telemetry/index.js +1 -1
  199. package/dist/templates/AuthScreen.js +1 -1
  200. package/dist/templates/ChatTemplate.js +1 -1
  201. package/dist/templates/CheckoutTemplate.js +1 -1
  202. package/dist/templates/DashboardTemplate.js +1 -1
  203. package/dist/templates/DataTablePage.js +1 -1
  204. package/dist/templates/EmailTemplate.js +1 -1
  205. package/dist/templates/FormLayoutPage.js +1 -1
  206. package/dist/ui/index.js +1 -1
  207. package/dist/version.js +1 -1
  208. package/package.json +1 -1
  209. package/dist/Calculator-4JDJKSA7.js +0 -29
  210. package/dist/CurrencyConverter-S7LG5PMX.js +0 -21
  211. package/dist/Notepad-VQ66RWLT.js +0 -25
  212. package/dist/PdfViewer-67VBUIRD.js +0 -1
  213. package/dist/Sidebar-YB4OVUG5.js +0 -43
  214. package/dist/Spreadsheet-4KXRJSHT.js +0 -37
  215. package/dist/Stock-VNFYS73L.js +0 -16
  216. package/dist/chunk-3JJFBUK6.js +0 -3
  217. package/dist/chunk-57SJKYA4.js +0 -29
  218. package/dist/chunk-AS4CTEZD.js +0 -8
  219. package/dist/chunk-HSOREHQB.js +0 -1
  220. package/dist/chunk-JJXFPGX4.js +0 -6
  221. package/dist/chunk-LYYR5DSP.js +0 -14
  222. package/dist/chunk-RERNKFEW.js +0 -19
  223. package/dist/chunk-W7S56JZ7.js +0 -7
  224. package/dist/chunk-YCQVEJOT.js +0 -3
  225. package/dist/chunk-YW2DH6YQ.js +0 -8
@@ -1,4 +1,4 @@
1
- import{fetchCityWeather as e,getCondition as t,AVAILABLE_CITIES as a,toFahrenheit as r}from"./chunk-FBDZGO3V.js";import{loadAppearance as n,WidgetSettingsModal as i}from"./chunk-KNVE7CMS.js";import{useWidgetSettings as s}from"./chunk-L3NYH4QV.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-HVX37PKU.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-FL2PUQX7.js";import"./chunk-ZN3O2KJ7.js";import"./chunk-YCQVEJOT.js";import{useShellPrefs as o}from"./chunk-KC3EX26K.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-UGTRSRIW.js";import"./chunk-XWLWG4HS.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import"./chunk-PJCVNFWM.js";import"./chunk-QR4RM7PO.js";import"./chunk-5QFPTDQF.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import"./chunk-VH6GB73Q.js";import"./chunk-KIBL6M3T.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as l}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-E6UCGCOC.js";import"./chunk-C3QOHMR6.js";import{useState as c,useEffect as d,useCallback as m}from"react";import{jsx as h,jsxs as p,Fragment as u}from"react/jsx-runtime";var f="weather_city",y="weather_appearance",g={useFahrenheit:!1,showLocalTime:!0,use24Hour:!1};function x(){const e="undefined"!=typeof localStorage?localStorage.getItem(f):null;if(e&&a[e])return e;try{const e=JSON.parse(localStorage.getItem("weather_cities")||"");if(Array.isArray(e)&&e[0]&&a[e[0]])return localStorage.setItem(f,e[0]),e[0]}catch{}return function(){try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;for(const[t,r]of Object.entries(a))if(r.tz===e)return t}catch{}return"London"}()}var b=r;function w(e,t=!1){try{if(t){const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!1}).formatToParts(/* @__PURE__ */new Date),a=parseInt(t.find(e=>"hour"===e.type)?.value||"0"),r=parseInt(t.find(e=>"minute"===e.type)?.value||"0");return`${String(a).padStart(2,"0")}:${String(r).padStart(2,"0")}`}const a=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(/* @__PURE__ */new Date),r=parseInt(a.find(e=>"hour"===e.type)?.value||"12"),n=parseInt(a.find(e=>"minute"===e.type)?.value||"0"),i=a.find(e=>"dayPeriod"===e.type)?.value||"";return`${r}:${String(n).padStart(2,"0")} ${i}`}catch{return""}}function v(){/* @__PURE__ */
1
+ import{fetchCityWeather as e,getCondition as t,AVAILABLE_CITIES as a,toFahrenheit as r}from"./chunk-FBDZGO3V.js";import{loadAppearance as n,WidgetSettingsModal as i}from"./chunk-RJZYORCR.js";import{useWidgetSettings as s}from"./chunk-PAB2ZU4F.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SEXLHFMR.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-EW6FRPFJ.js";import"./chunk-MOD4PGVF.js";import"./chunk-F2AEP37B.js";import"./chunk-4AJRHTTB.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-4GVH4ZUH.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import{useShellPrefs as o}from"./chunk-KC3EX26K.js";import"./chunk-FKZEGBLK.js";import"./chunk-5QFPTDQF.js";import"./chunk-QR4RM7PO.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import"./chunk-2SHYR3RA.js";import"./chunk-J75ZT2JQ.js";import"./chunk-VH6GB73Q.js";import{LoadingSpinner as l}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-E6UCGCOC.js";import"./chunk-C3QOHMR6.js";import{useState as c,useEffect as d,useCallback as m}from"react";import{jsx as h,jsxs as p,Fragment as u}from"react/jsx-runtime";var f="weather_city",y="weather_appearance",g={useFahrenheit:!1,showLocalTime:!0,use24Hour:!1};function x(){const e="undefined"!=typeof localStorage?localStorage.getItem(f):null;if(e&&a[e])return e;try{const e=JSON.parse(localStorage.getItem("weather_cities")||"");if(Array.isArray(e)&&e[0]&&a[e[0]])return localStorage.setItem(f,e[0]),e[0]}catch{}return function(){try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone;for(const[t,r]of Object.entries(a))if(r.tz===e)return t}catch{}return"London"}()}var b=r;function w(e,t=!1){try{if(t){const t=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!1}).formatToParts(/* @__PURE__ */new Date),a=parseInt(t.find(e=>"hour"===e.type)?.value||"0"),r=parseInt(t.find(e=>"minute"===e.type)?.value||"0");return`${String(a).padStart(2,"0")}:${String(r).padStart(2,"0")}`}const a=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(/* @__PURE__ */new Date),r=parseInt(a.find(e=>"hour"===e.type)?.value||"12"),n=parseInt(a.find(e=>"minute"===e.type)?.value||"0"),i=a.find(e=>"dayPeriod"===e.type)?.value||"";return`${r}:${String(n).padStart(2,"0")} ${i}`}catch{return""}}function v(){/* @__PURE__ */
2
2
  return p("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[
3
3
  /* @__PURE__ */h("div",{className:"absolute -top-5 -right-5 w-24 h-24",style:{animation:"wx-sun-rays 70s linear infinite"},children:/* @__PURE__ */h("svg",{viewBox:"0 0 100 100",className:"w-full h-full",children:Array.from({length:12}).map((e,t)=>/* @__PURE__ */h("rect",{x:49,y:3,width:2,height:14,rx:1,fill:"rgba(255, 232, 130, 0.55)",transform:`rotate(${30*t} 50 50)`},t))})}),
4
4
  /* @__PURE__ */h("div",{className:"absolute top-1 right-1 w-10 h-10 rounded-full",style:{background:"radial-gradient(circle at 35% 35%, #fff8cc 0%, #ffd84a 55%, #ff9e2a 100%)",boxShadow:"0 0 18px 5px rgba(255, 200, 80, 0.55)",animation:"wx-sun-pulse 4.5s ease-in-out infinite"}})]})}function k(){const e=Array.from({length:16}).map((e,t)=>({left:(53*t+11)%95+"%",top:(37*t+9)%78+"%",size:1+13*t%3,delay:.41*t%4+"s",duration:2.5+7*t%5*.6+"s"}));/* @__PURE__ */
@@ -19,42 +19,42 @@ return p("div",{className:"absolute inset-0 overflow-hidden pointer-events-none"
19
19
  /* @__PURE__ */h("div",{className:"absolute",style:{top:"40%",animation:"wx-drift-cloud 60s linear -22s infinite",opacity:.85},children:/* @__PURE__ */h(a,{scale:1.25})}),
20
20
  /* @__PURE__ */h("div",{className:"absolute",style:{top:"68%",animation:"wx-drift-cloud 78s linear -45s infinite",opacity:.7},children:/* @__PURE__ */h(a,{scale:.75})})]})}function j({heavy:e=!1}){const t=e?26:16,a=["wx-rain-a","wx-rain-b","wx-rain-c"],r=Array.from({length:t}).map((e,r)=>({left:(100*r/t+11*r%7)%100+"%",delay:.087*r%1.3+"s",height:12+r%4*5+"px",duration:.7+r%3*.18+"s",variant:a[r%a.length]}));/* @__PURE__ */
21
21
  return h("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:r.map((e,t)=>/* @__PURE__ */h("div",{className:"absolute",style:{left:e.left,top:"-20px",width:"1px",height:e.height,background:"linear-gradient(180deg, rgba(180,210,255,0) 0%, rgba(220,235,255,0.85) 90%, rgba(255,255,255,0.95) 100%)",transform:"rotate(8deg)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`,transformOrigin:"top"}},t))})}function S(){const e=["wx-snow-a","wx-snow-b","wx-snow-c"],t=Array.from({length:16}).map((t,a)=>({left:(100*a/16+13*a%5)%100+"%",delay:.43*a%5+"s",duration:4.5+a%5+"s",size:3+a%4*1.4,opacity:.65+7*a%4*.08,variant:e[a%e.length]}));/* @__PURE__ */
22
- return h("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:t.map((e,t)=>/* @__PURE__ */h("div",{className:"absolute rounded-full bg-white",style:{left:e.left,top:"-12px",width:e.size,height:e.size,opacity:e.opacity,boxShadow:"0 0 4px rgba(255,255,255,0.65)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`}},t))})}function C(){/* @__PURE__ */
22
+ return h("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:t.map((e,t)=>/* @__PURE__ */h("div",{className:"absolute rounded-full bg-white",style:{left:e.left,top:"-12px",width:e.size,height:e.size,opacity:e.opacity,boxShadow:"0 0 4px rgba(255,255,255,0.65)",animation:`${e.variant} ${e.duration} linear ${e.delay} infinite`}},t))})}function F(){/* @__PURE__ */
23
23
  return p("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[
24
24
  /* @__PURE__ */h(j,{heavy:!0}),
25
25
  /* @__PURE__ */h("div",{className:"absolute inset-0 bg-white",style:{animation:"wx-flash 6s ease-out infinite"}}),
26
- /* @__PURE__ */h("div",{className:"absolute inset-y-0 right-1/3 flex items-center justify-center pointer-events-none",style:{animation:"wx-bolt 6s ease-out infinite"},children:/* @__PURE__ */h("svg",{viewBox:"0 0 18 60",className:"h-4/5",style:{filter:"drop-shadow(0 0 6px rgba(255, 240, 150, 0.95)) drop-shadow(0 0 14px rgba(255, 220, 90, 0.7))"},children:/* @__PURE__ */h("path",{d:"M11 0 L2 28 L8 30 L4 60 L16 24 L9 22 Z",fill:"rgba(255, 250, 200, 0.98)",stroke:"rgba(255, 255, 255, 0.9)",strokeWidth:.3})})})]})}function L(){/* @__PURE__ */
27
- return h("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:Array.from({length:4}).map((e,t)=>/* @__PURE__ */h("div",{className:"absolute left-0 right-0",style:{top:10+22*t+"%",height:"14px",background:"linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%)",filter:"blur(2px)",animation:`wx-fog-drift ${10+3*t}s ease-in-out ${.7*t}s infinite alternate`}},t))})}function T({code:e,isDay:t}){return 0===e||1===e?/* @__PURE__ */h(t?v:k,{}):2===e?/* @__PURE__ */p(u,{children:[/* @__PURE__ */h(t?v:k,{}),
28
- /* @__PURE__ */h(N,{tone:t?"light":"dark"})]}):3===e?/* @__PURE__ */h(N,{tone:t?"light":"dark"}):45===e||48===e?/* @__PURE__ */h(L,{}):[51,53,61,80,81].includes(e)?/* @__PURE__ */h(j,{}):[55,63,65,82].includes(e)?/* @__PURE__ */h(j,{heavy:!0}):[71,73,75].includes(e)?/* @__PURE__ */h(S,{}):[95,96,99].includes(e)?/* @__PURE__ */h(C,{}):null}function $(){const[r,v]=c(x),[k,N]=c(()=>n(y)),[j,S]=c(null),[C,L]=c(!0),[,$]=c(0);d(()=>{const e=setInterval(()=>$(e=>e+1),6e4);return()=>clearInterval(e)},[]);const[D,F]=c(!1),[I,O]=c(r),[W,A]=c(k),{prefs:H,save:J}=o(),K={...g,...H.weather_prefs??{}},[U,V]=c(K);s(m(()=>{O(r),A({...k}),V({...K}),F(!0)},[r,k,K])),d(()=>{let t=!1;return L(!0),e(r).then(e=>{t||(S(e),L(!1))}),()=>{t=!0}},[r]);const B=e=>K.useFahrenheit?`${b(e)}°F`:`${e}°`;if(C&&!j)/* @__PURE__ */
26
+ /* @__PURE__ */h("div",{className:"absolute inset-y-0 right-1/3 flex items-center justify-center pointer-events-none",style:{animation:"wx-bolt 6s ease-out infinite"},children:/* @__PURE__ */h("svg",{viewBox:"0 0 18 60",className:"h-4/5",style:{filter:"drop-shadow(0 0 6px rgba(255, 240, 150, 0.95)) drop-shadow(0 0 14px rgba(255, 220, 90, 0.7))"},children:/* @__PURE__ */h("path",{d:"M11 0 L2 28 L8 30 L4 60 L16 24 L9 22 Z",fill:"rgba(255, 250, 200, 0.98)",stroke:"rgba(255, 255, 255, 0.9)",strokeWidth:.3})})})]})}function T(){/* @__PURE__ */
27
+ return h("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:Array.from({length:4}).map((e,t)=>/* @__PURE__ */h("div",{className:"absolute left-0 right-0",style:{top:10+22*t+"%",height:"14px",background:"linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.55) 50%, rgba(255,255,255,0) 100%)",filter:"blur(2px)",animation:`wx-fog-drift ${10+3*t}s ease-in-out ${.7*t}s infinite alternate`}},t))})}function C({code:e,isDay:t}){return 0===e||1===e?/* @__PURE__ */h(t?v:k,{}):2===e?/* @__PURE__ */p(u,{children:[/* @__PURE__ */h(t?v:k,{}),
28
+ /* @__PURE__ */h(N,{tone:t?"light":"dark"})]}):3===e?/* @__PURE__ */h(N,{tone:t?"light":"dark"}):45===e||48===e?/* @__PURE__ */h(T,{}):[51,53,61,80,81].includes(e)?/* @__PURE__ */h(j,{}):[55,63,65,82].includes(e)?/* @__PURE__ */h(j,{heavy:!0}):[71,73,75].includes(e)?/* @__PURE__ */h(S,{}):[95,96,99].includes(e)?/* @__PURE__ */h(F,{}):null}function D(){const[r,v]=c(x),[k,N]=c(()=>n(y)),[j,S]=c(null),[F,T]=c(!0),[,D]=c(0);d(()=>{const e=setInterval(()=>D(e=>e+1),6e4);return()=>clearInterval(e)},[]);const[$,L]=c(!1),[R,A]=c(r),[H,I]=c(k),{prefs:B,save:O}=o(),G={...g,...B.weather_prefs??{}},[J,U]=c(G);s(m(()=>{A(r),I({...k}),U({...G}),L(!0)},[r,k,G])),d(()=>{let t=!1;return T(!0),e(r).then(e=>{t||(S(e),T(!1))}),()=>{t=!0}},[r]);const W=e=>G.useFahrenheit?`${b(e)}°F`:`${e}°`;if(F&&!j)/* @__PURE__ */
29
29
  return h("div",{className:"flex items-center justify-center h-full bg-gradient-to-b from-sky-400 to-blue-500 rounded-lg text-white/80 text-xs",style:{minHeight:110},children:/* @__PURE__ */h(l,{size:"sm",padding:"",label:"Loading"})});if(!j)/* @__PURE__ */
30
- return h("div",{className:"flex items-center justify-center h-full bg-slate-700 rounded-lg text-white/80 text-xs",style:{minHeight:110},children:"Couldn't load weather"});const[G,M,Q]=t(j.code,j.isDay);/* @__PURE__ */
30
+ return h("div",{className:"flex items-center justify-center h-full bg-slate-700 rounded-lg text-white/80 text-xs",style:{minHeight:110},children:"Couldn't load weather"});const[K,M,P]=t(j.code,j.isDay);/* @__PURE__ */
31
31
  return p(u,{children:[
32
32
  /* @__PURE__ */h("style",{children:"\n@keyframes wx-rain-a { 0% { transform: translate(0,-20px); opacity: 0; } 10% { opacity: 0.95; } 100% { transform: translate(8px,140px); opacity: 0; } }\n@keyframes wx-rain-b { 0% { transform: translate(0,-20px); opacity: 0; } 12% { opacity: 0.85; } 100% { transform: translate(12px,140px); opacity: 0; } }\n@keyframes wx-rain-c { 0% { transform: translate(0,-20px); opacity: 0; } 10% { opacity: 1; } 100% { transform: translate(5px,140px); opacity: 0; } }\n@keyframes wx-snow-a { 0% { transform: translate(0,-12px) rotate(0deg); opacity: 0; } 10% { opacity: 0.9; } 50% { transform: translate(10px,55px) rotate(180deg); } 100% { transform: translate(-4px,140px) rotate(360deg); opacity: 0; } }\n@keyframes wx-snow-b { 0% { transform: translate(0,-12px) rotate(0deg); opacity: 0; } 10% { opacity: 0.85; } 50% { transform: translate(-12px,55px) rotate(-180deg); } 100% { transform: translate(6px,140px) rotate(-360deg); opacity: 0; } }\n@keyframes wx-snow-c { 0% { transform: translate(0,-12px); opacity: 0; } 10% { opacity: 0.7; } 100% { transform: translate(2px,140px); opacity: 0; } }\n@keyframes wx-drift-cloud { 0% { transform: translateX(-40%); } 100% { transform: translateX(140%); } }\n@keyframes wx-twinkle { 0%, 100% { opacity: 0.25; transform: scale(1); } 50% { opacity: 1; transform: scale(1.6); } }\n@keyframes wx-flash { 0%, 86%, 100% { opacity: 0; } 87% { opacity: 0.95; } 88% { opacity: 0.15; } 89% { opacity: 0.85; } 90% { opacity: 0; } }\n@keyframes wx-bolt { 0%, 86%, 90%, 100% { opacity: 0; } 87% { opacity: 1; } 89% { opacity: 0.85; } }\n@keyframes wx-sun-pulse { 0%, 100% { transform: scale(1); opacity: 0.65; } 50% { transform: scale(1.12); opacity: 0.95; } }\n@keyframes wx-sun-rays { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }\n@keyframes wx-fog-drift { 0% { transform: translateX(-25%); opacity: 0.3; } 50% { opacity: 0.65; } 100% { transform: translateX(25%); opacity: 0.3; } }\n@keyframes wx-shooting-star { 0%, 95% { opacity: 0; transform: translate(0,0) scale(0); } 96% { opacity: 1; transform: translate(0,0) scale(1); } 100% { opacity: 0; transform: translate(40px,30px) scale(1); } }\n"}),
33
- /* @__PURE__ */h("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:`rgba(15, 23, 42, ${k.activeOpacity/100})`,backdropFilter:k.activeBlur>0?`blur(${k.activeBlur}px)`:void 0},children:/* @__PURE__ */p("div",{className:`relative rounded-lg overflow-hidden text-white bg-gradient-to-br ${Q}`,style:{height:110},children:[
34
- /* @__PURE__ */h(T,{code:j.code,isDay:j.isDay}),
33
+ /* @__PURE__ */h("div",{className:"rounded-lg overflow-hidden",style:{backgroundColor:`rgba(15, 23, 42, ${k.activeOpacity/100})`,backdropFilter:k.activeBlur>0?`blur(${k.activeBlur}px)`:void 0},children:/* @__PURE__ */p("div",{className:`relative rounded-lg overflow-hidden text-white bg-gradient-to-br ${P}`,style:{height:110},children:[
34
+ /* @__PURE__ */h(C,{code:j.code,isDay:j.isDay}),
35
35
  /* @__PURE__ */p("div",{className:"relative z-10 px-3 py-3 flex flex-col h-full justify-between",children:[
36
36
  /* @__PURE__ */p("div",{className:"flex items-start justify-between gap-2",children:[
37
37
  /* @__PURE__ */p("div",{className:"min-w-0 flex-1",children:[
38
- /* @__PURE__ */h("div",{className:"text-base font-semibold leading-tight truncate drop-shadow-sm",children:j.city}),K.showLocalTime&&/* @__PURE__ */h("div",{className:"text-2xs opacity-90 leading-tight tabular-nums drop-shadow-sm",children:w(j.timezone,K.use24Hour)})]}),
39
- /* @__PURE__ */h("div",{className:"text-3xl font-extralight leading-none tracking-tight tabular-nums shrink-0 drop-shadow-sm",children:B(j.temp)})]}),
38
+ /* @__PURE__ */h("div",{className:"text-base font-semibold leading-tight truncate drop-shadow-sm",children:j.city}),G.showLocalTime&&/* @__PURE__ */h("div",{className:"text-2xs opacity-90 leading-tight tabular-nums drop-shadow-sm",children:w(j.timezone,G.use24Hour)})]}),
39
+ /* @__PURE__ */h("div",{className:"text-3xl font-extralight leading-none tracking-tight tabular-nums shrink-0 drop-shadow-sm",children:W(j.temp)})]}),
40
40
  /* @__PURE__ */p("div",{className:"flex items-end justify-between gap-2",children:[
41
41
  /* @__PURE__ */p("div",{className:"flex items-center gap-2 min-w-0",children:[
42
42
  /* @__PURE__ */h("span",{className:"text-lg leading-none drop-shadow-sm",children:M}),
43
- /* @__PURE__ */h("span",{className:"text-2xs font-medium drop-shadow-sm truncate",children:G})]}),
44
- /* @__PURE__ */p("span",{className:"text-2xs opacity-90 tabular-nums drop-shadow-sm shrink-0",children:["H:",B(j.high)," L:",B(j.low)]})]})]})]})}),
45
- /* @__PURE__ */p(i,{open:D,onClose:()=>F(!1),title:"Weather Settings",appearance:W,onAppearanceChange:A,onSave:()=>{v(I),N(W),J({weather_prefs:U}),localStorage.setItem(f,I),localStorage.setItem(y,JSON.stringify(W)),F(!1)},children:[
43
+ /* @__PURE__ */h("span",{className:"text-2xs font-medium drop-shadow-sm truncate",children:K})]}),
44
+ /* @__PURE__ */p("span",{className:"text-2xs opacity-90 tabular-nums drop-shadow-sm shrink-0",children:["H:",W(j.high)," L:",W(j.low)]})]})]})]})}),
45
+ /* @__PURE__ */p(i,{open:$,onClose:()=>L(!1),title:"Weather Settings",appearance:H,onAppearanceChange:I,onSave:()=>{v(R),N(H),O({weather_prefs:J}),localStorage.setItem(f,R),localStorage.setItem(y,JSON.stringify(H)),L(!1)},children:[
46
46
  /* @__PURE__ */h("div",{className:"space-y-3",children:/* @__PURE__ */p("div",{children:[
47
47
  /* @__PURE__ */h("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Display"}),
48
48
  /* @__PURE__ */p("div",{className:"flex items-center gap-3 mb-2",children:[
49
49
  /* @__PURE__ */h("span",{className:"text-sm text-gray-600 w-24",children:"Temperature"}),
50
- /* @__PURE__ */h("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */h("button",{onClick:()=>V(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(U.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
50
+ /* @__PURE__ */h("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */h("button",{onClick:()=>U(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(J.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
51
51
  /* @__PURE__ */p("div",{className:"flex items-center gap-3 mb-2",children:[
52
52
  /* @__PURE__ */h("span",{className:"text-sm text-gray-600 w-24",children:"Time Format"}),
53
- /* @__PURE__ */h("div",{className:"flex gap-1",children:[{key:!1,label:"AM/PM"},{key:!0,label:"24H"}].map(e=>/* @__PURE__ */h("button",{onClick:()=>V(t=>({...t,use24Hour:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(U.use24Hour===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
53
+ /* @__PURE__ */h("div",{className:"flex gap-1",children:[{key:!1,label:"AM/PM"},{key:!0,label:"24H"}].map(e=>/* @__PURE__ */h("button",{onClick:()=>U(t=>({...t,use24Hour:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(J.use24Hour===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
54
54
  /* @__PURE__ */p("label",{className:"flex items-center gap-2 cursor-pointer",children:[
55
- /* @__PURE__ */h("input",{type:"checkbox",checked:U.showLocalTime,onChange:e=>V(t=>({...t,showLocalTime:e.target.checked})),className:"rounded border-gray-300 text-blue-600 h-3.5 w-3.5"}),
55
+ /* @__PURE__ */h("input",{type:"checkbox",checked:J.showLocalTime,onChange:e=>U(t=>({...t,showLocalTime:e.target.checked})),className:"rounded border-gray-300 text-blue-600 h-3.5 w-3.5"}),
56
56
  /* @__PURE__ */h("span",{className:"text-sm text-gray-600",children:"Show local time"})]})]})}),
57
57
  /* @__PURE__ */p("div",{children:[
58
58
  /* @__PURE__ */h("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"City"}),
59
- /* @__PURE__ */h("select",{value:I,onChange:e=>O(e.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded px-2 h-8 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:Object.keys(a).map(e=>/* @__PURE__ */h("option",{value:e,children:e},e))}),
60
- /* @__PURE__ */h("p",{className:"mt-1 text-2xs text-gray-400",children:"Auto-detected from your timezone; change if needed."})]})]})]})}export{$ as default};
59
+ /* @__PURE__ */h("select",{value:R,onChange:e=>A(e.target.value),className:"w-full bg-gray-50 border border-gray-200 rounded px-2 h-8 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500",children:Object.keys(a).map(e=>/* @__PURE__ */h("option",{value:e,children:e},e))}),
60
+ /* @__PURE__ */h("p",{className:"mt-1 text-2xs text-gray-400",children:"Auto-detected from your timezone; change if needed."})]})]})]})}export{D as default};
@@ -1,6 +1,6 @@
1
- import{AVAILABLE_CITIES as e,fetchCityWeather as t,getCondition as r,toFahrenheit as n}from"./chunk-FBDZGO3V.js";import{loadAppearance as a,WidgetSettingsModal as s}from"./chunk-KNVE7CMS.js";import{useWidgetSettings as i}from"./chunk-L3NYH4QV.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-HVX37PKU.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-FL2PUQX7.js";import"./chunk-ZN3O2KJ7.js";import"./chunk-YCQVEJOT.js";import{useShellPrefs as c}from"./chunk-KC3EX26K.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-UGTRSRIW.js";import"./chunk-XWLWG4HS.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import"./chunk-PJCVNFWM.js";import"./chunk-QR4RM7PO.js";import"./chunk-5QFPTDQF.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import"./chunk-VH6GB73Q.js";import"./chunk-KIBL6M3T.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as o}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-E6UCGCOC.js";import"./chunk-C3QOHMR6.js";import{useState as l,useEffect as m,useCallback as h}from"react";import{jsxs as p,Fragment as u,jsx as d}from"react/jsx-runtime";var k="world_clock_appearance",g=["London","Shanghai","New York"];function x(){const{prefs:x,save:y}=c(),[b,j]=l(()=>a(k)),[f,N]=l(!1),[v,w]=l([]),[C,F]=l(b),D={useFahrenheit:!!x.weather_prefs?.useFahrenheit},[T,W]=l(D),[L,U]=l(()=>/* @__PURE__ */new Date);m(()=>{const e=setInterval(()=>U(/* @__PURE__ */new Date),3e4);return()=>clearInterval(e)},[]);const J=Object.fromEntries(Object.entries(e).map(([e,t])=>[t.tz,e])),K=x.world_clocks,O=(()=>{if(!Array.isArray(K)||0===K.length)return g;const t=[];for(const r of K){const n=e[r]?r:J[r];n&&!t.includes(n)&&t.push(n)}return t.length?t:g})(),[S,V]=l({}),[Q,G]=l(!0);m(()=>{let e=!1;return G(!0),(async()=>{const r={};await Promise.all(O.map(async e=>{const n=await t(e);n&&(r[e]=n)})),e||(V(r),G(!1))})(),()=>{e=!0}},[O.join(",")]),i(h(()=>{w([...O]),F({...b}),W({...D}),N(!0)},[O.join(","),b,D.useFahrenheit]));const R=e=>D.useFahrenheit?`${n(e)}°`:`${e}°`;/* @__PURE__ */
1
+ import{AVAILABLE_CITIES as e,fetchCityWeather as t,getCondition as r,toFahrenheit as n}from"./chunk-FBDZGO3V.js";import{loadAppearance as a,WidgetSettingsModal as s}from"./chunk-RJZYORCR.js";import{useWidgetSettings as i}from"./chunk-PAB2ZU4F.js";import"./chunk-CY5N5OA3.js";import"./chunk-AW7TOB6N.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-SEXLHFMR.js";import"./chunk-5A7MWTXX.js";import"./chunk-Y53KNQKL.js";import"./chunk-EW6FRPFJ.js";import"./chunk-MOD4PGVF.js";import"./chunk-F2AEP37B.js";import"./chunk-4AJRHTTB.js";import"./chunk-VWGWZY7A.js";import"./chunk-PKXQDCNR.js";import"./chunk-4GVH4ZUH.js";import"./chunk-UGTRSRIW.js";import"./chunk-CDAJKLGL.js";import"./chunk-D323R2FT.js";import{useShellPrefs as c}from"./chunk-KC3EX26K.js";import"./chunk-FKZEGBLK.js";import"./chunk-5QFPTDQF.js";import"./chunk-QR4RM7PO.js";import"./chunk-4IU5BSVE.js";import"./chunk-K7U4RWXJ.js";import"./chunk-2SHYR3RA.js";import"./chunk-J75ZT2JQ.js";import"./chunk-VH6GB73Q.js";import{LoadingSpinner as o}from"./chunk-Q5MD3VY6.js";import"./chunk-MRJKZWWV.js";import"./chunk-6KO5VTL7.js";import"./chunk-22S6LG6D.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-GLUJS42B.js";import"./chunk-D65T4H6J.js";import"./chunk-DTJRIWFR.js";import"./chunk-TWVUQUUD.js";import"./chunk-E6UCGCOC.js";import"./chunk-C3QOHMR6.js";import{useState as l,useEffect as m,useCallback as h}from"react";import{jsxs as p,Fragment as u,jsx as d}from"react/jsx-runtime";var k="world_clock_appearance",g=["London","Shanghai","New York"];function x(){const{prefs:x,save:y}=c(),[b,j]=l(()=>a(k)),[f,N]=l(!1),[v,w]=l([]),[F,C]=l(b),R={useFahrenheit:!!x.weather_prefs?.useFahrenheit},[D,T]=l(R),[U,G]=l(()=>/* @__PURE__ */new Date);m(()=>{const e=setInterval(()=>G(/* @__PURE__ */new Date),3e4);return()=>clearInterval(e)},[]);const J=Object.fromEntries(Object.entries(e).map(([e,t])=>[t.tz,e])),O=x.world_clocks,S=(()=>{if(!Array.isArray(O)||0===O.length)return g;const t=[];for(const r of O){const n=e[r]?r:J[r];n&&!t.includes(n)&&t.push(n)}return t.length?t:g})(),[W,L]=l({}),[A,B]=l(!0);m(()=>{let e=!1;return B(!0),(async()=>{const r={};await Promise.all(S.map(async e=>{const n=await t(e);n&&(r[e]=n)})),e||(L(r),B(!1))})(),()=>{e=!0}},[S.join(",")]),i(h(()=>{w([...S]),C({...b}),T({...R}),N(!0)},[S.join(","),b,R.useFahrenheit]));const K=e=>R.useFahrenheit?`${n(e)}°`:`${e}°`;/* @__PURE__ */
2
2
  return p(u,{children:[
3
- /* @__PURE__ */d("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${b.activeOpacity/100})`,backdropFilter:b.activeBlur>0?`blur(${b.activeBlur}px)`:void 0},children:/* @__PURE__ */p("div",{className:"divide-y divide-gray-200",children:[Q&&O.every(e=>!S[e])&&/* @__PURE__ */d(o,{size:"sm",padding:"py-6",label:"Loading"}),O.map(t=>{const n=S[t],a=e[t]?.tz??"UTC",{time:s,ampm:i}=function(e,t){try{const r=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(t),n=r.find(e=>"hour"===e.type)?.value||"12";return{time:`${n}:${r.find(e=>"minute"===e.type)?.value||"00"}`,ampm:(r.find(e=>"dayPeriod"===e.type)?.value||"").toUpperCase()}}catch{return{time:"",ampm:""}}}(a,L);if(!n)/* @__PURE__ */
3
+ /* @__PURE__ */d("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${b.activeOpacity/100})`,backdropFilter:b.activeBlur>0?`blur(${b.activeBlur}px)`:void 0},children:/* @__PURE__ */p("div",{className:"divide-y divide-gray-200",children:[A&&S.every(e=>!W[e])&&/* @__PURE__ */d(o,{size:"sm",padding:"py-6",label:"Loading"}),S.map(t=>{const n=W[t],a=e[t]?.tz??"UTC",{time:s,ampm:i}=function(e,t){try{const r=new Intl.DateTimeFormat("en-US",{timeZone:e,hour:"numeric",minute:"2-digit",hour12:!0}).formatToParts(t),n=r.find(e=>"hour"===e.type)?.value||"12";return{time:`${n}:${r.find(e=>"minute"===e.type)?.value||"00"}`,ampm:(r.find(e=>"dayPeriod"===e.type)?.value||"").toUpperCase()}}catch{return{time:"",ampm:""}}}(a,U);if(!n)/* @__PURE__ */
4
4
  return p("div",{className:"px-4 py-3",children:[
5
5
  /* @__PURE__ */p("div",{className:"flex items-baseline justify-between gap-2",children:[
6
6
  /* @__PURE__ */d("span",{className:"text-base font-semibold tracking-tight text-gray-900 truncate",children:t}),
@@ -10,7 +10,7 @@ return p("div",{className:"px-4 py-3",children:[
10
10
  return p("div",{className:"px-4 py-3",children:[
11
11
  /* @__PURE__ */p("div",{className:"flex items-baseline justify-between gap-2",children:[
12
12
  /* @__PURE__ */d("span",{className:"text-base font-semibold tracking-tight text-gray-900 truncate",children:t}),
13
- /* @__PURE__ */d("span",{className:"text-2xl font-extralight leading-none tabular-nums tracking-tight text-gray-900 shrink-0",children:R(n.temp)})]}),
13
+ /* @__PURE__ */d("span",{className:"text-2xl font-extralight leading-none tabular-nums tracking-tight text-gray-900 shrink-0",children:K(n.temp)})]}),
14
14
  /* @__PURE__ */p("div",{className:"flex items-center justify-between gap-2 mt-2 text-2xs",children:[
15
15
  /* @__PURE__ */p("div",{className:"flex items-center gap-2 min-w-0 text-gray-500",children:[
16
16
  /* @__PURE__ */d("span",{className:"text-base leading-none shrink-0",children:l}),
@@ -18,13 +18,13 @@ return p("div",{className:"px-4 py-3",children:[
18
18
  /* @__PURE__ */d("span",{className:"text-3xs font-medium ml-0.5 opacity-70",children:i})]}),
19
19
  /* @__PURE__ */d("span",{className:"text-gray-300 shrink-0",children:"·"}),
20
20
  /* @__PURE__ */d("span",{className:"truncate",children:c})]}),
21
- /* @__PURE__ */p("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",R(n.high)," L:",R(n.low)]})]})]},t)})]})}),
22
- /* @__PURE__ */p(s,{open:f,onClose:()=>N(!1),title:"World Clock Settings",appearance:C,onAppearanceChange:F,onSave:()=>{0!==v.length&&(y({world_clocks:v,weather_prefs:{...x.weather_prefs??{},useFahrenheit:T.useFahrenheit}}),j(C),localStorage.setItem(k,JSON.stringify(C)),N(!1))},children:[
21
+ /* @__PURE__ */p("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",K(n.high)," L:",K(n.low)]})]})]},t)})]})}),
22
+ /* @__PURE__ */p(s,{open:f,onClose:()=>N(!1),title:"World Clock Settings",appearance:F,onAppearanceChange:C,onSave:()=>{0!==v.length&&(y({world_clocks:v,weather_prefs:{...x.weather_prefs??{},useFahrenheit:D.useFahrenheit}}),j(F),localStorage.setItem(k,JSON.stringify(F)),N(!1))},children:[
23
23
  /* @__PURE__ */p("div",{children:[
24
24
  /* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Display"}),
25
25
  /* @__PURE__ */p("div",{className:"flex items-center gap-3 mb-2",children:[
26
26
  /* @__PURE__ */d("span",{className:"text-sm text-gray-600 w-24",children:"Temperature"}),
27
- /* @__PURE__ */d("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */d("button",{onClick:()=>W(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(T.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
27
+ /* @__PURE__ */d("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */d("button",{onClick:()=>T(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(D.useFahrenheit===e.key?"bg-blue-600 text-white border-blue-600":"bg-white text-gray-700 border-gray-300 hover:bg-gray-50"),children:e.label},String(e.key)))})]}),
28
28
  /* @__PURE__ */d("p",{className:"text-2xs text-gray-400 mt-1",children:"Shared with the Weather widget."})]}),
29
29
  /* @__PURE__ */p("div",{children:[
30
30
  /* @__PURE__ */d("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Cities"}),
@@ -30,6 +30,27 @@ interface AssistantMessageMetadata {
30
30
  source?: MessageSource;
31
31
  /** Set on a reply streamed in this window; a restored thread has none. */
32
32
  usage?: AssistantTurnUsage;
33
+ /** The server's run that wrote this answer, on an answer the person can
34
+ * rate (efficient-backend `assistant.ratings`): sent on `finish`, and on
35
+ * each answer of a restored thread. */
36
+ run_id?: string;
37
+ /** The person's own rating of it, from a restored thread. */
38
+ rating?: AssistantAnswerRating | null;
39
+ }
40
+ /** Thumbs up or down on one answer. */
41
+ type AssistantAnswerVerdict = 'up' | 'down';
42
+ /** A person's rating of one answer. `note` is what was wrong, in a few words;
43
+ * a thumbs-up carries none. */
44
+ interface AssistantAnswerRating {
45
+ verdict: AssistantAnswerVerdict;
46
+ note: string;
47
+ }
48
+ /** What the chat hands `onRate`: the answer, and the new rating — `null`
49
+ * when the person took theirs back. */
50
+ interface AssistantRateRequest {
51
+ conversationId: string;
52
+ runId: string;
53
+ rating: AssistantAnswerRating | null;
33
54
  }
34
55
  /** A step of a server-run plan. `status` is the server's record of what ran. */
35
56
  interface PlanStepData {
@@ -169,6 +190,17 @@ interface AssistantChatLabels {
169
190
  streamingRate: string;
170
191
  /** Names the row of suggested next questions under the last answer. */
171
192
  followups: string;
193
+ /** Names the thumbs under an answer for assistive technology. */
194
+ rateAnswer: string;
195
+ rateUp: string;
196
+ rateDown: string;
197
+ /** The note's placeholder, under a thumbs-down. */
198
+ rateNote: string;
199
+ rateNoteSend: string;
200
+ rateNoteSkip: string;
201
+ /** Shown once a thumbs-down's note has been sent. */
202
+ rateThanks: string;
203
+ rateFailed: string;
172
204
  }
173
205
  type AssistantChatVariant = 'panel' | 'window' | 'bubble';
174
206
  /** A host's own action on a piece of the person's text — the admin portal's
@@ -250,6 +282,12 @@ interface AssistantChatProps {
250
282
  * Spreadsheet" and "Copy as CSV". The chat knows nothing of what they do.
251
283
  * None by default. */
252
284
  tableActions?: MarkdownTableAction[];
285
+ /** Thumbs up and down under each finished answer the server says can be
286
+ * rated, with a short "what was wrong" note after a thumbs-down. The chat
287
+ * hands the host the rating and the host saves it (the admin portal's
288
+ * `PUT …/runs/<run>/rating/`); reject to show that it was not saved.
289
+ * Without it, no thumbs are drawn. */
290
+ onRate?: (request: AssistantRateRequest) => Promise<void> | void;
253
291
  /** Replaces `fetch`, for hosts that need to wrap requests. */
254
292
  fetch?: typeof fetch;
255
293
  className?: string;
@@ -276,8 +314,11 @@ interface MessageProps {
276
314
  userActions?: AssistantTextAction[];
277
315
  /** Controls under each table, once the reply has finished. */
278
316
  tableActions?: MarkdownTableAction[];
317
+ /** Saves the person's rating of this answer; with it, a finished answer the
318
+ * server named a run for shows thumbs. */
319
+ onRate?: (runId: string, rating: AssistantAnswerRating | null) => Promise<void> | void;
279
320
  }
280
- declare function Message({ message, toolLabels, labels, showReasoning, showToolOutput, showUsage, live, onApprove, plans, userActions, tableActions, onLinkClick }: MessageProps): react_jsx_runtime.JSX.Element | null;
321
+ declare function Message({ message, toolLabels, labels, showReasoning, showToolOutput, showUsage, live, onApprove, plans, userActions, tableActions, onLinkClick, onRate }: MessageProps): react_jsx_runtime.JSX.Element | null;
281
322
 
282
323
  interface ApprovalDecision {
283
324
  approval_id: string;
@@ -313,6 +354,10 @@ interface HistoryMessage {
313
354
  source?: MessageSource;
314
355
  text: string;
315
356
  created_at?: string;
357
+ /** On an answer the caller can rate: the run that wrote it. */
358
+ run_id?: string;
359
+ /** The caller's own rating of it, `null` when none. */
360
+ rating?: AssistantAnswerRating | null;
316
361
  }
317
362
  interface HistoryApproval {
318
363
  approval_id: string;
@@ -342,13 +387,6 @@ declare function plansOf(messages: AssistantUIMessage[]): Map<string, PlanDataPa
342
387
  * is active, and — once it has finished — until the person sends another
343
388
  * message, so its outcome stays in view (folded). */
344
389
  declare function pinnedPlan(messages: AssistantUIMessage[]): PlanDataPart | null;
345
- /** Rebuild the thread from `GET <apiBase>/assistant/chat/<id>/`. Pending
346
- * approvals come back as one trailing assistant message of tool parts in
347
- * `approval-requested`, so the same card and the same continuation apply.
348
- * A plan still waiting or running rides in that message as its `data-plan`
349
- * part, so the checklist is pinned again and the continuation's updates
350
- * replace it in place. A finished plan is already told in the thread by the
351
- * server's own summary message. */
352
390
  declare function messagesFromHistory(history: ConversationHistory): AssistantUIMessage[];
353
391
  declare function isDroppedConnection(error: Error | undefined | null): boolean;
354
392
  interface FailureView {
@@ -427,4 +465,4 @@ declare function finishedStats(usage: AssistantTurnUsage, labels: StatsLabels):
427
465
  /** The line under a reply being written: `elapsedMs` since the reply began. */
428
466
  declare function liveStats(text: string, elapsedMs: number, labels: StatsLabels): string;
429
467
 
430
- export { ApprovalCard, type ApprovalDecision, AssistantChat, type AssistantChatLabels, type AssistantChatProps, type AssistantChatRequestBody, type AssistantChatVariant, type AssistantConversation, type AssistantErrorCode, Message as AssistantMessage, type AssistantMessageMetadata, type AssistantTextAction, type AssistantTurnUsage, type AssistantUIMessage, type ConversationHistory, DEFAULT_ASSISTANT_CHAT_LABELS, type ErrorDataPart, type FailureView, type MessageSource, PlanApprovalCard, PlanChecklist, type PlanDataPart, type PlanStatus, type PlanStepData, type ToolLabel, type ToolLabelSpec, type ToolLabels, ToolStep, type ToolSummaryDataPart, type ToolSummaryRow, buildRequestBody, estimateTokens, failureView, finishedStats, isDroppedConnection, liveStats, messagesFromHistory, pinnedPlan, plansOf, tokensPerSecond, toolSummariesOf };
468
+ export { ApprovalCard, type ApprovalDecision, type AssistantAnswerRating, type AssistantAnswerVerdict, AssistantChat, type AssistantChatLabels, type AssistantChatProps, type AssistantChatRequestBody, type AssistantChatVariant, type AssistantConversation, type AssistantErrorCode, Message as AssistantMessage, type AssistantMessageMetadata, type AssistantRateRequest, type AssistantTextAction, type AssistantTurnUsage, type AssistantUIMessage, type ConversationHistory, DEFAULT_ASSISTANT_CHAT_LABELS, type ErrorDataPart, type FailureView, type MessageSource, PlanApprovalCard, PlanChecklist, type PlanDataPart, type PlanStatus, type PlanStepData, type ToolLabel, type ToolLabelSpec, type ToolLabels, ToolStep, type ToolSummaryDataPart, type ToolSummaryRow, buildRequestBody, estimateTokens, failureView, finishedStats, isDroppedConnection, liveStats, messagesFromHistory, pinnedPlan, plansOf, tokensPerSecond, toolSummariesOf };
package/dist/ai/index.js CHANGED
@@ -1,39 +1,44 @@
1
1
  "use client";
2
- import{StepChain as e,StepChainItem as t}from"../chunk-SAKHGHF5.js";import{Markdown as n}from"../chunk-37JDUDCO.js";import{Textarea_default as r}from"../chunk-7PCI6AUU.js";import"../chunk-UJUTS6LJ.js";import"../chunk-PJPK2ADX.js";import{useContextMenu as o,ContextMenu as a}from"../chunk-AX7KPMDV.js";import{Banner as s}from"../chunk-WTY3SXO7.js";import"../chunk-B55IXYDR.js";import{IconButton_default as l}from"../chunk-4CANQ3B3.js";import"../chunk-PF3ANJFI.js";import{parseChartSpec as i}from"../chunk-CR7T435F.js";import{SpecChart as c}from"../chunk-TFMC2WAS.js";import"../chunk-X2S2XDZI.js";import"../chunk-5OTS2G3M.js";import"../chunk-36BRD5J3.js";import"../chunk-OSA24YH6.js";import"../chunk-CK2YOGUS.js";import"../chunk-BRHIRE4D.js";import"../chunk-VFC6QUEN.js";import"../chunk-W5M6P4DZ.js";import"../chunk-465RRWBY.js";import{ChartSkeleton as u}from"../chunk-Y4MI6NRI.js";import"../chunk-CNYAHYE6.js";import"../chunk-PJCVNFWM.js";import"../chunk-QR4RM7PO.js";import"../chunk-5QFPTDQF.js";import{Button_default as p}from"../chunk-4IU5BSVE.js";import"../chunk-K7U4RWXJ.js";import"../chunk-VH6GB73Q.js";import{Icon as d}from"../chunk-KIBL6M3T.js";import"../chunk-J75ZT2JQ.js";import{SpinnerRing as m}from"../chunk-Q5MD3VY6.js";import"../chunk-MRJKZWWV.js";import"../chunk-6KO5VTL7.js";import"../chunk-22S6LG6D.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-GLUJS42B.js";import"../chunk-D65T4H6J.js";import"../chunk-P5BOTIJU.js";import"../chunk-DTJRIWFR.js";import"../chunk-RSO67DWS.js";import"../chunk-MG7A3R75.js";import"../chunk-2JWPNR2U.js";import"../chunk-MAFUXCPZ.js";import"../chunk-TWVUQUUD.js";import"../chunk-EYKUKN32.js";import"../chunk-TZFACUMR.js";import"../chunk-E6UCGCOC.js";import"../chunk-C3QOHMR6.js";import{useRef as h,useState as g,useEffect as f,useId as v,useCallback as b,useMemo as y}from"react";import{jsx as k,jsxs as w}from"react/jsx-runtime";import{isToolUIPart as x,getToolName as N,DefaultChatTransport as C,lastAssistantMessageIsCompleteWithApprovalResponses as j}from"ai";import{useChat as A}from"@ai-sdk/react";function S({labels:e,placeholder:t,busy:n,focusWhen:o,onSend:a,onStop:s,onNewChat:i,actions:c}){const[u,m]=g(""),v=h(null);f(()=>{o&&v.current?.focus()},[o]);const b=()=>{!n&&u.trim()&&(a(u),m(""))};/* @__PURE__ */
3
- return w("form",{className:"flex items-end gap-2 border-t border-gray-200 p-3",onSubmit:e=>{e.preventDefault(),b()},children:[i&&/* @__PURE__ */k(l,{type:"button",variant:"ghost","aria-label":e.newChat,title:e.newChat,onClick:i,children:/* @__PURE__ */k(d,{name:"add"})}),
4
- /* @__PURE__ */k("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */k(r,{ref:v,"aria-label":e.inputLabel,placeholder:t,rows:1,autoGrow:!0,value:u,onChange:e=>m(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),b())},className:"max-h-32"})}),c?.map(e=>e.icon?/* @__PURE__ */k(l,{type:"button",variant:"ghost","aria-label":e.label,title:e.label,disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:/* @__PURE__ */k(d,{name:e.icon})},e.key):/* @__PURE__ */k(p,{type:"button",variant:"ghost",disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:e.label},e.key)),/* @__PURE__ */k(p,n?{type:"button",variant:"secondary",onClick:s,children:e.stop}:{type:"submit",disabled:!u.trim(),children:e.send})]})}function $(e){if(!x(e))return null;const t=e;return{toolName:N(e),toolCallId:t.toolCallId,state:t.state,input:t.input,output:t.output,errorText:t.errorText,approvalId:t.approval?.id,approved:t.approval?.approved}}function R(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-tool-summary"!==n.type)continue;const e=n.data;e&&"string"==typeof e.tool_call_id&&Array.isArray(e.rows)&&e.rows.length>0&&t.set(e.tool_call_id,e)}return t}function T(e){return e.parts.map(e=>"text"===e.type?e.text:"").join("")}function _(e,t){const n=e[e.length-1];if(!n)throw new Error("assistant chat: no message to send");if("user"===n.role){const e=T(n).trim();if(!e)throw new Error("assistant chat: empty message");return{conversation_id:t,text:e,approvals:[]}}const r=function(e){const t=[];for(const n of e.parts){if(!x(n))continue;const e=n;if("approval-responded"!==e.state||!e.approval||"boolean"!=typeof e.approval.approved)continue;const r={approval_id:e.approval.id,approved:e.approval.approved};e.approval.reason&&(r.reason=e.approval.reason),t.push(r)}return t}(n);if(0===r.length)throw new Error("assistant chat: no approval decision to send");return{conversation_id:t,text:null,approvals:r}}var I=/* @__PURE__ */new Set(["proposed","approved","running"]);function D(e){return I.has(e.status)}function M(e){const t=[];for(const n of e.parts)"data-plan"===n.type&&t.push(n.data);return t}function O(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of M(n))t.delete(e.id),t.set(e.id,e);return t}function L(e){const t=[...O(e).values()],n=t[t.length-1];if(!n)return null;if(D(n))return n;const r=e[e.length-1];return r&&"assistant"===r.role&&M(r).some(e=>e.id===n.id)?n:null}function U(e){const t=e.messages.filter(e=>e.text).map(e=>({id:e.id,role:e.role,parts:[{type:"text",text:e.text}],...e.source&&e.source!==e.role?{metadata:{source:e.source}}:{}})),n=(e.plans??[]).filter(D);return(e.pending_approvals.length>0||n.length>0)&&t.push({id:`pending-approvals-${e.id}`,role:"assistant",parts:[...n.map(e=>({type:"data-plan",id:e.id,data:e})),...e.pending_approvals.map(e=>({type:`tool-${e.tool_name}`,toolCallId:e.tool_call_id??e.approval_id,state:"approval-requested",input:e.input,approval:{id:e.approval_id}}))]}),t}function P(e,t){const n=e?.message?.trim();if(!n)return t;if(n.startsWith("{")){try{const e=JSON.parse(n);for(const t of["detail","errorText","message","title","error"]){const n=e[t];if("string"==typeof n&&n.trim())return n.trim()}}catch{return t}return t}return n.startsWith("<")||n.length>400?t:n}var E=/^(load failed|failed to fetch|network ?error( when attempting to fetch resource)?|(the )?network connection was lost|error in input stream|terminated)\.?$/i;function J(e){return!(!e||"AbortError"===e.name)&&E.test(e.message?.trim()??"")}var F=/* @__PURE__ */new Set(["budget_reached","not_permitted"]);function W(e,t,n){return J(e)?{text:n.connectionDropped,retryable:!0}:{text:P(e,n.genericError),retryable:!(t&&F.has(t))}}function B(e){const t=e[e.length-1];if(!t)return!1;if("user"===t.role)return""!==T(t).trim();const n=e[e.length-2];return!(!n||"user"!==n.role||!T(n).trim())&&!t.parts.some(e=>void 0!==$(e)?.approvalId)}function H(e){const t=e.replace(/^tool-/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var z={propose_plan:{label:"Plan the changes",running:"Planning the changes",done:"Planned the changes"}};function K(e,t){const n=t?.[e]??z[e];return"string"==typeof n?{label:n}:n??{label:H(e)}}function q(e,t){return K(e,t).label}function G(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function Q(e,t,n){const r=K(e,n).describe;if(!r)return"";try{return r(G(t))?.trim()??""}catch{return""}}function Y(e,t){return null==e?"":"boolean"==typeof e?e?"Yes":"No":"object"!=typeof e?String(e):Array.isArray(e)?e.map(e=>Y(e,t+1)).filter(Boolean).join(", "):t>=3?"…":Object.entries(e).map(([e,n])=>{const r=Y(n,t+1);return r?`${H(e)}: ${r}`:""}).filter(Boolean).join("; ")}function V(e){const t=G(e),n=[];for(const[e,r]of Object.entries(t)){const t=Y(r,0);t&&n.push({label:H(e),value:t})}return 0===n.length&&null!=e&&"object"!=typeof e&&n.push({label:"Value",value:Y(e,0)}),n}var X={proposed:"planProposed",approved:"planApproved",running:"planRunning",completed:"planCompleted",failed:"planFailed",denied:"planDenied",expired:"planExpired"},Z={pending:"pending",running:"active",done:"complete",failed:"failed",skipped:"skipped"};function ee(e,t){const n=Q(e.tool_name,e.input,t);return`${q(e.tool_name,t)}${n?` ${n}`:""}`}function te(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}function ne(e,t){const n=e.steps.filter(e=>"done"===e.status).length;return`${te(t.planSummary,{done:n,total:e.steps.length})} · ${t[X[e.status]]}`}function re({plan:n,labels:r}){/* @__PURE__ */
5
- return k("section",{"aria-label":r.plan,className:"border-t border-gray-200 bg-white px-3 py-2",children:/* @__PURE__ */k(e,{summary:ne(n,r),busy:D(n),label:r.plan,children:n.steps.map(e=>/* @__PURE__ */k(t,{label:e.title,status:Z[e.status],description:"done"!==e.status&&e.result_summary?e.result_summary:void 0},e.id))})})}function oe({approvalId:e,plan:t,input:n,labels:r,toolLabels:o,onApprove:a}){const s=function(e,t){if(e)return e.steps.map(e=>({key:e.id,title:e.title,tool_name:e.tool_name,input:e.input}));const n=t?.steps;return Array.isArray(n)?n.map((e,t)=>{const n=e??{};return{key:String(t),title:"string"==typeof n.title?n.title:"",tool_name:"string"==typeof n.tool?n.tool:"",input:n.args}}):[]}(t,n),l=te(r.planApprovalHeading,{count:s.length});/* @__PURE__ */
6
- return w("div",{role:"group","aria-label":l,className:"rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm",children:[
2
+ import{StepChain as e,StepChainItem as t}from"../chunk-MC43PRTL.js";import{Markdown as n}from"../chunk-ECCUEG3J.js";import{Textarea_default as r}from"../chunk-7PCI6AUU.js";import"../chunk-UJUTS6LJ.js";import"../chunk-PJPK2ADX.js";import{useContextMenu as a,ContextMenu as o}from"../chunk-JDKRQG7X.js";import{Banner as s}from"../chunk-MY755PTJ.js";import"../chunk-TZHWF3P5.js";import{Input_default as l}from"../chunk-GX2GSDJP.js";import"../chunk-PF3ANJFI.js";import{IconButton_default as i}from"../chunk-4CANQ3B3.js";import{parseChartSpec as c}from"../chunk-CR7T435F.js";import{SpecChart as u}from"../chunk-BKZGI76S.js";import"../chunk-X2S2XDZI.js";import"../chunk-5OTS2G3M.js";import"../chunk-36BRD5J3.js";import"../chunk-WSPO4N72.js";import"../chunk-EYKUKN32.js";import"../chunk-CK2YOGUS.js";import"../chunk-BRHIRE4D.js";import"../chunk-VFC6QUEN.js";import"../chunk-ETF7LAYZ.js";import"../chunk-465RRWBY.js";import{ChartSkeleton as d}from"../chunk-Y4MI6NRI.js";import"../chunk-CNYAHYE6.js";import"../chunk-FKZEGBLK.js";import"../chunk-5QFPTDQF.js";import"../chunk-QR4RM7PO.js";import{Button_default as p}from"../chunk-4IU5BSVE.js";import"../chunk-K7U4RWXJ.js";import{Icon as m}from"../chunk-2SHYR3RA.js";import"../chunk-J75ZT2JQ.js";import"../chunk-VH6GB73Q.js";import{SpinnerRing as h}from"../chunk-Q5MD3VY6.js";import"../chunk-MRJKZWWV.js";import"../chunk-6KO5VTL7.js";import"../chunk-22S6LG6D.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-GLUJS42B.js";import"../chunk-D65T4H6J.js";import"../chunk-P5BOTIJU.js";import"../chunk-DTJRIWFR.js";import"../chunk-I4VD5D43.js";import"../chunk-MG7A3R75.js";import"../chunk-2JWPNR2U.js";import"../chunk-MAFUXCPZ.js";import"../chunk-TZFACUMR.js";import"../chunk-TWVUQUUD.js";import"../chunk-E6UCGCOC.js";import"../chunk-C3QOHMR6.js";import{useRef as g,useState as f,useEffect as v,useId as b,useCallback as y,useMemo as w}from"react";import{jsx as k,jsxs as x}from"react/jsx-runtime";import{isToolUIPart as N,getToolName as C,DefaultChatTransport as j,lastAssistantMessageIsCompleteWithApprovalResponses as A}from"ai";import{useChat as S}from"@ai-sdk/react";function R({labels:e,placeholder:t,busy:n,focusWhen:a,onSend:o,onStop:s,onNewChat:l,actions:c}){const[u,d]=f(""),h=g(null);v(()=>{a&&h.current?.focus()},[a]);const b=()=>{!n&&u.trim()&&(o(u),d(""))};/* @__PURE__ */
3
+ return x("form",{className:"flex items-end gap-2 border-t border-gray-200 p-3",onSubmit:e=>{e.preventDefault(),b()},children:[l&&/* @__PURE__ */k(i,{type:"button",variant:"ghost","aria-label":e.newChat,title:e.newChat,onClick:l,children:/* @__PURE__ */k(m,{name:"add"})}),
4
+ /* @__PURE__ */k("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */k(r,{ref:h,"aria-label":e.inputLabel,placeholder:t,rows:1,autoGrow:!0,value:u,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),b())},className:"max-h-32"})}),c?.map(e=>e.icon?/* @__PURE__ */k(i,{type:"button",variant:"ghost","aria-label":e.label,title:e.label,disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:/* @__PURE__ */k(m,{name:e.icon})},e.key):/* @__PURE__ */k(p,{type:"button",variant:"ghost",disabled:!u.trim(),onClick:()=>e.onSelect(u.trim()),children:e.label},e.key)),/* @__PURE__ */k(p,n?{type:"button",variant:"secondary",onClick:s,children:e.stop}:{type:"submit",disabled:!u.trim(),children:e.send})]})}function T(e){if(!N(e))return null;const t=e;return{toolName:C(e),toolCallId:t.toolCallId,state:t.state,input:t.input,output:t.output,errorText:t.errorText,approvalId:t.approval?.id,approved:t.approval?.approved}}function _(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-tool-summary"!==n.type)continue;const e=n.data;e&&"string"==typeof e.tool_call_id&&Array.isArray(e.rows)&&e.rows.length>0&&t.set(e.tool_call_id,e)}return t}function I(e){return e.parts.map(e=>"text"===e.type?e.text:"").join("")}function $(e,t){const n=e[e.length-1];if(!n)throw new Error("assistant chat: no message to send");if("user"===n.role){const e=I(n).trim();if(!e)throw new Error("assistant chat: empty message");return{conversation_id:t,text:e,approvals:[]}}const r=function(e){const t=[];for(const n of e.parts){if(!N(n))continue;const e=n;if("approval-responded"!==e.state||!e.approval||"boolean"!=typeof e.approval.approved)continue;const r={approval_id:e.approval.id,approved:e.approval.approved};e.approval.reason&&(r.reason=e.approval.reason),t.push(r)}return t}(n);if(0===r.length)throw new Error("assistant chat: no approval decision to send");return{conversation_id:t,text:null,approvals:r}}var D=/* @__PURE__ */new Set(["proposed","approved","running"]);function L(e){return D.has(e.status)}function O(e){const t=[];for(const n of e.parts)"data-plan"===n.type&&t.push(n.data);return t}function U(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of O(n))t.delete(e.id),t.set(e.id,e);return t}function M(e){const t=[...U(e).values()],n=t[t.length-1];if(!n)return null;if(L(n))return n;const r=e[e.length-1];return r&&"assistant"===r.role&&O(r).some(e=>e.id===n.id)?n:null}function E(e){const t={};return e.source&&e.source!==e.role&&(t.source=e.source),"assistant"===e.role&&e.run_id&&(t.run_id=e.run_id,t.rating=e.rating??null),Object.keys(t).length>0?{metadata:t}:{}}function P(e){const t=e.messages.filter(e=>e.text).map(e=>({id:e.id,role:e.role,parts:[{type:"text",text:e.text}],...E(e)})),n=(e.plans??[]).filter(L);return(e.pending_approvals.length>0||n.length>0)&&t.push({id:`pending-approvals-${e.id}`,role:"assistant",parts:[...n.map(e=>({type:"data-plan",id:e.id,data:e})),...e.pending_approvals.map(e=>({type:`tool-${e.tool_name}`,toolCallId:e.tool_call_id??e.approval_id,state:"approval-requested",input:e.input,approval:{id:e.approval_id}}))]}),t}function J(e,t){const n=e?.message?.trim();if(!n)return t;if(n.startsWith("{")){try{const e=JSON.parse(n);for(const t of["detail","errorText","message","title","error"]){const n=e[t];if("string"==typeof n&&n.trim())return n.trim()}}catch{return t}return t}return n.startsWith("<")||n.length>400?t:n}var F=/^(load failed|failed to fetch|network ?error( when attempting to fetch resource)?|(the )?network connection was lost|error in input stream|terminated)\.?$/i;function B(e){return!(!e||"AbortError"===e.name)&&F.test(e.message?.trim()??"")}var z=/* @__PURE__ */new Set(["budget_reached","not_permitted"]);function W(e,t,n){return B(e)?{text:n.connectionDropped,retryable:!0}:{text:J(e,n.genericError),retryable:!(t&&z.has(t))}}function G(e){const t=e[e.length-1];if(!t)return!1;if("user"===t.role)return""!==I(t).trim();const n=e[e.length-2];return!(!n||"user"!==n.role||!I(n).trim())&&!t.parts.some(e=>void 0!==T(e)?.approvalId)}function H(e){const t=e.replace(/^tool-/,"").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_\-.]+/g," ").trim().toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):e}var K={propose_plan:{label:"Plan the changes",running:"Planning the changes",done:"Planned the changes"}};function Q(e,t){const n=t?.[e]??K[e];return"string"==typeof n?{label:n}:n??{label:H(e)}}function Y(e,t){return Q(e,t).label}function q(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function Z(e,t,n){const r=Q(e,n).describe;if(!r)return"";try{return r(q(t))?.trim()??""}catch{return""}}function V(e,t){return null==e?"":"boolean"==typeof e?e?"Yes":"No":"object"!=typeof e?String(e):Array.isArray(e)?e.map(e=>V(e,t+1)).filter(Boolean).join(", "):t>=3?"…":Object.entries(e).map(([e,n])=>{const r=V(n,t+1);return r?`${H(e)}: ${r}`:""}).filter(Boolean).join("; ")}function X(e){const t=q(e),n=[];for(const[e,r]of Object.entries(t)){const t=V(r,0);t&&n.push({label:H(e),value:t})}return 0===n.length&&null!=e&&"object"!=typeof e&&n.push({label:"Value",value:V(e,0)}),n}var ee={proposed:"planProposed",approved:"planApproved",running:"planRunning",completed:"planCompleted",failed:"planFailed",denied:"planDenied",expired:"planExpired"},te={pending:"pending",running:"active",done:"complete",failed:"failed",skipped:"skipped"};function ne(e,t){const n=Z(e.tool_name,e.input,t);return`${Y(e.tool_name,t)}${n?` ${n}`:""}`}function re(e,t){return e.replace(/\{(\w+)\}/g,(e,n)=>n in t?String(t[n]):e)}function ae(e,t){const n=e.steps.filter(e=>"done"===e.status).length;return`${re(t.planSummary,{done:n,total:e.steps.length})} · ${t[ee[e.status]]}`}function oe({plan:n,labels:r}){/* @__PURE__ */
5
+ return k("section",{"aria-label":r.plan,className:"border-t border-gray-200 bg-white px-3 py-2",children:/* @__PURE__ */k(e,{summary:ae(n,r),busy:L(n),label:r.plan,children:n.steps.map(e=>/* @__PURE__ */k(t,{label:e.title,status:te[e.status],description:"done"!==e.status&&e.result_summary?e.result_summary:void 0},e.id))})})}function se({approvalId:e,plan:t,input:n,labels:r,toolLabels:a,onApprove:o}){const s=function(e,t){if(e)return e.steps.map(e=>({key:e.id,title:e.title,tool_name:e.tool_name,input:e.input}));const n=t?.steps;return Array.isArray(n)?n.map((e,t)=>{const n=e??{};return{key:String(t),title:"string"==typeof n.title?n.title:"",tool_name:"string"==typeof n.tool?n.tool:"",input:n.args}}):[]}(t,n),l=re(r.planApprovalHeading,{count:s.length});/* @__PURE__ */
6
+ return x("div",{role:"group","aria-label":l,className:"rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm",children:[
7
7
  /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:l}),
8
- /* @__PURE__ */k("ol",{className:"mt-2 list-decimal space-y-2 pl-5",children:s.map(e=>{const t=V(e.input);/* @__PURE__ */
9
- return w("li",{children:[
10
- /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:ee(e,o)}),e.title&&/* @__PURE__ */k("div",{className:"text-xs text-gray-600",children:e.title}),t.length>0&&/* @__PURE__ */k("dl",{className:"mt-1 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:t.map(e=>/* @__PURE__ */w("div",{className:"contents",children:[
8
+ /* @__PURE__ */k("ol",{className:"mt-2 list-decimal space-y-2 pl-5",children:s.map(e=>{const t=X(e.input);/* @__PURE__ */
9
+ return x("li",{children:[
10
+ /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:ne(e,a)}),e.title&&/* @__PURE__ */k("div",{className:"text-xs text-gray-600",children:e.title}),t.length>0&&/* @__PURE__ */k("dl",{className:"mt-1 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:t.map(e=>/* @__PURE__ */x("div",{className:"contents",children:[
11
11
  /* @__PURE__ */k("dt",{className:"text-gray-500",children:e.label}),
12
12
  /* @__PURE__ */k("dd",{className:"min-w-0 break-words text-gray-800",children:e.value})]},e.label))})]},e.key)})}),
13
- /* @__PURE__ */w("div",{className:"mt-3 flex gap-2",children:[
14
- /* @__PURE__ */k(p,{size:"sm",onClick:()=>a(e,!0),children:r.approvePlan}),
15
- /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>a(e,!1),children:r.deny})]})]})}function ae({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */k("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function se({rows:e,label:t}){/* @__PURE__ */
16
- return k("dl",{"aria-label":t,className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:e.map((e,t)=>/* @__PURE__ */w("div",{className:"contents",children:[
13
+ /* @__PURE__ */x("div",{className:"mt-3 flex gap-2",children:[
14
+ /* @__PURE__ */k(p,{size:"sm",onClick:()=>o(e,!0),children:r.approvePlan}),
15
+ /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>o(e,!1),children:r.deny})]})]})}function le({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */k("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function ie({initial:e,labels:t,onRate:n}){const[r,a]=f(e??null),[o,s]=f(!1),[c,u]=f(""),[d,h]=f(!1),[g,v]=f(!1),[b,y]=f(!1),w=async e=>{const t=r;a(e),v(!1),y(!0);try{return await n(e),!0}catch{return a(t),v(!0),!1}finally{y(!1)}},N=e=>{const n="up"===e?t.rateUp:t.rateDown;/* @__PURE__ */
16
+ return k(i,{size:"sm","aria-label":n,title:n,"aria-pressed":r?.verdict===e,disabled:b,onClick:()=>{(async e=>{if(h(!1),r?.verdict===e)return s(!1),void await w(null);const t=await w({verdict:e,note:""});s(t&&"down"===e),u("")})(e)},children:/* @__PURE__ */k(m,{name:"hand-thumb-up",className:"down"===e?"rotate-180":void 0})})};/* @__PURE__ */
17
+ return x("div",{role:"group","aria-label":t.rateAnswer,className:"flex w-full max-w-[92%] flex-col gap-1",children:[
18
+ /* @__PURE__ */x("div",{className:"flex items-center gap-1",children:[N("up"),N("down"),d&&/* @__PURE__ */k("span",{role:"status",className:"px-1 text-xs text-gray-500",children:t.rateThanks}),g&&/* @__PURE__ */k("span",{role:"alert",className:"px-1 text-xs text-red-600",children:t.rateFailed})]}),o&&/* @__PURE__ */x("form",{className:"flex items-center gap-2",onSubmit:e=>{(async e=>{e.preventDefault();const t=c.trim();t&&!await w({verdict:"down",note:t})||(s(!1),h(Boolean(t)))})(e)},children:[
19
+ /* @__PURE__ */k("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */k(l,{size:"sm","aria-label":t.rateNote,placeholder:t.rateNote,maxLength:500,value:c,onChange:e=>u(e.target.value),autoFocus:!0})}),
20
+ /* @__PURE__ */k(p,{type:"submit",size:"sm",variant:"secondary",disabled:b||!c.trim(),children:t.rateNoteSend}),
21
+ /* @__PURE__ */k(p,{type:"button",size:"sm",variant:"ghost",onClick:()=>s(!1),children:t.rateNoteSkip})]})]})}function ce({rows:e,label:t}){/* @__PURE__ */
22
+ return k("dl",{"aria-label":t,className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:e.map((e,t)=>/* @__PURE__ */x("div",{className:"contents",children:[
17
23
  /* @__PURE__ */k("dt",{className:"text-gray-500",children:e.label}),
18
- /* @__PURE__ */k("dd",{className:"min-w-0 break-words "+(e.warn?"font-medium text-amber-700":"text-gray-800"),children:e.value})]},`${e.label}-${t}`))})}function le({tool:e,toolLabels:t,labels:n,onApprove:r}){const o=Q(e.toolName,e.input,t),a=V(e.input),s=e.approvalId,l=`${n.approvalNeeded}: ${q(e.toolName,t)}${o?` ${o}`:""}`;/* @__PURE__ */
19
- return w("div",{role:"group","aria-label":l,className:"rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm",children:[
20
- /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:l}),a.length>0&&/* @__PURE__ */k("div",{className:"mt-2",children:/* @__PURE__ */k(se,{rows:a})}),
21
- /* @__PURE__ */w("div",{className:"mt-3 flex gap-2",children:[
24
+ /* @__PURE__ */k("dd",{className:"min-w-0 break-words "+(e.warn?"font-medium text-amber-700":"text-gray-800"),children:e.value})]},`${e.label}-${t}`))})}function ue({tool:e,toolLabels:t,labels:n,onApprove:r}){const a=Z(e.toolName,e.input,t),o=X(e.input),s=e.approvalId,l=`${n.approvalNeeded}: ${Y(e.toolName,t)}${a?` ${a}`:""}`;/* @__PURE__ */
25
+ return x("div",{role:"group","aria-label":l,className:"rounded-lg border border-amber-300 bg-amber-50 p-3 text-sm",children:[
26
+ /* @__PURE__ */k("div",{className:"font-medium text-gray-900",children:l}),o.length>0&&/* @__PURE__ */k("div",{className:"mt-2",children:/* @__PURE__ */k(ce,{rows:o})}),
27
+ /* @__PURE__ */x("div",{className:"mt-3 flex gap-2",children:[
22
28
  /* @__PURE__ */k(p,{size:"sm",onClick:()=>r(s,!0),children:n.approve}),
23
- /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>r(s,!1),children:n.deny})]})]})}var ie={running:"active",done:"complete",failed:"failed",declined:"stopped",waiting:"waiting"};function ce(e,t,n){return function(e,t,n,r,o,a){const s=K(n,o),l=Q(n,r,o),i=(e,t)=>({kind:e,base:t,subject:l,text:l?`${t} ${l}`:t});switch(e){case"output-available":return i("done",s.done??s.label);case"output-error":return i("failed",`${s.label} ${a.toolFailed}`);case"output-denied":return i("declined",`${s.label} ${a.toolDeclined}`);case"approval-requested":return i("waiting",`${a.approvalNeeded}: ${s.label}`);case"approval-responded":return!1===t?i("declined",`${s.label} — ${a.declined}`):i("running",`${a.approved}: ${s.running??s.label}`);default:return i("running",s.running??s.label)}}(e.state,e.approved,e.toolName,e.input,t,n)}function ue({tool:e,summary:n,toolLabels:r,labels:o,showOutput:a}){const s=ce(e,r,o),l=V(e.input),i=a&&"output-available"===e.state?V(e.output):[],c=a&&"output-error"===e.state&&e.errorText?e.errorText:"",u="output-available"===e.state&&n?n.rows:[];let p=null;return(l.length>0||i.length>0||c)&&(p=/* @__PURE__ */w("details",{className:u.length>0?"mt-1":void 0,children:[
24
- /* @__PURE__ */k("summary",{className:"cursor-pointer select-none",children:o.details}),
25
- /* @__PURE__ */w("div",{className:"mt-1 space-y-2",children:[l.length>0&&/* @__PURE__ */k(se,{rows:l}),i.length>0&&/* @__PURE__ */k(se,{rows:i}),c&&/* @__PURE__ */k("div",{className:"text-red-600",children:c})]})]})),/* @__PURE__ */w(t,{label:s.base,description:s.subject||void 0,status:ie[s.kind],children:[u.length>0&&/* @__PURE__ */k(se,{rows:u,label:o.stepSources}),p]})}function pe(e,t){return e>0&&t>=100?e/(t/1e3):null}function de(e){return Math.ceil(e.length/4)}var me=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),he=e=>Math.round(e).toLocaleString();function ge(e,t){const n=pe(e.output_tokens,e.generation_ms);return null===n?me(t.replyTokens,{tokens:he(e.output_tokens)}):me(t.replyStats,{tokens:he(e.output_tokens),seconds:(e.generation_ms/1e3).toFixed(1),rate:he(n)})}function fe(e,t,n){const r=t>=1e3?pe(de(e),t):null;return null===r?n.streaming:me(n.streamingRate,{rate:he(r)})}function ve(e){if("chart"!==e.lang)return null;if(!e.closed)/* @__PURE__ */return k(u,{height:200});const t=i(e.code);return t?/* @__PURE__ */k(c,{spec:t}):null}function be(e,t){return"approval-responded"===e.state&&t.some(t=>{return t.toolName===e.toolName&&"approval-requested"!==t.state&&(t.toolCallId===e.toolCallId||(n=t.input,r=e.input,JSON.stringify(n)===JSON.stringify(r)));var n,r})}function ye(e,t,n,r){const o=e.flatMap(e=>"tool"===e.kind?[ce(e.tool,n,r)]:[]);if(t){const e=o.find(e=>"running"===e.kind);return e?e.base:r.working}const a=[...new Set(o.map(e=>e.base))];return a.length>0?a.join(" · "):r.reasoning}function ke({message:e,live:t,labels:n}){const r=T(e),o=r.length>0,a=h(null),[s,l]=g(0);f(()=>{if(!t)return;null===a.current&&(a.current=performance.now());const e=setInterval(()=>l(performance.now()-(a.current??performance.now())),500);return()=>clearInterval(e)},[t]);const i=e.metadata?.usage;let c=null;return t?c=o?fe(r,s,n):null:i&&(c=ge(i,n)),c?/* @__PURE__ */k("div",{className:"px-1 text-xs tabular-nums text-gray-500",children:c}):null}function we({text:e,actions:t}){const n=o(),r=/* @__PURE__ */k("div",{className:"max-w-[85%] whitespace-pre-wrap break-words rounded-2xl bg-blue-600 px-3 py-2 text-sm text-white",children:e});return t?.length?/* @__PURE__ */w("div",{className:"flex justify-end",onContextMenu:e=>n.open(e,void 0),children:[r,n.state&&/* @__PURE__ */k(a,{...n.props,"aria-label":e,items:t.map(t=>({key:t.key,label:t.label,onSelect:()=>t.onSelect(e)}))})]}):/* @__PURE__ */k("div",{className:"flex justify-end",children:r})}function xe({message:r,toolLabels:o,labels:a,showReasoning:s,showToolOutput:l,showUsage:i,live:c,onApprove:u,plans:p,userActions:d,tableActions:m,onLinkClick:h}){const g=r.metadata?.source;if("system"===g){const e=T(r);return e?/* @__PURE__ */k("div",{className:"text-center text-xs text-gray-500",children:e}):null}if("user"===r.role){const e=T(r);return e?/* @__PURE__ */k(we,{text:e,actions:d}):null}const f=r.parts.map($),v=R(r),b=[],y=[];let x=-1;const N=e=>{x<0&&(x=b.push(null)-1),y.push(e)};if(r.parts.forEach((e,t)=>{if("text"===e.type)return void(e.text.trim()&&b.push(
26
- /* @__PURE__ */k(n,{renderFence:ve,tableActions:c?void 0:m,onLinkClick:h,children:e.text},t)));if("reasoning"===e.type)return void(s&&e.text.trim()&&N({kind:"reasoning",key:`r${t}`,text:e.text}));const r=f[t];r&&(be(r,f.slice(t+1).filter(e=>null!==e))||("approval-requested"===r.state&&r.approvalId&&"propose_plan"===r.toolName?b.push(
27
- /* @__PURE__ */k(oe,{approvalId:r.approvalId,plan:p?.get(r.approvalId),input:r.input,labels:a,toolLabels:o,onApprove:u},r.toolCallId)):"approval-requested"===r.state&&r.approvalId?b.push(
28
- /* @__PURE__ */k(le,{tool:r,toolLabels:o,labels:a,onApprove:u},r.toolCallId)):N({kind:"tool",key:r.toolCallId,tool:r})))}),x>=0&&(b[x]=/* @__PURE__ */k(e,{summary:ye(y,c,o,a),busy:c,label:a.steps,children:y.map(e=>"tool"===e.kind?/* @__PURE__ */k(ue,{tool:e.tool,summary:v.get(e.tool.toolCallId),toolLabels:o,labels:a,showOutput:l},e.key):/* @__PURE__ */k(t,{status:"complete",label:/* @__PURE__ */w("details",{children:[
29
- /* @__PURE__ */k("summary",{className:"cursor-pointer select-none",children:a.reasoning}),
30
- /* @__PURE__ */k("div",{className:"mt-1 whitespace-pre-wrap text-gray-500",children:e.text})]})},e.key))},"chain")),0===b.length)return null;const C=/* @__PURE__ */w("div",{className:"max-w-[92%] min-w-0 space-y-2 rounded-2xl bg-white px-3 py-2 text-gray-800 shadow-sm",children:["staff"===g&&/* @__PURE__ */k("div",{className:"text-xs font-medium text-blue-600",children:a.teamName}),b]});return!i||g?/* @__PURE__ */k("div",{className:"flex justify-start",children:C}):/* @__PURE__ */w("div",{className:"flex flex-col items-start gap-1",children:[C,
31
- /* @__PURE__ */k(ke,{message:r,live:c,labels:a})]})}function Ne(e){const{messages:t,status:n,error:r,history:o,labels:a}=e,l=h(null),i=y(()=>function(e){const t=/* @__PURE__ */new Map;for(const n of O(e).values())t.set(n.approval_id,n);return t}(t),[t]),c=r?W(r,e.errorCode??null,a):null,u=t[t.length-1],d="ready"!==n||r||e.handedOver||"assistant"!==u?.role||!e.onAsk?[]:e.followups??[];return f(()=>{const e=l.current;e&&(e.scrollTop=e.scrollHeight)},[t,n]),/* @__PURE__ */w("div",{ref:l,role:"log","aria-label":e.title,"aria-live":"polite","aria-busy":"submitted"===n||"streaming"===n,className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto bg-gray-50 p-3",children:["loading"===o&&/* @__PURE__ */w("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
32
- /* @__PURE__ */k(m,{className:"h-3 w-3"}),a.loadingHistory]}),"failed"===o&&/* @__PURE__ */k(s,{tone:"warning",children:a.historyFailed}),0===t.length&&"idle"===o&&/* @__PURE__ */k("p",{className:"m-auto text-center text-sm text-gray-500",children:a.emptyState}),t.map((r,o)=>/* @__PURE__ */k(xe,{live:o===t.length-1&&("submitted"===n||"streaming"===n),message:r,toolLabels:e.toolLabels,labels:a,showReasoning:e.showReasoning,showToolOutput:e.showToolOutput,showUsage:e.showUsage,tableActions:e.tableActions,onApprove:e.onApprove,onLinkClick:e.onLinkClick,plans:i,userActions:e.userMessageActions},r.id)),e.onAsk&&/* @__PURE__ */k(ae,{questions:d,label:a.followups,onAsk:e.onAsk}),e.handedOver&&/* @__PURE__ */k("div",{role:"status",className:"text-center text-xs text-gray-500",children:a.teamJoined}),"submitted"===n&&/* @__PURE__ */w("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
33
- /* @__PURE__ */k(m,{className:"h-3 w-3"}),a.thinking]}),c&&/* @__PURE__ */w("div",{role:"alert",className:"flex flex-col items-start gap-2",children:[
34
- /* @__PURE__ */k(s,{tone:"danger",children:c.text}),c.retryable&&e.onRetry&&"error"===n&&/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:e.onRetry,children:a.retry})]})]})}var Ce={title:"Assistant",placeholder:"Ask a question…",inputLabel:"Message to the assistant",send:"Send",stop:"Stop",newChat:"New chat",open:"Open assistant",close:"Close assistant",thinking:"Thinking",loadingHistory:"Loading the conversation",historyFailed:"The earlier conversation could not be loaded.",emptyState:"Ask me anything to get started.",approvalNeeded:"Approval needed",approve:"Approve",deny:"Deny",approved:"Approved",declined:"Declined",toolFailed:"did not complete",toolDeclined:"was not approved",details:"Details",stepSources:"Where these figures came from",reasoning:"Reasoning",genericError:"Something went wrong. Please try again.",connectionDropped:"The connection dropped. Your question may still be answering; reopen the chat in a moment.",retry:"Retry",working:"Working",steps:"Steps",teamName:"Team",teamJoined:"A team member has joined",plan:"Plan",planSummary:"Plan: {done} of {total} done",planProposed:"waiting for your approval",planApproved:"approved, starting",planRunning:"in progress",planCompleted:"finished",planFailed:"stopped — not every step ran",planDenied:"not approved — nothing was changed",planExpired:"expired — nothing was changed",planApprovalHeading:"Approve this plan of {count} steps",approvePlan:"Approve plan",replyStats:"{tokens} tokens · {seconds} s · {rate} tok/s",replyTokens:"{tokens} tokens",streaming:"Streaming",streamingRate:"Streaming · ~{rate} tok/s",followups:"Suggested follow-up questions"},je=(e,t)=>`${e.replace(/\/+$/,"")}/${t}`;function Ae(e){return je(e,"assistant/chat/")}function Se(e,t){return je(e,`assistant/chat/${encodeURIComponent(t)}/`)}function $e(e){const t=h(e);t.current=e;const n=h(e.conversationId?{id:e.conversationId}:null),[r,o]=g("idle"),[a,s]=g(!1),[l,i]=g(null),[c,u]=g([]),[p,d]=g(n.current),m=b(e=>{n.current=e,d(e)},[]),v=b((e,n)=>(t.current.fetch??fetch)(e,n),[]),k=y(()=>new C({api:Ae(e.apiBase),fetch:v,prepareSendMessagesRequest:async({messages:e})=>{const{apiBase:r,getHeaders:o,credentials:a}=t.current;return{api:Ae(r),body:_(e,n.current?.id??null),headers:await(o?.())??{},...a?{credentials:a}:{}}}}),[v]),w=A({transport:k,sendAutomaticallyWhen:j,onData:e=>{if("data-error"===e.type)return void i(e.data.code);if("data-followups"===e.type)return void u(function(e){const t=e?.questions;if(!Array.isArray(t))return[];const n=[];for(const e of t){if("string"!=typeof e)continue;const t=e.trim();!t||t.includes("\n")||n.includes(t)||n.push(t)}return n.slice(0,3)}(e.data));if("data-conversation"!==e.type)return;const{id:r,guest_token:o}=e.data,a=n.current,s=o??(a?.id===r?a.guestToken:void 0);a&&a.id===r&&a.guestToken===s||(m(s?{id:r,guestToken:s}:{id:r}),t.current.onConversation?.(n.current))}}),{setMessages:x,stop:N}=w,S=b(async(e,n)=>{const{apiBase:r,getHeaders:a,credentials:l,onConversation:i}=t.current;o("loading"),u([]);try{const t=await v(Se(r,e),{method:"GET",headers:await(a?.())??{},...l?{credentials:l}:{},signal:n});if(n.aborted)return;if(404===t.status)return m(null),i?.(null),void o("idle");if(!t.ok)throw new Error(`history ${t.status}`);const c=await t.json();if(n.aborted)return;s(!0===c.handed_over),x(e=>e.length>0?e:U(c)),o("idle")}catch{n.aborted||o("failed")}},[v,x,m]),$=e.conversationId??null;f(()=>{if($===(n.current?.id??null)&&w.messages.length>0)return;if(null===$)return n.current&&(m(null),N(),x([]),u([])),void o("idle");n.current?.id===$||m({id:$});const e=new AbortController;return S($,e.signal),()=>e.abort()},[$,S,x,N,m]);const R=b(async e=>{const r=n.current?.id;if(r)try{const{apiBase:o,getHeaders:a,credentials:l}=t.current,i=await v(Se(o,r),{method:"GET",headers:await(a?.())??{},...l?{credentials:l}:{},...e?{signal:e}:{}});if(!i.ok||e?.aborted||n.current?.id!==r)return;const c=await i.json();s(!0===c.handed_over);const u=U(c).filter(e=>e.metadata?.source);if(0===u.length)return;x(e=>{const t=new Set(e.map(e=>e.id)),n=u.filter(e=>!t.has(e.id));return n.length>0?[...e,...n]:e})}catch{}},[v,x]),T=h(R);T.current=R;const{status:I}=w,D="submitted"===I||"streaming"===I,M=h(!1),O=h(!1),L=!!e.subscribe;f(()=>{const e=M.current&&!D;if(M.current=D,!e)return;if(L&&!O.current)return;O.current=!1;const t=new AbortController;return T.current(t.signal),()=>t.abort()},[D,L]);const P=h(D);P.current=D;const E=p?.id,J=p?.guestToken;f(()=>{const e=n.current,r=t.current.subscribe;if(e&&r)return r(e,()=>{P.current?O.current=!0:T.current()})??void 0},[E,J]);const F=b(e=>{const t=e.trim();t&&(i(null),u([]),w.sendMessage({text:t}))},[w]),W=b(()=>{B(w.messages)&&(i(null),u([]),w.regenerate())},[w]),H=b((e,t)=>{i(null),u([]),w.addToolApprovalResponse({id:e,approved:t})},[w]),z=b(()=>{N(),m(null),x([]),o("idle"),s(!1),i(null),u([]),t.current.onConversation?.(null)},[x,N,m]);return{messages:w.messages,status:w.status,error:w.error,errorCode:l,canRetry:B(w.messages),retry:W,historyState:r,handedOver:a,followups:c,send:F,stop:N,approve:H,reset:z}}function Re(e){const t={...Ce,...e.labels},n=e.variant??"panel",r=$e(e),o="submitted"===r.status||"streaming"===r.status,a=h(e.onBusyChange);a.current=e.onBusyChange,f(()=>{a.current?.(o)},[o]);const s="window"===n,i=e.showHeader??"window"!==n,c=e.title??t.title,u=L(r.messages),m=h(!1),{send:g}=r;return f(()=>{m.current||e.conversationId||!e.initialQuestion?.trim()||(m.current=!0,g(e.initialQuestion))},[]),/* @__PURE__ */w("section",{"aria-label":c,className:`flex h-full min-h-0 flex-col bg-white text-gray-900 ${e.className??""}`.trim(),children:[i&&/* @__PURE__ */w("header",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2",children:[
35
- /* @__PURE__ */k("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:c}),r.messages.length>0&&/* @__PURE__ */k(p,{size:"sm",variant:"ghost",onClick:r.reset,children:t.newChat}),e.onClose&&/* @__PURE__ */k(l,{size:"sm","aria-label":t.close,onClick:e.onClose,children:/* @__PURE__ */k(d,{name:"close"})})]}),
36
- /* @__PURE__ */k(Ne,{messages:r.messages,status:r.status,error:r.error,errorCode:r.errorCode,onRetry:r.canRetry?r.retry:void 0,history:r.historyState,handedOver:r.handedOver,labels:t,title:c,toolLabels:e.toolLabels,showReasoning:s&&!0===e.showReasoning,showToolOutput:s,showUsage:s&&!0===e.showUsage,tableActions:e.tableActions,onApprove:r.approve,onLinkClick:e.onLinkClick,userMessageActions:e.userMessageActions,followups:r.followups,onAsk:r.send}),u&&/* @__PURE__ */k(re,{plan:u,labels:t},u.id),
37
- /* @__PURE__ */k(S,{labels:t,placeholder:e.placeholder??t.placeholder,busy:o,focusWhen:e.focusComposer,onSend:r.send,onStop:r.stop,onNewChat:!i&&!1!==e.showNewChat&&r.messages.length>0?r.reset:void 0,actions:e.composerActions})]})}function Te(e){const t={...Ce,...e.labels},[n,r]=g(e.defaultOpen??!1),o=v(),a=h(null),s=h(n),l=t=>{r(t),e.onOpenChange?.(t)};return f(()=>{s.current&&!n&&a.current?.focus(),s.current=n},[n]),/* @__PURE__ */w("div",{className:"rosh-assistant",style:{display:"contents"},children:[n&&/* @__PURE__ */k("div",{id:o,role:"dialog","aria-label":e.title??t.title,onKeyDown:e=>{"Escape"===e.key&&l(!1)},className:"fixed inset-x-2 bottom-20 z-[var(--z-window,1000)] h-[min(34rem,calc(100dvh-6rem))] overflow-hidden rounded-xl border border-gray-200 shadow-xl sm:inset-x-auto sm:right-4 sm:w-96",children:/* @__PURE__ */k(Re,{...e,onClose:()=>l(!1),focusComposer:!0})}),
38
- /* @__PURE__ */k("button",{ref:a,type:"button","aria-expanded":n,"aria-controls":n?o:void 0,"aria-label":n?t.close:t.open,onClick:()=>l(!n),className:"fixed bottom-4 right-4 z-[var(--z-window,1000)] flex h-12 w-12 items-center justify-center rounded-full shadow-lg bg-[var(--assistant-launcher-bg,var(--color-blue-600))] text-[var(--assistant-launcher-ink,var(--color-white))] hover:bg-[var(--assistant-launcher-bg-hover,var(--color-blue-700))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--assistant-launcher-bg,var(--color-blue-600))]",children:/* @__PURE__ */k(d,n?{name:"close",size:20}:{name:"chat-bubble-left-right",size:22})})]})}function _e(e){if("bubble"===e.variant)/* @__PURE__ */return k(Te,{...e});const t="window"!==e.variant;/* @__PURE__ */
39
- return k(Re,{...e,className:`${t?"border-l border-gray-200":""} ${e.className??""}`.trim()})}export{le as ApprovalCard,_e as AssistantChat,xe as AssistantMessage,Ce as DEFAULT_ASSISTANT_CHAT_LABELS,oe as PlanApprovalCard,re as PlanChecklist,ue as ToolStep,_ as buildRequestBody,de as estimateTokens,W as failureView,ge as finishedStats,J as isDroppedConnection,fe as liveStats,U as messagesFromHistory,L as pinnedPlan,O as plansOf,pe as tokensPerSecond,R as toolSummariesOf};
29
+ /* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:()=>r(s,!1),children:n.deny})]})]})}var de={running:"active",done:"complete",failed:"failed",declined:"stopped",waiting:"waiting"};function pe(e,t,n){return function(e,t,n,r,a,o){const s=Q(n,a),l=Z(n,r,a),i=(e,t)=>({kind:e,base:t,subject:l,text:l?`${t} ${l}`:t});switch(e){case"output-available":return i("done",s.done??s.label);case"output-error":return i("failed",`${s.label} ${o.toolFailed}`);case"output-denied":return i("declined",`${s.label} ${o.toolDeclined}`);case"approval-requested":return i("waiting",`${o.approvalNeeded}: ${s.label}`);case"approval-responded":return!1===t?i("declined",`${s.label} — ${o.declined}`):i("running",`${o.approved}: ${s.running??s.label}`);default:return i("running",s.running??s.label)}}(e.state,e.approved,e.toolName,e.input,t,n)}function me({tool:e,summary:n,toolLabels:r,labels:a,showOutput:o}){const s=pe(e,r,a),l=X(e.input),i=o&&"output-available"===e.state?X(e.output):[],c=o&&"output-error"===e.state&&e.errorText?e.errorText:"",u="output-available"===e.state&&n?n.rows:[];let d=null;return(l.length>0||i.length>0||c)&&(d=/* @__PURE__ */x("details",{className:u.length>0?"mt-1":void 0,children:[
30
+ /* @__PURE__ */k("summary",{className:"cursor-pointer select-none",children:a.details}),
31
+ /* @__PURE__ */x("div",{className:"mt-1 space-y-2",children:[l.length>0&&/* @__PURE__ */k(ce,{rows:l}),i.length>0&&/* @__PURE__ */k(ce,{rows:i}),c&&/* @__PURE__ */k("div",{className:"text-red-600",children:c})]})]})),/* @__PURE__ */x(t,{label:s.base,description:s.subject||void 0,status:de[s.kind],children:[u.length>0&&/* @__PURE__ */k(ce,{rows:u,label:a.stepSources}),d]})}function he(e,t){return e>0&&t>=100?e/(t/1e3):null}function ge(e){return Math.ceil(e.length/4)}var fe=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),ve=e=>Math.round(e).toLocaleString();function be(e,t){const n=he(e.output_tokens,e.generation_ms);return null===n?fe(t.replyTokens,{tokens:ve(e.output_tokens)}):fe(t.replyStats,{tokens:ve(e.output_tokens),seconds:(e.generation_ms/1e3).toFixed(1),rate:ve(n)})}function ye(e,t,n){const r=t>=1e3?he(ge(e),t):null;return null===r?n.streaming:fe(n.streamingRate,{rate:ve(r)})}function we(e){if("chart"!==e.lang)return null;if(!e.closed)/* @__PURE__ */return k(d,{height:200});const t=c(e.code);return t?/* @__PURE__ */k(u,{spec:t}):null}function ke(e,t){return"approval-responded"===e.state&&t.some(t=>{return t.toolName===e.toolName&&"approval-requested"!==t.state&&(t.toolCallId===e.toolCallId||(n=t.input,r=e.input,JSON.stringify(n)===JSON.stringify(r)));var n,r})}function xe(e,t,n,r){const a=e.flatMap(e=>"tool"===e.kind?[pe(e.tool,n,r)]:[]);if(t){const e=a.find(e=>"running"===e.kind);return e?e.base:r.working}const o=[...new Set(a.map(e=>e.base))];return o.length>0?o.join(" · "):r.reasoning}function Ne({message:e,live:t,labels:n}){const r=I(e),a=r.length>0,o=g(null),[s,l]=f(0);v(()=>{if(!t)return;null===o.current&&(o.current=performance.now());const e=setInterval(()=>l(performance.now()-(o.current??performance.now())),500);return()=>clearInterval(e)},[t]);const i=e.metadata?.usage;let c=null;return t?c=a?ye(r,s,n):null:i&&(c=be(i,n)),c?/* @__PURE__ */k("div",{className:"px-1 text-xs tabular-nums text-gray-500",children:c}):null}function Ce({text:e,actions:t}){const n=a(),r=/* @__PURE__ */k("div",{className:"max-w-[85%] whitespace-pre-wrap break-words rounded-2xl bg-blue-600 px-3 py-2 text-sm text-white",children:e});return t?.length?/* @__PURE__ */x("div",{className:"flex justify-end",onContextMenu:e=>n.open(e,void 0),children:[r,n.state&&/* @__PURE__ */k(o,{...n.props,"aria-label":e,items:t.map(t=>({key:t.key,label:t.label,onSelect:()=>t.onSelect(e)}))})]}):/* @__PURE__ */k("div",{className:"flex justify-end",children:r})}function je({message:r,toolLabels:a,labels:o,showReasoning:s,showToolOutput:l,showUsage:i,live:c,onApprove:u,plans:d,userActions:p,tableActions:m,onLinkClick:h,onRate:g}){const f=r.metadata?.source;if("system"===f){const e=I(r);return e?/* @__PURE__ */k("div",{className:"text-center text-xs text-gray-500",children:e}):null}if("user"===r.role){const e=I(r);return e?/* @__PURE__ */k(Ce,{text:e,actions:p}):null}const v=r.parts.map(T),b=_(r),y=[],w=[];let N=-1;const C=e=>{N<0&&(N=y.push(null)-1),w.push(e)};if(r.parts.forEach((e,t)=>{if("text"===e.type)return void(e.text.trim()&&y.push(
32
+ /* @__PURE__ */k(n,{renderFence:we,tableActions:c?void 0:m,onLinkClick:h,children:e.text},t)));if("reasoning"===e.type)return void(s&&e.text.trim()&&C({kind:"reasoning",key:`r${t}`,text:e.text}));const r=v[t];r&&(ke(r,v.slice(t+1).filter(e=>null!==e))||("approval-requested"===r.state&&r.approvalId&&"propose_plan"===r.toolName?y.push(
33
+ /* @__PURE__ */k(se,{approvalId:r.approvalId,plan:d?.get(r.approvalId),input:r.input,labels:o,toolLabels:a,onApprove:u},r.toolCallId)):"approval-requested"===r.state&&r.approvalId?y.push(
34
+ /* @__PURE__ */k(ue,{tool:r,toolLabels:a,labels:o,onApprove:u},r.toolCallId)):C({kind:"tool",key:r.toolCallId,tool:r})))}),N>=0&&(y[N]=/* @__PURE__ */k(e,{summary:xe(w,c,a,o),busy:c,label:o.steps,children:w.map(e=>"tool"===e.kind?/* @__PURE__ */k(me,{tool:e.tool,summary:b.get(e.tool.toolCallId),toolLabels:a,labels:o,showOutput:l},e.key):/* @__PURE__ */k(t,{status:"complete",label:/* @__PURE__ */x("details",{children:[
35
+ /* @__PURE__ */k("summary",{className:"cursor-pointer select-none",children:o.reasoning}),
36
+ /* @__PURE__ */k("div",{className:"mt-1 whitespace-pre-wrap text-gray-500",children:e.text})]})},e.key))},"chain")),0===y.length)return null;const j=/* @__PURE__ */x("div",{className:"max-w-[92%] min-w-0 space-y-2 rounded-2xl bg-white px-3 py-2 text-gray-800 shadow-sm",children:["staff"===f&&/* @__PURE__ */k("div",{className:"text-xs font-medium text-blue-600",children:o.teamName}),y]}),A=i&&!f,S=r.metadata?.run_id,R=Boolean(g&&S&&!c&&!f);return A||R?/* @__PURE__ */x("div",{className:"flex flex-col items-start gap-1",children:[j,A&&/* @__PURE__ */k(Ne,{message:r,live:c,labels:o}),R&&g&&S&&/* @__PURE__ */k(ie,{initial:r.metadata?.rating,labels:o,onRate:e=>g(S,e)})]}):/* @__PURE__ */k("div",{className:"flex justify-start",children:j})}function Ae(e){const{messages:t,status:n,error:r,history:a,labels:o}=e,l=g(null),i=w(()=>function(e){const t=/* @__PURE__ */new Map;for(const n of U(e).values())t.set(n.approval_id,n);return t}(t),[t]),c=r?W(r,e.errorCode??null,o):null,u=t[t.length-1],d="ready"!==n||r||e.handedOver||"assistant"!==u?.role||!e.onAsk?[]:e.followups??[];return v(()=>{const e=l.current;e&&(e.scrollTop=e.scrollHeight)},[t,n]),/* @__PURE__ */x("div",{ref:l,role:"log","aria-label":e.title,"aria-live":"polite","aria-busy":"submitted"===n||"streaming"===n,className:"flex min-h-0 flex-1 flex-col gap-3 overflow-auto bg-gray-50 p-3",children:["loading"===a&&/* @__PURE__ */x("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
37
+ /* @__PURE__ */k(h,{className:"h-3 w-3"}),o.loadingHistory]}),"failed"===a&&/* @__PURE__ */k(s,{tone:"warning",children:o.historyFailed}),0===t.length&&"idle"===a&&/* @__PURE__ */k("p",{className:"m-auto text-center text-sm text-gray-500",children:o.emptyState}),t.map((r,a)=>/* @__PURE__ */k(je,{live:a===t.length-1&&("submitted"===n||"streaming"===n),message:r,toolLabels:e.toolLabels,labels:o,showReasoning:e.showReasoning,showToolOutput:e.showToolOutput,showUsage:e.showUsage,tableActions:e.tableActions,onApprove:e.onApprove,onLinkClick:e.onLinkClick,plans:i,userActions:e.userMessageActions,onRate:e.onRate},r.id)),e.onAsk&&/* @__PURE__ */k(le,{questions:d,label:o.followups,onAsk:e.onAsk}),e.handedOver&&/* @__PURE__ */k("div",{role:"status",className:"text-center text-xs text-gray-500",children:o.teamJoined}),"submitted"===n&&/* @__PURE__ */x("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
38
+ /* @__PURE__ */k(h,{className:"h-3 w-3"}),o.thinking]}),c&&/* @__PURE__ */x("div",{role:"alert",className:"flex flex-col items-start gap-2",children:[
39
+ /* @__PURE__ */k(s,{tone:"danger",children:c.text}),c.retryable&&e.onRetry&&"error"===n&&/* @__PURE__ */k(p,{size:"sm",variant:"secondary",onClick:e.onRetry,children:o.retry})]})]})}var Se={title:"Assistant",placeholder:"Ask a question…",inputLabel:"Message to the assistant",send:"Send",stop:"Stop",newChat:"New chat",open:"Open assistant",close:"Close assistant",thinking:"Thinking",loadingHistory:"Loading the conversation",historyFailed:"The earlier conversation could not be loaded.",emptyState:"Ask me anything to get started.",approvalNeeded:"Approval needed",approve:"Approve",deny:"Deny",approved:"Approved",declined:"Declined",toolFailed:"did not complete",toolDeclined:"was not approved",details:"Details",stepSources:"Where these figures came from",reasoning:"Reasoning",genericError:"Something went wrong. Please try again.",connectionDropped:"The connection dropped. Your question may still be answering; reopen the chat in a moment.",retry:"Retry",working:"Working",steps:"Steps",teamName:"Team",teamJoined:"A team member has joined",plan:"Plan",planSummary:"Plan: {done} of {total} done",planProposed:"waiting for your approval",planApproved:"approved, starting",planRunning:"in progress",planCompleted:"finished",planFailed:"stopped — not every step ran",planDenied:"not approved — nothing was changed",planExpired:"expired — nothing was changed",planApprovalHeading:"Approve this plan of {count} steps",approvePlan:"Approve plan",replyStats:"{tokens} tokens · {seconds} s · {rate} tok/s",replyTokens:"{tokens} tokens",streaming:"Streaming",streamingRate:"Streaming · ~{rate} tok/s",followups:"Suggested follow-up questions",rateAnswer:"Rate this answer",rateUp:"Helpful",rateDown:"Not helpful",rateNote:"What was wrong? (optional)",rateNoteSend:"Send",rateNoteSkip:"Skip",rateThanks:"Thanks for telling us.",rateFailed:"Your rating could not be saved."},Re=(e,t)=>`${e.replace(/\/+$/,"")}/${t}`;function Te(e){return Re(e,"assistant/chat/")}function _e(e,t){return Re(e,`assistant/chat/${encodeURIComponent(t)}/`)}function Ie(e){const t=g(e);t.current=e;const n=g(e.conversationId?{id:e.conversationId}:null),[r,a]=f("idle"),[o,s]=f(!1),[l,i]=f(null),[c,u]=f([]),[d,p]=f(n.current),m=y(e=>{n.current=e,p(e)},[]),h=y((e,n)=>(t.current.fetch??fetch)(e,n),[]),b=w(()=>new j({api:Te(e.apiBase),fetch:h,prepareSendMessagesRequest:async({messages:e})=>{const{apiBase:r,getHeaders:a,credentials:o}=t.current;return{api:Te(r),body:$(e,n.current?.id??null),headers:await(a?.())??{},...o?{credentials:o}:{}}}}),[h]),k=S({transport:b,sendAutomaticallyWhen:A,onData:e=>{if("data-error"===e.type)return void i(e.data.code);if("data-followups"===e.type)return void u(function(e){const t=e?.questions;if(!Array.isArray(t))return[];const n=[];for(const e of t){if("string"!=typeof e)continue;const t=e.trim();!t||t.includes("\n")||n.includes(t)||n.push(t)}return n.slice(0,3)}(e.data));if("data-conversation"!==e.type)return;const{id:r,guest_token:a}=e.data,o=n.current,s=a??(o?.id===r?o.guestToken:void 0);o&&o.id===r&&o.guestToken===s||(m(s?{id:r,guestToken:s}:{id:r}),t.current.onConversation?.(n.current))}}),{setMessages:x,stop:N}=k,C=y(async(e,n)=>{const{apiBase:r,getHeaders:o,credentials:l,onConversation:i}=t.current;a("loading"),u([]);try{const t=await h(_e(r,e),{method:"GET",headers:await(o?.())??{},...l?{credentials:l}:{},signal:n});if(n.aborted)return;if(404===t.status)return m(null),i?.(null),void a("idle");if(!t.ok)throw new Error(`history ${t.status}`);const c=await t.json();if(n.aborted)return;s(!0===c.handed_over),x(e=>e.length>0?e:P(c)),a("idle")}catch{n.aborted||a("failed")}},[h,x,m]),R=e.conversationId??null;v(()=>{if(R===(n.current?.id??null)&&k.messages.length>0)return;if(null===R)return n.current&&(m(null),N(),x([]),u([])),void a("idle");n.current?.id===R||m({id:R});const e=new AbortController;return C(R,e.signal),()=>e.abort()},[R,C,x,N,m]);const T=y(async e=>{const r=n.current?.id;if(r)try{const{apiBase:a,getHeaders:o,credentials:l}=t.current,i=await h(_e(a,r),{method:"GET",headers:await(o?.())??{},...l?{credentials:l}:{},...e?{signal:e}:{}});if(!i.ok||e?.aborted||n.current?.id!==r)return;const c=await i.json();s(!0===c.handed_over);const u=P(c).filter(e=>e.metadata?.source);if(0===u.length)return;x(e=>{const t=new Set(e.map(e=>e.id)),n=u.filter(e=>!t.has(e.id));return n.length>0?[...e,...n]:e})}catch{}},[h,x]),_=g(T);_.current=T;const{status:I}=k,D="submitted"===I||"streaming"===I,L=g(!1),O=g(!1),U=!!e.subscribe;v(()=>{const e=L.current&&!D;if(L.current=D,!e)return;if(U&&!O.current)return;O.current=!1;const t=new AbortController;return _.current(t.signal),()=>t.abort()},[D,U]);const M=g(D);M.current=D;const E=d?.id,J=d?.guestToken;v(()=>{const e=n.current,r=t.current.subscribe;if(e&&r)return r(e,()=>{M.current?O.current=!0:_.current()})??void 0},[E,J]);const F=y(e=>{const t=e.trim();t&&(i(null),u([]),k.sendMessage({text:t}))},[k]),B=y(()=>{G(k.messages)&&(i(null),u([]),k.regenerate())},[k]),z=y((e,t)=>{i(null),u([]),k.addToolApprovalResponse({id:e,approved:t})},[k]),W=y(()=>{N(),m(null),x([]),a("idle"),s(!1),i(null),u([]),t.current.onConversation?.(null)},[x,N,m]);return{conversationId:d?.id??null,messages:k.messages,status:k.status,error:k.error,errorCode:l,canRetry:G(k.messages),retry:B,historyState:r,handedOver:o,followups:c,send:F,stop:N,approve:z,reset:W}}function $e(e){const t={...Se,...e.labels},n=e.variant??"panel",r=Ie(e),a="submitted"===r.status||"streaming"===r.status,o=g(e.onBusyChange);o.current=e.onBusyChange,v(()=>{o.current?.(a)},[a]);const s="window"===n,l=e.showHeader??"window"!==n,c=e.title??t.title,u=M(r.messages),{onRate:d}=e,{conversationId:h}=r,f=g(!1),{send:b}=r;return v(()=>{f.current||e.conversationId||!e.initialQuestion?.trim()||(f.current=!0,b(e.initialQuestion))},[]),/* @__PURE__ */x("section",{"aria-label":c,className:`flex h-full min-h-0 flex-col bg-white text-gray-900 ${e.className??""}`.trim(),children:[l&&/* @__PURE__ */x("header",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2",children:[
40
+ /* @__PURE__ */k("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:c}),r.messages.length>0&&/* @__PURE__ */k(p,{size:"sm",variant:"ghost",onClick:r.reset,children:t.newChat}),e.onClose&&/* @__PURE__ */k(i,{size:"sm","aria-label":t.close,onClick:e.onClose,children:/* @__PURE__ */k(m,{name:"close"})})]}),
41
+ /* @__PURE__ */k(Ae,{messages:r.messages,status:r.status,error:r.error,errorCode:r.errorCode,onRetry:r.canRetry?r.retry:void 0,history:r.historyState,handedOver:r.handedOver,labels:t,title:c,toolLabels:e.toolLabels,showReasoning:s&&!0===e.showReasoning,showToolOutput:s,showUsage:s&&!0===e.showUsage,tableActions:e.tableActions,onApprove:r.approve,onLinkClick:e.onLinkClick,userMessageActions:e.userMessageActions,followups:r.followups,onAsk:r.send,onRate:d&&h?(e,t)=>d({conversationId:h,runId:e,rating:t}):void 0}),u&&/* @__PURE__ */k(oe,{plan:u,labels:t},u.id),
42
+ /* @__PURE__ */k(R,{labels:t,placeholder:e.placeholder??t.placeholder,busy:a,focusWhen:e.focusComposer,onSend:r.send,onStop:r.stop,onNewChat:!l&&!1!==e.showNewChat&&r.messages.length>0?r.reset:void 0,actions:e.composerActions})]})}function De(e){const t={...Se,...e.labels},[n,r]=f(e.defaultOpen??!1),a=b(),o=g(null),s=g(n),l=t=>{r(t),e.onOpenChange?.(t)};return v(()=>{s.current&&!n&&o.current?.focus(),s.current=n},[n]),/* @__PURE__ */x("div",{className:"rosh-assistant",style:{display:"contents"},children:[n&&/* @__PURE__ */k("div",{id:a,role:"dialog","aria-label":e.title??t.title,onKeyDown:e=>{"Escape"===e.key&&l(!1)},className:"fixed inset-x-2 bottom-20 z-[var(--z-window,1000)] h-[min(34rem,calc(100dvh-6rem))] overflow-hidden rounded-xl border border-gray-200 shadow-xl sm:inset-x-auto sm:right-4 sm:w-96",children:/* @__PURE__ */k($e,{...e,onClose:()=>l(!1),focusComposer:!0})}),
43
+ /* @__PURE__ */k("button",{ref:o,type:"button","aria-expanded":n,"aria-controls":n?a:void 0,"aria-label":n?t.close:t.open,onClick:()=>l(!n),className:"fixed bottom-4 right-4 z-[var(--z-window,1000)] flex h-12 w-12 items-center justify-center rounded-full shadow-lg bg-[var(--assistant-launcher-bg,var(--color-blue-600))] text-[var(--assistant-launcher-ink,var(--color-white))] hover:bg-[var(--assistant-launcher-bg-hover,var(--color-blue-700))] focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--assistant-launcher-bg,var(--color-blue-600))]",children:/* @__PURE__ */k(m,n?{name:"close",size:20}:{name:"chat-bubble-left-right",size:22})})]})}function Le(e){if("bubble"===e.variant)/* @__PURE__ */return k(De,{...e});const t="window"!==e.variant;/* @__PURE__ */
44
+ return k($e,{...e,className:`${t?"border-l border-gray-200":""} ${e.className??""}`.trim()})}export{ue as ApprovalCard,Le as AssistantChat,je as AssistantMessage,Se as DEFAULT_ASSISTANT_CHAT_LABELS,se as PlanApprovalCard,oe as PlanChecklist,me as ToolStep,$ as buildRequestBody,ge as estimateTokens,W as failureView,be as finishedStats,B as isDroppedConnection,ye as liveStats,P as messagesFromHistory,M as pinnedPlan,U as plansOf,he as tokensPerSecond,_ as toolSummariesOf};