@corti/embedded-web 0.2.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,6 +15,48 @@ A web component and React component library that provides an embedded interface
15
15
  npm install @corti/embedded-web
16
16
  ```
17
17
 
18
+ ## Testing
19
+
20
+ Install dependencies before running tests:
21
+
22
+ ```bash
23
+ npm install
24
+ ```
25
+
26
+ Run the full test suite:
27
+
28
+ ```bash
29
+ npm test
30
+ ```
31
+
32
+ Run tests in watch mode while developing:
33
+
34
+ ```bash
35
+ npm run test:watch
36
+ ```
37
+
38
+ Run only the embedded component communication integration test:
39
+
40
+ ```bash
41
+ npx tsc -p tsconfig.test.json && npx wtr .tmp/test-dist/test/corti-embedded.integration.test.js
42
+ ```
43
+
44
+ Run the integration test across Chromium, Firefox, and WebKit:
45
+
46
+ ```bash
47
+ npx tsc -p tsconfig.test.json && EMBEDDED_WEB_TEST_BROWSERS=chromium,firefox,webkit npx wtr .tmp/test-dist/test/corti-embedded.integration.test.js
48
+ ```
49
+
50
+ Run the integration test against an installed Microsoft Edge channel:
51
+
52
+ ```bash
53
+ npx tsc -p tsconfig.test.json && EMBEDDED_WEB_TEST_BROWSERS=chromium EMBEDDED_WEB_CHROMIUM_CHANNEL=msedge npx wtr .tmp/test-dist/test/corti-embedded.integration.test.js
54
+ ```
55
+
56
+ The integration test runs in Playwright Chromium by default and can be expanded to Firefox, WebKit, or an installed Edge channel. It validates the public web component API against a real iframe `postMessage` boundary and uses the local test runner setup, so it does not require access to the live embedded Assistant service.
57
+
58
+ Pull requests also run the integration test against Microsoft Edge on a Windows GitHub Actions runner.
59
+
18
60
  ## Usage
19
61
 
20
62
  ### Web Component
@@ -43,9 +85,16 @@ const interaction = await myComponent.createInteraction({
43
85
  }
44
86
  });
45
87
 
46
- await myComponent.configureSession({"defaultTemplateKey": "soap_note"});
88
+ await myComponent.setInteractionOptions({
89
+ templates: {
90
+ defaultTemplate: {
91
+ behaviour: "fallback",
92
+ template: { source: "standard", id: "soap_note" },
93
+ },
94
+ },
95
+ });
47
96
  await myComponent.addFacts([{"text": "Chest pain", "group": "other"}]);
48
- await myComponent.navigate('/interactions/123');
97
+ await myComponent.navigate({ path: "/interactions/123" });
49
98
  await myComponent.show()
50
99
  ```
51
100
 
@@ -100,7 +149,14 @@ function App() {
100
149
  });
101
150
  console.log("Authenticated:", user);
102
151
 
103
- await api.configureSession({ defaultTemplateKey: "soap_note" });
152
+ await api.setInteractionOptions({
153
+ templates: {
154
+ defaultTemplate: {
155
+ behaviour: "fallback",
156
+ template: { source: "standard", id: "soap_note" },
157
+ },
158
+ },
159
+ });
104
160
  await api.createInteraction({
105
161
  encounter: {
106
162
  identifier: `encounter-${Date.now()}`,
@@ -172,14 +228,37 @@ const authResponse = await component.auth({
172
228
  });
173
229
  ```
174
230
 
175
- #### configureSession
231
+ #### configureApp
176
232
 
177
233
  ```javascript
178
- await component.configureSession({
179
- defaultLanguage: "en",
180
- defaultOutputLanguage: "en",
181
- defaultTemplateKey: "discharge-summary",
182
- defaultMode: "virtual",
234
+ await component.configureApp({
235
+ ui: {
236
+ aiChat: true,
237
+ navigation: false,
238
+ },
239
+ appearance: {
240
+ primaryColor: "#000000",
241
+ },
242
+ });
243
+ ```
244
+
245
+ #### setInteractionOptions
246
+
247
+ ```javascript
248
+ await component.setInteractionOptions({
249
+ mode: {
250
+ fallback: "virtual",
251
+ options: ["in-person", "virtual"],
252
+ },
253
+ spokenLanguage: {
254
+ fallback: "en",
255
+ },
256
+ templates: {
257
+ defaultTemplate: {
258
+ behaviour: "fallback",
259
+ template: { source: "standard", id: "discharge-summary" },
260
+ },
261
+ },
183
262
  });
184
263
  ```
185
264
 
@@ -195,7 +274,7 @@ await component.addFacts([
195
274
  #### navigate
196
275
 
197
276
  ```javascript
198
- await component.navigate("/interactions/123");
277
+ await component.navigate({ path: "/interactions/123" });
199
278
  ```
200
279
 
201
280
  #### createInteraction
@@ -243,7 +322,7 @@ The component uses a `PostMessageHandler` utility class that:
243
322
 
244
323
  The React component (`CortiEmbeddedReact`) is available as an additional export and provides:
245
324
 
246
- - **Hook-based API access**: `useCortiEmbeddedApi(ref)` exposes instance-bound methods (`auth`, `navigate`, `createInteraction`, etc.)
325
+ - **Hook-based API access**: `useCortiEmbeddedApi(ref)` exposes instance-bound methods (`auth`, `navigate`, `createInteraction`, `showDeviceLinkQR`, etc.)
247
326
  - **Generic event stream**: `onEvent` receives the wrapper's `event` `CustomEvent`, with `event.detail` shaped as `{ name, payload }`
248
327
  - **Status hook**: `useCortiEmbeddedStatus(ref)` keeps latest status/reactive state
249
328
  - **Multi-instance safety**: API methods are scoped to the ref you pass
@@ -302,7 +381,7 @@ function Example() {
302
381
  const run = async () => {
303
382
  await api.auth({ access_token: '...', token_type: 'Bearer' });
304
383
  const created = await api.createInteraction({ encounter: { ... } });
305
- await api.navigate(`/session/${created.id}`);
384
+ await api.navigate({ path: `/session/${created.id}` });
306
385
  };
307
386
 
308
387
  return (
@@ -316,6 +395,8 @@ function Example() {
316
395
 
317
396
  For detailed React usage examples, see [docs/react-usage.md](./docs/react-usage.md).
318
397
 
398
+ For configuration migration details, see [docs/migration-guide.md](./docs/migration-guide.md) and [docs/deprecation-timeline.md](./docs/deprecation-timeline.md).
399
+
319
400
  ## Package Structure
320
401
 
321
402
  - **Default export**: Web component only (`dist/web-bundle.js`, readable non-minified bundle)
@@ -1,12 +1,24 @@
1
1
  import type { Corti } from "@corti/sdk";
2
2
  import { LitElement, type PropertyValues } from "lit";
3
- import type { ConfigureAppPayload, ConfigureAppResponse, CreateInteractionPayload, SetCredentialsPayload, CortiEmbeddedAPI, InteractionDetails, SessionConfig, User, GetStatusResponse, GetTemplatesResponse, KeycloakTokenResponse } from "./types";
3
+ import type { ConfigureApplicationPayload, ConfigureApplicationResponse, ConfigurePayload, ConfigureResponse, CreateInteractionPayload, DeviceLinkTokenResponse, NavigatePayload, SetInteractionOptionsPayload, SetCredentialsPayload, CortiEmbeddedAPI, InteractionDetails, SessionConfig, User, GetStatusResponse, GetTemplatesResponse, KeycloakTokenResponse, ShowDeviceLinkQRResponse } from "./public-types.js";
4
+ type DOMEventListener = ((event: Event) => void) | {
5
+ handleEvent(event: Event): void;
6
+ };
7
+ type DOMAddEventListenerOptions = boolean | {
8
+ capture?: boolean;
9
+ once?: boolean;
10
+ passive?: boolean;
11
+ signal?: AbortSignal;
12
+ };
4
13
  export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAPI {
5
14
  static styles: import("lit").CSSResult[];
6
15
  visibility: string;
7
16
  baseURL: string;
8
17
  private postMessageHandler;
9
18
  private normalizedBaseURL;
19
+ private warnedDeprecatedEventSubscriptions;
20
+ addEventListener(type: string, callback: DOMEventListener, options?: DOMAddEventListenerOptions): void;
21
+ private warnDeprecatedEventSubscription;
10
22
  private getIframeAllowPolicy;
11
23
  connectedCallback(): void;
12
24
  disconnectedCallback(): void;
@@ -14,6 +26,7 @@ export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAP
14
26
  private dispatchPublicEvent;
15
27
  private dispatchEmbeddedEvent;
16
28
  private dispatchErrorEvent;
29
+ private static warnDeprecatedAPI;
17
30
  private isRealIframeLoad;
18
31
  private handleIframeLoad;
19
32
  private getIframe;
@@ -44,10 +57,10 @@ export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAP
44
57
  addFacts(facts: Corti.FactsCreateInput[]): Promise<void>;
45
58
  /**
46
59
  * Navigate to a specific path within the embedded UI
47
- * @param path Path to navigate to
60
+ * @param payload Navigation request payload or legacy path string
48
61
  * @returns Promise that resolves when navigation is complete
49
62
  */
50
- navigate(path: string): Promise<void>;
63
+ navigate(payload: NavigatePayload | string): Promise<void>;
51
64
  /**
52
65
  * Start recording
53
66
  * @returns Promise that resolves when recording starts
@@ -68,7 +81,19 @@ export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAP
68
81
  * @param config Component configuration
69
82
  * @returns Promise that resolves when configuration is applied
70
83
  */
71
- configure(config: ConfigureAppPayload): Promise<ConfigureAppResponse>;
84
+ configureApp(config: ConfigureApplicationPayload): Promise<ConfigureApplicationResponse>;
85
+ /**
86
+ * Configure the component
87
+ * @param config Component configuration
88
+ * @returns Promise that resolves when configuration is applied
89
+ */
90
+ configure(config: ConfigurePayload): Promise<ConfigureResponse>;
91
+ /**
92
+ * Set one-shot interaction options for the embedded instance.
93
+ * @param config Interaction/session-level options
94
+ * @returns Promise that resolves when options are applied
95
+ */
96
+ setInteractionOptions(config: SetInteractionOptionsPayload): Promise<void>;
72
97
  /**
73
98
  * Set authentication credentials without triggering auth flow
74
99
  * @param credentials Authentication credentials to store
@@ -87,6 +112,12 @@ export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAP
87
112
  * Get templates
88
113
  */
89
114
  getTemplates(): Promise<GetTemplatesResponse>;
115
+ /**
116
+ * Show the device-link QR code in the embedded UI
117
+ * @param payload Device-link token response to render as a QR code
118
+ * @returns Promise resolving to the rendered QR code state
119
+ */
120
+ showDeviceLinkQR(payload: DeviceLinkTokenResponse): Promise<ShowDeviceLinkQRResponse>;
90
121
  /**
91
122
  * Check the current status of the iframe and PostMessageHandler
92
123
  * Useful for debugging
@@ -105,3 +136,4 @@ export declare class CortiEmbedded extends LitElement implements CortiEmbeddedAP
105
136
  };
106
137
  render(): import("lit-html").TemplateResult<1>;
107
138
  }
139
+ export {};
@@ -13,12 +13,41 @@ import { buildEmbeddedUrl, isRealEmbeddedLoad } from "./utils/embedUrl.js";
13
13
  import { formatError } from "./utils/errorFormatter.js";
14
14
  import { PostMessageHandler, } from "./utils/PostMessageHandler.js";
15
15
  const IFRAME_SANDBOX_POLICY = "allow-forms allow-modals allow-scripts allow-same-origin";
16
+ const DEPRECATION_TIMELINE_URL = "https://docs.corti.ai/assistant/deprecation-timeline";
17
+ const CONFIGURATION_MIGRATION_URL = "https://docs.corti.ai/assistant/configuration-migration";
18
+ const DEPRECATED_EVENT_SUBSCRIPTIONS = new Set([
19
+ "ready",
20
+ "loaded",
21
+ "recordingStarted",
22
+ "recordingStopped",
23
+ "documentGenerated",
24
+ "documentUpdated",
25
+ "documentSynced",
26
+ "authChanged",
27
+ "interactionCreated",
28
+ "navigationChanged",
29
+ "usage",
30
+ "embedded-event",
31
+ ]);
16
32
  export class CortiEmbedded extends LitElement {
17
33
  constructor() {
18
34
  super(...arguments);
19
35
  this.visibility = "hidden";
20
36
  this.postMessageHandler = null;
21
37
  this.normalizedBaseURL = null;
38
+ this.warnedDeprecatedEventSubscriptions = new Set();
39
+ }
40
+ addEventListener(type, callback, options) {
41
+ this.warnDeprecatedEventSubscription(type);
42
+ super.addEventListener(type, callback, options);
43
+ }
44
+ warnDeprecatedEventSubscription(eventName) {
45
+ if (!DEPRECATED_EVENT_SUBSCRIPTIONS.has(eventName) ||
46
+ this.warnedDeprecatedEventSubscriptions.has(eventName)) {
47
+ return;
48
+ }
49
+ this.warnedDeprecatedEventSubscriptions.add(eventName);
50
+ console.warn(`[Corti Embedded] The '${eventName}' event subscription is deprecated and will be removed in a future release. Subscribe to the canonical 'event' stream instead. See ${DEPRECATION_TIMELINE_URL}.`);
22
51
  }
23
52
  // eslint-disable-next-line class-methods-use-this
24
53
  getIframeAllowPolicy(normalizedBaseURL) {
@@ -109,6 +138,9 @@ export class CortiEmbedded extends LitElement {
109
138
  dispatchErrorEvent(error) {
110
139
  this.dispatchPublicEvent("error", error);
111
140
  }
141
+ static warnDeprecatedAPI(methodName, replacement) {
142
+ console.warn(`[Corti Embedded] ${methodName} is deprecated and will be removed in a future release. Use ${replacement} instead. See ${CONFIGURATION_MIGRATION_URL} and ${DEPRECATION_TIMELINE_URL}.`);
143
+ }
112
144
  isRealIframeLoad(iframe) {
113
145
  const src = iframe.getAttribute("src") || "";
114
146
  if (!this.normalizedBaseURL)
@@ -250,6 +282,7 @@ export class CortiEmbedded extends LitElement {
250
282
  throw new Error("Component not ready");
251
283
  }
252
284
  try {
285
+ CortiEmbedded.warnDeprecatedAPI("configureSession()", "setInteractionOptions()");
253
286
  const payload = {
254
287
  defaultLanguage: config.defaultLanguage,
255
288
  defaultOutputLanguage: config.defaultOutputLanguage,
@@ -293,20 +326,20 @@ export class CortiEmbedded extends LitElement {
293
326
  }
294
327
  /**
295
328
  * Navigate to a specific path within the embedded UI
296
- * @param path Path to navigate to
329
+ * @param payload Navigation request payload or legacy path string
297
330
  * @returns Promise that resolves when navigation is complete
298
331
  */
299
- async navigate(path) {
332
+ async navigate(payload) {
300
333
  if (!this.postMessageHandler) {
301
334
  throw new Error("Component not ready");
302
335
  }
303
336
  try {
304
- const payload = { path };
337
+ const normalizedPayload = typeof payload === "string" ? { path: payload } : payload;
305
338
  await this.postMessageHandler.postMessage({
306
339
  type: "CORTI_EMBEDDED",
307
340
  version: "v1",
308
341
  action: "navigate",
309
- payload,
342
+ payload: normalizedPayload,
310
343
  });
311
344
  }
312
345
  catch (error) {
@@ -388,6 +421,32 @@ export class CortiEmbedded extends LitElement {
388
421
  throw new Error(JSON.stringify(formattedError));
389
422
  }
390
423
  }
424
+ /**
425
+ * Configure the component
426
+ * @param config Component configuration
427
+ * @returns Promise that resolves when configuration is applied
428
+ */
429
+ async configureApp(config) {
430
+ if (!this.postMessageHandler) {
431
+ throw new Error("Component not ready");
432
+ }
433
+ try {
434
+ const response = await this.postMessageHandler.postMessage({
435
+ type: "CORTI_EMBEDDED",
436
+ version: "v1",
437
+ action: "configureApp",
438
+ payload: config,
439
+ });
440
+ if (response.success && response.payload) {
441
+ return response.payload;
442
+ }
443
+ throw new Error(response.error);
444
+ }
445
+ catch (error) {
446
+ const formattedError = formatError(error, "Failed to configure app");
447
+ throw new Error(JSON.stringify(formattedError));
448
+ }
449
+ }
391
450
  /**
392
451
  * Configure the component
393
452
  * @param config Component configuration
@@ -398,6 +457,7 @@ export class CortiEmbedded extends LitElement {
398
457
  throw new Error("Component not ready");
399
458
  }
400
459
  try {
460
+ CortiEmbedded.warnDeprecatedAPI("configure()", "configureApp()");
401
461
  const response = await this.postMessageHandler.postMessage({
402
462
  type: "CORTI_EMBEDDED",
403
463
  version: "v1",
@@ -414,6 +474,31 @@ export class CortiEmbedded extends LitElement {
414
474
  throw new Error(JSON.stringify(formattedError));
415
475
  }
416
476
  }
477
+ /**
478
+ * Set one-shot interaction options for the embedded instance.
479
+ * @param config Interaction/session-level options
480
+ * @returns Promise that resolves when options are applied
481
+ */
482
+ async setInteractionOptions(config) {
483
+ if (!this.postMessageHandler) {
484
+ throw new Error("Component not ready");
485
+ }
486
+ try {
487
+ const response = await this.postMessageHandler.postMessage({
488
+ type: "CORTI_EMBEDDED",
489
+ version: "v1",
490
+ action: "setInteractionOptions",
491
+ payload: config,
492
+ });
493
+ if (response.success === false || response.error) {
494
+ throw new Error(response.error);
495
+ }
496
+ }
497
+ catch (error) {
498
+ const formattedError = formatError(error, "Failed to set interaction options");
499
+ throw new Error(JSON.stringify(formattedError));
500
+ }
501
+ }
417
502
  /**
418
503
  * Set authentication credentials without triggering auth flow
419
504
  * @param credentials Authentication credentials to store
@@ -474,6 +559,32 @@ export class CortiEmbedded extends LitElement {
474
559
  throw new Error(JSON.stringify(formattedError));
475
560
  }
476
561
  }
562
+ /**
563
+ * Show the device-link QR code in the embedded UI
564
+ * @param payload Device-link token response to render as a QR code
565
+ * @returns Promise resolving to the rendered QR code state
566
+ */
567
+ async showDeviceLinkQR(payload) {
568
+ if (!this.postMessageHandler) {
569
+ throw new Error("Component not ready");
570
+ }
571
+ try {
572
+ const response = await this.postMessageHandler.postMessage({
573
+ type: "CORTI_EMBEDDED",
574
+ version: "v1",
575
+ action: "showDeviceLinkQR",
576
+ payload,
577
+ });
578
+ if (response.success && response.payload) {
579
+ return response.payload;
580
+ }
581
+ throw new Error(response.error);
582
+ }
583
+ catch (error) {
584
+ const formattedError = formatError(error, "Failed to show device link QR");
585
+ throw new Error(JSON.stringify(formattedError));
586
+ }
587
+ }
477
588
  /**
478
589
  * Check the current status of the iframe and PostMessageHandler
479
590
  * Useful for debugging
@@ -1 +1 @@
1
- {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AM,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,AAAhC,CAAiC;AAG9C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iDACpB;AAGtB;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACzB","sourcesContent":["/* eslint-disable no-console */\nimport type { Corti } from \"@corti/sdk\";\nimport { html, LitElement, type PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport type {\n AuthResponse,\n AddFactsPayload,\n ConfigureAppPayload,\n ConfigureAppResponse,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n CreateInteractionResponse,\n NavigatePayload,\n SetCredentialsPayload,\n CortiEmbeddedAPI,\n InteractionDetails,\n SessionConfig,\n User,\n GetStatusResponse,\n GetTemplatesResponse,\n KeycloakTokenResponse,\n} from \"./types\";\nimport { baseStyles } from \"./styles/base.js\";\nimport { containerStyles } from \"./styles/container-styles.js\";\nimport { validateAndNormalizeBaseURL } from \"./utils/baseUrl.js\";\nimport { buildEmbeddedUrl, isRealEmbeddedLoad } from \"./utils/embedUrl.js\";\nimport { formatError } from \"./utils/errorFormatter.js\";\nimport {\n PostMessageHandler,\n type PostMessageHandlerCallbacks,\n} from \"./utils/PostMessageHandler.js\";\n\nconst IFRAME_SANDBOX_POLICY =\n \"allow-forms allow-modals allow-scripts allow-same-origin\";\n\nexport class CortiEmbedded extends LitElement implements CortiEmbeddedAPI {\n static styles = [baseStyles, containerStyles];\n\n @property({ type: String, reflect: true })\n visibility = \"hidden\";\n\n @property({ type: String, reflect: true })\n baseURL!: string;\n\n private postMessageHandler: PostMessageHandler | null = null;\n\n private normalizedBaseURL: string | null = null;\n\n // eslint-disable-next-line class-methods-use-this\n private getIframeAllowPolicy(normalizedBaseURL?: string | null): string {\n const permissionTarget = normalizedBaseURL\n ? new URL(normalizedBaseURL).origin\n : \"*\";\n\n return [\n `microphone ${permissionTarget}`,\n `camera ${permissionTarget}`,\n `device-capture ${permissionTarget}`,\n `display-capture ${permissionTarget}`,\n `clipboard-write ${permissionTarget}`,\n ].join(\"; \");\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Ensure baseURL is provided\n if (!this.baseURL) {\n this.dispatchErrorEvent({\n message: \"baseURL is required\",\n });\n return;\n }\n\n // Validate and normalize the initial baseURL early (fail fast)\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n // Dispatch the error event rather than throwing so consumers can handle it\n // via the 'error' event listener without wrapping connectedCallback in try/catch.\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n }\n\n private async setupPostMessageHandler() {\n // Prevent multiple setups\n if (this.postMessageHandler) {\n return;\n }\n\n const iframe = this.getIframe();\n\n if (iframe?.contentWindow) {\n const callbacks: PostMessageHandlerCallbacks = {\n onEvent: event => {\n this.dispatchEmbeddedEvent(event.name, event.payload);\n },\n onError: error => {\n this.dispatchErrorEvent(error);\n },\n };\n\n this.postMessageHandler = new PostMessageHandler(iframe, callbacks);\n } else {\n this.dispatchErrorEvent({\n message: \"No iframe or contentWindow available\",\n });\n }\n }\n\n private dispatchPublicEvent(event: string, data: unknown) {\n this.dispatchEvent(new CustomEvent(event, { detail: data }));\n }\n\n private dispatchEmbeddedEvent(rawEventName: string, payload: unknown) {\n if (rawEventName === \"ready\" || rawEventName === \"loaded\") return;\n // Pass all other events through as raw DOM events for direct listeners.\n this.dispatchPublicEvent(rawEventName, payload);\n\n // Forward supported embedded events through the generic 'event' stream so\n // consumers can observe them without subscribing to each raw event name.\n this.dispatchPublicEvent(\"event\", {\n name: rawEventName,\n payload,\n });\n\n // Also emit the legacy 'embedded-event' stream for backward compatibility.\n // This allows existing integrations listening for 'embedded-event' to continue\n // working while newer consumers can use the 'event' stream.\n this.dispatchPublicEvent(\"embedded-event\", {\n name: rawEventName,\n payload,\n });\n }\n\n private dispatchErrorEvent(error: {\n message: string;\n code?: string;\n details?: unknown;\n }) {\n this.dispatchPublicEvent(\"error\", error);\n }\n\n private isRealIframeLoad(iframe: HTMLIFrameElement): boolean {\n const src = iframe.getAttribute(\"src\") || \"\";\n if (!this.normalizedBaseURL) return false;\n return isRealEmbeddedLoad(src, this.normalizedBaseURL);\n }\n\n private async handleIframeLoad(event: Event) {\n const iframe = event.target as HTMLIFrameElement | null;\n if (!iframe) {\n return;\n }\n // Only initialize on real URL load, ignore about:blank\n if (!this.isRealIframeLoad(iframe)) {\n return;\n }\n try {\n await this.setupPostMessageHandler();\n } catch (error) {\n this.dispatchErrorEvent({\n message: `Failed to setup PostMessageHandler on iframe load: ${error}`,\n });\n }\n }\n\n private getIframe(): HTMLIFrameElement | null {\n return this.shadowRoot?.querySelector(\"iframe\") || null;\n }\n\n protected updated(changedProps: PropertyValues) {\n super.updated(changedProps);\n if (changedProps.has(\"baseURL\")) {\n // Tear down the existing handler; the new one is created in handleIframeLoad\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n\n // Validate the new URL\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.normalizedBaseURL = null;\n const iframe = this.getIframe();\n if (iframe) {\n iframe.setAttribute(\"src\", \"about:blank\");\n }\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n return;\n }\n\n // Update the iframe to the new URL\n const iframe = this.getIframe();\n if (iframe) {\n const expected = buildEmbeddedUrl(this.normalizedBaseURL);\n iframe.setAttribute(\"allow\", this.getIframeAllowPolicy(expected));\n if (iframe.getAttribute(\"src\") !== expected) {\n iframe.setAttribute(\"src\", expected);\n }\n }\n }\n }\n\n // Public API Implementation\n\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n async auth(credentials: KeycloakTokenResponse): Promise<User> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: KeycloakTokenResponse = {\n access_token: credentials.access_token,\n token_type: credentials.token_type,\n expires_at: credentials.expires_at,\n expires_in: credentials.expires_in,\n refresh_expires_in: credentials.refresh_expires_in,\n refresh_token: credentials.refresh_token,\n id_token: credentials.id_token,\n \"not-before-policy\": credentials[\"not-before-policy\"],\n session_state: credentials.session_state,\n scope: credentials.scope,\n profile: credentials.profile,\n };\n\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"auth\",\n payload,\n });\n\n if (response.success && response.payload) {\n return (response.payload as AuthResponse).user;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Authentication failed\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n async createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"createInteraction\",\n payload: encounter,\n });\n\n if (response.success && response.payload) {\n const result = response.payload as CreateInteractionResponse;\n return {\n id: result.id,\n createdAt: result.createdAt,\n };\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to create interaction\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n */\n async configureSession(config: SessionConfig): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: ConfigureSessionPayload = {\n defaultLanguage: config.defaultLanguage,\n defaultOutputLanguage: config.defaultOutputLanguage,\n defaultTemplateKey: config.defaultTemplateKey,\n defaultMode: config.defaultMode,\n };\n\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureSession\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure session\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n async addFacts(facts: Corti.FactsCreateInput[]): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: AddFactsPayload = { facts };\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"addFacts\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to add facts\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param path Path to navigate to\n * @returns Promise that resolves when navigation is complete\n */\n async navigate(path: string): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: NavigatePayload = { path };\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"navigate\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to navigate\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n async startRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"startRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to start recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n async stopRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"stopRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to stop recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n async getStatus(): Promise<GetStatusResponse> {\n if (!this.postMessageHandler) {\n return {\n auth: {\n isAuthenticated: false,\n user: undefined,\n },\n currentUrl: \"\",\n interaction: null,\n };\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getStatus\",\n payload: {},\n });\n\n if (response.success && response.payload) {\n return response.payload as GetStatusResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get status\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configure(config: ConfigureAppPayload): Promise<ConfigureAppResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configure\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureAppResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to configure component\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n async setCredentials(credentials: SetCredentialsPayload): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n if (!credentials.password) {\n throw new Error(\"Password is required\");\n }\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setCredentials\",\n payload: credentials,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to set credentials\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Show the embedded UI\n */\n show(): void {\n this.visibility = \"visible\";\n }\n\n /**\n * Hide the embedded UI\n */\n hide(): void {\n this.visibility = \"hidden\";\n }\n\n /**\n * Get templates\n */\n async getTemplates(): Promise<GetTemplatesResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getTemplates\",\n });\n\n if (response.success && response.payload) {\n return response.payload as GetTemplatesResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get templates\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Check the current status of the iframe and PostMessageHandler\n * Useful for debugging\n * @deprecated Use getStatus() instead\n */\n getDebugStatus() {\n const iframe = this.getIframe();\n return {\n ready: iframe?.contentDocument?.readyState === \"complete\",\n iframeExists: !!iframe,\n iframeSrc: iframe?.src,\n iframeContentWindow: !!iframe?.contentWindow,\n iframeContentDocument: !!iframe?.contentDocument,\n iframeReadyState: iframe?.contentDocument?.readyState,\n postMessageHandlerExists: !!this.postMessageHandler,\n postMessageHandlerReady: this.postMessageHandler?.ready || false,\n baseURL: this.baseURL,\n };\n }\n\n render() {\n // Use the pre-validated normalizedBaseURL so render() never throws.\n // normalizedBaseURL is set in connectedCallback (before first render) and\n // kept up to date by updated() on each baseURL change.\n if (!this.normalizedBaseURL) {\n return html``;\n }\n\n return html`\n <iframe\n src=${buildEmbeddedUrl(this.normalizedBaseURL)}\n title=\"Corti Embedded UI\"\n sandbox=${IFRAME_SANDBOX_POLICY}\n allow=${this.getIframeAllowPolicy(this.normalizedBaseURL)}\n @load=${(event: Event) => this.handleIframeLoad(event)}\n @unload=${() => this.postMessageHandler?.destroy()}\n style=${this.visibility === \"hidden\"\n ? \"display: none;\"\n : \"display: block;\"}\n ></iframe>\n `;\n }\n}\n"]}
1
+ {"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C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;8CACzB","sourcesContent":["/* eslint-disable no-console */\nimport type { Corti } from \"@corti/sdk\";\nimport { html, LitElement, type PropertyValues } from \"lit\";\nimport { property } from \"lit/decorators.js\";\nimport type {\n AuthResponse,\n AddFactsPayload,\n ConfigureApplicationPayload,\n ConfigureApplicationResponse,\n ConfigurePayload,\n ConfigureResponse,\n ConfigureSessionPayload,\n CreateInteractionPayload,\n CreateInteractionResponse,\n DeviceLinkTokenResponse,\n NavigatePayload,\n SetInteractionOptionsPayload,\n SetCredentialsPayload,\n CortiEmbeddedAPI,\n InteractionDetails,\n SessionConfig,\n User,\n GetStatusResponse,\n GetTemplatesResponse,\n KeycloakTokenResponse,\n ShowDeviceLinkQRResponse,\n} from \"./public-types.js\";\nimport { baseStyles } from \"./styles/base.js\";\nimport { containerStyles } from \"./styles/container-styles.js\";\nimport { validateAndNormalizeBaseURL } from \"./utils/baseUrl.js\";\nimport { buildEmbeddedUrl, isRealEmbeddedLoad } from \"./utils/embedUrl.js\";\nimport { formatError } from \"./utils/errorFormatter.js\";\nimport {\n PostMessageHandler,\n type PostMessageHandlerCallbacks,\n} from \"./utils/PostMessageHandler.js\";\n\nconst IFRAME_SANDBOX_POLICY =\n \"allow-forms allow-modals allow-scripts allow-same-origin\";\n\nconst DEPRECATION_TIMELINE_URL =\n \"https://docs.corti.ai/assistant/deprecation-timeline\";\n\nconst CONFIGURATION_MIGRATION_URL =\n \"https://docs.corti.ai/assistant/configuration-migration\";\n\nconst DEPRECATED_EVENT_SUBSCRIPTIONS = new Set([\n \"ready\",\n \"loaded\",\n \"recordingStarted\",\n \"recordingStopped\",\n \"documentGenerated\",\n \"documentUpdated\",\n \"documentSynced\",\n \"authChanged\",\n \"interactionCreated\",\n \"navigationChanged\",\n \"usage\",\n \"embedded-event\",\n]);\n\ntype DOMEventListener =\n | ((event: Event) => void)\n | { handleEvent(event: Event): void };\n\ntype DOMAddEventListenerOptions =\n | boolean\n | {\n capture?: boolean;\n once?: boolean;\n passive?: boolean;\n signal?: AbortSignal;\n };\n\nexport class CortiEmbedded extends LitElement implements CortiEmbeddedAPI {\n static styles = [baseStyles, containerStyles];\n\n @property({ type: String, reflect: true })\n visibility = \"hidden\";\n\n @property({ type: String, reflect: true })\n baseURL!: string;\n\n private postMessageHandler: PostMessageHandler | null = null;\n\n private normalizedBaseURL: string | null = null;\n\n private warnedDeprecatedEventSubscriptions = new Set<string>();\n\n addEventListener(\n type: string,\n callback: DOMEventListener,\n options?: DOMAddEventListenerOptions,\n ): void {\n this.warnDeprecatedEventSubscription(type);\n super.addEventListener(type, callback, options);\n }\n\n private warnDeprecatedEventSubscription(eventName: string): void {\n if (\n !DEPRECATED_EVENT_SUBSCRIPTIONS.has(eventName) ||\n this.warnedDeprecatedEventSubscriptions.has(eventName)\n ) {\n return;\n }\n\n this.warnedDeprecatedEventSubscriptions.add(eventName);\n console.warn(\n `[Corti Embedded] The '${eventName}' event subscription is deprecated and will be removed in a future release. Subscribe to the canonical 'event' stream instead. See ${DEPRECATION_TIMELINE_URL}.`,\n );\n }\n\n // eslint-disable-next-line class-methods-use-this\n private getIframeAllowPolicy(normalizedBaseURL?: string | null): string {\n const permissionTarget = normalizedBaseURL\n ? new URL(normalizedBaseURL).origin\n : \"*\";\n\n return [\n `microphone ${permissionTarget}`,\n `camera ${permissionTarget}`,\n `device-capture ${permissionTarget}`,\n `display-capture ${permissionTarget}`,\n `clipboard-write ${permissionTarget}`,\n ].join(\"; \");\n }\n\n connectedCallback() {\n super.connectedCallback();\n\n // Ensure baseURL is provided\n if (!this.baseURL) {\n this.dispatchErrorEvent({\n message: \"baseURL is required\",\n });\n return;\n }\n\n // Validate and normalize the initial baseURL early (fail fast)\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n // Dispatch the error event rather than throwing so consumers can handle it\n // via the 'error' event listener without wrapping connectedCallback in try/catch.\n }\n }\n\n disconnectedCallback() {\n super.disconnectedCallback();\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n }\n\n private async setupPostMessageHandler() {\n // Prevent multiple setups\n if (this.postMessageHandler) {\n return;\n }\n\n const iframe = this.getIframe();\n\n if (iframe?.contentWindow) {\n const callbacks: PostMessageHandlerCallbacks = {\n onEvent: event => {\n this.dispatchEmbeddedEvent(event.name, event.payload);\n },\n onError: error => {\n this.dispatchErrorEvent(error);\n },\n };\n\n this.postMessageHandler = new PostMessageHandler(iframe, callbacks);\n } else {\n this.dispatchErrorEvent({\n message: \"No iframe or contentWindow available\",\n });\n }\n }\n\n private dispatchPublicEvent(event: string, data: unknown) {\n this.dispatchEvent(new CustomEvent(event, { detail: data }));\n }\n\n private dispatchEmbeddedEvent(rawEventName: string, payload: unknown) {\n if (rawEventName === \"ready\" || rawEventName === \"loaded\") return;\n // Pass all other events through as raw DOM events for direct listeners.\n this.dispatchPublicEvent(rawEventName, payload);\n\n // Forward supported embedded events through the generic 'event' stream so\n // consumers can observe them without subscribing to each raw event name.\n this.dispatchPublicEvent(\"event\", {\n name: rawEventName,\n payload,\n });\n\n // Also emit the legacy 'embedded-event' stream for backward compatibility.\n // This allows existing integrations listening for 'embedded-event' to continue\n // working while newer consumers can use the 'event' stream.\n this.dispatchPublicEvent(\"embedded-event\", {\n name: rawEventName,\n payload,\n });\n }\n\n private dispatchErrorEvent(error: {\n message: string;\n code?: string;\n details?: unknown;\n }) {\n this.dispatchPublicEvent(\"error\", error);\n }\n\n private static warnDeprecatedAPI(\n methodName: string,\n replacement: string,\n ): void {\n console.warn(\n `[Corti Embedded] ${methodName} is deprecated and will be removed in a future release. Use ${replacement} instead. See ${CONFIGURATION_MIGRATION_URL} and ${DEPRECATION_TIMELINE_URL}.`,\n );\n }\n\n private isRealIframeLoad(iframe: HTMLIFrameElement): boolean {\n const src = iframe.getAttribute(\"src\") || \"\";\n if (!this.normalizedBaseURL) return false;\n return isRealEmbeddedLoad(src, this.normalizedBaseURL);\n }\n\n private async handleIframeLoad(event: Event) {\n const iframe = event.target as HTMLIFrameElement | null;\n if (!iframe) {\n return;\n }\n // Only initialize on real URL load, ignore about:blank\n if (!this.isRealIframeLoad(iframe)) {\n return;\n }\n try {\n await this.setupPostMessageHandler();\n } catch (error) {\n this.dispatchErrorEvent({\n message: `Failed to setup PostMessageHandler on iframe load: ${error}`,\n });\n }\n }\n\n private getIframe(): HTMLIFrameElement | null {\n return this.shadowRoot?.querySelector(\"iframe\") || null;\n }\n\n protected updated(changedProps: PropertyValues) {\n super.updated(changedProps);\n if (changedProps.has(\"baseURL\")) {\n // Tear down the existing handler; the new one is created in handleIframeLoad\n if (this.postMessageHandler) {\n this.postMessageHandler.destroy();\n this.postMessageHandler = null;\n }\n\n // Validate the new URL\n try {\n this.normalizedBaseURL = validateAndNormalizeBaseURL(this.baseURL);\n } catch (error) {\n this.normalizedBaseURL = null;\n const iframe = this.getIframe();\n if (iframe) {\n iframe.setAttribute(\"src\", \"about:blank\");\n }\n this.dispatchErrorEvent({\n message: (error as Error).message || \"Invalid baseURL\",\n });\n return;\n }\n\n // Update the iframe to the new URL\n const iframe = this.getIframe();\n if (iframe) {\n const expected = buildEmbeddedUrl(this.normalizedBaseURL);\n iframe.setAttribute(\"allow\", this.getIframeAllowPolicy(expected));\n if (iframe.getAttribute(\"src\") !== expected) {\n iframe.setAttribute(\"src\", expected);\n }\n }\n }\n }\n\n // Public API Implementation\n\n /**\n * Authenticate with the Corti system\n * @param credentials Authentication credentials\n * @returns Promise resolving to user information\n */\n async auth(credentials: KeycloakTokenResponse): Promise<User> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: KeycloakTokenResponse = {\n access_token: credentials.access_token,\n token_type: credentials.token_type,\n expires_at: credentials.expires_at,\n expires_in: credentials.expires_in,\n refresh_expires_in: credentials.refresh_expires_in,\n refresh_token: credentials.refresh_token,\n id_token: credentials.id_token,\n \"not-before-policy\": credentials[\"not-before-policy\"],\n session_state: credentials.session_state,\n scope: credentials.scope,\n profile: credentials.profile,\n };\n\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"auth\",\n payload,\n });\n\n if (response.success && response.payload) {\n return (response.payload as AuthResponse).user;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Authentication failed\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Create a new interaction\n * @param encounter Encounter request data\n * @returns Promise resolving to interaction details\n */\n async createInteraction(\n encounter: CreateInteractionPayload,\n ): Promise<InteractionDetails> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"createInteraction\",\n payload: encounter,\n });\n\n if (response.success && response.payload) {\n const result = response.payload as CreateInteractionResponse;\n return {\n id: result.id,\n createdAt: result.createdAt,\n };\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to create interaction\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the current session\n * @param config Session configuration\n * @returns Promise that resolves when configuration is complete\n */\n async configureSession(config: SessionConfig): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n CortiEmbedded.warnDeprecatedAPI(\n \"configureSession()\",\n \"setInteractionOptions()\",\n );\n const payload: ConfigureSessionPayload = {\n defaultLanguage: config.defaultLanguage,\n defaultOutputLanguage: config.defaultOutputLanguage,\n defaultTemplateKey: config.defaultTemplateKey,\n defaultMode: config.defaultMode,\n };\n\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureSession\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure session\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Add facts to the current session\n * @param facts Array of facts to add\n * @returns Promise that resolves when facts are added\n */\n async addFacts(facts: Corti.FactsCreateInput[]): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const payload: AddFactsPayload = { facts };\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"addFacts\",\n payload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to add facts\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Navigate to a specific path within the embedded UI\n * @param payload Navigation request payload or legacy path string\n * @returns Promise that resolves when navigation is complete\n */\n async navigate(payload: NavigatePayload | string): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const normalizedPayload: NavigatePayload =\n typeof payload === \"string\" ? { path: payload } : payload;\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"navigate\",\n payload: normalizedPayload,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to navigate\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Start recording\n * @returns Promise that resolves when recording starts\n */\n async startRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"startRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to start recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Stop recording\n * @returns Promise that resolves when recording stops\n */\n async stopRecording(): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"stopRecording\",\n payload: {},\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to stop recording\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Get current component status\n * @returns Promise resolving to current status\n */\n async getStatus(): Promise<GetStatusResponse> {\n if (!this.postMessageHandler) {\n return {\n auth: {\n isAuthenticated: false,\n user: undefined,\n },\n currentUrl: \"\",\n interaction: null,\n };\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getStatus\",\n payload: {},\n });\n\n if (response.success && response.payload) {\n return response.payload as GetStatusResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get status\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configureApp(\n config: ConfigureApplicationPayload,\n ): Promise<ConfigureApplicationResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configureApp\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureApplicationResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to configure app\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Configure the component\n * @param config Component configuration\n * @returns Promise that resolves when configuration is applied\n */\n async configure(config: ConfigurePayload): Promise<ConfigureResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n CortiEmbedded.warnDeprecatedAPI(\"configure()\", \"configureApp()\");\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"configure\",\n payload: config,\n });\n\n if (response.success && response.payload) {\n return response.payload as ConfigureResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to configure component\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set one-shot interaction options for the embedded instance.\n * @param config Interaction/session-level options\n * @returns Promise that resolves when options are applied\n */\n async setInteractionOptions(\n config: SetInteractionOptionsPayload,\n ): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setInteractionOptions\",\n payload: config,\n });\n\n if (response.success === false || response.error) {\n throw new Error(response.error);\n }\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to set interaction options\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Set authentication credentials without triggering auth flow\n * @param credentials Authentication credentials to store\n * @returns Promise that resolves when credentials are set\n */\n async setCredentials(credentials: SetCredentialsPayload): Promise<void> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n if (!credentials.password) {\n throw new Error(\"Password is required\");\n }\n await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"setCredentials\",\n payload: credentials,\n });\n } catch (error) {\n const formattedError = formatError(error, \"Failed to set credentials\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Show the embedded UI\n */\n show(): void {\n this.visibility = \"visible\";\n }\n\n /**\n * Hide the embedded UI\n */\n hide(): void {\n this.visibility = \"hidden\";\n }\n\n /**\n * Get templates\n */\n async getTemplates(): Promise<GetTemplatesResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"getTemplates\",\n });\n\n if (response.success && response.payload) {\n return response.payload as GetTemplatesResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(error, \"Failed to get templates\");\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Show the device-link QR code in the embedded UI\n * @param payload Device-link token response to render as a QR code\n * @returns Promise resolving to the rendered QR code state\n */\n async showDeviceLinkQR(\n payload: DeviceLinkTokenResponse,\n ): Promise<ShowDeviceLinkQRResponse> {\n if (!this.postMessageHandler) {\n throw new Error(\"Component not ready\");\n }\n\n try {\n const response = await this.postMessageHandler.postMessage({\n type: \"CORTI_EMBEDDED\",\n version: \"v1\",\n action: \"showDeviceLinkQR\",\n payload,\n });\n\n if (response.success && response.payload) {\n return response.payload as ShowDeviceLinkQRResponse;\n }\n throw new Error(response.error);\n } catch (error) {\n const formattedError = formatError(\n error,\n \"Failed to show device link QR\",\n );\n throw new Error(JSON.stringify(formattedError));\n }\n }\n\n /**\n * Check the current status of the iframe and PostMessageHandler\n * Useful for debugging\n * @deprecated Use getStatus() instead\n */\n getDebugStatus() {\n const iframe = this.getIframe();\n return {\n ready: iframe?.contentDocument?.readyState === \"complete\",\n iframeExists: !!iframe,\n iframeSrc: iframe?.src,\n iframeContentWindow: !!iframe?.contentWindow,\n iframeContentDocument: !!iframe?.contentDocument,\n iframeReadyState: iframe?.contentDocument?.readyState,\n postMessageHandlerExists: !!this.postMessageHandler,\n postMessageHandlerReady: this.postMessageHandler?.ready || false,\n baseURL: this.baseURL,\n };\n }\n\n render() {\n // Use the pre-validated normalizedBaseURL so render() never throws.\n // normalizedBaseURL is set in connectedCallback (before first render) and\n // kept up to date by updated() on each baseURL change.\n if (!this.normalizedBaseURL) {\n return html``;\n }\n\n return html`\n <iframe\n src=${buildEmbeddedUrl(this.normalizedBaseURL)}\n title=\"Corti Embedded UI\"\n sandbox=${IFRAME_SANDBOX_POLICY}\n allow=${this.getIframeAllowPolicy(this.normalizedBaseURL)}\n @load=${(event: Event) => this.handleIframeLoad(event)}\n @unload=${() => this.postMessageHandler?.destroy()}\n style=${this.visibility === \"hidden\"\n ? \"display: none;\"\n : \"display: block;\"}\n ></iframe>\n `;\n }\n}\n"]}