obi-sdk 0.4.1 → 0.4.2

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.
@@ -1,4 +1,4 @@
1
- import { O as ObiWidget } from "./chunks/obi-widget-58dc98b0.js";
1
+ import { O as ObiWidget } from "./chunks/obi-widget-2ba751b3.js";
2
2
  import "./chunks/types-e0297e7b.js";
3
3
  if (!customElements.get("obi-widget")) {
4
4
  customElements.define("obi-widget", ObiWidget);
@@ -77,18 +77,18 @@ function processQueue() {
77
77
  }
78
78
  }
79
79
  async function loadFonts() {
80
+ await loadFont("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap");
81
+ await loadFont("https://fonts.cdnfonts.com/css/satoshi");
82
+ }
83
+ async function loadFont(fontUrl) {
80
84
  return retryOperation(async () => {
81
85
  if (!document.head) {
82
86
  throw new Error("document.head not available");
83
87
  }
84
- const existingLink = document.head.querySelector('link[href*="fonts.googleapis.com"]');
85
- if (existingLink) {
86
- return;
87
- }
88
88
  const link = document.createElement("link");
89
89
  document.head.querySelectorAll("link[data-obi-font]").forEach((node) => node.remove());
90
90
  link.setAttribute("data-obi-font", "true");
91
- link.href = "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap";
91
+ link.href = fontUrl;
92
92
  link.rel = "stylesheet";
93
93
  return new Promise((resolve, reject) => {
94
94
  const timeout = setTimeout(() => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/core/init.ts"],"sourcesContent":["import { ObiWidget } from \"../ui/components/obi-widget\"\n\nif (!customElements.get(\"obi-widget\")) {\n customElements.define(\"obi-widget\", ObiWidget)\n}\n\n// Retry configuration\nconst RETRY_CONFIG = {\n maxAttempts: 3,\n baseDelay: 200, // ms\n maxDelay: 2000, // ms\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\nfunction getRetryDelay(attempt: number): number {\n const exponentialDelay = RETRY_CONFIG.baseDelay * Math.pow(2, attempt)\n return Math.min(exponentialDelay, RETRY_CONFIG.maxDelay)\n}\n\nasync function retryOperation<T>(\n operation: () => Promise<T> | T,\n operationName: string,\n maxAttempts: number = RETRY_CONFIG.maxAttempts\n): Promise<T> {\n let lastError: Error | null = null\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await operation()\n } catch (error) {\n lastError = error as Error\n console.warn(`${operationName} failed (attempt ${attempt + 1}/${maxAttempts}):`, error)\n\n if (attempt < maxAttempts - 1) {\n const delayMs = getRetryDelay(attempt)\n await delay(delayMs)\n }\n }\n }\n\n throw new Error(`${operationName} failed after ${maxAttempts} attempts: ${lastError?.message}`)\n}\n\nfunction mountSDK(): void {\n const w = window as any\n if (typeof w.ObiSDK === \"function\" || typeof w.ObiSDK === \"object\") {\n return\n }\n\n // Initialize the SDK\n w.ObiSDK = function (command: string, config?: any) {\n if (command === \"update\" && config) {\n w.obiWidgetConfig = {\n ...w.obiWidgetConfig,\n ...config,\n }\n }\n }\n w.ObiSDK.q = []\n}\n\n// Mount the widget if not already present\nasync function mountWidget(): Promise<void> {\n return retryOperation(async () => {\n if (document.querySelector(\"obi-widget\")) {\n return // Already mounted\n }\n\n if (!document.body) {\n throw new Error(\"document.body not available\")\n }\n\n const widget = document.createElement(\"obi-widget\")\n document.body.appendChild(widget)\n console.log(\"Obi Widget mounted\")\n }, \"Widget mounting\")\n}\n\n// Optionally process a queue if you want to support it\nfunction processQueue() {\n const w = window as any\n if (w.ObiSDK && Array.isArray(w.ObiSDK.q)) {\n // Process each command in the queue\n w.ObiSDK.q.forEach((args: any[]) => {\n const [command, config] = args\n if (command === \"update\" && config) {\n w.obiWidgetConfig = {\n ...w.obiWidgetConfig,\n ...config,\n }\n }\n })\n w.ObiSDK.q = []\n }\n}\n\nasync function loadFonts(): Promise<void> {\n return retryOperation(async () => {\n if (!document.head) {\n throw new Error(\"document.head not available\")\n }\n\n // Check if fonts are already loaded\n const existingLink = document.head.querySelector('link[href*=\"fonts.googleapis.com\"]')\n if (existingLink) {\n return // Already loaded\n }\n\n const link = document.createElement(\"link\")\n // Remove any previous failed link for a clean retry\n document.head.querySelectorAll(\"link[data-obi-font]\").forEach((node) => node.remove())\n link.setAttribute(\"data-obi-font\", \"true\")\n\n link.href =\n \"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap\"\n link.rel = \"stylesheet\"\n\n // Wait for font load or timeout\n return new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(new Error(\"Font loading timeout\"))\n }, 5000)\n\n link.onload = () => {\n clearTimeout(timeout)\n resolve()\n }\n\n link.onerror = () => {\n clearTimeout(timeout)\n reject(new Error(\"Font loading failed\"))\n }\n\n document.head.appendChild(link)\n })\n }, \"Font loading\")\n}\n\nasync function safeInitialize(): Promise<void> {\n try {\n mountSDK()\n await loadFonts()\n await mountWidget()\n processQueue()\n console.log(\"Obi Widget initialized successfully\")\n } catch (error) {\n console.error(\"Obi Widget initialization failed:\", error)\n // Still try to mount basic functionality\n try {\n mountSDK()\n processQueue()\n console.log(\"Obi Widget fallback initialization completed\")\n } catch (fallbackError) {\n console.error(\"Obi Widget fallback initialization failed:\", fallbackError)\n }\n }\n}\n\n// Main init\nexport function initializeObiWidget() {\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n safeInitialize()\n })\n } else {\n safeInitialize()\n }\n}\n\n// Auto-initialize\ninitializeObiWidget()\n"],"names":[],"mappings":"AAEA,SAAA,KAAA,iBAAA;AAAA,OAAA;AAAA,IAAI,CAAC,eAAe,IAAI,YAAY,GAAG;AACtB,iBAAA,OAAO,cAAc,SAAS;AAC/C;AAGA,MAAM,eAAe;AAAA,EACnB,aAAa;AAAA,EACb,WAAW;AAAA;AAAA,EACX,UAAU;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,qCAAqC;AAAA,WAC1C,OAAO;AACN,YAAA,MAAM,qCAAqC,KAAK;AAEpD,QAAA;AACO;AACI;AACb,cAAQ,IAAI,8CAA8C;AAAA,aACnD,eAAe;AACd,cAAA,MAAM,8CAA8C,aAAa;AAAA,IAC3E;AAAA,EACF;AACF;AAGO,SAAS,sBAAsB;AAChC,MAAA,SAAS,eAAe,WAAW;AAC5B,aAAA,iBAAiB,oBAAoB,MAAM;AACnC;IAAA,CAChB;AAAA,EAAA,OACI;AACU;EACjB;AACF;AAGA,oBAAoB;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/core/init.ts"],"sourcesContent":["import { ObiWidget } from \"../ui/components/obi-widget\"\n\nif (!customElements.get(\"obi-widget\")) {\n customElements.define(\"obi-widget\", ObiWidget)\n}\n\n// Retry configuration\nconst RETRY_CONFIG = {\n maxAttempts: 3,\n baseDelay: 200, // ms\n maxDelay: 2000, // ms\n}\n\nfunction delay(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n\nfunction getRetryDelay(attempt: number): number {\n const exponentialDelay = RETRY_CONFIG.baseDelay * Math.pow(2, attempt)\n return Math.min(exponentialDelay, RETRY_CONFIG.maxDelay)\n}\n\nasync function retryOperation<T>(\n operation: () => Promise<T> | T,\n operationName: string,\n maxAttempts: number = RETRY_CONFIG.maxAttempts\n): Promise<T> {\n let lastError: Error | null = null\n\n for (let attempt = 0; attempt < maxAttempts; attempt++) {\n try {\n return await operation()\n } catch (error) {\n lastError = error as Error\n console.warn(`${operationName} failed (attempt ${attempt + 1}/${maxAttempts}):`, error)\n\n if (attempt < maxAttempts - 1) {\n const delayMs = getRetryDelay(attempt)\n await delay(delayMs)\n }\n }\n }\n\n throw new Error(`${operationName} failed after ${maxAttempts} attempts: ${lastError?.message}`)\n}\n\nfunction mountSDK(): void {\n const w = window as any\n if (typeof w.ObiSDK === \"function\" || typeof w.ObiSDK === \"object\") {\n return\n }\n\n // Initialize the SDK\n w.ObiSDK = function (command: string, config?: any) {\n if (command === \"update\" && config) {\n w.obiWidgetConfig = {\n ...w.obiWidgetConfig,\n ...config,\n }\n }\n }\n w.ObiSDK.q = []\n}\n\n// Mount the widget if not already present\nasync function mountWidget(): Promise<void> {\n return retryOperation(async () => {\n if (document.querySelector(\"obi-widget\")) {\n return // Already mounted\n }\n\n if (!document.body) {\n throw new Error(\"document.body not available\")\n }\n\n const widget = document.createElement(\"obi-widget\")\n document.body.appendChild(widget)\n console.log(\"Obi Widget mounted\")\n }, \"Widget mounting\")\n}\n\n// Optionally process a queue if you want to support it\nfunction processQueue() {\n const w = window as any\n if (w.ObiSDK && Array.isArray(w.ObiSDK.q)) {\n // Process each command in the queue\n w.ObiSDK.q.forEach((args: any[]) => {\n const [command, config] = args\n if (command === \"update\" && config) {\n w.obiWidgetConfig = {\n ...w.obiWidgetConfig,\n ...config,\n }\n }\n })\n w.ObiSDK.q = []\n }\n}\n\nasync function loadFonts(): Promise<void> {\n await loadFont(\"https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap\")\n await loadFont(\"https://fonts.cdnfonts.com/css/satoshi\")\n}\n\nasync function loadFont(fontUrl: string): Promise<void> {\n return retryOperation(async () => {\n if (!document.head) {\n throw new Error(\"document.head not available\")\n }\n\n // Check if fonts are already loaded\n // const existingLink = document.head.querySelector('link[href*=\"fonts.googleapis.com\"]')\n // if (existingLink) {\n // return // Already loaded\n // }\n\n const link = document.createElement(\"link\")\n // Remove any previous failed link for a clean retry\n document.head.querySelectorAll(\"link[data-obi-font]\").forEach((node) => node.remove())\n link.setAttribute(\"data-obi-font\", \"true\")\n\n link.href = fontUrl\n link.rel = \"stylesheet\"\n\n // Wait for font load or timeout\n return new Promise<void>((resolve, reject) => {\n const timeout = setTimeout(() => {\n reject(new Error(\"Font loading timeout\"))\n }, 5000)\n\n link.onload = () => {\n clearTimeout(timeout)\n resolve()\n }\n\n link.onerror = () => {\n clearTimeout(timeout)\n reject(new Error(\"Font loading failed\"))\n }\n\n document.head.appendChild(link)\n })\n }, \"Font loading\")\n}\n\nasync function safeInitialize(): Promise<void> {\n try {\n mountSDK()\n await loadFonts()\n await mountWidget()\n processQueue()\n console.log(\"Obi Widget initialized successfully\")\n } catch (error) {\n console.error(\"Obi Widget initialization failed:\", error)\n // Still try to mount basic functionality\n try {\n mountSDK()\n processQueue()\n console.log(\"Obi Widget fallback initialization completed\")\n } catch (fallbackError) {\n console.error(\"Obi Widget fallback initialization failed:\", fallbackError)\n }\n }\n}\n\n// Main init\nexport function initializeObiWidget() {\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", () => {\n safeInitialize()\n })\n } else {\n safeInitialize()\n }\n}\n\n// Auto-initialize\ninitializeObiWidget()\n"],"names":[],"mappings":"AAEA,SAAA,KAAA,iBAAA;AAAA,OAAA;AAAA,IAAI,CAAC,eAAe,IAAI,YAAY,GAAG;AACtB,iBAAA,OAAO,cAAc,SAAS;AAC/C;AAGA,MAAM,eAAe;AAAA,EACnB,aAAa;AAAA,EACb,WAAW;AAAA;AAAA,EACX,UAAU;AAAA;AACZ;AAEA,SAAS,MAAM,IAA2B;AACxC,SAAO,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,EAAE,CAAC;AACzD;AAEA,SAAS,cAAc,SAAyB;AAC9C,QAAM,mBAAmB,aAAa,YAAY,KAAK,IAAI,GAAG,OAAO;AACrE,SAAO,KAAK,IAAI,kBAAkB,aAAa,QAAQ;AACzD;AAEA,eAAe,eACb,WACA,eACA,cAAsB,aAAa,aACvB;AACZ,MAAI,YAA0B;AAE9B,WAAS,UAAU,GAAG,UAAU,aAAa,WAAW;AAClD,QAAA;AACF,aAAO,MAAM,UAAU;AAAA,aAChB,OAAO;AACF,kBAAA;AACJ,cAAA,KAAK,GAAG,aAAa,oBAAoB,UAAU,CAAC,IAAI,WAAW,MAAM,KAAK;AAElF,UAAA,UAAU,cAAc,GAAG;AACvB,cAAA,UAA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AAC5B,QAAA,CAAC,SAAS,MAAM;AACZ,YAAA,IAAI,MAAM,6BAA6B;AAAA,IAC/C;AAQM,UAAA,OAAO,SAAS,cAAc,MAAM;AAEjC,aAAA,KAAK,iBAAiB,qBAAqB,EAAE,QAAQ,CAAC,SAAS,KAAK,OAAA,CAAQ;AAChF,SAAA,aAAa,iBAAiB,MAAM;AAEzC,SAAK,OAAO;AACZ,SAAK,MAAM;AAGX,WAAO,IAAI,QAAc,CAAC,SAAS,WAAW;AACtC,YAAA,UAAU,WAAW,MAAM;AACxB,eAAA,IAAI,MAAM,sBAAsB,CAAC;AAAA,SACvC,GAAI;AAEP,WAAK,SAAS,MAAM;AAClB,qBAAa,OAAO;AACZ;MAAA;AAGV,WAAK,UAAU,MAAM;AACnB,qBAAa,OAAO;AACb,eAAA,IAAI,MAAM,qBAAqB,CAAC;AAAA,MAAA;AAGhC,eAAA,KAAK,YAAY,IAAI;AAAA,IAAA,CAC/B;AAAA,KACA,cAAc;AACnB;AAEA,eAAe,iBAAgC;AACzC,MAAA;AACO;AACT,UAAM,UAAU;AAChB,UAAM,YAAY;AACL;AACb,YAAQ,IAAI,qCAAqC;AAAA,WAC1C,OAAO;AACN,YAAA,MAAM,qCAAqC,KAAK;AAEpD,QAAA;AACO;AACI;AACb,cAAQ,IAAI,8CAA8C;AAAA,aACnD,eAAe;AACd,cAAA,MAAM,8CAA8C,aAAa;AAAA,IAC3E;AAAA,EACF;AACF;AAGO,SAAS,sBAAsB;AAChC,MAAA,SAAS,eAAe,WAAW;AAC5B,aAAA,iBAAiB,oBAAoB,MAAM;AACnC;IAAA,CAChB;AAAA,EAAA,OACI;AACU;EACjB;AACF;AAGA,oBAAoB;"}
@@ -1,6 +1,6 @@
1
1
  import { S as SDKState } from "./chunks/types-e0297e7b.js";
2
- import { i, n, a as i$1, x } from "./chunks/obi-widget-58dc98b0.js";
3
- import { A, C, c, d, D, N, b, O, S } from "./chunks/obi-widget-58dc98b0.js";
2
+ import { i, n, a as i$1, x } from "./chunks/obi-widget-2ba751b3.js";
3
+ import { A, C, c, d, D, N, b, O, S } from "./chunks/obi-widget-2ba751b3.js";
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
6
  var __decorateClass = (decorators, target, key, kind) => {
@@ -85,14 +85,14 @@ if (!customElements.get("obi-status-widget")) {
85
85
  const statusWidget = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, ObiStatusWidget }, Symbol.toStringTag, { value: "Module" }));
86
86
  function defineCustomElements() {
87
87
  Promise.resolve().then(() => statusWidget);
88
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.o);
89
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.j);
90
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.k);
91
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.e);
92
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.f);
93
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.s);
94
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.g);
95
- import("./chunks/obi-widget-58dc98b0.js").then((n2) => n2.h);
88
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.o);
89
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.j);
90
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.k);
91
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.e);
92
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.f);
93
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.s);
94
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.g);
95
+ import("./chunks/obi-widget-2ba751b3.js").then((n2) => n2.h);
96
96
  }
97
97
  export {
98
98
  A as AudioEqualizer,
@@ -33522,7 +33522,7 @@ class SessionStartModal extends LitElement {
33522
33522
  <p class="subtitle">${this.session.description}</p>
33523
33523
  </div>
33524
33524
 
33525
- <button class="button button-primary" @click=${this.handleStart}>Continue →</button>
33525
+ <button class="button button-primary" @click=${this.handleStart}>Continue</button>
33526
33526
  </div>
33527
33527
  `;
33528
33528
  }
@@ -33531,6 +33531,7 @@ SessionStartModal.styles = css`
33531
33531
  :host {
33532
33532
  display: block;
33533
33533
  font-family: "Inter", sans-serif;
33534
+ box-sizing: border-box;
33534
33535
  }
33535
33536
 
33536
33537
  .backdrop {
@@ -33544,18 +33545,18 @@ SessionStartModal.styles = css`
33544
33545
  }
33545
33546
 
33546
33547
  .container {
33548
+ box-sizing: border-box;
33547
33549
  position: fixed;
33548
33550
  top: 50%;
33549
33551
  left: 50%;
33550
33552
  transform: translate(-50%, -50%);
33551
33553
  z-index: 50;
33552
- gap: 32px;
33553
33554
 
33554
33555
  /* Layout from user specifications */
33555
33556
  display: flex;
33556
33557
  width: 640px;
33557
33558
  min-height: 380px;
33558
- padding: 48px 48px 32px 48px;
33559
+ padding: 32px;
33559
33560
  flex-direction: column;
33560
33561
  justify-content: space-between;
33561
33562
  align-items: center;
@@ -33574,20 +33575,17 @@ SessionStartModal.styles = css`
33574
33575
  flex-direction: column;
33575
33576
  align-items: center;
33576
33577
  text-align: center;
33577
- gap: 16px;
33578
33578
  }
33579
33579
 
33580
33580
  .logo {
33581
33581
  display: flex;
33582
33582
  width: 96px;
33583
33583
  height: 96px;
33584
- padding: 8px;
33585
33584
  justify-content: center;
33586
33585
  align-items: center;
33587
- gap: 8px;
33588
33586
  aspect-ratio: 1/1;
33589
- border-radius: var(--border-radius-lg, 12px);
33590
- background: var(--tailwind-colors-violet-600, #7c3aed);
33587
+ border-radius: 8px;
33588
+ background: var(--obi-primary, #a10fff);
33591
33589
  box-shadow:
33592
33590
  0px 0px 8px 0px rgba(168, 85, 247, 0.12),
33593
33591
  0px 0px 8px 0px rgba(192, 132, 252, 0.24),
@@ -33605,32 +33603,36 @@ SessionStartModal.styles = css`
33605
33603
  }
33606
33604
 
33607
33605
  h1 {
33608
- font-family: "Syne", sans-serif;
33606
+ font-family: "Satoshi", sans-serif;
33609
33607
  font-size: 32px;
33610
33608
  font-weight: 700;
33611
33609
  color: #111827;
33612
33610
  margin: 0;
33611
+ margin-top: 32px;
33612
+ margin-bottom: 16px;
33613
33613
  }
33614
33614
 
33615
33615
  .subtitle {
33616
+ font-family: "Satoshi", sans-serif;
33617
+ font-weight: 300;
33616
33618
  font-size: 16px;
33617
- color: #6b7280;
33618
- line-height: 1.5;
33619
+ color: #18181b;
33620
+ line-height: 1.4;
33619
33621
  margin: 0;
33620
33622
  }
33621
33623
 
33622
33624
  .button {
33625
+ font-family: "Satoshi", sans-serif;
33626
+ font-weight: 400;
33627
+ font-size: 16px;
33623
33628
  padding: 12px 24px;
33624
33629
  border-radius: 8px;
33625
33630
  border: none;
33626
- font-size: 16px;
33627
- font-weight: 500;
33628
33631
  cursor: pointer;
33629
33632
  transition: all 0.2s ease;
33630
33633
  display: flex;
33631
33634
  align-items: center;
33632
33635
  justify-content: center;
33633
- gap: 8px;
33634
33636
  }
33635
33637
 
33636
33638
  .button-primary {
@@ -33654,21 +33656,19 @@ SessionStartModal.styles = css`
33654
33656
 
33655
33657
  .close-button {
33656
33658
  position: absolute;
33657
- top: 16px;
33659
+ top: 12px;
33658
33660
  right: 16px;
33659
33661
  background: none;
33660
33662
  border: none;
33661
33663
  cursor: pointer;
33662
33664
  font-size: 24px;
33663
33665
  color: #6b7280;
33664
- padding: 4px;
33665
- border-radius: 4px;
33666
- transition: all 0.2s ease;
33667
- }
33668
-
33669
- .close-button:hover {
33670
- color: #374151;
33671
- background: #f3f4f6;
33666
+ padding: 0;
33667
+ margin: 0;
33668
+ line-height: 1;
33669
+ display: inline-flex;
33670
+ align-items: center;
33671
+ justify-content: center;
33672
33672
  }
33673
33673
  `;
33674
33674
  __decorateClass$1([
@@ -33694,7 +33694,6 @@ var __decorateClass = (decorators, target, key, kind) => {
33694
33694
  __defProp(target, key, result);
33695
33695
  return result;
33696
33696
  };
33697
- const WIDGET_PARAMS_KEY = "io.obi.widget-parameters";
33698
33697
  class ObiWidget extends LitElement {
33699
33698
  constructor() {
33700
33699
  super();
@@ -33788,9 +33787,12 @@ class ObiWidget extends LitElement {
33788
33787
  url.searchParams.delete(SESSION_URL_PARAM);
33789
33788
  window.history.replaceState({}, "", url.toString());
33790
33789
  try {
33791
- localStorage.removeItem(WIDGET_PARAMS_KEY);
33790
+ if (window.__obiUrlParams) {
33791
+ ;
33792
+ window.__obiUrlParams = null;
33793
+ }
33792
33794
  } catch (error) {
33793
- console.warn("Failed to remove widget parameters from localStorage:", error);
33795
+ console.warn("Failed to clean up window URL parameters:", error);
33794
33796
  }
33795
33797
  }
33796
33798
  /**
@@ -33980,13 +33982,8 @@ class ObiWidget extends LitElement {
33980
33982
  await this.checkExistingSession();
33981
33983
  if (!this.activeSession) {
33982
33984
  let storedParams = {};
33983
- try {
33984
- const storedParamsJson = localStorage.getItem(WIDGET_PARAMS_KEY);
33985
- if (storedParamsJson) {
33986
- storedParams = JSON.parse(storedParamsJson);
33987
- }
33988
- } catch (error) {
33989
- console.warn("Failed to parse stored widget parameters:", error);
33985
+ if (window.__obiUrlParams) {
33986
+ storedParams = window.__obiUrlParams;
33990
33987
  }
33991
33988
  if (Object.keys(storedParams).length === 0) {
33992
33989
  const urlParams = new URLSearchParams(window.location.search);
@@ -33997,8 +33994,13 @@ class ObiWidget extends LitElement {
33997
33994
  const sessionId = storedParams[SESSION_URL_PARAM];
33998
33995
  if (sessionId && this.apiKey) {
33999
33996
  await this.handleUrlSessionEvent(sessionId);
34000
- } else {
34001
- console.log("No session ID found or API key is not set");
33997
+ } else if (sessionId && !this.apiKey) {
33998
+ console.log("Session ID found but API key not ready, retrying...");
33999
+ setTimeout(() => {
34000
+ if (this.apiKey) {
34001
+ this.handleUrlSessionEvent(sessionId);
34002
+ }
34003
+ }, 100);
34002
34004
  }
34003
34005
  }
34004
34006
  }
@@ -34009,7 +34011,17 @@ class ObiWidget extends LitElement {
34009
34011
  this.boundSaveSessionData = this.saveSessionData.bind(this);
34010
34012
  window.addEventListener("beforeunload", this.boundSaveSessionData);
34011
34013
  window.addEventListener("pagehide", this.boundSaveSessionData);
34012
- this.sessionConnectionCheck();
34014
+ if (document.readyState === "complete") {
34015
+ Promise.resolve().then(() => this.sessionConnectionCheck());
34016
+ } else {
34017
+ window.addEventListener(
34018
+ "load",
34019
+ () => {
34020
+ Promise.resolve().then(() => this.sessionConnectionCheck());
34021
+ },
34022
+ { once: true }
34023
+ );
34024
+ }
34013
34025
  }
34014
34026
  disconnectedCallback() {
34015
34027
  if (this.closeNavTimeoutRef !== null) {
@@ -34376,18 +34388,18 @@ function processQueue() {
34376
34388
  }
34377
34389
  }
34378
34390
  async function loadFonts() {
34391
+ await loadFont("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap");
34392
+ await loadFont("https://fonts.cdnfonts.com/css/satoshi");
34393
+ }
34394
+ async function loadFont(fontUrl) {
34379
34395
  return retryOperation(async () => {
34380
34396
  if (!document.head) {
34381
34397
  throw new Error("document.head not available");
34382
34398
  }
34383
- const existingLink = document.head.querySelector('link[href*="fonts.googleapis.com"]');
34384
- if (existingLink) {
34385
- return;
34386
- }
34387
34399
  const link = document.createElement("link");
34388
34400
  document.head.querySelectorAll("link[data-obi-font]").forEach((node) => node.remove());
34389
34401
  link.setAttribute("data-obi-font", "true");
34390
- link.href = "https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap";
34402
+ link.href = fontUrl;
34391
34403
  link.rel = "stylesheet";
34392
34404
  return new Promise((resolve, reject) => {
34393
34405
  const timeout = setTimeout(() => {