@saar-ai/web-widget 0.26.0 → 0.26.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,9 +41,11 @@ export interface CaptureCardOptions {
41
41
  /** Asked for by a refused checkout: `'last'` is the final card before checkout opens. */
42
42
  readonly checkout?: 'more' | 'last';
43
43
  }
44
- type CopyKey = 'checkoutIntro' | 'checkoutReady' | 'phoneLocal' | 'send' | 'refuse' | 'choose' | 'saved' | 'declined' | 'invalid' | 'closed' | 'failed' | CaptureCardValueError;
44
+ type CopyKey = 'checkoutIntro' | 'checkoutReady' | 'phoneLocal' | 'dialCode' | 'send' | 'refuse' | 'choose' | 'saved' | 'declined' | 'invalid' | 'closed' | 'failed' | CaptureCardValueError;
45
45
  /** Lives here, not in `messages.ts`, so the copy ships in this chunk and not in `ui`. */
46
46
  export declare const CAPTURE_CARD_COPY: Readonly<Record<'en' | 'ar' | 'hi', Readonly<Record<CopyKey, string>>>>;
47
+ /** The national digits to append to `+code`: the trunk prefix dropped, where there is one. */
48
+ export declare function nationalDigits(code: string, digits: string): string;
47
49
  /**
48
50
  * Returns the teardown.
49
51
  * @param root an empty element the host owns
@@ -1 +1 @@
1
- {"version":3,"file":"capture-card-dom.d.ts","sourceRoot":"","sources":["../../src/capture-card/capture-card-dom.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAGL,KAAK,yBAAyB,EAC9B,KAAK,qBAAqB,EAC3B,MAAM,uCAAuC,CAAC;AAE/C,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,QAAQ,CAAC,SA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AG,MAAM,IAAI,CAiU3F"}
@@ -1,9 +1,4 @@
1
1
  //#region ../widget-protocol/dist/capture-card.js
2
- /**
3
- * Capture card rules shared by the server and the widget's lazy card chunk.
4
- * Must stay zod-free and import-free: the chunk may not pull zod. The check
5
- * here must never refuse a value the server accepts (pinned in `apps/api`).
6
- */
7
2
  /** The `type` of the widget event that carries a card. */
8
3
  var CAPTURE_CARD_EVENT_TYPE = "capture-card";
9
4
  /**
@@ -1,4 +1,11 @@
1
- import { l as captureCardOutcomeOf, u as checkCaptureCardValue } from "./capture-card-D7DqAq-N.js";
1
+ import { l as captureCardOutcomeOf, u as checkCaptureCardValue } from "./capture-card-DiTdcTCh.js";
2
+ //#region ../widget-protocol/dist/capture-card-dial-codes.js
3
+ /**
4
+ * Calling code, then its regions as consecutive two-letter codes, entries
5
+ * split by `;`. The first region of a code is the one people mean by it; the rest are alphabetical.
6
+ */
7
+ var DIAL_CODE_TABLE = "1:USAGAIASBBBMBSCADMDOGDGUJMKNKYLCMPMSPRSXTCTTVCVGVI;7:RUKZ;20:EG;27:ZA;30:GR;31:NL;32:BE;33:FR;34:ES;36:HU;39:ITVA;40:RO;41:CH;43:AT;44:GBGGIMJE;45:DK;46:SE;47:NOSJ;48:PL;49:DE;51:PE;52:MX;53:CU;54:AR;55:BR;56:CL;57:CO;58:VE;60:MY;61:AUCCCX;62:ID;63:PH;64:NZ;65:SG;66:TH;81:JP;82:KR;84:VN;86:CN;90:TR;91:IN;92:PK;93:AF;94:LK;95:MM;98:IR;211:SS;212:MAEH;213:DZ;216:TN;218:LY;220:GM;221:SN;222:MR;223:ML;224:GN;225:CI;226:BF;227:NE;228:TG;229:BJ;230:MU;231:LR;232:SL;233:GH;234:NG;235:TD;236:CF;237:CM;238:CV;239:ST;240:GQ;241:GA;242:CG;243:CD;244:AO;245:GW;246:IO;247:AC;248:SC;249:SD;250:RW;251:ET;252:SO;253:DJ;254:KE;255:TZ;256:UG;257:BI;258:MZ;260:ZM;261:MG;262:REYT;263:ZW;264:NA;265:MW;266:LS;267:BW;268:SZ;269:KM;290:SHTA;291:ER;297:AW;298:FO;299:GL;350:GI;351:PT;352:LU;353:IE;354:IS;355:AL;356:MT;357:CY;358:FIAX;359:BG;370:LT;371:LV;372:EE;373:MD;374:AM;375:BY;376:AD;377:MC;378:SM;380:UA;381:RS;382:ME;383:XK;385:HR;386:SI;387:BA;389:MK;420:CZ;421:SK;423:LI;500:FK;501:BZ;502:GT;503:SV;504:HN;505:NI;506:CR;507:PA;508:PM;509:HT;590:GPBLMF;591:BO;592:GY;593:EC;594:GF;595:PY;596:MQ;597:SR;598:UY;599:CWBQ;670:TL;672:NF;673:BN;674:NR;675:PG;676:TO;677:SB;678:VU;679:FJ;680:PW;681:WF;682:CK;683:NU;685:WS;686:KI;687:NC;688:TV;689:PF;690:TK;691:FM;692:MH;850:KP;852:HK;853:MO;855:KH;856:LA;880:BD;886:TW;960:MV;961:LB;962:JO;963:SY;964:IQ;965:KW;966:SA;967:YE;968:OM;970:PS;971:AE;972:IL;973:BH;974:QA;975:BT;976:MN;977:NP;992:TJ;993:TM;994:AZ;995:GE;996:KG;998:UZ";
8
+ //#endregion
2
9
  //#region src/capture-card/capture-card-dom.ts
3
10
  /**
4
11
  * The capture card, plain DOM, in its own lazy chunk (`capture-card.mjs`).
@@ -13,6 +20,7 @@ var CAPTURE_CARD_COPY = {
13
20
  checkoutIntro: "Needed before checkout.",
14
21
  checkoutReady: "Thanks — you can check out now.",
15
22
  phoneLocal: "Enter a phone number.",
23
+ dialCode: "Country code",
16
24
  send: "Send",
17
25
  refuse: "I’d rather not say",
18
26
  choose: "Choose one",
@@ -22,7 +30,7 @@ var CAPTURE_CARD_COPY = {
22
30
  length: "That is too long.",
23
31
  characters: "That contains characters that can’t be used.",
24
32
  email: "Enter an email address, like name@example.com.",
25
- phone: "Enter the number with its country code, starting with +.",
33
+ phone: "Choose the country code and enter the number.",
26
34
  choice: "Choose one of the options.",
27
35
  number: "Enter a number, like 12.",
28
36
  date: "Enter a date.",
@@ -36,6 +44,7 @@ var CAPTURE_CARD_COPY = {
36
44
  checkoutIntro: "مطلوب قبل إتمام الشراء.",
37
45
  checkoutReady: "شكرًا — يمكنك إتمام الشراء الآن.",
38
46
  phoneLocal: "يُرجى إدخال رقم هاتف.",
47
+ dialCode: "رمز الدولة",
39
48
  send: "إرسال",
40
49
  refuse: "أفضّل عدم الإجابة",
41
50
  choose: "يُرجى الاختيار",
@@ -45,7 +54,7 @@ var CAPTURE_CARD_COPY = {
45
54
  length: "النص طويل جدًا.",
46
55
  characters: "يحتوي على أحرف لا يمكن استخدامها.",
47
56
  email: "يُرجى إدخال بريد إلكتروني، مثل name@example.com.",
48
- phone: "يُرجى إدخال الرقم مع رمز الدولة، بدءًا بـ +.",
57
+ phone: "يُرجى اختيار رمز الدولة وإدخال الرقم.",
49
58
  choice: "يُرجى اختيار أحد الخيارات.",
50
59
  number: "يُرجى إدخال رقم، مثل 12.",
51
60
  date: "يُرجى إدخال تاريخ.",
@@ -59,6 +68,7 @@ var CAPTURE_CARD_COPY = {
59
68
  checkoutIntro: "चेकआउट से पहले ज़रूरी।",
60
69
  checkoutReady: "धन्यवाद — अब आप चेकआउट कर सकते हैं।",
61
70
  phoneLocal: "फ़ोन नंबर दर्ज करें।",
71
+ dialCode: "देश कोड",
62
72
  send: "भेजें",
63
73
  refuse: "मुझे नहीं बताना",
64
74
  choose: "एक चुनें",
@@ -68,7 +78,7 @@ var CAPTURE_CARD_COPY = {
68
78
  length: "यह बहुत लंबा है।",
69
79
  characters: "इसमें ऐसे अक्षर हैं जिनका उपयोग नहीं हो सकता।",
70
80
  email: "ईमेल पता दर्ज करें, जैसे name@example.com।",
71
- phone: "देश कोड के साथ नंबर दर्ज करें, जो + से शुरू हो।",
81
+ phone: "देश कोड चुनें और नंबर दर्ज करें।",
72
82
  choice: "विकल्पों में से एक चुनें।",
73
83
  number: "कोई संख्या दर्ज करें, जैसे 12।",
74
84
  date: "कोई तारीख दर्ज करें।",
@@ -134,6 +144,100 @@ function countryChoices(locale) {
134
144
  }
135
145
  return out.sort((x, y) => x[1].localeCompare(y[1], locale));
136
146
  }
147
+ var ASCII_ZERO_BLOCKS = [
148
+ 1632,
149
+ 1776,
150
+ 1984,
151
+ 2406,
152
+ 2534,
153
+ 2662,
154
+ 2790,
155
+ 2918,
156
+ 3046,
157
+ 3174,
158
+ 3302,
159
+ 3430,
160
+ 3664,
161
+ 3792,
162
+ 3872,
163
+ 4160,
164
+ 6112,
165
+ 6160,
166
+ 65296
167
+ ];
168
+ /** Digits of any script (`\p{Nd}`) as ASCII `0-9`; other characters are kept. */
169
+ function toAsciiDigits(value) {
170
+ return value.replace(/\p{Nd}/gu, (ch) => {
171
+ const cp = ch.codePointAt(0);
172
+ const zero = ASCII_ZERO_BLOCKS.find((z) => cp >= z && cp <= z + 9);
173
+ return zero === void 0 ? ch : String(cp - zero);
174
+ });
175
+ }
176
+ /** Calling codes whose national numbers keep their leading 0. */
177
+ var KEEPS_LEADING_ZERO = /* @__PURE__ */ new Set([
178
+ "39",
179
+ "378",
180
+ "379",
181
+ "225",
182
+ "229",
183
+ "241",
184
+ "242"
185
+ ]);
186
+ /** The national digits to append to `+code`: the trunk prefix dropped, where there is one. */
187
+ function nationalDigits(code, digits) {
188
+ if (KEEPS_LEADING_ZERO.has(code)) return digits;
189
+ if (code === "36" && digits.startsWith("06")) return digits.slice(2);
190
+ return digits.replace(/^0/, "");
191
+ }
192
+ /** Every region with a calling code, in the shopper's language, as `[region, code, label]`. */
193
+ function dialChoices(locale) {
194
+ let names = null;
195
+ try {
196
+ names = new Intl.DisplayNames([locale, "en"], {
197
+ type: "region",
198
+ fallback: "code"
199
+ });
200
+ } catch {}
201
+ const out = [];
202
+ for (const entry of DIAL_CODE_TABLE.split(";")) {
203
+ const [code = "", regions = ""] = entry.split(":");
204
+ for (let i = 0; i < regions.length; i += 2) {
205
+ const region = regions.slice(i, i + 2);
206
+ const flag = String.fromCodePoint(127397 + region.charCodeAt(0), 127397 + region.charCodeAt(1));
207
+ out.push([
208
+ region,
209
+ code,
210
+ `${flag} ${names?.of(region) ?? region} (+${code})`
211
+ ]);
212
+ }
213
+ }
214
+ return out.sort((x, y) => x[2].slice(5).localeCompare(y[2].slice(5), locale));
215
+ }
216
+ /** The region whose calling code starts `digits`: `prefer` if it shares the code, else the code's main one. */
217
+ function regionOfDigits(digits, prefer) {
218
+ const entries = DIAL_CODE_TABLE.split(";");
219
+ for (let n = 3; n > 0; n--) {
220
+ const entry = entries.find((e) => e.startsWith(`${digits.slice(0, n)}:`));
221
+ if (entry !== void 0) {
222
+ const regions = entry.slice(entry.indexOf(":") + 1);
223
+ return regions.match(/../g).includes(prefer) ? prefer : regions.slice(0, 2);
224
+ }
225
+ }
226
+ return "";
227
+ }
228
+ function styleField(field) {
229
+ Object.assign(field.style, {
230
+ width: field instanceof HTMLSelectElement ? "auto" : "100%",
231
+ minWidth: "0",
232
+ boxSizing: "border-box",
233
+ padding: "8px 10px",
234
+ borderRadius: "8px",
235
+ border: "1px solid var(--widget-foreground-muted)",
236
+ background: "transparent",
237
+ color: "inherit",
238
+ font: "inherit"
239
+ });
240
+ }
137
241
  var nextId = 0;
138
242
  /**
139
243
  * Returns the teardown.
@@ -199,6 +303,9 @@ function mountCaptureCard(root, options) {
199
303
  const choices = spec.input === "choice" && spec.choices && spec.choices.length > 0 ? spec.choices : null;
200
304
  const listed = choices !== null ? choices.map((choice) => [choice, choice]) : spec.input === "country" ? countryChoices(options.locale) : null;
201
305
  let field;
306
+ /** What the card sends for this detail: the phone's code and number joined. */
307
+ let read = () => field.value;
308
+ let holder = null;
202
309
  if (listed !== null) {
203
310
  const select = el("select");
204
311
  const placeholder = el("option", copy.choose);
@@ -221,20 +328,50 @@ function mountCaptureCard(root, options) {
221
328
  }
222
329
  if (spec.maxLength !== void 0) input.maxLength = spec.maxLength;
223
330
  field = input;
331
+ if (spec.input === "phone") {
332
+ const choices = dialChoices(options.locale);
333
+ const dial = el("select");
334
+ dial.setAttribute("aria-label", copy.dialCode);
335
+ const none = el("option", copy.dialCode);
336
+ none.value = "";
337
+ dial.append(none);
338
+ for (const [region, , text] of choices) {
339
+ const option = el("option", text);
340
+ option.value = region;
341
+ dial.append(option);
342
+ }
343
+ dial.value = spec.region ?? "";
344
+ dial.style.maxWidth = "45%";
345
+ input.addEventListener("input", () => {
346
+ if (input.value.trim().startsWith("+")) {
347
+ const digits = input.value.replace(/\D/g, "");
348
+ dial.value = regionOfDigits(digits, dial.value) || dial.value;
349
+ }
350
+ });
351
+ read = () => {
352
+ const raw = input.value.trim();
353
+ const digits = toAsciiDigits(raw).replace(/\D/g, "");
354
+ const code = choices.find((c) => c[0] === dial.value)?.[1];
355
+ if (digits.length < 4) return raw;
356
+ if (raw.startsWith("+")) return raw;
357
+ if (digits.length > 2 && /^[0٠۰०]{2}/u.test(raw)) return `+${digits.slice(2)}`;
358
+ if (code === void 0 || dial.value === spec.region) return raw;
359
+ return `+${code}${nationalDigits(code, digits)}`;
360
+ };
361
+ holder = el("div");
362
+ Object.assign(holder.style, {
363
+ display: "flex",
364
+ gap: "6px",
365
+ direction: "ltr"
366
+ });
367
+ holder.append(dial, input);
368
+ styleField(dial);
369
+ }
224
370
  }
225
371
  field.id = `${rowId}-input`;
226
372
  field.name = spec.field;
227
- Object.assign(field.style, {
228
- width: "100%",
229
- boxSizing: "border-box",
230
- padding: "8px 10px",
231
- borderRadius: "8px",
232
- border: "1px solid var(--widget-foreground-muted)",
233
- background: "transparent",
234
- color: "inherit",
235
- font: "inherit"
236
- });
237
- form.append(field);
373
+ styleField(field);
374
+ form.append(holder ?? field);
238
375
  const error = el("p");
239
376
  error.id = `${rowId}-error`;
240
377
  error.setAttribute("aria-live", "polite");
@@ -249,6 +386,7 @@ function mountCaptureCard(root, options) {
249
386
  return {
250
387
  spec,
251
388
  field,
389
+ read,
252
390
  error,
253
391
  choices,
254
392
  done: false
@@ -386,7 +524,7 @@ function mountCaptureCard(root, options) {
386
524
  ...spec.maxLength !== void 0 ? { maxLength: spec.maxLength } : {},
387
525
  ...choices !== null ? { choices } : {},
388
526
  ...spec.region ? { region: spec.region } : {}
389
- }, field.value);
527
+ }, row.read());
390
528
  if (!checked.ok) {
391
529
  showError(row, checked.error);
392
530
  field.focus();
@@ -1,4 +1,4 @@
1
- import { a as CAPTURE_CARD_INPUTS, c as CAPTURE_SAVED_EVENT_TYPE, i as CAPTURE_CARD_FIELD_PATTERN, n as CAPTURE_CARD_CONSENT_MAX, o as CAPTURE_CARD_REGION_PATTERN, r as CAPTURE_CARD_EVENT_TYPE, s as CAPTURE_CARD_VALUE_MAX, t as CAPTURE_CARD_CONSENT_CHANNELS } from "./capture-card-D7DqAq-N.js";
1
+ import { a as CAPTURE_CARD_INPUTS, c as CAPTURE_SAVED_EVENT_TYPE, i as CAPTURE_CARD_FIELD_PATTERN, n as CAPTURE_CARD_CONSENT_MAX, o as CAPTURE_CARD_REGION_PATTERN, r as CAPTURE_CARD_EVENT_TYPE, s as CAPTURE_CARD_VALUE_MAX, t as CAPTURE_CARD_CONSENT_CHANNELS } from "./capture-card-DiTdcTCh.js";
2
2
  import { a as isSafeFormSelector, i as isSafeFillValue, r as isSafeControlName, t as FILL_FORM_EVENT_TYPE } from "./form-fill-B-h6Uw1t.js";
3
3
  import { a as httpUrl, c as number, d as string, f as union, i as discriminatedUnion, l as object, n as array, o as literal, p as uuid, r as boolean, t as _enum, u as record } from "./schemas-DgC5Pex0.js";
4
4
  //#region ../widget-protocol/dist/act.js
@@ -17412,7 +17412,7 @@ function callStartStamp(spoken, others) {
17412
17412
  * cache makes a second `start()` after `stop()` free).
17413
17413
  */
17414
17414
  async function loadVoiceProtocol() {
17415
- const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-Bvu3c3dk.js")]);
17415
+ const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-B6vq8jBL.js")]);
17416
17416
  return {
17417
17417
  decodeTelemetry: telemetry.decodeTelemetry,
17418
17418
  encodeCallerText: telemetry.encodeCallerText,
@@ -18903,7 +18903,7 @@ function CaptureCardHost({ options }) {
18903
18903
  useEffect(() => {
18904
18904
  let dispose;
18905
18905
  let live = true;
18906
- import("./capture-card-dom-C0IKjuBA.js").then(({ mountCaptureCard }) => {
18906
+ import("./capture-card-dom-gYwMglNe.js").then(({ mountCaptureCard }) => {
18907
18907
  if (live && ref.current) dispose = mountCaptureCard(ref.current, options);
18908
18908
  }).catch(() => void 0);
18909
18909
  return () => {
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as IDLE_SNAPSHOT, $t as readStoredMinimised, A as rendererFor, An as formatMessage, At as MARK, B as textDirectionFor, Bn as KNOT_PATH, Bt as SHEET_PEEK_MAX, C as VoiceWidgetWithRenderer, Cn as oklchToOklab, Ct as DOCK_ALIGN_STORAGE_KEY, D as WidgetCartSummary, Dn as srgbToLinear, Dt as FLOAT_DUCK_DISMISS_MS, E as readsAsCheckoutIntent, En as rotateHue, Et as DRAG_TAP_SLOP_PX, F as CallView, Fn as MARK_VARIANTS, Ft as RADII, G as edgeOf, Gt as bottomLen, H as CONCIERGE_POSITIONS, Hn as BotFace, Ht as SHEET_TUCK, I as IDLE_CALL_RECORD, In as WIDGET_AVATARS, It as ROW_H, J as positionClasses, Jt as persistAlign, K as nearestPosition, Kt as containerAnchor, L as WidgetMarkdown, Ln as WIDGET_IDENTITY_AVATARS, Lt as SHEET_EXPANDED_DESKTOP_MAX, M as ShellRenderer, Mn as widgetMessagesFromCopy, Mt as PILL_H, N as deriveWidgetView, Nn as MorphingLoader, Nt as PILL_MARK, O as VariantOptionChips, On as withAlpha, Ot as FLOAT_GAP, P as ConciergeShell, Pn as DEFAULT_WIDGET_AVATAR, Pt as PROACTIVE_NUDGE_MS, Q as Mark, Qt as readStoredAlign, R as parseBlocks, Rn as dockAvatarFor, Rt as SHEET_EXPANDED_VH, S as VoiceWidget, Sn as oklchToHex, St as DESKTOP_WIDTHS, T as readsAsCartViewIntent, Tn as relativeLuminance, Tt as DRAG_CLICK_WINDOW_MS, U as DEFAULT_CONCIERGE_POSITION, Un as labelProps, Ut as SHORT_VIEWPORT, V as ConciergeLauncher, Vn as RopeKnot, Vt as SHEET_TOP_CLEARANCE, W as alignOf, Wn as cn, Wt as Z_INDEX, X as LAUNCHER_VARIANTS, Xt as pillAnchor, Y as positionForArrow, Yt as persistMinimised, Z as MARK_STATES, Zt as readStored, _ as useVoiceSession, _n as linearToSrgb, _t as BOTTOM_FLOOR, a as MAX_REPORTED_CART_LINES, an as SHEET_RADIUS_MAX_PX, at as latencyBetween, b as useChatSession, bn as oklabToLinearRgb, bt as DESKTOP_BREAKPOINT, c as deriveCallPhase, cn as deriveTheme, ct as deriveDockState, d as resolveCheckoutUrl, dn as themeToMarkedHostCss, dt as CONCIERGE_STATES, en as rowWidthLen, et as botStateFor, f as toChatCart, fn as contrastRatio, ft as deriveConciergeState, g as createWidgetVoiceTokenFetcher, gn as linearRgbToOklab, gt as ACTIVITY_W, h as ROOM_EVENTS, hn as hexToOklch, ht as WIDGET_MESSAGE_MAX_LENGTH, i as ConciergeWidget, in as CARD_RADIUS_MAX_PX, it as formatMs, j as DockRenderer, jn as resolveWidgetMessages, jt as MOBILE_MARGIN, k as WidgetCardList, kn as defaultWidgetMessages, kt as GLASS_IDLE_MS, l as mergeAddedCartLine, ln as themeToCss, lt as deriveDockView, m as deriveWidgetTheme, mn as hexToOklab, mt as formatMoney, n as CART_LINE_VARIANT_ID_SHAPE, nn as snapAlign, nt as SESSION_EVENTS, o as cartLinesFromSnapshot, on as SYSTEM_FONT_STACK, ot as Dock, p as WidgetThemeScope, pn as formatHex, pt as idleConciergeInput, q as panelClasses, qt as geometryVars, r as ConciergeHost, rn as writeStored, rt as SessionLog, s as chooseOptionsAction, sn as WIDGET_THEME_TOKENS, st as DOCK_STATES, t as CART_LINE_PLATFORM_VARIANT_ID_SHAPE, tn as sheetMaxHeightLen, tt as SseFrameParser, u as resolveAddToCartHandler, un as themeToInlineStyle, ut as idleDockInput, v as CHECKOUT_CAPTURE_REQUIRED, vn as mixToward, vt as CONTROL, w as basketIntentFromTurns, wn as parseHex, wt as DOCK_MINIMISED_STORAGE_KEY, xn as oklabToOklch, xt as DESKTOP_GUTTER, y as isSameOriginPath, yn as oklabToHex, yt as DESKTOP_BOTTOM, z as stripBidiControls, zn as isWidgetAvatar, zt as SHEET_GAP } from "./chunks/host-widget-BeuO9EtO.js";
1
+ import { $ as IDLE_SNAPSHOT, $t as readStoredMinimised, A as rendererFor, An as formatMessage, At as MARK, B as textDirectionFor, Bn as KNOT_PATH, Bt as SHEET_PEEK_MAX, C as VoiceWidgetWithRenderer, Cn as oklchToOklab, Ct as DOCK_ALIGN_STORAGE_KEY, D as WidgetCartSummary, Dn as srgbToLinear, Dt as FLOAT_DUCK_DISMISS_MS, E as readsAsCheckoutIntent, En as rotateHue, Et as DRAG_TAP_SLOP_PX, F as CallView, Fn as MARK_VARIANTS, Ft as RADII, G as edgeOf, Gt as bottomLen, H as CONCIERGE_POSITIONS, Hn as BotFace, Ht as SHEET_TUCK, I as IDLE_CALL_RECORD, In as WIDGET_AVATARS, It as ROW_H, J as positionClasses, Jt as persistAlign, K as nearestPosition, Kt as containerAnchor, L as WidgetMarkdown, Ln as WIDGET_IDENTITY_AVATARS, Lt as SHEET_EXPANDED_DESKTOP_MAX, M as ShellRenderer, Mn as widgetMessagesFromCopy, Mt as PILL_H, N as deriveWidgetView, Nn as MorphingLoader, Nt as PILL_MARK, O as VariantOptionChips, On as withAlpha, Ot as FLOAT_GAP, P as ConciergeShell, Pn as DEFAULT_WIDGET_AVATAR, Pt as PROACTIVE_NUDGE_MS, Q as Mark, Qt as readStoredAlign, R as parseBlocks, Rn as dockAvatarFor, Rt as SHEET_EXPANDED_VH, S as VoiceWidget, Sn as oklchToHex, St as DESKTOP_WIDTHS, T as readsAsCartViewIntent, Tn as relativeLuminance, Tt as DRAG_CLICK_WINDOW_MS, U as DEFAULT_CONCIERGE_POSITION, Un as labelProps, Ut as SHORT_VIEWPORT, V as ConciergeLauncher, Vn as RopeKnot, Vt as SHEET_TOP_CLEARANCE, W as alignOf, Wn as cn, Wt as Z_INDEX, X as LAUNCHER_VARIANTS, Xt as pillAnchor, Y as positionForArrow, Yt as persistMinimised, Z as MARK_STATES, Zt as readStored, _ as useVoiceSession, _n as linearToSrgb, _t as BOTTOM_FLOOR, a as MAX_REPORTED_CART_LINES, an as SHEET_RADIUS_MAX_PX, at as latencyBetween, b as useChatSession, bn as oklabToLinearRgb, bt as DESKTOP_BREAKPOINT, c as deriveCallPhase, cn as deriveTheme, ct as deriveDockState, d as resolveCheckoutUrl, dn as themeToMarkedHostCss, dt as CONCIERGE_STATES, en as rowWidthLen, et as botStateFor, f as toChatCart, fn as contrastRatio, ft as deriveConciergeState, g as createWidgetVoiceTokenFetcher, gn as linearRgbToOklab, gt as ACTIVITY_W, h as ROOM_EVENTS, hn as hexToOklch, ht as WIDGET_MESSAGE_MAX_LENGTH, i as ConciergeWidget, in as CARD_RADIUS_MAX_PX, it as formatMs, j as DockRenderer, jn as resolveWidgetMessages, jt as MOBILE_MARGIN, k as WidgetCardList, kn as defaultWidgetMessages, kt as GLASS_IDLE_MS, l as mergeAddedCartLine, ln as themeToCss, lt as deriveDockView, m as deriveWidgetTheme, mn as hexToOklab, mt as formatMoney, n as CART_LINE_VARIANT_ID_SHAPE, nn as snapAlign, nt as SESSION_EVENTS, o as cartLinesFromSnapshot, on as SYSTEM_FONT_STACK, ot as Dock, p as WidgetThemeScope, pn as formatHex, pt as idleConciergeInput, q as panelClasses, qt as geometryVars, r as ConciergeHost, rn as writeStored, rt as SessionLog, s as chooseOptionsAction, sn as WIDGET_THEME_TOKENS, st as DOCK_STATES, t as CART_LINE_PLATFORM_VARIANT_ID_SHAPE, tn as sheetMaxHeightLen, tt as SseFrameParser, u as resolveAddToCartHandler, un as themeToInlineStyle, ut as idleDockInput, v as CHECKOUT_CAPTURE_REQUIRED, vn as mixToward, vt as CONTROL, w as basketIntentFromTurns, wn as parseHex, wt as DOCK_MINIMISED_STORAGE_KEY, xn as oklabToOklch, xt as DESKTOP_GUTTER, y as isSameOriginPath, yn as oklabToHex, yt as DESKTOP_BOTTOM, z as stripBidiControls, zn as isWidgetAvatar, zt as SHEET_GAP } from "./chunks/host-widget-4FfPd2gs.js";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { Component, createElement, useEffect, useRef } from "react";
4
4
  import { createRoot } from "react-dom/client";
@@ -1,4 +1,4 @@
1
- import { i as ConciergeWidget, x as detectPage } from "../chunks/host-widget-BeuO9EtO.js";
1
+ import { i as ConciergeWidget, x as detectPage } from "../chunks/host-widget-4FfPd2gs.js";
2
2
  import { useCallback, useEffect, useMemo, useRef } from "react";
3
3
  import { usePathname, useRouter } from "next/navigation";
4
4
  //#region src/next/use-next-bridge.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saar-ai/web-widget",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "saar:distribution": "publishable",
5
5
  "description": "The concierge widget's React UI — ConciergeShell chrome plus the full end-user conversation (VoiceWidget, useChatSession, useVoiceSession) — de-Nexted for the merchant-site embed (docs/WIDGET_EMBED_PLAN.md §4 Phase 3). Publishes PUBLICLY to npmjs (docs/WIDGET_EMBED_PLAN.md §5.1) — every workspace and third-party runtime dependency is bundled into dist/ at build time, so \"dependencies\" is empty. React and react-dom are peer dependencies only; next is an optional peer, needed only by the ./next subpath (Phase 5).",
6
6
  "type": "module",
@@ -83,6 +83,7 @@
83
83
  "@wesence/vitest-presets": "0.0.1",
84
84
  "clsx": "^2.1.1",
85
85
  "jsdom": "^30.1.0",
86
+ "libphonenumber-js": "^1.13.14",
86
87
  "livekit-client": "^2.21.0",
87
88
  "lucide-react": "^1.47.0",
88
89
  "next": "^16.4.1",