obi-sdk 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -414,12 +414,13 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
414
414
  <p class="subtitle">${this.session.description}</p>
415
415
  </div>
416
416
 
417
- <button class="button button-primary" @click=${this.handleStart}>Continue →</button>
417
+ <button class="button button-primary" @click=${this.handleStart}>Continue</button>
418
418
  </div>
419
419
  `}}jQ.styles=t.css`
420
420
  :host {
421
421
  display: block;
422
422
  font-family: "Inter", sans-serif;
423
+ box-sizing: border-box;
423
424
  }
424
425
 
425
426
  .backdrop {
@@ -433,18 +434,18 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
433
434
  }
434
435
 
435
436
  .container {
437
+ box-sizing: border-box;
436
438
  position: fixed;
437
439
  top: 50%;
438
440
  left: 50%;
439
441
  transform: translate(-50%, -50%);
440
442
  z-index: 50;
441
- gap: 32px;
442
443
 
443
444
  /* Layout from user specifications */
444
445
  display: flex;
445
446
  width: 640px;
446
447
  min-height: 380px;
447
- padding: 48px 48px 32px 48px;
448
+ padding: 32px;
448
449
  flex-direction: column;
449
450
  justify-content: space-between;
450
451
  align-items: center;
@@ -463,20 +464,17 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
463
464
  flex-direction: column;
464
465
  align-items: center;
465
466
  text-align: center;
466
- gap: 16px;
467
467
  }
468
468
 
469
469
  .logo {
470
470
  display: flex;
471
471
  width: 96px;
472
472
  height: 96px;
473
- padding: 8px;
474
473
  justify-content: center;
475
474
  align-items: center;
476
- gap: 8px;
477
475
  aspect-ratio: 1/1;
478
- border-radius: var(--border-radius-lg, 12px);
479
- background: var(--tailwind-colors-violet-600, #7c3aed);
476
+ border-radius: 8px;
477
+ background: var(--obi-primary, #a10fff);
480
478
  box-shadow:
481
479
  0px 0px 8px 0px rgba(168, 85, 247, 0.12),
482
480
  0px 0px 8px 0px rgba(192, 132, 252, 0.24),
@@ -494,32 +492,36 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
494
492
  }
495
493
 
496
494
  h1 {
497
- font-family: "Syne", sans-serif;
495
+ font-family: "Satoshi", sans-serif;
498
496
  font-size: 32px;
499
497
  font-weight: 700;
500
498
  color: #111827;
501
499
  margin: 0;
500
+ margin-top: 32px;
501
+ margin-bottom: 16px;
502
502
  }
503
503
 
504
504
  .subtitle {
505
+ font-family: "Satoshi", sans-serif;
506
+ font-weight: 300;
505
507
  font-size: 16px;
506
- color: #6b7280;
507
- line-height: 1.5;
508
+ color: #18181b;
509
+ line-height: 1.4;
508
510
  margin: 0;
509
511
  }
510
512
 
511
513
  .button {
514
+ font-family: "Satoshi", sans-serif;
515
+ font-weight: 400;
516
+ font-size: 16px;
512
517
  padding: 12px 24px;
513
518
  border-radius: 8px;
514
519
  border: none;
515
- font-size: 16px;
516
- font-weight: 500;
517
520
  cursor: pointer;
518
521
  transition: all 0.2s ease;
519
522
  display: flex;
520
523
  align-items: center;
521
524
  justify-content: center;
522
- gap: 8px;
523
525
  }
524
526
 
525
527
  .button-primary {
@@ -543,23 +545,21 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
543
545
 
544
546
  .close-button {
545
547
  position: absolute;
546
- top: 16px;
548
+ top: 12px;
547
549
  right: 16px;
548
550
  background: none;
549
551
  border: none;
550
552
  cursor: pointer;
551
553
  font-size: 24px;
552
554
  color: #6b7280;
553
- padding: 4px;
554
- border-radius: 4px;
555
- transition: all 0.2s ease;
556
- }
557
-
558
- .close-button:hover {
559
- color: #374151;
560
- background: #f3f4f6;
555
+ padding: 0;
556
+ margin: 0;
557
+ line-height: 1;
558
+ display: inline-flex;
559
+ align-items: center;
560
+ justify-content: center;
561
561
  }
562
- `,GQ([lg({type:Object})],jQ.prototype,"session",2),GQ([lg({type:Function})],jQ.prototype,"onStart",2),GQ([lg({type:Function})],jQ.prototype,"onClose",2),customElements.get("obi-session-start-modal")||customElements.define("obi-session-start-modal",jQ);var VQ=Object.defineProperty,PQ=Object.getOwnPropertyDescriptor,_Q=(A,t,e,i)=>{for(var n,s=i>1?void 0:i?PQ(t,e):t,r=A.length-1;r>=0;r--)(n=A[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&VQ(t,e,s),s};const JQ="io.obi.widget-parameters";class XQ extends t.LitElement{constructor(){super(),this.apiKey="",this.isActive=!0,this.linkOnlyAccess=!1,this.position="bottom-right",this.user=null,this.state=Ga.READY,this.storedActiveState=void 0,this.showCourseModal=!1,this.showSessionStartModal=!1,this.selectedCourse=null,this.isHovering=!1,this.navVisible=!1,this.activeSession=null,this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.boundSaveSessionData=null,this.obiClient=null,this.closeNavTimeoutRef=null,this.researchingTimeoutRef=null,this.handleCourseSelectEvent=A=>{const t=A;this.selectedCourse=t.detail,this.showCourseModal=!1,this.showSessionStartModal=!0},this.handleUrlSessionEvent=async A=>{try{if(!this.obiClient)return;const t=await this.obiClient.listSessions(this.apiKey);if(t.data){const e=t.data.sessions,i=e?.find((t=>t.uuid===A));if(i){const t=i;this.selectedCourse={id:A,name:t.onboarding_plan?.name||"",description:t.onboarding_plan?.description||""},this.state=Ga.LOADING,this.showSessionStartModal=!0}}}catch(t){}},this.obiClient=new u({baseUrl:e});const A=()=>{this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl&&this.saveSessionData()};window.addEventListener("beforeunload",A),window.addEventListener("pagehide",A)}updateFromConfig(){window.obiWidgetConfig&&(this.apiKey=window.obiWidgetConfig.apiKey||this.apiKey,this.position=window.obiWidgetConfig.position||this.position,this.user=window.obiWidgetConfig.user||this.user,void 0!==window.obiWidgetConfig.isActive&&(this.isActive=window.obiWidgetConfig.isActive),void 0!==window.obiWidgetConfig.linkOnlyAccess&&(this.linkOnlyAccess=window.obiWidgetConfig.linkOnlyAccess),this.style.setProperty("--obi-primary",window.obiWidgetConfig?.primaryColor||"#9500ff"),this.style.setProperty("--obi-secondary",window.obiWidgetConfig?.secondaryColor||"#c4b5fd"))}removeSessionUrlParams(){const A=new URL(window.location.href);A.searchParams.delete(Pa),window.history.replaceState({},"",A.toString());try{localStorage.removeItem(JQ)}catch(t){}}createSession(A){try{return new Va({sessionId:A,apiBaseUrl:e})||null}catch(t){return null}}setupSessionEventListeners(A,t){A.on("stateChanged",(t=>{if(t===Ga.RESEARCHING)return this.researchingTimeoutRef&&window.clearTimeout(this.researchingTimeoutRef),this.state=t,this.researchingTimeoutRef=window.setTimeout((()=>{this.researchingTimeoutRef=null;const t=A.getCurrentState();this.state=t,t!==Ga.READY&&(this.storedActiveState=t)}),1500),void(this.storedActiveState=t);null===this.researchingTimeoutRef&&(this.state=t,t!==Ga.READY&&(this.storedActiveState=t))})),A.on("volume",(({speaker:A,spectrum:t,volume:e})=>{this.volume={speaker:A,spectrum:t,volume:e}})),A.on("error",(A=>{this.state=Ga.ERROR,this.activeSession=null,t&&t()}))}handleSessionCreationFailure(A){this.state=Ga.ERROR,this.activeSession=null,A&&A()}async connectObi(A){if(!this.activeSession)try{const t=this.createSession(A);if(!t)return void this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()));this.setupSessionEventListeners(t,(()=>this.removeSessionUrlParams())),t.on("screenCaptureRequested",(async()=>{try{const e=(await(A=document.documentElement,t={useCORS:!0,allowTaint:!0,foreignObjectRendering:!0},void 0===t&&(t={}),(function(A,t){return Ya(void 0,void 0,void 0,(function(){var e,i,n,s,r,o,a,c,h,u,l,d,B,w,f,g,Q,v,p,m,U,C,F,y,b,E,H,I,k,T,S,K,O,D,M,L,x,R;return Za(this,(function(N){switch(N.label){case 0:if(!A||"object"!=typeof A)return[2,Promise.reject("Invalid element provided as first argument")];if(!(e=A.ownerDocument))throw new Error("Element is not attached to a Document");if(!(i=e.defaultView))throw new Error("Document is not attached to a Window");return n={allowTaint:null!==(C=t.allowTaint)&&void 0!==C&&C,imageTimeout:null!==(F=t.imageTimeout)&&void 0!==F?F:15e3,proxy:t.proxy,useCORS:null!==(y=t.useCORS)&&void 0!==y&&y,customIsSameOrigin:t.customIsSameOrigin},s=Xa({logging:null===(b=t.logging)||void 0===b||b,cache:t.cache},n),r={windowWidth:null!==(E=t.windowWidth)&&void 0!==E?E:i.innerWidth,windowHeight:null!==(H=t.windowHeight)&&void 0!==H?H:i.innerHeight,scrollX:null!==(I=t.scrollX)&&void 0!==I?I:i.pageXOffset,scrollY:null!==(k=t.scrollY)&&void 0!==k?k:i.pageYOffset},o=new Wa(r.scrollX,r.scrollY,r.windowWidth,r.windowHeight),a=new jf(s,o),c=null!==(T=t.foreignObjectRendering)&&void 0!==T&&T,h={allowTaint:null!==(S=t.allowTaint)&&void 0!==S&&S,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:c,copyStyles:c},a.logger.debug("Starting document clone with size ".concat(o.width,"x").concat(o.height," scrolled to ").concat(-o.left,",").concat(-o.top)),u=new Ew(a,A,h),(l=u.clonedReferenceElement)?[4,u.toIFrame(e,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=N.sent(),B=tw(l)||"HTML"===l.tagName?(function(A){var t=A.body,e=A.documentElement;if(!t||!e)throw new Error("Unable to get document size");var i=Math.max(Math.max(t.scrollWidth,e.scrollWidth),Math.max(t.offsetWidth,e.offsetWidth),Math.max(t.clientWidth,e.clientWidth)),n=Math.max(Math.max(t.scrollHeight,e.scrollHeight),Math.max(t.offsetHeight,e.offsetHeight),Math.max(t.clientHeight,e.clientHeight));return new Wa(0,0,i,n)})(l.ownerDocument):qa(a,l),w=B.width,f=B.height,g=B.left,Q=B.top,v=(function(A,t,e){var i=t.ownerDocument,n=i.documentElement?Pu(A,getComputedStyle(i.documentElement).backgroundColor):_u.TRANSPARENT,s=i.body?Pu(A,getComputedStyle(i.body).backgroundColor):_u.TRANSPARENT,r="string"==typeof e?Pu(A,e):null===e?_u.TRANSPARENT:4294967295;return t===i.documentElement?au(n)?au(s)?r:s:n:r})(a,l,t.backgroundColor),p={canvas:t.canvas,backgroundColor:v,scale:null!==(O=null!==(K=t.scale)&&void 0!==K?K:i.devicePixelRatio)&&void 0!==O?O:1,x:(null!==(D=t.x)&&void 0!==D?D:0)+g,y:(null!==(M=t.y)&&void 0!==M?M:0)+Q,width:null!==(L=t.width)&&void 0!==L?L:Math.ceil(w),height:null!==(x=t.height)&&void 0!==x?x:Math.ceil(f)},c?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Rf(a,p).render(l)]):[3,3];case 2:return m=N.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at ".concat(g,",").concat(Q," with size ").concat(w,"x").concat(f," using computed rendering")),a.logger.debug("Starting DOM parsing"),U=PB(a,l),v===U.styles.backgroundColor&&(U.styles.backgroundColor=_u.TRANSPARENT),a.logger.debug("Starting renderer for element at ".concat(p.x,",").concat(p.y," with size ").concat(p.width,"x").concat(p.height)),[4,new Kf(a,p).render(U)];case 4:m=N.sent(),N.label=5;case 5:return(null===(R=t.removeContainer)||void 0===R||R)&&(Ew.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,m]}}))}))})(A,t))).toDataURL("image/png");this.activeSession.emit("screenCaptureComplete",e)}catch(e){this.activeSession.emit("screenCaptureComplete","error")}var A,t}));const e=await t.connect();e&&(this.sessionToken=A,this.roomToken=e.token,this.roomUrl=e.url,this.removeSessionUrlParams()),this.activeSession=t}catch(t){this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()))}}async handleSessionStart(A){this.activeSession||(this.showSessionStartModal=!1,this.state=Ga.LOADING,await this.connectObi(A))}async checkExistingSession(){try{const A=JSON.parse(wg.getItem(Bg)||"{}"),{sessionToken:t,roomToken:e,roomUrl:i,sessionExpiry:n,obiState:s}=A;if(!t||!e||!i)return;if(n&&new Date(n)<new Date)return void this.clearSessionStorage();this.state=Ga.LOADING;const r=this.createSession(t);if(!r)return void this.handleSessionCreationFailure((()=>this.clearSessionStorage()));this.setupSessionEventListeners(r,(()=>this.clearSessionStorage())),await r.reconnect(i,e,s)?(this.activeSession=r,this.sessionToken=t,this.roomToken=e,this.roomUrl=i,this.state=s,this.storedActiveState=s):this.clearSessionStorage()}catch(A){this.handleSessionCreationFailure((()=>this.clearSessionStorage()))}}clearSessionStorage(){wg.removeItem(Bg)}saveSessionData(){if(this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl){const A=new Date;A.setMinutes(A.getMinutes()+5);const t={sessionToken:this.sessionToken,roomToken:this.roomToken,roomUrl:this.roomUrl,obiState:this.storedActiveState??this.state,sessionExpiry:A.toISOString()};wg.setItem(Bg,JSON.stringify(t))}}async sessionConnectionCheck(){if(await this.checkExistingSession(),!this.activeSession){let t={};try{const A=localStorage.getItem(JQ);A&&(t=JSON.parse(A))}catch(A){}0===Object.keys(t).length&&new URLSearchParams(window.location.search).forEach(((A,e)=>{t[e]=A}));const e=t[Pa];e&&this.apiKey&&await this.handleUrlSessionEvent(e)}}connectedCallback(){super.connectedCallback(),this.updateFromConfig(),this.setAttribute("position",this.position),this.boundSaveSessionData=this.saveSessionData.bind(this),window.addEventListener("beforeunload",this.boundSaveSessionData),window.addEventListener("pagehide",this.boundSaveSessionData),this.sessionConnectionCheck()}disconnectedCallback(){null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.boundSaveSessionData&&(window.removeEventListener("beforeunload",this.boundSaveSessionData),window.removeEventListener("pagehide",this.boundSaveSessionData)),this.removeSessionUrlParams(),super.disconnectedCallback()}handleMouseEnter(){this.isHovering=!0,this.navVisible=!0}handleMouseLeave(){this.isHovering=!1,null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),this.closeNavTimeoutRef=window.setTimeout((()=>{this.isHovering||(this.navVisible=!1),this.closeNavTimeoutRef=null}),300)}terminateSession(){this.clearSessionStorage(),this.sessionToken=null,this.roomToken=null,this.roomUrl=null,null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.activeSession&&(this.activeSession.disconnect(),this.activeSession=null),this.state=Ga.READY}handleItemSelect(A,t){"experiences"!==A?xa([A,t]).with(["pause",!0],(()=>{this.activeSession?.pauseRecording()})).with(["pause",!1],(()=>{this.activeSession?.resumeRecording()})).with(["activate",!1],(()=>{this.terminateSession()})).otherwise((()=>{})):this.showCourseModal=!0}render(){if(!this.isActive)return t.nothing;if(this.linkOnlyAccess&&this.state===Ga.READY)return t.nothing;const A=xa(this.state).with(Ga.LOADING,(()=>t.html`<obi-dot-loader></obi-dot-loader>`)).with(Ga.RESEARCHING,(()=>t.html`<obi-searching-loader></obi-searching-loader>`)).with(Da.union(Ga.USER_SPEAKING,Ga.AGENT_SPEAKING),(()=>t.html`<obi-audio-equalizer .volume=${this.volume}></obi-audio-equalizer>`)).with(Ga.THINKING,(()=>t.html`<obi-dot-loader></obi-dot-loader>`)).with(Ga.PAUSED,(()=>bg)).otherwise((()=>bg)),e=this.state===Ga.USER_SPEAKING||this.state===Ga.AGENT_SPEAKING,i=this.state===Ga.RESEARCHING,n=this.state===Ga.USER_SPEAKING,s=["widget-container",this.state!==Ga.READY||this.navVisible?"rotated":"",e?"pulse":"",i?"researching":"",n?"user-speaking":""].filter(Boolean).join(" ");return t.html`
562
+ `,GQ([lg({type:Object})],jQ.prototype,"session",2),GQ([lg({type:Function})],jQ.prototype,"onStart",2),GQ([lg({type:Function})],jQ.prototype,"onClose",2),customElements.get("obi-session-start-modal")||customElements.define("obi-session-start-modal",jQ);var VQ=Object.defineProperty,PQ=Object.getOwnPropertyDescriptor,_Q=(A,t,e,i)=>{for(var n,s=i>1?void 0:i?PQ(t,e):t,r=A.length-1;r>=0;r--)(n=A[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&VQ(t,e,s),s};class JQ extends t.LitElement{constructor(){super(),this.apiKey="",this.isActive=!0,this.linkOnlyAccess=!1,this.position="bottom-right",this.user=null,this.state=Ga.READY,this.storedActiveState=void 0,this.showCourseModal=!1,this.showSessionStartModal=!1,this.selectedCourse=null,this.isHovering=!1,this.navVisible=!1,this.activeSession=null,this.volume={speaker:"ASSISTANT",volume:0,spectrum:[]},this.sessionToken=null,this.roomToken=null,this.roomUrl=null,this.boundSaveSessionData=null,this.obiClient=null,this.closeNavTimeoutRef=null,this.researchingTimeoutRef=null,this.handleCourseSelectEvent=A=>{const t=A;this.selectedCourse=t.detail,this.showCourseModal=!1,this.showSessionStartModal=!0},this.handleUrlSessionEvent=async A=>{try{if(!this.obiClient)return;const t=await this.obiClient.listSessions(this.apiKey);if(t.data){const e=t.data.sessions,i=e?.find((t=>t.uuid===A));if(i){const t=i;this.selectedCourse={id:A,name:t.onboarding_plan?.name||"",description:t.onboarding_plan?.description||""},this.state=Ga.LOADING,this.showSessionStartModal=!0}}}catch(t){}},this.obiClient=new u({baseUrl:e});const A=()=>{this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl&&this.saveSessionData()};window.addEventListener("beforeunload",A),window.addEventListener("pagehide",A)}updateFromConfig(){window.obiWidgetConfig&&(this.apiKey=window.obiWidgetConfig.apiKey||this.apiKey,this.position=window.obiWidgetConfig.position||this.position,this.user=window.obiWidgetConfig.user||this.user,void 0!==window.obiWidgetConfig.isActive&&(this.isActive=window.obiWidgetConfig.isActive),void 0!==window.obiWidgetConfig.linkOnlyAccess&&(this.linkOnlyAccess=window.obiWidgetConfig.linkOnlyAccess),this.style.setProperty("--obi-primary",window.obiWidgetConfig?.primaryColor||"#9500ff"),this.style.setProperty("--obi-secondary",window.obiWidgetConfig?.secondaryColor||"#c4b5fd"))}removeSessionUrlParams(){const A=new URL(window.location.href);A.searchParams.delete(Pa),window.history.replaceState({},"",A.toString());try{window.__obiUrlParams&&(window.__obiUrlParams=null)}catch(t){}}createSession(A){try{return new Va({sessionId:A,apiBaseUrl:e})||null}catch(t){return null}}setupSessionEventListeners(A,t){A.on("stateChanged",(t=>{if(t===Ga.RESEARCHING)return this.researchingTimeoutRef&&window.clearTimeout(this.researchingTimeoutRef),this.state=t,this.researchingTimeoutRef=window.setTimeout((()=>{this.researchingTimeoutRef=null;const t=A.getCurrentState();this.state=t,t!==Ga.READY&&(this.storedActiveState=t)}),1500),void(this.storedActiveState=t);null===this.researchingTimeoutRef&&(this.state=t,t!==Ga.READY&&(this.storedActiveState=t))})),A.on("volume",(({speaker:A,spectrum:t,volume:e})=>{this.volume={speaker:A,spectrum:t,volume:e}})),A.on("error",(A=>{this.state=Ga.ERROR,this.activeSession=null,t&&t()}))}handleSessionCreationFailure(A){this.state=Ga.ERROR,this.activeSession=null,A&&A()}async connectObi(A){if(!this.activeSession)try{const t=this.createSession(A);if(!t)return void this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()));this.setupSessionEventListeners(t,(()=>this.removeSessionUrlParams())),t.on("screenCaptureRequested",(async()=>{try{const e=(await(A=document.documentElement,t={useCORS:!0,allowTaint:!0,foreignObjectRendering:!0},void 0===t&&(t={}),(function(A,t){return Ya(void 0,void 0,void 0,(function(){var e,i,n,s,r,o,a,c,h,u,l,d,B,w,f,g,Q,v,p,m,U,C,F,y,b,E,H,I,k,T,S,K,O,D,M,L,x,R;return Za(this,(function(N){switch(N.label){case 0:if(!A||"object"!=typeof A)return[2,Promise.reject("Invalid element provided as first argument")];if(!(e=A.ownerDocument))throw new Error("Element is not attached to a Document");if(!(i=e.defaultView))throw new Error("Document is not attached to a Window");return n={allowTaint:null!==(C=t.allowTaint)&&void 0!==C&&C,imageTimeout:null!==(F=t.imageTimeout)&&void 0!==F?F:15e3,proxy:t.proxy,useCORS:null!==(y=t.useCORS)&&void 0!==y&&y,customIsSameOrigin:t.customIsSameOrigin},s=Xa({logging:null===(b=t.logging)||void 0===b||b,cache:t.cache},n),r={windowWidth:null!==(E=t.windowWidth)&&void 0!==E?E:i.innerWidth,windowHeight:null!==(H=t.windowHeight)&&void 0!==H?H:i.innerHeight,scrollX:null!==(I=t.scrollX)&&void 0!==I?I:i.pageXOffset,scrollY:null!==(k=t.scrollY)&&void 0!==k?k:i.pageYOffset},o=new Wa(r.scrollX,r.scrollY,r.windowWidth,r.windowHeight),a=new jf(s,o),c=null!==(T=t.foreignObjectRendering)&&void 0!==T&&T,h={allowTaint:null!==(S=t.allowTaint)&&void 0!==S&&S,onclone:t.onclone,ignoreElements:t.ignoreElements,inlineImages:c,copyStyles:c},a.logger.debug("Starting document clone with size ".concat(o.width,"x").concat(o.height," scrolled to ").concat(-o.left,",").concat(-o.top)),u=new Ew(a,A,h),(l=u.clonedReferenceElement)?[4,u.toIFrame(e,o)]:[2,Promise.reject("Unable to find element in cloned iframe")];case 1:return d=N.sent(),B=tw(l)||"HTML"===l.tagName?(function(A){var t=A.body,e=A.documentElement;if(!t||!e)throw new Error("Unable to get document size");var i=Math.max(Math.max(t.scrollWidth,e.scrollWidth),Math.max(t.offsetWidth,e.offsetWidth),Math.max(t.clientWidth,e.clientWidth)),n=Math.max(Math.max(t.scrollHeight,e.scrollHeight),Math.max(t.offsetHeight,e.offsetHeight),Math.max(t.clientHeight,e.clientHeight));return new Wa(0,0,i,n)})(l.ownerDocument):qa(a,l),w=B.width,f=B.height,g=B.left,Q=B.top,v=(function(A,t,e){var i=t.ownerDocument,n=i.documentElement?Pu(A,getComputedStyle(i.documentElement).backgroundColor):_u.TRANSPARENT,s=i.body?Pu(A,getComputedStyle(i.body).backgroundColor):_u.TRANSPARENT,r="string"==typeof e?Pu(A,e):null===e?_u.TRANSPARENT:4294967295;return t===i.documentElement?au(n)?au(s)?r:s:n:r})(a,l,t.backgroundColor),p={canvas:t.canvas,backgroundColor:v,scale:null!==(O=null!==(K=t.scale)&&void 0!==K?K:i.devicePixelRatio)&&void 0!==O?O:1,x:(null!==(D=t.x)&&void 0!==D?D:0)+g,y:(null!==(M=t.y)&&void 0!==M?M:0)+Q,width:null!==(L=t.width)&&void 0!==L?L:Math.ceil(w),height:null!==(x=t.height)&&void 0!==x?x:Math.ceil(f)},c?(a.logger.debug("Document cloned, using foreign object rendering"),[4,new Rf(a,p).render(l)]):[3,3];case 2:return m=N.sent(),[3,5];case 3:return a.logger.debug("Document cloned, element located at ".concat(g,",").concat(Q," with size ").concat(w,"x").concat(f," using computed rendering")),a.logger.debug("Starting DOM parsing"),U=PB(a,l),v===U.styles.backgroundColor&&(U.styles.backgroundColor=_u.TRANSPARENT),a.logger.debug("Starting renderer for element at ".concat(p.x,",").concat(p.y," with size ").concat(p.width,"x").concat(p.height)),[4,new Kf(a,p).render(U)];case 4:m=N.sent(),N.label=5;case 5:return(null===(R=t.removeContainer)||void 0===R||R)&&(Ew.destroy(d)||a.logger.error("Cannot detach cloned iframe as it is not in the DOM anymore")),a.logger.debug("Finished rendering"),[2,m]}}))}))})(A,t))).toDataURL("image/png");this.activeSession.emit("screenCaptureComplete",e)}catch(e){this.activeSession.emit("screenCaptureComplete","error")}var A,t}));const e=await t.connect();e&&(this.sessionToken=A,this.roomToken=e.token,this.roomUrl=e.url,this.removeSessionUrlParams()),this.activeSession=t}catch(t){this.handleSessionCreationFailure((()=>this.removeSessionUrlParams()))}}async handleSessionStart(A){this.activeSession||(this.showSessionStartModal=!1,this.state=Ga.LOADING,await this.connectObi(A))}async checkExistingSession(){try{const A=JSON.parse(wg.getItem(Bg)||"{}"),{sessionToken:t,roomToken:e,roomUrl:i,sessionExpiry:n,obiState:s}=A;if(!t||!e||!i)return;if(n&&new Date(n)<new Date)return void this.clearSessionStorage();this.state=Ga.LOADING;const r=this.createSession(t);if(!r)return void this.handleSessionCreationFailure((()=>this.clearSessionStorage()));this.setupSessionEventListeners(r,(()=>this.clearSessionStorage())),await r.reconnect(i,e,s)?(this.activeSession=r,this.sessionToken=t,this.roomToken=e,this.roomUrl=i,this.state=s,this.storedActiveState=s):this.clearSessionStorage()}catch(A){this.handleSessionCreationFailure((()=>this.clearSessionStorage()))}}clearSessionStorage(){wg.removeItem(Bg)}saveSessionData(){if(this.activeSession&&this.sessionToken&&this.roomToken&&this.roomUrl){const A=new Date;A.setMinutes(A.getMinutes()+5);const t={sessionToken:this.sessionToken,roomToken:this.roomToken,roomUrl:this.roomUrl,obiState:this.storedActiveState??this.state,sessionExpiry:A.toISOString()};wg.setItem(Bg,JSON.stringify(t))}}async sessionConnectionCheck(){if(await this.checkExistingSession(),!this.activeSession){let A={};window.__obiUrlParams&&(A=window.__obiUrlParams),0===Object.keys(A).length&&new URLSearchParams(window.location.search).forEach(((t,e)=>{A[e]=t}));const t=A[Pa];t&&this.apiKey?await this.handleUrlSessionEvent(t):t&&!this.apiKey&&setTimeout((()=>{this.apiKey&&this.handleUrlSessionEvent(t)}),100)}}connectedCallback(){super.connectedCallback(),this.updateFromConfig(),this.setAttribute("position",this.position),this.boundSaveSessionData=this.saveSessionData.bind(this),window.addEventListener("beforeunload",this.boundSaveSessionData),window.addEventListener("pagehide",this.boundSaveSessionData),"complete"===document.readyState?Promise.resolve().then((()=>this.sessionConnectionCheck())):window.addEventListener("load",(()=>{Promise.resolve().then((()=>this.sessionConnectionCheck()))}),{once:!0})}disconnectedCallback(){null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.boundSaveSessionData&&(window.removeEventListener("beforeunload",this.boundSaveSessionData),window.removeEventListener("pagehide",this.boundSaveSessionData)),this.removeSessionUrlParams(),super.disconnectedCallback()}handleMouseEnter(){this.isHovering=!0,this.navVisible=!0}handleMouseLeave(){this.isHovering=!1,null!==this.closeNavTimeoutRef&&window.clearTimeout(this.closeNavTimeoutRef),this.closeNavTimeoutRef=window.setTimeout((()=>{this.isHovering||(this.navVisible=!1),this.closeNavTimeoutRef=null}),300)}terminateSession(){this.clearSessionStorage(),this.sessionToken=null,this.roomToken=null,this.roomUrl=null,null!==this.researchingTimeoutRef&&(window.clearTimeout(this.researchingTimeoutRef),this.researchingTimeoutRef=null),this.activeSession&&(this.activeSession.disconnect(),this.activeSession=null),this.state=Ga.READY}handleItemSelect(A,t){"experiences"!==A?xa([A,t]).with(["pause",!0],(()=>{this.activeSession?.pauseRecording()})).with(["pause",!1],(()=>{this.activeSession?.resumeRecording()})).with(["activate",!1],(()=>{this.terminateSession()})).otherwise((()=>{})):this.showCourseModal=!0}render(){if(!this.isActive)return t.nothing;if(this.linkOnlyAccess&&this.state===Ga.READY)return t.nothing;const A=xa(this.state).with(Ga.LOADING,(()=>t.html`<obi-dot-loader></obi-dot-loader>`)).with(Ga.RESEARCHING,(()=>t.html`<obi-searching-loader></obi-searching-loader>`)).with(Da.union(Ga.USER_SPEAKING,Ga.AGENT_SPEAKING),(()=>t.html`<obi-audio-equalizer .volume=${this.volume}></obi-audio-equalizer>`)).with(Ga.THINKING,(()=>t.html`<obi-dot-loader></obi-dot-loader>`)).with(Ga.PAUSED,(()=>bg)).otherwise((()=>bg)),e=this.state===Ga.USER_SPEAKING||this.state===Ga.AGENT_SPEAKING,i=this.state===Ga.RESEARCHING,n=this.state===Ga.USER_SPEAKING,s=["widget-container",this.state!==Ga.READY||this.navVisible?"rotated":"",e?"pulse":"",i?"researching":"",n?"user-speaking":""].filter(Boolean).join(" ");return t.html`
563
563
  <div
564
564
  class="${s}"
565
565
  @mouseenter=${this.handleMouseEnter}
@@ -586,7 +586,7 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
586
586
  .onStart=${this.handleSessionStart.bind(this)}
587
587
  .onClose=${()=>{this.showSessionStartModal=!1,this.selectedCourse=null,this.state=Ga.READY,this.removeSessionUrlParams()}}
588
588
  ></obi-session-start-modal>`:t.nothing}
589
- `}}function YQ(A){return new Promise((t=>setTimeout(t,A)))}function ZQ(A){const t=200*Math.pow(2,A);return Math.min(t,2e3)}async function WQ(A,t,e=3){let i=null;for(let s=0;s<e;s++)try{return await A()}catch(n){if(i=n,s<e-1){const A=ZQ(s);await YQ(A)}}throw new Error(`${t} failed after ${e} attempts: ${i?.message}`)}function qQ(){const A=window;"function"!=typeof A.ObiSDK&&"object"!=typeof A.ObiSDK&&(A.ObiSDK=function(t,e){"update"===t&&e&&(A.obiWidgetConfig={...A.obiWidgetConfig,...e})},A.ObiSDK.q=[])}function $Q(){const A=window;A.ObiSDK&&Array.isArray(A.ObiSDK.q)&&(A.ObiSDK.q.forEach((t=>{const[e,i]=t;"update"===e&&i&&(A.obiWidgetConfig={...A.obiWidgetConfig,...i})})),A.ObiSDK.q=[])}async function zQ(){try{qQ(),await(async function(){return WQ((async()=>{if(!document.head)throw new Error("document.head not available");if(document.head.querySelector('link[href*="fonts.googleapis.com"]'))return;const A=document.createElement("link");return document.head.querySelectorAll("link[data-obi-font]").forEach((A=>A.remove())),A.setAttribute("data-obi-font","true"),A.href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap",A.rel="stylesheet",new Promise(((t,e)=>{const i=setTimeout((()=>{e(new Error("Font loading timeout"))}),5e3);A.onload=()=>{clearTimeout(i),t()},A.onerror=()=>{clearTimeout(i),e(new Error("Font loading failed"))},document.head.appendChild(A)}))}),"Font loading")})(),await(async function(){return WQ((async()=>{if(document.querySelector("obi-widget"))return;if(!document.body)throw new Error("document.body not available");const A=document.createElement("obi-widget");document.body.appendChild(A)}),"Widget mounting")})(),$Q()}catch(A){try{qQ(),$Q()}catch(t){}}}XQ.styles=t.css`
589
+ `}}function XQ(A){return new Promise((t=>setTimeout(t,A)))}function YQ(A){const t=200*Math.pow(2,A);return Math.min(t,2e3)}async function ZQ(A,t,e=3){let i=null;for(let s=0;s<e;s++)try{return await A()}catch(n){if(i=n,s<e-1){const A=YQ(s);await XQ(A)}}throw new Error(`${t} failed after ${e} attempts: ${i?.message}`)}function WQ(){const A=window;"function"!=typeof A.ObiSDK&&"object"!=typeof A.ObiSDK&&(A.ObiSDK=function(t,e){"update"===t&&e&&(A.obiWidgetConfig={...A.obiWidgetConfig,...e})},A.ObiSDK.q=[])}function qQ(){const A=window;A.ObiSDK&&Array.isArray(A.ObiSDK.q)&&(A.ObiSDK.q.forEach((t=>{const[e,i]=t;"update"===e&&i&&(A.obiWidgetConfig={...A.obiWidgetConfig,...i})})),A.ObiSDK.q=[])}async function $Q(A){return ZQ((async()=>{if(!document.head)throw new Error("document.head not available");const t=document.createElement("link");return document.head.querySelectorAll("link[data-obi-font]").forEach((A=>A.remove())),t.setAttribute("data-obi-font","true"),t.href=A,t.rel="stylesheet",new Promise(((A,e)=>{const i=setTimeout((()=>{e(new Error("Font loading timeout"))}),5e3);t.onload=()=>{clearTimeout(i),A()},t.onerror=()=>{clearTimeout(i),e(new Error("Font loading failed"))},document.head.appendChild(t)}))}),"Font loading")}async function zQ(){try{WQ(),await(async function(){await $Q("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Syne:wght@400..800&display=swap"),await $Q("https://fonts.cdnfonts.com/css/satoshi")})(),await(async function(){return ZQ((async()=>{if(document.querySelector("obi-widget"))return;if(!document.body)throw new Error("document.body not available");const A=document.createElement("obi-widget");document.body.appendChild(A)}),"Widget mounting")})(),qQ()}catch(A){try{WQ(),qQ()}catch(t){}}}JQ.styles=t.css`
590
590
  :host {
591
591
  display: block;
592
592
  position: fixed;
@@ -708,4 +708,4 @@ var A,t;A=this,t=function(A,t){"use strict";const e={}.VITE_API_BASE_URL,i=/\{[^
708
708
  .pulse {
709
709
  animation: pulse-shadow 2s ease-in-out infinite;
710
710
  }
711
- `,_Q([dg()],XQ.prototype,"apiKey",2),_Q([dg()],XQ.prototype,"isActive",2),_Q([dg()],XQ.prototype,"linkOnlyAccess",2),_Q([dg()],XQ.prototype,"position",2),_Q([dg()],XQ.prototype,"user",2),_Q([dg()],XQ.prototype,"state",2),_Q([dg()],XQ.prototype,"storedActiveState",2),_Q([dg()],XQ.prototype,"showCourseModal",2),_Q([dg()],XQ.prototype,"showSessionStartModal",2),_Q([dg()],XQ.prototype,"selectedCourse",2),_Q([dg()],XQ.prototype,"isHovering",2),_Q([dg()],XQ.prototype,"navVisible",2),_Q([dg()],XQ.prototype,"activeSession",2),_Q([dg()],XQ.prototype,"volume",2),customElements.get("obi-widget")||customElements.define("obi-widget",XQ),customElements.get("obi-widget")||customElements.define("obi-widget",XQ),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{zQ()})):zQ(),A.ObiWidget=XQ,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lit")):"function"==typeof define&&define.amd?define(["exports","lit"],t):t((A="undefined"!=typeof globalThis?globalThis:A||self).ObiSDK={},A.lit);//# sourceMappingURL=obi-sdk.umd.js.map
711
+ `,_Q([dg()],JQ.prototype,"apiKey",2),_Q([dg()],JQ.prototype,"isActive",2),_Q([dg()],JQ.prototype,"linkOnlyAccess",2),_Q([dg()],JQ.prototype,"position",2),_Q([dg()],JQ.prototype,"user",2),_Q([dg()],JQ.prototype,"state",2),_Q([dg()],JQ.prototype,"storedActiveState",2),_Q([dg()],JQ.prototype,"showCourseModal",2),_Q([dg()],JQ.prototype,"showSessionStartModal",2),_Q([dg()],JQ.prototype,"selectedCourse",2),_Q([dg()],JQ.prototype,"isHovering",2),_Q([dg()],JQ.prototype,"navVisible",2),_Q([dg()],JQ.prototype,"activeSession",2),_Q([dg()],JQ.prototype,"volume",2),customElements.get("obi-widget")||customElements.define("obi-widget",JQ),customElements.get("obi-widget")||customElements.define("obi-widget",JQ),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{zQ()})):zQ(),A.ObiWidget=JQ,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lit")):"function"==typeof define&&define.amd?define(["exports","lit"],t):t((A="undefined"!=typeof globalThis?globalThis:A||self).ObiSDK={},A.lit);//# sourceMappingURL=obi-sdk.umd.js.map