@saar-ai/web-widget 0.21.0 → 0.22.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/dist/avatar-face.d.ts +4 -1
- package/dist/avatar-face.d.ts.map +1 -1
- package/dist/chunks/{host-widget-D675mXsN.js → host-widget-ETlw6B5z.js} +238 -126
- package/dist/concierge-shell.css +1 -1
- package/dist/generated/concierge-shell-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/next/index.js +1 -1
- package/dist/use-chat-session.d.ts +6 -2
- package/dist/use-chat-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +7 -2
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/call-view.d.ts +39 -6
- package/dist/widget/call-view.d.ts.map +1 -1
- package/dist/widget/concierge-shell.d.ts +8 -4
- package/dist/widget/concierge-shell.d.ts.map +1 -1
- package/dist/widget/shell-renderer.d.ts +1 -1
- package/dist/widget/shell-renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/styles/call-view.css +104 -30
- package/src/styles/mark.css +39 -5
- package/src/styles/widget-panel.css +29 -26
|
@@ -10188,6 +10188,46 @@ function createLucideIcon(iconDataOrName, iconNode = [], aliases = []) {
|
|
|
10188
10188
|
return Component;
|
|
10189
10189
|
}
|
|
10190
10190
|
//#endregion
|
|
10191
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/audio-lines.mjs
|
|
10192
|
+
/**
|
|
10193
|
+
* @license lucide-react v1.50.0 - ISC
|
|
10194
|
+
*
|
|
10195
|
+
* This source code is licensed under the ISC license.
|
|
10196
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
10197
|
+
*/
|
|
10198
|
+
var __iconData$6 = {
|
|
10199
|
+
name: "audio-lines",
|
|
10200
|
+
size: 24,
|
|
10201
|
+
node: [
|
|
10202
|
+
["path", {
|
|
10203
|
+
d: "M2 10v3",
|
|
10204
|
+
key: "1fnikh"
|
|
10205
|
+
}],
|
|
10206
|
+
["path", {
|
|
10207
|
+
d: "M6 6v11",
|
|
10208
|
+
key: "11sgs0"
|
|
10209
|
+
}],
|
|
10210
|
+
["path", {
|
|
10211
|
+
d: "M10 3v18",
|
|
10212
|
+
key: "yhl04a"
|
|
10213
|
+
}],
|
|
10214
|
+
["path", {
|
|
10215
|
+
d: "M14 8v7",
|
|
10216
|
+
key: "3a1oy3"
|
|
10217
|
+
}],
|
|
10218
|
+
["path", {
|
|
10219
|
+
d: "M18 5v13",
|
|
10220
|
+
key: "123xd1"
|
|
10221
|
+
}],
|
|
10222
|
+
["path", {
|
|
10223
|
+
d: "M22 10v3",
|
|
10224
|
+
key: "154ddg"
|
|
10225
|
+
}]
|
|
10226
|
+
]
|
|
10227
|
+
};
|
|
10228
|
+
__iconData$6.node;
|
|
10229
|
+
var AudioLines = createLucideIcon(__iconData$6);
|
|
10230
|
+
//#endregion
|
|
10191
10231
|
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/grip-vertical.mjs
|
|
10192
10232
|
/**
|
|
10193
10233
|
* @license lucide-react v1.50.0 - ISC
|
|
@@ -10533,7 +10573,7 @@ var MARK_SIZE = {
|
|
|
10533
10573
|
sm: 48,
|
|
10534
10574
|
lg: 64
|
|
10535
10575
|
};
|
|
10536
|
-
function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey, name, muted, markSize }) {
|
|
10576
|
+
function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey, name, muted, markSize, markState }) {
|
|
10537
10577
|
switch (avatar) {
|
|
10538
10578
|
case "orb": return /* @__PURE__ */ jsx(BotFace, {
|
|
10539
10579
|
state,
|
|
@@ -10551,7 +10591,7 @@ function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey, na
|
|
|
10551
10591
|
case "monogram":
|
|
10552
10592
|
case "dot": return /* @__PURE__ */ jsx(Mark, {
|
|
10553
10593
|
variant: avatar,
|
|
10554
|
-
state: markStateFor(state, { muted }),
|
|
10594
|
+
state: markState ?? markStateFor(state, { muted }),
|
|
10555
10595
|
size: markSize ?? MARK_SIZE[size],
|
|
10556
10596
|
...name !== void 0 ? { name } : {},
|
|
10557
10597
|
...label !== void 0 ? { label } : {}
|
|
@@ -11450,6 +11490,13 @@ var defaultCallMessages = {
|
|
|
11450
11490
|
call_ended: "Call ended",
|
|
11451
11491
|
call_interrupted: "Interrupted",
|
|
11452
11492
|
call_try_saying: "Try saying",
|
|
11493
|
+
call_start: "Start a call",
|
|
11494
|
+
call_agent: "Assistant",
|
|
11495
|
+
call_you: "You",
|
|
11496
|
+
call_thinking: "Thinking…",
|
|
11497
|
+
call_listening: "Listening…",
|
|
11498
|
+
call_mute_short: "Mute",
|
|
11499
|
+
call_end_short: "End",
|
|
11453
11500
|
call_to_text: "Type instead",
|
|
11454
11501
|
call_back_to_call: "Back to call",
|
|
11455
11502
|
call_back_to_chat: "Back to chat",
|
|
@@ -11661,12 +11708,38 @@ function CallTimer({ record, locale }) {
|
|
|
11661
11708
|
});
|
|
11662
11709
|
}
|
|
11663
11710
|
/**
|
|
11664
|
-
* The
|
|
11665
|
-
*
|
|
11666
|
-
*
|
|
11667
|
-
|
|
11711
|
+
* The suggestions the call earns right now (SAA-503). The open capture card's
|
|
11712
|
+
* choices first, unlabelled; else, before the caller has said anything, the
|
|
11713
|
+
* tenant's starters under a "Try saying" label. Nothing fits ⇒ nothing drawn.
|
|
11714
|
+
*/
|
|
11715
|
+
function contextualSuggestions(turns, starters, choices) {
|
|
11716
|
+
if (choices?.length) return {
|
|
11717
|
+
lines: choices,
|
|
11718
|
+
opening: false
|
|
11719
|
+
};
|
|
11720
|
+
const opening = !turns.some((turn) => turn.speaker === "caller" && !turn.shared);
|
|
11721
|
+
return {
|
|
11722
|
+
lines: opening ? starters : [],
|
|
11723
|
+
opening
|
|
11724
|
+
};
|
|
11725
|
+
}
|
|
11726
|
+
/** The mark's state on a call: the room's own states, which `BotState` cannot say. */
|
|
11727
|
+
function callMarkState(state, bot, ended, muted) {
|
|
11728
|
+
if (ended) return "idle";
|
|
11729
|
+
if (state === "connecting" || state === "reconnecting") return "connecting";
|
|
11730
|
+
if (muted && bot !== "speaking") return "muted";
|
|
11731
|
+
return bot;
|
|
11732
|
+
}
|
|
11733
|
+
/**
|
|
11734
|
+
* The widget generation's call, after the Design-canvas prototype: a header
|
|
11735
|
+
* with the agent's name and the timer, the mark large in the middle (its
|
|
11736
|
+
* motion is the state), the call's own turns with each speaker named and the
|
|
11737
|
+
* caller in their own bubble, the pending turn in the stream ("Thinking…",
|
|
11738
|
+
* "Listening…"), an open capture card, the suggestions that fit, and the
|
|
11739
|
+
* labelled controls; then the summary once it ends. Styled by
|
|
11740
|
+
* `styles/call-view.css` (`.wgc`). See docs/CONCIERGE_GENERATIONS.md "Call mode".
|
|
11668
11741
|
*/
|
|
11669
|
-
function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, onSay, checkout = false, cart, messages, locale, voice, name, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
|
|
11742
|
+
function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, choices, extras, onSay, checkout = false, cart, messages, locale, voice, name, title, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
|
|
11670
11743
|
const t = (key) => callText(messages, key);
|
|
11671
11744
|
const ended = !record.active;
|
|
11672
11745
|
const { word, explain } = callStatus(state, {
|
|
@@ -11675,6 +11748,8 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11675
11748
|
});
|
|
11676
11749
|
const [said, setSaid] = useState([]);
|
|
11677
11750
|
const shown = turns.slice(record.from).filter((turn, i, all) => turn.speaker === "event" ? false : turn.filler ? i === all.length - 1 : turn.text.trim() !== "" || (turn.cards?.items.length ?? 0) > 0);
|
|
11751
|
+
const last = shown[shown.length - 1];
|
|
11752
|
+
const pending = ended ? null : state === "thinking" && !(last?.speaker === "agent" && last.final === false) ? "agent" : callerSpeaking && !(last?.speaker === "caller" && last.final === false) ? "caller" : null;
|
|
11678
11753
|
const streamRef = useRef(null);
|
|
11679
11754
|
const contentRef = useRef(null);
|
|
11680
11755
|
const rootRef = useRef(null);
|
|
@@ -11683,20 +11758,37 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11683
11758
|
const active = (root?.getRootNode())?.activeElement;
|
|
11684
11759
|
if (root && (!active || active === document.body)) (root.querySelector("button.wgc-mk,[data-end]") ?? root.querySelector(".wgc-ctl button,.wgc-sum button"))?.focus();
|
|
11685
11760
|
}, []);
|
|
11686
|
-
useFollowBottom(streamRef, contentRef, shown.length, void 0, true);
|
|
11761
|
+
useFollowBottom(streamRef, contentRef, shown.length + (pending ? 1 : 0) + (extras ? 1 : 0), void 0, true);
|
|
11687
11762
|
const interrupting = voice.agentSpeaking === true && voice.onInterrupt !== void 0;
|
|
11688
11763
|
const fixable = voice.phase === "blocked" && voice.onFixPermission !== void 0;
|
|
11689
|
-
const lines
|
|
11764
|
+
const { lines: offered, opening } = contextualSuggestions(turns.slice(record.from), suggestions, choices);
|
|
11765
|
+
const lines = !ended && onSay && (state === "muted" || state === "listening" && !callerSpeaking) ? offered.filter((line) => !said.includes(line)) : [];
|
|
11690
11766
|
const say = useScrollRow(t("call_say_prev"), t("call_say_next"), lines.length);
|
|
11691
11767
|
const added = ended ? addedDuringCall(record.cart, cart ?? []) : [];
|
|
11768
|
+
const muted = voice.muted === true && !ended;
|
|
11769
|
+
const big = shown.length === 0 && !extras;
|
|
11770
|
+
const agentName = name ?? title ?? t("call_agent");
|
|
11692
11771
|
const mark = /* @__PURE__ */ jsx(AvatarFace, {
|
|
11693
11772
|
avatar,
|
|
11694
11773
|
state: ended ? "idle" : bot,
|
|
11695
|
-
size: "sm",
|
|
11696
|
-
markSize:
|
|
11697
|
-
|
|
11774
|
+
size: big ? "lg" : "sm",
|
|
11775
|
+
markSize: big ? 112 : 64,
|
|
11776
|
+
markState: callMarkState(state, bot, ended, muted),
|
|
11777
|
+
muted,
|
|
11698
11778
|
...name !== void 0 ? { name } : {}
|
|
11699
11779
|
});
|
|
11780
|
+
const who = (speaker, operator) => /* @__PURE__ */ jsx("span", {
|
|
11781
|
+
className: "wgc-who",
|
|
11782
|
+
dir: "auto",
|
|
11783
|
+
children: speaker === "caller" ? t("call_you") : operator ?? agentName
|
|
11784
|
+
});
|
|
11785
|
+
const control = (button, short) => /* @__PURE__ */ jsxs("div", {
|
|
11786
|
+
className: "wgc-cw",
|
|
11787
|
+
children: [button, /* @__PURE__ */ jsx("span", {
|
|
11788
|
+
"aria-hidden": true,
|
|
11789
|
+
children: short
|
|
11790
|
+
})]
|
|
11791
|
+
});
|
|
11700
11792
|
return /* @__PURE__ */ jsxs("div", {
|
|
11701
11793
|
ref: rootRef,
|
|
11702
11794
|
"data-testid": "widget-call-view",
|
|
@@ -11706,27 +11798,16 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11706
11798
|
/* @__PURE__ */ jsxs("div", {
|
|
11707
11799
|
className: "wgc-hd",
|
|
11708
11800
|
children: [
|
|
11709
|
-
interrupting ? /* @__PURE__ */ jsx("button", {
|
|
11710
|
-
type: "button",
|
|
11711
|
-
"data-testid": "widget-interrupt",
|
|
11712
|
-
"aria-label": voice.labels.interrupt ?? defaultWidgetMessages.dock_interrupt,
|
|
11713
|
-
onClick: () => voice.onInterrupt?.("tap"),
|
|
11714
|
-
className: "wgc-mk",
|
|
11715
|
-
children: mark
|
|
11716
|
-
}) : /* @__PURE__ */ jsx("span", {
|
|
11717
|
-
className: "wgc-mk",
|
|
11718
|
-
children: mark
|
|
11719
|
-
}),
|
|
11720
11801
|
/* @__PURE__ */ jsx("p", {
|
|
11721
|
-
|
|
11722
|
-
|
|
11723
|
-
children:
|
|
11802
|
+
className: "wgc-nm",
|
|
11803
|
+
dir: "auto",
|
|
11804
|
+
children: title ?? agentName
|
|
11724
11805
|
}),
|
|
11725
11806
|
/* @__PURE__ */ jsx("span", {
|
|
11726
11807
|
role: "status",
|
|
11727
11808
|
"data-testid": "widget-call-announce",
|
|
11728
11809
|
className: "sr-only",
|
|
11729
|
-
children:
|
|
11810
|
+
children: ended || explain && state !== "ducked" && !hint ? t(word) : null
|
|
11730
11811
|
}),
|
|
11731
11812
|
/* @__PURE__ */ jsx(CallTimer, {
|
|
11732
11813
|
record,
|
|
@@ -11735,9 +11816,25 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11735
11816
|
actions
|
|
11736
11817
|
]
|
|
11737
11818
|
}),
|
|
11738
|
-
|
|
11819
|
+
/* @__PURE__ */ jsx("div", {
|
|
11820
|
+
className: "wgc-hero",
|
|
11821
|
+
"data-big": big ? "" : void 0,
|
|
11822
|
+
children: interrupting ? /* @__PURE__ */ jsx("button", {
|
|
11823
|
+
type: "button",
|
|
11824
|
+
"data-testid": "widget-interrupt",
|
|
11825
|
+
"aria-label": voice.labels.interrupt ?? defaultWidgetMessages.dock_interrupt,
|
|
11826
|
+
onClick: () => voice.onInterrupt?.("tap"),
|
|
11827
|
+
className: "wgc-mk",
|
|
11828
|
+
children: mark
|
|
11829
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
11830
|
+
className: "wgc-mk",
|
|
11831
|
+
children: mark
|
|
11832
|
+
})
|
|
11833
|
+
}),
|
|
11834
|
+
explain && !ended || fixable ? /* @__PURE__ */ jsxs("div", {
|
|
11739
11835
|
className: "wgc-hint",
|
|
11740
|
-
|
|
11836
|
+
"data-testid": "widget-voice-state",
|
|
11837
|
+
children: [explain && !ended ? hint ?? /* @__PURE__ */ jsx("span", { children: t(word) }) : null, fixable ? /* @__PURE__ */ jsx("button", {
|
|
11741
11838
|
type: "button",
|
|
11742
11839
|
"data-testid": "widget-fix-permission",
|
|
11743
11840
|
onClick: voice.onFixPermission,
|
|
@@ -11747,41 +11844,62 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11747
11844
|
}) : null,
|
|
11748
11845
|
/* @__PURE__ */ jsx("div", {
|
|
11749
11846
|
ref: streamRef,
|
|
11750
|
-
role: "
|
|
11847
|
+
role: "region",
|
|
11751
11848
|
tabIndex: 0,
|
|
11752
11849
|
"aria-label": messages.conversation,
|
|
11753
11850
|
className: "wgc-log no-scrollbar",
|
|
11754
|
-
children: /* @__PURE__ */
|
|
11851
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
11755
11852
|
ref: contentRef,
|
|
11756
|
-
children:
|
|
11757
|
-
|
|
11758
|
-
|
|
11853
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
11854
|
+
role: "log",
|
|
11855
|
+
children: [shown.map((turn, i) => {
|
|
11856
|
+
const you = turn.speaker === "caller";
|
|
11857
|
+
const prev = shown[i - 1];
|
|
11858
|
+
const opens = prev === void 0 || prev.speaker !== turn.speaker || prev.operatorName !== turn.operatorName;
|
|
11859
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11860
|
+
className: "wgc-t",
|
|
11861
|
+
"data-you": you ? "" : void 0,
|
|
11862
|
+
children: [
|
|
11863
|
+
opens ? who(you ? "caller" : "agent", turn.operatorName) : null,
|
|
11864
|
+
turn.text.trim() !== "" ? /* @__PURE__ */ jsxs("p", {
|
|
11865
|
+
dir: textDirectionFor(turn.locale),
|
|
11866
|
+
lang: turn.locale,
|
|
11867
|
+
"data-testid": you ? "widget-turn-caller" : "widget-turn-agent",
|
|
11868
|
+
"data-cut": turn.cut || turn.filler ? "" : void 0,
|
|
11869
|
+
"data-cur": i === shown.length - 1 && !ended && !pending ? "" : void 0,
|
|
11870
|
+
"data-partial": turn.final === false ? "" : void 0,
|
|
11871
|
+
"aria-hidden": turn.final === false ? true : void 0,
|
|
11872
|
+
className: "wgc-tx",
|
|
11873
|
+
children: [stripBidiControls(turn.text), turn.cut ? /* @__PURE__ */ jsx("span", {
|
|
11874
|
+
className: "wgc-cut",
|
|
11875
|
+
children: t("call_interrupted")
|
|
11876
|
+
}) : null]
|
|
11877
|
+
}) : null,
|
|
11878
|
+
!you && turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
11879
|
+
className: "wgc-cards",
|
|
11880
|
+
children: renderCards(turn.cards)
|
|
11881
|
+
}) : null
|
|
11882
|
+
]
|
|
11883
|
+
}, i);
|
|
11884
|
+
}), pending ? /* @__PURE__ */ jsxs("div", {
|
|
11885
|
+
"aria-hidden": true,
|
|
11886
|
+
"data-testid": "widget-call-pending",
|
|
11759
11887
|
className: "wgc-t",
|
|
11760
|
-
"data-you":
|
|
11761
|
-
children: [
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11765
|
-
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11770
|
-
children: [stripBidiControls(turn.text), turn.cut ? /* @__PURE__ */ jsx("span", {
|
|
11771
|
-
className: "wgc-cut",
|
|
11772
|
-
children: t("call_interrupted")
|
|
11773
|
-
}) : null]
|
|
11774
|
-
}) : null, !you && turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
11775
|
-
className: "wgc-cards",
|
|
11776
|
-
children: renderCards(turn.cards)
|
|
11777
|
-
}) : null]
|
|
11778
|
-
}, i);
|
|
11779
|
-
})
|
|
11888
|
+
"data-you": pending === "caller" ? "" : void 0,
|
|
11889
|
+
children: [last?.speaker === pending ? null : who(pending), /* @__PURE__ */ jsx("p", {
|
|
11890
|
+
className: "wgc-tx wgc-pend",
|
|
11891
|
+
children: t(pending === "agent" ? "call_thinking" : "call_listening")
|
|
11892
|
+
})]
|
|
11893
|
+
}) : null]
|
|
11894
|
+
}), extras ? /* @__PURE__ */ jsx("div", {
|
|
11895
|
+
className: "wgc-x",
|
|
11896
|
+
children: extras
|
|
11897
|
+
}) : null]
|
|
11780
11898
|
})
|
|
11781
11899
|
}),
|
|
11782
11900
|
lines.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
11783
11901
|
className: "wgc-say",
|
|
11784
|
-
children: [/* @__PURE__ */ jsx("p", { children: t("call_try_saying") }), /* @__PURE__ */ jsxs("div", {
|
|
11902
|
+
children: [opening ? /* @__PURE__ */ jsx("p", { children: t("call_try_saying") }) : null, /* @__PURE__ */ jsxs("div", {
|
|
11785
11903
|
className: "wsr",
|
|
11786
11904
|
children: [/* @__PURE__ */ jsx("ul", {
|
|
11787
11905
|
"data-testid": "widget-suggestions",
|
|
@@ -11805,6 +11923,10 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11805
11923
|
"data-testid": "widget-call-summary",
|
|
11806
11924
|
className: "wgc-sum",
|
|
11807
11925
|
children: [
|
|
11926
|
+
/* @__PURE__ */ jsx("p", {
|
|
11927
|
+
"data-testid": "widget-call-ended",
|
|
11928
|
+
children: t(word)
|
|
11929
|
+
}),
|
|
11808
11930
|
added.length > 0 ? /* @__PURE__ */ jsx("p", { children: formatMessage(t("call_summary_added"), { items: added.join(", ") }) }) : null,
|
|
11809
11931
|
checkout ? /* @__PURE__ */ jsx("p", { children: t("call_summary_checkout") }) : null,
|
|
11810
11932
|
/* @__PURE__ */ jsx("button", {
|
|
@@ -11817,19 +11939,19 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11817
11939
|
}) : /* @__PURE__ */ jsxs("div", {
|
|
11818
11940
|
className: "wgc-ctl",
|
|
11819
11941
|
children: [
|
|
11820
|
-
/* @__PURE__ */ jsx(MicButton, {
|
|
11942
|
+
control(/* @__PURE__ */ jsx(MicButton, {
|
|
11821
11943
|
voice,
|
|
11822
11944
|
testId: testIds?.mic
|
|
11823
|
-
}),
|
|
11824
|
-
voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11945
|
+
}), t("call_mute_short")),
|
|
11946
|
+
voice.onEnd !== void 0 ? control(/* @__PURE__ */ jsx("button", {
|
|
11825
11947
|
type: "button",
|
|
11826
11948
|
"data-testid": testIds?.endCall,
|
|
11827
11949
|
"data-end": "",
|
|
11828
11950
|
onClick: voice.onEnd,
|
|
11829
11951
|
"aria-label": voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
11830
11952
|
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
11831
|
-
}) : null,
|
|
11832
|
-
/* @__PURE__ */ jsx("button", {
|
|
11953
|
+
}), t("call_end_short")) : null,
|
|
11954
|
+
control(/* @__PURE__ */ jsx("button", {
|
|
11833
11955
|
type: "button",
|
|
11834
11956
|
"data-testid": "widget-call-to-text",
|
|
11835
11957
|
onClick: onText,
|
|
@@ -11844,7 +11966,7 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11844
11966
|
"aria-hidden": true,
|
|
11845
11967
|
children: /* @__PURE__ */ jsx("path", { d: "M4 20l1.3-4A8 8 0 1 1 8 19z" })
|
|
11846
11968
|
})
|
|
11847
|
-
})
|
|
11969
|
+
}), t("call_to_text"))
|
|
11848
11970
|
]
|
|
11849
11971
|
})
|
|
11850
11972
|
]
|
|
@@ -11852,28 +11974,7 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11852
11974
|
}
|
|
11853
11975
|
//#endregion
|
|
11854
11976
|
//#region src/widget/concierge-shell.tsx
|
|
11855
|
-
|
|
11856
|
-
* Maps the call onto the pill it shows, reusing fields `ConciergeShellVoice`
|
|
11857
|
-
* already carries rather than inventing new plumbing:
|
|
11858
|
-
*
|
|
11859
|
-
* - `'connecting'` → `connecting`
|
|
11860
|
-
* - `'waiting'` (the agent is thinking, between the caller's turn ending and
|
|
11861
|
-
* the reply starting) → `thinking`
|
|
11862
|
-
* - `'live'` + `agentSpeaking` → `speaking`
|
|
11863
|
-
* - `'live'` otherwise → `listening`
|
|
11864
|
-
* - `'idle'` / `'blocked'` → `null`, no pill
|
|
11865
|
-
*
|
|
11866
|
-
* `agentSpeaking` is already a real field on {@link ConciergeShellVoice} —
|
|
11867
|
-
* this function only reads it, it does not require every caller to start
|
|
11868
|
-
* setting it; a caller that never populates it simply never reaches
|
|
11869
|
-
* `'speaking'`, which is exactly the same "renders sensibly with what it is
|
|
11870
|
-
* given" contract every other optional field on this interface follows.
|
|
11871
|
-
*/
|
|
11872
|
-
function voiceStatePillState(voice) {
|
|
11873
|
-
const phase = voice?.phase;
|
|
11874
|
-
return phase === "connecting" ? "connecting" : phase === "waiting" ? "thinking" : phase === "live" ? voice?.agentSpeaking ? "speaking" : "listening" : null;
|
|
11875
|
-
}
|
|
11876
|
-
function ConciergeShell({ open, onOpenChange, state, messageArrived = false, launcher, launcherInitials, launcherVariant, agentName, typing = false, operatorName, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, call, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution, privacyChoices, focusOnOpen = true }) {
|
|
11977
|
+
function ConciergeShell({ open, onOpenChange, state, messageArrived = false, launcher, launcherInitials, launcherVariant, agentName, typing = false, operatorName, avatar = "orb", labels, children, badge, draft, onDraftChange, onSubmit, composerDisabled = false, voice, callIcon, call, announcement, skin, skinStyle, idPrefix = "concierge", scrollKey, composerLeading, testIds, position = DEFAULT_CONCIERGE_POSITION, onPositionChange, attribution, privacyChoices, focusOnOpen = true }) {
|
|
11877
11978
|
const triggerId = `${idPrefix}-trigger`;
|
|
11878
11979
|
const inputId = `${idPrefix}-input`;
|
|
11879
11980
|
const panelRef = useRef(null);
|
|
@@ -11948,8 +12049,6 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11948
12049
|
]);
|
|
11949
12050
|
/** A call is running — anything but `idle`, including the phases not speakable yet. */
|
|
11950
12051
|
const inCall = voice !== void 0 && voice.phase !== "idle";
|
|
11951
|
-
/** `null` for `idle` and `blocked` — see `voiceStatePillState`. */
|
|
11952
|
-
const voicePillState = voiceStatePillState(voice);
|
|
11953
12052
|
/** No voice leg to press at all, or a microphone the browser refused. */
|
|
11954
12053
|
const micUnusable = voice !== void 0 && (voice.disabled === true || voice.phase === "blocked");
|
|
11955
12054
|
const showEnd = inCall && voice.onEnd !== void 0;
|
|
@@ -12013,6 +12112,7 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12013
12112
|
...call,
|
|
12014
12113
|
voice,
|
|
12015
12114
|
...agentName !== void 0 ? { name: agentName } : {},
|
|
12115
|
+
title: labels.title ?? labels.dialog,
|
|
12016
12116
|
checkout: callMode.record.checkout,
|
|
12017
12117
|
actions: closeButton,
|
|
12018
12118
|
record: callMode.record,
|
|
@@ -12055,35 +12155,30 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12055
12155
|
children: labels.title ?? labels.dialog
|
|
12056
12156
|
}), /* @__PURE__ */ jsxs("div", {
|
|
12057
12157
|
className: "wgp-sub",
|
|
12058
|
-
children: [
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
"aria-hidden": true,
|
|
12064
|
-
"data-live": voicePillState === "speaking" || voicePillState === "listening" ? "" : void 0,
|
|
12065
|
-
className: cn(voicePillState !== "listening" && "animate-pulse motion-reduce:animate-none")
|
|
12066
|
-
}), /* @__PURE__ */ jsx("span", { children: voice?.labels[voicePillState] ?? defaultWidgetMessages[`voice_state_${voicePillState}`] })] }) : null
|
|
12067
|
-
}),
|
|
12068
|
-
operatorName === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
12069
|
-
"data-testid": "widget-operator-name",
|
|
12070
|
-
dir: "auto",
|
|
12071
|
-
children: operatorName
|
|
12072
|
-
}),
|
|
12073
|
-
badge
|
|
12074
|
-
]
|
|
12158
|
+
children: [operatorName === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
12159
|
+
"data-testid": "widget-operator-name",
|
|
12160
|
+
dir: "auto",
|
|
12161
|
+
children: operatorName
|
|
12162
|
+
}), badge]
|
|
12075
12163
|
})]
|
|
12076
12164
|
}),
|
|
12077
12165
|
/* @__PURE__ */ jsxs("div", {
|
|
12078
12166
|
className: "wgp-act",
|
|
12079
|
-
children: [
|
|
12167
|
+
children: [inCall && call ? /* @__PURE__ */ jsx(CallTimer, {
|
|
12168
|
+
record: callMode.record,
|
|
12169
|
+
locale: call.locale
|
|
12170
|
+
}) : voice && !inCall ? /* @__PURE__ */ jsx("button", {
|
|
12080
12171
|
type: "button",
|
|
12081
12172
|
className: "wgp-ib",
|
|
12082
12173
|
"data-testid": "widget-voice-cta",
|
|
12083
|
-
"aria-label": voice.labels.start,
|
|
12084
|
-
title: voice.labels.start,
|
|
12174
|
+
"aria-label": micUnusable ? voice.labels.unavailable ?? voice.labels.start : voice.labels.start,
|
|
12175
|
+
title: micUnusable ? voice.labels.unavailable ?? voice.labels.start : voice.labels.start,
|
|
12176
|
+
disabled: micUnusable,
|
|
12085
12177
|
onClick: voice.onStart,
|
|
12086
|
-
children: /* @__PURE__ */ jsx(
|
|
12178
|
+
children: callIcon ? /* @__PURE__ */ jsx("span", {
|
|
12179
|
+
"aria-hidden": true,
|
|
12180
|
+
children: callIcon
|
|
12181
|
+
}) : /* @__PURE__ */ jsx(AudioLines, {})
|
|
12087
12182
|
}) : null, closeButton]
|
|
12088
12183
|
})
|
|
12089
12184
|
]
|
|
@@ -12104,7 +12199,7 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12104
12199
|
className: "wgp-typing",
|
|
12105
12200
|
children: [/* @__PURE__ */ jsx("span", {
|
|
12106
12201
|
className: "sr-only",
|
|
12107
|
-
children: defaultWidgetMessages.typing
|
|
12202
|
+
children: labels.typing ?? defaultWidgetMessages.typing
|
|
12108
12203
|
}), [
|
|
12109
12204
|
0,
|
|
12110
12205
|
1,
|
|
@@ -12124,7 +12219,7 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12124
12219
|
className: "wgp-cz",
|
|
12125
12220
|
onSubmit: submit,
|
|
12126
12221
|
children: [
|
|
12127
|
-
showEnd || interrupting || fixable ||
|
|
12222
|
+
showEnd || interrupting || fixable || inCall ? /* @__PURE__ */ jsxs("div", {
|
|
12128
12223
|
className: "wgp-call",
|
|
12129
12224
|
children: [
|
|
12130
12225
|
fixable ? /* @__PURE__ */ jsx("button", {
|
|
@@ -12155,6 +12250,11 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12155
12250
|
})
|
|
12156
12251
|
})
|
|
12157
12252
|
}) : null,
|
|
12253
|
+
inCall && voice ? /* @__PURE__ */ jsx(MicButton, {
|
|
12254
|
+
voice,
|
|
12255
|
+
testId: testIds?.mic,
|
|
12256
|
+
className: "wgp-ib"
|
|
12257
|
+
}) : null,
|
|
12158
12258
|
call !== void 0 && inCall ? /* @__PURE__ */ jsx("button", {
|
|
12159
12259
|
type: "button",
|
|
12160
12260
|
onClick: callMode.backToCall,
|
|
@@ -12206,19 +12306,15 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12206
12306
|
autoComplete: "off",
|
|
12207
12307
|
className: cn("wgp-in", inCall && draft === "" && "opacity-60 focus:opacity-100")
|
|
12208
12308
|
}),
|
|
12209
|
-
|
|
12210
|
-
voice,
|
|
12211
|
-
testId: testIds?.mic,
|
|
12212
|
-
className: "wgp-ib"
|
|
12213
|
-
}) : null,
|
|
12214
|
-
draft.trim() ? /* @__PURE__ */ jsx("button", {
|
|
12309
|
+
/* @__PURE__ */ jsx("button", {
|
|
12215
12310
|
type: "submit",
|
|
12216
12311
|
"aria-label": labels.send,
|
|
12312
|
+
title: labels.send,
|
|
12217
12313
|
"data-testid": testIds?.send,
|
|
12218
|
-
disabled: composerDisabled,
|
|
12314
|
+
disabled: composerDisabled || draft.trim() === "",
|
|
12219
12315
|
className: "wgp-ib wgp-send",
|
|
12220
12316
|
children: /* @__PURE__ */ jsx(Send, { className: "rtl:-scale-x-100" })
|
|
12221
|
-
})
|
|
12317
|
+
})
|
|
12222
12318
|
]
|
|
12223
12319
|
}),
|
|
12224
12320
|
attribution || privacyChoices ? /* @__PURE__ */ jsxs("p", {
|
|
@@ -12537,7 +12633,7 @@ function positionFor(dock) {
|
|
|
12537
12633
|
const align = dock?.layout?.desktopAlign;
|
|
12538
12634
|
return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
|
|
12539
12635
|
}
|
|
12540
|
-
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, renderCards, suggestions, call: callHooks, cart, dock, locale }) {
|
|
12636
|
+
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, renderCards, suggestions, call: callHooks, cart, capturing, showBasket, captureChoices, dock, locale }) {
|
|
12541
12637
|
const [restored] = useState(readOpen);
|
|
12542
12638
|
const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
|
|
12543
12639
|
const onShown = dock?.onShown;
|
|
@@ -12666,9 +12762,9 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
12666
12762
|
...voiceInput.onFixPermission !== void 0 ? { onFixPermission: voiceInput.onFixPermission } : {},
|
|
12667
12763
|
...voiceUnavailable !== void 0 ? { disabled: true } : {},
|
|
12668
12764
|
labels: {
|
|
12669
|
-
start: messages
|
|
12765
|
+
start: callText(messages, "call_start"),
|
|
12670
12766
|
end: messages.call_end,
|
|
12671
|
-
mute: messages
|
|
12767
|
+
mute: callText(messages, "call_mute_short"),
|
|
12672
12768
|
unmute: messages.mic_start,
|
|
12673
12769
|
connecting: messages.voice_state_connecting,
|
|
12674
12770
|
...messages.dock_fix_browser !== void 0 ? { fixBrowser: messages.dock_fix_browser } : {},
|
|
@@ -12735,6 +12831,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
12735
12831
|
...agentName ? { title: agentName } : {},
|
|
12736
12832
|
composerPlaceholder: messages.type_placeholder,
|
|
12737
12833
|
send: messages.send,
|
|
12834
|
+
typing: messages.typing,
|
|
12738
12835
|
move: messages.move,
|
|
12739
12836
|
...launcherLabel ? { launcher: launcherLabel } : {}
|
|
12740
12837
|
},
|
|
@@ -12745,6 +12842,8 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
12745
12842
|
turns,
|
|
12746
12843
|
renderCards,
|
|
12747
12844
|
suggestions,
|
|
12845
|
+
choices: captureChoices,
|
|
12846
|
+
...capturing || attaching !== null || showBasket && (cart?.lines.length ?? 0) > 0 ? { extras } : {},
|
|
12748
12847
|
...callHooks?.sendText !== void 0 ? { onSay: callHooks.sendText } : {},
|
|
12749
12848
|
...checkout !== void 0 ? { checkout } : {},
|
|
12750
12849
|
...cart !== void 0 ? { cart: cart.lines } : {},
|
|
@@ -13574,7 +13673,7 @@ function readsAsCartViewIntent(text) {
|
|
|
13574
13673
|
* can pass it without conversion.
|
|
13575
13674
|
*/
|
|
13576
13675
|
function basketIntentFromTurns(turns) {
|
|
13577
|
-
const lastCallerLine = [...turns].reverse().find((turn) => turn.speaker === "caller");
|
|
13676
|
+
const lastCallerLine = [...turns].reverse().find((turn) => turn.speaker === "caller" && !turn.shared);
|
|
13578
13677
|
if (lastCallerLine === void 0) return false;
|
|
13579
13678
|
return readsAsCheckoutIntent(lastCallerLine.text) || readsAsCartViewIntent(lastCallerLine.text);
|
|
13580
13679
|
}
|
|
@@ -13619,7 +13718,7 @@ function VoiceWidget({ renderer, generation, ...props }) {
|
|
|
13619
13718
|
});
|
|
13620
13719
|
}
|
|
13621
13720
|
/** `VoiceWidget` with the renderer decided — the component the CDN entries and `ConciergeHost` use. */
|
|
13622
|
-
function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCall, callPhase = "idle", onSendText, micOpen, status, statusKind, notice, mode = "voice", escalated = false, humanTyping = false, onTyping, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, onAttachFile, cart, captureCard, messages = defaultWidgetMessages, suggestions, navigate, locale = "en", skinStyle, avatar, attribution, privacyChoices, call, dock }) {
|
|
13721
|
+
function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCall, callPhase = "idle", onSendText, micOpen, status, statusKind, notice, mode = "voice", escalated = false, humanTyping = false, onTyping, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, onAttachFile, cart, captureCard, captureChoices, messages = defaultWidgetMessages, suggestions, navigate, locale = "en", skinStyle, avatar, attribution, privacyChoices, call, dock }) {
|
|
13623
13722
|
const [draft, setDraft] = useState("");
|
|
13624
13723
|
const [sending, setSending] = useState(false);
|
|
13625
13724
|
/** Roomy mode — see the expand control in the header. Collapses back on close, so a reopened widget starts small. */
|
|
@@ -13940,6 +14039,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13940
14039
|
cart,
|
|
13941
14040
|
attaching,
|
|
13942
14041
|
capturing: captureCard != null,
|
|
14042
|
+
captureChoices,
|
|
13943
14043
|
onAttach,
|
|
13944
14044
|
attachInput,
|
|
13945
14045
|
transcript: renderLog(turns),
|
|
@@ -15485,10 +15585,16 @@ function useChatSession(options) {
|
|
|
15485
15585
|
clearDeskTyping();
|
|
15486
15586
|
}, [clearDeskTyping]);
|
|
15487
15587
|
/** See {@link UseChatSessionResult.markCaptureAnswered}. */
|
|
15488
|
-
const markCaptureAnswered = useCallback((outcome) => {
|
|
15588
|
+
const markCaptureAnswered = useCallback((outcome, shown) => {
|
|
15489
15589
|
if (!mountedRef.current) return;
|
|
15490
15590
|
const id = `event-capture-${captureEventCountRef.current += 1}`;
|
|
15491
|
-
setTurns((prev) => [...prev, {
|
|
15591
|
+
setTurns((prev) => [...prev, outcome === "saved" && shown ? {
|
|
15592
|
+
id,
|
|
15593
|
+
speaker: "caller",
|
|
15594
|
+
text: shown,
|
|
15595
|
+
final: true,
|
|
15596
|
+
shared: true
|
|
15597
|
+
} : {
|
|
15492
15598
|
id,
|
|
15493
15599
|
speaker: "event",
|
|
15494
15600
|
event: outcome === "saved" ? "capture_saved" : "capture_declined",
|
|
@@ -19690,6 +19796,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19690
19796
|
}
|
|
19691
19797
|
if (event.type === "capture-card") {
|
|
19692
19798
|
if (open?.card.field === event.field && !closedCapturesRef.current.has(open)) return;
|
|
19799
|
+
let shown;
|
|
19693
19800
|
const options = {
|
|
19694
19801
|
card: event,
|
|
19695
19802
|
locale,
|
|
@@ -19697,11 +19804,12 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19697
19804
|
submit: async (answer) => {
|
|
19698
19805
|
const status = await session.submitCapture(answer);
|
|
19699
19806
|
if (status === 404) closedCapturesRef.current.add(options);
|
|
19807
|
+
if ("value" in answer) shown = `${event.label} · ${answer.value}`;
|
|
19700
19808
|
return status;
|
|
19701
19809
|
},
|
|
19702
19810
|
onAnswered: (outcome) => {
|
|
19703
19811
|
showCaptureCard(null);
|
|
19704
|
-
session.markCaptureAnswered(outcome);
|
|
19812
|
+
session.markCaptureAnswered(outcome, shown);
|
|
19705
19813
|
if (!inCallRef.current) session.sendReport({
|
|
19706
19814
|
kind: "capture_card",
|
|
19707
19815
|
field: event.field,
|
|
@@ -20070,7 +20178,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20070
20178
|
voice.toggleMic();
|
|
20071
20179
|
return;
|
|
20072
20180
|
}
|
|
20073
|
-
voice.start({ greet: !session.turns.some((t) => t.speaker === "caller") });
|
|
20181
|
+
voice.start({ greet: !session.turns.some((t) => t.speaker === "caller" && !t.shared) });
|
|
20074
20182
|
}, [
|
|
20075
20183
|
voiceEnabled,
|
|
20076
20184
|
escalated,
|
|
@@ -20248,6 +20356,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20248
20356
|
final: turn.final,
|
|
20249
20357
|
...turn.event ? { event: turn.event } : {},
|
|
20250
20358
|
...turn.delivery ? { delivery: turn.delivery } : {},
|
|
20359
|
+
...turn.shared ? { shared: turn.shared } : {},
|
|
20251
20360
|
...turn.cards ? { cards: turn.cards } : {},
|
|
20252
20361
|
...turn.attachments ? { attachments: turn.attachments } : {},
|
|
20253
20362
|
...turn.operatorName ? { operatorName: turn.operatorName } : {}
|
|
@@ -20857,7 +20966,10 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20857
20966
|
...attribution !== void 0 ? { attribution } : {},
|
|
20858
20967
|
...privacyChoices !== void 0 ? { privacyChoices } : {},
|
|
20859
20968
|
dock: dockProps,
|
|
20860
|
-
...captureCard !== null ? {
|
|
20969
|
+
...captureCard !== null ? {
|
|
20970
|
+
captureCard: /* @__PURE__ */ jsx(CaptureCardHost, { options: captureCard }),
|
|
20971
|
+
captureChoices: captureCard.card.choices
|
|
20972
|
+
} : {}
|
|
20861
20973
|
});
|
|
20862
20974
|
}
|
|
20863
20975
|
//#endregion
|