@flowengage/react-chatbot 8.0.35 → 8.0.37
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/flowengage-embed.js +15 -15
- package/dist/flowengage-react-chatbot.cjs +38 -38
- package/dist/flowengage-react-chatbot.mjs +2045 -2005
- package/package.json +1 -1
package/dist/flowengage-embed.js
CHANGED
|
@@ -30,18 +30,18 @@ Error generating stack: `+e.message+`
|
|
|
30
30
|
box-shadow: none !important;
|
|
31
31
|
transition: outline-color 0.25s ease, box-shadow 0.25s ease !important;
|
|
32
32
|
}
|
|
33
|
-
`,document.head.appendChild(e)};function fr(e,t){if(typeof document>`u`)return null;if(e){let n=document.getElementById(e)||document.querySelector(`[data-section="${e}"]`);if(n)return n;t||=e.replace(/[-_]+/g,` `).trim()}if(!t)return null;let n=t.toLowerCase().trim(),r=n.split(/\s+/).filter(e=>e.length>2),i=Array.from(document.querySelectorAll(`h1.h2.h3.h4.h5.h6.[data-section].section[id].[id].main li.article li.[role='main'] li.[class*='card'].[class*='Card'].[class*='feature'].[class*='Feature'].[class*='tier'].[class*='Tier'].[class*='plan'].[class*='Plan'].[class*='pricing'].[class*='Pricing'].[class*='testimonial'].[class*='Testimonial'].[class*='team'].[class*='Team'].[class*='service'].[class*='Service'].[class*='block'].[role='listitem'].[role='article'].[role='region'].dt.dd`.split(`.`).join(`, `))).filter(e=>{if(Nn(e))return!1;let t=e.textContent.trim();return!(t.length<3||t.length>5e3||e.closest(`nav, footer, header, aside, .nav, .footer, .header`))});for(let e of i)if(Pn(e).toLowerCase()===n)return e;for(let e of i){let t=Pn(e).toLowerCase();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=Pn(e).toLowerCase();t.includes(n)&&a.push({el:e,len:t.length})}if(a.length)return a.sort((e,t)=>e.len-t.len),a[0].el;for(let e of i){let t=Pn(e).toLowerCase();if(t.length>3&&n.includes(t))return e}if(r.length>0){let e=null,t=0;for(let n of i){let i=Pn(n).toLowerCase(),a=0;for(let e of r)i.includes(e)&&a++;let o=a/r.length;o>t&&o>=.6&&(t=o,e=n)}if(e)return e}let o=Array.from(document.querySelectorAll(`main [role='group']`)).filter(e=>!Nn(e)),s=[];for(let e of o){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();t.length<15||t.length>8e3||t.includes(n)&&s.push({el:e,len:t.length})}if(s.length)return s.sort((e,t)=>e.len-t.len),s[0].el;if(r.length>0){let e=Array.from(document.querySelectorAll(`main a[href], article a[href], .views-row a[href], h2 a[href], h3 a[href], .card a[href], [class*='teaser'] a[href]`)).filter(e=>{if(Nn(e))return!1;try{let t=e.getAttribute(`href`)||``;if(!t||t===`#`||t.startsWith(`javascript:`))return!1}catch{return!1}let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>=3&&t.length<=220}),t=null,n=0;for(let i of e){let e=i.textContent.replace(/\s+/g,` `).toLowerCase(),a=0;for(let t of r)e.includes(t)&&a++;let o=a/r.length;o>n&&o>=.5&&(n=o,t=i)}if(t)return t.closest(`article`)||t.closest(`.views-row`)||t}let c=document.querySelectorAll(`section, article, .card, [class*='feature'], [class*='service']`);for(let e of c){if(Nn(e))continue;let t=e.querySelector(`h1, h2, h3, h4, h5, h6`);if(t){let r=t.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(r.includes(n)||n.includes(r))return e}}let l=document.querySelectorAll(`li, strong, blockquote, dt`);for(let e of l){if(Nn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e.tagName===`STRONG`&&e.parentElement?.tagName===`LI`?e.parentElement:e}let u=Array.from(document.querySelectorAll(`a[href]`)).filter(e=>!Nn(e));u.sort((e,t)=>(e.textContent||``).trim().length-(t.textContent||``).trim().length);for(let e of u){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e}let d=document.querySelectorAll(`p`);for(let e of d){if(Nn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function pr(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;dr();let r=document.querySelectorAll(`.fe-highlight-section`);for(let t of r)t!==e&&(t.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`),t.classList.add(`fe-highlight-exiting`),setTimeout(()=>t.classList.remove(`fe-highlight-exiting`),300));if(e.classList.remove(`fe-highlight-exiting`),e.classList.add(`fe-highlight-section`),t?e.classList.add(`fe-highlight-speaking`):e.classList.remove(`fe-highlight-speaking`),n)try{e.scrollIntoView({behavior:`smooth`,block:`center`})}catch{try{e.scrollIntoView(!0)}catch{}}}function mr(){typeof document>`u`||(document.querySelectorAll(`.fe-highlight-section, .fe-highlight-exiting`).forEach(e=>e.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`)),jn())}function hr(e){if(typeof window>`u`)return e;try{let t=new URL(String(e).trim(),window.location.href);return!/^https?:$/i.test(t.protocol)||t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href}catch{return e}}async function gr(e){if(typeof window>`u`)return!1;try{let t=new URL(String(e).trim(),window.location.href),n=t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href;return(await fetch(n,{method:`HEAD`,mode:`same-origin`,cache:`no-store`})).ok}catch{return!1}}async function _r(e,{siteId:t,apiBaseUrl:n}){if(!e)return{allowed:!1,correctedUrl:null};let r=!1;try{r=!!Zn()}catch{r=!1}let i=async()=>({allowed:r?!1:await gr(e),correctedUrl:null});if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),i();let a=String(n).replace(/\/$/,``),o=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let e=await(await fetch(`${a}/api/widget/navigate-allowed?${o.toString()}`)).json().catch(()=>({}));return e.success&&e.allowed?{allowed:!0,correctedUrl:e.correctedUrl||null}:i()}catch(e){return console.warn(`[FlowEngage] navigate-allowed check failed:`,e?.message),i()}}function vr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(In,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function yr(e,{skipPushState:t=!1,isBack:n=!1}={}){if(typeof window>`u`||typeof document>`u`)return!1;try{if(new URL(e,window.location.href).origin!==window.location.origin)return!1}catch{return!1}cr();let r=new AbortController,i=setTimeout(()=>r.abort(),8e3);try{let a=await fetch(e,{credentials:`same-origin`,cache:`no-store`,signal:r.signal});if(clearTimeout(i),!a.ok)return lr(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return lr(),!1;try{typeof window.Drupal?.detachBehaviors==`function`&&window.Drupal.detachBehaviors(document.body,window.drupalSettings)}catch{}document.querySelectorAll(`script`).forEach(e=>{e.setAttribute(`data-fe-original`,`true`)}),Array.from(document.body.children).forEach(e=>{if(e===c)return;let t=e.tagName?.toUpperCase();t===`AUDIO`||t===`VIDEO`||e.remove()}),$n();let l=new Set(Array.from(document.querySelectorAll(`link[rel='stylesheet']`)).map(e=>{try{return new URL(e.getAttribute(`href`)||``,window.location.href).href}catch{return``}}));for(let t of Array.from(s.head.querySelectorAll(`link[rel='stylesheet']`))){let n=t.getAttribute(`href`);if(!n)continue;let r;try{r=new URL(n,e).href}catch{continue}if(l.has(r))continue;let i=document.createElement(`link`);i.rel=`stylesheet`,i.href=r,i.setAttribute(Qn,`true`),t.media&&(i.media=t.media),document.head.appendChild(i)}for(let e of Array.from(s.head.querySelectorAll(`style`))){if(!e.textContent.trim())continue;let t=e.textContent.trim().slice(0,120);if(Array.from(document.head.querySelectorAll(`style:not([data-fe-swap-css])`)).some(e=>e.textContent.trim().slice(0,120)===t))continue;let n=document.createElement(`style`);n.textContent=e.textContent,n.setAttribute(Qn,`true`),document.head.appendChild(n)}Array.from(s.body.children).forEach(e=>{e.tagName?.toUpperCase()!==`SCRIPT`&&document.body.insertBefore(document.importNode(e,!0),c)});let u=document.querySelectorAll(`script:not([data-fe-replayed])`);for(let e of u){if(e.closest(`#flowengage-root, .flowengage-shell`)||e.hasAttribute(`data-fe-original`)||e.hasAttribute(`data-fe-replayed`))continue;let t=e.getAttribute(`src`),n=e.getAttribute(`type`)||``;if(!(n&&n!==`text/javascript`&&n!==``&&!n.includes(`drupal-ajax`))){if(n.includes(`drupal-ajax`)){e.setAttribute(`data-fe-replayed`,`true`);try{let t=JSON.parse(e.textContent);if(Array.isArray(t))for(let e of t){if((e.command===`insert`||e.command===`insert_new_content`)&&e.selector&&e.data){let t=document.querySelector(e.selector);t&&(e.method===`replaceWith`?t.outerHTML=e.data:e.method===`html`||e.method===`replace`?t.innerHTML=e.data:e.method===`append`?t.insertAdjacentHTML(`beforeend`,e.data):e.method===`prepend`?t.insertAdjacentHTML(`afterbegin`,e.data):t.innerHTML=e.data,Fn(`trySpaNavigate: BigPipe replacement →`,e.selector))}if(e.command===`settings`&&e.settings)try{window.drupalSettings&&typeof window.drupalSettings==`object`&&Object.assign(window.drupalSettings,e.settings)}catch{}}}catch(e){Fn(`trySpaNavigate: BigPipe parse error:`,e.message)}continue}if(!t&&e.textContent.trim()){let t=e.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(t)){e.setAttribute(`data-fe-replayed`,`true`);continue}let n=document.createElement(`script`);n.textContent=t,n.setAttribute(`data-fe-replayed`,`true`),e.parentNode.replaceChild(n,e)}}}try{for(let e of Array.from(s.querySelectorAll(`script`))){let t=(e.textContent||``).match(/drupalSettings\s*[,=]\s*(\{[\s\S]*?\})\s*[;)]/);if(t){try{let e=JSON.parse(t[1]);window.drupalSettings&&typeof window.drupalSettings==`object`?Object.assign(window.drupalSettings,e):window.drupalSettings=e,Fn(`trySpaNavigate: updated drupalSettings from new page`)}catch{}break}}}catch{}let d=window.location.assign.bind(window.location),f=window.location.replace.bind(window.location),p=!0;window.location.assign=e=>{if(p){Fn(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){Fn(`trySpaNavigate: blocked location.replace from replayed script:`,e);return}return f(e)};function m(e){let t=e.toLowerCase();return!!(/\/jquery[.\-\/]/.test(t)||/\/jquery\.min\.js/.test(t)||/\/jquery-once/.test(t)||/\/jquery\.once/.test(t)||/\/jquery\.ui[\./]/.test(t)||/\/jqueryui/.test(t)||/\/core\/misc\//.test(t)||/\/core\/modules\//.test(t)||/\/misc\/drupal\.js/.test(t)||/\/lodash[.\-\/]/.test(t)||/\/underscore[.\-\/]/.test(t)||/\/backbone[.\-\/]/.test(t)||/\/modernizr[.\-\/]/.test(t)||/\/popper[.\-\/]/.test(t)||/\/bootstrap\.min\.js/.test(t)||/\/bootstrap\.bundle/.test(t))}let h=new Set(Array.from(document.querySelectorAll(`script[src]`)).map(e=>{try{return new URL(e.getAttribute(`src`)||``,window.location.href).href}catch{return``}}));function g(t,n){let r=t.getAttribute(`src`)||``;if(r.includes(`flowengage`))return;let i=document.createElement(`script`);if(r){let n;try{n=new URL(r,e).href}catch{return}if(h.has(n)){if(m(n))return;Fn(`trySpaNavigate: re-running theme/custom script:`,n)}h.add(n),i.src=n,i.async=t.async,i.defer=t.defer}else if(t.textContent.trim()){let e=t.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(e)){Fn(`trySpaNavigate: skipping inline script with navigation:`,e.slice(0,120));return}if(/^\s*\(?\s*(?:window\.)?drupalSettings\s*[,=]/.test(e))return;i.textContent=e}else return;let a=t.getAttribute(`type`);a&&a!==`text/javascript`&&a!==``&&(i.type=a),n.parentNode.insertBefore(i,n)}for(let e of Array.from(s.head.querySelectorAll(`script`)))g(e,c);for(let e of Array.from(s.body.querySelectorAll(`script`)))g(e,c);try{typeof window.Drupal?.attachBehaviors==`function`&&window.Drupal.attachBehaviors(document.body,window.drupalSettings)}catch{}try{typeof window.jQuery==`function`&&(window.jQuery(document).trigger(`ready`),window.dispatchEvent(new Event(`resize`)))}catch{}try{document.dispatchEvent(new Event(`DOMContentLoaded`,{bubbles:!0,cancelable:!1}))}catch{}try{window.dispatchEvent(new Event(`load`))}catch{}try{let e=document.querySelectorAll(`iframe:not([data-fe-skip-reload])`);for(let t of e){if(t.closest(`#flowengage-root, .flowengage-shell`))continue;let e=t.getAttribute(`src`)||t.src;e&&e!==`about:blank`&&!e.startsWith(`javascript:`)&&(Fn(`trySpaNavigate: reloading iframe:`,e),t.src=e)}}catch{}try{let e=document.querySelectorAll(`.g-recaptcha, [data-sitekey]`);if(e.length>0){if(typeof window.grecaptcha?.render==`function`){for(let t of e)if(!t.closest(`#flowengage-root`)){t.innerHTML=``;try{window.grecaptcha.render(t,{sitekey:t.getAttribute(`data-sitekey`)||``}),Fn(`trySpaNavigate: re-rendered reCAPTCHA`)}catch{}}}else if(!document.querySelector(`script[src*='recaptcha']`)){let e=document.createElement(`script`);e.src=`https://www.google.com/recaptcha/api.js?render=explicit`,e.async=!0,document.head.appendChild(e),Fn(`trySpaNavigate: injected reCAPTCHA script`)}}}catch{}if(setTimeout(()=>{p=!1,window.location.assign=d,window.location.replace=f},2e3),s.title&&(document.title=s.title),!t)try{history.pushState({flowengageSpa:!0},``,e)}catch{}if(Kn(),Jn(),n){try{nr()}catch{}try{ar()}catch{}}else window.scrollTo(0,0);lr(),or(e);try{sessionStorage.removeItem(In)}catch{}try{sessionStorage.removeItem(Rn)}catch{}try{Gn=new URL(e,window.location.origin).pathname}catch{}return Fn(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),lr(),!1}}function br(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Rn,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function xr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(Rn)}catch{}}function Sr(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(Rn)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(Rn)}catch{}return e.voiceWasActive?Date.now()-e.ts>zn?(Fn(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(Fn(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}function Cr(){if(typeof document>`u`)return!1;let e=/(^|\W)(404|page not found|not found|page (?:doesn'?t|does not) exist|no longer exists|couldn'?t find (?:this|that|the) page|error 404|oops[!,. ].*(?:not found|doesn'?t exist))(\W|$)/i,t=(document.title||``).trim();if(t&&e.test(t))return!0;let n=document.querySelector(`main, [role="main"], #content, .content`)||document.body;if(n){let t=n.querySelectorAll(`h1, h2`);for(let n of t){let t=(n.textContent||``).replace(/\s+/g,` `).trim();if(t&&t.length<80&&e.test(t))return!0}}return!1}async function wr(e,t={}){if(typeof window>`u`)return{navigated:!1};let{sectionText:n,voiceActive:r=!1}=t;try{let t=hr(e),i=new URL(t,window.location.origin);if(i.hash&&i.pathname===window.location.pathname){let e=document.getElementById(i.hash.slice(1));if(e)return e.scrollIntoView({behavior:`smooth`,block:`start`}),{navigated:!0}}if(i.pathname===window.location.pathname&&i.search===window.location.search&&!i.hash)return{navigated:!1,reason:`already-on-page`};let a=i.pathname+i.search+i.hash,o=window.next?.router;if(o?.push)return new Promise(e=>{let t=()=>{o.events?.off(`routeChangeComplete`,t),e({navigated:!0})};o.events?.on(`routeChangeComplete`,t),o.push(a),setTimeout(t,5e3)});if(window.__NEXT_ROUTER__?.push)return window.__NEXT_ROUTER__.push(a),{navigated:!0};if(Zn()){n&&vr(n);let e=window.location.href;try{window.history.pushState({},``,i.href),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}if(await new Promise(e=>setTimeout(e,400)),Cr()){try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return n&&vr(n),r||ke(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&vr(n),r||ke(),window.location.assign(i.href),{navigated:!0}}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&vr(n);try{window.location.href=hr(e)}catch{window.location.href=e}return{navigated:!0}}}var Tr=!1,Er=null;function Dr(e){Er=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!Tr&&(Tr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!Er)return;let t=e.target.closest?.(`a[href]`);if(!t||t.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`))return;let n=t.getAttribute(`href`)||``;if(!n||n===`#`||n.startsWith(`javascript:`)||n.startsWith(`mailto:`)||n.startsWith(`tel:`)||t.hasAttribute(`download`)||t.target===`_blank`||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let r;try{if(r=new URL(n,window.location.href),r.origin!==window.location.origin)return}catch{return}if(!(r.pathname===window.location.pathname&&r.hash)&&!(r.pathname===window.location.pathname&&r.search===window.location.search&&!r.hash)){Fn(`voice-link-hook: saving state before navigation →`,r.href);try{Er.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(Er&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){Fn(`voice-form-hook: saving state before form submit`);try{Er.onBeforeNavigate()}catch{}}},!0)))}function Or(){Er=null,Fn(`voice-nav-hooks: deactivated`)}var kr=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),B=s(((e,t)=>{t.exports=kr()}))(),Ar=e=>!e||typeof e!=`string`?e:e.replace(/<human_assistance_request[^>]*>/gi,``).replace(/<\/human_assistance_request>/gi,``).replace(/<navigate[^>]*\/>/gi,``).replace(/<navigate[^>]*>[\s\S]*?<\/navigate>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*>[\s\S]*?<\/[a-z]+(?:_[a-z]+)+>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*\/>/gi,``).trim(),jr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:Ar(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function Mr(e){if(!e||typeof e!=`string`)return null;let t=e.match(/<navigate([^>]*?)(?:\/>|>[\s\S]*?<\/navigate>)/i);if(!t)return null;let n=t[1],r=n.match(/url=["']([^"']+)["']/i);if(!r)return null;let i=n.match(/section=["']([^"']+)["']/i)||n.match(/highlight=["']([^"']+)["']/i);return{url:r[1].trim(),section:i?.[1]?.trim()||null}}var Nr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,Pr=(e={})=>{if(!e?.candidate)return null;if(typeof e.candidate==`object`)return e.candidate;let t=e.sdpMid!==void 0&&e.sdpMid!==null&&e.sdpMid!==``,n=e.sdpMLineIndex!==void 0&&e.sdpMLineIndex!==null;return!t&&!n?null:{candidate:e.candidate,...t?{sdpMid:e.sdpMid}:{},...n?{sdpMLineIndex:e.sdpMLineIndex}:{}}},Fr=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},Ir=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Lr({siteId:e,config:t,children:n,language:r=`en`}){let i=(0,b.useMemo)(()=>e?{...t||{},siteId:e}:t||null,[e,t]),[a,o]=(0,b.useState)(0),[s,c]=(0,b.useState)(`booting`),[l,u]=(0,b.useState)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(``),[h,g]=(0,b.useState)([]),_=(0,b.useCallback)(()=>{g(e=>[...e,{id:`nav-fail-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`I couldn't find that page on our site — could you tell me more about what you're looking for?`,timestamp:new Date().toISOString()}])},[]),v=(0,b.useCallback)(()=>{g(e=>[...e,{id:`nav-already-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`Looks like you're already on this page!`,timestamp:new Date().toISOString()}])},[]),[y,x]=(0,b.useState)(k().isOpen),[C,w]=(0,b.useState)(k().activeScreen),[ee,T]=(0,b.useState)(k().isHumanHandled),[E,ie]=(0,b.useState)(k().agentName),[ce,D]=(0,b.useState)(k().agentHeadshot),[O,le]=(0,b.useState)(()=>pe(i?.siteId)),[he,ge]=(0,b.useState)(!1),[_e,ye]=(0,b.useState)(!1),[j,be]=(0,b.useState)(`idle`),[xe,Se]=(0,b.useState)(!1),[Ce,we]=(0,b.useState)(!1),[Te,De]=(0,b.useState)(``),[Oe,ke]=(0,b.useState)(!1),[Ae,je]=(0,b.useState)(0),[Me,Ne]=(0,b.useState)(0),[Pe,Fe]=(0,b.useState)(!1),[M,ze]=(0,b.useState)(null),[Be,Ve]=(0,b.useState)(null),[He,N]=(0,b.useState)(`idle`),[Ue,We]=(0,b.useState)(null),[Ge,Ke]=(0,b.useState)(!1),[qe,Je]=(0,b.useState)(``),[Ye,Xe]=(0,b.useState)(!1),Ze=(0,b.useRef)(null),P=(0,b.useRef)(null),Qe=(0,b.useRef)(``),$e=(0,b.useRef)(!1),et=(0,b.useRef)(null),F=(0,b.useRef)(null),tt=(0,b.useRef)(null),nt=(0,b.useRef)(null),rt=(0,b.useRef)(null),it=(0,b.useRef)(null),at=(0,b.useRef)(null),ot=(0,b.useRef)(!1),st=(0,b.useRef)({url:null,at:0}),I=(0,b.useCallback)((e,t)=>{let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=st.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(st.current={url:n,at:Date.now()},wr(e,t))},[]),ct=(0,b.useRef)([]),L=(0,b.useRef)(null),lt=(0,b.useRef)(null),ut=(0,b.useRef)(null),dt=(0,b.useRef)(!1),ft=(0,b.useRef)(!1),pt=(0,b.useRef)(``),mt=(0,b.useRef)(null),ht=(0,b.useRef)(null),gt=(0,b.useRef)([]),_t=(0,b.useRef)(0),vt=(0,b.useRef)(E),yt=(0,b.useRef)([]),R=(0,b.useRef)(!1),bt=(0,b.useRef)(!1),xt=(0,b.useRef)(i),St=(0,b.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),Ct=(0,b.useCallback)((e={})=>{let t=!!e.is_human_handled;return T(t),t?(w(`agent`),e.agent_info?.name&&ie(e.agent_info.name),e.agent_info?.headshot&&D(e.agent_info.headshot),t):(w(`ai`),t)},[]),wt=(0,b.useMemo)(()=>{let e=d?.widgetSettings?.call?.maxDurationSeconds??i?.widgetSettings?.call?.maxDurationSeconds??i?.callMaxDurationSeconds,t=Number(e);return Number.isFinite(t)&&t>0?t:ne},[i,d]);(0,b.useEffect)(()=>{F.current=M},[M]),(0,b.useEffect)(()=>{vt.current=E},[E]),(0,b.useEffect)(()=>{bt.current=Oe},[Oe]),(0,b.useEffect)(()=>{xt.current=i},[i]);let Tt=()=>{Je(``)},Et=(0,b.useCallback)(()=>{ut.current&&=(window.clearTimeout(ut.current),null)},[]),Dt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return le(t),me(t,i?.siteId),t};(0,b.useEffect)(()=>{let e=i?.siteId;e&&le(pe(e))},[i?.siteId]);let Ot=(e=`unspecified`)=>{let t=L.current||it.current?.callId,n=_t.current,r=mt.current;if(mt.current=null,_t.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=gt.current;if(gt.current=[],e.length>0&&t&&P.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;P.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}};try{r.stop()}catch{r.onstop=null,gt.current=[]}}else if(r&&r.state===`inactive`){let e=gt.current;if(gt.current=[],e.length>0&&t&&P.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;P.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else gt.current=[];if(ht.current){try{ht.current.close()}catch{}ht.current=null}tt.current&&=(tt.current.close(),null),nt.current&&=(nt.current.getTracks().forEach(e=>e.stop()),null),rt.current&&=(rt.current.srcObject=null,rt.current.remove(),null),Et(),it.current=null,ct.current=[],L.current=null,lt.current=null,dt.current=!1,Ke(!1),ze(null),Ve(null),N(`idle`),We(null)},kt=(e=new Date().toISOString())=>{let t=Ze.current,n=L.current||it.current?.callId;if(!(!t?.connected||!n||dt.current)){dt.current=!0,t.emit(`call:connected`,{callId:n,chatId:Qe.current,connectedAt:e});try{let e=nt.current,t=rt.current?.srcObject;if(e&&t&&!mt.current){gt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);ht.current=n;let r=n.createMediaStreamDestination();n.createMediaStreamSource(e).connect(r),n.createMediaStreamSource(t).connect(r);let i=window.MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:`audio/mp4`,a=new window.MediaRecorder(r.stream,{mimeType:i});a.ondataavailable=e=>{e.data&&e.data.size>0&>.current.push(e.data)},mt.current=a,_t.current=Date.now(),a.start(1e3),setTimeout(()=>{try{if(!window.speechSynthesis)return;let e=new SpeechSynthesisUtterance(`This call is being recorded for quality and training purposes.`);if(e.rate=.95,e.pitch=1,e.volume=1,window.MediaStreamTrackGenerator||window.AudioContext)try{let t=n.createMediaStreamDestination();e.onstart=()=>{try{let i=document.createElement(`audio`);i.style.display=`none`,i.srcObject=t.stream,document.body.appendChild(i),i.play().catch(()=>{});let a=n.createMediaStreamSource(t.stream);a.connect(r),e.onend=()=>{try{a.disconnect()}catch{}try{i.remove()}catch{}}}catch{}}}catch{}window.speechSynthesis.speak(e)}catch{}},200)}}catch{}}},At=(e={})=>{if(!e.callId)return;let t=lt.current===e.callId,n=L.current===e.callId,r=F.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Et(),ze(null),t||n){L.current=e.callId,Ve(e.callId),N(e=>e===`connected`?e:`connecting`),x(!0);return}N(`idle`)}},jt=(e={})=>{if(!e.callId)return;let t=lt.current===e.callId,n=L.current===e.callId,r=F.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Et(),n){Ot();return}lt.current=null,it.current=null,ct.current=[],ze(null),N(`idle`)}},Mt=async(e={})=>{let t=tt.current,n=Ze.current,r=e.sdpOffer||e.offer?.sdp;if(!t||!n?.connected||!r||!e.callId){console.log(`[FlowEngageProvider] deferring remote offer until peer/socket ready`,{callId:e.callId,chatId:Qe.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),it.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),ct.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Qe.current,queuedCount:ct.current.length});for(let e of ct.current)await t.addIceCandidate(new RTCIceCandidate(e));ct.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:Qe.current})};(0,b.useEffect)(()=>{A({isOpen:y,activeScreen:C,isHumanHandled:ee,agentName:E,agentHeadshot:ce})},[y,C,ee,E,ce]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{Xe(!0);try{let t=S(i),n=await Le(t);if(!e)return;let a=t.siteId,o=ue(a),s=ve(a),l=``;try{let e=$e.current,r=et.current;if($e.current=!1,et.current=null,l=(await Ie({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||ae(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);oe(),fe(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||se(),fe(a,l)}Qe.current=l;let u=Re({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});P.current=u,f({...n,apiBaseUrl:t.apiBaseUrl}),m(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,p=Cn({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});Ze.current=p,p.on(`connect`,async()=>{be(`connected`);let e=Qe.current;if(e&&P.current)try{Ct(await P.current.checkHumanHandled(e))}catch{}}),p.on(`disconnect`,()=>{be(`disconnected`)}),p.on(`aiTyping`,()=>{ye(!0)}),p.on(`ai:typing`,()=>{ye(!0)}),p.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:Ar(t.message)};ye(!1),ge(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&g(e=>[...e.filter(e=>!e.isPending),{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}])}),p.on(`conversationStarted`,e=>{e?.message&&g(t=>[...t,{id:`system-start-${Date.now()}`,sender:`system`,message:e.message,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`message:new`,e=>{let t=e.message||e,n={...t,message:Ar(t.message)};ye(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&((n.sender===`agent`||n.agent_name||n.sender===`ai`||n.sender===`bot`)&&ge(!1),g(e=>n.sender===`bot`||n.sender===`ai`?[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]:e.some(e=>e.id===n.messageId||e.sender===n.sender&&e.message===n.message&&e.isPending)?e.map(e=>e.sender===n.sender&&e.message===n.message&&e.isPending?{...n,isPending:!1,id:n.messageId||e.id}:e):[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]),(n.sender===`agent`||n.agent_name)&&(T(!0),w(`agent`),ie(Fr([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&D(n.sender_headshot),x(!0),je(e=>e+1)))});let h=(e={})=>{let t=Fr([e.agent?.name,e.agentName,e.agent_name,vt.current],d);T(!0),w(`agent`),ie(t),D(e.agent?.headshot||null),x(!0),je(e=>e+1),g(e=>Ir(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},y=(e={})=>{let t=Fr([e.agent?.name,e.agentName,e.agent_name,vt.current],d);T(!1),w(`ai`),g(e=>Ir(e,{id:`agent-left-${Date.now()}`,sender:`system`,message:`${t} has left the chat.`,timestamp:new Date().toISOString(),isPending:!1}))};p.on(`agent:joined`,h),p.on(`agentJoined`,h),p.on(`agent:left`,y),p.on(`agentLeft`,y),p.on(`conversationEnded`,e=>{Fe(!0);let t=e?.message||`This conversation has ended. Thank you for reaching out!`;g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:t,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`chat:history_update`,e=>{let t=jr(e.chat_history||[]);g(t),t.length===0&&(Fe(!1),T(!1),w(`ai`),ye(!1),ge(!1))}),p.on(`conversation:reset`,()=>{g([]),Fe(!1),T(!1),w(`ai`),ye(!1),ge(!1)}),p.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),Ne(e=>e+1),x(!0),je(e=>e+1)}),p.on(`typing:start`,e=>{e.sender===`agent`&&ge(!0)}),p.on(`typing:stop`,e=>{e.sender===`agent`&&ge(!1)}),p.on(`call:incoming`,(e={})=>{let t=Fr([e.agentName,e.ownerName,e.agent?.name,vt.current],`Agent`);Tt(),Et(),dt.current=!1,ze({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),ie(e=>Fr([t,e],`Agent`)),N(`incoming`),We(null),x(!0)}),p.on(`call:offer`,async(e={})=>{it.current=e;try{await Mt(e)}catch(e){console.error(`[FlowEngageProvider] failed to apply remote offer`,e)}}),p.on(`call:ice-candidate-from-agent`,async(e={})=>{if(e.candidate)try{let t=Pr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!tt.current||!tt.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Qe.current,queueSize:ct.current.length+1}),ct.current.push(t);return}await tt.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),p.on(`call:ended`,()=>{Tt(),Ot(`socket:call_ended`)}),p.on(`call:accepted`,(e={})=>{At(e)}),p.on(`call:accepted_by_other`,(e={})=>{At(e)}),p.on(`call:rejected`,(e={})=>{jt(e)}),p.on(`call:missed`,(e={})=>{jt(e)}),p.on(`call:failed`,(e={})=>{jt(e)}),p.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=lt.current===e.callId,n=L.current===e.callId,r=it.current?.callId===e.callId,i=F.current?.callId===e.callId;if(!t&&!n&&!r){i&&(ze(null),N(`idle`));return}dt.current=!0,lt.current=null,L.current=e.callId,Ve(e.callId),ze(null),N(`connected`),We(e.connectedAt||new Date().toISOString()),x(!0)}),p.on(`call:unavailable`,(e={})=>{Ot(`socket:call_unavailable`),Je(Nr(e,`This visitor is not available for a call right now.`)),x(!0)}),p.on(`call:error`,(e={})=>{Ot(`socket:call_error`),Je(Nr(e,`We couldn't connect the call right now.`)),x(!0)}),p.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&I(e,{voiceActive:bt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?_():r===`already-on-page`&&v();return}let i=t||n;!i||!bt.current||setTimeout(()=>{let e=fr(null,i);e&&pr(e)},300)})}),p.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=fr(e||null,t||null);n&&pr(n)}),p.on(`visitor:clear_highlight`,()=>{mr()}),St.current=wn({socket:p,chatId:l});let b=await u.loadHistory(l,r);if(!e)return;g(jr(b.chat_history||[])),T(!!b.is_human_handled),w(b.is_human_handled?`agent`:C);let ee=b?.visitor_email||b?.visitorEmail;if(ee&&String(ee).trim()&&Dt(String(ee).trim()),await new Promise(e=>setTimeout(e,500)),!e)return;c(`ready`)}catch(t){if(!e)return;u(t),c(`error`)}finally{e&&Xe(!1)}})(),()=>{e=!1,St.current?.cleanup?.(),Ot(),Ze.current?.disconnect()}},[i,r,a]),(0,b.useEffect)(()=>()=>{if(Oe&&!R.current&&yt.current.length>0){let e=Qe.current,t=yt.current,n=P.current;n&&e&&t.length>0&&(console.log(`[FlowEngageProvider] safety-net: syncing voice transcript on unmount`),n.beaconSyncVoice(e,t)||n.syncVoice(e,t).catch(()=>{}),R.current=!0)}},[Oe,d]);let Nt=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=P.current;!e||!p||Nt.current!==y&&(y&&Nt.current!==null?e.updateChatStatus(p,`open`).catch(()=>{}):Nt.current===!0&&e.updateChatStatus(p,`widget_closed`).catch(()=>{}),Nt.current=y)},[y,p]),(0,b.useEffect)(()=>{let e=()=>{let e=Qe.current,t=P.current;!e||!t||typeof navigator>`u`||t.beaconWidgetClosed?.(e)||t.updateChatStatus(e,`widget_closed`).catch(()=>{})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let Pt=async()=>{if(!(!M?.callId||!P.current||!Ze.current||!p)){Tt(),lt.current=M.callId,Et();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});nt.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await P.current.getIceServersConfig();e?.data?.iceServers?.length&&(t=e.data.iceServers)}catch(e){console.warn(`[FlowEngageProvider] ice-config fetch failed, using STUN default`,e)}let n=new RTCPeerConnection({iceServers:t});tt.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();N(`connected`),We(t=>t||e),kt(e);return}if(e===`connecting`){N(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Ot(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();N(`connected`),We(t=>t||e),kt(e);return}if(e===`checking`||e===`new`){N(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Ot(`peer:ice_${e}`)},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!Ze.current?.connected)return;let t=e.candidate;Ze.current.emit(`call:ice-candidate`,{callId:M.callId,candidate:t.candidate,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex,chatId:p,from:`customer`})},n.ontrack=e=>{let[t]=e.streams||[],[n]=t?.getAudioTracks?.()||[];if(!rt.current){let e=document.createElement(`audio`);e.id=`flowengage-remote-audio`,e.autoplay=!0,e.playsInline=!0,e.onplay=()=>{},e.onpause=()=>{},e.onended=()=>{},e.onerror=e=>{},rt.current=e,document.body.appendChild(e)}rt.current.srcObject=e.streams[0];let r=M?.callId,i=r&&(lt.current===r||L.current===r);if(!dt.current&&i){let e=new Date().toISOString();N(`connected`),We(t=>t||e),L.current=r,Ve(r),kt(e)}rt.current.srcObject=t||null;let a=rt.current.play?.();a?.catch&&a.catch(e=>{})};let r=it.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||M.callId,chatId:p}),await Mt({...r,callId:r.callId||M.callId})),await P.current.acceptCall(M.callId,p),Ze.current?.emit(`call:accepted`,{callId:M.callId,chatId:p}),L.current=M.callId,Ve(M.callId),N(e=>e===`connected`||dt.current?`connected`:`connecting`),ze(null),x(!0)}catch(e){if(lt.current=null,Ot(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){Je(Nr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await P.current.rejectCall(M.callId,p)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}Je(`Microphone access was denied. Please allow microphone access to accept the call.`);return}Je(`We couldn't connect the call right now. Please try again.`)}}},Ft=async()=>{if(!M?.callId||!P.current||!p){Ot(`reject_call_without_server_context`);return}let e=M.callId;Et(),Tt(),Ze.current?.emit(`call:rejected`,{callId:e,chatId:p,reason:`visitor_declined`});try{await P.current.rejectCall(e,p)}catch(e){Je(Nr(e,`We couldn't decline the call cleanly.`))}finally{Ot(`reject_call_finally`)}},It=(0,b.useRef)(Ft);It.current=Ft,(0,b.useEffect)(()=>{if(!M?.callId||Be){Et();return}let e=M.callId;return Et(),ut.current=window.setTimeout(()=>{F.current?.callId===e&<.current!==e&&L.current!==e&&It.current()},re),()=>{ut.current&&=(window.clearTimeout(ut.current),null)}},[Be,Et,M?.callId]);let Lt=async()=>{if(!Be||!P.current||!p){Ot(`end_call_without_server_context`);return}Tt();try{await P.current.endWebRTCCall(Be,p)}catch(e){Je(Nr(e,`The call ended locally, but the server could not be updated.`))}finally{Ot(`end_call_finally`)}},Rt=()=>{let e=nt.current?.getAudioTracks?.()||[],t=tt.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!Ge;n.forEach(e=>{e.enabled=!r}),Ke(r)},zt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(x(!0),!(!t||!P.current||!p||typeof window>`u`)){try{await P.current.trackVisitor({chatId:p,currentPagePath:window.location.pathname||`/`})}catch{}try{await P.current.updateChatStatus(p,`open`)}catch{}}},Bt=async e=>{let t=Dt(e);if(!t||!P.current||!Qe.current)return t;try{await P.current.trackVisitor({chatId:Qe.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},Vt=()=>{!p||!Ze.current?.connected||ft.current||(ft.current=!0,Ze.current.emit(`typing:start`,{chatId:p,sender:`user`}))},Ht=()=>{!p||!Ze.current?.connected||!ft.current||(ft.current=!1,Ze.current.emit(`typing:stop`,{chatId:p,sender:`user`}))},Ut=(e=``)=>{let t=typeof e==`string`?e:``;!p||!Ze.current?.connected||t!==``&&pt.current===t||(pt.current=t,Ze.current.emit(`typing:update`,{chatId:p,sender:`user`,text:t}))};function Wt(){if(typeof document>`u`)return null;try{let e=(document.querySelector(`main`)||document.querySelector(`[role='main']`)||document.querySelector(`article`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);e.querySelectorAll(`nav, footer, header, aside, script, style, noscript, #flowengage-root, .flowengage-shell, .flowengage-widget-root, [id*='flowengage'], [class*='flowengage']`).forEach(e=>e.remove());let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>0?t.substring(0,3e3):null}catch{return null}}let Gt=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!P.current||!p||s!==`ready`||Pe)return;Ht(),ot.current=!1;let o=/^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i,c=/^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i,l=/\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;if(at.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=at.current;at.current=null,ot.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),I(e,{voiceActive:bt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t||!bt.current||setTimeout(()=>{let e=fr(null,t);e&&pr(e)},300)})}else o.test(a)||(at.current=null);let d=`pending-user-${Date.now()}`,f={id:d,sender:`user`,message:e,timestamp:new Date().toISOString(),isPending:!0,type:i?.type||`text`,metadata:i?.metadata||void 0,...n||{}};g(e=>[...e,f]);let m=ee;if(m)try{m=Ct(await P.current.checkHumanHandled(p))}catch{}if(m&&Ze.current?.connected){Ze.current.emit(`customer:message`,{chatId:p,content:e,sender:`user`,email:O||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}Se(!0);try{let o=await P.current.sendAiMessage(p,e,r,t,{...n||{},...O?{email:O}:{}},{...i,currentPageUrl:typeof window<`u`?window.location.href:void 0,currentPageTitle:typeof window<`u`?document.title:void 0,currentPagePath:typeof window<`u`?window.location.pathname:void 0,currentPageContent:Wt()||void 0}),s=o.chat_history||[];if(console.log(`[FWH Nav Debug] API response fields:`,{has_navigate:!!o.navigate,navigate:o.navigate,has_pending_navigate:!!o.pending_navigate,pending_navigate:o.pending_navigate,last_bot_msg:[...s].reverse().find(e=>e.sender===`bot`)?.message?.substring(0,80)}),o.pending_navigate?.url){let e={url:o.pending_navigate.url,section:o.pending_navigate.section||null};l.test(a)?(console.log(`[FWH Nav] Auto-navigating (intent detected) →`,e.url),I(e.url,{voiceActive:bt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?_():n===`already-on-page`&&v();return}e.section&&setTimeout(()=>{let t=fr(null,e.section);t&&pr(t)},300)})):(at.current=e,console.log(`[FWH Nav] Stored pending nav →`,at.current))}if(o.navigate?.url)if(ot.current)ot.current=!1;else{let{url:e,section:t}=o.navigate;I(e,{voiceActive:bt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t||!bt.current||setTimeout(()=>{let e=fr(null,t);e&&pr(e)},300)})}else{let e=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=Mr(e.message);t&&_r(t.url,{siteId:xt.current?.siteId,apiBaseUrl:xt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){_();return}I(n||t.url,{voiceActive:bt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t.section||!bt.current||setTimeout(()=>{let e=fr(null,t.section);e&&pr(e)},300)})})}}g(jr(s)),T(!!o.is_human_handled),w(o.is_human_handled?`agent`:`ai`),ye(!1),Se(!1),await P.current.updateChatStatus(p,`messageSent`)}catch(e){g(e=>e.filter(e=>e.id!==d)),ye(!1),Se(!1),e.status===429?(we(!0),De(e.message),window.setTimeout(()=>{we(!1),De(``)},te)):u(e)}},Kt=async e=>{if(!P.current||!e)throw Error(`Upload is unavailable right now.`);return P.current.uploadChatFile(e)},qt=async e=>{if(!(!P.current||!p)){try{let t=e?`voice`:`text`;await P.current.setChatMode(p,t)}catch{}ke(e),e&&(R.current=!1)}},Jt=async e=>{if(R.current)return;if(R.current=!0,!P.current||!p||!e?.length){ke(!1);return}let t=()=>{let t=jr(e);g(e=>{if(!e.length)return t;let n=e[e.length-1],r=t[0];return n&&r&&n.sender===r.sender&&n.message===r.message?e:[...e,...t]})};try{let n=await P.current.syncVoice(p,e);if(n?.chat_history?.length)g(jr(n.chat_history));else if(n?.success)try{let e=await P.current.loadHistory(p,r);e?.chat_history?.length?g(jr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{ke(!1)}},Yt=async()=>{if(!(!P.current||!p)){Oe&&!R.current&&yt.current.length>0&&await Jt(yt.current);try{await P.current.endConversation(p)}catch{try{await P.current.updateChatStatus(p,`ended`)}catch{}}Fe(!0),g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:`This conversation has ended. Thank you for reaching out!`,timestamp:new Date().toISOString(),isPending:!1}])}};(0,b.useEffect)(()=>{if(He!==`connected`||!Be||!p||!Ue||!wt)return;let e=new Date(Ue).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,wt*1e3-t),r=window.setTimeout(()=>{Je(`The call ended because it reached the time limit.`),Lt()},n);return()=>window.clearTimeout(r)},[Be,Ue,He,p,Lt,wt]),(0,b.useEffect)(()=>{let e=()=>{let e=Qe.current,t=P.current;if(!t||!e)return;if(bt.current&&yt.current.length>0&&Ee(),!R.current&&yt.current.length>0&&(t.beaconSyncVoice(e,yt.current)||t.syncVoice(e,yt.current).catch(()=>{}),R.current=!0),L.current){t.beaconEndWebRTCCall(L.current,e);return}let n=lt.current||F.current?.callId;n&&t.beaconCustomerUnavailable(n,e)};return window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}},[]);let Xt=(0,b.useCallback)(()=>{let e=i?.siteId;de(e),$e.current=!0,et.current=null,Ze.current?.disconnect(),g([]),m(``),Qe.current=``,Fe(!1),T(!1),ie(null),D(null),Xe(!0),o(e=>e+1)},[i?.siteId]),Zt=(0,b.useCallback)(e=>{i?.siteId,$e.current=!1,et.current=e,Ze.current?.disconnect(),g([]),m(``),Qe.current=``,Fe(!1),T(!1),ie(null),D(null),Xe(!0),o(e=>e+1)},[i?.siteId]),Qt=(0,b.useMemo)(()=>({status:s,error:l,runtimeConfig:d,resolvedConfig:i,chatId:p,chatHistory:h,isOpen:y,activeScreen:C,isHumanHandled:ee,agentName:E,agentHeadshot:ce,visitorEmail:O,isAgentTyping:he,isAiTyping:_e,connectionStatus:j,isLoading:xe,isVoiceMode:Oe,isRateLimited:Ce,rateLimitMessage:Te,isConversationEnded:Pe,isSessionRestoring:Ye,openToChatCounter:Ae,voiceEndCounter:Me,incomingCall:M,activeCallId:Be,callConnectionState:He,callConnectedAt:Ue,isCallMuted:Ge,webRTCError:qe,language:r,historyRef:yt,hasSyncedRef:R,dismissCallError:Tt,captureVisitorEmail:Bt,startTyping:Vt,stopTyping:Ht,updateTypingDraft:Ut,notifyRouteChange:()=>St.current?.notifyRouteChange?.(),openWidget:zt,closeWidget:()=>x(!1),toggleWidget:()=>{if(y){x(!1);return}zt({notifyChatInitiated:!0})},sendMessage:Gt,uploadChatFile:Kt,setVoiceMode:qt,onMessageSync:Jt,endConversation:Yt,startNewChat:Xt,resumeChat:Zt,getVisitorChatHistory:()=>P.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>P.current?.getVisitorChatThread?.(e),acceptCall:Pt,rejectCall:Ft,endWebRTCCall:Lt,toggleCallMute:Rt}),[s,l,d,i,p,h,y,C,ee,E,ce,O,he,_e,j,xe,Oe,Ce,Te,Pe,Ye,Ae,Me,M,Be,He,Ue,Ge,qe,r,Bt,Vt,Ht,Ut,Pt,Ft,Lt,Rt,zt,Gt,Kt,qt,Jt,Yt,Xt,Tt]);return(0,B.jsx)(Tn.Provider,{value:Qt,children:n})}var Rr=(0,b.createContext)({});function zr(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Br=typeof window<`u`?b.useLayoutEffect:b.useEffect,Vr=(0,b.createContext)(null);function Hr(e,t){e.indexOf(t)===-1&&e.push(t)}function Ur(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Wr=(e,t,n)=>n>t?t:n<e?e:n,Gr={},Kr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function qr(e){return typeof e==`object`&&!!e}var Jr=e=>/^0[^.\s]+$/u.test(e);function Yr(e){let t;return()=>(t===void 0&&(t=e()),t)}var Xr=e=>e,Zr=(e,t)=>n=>t(e(n)),Qr=(...e)=>e.reduce(Zr),$r=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},ei=class{constructor(){this.subscriptions=[]}add(e){return Hr(this.subscriptions,e),()=>Ur(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},ti=e=>e*1e3,ni=e=>e/1e3;function ri(e,t){return t?1e3/t*e:0}var ii=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ai=1e-7,oi=12;function si(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ii(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ai&&++s<oi);return o}function ci(e,t,n,r){if(e===t&&n===r)return Xr;let i=t=>si(t,0,1,e,n);return e=>e===0||e===1?e:ii(i(e),t,r)}var li=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ui=e=>t=>1-e(1-t),di=ci(.33,1.53,.69,.99),fi=ui(di),pi=li(fi),mi=e=>e>=1?1:(e*=2)<1?.5*fi(e):.5*(2-2**(-10*(e-1))),hi=e=>1-Math.sin(Math.acos(e)),gi=ui(hi),_i=li(hi),vi=ci(.42,0,1,1),yi=ci(0,0,.58,1),bi=ci(.42,0,.58,1),xi=e=>Array.isArray(e)&&typeof e[0]!=`number`,Si=e=>Array.isArray(e)&&typeof e[0]==`number`,Ci={linear:Xr,easeIn:vi,easeInOut:bi,easeOut:yi,circIn:hi,circInOut:_i,circOut:gi,backIn:fi,backInOut:pi,backOut:di,anticipate:mi},wi=e=>typeof e==`string`,Ti=e=>{if(Si(e)){e.length;let[t,n,r,i]=e;return ci(t,n,r,i)}else if(wi(e))return Ci[e],`${e}`,Ci[e];return e},Ei=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],Di={value:null,addProjectionMetrics:null};function Oi(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&Di.value&&Di.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var ki=40;function Ai(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Ei.reduce((e,n)=>(e[n]=Oi(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Gr.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,ki),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Ei.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Ei.length;t++)o[Ei[t]].cancel(e)},state:i,steps:o}}var{schedule:V,cancel:H,state:U,steps:ji}=Ai(typeof requestAnimationFrame<`u`?requestAnimationFrame:Xr,!0),Mi;function Ni(){Mi=void 0}var Pi={now:()=>(Mi===void 0&&Pi.set(U.isProcessing||Gr.useManualTiming?U.timestamp:performance.now()),Mi),set:e=>{Mi=e,queueMicrotask(Ni)}},Fi={layout:0,mainThread:0,waapi:0},Ii=e=>t=>typeof t==`string`&&t.startsWith(e),Li=Ii(`--`),Ri=Ii(`var(--`),zi=e=>Ri(e)?Bi.test(e.split(`/*`)[0].trim()):!1,Bi=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Vi(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Hi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Ui={...Hi,transform:e=>Wr(0,1,e)},Wi={...Hi,default:1},Gi=e=>Math.round(e*1e5)/1e5,Ki=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function qi(e){return e==null}var Ji=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Yi=(e,t)=>n=>!!(typeof n==`string`&&Ji.test(n)&&n.startsWith(e)||t&&!qi(n)&&Object.prototype.hasOwnProperty.call(n,t)),Xi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ki);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Zi=e=>Wr(0,255,e),Qi={...Hi,transform:e=>Math.round(Zi(e))},$i={test:Yi(`rgb`,`red`),parse:Xi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Qi.transform(e)+`, `+Qi.transform(t)+`, `+Qi.transform(n)+`, `+Gi(Ui.transform(r))+`)`};function ea(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var ta={test:Yi(`#`),parse:ea,transform:$i.transform},na=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ra=na(`deg`),ia=na(`%`),W=na(`px`),aa=na(`vh`),oa=na(`vw`),sa={...ia,parse:e=>ia.parse(e)/100,transform:e=>ia.transform(e*100)},ca={test:Yi(`hsl`,`hue`),parse:Xi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ia.transform(Gi(t))+`, `+ia.transform(Gi(n))+`, `+Gi(Ui.transform(r))+`)`},la={test:e=>$i.test(e)||ta.test(e)||ca.test(e),parse:e=>$i.test(e)?$i.parse(e):ca.test(e)?ca.parse(e):ta.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?$i.transform(e):ca.transform(e),getAnimatableNone:e=>{let t=la.parse(e);return t.alpha=0,la.transform(t)}},ua=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function da(e){return isNaN(e)&&typeof e==`string`&&(e.match(Ki)?.length||0)+(e.match(ua)?.length||0)>0}var fa=`number`,pa=`color`,ma=`var`,ha=`var(`,ga="${}",_a=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function va(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(_a,e=>(la.test(e)?(r.color.push(a),i.push(pa),n.push(la.parse(e))):e.startsWith(ha)?(r.var.push(a),i.push(ma),n.push(e)):(r.number.push(a),i.push(fa),n.push(parseFloat(e))),++a,ga)).split(ga),indexes:r,types:i}}function ya(e){return va(e).values}function ba({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===fa?i+=Gi(r[a]):e===pa?i+=la.transform(r[a]):i+=r[a]}return i}}function xa(e){return ba(va(e))}var Sa=e=>typeof e==`number`?0:la.test(e)?la.getAnimatableNone(e):e,Ca=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Sa(e);function wa(e){let t=va(e);return ba(t)(t.values.map((e,n)=>Ca(e,t.split[n])))}var Ta={test:da,parse:ya,createTransformer:xa,getAnimatableNone:wa};function Ea(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Da({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Ea(s,r,e+1/3),a=Ea(s,r,e),o=Ea(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Oa(e,t){return n=>n>0?t:e}var ka=(e,t,n)=>e+(t-e)*n,Aa=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},ja=[ta,$i,ca],Ma=e=>ja.find(t=>t.test(e));function Na(e){let t=Ma(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===ca&&(n=Da(n)),n}var Pa=(e,t)=>{let n=Na(e),r=Na(t);if(!n||!r)return Oa(e,t);let i={...n};return e=>(i.red=Aa(n.red,r.red,e),i.green=Aa(n.green,r.green,e),i.blue=Aa(n.blue,r.blue,e),i.alpha=ka(n.alpha,r.alpha,e),$i.transform(i))},Fa=new Set([`none`,`hidden`]);function Ia(e,t){return Fa.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function La(e,t){return n=>ka(e,t,n)}function Ra(e){return typeof e==`number`?La:typeof e==`string`?zi(e)?Oa:la.test(e)?Pa:Ha:Array.isArray(e)?za:typeof e==`object`?la.test(e)?Pa:Ba:Oa}function za(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Ra(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Ba(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Ra(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Va(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Ha=(e,t)=>{let n=Ta.createTransformer(t),r=va(e),i=va(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Fa.has(e)&&!i.values.length||Fa.has(t)&&!r.values.length?Ia(e,t):Qr(za(Va(r,i),i.values),n):(`${e}${t}`,Oa(e,t))};function Ua(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?ka(e,t,n):Ra(e)(e,t)}var Wa=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>V.update(t,e),stop:()=>H(t),now:()=>U.isProcessing?U.timestamp:Pi.now()}},Ga=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Ka=2e4;function qa(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Ja(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(qa(r),Ka);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ni(i)}}var Ya={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Xa(e,t){return e*Math.sqrt(1-t*t)}var Za=12;function Qa(e,t,n){let r=n;for(let n=1;n<Za;n++)r-=e(r)/t(r);return r}var $a=.001;function eo({duration:e=Ya.duration,bounce:t=Ya.bounce,velocity:n=Ya.velocity,mass:r=Ya.mass}){let i,a;Ya.maxDuration;let o=1-t;o=Wr(Ya.minDamping,Ya.maxDamping,o),e=Wr(Ya.minDuration,Ya.maxDuration,ni(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Xa(t,o),c=Math.exp(-i);return $a-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Xa(t**2,o);return(-i(t)+$a>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-$a+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Qa(i,a,s);if(e=ti(e),isNaN(c))return{stiffness:Ya.stiffness,damping:Ya.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var to=[`duration`,`bounce`],no=[`stiffness`,`damping`,`mass`];function ro(e,t){return t.some(t=>e[t]!==void 0)}function io(e){let t={velocity:Ya.velocity,stiffness:Ya.stiffness,damping:Ya.damping,mass:Ya.mass,isResolvedFromDuration:!1,...e};if(!ro(e,no)&&ro(e,to))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Wr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ya.mass,stiffness:i,damping:a}}else{let n=eo({...e,velocity:0});t={...t,...n,mass:Ya.mass},t.isResolvedFromDuration=!0}return t}function ao(e=Ya.visualDuration,t=Ya.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=io({...n,velocity:-ni(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ni(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Ya.restSpeed.granular:Ya.restSpeed.default,i||=v?Ya.restDelta.granular:Ya.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Xa(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let ee={calculatedDuration:p&&d||null,velocity:e=>ti(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=ti(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=ti(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(qa(ee),Ka),t=Ga(t=>ee.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return ee}ao.applyToOptions=e=>{let t=Ja(e,100,ao);return e.ease=t.ease,e.duration=ti(t.duration),e.type=`keyframes`,e};var oo=5;function so(e,t,n){let r=Math.max(t-oo,0);return ri(n-e(r),t-r)}function G({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=ao({keyframes:[f.value,m(f.value)],velocity:so(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function co(e,t,n){let r=[],i=n||Gr.mix||Ua,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Qr(Array.isArray(t)?t[n]||Xr:t,a)),r.push(a)}return r}function lo(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=co(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=$r(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Wr(e[0],e[a-1],t)):l}function uo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=$r(0,t,r);e.push(ka(n,1,i))}}function fo(e){let t=[0];return uo(t,e.length-1),t}function po(e,t){return e.map(e=>e*t)}function mo(e,t){return e.map(()=>t||bi).splice(0,e.length-1)}function ho({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=xi(r)?r.map(Ti):Ti(r),a={done:!1,value:t[0]},o=lo(po(n&&n.length===t.length?n:fo(t),e),t,{ease:Array.isArray(i)?i:mo(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var go=e=>e!==null;function _o(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(go),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var vo={decay:G,inertia:G,tween:ho,keyframes:ho,spring:ao};function yo(e){typeof e.type==`string`&&(e.type=vo[e.type])}var bo=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},xo=e=>e/100,So=class extends bo{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Pi.now()&&this.tick(Pi.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Fi.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;yo(e);let{type:t=ho,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||ho;s!==ho&&typeof o[0]!=`number`&&(this.mixKeyframes=Qr(xo,Ua(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=qa(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Wr(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==G&&(b.value=_o(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ni(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ni(e)}get time(){return ni(this.currentTime)}set time(e){e=ti(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return so(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Pi.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ni(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Wa,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Pi.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,Fi.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function Co(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var wo=e=>e*180/Math.PI,To=e=>Do(wo(Math.atan2(e[1],e[0]))),Eo={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:To,rotateZ:To,skewX:e=>wo(Math.atan(e[1])),skewY:e=>wo(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Do=e=>(e%=360,e<0&&(e+=360),e),Oo=To,ko=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ao=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),jo={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ko,scaleY:Ao,scale:e=>(ko(e)+Ao(e))/2,rotateX:e=>Do(wo(Math.atan2(e[6],e[5]))),rotateY:e=>Do(wo(Math.atan2(-e[2],e[0]))),rotateZ:Oo,rotate:Oo,skewX:e=>wo(Math.atan(e[4])),skewY:e=>wo(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Mo(e){return e.includes(`scale`)?1:0}function No(e,t){if(!e||e===`none`)return Mo(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=jo,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Eo,i=t}if(!i)return Mo(t);let a=r[t],o=i[1].split(`,`).map(Fo);return typeof a==`function`?a(o):o[a]}var Po=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return No(n,t)};function Fo(e){return parseFloat(e.trim())}var Io=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Lo=new Set(Io),Ro=e=>e===Hi||e===W,zo=new Set([`x`,`y`,`z`]),Bo=Io.filter(e=>!zo.has(e));function Vo(e){let t=[];return Bo.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Ho={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>No(t,`x`),y:(e,{transform:t})=>No(t,`y`)};Ho.translateX=Ho.x,Ho.translateY=Ho.y;var Uo=new Set,Wo=!1,Go=!1,Ko=!1;function qo(){if(Go){let e=Array.from(Uo).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Vo(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Go=!1,Wo=!1,Uo.forEach(e=>e.complete(Ko)),Uo.clear()}function Jo(){Uo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Go=!0)})}function Yo(){Ko=!0,Jo(),qo(),Ko=!1}var Xo=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Uo.add(this),Wo||(Wo=!0,V.read(Jo),V.resolveKeyframes(qo))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Co(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Uo.delete(this)}cancel(){this.state===`scheduled`&&(Uo.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Zo=e=>e.startsWith(`--`);function Qo(e,t,n){Zo(t)?e.style.setProperty(t,n):e.style[t]=n}var $o={};function es(e,t){let n=Yr(e);return()=>$o[t]??n()}var ts=es(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),ns=es(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),rs=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,is={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:rs([0,.65,.55,1]),circOut:rs([.55,0,1,.45]),backIn:rs([.31,.01,.66,-.59]),backOut:rs([.33,1.53,.69,.99])};function as(e,t){if(e)return typeof e==`function`?ns()?Ga(e,t):`ease-out`:Si(e)?rs(e):Array.isArray(e)?e.map(e=>as(e,t)||is.easeOut):is[e]}function os(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=as(s,i);Array.isArray(d)&&(u.easing=d),Di.value&&Fi.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return Di.value&&p.finished.finally(()=>{Fi.waapi--}),p}function ss(e){return typeof e==`function`&&`applyToOptions`in e}function cs({type:e,...t}){return ss(e)&&ns()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var ls=class extends bo{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=cs(e);this.animation=os(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=_o(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Qo(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ni(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ni(e)}get time(){return ni(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ti(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&ts()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Xr):r(this)}},us={anticipate:mi,backInOut:pi,circInOut:_i};function ds(e){return e in us}function fs(e){typeof e.ease==`string`&&ds(e.ease)&&(e.ease=us[e.ease])}var ps=10,ms=class extends ls{constructor(e){fs(e),yo(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new So({...a,autoplay:!1}),s=Math.max(ps,Pi.now()-this.startTime),c=Wr(0,ps,s-ps),l=o.sample(s).value,{name:u}=this.options;i&&u&&Qo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},hs=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Ta.test(e)||e===`0`)&&!e.startsWith(`url(`));function gs(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function _s(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=hs(i,t),s=hs(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:gs(e)||(n===`spring`||ss(n))&&r}function vs(e){e.duration=0,e.type=`keyframes`}var ys=new Set([`opacity`,`clipPath`,`filter`,`transform`]),bs=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function xs(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&bs.test(e[t]))return!0;return!1}var Ss=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Cs=Yr(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ws(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Cs()&&n&&(ys.has(n)||Ss.has(n)&&xs(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Ts=40,Es=class extends bo{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Pi.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u};this.keyframeResolver=new(l?.KeyframeResolver||Xo)(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Pi.now();let u=!0;_s(e,i,a,o)||(u=!1,(Gr.instantAnimations||!s)&&l?.(_o(e,n,t)),e[0]=e[e.length-1],vs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Ts?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&ws(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new ms({...d,element:p})}catch{m=new So(d)}else m=new So(d);m.finished.then(()=>{this.notifyFinished()}).catch(Xr),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Yo()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Ds(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Os=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ks(e){let t=Os.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function As(e,t,n=1){`${e}`;let[r,i]=ks(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Kr(e)?parseFloat(e):e}return zi(i)?As(i,t,n+1):i}var js={type:`spring`,stiffness:500,damping:25,restSpeed:10},Ms=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ns={type:`keyframes`,duration:.8},Ps={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Fs=(e,{keyframes:t})=>t.length>2?Ns:Lo.has(e)?e.startsWith(`scale`)?Ms(t[1]):js:Ps;function Is(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Ls(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Is(n,e)}var Rs=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function zs(e){for(let t in e)if(!Rs.has(t))return!0;return!1}var Bs=(e,t,n,r={},i,a)=>o=>{let s=Ls(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=ti(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};zs(s)||Object.assign(u,Fs(e,u)),u.duration&&=ti(u.duration),u.repeatDelay&&=ti(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(vs(u),u.delay===0&&(d=!0)),(Gr.instantAnimations||Gr.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,vs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=_o(u.keyframes,s);if(e!==void 0){V.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new So(u):new Es(u)};function Vs(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Hs(e,t,n,r){if(typeof t==`function`){let[i,a]=Vs(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Vs(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Us(e,t,n){let r=e.getProps();return Hs(r,t,n===void 0?r.custom:n,e)}var Ws=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Io]),Gs=30,Ks=e=>!isNaN(parseFloat(e)),qs={current:void 0},Js=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Pi.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Pi.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Ks(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new ei);let n=this.events[e].add(t);return e===`change`?()=>{n(),V.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return qs.current&&qs.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Pi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Gs)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Gs);return ri(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Ys(e,t){return new Js(e,t)}var Xs=e=>Array.isArray(e);function Zs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ys(n))}function Qs(e){return Xs(e)?e[e.length-1]||0:e}function $s(e,t){let{transitionEnd:n={},transition:r={},...i}=Us(e,t)||{};i={...i,...n};for(let t in i)Zs(e,t,Qs(i[t]))}var ec=e=>!!(e&&e.getVelocity);function tc(e){return!!(ec(e)&&e.add)}function nc(e,t){let n=e.getValue(`willChange`);if(tc(n))return n.add(t);if(!n&&Gr.WillChange){let n=new Gr.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function rc(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var ic=`data-`+rc(`framerAppearId`);function ac(e){return e.props[ic]}function oc({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function sc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Is(a,c):c;let l=a?.reduceMotion;r&&(a=r);let u=[],d=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||d&&oc(d,t))continue;let o={delay:n,...Ls(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){V.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=ac(e);if(n){let e=window.MotionHandoffAnimation(n,t,V);e!==null&&(o.startTime=e,f=!0)}}nc(e,t);let p=l??e.shouldReduceMotion;r.start(Bs(t,r,i,p&&Ws.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>V.update(()=>{o&&$s(e,o)});u.length?Promise.all(u).then(t):t()}return u}function cc(e,t,n={}){let r=Us(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(sc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return lc(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function lc(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(cc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Ds(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function uc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>cc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=cc(e,t,n);else{let i=typeof t==`function`?Us(e,t,n.custom):t;r=Promise.all(sc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var dc={test:e=>e===`auto`,parse:e=>e},fc=e=>t=>t.test(e),pc=[Hi,W,ia,ra,oa,aa,dc],mc=e=>pc.find(fc(e));function hc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Jr(e)}var gc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function _c(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ki)||[];if(!r)return e;let i=n.replace(r,``),a=gc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var vc=/\b([a-z-]*)\(.*?\)/gu,yc={...Ta,getAnimatableNone:e=>{let t=e.match(vc);return t?t.map(_c).join(` `):e}},bc={...Ta,getAnimatableNone:e=>{let t=Ta.parse(e);return Ta.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},xc={...Hi,transform:Math.round},Sc={borderWidth:W,borderTopWidth:W,borderRightWidth:W,borderBottomWidth:W,borderLeftWidth:W,borderRadius:W,borderTopLeftRadius:W,borderTopRightRadius:W,borderBottomRightRadius:W,borderBottomLeftRadius:W,width:W,maxWidth:W,height:W,maxHeight:W,top:W,right:W,bottom:W,left:W,inset:W,insetBlock:W,insetBlockStart:W,insetBlockEnd:W,insetInline:W,insetInlineStart:W,insetInlineEnd:W,padding:W,paddingTop:W,paddingRight:W,paddingBottom:W,paddingLeft:W,paddingBlock:W,paddingBlockStart:W,paddingBlockEnd:W,paddingInline:W,paddingInlineStart:W,paddingInlineEnd:W,margin:W,marginTop:W,marginRight:W,marginBottom:W,marginLeft:W,marginBlock:W,marginBlockStart:W,marginBlockEnd:W,marginInline:W,marginInlineStart:W,marginInlineEnd:W,fontSize:W,backgroundPositionX:W,backgroundPositionY:W,rotate:ra,rotateX:ra,rotateY:ra,rotateZ:ra,scale:Wi,scaleX:Wi,scaleY:Wi,scaleZ:Wi,skew:ra,skewX:ra,skewY:ra,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:Ui,originX:sa,originY:sa,originZ:W,zIndex:xc,fillOpacity:Ui,strokeOpacity:Ui,numOctaves:xc},Cc={...Sc,color:la,backgroundColor:la,outlineColor:la,fill:la,stroke:la,borderColor:la,borderTopColor:la,borderRightColor:la,borderBottomColor:la,borderLeftColor:la,filter:yc,WebkitFilter:yc,mask:bc,WebkitMask:bc},wc=e=>Cc[e],Tc=new Set([yc,bc]);function Ec(e,t){let n=wc(e);return Tc.has(n)||(n=Ta),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Dc=new Set([`auto`,`none`,`0`]);function Oc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Dc.has(t)&&va(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Ec(n,i)}var kc=class extends Xo{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),zi(r))){let i=As(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Ws.has(n)||e.length!==2)return;let[r,i]=e,a=mc(r),o=mc(i);if(Vi(r)!==Vi(i)&&Ho[n]){this.needsMeasurement=!0;return}if(a!==o)if(Ro(a)&&Ro(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Ho[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||hc(e[t]))&&n.push(t);n.length&&Oc(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ho[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=Ho[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function Ac(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var jc=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Mc(e){return qr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Nc,cancel:Pc}=Ai(queueMicrotask,!1),Fc={x:!1,y:!1};function Ic(){return Fc.x||Fc.y}function Lc(e){return e===`x`||e===`y`?Fc[e]?null:(Fc[e]=!0,()=>{Fc[e]=!1}):Fc.x||Fc.y?null:(Fc.x=Fc.y=!0,()=>{Fc.x=Fc.y=!1})}function Rc(e,t){let n=Ac(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function zc(e){return!(e.pointerType===`touch`||Ic())}function Bc(e,t,n={}){let[r,i,a]=Rc(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!zc(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Vc=(e,t)=>t?e===t?!0:Vc(e,t.parentElement):!1,Hc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Uc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Wc(e){return Uc.has(e.tagName)||e.isContentEditable===!0}var Gc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Kc(e){return Gc.has(e.tagName)||e.isContentEditable===!0}var qc=new WeakSet;function Jc(e){return t=>{t.key===`Enter`&&e(t)}}function Yc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Xc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Jc(()=>{if(qc.has(n))return;Yc(n,`down`);let e=Jc(()=>{Yc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Yc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Zc(e){return Hc(e)&&!Ic()}var Qc=new WeakSet;function $c(e,t,n={}){let[r,i,a]=Rc(e,n),o=e=>{let r=e.currentTarget;if(!Zc(e)||Qc.has(e))return;qc.add(r),n.stopPropagation&&Qc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),qc.has(r)&&qc.delete(r),Zc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Vc(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),Mc(e)&&(e.addEventListener(`focus`,e=>Xc(e,i)),!Wc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function el(e){return qr(e)&&`ownerSVGElement`in e}var tl=new WeakMap,nl,rl=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:el(r)&&`getBBox`in r?r.getBBox()[t]:r[n],il=rl(`inline`,`width`,`offsetWidth`),al=rl(`block`,`height`,`offsetHeight`);function ol({target:e,borderBoxSize:t}){tl.get(e)?.forEach(n=>{n(e,{get width(){return il(e,t)},get height(){return al(e,t)}})})}function sl(e){e.forEach(ol)}function cl(){typeof ResizeObserver>`u`||(nl=new ResizeObserver(sl))}function ll(e,t){nl||cl();let n=Ac(e);return n.forEach(e=>{let n=tl.get(e);n||(n=new Set,tl.set(e,n)),n.add(t),nl?.observe(e)}),()=>{n.forEach(e=>{let n=tl.get(e);n?.delete(t),n?.size||nl?.unobserve(e)})}}var ul=new Set,dl;function fl(){dl=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ul.forEach(t=>t(e))},window.addEventListener(`resize`,dl)}function pl(e){return ul.add(e),dl||fl(),()=>{ul.delete(e),!ul.size&&typeof dl==`function`&&(window.removeEventListener(`resize`,dl),dl=void 0)}}function ml(e,t){return typeof e==`function`?pl(e):ll(e,t)}function hl(e){return el(e)&&e.tagName===`svg`}var gl=[...pc,la,Ta],_l=e=>gl.find(fc(e)),vl=()=>({translate:0,scale:1,origin:0,originPoint:0}),yl=()=>({x:vl(),y:vl()}),bl=()=>({min:0,max:0}),xl=()=>({x:bl(),y:bl()}),Sl=new WeakMap;function Cl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function wl(e){return typeof e==`string`||Array.isArray(e)}var Tl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],El=[`initial`,...Tl];function Dl(e){return Cl(e.animate)||El.some(t=>wl(e[t]))}function Ol(e){return!!(Dl(e)||e.variants)}function kl(e,t,n){for(let r in t){let i=t[r],a=n[r];if(ec(i))e.addValue(r,i);else if(ec(a))e.addValue(r,Ys(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Ys(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Al={current:null},jl={current:!1},Ml=typeof window<`u`;function Nl(){if(jl.current=!0,Ml)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Al.current=e.matches;e.addEventListener(`change`,t),t()}else Al.current=!1}var Pl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Fl={};function Il(e){Fl=e}function Ll(){return Fl}var Rl=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Xo,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Pi.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,V.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Dl(t),this.isVariantNode=Ol(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&ec(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,Sl.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(jl.current||Nl(),this.shouldReduceMotion=Al.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),H(this.notifyUpdate),H(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&ys.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new ls({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:ti(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Lo.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&V.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Fl){let t=Fl[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):xl()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Pl.length;t++){let n=Pl[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=kl(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Ys(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Kr(n)||Jr(n))?n=parseFloat(n):!_l(n)&&Ta.test(t)&&(n=Ec(e,t)),this.setBaseTarget(e,ec(n)?n.get():n)),ec(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Hs(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!ec(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new ei),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Nc.render(this.render)}},K=class extends Rl{constructor(){super(...arguments),this.KeyframeResolver=kc}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;ec(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},q=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function J({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Y({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function zl(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Bl(e){return e===void 0||e===1}function Vl({scale:e,scaleX:t,scaleY:n}){return!Bl(e)||!Bl(t)||!Bl(n)}function Hl(e){return Vl(e)||Ul(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ul(e){return Wl(e.x)||Wl(e.y)}function Wl(e){return e&&e!==`0%`}function Gl(e,t,n){return n+t*(e-n)}function Kl(e,t,n,r,i){return i!==void 0&&(e=Gl(e,i,r)),Gl(e,n,r)+t}function ql(e,t=0,n=1,r,i){e.min=Kl(e.min,t,n,r,i),e.max=Kl(e.max,t,n,r,i)}function Jl(e,{x:t,y:n}){ql(e.x,t.translate,t.scale,t.originPoint),ql(e.y,n.translate,n.scale,n.originPoint)}var Yl=.999999999999,Xl=1.0000000000001;function Zl(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Ql(e.x,-a.scroll.offset.x),Ql(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Jl(e,o)),r&&Hl(a.latestValues)&&tu(e,a.latestValues,a.layout?.layoutBox))}t.x<Xl&&t.x>Yl&&(t.x=1),t.y<Xl&&t.y>Yl&&(t.y=1)}function Ql(e,t){e.min+=t,e.max+=t}function $l(e,t,n,r,i=.5){ql(e,t,n,ka(e.min,e.max,i),r)}function eu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function tu(e,t,n){let r=n??e;$l(e.x,eu(t.x,r.x),t.scaleX,t.scale,t.originX),$l(e.y,eu(t.y,r.y),t.scaleY,t.scale,t.originY)}function nu(e,t){return J(zl(e.getBoundingClientRect(),t))}function ru(e,t,n){let r=nu(e,n),{scroll:i}=t;return i&&(Ql(r.x,i.offset.x),Ql(r.y,i.offset.y)),r}var iu={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},au=Io.length;function ou(e,t,n){let r=``,i=!0;for(let a=0;a<au;a++){let o=Io[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===(o.startsWith(`scale`)?1:0);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=jc(s,Sc[o]);if(!c){i=!1;let t=iu[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function su(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Lo.has(e)){o=!0;continue}else if(Li(e)){i[e]=n;continue}else{let t=jc(n,Sc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=ou(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function cu(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function lu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var uu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${lu(e,t.target.x)}% ${lu(e,t.target.y)}%`}},du={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Ta.parse(e);if(i.length>5)return r;let a=Ta.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=ka(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},fu={borderRadius:{...uu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:uu,borderTopRightRadius:uu,borderBottomLeftRadius:uu,borderBottomRightRadius:uu,boxShadow:du};function pu(e,{layout:t,layoutId:n}){return Lo.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!fu[e]||e===`opacity`)}function mu(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(ec(r[t])||i&&ec(i[t])||pu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function hu(e){return window.getComputedStyle(e)}var gu=class extends K{constructor(){super(...arguments),this.type=`html`,this.renderInstance=cu}readValueFromInstance(e,t){if(Lo.has(t))return this.projection?.isProjecting?Mo(t):Po(e,t);{let n=hu(e),r=(Li(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return nu(e,t)}build(e,t,n){su(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return mu(e,t,n)}},_u={offset:`stroke-dashoffset`,array:`stroke-dasharray`},vu={offset:`strokeDashoffset`,array:`strokeDasharray`};function yu(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?_u:vu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var bu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function xu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(su(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of bu)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&yu(d,i,a,o,!1)}var Su=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),Cu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function wu(e,t,n,r){cu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Su.has(n)?n:rc(n),t.attrs[n])}function Tu(e,t,n){let r=mu(e,t,n);for(let n in e)if(ec(e[n])||ec(t[n])){let t=Io.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Eu=class extends K{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=xl}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Lo.has(t)){let e=wc(t);return e&&e.default||0}return t=Su.has(t)?t:rc(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Tu(e,t,n)}build(e,t,n){xu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){wu(e,t,n,r)}mount(e){this.isSVGTag=Cu(e.tagName),super.mount(e)}},Du=El.length;function Ou(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Ou(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Du;n++){let r=El[n],i=e.props[r];(wl(i)||i===!1)&&(t[r]=i)}return t}function ku(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Au=[...Tl].reverse(),ju=Tl.length;function Mu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>uc(e,t,n)))}function Nu(e){let t=Mu(e),n=Iu(),r=!0,i=!1,a=t=>(n,r)=>{let i=Us(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=Ou(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<ju;t++){let p=Au[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=wl(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||Cl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Pu(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,ee={...w,...C},T=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in ee){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Xs(t)&&Xs(n)?!ku(t,n):t!==n,r?t==null?u.add(e):T(e):t!==void 0&&u.has(e)?T(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let te=v&&y;b&&(!te||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!te&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Us(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Ds(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Us(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Iu(),i=!0}}}function Pu(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ku(t,e):!1}function Fu(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Iu(){return{animate:Fu(!0),whileInView:Fu(),whileHover:Fu(),whileTap:Fu(),whileDrag:Fu(),whileFocus:Fu(),exit:Fu()}}function Lu(e,t){e.min=t.min,e.max=t.max}function Ru(e,t){Lu(e.x,t.x),Lu(e.y,t.y)}function zu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Bu=1e-4,Vu=1-Bu,Hu=1+Bu,Uu=.01,Wu=0-Uu,Gu=0+Uu;function X(e){return e.max-e.min}function Ku(e,t,n){return Math.abs(e-t)<=n}function qu(e,t,n,r=.5){e.origin=r,e.originPoint=ka(t.min,t.max,e.origin),e.scale=X(n)/X(t),e.translate=ka(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Vu&&e.scale<=Hu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Wu&&e.translate<=Gu||isNaN(e.translate))&&(e.translate=0)}function Ju(e,t,n,r){qu(e.x,t.x,n.x,r?r.originX:void 0),qu(e.y,t.y,n.y,r?r.originY:void 0)}function Yu(e,t,n,r=0){e.min=(r?ka(n.min,n.max,r):n.min)+t.min,e.max=e.min+X(t)}function Xu(e,t,n,r){Yu(e.x,t.x,n.x,r?.x),Yu(e.y,t.y,n.y,r?.y)}function Zu(e,t,n,r=0){let i=r?ka(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+X(t)}function Qu(e,t,n,r){Zu(e.x,t.x,n.x,r?.x),Zu(e.y,t.y,n.y,r?.y)}function $u(e,t,n,r,i){return e-=t,e=Gl(e,1/n,r),i!==void 0&&(e=Gl(e,1/i,r)),e}function ed(e,t=0,n=1,r=.5,i,a=e,o=e){if(ia.test(t)&&(t=parseFloat(t),t=ka(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=ka(a.min,a.max,r);e===a&&(s-=t),e.min=$u(e.min,t,n,s,i),e.max=$u(e.max,t,n,s,i)}function td(e,t,[n,r,i],a,o){ed(e,t[n],t[r],t[i],t.scale,a,o)}var nd=[`x`,`scaleX`,`originX`],rd=[`y`,`scaleY`,`originY`];function id(e,t,n,r){td(e.x,t,nd,n?n.x:void 0,r?r.x:void 0),td(e.y,t,rd,n?n.y:void 0,r?r.y:void 0)}function ad(e){return e.translate===0&&e.scale===1}function od(e){return ad(e.x)&&ad(e.y)}function sd(e,t){return e.min===t.min&&e.max===t.max}function cd(e,t){return sd(e.x,t.x)&&sd(e.y,t.y)}function ld(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ud(e,t){return ld(e.x,t.x)&&ld(e.y,t.y)}function dd(e){return X(e.x)/X(e.y)}function fd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function pd(e){return[e(`x`),e(`y`)]}function md(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var hd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],gd=hd.length,_d=e=>typeof e==`string`?parseFloat(e):e,vd=e=>typeof e==`number`||W.test(e);function yd(e,t,n,r,i,a){i?(e.opacity=ka(0,n.opacity??1,Z(r)),e.opacityExit=ka(t.opacity??1,0,xd(r))):a&&(e.opacity=ka(t.opacity??1,n.opacity??1,r));for(let i=0;i<gd;i++){let a=hd[i],o=bd(t,a),s=bd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||vd(o)===vd(s)?(e[a]=Math.max(ka(_d(o),_d(s),r),0),(ia.test(s)||ia.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=ka(t.rotate||0,n.rotate||0,r))}function bd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Z=Sd(0,.5,gi),xd=Sd(.5,.95,Xr);function Sd(e,t,n){return r=>r<e?0:r>t?1:n($r(e,t,r))}function Cd(e,t,n){let r=ec(e)?e:Ys(e);return r.start(Bs(``,r,t,n)),r.animation}function wd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var Td=(e,t)=>e.depth-t.depth,Ed=class{constructor(){this.children=[],this.isDirty=!1}add(e){Hr(this.children,e),this.isDirty=!0}remove(e){Ur(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(e)}};function Dd(e,t){let n=Pi.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(H(r),e(a-t))};return V.setup(r,!0),()=>H(r)}function Od(e){return ec(e)?e.get():e}var kd=class{constructor(){this.members=[]}add(e){Hr(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Ur(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Ur(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Ad={hasAnimatedSinceResize:!0,hasEverUpdated:!1},jd={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Md=[``,`X`,`Y`,`Z`],Nd=1e3,Pd=0;function Fd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Id(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ac(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,V,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Id(r)}function Ld({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Pd++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Di.value&&(jd.nodes=jd.calculatedTargetDeltas=jd.calculatedProjections=0),this.nodes.forEach(Bd),this.nodes.forEach(Yd),this.nodes.forEach(Xd),this.nodes.forEach(Vd),Di.addProjectionMetrics&&Di.addProjectionMetrics(jd)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new Ed)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ei),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=el(t)&&!hl(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;V.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Dd(i,250),Ad.hasAnimatedSinceResize&&(Ad.hasAnimatedSinceResize=!1,this.nodes.forEach(Jd)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||rf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!ud(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Ls(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l)}else t||Jd(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),H(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Zd),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Id(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(Wd),this.nodes.forEach(Ud);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Gd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Kd),this.nodes.forEach(qd),this.nodes.forEach(Rd),this.nodes.forEach(zd)):this.nodes.forEach(Gd),this.clearAllSnapshots();let e=Pi.now();U.delta=Wr(0,1e3/60,e-U.timestamp),U.timestamp=e,U.isProcessing=!0,ji.update.process(U),ji.preRender.process(U),ji.render.process(U),U.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Nc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Hd),this.sharedNodes.forEach(Qd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,V.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){V.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!X(this.snapshot.measuredBox.x)&&!X(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=xl(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!od(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Hl(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),cf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return xl();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(uf))){let{scroll:e}=this.root;e&&(Ql(t.x,e.offset.x),Ql(t.y,e.offset.y))}return t}removeElementScroll(e){let t=xl();if(Ru(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Ru(t,e),Ql(t.x,i.offset.x),Ql(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||xl();Ru(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Ql(r.x,-n.scroll.offset.x),Ql(r.y,-n.scroll.offset.y)),Hl(n.latestValues)&&tu(r,n.latestValues,n.layout?.layoutBox)}return Hl(this.latestValues)&&tu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=xl();Ru(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Hl(n.latestValues))continue;let r;n.instance&&(Vl(n.latestValues)&&n.updateSnapshot(),r=xl(),Ru(r,n.measurePageBox())),id(t,n.latestValues,n.snapshot?.layoutBox,r)}return Hl(this.latestValues)&&id(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==U.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=U.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=xl(),this.targetWithTransforms=xl()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Xu(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Ru(this.target,this.layout.layoutBox),Jl(this.target,this.targetDelta)):Ru(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Di.value&&jd.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Vl(this.parent.latestValues)||Ul(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=xl(),this.relativeTargetOrigin=xl(),Qu(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Ru(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===U.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Ru(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Zl(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=xl());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(zu(this.prevProjectionDelta.x,this.projectionDelta.x),zu(this.prevProjectionDelta.y,this.projectionDelta.y)),Ju(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!fd(this.projectionDelta.x,this.prevProjectionDelta.x)||!fd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Di.value&&jd.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=yl(),this.projectionDelta=yl(),this.projectionDeltaWithTransform=yl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=yl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=xl(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(nf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;$d(a.x,e.x,n),$d(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Qu(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&cd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=xl(),Ru(d,this.relativeTarget)),s&&(this.animationValues=i,yd(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(H(this.pendingAnimation),void 0),this.pendingAnimation=V.update(()=>{Ad.hasAnimatedSinceResize=!0,Fi.layout++,this.motionValue||=Ys(0),this.motionValue.jump(0,!1),this.currentAnimation=Cd(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Fi.layout--},onComplete:()=>{Fi.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&lf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||xl();let t=X(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=X(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Ru(t,n),tu(t,i),Ju(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new kd),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Fd(`z`,e,r,this.animationValues);for(let t=0;t<Md.length;t++)Fd(`rotate${Md[t]}`,e,r,this.animationValues),Fd(`skew${Md[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=Od(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=Od(t?.pointerEvents)||``),this.hasProjected&&!Hl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=md(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in fu){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=fu[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?Od(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Ud),this.root.sharedNodes.clear()}}}function Rd(e){e.updateLayout()}function zd(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)pd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=X(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Lu(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else lf(i,t.layoutBox,n)&&pd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=X(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=yl();Ju(o,n,t.layoutBox);let s=yl();a?Ju(s,e.applyTransform(r,!0),t.measuredBox):Ju(s,n,t.layoutBox);let c=!od(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=xl();Qu(s,t.layoutBox,i.layoutBox,o);let c=xl();Qu(c,n,a.layoutBox,o),ud(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Bd(e){Di.value&&jd.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Vd(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Hd(e){e.clearSnapshot()}function Ud(e){e.clearMeasurements()}function Wd(e){e.isLayoutDirty=!0,e.updateLayout()}function Gd(e){e.isLayoutDirty=!1}function Kd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function qd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Jd(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Yd(e){e.resolveTargetDelta()}function Xd(e){e.calcProjection()}function Zd(e){e.resetSkewAndRotation()}function Qd(e){e.removeLeadSnapshot()}function $d(e,t,n){e.translate=ka(t.translate,0,n),e.scale=ka(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ef(e,t,n,r){e.min=ka(t.min,n.min,r),e.max=ka(t.max,n.max,r)}function tf(e,t,n,r){ef(e.x,t.x,n.x,r),ef(e.y,t.y,n.y,r)}function nf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var rf={duration:.45,ease:[.4,0,.1,1]},af=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),of=af(`applewebkit/`)&&!af(`chrome/`)?Math.round:Xr;function sf(e){e.min=of(e.min),e.max=of(e.max)}function cf(e){sf(e.x),sf(e.y)}function lf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ku(dd(t),dd(n),.2)}function uf(e){return e!==e.root&&e.scroll?.wasRoot}var df=Ld({attachResizeListener:(e,t)=>wd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),ff={current:void 0},pf=Ld({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ff.current){let e=new df({});e.mount(window),e.setOptions({layoutScroll:!0}),ff.current=e}return ff.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),mf=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function hf(e=!0){let t=(0,b.useContext)(Vr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,b.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var gf=(0,b.createContext)({strict:!1}),_f={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},vf=!1;function yf(){if(vf)return;let e={};for(let t in _f)e[t]={isEnabled:e=>_f[t].some(t=>!!e[t])};Il(e),vf=!0}function bf(){return yf(),Ll()}function xf(e){let t=bf();for(let n in e)t[n]={...t[n],...e[n]};Il(t)}var Sf=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Cf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Sf.has(e)}var wf=c({default:()=>Tf}),Tf,Ef=o((()=>{throw Tf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Df=e=>!Cf(e);function Of(e){typeof e==`function`&&(Df=t=>t.startsWith(`on`)?!Cf(t):e(t))}try{Of((Ef(),d(wf)).default)}catch{}function kf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||ec(e[i])||(Df(i)||n===!0&&Cf(i)||!t&&!Cf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Af=(0,b.createContext)({});function jf(e,t){if(Dl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||wl(t)?t:void 0,animate:wl(n)?n:void 0}}return e.inherit===!1?{}:t}function Mf(e){let{initial:t,animate:n}=jf(e,(0,b.useContext)(Af));return(0,b.useMemo)(()=>({initial:t,animate:n}),[Nf(t),Nf(n)])}function Nf(e){return Array.isArray(e)?e.join(` `):e}var Pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ff(e,t,n){for(let r in t)!ec(t[r])&&!pu(r,n)&&(e[r]=t[r])}function If({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=Pf();return su(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Lf(e,t){let n=e.style||{},r={};return Ff(r,n,e),Object.assign(r,If(e,t)),r}function Rf(e,t){let n={},r=Lf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var zf=()=>({...Pf(),attrs:{}});function Bf(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=zf();return xu(n,t,Cu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Ff(t,e.style,e),i.style={...t,...i.style}}return i}var Vf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function Hf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Vf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Uf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Hf(e)?Bf:Rf)(t,r,i,e),c=kf(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>ec(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function Wf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Gf(n,r,i,e),renderState:t()}}function Gf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Od(a[e]);let{initial:o,animate:s}=e,c=Dl(e),l=Ol(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Cl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Hs(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Kf=e=>(t,n)=>{let r=(0,b.useContext)(Af),i=(0,b.useContext)(Vr),a=()=>Wf(e,t,r,i);return n?a():zr(a)},qf=Kf({scrapeMotionValuesFromProps:mu,createRenderState:Pf}),Jf=Kf({scrapeMotionValuesFromProps:Tu,createRenderState:zf}),Yf=Symbol.for(`motionComponentSymbol`);function Xf(e,t,n){let r=(0,b.useRef)(n);(0,b.useInsertionEffect)(()=>{r.current=n});let i=(0,b.useRef)(null);return(0,b.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var Zf=(0,b.createContext)({});function Qf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function $f(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(Af),s=(0,b.useContext)(gf),c=(0,b.useContext)(Vr),l=(0,b.useContext)(mf),u=l.reducedMotion,d=l.skipAnimations,f=(0,b.useRef)(null),p=(0,b.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,b.useContext)(Zf);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&ep(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[ic],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Br(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,b.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function ep(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:tp(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Qf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function tp(e){if(e)return e.options.allowProjection===!1?tp(e.parent):e.projection}function np(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&xf(r);let a=n?n===`svg`:Hf(e),o=a?Jf:qf;function s(n,s){let c,l={...(0,b.useContext)(mf),...n,layoutId:rp(n)},{isStatic:u}=l,d=Mf(n),f=o(n,u);if(!u&&typeof window<`u`){ip(l,r);let t=ap(l);c=t.MeasureLayout,d.visualElement=$f(e,f,l,i,t.ProjectionNode,a)}return(0,B.jsxs)(Af.Provider,{value:d,children:[c&&d.visualElement?(0,B.jsx)(c,{visualElement:d.visualElement,...l}):null,Uf(e,n,Xf(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,b.forwardRef)(s);return c[Yf]=e,c}function rp({layoutId:e}){let t=(0,b.useContext)(Rr).id;return t&&e!==void 0?t+`-`+e:e}function ip(e,t){(0,b.useContext)(gf).strict}function ap(e){let{drag:t,layout:n}=bf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function op(e,t){if(typeof Proxy>`u`)return np;let n=new Map,r=(n,r)=>np(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,np(a,void 0,e,t)),n.get(a))})}var sp=(e,t)=>t.isSVG??Hf(e)?new Eu(t):new gu(t,{allowProjection:e!==b.Fragment}),cp=class extends q{constructor(e){super(e),e.animationState||=Nu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Cl(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},lp=0,up={animation:{Feature:cp},exit:{Feature:class extends q{constructor(){super(...arguments),this.id=lp++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=Us(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function dp(e){return{point:{x:e.pageX,y:e.pageY}}}var fp=e=>t=>Hc(t)&&e(t,dp(t));function pp(e,t,n,r){return wd(e,t,fp(n),r)}var mp=({current:e})=>e?e.ownerDocument.defaultView:null,hp=(e,t)=>Math.abs(e-t);function gp(e,t){let n=hp(e.x,t.x),r=hp(e.y,t.y);return Math.sqrt(n**2+r**2)}var _p=new Set([`auto`,`scroll`]),vp=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=yp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=xp(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=gp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=U;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=yp(t,this.transformPagePoint),V.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=xp(e.type===`pointercancel`?this.lastMoveEventInfo:yp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Hc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=yp(dp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=U;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,xp(s,this.history)),this.removeListeners=Qr(pp(this.contextWindow,`pointermove`,this.handlePointerMove),pp(this.contextWindow,`pointerup`,this.handlePointerUp),pp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(_p.has(e.overflowX)||_p.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),V.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),H(this.updatePoint)}};function yp(e,t){return t?{point:t(e.point)}:e}function bp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function xp({point:e},t){return{point:e,delta:bp(e,Cp(t)),offset:bp(e,Sp(t)),velocity:wp(t,.1)}}function Sp(e){return e[0]}function Cp(e){return e[e.length-1]}function wp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Cp(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>ti(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>ti(t)*2&&(r=e[1]);let a=ni(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Tp(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?ka(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?ka(n,e,r.max):Math.min(e,n)),e}function Ep(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Dp(e,{top:t,left:n,bottom:r,right:i}){return{x:Ep(e.x,n,i),y:Ep(e.y,t,r)}}function Op(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function kp(e,t){return{x:Op(e.x,t.x),y:Op(e.y,t.y)}}function Ap(e,t){let n=.5,r=X(e),i=X(t);return i>r?n=$r(t.min,t.max-r,e.min):r>i&&(n=$r(e.min,e.max-i,t.min)),Wr(0,1,n)}function jp(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Mp=.35;function Np(e=Mp){return e===!1?e=0:e===!0&&(e=Mp),{x:Pp(e,`left`,`right`),y:Pp(e,`top`,`bottom`)}}function Pp(e,t,n){return{min:Fp(e,t),max:Fp(e,n)}}function Fp(e,t){return typeof e==`number`?e:e[t]||0}var Ip=new WeakMap,Lp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=xl(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(dp(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Lc(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),pd(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ia.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=X(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&V.update(()=>i(e,t),!1,!0),nc(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Vp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&V.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new vp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:mp(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&V.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!Bp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Tp(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Qf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Dp(n.layoutBox,e):this.constraints=!1,this.elastic=Np(t),r!==this.constraints&&!Qf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&pd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=jp(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Qf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=ru(n,r.root,this.visualElement.getTransformPagePoint()),a=kp(r.layout.layoutBox,i);if(t){let e=t(Y(a));this.hasMutatedConstraints=!!e,e&&(a=J(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=pd(o=>{if(!Bp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return nc(this.visualElement,e),n.start(Bs(e,n,0,t,this.visualElement,!1))}stopAnimation(){pd(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){pd(t=>{let{drag:n}=this.getProps();if(!Bp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-ka(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Qf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};pd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Ap({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),pd(t=>{if(!Bp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(ka(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Ip.set(this.visualElement,this);let e=this.visualElement.current,t=pp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Kc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Qf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=zp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),V.read(r);let o=wd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(pd(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Mp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Rp(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function zp(e,t,n){let r=ml(e,Rp(n)),i=ml(t,Rp(n));return()=>{r(),i()}}function Bp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Vp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Hp=class extends q{constructor(e){super(e),this.removeGroupControls=Xr,this.removeListeners=Xr,this.controls=new Lp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Xr}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Up=e=>(t,n)=>{e&&V.update(()=>e(t,n),!1,!0)},Wp=class extends q{constructor(){super(...arguments),this.removePointerDownListener=Xr}onPointerDown(e){this.session=new vp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Up(e),onStart:Up(t),onMove:Up(n),onEnd:(e,t)=>{delete this.session,r&&V.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=pp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Gp=!1,Kp=class extends b.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),Gp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ad.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),Gp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||V.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Nc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Gp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function qp(e){let[t,n]=hf(),r=(0,b.useContext)(Rr);return(0,B.jsx)(Kp,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Zf),isPresent:t,safeToRemove:n})}var Jp={pan:{Feature:Wp},drag:{Feature:Hp,ProjectionNode:pf,MeasureLayout:qp}};function Yp(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&V.postRender(()=>i(t,dp(t)))}var Xp=class extends q{mount(){let{current:e}=this.node;e&&(this.unmount=Bc(e,(e,t)=>(Yp(this.node,t,`Start`),e=>Yp(this.node,e,`End`))))}unmount(){}},Zp=class extends q{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Qr(wd(this.node.current,`focus`,()=>this.onFocus()),wd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Qp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&V.postRender(()=>i(t,dp(t)))}var $p=class extends q{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=$c(e,(e,t)=>(Qp(this.node,t,`Start`),(e,{success:t})=>Qp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},em=new WeakMap,tm=new WeakMap,nm=e=>{let t=em.get(e.target);t&&t(e)},rm=e=>{e.forEach(nm)};function im({root:e,...t}){let n=e||document;tm.has(n)||tm.set(n,{});let r=tm.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(rm,{root:e,...t})),r[i]}function am(e,t,n){let r=im(t);return em.set(e,n),r.observe(e),()=>{em.delete(e),r.unobserve(e)}}var om={some:0,all:1},sm=class extends q{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:om[r]};this.stopObserver=am(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(cm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function cm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var lm={inView:{Feature:sm},tap:{Feature:$p},focus:{Feature:Zp},hover:{Feature:Xp}},um={layout:{ProjectionNode:pf,MeasureLayout:qp}},dm=op({...up,...lm,...Jp,...um},sp),fm=24e3,pm=2048;function mm(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=Math.max(-1,Math.min(1,e[n]));t[n]=r<0?r*32768:r*32767}return t}function hm(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}function gm(e,t){let n=0,r=[];return{enqueue:i=>{let a=hm(i),o=e.createBuffer(1,a.length,fm);o.copyToChannel(a,0);let s=e.createBufferSource();s.buffer=o,s.connect(e.destination);let c=Math.max(e.currentTime,n);s.start(c),n=c+o.duration,r.push(s),s.onended=()=>{r=r.filter(e=>e!==s),r.length||t?.()}},stop:()=>{r.forEach(e=>{try{e.stop()}catch{}}),r=[],n=0},isPlaying:()=>r.length>0}}async function _m(e,t,n){let r=new URLSearchParams({siteId:t||``});n&&r.set(`chatId`,n);let i=await fetch(`${e}/api/voice/session?${r.toString()}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(i.status===429){let e=await i.json().catch(()=>({}));throw Error(e.message||`Too many voice sessions started. Please wait a minute before trying again.`)}if(!i.ok)throw Error(`Could not start a voice session.`);let a=await i.json();if(!a?.success||!a.token)throw Error(a?.error||`Voice session was refused.`);return a}async function vm(e){let{apiBaseUrl:t,siteId:n,chatId:r,clientTools:i={},onConnect:a,onDisconnect:o,onMessage:s,onModeChange:c,onError:l,onUnhandledClientToolCall:u}=e,d=await _m(t,n,r);e.greeting!==void 0&&(e.greeting?d.settings.agent.greeting=e.greeting:delete d.settings.agent.greeting);let f=d.settings?.agent?.think?.prompt||``,p=``,m=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),h=new(window.AudioContext||window.webkitAudioContext)({sampleRate:fm});h.state===`suspended`&&await h.resume();let g=new WebSocket(d.wsUrl,[`token`,d.token]);g.binaryType=`arraybuffer`;let _=!1,v=!1,y=!1,b=gm(h,()=>{y&&(y=!1,c?.({mode:`listening`}))}),x=h.createMediaStreamSource(m),S=h.createScriptProcessor(pm,1,1);S.onaudioprocess=e=>{_||v||g.readyState!==WebSocket.OPEN||g.send(mm(e.inputBuffer.getChannelData(0)).buffer)},x.connect(S),S.connect(h.destination);let C=()=>{if(!_){_=!0,b.stop();try{S.disconnect(),x.disconnect()}catch{}m.getTracks().forEach(e=>e.stop()),h.close().catch(()=>{}),(g.readyState===WebSocket.OPEN||g.readyState===WebSocket.CONNECTING)&&g.close()}},w=async e=>{let t=i[e.name];if(!t)return u?.({tool_name:e.name}),{error:`Unknown tool ${e.name}`};let n={};try{n=JSON.parse(e.arguments||`{}`)}catch{}try{return await t(n)}catch(e){return{error:e?.message||`Tool execution failed`}}},ee=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await w(t);if(_||g.readyState!==WebSocket.OPEN)return;g.send(JSON.stringify({type:`FunctionCallResponse`,id:t.id,name:t.name,content:typeof e==`string`?e:JSON.stringify(e??{})}))}},T=e=>{switch(e.type){case`Welcome`:a?.({conversationId:e.request_id||d.token.slice(0,12)});break;case`ConversationText`:s?.({role:e.role===`user`?`user`:`agent`,message:e.content});break;case`UserStartedSpeaking`:b.stop(),y=!1,c?.({mode:`listening`});break;case`AgentStartedSpeaking`:y=!0,c?.({mode:`speaking`});break;case`AgentAudioDone`:b.isPlaying()||(y=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:ee(e);break;case`Error`:l?.(Error(e.description||`Voice service error`));break;default:break}};return g.onopen=()=>g.send(JSON.stringify(d.settings)),g.onmessage=e=>{if(e.data instanceof ArrayBuffer){b.enqueue(new Int16Array(e.data));return}try{T(JSON.parse(e.data))}catch{}},g.onerror=()=>l?.(Error(`Voice connection failed`)),g.onclose=()=>{C(),o?.()},{endSession:async()=>C(),sendContextualUpdate:e=>{_||g.readyState!==WebSocket.OPEN||!e||(p+=`\n\n${e}`,g.send(JSON.stringify({type:`UpdatePrompt`,prompt:`${f}${p}`})))},setMicMuted:e=>{v=!!e},get status(){return _?`disconnected`:`connected`}}}var ym={startSession:vm},bm=({size:e=18,color:t=`currentColor`})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:t}),(0,B.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),xm=({size:e=20})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,B.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),Sm=({size:e=18})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,B.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),Cm=()=>(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,B.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),wm=()=>(0,B.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z`})}),Tm=({className:e=``})=>(0,B.jsxs)(`svg`,{className:e,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,B.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,B.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),Em=({size:e=14})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 8V4H8`}),(0,B.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,B.jsx)(`path`,{d:`M2 14h2`}),(0,B.jsx)(`path`,{d:`M20 14h2`}),(0,B.jsx)(`path`,{d:`M15 13v2`}),(0,B.jsx)(`path`,{d:`M9 13v2`})]}),Dm=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,B.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),Om=({size:e=20,color:t=`currentColor`})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:t}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:t}),(0,B.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:t})]}),km=({size:e=20,color:t=`currentColor`})=>(0,B.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`path`,{d:`M22 11.5667C22 16.8499 17.5222 21.1334 12 21.1334C11.3507 21.1343 10.7032 21.0742 10.0654 20.9545C9.60633 20.8682 9.37678 20.8251 9.21653 20.8496C9.05627 20.8741 8.82918 20.9948 8.37499 21.2364C7.09014 21.9197 5.59195 22.161 4.15111 21.893C4.69874 21.2194 5.07275 20.4112 5.23778 19.5448C5.33778 19.0148 5.09 18.5 4.71889 18.1231C3.03333 16.4115 2 14.1051 2 11.5667C2 6.28357 6.47778 2 12 2C17.5222 2 22 6.28357 22 11.5667Z`,stroke:`white`,"stroke-width":`1.5`,"stroke-linejoin":`round`}),(0,B.jsx)(`path`,{d:`M11.9955 12H12.0045M15.991 12H16M8 12H8.00897`,stroke:`white`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]}),Am=()=>(0,B.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,B.jsx)(`path`,{d:`M16.7133 8.59374C18.1939 8.98463 19.2229 9.47922 20.1589 10.0848C21.5432 10.9804 22.1367 12.5944 21.9737 14.1517C21.9049 14.8099 21.3744 15.1246 20.7592 14.9544L19.3705 14.57C18.2697 14.2653 17.7193 14.1129 17.3837 13.71C17.0481 13.307 17.0086 12.751 16.9296 11.6391L16.7133 8.59374ZM16.7133 8.59374C13.7164 7.80255 10.2871 7.80163 7.28669 8.59374M7.28669 8.59374C5.80606 8.98463 4.77711 9.47923 3.84113 10.0848C2.45683 10.9804 1.86334 12.5944 2.02628 14.1517C2.09514 14.8099 2.62563 15.1246 3.24078 14.9544L4.62954 14.57C5.73032 14.2653 6.28071 14.1129 6.61631 13.71C6.95191 13.307 6.9914 12.751 7.07038 11.6391L7.28669 8.59374Z`,stroke:`#E30C12`,"stroke-width":`1.5`,"stroke-linejoin":`round`})}),jm=({size:e=24})=>(0,B.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 19v3`}),(0,B.jsx)(`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`}),(0,B.jsx)(`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`}),(0,B.jsx)(`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`}),(0,B.jsx)(`path`,{d:`m2 2 20 20`}),(0,B.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`})]}),Mm=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),Nm=(e=``)=>String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Pm=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),Fm=/^https?:\/\//i;function Im(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Pm.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;Fm.test(e)&&(r.href=e),r.target=`_blank`,r.rel=`noopener noreferrer`}for(;n.attributes.length>0;)n.removeAttribute(n.attributes[0].name);for(let[e,t]of Object.entries(r))n.setAttribute(e,t);Im(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Lm(e){let t=document.createElement(`div`);return t.innerHTML=e,Im(t),t.innerHTML}function Rm(e){let t=String(e||``).trim();if(!t)return t;let n=/^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);if(n&&!/<\/?strong\b/i.test(n[1]))return`<p>${n[1]}</p>`;let r=/^<strong>([\s\S]*?)<\/strong>$/i.exec(t);if(r&&!/<\/?strong\b/i.test(r[1])){let e=r[1].trim();return/^<(?:p|ul|ol)\b/i.test(e)?e:`<p>${e}</p>`}return e}var zm=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return Rm(Lm(t));let n=t.replace(/\r\n/g,`
|
|
33
|
+
`,document.head.appendChild(e)};function fr(e,t){if(typeof document>`u`)return null;if(e){let n=document.getElementById(e)||document.querySelector(`[data-section="${e}"]`);if(n)return n;t||=e.replace(/[-_]+/g,` `).trim()}if(!t)return null;let n=t.toLowerCase().trim(),r=n.split(/\s+/).filter(e=>e.length>2),i=Array.from(document.querySelectorAll(`h1.h2.h3.h4.h5.h6.[data-section].section[id].[id].main li.article li.[role='main'] li.[class*='card'].[class*='Card'].[class*='feature'].[class*='Feature'].[class*='tier'].[class*='Tier'].[class*='plan'].[class*='Plan'].[class*='pricing'].[class*='Pricing'].[class*='testimonial'].[class*='Testimonial'].[class*='team'].[class*='Team'].[class*='service'].[class*='Service'].[class*='block'].[role='listitem'].[role='article'].[role='region'].dt.dd`.split(`.`).join(`, `))).filter(e=>{if(Nn(e))return!1;let t=e.textContent.trim();return!(t.length<3||t.length>5e3||e.closest(`nav, footer, header, aside, .nav, .footer, .header`))});for(let e of i)if(Pn(e).toLowerCase()===n)return e;for(let e of i){let t=Pn(e).toLowerCase();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=Pn(e).toLowerCase();t.includes(n)&&a.push({el:e,len:t.length})}if(a.length)return a.sort((e,t)=>e.len-t.len),a[0].el;for(let e of i){let t=Pn(e).toLowerCase();if(t.length>3&&n.includes(t))return e}if(r.length>0){let e=null,t=0;for(let n of i){let i=Pn(n).toLowerCase(),a=0;for(let e of r)i.includes(e)&&a++;let o=a/r.length;o>t&&o>=.6&&(t=o,e=n)}if(e)return e}let o=Array.from(document.querySelectorAll(`main [role='group']`)).filter(e=>!Nn(e)),s=[];for(let e of o){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();t.length<15||t.length>8e3||t.includes(n)&&s.push({el:e,len:t.length})}if(s.length)return s.sort((e,t)=>e.len-t.len),s[0].el;if(r.length>0){let e=Array.from(document.querySelectorAll(`main a[href], article a[href], .views-row a[href], h2 a[href], h3 a[href], .card a[href], [class*='teaser'] a[href]`)).filter(e=>{if(Nn(e))return!1;try{let t=e.getAttribute(`href`)||``;if(!t||t===`#`||t.startsWith(`javascript:`))return!1}catch{return!1}let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>=3&&t.length<=220}),t=null,n=0;for(let i of e){let e=i.textContent.replace(/\s+/g,` `).toLowerCase(),a=0;for(let t of r)e.includes(t)&&a++;let o=a/r.length;o>n&&o>=.5&&(n=o,t=i)}if(t)return t.closest(`article`)||t.closest(`.views-row`)||t}let c=document.querySelectorAll(`section, article, .card, [class*='feature'], [class*='service']`);for(let e of c){if(Nn(e))continue;let t=e.querySelector(`h1, h2, h3, h4, h5, h6`);if(t){let r=t.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(r.includes(n)||n.includes(r))return e}}let l=document.querySelectorAll(`li, strong, blockquote, dt`);for(let e of l){if(Nn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e.tagName===`STRONG`&&e.parentElement?.tagName===`LI`?e.parentElement:e}let u=Array.from(document.querySelectorAll(`a[href]`)).filter(e=>!Nn(e));u.sort((e,t)=>(e.textContent||``).trim().length-(t.textContent||``).trim().length);for(let e of u){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<500)return e}let d=document.querySelectorAll(`p`);for(let e of d){if(Nn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function pr(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;dr();let r=document.querySelectorAll(`.fe-highlight-section`);for(let t of r)t!==e&&(t.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`),t.classList.add(`fe-highlight-exiting`),setTimeout(()=>t.classList.remove(`fe-highlight-exiting`),300));if(e.classList.remove(`fe-highlight-exiting`),e.classList.add(`fe-highlight-section`),t?e.classList.add(`fe-highlight-speaking`):e.classList.remove(`fe-highlight-speaking`),n)try{e.scrollIntoView({behavior:`smooth`,block:`center`})}catch{try{e.scrollIntoView(!0)}catch{}}}function mr(){typeof document>`u`||(document.querySelectorAll(`.fe-highlight-section, .fe-highlight-exiting`).forEach(e=>e.classList.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`)),jn())}function hr(e){if(typeof window>`u`)return e;try{let t=new URL(String(e).trim(),window.location.href);return!/^https?:$/i.test(t.protocol)||t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href}catch{return e}}async function gr(e){if(typeof window>`u`)return!1;try{let t=new URL(String(e).trim(),window.location.href),n=t.origin===window.location.origin?t.href:new URL(t.pathname+t.search+t.hash,window.location.origin).href;return(await fetch(n,{method:`HEAD`,mode:`same-origin`,cache:`no-store`})).ok}catch{return!1}}async function _r(e,{siteId:t,apiBaseUrl:n}){if(!e)return{allowed:!1,correctedUrl:null};let r=!1;try{r=!!Zn()}catch{r=!1}let i=async()=>({allowed:r?!1:await gr(e),correctedUrl:null});if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),i();let a=String(n).replace(/\/$/,``),o=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let e=await(await fetch(`${a}/api/widget/navigate-allowed?${o.toString()}`)).json().catch(()=>({}));return e.success&&e.allowed?{allowed:!0,correctedUrl:e.correctedUrl||null}:i()}catch(e){return console.warn(`[FlowEngage] navigate-allowed check failed:`,e?.message),i()}}function vr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(In,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function yr(e,{skipPushState:t=!1,isBack:n=!1}={}){if(typeof window>`u`||typeof document>`u`)return!1;try{if(new URL(e,window.location.href).origin!==window.location.origin)return!1}catch{return!1}cr();let r=new AbortController,i=setTimeout(()=>r.abort(),8e3);try{let a=await fetch(e,{credentials:`same-origin`,cache:`no-store`,signal:r.signal});if(clearTimeout(i),!a.ok)return lr(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return lr(),!1;try{typeof window.Drupal?.detachBehaviors==`function`&&window.Drupal.detachBehaviors(document.body,window.drupalSettings)}catch{}document.querySelectorAll(`script`).forEach(e=>{e.setAttribute(`data-fe-original`,`true`)}),Array.from(document.body.children).forEach(e=>{if(e===c)return;let t=e.tagName?.toUpperCase();t===`AUDIO`||t===`VIDEO`||e.remove()}),$n();let l=new Set(Array.from(document.querySelectorAll(`link[rel='stylesheet']`)).map(e=>{try{return new URL(e.getAttribute(`href`)||``,window.location.href).href}catch{return``}}));for(let t of Array.from(s.head.querySelectorAll(`link[rel='stylesheet']`))){let n=t.getAttribute(`href`);if(!n)continue;let r;try{r=new URL(n,e).href}catch{continue}if(l.has(r))continue;let i=document.createElement(`link`);i.rel=`stylesheet`,i.href=r,i.setAttribute(Qn,`true`),t.media&&(i.media=t.media),document.head.appendChild(i)}for(let e of Array.from(s.head.querySelectorAll(`style`))){if(!e.textContent.trim())continue;let t=e.textContent.trim().slice(0,120);if(Array.from(document.head.querySelectorAll(`style:not([data-fe-swap-css])`)).some(e=>e.textContent.trim().slice(0,120)===t))continue;let n=document.createElement(`style`);n.textContent=e.textContent,n.setAttribute(Qn,`true`),document.head.appendChild(n)}Array.from(s.body.children).forEach(e=>{e.tagName?.toUpperCase()!==`SCRIPT`&&document.body.insertBefore(document.importNode(e,!0),c)});let u=document.querySelectorAll(`script:not([data-fe-replayed])`);for(let e of u){if(e.closest(`#flowengage-root, .flowengage-shell`)||e.hasAttribute(`data-fe-original`)||e.hasAttribute(`data-fe-replayed`))continue;let t=e.getAttribute(`src`),n=e.getAttribute(`type`)||``;if(!(n&&n!==`text/javascript`&&n!==``&&!n.includes(`drupal-ajax`))){if(n.includes(`drupal-ajax`)){e.setAttribute(`data-fe-replayed`,`true`);try{let t=JSON.parse(e.textContent);if(Array.isArray(t))for(let e of t){if((e.command===`insert`||e.command===`insert_new_content`)&&e.selector&&e.data){let t=document.querySelector(e.selector);t&&(e.method===`replaceWith`?t.outerHTML=e.data:e.method===`html`||e.method===`replace`?t.innerHTML=e.data:e.method===`append`?t.insertAdjacentHTML(`beforeend`,e.data):e.method===`prepend`?t.insertAdjacentHTML(`afterbegin`,e.data):t.innerHTML=e.data,Fn(`trySpaNavigate: BigPipe replacement →`,e.selector))}if(e.command===`settings`&&e.settings)try{window.drupalSettings&&typeof window.drupalSettings==`object`&&Object.assign(window.drupalSettings,e.settings)}catch{}}}catch(e){Fn(`trySpaNavigate: BigPipe parse error:`,e.message)}continue}if(!t&&e.textContent.trim()){let t=e.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(t)){e.setAttribute(`data-fe-replayed`,`true`);continue}let n=document.createElement(`script`);n.textContent=t,n.setAttribute(`data-fe-replayed`,`true`),e.parentNode.replaceChild(n,e)}}}try{for(let e of Array.from(s.querySelectorAll(`script`))){let t=(e.textContent||``).match(/drupalSettings\s*[,=]\s*(\{[\s\S]*?\})\s*[;)]/);if(t){try{let e=JSON.parse(t[1]);window.drupalSettings&&typeof window.drupalSettings==`object`?Object.assign(window.drupalSettings,e):window.drupalSettings=e,Fn(`trySpaNavigate: updated drupalSettings from new page`)}catch{}break}}}catch{}let d=window.location.assign.bind(window.location),f=window.location.replace.bind(window.location),p=!0;window.location.assign=e=>{if(p){Fn(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){Fn(`trySpaNavigate: blocked location.replace from replayed script:`,e);return}return f(e)};function m(e){let t=e.toLowerCase();return!!(/\/jquery[.\-\/]/.test(t)||/\/jquery\.min\.js/.test(t)||/\/jquery-once/.test(t)||/\/jquery\.once/.test(t)||/\/jquery\.ui[\./]/.test(t)||/\/jqueryui/.test(t)||/\/core\/misc\//.test(t)||/\/core\/modules\//.test(t)||/\/misc\/drupal\.js/.test(t)||/\/lodash[.\-\/]/.test(t)||/\/underscore[.\-\/]/.test(t)||/\/backbone[.\-\/]/.test(t)||/\/modernizr[.\-\/]/.test(t)||/\/popper[.\-\/]/.test(t)||/\/bootstrap\.min\.js/.test(t)||/\/bootstrap\.bundle/.test(t))}let h=new Set(Array.from(document.querySelectorAll(`script[src]`)).map(e=>{try{return new URL(e.getAttribute(`src`)||``,window.location.href).href}catch{return``}}));function g(t,n){let r=t.getAttribute(`src`)||``;if(r.includes(`flowengage`))return;let i=document.createElement(`script`);if(r){let n;try{n=new URL(r,e).href}catch{return}if(h.has(n)){if(m(n))return;Fn(`trySpaNavigate: re-running theme/custom script:`,n)}h.add(n),i.src=n,i.async=t.async,i.defer=t.defer}else if(t.textContent.trim()){let e=t.textContent;if(/window\.location\s*[.=]|location\s*\.\s*(href|assign|replace|reload)\s*[=(]/i.test(e)){Fn(`trySpaNavigate: skipping inline script with navigation:`,e.slice(0,120));return}if(/^\s*\(?\s*(?:window\.)?drupalSettings\s*[,=]/.test(e))return;i.textContent=e}else return;let a=t.getAttribute(`type`);a&&a!==`text/javascript`&&a!==``&&(i.type=a),n.parentNode.insertBefore(i,n)}for(let e of Array.from(s.head.querySelectorAll(`script`)))g(e,c);for(let e of Array.from(s.body.querySelectorAll(`script`)))g(e,c);try{typeof window.Drupal?.attachBehaviors==`function`&&window.Drupal.attachBehaviors(document.body,window.drupalSettings)}catch{}try{typeof window.jQuery==`function`&&(window.jQuery(document).trigger(`ready`),window.dispatchEvent(new Event(`resize`)))}catch{}try{document.dispatchEvent(new Event(`DOMContentLoaded`,{bubbles:!0,cancelable:!1}))}catch{}try{window.dispatchEvent(new Event(`load`))}catch{}try{let e=document.querySelectorAll(`iframe:not([data-fe-skip-reload])`);for(let t of e){if(t.closest(`#flowengage-root, .flowengage-shell`))continue;let e=t.getAttribute(`src`)||t.src;e&&e!==`about:blank`&&!e.startsWith(`javascript:`)&&(Fn(`trySpaNavigate: reloading iframe:`,e),t.src=e)}}catch{}try{let e=document.querySelectorAll(`.g-recaptcha, [data-sitekey]`);if(e.length>0){if(typeof window.grecaptcha?.render==`function`){for(let t of e)if(!t.closest(`#flowengage-root`)){t.innerHTML=``;try{window.grecaptcha.render(t,{sitekey:t.getAttribute(`data-sitekey`)||``}),Fn(`trySpaNavigate: re-rendered reCAPTCHA`)}catch{}}}else if(!document.querySelector(`script[src*='recaptcha']`)){let e=document.createElement(`script`);e.src=`https://www.google.com/recaptcha/api.js?render=explicit`,e.async=!0,document.head.appendChild(e),Fn(`trySpaNavigate: injected reCAPTCHA script`)}}}catch{}if(setTimeout(()=>{p=!1,window.location.assign=d,window.location.replace=f},2e3),s.title&&(document.title=s.title),!t)try{history.pushState({flowengageSpa:!0},``,e)}catch{}if(Kn(),Jn(),n){try{nr()}catch{}try{ar()}catch{}}else window.scrollTo(0,0);lr(),or(e);try{sessionStorage.removeItem(In)}catch{}try{sessionStorage.removeItem(Rn)}catch{}try{Gn=new URL(e,window.location.origin).pathname}catch{}return Fn(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),lr(),!1}}function br(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Rn,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function xr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(Rn)}catch{}}function Sr(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(Rn)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(Rn)}catch{}return e.voiceWasActive?Date.now()-e.ts>zn?(Fn(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(Fn(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}function Cr(){if(typeof document>`u`)return!1;let e=/(^|\W)(404|page not found|not found|page (?:doesn'?t|does not) exist|no longer exists|couldn'?t find (?:this|that|the) page|error 404|oops[!,. ].*(?:not found|doesn'?t exist))(\W|$)/i,t=(document.title||``).trim();if(t&&e.test(t))return!0;let n=document.querySelector(`main, [role="main"], #content, .content`)||document.body;if(n){let t=n.querySelectorAll(`h1, h2`);for(let n of t){let t=(n.textContent||``).replace(/\s+/g,` `).trim();if(t&&t.length<80&&e.test(t))return!0}}return!1}async function wr(e,t={}){if(typeof window>`u`)return{navigated:!1};let{sectionText:n,voiceActive:r=!1}=t;try{let t=hr(e),i=new URL(t,window.location.origin);if(i.hash&&i.pathname===window.location.pathname){let e=document.getElementById(i.hash.slice(1));if(e)return e.scrollIntoView({behavior:`smooth`,block:`start`}),{navigated:!0}}if(i.pathname===window.location.pathname&&i.search===window.location.search&&!i.hash)return{navigated:!1,reason:`already-on-page`};let a=i.pathname+i.search+i.hash,o=window.next?.router;if(o?.push)return new Promise(e=>{let t=()=>{o.events?.off(`routeChangeComplete`,t),e({navigated:!0})};o.events?.on(`routeChangeComplete`,t),o.push(a),setTimeout(t,5e3)});if(window.__NEXT_ROUTER__?.push)return window.__NEXT_ROUTER__.push(a),{navigated:!0};if(Zn()){n&&vr(n);let e=window.location.href;try{window.history.pushState({},``,i.href),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}if(await new Promise(e=>setTimeout(e,400)),Cr()){try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return n&&vr(n),r||ke(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&vr(n),r||ke(),window.location.assign(i.href),{navigated:!0}}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&vr(n);try{window.location.href=hr(e)}catch{window.location.href=e}return{navigated:!0}}}var Tr=!1,Er=null;function Dr(e){Er=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!Tr&&(Tr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!Er)return;let t=e.target.closest?.(`a[href]`);if(!t||t.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`))return;let n=t.getAttribute(`href`)||``;if(!n||n===`#`||n.startsWith(`javascript:`)||n.startsWith(`mailto:`)||n.startsWith(`tel:`)||t.hasAttribute(`download`)||t.target===`_blank`||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;let r;try{if(r=new URL(n,window.location.href),r.origin!==window.location.origin)return}catch{return}if(!(r.pathname===window.location.pathname&&r.hash)&&!(r.pathname===window.location.pathname&&r.search===window.location.search&&!r.hash)){Fn(`voice-link-hook: saving state before navigation →`,r.href);try{Er.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(Er&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){Fn(`voice-form-hook: saving state before form submit`);try{Er.onBeforeNavigate()}catch{}}},!0)))}function Or(){Er=null,Fn(`voice-nav-hooks: deactivated`)}var kr=s((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),B=s(((e,t)=>{t.exports=kr()}))(),Ar=e=>!e||typeof e!=`string`?e:e.replace(/<human_assistance_request[^>]*>/gi,``).replace(/<\/human_assistance_request>/gi,``).replace(/<navigate[^>]*\/>/gi,``).replace(/<navigate[^>]*>[\s\S]*?<\/navigate>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*>[\s\S]*?<\/[a-z]+(?:_[a-z]+)+>/gi,``).replace(/<[a-z]+(?:_[a-z]+)+[^>]*\/>/gi,``).trim(),jr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:Ar(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function Mr(e){if(!e||typeof e!=`string`)return null;let t=e.match(/<navigate([^>]*?)(?:\/>|>[\s\S]*?<\/navigate>)/i);if(!t)return null;let n=t[1],r=n.match(/url=["']([^"']+)["']/i);if(!r)return null;let i=n.match(/section=["']([^"']+)["']/i)||n.match(/highlight=["']([^"']+)["']/i);return{url:r[1].trim(),section:i?.[1]?.trim()||null}}var Nr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,Pr=(e={})=>{if(!e?.candidate)return null;if(typeof e.candidate==`object`)return e.candidate;let t=e.sdpMid!==void 0&&e.sdpMid!==null&&e.sdpMid!==``,n=e.sdpMLineIndex!==void 0&&e.sdpMLineIndex!==null;return!t&&!n?null:{candidate:e.candidate,...t?{sdpMid:e.sdpMid}:{},...n?{sdpMLineIndex:e.sdpMLineIndex}:{}}},Fr=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},Ir=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Lr({siteId:e,config:t,children:n,language:r=`en`}){let i=(0,b.useMemo)(()=>e?{...t||{},siteId:e}:t||null,[e,t]),[a,o]=(0,b.useState)(0),[s,c]=(0,b.useState)(`booting`),[l,u]=(0,b.useState)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(``),[h,g]=(0,b.useState)([]),_=(0,b.useCallback)(()=>{g(e=>[...e,{id:`nav-fail-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`I couldn't find that page on our site — could you tell me more about what you're looking for?`,timestamp:new Date().toISOString()}])},[]),v=(0,b.useCallback)(()=>{g(e=>[...e,{id:`nav-already-${e.length}-${Math.random().toString(36).slice(2,8)}`,sender:`bot`,message:`Looks like you're already on this page!`,timestamp:new Date().toISOString()}])},[]),[y,x]=(0,b.useState)(k().isOpen),[C,w]=(0,b.useState)(k().activeScreen),[ee,T]=(0,b.useState)(k().isHumanHandled),[E,ie]=(0,b.useState)(k().agentName),[ce,D]=(0,b.useState)(k().agentHeadshot),[O,le]=(0,b.useState)(()=>pe(i?.siteId)),[he,ge]=(0,b.useState)(!1),[_e,ye]=(0,b.useState)(!1),[j,be]=(0,b.useState)(`idle`),[xe,Se]=(0,b.useState)(!1),[Ce,we]=(0,b.useState)(!1),[Te,De]=(0,b.useState)(``),[Oe,ke]=(0,b.useState)(!1),[Ae,je]=(0,b.useState)(0),[Me,Ne]=(0,b.useState)(0),[Pe,Fe]=(0,b.useState)(!1),[M,ze]=(0,b.useState)(null),[Be,Ve]=(0,b.useState)(null),[He,N]=(0,b.useState)(`idle`),[Ue,We]=(0,b.useState)(null),[Ge,Ke]=(0,b.useState)(!1),[qe,Je]=(0,b.useState)(``),[Ye,Xe]=(0,b.useState)(!1),Ze=(0,b.useRef)(null),P=(0,b.useRef)(null),Qe=(0,b.useRef)(``),$e=(0,b.useRef)(!1),et=(0,b.useRef)(null),F=(0,b.useRef)(null),tt=(0,b.useRef)(null),nt=(0,b.useRef)(null),rt=(0,b.useRef)(null),it=(0,b.useRef)(null),at=(0,b.useRef)(null),ot=(0,b.useRef)(!1),st=(0,b.useRef)({url:null,at:0}),I=(0,b.useCallback)((e,t)=>{let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=st.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(st.current={url:n,at:Date.now()},wr(e,t))},[]),ct=(0,b.useRef)([]),L=(0,b.useRef)(null),lt=(0,b.useRef)(null),ut=(0,b.useRef)(null),dt=(0,b.useRef)(!1),ft=(0,b.useRef)(!1),pt=(0,b.useRef)(``),mt=(0,b.useRef)(null),ht=(0,b.useRef)(null),gt=(0,b.useRef)([]),_t=(0,b.useRef)(0),vt=(0,b.useRef)(E),yt=(0,b.useRef)([]),R=(0,b.useRef)(!1),bt=(0,b.useRef)(!1),xt=(0,b.useRef)(i),St=(0,b.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),Ct=(0,b.useCallback)((e={})=>{let t=!!e.is_human_handled;return T(t),t?(w(`agent`),e.agent_info?.name&&ie(e.agent_info.name),e.agent_info?.headshot&&D(e.agent_info.headshot),t):(w(`ai`),t)},[]),wt=(0,b.useMemo)(()=>{let e=d?.widgetSettings?.call?.maxDurationSeconds??i?.widgetSettings?.call?.maxDurationSeconds??i?.callMaxDurationSeconds,t=Number(e);return Number.isFinite(t)&&t>0?t:ne},[i,d]);(0,b.useEffect)(()=>{F.current=M},[M]),(0,b.useEffect)(()=>{vt.current=E},[E]),(0,b.useEffect)(()=>{bt.current=Oe},[Oe]),(0,b.useEffect)(()=>{xt.current=i},[i]);let Tt=()=>{Je(``)},Et=(0,b.useCallback)(()=>{ut.current&&=(window.clearTimeout(ut.current),null)},[]),Dt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return le(t),me(t,i?.siteId),t};(0,b.useEffect)(()=>{let e=i?.siteId;e&&le(pe(e))},[i?.siteId]);let Ot=(e=`unspecified`)=>{let t=L.current||it.current?.callId,n=_t.current,r=mt.current;if(mt.current=null,_t.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=gt.current;if(gt.current=[],e.length>0&&t&&P.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;P.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}};try{r.stop()}catch{r.onstop=null,gt.current=[]}}else if(r&&r.state===`inactive`){let e=gt.current;if(gt.current=[],e.length>0&&t&&P.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;P.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else gt.current=[];if(ht.current){try{ht.current.close()}catch{}ht.current=null}tt.current&&=(tt.current.close(),null),nt.current&&=(nt.current.getTracks().forEach(e=>e.stop()),null),rt.current&&=(rt.current.srcObject=null,rt.current.remove(),null),Et(),it.current=null,ct.current=[],L.current=null,lt.current=null,dt.current=!1,Ke(!1),ze(null),Ve(null),N(`idle`),We(null)},kt=(e=new Date().toISOString())=>{let t=Ze.current,n=L.current||it.current?.callId;if(!(!t?.connected||!n||dt.current)){dt.current=!0,t.emit(`call:connected`,{callId:n,chatId:Qe.current,connectedAt:e});try{let e=nt.current,t=rt.current?.srcObject;if(e&&t&&!mt.current){gt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);ht.current=n;let r=n.createMediaStreamDestination();n.createMediaStreamSource(e).connect(r),n.createMediaStreamSource(t).connect(r);let i=window.MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:`audio/mp4`,a=new window.MediaRecorder(r.stream,{mimeType:i});a.ondataavailable=e=>{e.data&&e.data.size>0&>.current.push(e.data)},mt.current=a,_t.current=Date.now(),a.start(1e3),setTimeout(()=>{try{if(!window.speechSynthesis)return;let e=new SpeechSynthesisUtterance(`This call is being recorded for quality and training purposes.`);if(e.rate=.95,e.pitch=1,e.volume=1,window.MediaStreamTrackGenerator||window.AudioContext)try{let t=n.createMediaStreamDestination();e.onstart=()=>{try{let i=document.createElement(`audio`);i.style.display=`none`,i.srcObject=t.stream,document.body.appendChild(i),i.play().catch(()=>{});let a=n.createMediaStreamSource(t.stream);a.connect(r),e.onend=()=>{try{a.disconnect()}catch{}try{i.remove()}catch{}}}catch{}}}catch{}window.speechSynthesis.speak(e)}catch{}},200)}}catch{}}},At=(e={})=>{if(!e.callId)return;let t=lt.current===e.callId,n=L.current===e.callId,r=F.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Et(),ze(null),t||n){L.current=e.callId,Ve(e.callId),N(e=>e===`connected`?e:`connecting`),x(!0);return}N(`idle`)}},jt=(e={})=>{if(!e.callId)return;let t=lt.current===e.callId,n=L.current===e.callId,r=F.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Et(),n){Ot();return}lt.current=null,it.current=null,ct.current=[],ze(null),N(`idle`)}},Mt=async(e={})=>{let t=tt.current,n=Ze.current,r=e.sdpOffer||e.offer?.sdp;if(!t||!n?.connected||!r||!e.callId){console.log(`[FlowEngageProvider] deferring remote offer until peer/socket ready`,{callId:e.callId,chatId:Qe.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),it.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),ct.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Qe.current,queuedCount:ct.current.length});for(let e of ct.current)await t.addIceCandidate(new RTCIceCandidate(e));ct.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:Qe.current})};(0,b.useEffect)(()=>{A({isOpen:y,activeScreen:C,isHumanHandled:ee,agentName:E,agentHeadshot:ce})},[y,C,ee,E,ce]),(0,b.useEffect)(()=>{let e=!0;return(async()=>{Xe(!0);try{let t=S(i),n=await Le(t);if(!e)return;let a=t.siteId,o=ue(a),s=ve(a),l=``;try{let e=$e.current,r=et.current;if($e.current=!1,et.current=null,l=(await Ie({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||ae(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);oe(),fe(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||se(),fe(a,l)}Qe.current=l;let u=Re({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});P.current=u,f({...n,apiBaseUrl:t.apiBaseUrl}),m(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,p=Cn({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});Ze.current=p,p.on(`connect`,async()=>{be(`connected`);let e=Qe.current;if(e&&P.current)try{Ct(await P.current.checkHumanHandled(e))}catch{}}),p.on(`disconnect`,()=>{be(`disconnected`)}),p.on(`aiTyping`,()=>{ye(!0)}),p.on(`ai:typing`,()=>{ye(!0)}),p.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:Ar(t.message)};ye(!1),ge(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&g(e=>[...e.filter(e=>!e.isPending),{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}])}),p.on(`conversationStarted`,e=>{e?.message&&g(t=>[...t,{id:`system-start-${Date.now()}`,sender:`system`,message:e.message,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`message:new`,e=>{let t=e.message||e,n={...t,message:Ar(t.message)};ye(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&((n.sender===`agent`||n.agent_name||n.sender===`ai`||n.sender===`bot`)&&ge(!1),g(e=>n.sender===`bot`||n.sender===`ai`?[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]:e.some(e=>e.id===n.messageId||e.sender===n.sender&&e.message===n.message&&e.isPending)?e.map(e=>e.sender===n.sender&&e.message===n.message&&e.isPending?{...n,isPending:!1,id:n.messageId||e.id}:e):[...e,{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}]),(n.sender===`agent`||n.agent_name)&&(T(!0),w(`agent`),ie(Fr([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&D(n.sender_headshot),x(!0),je(e=>e+1)))});let h=(e={})=>{let t=Fr([e.agent?.name,e.agentName,e.agent_name,vt.current],d);T(!0),w(`agent`),ie(t),D(e.agent?.headshot||null),x(!0),je(e=>e+1),g(e=>Ir(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},y=(e={})=>{let t=Fr([e.agent?.name,e.agentName,e.agent_name,vt.current],d);T(!1),w(`ai`),g(e=>Ir(e,{id:`agent-left-${Date.now()}`,sender:`system`,message:`${t} has left the chat.`,timestamp:new Date().toISOString(),isPending:!1}))};p.on(`agent:joined`,h),p.on(`agentJoined`,h),p.on(`agent:left`,y),p.on(`agentLeft`,y),p.on(`conversationEnded`,e=>{Fe(!0);let t=e?.message||`This conversation has ended. Thank you for reaching out!`;g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:t,timestamp:new Date().toISOString(),isPending:!1}])}),p.on(`chat:history_update`,e=>{let t=jr(e.chat_history||[]);g(t),t.length===0&&(Fe(!1),T(!1),w(`ai`),ye(!1),ge(!1))}),p.on(`conversation:reset`,()=>{g([]),Fe(!1),T(!1),w(`ai`),ye(!1),ge(!1)}),p.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),Ne(e=>e+1),x(!0),je(e=>e+1)}),p.on(`typing:start`,e=>{e.sender===`agent`&&ge(!0)}),p.on(`typing:stop`,e=>{e.sender===`agent`&&ge(!1)}),p.on(`call:incoming`,(e={})=>{let t=Fr([e.agentName,e.ownerName,e.agent?.name,vt.current],`Agent`);Tt(),Et(),dt.current=!1,ze({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),ie(e=>Fr([t,e],`Agent`)),N(`incoming`),We(null),x(!0)}),p.on(`call:offer`,async(e={})=>{it.current=e;try{await Mt(e)}catch(e){console.error(`[FlowEngageProvider] failed to apply remote offer`,e)}}),p.on(`call:ice-candidate-from-agent`,async(e={})=>{if(e.candidate)try{let t=Pr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!tt.current||!tt.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Qe.current,queueSize:ct.current.length+1}),ct.current.push(t);return}await tt.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),p.on(`call:ended`,()=>{Tt(),Ot(`socket:call_ended`)}),p.on(`call:accepted`,(e={})=>{At(e)}),p.on(`call:accepted_by_other`,(e={})=>{At(e)}),p.on(`call:rejected`,(e={})=>{jt(e)}),p.on(`call:missed`,(e={})=>{jt(e)}),p.on(`call:failed`,(e={})=>{jt(e)}),p.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=lt.current===e.callId,n=L.current===e.callId,r=it.current?.callId===e.callId,i=F.current?.callId===e.callId;if(!t&&!n&&!r){i&&(ze(null),N(`idle`));return}dt.current=!0,lt.current=null,L.current=e.callId,Ve(e.callId),ze(null),N(`connected`),We(e.connectedAt||new Date().toISOString()),x(!0)}),p.on(`call:unavailable`,(e={})=>{Ot(`socket:call_unavailable`),Je(Nr(e,`This visitor is not available for a call right now.`)),x(!0)}),p.on(`call:error`,(e={})=>{Ot(`socket:call_error`),Je(Nr(e,`We couldn't connect the call right now.`)),x(!0)}),p.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&I(e,{voiceActive:bt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?_():r===`already-on-page`&&v();return}let i=t||n;!i||!bt.current||setTimeout(()=>{let e=fr(null,i);e&&pr(e)},300)})}),p.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=fr(e||null,t||null);n&&pr(n)}),p.on(`visitor:clear_highlight`,()=>{mr()}),St.current=wn({socket:p,chatId:l});let b=await u.loadHistory(l,r);if(!e)return;g(jr(b.chat_history||[])),T(!!b.is_human_handled),w(b.is_human_handled?`agent`:C);let ee=b?.visitor_email||b?.visitorEmail;if(ee&&String(ee).trim()&&Dt(String(ee).trim()),await new Promise(e=>setTimeout(e,500)),!e)return;c(`ready`)}catch(t){if(!e)return;u(t),c(`error`)}finally{e&&Xe(!1)}})(),()=>{e=!1,St.current?.cleanup?.(),Ot(),Ze.current?.disconnect()}},[i,r,a]),(0,b.useEffect)(()=>()=>{if(Oe&&!R.current&&yt.current.length>0){let e=Qe.current,t=yt.current,n=P.current;n&&e&&t.length>0&&(console.log(`[FlowEngageProvider] safety-net: syncing voice transcript on unmount`),n.beaconSyncVoice(e,t)||n.syncVoice(e,t).catch(()=>{}),R.current=!0)}},[Oe,d]);let Nt=(0,b.useRef)(null);(0,b.useEffect)(()=>{let e=P.current;!e||!p||Nt.current!==y&&(y&&Nt.current!==null?e.updateChatStatus(p,`open`).catch(()=>{}):Nt.current===!0&&e.updateChatStatus(p,`widget_closed`).catch(()=>{}),Nt.current=y)},[y,p]),(0,b.useEffect)(()=>{let e=()=>{let e=Qe.current,t=P.current;!e||!t||typeof navigator>`u`||t.beaconWidgetClosed?.(e)||t.updateChatStatus(e,`widget_closed`).catch(()=>{})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]);let Pt=async()=>{if(!(!M?.callId||!P.current||!Ze.current||!p)){Tt(),lt.current=M.callId,Et();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});nt.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await P.current.getIceServersConfig();e?.data?.iceServers?.length&&(t=e.data.iceServers)}catch(e){console.warn(`[FlowEngageProvider] ice-config fetch failed, using STUN default`,e)}let n=new RTCPeerConnection({iceServers:t});tt.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();N(`connected`),We(t=>t||e),kt(e);return}if(e===`connecting`){N(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Ot(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();N(`connected`),We(t=>t||e),kt(e);return}if(e===`checking`||e===`new`){N(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Ot(`peer:ice_${e}`)},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!Ze.current?.connected)return;let t=e.candidate;Ze.current.emit(`call:ice-candidate`,{callId:M.callId,candidate:t.candidate,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex,chatId:p,from:`customer`})},n.ontrack=e=>{let[t]=e.streams||[],[n]=t?.getAudioTracks?.()||[];if(!rt.current){let e=document.createElement(`audio`);e.id=`flowengage-remote-audio`,e.autoplay=!0,e.playsInline=!0,e.onplay=()=>{},e.onpause=()=>{},e.onended=()=>{},e.onerror=e=>{},rt.current=e,document.body.appendChild(e)}rt.current.srcObject=e.streams[0];let r=M?.callId,i=r&&(lt.current===r||L.current===r);if(!dt.current&&i){let e=new Date().toISOString();N(`connected`),We(t=>t||e),L.current=r,Ve(r),kt(e)}rt.current.srcObject=t||null;let a=rt.current.play?.();a?.catch&&a.catch(e=>{})};let r=it.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||M.callId,chatId:p}),await Mt({...r,callId:r.callId||M.callId})),await P.current.acceptCall(M.callId,p),Ze.current?.emit(`call:accepted`,{callId:M.callId,chatId:p}),L.current=M.callId,Ve(M.callId),N(e=>e===`connected`||dt.current?`connected`:`connecting`),ze(null),x(!0)}catch(e){if(lt.current=null,Ot(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){Je(Nr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await P.current.rejectCall(M.callId,p)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}Je(`Microphone access was denied. Please allow microphone access to accept the call.`);return}Je(`We couldn't connect the call right now. Please try again.`)}}},Ft=async()=>{if(!M?.callId||!P.current||!p){Ot(`reject_call_without_server_context`);return}let e=M.callId;Et(),Tt(),Ze.current?.emit(`call:rejected`,{callId:e,chatId:p,reason:`visitor_declined`});try{await P.current.rejectCall(e,p)}catch(e){Je(Nr(e,`We couldn't decline the call cleanly.`))}finally{Ot(`reject_call_finally`)}},It=(0,b.useRef)(Ft);It.current=Ft,(0,b.useEffect)(()=>{if(!M?.callId||Be){Et();return}let e=M.callId;return Et(),ut.current=window.setTimeout(()=>{F.current?.callId===e&<.current!==e&&L.current!==e&&It.current()},re),()=>{ut.current&&=(window.clearTimeout(ut.current),null)}},[Be,Et,M?.callId]);let Lt=async()=>{if(!Be||!P.current||!p){Ot(`end_call_without_server_context`);return}Tt();try{await P.current.endWebRTCCall(Be,p)}catch(e){Je(Nr(e,`The call ended locally, but the server could not be updated.`))}finally{Ot(`end_call_finally`)}},Rt=()=>{let e=nt.current?.getAudioTracks?.()||[],t=tt.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!Ge;n.forEach(e=>{e.enabled=!r}),Ke(r)},zt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(x(!0),!(!t||!P.current||!p||typeof window>`u`)){try{await P.current.trackVisitor({chatId:p,currentPagePath:window.location.pathname||`/`})}catch{}try{await P.current.updateChatStatus(p,`open`)}catch{}}},Bt=async e=>{let t=Dt(e);if(!t||!P.current||!Qe.current)return t;try{await P.current.trackVisitor({chatId:Qe.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},Vt=()=>{!p||!Ze.current?.connected||ft.current||(ft.current=!0,Ze.current.emit(`typing:start`,{chatId:p,sender:`user`}))},Ht=()=>{!p||!Ze.current?.connected||!ft.current||(ft.current=!1,Ze.current.emit(`typing:stop`,{chatId:p,sender:`user`}))},Ut=(e=``)=>{let t=typeof e==`string`?e:``;!p||!Ze.current?.connected||t!==``&&pt.current===t||(pt.current=t,Ze.current.emit(`typing:update`,{chatId:p,sender:`user`,text:t}))};function Wt(){if(typeof document>`u`)return null;try{let e=(document.querySelector(`main`)||document.querySelector(`[role='main']`)||document.querySelector(`article`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);e.querySelectorAll(`nav, footer, header, aside, script, style, noscript, #flowengage-root, .flowengage-shell, .flowengage-widget-root, [id*='flowengage'], [class*='flowengage']`).forEach(e=>e.remove());let t=e.textContent.replace(/\s+/g,` `).trim();return t.length>0?t.substring(0,3e3):null}catch{return null}}let Gt=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!P.current||!p||s!==`ready`||Pe)return;Ht(),ot.current=!1;let o=/^\s*(yes|yeah|sure|ok|okay|go ahead|take me(?: there)?(?!\s+\w)|navigate(?!\s+(?:me\s+)?to\s+\w)|yep|absolutely|please do|do it|let'?s go|go there|show me(?!\s+(?:the|a|an)\s+\w)|go to it|bring me there|navigate me there)\b/i,c=/^\s*(?:yes|yeah|sure|ok|okay|yep|absolutely)\s+(?!(?:please|do\s+it|let'?s|that|this|there|it|thanks|go|cool|great|perfect|sounds|alright|proceed)\b)\w/i,l=/\b(take me|navigate|go to|show me|bring me|open|go there|navigate to|take me to|let'?s go to)\b/i;if(at.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=at.current;at.current=null,ot.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),I(e,{voiceActive:bt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t||!bt.current||setTimeout(()=>{let e=fr(null,t);e&&pr(e)},300)})}else o.test(a)||(at.current=null);let d=`pending-user-${Date.now()}`,f={id:d,sender:`user`,message:e,timestamp:new Date().toISOString(),isPending:!0,type:i?.type||`text`,metadata:i?.metadata||void 0,...n||{}};g(e=>[...e,f]);let m=ee;if(m)try{m=Ct(await P.current.checkHumanHandled(p))}catch{}if(m&&Ze.current?.connected){Ze.current.emit(`customer:message`,{chatId:p,content:e,sender:`user`,email:O||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}Se(!0);try{let o=await P.current.sendAiMessage(p,e,r,t,{...n||{},...O?{email:O}:{}},{...i,currentPageUrl:typeof window<`u`?window.location.href:void 0,currentPageTitle:typeof window<`u`?document.title:void 0,currentPagePath:typeof window<`u`?window.location.pathname:void 0,currentPageContent:Wt()||void 0}),s=o.chat_history||[];if(console.log(`[FWH Nav Debug] API response fields:`,{has_navigate:!!o.navigate,navigate:o.navigate,has_pending_navigate:!!o.pending_navigate,pending_navigate:o.pending_navigate,last_bot_msg:[...s].reverse().find(e=>e.sender===`bot`)?.message?.substring(0,80)}),o.pending_navigate?.url){let e={url:o.pending_navigate.url,section:o.pending_navigate.section||null};l.test(a)?(console.log(`[FWH Nav] Auto-navigating (intent detected) →`,e.url),I(e.url,{voiceActive:bt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?_():n===`already-on-page`&&v();return}e.section&&setTimeout(()=>{let t=fr(null,e.section);t&&pr(t)},300)})):(at.current=e,console.log(`[FWH Nav] Stored pending nav →`,at.current))}if(o.navigate?.url)if(ot.current)ot.current=!1;else{let{url:e,section:t}=o.navigate;I(e,{voiceActive:bt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t||!bt.current||setTimeout(()=>{let e=fr(null,t);e&&pr(e)},300)})}else{let e=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=Mr(e.message);t&&_r(t.url,{siteId:xt.current?.siteId,apiBaseUrl:xt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){_();return}I(n||t.url,{voiceActive:bt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?_():n===`already-on-page`&&v();return}!t.section||!bt.current||setTimeout(()=>{let e=fr(null,t.section);e&&pr(e)},300)})})}}g(jr(s)),T(!!o.is_human_handled),w(o.is_human_handled?`agent`:`ai`),ye(!1),Se(!1),await P.current.updateChatStatus(p,`messageSent`)}catch(e){g(e=>e.filter(e=>e.id!==d)),ye(!1),Se(!1),e.status===429?(we(!0),De(e.message),window.setTimeout(()=>{we(!1),De(``)},te)):u(e)}},Kt=async e=>{if(!P.current||!e)throw Error(`Upload is unavailable right now.`);return P.current.uploadChatFile(e)},qt=async e=>{if(!(!P.current||!p)){try{let t=e?`voice`:`text`;await P.current.setChatMode(p,t)}catch{}ke(e),e&&(R.current=!1)}},Jt=async e=>{if(R.current)return;if(R.current=!0,!P.current||!p||!e?.length){ke(!1);return}let t=()=>{let t=jr(e);g(e=>{if(!e.length)return t;let n=e[e.length-1],r=t[0];return n&&r&&n.sender===r.sender&&n.message===r.message?e:[...e,...t]})};try{let n=await P.current.syncVoice(p,e);if(n?.chat_history?.length)g(jr(n.chat_history));else if(n?.success)try{let e=await P.current.loadHistory(p,r);e?.chat_history?.length?g(jr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{ke(!1)}},Yt=async()=>{if(!(!P.current||!p)){Oe&&!R.current&&yt.current.length>0&&await Jt(yt.current);try{await P.current.endConversation(p)}catch{try{await P.current.updateChatStatus(p,`ended`)}catch{}}Fe(!0),g(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:`This conversation has ended. Thank you for reaching out!`,timestamp:new Date().toISOString(),isPending:!1}])}};(0,b.useEffect)(()=>{if(He!==`connected`||!Be||!p||!Ue||!wt)return;let e=new Date(Ue).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,wt*1e3-t),r=window.setTimeout(()=>{Je(`The call ended because it reached the time limit.`),Lt()},n);return()=>window.clearTimeout(r)},[Be,Ue,He,p,Lt,wt]),(0,b.useEffect)(()=>{let e=()=>{let e=Qe.current,t=P.current;if(!t||!e)return;if(bt.current&&yt.current.length>0&&Ee(),!R.current&&yt.current.length>0&&(t.beaconSyncVoice(e,yt.current)||t.syncVoice(e,yt.current).catch(()=>{}),R.current=!0),L.current){t.beaconEndWebRTCCall(L.current,e);return}let n=lt.current||F.current?.callId;n&&t.beaconCustomerUnavailable(n,e)};return window.addEventListener(`pagehide`,e),window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`pagehide`,e),window.removeEventListener(`beforeunload`,e)}},[]);let Xt=(0,b.useCallback)(()=>{let e=i?.siteId;de(e),$e.current=!0,et.current=null,Ze.current?.disconnect(),g([]),m(``),Qe.current=``,Fe(!1),T(!1),ie(null),D(null),Xe(!0),o(e=>e+1)},[i?.siteId]),Zt=(0,b.useCallback)(e=>{i?.siteId,$e.current=!1,et.current=e,Ze.current?.disconnect(),g([]),m(``),Qe.current=``,Fe(!1),T(!1),ie(null),D(null),Xe(!0),o(e=>e+1)},[i?.siteId]),Qt=(0,b.useMemo)(()=>({status:s,error:l,runtimeConfig:d,resolvedConfig:i,chatId:p,chatHistory:h,isOpen:y,activeScreen:C,isHumanHandled:ee,agentName:E,agentHeadshot:ce,visitorEmail:O,isAgentTyping:he,isAiTyping:_e,connectionStatus:j,isLoading:xe,isVoiceMode:Oe,isRateLimited:Ce,rateLimitMessage:Te,isConversationEnded:Pe,isSessionRestoring:Ye,openToChatCounter:Ae,voiceEndCounter:Me,incomingCall:M,activeCallId:Be,callConnectionState:He,callConnectedAt:Ue,isCallMuted:Ge,webRTCError:qe,language:r,historyRef:yt,hasSyncedRef:R,dismissCallError:Tt,captureVisitorEmail:Bt,startTyping:Vt,stopTyping:Ht,updateTypingDraft:Ut,notifyRouteChange:()=>St.current?.notifyRouteChange?.(),openWidget:zt,closeWidget:()=>x(!1),toggleWidget:()=>{if(y){x(!1);return}zt({notifyChatInitiated:!0})},sendMessage:Gt,uploadChatFile:Kt,setVoiceMode:qt,onMessageSync:Jt,endConversation:Yt,startNewChat:Xt,resumeChat:Zt,getVisitorChatHistory:()=>P.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>P.current?.getVisitorChatThread?.(e),acceptCall:Pt,rejectCall:Ft,endWebRTCCall:Lt,toggleCallMute:Rt}),[s,l,d,i,p,h,y,C,ee,E,ce,O,he,_e,j,xe,Oe,Ce,Te,Pe,Ye,Ae,Me,M,Be,He,Ue,Ge,qe,r,Bt,Vt,Ht,Ut,Pt,Ft,Lt,Rt,zt,Gt,Kt,qt,Jt,Yt,Xt,Tt]);return(0,B.jsx)(Tn.Provider,{value:Qt,children:n})}var Rr=(0,b.createContext)({});function zr(e){let t=(0,b.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Br=typeof window<`u`?b.useLayoutEffect:b.useEffect,Vr=(0,b.createContext)(null);function Hr(e,t){e.indexOf(t)===-1&&e.push(t)}function Ur(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Wr=(e,t,n)=>n>t?t:n<e?e:n,Gr={},Kr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function qr(e){return typeof e==`object`&&!!e}var Jr=e=>/^0[^.\s]+$/u.test(e);function Yr(e){let t;return()=>(t===void 0&&(t=e()),t)}var Xr=e=>e,Zr=(e,t)=>n=>t(e(n)),Qr=(...e)=>e.reduce(Zr),$r=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},ei=class{constructor(){this.subscriptions=[]}add(e){return Hr(this.subscriptions,e),()=>Ur(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r)if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},ti=e=>e*1e3,ni=e=>e/1e3;function ri(e,t){return t?1e3/t*e:0}var ii=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ai=1e-7,oi=12;function si(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ii(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ai&&++s<oi);return o}function ci(e,t,n,r){if(e===t&&n===r)return Xr;let i=t=>si(t,0,1,e,n);return e=>e===0||e===1?e:ii(i(e),t,r)}var li=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ui=e=>t=>1-e(1-t),di=ci(.33,1.53,.69,.99),fi=ui(di),pi=li(fi),mi=e=>e>=1?1:(e*=2)<1?.5*fi(e):.5*(2-2**(-10*(e-1))),hi=e=>1-Math.sin(Math.acos(e)),gi=ui(hi),_i=li(hi),vi=ci(.42,0,1,1),yi=ci(0,0,.58,1),bi=ci(.42,0,.58,1),xi=e=>Array.isArray(e)&&typeof e[0]!=`number`,Si=e=>Array.isArray(e)&&typeof e[0]==`number`,Ci={linear:Xr,easeIn:vi,easeInOut:bi,easeOut:yi,circIn:hi,circInOut:_i,circOut:gi,backIn:fi,backInOut:pi,backOut:di,anticipate:mi},wi=e=>typeof e==`string`,Ti=e=>{if(Si(e)){e.length;let[t,n,r,i]=e;return ci(t,n,r,i)}else if(wi(e))return Ci[e],`${e}`,Ci[e];return e},Ei=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],Di={value:null,addProjectionMetrics:null};function Oi(e,t){let n=new Set,r=new Set,i=!1,a=!1,o=new WeakSet,s={delta:0,timestamp:0,isProcessing:!1},c=0;function l(t){o.has(t)&&(u.schedule(t),e()),c++,t(s)}let u={schedule:(e,t=!1,a=!1)=>{let s=a&&i?n:r;return t&&o.add(e),s.add(e),e},cancel:e=>{r.delete(e),o.delete(e)},process:e=>{if(s=e,i){a=!0;return}i=!0;let o=n;n=r,r=o,n.forEach(l),t&&Di.value&&Di.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var ki=40;function Ai(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Ei.reduce((e,n)=>(e[n]=Oi(a,t?n:void 0),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=Gr.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,ki),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:Ei.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<Ei.length;t++)o[Ei[t]].cancel(e)},state:i,steps:o}}var{schedule:V,cancel:H,state:U,steps:ji}=Ai(typeof requestAnimationFrame<`u`?requestAnimationFrame:Xr,!0),Mi;function Ni(){Mi=void 0}var Pi={now:()=>(Mi===void 0&&Pi.set(U.isProcessing||Gr.useManualTiming?U.timestamp:performance.now()),Mi),set:e=>{Mi=e,queueMicrotask(Ni)}},Fi={layout:0,mainThread:0,waapi:0},Ii=e=>t=>typeof t==`string`&&t.startsWith(e),Li=Ii(`--`),Ri=Ii(`var(--`),zi=e=>Ri(e)?Bi.test(e.split(`/*`)[0].trim()):!1,Bi=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Vi(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Hi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Ui={...Hi,transform:e=>Wr(0,1,e)},Wi={...Hi,default:1},Gi=e=>Math.round(e*1e5)/1e5,Ki=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function qi(e){return e==null}var Ji=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Yi=(e,t)=>n=>!!(typeof n==`string`&&Ji.test(n)&&n.startsWith(e)||t&&!qi(n)&&Object.prototype.hasOwnProperty.call(n,t)),Xi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ki);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Zi=e=>Wr(0,255,e),Qi={...Hi,transform:e=>Math.round(Zi(e))},$i={test:Yi(`rgb`,`red`),parse:Xi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Qi.transform(e)+`, `+Qi.transform(t)+`, `+Qi.transform(n)+`, `+Gi(Ui.transform(r))+`)`};function ea(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var ta={test:Yi(`#`),parse:ea,transform:$i.transform},na=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ra=na(`deg`),ia=na(`%`),W=na(`px`),aa=na(`vh`),oa=na(`vw`),sa={...ia,parse:e=>ia.parse(e)/100,transform:e=>ia.transform(e*100)},ca={test:Yi(`hsl`,`hue`),parse:Xi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ia.transform(Gi(t))+`, `+ia.transform(Gi(n))+`, `+Gi(Ui.transform(r))+`)`},la={test:e=>$i.test(e)||ta.test(e)||ca.test(e),parse:e=>$i.test(e)?$i.parse(e):ca.test(e)?ca.parse(e):ta.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?$i.transform(e):ca.transform(e),getAnimatableNone:e=>{let t=la.parse(e);return t.alpha=0,la.transform(t)}},ua=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function da(e){return isNaN(e)&&typeof e==`string`&&(e.match(Ki)?.length||0)+(e.match(ua)?.length||0)>0}var fa=`number`,pa=`color`,ma=`var`,ha=`var(`,ga="${}",_a=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function va(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(_a,e=>(la.test(e)?(r.color.push(a),i.push(pa),n.push(la.parse(e))):e.startsWith(ha)?(r.var.push(a),i.push(ma),n.push(e)):(r.number.push(a),i.push(fa),n.push(parseFloat(e))),++a,ga)).split(ga),indexes:r,types:i}}function ya(e){return va(e).values}function ba({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];e===fa?i+=Gi(r[a]):e===pa?i+=la.transform(r[a]):i+=r[a]}return i}}function xa(e){return ba(va(e))}var Sa=e=>typeof e==`number`?0:la.test(e)?la.getAnimatableNone(e):e,Ca=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Sa(e);function wa(e){let t=va(e);return ba(t)(t.values.map((e,n)=>Ca(e,t.split[n])))}var Ta={test:da,parse:ya,createTransformer:xa,getAnimatableNone:wa};function Ea(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Da({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=Ea(s,r,e+1/3),a=Ea(s,r,e),o=Ea(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Oa(e,t){return n=>n>0?t:e}var ka=(e,t,n)=>e+(t-e)*n,Aa=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},ja=[ta,$i,ca],Ma=e=>ja.find(t=>t.test(e));function Na(e){let t=Ma(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===ca&&(n=Da(n)),n}var Pa=(e,t)=>{let n=Na(e),r=Na(t);if(!n||!r)return Oa(e,t);let i={...n};return e=>(i.red=Aa(n.red,r.red,e),i.green=Aa(n.green,r.green,e),i.blue=Aa(n.blue,r.blue,e),i.alpha=ka(n.alpha,r.alpha,e),$i.transform(i))},Fa=new Set([`none`,`hidden`]);function Ia(e,t){return Fa.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function La(e,t){return n=>ka(e,t,n)}function Ra(e){return typeof e==`number`?La:typeof e==`string`?zi(e)?Oa:la.test(e)?Pa:Ha:Array.isArray(e)?za:typeof e==`object`?la.test(e)?Pa:Ba:Oa}function za(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Ra(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Ba(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Ra(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Va(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]];n[i]=e.values[o]??0,r[a]++}return n}var Ha=(e,t)=>{let n=Ta.createTransformer(t),r=va(e),i=va(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?Fa.has(e)&&!i.values.length||Fa.has(t)&&!r.values.length?Ia(e,t):Qr(za(Va(r,i),i.values),n):(`${e}${t}`,Oa(e,t))};function Ua(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?ka(e,t,n):Ra(e)(e,t)}var Wa=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>V.update(t,e),stop:()=>H(t),now:()=>U.isProcessing?U.timestamp:Pi.now()}},Ga=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Ka=2e4;function qa(e){let t=0,n=e.next(t);for(;!n.done&&t<2e4;)t+=50,n=e.next(t);return t>=2e4?1/0:t}function Ja(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(qa(r),Ka);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:ni(i)}}var Ya={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function Xa(e,t){return e*Math.sqrt(1-t*t)}var Za=12;function Qa(e,t,n){let r=n;for(let n=1;n<Za;n++)r-=e(r)/t(r);return r}var $a=.001;function eo({duration:e=Ya.duration,bounce:t=Ya.bounce,velocity:n=Ya.velocity,mass:r=Ya.mass}){let i,a;Ya.maxDuration;let o=1-t;o=Wr(Ya.minDamping,Ya.maxDamping,o),e=Wr(Ya.minDuration,Ya.maxDuration,ni(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Xa(t,o),c=Math.exp(-i);return $a-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o**2*t**2*e,c=Math.exp(-r),l=Xa(t**2,o);return(-i(t)+$a>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-$a+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Qa(i,a,s);if(e=ti(e),isNaN(c))return{stiffness:Ya.stiffness,damping:Ya.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var to=[`duration`,`bounce`],no=[`stiffness`,`damping`,`mass`];function ro(e,t){return t.some(t=>e[t]!==void 0)}function io(e){let t={velocity:Ya.velocity,stiffness:Ya.stiffness,damping:Ya.damping,mass:Ya.mass,isResolvedFromDuration:!1,...e};if(!ro(e,no)&&ro(e,to))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Wr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ya.mass,stiffness:i,damping:a}}else{let n=eo({...e,velocity:0});t={...t,...n,mass:Ya.mass},t.isResolvedFromDuration=!0}return t}function ao(e=Ya.visualDuration,t=Ya.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=io({...n,velocity:-ni(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=ni(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Ya.restSpeed.granular:Ya.restSpeed.default,i||=v?Ya.restDelta.granular:Ya.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Xa(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),C=h*_*S+g*x,w=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(C*Math.sin(x*e)+w*Math.cos(x*e));else if(h===1){y=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;b=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);y=t=>{let n=Math.exp(-h*_*t),r=Math.min(e*t,300);return o-n*((m+h*_*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+h*_*g)/e,n=h*_*t-g*e,r=h*_*g-t*e;b=t=>{let i=Math.exp(-h*_*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let ee={calculatedDuration:p&&d||null,velocity:e=>ti(b(e)),next:e=>{if(!p&&h<1){let t=Math.exp(-h*_*e),n=Math.sin(x*e),a=Math.cos(x*e),c=o-t*(S*n+g*a),l=ti(t*(C*n+w*a));return s.done=Math.abs(l)<=r&&Math.abs(o-c)<=i,s.value=s.done?o:c,s}let t=y(e);if(p)s.done=e>=d;else{let n=ti(b(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(qa(ee),Ka),t=Ga(t=>ee.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return ee}ao.applyToOptions=e=>{let t=Ja(e,100,ao);return e.ease=t.ease,e.duration=ti(t.duration),e.type=`keyframes`,e};var oo=5;function so(e,t,n){let r=Math.max(t-oo,0);return ri(n-e(r),t-r)}function G({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>s!==void 0&&e<s||c!==void 0&&e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>_+v(e),b=e=>{let t=v(e),n=y(e);f.done=Math.abs(t)<=l,f.value=f.done?_:n},x,S,C=e=>{p(f.value)&&(x=e,S=ao({keyframes:[f.value,m(f.value)],velocity:so(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return C(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),C(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function co(e,t,n){let r=[],i=n||Gr.mix||Ua,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Qr(Array.isArray(t)?t[n]||Xr:t,a)),r.push(a)}return r}function lo(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=co(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=$r(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Wr(e[0],e[a-1],t)):l}function uo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=$r(0,t,r);e.push(ka(n,1,i))}}function fo(e){let t=[0];return uo(t,e.length-1),t}function po(e,t){return e.map(e=>e*t)}function mo(e,t){return e.map(()=>t||bi).splice(0,e.length-1)}function ho({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=xi(r)?r.map(Ti):Ti(r),a={done:!1,value:t[0]},o=lo(po(n&&n.length===t.length?n:fo(t),e),t,{ease:Array.isArray(i)?i:mo(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var go=e=>e!==null;function _o(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(go),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var vo={decay:G,inertia:G,tween:ho,keyframes:ho,spring:ao};function yo(e){typeof e.type==`string`&&(e.type=vo[e.type])}var bo=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},xo=e=>e/100,So=class extends bo{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==Pi.now()&&this.tick(Pi.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Fi.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;yo(e);let{type:t=ho,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||ho;s!==ho&&typeof o[0]!=`number`&&(this.mixKeyframes=Qr(xo,Ua(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=qa(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.holdTime===null?this.currentTime=t:this.currentTime=this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=Wr(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==G&&(b.value=_o(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return ni(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ni(e)}get time(){return ni(this.currentTime)}set time(e){e=ti(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return so(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(Pi.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=ni(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Wa,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(Pi.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null,Fi.mainThread--}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function Co(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var wo=e=>e*180/Math.PI,To=e=>Do(wo(Math.atan2(e[1],e[0]))),Eo={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:To,rotateZ:To,skewX:e=>wo(Math.atan(e[1])),skewY:e=>wo(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Do=e=>(e%=360,e<0&&(e+=360),e),Oo=To,ko=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Ao=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),jo={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:ko,scaleY:Ao,scale:e=>(ko(e)+Ao(e))/2,rotateX:e=>Do(wo(Math.atan2(e[6],e[5]))),rotateY:e=>Do(wo(Math.atan2(-e[2],e[0]))),rotateZ:Oo,rotate:Oo,skewX:e=>wo(Math.atan(e[4])),skewY:e=>wo(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Mo(e){return e.includes(`scale`)?1:0}function No(e,t){if(!e||e===`none`)return Mo(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=jo,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Eo,i=t}if(!i)return Mo(t);let a=r[t],o=i[1].split(`,`).map(Fo);return typeof a==`function`?a(o):o[a]}var Po=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return No(n,t)};function Fo(e){return parseFloat(e.trim())}var Io=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Lo=new Set(Io),Ro=e=>e===Hi||e===W,zo=new Set([`x`,`y`,`z`]),Bo=Io.filter(e=>!zo.has(e));function Vo(e){let t=[];return Bo.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Ho={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>No(t,`x`),y:(e,{transform:t})=>No(t,`y`)};Ho.translateX=Ho.x,Ho.translateY=Ho.y;var Uo=new Set,Wo=!1,Go=!1,Ko=!1;function qo(){if(Go){let e=Array.from(Uo).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Vo(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Go=!1,Wo=!1,Uo.forEach(e=>e.complete(Ko)),Uo.clear()}function Jo(){Uo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Go=!0)})}function Yo(){Ko=!0,Jo(),qo(),Ko=!1}var Xo=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Uo.add(this),Wo||(Wo=!0,V.read(Jo),V.resolveKeyframes(qo))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}Co(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Uo.delete(this)}cancel(){this.state===`scheduled`&&(Uo.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Zo=e=>e.startsWith(`--`);function Qo(e,t,n){Zo(t)?e.style.setProperty(t,n):e.style[t]=n}var $o={};function es(e,t){let n=Yr(e);return()=>$o[t]??n()}var ts=es(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),ns=es(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),rs=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,is={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:rs([0,.65,.55,1]),circOut:rs([.55,0,1,.45]),backIn:rs([.31,.01,.66,-.59]),backOut:rs([.33,1.53,.69,.99])};function as(e,t){if(e)return typeof e==`function`?ns()?Ga(e,t):`ease-out`:Si(e)?rs(e):Array.isArray(e)?e.map(e=>as(e,t)||is.easeOut):is[e]}function os(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=as(s,i);Array.isArray(d)&&(u.easing=d),Di.value&&Fi.waapi++;let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};l&&(f.pseudoElement=l);let p=e.animate(u,f);return Di.value&&p.finished.finally(()=>{Fi.waapi--}),p}function ss(e){return typeof e==`function`&&`applyToOptions`in e}function cs({type:e,...t}){return ss(e)&&ns()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var ls=class extends bo{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=cs(e);this.animation=os(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=_o(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Qo(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e===`idle`||e===`finished`||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return ni(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+ni(e)}get time(){return ni(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ti(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&ts()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Xr):r(this)}},us={anticipate:mi,backInOut:pi,circInOut:_i};function ds(e){return e in us}function fs(e){typeof e.ease==`string`&&ds(e.ease)&&(e.ease=us[e.ease])}var ps=10,ms=class extends ls{constructor(e){fs(e),yo(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new So({...a,autoplay:!1}),s=Math.max(ps,Pi.now()-this.startTime),c=Wr(0,ps,s-ps),l=o.sample(s).value,{name:u}=this.options;i&&u&&Qo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},hs=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Ta.test(e)||e===`0`)&&!e.startsWith(`url(`));function gs(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function _s(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=hs(i,t),s=hs(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:gs(e)||(n===`spring`||ss(n))&&r}function vs(e){e.duration=0,e.type=`keyframes`}var ys=new Set([`opacity`,`clipPath`,`filter`,`transform`]),bs=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function xs(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&bs.test(e[t]))return!0;return!1}var Ss=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Cs=Yr(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ws(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e;if(!(t?.owner?.current instanceof HTMLElement))return!1;let{onUpdate:c,transformTemplate:l}=t.owner.getProps();return Cs()&&n&&(ys.has(n)||Ss.has(n)&&xs(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Ts=40,Es=class extends bo{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=Pi.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u};this.keyframeResolver=new(l?.KeyframeResolver||Xo)(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=Pi.now();let u=!0;_s(e,i,a,o)||(u=!1,(Gr.instantAnimations||!s)&&l?.(_o(e,n,t)),e[0]=e[e.length-1],vs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Ts?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&ws(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new ms({...d,element:p})}catch{m=new So(d)}else m=new So(d);m.finished.then(()=>{this.notifyFinished()}).catch(Xr),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),Yo()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Ds(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Os=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ks(e){let t=Os.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function As(e,t,n=1){`${e}`;let[r,i]=ks(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Kr(e)?parseFloat(e):e}return zi(i)?As(i,t,n+1):i}var js={type:`spring`,stiffness:500,damping:25,restSpeed:10},Ms=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ns={type:`keyframes`,duration:.8},Ps={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Fs=(e,{keyframes:t})=>t.length>2?Ns:Lo.has(e)?e.startsWith(`scale`)?Ms(t[1]):js:Ps;function Is(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Ls(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Is(n,e)}var Rs=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function zs(e){for(let t in e)if(!Rs.has(t))return!0;return!1}var Bs=(e,t,n,r={},i,a)=>o=>{let s=Ls(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=ti(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};zs(s)||Object.assign(u,Fs(e,u)),u.duration&&=ti(u.duration),u.repeatDelay&&=ti(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(vs(u),u.delay===0&&(d=!0)),(Gr.instantAnimations||Gr.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,vs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=_o(u.keyframes,s);if(e!==void 0){V.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new So(u):new Es(u)};function Vs(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Hs(e,t,n,r){if(typeof t==`function`){let[i,a]=Vs(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Vs(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Us(e,t,n){let r=e.getProps();return Hs(r,t,n===void 0?r.custom:n,e)}var Ws=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Io]),Gs=30,Ks=e=>!isNaN(parseFloat(e)),qs={current:void 0},Js=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Pi.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=Pi.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Ks(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new ei);let n=this.events[e].add(t);return e===`change`?()=>{n(),V.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return qs.current&&qs.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Pi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Gs)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Gs);return ri(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Ys(e,t){return new Js(e,t)}var Xs=e=>Array.isArray(e);function Zs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Ys(n))}function Qs(e){return Xs(e)?e[e.length-1]||0:e}function $s(e,t){let{transitionEnd:n={},transition:r={},...i}=Us(e,t)||{};i={...i,...n};for(let t in i)Zs(e,t,Qs(i[t]))}var ec=e=>!!(e&&e.getVelocity);function tc(e){return!!(ec(e)&&e.add)}function nc(e,t){let n=e.getValue(`willChange`);if(tc(n))return n.add(t);if(!n&&Gr.WillChange){let n=new Gr.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function rc(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var ic=`data-`+rc(`framerAppearId`);function ac(e){return e.props[ic]}function oc({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function sc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Is(a,c):c;let l=a?.reduceMotion;r&&(a=r);let u=[],d=i&&e.animationState&&e.animationState.getState()[i];for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||d&&oc(d,t))continue;let o={delay:n,...Ls(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){V.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=ac(e);if(n){let e=window.MotionHandoffAnimation(n,t,V);e!==null&&(o.startTime=e,f=!0)}}nc(e,t);let p=l??e.shouldReduceMotion;r.start(Bs(t,r,i,p&&Ws.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>V.update(()=>{o&&$s(e,o)});u.length?Promise.all(u).then(t):t()}return u}function cc(e,t,n={}){let r=Us(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(sc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return lc(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}else return Promise.all([a(),o(n.delay)])}function lc(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(cc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Ds(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function uc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>cc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=cc(e,t,n);else{let i=typeof t==`function`?Us(e,t,n.custom):t;r=Promise.all(sc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var dc={test:e=>e===`auto`,parse:e=>e},fc=e=>t=>t.test(e),pc=[Hi,W,ia,ra,oa,aa,dc],mc=e=>pc.find(fc(e));function hc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Jr(e)}var gc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function _c(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ki)||[];if(!r)return e;let i=n.replace(r,``),a=gc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var vc=/\b([a-z-]*)\(.*?\)/gu,yc={...Ta,getAnimatableNone:e=>{let t=e.match(vc);return t?t.map(_c).join(` `):e}},bc={...Ta,getAnimatableNone:e=>{let t=Ta.parse(e);return Ta.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},xc={...Hi,transform:Math.round},Sc={borderWidth:W,borderTopWidth:W,borderRightWidth:W,borderBottomWidth:W,borderLeftWidth:W,borderRadius:W,borderTopLeftRadius:W,borderTopRightRadius:W,borderBottomRightRadius:W,borderBottomLeftRadius:W,width:W,maxWidth:W,height:W,maxHeight:W,top:W,right:W,bottom:W,left:W,inset:W,insetBlock:W,insetBlockStart:W,insetBlockEnd:W,insetInline:W,insetInlineStart:W,insetInlineEnd:W,padding:W,paddingTop:W,paddingRight:W,paddingBottom:W,paddingLeft:W,paddingBlock:W,paddingBlockStart:W,paddingBlockEnd:W,paddingInline:W,paddingInlineStart:W,paddingInlineEnd:W,margin:W,marginTop:W,marginRight:W,marginBottom:W,marginLeft:W,marginBlock:W,marginBlockStart:W,marginBlockEnd:W,marginInline:W,marginInlineStart:W,marginInlineEnd:W,fontSize:W,backgroundPositionX:W,backgroundPositionY:W,rotate:ra,rotateX:ra,rotateY:ra,rotateZ:ra,scale:Wi,scaleX:Wi,scaleY:Wi,scaleZ:Wi,skew:ra,skewX:ra,skewY:ra,distance:W,translateX:W,translateY:W,translateZ:W,x:W,y:W,z:W,perspective:W,transformPerspective:W,opacity:Ui,originX:sa,originY:sa,originZ:W,zIndex:xc,fillOpacity:Ui,strokeOpacity:Ui,numOctaves:xc},Cc={...Sc,color:la,backgroundColor:la,outlineColor:la,fill:la,stroke:la,borderColor:la,borderTopColor:la,borderRightColor:la,borderBottomColor:la,borderLeftColor:la,filter:yc,WebkitFilter:yc,mask:bc,WebkitMask:bc},wc=e=>Cc[e],Tc=new Set([yc,bc]);function Ec(e,t){let n=wc(e);return Tc.has(n)||(n=Ta),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Dc=new Set([`auto`,`none`,`0`]);function Oc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Dc.has(t)&&va(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Ec(n,i)}var kc=class extends Xo{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),zi(r))){let i=As(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Ws.has(n)||e.length!==2)return;let[r,i]=e,a=mc(r),o=mc(i);if(Vi(r)!==Vi(i)&&Ho[n]){this.needsMeasurement=!0;return}if(a!==o)if(Ro(a)&&Ro(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Ho[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||hc(e[t]))&&n.push(t);n.length&&Oc(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Ho[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=Ho[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}};function Ac(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var jc=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Mc(e){return qr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Nc,cancel:Pc}=Ai(queueMicrotask,!1),Fc={x:!1,y:!1};function Ic(){return Fc.x||Fc.y}function Lc(e){return e===`x`||e===`y`?Fc[e]?null:(Fc[e]=!0,()=>{Fc[e]=!1}):Fc.x||Fc.y?null:(Fc.x=Fc.y=!0,()=>{Fc.x=Fc.y=!1})}function Rc(e,t){let n=Ac(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function zc(e){return!(e.pointerType===`touch`||Ic())}function Bc(e,t,n={}){let[r,i,a]=Rc(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!zc(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Vc=(e,t)=>t?e===t?!0:Vc(e,t.parentElement):!1,Hc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Uc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Wc(e){return Uc.has(e.tagName)||e.isContentEditable===!0}var Gc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Kc(e){return Gc.has(e.tagName)||e.isContentEditable===!0}var qc=new WeakSet;function Jc(e){return t=>{t.key===`Enter`&&e(t)}}function Yc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Xc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Jc(()=>{if(qc.has(n))return;Yc(n,`down`);let e=Jc(()=>{Yc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Yc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Zc(e){return Hc(e)&&!Ic()}var Qc=new WeakSet;function $c(e,t,n={}){let[r,i,a]=Rc(e,n),o=e=>{let r=e.currentTarget;if(!Zc(e)||Qc.has(e))return;qc.add(r),n.stopPropagation&&Qc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),qc.has(r)&&qc.delete(r),Zc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Vc(r,e.target))},c=e=>{o(e,!1)};window.addEventListener(`pointerup`,s,i),window.addEventListener(`pointercancel`,c,i)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),Mc(e)&&(e.addEventListener(`focus`,e=>Xc(e,i)),!Wc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function el(e){return qr(e)&&`ownerSVGElement`in e}var tl=new WeakMap,nl,rl=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:el(r)&&`getBBox`in r?r.getBBox()[t]:r[n],il=rl(`inline`,`width`,`offsetWidth`),al=rl(`block`,`height`,`offsetHeight`);function ol({target:e,borderBoxSize:t}){tl.get(e)?.forEach(n=>{n(e,{get width(){return il(e,t)},get height(){return al(e,t)}})})}function sl(e){e.forEach(ol)}function cl(){typeof ResizeObserver>`u`||(nl=new ResizeObserver(sl))}function ll(e,t){nl||cl();let n=Ac(e);return n.forEach(e=>{let n=tl.get(e);n||(n=new Set,tl.set(e,n)),n.add(t),nl?.observe(e)}),()=>{n.forEach(e=>{let n=tl.get(e);n?.delete(t),n?.size||nl?.unobserve(e)})}}var ul=new Set,dl;function fl(){dl=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ul.forEach(t=>t(e))},window.addEventListener(`resize`,dl)}function pl(e){return ul.add(e),dl||fl(),()=>{ul.delete(e),!ul.size&&typeof dl==`function`&&(window.removeEventListener(`resize`,dl),dl=void 0)}}function ml(e,t){return typeof e==`function`?pl(e):ll(e,t)}function hl(e){return el(e)&&e.tagName===`svg`}var gl=[...pc,la,Ta],_l=e=>gl.find(fc(e)),vl=()=>({translate:0,scale:1,origin:0,originPoint:0}),yl=()=>({x:vl(),y:vl()}),bl=()=>({min:0,max:0}),xl=()=>({x:bl(),y:bl()}),Sl=new WeakMap;function Cl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function wl(e){return typeof e==`string`||Array.isArray(e)}var Tl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],El=[`initial`,...Tl];function Dl(e){return Cl(e.animate)||El.some(t=>wl(e[t]))}function Ol(e){return!!(Dl(e)||e.variants)}function kl(e,t,n){for(let r in t){let i=t[r],a=n[r];if(ec(i))e.addValue(r,i);else if(ec(a))e.addValue(r,Ys(i,{owner:e}));else if(a!==i)if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Ys(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Al={current:null},jl={current:!1},Ml=typeof window<`u`;function Nl(){if(jl.current=!0,Ml)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Al.current=e.matches;e.addEventListener(`change`,t),t()}else Al.current=!1}var Pl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Fl={};function Il(e){Fl=e}function Ll(){return Fl}var Rl=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=Xo,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=Pi.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,V.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Dl(t),this.isVariantNode=Ol(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&ec(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,Sl.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(jl.current||Nl(),this.shouldReduceMotion=Al.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),H(this.notifyUpdate),H(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&ys.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new ls({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:ti(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Lo.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&V.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i(),t.owner&&t.stop()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Fl){let t=Fl[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):xl()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Pl.length;t++){let n=Pl[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=kl(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Ys(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(Kr(n)||Jr(n))?n=parseFloat(n):!_l(n)&&Ta.test(t)&&(n=Ec(e,t)),this.setBaseTarget(e,ec(n)?n.get():n)),ec(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Hs(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!ec(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new ei),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Nc.render(this.render)}},K=class extends Rl{constructor(){super(...arguments),this.KeyframeResolver=kc}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;ec(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},q=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function J({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Y({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function zl(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Bl(e){return e===void 0||e===1}function Vl({scale:e,scaleX:t,scaleY:n}){return!Bl(e)||!Bl(t)||!Bl(n)}function Hl(e){return Vl(e)||Ul(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ul(e){return Wl(e.x)||Wl(e.y)}function Wl(e){return e&&e!==`0%`}function Gl(e,t,n){return n+t*(e-n)}function Kl(e,t,n,r,i){return i!==void 0&&(e=Gl(e,i,r)),Gl(e,n,r)+t}function ql(e,t=0,n=1,r,i){e.min=Kl(e.min,t,n,r,i),e.max=Kl(e.max,t,n,r,i)}function Jl(e,{x:t,y:n}){ql(e.x,t.translate,t.scale,t.originPoint),ql(e.y,n.translate,n.scale,n.originPoint)}var Yl=.999999999999,Xl=1.0000000000001;function Zl(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(Ql(e.x,-a.scroll.offset.x),Ql(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Jl(e,o)),r&&Hl(a.latestValues)&&tu(e,a.latestValues,a.layout?.layoutBox))}t.x<Xl&&t.x>Yl&&(t.x=1),t.y<Xl&&t.y>Yl&&(t.y=1)}function Ql(e,t){e.min+=t,e.max+=t}function $l(e,t,n,r,i=.5){ql(e,t,n,ka(e.min,e.max,i),r)}function eu(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function tu(e,t,n){let r=n??e;$l(e.x,eu(t.x,r.x),t.scaleX,t.scale,t.originX),$l(e.y,eu(t.y,r.y),t.scaleY,t.scale,t.originY)}function nu(e,t){return J(zl(e.getBoundingClientRect(),t))}function ru(e,t,n){let r=nu(e,n),{scroll:i}=t;return i&&(Ql(r.x,i.offset.x),Ql(r.y,i.offset.y)),r}var iu={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},au=Io.length;function ou(e,t,n){let r=``,i=!0;for(let a=0;a<au;a++){let o=Io[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===(o.startsWith(`scale`)?1:0);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=jc(s,Sc[o]);if(!c){i=!1;let t=iu[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function su(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Lo.has(e)){o=!0;continue}else if(Li(e)){i[e]=n;continue}else{let t=jc(n,Sc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=ou(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function cu(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function lu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var uu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(W.test(e))e=parseFloat(e);else return e;return`${lu(e,t.target.x)}% ${lu(e,t.target.y)}%`}},du={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Ta.parse(e);if(i.length>5)return r;let a=Ta.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=ka(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},fu={borderRadius:{...uu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:uu,borderTopRightRadius:uu,borderBottomLeftRadius:uu,borderBottomRightRadius:uu,boxShadow:du};function pu(e,{layout:t,layoutId:n}){return Lo.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!fu[e]||e===`opacity`)}function mu(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(ec(r[t])||i&&ec(i[t])||pu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function hu(e){return window.getComputedStyle(e)}var gu=class extends K{constructor(){super(...arguments),this.type=`html`,this.renderInstance=cu}readValueFromInstance(e,t){if(Lo.has(t))return this.projection?.isProjecting?Mo(t):Po(e,t);{let n=hu(e),r=(Li(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return nu(e,t)}build(e,t,n){su(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return mu(e,t,n)}},_u={offset:`stroke-dashoffset`,array:`stroke-dasharray`},vu={offset:`strokeDashoffset`,array:`strokeDasharray`};function yu(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?_u:vu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var bu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function xu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(su(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;d.transform&&(f.transform=d.transform,delete d.transform),(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox);for(let e of bu)d[e]!==void 0&&(f[e]=d[e],delete d[e]);t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&yu(d,i,a,o,!1)}var Su=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),Cu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function wu(e,t,n,r){cu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Su.has(n)?n:rc(n),t.attrs[n])}function Tu(e,t,n){let r=mu(e,t,n);for(let n in e)if(ec(e[n])||ec(t[n])){let t=Io.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var Eu=class extends K{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=xl}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Lo.has(t)){let e=wc(t);return e&&e.default||0}return t=Su.has(t)?t:rc(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Tu(e,t,n)}build(e,t,n){xu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){wu(e,t,n,r)}mount(e){this.isSVGTag=Cu(e.tagName),super.mount(e)}},Du=El.length;function Ou(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Ou(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Du;n++){let r=El[n],i=e.props[r];(wl(i)||i===!1)&&(t[r]=i)}return t}function ku(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Au=[...Tl].reverse(),ju=Tl.length;function Mu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>uc(e,t,n)))}function Nu(e){let t=Mu(e),n=Iu(),r=!0,i=!1,a=t=>(n,r)=>{let i=Us(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=Ou(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<ju;t++){let p=Au[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=wl(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||Cl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Pu(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,ee={...w,...C},T=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in ee){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Xs(t)&&Xs(n)?!ku(t,n):t!==n,r?t==null?u.add(e):T(e):t!==void 0&&u.has(e)?T(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let te=v&&y;b&&(!te||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!te&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Us(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Ds(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Us(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Iu(),i=!0}}}function Pu(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!ku(t,e):!1}function Fu(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Iu(){return{animate:Fu(!0),whileInView:Fu(),whileHover:Fu(),whileTap:Fu(),whileDrag:Fu(),whileFocus:Fu(),exit:Fu()}}function Lu(e,t){e.min=t.min,e.max=t.max}function Ru(e,t){Lu(e.x,t.x),Lu(e.y,t.y)}function zu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Bu=1e-4,Vu=1-Bu,Hu=1+Bu,Uu=.01,Wu=0-Uu,Gu=0+Uu;function X(e){return e.max-e.min}function Ku(e,t,n){return Math.abs(e-t)<=n}function qu(e,t,n,r=.5){e.origin=r,e.originPoint=ka(t.min,t.max,e.origin),e.scale=X(n)/X(t),e.translate=ka(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Vu&&e.scale<=Hu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Wu&&e.translate<=Gu||isNaN(e.translate))&&(e.translate=0)}function Ju(e,t,n,r){qu(e.x,t.x,n.x,r?r.originX:void 0),qu(e.y,t.y,n.y,r?r.originY:void 0)}function Yu(e,t,n,r=0){e.min=(r?ka(n.min,n.max,r):n.min)+t.min,e.max=e.min+X(t)}function Xu(e,t,n,r){Yu(e.x,t.x,n.x,r?.x),Yu(e.y,t.y,n.y,r?.y)}function Zu(e,t,n,r=0){let i=r?ka(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+X(t)}function Qu(e,t,n,r){Zu(e.x,t.x,n.x,r?.x),Zu(e.y,t.y,n.y,r?.y)}function $u(e,t,n,r,i){return e-=t,e=Gl(e,1/n,r),i!==void 0&&(e=Gl(e,1/i,r)),e}function ed(e,t=0,n=1,r=.5,i,a=e,o=e){if(ia.test(t)&&(t=parseFloat(t),t=ka(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=ka(a.min,a.max,r);e===a&&(s-=t),e.min=$u(e.min,t,n,s,i),e.max=$u(e.max,t,n,s,i)}function td(e,t,[n,r,i],a,o){ed(e,t[n],t[r],t[i],t.scale,a,o)}var nd=[`x`,`scaleX`,`originX`],rd=[`y`,`scaleY`,`originY`];function id(e,t,n,r){td(e.x,t,nd,n?n.x:void 0,r?r.x:void 0),td(e.y,t,rd,n?n.y:void 0,r?r.y:void 0)}function ad(e){return e.translate===0&&e.scale===1}function od(e){return ad(e.x)&&ad(e.y)}function sd(e,t){return e.min===t.min&&e.max===t.max}function cd(e,t){return sd(e.x,t.x)&&sd(e.y,t.y)}function ld(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ud(e,t){return ld(e.x,t.x)&&ld(e.y,t.y)}function dd(e){return X(e.x)/X(e.y)}function fd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function pd(e){return[e(`x`),e(`y`)]}function md(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,rotateX:i,rotateY:a,skewX:o,skewY:s}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotateX(${i}deg) `),a&&(r+=`rotateY(${a}deg) `),o&&(r+=`skewX(${o}deg) `),s&&(r+=`skewY(${s}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var hd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],gd=hd.length,_d=e=>typeof e==`string`?parseFloat(e):e,vd=e=>typeof e==`number`||W.test(e);function yd(e,t,n,r,i,a){i?(e.opacity=ka(0,n.opacity??1,Z(r)),e.opacityExit=ka(t.opacity??1,0,xd(r))):a&&(e.opacity=ka(t.opacity??1,n.opacity??1,r));for(let i=0;i<gd;i++){let a=hd[i],o=bd(t,a),s=bd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||vd(o)===vd(s)?(e[a]=Math.max(ka(_d(o),_d(s),r),0),(ia.test(s)||ia.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=ka(t.rotate||0,n.rotate||0,r))}function bd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Z=Sd(0,.5,gi),xd=Sd(.5,.95,Xr);function Sd(e,t,n){return r=>r<e?0:r>t?1:n($r(e,t,r))}function Cd(e,t,n){let r=ec(e)?e:Ys(e);return r.start(Bs(``,r,t,n)),r.animation}function wd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var Td=(e,t)=>e.depth-t.depth,Ed=class{constructor(){this.children=[],this.isDirty=!1}add(e){Hr(this.children,e),this.isDirty=!0}remove(e){Ur(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Td),this.isDirty=!1,this.children.forEach(e)}};function Dd(e,t){let n=Pi.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(H(r),e(a-t))};return V.setup(r,!0),()=>H(r)}function Od(e){return ec(e)?e.get():e}var kd=class{constructor(){this.members=[]}add(e){Hr(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(Ur(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Ur(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Ad={hasAnimatedSinceResize:!0,hasEverUpdated:!1},jd={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Md=[``,`X`,`Y`,`Z`],Nd=1e3,Pd=0;function Fd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Id(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ac(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,V,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Id(r)}function Ld({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Pd++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Di.value&&(jd.nodes=jd.calculatedTargetDeltas=jd.calculatedProjections=0),this.nodes.forEach(Bd),this.nodes.forEach(Yd),this.nodes.forEach(Xd),this.nodes.forEach(Vd),Di.addProjectionMetrics&&Di.addProjectionMetrics(jd)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new Ed)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ei),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=el(t)&&!hl(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;V.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Dd(i,250),Ad.hasAnimatedSinceResize&&(Ad.hasAnimatedSinceResize=!1,this.nodes.forEach(Jd)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||rf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!ud(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...Ls(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l)}else t||Jd(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),H(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(Zd),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Id(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(Wd),this.nodes.forEach(Ud);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Gd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Kd),this.nodes.forEach(qd),this.nodes.forEach(Rd),this.nodes.forEach(zd)):this.nodes.forEach(Gd),this.clearAllSnapshots();let e=Pi.now();U.delta=Wr(0,1e3/60,e-U.timestamp),U.timestamp=e,U.isProcessing=!0,ji.update.process(U),ji.preRender.process(U),ji.render.process(U),U.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Nc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Hd),this.sharedNodes.forEach(Qd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,V.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){V.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!X(this.snapshot.measuredBox.x)&&!X(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=xl(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!od(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Hl(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),cf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return xl();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(uf))){let{scroll:e}=this.root;e&&(Ql(t.x,e.offset.x),Ql(t.y,e.offset.y))}return t}removeElementScroll(e){let t=xl();if(Ru(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Ru(t,e),Ql(t.x,i.offset.x),Ql(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||xl();Ru(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(Ql(r.x,-n.scroll.offset.x),Ql(r.y,-n.scroll.offset.y)),Hl(n.latestValues)&&tu(r,n.latestValues,n.layout?.layoutBox)}return Hl(this.latestValues)&&tu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=xl();Ru(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Hl(n.latestValues))continue;let r;n.instance&&(Vl(n.latestValues)&&n.updateSnapshot(),r=xl(),Ru(r,n.measurePageBox())),id(t,n.latestValues,n.snapshot?.layoutBox,r)}return Hl(this.latestValues)&&id(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0?!0:e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==U.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=U.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=xl(),this.targetWithTransforms=xl()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Xu(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Ru(this.target,this.layout.layoutBox),Jl(this.target,this.targetDelta)):Ru(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Di.value&&jd.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Vl(this.parent.latestValues)||Ul(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=xl(),this.relativeTargetOrigin=xl(),Qu(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Ru(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===U.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Ru(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Zl(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=xl());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(zu(this.prevProjectionDelta.x,this.projectionDelta.x),zu(this.prevProjectionDelta.y,this.projectionDelta.y)),Ju(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!fd(this.projectionDelta.x,this.prevProjectionDelta.x)||!fd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Di.value&&jd.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=yl(),this.projectionDelta=yl(),this.projectionDeltaWithTransform=yl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=yl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=xl(),s=(n?n.source:void 0)!==(this.layout?this.layout.source:void 0),c=this.getStack(),l=!c||c.members.length<=1,u=!!(s&&!l&&this.options.crossfade===!0&&!this.path.some(nf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;$d(a.x,e.x,n),$d(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Qu(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),tf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&cd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=xl(),Ru(d,this.relativeTarget)),s&&(this.animationValues=i,yd(i,r,this.latestValues,n,u,l)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(H(this.pendingAnimation),void 0),this.pendingAnimation=V.update(()=>{Ad.hasAnimatedSinceResize=!0,Fi.layout++,this.motionValue||=Ys(0),this.motionValue.jump(0,!1),this.currentAnimation=Cd(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Fi.layout--},onComplete:()=>{Fi.layout--,e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Nd),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(!(!t||!n||!r)){if(this!==e&&this.layout&&r&&lf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||xl();let t=X(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=X(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Ru(t,n),tu(t,i),Ju(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new kd),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return e?e.lead===this:!0}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&Fd(`z`,e,r,this.animationValues);for(let t=0;t<Md.length;t++)Fd(`rotate${Md[t]}`,e,r,this.animationValues),Fd(`skew${Md[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=Od(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=Od(t?.pointerEvents)||``),this.hasProjected&&!Hl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=md(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,r.animationValues?e.opacity=r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:e.opacity=r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in fu){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=fu[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?Od(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Ud),this.root.sharedNodes.clear()}}}function Rd(e){e.updateLayout()}function zd(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)pd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=X(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Lu(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else lf(i,t.layoutBox,n)&&pd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=X(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=yl();Ju(o,n,t.layoutBox);let s=yl();a?Ju(s,e.applyTransform(r,!0),t.measuredBox):Ju(s,n,t.layoutBox);let c=!od(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=xl();Qu(s,t.layoutBox,i.layoutBox,o);let c=xl();Qu(c,n,a.layoutBox,o),ud(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Bd(e){Di.value&&jd.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function Vd(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Hd(e){e.clearSnapshot()}function Ud(e){e.clearMeasurements()}function Wd(e){e.isLayoutDirty=!0,e.updateLayout()}function Gd(e){e.isLayoutDirty=!1}function Kd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function qd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Jd(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Yd(e){e.resolveTargetDelta()}function Xd(e){e.calcProjection()}function Zd(e){e.resetSkewAndRotation()}function Qd(e){e.removeLeadSnapshot()}function $d(e,t,n){e.translate=ka(t.translate,0,n),e.scale=ka(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ef(e,t,n,r){e.min=ka(t.min,n.min,r),e.max=ka(t.max,n.max,r)}function tf(e,t,n,r){ef(e.x,t.x,n.x,r),ef(e.y,t.y,n.y,r)}function nf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var rf={duration:.45,ease:[.4,0,.1,1]},af=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),of=af(`applewebkit/`)&&!af(`chrome/`)?Math.round:Xr;function sf(e){e.min=of(e.min),e.max=of(e.max)}function cf(e){sf(e.x),sf(e.y)}function lf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Ku(dd(t),dd(n),.2)}function uf(e){return e!==e.root&&e.scroll?.wasRoot}var df=Ld({attachResizeListener:(e,t)=>wd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),ff={current:void 0},pf=Ld({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!ff.current){let e=new df({});e.mount(window),e.setOptions({layoutScroll:!0}),ff.current=e}return ff.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),mf=(0,b.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function hf(e=!0){let t=(0,b.useContext)(Vr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,b.useId)();(0,b.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,b.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var gf=(0,b.createContext)({strict:!1}),_f={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},vf=!1;function yf(){if(vf)return;let e={};for(let t in _f)e[t]={isEnabled:e=>_f[t].some(t=>!!e[t])};Il(e),vf=!0}function bf(){return yf(),Ll()}function xf(e){let t=bf();for(let n in e)t[n]={...t[n],...e[n]};Il(t)}var Sf=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function Cf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Sf.has(e)}var wf=c({default:()=>Tf}),Tf,Ef=o((()=>{throw Tf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Df=e=>!Cf(e);function Of(e){typeof e==`function`&&(Df=t=>t.startsWith(`on`)?!Cf(t):e(t))}try{Of((Ef(),d(wf)).default)}catch{}function kf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||ec(e[i])||(Df(i)||n===!0&&Cf(i)||!t&&!Cf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Af=(0,b.createContext)({});function jf(e,t){if(Dl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||wl(t)?t:void 0,animate:wl(n)?n:void 0}}return e.inherit===!1?{}:t}function Mf(e){let{initial:t,animate:n}=jf(e,(0,b.useContext)(Af));return(0,b.useMemo)(()=>({initial:t,animate:n}),[Nf(t),Nf(n)])}function Nf(e){return Array.isArray(e)?e.join(` `):e}var Pf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Ff(e,t,n){for(let r in t)!ec(t[r])&&!pu(r,n)&&(e[r]=t[r])}function If({transformTemplate:e},t){return(0,b.useMemo)(()=>{let n=Pf();return su(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Lf(e,t){let n=e.style||{},r={};return Ff(r,n,e),Object.assign(r,If(e,t)),r}function Rf(e,t){let n={},r=Lf(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var zf=()=>({...Pf(),attrs:{}});function Bf(e,t,n,r){let i=(0,b.useMemo)(()=>{let n=zf();return xu(n,t,Cu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Ff(t,e.style,e),i.style={...t,...i.style}}return i}var Vf=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function Hf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Vf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Uf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Hf(e)?Bf:Rf)(t,r,i,e),c=kf(t,typeof e==`string`,a),l=e===b.Fragment?{}:{...c,...s,ref:n},{children:u}=t,d=(0,b.useMemo)(()=>ec(u)?u.get():u,[u]);return(0,b.createElement)(e,{...l,children:d})}function Wf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Gf(n,r,i,e),renderState:t()}}function Gf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Od(a[e]);let{initial:o,animate:s}=e,c=Dl(e),l=Ol(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!Cl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Hs(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var Kf=e=>(t,n)=>{let r=(0,b.useContext)(Af),i=(0,b.useContext)(Vr),a=()=>Wf(e,t,r,i);return n?a():zr(a)},qf=Kf({scrapeMotionValuesFromProps:mu,createRenderState:Pf}),Jf=Kf({scrapeMotionValuesFromProps:Tu,createRenderState:zf}),Yf=Symbol.for(`motionComponentSymbol`);function Xf(e,t,n){let r=(0,b.useRef)(n);(0,b.useInsertionEffect)(()=>{r.current=n});let i=(0,b.useRef)(null);return(0,b.useCallback)(n=>{n&&e.onMount?.(n);let a=r.current;if(typeof a==`function`)if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n);else a&&(a.current=n);t&&(n?t.mount(n):t.unmount())},[t])}var Zf=(0,b.createContext)({});function Qf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function $f(e,t,n,r,i,a){let{visualElement:o}=(0,b.useContext)(Af),s=(0,b.useContext)(gf),c=(0,b.useContext)(Vr),l=(0,b.useContext)(mf),u=l.reducedMotion,d=l.skipAnimations,f=(0,b.useRef)(null),p=(0,b.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,b.useContext)(Zf);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&ep(f.current,n,i,h);let g=(0,b.useRef)(!1);(0,b.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let _=n[ic],v=(0,b.useRef)(!!_&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(_)&&window.MotionHasOptimisedAnimation?.(_));return Br(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),v.current&&m.animationState&&m.animationState.animateChanges())}),(0,b.useEffect)(()=>{m&&(!v.current&&m.animationState&&m.animationState.animateChanges(),v.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(_)}),!1),m.enteringChildren=void 0)}),m}function ep(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:tp(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Qf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function tp(e){if(e)return e.options.allowProjection===!1?tp(e.parent):e.projection}function np(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&xf(r);let a=n?n===`svg`:Hf(e),o=a?Jf:qf;function s(n,s){let c,l={...(0,b.useContext)(mf),...n,layoutId:rp(n)},{isStatic:u}=l,d=Mf(n),f=o(n,u);if(!u&&typeof window<`u`){ip(l,r);let t=ap(l);c=t.MeasureLayout,d.visualElement=$f(e,f,l,i,t.ProjectionNode,a)}return(0,B.jsxs)(Af.Provider,{value:d,children:[c&&d.visualElement?(0,B.jsx)(c,{visualElement:d.visualElement,...l}):null,Uf(e,n,Xf(f,d.visualElement,s),f,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,b.forwardRef)(s);return c[Yf]=e,c}function rp({layoutId:e}){let t=(0,b.useContext)(Rr).id;return t&&e!==void 0?t+`-`+e:e}function ip(e,t){(0,b.useContext)(gf).strict}function ap(e){let{drag:t,layout:n}=bf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function op(e,t){if(typeof Proxy>`u`)return np;let n=new Map,r=(n,r)=>np(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,np(a,void 0,e,t)),n.get(a))})}var sp=(e,t)=>t.isSVG??Hf(e)?new Eu(t):new gu(t,{allowProjection:e!==b.Fragment}),cp=class extends q{constructor(e){super(e),e.animationState||=Nu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Cl(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},lp=0,up={animation:{Feature:cp},exit:{Feature:class extends q{constructor(){super(...arguments),this.id=lp++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`){let n=Us(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function dp(e){return{point:{x:e.pageX,y:e.pageY}}}var fp=e=>t=>Hc(t)&&e(t,dp(t));function pp(e,t,n,r){return wd(e,t,fp(n),r)}var mp=({current:e})=>e?e.ownerDocument.defaultView:null,hp=(e,t)=>Math.abs(e-t);function gp(e,t){let n=hp(e.x,t.x),r=hp(e.y,t.y);return Math.sqrt(n**2+r**2)}var _p=new Set([`auto`,`scroll`]),vp=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=yp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=xp(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=gp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=U;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=yp(t,this.transformPagePoint),V.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=xp(e.type===`pointercancel`?this.lastMoveEventInfo:yp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Hc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=yp(dp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=U;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,xp(s,this.history)),this.removeListeners=Qr(pp(this.contextWindow,`pointermove`,this.handlePointerMove),pp(this.contextWindow,`pointerup`,this.handlePointerUp),pp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(_p.has(e.overflowX)||_p.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};i.x===0&&i.y===0||(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),V.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),H(this.updatePoint)}};function yp(e,t){return t?{point:t(e.point)}:e}function bp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function xp({point:e},t){return{point:e,delta:bp(e,Cp(t)),offset:bp(e,Sp(t)),velocity:wp(t,.1)}}function Sp(e){return e[0]}function Cp(e){return e[e.length-1]}function wp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Cp(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>ti(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>ti(t)*2&&(r=e[1]);let a=ni(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Tp(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?ka(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?ka(n,e,r.max):Math.min(e,n)),e}function Ep(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Dp(e,{top:t,left:n,bottom:r,right:i}){return{x:Ep(e.x,n,i),y:Ep(e.y,t,r)}}function Op(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function kp(e,t){return{x:Op(e.x,t.x),y:Op(e.y,t.y)}}function Ap(e,t){let n=.5,r=X(e),i=X(t);return i>r?n=$r(t.min,t.max-r,e.min):r>i&&(n=$r(e.min,e.max-i,t.min)),Wr(0,1,n)}function jp(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Mp=.35;function Np(e=Mp){return e===!1?e=0:e===!0&&(e=Mp),{x:Pp(e,`left`,`right`),y:Pp(e,`top`,`bottom`)}}function Pp(e,t,n){return{min:Fp(e,t),max:Fp(e,n)}}function Fp(e,t){return typeof e==`number`?e:e[t]||0}var Ip=new WeakMap,Lp=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=xl(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(dp(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Lc(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),pd(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ia.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=X(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&V.update(()=>i(e,t),!1,!0),nc(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=Vp(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&V.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new vp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:mp(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&V.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!Bp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Tp(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&Qf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Dp(n.layoutBox,e):this.constraints=!1,this.elastic=Np(t),r!==this.constraints&&!Qf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&pd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=jp(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Qf(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=ru(n,r.root,this.visualElement.getTransformPagePoint()),a=kp(r.layout.layoutBox,i);if(t){let e=t(Y(a));this.hasMutatedConstraints=!!e,e&&(a=J(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=pd(o=>{if(!Bp(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return nc(this.visualElement,e),n.start(Bs(e,n,0,t,this.visualElement,!1))}stopAnimation(){pd(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`,n=this.visualElement.getProps();return n[t]||this.visualElement.getValue(e,(n.initial?n.initial[e]:void 0)||0)}snapToCursor(e){pd(t=>{let{drag:n}=this.getProps();if(!Bp(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-ka(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Qf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};pd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Ap({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),pd(t=>{if(!Bp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(ka(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Ip.set(this.visualElement,this);let e=this.visualElement.current,t=pp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Kc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Qf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=zp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),V.read(r);let o=wd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(pd(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Mp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Rp(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function zp(e,t,n){let r=ml(e,Rp(n)),i=ml(t,Rp(n));return()=>{r(),i()}}function Bp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Vp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Hp=class extends q{constructor(e){super(e),this.removeGroupControls=Xr,this.removeListeners=Xr,this.controls=new Lp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Xr}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},Up=e=>(t,n)=>{e&&V.update(()=>e(t,n),!1,!0)},Wp=class extends q{constructor(){super(...arguments),this.removePointerDownListener=Xr}onPointerDown(e){this.session=new vp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:mp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Up(e),onStart:Up(t),onMove:Up(n),onEnd:(e,t)=>{delete this.session,r&&V.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=pp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Gp=!1,Kp=class extends b.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),Gp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ad.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),Gp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||V.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Nc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Gp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function qp(e){let[t,n]=hf(),r=(0,b.useContext)(Rr);return(0,B.jsx)(Kp,{...e,layoutGroup:r,switchLayoutGroup:(0,b.useContext)(Zf),isPresent:t,safeToRemove:n})}var Jp={pan:{Feature:Wp},drag:{Feature:Hp,ProjectionNode:pf,MeasureLayout:qp}};function Yp(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&V.postRender(()=>i(t,dp(t)))}var Xp=class extends q{mount(){let{current:e}=this.node;e&&(this.unmount=Bc(e,(e,t)=>(Yp(this.node,t,`Start`),e=>Yp(this.node,e,`End`))))}unmount(){}},Zp=class extends q{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}!e||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){!this.isActive||!this.node.animationState||(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=Qr(wd(this.node.current,`focus`,()=>this.onFocus()),wd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Qp(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&V.postRender(()=>i(t,dp(t)))}var $p=class extends q{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=$c(e,(e,t)=>(Qp(this.node,t,`Start`),(e,{success:t})=>Qp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},em=new WeakMap,tm=new WeakMap,nm=e=>{let t=em.get(e.target);t&&t(e)},rm=e=>{e.forEach(nm)};function im({root:e,...t}){let n=e||document;tm.has(n)||tm.set(n,{});let r=tm.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(rm,{root:e,...t})),r[i]}function am(e,t,n){let r=im(t);return em.set(e,n),r.observe(e),()=>{em.delete(e),r.unobserve(e)}}var om={some:0,all:1},sm=class extends q{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:om[r]};this.stopObserver=am(this.node.current,a,e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)})}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(cm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function cm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var lm={inView:{Feature:sm},tap:{Feature:$p},focus:{Feature:Zp},hover:{Feature:Xp}},um={layout:{ProjectionNode:pf,MeasureLayout:qp}},dm=op({...up,...lm,...Jp,...um},sp),fm=24e3,pm=2048,mm=1200;function hm(e){let t=new Int16Array(e.length);for(let n=0;n<e.length;n++){let r=Math.max(-1,Math.min(1,e[n]));t[n]=r<0?r*32768:r*32767}return t}function gm(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}function _m(e,t){let n=0,r=[];return{enqueue:i=>{let a=gm(i),o=e.createBuffer(1,a.length,fm);o.copyToChannel(a,0);let s=e.createBufferSource();s.buffer=o,s.connect(e.destination);let c=Math.max(e.currentTime,n);s.start(c),n=c+o.duration,r.push(s),s.onended=()=>{r=r.filter(e=>e!==s),r.length||t?.()}},stop:()=>{r.forEach(e=>{try{e.stop()}catch{}}),r=[],n=0},isPlaying:()=>r.length>0}}async function vm(e,t,n){let r=new URLSearchParams({siteId:t||``});n&&r.set(`chatId`,n);let i=await fetch(`${e}/api/voice/session?${r.toString()}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(i.status===429){let e=await i.json().catch(()=>({}));throw Error(e.message||`Too many voice sessions started. Please wait a minute before trying again.`)}if(!i.ok)throw Error(`Could not start a voice session.`);let a=await i.json();if(!a?.success||!a.token)throw Error(a?.error||`Voice session was refused.`);return a}async function ym(e){let{apiBaseUrl:t,siteId:n,chatId:r,clientTools:i={},onConnect:a,onDisconnect:o,onMessage:s,onModeChange:c,onError:l,onUnhandledClientToolCall:u}=e,d=await vm(t,n,r);e.greeting!==void 0&&(e.greeting?d.settings.agent.greeting=e.greeting:delete d.settings.agent.greeting);let f=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),p=new(window.AudioContext||window.webkitAudioContext)({sampleRate:fm});p.state===`suspended`&&await p.resume();let m=new WebSocket(d.wsUrl,[`token`,d.token]);m.binaryType=`arraybuffer`;let h={role:null,text:``,timer:null},g=()=>{h.timer&&=(clearTimeout(h.timer),null);let e=h.text.trim(),t=h.role;h.text=``,h.role=null,e&&t&&s?.({role:t,message:e})},_=(e,t)=>{t&&(h.role&&h.role!==e&&g(),h.role=e,h.text=h.text?`${h.text} ${t}`.replace(/\s+/g,` `):t,h.timer&&clearTimeout(h.timer),h.timer=setTimeout(g,mm))},v=!1,y=!1,b=!1,x=_m(p,()=>{b&&(b=!1,c?.({mode:`listening`}))}),S=p.createMediaStreamSource(f),C=p.createScriptProcessor(pm,1,1);C.onaudioprocess=e=>{v||y||m.readyState!==WebSocket.OPEN||m.send(hm(e.inputBuffer.getChannelData(0)).buffer)},S.connect(C),C.connect(p.destination);let w=()=>{if(!v){v=!0,g(),x.stop();try{C.disconnect(),S.disconnect()}catch{}f.getTracks().forEach(e=>e.stop()),p.close().catch(()=>{}),(m.readyState===WebSocket.OPEN||m.readyState===WebSocket.CONNECTING)&&m.close()}},ee=async e=>{let t=i[e.name];if(!t)return u?.({tool_name:e.name}),{error:`Unknown tool ${e.name}`};let n={};try{n=JSON.parse(e.arguments||`{}`)}catch{}try{return await t(n)}catch(e){return{error:e?.message||`Tool execution failed`}}},T=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await ee(t);if(v||m.readyState!==WebSocket.OPEN)return;m.send(JSON.stringify({type:`FunctionCallResponse`,id:t.id,name:t.name,content:typeof e==`string`?e:JSON.stringify(e??{})}))}},te=e=>{switch(e.type){case`Welcome`:a?.({conversationId:e.request_id||d.token.slice(0,12)});break;case`ConversationText`:_(e.role===`user`?`user`:`agent`,e.content);break;case`UserStartedSpeaking`:g(),x.stop(),b=!1,c?.({mode:`listening`});break;case`AgentStartedSpeaking`:b=!0,c?.({mode:`speaking`});break;case`AgentAudioDone`:g(),x.isPlaying()||(b=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:T(e);break;case`PromptUpdated`:case`AgentThinking`:break;case`Error`:console.error(`[FlowEngage:Deepgram]`,e.code||``,e.description||e),l?.(Error(e.description||`Voice service error`));break;case`Warning`:console.warn(`[FlowEngage:Deepgram]`,e.code||``,e.description||``);break;default:break}};return m.onopen=()=>m.send(JSON.stringify(d.settings)),m.onmessage=e=>{if(e.data instanceof ArrayBuffer){x.enqueue(new Int16Array(e.data));return}try{te(JSON.parse(e.data))}catch{}},m.onerror=()=>l?.(Error(`Voice connection failed`)),m.onclose=()=>{w(),o?.()},{endSession:async()=>w(),sendContextualUpdate:e=>{v||m.readyState!==WebSocket.OPEN||!e||m.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:e=>{v||m.readyState!==WebSocket.OPEN||!e||m.send(JSON.stringify({type:`InjectUserMessage`,content:e}))},injectAgentSpeech:(e,t=`interrupt`)=>{v||m.readyState!==WebSocket.OPEN||!e||m.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setMicMuted:e=>{y=!!e},get status(){return v?`disconnected`:`connected`}}}var bm={startSession:ym},xm=({size:e=18,color:t=`currentColor`})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:t}),(0,B.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),Sm=({size:e=20})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M10.68 13.31a16 16 0 003.41 2.6l1.27-1.27a2 2 0 012.11-.45 12.84 12.84 0 002.81.7 2 2 0 011.72 2v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07A19.42 19.42 0 013.07 8.62 19.79 19.79 0 01.1 2 2 2 0 012.11 0h3a2 2 0 012 1.72c.127.96.361 1.903.7 2.81a2 2 0 01-.45 2.11L6.18 7.84`}),(0,B.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),Cm=({size:e=18})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,B.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),wm=()=>(0,B.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,B.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),Tm=()=>(0,B.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M22 16.92v3a2 2 0 01-2.18 2 19.79 19.79 0 01-8.63-3.07 19.42 19.42 0 01-6.12-6.11A19.79 19.79 0 012 4.11 2 2 0 014.11 2h3a2 2 0 012 1.72c.13.96.37 1.91.71 2.81a2 2 0 01-.45 2.11L8.09 9.91a16 16 0 006 6l1.27-1.27a2 2 0 012.11-.45c.9.34 1.85.58 2.81.71A2 2 0 0122 16.92z`})}),Em=({className:e=``})=>(0,B.jsxs)(`svg`,{className:e,width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,B.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,B.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),Dm=({size:e=14})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 8V4H8`}),(0,B.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,B.jsx)(`path`,{d:`M2 14h2`}),(0,B.jsx)(`path`,{d:`M20 14h2`}),(0,B.jsx)(`path`,{d:`M15 13v2`}),(0,B.jsx)(`path`,{d:`M9 13v2`})]}),Om=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,B.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),km=({size:e=20,color:t=`currentColor`})=>(0,B.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:t}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:t}),(0,B.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:t})]}),Am=({size:e=20,color:t=`currentColor`})=>(0,B.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`path`,{d:`M22 11.5667C22 16.8499 17.5222 21.1334 12 21.1334C11.3507 21.1343 10.7032 21.0742 10.0654 20.9545C9.60633 20.8682 9.37678 20.8251 9.21653 20.8496C9.05627 20.8741 8.82918 20.9948 8.37499 21.2364C7.09014 21.9197 5.59195 22.161 4.15111 21.893C4.69874 21.2194 5.07275 20.4112 5.23778 19.5448C5.33778 19.0148 5.09 18.5 4.71889 18.1231C3.03333 16.4115 2 14.1051 2 11.5667C2 6.28357 6.47778 2 12 2C17.5222 2 22 6.28357 22 11.5667Z`,stroke:`white`,"stroke-width":`1.5`,"stroke-linejoin":`round`}),(0,B.jsx)(`path`,{d:`M11.9955 12H12.0045M15.991 12H16M8 12H8.00897`,stroke:`white`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]}),jm=()=>(0,B.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,B.jsx)(`path`,{d:`M16.7133 8.59374C18.1939 8.98463 19.2229 9.47922 20.1589 10.0848C21.5432 10.9804 22.1367 12.5944 21.9737 14.1517C21.9049 14.8099 21.3744 15.1246 20.7592 14.9544L19.3705 14.57C18.2697 14.2653 17.7193 14.1129 17.3837 13.71C17.0481 13.307 17.0086 12.751 16.9296 11.6391L16.7133 8.59374ZM16.7133 8.59374C13.7164 7.80255 10.2871 7.80163 7.28669 8.59374M7.28669 8.59374C5.80606 8.98463 4.77711 9.47923 3.84113 10.0848C2.45683 10.9804 1.86334 12.5944 2.02628 14.1517C2.09514 14.8099 2.62563 15.1246 3.24078 14.9544L4.62954 14.57C5.73032 14.2653 6.28071 14.1129 6.61631 13.71C6.95191 13.307 6.9914 12.751 7.07038 11.6391L7.28669 8.59374Z`,stroke:`#E30C12`,"stroke-width":`1.5`,"stroke-linejoin":`round`})}),Mm=({size:e=24})=>(0,B.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 19v3`}),(0,B.jsx)(`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`}),(0,B.jsx)(`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`}),(0,B.jsx)(`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`}),(0,B.jsx)(`path`,{d:`m2 2 20 20`}),(0,B.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`})]}),Nm=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),Pm=(e=``)=>String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),Fm=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),Im=/^https?:\/\//i;function Lm(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Fm.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;Im.test(e)&&(r.href=e),r.target=`_blank`,r.rel=`noopener noreferrer`}for(;n.attributes.length>0;)n.removeAttribute(n.attributes[0].name);for(let[e,t]of Object.entries(r))n.setAttribute(e,t);Lm(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Rm(e){let t=document.createElement(`div`);return t.innerHTML=e,Lm(t),t.innerHTML}function zm(e){let t=String(e||``).trim();if(!t)return t;let n=/^<p>\s*<strong>([\s\S]*?)<\/strong>\s*<\/p>$/i.exec(t);if(n&&!/<\/?strong\b/i.test(n[1]))return`<p>${n[1]}</p>`;let r=/^<strong>([\s\S]*?)<\/strong>$/i.exec(t);if(r&&!/<\/?strong\b/i.test(r[1])){let e=r[1].trim();return/^<(?:p|ul|ol)\b/i.test(e)?e:`<p>${e}</p>`}return e}var Bm=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return zm(Rm(t));let n=t.replace(/\r\n/g,`
|
|
34
34
|
`).replace(/\n{3,}/g,`
|
|
35
35
|
|
|
36
|
-
`).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>
|
|
37
|
-
`).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>/^[-*]\s+/.test(e));if(n.length>=2&&n.length===t.length)return`<ul>${n.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`;let i=e.split(/\s+(?=[-*]\s+\*\*?)/).map(e=>e.trim()).filter(Boolean);return i.length>=2&&i.every(e=>/^[-*]\s+/.test(e))?`<ul>${i.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`:`<p>${r(e).replace(/\n/g,`<br />`)}</p>`}).join(``))},Bm=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),Vm=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),Hm=`image/png,image/jpeg,.pdf,.docx`;function Um(e){if(!e)return!1;let t=typeof e.name==`string`?e.name.toLowerCase():``,n=t.includes(`.`)?`.${t.split(`.`).pop()}`:``,r=typeof e.type==`string`?e.type.toLowerCase():``;return r===`image/png`||r===`image/jpeg`||Bm.has(r)||Vm.has(n)}function Wm(e){return e?Um(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function Gm(e=0){if(!Number.isFinite(e)||e<=0)return``;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i)} ${t[r]}`}function Km(e){return e?e.name||`Attachment`:``}function qm(e){if(!e||typeof e!=`string`)return`?`;let t=e.trim();if(!t)return`?`;let n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[n.length-1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()}function Jm({src:e,name:t,imgStyle:n,initialsSpanStyle:r}){let[i,a]=(0,b.useState)(null),o=typeof e==`string`?e.trim():``;return(0,b.useEffect)(()=>{if(!o){a(null);return}a(null);let e=!1,t=new window.Image;return t.onload=()=>{e||a(o)},t.onerror=()=>{e||a(null)},t.src=o,()=>{e=!0}},[o]),i?(0,B.jsx)(`img`,{src:i,alt:``,style:n,onError:()=>a(null)}):(0,B.jsx)(`span`,{style:r,children:qm(t)})}function Ym({chatHistory:e,isAiTyping:t,isLoading:n,isAgentTyping:r,setReplyContext:i,primaryColor:a=`#3B82F6`,agentHeadshot:o=null,agentDisplayName:s=`Agent`,botAvatarNode:c=null}){let{resolvedConfig:l}=En(),u=(0,b.useRef)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),h=(0,b.useRef)(e.length),g=(0,b.useRef)(!0),_=(0,b.useRef)(null),v=(0,b.useCallback)(e=>{let t=e.target.closest(`a[href]`);if(!t)return;let n=t.getAttribute(`href`)||``;if(!(!n||n.startsWith(`mailto:`)||n.startsWith(`tel:`)||n.startsWith(`javascript:`)))try{let t=new URL(n,window.location.href);if(t.origin!==window.location.origin){e.preventDefault(),window.open(t.href,`_blank`,`noopener,noreferrer`);return}e.preventDefault(),_r(t.href,{siteId:l?.siteId,apiBaseUrl:l?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{e&&wr(n||t.href)})}catch{}},[l]),y=e=>{if(!e)return`just now`;let t=new Date,n=new Date(e),r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i} min${i>1?`s`:``} ago`;let a=Math.floor(i/60);if(a<24)return`${a} hr${a>1?`s`:``} ago`;let o=Math.floor(a/24);return`${o} day${o>1?`s`:``} ago`};return(0,b.useEffect)(()=>{if(g.current){g.current=!1,h.current=e.length,_.current&&(_.current.scrollTop=_.current.scrollHeight);return}let n=e.length>h.current;h.current=e.length,(n||t||r)&&u.current?.scrollIntoView({behavior:`smooth`})},[e.length,t,n,r]),(0,B.jsxs)(`div`,{ref:_,style:{flex:1,overflowY:`auto`,overscrollBehavior:`contain`,padding:`10px 16px 20px`,display:`flex`,flexDirection:`column`,background:`transparent`},children:[e.map(e=>{if(e.type===`call_recording`||typeof e.message==`string`&&e.message.includes(`AI chat recording`))return null;let t=e.sender===`system`,n=e.sender===`user`,r=e.sender===`ai`||e.sender===`bot`,l=e.sender===`agent`,u=e.isPending,d=e.type===`file`&&e.metadata?.fileUrl,h=e.agent_name||e.agentName||e.metadata?.agentName||s,g=typeof e.sender_headshot==`string`&&e.sender_headshot.trim()||typeof o==`string`&&o.trim()||null,_=Mm(e.replyToContent||e.replyContext?.message||``),b=e.replyToSender===`user`?`You`:e.replyToSender===`agent`?`Agent`:e.replyToSender===`ai`||e.replyToSender===`bot`?`AI Assistant`:`Message`;return t?(0,B.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,margin:`8px 0`},children:(0,B.jsx)(`div`,{style:{padding:`6px 12px`,borderRadius:`9999px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,fontWeight:500},children:e.message})},e.id):(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:n?`flex-end`:`flex-start`,alignItems:`flex-start`,marginBottom:`16px`,gap:`8px`,flexDirection:`row`},children:[!n&&(r||l)&&(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:l?`#f3f4f6`:c&&r?`transparent`:`var(--flowengage-primary)`,color:l?a:`#fff`,boxShadow:l?`0 2px 8px rgba(0,0,0,0.06)`:c&&r?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`,border:l?`1px solid ${a}22`:`none`,fontSize:`12px`,fontWeight:800,marginTop:!u&&(r||l)?`22px`:`0px`},children:r?c||(0,B.jsx)(Em,{size:16}):(0,B.jsx)(Jm,{src:g||``,name:h,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n?`flex-end`:`flex-start`,maxWidth:`75%`,minWidth:0},children:[!u&&l&&(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e),style:{opacity:1,marginBottom:`4px`,display:`flex`,alignItems:`center`,gap:`4px`,fontSize:`11px`,color:`#9ca3af`,background:`transparent`,border:0,cursor:`pointer`,padding:0,marginLeft:`2px`},onMouseEnter:e=>{e.currentTarget.style.color=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:[(0,B.jsx)(Cm,{}),`Reply`]}),(0,B.jsxs)(`div`,{style:{padding:`8px 16px`,borderRadius:n?`20px 6px 20px 20px`:`6px 20px 20px 20px`,lineHeight:1.8,letterSpacing:0,boxShadow:`0 2px 8px rgba(0,0,0,0.06)`,background:n?`var(--flowengage-primary)`:`rgba(255,255,255,0.92)`,color:n?`#fff`:`#111827`,fontSize:`14px`,fontWeight:400,opacity:u?.55:1,transition:`opacity 0.3s ease`,wordBreak:`break-word`,width:`fit-content`},children:[_&&(0,B.jsxs)(`div`,{style:{marginBottom:`8px`,borderRadius:`14px`,borderLeft:n?`2px solid rgba(255,255,255,0.8)`:`2px solid var(--flowengage-primary)`,padding:`8px 12px`,fontSize:`12px`,background:n?`rgba(255,255,255,0.15)`:`#f9fafb`,color:n?`rgba(255,255,255,0.9)`:`#6b7280`},children:[(0,B.jsx)(`div`,{style:{marginBottom:`2px`,fontWeight:600},children:b}),(0,B.jsx)(`div`,{style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:_})]}),d?(()=>{let t=e.metadata.fileType||``,r=e.metadata.fileName||e.message||`File`,i=Gm(e.metadata.fileSize),a=t.startsWith(`image/`),o=`shared file: ${r}`.toLowerCase(),s=(e.message||``).trim(),c=s&&s.toLowerCase()!==o&&!s.toLowerCase().startsWith(`shared file:`),l=t===`application/pdf`?{color:`#ef4444`,label:`PDF`}:t.includes(`word`)||t.includes(`docx`)?{color:`#3b82f6`,label:`DOCX`}:t.includes(`excel`)||t.includes(`sheet`)||t===`text/csv`?{color:`#10b981`,label:`XLSX`}:{color:`#6b7280`,label:`FILE`};return(0,B.jsxs)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children:[c&&(0,B.jsx)(`div`,{style:{marginBottom:`6px`,fontSize:`14px`,color:n?`#fff`:`#111827`,whiteSpace:`normal`,wordBreak:`break-word`},children:s}),a?(0,B.jsx)(`button`,{type:`button`,onClick:()=>f({url:e.metadata.fileUrl,name:r}),onMouseEnter:()=>m(e.id),onMouseLeave:()=>m(null),style:{display:`block`,width:`100%`,background:`transparent`,border:0,padding:0,margin:0,textAlign:`left`,cursor:`pointer`},children:(0,B.jsxs)(`div`,{style:{position:`relative`},children:[(0,B.jsx)(`img`,{src:e.metadata.fileUrl,alt:r,style:{width:`100%`,borderRadius:`10px`,display:`block`,maxHeight:`180px`,objectFit:`cover`}}),(0,B.jsx)(`div`,{style:{position:`absolute`,inset:0,borderRadius:`10px`,background:p===e.id?`rgba(17,24,39,0.32)`:`rgba(17,24,39,0)`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#fff`,fontSize:`13px`,fontWeight:700,letterSpacing:`0.02em`,opacity:p===e.id?1:0,transition:`background 0.18s ease, opacity 0.18s ease`,pointerEvents:`none`},children:`Preview`})]})}):(0,B.jsx)(`a`,{href:e.metadata.fileUrl,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:`none`,display:`block`},children:(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,background:n?`rgba(255,255,255,0.15)`:`#f3f4f6`,borderRadius:`12px`,padding:`10px 12px`},children:[(0,B.jsxs)(`div`,{style:{width:`38px`,height:`46px`,borderRadius:`8px`,background:n?`rgba(255,255,255,0.22)`:`#fff`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,flexShrink:0,boxShadow:`0 1px 4px rgba(0,0,0,0.1)`,gap:`3px`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`#fff`:l.color,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,B.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,B.jsx)(`span`,{style:{fontSize:`7px`,fontWeight:800,letterSpacing:`0.04em`,color:n?`#fff`:l.color,lineHeight:1},children:l.label})]}),(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:n?`#fff`:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&(0,B.jsx)(`div`,{style:{fontSize:`11px`,marginTop:`3px`,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]}),(0,B.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`rgba(255,255,255,0.65)`:`#9ca3af`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,B.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,B.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,B.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})]})})]})})():r?(0,B.jsx)(`div`,{className:`flowengage-message-content fe-bot-message`,dangerouslySetInnerHTML:{__html:zm(e.message)},onClick:v}):(0,B.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e.message})]}),(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,marginTop:`4px`,padding:`0 4px`,alignSelf:n?`flex-end`:`flex-start`},children:u?(0,B.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500,fontStyle:`italic`},children:`sending…`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500},children:y(e.timestamp||e.createdAt)}),(0,B.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:700,color:n?`var(--flowengage-primary)`:`#9ca3af`},children:`✓`})]})})]})]},e.id)}),(t||n)&&(0,B.jsxs)(`div`,{style:{marginBottom:`16px`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:c?`transparent`:`var(--flowengage-primary)`,color:`#fff`,boxShadow:c?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`},children:c||(0,B.jsx)(Em,{size:16})}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,color:`#374151`,fontSize:`13px`,fontWeight:500,fontStyle:`italic`},children:[`Analysing`,[0,1,2].map(e=>(0,B.jsx)(`span`,{style:{animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`},children:`.`},e))]})]}),r&&(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,marginBottom:`12px`},children:[(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,overflow:`hidden`},children:(0,B.jsx)(Jm,{src:o||``,name:s,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,B.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})]}),(0,B.jsx)(`div`,{ref:u}),d&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>f(null),style:{position:`fixed`,inset:0,zIndex:1e4,border:0,padding:`16px`,margin:0,background:`rgba(2,6,23,0.88)`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`default`},children:(0,B.jsxs)(`div`,{style:{position:`relative`,maxWidth:`min(96vw, 1100px)`,maxHeight:`96vh`,width:`100%`,display:`flex`,flexDirection:`column`,gap:`10px`,alignItems:`center`},children:[(0,B.jsx)(`img`,{src:d.url,alt:d.name,style:{width:`100%`,maxHeight:`calc(96vh - 72px)`,objectFit:`contain`,borderRadius:`16px`,boxShadow:`0 30px 80px rgba(0,0,0,0.42)`}}),(0,B.jsx)(`div`,{style:{maxWidth:`100%`,padding:`8px 14px`,borderRadius:`9999px`,background:`rgba(255,255,255,0.92)`,color:`#0f172a`,fontSize:`12px`,fontWeight:600,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:d.name})]})})]})}var Xm=typeof window<`u`&&(window.matchMedia?.(`(pointer: coarse)`).matches||navigator.maxTouchPoints>0);function Zm({input:e,setInput:t,onSubmit:n,isConversationEnded:r,callUiActive:i,handleToggleVoice:a,activeScreen:o,inputDisabled:s,replyContext:c,clearReplyContext:l,requiresEmail:u,emailInput:d,setEmailInput:f,emailError:p,showVoiceToggle:m=!1,voiceEnabled:h=!0,onFileSelect:g,selectedFile:_=null,onRemoveSelectedFile:v,attachmentError:y=``,isUploadingAttachment:x=!1,inputPlaceholder:S=`Type your message`}){let C=(0,b.useRef)(null),w=(0,b.useRef)(null),ee=e=>{e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};(0,b.useEffect)(()=>{u||ee(w.current)},[e,u]);let T=e=>{e.key===`Enter`&&(Xm||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit()))},te=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,ne=u?!!d?.trim():!!e?.trim()||!!_,re=s||x||!ne,E=!u&&h&&m;return(0,B.jsxs)(`div`,{style:{padding:`0 16px`,background:`transparent`},children:[c&&(0,B.jsxs)(`div`,{style:{marginBottom:`8px`,display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.05)`,background:`#fff`,padding:`12px 16px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0,flex:1,borderLeft:`2px solid var(--flowengage-primary)`,paddingLeft:`12px`},children:[(0,B.jsxs)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`},children:[`Replying to `,te]}),(0,B.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`12px`,color:`#6b7280`},children:c.replyToContent||c.message})]}),(0,B.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`},onClick:l,"aria-label":`Cancel reply`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),u&&(0,B.jsx)(`div`,{style:{marginBottom:`8px`,padding:`0 8px`},children:(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`#111827`,fontSize:`14px`,fontWeight:500,textAlign:`center`},children:[(0,B.jsx)(`span`,{style:{display:`inline-flex`,width:`22px`,height:`22px`,borderRadius:`9999px`,alignItems:`center`,justifyContent:`center`,background:`rgba(59,130,246,0.08)`,color:`var(--flowengage-primary)`},children:(0,B.jsx)(Em,{size:13})}),(0,B.jsx)(`span`,{children:`Please provide your email address so we can help you.`})]})}),_&&!u&&(0,B.jsxs)(`div`,{style:{marginBottom:`10px`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.06)`,background:`#fff`,padding:`12px 14px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,B.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`,marginBottom:`2px`},children:`Attachment ready`}),(0,B.jsx)(`div`,{style:{fontSize:`13px`,color:`#111827`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:Km(_)}),(0,B.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:Gm(_.size)})]}),(0,B.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`,flexShrink:0},onClick:v,"aria-label":`Remove attachment`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),(0,B.jsxs)(`form`,{style:{display:`flex`,alignItems:`flex-end`,gap:`8px`,minHeight:`40px`,padding:`4px`,border:`1px solid rgba(0,0,0,0.06)`,borderRadius:`20px`,background:`#fff`,boxShadow:`0 4px 14px rgba(0,0,0,0.04)`,opacity:1},onSubmit:n,children:[E?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:C,type:`file`,accept:Hm,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&g?.(t),e.target.value=``}}),(0,B.jsx)(`button`,{type:`button`,style:{width:`32px`,height:`32px`,borderRadius:`9999px`,background:`#f3f4f8`,color:`var(--flowengage-primary)`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.2s ease, opacity 0.2s ease`,border:0,cursor:`pointer`,flexShrink:0},onClick:()=>C.current?.click(),title:`Attach file`,"aria-label":`Attach file`,disabled:x,onMouseEnter:e=>{e.currentTarget.style.opacity=`0.8`},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,B.jsx)(Dm,{size:16,color:`currentColor`})})]}):null,u?(0,B.jsx)(`input`,{className:`flowengage-chat-text-input`,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,outline:`none`,padding:0,paddingLeft:E?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,alignSelf:`center`},value:d,onChange:e=>f(e.target.value),placeholder:`Enter your Email`,disabled:s,type:`email`,autoComplete:`email`}):(0,B.jsx)(`textarea`,{ref:w,className:`flowengage-chat-text-input`,rows:1,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,lineHeight:`20px`,outline:`none`,padding:`6px 0`,paddingLeft:E?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,resize:`none`,maxHeight:`120px`,overflowY:`auto`},value:e,onChange:e=>{t(e.target.value),ee(e.target)},onKeyDown:T,placeholder:o===`agent`?`Message the agent…`:S,disabled:s,autoComplete:`off`}),(0,B.jsx)(`button`,{type:`submit`,style:{width:`32px`,height:`32px`,borderRadius:`9999px`,background:`var(--flowengage-primary)`,color:`#fff`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`opacity 0.2s ease`,cursor:re?`not-allowed`:`pointer`,opacity:re?.45:1,flexShrink:0},disabled:re,onMouseEnter:e=>{re||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,B.jsx)(Sm,{size:16})})]}),!u&&y&&(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`7px 4px 0`},children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#dc2626`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,B.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,B.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,B.jsx)(`span`,{style:{fontSize:`11px`,color:`#dc2626`,fontWeight:500},children:y})]}),u&&p&&(0,B.jsx)(`div`,{style:{padding:`8px 16px 0`,fontSize:`12px`,fontWeight:500,color:`#f43f5e`},children:p})]})}function Qm({webRTCError:e,micError:t,setMicError:n,dismissCallError:r,isRateLimited:i,rateLimitMessage:a}){return(0,B.jsxs)(B.Fragment,{children:[(e||t)&&(0,B.jsxs)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,borderRadius:`12px`,background:`#fef2f2`,border:`1px solid #fee2e2`,display:`flex`,alignItems:`flex-start`,gap:`10px`},children:[(0,B.jsx)(Tm,{className:``}),(0,B.jsx)(`span`,{style:{fontSize:`12px`,color:`#b91c1c`,lineHeight:1.5,flex:1},children:e||t}),(0,B.jsx)(`button`,{style:{flexShrink:0,background:`transparent`,border:0,color:`#f87171`,cursor:`pointer`,fontSize:`18px`,lineHeight:1},onClick:()=>{n(null),r()},onMouseEnter:e=>{e.currentTarget.style.color=`#dc2626`},onMouseLeave:e=>{e.currentTarget.style.color=`#f87171`},children:`×`})]}),i&&(0,B.jsx)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,fontSize:`13px`,borderRadius:`12px`,background:`#fee2e2`,color:`#991b1b`},children:a})]})}var $m=[`#135bd8`,`#ef334b`,`#ffbd2e`];function eh(e){return!Array.isArray(e)||e.length===0?$m:e.length===1?[e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0]]:[e[0],e[1],e[2]]}var th={idle:3,listening:.75,thinking:1,speaking:1.4,muted:.75,error:.08};function nh(e){if(!e||typeof e!=`string`)return[0,0,0];let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;return[parseInt(n.slice(0,2),16)/255,parseInt(n.slice(2,4),16)/255,parseInt(n.slice(4,6),16)/255]}function rh(e,t){if(!e||typeof e!=`string`)return`rgba(0,0,0,${t})`;if(e.startsWith(`rgb`))return e.replace(/[\d.]+\)$/,`${t})`);let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}var ih=`
|
|
36
|
+
`).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>Pm(e).replace(/\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/g,`<a href="$2" target="_blank" rel="noopener noreferrer">$1</a>`).replace(/\*\*([^*]+)\*\*/g,`<strong>$1</strong>`).replace(/\*([^*\n]+)\*/g,`<em>$1</em>`);return zm(n.map(e=>{let t=e.split(`
|
|
37
|
+
`).map(e=>e.trim()).filter(Boolean),n=t.filter(e=>/^[-*]\s+/.test(e));if(n.length>=2&&n.length===t.length)return`<ul>${n.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`;let i=e.split(/\s+(?=[-*]\s+\*\*?)/).map(e=>e.trim()).filter(Boolean);return i.length>=2&&i.every(e=>/^[-*]\s+/.test(e))?`<ul>${i.map(e=>`<li>${r(e.replace(/^[-*]\s+/,``))}</li>`).join(``)}</ul>`:`<p>${r(e).replace(/\n/g,`<br />`)}</p>`}).join(``))},Vm=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),Hm=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),Um=`image/png,image/jpeg,.pdf,.docx`;function Wm(e){if(!e)return!1;let t=typeof e.name==`string`?e.name.toLowerCase():``,n=t.includes(`.`)?`.${t.split(`.`).pop()}`:``,r=typeof e.type==`string`?e.type.toLowerCase():``;return r===`image/png`||r===`image/jpeg`||Vm.has(r)||Hm.has(n)}function Gm(e){return e?Wm(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function Km(e=0){if(!Number.isFinite(e)||e<=0)return``;let t=[`B`,`KB`,`MB`,`GB`],n=e,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r+=1;let i=n>=10||r===0?0:1;return`${n.toFixed(i)} ${t[r]}`}function qm(e){return e?e.name||`Attachment`:``}function Jm(e){if(!e||typeof e!=`string`)return`?`;let t=e.trim();if(!t)return`?`;let n=t.split(/\s+/).filter(Boolean);return n.length>=2?`${n[0][0]}${n[n.length-1][0]}`.toUpperCase():t.slice(0,2).toUpperCase()}function Ym({src:e,name:t,imgStyle:n,initialsSpanStyle:r}){let[i,a]=(0,b.useState)(null),o=typeof e==`string`?e.trim():``;return(0,b.useEffect)(()=>{if(!o){a(null);return}a(null);let e=!1,t=new window.Image;return t.onload=()=>{e||a(o)},t.onerror=()=>{e||a(null)},t.src=o,()=>{e=!0}},[o]),i?(0,B.jsx)(`img`,{src:i,alt:``,style:n,onError:()=>a(null)}):(0,B.jsx)(`span`,{style:r,children:Jm(t)})}function Xm({chatHistory:e,isAiTyping:t,isLoading:n,isAgentTyping:r,setReplyContext:i,primaryColor:a=`#3B82F6`,agentHeadshot:o=null,agentDisplayName:s=`Agent`,botAvatarNode:c=null}){let{resolvedConfig:l}=En(),u=(0,b.useRef)(null),[d,f]=(0,b.useState)(null),[p,m]=(0,b.useState)(null),h=(0,b.useRef)(e.length),g=(0,b.useRef)(!0),_=(0,b.useRef)(null),v=(0,b.useCallback)(e=>{let t=e.target.closest(`a[href]`);if(!t)return;let n=t.getAttribute(`href`)||``;if(!(!n||n.startsWith(`mailto:`)||n.startsWith(`tel:`)||n.startsWith(`javascript:`)))try{let t=new URL(n,window.location.href);if(t.origin!==window.location.origin){e.preventDefault(),window.open(t.href,`_blank`,`noopener,noreferrer`);return}e.preventDefault(),_r(t.href,{siteId:l?.siteId,apiBaseUrl:l?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{e&&wr(n||t.href)})}catch{}},[l]),y=e=>{if(!e)return`just now`;let t=new Date,n=new Date(e),r=Math.max(0,Math.floor((t-n)/1e3));if(r<60)return`just now`;let i=Math.floor(r/60);if(i<60)return`${i} min${i>1?`s`:``} ago`;let a=Math.floor(i/60);if(a<24)return`${a} hr${a>1?`s`:``} ago`;let o=Math.floor(a/24);return`${o} day${o>1?`s`:``} ago`};return(0,b.useEffect)(()=>{if(g.current){g.current=!1,h.current=e.length,_.current&&(_.current.scrollTop=_.current.scrollHeight);return}let n=e.length>h.current;h.current=e.length,(n||t||r)&&u.current?.scrollIntoView({behavior:`smooth`})},[e.length,t,n,r]),(0,B.jsxs)(`div`,{ref:_,style:{flex:1,overflowY:`auto`,overscrollBehavior:`contain`,padding:`10px 16px 20px`,display:`flex`,flexDirection:`column`,background:`transparent`},children:[e.map(e=>{if(e.type===`call_recording`||typeof e.message==`string`&&e.message.includes(`AI chat recording`))return null;let t=e.sender===`system`,n=e.sender===`user`,r=e.sender===`ai`||e.sender===`bot`,l=e.sender===`agent`,u=e.isPending,d=e.type===`file`&&e.metadata?.fileUrl,h=e.agent_name||e.agentName||e.metadata?.agentName||s,g=typeof e.sender_headshot==`string`&&e.sender_headshot.trim()||typeof o==`string`&&o.trim()||null,_=Nm(e.replyToContent||e.replyContext?.message||``),b=e.replyToSender===`user`?`You`:e.replyToSender===`agent`?`Agent`:e.replyToSender===`ai`||e.replyToSender===`bot`?`AI Assistant`:`Message`;return t?(0,B.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,margin:`8px 0`},children:(0,B.jsx)(`div`,{style:{padding:`6px 12px`,borderRadius:`9999px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,fontWeight:500},children:e.message})},e.id):(0,B.jsxs)(`div`,{style:{display:`flex`,justifyContent:n?`flex-end`:`flex-start`,alignItems:`flex-start`,marginBottom:`16px`,gap:`8px`,flexDirection:`row`},children:[!n&&(r||l)&&(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:l?`#f3f4f6`:c&&r?`transparent`:`var(--flowengage-primary)`,color:l?a:`#fff`,boxShadow:l?`0 2px 8px rgba(0,0,0,0.06)`:c&&r?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`,border:l?`1px solid ${a}22`:`none`,fontSize:`12px`,fontWeight:800,marginTop:!u&&(r||l)?`22px`:`0px`},children:r?c||(0,B.jsx)(Dm,{size:16}):(0,B.jsx)(Ym,{src:g||``,name:h,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n?`flex-end`:`flex-start`,maxWidth:`75%`,minWidth:0},children:[!u&&l&&(0,B.jsxs)(`button`,{type:`button`,onClick:()=>i(e),style:{opacity:1,marginBottom:`4px`,display:`flex`,alignItems:`center`,gap:`4px`,fontSize:`11px`,color:`#9ca3af`,background:`transparent`,border:0,cursor:`pointer`,padding:0,marginLeft:`2px`},onMouseEnter:e=>{e.currentTarget.style.color=`#4b5563`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:[(0,B.jsx)(wm,{}),`Reply`]}),(0,B.jsxs)(`div`,{style:{padding:`8px 16px`,borderRadius:n?`20px 6px 20px 20px`:`6px 20px 20px 20px`,lineHeight:1.8,letterSpacing:0,boxShadow:`0 2px 8px rgba(0,0,0,0.06)`,background:n?`var(--flowengage-primary)`:`rgba(255,255,255,0.92)`,color:n?`#fff`:`#111827`,fontSize:`14px`,fontWeight:400,opacity:u?.55:1,transition:`opacity 0.3s ease`,wordBreak:`break-word`,width:`fit-content`},children:[_&&(0,B.jsxs)(`div`,{style:{marginBottom:`8px`,borderRadius:`14px`,borderLeft:n?`2px solid rgba(255,255,255,0.8)`:`2px solid var(--flowengage-primary)`,padding:`8px 12px`,fontSize:`12px`,background:n?`rgba(255,255,255,0.15)`:`#f9fafb`,color:n?`rgba(255,255,255,0.9)`:`#6b7280`},children:[(0,B.jsx)(`div`,{style:{marginBottom:`2px`,fontWeight:600},children:b}),(0,B.jsx)(`div`,{style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:_})]}),d?(()=>{let t=e.metadata.fileType||``,r=e.metadata.fileName||e.message||`File`,i=Km(e.metadata.fileSize),a=t.startsWith(`image/`),o=`shared file: ${r}`.toLowerCase(),s=(e.message||``).trim(),c=s&&s.toLowerCase()!==o&&!s.toLowerCase().startsWith(`shared file:`),l=t===`application/pdf`?{color:`#ef4444`,label:`PDF`}:t.includes(`word`)||t.includes(`docx`)?{color:`#3b82f6`,label:`DOCX`}:t.includes(`excel`)||t.includes(`sheet`)||t===`text/csv`?{color:`#10b981`,label:`XLSX`}:{color:`#6b7280`,label:`FILE`};return(0,B.jsxs)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children:[c&&(0,B.jsx)(`div`,{style:{marginBottom:`6px`,fontSize:`14px`,color:n?`#fff`:`#111827`,whiteSpace:`normal`,wordBreak:`break-word`},children:s}),a?(0,B.jsx)(`button`,{type:`button`,onClick:()=>f({url:e.metadata.fileUrl,name:r}),onMouseEnter:()=>m(e.id),onMouseLeave:()=>m(null),style:{display:`block`,width:`100%`,background:`transparent`,border:0,padding:0,margin:0,textAlign:`left`,cursor:`pointer`},children:(0,B.jsxs)(`div`,{style:{position:`relative`},children:[(0,B.jsx)(`img`,{src:e.metadata.fileUrl,alt:r,style:{width:`100%`,borderRadius:`10px`,display:`block`,maxHeight:`180px`,objectFit:`cover`}}),(0,B.jsx)(`div`,{style:{position:`absolute`,inset:0,borderRadius:`10px`,background:p===e.id?`rgba(17,24,39,0.32)`:`rgba(17,24,39,0)`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#fff`,fontSize:`13px`,fontWeight:700,letterSpacing:`0.02em`,opacity:p===e.id?1:0,transition:`background 0.18s ease, opacity 0.18s ease`,pointerEvents:`none`},children:`Preview`})]})}):(0,B.jsx)(`a`,{href:e.metadata.fileUrl,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:`none`,display:`block`},children:(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`10px`,background:n?`rgba(255,255,255,0.15)`:`#f3f4f6`,borderRadius:`12px`,padding:`10px 12px`},children:[(0,B.jsxs)(`div`,{style:{width:`38px`,height:`46px`,borderRadius:`8px`,background:n?`rgba(255,255,255,0.22)`:`#fff`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,flexShrink:0,boxShadow:`0 1px 4px rgba(0,0,0,0.1)`,gap:`3px`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`#fff`:l.color,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,B.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,B.jsx)(`span`,{style:{fontSize:`7px`,fontWeight:800,letterSpacing:`0.04em`,color:n?`#fff`:l.color,lineHeight:1},children:l.label})]}),(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:n?`#fff`:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&(0,B.jsx)(`div`,{style:{fontSize:`11px`,marginTop:`3px`,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]}),(0,B.jsxs)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:n?`rgba(255,255,255,0.65)`:`#9ca3af`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,B.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,B.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,B.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})]})})]})})():r?(0,B.jsx)(`div`,{className:`flowengage-message-content fe-bot-message`,dangerouslySetInnerHTML:{__html:Bm(e.message)},onClick:v}):(0,B.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e.message})]}),(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,marginTop:`4px`,padding:`0 4px`,alignSelf:n?`flex-end`:`flex-start`},children:u?(0,B.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500,fontStyle:`italic`},children:`sending…`}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500},children:y(e.timestamp||e.createdAt)}),(0,B.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:700,color:n?`var(--flowengage-primary)`:`#9ca3af`},children:`✓`})]})})]})]},e.id)}),(t||n)&&(0,B.jsxs)(`div`,{style:{marginBottom:`16px`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,background:c?`transparent`:`var(--flowengage-primary)`,color:`#fff`,boxShadow:c?`none`:`0 8px 20px rgba(59,130,246,0.24)`,overflow:`hidden`},children:c||(0,B.jsx)(Dm,{size:16})}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`2px`,color:`#374151`,fontSize:`13px`,fontWeight:500,fontStyle:`italic`},children:[`Analysing`,[0,1,2].map(e=>(0,B.jsx)(`span`,{style:{animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`},children:`.`},e))]})]}),r&&(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,marginBottom:`12px`},children:[(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,overflow:`hidden`},children:(0,B.jsx)(Ym,{src:o||``,name:s,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,B.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})]}),(0,B.jsx)(`div`,{ref:u}),d&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>f(null),style:{position:`fixed`,inset:0,zIndex:1e4,border:0,padding:`16px`,margin:0,background:`rgba(2,6,23,0.88)`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`default`},children:(0,B.jsxs)(`div`,{style:{position:`relative`,maxWidth:`min(96vw, 1100px)`,maxHeight:`96vh`,width:`100%`,display:`flex`,flexDirection:`column`,gap:`10px`,alignItems:`center`},children:[(0,B.jsx)(`img`,{src:d.url,alt:d.name,style:{width:`100%`,maxHeight:`calc(96vh - 72px)`,objectFit:`contain`,borderRadius:`16px`,boxShadow:`0 30px 80px rgba(0,0,0,0.42)`}}),(0,B.jsx)(`div`,{style:{maxWidth:`100%`,padding:`8px 14px`,borderRadius:`9999px`,background:`rgba(255,255,255,0.92)`,color:`#0f172a`,fontSize:`12px`,fontWeight:600,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:d.name})]})})]})}var Zm=typeof window<`u`&&(window.matchMedia?.(`(pointer: coarse)`).matches||navigator.maxTouchPoints>0);function Qm({input:e,setInput:t,onSubmit:n,isConversationEnded:r,callUiActive:i,handleToggleVoice:a,activeScreen:o,inputDisabled:s,replyContext:c,clearReplyContext:l,requiresEmail:u,emailInput:d,setEmailInput:f,emailError:p,showVoiceToggle:m=!1,voiceEnabled:h=!0,onFileSelect:g,selectedFile:_=null,onRemoveSelectedFile:v,attachmentError:y=``,isUploadingAttachment:x=!1,inputPlaceholder:S=`Type your message`}){let C=(0,b.useRef)(null),w=(0,b.useRef)(null),ee=e=>{e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};(0,b.useEffect)(()=>{u||ee(w.current)},[e,u]);let T=e=>{e.key===`Enter`&&(Zm||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit()))},te=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,ne=u?!!d?.trim():!!e?.trim()||!!_,re=s||x||!ne,E=!u&&h&&m;return(0,B.jsxs)(`div`,{style:{padding:`0 16px`,background:`transparent`},children:[c&&(0,B.jsxs)(`div`,{style:{marginBottom:`8px`,display:`flex`,alignItems:`flex-start`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.05)`,background:`#fff`,padding:`12px 16px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0,flex:1,borderLeft:`2px solid var(--flowengage-primary)`,paddingLeft:`12px`},children:[(0,B.jsxs)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`},children:[`Replying to `,te]}),(0,B.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`12px`,color:`#6b7280`},children:c.replyToContent||c.message})]}),(0,B.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`},onClick:l,"aria-label":`Cancel reply`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),u&&(0,B.jsx)(`div`,{style:{marginBottom:`8px`,padding:`0 8px`},children:(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`#111827`,fontSize:`14px`,fontWeight:500,textAlign:`center`},children:[(0,B.jsx)(`span`,{style:{display:`inline-flex`,width:`22px`,height:`22px`,borderRadius:`9999px`,alignItems:`center`,justifyContent:`center`,background:`rgba(59,130,246,0.08)`,color:`var(--flowengage-primary)`},children:(0,B.jsx)(Dm,{size:13})}),(0,B.jsx)(`span`,{children:`Please provide your email address so we can help you.`})]})}),_&&!u&&(0,B.jsxs)(`div`,{style:{marginBottom:`10px`,display:`flex`,alignItems:`center`,justifyContent:`space-between`,gap:`12px`,borderRadius:`16px`,border:`1px solid rgba(0,0,0,0.06)`,background:`#fff`,padding:`12px 14px`,boxShadow:`0 8px 24px rgba(0,0,0,0.05)`},children:[(0,B.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,B.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`,marginBottom:`2px`},children:`Attachment ready`}),(0,B.jsx)(`div`,{style:{fontSize:`13px`,color:`#111827`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:qm(_)}),(0,B.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:Km(_.size)})]}),(0,B.jsx)(`button`,{type:`button`,style:{width:`28px`,height:`28px`,borderRadius:`9999px`,border:0,background:`#f3f4f6`,color:`#6b7280`,transition:`color 0.2s ease, background 0.2s ease`,cursor:`pointer`,flexShrink:0},onClick:v,"aria-label":`Remove attachment`,onMouseEnter:e=>{e.currentTarget.style.background=`#e5e7eb`,e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.background=`#f3f4f6`,e.currentTarget.style.color=`#6b7280`},children:`×`})]}),(0,B.jsxs)(`form`,{style:{display:`flex`,alignItems:`flex-end`,gap:`8px`,minHeight:`40px`,padding:`4px`,border:`1px solid rgba(0,0,0,0.06)`,borderRadius:`20px`,background:`#fff`,boxShadow:`0 4px 14px rgba(0,0,0,0.04)`,opacity:1},onSubmit:n,children:[E?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:C,type:`file`,accept:Um,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&g?.(t),e.target.value=``}}),(0,B.jsx)(`button`,{type:`button`,style:{width:`32px`,height:`32px`,borderRadius:`9999px`,background:`#f3f4f8`,color:`var(--flowengage-primary)`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`background 0.2s ease, opacity 0.2s ease`,border:0,cursor:`pointer`,flexShrink:0},onClick:()=>C.current?.click(),title:`Attach file`,"aria-label":`Attach file`,disabled:x,onMouseEnter:e=>{e.currentTarget.style.opacity=`0.8`},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,B.jsx)(Om,{size:16,color:`currentColor`})})]}):null,u?(0,B.jsx)(`input`,{className:`flowengage-chat-text-input`,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,outline:`none`,padding:0,paddingLeft:E?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,alignSelf:`center`},value:d,onChange:e=>f(e.target.value),placeholder:`Enter your Email`,disabled:s,type:`email`,autoComplete:`email`}):(0,B.jsx)(`textarea`,{ref:w,className:`flowengage-chat-text-input`,rows:1,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,lineHeight:`20px`,outline:`none`,padding:`6px 0`,paddingLeft:E?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,resize:`none`,maxHeight:`120px`,overflowY:`auto`},value:e,onChange:e=>{t(e.target.value),ee(e.target)},onKeyDown:T,placeholder:o===`agent`?`Message the agent…`:S,disabled:s,autoComplete:`off`}),(0,B.jsx)(`button`,{type:`submit`,style:{width:`32px`,height:`32px`,borderRadius:`9999px`,background:`var(--flowengage-primary)`,color:`#fff`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,transition:`opacity 0.2s ease`,cursor:re?`not-allowed`:`pointer`,opacity:re?.45:1,flexShrink:0},disabled:re,onMouseEnter:e=>{re||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,B.jsx)(Cm,{size:16})})]}),!u&&y&&(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`7px 4px 0`},children:[(0,B.jsxs)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#dc2626`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,B.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,B.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,B.jsx)(`span`,{style:{fontSize:`11px`,color:`#dc2626`,fontWeight:500},children:y})]}),u&&p&&(0,B.jsx)(`div`,{style:{padding:`8px 16px 0`,fontSize:`12px`,fontWeight:500,color:`#f43f5e`},children:p})]})}function $m({webRTCError:e,micError:t,setMicError:n,dismissCallError:r,isRateLimited:i,rateLimitMessage:a}){return(0,B.jsxs)(B.Fragment,{children:[(e||t)&&(0,B.jsxs)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,borderRadius:`12px`,background:`#fef2f2`,border:`1px solid #fee2e2`,display:`flex`,alignItems:`flex-start`,gap:`10px`},children:[(0,B.jsx)(Em,{className:``}),(0,B.jsx)(`span`,{style:{fontSize:`12px`,color:`#b91c1c`,lineHeight:1.5,flex:1},children:e||t}),(0,B.jsx)(`button`,{style:{flexShrink:0,background:`transparent`,border:0,color:`#f87171`,cursor:`pointer`,fontSize:`18px`,lineHeight:1},onClick:()=>{n(null),r()},onMouseEnter:e=>{e.currentTarget.style.color=`#dc2626`},onMouseLeave:e=>{e.currentTarget.style.color=`#f87171`},children:`×`})]}),i&&(0,B.jsx)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,fontSize:`13px`,borderRadius:`12px`,background:`#fee2e2`,color:`#991b1b`},children:a})]})}var eh=[`#135bd8`,`#ef334b`,`#ffbd2e`];function th(e){return!Array.isArray(e)||e.length===0?eh:e.length===1?[e[0],e[0],e[0]]:e.length===2?[e[0],e[1],e[0]]:[e[0],e[1],e[2]]}var nh={idle:3,listening:.75,thinking:1,speaking:1.4,muted:.75,error:.08};function rh(e){if(!e||typeof e!=`string`)return[0,0,0];let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;return[parseInt(n.slice(0,2),16)/255,parseInt(n.slice(2,4),16)/255,parseInt(n.slice(4,6),16)/255]}function ih(e,t){if(!e||typeof e!=`string`)return`rgba(0,0,0,${t})`;if(e.startsWith(`rgb`))return e.replace(/[\d.]+\)$/,`${t})`);let n=e.replace(`#`,``),r=n.length===3?n.split(``).map(e=>e+e).join(``):n;return`rgba(${parseInt(r.slice(0,2),16)},${parseInt(r.slice(2,4),16)},${parseInt(r.slice(4,6),16)},${t})`}var ah=`
|
|
38
38
|
attribute vec2 a_pos;
|
|
39
39
|
varying vec2 v_uv;
|
|
40
40
|
void main() {
|
|
41
41
|
v_uv = a_pos * 0.5 + 0.5;
|
|
42
42
|
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
43
43
|
}
|
|
44
|
-
`,
|
|
44
|
+
`,oh=`
|
|
45
45
|
precision highp float;
|
|
46
46
|
|
|
47
47
|
varying vec2 v_uv;
|
|
@@ -156,7 +156,7 @@ Error generating stack: `+e.message+`
|
|
|
156
156
|
|
|
157
157
|
gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
|
|
158
158
|
}
|
|
159
|
-
`;function
|
|
159
|
+
`;function sh(e,t,n){let r=(t,n)=>{let r=e.createShader(t);return e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`[AnimatedOrb shader]`,e.getShaderInfoLog(r)),null)},i=r(e.VERTEX_SHADER,t),a=r(e.FRAGMENT_SHADER,n);if(!i||!a)return null;let o=e.createProgram();return e.attachShader(o,i),e.attachShader(o,a),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?o:(console.error(`[AnimatedOrb link]`,e.getProgramInfoLog(o)),null)}function ch({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=th(r),u=t===`speaking`,d=e<=50,f=(0,b.useRef)(null),p=(0,b.useRef)(nh[t]??.35);(0,b.useEffect)(()=>{p.current=nh[t]??.35},[t]),(0,b.useEffect)(()=>{let t=f.current;if(!t)return;let n=Math.min(window.devicePixelRatio||1,2);t.width=e*n,t.height=e*n;let r=t.getContext(`webgl`,{alpha:!0,antialias:!0})||t.getContext(`experimental-webgl`,{alpha:!0,antialias:!0});if(!r){console.warn(`[AnimatedOrb] WebGL unavailable.`);return}let i=sh(r,ah,oh);if(!i){console.error(`[AnimatedOrb] WebGL program failed to compile/link`);return}r.useProgram(i);let a=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,a),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW);let o=r.getAttribLocation(i,`a_pos`);r.enableVertexAttribArray(o),r.vertexAttribPointer(o,2,r.FLOAT,!1,0,0);let u={time:r.getUniformLocation(i,`u_time`),speed:r.getUniformLocation(i,`u_speed`),c1:r.getUniformLocation(i,`u_c1`),c2:r.getUniformLocation(i,`u_c2`),c3:r.getUniformLocation(i,`u_c3`)};r.uniform3fv(u.c1,rh(s)),r.uniform3fv(u.c2,rh(c)),r.uniform3fv(u.c3,rh(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),m,h=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,p.current),r.drawArrays(r.TRIANGLES,0,6),m=requestAnimationFrame(h)};return m=requestAnimationFrame(h),()=>{cancelAnimationFrame(m),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let m=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,B.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!d&&(0,B.jsx)(dm.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${ih(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,B.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:m,transition:`filter 1.2s ease`},children:(0,B.jsx)(`canvas`,{ref:f,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,B.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,B.jsx)(dm.div,{style:{width:`3px`,borderRadius:`3px`,background:`rgba(255,255,255,0.85)`},animate:{height:[4,e+8,4]},transition:{duration:.48,delay:t*.08,repeat:1/0,ease:`easeInOut`}},t))})})]})}var lh=`
|
|
160
160
|
@keyframes fe-call-ring-pulse {
|
|
161
161
|
0% { transform: scale(1); opacity: 0.55; }
|
|
162
162
|
70% { transform: scale(1.85); opacity: 0; }
|
|
@@ -185,9 +185,9 @@ Error generating stack: `+e.message+`
|
|
|
185
185
|
0%, 100% { opacity: 0.5; transform: scale(1); }
|
|
186
186
|
50% { opacity: 0.9; transform: scale(1.12); }
|
|
187
187
|
}
|
|
188
|
-
`;function lh(e){let t=(e||``).replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;return`${parseInt(n.slice(0,2),16)},${parseInt(n.slice(2,4),16)},${parseInt(n.slice(4,6),16)}`}function uh(e){if(!e||typeof e!=`string`)return`#1a1a1a`;let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255,o=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return .2126*o(r)+.7152*o(i)+.0722*o(a)>.179?`#1a1a1a`:`#ffffff`}function dh(e,t){let n=Array.isArray(e)&&e.length>0?e:[t||`#3B82F6`],[r,i,a]=n;return n.length===1?[`radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,`radial-gradient(ellipse 90% 55% at 50% 108%, ${r}1a 0%, transparent 65%)`,`#f7f8fa`].join(`, `):n.length===2?[`radial-gradient(ellipse 80% 100% at -10% 50%, ${r}22 0%, transparent 70%)`,`radial-gradient(ellipse 80% 100% at 110% 50%, ${i}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `):[`radial-gradient(ellipse 80% 70% at -10% 50%, ${r}22 0%, transparent 70%)`,`radial-gradient(ellipse 70% 80% at 110% 30%, ${i}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 60% at 50% 110%, ${a}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `)}function fh({headshot:e,name:t,size:n=80,primaryColor:r=`#3B82F6`}){let i=(t||`A`)[0].toUpperCase(),a=uh(r),o=n>48?{boxShadow:`0 0 0 3px ${r}44`,border:`3px solid rgba(255,255,255,0.15)`}:{border:`1.5px solid ${r}55`};return e?(0,B.jsx)(`img`,{src:e,alt:t||`Agent`,style:{width:n,height:n,borderRadius:`50%`,objectFit:`cover`,position:`relative`,zIndex:1,flexShrink:0,...o}}):(0,B.jsx)(`div`,{style:{width:n,height:n,borderRadius:`50%`,background:`linear-gradient(135deg, ${r}, ${r}99)`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:Math.round(n*.36)+`px`,fontWeight:700,color:a,position:`relative`,zIndex:1,flexShrink:0,...o},children:i})}function ph(e){let t=(0,b.useRef)(null),n=(0,b.useCallback)(()=>{if(!t.current)return;let{audioContext:e,oscillator:n,interval:r,toneTimeout:i}=t.current;window.clearInterval(r),window.clearTimeout(i);try{n.stop()}catch{}try{e.close()}catch{}t.current=null},[]),r=(0,b.useCallback)(()=>{if(t.current||typeof window>`u`)return;let e=window.AudioContext||window.webkitAudioContext||null;if(e)try{let n=new e,r=n.createOscillator(),i=n.createGain();r.connect(i),i.connect(n.destination),r.frequency.value=0,r.type=`sine`,i.gain.value=.3;let a=()=>{t.current&&(window.clearTimeout(t.current.toneTimeout),r.frequency.value=440,t.current.toneTimeout=window.setTimeout(()=>{r.frequency.value=0},400))};n.state===`suspended`&&n.resume().catch(e=>{console.warn(`[FlowEngage] ringtone autoplay blocked`,e)}),r.start(),t.current={audioContext:n,oscillator:r,interval:null,toneTimeout:null},a(),t.current.interval=window.setInterval(a,1e3)}catch(e){console.warn(`[FlowEngage] failed to start ringtone`,e)}},[]);return(0,b.useEffect)(()=>{if(e){r();return}n()},[e,r,n]),(0,b.useEffect)(()=>()=>n(),[n]),n}function mh({incomingCall:e,activeCallId:t,callConnectionState:n,callDurationSeconds:r,isCallMuted:i,agentName:a,agentHeadshot:o,fallbackAgentName:s,acceptCall:c,rejectCall:l,endWebRTCCall:u,toggleCallMute:d,formatCallDuration:f,onMinimize:p,primaryColor:m=`#3B82F6`,orbColors:h,chatHistory:g=[]}){let _=a||s||`Agent`,v=e?`incoming`:n===`connecting`?`connecting`:`ongoing`,y=ph(!!e),b=async()=>{y(),await c()},x=async()=>{y(),await l()},S=i?`muted`:n===`connecting`?`idle`:`listening`,C=v===`ongoing`,w={position:`absolute`,inset:0,zIndex:10,display:`flex`,flexDirection:`column`,borderRadius:`inherit`,overflow:`hidden`,background:dh(h,m),animation:C?`fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`:`fe-call-fade-in 0.32s ease`};if(v===`incoming`){let e=Array.isArray(h)&&h.length>0?h:[m];return(0,B.jsxs)(`div`,{style:w,children:[(0,B.jsx)(`style`,{children:ch}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`space-between`,padding:`60px 32px 56px`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`22px`},children:[(0,B.jsxs)(`div`,{style:{position:`relative`,width:`96px`,height:`96px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,B.jsx)(`div`,{style:{position:`absolute`,width:`96px`,height:`96px`,borderRadius:`50%`,background:`radial-gradient(circle, rgba(${lh(e[0])},0.2) 0%, transparent 70%)`,filter:`blur(10px)`,zIndex:0}}),[0,.5,1].map((t,n)=>(0,B.jsx)(`div`,{style:{position:`absolute`,width:`96px`,height:`96px`,borderRadius:`50%`,border:`1.5px solid ${e[n%e.length]}`,animation:`fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,zIndex:1}},n)),(0,B.jsx)(fh,{headshot:o,name:_,size:82,primaryColor:m})]}),(0,B.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,B.jsx)(`div`,{style:{fontSize:`22px`,fontWeight:700,color:`#111827`,letterSpacing:`-0.015em`,lineHeight:1.2},children:_}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginTop:`8px`},children:[(0,B.jsx)(`div`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:e[0],boxShadow:`0 0 5px ${e[0]}88`,animation:`fe-call-dot-blink 1.4s ease-in-out infinite`}}),(0,B.jsx)(`span`,{style:{fontSize:`13px`,color:`#6b7280`,letterSpacing:`0.01em`},children:`Incoming call`})]})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`56px`,alignItems:`flex-end`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`10px`},children:[(0,B.jsx)(`button`,{type:`button`,onClick:x,style:{width:`68px`,height:`68px`,borderRadius:`50%`,background:`#ef4444`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`white`,boxShadow:`0 6px 24px rgba(239,68,68,0.5)`,transition:`transform 0.15s ease, box-shadow 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.08)`,e.currentTarget.style.boxShadow=`0 8px 28px rgba(239,68,68,0.65)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`,e.currentTarget.style.boxShadow=`0 6px 24px rgba(239,68,68,0.5)`},"aria-label":`Decline call`,children:(0,B.jsx)(xm,{size:26})}),(0,B.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Decline`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`10px`},children:[(0,B.jsx)(`button`,{type:`button`,onClick:b,style:{width:`68px`,height:`68px`,borderRadius:`50%`,background:`#22c55e`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`white`,boxShadow:`0 6px 24px rgba(34,197,94,0.5)`,transition:`transform 0.15s ease, box-shadow 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.08)`,e.currentTarget.style.boxShadow=`0 8px 28px rgba(34,197,94,0.65)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`,e.currentTarget.style.boxShadow=`0 6px 24px rgba(34,197,94,0.5)`},"aria-label":`Accept call`,children:(0,B.jsx)(wm,{})}),(0,B.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Accept`})]})]})]})]})}return v===`connecting`?(0,B.jsxs)(`div`,{style:w,children:[(0,B.jsx)(`style`,{children:ch}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`24px`},children:[(0,B.jsx)(fh,{headshot:o,name:_,size:64,primaryColor:m}),(0,B.jsx)(`div`,{style:{width:`48px`,height:`48px`,borderRadius:`50%`,border:`3px solid rgba(255,255,255,0.12)`,borderTopColor:Array.isArray(h)&&h[0]||m,animation:`fe-call-spin 0.9s linear infinite`}}),(0,B.jsx)(`span`,{style:{fontSize:`15px`,color:`#6b7280`,letterSpacing:`0.01em`},children:`Connecting…`})]})]}):(0,B.jsxs)(`div`,{style:w,children:[(0,B.jsx)(`style`,{children:ch}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px 16px 10px`,gap:`10px`,flexShrink:0},children:[(0,B.jsx)(`button`,{type:`button`,onClick:p,style:{width:`40px`,height:`40px`,borderRadius:`50%`,background:`rgba(0,0,0,0.06)`,border:`1px solid rgba(0,0,0,0.1)`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#374151`,transition:`background 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(0,0,0,0.11)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(0,0,0,0.06)`},"aria-label":`Minimize call`,children:(0,B.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,B.jsx)(sh,{colors:h,size:36,voiceState:S}),(0,B.jsx)(`div`,{style:{flex:1,minWidth:0,fontSize:`15px`,fontWeight:600,color:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:_}),(0,B.jsx)(`div`,{style:{flexShrink:0,padding:`3px 10px`,borderRadius:`999px`,background:`${m}18`,border:`1px solid ${m}44`,display:`flex`,alignItems:`center`},children:(0,B.jsx)(`span`,{style:{fontSize:`11px`,fontWeight:600,color:m,letterSpacing:`0.02em`,lineHeight:1},children:`On Call`})})]}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`,padding:`0 24px 16px`},children:[(0,B.jsx)(fh,{headshot:o,name:_,size:116,primaryColor:m}),(0,B.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,B.jsx)(`div`,{style:{fontSize:`20px`,fontWeight:700,color:`#111827`,letterSpacing:`-0.01em`},children:_}),(0,B.jsx)(`div`,{style:{marginTop:`8px`,fontSize:`24px`,fontWeight:300,color:`#9ca3af`,letterSpacing:`0.06em`,fontVariantNumeric:`tabular-nums`},children:f(r)})]})]}),(0,B.jsxs)(`div`,{style:{flexShrink:0,display:`flex`,gap:`12px`,padding:`16px 24px 40px`},children:[(0,B.jsxs)(`button`,{type:`button`,onClick:d,style:{flex:1,height:`54px`,borderRadius:`14px`,background:i?`rgba(239,68,68,0.1)`:`rgba(0,0,0,0.06)`,border:i?`1.5px solid rgba(239,68,68,0.4)`:`1.5px solid rgba(0,0,0,0.1)`,cursor:`pointer`,color:i?`#ef4444`:`#374151`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,fontSize:`14px`,fontWeight:600,transition:`all 0.2s ease`},"aria-label":i?`Unmute`:`Mute`,children:[i?(0,B.jsx)(jm,{size:18}):(0,B.jsx)(bm,{size:18}),i?`Unmute`:`Mute`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:u,style:{flex:1,height:`54px`,borderRadius:`14px`,background:`rgba(239,68,68,0.9)`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`white`,fontSize:`14px`,fontWeight:600,boxShadow:`0 4px 20px rgba(239,68,68,0.38)`,transition:`transform 0.15s ease, background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`#ef4444`,e.currentTarget.style.transform=`scale(1.02)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(239,68,68,0.9)`,e.currentTarget.style.transform=`scale(1)`},"aria-label":`End call`,children:[(0,B.jsx)(xm,{size:18}),`End Call`]})]})]})}function hh({agentName:e,agentHeadshot:t,fallbackAgentName:n,callDurationSeconds:r,isCallMuted:i,formatCallDuration:a,toggleCallMute:o,endWebRTCCall:s,onExpand:c,primaryColor:l=`#3B82F6`}){let u=e||n||`Agent`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`style`,{children:ch}),(0,B.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&c?.()},onMouseEnter:e=>{e.currentTarget.style.boxShadow=`0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.95)`,e.currentTarget.style.transform=`translateY(-2px)`},onMouseLeave:e=>{e.currentTarget.style.boxShadow=`0 4px 20px rgba(0,0,0,0.09), 0 1px 6px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.9)`,e.currentTarget.style.transform=`translateY(0)`},style:{display:`flex`,alignItems:`center`,gap:`12px`,padding:`10px 12px 10px 10px`,margin:`0 12px 8px`,borderRadius:`18px`,background:`rgba(255,255,255,0.88)`,backdropFilter:`blur(20px)`,WebkitBackdropFilter:`blur(20px)`,border:`1px solid rgba(255,255,255,0.65)`,boxShadow:`0 4px 20px rgba(0,0,0,0.09), 0 1px 6px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.9)`,cursor:`pointer`,animation:`fe-call-bar-slide-in 0.3s cubic-bezier(0.16,1,0.3,1)`,flexShrink:0,userSelect:`none`,outline:`none`,transition:`box-shadow 0.22s ease, transform 0.18s ease`},children:[(0,B.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:`42px`,height:`42px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,B.jsx)(`div`,{style:{position:`absolute`,inset:`-4px`,borderRadius:`50%`,background:`${l}28`,animation:`fe-call-avatar-breathe 2.8s ease-in-out infinite`}}),(0,B.jsx)(`div`,{style:{position:`absolute`,inset:`-2px`,borderRadius:`50%`,border:`1.5px solid ${l}55`}}),(0,B.jsx)(fh,{headshot:t,name:u,size:38,primaryColor:l})]}),(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:`#111827`,lineHeight:1.3,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:u}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,marginTop:`3px`},children:[(0,B.jsx)(`div`,{style:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`#22c55e`,flexShrink:0,boxShadow:`0 0 4px rgba(34,197,94,0.6)`,animation:`fe-call-dot-blink 1.6s ease-in-out infinite`}}),(0,B.jsxs)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontVariantNumeric:`tabular-nums`,letterSpacing:`0.01em`},children:[`On Call\xA0•\xA0`,a(r)]})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`,flexShrink:0},children:[(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.12)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},style:{width:`36px`,height:`36px`,borderRadius:`50%`,background:i?`${l}18`:`rgba(0,0,0,0.05)`,border:i?`1.5px solid ${l}55`:`1.5px solid rgba(0,0,0,0.08)`,cursor:`pointer`,color:i?l:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,transition:`all 0.18s ease`,boxShadow:i?`0 0 0 3px ${l}12`:`none`},"aria-label":i?`Unmute`:`Mute`,children:i?(0,B.jsx)(jm,{size:15}):(0,B.jsx)(bm,{size:15})}),(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.12)`,e.currentTarget.style.boxShadow=`0 4px 16px rgba(239,68,68,0.55)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`,e.currentTarget.style.boxShadow=`0 2px 10px rgba(239,68,68,0.35)`},style:{width:`36px`,height:`36px`,borderRadius:`50%`,background:`#ef4444`,border:`none`,cursor:`pointer`,color:`white`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,boxShadow:`0 2px 10px rgba(239,68,68,0.35)`,transition:`all 0.18s ease`},"aria-label":`End call`,children:(0,B.jsx)(xm,{size:16})})]})]})]})}function gh(e,t={}){let n=t.maxChars??4500;if(!Array.isArray(e)||e.length===0)return``;let r=[];for(let t of e){if(!t||t.isPending)continue;let e=String(t.sender||``).toLowerCase(),n=null;if(e===`user`?n=`Visitor`:(e===`bot`||e===`ai`||e===`agent`)&&(n=`Assistant`),!n)continue;let i=String(t.message||``).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim().slice(0,1200);i&&r.push(`${n}: ${i}`)}if(r.length===0)return``;let i=r.join(`
|
|
188
|
+
`;function uh(e){let t=(e||``).replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t;return`${parseInt(n.slice(0,2),16)},${parseInt(n.slice(2,4),16)},${parseInt(n.slice(4,6),16)}`}function dh(e){if(!e||typeof e!=`string`)return`#1a1a1a`;let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255,o=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return .2126*o(r)+.7152*o(i)+.0722*o(a)>.179?`#1a1a1a`:`#ffffff`}function fh(e,t){let n=Array.isArray(e)&&e.length>0?e:[t||`#3B82F6`],[r,i,a]=n;return n.length===1?[`radial-gradient(ellipse 110% 65% at 50% -5%, ${r}28 0%, transparent 68%)`,`radial-gradient(ellipse 90% 55% at 50% 108%, ${r}1a 0%, transparent 65%)`,`#f7f8fa`].join(`, `):n.length===2?[`radial-gradient(ellipse 80% 100% at -10% 50%, ${r}22 0%, transparent 70%)`,`radial-gradient(ellipse 80% 100% at 110% 50%, ${i}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `):[`radial-gradient(ellipse 80% 70% at -10% 50%, ${r}22 0%, transparent 70%)`,`radial-gradient(ellipse 70% 80% at 110% 30%, ${i}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 60% at 50% 110%, ${a}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `)}function ph({headshot:e,name:t,size:n=80,primaryColor:r=`#3B82F6`}){let i=(t||`A`)[0].toUpperCase(),a=dh(r),o=n>48?{boxShadow:`0 0 0 3px ${r}44`,border:`3px solid rgba(255,255,255,0.15)`}:{border:`1.5px solid ${r}55`};return e?(0,B.jsx)(`img`,{src:e,alt:t||`Agent`,style:{width:n,height:n,borderRadius:`50%`,objectFit:`cover`,position:`relative`,zIndex:1,flexShrink:0,...o}}):(0,B.jsx)(`div`,{style:{width:n,height:n,borderRadius:`50%`,background:`linear-gradient(135deg, ${r}, ${r}99)`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:Math.round(n*.36)+`px`,fontWeight:700,color:a,position:`relative`,zIndex:1,flexShrink:0,...o},children:i})}function mh(e){let t=(0,b.useRef)(null),n=(0,b.useCallback)(()=>{if(!t.current)return;let{audioContext:e,oscillator:n,interval:r,toneTimeout:i}=t.current;window.clearInterval(r),window.clearTimeout(i);try{n.stop()}catch{}try{e.close()}catch{}t.current=null},[]),r=(0,b.useCallback)(()=>{if(t.current||typeof window>`u`)return;let e=window.AudioContext||window.webkitAudioContext||null;if(e)try{let n=new e,r=n.createOscillator(),i=n.createGain();r.connect(i),i.connect(n.destination),r.frequency.value=0,r.type=`sine`,i.gain.value=.3;let a=()=>{t.current&&(window.clearTimeout(t.current.toneTimeout),r.frequency.value=440,t.current.toneTimeout=window.setTimeout(()=>{r.frequency.value=0},400))};n.state===`suspended`&&n.resume().catch(e=>{console.warn(`[FlowEngage] ringtone autoplay blocked`,e)}),r.start(),t.current={audioContext:n,oscillator:r,interval:null,toneTimeout:null},a(),t.current.interval=window.setInterval(a,1e3)}catch(e){console.warn(`[FlowEngage] failed to start ringtone`,e)}},[]);return(0,b.useEffect)(()=>{if(e){r();return}n()},[e,r,n]),(0,b.useEffect)(()=>()=>n(),[n]),n}function hh({incomingCall:e,activeCallId:t,callConnectionState:n,callDurationSeconds:r,isCallMuted:i,agentName:a,agentHeadshot:o,fallbackAgentName:s,acceptCall:c,rejectCall:l,endWebRTCCall:u,toggleCallMute:d,formatCallDuration:f,onMinimize:p,primaryColor:m=`#3B82F6`,orbColors:h,chatHistory:g=[]}){let _=a||s||`Agent`,v=e?`incoming`:n===`connecting`?`connecting`:`ongoing`,y=mh(!!e),b=async()=>{y(),await c()},x=async()=>{y(),await l()},S=i?`muted`:n===`connecting`?`idle`:`listening`,C=v===`ongoing`,w={position:`absolute`,inset:0,zIndex:10,display:`flex`,flexDirection:`column`,borderRadius:`inherit`,overflow:`hidden`,background:fh(h,m),animation:C?`fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`:`fe-call-fade-in 0.32s ease`};if(v===`incoming`){let e=Array.isArray(h)&&h.length>0?h:[m];return(0,B.jsxs)(`div`,{style:w,children:[(0,B.jsx)(`style`,{children:lh}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`space-between`,padding:`60px 32px 56px`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`22px`},children:[(0,B.jsxs)(`div`,{style:{position:`relative`,width:`96px`,height:`96px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,B.jsx)(`div`,{style:{position:`absolute`,width:`96px`,height:`96px`,borderRadius:`50%`,background:`radial-gradient(circle, rgba(${uh(e[0])},0.2) 0%, transparent 70%)`,filter:`blur(10px)`,zIndex:0}}),[0,.5,1].map((t,n)=>(0,B.jsx)(`div`,{style:{position:`absolute`,width:`96px`,height:`96px`,borderRadius:`50%`,border:`1.5px solid ${e[n%e.length]}`,animation:`fe-call-ring-pulse 2.6s cubic-bezier(0.215,0.61,0.355,1) ${t}s infinite`,zIndex:1}},n)),(0,B.jsx)(ph,{headshot:o,name:_,size:82,primaryColor:m})]}),(0,B.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,B.jsx)(`div`,{style:{fontSize:`22px`,fontWeight:700,color:`#111827`,letterSpacing:`-0.015em`,lineHeight:1.2},children:_}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginTop:`8px`},children:[(0,B.jsx)(`div`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:e[0],boxShadow:`0 0 5px ${e[0]}88`,animation:`fe-call-dot-blink 1.4s ease-in-out infinite`}}),(0,B.jsx)(`span`,{style:{fontSize:`13px`,color:`#6b7280`,letterSpacing:`0.01em`},children:`Incoming call`})]})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`56px`,alignItems:`flex-end`},children:[(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`10px`},children:[(0,B.jsx)(`button`,{type:`button`,onClick:x,style:{width:`68px`,height:`68px`,borderRadius:`50%`,background:`#ef4444`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`white`,boxShadow:`0 6px 24px rgba(239,68,68,0.5)`,transition:`transform 0.15s ease, box-shadow 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.08)`,e.currentTarget.style.boxShadow=`0 8px 28px rgba(239,68,68,0.65)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`,e.currentTarget.style.boxShadow=`0 6px 24px rgba(239,68,68,0.5)`},"aria-label":`Decline call`,children:(0,B.jsx)(Sm,{size:26})}),(0,B.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Decline`})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`10px`},children:[(0,B.jsx)(`button`,{type:`button`,onClick:b,style:{width:`68px`,height:`68px`,borderRadius:`50%`,background:`#22c55e`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`white`,boxShadow:`0 6px 24px rgba(34,197,94,0.5)`,transition:`transform 0.15s ease, box-shadow 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.08)`,e.currentTarget.style.boxShadow=`0 8px 28px rgba(34,197,94,0.65)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`,e.currentTarget.style.boxShadow=`0 6px 24px rgba(34,197,94,0.5)`},"aria-label":`Accept call`,children:(0,B.jsx)(Tm,{})}),(0,B.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Accept`})]})]})]})]})}return v===`connecting`?(0,B.jsxs)(`div`,{style:w,children:[(0,B.jsx)(`style`,{children:lh}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`24px`},children:[(0,B.jsx)(ph,{headshot:o,name:_,size:64,primaryColor:m}),(0,B.jsx)(`div`,{style:{width:`48px`,height:`48px`,borderRadius:`50%`,border:`3px solid rgba(255,255,255,0.12)`,borderTopColor:Array.isArray(h)&&h[0]||m,animation:`fe-call-spin 0.9s linear infinite`}}),(0,B.jsx)(`span`,{style:{fontSize:`15px`,color:`#6b7280`,letterSpacing:`0.01em`},children:`Connecting…`})]})]}):(0,B.jsxs)(`div`,{style:w,children:[(0,B.jsx)(`style`,{children:lh}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px 16px 10px`,gap:`10px`,flexShrink:0},children:[(0,B.jsx)(`button`,{type:`button`,onClick:p,style:{width:`40px`,height:`40px`,borderRadius:`50%`,background:`rgba(0,0,0,0.06)`,border:`1px solid rgba(0,0,0,0.1)`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`#374151`,transition:`background 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(0,0,0,0.11)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(0,0,0,0.06)`},"aria-label":`Minimize call`,children:(0,B.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,B.jsx)(ch,{colors:h,size:36,voiceState:S}),(0,B.jsx)(`div`,{style:{flex:1,minWidth:0,fontSize:`15px`,fontWeight:600,color:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:_}),(0,B.jsx)(`div`,{style:{flexShrink:0,padding:`3px 10px`,borderRadius:`999px`,background:`${m}18`,border:`1px solid ${m}44`,display:`flex`,alignItems:`center`},children:(0,B.jsx)(`span`,{style:{fontSize:`11px`,fontWeight:600,color:m,letterSpacing:`0.02em`,lineHeight:1},children:`On Call`})})]}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`,padding:`0 24px 16px`},children:[(0,B.jsx)(ph,{headshot:o,name:_,size:116,primaryColor:m}),(0,B.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,B.jsx)(`div`,{style:{fontSize:`20px`,fontWeight:700,color:`#111827`,letterSpacing:`-0.01em`},children:_}),(0,B.jsx)(`div`,{style:{marginTop:`8px`,fontSize:`24px`,fontWeight:300,color:`#9ca3af`,letterSpacing:`0.06em`,fontVariantNumeric:`tabular-nums`},children:f(r)})]})]}),(0,B.jsxs)(`div`,{style:{flexShrink:0,display:`flex`,gap:`12px`,padding:`16px 24px 40px`},children:[(0,B.jsxs)(`button`,{type:`button`,onClick:d,style:{flex:1,height:`54px`,borderRadius:`14px`,background:i?`rgba(239,68,68,0.1)`:`rgba(0,0,0,0.06)`,border:i?`1.5px solid rgba(239,68,68,0.4)`:`1.5px solid rgba(0,0,0,0.1)`,cursor:`pointer`,color:i?`#ef4444`:`#374151`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,fontSize:`14px`,fontWeight:600,transition:`all 0.2s ease`},"aria-label":i?`Unmute`:`Mute`,children:[i?(0,B.jsx)(Mm,{size:18}):(0,B.jsx)(xm,{size:18}),i?`Unmute`:`Mute`]}),(0,B.jsxs)(`button`,{type:`button`,onClick:u,style:{flex:1,height:`54px`,borderRadius:`14px`,background:`rgba(239,68,68,0.9)`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`white`,fontSize:`14px`,fontWeight:600,boxShadow:`0 4px 20px rgba(239,68,68,0.38)`,transition:`transform 0.15s ease, background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`#ef4444`,e.currentTarget.style.transform=`scale(1.02)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(239,68,68,0.9)`,e.currentTarget.style.transform=`scale(1)`},"aria-label":`End call`,children:[(0,B.jsx)(Sm,{size:18}),`End Call`]})]})]})}function gh({agentName:e,agentHeadshot:t,fallbackAgentName:n,callDurationSeconds:r,isCallMuted:i,formatCallDuration:a,toggleCallMute:o,endWebRTCCall:s,onExpand:c,primaryColor:l=`#3B82F6`}){let u=e||n||`Agent`;return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`style`,{children:lh}),(0,B.jsxs)(`div`,{role:`button`,tabIndex:0,onClick:c,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&c?.()},onMouseEnter:e=>{e.currentTarget.style.boxShadow=`0 8px 32px rgba(0,0,0,0.14), 0 2px 8px rgba(0,0,0,0.08), inset 0 1px 0 rgba(255,255,255,0.95)`,e.currentTarget.style.transform=`translateY(-2px)`},onMouseLeave:e=>{e.currentTarget.style.boxShadow=`0 4px 20px rgba(0,0,0,0.09), 0 1px 6px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.9)`,e.currentTarget.style.transform=`translateY(0)`},style:{display:`flex`,alignItems:`center`,gap:`12px`,padding:`10px 12px 10px 10px`,margin:`0 12px 8px`,borderRadius:`18px`,background:`rgba(255,255,255,0.88)`,backdropFilter:`blur(20px)`,WebkitBackdropFilter:`blur(20px)`,border:`1px solid rgba(255,255,255,0.65)`,boxShadow:`0 4px 20px rgba(0,0,0,0.09), 0 1px 6px rgba(0,0,0,0.06), inset 0 1px 0 rgba(255,255,255,0.9)`,cursor:`pointer`,animation:`fe-call-bar-slide-in 0.3s cubic-bezier(0.16,1,0.3,1)`,flexShrink:0,userSelect:`none`,outline:`none`,transition:`box-shadow 0.22s ease, transform 0.18s ease`},children:[(0,B.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:`42px`,height:`42px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,B.jsx)(`div`,{style:{position:`absolute`,inset:`-4px`,borderRadius:`50%`,background:`${l}28`,animation:`fe-call-avatar-breathe 2.8s ease-in-out infinite`}}),(0,B.jsx)(`div`,{style:{position:`absolute`,inset:`-2px`,borderRadius:`50%`,border:`1.5px solid ${l}55`}}),(0,B.jsx)(ph,{headshot:t,name:u,size:38,primaryColor:l})]}),(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:`#111827`,lineHeight:1.3,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:u}),(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,marginTop:`3px`},children:[(0,B.jsx)(`div`,{style:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`#22c55e`,flexShrink:0,boxShadow:`0 0 4px rgba(34,197,94,0.6)`,animation:`fe-call-dot-blink 1.6s ease-in-out infinite`}}),(0,B.jsxs)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontVariantNumeric:`tabular-nums`,letterSpacing:`0.01em`},children:[`On Call\xA0•\xA0`,a(r)]})]})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`,flexShrink:0},children:[(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.12)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},style:{width:`36px`,height:`36px`,borderRadius:`50%`,background:i?`${l}18`:`rgba(0,0,0,0.05)`,border:i?`1.5px solid ${l}55`:`1.5px solid rgba(0,0,0,0.08)`,cursor:`pointer`,color:i?l:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,transition:`all 0.18s ease`,boxShadow:i?`0 0 0 3px ${l}12`:`none`},"aria-label":i?`Unmute`:`Mute`,children:i?(0,B.jsx)(Mm,{size:15}):(0,B.jsx)(xm,{size:15})}),(0,B.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.12)`,e.currentTarget.style.boxShadow=`0 4px 16px rgba(239,68,68,0.55)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`,e.currentTarget.style.boxShadow=`0 2px 10px rgba(239,68,68,0.35)`},style:{width:`36px`,height:`36px`,borderRadius:`50%`,background:`#ef4444`,border:`none`,cursor:`pointer`,color:`white`,display:`flex`,alignItems:`center`,justifyContent:`center`,flexShrink:0,boxShadow:`0 2px 10px rgba(239,68,68,0.35)`,transition:`all 0.18s ease`},"aria-label":`End call`,children:(0,B.jsx)(Sm,{size:16})})]})]})]})}function _h(e,t={}){let n=t.maxChars??4500;if(!Array.isArray(e)||e.length===0)return``;let r=[];for(let t of e){if(!t||t.isPending)continue;let e=String(t.sender||``).toLowerCase(),n=null;if(e===`user`?n=`Visitor`:(e===`bot`||e===`ai`||e===`agent`)&&(n=`Assistant`),!n)continue;let i=String(t.message||``).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim().slice(0,1200);i&&r.push(`${n}: ${i}`)}if(r.length===0)return``;let i=r.join(`
|
|
189
189
|
`);return i.length>n&&(i=`…(earlier messages omitted)
|
|
190
|
-
`+i.slice(-n)),i}var Q=`fe-vv`;function
|
|
190
|
+
`+i.slice(-n)),i}var Q=`fe-vv`;function vh(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
|
|
191
191
|
/* ── Action toast ───────────────────────────────────────────────────────────── */
|
|
192
192
|
#${Q}-toast {
|
|
193
193
|
position: fixed;
|
|
@@ -327,27 +327,27 @@ Error generating stack: `+e.message+`
|
|
|
327
327
|
50% { transform: translate(-4px,-4px) scale(0.82); }
|
|
328
328
|
100% { transform: translate(-4px,-4px) scale(1); }
|
|
329
329
|
}
|
|
330
|
-
`,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var
|
|
330
|
+
`,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var yh=null,bh=null;function xh(){return(!yh||!yh.isConnected)&&(yh=document.createElement(`div`),yh.id=`${Q}-toast`,document.body.appendChild(yh)),yh}function Sh(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;vh(),bh&&=(clearTimeout(bh),null);let i=xh();if(i.innerHTML=``,n){let e=document.createElement(`span`);e.className=`${Q}-icon`,e.textContent=n,i.appendChild(e)}else if(t){let e=document.createElement(`span`);e.className=`${Q}-spin`,i.appendChild(e)}let a=document.createElement(`span`);a.textContent=e,i.appendChild(a),i.classList.remove(`${Q}-show`),i.offsetHeight,i.classList.add(`${Q}-show`),r>0&&(bh=setTimeout(()=>Ch(),r))}function Ch(e=0){yh&&(e>0?bh=setTimeout(()=>{yh&&yh.classList.remove(`${Q}-show`)},e):yh&&yh.classList.remove(`${Q}-show`))}var wh=null,Th=[];function Eh(){return(!wh||!wh.isConnected)&&(wh=document.createElement(`div`),wh.id=`${Q}-bar`,document.body.appendChild(wh)),wh}function Dh(){if(typeof document>`u`)return;vh(),Th.forEach(clearTimeout),Th=[];let e=Eh();e.style.transition=`none`,e.style.width=`0%`,e.classList.add(`${Q}-bar-active`),e.offsetHeight,e.style.transition=`width 0.35s ease, opacity 0.25s ease`;let t=[[80,`width 0.6s ease`],[92,`width 1.2s ease`]],n=50;for(let[e,r]of t){let t=n,i=e,a=r;Th.push(setTimeout(()=>{wh&&(wh.style.transition=a,wh.style.width=`${i}%`)},t)),n+=800}}function Oh(){wh&&(Th.forEach(clearTimeout),Th=[],wh.style.transition=`width 0.2s ease`,wh.style.width=`100%`,Th.push(setTimeout(()=>{wh&&(wh.style.transition=`opacity 0.35s ease`,wh.style.opacity=`0`,Th.push(setTimeout(()=>{wh&&(wh.style.width=`0%`,wh.classList.remove(`${Q}-bar-active`))},380)))},220)))}var kh=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
|
|
331
331
|
<filter id="${Q}-csh">
|
|
332
332
|
<feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
|
|
333
333
|
</filter>
|
|
334
334
|
<path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
|
|
335
335
|
fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
|
|
336
336
|
filter="url(#${Q}-csh)"/>
|
|
337
|
-
</svg>`,
|
|
337
|
+
</svg>`,Ah=null,jh=!1;function Mh(){return(!Ah||!Ah.isConnected)&&(Ah=document.createElement(`div`),Ah.id=`${Q}-cursor`,Ah.innerHTML=kh,document.body.appendChild(Ah),jh=!1),Ah}async function Nh(e){if(typeof document>`u`||!e)return;vh();let t;try{t=e.getBoundingClientRect()}catch{return}let n=t.left+Math.min(16,t.width*.2),r=t.top+Math.min(12,t.height*.25),i=Mh();jh||=(i.style.transition=`none`,i.style.left=`${window.innerWidth/2}px`,i.style.top=`${window.innerHeight*.4}px`,i.classList.add(`${Q}-cursor-visible`),i.offsetHeight,i.style.transition=`left 0.32s cubic-bezier(0.25,0.46,0.45,0.94), top 0.32s cubic-bezier(0.25,0.46,0.45,0.94), opacity 0.2s ease`,!0),i.style.left=`${n}px`,i.style.top=`${r}px`,await Lh(360)}function Ph(e=!1){Ah&&(e?(Ah.classList.remove(`${Q}-cursor-visible`),jh=!1):(Ah.classList.remove(`${Q}-cursor-visible`),setTimeout(()=>{jh=!1},250)))}async function Fh(e){Ah&&(Ah.classList.add(`${Q}-cursor-click`),await Lh(280),Ah.classList.remove(`${Q}-cursor-click`))}function Ih(e){if(!e||typeof document>`u`)return;vh();let t;try{t=e.getBoundingClientRect()}catch{return}let n=e.style.position,r=e.style.overflow,i=window.getComputedStyle(e).position;[`relative`,`absolute`,`fixed`,`sticky`].includes(i)||(e.style.position=`relative`),e.style.overflow=`hidden`;let a=document.createElement(`span`);a.className=`${Q}-ripple`;let o=Math.max(t.width,t.height)*1.2;Object.assign(a.style,{width:`${o}px`,height:`${o}px`,left:`${t.width/2-o/2}px`,top:`${t.height/2-o/2}px`}),e.appendChild(a),setTimeout(()=>{a.remove(),e.style.position=n,e.style.overflow=r},650)}function Lh(e){return new Promise(t=>setTimeout(t,e))}function $(...e){Dn()&&console.log(`[FlowEngage:voice-tools]`,...e)}function Rh(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function zh(e){let t=new Set;function n(r){if(!r||t.has(r))return;t.add(r),e(r);let i=r.querySelectorAll(`iframe`);for(let e of i)if(!Nn(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function Bh(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function Vh(e){let t=e.ownerDocument||document,n=e.getAttribute(`aria-labelledby`);if(n){let e=n.trim().split(/\s+/).filter(Boolean),r=[];for(let n of e)try{let e=t.getElementById(n);e?.textContent&&r.push(e.textContent.trim())}catch{}if(r.length)return Bh(r.join(` `))}if(e.labels&&e.labels.length)return Bh(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return Bh(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return Bh(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return Bh(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=Bh(i.textContent);if(e)return e}i=i.previousElementSibling}let a=e.parentElement;for(let e=0;e<5&&a;e+=1){if(a.tagName===`LABEL`)return Bh(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return Bh(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?Bh(o):null}function Hh(){let e=[];return zh(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(Nn(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=Rh(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function Uh(){return Hh().map((e,t)=>{let n={formIndex:0,fieldIndex:t,tag:e.tagName,type:e.type||`text`,name:e.name||null,id:e.id||null,label:Vh(e),placeholder:e.placeholder||null};return e.tagName===`SELECT`&&(n.options=Array.from(e.options).filter(e=>e.value!==``&&!e.disabled).map(e=>({value:e.value,text:e.text.trim()})),n.currentValue=e.value||null),n})}function Wh(){let e=[];return zh(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(Nn(e)||e.disabled)return!1;try{let t=Rh(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e.slice(0,60).map((e,t)=>({index:t,text:(e.textContent||e.value||``).replace(/\s+/g,` `).trim().slice(0,120)||null,ariaLabel:e.getAttribute(`aria-label`),type:e.type||e.tagName}))}function Gh(e,t){try{if(!e?.getBoundingClientRect||!t?.getBoundingClientRect)return 1/0;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i={x:n.left+n.width/2,y:n.top+n.height/2},a={x:r.left+r.width/2,y:r.top+r.height/2};return Math.hypot(i.x-a.x,i.y-a.y)}catch{return 1/0}}function Kh(e,t){let n=String(t||``).toLowerCase().trim();if(!n)return 0;let r=(e.innerText||e.textContent||``).replace(/\s+/g,` `).trim(),i=[r,e.value,e.getAttribute(`aria-label`),e.getAttribute(`title`),e.getAttribute(`data-text`),e.getAttribute(`data-label`)].filter(Boolean).join(` `).toLowerCase().replace(/\s+/g,` `);if(i.includes(n)||r.toLowerCase()===n)return 100;let a=n.split(/\s+/).filter(e=>e.length>1);if(!a.length)return 0;let o=0;for(let e of a)i.includes(e)&&(o+=1);return o/a.length*92}function qh(e,t,n=6){let r=String(t||``).toLowerCase().trim();if(!r)return!1;let i=e;for(let e=0;e<n&&i&&(i=i.parentElement,i);e++)if((i.innerText||i.textContent||``).toLowerCase().includes(r))return!0;return!1}function Jh(e,t,n){let r=[];zh(e=>{let t=Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"], a[href]`));r.push(...t.filter(e=>{if(Nn(e)||e.disabled)return!1;try{let t=Rh(e);if(t.display===`none`||t.visibility===`hidden`||t.opacity===`0`)return!1}catch{}return!0}))});let i=0,a=r.map(t=>({el:t,s:Kh(t,e)}));for(let{s:e}of a)e>i&&(i=e);if(i<28)return null;let o=a.filter(({s:e})=>e===i).map(({el:e})=>e);if(o.length===1)return o[0];if(n){let e=o.filter(e=>qh(e,n));if(e.length===1)return e[0];e.length>1&&(o=e)}let s=Array.isArray(t)?t.filter(e=>e&&e.isConnected):[];if(s.length){let e=o[0],t=1/0;for(let n of o)for(let r of s){let i=Gh(n,r);i<t&&(t=i,e=n)}return e}return o[0]}function Yh(e){if(e==null)return{};if(typeof e==`string`){let t=e.trim();if(!t)return{};try{return JSON.parse(t)}catch{return{url:t}}}return e}function Xh(e){if(!e||typeof e!=`object`)return null;let t=e.url??e.target_url??e.page_url??e.pageUrl??e.link??e.href??e.path;return t==null?null:String(t).trim()||null}function Zh(){let e={};document.querySelectorAll(`h1, h2, h3, h4, h5, h6`).forEach(t=>{if(t.id)return;let n=t.textContent.trim();if(!n)return;let r=n.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-|-$/g,``).substring(0,60);if(e[r]){let t=2;for(;e[r+`-`+t];)t++;r=r+`-`+t}e[r]=!0,t.id=r})}function Qh(){let e=e=>{let t=Array.from(e).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)&&!e.closest(`nav, footer, header, aside, .nav, .footer, .header, .sidebar`)),n=[],r=0;for(;r<t.length;){let e=t[r],i=Pn(e);if(!i||i.length<2){r++;continue}let a=i;if(i.length<40&&!/[.!?:;]$/.test(i)&&r+1<t.length){let n=t[r+1],o=Pn(n);o&&n.tagName===e.tagName&&o.length<60&&(e.nextElementSibling===n||e.parentElement===n.parentElement)&&(a=`${i} ${o}`,r++)}a.length>2&&a.length<200&&n.push(a),r++}return n},t=document.querySelector(`main, [role='main']`)||document.body,n=e(t.querySelectorAll(`h1, h2, h3`));n.length||(n=e(document.body.querySelectorAll(`h1, h2, h3`))),n.length||(n=e(document.body.querySelectorAll(`h4, h5`)));let r=[...new Set(n)].slice(0,15),i=Array.from(t.querySelectorAll(`h1`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)&&!e.closest(`nav, footer, header, aside, .nav, .footer, .header, .sidebar`)),a=null;if(i.length===1){let e=Pn(i[0]);e&&r[0]&&r[0].toLowerCase().trim()===e.toLowerCase().trim()&&(a=r[0])}let o=``;try{let e=t.querySelector(`h1, h2, h3, h4, h5`);if(e){let n=document.createRange();n.setStart(t,0),n.setEndBefore(e);let r=n.cloneContents(),i=[];r.querySelectorAll(`p, li`).forEach(e=>{let t=e.textContent.replace(/\s+/g,` `).trim();t.length>20&&i.push(t)}),o=i.join(` `).slice(0,600)}}catch{}return{headings:r,pageTitleHeading:a,introText:o}}function $h(e){if(!e||typeof document>`u`)return``;let t=new Set([`script`,`style`,`noscript`,`svg`,`iframe`,`nav`,`footer`,`header`,`aside`]),n=parseInt(e.tagName[1],10),r=Array.from({length:n},(e,t)=>`h${t+1}`).join(`, `),i=Array.from(document.querySelectorAll(r)).filter(e=>!e.closest(Mn)),a=i.indexOf(e),o=a===-1?null:i[a+1],s=document.createRange();try{if(s.setStartAfter(e),o)s.setEndBefore(o);else{let e=document.querySelector(`main, [role='main'], article`)||document.body;s.setEnd(e,e.childNodes.length)}}catch{return e.textContent.replace(/\s+/g,` `).trim()}let c;try{c=s.cloneContents()}catch{return e.textContent.replace(/\s+/g,` `).trim()}let l=[];function u(e){if(e.nodeType===Node.TEXT_NODE){let t=e.textContent.replace(/\s+/g,` `).trim();t&&l.push(t);return}if(e.nodeType!==Node.ELEMENT_NODE)return;let n=e.tagName.toLowerCase();if(!t.has(n)){if(n===`ul`||n===`ol`){let t=Array.from(e.querySelectorAll(`:scope > li`)).map(e=>{let t=e.textContent.replace(/\s+/g,` `).trim();return t?`• ${t}`:null}).filter(Boolean);t.length&&l.push(t.join(`
|
|
338
338
|
`));return}if(n===`table`){let t=Array.from(e.querySelectorAll(`tr`)).map(e=>Array.from(e.querySelectorAll(`td, th`)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(Boolean).join(` | `)).filter(Boolean);t.length&&l.push(t.join(`
|
|
339
339
|
`));return}if(n===`form`){let t=Array.from(e.querySelectorAll(`input, textarea, select`)).map(e=>{let t=(e.getAttribute(`type`)||`text`).toLowerCase();if([`hidden`,`submit`,`button`,`reset`].includes(t))return null;let n=e.getAttribute(`placeholder`)||e.getAttribute(`aria-label`)||e.getAttribute(`name`)||t;return n?String(n).trim().slice(0,40):null}).filter(Boolean),n=e.querySelector(`button[type="submit"], input[type="submit"]`),r=n?(n.textContent||n.value||`Submit`).trim().slice(0,40):`Submit`;t.length&&l.push(`[FORM PRESENT: ${t.length} field(s) — ${t.join(`, `)}. Submit button: "${r}"]`);return}if(n===`p`||n===`blockquote`){let t=e.textContent.replace(/\s+/g,` `).trim();t.length>2&&l.push(t);return}if(/^h[1-6]$/.test(n)){let t=e.textContent.replace(/\s+/g,` `).trim();t.length>2&&l.push(t);return}for(let t of e.childNodes)u(t)}}for(let e of c.childNodes)u(e);let d=new Set;return l.filter(e=>{let t=e.substring(0,80);return d.has(t)?!1:(d.add(t),!0)}).join(`
|
|
340
340
|
`).replace(/\n{3,}/g,`
|
|
341
341
|
|
|
342
|
-
`).trim()}function $h(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={"fwh-navigate-mvp":async n=>{$(`fwh-navigate-mvp ▶ raw parameters:`,n);let i=Jh(n),a=Yh(i),o=i.section_text??i.sectionText??i.section,s=Array.isArray(i.expected_landmarks)?i.expected_landmarks:Array.isArray(i.expectedLandmarks)?i.expectedLandmarks:[];if($(`fwh-navigate-mvp · coerced:`,{url:a,sectionText:o,expectedLandmarks:s}),!a){let e=`Missing url: pass a string url, path like /pricing, or JSON with a url field.`;return $(`fwh-navigate-mvp ✖`,e),e}if(typeof window<`u`)try{let e=new URL(a,window.location.href);if(e.origin!==window.location.origin&&/^https?:$/i.test(e.protocol)){let t=e.hostname;return $(`fwh-navigate-mvp ✖ external URL blocked:`,e.href),`EXTERNAL_LINK_BLOCKED: The URL "${a}" points to an external site (${t}) that opens in a new tab. I cannot open new tabs or navigate to external sites. Tell the visitor exactly this: "That link opens an external app — I'm not able to open it for you, but you can click the link directly in the navigation header."`}}catch{}if(typeof window<`u`){try{let e=new URL(a,window.location.href);if(e.pathname===window.location.pathname&&e.search===window.location.search)return $(`fwh-navigate-mvp ✖ already on page, skipping`),`OK_ALREADY_ON_PAGE. The visitor is already on this page. Do not navigate. Proceed directly with highlights, answering the question, or reading page content.`}catch{}let e=window.__fe_user_nav_during_speech;if(e&&Date.now()-e.ts<3e4)try{if(new URL(a,window.location.href).pathname===e.fromPath)return $(`flowengage_navigate ✖ blocked — would navigate back to page visitor just left`,e),`NAV_BLOCKED: The visitor just left "${e.fromPageName}" and is now on "${e.toPageName}". Do NOT navigate them back. If they said "continue", resume verbally from where you left off — no navigation needed. If they want to return, they will navigate themselves.`}catch{}}let{allowed:c,correctedUrl:l}=await _r(a,{siteId:t,apiBaseUrl:e.apiBaseUrl});if(!c){let e=`PAGE_NOT_IN_SITE: "${a}" is NOT a real page on this site — do NOT guess or invent URL paths. Do NOT tell the visitor you are taking them there. Instead, find the REAL page: look at your Popular Pages / Site Pages list for the closest actual match, or call fwh-list-nav-links-mvp (to read the site's real menu links) or fwh-search-mvp (to find the right page). If a close match exists (e.g. the visitor said "support" and the site has "Technical Support"), tell them the ACTUAL page name and ask "we don't have a page called that, but we do have [real page] — would you like me to take you there?" Then navigate only to that verified URL.`;return $(`fwh-navigate-mvp ✖ blocked`,e),e}l&&l!==a&&($(`fwh-navigate-mvp · corrected url:`,{requested:a,correctedUrl:l}),a=l);try{xh(`Navigating to ${a}...`,{spinner:!0}),Eh(),jn();try{let e=r?r():``;if(e&&t){let n=gh([{sender:`user`,message:e}]);n&&Se(t,n)}}catch{}Ee();let e=a;try{e=new URL(a,typeof window<`u`?window.location.href:``).href}catch{}let n=`this`;try{let e=new URL(a,window.location.href).pathname.split(`/`).filter(Boolean).pop()||``;n=e?e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`Home`}catch{}t&&typeof window<`u`&&Ne(t,window.location.href,e,n),br(e),$(`fwh-navigate-mvp → real navigation`,a);let i=typeof window<`u`&&!!Zn();if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),i&&Hn(12e3),wr(a,{voiceActive:!0}).catch(()=>{}),i)try{let e=new URL(a,window.location.origin).pathname,t=Date.now()+2e3;for(;Date.now()<t&&!(typeof window<`u`&&window.location.pathname===e);)await new Promise(e=>setTimeout(e,80));let n=typeof window<`u`?window.location.pathname:e,r=typeof window<`u`?window.location.href:a,i=n===e,o=(n.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`;$(`fwh-navigate-mvp → SPA nav complete. target:`,e,`actual:`,n);try{typeof window<`u`&&window.scrollTo(0,0)}catch{}let s=[],c=null,l=``,u=Date.now()+12e3;for(;Date.now()<u&&(await new Promise(e=>setTimeout(e,300)),{headings:s,pageTitleHeading:c,introText:l}=Zh(),!(s.length>=1)););Xh(),$(`fwh-navigate-mvp → page headings collected:`,s,`titleHeading:`,c);let d=s.length?s.join(` | `):`none`,f=s.length?`Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate.`:`No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.`,p=c?` "${c}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${l||`(no intro text found)`}"`:l?` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${l}"`:``,m=``;try{if(s.length>0){let e=s.slice(0,3),t=[];for(let n of e){let e=fr(null,n);if(e){let r=Qh(e).substring(0,800);r&&t.push(`[Section: ${n}] ${r}`)}}t.length>0&&(m=` CONTENT FOR FIRST FEW SECTIONS: ${t.join(` | `)}. Use this content to answer immediately if the visitor asks about one of these sections.`)}}catch{}return Cr()?(xr(),$(`fwh-navigate-mvp ✖ landed on a not-found/404 page:`,r),`NAVIGATION_PAGE_NOT_FOUND. The page at ${r} does not exist — it shows a "not found"/404 error, not real content. Do NOT offer a page overview, do NOT describe or highlight any sections, do NOT claim the navigation succeeded. Tell the visitor EXACTLY: "It looks like that page doesn't exist — I couldn't find it. Would you like me to take you somewhere else?" Then STOP and wait for their reply.`):i?(xr(),`OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${d}.${p} ${f}${m} Speak EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for their reply.`):(xr(),`OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${d}.${p} ${f}${m} Speak EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for their reply.`)}catch{}let o=`this`;try{let e=new URL(a,window.location.href).pathname.split(`/`).filter(Boolean).pop()||``;o=e?e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`Home`}catch{}return`OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, say EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for the visitor's reply.`}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`fwh-navigate-mvp ✖`,t),xh(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Dh(),Sh(900)}},"fwh-highlight-mvp":async e=>{$(`fwh-highlight-mvp ▶`,e);let t=Jh(e),n=t?.section_id||t?.sectionId,r=t?.section_text||t?.sectionText;if(typeof window<`u`&&window.__fe_user_nav_during_speech){let e=window.__fe_user_nav_during_speech,t=window.location.pathname;if(Date.now()-e.ts>=3e4)window.__fe_user_nav_during_speech=null;else return $(`flowengage_highlight ✖ blocked — user navigated during speech`,e),`NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call flowengage_highlight again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`}Xh();let i=(e=>e&&e.replace(/^\d+\.\s*/,``).replace(/^["']|["']$/g,``).trim())(r),a=fr(n||null,i||null);if(!a&&i){let e=Date.now()+600;for(;!a&&Date.now()<e;)await new Promise(e=>setTimeout(e,50)),Xh(),a=fr(null,i)}if(!a){$(`fwh-highlight-mvp ✖ no element for:`,i||n);let{headings:e}=Zh(),t=e.length?`Page headings: ${e.map(e=>`"${e}"`).join(` | `)}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.`:`No headings found — skip highlight and continue speaking.`;return`HIGHLIGHT_NOT_FOUND: "${i||n}" on the current page. ${t}`}return An(a),$(`fwh-highlight-mvp ✓`,i||n),`OK_HIGHLIGHT: "${i||n}". WALKTHROUGH: continue immediately to the next section — do NOT pause between sections.`},"fwh-read-content-mvp":async e=>{$(`fwh-read-content-mvp ▶`,e);let t=Jh(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=fr(null,n);if(!t)return`Could not find section "${n}" on the page.`;e=Qh(t)}else{let t=(document.querySelector(`main`)||document.querySelector(`article`)||document.querySelector(`[role="main"]`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);t.querySelectorAll(`nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar, #flowengage-root, .flowengage-shell, .flowengage-widget-root`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`fwh-read-content-mvp ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`fwh-read-content-mvp ✖`,e.message),`Could not read page content: ${e.message}`}},"fwh-page-content-mvp":async e=>{$(`fwh-page-content-mvp ▶`,e);let r=Jh(e),i=r?.url||r?.page_url||``;if($(`fwh-page-content-mvp · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`fwh-page-content-mvp ✖ missing url`),`Missing url parameter.`;if(!t)return $(`fwh-page-content-mvp ✖ no siteId`),`Site is not configured.`;if(!n)return $(`fwh-page-content-mvp ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`fwh-page-content-mvp → POST`,e);let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,url:i})}),a=await r.json();if($(`fwh-page-content-mvp · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`fwh-page-content-mvp ✖`,e),`${e} FALLBACK REQUIRED: This page is not in the search index. Call fwh-read-content-mvp (no parameters) immediately to read the live page content directly from the visitor's browser — do NOT tell the visitor you cannot access the page.`}return $(`fwh-page-content-mvp ✓`,`title: ${a.title}`,`sections: ${(a.sections||[]).length}`,`content: ${(a.content||``).length} chars`),JSON.stringify({title:a.title,url:a.url,sections:a.sections,content:a.content})}catch(e){let t=`Page content error: ${e.message||`network`}`;return $(`fwh-page-content-mvp ✖`,t),t}},"fwh-search-mvp":async e=>{$(`fwh-search-mvp ▶`,e);let r=Jh(e).query;if(!r)return $(`fwh-search-mvp ✖ missing query`),`Missing query parameter.`;if(!t)return $(`fwh-search-mvp ✖ no siteId`),`Search unavailable (no siteId configured).`;if(!n)return $(`fwh-search-mvp ✖ no api base`),`Search unavailable (no API base URL).`;try{let e=`${n}/api/site-tools/search`;$(`fwh-search-mvp → POST`,e);let i=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,query:r,currentUrl:typeof window<`u`?window.location.href:``})}),a=await i.json();if($(`fwh-search-mvp · HTTP`,i.status,`success:`,a.success),!a.success||!a.results?.length)return`No results found for that query. Try rephrasing, or use fwh-read-content-mvp to read the current page.`;let o=a.results.slice(0,5).map((e,t)=>`${t+1}. ${e.title||e.url} (${e.url})${e.snippet?` — ${e.snippet}`:``}`).join(`
|
|
343
|
-
`);return $(`fwh-search-mvp ✓`,`${a.results.length} result(s)`),`SEARCH_RESULTS:\n${o}`}catch(e){return $(`fwh-search-mvp ✖`,e.message),`Search failed. Use fwh-read-content-mvp to read the current page instead.`}},"fwh-list-nav-links-mvp":async()=>{if($(`fwh-list-nav-links-mvp ▶`),typeof window>`u`)return`Cannot read navigation (no browser context).`;let e=new Map,t=[],n=[`nav a`,`[role='navigation'] a`,`header a`,`.navbar a`,`.nav a`,`.menu a`,`.navigation a`,`.header a`,`[class*='nav'] a`,`[class*='menu'] a`,`[class*='header'] a`];if(
|
|
344
|
-
`);return $(`fwh-list-nav-links-mvp ✓`,`${t.length} links`),`NAV_LINKS (${t.length} total, showing up to 50):\n${r}\n\nIMPORTANT: Use the EXACT text shown above when reading link names to the visitor. Do NOT rename, abbreviate, or invent options not listed here. To navigate, call fwh-navigate-mvp with the href value.`},"fwh-end-session-mvp":async()=>($(`fwh-end-session-mvp ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),"fwh-request-email-mvp":async()=>($(`fwh-request-email-mvp ▶`),typeof e.requestEmailCollection==`function`&&e.requestEmailCollection(),`EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: "Please enter your email in the text box to continue." Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message.`),"fwh-get-current-page-mvp":async()=>{if($(`fwh-get-current-page-mvp ▶`),typeof window>`u`)return`Cannot determine current page (no browser context).`;let e=window.location.href,t=window.location.pathname,n=document.title||``,{headings:r,pageTitleHeading:i,introText:a}=Zh();$(`fwh-get-current-page-mvp ✓`,{url:e,path:t,title:n}),$(`fwh-get-current-page-mvp → page headings collected:`,r,`titleHeading:`,i);let o=i?` NOTE: "${i}" is the PAGE TITLE, not a content section — do NOT fwh-highlight-mvp it or list it as a separate section in a walkthrough. Instead, open with a brief 1-2 sentence summary of this intro text before covering the real sections: "${a||`(no intro text captured)`}"`:a?` NOTE: no separate page-title heading was detected, but this intro text appears before the first section — open your walkthrough with a brief 1-2 sentence summary of it before covering sections: "${a}"`:``;if(!r.length)return`CURRENT_PAGE. URL: ${e} | Title: ${n} |${o} No structured section headings found on this page. If there is intro text above, describe it; otherwise describe the page from your knowledge. Do not call this tool again.`;let s=r.map(e=>`"${e}"`).join(` | `);return`CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o} *** WALKTHROUGH RULES: (1) For fwh-highlight-mvp, pass the heading text EXACTLY as shown — no numbers, no extra punctuation, no paraphrasing. (2) TIMING IS CRITICAL: the tool fires AFTER the speech that comes before it. This means: put the SHORT TRANSITION (1-5 words) BEFORE the tool call, put the FULL DESCRIPTION AFTER the tool call. Pattern: "Transition phrase." + fwh-highlight-mvp("Heading") + "Full description (3-4 sentences)". NEVER describe a section before calling its highlight tool. (3) DO NOT call this tool again. If the visitor requested a walkthrough: START IT NOW${o?` (open with the intro note above first)`:``} — "Let me walk you through this." + fwh-highlight-mvp("${r[0]||`first heading`}") + "Description..." etc. Cover ALL ${r.length} sections without pausing. ***`},"fwh-list-forms-mvp":async()=>{let e=Hh(),t=Uh();$(`fwh-list-forms-mvp ✓`,`${e.length} field(s)`,`${t.length} button(s)`);let n=e.map(e=>({...e,inputCategory:e.tag===`SELECT`?`dropdown_select`:`text_input`}));return JSON.stringify({fields:n,buttons:t,hint:`field_key: use the label/placeholder/name shown above. CRITICAL: fields with inputCategory='dropdown_select' are SELECT elements — their field_key must match the SELECT's own label (e.g. 'Company Size'), NOT the option text (e.g. 'Small Business') and NOT a nearby text input label. Never fill a SELECT option value into a text input.`})},"fwh-fill-form-mvp":async()=>`FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.`,"fwh-click-button-mvp":async e=>{let t=Jh(e),n=(t.button_text??t.buttonText??t.text??``).trim(),r=(t.card_context??t.cardContext??``).trim();if($(`fwh-click-button-mvp ▶`,n,r?`(card_context: ${r})`:``),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let a=qh(n,i,r);if(!a)return $(`fwh-click-button-mvp ✖ no match`),`Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;try{xh(`Clicking ${n}...`,{spinner:!0});try{a.scrollIntoView({block:`center`,inline:`nearest`})}catch{a.scrollIntoView(!0)}await Mh(a),a.focus?.(),await Ph(a),Fh(a),a.click();let e=(a.textContent||a.value||a.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`fwh-click-button-mvp ✓`,t),xh(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`fwh-click-button-mvp ✖`,t),xh(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Nh(),Sh(700)}}};return{...a,highlightOnPage:a[`fwh-highlight-mvp`],getPageContent:a[`fwh-page-content-mvp`],endVoiceSession:a[`fwh-end-session-mvp`],listPageForms:a[`fwh-list-forms-mvp`],fillFormFields:a[`fwh-fill-form-mvp`],clickPageButton:a[`fwh-click-button-mvp`]}}function eg(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=Dn();r?console.log(`[FlowEngage:voice-tool] ▶`,e,n):console.info(`[FlowEngage] voice tool » ${e}`);let i;try{i=await t(n)}catch(t){let n=`Tool error: ${t?.message||String(t)}`;return console.error(`[FlowEngage] voice tool ${e} threw:`,t),n}let a=typeof i==`string`?i.length>220?`${i.slice(0,220)}…`:i:String(i);return r?console.log(`[FlowEngage:voice-tool] ◀`,e,a):console.info(`[FlowEngage] voice tool « ${e}:`,a),i}]))}var tg={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function ng(e){if(!Array.isArray(e)||e.length<2)return`linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa`;let[t,n,r]=e;return e.length>=3&&r?[`radial-gradient(ellipse 80% 70% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 70% 80% at 110% 30%, ${n}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 60% at 50% 110%, ${r}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `):[`radial-gradient(ellipse 80% 100% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 100% at 110% 50%, ${n}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `)}function rg(e){if(!e||typeof e!=`string`)return`#1a1a1a`;let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255,o=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return .2126*o(r)+.7152*o(i)+.0722*o(a)>.179?`#1a1a1a`:`#ffffff`}function ig(e){let[t,n]=b.useState(null),r=typeof e==`string`?e.trim():``;return b.useEffect(()=>{if(!r){n(null);return}n(null);let e=!1,t=new window.Image;return t.onload=()=>{e||n(r)},t.onerror=()=>{e||n(null)},t.src=r,()=>{e=!0}},[r]),t}function ag({logo:e,style:t}){let n=ig(typeof e==`string`?e:null);if(!e)return null;if(typeof e==`string`)return n?(0,B.jsx)(`img`,{src:n,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}}):null;let r=typeof e==`function`?b.createElement(e):b.isValidElement(e)?e:null;return r?(0,B.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:r}):null}function og({title:e}){return(0,B.jsx)(`div`,{style:{width:`100%`,height:`100%`,borderRadius:`16px`,background:`linear-gradient(135deg, rgba(59,130,246,0.16) 0%, rgba(59,130,246,0.08) 100%)`,color:`#2563eb`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`18px`,fontWeight:700,letterSpacing:`-0.03em`},children:String(e||`FE`).split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()||``).join(``)||`FE`})}function sg(e,t){let n=(t||``).trim();return n?!!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\b(hang\s+up|disconnect)\b/i.test(n)||e===`bot`&&(/\b(that'?s all|we'?re done)\b/i.test(n)||/\b(goodbye|bye)\b/i.test(n)||/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n)||/\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n)||/\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n)||/\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n)||/\b(wrapping\s+up|signing\s+off)\b/i.test(n))):!1}function cg({orbColors:e,...t}){return(0,B.jsx)(sh,{colors:e,...t})}function lg({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a,isClosing:o}){let s=n||tg.green,c=rg(s),l=a?72:94,u=(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:a?`flex-end`:`center`,gap:a?`7px`:`9px`},children:[(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(dm.p,{initial:{x:-16,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.36},style:{margin:`0 0 14px`,fontSize:`14px`,fontWeight:700,color:`white`,lineHeight:1.4,textShadow:`0 1px 4px rgba(0,0,0,0.35)`,maxWidth:`210px`,wordBreak:`break-word`,overflow:`hidden`,display:`-webkit-box`,WebkitLineClamp:4,WebkitBoxOrient:`vertical`},children:e.entryPrompt}),(0,B.jsxs)(dm.div,{initial:{y:10,opacity:0},animate:{y:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.54},style:{display:`flex`,gap:`16px`,flexWrap:`nowrap`},children:[(0,B.jsx)(`button`,{onClick:r,style:{height:`31px`,boxSizing:`border-box`,padding:`0 16px`,borderRadius:`999px`,background:s,color:c,fontWeight:400,fontSize:`14px`,border:`none`,cursor:`pointer`,whiteSpace:`nowrap`,boxShadow:`0 4px 16px ${s}66`,transition:`transform 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.04)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.yesLabel}),(0,B.jsx)(`button`,{onClick:i,style:{height:`31px`,boxSizing:`border-box`,padding:`0 16px`,borderRadius:`999px`,background:`transparent`,color:`white`,fontWeight:400,fontSize:`14px`,border:`2px solid rgba(255,255,255,0.55)`,cursor:`pointer`,whiteSpace:`nowrap`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.9)`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.55)`},children:e.laterLabel})]})]}),(0,B.jsx)(dm.div,{initial:{x:120,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:220,damping:22,delay:0},style:{flexShrink:0},children:(0,B.jsx)(cg,{size:l,orbColors:t})})]});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(dm.div,{initial:{opacity:0},animate:{opacity:o?0:1},transition:{duration:.28},style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.72)`,zIndex:-1}}),a?(0,B.jsx)(`div`,{style:{position:`absolute`,bottom:0,left:0,right:0,padding:`24px 20px 40px`,overflow:`hidden`,animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u}):(0,B.jsx)(`div`,{style:{animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u})]})}function ug({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a,isMobile:o,isClosing:s}){let c=n||tg.green,l=rg(c);return(0,B.jsxs)(dm.div,{initial:{scale:50/350,borderRadius:`50%`},animate:s?{scale:50/350,opacity:0,borderRadius:`50%`}:{scale:1,borderRadius:`16px`,opacity:1},transition:{type:`spring`,stiffness:260,damping:26},style:{transformOrigin:o?`bottom center`:`bottom right`,background:`white`,width:o?`100%`:`350px`,height:`245px`,padding:`24px 40px 32px`,boxSizing:`border-box`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`space-between`,boxShadow:`0 20px 60px rgba(0,0,0,0.2)`,position:`relative`,overflow:`hidden`},children:[(0,B.jsx)(`button`,{onClick:a,style:{position:`absolute`,top:`14px`,right:`14px`,background:`none`,border:`none`,cursor:`pointer`,color:`#9ca3af`,padding:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:(0,B.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,B.jsx)(cg,{size:72,orbColors:t}),(0,B.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,B.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,lineHeight:1.4},children:e.connectionTitle}),e.connectionSubtitle&&(0,B.jsx)(`p`,{style:{margin:`6px 0 0`,fontSize:`13px`,fontWeight:400,color:`#6b7280`,lineHeight:1.4},children:e.connectionSubtitle})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,width:`100%`},children:[(0,B.jsx)(`button`,{onClick:r,style:{width:`127px`,height:`43px`,borderRadius:`999px`,background:c,color:l,fontWeight:400,fontSize:`16px`,border:`none`,cursor:`pointer`,transition:`transform 0.15s ease`,boxShadow:`0 4px 12px ${c}55`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.03)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.voiceLabel}),(0,B.jsx)(`button`,{onClick:i,style:{width:`127px`,height:`43px`,borderRadius:`999px`,background:`transparent`,color:`#111827`,fontWeight:400,fontSize:`16px`,border:`1.5px solid #d1d5db`,cursor:`pointer`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`#6b7280`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`#d1d5db`},children:e.textLabel})]})]})}function dg({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,chatId:o,historyRef:s,onMessageSync:c,voiceEndCounter:l,websiteName:u,voiceFirstMessage:d,captureVisitorEmail:f,emailRequired:p,emailCaptureEnabled:m=!0,listeningLabel:h=`Listening...`,enterChatModeLabel:g=`Enter Chat Mode`,endConversationLabel:_=`End Conversation`}){(0,b.useEffect)(()=>(console.log(`[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED`),()=>console.log(`[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED`)),[]);let[v,y]=(0,b.useState)(`idle`),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(!1),[ee,T]=(0,b.useState)(!1),[te,ne]=(0,b.useState)(``),[re,E]=(0,b.useState)(``),ie=(0,b.useRef)(!1),ae=(0,b.useRef)(!1),oe=(0,b.useRef)(null),se=(0,b.useRef)(0),ce=(0,b.useRef)(``),D=(0,b.useRef)(null),O=(0,b.useRef)(``),le=(0,b.useRef)(async()=>{}),ue=(0,b.useRef)(!1),de=(0,b.useRef)(!1),fe=(0,b.useRef)(!1),k=(0,b.useRef)(!1),A=(0,b.useRef)(`minimized`),pe=(0,b.useRef)(null),me=(0,b.useRef)(null),he=(0,b.useRef)(null),ge=(0,b.useRef)(0),_e=(0,b.useRef)(!1),ve=(0,b.useRef)(`idle`),ye=(0,b.useRef)(!1),j=(0,b.useRef)(!1),be=(0,b.useRef)(null),xe=(0,b.useRef)(null),Te=(0,b.useRef)(!1),De=(0,b.useCallback)((e=`minimized`)=>{console.warn(`[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called`,{destination:e,stack:Error().stack?.split(`
|
|
345
|
-
`).slice(1,4).join(` | `)}),A.current=e,k.current=!0,queueMicrotask(()=>{ue.current||(ue.current=!0,le.current?.())})},[s]),Oe=(0,b.useCallback)(()=>{oe.current&&=(clearTimeout(oe.current),null)},[]),ke=(0,b.useCallback)(()=>{Oe(),oe.current=setTimeout(()=>{if(!(!ae.current||ie.current))if(se.current<3){se.current+=1;try{D.current?.sendUserMessage?.(`[SYSTEM: The visitor still has NOT entered their email in the text box. Remind them once, briefly and warmly: 'I still need your email in the box below to continue — could you enter it, please?' Then stay completely silent again. Do NOT answer any other question until the email is provided.]`)}catch{}ke()}else{try{D.current?.sendUserMessage?.(`[SYSTEM: The visitor did not provide their email after multiple reminders. Say a brief, warm goodbye EXACTLY like: 'Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!' Then stop talking. Do NOT ask for the email again.]`)}catch{}ae.current=!1,T(!1),Oe(),_e.current=!0}},1e4)},[Oe]),Ae=(0,b.useCallback)(async e=>{k.current=!0;try{jn()}catch{}if(i)try{Pe(i)}catch{}try{await D.current?.endSession?.()}catch{}let t=pe.current,n=me.current;if(t&&o&&a){let e=n?Math.round((Date.now()-n)/1e3):0;fetch(`${a}/api/voice/save-chat-recording`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:o,elevenLabsConversationId:t,duration:e,siteId:i})}).catch(e=>console.warn(`[FlowEngage] save-chat-recording failed:`,e.message))}if(pe.current=null,me.current=null,D.current=null,y(`idle`),S(!1),ue.current=!1,Or(),i)try{we(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);le.current=()=>Ae(A.current===`chat`?t:n),(0,b.useEffect)(()=>{de.current=x},[x]),(0,b.useEffect)(()=>{l&&De(`chat`)},[l]),(0,b.useEffect)(()=>{let e=!1,l=null,f=null,h=null;return(async()=>{if(!i){y(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],O.current=``,ue.current=!1,fe.current=!1,k.current=!1,A.current=`minimized`,Dr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=gh(s.current);e&&Se(i,e)}catch{}if(!Zn()){let e=pe.current,t=me.current;if(e&&o&&a)try{let n=t?Math.round((Date.now()-t)/1e3):0,r=JSON.stringify({chatId:o,elevenLabsConversationId:e,duration:n,siteId:i}),s=`${a}/api/voice/save-chat-recording`;fetch(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0}).catch(()=>{}),pe.current=null,me.current=null}catch{}}Ee()}});let t=eg($h({siteId:i||null,apiBaseUrl:a||null,chatId:o||null,getLastUserVoiceText:()=>O.current,requestEndSession:()=>{_e.current=!0},requestEmailCollection:()=>{m&&(ie.current||ae.current||(ae.current=!0,se.current=0,T(!0),ke()))}})),n=i?Ce(i):null,r=!!n?.transcript,c=i?Pe(i):null,g=!!c,_=typeof window<`u`?window.location.pathname:`/`,v=typeof document<`u`?document.title:``,b=_.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,``)||`/`,x=b===`/`||b===``,C={apiBaseUrl:a,siteId:i,chatId:o,clientTools:t},w=(_.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),ee=``;v&&v.includes(`|`)&&(ee=v.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let te=ee||w||`this page`;if(g){let e=c?.pageName||te;C.greeting=`I have navigated you on ${e} page. Do you want to know about any specific section or want a complete overview?`,console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${_})`)}else if(r)C.greeting=`Welcome back! I see you're now on the ${te} page. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;else{let e=u||``;C.greeting=d||(x?e?`Hi, welcome to ${e}! How may I help you?`:`Hi, welcome! How may I help you?`:`Welcome to the ${te} page!`),x||console.log(`[FlowEngage] 🏠 Page-context greeting: "${te}" for ${_}`)}let ne=!1,re=g?`NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.`:null,E=!1,oe=!g&&!r?`Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead.`:null,le=r&&!g,he=!1,we=le?`The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript, or the visitor navigated before saying much)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.`:null,Oe=!1,Ae=!1,Me=m&&!!p,Ne=await ym.startSession({...C,onConnect:({conversationId:e})=>{pe.current=e,me.current=Date.now(),console.log(`[FlowEngage] 🎙️ AI chat session connected:`,e)},onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onModeChange:({mode:t})=>{if(!e){if(t===`speaking`){xe.current&&=(clearTimeout(xe.current),null),y(`speaking`),ve.current=`speaking`,ye.current=!0,Te.current=!1,be.current&&=(clearTimeout(be.current),null);return}if(ve.current=`listening`,_e.current){_e.current=!1,De();return}if(Me&&!Ae){Ae=!0,ne=!0,E=!0;try{D.current?.sendContextualUpdate?.(`CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: "Before I answer that, could you please enter your email in the text box below?" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be "Before". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.`)}catch{}}if(re&&!ne){ne=!0;try{D.current?.sendContextualUpdate?.(re)}catch{}}if(we&&!he){he=!0;try{D.current?.sendContextualUpdate?.(we)}catch{}}if(oe&&!E){E=!0;try{D.current?.sendContextualUpdate?.(oe)}catch{}}xe.current&&clearTimeout(xe.current),xe.current=setTimeout(()=>{e||ve.current!==`speaking`&&(Te.current||(xe.current=null,ve.current=`listening`,y(`listening`),ye.current&&j.current&&!de.current&&!ae.current&&(be.current&&clearTimeout(be.current),be.current=setTimeout(()=>{if(!e&&ve.current===`listening`&&!de.current&&!ae.current)try{D.current?.sendContextualUpdate?.(`The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.`)}catch{}},15e3))))},1200)}},onMessage:t=>{if(e)return;let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;if(r){if(n===`user`){O.current=r,Te.current=!0,j.current=!0,xe.current&&=(clearTimeout(xe.current),null),be.current&&=(clearTimeout(be.current),null);try{jn()}catch{}Me&&!Oe&&!ie.current&&(Oe=!0,ce.current=r,ae.current||(ae.current=!0,se.current=0,T(!0),ke()))}if(s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString()}],i)try{let e=gh(s.current);e&&Se(i,e)}catch{}if(sg(n,r)){_e.current=!0;return}if(de.current&&n===`bot`&&/are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r))if(ge.current+=1,ge.current===2)try{D.current?.sendContextualUpdate?.(`IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.`)}catch{}else ge.current>=5&&De(`minimized`)}},onError:t=>{if(!e&&!k.current&&!fe.current&&!je()){fe.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{D.current?.setMicMuted?.(!0)}catch{}S(!0),y(`error`),De(`chat`)}},onDisconnect:t=>{if(e||k.current||fe.current||je())return;let n=s.current?.length||0;console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:n,reason:t?.reason,closeCode:t?.context?.code,closeReason:t?.context?.reason||t?.message,lastUserText:O.current||``,wasMuted:de.current}),fe.current=!0;try{D.current?.setMicMuted?.(!0)}catch{}S(!0),De(`chat`)}});if(e){console.warn(`[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately`),Ne.endSession().catch(()=>{});return}l=Ne,D.current=Ne,y(`listening`);try{let e=typeof window<`u`?window.location.href:``,a=`[]`;try{a=await t[`fwh-list-forms-mvp`]()}catch{}let o=`none`;if(typeof window<`u`&&typeof document<`u`)try{let e=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`,t=document.querySelector(`main, [role='main']`)||document.body,n=Array.from(t.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200);n.length||(n=Array.from(document.body.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200)),n.length&&(o=[...new Set(n)].slice(0,15).join(` | `))}catch{}let s=r&&!g?`RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript||``}\n\n`:``;Ne.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i||`unknown`}. Forms: ${a}. ${p?``:`Visitor's email is already on file from a prior session — do NOT ask for it again. `}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`)}catch{}if(typeof window<`u`){let t=window.location.pathname,n=()=>{if(e)return;let n=window.location.pathname;if(n===t)return;if(Un()){t=n;return}let r=t;t=n;let i=window.location.href,a=typeof document<`u`?document.title:``,o=typeof document<`u`?Array.from(document.querySelectorAll(`h1, h2, h3, h4`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell`)).map(e=>({tag:e.tagName,text:e.textContent.trim()})).filter(e=>e.text.length>0&&e.text.length<200).slice(0,20):[];try{jn()}catch{}let s=e=>(e.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`,c=s(r),l=s(n);typeof window<`u`&&(window.__fe_user_nav_during_speech={fromPath:r,toPath:n,fromPageName:c,toPageName:l,ts:Date.now()});try{D.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${l}" page (${i}). Page title: "${a}". Sections: ${JSON.stringify(o)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${l} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call flowengage_navigate, do NOT call flowengage_highlight, the visitor will navigate themselves if needed. IF I want to hear about this page: call flowengage_highlight for sections of "${l}" only.]`)}catch{}};f=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{f(...e),setTimeout(n,50)},h=()=>setTimeout(n,50),window.addEventListener(`popstate`,h)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(y(`error`),A.current=`chat`,window.setTimeout(()=>{e||t?.()},0)))}})(),()=>{console.warn(`[FlowEngage:VoiceDebug] ⚠️ useEffect CLEANUP fired — session will be killed`,{agentId:r,siteId:i,apiBaseUrl:a}),e=!0,k.current=!0;try{jn()}catch{}if(i)try{Pe(i)}catch{}typeof window<`u`&&(window.__fe_user_nav_during_speech=null),Or(),be.current&&=(clearTimeout(be.current),null),xe.current&&=(clearTimeout(xe.current),null),oe.current&&=(clearTimeout(oe.current),null),ye.current=!1,Te.current=!1,ve.current=`idle`,f&&typeof window<`u`&&(window.history.pushState=f),h&&typeof window<`u`&&window.removeEventListener(`popstate`,h);let t=l||D.current,n=pe.current,u=me.current;if(t?.endSession?.().catch(()=>{}),n&&o&&a){let e=u?Math.round((Date.now()-u)/1e3):0,t=JSON.stringify({chatId:o,elevenLabsConversationId:n,duration:e,siteId:i}),r=`${a}/api/voice/save-chat-recording`;typeof navigator<`u`&&navigator.sendBeacon&&navigator.sendBeacon(r,new Blob([t],{type:`application/json`}))||fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:t,keepalive:!0}).catch(()=>{}),pe.current=null,me.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,De]),(0,b.useEffect)(()=>{if(!C)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;he.current&&!he.current.contains(t)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[C]);let Me=async()=>{if(D.current)try{if(x){ge.current=0,await D.current.setMicMuted?.(!1),S(!1);try{D.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{ge.current=0,await D.current.setMicMuted?.(!0),S(!0);try{D.current.sendContextualUpdate?.(`The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.`)}catch{}}}catch{}},Ne=(0,b.useCallback)(async e=>{e?.preventDefault?.();let t=te.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){E(`Please enter a valid email address.`);return}E(``);try{typeof f==`function`&&await f(t)}catch{}ie.current=!0,ae.current=!1,Oe(),T(!1),ne(``);let n=ce.current;ce.current=``;try{D.current?.sendUserMessage?.(`[SYSTEM: EMAIL_SAVED — the visitor typed and submitted their email address. Say a brief 'Thank you!' and then `+(n?`immediately answer their original question fully: "${n}".`:`continue helping them.`)+` Do NOT ask for their email again.]`)}catch{}},[te,f,Oe]),Fe=Array.isArray(e)&&e[0]||`#3B82F6`;return(0,B.jsxs)(`div`,{ref:he,style:{position:`relative`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`14px`,animation:`fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)`},children:[ee&&(0,B.jsxs)(`form`,{onSubmit:Ne,style:{width:`270px`,maxWidth:`calc(100vw - 40px)`,boxSizing:`border-box`,background:`rgba(15,22,36,0.97)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,padding:`16px`,display:`flex`,flexDirection:`column`,gap:`10px`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,B.jsx)(`span`,{style:{color:`white`,fontSize:`13px`,fontWeight:600,lineHeight:1.4},children:`Please enter your email to continue`}),(0,B.jsx)(`input`,{type:`email`,inputMode:`email`,autoComplete:`email`,autoFocus:!0,value:te,onChange:e=>{ne(e.target.value),re&&E(``)},placeholder:`you@example.com`,style:{width:`100%`,boxSizing:`border-box`,padding:`10px 12px`,borderRadius:`10px`,border:re?`1.5px solid #ef4444`:`1.5px solid #4b5563`,background:`#1f2937`,color:`white`,fontSize:`14px`,outline:`none`}}),re&&(0,B.jsx)(`span`,{style:{color:`#f87171`,fontSize:`12px`},children:re}),(0,B.jsx)(`button`,{type:`submit`,disabled:!te.trim(),style:{width:`100%`,padding:`10px 12px`,borderRadius:`10px`,border:`none`,background:te.trim()?Fe:`#374151`,color:`white`,fontSize:`14px`,fontWeight:600,cursor:te.trim()?`pointer`:`default`,transition:`background 0.2s ease`},children:`Submit`})]}),(0,B.jsxs)(`div`,{style:{position:`relative`},children:[v===`listening`&&!x&&(0,B.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`white`,fontSize:`18px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:h}),x&&(0,B.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`#f87171`,fontSize:`16px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:`Muted`}),(0,B.jsx)(cg,{size:72,voiceState:v,isMuted:x,orbColors:e})]}),v===`error`&&(0,B.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,B.jsx)(`button`,{onClick:Me,title:x?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:x?`#7f1d1d`:`#1f2937`,border:x?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:x?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:x?(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,B.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,B.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,B.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,B.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,B.jsx)(bm,{size:16,color:`currentColor`})}),(0,B.jsx)(`button`,{onClick:()=>w(e=>!e),style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:`#1f2937`,border:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`,transition:`background 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:(0,B.jsx)(Om,{size:16,color:`currentColor`})})]}),C&&(0,B.jsxs)(`div`,{style:{position:`absolute`,bottom:0,right:0,width:`230px`,zIndex:9999,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,animation:`fe-orb-fade-in 0.18s ease`,padding:`12px 12px 40px`},children:[(0,B.jsxs)(`button`,{onClick:()=>{w(!1),A.current=`chat`,Ae(t)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsx)(km,{}),g]}),(0,B.jsxs)(`button`,{onClick:()=>{w(!1),A.current=`minimized`,Ae(n)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`#E30C12`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(227,12,18,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsx)(Am,{}),_]}),(0,B.jsx)(`button`,{onClick:()=>w(!1),style:{position:`absolute`,bottom:`8px`,right:`8px`,width:`24px`,height:`24px`,borderRadius:`50%`,background:`rgba(255,255,255,0.15)`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.25)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.15)`},children:(0,B.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,B.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]})}function fg({orbColors:e}){let t=Array.isArray(e)&&e.length>0?e:[`#135bd8`,`#ef334b`,`#ffbd2e`],n=t[0],r=t[1]||t[0],i=t[2]||t[0];return(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,flexShrink:0,background:`
|
|
342
|
+
`).trim()}function eg(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={"fwh-navigate-mvp":async n=>{$(`fwh-navigate-mvp ▶ raw parameters:`,n);let i=Yh(n),a=Xh(i),o=i.section_text??i.sectionText??i.section,s=Array.isArray(i.expected_landmarks)?i.expected_landmarks:Array.isArray(i.expectedLandmarks)?i.expectedLandmarks:[];if($(`fwh-navigate-mvp · coerced:`,{url:a,sectionText:o,expectedLandmarks:s}),!a){let e=`Missing url: pass a string url, path like /pricing, or JSON with a url field.`;return $(`fwh-navigate-mvp ✖`,e),e}if(typeof window<`u`)try{let e=new URL(a,window.location.href);if(e.origin!==window.location.origin&&/^https?:$/i.test(e.protocol)){let t=e.hostname;return $(`fwh-navigate-mvp ✖ external URL blocked:`,e.href),`EXTERNAL_LINK_BLOCKED: The URL "${a}" points to an external site (${t}) that opens in a new tab. I cannot open new tabs or navigate to external sites. Tell the visitor exactly this: "That link opens an external app — I'm not able to open it for you, but you can click the link directly in the navigation header."`}}catch{}if(typeof window<`u`){try{let e=new URL(a,window.location.href);if(e.pathname===window.location.pathname&&e.search===window.location.search)return $(`fwh-navigate-mvp ✖ already on page, skipping`),`OK_ALREADY_ON_PAGE. The visitor is already on this page. Do not navigate. Proceed directly with highlights, answering the question, or reading page content.`}catch{}let e=window.__fe_user_nav_during_speech;if(e&&Date.now()-e.ts<3e4)try{if(new URL(a,window.location.href).pathname===e.fromPath)return $(`flowengage_navigate ✖ blocked — would navigate back to page visitor just left`,e),`NAV_BLOCKED: The visitor just left "${e.fromPageName}" and is now on "${e.toPageName}". Do NOT navigate them back. If they said "continue", resume verbally from where you left off — no navigation needed. If they want to return, they will navigate themselves.`}catch{}}let{allowed:c,correctedUrl:l}=await _r(a,{siteId:t,apiBaseUrl:e.apiBaseUrl});if(!c){let e=`PAGE_NOT_IN_SITE: "${a}" is NOT a real page on this site — do NOT guess or invent URL paths. Do NOT tell the visitor you are taking them there. Instead, find the REAL page: look at your Popular Pages / Site Pages list for the closest actual match, or call fwh-list-nav-links-mvp (to read the site's real menu links) or fwh-search-mvp (to find the right page). If a close match exists (e.g. the visitor said "support" and the site has "Technical Support"), tell them the ACTUAL page name and ask "we don't have a page called that, but we do have [real page] — would you like me to take you there?" Then navigate only to that verified URL.`;return $(`fwh-navigate-mvp ✖ blocked`,e),e}l&&l!==a&&($(`fwh-navigate-mvp · corrected url:`,{requested:a,correctedUrl:l}),a=l);try{Sh(`Navigating to ${a}...`,{spinner:!0}),Dh(),jn();try{let e=r?r():``;if(e&&t){let n=_h([{sender:`user`,message:e}]);n&&Se(t,n)}}catch{}Ee();let e=a;try{e=new URL(a,typeof window<`u`?window.location.href:``).href}catch{}let n=`this`;try{let e=new URL(a,window.location.href).pathname.split(`/`).filter(Boolean).pop()||``;n=e?e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`Home`}catch{}t&&typeof window<`u`&&Ne(t,window.location.href,e,n),br(e),$(`fwh-navigate-mvp → real navigation`,a);let i=typeof window<`u`&&!!Zn();if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),i&&Hn(12e3),wr(a,{voiceActive:!0}).catch(()=>{}),i)try{let e=new URL(a,window.location.origin).pathname,t=Date.now()+2e3;for(;Date.now()<t&&!(typeof window<`u`&&window.location.pathname===e);)await new Promise(e=>setTimeout(e,80));let n=typeof window<`u`?window.location.pathname:e,r=typeof window<`u`?window.location.href:a,i=n===e,o=(n.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`;$(`fwh-navigate-mvp → SPA nav complete. target:`,e,`actual:`,n);try{typeof window<`u`&&window.scrollTo(0,0)}catch{}let s=[],c=null,l=``,u=Date.now()+12e3;for(;Date.now()<u&&(await new Promise(e=>setTimeout(e,300)),{headings:s,pageTitleHeading:c,introText:l}=Qh(),!(s.length>=1)););Zh(),$(`fwh-navigate-mvp → page headings collected:`,s,`titleHeading:`,c);let d=s.length?s.join(` | `):`none`,f=s.length?`Use ONLY these exact heading strings for fwh-highlight-mvp — never invent or abbreviate.`:`No headings collected yet — call fwh-get-current-page-mvp immediately (no speech) to get the live headings before speaking or highlighting.`,p=c?` "${c}" is the PAGE TITLE, not a content section — do not fwh-highlight-mvp it separately; if doing a walkthrough, just fold this intro into your opening line: "${l||`(no intro text found)`}"`:l?` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${l}"`:``,m=``;try{if(s.length>0){let e=s.slice(0,3),t=[];for(let n of e){let e=fr(null,n);if(e){let r=$h(e).substring(0,800);r&&t.push(`[Section: ${n}] ${r}`)}}t.length>0&&(m=` CONTENT FOR FIRST FEW SECTIONS: ${t.join(` | `)}. Use this content to answer immediately if the visitor asks about one of these sections.`)}}catch{}return Cr()?(xr(),$(`fwh-navigate-mvp ✖ landed on a not-found/404 page:`,r),`NAVIGATION_PAGE_NOT_FOUND. The page at ${r} does not exist — it shows a "not found"/404 error, not real content. Do NOT offer a page overview, do NOT describe or highlight any sections, do NOT claim the navigation succeeded. Tell the visitor EXACTLY: "It looks like that page doesn't exist — I couldn't find it. Would you like me to take you somewhere else?" Then STOP and wait for their reply.`):i?(xr(),`OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${d}.${p} ${f}${m} Speak EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for their reply.`):(xr(),`NAVIGATION_DID_NOT_HAPPEN. The visitor is STILL on ${r} (page: "${o}") — the navigation did not go through. Do NOT say "I have navigated you". Do NOT claim success. Tell the visitor EXACTLY: "Sorry, I couldn't open that page just now. Would you like me to try again, or is there something else I can help with?" Then STOP and wait for their reply.`)}catch{}let o=`this`;try{let e=new URL(a,window.location.href).pathname.split(`/`).filter(Boolean).pop()||``;o=e?e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()):`Home`}catch{}return`OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, say EXACTLY: "I have navigated you on ${o} page. Do you want to know about any specific section or want a complete overview?" Then STOP — wait for the visitor's reply.`}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`fwh-navigate-mvp ✖`,t),Sh(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Oh(),Ch(900)}},"fwh-highlight-mvp":async e=>{$(`fwh-highlight-mvp ▶`,e);let t=Yh(e),n=t?.section_id||t?.sectionId,r=t?.section_text||t?.sectionText;if(typeof window<`u`&&window.__fe_user_nav_during_speech){let e=window.__fe_user_nav_during_speech,t=window.location.pathname;if(Date.now()-e.ts>=3e4)window.__fe_user_nav_during_speech=null;else return $(`flowengage_highlight ✖ blocked — user navigated during speech`,e),`NAV_CHANGED: The visitor navigated from "${e.fromPageName}" to "${e.toPageName}" (current path: ${t}) while you were speaking. STOP the current walkthrough immediately. DO NOT call flowengage_highlight again. Say out loud: "I see you've navigated to the ${e.toPageName} page — do you want me to continue what I was explaining, or shall I guide you through this page?" Wait for the visitor's answer before doing anything else.`}Zh();let i=(e=>e&&e.replace(/^\d+\.\s*/,``).replace(/^["']|["']$/g,``).trim())(r),a=fr(n||null,i||null);if(!a&&i){let e=Date.now()+600;for(;!a&&Date.now()<e;)await new Promise(e=>setTimeout(e,50)),Zh(),a=fr(null,i)}if(!a){$(`fwh-highlight-mvp ✖ no element for:`,i||n);let{headings:e}=Qh(),t=e.length?`Page headings: ${e.map(e=>`"${e}"`).join(` | `)}. Use one of these EXACT strings for section_text — no numbers, no quotes around them.`:`No headings found — skip highlight and continue speaking.`;return`HIGHLIGHT_NOT_FOUND: "${i||n}" on the current page. ${t}`}return An(a),$(`fwh-highlight-mvp ✓`,i||n),`OK_HIGHLIGHT: "${i||n}". Your NEXT response must be speech only (no tool call) describing THIS section — "${i||n}" — using its own content, then end with the continue question.`},"fwh-read-content-mvp":async e=>{$(`fwh-read-content-mvp ▶`,e);let t=Yh(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=fr(null,n);if(!t)return`Could not find section "${n}" on the page.`;e=$h(t)}else{let t=(document.querySelector(`main`)||document.querySelector(`article`)||document.querySelector(`[role="main"]`)||document.querySelector(`#content`)||document.querySelector(`.content`)||document.body).cloneNode(!0);t.querySelectorAll(`nav, footer, header, aside, script, style, noscript, .nav, .footer, .header, .sidebar, #flowengage-root, .flowengage-shell, .flowengage-widget-root`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`fwh-read-content-mvp ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`fwh-read-content-mvp ✖`,e.message),`Could not read page content: ${e.message}`}},"fwh-page-content-mvp":async e=>{$(`fwh-page-content-mvp ▶`,e);let r=Yh(e),i=r?.url||r?.page_url||``;if($(`fwh-page-content-mvp · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`fwh-page-content-mvp ✖ missing url`),`Missing url parameter.`;if(!t)return $(`fwh-page-content-mvp ✖ no siteId`),`Site is not configured.`;if(!n)return $(`fwh-page-content-mvp ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`fwh-page-content-mvp → POST`,e);let r=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,url:i})}),a=await r.json();if($(`fwh-page-content-mvp · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`fwh-page-content-mvp ✖`,e),`${e} FALLBACK REQUIRED: This page is not in the search index. Call fwh-read-content-mvp (no parameters) immediately to read the live page content directly from the visitor's browser — do NOT tell the visitor you cannot access the page.`}return $(`fwh-page-content-mvp ✓`,`title: ${a.title}`,`sections: ${(a.sections||[]).length}`,`content: ${(a.content||``).length} chars`),JSON.stringify({title:a.title,url:a.url,sections:a.sections,content:a.content})}catch(e){let t=`Page content error: ${e.message||`network`}`;return $(`fwh-page-content-mvp ✖`,t),t}},"fwh-search-mvp":async e=>{$(`fwh-search-mvp ▶`,e);let r=Yh(e).query;if(!r)return $(`fwh-search-mvp ✖ missing query`),`Missing query parameter.`;if(!t)return $(`fwh-search-mvp ✖ no siteId`),`Search unavailable (no siteId configured).`;if(!n)return $(`fwh-search-mvp ✖ no api base`),`Search unavailable (no API base URL).`;try{let e=`${n}/api/site-tools/search`;$(`fwh-search-mvp → POST`,e);let i=await fetch(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({siteId:t,query:r,currentUrl:typeof window<`u`?window.location.href:``})}),a=await i.json();if($(`fwh-search-mvp · HTTP`,i.status,`success:`,a.success),!a.success||!a.results?.length)return`No results found for that query. Try rephrasing, or use fwh-read-content-mvp to read the current page.`;let o=a.results.slice(0,5).map((e,t)=>`${t+1}. ${e.title||e.url} (${e.url})${e.snippet?` — ${e.snippet}`:``}`).join(`
|
|
343
|
+
`);return $(`fwh-search-mvp ✓`,`${a.results.length} result(s)`),`SEARCH_RESULTS:\n${o}`}catch(e){return $(`fwh-search-mvp ✖`,e.message),`Search failed. Use fwh-read-content-mvp to read the current page instead.`}},"fwh-list-nav-links-mvp":async()=>{if($(`fwh-list-nav-links-mvp ▶`),typeof window>`u`)return`Cannot read navigation (no browser context).`;let e=new Map,t=[],n=[`nav a`,`[role='navigation'] a`,`header a`,`.navbar a`,`.nav a`,`.menu a`,`.navigation a`,`.header a`,`[class*='nav'] a`,`[class*='menu'] a`,`[class*='header'] a`];if(zh(t=>{for(let r of n)try{t.querySelectorAll(r).forEach(t=>{if(Nn(t))return;let n=t.getAttribute(`href`),r=(t.textContent||``).replace(/\s+/g,` `).trim();if(!r||!n||n===`#`||n.startsWith(`javascript:`))return;try{let e=t.parentElement;if(e&&Rh(e).display===`none`&&!e.closest(`nav, [role='navigation'], header, [class*='nav'], [class*='menu']`))return}catch{}let i=r.toLowerCase()+`|`+n;e.has(i)||e.set(i,{text:r,href:n})})}catch{}t.querySelectorAll(`select`).forEach(t=>{if(Nn(t))return;let n=Vh(t);/nav|menu|page|section|go to/i.test(n||t.name||t.id||``)&&Array.from(t.options).forEach(r=>{if(!r.value||r.disabled)return;let i=r.text.trim();if(!i)return;let a=i.toLowerCase()+`|`+r.value;e.has(a)||e.set(a,{text:i,href:r.value,isSelectOption:!0,selectLabel:n||t.name||`dropdown`})})})}),e.forEach(e=>t.push(e)),!t.length)return`NAV_LINKS: No navigation links found on this page. Use fwh-read-content-mvp to read page content or fwh-search-mvp to search the site.`;let r=t.slice(0,50).map((e,t)=>`${t+1}. "${e.text}"${e.isSelectOption?` (dropdown option in "${e.selectLabel}")`:``} → ${e.href}`).join(`
|
|
344
|
+
`);return $(`fwh-list-nav-links-mvp ✓`,`${t.length} links`),`NAV_LINKS (${t.length} total, showing up to 50):\n${r}\n\nIMPORTANT: Use the EXACT text shown above when reading link names to the visitor. Do NOT rename, abbreviate, or invent options not listed here. To navigate, call fwh-navigate-mvp with the href value.`},"fwh-end-session-mvp":async()=>($(`fwh-end-session-mvp ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),"fwh-request-email-mvp":async()=>($(`fwh-request-email-mvp ▶`),typeof e.requestEmailCollection==`function`&&e.requestEmailCollection(),`EMAIL_BOX_SHOWN. An email input text box is now visible to the visitor. Say EXACTLY: "Please enter your email in the text box to continue." Then stop and wait silently — do NOT ask them to say it aloud, do NOT repeat, and do NOT answer any other question until you receive the EMAIL_SAVED message.`),"fwh-get-current-page-mvp":async()=>{if($(`fwh-get-current-page-mvp ▶`),typeof window>`u`)return`Cannot determine current page (no browser context).`;let e=window.location.href,t=window.location.pathname,n=document.title||``,{headings:r,pageTitleHeading:i,introText:a}=Qh();$(`fwh-get-current-page-mvp ✓`,{url:e,path:t,title:n}),$(`fwh-get-current-page-mvp → page headings collected:`,r,`titleHeading:`,i);let o=i?` NOTE: "${i}" is the PAGE TITLE, not a content section — do NOT fwh-highlight-mvp it or list it as a separate section in a walkthrough. Instead, open with a brief 1-2 sentence summary of this intro text before covering the real sections: "${a||`(no intro text captured)`}"`:a?` NOTE: no separate page-title heading was detected, but this intro text appears before the first section — open your walkthrough with a brief 1-2 sentence summary of it before covering sections: "${a}"`:``;if(!r.length)return`CURRENT_PAGE. URL: ${e} | Title: ${n} |${o} No structured section headings found on this page. If there is intro text above, describe it; otherwise describe the page from your knowledge. Do not call this tool again.`;let s=r.map(e=>`"${e}"`).join(` | `);return`CURRENT_PAGE. URL: ${e} | Title: ${n} | Page sections (${r.length} total): ${s}.${o} *** WALKTHROUGH RULES: (1) For fwh-highlight-mvp, pass the heading text EXACTLY as shown — no numbers, no extra punctuation, no paraphrasing. (2) TIMING IS CRITICAL: the tool fires AFTER the speech that comes before it. This means: put the SHORT TRANSITION (1-5 words) BEFORE the tool call, put the FULL DESCRIPTION AFTER the tool call. Pattern: "Transition phrase." + fwh-highlight-mvp("Heading") + "Full description (3-4 sentences)". NEVER describe a section before calling its highlight tool. (3) DO NOT call this tool again. If the visitor requested a walkthrough: START IT NOW${o?` (open with the intro note above first)`:``} — "Let me walk you through this." + fwh-highlight-mvp("${r[0]||`first heading`}") + "Description..." etc. Cover ALL ${r.length} sections without pausing. ***`},"fwh-list-forms-mvp":async()=>{let e=Uh(),t=Wh();$(`fwh-list-forms-mvp ✓`,`${e.length} field(s)`,`${t.length} button(s)`);let n=e.map(e=>({...e,inputCategory:e.tag===`SELECT`?`dropdown_select`:`text_input`}));return JSON.stringify({fields:n,buttons:t,hint:`field_key: use the label/placeholder/name shown above. CRITICAL: fields with inputCategory='dropdown_select' are SELECT elements — their field_key must match the SELECT's own label (e.g. 'Company Size'), NOT the option text (e.g. 'Small Business') and NOT a nearby text input label. Never fill a SELECT option value into a text input.`})},"fwh-fill-form-mvp":async()=>`FORM_FILLING_DISABLED: Form filling is not available at this time. Tell the visitor what fields are present (use fwh-list-forms-mvp) and ask them to fill the form themselves.`,"fwh-click-button-mvp":async e=>{let t=Yh(e),n=(t.button_text??t.buttonText??t.text??``).trim(),r=(t.card_context??t.cardContext??``).trim();if($(`fwh-click-button-mvp ▶`,n,r?`(card_context: ${r})`:``),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let a=Jh(n,i,r);if(!a)return $(`fwh-click-button-mvp ✖ no match`),`Could not find a button matching "${n}". Call fwh-list-forms-mvp to see button texts.`;try{Sh(`Clicking ${n}...`,{spinner:!0});try{a.scrollIntoView({block:`center`,inline:`nearest`})}catch{a.scrollIntoView(!0)}await Nh(a),a.focus?.(),await Fh(a),Ih(a),a.click();let e=(a.textContent||a.value||a.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`fwh-click-button-mvp ✓`,t),Sh(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`fwh-click-button-mvp ✖`,t),Sh(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Ph(),Ch(700)}}};return{...a,highlightOnPage:a[`fwh-highlight-mvp`],getPageContent:a[`fwh-page-content-mvp`],endVoiceSession:a[`fwh-end-session-mvp`],listPageForms:a[`fwh-list-forms-mvp`],fillFormFields:a[`fwh-fill-form-mvp`],clickPageButton:a[`fwh-click-button-mvp`]}}function tg(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=Dn();r?console.log(`[FlowEngage:voice-tool] ▶`,e,n):console.info(`[FlowEngage] voice tool » ${e}`);let i;try{i=await t(n)}catch(t){let n=`Tool error: ${t?.message||String(t)}`;return console.error(`[FlowEngage] voice tool ${e} threw:`,t),n}let a=typeof i==`string`?i.length>220?`${i.slice(0,220)}…`:i:String(i);return r?console.log(`[FlowEngage:voice-tool] ◀`,e,a):console.info(`[FlowEngage] voice tool « ${e}:`,a),i}]))}var ng={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function rg(e){if(!Array.isArray(e)||e.length<2)return`linear-gradient(145deg, #dce8f022 0%, #e8dff522 45%, #f5e0e022 100%), #f7f8fa`;let[t,n,r]=e;return e.length>=3&&r?[`radial-gradient(ellipse 80% 70% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 70% 80% at 110% 30%, ${n}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 60% at 50% 110%, ${r}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `):[`radial-gradient(ellipse 80% 100% at -10% 50%, ${t}1a 0%, transparent 70%)`,`radial-gradient(ellipse 80% 100% at 110% 50%, ${n}1a 0%, transparent 70%)`,`#f7f8fa`].join(`, `)}function ig(e){if(!e||typeof e!=`string`)return`#1a1a1a`;let t=e.replace(`#`,``),n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255,o=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4;return .2126*o(r)+.7152*o(i)+.0722*o(a)>.179?`#1a1a1a`:`#ffffff`}function ag(e){let[t,n]=b.useState(null),r=typeof e==`string`?e.trim():``;return b.useEffect(()=>{if(!r){n(null);return}n(null);let e=!1,t=new window.Image;return t.onload=()=>{e||n(r)},t.onerror=()=>{e||n(null)},t.src=r,()=>{e=!0}},[r]),t}function og({logo:e,style:t}){let n=ag(typeof e==`string`?e:null);if(!e)return null;if(typeof e==`string`)return n?(0,B.jsx)(`img`,{src:n,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}}):null;let r=typeof e==`function`?b.createElement(e):b.isValidElement(e)?e:null;return r?(0,B.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:r}):null}function sg({title:e}){return(0,B.jsx)(`div`,{style:{width:`100%`,height:`100%`,borderRadius:`16px`,background:`linear-gradient(135deg, rgba(59,130,246,0.16) 0%, rgba(59,130,246,0.08) 100%)`,color:`#2563eb`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`18px`,fontWeight:700,letterSpacing:`-0.03em`},children:String(e||`FE`).split(/\s+/).filter(Boolean).slice(0,2).map(e=>e[0]?.toUpperCase()||``).join(``)||`FE`})}function cg(e,t){let n=(t||``).trim();return n?!!(/\b(let'?s|let us)\s+(end|stop|finish|wrap up|close)\s+(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\bend\s+(this\s+)?(the\s+)?(voice\s+)?(session|call|chat)\b/i.test(n)||/\b(hang\s+up|disconnect)\b/i.test(n)||e===`bot`&&(/\b(that'?s all|we'?re done)\b/i.test(n)||/\b(goodbye|bye)\b/i.test(n)||/\b(I'?ll|I will|Let me|I can|I'?m going to)\s+(end|close)\s+(the\s+)?(voice\s+)?(session|call)\b/i.test(n)||/\b(ending|closing)\s+(the\s+)?(voice\s+)?session\b|\bvoice\s+session\s+(is\s+)?(now\s+)?(ended|over|closing)\b/i.test(n)||/\b(session|call)\s+(is\s+)?(now\s+)?(ended|over)\b/i.test(n)||/\bwe\s+can\s+end\s+(the\s+)?(session|call)?\s*(here|now)\b/i.test(n)||/\b(wrapping\s+up|signing\s+off)\b/i.test(n))):!1}function lg({orbColors:e,...t}){return(0,B.jsx)(ch,{colors:e,...t})}function ug({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a,isClosing:o}){let s=n||ng.green,c=ig(s),l=a?72:94,u=(0,B.jsxs)(`div`,{style:{display:`flex`,alignItems:a?`flex-end`:`center`,gap:a?`7px`:`9px`},children:[(0,B.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,B.jsx)(dm.p,{initial:{x:-16,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.36},style:{margin:`0 0 14px`,fontSize:`14px`,fontWeight:700,color:`white`,lineHeight:1.4,textShadow:`0 1px 4px rgba(0,0,0,0.35)`,maxWidth:`210px`,wordBreak:`break-word`,overflow:`hidden`,display:`-webkit-box`,WebkitLineClamp:4,WebkitBoxOrient:`vertical`},children:e.entryPrompt}),(0,B.jsxs)(dm.div,{initial:{y:10,opacity:0},animate:{y:0,opacity:1},transition:{type:`spring`,stiffness:260,damping:24,delay:.54},style:{display:`flex`,gap:`16px`,flexWrap:`nowrap`},children:[(0,B.jsx)(`button`,{onClick:r,style:{height:`31px`,boxSizing:`border-box`,padding:`0 16px`,borderRadius:`999px`,background:s,color:c,fontWeight:400,fontSize:`14px`,border:`none`,cursor:`pointer`,whiteSpace:`nowrap`,boxShadow:`0 4px 16px ${s}66`,transition:`transform 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.04)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.yesLabel}),(0,B.jsx)(`button`,{onClick:i,style:{height:`31px`,boxSizing:`border-box`,padding:`0 16px`,borderRadius:`999px`,background:`transparent`,color:`white`,fontWeight:400,fontSize:`14px`,border:`2px solid rgba(255,255,255,0.55)`,cursor:`pointer`,whiteSpace:`nowrap`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.9)`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`rgba(255,255,255,0.55)`},children:e.laterLabel})]})]}),(0,B.jsx)(dm.div,{initial:{x:120,opacity:0},animate:{x:0,opacity:1},transition:{type:`spring`,stiffness:220,damping:22,delay:0},style:{flexShrink:0},children:(0,B.jsx)(lg,{size:l,orbColors:t})})]});return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(dm.div,{initial:{opacity:0},animate:{opacity:o?0:1},transition:{duration:.28},style:{position:`fixed`,inset:0,background:`rgba(0,0,0,0.72)`,zIndex:-1}}),a?(0,B.jsx)(`div`,{style:{position:`absolute`,bottom:0,left:0,right:0,padding:`24px 20px 40px`,overflow:`hidden`,animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u}):(0,B.jsx)(`div`,{style:{animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u})]})}function dg({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a,isMobile:o,isClosing:s}){let c=n||ng.green,l=ig(c);return(0,B.jsxs)(dm.div,{initial:{scale:50/350,borderRadius:`50%`},animate:s?{scale:50/350,opacity:0,borderRadius:`50%`}:{scale:1,borderRadius:`16px`,opacity:1},transition:{type:`spring`,stiffness:260,damping:26},style:{transformOrigin:o?`bottom center`:`bottom right`,background:`white`,width:o?`100%`:`350px`,height:`245px`,padding:`24px 40px 32px`,boxSizing:`border-box`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`space-between`,boxShadow:`0 20px 60px rgba(0,0,0,0.2)`,position:`relative`,overflow:`hidden`},children:[(0,B.jsx)(`button`,{onClick:a,style:{position:`absolute`,top:`14px`,right:`14px`,background:`none`,border:`none`,cursor:`pointer`,color:`#9ca3af`,padding:`4px`,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#374151`},onMouseLeave:e=>{e.currentTarget.style.color=`#9ca3af`},children:(0,B.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,B.jsx)(lg,{size:72,orbColors:t}),(0,B.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,B.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,lineHeight:1.4},children:e.connectionTitle}),e.connectionSubtitle&&(0,B.jsx)(`p`,{style:{margin:`6px 0 0`,fontSize:`13px`,fontWeight:400,color:`#6b7280`,lineHeight:1.4},children:e.connectionSubtitle})]}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,width:`100%`},children:[(0,B.jsx)(`button`,{onClick:r,style:{width:`127px`,height:`43px`,borderRadius:`999px`,background:c,color:l,fontWeight:400,fontSize:`16px`,border:`none`,cursor:`pointer`,transition:`transform 0.15s ease`,boxShadow:`0 4px 12px ${c}55`},onMouseEnter:e=>{e.currentTarget.style.transform=`scale(1.03)`},onMouseLeave:e=>{e.currentTarget.style.transform=`scale(1)`},children:e.voiceLabel}),(0,B.jsx)(`button`,{onClick:i,style:{width:`127px`,height:`43px`,borderRadius:`999px`,background:`transparent`,color:`#111827`,fontWeight:400,fontSize:`16px`,border:`1.5px solid #d1d5db`,cursor:`pointer`,transition:`border-color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.borderColor=`#6b7280`},onMouseLeave:e=>{e.currentTarget.style.borderColor=`#d1d5db`},children:e.textLabel})]})]})}function fg({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,chatId:o,historyRef:s,onMessageSync:c,voiceEndCounter:l,websiteName:u,voiceFirstMessage:d,captureVisitorEmail:f,emailRequired:p,emailCaptureEnabled:m=!0,listeningLabel:h=`Listening...`,enterChatModeLabel:g=`Enter Chat Mode`,endConversationLabel:_=`End Conversation`}){(0,b.useEffect)(()=>(console.log(`[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED`),()=>console.log(`[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED`)),[]);let[v,y]=(0,b.useState)(`idle`),[x,S]=(0,b.useState)(!1),[C,w]=(0,b.useState)(!1),[ee,T]=(0,b.useState)(!1),[te,ne]=(0,b.useState)(``),[re,E]=(0,b.useState)(``),ie=(0,b.useRef)(!1),ae=(0,b.useRef)(!1),oe=(0,b.useRef)(null),se=(0,b.useRef)(0),ce=(0,b.useRef)(``),D=(0,b.useRef)(null),O=(0,b.useRef)(``),le=(0,b.useRef)(async()=>{}),ue=(0,b.useRef)(!1),de=(0,b.useRef)(!1),fe=(0,b.useRef)(!1),k=(0,b.useRef)(!1),A=(0,b.useRef)(`minimized`),pe=(0,b.useRef)(null),me=(0,b.useRef)(null),he=(0,b.useRef)(null),ge=(0,b.useRef)(0),_e=(0,b.useRef)(!1),ve=(0,b.useRef)(`idle`),ye=(0,b.useRef)(!1),j=(0,b.useRef)(!1),be=(0,b.useRef)(null),xe=(0,b.useRef)(null),Te=(0,b.useRef)(!1),De=(0,b.useCallback)((e=`minimized`)=>{console.warn(`[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called`,{destination:e,stack:Error().stack?.split(`
|
|
345
|
+
`).slice(1,4).join(` | `)}),A.current=e,k.current=!0,queueMicrotask(()=>{ue.current||(ue.current=!0,le.current?.())})},[s]),Oe=(0,b.useCallback)(()=>{oe.current&&=(clearTimeout(oe.current),null)},[]);(0,b.useEffect)(()=>{p||(ie.current=!0,ae.current=!1,T(!1),Oe())},[p,Oe]);let ke=(0,b.useCallback)(()=>{Oe(),oe.current=setTimeout(()=>{if(!(!ae.current||ie.current))if(se.current<3){se.current+=1;try{D.current?.injectAgentSpeech?.(`I still need your email in the box below to continue — could you enter it, please?`,`queue`)}catch{}ke()}else{try{D.current?.injectAgentSpeech?.(`Since I haven't received your email, I'll close this session for now. Feel free to come back anytime — take care!`,`queue`)}catch{}ae.current=!1,T(!1),Oe(),_e.current=!0}},1e4)},[Oe]),Ae=(0,b.useCallback)(async e=>{k.current=!0;try{jn()}catch{}if(i)try{Pe(i)}catch{}try{await D.current?.endSession?.()}catch{}let t=pe.current,n=me.current;if(t&&o&&a){let e=n?Math.round((Date.now()-n)/1e3):0;fetch(`${a}/api/voice/save-chat-recording`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:o,elevenLabsConversationId:t,duration:e,siteId:i})}).catch(e=>console.warn(`[FlowEngage] save-chat-recording failed:`,e.message))}if(pe.current=null,me.current=null,D.current=null,y(`idle`),S(!1),ue.current=!1,Or(),i)try{we(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);le.current=()=>Ae(A.current===`chat`?t:n),(0,b.useEffect)(()=>{de.current=x},[x]),(0,b.useEffect)(()=>{l&&De(`chat`)},[l]),(0,b.useEffect)(()=>{let e=!1,l=null,f=null,h=null;return(async()=>{if(!i){y(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],O.current=``,ue.current=!1,fe.current=!1,k.current=!1,A.current=`minimized`,Dr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=_h(s.current);e&&Se(i,e)}catch{}if(!Zn()){let e=pe.current,t=me.current;if(e&&o&&a)try{let n=t?Math.round((Date.now()-t)/1e3):0,r=JSON.stringify({chatId:o,elevenLabsConversationId:e,duration:n,siteId:i}),s=`${a}/api/voice/save-chat-recording`;fetch(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0}).catch(()=>{}),pe.current=null,me.current=null}catch{}}Ee()}});let t=tg(eg({siteId:i||null,apiBaseUrl:a||null,chatId:o||null,getLastUserVoiceText:()=>O.current,requestEndSession:()=>{_e.current=!0},requestEmailCollection:()=>{m&&(ie.current||ae.current||(ae.current=!0,se.current=0,T(!0),ke()))}})),n=i?Ce(i):null,r=!!n?.transcript,c=i?Pe(i):null,g=!!c,_=typeof window<`u`?window.location.pathname:`/`,v=typeof document<`u`?document.title:``,b=_.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,``)||`/`,x=b===`/`||b===``,C={apiBaseUrl:a,siteId:i,chatId:o,clientTools:t},w=(_.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),ee=``;v&&v.includes(`|`)&&(ee=v.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let te=ee||w||`this page`,ne=(()=>{if(!c?.targetUrl)return!0;try{return new URL(c.targetUrl,window.location.href).pathname.replace(/\/$/,``)===window.location.pathname.replace(/\/$/,``)}catch{return!0}})();if(g&&!ne)C.greeting=`You're on the ${te} page. What would you like to know?`,console.warn(`[FlowEngage] nav target "${c?.pageName}" not reached — on "${te}" instead; not claiming navigation`);else if(g){let e=c?.pageName||te;C.greeting=`I have navigated you on ${e} page. Do you want to know about any specific section or want a complete overview?`,console.log(`[FlowEngage] 🔄 Agent-nav resume: greeting set for "${e}" (${_})`)}else if(r)C.greeting=`Welcome back! I see you're now on the ${te} page. Would you like me to continue what I was explaining before, or would you like to know about this page instead?`;else{let e=u||``;C.greeting=d||(x?e?`Hi, welcome to ${e}! How may I help you?`:`Hi, welcome! How may I help you?`:`Welcome to the ${te} page!`),x||console.log(`[FlowEngage] 🏠 Page-context greeting: "${te}" for ${_}`)}let re=!1,E=g?`NAVIGATION COMPLETE — The exact phrase "I have navigated you on [page] page. Do you want to know about any specific section or want a complete overview?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until the visitor responds. When they reply: if they name a specific section → call fwh-get-current-page-mvp then answer immediately; if they say "overview" or anything non-specific → call fwh-get-current-page-mvp (zero speech) then do a full highlighted walkthrough.`:null,oe=!1,le=!g&&!r?`Your greeting has been spoken. Wait for the visitor to ask a question or tell you what they need. Do NOT auto-start a walkthrough or highlight any sections — let the visitor lead.`:null,he=r&&!g,we=!1,Oe=he?`The question "Would you like me to continue what I was explaining before, or would you like to know about this page instead?" has already been spoken as your firstMessage. DO NOT repeat it. PRIOR CONVERSATION CONTEXT:\n${n?.transcript?`Prior transcript:\n${n.transcript}\n`:`(no prior transcript, or the visitor navigated before saying much)`}\nNow STOP — wait silently for the visitor's reply. Do NOT speak, do NOT call any tool until they respond. When they reply: if they want you to CONTINUE the previous topic → resume verbally from the prior transcript above, do NOT call fwh-get-current-page-mvp or describe the new page unless they ask. If they want to know about THIS page → call fwh-get-current-page-mvp (zero speech) then proceed as a normal fresh-page walkthrough/description. If their reply is ambiguous, ask them to clarify which they'd prefer rather than guessing.`:null,Ae=!1,Me=!1,Ne=m&&!!p,Fe=await bm.startSession({...C,onConnect:({conversationId:e})=>{pe.current=e,me.current=Date.now(),console.log(`[FlowEngage] 🎙️ AI chat session connected:`,e)},onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onModeChange:({mode:t})=>{if(!e){if(t===`speaking`){xe.current&&=(clearTimeout(xe.current),null),y(`speaking`),ve.current=`speaking`,ye.current=!0,Te.current=!1,be.current&&=(clearTimeout(be.current),null);return}if(ve.current=`listening`,_e.current){_e.current=!1,De();return}if(Ne&&!Me&&!ie.current){Me=!0,re=!0,oe=!0;try{D.current?.sendContextualUpdate?.(`CRITICAL — EMAIL REQUIRED BEFORE ANYTHING ELSE. The visitor has not provided their email. Do NOT speak right now. Wait silently for the visitor to speak first. The MOMENT the visitor says ANYTHING — a question, a request, or just a greeting — your ENTIRE next response must be EXACTLY this one sentence: "Before I answer that, could you please enter your email in the text box below?" Do NOT answer their question. Do NOT say anything about the topic. Do NOT begin an answer and then switch — your first word must be "Before". After you say that sentence, stay completely silent until you receive an EMAIL_SAVED message, then thank them briefly and answer their question in full.`)}catch{}}if(E&&!re){re=!0;try{D.current?.sendContextualUpdate?.(E)}catch{}}if(Oe&&!we){we=!0;try{D.current?.sendContextualUpdate?.(Oe)}catch{}}if(le&&!oe){oe=!0;try{D.current?.sendContextualUpdate?.(le)}catch{}}xe.current&&clearTimeout(xe.current),xe.current=setTimeout(()=>{e||ve.current!==`speaking`&&(Te.current||(xe.current=null,ve.current=`listening`,y(`listening`),ye.current&&j.current&&!de.current&&!ae.current&&(be.current&&clearTimeout(be.current),be.current=setTimeout(()=>{if(!e&&ve.current===`listening`&&!de.current&&!ae.current)try{D.current?.sendContextualUpdate?.(`The visitor has been silent for a while. Ask one short, natural question to re-engage — for example: 'Is there anything specific you'd like to know more about?' or 'What else can I help you with today?' Keep it to one sentence.`)}catch{}},15e3))))},1200)}},onMessage:t=>{if(e)return;let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;if(r){if(n===`user`){O.current=r,Te.current=!0,j.current=!0,xe.current&&=(clearTimeout(xe.current),null),be.current&&=(clearTimeout(be.current),null);try{jn()}catch{}Ne&&!Ae&&!ie.current&&(Ae=!0,ce.current=r,ae.current||(ae.current=!0,se.current=0,T(!0),ke()))}if(s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString()}],i)try{let e=_h(s.current);e&&Se(i,e)}catch{}if(cg(n,r)){_e.current=!0;return}if(de.current&&n===`bot`&&/are you still there|still there\??|hello\?|anyone there|checking in|you there|are you available|is anyone|did you step away/i.test(r))if(ge.current+=1,ge.current===2)try{D.current?.sendContextualUpdate?.(`IMPORTANT: The visitor is muted and has not responded to your last 2 checks. Make exactly ONE more check. If there is still no response, say: 'I feel like you are not active, so I'm ending this session. You can connect with me anytime.' then immediately call the fwh-end-session-mvp tool to end the voice session. Do NOT ask again after that.`)}catch{}else ge.current>=5&&De(`minimized`)}},onError:t=>{if(!e&&!k.current&&!fe.current&&!je()){fe.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{D.current?.setMicMuted?.(!0)}catch{}S(!0),y(`error`),De(`chat`)}},onDisconnect:t=>{if(e||k.current||fe.current||je())return;let n=s.current?.length||0;console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:n,reason:t?.reason,closeCode:t?.context?.code,closeReason:t?.context?.reason||t?.message,lastUserText:O.current||``,wasMuted:de.current}),fe.current=!0;try{D.current?.setMicMuted?.(!0)}catch{}S(!0),De(`chat`)}});if(e){console.warn(`[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately`),Fe.endSession().catch(()=>{});return}l=Fe,D.current=Fe,y(`listening`);try{let e=typeof window<`u`?window.location.href:``,a=`[]`;try{a=await t[`fwh-list-forms-mvp`]()}catch{}let o=`none`;if(typeof window<`u`&&typeof document<`u`)try{let e=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`,t=document.querySelector(`main, [role='main']`)||document.body,n=Array.from(t.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200);n.length||(n=Array.from(document.body.querySelectorAll(`h1, h2, h3`)).filter(t=>!t.closest(e)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200)),n.length&&(o=[...new Set(n)].slice(0,15).join(` | `))}catch{}let s=r&&!g?`RESUMING PRIOR SESSION — DO NOT GREET. The visitor is continuing the same conversation after a page reload. Do not introduce yourself or re-state your capabilities. Wait silently until the visitor speaks; if you must speak first, briefly acknowledge where you left off in one short sentence.\nPrior transcript:\n${n?.transcript||``}\n\n`:``;Fe.sendContextualUpdate(`${s}SESSION_CONTEXT (NOT a tool result — do NOT treat as CURRENT_PAGE): Visitor is on: ${e} | Approx headings for awareness only: ${o}. SiteId: ${i||`unknown`}. Forms: ${a}. ${p?``:`Visitor's email is already on file from a prior session — do NOT ask for it again. `}The visitor is ALREADY on this page — do NOT offer to navigate there. WALKTHROUGH RULE: When the visitor asks for a walkthrough or overview of this page, you MUST IMMEDIATELY call fwh-get-current-page-mvp (zero speech — call it silently with NO words before it) to get the exact highlightable headings. The approximate headings above are for routing awareness ONLY — they are NOT precise enough for fwh-highlight-mvp. Do NOT skip fwh-get-current-page-mvp. Voice: call end_voice_session or say you are ending the session to stop.`)}catch{}if(typeof window<`u`){let t=window.location.pathname,n=()=>{if(e)return;let n=window.location.pathname;if(n===t)return;if(Un()){t=n;return}let r=t;t=n;let i=window.location.href,a=typeof document<`u`?document.title:``,o=typeof document<`u`?Array.from(document.querySelectorAll(`h1, h2, h3, h4`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell`)).map(e=>({tag:e.tagName,text:e.textContent.trim()})).filter(e=>e.text.length>0&&e.text.length<200).slice(0,20):[];try{jn()}catch{}let s=e=>(e.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`,c=s(r),l=s(n);typeof window<`u`&&(window.__fe_user_nav_during_speech={fromPath:r,toPath:n,fromPageName:c,toPageName:l,ts:Date.now()});try{D.current?.sendUserMessage?.(`[SYSTEM: I navigated away mid-walkthrough — I am now on the "${l}" page (${i}). Page title: "${a}". Sections: ${JSON.stringify(o)}. STOP everything. Do NOT describe the new page. Say EXACTLY: "I see you've navigated to the ${l} page — would you like me to continue what I was explaining, or shall I walk you through this page?" Then wait for my answer. IF I say continue/yes/carry on: resume speaking verbally from where you left off — do NOT call flowengage_navigate, do NOT call flowengage_highlight, the visitor will navigate themselves if needed. IF I want to hear about this page: call flowengage_highlight for sections of "${l}" only.]`)}catch{}};f=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{f(...e),setTimeout(n,50)},h=()=>setTimeout(n,50),window.addEventListener(`popstate`,h)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(y(`error`),A.current=`chat`,window.setTimeout(()=>{e||t?.()},0)))}})(),()=>{console.warn(`[FlowEngage:VoiceDebug] ⚠️ useEffect CLEANUP fired — session will be killed`,{agentId:r,siteId:i,apiBaseUrl:a}),e=!0,k.current=!0;try{jn()}catch{}if(i)try{Pe(i)}catch{}typeof window<`u`&&(window.__fe_user_nav_during_speech=null),Or(),be.current&&=(clearTimeout(be.current),null),xe.current&&=(clearTimeout(xe.current),null),oe.current&&=(clearTimeout(oe.current),null),ye.current=!1,Te.current=!1,ve.current=`idle`,f&&typeof window<`u`&&(window.history.pushState=f),h&&typeof window<`u`&&window.removeEventListener(`popstate`,h);let t=l||D.current,n=pe.current,u=me.current;if(t?.endSession?.().catch(()=>{}),n&&o&&a){let e=u?Math.round((Date.now()-u)/1e3):0,t=JSON.stringify({chatId:o,elevenLabsConversationId:n,duration:e,siteId:i}),r=`${a}/api/voice/save-chat-recording`;typeof navigator<`u`&&navigator.sendBeacon&&navigator.sendBeacon(r,new Blob([t],{type:`application/json`}))||fetch(r,{method:`POST`,headers:{"Content-Type":`application/json`},body:t,keepalive:!0}).catch(()=>{}),pe.current=null,me.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,De]),(0,b.useEffect)(()=>{if(!C)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;he.current&&!he.current.contains(t)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[C]);let Me=async()=>{if(D.current)try{if(x){ge.current=0,await D.current.setMicMuted?.(!1),S(!1);try{D.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{ge.current=0,await D.current.setMicMuted?.(!0),S(!0);try{D.current.sendContextualUpdate?.(`The visitor has muted their microphone. Do NOT speak, ask if they are there, or prompt them in any way. Stay completely silent until they unmute.`)}catch{}}}catch{}},Ne=(0,b.useCallback)(async e=>{e?.preventDefault?.();let t=te.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){E(`Please enter a valid email address.`);return}E(``);try{typeof f==`function`&&await f(t)}catch{}ie.current=!0,ae.current=!1,Oe(),T(!1),ne(``);let n=ce.current;ce.current=``;try{D.current?.sendUserMessage?.(`[SYSTEM: EMAIL_SAVED — the visitor typed and submitted their email address. Say a brief 'Thank you!' and then `+(n?`immediately answer their original question fully: "${n}".`:`continue helping them.`)+` Do NOT ask for their email again.]`)}catch{}},[te,f,Oe]),Fe=Array.isArray(e)&&e[0]||`#3B82F6`;return(0,B.jsxs)(`div`,{ref:he,style:{position:`relative`,display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`14px`,animation:`fe-orb-slide-up 0.42s cubic-bezier(0.16,1,0.3,1)`},children:[ee&&(0,B.jsxs)(`form`,{onSubmit:Ne,style:{width:`270px`,maxWidth:`calc(100vw - 40px)`,boxSizing:`border-box`,background:`rgba(15,22,36,0.97)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,padding:`16px`,display:`flex`,flexDirection:`column`,gap:`10px`,animation:`fe-orb-fade-in 0.18s ease`},children:[(0,B.jsx)(`span`,{style:{color:`white`,fontSize:`13px`,fontWeight:600,lineHeight:1.4},children:`Please enter your email to continue`}),(0,B.jsx)(`input`,{type:`email`,inputMode:`email`,autoComplete:`email`,autoFocus:!0,value:te,onChange:e=>{ne(e.target.value),re&&E(``)},placeholder:`you@example.com`,style:{width:`100%`,boxSizing:`border-box`,padding:`10px 12px`,borderRadius:`10px`,border:re?`1.5px solid #ef4444`:`1.5px solid #4b5563`,background:`#1f2937`,color:`white`,fontSize:`14px`,outline:`none`}}),re&&(0,B.jsx)(`span`,{style:{color:`#f87171`,fontSize:`12px`},children:re}),(0,B.jsx)(`button`,{type:`submit`,disabled:!te.trim(),style:{width:`100%`,padding:`10px 12px`,borderRadius:`10px`,border:`none`,background:te.trim()?Fe:`#374151`,color:`white`,fontSize:`14px`,fontWeight:600,cursor:te.trim()?`pointer`:`default`,transition:`background 0.2s ease`},children:`Submit`})]}),(0,B.jsxs)(`div`,{style:{position:`relative`},children:[v===`listening`&&!x&&(0,B.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`white`,fontSize:`18px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:h}),x&&(0,B.jsx)(`span`,{style:{position:`absolute`,right:`100%`,marginRight:`18px`,top:`50%`,transform:`translateY(-50%)`,color:`#f87171`,fontSize:`16px`,fontWeight:600,letterSpacing:`0.01em`,textShadow:`0 2px 4px rgba(0,0,0,0.4)`,whiteSpace:`nowrap`},children:`Muted`}),(0,B.jsx)(lg,{size:72,voiceState:v,isMuted:x,orbColors:e})]}),v===`error`&&(0,B.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,B.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,B.jsx)(`button`,{onClick:Me,title:x?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:x?`#7f1d1d`:`#1f2937`,border:x?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:x?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:x?(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,B.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,B.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,B.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,B.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,B.jsx)(xm,{size:16,color:`currentColor`})}),(0,B.jsx)(`button`,{onClick:()=>w(e=>!e),style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:`#1f2937`,border:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`,transition:`background 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:(0,B.jsx)(km,{size:16,color:`currentColor`})})]}),C&&(0,B.jsxs)(`div`,{style:{position:`absolute`,bottom:0,right:0,width:`230px`,zIndex:9999,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,animation:`fe-orb-fade-in 0.18s ease`,padding:`12px 12px 40px`},children:[(0,B.jsxs)(`button`,{onClick:()=>{w(!1),A.current=`chat`,Ae(t)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsx)(Am,{}),g]}),(0,B.jsxs)(`button`,{onClick:()=>{w(!1),A.current=`minimized`,Ae(n)},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`12px 16px`,background:`none`,border:`none`,color:`#E30C12`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`,borderRadius:`8px`,whiteSpace:`nowrap`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(227,12,18,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsx)(jm,{}),_]}),(0,B.jsx)(`button`,{onClick:()=>w(!1),style:{position:`absolute`,bottom:`8px`,right:`8px`,width:`24px`,height:`24px`,borderRadius:`50%`,background:`rgba(255,255,255,0.15)`,border:`none`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:`white`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.25)`},onMouseLeave:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.15)`},children:(0,B.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,B.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]})}function pg({orbColors:e}){let t=Array.isArray(e)&&e.length>0?e:[`#135bd8`,`#ef334b`,`#ffbd2e`],n=t[0],r=t[1]||t[0],i=t[2]||t[0];return(0,B.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,flexShrink:0,background:`
|
|
346
346
|
radial-gradient(circle at 18% 50%, ${n} 0%, ${n}99 35%, transparent 65%),
|
|
347
347
|
radial-gradient(circle at 82% 50%, ${r} 0%, ${r}99 35%, transparent 65%),
|
|
348
348
|
radial-gradient(circle at 50% 82%, ${i} 0%, ${i}99 30%, transparent 58%),
|
|
349
349
|
white
|
|
350
|
-
`.replace(/\s+/g,` `).trim()}})}var pg=()=>(0,B.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,B.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})});function mg({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:d,agentName:f,agentHeadshot:p,fallbackAgentName:m,input:h,setInput:g,onSubmit:_,isConversationEnded:v,isLoading:y,isRateLimited:x,rateLimitMessage:S,selectedFile:C,onFileSelect:w,onRemoveSelectedFile:ee,attachmentError:T,isUploadingAttachment:te,requiresEmail:ne,emailInput:re,setEmailInput:E,emailError:ie,emailCaptureSuccess:ae,replyContext:oe,setReplyContext:se,webRTCError:ce,micError:D,setMicError:O,dismissCallError:le,activeCallId:ue,isCallMuted:de,toggleCallMute:fe,endWebRTCCall:k,formatCallDuration:A,callDurationSeconds:pe,isCallMinimized:me,onExpand:he,onCollapse:ge,onStartVoice:_e,voiceEnabled:ve,headerBgColor:ye,onNewChat:j,showPoweredBy:be,privacyPolicyUrl:xe,getVisitorChatHistory:Se,resumeChat:Ce,isSessionRestoring:we,isClosing:Te}){let Ee=c.length>0,De=y||x||v,Oe=!!ue,[ke,Ae]=(0,b.useState)(!1),[je,Me]=(0,b.useState)(!1),[Ne,Pe]=(0,b.useState)([]),[Fe,M]=(0,b.useState)(!1),Ie=(0,b.useRef)(null),[Le,Re]=(0,b.useState)(()=>typeof window<`u`?window.visualViewport?.height??window.innerHeight:600),[ze,Be]=(0,b.useState)(0);(0,b.useEffect)(()=>{if(!s)return;let e=window.visualViewport;if(!e)return;let t=()=>{Re(e.height),Be(Math.max(0,window.innerHeight-e.offsetTop-e.height))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[s]);let Ve=s&&window.innerHeight-Le>150,He=async()=>{Ae(!1),Me(!0),M(!0);try{let e=await Se();e?.data&&Pe(e.data)}catch(e){console.error(e)}finally{M(!1)}},N=async e=>{Me(!1),Ce?.(e.chatId)};return(0,b.useEffect)(()=>{if(!ke)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Ie.current&&!Ie.current.contains(t)&&Ae(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[ke]),(0,B.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`0`,right:`0`,bottom:`${ze}px`,height:Le>0?`${Math.round(Le*(Ve?1:.92))}px`:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:Te?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)`}:{"--flowengage-primary":n,"--flowengage-accent":n,width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,background:r,borderRadius:`22px`,boxShadow:`0 24px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,position:`relative`,animation:Te?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`},children:[(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 10px 14px`,background:ye||`transparent`,flexShrink:0,position:`relative`,zIndex:30},children:[(0,B.jsx)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:(0,B.jsx)(`button`,{onClick:ge,style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},children:(0,B.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})}),(()=>{let t=!!i,n=!!e.hasCustomTitle,r=t||n,a=t||!r,o=n||!r,c=a&&o;return(0,B.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:c?`minmax(72px, 40%) minmax(0, 60%)`:`1fr`,columnGap:c?`12px`:0,alignItems:`center`,justifyItems:c?`stretch`:`center`},children:[a&&(0,B.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,B.jsx)(ag,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,B.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,B.jsx)(og,{title:e.chatTitle})})}),o&&(0,B.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:c?`flex-start`:`center`},children:(0,B.jsx)(`span`,{style:{fontSize:`15px`,fontWeight:600,color:`#111827`,letterSpacing:`-0.01em`,lineHeight:1.2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.chatTitle,children:e.chatTitle})})]})})(),(0,B.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Ie,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>Ae(e=>!e),style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},"aria-label":`Chat options`,children:(0,B.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),ke&&(0,B.jsxs)(`div`,{style:{position:`absolute`,top:`34px`,right:0,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[ve&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(!1),_e?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,B.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,B.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(!1),j?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7`}),(0,B.jsx)(`path`,{d:`M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z`})]}),`Start new chat`]}),Se&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,B.jsxs)(`button`,{type:`button`,onClick:He,style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z`})}),`Chat history`]})]}),(0,B.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(!1),ge?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,B.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,B.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`Close conversation`]})]})]})]}),(0,B.jsx)(Qm,{webRTCError:ce,micError:D,setMicError:O,dismissCallError:le,isRateLimited:x,rateLimitMessage:S}),me&&(0,B.jsx)(hh,{agentName:f,agentHeadshot:p,fallbackAgentName:m,callDurationSeconds:pe,isCallMuted:de,formatCallDuration:A,toggleCallMute:fe,endWebRTCCall:k,onExpand:he,primaryColor:n}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[je?(0,B.jsxs)(`div`,{style:{position:`absolute`,inset:0,background:`white`,zIndex:20,display:`flex`,flexDirection:`column`,animation:`fe-orb-fade-in 0.2s ease`},children:[(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px`,borderBottom:`1px solid #f3f4f6`,flexShrink:0},children:(0,B.jsxs)(`button`,{onClick:()=>Me(!1),style:{background:`none`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,color:`#6b7280`},children:[(0,B.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),(0,B.jsx)(`span`,{style:{marginLeft:`8px`,fontWeight:500,fontSize:`15px`},children:`Return to Chat`})]})}),(0,B.jsx)(`div`,{style:{flex:1,overflowY:`auto`,position:`relative`},children:Fe?(0,B.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):Ne.length>0?(0,B.jsx)(`div`,{children:Ne.map(e=>(0,B.jsxs)(`div`,{onClick:()=>N(e),style:{padding:`16px 20px`,borderBottom:`1px solid #f3f4f6`,cursor:`pointer`,transition:`background 0.15s ease`},onMouseEnter:e=>e.currentTarget.style.background=`#f9fafb`,onMouseLeave:e=>e.currentTarget.style.background=`white`,children:[(0,B.jsxs)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginBottom:`6px`,fontWeight:500},children:[new Date(e.createdAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),` at `,new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]}),(0,B.jsx)(`div`,{style:{fontSize:`14.5px`,color:`#111827`,opacity:.9,overflow:`hidden`,textOverflow:`ellipsis`,display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,lineHeight:1.4},children:e.message||`Conversation`})]},e.chatId))}):(0,B.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#9ca3af`,fontSize:`14px`},children:`No previous chats found.`})})]}):null,Ee?(0,B.jsx)(Ym,{chatHistory:c,isAiTyping:l,isLoading:y,isAgentTyping:u,setReplyContext:se,TypingDots:pg,primaryColor:n,agentHeadshot:p,agentDisplayName:f||m,botAvatarNode:(0,B.jsx)(fg,{orbColors:t})}):we?(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`},children:[(0,B.jsx)(`div`,{style:{width:`28px`,height:`28px`,border:`3px solid #f3f4f6`,borderTop:`3px solid ${n}`,borderRadius:`50%`,animation:`spin 1s linear infinite`},children:(0,B.jsx)(`style`,{children:`@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})}),(0,B.jsx)(`div`,{style:{color:`#6b7280`,fontSize:`14px`,fontWeight:500,animation:`fe-orb-fade-in 1s infinite alternate`},children:`Loading chat...`})]}):(0,B.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,B.jsx)(cg,{size:94,orbColors:t}),(0,B.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,B.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,B.jsx)(`button`,{onClick:()=>o?.(e),style:{padding:`8px 16px`,borderRadius:`999px`,background:`white`,border:`1.5px solid ${n}33`,color:n||`#374151`,fontSize:`13px`,fontWeight:500,cursor:`pointer`,transition:`all 0.15s ease`,boxShadow:`0 1px 4px rgba(0,0,0,0.06)`},onMouseEnter:e=>{e.currentTarget.style.background=`${n}12`,e.currentTarget.style.borderColor=n},onMouseLeave:e=>{e.currentTarget.style.background=`white`,e.currentTarget.style.borderColor=`${n}33`},children:e.label||e.text},e.id))})]})]}),ae&&(0,B.jsxs)(`div`,{style:{margin:`0 16px 8px`,padding:`9px 14px`,borderRadius:`12px`,background:`#ecfdf5`,border:`1px solid #6ee7b7`,display:`flex`,alignItems:`center`,gap:`8px`,animation:`fe-orb-fade-in 0.2s ease`,flexShrink:0},children:[(0,B.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#10b981`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,B.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,B.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`#065f46`},children:`Email saved — we'll be in touch!`})]}),(0,B.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:ne?`6px 0 0`:`12px 0 0`},children:(0,B.jsx)(Zm,{input:h,setInput:g,onSubmit:_,isConversationEnded:v,callUiActive:Oe,handleToggleVoice:_e,showVoiceToggle:d===`agent`,activeScreen:d,inputDisabled:De,replyContext:oe,clearReplyContext:()=>se(null),onFileSelect:w,selectedFile:C,onRemoveSelectedFile:ee,attachmentError:T,isUploadingAttachment:te,requiresEmail:ne,emailInput:re,setEmailInput:E,emailError:ie,inputPlaceholder:e.inputPlaceholder})}),!Ve&&(0,B.jsxs)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`8px 20px`,paddingBottom:`max(12px, env(safe-area-inset-bottom, 12px))`,pointerEvents:`none`},children:[xe&&(0,B.jsxs)(`p`,{style:{margin:`0 0 4px`,fontSize:`10px`,color:`#9ca3af`,lineHeight:1.4,userSelect:`none`,pointerEvents:`auto`},children:[`This conversation is recorded for quality assurance purposes.`,` `,(0,B.jsx)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#6b7280`,textDecoration:`underline`},children:`See our privacy policy`})]}),be&&(0,B.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,B.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})]})]})}function hg(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:d,isLoading:f,isRateLimited:p,rateLimitMessage:m,isConversationEnded:h,incomingCall:g,activeCallId:_,callConnectionState:v,callConnectedAt:y,isCallMuted:x,webRTCError:S,language:C,chatId:w,historyRef:ee,onMessageSync:T,sendMessage:te,uploadChatFile:ne,openWidget:re,captureVisitorEmail:E,setVoiceMode:ie,endConversation:ae,startNewChat:oe,acceptCall:se,rejectCall:ce,endWebRTCCall:le,toggleCallMute:ue,dismissCallError:de,startTyping:fe,stopTyping:k,updateTypingDraft:A,getVisitorChatHistory:pe,resumeChat:me,isSessionRestoring:he,openToChatCounter:ge,voiceEndCounter:_e}=En();(0,b.useEffect)(()=>{try{ur()}catch{}},[]),(0,b.useEffect)(()=>{ge&&F!==`voice_mode`&&F!==`text_chat`&&F!==`call_screen`&&(ie?.(!1),tt(`text_chat`))},[ge]);let ve=t?.widgetSettings||{},ye=n?.widgetSettings||{},j={...ve.branding||{},...ye.branding||{}},be={...ve.theme||{},...ye.theme||{}},xe={...ve.features||{},...ye.features||{}},Se=xe.voice!==!1,Te=Array.isArray(be.orbColors)&&be.orbColors.length>0?be.orbColors:null,Ee=be.buttonColor||be.primaryColor||Te?.[0]||`#3B82F6`,Oe={small:50,medium:64,large:80},ke=Oe[be.orbSize]||Oe.small,je=be.position||`bottom-right`,Me=j.fallbackAgentName||`Agent`,Ne=ng(Te??be.chatBgColors),Pe=j.logo||j.logoUrl||null,Fe=C||`en`,M=ve.recommendations?.[Fe]||[],Ie=(ye.recommendations?.[Fe]??M).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Le=Array.isArray(j.quickChatOptions)&&j.quickChatOptions.length>0?j.quickChatOptions:Ie,Re=j.hideWatermark===!0?!1:j.showPoweredBy!==!1,ze=j.headerBgColor||null,Be=be.bottomPosition==null?`1.5rem`:`${be.bottomPosition}px`,Ve=j.privacyPolicyUrl||null,He=j.chatbotEnabled!==!1&&be.chatbotEnabled!==!1,[N,Ue]=(0,b.useState)(()=>typeof window<`u`?window.location.pathname:`/`);(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>Ue(window.location.pathname),t=window.history.pushState.bind(window.history);return window.history.pushState=(...n)=>{t(...n),setTimeout(e,50)},window.addEventListener(`popstate`,e),()=>{window.history.pushState=t,window.removeEventListener(`popstate`,e)}},[]);let We=(()=>{let e={...ve.pageVisibility||{},...ye.pageVisibility||{}};return Array.isArray(e.allowedPaths)?e.allowedPaths.filter(Boolean):[]})(),Ge=We.length===0||We.some(e=>e===`*`||e===`/*`?!0:e.endsWith(`/*`)?N.startsWith(e.slice(0,-1)):N.replace(/\/$/,``)===e.replace(/\/$/,``)),Ke=ve.greetings?.[C]||ye.greetings?.[C]||j.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,qe={entryPrompt:j.entryPrompt||`Do you want to explore in a new way?`,yesLabel:j.yesLabel||`Yes`,laterLabel:j.laterLabel||`Later`,connectionTitle:j.connectionTitle||`How would you like to connect?`,connectionSubtitle:j.connectionSubtitle||``,voiceLabel:j.voiceLabel||`Voice`,textLabel:j.textLabel||`Text`,chatTitle:j.headerName||`Chat with FlowEngage`,hasCustomTitle:!!(j.headerName&&String(j.headerName).trim()),introGreeting:Ke,inputPlaceholder:j.inputPlaceholder||`Type your message`,analysingLabel:j.analysingLabel||`analysing...`},Je=ye.elevenLabsAgentId||t?.elevenLabsAgentId||null,Ye=t?.siteId||n?.siteId||null,Xe=t?.apiBaseUrl||``;(0,b.useEffect)(()=>{Xn(t?.siteType||null)},[t?.siteType]);let Ze=(0,b.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),P=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,Qe=r.some(e=>e.sender===`user`),$e=(0,b.useMemo)(()=>{let e=r.findIndex(e=>e.sender===`user`);return e===-1?!1:r.slice(e+1).some(e=>e.sender===`bot`||e.sender===`ai`||e.sender===`agent`)},[r]),et=!!(ye._dashboardLivePreview||ve._dashboardLivePreview),[F,tt]=(0,b.useState)(()=>et?`text_chat`:`entry_prompt`),[nt,rt]=(0,b.useState)(``),[it,at]=(0,b.useState)(null),[ot,st]=(0,b.useState)(l||``),[I,ct]=(0,b.useState)(``),[L,lt]=(0,b.useState)(!1),[ut,dt]=(0,b.useState)(0),[ft,pt]=(0,b.useState)(null),[mt,ht]=(0,b.useState)(null),[gt,_t]=(0,b.useState)(``),[vt,yt]=(0,b.useState)(!1),[R,bt]=(0,b.useState)(!1),[xt,St]=(0,b.useState)(!1),Ct=(0,b.useRef)(null),wt=(0,b.useRef)(!1),Tt=!l&&Qe&&$e&&F!==`voice_mode`;(0,b.useLayoutEffect)(()=>{if(e!==`ready`||wt.current)return;if(wt.current=!0,!Se){tt(`minimized_orb`);return}let t=!1;try{t=Sr().shouldResumeVoice}catch{}let n=De(),r=Ye?Ce(Ye):null,i=n||!!r?.transcript;if(t){re?.({notifyChatInitiated:!0}),ie?.(!0),tt(`voice_mode`);return}if(Ae()){re?.({notifyChatInitiated:!1}),tt(`text_chat`);return}if(i){if((typeof performance<`u`?performance.getEntriesByType?.(`navigation`)?.[0]?.type??`navigate`:`navigate`)===`reload`){tt(`minimized_orb`);return}re?.({notifyChatInitiated:!0}),ie?.(!0),tt(`voice_mode`);return}if(Ye)try{we(Ye)}catch{}if(D(Ye)){tt(`minimized_orb`);return}},[e,r]);let[Et,Dt]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,b.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>Dt(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,b.useEffect)(()=>{st(l||``),l&&ct(``)},[l]);let Ot=(0,b.useCallback)(()=>{ht(null),_t(``)},[]),kt=(0,b.useCallback)(e=>{let t=Wm(e);if(t){ht(null),_t(t);return}ht(e),_t(``)},[]);(0,b.useEffect)(()=>{if(!y||v!==`connected`){dt(0);return}let e=()=>{let e=new Date(y).getTime();isNaN(e)||dt(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[y,v]);let At=(0,b.useCallback)(()=>{tt(`call_screen`),bt(!1)},[]),jt=(0,b.useCallback)(()=>{tt(`text_chat`),bt(!0)},[]);(0,b.useEffect)(()=>{let e=g?.callId||_||null;if(!e){Ct.current=null;return}if(g?.callId||v===`connecting`||v===`connected`){if(F===`minimized_orb`&&R&&_&&!g?.callId){Ct.current=e;return}!(!i||F===`minimized_orb`||F===`voice_mode`)&&Ct.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:F,hasIncomingCall:!!g?.callId,activeCallId:_,callConnectionState:v}),Ct.current=e,F===`voice_mode`&&ie?.(!1),re?.(),At())}},[_,v,At,g?.callId,i,re,ie,F]),(0,b.useEffect)(()=>{!g&&!_&&F===`call_screen`&&tt(`text_chat`)},[g,_,F]),(0,b.useEffect)(()=>{!_&&R&&bt(!1)},[_,R]),(0,b.useEffect)(()=>{if(!o||h){A?.(``),k?.();return}if(!nt.trim()||mt){A?.(``);let e=window.setTimeout(()=>k?.(),100);return()=>window.clearTimeout(e)}fe?.();let e=window.setTimeout(()=>A?.(nt),120),t=window.setTimeout(()=>k?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[nt,mt,o,h,fe,k,A]);let Mt=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,Nt=async e=>{if(e.preventDefault(),h)return;if(Tt){let e=ot.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){ct(`Please enter a valid email so we can continue helping you.`);return}await E(e),ct(``),lt(!0),setTimeout(()=>lt(!1),3e3);return}let t=Mt(it);if(!nt.trim()&&!mt)return;if(mt){try{yt(!0),_t(``);let e=await ne(mt),n=e?.data||e,r=nt.trim()||`Shared file: ${Km(mt)}`;rt(``),at(null),Ot(),await te(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||mt.name,fileType:n?.fileType||mt.type,fileSize:n?.fileSize||mt.size}})}catch(e){_t(e?.message||`Failed to upload the selected file.`)}finally{yt(!1)}return}let n=nt.trim();rt(``),at(null),await te(n,``,t)},Pt=(0,b.useCallback)(()=>{r.length!==0&&oe?.()},[r.length,oe]),Ft=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},It=(0,b.useCallback)(async e=>{if(h||f)return;let t=e.message||e.label||e.text||``;t.trim()&&await te(t.trim(),``)},[h,f,te]),Lt=Et&&F===`entry_prompt`?{inset:0}:Et&&F===`text_chat`?{left:0,right:0,bottom:0}:Et&&F===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:Et&&F===`connection_modal`?{left:`12px`,right:`12px`,bottom:`12px`}:F===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...je===`bottom-left`?{left:`1.5rem`,bottom:Be}:{right:`1.5rem`,bottom:Be}}:je===`bottom-left`?{left:`1.5rem`,bottom:Be}:{right:`1.5rem`,bottom:Be},Rt=(0,b.useCallback)(()=>{F!==`minimized_orb`&&(St(!0),setTimeout(()=>{tt(`minimized_orb`),St(!1),_&&bt(!0)},280))},[_,F]),zt=()=>tt(`connection_modal`),Bt=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}re({notifyChatInitiated:!0}),ie?.(!0),tt(`voice_mode`)},Vt=()=>{re({notifyChatInitiated:!0}),ie?.(!1),tt(`text_chat`)},Ht=()=>{ie?.(!1),Rt()};return e!==`ready`||!He||xe.chat===!1||!Ge?null:(0,B.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...Lt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[F===`entry_prompt`&&(0,B.jsx)(lg,{copy:qe,orbColors:Te,primaryColor:Ee,onYes:()=>{O(Ye),Bt()},onLater:()=>{O(Ye),Rt()},isMobile:Et,isClosing:xt}),F===`minimized_orb`&&(0,B.jsxs)(dm.div,{layoutId:`fe-main-orb`,initial:{scale:.4,opacity:0},animate:{scale:1,opacity:1},transition:{type:`spring`,stiffness:280,damping:18},style:{transformOrigin:`bottom right`,display:`inline-flex`,flexDirection:`column`,alignItems:je===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[_&&(0,B.jsxs)(`button`,{type:`button`,onClick:At,style:{maxWidth:Et?`220px`:`240px`,padding:`10px 14px`,borderRadius:`18px`,border:`1px solid rgba(255,255,255,0.7)`,background:`rgba(255,255,255,0.94)`,backdropFilter:`blur(18px)`,WebkitBackdropFilter:`blur(18px)`,boxShadow:`0 10px 26px rgba(15,23,42,0.14)`,display:`flex`,alignItems:`center`,gap:`10px`,cursor:`pointer`,textAlign:`left`},children:[(0,B.jsx)(`span`,{style:{width:`9px`,height:`9px`,borderRadius:`50%`,background:`#22c55e`,boxShadow:`0 0 0 4px rgba(34,197,94,0.16)`,flexShrink:0}}),(0,B.jsxs)(`span`,{style:{minWidth:0},children:[(0,B.jsx)(`span`,{style:{display:`block`,fontSize:`12px`,fontWeight:700,color:`#111827`,lineHeight:1.2},children:v===`connected`?`Call in progress`:`Call is active`}),(0,B.jsx)(`span`,{style:{display:`block`,fontSize:`11px`,color:`#6b7280`,lineHeight:1.3,marginTop:`2px`,whiteSpace:`nowrap`},children:v===`connected`?`${Ft(ut)} with ${Ze}`:`Tap to return to ${Ze}`})]})]}),(0,B.jsx)(cg,{size:ke,orbColors:Te,onClick:_?At:Se?zt:Vt})]}),F===`connection_modal`&&(0,B.jsx)(ug,{copy:qe,orbColors:Te,primaryColor:Ee,onVoice:Bt,onText:Vt,onClose:Rt,isMobile:Et,isClosing:xt}),F===`voice_mode`&&(0,B.jsx)(dg,{orbColors:Te,onEnterChat:Vt,onEndChat:Ht,agentId:Je,siteId:Ye,apiBaseUrl:Xe,chatId:w,historyRef:ee,onMessageSync:T,voiceEndCounter:_e,websiteName:t?.websiteName,voiceFirstMessage:ve.voiceFirstMessage||null,captureVisitorEmail:E,emailRequired:!l,emailCaptureEnabled:j.disableEmailCapture!==!0,listeningLabel:j.voiceListeningLabel||`Listening...`,enterChatModeLabel:j.voiceEnterChatLabel||`Enter Chat Mode`,endConversationLabel:j.voiceEndConversationLabel||`End Conversation`},`voice`),F===`call_screen`&&(0,B.jsx)(mh,{incomingCall:g,activeCallId:_,callConnectionState:v,callDurationSeconds:ut,isCallMuted:x,agentName:Ze,agentHeadshot:P,fallbackAgentName:Me,acceptCall:se,rejectCall:ce,endWebRTCCall:le,toggleCallMute:ue,formatCallDuration:Ft,onMinimize:jt,primaryColor:Ee,orbColors:Te,chatHistory:r}),F===`text_chat`&&(0,B.jsx)(mg,{isClosing:xt,copy:qe,orbColors:Te,primaryColor:Ee,chatBgGradient:Ne,logo:Pe,quickChatOptions:Le,onQuickChatSelect:It,isMobile:Et,chatHistory:r,isAiTyping:d,isAgentTyping:u,activeScreen:a,agentName:Ze,agentHeadshot:P,fallbackAgentName:Me,input:nt,setInput:rt,onSubmit:Nt,isConversationEnded:h,isLoading:f,isRateLimited:p,rateLimitMessage:m,selectedFile:mt,onFileSelect:kt,onRemoveSelectedFile:Ot,attachmentError:gt,isUploadingAttachment:vt,requiresEmail:Tt,emailInput:ot,setEmailInput:st,emailError:I,emailCaptureSuccess:L,replyContext:it,setReplyContext:at,webRTCError:S,micError:ft,setMicError:pt,dismissCallError:de,activeCallId:_,isCallMuted:x,toggleCallMute:ue,endWebRTCCall:le,formatCallDuration:Ft,callDurationSeconds:ut,onCollapse:Rt,onStartVoice:Bt,voiceEnabled:Se,onNewChat:Pt,onMinimize:jt,onExpand:At,isCallMinimized:!!_,showPoweredBy:Re,privacyPolicyUrl:Ve,headerBgColor:ze,getVisitorChatHistory:pe,resumeChat:me,isSessionRestoring:he}),(0,B.jsx)(`style`,{children:`
|
|
350
|
+
`.replace(/\s+/g,` `).trim()}})}var mg=()=>(0,B.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`12px 16px`,borderRadius:`18px`,background:`#fff`,boxShadow:`0 2px 6px rgba(0,0,0,0.04)`},children:[0,1,2].map(e=>(0,B.jsx)(`span`,{style:{width:`7px`,height:`7px`,borderRadius:`50%`,background:`#9ca3af`,animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`}},e))})});function hg({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:d,agentName:f,agentHeadshot:p,fallbackAgentName:m,input:h,setInput:g,onSubmit:_,isConversationEnded:v,isLoading:y,isRateLimited:x,rateLimitMessage:S,selectedFile:C,onFileSelect:w,onRemoveSelectedFile:ee,attachmentError:T,isUploadingAttachment:te,requiresEmail:ne,emailInput:re,setEmailInput:E,emailError:ie,emailCaptureSuccess:ae,replyContext:oe,setReplyContext:se,webRTCError:ce,micError:D,setMicError:O,dismissCallError:le,activeCallId:ue,isCallMuted:de,toggleCallMute:fe,endWebRTCCall:k,formatCallDuration:A,callDurationSeconds:pe,isCallMinimized:me,onExpand:he,onCollapse:ge,onStartVoice:_e,voiceEnabled:ve,headerBgColor:ye,onNewChat:j,showPoweredBy:be,privacyPolicyUrl:xe,getVisitorChatHistory:Se,resumeChat:Ce,isSessionRestoring:we,isClosing:Te}){let Ee=c.length>0,De=y||x||v,Oe=!!ue,[ke,Ae]=(0,b.useState)(!1),[je,Me]=(0,b.useState)(!1),[Ne,Pe]=(0,b.useState)([]),[Fe,M]=(0,b.useState)(!1),Ie=(0,b.useRef)(null),[Le,Re]=(0,b.useState)(()=>typeof window<`u`?window.visualViewport?.height??window.innerHeight:600),[ze,Be]=(0,b.useState)(0);(0,b.useEffect)(()=>{if(!s)return;let e=window.visualViewport;if(!e)return;let t=()=>{Re(e.height),Be(Math.max(0,window.innerHeight-e.offsetTop-e.height))};return e.addEventListener(`resize`,t),e.addEventListener(`scroll`,t),t(),()=>{e.removeEventListener(`resize`,t),e.removeEventListener(`scroll`,t)}},[s]);let Ve=s&&window.innerHeight-Le>150,He=async()=>{Ae(!1),Me(!0),M(!0);try{let e=await Se();e?.data&&Pe(e.data)}catch(e){console.error(e)}finally{M(!1)}},N=async e=>{Me(!1),Ce?.(e.chatId)};return(0,b.useEffect)(()=>{if(!ke)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Ie.current&&!Ie.current.contains(t)&&Ae(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[ke]),(0,B.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`0`,right:`0`,bottom:`${ze}px`,height:Le>0?`${Math.round(Le*(Ve?1:.92))}px`:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:Te?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.28s cubic-bezier(0.16,1,0.3,1)`}:{"--flowengage-primary":n,"--flowengage-accent":n,width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,background:r,borderRadius:`22px`,boxShadow:`0 24px 64px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.08)`,display:`flex`,flexDirection:`column`,overflow:`hidden`,position:`relative`,animation:Te?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:`fe-orb-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`},children:[(0,B.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 10px 14px`,background:ye||`transparent`,flexShrink:0,position:`relative`,zIndex:30},children:[(0,B.jsx)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:(0,B.jsx)(`button`,{onClick:ge,style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`,flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},children:(0,B.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})})}),(()=>{let t=!!i,n=!!e.hasCustomTitle,r=t||n,a=t||!r,o=n||!r,c=a&&o;return(0,B.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:c?`minmax(72px, 40%) minmax(0, 60%)`:`1fr`,columnGap:c?`12px`:0,alignItems:`center`,justifyItems:c?`stretch`:`center`},children:[a&&(0,B.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,B.jsx)(og,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,B.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,B.jsx)(sg,{title:e.chatTitle})})}),o&&(0,B.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:c?`flex-start`:`center`},children:(0,B.jsx)(`span`,{style:{fontSize:`15px`,fontWeight:600,color:`#111827`,letterSpacing:`-0.01em`,lineHeight:1.2,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},title:e.chatTitle,children:e.chatTitle})})]})})(),(0,B.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Ie,children:[(0,B.jsx)(`button`,{type:`button`,onClick:()=>Ae(e=>!e),style:{width:`40px`,height:`40px`,background:`none`,border:`none`,cursor:`pointer`,color:`#6b7280`,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`4px`,borderRadius:`10px`,transition:`color 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.color=`#111827`},onMouseLeave:e=>{e.currentTarget.style.color=`#6b7280`},"aria-label":`Chat options`,children:(0,B.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,B.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),ke&&(0,B.jsxs)(`div`,{style:{position:`absolute`,top:`34px`,right:0,background:`rgba(15,22,36,0.96)`,backdropFilter:`blur(14px)`,WebkitBackdropFilter:`blur(14px)`,borderRadius:`16px`,overflow:`hidden`,boxShadow:`0 10px 40px rgba(0,0,0,0.45)`,minWidth:`210px`,border:`1px solid rgba(255,255,255,0.07)`,animation:`fe-orb-fade-in 0.18s ease`},children:[ve&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(!1),_e?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,B.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,B.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}})]}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(!1),j?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`path`,{d:`M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7`}),(0,B.jsx)(`path`,{d:`M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z`})]}),`Start new chat`]}),Se&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,B.jsxs)(`button`,{type:`button`,onClick:He,style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`white`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(255,255,255,0.08)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`path`,{d:`M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z`})}),`Chat history`]})]}),(0,B.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,B.jsxs)(`button`,{type:`button`,onClick:()=>{Ae(!1),ge?.()},style:{display:`flex`,alignItems:`center`,gap:`12px`,width:`100%`,padding:`14px 18px`,background:`none`,border:`none`,color:`#f87171`,fontSize:`14px`,fontWeight:500,cursor:`pointer`,textAlign:`left`,transition:`background 0.15s ease`},onMouseEnter:e=>{e.currentTarget.style.background=`rgba(248,113,113,0.1)`},onMouseLeave:e=>{e.currentTarget.style.background=`none`},children:[(0,B.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,B.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,B.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,B.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`Close conversation`]})]})]})]}),(0,B.jsx)($m,{webRTCError:ce,micError:D,setMicError:O,dismissCallError:le,isRateLimited:x,rateLimitMessage:S}),me&&(0,B.jsx)(gh,{agentName:f,agentHeadshot:p,fallbackAgentName:m,callDurationSeconds:pe,isCallMuted:de,formatCallDuration:A,toggleCallMute:fe,endWebRTCCall:k,onExpand:he,primaryColor:n}),(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[je?(0,B.jsxs)(`div`,{style:{position:`absolute`,inset:0,background:`white`,zIndex:20,display:`flex`,flexDirection:`column`,animation:`fe-orb-fade-in 0.2s ease`},children:[(0,B.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px`,borderBottom:`1px solid #f3f4f6`,flexShrink:0},children:(0,B.jsxs)(`button`,{onClick:()=>Me(!1),style:{background:`none`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,color:`#6b7280`},children:[(0,B.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,B.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),(0,B.jsx)(`span`,{style:{marginLeft:`8px`,fontWeight:500,fontSize:`15px`},children:`Return to Chat`})]})}),(0,B.jsx)(`div`,{style:{flex:1,overflowY:`auto`,position:`relative`},children:Fe?(0,B.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):Ne.length>0?(0,B.jsx)(`div`,{children:Ne.map(e=>(0,B.jsxs)(`div`,{onClick:()=>N(e),style:{padding:`16px 20px`,borderBottom:`1px solid #f3f4f6`,cursor:`pointer`,transition:`background 0.15s ease`},onMouseEnter:e=>e.currentTarget.style.background=`#f9fafb`,onMouseLeave:e=>e.currentTarget.style.background=`white`,children:[(0,B.jsxs)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginBottom:`6px`,fontWeight:500},children:[new Date(e.createdAt).toLocaleDateString(void 0,{month:`short`,day:`numeric`}),` at `,new Date(e.createdAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})]}),(0,B.jsx)(`div`,{style:{fontSize:`14.5px`,color:`#111827`,opacity:.9,overflow:`hidden`,textOverflow:`ellipsis`,display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,lineHeight:1.4},children:e.message||`Conversation`})]},e.chatId))}):(0,B.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#9ca3af`,fontSize:`14px`},children:`No previous chats found.`})})]}):null,Ee?(0,B.jsx)(Xm,{chatHistory:c,isAiTyping:l,isLoading:y,isAgentTyping:u,setReplyContext:se,TypingDots:mg,primaryColor:n,agentHeadshot:p,agentDisplayName:f||m,botAvatarNode:(0,B.jsx)(pg,{orbColors:t})}):we?(0,B.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`},children:[(0,B.jsx)(`div`,{style:{width:`28px`,height:`28px`,border:`3px solid #f3f4f6`,borderTop:`3px solid ${n}`,borderRadius:`50%`,animation:`spin 1s linear infinite`},children:(0,B.jsx)(`style`,{children:`@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})}),(0,B.jsx)(`div`,{style:{color:`#6b7280`,fontSize:`14px`,fontWeight:500,animation:`fe-orb-fade-in 1s infinite alternate`},children:`Loading chat...`})]}):(0,B.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,B.jsx)(lg,{size:94,orbColors:t}),(0,B.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,B.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,B.jsx)(`button`,{onClick:()=>o?.(e),style:{padding:`8px 16px`,borderRadius:`999px`,background:`white`,border:`1.5px solid ${n}33`,color:n||`#374151`,fontSize:`13px`,fontWeight:500,cursor:`pointer`,transition:`all 0.15s ease`,boxShadow:`0 1px 4px rgba(0,0,0,0.06)`},onMouseEnter:e=>{e.currentTarget.style.background=`${n}12`,e.currentTarget.style.borderColor=n},onMouseLeave:e=>{e.currentTarget.style.background=`white`,e.currentTarget.style.borderColor=`${n}33`},children:e.label||e.text},e.id))})]})]}),ae&&(0,B.jsxs)(`div`,{style:{margin:`0 16px 8px`,padding:`9px 14px`,borderRadius:`12px`,background:`#ecfdf5`,border:`1px solid #6ee7b7`,display:`flex`,alignItems:`center`,gap:`8px`,animation:`fe-orb-fade-in 0.2s ease`,flexShrink:0},children:[(0,B.jsx)(`svg`,{width:`15`,height:`15`,viewBox:`0 0 24 24`,fill:`none`,stroke:`#10b981`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,style:{flexShrink:0},children:(0,B.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,B.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`#065f46`},children:`Email saved — we'll be in touch!`})]}),(0,B.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:ne?`6px 0 0`:`12px 0 0`},children:(0,B.jsx)(Qm,{input:h,setInput:g,onSubmit:_,isConversationEnded:v,callUiActive:Oe,handleToggleVoice:_e,showVoiceToggle:d===`agent`,activeScreen:d,inputDisabled:De,replyContext:oe,clearReplyContext:()=>se(null),onFileSelect:w,selectedFile:C,onRemoveSelectedFile:ee,attachmentError:T,isUploadingAttachment:te,requiresEmail:ne,emailInput:re,setEmailInput:E,emailError:ie,inputPlaceholder:e.inputPlaceholder})}),!Ve&&(0,B.jsxs)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`8px 20px`,paddingBottom:`max(12px, env(safe-area-inset-bottom, 12px))`,pointerEvents:`none`},children:[xe&&(0,B.jsxs)(`p`,{style:{margin:`0 0 4px`,fontSize:`10px`,color:`#9ca3af`,lineHeight:1.4,userSelect:`none`,pointerEvents:`auto`},children:[`This conversation is recorded for quality assurance purposes.`,` `,(0,B.jsx)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#6b7280`,textDecoration:`underline`},children:`See our privacy policy`})]}),be&&(0,B.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,B.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})]})]})}function gg(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:d,isLoading:f,isRateLimited:p,rateLimitMessage:m,isConversationEnded:h,incomingCall:g,activeCallId:_,callConnectionState:v,callConnectedAt:y,isCallMuted:x,webRTCError:S,language:C,chatId:w,historyRef:ee,onMessageSync:T,sendMessage:te,uploadChatFile:ne,openWidget:re,captureVisitorEmail:E,setVoiceMode:ie,endConversation:ae,startNewChat:oe,acceptCall:se,rejectCall:ce,endWebRTCCall:le,toggleCallMute:ue,dismissCallError:de,startTyping:fe,stopTyping:k,updateTypingDraft:A,getVisitorChatHistory:pe,resumeChat:me,isSessionRestoring:he,openToChatCounter:ge,voiceEndCounter:_e}=En();(0,b.useEffect)(()=>{try{ur()}catch{}},[]),(0,b.useEffect)(()=>{ge&&F!==`voice_mode`&&F!==`text_chat`&&F!==`call_screen`&&(ie?.(!1),tt(`text_chat`))},[ge]);let ve=t?.widgetSettings||{},ye=n?.widgetSettings||{},j={...ve.branding||{},...ye.branding||{}},be={...ve.theme||{},...ye.theme||{}},xe={...ve.features||{},...ye.features||{}},Se=xe.voice!==!1,Te=Array.isArray(be.orbColors)&&be.orbColors.length>0?be.orbColors:null,Ee=be.buttonColor||be.primaryColor||Te?.[0]||`#3B82F6`,Oe={small:50,medium:64,large:80},ke=Oe[be.orbSize]||Oe.small,je=be.position||`bottom-right`,Me=j.fallbackAgentName||`Agent`,Ne=rg(Te??be.chatBgColors),Pe=j.logo||j.logoUrl||null,Fe=C||`en`,M=ve.recommendations?.[Fe]||[],Ie=(ye.recommendations?.[Fe]??M).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Le=Array.isArray(j.quickChatOptions)&&j.quickChatOptions.length>0?j.quickChatOptions:Ie,Re=j.hideWatermark===!0?!1:j.showPoweredBy!==!1,ze=j.headerBgColor||null,Be=be.bottomPosition==null?`1.5rem`:`${be.bottomPosition}px`,Ve=j.privacyPolicyUrl||null,He=j.chatbotEnabled!==!1&&be.chatbotEnabled!==!1,[N,Ue]=(0,b.useState)(()=>typeof window<`u`?window.location.pathname:`/`);(0,b.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>Ue(window.location.pathname),t=window.history.pushState.bind(window.history);return window.history.pushState=(...n)=>{t(...n),setTimeout(e,50)},window.addEventListener(`popstate`,e),()=>{window.history.pushState=t,window.removeEventListener(`popstate`,e)}},[]);let We=(()=>{let e={...ve.pageVisibility||{},...ye.pageVisibility||{}};return Array.isArray(e.allowedPaths)?e.allowedPaths.filter(Boolean):[]})(),Ge=We.length===0||We.some(e=>e===`*`||e===`/*`?!0:e.endsWith(`/*`)?N.startsWith(e.slice(0,-1)):N.replace(/\/$/,``)===e.replace(/\/$/,``)),Ke=ve.greetings?.[C]||ye.greetings?.[C]||j.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,qe={entryPrompt:j.entryPrompt||`Do you want to explore in a new way?`,yesLabel:j.yesLabel||`Yes`,laterLabel:j.laterLabel||`Later`,connectionTitle:j.connectionTitle||`How would you like to connect?`,connectionSubtitle:j.connectionSubtitle||``,voiceLabel:j.voiceLabel||`Voice`,textLabel:j.textLabel||`Text`,chatTitle:j.headerName||`Chat with FlowEngage`,hasCustomTitle:!!(j.headerName&&String(j.headerName).trim()),introGreeting:Ke,inputPlaceholder:j.inputPlaceholder||`Type your message`,analysingLabel:j.analysingLabel||`analysing...`},Je=ye.elevenLabsAgentId||t?.elevenLabsAgentId||null,Ye=t?.siteId||n?.siteId||null,Xe=t?.apiBaseUrl||``;(0,b.useEffect)(()=>{Xn(t?.siteType||null)},[t?.siteType]);let Ze=(0,b.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),P=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,Qe=r.some(e=>e.sender===`user`),$e=(0,b.useMemo)(()=>{let e=r.findIndex(e=>e.sender===`user`);return e===-1?!1:r.slice(e+1).some(e=>e.sender===`bot`||e.sender===`ai`||e.sender===`agent`)},[r]),et=!!(ye._dashboardLivePreview||ve._dashboardLivePreview),[F,tt]=(0,b.useState)(()=>et?`text_chat`:`entry_prompt`),[nt,rt]=(0,b.useState)(``),[it,at]=(0,b.useState)(null),[ot,st]=(0,b.useState)(l||``),[I,ct]=(0,b.useState)(``),[L,lt]=(0,b.useState)(!1),[ut,dt]=(0,b.useState)(0),[ft,pt]=(0,b.useState)(null),[mt,ht]=(0,b.useState)(null),[gt,_t]=(0,b.useState)(``),[vt,yt]=(0,b.useState)(!1),[R,bt]=(0,b.useState)(!1),[xt,St]=(0,b.useState)(!1),Ct=(0,b.useRef)(null),wt=(0,b.useRef)(!1),Tt=!l&&Qe&&$e&&F!==`voice_mode`;(0,b.useLayoutEffect)(()=>{if(e!==`ready`||wt.current)return;if(wt.current=!0,!Se){tt(`minimized_orb`);return}let t=!1;try{t=Sr().shouldResumeVoice}catch{}let n=De(),r=Ye?Ce(Ye):null,i=n||!!r?.transcript;if(t){re?.({notifyChatInitiated:!0}),ie?.(!0),tt(`voice_mode`);return}if(Ae()){re?.({notifyChatInitiated:!1}),tt(`text_chat`);return}if(i){if((typeof performance<`u`?performance.getEntriesByType?.(`navigation`)?.[0]?.type??`navigate`:`navigate`)===`reload`){tt(`minimized_orb`);return}re?.({notifyChatInitiated:!0}),ie?.(!0),tt(`voice_mode`);return}if(Ye)try{we(Ye)}catch{}if(D(Ye)){tt(`minimized_orb`);return}},[e,r]);let[Et,Dt]=(0,b.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,b.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>Dt(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,b.useEffect)(()=>{st(l||``),l&&ct(``)},[l]);let Ot=(0,b.useCallback)(()=>{ht(null),_t(``)},[]),kt=(0,b.useCallback)(e=>{let t=Gm(e);if(t){ht(null),_t(t);return}ht(e),_t(``)},[]);(0,b.useEffect)(()=>{if(!y||v!==`connected`){dt(0);return}let e=()=>{let e=new Date(y).getTime();isNaN(e)||dt(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[y,v]);let At=(0,b.useCallback)(()=>{tt(`call_screen`),bt(!1)},[]),jt=(0,b.useCallback)(()=>{tt(`text_chat`),bt(!0)},[]);(0,b.useEffect)(()=>{let e=g?.callId||_||null;if(!e){Ct.current=null;return}if(g?.callId||v===`connecting`||v===`connected`){if(F===`minimized_orb`&&R&&_&&!g?.callId){Ct.current=e;return}!(!i||F===`minimized_orb`||F===`voice_mode`)&&Ct.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:F,hasIncomingCall:!!g?.callId,activeCallId:_,callConnectionState:v}),Ct.current=e,F===`voice_mode`&&ie?.(!1),re?.(),At())}},[_,v,At,g?.callId,i,re,ie,F]),(0,b.useEffect)(()=>{!g&&!_&&F===`call_screen`&&tt(`text_chat`)},[g,_,F]),(0,b.useEffect)(()=>{!_&&R&&bt(!1)},[_,R]),(0,b.useEffect)(()=>{if(!o||h){A?.(``),k?.();return}if(!nt.trim()||mt){A?.(``);let e=window.setTimeout(()=>k?.(),100);return()=>window.clearTimeout(e)}fe?.();let e=window.setTimeout(()=>A?.(nt),120),t=window.setTimeout(()=>k?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[nt,mt,o,h,fe,k,A]);let Mt=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,Nt=async e=>{if(e.preventDefault(),h)return;if(Tt){let e=ot.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){ct(`Please enter a valid email so we can continue helping you.`);return}await E(e),ct(``),lt(!0),setTimeout(()=>lt(!1),3e3);return}let t=Mt(it);if(!nt.trim()&&!mt)return;if(mt){try{yt(!0),_t(``);let e=await ne(mt),n=e?.data||e,r=nt.trim()||`Shared file: ${qm(mt)}`;rt(``),at(null),Ot(),await te(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||mt.name,fileType:n?.fileType||mt.type,fileSize:n?.fileSize||mt.size}})}catch(e){_t(e?.message||`Failed to upload the selected file.`)}finally{yt(!1)}return}let n=nt.trim();rt(``),at(null),await te(n,``,t)},Pt=(0,b.useCallback)(()=>{r.length!==0&&oe?.()},[r.length,oe]),Ft=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},It=(0,b.useCallback)(async e=>{if(h||f)return;let t=e.message||e.label||e.text||``;t.trim()&&await te(t.trim(),``)},[h,f,te]),Lt=Et&&F===`entry_prompt`?{inset:0}:Et&&F===`text_chat`?{left:0,right:0,bottom:0}:Et&&F===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:Et&&F===`connection_modal`?{left:`12px`,right:`12px`,bottom:`12px`}:F===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...je===`bottom-left`?{left:`1.5rem`,bottom:Be}:{right:`1.5rem`,bottom:Be}}:je===`bottom-left`?{left:`1.5rem`,bottom:Be}:{right:`1.5rem`,bottom:Be},Rt=(0,b.useCallback)(()=>{F!==`minimized_orb`&&(St(!0),setTimeout(()=>{tt(`minimized_orb`),St(!1),_&&bt(!0)},280))},[_,F]),zt=()=>tt(`connection_modal`),Bt=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}re({notifyChatInitiated:!0}),ie?.(!0),tt(`voice_mode`)},Vt=()=>{re({notifyChatInitiated:!0}),ie?.(!1),tt(`text_chat`)},Ht=()=>{ie?.(!1),Rt()};return e!==`ready`||!He||xe.chat===!1||!Ge?null:(0,B.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...Lt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[F===`entry_prompt`&&(0,B.jsx)(ug,{copy:qe,orbColors:Te,primaryColor:Ee,onYes:()=>{O(Ye),Bt()},onLater:()=>{O(Ye),Rt()},isMobile:Et,isClosing:xt}),F===`minimized_orb`&&(0,B.jsxs)(dm.div,{layoutId:`fe-main-orb`,initial:{scale:.4,opacity:0},animate:{scale:1,opacity:1},transition:{type:`spring`,stiffness:280,damping:18},style:{transformOrigin:`bottom right`,display:`inline-flex`,flexDirection:`column`,alignItems:je===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[_&&(0,B.jsxs)(`button`,{type:`button`,onClick:At,style:{maxWidth:Et?`220px`:`240px`,padding:`10px 14px`,borderRadius:`18px`,border:`1px solid rgba(255,255,255,0.7)`,background:`rgba(255,255,255,0.94)`,backdropFilter:`blur(18px)`,WebkitBackdropFilter:`blur(18px)`,boxShadow:`0 10px 26px rgba(15,23,42,0.14)`,display:`flex`,alignItems:`center`,gap:`10px`,cursor:`pointer`,textAlign:`left`},children:[(0,B.jsx)(`span`,{style:{width:`9px`,height:`9px`,borderRadius:`50%`,background:`#22c55e`,boxShadow:`0 0 0 4px rgba(34,197,94,0.16)`,flexShrink:0}}),(0,B.jsxs)(`span`,{style:{minWidth:0},children:[(0,B.jsx)(`span`,{style:{display:`block`,fontSize:`12px`,fontWeight:700,color:`#111827`,lineHeight:1.2},children:v===`connected`?`Call in progress`:`Call is active`}),(0,B.jsx)(`span`,{style:{display:`block`,fontSize:`11px`,color:`#6b7280`,lineHeight:1.3,marginTop:`2px`,whiteSpace:`nowrap`},children:v===`connected`?`${Ft(ut)} with ${Ze}`:`Tap to return to ${Ze}`})]})]}),(0,B.jsx)(lg,{size:ke,orbColors:Te,onClick:_?At:Se?zt:Vt})]}),F===`connection_modal`&&(0,B.jsx)(dg,{copy:qe,orbColors:Te,primaryColor:Ee,onVoice:Bt,onText:Vt,onClose:Rt,isMobile:Et,isClosing:xt}),F===`voice_mode`&&(0,B.jsx)(fg,{orbColors:Te,onEnterChat:Vt,onEndChat:Ht,agentId:Je,siteId:Ye,apiBaseUrl:Xe,chatId:w,historyRef:ee,onMessageSync:T,voiceEndCounter:_e,websiteName:t?.websiteName,voiceFirstMessage:ve.voiceFirstMessage||null,captureVisitorEmail:E,emailRequired:!l,emailCaptureEnabled:j.disableEmailCapture!==!0,listeningLabel:j.voiceListeningLabel||`Listening...`,enterChatModeLabel:j.voiceEnterChatLabel||`Enter Chat Mode`,endConversationLabel:j.voiceEndConversationLabel||`End Conversation`},`voice`),F===`call_screen`&&(0,B.jsx)(hh,{incomingCall:g,activeCallId:_,callConnectionState:v,callDurationSeconds:ut,isCallMuted:x,agentName:Ze,agentHeadshot:P,fallbackAgentName:Me,acceptCall:se,rejectCall:ce,endWebRTCCall:le,toggleCallMute:ue,formatCallDuration:Ft,onMinimize:jt,primaryColor:Ee,orbColors:Te,chatHistory:r}),F===`text_chat`&&(0,B.jsx)(hg,{isClosing:xt,copy:qe,orbColors:Te,primaryColor:Ee,chatBgGradient:Ne,logo:Pe,quickChatOptions:Le,onQuickChatSelect:It,isMobile:Et,chatHistory:r,isAiTyping:d,isAgentTyping:u,activeScreen:a,agentName:Ze,agentHeadshot:P,fallbackAgentName:Me,input:nt,setInput:rt,onSubmit:Nt,isConversationEnded:h,isLoading:f,isRateLimited:p,rateLimitMessage:m,selectedFile:mt,onFileSelect:kt,onRemoveSelectedFile:Ot,attachmentError:gt,isUploadingAttachment:vt,requiresEmail:Tt,emailInput:ot,setEmailInput:st,emailError:I,emailCaptureSuccess:L,replyContext:it,setReplyContext:at,webRTCError:S,micError:ft,setMicError:pt,dismissCallError:de,activeCallId:_,isCallMuted:x,toggleCallMute:ue,endWebRTCCall:le,formatCallDuration:Ft,callDurationSeconds:ut,onCollapse:Rt,onStartVoice:Bt,voiceEnabled:Se,onNewChat:Pt,onMinimize:jt,onExpand:At,isCallMinimized:!!_,showPoweredBy:Re,privacyPolicyUrl:Ve,headerBgColor:ze,getVisitorChatHistory:pe,resumeChat:me,isSessionRestoring:he}),(0,B.jsx)(`style`,{children:`
|
|
351
351
|
/* Force any SVG (or img) inside LogoSlot to fill the container height
|
|
352
352
|
regardless of whether the component forwards its style prop. */
|
|
353
353
|
.fe-logo-slot svg,
|
|
@@ -366,4 +366,4 @@ Error generating stack: `+e.message+`
|
|
|
366
366
|
@keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }
|
|
367
367
|
@keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }
|
|
368
368
|
@keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }
|
|
369
|
-
`})]})}var gg=class extends b.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[FlowEngage] Widget crashed:`,e,t.componentStack)}render(){return this.state.hasError?this.props.fallback??null:this.props.children}},_g=`@import "https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap";:host{all:initial;box-sizing:border-box!important;color:#111827!important;-webkit-font-smoothing:antialiased!important;z-index:2147483647!important;background:0 0!important;border:none!important;margin:0!important;padding:0!important;font-family:Poppins,system-ui,-apple-system,sans-serif!important;font-size:16px!important;line-height:1.5!important;display:block!important;position:relative!important}:host *,:host :before,:host :after{box-sizing:border-box}.flowengage-widget-root{-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility;color:#111827!important;-webkit-font-smoothing:antialiased!important;font-family:Poppins,system-ui,-apple-system,sans-serif!important;font-size:16px!important;line-height:1.5!important}.flowengage-widget-root *,.flowengage-widget-root :before,.flowengage-widget-root :after{font-family:inherit!important}.flowengage-widget-root input,.flowengage-widget-root textarea,.flowengage-widget-root button,.flowengage-widget-root select,.flowengage-widget-root optgroup,.flowengage-widget-root option{font-size:inherit;line-height:inherit;font-family:inherit!important}.flowengage-shell,.flowengage-shell *{font-family:inherit!important}.flowengage-chat-panel{border:none;border-radius:0;outline:none;flex-direction:column;width:100%;height:100%;display:flex;position:relative;overflow:hidden;box-shadow:0 20px 50px #00000026}.flowengage-chat-text-input{margin:0!important}.flowengage-chat-text-input:focus{box-shadow:none!important;border:none!important;outline:none!important}@media (width>=768px){.flowengage-chat-panel{border-radius:24px;width:min(350px,100vw - 40px);height:min(700px,100vh - 120px)}}.flowengage-shell[data-open=true]{inset:0}@media (width>=768px){.flowengage-shell[data-open=true]{inset:auto 1.5rem 1.5rem auto}}.flowengage-logo-fallback{background:conic-gradient(from 180deg, var(--flowengage-primary) 0%, var(--flowengage-accent) 45%, var(--flowengage-primary) 100%)}.fe-bot-message p{margin:0 0 .5em}.fe-bot-message p:last-child{margin-bottom:0}.fe-bot-message ul,.fe-bot-message ol{margin:.4em 0 .4em 1.2em;padding:0}.fe-bot-message li{margin-bottom:.25em}.fe-bot-message strong{font-weight:600}.fe-bot-message a{color:var(--flowengage-primary);text-decoration:underline}.fe-bot-message a:hover{opacity:.8}.incoming-call-overlay{z-index:1000;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#1a1a2ef2;justify-content:center;align-items:center;transition:all .3s ease-in-out;display:flex;position:absolute;left:0;right:0}.incoming-call-overlay.bottom-mode{border-top:2px solid #ffffff1a;min-height:120px;animation:.4s cubic-bezier(.16,1,.3,1) slideUpBanner;top:auto;bottom:0;box-shadow:0 -10px 30px #00000080}.incoming-call-overlay.header-mode{border-bottom:2px solid #ffffff1a;min-height:80px;animation:.4s cubic-bezier(.16,1,.3,1) slideDownBanner;top:0;bottom:auto;box-shadow:0 10px 30px #00000080}.incoming-call-container{justify-content:space-between;align-items:center;gap:14px;width:100%;padding:14px 16px;display:flex}.incoming-call-container.connected-layout{flex-direction:column;justify-content:center;align-items:stretch;gap:14px}.call-connected-top{justify-content:space-between;align-items:center;gap:16px;width:100%;display:flex}.call-connected-identity{flex:1;align-items:center;gap:14px;min-width:0;display:flex}.call-icon-wrapper{color:#fff;z-index:1;border-radius:9999px;flex-shrink:0;justify-content:center;align-items:center;width:54px;height:54px;margin-right:4px;display:flex;position:relative}.call-icon-wrapper.incoming{background:linear-gradient(135deg,#4caf50,#45a049);animation:1s ease-in-out infinite bounce}.call-icon-wrapper.connecting{background:linear-gradient(135deg,#2196f3,#1976d2)}.call-icon-wrapper.connected{background:linear-gradient(135deg,#4caf50,#45a049)}.call-pulse-animation{z-index:-1;background:#4caf504d;border-radius:50%;width:120px;height:120px;animation:1.5s ease-out infinite pulse;position:absolute}.call-connecting-animation{z-index:-1;border:3px solid #0000;border-top-color:#2196f3;border-radius:50%;width:100px;height:100px;animation:1s linear infinite spin;position:absolute}.call-info-group{flex-direction:column;flex:1;min-width:0;margin-right:8px;display:flex}.call-title{color:#fff;white-space:normal;text-overflow:clip;margin:0;font-size:16px;font-weight:700;line-height:1.2;overflow:visible}.call-subtitle{color:#ffffffb3;white-space:normal;text-overflow:clip;margin:4px 0 0;font-size:12px;line-height:1.35;overflow:visible}.call-timer{text-align:center;color:#fff;flex-shrink:0;min-width:54px;font-size:13px;font-weight:700}.call-actions{flex-shrink:0;align-items:center;gap:8px;display:flex}.call-actions.connected{justify-content:center;width:100%}.flowengage-call-btn{cursor:pointer;color:#fff;border:none;border-radius:8px;justify-content:center;align-items:center;gap:6px;min-width:92px;padding:8px 12px;font-size:12px;font-weight:600;line-height:1;transition:transform .2s,box-shadow .2s,background .2s;display:flex}.flowengage-call-btn svg{flex-shrink:0;display:block}.flowengage-call-btn span{justify-content:center;align-items:center;line-height:1;display:flex}.flowengage-call-btn.icon-only{border-radius:9999px;width:46px;min-width:46px;height:46px;padding:0}.flowengage-call-btn-accept{background:linear-gradient(135deg,#4caf50,#45a049);box-shadow:0 8px 24px #4caf5066}.flowengage-call-btn-reject,.flowengage-call-btn-end{background:linear-gradient(135deg,#f44336,#d32f2f);box-shadow:0 4px 12px #f4433666}.flowengage-call-btn-mute{background:#ffffff1a;border:2px solid #fff3}.flowengage-call-btn-mute.active{background:#f443364d;border-color:#f44336}.flowengage-call-btn:hover:not(:disabled){transform:scale(1.05)}.incoming-call-overlay.header-mode .flowengage-call-btn{border-radius:9999px!important;width:36px!important;min-width:36px!important;height:36px!important;padding:0!important}.incoming-call-overlay.header-mode .flowengage-call-btn span{display:none!important}.incoming-call-overlay.header-mode .call-icon-wrapper{width:40px;height:40px;margin-right:0}.incoming-call-overlay.header-mode .call-info-group{min-width:0}.incoming-call-overlay.header-mode .call-title,.incoming-call-overlay.header-mode .call-subtitle{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=640px){.incoming-call-container{align-items:flex-start;gap:10px;padding:12px 14px}.incoming-call-container.connected-layout{align-items:stretch}.call-connected-top{flex-direction:column;align-items:flex-start;gap:10px}.call-connected-identity{width:100%}.call-info-group{margin-right:0}.call-actions{flex-wrap:wrap;align-self:stretch;gap:6px}.call-actions.connected{justify-content:stretch}.call-actions.connected .flowengage-call-btn{flex:1}.flowengage-call-btn{min-width:78px;padding:8px 10px}}@keyframes slideUpBanner{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes slideDownBanner{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse{0%{opacity:1;transform:scale(.8)}to{opacity:0;transform:scale(2)}}@keyframes spin{to{transform:rotate(360deg)}}.fe-screen-fade-in{animation:.4s cubic-bezier(.16,1,.3,1) forwards feFadeIn}@keyframes feFadeIn{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.flowengage-initial-bg{background-color:#fff;position:relative;overflow:hidden}.flowengage-initial-bg:before{content:"";background:linear-gradient(to bottom, var(--flowengage-primary) 0%, var(--flowengage-accent) 55%, white 82%);opacity:0;pointer-events:none;z-index:0;transition:opacity .6s cubic-bezier(.4,0,.2,1);position:absolute;inset:0}.flowengage-initial-bg.is-initial:before{opacity:1}.flowengage-content-wrapper{z-index:1;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}`,vg=null,yg=!1;function bg(){let e=document.createElement(`div`);e.id=`flowengage-root`;let t=e.attachShadow({mode:`open`}),n=document.createElement(`style`);n.textContent=_g,t.appendChild(n);let r=document.createElement(`div`);return r.setAttribute(`data-flowengage-mount`,`true`),r.className=`flowengage-widget-root`,t.appendChild(r),{host:e,mount:r}}function xg(e){if(document.body){e();return}let t=new MutationObserver(()=>{document.body&&(t.disconnect(),e())});t.observe(document.documentElement,{childList:!0})}function Sg({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}){if(yg){console.warn(`[FlowEngage] Already initialized. Call FlowEngage.destroy() first to re-initialize.`);return}if(!e){console.error(`[FlowEngage] siteId is required. Pass it via data-site-id attribute or FlowEngage.init({ siteId: 'YOUR_SITE_ID' }).`);return}if(!document.body){console.error(`[FlowEngage] document.body is not available yet. The widget will auto-retry once the DOM is ready.`),xg(()=>Sg({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}));return}if(document.getElementById(`flowengage-root`)){console.warn(`[FlowEngage] #flowengage-root already exists. Skipping duplicate mount.`);return}let{host:i,mount:a}=bg();document.body.appendChild(i),vg=(0,x.createRoot)(a);let o={widgetSettings:n,...r&&{apiBaseUrl:r}};vg.render(b.createElement(gg,null,b.createElement(Lr,{siteId:e,language:t,config:o},b.createElement(hg)))),yg=!0}var Cg={init({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}={}){document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>xg(()=>Sg({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))):xg(()=>Sg({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))},destroy(){vg&&=(vg.unmount(),null);let e=document.getElementById(`flowengage-root`);e&&e.remove();let t=document.getElementById(`flowengage-styles`);t&&t.remove(),yg=!1}},wg=()=>{let e=document.currentScript;(!e||!e.getAttribute(`data-site-id`))&&(e=document.querySelector(`script[data-site-id]`));let t=e?.getAttribute(`data-site-id`);if(!t)return;let n=e?.getAttribute(`data-language`)||`en`,r=e?.getAttribute(`data-api-url`)||void 0,i={};try{let t=e?.getAttribute(`data-widget-settings`);t&&(i=JSON.parse(t))}catch{}let a={widgetSettings:i,...r&&{apiBaseUrl:r}};xg(()=>Sg({siteId:t,language:n,widgetSettings:a.widgetSettings,apiBaseUrl:r}))};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,wg):wg(),typeof window<`u`&&(window.FlowEngage=Cg),Cg})();
|
|
369
|
+
`})]})}var _g=class extends b.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){console.error(`[FlowEngage] Widget crashed:`,e,t.componentStack)}render(){return this.state.hasError?this.props.fallback??null:this.props.children}},vg=`@import "https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap";:host{all:initial;box-sizing:border-box!important;color:#111827!important;-webkit-font-smoothing:antialiased!important;z-index:2147483647!important;background:0 0!important;border:none!important;margin:0!important;padding:0!important;font-family:Poppins,system-ui,-apple-system,sans-serif!important;font-size:16px!important;line-height:1.5!important;display:block!important;position:relative!important}:host *,:host :before,:host :after{box-sizing:border-box}.flowengage-widget-root{-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility;color:#111827!important;-webkit-font-smoothing:antialiased!important;font-family:Poppins,system-ui,-apple-system,sans-serif!important;font-size:16px!important;line-height:1.5!important}.flowengage-widget-root *,.flowengage-widget-root :before,.flowengage-widget-root :after{font-family:inherit!important}.flowengage-widget-root input,.flowengage-widget-root textarea,.flowengage-widget-root button,.flowengage-widget-root select,.flowengage-widget-root optgroup,.flowengage-widget-root option{font-size:inherit;line-height:inherit;font-family:inherit!important}.flowengage-shell,.flowengage-shell *{font-family:inherit!important}.flowengage-chat-panel{border:none;border-radius:0;outline:none;flex-direction:column;width:100%;height:100%;display:flex;position:relative;overflow:hidden;box-shadow:0 20px 50px #00000026}.flowengage-chat-text-input{margin:0!important}.flowengage-chat-text-input:focus{box-shadow:none!important;border:none!important;outline:none!important}@media (width>=768px){.flowengage-chat-panel{border-radius:24px;width:min(350px,100vw - 40px);height:min(700px,100vh - 120px)}}.flowengage-shell[data-open=true]{inset:0}@media (width>=768px){.flowengage-shell[data-open=true]{inset:auto 1.5rem 1.5rem auto}}.flowengage-logo-fallback{background:conic-gradient(from 180deg, var(--flowengage-primary) 0%, var(--flowengage-accent) 45%, var(--flowengage-primary) 100%)}.fe-bot-message p{margin:0 0 .5em}.fe-bot-message p:last-child{margin-bottom:0}.fe-bot-message ul,.fe-bot-message ol{margin:.4em 0 .4em 1.2em;padding:0}.fe-bot-message li{margin-bottom:.25em}.fe-bot-message strong{font-weight:600}.fe-bot-message a{color:var(--flowengage-primary);text-decoration:underline}.fe-bot-message a:hover{opacity:.8}.incoming-call-overlay{z-index:1000;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);background:#1a1a2ef2;justify-content:center;align-items:center;transition:all .3s ease-in-out;display:flex;position:absolute;left:0;right:0}.incoming-call-overlay.bottom-mode{border-top:2px solid #ffffff1a;min-height:120px;animation:.4s cubic-bezier(.16,1,.3,1) slideUpBanner;top:auto;bottom:0;box-shadow:0 -10px 30px #00000080}.incoming-call-overlay.header-mode{border-bottom:2px solid #ffffff1a;min-height:80px;animation:.4s cubic-bezier(.16,1,.3,1) slideDownBanner;top:0;bottom:auto;box-shadow:0 10px 30px #00000080}.incoming-call-container{justify-content:space-between;align-items:center;gap:14px;width:100%;padding:14px 16px;display:flex}.incoming-call-container.connected-layout{flex-direction:column;justify-content:center;align-items:stretch;gap:14px}.call-connected-top{justify-content:space-between;align-items:center;gap:16px;width:100%;display:flex}.call-connected-identity{flex:1;align-items:center;gap:14px;min-width:0;display:flex}.call-icon-wrapper{color:#fff;z-index:1;border-radius:9999px;flex-shrink:0;justify-content:center;align-items:center;width:54px;height:54px;margin-right:4px;display:flex;position:relative}.call-icon-wrapper.incoming{background:linear-gradient(135deg,#4caf50,#45a049);animation:1s ease-in-out infinite bounce}.call-icon-wrapper.connecting{background:linear-gradient(135deg,#2196f3,#1976d2)}.call-icon-wrapper.connected{background:linear-gradient(135deg,#4caf50,#45a049)}.call-pulse-animation{z-index:-1;background:#4caf504d;border-radius:50%;width:120px;height:120px;animation:1.5s ease-out infinite pulse;position:absolute}.call-connecting-animation{z-index:-1;border:3px solid #0000;border-top-color:#2196f3;border-radius:50%;width:100px;height:100px;animation:1s linear infinite spin;position:absolute}.call-info-group{flex-direction:column;flex:1;min-width:0;margin-right:8px;display:flex}.call-title{color:#fff;white-space:normal;text-overflow:clip;margin:0;font-size:16px;font-weight:700;line-height:1.2;overflow:visible}.call-subtitle{color:#ffffffb3;white-space:normal;text-overflow:clip;margin:4px 0 0;font-size:12px;line-height:1.35;overflow:visible}.call-timer{text-align:center;color:#fff;flex-shrink:0;min-width:54px;font-size:13px;font-weight:700}.call-actions{flex-shrink:0;align-items:center;gap:8px;display:flex}.call-actions.connected{justify-content:center;width:100%}.flowengage-call-btn{cursor:pointer;color:#fff;border:none;border-radius:8px;justify-content:center;align-items:center;gap:6px;min-width:92px;padding:8px 12px;font-size:12px;font-weight:600;line-height:1;transition:transform .2s,box-shadow .2s,background .2s;display:flex}.flowengage-call-btn svg{flex-shrink:0;display:block}.flowengage-call-btn span{justify-content:center;align-items:center;line-height:1;display:flex}.flowengage-call-btn.icon-only{border-radius:9999px;width:46px;min-width:46px;height:46px;padding:0}.flowengage-call-btn-accept{background:linear-gradient(135deg,#4caf50,#45a049);box-shadow:0 8px 24px #4caf5066}.flowengage-call-btn-reject,.flowengage-call-btn-end{background:linear-gradient(135deg,#f44336,#d32f2f);box-shadow:0 4px 12px #f4433666}.flowengage-call-btn-mute{background:#ffffff1a;border:2px solid #fff3}.flowengage-call-btn-mute.active{background:#f443364d;border-color:#f44336}.flowengage-call-btn:hover:not(:disabled){transform:scale(1.05)}.incoming-call-overlay.header-mode .flowengage-call-btn{border-radius:9999px!important;width:36px!important;min-width:36px!important;height:36px!important;padding:0!important}.incoming-call-overlay.header-mode .flowengage-call-btn span{display:none!important}.incoming-call-overlay.header-mode .call-icon-wrapper{width:40px;height:40px;margin-right:0}.incoming-call-overlay.header-mode .call-info-group{min-width:0}.incoming-call-overlay.header-mode .call-title,.incoming-call-overlay.header-mode .call-subtitle{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=640px){.incoming-call-container{align-items:flex-start;gap:10px;padding:12px 14px}.incoming-call-container.connected-layout{align-items:stretch}.call-connected-top{flex-direction:column;align-items:flex-start;gap:10px}.call-connected-identity{width:100%}.call-info-group{margin-right:0}.call-actions{flex-wrap:wrap;align-self:stretch;gap:6px}.call-actions.connected{justify-content:stretch}.call-actions.connected .flowengage-call-btn{flex:1}.flowengage-call-btn{min-width:78px;padding:8px 10px}}@keyframes slideUpBanner{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes slideDownBanner{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes bounce{0%,to{transform:translateY(0)}50%{transform:translateY(-10px)}}@keyframes pulse{0%{opacity:1;transform:scale(.8)}to{opacity:0;transform:scale(2)}}@keyframes spin{to{transform:rotate(360deg)}}.fe-screen-fade-in{animation:.4s cubic-bezier(.16,1,.3,1) forwards feFadeIn}@keyframes feFadeIn{0%{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}.flowengage-initial-bg{background-color:#fff;position:relative;overflow:hidden}.flowengage-initial-bg:before{content:"";background:linear-gradient(to bottom, var(--flowengage-primary) 0%, var(--flowengage-accent) 55%, white 82%);opacity:0;pointer-events:none;z-index:0;transition:opacity .6s cubic-bezier(.4,0,.2,1);position:absolute;inset:0}.flowengage-initial-bg.is-initial:before{opacity:1}.flowengage-content-wrapper{z-index:1;flex-direction:column;flex:1;min-height:0;display:flex;position:relative}`,yg=null,bg=!1;function xg(){let e=document.createElement(`div`);e.id=`flowengage-root`;let t=e.attachShadow({mode:`open`}),n=document.createElement(`style`);n.textContent=vg,t.appendChild(n);let r=document.createElement(`div`);return r.setAttribute(`data-flowengage-mount`,`true`),r.className=`flowengage-widget-root`,t.appendChild(r),{host:e,mount:r}}function Sg(e){if(document.body){e();return}let t=new MutationObserver(()=>{document.body&&(t.disconnect(),e())});t.observe(document.documentElement,{childList:!0})}function Cg({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}){if(bg){console.warn(`[FlowEngage] Already initialized. Call FlowEngage.destroy() first to re-initialize.`);return}if(!e){console.error(`[FlowEngage] siteId is required. Pass it via data-site-id attribute or FlowEngage.init({ siteId: 'YOUR_SITE_ID' }).`);return}if(!document.body){console.error(`[FlowEngage] document.body is not available yet. The widget will auto-retry once the DOM is ready.`),Sg(()=>Cg({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}));return}if(document.getElementById(`flowengage-root`)){console.warn(`[FlowEngage] #flowengage-root already exists. Skipping duplicate mount.`);return}let{host:i,mount:a}=xg();document.body.appendChild(i),yg=(0,x.createRoot)(a);let o={widgetSettings:n,...r&&{apiBaseUrl:r}};yg.render(b.createElement(_g,null,b.createElement(Lr,{siteId:e,language:t,config:o},b.createElement(gg)))),bg=!0}var wg={init({siteId:e,language:t=`en`,widgetSettings:n={},apiBaseUrl:r}={}){document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>Sg(()=>Cg({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))):Sg(()=>Cg({siteId:e,language:t,widgetSettings:n,apiBaseUrl:r}))},destroy(){yg&&=(yg.unmount(),null);let e=document.getElementById(`flowengage-root`);e&&e.remove();let t=document.getElementById(`flowengage-styles`);t&&t.remove(),bg=!1}},Tg=()=>{let e=document.currentScript;(!e||!e.getAttribute(`data-site-id`))&&(e=document.querySelector(`script[data-site-id]`));let t=e?.getAttribute(`data-site-id`);if(!t)return;let n=e?.getAttribute(`data-language`)||`en`,r=e?.getAttribute(`data-api-url`)||void 0,i={};try{let t=e?.getAttribute(`data-widget-settings`);t&&(i=JSON.parse(t))}catch{}let a={widgetSettings:i,...r&&{apiBaseUrl:r}};Sg(()=>Cg({siteId:t,language:n,widgetSettings:a.widgetSettings,apiBaseUrl:r}))};return document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Tg):Tg(),typeof window<`u`&&(window.FlowEngage=wg),wg})();
|