juneau 0.14.1 → 0.15.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 +15 -0
- package/dist/components/AiChat/AiChat.d.ts +7 -1
- package/dist/components/AiChat/AiChat.d.ts.map +1 -1
- package/dist/components/AiSidebar/AiSidebar.d.ts +6 -1
- package/dist/components/AiSidebar/AiSidebar.d.ts.map +1 -1
- package/dist/index.cjs +21 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +502 -497
- package/dist/index.js.map +1 -1
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +86 -86
package/README.md
CHANGED
|
@@ -516,6 +516,7 @@ The sidebar anchors to the bottom-right of the viewport and opens at 60% screen
|
|
|
516
516
|
| `renderPart` | `RenderPartFn` | Custom part renderer — see below. |
|
|
517
517
|
| `onEntityClick` | `(entity, entityType?) => void` | Makes entity cards clickable — e.g. navigate to the record. |
|
|
518
518
|
| `headerActions` | `ReactNode` | Extra controls in the header, left of reset/minimize. Rendered as given — Juneau never interprets them. |
|
|
519
|
+
| `aboveInput` | `ReactNode` | Content rendered directly above the input (e.g. a feedback prompt). Forwarded to `AiChat`; hidden while minimized. |
|
|
519
520
|
|
|
520
521
|
**Header chrome (`headerActions`):**
|
|
521
522
|
|
|
@@ -581,6 +582,19 @@ function MyPage() {
|
|
|
581
582
|
| `placeholder` | `string` | Input placeholder text. |
|
|
582
583
|
| `renderPart` | `RenderPartFn` | Custom part renderer — see below. |
|
|
583
584
|
| `onEntityClick` | `(entity, entityType?) => void` | Makes entity cards clickable — e.g. navigate to the record. |
|
|
585
|
+
| `aboveInput` | `ReactNode` | Content rendered between the messages / error banner and the input. See below. |
|
|
586
|
+
|
|
587
|
+
**Slot above the input (`aboveInput`):**
|
|
588
|
+
|
|
589
|
+
Renders consumer content — a feedback prompt, a notice, anything — between the message list (and error banner) and the input. The wrapper carries `data-juneau="above-input"` and `data-juneau-above-input`, never shrinks, and spans the full width; the message list keeps scrolling and the input stays at the bottom. When the prop is `undefined` or `null`, nothing is rendered — not even the wrapper.
|
|
590
|
+
|
|
591
|
+
```tsx
|
|
592
|
+
<AiSidebar
|
|
593
|
+
aboveInput={
|
|
594
|
+
<MyFeedbackPrompt onSubmit={sendFeedback} />
|
|
595
|
+
}
|
|
596
|
+
/>
|
|
597
|
+
```
|
|
584
598
|
|
|
585
599
|
---
|
|
586
600
|
|
|
@@ -1018,6 +1032,7 @@ Beyond tokens, key elements carry stable `data-juneau` attributes so you can tar
|
|
|
1018
1032
|
| `data-juneau="message"` + `data-juneau-role="user\|assistant"` | Each message row |
|
|
1019
1033
|
| `data-juneau-segment="bubble\|card"` | Bubble / card segment inside a message |
|
|
1020
1034
|
| `data-juneau="typing-indicator"` | Typing indicator |
|
|
1035
|
+
| `data-juneau="above-input"` (also `data-juneau-above-input`) | `aboveInput` slot wrapper in `AiChat` — only rendered when the prop is set |
|
|
1021
1036
|
| `data-juneau="input"` | `AiInput` wrapper |
|
|
1022
1037
|
| `data-juneau="input-textarea"` | `AiInput` textarea |
|
|
1023
1038
|
| `data-juneau="error"` | `AiError` banner |
|
|
@@ -38,6 +38,12 @@ type Props = {
|
|
|
38
38
|
* Use it for a rich "get started" hero — headline, suggestion chips, anything.
|
|
39
39
|
*/
|
|
40
40
|
emptyState?: ReactNode;
|
|
41
|
+
/**
|
|
42
|
+
* Consumer content rendered between the message list / error banner and the
|
|
43
|
+
* input, e.g. a feedback prompt. When omitted nothing renders — not even the
|
|
44
|
+
* wrapper — so the default layout is unaffected.
|
|
45
|
+
*/
|
|
46
|
+
aboveInput?: ReactNode;
|
|
41
47
|
className?: string;
|
|
42
48
|
style?: CSSProperties;
|
|
43
49
|
};
|
|
@@ -49,6 +55,6 @@ type Props = {
|
|
|
49
55
|
* Used by AiSidebar (inside the sidebar chrome) and directly in dashboard
|
|
50
56
|
* or any other layout where you want chat without the sidebar wrapper.
|
|
51
57
|
*/
|
|
52
|
-
export declare function AiChat({ messages, input, isLoading, isConnecting, error, onInputChange, onSend, onStop, onProposalConfirm, onProposalCancel, onEntityClick, placeholder, assistantIcon, actions, sendIcon, renderPart, emptyState, className, style, }: Props): import("react").JSX.Element;
|
|
58
|
+
export declare function AiChat({ messages, input, isLoading, isConnecting, error, onInputChange, onSend, onStop, onProposalConfirm, onProposalCancel, onEntityClick, placeholder, assistantIcon, actions, sendIcon, renderPart, emptyState, aboveInput, className, style, }: Props): import("react").JSX.Element;
|
|
53
59
|
export {};
|
|
54
60
|
//# sourceMappingURL=AiChat.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiChat.d.ts","sourceRoot":"","sources":["../../../src/components/AiChat/AiChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,sFAAsF;IACtF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EACL,aAAa,EACb,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,aAAa,EACb,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,GACN,EAAE,KAAK,+
|
|
1
|
+
{"version":3,"file":"AiChat.d.ts","sourceRoot":"","sources":["../../../src/components/AiChat/AiChat.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAIxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,SAAS,EAAE,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,iGAAiG;IACjG,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,iBAAiB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,sFAAsF;IACtF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,EACrB,QAAQ,EACR,KAAK,EACL,SAAS,EACT,YAAY,EACZ,KAAK,EACL,aAAa,EACb,MAAM,EACN,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,WAAW,EACX,aAAa,EACb,OAAO,EACP,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,GACN,EAAE,KAAK,+BAuCP"}
|
|
@@ -64,7 +64,12 @@ type Props = {
|
|
|
64
64
|
* Use it for a rich "get started" hero — headline, suggestion chips, anything.
|
|
65
65
|
*/
|
|
66
66
|
emptyState?: ReactNode;
|
|
67
|
+
/**
|
|
68
|
+
* Consumer content rendered directly above the input, e.g. a feedback prompt.
|
|
69
|
+
* Forwarded to `AiChat`; hidden together with the chat body while minimized.
|
|
70
|
+
*/
|
|
71
|
+
aboveInput?: ReactNode;
|
|
67
72
|
};
|
|
68
|
-
export declare function AiSidebar({ title, icon, assistantIcon, actions, sendIcon, height, className, style, onReset, confirmReset, renderPart, onEntityClick, headerActions, badge, minimized, onMinimizedChange, emptyState, }: Props): import("react").JSX.Element;
|
|
73
|
+
export declare function AiSidebar({ title, icon, assistantIcon, actions, sendIcon, height, className, style, onReset, confirmReset, renderPart, onEntityClick, headerActions, badge, minimized, onMinimizedChange, emptyState, aboveInput, }: Props): import("react").JSX.Element;
|
|
69
74
|
export {};
|
|
70
75
|
//# sourceMappingURL=AiSidebar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AiSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/AiSidebar/AiSidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,KAAK,KAAK,GAAG;IACX,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD;;;;OAIG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,sFAAsF;IACtF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,IAAI,EACJ,aAAa,EACb,OAAO,EACP,QAAQ,EACR,MAAe,EACf,SAAS,EACT,KAAK,EACL,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,GACX,EAAE,KAAK,+
|
|
1
|
+
{"version":3,"file":"AiSidebar.d.ts","sourceRoot":"","sources":["../../../src/components/AiSidebar/AiSidebar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAGnE,KAAK,KAAK,GAAG;IACX,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,2EAA2E;IAC3E,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAChD;;;;OAIG;IACH,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,sFAAsF;IACtF,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE;;;OAGG;IACH,aAAa,CAAC,EAAE,SAAS,CAAC;IAC1B;;;OAGG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;OAGG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;CACxB,CAAC;AAEF,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,IAAI,EACJ,aAAa,EACb,OAAO,EACP,QAAQ,EACR,MAAe,EACf,SAAS,EACT,KAAK,EACL,OAAO,EACP,YAAY,EACZ,UAAU,EACV,aAAa,EACb,aAAa,EACb,KAAK,EACL,SAAS,EACT,iBAAiB,EACjB,UAAU,EACV,UAAU,GACX,EAAE,KAAK,+BA0EP"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),t=require("react/jsx-runtime")
|
|
2
|
-
Found document **INV-2024-0894** from **DataSys a.s.** for **CZK 390 000**.`,25),yield{type:"done"}}async function*
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react"),t=require("react/jsx-runtime"),$e=require("react-markdown"),Re=require("remark-gfm");function fe(e){return e.map(s=>s.role!=="assistant"||s.parts.some(a=>a.type==="text")?s:{...s,parts:[{type:"text",text:""}]})}const x=e=>new Promise(s=>setTimeout(s,e));function ge(e){return e.parts.filter(s=>s.type==="text").map(s=>s.text).join("")}async function re(e,s,a){for await(const r of e)if(a?.aborted||(s(r),r.type==="done"||r.type==="error"))break}function ie(e){return e.type==="proposal"}function Ee(e){return e.type==="chart"&&Array.isArray(e.series)}const De=1;function He(e){return e.map(s=>({...s,v:De,createdAt:s.createdAt.toISOString(),parts:s.parts.filter(a=>!(a.type==="activity"&&a.status==="running")).map(qe)}))}function qe(e){return ie(e)&&!e.proposal.resolved?{...e,proposal:{...e.proposal,resolved:"expired"}}:e}function Ve(e){return e.map(({v:s,...a})=>({...a,createdAt:new Date(a.createdAt)}))}function xe(e,s){if(s<=0||e.length<=s)return e;let a=e.length-s;for(;a<e.length&&e[a].role==="assistant";)a++;return e.slice(a)}function Oe(e,s){return s<=0||e.length<=s?[...e].sort(ue):[...e].sort(ue).slice(0,s)}const ue=(e,s)=>s.updatedAt.getTime()-e.updatedAt.getTime(),Fe={async*sendMessage(e){const s=[...e.messages].reverse().find(r=>r.role==="user"),a=s?ge(s).toLowerCase():"";a.includes("activity")||a.includes("progress")||a.includes("document")||a.includes("dokument")?yield*We():a.includes("table")||a.includes("data")||a.includes("list")||a.includes("show")?yield*Je():a.includes("proposal")||a.includes("suggest")||a.includes("recommend")?yield*Ze():a.includes("entity")||a.includes("card")||a.includes("detail")||a.includes("find")?yield*Ue():a.includes("help")||a.includes("what can")||a.includes("how do")?yield*Ke():a.includes("error")||a.includes("fail")||a.includes("break")?yield*Ge():yield*Qe(a)}};async function*We(){yield{type:"part",part:{type:"activity",id:"select-skill",title:"Selecting skill",description:"Looking for the best skill for this request.",status:"running"}},await x(700),yield{type:"part",part:{type:"activity",id:"select-skill",title:"Skill selected",description:"Using Document Search.",status:"done"}},await x(300),yield{type:"part",part:{type:"activity",id:"search-document",title:"Searching document",description:"Looking up document by ID.",status:"running"}},await x(900),yield{type:"part",part:{type:"activity",id:"search-document",title:"Document found",description:"Found document INV-2024-0894.",status:"done"}},await x(300),yield*v(`
|
|
2
|
+
Found document **INV-2024-0894** from **DataSys a.s.** for **CZK 390 000**.`,25),yield{type:"done"}}async function*Je(){yield*v(`Here is a summary of the data you requested:
|
|
3
3
|
|
|
4
|
-
`,30),await
|
|
5
|
-
Total across all entries: **7,900** — Type A accounts for the largest share at 53%.`,25),yield{type:"done"}}async function*
|
|
4
|
+
`,30),await x(400),yield{type:"part",part:{type:"table",columns:["Name","Category","Value","Status"],rows:[{Name:"Item Alpha",Category:"Type A",Value:"1,200",Status:"Active"},{Name:"Item Beta",Category:"Type B",Value:"840",Status:"Active"},{Name:"Item Gamma",Category:"Type A",Value:"3,050",Status:"Pending"},{Name:"Item Delta",Category:"Type C",Value:"610",Status:"Inactive"},{Name:"Item Epsilon",Category:"Type B",Value:"2,200",Status:"Active"}]}},await x(300),yield*v(`
|
|
5
|
+
Total across all entries: **7,900** — Type A accounts for the largest share at 53%.`,25),yield{type:"done"}}async function*Ze(){yield*v(`Based on the current data, I have a suggestion for you:
|
|
6
6
|
|
|
7
|
-
`,30),await
|
|
7
|
+
`,30),await x(500),yield{type:"part",part:{type:"proposal",proposal:{id:"mock-proposal-1",title:"Save this as a recurring report",description:"This summary can be automatically generated on a schedule so you always have up-to-date insights.",confirmLabel:"Save report",cancelLabel:"Dismiss",payload:{reportType:"summary",schedule:"weekly"}}}},yield{type:"done"}}async function*Ue(){yield*v(`I found these records matching your request:
|
|
8
8
|
|
|
9
|
-
`,30),await
|
|
9
|
+
`,30),await x(400),yield{type:"part",part:{type:"entity-list",title:"2 records found",entityType:"record",entities:[{id:"rec-2024-0894",title:"REC-2024-0894",subtitle:"DataSys a.s.",fields:[{label:"Amount",value:"CZK 390 000"},{label:"Due date",value:"2024-08-15"},{label:"Status",value:"Approved",badge:"success"}]},{id:"rec-2024-0895",title:"REC-2024-0895",subtitle:"NetFlow s.r.o.",fields:[{label:"Amount",value:"CZK 218 500"},{label:"Due date",value:"2024-08-22"},{label:"Status",value:"Pending",badge:"warning"}]}]}},await x(300),yield*v(`
|
|
10
10
|
Here is the detail of the first one:
|
|
11
11
|
|
|
12
|
-
`,25),await
|
|
12
|
+
`,25),await x(300),yield{type:"part",part:{type:"entity",entityType:"record",entity:{id:"rec-2024-0894",title:"REC-2024-0894",subtitle:"DataSys a.s. — Consulting",fields:[{label:"Amount",value:"CZK 390 000"},{label:"Issued",value:"2024-07-15"},{label:"Due date",value:"2024-08-15"},{label:"Status",value:"Approved",badge:"success"}]}}},yield{type:"done"}}async function*Ke(){yield*v(`I'm a general-purpose AI assistant. Here's what I can help with:
|
|
13
13
|
|
|
14
|
-
`,30),await
|
|
15
|
-
`,22),await
|
|
16
|
-
`,22),await
|
|
17
|
-
`,22),await
|
|
18
|
-
Try asking: *"Show me the data"* or *"Can you suggest something?"*`,25),yield{type:"done"}}async function*
|
|
14
|
+
`,30),await x(200),yield*v(`- **Summarise data** — ask me to show, list, or summarise information
|
|
15
|
+
`,22),await x(150),yield*v(`- **Make suggestions** — ask me to recommend or propose something
|
|
16
|
+
`,22),await x(150),yield*v(`- **Answer questions** — ask me anything and I'll do my best
|
|
17
|
+
`,22),await x(200),yield*v(`
|
|
18
|
+
Try asking: *"Show me the data"* or *"Can you suggest something?"*`,25),yield{type:"done"}}async function*Ge(){yield*v("Attempting to process your request…",30),await x(800),yield{type:"error",message:"Simulated error: the upstream service returned an unexpected response."}}async function*Qe(e){yield*v(`Got it — you asked about *"${e||"your request"}"*.
|
|
19
19
|
|
|
20
|
-
`,30),await
|
|
20
|
+
`,30),await x(400),yield*v(`I'm a **mock adapter** used for development. I respond to a few trigger words:
|
|
21
21
|
|
|
22
|
-
`,25),await
|
|
23
|
-
`,22),await
|
|
24
|
-
`,22),await
|
|
25
|
-
`,22),await
|
|
26
|
-
`,22),await
|
|
27
|
-
`,22),yield{type:"done"}}async function*v(e,s){for(let r=0;r<e.length;r+=3)yield{type:"text",text:e.slice(r,r+3)},await
|
|
28
|
-
`);n=o.pop()??"";for(const l of o){const p=l.trim();if(!(!p||p.startsWith(":"))&&p.startsWith("data: ")){const y=p.slice(6);if(y==="[DONE]"){yield{type:"done"};return}const c=s(y);for(const f of c)if(yield f,f.type==="done"||f.type==="error")return}}}}finally{a.releaseLock()}yield{type:"done"}}const
|
|
29
|
-
`);n=o.pop()??"";for(const l of o){const p=l.trim();if(!p)continue;const y=s(p);for(const c of y)if(yield c,c.type==="done"||c.type==="error")return}}if(n.trim()){const i=s(n.trim());for(const d of i)if(yield d,d.type==="done"||d.type==="error")return}}finally{a.releaseLock()}yield{type:"done"}}const st=e=>{const s=oe(e);return s.length>0?s:e?[{type:"text",text:e}]:[]};let at=0;const ee=()=>`msg-${++at}-${Date.now()}`,pe=he;function xe({adapter:e,context:s,onProposalConfirm:a,onProposalCancel:r,initialMessages:n,historyLimit:i,onMessagesChange:d}){const[o,l]=u.useState(n??[]),[p,y]=u.useState(""),[c,f]=u.useState(!1),[w,m]=u.useState(!1),[z,A]=u.useState(null),M=u.useRef(null),T=u.useRef(!1),V=u.useRef(d);u.useEffect(()=>{V.current=d}),u.useEffect(()=>{!T.current||c||(T.current=!1,V.current?.(o))},[o,c]);const N=u.useCallback(h=>{l(b=>{const x=b[b.length-1];if(!x||x.role!=="assistant")return b;if(h.type==="activity"&&h.id){const j=[...x.parts],_=j.findIndex(C=>C.type==="activity"&&C.id===h.id);if(_!==-1)return j[_]=h,[...b.slice(0,-1),{...x,parts:j}]}return[...b.slice(0,-1),{...x,parts:[...x.parts,h]}]})},[]),E=u.useCallback(h=>{l(b=>{const x=b[b.length-1];if(!x||x.role!=="assistant")return b;const j=[...x.parts],_=j[j.length-1];return _?.type==="text"?j[j.length-1]={type:"text",text:_.text+h}:j.push({type:"text",text:h}),[...b.slice(0,-1),{...x,parts:j}]})},[]),D=u.useCallback(async(h,b)=>{A(null);const x={id:ee(),role:"user",parts:[{type:"text",text:h}],createdAt:new Date},j=ee();let _=!1;const C=()=>{if(_)return;_=!0;const B={id:j,role:"assistant",parts:[],createdAt:new Date};l(q=>[...q,B])};l(B=>[...B,x]),f(!0),m(!0),M.current?.abort();const de=new AbortController;M.current=de;try{const B=ge([...b,x],i??Number.POSITIVE_INFINITY),q=e.sendMessage({messages:pe(B),context:s});await re(q,O=>{switch(m(!1),O.type){case"text":C(),E(O.text);break;case"part":C(),N(O.part);break;case"error":C(),N({type:"error",message:O.message}),A(O.message);break;case"done":break}},de.signal)}catch(B){const q=B instanceof Error?B.message:"Unknown error occurred";A(q),C(),N({type:"error",message:q})}finally{T.current=!0,f(!1),m(!1)}},[e,s,i,E,N]),Z=u.useCallback(async()=>{const h=p.trim();!h||c||(y(""),await D(h,o))},[p,c,o,D]),U=u.useCallback(async h=>{!h.trim()||c||await D(h,o)},[c,o,D]),K=u.useCallback(async h=>{if(c)return;A(null),f(!0),m(!0);const b={id:ee(),role:"assistant",parts:[],createdAt:new Date};l(_=>[..._,b]),M.current?.abort();const x=new AbortController;M.current=x;const j={id:ee(),role:"system",parts:[{type:"text",text:h}],createdAt:new Date};try{const _=e.sendMessage({messages:pe([j]),context:s});await re(_,C=>{switch(m(!1),C.type){case"text":E(C.text);break;case"part":N(C.part);break;case"error":N({type:"error",message:C.message}),A(C.message);break;case"done":break}},x.signal)}catch(_){const C=_ instanceof Error?_.message:"Unknown error occurred";A(C),N({type:"error",message:C})}finally{T.current=!0,f(!1),m(!1)}},[c,e,s,E,N]),G=u.useCallback(()=>{M.current?.abort(),f(!1),m(!1)},[]),Q=u.useCallback(h=>{M.current?.abort(),T.current=!0,l(h??[]),y(""),A(null),f(!1),m(!1)},[]),H=u.useCallback((h,b)=>{T.current=!0,l(x=>x.map(j=>({...j,parts:j.parts.map(_=>ie(_)&&_.proposal.id===h?{..._,proposal:{..._.proposal,resolved:b}}:_)})))},[]),Y=u.useCallback((h,b)=>{H(h,"confirmed"),a?.(h,b)},[a,H]),X=u.useCallback(h=>{H(h,"cancelled"),r?.(h)},[r,H]);return u.useMemo(()=>({messages:o,input:p,setInput:y,sendMessage:Z,sendMessageWithText:U,sendGreeting:K,stop:G,isLoading:c,isConnecting:w,error:z,reset:Q,confirmProposal:Y,cancelProposal:X}),[o,p,Z,U,K,G,c,w,z,Q,Y,X])}const ce={sidebarTitle:"AI Assistant",clearConversation:"Clear conversation",resetConversation:"Reset conversation",minimizeSidebar:"Minimize",expandSidebar:"Expand",userLabel:"You",inputPlaceholder:"Ask a question… (Enter to send)",sendMessage:"Send message",stopMessage:"Stop",typingMessage:"Assistant is typing",connectingMessage:"Connecting…",emptyStateText:"How can I help you today?",emptyStateHint:'Try: "Show me the data" or "Can you suggest something?"',proposalConfirm:"Confirm",proposalCancel:"Cancel",proposalConfirmed:"Confirmed",proposalCancelled:"Cancelled",proposalExpired:"No longer available",errorDismiss:"Dismiss",actionAddFile:"Add file",actionQuickActions:"Quick actions",actionNew:"New",actionHistory:"History",actionRules:"Rules",historyEmpty:"No previous chats",historyDeleteChat:"Delete chat"},_e=u.createContext(ce);function R(){return u.useContext(_e)}const nt="_root_14q8g_1",rt={root:nt};function it({children:e,theme:s,labels:a,defaultTitle:r,className:n,style:i}){const d={...ce,...r?{sidebarTitle:r}:{},...a},o=s?ot(s):void 0;return t.jsx(_e.Provider,{value:d,children:t.jsx("div",{className:[rt.root,n].filter(Boolean).join(" "),style:{...o,...i},children:e})})}function ot(e){const s={"--juneau-color-primary":e.colorPrimary,"--juneau-color-primary-dark":e.colorPrimaryDark,"--juneau-color-primary-light":e.colorPrimaryLight,"--juneau-color-primary-border":e.colorPrimaryBorder,"--juneau-color-accent":e.colorAccent,"--juneau-color-accent-dark":e.colorAccentDark,"--juneau-color-accent-light":e.colorAccentLight,"--juneau-color-accent-border":e.colorAccentBorder,"--juneau-color-surface":e.colorSurface,"--juneau-color-surface-raised":e.colorSurfaceRaised,"--juneau-color-surface-hover":e.colorSurfaceHover,"--juneau-color-border":e.colorBorder,"--juneau-color-border-subtle":e.colorBorderSubtle,"--juneau-color-text-primary":e.colorTextPrimary,"--juneau-color-text-secondary":e.colorTextSecondary,"--juneau-color-text-muted":e.colorTextMuted,"--juneau-color-text-faint":e.colorTextFaint,"--juneau-color-text-inverse":e.colorTextInverse,"--juneau-color-assistant-avatar":e.colorAssistantAvatar,"--juneau-color-error-bg":e.colorErrorBg,"--juneau-color-error-border":e.colorErrorBorder,"--juneau-color-error-text":e.colorErrorText,"--juneau-color-success-bg":e.colorSuccessBg,"--juneau-color-success-text":e.colorSuccessText,"--juneau-color-warning-bg":e.colorWarningBg,"--juneau-color-warning-text":e.colorWarningText,"--juneau-color-danger-bg":e.colorDangerBg,"--juneau-color-danger-text":e.colorDangerText,"--juneau-radius-sm":e.radiusSm,"--juneau-radius-md":e.radiusMd,"--juneau-radius-lg":e.radiusLg,"--juneau-radius-full":e.radiusFull,"--juneau-font-size-xs":e.fontSizeXs,"--juneau-font-size-sm":e.fontSizeSm,"--juneau-font-size-base":e.fontSizeBase,"--juneau-font-size-md":e.fontSizeMd,"--juneau-font-size-lg":e.fontSizeLg,"--juneau-font-size-xl":e.fontSizeXl,"--juneau-font-size-2xl":e.fontSize2xl,"--juneau-font-size-3xl":e.fontSize3xl,"--juneau-font-family":e.fontFamily,"--juneau-transition-fast":e.transitionFast};return Object.fromEntries(Object.entries(s).filter(([,a])=>a!==void 0))}const ne=u.createContext(null);function be(){const e=u.useContext(ne);if(!e)throw new Error("useAiChatContext must be used inside <AiChatProvider>. Wrap your app (or layout) with <AiChatProvider adapter={...}>.");return e}function ct(){return u.useContext(ne)}function lt({adapter:e,context:s,onProposalConfirm:a,onProposalCancel:r,initialMessages:n,historyLimit:i,onMessagesChange:d,children:o}){const[l,p]=u.useState(s),y=u.useCallback(w=>{p(typeof w=="function"?m=>w(m):w)},[]),c=xe({adapter:e,context:l,onProposalConfirm:a,onProposalCancel:r,initialMessages:n,historyLimit:i,onMessagesChange:d}),f=u.useMemo(()=>({...c,setContext:y}),[c,y]);return t.jsx(ne.Provider,{value:f,children:o})}const dt={sidebarTitle:"AI Asistent",clearConversation:"Vymazat konverzaci",resetConversation:"Resetovat konverzaci",minimizeSidebar:"Minimalizovat",expandSidebar:"Rozbalit",userLabel:"Vy",inputPlaceholder:"Zeptejte se na cokoliv… (Enter pro odeslání)",sendMessage:"Odeslat zprávu",stopMessage:"Zastavit",typingMessage:"Asistent píše",connectingMessage:"Připojování…",emptyStateText:"Jak vám mohu dnes pomoci?",emptyStateHint:'Zkuste: „Ukáž mi data" nebo „Máš nějaký návrh?"',proposalConfirm:"Potvrdit",proposalCancel:"Zrušit",proposalConfirmed:"Potvrzeno",proposalCancelled:"Zrušeno",proposalExpired:"Již není k dispozici",errorDismiss:"Zavřít",actionAddFile:"Přidat soubor",actionQuickActions:"Rychlé akce",actionNew:"Nový",actionHistory:"Historie",actionRules:"Pravidla",historyEmpty:"Žádné předchozí konverzace",historyDeleteChat:"Smazat konverzaci"};function je({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M456 0c-48.6 0-88 39.4-88 88l0 29.2L12.5 390.6c-14 10.8-16.6 30.9-5.9 44.9s30.9 16.6 44.9 5.9L126.1 384l133.1 0 46.6 113.1c5 12.3 19.1 18.1 31.3 13.1s18.1-19.1 13.1-31.3L311.1 384l40.9 0c1.1 0 2.1 0 3.2 0l46.6 113.2c5 12.3 19.1 18.1 31.3 13.1s18.1-19.1 13.1-31.3l-42-102C484.9 354.1 544 280 544 192l0-64 0-8 80.5-20.1c8.6-2.1 13.8-10.8 11.6-19.4C629 52 603.4 32 574 32l-50.1 0C507.7 12.5 483.3 0 456 0zm0 64a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"})})}function ut({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s6.2-22.8 16.4-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})})}function pt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M364.2 83.8c-24.4-24.4-64-24.4-88.4 0l-184 184c-42.1 42.1-42.1 110.3 0 152.4s110.3 42.1 152.4 0l152-152c10.9-10.9 28.7-10.9 39.6 0s10.9 28.7 0 39.6l-152 152c-64 64-167.6 64-231.6 0s-64-167.6 0-231.6l184-184c46.3-46.3 121.3-46.3 167.6 0s46.3 121.3 0 167.6l-176 176c-28.6 28.6-75 28.6-103.6 0s-28.6-75 0-103.6l144-144c10.9-10.9 28.7-10.9 39.6 0s10.9 28.7 0 39.6l-144 144c-6.7 6.7-6.7 17.7 0 24.4s17.7 6.7 24.4 0l176-176c24.4-24.4 24.4-64 0-88.4z"})})}function yt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M349.4 44.6c5.9-13.7 1.5-29.7-10.6-38.5s-28.6-8-39.9 1.8l-256 224c-10 8.8-13.6 22.9-8.9 35.3S50.7 288 64 288l111.5 0L98.6 467.4c-5.9 13.7-1.5 29.7 10.6 38.5s28.6 8 39.9-1.8l256-224c10-8.8 13.6-22.9 8.9-35.3s-16.6-20.7-30-20.7l-111.5 0L349.4 44.6z"})})}function mt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z"})})}function ht({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M75 75L41 41C25.9 25.9 0 36.6 0 57.9L0 168c0 13.3 10.7 24 24 24l110.1 0c21.4 0 32.1-25.9 17-41l-31.8-31.8C143.9 83.5 196.2 64 252.6 64C370.8 64 464 157.8 464 276c0 77.5-40.8 145.4-102 182.9c-15.1 9.2-19.9 29-10.7 44.1s29 19.9 44.1 10.7C471 467.5 528 378.4 528 276C528 124.1 404.5 0 252.6 0C186 0 125.3 26.4 80 70.2L75 75zM256 152c-13.3 0-24 10.7-24 24l0 104c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65 0-94.1c0-13.3-10.7-24-24-24z"})})}function ft({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M0 80C0 53.5 21.5 32 48 32l96 0c26.5 0 48 21.5 48 48l0 16 192 0 0-16c0-26.5 21.5-48 48-48l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-26.6 0c-25.8 50.9-72.7 88.5-129.4 99.8L384 416l32 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l32 0 0-72.2C135.3 332.5 88.4 294.9 62.6 244L48 244c-26.5 0-48-21.5-48-48L0 80zM128 240c0 70.7 57.3 128 128 128s128-57.3 128-128l0-128L128 112l0 128zM512 176l0-64-64 0 0 64-48 0 0 16c0 8.8-.7 17.4-2 25.8c3.3 .1 6.6 .2 9.9 .2l56 0c26.5 0 48-21.5 48-48l0-64zM48 176c0 26.5 21.5 48 48 48l56 0c3.4 0 6.7-.1 9.9-.2c-1.3-8.4-2-17-2-25.8l0-16-48 0 0-64-64 0 0 58z"})})}function gt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l448 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416z"})})}function xt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M432 64L208 64c-8.8 0-16 7.2-16 16l0 16-64 0 0-16c0-44.2 35.8-80 80-80L432 0c44.2 0 80 35.8 80 80l0 224c0 44.2-35.8 80-80 80l-16 0 0-64 16 0c8.8 0 16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zM0 192c0-35.3 28.7-64 64-64l256 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 192zm64 32c0 17.7 14.3 32 32 32l192 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L96 192c-17.7 0-32 14.3-32 32z"})})}function _t({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M125.7 160H176c17.7 0 32 14.3 32 32s-14.3 32-32 32H48c-17.7 0-32-14.3-32-32V64c0-17.7 14.3-32 32-32s32 14.3 32 32v51.2L97.6 97.6c87.5-87.5 229.3-87.5 316.8 0s87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3s-163.8-62.5-226.3 0L125.7 160z"})})}function bt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})})}const jt="_wrapper_v5oy7_1",vt="_table_v5oy7_8",wt="_th_v5oy7_14",Ct="_tr_v5oy7_24",kt="_td_v5oy7_32",F={wrapper:jt,table:vt,th:wt,tr:Ct,td:kt};function ve({part:e}){return t.jsx("div",{className:F.wrapper,"data-juneau":"table-part",children:t.jsxs("table",{className:F.table,children:[t.jsx("thead",{children:t.jsx("tr",{children:e.columns.map(s=>t.jsx("th",{className:F.th,children:s},s))})}),t.jsx("tbody",{children:e.rows.map((s,a)=>t.jsx("tr",{className:F.tr,children:e.columns.map(r=>t.jsx("td",{className:F.td,children:String(s[r]??"")},r))},a))})]})})}const Nt="_card_1un2m_1",At="_header_1un2m_9",St="_icon_1un2m_16",zt="_title_1un2m_24",Mt="_description_1un2m_30",Tt="_cardResolved_1un2m_37",It="_resolvedBadge_1un2m_41",Lt="_actions_1un2m_52",Pt="_confirm_1un2m_57",Bt="_cancel_1un2m_73",S={card:Nt,header:At,icon:St,title:zt,description:Mt,cardResolved:Tt,resolvedBadge:It,actions:Lt,confirm:Pt,cancel:Bt};function we({part:e,onConfirm:s,onCancel:a}){const r=R(),{proposal:n}=e,i=n.resolved==="confirmed"?r.proposalConfirmed:n.resolved==="cancelled"?r.proposalCancelled:n.resolved==="expired"?r.proposalExpired:null;return t.jsxs("div",{className:n.resolved?`${S.card} ${S.cardResolved}`:S.card,"data-juneau":"proposal-card",children:[t.jsxs("div",{className:S.header,children:[t.jsx("svg",{className:S.icon,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10 1a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 0110 1zM5.05 3.05a.75.75 0 011.06 1.06l-1.06 1.06a.75.75 0 11-1.06-1.06l1.06-1.06zm9.9 0a.75.75 0 010 1.06l-1.06 1.06a.75.75 0 11-1.06-1.06l1.06-1.06a.75.75 0 011.06 0zM10 6a4 4 0 100 8 4 4 0 000-8zm-9 4a.75.75 0 01.75-.75h1.5a.75.75 0 010 1.5h-1.5A.75.75 0 011 10zm15.75-.75a.75.75 0 000 1.5h1.5a.75.75 0 000-1.5h-1.5zM4.11 14.89a.75.75 0 010 1.06l-1.06 1.06a.75.75 0 11-1.06-1.06l1.06-1.06a.75.75 0 011.06 0zm11.84 1.06a.75.75 0 10-1.06-1.06l-1.06 1.06a.75.75 0 101.06 1.06l1.06-1.06zM10 17.25a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5a.75.75 0 01.75-.75z"})}),t.jsx("span",{className:S.title,children:n.title})]}),n.description&&t.jsx("p",{className:S.description,children:n.description}),i?t.jsx("span",{className:S.resolvedBadge,children:i}):t.jsxs("div",{className:S.actions,children:[t.jsx("button",{className:S.confirm,onClick:()=>s(n.id,n.payload),children:n.confirmLabel??r.proposalConfirm}),t.jsx("button",{className:S.cancel,onClick:()=>a(n.id),children:n.cancelLabel??r.proposalCancel})]})]})}const $t="_activity_2jjfs_1",Rt="_indicator_2jjfs_13",Et="_content_2jjfs_36",Dt="_title_2jjfs_40",Ht="_description_2jjfs_45",W={activity:$t,indicator:Rt,content:Et,title:Dt,description:Ht};function Ce({part:e}){return t.jsxs("div",{className:W.activity,"data-status":e.status,"data-juneau":"activity-part",children:[t.jsx("span",{className:W.indicator,"aria-hidden":"true"}),t.jsxs("div",{className:W.content,children:[t.jsx("div",{className:W.title,children:e.title}),e.description&&t.jsx("div",{className:W.description,children:e.description})]})]})}const qt="_card_jwkcu_1",Vt="_cardClickable_jwkcu_14",Ot="_header_jwkcu_24",Ft="_title_jwkcu_30",Wt="_subtitle_jwkcu_36",Jt="_fields_jwkcu_41",Zt="_fieldRow_jwkcu_48",Ut="_fieldLabel_jwkcu_55",Kt="_fieldValue_jwkcu_61",Gt="_badge_jwkcu_68",Qt="_badgeSuccess_jwkcu_76",Yt="_badgeWarning_jwkcu_81",Xt="_badgeDanger_jwkcu_86",es="_badgeNeutral_jwkcu_91",k={card:qt,cardClickable:Vt,header:Ot,title:Ft,subtitle:Wt,fields:Jt,fieldRow:Zt,fieldLabel:Ut,fieldValue:Kt,badge:Gt,badgeSuccess:Qt,badgeWarning:Yt,badgeDanger:Xt,badgeNeutral:es},ts={success:k.badgeSuccess,warning:k.badgeWarning,danger:k.badgeDanger,neutral:k.badgeNeutral};function le({part:e,onEntityClick:s}){const{entity:a,entityType:r}=e,n=s!==void 0,i=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:k.header,children:[t.jsx("span",{className:k.title,children:a.title}),a.subtitle&&t.jsx("span",{className:k.subtitle,children:a.subtitle})]}),a.fields&&a.fields.length>0&&t.jsx("dl",{className:k.fields,children:a.fields.map((d,o)=>t.jsxs("div",{className:k.fieldRow,children:[t.jsx("dt",{className:k.fieldLabel,children:d.label}),t.jsx("dd",{className:k.fieldValue,children:d.badge?t.jsx("span",{className:`${k.badge} ${ts[d.badge]}`,children:d.value}):d.value})]},o))})]});return n?t.jsx("button",{type:"button",className:`${k.card} ${k.cardClickable}`,onClick:()=>s(a,r),"data-juneau":"entity-card",children:i}):t.jsx("div",{className:k.card,"data-juneau":"entity-card",children:i})}const ss="_list_a2maw_1",as="_listTitle_a2maw_11",ye={list:ss,listTitle:as};function ke({part:e,onEntityClick:s}){return t.jsxs("div",{className:ye.list,"data-juneau":"entity-list-part",children:[e.title&&t.jsx("span",{className:ye.listTitle,children:e.title}),e.entities.map((a,r)=>t.jsx(le,{part:{type:"entity",entity:a,entityType:e.entityType},onEntityClick:s},a.id??r))]})}const ns="_markdown_1yi3y_1",rs="_unknownPart_1yi3y_84",is="_errorText_1yi3y_98",os="_errorIcon_1yi3y_106",te={markdown:ns,unknownPart:rs,errorText:is,errorIcon:os};function Ne({part:e,onProposalConfirm:s,onProposalCancel:a,onEntityClick:r,renderPart:n}){if(n){const i=n(e);if(i!=null)return t.jsx(t.Fragment,{children:i})}switch(e.type){case"text":return t.jsx("div",{className:te.markdown,children:t.jsx(Be,{remarkPlugins:[$e],children:e.text})});case"table":return t.jsx(ve,{part:e});case"activity":return t.jsx(Ce,{part:e});case"proposal":return t.jsx(we,{part:e,onConfirm:s,onCancel:a});case"entity":return t.jsx(le,{part:e,onEntityClick:r});case"entity-list":return t.jsx(ke,{part:e,onEntityClick:r});case"error":return t.jsxs("span",{className:te.errorText,children:[t.jsx(bt,{className:te.errorIcon}),e.message]});default:return globalThis.process?.env?.NODE_ENV!=="production"?t.jsxs("div",{className:te.unknownPart,children:["Unhandled part type: ",t.jsx("code",{children:e.type})," — pass a"," ",t.jsx("code",{children:"renderPart"})," prop to render it."]}):null}}const cs="_wrapper_1q20p_1",ls="_user_1q20p_8",ds="_assistant_1q20p_12",us="_avatar_1q20p_16",ps="_content_1q20p_43",ys="_bubble_1q20p_51",ms="_card_1q20p_70",hs="_empty_1q20p_92",I={wrapper:cs,user:ls,assistant:ds,avatar:us,content:ps,bubble:ys,card:ms,empty:hs},fs=new Set(["text","error","activity"]);function Ae(e){return!fs.has(e.type)}function gs(e){const s=[];return e.forEach((a,r)=>{const n=Ae(a),i=s[s.length-1];if(i&&!n&&!i.card){i.parts.push({part:a,index:r});return}s.push({card:n,parts:[{part:a,index:r}]})}),s}function Se({message:e,onProposalConfirm:s,onProposalCancel:a,onEntityClick:r,assistantIcon:n,renderPart:i}){const d=R(),o=e.role==="user",l=(y,c)=>t.jsx(Ne,{part:y,onProposalConfirm:s,onProposalCancel:a,onEntityClick:r,renderPart:i},c),p=e.parts.some(Ae);return t.jsxs("div",{className:`${I.wrapper} ${o?I.user:I.assistant}`,"data-juneau":"message","data-juneau-role":e.role,children:[!o&&t.jsx("div",{className:I.avatar,"aria-hidden":"true","data-juneau":"assistant-avatar",children:n??t.jsx(je,{})}),p?t.jsx("div",{className:I.content,children:gs(e.parts).map((y,c)=>t.jsx("div",{className:y.card?I.card:I.bubble,"data-juneau-segment":y.card?"card":"bubble",children:y.parts.map(({part:f,index:w})=>l(f,w))},c))}):t.jsxs("div",{className:I.bubble,"data-juneau-segment":"bubble",children:[e.parts.map((y,c)=>l(y,c)),e.parts.length===0&&t.jsx("span",{className:I.empty})]}),o&&t.jsx("div",{className:I.avatar,children:d.userLabel})]})}const xs="_wrapper_1dvvu_1",_s="_dot_1dvvu_8",bs="_connectingLabel_1dvvu_19",J={wrapper:xs,dot:_s,connectingLabel:bs};function ze({connecting:e=!1}){const s=R();return t.jsxs("div",{className:J.wrapper,"aria-label":e?s.connectingMessage:s.typingMessage,"data-juneau":"typing-indicator",children:[t.jsx("span",{className:J.dot}),t.jsx("span",{className:J.dot}),t.jsx("span",{className:J.dot}),e&&t.jsx("span",{className:J.connectingLabel,children:s.connectingMessage})]})}const js="_list_1f8gn_1",vs="_empty_1f8gn_11",ws="_hint_1f8gn_24",Cs="_typing_1f8gn_31",se={list:js,empty:vs,hint:ws,typing:Cs};function Me({messages:e,isLoading:s,isConnecting:a,onProposalConfirm:r,onProposalCancel:n,onEntityClick:i,assistantIcon:d,renderPart:o,emptyState:l}){const p=R(),y=u.useRef(null);return u.useEffect(()=>{y.current?.scrollIntoView({behavior:"smooth"})},[e,s]),t.jsxs("div",{className:se.list,"data-juneau":"message-list",children:[e.length===0&&(l??t.jsxs("div",{className:se.empty,"data-juneau":"empty-state",children:[t.jsx("p",{children:p.emptyStateText}),t.jsx("p",{className:se.hint,children:t.jsx("em",{children:p.emptyStateHint})})]})),e.map(c=>t.jsx(Se,{message:c,onProposalConfirm:r,onProposalCancel:n,onEntityClick:i,assistantIcon:d,renderPart:o},c.id)),s&&t.jsx("div",{className:se.typing,children:t.jsx(ze,{connecting:a})}),t.jsx("div",{ref:y})]})}const ks="_wrapper_v8iyr_1",Ns="_textarea_v8iyr_11",As="_toolbar_v8iyr_35",Ss="_actions_v8iyr_45",zs="_actionBtn_v8iyr_52",Ms="_sendBtn_v8iyr_85",Ts="_spinnerIcon_v8iyr_116",Is="_stopBtn_v8iyr_126",Ls="_stopIcon_v8iyr_149",L={wrapper:ks,textarea:Ns,toolbar:As,actions:Ss,actionBtn:zs,sendBtn:Ms,spinnerIcon:Ts,stopBtn:Is,stopIcon:Ls};function Te({value:e,onChange:s,onSend:a,onStop:r,isLoading:n,placeholder:i,actions:d,sendIcon:o}){const l=R(),p=u.useRef(null),y=u.useRef(!1);u.useEffect(()=>{y.current&&!n&&p.current?.focus(),y.current=n},[n]);const c=[{icon:t.jsx(pt,{}),label:l.actionAddFile},{icon:t.jsx(yt,{}),label:l.actionQuickActions},{icon:t.jsx(mt,{}),label:l.actionNew},{icon:t.jsx(ht,{}),label:l.actionHistory},{icon:t.jsx(ft,{}),label:l.actionRules}],f=d??c,w=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),n||a())};return t.jsxs("div",{className:L.wrapper,"data-juneau":"input",children:[t.jsx("textarea",{ref:p,className:L.textarea,"data-juneau":"input-textarea",value:e,onChange:m=>s(m.target.value),onKeyDown:w,placeholder:i??l.inputPlaceholder,rows:3,"aria-label":l.sendMessage}),t.jsxs("div",{className:L.toolbar,children:[f.length>0&&t.jsx("div",{className:L.actions,children:f.map((m,z)=>t.jsxs("button",{className:L.actionBtn,type:"button",disabled:n,"aria-label":m.label,onClick:m.onClick,children:[m.icon,t.jsx("span",{children:m.label})]},z))}),n&&r?t.jsxs("button",{className:L.stopBtn,onClick:r,"aria-label":l.stopMessage,type:"button",children:[t.jsx("svg",{className:L.stopIcon,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),t.jsx("span",{children:l.stopMessage})]}):t.jsxs("button",{className:L.sendBtn,onClick:a,disabled:n||!e.trim(),"aria-label":l.sendMessage,type:"button",children:[n?t.jsx("svg",{className:L.spinnerIcon,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:t.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"32",strokeDashoffset:"12"})}):o??t.jsx(ut,{}),t.jsx("span",{children:l.sendMessage})]})]})]})}const Ps="_wrapper_1kefv_1",Bs="_icon_1kefv_14",$s="_message_1kefv_20",Rs="_dismiss_1kefv_24",ae={wrapper:Ps,icon:Bs,message:$s,dismiss:Rs};function Ie({message:e,onDismiss:s}){const a=R();return t.jsxs("div",{className:ae.wrapper,role:"alert","data-juneau":"error",children:[t.jsx("svg",{className:ae.icon,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})}),t.jsx("span",{className:ae.message,children:e}),s&&t.jsx("button",{className:ae.dismiss,onClick:s,"aria-label":a.errorDismiss,children:t.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]})}const Es="_chat_1acbe_1",Ds={chat:Es};function Le({messages:e,input:s,isLoading:a,isConnecting:r,error:n,onInputChange:i,onSend:d,onStop:o,onProposalConfirm:l,onProposalCancel:p,onEntityClick:y,placeholder:c,assistantIcon:f,actions:w,sendIcon:m,renderPart:z,emptyState:A,className:M,style:T}){return t.jsxs("div",{className:[Ds.chat,M].filter(Boolean).join(" "),style:T,"data-juneau":"chat",children:[t.jsx(Me,{messages:e,isLoading:a,isConnecting:r,onProposalConfirm:l,onProposalCancel:p,onEntityClick:y,assistantIcon:f,renderPart:z,emptyState:A}),n&&t.jsx(Ie,{message:n}),t.jsx(Te,{value:s,onChange:i,onSend:d,onStop:o,isLoading:a,placeholder:c,actions:w,sendIcon:m})]})}const Hs="_header_1ss3g_1",qs="_left_1ss3g_12",Vs="_icon_1ss3g_18",Os="_title_1ss3g_23",Fs="_resetBtn_1ss3g_29",Ws="_actions_1ss3g_50",Js="_badge_1ss3g_57",$={header:Hs,left:qs,icon:Vs,title:Os,resetBtn:Fs,actions:Ws,badge:Js};function Pe({title:e,onMinimize:s,isMinimized:a,icon:r,onReset:n,badge:i,headerActions:d}){const o=R();return t.jsxs("div",{className:$.header,"data-juneau":"header",children:[t.jsxs("div",{className:$.left,children:[t.jsx("span",{className:$.icon,"aria-hidden":"true","data-juneau":"header-icon",children:r??t.jsx(je,{})}),t.jsx("span",{className:$.title,children:e??o.sidebarTitle}),i&&t.jsx("span",{className:$.badge,"data-juneau":"header-badge",children:i})]}),(s||n||d)&&t.jsxs("div",{className:$.actions,children:[d,n&&t.jsx("button",{className:$.resetBtn,onClick:n,title:o.resetConversation,"aria-label":o.resetConversation,"data-juneau":"header-reset",children:t.jsx(_t,{})}),s&&t.jsx("button",{className:$.resetBtn,onClick:s,title:a?o.expandSidebar:o.minimizeSidebar,"aria-label":a?o.expandSidebar:o.minimizeSidebar,"data-juneau":"header-minimize",children:a?t.jsx(xt,{}):t.jsx(gt,{})})]})]})}const Zs="_sidebar_17ski_1",Us="_minimized_17ski_20",me={sidebar:Zs,minimized:Us};function Ks({title:e,icon:s,assistantIcon:a,actions:r,sendIcon:n,height:i="60vh",className:d,style:o,onReset:l,confirmReset:p,renderPart:y,onEntityClick:c,headerActions:f,badge:w,minimized:m,onMinimizedChange:z,emptyState:A}){const[M,T]=u.useState(!1),V=m!==void 0,N=V?m:M,E=()=>{const j=!N;V||T(j),z?.(j)},{messages:D,input:Z,setInput:U,sendMessage:K,stop:G,isLoading:Q,isConnecting:H,error:Y,reset:X,confirmProposal:h,cancelProposal:b}=be(),x=l?async()=>{p&&!await p()||(X(),l())}:void 0;return t.jsxs("aside",{className:[me.sidebar,N?me.minimized:"",d].filter(Boolean).join(" "),style:{height:N?void 0:i,...o},"data-juneau":"sidebar",children:[t.jsx(Pe,{title:e,icon:s,onMinimize:E,isMinimized:N,onReset:x,badge:w,headerActions:f}),!N&&t.jsx(Le,{messages:D,input:Z,isLoading:Q,isConnecting:H,error:Y,onInputChange:U,onSend:K,onStop:G,onProposalConfirm:h,onProposalCancel:b,assistantIcon:a??s,actions:r,sendIcon:n,renderPart:y,onEntityClick:c,emptyState:A})]})}const Gs="_list_180ms_1",Qs="_item_180ms_10",Ys="_chat_180ms_16",Xs="_chatActive_180ms_36",ea="_title_180ms_40",ta="_date_180ms_50",sa="_empty_180ms_82",P={list:Gs,item:Qs,chat:Ys,chatActive:Xs,title:ea,date:ta,delete:"_delete_180ms_56",empty:sa};function aa({chats:e,onSelect:s,activeChatId:a,onDelete:r}){const n=R();return e.length===0?t.jsx("p",{className:P.empty,children:n.historyEmpty}):t.jsx("ul",{className:P.list,"data-juneau":"history-list",children:e.map(i=>t.jsxs("li",{className:P.item,children:[t.jsxs("button",{className:i.id===a?`${P.chat} ${P.chatActive}`:P.chat,onClick:()=>s(i.id),children:[t.jsx("span",{className:P.title,children:i.title}),t.jsx("span",{className:P.date,children:i.updatedAt.toLocaleDateString(void 0,{day:"numeric",month:"short"})})]}),r&&t.jsx("button",{className:P.delete,onClick:()=>r(i.id),"aria-label":n.historyDeleteChat,children:t.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]},i.id))})}exports.AiActivityPart=Ce;exports.AiChat=Le;exports.AiChatContext=ne;exports.AiChatHeader=Pe;exports.AiChatHistoryList=aa;exports.AiChatProvider=lt;exports.AiEntityCard=le;exports.AiEntityListPart=ke;exports.AiError=Ie;exports.AiInput=Te;exports.AiMessageBubble=Se;exports.AiMessageList=Me;exports.AiMessagePartRenderer=Ne;exports.AiProposalCard=we;exports.AiSidebar=Ks;exports.AiTablePart=ve;exports.AiTypingIndicator=ze;exports.JuneauProvider=it;exports.consumeStream=re;exports.createFetchStreamAdapter=et;exports.createSseAdapter=Qe;exports.delay=g;exports.deserializeMessages=qe;exports.getMessageText=fe;exports.isChartPart=Re;exports.isProposalPart=ie;exports.juneauCs=dt;exports.juneauEn=ce;exports.mockAdapter=Oe;exports.parseJuneauWire=oe;exports.serializeForStorage=De;exports.serializeMessages=he;exports.trimChats=Ve;exports.trimHistory=ge;exports.useAiChat=xe;exports.useAiChatContext=be;exports.useAiChatContextSafe=ct;
|
|
22
|
+
`,25),await x(200),yield*v(`- Say **"show"**, **"list"**, **"data"**, or **"table"** → renders a data table
|
|
23
|
+
`,22),await x(150),yield*v(`- Say **"suggest"**, **"recommend"**, or **"proposal"** → renders a proposal card
|
|
24
|
+
`,22),await x(150),yield*v(`- Say **"entity"**, **"card"**, **"detail"**, or **"find"** → renders entity cards
|
|
25
|
+
`,22),await x(150),yield*v(`- Say **"help"** or **"what can you do"** → shows capabilities
|
|
26
|
+
`,22),await x(150),yield*v(`- Say **"error"** or **"fail"** → simulates an error response
|
|
27
|
+
`,22),yield{type:"done"}}async function*v(e,s){for(let r=0;r<e.length;r+=3)yield{type:"text",text:e.slice(r,r+3)},await x(s)}function oe(e){if(!e||e==="[DONE]")return[];let s;try{s=JSON.parse(e)}catch{return[]}switch(s.type){case"text":return s.text?[{type:"text",text:s.text}]:[];case"activity":return[{type:"part",part:{type:"activity",id:s.id,title:s.title,description:s.description,status:s.status,metadata:s.metadata}}];case"part":return[{type:"part",part:s.part}];case"done":return[{type:"done"}];case"error":return[{type:"error",message:s.message}];default:return[]}}function Ye(e,s={}){const{method:a="POST",headers:r={},getHeaders:n,getBody:i,getMessages:d,parseEvent:o=et,credentials:l}=s;return{async*sendMessage(p){const y=n?await n(p):{},c=d?await d(p.messages):p.messages,f={...p,messages:c},w=i?i(f):{messages:f.messages,context:f.context},h=await fetch(e,{method:a,credentials:l,headers:{"Content-Type":"application/json",...r,...y},body:JSON.stringify(w)});if(!h.ok){const M=await h.text().catch(()=>`HTTP ${h.status}`);yield{type:"error",message:`Request failed (${h.status}): ${M}`};return}if(!h.body){yield{type:"error",message:"Response body is empty — server may not support streaming."};return}yield*Xe(h.body,o)}}}async function*Xe(e,s){const a=e.getReader(),r=new TextDecoder;let n="";try{for(;;){const{done:i,value:d}=await a.read();if(i)break;n+=r.decode(d,{stream:!0});const o=n.split(`
|
|
28
|
+
`);n=o.pop()??"";for(const l of o){const p=l.trim();if(!(!p||p.startsWith(":"))&&p.startsWith("data: ")){const y=p.slice(6);if(y==="[DONE]"){yield{type:"done"};return}const c=s(y);for(const f of c)if(yield f,f.type==="done"||f.type==="error")return}}}}finally{a.releaseLock()}yield{type:"done"}}const et=e=>{if(!e||e==="[DONE]")return[];const s=oe(e);if(s.length>0)return s;try{const a=JSON.parse(e);if(a.error?.message)return[{type:"error",message:a.error.message}];const r=a.choices?.[0]?.delta;return a.choices?.[0]?.finish_reason==="stop"?[{type:"done"}]:r?.content?[{type:"text",text:r.content}]:[]}catch{return[]}};function tt(e,s={}){const{method:a="POST",headers:r={},getHeaders:n,getBody:i,parseChunk:d=at,credentials:o}=s;return{async*sendMessage(l){const p=n?await n(l):{},y=i?i(l):{messages:l.messages,context:l.context},c=await fetch(e,{method:a,credentials:o,headers:{"Content-Type":"application/json",...r,...p},body:JSON.stringify(y)});if(!c.ok){const f=await c.text().catch(()=>`HTTP ${c.status}`);yield{type:"error",message:`Request failed (${c.status}): ${f}`};return}if(!c.body){yield{type:"error",message:"Response body is empty — server may not support streaming."};return}yield*st(c.body,d)}}}async function*st(e,s){const a=e.getReader(),r=new TextDecoder;let n="";try{for(;;){const{done:i,value:d}=await a.read();if(i)break;n+=r.decode(d,{stream:!0});const o=n.split(`
|
|
29
|
+
`);n=o.pop()??"";for(const l of o){const p=l.trim();if(!p)continue;const y=s(p);for(const c of y)if(yield c,c.type==="done"||c.type==="error")return}}if(n.trim()){const i=s(n.trim());for(const d of i)if(yield d,d.type==="done"||d.type==="error")return}}finally{a.releaseLock()}yield{type:"done"}}const at=e=>{const s=oe(e);return s.length>0?s:e?[{type:"text",text:e}]:[]};let nt=0;const ee=()=>`msg-${++nt}-${Date.now()}`,pe=fe;function be({adapter:e,context:s,onProposalConfirm:a,onProposalCancel:r,initialMessages:n,historyLimit:i,onMessagesChange:d}){const[o,l]=u.useState(n??[]),[p,y]=u.useState(""),[c,f]=u.useState(!1),[w,h]=u.useState(!1),[M,N]=u.useState(null),A=u.useRef(null),T=u.useRef(!1),D=u.useRef(d);u.useEffect(()=>{D.current=d}),u.useEffect(()=>{!T.current||c||(T.current=!1,D.current?.(o))},[o,c]);const S=u.useCallback(m=>{l(_=>{const b=_[_.length-1];if(!b||b.role!=="assistant")return _;if(m.type==="activity"&&m.id){const j=[...b.parts],g=j.findIndex(C=>C.type==="activity"&&C.id===m.id);if(g!==-1)return j[g]=m,[..._.slice(0,-1),{...b,parts:j}]}return[..._.slice(0,-1),{...b,parts:[...b.parts,m]}]})},[]),I=u.useCallback(m=>{l(_=>{const b=_[_.length-1];if(!b||b.role!=="assistant")return _;const j=[...b.parts],g=j[j.length-1];return g?.type==="text"?j[j.length-1]={type:"text",text:g.text+m}:j.push({type:"text",text:m}),[..._.slice(0,-1),{...b,parts:j}]})},[]),H=u.useCallback(async(m,_)=>{N(null);const b={id:ee(),role:"user",parts:[{type:"text",text:m}],createdAt:new Date},j=ee();let g=!1;const C=()=>{if(g)return;g=!0;const $={id:j,role:"assistant",parts:[],createdAt:new Date};l(V=>[...V,$])};l($=>[...$,b]),f(!0),h(!0),A.current?.abort();const de=new AbortController;A.current=de;try{const $=xe([..._,b],i??Number.POSITIVE_INFINITY),V=e.sendMessage({messages:pe($),context:s});await re(V,O=>{switch(h(!1),O.type){case"text":C(),I(O.text);break;case"part":C(),S(O.part);break;case"error":C(),S({type:"error",message:O.message}),N(O.message);break;case"done":break}},de.signal)}catch($){const V=$ instanceof Error?$.message:"Unknown error occurred";N(V),C(),S({type:"error",message:V})}finally{T.current=!0,f(!1),h(!1)}},[e,s,i,I,S]),Z=u.useCallback(async()=>{const m=p.trim();!m||c||(y(""),await H(m,o))},[p,c,o,H]),U=u.useCallback(async m=>{!m.trim()||c||await H(m,o)},[c,o,H]),K=u.useCallback(async m=>{if(c)return;N(null),f(!0),h(!0);const _={id:ee(),role:"assistant",parts:[],createdAt:new Date};l(g=>[...g,_]),A.current?.abort();const b=new AbortController;A.current=b;const j={id:ee(),role:"system",parts:[{type:"text",text:m}],createdAt:new Date};try{const g=e.sendMessage({messages:pe([j]),context:s});await re(g,C=>{switch(h(!1),C.type){case"text":I(C.text);break;case"part":S(C.part);break;case"error":S({type:"error",message:C.message}),N(C.message);break;case"done":break}},b.signal)}catch(g){const C=g instanceof Error?g.message:"Unknown error occurred";N(C),S({type:"error",message:C})}finally{T.current=!0,f(!1),h(!1)}},[c,e,s,I,S]),G=u.useCallback(()=>{A.current?.abort(),f(!1),h(!1)},[]),Q=u.useCallback(m=>{A.current?.abort(),T.current=!0,l(m??[]),y(""),N(null),f(!1),h(!1)},[]),q=u.useCallback((m,_)=>{T.current=!0,l(b=>b.map(j=>({...j,parts:j.parts.map(g=>ie(g)&&g.proposal.id===m?{...g,proposal:{...g.proposal,resolved:_}}:g)})))},[]),Y=u.useCallback((m,_)=>{q(m,"confirmed"),a?.(m,_)},[a,q]),X=u.useCallback(m=>{q(m,"cancelled"),r?.(m)},[r,q]);return u.useMemo(()=>({messages:o,input:p,setInput:y,sendMessage:Z,sendMessageWithText:U,sendGreeting:K,stop:G,isLoading:c,isConnecting:w,error:M,reset:Q,confirmProposal:Y,cancelProposal:X}),[o,p,Z,U,K,G,c,w,M,Q,Y,X])}const ce={sidebarTitle:"AI Assistant",clearConversation:"Clear conversation",resetConversation:"Reset conversation",minimizeSidebar:"Minimize",expandSidebar:"Expand",userLabel:"You",inputPlaceholder:"Ask a question… (Enter to send)",sendMessage:"Send message",stopMessage:"Stop",typingMessage:"Assistant is typing",connectingMessage:"Connecting…",emptyStateText:"How can I help you today?",emptyStateHint:'Try: "Show me the data" or "Can you suggest something?"',proposalConfirm:"Confirm",proposalCancel:"Cancel",proposalConfirmed:"Confirmed",proposalCancelled:"Cancelled",proposalExpired:"No longer available",errorDismiss:"Dismiss",actionAddFile:"Add file",actionQuickActions:"Quick actions",actionNew:"New",actionHistory:"History",actionRules:"Rules",historyEmpty:"No previous chats",historyDeleteChat:"Delete chat"},_e=u.createContext(ce);function E(){return u.useContext(_e)}const rt="_root_1etc2_1",it={root:rt};function ot({children:e,theme:s,labels:a,defaultTitle:r,className:n,style:i}){const d={...ce,...r?{sidebarTitle:r}:{},...a},o=s?ct(s):void 0;return t.jsx(_e.Provider,{value:d,children:t.jsx("div",{className:[it.root,n].filter(Boolean).join(" "),style:{...o,...i},children:e})})}function ct(e){const s={"--juneau-color-primary":e.colorPrimary,"--juneau-color-primary-dark":e.colorPrimaryDark,"--juneau-color-primary-light":e.colorPrimaryLight,"--juneau-color-primary-border":e.colorPrimaryBorder,"--juneau-color-accent":e.colorAccent,"--juneau-color-accent-dark":e.colorAccentDark,"--juneau-color-accent-light":e.colorAccentLight,"--juneau-color-accent-border":e.colorAccentBorder,"--juneau-color-surface":e.colorSurface,"--juneau-color-surface-raised":e.colorSurfaceRaised,"--juneau-color-surface-hover":e.colorSurfaceHover,"--juneau-color-border":e.colorBorder,"--juneau-color-border-subtle":e.colorBorderSubtle,"--juneau-color-text-primary":e.colorTextPrimary,"--juneau-color-text-secondary":e.colorTextSecondary,"--juneau-color-text-muted":e.colorTextMuted,"--juneau-color-text-faint":e.colorTextFaint,"--juneau-color-text-inverse":e.colorTextInverse,"--juneau-color-assistant-avatar":e.colorAssistantAvatar,"--juneau-color-error-bg":e.colorErrorBg,"--juneau-color-error-border":e.colorErrorBorder,"--juneau-color-error-text":e.colorErrorText,"--juneau-color-success-bg":e.colorSuccessBg,"--juneau-color-success-text":e.colorSuccessText,"--juneau-color-warning-bg":e.colorWarningBg,"--juneau-color-warning-text":e.colorWarningText,"--juneau-color-danger-bg":e.colorDangerBg,"--juneau-color-danger-text":e.colorDangerText,"--juneau-radius-sm":e.radiusSm,"--juneau-radius-md":e.radiusMd,"--juneau-radius-lg":e.radiusLg,"--juneau-radius-full":e.radiusFull,"--juneau-font-size-xs":e.fontSizeXs,"--juneau-font-size-sm":e.fontSizeSm,"--juneau-font-size-base":e.fontSizeBase,"--juneau-font-size-md":e.fontSizeMd,"--juneau-font-size-lg":e.fontSizeLg,"--juneau-font-size-xl":e.fontSizeXl,"--juneau-font-size-2xl":e.fontSize2xl,"--juneau-font-size-3xl":e.fontSize3xl,"--juneau-font-family":e.fontFamily,"--juneau-transition-fast":e.transitionFast};return Object.fromEntries(Object.entries(s).filter(([,a])=>a!==void 0))}const ne=u.createContext(null);function je(){const e=u.useContext(ne);if(!e)throw new Error("useAiChatContext must be used inside <AiChatProvider>. Wrap your app (or layout) with <AiChatProvider adapter={...}>.");return e}function lt(){return u.useContext(ne)}function dt({adapter:e,context:s,onProposalConfirm:a,onProposalCancel:r,initialMessages:n,historyLimit:i,onMessagesChange:d,children:o}){const[l,p]=u.useState(s),y=u.useCallback(w=>{p(typeof w=="function"?h=>w(h):w)},[]),c=be({adapter:e,context:l,onProposalConfirm:a,onProposalCancel:r,initialMessages:n,historyLimit:i,onMessagesChange:d}),f=u.useMemo(()=>({...c,setContext:y}),[c,y]);return t.jsx(ne.Provider,{value:f,children:o})}const ut={sidebarTitle:"AI Asistent",clearConversation:"Vymazat konverzaci",resetConversation:"Resetovat konverzaci",minimizeSidebar:"Minimalizovat",expandSidebar:"Rozbalit",userLabel:"Vy",inputPlaceholder:"Zeptejte se na cokoliv… (Enter pro odeslání)",sendMessage:"Odeslat zprávu",stopMessage:"Zastavit",typingMessage:"Asistent píše",connectingMessage:"Připojování…",emptyStateText:"Jak vám mohu dnes pomoci?",emptyStateHint:'Zkuste: „Ukáž mi data" nebo „Máš nějaký návrh?"',proposalConfirm:"Potvrdit",proposalCancel:"Zrušit",proposalConfirmed:"Potvrzeno",proposalCancelled:"Zrušeno",proposalExpired:"Již není k dispozici",errorDismiss:"Zavřít",actionAddFile:"Přidat soubor",actionQuickActions:"Rychlé akce",actionNew:"Nový",actionHistory:"Historie",actionRules:"Pravidla",historyEmpty:"Žádné předchozí konverzace",historyDeleteChat:"Smazat konverzaci"};function ve({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M456 0c-48.6 0-88 39.4-88 88l0 29.2L12.5 390.6c-14 10.8-16.6 30.9-5.9 44.9s30.9 16.6 44.9 5.9L126.1 384l133.1 0 46.6 113.1c5 12.3 19.1 18.1 31.3 13.1s18.1-19.1 13.1-31.3L311.1 384l40.9 0c1.1 0 2.1 0 3.2 0l46.6 113.2c5 12.3 19.1 18.1 31.3 13.1s18.1-19.1 13.1-31.3l-42-102C484.9 354.1 544 280 544 192l0-64 0-8 80.5-20.1c8.6-2.1 13.8-10.8 11.6-19.4C629 52 603.4 32 574 32l-50.1 0C507.7 12.5 483.3 0 456 0zm0 64a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"})})}function pt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s6.2-22.8 16.4-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})})}function yt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M364.2 83.8c-24.4-24.4-64-24.4-88.4 0l-184 184c-42.1 42.1-42.1 110.3 0 152.4s110.3 42.1 152.4 0l152-152c10.9-10.9 28.7-10.9 39.6 0s10.9 28.7 0 39.6l-152 152c-64 64-167.6 64-231.6 0s-64-167.6 0-231.6l184-184c46.3-46.3 121.3-46.3 167.6 0s46.3 121.3 0 167.6l-176 176c-28.6 28.6-75 28.6-103.6 0s-28.6-75 0-103.6l144-144c10.9-10.9 28.7-10.9 39.6 0s10.9 28.7 0 39.6l-144 144c-6.7 6.7-6.7 17.7 0 24.4s17.7 6.7 24.4 0l176-176c24.4-24.4 24.4-64 0-88.4z"})})}function ht({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M349.4 44.6c5.9-13.7 1.5-29.7-10.6-38.5s-28.6-8-39.9 1.8l-256 224c-10 8.8-13.6 22.9-8.9 35.3S50.7 288 64 288l111.5 0L98.6 467.4c-5.9 13.7-1.5 29.7 10.6 38.5s28.6 8 39.9-1.8l256-224c10-8.8 13.6-22.9 8.9-35.3s-16.6-20.7-30-20.7l-111.5 0L349.4 44.6z"})})}function mt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 448 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z"})})}function ft({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M75 75L41 41C25.9 25.9 0 36.6 0 57.9L0 168c0 13.3 10.7 24 24 24l110.1 0c21.4 0 32.1-25.9 17-41l-31.8-31.8C143.9 83.5 196.2 64 252.6 64C370.8 64 464 157.8 464 276c0 77.5-40.8 145.4-102 182.9c-15.1 9.2-19.9 29-10.7 44.1s29 19.9 44.1 10.7C471 467.5 528 378.4 528 276C528 124.1 404.5 0 252.6 0C186 0 125.3 26.4 80 70.2L75 75zM256 152c-13.3 0-24 10.7-24 24l0 104c0 6.4 2.5 12.5 7 17l72 72c9.4 9.4 24.6 9.4 33.9 0s9.4-24.6 0-33.9l-65-65 0-94.1c0-13.3-10.7-24-24-24z"})})}function gt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 576 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M0 80C0 53.5 21.5 32 48 32l96 0c26.5 0 48 21.5 48 48l0 16 192 0 0-16c0-26.5 21.5-48 48-48l96 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-26.6 0c-25.8 50.9-72.7 88.5-129.4 99.8L384 416l32 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32l32 0 0-72.2C135.3 332.5 88.4 294.9 62.6 244L48 244c-26.5 0-48-21.5-48-48L0 80zM128 240c0 70.7 57.3 128 128 128s128-57.3 128-128l0-128L128 112l0 128zM512 176l0-64-64 0 0 64-48 0 0 16c0 8.8-.7 17.4-2 25.8c3.3 .1 6.6 .2 9.9 .2l56 0c26.5 0 48-21.5 48-48l0-64zM48 176c0 26.5 21.5 48 48 48l56 0c3.4 0 6.7-.1 9.9-.2c-1.3-8.4-2-17-2-25.8l0-16-48 0 0-64-64 0 0 58z"})})}function xt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M32 416c-17.7 0-32 14.3-32 32s14.3 32 32 32l448 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L32 416z"})})}function bt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M432 64L208 64c-8.8 0-16 7.2-16 16l0 16-64 0 0-16c0-44.2 35.8-80 80-80L432 0c44.2 0 80 35.8 80 80l0 224c0 44.2-35.8 80-80 80l-16 0 0-64 16 0c8.8 0 16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zM0 192c0-35.3 28.7-64 64-64l256 0c35.3 0 64 28.7 64 64l0 256c0 35.3-28.7 64-64 64L64 512c-35.3 0-64-28.7-64-64L0 192zm64 32c0 17.7 14.3 32 32 32l192 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L96 192c-17.7 0-32 14.3-32 32z"})})}function _t({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{d:"M125.7 160H176c17.7 0 32 14.3 32 32s-14.3 32-32 32H48c-17.7 0-32-14.3-32-32V64c0-17.7 14.3-32 32-32s32 14.3 32 32v51.2L97.6 97.6c87.5-87.5 229.3-87.5 316.8 0s87.5 229.3 0 316.8s-229.3 87.5-316.8 0c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0c62.5 62.5 163.8 62.5 226.3 0s62.5-163.8 0-226.3s-163.8-62.5-226.3 0L125.7 160z"})})}function jt({className:e,style:s,"aria-hidden":a=!0}){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",width:"1em",height:"1em",fill:"currentColor",className:e,style:s,"aria-hidden":a,children:t.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})})}const vt="_wrapper_izvjy_1",wt="_table_izvjy_15",Ct="_th_izvjy_27",kt="_tr_izvjy_47",Nt="_td_izvjy_63",F={wrapper:vt,table:wt,th:Ct,tr:kt,td:Nt};function we({part:e}){return t.jsx("div",{className:F.wrapper,"data-juneau":"table-part",children:t.jsxs("table",{className:F.table,children:[t.jsx("thead",{children:t.jsx("tr",{children:e.columns.map(s=>t.jsx("th",{className:F.th,children:s},s))})}),t.jsx("tbody",{children:e.rows.map((s,a)=>t.jsx("tr",{className:F.tr,children:e.columns.map(r=>t.jsx("td",{className:F.td,children:String(s[r]??"")},r))},a))})]})})}const At="_card_99bqr_1",St="_header_99bqr_17",zt="_icon_99bqr_31",Mt="_title_99bqr_47",Tt="_description_99bqr_59",It="_cardResolved_99bqr_73",Lt="_resolvedBadge_99bqr_81",Pt="_actions_99bqr_103",Bt="_confirm_99bqr_113",$t="_cancel_99bqr_145",z={card:At,header:St,icon:zt,title:Mt,description:Tt,cardResolved:It,resolvedBadge:Lt,actions:Pt,confirm:Bt,cancel:$t};function Ce({part:e,onConfirm:s,onCancel:a}){const r=E(),{proposal:n}=e,i=n.resolved==="confirmed"?r.proposalConfirmed:n.resolved==="cancelled"?r.proposalCancelled:n.resolved==="expired"?r.proposalExpired:null;return t.jsxs("div",{className:n.resolved?`${z.card} ${z.cardResolved}`:z.card,"data-juneau":"proposal-card",children:[t.jsxs("div",{className:z.header,children:[t.jsx("svg",{className:z.icon,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M10 1a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5A.75.75 0 0110 1zM5.05 3.05a.75.75 0 011.06 1.06l-1.06 1.06a.75.75 0 11-1.06-1.06l1.06-1.06zm9.9 0a.75.75 0 010 1.06l-1.06 1.06a.75.75 0 11-1.06-1.06l1.06-1.06a.75.75 0 011.06 0zM10 6a4 4 0 100 8 4 4 0 000-8zm-9 4a.75.75 0 01.75-.75h1.5a.75.75 0 010 1.5h-1.5A.75.75 0 011 10zm15.75-.75a.75.75 0 000 1.5h1.5a.75.75 0 000-1.5h-1.5zM4.11 14.89a.75.75 0 010 1.06l-1.06 1.06a.75.75 0 11-1.06-1.06l1.06-1.06a.75.75 0 011.06 0zm11.84 1.06a.75.75 0 10-1.06-1.06l-1.06 1.06a.75.75 0 101.06 1.06l1.06-1.06zM10 17.25a.75.75 0 01.75.75v1.5a.75.75 0 01-1.5 0v-1.5a.75.75 0 01.75-.75z"})}),t.jsx("span",{className:z.title,children:n.title})]}),n.description&&t.jsx("p",{className:z.description,children:n.description}),i?t.jsx("span",{className:z.resolvedBadge,children:i}):t.jsxs("div",{className:z.actions,children:[t.jsx("button",{className:z.confirm,onClick:()=>s(n.id,n.payload),children:n.confirmLabel??r.proposalConfirm}),t.jsx("button",{className:z.cancel,onClick:()=>a(n.id),children:n.cancelLabel??r.proposalCancel})]})]})}const Rt="_activity_1661l_1",Et="_indicator_1661l_25",Dt="_content_1661l_71",Ht="_title_1661l_79",qt="_description_1661l_89",W={activity:Rt,indicator:Et,content:Dt,title:Ht,description:qt};function ke({part:e}){return t.jsxs("div",{className:W.activity,"data-status":e.status,"data-juneau":"activity-part",children:[t.jsx("span",{className:W.indicator,"aria-hidden":"true"}),t.jsxs("div",{className:W.content,children:[t.jsx("div",{className:W.title,children:e.title}),e.description&&t.jsx("div",{className:W.description,children:e.description})]})]})}const Vt="_card_jwkcu_1",Ot="_cardClickable_jwkcu_14",Ft="_header_jwkcu_24",Wt="_title_jwkcu_30",Jt="_subtitle_jwkcu_36",Zt="_fields_jwkcu_41",Ut="_fieldRow_jwkcu_48",Kt="_fieldLabel_jwkcu_55",Gt="_fieldValue_jwkcu_61",Qt="_badge_jwkcu_68",Yt="_badgeSuccess_jwkcu_76",Xt="_badgeWarning_jwkcu_81",es="_badgeDanger_jwkcu_86",ts="_badgeNeutral_jwkcu_91",k={card:Vt,cardClickable:Ot,header:Ft,title:Wt,subtitle:Jt,fields:Zt,fieldRow:Ut,fieldLabel:Kt,fieldValue:Gt,badge:Qt,badgeSuccess:Yt,badgeWarning:Xt,badgeDanger:es,badgeNeutral:ts},ss={success:k.badgeSuccess,warning:k.badgeWarning,danger:k.badgeDanger,neutral:k.badgeNeutral};function le({part:e,onEntityClick:s}){const{entity:a,entityType:r}=e,n=s!==void 0,i=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:k.header,children:[t.jsx("span",{className:k.title,children:a.title}),a.subtitle&&t.jsx("span",{className:k.subtitle,children:a.subtitle})]}),a.fields&&a.fields.length>0&&t.jsx("dl",{className:k.fields,children:a.fields.map((d,o)=>t.jsxs("div",{className:k.fieldRow,children:[t.jsx("dt",{className:k.fieldLabel,children:d.label}),t.jsx("dd",{className:k.fieldValue,children:d.badge?t.jsx("span",{className:`${k.badge} ${ss[d.badge]}`,children:d.value}):d.value})]},o))})]});return n?t.jsx("button",{type:"button",className:`${k.card} ${k.cardClickable}`,onClick:()=>s(a,r),"data-juneau":"entity-card",children:i}):t.jsx("div",{className:k.card,"data-juneau":"entity-card",children:i})}const as="_list_a2maw_1",ns="_listTitle_a2maw_11",ye={list:as,listTitle:ns};function Ne({part:e,onEntityClick:s}){return t.jsxs("div",{className:ye.list,"data-juneau":"entity-list-part",children:[e.title&&t.jsx("span",{className:ye.listTitle,children:e.title}),e.entities.map((a,r)=>t.jsx(le,{part:{type:"entity",entity:a,entityType:e.entityType},onEntityClick:s},a.id??r))]})}const rs="_markdown_sznoh_1",is="_unknownPart_sznoh_167",os="_errorText_sznoh_195",cs="_errorIcon_sznoh_211",te={markdown:rs,unknownPart:is,errorText:os,errorIcon:cs};function Ae({part:e,onProposalConfirm:s,onProposalCancel:a,onEntityClick:r,renderPart:n}){if(n){const i=n(e);if(i!=null)return t.jsx(t.Fragment,{children:i})}switch(e.type){case"text":return t.jsx("div",{className:te.markdown,children:t.jsx($e,{remarkPlugins:[Re],children:e.text})});case"table":return t.jsx(we,{part:e});case"activity":return t.jsx(ke,{part:e});case"proposal":return t.jsx(Ce,{part:e,onConfirm:s,onCancel:a});case"entity":return t.jsx(le,{part:e,onEntityClick:r});case"entity-list":return t.jsx(Ne,{part:e,onEntityClick:r});case"error":return t.jsxs("span",{className:te.errorText,children:[t.jsx(jt,{className:te.errorIcon}),e.message]});default:return globalThis.process?.env?.NODE_ENV!=="production"?t.jsxs("div",{className:te.unknownPart,children:["Unhandled part type: ",t.jsx("code",{children:e.type})," — pass a"," ",t.jsx("code",{children:"renderPart"})," prop to render it."]}):null}}const ls="_wrapper_1q20p_1",ds="_user_1q20p_8",us="_assistant_1q20p_12",ps="_avatar_1q20p_16",ys="_content_1q20p_43",hs="_bubble_1q20p_51",ms="_card_1q20p_70",fs="_empty_1q20p_92",L={wrapper:ls,user:ds,assistant:us,avatar:ps,content:ys,bubble:hs,card:ms,empty:fs},gs=new Set(["text","error","activity"]);function Se(e){return!gs.has(e.type)}function xs(e){const s=[];return e.forEach((a,r)=>{const n=Se(a),i=s[s.length-1];if(i&&!n&&!i.card){i.parts.push({part:a,index:r});return}s.push({card:n,parts:[{part:a,index:r}]})}),s}function ze({message:e,onProposalConfirm:s,onProposalCancel:a,onEntityClick:r,assistantIcon:n,renderPart:i}){const d=E(),o=e.role==="user",l=(y,c)=>t.jsx(Ae,{part:y,onProposalConfirm:s,onProposalCancel:a,onEntityClick:r,renderPart:i},c),p=e.parts.some(Se);return t.jsxs("div",{className:`${L.wrapper} ${o?L.user:L.assistant}`,"data-juneau":"message","data-juneau-role":e.role,children:[!o&&t.jsx("div",{className:L.avatar,"aria-hidden":"true","data-juneau":"assistant-avatar",children:n??t.jsx(ve,{})}),p?t.jsx("div",{className:L.content,children:xs(e.parts).map((y,c)=>t.jsx("div",{className:y.card?L.card:L.bubble,"data-juneau-segment":y.card?"card":"bubble",children:y.parts.map(({part:f,index:w})=>l(f,w))},c))}):t.jsxs("div",{className:L.bubble,"data-juneau-segment":"bubble",children:[e.parts.map((y,c)=>l(y,c)),e.parts.length===0&&t.jsx("span",{className:L.empty})]}),o&&t.jsx("div",{className:L.avatar,children:d.userLabel})]})}const bs="_wrapper_1oco7_1",_s="_dot_1oco7_15",js="_connectingLabel_1oco7_37",J={wrapper:bs,dot:_s,connectingLabel:js};function Me({connecting:e=!1}){const s=E();return t.jsxs("div",{className:J.wrapper,"aria-label":e?s.connectingMessage:s.typingMessage,"data-juneau":"typing-indicator",children:[t.jsx("span",{className:J.dot}),t.jsx("span",{className:J.dot}),t.jsx("span",{className:J.dot}),e&&t.jsx("span",{className:J.connectingLabel,children:s.connectingMessage})]})}const vs="_list_ixto8_1",ws="_empty_ixto8_21",Cs="_hint_ixto8_47",ks="_typing_ixto8_61",se={list:vs,empty:ws,hint:Cs,typing:ks};function Te({messages:e,isLoading:s,isConnecting:a,onProposalConfirm:r,onProposalCancel:n,onEntityClick:i,assistantIcon:d,renderPart:o,emptyState:l}){const p=E(),y=u.useRef(null);return u.useEffect(()=>{y.current?.scrollIntoView({behavior:"smooth"})},[e,s]),t.jsxs("div",{className:se.list,"data-juneau":"message-list",children:[e.length===0&&(l??t.jsxs("div",{className:se.empty,"data-juneau":"empty-state",children:[t.jsx("p",{children:p.emptyStateText}),t.jsx("p",{className:se.hint,children:t.jsx("em",{children:p.emptyStateHint})})]})),e.map(c=>t.jsx(ze,{message:c,onProposalConfirm:r,onProposalCancel:n,onEntityClick:i,assistantIcon:d,renderPart:o},c.id)),s&&t.jsx("div",{className:se.typing,children:t.jsx(Me,{connecting:a})}),t.jsx("div",{ref:y})]})}const Ns="_wrapper_ehrkb_1",As="_textarea_ehrkb_21",Ss="_toolbar_ehrkb_69",zs="_actions_ehrkb_89",Ms="_actionBtn_ehrkb_103",Ts="_sendBtn_ehrkb_169",Is="_spinnerIcon_ehrkb_231",Ls="_stopBtn_ehrkb_251",Ps="_stopIcon_ehrkb_297",P={wrapper:Ns,textarea:As,toolbar:Ss,actions:zs,actionBtn:Ms,sendBtn:Ts,spinnerIcon:Is,stopBtn:Ls,stopIcon:Ps};function Ie({value:e,onChange:s,onSend:a,onStop:r,isLoading:n,placeholder:i,actions:d,sendIcon:o}){const l=E(),p=u.useRef(null),y=u.useRef(!1);u.useEffect(()=>{y.current&&!n&&p.current?.focus(),y.current=n},[n]);const c=[{icon:t.jsx(yt,{}),label:l.actionAddFile},{icon:t.jsx(ht,{}),label:l.actionQuickActions},{icon:t.jsx(mt,{}),label:l.actionNew},{icon:t.jsx(ft,{}),label:l.actionHistory},{icon:t.jsx(gt,{}),label:l.actionRules}],f=d??c,w=h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),n||a())};return t.jsxs("div",{className:P.wrapper,"data-juneau":"input",children:[t.jsx("textarea",{ref:p,className:P.textarea,"data-juneau":"input-textarea",value:e,onChange:h=>s(h.target.value),onKeyDown:w,placeholder:i??l.inputPlaceholder,rows:3,"aria-label":l.sendMessage}),t.jsxs("div",{className:P.toolbar,children:[f.length>0&&t.jsx("div",{className:P.actions,children:f.map((h,M)=>t.jsxs("button",{className:P.actionBtn,type:"button",disabled:n,"aria-label":h.label,onClick:h.onClick,children:[h.icon,t.jsx("span",{children:h.label})]},M))}),n&&r?t.jsxs("button",{className:P.stopBtn,onClick:r,"aria-label":l.stopMessage,type:"button",children:[t.jsx("svg",{className:P.stopIcon,viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"2"})}),t.jsx("span",{children:l.stopMessage})]}):t.jsxs("button",{className:P.sendBtn,onClick:a,disabled:n||!e.trim(),"aria-label":l.sendMessage,type:"button",children:[n?t.jsx("svg",{className:P.spinnerIcon,viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",children:t.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeDasharray:"32",strokeDashoffset:"12"})}):o??t.jsx(pt,{}),t.jsx("span",{children:l.sendMessage})]})]})]})}const Bs="_wrapper_1e3w5_1",$s="_icon_1e3w5_27",Rs="_message_1e3w5_39",Es="_dismiss_1e3w5_47",ae={wrapper:Bs,icon:$s,message:Rs,dismiss:Es};function Le({message:e,onDismiss:s}){const a=E();return t.jsxs("div",{className:ae.wrapper,role:"alert","data-juneau":"error",children:[t.jsx("svg",{className:ae.icon,viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{fillRule:"evenodd",d:"M8.485 2.495c.673-1.167 2.357-1.167 3.03 0l6.28 10.875c.673 1.167-.17 2.625-1.516 2.625H3.72c-1.347 0-2.189-1.458-1.515-2.625L8.485 2.495zM10 5a.75.75 0 01.75.75v3.5a.75.75 0 01-1.5 0v-3.5A.75.75 0 0110 5zm0 9a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})}),t.jsx("span",{className:ae.message,children:e}),s&&t.jsx("button",{className:ae.dismiss,onClick:s,"aria-label":a.errorDismiss,children:t.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]})}const Ds="_chat_nablk_1",Hs="_aboveInput_nablk_15",he={chat:Ds,aboveInput:Hs};function Pe({messages:e,input:s,isLoading:a,isConnecting:r,error:n,onInputChange:i,onSend:d,onStop:o,onProposalConfirm:l,onProposalCancel:p,onEntityClick:y,placeholder:c,assistantIcon:f,actions:w,sendIcon:h,renderPart:M,emptyState:N,aboveInput:A,className:T,style:D}){return t.jsxs("div",{className:[he.chat,T].filter(Boolean).join(" "),style:D,"data-juneau":"chat",children:[t.jsx(Te,{messages:e,isLoading:a,isConnecting:r,onProposalConfirm:l,onProposalCancel:p,onEntityClick:y,assistantIcon:f,renderPart:M,emptyState:N}),n&&t.jsx(Le,{message:n}),A!=null&&t.jsx("div",{className:he.aboveInput,"data-juneau":"above-input","data-juneau-above-input":"",children:A}),t.jsx(Ie,{value:s,onChange:i,onSend:d,onStop:o,isLoading:a,placeholder:c,actions:w,sendIcon:h})]})}const qs="_header_1br16_1",Vs="_left_1br16_23",Os="_icon_1br16_35",Fs="_title_1br16_45",Ws="_resetBtn_1br16_57",Js="_actions_1br16_99",Zs="_badge_1br16_113",R={header:qs,left:Vs,icon:Os,title:Fs,resetBtn:Ws,actions:Js,badge:Zs};function Be({title:e,onMinimize:s,isMinimized:a,icon:r,onReset:n,badge:i,headerActions:d}){const o=E();return t.jsxs("div",{className:R.header,"data-juneau":"header",children:[t.jsxs("div",{className:R.left,children:[t.jsx("span",{className:R.icon,"aria-hidden":"true","data-juneau":"header-icon",children:r??t.jsx(ve,{})}),t.jsx("span",{className:R.title,children:e??o.sidebarTitle}),i&&t.jsx("span",{className:R.badge,"data-juneau":"header-badge",children:i})]}),(s||n||d)&&t.jsxs("div",{className:R.actions,children:[d,n&&t.jsx("button",{className:R.resetBtn,onClick:n,title:o.resetConversation,"aria-label":o.resetConversation,"data-juneau":"header-reset",children:t.jsx(_t,{})}),s&&t.jsx("button",{className:R.resetBtn,onClick:s,title:a?o.expandSidebar:o.minimizeSidebar,"aria-label":a?o.expandSidebar:o.minimizeSidebar,"data-juneau":"header-minimize",children:a?t.jsx(bt,{}):t.jsx(xt,{})})]})]})}const Us="_sidebar_u9ybt_1",Ks="_minimized_u9ybt_39",me={sidebar:Us,minimized:Ks};function Gs({title:e,icon:s,assistantIcon:a,actions:r,sendIcon:n,height:i="60vh",className:d,style:o,onReset:l,confirmReset:p,renderPart:y,onEntityClick:c,headerActions:f,badge:w,minimized:h,onMinimizedChange:M,emptyState:N,aboveInput:A}){const[T,D]=u.useState(!1),S=h!==void 0,I=S?h:T,H=()=>{const g=!I;S||D(g),M?.(g)},{messages:Z,input:U,setInput:K,sendMessage:G,stop:Q,isLoading:q,isConnecting:Y,error:X,reset:m,confirmProposal:_,cancelProposal:b}=je(),j=l?async()=>{p&&!await p()||(m(),l())}:void 0;return t.jsxs("aside",{className:[me.sidebar,I?me.minimized:"",d].filter(Boolean).join(" "),style:{height:I?void 0:i,...o},"data-juneau":"sidebar",children:[t.jsx(Be,{title:e,icon:s,onMinimize:H,isMinimized:I,onReset:j,badge:w,headerActions:f}),!I&&t.jsx(Pe,{messages:Z,input:U,isLoading:q,isConnecting:Y,error:X,onInputChange:K,onSend:G,onStop:Q,onProposalConfirm:_,onProposalCancel:b,assistantIcon:a??s,actions:r,sendIcon:n,renderPart:y,onEntityClick:c,emptyState:N,aboveInput:A})]})}const Qs="_list_j7fvh_1",Ys="_item_j7fvh_19",Xs="_chat_j7fvh_31",ea="_chatActive_j7fvh_71",ta="_title_j7fvh_79",sa="_date_j7fvh_99",aa="_empty_j7fvh_163",B={list:Qs,item:Ys,chat:Xs,chatActive:ea,title:ta,date:sa,delete:"_delete_j7fvh_111",empty:aa};function na({chats:e,onSelect:s,activeChatId:a,onDelete:r}){const n=E();return e.length===0?t.jsx("p",{className:B.empty,children:n.historyEmpty}):t.jsx("ul",{className:B.list,"data-juneau":"history-list",children:e.map(i=>t.jsxs("li",{className:B.item,children:[t.jsxs("button",{className:i.id===a?`${B.chat} ${B.chatActive}`:B.chat,onClick:()=>s(i.id),children:[t.jsx("span",{className:B.title,children:i.title}),t.jsx("span",{className:B.date,children:i.updatedAt.toLocaleDateString(void 0,{day:"numeric",month:"short"})})]}),r&&t.jsx("button",{className:B.delete,onClick:()=>r(i.id),"aria-label":n.historyDeleteChat,children:t.jsx("svg",{viewBox:"0 0 16 16",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M3.72 3.72a.75.75 0 011.06 0L8 6.94l3.22-3.22a.75.75 0 111.06 1.06L9.06 8l3.22 3.22a.75.75 0 11-1.06 1.06L8 9.06l-3.22 3.22a.75.75 0 01-1.06-1.06L6.94 8 3.72 4.78a.75.75 0 010-1.06z"})})})]},i.id))})}exports.AiActivityPart=ke;exports.AiChat=Pe;exports.AiChatContext=ne;exports.AiChatHeader=Be;exports.AiChatHistoryList=na;exports.AiChatProvider=dt;exports.AiEntityCard=le;exports.AiEntityListPart=Ne;exports.AiError=Le;exports.AiInput=Ie;exports.AiMessageBubble=ze;exports.AiMessageList=Te;exports.AiMessagePartRenderer=Ae;exports.AiProposalCard=Ce;exports.AiSidebar=Gs;exports.AiTablePart=we;exports.AiTypingIndicator=Me;exports.JuneauProvider=ot;exports.consumeStream=re;exports.createFetchStreamAdapter=tt;exports.createSseAdapter=Ye;exports.delay=x;exports.deserializeMessages=Ve;exports.getMessageText=ge;exports.isChartPart=Ee;exports.isProposalPart=ie;exports.juneauCs=ut;exports.juneauEn=ce;exports.mockAdapter=Fe;exports.parseJuneauWire=oe;exports.serializeForStorage=He;exports.serializeMessages=fe;exports.trimChats=Oe;exports.trimHistory=xe;exports.useAiChat=be;exports.useAiChatContext=je;exports.useAiChatContextSafe=lt;
|
|
30
30
|
//# sourceMappingURL=index.cjs.map
|