obi-sdk 0.19.60-beta.0 → 0.19.60

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
@@ -131,4 +131,4 @@ ${t}</tr>
131
131
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
132
132
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ra(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let i=this.parser.parseInline(n),r=_3(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ra(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=_3(t);if(r===null)return Ra(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${Ra(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ra(t.text)}},Zb=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Sr=class cy{constructor(e){bt(this,"options"),bt(this,"renderer"),bt(this,"textRenderer"),this.options=e||Ss,this.options.renderer=this.options.renderer||new Sp,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Zb}static parse(e,n){return new cy(n).parse(e)}static parseInline(e,n){return new cy(n).parseInline(e)}parse(e){var i,r;let n="";for(let a=0;a<e.length;a++){let o=e[a];if((r=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&r[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let l='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var r,a;let i="";for(let o=0;o<e.length;o++){let s=e[o];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[s.type]){let c=this.options.extensions.renderers[s.type].call({parser:this},s);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=c||"";continue}}let l=s;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},kp,Hu=(kp=class{constructor(t){bt(this,"options"),bt(this,"block"),this.options=t||Ss}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?xr.lex:xr.lexInline}provideParser(){return this.block?Sr.parse:Sr.parseInline}},bt(kp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),bt(kp,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),kp),oF=class{constructor(...t){bt(this,"defaults",Vb()),bt(this,"options",this.setOptions),bt(this,"parse",this.parseMarkdown(!0)),bt(this,"parseInline",this.parseMarkdown(!1)),bt(this,"Parser",Sr),bt(this,"Renderer",Sp),bt(this,"TextRenderer",Zb),bt(this,"Lexer",xr),bt(this,"Tokenizer",xp),bt(this,"Hooks",Hu),this.use(...t)}walkTokens(t,e){var i,r;let n=[];for(let a of t)switch(n=n.concat(e.call(this,a)),a.type){case"table":{let o=a;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of o.rows)for(let l of s)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=a;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=a;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let l=o[s].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let a=e.renderers[r.name];a?e.renderers[r.name]=function(...o){let s=r.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[r.level];a?a.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),n.renderer){let r=this.defaults.renderer||new Sp(this.defaults);for(let a in n.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=n.renderer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u||""}}i.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new xp(this.defaults);for(let a in n.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=n.tokenizer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Hu;for(let a in n.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=n.hooks[o],l=r[o];Hu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&Hu.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(r,c);return l.call(r,d)})();let u=s.call(r,c);return l.call(r,u)}:r[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(r,c);return d===!1&&(d=await l.apply(r,c)),d})();let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,a=n.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),r&&(s=s.concat(r.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return xr.lex(t,e??this.defaults)}parser(t,e){return Sr.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let i={...n},r={...this.defaults,...i},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let o=r.hooks?await r.hooks.preprocess(e):e,s=await(r.hooks?await r.hooks.provideLexer():t?xr.lex:xr.lexInline)(o,r),l=r.hooks?await r.hooks.processAllTokens(s):s;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser():t?Sr.parse:Sr.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(a);try{r.hooks&&(e=r.hooks.preprocess(e));let o=(r.hooks?r.hooks.provideLexer():t?xr.lex:xr.lexInline)(e,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let s=(r.hooks?r.hooks.provideParser():t?Sr.parse:Sr.parseInline)(o,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return n=>{if(n.message+=`
133
133
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ra(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},ks=new oF;function ot(t,e){return ks.parse(t,e)}ot.options=ot.setOptions=function(t){return ks.setOptions(t),ot.defaults=ks.defaults,o3(ot.defaults),ot},ot.getDefaults=Vb,ot.defaults=Ss,ot.use=function(...t){return ks.use(...t),ot.defaults=ks.defaults,o3(ot.defaults),ot},ot.walkTokens=function(t,e){return ks.walkTokens(t,e)},ot.parseInline=ks.parseInline,ot.Parser=Sr,ot.parser=Sr.parse,ot.Renderer=Sp,ot.TextRenderer=Zb,ot.Lexer=xr,ot.lexer=xr.lex,ot.Tokenizer=xp,ot.Hooks=Hu,ot.parse=ot,ot.options,ot.setOptions,ot.use,ot.walkTokens,ot.parseInline,Sr.parse,xr.lex;const sF="_base_1ne03_1",lF={base:sF},cF=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],uF=["href","title","target","rel"];ot.setOptions({breaks:!0,gfm:!0});function dF(t){const{content:e,className:n,...i}=t,r=T.useMemo(()=>{if(!e)return"";const a=ot.parse(e,{async:!1});return kz.sanitize(a,{ALLOWED_TAGS:[...cF],ALLOWED_ATTR:[...uF],ALLOW_DATA_ATTR:!1})},[e]);return r?f.jsx("div",{className:oe(lF.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const hF="_controlBar_7jslb_1",fF="_popoverAnchor_7jslb_11",pF="_controlBarSlot_7jslb_15",mF="_confirmationPopover_7jslb_21",gF="_confirmationPopoverAlignRight_7jslb_36",vF="_confirmationPopoverAlignCenter_7jslb_39",bF="_confirmationMessage_7jslb_59",yF="_confirmationActions_7jslb_66",_F="_confirmationButton_7jslb_71",xF="_confirmationButtonCancel_7jslb_89",SF="_confirmationButtonNeutral_7jslb_97",kF="_confirmationButtonDanger_7jslb_105",TF="_controlButton_7jslb_114",wF="_controlButtonIconOnly_7jslb_136",CF="_controlButtonDisabled_7jslb_141",EF="_controlButtonDanger_7jslb_168",RF="_controlButtonContent_7jslb_184",AF="_controlButtonIcon_7jslb_136",NF="_controlButtonLabel_7jslb_200",OF="_controlButtonChevron_7jslb_207",MF="_controlButtonNotificationDot_7jslb_216",DF="_deviceSplitButton_7jslb_228",PF="_deviceSplitButtonEnabled_7jslb_232",LF="_dualButtonContent_7jslb_313",IF="_dualButtonIcon_7jslb_323",jF="_dualButtonLabel_7jslb_332",BF="_screenShareButton_7jslb_346",UF="_screenShareButtonCompact_7jslb_357",Fe={controlBar:hF,popoverAnchor:fF,controlBarSlot:pF,confirmationPopover:mF,confirmationPopoverAlignRight:gF,confirmationPopoverAlignCenter:vF,confirmationMessage:bF,confirmationActions:yF,confirmationButton:_F,confirmationButtonCancel:xF,confirmationButtonNeutral:SF,confirmationButtonDanger:kF,controlButton:TF,controlButtonIconOnly:wF,controlButtonDisabled:CF,controlButtonDanger:EF,controlButtonContent:RF,controlButtonIcon:AF,controlButtonLabel:NF,controlButtonChevron:OF,controlButtonNotificationDot:MF,deviceSplitButton:DF,deviceSplitButtonEnabled:PF,dualButtonContent:LF,dualButtonIcon:IF,dualButtonLabel:jF,screenShareButton:BF,screenShareButtonCompact:UF},zF="_inline_1gpyx_1",FF="_vertical_1gpyx_6",qF="_divider_1gpyx_10",HF="_dividerVertical_1gpyx_16",VF="_customDivider_1gpyx_21",Vu={inline:zF,vertical:FF,divider:qF,dividerVertical:HF,customDivider:VF},k3={none:"0px",xxs:"var(--space-xxs)",xs:"var(--space-xs)",sm:"var(--space-sm)",md:"var(--space-md)",lg:"var(--space-lg)",xl:"var(--space-xl)","2xl":"var(--space-2xl)","3xl":"var(--space-3xl)","4xl":"var(--space-4xl)","5xl":"var(--space-5xl)"};function kr(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in k3)return k3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function GF(t,e){const{as:n,direction:i="horizontal",gap:r,align:a="center",justify:o,wrap:s=!1,divider:l,className:c,style:u,children:d,...h}=t,p=n??"div",v={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const y=kr(r);y&&(v.gap=y)}const m=fi.Children.toArray(d).filter(y=>y!=null&&typeof y!="boolean"),S=y=>!l||y===0?null:l===!0||l==="line"?f.jsx("span",{"aria-hidden":"true",className:oe(Vu.divider,i==="vertical"&&Vu.dividerVertical)},`inline-divider-${y}`):f.jsx("span",{"aria-hidden":"true",className:Vu.customDivider,children:l},`inline-divider-${y}`),g=[];return m.forEach((y,x)=>{if(x>0){const b=S(x);b&&g.push(b)}g.push(y)}),f.jsx(p,{ref:e,className:oe(Vu.inline,i==="vertical"&&Vu.vertical,c),style:v,...h,children:g})}const Tp=fi.forwardRef(GF);Tp.displayName="Inline";function WF(){const[t,e]=T.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return T.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 767px)"),i=()=>{e(n.matches)};return i(),typeof n.addEventListener=="function"?(n.addEventListener("change",i),()=>n.removeEventListener("change",i)):(n.addListener(i),()=>n.removeListener(i))},[]),t}function wp(t){const{icon:e,label:n,showChevron:i=!1,variant:r="default",disabled:a,className:o="",size:s="md",iconOnly:l=!1,showNotificationDot:c=!1,isOn:u,"aria-label":d,...h}=t,p=oe(Fe.controlButton,a&&Fe.controlButtonDisabled,l&&Fe.controlButtonIconOnly,r==="danger"&&Fe.controlButtonDanger,o),v=Number.parseInt(Nb[s],10),m=r==="danger"?"outline":"primary",S=r==="danger"?"danger":"default",g=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:Fe.controlButtonContent,children:[e?f.jsx("span",{className:Fe.controlButtonIcon,children:fi.isValidElement(e)&&e.props.size===void 0?fi.cloneElement(e,{size:v}):e}):null,l?null:f.jsx("span",{className:Fe.controlButtonLabel,children:n}),l||!i?null:f.jsx("span",{className:Fe.controlButtonChevron,"aria-hidden":"true",children:f.jsx(Ob,{size:16})})]}),c?f.jsx("span",{className:Fe.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?f.jsx(hp,{...h,type:"button",disabled:a,variant:m,color:S,isOn:u,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g}):f.jsx(Ro,{...h,type:"button",disabled:a,variant:m,color:S,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g})}function YF(t){const{audioDevices:e,currentMicrophoneId:n,isMicrophoneEnabled:i,isScreenShareActive:r,widgetState:a,canPublishData:o,browserSupportsScreenSharing:s,screenShareButtonVariant:l="default",microphoneButtonVariant:c="split",onMicDeviceSelect:u,onMicToggle:d,onChatToggle:h,onLeave:p,onScreenShareToggle:v,showChatNotification:m=!1,isLanguageSelectorEnabled:S=!0,languages:g=[],selectedLanguage:y=null,defaultLanguageCode:x=null,isMultilingual:b=!1,onLanguageChange:k,isChatOpen:w=a==="chat",leadingControl:C,trailingControl:R}=t,A=g.length,N=!S||A===0,O=WF(),B=O?"xs":"sm",X=O,[L,Y]=T.useState(!1),[P,V]=T.useState(!1),K=T.useRef(null),ee=T.useRef(null);T.useEffect(()=>{const Ye=me=>{const Ne=me.composedPath();L&&K.current&&!Ne.includes(K.current)&&Y(!1),P&&ee.current&&!Ne.includes(ee.current)&&V(!1)},Lt=me=>{me.key==="Escape"&&(L&&Y(!1),P&&V(!1))};if(L||P)return document.addEventListener("mousedown",Ye),document.addEventListener("keydown",Lt),()=>{document.removeEventListener("mousedown",Ye),document.removeEventListener("keydown",Lt)}},[L,P]),T.useEffect(()=>{r||Y(!1)},[r]);const $=T.useMemo(()=>e.map(Ye=>({label:Ye.label||`Microphone ${Ye.deviceId.slice(0,8)}`,value:Ye.deviceId})),[e]),U=T.useMemo(()=>n?$.find(Ye=>Ye.value===n)??null:null,[n,$]),Z=T.useCallback(Ye=>{Ye.value,u(Ye.value)},[u]),Q={microphone:!0,screenShare:s,chat:o},le=T.useCallback(()=>{if(r){Y(!0);return}v()},[r,v]),j=T.useCallback(()=>{Y(!1),v()},[v]),ge=T.useCallback(()=>{Y(!1)},[]),H=T.useCallback(()=>{V(!0)},[]),he=T.useCallback(()=>{V(!1),p()},[p]),ve=T.useCallback(()=>{V(!1)},[]);return f.jsx("div",{className:Fe.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify(Q),"data-language-option-count":A>0?String(A):void 0,"data-default-language-code":x??void 0,children:f.jsxs(Tp,{gap:B,align:"center",justify:"center",wrap:X,children:[C?f.jsx("div",{className:Fe.controlBarSlot,children:C}):null,c==="simple"?f.jsx(wp,{icon:i?f.jsx(up,{}):f.jsx(dp,{}),label:"Microphone",onClick:d,isOn:i,"aria-label":i?"Mute microphone":"Unmute microphone"}):f.jsx(MU,{onClick:d,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:$,value:U,onChange:Z,variant:"primary",menuPlacement:"top",menuDisabled:$.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:oe(Fe.deviceSplitButton,i&&Fe.deviceSplitButtonEnabled),children:f.jsxs("span",{className:Fe.dualButtonContent,children:[f.jsx("span",{className:Fe.dualButtonIcon,children:i?f.jsx(up,{}):f.jsx(dp,{})}),f.jsx("span",{className:Fe.dualButtonLabel,children:"Microphone"})]})}),o?f.jsx(wp,{icon:f.jsx(OE,{}),label:"Chat",onClick:h,isOn:w,"aria-label":"Toggle chat",showNotificationDot:m}):null,s?f.jsxs("div",{ref:K,className:Fe.popoverAnchor,children:[f.jsx(wp,{icon:f.jsx(LE,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Fe.screenShareButtonCompact:Fe.screenShareButton,iconOnly:l==="compact",onClick:le,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),L?f.jsxs("div",{className:oe(Fe.confirmationPopover,Fe.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[f.jsx("p",{className:Fe.confirmationMessage,children:"Stop screen sharing?"}),f.jsxs("div",{className:Fe.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonCancel),onClick:ge,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonNeutral),onClick:j,children:"Stop"})]})]}):null]}):null,f.jsx(VE,{languages:g,value:y,onChange:k,defaultLanguageCode:x,variant:"control-bar",disabled:N}),f.jsxs("div",{ref:ee,className:Fe.popoverAnchor,children:[f.jsx(wp,{icon:f.jsx(Mb,{}),label:"Leave",variant:"danger",onClick:H,"aria-label":"Leave meeting"}),P?f.jsxs("div",{className:oe(Fe.confirmationPopover,Fe.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:Fe.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:Fe.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonCancel),onClick:ve,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonDanger),onClick:he,children:"Leave"})]})]}):null]}),R?f.jsx("div",{className:Fe.controlBarSlot,children:R}):null]})})}function T3(t){return f.jsx(YF,{...t})}const KF="_controlBar_1n8jn_1",XF="_controlButton_1n8jn_12",$F="_controlButtonDisabled_1n8jn_35",JF="_controlButtonDanger_1n8jn_62",QF="_controlButtonIconOnly_1n8jn_78",ZF="_screenShareButton_1n8jn_83",eq="_controlButtonContent_1n8jn_88",tq="_controlButtonIcon_1n8jn_78",nq="_controlButtonLabel_1n8jn_103",iq="_controlButtonNotificationDot_1n8jn_108",rq="_popoverAnchor_1n8jn_198",aq="_confirmationPopover_1n8jn_202",oq="_confirmationMessage_1n8jn_216",sq="_confirmationActions_1n8jn_223",lq="_confirmationButton_1n8jn_228",cq="_confirmationButtonCancel_1n8jn_246",uq="_confirmationButtonDanger_1n8jn_254",yt={controlBar:KF,controlButton:XF,controlButtonDisabled:$F,controlButtonDanger:JF,controlButtonIconOnly:QF,screenShareButton:ZF,controlButtonContent:eq,controlButtonIcon:tq,controlButtonLabel:nq,controlButtonNotificationDot:iq,popoverAnchor:rq,confirmationPopover:aq,confirmationMessage:oq,confirmationActions:sq,confirmationButton:lq,confirmationButtonCancel:cq,confirmationButtonDanger:uq};function Ts(t){const{icon:e,label:n,variant:i="default",disabled:r,className:a="",iconOnly:o=!1,showNotificationDot:s=!1,isOn:l,"aria-label":c,...u}=t,d=oe(yt.controlButton,r&&yt.controlButtonDisabled,o&&yt.controlButtonIconOnly,i==="danger"&&yt.controlButtonDanger,a),h=i==="danger"?"outline":"primary",p=i==="danger"?"danger":"default",v=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:yt.controlButtonContent,children:[e?f.jsx("span",{className:yt.controlButtonIcon,children:fi.isValidElement(e)&&e.props.size===void 0?fi.cloneElement(e,{size:20}):e}):null,o?null:f.jsx("span",{className:yt.controlButtonLabel,children:n})]}),s?f.jsx("span",{className:yt.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?f.jsx(hp,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:v}):f.jsx(Ro,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:v})}function dq(t){const{isMicrophoneEnabled:e,isChatOpen:n,isScreenShareActive:i,showChatNotification:r=!1,onMicToggle:a,onChatToggle:o,onScreenShareToggle:s,onLeave:l,languages:c=[],selectedLanguage:u=null,defaultLanguageCode:d=null,isMultilingual:h=!1,onLanguageChange:p,isLanguageSelectorEnabled:v=!0,className:m,testId:S,...g}=t,y=!v||c.length===0,[x,b]=T.useState(!1),k=T.useRef(null);T.useEffect(()=>{const O=X=>{const L=X.composedPath();x&&k.current&&!L.includes(k.current)&&b(!1)},B=X=>{X.key==="Escape"&&x&&b(!1)};if(x)return document.addEventListener("mousedown",O),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",B)}},[x]);const w=T.useCallback(()=>{a()},[a]),C=T.useCallback(()=>{s()},[s]),R=T.useCallback(()=>{b(!0)},[]),A=T.useCallback(()=>{b(!1),l()},[l]),N=T.useCallback(()=>{b(!1)},[]);return f.jsx("div",{...g,className:oe(yt.controlBar,m),"data-testid":S,children:f.jsxs(Tp,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(Ts,{icon:e?f.jsx(up,{size:18}):f.jsx(dp,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:w,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(Ts,{icon:f.jsx(OE,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),f.jsx(Ts,{icon:f.jsx(LE,{}),label:"Screen share",iconOnly:!0,className:yt.screenShareButton,isOn:i,onClick:C,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),f.jsx(VE,{languages:c,value:u,onChange:p,defaultLanguageCode:d,variant:"pip",disabled:y}),f.jsxs("div",{ref:k,className:yt.popoverAnchor,children:[f.jsx(Ts,{icon:f.jsx(Mb,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:R,"aria-label":"Hang up"}),x?f.jsxs("div",{className:yt.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:yt.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:yt.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonCancel),onClick:N,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonDanger),onClick:A,children:"Leave"})]})]}):null]})]})})}function hq(t){return f.jsx(dq,{...t})}const fq="_container_nz2la_1",pq={container:fq},mq="_responsive_14d0j_2",Gu={responsive:mq,"showAboveWidth-sm":"_showAboveWidth-sm_14d0j_15","showAboveWidth-md":"_showAboveWidth-md_14d0j_24","showAboveWidth-lg":"_showAboveWidth-lg_14d0j_33","showAboveWidth-xl":"_showAboveWidth-xl_14d0j_42","hideAboveWidth-sm":"_hideAboveWidth-sm_14d0j_53","hideAboveWidth-md":"_hideAboveWidth-md_14d0j_59","hideAboveWidth-lg":"_hideAboveWidth-lg_14d0j_65","hideAboveWidth-xl":"_hideAboveWidth-xl_14d0j_71","showAboveHeight-short":"_showAboveHeight-short_14d0j_84","showAboveHeight-medium":"_showAboveHeight-medium_14d0j_93","hideAboveHeight-short":"_hideAboveHeight-short_14d0j_104","hideAboveHeight-medium":"_hideAboveHeight-medium_14d0j_110"};function w3(t){const{as:e,children:n,showAboveWidth:i,hideAboveWidth:r,showAboveHeight:a,hideAboveHeight:o,className:s,...l}=t,c=[Gu.responsive];return i&&c.push(Gu[`showAboveWidth-${i}`]),r&&c.push(Gu[`hideAboveWidth-${r}`]),a&&c.push(Gu[`showAboveHeight-${a}`]),o&&c.push(Gu[`hideAboveHeight-${o}`]),f.jsx(e??"div",{...l,className:oe(c,s),children:n})}function gq(t){const{isMicrophoneEnabled:e,onMicToggle:n,onLeave:i,onReturnToCourseOutline:r,zIndex:a=1e3,className:o,testId:s}=t,[l,c]=T.useState(!1),u=T.useRef(null);T.useEffect(()=>{const g=x=>{const b=x.composedPath();l&&u.current&&!b.includes(u.current)&&c(!1)},y=x=>{x.key==="Escape"&&l&&c(!1)};if(l)return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[l]);const d=T.useCallback(()=>{n()},[n]),h=T.useCallback(()=>{r()},[r]),p=T.useCallback(()=>{c(!0)},[]),v=T.useCallback(()=>{c(!1),i()},[i]),m=T.useCallback(()=>{c(!1)},[]),S=T.useMemo(()=>({position:"fixed",left:"50%",transform:"translateX(-50%)",bottom:"calc(var(--space-md, 16px) + env(safe-area-inset-bottom))",zIndex:a,width:"100%",maxWidth:"520px",paddingInline:"var(--space-sm, 8px)",boxSizing:"border-box",display:"flex",justifyContent:"center"}),[a]);return f.jsx(w3,{hideAboveWidth:"md",className:o,style:S,"data-testid":s,children:f.jsx("div",{className:pq.container,children:f.jsx("div",{className:oe(yt.controlBar),children:f.jsxs(Tp,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(Ts,{icon:e?f.jsx(up,{size:18}):f.jsx(dp,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:d,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(Ts,{icon:f.jsx(jE,{size:18}),label:"Return to course outline",iconOnly:!0,onClick:h,"aria-label":"Return to course outline"}),f.jsxs("div",{ref:u,className:yt.popoverAnchor,children:[f.jsx(Ts,{icon:f.jsx(Mb,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:p,"aria-label":"Hang up"}),l?f.jsxs("div",{className:yt.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:yt.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:yt.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonCancel),onClick:m,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonDanger),onClick:v,children:"Leave"})]})]}):null]})]})})})})}const vq="_container_zht0b_1",bq="_containerGradient_zht0b_14",yq="_containerFlat_zht0b_24",_q="_halo_zht0b_28",xq="_outerRing_zht0b_38",Sq="_circle_zht0b_42",kq="_image_zht0b_72",Tq="_captionContainer_zht0b_88",wq="_captionRegion_zht0b_99",Aa={container:vq,containerGradient:bq,containerFlat:yq,halo:_q,outerRing:xq,circle:Sq,image:kq,captionContainer:Tq,captionRegion:wq},Cq="_statusText_1dkze_6",Eq={statusText:Cq},Rq={idle:null,thinking:"Thinking...",searching:"Searching..."};function Aq(t){const{status:e,size:n="md"}=t,i=e?Rq[e]:null,r=i!==null;return f.jsx("div",{className:Eq.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const Nq="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",Oq={sm:{haloSize:"4.5rem",maxBorderWidth:5,outerRingScalePower:.55,glowSize:"20px"},md:{haloSize:"8rem",maxBorderWidth:8,outerRingScalePower:.7,glowSize:"35px"},lg:{haloSize:"10rem",maxBorderWidth:10,outerRingScalePower:.75,glowSize:"42px"}};function C3(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=Nq,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=Oq[n],p=Math.min(1,Math.max(0,e)),v=p>.01,m=v?Math.min(1,p/.5):0,S=v?Math.max(1,m*h.maxBorderWidth):0,g=1.02,y=v?g+p*h.outerRingScalePower:g,x=v?.2+p*.35:0,b={...u??{},...a?{"--avatar-fallback-accent":a}:{}},k={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${S}px`,"--avatar-fallback-secondary-border-scale":y.toString(),"--avatar-fallback-secondary-border-opacity":x.toString(),"--avatar-fallback-glow-size":h.glowSize},w=l!=null&&l!=="";return f.jsxs("div",{...d,className:oe(Aa.container,i==="gradient"?Aa.containerGradient:Aa.containerFlat,c),style:b,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[f.jsxs("div",{className:Aa.halo,style:k,children:[f.jsx("div",{className:Aa.outerRing,"aria-hidden":"true"}),f.jsx("div",{className:Aa.circle,children:f.jsx("img",{className:Aa.image,src:r,alt:"","aria-hidden":"true"})}),f.jsx(Aq,{status:s,size:n})]}),w&&f.jsx("div",{className:Aa.captionContainer,children:f.jsx("div",{className:Aa.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const Mq="_container_1k3qg_11",Dq="_screenshot_1k3qg_20",Pq="_flash_1k3qg_30",ey={container:Mq,screenshot:Dq,flash:Pq};function Lq(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=T.useState(!1),s=T.useRef(null),l=T.useRef(i);return T.useEffect(()=>{l.current=i},[i]),T.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{var c;o(!1),s.current=null,(c=l.current)==null||c.call(l)},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r]),a?f.jsxs("div",{className:ey.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&f.jsx("img",{src:n,alt:"Captured screenshot",className:ey.screenshot}),f.jsx("div",{className:ey.flash})]}):null}const Iq="_container_13ukq_1",jq="_dragging_13ukq_5",Bq="_placeholder_13ukq_9",Uq="_handleButton_13ukq_15",zq="_customHandle_13ukq_105",Vl={container:Iq,dragging:jq,placeholder:Bq,handleButton:Uq,"handle-top":"_handle-top_13ukq_65","handle-bottom":"_handle-bottom_13ukq_75","handle-left":"_handle-left_13ukq_85","handle-right":"_handle-right_13ukq_95",customHandle:zq};function Fq(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=T.useState(!1),o=T.useRef(null),s=T.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=T.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=T.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return T.useEffect(()=>{i&&l()},[i,l]),T.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function qq(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=T.useRef(null),[a,o]=T.useState(!!e),[s,l]=T.useState(!1),[c,u]=T.useState(null),[d,h]=T.useState(()=>e??{x:0,y:0}),p=T.useRef(d);s||(p.current=d);const v=T.useRef(null),m=T.useRef(!1),S=T.useRef(!1);T.useEffect(()=>{e&&(S.current||(o(!0),h(e),p.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),T.useEffect(()=>{if(e||m.current)return;const b=r.current;if(!b)return;const k=b.getBoundingClientRect(),w={x:k.left,y:k.top};m.current=!0,o(!0),h(w),p.current=w,u(n?{width:k.width,height:k.height}:null)},[e,n]);const g=T.useCallback(b=>{const k=v.current;if(!(!k||b.pointerId!==k.pointerId)){v.current=null,S.current=!0,h(p.current),l(!1);try{b.currentTarget.releasePointerCapture(k.pointerId)}catch{}}},[]),y=T.useCallback(b=>{b.button===0&&(b.preventDefault(),b.currentTarget.setPointerCapture(b.pointerId),v.current={pointerId:b.pointerId,startClientX:b.clientX,startClientY:b.clientY,startX:p.current.x,startY:p.current.y},l(!0))},[]),x=T.useCallback(b=>{const k=v.current;if(!k||b.pointerId!==k.pointerId)return;const w={x:k.startX+(b.clientX-k.startClientX),y:k.startY+(b.clientY-k.startClientY)};p.current=w,r.current&&(r.current.style.transform=`translate3d(${w.x}px, ${w.y}px, 0)`),i==null||i(w)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:y,onPointerMove:x,endDrag:g}}function Hq(t){const{children:e,className:n,handle:i="top",initialPosition:r,disabled:a=!1,preserveSpace:o=!0,zIndex:s=1e3,onPositionChange:l,handleAriaLabel:c="Drag",handleLingerMs:u=350,style:d,...h}=t,{containerRef:p,isFixed:v,isDragging:m,position:S,placeholderSize:g,onPointerDown:y,onPointerMove:x,endDrag:b}=qq({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:k,showHandle:w,scheduleHideHandle:C}=Fq({disabled:a,lingerMs:u,isDragging:m}),R=typeof e=="function",A=T.useMemo(()=>{const O=B=>f.jsx("div",{className:oe(Vl.customHandle,B.className),onPointerDown:y,onPointerMove:x,onPointerUp:b,onPointerCancel:b,children:B.children});return O.displayName="Draggable.Handle",O},[y,x,b]),N={...d,position:v?"fixed":"relative",top:v?0:d==null?void 0:d.top,left:v?0:d==null?void 0:d.left,transform:v?`translate3d(${S.x}px, ${S.y}px, 0)`:d==null?void 0:d.transform,zIndex:v?s:d==null?void 0:d.zIndex};return f.jsxs(f.Fragment,{children:[o&&v&&g?f.jsx("div",{className:Vl.placeholder,style:{width:g.width,height:g.height}}):null,f.jsxs("div",{ref:p,className:oe(Vl.container,m?Vl.dragging:null,n),"data-handle-visible":R?void 0:a?"false":k||m?"true":"false",style:N,onMouseEnter:R?void 0:w,onMouseLeave:R?void 0:C,...h,children:[!R&&!a?f.jsx("button",{type:"button",className:oe(Vl.handleButton,Vl[`handle-${i}`]),"aria-label":c,onMouseEnter:w,onMouseLeave:C,onPointerDown:O=>{w(),y(O)},onPointerMove:x,onPointerUp:b,onPointerCancel:b}):null,R?e({Handle:A}):e]})]})}const Vq="_container_gzwdo_1",Gq="_captionRegion_gzwdo_14",Wq="_status_gzwdo_22",Yq="_captionText_gzwdo_29",Cp={container:Vq,captionRegion:Gq,status:Wq,captionText:Yq},Kq={idle:null,thinking:"Thinking...",searching:"Searching..."};function Xq(t){const{text:e,status:n,className:i,...r}=t,a=n?Kq[n]:null;return f.jsx("div",{...r,className:oe(Cp.container,i),"data-testid":"pip-captions-panel",children:f.jsxs("div",{className:Cp.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?f.jsx("div",{className:Cp.status,children:a}):null,f.jsx("div",{className:Cp.captionText,children:e})]})})}const $q="_panel_1laxg_1",Jq="_row_1laxg_22",Qq="_stepContent_1laxg_29",Zq="_stepLabel_1laxg_37",eH="_currentStep_1laxg_44",tH="_nextStep_1laxg_51",nH="_skipButtonContainer_1laxg_65",iH="_circleButton_1laxg_73",rH="_arrowPlaceholder_1laxg_100",aH="_skipButton_1laxg_65",ir={panel:$q,row:Jq,stepContent:Qq,stepLabel:Zq,currentStep:eH,nextStep:tH,skipButtonContainer:nH,circleButton:iH,arrowPlaceholder:rH,skipButton:aH},oH="_truncatedText_1u580_1",sH={truncatedText:oH};function E3(t){const{children:e,maxLines:n=2,className:i,"data-testid":r}=t;return f.jsx("div",{className:`${sH.truncatedText} ${i||""}`,style:{WebkitLineClamp:n},"data-testid":r,children:e})}function lH(t,e,n){var c;const i=t.length,r=n&&i>0&&((c=t[i-1])==null?void 0:c.title)==="Conclusion",a=r?t.slice(0,-1):t.slice(),o=a.length;if(o===0)return{visibleSteps:a,currentIndex:null};const s=typeof e=="number"&&Number.isFinite(e)?e:1;if(r&&s===i)return{visibleSteps:a,currentIndex:null};const l=Math.min(Math.max(s,1),o)-1;return{visibleSteps:a,currentIndex:l}}function ty(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function cH(t){var A;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=T.useMemo(()=>lH(e,n,r),[n,r,e]),[u,d]=T.useState(()=>ty(n,l.length)),h=T.useRef(!1);T.useEffect(()=>{if(!h.current)d(ty(n,l.length));else{const N=ty(n,l.length);u===N&&(h.current=!1)}},[n,l,u]);const p=l.length,v=l[u],m=u>0,S=u<p-1,g=S?(A=l[u+1])==null?void 0:A.title:void 0,y=p>0,x=y?u+1:0,b=y?`Step ${x}/${p}`:"No steps available",k=c!==null&&v&&u!==c,w=()=>{m&&(h.current=!0,d(N=>Math.max(N-1,0)))},C=()=>{S&&(h.current=!0,d(N=>Math.min(N+1,p-1)))},R=()=>{!k||!v||!i||(h.current=!1,i(u,v))};return f.jsxs("div",{...s,className:oe(ir.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[f.jsxs("div",{className:ir.row,children:[m?f.jsx("button",{type:"button",className:ir.circleButton,"aria-label":"Previous step",onClick:w,children:f.jsx(ME,{size:14})}):f.jsx("span",{className:ir.arrowPlaceholder,"aria-hidden":"true"}),f.jsxs("div",{className:ir.stepContent,children:[f.jsx(Si,{className:ir.stepLabel,"aria-live":"polite",children:b}),f.jsx(E3,{maxLines:2,children:f.jsx(Si,{className:ir.currentStep,"data-testid":"pip-outline-current-step",children:(v==null?void 0:v.title)??"No steps available"})}),g?f.jsx(E3,{maxLines:2,children:f.jsxs(Si,{variant:"muted",className:ir.nextStep,children:["Next: ",g]})}):null]}),S?f.jsx("button",{type:"button",className:ir.circleButton,"aria-label":"Next step",onClick:C,children:f.jsx(tB,{size:14})}):f.jsx("span",{className:ir.arrowPlaceholder,"aria-hidden":"true"})]}),k?f.jsx("div",{className:ir.skipButtonContainer,children:f.jsx("button",{type:"button",className:ir.skipButton,"aria-label":"Skip to this step",onClick:R,children:f.jsx(aB,{size:14})})}):null]})}const uH="_window_zm5au_1",dH="_exitButton_zm5au_14",hH="_content_zm5au_47",fH="_contentTopOverlay_zm5au_58",pH="_dragHandle_zm5au_68",mH="_contentBottomOverlay_zm5au_78",gH="_controls_zm5au_87",vH="_messagesPanelWrapper_zm5au_95",Ao={window:uH,exitButton:dH,content:hH,contentTopOverlay:fH,dragHandle:pH,contentBottomOverlay:mH,controls:gH,messagesPanelWrapper:vH};function bH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function yH(t){const{onExit:e,controlBarProps:n,isCourseOutlineSelected:i,onCourseOutlineToggle:r,isCaptionsEnabled:a=!1,onCaptionsToggle:o,courseOutline:s,messagesPanel:l,avatarFallbackProps:c,contentTopOverlaySlot:u,screenshotUrl:d,cameraShotTrigger:h,className:p,testId:v,...m}=t,S=i,g=n.isChatOpen&&!S&&l,y=c==null?void 0:c.captionsText,x=a&&bH(y),[b,k]=T.useState(!1),w=T.useRef(h),C=T.useCallback(()=>{k(!1)},[]);T.useEffect(()=>{h&&h>0&&h!==w.current&&k(!0),w.current=h},[h]);const R=T.useCallback(()=>f.jsx(C3,{audioPower:(c==null?void 0:c.audioPower)??0,size:"sm",background:"flat",imageSrc:c==null?void 0:c.imageSrc,ariaLabel:c==null?void 0:c.ariaLabel,status:c==null?void 0:c.status}),[c]),A=S?s?f.jsx(cH,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):R():g?f.jsx("div",{className:Ao.messagesPanelWrapper,children:l}):x?f.jsx(Xq,{text:y}):R();return f.jsxs("div",{...m,className:oe(Ao.window,p),"data-testid":v,role:"group","aria-label":"Picture-in-Picture",children:[f.jsxs("div",{className:Ao.content,children:[f.jsx("div",{className:Ao.contentTopOverlay,children:u}),f.jsx("button",{type:"button",className:Ao.exitButton,onClick:e,"aria-label":"Exit PiP",children:f.jsx(nB,{size:14})}),A,!g&&f.jsxs("div",{className:Ao.contentBottomOverlay,children:[f.jsx(hp,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:f.jsx(jE,{size:18})}),f.jsx(hp,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:f.jsx(eB,{size:18})})]}),f.jsx(Lq,{isActive:b,imageUrl:d??null,onComplete:C})]}),f.jsx("div",{className:Ao.controls,children:f.jsx(hq,{...n})})]})}function _H(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return f.jsx(Hq,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>f.jsx(yH,{...r,contentTopOverlaySlot:f.jsx(a,{className:Ao.dragHandle})})})}const xH="_root_ygi3o_1",SH="_overlay_ygi3o_7",kH="_caption_ygi3o_17",ny={root:xH,overlay:SH,caption:kH};function TH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function wH(t){const{children:e,className:n,text:i}=t,r=TH(i);return f.jsxs("div",{className:oe(ny.root,n),children:[e,r?f.jsx("div",{className:ny.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:f.jsx("div",{className:ny.caption,children:i})}):null]})}const CH="_box_dc9yv_1",EH={box:CH},R3={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},A3={surface:"var(--color-surface)",surfaceMuted:"var(--color-surface-muted)",surfaceAlt:"var(--color-surface-alt)",primarySoft:"var(--color-primary-soft)",primarySofter:"var(--color-primary-softer)",dangerSurface:"var(--color-danger-surface)"};function RH(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in R3)return R3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function AH(t){if(t!==void 0){if(t in A3)return A3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function NH(t,e){const{as:n,className:i,padding:r,paddingX:a,paddingY:o,paddingTop:s,paddingBottom:l,paddingLeft:c,paddingRight:u,paddingSm:d,paddingMd:h,paddingLg:p,paddingXl:v,margin:m,marginX:S,marginY:g,marginTop:y,marginBottom:x,marginLeft:b,marginRight:k,radius:w,radiusTop:C,radiusBottom:R,radiusLeft:A,radiusRight:N,radiusTopLeft:O,radiusTopRight:B,radiusBottomLeft:X,radiusBottomRight:L,background:Y,gap:P,style:V,...K}=t,ee=n??"div",$={...V},U=$,Z={},Q=(H,he)=>{if(he===void 0)return;const ve=kr(he);ve&&($[H]=ve)},le=(H,he)=>{if(he===void 0)return;const ve=kr(he);ve&&($[H]=ve)},j=(H,he)=>{if(he===void 0)return;const ve=RH(he);ve&&($[H]=ve)},ge={sm:d,md:h,lg:p,xl:v};if(r!==void 0){const H=kr(r);H&&(U["--box-padding"]=H)}for(const[H,he]of Object.entries(ge)){if(he===void 0)continue;const ve=kr(he);ve&&(U[`--box-padding-${H}`]=ve,Z[`data-padding-${H}`]="")}if(a!==void 0){const H=kr(a);H&&($.paddingLeft=H,$.paddingRight=H)}if(o!==void 0){const H=kr(o);H&&($.paddingTop=H,$.paddingBottom=H)}if(Q("paddingTop",s),Q("paddingBottom",l),Q("paddingLeft",c),Q("paddingRight",u),m!==void 0){const H=kr(m);H&&($.margin=H)}if(S!==void 0){const H=kr(S);H&&($.marginLeft=H,$.marginRight=H)}if(g!==void 0){const H=kr(g);H&&($.marginTop=H,$.marginBottom=H)}if(le("marginTop",y),le("marginBottom",x),le("marginLeft",b),le("marginRight",k),P!==void 0){const H=kr(P);H&&($.gap=H)}if(j("borderRadius",w),C!==void 0&&(j("borderTopLeftRadius",C),j("borderTopRightRadius",C)),R!==void 0&&(j("borderBottomLeftRadius",R),j("borderBottomRightRadius",R)),A!==void 0&&(j("borderTopLeftRadius",A),j("borderBottomLeftRadius",A)),N!==void 0&&(j("borderTopRightRadius",N),j("borderBottomRightRadius",N)),j("borderTopLeftRadius",O),j("borderTopRightRadius",B),j("borderBottomLeftRadius",X),j("borderBottomRightRadius",L),Y!==void 0){const H=AH(Y);H&&($.background=H)}return f.jsx(ee,{ref:e,className:oe(EH.box,i),style:$,...Z,...K})}const Ep=fi.forwardRef(NH);Ep.displayName="Box";const OH="_panel_eawk4_1",MH="_selected_eawk4_10",N3={panel:OH,selected:MH};function Wu(t){const{children:e,className:n,selected:i,...r}=t;return f.jsx("div",{className:oe(N3.panel,i?N3.selected:null,n),...r,children:e})}const DH="_root_yccm8_1",PH="_header_yccm8_8",LH="_icon_yccm8_15",IH="_text_yccm8_26",jH="_heading_yccm8_33",BH="_description_yccm8_41",UH="_body_yccm8_47",zH="_footer_yccm8_54",No={root:DH,header:PH,icon:LH,text:IH,heading:jH,description:BH,body:UH,footer:zH};function O3(t){const{className:e,...n}=t;return f.jsx("div",{className:oe(No.icon,e),...n})}function M3(t){const{className:e,...n}=t;return f.jsx("h3",{className:oe(No.heading,e),...n})}function D3(t){const{className:e,...n}=t;return f.jsx("p",{className:oe(No.description,e),...n})}function P3(t){const{className:e,...n}=t;return f.jsx("div",{className:oe(No.footer,e),...n})}function FH(t){const e=T.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(T.isValidElement(s)&&s.type===O3&&i===void 0){i=s;continue}if(T.isValidElement(s)&&s.type===M3&&r===void 0){r=s;continue}if(T.isValidElement(s)&&s.type===D3&&a===void 0){a=s;continue}if(T.isValidElement(s)&&s.type===P3&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function qH(t){const{children:e,className:n,...i}=t,r=FH(e),a=r.icon||r.heading||r.description;return f.jsxs(Wu,{className:oe(No.root,n),...i,children:[a?f.jsxs("div",{className:No.header,children:[r.icon,r.heading||r.description?f.jsxs("div",{className:No.text,children:[r.heading,r.description]}):null]}):null,r.body.length?f.jsx("div",{className:No.body,children:r.body}):null,r.footer]})}const iy=Object.assign(qH,{Icon:O3,Heading:M3,Description:D3,Footer:P3}),HH="_panel_f4a69_1",VH="_header_f4a69_10",GH="_title_f4a69_19",WH="_scrollArea_f4a69_29",YH="_scrollable_f4a69_34",KH="_list_f4a69_39",XH="_courseButton_f4a69_45",$H="_courseCard_f4a69_61",JH="_loading_f4a69_65",QH="_spinnerWrapper_f4a69_69",ZH="_spinner_f4a69_69",eV="_contentHidden_f4a69_92",tV="_courseHeading_f4a69_101",nV="_courseDescription_f4a69_107",iV="_empty_f4a69_116",zn={panel:HH,header:VH,title:GH,scrollArea:WH,scrollable:YH,list:KH,courseButton:XH,courseCard:$H,loading:JH,spinnerWrapper:QH,spinner:ZH,contentHidden:eV,courseHeading:tV,courseDescription:nV,empty:iV};function rV(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=T.useState(()=>i??[]),l=a?n:o,c=T.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=T.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(p=>p!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function aV(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,loadingCourseId:l,emptyMessage:c="No courses available",testId:u,...d}=t;return f.jsxs(Wu,{...d,className:oe(zn.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsx("div",{className:zn.header,children:f.jsx(Si,{as:"h2",className:zn.title,children:e})}),f.jsx("div",{className:zn.scrollArea,children:f.jsx(ql,{className:zn.scrollable,children:r.length===0?f.jsx(Si,{variant:"muted",className:zn.empty,"data-testid":"course-panel-empty",children:c}):f.jsx("div",{className:zn.list,"data-testid":"course-panel-list",children:r.map(h=>{const p=o.includes(h.id),v=l!=null&&h.id===l,m=h.disabled===!0||l!=null,S=oe(zn.courseButton,v&&zn.loading);return f.jsxs("button",{type:"button",className:S,"aria-pressed":p,"aria-disabled":m,"aria-busy":v||void 0,disabled:m,onClick:()=>s==null?void 0:s(h.id,h),"data-testid":`course-panel-item-${h.id}`,children:[v?f.jsx("span",{className:zn.spinnerWrapper,"aria-hidden":"true","data-testid":`course-panel-item-spinner-${h.id}`,children:f.jsx("span",{className:zn.spinner})}):null,f.jsxs(iy,{selected:p,className:zn.courseCard,children:[f.jsx(iy.Heading,{className:oe(zn.courseHeading,v&&zn.contentHidden),children:h.title}),h.description?f.jsx(iy.Description,{className:oe(zn.courseDescription,v&&zn.contentHidden),children:h.description}):null]})]},h.id)})})})})]})}function L3(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=rV({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=T.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return f.jsx(aV,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const oV="_panel_1je0q_1",sV="_header_1je0q_10",lV="_headerActions_1je0q_19",cV="_popoverAnchor_1je0q_27",uV="_backButton_1je0q_31",dV="_divider_1je0q_38",hV="_title_1je0q_44",fV="_scrollArea_1je0q_54",pV="_scrollable_1je0q_59",mV="_list_1je0q_64",gV="_section_1je0q_70",vV="_sectionHeader_1je0q_76",bV="_sectionTitle_1je0q_80",yV="_sectionTitleCompact_1je0q_88",_V="_item_1je0q_92",xV="_itemClickable_1je0q_106",SV="_itemCompleted_1je0q_110",kV="_itemCurrent_1je0q_114",TV="_itemFuture_1je0q_118",wV="_itemDisabled_1je0q_123",CV="_row_1je0q_137",EV="_stepHeader_1je0q_144",RV="_stepNumber_1je0q_153",AV="_stepTitle_1je0q_159",NV="_checkIcon_1je0q_171",OV="_empty_1je0q_175",MV="_confirmationPopover_1je0q_180",DV="_confirmationMessage_1je0q_204",PV="_confirmationActions_1je0q_211",LV="_confirmationButton_1je0q_216",IV="_confirmationButtonCancel_1je0q_234",jV="_confirmationButtonNeutral_1je0q_242",Re={panel:oV,header:sV,headerActions:lV,popoverAnchor:cV,backButton:uV,divider:dV,title:hV,scrollArea:fV,scrollable:pV,list:mV,section:gV,sectionHeader:vV,sectionTitle:bV,sectionTitleCompact:yV,item:_V,itemClickable:xV,itemCompleted:SV,itemCurrent:kV,itemFuture:TV,itemDisabled:wV,row:CV,stepHeader:EV,stepNumber:RV,stepTitle:AV,checkIcon:NV,empty:OV,confirmationPopover:MV,confirmationMessage:DV,confirmationActions:PV,confirmationButton:LV,confirmationButtonCancel:IV,confirmationButtonNeutral:jV};function BV(t){var p;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((p=e[r-1])==null?void 0:p.title)==="Conclusion",o=a?e.slice(0,-1):e.slice(),s=o.length,l=typeof n=="number"&&isFinite(n)?n:1;if(s===0)return{visibleSteps:o,completedIndices:[],currentIndex:null,futureIndices:[]};if(a&&l===r)return{visibleSteps:o,completedIndices:Array.from({length:s},(v,m)=>m),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(v,m)=>m),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(v,m)=>d+1+m);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function UV(t){const{title:e="Course Outline",ariaLabel:n,className:i,steps:r,currentStep:a,onStepClick:o,hideTrailingConclusionStep:s=!0,emptyMessage:l="No steps available",density:c="default",testId:u,onBackToCoursesConfirm:d,backToCoursesDisabled:h=!1,backToCoursesLabel:p="Back to courses",backToCoursesConfirmMessage:v="Going back will end this course. You can start another course from the list.",backToCoursesConfirmLabel:m="Back",backToCoursesCancelLabel:S="Cancel",showBackToCourses:g=!0,...y}=t,[x,b]=T.useState(!1),k=T.useRef(null),w=h||!d,C=T.useCallback(V=>(V+1).toString().padStart(2,"0"),[]),{visibleSteps:R,completedIndices:A,currentIndex:N,futureIndices:O}=T.useMemo(()=>BV({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),B=c==="compact"?"md":"lg",X=T.useCallback(()=>{w||b(V=>!V)},[w]),L=T.useCallback(()=>{b(!1)},[]),Y=T.useCallback(()=>{b(!1),d&&d()},[d]);T.useEffect(()=>{if(!x)return;const V=ee=>{const $=ee.composedPath();k.current&&!$.includes(k.current)&&b(!1)},K=ee=>{ee.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",V),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",K)}},[x]),T.useEffect(()=>{w&&x&&b(!1)},[w,x]);const P=T.useCallback((V,K)=>{const ee=R[V];if(!ee)return null;const $=typeof o=="function",U=$&&ee.disabled===!0,Z=$&&!U,Q=oe(Re.item,{[Re.itemClickable]:Z,[Re.itemCompleted]:K==="completed",[Re.itemCurrent]:K==="current",[Re.itemFuture]:K==="future",[Re.itemDisabled]:U}),le=f.jsxs("div",{className:Re.row,children:[f.jsxs("div",{className:Re.stepHeader,children:[f.jsx("span",{className:Re.stepNumber,children:C(V)}),f.jsx("span",{className:Re.stepTitle,children:ee.title})]}),K==="completed"?f.jsx(lp,{size:20,className:Re.checkIcon}):null]});return $?f.jsx(Ep,{as:"button",type:"button",className:Q,onClick:()=>{Z&&o(V,ee)},disabled:U,"aria-current":K==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${ee.title}`,"data-testid":`course-outline-item-${ee.id}`,padding:B,radius:"panel",gap:"sm",children:le},ee.id):f.jsx(Ep,{className:Q,"aria-current":K==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${ee.title}`,"data-testid":`course-outline-item-${ee.id}`,padding:B,radius:"panel",gap:"sm",children:le},ee.id)},[C,B,o,R]);return f.jsxs(Wu,{...y,className:oe(Re.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsxs("div",{className:Re.header,children:[f.jsx(Si,{as:"h2",className:Re.title,children:e}),g?f.jsx("div",{className:Re.headerActions,children:f.jsxs("div",{ref:k,className:Re.popoverAnchor,children:[f.jsxs(Ro,{type:"button",variant:"secondary",color:"default",size:"sm",className:Re.backButton,onClick:X,disabled:w,"aria-label":p,"data-testid":"course-outline-back-button",children:[f.jsx(ME,{size:16,"aria-hidden":"true"}),f.jsx("span",{children:p})]}),x?f.jsxs("div",{className:Re.confirmationPopover,role:"dialog","aria-label":"Back to courses confirmation","data-testid":"course-outline-back-confirm",children:[f.jsx("p",{className:Re.confirmationMessage,children:v}),f.jsxs("div",{className:Re.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(Re.confirmationButton,Re.confirmationButtonCancel),onClick:L,"data-testid":"course-outline-back-cancel",children:S}),f.jsx("button",{type:"button",className:oe(Re.confirmationButton,Re.confirmationButtonNeutral),onClick:Y,"data-testid":"course-outline-back-confirm-action",children:m})]})]}):null]})}):null]}),f.jsx("div",{className:Re.divider,"aria-hidden":"true"}),f.jsx("div",{className:Re.scrollArea,children:f.jsx(ql,{className:Re.scrollable,children:R.length===0?f.jsx(Si,{variant:"muted",className:Re.empty,"data-testid":"course-outline-empty",children:l}):f.jsxs("div",{className:Re.list,"data-testid":"course-outline-list",children:[A.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-completed",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:oe(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Completed"})}),A.map(V=>P(V,"completed"))]}):null,N!==null?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-current",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:oe(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Current"})}),P(N,"current")]}):null,O.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-upcoming",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:oe(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Upcoming"})}),O.map(V=>P(V,"future"))]}):null]})})})]})}function zV(t){return f.jsx(UV,{...t})}const FV="_panel_h7cuf_1",qV="_messagesArea_h7cuf_20",HV="_messagesList_h7cuf_46",VV="_messageItem_h7cuf_53",GV="_messageMetadata_h7cuf_59",WV="_senderName_h7cuf_67",YV="_timestamp_h7cuf_71",KV="_messageBubble_h7cuf_75",XV="_agentMessage_h7cuf_85",$V="_agentActions_h7cuf_89",JV="_copyButton_h7cuf_95",QV="_copyButtonCopied_h7cuf_129",ZV="_empty_h7cuf_133",eG="_composer_h7cuf_140",tG="_composerDisabled_h7cuf_160",nG="_composerInput_h7cuf_165",iG="_sendButton_h7cuf_180",Ln={panel:FV,messagesArea:qV,messagesList:HV,messageItem:VV,messageMetadata:GV,senderName:WV,timestamp:YV,messageBubble:KV,agentMessage:XV,agentActions:$V,copyButton:JV,copyButtonCopied:QV,empty:ZV,composer:eG,composerDisabled:tG,composerInput:nG,sendButton:iG};function rG(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function aG(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function oG(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function sG(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function lG(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=T.useState(""),[d,h]=T.useState(null),p=T.useRef(null),v=T.useRef(null),m=T.useMemo(()=>{const b=e[e.length-1];return b?b.id??`${b.timestamp}-${e.length-1}`:null},[e]);T.useEffect(()=>{var b,k;(k=(b=p.current)==null?void 0:b.scrollIntoView)==null||k.call(b,{behavior:"smooth"})},[m]),T.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]);const S=T.useCallback(async()=>{const b=c.trim();b.length!==0&&(await i(b),u(""))},[c,i]),g=T.useCallback(b=>{b.key==="Enter"&&(b.preventDefault(),S())},[S]),y=T.useCallback(async(b,k)=>{try{await sG(b.message??""),h(k),v.current&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{h(null),v.current=null},2e3)}catch(w){console.warn("[PiPChatPanel] Failed to copy message",w)}},[]),x=c.trim().length>0&&!r;return f.jsxs("div",{...l,className:oe(Ln.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[f.jsx("div",{className:Ln.messagesArea,children:e.length===0?f.jsx("div",{className:Ln.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):f.jsxs("div",{className:Ln.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((b,k)=>{const w=b.id??`${b.timestamp}-${k}`,C=aG(b,n),R=d===w;return f.jsxs("div",{className:oe(Ln.messageItem,C&&Ln.agentMessage),"data-testid":`pip-chat-panel-message-${w}`,children:[f.jsxs("div",{className:Ln.messageMetadata,children:[f.jsx("span",{className:Ln.senderName,children:oG(b,n)}),f.jsx("span",{className:Ln.timestamp,children:rG(b.timestamp)})]}),f.jsx("div",{className:Ln.messageBubble,children:b.message}),C?f.jsx("div",{className:Ln.agentActions,children:f.jsx("button",{type:"button",className:oe(Ln.copyButton,R&&Ln.copyButtonCopied),onClick:()=>void y(b,w),"aria-label":R?"Copied":"Copy message",title:R?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":R?"true":"false",children:f.jsx(DE,{size:14})})}):null]},w)}),f.jsx("div",{ref:p})]})}),f.jsxs("div",{className:oe(Ln.composer,r&&Ln.composerDisabled),children:[f.jsx("input",{type:"text",className:Ln.composerInput,value:c,onChange:b=>u(b.target.value),onKeyDown:g,placeholder:a,disabled:r,"aria-label":"Message"}),f.jsx("button",{type:"button",className:Ln.sendButton,onClick:()=>void S(),disabled:!x,"aria-label":"Send message",children:f.jsx(IE,{size:16})})]})]})}const cG="_panel_k5ick_1",uG="_header_k5ick_11",dG="_title_k5ick_19",hG="_titleCompact_k5ick_29",fG="_headerActions_k5ick_33",pG="_closeButton_k5ick_39",mG="_divider_k5ick_67",gG="_body_k5ick_73",vG="_messagesArea_k5ick_81",bG="_scrollable_k5ick_86",yG="_messagesList_k5ick_90",_G="_messageItem_k5ick_98",xG="_messageMetadata_k5ick_104",SG="_senderName_k5ick_112",kG="_timestamp_k5ick_116",TG="_messageBubble_k5ick_120",wG="_messageText_k5ick_124",CG="_agentMessage_k5ick_130",EG="_agentActions_k5ick_134",RG="_copyButton_k5ick_140",AG="_copyButtonCopied_k5ick_174",NG="_inputRow_k5ick_178",OG="_empty_k5ick_182",MG="_composer_k5ick_188",DG="_composerDefault_k5ick_203",PG="_composerCompact_k5ick_208",LG="_composerDisabled_k5ick_218",IG="_composerInputWrapper_k5ick_223",jG="_composerInput_k5ick_223",BG="_sendButton_k5ick_240",UG="_sendButtonCompact_k5ick_257",rt={panel:cG,header:uG,title:dG,titleCompact:hG,headerActions:fG,closeButton:pG,divider:mG,body:gG,messagesArea:vG,scrollable:bG,messagesList:yG,messageItem:_G,messageMetadata:xG,senderName:SG,timestamp:kG,messageBubble:TG,messageText:wG,agentMessage:CG,agentActions:EG,copyButton:RG,copyButtonCopied:AG,inputRow:NG,empty:OG,composer:MG,composerDefault:DG,composerCompact:PG,composerDisabled:LG,composerInputWrapper:IG,composerInput:jG,sendButton:BG,sendButtonCompact:UG};function zG(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function FG(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function qG(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function HG(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function VG(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=T.useState(""),l=T.useCallback(async()=>{const p=o.trim();p.length!==0&&(await a(p),s(""))},[a,o]),c=T.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return f.jsxs("div",{className:oe(rt.composer,u?rt.composerCompact:rt.composerDefault,e?rt.composerDisabled:null),children:[f.jsx("div",{className:rt.composerInputWrapper,children:f.jsx(UE,{value:o,onChange:s,onKeyDown:c,className:rt.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),f.jsx("button",{type:"button",className:oe(rt.sendButton,u?rt.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:f.jsx(IE,{size:d})})]})}function I3(t){const{title:e="Messages",ariaLabel:n,className:i,messages:r,isSending:a=!1,localIdentity:o,onSend:s,onClose:l,showCloseButton:c=!0,emptyMessage:u="No messages yet",density:d="default",testId:h,formatTimestamp:p=zG,getSenderName:v,isAgentMessage:m,copyResetDelayMs:S=2e3,showAgentCopyButton:g=!0,inputPlaceholder:y,inputAutoFocus:x,...b}=t,k=T.useRef(null),[w,C]=T.useState(null),R=T.useRef(null),A=T.useCallback(Y=>v?v(Y):qG(Y,o),[v,o]),N=T.useCallback(Y=>m?m(Y,o):FG(Y,o),[m,o]),O=T.useMemo(()=>{const Y=r[r.length-1];return Y?Y.id??`${Y.timestamp}-${r.length-1}`:null},[r]);T.useEffect(()=>{var Y,P;(P=(Y=k.current)==null?void 0:Y.scrollIntoView)==null||P.call(Y,{behavior:"smooth"})},[O]),T.useEffect(()=>()=>{R.current&&(window.clearTimeout(R.current),R.current=null)},[]);const B=T.useCallback(Y=>{C(Y),R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{C(null),R.current=null},S)},[S]),X=T.useCallback(async(Y,P)=>{try{await HG(Y.message??""),B(P)}catch(V){console.warn("[ChatPanel] Failed to copy message",V)}},[B]),L=d==="compact"?"sm":"md";return f.jsxs(Wu,{...b,className:oe(rt.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[f.jsxs("div",{className:rt.header,children:[f.jsx(Si,{as:"h2",className:oe(rt.title,d==="compact"?rt.titleCompact:null),children:e}),l&&c?f.jsx("div",{className:rt.headerActions,children:f.jsx("button",{type:"button",className:rt.closeButton,onClick:l,"aria-label":`Close ${e}`,children:f.jsx(cp,{size:d==="compact"?18:20})})}):null]}),f.jsx("div",{className:rt.divider,"aria-hidden":"true"}),f.jsxs("div",{className:rt.body,children:[f.jsx("div",{className:rt.messagesArea,children:f.jsx(ql,{className:rt.scrollable,children:r.length===0?f.jsx(Si,{variant:"muted",className:rt.empty,"data-testid":"chat-panel-empty",children:u}):f.jsxs("div",{className:rt.messagesList,"data-testid":"chat-panel-list",children:[r.map((Y,P)=>{const V=Y.id??`${Y.timestamp}-${P}`,K=N(Y),ee=w===V;return f.jsxs("div",{className:oe(rt.messageItem,K?rt.agentMessage:null),"data-testid":`chat-panel-message-${V}`,children:[f.jsxs("div",{className:rt.messageMetadata,children:[f.jsx("span",{className:rt.senderName,children:A(Y)}),f.jsx("span",{className:rt.timestamp,children:p(Y.timestamp)})]}),f.jsx(Ep,{className:rt.messageBubble,padding:"md",radius:"panel",background:K?"surfaceMuted":"surface",children:f.jsx("div",{className:rt.messageText,children:Y.message})}),K&&g?f.jsx("div",{className:rt.agentActions,children:f.jsx("button",{type:"button",className:oe(rt.copyButton,ee?rt.copyButtonCopied:null),onClick:()=>void X(Y,V),"aria-label":ee?"Copied":"Copy agent message",title:ee?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":ee?"true":"false",children:f.jsx(DE,{size:18})})}):null]},V)}),f.jsx("div",{ref:k})]})})}),f.jsx("div",{className:rt.inputRow,children:f.jsx(VG,{onSend:s,disabled:a,placeholder:y,size:L,autoFocus:x})})]})]})}T.createContext("vertical");const GG="_container_1v6ko_1",WG="_video_1v6ko_7",YG="_chip_1v6ko_16",KG="_logo_1v6ko_34",Rp={container:GG,video:WG,chip:YG,logo:KG},XG="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function $G(t){const{agentName:e="Obi",greetingVideoSrc:n,className:i,...r}=t,a=T.useRef(null),o=()=>{var s;try{(s=a.current)==null||s.pause()}catch{}};return f.jsxs("div",{className:oe(Rp.container,i),...r,children:[f.jsx("video",{ref:a,className:Rp.video,src:n??XG,autoPlay:!0,muted:!0,playsInline:!0,onEnded:o}),f.jsxs("div",{className:Rp.chip,children:[f.jsx(iB,{size:12,className:Rp.logo}),f.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const j3=50,Gl="?",B3=/\(error: (.*)\)/,U3=/captureMessage|captureException/;function JG(...t){const e=t.sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0,r=0)=>{const a=[],o=n.split(`
134
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=B3.test(l)?l.replace(B3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=j3+r)break}}return QG(a.slice(r))}}function QG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Ap(e).function||"")&&e.pop(),e.reverse(),U3.test(Ap(e).function||"")&&(e.pop(),U3.test(Ap(e).function||"")&&e.pop()),e.slice(0,j3).map(n=>({...n,filename:n.filename||Ap(e).filename,function:n.function||Gl}))}function Ap(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ZG=30,eW=50;function ry(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Gl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const tW=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nW=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,iW=/\((\S*)(?::(\d+))(?::(\d+))\)/,rW=t=>{const e=tW.exec(t);if(e){const[,i,r,a]=e;return ry(i,Gl,+r,+a)}const n=nW.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=iW.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=z3(n[1]||Gl,n[2]);return ry(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},aW=[ZG,rW],oW=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,sW=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;JG(...[aW,[eW,t=>{const e=oW.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=sW.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Gl;return[i,n]=z3(i,n),ry(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const z3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Gl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const lW={sm:640,md:900,lg:1024,xl:1280};function cW(t){return`(max-width: ${lW[t]-1}px)`}const rr={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function ay(...t){return t.filter(Boolean).join(" ")}function uW(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:ay(rr.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:ay(rr.layout,u?rr.layoutThree:null),children:[f.jsxs("div",{className:rr.leftPanel,children:[f.jsxs("div",{className:rr.videoFrame,children:[d&&h&&f.jsx("div",{className:rr.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:rr.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})})}),f.jsx(wH,{className:rr.captions,text:e,children:f.jsx(C3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:rr.controls,children:f.jsx(T3,{...o})})]}),u?f.jsx("div",{className:rr.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:rr.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(L3,{...l,courses:s,className:ay(rr.coursePanel,l==null?void 0:l.className)})})]})})}function F3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(uW,{...r})})}const dW=80,hW=500,fW=1e3;function pW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=T.useState(""),[s,l]=T.useState(!1),c=T.useRef(""),u=T.useRef(null),d=T.useRef(null),h=T.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},v=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return T.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>dW?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},hW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},fW+n))},[r,s,n]),T.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const ws={shell:"_shell_1n2od_1",layout:"_layout_1n2od_11",mainPanel:"_mainPanel_1n2od_25",coursePanel:"_coursePanel_1n2od_39",controls:"_controls_1n2od_44",returnToPipSlot:"_returnToPipSlot_1n2od_49",returnToPipButton:"_returnToPipButton_1n2od_55"};function q3(...t){return t.filter(Boolean).join(" ")}function mW(t){const{controlBarProps:e,courses:n,coursePanelProps:i,mainPanel:r,onReturnToPiP:a,className:o}=t,s=a?f.jsx(Ro,{type:"button",size:"sm",variant:"tertiary",className:ws.returnToPipButton,onClick:a,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})}):null,l=s?f.jsxs("span",{className:ws.returnToPipSlot,children:[s,e.leadingControl]}):e.leadingControl,c={...e,browserSupportsScreenSharing:!1,microphoneButtonVariant:"simple",...s?{leadingControl:l}:{}};return f.jsx("div",{className:q3(ws.shell,o),"data-testid":"mobile-course-dialog-content",children:f.jsxs("div",{className:ws.layout,children:[f.jsx("div",{className:ws.mainPanel,"data-testid":"mobile-course-dialog-main-panel",children:r??f.jsx(L3,{...i,courses:n,className:q3(ws.coursePanel,i==null?void 0:i.className)})}),f.jsx("div",{className:ws.controls,children:f.jsx(T3,{...c})})]})})}function H3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mW,{...r})})}const Tr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function gW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(Pb,{open:e,onClose:n,size:"large",showCloseButton:c,className:Tr.dialogWithSmallClose,children:f.jsxs("div",{className:Tr.layout,children:[f.jsxs("div",{className:Tr.left,children:[f.jsxs("div",{className:Tr.copy,children:[f.jsx(Si,{variant:"heading",children:r}),f.jsx(Si,{variant:"subheading",children:a}),f.jsx(Si,{variant:"muted",as:"div",className:Tr.description,children:f.jsx(ql,{className:Tr.descriptionScroller,children:f.jsx(dF,{content:o})})})]}),f.jsxs("div",{className:Tr.cta,children:[f.jsx(Ro,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(Si,{variant:"subscript",as:"p",className:Tr.disclaimer,children:l})]})]}),f.jsx(w3,{showAboveWidth:"md",children:f.jsx("div",{className:Tr.right,children:f.jsx(Wu,{className:Tr.mediaPanel,children:f.jsx($G,{agentName:r,greetingVideoSrc:d,className:Tr.agentStill})})})})]})})}const vW={launcherPill:"_launcherPill_1fhyr_1"};function bW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:vW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const V3="__ama_course__",yW="ama_course",_W=3e4,G3=cW("md");function xW(t){var Xl,kn,Tn,Po,Lo,Xr,Io,Gt,jo,Bo,Uo,zo,$l,_,I,M,pe,Pe,be,Wt,kt,Tt,$r,Le,Fo,Jl,iR,rR,aR;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((Xl=e.client)==null?void 0:Xl.selectedPlanUuid)??null:null,a=((kn=e.client)==null?void 0:kn.session)??null,o=!!a&&(i&&!!r||!!((Tn=e.client)!=null&&Tn.selectedPlanUuid)),[s,l]=T.useState(()=>a),[c,u]=T.useState(()=>a!=null&&a.sessionUuid?kW(a.sessionUuid):null),d=(()=>{var W;return a?((W=a.roomId)==null?void 0:W.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=T.useState(()=>d),v=T.useRef(d),[m,S]=T.useState(!1),[g,y]=T.useState(!1),[x,b]=T.useState(!1),[k,w]=T.useState([]),[C,R]=T.useState(null),[A,N]=T.useState(null),[O,B]=T.useState(0),[X,L]=T.useState(!1),[Y,P]=T.useState(!1),[V,K]=T.useState(0),[ee,$]=T.useState(null),[U,Z]=T.useState([]),[Q,le]=T.useState(!1),[j,ge]=T.useState(!1),[H,he]=T.useState(()=>o),ve=T.useRef(o),Ye=T.useRef(null),Lt=T.useRef(null),me=T.useRef(!1),Ne=EW(),_t=()=>{p(W=>{const ne=W==="course-selection",Se=W==="course-outline"&&me.current;return ne||Se?(me.current=!1,L(!1),"pip"):W})};T.useEffect(()=>{v.current=h},[h]),T.useEffect(()=>()=>{Ye.current&&clearTimeout(Ye.current)},[]);const dt=()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)},Ht=()=>{dt(),Lt.current=null,N(W=>W===null?W:null)},un=W=>{dt(),Lt.current=W,N(W),Ye.current=setTimeout(()=>{const ne=Lt.current===W,Se=v.current==="course-selection";ne&&Se&&(Lt.current=null,N(null)),Ye.current=null},_W)},Ot=TW((Lo=(Po=e.client)==null?void 0:Po.product)==null?void 0:Lo.widget_url_blacklist),dn=wW(s),{audioDevices:In}=CW();T.useEffect(()=>{s!=null&&s.sessionUuid&&W3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:ri}=pW(U,{delayMs:0}),ai=typeof navigator<"u"&&!!((Xr=navigator.mediaDevices)!=null&&Xr.getDisplayMedia),ue=((Gt=(Io=s==null?void 0:s.room)==null?void 0:Io.localParticipant)==null?void 0:Gt.isScreenShareEnabled)??!1,Ke=W=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??W.identity,Se=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",Ze=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Se,lastName:Ze,email:xe}},Ce=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se,Ze].map(ht=>ht.trim());return xe.some(ht=>ht.length>0)?xe.join(":"):""},tt=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:Ze.length>0?Ze:void 0,screenShareSupported:ai}},st=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),Fn=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.avatar_image_url)||((zo=(Uo=e.client)==null?void 0:Uo.product)==null?void 0:zo.logo_url)||void 0,Li=((_=($l=e.client)==null?void 0:$l.product)==null?void 0:_.greeting_video_url)||void 0,Yr=SW({sdk:e,session:s,isBlacklisted:Ot}),q=!i&&Yr,re=!!(s??((I=e.client)==null?void 0:I.session)??null),de=(s==null?void 0:s.clientType)==="meet"?Ce(s):"",qe=(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.assistant_subtitle,St=typeof qe=="string"&&qe.trim().length>0?qe:"Onboarding Assistant",hn=()=>B(W=>W+1),Ii=async()=>{var ne,Se;if(!s)return;const W=((Se=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Se.isScreenShareEnabled)??!1;try{W?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(Ze){console.error("[obi-sdk] failed to toggle screen share",Ze)}finally{hn()}},wr=T.useRef(null),Vt=T.useRef(null),qn=T.useRef(!1),xn=T.useRef({session:null,sessionUuid:null,started:!1}),jn=T.useRef(null),Oo=T.useRef(new WeakMap),Wl=(W,ne)=>{if(!ne)return;let Se=Oo.current.get(W);Se||(Se=new Set,Oo.current.set(W,Se)),Se.add(ne)},Te=W=>{if(!W||wr.current===W)return;Vt.current&&(Vt.current(),Vt.current=null);const ne=()=>hn(),Se=Ie=>{u(Ie),Ht(),W!=null&&W.sessionUuid&&W3(W.sessionUuid,Ie),p(fe=>fe==="pip"||fe==="course-outline"?fe:fe==="course-selection"?(me.current=!0,"course-outline"):fe)},Ze=Ie=>{Ht(),w(Ie.courses),p("course-selection"),me.current=!1,u(null),W!=null&&W.sessionUuid&&Y3(W.sessionUuid),R(null),P(!1)},xe=(Ie,fe)=>{},Ae=Ie=>{Ie.isAgent},ht=Ie=>{$(Ie),K(Date.now())},It=Ie=>{if(!Ie){$(null);return}$(Ie),K(Date.now())};W.on("stateChanged",ne),W.on("speakingStateChanged",ne),W.on("paused",ne),W.on("unpaused",ne),W.on("chatMessagesChanged",ne),W.on("chatMessageReceived",Ae),W.on("courseProgress",Se),W.on("courseSelection",Ze),W.on("transcript",xe),W.on("screenCaptured",ht),W.on("screenCaptureNotification",It),W.on("captions",Z),W.on("introductionComplete",_t),wr.current=W,Vt.current=()=>{W.off("stateChanged",ne),W.off("speakingStateChanged",ne),W.off("paused",ne),W.off("unpaused",ne),W.off("chatMessagesChanged",ne),W.off("chatMessageReceived",Ae),W.off("courseProgress",Se),W.off("courseSelection",Ze),W.off("transcript",xe),W.off("screenCaptured",ht),W.off("screenCaptureNotification",It),W.off("captions",Z),W.off("introductionComplete",_t)}},Sn=W=>{var Se;return W?((Se=W.roomId)==null?void 0:Se.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};T.useEffect(()=>{const W=()=>{jn.current&&(jn.current(),jn.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(xn.current.session&&xn.current.session===xe||!!xn.current.sessionUuid&&!!xe.sessionUuid&&xn.current.sessionUuid===xe.sessionUuid){if(xn.current.started||jn.current)return}else xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},W();const ht=async()=>{xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const fe=Ce(xe);fe&&Wl(xe,fe);try{await xe.sendHumanJoined(tt(xe))}catch(Xe){console.error("[obi-sdk] failed to send human_joined handshake",Xe)}},It=(fe,Xe)=>{fe==="connecting"||fe==="error"||(W(),ht())},Ie=xe.state;if(Ie&&Ie!=="connecting"&&Ie!=="error"){ht();return}xe.on("stateChanged",It),jn.current=()=>{xe.off("stateChanged",It)}},Se=xe=>{var Ae,ht,It,Ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Sn(((It=e.client)==null?void 0:It.session)??null));else{const Xe=!!e.passivePlanUuid,fn=Xe&&!!((ht=e.client)!=null&&ht.selectedPlanUuid);if(Xe&&!fn)return;p("start-session")}else(Ie=e.client)!=null&&Ie.session||p("hidden")},Ze=()=>hn();if(e.on("showMenu",Se),e.on("configUpdated",Ze),e.client){e.client.session&&(l(e.client.session),Te(e.client.session),p(Sn(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1);const ht=ve.current;ve.current=!1,ht?(me.current=!0,p("course-outline")):(me.current=!1,p(Sn(Ae))),la().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1),me.current=!1,p(Sn(Ae)),ne(Ae)});const xe=()=>{var It;const Ae=(It=e.client)==null?void 0:It.session;Ae!=null&&Ae.sessionUuid&&Y3(Ae.sessionUuid);const ht=wr.current;Vt.current&&(Vt.current(),Vt.current=null),l(null),wr.current=null,S(!1),y(!1),b(!1),P(!1),he(!1),ve.current=!1,Ht(),me.current=!1,W(),xn.current={session:null,sessionUuid:null,started:!1},ht&&Oo.current.delete(ht),qn.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",hn)}return()=>{e.off("showMenu",Se),e.off("configUpdated",Ze),Vt.current&&Vt.current(),W()}},[e]),T.useEffect(()=>{const W=s;if(!W||W.clientType!=="meet")return;const ne=W.state;if(!ne||ne==="connecting"||ne==="error"||!de)return;const Se=Oo.current.get(W);Se!=null&&Se.has(de)||(Wl(W,de),W.sendHumanJoined(tt(W)).catch(Ze=>console.error("[obi-sdk] failed to send human_joined update",Ze)))},[ai,de,s,s==null?void 0:s.state]),T.useLayoutEffect(()=>{var W,ne;(ne=(W=e.client)==null?void 0:W.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(be=(Pe=e.client)==null?void 0:Pe.product)==null?void 0:be.primary_color,n]),T.useEffect(()=>{if(i&&!Ot&&!re){if(!r){p("hidden");return}p("start-session")}},[re,i,Ot,r]),T.useEffect(()=>{var It,Ie;ge(!1);const W=(It=e.client)==null?void 0:It.api,ne=(Ie=e.client)==null?void 0:Ie.product;if(!W||!ne)return;const Se=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),Ze=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Se?Ae.product_uuid=Se:Ze?Ae.product_slug=Ze:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let ht=!1;return W.getFeatureFlags(Ae).then(fe=>{if(ht)return;const fn=((fe==null?void 0:fe.data)??[]).find(sy=>(sy==null?void 0:sy.slug)===yW);if(!fn)return;const{user_enabled:oi,product_enabled:ki,global_enabled:ji}=fn;let si=!!ji;ki!=null&&(si=!!ki),oi!=null&&(si=!!oi),ge(si)}).catch(fe=>{console.error("[obi-sdk] failed to load AMA feature flag",fe)}),()=>{ht=!0}},[(Wt=e.client)==null?void 0:Wt.api,(kt=e.client)==null?void 0:kt.product]);const Yl=(c==null?void 0:c.stepNames.map((W,ne)=>({id:`step-${ne+1}`,title:W})))??[],Kr=((c==null?void 0:c.totalSteps)??0)>0&&((c==null?void 0:c.stepNames.length)??0)>0?(c==null?void 0:c.currentStep)??null:null,Mo=!0,Do=(W,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(Ot||i&&!r&&!re)return null;if(h==="hidden")return q?f.jsx(bW,{label:St,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const W=(Tt=e.client)==null?void 0:Tt.product,ne=($r=e.client)==null?void 0:$r.selectedPlan,Se=i&&!!r,Ze=i&&!!r||!!((Le=e.client)!=null&&Le.selectedPlanUuid),xe=(W==null?void 0:W.agent_name)||"Obi",Ae=(W==null?void 0:W.assistant_subtitle)||"AI Assistant",ht=Se&&(ne==null?void 0:ne.description)||(W==null?void 0:W.assistant_description)||"";return f.jsx(gW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{ve.current=Ze,he(Ze),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:ht,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:Li})}if(h==="course-selection"){const W=(Fo=s==null?void 0:s.roomId)==null?void 0:Fo.startsWith("obs-"),ne=((Jl=e.client)==null?void 0:Jl.plans)||[],Se=W&&k.length>0,Ze=Se?k.slice().sort((fe,Xe)=>fe.order!==void 0&&Xe.order!==void 0?fe.order-Xe.order:fe.order!==void 0?-1:Xe.order!==void 0?1:fe.name.localeCompare(Xe.name)).map(fe=>({id:fe.uuid,title:fe.name,description:fe.description||fe.overview||"",status:fe.completed?"completed":"available",duration:typeof fe.duration=="number"?`${fe.duration} min`:fe.duration})):ne.map(fe=>{var Xe,fn;return{id:fe.uuid,title:fe.name,description:fe.description,status:(fn=(Xe=e.client)==null?void 0:Xe.planIsCompleted)!=null&&fn[ne.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}});Se&&j&&Ze.push({id:V3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,ht={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),s&&fe&&await s.switchMicrophoneDevice(fe),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:fe=>{s==null||s.setLanguage(fe)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},It=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((iR=s==null?void 0:s.room)==null?void 0:iR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async fe=>{var Xe,fn,oi,ki;if(s){const ji=Date.now();s.appendChatMessage({timestamp:ji,message:fe,from:{identity:((fn=(Xe=s.room)==null?void 0:Xe.localParticipant)==null?void 0:fn.identity)??null,name:((ki=(oi=s.room)==null?void 0:oi.localParticipant)==null?void 0:ki.name)??null},isAgent:!1}),await s.say(fe)}},onClose:()=>b(!1)}):void 0,Ie={selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async fe=>{var Xe,fn,oi,ki;if(!Lt.current)if(Se){if(fe===V3){un(fe),R(fe);try{await((Xe=s==null?void 0:s.say)==null?void 0:Xe.call(s,"Please start an AMA session."))}catch(si){console.error("[obi-sdk] failed to start AMA course",si),Ht(),R(null)}return}const ji=k.find(si=>si.uuid===fe);if(ji){un(fe),R(fe);try{await((fn=s==null?void 0:s.say)==null?void 0:fn.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),Ht(),R(null)}}}else{const ji=ne.find(si=>si.uuid===fe);if(ji){un(fe),(oi=e.client)==null||oi.selectPlan(ji),p("pip");try{await((ki=s==null?void 0:s.say)==null?void 0:ki.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),p("course-selection"),Ht()}}}}};return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,mainPanel:It}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,rightPanel:It,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="course-outline"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async Ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ie),s&&Ie&&await s.switchMicrophoneDevice(Ie),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Ie=>{s==null||s.setLanguage(Ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},Ze=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((rR=s==null?void 0:s.room)==null?void 0:rR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Ie=>{var fe,Xe,fn,oi;if(s){const ki=Date.now();s.appendChatMessage({timestamp:ki,message:Ie,from:{identity:((Xe=(fe=s.room)==null?void 0:fe.localParticipant)==null?void 0:Xe.identity)??null,name:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(Ie)}},onClose:()=>b(!1)}):void 0,xe=!!c,Ae=!H,ht=async()=>{if(!(!(s!=null&&s.endCourse)||Y)){P(!0);try{await s.endCourse("back_to_courses")}catch(Ie){console.error("[obi-sdk] failed to end course",Ie),P(!1)}}},It=f.jsx(zV,{steps:Yl,currentStep:Kr,hideTrailingConclusionStep:Mo,onStepClick:Do,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:ht,backToCoursesDisabled:Y}:{}});return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,mainPanel:Ze??It,onReturnToPiP:xe?()=>p("pip"):void 0}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,middlePanel:It,rightPanel:Ze,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="pip"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se=()=>{s==null||s.stop()},Ze=()=>{if(me.current=!1,c){p("course-outline");return}p("course-selection")},xe={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:ue,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>b(Xe=>!Xe),onScreenShareToggle:Ii,onLeave:Se,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Xe=>{s==null||s.setLanguage(Xe)},isLanguageSelectorEnabled:!0};if(Ne)return f.jsx(gq,{isMicrophoneEnabled:xe.isMicrophoneEnabled,onMicToggle:xe.onMicToggle,onLeave:Se,onReturnToCourseOutline:Ze});const Ae=280,ht=250,It=16,Ie={x:window.innerWidth-Ae-It,y:window.innerHeight-ht-It},fe=x?f.jsx(lG,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((aR=s==null?void 0:s.room)==null?void 0:aR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Xe=>{var fn,oi,ki,ji;if(s){const si=Date.now();s.appendChatMessage({timestamp:si,message:Xe,from:{identity:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.identity)??null,name:((ji=(ki=s.room)==null?void 0:ki.localParticipant)==null?void 0:ji.name)??null},isAgent:!1}),await s.say(Xe)}},testId:"pip-chat-panel"}):void 0;return f.jsx(_H,{initialPosition:Ie,onExit:Ze,controlBarProps:xe,isCourseOutlineSelected:X&&!!c,onCourseOutlineToggle:c?()=>{L(Xe=>!Xe)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>le(Xe=>!Xe),courseOutline:c?{steps:Yl,currentStep:Kr,onStepClick:Do,hideTrailingConclusionStep:Mo}:void 0,messagesPanel:fe,avatarFallbackProps:{audioPower:dn,imageSrc:Fn,status:st,captionsText:ri},screenshotUrl:ee,cameraShotTrigger:V})}return null}function SW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function W3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function kW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function Y3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function TW(t){const[e,n]=T.useState(()=>xs(t));return T.useEffect(()=>{n(xs(t))},[t]),T.useEffect(()=>{const i=()=>{n(xs(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function wW(t){const[e,n]=T.useState(0),i=T.useRef(null),r=T.useRef(0),a=T.useRef(0);return T.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let v=0;for(let m=0;m<s.length;m++)v+=s[m];l=Math.min(1,Math.max(0,v/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function CW(){const[t,e]=T.useState({audioDevices:[]});return T.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function EW(){const t=()=>typeof window>"u"||!("matchMedia"in window)?!1:window.matchMedia(G3).matches,[e,n]=T.useState(()=>t());return T.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const i=window.matchMedia(G3),r=a=>{n(a.matches)};return n(i.matches),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}function K3(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t.endsWith(".clinic1.com")||t.endsWith(".onuptick.com")||t.endsWith(".gorgias.com")||t==="app.canibuild.com"||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const X3=K3();function RW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;AW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(H7);const a=[r];if(X3){const s=new CSSStyleSheet;s.replaceSync(z7),a.push(s);const l=new CSSStyleSheet;l.replaceSync(q7),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(F7),a.push(s)}n.adoptedStyleSheets=a;const o=U7.createRoot(i);X3?o.render(f.jsx(xW,{sdk:t,shadowHost:e})):o.render(f.jsx(W7,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function AW(){$3("https://fonts.cdnfonts.com/css/satoshi"),$3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const J3="49206C6F7665204F6269_session",Q3="obi-url-params",oy="obi-client-heartbeat",NW=5e3,Z3=4e4,eR=15e3;function OW(){return K3()?"meet":"sdk"}function MW(){if(typeof window>"u")return!1;const t=navigator.userAgent||"",n=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|tablet/i.test(t.toLowerCase()),i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches;return n||i}class DW extends Dp{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=OW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=Rh.deserialise(r,e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new Rh(e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,v,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(v=this.client)==null?void 0:v.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&xs(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{la().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&la().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){const n=MW()?"mobile":"desktop";await this.client.startSession(this.client.selectedPlanUuid||null,i=>{i.on("stateChanged",r=>{r!=="disconnecting"&&r!=="disconnected"&&r!=="error"&&r!=="connecting"&&this.save()}),i.on("paused",()=>{this.save()}),i.on("unpaused",()=>{this.save()})},{...e,environment:n})}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(Q3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[J3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(J3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(Q3),this.passivePlanUuid=n}mountWidget(){RW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await MO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await CR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await uO(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>Z3,reason:s>Z3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>eR,reason:o>eR?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(oy);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{la().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},NW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(oy,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(oy)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function tR(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return PW({appToken:t,window:n,init:e})}async function PW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new DW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function nR(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{tR(void 0,nR)}):tR(void 0,nR)})();
134
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=B3.test(l)?l.replace(B3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=j3+r)break}}return QG(a.slice(r))}}function QG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Ap(e).function||"")&&e.pop(),e.reverse(),U3.test(Ap(e).function||"")&&(e.pop(),U3.test(Ap(e).function||"")&&e.pop()),e.slice(0,j3).map(n=>({...n,filename:n.filename||Ap(e).filename,function:n.function||Gl}))}function Ap(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ZG=30,eW=50;function ry(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Gl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const tW=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nW=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,iW=/\((\S*)(?::(\d+))(?::(\d+))\)/,rW=t=>{const e=tW.exec(t);if(e){const[,i,r,a]=e;return ry(i,Gl,+r,+a)}const n=nW.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=iW.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=z3(n[1]||Gl,n[2]);return ry(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},aW=[ZG,rW],oW=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,sW=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;JG(...[aW,[eW,t=>{const e=oW.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=sW.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Gl;return[i,n]=z3(i,n),ry(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const z3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Gl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const lW={sm:640,md:900,lg:1024,xl:1280};function cW(t){return`(max-width: ${lW[t]-1}px)`}const rr={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function ay(...t){return t.filter(Boolean).join(" ")}function uW(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:ay(rr.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:ay(rr.layout,u?rr.layoutThree:null),children:[f.jsxs("div",{className:rr.leftPanel,children:[f.jsxs("div",{className:rr.videoFrame,children:[d&&h&&f.jsx("div",{className:rr.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:rr.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})})}),f.jsx(wH,{className:rr.captions,text:e,children:f.jsx(C3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:rr.controls,children:f.jsx(T3,{...o})})]}),u?f.jsx("div",{className:rr.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:rr.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(L3,{...l,courses:s,className:ay(rr.coursePanel,l==null?void 0:l.className)})})]})})}function F3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(uW,{...r})})}const dW=80,hW=500,fW=1e3;function pW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=T.useState(""),[s,l]=T.useState(!1),c=T.useRef(""),u=T.useRef(null),d=T.useRef(null),h=T.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},v=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return T.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>dW?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},hW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},fW+n))},[r,s,n]),T.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const ws={shell:"_shell_1n2od_1",layout:"_layout_1n2od_11",mainPanel:"_mainPanel_1n2od_25",coursePanel:"_coursePanel_1n2od_39",controls:"_controls_1n2od_44",returnToPipSlot:"_returnToPipSlot_1n2od_49",returnToPipButton:"_returnToPipButton_1n2od_55"};function q3(...t){return t.filter(Boolean).join(" ")}function mW(t){const{controlBarProps:e,courses:n,coursePanelProps:i,mainPanel:r,onReturnToPiP:a,className:o}=t,s=a?f.jsx(Ro,{type:"button",size:"sm",variant:"tertiary",className:ws.returnToPipButton,onClick:a,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})}):null,l=s?f.jsxs("span",{className:ws.returnToPipSlot,children:[s,e.leadingControl]}):e.leadingControl,c={...e,browserSupportsScreenSharing:!1,microphoneButtonVariant:"simple",...s?{leadingControl:l}:{}};return f.jsx("div",{className:q3(ws.shell,o),"data-testid":"mobile-course-dialog-content",children:f.jsxs("div",{className:ws.layout,children:[f.jsx("div",{className:ws.mainPanel,"data-testid":"mobile-course-dialog-main-panel",children:r??f.jsx(L3,{...i,courses:n,className:q3(ws.coursePanel,i==null?void 0:i.className)})}),f.jsx("div",{className:ws.controls,children:f.jsx(T3,{...c})})]})})}function H3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mW,{...r})})}const Tr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function gW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(Pb,{open:e,onClose:n,size:"large",showCloseButton:c,className:Tr.dialogWithSmallClose,children:f.jsxs("div",{className:Tr.layout,children:[f.jsxs("div",{className:Tr.left,children:[f.jsxs("div",{className:Tr.copy,children:[f.jsx(Si,{variant:"heading",children:r}),f.jsx(Si,{variant:"subheading",children:a}),f.jsx(Si,{variant:"muted",as:"div",className:Tr.description,children:f.jsx(ql,{className:Tr.descriptionScroller,children:f.jsx(dF,{content:o})})})]}),f.jsxs("div",{className:Tr.cta,children:[f.jsx(Ro,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(Si,{variant:"subscript",as:"p",className:Tr.disclaimer,children:l})]})]}),f.jsx(w3,{showAboveWidth:"md",children:f.jsx("div",{className:Tr.right,children:f.jsx(Wu,{className:Tr.mediaPanel,children:f.jsx($G,{agentName:r,greetingVideoSrc:d,className:Tr.agentStill})})})})]})})}const vW={launcherPill:"_launcherPill_1fhyr_1"};function bW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:vW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const V3="__ama_course__",yW="ama_course",_W=3e4,G3=cW("md");function xW(t){var Xl,kn,Tn,Po,Lo,Xr,Io,Gt,jo,Bo,Uo,zo,$l,_,I,M,pe,Pe,be,Wt,kt,Tt,$r,Le,Fo,Jl,iR,rR,aR;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((Xl=e.client)==null?void 0:Xl.selectedPlanUuid)??null:null,a=((kn=e.client)==null?void 0:kn.session)??null,o=!!a&&(i&&!!r||!!((Tn=e.client)!=null&&Tn.selectedPlanUuid)),[s,l]=T.useState(()=>a),[c,u]=T.useState(()=>a!=null&&a.sessionUuid?kW(a.sessionUuid):null),d=(()=>{var W;return a?((W=a.roomId)==null?void 0:W.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=T.useState(()=>d),v=T.useRef(d),[m,S]=T.useState(!1),[g,y]=T.useState(!1),[x,b]=T.useState(!1),[k,w]=T.useState([]),[C,R]=T.useState(null),[A,N]=T.useState(null),[O,B]=T.useState(0),[X,L]=T.useState(!1),[Y,P]=T.useState(!1),[V,K]=T.useState(0),[ee,$]=T.useState(null),[U,Z]=T.useState([]),[Q,le]=T.useState(!1),[j,ge]=T.useState(!1),[H,he]=T.useState(()=>o),ve=T.useRef(o),Ye=T.useRef(null),Lt=T.useRef(null),me=T.useRef(!1),Ne=EW(),_t=()=>{p(W=>{const ne=W==="course-selection",Se=W==="course-outline"&&me.current;return ne||Se?(me.current=!1,L(!1),"pip"):W})};T.useEffect(()=>{v.current=h},[h]),T.useEffect(()=>()=>{Ye.current&&clearTimeout(Ye.current)},[]);const dt=()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)},Ht=()=>{dt(),Lt.current=null,N(W=>W===null?W:null)},un=W=>{dt(),Lt.current=W,N(W),Ye.current=setTimeout(()=>{const ne=Lt.current===W,Se=v.current==="course-selection";ne&&Se&&(Lt.current=null,N(null)),Ye.current=null},_W)},Ot=TW((Lo=(Po=e.client)==null?void 0:Po.product)==null?void 0:Lo.widget_url_blacklist),dn=wW(s),{audioDevices:In}=CW();T.useEffect(()=>{s!=null&&s.sessionUuid&&W3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:ri}=pW(U,{delayMs:0}),ai=typeof navigator<"u"&&!!((Xr=navigator.mediaDevices)!=null&&Xr.getDisplayMedia),ue=((Gt=(Io=s==null?void 0:s.room)==null?void 0:Io.localParticipant)==null?void 0:Gt.isScreenShareEnabled)??!1,Ke=W=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??W.identity,Se=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",Ze=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Se,lastName:Ze,email:xe}},Ce=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se,Ze].map(ht=>ht.trim());return xe.some(ht=>ht.length>0)?xe.join(":"):""},tt=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:Ze.length>0?Ze:void 0,screenShareSupported:ai}},st=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),Fn=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.avatar_image_url)||((zo=(Uo=e.client)==null?void 0:Uo.product)==null?void 0:zo.logo_url)||void 0,Li=((_=($l=e.client)==null?void 0:$l.product)==null?void 0:_.greeting_video_url)||void 0,Yr=SW({sdk:e,session:s,isBlacklisted:Ot}),q=!i&&Yr,re=!!(s??((I=e.client)==null?void 0:I.session)??null),de=(s==null?void 0:s.clientType)==="meet"?Ce(s):"",qe=(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.assistant_subtitle,St=typeof qe=="string"&&qe.trim().length>0?qe:"Onboarding Assistant",hn=()=>B(W=>W+1),Ii=async()=>{var ne,Se;if(!s)return;const W=((Se=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Se.isScreenShareEnabled)??!1;try{W?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(Ze){console.error("[obi-sdk] failed to toggle screen share",Ze)}finally{hn()}},wr=T.useRef(null),Vt=T.useRef(null),qn=T.useRef(!1),xn=T.useRef({session:null,sessionUuid:null,started:!1}),jn=T.useRef(null),Oo=T.useRef(new WeakMap),Wl=(W,ne)=>{if(!ne)return;let Se=Oo.current.get(W);Se||(Se=new Set,Oo.current.set(W,Se)),Se.add(ne)},Te=W=>{if(!W||wr.current===W)return;Vt.current&&(Vt.current(),Vt.current=null);const ne=()=>hn(),Se=Ie=>{u(Ie),Ht(),W!=null&&W.sessionUuid&&W3(W.sessionUuid,Ie),p(fe=>fe==="pip"||fe==="course-outline"?fe:fe==="course-selection"?(me.current=!0,"course-outline"):fe)},Ze=Ie=>{Ht(),w(Ie.courses),p("course-selection"),me.current=!1,u(null),W!=null&&W.sessionUuid&&Y3(W.sessionUuid),R(null),P(!1)},xe=(Ie,fe)=>{},Ae=Ie=>{Ie.isAgent},ht=Ie=>{$(Ie),K(Date.now())},It=Ie=>{if(!Ie){$(null);return}$(Ie),K(Date.now())};W.on("stateChanged",ne),W.on("speakingStateChanged",ne),W.on("paused",ne),W.on("unpaused",ne),W.on("chatMessagesChanged",ne),W.on("chatMessageReceived",Ae),W.on("courseProgress",Se),W.on("courseSelection",Ze),W.on("transcript",xe),W.on("screenCaptured",ht),W.on("screenCaptureNotification",It),W.on("captions",Z),W.on("introductionComplete",_t),wr.current=W,Vt.current=()=>{W.off("stateChanged",ne),W.off("speakingStateChanged",ne),W.off("paused",ne),W.off("unpaused",ne),W.off("chatMessagesChanged",ne),W.off("chatMessageReceived",Ae),W.off("courseProgress",Se),W.off("courseSelection",Ze),W.off("transcript",xe),W.off("screenCaptured",ht),W.off("screenCaptureNotification",It),W.off("captions",Z),W.off("introductionComplete",_t)}},Sn=W=>{var Se;return W?((Se=W.roomId)==null?void 0:Se.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};T.useEffect(()=>{const W=()=>{jn.current&&(jn.current(),jn.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(xn.current.session&&xn.current.session===xe||!!xn.current.sessionUuid&&!!xe.sessionUuid&&xn.current.sessionUuid===xe.sessionUuid){if(xn.current.started||jn.current)return}else xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},W();const ht=async()=>{xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const fe=Ce(xe);fe&&Wl(xe,fe);try{await xe.sendHumanJoined(tt(xe))}catch(Xe){console.error("[obi-sdk] failed to send human_joined handshake",Xe)}},It=(fe,Xe)=>{fe==="connecting"||fe==="error"||(W(),ht())},Ie=xe.state;if(Ie&&Ie!=="connecting"&&Ie!=="error"){ht();return}xe.on("stateChanged",It),jn.current=()=>{xe.off("stateChanged",It)}},Se=xe=>{var Ae,ht,It,Ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Sn(((It=e.client)==null?void 0:It.session)??null));else{const Xe=!!e.passivePlanUuid,fn=Xe&&!!((ht=e.client)!=null&&ht.selectedPlanUuid);if(Xe&&!fn)return;p("start-session")}else(Ie=e.client)!=null&&Ie.session||p("hidden")},Ze=()=>hn();if(e.on("showMenu",Se),e.on("configUpdated",Ze),e.client){e.client.session&&(l(e.client.session),Te(e.client.session),p(Sn(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1);const ht=ve.current;ve.current=!1,ht?(me.current=!0,p("course-outline")):(me.current=!1,p(Sn(Ae))),la().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1),me.current=!1,p(Sn(Ae)),ne(Ae)});const xe=()=>{var It;const Ae=(It=e.client)==null?void 0:It.session;Ae!=null&&Ae.sessionUuid&&Y3(Ae.sessionUuid);const ht=wr.current;Vt.current&&(Vt.current(),Vt.current=null),l(null),wr.current=null,S(!1),y(!1),b(!1),P(!1),he(!1),ve.current=!1,Ht(),me.current=!1,W(),xn.current={session:null,sessionUuid:null,started:!1},ht&&Oo.current.delete(ht),qn.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",hn)}return()=>{e.off("showMenu",Se),e.off("configUpdated",Ze),Vt.current&&Vt.current(),W()}},[e]),T.useEffect(()=>{const W=s;if(!W||W.clientType!=="meet")return;const ne=W.state;if(!ne||ne==="connecting"||ne==="error"||!de)return;const Se=Oo.current.get(W);Se!=null&&Se.has(de)||(Wl(W,de),W.sendHumanJoined(tt(W)).catch(Ze=>console.error("[obi-sdk] failed to send human_joined update",Ze)))},[ai,de,s,s==null?void 0:s.state]),T.useLayoutEffect(()=>{var W,ne;(ne=(W=e.client)==null?void 0:W.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(be=(Pe=e.client)==null?void 0:Pe.product)==null?void 0:be.primary_color,n]),T.useEffect(()=>{if(i&&!Ot&&!re){if(!r){p("hidden");return}p("start-session")}},[re,i,Ot,r]),T.useEffect(()=>{var It,Ie;ge(!1);const W=(It=e.client)==null?void 0:It.api,ne=(Ie=e.client)==null?void 0:Ie.product;if(!W||!ne)return;const Se=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),Ze=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Se?Ae.product_uuid=Se:Ze?Ae.product_slug=Ze:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let ht=!1;return W.getFeatureFlags(Ae).then(fe=>{if(ht)return;const fn=((fe==null?void 0:fe.data)??[]).find(sy=>(sy==null?void 0:sy.slug)===yW);if(!fn)return;const{user_enabled:oi,product_enabled:ki,global_enabled:ji}=fn;let si=!!ji;ki!=null&&(si=!!ki),oi!=null&&(si=!!oi),ge(si)}).catch(fe=>{console.error("[obi-sdk] failed to load AMA feature flag",fe)}),()=>{ht=!0}},[(Wt=e.client)==null?void 0:Wt.api,(kt=e.client)==null?void 0:kt.product]);const Yl=(c==null?void 0:c.stepNames.map((W,ne)=>({id:`step-${ne+1}`,title:W})))??[],Kr=((c==null?void 0:c.totalSteps)??0)>0&&((c==null?void 0:c.stepNames.length)??0)>0?(c==null?void 0:c.currentStep)??null:null,Mo=!0,Do=(W,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(Ot||i&&!r&&!re)return null;if(h==="hidden")return q?f.jsx(bW,{label:St,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const W=(Tt=e.client)==null?void 0:Tt.product,ne=($r=e.client)==null?void 0:$r.selectedPlan,Se=i&&!!r,Ze=i&&!!r||!!((Le=e.client)!=null&&Le.selectedPlanUuid),xe=(W==null?void 0:W.agent_name)||"Obi",Ae=(W==null?void 0:W.assistant_subtitle)||"AI Assistant",ht=Se&&(ne==null?void 0:ne.description)||(W==null?void 0:W.assistant_description)||"";return f.jsx(gW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{ve.current=Ze,he(Ze),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:ht,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:Li})}if(h==="course-selection"){const W=(Fo=s==null?void 0:s.roomId)==null?void 0:Fo.startsWith("obs-"),ne=((Jl=e.client)==null?void 0:Jl.plans)||[],Se=W&&k.length>0,Ze=Se?k.slice().sort((fe,Xe)=>fe.order!==void 0&&Xe.order!==void 0?fe.order-Xe.order:fe.order!==void 0?-1:Xe.order!==void 0?1:fe.name.localeCompare(Xe.name)).map(fe=>({id:fe.uuid,title:fe.name,description:fe.description||fe.overview||"",status:fe.completed?"completed":"available",duration:typeof fe.duration=="number"?`${fe.duration} min`:fe.duration})):ne.map(fe=>{var Xe,fn;return{id:fe.uuid,title:fe.name,description:fe.description,status:(fn=(Xe=e.client)==null?void 0:Xe.planIsCompleted)!=null&&fn[ne.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}});Se&&j&&Ze.push({id:V3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,ht={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),s&&fe&&await s.switchMicrophoneDevice(fe),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:fe=>{s==null||s.setLanguage(fe)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},It=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((iR=s==null?void 0:s.room)==null?void 0:iR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async fe=>{var Xe,fn,oi,ki;if(s){const ji=Date.now();s.appendChatMessage({timestamp:ji,message:fe,from:{identity:((fn=(Xe=s.room)==null?void 0:Xe.localParticipant)==null?void 0:fn.identity)??null,name:((ki=(oi=s.room)==null?void 0:oi.localParticipant)==null?void 0:ki.name)??null},isAgent:!1}),await s.say(fe)}},onClose:()=>b(!1)}):void 0,Ie={selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async fe=>{var Xe,fn,oi,ki;if(!Lt.current)if(Se){if(fe===V3){un(fe),R(fe);try{await((Xe=s==null?void 0:s.say)==null?void 0:Xe.call(s,"Please start an AMA session."))}catch(si){console.error("[obi-sdk] failed to start AMA course",si),Ht(),R(null)}return}const ji=k.find(si=>si.uuid===fe);if(ji){un(fe),R(fe);try{await((fn=s==null?void 0:s.say)==null?void 0:fn.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),Ht(),R(null)}}}else{const ji=ne.find(si=>si.uuid===fe);if(ji){un(fe),(oi=e.client)==null||oi.selectPlan(ji),p("pip");try{await((ki=s==null?void 0:s.say)==null?void 0:ki.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),p("course-selection"),Ht()}}}}};return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,mainPanel:It}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,rightPanel:It,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="course-outline"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async Ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ie),s&&Ie&&await s.switchMicrophoneDevice(Ie),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Ie=>{s==null||s.setLanguage(Ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},Ze=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((rR=s==null?void 0:s.room)==null?void 0:rR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Ie=>{var fe,Xe,fn,oi;if(s){const ki=Date.now();s.appendChatMessage({timestamp:ki,message:Ie,from:{identity:((Xe=(fe=s.room)==null?void 0:fe.localParticipant)==null?void 0:Xe.identity)??null,name:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(Ie)}},onClose:()=>b(!1)}):void 0,xe=!!c,Ae=!H,ht=async()=>{if(!(!(s!=null&&s.endCourse)||Y)){P(!0);try{await s.endCourse("back_to_courses")}catch(Ie){console.error("[obi-sdk] failed to end course",Ie),P(!1)}}},It=f.jsx(zV,{steps:Yl,currentStep:Kr,hideTrailingConclusionStep:Mo,onStepClick:Do,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:ht,backToCoursesDisabled:Y}:{}});return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,mainPanel:Ze??It,onReturnToPiP:xe?()=>p("pip"):void 0}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,middlePanel:It,rightPanel:Ze,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="pip"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se=()=>{s==null||s.stop()},Ze=()=>{if(me.current=!1,c){p("course-outline");return}p("course-selection")},xe={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:ue,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>b(Xe=>!Xe),onScreenShareToggle:Ii,onLeave:Se,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Xe=>{s==null||s.setLanguage(Xe)},isLanguageSelectorEnabled:!0};if(Ne)return f.jsx(gq,{isMicrophoneEnabled:xe.isMicrophoneEnabled,onMicToggle:xe.onMicToggle,onLeave:Se,onReturnToCourseOutline:Ze});const Ae=280,ht=250,It=16,Ie={x:window.innerWidth-Ae-It,y:window.innerHeight-ht-It},fe=x?f.jsx(lG,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((aR=s==null?void 0:s.room)==null?void 0:aR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Xe=>{var fn,oi,ki,ji;if(s){const si=Date.now();s.appendChatMessage({timestamp:si,message:Xe,from:{identity:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.identity)??null,name:((ji=(ki=s.room)==null?void 0:ki.localParticipant)==null?void 0:ji.name)??null},isAgent:!1}),await s.say(Xe)}},testId:"pip-chat-panel"}):void 0;return f.jsx(_H,{initialPosition:Ie,onExit:Ze,controlBarProps:xe,isCourseOutlineSelected:X&&!!c,onCourseOutlineToggle:c?()=>{L(Xe=>!Xe)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>le(Xe=>!Xe),courseOutline:c?{steps:Yl,currentStep:Kr,onStepClick:Do,hideTrailingConclusionStep:Mo}:void 0,messagesPanel:fe,avatarFallbackProps:{audioPower:dn,imageSrc:Fn,status:st,captionsText:ri},screenshotUrl:ee,cameraShotTrigger:V})}return null}function SW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function W3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function kW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function Y3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function TW(t){const[e,n]=T.useState(()=>xs(t));return T.useEffect(()=>{n(xs(t))},[t]),T.useEffect(()=>{const i=()=>{n(xs(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function wW(t){const[e,n]=T.useState(0),i=T.useRef(null),r=T.useRef(0),a=T.useRef(0);return T.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let v=0;for(let m=0;m<s.length;m++)v+=s[m];l=Math.min(1,Math.max(0,v/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function CW(){const[t,e]=T.useState({audioDevices:[]});return T.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function EW(){const t=()=>typeof window>"u"||!("matchMedia"in window)?!1:window.matchMedia(G3).matches,[e,n]=T.useState(()=>t());return T.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const i=window.matchMedia(G3),r=a=>{n(a.matches)};return n(i.matches),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}function K3(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t.endsWith(".clinic1.com")||t.endsWith(".onuptick.com")||t.endsWith(".gorgias.com")||t==="app.canibuild.com"||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const X3=K3();function RW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;AW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(H7);const a=[r];if(X3){const s=new CSSStyleSheet;s.replaceSync(z7),a.push(s);const l=new CSSStyleSheet;l.replaceSync(q7),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(F7),a.push(s)}n.adoptedStyleSheets=a;const o=U7.createRoot(i);X3?o.render(f.jsx(xW,{sdk:t,shadowHost:e})):o.render(f.jsx(W7,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function AW(){$3("https://fonts.cdnfonts.com/css/satoshi"),$3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const J3="49206C6F7665204F6269_session",Q3="obi-url-params",oy="obi-client-heartbeat",NW=5e3,Z3=4e4,eR=15e3;function OW(){return K3()?"meet":"sdk"}function MW(){if(typeof window>"u")return!1;const t=navigator.userAgent||"",n=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|tablet/i.test(t.toLowerCase()),i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches;return n||i}class DW extends Dp{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=OW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=Rh.deserialise(r,e,i,{apiBaseUrl:"https://app.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new Rh(e,i,{apiBaseUrl:"https://app.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,v,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(v=this.client)==null?void 0:v.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&xs(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{la().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&la().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){const n=MW()?"mobile":"desktop";await this.client.startSession(this.client.selectedPlanUuid||null,i=>{i.on("stateChanged",r=>{r!=="disconnecting"&&r!=="disconnected"&&r!=="error"&&r!=="connecting"&&this.save()}),i.on("paused",()=>{this.save()}),i.on("unpaused",()=>{this.save()})},{...e,environment:n})}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(Q3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[J3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(J3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(Q3),this.passivePlanUuid=n}mountWidget(){RW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await MO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await CR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await uO(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>Z3,reason:s>Z3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>eR,reason:o>eR?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(oy);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{la().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},NW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(oy,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(oy)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function tR(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return PW({appToken:t,window:n,init:e})}async function PW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new DW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function nR(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{tR(void 0,nR)}):tR(void 0,nR)})();
@@ -131,4 +131,4 @@ ${t}</tr>
131
131
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
132
132
  `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${Ra(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let i=this.parser.parseInline(n),r=_3(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+Ra(e)+'"'),a+=">"+i+"</a>",a}image({href:t,title:e,text:n,tokens:i}){i&&(n=this.parser.parseInline(i,this.parser.textRenderer));let r=_3(t);if(r===null)return Ra(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${Ra(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:Ra(t.text)}},Zb=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Sr=class cy{constructor(e){bt(this,"options"),bt(this,"renderer"),bt(this,"textRenderer"),this.options=e||Ss,this.options.renderer=this.options.renderer||new Sp,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Zb}static parse(e,n){return new cy(n).parse(e)}static parseInline(e,n){return new cy(n).parseInline(e)}parse(e){var i,r;let n="";for(let a=0;a<e.length;a++){let o=e[a];if((r=(i=this.options.extensions)==null?void 0:i.renderers)!=null&&r[o.type]){let l=o,c=this.options.extensions.renderers[l.type].call({parser:this},l);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){n+=c||"";continue}}let s=o;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let l='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return n}parseInline(e,n=this.renderer){var r,a;let i="";for(let o=0;o<e.length;o++){let s=e[o];if((a=(r=this.options.extensions)==null?void 0:r.renderers)!=null&&a[s.type]){let c=this.options.extensions.renderers[s.type].call({parser:this},s);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){i+=c||"";continue}}let l=s;switch(l.type){case"escape":{i+=n.text(l);break}case"html":{i+=n.html(l);break}case"link":{i+=n.link(l);break}case"image":{i+=n.image(l);break}case"checkbox":{i+=n.checkbox(l);break}case"strong":{i+=n.strong(l);break}case"em":{i+=n.em(l);break}case"codespan":{i+=n.codespan(l);break}case"br":{i+=n.br(l);break}case"del":{i+=n.del(l);break}case"text":{i+=n.text(l);break}default:{let c='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return i}},kp,Hu=(kp=class{constructor(t){bt(this,"options"),bt(this,"block"),this.options=t||Ss}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?xr.lex:xr.lexInline}provideParser(){return this.block?Sr.parse:Sr.parseInline}},bt(kp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),bt(kp,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),kp),oF=class{constructor(...t){bt(this,"defaults",Vb()),bt(this,"options",this.setOptions),bt(this,"parse",this.parseMarkdown(!0)),bt(this,"parseInline",this.parseMarkdown(!1)),bt(this,"Parser",Sr),bt(this,"Renderer",Sp),bt(this,"TextRenderer",Zb),bt(this,"Lexer",xr),bt(this,"Tokenizer",xp),bt(this,"Hooks",Hu),this.use(...t)}walkTokens(t,e){var i,r;let n=[];for(let a of t)switch(n=n.concat(e.call(this,a)),a.type){case"table":{let o=a;for(let s of o.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of o.rows)for(let l of s)n=n.concat(this.walkTokens(l.tokens,e));break}case"list":{let o=a;n=n.concat(this.walkTokens(o.items,e));break}default:{let o=a;(r=(i=this.defaults.extensions)==null?void 0:i.childTokens)!=null&&r[o.type]?this.defaults.extensions.childTokens[o.type].forEach(s=>{let l=o[s].flat(1/0);n=n.concat(this.walkTokens(l,e))}):o.tokens&&(n=n.concat(this.walkTokens(o.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(n=>{let i={...n};if(i.async=this.defaults.async||i.async||!1,n.extensions&&(n.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let a=e.renderers[r.name];a?e.renderers[r.name]=function(...o){let s=r.renderer.apply(this,o);return s===!1&&(s=a.apply(this,o)),s}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[r.level];a?a.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),i.extensions=e),n.renderer){let r=this.defaults.renderer||new Sp(this.defaults);for(let a in n.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let o=a,s=n.renderer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u||""}}i.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new xp(this.defaults);for(let a in n.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let o=a,s=n.tokenizer[o],l=r[o];r[o]=(...c)=>{let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Hu;for(let a in n.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let o=a,s=n.hooks[o],l=r[o];Hu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&Hu.passThroughHooksRespectAsync.has(a))return(async()=>{let d=await s.call(r,c);return l.call(r,d)})();let u=s.call(r,c);return l.call(r,u)}:r[o]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await s.apply(r,c);return d===!1&&(d=await l.apply(r,c)),d})();let u=s.apply(r,c);return u===!1&&(u=l.apply(r,c)),u}}i.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,a=n.walkTokens;i.walkTokens=function(o){let s=[];return s.push(a.call(this,o)),r&&(s=s.concat(r.call(this,o))),s}}this.defaults={...this.defaults,...i}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return xr.lex(t,e??this.defaults)}parser(t,e){return Sr.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let i={...n},r={...this.defaults,...i},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return a(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let o=r.hooks?await r.hooks.preprocess(e):e,s=await(r.hooks?await r.hooks.provideLexer():t?xr.lex:xr.lexInline)(o,r),l=r.hooks?await r.hooks.processAllTokens(s):s;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser():t?Sr.parse:Sr.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(a);try{r.hooks&&(e=r.hooks.preprocess(e));let o=(r.hooks?r.hooks.provideLexer():t?xr.lex:xr.lexInline)(e,r);r.hooks&&(o=r.hooks.processAllTokens(o)),r.walkTokens&&this.walkTokens(o,r.walkTokens);let s=(r.hooks?r.hooks.provideParser():t?Sr.parse:Sr.parseInline)(o,r);return r.hooks&&(s=r.hooks.postprocess(s)),s}catch(o){return a(o)}}}onError(t,e){return n=>{if(n.message+=`
133
133
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+Ra(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},ks=new oF;function ot(t,e){return ks.parse(t,e)}ot.options=ot.setOptions=function(t){return ks.setOptions(t),ot.defaults=ks.defaults,o3(ot.defaults),ot},ot.getDefaults=Vb,ot.defaults=Ss,ot.use=function(...t){return ks.use(...t),ot.defaults=ks.defaults,o3(ot.defaults),ot},ot.walkTokens=function(t,e){return ks.walkTokens(t,e)},ot.parseInline=ks.parseInline,ot.Parser=Sr,ot.parser=Sr.parse,ot.Renderer=Sp,ot.TextRenderer=Zb,ot.Lexer=xr,ot.lexer=xr.lex,ot.Tokenizer=xp,ot.Hooks=Hu,ot.parse=ot,ot.options,ot.setOptions,ot.use,ot.walkTokens,ot.parseInline,Sr.parse,xr.lex;const sF="_base_1ne03_1",lF={base:sF},cF=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],uF=["href","title","target","rel"];ot.setOptions({breaks:!0,gfm:!0});function dF(t){const{content:e,className:n,...i}=t,r=T.useMemo(()=>{if(!e)return"";const a=ot.parse(e,{async:!1});return kz.sanitize(a,{ALLOWED_TAGS:[...cF],ALLOWED_ATTR:[...uF],ALLOW_DATA_ATTR:!1})},[e]);return r?f.jsx("div",{className:oe(lF.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const hF="_controlBar_7jslb_1",fF="_popoverAnchor_7jslb_11",pF="_controlBarSlot_7jslb_15",mF="_confirmationPopover_7jslb_21",gF="_confirmationPopoverAlignRight_7jslb_36",vF="_confirmationPopoverAlignCenter_7jslb_39",bF="_confirmationMessage_7jslb_59",yF="_confirmationActions_7jslb_66",_F="_confirmationButton_7jslb_71",xF="_confirmationButtonCancel_7jslb_89",SF="_confirmationButtonNeutral_7jslb_97",kF="_confirmationButtonDanger_7jslb_105",TF="_controlButton_7jslb_114",wF="_controlButtonIconOnly_7jslb_136",CF="_controlButtonDisabled_7jslb_141",EF="_controlButtonDanger_7jslb_168",RF="_controlButtonContent_7jslb_184",AF="_controlButtonIcon_7jslb_136",NF="_controlButtonLabel_7jslb_200",OF="_controlButtonChevron_7jslb_207",MF="_controlButtonNotificationDot_7jslb_216",DF="_deviceSplitButton_7jslb_228",PF="_deviceSplitButtonEnabled_7jslb_232",LF="_dualButtonContent_7jslb_313",IF="_dualButtonIcon_7jslb_323",jF="_dualButtonLabel_7jslb_332",BF="_screenShareButton_7jslb_346",UF="_screenShareButtonCompact_7jslb_357",Fe={controlBar:hF,popoverAnchor:fF,controlBarSlot:pF,confirmationPopover:mF,confirmationPopoverAlignRight:gF,confirmationPopoverAlignCenter:vF,confirmationMessage:bF,confirmationActions:yF,confirmationButton:_F,confirmationButtonCancel:xF,confirmationButtonNeutral:SF,confirmationButtonDanger:kF,controlButton:TF,controlButtonIconOnly:wF,controlButtonDisabled:CF,controlButtonDanger:EF,controlButtonContent:RF,controlButtonIcon:AF,controlButtonLabel:NF,controlButtonChevron:OF,controlButtonNotificationDot:MF,deviceSplitButton:DF,deviceSplitButtonEnabled:PF,dualButtonContent:LF,dualButtonIcon:IF,dualButtonLabel:jF,screenShareButton:BF,screenShareButtonCompact:UF},zF="_inline_1gpyx_1",FF="_vertical_1gpyx_6",qF="_divider_1gpyx_10",HF="_dividerVertical_1gpyx_16",VF="_customDivider_1gpyx_21",Vu={inline:zF,vertical:FF,divider:qF,dividerVertical:HF,customDivider:VF},k3={none:"0px",xxs:"var(--space-xxs)",xs:"var(--space-xs)",sm:"var(--space-sm)",md:"var(--space-md)",lg:"var(--space-lg)",xl:"var(--space-xl)","2xl":"var(--space-2xl)","3xl":"var(--space-3xl)","4xl":"var(--space-4xl)","5xl":"var(--space-5xl)"};function kr(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in k3)return k3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function GF(t,e){const{as:n,direction:i="horizontal",gap:r,align:a="center",justify:o,wrap:s=!1,divider:l,className:c,style:u,children:d,...h}=t,p=n??"div",v={display:"flex",flexDirection:i==="horizontal"?"row":"column",flexWrap:s?"wrap":"nowrap",alignItems:a,...o?{justifyContent:o}:{},...u};if(r!==void 0){const y=kr(r);y&&(v.gap=y)}const m=fi.Children.toArray(d).filter(y=>y!=null&&typeof y!="boolean"),S=y=>!l||y===0?null:l===!0||l==="line"?f.jsx("span",{"aria-hidden":"true",className:oe(Vu.divider,i==="vertical"&&Vu.dividerVertical)},`inline-divider-${y}`):f.jsx("span",{"aria-hidden":"true",className:Vu.customDivider,children:l},`inline-divider-${y}`),g=[];return m.forEach((y,x)=>{if(x>0){const b=S(x);b&&g.push(b)}g.push(y)}),f.jsx(p,{ref:e,className:oe(Vu.inline,i==="vertical"&&Vu.vertical,c),style:v,...h,children:g})}const Tp=fi.forwardRef(GF);Tp.displayName="Inline";function WF(){const[t,e]=T.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return T.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;const n=window.matchMedia("(max-width: 767px)"),i=()=>{e(n.matches)};return i(),typeof n.addEventListener=="function"?(n.addEventListener("change",i),()=>n.removeEventListener("change",i)):(n.addListener(i),()=>n.removeListener(i))},[]),t}function wp(t){const{icon:e,label:n,showChevron:i=!1,variant:r="default",disabled:a,className:o="",size:s="md",iconOnly:l=!1,showNotificationDot:c=!1,isOn:u,"aria-label":d,...h}=t,p=oe(Fe.controlButton,a&&Fe.controlButtonDisabled,l&&Fe.controlButtonIconOnly,r==="danger"&&Fe.controlButtonDanger,o),v=Number.parseInt(Nb[s],10),m=r==="danger"?"outline":"primary",S=r==="danger"?"danger":"default",g=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:Fe.controlButtonContent,children:[e?f.jsx("span",{className:Fe.controlButtonIcon,children:fi.isValidElement(e)&&e.props.size===void 0?fi.cloneElement(e,{size:v}):e}):null,l?null:f.jsx("span",{className:Fe.controlButtonLabel,children:n}),l||!i?null:f.jsx("span",{className:Fe.controlButtonChevron,"aria-hidden":"true",children:f.jsx(Ob,{size:16})})]}),c?f.jsx("span",{className:Fe.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?f.jsx(hp,{...h,type:"button",disabled:a,variant:m,color:S,isOn:u,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g}):f.jsx(Ro,{...h,type:"button",disabled:a,variant:m,color:S,"aria-label":d||n,className:p,"data-has-notification":c?"true":void 0,children:g})}function YF(t){const{audioDevices:e,currentMicrophoneId:n,isMicrophoneEnabled:i,isScreenShareActive:r,widgetState:a,canPublishData:o,browserSupportsScreenSharing:s,screenShareButtonVariant:l="default",microphoneButtonVariant:c="split",onMicDeviceSelect:u,onMicToggle:d,onChatToggle:h,onLeave:p,onScreenShareToggle:v,showChatNotification:m=!1,isLanguageSelectorEnabled:S=!0,languages:g=[],selectedLanguage:y=null,defaultLanguageCode:x=null,isMultilingual:b=!1,onLanguageChange:k,isChatOpen:w=a==="chat",leadingControl:C,trailingControl:R}=t,A=g.length,N=!S||A===0,O=WF(),B=O?"xs":"sm",X=O,[L,Y]=T.useState(!1),[P,V]=T.useState(!1),K=T.useRef(null),ee=T.useRef(null);T.useEffect(()=>{const Ye=me=>{const Ne=me.composedPath();L&&K.current&&!Ne.includes(K.current)&&Y(!1),P&&ee.current&&!Ne.includes(ee.current)&&V(!1)},Lt=me=>{me.key==="Escape"&&(L&&Y(!1),P&&V(!1))};if(L||P)return document.addEventListener("mousedown",Ye),document.addEventListener("keydown",Lt),()=>{document.removeEventListener("mousedown",Ye),document.removeEventListener("keydown",Lt)}},[L,P]),T.useEffect(()=>{r||Y(!1)},[r]);const $=T.useMemo(()=>e.map(Ye=>({label:Ye.label||`Microphone ${Ye.deviceId.slice(0,8)}`,value:Ye.deviceId})),[e]),U=T.useMemo(()=>n?$.find(Ye=>Ye.value===n)??null:null,[n,$]),Z=T.useCallback(Ye=>{Ye.value,u(Ye.value)},[u]),Q={microphone:!0,screenShare:s,chat:o},le=T.useCallback(()=>{if(r){Y(!0);return}v()},[r,v]),j=T.useCallback(()=>{Y(!1),v()},[v]),ge=T.useCallback(()=>{Y(!1)},[]),H=T.useCallback(()=>{V(!0)},[]),he=T.useCallback(()=>{V(!1),p()},[p]),ve=T.useCallback(()=>{V(!1)},[]);return f.jsx("div",{className:Fe.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify(Q),"data-language-option-count":A>0?String(A):void 0,"data-default-language-code":x??void 0,children:f.jsxs(Tp,{gap:B,align:"center",justify:"center",wrap:X,children:[C?f.jsx("div",{className:Fe.controlBarSlot,children:C}):null,c==="simple"?f.jsx(wp,{icon:i?f.jsx(up,{}):f.jsx(dp,{}),label:"Microphone",onClick:d,isOn:i,"aria-label":i?"Mute microphone":"Unmute microphone"}):f.jsx(MU,{onClick:d,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:$,value:U,onChange:Z,variant:"primary",menuPlacement:"top",menuDisabled:$.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:oe(Fe.deviceSplitButton,i&&Fe.deviceSplitButtonEnabled),children:f.jsxs("span",{className:Fe.dualButtonContent,children:[f.jsx("span",{className:Fe.dualButtonIcon,children:i?f.jsx(up,{}):f.jsx(dp,{})}),f.jsx("span",{className:Fe.dualButtonLabel,children:"Microphone"})]})}),o?f.jsx(wp,{icon:f.jsx(OE,{}),label:"Chat",onClick:h,isOn:w,"aria-label":"Toggle chat",showNotificationDot:m}):null,s?f.jsxs("div",{ref:K,className:Fe.popoverAnchor,children:[f.jsx(wp,{icon:f.jsx(LE,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?Fe.screenShareButtonCompact:Fe.screenShareButton,iconOnly:l==="compact",onClick:le,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),L?f.jsxs("div",{className:oe(Fe.confirmationPopover,Fe.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[f.jsx("p",{className:Fe.confirmationMessage,children:"Stop screen sharing?"}),f.jsxs("div",{className:Fe.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonCancel),onClick:ge,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonNeutral),onClick:j,children:"Stop"})]})]}):null]}):null,f.jsx(VE,{languages:g,value:y,onChange:k,defaultLanguageCode:x,variant:"control-bar",disabled:N}),f.jsxs("div",{ref:ee,className:Fe.popoverAnchor,children:[f.jsx(wp,{icon:f.jsx(Mb,{}),label:"Leave",variant:"danger",onClick:H,"aria-label":"Leave meeting"}),P?f.jsxs("div",{className:oe(Fe.confirmationPopover,Fe.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:Fe.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:Fe.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonCancel),onClick:ve,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(Fe.confirmationButton,Fe.confirmationButtonDanger),onClick:he,children:"Leave"})]})]}):null]}),R?f.jsx("div",{className:Fe.controlBarSlot,children:R}):null]})})}function T3(t){return f.jsx(YF,{...t})}const KF="_controlBar_1n8jn_1",XF="_controlButton_1n8jn_12",$F="_controlButtonDisabled_1n8jn_35",JF="_controlButtonDanger_1n8jn_62",QF="_controlButtonIconOnly_1n8jn_78",ZF="_screenShareButton_1n8jn_83",eq="_controlButtonContent_1n8jn_88",tq="_controlButtonIcon_1n8jn_78",nq="_controlButtonLabel_1n8jn_103",iq="_controlButtonNotificationDot_1n8jn_108",rq="_popoverAnchor_1n8jn_198",aq="_confirmationPopover_1n8jn_202",oq="_confirmationMessage_1n8jn_216",sq="_confirmationActions_1n8jn_223",lq="_confirmationButton_1n8jn_228",cq="_confirmationButtonCancel_1n8jn_246",uq="_confirmationButtonDanger_1n8jn_254",yt={controlBar:KF,controlButton:XF,controlButtonDisabled:$F,controlButtonDanger:JF,controlButtonIconOnly:QF,screenShareButton:ZF,controlButtonContent:eq,controlButtonIcon:tq,controlButtonLabel:nq,controlButtonNotificationDot:iq,popoverAnchor:rq,confirmationPopover:aq,confirmationMessage:oq,confirmationActions:sq,confirmationButton:lq,confirmationButtonCancel:cq,confirmationButtonDanger:uq};function Ts(t){const{icon:e,label:n,variant:i="default",disabled:r,className:a="",iconOnly:o=!1,showNotificationDot:s=!1,isOn:l,"aria-label":c,...u}=t,d=oe(yt.controlButton,r&&yt.controlButtonDisabled,o&&yt.controlButtonIconOnly,i==="danger"&&yt.controlButtonDanger,a),h=i==="danger"?"outline":"primary",p=i==="danger"?"danger":"default",v=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:yt.controlButtonContent,children:[e?f.jsx("span",{className:yt.controlButtonIcon,children:fi.isValidElement(e)&&e.props.size===void 0?fi.cloneElement(e,{size:20}):e}):null,o?null:f.jsx("span",{className:yt.controlButtonLabel,children:n})]}),s?f.jsx("span",{className:yt.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?f.jsx(hp,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs",isOn:l,"aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:v}):f.jsx(Ro,{...u,type:"button",disabled:r,variant:h,color:p,size:"xs","aria-label":c||n,className:d,"data-has-notification":s?"true":void 0,children:v})}function dq(t){const{isMicrophoneEnabled:e,isChatOpen:n,isScreenShareActive:i,showChatNotification:r=!1,onMicToggle:a,onChatToggle:o,onScreenShareToggle:s,onLeave:l,languages:c=[],selectedLanguage:u=null,defaultLanguageCode:d=null,isMultilingual:h=!1,onLanguageChange:p,isLanguageSelectorEnabled:v=!0,className:m,testId:S,...g}=t,y=!v||c.length===0,[x,b]=T.useState(!1),k=T.useRef(null);T.useEffect(()=>{const O=X=>{const L=X.composedPath();x&&k.current&&!L.includes(k.current)&&b(!1)},B=X=>{X.key==="Escape"&&x&&b(!1)};if(x)return document.addEventListener("mousedown",O),document.addEventListener("keydown",B),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",B)}},[x]);const w=T.useCallback(()=>{a()},[a]),C=T.useCallback(()=>{s()},[s]),R=T.useCallback(()=>{b(!0)},[]),A=T.useCallback(()=>{b(!1),l()},[l]),N=T.useCallback(()=>{b(!1)},[]);return f.jsx("div",{...g,className:oe(yt.controlBar,m),"data-testid":S,children:f.jsxs(Tp,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(Ts,{icon:e?f.jsx(up,{size:18}):f.jsx(dp,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:w,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(Ts,{icon:f.jsx(OE,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),f.jsx(Ts,{icon:f.jsx(LE,{}),label:"Screen share",iconOnly:!0,className:yt.screenShareButton,isOn:i,onClick:C,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),f.jsx(VE,{languages:c,value:u,onChange:p,defaultLanguageCode:d,variant:"pip",disabled:y}),f.jsxs("div",{ref:k,className:yt.popoverAnchor,children:[f.jsx(Ts,{icon:f.jsx(Mb,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:R,"aria-label":"Hang up"}),x?f.jsxs("div",{className:yt.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:yt.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:yt.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonCancel),onClick:N,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonDanger),onClick:A,children:"Leave"})]})]}):null]})]})})}function hq(t){return f.jsx(dq,{...t})}const fq="_container_nz2la_1",pq={container:fq},mq="_responsive_14d0j_2",Gu={responsive:mq,"showAboveWidth-sm":"_showAboveWidth-sm_14d0j_15","showAboveWidth-md":"_showAboveWidth-md_14d0j_24","showAboveWidth-lg":"_showAboveWidth-lg_14d0j_33","showAboveWidth-xl":"_showAboveWidth-xl_14d0j_42","hideAboveWidth-sm":"_hideAboveWidth-sm_14d0j_53","hideAboveWidth-md":"_hideAboveWidth-md_14d0j_59","hideAboveWidth-lg":"_hideAboveWidth-lg_14d0j_65","hideAboveWidth-xl":"_hideAboveWidth-xl_14d0j_71","showAboveHeight-short":"_showAboveHeight-short_14d0j_84","showAboveHeight-medium":"_showAboveHeight-medium_14d0j_93","hideAboveHeight-short":"_hideAboveHeight-short_14d0j_104","hideAboveHeight-medium":"_hideAboveHeight-medium_14d0j_110"};function w3(t){const{as:e,children:n,showAboveWidth:i,hideAboveWidth:r,showAboveHeight:a,hideAboveHeight:o,className:s,...l}=t,c=[Gu.responsive];return i&&c.push(Gu[`showAboveWidth-${i}`]),r&&c.push(Gu[`hideAboveWidth-${r}`]),a&&c.push(Gu[`showAboveHeight-${a}`]),o&&c.push(Gu[`hideAboveHeight-${o}`]),f.jsx(e??"div",{...l,className:oe(c,s),children:n})}function gq(t){const{isMicrophoneEnabled:e,onMicToggle:n,onLeave:i,onReturnToCourseOutline:r,zIndex:a=1e3,className:o,testId:s}=t,[l,c]=T.useState(!1),u=T.useRef(null);T.useEffect(()=>{const g=x=>{const b=x.composedPath();l&&u.current&&!b.includes(u.current)&&c(!1)},y=x=>{x.key==="Escape"&&l&&c(!1)};if(l)return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[l]);const d=T.useCallback(()=>{n()},[n]),h=T.useCallback(()=>{r()},[r]),p=T.useCallback(()=>{c(!0)},[]),v=T.useCallback(()=>{c(!1),i()},[i]),m=T.useCallback(()=>{c(!1)},[]),S=T.useMemo(()=>({position:"fixed",left:"50%",transform:"translateX(-50%)",bottom:"calc(var(--space-md, 16px) + env(safe-area-inset-bottom))",zIndex:a,width:"100%",maxWidth:"520px",paddingInline:"var(--space-sm, 8px)",boxSizing:"border-box",display:"flex",justifyContent:"center"}),[a]);return f.jsx(w3,{hideAboveWidth:"md",className:o,style:S,"data-testid":s,children:f.jsx("div",{className:pq.container,children:f.jsx("div",{className:oe(yt.controlBar),children:f.jsxs(Tp,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(Ts,{icon:e?f.jsx(up,{size:18}):f.jsx(dp,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:d,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(Ts,{icon:f.jsx(jE,{size:18}),label:"Return to course outline",iconOnly:!0,onClick:h,"aria-label":"Return to course outline"}),f.jsxs("div",{ref:u,className:yt.popoverAnchor,children:[f.jsx(Ts,{icon:f.jsx(Mb,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:p,"aria-label":"Hang up"}),l?f.jsxs("div",{className:yt.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:yt.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:yt.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonCancel),onClick:m,children:"Cancel"}),f.jsx("button",{type:"button",className:oe(yt.confirmationButton,yt.confirmationButtonDanger),onClick:v,children:"Leave"})]})]}):null]})]})})})})}const vq="_container_zht0b_1",bq="_containerGradient_zht0b_14",yq="_containerFlat_zht0b_24",_q="_halo_zht0b_28",xq="_outerRing_zht0b_38",Sq="_circle_zht0b_42",kq="_image_zht0b_72",Tq="_captionContainer_zht0b_88",wq="_captionRegion_zht0b_99",Aa={container:vq,containerGradient:bq,containerFlat:yq,halo:_q,outerRing:xq,circle:Sq,image:kq,captionContainer:Tq,captionRegion:wq},Cq="_statusText_1dkze_6",Eq={statusText:Cq},Rq={idle:null,thinking:"Thinking...",searching:"Searching..."};function Aq(t){const{status:e,size:n="md"}=t,i=e?Rq[e]:null,r=i!==null;return f.jsx("div",{className:Eq.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const Nq="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",Oq={sm:{haloSize:"4.5rem",maxBorderWidth:5,outerRingScalePower:.55,glowSize:"20px"},md:{haloSize:"8rem",maxBorderWidth:8,outerRingScalePower:.7,glowSize:"35px"},lg:{haloSize:"10rem",maxBorderWidth:10,outerRingScalePower:.75,glowSize:"42px"}};function C3(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=Nq,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=Oq[n],p=Math.min(1,Math.max(0,e)),v=p>.01,m=v?Math.min(1,p/.5):0,S=v?Math.max(1,m*h.maxBorderWidth):0,g=1.02,y=v?g+p*h.outerRingScalePower:g,x=v?.2+p*.35:0,b={...u??{},...a?{"--avatar-fallback-accent":a}:{}},k={"--avatar-fallback-halo-size":h.haloSize,"--avatar-fallback-border-width":`${S}px`,"--avatar-fallback-secondary-border-scale":y.toString(),"--avatar-fallback-secondary-border-opacity":x.toString(),"--avatar-fallback-glow-size":h.glowSize},w=l!=null&&l!=="";return f.jsxs("div",{...d,className:oe(Aa.container,i==="gradient"?Aa.containerGradient:Aa.containerFlat,c),style:b,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[f.jsxs("div",{className:Aa.halo,style:k,children:[f.jsx("div",{className:Aa.outerRing,"aria-hidden":"true"}),f.jsx("div",{className:Aa.circle,children:f.jsx("img",{className:Aa.image,src:r,alt:"","aria-hidden":"true"})}),f.jsx(Aq,{status:s,size:n})]}),w&&f.jsx("div",{className:Aa.captionContainer,children:f.jsx("div",{className:Aa.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const Mq="_container_1k3qg_11",Dq="_screenshot_1k3qg_20",Pq="_flash_1k3qg_30",ey={container:Mq,screenshot:Dq,flash:Pq};function Lq(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=T.useState(!1),s=T.useRef(null),l=T.useRef(i);return T.useEffect(()=>{l.current=i},[i]),T.useEffect(()=>{if(!e){o(!1),s.current&&(clearTimeout(s.current),s.current=null);return}if(!s.current)return o(!0),s.current=setTimeout(()=>{var c;o(!1),s.current=null,(c=l.current)==null||c.call(l)},r),()=>{s.current&&(clearTimeout(s.current),s.current=null)}},[e,r]),a?f.jsxs("div",{className:ey.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&f.jsx("img",{src:n,alt:"Captured screenshot",className:ey.screenshot}),f.jsx("div",{className:ey.flash})]}):null}const Iq="_container_13ukq_1",jq="_dragging_13ukq_5",Bq="_placeholder_13ukq_9",Uq="_handleButton_13ukq_15",zq="_customHandle_13ukq_105",Vl={container:Iq,dragging:jq,placeholder:Bq,handleButton:Uq,"handle-top":"_handle-top_13ukq_65","handle-bottom":"_handle-bottom_13ukq_75","handle-left":"_handle-left_13ukq_85","handle-right":"_handle-right_13ukq_95",customHandle:zq};function Fq(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=T.useState(!1),o=T.useRef(null),s=T.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=T.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=T.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return T.useEffect(()=>{i&&l()},[i,l]),T.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function qq(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=T.useRef(null),[a,o]=T.useState(!!e),[s,l]=T.useState(!1),[c,u]=T.useState(null),[d,h]=T.useState(()=>e??{x:0,y:0}),p=T.useRef(d);s||(p.current=d);const v=T.useRef(null),m=T.useRef(!1),S=T.useRef(!1);T.useEffect(()=>{e&&(S.current||(o(!0),h(e),p.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),T.useEffect(()=>{if(e||m.current)return;const b=r.current;if(!b)return;const k=b.getBoundingClientRect(),w={x:k.left,y:k.top};m.current=!0,o(!0),h(w),p.current=w,u(n?{width:k.width,height:k.height}:null)},[e,n]);const g=T.useCallback(b=>{const k=v.current;if(!(!k||b.pointerId!==k.pointerId)){v.current=null,S.current=!0,h(p.current),l(!1);try{b.currentTarget.releasePointerCapture(k.pointerId)}catch{}}},[]),y=T.useCallback(b=>{b.button===0&&(b.preventDefault(),b.currentTarget.setPointerCapture(b.pointerId),v.current={pointerId:b.pointerId,startClientX:b.clientX,startClientY:b.clientY,startX:p.current.x,startY:p.current.y},l(!0))},[]),x=T.useCallback(b=>{const k=v.current;if(!k||b.pointerId!==k.pointerId)return;const w={x:k.startX+(b.clientX-k.startClientX),y:k.startY+(b.clientY-k.startClientY)};p.current=w,r.current&&(r.current.style.transform=`translate3d(${w.x}px, ${w.y}px, 0)`),i==null||i(w)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:y,onPointerMove:x,endDrag:g}}function Hq(t){const{children:e,className:n,handle:i="top",initialPosition:r,disabled:a=!1,preserveSpace:o=!0,zIndex:s=1e3,onPositionChange:l,handleAriaLabel:c="Drag",handleLingerMs:u=350,style:d,...h}=t,{containerRef:p,isFixed:v,isDragging:m,position:S,placeholderSize:g,onPointerDown:y,onPointerMove:x,endDrag:b}=qq({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:k,showHandle:w,scheduleHideHandle:C}=Fq({disabled:a,lingerMs:u,isDragging:m}),R=typeof e=="function",A=T.useMemo(()=>{const O=B=>f.jsx("div",{className:oe(Vl.customHandle,B.className),onPointerDown:y,onPointerMove:x,onPointerUp:b,onPointerCancel:b,children:B.children});return O.displayName="Draggable.Handle",O},[y,x,b]),N={...d,position:v?"fixed":"relative",top:v?0:d==null?void 0:d.top,left:v?0:d==null?void 0:d.left,transform:v?`translate3d(${S.x}px, ${S.y}px, 0)`:d==null?void 0:d.transform,zIndex:v?s:d==null?void 0:d.zIndex};return f.jsxs(f.Fragment,{children:[o&&v&&g?f.jsx("div",{className:Vl.placeholder,style:{width:g.width,height:g.height}}):null,f.jsxs("div",{ref:p,className:oe(Vl.container,m?Vl.dragging:null,n),"data-handle-visible":R?void 0:a?"false":k||m?"true":"false",style:N,onMouseEnter:R?void 0:w,onMouseLeave:R?void 0:C,...h,children:[!R&&!a?f.jsx("button",{type:"button",className:oe(Vl.handleButton,Vl[`handle-${i}`]),"aria-label":c,onMouseEnter:w,onMouseLeave:C,onPointerDown:O=>{w(),y(O)},onPointerMove:x,onPointerUp:b,onPointerCancel:b}):null,R?e({Handle:A}):e]})]})}const Vq="_container_gzwdo_1",Gq="_captionRegion_gzwdo_14",Wq="_status_gzwdo_22",Yq="_captionText_gzwdo_29",Cp={container:Vq,captionRegion:Gq,status:Wq,captionText:Yq},Kq={idle:null,thinking:"Thinking...",searching:"Searching..."};function Xq(t){const{text:e,status:n,className:i,...r}=t,a=n?Kq[n]:null;return f.jsx("div",{...r,className:oe(Cp.container,i),"data-testid":"pip-captions-panel",children:f.jsxs("div",{className:Cp.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?f.jsx("div",{className:Cp.status,children:a}):null,f.jsx("div",{className:Cp.captionText,children:e})]})})}const $q="_panel_1laxg_1",Jq="_row_1laxg_22",Qq="_stepContent_1laxg_29",Zq="_stepLabel_1laxg_37",eH="_currentStep_1laxg_44",tH="_nextStep_1laxg_51",nH="_skipButtonContainer_1laxg_65",iH="_circleButton_1laxg_73",rH="_arrowPlaceholder_1laxg_100",aH="_skipButton_1laxg_65",ir={panel:$q,row:Jq,stepContent:Qq,stepLabel:Zq,currentStep:eH,nextStep:tH,skipButtonContainer:nH,circleButton:iH,arrowPlaceholder:rH,skipButton:aH},oH="_truncatedText_1u580_1",sH={truncatedText:oH};function E3(t){const{children:e,maxLines:n=2,className:i,"data-testid":r}=t;return f.jsx("div",{className:`${sH.truncatedText} ${i||""}`,style:{WebkitLineClamp:n},"data-testid":r,children:e})}function lH(t,e,n){var c;const i=t.length,r=n&&i>0&&((c=t[i-1])==null?void 0:c.title)==="Conclusion",a=r?t.slice(0,-1):t.slice(),o=a.length;if(o===0)return{visibleSteps:a,currentIndex:null};const s=typeof e=="number"&&Number.isFinite(e)?e:1;if(r&&s===i)return{visibleSteps:a,currentIndex:null};const l=Math.min(Math.max(s,1),o)-1;return{visibleSteps:a,currentIndex:l}}function ty(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function cH(t){var A;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=T.useMemo(()=>lH(e,n,r),[n,r,e]),[u,d]=T.useState(()=>ty(n,l.length)),h=T.useRef(!1);T.useEffect(()=>{if(!h.current)d(ty(n,l.length));else{const N=ty(n,l.length);u===N&&(h.current=!1)}},[n,l,u]);const p=l.length,v=l[u],m=u>0,S=u<p-1,g=S?(A=l[u+1])==null?void 0:A.title:void 0,y=p>0,x=y?u+1:0,b=y?`Step ${x}/${p}`:"No steps available",k=c!==null&&v&&u!==c,w=()=>{m&&(h.current=!0,d(N=>Math.max(N-1,0)))},C=()=>{S&&(h.current=!0,d(N=>Math.min(N+1,p-1)))},R=()=>{!k||!v||!i||(h.current=!1,i(u,v))};return f.jsxs("div",{...s,className:oe(ir.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[f.jsxs("div",{className:ir.row,children:[m?f.jsx("button",{type:"button",className:ir.circleButton,"aria-label":"Previous step",onClick:w,children:f.jsx(ME,{size:14})}):f.jsx("span",{className:ir.arrowPlaceholder,"aria-hidden":"true"}),f.jsxs("div",{className:ir.stepContent,children:[f.jsx(Si,{className:ir.stepLabel,"aria-live":"polite",children:b}),f.jsx(E3,{maxLines:2,children:f.jsx(Si,{className:ir.currentStep,"data-testid":"pip-outline-current-step",children:(v==null?void 0:v.title)??"No steps available"})}),g?f.jsx(E3,{maxLines:2,children:f.jsxs(Si,{variant:"muted",className:ir.nextStep,children:["Next: ",g]})}):null]}),S?f.jsx("button",{type:"button",className:ir.circleButton,"aria-label":"Next step",onClick:C,children:f.jsx(tB,{size:14})}):f.jsx("span",{className:ir.arrowPlaceholder,"aria-hidden":"true"})]}),k?f.jsx("div",{className:ir.skipButtonContainer,children:f.jsx("button",{type:"button",className:ir.skipButton,"aria-label":"Skip to this step",onClick:R,children:f.jsx(aB,{size:14})})}):null]})}const uH="_window_zm5au_1",dH="_exitButton_zm5au_14",hH="_content_zm5au_47",fH="_contentTopOverlay_zm5au_58",pH="_dragHandle_zm5au_68",mH="_contentBottomOverlay_zm5au_78",gH="_controls_zm5au_87",vH="_messagesPanelWrapper_zm5au_95",Ao={window:uH,exitButton:dH,content:hH,contentTopOverlay:fH,dragHandle:pH,contentBottomOverlay:mH,controls:gH,messagesPanelWrapper:vH};function bH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function yH(t){const{onExit:e,controlBarProps:n,isCourseOutlineSelected:i,onCourseOutlineToggle:r,isCaptionsEnabled:a=!1,onCaptionsToggle:o,courseOutline:s,messagesPanel:l,avatarFallbackProps:c,contentTopOverlaySlot:u,screenshotUrl:d,cameraShotTrigger:h,className:p,testId:v,...m}=t,S=i,g=n.isChatOpen&&!S&&l,y=c==null?void 0:c.captionsText,x=a&&bH(y),[b,k]=T.useState(!1),w=T.useRef(h),C=T.useCallback(()=>{k(!1)},[]);T.useEffect(()=>{h&&h>0&&h!==w.current&&k(!0),w.current=h},[h]);const R=T.useCallback(()=>f.jsx(C3,{audioPower:(c==null?void 0:c.audioPower)??0,size:"sm",background:"flat",imageSrc:c==null?void 0:c.imageSrc,ariaLabel:c==null?void 0:c.ariaLabel,status:c==null?void 0:c.status}),[c]),A=S?s?f.jsx(cH,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):R():g?f.jsx("div",{className:Ao.messagesPanelWrapper,children:l}):x?f.jsx(Xq,{text:y}):R();return f.jsxs("div",{...m,className:oe(Ao.window,p),"data-testid":v,role:"group","aria-label":"Picture-in-Picture",children:[f.jsxs("div",{className:Ao.content,children:[f.jsx("div",{className:Ao.contentTopOverlay,children:u}),f.jsx("button",{type:"button",className:Ao.exitButton,onClick:e,"aria-label":"Exit PiP",children:f.jsx(nB,{size:14})}),A,!g&&f.jsxs("div",{className:Ao.contentBottomOverlay,children:[f.jsx(hp,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:f.jsx(jE,{size:18})}),f.jsx(hp,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:f.jsx(eB,{size:18})})]}),f.jsx(Lq,{isActive:b,imageUrl:d??null,onComplete:C})]}),f.jsx("div",{className:Ao.controls,children:f.jsx(hq,{...n})})]})}function _H(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return f.jsx(Hq,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>f.jsx(yH,{...r,contentTopOverlaySlot:f.jsx(a,{className:Ao.dragHandle})})})}const xH="_root_ygi3o_1",SH="_overlay_ygi3o_7",kH="_caption_ygi3o_17",ny={root:xH,overlay:SH,caption:kH};function TH(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function wH(t){const{children:e,className:n,text:i}=t,r=TH(i);return f.jsxs("div",{className:oe(ny.root,n),children:[e,r?f.jsx("div",{className:ny.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:f.jsx("div",{className:ny.caption,children:i})}):null]})}const CH="_box_dc9yv_1",EH={box:CH},R3={none:"0px",panel:"var(--radius-panel)",card:"var(--radius-card)"},A3={surface:"var(--color-surface)",surfaceMuted:"var(--color-surface-muted)",surfaceAlt:"var(--color-surface-alt)",primarySoft:"var(--color-primary-soft)",primarySofter:"var(--color-primary-softer)",dangerSurface:"var(--color-danger-surface)"};function RH(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in R3)return R3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function AH(t){if(t!==void 0){if(t in A3)return A3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function NH(t,e){const{as:n,className:i,padding:r,paddingX:a,paddingY:o,paddingTop:s,paddingBottom:l,paddingLeft:c,paddingRight:u,paddingSm:d,paddingMd:h,paddingLg:p,paddingXl:v,margin:m,marginX:S,marginY:g,marginTop:y,marginBottom:x,marginLeft:b,marginRight:k,radius:w,radiusTop:C,radiusBottom:R,radiusLeft:A,radiusRight:N,radiusTopLeft:O,radiusTopRight:B,radiusBottomLeft:X,radiusBottomRight:L,background:Y,gap:P,style:V,...K}=t,ee=n??"div",$={...V},U=$,Z={},Q=(H,he)=>{if(he===void 0)return;const ve=kr(he);ve&&($[H]=ve)},le=(H,he)=>{if(he===void 0)return;const ve=kr(he);ve&&($[H]=ve)},j=(H,he)=>{if(he===void 0)return;const ve=RH(he);ve&&($[H]=ve)},ge={sm:d,md:h,lg:p,xl:v};if(r!==void 0){const H=kr(r);H&&(U["--box-padding"]=H)}for(const[H,he]of Object.entries(ge)){if(he===void 0)continue;const ve=kr(he);ve&&(U[`--box-padding-${H}`]=ve,Z[`data-padding-${H}`]="")}if(a!==void 0){const H=kr(a);H&&($.paddingLeft=H,$.paddingRight=H)}if(o!==void 0){const H=kr(o);H&&($.paddingTop=H,$.paddingBottom=H)}if(Q("paddingTop",s),Q("paddingBottom",l),Q("paddingLeft",c),Q("paddingRight",u),m!==void 0){const H=kr(m);H&&($.margin=H)}if(S!==void 0){const H=kr(S);H&&($.marginLeft=H,$.marginRight=H)}if(g!==void 0){const H=kr(g);H&&($.marginTop=H,$.marginBottom=H)}if(le("marginTop",y),le("marginBottom",x),le("marginLeft",b),le("marginRight",k),P!==void 0){const H=kr(P);H&&($.gap=H)}if(j("borderRadius",w),C!==void 0&&(j("borderTopLeftRadius",C),j("borderTopRightRadius",C)),R!==void 0&&(j("borderBottomLeftRadius",R),j("borderBottomRightRadius",R)),A!==void 0&&(j("borderTopLeftRadius",A),j("borderBottomLeftRadius",A)),N!==void 0&&(j("borderTopRightRadius",N),j("borderBottomRightRadius",N)),j("borderTopLeftRadius",O),j("borderTopRightRadius",B),j("borderBottomLeftRadius",X),j("borderBottomRightRadius",L),Y!==void 0){const H=AH(Y);H&&($.background=H)}return f.jsx(ee,{ref:e,className:oe(EH.box,i),style:$,...Z,...K})}const Ep=fi.forwardRef(NH);Ep.displayName="Box";const OH="_panel_eawk4_1",MH="_selected_eawk4_10",N3={panel:OH,selected:MH};function Wu(t){const{children:e,className:n,selected:i,...r}=t;return f.jsx("div",{className:oe(N3.panel,i?N3.selected:null,n),...r,children:e})}const DH="_root_yccm8_1",PH="_header_yccm8_8",LH="_icon_yccm8_15",IH="_text_yccm8_26",jH="_heading_yccm8_33",BH="_description_yccm8_41",UH="_body_yccm8_47",zH="_footer_yccm8_54",No={root:DH,header:PH,icon:LH,text:IH,heading:jH,description:BH,body:UH,footer:zH};function O3(t){const{className:e,...n}=t;return f.jsx("div",{className:oe(No.icon,e),...n})}function M3(t){const{className:e,...n}=t;return f.jsx("h3",{className:oe(No.heading,e),...n})}function D3(t){const{className:e,...n}=t;return f.jsx("p",{className:oe(No.description,e),...n})}function P3(t){const{className:e,...n}=t;return f.jsx("div",{className:oe(No.footer,e),...n})}function FH(t){const e=T.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(T.isValidElement(s)&&s.type===O3&&i===void 0){i=s;continue}if(T.isValidElement(s)&&s.type===M3&&r===void 0){r=s;continue}if(T.isValidElement(s)&&s.type===D3&&a===void 0){a=s;continue}if(T.isValidElement(s)&&s.type===P3&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function qH(t){const{children:e,className:n,...i}=t,r=FH(e),a=r.icon||r.heading||r.description;return f.jsxs(Wu,{className:oe(No.root,n),...i,children:[a?f.jsxs("div",{className:No.header,children:[r.icon,r.heading||r.description?f.jsxs("div",{className:No.text,children:[r.heading,r.description]}):null]}):null,r.body.length?f.jsx("div",{className:No.body,children:r.body}):null,r.footer]})}const iy=Object.assign(qH,{Icon:O3,Heading:M3,Description:D3,Footer:P3}),HH="_panel_f4a69_1",VH="_header_f4a69_10",GH="_title_f4a69_19",WH="_scrollArea_f4a69_29",YH="_scrollable_f4a69_34",KH="_list_f4a69_39",XH="_courseButton_f4a69_45",$H="_courseCard_f4a69_61",JH="_loading_f4a69_65",QH="_spinnerWrapper_f4a69_69",ZH="_spinner_f4a69_69",eV="_contentHidden_f4a69_92",tV="_courseHeading_f4a69_101",nV="_courseDescription_f4a69_107",iV="_empty_f4a69_116",zn={panel:HH,header:VH,title:GH,scrollArea:WH,scrollable:YH,list:KH,courseButton:XH,courseCard:$H,loading:JH,spinnerWrapper:QH,spinner:ZH,contentHidden:eV,courseHeading:tV,courseDescription:nV,empty:iV};function rV(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=T.useState(()=>i??[]),l=a?n:o,c=T.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=T.useCallback(d=>{const h=l.includes(d);if(e==="single"){c(h?[]:[d]);return}if(h){c(l.filter(p=>p!==d));return}c([...l,d])},[l,e,c]);return{selectedCourseIds:l,toggleCourseId:u}}function aV(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,loadingCourseId:l,emptyMessage:c="No courses available",testId:u,...d}=t;return f.jsxs(Wu,{...d,className:oe(zn.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsx("div",{className:zn.header,children:f.jsx(Si,{as:"h2",className:zn.title,children:e})}),f.jsx("div",{className:zn.scrollArea,children:f.jsx(ql,{className:zn.scrollable,children:r.length===0?f.jsx(Si,{variant:"muted",className:zn.empty,"data-testid":"course-panel-empty",children:c}):f.jsx("div",{className:zn.list,"data-testid":"course-panel-list",children:r.map(h=>{const p=o.includes(h.id),v=l!=null&&h.id===l,m=h.disabled===!0||l!=null,S=oe(zn.courseButton,v&&zn.loading);return f.jsxs("button",{type:"button",className:S,"aria-pressed":p,"aria-disabled":m,"aria-busy":v||void 0,disabled:m,onClick:()=>s==null?void 0:s(h.id,h),"data-testid":`course-panel-item-${h.id}`,children:[v?f.jsx("span",{className:zn.spinnerWrapper,"aria-hidden":"true","data-testid":`course-panel-item-spinner-${h.id}`,children:f.jsx("span",{className:zn.spinner})}):null,f.jsxs(iy,{selected:p,className:zn.courseCard,children:[f.jsx(iy.Heading,{className:oe(zn.courseHeading,v&&zn.contentHidden),children:h.title}),h.description?f.jsx(iy.Description,{className:oe(zn.courseDescription,v&&zn.contentHidden),children:h.description}):null]})]},h.id)})})})})]})}function L3(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=rV({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=T.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return f.jsx(aV,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const oV="_panel_1je0q_1",sV="_header_1je0q_10",lV="_headerActions_1je0q_19",cV="_popoverAnchor_1je0q_27",uV="_backButton_1je0q_31",dV="_divider_1je0q_38",hV="_title_1je0q_44",fV="_scrollArea_1je0q_54",pV="_scrollable_1je0q_59",mV="_list_1je0q_64",gV="_section_1je0q_70",vV="_sectionHeader_1je0q_76",bV="_sectionTitle_1je0q_80",yV="_sectionTitleCompact_1je0q_88",_V="_item_1je0q_92",xV="_itemClickable_1je0q_106",SV="_itemCompleted_1je0q_110",kV="_itemCurrent_1je0q_114",TV="_itemFuture_1je0q_118",wV="_itemDisabled_1je0q_123",CV="_row_1je0q_137",EV="_stepHeader_1je0q_144",RV="_stepNumber_1je0q_153",AV="_stepTitle_1je0q_159",NV="_checkIcon_1je0q_171",OV="_empty_1je0q_175",MV="_confirmationPopover_1je0q_180",DV="_confirmationMessage_1je0q_204",PV="_confirmationActions_1je0q_211",LV="_confirmationButton_1je0q_216",IV="_confirmationButtonCancel_1je0q_234",jV="_confirmationButtonNeutral_1je0q_242",Re={panel:oV,header:sV,headerActions:lV,popoverAnchor:cV,backButton:uV,divider:dV,title:hV,scrollArea:fV,scrollable:pV,list:mV,section:gV,sectionHeader:vV,sectionTitle:bV,sectionTitleCompact:yV,item:_V,itemClickable:xV,itemCompleted:SV,itemCurrent:kV,itemFuture:TV,itemDisabled:wV,row:CV,stepHeader:EV,stepNumber:RV,stepTitle:AV,checkIcon:NV,empty:OV,confirmationPopover:MV,confirmationMessage:DV,confirmationActions:PV,confirmationButton:LV,confirmationButtonCancel:IV,confirmationButtonNeutral:jV};function BV(t){var p;const{steps:e,currentStep:n,hideTrailingConclusionStep:i}=t,r=e.length,a=i&&r>0&&((p=e[r-1])==null?void 0:p.title)==="Conclusion",o=a?e.slice(0,-1):e.slice(),s=o.length,l=typeof n=="number"&&isFinite(n)?n:1;if(s===0)return{visibleSteps:o,completedIndices:[],currentIndex:null,futureIndices:[]};if(a&&l===r)return{visibleSteps:o,completedIndices:Array.from({length:s},(v,m)=>m),currentIndex:null,futureIndices:[]};const c=Math.min(Math.max(l,1),s)-1,u=Array.from({length:Math.max(0,c)},(v,m)=>m),d=Math.min(c,s-1),h=Array.from({length:Math.max(0,s-(d+1))},(v,m)=>d+1+m);return{visibleSteps:o,completedIndices:u,currentIndex:d,futureIndices:h}}function UV(t){const{title:e="Course Outline",ariaLabel:n,className:i,steps:r,currentStep:a,onStepClick:o,hideTrailingConclusionStep:s=!0,emptyMessage:l="No steps available",density:c="default",testId:u,onBackToCoursesConfirm:d,backToCoursesDisabled:h=!1,backToCoursesLabel:p="Back to courses",backToCoursesConfirmMessage:v="Going back will end this course. You can start another course from the list.",backToCoursesConfirmLabel:m="Back",backToCoursesCancelLabel:S="Cancel",showBackToCourses:g=!0,...y}=t,[x,b]=T.useState(!1),k=T.useRef(null),w=h||!d,C=T.useCallback(V=>(V+1).toString().padStart(2,"0"),[]),{visibleSteps:R,completedIndices:A,currentIndex:N,futureIndices:O}=T.useMemo(()=>BV({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),B=c==="compact"?"md":"lg",X=T.useCallback(()=>{w||b(V=>!V)},[w]),L=T.useCallback(()=>{b(!1)},[]),Y=T.useCallback(()=>{b(!1),d&&d()},[d]);T.useEffect(()=>{if(!x)return;const V=ee=>{const $=ee.composedPath();k.current&&!$.includes(k.current)&&b(!1)},K=ee=>{ee.key==="Escape"&&b(!1)};return document.addEventListener("mousedown",V),document.addEventListener("keydown",K),()=>{document.removeEventListener("mousedown",V),document.removeEventListener("keydown",K)}},[x]),T.useEffect(()=>{w&&x&&b(!1)},[w,x]);const P=T.useCallback((V,K)=>{const ee=R[V];if(!ee)return null;const $=typeof o=="function",U=$&&ee.disabled===!0,Z=$&&!U,Q=oe(Re.item,{[Re.itemClickable]:Z,[Re.itemCompleted]:K==="completed",[Re.itemCurrent]:K==="current",[Re.itemFuture]:K==="future",[Re.itemDisabled]:U}),le=f.jsxs("div",{className:Re.row,children:[f.jsxs("div",{className:Re.stepHeader,children:[f.jsx("span",{className:Re.stepNumber,children:C(V)}),f.jsx("span",{className:Re.stepTitle,children:ee.title})]}),K==="completed"?f.jsx(lp,{size:20,className:Re.checkIcon}):null]});return $?f.jsx(Ep,{as:"button",type:"button",className:Q,onClick:()=>{Z&&o(V,ee)},disabled:U,"aria-current":K==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${ee.title}`,"data-testid":`course-outline-item-${ee.id}`,padding:B,radius:"panel",gap:"sm",children:le},ee.id):f.jsx(Ep,{className:Q,"aria-current":K==="current"?"step":void 0,"aria-label":`Step ${C(V)}: ${ee.title}`,"data-testid":`course-outline-item-${ee.id}`,padding:B,radius:"panel",gap:"sm",children:le},ee.id)},[C,B,o,R]);return f.jsxs(Wu,{...y,className:oe(Re.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsxs("div",{className:Re.header,children:[f.jsx(Si,{as:"h2",className:Re.title,children:e}),g?f.jsx("div",{className:Re.headerActions,children:f.jsxs("div",{ref:k,className:Re.popoverAnchor,children:[f.jsxs(Ro,{type:"button",variant:"secondary",color:"default",size:"sm",className:Re.backButton,onClick:X,disabled:w,"aria-label":p,"data-testid":"course-outline-back-button",children:[f.jsx(ME,{size:16,"aria-hidden":"true"}),f.jsx("span",{children:p})]}),x?f.jsxs("div",{className:Re.confirmationPopover,role:"dialog","aria-label":"Back to courses confirmation","data-testid":"course-outline-back-confirm",children:[f.jsx("p",{className:Re.confirmationMessage,children:v}),f.jsxs("div",{className:Re.confirmationActions,children:[f.jsx("button",{type:"button",className:oe(Re.confirmationButton,Re.confirmationButtonCancel),onClick:L,"data-testid":"course-outline-back-cancel",children:S}),f.jsx("button",{type:"button",className:oe(Re.confirmationButton,Re.confirmationButtonNeutral),onClick:Y,"data-testid":"course-outline-back-confirm-action",children:m})]})]}):null]})}):null]}),f.jsx("div",{className:Re.divider,"aria-hidden":"true"}),f.jsx("div",{className:Re.scrollArea,children:f.jsx(ql,{className:Re.scrollable,children:R.length===0?f.jsx(Si,{variant:"muted",className:Re.empty,"data-testid":"course-outline-empty",children:l}):f.jsxs("div",{className:Re.list,"data-testid":"course-outline-list",children:[A.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-completed",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:oe(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Completed"})}),A.map(V=>P(V,"completed"))]}):null,N!==null?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-current",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:oe(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Current"})}),P(N,"current")]}):null,O.length>0?f.jsxs("div",{className:Re.section,"data-testid":"course-outline-section-upcoming",children:[f.jsx("div",{className:Re.sectionHeader,children:f.jsx("span",{className:oe(Re.sectionTitle,c==="compact"?Re.sectionTitleCompact:null),children:"Upcoming"})}),O.map(V=>P(V,"future"))]}):null]})})})]})}function zV(t){return f.jsx(UV,{...t})}const FV="_panel_h7cuf_1",qV="_messagesArea_h7cuf_20",HV="_messagesList_h7cuf_46",VV="_messageItem_h7cuf_53",GV="_messageMetadata_h7cuf_59",WV="_senderName_h7cuf_67",YV="_timestamp_h7cuf_71",KV="_messageBubble_h7cuf_75",XV="_agentMessage_h7cuf_85",$V="_agentActions_h7cuf_89",JV="_copyButton_h7cuf_95",QV="_copyButtonCopied_h7cuf_129",ZV="_empty_h7cuf_133",eG="_composer_h7cuf_140",tG="_composerDisabled_h7cuf_160",nG="_composerInput_h7cuf_165",iG="_sendButton_h7cuf_180",Ln={panel:FV,messagesArea:qV,messagesList:HV,messageItem:VV,messageMetadata:GV,senderName:WV,timestamp:YV,messageBubble:KV,agentMessage:XV,agentActions:$V,copyButton:JV,copyButtonCopied:QV,empty:ZV,composer:eG,composerDisabled:tG,composerInput:nG,sendButton:iG};function rG(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function aG(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function oG(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function sG(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function lG(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=T.useState(""),[d,h]=T.useState(null),p=T.useRef(null),v=T.useRef(null),m=T.useMemo(()=>{const b=e[e.length-1];return b?b.id??`${b.timestamp}-${e.length-1}`:null},[e]);T.useEffect(()=>{var b,k;(k=(b=p.current)==null?void 0:b.scrollIntoView)==null||k.call(b,{behavior:"smooth"})},[m]),T.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]);const S=T.useCallback(async()=>{const b=c.trim();b.length!==0&&(await i(b),u(""))},[c,i]),g=T.useCallback(b=>{b.key==="Enter"&&(b.preventDefault(),S())},[S]),y=T.useCallback(async(b,k)=>{try{await sG(b.message??""),h(k),v.current&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{h(null),v.current=null},2e3)}catch(w){console.warn("[PiPChatPanel] Failed to copy message",w)}},[]),x=c.trim().length>0&&!r;return f.jsxs("div",{...l,className:oe(Ln.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[f.jsx("div",{className:Ln.messagesArea,children:e.length===0?f.jsx("div",{className:Ln.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):f.jsxs("div",{className:Ln.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((b,k)=>{const w=b.id??`${b.timestamp}-${k}`,C=aG(b,n),R=d===w;return f.jsxs("div",{className:oe(Ln.messageItem,C&&Ln.agentMessage),"data-testid":`pip-chat-panel-message-${w}`,children:[f.jsxs("div",{className:Ln.messageMetadata,children:[f.jsx("span",{className:Ln.senderName,children:oG(b,n)}),f.jsx("span",{className:Ln.timestamp,children:rG(b.timestamp)})]}),f.jsx("div",{className:Ln.messageBubble,children:b.message}),C?f.jsx("div",{className:Ln.agentActions,children:f.jsx("button",{type:"button",className:oe(Ln.copyButton,R&&Ln.copyButtonCopied),onClick:()=>void y(b,w),"aria-label":R?"Copied":"Copy message",title:R?"Copied":"Copy message","data-testid":"pip-copy-agent-message","data-copied":R?"true":"false",children:f.jsx(DE,{size:14})})}):null]},w)}),f.jsx("div",{ref:p})]})}),f.jsxs("div",{className:oe(Ln.composer,r&&Ln.composerDisabled),children:[f.jsx("input",{type:"text",className:Ln.composerInput,value:c,onChange:b=>u(b.target.value),onKeyDown:g,placeholder:a,disabled:r,"aria-label":"Message"}),f.jsx("button",{type:"button",className:Ln.sendButton,onClick:()=>void S(),disabled:!x,"aria-label":"Send message",children:f.jsx(IE,{size:16})})]})]})}const cG="_panel_k5ick_1",uG="_header_k5ick_11",dG="_title_k5ick_19",hG="_titleCompact_k5ick_29",fG="_headerActions_k5ick_33",pG="_closeButton_k5ick_39",mG="_divider_k5ick_67",gG="_body_k5ick_73",vG="_messagesArea_k5ick_81",bG="_scrollable_k5ick_86",yG="_messagesList_k5ick_90",_G="_messageItem_k5ick_98",xG="_messageMetadata_k5ick_104",SG="_senderName_k5ick_112",kG="_timestamp_k5ick_116",TG="_messageBubble_k5ick_120",wG="_messageText_k5ick_124",CG="_agentMessage_k5ick_130",EG="_agentActions_k5ick_134",RG="_copyButton_k5ick_140",AG="_copyButtonCopied_k5ick_174",NG="_inputRow_k5ick_178",OG="_empty_k5ick_182",MG="_composer_k5ick_188",DG="_composerDefault_k5ick_203",PG="_composerCompact_k5ick_208",LG="_composerDisabled_k5ick_218",IG="_composerInputWrapper_k5ick_223",jG="_composerInput_k5ick_223",BG="_sendButton_k5ick_240",UG="_sendButtonCompact_k5ick_257",rt={panel:cG,header:uG,title:dG,titleCompact:hG,headerActions:fG,closeButton:pG,divider:mG,body:gG,messagesArea:vG,scrollable:bG,messagesList:yG,messageItem:_G,messageMetadata:xG,senderName:SG,timestamp:kG,messageBubble:TG,messageText:wG,agentMessage:CG,agentActions:EG,copyButton:RG,copyButtonCopied:AG,inputRow:NG,empty:OG,composer:MG,composerDefault:DG,composerCompact:PG,composerDisabled:LG,composerInputWrapper:IG,composerInput:jG,sendButton:BG,sendButtonCompact:UG};function zG(t){const e=new Date(t),n=e.getHours(),i=e.getMinutes(),r=n>=12?"PM":"AM",a=n%12||12,o=i.toString().padStart(2,"0");return`${a}:${o}${r}`}function FG(t,e){var i,r;if(typeof t.isAgent=="boolean")return t.isAgent;const n=((i=t.from)==null?void 0:i.identity)??void 0;return n&&e&&n===e?!1:((r=t.attributes)==null?void 0:r.source)==="agent-rpc"?!0:n?n==="agent-avatar"||n.startsWith("agent-"):!1}function qG(t,e){var i,r,a;const n=(i=t.from)==null?void 0:i.identity;return n&&e&&n===e?"You":((r=t.from)==null?void 0:r.name)??((a=t.attributes)==null?void 0:a.senderName)??n??"Unknown"}async function HG(t){var n;if(typeof navigator<"u"&&((n=navigator.clipboard)!=null&&n.writeText)){await navigator.clipboard.writeText(t);return}if(typeof document>"u")throw new Error("Clipboard unavailable");const e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-9999px",e.style.top="0",e.setAttribute("readonly","true"),document.body.appendChild(e),e.select(),document.execCommand("copy"),document.body.removeChild(e)}function VG(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=T.useState(""),l=T.useCallback(async()=>{const p=o.trim();p.length!==0&&(await a(p),s(""))},[a,o]),c=T.useCallback(p=>{p.key==="Enter"&&(p.preventDefault(),l())},[l]),u=i==="sm"||i==="xs",d=u?18:24,h=o.trim().length>0&&e!==!0;return f.jsxs("div",{className:oe(rt.composer,u?rt.composerCompact:rt.composerDefault,e?rt.composerDisabled:null),children:[f.jsx("div",{className:rt.composerInputWrapper,children:f.jsx(UE,{value:o,onChange:s,onKeyDown:c,className:rt.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),f.jsx("button",{type:"button",className:oe(rt.sendButton,u?rt.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:f.jsx(IE,{size:d})})]})}function I3(t){const{title:e="Messages",ariaLabel:n,className:i,messages:r,isSending:a=!1,localIdentity:o,onSend:s,onClose:l,showCloseButton:c=!0,emptyMessage:u="No messages yet",density:d="default",testId:h,formatTimestamp:p=zG,getSenderName:v,isAgentMessage:m,copyResetDelayMs:S=2e3,showAgentCopyButton:g=!0,inputPlaceholder:y,inputAutoFocus:x,...b}=t,k=T.useRef(null),[w,C]=T.useState(null),R=T.useRef(null),A=T.useCallback(Y=>v?v(Y):qG(Y,o),[v,o]),N=T.useCallback(Y=>m?m(Y,o):FG(Y,o),[m,o]),O=T.useMemo(()=>{const Y=r[r.length-1];return Y?Y.id??`${Y.timestamp}-${r.length-1}`:null},[r]);T.useEffect(()=>{var Y,P;(P=(Y=k.current)==null?void 0:Y.scrollIntoView)==null||P.call(Y,{behavior:"smooth"})},[O]),T.useEffect(()=>()=>{R.current&&(window.clearTimeout(R.current),R.current=null)},[]);const B=T.useCallback(Y=>{C(Y),R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{C(null),R.current=null},S)},[S]),X=T.useCallback(async(Y,P)=>{try{await HG(Y.message??""),B(P)}catch(V){console.warn("[ChatPanel] Failed to copy message",V)}},[B]),L=d==="compact"?"sm":"md";return f.jsxs(Wu,{...b,className:oe(rt.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[f.jsxs("div",{className:rt.header,children:[f.jsx(Si,{as:"h2",className:oe(rt.title,d==="compact"?rt.titleCompact:null),children:e}),l&&c?f.jsx("div",{className:rt.headerActions,children:f.jsx("button",{type:"button",className:rt.closeButton,onClick:l,"aria-label":`Close ${e}`,children:f.jsx(cp,{size:d==="compact"?18:20})})}):null]}),f.jsx("div",{className:rt.divider,"aria-hidden":"true"}),f.jsxs("div",{className:rt.body,children:[f.jsx("div",{className:rt.messagesArea,children:f.jsx(ql,{className:rt.scrollable,children:r.length===0?f.jsx(Si,{variant:"muted",className:rt.empty,"data-testid":"chat-panel-empty",children:u}):f.jsxs("div",{className:rt.messagesList,"data-testid":"chat-panel-list",children:[r.map((Y,P)=>{const V=Y.id??`${Y.timestamp}-${P}`,K=N(Y),ee=w===V;return f.jsxs("div",{className:oe(rt.messageItem,K?rt.agentMessage:null),"data-testid":`chat-panel-message-${V}`,children:[f.jsxs("div",{className:rt.messageMetadata,children:[f.jsx("span",{className:rt.senderName,children:A(Y)}),f.jsx("span",{className:rt.timestamp,children:p(Y.timestamp)})]}),f.jsx(Ep,{className:rt.messageBubble,padding:"md",radius:"panel",background:K?"surfaceMuted":"surface",children:f.jsx("div",{className:rt.messageText,children:Y.message})}),K&&g?f.jsx("div",{className:rt.agentActions,children:f.jsx("button",{type:"button",className:oe(rt.copyButton,ee?rt.copyButtonCopied:null),onClick:()=>void X(Y,V),"aria-label":ee?"Copied":"Copy agent message",title:ee?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":ee?"true":"false",children:f.jsx(DE,{size:18})})}):null]},V)}),f.jsx("div",{ref:k})]})})}),f.jsx("div",{className:rt.inputRow,children:f.jsx(VG,{onSend:s,disabled:a,placeholder:y,size:L,autoFocus:x})})]})]})}T.createContext("vertical");const GG="_container_1v6ko_1",WG="_video_1v6ko_7",YG="_chip_1v6ko_16",KG="_logo_1v6ko_34",Rp={container:GG,video:WG,chip:YG,logo:KG},XG="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function $G(t){const{agentName:e="Obi",greetingVideoSrc:n,className:i,...r}=t,a=T.useRef(null),o=()=>{var s;try{(s=a.current)==null||s.pause()}catch{}};return f.jsxs("div",{className:oe(Rp.container,i),...r,children:[f.jsx("video",{ref:a,className:Rp.video,src:n??XG,autoPlay:!0,muted:!0,playsInline:!0,onEnded:o}),f.jsxs("div",{className:Rp.chip,children:[f.jsx(iB,{size:12,className:Rp.logo}),f.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const j3=50,Gl="?",B3=/\(error: (.*)\)/,U3=/captureMessage|captureException/;function JG(...t){const e=t.sort((n,i)=>n[0]-i[0]).map(n=>n[1]);return(n,i=0,r=0)=>{const a=[],o=n.split(`
134
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=B3.test(l)?l.replace(B3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=j3+r)break}}return QG(a.slice(r))}}function QG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Ap(e).function||"")&&e.pop(),e.reverse(),U3.test(Ap(e).function||"")&&(e.pop(),U3.test(Ap(e).function||"")&&e.pop()),e.slice(0,j3).map(n=>({...n,filename:n.filename||Ap(e).filename,function:n.function||Gl}))}function Ap(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ZG=30,eW=50;function ry(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Gl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const tW=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nW=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,iW=/\((\S*)(?::(\d+))(?::(\d+))\)/,rW=t=>{const e=tW.exec(t);if(e){const[,i,r,a]=e;return ry(i,Gl,+r,+a)}const n=nW.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=iW.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=z3(n[1]||Gl,n[2]);return ry(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},aW=[ZG,rW],oW=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,sW=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;JG(...[aW,[eW,t=>{const e=oW.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=sW.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Gl;return[i,n]=z3(i,n),ry(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const z3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Gl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const lW={sm:640,md:900,lg:1024,xl:1280};function cW(t){return`(max-width: ${lW[t]-1}px)`}const rr={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function ay(...t){return t.filter(Boolean).join(" ")}function uW(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:ay(rr.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:ay(rr.layout,u?rr.layoutThree:null),children:[f.jsxs("div",{className:rr.leftPanel,children:[f.jsxs("div",{className:rr.videoFrame,children:[d&&h&&f.jsx("div",{className:rr.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:rr.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})})}),f.jsx(wH,{className:rr.captions,text:e,children:f.jsx(C3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:rr.controls,children:f.jsx(T3,{...o})})]}),u?f.jsx("div",{className:rr.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:rr.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(L3,{...l,courses:s,className:ay(rr.coursePanel,l==null?void 0:l.className)})})]})})}function F3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(uW,{...r})})}const dW=80,hW=500,fW=1e3;function pW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=T.useState(""),[s,l]=T.useState(!1),c=T.useRef(""),u=T.useRef(null),d=T.useRef(null),h=T.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},v=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return T.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>dW?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},hW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},fW+n))},[r,s,n]),T.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const ws={shell:"_shell_1n2od_1",layout:"_layout_1n2od_11",mainPanel:"_mainPanel_1n2od_25",coursePanel:"_coursePanel_1n2od_39",controls:"_controls_1n2od_44",returnToPipSlot:"_returnToPipSlot_1n2od_49",returnToPipButton:"_returnToPipButton_1n2od_55"};function q3(...t){return t.filter(Boolean).join(" ")}function mW(t){const{controlBarProps:e,courses:n,coursePanelProps:i,mainPanel:r,onReturnToPiP:a,className:o}=t,s=a?f.jsx(Ro,{type:"button",size:"sm",variant:"tertiary",className:ws.returnToPipButton,onClick:a,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})}):null,l=s?f.jsxs("span",{className:ws.returnToPipSlot,children:[s,e.leadingControl]}):e.leadingControl,c={...e,browserSupportsScreenSharing:!1,microphoneButtonVariant:"simple",...s?{leadingControl:l}:{}};return f.jsx("div",{className:q3(ws.shell,o),"data-testid":"mobile-course-dialog-content",children:f.jsxs("div",{className:ws.layout,children:[f.jsx("div",{className:ws.mainPanel,"data-testid":"mobile-course-dialog-main-panel",children:r??f.jsx(L3,{...i,courses:n,className:q3(ws.coursePanel,i==null?void 0:i.className)})}),f.jsx("div",{className:ws.controls,children:f.jsx(T3,{...c})})]})})}function H3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mW,{...r})})}const Tr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function gW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(Pb,{open:e,onClose:n,size:"large",showCloseButton:c,className:Tr.dialogWithSmallClose,children:f.jsxs("div",{className:Tr.layout,children:[f.jsxs("div",{className:Tr.left,children:[f.jsxs("div",{className:Tr.copy,children:[f.jsx(Si,{variant:"heading",children:r}),f.jsx(Si,{variant:"subheading",children:a}),f.jsx(Si,{variant:"muted",as:"div",className:Tr.description,children:f.jsx(ql,{className:Tr.descriptionScroller,children:f.jsx(dF,{content:o})})})]}),f.jsxs("div",{className:Tr.cta,children:[f.jsx(Ro,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(Si,{variant:"subscript",as:"p",className:Tr.disclaimer,children:l})]})]}),f.jsx(w3,{showAboveWidth:"md",children:f.jsx("div",{className:Tr.right,children:f.jsx(Wu,{className:Tr.mediaPanel,children:f.jsx($G,{agentName:r,greetingVideoSrc:d,className:Tr.agentStill})})})})]})})}const vW={launcherPill:"_launcherPill_1fhyr_1"};function bW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:vW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const V3="__ama_course__",yW="ama_course",_W=3e4,G3=cW("md");function xW(t){var Xl,kn,Tn,Po,Lo,Xr,Io,Gt,jo,Bo,Uo,zo,$l,_,I,M,pe,Pe,be,Wt,kt,Tt,$r,Le,Fo,Jl,iR,rR,aR;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((Xl=e.client)==null?void 0:Xl.selectedPlanUuid)??null:null,a=((kn=e.client)==null?void 0:kn.session)??null,o=!!a&&(i&&!!r||!!((Tn=e.client)!=null&&Tn.selectedPlanUuid)),[s,l]=T.useState(()=>a),[c,u]=T.useState(()=>a!=null&&a.sessionUuid?kW(a.sessionUuid):null),d=(()=>{var W;return a?((W=a.roomId)==null?void 0:W.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=T.useState(()=>d),v=T.useRef(d),[m,S]=T.useState(!1),[g,y]=T.useState(!1),[x,b]=T.useState(!1),[k,w]=T.useState([]),[C,R]=T.useState(null),[A,N]=T.useState(null),[O,B]=T.useState(0),[X,L]=T.useState(!1),[Y,P]=T.useState(!1),[V,K]=T.useState(0),[ee,$]=T.useState(null),[U,Z]=T.useState([]),[Q,le]=T.useState(!1),[j,ge]=T.useState(!1),[H,he]=T.useState(()=>o),ve=T.useRef(o),Ye=T.useRef(null),Lt=T.useRef(null),me=T.useRef(!1),Ne=EW(),_t=()=>{p(W=>{const ne=W==="course-selection",Se=W==="course-outline"&&me.current;return ne||Se?(me.current=!1,L(!1),"pip"):W})};T.useEffect(()=>{v.current=h},[h]),T.useEffect(()=>()=>{Ye.current&&clearTimeout(Ye.current)},[]);const dt=()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)},Ht=()=>{dt(),Lt.current=null,N(W=>W===null?W:null)},un=W=>{dt(),Lt.current=W,N(W),Ye.current=setTimeout(()=>{const ne=Lt.current===W,Se=v.current==="course-selection";ne&&Se&&(Lt.current=null,N(null)),Ye.current=null},_W)},Ot=TW((Lo=(Po=e.client)==null?void 0:Po.product)==null?void 0:Lo.widget_url_blacklist),dn=wW(s),{audioDevices:In}=CW();T.useEffect(()=>{s!=null&&s.sessionUuid&&W3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:ri}=pW(U,{delayMs:0}),ai=typeof navigator<"u"&&!!((Xr=navigator.mediaDevices)!=null&&Xr.getDisplayMedia),ue=((Gt=(Io=s==null?void 0:s.room)==null?void 0:Io.localParticipant)==null?void 0:Gt.isScreenShareEnabled)??!1,Ke=W=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??W.identity,Se=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",Ze=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Se,lastName:Ze,email:xe}},Ce=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se,Ze].map(ht=>ht.trim());return xe.some(ht=>ht.length>0)?xe.join(":"):""},tt=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:Ze.length>0?Ze:void 0,screenShareSupported:ai}},st=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),Fn=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.avatar_image_url)||((zo=(Uo=e.client)==null?void 0:Uo.product)==null?void 0:zo.logo_url)||void 0,Li=((_=($l=e.client)==null?void 0:$l.product)==null?void 0:_.greeting_video_url)||void 0,Yr=SW({sdk:e,session:s,isBlacklisted:Ot}),q=!i&&Yr,re=!!(s??((I=e.client)==null?void 0:I.session)??null),de=(s==null?void 0:s.clientType)==="meet"?Ce(s):"",qe=(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.assistant_subtitle,St=typeof qe=="string"&&qe.trim().length>0?qe:"Onboarding Assistant",hn=()=>B(W=>W+1),Ii=async()=>{var ne,Se;if(!s)return;const W=((Se=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Se.isScreenShareEnabled)??!1;try{W?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(Ze){console.error("[obi-sdk] failed to toggle screen share",Ze)}finally{hn()}},wr=T.useRef(null),Vt=T.useRef(null),qn=T.useRef(!1),xn=T.useRef({session:null,sessionUuid:null,started:!1}),jn=T.useRef(null),Oo=T.useRef(new WeakMap),Wl=(W,ne)=>{if(!ne)return;let Se=Oo.current.get(W);Se||(Se=new Set,Oo.current.set(W,Se)),Se.add(ne)},Te=W=>{if(!W||wr.current===W)return;Vt.current&&(Vt.current(),Vt.current=null);const ne=()=>hn(),Se=Ie=>{u(Ie),Ht(),W!=null&&W.sessionUuid&&W3(W.sessionUuid,Ie),p(fe=>fe==="pip"||fe==="course-outline"?fe:fe==="course-selection"?(me.current=!0,"course-outline"):fe)},Ze=Ie=>{Ht(),w(Ie.courses),p("course-selection"),me.current=!1,u(null),W!=null&&W.sessionUuid&&Y3(W.sessionUuid),R(null),P(!1)},xe=(Ie,fe)=>{},Ae=Ie=>{Ie.isAgent},ht=Ie=>{$(Ie),K(Date.now())},It=Ie=>{if(!Ie){$(null);return}$(Ie),K(Date.now())};W.on("stateChanged",ne),W.on("speakingStateChanged",ne),W.on("paused",ne),W.on("unpaused",ne),W.on("chatMessagesChanged",ne),W.on("chatMessageReceived",Ae),W.on("courseProgress",Se),W.on("courseSelection",Ze),W.on("transcript",xe),W.on("screenCaptured",ht),W.on("screenCaptureNotification",It),W.on("captions",Z),W.on("introductionComplete",_t),wr.current=W,Vt.current=()=>{W.off("stateChanged",ne),W.off("speakingStateChanged",ne),W.off("paused",ne),W.off("unpaused",ne),W.off("chatMessagesChanged",ne),W.off("chatMessageReceived",Ae),W.off("courseProgress",Se),W.off("courseSelection",Ze),W.off("transcript",xe),W.off("screenCaptured",ht),W.off("screenCaptureNotification",It),W.off("captions",Z),W.off("introductionComplete",_t)}},Sn=W=>{var Se;return W?((Se=W.roomId)==null?void 0:Se.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};T.useEffect(()=>{const W=()=>{jn.current&&(jn.current(),jn.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(xn.current.session&&xn.current.session===xe||!!xn.current.sessionUuid&&!!xe.sessionUuid&&xn.current.sessionUuid===xe.sessionUuid){if(xn.current.started||jn.current)return}else xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},W();const ht=async()=>{xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const fe=Ce(xe);fe&&Wl(xe,fe);try{await xe.sendHumanJoined(tt(xe))}catch(Xe){console.error("[obi-sdk] failed to send human_joined handshake",Xe)}},It=(fe,Xe)=>{fe==="connecting"||fe==="error"||(W(),ht())},Ie=xe.state;if(Ie&&Ie!=="connecting"&&Ie!=="error"){ht();return}xe.on("stateChanged",It),jn.current=()=>{xe.off("stateChanged",It)}},Se=xe=>{var Ae,ht,It,Ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Sn(((It=e.client)==null?void 0:It.session)??null));else{const Xe=!!e.passivePlanUuid,fn=Xe&&!!((ht=e.client)!=null&&ht.selectedPlanUuid);if(Xe&&!fn)return;p("start-session")}else(Ie=e.client)!=null&&Ie.session||p("hidden")},Ze=()=>hn();if(e.on("showMenu",Se),e.on("configUpdated",Ze),e.client){e.client.session&&(l(e.client.session),Te(e.client.session),p(Sn(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1);const ht=ve.current;ve.current=!1,ht?(me.current=!0,p("course-outline")):(me.current=!1,p(Sn(Ae))),la().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1),me.current=!1,p(Sn(Ae)),ne(Ae)});const xe=()=>{var It;const Ae=(It=e.client)==null?void 0:It.session;Ae!=null&&Ae.sessionUuid&&Y3(Ae.sessionUuid);const ht=wr.current;Vt.current&&(Vt.current(),Vt.current=null),l(null),wr.current=null,S(!1),y(!1),b(!1),P(!1),he(!1),ve.current=!1,Ht(),me.current=!1,W(),xn.current={session:null,sessionUuid:null,started:!1},ht&&Oo.current.delete(ht),qn.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",hn)}return()=>{e.off("showMenu",Se),e.off("configUpdated",Ze),Vt.current&&Vt.current(),W()}},[e]),T.useEffect(()=>{const W=s;if(!W||W.clientType!=="meet")return;const ne=W.state;if(!ne||ne==="connecting"||ne==="error"||!de)return;const Se=Oo.current.get(W);Se!=null&&Se.has(de)||(Wl(W,de),W.sendHumanJoined(tt(W)).catch(Ze=>console.error("[obi-sdk] failed to send human_joined update",Ze)))},[ai,de,s,s==null?void 0:s.state]),T.useLayoutEffect(()=>{var W,ne;(ne=(W=e.client)==null?void 0:W.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(be=(Pe=e.client)==null?void 0:Pe.product)==null?void 0:be.primary_color,n]),T.useEffect(()=>{if(i&&!Ot&&!re){if(!r){p("hidden");return}p("start-session")}},[re,i,Ot,r]),T.useEffect(()=>{var It,Ie;ge(!1);const W=(It=e.client)==null?void 0:It.api,ne=(Ie=e.client)==null?void 0:Ie.product;if(!W||!ne)return;const Se=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),Ze=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Se?Ae.product_uuid=Se:Ze?Ae.product_slug=Ze:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let ht=!1;return W.getFeatureFlags(Ae).then(fe=>{if(ht)return;const fn=((fe==null?void 0:fe.data)??[]).find(sy=>(sy==null?void 0:sy.slug)===yW);if(!fn)return;const{user_enabled:oi,product_enabled:ki,global_enabled:ji}=fn;let si=!!ji;ki!=null&&(si=!!ki),oi!=null&&(si=!!oi),ge(si)}).catch(fe=>{console.error("[obi-sdk] failed to load AMA feature flag",fe)}),()=>{ht=!0}},[(Wt=e.client)==null?void 0:Wt.api,(kt=e.client)==null?void 0:kt.product]);const Yl=(c==null?void 0:c.stepNames.map((W,ne)=>({id:`step-${ne+1}`,title:W})))??[],Kr=((c==null?void 0:c.totalSteps)??0)>0&&((c==null?void 0:c.stepNames.length)??0)>0?(c==null?void 0:c.currentStep)??null:null,Mo=!0,Do=(W,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(Ot||i&&!r&&!re)return null;if(h==="hidden")return q?f.jsx(bW,{label:St,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const W=(Tt=e.client)==null?void 0:Tt.product,ne=($r=e.client)==null?void 0:$r.selectedPlan,Se=i&&!!r,Ze=i&&!!r||!!((Le=e.client)!=null&&Le.selectedPlanUuid),xe=(W==null?void 0:W.agent_name)||"Obi",Ae=(W==null?void 0:W.assistant_subtitle)||"AI Assistant",ht=Se&&(ne==null?void 0:ne.description)||(W==null?void 0:W.assistant_description)||"";return f.jsx(gW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{ve.current=Ze,he(Ze),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:ht,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:Li})}if(h==="course-selection"){const W=(Fo=s==null?void 0:s.roomId)==null?void 0:Fo.startsWith("obs-"),ne=((Jl=e.client)==null?void 0:Jl.plans)||[],Se=W&&k.length>0,Ze=Se?k.slice().sort((fe,Xe)=>fe.order!==void 0&&Xe.order!==void 0?fe.order-Xe.order:fe.order!==void 0?-1:Xe.order!==void 0?1:fe.name.localeCompare(Xe.name)).map(fe=>({id:fe.uuid,title:fe.name,description:fe.description||fe.overview||"",status:fe.completed?"completed":"available",duration:typeof fe.duration=="number"?`${fe.duration} min`:fe.duration})):ne.map(fe=>{var Xe,fn;return{id:fe.uuid,title:fe.name,description:fe.description,status:(fn=(Xe=e.client)==null?void 0:Xe.planIsCompleted)!=null&&fn[ne.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}});Se&&j&&Ze.push({id:V3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,ht={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),s&&fe&&await s.switchMicrophoneDevice(fe),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:fe=>{s==null||s.setLanguage(fe)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},It=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((iR=s==null?void 0:s.room)==null?void 0:iR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async fe=>{var Xe,fn,oi,ki;if(s){const ji=Date.now();s.appendChatMessage({timestamp:ji,message:fe,from:{identity:((fn=(Xe=s.room)==null?void 0:Xe.localParticipant)==null?void 0:fn.identity)??null,name:((ki=(oi=s.room)==null?void 0:oi.localParticipant)==null?void 0:ki.name)??null},isAgent:!1}),await s.say(fe)}},onClose:()=>b(!1)}):void 0,Ie={selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async fe=>{var Xe,fn,oi,ki;if(!Lt.current)if(Se){if(fe===V3){un(fe),R(fe);try{await((Xe=s==null?void 0:s.say)==null?void 0:Xe.call(s,"Please start an AMA session."))}catch(si){console.error("[obi-sdk] failed to start AMA course",si),Ht(),R(null)}return}const ji=k.find(si=>si.uuid===fe);if(ji){un(fe),R(fe);try{await((fn=s==null?void 0:s.say)==null?void 0:fn.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),Ht(),R(null)}}}else{const ji=ne.find(si=>si.uuid===fe);if(ji){un(fe),(oi=e.client)==null||oi.selectPlan(ji),p("pip");try{await((ki=s==null?void 0:s.say)==null?void 0:ki.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),p("course-selection"),Ht()}}}}};return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,mainPanel:It}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,rightPanel:It,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="course-outline"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async Ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ie),s&&Ie&&await s.switchMicrophoneDevice(Ie),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Ie=>{s==null||s.setLanguage(Ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},Ze=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((rR=s==null?void 0:s.room)==null?void 0:rR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Ie=>{var fe,Xe,fn,oi;if(s){const ki=Date.now();s.appendChatMessage({timestamp:ki,message:Ie,from:{identity:((Xe=(fe=s.room)==null?void 0:fe.localParticipant)==null?void 0:Xe.identity)??null,name:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(Ie)}},onClose:()=>b(!1)}):void 0,xe=!!c,Ae=!H,ht=async()=>{if(!(!(s!=null&&s.endCourse)||Y)){P(!0);try{await s.endCourse("back_to_courses")}catch(Ie){console.error("[obi-sdk] failed to end course",Ie),P(!1)}}},It=f.jsx(zV,{steps:Yl,currentStep:Kr,hideTrailingConclusionStep:Mo,onStepClick:Do,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:ht,backToCoursesDisabled:Y}:{}});return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,mainPanel:Ze??It,onReturnToPiP:xe?()=>p("pip"):void 0}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,middlePanel:It,rightPanel:Ze,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="pip"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se=()=>{s==null||s.stop()},Ze=()=>{if(me.current=!1,c){p("course-outline");return}p("course-selection")},xe={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:ue,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>b(Xe=>!Xe),onScreenShareToggle:Ii,onLeave:Se,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Xe=>{s==null||s.setLanguage(Xe)},isLanguageSelectorEnabled:!0};if(Ne)return f.jsx(gq,{isMicrophoneEnabled:xe.isMicrophoneEnabled,onMicToggle:xe.onMicToggle,onLeave:Se,onReturnToCourseOutline:Ze});const Ae=280,ht=250,It=16,Ie={x:window.innerWidth-Ae-It,y:window.innerHeight-ht-It},fe=x?f.jsx(lG,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((aR=s==null?void 0:s.room)==null?void 0:aR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Xe=>{var fn,oi,ki,ji;if(s){const si=Date.now();s.appendChatMessage({timestamp:si,message:Xe,from:{identity:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.identity)??null,name:((ji=(ki=s.room)==null?void 0:ki.localParticipant)==null?void 0:ji.name)??null},isAgent:!1}),await s.say(Xe)}},testId:"pip-chat-panel"}):void 0;return f.jsx(_H,{initialPosition:Ie,onExit:Ze,controlBarProps:xe,isCourseOutlineSelected:X&&!!c,onCourseOutlineToggle:c?()=>{L(Xe=>!Xe)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>le(Xe=>!Xe),courseOutline:c?{steps:Yl,currentStep:Kr,onStepClick:Do,hideTrailingConclusionStep:Mo}:void 0,messagesPanel:fe,avatarFallbackProps:{audioPower:dn,imageSrc:Fn,status:st,captionsText:ri},screenshotUrl:ee,cameraShotTrigger:V})}return null}function SW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function W3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function kW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function Y3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function TW(t){const[e,n]=T.useState(()=>xs(t));return T.useEffect(()=>{n(xs(t))},[t]),T.useEffect(()=>{const i=()=>{n(xs(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function wW(t){const[e,n]=T.useState(0),i=T.useRef(null),r=T.useRef(0),a=T.useRef(0);return T.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let v=0;for(let m=0;m<s.length;m++)v+=s[m];l=Math.min(1,Math.max(0,v/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function CW(){const[t,e]=T.useState({audioDevices:[]});return T.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function EW(){const t=()=>typeof window>"u"||!("matchMedia"in window)?!1:window.matchMedia(G3).matches,[e,n]=T.useState(()=>t());return T.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const i=window.matchMedia(G3),r=a=>{n(a.matches)};return n(i.matches),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}function K3(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t.endsWith(".clinic1.com")||t.endsWith(".onuptick.com")||t.endsWith(".gorgias.com")||t==="app.canibuild.com"||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const X3=K3();function RW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;AW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(H7);const a=[r];if(X3){const s=new CSSStyleSheet;s.replaceSync(z7),a.push(s);const l=new CSSStyleSheet;l.replaceSync(q7),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(F7),a.push(s)}n.adoptedStyleSheets=a;const o=U7.createRoot(i);X3?o.render(f.jsx(xW,{sdk:t,shadowHost:e})):o.render(f.jsx(W7,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function AW(){$3("https://fonts.cdnfonts.com/css/satoshi"),$3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const J3="49206C6F7665204F6269_session",Q3="obi-url-params",oy="obi-client-heartbeat",NW=5e3,Z3=4e4,eR=15e3;function OW(){return K3()?"meet":"sdk"}function MW(){if(typeof window>"u")return!1;const t=navigator.userAgent||"",n=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|tablet/i.test(t.toLowerCase()),i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches;return n||i}class DW extends Dp{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=OW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=Rh.deserialise(r,e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new Rh(e,i,{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,v,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(v=this.client)==null?void 0:v.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&xs(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{la().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&la().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){const n=MW()?"mobile":"desktop";await this.client.startSession(this.client.selectedPlanUuid||null,i=>{i.on("stateChanged",r=>{r!=="disconnecting"&&r!=="disconnected"&&r!=="error"&&r!=="connecting"&&this.save()}),i.on("paused",()=>{this.save()}),i.on("unpaused",()=>{this.save()})},{...e,environment:n})}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(Q3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[J3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(J3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(Q3),this.passivePlanUuid=n}mountWidget(){RW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await MO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await CR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await uO(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>Z3,reason:s>Z3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>eR,reason:o>eR?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(oy);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{la().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},NW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(oy,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(oy)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function tR(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return PW({appToken:t,window:n,init:e})}async function PW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new DW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function nR(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{tR(void 0,nR)}):tR(void 0,nR)})();
134
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=B3.test(l)?l.replace(B3,"$1"):l;if(!c.match(/\S*Error: /)){for(const u of e){const d=u(c);if(d){a.push(d);break}}if(a.length>=j3+r)break}}return QG(a.slice(r))}}function QG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(Ap(e).function||"")&&e.pop(),e.reverse(),U3.test(Ap(e).function||"")&&(e.pop(),U3.test(Ap(e).function||"")&&e.pop()),e.slice(0,j3).map(n=>({...n,filename:n.filename||Ap(e).filename,function:n.function||Gl}))}function Ap(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const ZG=30,eW=50;function ry(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?Gl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const tW=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,nW=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,iW=/\((\S*)(?::(\d+))(?::(\d+))\)/,rW=t=>{const e=tW.exec(t);if(e){const[,i,r,a]=e;return ry(i,Gl,+r,+a)}const n=nW.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=iW.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=z3(n[1]||Gl,n[2]);return ry(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},aW=[ZG,rW],oW=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,sW=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;JG(...[aW,[eW,t=>{const e=oW.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=sW.exec(e[3]);r&&(e[1]=e[1]||"eval",e[3]=r[1],e[4]=r[2],e[5]="")}let n=e[3],i=e[1]||Gl;return[i,n]=z3(i,n),ry(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const z3=(t,e)=>{const n=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return n||i?[t.indexOf("@")!==-1?t.split("@")[0]:Gl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const lW={sm:640,md:900,lg:1024,xl:1280};function cW(t){return`(max-width: ${lW[t]-1}px)`}const rr={shell:"_shell_8bsnr_1",layout:"_layout_8bsnr_11",layoutThree:"_layoutThree_8bsnr_23",leftPanel:"_leftPanel_8bsnr_27",middlePanel:"_middlePanel_8bsnr_36",rightPanel:"_rightPanel_8bsnr_37",videoFrame:"_videoFrame_8bsnr_41",captions:"_captions_8bsnr_52",controls:"_controls_8bsnr_58",coursePanel:"_coursePanel_8bsnr_71",returnToPiPOverlay:"_returnToPiPOverlay_8bsnr_82",returnToPiPButton:"_returnToPiPButton_8bsnr_94"};function ay(...t){return t.filter(Boolean).join(" ")}function uW(t){const{captionsText:e,avatarAudioPower:n=0,avatarImageSrc:i,avatarAriaLabel:r,avatarStatus:a,controlBarProps:o,courses:s,coursePanelProps:l,middlePanel:c,rightPanel:u,isCourseOutlineOpen:d,onReturnToPiP:h,className:p}=t;return f.jsx("div",{className:ay(rr.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:ay(rr.layout,u?rr.layoutThree:null),children:[f.jsxs("div",{className:rr.leftPanel,children:[f.jsxs("div",{className:rr.videoFrame,children:[d&&h&&f.jsx("div",{className:rr.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:rr.returnToPiPButton,onClick:h,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})})}),f.jsx(wH,{className:rr.captions,text:e,children:f.jsx(C3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:rr.controls,children:f.jsx(T3,{...o})})]}),u?f.jsx("div",{className:rr.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:rr.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(L3,{...l,courses:s,className:ay(rr.coursePanel,l==null?void 0:l.className)})})]})})}function F3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(uW,{...r})})}const dW=80,hW=500,fW=1e3;function pW(t,e){const{delayMs:n=0}=e??{},r=t.filter(m=>{var g;const S=(g=m.participantInfo)==null?void 0:g.identity;return(S==null?void 0:S.startsWith("agent-"))??!1}).map(m=>m.text??"").join(" ").trim(),[a,o]=T.useState(""),[s,l]=T.useState(!1),c=T.useRef(""),u=T.useRef(null),d=T.useRef(null),h=T.useRef(null),p=m=>{h.current&&(clearTimeout(h.current),h.current=null),n>0?h.current=setTimeout(()=>{o(m)},n):o(m)},v=(m,S)=>m.startsWith(S)?m.slice(S.length).trim():m.trim();return T.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>dW?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},hW+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},fW+n))},[r,s,n]),T.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const ws={shell:"_shell_1n2od_1",layout:"_layout_1n2od_11",mainPanel:"_mainPanel_1n2od_25",coursePanel:"_coursePanel_1n2od_39",controls:"_controls_1n2od_44",returnToPipSlot:"_returnToPipSlot_1n2od_49",returnToPipButton:"_returnToPipButton_1n2od_55"};function q3(...t){return t.filter(Boolean).join(" ")}function mW(t){const{controlBarProps:e,courses:n,coursePanelProps:i,mainPanel:r,onReturnToPiP:a,className:o}=t,s=a?f.jsx(Ro,{type:"button",size:"sm",variant:"tertiary",className:ws.returnToPipButton,onClick:a,"aria-label":"Return to PiP","data-testid":"course-return-to-pip",children:f.jsx(PE,{size:14})}):null,l=s?f.jsxs("span",{className:ws.returnToPipSlot,children:[s,e.leadingControl]}):e.leadingControl,c={...e,browserSupportsScreenSharing:!1,microphoneButtonVariant:"simple",...s?{leadingControl:l}:{}};return f.jsx("div",{className:q3(ws.shell,o),"data-testid":"mobile-course-dialog-content",children:f.jsxs("div",{className:ws.layout,children:[f.jsx("div",{className:ws.mainPanel,"data-testid":"mobile-course-dialog-main-panel",children:r??f.jsx(L3,{...i,courses:n,className:q3(ws.coursePanel,i==null?void 0:i.className)})}),f.jsx("div",{className:ws.controls,children:f.jsx(T3,{...c})})]})})}function H3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(Pb,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mW,{...r})})}const Tr={layout:"_layout_k1q6c_1",left:"_left_k1q6c_10",copy:"_copy_k1q6c_17",description:"_description_k1q6c_25",descriptionScroller:"_descriptionScroller_k1q6c_31",cta:"_cta_k1q6c_36",disclaimer:"_disclaimer_k1q6c_43",right:"_right_k1q6c_47",mediaPanel:"_mediaPanel_k1q6c_56",agentStill:"_agentStill_k1q6c_63",dialogWithSmallClose:"_dialogWithSmallClose_k1q6c_88"};function gW(t){const{open:e,onClose:n,onStart:i,agentName:r,agentSubtitle:a,description:o,startLabel:s="Start Now",disclaimer:l="Sessions are securely recorded for quality improvement purposes.",showCloseButton:c=!1,isStarting:u=!1,greetingVideoSrc:d}=t;return f.jsx(Pb,{open:e,onClose:n,size:"large",showCloseButton:c,className:Tr.dialogWithSmallClose,children:f.jsxs("div",{className:Tr.layout,children:[f.jsxs("div",{className:Tr.left,children:[f.jsxs("div",{className:Tr.copy,children:[f.jsx(Si,{variant:"heading",children:r}),f.jsx(Si,{variant:"subheading",children:a}),f.jsx(Si,{variant:"muted",as:"div",className:Tr.description,children:f.jsx(ql,{className:Tr.descriptionScroller,children:f.jsx(dF,{content:o})})})]}),f.jsxs("div",{className:Tr.cta,children:[f.jsx(Ro,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(Si,{variant:"subscript",as:"p",className:Tr.disclaimer,children:l})]})]}),f.jsx(w3,{showAboveWidth:"md",children:f.jsx("div",{className:Tr.right,children:f.jsx(Wu,{className:Tr.mediaPanel,children:f.jsx($G,{agentName:r,greetingVideoSrc:d,className:Tr.agentStill})})})})]})})}const vW={launcherPill:"_launcherPill_1fhyr_1"};function bW(t){const{label:e,onClick:n}=t;return f.jsx("button",{type:"button",className:vW.launcherPill,onClick:n,"data-testid":"ai-coach-pill",children:e})}const V3="__ama_course__",yW="ama_course",_W=3e4,G3=cW("md");function xW(t){var Xl,kn,Tn,Po,Lo,Xr,Io,Gt,jo,Bo,Uo,zo,$l,_,I,M,pe,Pe,be,Wt,kt,Tt,$r,Le,Fo,Jl,iR,rR,aR;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((Xl=e.client)==null?void 0:Xl.selectedPlanUuid)??null:null,a=((kn=e.client)==null?void 0:kn.session)??null,o=!!a&&(i&&!!r||!!((Tn=e.client)!=null&&Tn.selectedPlanUuid)),[s,l]=T.useState(()=>a),[c,u]=T.useState(()=>a!=null&&a.sessionUuid?kW(a.sessionUuid):null),d=(()=>{var W;return a?((W=a.roomId)==null?void 0:W.startsWith("obs-"))&&!c?"course-selection":"pip":r?"start-session":"hidden"})(),[h,p]=T.useState(()=>d),v=T.useRef(d),[m,S]=T.useState(!1),[g,y]=T.useState(!1),[x,b]=T.useState(!1),[k,w]=T.useState([]),[C,R]=T.useState(null),[A,N]=T.useState(null),[O,B]=T.useState(0),[X,L]=T.useState(!1),[Y,P]=T.useState(!1),[V,K]=T.useState(0),[ee,$]=T.useState(null),[U,Z]=T.useState([]),[Q,le]=T.useState(!1),[j,ge]=T.useState(!1),[H,he]=T.useState(()=>o),ve=T.useRef(o),Ye=T.useRef(null),Lt=T.useRef(null),me=T.useRef(!1),Ne=EW(),_t=()=>{p(W=>{const ne=W==="course-selection",Se=W==="course-outline"&&me.current;return ne||Se?(me.current=!1,L(!1),"pip"):W})};T.useEffect(()=>{v.current=h},[h]),T.useEffect(()=>()=>{Ye.current&&clearTimeout(Ye.current)},[]);const dt=()=>{Ye.current&&(clearTimeout(Ye.current),Ye.current=null)},Ht=()=>{dt(),Lt.current=null,N(W=>W===null?W:null)},un=W=>{dt(),Lt.current=W,N(W),Ye.current=setTimeout(()=>{const ne=Lt.current===W,Se=v.current==="course-selection";ne&&Se&&(Lt.current=null,N(null)),Ye.current=null},_W)},Ot=TW((Lo=(Po=e.client)==null?void 0:Po.product)==null?void 0:Lo.widget_url_blacklist),dn=wW(s),{audioDevices:In}=CW();T.useEffect(()=>{s!=null&&s.sessionUuid&&W3(s.sessionUuid,c)},[c,s==null?void 0:s.sessionUuid]);const{caption:ri}=pW(U,{delayMs:0}),ai=typeof navigator<"u"&&!!((Xr=navigator.mediaDevices)!=null&&Xr.getDisplayMedia),ue=((Gt=(Io=s==null?void 0:s.room)==null?void 0:Io.localParticipant)==null?void 0:Gt.isScreenShareEnabled)??!1,Ke=W=>{var Ae;const ne=((Ae=e.client)==null?void 0:Ae.identity)??W.identity,Se=typeof(ne==null?void 0:ne.first_name)=="string"?ne.first_name.trim():"",Ze=typeof(ne==null?void 0:ne.last_name)=="string"?ne.last_name.trim():"",xe=typeof(ne==null?void 0:ne.email)=="string"&&ne.email.trim().length>0?ne.email.trim():"";return{firstName:Se,lastName:Ze,email:xe}},Ce=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se,Ze].map(ht=>ht.trim());return xe.some(ht=>ht.length>0)?xe.join(":"):""},tt=W=>{const{firstName:ne,lastName:Se,email:Ze}=Ke(W),xe=[ne,Se].filter(Boolean).join(" ").trim();return{name:xe.length>0?xe:void 0,email:Ze.length>0?Ze:void 0,screenShareSupported:ai}},st=(()=>{if(s!=null&&s.speakingState){if(s.speakingState==="thinking")return"thinking";if(s.speakingState==="busy")return"searching"}})(),Fn=((Bo=(jo=e.client)==null?void 0:jo.product)==null?void 0:Bo.avatar_image_url)||((zo=(Uo=e.client)==null?void 0:Uo.product)==null?void 0:zo.logo_url)||void 0,Li=((_=($l=e.client)==null?void 0:$l.product)==null?void 0:_.greeting_video_url)||void 0,Yr=SW({sdk:e,session:s,isBlacklisted:Ot}),q=!i&&Yr,re=!!(s??((I=e.client)==null?void 0:I.session)??null),de=(s==null?void 0:s.clientType)==="meet"?Ce(s):"",qe=(pe=(M=e.client)==null?void 0:M.product)==null?void 0:pe.assistant_subtitle,St=typeof qe=="string"&&qe.trim().length>0?qe:"Onboarding Assistant",hn=()=>B(W=>W+1),Ii=async()=>{var ne,Se;if(!s)return;const W=((Se=(ne=s.room)==null?void 0:ne.localParticipant)==null?void 0:Se.isScreenShareEnabled)??!1;try{W?await s.setScreenShareEnabled(!1):await s.shareScreen()}catch(Ze){console.error("[obi-sdk] failed to toggle screen share",Ze)}finally{hn()}},wr=T.useRef(null),Vt=T.useRef(null),qn=T.useRef(!1),xn=T.useRef({session:null,sessionUuid:null,started:!1}),jn=T.useRef(null),Oo=T.useRef(new WeakMap),Wl=(W,ne)=>{if(!ne)return;let Se=Oo.current.get(W);Se||(Se=new Set,Oo.current.set(W,Se)),Se.add(ne)},Te=W=>{if(!W||wr.current===W)return;Vt.current&&(Vt.current(),Vt.current=null);const ne=()=>hn(),Se=Ie=>{u(Ie),Ht(),W!=null&&W.sessionUuid&&W3(W.sessionUuid,Ie),p(fe=>fe==="pip"||fe==="course-outline"?fe:fe==="course-selection"?(me.current=!0,"course-outline"):fe)},Ze=Ie=>{Ht(),w(Ie.courses),p("course-selection"),me.current=!1,u(null),W!=null&&W.sessionUuid&&Y3(W.sessionUuid),R(null),P(!1)},xe=(Ie,fe)=>{},Ae=Ie=>{Ie.isAgent},ht=Ie=>{$(Ie),K(Date.now())},It=Ie=>{if(!Ie){$(null);return}$(Ie),K(Date.now())};W.on("stateChanged",ne),W.on("speakingStateChanged",ne),W.on("paused",ne),W.on("unpaused",ne),W.on("chatMessagesChanged",ne),W.on("chatMessageReceived",Ae),W.on("courseProgress",Se),W.on("courseSelection",Ze),W.on("transcript",xe),W.on("screenCaptured",ht),W.on("screenCaptureNotification",It),W.on("captions",Z),W.on("introductionComplete",_t),wr.current=W,Vt.current=()=>{W.off("stateChanged",ne),W.off("speakingStateChanged",ne),W.off("paused",ne),W.off("unpaused",ne),W.off("chatMessagesChanged",ne),W.off("chatMessageReceived",Ae),W.off("courseProgress",Se),W.off("courseSelection",Ze),W.off("transcript",xe),W.off("screenCaptured",ht),W.off("screenCaptureNotification",It),W.off("captions",Z),W.off("introductionComplete",_t)}},Sn=W=>{var Se;return W?((Se=W.roomId)==null?void 0:Se.startsWith("obs-"))&&!c?"course-selection":"pip":"hidden"};T.useEffect(()=>{const W=()=>{jn.current&&(jn.current(),jn.current=null)},ne=xe=>{if(xe.clientType!=="meet")return;if(xn.current.session&&xn.current.session===xe||!!xn.current.sessionUuid&&!!xe.sessionUuid&&xn.current.sessionUuid===xe.sessionUuid){if(xn.current.started||jn.current)return}else xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!1},W();const ht=async()=>{xn.current={session:xe,sessionUuid:xe.sessionUuid??null,started:!0};const fe=Ce(xe);fe&&Wl(xe,fe);try{await xe.sendHumanJoined(tt(xe))}catch(Xe){console.error("[obi-sdk] failed to send human_joined handshake",Xe)}},It=(fe,Xe)=>{fe==="connecting"||fe==="error"||(W(),ht())},Ie=xe.state;if(Ie&&Ie!=="connecting"&&Ie!=="error"){ht();return}xe.on("stateChanged",It),jn.current=()=>{xe.off("stateChanged",It)}},Se=xe=>{var Ae,ht,It,Ie;if(xe)if((Ae=e.client)!=null&&Ae.session)p(Sn(((It=e.client)==null?void 0:It.session)??null));else{const Xe=!!e.passivePlanUuid,fn=Xe&&!!((ht=e.client)!=null&&ht.selectedPlanUuid);if(Xe&&!fn)return;p("start-session")}else(Ie=e.client)!=null&&Ie.session||p("hidden")},Ze=()=>hn();if(e.on("showMenu",Se),e.on("configUpdated",Ze),e.client){e.client.session&&(l(e.client.session),Te(e.client.session),p(Sn(e.client.session))),e.client.on("sessionStarted",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1);const ht=ve.current;ve.current=!1,ht?(me.current=!0,p("course-outline")):(me.current=!1,p(Sn(Ae))),la().track("session-started",{planId:Ae.planId}),ne(Ae)}),e.client.on("sessionResumed",Ae=>{l(Ae),Te(Ae),qn.current=!1,S(!1),y(!1),b(!1),P(!1),me.current=!1,p(Sn(Ae)),ne(Ae)});const xe=()=>{var It;const Ae=(It=e.client)==null?void 0:It.session;Ae!=null&&Ae.sessionUuid&&Y3(Ae.sessionUuid);const ht=wr.current;Vt.current&&(Vt.current(),Vt.current=null),l(null),wr.current=null,S(!1),y(!1),b(!1),P(!1),he(!1),ve.current=!1,Ht(),me.current=!1,W(),xn.current={session:null,sessionUuid:null,started:!1},ht&&Oo.current.delete(ht),qn.current||p("hidden")};e.client.on("sessionStopped",xe),e.client.on("sessionShutdown",xe),e.client.on("stateChanged",hn)}return()=>{e.off("showMenu",Se),e.off("configUpdated",Ze),Vt.current&&Vt.current(),W()}},[e]),T.useEffect(()=>{const W=s;if(!W||W.clientType!=="meet")return;const ne=W.state;if(!ne||ne==="connecting"||ne==="error"||!de)return;const Se=Oo.current.get(W);Se!=null&&Se.has(de)||(Wl(W,de),W.sendHumanJoined(tt(W)).catch(Ze=>console.error("[obi-sdk] failed to send human_joined update",Ze)))},[ai,de,s,s==null?void 0:s.state]),T.useLayoutEffect(()=>{var W,ne;(ne=(W=e.client)==null?void 0:W.product)!=null&&ne.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(be=(Pe=e.client)==null?void 0:Pe.product)==null?void 0:be.primary_color,n]),T.useEffect(()=>{if(i&&!Ot&&!re){if(!r){p("hidden");return}p("start-session")}},[re,i,Ot,r]),T.useEffect(()=>{var It,Ie;ge(!1);const W=(It=e.client)==null?void 0:It.api,ne=(Ie=e.client)==null?void 0:Ie.product;if(!W||!ne)return;const Se=(ne==null?void 0:ne.uuid)??(ne==null?void 0:ne.product_uuid),Ze=(ne==null?void 0:ne.slug)??(ne==null?void 0:ne.product_slug),xe=(ne==null?void 0:ne.id)??(ne==null?void 0:ne.product_id),Ae={};if(Se?Ae.product_uuid=Se:Ze?Ae.product_slug=Ze:xe!=null&&(Ae.product_id=String(xe)),Object.keys(Ae).length===0)return;let ht=!1;return W.getFeatureFlags(Ae).then(fe=>{if(ht)return;const fn=((fe==null?void 0:fe.data)??[]).find(sy=>(sy==null?void 0:sy.slug)===yW);if(!fn)return;const{user_enabled:oi,product_enabled:ki,global_enabled:ji}=fn;let si=!!ji;ki!=null&&(si=!!ki),oi!=null&&(si=!!oi),ge(si)}).catch(fe=>{console.error("[obi-sdk] failed to load AMA feature flag",fe)}),()=>{ht=!0}},[(Wt=e.client)==null?void 0:Wt.api,(kt=e.client)==null?void 0:kt.product]);const Yl=(c==null?void 0:c.stepNames.map((W,ne)=>({id:`step-${ne+1}`,title:W})))??[],Kr=((c==null?void 0:c.totalSteps)??0)>0&&((c==null?void 0:c.stepNames.length)??0)>0?(c==null?void 0:c.currentStep)??null:null,Mo=!0,Do=(W,ne)=>{s==null||s.say(`Can we jump to the section about ${ne.title}?`)};if(Ot||i&&!r&&!re)return null;if(h==="hidden")return q?f.jsx(bW,{label:St,onClick:()=>{e.updateShowMenu(!0)}}):null;if(h==="start-session"){const W=(Tt=e.client)==null?void 0:Tt.product,ne=($r=e.client)==null?void 0:$r.selectedPlan,Se=i&&!!r,Ze=i&&!!r||!!((Le=e.client)!=null&&Le.selectedPlanUuid),xe=(W==null?void 0:W.agent_name)||"Obi",Ae=(W==null?void 0:W.assistant_subtitle)||"AI Assistant",ht=Se&&(ne==null?void 0:ne.description)||(W==null?void 0:W.assistant_description)||"";return f.jsx(gW,{open:!0,onClose:()=>{S(!1),p("hidden")},onStart:()=>{ve.current=Ze,he(Ze),S(!0),e.startSession({withMicrophone:!0})},agentName:xe,agentSubtitle:Ae,description:ht,showCloseButton:!1,startLabel:"Start Session",isStarting:m,greetingVideoSrc:Li})}if(h==="course-selection"){const W=(Fo=s==null?void 0:s.roomId)==null?void 0:Fo.startsWith("obs-"),ne=((Jl=e.client)==null?void 0:Jl.plans)||[],Se=W&&k.length>0,Ze=Se?k.slice().sort((fe,Xe)=>fe.order!==void 0&&Xe.order!==void 0?fe.order-Xe.order:fe.order!==void 0?-1:Xe.order!==void 0?1:fe.name.localeCompare(Xe.name)).map(fe=>({id:fe.uuid,title:fe.name,description:fe.description||fe.overview||"",status:fe.completed?"completed":"available",duration:typeof fe.duration=="number"?`${fe.duration} min`:fe.duration})):ne.map(fe=>{var Xe,fn;return{id:fe.uuid,title:fe.name,description:fe.description,status:(fn=(Xe=e.client)==null?void 0:Xe.planIsCompleted)!=null&&fn[ne.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}});Se&&j&&Ze.push({id:V3,title:"Ask me anything",description:"Ask questions before choosing a course.",status:"available"});const xe=(s==null?void 0:s.languageCodes)||[],Ae=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,ht={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),s&&fe&&await s.switchMicrophoneDevice(fe),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:xe,selectedLanguage:Ae,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:fe=>{s==null||s.setLanguage(fe)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},It=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((iR=s==null?void 0:s.room)==null?void 0:iR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async fe=>{var Xe,fn,oi,ki;if(s){const ji=Date.now();s.appendChatMessage({timestamp:ji,message:fe,from:{identity:((fn=(Xe=s.room)==null?void 0:Xe.localParticipant)==null?void 0:fn.identity)??null,name:((ki=(oi=s.room)==null?void 0:oi.localParticipant)==null?void 0:ki.name)??null},isAgent:!1}),await s.say(fe)}},onClose:()=>b(!1)}):void 0,Ie={selectedCourseIds:C?[C]:void 0,loadingCourseId:A,onCourseToggle:async fe=>{var Xe,fn,oi,ki;if(!Lt.current)if(Se){if(fe===V3){un(fe),R(fe);try{await((Xe=s==null?void 0:s.say)==null?void 0:Xe.call(s,"Please start an AMA session."))}catch(si){console.error("[obi-sdk] failed to start AMA course",si),Ht(),R(null)}return}const ji=k.find(si=>si.uuid===fe);if(ji){un(fe),R(fe);try{await((fn=s==null?void 0:s.say)==null?void 0:fn.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),Ht(),R(null)}}}else{const ji=ne.find(si=>si.uuid===fe);if(ji){un(fe),(oi=e.client)==null||oi.selectPlan(ji),p("pip");try{await((ki=s==null?void 0:s.say)==null?void 0:ki.call(s,`I'd like to take the ${ji.name} course.`))}catch(si){console.error("[obi-sdk] failed to send course selection",si),p("course-selection"),Ht()}}}}};return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,mainPanel:It}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:Ze,controlBarProps:ht,coursePanelProps:Ie,rightPanel:It,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="course-outline"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se={audioDevices:In,currentMicrophoneId:(s==null?void 0:s.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isScreenShareActive:ue,widgetState:x?"chat":null,canPublishData:!0,browserSupportsScreenSharing:ai,onMicDeviceSelect:async Ie=>{e.client&&(e.client.preferredMicrophoneDeviceId=Ie),s&&Ie&&await s.switchMicrophoneDevice(Ie),hn()},onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>{b(!x)},onLeave:()=>{s==null||s.stop()},onScreenShareToggle:Ii,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Ie=>{s==null||s.setLanguage(Ie)},isLanguageSelectorEnabled:!0,...x?{screenShareButtonVariant:"compact"}:{}},Ze=x?f.jsx(I3,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((rR=s==null?void 0:s.room)==null?void 0:rR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Ie=>{var fe,Xe,fn,oi;if(s){const ki=Date.now();s.appendChatMessage({timestamp:ki,message:Ie,from:{identity:((Xe=(fe=s.room)==null?void 0:fe.localParticipant)==null?void 0:Xe.identity)??null,name:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.name)??null},isAgent:!1}),await s.say(Ie)}},onClose:()=>b(!1)}):void 0,xe=!!c,Ae=!H,ht=async()=>{if(!(!(s!=null&&s.endCourse)||Y)){P(!0);try{await s.endCourse("back_to_courses")}catch(Ie){console.error("[obi-sdk] failed to end course",Ie),P(!1)}}},It=f.jsx(zV,{steps:Yl,currentStep:Kr,hideTrailingConclusionStep:Mo,onStepClick:Do,showBackToCourses:Ae,...Ae?{onBackToCoursesConfirm:ht,backToCoursesDisabled:Y}:{}});return Ne?f.jsx(H3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,mainPanel:Ze??It,onReturnToPiP:xe?()=>p("pip"):void 0}):f.jsx(F3,{open:!0,onClose:()=>s==null?void 0:s.stop(),courses:[],controlBarProps:Se,middlePanel:It,rightPanel:Ze,isCourseOutlineOpen:xe,onReturnToPiP:xe?()=>p("pip"):void 0,avatarImageSrc:Fn,avatarAudioPower:dn,avatarStatus:st,captionsText:ri})}if(h==="pip"){const W=(s==null?void 0:s.languageCodes)||[],ne=(s==null?void 0:s.selectedLanguage)||(s==null?void 0:s.defaultLanguageCode)||null,Se=()=>{s==null||s.stop()},Ze=()=>{if(me.current=!1,c){p("course-outline");return}p("course-selection")},xe={isMicrophoneEnabled:!g&&((s==null?void 0:s.isMicShared)??!1),isChatOpen:x,isScreenShareActive:ue,onMicToggle:async()=>{s!=null&&s.isMicShared?g?(await s.unmuteMicrophone(),y(!1)):(await s.muteMicrophone(),y(!0)):await(s==null?void 0:s.shareMicrophone())},onChatToggle:()=>b(Xe=>!Xe),onScreenShareToggle:Ii,onLeave:Se,languages:W,selectedLanguage:ne,defaultLanguageCode:s==null?void 0:s.defaultLanguageCode,isMultilingual:(s==null?void 0:s.isMultilingual)??!1,onLanguageChange:Xe=>{s==null||s.setLanguage(Xe)},isLanguageSelectorEnabled:!0};if(Ne)return f.jsx(gq,{isMicrophoneEnabled:xe.isMicrophoneEnabled,onMicToggle:xe.onMicToggle,onLeave:Se,onReturnToCourseOutline:Ze});const Ae=280,ht=250,It=16,Ie={x:window.innerWidth-Ae-It,y:window.innerHeight-ht-It},fe=x?f.jsx(lG,{messages:(s==null?void 0:s.chatMessages)??[],localIdentity:((aR=s==null?void 0:s.room)==null?void 0:aR.localParticipant.identity)??(typeof(s==null?void 0:s.identity)=="string"?s.identity:null),onSend:async Xe=>{var fn,oi,ki,ji;if(s){const si=Date.now();s.appendChatMessage({timestamp:si,message:Xe,from:{identity:((oi=(fn=s.room)==null?void 0:fn.localParticipant)==null?void 0:oi.identity)??null,name:((ji=(ki=s.room)==null?void 0:ki.localParticipant)==null?void 0:ji.name)??null},isAgent:!1}),await s.say(Xe)}},testId:"pip-chat-panel"}):void 0;return f.jsx(_H,{initialPosition:Ie,onExit:Ze,controlBarProps:xe,isCourseOutlineSelected:X&&!!c,onCourseOutlineToggle:c?()=>{L(Xe=>!Xe)}:void 0,isCaptionsEnabled:Q,onCaptionsToggle:()=>le(Xe=>!Xe),courseOutline:c?{steps:Yl,currentStep:Kr,onStepClick:Do,hideTrailingConclusionStep:Mo}:void 0,messagesPanel:fe,avatarFallbackProps:{audioPower:dn,imageSrc:Fn,status:st,captionsText:ri},screenshotUrl:ee,cameraShotTrigger:V})}return null}function SW(t){var l,c;const{sdk:e,session:n,isBlacklisted:i}=t;if(i)return!1;const r=e.client;if(!r||r.state!=="ready"||(n??r.session??null))return!1;let o=e.isActive;return((l=r.product)==null?void 0:l.name)==="Canibuild"&&(o=!0),!(!o||(e.widgetDisplay??((c=r.product)==null?void 0:c.widget_display))==="invisible")}function W3(t,e){if(!t)return;const n=`obi-widget-course-progress-${t}`;if(e===null){localStorage.removeItem(n);return}try{const i={...e,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(i))}catch(i){console.error("[obi-sdk] failed to save course progress",i)}}function kW(t){if(!t)return null;const e=`obi-widget-course-progress-${t}`;try{const n=localStorage.getItem(e);if(!n)return null;const i=JSON.parse(n);if(typeof i.currentStep!="number"||typeof i.totalSteps!="number"||!Array.isArray(i.stepNames))return console.warn("[obi-sdk] invalid course progress data, clearing",i),localStorage.removeItem(e),null;const r=24*60*60*1e3;return i.timestamp&&Date.now()-i.timestamp>r?(localStorage.removeItem(e),null):{currentStep:i.currentStep,totalSteps:i.totalSteps,stepNames:i.stepNames}}catch(n){return console.error("[obi-sdk] failed to load course progress",n),localStorage.removeItem(e),null}}function Y3(t){if(!t)return;const e=`obi-widget-course-progress-${t}`;try{localStorage.removeItem(e)}catch(n){console.error("[obi-sdk] failed to clear course progress",n)}}function TW(t){const[e,n]=T.useState(()=>xs(t));return T.useEffect(()=>{n(xs(t))},[t]),T.useEffect(()=>{const i=()=>{n(xs(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function wW(t){const[e,n]=T.useState(0),i=T.useRef(null),r=T.useRef(0),a=T.useRef(0);return T.useEffect(()=>{if(!t){n(0),r.current=0,a.current=0;return}const o=()=>{const s=t.audioSpectrum();let l=0;if(s&&s.length>0){let v=0;for(let m=0;m<s.length;m++)v+=s[m];l=Math.min(1,Math.max(0,v/s.length))}const c=r.current,d=l>=c?.7:.15,h=c*d+l*(1-d);r.current=h;const p=h<.05?0:Math.min(1,h);Math.abs(p-a.current)>.01&&(a.current=p,n(p)),i.current=requestAnimationFrame(o)};return i.current=requestAnimationFrame(o),()=>{i.current&&cancelAnimationFrame(i.current)}},[t]),e}function CW(){const[t,e]=T.useState({audioDevices:[]});return T.useEffect(()=>{var i;if(typeof navigator>"u"||!((i=navigator.mediaDevices)!=null&&i.enumerateDevices))return;const n=()=>{navigator.mediaDevices.enumerateDevices().then(r=>{e({audioDevices:r.filter(a=>a.kind==="audioinput")})})};return n(),navigator.mediaDevices.addEventListener("devicechange",n),()=>navigator.mediaDevices.removeEventListener("devicechange",n)},[]),t}function EW(){const t=()=>typeof window>"u"||!("matchMedia"in window)?!1:window.matchMedia(G3).matches,[e,n]=T.useState(()=>t());return T.useEffect(()=>{if(typeof window>"u"||!("matchMedia"in window))return;const i=window.matchMedia(G3),r=a=>{n(a.matches)};return n(i.matches),i.addEventListener("change",r),()=>i.removeEventListener("change",r)},[]),e}function K3(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t.endsWith(".clinic1.com")||t.endsWith(".onuptick.com")||t.endsWith(".gorgias.com")||t==="app.canibuild.com"||t==="getcor.ai"||t==="getcor.io"||t==="localhost"||t==="127.0.0.1"||t==="::1"}const X3=K3();function RW(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;AW();const e=document.createElement("div");e.id="obi-host",e.style.position="fixed",e.style.zIndex="9999",document.body.appendChild(e);const n=e.attachShadow({mode:"open"}),i=document.createElement("div");i.id="obi-container",n.appendChild(i);const r=new CSSStyleSheet;r.replaceSync(H7);const a=[r];if(X3){const s=new CSSStyleSheet;s.replaceSync(z7),a.push(s);const l=new CSSStyleSheet;l.replaceSync(q7),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(F7),a.push(s)}n.adoptedStyleSheets=a;const o=U7.createRoot(i);X3?o.render(f.jsx(xW,{sdk:t,shadowHost:e})):o.render(f.jsx(W7,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function AW(){$3("https://fonts.cdnfonts.com/css/satoshi"),$3("https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap")}function $3(t){const e=document.createElement("link");e.href=t,e.rel="stylesheet",document.head.appendChild(e)}const J3="49206C6F7665204F6269_session",Q3="obi-url-params",oy="obi-client-heartbeat",NW=5e3,Z3=4e4,eR=15e3;function OW(){return K3()?"meet":"sdk"}function MW(){if(typeof window>"u")return!1;const t=navigator.userAgent||"",n=/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini|mobile|tablet/i.test(t.toLowerCase()),i=typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches;return n||i}class DW extends Dp{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,this.heartbeatInterval=null,this.dispatchCommand=(n,i)=>{var r,a,o,s,l;switch(this.commandLog.push({commandType:n,args:i}),n){case"update":this.updateConfig(i);break;case"startSession":{if(i!=null&&i.planUuid){const c=(((r=this.client)==null?void 0:r.plans)||[]).find(u=>u.uuid===i.planUuid)||null;if(!c){console.warn("[obi] startSession command requires a valid planUuid",i);return}(o=(a=this.client)==null?void 0:a.selectPlan)==null||o.call(a,c)}this.updateActive(!0);break}case"stopSession":(l=(s=this.client)==null?void 0:s.stopSession)==null||l.call(s);break;case"say":this.say(i);break;default:console.warn("[obi] unknown command",{commandType:n,args:i})}},e&&this.createClient(e),this.parsePassiveParams()}async createClient(e){if(this.client){this.client.appToken!==e&&console.warn("[obi] client already exists with different app token");return}let n=null;const i=OW(),r=this.load();if(r)try{const a=this.parsePersistedSessionMetadata(r),o=a&&this.isPersistedSessionStale(a);o!=null&&o.stale&&a?(this.trackStaleSessionDiscard(a.sessionUuid,o.ageMs,o.reason),this.clearCachedClient()):(n=Rh.deserialise(r,e,i,{apiBaseUrl:"https://app.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:this.clearCachedClient())}catch(a){console.error("[obi] error loading cached client",a),this.clearCachedClient()}n||(n=new Rh(e,i,{apiBaseUrl:"https://app.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.session&&this.startHeartbeat(this.client.session.sessionUuid),this.client.on("stateChanged",a=>{var o,s,l,c,u,d,h,p,v,m;a==="ready"&&this.updateConfig({isActive:((o=window==null?void 0:window.obiWidgetConfig)==null?void 0:o.isActive)??((s=this.client)==null?void 0:s.showWidget),primaryColour:((c=(l=this.client)==null?void 0:l.product)==null?void 0:c.primary_color)||"#9500FF",widgetDisplay:((u=window==null?void 0:window.obiWidgetConfig)==null?void 0:u.widgetDisplay)||((h=(d=this.client)==null?void 0:d.product)==null?void 0:h.widget_display)||"regular",completedWidgetDisplay:((p=window==null?void 0:window.obiWidgetConfig)==null?void 0:p.completedWidgetDisplay)||((m=(v=this.client)==null?void 0:v.product)==null?void 0:m.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{var a,o;this.save(),this.startHeartbeat(((o=(a=this.client)==null?void 0:a.session)==null?void 0:o.sessionUuid)||null),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{this.clearCachedClient(),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{this.clearCachedClient()}),this.client.on("trackEvent",(a,o)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(a=>{a.on("stateChanged",o=>{o!=="disconnecting"&&o!=="disconnected"&&o!=="error"&&o!=="connecting"&&this.save()}),a.on("paused",()=>{this.save()}),a.on("unpaused",()=>{this.save()})}))}_maybeActOnServerEngagement(){var s;const e=this.client;if(!e||e.state!=="ready")return;const n=e.product,i=(s=e.engagement)==null?void 0:s.style;if(!i||n&&xs(n.widget_url_blacklist||[])||!e.showWidget)return;const r=e.plans||[],a=e.planIsCompleted||[],o=r.length>0&&a.filter(Boolean).length===r.length;if(!(r.length===0||o)){if(i==="modal"){const l=a.findIndex(u=>!u),c=l>=0?r[l]:null;c&&e.selectPlan(c)}else i==="popover"&&setTimeout(()=>{this.showMessage("Don't forget to complete your onboarding",{autoCloseMs:1e4})},1e3);try{la().track("engagement-prompt-shown",{style:i})}catch{}}}async initialise(e={}){var n;this.commandQueue=e.queuedCommands||[],this._resumed?(this._resumed=!1,this.dispatchCommandQueue()):this.client?this.client.initialise({planUuid:this.passivePlanUuid||void 0,identity:((n=window==null?void 0:window.obiWidgetConfig)==null?void 0:n.user)||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}this.dispatchCommandQueue()}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}):this.dispatchCommandQueue()}async updateConfig(e){e.apiKey!==void 0&&await this.updateAppToken(e.apiKey),this.updateActive(e.isActive),this.updatePrimaryColour(e.primaryColour),this.updateWidgetDisplay(e.widgetDisplay),this.updateCompletedWidgetDisplay(e.completedWidgetDisplay),this.updateWidgetPosition(e.widgetPosition),e.user!==void 0&&await this.updateIdentity(e.user),this.updateShowMenu(e.showMenu),this.emit("configUpdated")}async updateAppToken(e){var n;e===void 0||e==((n=this.client)==null?void 0:n.appToken)||(this.passivePlanUuid,await this.createClient(e),this.client&&await this.client.initialise({planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(i=>{console.error("[obi] error initialising client",i),this.emit("error",i)}))}updateActive(e){e===void 0||e==this.isActive||(this.isActive=e)}updatePrimaryColour(e){e===void 0||e==this.primaryColour||(this.primaryColour=e)}updateWidgetDisplay(e){e===void 0||e==this.widgetDisplay||(this.widgetDisplay=e)}updateCompletedWidgetDisplay(e){e===void 0||e==this.completedWidgetDisplay||(this.completedWidgetDisplay=e)}updateWidgetPosition(e){e===void 0||e==this.widgetPosition||(this.widgetPosition=e)}async updateIdentity(e){var i,r;if(e===void 0||e==((i=this.client)==null?void 0:i.identity))return;(r=this.client)==null||r.identity;let n=e?{...e,extra:{...e,...(e==null?void 0:e.extra)||{}}}:void 0;await this.client.initialise({identity:n,planUuid:this.passivePlanUuid||void 0}).then(()=>{this.emit("initialised");try{this._maybeActOnServerEngagement()}catch{}}).catch(a=>{console.error("[obi] error initialising client",a),this.emit("error",a)}),e!=null&&e.email&&la().identify((e==null?void 0:e.email)||"",n)}updateShowMenu(e){e!==void 0&&this.emit("showMenu",e)}async say(e){var n,i,r;await((r=(i=(n=this.client)==null?void 0:n.session)==null?void 0:i.say)==null?void 0:r.call(i,e))}async startSession(e){const n=MW()?"mobile":"desktop";await this.client.startSession(this.client.selectedPlanUuid||null,i=>{i.on("stateChanged",r=>{r!=="disconnecting"&&r!=="disconnected"&&r!=="error"&&r!=="connecting"&&this.save()}),i.on("paused",()=>{this.save()}),i.on("unpaused",()=>{this.save()})},{...e,environment:n})}dispatchCommandQueue(){const e=this.commandQueue;this.commandQueue=[],e.forEach(n=>{try{this.dispatchCommand(n[0],n[1]||[])}catch(i){console.error("[obi] error dispatching command",i)}})}parsePassiveParams(){if(this.passivePlanUuid){this.passivePlanUuid;return}let e={};e=JSON.parse(localStorage.getItem(Q3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[J3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(J3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(Q3),this.passivePlanUuid=n}mountWidget(){RW(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await MO(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await CR(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.css_line_breaks))}catch(e){throw console.error("[obi] error initialising unicode trie",e),e}try{return(await uO(document.documentElement,{useCORS:!0,allowTaint:!0,foreignObjectRendering:!0})).toDataURL("image/png")}catch(e){throw console.error("[obi] error capturing screen",e),e}}save(){var n;const e=((n=this.client)==null?void 0:n.serialise())||"";localStorage.setItem("obi-client",e)}load(){return localStorage.getItem("obi-client")}parsePersistedSessionMetadata(e){const n=JSON.parse(e),i=this.parseTimestampMs(n.serialisedAt);if(!n.session)return null;let r=null;if(typeof n.session=="string")try{r=JSON.parse(n.session)}catch{return null}else typeof n.session=="object"&&(r=n.session);return r?{sessionUuid:typeof r.sessionUuid=="string"?r.sessionUuid:null,startedAtMs:this.parseTimestampMs(r.startedAt),serialisedAtMs:i}:null}isPersistedSessionStale(e){const n=Date.now(),i=this.readHeartbeat();if(i&&i.sessionUuid&&e.sessionUuid&&i.sessionUuid===e.sessionUuid){const s=Math.max(0,n-i.updatedAtMs);return{stale:s>Z3,reason:s>Z3?"heartbeat-stale":"heartbeat-fresh",ageMs:s}}const r=[e.serialisedAtMs,e.startedAtMs].filter(s=>typeof s=="number"&&Number.isFinite(s));if(r.length===0)return{stale:!0,reason:"fallback-missing-timestamps",ageMs:null};const a=Math.max(...r),o=Math.max(0,n-a);return{stale:o>eR,reason:o>eR?"fallback-too-old":"fallback-recent",ageMs:o}}parseTimestampMs(e){if(typeof e=="number")return e;if(typeof e=="string"){const n=Number(e);if(!Number.isNaN(n))return n;const i=Date.parse(e);return Number.isFinite(i)?i:null}return null}readHeartbeat(){const e=localStorage.getItem(oy);if(!e)return null;try{return JSON.parse(e)}catch{return null}}trackStaleSessionDiscard(e,n,i){try{la().track("stale-session-discarded",{sessionUuid:e||void 0,ageMs:n??void 0,reason:i})}catch{}}startHeartbeat(e){if(!e){this.clearHeartbeat();return}this.stopHeartbeat(),this.writeHeartbeat(e),this.heartbeatInterval=setInterval(()=>{this.writeHeartbeat(e)},NW)}stopHeartbeat(){this.heartbeatInterval&&(clearInterval(this.heartbeatInterval),this.heartbeatInterval=null)}writeHeartbeat(e){const n={sessionUuid:e,updatedAtMs:Date.now()};localStorage.setItem(oy,JSON.stringify(n))}clearHeartbeat(){this.stopHeartbeat(),localStorage.removeItem(oy)}clearCachedClient(){this.clearHeartbeat(),localStorage.removeItem("obi-client")}}async function tR(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return PW({appToken:t,window:n,init:e})}async function PW({appToken:t,window:e,init:n}){var a,o;if(e.obi){console.warn("[obi] obi object already found on window, skipping");return}n&&n(),t||(t=(a=e==null?void 0:e.obiWidgetConfig)==null?void 0:a.apiKey);let i;try{i=((o=e.ObiSDK)==null?void 0:o.q)||[]}catch{i=[]}const r=new DW(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function nR(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{tR(void 0,nR)}):tR(void 0,nR)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obi-sdk",
3
- "version": "0.19.60-beta.0",
3
+ "version": "0.19.60",
4
4
  "description": "JavaScript SDK for Obi",
5
5
  "type": "module",
6
6
  "main": "dist/obi-sdk.umd.js",