@xpert-ai/chatkit-web-component 0.0.3 → 0.2.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.
@@ -43,6 +43,7 @@ var __decorateElement = (array, flags, name, decorators, target, extra) => {
43
43
  }
44
44
  return k || __decoratorMetadata(array, target), desc && __defProp(target, name, desc), p ? k ^ 4 ? extra : desc : target;
45
45
  };
46
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
46
47
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
47
48
  var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use the "in" operator on this value') : member.has(obj);
48
49
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
@@ -50,11 +51,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
50
51
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
51
52
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
52
53
 
53
- var _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _setThreadId_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _a2, _opts, _frameUrl, _frame, _wrapper, _shadow, _resolveLoaded, _loaded, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
54
- var __defProp2 = Object.defineProperty;
55
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
56
- var __publicField = (obj, key, value) => __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
57
- var _a, _b;
54
+ var _a, _b, _setTrainingOptOut_dec, _hideHistory_dec, _showHistory_dec, _sendCustomAction_dec, _shareThread_dec, _setThreadId_dec, _setComposerValue_dec, _sendUserMessage_dec, _fetchUpdates_dec, _focusComposer_dec, _c, _opts, _frameUrl, _frame, _wrapper, _shadow, _resolveLoaded, _loaded, _messenger, _ChatKitElementBase_instances, emitAndThrow_fn, setOptionsDataAttributes_fn, getFrameUrl_fn, setFrameUrl_fn, consumeFrameUrl_fn, _handleFrameLoad, _initialized, maybeInit_fn, _init;
58
55
  class EventEmitter {
59
56
  constructor() {
60
57
  __publicField(this, "callbacks", /* @__PURE__ */ new Map());
@@ -66,16 +63,16 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
66
63
  this.callbacks.get(event).add(callback);
67
64
  }
68
65
  emit(event, ...args) {
69
- var _a22;
66
+ var _a2;
70
67
  const data = args[0];
71
- (_a22 = this.callbacks.get(event)) == null ? void 0 : _a22.forEach((callback) => callback(data));
68
+ (_a2 = this.callbacks.get(event)) == null ? void 0 : _a2.forEach((callback) => callback(data));
72
69
  }
73
70
  off(event, callback) {
74
- var _a22;
71
+ var _a2;
75
72
  if (!callback) {
76
73
  this.callbacks.delete(event);
77
74
  } else {
78
- (_a22 = this.callbacks.get(event)) == null ? void 0 : _a22.delete(callback);
75
+ (_a2 = this.callbacks.get(event)) == null ? void 0 : _a2.delete(callback);
79
76
  }
80
77
  }
81
78
  allOff() {
@@ -200,8 +197,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
200
197
  const EventStreamContentType = "text/event-stream";
201
198
  const DefaultRetryInterval = 1e3;
202
199
  const LastEventId = "last-event-id";
203
- function fetchEventSource(input, _a22) {
204
- var { signal: inputSignal, headers: inputHeaders, onopen: inputOnOpen, onmessage, onclose, onerror, openWhenHidden, fetch: inputFetch } = _a22, rest = __rest(_a22, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
200
+ function fetchEventSource(input, _a2) {
201
+ var { signal: inputSignal, headers: inputHeaders, onopen: inputOnOpen, onmessage, onclose, onerror, openWhenHidden, fetch: inputFetch } = _a2, rest = __rest(_a2, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
205
202
  return new Promise((resolve, reject) => {
206
203
  const headers = Object.assign({}, inputHeaders);
207
204
  if (!headers.accept) {
@@ -303,7 +300,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
303
300
  }
304
301
  }
305
302
  _a = FRAME_SAFE_ERROR_KEY;
306
- const _FrameSafeHttpError = class _FrameSafeHttpError2 {
303
+ const _FrameSafeHttpError = class _FrameSafeHttpError {
307
304
  constructor(message, res, metadata) {
308
305
  __publicField(this, _a, "HttpError");
309
306
  __publicField(this, "message");
@@ -318,7 +315,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
318
315
  this.metadata = metadata;
319
316
  }
320
317
  static fromHttpError(error) {
321
- return new _FrameSafeHttpError2(
318
+ return new _FrameSafeHttpError(
322
319
  error.message,
323
320
  {
324
321
  status: error.status,
@@ -348,9 +345,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
348
345
  await fetchEventSource(url, {
349
346
  ...restParams,
350
347
  onopen: async (res) => {
351
- var _a22;
348
+ var _a2;
352
349
  onopen == null ? void 0 : onopen(res);
353
- if (res.ok && ((_a22 = res.headers.get("content-type")) == null ? void 0 : _a22.startsWith("text/event-stream"))) {
350
+ if (res.ok && ((_a2 = res.headers.get("content-type")) == null ? void 0 : _a2.startsWith("text/event-stream"))) {
354
351
  retryAttempt = 0;
355
352
  return;
356
353
  }
@@ -373,7 +370,21 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
373
370
  }
374
371
  });
375
372
  };
376
- let IntegrationError$1 = class IntegrationError extends Error {
373
+ function safeRandomUUID() {
374
+ const cryptoRef = globalThis.crypto;
375
+ if (typeof (cryptoRef == null ? void 0 : cryptoRef.randomUUID) === "function") {
376
+ return cryptoRef.randomUUID();
377
+ }
378
+ if (typeof (cryptoRef == null ? void 0 : cryptoRef.getRandomValues) === "function") {
379
+ const bytes = new Uint8Array(16);
380
+ cryptoRef.getRandomValues(bytes);
381
+ bytes[6] = bytes[6] & 15 | 64;
382
+ bytes[8] = bytes[8] & 63 | 128;
383
+ return [...bytes].map((byte) => byte.toString(16).padStart(2, "0")).join("").replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "$1-$2-$3-$4-$5");
384
+ }
385
+ return `ck_${Date.now()}_${Math.random().toString(16).slice(2)}`;
386
+ }
387
+ let IntegrationError$1 = class IntegrationError2 extends Error {
377
388
  constructor(message) {
378
389
  super(message);
379
390
  __publicField(this, "_name");
@@ -383,7 +394,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
383
394
  static fromPossibleFrameSafeError(error) {
384
395
  if (error && typeof error === "object" && FRAME_SAFE_ERROR_KEY in error && error[FRAME_SAFE_ERROR_KEY] === "IntegrationError") {
385
396
  const safeError = error;
386
- const parsedError = new IntegrationError(safeError.message);
397
+ const parsedError = new IntegrationError2(safeError.message);
387
398
  parsedError.stack = safeError.stack;
388
399
  return parsedError;
389
400
  }
@@ -421,7 +432,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
421
432
  get: (_, command) => {
422
433
  return (data, transfer) => {
423
434
  return new Promise((resolve, reject) => {
424
- const nonce = crypto.randomUUID();
435
+ const nonce = safeRandomUUID();
425
436
  this.handlers.set(nonce, { resolve, reject, stack: new Error().stack || "" });
426
437
  this.sendMessage(
427
438
  {
@@ -438,8 +449,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
438
449
  }
439
450
  ));
440
451
  __publicField(this, "handleMessage", async (event) => {
441
- var _a22, _b2, _c, _d;
442
- console.log("Received message", event.data, event.origin, this.targetOrigin, event.source, this.target());
452
+ var _a2, _b2, _c2, _d;
443
453
  if (!event.data || event.data.__xpaiChatKit !== true || event.origin !== this.targetOrigin || event.source !== this.target()) {
444
454
  return;
445
455
  }
@@ -512,7 +522,6 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
512
522
  break;
513
523
  }
514
524
  case "command": {
515
- console.log("Received command", data.command, data.data);
516
525
  if (!this.canReceiveCommand(data.command)) {
517
526
  this.sendMessage({
518
527
  type: "response",
@@ -522,7 +531,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
522
531
  return;
523
532
  }
524
533
  try {
525
- const response = await ((_b2 = (_a22 = this.commandHandlers)[data.command]) == null ? void 0 : _b2.call(_a22, data.data));
534
+ const response = await ((_b2 = (_a2 = this.commandHandlers)[data.command]) == null ? void 0 : _b2.call(_a2, data.data));
526
535
  this.sendMessage({
527
536
  type: "response",
528
537
  response,
@@ -566,7 +575,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
566
575
  console.error("No handler found for nonce", data.nonce);
567
576
  return;
568
577
  }
569
- (_d = (_c = this.fetchEventSourceHandlers.get(data.nonce)) == null ? void 0 : _c.onmessage) == null ? void 0 : _d.call(_c, data.message);
578
+ (_d = (_c2 = this.fetchEventSourceHandlers.get(data.nonce)) == null ? void 0 : _c2.onmessage) == null ? void 0 : _d.call(_c2, data.message);
570
579
  break;
571
580
  }
572
581
  case "abortSignal": {
@@ -588,12 +597,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
588
597
  this.targetOrigin = targetOrigin;
589
598
  }
590
599
  sendMessage(data, transfer) {
591
- var _a22;
600
+ var _a2;
592
601
  const message = {
593
602
  __xpaiChatKit: true,
594
603
  ...data
595
604
  };
596
- (_a22 = this.target()) == null ? void 0 : _a22.postMessage(message, this.targetOrigin, transfer);
605
+ (_a2 = this.target()) == null ? void 0 : _a2.postMessage(message, this.targetOrigin, transfer);
597
606
  }
598
607
  connect() {
599
608
  window.addEventListener("message", this.handleMessage);
@@ -603,7 +612,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
603
612
  }
604
613
  fetch(url, params) {
605
614
  return new Promise((resolve, reject) => {
606
- const nonce = crypto.randomUUID();
615
+ const nonce = safeRandomUUID();
607
616
  this.handlers.set(nonce, { resolve, reject, stack: new Error().stack || "" });
608
617
  let formData;
609
618
  if (params.body instanceof FormData) {
@@ -615,11 +624,11 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
615
624
  }
616
625
  if (params.signal) {
617
626
  params.signal.addEventListener("abort", () => {
618
- var _a22;
627
+ var _a2;
619
628
  this.sendMessage({
620
629
  type: "abortSignal",
621
630
  nonce,
622
- reason: (_a22 = params.signal) == null ? void 0 : _a22.reason
631
+ reason: (_a2 = params.signal) == null ? void 0 : _a2.reason
623
632
  });
624
633
  });
625
634
  params.signal = void 0;
@@ -632,7 +641,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
632
641
  fetchEventSource(url, params) {
633
642
  return new Promise((resolve, reject) => {
634
643
  const { onmessage, signal, ...rest } = params;
635
- const nonce = crypto.randomUUID();
644
+ const nonce = safeRandomUUID();
636
645
  this.handlers.set(nonce, { resolve, reject, stack: new Error().stack || "" });
637
646
  this.fetchEventSourceHandlers.set(nonce, {
638
647
  onmessage
@@ -681,7 +690,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
681
690
  for (const b of bytes) bin += String.fromCharCode(b);
682
691
  return toUrlBase64(bin);
683
692
  };
684
- class IntegrationError2 extends Error {
693
+ class IntegrationError extends Error {
685
694
  }
686
695
  function fromPossibleFrameSafeError(err) {
687
696
  return err.message;
@@ -885,14 +894,14 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
885
894
  const command = String(context.name);
886
895
  return function(...args) {
887
896
  if (!this.capabilities.commands.has(command)) {
888
- throw new IntegrationError2(
897
+ throw new IntegrationError(
889
898
  `ChatKit command "${String(command)}" is not available for the "${this.profile}" profile.`
890
899
  );
891
900
  }
892
901
  return value.apply(this, args);
893
902
  };
894
903
  }
895
- class ChatKitElementBase extends (_a2 = HTMLElement, _focusComposer_dec = [requireCommandCapability], _fetchUpdates_dec = [requireCommandCapability], _sendUserMessage_dec = [requireCommandCapability], _setComposerValue_dec = [requireCommandCapability], _setThreadId_dec = [requireCommandCapability], _shareThread_dec = [requireCommandCapability], _sendCustomAction_dec = [requireCommandCapability], _showHistory_dec = [requireCommandCapability], _hideHistory_dec = [requireCommandCapability], _setTrainingOptOut_dec = [requireCommandCapability], _a2) {
904
+ class ChatKitElementBase extends (_c = HTMLElement, _focusComposer_dec = [requireCommandCapability], _fetchUpdates_dec = [requireCommandCapability], _sendUserMessage_dec = [requireCommandCapability], _setComposerValue_dec = [requireCommandCapability], _setThreadId_dec = [requireCommandCapability], _shareThread_dec = [requireCommandCapability], _sendCustomAction_dec = [requireCommandCapability], _showHistory_dec = [requireCommandCapability], _hideHistory_dec = [requireCommandCapability], _setTrainingOptOut_dec = [requireCommandCapability], _c) {
896
905
  constructor({ profile }) {
897
906
  super();
898
907
  __runInitializers(_init, 5, this);
@@ -908,17 +917,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
908
917
  }));
909
918
  __privateAdd(this, _messenger, new ChatFrameMessenger({
910
919
  fetch: (...args) => {
911
- var _a3;
912
- const customFetch = ((_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.api) && "fetch" in __privateGet(this, _opts).api && __privateGet(this, _opts).api.fetch;
920
+ var _a2;
921
+ const customFetch = ((_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.api) && "fetch" in __privateGet(this, _opts).api && __privateGet(this, _opts).api.fetch;
913
922
  return customFetch ? customFetch(...args) : fetch(...args);
914
923
  },
915
924
  target: () => {
916
- var _a3;
917
- return ((_a3 = __privateGet(this, _frame)) == null ? void 0 : _a3.contentWindow) ?? null;
925
+ var _a2;
926
+ return ((_a2 = __privateGet(this, _frame)) == null ? void 0 : _a2.contentWindow) ?? null;
918
927
  },
919
928
  targetOrigin: window.location.origin,
920
929
  handlers: {
921
- onFileInputClick: ({ inputAttributes }) => {
930
+ onFileInputClick: ({
931
+ inputAttributes
932
+ }) => {
922
933
  return new Promise((resolve) => {
923
934
  const input = document.createElement("input");
924
935
  for (const [key, value] of Object.entries(inputAttributes)) {
@@ -942,40 +953,43 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
942
953
  id,
943
954
  tool_call_id
944
955
  }) => {
945
- var _a3;
946
- const onClientTool = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.onClientTool;
956
+ var _a2;
957
+ const onClientTool = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.onClientTool;
947
958
  if (!onClientTool) {
948
- __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError2(
959
+ __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError(
949
960
  `No handler for client tool calls. You'll need to add onClientTool to your ChatKit options.`
950
961
  ));
951
962
  }
952
963
  return onClientTool({ name, params, id, tool_call_id });
953
964
  },
954
- onWidgetAction: async ({ action, widgetItem }) => {
955
- var _a3, _b2;
956
- const onAction = (_b2 = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.widgets) == null ? void 0 : _b2.onAction;
965
+ onWidgetAction: async ({
966
+ action,
967
+ widgetItem
968
+ }) => {
969
+ var _a2, _b2;
970
+ const onAction = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.widgets) == null ? void 0 : _b2.onAction;
957
971
  if (!onAction) {
958
- __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError2(
972
+ __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError(
959
973
  `No handler for widget actions. You'll need to add widgets.onAction to your ChatKit options.`
960
974
  ));
961
975
  }
962
976
  return onAction(action, widgetItem);
963
977
  },
964
978
  onEntitySearch: async ({ query }) => {
965
- var _a3, _b2, _c;
966
- return ((_c = (_b2 = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.entities) == null ? void 0 : _b2.onTagSearch) == null ? void 0 : _c.call(_b2, query)) ?? [];
979
+ var _a2, _b2, _c2;
980
+ return ((_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.entities) == null ? void 0 : _b2.onTagSearch) == null ? void 0 : _c2.call(_b2, query)) ?? [];
967
981
  },
968
982
  onEntityClick: async ({ entity }) => {
969
- var _a3, _b2, _c;
970
- return (_c = (_b2 = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.entities) == null ? void 0 : _b2.onClick) == null ? void 0 : _c.call(_b2, entity);
983
+ var _a2, _b2, _c2;
984
+ return (_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.entities) == null ? void 0 : _b2.onClick) == null ? void 0 : _c2.call(_b2, entity);
971
985
  },
972
986
  onEntityPreview: async ({ entity }) => {
973
- var _a3, _b2, _c;
974
- return ((_c = (_b2 = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.entities) == null ? void 0 : _b2.onRequestPreview) == null ? void 0 : _c.call(_b2, entity)) ?? { preview: null };
987
+ var _a2, _b2, _c2;
988
+ return ((_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.entities) == null ? void 0 : _b2.onRequestPreview) == null ? void 0 : _c2.call(_b2, entity)) ?? { preview: null };
975
989
  },
976
990
  onGetClientSecret: async (currentClientSecret) => {
977
991
  if (!__privateGet(this, _opts) || !("getClientSecret" in __privateGet(this, _opts).api) || !__privateGet(this, _opts).api.getClientSecret) {
978
- __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError2(
992
+ __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, new IntegrationError(
979
993
  "Could not refresh the session because ChatKitOptions.api.getClientSecret is not configured."
980
994
  ));
981
995
  }
@@ -985,15 +999,19 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
985
999
  op,
986
1000
  params
987
1001
  }) => {
988
- throw new IntegrationError2("ChatKit: onAddMetadataToRequest is unimplemented.");
1002
+ throw new IntegrationError(
1003
+ "ChatKit: onAddMetadataToRequest is unimplemented."
1004
+ );
989
1005
  }
990
1006
  }
991
1007
  }));
992
1008
  __privateAdd(this, _handleFrameLoad, () => {
993
- var _a3;
1009
+ var _a2;
994
1010
  this.dataset.loaded = "true";
995
- this.dispatchEvent(new CustomEvent("chatkit.ready", { bubbles: true, composed: true }));
996
- (_a3 = __privateGet(this, _resolveLoaded)) == null ? void 0 : _a3.call(this);
1011
+ this.dispatchEvent(
1012
+ new CustomEvent("chatkit.ready", { bubbles: true, composed: true })
1013
+ );
1014
+ (_a2 = __privateGet(this, _resolveLoaded)) == null ? void 0 : _a2.call(this);
997
1015
  });
998
1016
  __privateAdd(this, _initialized, false);
999
1017
  this.profile = profile;
@@ -1052,19 +1070,21 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1052
1070
  __privateSet(this, _wrapper, wrapper);
1053
1071
  __privateGet(this, _shadow).append(style);
1054
1072
  __privateGet(this, _messenger).on("left_header_icon_click", () => {
1055
- var _a3, _b2, _c;
1056
- (_c = (_b2 = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.header) == null ? void 0 : _b2.leftAction) == null ? void 0 : _c.onClick();
1073
+ var _a2, _b2, _c2;
1074
+ (_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.header) == null ? void 0 : _b2.leftAction) == null ? void 0 : _c2.onClick();
1057
1075
  });
1058
1076
  __privateGet(this, _messenger).on("right_header_icon_click", () => {
1059
- var _a3, _b2, _c;
1060
- (_c = (_b2 = (_a3 = __privateGet(this, _opts)) == null ? void 0 : _a3.header) == null ? void 0 : _b2.rightAction) == null ? void 0 : _c.onClick();
1077
+ var _a2, _b2, _c2;
1078
+ (_c2 = (_b2 = (_a2 = __privateGet(this, _opts)) == null ? void 0 : _a2.header) == null ? void 0 : _b2.rightAction) == null ? void 0 : _c2.onClick();
1061
1079
  });
1062
1080
  __privateGet(this, _messenger).on("public_event", ([event, data]) => {
1063
1081
  if (!this.capabilities.events.has(event)) return;
1064
1082
  if (event === "error" && "error" in data) {
1065
1083
  const error = fromPossibleFrameSafeError(data.error);
1066
- this.dispatchEvent(new CustomEvent("chatkit.error", { detail: { error } }));
1067
- if (error instanceof IntegrationError2) {
1084
+ this.dispatchEvent(
1085
+ new CustomEvent("chatkit.error", { detail: { error } })
1086
+ );
1087
+ if (error instanceof IntegrationError) {
1068
1088
  throw error;
1069
1089
  }
1070
1090
  return;
@@ -1089,12 +1109,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1089
1109
  __privateMethod(this, _ChatKitElementBase_instances, maybeInit_fn).call(this);
1090
1110
  } catch (error) {
1091
1111
  console.error(error);
1092
- __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, error instanceof Error ? error : new IntegrationError2("Failed to initialize ChatKit"));
1112
+ __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, error instanceof Error ? error : new IntegrationError("Failed to initialize ChatKit"));
1093
1113
  }
1094
1114
  }
1095
1115
  disconnectedCallback() {
1096
- var _a3;
1097
- (_a3 = __privateGet(this, _frame)) == null ? void 0 : _a3.removeEventListener("load", __privateGet(this, _handleFrameLoad));
1116
+ var _a2;
1117
+ (_a2 = __privateGet(this, _frame)) == null ? void 0 : _a2.removeEventListener("load", __privateGet(this, _handleFrameLoad));
1098
1118
  __privateGet(this, _messenger).disconnect();
1099
1119
  }
1100
1120
  applySanitizedOptions(newOptions) {
@@ -1114,62 +1134,62 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1114
1134
  __privateMethod(this, _ChatKitElementBase_instances, consumeFrameUrl_fn).call(this, sanitized);
1115
1135
  this.applySanitizedOptions(sanitized);
1116
1136
  } catch (error) {
1117
- __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, error instanceof Error ? error : new IntegrationError2("Failed to parse options"));
1137
+ __privateMethod(this, _ChatKitElementBase_instances, emitAndThrow_fn).call(this, error instanceof Error ? error : new IntegrationError("Failed to parse options"));
1118
1138
  }
1119
1139
  }
1120
1140
  async focusComposer() {
1121
- var _a3, _b2;
1141
+ var _a2, _b2;
1122
1142
  await __privateGet(this, _loaded);
1123
- (_a3 = __privateGet(this, _frame)) == null ? void 0 : _a3.focus();
1143
+ (_a2 = __privateGet(this, _frame)) == null ? void 0 : _a2.focus();
1124
1144
  await ((_b2 = __privateGet(this, _messenger)) == null ? void 0 : _b2.commands.focusComposer());
1125
1145
  }
1126
1146
  async fetchUpdates() {
1127
- var _a3;
1147
+ var _a2;
1128
1148
  await __privateGet(this, _loaded);
1129
- await ((_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.fetchUpdates());
1149
+ await ((_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.fetchUpdates());
1130
1150
  }
1131
1151
  async sendUserMessage(params) {
1132
- var _a3;
1152
+ var _a2;
1133
1153
  await __privateGet(this, _loaded);
1134
- await ((_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.sendUserMessage(params));
1154
+ await ((_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.sendUserMessage(params));
1135
1155
  }
1136
1156
  async setComposerValue(params) {
1137
- var _a3;
1157
+ var _a2;
1138
1158
  await __privateGet(this, _loaded);
1139
- await ((_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.setComposerValue(params));
1159
+ await ((_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.setComposerValue(params));
1140
1160
  }
1141
1161
  async setThreadId(threadId) {
1142
- var _a3;
1162
+ var _a2;
1143
1163
  await __privateGet(this, _loaded);
1144
- await ((_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.setThreadId({ threadId }));
1164
+ await ((_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.setThreadId({ threadId }));
1145
1165
  }
1146
1166
  async shareThread() {
1147
- var _a3;
1167
+ var _a2;
1148
1168
  await __privateGet(this, _loaded);
1149
- return (_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.shareThread();
1169
+ return (_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.shareThread();
1150
1170
  }
1151
1171
  async sendCustomAction(action, itemId) {
1152
- var _a3;
1172
+ var _a2;
1153
1173
  await __privateGet(this, _loaded);
1154
- return (_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.sendCustomAction({ action, itemId });
1174
+ return (_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.sendCustomAction({ action, itemId });
1155
1175
  }
1156
1176
  async showHistory() {
1157
- var _a3;
1177
+ var _a2;
1158
1178
  await __privateGet(this, _loaded);
1159
- return (_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.showHistory();
1179
+ return (_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.showHistory();
1160
1180
  }
1161
1181
  async hideHistory() {
1162
- var _a3;
1182
+ var _a2;
1163
1183
  await __privateGet(this, _loaded);
1164
- return (_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.hideHistory();
1184
+ return (_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.hideHistory();
1165
1185
  }
1166
1186
  async setTrainingOptOut(value) {
1167
- var _a3;
1187
+ var _a2;
1168
1188
  await __privateGet(this, _loaded);
1169
- return (_a3 = __privateGet(this, _messenger)) == null ? void 0 : _a3.commands.setTrainingOptOut({ value });
1189
+ return (_a2 = __privateGet(this, _messenger)) == null ? void 0 : _a2.commands.setTrainingOptOut({ value });
1170
1190
  }
1171
1191
  }
1172
- _init = __decoratorStart(_a2);
1192
+ _init = __decoratorStart(_c);
1173
1193
  _opts = new WeakMap();
1174
1194
  _frameUrl = new WeakMap();
1175
1195
  _frame = new WeakMap();
@@ -1184,12 +1204,12 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1184
1204
  throw error;
1185
1205
  };
1186
1206
  setOptionsDataAttributes_fn = function(options) {
1187
- var _a3;
1188
- this.dataset.colorScheme = typeof options.theme === "string" ? options.theme : ((_a3 = options.theme) == null ? void 0 : _a3.colorScheme) ?? "light";
1207
+ var _a2;
1208
+ this.dataset.colorScheme = typeof options.theme === "string" ? options.theme : ((_a2 = options.theme) == null ? void 0 : _a2.colorScheme) ?? "light";
1189
1209
  };
1190
1210
  getFrameUrl_fn = function() {
1191
1211
  if (!__privateGet(this, _frameUrl)) {
1192
- throw new IntegrationError2(
1212
+ throw new IntegrationError(
1193
1213
  "ChatKit frameUrl is not configured. Provide it via setOptions({ frameUrl }) before mounting."
1194
1214
  );
1195
1215
  }
@@ -1197,7 +1217,7 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1197
1217
  };
1198
1218
  setFrameUrl_fn = function(frameUrl) {
1199
1219
  if (__privateGet(this, _initialized) && __privateGet(this, _frameUrl) && __privateGet(this, _frameUrl) !== frameUrl) {
1200
- throw new IntegrationError2(
1220
+ throw new IntegrationError(
1201
1221
  "ChatKit frameUrl cannot be changed after initialization. Create a new element to use a different URL."
1202
1222
  );
1203
1223
  }
@@ -1209,7 +1229,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1209
1229
  delete options.frameUrl;
1210
1230
  if (frameUrl == null) return;
1211
1231
  if (typeof frameUrl !== "string" || frameUrl.trim() === "") {
1212
- throw new IntegrationError2("ChatKit frameUrl must be a non-empty string.");
1232
+ throw new IntegrationError(
1233
+ "ChatKit frameUrl must be a non-empty string."
1234
+ );
1213
1235
  }
1214
1236
  __privateMethod(this, _ChatKitElementBase_instances, setFrameUrl_fn).call(this, frameUrl);
1215
1237
  };
@@ -1250,8 +1272,8 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
1250
1272
  super({ profile: "chatkit" });
1251
1273
  }
1252
1274
  sanitizeOptions(options) {
1253
- var _a3;
1254
- (_a3 = options.threadItemActions) == null ? true : delete _a3.share;
1275
+ var _a2;
1276
+ (_a2 = options.threadItemActions) == null ? true : delete _a2.share;
1255
1277
  return options;
1256
1278
  }
1257
1279
  }