'use strict';
window.HubContent=(()=>{
function Loading({label}){
 return (
   <div
     className="launcher-loader fixed inset-0 z-50 flex items-center justify-center bg-[#ffffffcc] dark:bg-[#111827cc]"
     role="status"
   >
     <span
       className="launcher-spinner size-16 animate-spin rounded-full border-2 border-solid border-transparent border-y-blue-500 dark:border-y-blue-400"
       aria-hidden={true}
     />
     <span className="sr-only">{label}</span>
   </div>
 );
}
function Footer(){return (
  <footer
    className="hub-footer shrink-0 px-4 pt-2 text-center text-[11px] leading-4 text-muted"
    data-safe-edge="bottom"
  >
    {'© ' + new Date().getFullYear() + '\u00a0'}
    <a
      className="text-inherit underline-offset-2"
      href="https://evenflow.world/"
      target="_blank"
      rel="noopener noreferrer"
    >
      Evenflow Connected Conversations
    </a>
  </footer>
);}
function LoginAsBanner({className='',toolbar=false}={}){
 const [busy,setBusy]=React.useState(false),[error,setError]=React.useState('');
 async function stop(){setBusy(true);setError('');try{await HubHost.stopLoginAs();}catch(error){setError(error.message);setBusy(false);}}
 const layout=toolbar?'grid grid-cols-[minmax(0,1fr)_auto] self-start gap-2 py-1 pl-2.5 pr-1':'flex flex-wrap gap-2 py-[3px] pl-2.5 pr-[5px]';
 const stopClass=toolbar?'inline-flex min-h-11 min-w-11 items-center justify-center rounded-md border border-solid border-[color:var(--acting-edge)] bg-transparent px-1.5 text-[12px] font-semibold text-inherit hover:bg-[color:var(--acting-hover)]':'small min-h-7 border-transparent bg-transparent px-[7px] py-[3px] text-[12px] text-inherit shadow-none hover:bg-[var(--acting-hover)]';
 return (
   <aside
     className={
       'login-as-banner w-fit max-w-full items-center rounded-[10px] border border-solid text-[13px] leading-[1.5] ' +
       layout +
       ' ' +
       className
     }
     aria-label="Acting as"
   >
     <span className="min-w-0 [overflow-wrap:anywhere]">
       {toolbar ? <span className="block text-[11px] font-medium leading-4">Acting as</span> : 'Acting as '}
       <strong className={toolbar ? 'block font-medium leading-[18px]' : 'font-semibold'}>
         {HubHost.loginAs.user.email}
       </strong>
     </span>
     <button type="button" className={stopClass} disabled={busy} onClick={stop}>
       {busy ? 'Stopping…' : 'Stop'}
     </button>
     {error && (
       <span className={toolbar ? 'col-span-full text-danger' : 'basis-full text-danger'} role="alert">
         {error}
       </span>
     )}
   </aside>
 );
}
function appHeader(title,...actions){
 return (
   <header
     className={
       'app-host-header [&>button]:flex-none flex min-h-14 shrink-0 flex-wrap items-center gap-3 bg-surface px-4 py-2 [border-bottom:1px_solid_var(--edge)] [.nh-inbox-layout_&]:phone:gap-1.5'
     }
     data-safe-edge="top"
   >
     {actions}
     <h1 className="m-0 min-w-0 truncate text-[16px] font-medium leading-[1.4] flex-1" title={title}>
       {title}
     </h1>
     {HubHost.loginAs && (
       <LoginAsBanner
         className={'ml-auto shrink [.nh-inbox-layout_&]:ml-0 [.nh-inbox-layout_&]:basis-full'}
       />
     )}
   </header>
 );
}
function HostedApp({page,frameRef,pendingPage,onClose,onBackToInbox,hidden=false,showHome=true,inbox=false,placement='fixed inset-0 z-[80]'}){
 const [title,setTitle]=React.useState(page.title);
 const [src,setSrc]=React.useState(null),[error,setError]=React.useState(''),ownFrame=React.useRef(null);
 const frame=frameRef||ownFrame;
 React.useLayoutEffect(()=>{
  const scrollY=window.scrollY,overflow=document.body.style.overflow;
  let deactivate;
  document.body.style.overflow='hidden';
  setTitle(page.title);
  try{deactivate=HubHost.activateApp(page,onClose,frame,setTitle);setSrc(HubHost.appTarget(page.url).url);}
  catch(error){setError(error.message||'This app could not be opened.');}
  return()=>{deactivate?.();document.body.style.overflow=overflow;window.scrollTo(0,scrollY);};
 },[page]);
 const heading=pendingPage?.title||title;
 return (
   <section
     className={
       'app-host flex flex-col bg-canvas text-ink aria-hidden:pointer-events-none aria-hidden:invisible ' +
       placement
     }
     data-android-teams-app-link={page.androidTeamsAppLink || undefined}
     aria-hidden={hidden || undefined}
     inert={hidden ? '' : undefined}
     aria-label={heading}
   >
     {appHeader(
       heading,
       showHome && !onBackToInbox && (
         <button
           type="button"
           className="small !border-transparent !bg-transparent !shadow-none hover:!bg-hover"
           onClick={onClose}
           aria-label="Back to home"
         >
           {HubIcons.render('arrow-left')}Home
         </button>
       ),
       onBackToInbox && (
         <button
           type="button"
           className="iconbtn shrink-0"
           aria-label="Back to Inbox"
           title="Back to Inbox"
           onClick={onBackToInbox}
         >
           {HubIcons.render('arrow-left')}
         </button>
       )
     )}
     {error && (
       <p className="px-2 py-12 text-center text-[13px] text-muted" role="alert">
         {error}
       </p>
     )}
     {pendingPage && (
       <p role="status" className="m-0 flex flex-1 items-center justify-center text-sm text-muted">
         Loading request…
       </p>
     )}
     {src && (
       <iframe
         ref={frame}
         className={(pendingPage ? 'hidden' : 'block') + ' min-h-0 w-full flex-1 border-0 bg-canvas'}
         title={heading}
         src={src}
         onLoad={(event) => window.HubForegroundActivity.watchFrame(event.currentTarget)}
         allow="clipboard-write; fullscreen"
         sandbox={'allow-forms allow-scripts allow-same-origin allow-downloads allow-modals' +
           (inbox && new URL(src, location.href).pathname.startsWith('/px/c4/') ? ' allow-popups allow-popups-to-escape-sandbox' : '')}
       />
     )}
   </section>
 );
}
return {appHeader,HostedApp,LoginAsBanner,Footer,Loading};
})();
