efficient-shell 13.16.0 → 13.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/{Browser-4KWGT3FG.js → Browser-ORLSC6T4.js} +15 -15
- package/dist/Calculator-4UBMDAJO.js +29 -0
- package/dist/{CurrencyConverter-X5ENBDLK.js → CurrencyConverter-H3HHXXKT.js} +6 -6
- package/dist/{Files-NT76VUHQ.js → Files-PI3Z4TAO.js} +53 -53
- package/dist/Notepad-6FPZHJQ7.js +24 -0
- package/dist/PdfViewer-EELX35ZI.js +1 -0
- package/dist/{PomodoroTimer-KDXH5M3Q.js → PomodoroTimer-JVCYYGRD.js} +16 -16
- package/dist/{Preview-QNJD5PVD.js → Preview-4XSAIYMZ.js} +21 -21
- package/dist/{Stock-JR77FPOD.js → Stock-S266KGAF.js} +4 -4
- package/dist/{Weather-MGSDU3M5.js → Weather-TE4TTTQA.js} +19 -19
- package/dist/{WorldClock-GGAYPYIO.js → WorldClock-5TPBHBYA.js} +6 -6
- package/dist/ai/index.js +23 -23
- package/dist/apps/ImageAnnotator.js +1 -1
- package/dist/apps/index.js +1 -1
- package/dist/bin/browser-check.js +1 -1
- package/dist/bin/media-host-check.js +1 -1
- package/dist/bin/ui-check.js +1 -1
- package/dist/brand.css +1 -1
- package/dist/charts/BoxPlotChart.js +1 -1
- package/dist/charts/CandlestickChart.js +1 -1
- package/dist/charts/CartesianPlot.js +1 -1
- package/dist/charts/ColumnChart.js +1 -1
- package/dist/charts/FunnelChart.js +1 -1
- package/dist/charts/HeatmapChart.js +1 -1
- package/dist/charts/HistogramChart.js +1 -1
- package/dist/charts/PieChart.js +1 -1
- package/dist/charts/RangeChart.js +1 -1
- package/dist/charts/SankeyChart.js +1 -1
- package/dist/charts/ScatterChart.js +1 -1
- package/dist/charts/SpecChart.js +1 -1
- package/dist/charts/TimeSeriesChart.js +1 -1
- package/dist/charts/TreemapChart.js +1 -1
- package/dist/charts/WaterfallChart.js +1 -1
- package/dist/chunk-2WBKQOLF.js +2 -0
- package/dist/{chunk-QE2JX7D4.js → chunk-34HRPEQD.js} +1 -1
- package/dist/{chunk-OWAYSIQH.js → chunk-42DF7CDB.js} +5 -5
- package/dist/chunk-43JCG6EB.js +1 -0
- package/dist/{chunk-J4CVYOY3.js → chunk-4SYPNE3P.js} +1 -1
- package/dist/{chunk-OEPQIIYL.js → chunk-63E4ZZYI.js} +1 -1
- package/dist/{chunk-CKTFXTJL.js → chunk-6OCA7RKQ.js} +1 -1
- package/dist/{chunk-NISLELJF.js → chunk-6UGMQZTF.js} +1 -1
- package/dist/{chunk-VYHVIKP6.js → chunk-7SVSHJOO.js} +10 -10
- package/dist/{chunk-W6NGPSMM.js → chunk-ABPVCVCT.js} +12 -12
- package/dist/{chunk-FKMARSJZ.js → chunk-BNI3N4TT.js} +2 -2
- package/dist/{chunk-IJNQ2BUY.js → chunk-CILE3ZCC.js} +2 -2
- package/dist/{chunk-XHD6Q6JV.js → chunk-EFO72DEI.js} +1 -1
- package/dist/{chunk-IJJNJJ6I.js → chunk-EG5MU7XL.js} +1 -1
- package/dist/{chunk-UC5IC3AM.js → chunk-EHM3ZVVT.js} +4 -4
- package/dist/{chunk-SHHRC5XK.js → chunk-ENVANMHI.js} +7 -7
- package/dist/{chunk-UFWBPTCM.js → chunk-F5F5RKB5.js} +5 -5
- package/dist/{chunk-OLSA36VX.js → chunk-FUPU7Z2G.js} +6 -6
- package/dist/{chunk-YDFDTRZF.js → chunk-G7SILKUY.js} +5 -5
- package/dist/{chunk-BVX7LUAW.js → chunk-GEQZUCEO.js} +6 -6
- package/dist/{chunk-J6QC45OS.js → chunk-HC5KQZFG.js} +5 -5
- package/dist/{chunk-GNXAVDZD.js → chunk-J5NBRYBF.js} +1 -1
- package/dist/chunk-KBQXXPFK.js +1 -0
- package/dist/{chunk-MHQW6NAE.js → chunk-KBZMOPPH.js} +10 -10
- package/dist/{chunk-N5KJLHYI.js → chunk-LADP6AJY.js} +5 -5
- package/dist/{chunk-IG3K6AGW.js → chunk-LUCO5PS6.js} +1 -1
- package/dist/chunk-M6UKCZHT.js +2 -0
- package/dist/{chunk-H5PSCQJ2.js → chunk-NVKRYUCM.js} +6 -6
- package/dist/{chunk-7IXU4YT4.js → chunk-OFFJHTNM.js} +4 -4
- package/dist/chunk-OTEAWX2C.js +1 -0
- package/dist/chunk-OUYGLDQN.js +24 -0
- package/dist/{chunk-7TJZ5AJE.js → chunk-QNXTVDIC.js} +6 -6
- package/dist/{chunk-PY4DTB6Y.js → chunk-QSJMLHBD.js} +1 -1
- package/dist/{chunk-IUQJGFEO.js → chunk-QTDR2CTB.js} +3 -3
- package/dist/{chunk-K2FVP22A.js → chunk-S43DEWMZ.js} +1 -1
- package/dist/{chunk-XXTAMF3O.js → chunk-S7YUQLBN.js} +6 -6
- package/dist/chunk-SHBZTW7P.js +5 -0
- package/dist/chunk-SM3N5UJ2.js +69 -0
- package/dist/{chunk-J4KPBR5B.js → chunk-TKCCJRPE.js} +1 -1
- package/dist/{chunk-YTDMCUL7.js → chunk-U5RG34NE.js} +10 -10
- package/dist/{chunk-NW5NSV7N.js → chunk-V6HKE4HV.js} +2 -2
- package/dist/{chunk-OIEFMLYI.js → chunk-VR6LMREE.js} +3 -3
- package/dist/{chunk-EJOKROMB.js → chunk-WHPYQOXA.js} +5 -5
- package/dist/{chunk-WLBWACKP.js → chunk-WJTNQ7YD.js} +1 -1
- package/dist/{chunk-P5C7DI5A.js → chunk-WPGSU4QG.js} +5 -5
- package/dist/{chunk-75R3EKWZ.js → chunk-XD3M5ZXM.js} +3 -3
- package/dist/chunk-ZI2FDUYJ.js +99 -0
- package/dist/data/EntityList.js +1 -1
- package/dist/data/ResizableTable.js +1 -1
- package/dist/forms/BorderInput.js +1 -1
- package/dist/forms/BrandAssetEditor.js +1 -1
- package/dist/forms/ColorPicker.js +1 -1
- package/dist/forms/CornersInput.js +1 -1
- package/dist/forms/InputNumber.js +1 -1
- package/dist/forms/MediaLibrary.js +1 -1
- package/dist/forms/MediaUploadField.js +1 -1
- package/dist/forms/PositionInput.js +1 -1
- package/dist/forms/SidesInput.js +1 -1
- package/dist/forms/Slider.js +1 -1
- package/dist/forms/UnitMenu.js +1 -1
- package/dist/forms/WidestLabel.d.ts +26 -0
- package/dist/forms/WidestLabel.js +1 -0
- package/dist/forms/WidthsBar.js +1 -1
- package/dist/icons/brands.node.js +1 -1
- package/dist/icons/efficient-glyphs.js +1 -1
- package/dist/icons/efficient-looks.js +1 -1
- package/dist/icons/efficient.js +1 -1
- package/dist/icons/index.js +1 -1
- package/dist/icons/looks/map.js +1 -1
- package/dist/icons/payment.js +3 -3
- package/dist/icons/sets.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +117 -117
- package/dist/pdf/index.js +1 -1
- package/dist/shell/FitFrame.d.ts +46 -0
- package/dist/shell/FitFrame.js +2 -0
- package/dist/shell/LanguageSelect.js +1 -1
- package/dist/shell/SettingRow.js +1 -1
- package/dist/shell/SidebarLayout.js +1 -1
- package/dist/telemetry/index.js +1 -1
- package/dist/templates/ChatTemplate.js +1 -1
- package/dist/templates/DashboardTemplate.js +1 -1
- package/dist/templates/EmailTemplate.js +1 -1
- package/dist/ui/index.d.ts +2 -0
- package/dist/ui/index.js +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
- package/dist/Calculator-VURS4NAT.js +0 -29
- package/dist/Notepad-6AMNAYQQ.js +0 -24
- package/dist/PdfViewer-PFQGQRQX.js +0 -1
- package/dist/chunk-6QKTQOEV.js +0 -69
- package/dist/chunk-74SCWPQF.js +0 -1
- package/dist/chunk-JFOMAXD2.js +0 -99
- package/dist/chunk-OMOAD5LL.js +0 -1
- package/dist/chunk-QAAHFU2I.js +0 -1
- package/dist/chunk-XQVGBVHC.js +0 -5
- package/dist/chunk-YGKLZBWC.js +0 -24
- /package/dist/{chunk-VG6BT2UG.js → chunk-7UCZAUAU.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{AVAILABLE_CITIES as e,fetchCityWeather as t,cityClock as r,getCondition as n,toFahrenheit as s}from"./chunk-HYHZEQMG.js";import{loadAppearance as i,WidgetSettingsModal as a}from"./chunk-
|
|
1
|
+
import{AVAILABLE_CITIES as e,fetchCityWeather as t,cityClock as r,getCondition as n,toFahrenheit as s}from"./chunk-HYHZEQMG.js";import{loadAppearance as i,WidgetSettingsModal as a}from"./chunk-QSJMLHBD.js";import"./chunk-NHKT5IH6.js";import"./chunk-36BRD5J3.js";import"./chunk-JRQMX4PK.js";import"./chunk-LF27WIN2.js";import{useWidgetSettings as c}from"./chunk-ZI2FDUYJ.js";import"./chunk-4LXCCZDM.js";import"./chunk-KNUR2UEG.js";import"./chunk-JDCM2VHG.js";import"./chunk-M2TQOJ3G.js";import"./chunk-FBZUEZK7.js";import"./chunk-5A7MWTXX.js";import"./chunk-BG3C4ALM.js";import"./chunk-GMLOMLCS.js";import"./chunk-UTQN5AIO.js";import"./chunk-EIFNESXS.js";import"./chunk-SXHV5OLA.js";import"./chunk-SF4IIV5Z.js";import"./chunk-FRCTA5FS.js";import"./chunk-VWGWZY7A.js";import"./chunk-UVHXVSB2.js";import"./chunk-WRV6QKJN.js";import"./chunk-AW7TOB6N.js";import"./chunk-4U5M37SF.js";import"./chunk-F3ZOO23R.js";import"./chunk-2QY5BJLA.js";import"./chunk-UGTRSRIW.js";import{useShellPrefs as o}from"./chunk-DPFEQQQU.js";import"./chunk-DWGYC7OD.js";import"./chunk-YDJ5IZOU.js";import"./chunk-THAPVKEJ.js";import"./chunk-URHGHXDN.js";import"./chunk-5QFPTDQF.js";import"./chunk-UTISUEO4.js";import"./chunk-BUFAJJDZ.js";import"./chunk-ISVODSRP.js";import"./chunk-J75ZT2JQ.js";import{LoadingSpinner as m}from"./chunk-R2VKEMZH.js";import"./chunk-BWJZTHZ6.js";import"./chunk-TD3ZQD5R.js";import"./chunk-F2RAIGCG.js";import"./chunk-PGN5ME7B.js";import"./chunk-62LW225J.js";import"./chunk-VY3UA6AR.js";import"./chunk-WCCS4VFE.js";import"./chunk-ZDXRSY2Y.js";import"./chunk-STKJA4PV.js";import"./chunk-M6UKCZHT.js";import"./chunk-UQYNPYF4.js";import"./chunk-MRJKZWWV.js";import"./chunk-TWVUQUUD.js";import"./chunk-5FYDNH4Y.js";import"./chunk-LNXBTK7Q.js";import"./chunk-MAFUXCPZ.js";import"./chunk-IUVGHHR3.js";import"./chunk-C3QOHMR6.js";import{useState as h,useEffect as l,useCallback as p}from"react";import{jsxs as u,Fragment as d,jsx as k}from"react/jsx-runtime";var j="world_clock_appearance",g=["London","Shanghai","New York"];function x(){const{prefs:x,save:b}=o(),[f,N]=h(()=>i(j)),[y,v]=h(!1),[F,w]=h([]),[S,D]=h(f),U={useFahrenheit:!!x.weather_prefs?.useFahrenheit},[C,H]=h(U),[J,Z]=h(()=>/* @__PURE__ */new Date);l(()=>{const e=setInterval(()=>Z(/* @__PURE__ */new Date),3e4);return()=>clearInterval(e)},[]);const A=Object.fromEntries(Object.entries(e).map(([e,t])=>[t.tz,e])),Q=x.world_clocks,R=(()=>{if(!Array.isArray(Q)||0===Q.length)return g;const t=[];for(const r of Q){const n=e[r]?r:A[r];n&&!t.includes(n)&&t.push(n)}return t.length?t:g})(),[T,M]=h({}),[O,I]=h(!0);l(()=>{let e=!1;return I(!0),(async()=>{const r={};await Promise.all(R.map(async e=>{const n=await t(e);n&&(r[e]=n)})),e||(M(r),I(!1))})(),()=>{e=!0}},[R.join(",")]),c(p(()=>{w([...R]),D({...f}),H({...U}),v(!0)},[R.join(","),f,U.useFahrenheit]));const V=e=>U.useFahrenheit?`${s(e)}°`:`${e}°`;/* @__PURE__ */
|
|
2
2
|
return u(d,{children:[
|
|
3
|
-
/* @__PURE__ */k("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */u("div",{className:"divide-y divide-gray-200",children:[
|
|
3
|
+
/* @__PURE__ */k("div",{style:{backgroundColor:`rgb(var(--taskbar-bg-rgb, 243 244 246) / ${f.activeOpacity/100})`,backdropFilter:f.activeBlur>0?`blur(${f.activeBlur}px)`:void 0},children:/* @__PURE__ */u("div",{className:"divide-y divide-gray-200",children:[O&&R.every(e=>!T[e])&&/* @__PURE__ */k(m,{size:"sm",padding:"py-6",label:"Loading"}),R.map(t=>{const s=T[t],{time:i,ampm:a}=r(e[t]?.tz,J);if(!s)/* @__PURE__ */
|
|
4
4
|
return u("div",{className:"px-4 py-3",children:[
|
|
5
5
|
/* @__PURE__ */u("div",{className:"flex items-baseline justify-between gap-2",children:[
|
|
6
6
|
/* @__PURE__ */k("span",{className:"text-base font-semibold tracking-tight text-ink-strongest truncate",children:t}),
|
|
@@ -10,7 +10,7 @@ return u("div",{className:"px-4 py-3",children:[
|
|
|
10
10
|
return u("div",{className:"px-4 py-3",children:[
|
|
11
11
|
/* @__PURE__ */u("div",{className:"flex items-baseline justify-between gap-2",children:[
|
|
12
12
|
/* @__PURE__ */k("span",{className:"text-base font-semibold tracking-tight text-ink-strongest truncate",children:t}),
|
|
13
|
-
/* @__PURE__ */k("span",{className:"text-2xl font-extralight leading-none tabular-nums tracking-tight text-ink-strongest shrink-0",children:
|
|
13
|
+
/* @__PURE__ */k("span",{className:"text-2xl font-extralight leading-none tabular-nums tracking-tight text-ink-strongest shrink-0",children:V(s.temp)})]}),
|
|
14
14
|
/* @__PURE__ */u("div",{className:"flex items-center justify-between gap-2 mt-2 text-2xs",children:[
|
|
15
15
|
/* @__PURE__ */u("div",{className:"flex items-center gap-2 min-w-0 text-ink-faint",children:[
|
|
16
16
|
/* @__PURE__ */k("span",{className:"text-base leading-none shrink-0",children:o}),
|
|
@@ -18,13 +18,13 @@ return u("div",{className:"px-4 py-3",children:[
|
|
|
18
18
|
/* @__PURE__ */k("span",{className:"text-3xs font-medium ml-0.5 opacity-70",children:a})]}),
|
|
19
19
|
/* @__PURE__ */k("span",{className:"text-gray-300 shrink-0",children:"·"}),
|
|
20
20
|
/* @__PURE__ */k("span",{className:"truncate",children:c})]}),
|
|
21
|
-
/* @__PURE__ */u("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",
|
|
22
|
-
/* @__PURE__ */u(a,{open:y,onClose:()=>v(!1),title:"World Clock Settings",appearance:
|
|
21
|
+
/* @__PURE__ */u("span",{className:"tabular-nums text-gray-500 shrink-0",children:["H:",V(s.high)," L:",V(s.low)]})]})]},t)})]})}),
|
|
22
|
+
/* @__PURE__ */u(a,{open:y,onClose:()=>v(!1),title:"World Clock Settings",appearance:S,onAppearanceChange:D,onSave:()=>{0!==F.length&&(b({world_clocks:F,weather_prefs:{...x.weather_prefs??{},useFahrenheit:C.useFahrenheit}}),N(S),localStorage.setItem(j,JSON.stringify(S)),v(!1))},children:[
|
|
23
23
|
/* @__PURE__ */u("div",{children:[
|
|
24
24
|
/* @__PURE__ */k("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Display"}),
|
|
25
25
|
/* @__PURE__ */u("div",{className:"flex items-center gap-3 mb-2",children:[
|
|
26
26
|
/* @__PURE__ */k("span",{className:"text-sm text-gray-600 w-24",children:"Temperature"}),
|
|
27
|
-
/* @__PURE__ */k("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */k("button",{onClick:()=>
|
|
27
|
+
/* @__PURE__ */k("div",{className:"flex gap-1",children:[{key:!1,label:"°C"},{key:!0,label:"°F"}].map(e=>/* @__PURE__ */k("button",{onClick:()=>H(t=>({...t,useFahrenheit:e.key})),className:"px-3 py-1 text-xs font-medium rounded-lg border transition-colors "+(C.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__ */k("p",{className:"text-2xs text-ink-faintest mt-1",children:"Shared with the Weather widget."})]}),
|
|
29
29
|
/* @__PURE__ */u("div",{children:[
|
|
30
30
|
/* @__PURE__ */k("h3",{className:"text-sm font-semibold text-gray-700 mb-2",children:"Cities"}),
|
package/dist/ai/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{StepChainItem as e,StepChain as t}from"../chunk-Z2Z653OO.js";import{Markdown as n}from"../chunk-E7BQZL7X.js";import{Divider as a}from"../chunk-DFOFEBYX.js";import{Avatar as r}from"../chunk-W2TPXKCV.js";import"../chunk-UJUTS6LJ.js";import"../chunk-Z5TE3MEG.js";import{useContextMenu as s,ContextMenu as o}from"../chunk-VKZC3NPM.js";import{Banner as i}from"../chunk-XWJT6TFU.js";import{
|
|
2
|
+
import{StepChainItem as e,StepChain as t}from"../chunk-Z2Z653OO.js";import{Markdown as n}from"../chunk-E7BQZL7X.js";import{Divider as a}from"../chunk-DFOFEBYX.js";import{Avatar as r}from"../chunk-W2TPXKCV.js";import"../chunk-UJUTS6LJ.js";import"../chunk-Z5TE3MEG.js";import{useContextMenu as s,ContextMenu as o}from"../chunk-VKZC3NPM.js";import{Banner as i}from"../chunk-XWJT6TFU.js";import{AttachmentDropZone as l}from"../chunk-6QH7I2V5.js";import{Input_default as c}from"../chunk-3SIRRK3F.js";import"../chunk-EX3DARI3.js";import"../chunk-VQBKRBBR.js";import{IconButton_default as d}from"../chunk-NWS5G7FE.js";import"../chunk-AYZY3YNC.js";import{CloseGlyph as u}from"../chunk-YWMCW5BN.js";import"../chunk-GUSENWAH.js";import{useFileIntake as p,humanSize as m,FileIntakeAlert as h}from"../chunk-VFSAJMNX.js";import{parseChartSpec as f}from"../chunk-CR7T435F.js";import{SpecChart as g}from"../chunk-WJTNQ7YD.js";import{formatBytes as x}from"../chunk-OJI4ROSD.js";import{formatTime as b}from"../chunk-NHKT5IH6.js";import"../chunk-36BRD5J3.js";import"../chunk-JRQMX4PK.js";import"../chunk-LF27WIN2.js";import"../chunk-ABPVCVCT.js";import{FlowChart as v}from"../chunk-R5WBDXI2.js";import{parseFlowSpec as y}from"../chunk-FAERBT6Y.js";import"../chunk-MOKABQCY.js";import"../chunk-CK2YOGUS.js";import"../chunk-G5UGCAWN.js";import"../chunk-VFC6QUEN.js";import"../chunk-G7SILKUY.js";import"../chunk-465RRWBY.js";import{ChartSkeleton as w}from"../chunk-ZNV75GAG.js";import"../chunk-CNYAHYE6.js";import"../chunk-DWGYC7OD.js";import"../chunk-YDJ5IZOU.js";import"../chunk-THAPVKEJ.js";import"../chunk-URHGHXDN.js";import"../chunk-5QFPTDQF.js";import{Button_default as k}from"../chunk-UTISUEO4.js";import"../chunk-BUFAJJDZ.js";import{Icon as N}from"../chunk-ISVODSRP.js";import"../chunk-J75ZT2JQ.js";import{SpinnerRing as A}from"../chunk-R2VKEMZH.js";import"../chunk-BWJZTHZ6.js";import"../chunk-TD3ZQD5R.js";import"../chunk-F2RAIGCG.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-VY3UA6AR.js";import"../chunk-WCCS4VFE.js";import"../chunk-ZDXRSY2Y.js";import"../chunk-UQYNPYF4.js";import"../chunk-MRJKZWWV.js";import"../chunk-HC5KQZFG.js";import"../chunk-KNZ7YTFH.js";import"../chunk-2JWPNR2U.js";import"../chunk-WDQI3FV6.js";import"../chunk-TZFACUMR.js";import{registerModalEscapeInterceptor as C}from"../chunk-TWVUQUUD.js";import"../chunk-5FYDNH4Y.js";import"../chunk-LNXBTK7Q.js";import"../chunk-MAFUXCPZ.js";import{useShellStrings as T}from"../chunk-IUVGHHR3.js";import"../chunk-C3QOHMR6.js";import{useRef as j,useEffect as S,useState as $,Fragment as R,useId as _,useLayoutEffect as O,useCallback as D,useMemo as I}from"react";import{isToolUIPart as M,getToolName as z,DefaultChatTransport as F,lastAssistantMessageIsCompleteWithApprovalResponses as P}from"ai";import{jsx as L,jsxs as B,Fragment as E}from"react/jsx-runtime";import{createPortal as U}from"react-dom";import{useChat as q}from"@ai-sdk/react";function W(e){if(!M(e))return null;const t=e;return{toolName:z(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 H(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 Y(e){const t=/* @__PURE__ */new Map;for(const n of e.parts){if("data-file"!==n.type)continue;const e=n.data;e&&"string"==typeof e.id&&"string"==typeof e.filename&&t.set(e.id,e)}return[...t.values()]}function Q(e){return e.parts.map(e=>"text"===e.type?e.text:"").join("")}var J="efficient-attachment:";function V(e){return{type:"file",mediaType:e.content_type,filename:e.filename,url:`${J}${e.id}`,providerMetadata:{efficient:{size:e.size}}}}function K(e){const t=[];for(const n of e.parts){if("file"!==n.type||!n.url.startsWith(J))continue;const e=n.providerMetadata?.efficient?.size;t.push({id:n.url.slice(21),filename:n.filename??"",content_type:n.mediaType,size:"number"==typeof e?e:0})}return t}var Z=/* @__PURE__ */new Set(["data-conversation","data-plan","data-followups","data-choices","data-tool-summary","data-error","data-file","data-approval","data-busy"]);function G(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=Q(n).trim();if(!e)throw new Error("assistant chat: empty message");const a=K(n).map(e=>e.id),r=n.metadata?.replyTo?.id;return{conversation_id:t,text:e,approvals:[],...a.length>0?{attachments:a}:{},...r?{reply_to:r}:{}}}const a=function(e){const t=[];for(const n of e.parts){if(!M(n))continue;const e=n;if("approval-responded"!==e.state||!e.approval||"boolean"!=typeof e.approval.approved)continue;const a={approval_id:e.approval.id,approved:e.approval.approved};e.approval.reason&&(a.reason=e.approval.reason),t.push(a)}return t}(n);if(0===a.length)throw new Error("assistant chat: no approval decision to send");return{conversation_id:t,text:null,approvals:a}}var X=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function ee(e,t,n=""){const a=[t.trim(),n.trim()].filter(Boolean).map(X);return 0!==a.length&&new RegExp(`(^|[^\\p{L}\\p{N}_@])(?:${a.join("|")})(?![\\p{L}\\p{N}_@])`,"iu").test(e)}function te(e,t){const n=("string"==typeof t?[t]:[...t]).map(e=>e.trim()).filter(Boolean).sort((e,t)=>t.length-e.length);if(!n.length||!e)return e?[{text:e,mention:!1}]:[];const a=[];let r=0;const s=new RegExp(`(^|[^\\p{L}\\p{N}_@])(${n.map(X).join("|")})(?![\\p{L}\\p{N}_@])`,"giu");for(const t of e.matchAll(s)){const n=(t.index??0)+t[1].length;n>r&&a.push({text:e.slice(r,n),mention:!1}),a.push({text:t[2],mention:!0}),r=n+t[2].length}return r<e.length&&a.push({text:e.slice(r),mention:!1}),a}function ne(e,t){return ee(e,t)?e:`${t.trim()} ${e.trimStart()}`}function ae(e){const t=e.map(e=>e.name).filter(Boolean);return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}var re=/* @__PURE__ */new Set(["proposed","approved","running"]);function se(e){return re.has(e.status)}function oe(e){const t=[];for(const n of e.parts)"data-plan"===n.type&&t.push(n.data);return t}function ie(e){const t=/* @__PURE__ */new Map;for(const n of e)for(const e of oe(n))t.delete(e.id),t.set(e.id,e);return t}function le(e){const t=[...ie(e).values()],n=t[t.length-1];if(!n)return null;if(se(n))return n;const a=e[e.length-1];return a&&"assistant"===a.role&&oe(a).some(e=>e.id===n.id)?n:null}function ce(e){const t={};return e.source&&e.source!==e.role&&(t.source=e.source),e.author&&(t.author=e.author),e.asked_by&&(t.askedBy=e.asked_by),e.created_at&&(t.createdAt=e.created_at),e.reply_to&&(t.replyTo=e.reply_to),"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 de(e,t){const n=/* @__PURE__ */new Map;for(const a of e.parts){if("data-approval"!==a.type)continue;const e=a.data,r=e?.[t];"string"==typeof e?.approval_id&&"string"==typeof r&&r&&n.set(e.approval_id,r)}return n}function ue(e){const t=e.messages.filter(e=>e.text).map(e=>({id:e.id,role:e.role,parts:[...(e.attachments??[]).map(V),{type:"text",text:e.text},...(e.files??[]).map(e=>({type:"data-file",id:`file-${e.id}`,data:e})),...e.update?[{type:"data-update",id:`update-${e.update.id}`,data:e.update}]:[]],...ce(e)})),n=(e.plans??[]).filter(se);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}})),...e.pending_approvals.filter(e=>e.expires_at||e.notice).map(e=>({type:"data-approval",id:e.approval_id,data:{approval_id:e.approval_id,expires_at:e.expires_at,...e.notice?{notice:e.notice}:{}}}))]}),t}function pe(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()}for(const t of Object.values(e)){const e=Array.isArray(t)?t[0]:void 0;if("string"==typeof e&&e.trim()&&e.length<=400)return e.trim()}}catch{return t}return t}return n.startsWith("<")||n.length>400?t:n}var me=/^(load failed|failed to fetch|network ?error( when attempting to fetch resource)?|(the )?network connection was lost|error in input stream|terminated)\.?$/i;function he(e){return!(!e||"AbortError"===e.name)&&me.test(e.message?.trim()??"")}var fe=/* @__PURE__ */new Set(["budget_reached","not_permitted"]);function ge(e,t,n){return he(e)?{text:n.connectionDropped,retryable:!0}:{text:pe(e,n.genericError),retryable:!(t&&fe.has(t))}}function xe(e){const t=e[e.length-1];if(!t)return!1;if("user"===t.role)return""!==Q(t).trim();const n=e[e.length-2];return!(!n||"user"!==n.role||!Q(n).trim())&&!t.parts.some(e=>void 0!==W(e)?.approvalId)}var be=["👍","✅","👀"],ve=["👍","👎","❤️","😂","😮","😢","🙏","🎉","✅","❌","👀","🔥","💯","🚀","👏","🙌","😀","😅","🤔","😬","🤝","💪","📦","🚚","📅","⏰","💰","📈","⚠️","❓","➕","👌"];function ye(e,t,n="You"){const a=e.names.map(a=>t&&a===t&&e.mine?n:a),r=e.mine?[n,...a.filter(e=>e!==n)]:a;return r.length<=1?r[0]??"":`${r.slice(0,-1).join(", ")} and ${r[r.length-1]}`}function we({onPick:e,onClose:t,label:n="Add reaction"}){const a=j(null);S(()=>{const e=e=>{a.current&&!a.current.contains(e.target)&&t()};return document.addEventListener("mousedown",e),a.current?.querySelector("button")?.focus(),()=>document.removeEventListener("mousedown",e)},[t]);/* @__PURE__ */
|
|
3
3
|
return L("div",{ref:a,role:"dialog","aria-label":n,className:"absolute z-20 mt-1 grid w-max grid-cols-8 gap-0.5 rounded-md border border-line bg-surface p-1 shadow-lg","data-emoji-picker":"",onKeyDown:e=>{"Escape"===e.key&&(e.stopPropagation(),t())},children:ve.map(n=>/* @__PURE__ */L("button",{type:"button",className:"flex h-7 w-7 items-center justify-center rounded text-base hover:bg-surface-sunken focus-visible:bg-surface-sunken","aria-label":n,onClick:()=>{e(n),t()},children:n},n))})}function ke({onReact:e,label:t="Add reaction"}){const[n,a]=$(!1);/* @__PURE__ */
|
|
4
4
|
return B("span",{className:"relative flex items-center gap-0.5","data-reaction-bar":"",children:[be.map(t=>/* @__PURE__ */L("button",{type:"button",className:"flex h-6 w-6 items-center justify-center rounded text-sm hover:bg-surface-sunken","aria-label":`React ${t}`,title:`React ${t}`,onClick:()=>e(t),children:t},t)),
|
|
5
5
|
/* @__PURE__ */L(d,{size:"sm",variant:"ghost","aria-label":t,title:t,"aria-haspopup":"dialog",onClick:()=>a(e=>!e),children:/* @__PURE__ */L(N,{name:"face-smile",className:"h-3.5 w-3.5"})}),n&&/* @__PURE__ */L("span",{className:"absolute right-0 top-full",children:/* @__PURE__ */L(we,{label:t,onPick:e,onClose:()=>a(!1)})})]})}function Ne({reactions:e,onToggle:t,selfName:n,label:a="Add reaction"}){const[r,s]=$(!1);return e.length?/* @__PURE__ */B("div",{className:"relative mt-1 flex flex-wrap items-center gap-1","data-reactions":"",children:[e.map(e=>{const a=ye(e,n),r="inline-flex h-6 items-center gap-1 rounded-full border px-2 text-xs tabular-nums "+(e.mine?"border-accent-border bg-accent-tint text-accent-text":"border-line bg-surface text-ink");/* @__PURE__ */
|
|
@@ -32,35 +32,35 @@ return B("div",{className:"flex items-start gap-2 px-3 pt-2","data-composer-quot
|
|
|
32
32
|
/* @__PURE__ */L("div",{className:"font-medium text-ink",children:a.replyingTo.replace("{name}",e.author_name)}),
|
|
33
33
|
/* @__PURE__ */L("div",{className:"truncate",children:e.excerpt})]}),n&&/* @__PURE__ */L(d,{type:"button",size:"sm",variant:"ghost","aria-label":a.clearQuote,title:a.clearQuote,onClick:n,children:/* @__PURE__ */L(N,{name:"close"})})]})}var Ye={sent:"Sent",delivered:"Delivered",read:"Read"};function Qe({receipt:e,onInfo:t}){const n=Ye[e],a=/* @__PURE__ */B("span",{className:"inline-flex "+("read"===e?"text-accent-text":"text-ink-faint"),"data-receipt":e,children:[
|
|
34
34
|
/* @__PURE__ */L(N,{name:"check",size:12}),"sent"!==e&&/* @__PURE__ */L(N,{name:"check",size:12,className:"-ml-2"})]});return t?/* @__PURE__ */L(d,{size:"sm",variant:"ghost","aria-label":`${n}. Message info`,title:`${n}. Message info`,onClick:t,children:a}):/* @__PURE__ */L("span",{role:"img","aria-label":n,title:n,className:"inline-flex",children:a})}function Je({name:e,assistant:t,avatarUrl:n,onAuthor:a,mine:r=!1,receipt:i,onReceiptInfo:l,createdAt:c,note:u,replyTo:p,labels:m,onQuote:h,barItems:f,menu:g,menuText:x,footer:v,edited:y=!1,deleted:w=!1,reactions:k,onReact:A,selfName:C,pinned:T=!1,actionsOn:j="hover",children:S}){const R=We(m),_=s(),O=c?b(c):"",D=w?void 0:h,I=w?void 0:A,M=w?void 0:g,z=w?/* @__PURE__ */L(Ae,{text:R.deleted}):S,F=w?null:I?/* @__PURE__ */B(E,{children:[
|
|
35
|
-
/* @__PURE__ */L(ke,{label:R.addReaction,onReact:e=>I(e,!(k??[]).some(t=>t.emoji===e&&t.mine))}),f]}):f,P=!w&&k?.length?/* @__PURE__ */L(Ne,{reactions:k,onToggle:I,selfName:C,label:R.addReaction}):null,U=P||v?/* @__PURE__ */B(E,{children:[P,v]}):null,q=T&&!w?/* @__PURE__ */L("span",{className:"text-2xs text-ink-faint","data-pinned":"",children:R.pinned}):null,W=y&&!w?/* @__PURE__ */L("span",{className:"text-xs text-ink-faint","data-edited":"",children:R.edited}):null,H=Boolean(M?.length),Y="hold"===j,[Q,J]=$(null),
|
|
35
|
+
/* @__PURE__ */L(ke,{label:R.addReaction,onReact:e=>I(e,!(k??[]).some(t=>t.emoji===e&&t.mine))}),f]}):f,P=!w&&k?.length?/* @__PURE__ */L(Ne,{reactions:k,onToggle:I,selfName:C,label:R.addReaction}):null,U=P||v?/* @__PURE__ */B(E,{children:[P,v]}):null,q=T&&!w?/* @__PURE__ */L("span",{className:"text-2xs text-ink-faint","data-pinned":"",children:R.pinned}):null,W=y&&!w?/* @__PURE__ */L("span",{className:"text-xs text-ink-faint","data-edited":"",children:R.edited}):null,H=Boolean(M?.length),Y="hold"===j,[Q,J]=$(null),V=Y&&!w&&Boolean(D||I||H),K=Ie(J,V),Z=!Y&&(D||F||H)?
|
|
36
36
|
/* @__PURE__ */B("div",{className:`absolute -top-3 ${r?"left-2":"right-2"} z-10 flex items-center gap-0.5 rounded-md border border-line bg-surface p-0.5 opacity-0 shadow-sm transition-opacity focus-within:opacity-100 group-hover:opacity-100`,"data-chat-chrome":"","data-row-actions":"",children:[D&&/* @__PURE__ */L(d,{size:"sm",variant:"ghost","aria-label":R.quote,title:R.quote,onClick:D,children:/* @__PURE__ */L(N,{name:"quote",className:"h-3.5 w-3.5"})}),F,H&&/* @__PURE__ */L(d,{size:"sm",variant:"ghost","aria-label":R.moreActions,title:R.moreActions,"aria-haspopup":"menu",onClick:e=>_.open(e,void 0),children:/* @__PURE__ */L(N,{name:"more",className:"h-3.5 w-3.5"})})]}):null,G=H&&_.state&&M&&/* @__PURE__ */L(o,{..._.props,"aria-label":R.moreActions,items:M.map(e=>({key:e.key,label:e.label,onSelect:()=>e.onSelect(x??"")}))}),X=[...D?[{key:"reply",label:R.reply,onSelect:D}]:[],...(M??[]).map(e=>({key:e.key,label:e.label,danger:"delete"===e.key,onSelect:()=>e.onSelect(x??"")}))],ee=Q&&/* @__PURE__ */L(Me,{anchor:Q,mine:r,preview:/* @__PURE__ */B("div",{className:r?"max-w-full rounded-2xl rounded-br-sm bg-accent-fill px-3 py-2 text-sm text-on-accent shadow-lg":"max-w-full rounded-2xl rounded-bl-sm px-3 py-2 text-sm text-ink shadow-lg "+(t?"bg-surface":"bg-surface-sunken"),children:[p&&/* @__PURE__ */L(Ee,{quote:p}),
|
|
37
37
|
/* @__PURE__ */L("div",{className:"min-w-0",children:z})]}),actions:X,onReact:I?e=>I(e,!(k??[]).some(t=>t.emoji===e&&t.mine)):void 0,reactLabel:R.addReaction,label:R.moreActions,onClose:()=>J(null)}),te=O?/* @__PURE__ */L("time",{dateTime:c,className:"shrink-0 text-xs tabular-nums text-ink-faint",children:O}):null;/* @__PURE__ */
|
|
38
38
|
return B("div",r?{className:"group relative flex min-w-0 flex-col items-end px-2 py-1","data-chat-row":"mine",onContextMenu:!Y&&H?e=>_.open(e,void 0):void 0,...K,children:[
|
|
39
39
|
/* @__PURE__ */L("span",{className:"sr-only",children:e}),q,
|
|
40
40
|
/* @__PURE__ */B("div",{className:"min-w-0 max-w-[75%] rounded-2xl rounded-br-sm px-3 py-2 text-sm "+(w?"border border-dashed border-line-strong":"bg-accent-fill text-on-accent"),"data-bubble":"mine",children:[p&&/* @__PURE__ */L(Ee,{quote:p}),
|
|
41
|
-
/* @__PURE__ */L("div",{className:"min-w-0",children:z})]}),(te||u||i||W)&&/* @__PURE__ */B("div",{className:"mt-0.5 flex items-center gap-2",children:[u&&/* @__PURE__ */L("span",{className:"min-w-0 truncate text-xs text-ink-faint",children:u}),W,te,i&&/* @__PURE__ */L(Qe,{receipt:i,onInfo:l})]}),U,
|
|
41
|
+
/* @__PURE__ */L("div",{className:"min-w-0",children:z})]}),(te||u||i||W)&&/* @__PURE__ */B("div",{className:"mt-0.5 flex items-center gap-2",children:[u&&/* @__PURE__ */L("span",{className:"min-w-0 truncate text-xs text-ink-faint",children:u}),W,te,i&&/* @__PURE__ */L(Qe,{receipt:i,onInfo:l})]}),U,Z,G,ee]}:{className:"group relative flex min-w-0 gap-2 px-2 py-1","data-chat-row":t?"assistant":"person",onContextMenu:!Y&&H?e=>_.open(e,void 0):void 0,...K,children:[a?/* @__PURE__ */L("button",{type:"button",className:"flex shrink-0 self-start rounded-full focus:outline-none focus-visible:ring-2 focus-visible:ring-accent-fill","aria-label":`${e}'s profile`,"data-row-author":"",onClick:a,children:/* @__PURE__ */L(Be,{name:e,assistant:t,avatarUrl:n})}):/* @__PURE__ */L(Be,{name:e,assistant:t,avatarUrl:n}),
|
|
42
42
|
/* @__PURE__ */B("div",{className:"flex min-w-0 flex-col items-start "+(t?"flex-1":"max-w-[85%]"),children:[
|
|
43
43
|
/* @__PURE__ */B("div",{className:"flex min-w-0 items-baseline gap-2",children:[a?
|
|
44
44
|
/* @__PURE__ */L("button",{type:"button",tabIndex:-1,className:"min-w-0 truncate text-left text-sm font-medium text-ink-strong hover:underline focus:outline-none","data-row-author-name":"",onClick:a,children:e}):/* @__PURE__ */L("span",{className:"truncate text-sm font-medium text-ink-strong",children:e}),te,W,u&&/* @__PURE__ */L("span",{className:"min-w-0 truncate text-xs text-ink-faint",children:u}),q]}),
|
|
45
45
|
/* @__PURE__ */B("div",{className:t?"min-w-0 w-full text-sm text-ink":"min-w-0 max-w-full rounded-2xl rounded-bl-sm bg-surface-sunken px-3 py-2 text-sm text-ink","data-bubble":t?void 0:"theirs",children:[p&&/* @__PURE__ */L(Ee,{quote:p}),
|
|
46
|
-
/* @__PURE__ */L("div",{className:"min-w-0",children:z})]}),U]}),
|
|
46
|
+
/* @__PURE__ */L("div",{className:"min-w-0",children:z})]}),U]}),Z,G,ee]})}var Ve=["·","✢","✳","✶","✻","✽","✻","✶","✳","✢"];function Ke(){return"undefined"!=typeof window&&"function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function Ze({resting:e=!1}){const t=function(){const[e,t]=$(0);return S(()=>{if(Ke())return;const e=setInterval(()=>t(e=>(e+1)%Ve.length),130);return()=>clearInterval(e)},[]),Ke()?"✻":Ve[e]}();/* @__PURE__ */
|
|
47
47
|
return L("span",{"aria-hidden":"true",className:"inline-block w-4 shrink-0 text-center text-base leading-none text-accent-text "+(e?"opacity-60":"motion-safe:animate-pulse"),children:e?"✻":t})}function Ge({label:e,words:t,since:n,secondsLabel:a,steadyLabel:r}){const[s,o]=$(0);S(()=>{if(e||t.length<2||Ke())return;const n=setInterval(()=>o(e=>(e+1)%t.length),1600);return()=>clearInterval(n)},[e,t.length]);const i=function(e){const[t]=$(()=>e||Date.now()),[n,a]=$(()=>Date.now());return S(()=>{const e=setInterval(()=>a(Date.now()),1e3);return()=>clearInterval(e)},[]),Math.max(0,Math.floor((n-(e||t))/1e3))}(n),l=e||t[s%Math.max(t.length,1)]||r;/* @__PURE__ */
|
|
48
48
|
return B("div",{className:"flex items-center gap-2 text-sm text-ink-faint","data-assistant-waiting":"",children:[
|
|
49
49
|
/* @__PURE__ */L("span",{className:"sr-only",children:r}),
|
|
50
|
-
/* @__PURE__ */L(
|
|
50
|
+
/* @__PURE__ */L(Ze,{}),
|
|
51
51
|
/* @__PURE__ */L("span",{"aria-hidden":"true",className:"min-w-0 truncate",children:`${l}…`}),
|
|
52
|
-
/* @__PURE__ */L("span",{"aria-hidden":"true",className:"shrink-0 text-xs tabular-nums",children:a.replace("{seconds}",String(i))})]})}function Xe({labels:e,placeholder:t,busy:n,focusWhen:a,onSend:r,onStop:s,onNewChat:o,actions:i,attachments:
|
|
53
|
-
/* @__PURE__ */L("span",{role:"status",className:"min-w-0 flex-1 truncate "+(W?"text-accent-text":"text-ink-faint"),children:Y}),Q&&/* @__PURE__ */L(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q.onClick(),I.current?.focus()},children:Q.label})]}):null,
|
|
54
|
-
/* @__PURE__ */L("textarea",{ref:I,"aria-label":e.inputLabel,placeholder:t,rows:1,value:C,onChange:e=>R(e.target.value),onInput:E,onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing)return e.preventDefault(),void q();"Escape"===e.key&&y&&w&&(e.preventDefault(),w())},className:"block max-h-48 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent py-1 text-sm leading-6 text-ink-strong outline-none placeholder:text-[color:var(--ink-placeholder)] "+(o||
|
|
55
|
-
/* @__PURE__ */L(
|
|
52
|
+
/* @__PURE__ */L("span",{"aria-hidden":"true",className:"shrink-0 text-xs tabular-nums",children:a.replace("{seconds}",String(i))})]})}function Xe({labels:e,placeholder:t,busy:n,focusWhen:a,onSend:r,onStop:s,onNewChat:o,actions:i,attachments:c,people:f,assistantDecides:g,deciding:x,quiet:b,onAskToReply:v,quote:y,onClearQuote:w}){const[C,R]=$(""),[_,O]=$(!1),I=j(null),M=function(e){const[t,n]=$([]),a=j(0),r=j(!0);S(()=>()=>{r.current=!1},[]);const s=e?.upload,o=D(e=>{if(s)for(const t of e){const e=a.current++;n(n=>[...n,{key:e,name:t.name,size:t.size}]),s(t).then(t=>{r.current&&n(n=>n.map(n=>n.key===e?{...n,attachment:t}:n))},t=>{const a=t instanceof Error&&t.message?t.message:String(t);r.current&&n(t=>t.map(t=>t.key===e?{...t,error:a}:t))})}},[s]),i=t.some(e=>!e.attachment&&!e.error),l=t.flatMap(e=>e.attachment?[e.attachment]:[]);return{pending:t,add:o,remove:e=>n(t=>t.filter(t=>t.key!==e)),clear:()=>n([]),uploading:i,ready:l}}(c),z=T().files,F=p({accept:c?.accept,maxSizeBytes:c?.maxSizeBytes,maxFiles:c?.maxFiles??5,acceptHint:c?.acceptHint,currentCount:M.pending.length,disabled:!c,onAccept:M.add});S(()=>{a&&I.current?.focus()},[a]);const P=y?.id;S(()=>{P&&I.current?.focus()},[P]);const E=()=>{const e=I.current;e&&(e.value&&0!==e.clientWidth?(e.style.height="auto",e.style.height=`${e.scrollHeight}px`):e.style.height="")};S(E,[C]),S(()=>{const e=I.current;if(!e||"undefined"==typeof ResizeObserver)return;let t=e.clientWidth;const n=new ResizeObserver(()=>{e.clientWidth!==t&&(t=e.clientWidth,E())});return n.observe(e),()=>n.disconnect()},[]);const U=n||x||M.uploading||!C.trim(),q=()=>{U||(r(C,M.ready,{peopleOnly:!!g&&_,...y?{reply_to:y.id}:{}}),R(""),M.clear(),F.clearRejections(),y&&w?.())},W=!!f&&(ee(C,e.assistantMention,e.assistantName)||M.pending.length>0),H=!!g&&!_,Y=W?e.toAssistant:H?e.assistantDecides:e.toPeople.replace("{names}",f??""),Q=W||x?null:g?{label:H?e.peopleOnly:e.letAssistantDecide,onClick:()=>O(H)}:{label:e.askAssistant,onClick:()=>R(t=>ne(t,e.assistantMention))},J=f?/* @__PURE__ */B("div",{className:"flex items-center gap-2 px-3 pt-1 text-xs",children:[
|
|
53
|
+
/* @__PURE__ */L("span",{role:"status",className:"min-w-0 flex-1 truncate "+(W?"text-accent-text":"text-ink-faint"),children:Y}),Q&&/* @__PURE__ */L(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>{Q.onClick(),I.current?.focus()},children:Q.label})]}):null,V=/* @__PURE__ */B("form",{className:"flex items-end gap-1 p-1",onSubmit:e=>{e.preventDefault(),q()},children:[o&&/* @__PURE__ */L(d,{type:"button",variant:"ghost","aria-label":e.newChat,title:e.newChat,onClick:o,children:/* @__PURE__ */L(N,{name:"compose"})}),c&&/* @__PURE__ */L(d,{type:"button",variant:"ghost","aria-label":e.attach,title:e.attach,onClick:F.open,disabled:n,children:/* @__PURE__ */L(N,{name:"add"})}),
|
|
54
|
+
/* @__PURE__ */L("textarea",{ref:I,"aria-label":e.inputLabel,placeholder:t,rows:1,value:C,onChange:e=>R(e.target.value),onInput:E,onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey&&!e.nativeEvent.isComposing)return e.preventDefault(),void q();"Escape"===e.key&&y&&w&&(e.preventDefault(),w())},className:"block max-h-48 min-w-0 flex-1 resize-none overflow-y-auto bg-transparent py-1 text-sm leading-6 text-ink-strong outline-none placeholder:text-[color:var(--ink-placeholder)] "+(o||c?"px-1":"px-2")}),i?.map(e=>e.icon?/* @__PURE__ */L(d,{type:"button",variant:"ghost","aria-label":e.label,title:e.label,disabled:!C.trim(),onClick:()=>e.onSelect(C.trim()),children:/* @__PURE__ */L(N,{name:e.icon})},e.key):/* @__PURE__ */L(k,{type:"button",variant:"ghost",disabled:!C.trim(),onClick:()=>e.onSelect(C.trim()),children:e.label},e.key)),/* @__PURE__ */L(d,n?{type:"button",variant:"ghost","aria-label":e.stop,title:e.stop,onClick:s,children:/* @__PURE__ */L(N,{name:"stop-circle"})}:{type:"submit",variant:"ghost","aria-label":e.send,title:e.send,disabled:U,children:/* @__PURE__ */L(N,{name:"enter"})})]}),K=f&&x?/* @__PURE__ */L("div",{className:"px-1 pb-1",children:/* @__PURE__ */L(Ge,{label:e.deciding,words:[],secondsLabel:e.waitingSeconds,steadyLabel:e.deciding})}):f&&b&&v?/* @__PURE__ */B("div",{className:"flex items-center gap-2 px-1 pb-1 text-xs text-ink-faint",children:[
|
|
55
|
+
/* @__PURE__ */L(Ze,{resting:!0}),
|
|
56
56
|
/* @__PURE__ */L("span",{role:"status",className:"min-w-0 flex-1 truncate",children:e.notReplied}),
|
|
57
|
-
/* @__PURE__ */L(k,{type:"button",size:"sm",variant:"secondary",onClick:v,children:e.askToReply})]}):null,
|
|
57
|
+
/* @__PURE__ */L(k,{type:"button",size:"sm",variant:"secondary",onClick:v,children:e.askToReply})]}):null,Z=y?/* @__PURE__ */L(He,{quote:y,labels:e,onClear:w?()=>{w(),I.current?.focus()}:void 0}):null,G="rounded-2xl border border-line bg-surface shadow-sm transition-colors focus-within:border-line-strong";return c?/* @__PURE__ */B(l,{intake:F,className:"px-3 pt-2 pb-3",children:[K,
|
|
58
58
|
/* @__PURE__ */B("div",{className:G,children:[M.pending.length>0&&/* @__PURE__ */L("ul",{className:"flex flex-wrap gap-2 px-3 pt-3",children:M.pending.map(t=>/* @__PURE__ */B("li",{className:"flex max-w-full items-center gap-2 rounded-md border py-1 pl-2 pr-1 text-xs "+(t.error?"border-red-200 bg-red-50 text-red-700":"border-gray-200 bg-gray-50 text-gray-700"),children:[t.attachment||t.error?/* @__PURE__ */L(N,{name:"page",size:14,"aria-hidden":"true"}):/* @__PURE__ */L("span",{role:"status","aria-label":e.attaching,className:"inline-flex",children:/* @__PURE__ */L(A,{className:"h-3 w-3"})}),
|
|
59
59
|
/* @__PURE__ */L("span",{className:"min-w-0 truncate",title:t.error??t.name,children:t.name}),
|
|
60
60
|
/* @__PURE__ */L("span",{className:"shrink-0 tabular-nums text-gray-400",children:m(t.size,z)}),
|
|
61
61
|
/* @__PURE__ */L("button",{type:"button",onClick:()=>M.remove(t.key),"aria-label":e.removeAttachment.replace("{name}",t.name),className:"shrink-0 rounded p-0.5 text-gray-400 hover:bg-gray-200 hover:text-gray-600",children:/* @__PURE__ */L(u,{className:"h-3.5 w-3.5"})})]},t.key))}),M.pending.some(e=>e.error)&&/* @__PURE__ */L("ul",{role:"alert",className:"flex flex-col gap-0.5 px-3 pt-1",children:M.pending.flatMap(e=>e.error?[/* @__PURE__ */L("li",{className:"text-xs text-red-600",children:`${e.name}: ${e.error}`},e.key)]:[])}),
|
|
62
|
-
/* @__PURE__ */L(h,{rejections:F.rejections,className:"px-3 pt-1"}),V
|
|
63
|
-
/* @__PURE__ */B("div",{className:G,children:[V
|
|
62
|
+
/* @__PURE__ */L(h,{rejections:F.rejections,className:"px-3 pt-1"}),Z,V]}),J]}):/* @__PURE__ */B("div",{className:"px-3 pt-2 pb-3",children:[K,
|
|
63
|
+
/* @__PURE__ */B("div",{className:G,children:[Z,V]}),J]})}function et(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 tt={propose_plan:{label:"Plan the changes",running:"Planning the changes",done:"Planned the changes"}};function nt(e,t){const n=t?.[e]??tt[e];return"string"==typeof n?{label:n}:n??{label:et(e)}}function at(e,t,n){const a=void 0===n?nt(e,t):ot(e,n,t);return a.done??a.label}function rt(e){return e&&"object"==typeof e&&!Array.isArray(e)?e:{}}function st(e,t,n){const a=nt(e,n).present;if(a)try{return a(rt(t))??void 0}catch{return}}function ot(e,t,n){const a=nt(e,n),r=st(e,t,n);return r?{...a,label:r.label??a.label,running:r.running??(r.label?void 0:a.running),done:r.done??(r.label?void 0:a.done)}:a}function it(e,t,n){return ot(e,t,n).label}function lt(e,t,n){const a=st(e,t,n)?.subject;if(void 0!==a)return a.trim();const r=nt(e,n).describe;if(!r)return"";try{return r(rt(t))?.trim()??""}catch{return""}}function ct(e,t){return null==e?"":"boolean"==typeof e?e?"Yes":"No":"object"!=typeof e?String(e):Array.isArray(e)?e.map(e=>ct(e,t+1)).filter(Boolean).join(", "):t>=3?"…":Object.entries(e).map(([e,n])=>{const a=ct(n,t+1);return a?`${et(e)}: ${a}`:""}).filter(Boolean).join("; ")}function dt(e){const t=rt(e),n=[];for(const[e,a]of Object.entries(t)){if(e.startsWith("_"))continue;const t=ct(a,0);t&&n.push({label:et(e),value:t})}return 0===n.length&&null!=e&&"object"!=typeof e&&n.push({label:"Value",value:ct(e,0)}),n}function ut(e,t){const n={answers:0,counted:0,inputTokens:0,outputTokens:0,rate:null};let a=0;const r=[],s=/* @__PURE__ */new Set,o=/* @__PURE__ */new Map;for(const i of e){if("user"===i.role){const e=i.metadata?.author?.name??null;for(const t of K(i))s.has(t.id)||(s.add(t.id),r.push({kind:"attached",attachment:t,from:e}));continue}if("assistant"!==i.role)continue;if(i.metadata?.source)continue;n.answers+=1;const e=i.metadata?.usage;e&&(n.counted+=1,n.inputTokens+=e.input_tokens,n.outputTokens+=e.output_tokens,a+=e.generation_ms);for(const e of Y(i))s.has(e.id)||(s.add(e.id),r.push({kind:"made",file:e}));const l=/* @__PURE__ */new Set;for(const e of i.parts){const n=W(e);if(!n||"output-available"!==n.state||l.has(n.toolCallId))continue;l.add(n.toolCallId);const a=at(n.toolName,t,n.input);o.set(a,(o.get(a)??0)+1)}}return n.outputTokens>0&&a>=100&&(n.rate=n.outputTokens/(a/1e3)),{usage:n,files:r,tools:[...o].map(([e,t])=>({label:e,count:t})).sort((e,t)=>t.count-e.count)}}function pt(e){return e<1e3?String(Math.round(e)):e<1e6?`${(e/1e3).toFixed(e<1e5?1:0).replace(/\.0$/,"")}k`:`${(e/1e6).toFixed(1).replace(/\.0$/,"")}M`}function mt(e,t){return e>0&&t>=100?e/(t/1e3):null}function ht(e){return Math.ceil(e.length/4)}var ft=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e),gt=e=>Math.round(e).toLocaleString();function xt(e,t){const n=mt(e.output_tokens,e.generation_ms);return null===n?ft(t.replyTokens,{tokens:gt(e.output_tokens)}):ft(t.replyStats,{tokens:gt(e.output_tokens),seconds:(e.generation_ms/1e3).toFixed(1),rate:gt(n)})}function bt(e,t,n){const a=t>=1e3?mt(ht(e),t):null;return null===a?n.streaming:ft(n.streamingRate,{rate:gt(a)})}var vt=(e,t)=>e.replace(/\{(\w+)\}/g,(e,n)=>t[n]??e);function yt({title:e,aside:t,children:n}){/* @__PURE__ */
|
|
64
64
|
return B("details",{open:!0,className:"group rounded-lg border border-line bg-surface px-3 py-2",children:[
|
|
65
65
|
/* @__PURE__ */B("summary",{className:"flex cursor-pointer select-none list-none items-center gap-1 text-sm font-medium text-ink-strong [&::-webkit-details-marker]:hidden",children:[
|
|
66
66
|
/* @__PURE__ */L("span",{children:e}),
|
|
@@ -97,11 +97,11 @@ return B("li",{children:[
|
|
|
97
97
|
/* @__PURE__ */L("div",{className:"font-medium text-gray-900",children:Dt(e,r)}),e.title&&/* @__PURE__ */L("div",{className:"text-xs text-gray-600",children:e.title}),t.length>0&&/* @__PURE__ */L("dl",{className:"mt-1 grid grid-cols-[max-content_1fr] gap-x-3 gap-y-1 text-xs",children:t.map(e=>/* @__PURE__ */B("div",{className:"contents",children:[
|
|
98
98
|
/* @__PURE__ */L("dt",{className:"text-gray-500",children:e.label}),
|
|
99
99
|
/* @__PURE__ */L("dd",{className:"min-w-0 break-words text-gray-800",children:e.value})]},e.label))})]},e.key)})}),
|
|
100
|
-
/* @__PURE__ */L(Tt,{approvalId:e,expiresAt:o,expired:"expired"===t?.status,approveLabel:a.approvePlan,labels:a,onApprove:s})]})}function Pt({choices:e,label:t,onAnswer:n}){return 0===e.length?null:/* @__PURE__ */L("div",{role:"group","aria-label":t,className:"flex flex-col items-start gap-2 pl-1",children:e.map(e=>/* @__PURE__ */L(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Lt({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */L("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */L(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Bt({initial:e,labels:t,onRate:n}){const[a,r]=$(e??null),[s,o]=$(!1),[i,
|
|
101
|
-
return L(d,{size:"sm","aria-label":n,title:n,"aria-pressed":a?.verdict===e,disabled:f,onClick:()=>{(async e=>{if(p(!1),a?.verdict===e)return o(!1),void await x(null);const t=await x({verdict:e,note:""});o(t&&"down"===e),
|
|
100
|
+
/* @__PURE__ */L(Tt,{approvalId:e,expiresAt:o,expired:"expired"===t?.status,approveLabel:a.approvePlan,labels:a,onApprove:s})]})}function Pt({choices:e,label:t,onAnswer:n}){return 0===e.length?null:/* @__PURE__ */L("div",{role:"group","aria-label":t,className:"flex flex-col items-start gap-2 pl-1",children:e.map(e=>/* @__PURE__ */L(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Lt({questions:e,label:t,onAsk:n}){return 0===e.length?null:/* @__PURE__ */L("div",{role:"group","aria-label":t,className:"flex flex-wrap gap-2 pl-1",children:e.map(e=>/* @__PURE__ */L(k,{size:"sm",variant:"secondary",onClick:()=>n(e),children:e},e))})}function Bt({initial:e,labels:t,onRate:n}){const[a,r]=$(e??null),[s,o]=$(!1),[i,l]=$(""),[u,p]=$(!1),[m,h]=$(!1),[f,g]=$(!1),x=async e=>{const t=a;r(e),h(!1),g(!0);try{return await n(e),!0}catch{return r(t),h(!0),!1}finally{g(!1)}},b=e=>{const n="up"===e?t.rateUp:t.rateDown;/* @__PURE__ */
|
|
101
|
+
return L(d,{size:"sm","aria-label":n,title:n,"aria-pressed":a?.verdict===e,disabled:f,onClick:()=>{(async e=>{if(p(!1),a?.verdict===e)return o(!1),void await x(null);const t=await x({verdict:e,note:""});o(t&&"down"===e),l("")})(e)},children:/* @__PURE__ */L(N,{name:"hand-thumb-up",className:"down"===e?"h-3.5 w-3.5 rotate-180":"h-3.5 w-3.5"})})};/* @__PURE__ */
|
|
102
102
|
return B("div",{role:"group","aria-label":t.rateAnswer,className:"flex min-w-0 flex-1 flex-col gap-1",children:[
|
|
103
103
|
/* @__PURE__ */B("div",{className:"flex items-center gap-1",children:[b("up"),b("down"),u&&/* @__PURE__ */L("span",{role:"status",className:"px-1 text-xs text-gray-500",children:t.rateThanks}),m&&/* @__PURE__ */L("span",{role:"alert",className:"px-1 text-xs text-red-600",children:t.rateFailed})]}),s&&/* @__PURE__ */B("form",{className:"flex items-center gap-2",onSubmit:e=>{(async e=>{e.preventDefault();const t=i.trim();t&&!await x({verdict:"down",note:t})||(o(!1),p(Boolean(t)))})(e)},children:[
|
|
104
|
-
/* @__PURE__ */L("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */L(
|
|
104
|
+
/* @__PURE__ */L("div",{className:"min-w-0 flex-1",children:/* @__PURE__ */L(c,{size:"sm","aria-label":t.rateNote,placeholder:t.rateNote,maxLength:500,value:i,onChange:e=>l(e.target.value),autoFocus:!0})}),
|
|
105
105
|
/* @__PURE__ */L(k,{type:"submit",size:"sm",variant:"secondary",disabled:f||!i.trim(),children:t.rateNoteSend}),
|
|
106
106
|
/* @__PURE__ */L(k,{type:"button",size:"sm",variant:"ghost",onClick:()=>o(!1),children:t.rateNoteSkip})]})]})}function Et(e,t){return n=>{if("chart"===n.lang){if(!n.closed)/* @__PURE__ */return L(w,{height:200});const e=f(n.code);return e?/* @__PURE__ */L(g,{spec:e}):null}if("flow"===n.lang){if(!n.closed)/* @__PURE__ */return L(w,{height:200});const a=y(n.code);return a?/* @__PURE__ */L(v,{spec:a,labels:{downloadPng:e.flowDownloadPng,downloadSvg:e.flowDownloadSvg,toPdf:e.flowToPdf},onToPdf:t?()=>t(e.flowToPdfText):void 0}):null}return null}}function Ut(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,a=e.input,JSON.stringify(n)===JSON.stringify(a)));var n,a})}function qt(e,t,n,a){const r=e.flatMap(e=>"tool"===e.kind?[$t(e.tool,n,a)]:[]);if(t){const e=r.find(e=>"running"===e.kind);return e?e.base:a.working}const s=[...new Set(r.map(e=>e.base))];return s.length>0?s.join(" · "):a.reasoning}function Wt({message:e,live:t,labels:n}){const a=Q(e),r=a.length>0,s=j(null),[o,i]=$(0);S(()=>{if(!t)return;null===s.current&&(s.current=performance.now());const e=setInterval(()=>i(performance.now()-(s.current??performance.now())),500);return()=>clearInterval(e)},[t]);const l=e.metadata?.usage;let c=null;return t?c=r?bt(a,o,n):null:l&&(c=xt(l,n)),c?/* @__PURE__ */L("div",{className:"px-1 text-xs leading-6 tabular-nums text-gray-500",children:c}):null}function Ht({files:e,labels:t,onOpen:n,start:a}){const r="flex max-w-full items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1 text-xs text-gray-700";/* @__PURE__ */
|
|
107
107
|
return L("ul",{className:a?"mt-1 flex flex-wrap gap-2":"flex max-w-[85%] flex-wrap justify-end gap-2",children:e.map(e=>{const a=/* @__PURE__ */B(E,{children:[
|
|
@@ -113,14 +113,14 @@ return L("li",{className:"max-w-full",children:n?/* @__PURE__ */L("button",{type
|
|
|
113
113
|
/* @__PURE__ */L("span",{className:"block text-xs text-gray-500",children:Yt(e)})]})]}),r="flex w-full max-w-sm items-center gap-2 rounded-lg border border-gray-200 bg-gray-50 px-3 py-2 text-left";return n?/* @__PURE__ */L("button",{type:"button",className:`${r} hover:border-blue-300 hover:bg-blue-50 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500`,"data-assistant-file":e.id,"aria-label":t.openFile.replace("{name}",e.filename),onClick:()=>n(e),children:a}):/* @__PURE__ */L("div",{className:r,"data-assistant-file":e.id,children:a})}function Jt({message:e,labels:t,showCopy:n,actions:r,answer:s,bar:o}){const[i,l]=$(!1);S(()=>{if(!i)return;const e=setTimeout(()=>l(!1),1500);return()=>clearTimeout(e)},[i]);const c=Q(e);if(!c.trim()||!n&&!r?.length)return null;const u=async()=>{const e=Array.from(s.current?.querySelectorAll("[data-answer-text]")??[]);l(await async function(e,t){const n="undefined"!=typeof navigator?navigator.clipboard:void 0;if(!n)return!1;try{return t&&"undefined"!=typeof ClipboardItem&&n.write?(await n.write([new ClipboardItem({"text/html":new Blob([t],{type:"text/html"}),"text/plain":new Blob([e],{type:"text/plain"})})]),!0):(await n.writeText(e),!0)}catch{return!1}}(c,function(e){return e.map(e=>{const t=e.cloneNode(!0);return t.querySelectorAll("button, [data-chat-chrome]").forEach(e=>e.remove()),t.querySelectorAll("[class]").forEach(e=>e.removeAttribute("class")),t.removeAttribute("class"),t.querySelectorAll("table").forEach(e=>e.setAttribute("style","border-collapse:collapse")),t.querySelectorAll("th, td").forEach(e=>e.setAttribute("style","border:1px solid #d0d5dd;padding:4px 8px;text-align:left;vertical-align:top")),t.innerHTML.trim()}).filter(Boolean).join("\n")}(e)))};if(o){const a=i?t.copied:t.copyAnswer;/* @__PURE__ */
|
|
114
114
|
return B(E,{children:[n&&/* @__PURE__ */L(d,{size:"sm",variant:"ghost","aria-label":a,title:a,onClick:()=>{u()},children:/* @__PURE__ */L(N,{name:i?"check":"copy",className:"h-3.5 w-3.5"})}),r?.map(t=>t.icon?/* @__PURE__ */L(d,{size:"sm",variant:"ghost","aria-label":t.label,title:t.label,onClick:()=>t.onSelect({id:e.id,text:c}),children:/* @__PURE__ */L(N,{name:t.icon,className:"h-3.5 w-3.5"})},t.key):/* @__PURE__ */L(k,{size:"sm",variant:"ghost",onClick:()=>t.onSelect({id:e.id,text:c}),children:t.label},t.key))]})}const p=[];return n&&p.push(
|
|
115
115
|
/* @__PURE__ */L(k,{size:"sm",variant:"ghost",leftIcon:/* @__PURE__ */L(N,{name:i?"check":"copy",look:"mini",className:"h-3.5 w-3.5","aria-hidden":"true"}),onClick:()=>{u()},children:i?t.copied:t.copyAnswer},"copy")),r?.forEach(t=>p.push(
|
|
116
|
-
/* @__PURE__ */L(k,{size:"sm",variant:"ghost",leftIcon:t.icon?/* @__PURE__ */L(N,{name:t.icon,look:"mini",className:"h-3.5 w-3.5","aria-hidden":"true"}):void 0,onClick:()=>t.onSelect({id:e.id,text:c}),children:t.label},t.key))),/* @__PURE__ */L("div",{className:"ml-auto flex items-center gap-0.5","data-chat-chrome":"",children:p.map((e,t)=>/* @__PURE__ */B(R,{children:[t>0&&/* @__PURE__ */L("span",{className:"flex h-3",children:/* @__PURE__ */L(a,{orientation:"vertical"})}),e]},t))})}function
|
|
116
|
+
/* @__PURE__ */L(k,{size:"sm",variant:"ghost",leftIcon:t.icon?/* @__PURE__ */L(N,{name:t.icon,look:"mini",className:"h-3.5 w-3.5","aria-hidden":"true"}):void 0,onClick:()=>t.onSelect({id:e.id,text:c}),children:t.label},t.key))),/* @__PURE__ */L("div",{className:"ml-auto flex items-center gap-0.5","data-chat-chrome":"",children:p.map((e,t)=>/* @__PURE__ */B(R,{children:[t>0&&/* @__PURE__ */L("span",{className:"flex h-3",children:/* @__PURE__ */L(a,{orientation:"vertical"})}),e]},t))})}function Vt({text:e,actions:t,files:n,labels:a,onOpenAttachment:r}){const i=s(),l=/* @__PURE__ */L("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}),c=n.length>0?/* @__PURE__ */L(Ht,{files:n,labels:a,onOpen:r}):null;return t?.length?/* @__PURE__ */B("div",{className:c?"flex flex-col items-end gap-2":"flex justify-end",onContextMenu:e=>i.open(e,void 0),children:[c,l,i.state&&/* @__PURE__ */L(o,{...i.props,"aria-label":e,items:t.map(t=>({key:t.key,label:t.label,onSelect:()=>t.onSelect(e)}))})]}):c?/* @__PURE__ */B("div",{className:"flex flex-col items-end gap-2",children:[c,l]}):/* @__PURE__ */L("div",{className:"flex justify-end",children:l})}var Kt=/* @__PURE__ */new Set(["input-streaming","input-available","approval-responded"]);function Zt({message:a,speaker:r,toolLabels:s,labels:o,showReasoning:i,showToolOutput:l,showUsage:c,live:d,waitingSince:u,onApprove:p,plans:m,userActions:h,tableActions:f,onLinkClick:g,onOpenAttachment:x,onOpenFile:b,renderDataPart:v,showCopy:y,answerActions:w,onRate:k,onAsk:N,layout:A,selfName:C,onQuote:T}){const S=a.metadata?.source,$=j(null),_="rows"===A,O=a.metadata?.createdAt,D=a.metadata?.replyTo??null,I=(e,t)=>T&&O&&!d&&t.trim()?()=>T({id:a.id,author_name:e,excerpt:Pe(t)}):void 0;if("system"===S){const e=Q(a);return e?/* @__PURE__ */L("div",{className:"text-center text-xs text-gray-500",children:e}):null}if("user"===a.role){const e=Q(a);if(!e)return null;const t=a.metadata?.author;if(_){const n=t?.name??(C||o.you),r=K(a);/* @__PURE__ */
|
|
117
117
|
return B(Je,{name:n,assistant:!1,avatarUrl:t?.avatar_url,mine:!t,createdAt:O,replyTo:D,labels:o,onQuote:I(n,e),menu:t?void 0:h,menuText:e,children:[
|
|
118
118
|
/* @__PURE__ */L("div",{className:"whitespace-pre-wrap break-words",children:/* @__PURE__ */L(Ue,{text:e,mention:o.assistantMention})}),r.length>0&&/* @__PURE__ */L(Ht,{files:r,labels:o,onOpen:x,start:!0})]})}return t?/* @__PURE__ */B("div",{className:"flex flex-col items-start gap-0.5",children:[
|
|
119
119
|
/* @__PURE__ */L("div",{className:"px-1 text-xs text-ink-faint",children:t.name}),
|
|
120
|
-
/* @__PURE__ */L("div",{className:"max-w-[85%] whitespace-pre-wrap break-words rounded-2xl border border-line bg-surface px-3 py-2 text-sm text-ink shadow-sm",children:e})]}):/* @__PURE__ */L(
|
|
121
|
-
/* @__PURE__ */L("div",{"data-answer-text":"",children:/* @__PURE__ */L(n,{renderFence:Et(o,d?void 0:N),tableActions:d?void 0:f,onLinkClick:g,children:e.text})},t)));if("data-file"===e.type){const t=e.data;return void(t&&"string"==typeof t.id&&!P.has(t.id)&&(P.add(t.id),F.push(/* @__PURE__ */L(Qt,{file:t,labels:o,onOpen:b},`file-${t.id}`))))}if(v&&e.type.startsWith("data-")&&!
|
|
120
|
+
/* @__PURE__ */L("div",{className:"max-w-[85%] whitespace-pre-wrap break-words rounded-2xl border border-line bg-surface px-3 py-2 text-sm text-ink shadow-sm",children:e})]}):/* @__PURE__ */L(Vt,{text:e,actions:h,files:K(a),labels:o,onOpenAttachment:x})}const M=a.parts.map(W),z=H(a),F=[],P=/* @__PURE__ */new Set,U=[];let q=-1;const Y=e=>{q<0&&(q=F.push(null)-1),U.push(e)},J=function(e){return de(e,"expires_at")}(a),V=function(e){return de(e,"notice")}(a);a.parts.forEach((e,t)=>{if("text"===e.type)return void(e.text.trim()&&F.push(
|
|
121
|
+
/* @__PURE__ */L("div",{"data-answer-text":"",children:/* @__PURE__ */L(n,{renderFence:Et(o,d?void 0:N),tableActions:d?void 0:f,onLinkClick:g,children:e.text})},t)));if("data-file"===e.type){const t=e.data;return void(t&&"string"==typeof t.id&&!P.has(t.id)&&(P.add(t.id),F.push(/* @__PURE__ */L(Qt,{file:t,labels:o,onOpen:b},`file-${t.id}`))))}if(v&&e.type.startsWith("data-")&&!Z.has(e.type)){const n=v(e,a);return void(n&&F.push(/* @__PURE__ */L(R,{children:n},`data-${t}`)))}if("reasoning"===e.type)return void(i&&e.text.trim()&&Y({kind:"reasoning",key:`r${t}`,text:e.text}));const r=M[t];r&&(Ut(r,M.slice(t+1).filter(e=>null!==e))||("approval-requested"===r.state&&r.approvalId&&"propose_plan"===r.toolName?F.push(
|
|
122
122
|
/* @__PURE__ */L(Ft,{approvalId:r.approvalId,plan:m?.get(r.approvalId),expiresAt:J.get(r.approvalId),input:r.input,labels:o,toolLabels:s,onApprove:p},r.toolCallId)):"approval-requested"===r.state&&r.approvalId?F.push(
|
|
123
|
-
/* @__PURE__ */L(jt,{tool:r,toolLabels:s,labels:o,onApprove:p,expiresAt:J.get(r.approvalId),notice:
|
|
123
|
+
/* @__PURE__ */L(jt,{tool:r,toolLabels:s,labels:o,onApprove:p,expiresAt:J.get(r.approvalId),notice:V.get(r.approvalId)},r.toolCallId)):Y({kind:"tool",key:r.toolCallId,tool:r})))}),q>=0&&(F[q]=/* @__PURE__ */L(t,{summary:qt(U,d,s,o),busy:d,label:o.steps,children:U.map(t=>"tool"===t.kind?/* @__PURE__ */L(Rt,{tool:t.tool,summary:z.get(t.tool.toolCallId),toolLabels:s,labels:o,showOutput:l},t.key):/* @__PURE__ */L(e,{status:"complete",label:/* @__PURE__ */B("details",{children:[
|
|
124
124
|
/* @__PURE__ */L("summary",{className:"cursor-pointer select-none",children:o.reasoning}),
|
|
125
125
|
/* @__PURE__ */L("div",{className:"mt-1 whitespace-pre-wrap text-gray-500",children:t.text})]})},t.key))},"chain"));const G=d&&function(e,t){if(t.some(e=>"approval-requested"===e?.state))return!1;let n=-1;for(let t=e.parts.length-1;t>=0;t-=1){const a=e.parts[t];if("step-start"!==a.type&&!a.type.startsWith("data-")&&("text"!==a.type||a.text.trim())){n=t;break}}if(n<0)return!0;if("text"===e.parts[n].type)return!1;const a=t[n];return!a||!Kt.has(a.state)||a}(a,M);if(G&&F.push(
|
|
126
126
|
/* @__PURE__ */L(Ge,{label:!0===G?void 0:$t(G,s,o).base,words:o.thinkingWords,since:u,secondsLabel:o.waitingSeconds,steadyLabel:o.thinking},"waiting")),0===F.length)return null;const X=a.metadata?.askedBy?o.askedBy.replace("{name}",a.metadata.askedBy.name):"";if(_){const e="staff"===S,t=e?o.teamName:r||o.assistantName||o.title,n=a.metadata?.run_id,s=Boolean(k&&n&&!d&&!S),i=Boolean(Q(a).trim())&&(!0===y||Boolean(w?.length)),l=d||!s&&!i?null:/* @__PURE__ */B(E,{children:[s&&k&&n&&/* @__PURE__ */L(Bt,{initial:a.metadata?.rating,labels:o,onRate:e=>k(n,e)}),
|
|
@@ -130,12 +130,12 @@ return B("div",re||oe||ae?{className:"flex w-fit min-w-0 max-w-[92%] flex-col it
|
|
|
130
130
|
/* @__PURE__ */B("div",{className:"flex flex-wrap items-start gap-x-2 gap-y-1",children:[
|
|
131
131
|
/* @__PURE__ */B("div",{className:"flex min-w-0 flex-1 items-start gap-1",children:[re&&/* @__PURE__ */L(Wt,{message:a,live:d,labels:o}),oe&&k&&se&&/* @__PURE__ */L(Bt,{initial:a.metadata?.rating,labels:o,onRate:e=>k(se,e)})]}),ae]})]}:{className:"flex max-w-[92%] flex-col items-start gap-0.5",children:[ne,te]})}var Gt={id:"pending-answer",role:"assistant",parts:[]};function Xt(e){const{messages:t,status:n,error:a,history:r,labels:s}=e,o="rows"===e.layout,l=j(null),c=I(()=>function(e){const t=/* @__PURE__ */new Map;for(const n of ie(e).values())t.set(n.approval_id,n);return t}(t),[t]),d=a?ge(a,e.errorCode??null,s):null,u=t[t.length-1],p="submitted"===n||"streaming"===n,[m,h]=$(void 0);S(()=>{h(e=>p?e??Date.now():void 0)},[p]);const f="ready"===n&&!a&&!e.handedOver&&"assistant"===u?.role&&!!e.onAsk,g=f?e.choices??[]:[],x=f&&0===g.length?e.followups??[]:[],b=j(null),v=j(!0),y=j(0),w=j("undefined"==typeof ResizeObserver),N=j(void 0),C=()=>{const e=l.current;e&&(e.scrollTop=e.scrollHeight)};S(()=>{const e=t[t.length-1];e&&e.id!==N.current&&(void 0===N.current||"user"===e.role&&!e.metadata?.author)&&(v.current=!0),N.current=e?.id,v.current&&C()},[t,n]),S(()=>{const e=l.current,t=b.current;if(!e||!t||"undefined"==typeof ResizeObserver)return;const n=new ResizeObserver(()=>{const t=e.clientHeight>0;t&&!w.current&&(v.current=!0),w.current=t,t&&(v.current?C():e.scrollTop=y.current)});return n.observe(e),n.observe(t),()=>n.disconnect()},[]);/* @__PURE__ */
|
|
132
132
|
return L("div",{ref:l,role:"log","aria-label":e.title,"aria-live":"polite","aria-busy":"submitted"===n||"streaming"===n,onScroll:()=>{const e=l.current;e&&0!==e.clientHeight&&w.current&&(y.current=e.scrollTop,v.current=e.scrollHeight-e.scrollTop-e.clientHeight<=48)},className:o?"min-h-0 flex-1 overflow-auto bg-surface px-2 py-3":"min-h-0 flex-1 overflow-auto bg-gray-50 p-3",children:/* @__PURE__ */B("div",{ref:b,className:o?"flex min-h-full flex-col gap-1":"flex min-h-full flex-col gap-3",children:["loading"===r&&/* @__PURE__ */B("div",{role:"status",className:"flex items-center gap-2 text-xs text-gray-500",children:[
|
|
133
|
-
/* @__PURE__ */L(A,{className:"h-3 w-3"}),s.loadingHistory]}),"failed"===r&&/* @__PURE__ */L(i,{tone:"warning",children:s.historyFailed}),0===t.length&&"idle"===r&&/* @__PURE__ */L("p",{className:"m-auto text-center text-sm text-gray-500",children:s.emptyState}),t.map((n,a)=>/* @__PURE__ */L(
|
|
134
|
-
/* @__PURE__ */L(
|
|
135
|
-
/* @__PURE__ */L(i,{tone:"danger",children:d.text}),d.retryable&&e.onRetry&&"error"===n&&/* @__PURE__ */L(k,{size:"sm",variant:"secondary",onClick:e.onRetry,children:s.retry})]})]})})}var en=(e,t)=>`${e.replace(/\/+$/,"")}/${t}`;function tn(e){return en(e,"assistant/chat/")}function nn(e,t){return en(e,`assistant/chat/${encodeURIComponent(t)}/`)}function an(e){const t=e.metadata;return Boolean(t?.source||t?.author||t?.askedBy)}function rn(e){return e.parts.map(e=>e.approval?.id??"").filter(Boolean).sort().join(",")}function sn(e){const t=j(e);t.current=e;const n=j(e.conversationId?{id:e.conversationId}:null),[a,r]=$("idle"),[s,o]=$(!1),[i,l]=$(null),[c,d]=$([]),[u,p]=$([]),[m,h]=$([]),[f,g]=$(!1),[x,b]=$(!1),[v,y]=$(!1),[w,k]=$(n.current),N=D(e=>{n.current=e,k(e)},[]),A=D((e,n)=>(t.current.fetch??fetch)(e,n),[]),C=I(()=>new F({api:tn(e.apiBase),fetch:A,prepareSendMessagesRequest:async({messages:e})=>{const{apiBase:a,getHeaders:r,credentials:s}=t.current;return{api:tn(a),body:G(e,n.current?.id??null),headers:await(r?.())??{},...s?{credentials:s}:{}}}}),[A]),T=q({transport:C,sendAutomaticallyWhen:P,onData:e=>{if(!
|
|
133
|
+
/* @__PURE__ */L(A,{className:"h-3 w-3"}),s.loadingHistory]}),"failed"===r&&/* @__PURE__ */L(i,{tone:"warning",children:s.historyFailed}),0===t.length&&"idle"===r&&/* @__PURE__ */L("p",{className:"m-auto text-center text-sm text-gray-500",children:s.emptyState}),t.map((n,a)=>/* @__PURE__ */L(Zt,{live:a===t.length-1&&p,waitingSince:m,message:n,speaker:e.assistantName,toolLabels:e.toolLabels,labels:s,showReasoning:e.showReasoning,showToolOutput:e.showToolOutput,showUsage:e.showUsage,tableActions:e.tableActions,onApprove:e.onApprove,onLinkClick:e.onLinkClick,onOpenFile:e.onOpenFile,renderDataPart:e.renderDataPart,plans:c,userActions:e.userMessageActions,onOpenAttachment:e.onOpenAttachment,showCopy:e.showCopy,answerActions:e.answerActions,onRate:e.onRate,onAsk:e.onAsk,layout:e.layout,selfName:e.selfName,onQuote:e.onQuote},n.id)),e.onAsk&&/* @__PURE__ */L(Pt,{choices:g,label:s.choices,onAnswer:e.onAsk}),e.onAsk&&/* @__PURE__ */L(Lt,{questions:x,label:s.followups,onAsk:e.onAsk}),e.handedOver&&/* @__PURE__ */L("div",{role:"status",className:"text-center text-xs text-gray-500",children:s.teamJoined}),"submitted"===n&&"assistant"!==u?.role&&
|
|
134
|
+
/* @__PURE__ */L(Zt,{message:Gt,live:!0,waitingSince:m,speaker:e.assistantName,toolLabels:e.toolLabels,labels:s,showReasoning:e.showReasoning,showToolOutput:e.showToolOutput,onApprove:e.onApprove,layout:e.layout},"pending-answer"),d&&/* @__PURE__ */B("div",{role:"alert",className:"flex flex-col items-start gap-2",children:[
|
|
135
|
+
/* @__PURE__ */L(i,{tone:"danger",children:d.text}),d.retryable&&e.onRetry&&"error"===n&&/* @__PURE__ */L(k,{size:"sm",variant:"secondary",onClick:e.onRetry,children:s.retry})]})]})})}var en=(e,t)=>`${e.replace(/\/+$/,"")}/${t}`;function tn(e){return en(e,"assistant/chat/")}function nn(e,t){return en(e,`assistant/chat/${encodeURIComponent(t)}/`)}function an(e){const t=e.metadata;return Boolean(t?.source||t?.author||t?.askedBy)}function rn(e){return e.parts.map(e=>e.approval?.id??"").filter(Boolean).sort().join(",")}function sn(e){const t=j(e);t.current=e;const n=j(e.conversationId?{id:e.conversationId}:null),[a,r]=$("idle"),[s,o]=$(!1),[i,l]=$(null),[c,d]=$([]),[u,p]=$([]),[m,h]=$([]),[f,g]=$(!1),[x,b]=$(!1),[v,y]=$(!1),[w,k]=$(n.current),N=D(e=>{n.current=e,k(e)},[]),A=D((e,n)=>(t.current.fetch??fetch)(e,n),[]),C=I(()=>new F({api:tn(e.apiBase),fetch:A,prepareSendMessagesRequest:async({messages:e})=>{const{apiBase:a,getHeaders:r,credentials:s}=t.current;return{api:tn(a),body:G(e,n.current?.id??null),headers:await(r?.())??{},...s?{credentials:s}:{}}}}),[A]),T=q({transport:C,sendAutomaticallyWhen:P,onData:e=>{if(!Z.has(e.type))return void t.current.onDataPart?.(e);if("data-error"===e.type)return void l(e.data.code);if("data-followups"===e.type)return void d(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-choices"===e.type)return void p(function(e){const t=e?.choices;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.length>=2?n.slice(0,4):[]}(e.data));if("data-conversation"!==e.type)return;const{id:a,guest_token:r}=e.data,s=n.current,o=r??(s?.id===a?s.guestToken:void 0);s&&s.id===a&&s.guestToken===o||(N(o?{id:a,guestToken:o}:{id:a}),t.current.onConversation?.(n.current))}}),{setMessages:R,stop:_}=T,O=D(async(e,n)=>{const{apiBase:a,getHeaders:s,credentials:i,onConversation:l}=t.current;r("loading"),d([]),p([]);try{const t=await A(nn(a,e),{method:"GET",headers:await(s?.())??{},...i?{credentials:i}:{},signal:n});if(n.aborted)return;if(404===t.status)return N(null),l?.(null),void r("idle");if(!t.ok)throw new Error(`history ${t.status}`);const c=await t.json();if(n.aborted)return;o(!0===c.handed_over),h(c.people??[]),R(e=>e.length>0?e:ue(c)),r("idle")}catch{n.aborted||r("failed")}},[A,R,N]),M=e.conversationId??null;S(()=>{if(M===(n.current?.id??null)&&T.messages.length>0)return;if(null===M)return n.current&&(N(null),_(),R([]),d([]),p([]),h([])),void r("idle");n.current?.id===M||N({id:M});const e=new AbortController;return O(M,e.signal),()=>e.abort()},[M,O,R,_,N]);const z=D(async e=>{const a=n.current?.id;if(a)try{const{apiBase:r,getHeaders:s,credentials:i}=t.current,l=await A(nn(r,a),{method:"GET",headers:await(s?.())??{},...i?{credentials:i}:{},...e?{signal:e}:{}});if(!l.ok||e?.aborted||n.current?.id!==a)return;const c=await l.json();o(!0===c.handed_over),h(c.people??[]);const d=ue(c),u=d.filter(an),p=d.find(e=>e.id===`pending-approvals-${a}`);if(0===u.length&&!p)return;R(e=>{const t=new Set(e.map(e=>e.id)),n=u.filter(e=>!t.has(e.id));let a=n.length>0?[...e,...n]:e;const r=new Set(a.filter(e=>e.id!==p?.id).flatMap(e=>rn(e).split(",").filter(Boolean)));if(p&&!rn(p).split(",").every(e=>r.has(e))){const e=a.find(e=>e.id===p.id);e?rn(e)!==rn(p)&&(a=[...a.filter(e=>e.id!==p.id),p]):a=[...a,p]}return a})}catch{}},[A,R]),L=j(z);L.current=z;const{status:B}=T,E="submitted"===B||"streaming"===B,U=j(!1),W=j(!1),H=!!e.subscribe;S(()=>{const e=U.current&&!E;if(U.current=E,!e)return;if(H&&!W.current)return;W.current=!1;const t=new AbortController;return L.current(t.signal),()=>t.abort()},[E,H]);const Y=j(E);Y.current=E;const Q=w?.id,J=w?.guestToken;S(()=>{const e=n.current,a=t.current.subscribe;if(e&&a)return a(e,()=>{Y.current?W.current=!0:L.current()})??void 0},[Q,J]);const K=D((e,t=[],n)=>{const a=e.trim();a&&(l(null),d([]),p([]),g(!1),T.sendMessage({text:a,...t.length>0?{files:t.map(V)}:{},...n?{metadata:{replyTo:n}}:{}}))},[T]),X=j(0),te=D((e,t)=>{X.current+=1;const n=`sending-${X.current}`;return R(a=>[...a,{id:n,role:"user",parts:[{type:"text",text:e}],...t?{metadata:{replyTo:t}}:{}}]),n},[R]),ae=D(e=>R(t=>t.filter(t=>t.id!==e)),[R]),re=D(async(e,a,r)=>{const s=n.current?.id;if(!s)return;g(!1),d([]),p([]);const o=a??te(e,r);try{const{apiBase:n,getHeaders:a,credentials:i}=t.current,l=await A(function(e,t){return en(e,`assistant/chat/${encodeURIComponent(t)}/messages/`)}(n,s),{method:"POST",headers:{"Content-Type":"application/json",...await(a?.())??{}},body:JSON.stringify(r?{text:e,reply_to:r.id}:{text:e}),...i?{credentials:i}:{}});if(!l.ok)throw new Error(`say ${l.status}`);const c=await l.json(),[d]=ue({id:s,messages:[c],pending_approvals:[]});R(e=>!d||e.some(e=>e.id===d.id)?e.filter(e=>e.id!==o):e.map(e=>e.id===o?d:e))}catch{ae(o),g(!0)}},[A,R,te,ae]),se=D(async e=>{const a=n.current?.id;if(!a)return!1;try{const{apiBase:n,getHeaders:r,credentials:s}=t.current,o=await A(function(e,t){return en(e,`assistant/chat/${encodeURIComponent(t)}/addressee/`)}(n,a),{method:"POST",headers:{"Content-Type":"application/json",...await(r?.())??{}},body:JSON.stringify({text:e}),...s?{credentials:s}:{}});return!!o.ok&&!0===(await o.json()).to_assistant}catch{return!1}},[A]),oe=e.mention??"",ie=e.name??"",le=!0===e.assistantDecides,ce=m.length>0,de=D((e,t=[],n={})=>{const a=e.trim();if(!a)return;y(!1);const{replyTo:r}=n;if(!ce||t.length>0||ee(a,oe,ie))return void K(a,t,r);if(!le||n.peopleOnly)return void re(a,void 0,r);const s=te(a,r);b(!0),se(a).then(e=>{if(!e)return y(!0),re(a,s,r);ae(s),K(a,[],r)}).finally(()=>b(!1))},[K,re,se,te,ae,ce,oe,ie,le]),pe=D(e=>{y(!1),K(ce?ne(e,oe):e)},[K,ce,oe]),me=D(()=>{xe(T.messages)&&(l(null),d([]),p([]),T.regenerate())},[T]),he=D((e,t)=>{l(null),d([]),p([]),T.addToolApprovalResponse({id:e,approved:t})},[T]),fe=D(()=>{_(),N(null),R([]),r("idle"),o(!1),l(null),d([]),p([]),h([]),g(!1),b(!1),y(!1),t.current.onConversation?.(null)},[R,_,N]);return{conversationId:w?.id??null,messages:T.messages,status:T.status,error:T.error,errorCode:i,canRetry:xe(T.messages),retry:me,historyState:a,handedOver:s,followups:c,choices:u,people:m,sayFailed:f,deciding:x,quiet:v,send:de,askAssistant:pe,stop:_,approve:he,reset:fe}}function on(e){const t={...ze,...e.labels},n=e.variant??"panel",a=sn({...e,mention:t.assistantMention,name:t.assistantName}),r=ae(a.people),s="submitted"===a.status||"streaming"===a.status,o=j(e.onBusyChange);o.current=e.onBusyChange,S(()=>{o.current?.(s)},[s]);const i="window"===n,l=e.showHeader??"window"!==n,c=e.title??t.title,u=le(a.messages),p=!0===e.readOnly,{onRate:m}=e,{conversationId:h}=a,f=j(!1),{send:g}=a,[x,b]=$(null);return S(()=>b(null),[h]),S(()=>{f.current||p||e.conversationId||!e.initialQuestion?.trim()||(f.current=!0,g(e.initialQuestion))},[]),/* @__PURE__ */B("section",{"aria-label":c,className:`flex h-full min-h-0 flex-col bg-white text-gray-900 ${e.className??""}`.trim(),children:[l&&/* @__PURE__ */B("header",{className:"flex items-center gap-2 border-b border-gray-200 px-3 py-2",children:[
|
|
136
136
|
/* @__PURE__ */L("h2",{className:"min-w-0 flex-1 truncate text-sm font-semibold",children:c}),a.messages.length>0&&/* @__PURE__ */L(k,{size:"sm",variant:"ghost",onClick:a.reset,children:t.newChat}),e.onClose&&/* @__PURE__ */L(d,{size:"sm","aria-label":t.close,onClick:e.onClose,children:/* @__PURE__ */L(N,{name:"close"})})]}),
|
|
137
137
|
/* @__PURE__ */B("div",{className:"flex min-h-0 flex-1",children:[
|
|
138
138
|
/* @__PURE__ */B("div",{className:"flex min-w-0 flex-1 flex-col",children:[
|
|
139
139
|
/* @__PURE__ */L(Xt,{messages:a.messages,status:a.status,error:a.error,errorCode:a.errorCode,history:a.historyState,handedOver:a.handedOver,labels:t,title:c,assistantName:r?t.assistantName||c:void 0,toolLabels:e.toolLabels,showReasoning:i&&!0===e.showReasoning,showToolOutput:i,showUsage:i&&!0===e.showUsage,tableActions:e.tableActions,onApprove:a.approve,onLinkClick:e.onLinkClick,onOpenFile:e.onOpenFile,renderDataPart:e.renderDataPart,userMessageActions:p?void 0:e.userMessageActions,showCopy:e.showCopy??i,answerActions:e.answerActions,onOpenAttachment:e.attachments?.onOpen,followups:a.followups,choices:a.choices,onAsk:p?void 0:a.askAssistant,onRetry:p?void 0:a.canRetry?a.retry:void 0,onRate:m&&h&&!p?(e,t)=>m({conversationId:h,runId:e,rating:t}):void 0,layout:e.layout,selfName:e.selfName,onQuote:p||"rows"!==e.layout?void 0:b}),u&&/* @__PURE__ */L(zt,{plan:u,labels:t},u.id),!p&&e.composerTop,!p&&a.sayFailed&&/* @__PURE__ */L("p",{role:"alert",className:"border-t border-line px-3 py-2 text-xs text-danger-text",children:t.sayFailed}),p?/* @__PURE__ */L("p",{role:"note",className:"border-t border-gray-200 px-3 py-2 text-xs text-gray-500",children:t.readOnly}):/* @__PURE__ */L(Xe,{labels:t,placeholder:r?t.peoplePlaceholder.replace("{names}",r).replace("{mention}",t.assistantMention):e.placeholder??t.placeholder,people:r||void 0,assistantDecides:e.assistantDecides,deciding:a.deciding,quiet:a.quiet,onAskToReply:()=>a.askAssistant(t.askToReplyText),busy:s,focusWhen:e.focusComposer,onSend:(e,t,n)=>a.send(e,t,{peopleOnly:n.peopleOnly,replyTo:n.reply_to&&x?.id===n.reply_to?x:void 0}),quote:x,onClearQuote:()=>b(null),onStop:a.stop,onNewChat:!l&&!1!==e.showNewChat&&a.messages.length>0?a.reset:void 0,actions:e.composerActions,attachments:e.attachments})]}),i&&e.details?.open&&/* @__PURE__ */L(At,{messages:a.messages,facts:e.details.facts,toolLabels:e.toolLabels,labels:t,assistantName:t.assistantName||c,onOpenFile:e.onOpenFile,onOpenAttachment:e.attachments?.onOpen})]})]})}function ln(e){const t={...ze,...e.labels},[n,a]=$(e.defaultOpen??!1),r=_(),s=j(null),o=j(n),i=t=>{a(t),e.onOpenChange?.(t)};return S(()=>{o.current&&!n&&s.current?.focus(),o.current=n},[n]),/* @__PURE__ */B("div",{className:"rosh-assistant",style:{display:"contents"},children:[n&&/* @__PURE__ */L("div",{id:r,role:"dialog","aria-label":e.title??t.title,onKeyDown:e=>{"Escape"===e.key&&i(!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__ */L(on,{...e,onClose:()=>i(!1),focusComposer:!0})}),
|
|
140
140
|
/* @__PURE__ */L("button",{ref:s,type:"button","aria-expanded":n,"aria-controls":n?r:void 0,"aria-label":n?t.close:t.open,onClick:()=>i(!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__ */L(N,n?{name:"close",size:20}:{name:"chat-bubble-left-right",size:22})})]})}function cn(e){if("bubble"===e.variant)/* @__PURE__ */return L(ln,{...e});const t="window"!==e.variant;/* @__PURE__ */
|
|
141
|
-
return L(on,{...e,className:`${t?"border-l border-gray-200":""} ${e.className??""}`.trim()})}export{jt as ApprovalCard,cn as AssistantChat,
|
|
141
|
+
return L(on,{...e,className:`${t?"border-l border-gray-200":""} ${e.className??""}`.trim()})}export{jt as ApprovalCard,cn as AssistantChat,Zt as AssistantMessage,ze as DEFAULT_ASSISTANT_CHAT_LABELS,Ae as DeletedText,we as EmojiPicker,Ce as ForwardedCard,Oe as MentionMenu,Ue as MentionText,Je as MessageRow,Z as OWN_DATA_PARTS,ve as PICKER_EMOJI,Ft as PlanApprovalCard,zt as PlanChecklist,be as QUICK_REACTIONS,Fe as QUOTE_EXCERPT_LENGTH,Ee as QuoteBlock,He as QuoteChip,qe as ROW_EXTRA_LABELS,ke as ReactionBarItems,Ne as ReactionPills,Qe as ReceiptTicks,Be as RowAvatar,Rt as ToolStep,je as TypingLine,ne as addressedToAssistant,V as attachmentPart,K as attachmentsOf,G as buildRequestBody,pt as compactCount,ht as estimateTokens,ge as failureView,Y as filesOf,$e as filterMentions,xt as finishedStats,Le as initialsOf,Re as insertMention,he as isDroppedConnection,bt as liveStats,Se as mentionQuery,te as mentionSpans,_e as mentionedIds,ee as mentionsAssistant,ue as messagesFromHistory,ae as peopleNames,le as pinnedPlan,ie as plansOf,Pe as quoteExcerpt,ye as reactionNames,ut as summarizeChat,mt as tokensPerSecond,H as toolSummariesOf,Te as typingWords,De as useMentionDraft};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{ImageAnnotator_default as default}from"../chunk-
|
|
2
|
+
export{ImageAnnotator_default as default}from"../chunk-SM3N5UJ2.js";import"../chunk-M6UKCZHT.js";import"../chunk-VQ35LXDC.js";import"../chunk-UQYNPYF4.js";import"../chunk-MRJKZWWV.js";import"../chunk-MAFUXCPZ.js";import"../chunk-IUVGHHR3.js";import"../chunk-C3QOHMR6.js";
|
package/dist/apps/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export{
|
|
2
|
+
export{FILES_ROUTE,chooseInFiles,openFilesInTrashMode,setFilesDemoTree,withdrawFilesChoice}from"../chunk-CUNYWXUT.js";export{setBrowserStartUrl}from"../chunk-LWLCNQY7.js";export{BUILTIN_APP_INFO}from"../chunk-V6HKE4HV.js";import{setSpreadsheetPreview as e}from"../chunk-KGRJSTPM.js";export{FILES_OFFICE_EXTENSIONS,FILES_ROLE_LABELS,FilesQuotaError,SPREADSHEET_PREVIEW_UPDATE_EVENT,claimSpreadsheetPreviewStage,createFileServerStore,filesRoleWrites,peekSpreadsheetPreviewStage,setFilesStore,setSpreadsheetPreview}from"../chunk-KGRJSTPM.js";import{setPdfPreview as t}from"../chunk-I4RJAMLJ.js";export{setPdfPreview}from"../chunk-I4RJAMLJ.js";import"../chunk-ZI2FDUYJ.js";import"../chunk-4LXCCZDM.js";import"../chunk-KNUR2UEG.js";import"../chunk-JDCM2VHG.js";import"../chunk-M2TQOJ3G.js";import"../chunk-FBZUEZK7.js";import"../chunk-5A7MWTXX.js";import"../chunk-BG3C4ALM.js";import"../chunk-GMLOMLCS.js";import"../chunk-UTQN5AIO.js";import"../chunk-EIFNESXS.js";import"../chunk-SXHV5OLA.js";import"../chunk-SF4IIV5Z.js";import"../chunk-FRCTA5FS.js";import"../chunk-VWGWZY7A.js";import"../chunk-UVHXVSB2.js";import"../chunk-WRV6QKJN.js";import"../chunk-AW7TOB6N.js";import"../chunk-4U5M37SF.js";import"../chunk-F3ZOO23R.js";import"../chunk-2QY5BJLA.js";import"../chunk-UGTRSRIW.js";import"../chunk-DPFEQQQU.js";import"../chunk-43JCG6EB.js";import"../chunk-DWGYC7OD.js";import"../chunk-YDJ5IZOU.js";import"../chunk-THAPVKEJ.js";import"../chunk-URHGHXDN.js";import"../chunk-5QFPTDQF.js";import"../chunk-UTISUEO4.js";import"../chunk-BUFAJJDZ.js";import"../chunk-ISVODSRP.js";import"../chunk-J75ZT2JQ.js";import"../chunk-R2VKEMZH.js";import"../chunk-BWJZTHZ6.js";import"../chunk-TD3ZQD5R.js";import"../chunk-F2RAIGCG.js";import"../chunk-PGN5ME7B.js";import"../chunk-62LW225J.js";import"../chunk-VY3UA6AR.js";import"../chunk-WCCS4VFE.js";import"../chunk-ZDXRSY2Y.js";import"../chunk-STKJA4PV.js";import"../chunk-M6UKCZHT.js";import{toast_default as o}from"../chunk-VQ35LXDC.js";import"../chunk-UQYNPYF4.js";import"../chunk-MRJKZWWV.js";import"../chunk-TWVUQUUD.js";import"../chunk-5FYDNH4Y.js";import"../chunk-LNXBTK7Q.js";import"../chunk-MAFUXCPZ.js";import{currentShellStrings as n}from"../chunk-IUVGHHR3.js";import"../chunk-C3QOHMR6.js";import{lazy as i}from"react";function r(e){const t=/\.([a-z0-9]+)(?:[?#].*)?$/i.exec((e||"").trim());return t?t[1].toLowerCase():""}var s=/* @__PURE__ */new Set(["csv","tsv"]),c=/* @__PURE__ */new Set(["xlsx","xls","xlsm","ods"]),a=/* @__PURE__ */new Set(["png","jpg","jpeg","gif","webp","bmp","svg","avif"]),m=/* @__PURE__ */new Set(["step","stp","stl","obj","gltf","glb","3mf","iges","igs"]);function l(e){const t=r(e);return"pdf"===t?"pdf":"dxf"===t?"dxf":s.has(t)?"csv":a.has(t)?"image":m.has(t)?"3d":null}function u(e){window.open(e,"_blank","noopener,noreferrer")}async function p(e,t,o){if(t.fetchBlob)return(await t.fetchBlob(o)).text();const n=await fetch(e);if(!n.ok)throw new Error(`fetch failed: ${n.status}`);return n.text()}function h(e,t){return(e instanceof Error?e.message:"")||t}async function k(i,s,a={}){const m=n().attachment,k=i?.url||"",j=i?.filename||m.fallbackName;if(!k&&!a.fetchBlob)return void o.error(m.noLink);const f=l(j)??l(k);if("csv"===f){try{e({csv:await p(k,a,i),filename:j}),s("/spreadsheet")}catch{o.error(m.spreadsheetFailed),k&&u(k)}return}if(c.has(r(j)||r(k)))return o.error(m.workbookUnavailable),void(k&&u(k));if(!f)return k?(o.info(m.noViewer),void u(k)):void o.error(m.noLink);if(!a.fetchBlob)return t({url:k,filename:j,kind:f}),void s("/preview");const d=t({filename:j,kind:f,converting:!0,convertingMessage:a.loadingMessage||m.loading});s("/preview");try{const e=await a.fetchBlob(i);d.update({url:URL.createObjectURL(e),filename:j,kind:f})}catch(e){d.update({filename:j,kind:f,converting:!1,convertingMessage:h(e,m.loadFailed)})}}function j(e,t,o={}){const i=n().attachment,s=[];let a=-1;return e.forEach((e,n)=>{const m=e?.url||"";if(!m&&!o.fetchBlob)return;const u=e?.filename||i.fallbackName;if(c.has(r(u)||r(m)))return;const p=l(u)??l(m);p&&"csv"!==p&&(n===t&&(a=s.length),s.push({att:e,sourceIndex:n,filename:u,url:m,kind:p}))}),{items:s,start:a}}async function f(e,o,i,r={}){const{items:s,start:c}=j(e,o,r);if(c<0||s.length<2){const t=e[o];return void(t&&await k(t,i,r))}const a=n().attachment,m=s.length;let l=null,u=-1;const p=e=>({position:{index:e,count:m},onPrevious:e>0?()=>{d(e-1)}:void 0,onNext:e<m-1?()=>{d(e+1)}:void 0}),f=e=>{l?l.update(e):(l=t(e),i("/preview"))};async function d(e){u=e;const{att:t,filename:o,url:n,kind:i}=s[e];if(r.fetchBlob){f({filename:o,kind:i,converting:!0,convertingMessage:r.loadingMessage||a.loading,...p(e)});try{const n=await r.fetchBlob(t),s=URL.createObjectURL(n);if(u!==e)return void URL.revokeObjectURL(s);f({url:s,filename:o,kind:i,...p(e)})}catch(t){if(u!==e)return;f({filename:o,kind:i,converting:!1,convertingMessage:h(t,a.loadFailed),...p(e)})}}else f({url:n,filename:o,kind:i,...p(e)})}await d(c)}var d=i(()=>import("../Calculator-4UBMDAJO.js")),w=i(()=>import("../Weather-TE4TTTQA.js")),S=i(()=>import("../CurrencyConverter-H3HHXXKT.js")),g=i(()=>import("../PomodoroTimer-JVCYYGRD.js")),v=i(()=>import("../Notepad-6FPZHJQ7.js")),T=i(()=>import("../WorldClock-5TPBHBYA.js")),F=i(()=>import("../Stock-S266KGAF.js")),E=i(()=>import("../Preview-4XSAIYMZ.js")),U=i(()=>import("../PdfViewer-EELX35ZI.js")),R=i(()=>import("../Files-PI3Z4TAO.js")),b=i(()=>import("../Browser-ORLSC6T4.js")),L={"/calculator":{component:d,label:"Calculator",size:"sm",allowPinOnTop:!0,utility:!0,widget:!0,dimensions:[280,420]},"/notepad":{component:v,label:"Notepad",size:"lg",allowPinOnTop:!0,flushBody:!0},"/weather":{component:w,label:"Weather",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,400]},"/currency":{component:S,label:"Currency Converter",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/pomodoro":{component:g,label:"Pomodoro Timer",size:"sm",utility:!0,widget:!0,dimensions:[320,600]},"/world-clock":{component:T,label:"World Clock",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,480]},"/stock":{component:F,label:"Stocks",size:"sm",utility:!0,widget:!0,autoHeight:!0,dimensions:[320,360]}},P={"/preview":{component:E,label:"Preview",size:"2xl",appStyle:!0,multiInstance:!0},"/files":{component:R,label:"Files",size:"xl",appStyle:!0}},C={"/browser":{component:b,label:"Browser",size:"2xl",appStyle:!0,multiInstance:!0}},I={...L,...P,...C};export{b as Browser,d as Calculator,S as CurrencyConverter,R as Files,v as Notepad,U as PdfViewer,g as PomodoroTimer,E as Preview,F as Stock,w as Weather,T as WorldClock,l as attachmentKind,I as bundledApps,P as documentApps,k as openAttachment,f as openAttachments,L as utilityApps,j as viewableAttachments,C as webApps};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"module";import{extname as t,isAbsolute as r,join as s,resolve as n}from"path";import{readFileSync as i,existsSync as o,statSync as c,readdirSync as a,mkdtempSync as l,rmSync as d}from"fs";import{execFileSync as h}from"child_process";import{tmpdir as f}from"os";import u from"assert/strict";import{createServer as w}from"http";import{pathToFileURL as p}from"url";function m(t,r){for(const n of[s(process.cwd(),"package.json"),r])try{return e(n)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}var g=class extends Error{};var y="efficient-shell-browser-check",v=`${y}: run real-browser checks, one <name>.entry.tsx page and one <name>.check.mjs check per scenario.\n\n ${y} [--dir tests/browser] [--css <file>]... [--tailwind <entry.css>]... [--serve <urlPath>=<file>]... [--define KEY=JSON]...\n\n --dir <folder> the scenario folder (default tests/browser)\n --css <file> a stylesheet every page links, in the order given\n --tailwind <entry.css> a Tailwind entry, compiled with this repository's @tailwindcss/cli,\n linked like a --css sheet, in the order given\n --serve <urlPath>=<file> a file the page can fetch at urlPath (starts with /)\n --define KEY=JSON replace KEY in the bundle with the JSON value\n --version, --help\n\nesbuild and playwright come from this repository's devDependencies.\nBROWSER_SHARD=<i>/<n> runs one shard. Exits 1 when a check fails.`,b={".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".html":"text/html; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".pdf":"application/pdf",".wasm":"application/wasm",".woff2":"font/woff2",".glb":"model/gltf-binary"},$=class extends Error{};function x(e,t,n){const i=r(t)?t:s(e,t);if(!o(i)||!c(i).isFile())throw new $(`${n} ${t}: no such file`);return i}function E(e,t,r){return i(x(e,t,r))}async function j(e){const{dir:t,root:r=process.cwd(),esbuild:i,chromium:o,stylesheets:c=[],serve:l={},define:d={},shard:h,reactDir:f,out:m=e=>console.log(e),err:g=(...e)=>console.error(...e)}=e,y=a(t).filter(e=>e.endsWith(".entry.tsx")).map(e=>e.replace(/\.entry\.tsx$/,"")).sort();if(0===y.length)throw new Error(`no *.entry.tsx found in ${t}`);const v=function(e,t){if(!t)return e;const r=/^(\d+)\/(\d+)$/.exec(t);if(!r)throw new Error(`BROWSER_SHARD must look like 1/3, got ${JSON.stringify(t)}`);const[s,n]=[Number(r[1]),Number(r[2])];if(!(n>=1&&s>=1&&s<=n))throw new Error(`BROWSER_SHARD ${t} is out of range`);return e.filter((e,t)=>t%n===s-1)}(y,h);h&&m(`shard ${h}: ${v.length} of ${y.length} scenarios`);const b=c.map((e,t)=>`/styles-${t+1}.css`),$=new Map(Object.entries(l));c.forEach((e,t)=>$.set(b[t],{contentType:"text/css; charset=utf-8",body:e}));const x=await o.launch({headless:!0});let E=!1;try{for(const e of v){const{default:o,describe:c,viewport:a}=await(import(p(s(t,`${e}.check.mjs`)).href)),l=await i.build({entryPoints:[s(t,`${e}.entry.tsx`)],bundle:!0,write:!1,outdir:s(r,"node_modules",".cache","efficient-shell-browser"),entryNames:"bundle",format:"esm",platform:"browser",target:"chrome120",jsx:"automatic",define:d,logLevel:"warning",...f&&{alias:{react:s(n(f),"react"),"react-dom":s(n(f),"react-dom")}}}),h=l.outputFiles.find(e=>e.path.endsWith(".js")).text,y=l.outputFiles.find(e=>e.path.endsWith(".css"))?.text??null,v=w((e,t)=>{const r=e.url??"/";if("/bundle.js"===r)return t.writeHead(200,{"content-type":"text/javascript; charset=utf-8"}),void t.end(h);if("/bundle.css"===r&&null!==y)return t.writeHead(200,{"content-type":"text/css; charset=utf-8"}),void t.end(y);const s=$.get(r);if(s)return t.writeHead(200,{"content-type":s.contentType}),void t.end(s.body);t.writeHead(200,{"content-type":"text/html; charset=utf-8"}),t.end("<!doctype html><html><head>"+b.map(e=>`<link rel="stylesheet" href="${e}">`).join("")+(null!==y?'<link rel="stylesheet" href="/bundle.css">':"")+'</head><body><div id="root"></div><script type="module" src="/bundle.js"><\/script></body></html>')});await new Promise((e,t)=>{v.once("error",t),v.listen(0,"127.0.0.1",e)});const j=v.address();u.ok(j&&"object"==typeof j);const R=`http://127.0.0.1:${j.port}`,S=await x.newPage({viewport:a??{width:1280,height:720}}),k=(e="")=>S.goto(`${R}/${e}`,{waitUntil:"networkidle"});S.setDefaultTimeout(15e3);const O=[];S.on("pageerror",e=>O.push(e));try{await k(),await o(S,{pageErrors:O,baseUrl:R,open:k}),m(`✔ ${c??e}`)}catch(t){E=!0,g(`✖ ${c??e}`),g(t);for(const e of O)g(" page error:",e.message)}finally{await S.close(),await new Promise(e=>v.close(e))}}}finally{await x.close()}return!E}var R=import.meta.url;process.exitCode=await async function(e,n){let i;try{i=function(e,n,i){let o="tests/browser";const c=[],a={},l={};for(let r=0;r<e.length;r++){const s=e[r];if("--help"===s||"-h"===s)return"help";if("--version"===s||"-v"===s)return"version";const d=s.indexOf("="),h=s.startsWith("--")&&d>0?s.slice(0,d):s;if(!["--dir","--css","--tailwind","--serve","--define"].includes(h))throw new $(`unknown argument "${s}"`);let f;if(h!==s)f=s.slice(d+1);else{if(r+1>=e.length)throw new $(`${h} needs a value`);f=e[++r]}if("--dir"===h)o=f;else if("--css"===h)c.push(E(n,f,h).toString("utf8"));else if("--tailwind"===h){const e=x(n,f,h);try{c.push(i(e))}catch(e){if(e instanceof g)throw new $(e.message);throw e}}else if("--serve"===h){const e=f.indexOf("=");if(e<=0)throw new $(`--serve ${f}: expected <urlPath>=<file>`);const r=f.slice(0,e);if(!r.startsWith("/"))throw new $(`--serve ${f}: the URL path must start with /`);const s=f.slice(e+1);a[r]={contentType:b[t(s).toLowerCase()]??"application/octet-stream",body:E(n,s,h)}}else{const e=f.indexOf("=");if(e<=0)throw new $(`--define ${f}: expected KEY=JSON`);const t=f.slice(0,e),r=f.slice(e+1);try{JSON.parse(r)}catch{throw new $(`--define ${t}: ${JSON.stringify(r)} is not JSON (a string needs its quotes: KEY='"text"')`)}l[t]=r}}return{dir:r(o)?o:s(n,o),stylesheets:c,serve:a,define:l}}(e,n.cwd,n.compileTailwind)}catch(e){if(!(e instanceof $))throw e;return n.err(`${y}: ${e.message}\n\n${v}`),1}if("help"===i)return n.out(v),0;if("version"===i)return n.out(n.version),0;n.env.BROWSER_SHARD&&(i.shard=n.env.BROWSER_SHARD),n.env.REACT_DIR&&(i.reactDir=n.env.REACT_DIR),i.root=n.cwd;try{return await n.runLane(i)?0:1}catch(e){return n.err(`${y}: ${e instanceof Error?e.message:String(e)}`),1}}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),version:"13.
|
|
2
|
+
import{createRequire as e}from"module";import{extname as t,isAbsolute as r,join as s,resolve as n}from"path";import{readFileSync as i,existsSync as o,statSync as c,readdirSync as a,mkdtempSync as l,rmSync as d}from"fs";import{execFileSync as h}from"child_process";import{tmpdir as f}from"os";import u from"assert/strict";import{createServer as w}from"http";import{pathToFileURL as p}from"url";function m(t,r){for(const n of[s(process.cwd(),"package.json"),r])try{return e(n)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}var g=class extends Error{};var y="efficient-shell-browser-check",v=`${y}: run real-browser checks, one <name>.entry.tsx page and one <name>.check.mjs check per scenario.\n\n ${y} [--dir tests/browser] [--css <file>]... [--tailwind <entry.css>]... [--serve <urlPath>=<file>]... [--define KEY=JSON]...\n\n --dir <folder> the scenario folder (default tests/browser)\n --css <file> a stylesheet every page links, in the order given\n --tailwind <entry.css> a Tailwind entry, compiled with this repository's @tailwindcss/cli,\n linked like a --css sheet, in the order given\n --serve <urlPath>=<file> a file the page can fetch at urlPath (starts with /)\n --define KEY=JSON replace KEY in the bundle with the JSON value\n --version, --help\n\nesbuild and playwright come from this repository's devDependencies.\nBROWSER_SHARD=<i>/<n> runs one shard. Exits 1 when a check fails.`,b={".js":"text/javascript; charset=utf-8",".mjs":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".html":"text/html; charset=utf-8",".json":"application/json; charset=utf-8",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".webp":"image/webp",".pdf":"application/pdf",".wasm":"application/wasm",".woff2":"font/woff2",".glb":"model/gltf-binary"},$=class extends Error{};function x(e,t,n){const i=r(t)?t:s(e,t);if(!o(i)||!c(i).isFile())throw new $(`${n} ${t}: no such file`);return i}function E(e,t,r){return i(x(e,t,r))}async function j(e){const{dir:t,root:r=process.cwd(),esbuild:i,chromium:o,stylesheets:c=[],serve:l={},define:d={},shard:h,reactDir:f,out:m=e=>console.log(e),err:g=(...e)=>console.error(...e)}=e,y=a(t).filter(e=>e.endsWith(".entry.tsx")).map(e=>e.replace(/\.entry\.tsx$/,"")).sort();if(0===y.length)throw new Error(`no *.entry.tsx found in ${t}`);const v=function(e,t){if(!t)return e;const r=/^(\d+)\/(\d+)$/.exec(t);if(!r)throw new Error(`BROWSER_SHARD must look like 1/3, got ${JSON.stringify(t)}`);const[s,n]=[Number(r[1]),Number(r[2])];if(!(n>=1&&s>=1&&s<=n))throw new Error(`BROWSER_SHARD ${t} is out of range`);return e.filter((e,t)=>t%n===s-1)}(y,h);h&&m(`shard ${h}: ${v.length} of ${y.length} scenarios`);const b=c.map((e,t)=>`/styles-${t+1}.css`),$=new Map(Object.entries(l));c.forEach((e,t)=>$.set(b[t],{contentType:"text/css; charset=utf-8",body:e}));const x=await o.launch({headless:!0});let E=!1;try{for(const e of v){const{default:o,describe:c,viewport:a}=await(import(p(s(t,`${e}.check.mjs`)).href)),l=await i.build({entryPoints:[s(t,`${e}.entry.tsx`)],bundle:!0,write:!1,outdir:s(r,"node_modules",".cache","efficient-shell-browser"),entryNames:"bundle",format:"esm",platform:"browser",target:"chrome120",jsx:"automatic",define:d,logLevel:"warning",...f&&{alias:{react:s(n(f),"react"),"react-dom":s(n(f),"react-dom")}}}),h=l.outputFiles.find(e=>e.path.endsWith(".js")).text,y=l.outputFiles.find(e=>e.path.endsWith(".css"))?.text??null,v=w((e,t)=>{const r=e.url??"/";if("/bundle.js"===r)return t.writeHead(200,{"content-type":"text/javascript; charset=utf-8"}),void t.end(h);if("/bundle.css"===r&&null!==y)return t.writeHead(200,{"content-type":"text/css; charset=utf-8"}),void t.end(y);const s=$.get(r);if(s)return t.writeHead(200,{"content-type":s.contentType}),void t.end(s.body);t.writeHead(200,{"content-type":"text/html; charset=utf-8"}),t.end("<!doctype html><html><head>"+b.map(e=>`<link rel="stylesheet" href="${e}">`).join("")+(null!==y?'<link rel="stylesheet" href="/bundle.css">':"")+'</head><body><div id="root"></div><script type="module" src="/bundle.js"><\/script></body></html>')});await new Promise((e,t)=>{v.once("error",t),v.listen(0,"127.0.0.1",e)});const j=v.address();u.ok(j&&"object"==typeof j);const R=`http://127.0.0.1:${j.port}`,S=await x.newPage({viewport:a??{width:1280,height:720}}),k=(e="")=>S.goto(`${R}/${e}`,{waitUntil:"networkidle"});S.setDefaultTimeout(15e3);const O=[];S.on("pageerror",e=>O.push(e));try{await k(),await o(S,{pageErrors:O,baseUrl:R,open:k}),m(`✔ ${c??e}`)}catch(t){E=!0,g(`✖ ${c??e}`),g(t);for(const e of O)g(" page error:",e.message)}finally{await S.close(),await new Promise(e=>v.close(e))}}}finally{await x.close()}return!E}var R=import.meta.url;process.exitCode=await async function(e,n){let i;try{i=function(e,n,i){let o="tests/browser";const c=[],a={},l={};for(let r=0;r<e.length;r++){const s=e[r];if("--help"===s||"-h"===s)return"help";if("--version"===s||"-v"===s)return"version";const d=s.indexOf("="),h=s.startsWith("--")&&d>0?s.slice(0,d):s;if(!["--dir","--css","--tailwind","--serve","--define"].includes(h))throw new $(`unknown argument "${s}"`);let f;if(h!==s)f=s.slice(d+1);else{if(r+1>=e.length)throw new $(`${h} needs a value`);f=e[++r]}if("--dir"===h)o=f;else if("--css"===h)c.push(E(n,f,h).toString("utf8"));else if("--tailwind"===h){const e=x(n,f,h);try{c.push(i(e))}catch(e){if(e instanceof g)throw new $(e.message);throw e}}else if("--serve"===h){const e=f.indexOf("=");if(e<=0)throw new $(`--serve ${f}: expected <urlPath>=<file>`);const r=f.slice(0,e);if(!r.startsWith("/"))throw new $(`--serve ${f}: the URL path must start with /`);const s=f.slice(e+1);a[r]={contentType:b[t(s).toLowerCase()]??"application/octet-stream",body:E(n,s,h)}}else{const e=f.indexOf("=");if(e<=0)throw new $(`--define ${f}: expected KEY=JSON`);const t=f.slice(0,e),r=f.slice(e+1);try{JSON.parse(r)}catch{throw new $(`--define ${t}: ${JSON.stringify(r)} is not JSON (a string needs its quotes: KEY='"text"')`)}l[t]=r}}return{dir:r(o)?o:s(n,o),stylesheets:c,serve:a,define:l}}(e,n.cwd,n.compileTailwind)}catch(e){if(!(e instanceof $))throw e;return n.err(`${y}: ${e.message}\n\n${v}`),1}if("help"===i)return n.out(v),0;if("version"===i)return n.out(n.version),0;n.env.BROWSER_SHARD&&(i.shard=n.env.BROWSER_SHARD),n.env.REACT_DIR&&(i.reactDir=n.env.REACT_DIR),i.root=n.cwd;try{return await n.runLane(i)?0:1}catch(e){return n.err(`${y}: ${e instanceof Error?e.message:String(e)}`),1}}(process.argv.slice(2),{cwd:process.cwd(),env:process.env,out:e=>console.log(e),err:e=>console.error(e),version:"13.18.0",compileTailwind:e=>function(e,t){if(!o(e)||!c(e).isFile())throw new g(`--tailwind ${e}: no such file`);const r=s(t,"node_modules",".bin","tailwindcss");if(!o(r))throw new g("--tailwind needs the Tailwind CLI: add @tailwindcss/cli to this repository's devDependencies");const n=l(s(f(),"browser-check-css-"));try{const o=s(n,"styles.css");return h(r,["-i",e,"-o",o],{cwd:t,stdio:["ignore","ignore","inherit"]}),i(o,"utf8")}finally{d(n,{recursive:!0,force:!0})}}(e,process.cwd()),runLane:e=>j({...e,esbuild:m("esbuild",R),chromium:m("playwright",R).chromium})});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";function o(t){return function(t,i){for(const r of[n(process.cwd(),"package.json"),i])try{return e(r)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}("typescript",t)}var s=/[.+^$()|[\]\\]/g;function a(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(s,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function c(e){const n=e.map(a);return e=>n.some(n=>n.test(e))}var g=new Set(["node_modules",".git"]),l=new Set(["dist","coverage",".next",".turbo"]);function u(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function h(e,t){const i=c(t),o=[...new Set(t.map(u))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),a=new Set,h=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?g.has(e.name)||""===t&&l.has(e.name)||h(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)h(e);return[...a].sort(d)}var d=(e,n)=>e<n?-1:e>n?1:0,f={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"]}};new Set((
|
|
2
|
+
import{createRequire as e}from"module";import{join as n}from"path";import{existsSync as t,readFileSync as i,readdirSync as r}from"fs";function o(t){return function(t,i){for(const r of[n(process.cwd(),"package.json"),i])try{return e(r)(t)}catch{}throw new Error(`${t} is not installed; add it to this repository's devDependencies`)}("typescript",t)}var s=/[.+^$()|[\]\\]/g;function a(e){let n="",t=0;for(let i=0;i<e.length;i++){const r=e[i];"*"===r?"*"===e[i+1]?"/"===e[i+2]?(n+="(?:[^/]+/)*",i+=2):(n+=".*",i+=1):n+="[^/]*":"?"===r?n+="[^/]":"{"===r?(n+="(?:",t+=1):"}"===r&&t>0?(n+=")",t-=1):n+=","===r&&t>0?"|":r.replace(s,"\\$&")}if(0!==t)throw new Error(`unbalanced { in glob "${e}"`);return new RegExp(`^${n}$`)}function c(e){const n=e.map(a);return e=>n.some(n=>n.test(e))}var g=new Set(["node_modules",".git"]),l=new Set(["dist","coverage",".next",".turbo"]);function u(e){const n=e.search(/[*?{]/),t=-1===n?e:e.slice(0,n),i=t.lastIndexOf("/");return-1===i?"":t.slice(0,i)}function h(e,t){const i=c(t),o=[...new Set(t.map(u))].sort(),s=o.filter(e=>!o.some(n=>n!==e&&(""===n||e.startsWith(`${n}/`)))),a=new Set,h=t=>{let o;try{o=r(n(e,t),{withFileTypes:!0})}catch{return}for(const e of o){const n=t?`${t}/${e.name}`:e.name;e.isDirectory()?g.has(e.name)||""===t&&l.has(e.name)||h(n):e.isFile()&&i(n)&&a.add(n)}};for(const e of s)h(e);return[...a].sort(d)}var d=(e,n)=>e<n?-1:e>n?1:0,f=(...e)=>["origin",...e].join("-");new RegExp(["(?:transformOrigin|transform-origin)\\s*[:=]\\s*[\"'`]?\\s*(?:top left|left top|0 0|0% 0%|0px 0px)(?![\\w%-])",`(?<![\\w-])!?${f("top","left")}(?![\\w-])`,`(?<![\\w-])!?${f("\\[0_0\\]")}`].join("|"));var p={busy:{words:["Accepting","Adding","Applying","Approving","Arranging","Asking","Assigning","Booking","Building","Calculating","Cancelling","Capturing","Changing","Checking","Choosing","Closing","Combining","Comparing","Completing","Confirming","Connecting","Converting","Copying","Correcting","Counting","Creating","Deleting","Detaching","Downloading","Drawing","Duplicating","Emailing","Ending","Exporting","Fetching","Filing","Finding","Flushing","Generating","Grouping","Importing","Linking","Loading","Locating","Looking","Making","Marking","Matching","Measuring","Merging","Moving","Opening","Ordering","Paying","Pending","Posting","Preparing","Previewing","Pricing","Processing","Provisioning","Publishing","Purging","Pushing","Queued","Queuing","Quoting","Re-booking","Re-importing","Re-opening","Reading","Rebooting","Rebuilding","Receiving","Reconciling","Reconnecting","Recording","Refreshing","Refunding","Regenerating","Registering","Reinstating","Rejecting","Removing","Reopening","Requesting","Resending","Resetting","Resolving","Restarting","Restoring","Resuming","Retrying","Reversing","Reverting","Running","Saving","Searching","Sending","Setting","Settling","Sharing","Signing","Splitting","Starting","Submitting","Suggesting","Switching","Syncing","Taking","Testing","Transferring","Typing","Updating","Uploading","Verifying","Waiting","Withdrawing","Working"]}};new Set((p.busy?.words??[]).map(e=>e.toLowerCase()));var m=(...e)=>e.join("-");m("p[xytrblse]?",""),m("max","[wh]",""),m("h",""),m("w",""),m("[wh]",""),m("min","h","");var w=class extends Error{},y=new Set(["$schema","schema","include","exclude","allow"]),$=e=>"object"==typeof e&&null!==e&&!Array.isArray(e),S=e=>"string"==typeof e&&""!==e.trim();var R="d3as2htf4hwbtr.cloudfront.net",b={dealer:{bucket:"inovit-dealer-portal-assets",hosts:["d201q0i87q901p.cloudfront.net"],key_pattern:"^marketing/"},media:{bucket:"regis-media-production",hosts:["media.regis.design","d21nnr9ivf9hcc.cloudfront.net"],key_pattern:"^[a-z0-9_]+/storefront/(?!uploads/thumbs/)"},site:{bucket:"inovit-ecommerce-media",hosts:["cdn.inovit.com","dhxlibd8r3td0.cloudfront.net"],key_pattern:"^images/"}},v=Object.values(b),k=Object.freeze([...new Set([...v.flatMap(e=>e.hosts),R,...v.map(e=>e.bucket)])].sort()),x=new RegExp([...k.map(e=>{return`(?<![\\w-])${n=e,n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?![\\w-])`;var n}),"(?<![\\w-])[a-z0-9]+\\.cloudfront\\.net(?![\\w-])","(?<![\\w-])(?:[a-z0-9-]+\\.)*s3(?:[.-][a-z0-9-]+)*\\.amazonaws\\.com(?![\\w-])","s3://"].join("|"),"gi");function C(e,n,t){const i=e.createSourceFile(n,t,e.ScriptTarget.Latest,!0,function(e,n){return n.endsWith(".tsx")?e.ScriptKind.TSX:n.endsWith(".jsx")?e.ScriptKind.JSX:/\.[cm]?js$/.test(n)?e.ScriptKind.JS:e.ScriptKind.TS}(e,n)),r=[],o=(e,n)=>{const t=i.getLineAndCharacterOfPosition(e.getStart(i)).line+1;for(const e of function(e){return[...e.matchAll(x)].map(e=>({match:e[0],index:e.index??0}))}(n)){const i=n.slice(0,e.index);r.push({line:t+(i.match(/\n/g)?.length??0),match:e.match})}},s=n=>{e.isStringLiteral(n)||e.isNoSubstitutionTemplateLiteral(n)||e.isTemplateHead(n)||e.isTemplateMiddle(n)||e.isTemplateTail(n)?o(n,n.text):e.isRegularExpressionLiteral(n)&&o(n,n.text.replace(/\\(.)/g,"$1")),e.forEachChild(n,s)};return s(i),r}var A="media-host-check.config.json",j="efficient-shell-media-host-check",T=`${j}: no code writes a media origin; files are reached through the storage backend, the API's URL, media() or imageCopyUrl() (harness API-15, SSOT-2).\n\n ${j} check this repository; exits 1 on a finding\n ${j} --json print the result as JSON\n\nRefused in any string, template or regular expression: every host and bucket in\nthe image-copies contract, any *.cloudfront.net host, any S3 endpoint, and s3://.\nReads ${A} in the current directory.`;function P(e,t,r){const o=[],s=c(r.exclude);for(const e of r.include)0===h(t,[e]).length&&o.push(`include "${e}" matches no file; delete it`);const a=h(t,r.include).filter(e=>(e=>/\.(?:[cm]?[jt]s|[jt]sx)$/.test(e)&&!e.endsWith(".d.ts"))(e)&&!s(e)),g=[];for(const r of a)for(const o of C(e,r,i(n(t,r),"utf8")))g.push({file:r,...o});const l=(e,n)=>e.toLowerCase()===n.toLowerCase();for(const e of r.allow)g.some(n=>n.file===e.file&&l(e.match,n.match))||o.push(`allow ${e.file} "${e.match}" matches nothing any more; delete it`);return{files:a.length,findings:g.filter(e=>!(e=>r.allow.some(n=>n.file===e.file&&l(n.match,e.match)))(e)),problems:o}}process.exitCode=function(e,r){let o=!1;for(const n of e){if("--help"===n||"-h"===n)return r.out(T),0;if("--version"===n||"-v"===n)return r.out(r.version),0;if("--json"!==n)return r.err(`${j}: unknown argument "${n}"\n\n${T}`),2;o=!0}const s=n(r.cwd,A);if(!t(s))return r.err(`${j}: no ${A} in ${r.cwd}. Run it from the repository root.`),2;let a;try{const e=function(e,n="media-host-check.config.json"){const t=[];if(!$(e))throw new w(`${n}: expected an object`);for(const n of Object.keys(e))y.has(n)||t.push(`unknown key "${n}"`);1!==e.schema&&t.push('"schema" must be 1');const i=(n,i)=>{const r=e[n];return void 0!==r||i?!Array.isArray(r)||!r.every(S)||i&&0===r.length?(t.push(`"${n}" must be ${i?"a non-empty":"an"} array of globs`),[]):r:[]},r=i("include",!0),o=i("exclude",!1),s=[];void 0===e.allow||Array.isArray(e.allow)||t.push('"allow" must be an array');for(const[n,i]of(Array.isArray(e.allow)?e.allow:[]).entries()){if(!($(i)&&S(i.file)&&S(i.match)&&S(i.reason))){t.push(`allow[${n}] needs "file", "match" and "reason", each a non-empty string`);continue}const e=Object.keys(i).filter(e=>!["file","match","reason"].includes(e));e.length&&t.push(`allow[${n}] has unknown keys: ${e.join(", ")}`),s.push({file:i.file,match:i.match,reason:i.reason})}if(t.length)throw new w(`${n}:\n ${t.join("\n ")}`);return{schema:1,include:r,exclude:o,allow:s}}(JSON.parse(i(s,"utf8")),A);a=P(r.loadTypeScript(),r.cwd,e)}catch(e){return r.err(`${j}: ${e instanceof w||e instanceof SyntaxError?e.message:String(e)}`),2}const c=a.findings.length>0||a.problems.length>0;if(o)return r.out(JSON.stringify({ok:!c,...a},null,2)),c?1:0;if(!c)return r.out(`${j}: ${a.files} files, no media origin written in code (harness API-15, SSOT-2).`),0;for(const e of a.findings)r.err(`${e.file}:${e.line} "${e.match}" is a media origin written in code.`);for(const e of a.problems)r.err(`${A}: ${e}`);return a.findings.length&&r.err(`\nReach the file through the storage backend, the URL the API returns, media() or imageCopyUrl() (harness API-15, SSOT-2). An origin that must stay goes in "allow" in ${A}, with its reason.`),1}(process.argv.slice(2),{cwd:process.cwd(),out:e=>console.log(e),err:e=>console.error(e),loadTypeScript:()=>o(import.meta.url),version:"13.18.0"});
|