@dabalabs/agent 0.0.2-beta → 0.0.4-beta
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 +56 -3
- package/dist/chunk-3BQ6LE6X.cjs +222 -0
- package/dist/chunk-3BQ6LE6X.cjs.map +1 -0
- package/dist/{chunk-CMHPVBEF.js → chunk-ETI4LRM7.js} +841 -100
- package/dist/chunk-ETI4LRM7.js.map +1 -0
- package/dist/chunk-TYOHYQDK.js +220 -0
- package/dist/chunk-TYOHYQDK.js.map +1 -0
- package/dist/{chunk-IMPMGYCG.cjs → chunk-VAIC5ACS.cjs} +841 -99
- package/dist/chunk-VAIC5ACS.cjs.map +1 -0
- package/dist/custom-element.cjs +4 -4
- package/dist/custom-element.d.cts +191 -2
- package/dist/custom-element.d.ts +191 -2
- package/dist/custom-element.js +2 -2
- package/dist/daba-agent.cjs +5 -14
- package/dist/daba-agent.d.cts +2 -4
- package/dist/daba-agent.d.ts +2 -4
- package/dist/daba-agent.js +2 -3
- package/dist/daba-agent.min.js +141 -36
- package/dist/daba-agent.min.js.map +1 -1
- package/dist/react.cjs +41 -14
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +38 -2
- package/dist/react.js.map +1 -1
- package/dist/{types-hdR_wQ1B.d.cts → types-BQRgqD4n.d.cts} +70 -4
- package/dist/{types-hdR_wQ1B.d.ts → types-BQRgqD4n.d.ts} +70 -4
- package/package.json +1 -1
- package/dist/chunk-7ENX2QZK.js +0 -193
- package/dist/chunk-7ENX2QZK.js.map +0 -1
- package/dist/chunk-CMHPVBEF.js.map +0 -1
- package/dist/chunk-GCU5OBSZ.js +0 -40
- package/dist/chunk-GCU5OBSZ.js.map +0 -1
- package/dist/chunk-HJPH4GNS.cjs +0 -196
- package/dist/chunk-HJPH4GNS.cjs.map +0 -1
- package/dist/chunk-IMPMGYCG.cjs.map +0 -1
- package/dist/chunk-JQMJMSFT.cjs +0 -46
- package/dist/chunk-JQMJMSFT.cjs.map +0 -1
- package/dist/custom-element-BZAUI4Dc.d.cts +0 -121
- package/dist/custom-element-PL2IXpG2.d.ts +0 -121
package/dist/react.cjs
CHANGED
|
@@ -1,21 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('
|
|
3
|
+
var chunkVAIC5ACS_cjs = require('./chunk-VAIC5ACS.cjs');
|
|
4
|
+
var React = require('react');
|
|
5
5
|
|
|
6
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
6
7
|
|
|
8
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
7
9
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
function DabaAgentComponent(props) {
|
|
11
|
+
const containerRef = React.useRef(null);
|
|
12
|
+
const agentRef = React.useRef(null);
|
|
13
|
+
const propsRef = React.useRef(props);
|
|
14
|
+
propsRef.current = props;
|
|
15
|
+
const configKey = JSON.stringify(
|
|
16
|
+
props,
|
|
17
|
+
(_key, value) => typeof value === "function" ? void 0 : value
|
|
18
|
+
);
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
if (!containerRef.current) return;
|
|
21
|
+
const agent = new chunkVAIC5ACS_cjs.DabaAgent({
|
|
22
|
+
...propsRef.current,
|
|
23
|
+
// After the spread: this component owns where the widget mounts.
|
|
24
|
+
container: containerRef.current,
|
|
25
|
+
onStatusChange: (status) => propsRef.current.onStatusChange?.(status),
|
|
26
|
+
onTranscript: (role, text, isFinal) => propsRef.current.onTranscript?.(role, text, isFinal),
|
|
27
|
+
onChatToggle: (isOpen) => propsRef.current.onChatToggle?.(isOpen),
|
|
28
|
+
onCards: (cards) => propsRef.current.onCards?.(cards),
|
|
29
|
+
onError: (error) => propsRef.current.onError?.(error)
|
|
30
|
+
});
|
|
31
|
+
agentRef.current = agent;
|
|
32
|
+
return () => {
|
|
33
|
+
agent.destroy();
|
|
34
|
+
agentRef.current = null;
|
|
35
|
+
};
|
|
36
|
+
}, [configKey]);
|
|
37
|
+
return React__default.default.createElement("div", {
|
|
38
|
+
ref: containerRef,
|
|
39
|
+
style: { display: "contents" },
|
|
40
|
+
"data-daba-agent-react-container": "true"
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
exports.DabaAgent = DabaAgentComponent;
|
|
45
|
+
exports.DabaAgentComponent = DabaAgentComponent;
|
|
46
|
+
exports.DabaAgentReact = DabaAgentComponent;
|
|
20
47
|
//# sourceMappingURL=react.cjs.map
|
|
21
48
|
//# sourceMappingURL=react.cjs.map
|
package/dist/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.cjs"}
|
|
1
|
+
{"version":3,"sources":["../src/components/react.ts"],"names":["useRef","useEffect","DabaAgent","React"],"mappings":";;;;;;;;;AAMO,SAAS,mBAAmB,KAAA,EAA2C;AAC5E,EAAA,MAAM,YAAA,GAAeA,aAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,QAAA,GAAWA,aAAyB,IAAI,CAAA;AAK9C,EAAA,MAAM,QAAA,GAAWA,aAAO,KAAK,CAAA;AAC7B,EAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAiBnB,EAAA,MAAM,YAAY,IAAA,CAAK,SAAA;AAAA,IAAU,KAAA;AAAA,IAAO,CAAC,IAAA,EAAM,KAAA,KAC7C,OAAO,KAAA,KAAU,aAAa,MAAA,GAAY;AAAA,GAC5C;AAEA,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AAE3B,IAAA,MAAM,KAAA,GAAQ,IAAIC,2BAAA,CAAU;AAAA,MAC1B,GAAG,QAAA,CAAS,OAAA;AAAA;AAAA,MAEZ,WAAW,YAAA,CAAa,OAAA;AAAA,MACxB,gBAAgB,CAAC,MAAA,KAAW,QAAA,CAAS,OAAA,CAAQ,iBAAiB,MAAM,CAAA;AAAA,MACpE,YAAA,EAAc,CAAC,IAAA,EAAM,IAAA,EAAM,OAAA,KACzB,SAAS,OAAA,CAAQ,YAAA,GAAe,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA;AAAA,MACrD,cAAc,CAAC,MAAA,KAAW,QAAA,CAAS,OAAA,CAAQ,eAAe,MAAM,CAAA;AAAA,MAChE,SAAS,CAAC,KAAA,KAAU,QAAA,CAAS,OAAA,CAAQ,UAAU,KAAK,CAAA;AAAA,MACpD,SAAS,CAAC,KAAA,KAAU,QAAA,CAAS,OAAA,CAAQ,UAAU,KAAK;AAAA,KACrD,CAAA;AACD,IAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAEnB,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,OAAA,EAAQ;AACd,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,OAAOC,sBAAA,CAAM,cAAc,KAAA,EAAO;AAAA,IAChC,GAAA,EAAK,YAAA;AAAA,IACL,KAAA,EAAO,EAAE,OAAA,EAAS,UAAA,EAAW;AAAA,IAC7B,iCAAA,EAAmC;AAAA,GACpC,CAAA;AACH","file":"react.cjs","sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { DabaAgent } from \"../agent\";\nimport type { DabaAgentOptions } from \"../types\";\n\nexport type DabaAgentProps = Omit<DabaAgentOptions, \"container\">;\n\nexport function DabaAgentComponent(props: DabaAgentProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null);\n const agentRef = useRef<DabaAgent | null>(null);\n\n // The agent reads its handlers back out of this ref at call time, which\n // is what keeps an inline `onCards={(c) => setCards(c)}` current without\n // its per-render identity forcing a rebuild below.\n const propsRef = useRef(props);\n propsRef.current = props;\n\n /**\n * The effect keys on the configuration's VALUE, not on the prop objects.\n *\n * `theme={{ accentColor: \"#0c8c5e\" }}` is a fresh object on every render\n * of the parent, so listing it as a dependency would destroy and rebuild\n * the widget — closing the panel, dropping the conversation, restarting\n * a voice session — every time an unrelated piece of the host page's\n * state changed. Serialising compares the way the integrator meant it.\n *\n * Functions are stripped rather than compared: callbacks are re-created\n * on every render too, and they reach the live agent through `propsRef`\n * instead. Serialising also means a newly added option is covered here\n * the moment it exists, which the hand-listed dependency array this\n * replaces was already out of step with (`env` never made it in).\n */\n const configKey = JSON.stringify(props, (_key, value) =>\n typeof value === \"function\" ? undefined : value,\n );\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const agent = new DabaAgent({\n ...propsRef.current,\n // After the spread: this component owns where the widget mounts.\n container: containerRef.current,\n onStatusChange: (status) => propsRef.current.onStatusChange?.(status),\n onTranscript: (role, text, isFinal) =>\n propsRef.current.onTranscript?.(role, text, isFinal),\n onChatToggle: (isOpen) => propsRef.current.onChatToggle?.(isOpen),\n onCards: (cards) => propsRef.current.onCards?.(cards),\n onError: (error) => propsRef.current.onError?.(error),\n });\n agentRef.current = agent;\n\n return () => {\n agent.destroy();\n agentRef.current = null;\n };\n }, [configKey]);\n\n return React.createElement(\"div\", {\n ref: containerRef,\n style: { display: \"contents\" },\n \"data-daba-agent-react-container\": \"true\",\n });\n}\n\nexport { DabaAgentComponent as DabaAgentReact, DabaAgentComponent as DabaAgent };\n"]}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { D as DabaAgentOptions } from './types-BQRgqD4n.cjs';
|
|
3
3
|
|
|
4
4
|
type DabaAgentProps = Omit<DabaAgentOptions, "container">;
|
|
5
5
|
declare function DabaAgentComponent(props: DabaAgentProps): React.ReactElement;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { D as DabaAgentOptions } from './types-BQRgqD4n.js';
|
|
3
3
|
|
|
4
4
|
type DabaAgentProps = Omit<DabaAgentOptions, "container">;
|
|
5
5
|
declare function DabaAgentComponent(props: DabaAgentProps): React.ReactElement;
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
import '
|
|
1
|
+
import { DabaAgent } from './chunk-ETI4LRM7.js';
|
|
2
|
+
import React, { useRef, useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
function DabaAgentComponent(props) {
|
|
5
|
+
const containerRef = useRef(null);
|
|
6
|
+
const agentRef = useRef(null);
|
|
7
|
+
const propsRef = useRef(props);
|
|
8
|
+
propsRef.current = props;
|
|
9
|
+
const configKey = JSON.stringify(
|
|
10
|
+
props,
|
|
11
|
+
(_key, value) => typeof value === "function" ? void 0 : value
|
|
12
|
+
);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!containerRef.current) return;
|
|
15
|
+
const agent = new DabaAgent({
|
|
16
|
+
...propsRef.current,
|
|
17
|
+
// After the spread: this component owns where the widget mounts.
|
|
18
|
+
container: containerRef.current,
|
|
19
|
+
onStatusChange: (status) => propsRef.current.onStatusChange?.(status),
|
|
20
|
+
onTranscript: (role, text, isFinal) => propsRef.current.onTranscript?.(role, text, isFinal),
|
|
21
|
+
onChatToggle: (isOpen) => propsRef.current.onChatToggle?.(isOpen),
|
|
22
|
+
onCards: (cards) => propsRef.current.onCards?.(cards),
|
|
23
|
+
onError: (error) => propsRef.current.onError?.(error)
|
|
24
|
+
});
|
|
25
|
+
agentRef.current = agent;
|
|
26
|
+
return () => {
|
|
27
|
+
agent.destroy();
|
|
28
|
+
agentRef.current = null;
|
|
29
|
+
};
|
|
30
|
+
}, [configKey]);
|
|
31
|
+
return React.createElement("div", {
|
|
32
|
+
ref: containerRef,
|
|
33
|
+
style: { display: "contents" },
|
|
34
|
+
"data-daba-agent-react-container": "true"
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { DabaAgentComponent as DabaAgent, DabaAgentComponent, DabaAgentComponent as DabaAgentReact };
|
|
3
39
|
//# sourceMappingURL=react.js.map
|
|
4
40
|
//# sourceMappingURL=react.js.map
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"react.js"}
|
|
1
|
+
{"version":3,"sources":["../src/components/react.ts"],"names":[],"mappings":";;;AAMO,SAAS,mBAAmB,KAAA,EAA2C;AAC5E,EAAA,MAAM,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,QAAA,GAAW,OAAyB,IAAI,CAAA;AAK9C,EAAA,MAAM,QAAA,GAAW,OAAO,KAAK,CAAA;AAC7B,EAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAiBnB,EAAA,MAAM,YAAY,IAAA,CAAK,SAAA;AAAA,IAAU,KAAA;AAAA,IAAO,CAAC,IAAA,EAAM,KAAA,KAC7C,OAAO,KAAA,KAAU,aAAa,MAAA,GAAY;AAAA,GAC5C;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,aAAa,OAAA,EAAS;AAE3B,IAAA,MAAM,KAAA,GAAQ,IAAI,SAAA,CAAU;AAAA,MAC1B,GAAG,QAAA,CAAS,OAAA;AAAA;AAAA,MAEZ,WAAW,YAAA,CAAa,OAAA;AAAA,MACxB,gBAAgB,CAAC,MAAA,KAAW,QAAA,CAAS,OAAA,CAAQ,iBAAiB,MAAM,CAAA;AAAA,MACpE,YAAA,EAAc,CAAC,IAAA,EAAM,IAAA,EAAM,OAAA,KACzB,SAAS,OAAA,CAAQ,YAAA,GAAe,IAAA,EAAM,IAAA,EAAM,OAAO,CAAA;AAAA,MACrD,cAAc,CAAC,MAAA,KAAW,QAAA,CAAS,OAAA,CAAQ,eAAe,MAAM,CAAA;AAAA,MAChE,SAAS,CAAC,KAAA,KAAU,QAAA,CAAS,OAAA,CAAQ,UAAU,KAAK,CAAA;AAAA,MACpD,SAAS,CAAC,KAAA,KAAU,QAAA,CAAS,OAAA,CAAQ,UAAU,KAAK;AAAA,KACrD,CAAA;AACD,IAAA,QAAA,CAAS,OAAA,GAAU,KAAA;AAEnB,IAAA,OAAO,MAAM;AACX,MAAA,KAAA,CAAM,OAAA,EAAQ;AACd,MAAA,QAAA,CAAS,OAAA,GAAU,IAAA;AAAA,IACrB,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,OAAO,KAAA,CAAM,cAAc,KAAA,EAAO;AAAA,IAChC,GAAA,EAAK,YAAA;AAAA,IACL,KAAA,EAAO,EAAE,OAAA,EAAS,UAAA,EAAW;AAAA,IAC7B,iCAAA,EAAmC;AAAA,GACpC,CAAA;AACH","file":"react.js","sourcesContent":["import React, { useEffect, useRef } from \"react\";\nimport { DabaAgent } from \"../agent\";\nimport type { DabaAgentOptions } from \"../types\";\n\nexport type DabaAgentProps = Omit<DabaAgentOptions, \"container\">;\n\nexport function DabaAgentComponent(props: DabaAgentProps): React.ReactElement {\n const containerRef = useRef<HTMLDivElement>(null);\n const agentRef = useRef<DabaAgent | null>(null);\n\n // The agent reads its handlers back out of this ref at call time, which\n // is what keeps an inline `onCards={(c) => setCards(c)}` current without\n // its per-render identity forcing a rebuild below.\n const propsRef = useRef(props);\n propsRef.current = props;\n\n /**\n * The effect keys on the configuration's VALUE, not on the prop objects.\n *\n * `theme={{ accentColor: \"#0c8c5e\" }}` is a fresh object on every render\n * of the parent, so listing it as a dependency would destroy and rebuild\n * the widget — closing the panel, dropping the conversation, restarting\n * a voice session — every time an unrelated piece of the host page's\n * state changed. Serialising compares the way the integrator meant it.\n *\n * Functions are stripped rather than compared: callbacks are re-created\n * on every render too, and they reach the live agent through `propsRef`\n * instead. Serialising also means a newly added option is covered here\n * the moment it exists, which the hand-listed dependency array this\n * replaces was already out of step with (`env` never made it in).\n */\n const configKey = JSON.stringify(props, (_key, value) =>\n typeof value === \"function\" ? undefined : value,\n );\n\n useEffect(() => {\n if (!containerRef.current) return;\n\n const agent = new DabaAgent({\n ...propsRef.current,\n // After the spread: this component owns where the widget mounts.\n container: containerRef.current,\n onStatusChange: (status) => propsRef.current.onStatusChange?.(status),\n onTranscript: (role, text, isFinal) =>\n propsRef.current.onTranscript?.(role, text, isFinal),\n onChatToggle: (isOpen) => propsRef.current.onChatToggle?.(isOpen),\n onCards: (cards) => propsRef.current.onCards?.(cards),\n onError: (error) => propsRef.current.onError?.(error),\n });\n agentRef.current = agent;\n\n return () => {\n agent.destroy();\n agentRef.current = null;\n };\n }, [configKey]);\n\n return React.createElement(\"div\", {\n ref: containerRef,\n style: { display: \"contents\" },\n \"data-daba-agent-react-container\": \"true\",\n });\n}\n\nexport { DabaAgentComponent as DabaAgentReact, DabaAgentComponent as DabaAgent };\n"]}
|
|
@@ -89,7 +89,7 @@ interface ChatMessage {
|
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* Colour and shape overrides. Every field is optional and every absent
|
|
92
|
-
* field falls back to the
|
|
92
|
+
* field falls back to the DabaLabs brand kit, so `{}` is a complete,
|
|
93
93
|
* correct theme rather than an empty one.
|
|
94
94
|
*/
|
|
95
95
|
interface DabaTheme {
|
|
@@ -124,8 +124,46 @@ interface DabaLauncher {
|
|
|
124
124
|
shape?: DabaLauncherShape;
|
|
125
125
|
/** Replaces the shipped mark entirely. Use for a customer's own logo. */
|
|
126
126
|
iconUrl?: string | null;
|
|
127
|
+
/**
|
|
128
|
+
* The mark as inline SVG markup rather than a URL.
|
|
129
|
+
*
|
|
130
|
+
* Wins over `iconUrl`. Worth preferring on a site with a strict
|
|
131
|
+
* Content-Security-Policy, where `img-src 'self'` blocks an <img> at
|
|
132
|
+
* someone else's CDN and the launcher would render empty; inline markup
|
|
133
|
+
* has no such dependency and can inherit `currentColor`. Script, event
|
|
134
|
+
* handlers and external references are stripped before it is inserted.
|
|
135
|
+
*/
|
|
136
|
+
iconSvg?: string | null;
|
|
137
|
+
/** An emoji or a letter or two, drawn as the mark. Wins over `iconUrl`,
|
|
138
|
+
* loses to `iconSvg`. */
|
|
139
|
+
iconText?: string | null;
|
|
127
140
|
/** Text beside the icon, turning the badge into a labelled pill. */
|
|
128
141
|
label?: string | null;
|
|
142
|
+
/** The launcher button itself, as any CSS length. Default "56px" — or
|
|
143
|
+
* "52px" below 480px wide, which an explicit value overrides on phones
|
|
144
|
+
* too. */
|
|
145
|
+
size?: string | number;
|
|
146
|
+
/** The mark inside the button, as any CSS length. Default "100%", so it
|
|
147
|
+
* fills the button; a wordmark with its own whitespace usually wants
|
|
148
|
+
* less. */
|
|
149
|
+
iconSize?: string | number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The chat panel's own box.
|
|
153
|
+
*
|
|
154
|
+
* Separate from `launcher` because "width and height" is ambiguous
|
|
155
|
+
* between the two, and an integrator who meant the panel and got the
|
|
156
|
+
* button has no way to tell from the option name.
|
|
157
|
+
*
|
|
158
|
+
* Ignored below 480px wide, where the panel goes full-screen: a fixed
|
|
159
|
+
* width on a phone either overflows the viewport or leaves a gutter.
|
|
160
|
+
*/
|
|
161
|
+
interface DabaPanel {
|
|
162
|
+
/** Any CSS length. Default "400px". */
|
|
163
|
+
width?: string | number;
|
|
164
|
+
/** Any CSS length. Default "740px". Still clamped to the viewport, so a
|
|
165
|
+
* value taller than the window does not push the launcher off-screen. */
|
|
166
|
+
height?: string | number;
|
|
129
167
|
}
|
|
130
168
|
interface DabaAgentOptions {
|
|
131
169
|
projectId: string;
|
|
@@ -133,7 +171,7 @@ interface DabaAgentOptions {
|
|
|
133
171
|
/** Overrides `env` when both are given — the only option that can name
|
|
134
172
|
* a host neither tier covers (self-hosted, a local gateway). */
|
|
135
173
|
gatewayUrl?: string;
|
|
136
|
-
/** Which
|
|
174
|
+
/** Which DabaLabs tier to talk to. Omit for production; pass "staging"
|
|
137
175
|
* to point the agent at the staging gateway. */
|
|
138
176
|
env?: DabaEnvironment;
|
|
139
177
|
/** Where to mount the widget. Defaults to a fixed-position element
|
|
@@ -158,8 +196,12 @@ interface DabaAgentOptions {
|
|
|
158
196
|
theme?: DabaTheme;
|
|
159
197
|
intro?: DabaIntro;
|
|
160
198
|
launcher?: DabaLauncher;
|
|
199
|
+
panel?: DabaPanel;
|
|
161
200
|
/** Brand logo shown in the panel header. */
|
|
162
201
|
logoUrl?: string | null;
|
|
202
|
+
/** The header logo as inline SVG markup. Wins over `logoUrl`; same CSP
|
|
203
|
+
* reasoning as `launcher.iconSvg`. */
|
|
204
|
+
logoSvg?: string | null;
|
|
163
205
|
/** BCP-47 code for the widget's own chrome, or "auto" to follow the
|
|
164
206
|
* host page's `lang`. Independent of what the assistant replies in —
|
|
165
207
|
* it always answers in the visitor's language regardless. */
|
|
@@ -177,7 +219,31 @@ interface DabaAgentOptions {
|
|
|
177
219
|
placeholder?: string;
|
|
178
220
|
/** Whether the chat popover starts open. */
|
|
179
221
|
initialOpen?: boolean;
|
|
180
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Keep past conversations in this browser, so a visitor can go back to
|
|
224
|
+
* one — a history button appears in the panel header once there is
|
|
225
|
+
* something in it.
|
|
226
|
+
*
|
|
227
|
+
* OFF unless you pass `true`. The live transcript is sessionStorage and
|
|
228
|
+
* dies with the tab on purpose ("a conversation is a visit, not an
|
|
229
|
+
* identity"); an archive is localStorage and outlives it, which on a
|
|
230
|
+
* shared or public machine is a decision an embed has to make
|
|
231
|
+
* deliberately rather than inherit. Nothing is sent to the gateway, and
|
|
232
|
+
* the visitor can delete any thread or clear the lot from the panel.
|
|
233
|
+
*/
|
|
234
|
+
historyEnabled?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Keyboard shortcut that opens and closes the assistant.
|
|
237
|
+
*
|
|
238
|
+
* A combination — `"ctrl+space"`, `"alt+k"` — or a modifier held on its
|
|
239
|
+
* own: `"hold:ctrl"`, and likewise `hold:alt`, `hold:shift`, `hold:meta`.
|
|
240
|
+
* A held modifier fires after about half a second and is abandoned the
|
|
241
|
+
* moment another key joins it, so `Ctrl+C` never opens the widget.
|
|
242
|
+
*
|
|
243
|
+
* Defaults per platform: `alt+space` on macOS, where the OS binds
|
|
244
|
+
* Ctrl+Space to the input-source switcher, and `ctrl+space` elsewhere.
|
|
245
|
+
* `null` disables the shortcut entirely.
|
|
246
|
+
*/
|
|
181
247
|
hotkey?: string | null;
|
|
182
248
|
onError?: (error: DabaError) => void;
|
|
183
249
|
onStatusChange?: (status: DabaAgentStatus) => void;
|
|
@@ -236,4 +302,4 @@ interface DabaChatReply {
|
|
|
236
302
|
conversationId: string;
|
|
237
303
|
}
|
|
238
304
|
|
|
239
|
-
export type { ChatMessage as C,
|
|
305
|
+
export type { ChatMessage as C, DabaAgentOptions as D, DabaAgentStatus as a, DabaAgentMode as b, DabaAgentPosition as c, DabaCard as d, DabaCardKind as e, DabaCardMeta as f, DabaChatReply as g, DabaDirection as h, DabaError as i, DabaIntro as j, DabaLauncher as k, DabaLauncherShape as l, DabaPanel as m, DabaRemoteConfig as n, DabaTheme as o, DabaThemePreference as p, DabaVoiceEngine as q };
|
|
@@ -89,7 +89,7 @@ interface ChatMessage {
|
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
91
91
|
* Colour and shape overrides. Every field is optional and every absent
|
|
92
|
-
* field falls back to the
|
|
92
|
+
* field falls back to the DabaLabs brand kit, so `{}` is a complete,
|
|
93
93
|
* correct theme rather than an empty one.
|
|
94
94
|
*/
|
|
95
95
|
interface DabaTheme {
|
|
@@ -124,8 +124,46 @@ interface DabaLauncher {
|
|
|
124
124
|
shape?: DabaLauncherShape;
|
|
125
125
|
/** Replaces the shipped mark entirely. Use for a customer's own logo. */
|
|
126
126
|
iconUrl?: string | null;
|
|
127
|
+
/**
|
|
128
|
+
* The mark as inline SVG markup rather than a URL.
|
|
129
|
+
*
|
|
130
|
+
* Wins over `iconUrl`. Worth preferring on a site with a strict
|
|
131
|
+
* Content-Security-Policy, where `img-src 'self'` blocks an <img> at
|
|
132
|
+
* someone else's CDN and the launcher would render empty; inline markup
|
|
133
|
+
* has no such dependency and can inherit `currentColor`. Script, event
|
|
134
|
+
* handlers and external references are stripped before it is inserted.
|
|
135
|
+
*/
|
|
136
|
+
iconSvg?: string | null;
|
|
137
|
+
/** An emoji or a letter or two, drawn as the mark. Wins over `iconUrl`,
|
|
138
|
+
* loses to `iconSvg`. */
|
|
139
|
+
iconText?: string | null;
|
|
127
140
|
/** Text beside the icon, turning the badge into a labelled pill. */
|
|
128
141
|
label?: string | null;
|
|
142
|
+
/** The launcher button itself, as any CSS length. Default "56px" — or
|
|
143
|
+
* "52px" below 480px wide, which an explicit value overrides on phones
|
|
144
|
+
* too. */
|
|
145
|
+
size?: string | number;
|
|
146
|
+
/** The mark inside the button, as any CSS length. Default "100%", so it
|
|
147
|
+
* fills the button; a wordmark with its own whitespace usually wants
|
|
148
|
+
* less. */
|
|
149
|
+
iconSize?: string | number;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The chat panel's own box.
|
|
153
|
+
*
|
|
154
|
+
* Separate from `launcher` because "width and height" is ambiguous
|
|
155
|
+
* between the two, and an integrator who meant the panel and got the
|
|
156
|
+
* button has no way to tell from the option name.
|
|
157
|
+
*
|
|
158
|
+
* Ignored below 480px wide, where the panel goes full-screen: a fixed
|
|
159
|
+
* width on a phone either overflows the viewport or leaves a gutter.
|
|
160
|
+
*/
|
|
161
|
+
interface DabaPanel {
|
|
162
|
+
/** Any CSS length. Default "400px". */
|
|
163
|
+
width?: string | number;
|
|
164
|
+
/** Any CSS length. Default "740px". Still clamped to the viewport, so a
|
|
165
|
+
* value taller than the window does not push the launcher off-screen. */
|
|
166
|
+
height?: string | number;
|
|
129
167
|
}
|
|
130
168
|
interface DabaAgentOptions {
|
|
131
169
|
projectId: string;
|
|
@@ -133,7 +171,7 @@ interface DabaAgentOptions {
|
|
|
133
171
|
/** Overrides `env` when both are given — the only option that can name
|
|
134
172
|
* a host neither tier covers (self-hosted, a local gateway). */
|
|
135
173
|
gatewayUrl?: string;
|
|
136
|
-
/** Which
|
|
174
|
+
/** Which DabaLabs tier to talk to. Omit for production; pass "staging"
|
|
137
175
|
* to point the agent at the staging gateway. */
|
|
138
176
|
env?: DabaEnvironment;
|
|
139
177
|
/** Where to mount the widget. Defaults to a fixed-position element
|
|
@@ -158,8 +196,12 @@ interface DabaAgentOptions {
|
|
|
158
196
|
theme?: DabaTheme;
|
|
159
197
|
intro?: DabaIntro;
|
|
160
198
|
launcher?: DabaLauncher;
|
|
199
|
+
panel?: DabaPanel;
|
|
161
200
|
/** Brand logo shown in the panel header. */
|
|
162
201
|
logoUrl?: string | null;
|
|
202
|
+
/** The header logo as inline SVG markup. Wins over `logoUrl`; same CSP
|
|
203
|
+
* reasoning as `launcher.iconSvg`. */
|
|
204
|
+
logoSvg?: string | null;
|
|
163
205
|
/** BCP-47 code for the widget's own chrome, or "auto" to follow the
|
|
164
206
|
* host page's `lang`. Independent of what the assistant replies in —
|
|
165
207
|
* it always answers in the visitor's language regardless. */
|
|
@@ -177,7 +219,31 @@ interface DabaAgentOptions {
|
|
|
177
219
|
placeholder?: string;
|
|
178
220
|
/** Whether the chat popover starts open. */
|
|
179
221
|
initialOpen?: boolean;
|
|
180
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Keep past conversations in this browser, so a visitor can go back to
|
|
224
|
+
* one — a history button appears in the panel header once there is
|
|
225
|
+
* something in it.
|
|
226
|
+
*
|
|
227
|
+
* OFF unless you pass `true`. The live transcript is sessionStorage and
|
|
228
|
+
* dies with the tab on purpose ("a conversation is a visit, not an
|
|
229
|
+
* identity"); an archive is localStorage and outlives it, which on a
|
|
230
|
+
* shared or public machine is a decision an embed has to make
|
|
231
|
+
* deliberately rather than inherit. Nothing is sent to the gateway, and
|
|
232
|
+
* the visitor can delete any thread or clear the lot from the panel.
|
|
233
|
+
*/
|
|
234
|
+
historyEnabled?: boolean;
|
|
235
|
+
/**
|
|
236
|
+
* Keyboard shortcut that opens and closes the assistant.
|
|
237
|
+
*
|
|
238
|
+
* A combination — `"ctrl+space"`, `"alt+k"` — or a modifier held on its
|
|
239
|
+
* own: `"hold:ctrl"`, and likewise `hold:alt`, `hold:shift`, `hold:meta`.
|
|
240
|
+
* A held modifier fires after about half a second and is abandoned the
|
|
241
|
+
* moment another key joins it, so `Ctrl+C` never opens the widget.
|
|
242
|
+
*
|
|
243
|
+
* Defaults per platform: `alt+space` on macOS, where the OS binds
|
|
244
|
+
* Ctrl+Space to the input-source switcher, and `ctrl+space` elsewhere.
|
|
245
|
+
* `null` disables the shortcut entirely.
|
|
246
|
+
*/
|
|
181
247
|
hotkey?: string | null;
|
|
182
248
|
onError?: (error: DabaError) => void;
|
|
183
249
|
onStatusChange?: (status: DabaAgentStatus) => void;
|
|
@@ -236,4 +302,4 @@ interface DabaChatReply {
|
|
|
236
302
|
conversationId: string;
|
|
237
303
|
}
|
|
238
304
|
|
|
239
|
-
export type { ChatMessage as C,
|
|
305
|
+
export type { ChatMessage as C, DabaAgentOptions as D, DabaAgentStatus as a, DabaAgentMode as b, DabaAgentPosition as c, DabaCard as d, DabaCardKind as e, DabaCardMeta as f, DabaChatReply as g, DabaDirection as h, DabaError as i, DabaIntro as j, DabaLauncher as k, DabaLauncherShape as l, DabaPanel as m, DabaRemoteConfig as n, DabaTheme as o, DabaThemePreference as p, DabaVoiceEngine as q };
|
package/package.json
CHANGED
package/dist/chunk-7ENX2QZK.js
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { DabaAgent } from './chunk-CMHPVBEF.js';
|
|
2
|
-
|
|
3
|
-
// src/components/custom-element.ts
|
|
4
|
-
var VALID_POSITIONS = [
|
|
5
|
-
"bottom-right",
|
|
6
|
-
"bottom-left",
|
|
7
|
-
"top-right",
|
|
8
|
-
"top-left"
|
|
9
|
-
];
|
|
10
|
-
var VALID_MODES = ["voice", "chat", "hybrid"];
|
|
11
|
-
var VALID_DIRECTIONS = ["auto", "ltr", "rtl"];
|
|
12
|
-
var VALID_THEMES = ["auto", "light", "dark"];
|
|
13
|
-
var VALID_LAUNCHER_SHAPES = ["rounded", "circle", "pill"];
|
|
14
|
-
var VALID_MEDIA_TYPES = ["video", "image", "none"];
|
|
15
|
-
var PROMPT_SEPARATOR = "|";
|
|
16
|
-
function readAttr(el, name) {
|
|
17
|
-
for (const attr of [name, `data-${name}`]) {
|
|
18
|
-
const raw = el.getAttribute(attr);
|
|
19
|
-
if (raw === null) continue;
|
|
20
|
-
const value = raw.trim();
|
|
21
|
-
if (value === "") continue;
|
|
22
|
-
return { attr, value };
|
|
23
|
-
}
|
|
24
|
-
return void 0;
|
|
25
|
-
}
|
|
26
|
-
function stringAttr(el, name) {
|
|
27
|
-
return readAttr(el, name)?.value;
|
|
28
|
-
}
|
|
29
|
-
function enumAttr(el, name, allowed) {
|
|
30
|
-
const found = readAttr(el, name);
|
|
31
|
-
if (!found) return void 0;
|
|
32
|
-
if (allowed.includes(found.value)) return found.value;
|
|
33
|
-
console.error(
|
|
34
|
-
`daba-agent: invalid ${found.attr} "${found.value}" on <daba-agent>. Expected one of ${allowed.join(
|
|
35
|
-
", "
|
|
36
|
-
)} \u2014 ignoring it.`,
|
|
37
|
-
el
|
|
38
|
-
);
|
|
39
|
-
return void 0;
|
|
40
|
-
}
|
|
41
|
-
function flagAttr(el, name) {
|
|
42
|
-
for (const attr of [name, `data-${name}`]) {
|
|
43
|
-
const raw = el.getAttribute(attr);
|
|
44
|
-
if (raw === null) continue;
|
|
45
|
-
const value = raw.trim().toLowerCase();
|
|
46
|
-
return value !== "false" && value !== "0" && value !== "no";
|
|
47
|
-
}
|
|
48
|
-
return void 0;
|
|
49
|
-
}
|
|
50
|
-
function promptsAttr(el, name) {
|
|
51
|
-
const found = readAttr(el, name);
|
|
52
|
-
if (!found) return void 0;
|
|
53
|
-
const prompts = found.value.split(PROMPT_SEPARATOR).map((prompt) => prompt.trim()).filter((prompt) => prompt !== "");
|
|
54
|
-
return prompts.length > 0 ? prompts : void 0;
|
|
55
|
-
}
|
|
56
|
-
function group(fields) {
|
|
57
|
-
return Object.values(fields).some((value) => value !== void 0) ? fields : void 0;
|
|
58
|
-
}
|
|
59
|
-
var DabaAgentElement = class extends HTMLElement {
|
|
60
|
-
constructor() {
|
|
61
|
-
super(...arguments);
|
|
62
|
-
this.agent = null;
|
|
63
|
-
}
|
|
64
|
-
connectedCallback() {
|
|
65
|
-
if (this.agent) return;
|
|
66
|
-
const projectId = stringAttr(this, "project-id");
|
|
67
|
-
const apiKey = stringAttr(this, "api-key");
|
|
68
|
-
if (!projectId || !apiKey) {
|
|
69
|
-
console.error(
|
|
70
|
-
"daba-agent: <daba-agent> custom element requires project-id and api-key attributes.",
|
|
71
|
-
this
|
|
72
|
-
);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const position = enumAttr(this, "position", VALID_POSITIONS);
|
|
76
|
-
const accentColor = stringAttr(this, "accent-color");
|
|
77
|
-
const mode = enumAttr(this, "mode", VALID_MODES);
|
|
78
|
-
const title = stringAttr(this, "title");
|
|
79
|
-
const placeholder = stringAttr(this, "placeholder");
|
|
80
|
-
const initialOpen = flagAttr(this, "initial-open");
|
|
81
|
-
const hotkey = stringAttr(this, "hotkey");
|
|
82
|
-
const gatewayUrl = stringAttr(this, "gateway-url");
|
|
83
|
-
const env = stringAttr(this, "env");
|
|
84
|
-
const theme = group({
|
|
85
|
-
accentColor,
|
|
86
|
-
accentContrast: stringAttr(this, "accent-contrast"),
|
|
87
|
-
surfaceColor: stringAttr(this, "surface-color"),
|
|
88
|
-
textColor: stringAttr(this, "text-color"),
|
|
89
|
-
radius: stringAttr(this, "radius"),
|
|
90
|
-
fontFamily: stringAttr(this, "font-family"),
|
|
91
|
-
theme: enumAttr(this, "theme", VALID_THEMES)
|
|
92
|
-
});
|
|
93
|
-
const introDisabled = flagAttr(this, "intro-disabled");
|
|
94
|
-
const intro = group({
|
|
95
|
-
enabled: introDisabled === void 0 ? void 0 : !introDisabled,
|
|
96
|
-
headline: stringAttr(this, "intro-headline"),
|
|
97
|
-
subheadline: stringAttr(this, "intro-subheadline"),
|
|
98
|
-
mediaUrl: stringAttr(this, "intro-media-url"),
|
|
99
|
-
mediaType: enumAttr(this, "intro-media-type", VALID_MEDIA_TYPES),
|
|
100
|
-
suggestedPrompts: promptsAttr(this, "suggested-prompts")
|
|
101
|
-
});
|
|
102
|
-
const launcher = group({
|
|
103
|
-
shape: enumAttr(this, "launcher-shape", VALID_LAUNCHER_SHAPES),
|
|
104
|
-
iconUrl: stringAttr(this, "launcher-icon-url"),
|
|
105
|
-
label: stringAttr(this, "launcher-label")
|
|
106
|
-
});
|
|
107
|
-
this.agent = new DabaAgent({
|
|
108
|
-
container: this,
|
|
109
|
-
projectId,
|
|
110
|
-
apiKey,
|
|
111
|
-
position,
|
|
112
|
-
accentColor,
|
|
113
|
-
mode,
|
|
114
|
-
title,
|
|
115
|
-
placeholder,
|
|
116
|
-
initialOpen,
|
|
117
|
-
hotkey,
|
|
118
|
-
gatewayUrl,
|
|
119
|
-
env,
|
|
120
|
-
theme,
|
|
121
|
-
intro,
|
|
122
|
-
launcher,
|
|
123
|
-
logoUrl: stringAttr(this, "logo-url"),
|
|
124
|
-
uiLanguage: stringAttr(this, "ui-language"),
|
|
125
|
-
direction: enumAttr(this, "direction", VALID_DIRECTIONS),
|
|
126
|
-
onStatusChange: (status) => {
|
|
127
|
-
this.dispatchEvent(
|
|
128
|
-
new CustomEvent("daba-status-change", { detail: { status }, bubbles: true, composed: true })
|
|
129
|
-
);
|
|
130
|
-
},
|
|
131
|
-
onTranscript: (role, text, isFinal) => {
|
|
132
|
-
this.dispatchEvent(
|
|
133
|
-
new CustomEvent("daba-transcript", {
|
|
134
|
-
detail: { role, text, isFinal },
|
|
135
|
-
bubbles: true,
|
|
136
|
-
composed: true
|
|
137
|
-
})
|
|
138
|
-
);
|
|
139
|
-
},
|
|
140
|
-
onError: (error) => {
|
|
141
|
-
this.dispatchEvent(
|
|
142
|
-
new CustomEvent("daba-error", { detail: { error }, bubbles: true, composed: true })
|
|
143
|
-
);
|
|
144
|
-
},
|
|
145
|
-
onChatToggle: (isOpen) => {
|
|
146
|
-
this.dispatchEvent(
|
|
147
|
-
new CustomEvent("daba-chat-toggle", { detail: { isOpen }, bubbles: true, composed: true })
|
|
148
|
-
);
|
|
149
|
-
},
|
|
150
|
-
// Cards arrive once per reply that carried structured items, so a
|
|
151
|
-
// host page can render them in its own layout instead of (or as well
|
|
152
|
-
// as) the panel's — a listing site putting event cards on the page.
|
|
153
|
-
onCards: (cards) => {
|
|
154
|
-
this.dispatchEvent(
|
|
155
|
-
new CustomEvent("daba-cards", { detail: { cards }, bubbles: true, composed: true })
|
|
156
|
-
);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
disconnectedCallback() {
|
|
161
|
-
if (this.agent) {
|
|
162
|
-
this.agent.destroy();
|
|
163
|
-
this.agent = null;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
get dabaAgent() {
|
|
167
|
-
return this.agent;
|
|
168
|
-
}
|
|
169
|
-
sendText(text) {
|
|
170
|
-
return this.agent?.sendText(text);
|
|
171
|
-
}
|
|
172
|
-
openChat() {
|
|
173
|
-
this.agent?.openChat();
|
|
174
|
-
}
|
|
175
|
-
closeChat() {
|
|
176
|
-
this.agent?.closeChat();
|
|
177
|
-
}
|
|
178
|
-
toggleChat() {
|
|
179
|
-
this.agent?.toggleChat();
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
function defineDabaAgentElement(tagName = "daba-agent") {
|
|
183
|
-
if (typeof window !== "undefined" && typeof customElements !== "undefined") {
|
|
184
|
-
if (!customElements.get(tagName)) {
|
|
185
|
-
customElements.define(tagName, DabaAgentElement);
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
defineDabaAgentElement();
|
|
190
|
-
|
|
191
|
-
export { DabaAgentElement, defineDabaAgentElement };
|
|
192
|
-
//# sourceMappingURL=chunk-7ENX2QZK.js.map
|
|
193
|
-
//# sourceMappingURL=chunk-7ENX2QZK.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/custom-element.ts"],"names":[],"mappings":";;;AAaA,IAAM,eAAA,GAAgD;AAAA,EACpD,cAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAA;AACA,IAAM,WAAA,GAAwC,CAAC,OAAA,EAAS,MAAA,EAAQ,QAAQ,CAAA;AACxE,IAAM,gBAAA,GAA6C,CAAC,MAAA,EAAQ,KAAA,EAAO,KAAK,CAAA;AACxE,IAAM,YAAA,GAA+C,CAAC,MAAA,EAAQ,OAAA,EAAS,MAAM,CAAA;AAC7E,IAAM,qBAAA,GAAsD,CAAC,SAAA,EAAW,QAAA,EAAU,MAAM,CAAA;AACxF,IAAM,iBAAA,GAAoB,CAAC,OAAA,EAAS,OAAA,EAAS,MAAM,CAAA;AAKnD,IAAM,gBAAA,GAAmB,GAAA;AAezB,SAAS,QAAA,CAAS,IAAiB,IAAA,EAA2D;AAC5F,EAAA,KAAA,MAAW,QAAQ,CAAC,IAAA,EAAM,CAAA,KAAA,EAAQ,IAAI,EAAE,CAAA,EAAG;AACzC,IAAA,MAAM,GAAA,GAAM,EAAA,CAAG,YAAA,CAAa,IAAI,CAAA;AAChC,IAAA,IAAI,QAAQ,IAAA,EAAM;AAClB,IAAA,MAAM,KAAA,GAAQ,IAAI,IAAA,EAAK;AACvB,IAAA,IAAI,UAAU,EAAA,EAAI;AAClB,IAAA,OAAO,EAAE,MAAM,KAAA,EAAM;AAAA,EACvB;AACA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,UAAA,CAAW,IAAiB,IAAA,EAAkC;AACrE,EAAA,OAAO,QAAA,CAAS,EAAA,EAAI,IAAI,CAAA,EAAG,KAAA;AAC7B;AAKA,SA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xB;AAAA,EAEO,UAAA,GAAmB;AACxB,IAAA,IAAA,CAAK,OAAO,UAAA,EAAW;AAAA,EACzB;AACF;AAEO,SAAS,sBAAA,CAAuB,UAAU,YAAA,EAAoB;AACnE,EAAA,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,OAAO,mBAAmB,WAAA,EAAa;AAC1E,IAAA,IAAI,CAAC,cAAA,CAAe,GAAA,CAAI,OAAO,CAAA,EAAG;AAChC,MAAA,cAAA,CAAe,MAAA,CAAO,SAAS,gBAAgB,CAAA;AAAA,IACjD;AAAA,EACF;AACF;AAEA,sBAAA,EAAuB","file":"chunk-7ENX2QZK.js","sourcesContent":["import { DabaAgent } from \"../agent\";\nimport type {\n DabaAgentMode,\n DabaAgentOptions,\n DabaAgentPosition,\n DabaDirection,\n DabaIntro,\n DabaLauncher,\n DabaLauncherShape,\n DabaTheme,\n DabaThemePreference,\n} from \"../types\";\n\nconst VALID_POSITIONS: readonly DabaAgentPosition[] = [\n \"bottom-right\",\n \"bottom-left\",\n \"top-right\",\n \"top-left\",\n];\nconst VALID_MODES: readonly DabaAgentMode[] = [\"voice\", \"chat\", \"hybrid\"];\nconst VALID_DIRECTIONS: readonly DabaDirection[] = [\"auto\", \"ltr\", \"rtl\"];\nconst VALID_THEMES: readonly DabaThemePreference[] = [\"auto\", \"light\", \"dark\"];\nconst VALID_LAUNCHER_SHAPES: readonly DabaLauncherShape[] = [\"rounded\", \"circle\", \"pill\"];\nconst VALID_MEDIA_TYPES = [\"video\", \"image\", \"none\"] as const;\n\n/** Same separator as the script-tag embed's data-daba-suggested-prompts —\n * a pipe, because starter prompts are sentences and sentences contain\n * commas. See src/auto-init.ts for the reasoning. */\nconst PROMPT_SEPARATOR = \"|\";\n\n/**\n * Reads `<name>`, then the `data-<name>` alias this element has always\n * accepted, and reports which spelling was found so a warning can quote\n * what the integrator actually typed.\n *\n * Absent AND blank both read as \"not set\", because an option left\n * `undefined` is what tells the agent to use the project's dashboard\n * configuration. A framework binding that renders `radius=\"\"` must leave\n * the served radius alone rather than override it with nothing.\n *\n * These readers deliberately mirror src/auto-init.ts: the two embeds spell\n * their attributes differently but must accept exactly the same values.\n */\nfunction readAttr(el: HTMLElement, name: string): { attr: string; value: string } | undefined {\n for (const attr of [name, `data-${name}`]) {\n const raw = el.getAttribute(attr);\n if (raw === null) continue;\n const value = raw.trim();\n if (value === \"\") continue;\n return { attr, value };\n }\n return undefined;\n}\n\nfunction stringAttr(el: HTMLElement, name: string): string | undefined {\n return readAttr(el, name)?.value;\n}\n\n/** A value outside the allowed set is dropped rather than forwarded, which\n * leaves the option `undefined` and so degrades a typo to the project's own\n * setting instead of letting garbage reach the DOM. */\nfunction enumAttr<T extends string>(\n el: HTMLElement,\n name: string,\n allowed: readonly T[],\n): T | undefined {\n const found = readAttr(el, name);\n if (!found) return undefined;\n if ((allowed as readonly string[]).includes(found.value)) return found.value as T;\n console.error(\n `daba-agent: invalid ${found.attr} \"${found.value}\" on <daba-agent>. Expected one of ${allowed.join(\n \", \",\n )} — ignoring it.`,\n el,\n );\n return undefined;\n}\n\n/** Present with no value is true, the way HTML spells a boolean, but an\n * explicit \"false\" still means false so a bound attribute\n * (`:intro-disabled=\"hideIntro\"`) does not disable the intro everywhere. */\nfunction flagAttr(el: HTMLElement, name: string): boolean | undefined {\n for (const attr of [name, `data-${name}`]) {\n const raw = el.getAttribute(attr);\n if (raw === null) continue;\n const value = raw.trim().toLowerCase();\n return value !== \"false\" && value !== \"0\" && value !== \"no\";\n }\n return undefined;\n}\n\n/** A list that separates into nothing is unset, not empty — far likelier a\n * binding that rendered nothing than a deliberate clearing of the\n * project's prompts. */\nfunction promptsAttr(el: HTMLElement, name: string): string[] | undefined {\n const found = readAttr(el, name);\n if (!found) return undefined;\n const prompts = found.value\n .split(PROMPT_SEPARATOR)\n .map((prompt) => prompt.trim())\n .filter((prompt) => prompt !== \"\");\n return prompts.length > 0 ? prompts : undefined;\n}\n\n/** Grouped options exist only when one of their fields was configured;\n * an empty group would read downstream as an intentional override. */\nfunction group<T extends object>(fields: T): T | undefined {\n return Object.values(fields).some((value) => value !== undefined) ? fields : undefined;\n}\n\nexport class DabaAgentElement extends HTMLElement {\n private agent: DabaAgent | null = null;\n\n connectedCallback(): void {\n if (this.agent) return;\n\n const projectId = stringAttr(this, \"project-id\");\n const apiKey = stringAttr(this, \"api-key\");\n\n if (!projectId || !apiKey) {\n console.error(\n \"daba-agent: <daba-agent> custom element requires project-id and api-key attributes.\",\n this,\n );\n return;\n }\n\n const position = enumAttr(this, \"position\", VALID_POSITIONS);\n const accentColor = stringAttr(this, \"accent-color\");\n const mode = enumAttr(this, \"mode\", VALID_MODES);\n const title = stringAttr(this, \"title\");\n const placeholder = stringAttr(this, \"placeholder\");\n const initialOpen = flagAttr(this, \"initial-open\");\n const hotkey = stringAttr(this, \"hotkey\");\n const gatewayUrl = stringAttr(this, \"gateway-url\");\n // env=\"staging\" points the element at the staging gateway, the same\n // way data-daba-env does for the script-tag embed. Absent means\n // production — see environment.ts.\n const env = stringAttr(this, \"env\") as DabaAgentOptions[\"env\"];\n\n // The accent is offered under both names it has on the option surface:\n // the flat `accentColor` the badge already reads, and the grouped\n // `theme.accentColor` that sits with the rest of the appearance\n // overrides. Same value either way.\n const theme = group<DabaTheme>({\n accentColor,\n accentContrast: stringAttr(this, \"accent-contrast\"),\n surfaceColor: stringAttr(this, \"surface-color\"),\n textColor: stringAttr(this, \"text-color\"),\n radius: stringAttr(this, \"radius\"),\n fontFamily: stringAttr(this, \"font-family\"),\n theme: enumAttr(this, \"theme\", VALID_THEMES),\n });\n\n // The attribute names the state an integrator wants to force — an\n // intro is on unless switched off — while the option carries the state\n // itself, so the flag is inverted here rather than in the agent.\n const introDisabled = flagAttr(this, \"intro-disabled\");\n const intro = group<DabaIntro>({\n enabled: introDisabled === undefined ? undefined : !introDisabled,\n headline: stringAttr(this, \"intro-headline\"),\n subheadline: stringAttr(this, \"intro-subheadline\"),\n mediaUrl: stringAttr(this, \"intro-media-url\"),\n mediaType: enumAttr(this, \"intro-media-type\", VALID_MEDIA_TYPES),\n suggestedPrompts: promptsAttr(this, \"suggested-prompts\"),\n });\n\n const launcher = group<DabaLauncher>({\n shape: enumAttr(this, \"launcher-shape\", VALID_LAUNCHER_SHAPES),\n iconUrl: stringAttr(this, \"launcher-icon-url\"),\n label: stringAttr(this, \"launcher-label\"),\n });\n\n this.agent = new DabaAgent({\n container: this,\n projectId,\n apiKey,\n position,\n accentColor,\n mode,\n title,\n placeholder,\n initialOpen,\n hotkey,\n gatewayUrl,\n env,\n theme,\n intro,\n launcher,\n logoUrl: stringAttr(this, \"logo-url\"),\n uiLanguage: stringAttr(this, \"ui-language\"),\n direction: enumAttr(this, \"direction\", VALID_DIRECTIONS),\n onStatusChange: (status) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-status-change\", { detail: { status }, bubbles: true, composed: true }),\n );\n },\n onTranscript: (role, text, isFinal) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-transcript\", {\n detail: { role, text, isFinal },\n bubbles: true,\n composed: true,\n }),\n );\n },\n onError: (error) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-error\", { detail: { error }, bubbles: true, composed: true }),\n );\n },\n onChatToggle: (isOpen) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-chat-toggle\", { detail: { isOpen }, bubbles: true, composed: true }),\n );\n },\n // Cards arrive once per reply that carried structured items, so a\n // host page can render them in its own layout instead of (or as well\n // as) the panel's — a listing site putting event cards on the page.\n onCards: (cards) => {\n this.dispatchEvent(\n new CustomEvent(\"daba-cards\", { detail: { cards }, bubbles: true, composed: true }),\n );\n },\n });\n }\n\n disconnectedCallback(): void {\n if (this.agent) {\n this.agent.destroy();\n this.agent = null;\n }\n }\n\n public get dabaAgent(): DabaAgent | null {\n return this.agent;\n }\n\n public sendText(text: string): Promise<void> | undefined {\n return this.agent?.sendText(text);\n }\n\n public openChat(): void {\n this.agent?.openChat();\n }\n\n public closeChat(): void {\n this.agent?.closeChat();\n }\n\n public toggleChat(): void {\n this.agent?.toggleChat();\n }\n}\n\nexport function defineDabaAgentElement(tagName = \"daba-agent\"): void {\n if (typeof window !== \"undefined\" && typeof customElements !== \"undefined\") {\n if (!customElements.get(tagName)) {\n customElements.define(tagName, DabaAgentElement);\n }\n }\n}\n\ndefineDabaAgentElement();\n"]}
|