obi-sdk 0.19.53-beta.0 → 0.19.53-beta.1

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
@@ -130,4 +130,4 @@ ${t}</tr>
130
130
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
131
131
  `}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>${va(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=JE(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+va(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=JE(t);if(r===null)return va(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${va(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:va(t.text)}},Rb=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}},mr=class zb{constructor(e){ht(this,"options"),ht(this,"renderer"),ht(this,"textRenderer"),this.options=e||es,this.options.renderer=this.options.renderer||new ep,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Rb}static parse(e,n){return new zb(n).parse(e)}static parseInline(e,n){return new zb(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}},tp,vu=(tp=class{constructor(t){ht(this,"options"),ht(this,"block"),this.options=t||es}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?pr.lex:pr.lexInline}provideParser(){return this.block?mr.parse:mr.parseInline}},ht(tp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ht(tp,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),tp),Rz=class{constructor(...t){ht(this,"defaults",yb()),ht(this,"options",this.setOptions),ht(this,"parse",this.parseMarkdown(!0)),ht(this,"parseInline",this.parseMarkdown(!1)),ht(this,"Parser",mr),ht(this,"Renderer",ep),ht(this,"TextRenderer",Rb),ht(this,"Lexer",pr),ht(this,"Tokenizer",Zf),ht(this,"Hooks",vu),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 ep(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 Zf(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 vu;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];vu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&vu.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 pr.lex(t,e??this.defaults)}parser(t,e){return mr.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?pr.lex:pr.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?mr.parse:mr.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?pr.lex:pr.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?mr.parse:mr.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+=`
132
132
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+va(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},ts=new Rz;function et(t,e){return ts.parse(t,e)}et.options=et.setOptions=function(t){return ts.setOptions(t),et.defaults=ts.defaults,BE(et.defaults),et},et.getDefaults=yb,et.defaults=es,et.use=function(...t){return ts.use(...t),et.defaults=ts.defaults,BE(et.defaults),et},et.walkTokens=function(t,e){return ts.walkTokens(t,e)},et.parseInline=ts.parseInline,et.Parser=mr,et.parser=mr.parse,et.Renderer=ep,et.TextRenderer=Rb,et.Lexer=pr,et.lexer=pr.lex,et.Tokenizer=Zf,et.Hooks=vu,et.parse=et,et.options,et.setOptions,et.use,et.walkTokens,et.parseInline,mr.parse,pr.lex;const Az="_base_1ne03_1",Nz={base:Az},Oz=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],Mz=["href","title","target","rel"];et.setOptions({breaks:!0,gfm:!0});function Dz(t){const{content:e,className:n,...i}=t,r=w.useMemo(()=>{if(!e)return"";const a=et.parse(e,{async:!1});return GU.sanitize(a,{ALLOWED_TAGS:[...Oz],ALLOWED_ATTR:[...Mz],ALLOW_DATA_ATTR:!1})},[e]);return r?f.jsx("div",{className:le(Nz.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const Pz="_controlBar_14416_1",Lz="_popoverAnchor_14416_11",Iz="_confirmationPopover_14416_15",jz="_confirmationPopoverAlignRight_14416_30",Bz="_confirmationPopoverAlignCenter_14416_33",Uz="_confirmationMessage_14416_53",zz="_confirmationActions_14416_60",Fz="_confirmationButton_14416_65",qz="_confirmationButtonCancel_14416_83",Hz="_confirmationButtonNeutral_14416_91",Vz="_confirmationButtonDanger_14416_99",Gz="_controlButton_14416_108",Wz="_controlButtonIconOnly_14416_130",Yz="_controlButtonDisabled_14416_135",Kz="_controlButtonDanger_14416_162",Xz="_controlButtonContent_14416_178",$z="_controlButtonIcon_14416_130",Qz="_controlButtonLabel_14416_194",Jz="_controlButtonChevron_14416_201",Zz="_controlButtonNotificationDot_14416_210",eF="_deviceSplitButton_14416_222",tF="_deviceSplitButtonEnabled_14416_226",nF="_dualButtonContent_14416_307",iF="_dualButtonIcon_14416_317",rF="_dualButtonLabel_14416_326",aF="_screenShareButton_14416_340",oF="_screenShareButtonCompact_14416_351",ze={controlBar:Pz,popoverAnchor:Lz,confirmationPopover:Iz,confirmationPopoverAlignRight:jz,confirmationPopoverAlignCenter:Bz,confirmationMessage:Uz,confirmationActions:zz,confirmationButton:Fz,confirmationButtonCancel:qz,confirmationButtonNeutral:Hz,confirmationButtonDanger:Vz,controlButton:Gz,controlButtonIconOnly:Wz,controlButtonDisabled:Yz,controlButtonDanger:Kz,controlButtonContent:Xz,controlButtonIcon:$z,controlButtonLabel:Qz,controlButtonChevron:Jz,controlButtonNotificationDot:Zz,deviceSplitButton:eF,deviceSplitButtonEnabled:tF,dualButtonContent:nF,dualButtonIcon:iF,dualButtonLabel:rF,screenShareButton:aF,screenShareButtonCompact:oF},sF="_inline_1gpyx_1",lF="_vertical_1gpyx_6",cF="_divider_1gpyx_10",uF="_dividerVertical_1gpyx_16",dF="_customDivider_1gpyx_21",bu={inline:sF,vertical:lF,divider:cF,dividerVertical:uF,customDivider:dF},t3={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 gr(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in t3)return t3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function hF(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=gr(r);y&&(v.gap=y)}const m=ii.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:le(bu.divider,i==="vertical"&&bu.dividerVertical)},`inline-divider-${y}`):f.jsx("span",{"aria-hidden":"true",className:bu.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:le(bu.inline,i==="vertical"&&bu.vertical,c),style:v,...h,children:g})}const Ab=ii.forwardRef(hF);Ab.displayName="Inline";function fF(){const[t,e]=w.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return w.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 Nb(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=le(ze.controlButton,a&&ze.controlButtonDisabled,l&&ze.controlButtonIconOnly,r==="danger"&&ze.controlButtonDanger,o),v=Number.parseInt(sb[s],10),m=r==="danger"?"outline":"primary",S=r==="danger"?"danger":"default",g=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:ze.controlButtonContent,children:[e?f.jsx("span",{className:ze.controlButtonIcon,children:ii.isValidElement(e)&&e.props.size===void 0?ii.cloneElement(e,{size:v}):e}):null,l?null:f.jsx("span",{className:ze.controlButtonLabel,children:n}),l||!i?null:f.jsx("span",{className:ze.controlButtonChevron,"aria-hidden":"true",children:f.jsx(lb,{size:16})})]}),c?f.jsx("span",{className:ze.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?f.jsx(Vf,{...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(xl,{...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 pF(t){const{audioDevices:e,currentMicrophoneId:n,isMicrophoneEnabled:i,isScreenShareActive:r,widgetState:a,canPublishData:o,browserSupportsScreenSharing:s,screenShareButtonVariant:l="default",onMicDeviceSelect:c,onMicToggle:u,onChatToggle:d,onLeave:h,onScreenShareToggle:p,showChatNotification:v=!1,isLanguageSelectorEnabled:m=!0,languages:S=[],selectedLanguage:g=null,defaultLanguageCode:y=null,isMultilingual:x=!1,onLanguageChange:b,isChatOpen:k=a==="chat"}=t,T=S.length,C=m&&x&&T>0,R=fF(),A=R?"xs":"sm",N=R,[O,U]=w.useState(!1),[G,L]=w.useState(!1),W=w.useRef(null),P=w.useRef(null);w.useEffect(()=>{const B=ge=>{const Et=ge.composedPath();O&&W.current&&!Et.includes(W.current)&&U(!1),G&&P.current&&!Et.includes(P.current)&&L(!1)},de=ge=>{ge.key==="Escape"&&(O&&U(!1),G&&L(!1))};if(O||G)return document.addEventListener("mousedown",B),document.addEventListener("keydown",de),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",de)}},[O,G]),w.useEffect(()=>{r||U(!1)},[r]);const X=w.useMemo(()=>e.map(B=>({label:B.label||`Microphone ${B.deviceId.slice(0,8)}`,value:B.deviceId})),[e]),J=w.useMemo(()=>n?X.find(B=>B.value===n)??null:null,[n,X]),re=w.useCallback(B=>{B.value,c(B.value)},[c]),$={microphone:!0,screenShare:s,chat:o},F=w.useCallback(()=>{if(r){U(!0);return}p()},[r,p]),Z=w.useCallback(()=>{U(!1),p()},[p]),K=w.useCallback(()=>{U(!1)},[]),se=w.useCallback(()=>{L(!0)},[]),j=w.useCallback(()=>{L(!1),h()},[h]),me=w.useCallback(()=>{L(!1)},[]);return f.jsx("div",{className:ze.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify($),"data-language-option-count":T>0?String(T):void 0,"data-default-language-code":y??void 0,children:f.jsxs(Ab,{gap:A,align:"center",justify:"center",wrap:N,children:[f.jsx(eU,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:X,value:J,onChange:re,variant:"primary",menuPlacement:"top",menuDisabled:X.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:le(ze.deviceSplitButton,i&&ze.deviceSplitButtonEnabled),children:f.jsxs("span",{className:ze.dualButtonContent,children:[f.jsx("span",{className:ze.dualButtonIcon,children:i?f.jsx(dE,{}):f.jsx(hE,{})}),f.jsx("span",{className:ze.dualButtonLabel,children:"Microphone"})]})}),o?f.jsx(Nb,{icon:f.jsx(lE,{}),label:"Chat",onClick:d,isOn:k,"aria-label":"Toggle chat",showNotificationDot:v}):null,s?f.jsxs("div",{ref:W,className:ze.popoverAnchor,children:[f.jsx(Nb,{icon:f.jsx(fE,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?ze.screenShareButtonCompact:ze.screenShareButton,iconOnly:l==="compact",onClick:F,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),O?f.jsxs("div",{className:le(ze.confirmationPopover,ze.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[f.jsx("p",{className:ze.confirmationMessage,children:"Stop screen sharing?"}),f.jsxs("div",{className:ze.confirmationActions,children:[f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonCancel),onClick:K,children:"Cancel"}),f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonNeutral),onClick:Z,children:"Stop"})]})]}):null]}):null,C?f.jsx(xE,{languages:S,value:g,onChange:b,defaultLanguageCode:y,variant:"control-bar"}):null,f.jsxs("div",{ref:P,className:ze.popoverAnchor,children:[f.jsx(Nb,{icon:f.jsx(uE,{}),label:"Leave",variant:"danger",onClick:se,"aria-label":"Leave meeting"}),G?f.jsxs("div",{className:le(ze.confirmationPopover,ze.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:ze.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:ze.confirmationActions,children:[f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonCancel),onClick:me,children:"Cancel"}),f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function mF(t){return f.jsx(pF,{...t})}const gF="_controlBar_1n8jn_1",vF="_controlButton_1n8jn_12",bF="_controlButtonDisabled_1n8jn_35",yF="_controlButtonDanger_1n8jn_62",_F="_controlButtonIconOnly_1n8jn_78",xF="_screenShareButton_1n8jn_83",SF="_controlButtonContent_1n8jn_88",kF="_controlButtonIcon_1n8jn_78",TF="_controlButtonLabel_1n8jn_103",wF="_controlButtonNotificationDot_1n8jn_108",CF="_popoverAnchor_1n8jn_198",EF="_confirmationPopover_1n8jn_202",RF="_confirmationMessage_1n8jn_216",AF="_confirmationActions_1n8jn_223",NF="_confirmationButton_1n8jn_228",OF="_confirmationButtonCancel_1n8jn_246",MF="_confirmationButtonDanger_1n8jn_254",pn={controlBar:gF,controlButton:vF,controlButtonDisabled:bF,controlButtonDanger:yF,controlButtonIconOnly:_F,screenShareButton:xF,controlButtonContent:SF,controlButtonIcon:kF,controlButtonLabel:TF,controlButtonNotificationDot:wF,popoverAnchor:CF,confirmationPopover:EF,confirmationMessage:RF,confirmationActions:AF,confirmationButton:NF,confirmationButtonCancel:OF,confirmationButtonDanger:MF};function np(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=le(pn.controlButton,r&&pn.controlButtonDisabled,o&&pn.controlButtonIconOnly,i==="danger"&&pn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",p=i==="danger"?"danger":"default",v=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:pn.controlButtonContent,children:[e?f.jsx("span",{className:pn.controlButtonIcon,children:ii.isValidElement(e)&&e.props.size===void 0?ii.cloneElement(e,{size:20}):e}):null,o?null:f.jsx("span",{className:pn.controlButtonLabel,children:n})]}),s?f.jsx("span",{className:pn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?f.jsx(Vf,{...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(xl,{...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 DF(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,onLanguageChange:p,isLanguageSelectorEnabled:v=!0,className:m,testId:S,...g}=t,y=!v||!h||c.length===0,[x,b]=w.useState(!1),k=w.useRef(null);w.useEffect(()=>{const O=G=>{const L=G.composedPath();x&&k.current&&!L.includes(k.current)&&b(!1)},U=G=>{G.key==="Escape"&&x&&b(!1)};if(x)return document.addEventListener("mousedown",O),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",U)}},[x]);const T=w.useCallback(()=>{a()},[a]),C=w.useCallback(()=>{s()},[s]),R=w.useCallback(()=>{b(!0)},[]),A=w.useCallback(()=>{b(!1),l()},[l]),N=w.useCallback(()=>{b(!1)},[]);return f.jsx("div",{...g,className:le(pn.controlBar,m),"data-testid":S,children:f.jsxs(Ab,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(np,{icon:e?f.jsx(dE,{size:18}):f.jsx(hE,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:T,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(np,{icon:f.jsx(lE,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),f.jsx(np,{icon:f.jsx(fE,{}),label:"Screen share",iconOnly:!0,className:pn.screenShareButton,isOn:i,onClick:C,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),f.jsx(xE,{languages:c,value:u,onChange:p,defaultLanguageCode:d,variant:"pip",disabled:y}),f.jsxs("div",{ref:k,className:pn.popoverAnchor,children:[f.jsx(np,{icon:f.jsx(uE,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:R,"aria-label":"Hang up"}),x?f.jsxs("div",{className:pn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:pn.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:pn.confirmationActions,children:[f.jsx("button",{type:"button",className:le(pn.confirmationButton,pn.confirmationButtonCancel),onClick:N,children:"Cancel"}),f.jsx("button",{type:"button",className:le(pn.confirmationButton,pn.confirmationButtonDanger),onClick:A,children:"Leave"})]})]}):null]})]})})}function PF(t){return f.jsx(DF,{...t})}const LF="_container_zht0b_1",IF="_containerGradient_zht0b_14",jF="_containerFlat_zht0b_24",BF="_halo_zht0b_28",UF="_outerRing_zht0b_38",zF="_circle_zht0b_42",FF="_image_zht0b_72",qF="_captionContainer_zht0b_88",HF="_captionRegion_zht0b_99",ba={container:LF,containerGradient:IF,containerFlat:jF,halo:BF,outerRing:UF,circle:zF,image:FF,captionContainer:qF,captionRegion:HF},VF="_statusText_1dkze_6",GF={statusText:VF},WF={idle:null,thinking:"Thinking...",searching:"Searching..."};function YF(t){const{status:e,size:n="md"}=t,i=e?WF[e]:null,r=i!==null;return f.jsx("div",{className:GF.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const KF="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",XF={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 n3(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=KF,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=XF[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},T=l!=null&&l!=="";return f.jsxs("div",{...d,className:le(ba.container,i==="gradient"?ba.containerGradient:ba.containerFlat,c),style:b,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[f.jsxs("div",{className:ba.halo,style:k,children:[f.jsx("div",{className:ba.outerRing,"aria-hidden":"true"}),f.jsx("div",{className:ba.circle,children:f.jsx("img",{className:ba.image,src:r,alt:"","aria-hidden":"true"})}),f.jsx(YF,{status:s,size:n})]}),T&&f.jsx("div",{className:ba.captionContainer,children:f.jsx("div",{className:ba.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const $F="_container_1k3qg_11",QF="_screenshot_1k3qg_20",JF="_flash_1k3qg_30",Ob={container:$F,screenshot:QF,flash:JF};function ZF(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=w.useState(!1),s=w.useRef(null),l=w.useRef(i);return w.useEffect(()=>{l.current=i},[i]),w.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:Ob.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&f.jsx("img",{src:n,alt:"Captured screenshot",className:Ob.screenshot}),f.jsx("div",{className:Ob.flash})]}):null}const eq="_container_13ukq_1",tq="_dragging_13ukq_5",nq="_placeholder_13ukq_9",iq="_handleButton_13ukq_15",rq="_customHandle_13ukq_105",Tl={container:eq,dragging:tq,placeholder:nq,handleButton:iq,"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:rq};function aq(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=w.useState(!1),o=w.useRef(null),s=w.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=w.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=w.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return w.useEffect(()=>{i&&l()},[i,l]),w.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function oq(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=w.useRef(null),[a,o]=w.useState(!!e),[s,l]=w.useState(!1),[c,u]=w.useState(null),[d,h]=w.useState(()=>e??{x:0,y:0}),p=w.useRef(d);s||(p.current=d);const v=w.useRef(null),m=w.useRef(!1),S=w.useRef(!1);w.useEffect(()=>{e&&(S.current||(o(!0),h(e),p.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),w.useEffect(()=>{if(e||m.current)return;const b=r.current;if(!b)return;const k=b.getBoundingClientRect(),T={x:k.left,y:k.top};m.current=!0,o(!0),h(T),p.current=T,u(n?{width:k.width,height:k.height}:null)},[e,n]);const g=w.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=w.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=w.useCallback(b=>{const k=v.current;if(!k||b.pointerId!==k.pointerId)return;const T={x:k.startX+(b.clientX-k.startClientX),y:k.startY+(b.clientY-k.startClientY)};p.current=T,r.current&&(r.current.style.transform=`translate3d(${T.x}px, ${T.y}px, 0)`),i==null||i(T)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:y,onPointerMove:x,endDrag:g}}function sq(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}=oq({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:k,showHandle:T,scheduleHideHandle:C}=aq({disabled:a,lingerMs:u,isDragging:m}),R=typeof e=="function",A=w.useMemo(()=>{const O=U=>f.jsx("div",{className:le(Tl.customHandle,U.className),onPointerDown:y,onPointerMove:x,onPointerUp:b,onPointerCancel:b,children:U.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:Tl.placeholder,style:{width:g.width,height:g.height}}):null,f.jsxs("div",{ref:p,className:le(Tl.container,m?Tl.dragging:null,n),"data-handle-visible":R?void 0:a?"false":k||m?"true":"false",style:N,onMouseEnter:R?void 0:T,onMouseLeave:R?void 0:C,...h,children:[!R&&!a?f.jsx("button",{type:"button",className:le(Tl.handleButton,Tl[`handle-${i}`]),"aria-label":c,onMouseEnter:T,onMouseLeave:C,onPointerDown:O=>{T(),y(O)},onPointerMove:x,onPointerUp:b,onPointerCancel:b}):null,R?e({Handle:A}):e]})]})}const lq="_container_gzwdo_1",cq="_captionRegion_gzwdo_14",uq="_status_gzwdo_22",dq="_captionText_gzwdo_29",ip={container:lq,captionRegion:cq,status:uq,captionText:dq},hq={idle:null,thinking:"Thinking...",searching:"Searching..."};function fq(t){const{text:e,status:n,className:i,...r}=t,a=n?hq[n]:null;return f.jsx("div",{...r,className:le(ip.container,i),"data-testid":"pip-captions-panel",children:f.jsxs("div",{className:ip.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?f.jsx("div",{className:ip.status,children:a}):null,f.jsx("div",{className:ip.captionText,children:e})]})})}const pq="_panel_1pokp_1",mq="_row_1pokp_21",gq="_stepContent_1pokp_27",vq="_stepLabel_1pokp_35",bq="_currentStep_1pokp_42",yq="_nextStep_1pokp_49",_q="_skipButtonContainer_1pokp_63",xq="_circleButton_1pokp_71",Sq="_arrowPlaceholder_1pokp_98",kq="_skipButton_1pokp_63",Ki={panel:pq,row:mq,stepContent:gq,stepLabel:vq,currentStep:bq,nextStep:yq,skipButtonContainer:_q,circleButton:xq,arrowPlaceholder:Sq,skipButton:kq},Tq="_truncatedText_1u580_1",wq={truncatedText:Tq};function i3(t){const{children:e,maxLines:n=2,className:i,"data-testid":r}=t;return f.jsx("div",{className:`${wq.truncatedText} ${i||""}`,style:{WebkitLineClamp:n},"data-testid":r,children:e})}function Cq(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 Mb(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function Eq(t){var C;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=w.useMemo(()=>Cq(e,n,r),[n,r,e]),[u,d]=w.useState(()=>Mb(n,l.length)),h=w.useRef(!1);w.useEffect(()=>{if(!h.current)d(Mb(n,l.length));else{const R=Mb(n,l.length);u===R&&(h.current=!1)}},[n,l,u]);const p=l.length,v=l[u],m=u>0,S=u<p-1,g=S?(C=l[u+1])==null?void 0:C.title:void 0,y=p===0?0:u+1,x=c!==null&&v&&u!==c,b=()=>{m&&(h.current=!0,d(R=>Math.max(R-1,0)))},k=()=>{S&&(h.current=!0,d(R=>Math.min(R+1,p-1)))},T=()=>{!x||!v||!i||(h.current=!1,i(u,v))};return f.jsxs("div",{...s,className:le(Ki.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[f.jsxs("div",{className:Ki.row,children:[m?f.jsx("button",{type:"button",className:Ki.circleButton,"aria-label":"Previous step",onClick:b,children:f.jsx(_B,{size:14})}):f.jsx("span",{className:Ki.arrowPlaceholder,"aria-hidden":"true"}),f.jsxs("div",{className:Ki.stepContent,children:[f.jsxs(hi,{className:Ki.stepLabel,"aria-live":"polite",children:["Step ",y,"/",p]}),f.jsx(i3,{maxLines:2,children:f.jsx(hi,{className:Ki.currentStep,"data-testid":"pip-outline-current-step",children:(v==null?void 0:v.title)??"No steps available"})}),g?f.jsx(i3,{maxLines:2,children:f.jsxs(hi,{variant:"muted",className:Ki.nextStep,children:["Next: ",g]})}):null]}),S?f.jsx("button",{type:"button",className:Ki.circleButton,"aria-label":"Next step",onClick:k,children:f.jsx(xB,{size:14})}):f.jsx("span",{className:Ki.arrowPlaceholder,"aria-hidden":"true"})]}),x?f.jsx("div",{className:Ki.skipButtonContainer,children:f.jsx("button",{type:"button",className:Ki.skipButton,"aria-label":"Skip to this step",onClick:T,children:f.jsx(CB,{size:14})})}):null]})}const Rq="_window_1itr6_1",Aq="_exitButton_1itr6_14",Nq="_content_1itr6_47",Oq="_contentTopOverlay_1itr6_57",Mq="_dragHandle_1itr6_67",Dq="_contentBottomOverlay_1itr6_77",Pq="_controls_1itr6_86",ns={window:Rq,exitButton:Aq,content:Nq,contentTopOverlay:Oq,dragHandle:Mq,contentBottomOverlay:Dq,controls:Pq};function Lq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function Iq(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&&Lq(y),[b,k]=w.useState(!1),T=w.useRef(h),C=w.useCallback(()=>{k(!1)},[]);w.useEffect(()=>{h&&h>0&&h!==T.current&&k(!0),T.current=h},[h]);const R=w.useCallback(()=>f.jsx(n3,{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(Eq,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):R():g?l:x?f.jsx(fq,{text:y}):R();return f.jsxs("div",{...m,className:le(ns.window,p),"data-testid":v,role:"group","aria-label":"Picture-in-Picture",children:[f.jsxs("div",{className:ns.content,children:[f.jsx("div",{className:ns.contentTopOverlay,children:u}),f.jsx("button",{type:"button",className:ns.exitButton,onClick:e,"aria-label":"Exit PiP",children:f.jsx(kB,{size:14})}),A,!g&&f.jsxs("div",{className:ns.contentBottomOverlay,children:[f.jsx(Vf,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:f.jsx(EB,{size:18})}),f.jsx(Vf,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:f.jsx(yB,{size:18})})]}),f.jsx(ZF,{isActive:b,imageUrl:d??null,onComplete:C})]}),f.jsx("div",{className:ns.controls,children:f.jsx(PF,{...n})})]})}function jq(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return f.jsx(sq,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>f.jsx(Iq,{...r,contentTopOverlaySlot:f.jsx(a,{className:ns.dragHandle})})})}const Bq="_root_ygi3o_1",Uq="_overlay_ygi3o_7",zq="_caption_ygi3o_17",Db={root:Bq,overlay:Uq,caption:zq};function Fq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function qq(t){const{children:e,className:n,text:i}=t,r=Fq(i);return f.jsxs("div",{className:le(Db.root,n),children:[e,r?f.jsx("div",{className:Db.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:f.jsx("div",{className:Db.caption,children:i})}):null]})}const Hq="_box_dc9yv_1",Vq={box:Hq},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 Gq(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 Wq(t){if(t!==void 0){if(t in a3)return a3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Yq(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:T,radiusTop:C,radiusBottom:R,radiusLeft:A,radiusRight:N,radiusTopLeft:O,radiusTopRight:U,radiusBottomLeft:G,radiusBottomRight:L,background:W,gap:P,style:X,...J}=t,re=n??"div",$={...X},F=$,Z={},K=(B,de)=>{if(de===void 0)return;const ge=gr(de);ge&&($[B]=ge)},se=(B,de)=>{if(de===void 0)return;const ge=gr(de);ge&&($[B]=ge)},j=(B,de)=>{if(de===void 0)return;const ge=Gq(de);ge&&($[B]=ge)},me={sm:d,md:h,lg:p,xl:v};if(r!==void 0){const B=gr(r);B&&(F["--box-padding"]=B)}for(const[B,de]of Object.entries(me)){if(de===void 0)continue;const ge=gr(de);ge&&(F[`--box-padding-${B}`]=ge,Z[`data-padding-${B}`]="")}if(a!==void 0){const B=gr(a);B&&($.paddingLeft=B,$.paddingRight=B)}if(o!==void 0){const B=gr(o);B&&($.paddingTop=B,$.paddingBottom=B)}if(K("paddingTop",s),K("paddingBottom",l),K("paddingLeft",c),K("paddingRight",u),m!==void 0){const B=gr(m);B&&($.margin=B)}if(S!==void 0){const B=gr(S);B&&($.marginLeft=B,$.marginRight=B)}if(g!==void 0){const B=gr(g);B&&($.marginTop=B,$.marginBottom=B)}if(se("marginTop",y),se("marginBottom",x),se("marginLeft",b),se("marginRight",k),P!==void 0){const B=gr(P);B&&($.gap=B)}if(j("borderRadius",T),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",U),j("borderBottomLeftRadius",G),j("borderBottomRightRadius",L),W!==void 0){const B=Wq(W);B&&($.background=B)}return f.jsx(re,{ref:e,className:le(Vq.box,i),style:$,...Z,...J})}const rp=ii.forwardRef(Yq);rp.displayName="Box";const Kq="_panel_eawk4_1",Xq="_selected_eawk4_10",o3={panel:Kq,selected:Xq};function yu(t){const{children:e,className:n,selected:i,...r}=t;return f.jsx("div",{className:le(o3.panel,i?o3.selected:null,n),...r,children:e})}const $q="_root_yccm8_1",Qq="_header_yccm8_8",Jq="_icon_yccm8_15",Zq="_text_yccm8_26",eH="_heading_yccm8_33",tH="_description_yccm8_41",nH="_body_yccm8_47",iH="_footer_yccm8_54",yo={root:$q,header:Qq,icon:Jq,text:Zq,heading:eH,description:tH,body:nH,footer:iH};function s3(t){const{className:e,...n}=t;return f.jsx("div",{className:le(yo.icon,e),...n})}function l3(t){const{className:e,...n}=t;return f.jsx("h3",{className:le(yo.heading,e),...n})}function c3(t){const{className:e,...n}=t;return f.jsx("p",{className:le(yo.description,e),...n})}function u3(t){const{className:e,...n}=t;return f.jsx("div",{className:le(yo.footer,e),...n})}function rH(t){const e=w.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(w.isValidElement(s)&&s.type===s3&&i===void 0){i=s;continue}if(w.isValidElement(s)&&s.type===l3&&r===void 0){r=s;continue}if(w.isValidElement(s)&&s.type===c3&&a===void 0){a=s;continue}if(w.isValidElement(s)&&s.type===u3&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function aH(t){const{children:e,className:n,...i}=t,r=rH(e),a=r.icon||r.heading||r.description;return f.jsxs(yu,{className:le(yo.root,n),...i,children:[a?f.jsxs("div",{className:yo.header,children:[r.icon,r.heading||r.description?f.jsxs("div",{className:yo.text,children:[r.heading,r.description]}):null]}):null,r.body.length?f.jsx("div",{className:yo.body,children:r.body}):null,r.footer]})}const Pb=Object.assign(aH,{Icon:s3,Heading:l3,Description:c3,Footer:u3}),oH="_panel_1uwhd_1",sH="_header_1uwhd_11",lH="_title_1uwhd_19",cH="_scrollArea_1uwhd_29",uH="_scrollable_1uwhd_34",dH="_list_1uwhd_38",hH="_courseButton_1uwhd_44",fH="_courseCard_1uwhd_55",pH="_courseHeading_1uwhd_64",mH="_courseDescription_1uwhd_70",gH="_empty_1uwhd_79",vr={panel:oH,header:sH,title:lH,scrollArea:cH,scrollable:uH,list:dH,courseButton:hH,courseCard:fH,courseHeading:pH,courseDescription:mH,empty:gH};function vH(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=w.useState(()=>i??[]),l=a?n:o,c=w.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=w.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 bH(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,emptyMessage:l="No courses available",testId:c,...u}=t;return f.jsxs(yu,{...u,className:le(vr.panel,i),role:"region","aria-label":n??e,"data-testid":c,children:[f.jsx("div",{className:vr.header,children:f.jsx(hi,{as:"h2",className:vr.title,children:e})}),f.jsx("div",{className:vr.scrollArea,children:f.jsx(Sl,{className:vr.scrollable,children:r.length===0?f.jsx(hi,{variant:"muted",className:vr.empty,"data-testid":"course-panel-empty",children:l}):f.jsx("div",{className:vr.list,"data-testid":"course-panel-list",children:r.map(d=>{const h=o.includes(d.id),p=d.disabled===!0;return f.jsx("button",{type:"button",className:vr.courseButton,"aria-pressed":h,"aria-disabled":p,disabled:p,onClick:()=>s==null?void 0:s(d.id,d),"data-testid":`course-panel-item-${d.id}`,children:f.jsxs(Pb,{selected:h,className:vr.courseCard,children:[f.jsx(Pb.Heading,{className:vr.courseHeading,children:d.title}),d.description?f.jsx(Pb.Description,{className:vr.courseDescription,children:d.description}):null]})},d.id)})})})})]})}function yH(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=vH({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=w.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return f.jsx(bH,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const _H="_panel_1on05_1",xH="_header_1on05_11",SH="_divider_1on05_19",kH="_title_1on05_25",TH="_scrollArea_1on05_35",wH="_scrollable_1on05_40",CH="_list_1on05_44",EH="_section_1on05_50",RH="_sectionHeader_1on05_56",AH="_sectionTitle_1on05_60",NH="_sectionTitleCompact_1on05_68",OH="_item_1on05_72",MH="_itemClickable_1on05_86",DH="_itemCompleted_1on05_90",PH="_itemCurrent_1on05_94",LH="_itemFuture_1on05_98",IH="_itemDisabled_1on05_103",jH="_row_1on05_117",BH="_stepHeader_1on05_124",UH="_stepNumber_1on05_133",zH="_stepTitle_1on05_139",FH="_checkIcon_1on05_151",qH="_empty_1on05_155",Qe={panel:_H,header:xH,divider:SH,title:kH,scrollArea:TH,scrollable:wH,list:CH,section:EH,sectionHeader:RH,sectionTitle:AH,sectionTitleCompact:NH,item:OH,itemClickable:MH,itemCompleted:DH,itemCurrent:PH,itemFuture:LH,itemDisabled:IH,row:jH,stepHeader:BH,stepNumber:UH,stepTitle:zH,checkIcon:FH,empty:qH};function HH(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 VH(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,...d}=t,h=w.useCallback(x=>(x+1).toString().padStart(2,"0"),[]),{visibleSteps:p,completedIndices:v,currentIndex:m,futureIndices:S}=w.useMemo(()=>HH({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),g=c==="compact"?"md":"lg",y=w.useCallback((x,b)=>{const k=p[x];if(!k)return null;const T=typeof o=="function",C=T&&k.disabled===!0,R=T&&!C,A=le(Qe.item,{[Qe.itemClickable]:R,[Qe.itemCompleted]:b==="completed",[Qe.itemCurrent]:b==="current",[Qe.itemFuture]:b==="future",[Qe.itemDisabled]:C}),N=f.jsxs("div",{className:Qe.row,children:[f.jsxs("div",{className:Qe.stepHeader,children:[f.jsx("span",{className:Qe.stepNumber,children:h(x)}),f.jsx("span",{className:Qe.stepTitle,children:k.title})]}),b==="completed"?f.jsx(qf,{size:20,className:Qe.checkIcon}):null]});return T?f.jsx(rp,{as:"button",type:"button",className:A,onClick:()=>{R&&o(x,k)},disabled:C,"aria-current":b==="current"?"step":void 0,"aria-label":`Step ${h(x)}: ${k.title}`,"data-testid":`course-outline-item-${k.id}`,padding:g,radius:"panel",gap:"sm",children:N},k.id):f.jsx(rp,{className:A,"aria-current":b==="current"?"step":void 0,"aria-label":`Step ${h(x)}: ${k.title}`,"data-testid":`course-outline-item-${k.id}`,padding:g,radius:"panel",gap:"sm",children:N},k.id)},[h,g,o,p]);return f.jsxs(yu,{...d,className:le(Qe.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsx("div",{className:Qe.header,children:f.jsx(hi,{as:"h2",className:Qe.title,children:e})}),f.jsx("div",{className:Qe.divider,"aria-hidden":"true"}),f.jsx("div",{className:Qe.scrollArea,children:f.jsx(Sl,{className:Qe.scrollable,children:p.length===0?f.jsx(hi,{variant:"muted",className:Qe.empty,"data-testid":"course-outline-empty",children:l}):f.jsxs("div",{className:Qe.list,"data-testid":"course-outline-list",children:[v.length>0?f.jsxs("div",{className:Qe.section,"data-testid":"course-outline-section-completed",children:[f.jsx("div",{className:Qe.sectionHeader,children:f.jsx("span",{className:le(Qe.sectionTitle,c==="compact"?Qe.sectionTitleCompact:null),children:"Completed"})}),v.map(x=>y(x,"completed"))]}):null,m!==null?f.jsxs("div",{className:Qe.section,"data-testid":"course-outline-section-current",children:[f.jsx("div",{className:Qe.sectionHeader,children:f.jsx("span",{className:le(Qe.sectionTitle,c==="compact"?Qe.sectionTitleCompact:null),children:"Current"})}),y(m,"current")]}):null,S.length>0?f.jsxs("div",{className:Qe.section,"data-testid":"course-outline-section-upcoming",children:[f.jsx("div",{className:Qe.sectionHeader,children:f.jsx("span",{className:le(Qe.sectionTitle,c==="compact"?Qe.sectionTitleCompact:null),children:"Upcoming"})}),S.map(x=>y(x,"future"))]}):null]})})})]})}function GH(t){return f.jsx(VH,{...t})}const WH="_panel_h7cuf_1",YH="_messagesArea_h7cuf_20",KH="_messagesList_h7cuf_46",XH="_messageItem_h7cuf_53",$H="_messageMetadata_h7cuf_59",QH="_senderName_h7cuf_67",JH="_timestamp_h7cuf_71",ZH="_messageBubble_h7cuf_75",eV="_agentMessage_h7cuf_85",tV="_agentActions_h7cuf_89",nV="_copyButton_h7cuf_95",iV="_copyButtonCopied_h7cuf_129",rV="_empty_h7cuf_133",aV="_composer_h7cuf_140",oV="_composerDisabled_h7cuf_160",sV="_composerInput_h7cuf_165",lV="_sendButton_h7cuf_180",An={panel:WH,messagesArea:YH,messagesList:KH,messageItem:XH,messageMetadata:$H,senderName:QH,timestamp:JH,messageBubble:ZH,agentMessage:eV,agentActions:tV,copyButton:nV,copyButtonCopied:iV,empty:rV,composer:aV,composerDisabled:oV,composerInput:sV,sendButton:lV};function cV(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 uV(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 dV(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 hV(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 fV(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=w.useState(""),[d,h]=w.useState(null),p=w.useRef(null),v=w.useRef(null),m=w.useMemo(()=>{const b=e[e.length-1];return b?b.id??`${b.timestamp}-${e.length-1}`:null},[e]);w.useEffect(()=>{var b,k;(k=(b=p.current)==null?void 0:b.scrollIntoView)==null||k.call(b,{behavior:"smooth"})},[m]),w.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]);const S=w.useCallback(async()=>{const b=c.trim();b.length!==0&&(await i(b),u(""))},[c,i]),g=w.useCallback(b=>{b.key==="Enter"&&(b.preventDefault(),S())},[S]),y=w.useCallback(async(b,k)=>{try{await hV(b.message??""),h(k),v.current&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{h(null),v.current=null},2e3)}catch(T){console.warn("[PiPChatPanel] Failed to copy message",T)}},[]),x=c.trim().length>0&&!r;return f.jsxs("div",{...l,className:le(An.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[f.jsx("div",{className:An.messagesArea,children:e.length===0?f.jsx("div",{className:An.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):f.jsxs("div",{className:An.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((b,k)=>{const T=b.id??`${b.timestamp}-${k}`,C=uV(b,n),R=d===T;return f.jsxs("div",{className:le(An.messageItem,C&&An.agentMessage),"data-testid":`pip-chat-panel-message-${T}`,children:[f.jsxs("div",{className:An.messageMetadata,children:[f.jsx("span",{className:An.senderName,children:dV(b,n)}),f.jsx("span",{className:An.timestamp,children:cV(b.timestamp)})]}),f.jsx("div",{className:An.messageBubble,children:b.message}),C?f.jsx("div",{className:An.agentActions,children:f.jsx("button",{type:"button",className:le(An.copyButton,R&&An.copyButtonCopied),onClick:()=>void y(b,T),"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(cE,{size:14})})}):null]},T)}),f.jsx("div",{ref:p})]})}),f.jsxs("div",{className:le(An.composer,r&&An.composerDisabled),children:[f.jsx("input",{type:"text",className:An.composerInput,value:c,onChange:b=>u(b.target.value),onKeyDown:g,placeholder:a,disabled:r,"aria-label":"Message"}),f.jsx("button",{type:"button",className:An.sendButton,onClick:()=>void S(),disabled:!x,"aria-label":"Send message",children:f.jsx(pE,{size:16})})]})]})}const pV="_panel_k5ick_1",mV="_header_k5ick_11",gV="_title_k5ick_19",vV="_titleCompact_k5ick_29",bV="_headerActions_k5ick_33",yV="_closeButton_k5ick_39",_V="_divider_k5ick_67",xV="_body_k5ick_73",SV="_messagesArea_k5ick_81",kV="_scrollable_k5ick_86",TV="_messagesList_k5ick_90",wV="_messageItem_k5ick_98",CV="_messageMetadata_k5ick_104",EV="_senderName_k5ick_112",RV="_timestamp_k5ick_116",AV="_messageBubble_k5ick_120",NV="_messageText_k5ick_124",OV="_agentMessage_k5ick_130",MV="_agentActions_k5ick_134",DV="_copyButton_k5ick_140",PV="_copyButtonCopied_k5ick_174",LV="_inputRow_k5ick_178",IV="_empty_k5ick_182",jV="_composer_k5ick_188",BV="_composerDefault_k5ick_203",UV="_composerCompact_k5ick_208",zV="_composerDisabled_k5ick_218",FV="_composerInputWrapper_k5ick_223",qV="_composerInput_k5ick_223",HV="_sendButton_k5ick_240",VV="_sendButtonCompact_k5ick_257",Je={panel:pV,header:mV,title:gV,titleCompact:vV,headerActions:bV,closeButton:yV,divider:_V,body:xV,messagesArea:SV,scrollable:kV,messagesList:TV,messageItem:wV,messageMetadata:CV,senderName:EV,timestamp:RV,messageBubble:AV,messageText:NV,agentMessage:OV,agentActions:MV,copyButton:DV,copyButtonCopied:PV,inputRow:LV,empty:IV,composer:jV,composerDefault:BV,composerCompact:UV,composerDisabled:zV,composerInputWrapper:FV,composerInput:qV,sendButton:HV,sendButtonCompact:VV};function GV(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 WV(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 YV(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 KV(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 XV(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=w.useState(""),l=w.useCallback(async()=>{const p=o.trim();p.length!==0&&(await a(p),s(""))},[a,o]),c=w.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:le(Je.composer,u?Je.composerCompact:Je.composerDefault,e?Je.composerDisabled:null),children:[f.jsx("div",{className:Je.composerInputWrapper,children:f.jsx(gE,{value:o,onChange:s,onKeyDown:c,className:Je.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),f.jsx("button",{type:"button",className:le(Je.sendButton,u?Je.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:f.jsx(pE,{size:d})})]})}function d3(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=GV,getSenderName:v,isAgentMessage:m,copyResetDelayMs:S=2e3,showAgentCopyButton:g=!0,inputPlaceholder:y,inputAutoFocus:x,...b}=t,k=w.useRef(null),[T,C]=w.useState(null),R=w.useRef(null),A=w.useCallback(W=>v?v(W):YV(W,o),[v,o]),N=w.useCallback(W=>m?m(W,o):WV(W,o),[m,o]),O=w.useMemo(()=>{const W=r[r.length-1];return W?W.id??`${W.timestamp}-${r.length-1}`:null},[r]);w.useEffect(()=>{var W,P;(P=(W=k.current)==null?void 0:W.scrollIntoView)==null||P.call(W,{behavior:"smooth"})},[O]),w.useEffect(()=>()=>{R.current&&(window.clearTimeout(R.current),R.current=null)},[]);const U=w.useCallback(W=>{C(W),R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{C(null),R.current=null},S)},[S]),G=w.useCallback(async(W,P)=>{try{await KV(W.message??""),U(P)}catch(X){console.warn("[ChatPanel] Failed to copy message",X)}},[U]),L=d==="compact"?"sm":"md";return f.jsxs(yu,{...b,className:le(Je.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[f.jsxs("div",{className:Je.header,children:[f.jsx(hi,{as:"h2",className:le(Je.title,d==="compact"?Je.titleCompact:null),children:e}),l&&c?f.jsx("div",{className:Je.headerActions,children:f.jsx("button",{type:"button",className:Je.closeButton,onClick:l,"aria-label":`Close ${e}`,children:f.jsx(Hf,{size:d==="compact"?18:20})})}):null]}),f.jsx("div",{className:Je.divider,"aria-hidden":"true"}),f.jsxs("div",{className:Je.body,children:[f.jsx("div",{className:Je.messagesArea,children:f.jsx(Sl,{className:Je.scrollable,children:r.length===0?f.jsx(hi,{variant:"muted",className:Je.empty,"data-testid":"chat-panel-empty",children:u}):f.jsxs("div",{className:Je.messagesList,"data-testid":"chat-panel-list",children:[r.map((W,P)=>{const X=W.id??`${W.timestamp}-${P}`,J=N(W),re=T===X;return f.jsxs("div",{className:le(Je.messageItem,J?Je.agentMessage:null),"data-testid":`chat-panel-message-${X}`,children:[f.jsxs("div",{className:Je.messageMetadata,children:[f.jsx("span",{className:Je.senderName,children:A(W)}),f.jsx("span",{className:Je.timestamp,children:p(W.timestamp)})]}),f.jsx(rp,{className:Je.messageBubble,padding:"md",radius:"panel",background:J?"surfaceMuted":"surface",children:f.jsx("div",{className:Je.messageText,children:W.message})}),J&&g?f.jsx("div",{className:Je.agentActions,children:f.jsx("button",{type:"button",className:le(Je.copyButton,re?Je.copyButtonCopied:null),onClick:()=>void G(W,X),"aria-label":re?"Copied":"Copy agent message",title:re?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":re?"true":"false",children:f.jsx(cE,{size:18})})}):null]},X)}),f.jsx("div",{ref:k})]})})}),f.jsx("div",{className:Je.inputRow,children:f.jsx(XV,{onSend:s,disabled:a,placeholder:y,size:L,autoFocus:x})})]})]})}const $V="_responsive_14d0j_2",_u={responsive:$V,"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 QV(t){const{as:e,children:n,showAboveWidth:i,hideAboveWidth:r,showAboveHeight:a,hideAboveHeight:o,className:s,...l}=t,c=[_u.responsive];return i&&c.push(_u[`showAboveWidth-${i}`]),r&&c.push(_u[`hideAboveWidth-${r}`]),a&&c.push(_u[`showAboveHeight-${a}`]),o&&c.push(_u[`hideAboveHeight-${o}`]),f.jsx(e??"div",{...l,className:le(c,s),children:n})}w.createContext("vertical");const JV="_container_1a1i6_1",ZV="_video_1a1i6_7",eG="_chip_1a1i6_16",tG="_logo_1a1i6_34",ap={container:JV,video:ZV,chip:eG,logo:tG},nG="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function iG(t){const{agentName:e="Obi",className:n,...i}=t,r=w.useRef(null),a=()=>{var o;try{(o=r.current)==null||o.pause()}catch{}};return f.jsxs("div",{className:le(ap.container,n),...i,children:[f.jsx("video",{ref:r,className:ap.video,src:nG,autoPlay:!0,muted:!0,playsInline:!0,onEnded:a}),f.jsxs("div",{className:ap.chip,children:[f.jsx(TB,{size:14,className:ap.logo}),f.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const h3=50,wl="?",f3=/\(error: (.*)\)/,p3=/captureMessage|captureException/;function rG(...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(`
133
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=f3.test(l)?l.replace(f3,"$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>=h3+r)break}}return aG(a.slice(r))}}function aG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(op(e).function||"")&&e.pop(),e.reverse(),p3.test(op(e).function||"")&&(e.pop(),p3.test(op(e).function||"")&&e.pop()),e.slice(0,h3).map(n=>({...n,filename:n.filename||op(e).filename,function:n.function||wl}))}function op(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const oG=30,sG=50;function Lb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?wl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const lG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,cG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,uG=/\((\S*)(?::(\d+))(?::(\d+))\)/,dG=t=>{const e=lG.exec(t);if(e){const[,i,r,a]=e;return Lb(i,wl,+r,+a)}const n=cG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=uG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=m3(n[1]||wl,n[2]);return Lb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},hG=[oG,dG],fG=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;rG(...[hG,[sG,t=>{const e=fG.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=pG.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]||wl;return[i,n]=m3(i,n),Lb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const m3=(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]:wl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Xi={shell:"_shell_1k5hq_1",layout:"_layout_1k5hq_11",layoutThree:"_layoutThree_1k5hq_23",leftPanel:"_leftPanel_1k5hq_27",middlePanel:"_middlePanel_1k5hq_36",rightPanel:"_rightPanel_1k5hq_37",videoFrame:"_videoFrame_1k5hq_41",captions:"_captions_1k5hq_52",controls:"_controls_1k5hq_58",coursePanel:"_coursePanel_1k5hq_71",returnToPiPOverlay:"_returnToPiPOverlay_1k5hq_82",returnToPiPButton:"_returnToPiPButton_1k5hq_95"};function Ib(...t){return t.filter(Boolean).join(" ")}function mG(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:Ib(Xi.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Ib(Xi.layout,u?Xi.layoutThree:null),children:[f.jsxs("div",{className:Xi.leftPanel,children:[f.jsxs("div",{className:Xi.videoFrame,children:[d&&h&&f.jsx("div",{className:Xi.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:Xi.returnToPiPButton,onClick:h,"aria-label":"Return to PiP",children:f.jsx(SB,{size:14})})}),f.jsx(qq,{className:Xi.captions,text:e,children:f.jsx(n3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:Xi.controls,children:f.jsx(mF,{...o})})]}),u?f.jsx("div",{className:Xi.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:Xi.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(yH,{...l,courses:s,className:Ib(Xi.coursePanel,l==null?void 0:l.className)})})]})})}function g3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(TE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mG,{...r})})}const gG=80,vG=500,bG=1e3;function yG(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]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.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 w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>gG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},vG+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},bG+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const br={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 _G(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}=t;return f.jsx(TE,{open:e,onClose:n,size:"large",showCloseButton:c,className:br.dialogWithSmallClose,children:f.jsxs("div",{className:br.layout,children:[f.jsxs("div",{className:br.left,children:[f.jsxs("div",{className:br.copy,children:[f.jsx(hi,{variant:"heading",children:r}),f.jsx(hi,{variant:"subheading",children:a}),f.jsx(hi,{variant:"muted",as:"div",className:br.description,children:f.jsx(Sl,{className:br.descriptionScroller,children:f.jsx(Dz,{content:o})})})]}),f.jsxs("div",{className:br.cta,children:[f.jsx(xl,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(hi,{variant:"subscript",as:"p",className:br.disclaimer,children:l})]})]}),f.jsx(QV,{showAboveWidth:"md",children:f.jsx("div",{className:br.right,children:f.jsx(yu,{className:br.mediaPanel,children:f.jsx(iG,{agentName:r,className:br.agentStill})})})})]})})}const xG={launcherPill:"_launcherPill_1fhyr_1"};function SG(t){const{onClick:e}=t;return f.jsx("button",{type:"button",className:xG.launcherPill,onClick:e,"data-testid":"ai-coach-pill",children:"AI Coach"})}function kG(t){var fi,Ei,ce,He,Ce,Ye,at,Kn,pi,yr,H,ie,ue,je,Re,ft,Xn,$i,ya,$n,Qn,Qi,mi;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((fi=e.client)==null?void 0:fi.selectedPlanUuid)??null:null,a=((Ei=e.client)==null?void 0:Ei.session)??null,[o,s]=w.useState(()=>a),[l,c]=w.useState(()=>a!=null&&a.sessionUuid?wG(a.sessionUuid):null),u=(()=>{var te;return a?((te=a.roomId)==null?void 0:te.startsWith("obs-"))&&!l?"course-selection":"pip":r?"start-session":"hidden"})(),[d,h]=w.useState(()=>u),[p,v]=w.useState(!1),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,b]=w.useState([]),[k,T]=w.useState(null),[C,R]=w.useState(0),[A,N]=w.useState(!1),[O,U]=w.useState(0),[G,L]=w.useState(null),[W,P]=w.useState([]),[X,J]=w.useState(!1),re=CG((He=(ce=e.client)==null?void 0:ce.product)==null?void 0:He.widget_url_blacklist),$=EG(o),{audioDevices:F}=RG();w.useEffect(()=>{o!=null&&o.sessionUuid&&v3(o.sessionUuid,l)},[l,o==null?void 0:o.sessionUuid]);const{caption:Z}=yG(W,{delayMs:0}),K=X?Z:"",se=typeof navigator<"u"&&!!((Ce=navigator.mediaDevices)!=null&&Ce.getDisplayMedia),j=((at=(Ye=o==null?void 0:o.room)==null?void 0:Ye.localParticipant)==null?void 0:at.isScreenShareEnabled)??!1,me=(()=>{if(o!=null&&o.speakingState){if(o.speakingState==="thinking")return"thinking";if(o.speakingState==="busy")return"searching"}})(),B=TG({sdk:e,session:o,isBlacklisted:re}),de=!i&&B,ge=!!(o??((Kn=e.client)==null?void 0:Kn.session)??null),Et=()=>R(te=>te+1),mn=async()=>{var _e,he;if(!o)return;const te=((he=(_e=o.room)==null?void 0:_e.localParticipant)==null?void 0:he.isScreenShareEnabled)??!1;try{te?await o.setScreenShareEnabled(!1):await o.shareScreen()}catch(Te){console.error("[obi-sdk] failed to toggle screen share",Te)}finally{Et()}},Se=w.useRef(null),ke=w.useRef(null),ct=w.useRef(!1),tt=te=>{if(!te||Se.current===te)return;ke.current&&(ke.current(),ke.current=null);const _e=()=>Et(),he=Rt=>{c(Rt),te!=null&&te.sessionUuid&&v3(te.sessionUuid,Rt),h(fe=>fe==="course-selection"?(N(!1),"pip"):fe)},Te=Rt=>{b(Rt.courses),h("course-selection"),c(null),te!=null&&te.sessionUuid&&b3(te.sessionUuid),T(null)},Vt=(Rt,fe)=>{},gt=Rt=>{L(Rt),U(Date.now())},Jt=Rt=>{if(!Rt){L(null);return}L(Rt),U(Date.now())};te.on("stateChanged",_e),te.on("speakingStateChanged",_e),te.on("paused",_e),te.on("unpaused",_e),te.on("chatMessagesChanged",_e),te.on("courseProgress",he),te.on("courseSelection",Te),te.on("transcript",Vt),te.on("screenCaptured",gt),te.on("screenCaptureNotification",Jt),te.on("captions",P),Se.current=te,ke.current=()=>{te.off("stateChanged",_e),te.off("speakingStateChanged",_e),te.off("paused",_e),te.off("unpaused",_e),te.off("chatMessagesChanged",_e),te.off("courseProgress",he),te.off("courseSelection",Te),te.off("transcript",Vt),te.off("screenCaptured",gt),te.off("screenCaptureNotification",Jt),te.off("captions",P)}},Qt=te=>{var he;return te?((he=te.roomId)==null?void 0:he.startsWith("obs-"))&&!l?"course-selection":"pip":"hidden"};w.useEffect(()=>{const te=he=>{var Te,Vt,gt,Jt;if(he)if((Te=e.client)!=null&&Te.session)h(Qt(((gt=e.client)==null?void 0:gt.session)??null));else{const fe=!!e.passivePlanUuid,kt=fe&&!!((Vt=e.client)!=null&&Vt.selectedPlanUuid);if(fe&&!kt)return;h("start-session")}else(Jt=e.client)!=null&&Jt.session||h("hidden")},_e=()=>Et();if(e.on("showMenu",te),e.on("configUpdated",_e),e.client){e.client.session&&(s(e.client.session),tt(e.client.session),h(Qt(e.client.session))),e.client.on("sessionStarted",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te)),Ha().track("session-started",{planId:Te.planId})}),e.client.on("sessionResumed",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te))});const he=()=>{var Vt;const Te=(Vt=e.client)==null?void 0:Vt.session;Te!=null&&Te.sessionUuid&&b3(Te.sessionUuid),ke.current&&(ke.current(),ke.current=null),s(null),Se.current=null,v(!1),S(!1),y(!1),ct.current||h("hidden")};e.client.on("sessionStopped",he),e.client.on("sessionShutdown",he),e.client.on("stateChanged",Et)}return()=>{e.off("showMenu",te),e.off("configUpdated",_e),ke.current&&ke.current()}},[e]),w.useLayoutEffect(()=>{var te,_e;(_e=(te=e.client)==null?void 0:te.product)!=null&&_e.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(yr=(pi=e.client)==null?void 0:pi.product)==null?void 0:yr.primary_color,n]),w.useEffect(()=>{if(i&&!re&&!ge){if(!r){h("hidden");return}h("start-session")}},[ge,i,re,r]);const gn=(l==null?void 0:l.stepNames.map((te,_e)=>({id:`step-${_e+1}`,title:te})))??[],Nt=(l==null?void 0:l.currentStep)??null,vn=!0,Nn=(te,_e)=>{o==null||o.say(`Can we jump to the section about ${_e.title}?`)};if(re||i&&!r&&!ge)return null;if(d==="hidden")return de?f.jsx(SG,{onClick:()=>{e.updateShowMenu(!0)}}):null;if(d==="start-session"){const te=(H=e.client)==null?void 0:H.product,_e=(ie=e.client)==null?void 0:ie.selectedPlan,he=i&&!!r,Te=(te==null?void 0:te.agent_name)||"Obi",Vt=(te==null?void 0:te.assistant_subtitle)||"AI Assistant",gt=he?(_e==null?void 0:_e.description)||(te==null?void 0:te.assistant_description)||(te==null?void 0:te.description)||"I'm here to help you.":(te==null?void 0:te.assistant_description)||(_e==null?void 0:_e.description)||(te==null?void 0:te.description)||"I'm here to help you.";return f.jsx(_G,{open:!0,onClose:()=>{v(!1),h("hidden")},onStart:()=>{v(!0),e.startSession({withMicrophone:!0})},agentName:Te,agentSubtitle:Vt,description:gt,showCloseButton:!0,startLabel:"Start Session",isStarting:p})}if(d==="course-selection"){const te=(ue=o==null?void 0:o.roomId)==null?void 0:ue.startsWith("obs-"),_e=((je=e.client)==null?void 0:je.plans)||[],he=te&&x.length>0,Te=he?x.slice().sort((fe,kt)=>fe.order!==void 0&&kt.order!==void 0?fe.order-kt.order:fe.order!==void 0?-1:kt.order!==void 0?1:fe.name.localeCompare(kt.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})):_e.map(fe=>{var kt,pt;return{id:fe.uuid,title:fe.name,description:fe.description,status:(pt=(kt=e.client)==null?void 0:kt.planIsCompleted)!=null&&pt[_e.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}}),Vt=(o==null?void 0:o.languageCodes)||[],gt=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,Jt={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),o&&fe&&await o.switchMicrophoneDevice(fe),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:Vt,selectedLanguage:gt,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Rt=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Re=o==null?void 0:o.room)==null?void 0:Re.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},onClose:()=>y(!1)}):void 0;return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:Te,controlBarProps:Jt,coursePanelProps:{selectedCourseIds:k?[k]:void 0,onCourseToggle:async fe=>{var kt,pt,At;if(he){const bn=x.find(Ri=>Ri.uuid===fe);if(bn){T(fe);try{await((kt=o==null?void 0:o.say)==null?void 0:kt.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),T(null)}}}else{const bn=_e.find(Ri=>Ri.uuid===fe);if(bn){(pt=e.client)==null||pt.selectPlan(bn),h("pip");try{await((At=o==null?void 0:o.say)==null?void 0:At.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),h("course-selection")}}}}},rightPanel:Rt,avatarImageSrc:((Xn=(ft=e.client)==null?void 0:ft.product)==null?void 0:Xn.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="course-outline"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async gt=>{e.client&&(e.client.preferredMicrophoneDeviceId=gt),o&&gt&&await o.switchMicrophoneDevice(gt),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:gt=>{o==null||o.setLanguage(gt)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Te=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:(($i=o==null?void 0:o.room)==null?void 0:$i.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async gt=>{var Jt,Rt,fe,kt;o&&(o.appendChatMessage({timestamp:Date.now(),message:gt,from:{identity:((Rt=(Jt=o.room)==null?void 0:Jt.localParticipant)==null?void 0:Rt.identity)??null,name:((kt=(fe=o.room)==null?void 0:fe.localParticipant)==null?void 0:kt.name)??null},isAgent:!1}),await o.say(gt))},onClose:()=>y(!1)}):void 0,Vt=f.jsx(GH,{steps:gn,currentStep:Nt,hideTrailingConclusionStep:vn,onStepClick:Nn});return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:[],controlBarProps:he,middlePanel:Vt,rightPanel:Te,avatarImageSrc:(($n=(ya=e.client)==null?void 0:ya.product)==null?void 0:$n.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="pip"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he=280,Te=250,Vt=16,gt={x:window.innerWidth-he-Vt,y:window.innerHeight-Te-Vt},Jt={isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isChatOpen:g,isScreenShareActive:j,onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>y(fe=>!fe),onScreenShareToggle:mn,onLeave:()=>{o==null||o.stop()},languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0},Rt=g?f.jsx(fV,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Qn=o==null?void 0:o.room)==null?void 0:Qn.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},testId:"pip-chat-panel"}):void 0;return f.jsx(jq,{initialPosition:gt,onExit:()=>{h("course-outline")},controlBarProps:Jt,isCourseOutlineSelected:A&&!!l,onCourseOutlineToggle:l?()=>{N(fe=>!fe)}:void 0,isCaptionsEnabled:X,onCaptionsToggle:()=>J(fe=>!fe),courseOutline:l?{steps:gn,currentStep:Nt,onStepClick:Nn,hideTrailingConclusionStep:vn}:void 0,messagesPanel:Rt,avatarFallbackProps:{audioPower:$,imageSrc:((mi=(Qi=e.client)==null?void 0:Qi.product)==null?void 0:mi.logo_url)??void 0,status:me,captionsText:K},screenshotUrl:G,cameraShotTrigger:O})}return null}function TG(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 v3(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 wG(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 b3(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 CG(t){const[e,n]=w.useState(()=>Zo(t));return w.useEffect(()=>{n(Zo(t))},[t]),w.useEffect(()=>{const i=()=>{n(Zo(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function EG(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.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 RG(){const[t,e]=w.useState({audioDevices:[]});return w.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 AG(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t==="getcor.ai"||t==="getcor.io"}const y3=AG();function NG(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;OG();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(lB);const a=[r];if(y3){const s=new CSSStyleSheet;s.replaceSync(aB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(sB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(oB),a.push(s)}n.adoptedStyleSheets=a;const o=rB.createRoot(i);y3?o.render(f.jsx(kG,{sdk:t,shadowHost:e})):o.render(f.jsx(dB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function OG(){_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 x3="49206C6F7665204F6269_session",S3="obi-url-params";class MG extends up{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=lh.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new lh(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,p,v;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((v=(p=this.client)==null?void 0:p.product)==null?void 0:v.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Zo(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{Ha().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){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),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&&Ha().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){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}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(S3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[x3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(x3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(S3),this.passivePlanUuid=n}mountWidget(){NG(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await QN(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await G3(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 AN(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")}}async function k3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return DG({appToken:t,window:n,init:e})}async function DG({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 MG(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function T3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{k3(void 0,T3)}):k3(void 0,T3)})();
133
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=f3.test(l)?l.replace(f3,"$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>=h3+r)break}}return aG(a.slice(r))}}function aG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(op(e).function||"")&&e.pop(),e.reverse(),p3.test(op(e).function||"")&&(e.pop(),p3.test(op(e).function||"")&&e.pop()),e.slice(0,h3).map(n=>({...n,filename:n.filename||op(e).filename,function:n.function||wl}))}function op(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const oG=30,sG=50;function Lb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?wl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const lG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,cG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,uG=/\((\S*)(?::(\d+))(?::(\d+))\)/,dG=t=>{const e=lG.exec(t);if(e){const[,i,r,a]=e;return Lb(i,wl,+r,+a)}const n=cG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=uG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=m3(n[1]||wl,n[2]);return Lb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},hG=[oG,dG],fG=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;rG(...[hG,[sG,t=>{const e=fG.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=pG.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]||wl;return[i,n]=m3(i,n),Lb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const m3=(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]:wl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Xi={shell:"_shell_1k5hq_1",layout:"_layout_1k5hq_11",layoutThree:"_layoutThree_1k5hq_23",leftPanel:"_leftPanel_1k5hq_27",middlePanel:"_middlePanel_1k5hq_36",rightPanel:"_rightPanel_1k5hq_37",videoFrame:"_videoFrame_1k5hq_41",captions:"_captions_1k5hq_52",controls:"_controls_1k5hq_58",coursePanel:"_coursePanel_1k5hq_71",returnToPiPOverlay:"_returnToPiPOverlay_1k5hq_82",returnToPiPButton:"_returnToPiPButton_1k5hq_95"};function Ib(...t){return t.filter(Boolean).join(" ")}function mG(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:Ib(Xi.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Ib(Xi.layout,u?Xi.layoutThree:null),children:[f.jsxs("div",{className:Xi.leftPanel,children:[f.jsxs("div",{className:Xi.videoFrame,children:[d&&h&&f.jsx("div",{className:Xi.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:Xi.returnToPiPButton,onClick:h,"aria-label":"Return to PiP",children:f.jsx(SB,{size:14})})}),f.jsx(qq,{className:Xi.captions,text:e,children:f.jsx(n3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:Xi.controls,children:f.jsx(mF,{...o})})]}),u?f.jsx("div",{className:Xi.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:Xi.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(yH,{...l,courses:s,className:Ib(Xi.coursePanel,l==null?void 0:l.className)})})]})})}function g3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(TE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mG,{...r})})}const gG=80,vG=500,bG=1e3;function yG(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]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.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 w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>gG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},vG+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},bG+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const br={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 _G(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}=t;return f.jsx(TE,{open:e,onClose:n,size:"large",showCloseButton:c,className:br.dialogWithSmallClose,children:f.jsxs("div",{className:br.layout,children:[f.jsxs("div",{className:br.left,children:[f.jsxs("div",{className:br.copy,children:[f.jsx(hi,{variant:"heading",children:r}),f.jsx(hi,{variant:"subheading",children:a}),f.jsx(hi,{variant:"muted",as:"div",className:br.description,children:f.jsx(Sl,{className:br.descriptionScroller,children:f.jsx(Dz,{content:o})})})]}),f.jsxs("div",{className:br.cta,children:[f.jsx(xl,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(hi,{variant:"subscript",as:"p",className:br.disclaimer,children:l})]})]}),f.jsx(QV,{showAboveWidth:"md",children:f.jsx("div",{className:br.right,children:f.jsx(yu,{className:br.mediaPanel,children:f.jsx(iG,{agentName:r,className:br.agentStill})})})})]})})}const xG={launcherPill:"_launcherPill_1fhyr_1"};function SG(t){const{onClick:e}=t;return f.jsx("button",{type:"button",className:xG.launcherPill,onClick:e,"data-testid":"ai-coach-pill",children:"AI Coach"})}function kG(t){var fi,Ei,ce,He,Ce,Ye,at,Kn,pi,yr,H,ie,ue,je,Re,ft,Xn,$i,ya,$n,Qn,Qi,mi;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((fi=e.client)==null?void 0:fi.selectedPlanUuid)??null:null,a=((Ei=e.client)==null?void 0:Ei.session)??null,[o,s]=w.useState(()=>a),[l,c]=w.useState(()=>a!=null&&a.sessionUuid?wG(a.sessionUuid):null),u=(()=>{var te;return a?((te=a.roomId)==null?void 0:te.startsWith("obs-"))&&!l?"course-selection":"pip":r?"start-session":"hidden"})(),[d,h]=w.useState(()=>u),[p,v]=w.useState(!1),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,b]=w.useState([]),[k,T]=w.useState(null),[C,R]=w.useState(0),[A,N]=w.useState(!1),[O,U]=w.useState(0),[G,L]=w.useState(null),[W,P]=w.useState([]),[X,J]=w.useState(!1),re=CG((He=(ce=e.client)==null?void 0:ce.product)==null?void 0:He.widget_url_blacklist),$=EG(o),{audioDevices:F}=RG();w.useEffect(()=>{o!=null&&o.sessionUuid&&v3(o.sessionUuid,l)},[l,o==null?void 0:o.sessionUuid]);const{caption:Z}=yG(W,{delayMs:0}),K=X?Z:"",se=typeof navigator<"u"&&!!((Ce=navigator.mediaDevices)!=null&&Ce.getDisplayMedia),j=((at=(Ye=o==null?void 0:o.room)==null?void 0:Ye.localParticipant)==null?void 0:at.isScreenShareEnabled)??!1,me=(()=>{if(o!=null&&o.speakingState){if(o.speakingState==="thinking")return"thinking";if(o.speakingState==="busy")return"searching"}})(),B=TG({sdk:e,session:o,isBlacklisted:re}),de=!i&&B,ge=!!(o??((Kn=e.client)==null?void 0:Kn.session)??null),Et=()=>R(te=>te+1),mn=async()=>{var _e,he;if(!o)return;const te=((he=(_e=o.room)==null?void 0:_e.localParticipant)==null?void 0:he.isScreenShareEnabled)??!1;try{te?await o.setScreenShareEnabled(!1):await o.shareScreen()}catch(Te){console.error("[obi-sdk] failed to toggle screen share",Te)}finally{Et()}},Se=w.useRef(null),ke=w.useRef(null),ct=w.useRef(!1),tt=te=>{if(!te||Se.current===te)return;ke.current&&(ke.current(),ke.current=null);const _e=()=>Et(),he=Rt=>{c(Rt),te!=null&&te.sessionUuid&&v3(te.sessionUuid,Rt),h(fe=>fe==="course-selection"?(N(!1),"pip"):fe)},Te=Rt=>{b(Rt.courses),h("course-selection"),c(null),te!=null&&te.sessionUuid&&b3(te.sessionUuid),T(null)},Vt=(Rt,fe)=>{},gt=Rt=>{L(Rt),U(Date.now())},Jt=Rt=>{if(!Rt){L(null);return}L(Rt),U(Date.now())};te.on("stateChanged",_e),te.on("speakingStateChanged",_e),te.on("paused",_e),te.on("unpaused",_e),te.on("chatMessagesChanged",_e),te.on("courseProgress",he),te.on("courseSelection",Te),te.on("transcript",Vt),te.on("screenCaptured",gt),te.on("screenCaptureNotification",Jt),te.on("captions",P),Se.current=te,ke.current=()=>{te.off("stateChanged",_e),te.off("speakingStateChanged",_e),te.off("paused",_e),te.off("unpaused",_e),te.off("chatMessagesChanged",_e),te.off("courseProgress",he),te.off("courseSelection",Te),te.off("transcript",Vt),te.off("screenCaptured",gt),te.off("screenCaptureNotification",Jt),te.off("captions",P)}},Qt=te=>{var he;return te?((he=te.roomId)==null?void 0:he.startsWith("obs-"))&&!l?"course-selection":"pip":"hidden"};w.useEffect(()=>{const te=he=>{var Te,Vt,gt,Jt;if(he)if((Te=e.client)!=null&&Te.session)h(Qt(((gt=e.client)==null?void 0:gt.session)??null));else{const fe=!!e.passivePlanUuid,kt=fe&&!!((Vt=e.client)!=null&&Vt.selectedPlanUuid);if(fe&&!kt)return;h("start-session")}else(Jt=e.client)!=null&&Jt.session||h("hidden")},_e=()=>Et();if(e.on("showMenu",te),e.on("configUpdated",_e),e.client){e.client.session&&(s(e.client.session),tt(e.client.session),h(Qt(e.client.session))),e.client.on("sessionStarted",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te)),Ha().track("session-started",{planId:Te.planId})}),e.client.on("sessionResumed",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te))});const he=()=>{var Vt;const Te=(Vt=e.client)==null?void 0:Vt.session;Te!=null&&Te.sessionUuid&&b3(Te.sessionUuid),ke.current&&(ke.current(),ke.current=null),s(null),Se.current=null,v(!1),S(!1),y(!1),ct.current||h("hidden")};e.client.on("sessionStopped",he),e.client.on("sessionShutdown",he),e.client.on("stateChanged",Et)}return()=>{e.off("showMenu",te),e.off("configUpdated",_e),ke.current&&ke.current()}},[e]),w.useLayoutEffect(()=>{var te,_e;(_e=(te=e.client)==null?void 0:te.product)!=null&&_e.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(yr=(pi=e.client)==null?void 0:pi.product)==null?void 0:yr.primary_color,n]),w.useEffect(()=>{if(i&&!re&&!ge){if(!r){h("hidden");return}h("start-session")}},[ge,i,re,r]);const gn=(l==null?void 0:l.stepNames.map((te,_e)=>({id:`step-${_e+1}`,title:te})))??[],Nt=(l==null?void 0:l.currentStep)??null,vn=!0,Nn=(te,_e)=>{o==null||o.say(`Can we jump to the section about ${_e.title}?`)};if(re||i&&!r&&!ge)return null;if(d==="hidden")return de?f.jsx(SG,{onClick:()=>{e.updateShowMenu(!0)}}):null;if(d==="start-session"){const te=(H=e.client)==null?void 0:H.product,_e=(ie=e.client)==null?void 0:ie.selectedPlan,he=i&&!!r,Te=(te==null?void 0:te.agent_name)||"Obi",Vt=(te==null?void 0:te.assistant_subtitle)||"AI Assistant",gt=he?(_e==null?void 0:_e.description)||(te==null?void 0:te.assistant_description)||(te==null?void 0:te.description)||"I'm here to help you.":(te==null?void 0:te.assistant_description)||(_e==null?void 0:_e.description)||(te==null?void 0:te.description)||"I'm here to help you.";return f.jsx(_G,{open:!0,onClose:()=>{v(!1),h("hidden")},onStart:()=>{v(!0),e.startSession({withMicrophone:!0})},agentName:Te,agentSubtitle:Vt,description:gt,showCloseButton:!1,startLabel:"Start Session",isStarting:p})}if(d==="course-selection"){const te=(ue=o==null?void 0:o.roomId)==null?void 0:ue.startsWith("obs-"),_e=((je=e.client)==null?void 0:je.plans)||[],he=te&&x.length>0,Te=he?x.slice().sort((fe,kt)=>fe.order!==void 0&&kt.order!==void 0?fe.order-kt.order:fe.order!==void 0?-1:kt.order!==void 0?1:fe.name.localeCompare(kt.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})):_e.map(fe=>{var kt,pt;return{id:fe.uuid,title:fe.name,description:fe.description,status:(pt=(kt=e.client)==null?void 0:kt.planIsCompleted)!=null&&pt[_e.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}}),Vt=(o==null?void 0:o.languageCodes)||[],gt=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,Jt={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),o&&fe&&await o.switchMicrophoneDevice(fe),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:Vt,selectedLanguage:gt,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Rt=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Re=o==null?void 0:o.room)==null?void 0:Re.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},onClose:()=>y(!1)}):void 0;return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:Te,controlBarProps:Jt,coursePanelProps:{selectedCourseIds:k?[k]:void 0,onCourseToggle:async fe=>{var kt,pt,At;if(he){const bn=x.find(Ri=>Ri.uuid===fe);if(bn){T(fe);try{await((kt=o==null?void 0:o.say)==null?void 0:kt.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),T(null)}}}else{const bn=_e.find(Ri=>Ri.uuid===fe);if(bn){(pt=e.client)==null||pt.selectPlan(bn),h("pip");try{await((At=o==null?void 0:o.say)==null?void 0:At.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),h("course-selection")}}}}},rightPanel:Rt,avatarImageSrc:((Xn=(ft=e.client)==null?void 0:ft.product)==null?void 0:Xn.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="course-outline"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async gt=>{e.client&&(e.client.preferredMicrophoneDeviceId=gt),o&&gt&&await o.switchMicrophoneDevice(gt),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:gt=>{o==null||o.setLanguage(gt)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Te=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:(($i=o==null?void 0:o.room)==null?void 0:$i.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async gt=>{var Jt,Rt,fe,kt;o&&(o.appendChatMessage({timestamp:Date.now(),message:gt,from:{identity:((Rt=(Jt=o.room)==null?void 0:Jt.localParticipant)==null?void 0:Rt.identity)??null,name:((kt=(fe=o.room)==null?void 0:fe.localParticipant)==null?void 0:kt.name)??null},isAgent:!1}),await o.say(gt))},onClose:()=>y(!1)}):void 0,Vt=f.jsx(GH,{steps:gn,currentStep:Nt,hideTrailingConclusionStep:vn,onStepClick:Nn});return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:[],controlBarProps:he,middlePanel:Vt,rightPanel:Te,avatarImageSrc:(($n=(ya=e.client)==null?void 0:ya.product)==null?void 0:$n.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="pip"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he=280,Te=250,Vt=16,gt={x:window.innerWidth-he-Vt,y:window.innerHeight-Te-Vt},Jt={isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isChatOpen:g,isScreenShareActive:j,onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>y(fe=>!fe),onScreenShareToggle:mn,onLeave:()=>{o==null||o.stop()},languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0},Rt=g?f.jsx(fV,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Qn=o==null?void 0:o.room)==null?void 0:Qn.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},testId:"pip-chat-panel"}):void 0;return f.jsx(jq,{initialPosition:gt,onExit:()=>{h("course-outline")},controlBarProps:Jt,isCourseOutlineSelected:A&&!!l,onCourseOutlineToggle:l?()=>{N(fe=>!fe)}:void 0,isCaptionsEnabled:X,onCaptionsToggle:()=>J(fe=>!fe),courseOutline:l?{steps:gn,currentStep:Nt,onStepClick:Nn,hideTrailingConclusionStep:vn}:void 0,messagesPanel:Rt,avatarFallbackProps:{audioPower:$,imageSrc:((mi=(Qi=e.client)==null?void 0:Qi.product)==null?void 0:mi.logo_url)??void 0,status:me,captionsText:K},screenshotUrl:G,cameraShotTrigger:O})}return null}function TG(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 v3(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 wG(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 b3(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 CG(t){const[e,n]=w.useState(()=>Zo(t));return w.useEffect(()=>{n(Zo(t))},[t]),w.useEffect(()=>{const i=()=>{n(Zo(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function EG(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.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 RG(){const[t,e]=w.useState({audioDevices:[]});return w.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 AG(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t==="getcor.ai"||t==="getcor.io"}const y3=AG();function NG(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;OG();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(lB);const a=[r];if(y3){const s=new CSSStyleSheet;s.replaceSync(aB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(sB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(oB),a.push(s)}n.adoptedStyleSheets=a;const o=rB.createRoot(i);y3?o.render(f.jsx(kG,{sdk:t,shadowHost:e})):o.render(f.jsx(dB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function OG(){_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 x3="49206C6F7665204F6269_session",S3="obi-url-params";class MG extends up{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=lh.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new lh(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,p,v;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((v=(p=this.client)==null?void 0:p.product)==null?void 0:v.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Zo(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{Ha().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){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),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&&Ha().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){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}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(S3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[x3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(x3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(S3),this.passivePlanUuid=n}mountWidget(){NG(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await QN(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await G3(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 AN(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")}}async function k3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return DG({appToken:t,window:n,init:e})}async function DG({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 MG(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function T3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{k3(void 0,T3)}):k3(void 0,T3)})();
@@ -130,4 +130,4 @@ ${t}</tr>
130
130
  `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
131
131
  `}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>${va(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=JE(t);if(r===null)return i;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+va(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=JE(t);if(r===null)return va(n);t=r;let a=`<img src="${t}" alt="${n}"`;return e&&(a+=` title="${va(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:va(t.text)}},Rb=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}},mr=class zb{constructor(e){ht(this,"options"),ht(this,"renderer"),ht(this,"textRenderer"),this.options=e||es,this.options.renderer=this.options.renderer||new ep,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Rb}static parse(e,n){return new zb(n).parse(e)}static parseInline(e,n){return new zb(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}},tp,vu=(tp=class{constructor(t){ht(this,"options"),ht(this,"block"),this.options=t||es}preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?pr.lex:pr.lexInline}provideParser(){return this.block?mr.parse:mr.parseInline}},ht(tp,"passThroughHooks",new Set(["preprocess","postprocess","processAllTokens","emStrongMask"])),ht(tp,"passThroughHooksRespectAsync",new Set(["preprocess","postprocess","processAllTokens"])),tp),Rz=class{constructor(...t){ht(this,"defaults",yb()),ht(this,"options",this.setOptions),ht(this,"parse",this.parseMarkdown(!0)),ht(this,"parseInline",this.parseMarkdown(!1)),ht(this,"Parser",mr),ht(this,"Renderer",ep),ht(this,"TextRenderer",Rb),ht(this,"Lexer",pr),ht(this,"Tokenizer",Zf),ht(this,"Hooks",vu),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 ep(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 Zf(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 vu;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];vu.passThroughHooks.has(a)?r[o]=c=>{if(this.defaults.async&&vu.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 pr.lex(t,e??this.defaults)}parser(t,e){return mr.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?pr.lex:pr.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?mr.parse:mr.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?pr.lex:pr.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?mr.parse:mr.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+=`
132
132
  Please report this to https://github.com/markedjs/marked.`,t){let i="<p>An error occurred:</p><pre>"+va(n.message+"",!0)+"</pre>";return e?Promise.resolve(i):i}if(e)return Promise.reject(n);throw n}}},ts=new Rz;function et(t,e){return ts.parse(t,e)}et.options=et.setOptions=function(t){return ts.setOptions(t),et.defaults=ts.defaults,BE(et.defaults),et},et.getDefaults=yb,et.defaults=es,et.use=function(...t){return ts.use(...t),et.defaults=ts.defaults,BE(et.defaults),et},et.walkTokens=function(t,e){return ts.walkTokens(t,e)},et.parseInline=ts.parseInline,et.Parser=mr,et.parser=mr.parse,et.Renderer=ep,et.TextRenderer=Rb,et.Lexer=pr,et.lexer=pr.lex,et.Tokenizer=Zf,et.Hooks=vu,et.parse=et,et.options,et.setOptions,et.use,et.walkTokens,et.parseInline,mr.parse,pr.lex;const Az="_base_1ne03_1",Nz={base:Az},Oz=["p","br","strong","em","u","a","ul","ol","li","h1","h2","h3","h4","h5","h6","code","pre","blockquote","hr"],Mz=["href","title","target","rel"];et.setOptions({breaks:!0,gfm:!0});function Dz(t){const{content:e,className:n,...i}=t,r=w.useMemo(()=>{if(!e)return"";const a=et.parse(e,{async:!1});return GU.sanitize(a,{ALLOWED_TAGS:[...Oz],ALLOWED_ATTR:[...Mz],ALLOW_DATA_ATTR:!1})},[e]);return r?f.jsx("div",{className:le(Nz.base,n),dangerouslySetInnerHTML:{__html:r},...i}):null}const Pz="_controlBar_14416_1",Lz="_popoverAnchor_14416_11",Iz="_confirmationPopover_14416_15",jz="_confirmationPopoverAlignRight_14416_30",Bz="_confirmationPopoverAlignCenter_14416_33",Uz="_confirmationMessage_14416_53",zz="_confirmationActions_14416_60",Fz="_confirmationButton_14416_65",qz="_confirmationButtonCancel_14416_83",Hz="_confirmationButtonNeutral_14416_91",Vz="_confirmationButtonDanger_14416_99",Gz="_controlButton_14416_108",Wz="_controlButtonIconOnly_14416_130",Yz="_controlButtonDisabled_14416_135",Kz="_controlButtonDanger_14416_162",Xz="_controlButtonContent_14416_178",$z="_controlButtonIcon_14416_130",Qz="_controlButtonLabel_14416_194",Jz="_controlButtonChevron_14416_201",Zz="_controlButtonNotificationDot_14416_210",eF="_deviceSplitButton_14416_222",tF="_deviceSplitButtonEnabled_14416_226",nF="_dualButtonContent_14416_307",iF="_dualButtonIcon_14416_317",rF="_dualButtonLabel_14416_326",aF="_screenShareButton_14416_340",oF="_screenShareButtonCompact_14416_351",ze={controlBar:Pz,popoverAnchor:Lz,confirmationPopover:Iz,confirmationPopoverAlignRight:jz,confirmationPopoverAlignCenter:Bz,confirmationMessage:Uz,confirmationActions:zz,confirmationButton:Fz,confirmationButtonCancel:qz,confirmationButtonNeutral:Hz,confirmationButtonDanger:Vz,controlButton:Gz,controlButtonIconOnly:Wz,controlButtonDisabled:Yz,controlButtonDanger:Kz,controlButtonContent:Xz,controlButtonIcon:$z,controlButtonLabel:Qz,controlButtonChevron:Jz,controlButtonNotificationDot:Zz,deviceSplitButton:eF,deviceSplitButtonEnabled:tF,dualButtonContent:nF,dualButtonIcon:iF,dualButtonLabel:rF,screenShareButton:aF,screenShareButtonCompact:oF},sF="_inline_1gpyx_1",lF="_vertical_1gpyx_6",cF="_divider_1gpyx_10",uF="_dividerVertical_1gpyx_16",dF="_customDivider_1gpyx_21",bu={inline:sF,vertical:lF,divider:cF,dividerVertical:uF,customDivider:dF},t3={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 gr(t){if(t!==void 0){if(typeof t=="number")return`${t}px`;if(t in t3)return t3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function hF(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=gr(r);y&&(v.gap=y)}const m=ii.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:le(bu.divider,i==="vertical"&&bu.dividerVertical)},`inline-divider-${y}`):f.jsx("span",{"aria-hidden":"true",className:bu.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:le(bu.inline,i==="vertical"&&bu.vertical,c),style:v,...h,children:g})}const Ab=ii.forwardRef(hF);Ab.displayName="Inline";function fF(){const[t,e]=w.useState(()=>typeof window>"u"?!1:window.innerWidth<768);return w.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 Nb(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=le(ze.controlButton,a&&ze.controlButtonDisabled,l&&ze.controlButtonIconOnly,r==="danger"&&ze.controlButtonDanger,o),v=Number.parseInt(sb[s],10),m=r==="danger"?"outline":"primary",S=r==="danger"?"danger":"default",g=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:ze.controlButtonContent,children:[e?f.jsx("span",{className:ze.controlButtonIcon,children:ii.isValidElement(e)&&e.props.size===void 0?ii.cloneElement(e,{size:v}):e}):null,l?null:f.jsx("span",{className:ze.controlButtonLabel,children:n}),l||!i?null:f.jsx("span",{className:ze.controlButtonChevron,"aria-hidden":"true",children:f.jsx(lb,{size:16})})]}),c?f.jsx("span",{className:ze.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof u=="boolean"?f.jsx(Vf,{...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(xl,{...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 pF(t){const{audioDevices:e,currentMicrophoneId:n,isMicrophoneEnabled:i,isScreenShareActive:r,widgetState:a,canPublishData:o,browserSupportsScreenSharing:s,screenShareButtonVariant:l="default",onMicDeviceSelect:c,onMicToggle:u,onChatToggle:d,onLeave:h,onScreenShareToggle:p,showChatNotification:v=!1,isLanguageSelectorEnabled:m=!0,languages:S=[],selectedLanguage:g=null,defaultLanguageCode:y=null,isMultilingual:x=!1,onLanguageChange:b,isChatOpen:k=a==="chat"}=t,T=S.length,C=m&&x&&T>0,R=fF(),A=R?"xs":"sm",N=R,[O,U]=w.useState(!1),[G,L]=w.useState(!1),W=w.useRef(null),P=w.useRef(null);w.useEffect(()=>{const B=ge=>{const Et=ge.composedPath();O&&W.current&&!Et.includes(W.current)&&U(!1),G&&P.current&&!Et.includes(P.current)&&L(!1)},de=ge=>{ge.key==="Escape"&&(O&&U(!1),G&&L(!1))};if(O||G)return document.addEventListener("mousedown",B),document.addEventListener("keydown",de),()=>{document.removeEventListener("mousedown",B),document.removeEventListener("keydown",de)}},[O,G]),w.useEffect(()=>{r||U(!1)},[r]);const X=w.useMemo(()=>e.map(B=>({label:B.label||`Microphone ${B.deviceId.slice(0,8)}`,value:B.deviceId})),[e]),J=w.useMemo(()=>n?X.find(B=>B.value===n)??null:null,[n,X]),re=w.useCallback(B=>{B.value,c(B.value)},[c]),$={microphone:!0,screenShare:s,chat:o},F=w.useCallback(()=>{if(r){U(!0);return}p()},[r,p]),Z=w.useCallback(()=>{U(!1),p()},[p]),K=w.useCallback(()=>{U(!1)},[]),se=w.useCallback(()=>{L(!0)},[]),j=w.useCallback(()=>{L(!1),h()},[h]),me=w.useCallback(()=>{L(!1)},[]);return f.jsx("div",{className:ze.controlBar,"data-testid":"control-bar","data-controls":JSON.stringify($),"data-language-option-count":T>0?String(T):void 0,"data-default-language-code":y??void 0,children:f.jsxs(Ab,{gap:A,align:"center",justify:"center",wrap:N,children:[f.jsx(eU,{onClick:u,buttonAriaLabel:i?"Mute microphone":"Unmute microphone",options:X,value:J,onChange:re,variant:"primary",menuPlacement:"top",menuDisabled:X.length===0,menuAriaLabel:"Select microphone device",listboxAriaLabel:"Microphone devices",ariaPressed:i,className:le(ze.deviceSplitButton,i&&ze.deviceSplitButtonEnabled),children:f.jsxs("span",{className:ze.dualButtonContent,children:[f.jsx("span",{className:ze.dualButtonIcon,children:i?f.jsx(dE,{}):f.jsx(hE,{})}),f.jsx("span",{className:ze.dualButtonLabel,children:"Microphone"})]})}),o?f.jsx(Nb,{icon:f.jsx(lE,{}),label:"Chat",onClick:d,isOn:k,"aria-label":"Toggle chat",showNotificationDot:v}):null,s?f.jsxs("div",{ref:W,className:ze.popoverAnchor,children:[f.jsx(Nb,{icon:f.jsx(fE,{}),label:r?"Share screen off":"Share screen",className:l==="compact"?ze.screenShareButtonCompact:ze.screenShareButton,iconOnly:l==="compact",onClick:F,isOn:r,"aria-label":r?"Stop screen sharing":"Start screen sharing"}),O?f.jsxs("div",{className:le(ze.confirmationPopover,ze.confirmationPopoverAlignCenter),role:"dialog","aria-label":"Stop screen sharing confirmation","data-testid":"confirm-stop-share",children:[f.jsx("p",{className:ze.confirmationMessage,children:"Stop screen sharing?"}),f.jsxs("div",{className:ze.confirmationActions,children:[f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonCancel),onClick:K,children:"Cancel"}),f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonNeutral),onClick:Z,children:"Stop"})]})]}):null]}):null,C?f.jsx(xE,{languages:S,value:g,onChange:b,defaultLanguageCode:y,variant:"control-bar"}):null,f.jsxs("div",{ref:P,className:ze.popoverAnchor,children:[f.jsx(Nb,{icon:f.jsx(uE,{}),label:"Leave",variant:"danger",onClick:se,"aria-label":"Leave meeting"}),G?f.jsxs("div",{className:le(ze.confirmationPopover,ze.confirmationPopoverAlignRight),role:"dialog","aria-label":"Leave meeting confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:ze.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:ze.confirmationActions,children:[f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonCancel),onClick:me,children:"Cancel"}),f.jsx("button",{type:"button",className:le(ze.confirmationButton,ze.confirmationButtonDanger),onClick:j,children:"Leave"})]})]}):null]})]})})}function mF(t){return f.jsx(pF,{...t})}const gF="_controlBar_1n8jn_1",vF="_controlButton_1n8jn_12",bF="_controlButtonDisabled_1n8jn_35",yF="_controlButtonDanger_1n8jn_62",_F="_controlButtonIconOnly_1n8jn_78",xF="_screenShareButton_1n8jn_83",SF="_controlButtonContent_1n8jn_88",kF="_controlButtonIcon_1n8jn_78",TF="_controlButtonLabel_1n8jn_103",wF="_controlButtonNotificationDot_1n8jn_108",CF="_popoverAnchor_1n8jn_198",EF="_confirmationPopover_1n8jn_202",RF="_confirmationMessage_1n8jn_216",AF="_confirmationActions_1n8jn_223",NF="_confirmationButton_1n8jn_228",OF="_confirmationButtonCancel_1n8jn_246",MF="_confirmationButtonDanger_1n8jn_254",pn={controlBar:gF,controlButton:vF,controlButtonDisabled:bF,controlButtonDanger:yF,controlButtonIconOnly:_F,screenShareButton:xF,controlButtonContent:SF,controlButtonIcon:kF,controlButtonLabel:TF,controlButtonNotificationDot:wF,popoverAnchor:CF,confirmationPopover:EF,confirmationMessage:RF,confirmationActions:AF,confirmationButton:NF,confirmationButtonCancel:OF,confirmationButtonDanger:MF};function np(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=le(pn.controlButton,r&&pn.controlButtonDisabled,o&&pn.controlButtonIconOnly,i==="danger"&&pn.controlButtonDanger,a),h=i==="danger"?"outline":"primary",p=i==="danger"?"danger":"default",v=f.jsxs(f.Fragment,{children:[f.jsxs("span",{className:pn.controlButtonContent,children:[e?f.jsx("span",{className:pn.controlButtonIcon,children:ii.isValidElement(e)&&e.props.size===void 0?ii.cloneElement(e,{size:20}):e}):null,o?null:f.jsx("span",{className:pn.controlButtonLabel,children:n})]}),s?f.jsx("span",{className:pn.controlButtonNotificationDot,"aria-hidden":"true"}):null]});return typeof l=="boolean"?f.jsx(Vf,{...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(xl,{...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 DF(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,onLanguageChange:p,isLanguageSelectorEnabled:v=!0,className:m,testId:S,...g}=t,y=!v||!h||c.length===0,[x,b]=w.useState(!1),k=w.useRef(null);w.useEffect(()=>{const O=G=>{const L=G.composedPath();x&&k.current&&!L.includes(k.current)&&b(!1)},U=G=>{G.key==="Escape"&&x&&b(!1)};if(x)return document.addEventListener("mousedown",O),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",O),document.removeEventListener("keydown",U)}},[x]);const T=w.useCallback(()=>{a()},[a]),C=w.useCallback(()=>{s()},[s]),R=w.useCallback(()=>{b(!0)},[]),A=w.useCallback(()=>{b(!1),l()},[l]),N=w.useCallback(()=>{b(!1)},[]);return f.jsx("div",{...g,className:le(pn.controlBar,m),"data-testid":S,children:f.jsxs(Ab,{gap:"xs",align:"center",justify:"center",wrap:!1,children:[f.jsx(np,{icon:e?f.jsx(dE,{size:18}):f.jsx(hE,{size:18}),label:"Microphone",iconOnly:!0,isOn:e,onClick:T,"aria-label":e?"Mute microphone":"Unmute microphone"}),f.jsx(np,{icon:f.jsx(lE,{}),label:"Chat",iconOnly:!0,isOn:n,onClick:o,"aria-label":"Toggle chat",showNotificationDot:r}),f.jsx(np,{icon:f.jsx(fE,{}),label:"Screen share",iconOnly:!0,className:pn.screenShareButton,isOn:i,onClick:C,"aria-label":i?"Stop screen sharing":"Start screen sharing"}),f.jsx(xE,{languages:c,value:u,onChange:p,defaultLanguageCode:d,variant:"pip",disabled:y}),f.jsxs("div",{ref:k,className:pn.popoverAnchor,children:[f.jsx(np,{icon:f.jsx(uE,{size:16}),label:"Hang up",iconOnly:!0,variant:"danger",onClick:R,"aria-label":"Hang up"}),x?f.jsxs("div",{className:pn.confirmationPopover,role:"dialog","aria-label":"Hang up confirmation","data-testid":"confirm-leave",children:[f.jsx("p",{className:pn.confirmationMessage,children:"Would you like to end the call?"}),f.jsxs("div",{className:pn.confirmationActions,children:[f.jsx("button",{type:"button",className:le(pn.confirmationButton,pn.confirmationButtonCancel),onClick:N,children:"Cancel"}),f.jsx("button",{type:"button",className:le(pn.confirmationButton,pn.confirmationButtonDanger),onClick:A,children:"Leave"})]})]}):null]})]})})}function PF(t){return f.jsx(DF,{...t})}const LF="_container_zht0b_1",IF="_containerGradient_zht0b_14",jF="_containerFlat_zht0b_24",BF="_halo_zht0b_28",UF="_outerRing_zht0b_38",zF="_circle_zht0b_42",FF="_image_zht0b_72",qF="_captionContainer_zht0b_88",HF="_captionRegion_zht0b_99",ba={container:LF,containerGradient:IF,containerFlat:jF,halo:BF,outerRing:UF,circle:zF,image:FF,captionContainer:qF,captionRegion:HF},VF="_statusText_1dkze_6",GF={statusText:VF},WF={idle:null,thinking:"Thinking...",searching:"Searching..."};function YF(t){const{status:e,size:n="md"}=t,i=e?WF[e]:null,r=i!==null;return f.jsx("div",{className:GF.statusText,"data-visible":r,"data-size":n,"aria-live":"polite",children:i})}const KF="https://obi-static.s3.ap-southeast-2.amazonaws.com/images/obi-avatar.png",XF={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 n3(t){const{audioPower:e,size:n="md",background:i="gradient",imageSrc:r=KF,accentColor:a,ariaLabel:o="Avatar placeholder",status:s,captionsText:l,className:c,style:u,...d}=t,h=XF[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},T=l!=null&&l!=="";return f.jsxs("div",{...d,className:le(ba.container,i==="gradient"?ba.containerGradient:ba.containerFlat,c),style:b,"data-testid":"avatar-fallback","aria-label":o,role:"img",children:[f.jsxs("div",{className:ba.halo,style:k,children:[f.jsx("div",{className:ba.outerRing,"aria-hidden":"true"}),f.jsx("div",{className:ba.circle,children:f.jsx("img",{className:ba.image,src:r,alt:"","aria-hidden":"true"})}),f.jsx(YF,{status:s,size:n})]}),T&&f.jsx("div",{className:ba.captionContainer,children:f.jsx("div",{className:ba.captionRegion,"data-size":n,role:"status","aria-live":"polite","aria-atomic":"true",children:l})})]})}const $F="_container_1k3qg_11",QF="_screenshot_1k3qg_20",JF="_flash_1k3qg_30",Ob={container:$F,screenshot:QF,flash:JF};function ZF(t){const{isActive:e,imageUrl:n,onComplete:i,duration:r=2e3}=t,[a,o]=w.useState(!1),s=w.useRef(null),l=w.useRef(i);return w.useEffect(()=>{l.current=i},[i]),w.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:Ob.container,"aria-live":"polite","aria-label":"Screenshot captured",children:[n&&f.jsx("img",{src:n,alt:"Captured screenshot",className:Ob.screenshot}),f.jsx("div",{className:Ob.flash})]}):null}const eq="_container_13ukq_1",tq="_dragging_13ukq_5",nq="_placeholder_13ukq_9",iq="_handleButton_13ukq_15",rq="_customHandle_13ukq_105",Tl={container:eq,dragging:tq,placeholder:nq,handleButton:iq,"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:rq};function aq(t){const{disabled:e,lingerMs:n,isDragging:i}=t,[r,a]=w.useState(!1),o=w.useRef(null),s=w.useCallback(()=>{o.current!==null&&(window.clearTimeout(o.current),o.current=null)},[]),l=w.useCallback(()=>{e||(s(),a(!0))},[s,e]),c=w.useCallback(()=>{e||i||(s(),o.current=window.setTimeout(()=>{a(!1),o.current=null},n))},[s,e,i,n]);return w.useEffect(()=>{i&&l()},[i,l]),w.useEffect(()=>s,[s]),{isHandleVisible:r,showHandle:l,scheduleHideHandle:c}}function oq(t){const{initialPosition:e,preserveSpace:n,onPositionChange:i}=t,r=w.useRef(null),[a,o]=w.useState(!!e),[s,l]=w.useState(!1),[c,u]=w.useState(null),[d,h]=w.useState(()=>e??{x:0,y:0}),p=w.useRef(d);s||(p.current=d);const v=w.useRef(null),m=w.useRef(!1),S=w.useRef(!1);w.useEffect(()=>{e&&(S.current||(o(!0),h(e),p.current=e))},[e==null?void 0:e.x,e==null?void 0:e.y]),w.useEffect(()=>{if(e||m.current)return;const b=r.current;if(!b)return;const k=b.getBoundingClientRect(),T={x:k.left,y:k.top};m.current=!0,o(!0),h(T),p.current=T,u(n?{width:k.width,height:k.height}:null)},[e,n]);const g=w.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=w.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=w.useCallback(b=>{const k=v.current;if(!k||b.pointerId!==k.pointerId)return;const T={x:k.startX+(b.clientX-k.startClientX),y:k.startY+(b.clientY-k.startClientY)};p.current=T,r.current&&(r.current.style.transform=`translate3d(${T.x}px, ${T.y}px, 0)`),i==null||i(T)},[i]);return{containerRef:r,isFixed:a,isDragging:s,position:d,placeholderSize:c,onPointerDown:y,onPointerMove:x,endDrag:g}}function sq(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}=oq({initialPosition:r,preserveSpace:o,onPositionChange:l}),{isHandleVisible:k,showHandle:T,scheduleHideHandle:C}=aq({disabled:a,lingerMs:u,isDragging:m}),R=typeof e=="function",A=w.useMemo(()=>{const O=U=>f.jsx("div",{className:le(Tl.customHandle,U.className),onPointerDown:y,onPointerMove:x,onPointerUp:b,onPointerCancel:b,children:U.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:Tl.placeholder,style:{width:g.width,height:g.height}}):null,f.jsxs("div",{ref:p,className:le(Tl.container,m?Tl.dragging:null,n),"data-handle-visible":R?void 0:a?"false":k||m?"true":"false",style:N,onMouseEnter:R?void 0:T,onMouseLeave:R?void 0:C,...h,children:[!R&&!a?f.jsx("button",{type:"button",className:le(Tl.handleButton,Tl[`handle-${i}`]),"aria-label":c,onMouseEnter:T,onMouseLeave:C,onPointerDown:O=>{T(),y(O)},onPointerMove:x,onPointerUp:b,onPointerCancel:b}):null,R?e({Handle:A}):e]})]})}const lq="_container_gzwdo_1",cq="_captionRegion_gzwdo_14",uq="_status_gzwdo_22",dq="_captionText_gzwdo_29",ip={container:lq,captionRegion:cq,status:uq,captionText:dq},hq={idle:null,thinking:"Thinking...",searching:"Searching..."};function fq(t){const{text:e,status:n,className:i,...r}=t,a=n?hq[n]:null;return f.jsx("div",{...r,className:le(ip.container,i),"data-testid":"pip-captions-panel",children:f.jsxs("div",{className:ip.captionRegion,role:"status","aria-live":"polite","aria-atomic":"true",children:[a?f.jsx("div",{className:ip.status,children:a}):null,f.jsx("div",{className:ip.captionText,children:e})]})})}const pq="_panel_1pokp_1",mq="_row_1pokp_21",gq="_stepContent_1pokp_27",vq="_stepLabel_1pokp_35",bq="_currentStep_1pokp_42",yq="_nextStep_1pokp_49",_q="_skipButtonContainer_1pokp_63",xq="_circleButton_1pokp_71",Sq="_arrowPlaceholder_1pokp_98",kq="_skipButton_1pokp_63",Ki={panel:pq,row:mq,stepContent:gq,stepLabel:vq,currentStep:bq,nextStep:yq,skipButtonContainer:_q,circleButton:xq,arrowPlaceholder:Sq,skipButton:kq},Tq="_truncatedText_1u580_1",wq={truncatedText:Tq};function i3(t){const{children:e,maxLines:n=2,className:i,"data-testid":r}=t;return f.jsx("div",{className:`${wq.truncatedText} ${i||""}`,style:{WebkitLineClamp:n},"data-testid":r,children:e})}function Cq(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 Mb(t,e){return e<=0||typeof t!="number"||!Number.isFinite(t)?0:Math.min(Math.max(Math.trunc(t),1),e)-1}function Eq(t){var C;const{steps:e,currentStep:n,onStepClick:i,hideTrailingConclusionStep:r=!0,className:a,testId:o,...s}=t,{visibleSteps:l,currentIndex:c}=w.useMemo(()=>Cq(e,n,r),[n,r,e]),[u,d]=w.useState(()=>Mb(n,l.length)),h=w.useRef(!1);w.useEffect(()=>{if(!h.current)d(Mb(n,l.length));else{const R=Mb(n,l.length);u===R&&(h.current=!1)}},[n,l,u]);const p=l.length,v=l[u],m=u>0,S=u<p-1,g=S?(C=l[u+1])==null?void 0:C.title:void 0,y=p===0?0:u+1,x=c!==null&&v&&u!==c,b=()=>{m&&(h.current=!0,d(R=>Math.max(R-1,0)))},k=()=>{S&&(h.current=!0,d(R=>Math.min(R+1,p-1)))},T=()=>{!x||!v||!i||(h.current=!1,i(u,v))};return f.jsxs("div",{...s,className:le(Ki.panel,a),"data-testid":o,role:"group","aria-label":"Course progress",children:[f.jsxs("div",{className:Ki.row,children:[m?f.jsx("button",{type:"button",className:Ki.circleButton,"aria-label":"Previous step",onClick:b,children:f.jsx(_B,{size:14})}):f.jsx("span",{className:Ki.arrowPlaceholder,"aria-hidden":"true"}),f.jsxs("div",{className:Ki.stepContent,children:[f.jsxs(hi,{className:Ki.stepLabel,"aria-live":"polite",children:["Step ",y,"/",p]}),f.jsx(i3,{maxLines:2,children:f.jsx(hi,{className:Ki.currentStep,"data-testid":"pip-outline-current-step",children:(v==null?void 0:v.title)??"No steps available"})}),g?f.jsx(i3,{maxLines:2,children:f.jsxs(hi,{variant:"muted",className:Ki.nextStep,children:["Next: ",g]})}):null]}),S?f.jsx("button",{type:"button",className:Ki.circleButton,"aria-label":"Next step",onClick:k,children:f.jsx(xB,{size:14})}):f.jsx("span",{className:Ki.arrowPlaceholder,"aria-hidden":"true"})]}),x?f.jsx("div",{className:Ki.skipButtonContainer,children:f.jsx("button",{type:"button",className:Ki.skipButton,"aria-label":"Skip to this step",onClick:T,children:f.jsx(CB,{size:14})})}):null]})}const Rq="_window_1itr6_1",Aq="_exitButton_1itr6_14",Nq="_content_1itr6_47",Oq="_contentTopOverlay_1itr6_57",Mq="_dragHandle_1itr6_67",Dq="_contentBottomOverlay_1itr6_77",Pq="_controls_1itr6_86",ns={window:Rq,exitButton:Aq,content:Nq,contentTopOverlay:Oq,dragHandle:Mq,contentBottomOverlay:Dq,controls:Pq};function Lq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function Iq(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&&Lq(y),[b,k]=w.useState(!1),T=w.useRef(h),C=w.useCallback(()=>{k(!1)},[]);w.useEffect(()=>{h&&h>0&&h!==T.current&&k(!0),T.current=h},[h]);const R=w.useCallback(()=>f.jsx(n3,{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(Eq,{steps:s.steps,currentStep:s.currentStep,onStepClick:s.onStepClick,hideTrailingConclusionStep:s.hideTrailingConclusionStep}):R():g?l:x?f.jsx(fq,{text:y}):R();return f.jsxs("div",{...m,className:le(ns.window,p),"data-testid":v,role:"group","aria-label":"Picture-in-Picture",children:[f.jsxs("div",{className:ns.content,children:[f.jsx("div",{className:ns.contentTopOverlay,children:u}),f.jsx("button",{type:"button",className:ns.exitButton,onClick:e,"aria-label":"Exit PiP",children:f.jsx(kB,{size:14})}),A,!g&&f.jsxs("div",{className:ns.contentBottomOverlay,children:[f.jsx(Vf,{isOn:i,onClick:r,variant:"primary",size:"xs","aria-label":"Toggle course outline",children:f.jsx(EB,{size:18})}),f.jsx(Vf,{isOn:a,onClick:o,variant:"primary",size:"xs","aria-label":"Toggle captions",children:f.jsx(yB,{size:18})})]}),f.jsx(ZF,{isActive:b,imageUrl:d??null,onComplete:C})]}),f.jsx("div",{className:ns.controls,children:f.jsx(PF,{...n})})]})}function jq(t){const{initialPosition:e,onPositionChange:n,zIndex:i=1e3,...r}=t;return f.jsx(sq,{initialPosition:e,onPositionChange:n,zIndex:i,preserveSpace:!1,children:({Handle:a})=>f.jsx(Iq,{...r,contentTopOverlaySlot:f.jsx(a,{className:ns.dragHandle})})})}const Bq="_root_ygi3o_1",Uq="_overlay_ygi3o_7",zq="_caption_ygi3o_17",Db={root:Bq,overlay:Uq,caption:zq};function Fq(t){return t==null?!1:typeof t=="string"?t.trim().length>0:!0}function qq(t){const{children:e,className:n,text:i}=t,r=Fq(i);return f.jsxs("div",{className:le(Db.root,n),children:[e,r?f.jsx("div",{className:Db.overlay,role:"status","aria-live":"polite","aria-atomic":"true",children:f.jsx("div",{className:Db.caption,children:i})}):null]})}const Hq="_box_dc9yv_1",Vq={box:Hq},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 Gq(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 Wq(t){if(t!==void 0){if(t in a3)return a3[t];if(typeof t=="string"&&t.trim().length>0)return t}}function Yq(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:T,radiusTop:C,radiusBottom:R,radiusLeft:A,radiusRight:N,radiusTopLeft:O,radiusTopRight:U,radiusBottomLeft:G,radiusBottomRight:L,background:W,gap:P,style:X,...J}=t,re=n??"div",$={...X},F=$,Z={},K=(B,de)=>{if(de===void 0)return;const ge=gr(de);ge&&($[B]=ge)},se=(B,de)=>{if(de===void 0)return;const ge=gr(de);ge&&($[B]=ge)},j=(B,de)=>{if(de===void 0)return;const ge=Gq(de);ge&&($[B]=ge)},me={sm:d,md:h,lg:p,xl:v};if(r!==void 0){const B=gr(r);B&&(F["--box-padding"]=B)}for(const[B,de]of Object.entries(me)){if(de===void 0)continue;const ge=gr(de);ge&&(F[`--box-padding-${B}`]=ge,Z[`data-padding-${B}`]="")}if(a!==void 0){const B=gr(a);B&&($.paddingLeft=B,$.paddingRight=B)}if(o!==void 0){const B=gr(o);B&&($.paddingTop=B,$.paddingBottom=B)}if(K("paddingTop",s),K("paddingBottom",l),K("paddingLeft",c),K("paddingRight",u),m!==void 0){const B=gr(m);B&&($.margin=B)}if(S!==void 0){const B=gr(S);B&&($.marginLeft=B,$.marginRight=B)}if(g!==void 0){const B=gr(g);B&&($.marginTop=B,$.marginBottom=B)}if(se("marginTop",y),se("marginBottom",x),se("marginLeft",b),se("marginRight",k),P!==void 0){const B=gr(P);B&&($.gap=B)}if(j("borderRadius",T),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",U),j("borderBottomLeftRadius",G),j("borderBottomRightRadius",L),W!==void 0){const B=Wq(W);B&&($.background=B)}return f.jsx(re,{ref:e,className:le(Vq.box,i),style:$,...Z,...J})}const rp=ii.forwardRef(Yq);rp.displayName="Box";const Kq="_panel_eawk4_1",Xq="_selected_eawk4_10",o3={panel:Kq,selected:Xq};function yu(t){const{children:e,className:n,selected:i,...r}=t;return f.jsx("div",{className:le(o3.panel,i?o3.selected:null,n),...r,children:e})}const $q="_root_yccm8_1",Qq="_header_yccm8_8",Jq="_icon_yccm8_15",Zq="_text_yccm8_26",eH="_heading_yccm8_33",tH="_description_yccm8_41",nH="_body_yccm8_47",iH="_footer_yccm8_54",yo={root:$q,header:Qq,icon:Jq,text:Zq,heading:eH,description:tH,body:nH,footer:iH};function s3(t){const{className:e,...n}=t;return f.jsx("div",{className:le(yo.icon,e),...n})}function l3(t){const{className:e,...n}=t;return f.jsx("h3",{className:le(yo.heading,e),...n})}function c3(t){const{className:e,...n}=t;return f.jsx("p",{className:le(yo.description,e),...n})}function u3(t){const{className:e,...n}=t;return f.jsx("div",{className:le(yo.footer,e),...n})}function rH(t){const e=w.Children.toArray(t),n=[];let i,r,a,o;for(const s of e){if(w.isValidElement(s)&&s.type===s3&&i===void 0){i=s;continue}if(w.isValidElement(s)&&s.type===l3&&r===void 0){r=s;continue}if(w.isValidElement(s)&&s.type===c3&&a===void 0){a=s;continue}if(w.isValidElement(s)&&s.type===u3&&o===void 0){o=s;continue}n.push(s)}return{icon:i,heading:r,description:a,footer:o,body:n}}function aH(t){const{children:e,className:n,...i}=t,r=rH(e),a=r.icon||r.heading||r.description;return f.jsxs(yu,{className:le(yo.root,n),...i,children:[a?f.jsxs("div",{className:yo.header,children:[r.icon,r.heading||r.description?f.jsxs("div",{className:yo.text,children:[r.heading,r.description]}):null]}):null,r.body.length?f.jsx("div",{className:yo.body,children:r.body}):null,r.footer]})}const Pb=Object.assign(aH,{Icon:s3,Heading:l3,Description:c3,Footer:u3}),oH="_panel_1uwhd_1",sH="_header_1uwhd_11",lH="_title_1uwhd_19",cH="_scrollArea_1uwhd_29",uH="_scrollable_1uwhd_34",dH="_list_1uwhd_38",hH="_courseButton_1uwhd_44",fH="_courseCard_1uwhd_55",pH="_courseHeading_1uwhd_64",mH="_courseDescription_1uwhd_70",gH="_empty_1uwhd_79",vr={panel:oH,header:sH,title:lH,scrollArea:cH,scrollable:uH,list:dH,courseButton:hH,courseCard:fH,courseHeading:pH,courseDescription:mH,empty:gH};function vH(t){const{selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}=t,a=n!==void 0,[o,s]=w.useState(()=>i??[]),l=a?n:o,c=w.useCallback(d=>{a||s(d),r==null||r(d)},[a,r]),u=w.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 bH(t){const{title:e="Courses",ariaLabel:n,className:i,courses:r,selectionMode:a="multiple",selectedCourseIds:o,onCourseToggle:s,emptyMessage:l="No courses available",testId:c,...u}=t;return f.jsxs(yu,{...u,className:le(vr.panel,i),role:"region","aria-label":n??e,"data-testid":c,children:[f.jsx("div",{className:vr.header,children:f.jsx(hi,{as:"h2",className:vr.title,children:e})}),f.jsx("div",{className:vr.scrollArea,children:f.jsx(Sl,{className:vr.scrollable,children:r.length===0?f.jsx(hi,{variant:"muted",className:vr.empty,"data-testid":"course-panel-empty",children:l}):f.jsx("div",{className:vr.list,"data-testid":"course-panel-list",children:r.map(d=>{const h=o.includes(d.id),p=d.disabled===!0;return f.jsx("button",{type:"button",className:vr.courseButton,"aria-pressed":h,"aria-disabled":p,disabled:p,onClick:()=>s==null?void 0:s(d.id,d),"data-testid":`course-panel-item-${d.id}`,children:f.jsxs(Pb,{selected:h,className:vr.courseCard,children:[f.jsx(Pb.Heading,{className:vr.courseHeading,children:d.title}),d.description?f.jsx(Pb.Description,{className:vr.courseDescription,children:d.description}):null]})},d.id)})})})})]})}function yH(t){const{selectionMode:e="multiple",selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r,onCourseToggle:a,...o}=t,{selectedCourseIds:s,toggleCourseId:l}=vH({selectionMode:e,selectedCourseIds:n,defaultSelectedCourseIds:i,onSelectedCourseIdsChange:r}),c=w.useCallback((u,d)=>{l(u),a==null||a(u,d)},[a,l]);return f.jsx(bH,{...o,selectionMode:e,selectedCourseIds:s,onCourseToggle:c})}const _H="_panel_1on05_1",xH="_header_1on05_11",SH="_divider_1on05_19",kH="_title_1on05_25",TH="_scrollArea_1on05_35",wH="_scrollable_1on05_40",CH="_list_1on05_44",EH="_section_1on05_50",RH="_sectionHeader_1on05_56",AH="_sectionTitle_1on05_60",NH="_sectionTitleCompact_1on05_68",OH="_item_1on05_72",MH="_itemClickable_1on05_86",DH="_itemCompleted_1on05_90",PH="_itemCurrent_1on05_94",LH="_itemFuture_1on05_98",IH="_itemDisabled_1on05_103",jH="_row_1on05_117",BH="_stepHeader_1on05_124",UH="_stepNumber_1on05_133",zH="_stepTitle_1on05_139",FH="_checkIcon_1on05_151",qH="_empty_1on05_155",Qe={panel:_H,header:xH,divider:SH,title:kH,scrollArea:TH,scrollable:wH,list:CH,section:EH,sectionHeader:RH,sectionTitle:AH,sectionTitleCompact:NH,item:OH,itemClickable:MH,itemCompleted:DH,itemCurrent:PH,itemFuture:LH,itemDisabled:IH,row:jH,stepHeader:BH,stepNumber:UH,stepTitle:zH,checkIcon:FH,empty:qH};function HH(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 VH(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,...d}=t,h=w.useCallback(x=>(x+1).toString().padStart(2,"0"),[]),{visibleSteps:p,completedIndices:v,currentIndex:m,futureIndices:S}=w.useMemo(()=>HH({steps:r,currentStep:a,hideTrailingConclusionStep:s}),[a,s,r]),g=c==="compact"?"md":"lg",y=w.useCallback((x,b)=>{const k=p[x];if(!k)return null;const T=typeof o=="function",C=T&&k.disabled===!0,R=T&&!C,A=le(Qe.item,{[Qe.itemClickable]:R,[Qe.itemCompleted]:b==="completed",[Qe.itemCurrent]:b==="current",[Qe.itemFuture]:b==="future",[Qe.itemDisabled]:C}),N=f.jsxs("div",{className:Qe.row,children:[f.jsxs("div",{className:Qe.stepHeader,children:[f.jsx("span",{className:Qe.stepNumber,children:h(x)}),f.jsx("span",{className:Qe.stepTitle,children:k.title})]}),b==="completed"?f.jsx(qf,{size:20,className:Qe.checkIcon}):null]});return T?f.jsx(rp,{as:"button",type:"button",className:A,onClick:()=>{R&&o(x,k)},disabled:C,"aria-current":b==="current"?"step":void 0,"aria-label":`Step ${h(x)}: ${k.title}`,"data-testid":`course-outline-item-${k.id}`,padding:g,radius:"panel",gap:"sm",children:N},k.id):f.jsx(rp,{className:A,"aria-current":b==="current"?"step":void 0,"aria-label":`Step ${h(x)}: ${k.title}`,"data-testid":`course-outline-item-${k.id}`,padding:g,radius:"panel",gap:"sm",children:N},k.id)},[h,g,o,p]);return f.jsxs(yu,{...d,className:le(Qe.panel,i),role:"region","aria-label":n??e,"data-testid":u,children:[f.jsx("div",{className:Qe.header,children:f.jsx(hi,{as:"h2",className:Qe.title,children:e})}),f.jsx("div",{className:Qe.divider,"aria-hidden":"true"}),f.jsx("div",{className:Qe.scrollArea,children:f.jsx(Sl,{className:Qe.scrollable,children:p.length===0?f.jsx(hi,{variant:"muted",className:Qe.empty,"data-testid":"course-outline-empty",children:l}):f.jsxs("div",{className:Qe.list,"data-testid":"course-outline-list",children:[v.length>0?f.jsxs("div",{className:Qe.section,"data-testid":"course-outline-section-completed",children:[f.jsx("div",{className:Qe.sectionHeader,children:f.jsx("span",{className:le(Qe.sectionTitle,c==="compact"?Qe.sectionTitleCompact:null),children:"Completed"})}),v.map(x=>y(x,"completed"))]}):null,m!==null?f.jsxs("div",{className:Qe.section,"data-testid":"course-outline-section-current",children:[f.jsx("div",{className:Qe.sectionHeader,children:f.jsx("span",{className:le(Qe.sectionTitle,c==="compact"?Qe.sectionTitleCompact:null),children:"Current"})}),y(m,"current")]}):null,S.length>0?f.jsxs("div",{className:Qe.section,"data-testid":"course-outline-section-upcoming",children:[f.jsx("div",{className:Qe.sectionHeader,children:f.jsx("span",{className:le(Qe.sectionTitle,c==="compact"?Qe.sectionTitleCompact:null),children:"Upcoming"})}),S.map(x=>y(x,"future"))]}):null]})})})]})}function GH(t){return f.jsx(VH,{...t})}const WH="_panel_h7cuf_1",YH="_messagesArea_h7cuf_20",KH="_messagesList_h7cuf_46",XH="_messageItem_h7cuf_53",$H="_messageMetadata_h7cuf_59",QH="_senderName_h7cuf_67",JH="_timestamp_h7cuf_71",ZH="_messageBubble_h7cuf_75",eV="_agentMessage_h7cuf_85",tV="_agentActions_h7cuf_89",nV="_copyButton_h7cuf_95",iV="_copyButtonCopied_h7cuf_129",rV="_empty_h7cuf_133",aV="_composer_h7cuf_140",oV="_composerDisabled_h7cuf_160",sV="_composerInput_h7cuf_165",lV="_sendButton_h7cuf_180",An={panel:WH,messagesArea:YH,messagesList:KH,messageItem:XH,messageMetadata:$H,senderName:QH,timestamp:JH,messageBubble:ZH,agentMessage:eV,agentActions:tV,copyButton:nV,copyButtonCopied:iV,empty:rV,composer:aV,composerDisabled:oV,composerInput:sV,sendButton:lV};function cV(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 uV(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 dV(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 hV(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 fV(t){const{messages:e,localIdentity:n,onSend:i,isSending:r=!1,inputPlaceholder:a="Type a message...",className:o,testId:s,...l}=t,[c,u]=w.useState(""),[d,h]=w.useState(null),p=w.useRef(null),v=w.useRef(null),m=w.useMemo(()=>{const b=e[e.length-1];return b?b.id??`${b.timestamp}-${e.length-1}`:null},[e]);w.useEffect(()=>{var b,k;(k=(b=p.current)==null?void 0:b.scrollIntoView)==null||k.call(b,{behavior:"smooth"})},[m]),w.useEffect(()=>()=>{v.current&&(window.clearTimeout(v.current),v.current=null)},[]);const S=w.useCallback(async()=>{const b=c.trim();b.length!==0&&(await i(b),u(""))},[c,i]),g=w.useCallback(b=>{b.key==="Enter"&&(b.preventDefault(),S())},[S]),y=w.useCallback(async(b,k)=>{try{await hV(b.message??""),h(k),v.current&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{h(null),v.current=null},2e3)}catch(T){console.warn("[PiPChatPanel] Failed to copy message",T)}},[]),x=c.trim().length>0&&!r;return f.jsxs("div",{...l,className:le(An.panel,o),"data-testid":s,role:"region","aria-label":"Chat",children:[f.jsx("div",{className:An.messagesArea,children:e.length===0?f.jsx("div",{className:An.empty,"data-testid":"pip-chat-panel-empty",children:"No messages yet"}):f.jsxs("div",{className:An.messagesList,"data-testid":"pip-chat-panel-list",children:[e.map((b,k)=>{const T=b.id??`${b.timestamp}-${k}`,C=uV(b,n),R=d===T;return f.jsxs("div",{className:le(An.messageItem,C&&An.agentMessage),"data-testid":`pip-chat-panel-message-${T}`,children:[f.jsxs("div",{className:An.messageMetadata,children:[f.jsx("span",{className:An.senderName,children:dV(b,n)}),f.jsx("span",{className:An.timestamp,children:cV(b.timestamp)})]}),f.jsx("div",{className:An.messageBubble,children:b.message}),C?f.jsx("div",{className:An.agentActions,children:f.jsx("button",{type:"button",className:le(An.copyButton,R&&An.copyButtonCopied),onClick:()=>void y(b,T),"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(cE,{size:14})})}):null]},T)}),f.jsx("div",{ref:p})]})}),f.jsxs("div",{className:le(An.composer,r&&An.composerDisabled),children:[f.jsx("input",{type:"text",className:An.composerInput,value:c,onChange:b=>u(b.target.value),onKeyDown:g,placeholder:a,disabled:r,"aria-label":"Message"}),f.jsx("button",{type:"button",className:An.sendButton,onClick:()=>void S(),disabled:!x,"aria-label":"Send message",children:f.jsx(pE,{size:16})})]})]})}const pV="_panel_k5ick_1",mV="_header_k5ick_11",gV="_title_k5ick_19",vV="_titleCompact_k5ick_29",bV="_headerActions_k5ick_33",yV="_closeButton_k5ick_39",_V="_divider_k5ick_67",xV="_body_k5ick_73",SV="_messagesArea_k5ick_81",kV="_scrollable_k5ick_86",TV="_messagesList_k5ick_90",wV="_messageItem_k5ick_98",CV="_messageMetadata_k5ick_104",EV="_senderName_k5ick_112",RV="_timestamp_k5ick_116",AV="_messageBubble_k5ick_120",NV="_messageText_k5ick_124",OV="_agentMessage_k5ick_130",MV="_agentActions_k5ick_134",DV="_copyButton_k5ick_140",PV="_copyButtonCopied_k5ick_174",LV="_inputRow_k5ick_178",IV="_empty_k5ick_182",jV="_composer_k5ick_188",BV="_composerDefault_k5ick_203",UV="_composerCompact_k5ick_208",zV="_composerDisabled_k5ick_218",FV="_composerInputWrapper_k5ick_223",qV="_composerInput_k5ick_223",HV="_sendButton_k5ick_240",VV="_sendButtonCompact_k5ick_257",Je={panel:pV,header:mV,title:gV,titleCompact:vV,headerActions:bV,closeButton:yV,divider:_V,body:xV,messagesArea:SV,scrollable:kV,messagesList:TV,messageItem:wV,messageMetadata:CV,senderName:EV,timestamp:RV,messageBubble:AV,messageText:NV,agentMessage:OV,agentActions:MV,copyButton:DV,copyButtonCopied:PV,inputRow:LV,empty:IV,composer:jV,composerDefault:BV,composerCompact:UV,composerDisabled:zV,composerInputWrapper:FV,composerInput:qV,sendButton:HV,sendButtonCompact:VV};function GV(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 WV(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 YV(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 KV(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 XV(t){const{disabled:e,placeholder:n,size:i="md",autoFocus:r,onSend:a}=t,[o,s]=w.useState(""),l=w.useCallback(async()=>{const p=o.trim();p.length!==0&&(await a(p),s(""))},[a,o]),c=w.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:le(Je.composer,u?Je.composerCompact:Je.composerDefault,e?Je.composerDisabled:null),children:[f.jsx("div",{className:Je.composerInputWrapper,children:f.jsx(gE,{value:o,onChange:s,onKeyDown:c,className:Je.composerInput,placeholder:n??"Send a message ...",disabled:e,size:i,autoFocus:r,"aria-label":"Message"})}),f.jsx("button",{type:"button",className:le(Je.sendButton,u?Je.sendButtonCompact:null),onClick:()=>void l(),disabled:!h,"aria-label":"Send message",children:f.jsx(pE,{size:d})})]})}function d3(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=GV,getSenderName:v,isAgentMessage:m,copyResetDelayMs:S=2e3,showAgentCopyButton:g=!0,inputPlaceholder:y,inputAutoFocus:x,...b}=t,k=w.useRef(null),[T,C]=w.useState(null),R=w.useRef(null),A=w.useCallback(W=>v?v(W):YV(W,o),[v,o]),N=w.useCallback(W=>m?m(W,o):WV(W,o),[m,o]),O=w.useMemo(()=>{const W=r[r.length-1];return W?W.id??`${W.timestamp}-${r.length-1}`:null},[r]);w.useEffect(()=>{var W,P;(P=(W=k.current)==null?void 0:W.scrollIntoView)==null||P.call(W,{behavior:"smooth"})},[O]),w.useEffect(()=>()=>{R.current&&(window.clearTimeout(R.current),R.current=null)},[]);const U=w.useCallback(W=>{C(W),R.current&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{C(null),R.current=null},S)},[S]),G=w.useCallback(async(W,P)=>{try{await KV(W.message??""),U(P)}catch(X){console.warn("[ChatPanel] Failed to copy message",X)}},[U]),L=d==="compact"?"sm":"md";return f.jsxs(yu,{...b,className:le(Je.panel,i),role:"region","aria-label":n??e,"data-testid":h,children:[f.jsxs("div",{className:Je.header,children:[f.jsx(hi,{as:"h2",className:le(Je.title,d==="compact"?Je.titleCompact:null),children:e}),l&&c?f.jsx("div",{className:Je.headerActions,children:f.jsx("button",{type:"button",className:Je.closeButton,onClick:l,"aria-label":`Close ${e}`,children:f.jsx(Hf,{size:d==="compact"?18:20})})}):null]}),f.jsx("div",{className:Je.divider,"aria-hidden":"true"}),f.jsxs("div",{className:Je.body,children:[f.jsx("div",{className:Je.messagesArea,children:f.jsx(Sl,{className:Je.scrollable,children:r.length===0?f.jsx(hi,{variant:"muted",className:Je.empty,"data-testid":"chat-panel-empty",children:u}):f.jsxs("div",{className:Je.messagesList,"data-testid":"chat-panel-list",children:[r.map((W,P)=>{const X=W.id??`${W.timestamp}-${P}`,J=N(W),re=T===X;return f.jsxs("div",{className:le(Je.messageItem,J?Je.agentMessage:null),"data-testid":`chat-panel-message-${X}`,children:[f.jsxs("div",{className:Je.messageMetadata,children:[f.jsx("span",{className:Je.senderName,children:A(W)}),f.jsx("span",{className:Je.timestamp,children:p(W.timestamp)})]}),f.jsx(rp,{className:Je.messageBubble,padding:"md",radius:"panel",background:J?"surfaceMuted":"surface",children:f.jsx("div",{className:Je.messageText,children:W.message})}),J&&g?f.jsx("div",{className:Je.agentActions,children:f.jsx("button",{type:"button",className:le(Je.copyButton,re?Je.copyButtonCopied:null),onClick:()=>void G(W,X),"aria-label":re?"Copied":"Copy agent message",title:re?"Copied":"Copy agent message","data-testid":"copy-agent-message","data-copied":re?"true":"false",children:f.jsx(cE,{size:18})})}):null]},X)}),f.jsx("div",{ref:k})]})})}),f.jsx("div",{className:Je.inputRow,children:f.jsx(XV,{onSend:s,disabled:a,placeholder:y,size:L,autoFocus:x})})]})]})}const $V="_responsive_14d0j_2",_u={responsive:$V,"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 QV(t){const{as:e,children:n,showAboveWidth:i,hideAboveWidth:r,showAboveHeight:a,hideAboveHeight:o,className:s,...l}=t,c=[_u.responsive];return i&&c.push(_u[`showAboveWidth-${i}`]),r&&c.push(_u[`hideAboveWidth-${r}`]),a&&c.push(_u[`showAboveHeight-${a}`]),o&&c.push(_u[`hideAboveHeight-${o}`]),f.jsx(e??"div",{...l,className:le(c,s),children:n})}w.createContext("vertical");const JV="_container_1a1i6_1",ZV="_video_1a1i6_7",eG="_chip_1a1i6_16",tG="_logo_1a1i6_34",ap={container:JV,video:ZV,chip:eG,logo:tG},nG="https://obi-static.s3.ap-southeast-2.amazonaws.com/videos/greeting.mp4";function iG(t){const{agentName:e="Obi",className:n,...i}=t,r=w.useRef(null),a=()=>{var o;try{(o=r.current)==null||o.pause()}catch{}};return f.jsxs("div",{className:le(ap.container,n),...i,children:[f.jsx("video",{ref:r,className:ap.video,src:nG,autoPlay:!0,muted:!0,playsInline:!0,onEnded:a}),f.jsxs("div",{className:ap.chip,children:[f.jsx(TB,{size:14,className:ap.logo}),f.jsx("span",{children:e})]})]})}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const h3=50,wl="?",f3=/\(error: (.*)\)/,p3=/captureMessage|captureException/;function rG(...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(`
133
- `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=f3.test(l)?l.replace(f3,"$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>=h3+r)break}}return aG(a.slice(r))}}function aG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(op(e).function||"")&&e.pop(),e.reverse(),p3.test(op(e).function||"")&&(e.pop(),p3.test(op(e).function||"")&&e.pop()),e.slice(0,h3).map(n=>({...n,filename:n.filename||op(e).filename,function:n.function||wl}))}function op(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const oG=30,sG=50;function Lb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?wl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const lG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,cG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,uG=/\((\S*)(?::(\d+))(?::(\d+))\)/,dG=t=>{const e=lG.exec(t);if(e){const[,i,r,a]=e;return Lb(i,wl,+r,+a)}const n=cG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=uG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=m3(n[1]||wl,n[2]);return Lb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},hG=[oG,dG],fG=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;rG(...[hG,[sG,t=>{const e=fG.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=pG.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]||wl;return[i,n]=m3(i,n),Lb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const m3=(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]:wl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Xi={shell:"_shell_1k5hq_1",layout:"_layout_1k5hq_11",layoutThree:"_layoutThree_1k5hq_23",leftPanel:"_leftPanel_1k5hq_27",middlePanel:"_middlePanel_1k5hq_36",rightPanel:"_rightPanel_1k5hq_37",videoFrame:"_videoFrame_1k5hq_41",captions:"_captions_1k5hq_52",controls:"_controls_1k5hq_58",coursePanel:"_coursePanel_1k5hq_71",returnToPiPOverlay:"_returnToPiPOverlay_1k5hq_82",returnToPiPButton:"_returnToPiPButton_1k5hq_95"};function Ib(...t){return t.filter(Boolean).join(" ")}function mG(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:Ib(Xi.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Ib(Xi.layout,u?Xi.layoutThree:null),children:[f.jsxs("div",{className:Xi.leftPanel,children:[f.jsxs("div",{className:Xi.videoFrame,children:[d&&h&&f.jsx("div",{className:Xi.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:Xi.returnToPiPButton,onClick:h,"aria-label":"Return to PiP",children:f.jsx(SB,{size:14})})}),f.jsx(qq,{className:Xi.captions,text:e,children:f.jsx(n3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:Xi.controls,children:f.jsx(mF,{...o})})]}),u?f.jsx("div",{className:Xi.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:Xi.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(yH,{...l,courses:s,className:Ib(Xi.coursePanel,l==null?void 0:l.className)})})]})})}function g3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(TE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mG,{...r})})}const gG=80,vG=500,bG=1e3;function yG(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]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.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 w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>gG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},vG+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},bG+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const br={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 _G(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}=t;return f.jsx(TE,{open:e,onClose:n,size:"large",showCloseButton:c,className:br.dialogWithSmallClose,children:f.jsxs("div",{className:br.layout,children:[f.jsxs("div",{className:br.left,children:[f.jsxs("div",{className:br.copy,children:[f.jsx(hi,{variant:"heading",children:r}),f.jsx(hi,{variant:"subheading",children:a}),f.jsx(hi,{variant:"muted",as:"div",className:br.description,children:f.jsx(Sl,{className:br.descriptionScroller,children:f.jsx(Dz,{content:o})})})]}),f.jsxs("div",{className:br.cta,children:[f.jsx(xl,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(hi,{variant:"subscript",as:"p",className:br.disclaimer,children:l})]})]}),f.jsx(QV,{showAboveWidth:"md",children:f.jsx("div",{className:br.right,children:f.jsx(yu,{className:br.mediaPanel,children:f.jsx(iG,{agentName:r,className:br.agentStill})})})})]})})}const xG={launcherPill:"_launcherPill_1fhyr_1"};function SG(t){const{onClick:e}=t;return f.jsx("button",{type:"button",className:xG.launcherPill,onClick:e,"data-testid":"ai-coach-pill",children:"AI Coach"})}function kG(t){var fi,Ei,ce,He,Ce,Ye,at,Kn,pi,yr,H,ie,ue,je,Re,ft,Xn,$i,ya,$n,Qn,Qi,mi;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((fi=e.client)==null?void 0:fi.selectedPlanUuid)??null:null,a=((Ei=e.client)==null?void 0:Ei.session)??null,[o,s]=w.useState(()=>a),[l,c]=w.useState(()=>a!=null&&a.sessionUuid?wG(a.sessionUuid):null),u=(()=>{var te;return a?((te=a.roomId)==null?void 0:te.startsWith("obs-"))&&!l?"course-selection":"pip":r?"start-session":"hidden"})(),[d,h]=w.useState(()=>u),[p,v]=w.useState(!1),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,b]=w.useState([]),[k,T]=w.useState(null),[C,R]=w.useState(0),[A,N]=w.useState(!1),[O,U]=w.useState(0),[G,L]=w.useState(null),[W,P]=w.useState([]),[X,J]=w.useState(!1),re=CG((He=(ce=e.client)==null?void 0:ce.product)==null?void 0:He.widget_url_blacklist),$=EG(o),{audioDevices:F}=RG();w.useEffect(()=>{o!=null&&o.sessionUuid&&v3(o.sessionUuid,l)},[l,o==null?void 0:o.sessionUuid]);const{caption:Z}=yG(W,{delayMs:0}),K=X?Z:"",se=typeof navigator<"u"&&!!((Ce=navigator.mediaDevices)!=null&&Ce.getDisplayMedia),j=((at=(Ye=o==null?void 0:o.room)==null?void 0:Ye.localParticipant)==null?void 0:at.isScreenShareEnabled)??!1,me=(()=>{if(o!=null&&o.speakingState){if(o.speakingState==="thinking")return"thinking";if(o.speakingState==="busy")return"searching"}})(),B=TG({sdk:e,session:o,isBlacklisted:re}),de=!i&&B,ge=!!(o??((Kn=e.client)==null?void 0:Kn.session)??null),Et=()=>R(te=>te+1),mn=async()=>{var _e,he;if(!o)return;const te=((he=(_e=o.room)==null?void 0:_e.localParticipant)==null?void 0:he.isScreenShareEnabled)??!1;try{te?await o.setScreenShareEnabled(!1):await o.shareScreen()}catch(Te){console.error("[obi-sdk] failed to toggle screen share",Te)}finally{Et()}},Se=w.useRef(null),ke=w.useRef(null),ct=w.useRef(!1),tt=te=>{if(!te||Se.current===te)return;ke.current&&(ke.current(),ke.current=null);const _e=()=>Et(),he=Rt=>{c(Rt),te!=null&&te.sessionUuid&&v3(te.sessionUuid,Rt),h(fe=>fe==="course-selection"?(N(!1),"pip"):fe)},Te=Rt=>{b(Rt.courses),h("course-selection"),c(null),te!=null&&te.sessionUuid&&b3(te.sessionUuid),T(null)},Vt=(Rt,fe)=>{},gt=Rt=>{L(Rt),U(Date.now())},Jt=Rt=>{if(!Rt){L(null);return}L(Rt),U(Date.now())};te.on("stateChanged",_e),te.on("speakingStateChanged",_e),te.on("paused",_e),te.on("unpaused",_e),te.on("chatMessagesChanged",_e),te.on("courseProgress",he),te.on("courseSelection",Te),te.on("transcript",Vt),te.on("screenCaptured",gt),te.on("screenCaptureNotification",Jt),te.on("captions",P),Se.current=te,ke.current=()=>{te.off("stateChanged",_e),te.off("speakingStateChanged",_e),te.off("paused",_e),te.off("unpaused",_e),te.off("chatMessagesChanged",_e),te.off("courseProgress",he),te.off("courseSelection",Te),te.off("transcript",Vt),te.off("screenCaptured",gt),te.off("screenCaptureNotification",Jt),te.off("captions",P)}},Qt=te=>{var he;return te?((he=te.roomId)==null?void 0:he.startsWith("obs-"))&&!l?"course-selection":"pip":"hidden"};w.useEffect(()=>{const te=he=>{var Te,Vt,gt,Jt;if(he)if((Te=e.client)!=null&&Te.session)h(Qt(((gt=e.client)==null?void 0:gt.session)??null));else{const fe=!!e.passivePlanUuid,kt=fe&&!!((Vt=e.client)!=null&&Vt.selectedPlanUuid);if(fe&&!kt)return;h("start-session")}else(Jt=e.client)!=null&&Jt.session||h("hidden")},_e=()=>Et();if(e.on("showMenu",te),e.on("configUpdated",_e),e.client){e.client.session&&(s(e.client.session),tt(e.client.session),h(Qt(e.client.session))),e.client.on("sessionStarted",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te)),Ha().track("session-started",{planId:Te.planId})}),e.client.on("sessionResumed",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te))});const he=()=>{var Vt;const Te=(Vt=e.client)==null?void 0:Vt.session;Te!=null&&Te.sessionUuid&&b3(Te.sessionUuid),ke.current&&(ke.current(),ke.current=null),s(null),Se.current=null,v(!1),S(!1),y(!1),ct.current||h("hidden")};e.client.on("sessionStopped",he),e.client.on("sessionShutdown",he),e.client.on("stateChanged",Et)}return()=>{e.off("showMenu",te),e.off("configUpdated",_e),ke.current&&ke.current()}},[e]),w.useLayoutEffect(()=>{var te,_e;(_e=(te=e.client)==null?void 0:te.product)!=null&&_e.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(yr=(pi=e.client)==null?void 0:pi.product)==null?void 0:yr.primary_color,n]),w.useEffect(()=>{if(i&&!re&&!ge){if(!r){h("hidden");return}h("start-session")}},[ge,i,re,r]);const gn=(l==null?void 0:l.stepNames.map((te,_e)=>({id:`step-${_e+1}`,title:te})))??[],Nt=(l==null?void 0:l.currentStep)??null,vn=!0,Nn=(te,_e)=>{o==null||o.say(`Can we jump to the section about ${_e.title}?`)};if(re||i&&!r&&!ge)return null;if(d==="hidden")return de?f.jsx(SG,{onClick:()=>{e.updateShowMenu(!0)}}):null;if(d==="start-session"){const te=(H=e.client)==null?void 0:H.product,_e=(ie=e.client)==null?void 0:ie.selectedPlan,he=i&&!!r,Te=(te==null?void 0:te.agent_name)||"Obi",Vt=(te==null?void 0:te.assistant_subtitle)||"AI Assistant",gt=he?(_e==null?void 0:_e.description)||(te==null?void 0:te.assistant_description)||(te==null?void 0:te.description)||"I'm here to help you.":(te==null?void 0:te.assistant_description)||(_e==null?void 0:_e.description)||(te==null?void 0:te.description)||"I'm here to help you.";return f.jsx(_G,{open:!0,onClose:()=>{v(!1),h("hidden")},onStart:()=>{v(!0),e.startSession({withMicrophone:!0})},agentName:Te,agentSubtitle:Vt,description:gt,showCloseButton:!0,startLabel:"Start Session",isStarting:p})}if(d==="course-selection"){const te=(ue=o==null?void 0:o.roomId)==null?void 0:ue.startsWith("obs-"),_e=((je=e.client)==null?void 0:je.plans)||[],he=te&&x.length>0,Te=he?x.slice().sort((fe,kt)=>fe.order!==void 0&&kt.order!==void 0?fe.order-kt.order:fe.order!==void 0?-1:kt.order!==void 0?1:fe.name.localeCompare(kt.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})):_e.map(fe=>{var kt,pt;return{id:fe.uuid,title:fe.name,description:fe.description,status:(pt=(kt=e.client)==null?void 0:kt.planIsCompleted)!=null&&pt[_e.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}}),Vt=(o==null?void 0:o.languageCodes)||[],gt=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,Jt={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),o&&fe&&await o.switchMicrophoneDevice(fe),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:Vt,selectedLanguage:gt,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Rt=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Re=o==null?void 0:o.room)==null?void 0:Re.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},onClose:()=>y(!1)}):void 0;return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:Te,controlBarProps:Jt,coursePanelProps:{selectedCourseIds:k?[k]:void 0,onCourseToggle:async fe=>{var kt,pt,At;if(he){const bn=x.find(Ri=>Ri.uuid===fe);if(bn){T(fe);try{await((kt=o==null?void 0:o.say)==null?void 0:kt.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),T(null)}}}else{const bn=_e.find(Ri=>Ri.uuid===fe);if(bn){(pt=e.client)==null||pt.selectPlan(bn),h("pip");try{await((At=o==null?void 0:o.say)==null?void 0:At.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),h("course-selection")}}}}},rightPanel:Rt,avatarImageSrc:((Xn=(ft=e.client)==null?void 0:ft.product)==null?void 0:Xn.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="course-outline"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async gt=>{e.client&&(e.client.preferredMicrophoneDeviceId=gt),o&&gt&&await o.switchMicrophoneDevice(gt),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:gt=>{o==null||o.setLanguage(gt)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Te=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:(($i=o==null?void 0:o.room)==null?void 0:$i.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async gt=>{var Jt,Rt,fe,kt;o&&(o.appendChatMessage({timestamp:Date.now(),message:gt,from:{identity:((Rt=(Jt=o.room)==null?void 0:Jt.localParticipant)==null?void 0:Rt.identity)??null,name:((kt=(fe=o.room)==null?void 0:fe.localParticipant)==null?void 0:kt.name)??null},isAgent:!1}),await o.say(gt))},onClose:()=>y(!1)}):void 0,Vt=f.jsx(GH,{steps:gn,currentStep:Nt,hideTrailingConclusionStep:vn,onStepClick:Nn});return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:[],controlBarProps:he,middlePanel:Vt,rightPanel:Te,avatarImageSrc:(($n=(ya=e.client)==null?void 0:ya.product)==null?void 0:$n.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="pip"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he=280,Te=250,Vt=16,gt={x:window.innerWidth-he-Vt,y:window.innerHeight-Te-Vt},Jt={isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isChatOpen:g,isScreenShareActive:j,onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>y(fe=>!fe),onScreenShareToggle:mn,onLeave:()=>{o==null||o.stop()},languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0},Rt=g?f.jsx(fV,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Qn=o==null?void 0:o.room)==null?void 0:Qn.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},testId:"pip-chat-panel"}):void 0;return f.jsx(jq,{initialPosition:gt,onExit:()=>{h("course-outline")},controlBarProps:Jt,isCourseOutlineSelected:A&&!!l,onCourseOutlineToggle:l?()=>{N(fe=>!fe)}:void 0,isCaptionsEnabled:X,onCaptionsToggle:()=>J(fe=>!fe),courseOutline:l?{steps:gn,currentStep:Nt,onStepClick:Nn,hideTrailingConclusionStep:vn}:void 0,messagesPanel:Rt,avatarFallbackProps:{audioPower:$,imageSrc:((mi=(Qi=e.client)==null?void 0:Qi.product)==null?void 0:mi.logo_url)??void 0,status:me,captionsText:K},screenshotUrl:G,cameraShotTrigger:O})}return null}function TG(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 v3(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 wG(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 b3(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 CG(t){const[e,n]=w.useState(()=>Zo(t));return w.useEffect(()=>{n(Zo(t))},[t]),w.useEffect(()=>{const i=()=>{n(Zo(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function EG(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.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 RG(){const[t,e]=w.useState({audioDevices:[]});return w.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 AG(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t==="getcor.ai"||t==="getcor.io"}const y3=AG();function NG(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;OG();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(lB);const a=[r];if(y3){const s=new CSSStyleSheet;s.replaceSync(aB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(sB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(oB),a.push(s)}n.adoptedStyleSheets=a;const o=rB.createRoot(i);y3?o.render(f.jsx(kG,{sdk:t,shadowHost:e})):o.render(f.jsx(dB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function OG(){_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 x3="49206C6F7665204F6269_session",S3="obi-url-params";class MG extends up{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=lh.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new lh(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,p,v;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((v=(p=this.client)==null?void 0:p.product)==null?void 0:v.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Zo(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{Ha().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){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),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&&Ha().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){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}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(S3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[x3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(x3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(S3),this.passivePlanUuid=n}mountWidget(){NG(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await QN(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await G3(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 AN(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")}}async function k3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return DG({appToken:t,window:n,init:e})}async function DG({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 MG(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function T3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{k3(void 0,T3)}):k3(void 0,T3)})();
133
+ `);for(let s=i;s<o.length;s++){const l=o[s];if(l.length>1024)continue;const c=f3.test(l)?l.replace(f3,"$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>=h3+r)break}}return aG(a.slice(r))}}function aG(t){if(!t.length)return[];const e=Array.from(t);return/sentryWrapped/.test(op(e).function||"")&&e.pop(),e.reverse(),p3.test(op(e).function||"")&&(e.pop(),p3.test(op(e).function||"")&&e.pop()),e.slice(0,h3).map(n=>({...n,filename:n.filename||op(e).filename,function:n.function||wl}))}function op(t){return t[t.length-1]||{}}typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const oG=30,sG=50;function Lb(t,e,n,i){const r={filename:t,function:e==="<anonymous>"?wl:e,in_app:!0};return n!==void 0&&(r.lineno=n),i!==void 0&&(r.colno=i),r}const lG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,cG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,uG=/\((\S*)(?::(\d+))(?::(\d+))\)/,dG=t=>{const e=lG.exec(t);if(e){const[,i,r,a]=e;return Lb(i,wl,+r,+a)}const n=cG.exec(t);if(n){if(n[2]&&n[2].indexOf("eval")===0){const a=uG.exec(n[2]);a&&(n[2]=a[1],n[3]=a[2],n[4]=a[3])}const[i,r]=m3(n[1]||wl,n[2]);return Lb(r,i,n[3]?+n[3]:void 0,n[4]?+n[4]:void 0)}},hG=[oG,dG],fG=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,pG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i;rG(...[hG,[sG,t=>{const e=fG.exec(t);if(e){if(e[3]&&e[3].indexOf(" > eval")>-1){const r=pG.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]||wl;return[i,n]=m3(i,n),Lb(n,i,e[4]?+e[4]:void 0,e[5]?+e[5]:void 0)}}]]);const m3=(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]:wl,n?`safari-extension:${e}`:`safari-web-extension:${e}`]:[t,e]};typeof __SENTRY_DEBUG__>"u"||__SENTRY_DEBUG__;const Xi={shell:"_shell_1k5hq_1",layout:"_layout_1k5hq_11",layoutThree:"_layoutThree_1k5hq_23",leftPanel:"_leftPanel_1k5hq_27",middlePanel:"_middlePanel_1k5hq_36",rightPanel:"_rightPanel_1k5hq_37",videoFrame:"_videoFrame_1k5hq_41",captions:"_captions_1k5hq_52",controls:"_controls_1k5hq_58",coursePanel:"_coursePanel_1k5hq_71",returnToPiPOverlay:"_returnToPiPOverlay_1k5hq_82",returnToPiPButton:"_returnToPiPButton_1k5hq_95"};function Ib(...t){return t.filter(Boolean).join(" ")}function mG(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:Ib(Xi.shell,p),"data-testid":"course-dialog-content",children:f.jsxs("div",{className:Ib(Xi.layout,u?Xi.layoutThree:null),children:[f.jsxs("div",{className:Xi.leftPanel,children:[f.jsxs("div",{className:Xi.videoFrame,children:[d&&h&&f.jsx("div",{className:Xi.returnToPiPOverlay,children:f.jsx("button",{type:"button",className:Xi.returnToPiPButton,onClick:h,"aria-label":"Return to PiP",children:f.jsx(SB,{size:14})})}),f.jsx(qq,{className:Xi.captions,text:e,children:f.jsx(n3,{audioPower:n,size:"lg",background:"flat",imageSrc:i,ariaLabel:r??"Agent avatar placeholder",status:a})})]}),f.jsx("div",{className:Xi.controls,children:f.jsx(mF,{...o})})]}),u?f.jsx("div",{className:Xi.rightPanel,"data-testid":"course-dialog-right-panel",children:u}):null,f.jsx("div",{className:Xi.middlePanel,"data-testid":"course-dialog-middle-panel",children:c??f.jsx(yH,{...l,courses:s,className:Ib(Xi.coursePanel,l==null?void 0:l.className)})})]})})}function g3(t){const{open:e,onClose:n,dialogProps:i,...r}=t;return f.jsx(TE,{open:e,onClose:n,variant:"ghost",...i,children:f.jsx(mG,{...r})})}const gG=80,vG=500,bG=1e3;function yG(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]=w.useState(""),[s,l]=w.useState(!1),c=w.useRef(""),u=w.useRef(null),d=w.useRef(null),h=w.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 w.useEffect(()=>{if(d.current&&(clearTimeout(d.current),d.current=null),s)return;const m=v(r,c.current);p(m),m.length>gG?(l(!0),u.current=setTimeout(()=>{l(!1),c.current=r},vG+n)):m.length>0&&(d.current=setTimeout(()=>{c.current=r,p("")},bG+n))},[r,s,n]),w.useEffect(()=>()=>{u.current&&clearTimeout(u.current),d.current&&clearTimeout(d.current),h.current&&clearTimeout(h.current)},[]),{caption:a,hasCaption:a.length>0}}const br={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 _G(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}=t;return f.jsx(TE,{open:e,onClose:n,size:"large",showCloseButton:c,className:br.dialogWithSmallClose,children:f.jsxs("div",{className:br.layout,children:[f.jsxs("div",{className:br.left,children:[f.jsxs("div",{className:br.copy,children:[f.jsx(hi,{variant:"heading",children:r}),f.jsx(hi,{variant:"subheading",children:a}),f.jsx(hi,{variant:"muted",as:"div",className:br.description,children:f.jsx(Sl,{className:br.descriptionScroller,children:f.jsx(Dz,{content:o})})})]}),f.jsxs("div",{className:br.cta,children:[f.jsx(xl,{type:"button",size:"lg",fullWidth:!0,onClick:i,isLoading:u,children:s}),f.jsx(hi,{variant:"subscript",as:"p",className:br.disclaimer,children:l})]})]}),f.jsx(QV,{showAboveWidth:"md",children:f.jsx("div",{className:br.right,children:f.jsx(yu,{className:br.mediaPanel,children:f.jsx(iG,{agentName:r,className:br.agentStill})})})})]})})}const xG={launcherPill:"_launcherPill_1fhyr_1"};function SG(t){const{onClick:e}=t;return f.jsx("button",{type:"button",className:xG.launcherPill,onClick:e,"data-testid":"ai-coach-pill",children:"AI Coach"})}function kG(t){var fi,Ei,ce,He,Ce,Ye,at,Kn,pi,yr,H,ie,ue,je,Re,ft,Xn,$i,ya,$n,Qn,Qi,mi;const{sdk:e,shadowHost:n}=t,i=!!e.passivePlanUuid,r=i?((fi=e.client)==null?void 0:fi.selectedPlanUuid)??null:null,a=((Ei=e.client)==null?void 0:Ei.session)??null,[o,s]=w.useState(()=>a),[l,c]=w.useState(()=>a!=null&&a.sessionUuid?wG(a.sessionUuid):null),u=(()=>{var te;return a?((te=a.roomId)==null?void 0:te.startsWith("obs-"))&&!l?"course-selection":"pip":r?"start-session":"hidden"})(),[d,h]=w.useState(()=>u),[p,v]=w.useState(!1),[m,S]=w.useState(!1),[g,y]=w.useState(!1),[x,b]=w.useState([]),[k,T]=w.useState(null),[C,R]=w.useState(0),[A,N]=w.useState(!1),[O,U]=w.useState(0),[G,L]=w.useState(null),[W,P]=w.useState([]),[X,J]=w.useState(!1),re=CG((He=(ce=e.client)==null?void 0:ce.product)==null?void 0:He.widget_url_blacklist),$=EG(o),{audioDevices:F}=RG();w.useEffect(()=>{o!=null&&o.sessionUuid&&v3(o.sessionUuid,l)},[l,o==null?void 0:o.sessionUuid]);const{caption:Z}=yG(W,{delayMs:0}),K=X?Z:"",se=typeof navigator<"u"&&!!((Ce=navigator.mediaDevices)!=null&&Ce.getDisplayMedia),j=((at=(Ye=o==null?void 0:o.room)==null?void 0:Ye.localParticipant)==null?void 0:at.isScreenShareEnabled)??!1,me=(()=>{if(o!=null&&o.speakingState){if(o.speakingState==="thinking")return"thinking";if(o.speakingState==="busy")return"searching"}})(),B=TG({sdk:e,session:o,isBlacklisted:re}),de=!i&&B,ge=!!(o??((Kn=e.client)==null?void 0:Kn.session)??null),Et=()=>R(te=>te+1),mn=async()=>{var _e,he;if(!o)return;const te=((he=(_e=o.room)==null?void 0:_e.localParticipant)==null?void 0:he.isScreenShareEnabled)??!1;try{te?await o.setScreenShareEnabled(!1):await o.shareScreen()}catch(Te){console.error("[obi-sdk] failed to toggle screen share",Te)}finally{Et()}},Se=w.useRef(null),ke=w.useRef(null),ct=w.useRef(!1),tt=te=>{if(!te||Se.current===te)return;ke.current&&(ke.current(),ke.current=null);const _e=()=>Et(),he=Rt=>{c(Rt),te!=null&&te.sessionUuid&&v3(te.sessionUuid,Rt),h(fe=>fe==="course-selection"?(N(!1),"pip"):fe)},Te=Rt=>{b(Rt.courses),h("course-selection"),c(null),te!=null&&te.sessionUuid&&b3(te.sessionUuid),T(null)},Vt=(Rt,fe)=>{},gt=Rt=>{L(Rt),U(Date.now())},Jt=Rt=>{if(!Rt){L(null);return}L(Rt),U(Date.now())};te.on("stateChanged",_e),te.on("speakingStateChanged",_e),te.on("paused",_e),te.on("unpaused",_e),te.on("chatMessagesChanged",_e),te.on("courseProgress",he),te.on("courseSelection",Te),te.on("transcript",Vt),te.on("screenCaptured",gt),te.on("screenCaptureNotification",Jt),te.on("captions",P),Se.current=te,ke.current=()=>{te.off("stateChanged",_e),te.off("speakingStateChanged",_e),te.off("paused",_e),te.off("unpaused",_e),te.off("chatMessagesChanged",_e),te.off("courseProgress",he),te.off("courseSelection",Te),te.off("transcript",Vt),te.off("screenCaptured",gt),te.off("screenCaptureNotification",Jt),te.off("captions",P)}},Qt=te=>{var he;return te?((he=te.roomId)==null?void 0:he.startsWith("obs-"))&&!l?"course-selection":"pip":"hidden"};w.useEffect(()=>{const te=he=>{var Te,Vt,gt,Jt;if(he)if((Te=e.client)!=null&&Te.session)h(Qt(((gt=e.client)==null?void 0:gt.session)??null));else{const fe=!!e.passivePlanUuid,kt=fe&&!!((Vt=e.client)!=null&&Vt.selectedPlanUuid);if(fe&&!kt)return;h("start-session")}else(Jt=e.client)!=null&&Jt.session||h("hidden")},_e=()=>Et();if(e.on("showMenu",te),e.on("configUpdated",_e),e.client){e.client.session&&(s(e.client.session),tt(e.client.session),h(Qt(e.client.session))),e.client.on("sessionStarted",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te)),Ha().track("session-started",{planId:Te.planId})}),e.client.on("sessionResumed",Te=>{s(Te),tt(Te),ct.current=!1,v(!1),S(!1),y(!1),h(Qt(Te))});const he=()=>{var Vt;const Te=(Vt=e.client)==null?void 0:Vt.session;Te!=null&&Te.sessionUuid&&b3(Te.sessionUuid),ke.current&&(ke.current(),ke.current=null),s(null),Se.current=null,v(!1),S(!1),y(!1),ct.current||h("hidden")};e.client.on("sessionStopped",he),e.client.on("sessionShutdown",he),e.client.on("stateChanged",Et)}return()=>{e.off("showMenu",te),e.off("configUpdated",_e),ke.current&&ke.current()}},[e]),w.useLayoutEffect(()=>{var te,_e;(_e=(te=e.client)==null?void 0:te.product)!=null&&_e.primary_color&&n.style.setProperty("--obi-color-primary",e.client.product.primary_color)},[(yr=(pi=e.client)==null?void 0:pi.product)==null?void 0:yr.primary_color,n]),w.useEffect(()=>{if(i&&!re&&!ge){if(!r){h("hidden");return}h("start-session")}},[ge,i,re,r]);const gn=(l==null?void 0:l.stepNames.map((te,_e)=>({id:`step-${_e+1}`,title:te})))??[],Nt=(l==null?void 0:l.currentStep)??null,vn=!0,Nn=(te,_e)=>{o==null||o.say(`Can we jump to the section about ${_e.title}?`)};if(re||i&&!r&&!ge)return null;if(d==="hidden")return de?f.jsx(SG,{onClick:()=>{e.updateShowMenu(!0)}}):null;if(d==="start-session"){const te=(H=e.client)==null?void 0:H.product,_e=(ie=e.client)==null?void 0:ie.selectedPlan,he=i&&!!r,Te=(te==null?void 0:te.agent_name)||"Obi",Vt=(te==null?void 0:te.assistant_subtitle)||"AI Assistant",gt=he?(_e==null?void 0:_e.description)||(te==null?void 0:te.assistant_description)||(te==null?void 0:te.description)||"I'm here to help you.":(te==null?void 0:te.assistant_description)||(_e==null?void 0:_e.description)||(te==null?void 0:te.description)||"I'm here to help you.";return f.jsx(_G,{open:!0,onClose:()=>{v(!1),h("hidden")},onStart:()=>{v(!0),e.startSession({withMicrophone:!0})},agentName:Te,agentSubtitle:Vt,description:gt,showCloseButton:!1,startLabel:"Start Session",isStarting:p})}if(d==="course-selection"){const te=(ue=o==null?void 0:o.roomId)==null?void 0:ue.startsWith("obs-"),_e=((je=e.client)==null?void 0:je.plans)||[],he=te&&x.length>0,Te=he?x.slice().sort((fe,kt)=>fe.order!==void 0&&kt.order!==void 0?fe.order-kt.order:fe.order!==void 0?-1:kt.order!==void 0?1:fe.name.localeCompare(kt.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})):_e.map(fe=>{var kt,pt;return{id:fe.uuid,title:fe.name,description:fe.description,status:(pt=(kt=e.client)==null?void 0:kt.planIsCompleted)!=null&&pt[_e.indexOf(fe)]?"completed":"available",duration:fe.estimated_duration?`${fe.estimated_duration} min`:void 0}}),Vt=(o==null?void 0:o.languageCodes)||[],gt=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,Jt={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async fe=>{e.client&&(e.client.preferredMicrophoneDeviceId=fe),o&&fe&&await o.switchMicrophoneDevice(fe),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:Vt,selectedLanguage:gt,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Rt=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Re=o==null?void 0:o.room)==null?void 0:Re.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},onClose:()=>y(!1)}):void 0;return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:Te,controlBarProps:Jt,coursePanelProps:{selectedCourseIds:k?[k]:void 0,onCourseToggle:async fe=>{var kt,pt,At;if(he){const bn=x.find(Ri=>Ri.uuid===fe);if(bn){T(fe);try{await((kt=o==null?void 0:o.say)==null?void 0:kt.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),T(null)}}}else{const bn=_e.find(Ri=>Ri.uuid===fe);if(bn){(pt=e.client)==null||pt.selectPlan(bn),h("pip");try{await((At=o==null?void 0:o.say)==null?void 0:At.call(o,`I'd like to take the ${bn.name} course.`))}catch(Ri){console.error("[obi-sdk] failed to send course selection",Ri),h("course-selection")}}}}},rightPanel:Rt,avatarImageSrc:((Xn=(ft=e.client)==null?void 0:ft.product)==null?void 0:Xn.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="course-outline"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he={audioDevices:F,currentMicrophoneId:(o==null?void 0:o.preferredMicrophoneDeviceId)||null,isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isScreenShareActive:j,widgetState:g?"chat":null,canPublishData:!0,browserSupportsScreenSharing:se,onMicDeviceSelect:async gt=>{e.client&&(e.client.preferredMicrophoneDeviceId=gt),o&&gt&&await o.switchMicrophoneDevice(gt),Et()},onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>{y(!g)},onLeave:()=>{o==null||o.stop()},onScreenShareToggle:mn,languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:gt=>{o==null||o.setLanguage(gt)},isLanguageSelectorEnabled:!0,...g?{screenShareButtonVariant:"compact"}:{}},Te=g?f.jsx(d3,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:(($i=o==null?void 0:o.room)==null?void 0:$i.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async gt=>{var Jt,Rt,fe,kt;o&&(o.appendChatMessage({timestamp:Date.now(),message:gt,from:{identity:((Rt=(Jt=o.room)==null?void 0:Jt.localParticipant)==null?void 0:Rt.identity)??null,name:((kt=(fe=o.room)==null?void 0:fe.localParticipant)==null?void 0:kt.name)??null},isAgent:!1}),await o.say(gt))},onClose:()=>y(!1)}):void 0,Vt=f.jsx(GH,{steps:gn,currentStep:Nt,hideTrailingConclusionStep:vn,onStepClick:Nn});return f.jsx(g3,{open:!0,onClose:()=>o==null?void 0:o.stop(),courses:[],controlBarProps:he,middlePanel:Vt,rightPanel:Te,avatarImageSrc:(($n=(ya=e.client)==null?void 0:ya.product)==null?void 0:$n.logo_url)||void 0,avatarAudioPower:$,avatarStatus:me,captionsText:K})}if(d==="pip"){const te=(o==null?void 0:o.languageCodes)||[],_e=(o==null?void 0:o.selectedLanguage)||(o==null?void 0:o.defaultLanguageCode)||null,he=280,Te=250,Vt=16,gt={x:window.innerWidth-he-Vt,y:window.innerHeight-Te-Vt},Jt={isMicrophoneEnabled:!m&&((o==null?void 0:o.isMicShared)??!1),isChatOpen:g,isScreenShareActive:j,onMicToggle:async()=>{o!=null&&o.isMicShared?m?(o.unmuteMicrophone(),S(!1)):(o.muteMicrophone(),S(!0)):await(o==null?void 0:o.shareMicrophone())},onChatToggle:()=>y(fe=>!fe),onScreenShareToggle:mn,onLeave:()=>{o==null||o.stop()},languages:te,selectedLanguage:_e,defaultLanguageCode:o==null?void 0:o.defaultLanguageCode,isMultilingual:(o==null?void 0:o.isMultilingual)??!1,onLanguageChange:fe=>{o==null||o.setLanguage(fe)},isLanguageSelectorEnabled:!0},Rt=g?f.jsx(fV,{messages:(o==null?void 0:o.chatMessages)??[],localIdentity:((Qn=o==null?void 0:o.room)==null?void 0:Qn.localParticipant.identity)??(typeof(o==null?void 0:o.identity)=="string"?o.identity:null),onSend:async fe=>{var kt,pt,At,bn;o&&(o.appendChatMessage({timestamp:Date.now(),message:fe,from:{identity:((pt=(kt=o.room)==null?void 0:kt.localParticipant)==null?void 0:pt.identity)??null,name:((bn=(At=o.room)==null?void 0:At.localParticipant)==null?void 0:bn.name)??null},isAgent:!1}),await o.say(fe))},testId:"pip-chat-panel"}):void 0;return f.jsx(jq,{initialPosition:gt,onExit:()=>{h("course-outline")},controlBarProps:Jt,isCourseOutlineSelected:A&&!!l,onCourseOutlineToggle:l?()=>{N(fe=>!fe)}:void 0,isCaptionsEnabled:X,onCaptionsToggle:()=>J(fe=>!fe),courseOutline:l?{steps:gn,currentStep:Nt,onStepClick:Nn,hideTrailingConclusionStep:vn}:void 0,messagesPanel:Rt,avatarFallbackProps:{audioPower:$,imageSrc:((mi=(Qi=e.client)==null?void 0:Qi.product)==null?void 0:mi.logo_url)??void 0,status:me,captionsText:K},screenshotUrl:G,cameraShotTrigger:O})}return null}function TG(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 v3(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 wG(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 b3(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 CG(t){const[e,n]=w.useState(()=>Zo(t));return w.useEffect(()=>{n(Zo(t))},[t]),w.useEffect(()=>{const i=()=>{n(Zo(t))};return window.addEventListener("popstate",i),window.addEventListener("hashchange",i),()=>{window.removeEventListener("popstate",i),window.removeEventListener("hashchange",i)}},[t]),e}function EG(t){const[e,n]=w.useState(0),i=w.useRef(null),r=w.useRef(0),a=w.useRef(0);return w.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 RG(){const[t,e]=w.useState({audioDevices:[]});return w.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 AG(){const t=window.location.hostname;return t.endsWith(".getcor.ai")||t.endsWith(".getcor.io")||t==="getcor.ai"||t==="getcor.io"}const y3=AG();function NG(t){if(document.querySelector("#obi-host")||document.querySelector("obi-widget"))return;OG();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(lB);const a=[r];if(y3){const s=new CSSStyleSheet;s.replaceSync(aB),a.push(s);const l=new CSSStyleSheet;l.replaceSync(sB),a.push(l)}else{const s=new CSSStyleSheet;s.replaceSync(oB),a.push(s)}n.adoptedStyleSheets=a;const o=rB.createRoot(i);y3?o.render(f.jsx(kG,{sdk:t,shadowHost:e})):o.render(f.jsx(dB,{sdk:t,shadowHost:e})),console.log("[obi-sdk] widget mounted")}function OG(){_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 x3="49206C6F7665204F6269_session",S3="obi-url-params";class MG extends up{constructor(e){super(),this.client=null,this.isActive=!1,this.primaryColour="#9500FF",this.passivePlanUuid=null,this.commandLog=[],this.commandQueue=[],this._resumed=!1,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=this.load();if(i)try{n=lh.deserialise(i,e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)}),n?this._resumed=!0:localStorage.removeItem("obi-client")}catch(r){console.error("[obi] error loading cached client",r),localStorage.removeItem("obi-client")}n||(n=new lh(e,"sdk",{apiBaseUrl:"https://staging.coragents.ai",captureScreen:this.captureScreen.bind(this)})),this.client=n,this.client.on("stateChanged",r=>{var a,o,s,l,c,u,d,h,p,v;r==="ready"&&this.updateConfig({isActive:((a=window==null?void 0:window.obiWidgetConfig)==null?void 0:a.isActive)??((o=this.client)==null?void 0:o.showWidget),primaryColour:((l=(s=this.client)==null?void 0:s.product)==null?void 0:l.primary_color)||"#9500FF",widgetDisplay:((c=window==null?void 0:window.obiWidgetConfig)==null?void 0:c.widgetDisplay)||((d=(u=this.client)==null?void 0:u.product)==null?void 0:d.widget_display)||"regular",completedWidgetDisplay:((h=window==null?void 0:window.obiWidgetConfig)==null?void 0:h.completedWidgetDisplay)||((v=(p=this.client)==null?void 0:p.product)==null?void 0:v.completed_widget_display)||"regular"})}),this.client.on("sessionStarted",()=>{this.save(),this.passivePlanUuid=null}),this.client.on("sessionStopped",()=>{localStorage.removeItem("obi-client"),this.passivePlanUuid=null}),this.client.on("sessionShutdown",()=>{localStorage.removeItem("obi-client")}),this.client.on("trackEvent",(r,a)=>{}),this.client.session&&(this.client.session.isPaused,this.client.resumeSession(r=>{r.on("stateChanged",a=>{a!=="disconnecting"&&a!=="disconnected"&&a!=="error"&&a!=="connecting"&&this.save()}),r.on("paused",()=>{this.save()}),r.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&&Zo(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{Ha().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){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),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&&Ha().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){await this.client.startSession(this.client.selectedPlanUuid||null,n=>{n.on("stateChanged",i=>{i!=="disconnecting"&&i!=="disconnected"&&i!=="error"&&i!=="connecting"&&this.save()}),n.on("paused",()=>{this.save()}),n.on("unpaused",()=>{this.save()})},e)}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(S3)||"{}"),Object.keys(e).length===0&&new URLSearchParams(window.location.search).forEach((a,o)=>{e[o]=a});const n=e[x3];if(!n)return null;const i=new URL(window.location.href);i.searchParams.delete(x3),window.history.replaceState({},"",i.toString()),i.toString(),localStorage.removeItem(S3),this.passivePlanUuid=n}mountWidget(){NG(this)}showMessage(e,n){try{this.emit("showMessage",{text:e,autoCloseMs:n==null?void 0:n.autoCloseMs})}catch{}}async captureScreen(){try{await QN(async()=>(this.graphemes||(this.graphemes=await this.client.api.getGraphemes()),this.graphemes.data.text_segmentation)),await G3(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 AN(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")}}async function k3(t,e){let n;try{n=window}catch{console.warn("[obi] no window object found"),n={}}return DG({appToken:t,window:n,init:e})}async function DG({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 MG(t);return e.ObiSDK=r.dispatchCommand,await r.initialise({queuedCommands:i}),e.obi=r,r.mountWidget(),r}function T3(){}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{k3(void 0,T3)}):k3(void 0,T3)})();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "obi-sdk",
3
- "version": "0.19.53-beta.0",
3
+ "version": "0.19.53-beta.1",
4
4
  "description": "JavaScript SDK for Obi",
5
5
  "type": "module",
6
6
  "main": "dist/obi-sdk.umd.js",