@cuekit-ai/react 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -89,18 +89,14 @@ var init_intent_store = __esm({
89
89
  setElement(elementData) {
90
90
  const index2 = store.allElementsData.findIndex((e3) => e3.elementId === elementData.elementId);
91
91
  if (index2 >= 0) {
92
- console.log("Updating existing element");
93
92
  store.allElementsData[index2] = elementData;
94
93
  } else {
95
- console.log("Adding new element");
96
94
  store.allElementsData.push(elementData);
97
95
  }
98
96
  },
99
97
  getElementById(elementId) {
100
98
  const match = store.allElementsData.find((e3) => e3.elementId === elementId);
101
99
  if (!match) {
102
- console.warn(`[GlobalStore] No element found for ID: ${elementId}`);
103
- console.log("All elements in store:", store.allElementsData);
104
100
  }
105
101
  return match;
106
102
  },
@@ -125,7 +121,6 @@ function navigate(path2, params) {
125
121
  try {
126
122
  navigationHandler(absolutePath, safeParams);
127
123
  } catch (error) {
128
- console.error("[CueKit] navigation handler failed, falling back to default:", error);
129
124
  }
130
125
  return;
131
126
  }
@@ -176,12 +171,10 @@ function onStateChange() {
176
171
  const metadata = JSON.parse(params.metadata);
177
172
  GlobalStore.setMetadata(routeName, metadata);
178
173
  } catch (error) {
179
- console.error("Failed to parse metadata from URL:", error);
180
174
  }
181
175
  }
182
176
  }
183
177
  function getElementPath(element3) {
184
- if (typeof window === "undefined") return "";
185
178
  if (element3.id) {
186
179
  return `id(${element3.id})`;
187
180
  }
@@ -219,7 +212,6 @@ var init_navigation = __esm({
219
212
  if (name2) {
220
213
  navigate(name2, params);
221
214
  } else {
222
- console.warn("[CueKit] route name not provided");
223
215
  }
224
216
  };
225
217
  handleNavigationAndClick = (routeName, elementHash) => {
@@ -262,7 +254,6 @@ var init_navigation = __esm({
262
254
  }
263
255
  }, 100);
264
256
  });
265
- if (typeof window === "undefined") return;
266
257
  observer.observe(document.body, { childList: true, subtree: true });
267
258
  };
268
259
  }
@@ -277,384 +268,7 @@ var init_constants = __esm({
277
268
  }
278
269
  });
279
270
 
280
- // src/utils/jsx-encoder.ts
281
- function generateStableDOMId(element3) {
282
- const tagName = element3.tagName.toLowerCase();
283
- const text7 = (element3.textContent || "").trim().substring(0, 50);
284
- let sibling = element3.previousElementSibling;
285
- let position3 = 1;
286
- while (sibling) {
287
- if (sibling.tagName === element3.tagName) {
288
- position3++;
289
- }
290
- sibling = sibling.previousElementSibling;
291
- }
292
- const path2 = getElementPath2(element3);
293
- const idString = `${tagName}[${position3}]_(${text7})_${path2}`;
294
- let hash = 0;
295
- for (let i2 = 0; i2 < idString.length; i2++) {
296
- const char = idString.charCodeAt(i2);
297
- hash = (hash << 5) - hash + char;
298
- hash |= 0;
299
- }
300
- return hash.toString(36);
301
- }
302
- function getElementPath2(element3) {
303
- if (element3.id) {
304
- return `id(${element3.id})`;
305
- }
306
- if (element3.tagName.toLowerCase() === "body") {
307
- return "/body";
308
- }
309
- let ix = 0;
310
- const siblings = element3.parentNode?.children || new HTMLCollection();
311
- for (let i2 = 0; i2 < siblings.length; i2++) {
312
- const sibling = siblings[i2];
313
- if (sibling === element3) {
314
- return `${getElementPath2(element3.parentNode)}/${element3.tagName}[${ix + 1}]`;
315
- }
316
- if (sibling.nodeType === 1 && sibling.tagName === element3.tagName) {
317
- ix++;
318
- }
319
- }
320
- return "not_found";
321
- }
322
- var init_jsx_encoder = __esm({
323
- "src/utils/jsx-encoder.ts"() {
324
- "use strict";
325
- }
326
- });
327
-
328
- // src/utils/element-service.ts
329
- function getInteractiveElements() {
330
- if (typeof document === "undefined") {
331
- return new class extends Array {
332
- }();
333
- }
334
- return document.querySelectorAll(INTERACTIVE_ELEMENT_SELECTOR);
335
- }
336
- function getImmediateText(element3) {
337
- let text7 = "";
338
- if (element3.childNodes) {
339
- for (const node2 of Array.from(element3.childNodes)) {
340
- if (node2.nodeType === 3) {
341
- text7 += node2.textContent || "";
342
- }
343
- }
344
- }
345
- return text7.trim();
346
- }
347
- function captureFullDOMStructure() {
348
- console.log("\u{1F333} Capturing full DOM structure...");
349
- const components = [];
350
- const interactiveElements = getInteractiveElements();
351
- interactiveElements.forEach((element3) => {
352
- if (element3 instanceof HTMLElement && !element3.closest("[data-cuekit-ignore]")) {
353
- const nodeData = buildFlatDOMNode(element3);
354
- if (nodeData) {
355
- components.push(nodeData);
356
- }
357
- }
358
- });
359
- const result = { components };
360
- console.log("\u{1F333} Full DOM structure captured:", result);
361
- return result;
362
- }
363
- function buildFlatDOMNode(element3) {
364
- if (element3.tagName.toLowerCase() === "script" || element3.hasAttribute("data-cuekit-ignore") || element3.style.display === "none" || element3.style.visibility === "hidden") {
365
- return null;
366
- }
367
- const hash = generateStableDOMId(element3);
368
- const text7 = getImmediateText(element3).substring(0, 100);
369
- const isClickable = isElementClickable(element3);
370
- const componentType = element3.tagName.toLowerCase();
371
- return {
372
- hash,
373
- text: text7,
374
- isClickable,
375
- componentType,
376
- children: []
377
- // No children in a flat structure
378
- };
379
- }
380
- function isElementClickable(element3) {
381
- const interactiveSelectors = [
382
- "button",
383
- "a",
384
- "input",
385
- "select",
386
- "textarea",
387
- '[role="button"]',
388
- '[role="link"]',
389
- '[role="tab"]',
390
- "[data-onclick-id]",
391
- "[data-on-press-id]",
392
- "[onclick]",
393
- "[onmousedown]",
394
- "[onmouseup]",
395
- "[ontouchstart]",
396
- "[ontouchend]",
397
- "[onkeydown]",
398
- "[onkeyup]",
399
- "[onkeypress]"
400
- ];
401
- for (const selector of interactiveSelectors) {
402
- if (element3.matches(selector)) {
403
- return true;
404
- }
405
- }
406
- const hasClickEvents = element3.onclick !== null || element3.getAttribute("onclick") !== null;
407
- const hasInteractiveEvents = element3.ontouchstart !== null || element3.getAttribute("ontouchstart") !== null || element3.ontouchend !== null || element3.getAttribute("ontouchend") !== null || element3.onkeydown !== null || element3.getAttribute("onkeydown") !== null || element3.onkeyup !== null || element3.getAttribute("onkeyup") !== null || element3.onkeypress !== null || element3.getAttribute("onkeypress") !== null;
408
- const hasPointerCursor = element3.style.cursor === "pointer" || getComputedStyle(element3).cursor === "pointer";
409
- const hasTabIndex = element3.hasAttribute("tabindex") && parseInt(element3.getAttribute("tabindex") || "0") >= 0;
410
- const hasInteractiveDataAttrs = element3.hasAttribute("data-clickable") || element3.hasAttribute("data-interactive") || element3.hasAttribute("data-action") || element3.hasAttribute("data-handler");
411
- const hasInteractiveAria = element3.hasAttribute("aria-pressed") || element3.hasAttribute("aria-expanded") || element3.hasAttribute("aria-selected") || element3.hasAttribute("aria-checked");
412
- return hasClickEvents || hasInteractiveEvents || hasPointerCursor || hasTabIndex || hasInteractiveDataAttrs || hasInteractiveAria;
413
- }
414
- function executeAction(action) {
415
- console.log("\u{1F3AF} Executing element action:", action);
416
- const { action_type, target_element, target } = action;
417
- switch (action_type) {
418
- case "click":
419
- return clickElement(target_element);
420
- case "navigate":
421
- return navigateToElement(target_element || target);
422
- case "input":
423
- case "focus":
424
- return focusElement(target_element);
425
- case "toggle":
426
- return toggleElement(target_element);
427
- default:
428
- console.warn(`\u26A0\uFE0F Unknown action type: ${action_type}`);
429
- return false;
430
- }
431
- }
432
- function getFullDOMStructure() {
433
- console.log("\u{1F333} ElementService: Getting full DOM structure...");
434
- return captureFullDOMStructure();
435
- }
436
- function clickElement(elementId) {
437
- if (!elementId) {
438
- console.warn("\u26A0\uFE0F No element ID provided for click action");
439
- return false;
440
- }
441
- const domStructure = getFullDOMStructure();
442
- const elementToClick = findElementById(domStructure, elementId);
443
- if (elementToClick) {
444
- console.log(`\u{1F3AF} Clicking element: ${elementId}`);
445
- const domElement = findDOMElementById(elementId);
446
- if (domElement) {
447
- domElement.click();
448
- return true;
449
- }
450
- } else {
451
- console.warn(`\u26A0\uFE0F Element not found: ${elementId}`);
452
- }
453
- return false;
454
- }
455
- function navigateToElement(target) {
456
- if (!target) {
457
- console.warn("\u26A0\uFE0F No target provided for navigation action");
458
- return false;
459
- }
460
- console.log(`\u{1F9ED} Navigating to: ${target}`);
461
- if (target.includes("/") || target.startsWith("http")) {
462
- safeNavigate(target, {});
463
- } else {
464
- handleNavigationAndClick(target, target);
465
- }
466
- return true;
467
- }
468
- function focusElement(elementId) {
469
- if (!elementId) {
470
- console.warn("\u26A0\uFE0F No element ID provided for focus action");
471
- return false;
472
- }
473
- const domElement = findDOMElementById(elementId);
474
- if (domElement instanceof HTMLInputElement || domElement instanceof HTMLTextAreaElement || domElement instanceof HTMLSelectElement) {
475
- console.log(`\u{1F4DD} Focusing element: ${elementId}`);
476
- domElement.focus();
477
- return true;
478
- } else {
479
- console.warn(`\u26A0\uFE0F Focusable element not found: ${elementId}`);
480
- return false;
481
- }
482
- }
483
- function toggleElement(elementId) {
484
- if (!elementId) {
485
- console.warn("\u26A0\uFE0F No element ID provided for toggle action");
486
- return false;
487
- }
488
- const domElement = findDOMElementById(elementId);
489
- if (domElement instanceof HTMLElement) {
490
- console.log(`\u{1F504} Toggling element: ${elementId}`);
491
- if (domElement instanceof HTMLInputElement) {
492
- if (domElement.type === "checkbox") {
493
- domElement.checked = !domElement.checked;
494
- } else if (domElement.type === "radio") {
495
- domElement.checked = true;
496
- }
497
- domElement.dispatchEvent(new Event("change", { bubbles: true }));
498
- } else {
499
- domElement.click();
500
- }
501
- return true;
502
- } else {
503
- console.warn(`\u26A0\uFE0F Toggleable element not found: ${elementId}`);
504
- return false;
505
- }
506
- }
507
- function findElementById(domStructure, elementId) {
508
- const searchInComponents = (components) => {
509
- for (const component of components) {
510
- if (component.hash === elementId) {
511
- return component;
512
- }
513
- if (component.children.length > 0) {
514
- const found = searchInComponents(component.children);
515
- if (found) return found;
516
- }
517
- }
518
- return null;
519
- };
520
- return searchInComponents(domStructure.components);
521
- }
522
- function findDOMElementById(elementId) {
523
- const interactiveElements = getInteractiveElements();
524
- for (const element3 of interactiveElements) {
525
- if (element3 instanceof HTMLElement) {
526
- console.log("\u{1F50D} Checking element:", element3);
527
- const hash = generateStableDOMId(element3);
528
- console.log("\u{1F50D} Generated hash:", hash);
529
- if (hash === elementId) {
530
- console.log("\u{1F50D} Found element:", element3);
531
- return element3;
532
- }
533
- }
534
- }
535
- return null;
536
- }
537
- var INTERACTIVE_ELEMENT_SELECTOR;
538
- var init_element_service = __esm({
539
- "src/utils/element-service.ts"() {
540
- "use strict";
541
- init_jsx_encoder();
542
- init_navigation();
543
- INTERACTIVE_ELEMENT_SELECTOR = 'a, button, input, textarea, select, [role="button"], [onclick]';
544
- }
545
- });
546
-
547
271
  // node_modules/livekit-client/dist/livekit-client.esm.mjs
548
- var livekit_client_esm_exports = {};
549
- __export(livekit_client_esm_exports, {
550
- AudioPresets: () => AudioPresets,
551
- BackupCodecPolicy: () => BackupCodecPolicy,
552
- BaseKeyProvider: () => BaseKeyProvider,
553
- CheckStatus: () => CheckStatus,
554
- Checker: () => Checker,
555
- ConnectionCheck: () => ConnectionCheck,
556
- ConnectionError: () => ConnectionError,
557
- ConnectionErrorReason: () => ConnectionErrorReason,
558
- ConnectionQuality: () => ConnectionQuality,
559
- ConnectionState: () => ConnectionState,
560
- CriticalTimers: () => CriticalTimers,
561
- CryptorError: () => CryptorError,
562
- CryptorErrorReason: () => CryptorErrorReason,
563
- CryptorEvent: () => CryptorEvent,
564
- DataPacket_Kind: () => DataPacket_Kind,
565
- DefaultReconnectPolicy: () => DefaultReconnectPolicy,
566
- DeviceUnsupportedError: () => DeviceUnsupportedError,
567
- DisconnectReason: () => DisconnectReason,
568
- EncryptionEvent: () => EncryptionEvent,
569
- EngineEvent: () => EngineEvent,
570
- ExternalE2EEKeyProvider: () => ExternalE2EEKeyProvider,
571
- KeyHandlerEvent: () => KeyHandlerEvent,
572
- KeyProviderEvent: () => KeyProviderEvent,
573
- LivekitError: () => LivekitError,
574
- LocalAudioTrack: () => LocalAudioTrack,
575
- LocalParticipant: () => LocalParticipant,
576
- LocalTrack: () => LocalTrack,
577
- LocalTrackPublication: () => LocalTrackPublication,
578
- LocalTrackRecorder: () => LocalTrackRecorder,
579
- LocalVideoTrack: () => LocalVideoTrack,
580
- LogLevel: () => LogLevel,
581
- LoggerNames: () => LoggerNames,
582
- MediaDeviceFailure: () => MediaDeviceFailure,
583
- Mutex: () => _,
584
- NegotiationError: () => NegotiationError,
585
- Participant: () => Participant,
586
- ParticipantEvent: () => ParticipantEvent,
587
- ParticipantKind: () => ParticipantInfo_Kind,
588
- PublishDataError: () => PublishDataError,
589
- PublishTrackError: () => PublishTrackError,
590
- RemoteAudioTrack: () => RemoteAudioTrack,
591
- RemoteParticipant: () => RemoteParticipant,
592
- RemoteTrack: () => RemoteTrack,
593
- RemoteTrackPublication: () => RemoteTrackPublication,
594
- RemoteVideoTrack: () => RemoteVideoTrack,
595
- Room: () => Room,
596
- RoomEvent: () => RoomEvent,
597
- RpcError: () => RpcError,
598
- ScreenSharePresets: () => ScreenSharePresets,
599
- SignalRequestError: () => SignalRequestError,
600
- SubscriptionError: () => SubscriptionError,
601
- Track: () => Track,
602
- TrackEvent: () => TrackEvent,
603
- TrackInvalidError: () => TrackInvalidError,
604
- TrackPublication: () => TrackPublication,
605
- TrackType: () => TrackType,
606
- UnexpectedConnectionState: () => UnexpectedConnectionState,
607
- UnsupportedServer: () => UnsupportedServer,
608
- VideoPreset: () => VideoPreset,
609
- VideoPresets: () => VideoPresets,
610
- VideoPresets43: () => VideoPresets43,
611
- VideoQuality: () => VideoQuality,
612
- attachToElement: () => attachToElement,
613
- attributes: () => attributeTypings,
614
- compareVersions: () => compareVersions,
615
- createAudioAnalyser: () => createAudioAnalyser,
616
- createE2EEKey: () => createE2EEKey,
617
- createKeyMaterialFromBuffer: () => createKeyMaterialFromBuffer,
618
- createKeyMaterialFromString: () => createKeyMaterialFromString,
619
- createLocalAudioTrack: () => createLocalAudioTrack,
620
- createLocalScreenTracks: () => createLocalScreenTracks,
621
- createLocalTracks: () => createLocalTracks,
622
- createLocalVideoTrack: () => createLocalVideoTrack,
623
- deriveKeys: () => deriveKeys,
624
- detachTrack: () => detachTrack,
625
- facingModeFromDeviceLabel: () => facingModeFromDeviceLabel,
626
- facingModeFromLocalTrack: () => facingModeFromLocalTrack,
627
- getBrowser: () => getBrowser,
628
- getEmptyAudioStreamTrack: () => getEmptyAudioStreamTrack,
629
- getEmptyVideoStreamTrack: () => getEmptyVideoStreamTrack,
630
- getLogger: () => getLogger,
631
- importKey: () => importKey,
632
- isAudioTrack: () => isAudioTrack,
633
- isBackupCodec: () => isBackupCodec,
634
- isBrowserSupported: () => isBrowserSupported,
635
- isE2EESupported: () => isE2EESupported,
636
- isInsertableStreamSupported: () => isInsertableStreamSupported,
637
- isLocalParticipant: () => isLocalParticipant,
638
- isLocalTrack: () => isLocalTrack,
639
- isRemoteParticipant: () => isRemoteParticipant,
640
- isRemoteTrack: () => isRemoteTrack,
641
- isScriptTransformSupported: () => isScriptTransformSupported,
642
- isVideoFrame: () => isVideoFrame,
643
- isVideoTrack: () => isVideoTrack,
644
- needsRbspUnescaping: () => needsRbspUnescaping,
645
- parseRbsp: () => parseRbsp,
646
- protocolVersion: () => protocolVersion,
647
- ratchet: () => ratchet,
648
- setLogExtension: () => setLogExtension,
649
- setLogLevel: () => setLogLevel,
650
- supportsAV1: () => supportsAV1,
651
- supportsAdaptiveStream: () => supportsAdaptiveStream,
652
- supportsDynacast: () => supportsDynacast,
653
- supportsVP9: () => supportsVP9,
654
- version: () => version,
655
- videoCodecs: () => videoCodecs,
656
- writeRbsp: () => writeRbsp
657
- });
658
272
  function _mergeNamespaces(n, m) {
659
273
  m.forEach(function(e3) {
660
274
  e3 && typeof e3 !== "string" && !Array.isArray(e3) && Object.keys(e3).forEach(function(k2) {
@@ -2679,34 +2293,6 @@ function getLogger(name2) {
2679
2293
  logger.setDefaultLevel(livekitLogger.getLevel());
2680
2294
  return logger;
2681
2295
  }
2682
- function setLogLevel(level, loggerName) {
2683
- if (loggerName) {
2684
- loglevelExports.getLogger(loggerName).setLevel(level);
2685
- } else {
2686
- for (const logger of livekitLoggers) {
2687
- logger.setLevel(level);
2688
- }
2689
- }
2690
- }
2691
- function setLogExtension(extension2, logger) {
2692
- const loggers = logger ? [logger] : livekitLoggers;
2693
- loggers.forEach((logR) => {
2694
- const originalFactory = logR.methodFactory;
2695
- logR.methodFactory = (methodName, configLevel, loggerName) => {
2696
- const rawMethod = originalFactory(methodName, configLevel, loggerName);
2697
- const logLevel = LogLevel[methodName];
2698
- const needLog = logLevel >= configLevel && logLevel < LogLevel.silent;
2699
- return (msg, context) => {
2700
- if (context) rawMethod(msg, context);
2701
- else rawMethod(msg);
2702
- if (needLog) {
2703
- extension2(logLevel, msg, context);
2704
- }
2705
- };
2706
- };
2707
- logR.setLevel(logR.getLevel());
2708
- });
2709
- }
2710
2296
  function __rest(s, e3) {
2711
2297
  var t = {};
2712
2298
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e3.indexOf(p) < 0)
@@ -5599,118 +5185,6 @@ function isInsertableStreamSupported() {
5599
5185
  return typeof window.RTCRtpSender !== "undefined" && // @ts-ignore
5600
5186
  typeof window.RTCRtpSender.prototype.createEncodedStreams !== "undefined";
5601
5187
  }
5602
- function isVideoFrame(frame) {
5603
- return "type" in frame;
5604
- }
5605
- function importKey(keyBytes_1) {
5606
- return __awaiter(this, arguments, void 0, function(keyBytes) {
5607
- let algorithm = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {
5608
- name: ENCRYPTION_ALGORITHM
5609
- };
5610
- let usage = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : "encrypt";
5611
- return function* () {
5612
- return crypto.subtle.importKey("raw", keyBytes, algorithm, false, usage === "derive" ? ["deriveBits", "deriveKey"] : ["encrypt", "decrypt"]);
5613
- }();
5614
- });
5615
- }
5616
- function createKeyMaterialFromString(password) {
5617
- return __awaiter(this, void 0, void 0, function* () {
5618
- let enc = new TextEncoder();
5619
- const keyMaterial = yield crypto.subtle.importKey("raw", enc.encode(password), {
5620
- name: "PBKDF2"
5621
- }, false, ["deriveBits", "deriveKey"]);
5622
- return keyMaterial;
5623
- });
5624
- }
5625
- function createKeyMaterialFromBuffer(cryptoBuffer) {
5626
- return __awaiter(this, void 0, void 0, function* () {
5627
- const keyMaterial = yield crypto.subtle.importKey("raw", cryptoBuffer, "HKDF", false, ["deriveBits", "deriveKey"]);
5628
- return keyMaterial;
5629
- });
5630
- }
5631
- function getAlgoOptions(algorithmName, salt) {
5632
- const textEncoder = new TextEncoder();
5633
- const encodedSalt = textEncoder.encode(salt);
5634
- switch (algorithmName) {
5635
- case "HKDF":
5636
- return {
5637
- name: "HKDF",
5638
- salt: encodedSalt,
5639
- hash: "SHA-256",
5640
- info: new ArrayBuffer(128)
5641
- };
5642
- case "PBKDF2": {
5643
- return {
5644
- name: "PBKDF2",
5645
- salt: encodedSalt,
5646
- hash: "SHA-256",
5647
- iterations: 1e5
5648
- };
5649
- }
5650
- default:
5651
- throw new Error("algorithm ".concat(algorithmName, " is currently unsupported"));
5652
- }
5653
- }
5654
- function deriveKeys(material, salt) {
5655
- return __awaiter(this, void 0, void 0, function* () {
5656
- const algorithmOptions = getAlgoOptions(material.algorithm.name, salt);
5657
- const encryptionKey = yield crypto.subtle.deriveKey(algorithmOptions, material, {
5658
- name: ENCRYPTION_ALGORITHM,
5659
- length: 128
5660
- }, false, ["encrypt", "decrypt"]);
5661
- return {
5662
- material,
5663
- encryptionKey
5664
- };
5665
- });
5666
- }
5667
- function createE2EEKey() {
5668
- return window.crypto.getRandomValues(new Uint8Array(32));
5669
- }
5670
- function ratchet(material, salt) {
5671
- return __awaiter(this, void 0, void 0, function* () {
5672
- const algorithmOptions = getAlgoOptions(material.algorithm.name, salt);
5673
- return crypto.subtle.deriveBits(algorithmOptions, material, 256);
5674
- });
5675
- }
5676
- function needsRbspUnescaping(frameData) {
5677
- for (var i2 = 0; i2 < frameData.length - 3; i2++) {
5678
- if (frameData[i2] == 0 && frameData[i2 + 1] == 0 && frameData[i2 + 2] == 3) return true;
5679
- }
5680
- return false;
5681
- }
5682
- function parseRbsp(stream) {
5683
- const dataOut = [];
5684
- var length = stream.length;
5685
- for (var i2 = 0; i2 < stream.length; ) {
5686
- if (length - i2 >= 3 && !stream[i2] && !stream[i2 + 1] && stream[i2 + 2] == 3) {
5687
- dataOut.push(stream[i2++]);
5688
- dataOut.push(stream[i2++]);
5689
- i2++;
5690
- } else {
5691
- dataOut.push(stream[i2++]);
5692
- }
5693
- }
5694
- return new Uint8Array(dataOut);
5695
- }
5696
- function writeRbsp(data_in) {
5697
- const dataOut = [];
5698
- var numConsecutiveZeros = 0;
5699
- for (var i2 = 0; i2 < data_in.length; ++i2) {
5700
- var byte = data_in[i2];
5701
- if (byte <= kEmulationByte && numConsecutiveZeros >= kZerosInStartSequence) {
5702
- dataOut.push(kEmulationByte);
5703
- numConsecutiveZeros = 0;
5704
- }
5705
- dataOut.push(byte);
5706
- if (byte == 0) {
5707
- ++numConsecutiveZeros;
5708
- } else {
5709
- numConsecutiveZeros = 0;
5710
- }
5711
- }
5712
- return new Uint8Array(dataOut);
5713
- }
5714
5188
  function cloneDeep(value) {
5715
5189
  if (typeof value === "undefined") {
5716
5190
  return value;
@@ -5818,12 +5292,6 @@ function supportsTransceiver() {
5818
5292
  function supportsAddTrack() {
5819
5293
  return "addTrack" in RTCPeerConnection.prototype;
5820
5294
  }
5821
- function supportsAdaptiveStream() {
5822
- return typeof ResizeObserver !== void 0 && typeof IntersectionObserver !== void 0;
5823
- }
5824
- function supportsDynacast() {
5825
- return supportsTransceiver();
5826
- }
5827
5295
  function supportsAV1() {
5828
5296
  if (!("getCapabilities" in RTCRtpSender)) {
5829
5297
  return false;
@@ -6011,12 +5479,6 @@ function getClientInfo() {
6011
5479
  }
6012
5480
  return info;
6013
5481
  }
6014
- function getEmptyVideoStreamTrack() {
6015
- if (!emptyVideoStreamTrack) {
6016
- emptyVideoStreamTrack = createDummyVideoStreamTrack();
6017
- }
6018
- return emptyVideoStreamTrack.clone();
6019
- }
6020
5482
  function createDummyVideoStreamTrack() {
6021
5483
  let width = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 16;
6022
5484
  let height = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 16;
@@ -6229,9 +5691,6 @@ function isRemoteVideoTrack(track) {
6229
5691
  function isLocalParticipant(p) {
6230
5692
  return p.isLocal;
6231
5693
  }
6232
- function isRemoteParticipant(p) {
6233
- return !p.isLocal;
6234
- }
6235
5694
  function splitUtf8(s, n) {
6236
5695
  const result = [];
6237
5696
  let encoded = new TextEncoder().encode(s);
@@ -8028,34 +7487,6 @@ function createLocalAudioTrack(options) {
8028
7487
  return tracks[0];
8029
7488
  });
8030
7489
  }
8031
- function createLocalScreenTracks(options) {
8032
- return __awaiter(this, void 0, void 0, function* () {
8033
- if (options === void 0) {
8034
- options = {};
8035
- }
8036
- if (options.resolution === void 0 && !isSafari17Based()) {
8037
- options.resolution = ScreenSharePresets.h1080fps30.resolution;
8038
- }
8039
- if (navigator.mediaDevices.getDisplayMedia === void 0) {
8040
- throw new DeviceUnsupportedError("getDisplayMedia not supported");
8041
- }
8042
- const constraints = screenCaptureToDisplayMediaStreamOptions(options);
8043
- const stream = yield navigator.mediaDevices.getDisplayMedia(constraints);
8044
- const tracks = stream.getVideoTracks();
8045
- if (tracks.length === 0) {
8046
- throw new TrackInvalidError("no video track found");
8047
- }
8048
- const screenVideo = new LocalVideoTrack(tracks[0], void 0, false);
8049
- screenVideo.source = Track.Source.ScreenShare;
8050
- const localTracks = [screenVideo];
8051
- if (stream.getAudioTracks().length > 0) {
8052
- const screenAudio = new LocalAudioTrack(stream.getAudioTracks()[0], void 0, false);
8053
- screenAudio.source = Track.Source.ScreenShareAudio;
8054
- localTracks.push(screenAudio);
8055
- }
8056
- return localTracks;
8057
- });
8058
- }
8059
7490
  function qualityFromProto(q2) {
8060
7491
  switch (q2) {
8061
7492
  case ConnectionQuality$1.EXCELLENT:
@@ -8112,55 +7543,7 @@ function isIPPrivate(address) {
8112
7543
  }
8113
7544
  return false;
8114
7545
  }
8115
- function facingModeFromLocalTrack(localTrack) {
8116
- let options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
8117
- var _a;
8118
- const track = isLocalTrack(localTrack) ? localTrack.mediaStreamTrack : localTrack;
8119
- const trackSettings = track.getSettings();
8120
- let result = {
8121
- facingMode: (_a = options.defaultFacingMode) !== null && _a !== void 0 ? _a : "user",
8122
- confidence: "low"
8123
- };
8124
- if ("facingMode" in trackSettings) {
8125
- const rawFacingMode = trackSettings.facingMode;
8126
- livekitLogger.trace("rawFacingMode", {
8127
- rawFacingMode
8128
- });
8129
- if (rawFacingMode && typeof rawFacingMode === "string" && isFacingModeValue(rawFacingMode)) {
8130
- result = {
8131
- facingMode: rawFacingMode,
8132
- confidence: "high"
8133
- };
8134
- }
8135
- }
8136
- if (["low", "medium"].includes(result.confidence)) {
8137
- livekitLogger.trace("Try to get facing mode from device label: (".concat(track.label, ")"));
8138
- const labelAnalysisResult = facingModeFromDeviceLabel(track.label);
8139
- if (labelAnalysisResult !== void 0) {
8140
- result = labelAnalysisResult;
8141
- }
8142
- }
8143
- return result;
8144
- }
8145
- function facingModeFromDeviceLabel(deviceLabel) {
8146
- var _a;
8147
- const label = deviceLabel.trim().toLowerCase();
8148
- if (label === "") {
8149
- return void 0;
8150
- }
8151
- if (knownDeviceLabels.has(label)) {
8152
- return knownDeviceLabels.get(label);
8153
- }
8154
- return (_a = Array.from(knownDeviceLabelSections.entries()).find((_ref) => {
8155
- let [section] = _ref;
8156
- return label.includes(section);
8157
- })) === null || _a === void 0 ? void 0 : _a[1];
8158
- }
8159
- function isFacingModeValue(item) {
8160
- const allowedValues = ["user", "environment", "left", "right"];
8161
- return item === void 0 || allowedValues.includes(item);
8162
- }
8163
- var e, h, o, _, FLOAT32_MAX, FLOAT32_MIN, UINT32_MAX, INT32_MAX, INT32_MIN, enumTypeSymbol, Message, TWO_PWR_32_DBL, decimalFrom1e7WithLeadingZeros, protoInt64, ScalarType, LongType, WireType, BinaryWriter, BinaryReader, encTable, decTable, protoBase64, jsonReadDefaults, jsonWriteDefaults, tokenNull, tokenIgnoredUnknownEnum, unknownFieldsSymbol, readDefaults, writeDefaults, InternalFieldList, fieldJsonName, reservedObjectProperties, reservedMessageProperties, fallback, safeMessageProperty, safeObjectProperty, InternalOneofInfo, proto3, Timestamp, MetricsBatch, TimeSeriesMetric, MetricSample, EventMetric, BackupCodecPolicy$1, TrackType, TrackSource, VideoQuality$1, ConnectionQuality$1, ClientConfigSetting, DisconnectReason, ReconnectReason, SubscriptionError, AudioTrackFeature, Room$1, Codec, ParticipantPermission, ParticipantInfo, ParticipantInfo_State, ParticipantInfo_Kind, ParticipantInfo_KindDetail, Encryption_Type, SimulcastCodecInfo, TrackInfo, VideoLayer, DataPacket, DataPacket_Kind, ActiveSpeakerUpdate, SpeakerInfo, UserPacket, SipDTMF, Transcription, TranscriptionSegment, ChatMessage, RpcRequest, RpcAck, RpcResponse, RpcError$1, ParticipantTracks, ServerInfo, ServerInfo_Edition, ClientInfo, ClientInfo_SDK, ClientConfiguration, VideoConfiguration, DisabledCodecs, TimedVersion, DataStream_OperationType, DataStream_TextHeader, DataStream_ByteHeader, DataStream_Header, DataStream_Chunk, DataStream_Trailer, SignalTarget, StreamState, CandidateProtocol, SignalRequest, SignalResponse, SimulcastCodec, AddTrackRequest, TrickleRequest, MuteTrackRequest, JoinResponse, ReconnectResponse, TrackPublishedResponse, TrackUnpublishedResponse, SessionDescription, ParticipantUpdate, UpdateSubscription, UpdateTrackSettings, UpdateLocalAudioTrack, UpdateLocalVideoTrack, LeaveRequest, LeaveRequest_Action, UpdateVideoLayers, UpdateParticipantMetadata, ICEServer, SpeakersChanged, RoomUpdate, ConnectionQualityInfo, ConnectionQualityUpdate, StreamStateInfo, StreamStateUpdate, SubscribedQuality, SubscribedCodec, SubscribedQualityUpdate, TrackPermission, SubscriptionPermission, SubscriptionPermissionUpdate, RoomMovedResponse, SyncState, DataChannelReceiveState, DataChannelInfo, SimulateScenario, Ping, Pong, RegionSettings, RegionInfo, SubscriptionResponse, RequestResponse, RequestResponse_Reason, TrackSubscribed, loglevel$1, loglevel, hasRequiredLoglevel, loglevelExports, LogLevel, LoggerNames, livekitLogger, livekitLoggers, workerLogger, maxRetryDelay, DEFAULT_RETRY_DELAYS_IN_MS, DefaultReconnectPolicy, events, hasRequiredEvents, eventsExports, logDisabled_, deprecationWarnings_, logging, chromeShim, firefoxShim, safariShim, sdp$1, hasRequiredSdp, sdpExports, SDPUtils, sdp, commonShim, ENCRYPTION_ALGORITHM, DECRYPTION_FAILURE_TOLERANCE, E2EE_FLAG, SALT, KEY_PROVIDER_DEFAULTS, KeyProviderEvent, KeyHandlerEvent, EncryptionEvent, CryptorEvent, kZerosInStartSequence, kEmulationByte, BaseKeyProvider, ExternalE2EEKeyProvider, LivekitError, ConnectionErrorReason, ConnectionError, DeviceUnsupportedError, TrackInvalidError, UnsupportedServer, UnexpectedConnectionState, NegotiationError, PublishDataError, PublishTrackError, SignalRequestError, MediaDeviceFailure, CryptorErrorReason, CryptorError, RoomEvent, ParticipantEvent, EngineEvent, TrackEvent, commonVersionIdentifier, browserDetails, browsersList, version$1, version, protocolVersion, CriticalTimers, BACKGROUND_REACTION_DELAY, recycledElements, VideoQuality, Track, VideoPreset, backupCodecs, videoCodecs, BackupCodecPolicy, AudioPresets, VideoPresets, VideoPresets43, ScreenSharePresets, separator, ddExtensionURI, resizeObserver, getResizeObserver, intersectionObserver, getIntersectionObserver, emptyVideoStreamTrack, emptyAudioStreamTrack, Future, E2EEManager, defaultId, DeviceManager, QueueTaskStatus, AsyncQueue, passThroughQueueSignals, SignalConnectionState, SignalClient, DataPacketBuffer, TTLMap, lib, parser, grammar, hasRequiredGrammar, hasRequiredParser, writer, hasRequiredWriter, hasRequiredLib, libExports, startBitrateForSVC, debounceInterval, PCEvents, PCTransport, defaultVideoCodec, publishDefaults, audioDefaults, videoDefaults, roomOptionDefaults, roomConnectOptionDefaults, PCTransportState, PCTransportManager, RpcError, MAX_PAYLOAD_BYTES, monitorFrequency, isMediaRecorderAvailable, FallbackRecorder, RecorderBase, LocalTrackRecorder, DEFAULT_DIMENSIONS_TIMEOUT, PRE_CONNECT_BUFFER_TIMEOUT, LocalTrack, LocalAudioTrack, presets169, presets43, presetsScreenShare, defaultSimulcastPresets169, defaultSimulcastPresets43, computeDefaultScreenShareSimulcastPresets, videoRids, ScalabilityMode, refreshSubscribedCodecAfterNewCodec, LocalVideoTrack, lossyDataChannel, reliableDataChannel, minReconnectWait, leaveReconnect, reliabeReceiveStateTTL, PCState, RTCEngine, SignalReconnectError, RegionUrlProvider, BaseStreamReader, ByteStreamReader, TextStreamReader, BaseStreamWriter, TextStreamWriter, ByteStreamWriter, RemoteTrack, RemoteAudioTrack, REACTION_DELAY, RemoteVideoTrack, HTMLElementInfo, TrackPublication, LocalTrackPublication, ConnectionQuality, Participant, STREAM_CHUNK_SIZE, LocalParticipant, RemoteTrackPublication, RemoteParticipant, ConnectionState, connectionReconcileFrequency, Room, Convert, attributeTypings, CheckStatus, Checker, CloudRegionCheck, TEST_DURATION, ConnectionProtocolCheck, PublishAudioCheck, PublishVideoCheck, ReconnectCheck, TURNCheck, WebRTCCheck, WebSocketCheck, ConnectionCheck, knownDeviceLabels, knownDeviceLabelSections;
7546
+ var e, h, o, _, FLOAT32_MAX, FLOAT32_MIN, UINT32_MAX, INT32_MAX, INT32_MIN, enumTypeSymbol, Message, TWO_PWR_32_DBL, decimalFrom1e7WithLeadingZeros, protoInt64, ScalarType, LongType, WireType, BinaryWriter, BinaryReader, encTable, decTable, protoBase64, jsonReadDefaults, jsonWriteDefaults, tokenNull, tokenIgnoredUnknownEnum, unknownFieldsSymbol, readDefaults, writeDefaults, InternalFieldList, fieldJsonName, reservedObjectProperties, reservedMessageProperties, fallback, safeMessageProperty, safeObjectProperty, InternalOneofInfo, proto3, Timestamp, MetricsBatch, TimeSeriesMetric, MetricSample, EventMetric, BackupCodecPolicy$1, TrackType, TrackSource, VideoQuality$1, ConnectionQuality$1, ClientConfigSetting, DisconnectReason, ReconnectReason, SubscriptionError, AudioTrackFeature, Room$1, Codec, ParticipantPermission, ParticipantInfo, ParticipantInfo_State, ParticipantInfo_Kind, ParticipantInfo_KindDetail, Encryption_Type, SimulcastCodecInfo, TrackInfo, VideoLayer, DataPacket, DataPacket_Kind, ActiveSpeakerUpdate, SpeakerInfo, UserPacket, SipDTMF, Transcription, TranscriptionSegment, ChatMessage, RpcRequest, RpcAck, RpcResponse, RpcError$1, ParticipantTracks, ServerInfo, ServerInfo_Edition, ClientInfo, ClientInfo_SDK, ClientConfiguration, VideoConfiguration, DisabledCodecs, TimedVersion, DataStream_OperationType, DataStream_TextHeader, DataStream_ByteHeader, DataStream_Header, DataStream_Chunk, DataStream_Trailer, SignalTarget, StreamState, CandidateProtocol, SignalRequest, SignalResponse, SimulcastCodec, AddTrackRequest, TrickleRequest, MuteTrackRequest, JoinResponse, ReconnectResponse, TrackPublishedResponse, TrackUnpublishedResponse, SessionDescription, ParticipantUpdate, UpdateSubscription, UpdateTrackSettings, UpdateLocalAudioTrack, UpdateLocalVideoTrack, LeaveRequest, LeaveRequest_Action, UpdateVideoLayers, UpdateParticipantMetadata, ICEServer, SpeakersChanged, RoomUpdate, ConnectionQualityInfo, ConnectionQualityUpdate, StreamStateInfo, StreamStateUpdate, SubscribedQuality, SubscribedCodec, SubscribedQualityUpdate, TrackPermission, SubscriptionPermission, SubscriptionPermissionUpdate, RoomMovedResponse, SyncState, DataChannelReceiveState, DataChannelInfo, SimulateScenario, Ping, Pong, RegionSettings, RegionInfo, SubscriptionResponse, RequestResponse, RequestResponse_Reason, TrackSubscribed, loglevel$1, loglevel, hasRequiredLoglevel, loglevelExports, LogLevel, LoggerNames, livekitLogger, livekitLoggers, workerLogger, maxRetryDelay, DEFAULT_RETRY_DELAYS_IN_MS, DefaultReconnectPolicy, events, hasRequiredEvents, eventsExports, logDisabled_, deprecationWarnings_, logging, chromeShim, firefoxShim, safariShim, sdp$1, hasRequiredSdp, sdpExports, SDPUtils, sdp, commonShim, DECRYPTION_FAILURE_TOLERANCE, E2EE_FLAG, SALT, KEY_PROVIDER_DEFAULTS, KeyProviderEvent, KeyHandlerEvent, EncryptionEvent, CryptorEvent, BaseKeyProvider, LivekitError, ConnectionErrorReason, ConnectionError, DeviceUnsupportedError, TrackInvalidError, UnsupportedServer, UnexpectedConnectionState, NegotiationError, PublishTrackError, SignalRequestError, MediaDeviceFailure, CryptorErrorReason, RoomEvent, ParticipantEvent, EngineEvent, TrackEvent, commonVersionIdentifier, browserDetails, browsersList, version$1, version, protocolVersion, CriticalTimers, BACKGROUND_REACTION_DELAY, recycledElements, VideoQuality, Track, VideoPreset, backupCodecs, videoCodecs, BackupCodecPolicy, AudioPresets, VideoPresets, VideoPresets43, ScreenSharePresets, separator, ddExtensionURI, resizeObserver, getResizeObserver, intersectionObserver, getIntersectionObserver, emptyAudioStreamTrack, Future, E2EEManager, defaultId, DeviceManager, QueueTaskStatus, AsyncQueue, passThroughQueueSignals, SignalConnectionState, SignalClient, DataPacketBuffer, TTLMap, lib, parser, grammar, hasRequiredGrammar, hasRequiredParser, writer, hasRequiredWriter, hasRequiredLib, libExports, startBitrateForSVC, debounceInterval, PCEvents, PCTransport, defaultVideoCodec, publishDefaults, audioDefaults, videoDefaults, roomOptionDefaults, roomConnectOptionDefaults, PCTransportState, PCTransportManager, RpcError, MAX_PAYLOAD_BYTES, monitorFrequency, isMediaRecorderAvailable, FallbackRecorder, RecorderBase, LocalTrackRecorder, DEFAULT_DIMENSIONS_TIMEOUT, PRE_CONNECT_BUFFER_TIMEOUT, LocalTrack, LocalAudioTrack, presets169, presets43, presetsScreenShare, defaultSimulcastPresets169, defaultSimulcastPresets43, computeDefaultScreenShareSimulcastPresets, videoRids, ScalabilityMode, refreshSubscribedCodecAfterNewCodec, LocalVideoTrack, lossyDataChannel, reliableDataChannel, minReconnectWait, leaveReconnect, reliabeReceiveStateTTL, PCState, RTCEngine, SignalReconnectError, RegionUrlProvider, BaseStreamReader, ByteStreamReader, TextStreamReader, BaseStreamWriter, TextStreamWriter, ByteStreamWriter, RemoteTrack, RemoteAudioTrack, REACTION_DELAY, RemoteVideoTrack, HTMLElementInfo, TrackPublication, LocalTrackPublication, ConnectionQuality, Participant, STREAM_CHUNK_SIZE, LocalParticipant, RemoteTrackPublication, RemoteParticipant, ConnectionState, connectionReconcileFrequency, Room, CheckStatus, Checker, CloudRegionCheck, TEST_DURATION, ConnectionProtocolCheck, PublishAudioCheck, PublishVideoCheck, ReconnectCheck, TURNCheck, WebRTCCheck, WebSocketCheck, ConnectionCheck;
8164
7547
  var init_livekit_client_esm = __esm({
8165
7548
  "node_modules/livekit-client/dist/livekit-client.esm.mjs"() {
8166
7549
  "use strict";
@@ -11899,7 +11282,6 @@ var init_livekit_client_esm = __esm({
11899
11282
  adapterFactory({
11900
11283
  window: typeof window === "undefined" ? void 0 : window
11901
11284
  });
11902
- ENCRYPTION_ALGORITHM = "AES-GCM";
11903
11285
  DECRYPTION_FAILURE_TOLERANCE = 10;
11904
11286
  E2EE_FLAG = "lk_e2ee";
11905
11287
  SALT = "LKFrameEncryptionKey";
@@ -11925,8 +11307,6 @@ var init_livekit_client_esm = __esm({
11925
11307
  (function(CryptorEvent2) {
11926
11308
  CryptorEvent2["Error"] = "cryptorError";
11927
11309
  })(CryptorEvent || (CryptorEvent = {}));
11928
- kZerosInStartSequence = 2;
11929
- kEmulationByte = 3;
11930
11310
  BaseKeyProvider = class extends eventsExports.EventEmitter {
11931
11311
  constructor() {
11932
11312
  let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
@@ -11970,32 +11350,6 @@ var init_livekit_client_esm = __esm({
11970
11350
  this.emit(KeyProviderEvent.RatchetRequest, participantIdentity, keyIndex);
11971
11351
  }
11972
11352
  };
11973
- ExternalE2EEKeyProvider = class extends BaseKeyProvider {
11974
- constructor() {
11975
- let options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
11976
- const opts = Object.assign(Object.assign({}, options), {
11977
- sharedKey: true,
11978
- // for a shared key provider failing to decrypt for a specific participant
11979
- // should not mark the key as invalid, so we accept wrong keys forever
11980
- // and won't try to auto-ratchet
11981
- ratchetWindowSize: 0,
11982
- failureTolerance: -1
11983
- });
11984
- super(opts);
11985
- }
11986
- /**
11987
- * Accepts a passphrase that's used to create the crypto keys.
11988
- * When passing in a string, PBKDF2 is used.
11989
- * When passing in an Array buffer of cryptographically random numbers, HKDF is being used. (recommended)
11990
- * @param key
11991
- */
11992
- setKey(key) {
11993
- return __awaiter(this, void 0, void 0, function* () {
11994
- const derivedKey = typeof key === "string" ? yield createKeyMaterialFromString(key) : yield createKeyMaterialFromBuffer(key);
11995
- this.onSetEncryptionKey(derivedKey);
11996
- });
11997
- }
11998
- };
11999
11353
  LivekitError = class extends Error {
12000
11354
  constructor(code4, message) {
12001
11355
  super(message || "an error has occured");
@@ -12051,12 +11405,6 @@ var init_livekit_client_esm = __esm({
12051
11405
  this.name = "NegotiationError";
12052
11406
  }
12053
11407
  };
12054
- PublishDataError = class extends LivekitError {
12055
- constructor(message) {
12056
- super(14, message !== null && message !== void 0 ? message : "unable to publish data");
12057
- this.name = "PublishDataError";
12058
- }
12059
- };
12060
11408
  PublishTrackError = class extends LivekitError {
12061
11409
  constructor(message, status) {
12062
11410
  super(15, message);
@@ -12099,15 +11447,6 @@ var init_livekit_client_esm = __esm({
12099
11447
  CryptorErrorReason2[CryptorErrorReason2["MissingKey"] = 1] = "MissingKey";
12100
11448
  CryptorErrorReason2[CryptorErrorReason2["InternalError"] = 2] = "InternalError";
12101
11449
  })(CryptorErrorReason || (CryptorErrorReason = {}));
12102
- CryptorError = class extends LivekitError {
12103
- constructor(message) {
12104
- let reason = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : CryptorErrorReason.InternalError;
12105
- let participantIdentity = arguments.length > 2 ? arguments[2] : void 0;
12106
- super(40, message);
12107
- this.reason = reason;
12108
- this.participantIdentity = participantIdentity;
12109
- }
12110
- };
12111
11450
  (function(RoomEvent2) {
12112
11451
  RoomEvent2["Connected"] = "connected";
12113
11452
  RoomEvent2["Reconnecting"] = "reconnecting";
@@ -22836,24 +22175,6 @@ var init_livekit_client_esm = __esm({
22836
22175
  Room.cleanupRegistry = typeof FinalizationRegistry !== "undefined" && new FinalizationRegistry((cleanup) => {
22837
22176
  cleanup();
22838
22177
  });
22839
- Convert = class {
22840
- static toAgentAttributes(json) {
22841
- return JSON.parse(json);
22842
- }
22843
- static agentAttributesToJson(value) {
22844
- return JSON.stringify(value);
22845
- }
22846
- static toTranscriptionAttributes(json) {
22847
- return JSON.parse(json);
22848
- }
22849
- static transcriptionAttributesToJson(value) {
22850
- return JSON.stringify(value);
22851
- }
22852
- };
22853
- attributeTypings = /* @__PURE__ */ Object.freeze({
22854
- __proto__: null,
22855
- Convert
22856
- });
22857
22178
  (function(CheckStatus2) {
22858
22179
  CheckStatus2[CheckStatus2["IDLE"] = 0] = "IDLE";
22859
22180
  CheckStatus2[CheckStatus2["RUNNING"] = 1] = "RUNNING";
@@ -23537,17 +22858,258 @@ var init_livekit_client_esm = __esm({
23537
22858
  });
23538
22859
  }
23539
22860
  };
23540
- knownDeviceLabels = /* @__PURE__ */ new Map([["obs virtual camera", {
23541
- facingMode: "environment",
23542
- confidence: "medium"
23543
- }]]);
23544
- knownDeviceLabelSections = /* @__PURE__ */ new Map([["iphone", {
23545
- facingMode: "environment",
23546
- confidence: "medium"
23547
- }], ["ipad", {
23548
- facingMode: "environment",
23549
- confidence: "medium"
23550
- }]]);
22861
+ }
22862
+ });
22863
+
22864
+ // src/utils/jsx-encoder.ts
22865
+ function generateStableDOMId(element3) {
22866
+ const tagName = element3.tagName.toLowerCase();
22867
+ const text7 = (element3.textContent || "").trim().substring(0, 50);
22868
+ let sibling = element3.previousElementSibling;
22869
+ let position3 = 1;
22870
+ while (sibling) {
22871
+ if (sibling.tagName === element3.tagName) {
22872
+ position3++;
22873
+ }
22874
+ sibling = sibling.previousElementSibling;
22875
+ }
22876
+ const path2 = getElementPath2(element3);
22877
+ const idString = `${tagName}[${position3}]_(${text7})_${path2}`;
22878
+ let hash = 0;
22879
+ for (let i2 = 0; i2 < idString.length; i2++) {
22880
+ const char = idString.charCodeAt(i2);
22881
+ hash = (hash << 5) - hash + char;
22882
+ hash |= 0;
22883
+ }
22884
+ return hash.toString(36);
22885
+ }
22886
+ function getElementPath2(element3) {
22887
+ if (element3.id) {
22888
+ return `id(${element3.id})`;
22889
+ }
22890
+ if (element3.tagName.toLowerCase() === "body") {
22891
+ return "/body";
22892
+ }
22893
+ let ix = 0;
22894
+ const siblings = element3.parentNode?.children || new HTMLCollection();
22895
+ for (let i2 = 0; i2 < siblings.length; i2++) {
22896
+ const sibling = siblings[i2];
22897
+ if (sibling === element3) {
22898
+ return `${getElementPath2(element3.parentNode)}/${element3.tagName}[${ix + 1}]`;
22899
+ }
22900
+ if (sibling.nodeType === 1 && sibling.tagName === element3.tagName) {
22901
+ ix++;
22902
+ }
22903
+ }
22904
+ return "not_found";
22905
+ }
22906
+ var init_jsx_encoder = __esm({
22907
+ "src/utils/jsx-encoder.ts"() {
22908
+ "use strict";
22909
+ }
22910
+ });
22911
+
22912
+ // src/utils/element-service.ts
22913
+ function getInteractiveElements() {
22914
+ const elements = document.querySelectorAll(INTERACTIVE_ELEMENT_SELECTOR);
22915
+ return Array.from(new Set(Array.from(elements)));
22916
+ }
22917
+ function getImmediateText(element3) {
22918
+ let text7 = "";
22919
+ if (element3.childNodes) {
22920
+ for (const node2 of Array.from(element3.childNodes)) {
22921
+ if (node2.nodeType === 3) {
22922
+ text7 += node2.textContent || "";
22923
+ }
22924
+ }
22925
+ }
22926
+ return text7.trim();
22927
+ }
22928
+ function captureFullDOMStructure() {
22929
+ console.log("\u{1F333} Capturing full DOM structure for Cuekit...");
22930
+ const interactiveElements = [];
22931
+ const descriptionsMap = /* @__PURE__ */ new Map();
22932
+ document.querySelectorAll("[data-for]").forEach((el) => {
22933
+ const targetId = el.getAttribute("data-for");
22934
+ if (!targetId) return;
22935
+ const tags = [];
22936
+ const description = el.getAttribute("data-ansyr-description");
22937
+ if (description) {
22938
+ tags.push(description);
22939
+ }
22940
+ if (el.textContent) {
22941
+ tags.push(el.textContent.trim());
22942
+ }
22943
+ if (tags.length > 0) {
22944
+ const existingTags = descriptionsMap.get(targetId) || [];
22945
+ descriptionsMap.set(targetId, [...existingTags, ...tags]);
22946
+ }
22947
+ });
22948
+ const allElements = getInteractiveElements();
22949
+ allElements.forEach((element3) => {
22950
+ const style = getComputedStyle(element3);
22951
+ if (element3.closest("[data-cuekit-ignore]") || !isElementClickable(element3) || element3.tagName.toLowerCase() === "script" || style.display === "none" || style.visibility === "hidden") {
22952
+ return;
22953
+ }
22954
+ const staticId = element3.getAttribute("data-ansyr-static");
22955
+ const dynamicId = element3.getAttribute("data-ansyr-dynamic");
22956
+ const id = staticId || dynamicId;
22957
+ const tags = [];
22958
+ const directDescription = element3.getAttribute("data-ansyr-description");
22959
+ if (directDescription) {
22960
+ tags.push(directDescription);
22961
+ }
22962
+ if (id && descriptionsMap.has(id)) {
22963
+ tags.push(...descriptionsMap.get(id) || []);
22964
+ }
22965
+ const dto = {
22966
+ testID: id || generateStableDOMId(element3),
22967
+ type: element3.tagName.toLowerCase(),
22968
+ textContent: getImmediateText(element3) || element3.textContent?.trim() || "",
22969
+ tags
22970
+ };
22971
+ interactiveElements.push(dto);
22972
+ });
22973
+ const result = {
22974
+ components: interactiveElements
22975
+ };
22976
+ console.log("\u{1F333} Full DOM structure captured:", result);
22977
+ return result;
22978
+ }
22979
+ function isElementClickable(element3) {
22980
+ const interactiveSelectors = [
22981
+ "button",
22982
+ "a",
22983
+ "input",
22984
+ "select",
22985
+ "textarea",
22986
+ '[role="button"]',
22987
+ '[role="link"]',
22988
+ '[role="tab"]',
22989
+ "[data-onclick-id]",
22990
+ "[data-on-press-id]",
22991
+ "[onclick]",
22992
+ "[onmousedown]",
22993
+ "[onmouseup]",
22994
+ "[ontouchstart]",
22995
+ "[ontouchend]",
22996
+ "[onkeydown]",
22997
+ "[onkeyup]",
22998
+ "[onkeypress]"
22999
+ ];
23000
+ for (const selector of interactiveSelectors) {
23001
+ if (element3.matches(selector)) {
23002
+ return true;
23003
+ }
23004
+ }
23005
+ const hasClickEvents = element3.onclick !== null || element3.getAttribute("onclick") !== null;
23006
+ const hasInteractiveEvents = element3.ontouchstart !== null || element3.getAttribute("ontouchstart") !== null || element3.ontouchend !== null || element3.getAttribute("ontouchend") !== null || element3.onkeydown !== null || element3.getAttribute("onkeydown") !== null || element3.onkeyup !== null || element3.getAttribute("onkeyup") !== null || element3.onkeypress !== null || element3.getAttribute("onkeypress") !== null;
23007
+ const hasPointerCursor = element3.style.cursor === "pointer" || getComputedStyle(element3).cursor === "pointer";
23008
+ const hasTabIndex = element3.hasAttribute("tabindex") && parseInt(element3.getAttribute("tabindex") || "0") >= 0;
23009
+ const hasInteractiveDataAttrs = element3.hasAttribute("data-clickable") || element3.hasAttribute("data-interactive") || element3.hasAttribute("data-action") || element3.hasAttribute("data-handler");
23010
+ const hasInteractiveAria = element3.hasAttribute("aria-pressed") || element3.hasAttribute("aria-expanded") || element3.hasAttribute("aria-selected") || element3.hasAttribute("aria-checked");
23011
+ return hasClickEvents || hasInteractiveEvents || hasPointerCursor || hasTabIndex || hasInteractiveDataAttrs || hasInteractiveAria;
23012
+ }
23013
+ function executeAction(action) {
23014
+ console.log("\u{1F3AF} Executing element action:", action);
23015
+ const { action_type, target_element, target } = action;
23016
+ switch (action_type) {
23017
+ case "click":
23018
+ return clickElement(target_element);
23019
+ case "navigate":
23020
+ return navigateToElement(target_element || target);
23021
+ case "input":
23022
+ case "focus":
23023
+ return focusElement(target_element);
23024
+ case "toggle":
23025
+ return toggleElement(target_element);
23026
+ default:
23027
+ console.warn(`\u26A0\uFE0F Unknown action type: ${action_type}`);
23028
+ return false;
23029
+ }
23030
+ }
23031
+ function getFullDOMStructure() {
23032
+ return captureFullDOMStructure();
23033
+ }
23034
+ function clickElement(elementId) {
23035
+ if (!elementId) {
23036
+ return false;
23037
+ }
23038
+ const domElement = findDOMElementById(elementId);
23039
+ if (domElement) {
23040
+ domElement.click();
23041
+ return true;
23042
+ }
23043
+ return false;
23044
+ }
23045
+ function navigateToElement(target) {
23046
+ if (!target) {
23047
+ return false;
23048
+ }
23049
+ if (target.includes("/") || target.startsWith("http")) {
23050
+ safeNavigate(target, {});
23051
+ } else {
23052
+ handleNavigationAndClick(target, target);
23053
+ }
23054
+ return true;
23055
+ }
23056
+ function focusElement(elementId) {
23057
+ if (!elementId) {
23058
+ return false;
23059
+ }
23060
+ const domElement = findDOMElementById(elementId);
23061
+ if (domElement instanceof HTMLInputElement || domElement instanceof HTMLTextAreaElement || domElement instanceof HTMLSelectElement) {
23062
+ domElement.focus();
23063
+ return true;
23064
+ } else {
23065
+ return false;
23066
+ }
23067
+ }
23068
+ function toggleElement(elementId) {
23069
+ if (!elementId) {
23070
+ return false;
23071
+ }
23072
+ const domElement = findDOMElementById(elementId);
23073
+ if (domElement instanceof HTMLElement) {
23074
+ if (domElement instanceof HTMLInputElement) {
23075
+ if (domElement.type === "checkbox") {
23076
+ domElement.checked = !domElement.checked;
23077
+ } else if (domElement.type === "radio") {
23078
+ domElement.checked = true;
23079
+ }
23080
+ domElement.dispatchEvent(new Event("change", { bubbles: true }));
23081
+ } else {
23082
+ domElement.click();
23083
+ }
23084
+ return true;
23085
+ } else {
23086
+ return false;
23087
+ }
23088
+ }
23089
+ function findDOMElementById(elementId) {
23090
+ if (!elementId) {
23091
+ return null;
23092
+ }
23093
+ const interactiveElements = getInteractiveElements();
23094
+ for (const element3 of interactiveElements) {
23095
+ if (element3 instanceof HTMLElement) {
23096
+ const staticId = element3.getAttribute("data-ansyr-static");
23097
+ const dynamicId = element3.getAttribute("data-ansyr-dynamic");
23098
+ const currentElementId = staticId || dynamicId || generateStableDOMId(element3);
23099
+ if (currentElementId === elementId) {
23100
+ return element3;
23101
+ }
23102
+ }
23103
+ }
23104
+ return null;
23105
+ }
23106
+ var INTERACTIVE_ELEMENT_SELECTOR;
23107
+ var init_element_service = __esm({
23108
+ "src/utils/element-service.ts"() {
23109
+ "use strict";
23110
+ init_navigation();
23111
+ init_jsx_encoder();
23112
+ INTERACTIVE_ELEMENT_SELECTOR = 'a, button, input, textarea, select, [role="button"], [onclick], [data-ansyr-static], [data-ansyr-dynamic]';
23551
23113
  }
23552
23114
  });
23553
23115
 
@@ -23570,12 +23132,6 @@ __export(webrtc_service_exports, {
23570
23132
  setServerUrl: () => setServerUrl,
23571
23133
  setWebRTCCallbacks: () => setWebRTCCallbacks
23572
23134
  });
23573
- async function getLiveKitClient() {
23574
- if (!livekitClient) {
23575
- livekitClient = await Promise.resolve().then(() => (init_livekit_client_esm(), livekit_client_esm_exports));
23576
- }
23577
- return livekitClient;
23578
- }
23579
23135
  function setServerUrl(url) {
23580
23136
  serverUrl = url;
23581
23137
  }
@@ -23587,31 +23143,29 @@ function setWebRTCCallbacks(newCallbacks) {
23587
23143
  }
23588
23144
  async function authenticate(userIdentity, apiKey, appId) {
23589
23145
  try {
23590
- console.log("\u{1F3A4} WebRTCService: Authenticating user...", { userIdentity });
23146
+ const authPayload = {
23147
+ user_identity: userIdentity,
23148
+ app_id: appId || _appId
23149
+ };
23591
23150
  const response = await fetch(`${serverUrl}/auth/login`, {
23592
23151
  method: "POST",
23593
23152
  headers: {
23594
23153
  "Content-Type": "application/json",
23595
23154
  "X-API-Key": apiKey
23596
23155
  },
23597
- body: JSON.stringify({
23598
- user_identity: userIdentity,
23599
- app_id: appId || _appId
23600
- })
23156
+ body: JSON.stringify(authPayload)
23601
23157
  });
23602
23158
  if (!response.ok) {
23603
23159
  const errorData = await response.json();
23604
23160
  throw new Error(errorData.detail || "Authentication failed");
23605
23161
  }
23606
23162
  const authData = await response.json();
23607
- console.log("\u{1F3A4} WebRTCService: Authentication successful:", authData);
23608
23163
  livekitUrl = authData.livekit_url;
23609
23164
  token = authData.livekit_token;
23610
23165
  roomName = authData.room_name;
23611
23166
  userIdentity = authData.user_identity;
23612
23167
  return authData;
23613
23168
  } catch (error) {
23614
- console.error("\u{1F3A4} WebRTCService: Authentication failed:", error);
23615
23169
  throw error;
23616
23170
  }
23617
23171
  }
@@ -23621,88 +23175,70 @@ async function connectToRoom(newLivekitUrl, newToken) {
23621
23175
  if (!url || !authToken) {
23622
23176
  throw new Error("Missing LiveKit URL or token. Please authenticate first.");
23623
23177
  }
23624
- console.log("\u{1F3A4} WebRTCService: Connecting to room...", { url, hasToken: !!authToken });
23625
23178
  try {
23626
23179
  setWebRTCConnectionState({ isConnected: false, isConnecting: true });
23627
- const { Room: Room3 } = await getLiveKitClient();
23628
- room = new Room3({
23180
+ room = new Room({
23629
23181
  adaptiveStream: true,
23630
23182
  dynacast: true
23631
23183
  });
23632
- await setupEventListeners();
23633
- await room?.connect(url, authToken);
23634
- console.log("\u{1F3A4} WebRTCService: Successfully connected to room:", room?.name);
23184
+ setupEventListeners();
23185
+ await room.connect(url, authToken);
23635
23186
  setWebRTCConnectionState({ isConnected: true, isConnecting: false });
23636
23187
  try {
23637
- await room?.localParticipant.setMicrophoneEnabled(true);
23638
- console.log("\u{1F3A4} WebRTCService: Microphone enabled");
23188
+ await room.localParticipant.setMicrophoneEnabled(true);
23639
23189
  } catch (micError) {
23640
- console.warn("\u{1F3A4} WebRTCService: Failed to enable microphone:", micError);
23641
23190
  }
23642
23191
  return { success: true };
23643
23192
  } catch (error) {
23644
- console.error("\u{1F3A4} WebRTCService: Failed to connect to room:", error);
23645
23193
  setWebRTCConnectionState({ isConnected: false, isConnecting: false });
23646
23194
  throw error;
23647
23195
  }
23648
23196
  }
23649
- async function setupEventListeners() {
23197
+ function setupEventListeners() {
23650
23198
  if (!room) return;
23651
- const { RoomEvent: RoomEvent2, ConnectionState: ConnectionState2, Track: Track2 } = await getLiveKitClient();
23652
- room.on(RoomEvent2.ConnectionStateChanged, (state) => {
23653
- console.log("\u{1F3A4} WebRTCService: Connection state changed:", state);
23199
+ room.on(RoomEvent.ConnectionStateChanged, (state) => {
23654
23200
  callbacks.onConnectionStateChange?.(state);
23655
- if (state === ConnectionState2.Connected) {
23656
- console.log("\u{1F3A4} WebRTCService: Successfully connected to room");
23201
+ if (state === ConnectionState.Connected) {
23657
23202
  setWebRTCConnectionState({ isConnected: true, isConnecting: false });
23658
- } else if (state === ConnectionState2.Disconnected) {
23659
- console.log("\u{1F3A4} WebRTCService: Disconnected from room");
23203
+ } else if (state === ConnectionState.Disconnected) {
23660
23204
  setWebRTCConnectionState({ isConnected: false, isConnecting: false });
23661
- } else if (state === ConnectionState2.Connecting) {
23662
- console.log("\u{1F3A4} WebRTCService: Connecting to room...");
23205
+ } else if (state === ConnectionState.Connecting) {
23663
23206
  setWebRTCConnectionState({ isConnected: false, isConnecting: true });
23664
23207
  }
23665
- }).on(RoomEvent2.ParticipantConnected, (participant) => {
23666
- console.log("\u{1F3A4} WebRTCService: Participant connected:", participant.identity);
23208
+ }).on(RoomEvent.ParticipantConnected, (participant) => {
23667
23209
  updateParticipantsList();
23668
- }).on(RoomEvent2.ParticipantDisconnected, (participant) => {
23669
- console.log("\u{1F3A4} WebRTCService: Participant disconnected:", participant.identity);
23210
+ }).on(RoomEvent.ParticipantDisconnected, (participant) => {
23670
23211
  updateParticipantsList();
23671
- }).on(
23672
- RoomEvent2.TrackSubscribed,
23673
- (track, publication, participant) => {
23674
- if (track.kind === Track2.Kind.Audio && !participant.isLocal) {
23675
- const isAIParticipant = participant.identity.toLowerCase().includes("ai") || participant.identity.toLowerCase().includes("bot") || !participant.identity.startsWith("user_");
23676
- if (isAIParticipant) {
23677
- const element3 = track.attach();
23678
- if (audioContainerRef?.current) {
23679
- audioContainerRef.current.appendChild(element3);
23680
- if (element3 instanceof HTMLAudioElement) {
23681
- const trackId = track.sid || `track_${Date.now()}_${Math.random()}`;
23682
- callbacks.onAISpeechStart?.(trackId);
23683
- element3.play().catch(
23684
- (error) => console.warn("\u{1F3A4} WebRTCService: Failed to auto-play audio:", error)
23685
- );
23686
- element3.addEventListener("ended", () => callbacks.onAISpeechEnd?.(trackId));
23687
- element3.addEventListener("pause", () => callbacks.onAISpeechEnd?.(trackId));
23688
- }
23212
+ }).on(RoomEvent.TrackSubscribed, (track, publication, participant) => {
23213
+ if (track.kind === Track.Kind.Audio && !participant.isLocal) {
23214
+ const isAIParticipant = participant.identity.toLowerCase().includes("ai") || participant.identity.toLowerCase().includes("bot") || !participant.identity.startsWith("user_");
23215
+ if (isAIParticipant) {
23216
+ const element3 = track.attach();
23217
+ if (audioContainerRef?.current) {
23218
+ audioContainerRef.current.appendChild(element3);
23219
+ if (element3 instanceof HTMLAudioElement) {
23220
+ const trackId = track.sid || `track_${Date.now()}_${Math.random()}`;
23221
+ callbacks.onAISpeechStart?.(trackId);
23222
+ element3.play().catch((error) => {
23223
+ });
23224
+ element3.addEventListener("ended", () => callbacks.onAISpeechEnd?.(trackId));
23225
+ element3.addEventListener("pause", () => callbacks.onAISpeechEnd?.(trackId));
23689
23226
  }
23690
23227
  }
23691
23228
  }
23692
23229
  }
23693
- ).on(RoomEvent2.TrackUnsubscribed, (track) => {
23230
+ }).on(RoomEvent.TrackUnsubscribed, (track) => {
23694
23231
  track.detach().forEach((element3) => element3.remove());
23695
- }).on(RoomEvent2.DataReceived, (payload, participant) => {
23696
- console.log("\u{1F4E1} LiveKit data received:", new TextDecoder().decode(payload));
23232
+ }).on(RoomEvent.DataReceived, (payload, participant) => {
23233
+ const decodedPayload = new TextDecoder().decode(payload);
23697
23234
  try {
23698
- const message = JSON.parse(new TextDecoder().decode(payload));
23699
- console.log("\u{1F4E1} LiveKit data received:", message);
23235
+ const message = JSON.parse(decodedPayload);
23700
23236
  callbacks.onNavigationCommand?.(message);
23701
23237
  } catch (error) {
23702
- const message = new TextDecoder().decode(payload);
23238
+ const message = decodedPayload;
23703
23239
  callbacks.onNavigationCommand?.({ type: "raw_text", data: message });
23704
23240
  }
23705
- }).on(RoomEvent2.Disconnected, () => {
23241
+ }).on(RoomEvent.Disconnected, () => {
23706
23242
  setWebRTCConnectionState({ isConnected: false, isConnecting: false });
23707
23243
  });
23708
23244
  }
@@ -23718,32 +23254,30 @@ function updateParticipantsList() {
23718
23254
  async function sendData(data, reliable = true) {
23719
23255
  if (!room) throw new Error("Not connected to room");
23720
23256
  try {
23721
- console.log("\u{1F4E1} LiveKit data sending:", data);
23257
+ console.log("\u2B06\uFE0F Sending data to backend [DataChannel]:", data);
23722
23258
  const encoder = new TextEncoder();
23723
23259
  const encodedData = encoder.encode(data);
23724
23260
  await room.localParticipant.publishData(encodedData, {
23725
23261
  reliable
23726
23262
  });
23727
23263
  } catch (error) {
23728
- console.error("\u274C Failed to send data:", error);
23264
+ throw error;
23729
23265
  }
23730
23266
  }
23731
23267
  async function sendScreenStatus(screenData) {
23732
23268
  try {
23269
+ console.log("\u2B06\uFE0F Sending to backend [/ai/data]:", JSON.stringify(screenData, null, 2));
23733
23270
  await fetch(`${serverUrl}/ai/data`, {
23734
23271
  method: "POST",
23735
23272
  headers: { "Content-Type": "application/json" },
23736
23273
  body: JSON.stringify(screenData)
23737
23274
  });
23738
23275
  } catch (error) {
23739
- console.error("Error sending screen status:", error);
23740
23276
  throw error;
23741
23277
  }
23742
23278
  }
23743
- async function isConnected() {
23744
- if (!room) return false;
23745
- const { ConnectionState: ConnectionState2 } = await getLiveKitClient();
23746
- return room?.state === ConnectionState2.Connected;
23279
+ function isConnected() {
23280
+ return room?.state === ConnectionState.Connected;
23747
23281
  }
23748
23282
  function getRoomName() {
23749
23283
  return roomName;
@@ -23753,12 +23287,10 @@ function getParticipants() {
23753
23287
  }
23754
23288
  async function sendUserCommand(command) {
23755
23289
  if (!room) return;
23756
- console.log(`\u{1F4AC} Sending user command: "${command}"`);
23757
23290
  await sendData(command);
23758
23291
  }
23759
23292
  async function sendRuntimeData() {
23760
23293
  if (!room) {
23761
- console.error("\u274C Cannot send runtime data without a room connection");
23762
23294
  return;
23763
23295
  }
23764
23296
  try {
@@ -23771,28 +23303,28 @@ async function sendRuntimeData() {
23771
23303
  current_screen: screenName
23772
23304
  }
23773
23305
  };
23774
- console.log("\u{1F4E6} Sending runtime data response");
23775
23306
  await sendData(JSON.stringify(response));
23776
- console.log("\u{1F4E6} Runtime data sent successfully");
23777
23307
  } catch (error) {
23778
- console.error("\u274C Failed to send runtime data:", error);
23779
23308
  }
23780
23309
  }
23781
23310
  async function sendStaticData(componentData, appId = "default") {
23782
23311
  try {
23312
+ const staticDataPayload = {
23313
+ type: "dashboard_data",
23314
+ app_id: appId,
23315
+ data: componentData
23316
+ };
23317
+ console.log("\u2B06\uFE0F Sending to backend [/ai/data]:", JSON.stringify(staticDataPayload, null, 2));
23783
23318
  const response = await fetch(`${serverUrl}/ai/data`, {
23784
23319
  method: "POST",
23785
23320
  headers: {
23786
23321
  "Content-Type": "application/json"
23787
23322
  },
23788
- body: JSON.stringify({
23789
- type: "dashboard_data",
23790
- app_id: appId,
23791
- data: componentData
23792
- })
23323
+ body: JSON.stringify(staticDataPayload)
23793
23324
  });
23794
23325
  if (response.ok) {
23795
23326
  const result = await response.json();
23327
+ console.log("\u2B07\uFE0F Received from backend [/ai/data]:", JSON.stringify(result, null, 2));
23796
23328
  return { success: true, data: result };
23797
23329
  } else {
23798
23330
  const errorText = await response.text();
@@ -23820,10 +23352,11 @@ async function disconnectFromRoom() {
23820
23352
  function getRoom() {
23821
23353
  return room;
23822
23354
  }
23823
- var room, reconnectTimeout, serverUrl, callbacks, audioContainerRef, livekitUrl, token, roomName, livekitClient;
23355
+ var room, reconnectTimeout, serverUrl, callbacks, audioContainerRef, livekitUrl, token, roomName;
23824
23356
  var init_webrtc_service = __esm({
23825
23357
  "src/utils/webrtc-service.ts"() {
23826
23358
  "use strict";
23359
+ init_livekit_client_esm();
23827
23360
  init_globals();
23828
23361
  init_constants();
23829
23362
  init_element_service();
@@ -23836,7 +23369,6 @@ var init_webrtc_service = __esm({
23836
23369
  livekitUrl = null;
23837
23370
  token = null;
23838
23371
  roomName = null;
23839
- livekitClient = null;
23840
23372
  }
23841
23373
  });
23842
23374
 
@@ -24170,6 +23702,802 @@ var require_extend = __commonJS({
24170
23702
  }
24171
23703
  });
24172
23704
 
23705
+ // (disabled):crypto
23706
+ var require_crypto = __commonJS({
23707
+ "(disabled):crypto"() {
23708
+ "use strict";
23709
+ }
23710
+ });
23711
+
23712
+ // node_modules/crypto-js/core.js
23713
+ var require_core = __commonJS({
23714
+ "node_modules/crypto-js/core.js"(exports, module2) {
23715
+ "use strict";
23716
+ (function(root4, factory) {
23717
+ if (typeof exports === "object") {
23718
+ module2.exports = exports = factory();
23719
+ } else if (typeof define === "function" && define.amd) {
23720
+ define([], factory);
23721
+ } else {
23722
+ root4.CryptoJS = factory();
23723
+ }
23724
+ })(exports, function() {
23725
+ var CryptoJS = CryptoJS || function(Math2, undefined2) {
23726
+ var crypto2;
23727
+ if (typeof window !== "undefined" && window.crypto) {
23728
+ crypto2 = window.crypto;
23729
+ }
23730
+ if (typeof self !== "undefined" && self.crypto) {
23731
+ crypto2 = self.crypto;
23732
+ }
23733
+ if (typeof globalThis !== "undefined" && globalThis.crypto) {
23734
+ crypto2 = globalThis.crypto;
23735
+ }
23736
+ if (!crypto2 && typeof window !== "undefined" && window.msCrypto) {
23737
+ crypto2 = window.msCrypto;
23738
+ }
23739
+ if (!crypto2 && typeof global !== "undefined" && global.crypto) {
23740
+ crypto2 = global.crypto;
23741
+ }
23742
+ if (!crypto2 && typeof require === "function") {
23743
+ try {
23744
+ crypto2 = require_crypto();
23745
+ } catch (err) {
23746
+ }
23747
+ }
23748
+ var cryptoSecureRandomInt = function() {
23749
+ if (crypto2) {
23750
+ if (typeof crypto2.getRandomValues === "function") {
23751
+ try {
23752
+ return crypto2.getRandomValues(new Uint32Array(1))[0];
23753
+ } catch (err) {
23754
+ }
23755
+ }
23756
+ if (typeof crypto2.randomBytes === "function") {
23757
+ try {
23758
+ return crypto2.randomBytes(4).readInt32LE();
23759
+ } catch (err) {
23760
+ }
23761
+ }
23762
+ }
23763
+ throw new Error("Native crypto module could not be used to get secure random number.");
23764
+ };
23765
+ var create2 = Object.create || /* @__PURE__ */ function() {
23766
+ function F2() {
23767
+ }
23768
+ return function(obj) {
23769
+ var subtype;
23770
+ F2.prototype = obj;
23771
+ subtype = new F2();
23772
+ F2.prototype = null;
23773
+ return subtype;
23774
+ };
23775
+ }();
23776
+ var C = {};
23777
+ var C_lib = C.lib = {};
23778
+ var Base = C_lib.Base = /* @__PURE__ */ function() {
23779
+ return {
23780
+ /**
23781
+ * Creates a new object that inherits from this object.
23782
+ *
23783
+ * @param {Object} overrides Properties to copy into the new object.
23784
+ *
23785
+ * @return {Object} The new object.
23786
+ *
23787
+ * @static
23788
+ *
23789
+ * @example
23790
+ *
23791
+ * var MyType = CryptoJS.lib.Base.extend({
23792
+ * field: 'value',
23793
+ *
23794
+ * method: function () {
23795
+ * }
23796
+ * });
23797
+ */
23798
+ extend: function(overrides) {
23799
+ var subtype = create2(this);
23800
+ if (overrides) {
23801
+ subtype.mixIn(overrides);
23802
+ }
23803
+ if (!subtype.hasOwnProperty("init") || this.init === subtype.init) {
23804
+ subtype.init = function() {
23805
+ subtype.$super.init.apply(this, arguments);
23806
+ };
23807
+ }
23808
+ subtype.init.prototype = subtype;
23809
+ subtype.$super = this;
23810
+ return subtype;
23811
+ },
23812
+ /**
23813
+ * Extends this object and runs the init method.
23814
+ * Arguments to create() will be passed to init().
23815
+ *
23816
+ * @return {Object} The new object.
23817
+ *
23818
+ * @static
23819
+ *
23820
+ * @example
23821
+ *
23822
+ * var instance = MyType.create();
23823
+ */
23824
+ create: function() {
23825
+ var instance = this.extend();
23826
+ instance.init.apply(instance, arguments);
23827
+ return instance;
23828
+ },
23829
+ /**
23830
+ * Initializes a newly created object.
23831
+ * Override this method to add some logic when your objects are created.
23832
+ *
23833
+ * @example
23834
+ *
23835
+ * var MyType = CryptoJS.lib.Base.extend({
23836
+ * init: function () {
23837
+ * // ...
23838
+ * }
23839
+ * });
23840
+ */
23841
+ init: function() {
23842
+ },
23843
+ /**
23844
+ * Copies properties into this object.
23845
+ *
23846
+ * @param {Object} properties The properties to mix in.
23847
+ *
23848
+ * @example
23849
+ *
23850
+ * MyType.mixIn({
23851
+ * field: 'value'
23852
+ * });
23853
+ */
23854
+ mixIn: function(properties) {
23855
+ for (var propertyName in properties) {
23856
+ if (properties.hasOwnProperty(propertyName)) {
23857
+ this[propertyName] = properties[propertyName];
23858
+ }
23859
+ }
23860
+ if (properties.hasOwnProperty("toString")) {
23861
+ this.toString = properties.toString;
23862
+ }
23863
+ },
23864
+ /**
23865
+ * Creates a copy of this object.
23866
+ *
23867
+ * @return {Object} The clone.
23868
+ *
23869
+ * @example
23870
+ *
23871
+ * var clone = instance.clone();
23872
+ */
23873
+ clone: function() {
23874
+ return this.init.prototype.extend(this);
23875
+ }
23876
+ };
23877
+ }();
23878
+ var WordArray = C_lib.WordArray = Base.extend({
23879
+ /**
23880
+ * Initializes a newly created word array.
23881
+ *
23882
+ * @param {Array} words (Optional) An array of 32-bit words.
23883
+ * @param {number} sigBytes (Optional) The number of significant bytes in the words.
23884
+ *
23885
+ * @example
23886
+ *
23887
+ * var wordArray = CryptoJS.lib.WordArray.create();
23888
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
23889
+ * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
23890
+ */
23891
+ init: function(words, sigBytes) {
23892
+ words = this.words = words || [];
23893
+ if (sigBytes != undefined2) {
23894
+ this.sigBytes = sigBytes;
23895
+ } else {
23896
+ this.sigBytes = words.length * 4;
23897
+ }
23898
+ },
23899
+ /**
23900
+ * Converts this word array to a string.
23901
+ *
23902
+ * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
23903
+ *
23904
+ * @return {string} The stringified word array.
23905
+ *
23906
+ * @example
23907
+ *
23908
+ * var string = wordArray + '';
23909
+ * var string = wordArray.toString();
23910
+ * var string = wordArray.toString(CryptoJS.enc.Utf8);
23911
+ */
23912
+ toString: function(encoder) {
23913
+ return (encoder || Hex).stringify(this);
23914
+ },
23915
+ /**
23916
+ * Concatenates a word array to this word array.
23917
+ *
23918
+ * @param {WordArray} wordArray The word array to append.
23919
+ *
23920
+ * @return {WordArray} This word array.
23921
+ *
23922
+ * @example
23923
+ *
23924
+ * wordArray1.concat(wordArray2);
23925
+ */
23926
+ concat: function(wordArray) {
23927
+ var thisWords = this.words;
23928
+ var thatWords = wordArray.words;
23929
+ var thisSigBytes = this.sigBytes;
23930
+ var thatSigBytes = wordArray.sigBytes;
23931
+ this.clamp();
23932
+ if (thisSigBytes % 4) {
23933
+ for (var i2 = 0; i2 < thatSigBytes; i2++) {
23934
+ var thatByte = thatWords[i2 >>> 2] >>> 24 - i2 % 4 * 8 & 255;
23935
+ thisWords[thisSigBytes + i2 >>> 2] |= thatByte << 24 - (thisSigBytes + i2) % 4 * 8;
23936
+ }
23937
+ } else {
23938
+ for (var j2 = 0; j2 < thatSigBytes; j2 += 4) {
23939
+ thisWords[thisSigBytes + j2 >>> 2] = thatWords[j2 >>> 2];
23940
+ }
23941
+ }
23942
+ this.sigBytes += thatSigBytes;
23943
+ return this;
23944
+ },
23945
+ /**
23946
+ * Removes insignificant bits.
23947
+ *
23948
+ * @example
23949
+ *
23950
+ * wordArray.clamp();
23951
+ */
23952
+ clamp: function() {
23953
+ var words = this.words;
23954
+ var sigBytes = this.sigBytes;
23955
+ words[sigBytes >>> 2] &= 4294967295 << 32 - sigBytes % 4 * 8;
23956
+ words.length = Math2.ceil(sigBytes / 4);
23957
+ },
23958
+ /**
23959
+ * Creates a copy of this word array.
23960
+ *
23961
+ * @return {WordArray} The clone.
23962
+ *
23963
+ * @example
23964
+ *
23965
+ * var clone = wordArray.clone();
23966
+ */
23967
+ clone: function() {
23968
+ var clone = Base.clone.call(this);
23969
+ clone.words = this.words.slice(0);
23970
+ return clone;
23971
+ },
23972
+ /**
23973
+ * Creates a word array filled with random bytes.
23974
+ *
23975
+ * @param {number} nBytes The number of random bytes to generate.
23976
+ *
23977
+ * @return {WordArray} The random word array.
23978
+ *
23979
+ * @static
23980
+ *
23981
+ * @example
23982
+ *
23983
+ * var wordArray = CryptoJS.lib.WordArray.random(16);
23984
+ */
23985
+ random: function(nBytes) {
23986
+ var words = [];
23987
+ for (var i2 = 0; i2 < nBytes; i2 += 4) {
23988
+ words.push(cryptoSecureRandomInt());
23989
+ }
23990
+ return new WordArray.init(words, nBytes);
23991
+ }
23992
+ });
23993
+ var C_enc = C.enc = {};
23994
+ var Hex = C_enc.Hex = {
23995
+ /**
23996
+ * Converts a word array to a hex string.
23997
+ *
23998
+ * @param {WordArray} wordArray The word array.
23999
+ *
24000
+ * @return {string} The hex string.
24001
+ *
24002
+ * @static
24003
+ *
24004
+ * @example
24005
+ *
24006
+ * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
24007
+ */
24008
+ stringify: function(wordArray) {
24009
+ var words = wordArray.words;
24010
+ var sigBytes = wordArray.sigBytes;
24011
+ var hexChars = [];
24012
+ for (var i2 = 0; i2 < sigBytes; i2++) {
24013
+ var bite = words[i2 >>> 2] >>> 24 - i2 % 4 * 8 & 255;
24014
+ hexChars.push((bite >>> 4).toString(16));
24015
+ hexChars.push((bite & 15).toString(16));
24016
+ }
24017
+ return hexChars.join("");
24018
+ },
24019
+ /**
24020
+ * Converts a hex string to a word array.
24021
+ *
24022
+ * @param {string} hexStr The hex string.
24023
+ *
24024
+ * @return {WordArray} The word array.
24025
+ *
24026
+ * @static
24027
+ *
24028
+ * @example
24029
+ *
24030
+ * var wordArray = CryptoJS.enc.Hex.parse(hexString);
24031
+ */
24032
+ parse: function(hexStr) {
24033
+ var hexStrLength = hexStr.length;
24034
+ var words = [];
24035
+ for (var i2 = 0; i2 < hexStrLength; i2 += 2) {
24036
+ words[i2 >>> 3] |= parseInt(hexStr.substr(i2, 2), 16) << 24 - i2 % 8 * 4;
24037
+ }
24038
+ return new WordArray.init(words, hexStrLength / 2);
24039
+ }
24040
+ };
24041
+ var Latin1 = C_enc.Latin1 = {
24042
+ /**
24043
+ * Converts a word array to a Latin1 string.
24044
+ *
24045
+ * @param {WordArray} wordArray The word array.
24046
+ *
24047
+ * @return {string} The Latin1 string.
24048
+ *
24049
+ * @static
24050
+ *
24051
+ * @example
24052
+ *
24053
+ * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
24054
+ */
24055
+ stringify: function(wordArray) {
24056
+ var words = wordArray.words;
24057
+ var sigBytes = wordArray.sigBytes;
24058
+ var latin1Chars = [];
24059
+ for (var i2 = 0; i2 < sigBytes; i2++) {
24060
+ var bite = words[i2 >>> 2] >>> 24 - i2 % 4 * 8 & 255;
24061
+ latin1Chars.push(String.fromCharCode(bite));
24062
+ }
24063
+ return latin1Chars.join("");
24064
+ },
24065
+ /**
24066
+ * Converts a Latin1 string to a word array.
24067
+ *
24068
+ * @param {string} latin1Str The Latin1 string.
24069
+ *
24070
+ * @return {WordArray} The word array.
24071
+ *
24072
+ * @static
24073
+ *
24074
+ * @example
24075
+ *
24076
+ * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
24077
+ */
24078
+ parse: function(latin1Str) {
24079
+ var latin1StrLength = latin1Str.length;
24080
+ var words = [];
24081
+ for (var i2 = 0; i2 < latin1StrLength; i2++) {
24082
+ words[i2 >>> 2] |= (latin1Str.charCodeAt(i2) & 255) << 24 - i2 % 4 * 8;
24083
+ }
24084
+ return new WordArray.init(words, latin1StrLength);
24085
+ }
24086
+ };
24087
+ var Utf8 = C_enc.Utf8 = {
24088
+ /**
24089
+ * Converts a word array to a UTF-8 string.
24090
+ *
24091
+ * @param {WordArray} wordArray The word array.
24092
+ *
24093
+ * @return {string} The UTF-8 string.
24094
+ *
24095
+ * @static
24096
+ *
24097
+ * @example
24098
+ *
24099
+ * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
24100
+ */
24101
+ stringify: function(wordArray) {
24102
+ try {
24103
+ return decodeURIComponent(escape(Latin1.stringify(wordArray)));
24104
+ } catch (e3) {
24105
+ throw new Error("Malformed UTF-8 data");
24106
+ }
24107
+ },
24108
+ /**
24109
+ * Converts a UTF-8 string to a word array.
24110
+ *
24111
+ * @param {string} utf8Str The UTF-8 string.
24112
+ *
24113
+ * @return {WordArray} The word array.
24114
+ *
24115
+ * @static
24116
+ *
24117
+ * @example
24118
+ *
24119
+ * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
24120
+ */
24121
+ parse: function(utf8Str) {
24122
+ return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
24123
+ }
24124
+ };
24125
+ var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
24126
+ /**
24127
+ * Resets this block algorithm's data buffer to its initial state.
24128
+ *
24129
+ * @example
24130
+ *
24131
+ * bufferedBlockAlgorithm.reset();
24132
+ */
24133
+ reset: function() {
24134
+ this._data = new WordArray.init();
24135
+ this._nDataBytes = 0;
24136
+ },
24137
+ /**
24138
+ * Adds new data to this block algorithm's buffer.
24139
+ *
24140
+ * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
24141
+ *
24142
+ * @example
24143
+ *
24144
+ * bufferedBlockAlgorithm._append('data');
24145
+ * bufferedBlockAlgorithm._append(wordArray);
24146
+ */
24147
+ _append: function(data) {
24148
+ if (typeof data == "string") {
24149
+ data = Utf8.parse(data);
24150
+ }
24151
+ this._data.concat(data);
24152
+ this._nDataBytes += data.sigBytes;
24153
+ },
24154
+ /**
24155
+ * Processes available data blocks.
24156
+ *
24157
+ * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
24158
+ *
24159
+ * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
24160
+ *
24161
+ * @return {WordArray} The processed data.
24162
+ *
24163
+ * @example
24164
+ *
24165
+ * var processedData = bufferedBlockAlgorithm._process();
24166
+ * var processedData = bufferedBlockAlgorithm._process(!!'flush');
24167
+ */
24168
+ _process: function(doFlush) {
24169
+ var processedWords;
24170
+ var data = this._data;
24171
+ var dataWords = data.words;
24172
+ var dataSigBytes = data.sigBytes;
24173
+ var blockSize = this.blockSize;
24174
+ var blockSizeBytes = blockSize * 4;
24175
+ var nBlocksReady = dataSigBytes / blockSizeBytes;
24176
+ if (doFlush) {
24177
+ nBlocksReady = Math2.ceil(nBlocksReady);
24178
+ } else {
24179
+ nBlocksReady = Math2.max((nBlocksReady | 0) - this._minBufferSize, 0);
24180
+ }
24181
+ var nWordsReady = nBlocksReady * blockSize;
24182
+ var nBytesReady = Math2.min(nWordsReady * 4, dataSigBytes);
24183
+ if (nWordsReady) {
24184
+ for (var offset = 0; offset < nWordsReady; offset += blockSize) {
24185
+ this._doProcessBlock(dataWords, offset);
24186
+ }
24187
+ processedWords = dataWords.splice(0, nWordsReady);
24188
+ data.sigBytes -= nBytesReady;
24189
+ }
24190
+ return new WordArray.init(processedWords, nBytesReady);
24191
+ },
24192
+ /**
24193
+ * Creates a copy of this object.
24194
+ *
24195
+ * @return {Object} The clone.
24196
+ *
24197
+ * @example
24198
+ *
24199
+ * var clone = bufferedBlockAlgorithm.clone();
24200
+ */
24201
+ clone: function() {
24202
+ var clone = Base.clone.call(this);
24203
+ clone._data = this._data.clone();
24204
+ return clone;
24205
+ },
24206
+ _minBufferSize: 0
24207
+ });
24208
+ var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
24209
+ /**
24210
+ * Configuration options.
24211
+ */
24212
+ cfg: Base.extend(),
24213
+ /**
24214
+ * Initializes a newly created hasher.
24215
+ *
24216
+ * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
24217
+ *
24218
+ * @example
24219
+ *
24220
+ * var hasher = CryptoJS.algo.SHA256.create();
24221
+ */
24222
+ init: function(cfg) {
24223
+ this.cfg = this.cfg.extend(cfg);
24224
+ this.reset();
24225
+ },
24226
+ /**
24227
+ * Resets this hasher to its initial state.
24228
+ *
24229
+ * @example
24230
+ *
24231
+ * hasher.reset();
24232
+ */
24233
+ reset: function() {
24234
+ BufferedBlockAlgorithm.reset.call(this);
24235
+ this._doReset();
24236
+ },
24237
+ /**
24238
+ * Updates this hasher with a message.
24239
+ *
24240
+ * @param {WordArray|string} messageUpdate The message to append.
24241
+ *
24242
+ * @return {Hasher} This hasher.
24243
+ *
24244
+ * @example
24245
+ *
24246
+ * hasher.update('message');
24247
+ * hasher.update(wordArray);
24248
+ */
24249
+ update: function(messageUpdate) {
24250
+ this._append(messageUpdate);
24251
+ this._process();
24252
+ return this;
24253
+ },
24254
+ /**
24255
+ * Finalizes the hash computation.
24256
+ * Note that the finalize operation is effectively a destructive, read-once operation.
24257
+ *
24258
+ * @param {WordArray|string} messageUpdate (Optional) A final message update.
24259
+ *
24260
+ * @return {WordArray} The hash.
24261
+ *
24262
+ * @example
24263
+ *
24264
+ * var hash = hasher.finalize();
24265
+ * var hash = hasher.finalize('message');
24266
+ * var hash = hasher.finalize(wordArray);
24267
+ */
24268
+ finalize: function(messageUpdate) {
24269
+ if (messageUpdate) {
24270
+ this._append(messageUpdate);
24271
+ }
24272
+ var hash = this._doFinalize();
24273
+ return hash;
24274
+ },
24275
+ blockSize: 512 / 32,
24276
+ /**
24277
+ * Creates a shortcut function to a hasher's object interface.
24278
+ *
24279
+ * @param {Hasher} hasher The hasher to create a helper for.
24280
+ *
24281
+ * @return {Function} The shortcut function.
24282
+ *
24283
+ * @static
24284
+ *
24285
+ * @example
24286
+ *
24287
+ * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
24288
+ */
24289
+ _createHelper: function(hasher) {
24290
+ return function(message, cfg) {
24291
+ return new hasher.init(cfg).finalize(message);
24292
+ };
24293
+ },
24294
+ /**
24295
+ * Creates a shortcut function to the HMAC's object interface.
24296
+ *
24297
+ * @param {Hasher} hasher The hasher to use in this HMAC helper.
24298
+ *
24299
+ * @return {Function} The shortcut function.
24300
+ *
24301
+ * @static
24302
+ *
24303
+ * @example
24304
+ *
24305
+ * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
24306
+ */
24307
+ _createHmacHelper: function(hasher) {
24308
+ return function(message, key) {
24309
+ return new C_algo.HMAC.init(hasher, key).finalize(message);
24310
+ };
24311
+ }
24312
+ });
24313
+ var C_algo = C.algo = {};
24314
+ return C;
24315
+ }(Math);
24316
+ return CryptoJS;
24317
+ });
24318
+ }
24319
+ });
24320
+
24321
+ // node_modules/crypto-js/md5.js
24322
+ var require_md5 = __commonJS({
24323
+ "node_modules/crypto-js/md5.js"(exports, module2) {
24324
+ "use strict";
24325
+ (function(root4, factory) {
24326
+ if (typeof exports === "object") {
24327
+ module2.exports = exports = factory(require_core());
24328
+ } else if (typeof define === "function" && define.amd) {
24329
+ define(["./core"], factory);
24330
+ } else {
24331
+ factory(root4.CryptoJS);
24332
+ }
24333
+ })(exports, function(CryptoJS) {
24334
+ (function(Math2) {
24335
+ var C = CryptoJS;
24336
+ var C_lib = C.lib;
24337
+ var WordArray = C_lib.WordArray;
24338
+ var Hasher = C_lib.Hasher;
24339
+ var C_algo = C.algo;
24340
+ var T = [];
24341
+ (function() {
24342
+ for (var i2 = 0; i2 < 64; i2++) {
24343
+ T[i2] = Math2.abs(Math2.sin(i2 + 1)) * 4294967296 | 0;
24344
+ }
24345
+ })();
24346
+ var MD52 = C_algo.MD5 = Hasher.extend({
24347
+ _doReset: function() {
24348
+ this._hash = new WordArray.init([
24349
+ 1732584193,
24350
+ 4023233417,
24351
+ 2562383102,
24352
+ 271733878
24353
+ ]);
24354
+ },
24355
+ _doProcessBlock: function(M3, offset) {
24356
+ for (var i2 = 0; i2 < 16; i2++) {
24357
+ var offset_i = offset + i2;
24358
+ var M_offset_i = M3[offset_i];
24359
+ M3[offset_i] = (M_offset_i << 8 | M_offset_i >>> 24) & 16711935 | (M_offset_i << 24 | M_offset_i >>> 8) & 4278255360;
24360
+ }
24361
+ var H3 = this._hash.words;
24362
+ var M_offset_0 = M3[offset + 0];
24363
+ var M_offset_1 = M3[offset + 1];
24364
+ var M_offset_2 = M3[offset + 2];
24365
+ var M_offset_3 = M3[offset + 3];
24366
+ var M_offset_4 = M3[offset + 4];
24367
+ var M_offset_5 = M3[offset + 5];
24368
+ var M_offset_6 = M3[offset + 6];
24369
+ var M_offset_7 = M3[offset + 7];
24370
+ var M_offset_8 = M3[offset + 8];
24371
+ var M_offset_9 = M3[offset + 9];
24372
+ var M_offset_10 = M3[offset + 10];
24373
+ var M_offset_11 = M3[offset + 11];
24374
+ var M_offset_12 = M3[offset + 12];
24375
+ var M_offset_13 = M3[offset + 13];
24376
+ var M_offset_14 = M3[offset + 14];
24377
+ var M_offset_15 = M3[offset + 15];
24378
+ var a = H3[0];
24379
+ var b2 = H3[1];
24380
+ var c = H3[2];
24381
+ var d = H3[3];
24382
+ a = FF(a, b2, c, d, M_offset_0, 7, T[0]);
24383
+ d = FF(d, a, b2, c, M_offset_1, 12, T[1]);
24384
+ c = FF(c, d, a, b2, M_offset_2, 17, T[2]);
24385
+ b2 = FF(b2, c, d, a, M_offset_3, 22, T[3]);
24386
+ a = FF(a, b2, c, d, M_offset_4, 7, T[4]);
24387
+ d = FF(d, a, b2, c, M_offset_5, 12, T[5]);
24388
+ c = FF(c, d, a, b2, M_offset_6, 17, T[6]);
24389
+ b2 = FF(b2, c, d, a, M_offset_7, 22, T[7]);
24390
+ a = FF(a, b2, c, d, M_offset_8, 7, T[8]);
24391
+ d = FF(d, a, b2, c, M_offset_9, 12, T[9]);
24392
+ c = FF(c, d, a, b2, M_offset_10, 17, T[10]);
24393
+ b2 = FF(b2, c, d, a, M_offset_11, 22, T[11]);
24394
+ a = FF(a, b2, c, d, M_offset_12, 7, T[12]);
24395
+ d = FF(d, a, b2, c, M_offset_13, 12, T[13]);
24396
+ c = FF(c, d, a, b2, M_offset_14, 17, T[14]);
24397
+ b2 = FF(b2, c, d, a, M_offset_15, 22, T[15]);
24398
+ a = GG(a, b2, c, d, M_offset_1, 5, T[16]);
24399
+ d = GG(d, a, b2, c, M_offset_6, 9, T[17]);
24400
+ c = GG(c, d, a, b2, M_offset_11, 14, T[18]);
24401
+ b2 = GG(b2, c, d, a, M_offset_0, 20, T[19]);
24402
+ a = GG(a, b2, c, d, M_offset_5, 5, T[20]);
24403
+ d = GG(d, a, b2, c, M_offset_10, 9, T[21]);
24404
+ c = GG(c, d, a, b2, M_offset_15, 14, T[22]);
24405
+ b2 = GG(b2, c, d, a, M_offset_4, 20, T[23]);
24406
+ a = GG(a, b2, c, d, M_offset_9, 5, T[24]);
24407
+ d = GG(d, a, b2, c, M_offset_14, 9, T[25]);
24408
+ c = GG(c, d, a, b2, M_offset_3, 14, T[26]);
24409
+ b2 = GG(b2, c, d, a, M_offset_8, 20, T[27]);
24410
+ a = GG(a, b2, c, d, M_offset_13, 5, T[28]);
24411
+ d = GG(d, a, b2, c, M_offset_2, 9, T[29]);
24412
+ c = GG(c, d, a, b2, M_offset_7, 14, T[30]);
24413
+ b2 = GG(b2, c, d, a, M_offset_12, 20, T[31]);
24414
+ a = HH(a, b2, c, d, M_offset_5, 4, T[32]);
24415
+ d = HH(d, a, b2, c, M_offset_8, 11, T[33]);
24416
+ c = HH(c, d, a, b2, M_offset_11, 16, T[34]);
24417
+ b2 = HH(b2, c, d, a, M_offset_14, 23, T[35]);
24418
+ a = HH(a, b2, c, d, M_offset_1, 4, T[36]);
24419
+ d = HH(d, a, b2, c, M_offset_4, 11, T[37]);
24420
+ c = HH(c, d, a, b2, M_offset_7, 16, T[38]);
24421
+ b2 = HH(b2, c, d, a, M_offset_10, 23, T[39]);
24422
+ a = HH(a, b2, c, d, M_offset_13, 4, T[40]);
24423
+ d = HH(d, a, b2, c, M_offset_0, 11, T[41]);
24424
+ c = HH(c, d, a, b2, M_offset_3, 16, T[42]);
24425
+ b2 = HH(b2, c, d, a, M_offset_6, 23, T[43]);
24426
+ a = HH(a, b2, c, d, M_offset_9, 4, T[44]);
24427
+ d = HH(d, a, b2, c, M_offset_12, 11, T[45]);
24428
+ c = HH(c, d, a, b2, M_offset_15, 16, T[46]);
24429
+ b2 = HH(b2, c, d, a, M_offset_2, 23, T[47]);
24430
+ a = II(a, b2, c, d, M_offset_0, 6, T[48]);
24431
+ d = II(d, a, b2, c, M_offset_7, 10, T[49]);
24432
+ c = II(c, d, a, b2, M_offset_14, 15, T[50]);
24433
+ b2 = II(b2, c, d, a, M_offset_5, 21, T[51]);
24434
+ a = II(a, b2, c, d, M_offset_12, 6, T[52]);
24435
+ d = II(d, a, b2, c, M_offset_3, 10, T[53]);
24436
+ c = II(c, d, a, b2, M_offset_10, 15, T[54]);
24437
+ b2 = II(b2, c, d, a, M_offset_1, 21, T[55]);
24438
+ a = II(a, b2, c, d, M_offset_8, 6, T[56]);
24439
+ d = II(d, a, b2, c, M_offset_15, 10, T[57]);
24440
+ c = II(c, d, a, b2, M_offset_6, 15, T[58]);
24441
+ b2 = II(b2, c, d, a, M_offset_13, 21, T[59]);
24442
+ a = II(a, b2, c, d, M_offset_4, 6, T[60]);
24443
+ d = II(d, a, b2, c, M_offset_11, 10, T[61]);
24444
+ c = II(c, d, a, b2, M_offset_2, 15, T[62]);
24445
+ b2 = II(b2, c, d, a, M_offset_9, 21, T[63]);
24446
+ H3[0] = H3[0] + a | 0;
24447
+ H3[1] = H3[1] + b2 | 0;
24448
+ H3[2] = H3[2] + c | 0;
24449
+ H3[3] = H3[3] + d | 0;
24450
+ },
24451
+ _doFinalize: function() {
24452
+ var data = this._data;
24453
+ var dataWords = data.words;
24454
+ var nBitsTotal = this._nDataBytes * 8;
24455
+ var nBitsLeft = data.sigBytes * 8;
24456
+ dataWords[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
24457
+ var nBitsTotalH = Math2.floor(nBitsTotal / 4294967296);
24458
+ var nBitsTotalL = nBitsTotal;
24459
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 15] = (nBitsTotalH << 8 | nBitsTotalH >>> 24) & 16711935 | (nBitsTotalH << 24 | nBitsTotalH >>> 8) & 4278255360;
24460
+ dataWords[(nBitsLeft + 64 >>> 9 << 4) + 14] = (nBitsTotalL << 8 | nBitsTotalL >>> 24) & 16711935 | (nBitsTotalL << 24 | nBitsTotalL >>> 8) & 4278255360;
24461
+ data.sigBytes = (dataWords.length + 1) * 4;
24462
+ this._process();
24463
+ var hash = this._hash;
24464
+ var H3 = hash.words;
24465
+ for (var i2 = 0; i2 < 4; i2++) {
24466
+ var H_i = H3[i2];
24467
+ H3[i2] = (H_i << 8 | H_i >>> 24) & 16711935 | (H_i << 24 | H_i >>> 8) & 4278255360;
24468
+ }
24469
+ return hash;
24470
+ },
24471
+ clone: function() {
24472
+ var clone = Hasher.clone.call(this);
24473
+ clone._hash = this._hash.clone();
24474
+ return clone;
24475
+ }
24476
+ });
24477
+ function FF(a, b2, c, d, x, s, t) {
24478
+ var n = a + (b2 & c | ~b2 & d) + x + t;
24479
+ return (n << s | n >>> 32 - s) + b2;
24480
+ }
24481
+ function GG(a, b2, c, d, x, s, t) {
24482
+ var n = a + (b2 & d | c & ~d) + x + t;
24483
+ return (n << s | n >>> 32 - s) + b2;
24484
+ }
24485
+ function HH(a, b2, c, d, x, s, t) {
24486
+ var n = a + (b2 ^ c ^ d) + x + t;
24487
+ return (n << s | n >>> 32 - s) + b2;
24488
+ }
24489
+ function II(a, b2, c, d, x, s, t) {
24490
+ var n = a + (c ^ (b2 | ~d)) + x + t;
24491
+ return (n << s | n >>> 32 - s) + b2;
24492
+ }
24493
+ C.MD5 = Hasher._createHelper(MD52);
24494
+ C.HmacMD5 = Hasher._createHmacHelper(MD52);
24495
+ })(Math);
24496
+ return CryptoJS.MD5;
24497
+ });
24498
+ }
24499
+ });
24500
+
24173
24501
  // src/index.ts
24174
24502
  var index_exports = {};
24175
24503
  __export(index_exports, {
@@ -24182,6 +24510,7 @@ __export(index_exports, {
24182
24510
  captureFullDOMStructure: () => captureFullDOMStructure,
24183
24511
  configureWebRTCServer: () => configureWebRTCServer,
24184
24512
  executeAction: () => executeAction,
24513
+ generateDynamicId: () => generateDynamicId,
24185
24514
  getFullDOMStructure: () => getFullDOMStructure,
24186
24515
  getWebRTCServerConfig: () => getWebRTCServerConfig,
24187
24516
  initWebRTC: () => initWebRTC,
@@ -24306,16 +24635,10 @@ var CuekitProvider = ({
24306
24635
  (0, import_react.useEffect)(() => {
24307
24636
  if (apiKey) {
24308
24637
  try {
24309
- console.log("\u{1F3A4} CuekitProvider: Starting WebRTC initialization...", {
24310
- apiKey: apiKey.substring(0, 10) + "..."
24311
- });
24312
24638
  initWebRTC(apiKey);
24313
- console.log("\u{1F3A4} CuekitProvider: WebRTC initialized successfully");
24314
24639
  } catch (error) {
24315
- console.error("\u{1F3A4} CuekitProvider: Failed to initialize WebRTC:", error);
24316
24640
  }
24317
24641
  } else {
24318
- console.warn("\u{1F3A4} CuekitProvider: No API key provided, skipping WebRTC initialization");
24319
24642
  }
24320
24643
  }, [apiKey]);
24321
24644
  (0, import_react.useEffect)(() => {
@@ -24328,15 +24651,11 @@ var CuekitProvider = ({
24328
24651
  Promise.resolve().then(() => (init_webrtc_service(), webrtc_service_exports)).then(({ setWebRTCCallbacks: setWebRTCCallbacks2 }) => {
24329
24652
  setWebRTCCallbacks2({
24330
24653
  onNavigationCommand: (command) => {
24331
- console.log("\u{1F9ED} Processing navigation command:", command);
24332
24654
  switch (command.type) {
24333
24655
  case "static_data_ready":
24334
- console.log("\u{1F4E6} Static data ready:", command.data);
24335
24656
  break;
24336
24657
  case "ai_intent":
24337
- console.log("\u{1F3AF} AI Intent:", command.text, "->", command.actionType);
24338
24658
  if (command.actionType === "navigate" && command.current_page) {
24339
- console.log(`\u{1F9ED} Navigating to: ${command.current_page}`);
24340
24659
  if (navigationHandler2) {
24341
24660
  navigationHandler2(command.current_page, {
24342
24661
  intent: command.intent,
@@ -24347,13 +24666,10 @@ var CuekitProvider = ({
24347
24666
  }
24348
24667
  break;
24349
24668
  case "user_speech_text":
24350
- console.log("\u{1F464} User said:", command.text);
24351
24669
  break;
24352
24670
  case "ai_speech_text":
24353
- console.log("\u{1F916} AI said:", command.text);
24354
24671
  break;
24355
24672
  default:
24356
- console.log("\u{1F50D} Unknown command type:", command.type);
24357
24673
  }
24358
24674
  },
24359
24675
  onConnectionStateChange: (state) => {
@@ -24441,6 +24757,7 @@ var import_react3 = require("react");
24441
24757
 
24442
24758
  // src/hooks/use-webrtc.ts
24443
24759
  var import_react2 = require("react");
24760
+ init_livekit_client_esm();
24444
24761
  init_webrtc_service();
24445
24762
  init_globals();
24446
24763
  var useWebRTC = (options) => {
@@ -24455,10 +24772,9 @@ var useWebRTC = (options) => {
24455
24772
  setAudioContainer(audioContainerRef2);
24456
24773
  }, []);
24457
24774
  (0, import_react2.useEffect)(() => {
24458
- const handleConnectionStateChange = async (state) => {
24459
- const { ConnectionState: ConnectionState2 } = await Promise.resolve().then(() => (init_livekit_client_esm(), livekit_client_esm_exports));
24460
- setIsConnected(state === ConnectionState2.Connected);
24461
- setIsConnecting(state === ConnectionState2.Connecting);
24775
+ const handleConnectionStateChange = (state) => {
24776
+ setIsConnected(state === ConnectionState.Connected);
24777
+ setIsConnecting(state === ConnectionState.Connecting);
24462
24778
  setConnectionState(state);
24463
24779
  options?.onConnectionStateChange?.(state);
24464
24780
  };
@@ -24493,7 +24809,6 @@ var useWebRTC = (options) => {
24493
24809
  setIsConnected(true);
24494
24810
  return authData;
24495
24811
  } catch (err) {
24496
- console.error("Connection failed:", err);
24497
24812
  setError(err.message || "Failed to connect");
24498
24813
  setIsConnected(false);
24499
24814
  } finally {
@@ -24505,15 +24820,6 @@ var useWebRTC = (options) => {
24505
24820
  setIsConnected(false);
24506
24821
  setRoom(null);
24507
24822
  }, []);
24508
- (0, import_react2.useEffect)(() => {
24509
- const checkConnection = async () => {
24510
- const connected = await isConnected();
24511
- setIsConnected(connected);
24512
- };
24513
- checkConnection();
24514
- const interval = setInterval(checkConnection, 5e3);
24515
- return () => clearInterval(interval);
24516
- }, []);
24517
24823
  const memoizedParticipants = (0, import_react2.useMemo)(() => {
24518
24824
  return getParticipants().map((p) => p.identity);
24519
24825
  }, [participants]);
@@ -24589,7 +24895,7 @@ var useCuekit = (options) => {
24589
24895
  const [micState, setMicState] = (0, import_react3.useState)("idle");
24590
24896
  const [status, setStatus] = (0, import_react3.useState)("");
24591
24897
  const handleNavigationCommand = (event) => {
24592
- console.log(`\u{1F9E0} Processing event in useCuekit: ${event.type}`, event);
24898
+ console.log(`\u2B07\uFE0F Received event from backend: ${event.type}`, event);
24593
24899
  switch (event.type) {
24594
24900
  case "user_speech_chunk":
24595
24901
  case "ai_speech_chunk": {
@@ -28472,9 +28778,9 @@ function factoryTitle(effects, ok3, nok, type, markerType, stringType) {
28472
28778
  return atBreak(code4);
28473
28779
  }
28474
28780
  effects.consume(code4);
28475
- return code4 === 92 ? escape : inside;
28781
+ return code4 === 92 ? escape2 : inside;
28476
28782
  }
28477
- function escape(code4) {
28783
+ function escape2(code4) {
28478
28784
  if (code4 === marker || code4 === 92) {
28479
28785
  effects.consume(code4);
28480
28786
  return inside;
@@ -37370,9 +37676,9 @@ var SunIcon = ({ width = 24, height = 24, className, ...props }) => {
37370
37676
  viewBox: "0 0 24 24",
37371
37677
  fill: "none",
37372
37678
  stroke: "currentColor",
37373
- "stroke-width": "2",
37374
- "stroke-linecap": "round",
37375
- "stroke-linejoin": "round",
37679
+ strokeWidth: "2",
37680
+ strokeLinecap: "round",
37681
+ strokeLinejoin: "round",
37376
37682
  className,
37377
37683
  ...props
37378
37684
  },
@@ -37401,9 +37707,9 @@ var MoonIcon = ({ width = 24, height = 24, className, ...props }) => {
37401
37707
  viewBox: "0 0 24 24",
37402
37708
  fill: "none",
37403
37709
  stroke: "currentColor",
37404
- "stroke-width": "2",
37405
- "stroke-linecap": "round",
37406
- "stroke-linejoin": "round",
37710
+ strokeWidth: "2",
37711
+ strokeLinecap: "round",
37712
+ strokeLinejoin: "round",
37407
37713
  className,
37408
37714
  ...props
37409
37715
  },
@@ -37424,9 +37730,9 @@ var CloseIcon = ({ width = 24, height = 24, className, ...props }) => {
37424
37730
  viewBox: "0 0 24 24",
37425
37731
  fill: "none",
37426
37732
  stroke: "currentColor",
37427
- "stroke-width": "2",
37428
- "stroke-linecap": "round",
37429
- "stroke-linejoin": "round",
37733
+ strokeWidth: "2",
37734
+ strokeLinecap: "round",
37735
+ strokeLinejoin: "round",
37430
37736
  className,
37431
37737
  ...props
37432
37738
  },
@@ -37448,9 +37754,9 @@ var PhoneOffIcon = ({ width = 24, height = 24, className, ...props }) => {
37448
37754
  viewBox: "0 0 24 24",
37449
37755
  fill: "none",
37450
37756
  stroke: "currentColor",
37451
- "stroke-width": "2",
37452
- "stroke-linecap": "round",
37453
- "stroke-linejoin": "round",
37757
+ strokeWidth: "2",
37758
+ strokeLinecap: "round",
37759
+ strokeLinejoin: "round",
37454
37760
  className,
37455
37761
  ...props
37456
37762
  },
@@ -40077,19 +40383,6 @@ var VoiceIntensityBars = ({
40077
40383
  return null;
40078
40384
  }
40079
40385
  let trackRef = null;
40080
- console.log("VoiceIntensityVisualizer Debug:", {
40081
- participants: participants.length,
40082
- localParticipant: !!localParticipant,
40083
- isActive
40084
- });
40085
- console.log(
40086
- "All participants:",
40087
- participants.map((p) => ({
40088
- identity: p.identity,
40089
- isLocal: p instanceof Participant,
40090
- hasAudio: p.getTrackPublication(Track.Source.Microphone)?.track !== void 0
40091
- }))
40092
- );
40093
40386
  let speakingParticipant = null;
40094
40387
  let highestAudioLevel = 0;
40095
40388
  participants.forEach((participant) => {
@@ -40102,15 +40395,8 @@ var VoiceIntensityBars = ({
40102
40395
  if (!speakingParticipant || highestAudioLevel === 0) {
40103
40396
  speakingParticipant = participants.find((p) => p.isSpeaking) || (participants.length > 0 ? participants[0] : null);
40104
40397
  if (speakingParticipant) {
40105
- console.log("Fallback to speaking status or first participant:", speakingParticipant.identity);
40106
40398
  }
40107
40399
  } else {
40108
- console.log(
40109
- "Using participant with highest audio level:",
40110
- speakingParticipant.identity,
40111
- "level:",
40112
- highestAudioLevel
40113
- );
40114
40400
  }
40115
40401
  if (speakingParticipant) {
40116
40402
  const audioTrack = speakingParticipant.getTrackPublication(Track.Source.Microphone);
@@ -40177,9 +40463,9 @@ var MicIcon = ({ width = 24, height = 24, className, ...props }) => {
40177
40463
  viewBox: "0 0 24 24",
40178
40464
  fill: "none",
40179
40465
  stroke: "currentColor",
40180
- "stroke-width": "2",
40181
- "stroke-linecap": "round",
40182
- "stroke-linejoin": "round",
40466
+ strokeWidth: "2",
40467
+ strokeLinecap: "round",
40468
+ strokeLinejoin: "round",
40183
40469
  className,
40184
40470
  ...props
40185
40471
  },
@@ -40202,9 +40488,9 @@ var LoaderIcon = ({ width = 24, height = 24, className, ...props }) => {
40202
40488
  viewBox: "0 0 24 24",
40203
40489
  fill: "none",
40204
40490
  stroke: "currentColor",
40205
- "stroke-width": "2",
40206
- "stroke-linecap": "round",
40207
- "stroke-linejoin": "round",
40491
+ strokeWidth: "2",
40492
+ strokeLinecap: "round",
40493
+ strokeLinejoin: "round",
40208
40494
  className,
40209
40495
  ...props
40210
40496
  },
@@ -40284,10 +40570,6 @@ var MicButton = ({
40284
40570
  appId
40285
40571
  });
40286
40572
  (0, import_react15.useEffect)(() => {
40287
- console.log("\u{1F3A4} MicButton received messages:", JSON.stringify(messageManagerMessages, null, 2));
40288
- }, [messageManagerMessages]);
40289
- (0, import_react15.useEffect)(() => {
40290
- if (typeof window === "undefined") return;
40291
40573
  const checkTheme = () => {
40292
40574
  if (typeof document !== "undefined") {
40293
40575
  let newTheme;
@@ -40301,7 +40583,6 @@ var MicButton = ({
40301
40583
  }
40302
40584
  };
40303
40585
  checkTheme();
40304
- if (typeof window === "undefined") return;
40305
40586
  if (defaultTheme === "system") {
40306
40587
  const observer = new MutationObserver(checkTheme);
40307
40588
  observer.observe(document.documentElement, {
@@ -40337,74 +40618,27 @@ var MicButton = ({
40337
40618
  }, [showBorderGlow]);
40338
40619
  const handleAISpeech = (0, import_react15.useCallback)(
40339
40620
  (isSpeaking, trackId) => {
40340
- console.log("\u{1F3A4} MicButton: ===== AI SPEECH EVENT START =====");
40341
- console.log("\u{1F3A4} MicButton: Event type:", isSpeaking ? "START" : "END");
40342
- console.log("\u{1F3A4} MicButton: Track ID:", trackId);
40343
- console.log("\u{1F3A4} MicButton: Current AI speaking state:", aiSpeakingRef.current);
40344
- console.log("\u{1F3A4} MicButton: Current active AI tracks:", Array.from(activeAITracksRef.current));
40345
- console.log("\u{1F3A4} MicButton: Current status:", status);
40346
- console.log("\u{1F3A4} MicButton: Current mic state:", micState);
40347
- console.log("\u{1F3A4} MicButton: Is listening:", isConnected2);
40348
- console.log("\u{1F3A4} MicButton: Is connected:", isConnected2);
40349
40621
  if (isSpeaking && trackId) {
40350
- console.log("\u{1F3A4} MicButton: ===== AI SPEECH START =====");
40351
- console.log("\u{1F3A4} MicButton: Adding track to active set:", trackId);
40352
40622
  activeAITracksRef.current.add(trackId);
40353
40623
  aiSpeakingRef.current = true;
40354
- console.log("\u{1F3A4} MicButton: After adding track:");
40355
- console.log("\u{1F3A4} MicButton: - Active tracks:", Array.from(activeAITracksRef.current));
40356
- console.log("\u{1F3A4} MicButton: - AI speaking state:", aiSpeakingRef.current);
40357
- console.log("\u{1F3A4} MicButton: - Status set to: AI is speaking...");
40358
40624
  if (aiSpeechTimeoutRef.current) {
40359
- console.log("\u{1F3A4} MicButton: Clearing existing AI speech timeout");
40360
40625
  clearTimeout(aiSpeechTimeoutRef.current);
40361
40626
  }
40362
- console.log(
40363
- "\u{1F3A4} MicButton: AI speech started, active tracks:",
40364
- Array.from(activeAITracksRef.current)
40365
- );
40366
40627
  } else if (!isSpeaking && trackId) {
40367
- console.log("\u{1F3A4} MicButton: ===== AI SPEECH END =====");
40368
- console.log("\u{1F3A4} MicButton: Removing track from active set:", trackId);
40369
40628
  activeAITracksRef.current.delete(trackId);
40370
- console.log("\u{1F3A4} MicButton: After removing track:");
40371
- console.log("\u{1F3A4} MicButton: - Active tracks:", Array.from(activeAITracksRef.current));
40372
- console.log("\u{1F3A4} MicButton: - Active tracks size:", activeAITracksRef.current.size);
40373
40629
  if (activeAITracksRef.current.size === 0) {
40374
- console.log("\u{1F3A4} MicButton: ===== ALL AI TRACKS ENDED =====");
40375
- console.log("\u{1F3A4} MicButton: No more active tracks, resetting AI speaking state");
40376
40630
  aiSpeakingRef.current = false;
40377
- console.log("\u{1F3A4} MicButton: After reset:");
40378
- console.log("\u{1F3A4} MicButton: - AI speaking state:", aiSpeakingRef.current);
40379
- console.log("\u{1F3A4} MicButton: - Status set to: Listening");
40380
- console.log("\u{1F3A4} MicButton: All AI tracks ended, voice recognition re-enabled");
40381
40631
  } else {
40382
- console.log("\u{1F3A4} MicButton: Still have active tracks, keeping AI speaking state");
40383
- console.log("\u{1F3A4} MicButton: Remaining tracks:", Array.from(activeAITracksRef.current));
40384
40632
  }
40385
40633
  } else if (!isSpeaking && !trackId) {
40386
- console.log("\u{1F3A4} MicButton: ===== MANUAL RESET =====");
40387
- console.log("\u{1F3A4} MicButton: Manual reset triggered");
40388
40634
  activeAITracksRef.current.clear();
40389
40635
  aiSpeakingRef.current = false;
40390
- console.log("\u{1F3A4} MicButton: After manual reset:");
40391
- console.log("\u{1F3A4} MicButton: - Active tracks cleared");
40392
- console.log("\u{1F3A4} MicButton: - AI speaking state:", aiSpeakingRef.current);
40393
- console.log("\u{1F3A4} MicButton: - Status set to: Listening");
40394
- console.log("\u{1F3A4} MicButton: AI speech manually reset");
40395
- }
40396
- console.log("\u{1F3A4} MicButton: ===== AI SPEECH EVENT END =====");
40397
- console.log("\u{1F3A4} MicButton: Final state:");
40398
- console.log("\u{1F3A4} MicButton: - AI speaking:", aiSpeakingRef.current);
40399
- console.log("\u{1F3A4} MicButton: - Active tracks:", Array.from(activeAITracksRef.current));
40400
- console.log("\u{1F3A4} MicButton: - Status:", status);
40401
- console.log("\u{1F3A4} MicButton: ================================");
40636
+ }
40402
40637
  },
40403
40638
  [status, micState, isConnected2]
40404
40639
  );
40405
40640
  (0, import_react15.useEffect)(() => {
40406
40641
  if (audioContainerRef2.current) {
40407
- console.log("\u{1F3A4} MicButton: Setting up audio container on mount");
40408
40642
  setAudioContainer(audioContainerRef2);
40409
40643
  }
40410
40644
  return () => {
@@ -40432,49 +40666,33 @@ var MicButton = ({
40432
40666
  };
40433
40667
  (0, import_react15.useEffect)(() => {
40434
40668
  if (isConnected2) {
40435
- console.log("\u{1F3A4} MicButton: WebRTC and SSE connections established - ready for commands");
40436
40669
  } else {
40437
- console.log("\u{1F3A4} MicButton: WebRTC not yet connected - ignoring speech");
40438
40670
  }
40439
40671
  }, [isConnected2]);
40440
40672
  (0, import_react15.useEffect)(() => {
40441
- console.log("\u{1F3A4} MicButton: Auto-open check:", {
40442
- isConnected: isConnected2,
40443
- chatIsOpen: isChatOpen
40444
- });
40445
40673
  if (isConnected2 && !isChatOpen) {
40446
- console.log("\u{1F3A4} MicButton: Auto-opening chat popup");
40447
40674
  openChat();
40448
40675
  }
40449
40676
  }, [isConnected2, isChatOpen, openChat]);
40450
40677
  (0, import_react15.useEffect)(() => {
40451
40678
  if (messageManagerMessages.length > 0 && !isChatOpen) {
40452
- console.log("\u{1F3A4} MicButton: Auto-opening chat popup due to messages");
40453
40679
  openChat();
40454
40680
  }
40455
40681
  }, [messageManagerMessages.length, isChatOpen, openChat]);
40456
40682
  const handleMicClick = (0, import_react15.useCallback)(() => {
40457
40683
  const shouldStop = micState === "listening" && isConnected2;
40458
40684
  if (shouldStop) {
40459
- console.log("\u{1F3A4} MicButton: User wants to stop - closing everything");
40460
40685
  voiceDisconnect().then(() => {
40461
- console.log("\u{1F3A4} MicButton: Stopped and disconnected");
40462
40686
  }).catch((error) => {
40463
- console.error("\u{1F3A4} MicButton: Error during disconnect:", error);
40464
40687
  });
40465
40688
  } else {
40466
- console.log("\u{1F3A4} MicButton: User wants to start - connecting everything");
40467
40689
  voiceConnect(`user_${Date.now()}`, apiKey, appId).then(() => {
40468
- console.log("\u{1F3A4} MicButton: WebRTC and SSE connections started");
40469
40690
  if (showBorderGlow) setShowBodyGlow(true);
40470
40691
  openChat();
40471
- console.log("\u{1F3A4} MicButton: Started listening");
40472
40692
  setTimeout(() => {
40473
- console.log("\u{1F3A4} MicButton: Force opening chat popup after connection");
40474
40693
  openChat();
40475
40694
  }, 500);
40476
40695
  }).catch((error) => {
40477
- console.error("\u{1F3A4} MicButton: Failed to start connections:", error);
40478
40696
  });
40479
40697
  }
40480
40698
  }, [
@@ -40488,14 +40706,12 @@ var MicButton = ({
40488
40706
  showBorderGlow
40489
40707
  ]);
40490
40708
  const handleSendText = async (textToSend) => {
40491
- console.log("\u{1F3A4} MicButton: handleSendText called with:", textToSend);
40492
40709
  setMicState("thinking");
40493
40710
  if (showBorderGlow) setShowBodyGlow(true);
40494
40711
  if (!isChatOpen) {
40495
40712
  openChat();
40496
40713
  }
40497
40714
  if (isConnected2) {
40498
- console.log("\u{1F3A4} MicButton: Sending via WebRTC");
40499
40715
  try {
40500
40716
  await sendUserCommand2(textToSend);
40501
40717
  setMicState("replying");
@@ -40504,27 +40720,21 @@ var MicButton = ({
40504
40720
  if (showBorderGlow) setShowBodyGlow(true);
40505
40721
  }, 1e3);
40506
40722
  } catch (error) {
40507
- console.error("\u{1F3A4} MicButton: Failed to send text:", error);
40508
40723
  } finally {
40509
40724
  setMicState("listening");
40510
40725
  if (showBorderGlow) setShowBodyGlow(true);
40511
40726
  }
40512
40727
  } else {
40513
- console.log("\u{1F3A4} MicButton: WebRTC not connected, cannot send message");
40514
40728
  setMicState("listening");
40515
40729
  if (showBorderGlow) setShowBodyGlow(true);
40516
40730
  }
40517
- console.log("\u{1F3A4} MicButton: Text sent via WebRTC");
40518
40731
  };
40519
40732
  const handleEndCall = async () => {
40520
- console.log("\u{1F3A4} MicButton: Ending call completely...");
40521
40733
  try {
40522
40734
  await voiceDisconnect();
40523
40735
  await voiceDisconnect();
40524
40736
  closeChat();
40525
- console.log("\u{1F3A4} MicButton: Call ended successfully");
40526
40737
  } catch (error) {
40527
- console.error("\u{1F3A4} MicButton: Error ending call:", error);
40528
40738
  }
40529
40739
  };
40530
40740
  const getIcon = () => {
@@ -40727,4 +40937,14 @@ var MicButton = ({
40727
40937
 
40728
40938
  // src/index.ts
40729
40939
  init_element_service();
40940
+
40941
+ // src/utils/instrumentation.ts
40942
+ var import_md5 = __toESM(require_md5());
40943
+ function generateDynamicId(routePath, elementIdentifier) {
40944
+ const combinedString = `${routePath}:${elementIdentifier}`;
40945
+ const hash = (0, import_md5.default)(combinedString).toString();
40946
+ return hash.substring(0, 8);
40947
+ }
40948
+
40949
+ // src/index.ts
40730
40950
  init_element_service();