@flowengage/react-chatbot 8.0.36 → 8.0.51

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.
@@ -1,4 +1,4 @@
1
- "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),u=e=>a.call(e,`module.exports`)?e[`module.exports`]:c(t({},`__esModule`,{value:!0}),e);let d=require(`react`);d=l(d);let f=require(`react/jsx-runtime`);var p=e=>{if(!e||typeof e!=`object`)throw Error(`FlowEngage config is required`);if(!e.siteId||typeof e.siteId!=`string`)throw Error(`[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId="your-site-id" /> or config={{ siteId: 'your-site-id' }}.`);let t=(e.apiBaseUrl||`http://localhost:5008`).replace(/\/+$/,``);return{siteId:e.siteId.trim(),apiBaseUrl:t}},m=(e,t)=>{let n=Number.parseInt(String(e??``),10);return Number.isFinite(n)&&n>0?n:t},h=m(void 0,1e4),g=m(void 0,15e3),_={chatId:`flowengage.chatId`,isOpen:`flowengage.isOpen`,activeScreen:`flowengage.activeScreen`,isHumanHandled:`flowengage.isHumanHandled`,agentName:`flowengage.agentName`,agentHeadshot:`flowengage.agentHeadshot`,visitorEmail:`flowengage.visitorEmail`},v=6e4,y=480*60,b=3e4,x=typeof window<`u`,S=e=>e?`flowengage.visitorEmail.${e}`:null,C=()=>{if(!x)return null;let e=window.localStorage.getItem(_.chatId);return e&&String(e).trim()?String(e).trim():null},w=()=>{if(x)try{window.localStorage.removeItem(_.chatId)}catch{}},T=()=>x?typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`:`server-chat-id`,E=e=>e?`flowengage.entrySeen.${e}`:null,ee=e=>{if(!x||!e)return!1;try{let t=E(e);return t?window.localStorage.getItem(t)===`1`:!1}catch{return!1}},D=e=>{if(!(!x||!e))try{let t=E(e);t&&window.localStorage.setItem(t,`1`)}catch{}},O=e=>e?`flowengage.persistedChatId.${e}`:null,te=e=>{if(!x||!e)return null;try{let t=O(e),n=t?window.localStorage.getItem(t):null;return n&&String(n).trim()?String(n).trim():null}catch{return null}},ne=e=>{if(!(!x||!e))try{let t=O(e);t&&window.localStorage.removeItem(t)}catch{}},re=(e,t)=>{if(!(!x||!e||!t))try{let n=O(e);n&&window.localStorage.setItem(n,String(t).trim())}catch{}},ie=()=>x?{isOpen:!1,activeScreen:window.sessionStorage.getItem(_.activeScreen)||`ai`,isHumanHandled:window.sessionStorage.getItem(_.isHumanHandled)===`true`,agentName:window.sessionStorage.getItem(_.agentName),agentHeadshot:window.sessionStorage.getItem(_.agentHeadshot),visitorEmail:``}:{isOpen:!1,activeScreen:`ai`,isHumanHandled:!1,agentName:null,agentHeadshot:null,visitorEmail:``},ae=e=>{x&&Object.entries(e).forEach(([e,t])=>{let n=_[e];if(n){if(t==null||t===!1){window.sessionStorage.removeItem(n);return}window.sessionStorage.setItem(n,String(t))}})},oe=e=>{if(!x||!e)return``;let t=S(e),n=window.localStorage.getItem(t);if(!n){let e=window.sessionStorage.getItem(_.visitorEmail);e&&(window.localStorage.setItem(t,e),window.sessionStorage.removeItem(_.visitorEmail),n=e)}return n||``},se=(e,t)=>{if(!x)return;let n=S(t);if(!n)return;let r=typeof e==`string`?e.trim():``;if(!r){window.localStorage.removeItem(n),window.sessionStorage.removeItem(_.visitorEmail);return}window.localStorage.setItem(n,r),window.sessionStorage.removeItem(_.visitorEmail)},k=e=>e?`flowengage.visitorId.${e}`:null,ce=()=>`v_${Date.now().toString(36)}_${typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,``).slice(0,16):Math.random().toString(36).slice(2,18)}`,le=e=>{if(!x||!e)return null;try{let t=k(e),n=t?window.localStorage.getItem(t):null;return n&&String(n).trim()?String(n).trim():null}catch{return null}},ue=e=>{if(!x||!e)return null;try{let t=le(e);if(t)return t;let n=ce(),r=k(e);return r&&window.localStorage.setItem(r,n),n}catch{return ce()}},A=`flowengage.tabId`,de=()=>{if(!x)return`default`;try{let e=window.sessionStorage.getItem(A);return e||(e=typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,``).slice(0,12):Math.random().toString(36).slice(2,14),window.sessionStorage.setItem(A,e)),e}catch{return`default`}},j=e=>e?`flowengage.voice.transcript.${e}.${de()}`:null,fe=600*1e3,pe=(e,t,n={})=>{if(!x||!e)return;let r=typeof t==`string`?t.trim():``;if(!r)return;let i=Number.isFinite(n.ttlMs)?n.ttlMs:fe,a={transcript:r,expiresAt:Date.now()+i};try{let t=j(e);t&&window.localStorage.setItem(t,JSON.stringify(a))}catch{}},me=e=>{if(!x||!e)return null;try{let t=j(e),n=t?window.localStorage.getItem(t):null;if(!n)return null;let r=JSON.parse(n);return!r||typeof r.transcript!=`string`?null:Number.isFinite(r.expiresAt)&&Date.now()>r.expiresAt?(window.localStorage.removeItem(t),null):r}catch{return null}},he=e=>{if(!(!x||!e))try{let t=j(e);t&&window.localStorage.removeItem(t)}catch{}},ge=`flowengage.voice.pendingResume`,_e=()=>{if(x)try{window.sessionStorage.setItem(ge,`1`)}catch{}},ve=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(ge)===`1`?(window.sessionStorage.removeItem(ge),!0):!1}catch{return!1}},ye=`flowengage.chat.pendingReopen`,be=()=>{if(x)try{window.sessionStorage.setItem(ye,`1`)}catch{}},xe=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(ye)===`1`?(window.sessionStorage.removeItem(ye),!0):!1}catch{return!1}},Se=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(ge)===`1`}catch{return!1}},M=e=>e?`flowengage.voice.navState.${e}.${de()}`:null,N=(e,t,n,r)=>{if(!(!x||!e||!t))try{let i=M(e);i&&window.sessionStorage.setItem(i,JSON.stringify({previousPage:String(t),targetPath:n?new URL(String(n),window.location.href).pathname:null,pageName:r||null,ts:Date.now()}))}catch{}},Ce=e=>{if(!x||!e)return null;try{let t=M(e);if(!t)return null;let n=window.sessionStorage.getItem(t);if(!n)return null;window.sessionStorage.removeItem(t);let r=JSON.parse(n);return!r||typeof r.previousPage!=`string`||Number.isFinite(r.ts)&&Date.now()-r.ts>6e4||r.targetPath&&(window.location.pathname.replace(/\/$/,``)||`/`)!==(r.targetPath.replace(/\/$/,``)||`/`)?null:{previousPage:r.previousPage,pageName:r.pageName||null}}catch{return null}},we=async e=>{let t=await e.json().catch(()=>({}));if(!e.ok){let n=Error(t.message||t.error||`Request failed with status ${e.status}`);throw n.status=e.status,n}return t},P=async(e,t={})=>{try{return await fetch(e,{mode:`cors`,...t})}catch(t){let n=Error(`Network error reaching ${e}. Check: (1) backend is running, (2) CORS allows this origin, (3) siteId is correct. Original: ${t.message}`);throw n.status=0,n.cause=t,n}},F=async({apiBaseUrl:e,userId:t,siteId:n,priorChatId:r=null,forceNew:i=!1,resumeChatId:a=null,visitorId:o=null})=>{let s=`${e}/api/visitors/resolve-session`,c={siteId:n};return r&&String(r).trim()&&(c.priorChatId=String(r).trim()),i&&(c.forceNew=!0),a&&(c.resumeChatId=a),o&&(c.visitorId=o),we(await P(s,{method:`POST`,mode:`cors`,headers:{"Content-Type":`application/json`,"x-user-id":t==null?``:String(t),...n?{"x-site-id":n}:{},...o?{"x-visitor-id":o}:{}},body:JSON.stringify(c)}))},Te=async({apiBaseUrl:e,siteId:t})=>{let n=typeof window<`u`?window.location.origin:`http://localhost`;return(await we(await P(`${e}/api/widget/chatbot-loader?${new URLSearchParams({siteId:t,origin:n}).toString()}`,{method:`GET`}))).data},Ee=({apiBaseUrl:e,userId:t,siteId:n,visitorId:r=null})=>{let i=(t,n)=>{let r=`${e}${t}`,i=JSON.stringify(n);if(typeof navigator<`u`&&navigator.sendBeacon)try{let e=new Blob([i],{type:`application/json`});return navigator.sendBeacon(r,e)}catch{}return typeof fetch<`u`?(fetch(r,{method:`POST`,mode:`cors`,keepalive:!0,headers:{"Content-Type":`application/json`},body:i}).catch(()=>{}),!0):!1},a=async(i,a={})=>we(await P(`${e}${i}`,{...a,headers:{"Content-Type":`application/json`,"x-user-id":t,...n?{"x-site-id":n}:{},...r?{"x-visitor-id":r}:{},...a.headers||{}}})),o=async(r,i,a={})=>{let o={"x-user-id":t,...n?{"x-site-id":n}:{},...a.headers||{}};return we(await P(`${e}${r}`,{...a,body:i,headers:o}))};return{async loadHistory(e,t=`en`,n=``){return a(`/api/ai/chat`,{method:`POST`,body:JSON.stringify({session_id:e,user_query:``,lang:t,category:n})})},async sendAiMessage(e,t,n=`en`,r=``,i=null,o={}){return a(`/api/ai/chat`,{method:`POST`,body:JSON.stringify({session_id:e,user_query:t,lang:n,category:r,...o||{},...i||{}})})},async uploadChatFile(e){let t=new FormData;return t.append(`file`,e),o(`/api/upload`,t,{method:`POST`})},async checkHumanHandled(e){return a(`/api/ai/check_human_handled`,{method:`POST`,body:JSON.stringify({session_id:e})})},async setChatMode(e,t){return a(`/api/ai/set_chat_mode`,{method:`POST`,body:JSON.stringify({session_id:e,mode:t})})},async toggleVoice(e){return a(`/api/ai/voice/toggle`,{method:`POST`,body:JSON.stringify({session_id:e})})},async syncVoice(e,r){return a(`/api/ai/voice/sync`,{method:`POST`,body:JSON.stringify({session_id:e,messages:r,...t?{userId:String(t)}:{},...n?{siteId:String(n)}:{}})})},async trackVisitor(e){return a(`/api/visitors/track`,{method:`POST`,body:JSON.stringify(e)})},async updateChatStatus(e,t){return a(`/api/chat/status`,{method:`POST`,body:JSON.stringify({chatId:e,type:t})})},async startConversation(e,t=`en`){return a(`/api/chat/status`,{method:`POST`,body:JSON.stringify({chatId:e,type:`open`,lang:t})})},async endConversation(e){return a(`/api/chat/status`,{method:`POST`,body:JSON.stringify({chatId:e,type:`closed`})})},async getVisitorChatHistory(){return a(`/api/visitors/my-chats`,{method:`GET`})},async getVisitorChatThread(e){return a(`/api/visitors/my-chats/${e}`,{method:`GET`})},async acceptCall(e,t){return a(`/api/calls/${e}/accept`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n})})},async rejectCall(e,t){return a(`/api/calls/${e}/reject`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n})})},async getIceServersConfig(){return we(await P(`${e}/api/calls/ice-config`,{method:`GET`,headers:{"x-user-id":t,...n?{"x-site-id":n}:{}}}))},async endWebRTCCall(e,t){return a(`/api/calls/${e}/end`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n,endedBy:`customer`})})},async markCustomerUnavailable(e,t){return a(`/api/calls/${e}/customer-unavailable`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n})})},async uploadRecording(e,t,n){let r=new FormData,i=`call-rec-${Date.now()}.webm`;return r.append(`audio`,t,i),r.append(`duration`,String(n)),o(`/api/calls/${e}/recording`,r,{method:`POST`})},beaconEndWebRTCCall(e,t){return i(`/api/calls/${e}/end`,{session_id:t,site_id:n,endedBy:`customer`})},beaconCustomerUnavailable(e,t){return i(`/api/calls/${e}/customer-unavailable`,{session_id:t,site_id:n})},beaconSyncVoice(r,i){if(typeof navigator>`u`||!navigator.sendBeacon)return!1;let a=new URLSearchParams;return a.append(`session_id`,r),a.append(`messages`,JSON.stringify(i)),t&&a.append(`userId`,String(t)),n&&a.append(`siteId`,String(n)),navigator.sendBeacon(`${e}/api/ai/voice/sync`,a)},beaconWidgetClosed(r){if(typeof navigator>`u`||!navigator.sendBeacon)return!1;let i=new URLSearchParams;return i.append(`chatId`,r),i.append(`type`,`widget_closed`),t&&i.append(`userId`,String(t)),n&&i.append(`siteId`,String(n)),navigator.sendBeacon(`${e}/api/chat/status`,i)}}},I=Object.create(null);I.open=`0`,I.close=`1`,I.ping=`2`,I.pong=`3`,I.message=`4`,I.upgrade=`5`,I.noop=`6`;var De=Object.create(null);Object.keys(I).forEach(e=>{De[I[e]]=e});var Oe={type:`error`,data:`parser error`},ke=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,Ae=typeof ArrayBuffer==`function`,je=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Me=({type:e,data:t},n,r)=>ke&&t instanceof Blob?n?r(t):Ne(t,r):Ae&&(t instanceof ArrayBuffer||je(t))?n?r(t):Ne(new Blob([t]),r):r(I[e]+(t||``)),Ne=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Pe(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var L;function Fe(e,t){if(ke&&e.data instanceof Blob)return e.data.arrayBuffer().then(Pe).then(t);if(Ae&&(e.data instanceof ArrayBuffer||je(e.data)))return t(Pe(e.data));Me(e,!1,e=>{L||=new TextEncoder,t(L.encode(e))})}var Ie=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Le=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)Le[Ie.charCodeAt(e)]=e;var Re=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=Le[e.charCodeAt(r)],o=Le[e.charCodeAt(r+1)],s=Le[e.charCodeAt(r+2)],c=Le[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},ze=typeof ArrayBuffer==`function`,Be=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:He(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:Ve(e.substring(1),t)}:De[n]?e.length>1?{type:De[n],data:e.substring(1)}:{type:De[n]}:Oe},Ve=(e,t)=>ze?He(Re(e),t):{base64:!0,data:e},He=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},Ue=``,We=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{Me(e,!1,e=>{r[a]=e,++i===n&&t(r.join(Ue))})})},Ge=(e,t)=>{let n=e.split(Ue),r=[];for(let e=0;e<n.length;e++){let i=Be(n[e],t);if(r.push(i),i.type===`error`)break}return r};function Ke(){return new TransformStream({transform(e,t){Fe(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var qe;function R(e){return e.reduce((e,t)=>e+t.length,0)}function z(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function Je(e,t){qe||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(R(n)<1)break;let e=z(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(R(n)<2)break;let e=z(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(R(n)<8)break;let e=z(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Oe);break}i=a*2**32+t.getUint32(4),r=3}else{if(R(n)<i)break;let e=z(n,i);s.enqueue(Be(a?e:qe.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Oe);break}}}})}function B(e){if(e)return Ye(e)}function Ye(e){for(var t in B.prototype)e[t]=B.prototype[t];return e}B.prototype.on=B.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},B.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},B.prototype.off=B.prototype.removeListener=B.prototype.removeAllListeners=B.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},B.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},B.prototype.emitReserved=B.prototype.emit,B.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},B.prototype.hasListeners=function(e){return!!this.listeners(e).length};var V=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),H=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),Xe=`arraybuffer`;function Ze(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var Qe=H.setTimeout,$e=H.clearTimeout;function et(e,t){t.useNativeTimers?(e.setTimeoutFn=Qe.bind(H),e.clearTimeoutFn=$e.bind(H)):(e.setTimeoutFn=H.setTimeout.bind(H),e.clearTimeoutFn=H.clearTimeout.bind(H))}var tt=1.33;function nt(e){return typeof e==`string`?rt(e):Math.ceil((e.byteLength||e.size)*tt)}function rt(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function it(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function at(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function ot(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var st=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},ct=class extends B{constructor(e){super(),this.writable=!1,et(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new st(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=Be(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=at(e);return t.length?`?`+t:``}},lt=class extends ct{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){Ge(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,We(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=it()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},ut=!1;try{ut=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var dt=ut;function ft(){}var pt=class extends lt{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},mt=class e extends B{constructor(e,t,n){super(),this.createRequest=e,et(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=Ze(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=ft,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(mt.requestsCount=0,mt.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,ht);else if(typeof addEventListener==`function`){let e=`onpagehide`in H?`pagehide`:`unload`;addEventListener(e,ht,!1)}}function ht(){for(let e in mt.requests)mt.requests.hasOwnProperty(e)&&mt.requests[e].abort()}var gt=(function(){let e=vt({xdomain:!1});return e&&e.responseType!==null})(),_t=class extends pt{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=gt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new mt(vt,this.uri(),e)}};function vt(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||dt))return new XMLHttpRequest}catch{}if(!t)try{return new H[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var yt=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,bt=class extends ct{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=yt?{}:Ze(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;Me(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&V(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=it()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},xt=H.WebSocket||H.MozWebSocket,St={websocket:class extends bt{createSocket(e,t,n){return yt?new xt(e,t,n):t?new xt(e,t):new xt(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends ct{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=Je(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=Ke();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&V(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:_t},Ct=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,wt=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function Tt(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=Ct.exec(e||``),a={},o=14;for(;o--;)a[wt[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Et(a,a.path),a.queryKey=Dt(a,a.query),a}function Et(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function Dt(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var Ot=typeof addEventListener==`function`&&typeof removeEventListener==`function`,kt=[];Ot&&addEventListener(`offline`,()=>{kt.forEach(e=>e())},!1);var At=class e extends B{constructor(e,t){if(super(),this.binaryType=Xe,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=Tt(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=Tt(t.host).host);et(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=ot(this.opts.query)),Ot&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},kt.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=nt(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,V(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),Ot&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=kt.indexOf(this._offlineEventListener);e!==-1&&kt.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};At.protocol=4;var jt=class extends At{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;At.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;At.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},Mt=class extends jt{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>St[e]).filter(e=>!!e)),super(e,n)}};Mt.protocol;function Nt(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=Tt(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var Pt=typeof ArrayBuffer==`function`,Ft=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,It=Object.prototype.toString,Lt=typeof Blob==`function`||typeof Blob<`u`&&It.call(Blob)===`[object BlobConstructor]`,Rt=typeof File==`function`||typeof File<`u`&&It.call(File)===`[object FileConstructor]`;function zt(e){return Pt&&(e instanceof ArrayBuffer||Ft(e))||Lt&&e instanceof Blob||Rt&&e instanceof File}function Bt(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(Bt(e[t]))return!0;return!1}if(zt(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return Bt(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&Bt(e[t]))return!0;return!1}function Vt(e){let t=[],n=e.data,r=e;return r.data=Ht(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Ht(e,t){if(!e)return e;if(zt(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=Ht(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Ht(e[r],t));return n}return e}function Ut(e,t){return e.data=Wt(e.data,t),delete e.attachments,e}function Wt(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Wt(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Wt(e[n],t));return e}var Gt=s({Decoder:()=>Jt,Encoder:()=>qt,PacketType:()=>U,isPacketValid:()=>tn,protocol:()=>5}),Kt=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],U;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(U||={});var qt=class{constructor(e){this.replacer=e}encode(e){return(e.type===U.EVENT||e.type===U.ACK)&&Bt(e)?this.encodeAsBinary({type:e.type===U.EVENT?U.BINARY_EVENT:U.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===U.BINARY_EVENT||e.type===U.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Vt(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},Jt=class e extends B{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===U.BINARY_EVENT;n||t.type===U.BINARY_ACK?(t.type=n?U.EVENT:U.ACK,this.reconstructor=new Yt(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(zt(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(U[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===U.BINARY_EVENT||r.type===U.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!Zt(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case U.CONNECT:return $t(t);case U.DISCONNECT:return t===void 0;case U.CONNECT_ERROR:return typeof t==`string`||$t(t);case U.EVENT:case U.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&Kt.indexOf(t[0])===-1);case U.ACK:case U.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},Yt=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=Ut(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Xt(e){return typeof e==`string`}var Zt=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function Qt(e){return e===void 0||Zt(e)}function $t(e){return Object.prototype.toString.call(e)===`[object Object]`}function en(e,t){switch(e){case U.CONNECT:return t===void 0||$t(t);case U.DISCONNECT:return t===void 0;case U.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&Kt.indexOf(t[0])===-1);case U.ACK:return Array.isArray(t);case U.CONNECT_ERROR:return typeof t==`string`||$t(t);default:return!1}}function tn(e){return Xt(e.nsp)&&Qt(e.id)&&en(e.type,e.data)}function nn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var rn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),an=class extends B{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[nn(e,`open`,this.onopen.bind(this)),nn(e,`packet`,this.onpacket.bind(this)),nn(e,`error`,this.onerror.bind(this)),nn(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(rn.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:U.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:U.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case U.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case U.EVENT:case U.BINARY_EVENT:this.onevent(e);break;case U.ACK:case U.BINARY_ACK:this.onack(e);break;case U.DISCONNECT:this.ondisconnect();break;case U.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:U.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:U.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function on(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}on.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},on.prototype.reset=function(){this.attempts=0},on.prototype.setMin=function(e){this.ms=e},on.prototype.setMax=function(e){this.max=e},on.prototype.setJitter=function(e){this.jitter=e};var sn=class extends B{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,et(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new on({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||Gt;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new Mt(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=nn(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=nn(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(nn(e,`ping`,this.onping.bind(this)),nn(e,`data`,this.ondata.bind(this)),nn(e,`error`,this.onerror.bind(this)),nn(e,`close`,this.onclose.bind(this)),nn(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){V(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new an(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},cn={};function ln(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=Nt(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=cn[i]&&a in cn[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new sn(r,t):(cn[i]||(cn[i]=new sn(r,t)),c=cn[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(ln,{Manager:sn,Socket:an,io:ln,connect:ln});var un=({apiBaseUrl:e,userId:t,chatId:n,siteId:r})=>ln(e,{transports:[`polling`,`websocket`],upgrade:!0,rememberUpgrade:!1,auth:{userId:t,chatId:n,siteId:r},query:{chatId:n,siteId:r}}),dn=({socket:e,chatId:t})=>{if(!e||!t||typeof window>`u`)return()=>{};let n=window.location.pathname+window.location.search,r=Date.now(),i=null,a=null,o=()=>{console.log(`[FlowEngageTracking] visitor:session_start`,{chatId:t,path:n}),e.emit(`visitor:session_start`,{chatId:t,path:n,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,timestamp:Date.now()})},s=()=>{console.log(`[FlowEngageTracking] visitor:page_enter`,{chatId:t,path:n}),e.emit(`visitor:page_enter`,{chatId:t,path:n,title:document.title,timestamp:Date.now()})},c=(n,r)=>{console.log(`[FlowEngageTracking] visitor:page_leave`,{chatId:t,path:n,duration:Math.max(0,Math.floor((Date.now()-r)/1e3))}),e.emit(`visitor:page_leave`,{chatId:t,path:n,duration:Math.max(0,Math.floor((Date.now()-r)/1e3)),timestamp:Date.now()})},l=()=>{console.log(`[FlowEngageTracking] visitor:heartbeat`,{chatId:t,path:n}),e.emit(`visitor:heartbeat`,{chatId:t,path:n,title:document.title,timestamp:Date.now()})},u=()=>{i&&window.clearInterval(i),i=window.setInterval(l,h)},d=()=>{i&&=(window.clearInterval(i),null)},f=r=>{console.log(`[FlowEngageTracking] visitor:visibility`,{chatId:t,state:r}),e.emit(`visitor:visibility`,{chatId:t,state:r,path:n,title:document.title,timestamp:Date.now()})},p=()=>{if(document.hidden){a&&window.clearTimeout(a),a=window.setTimeout(()=>{a=null,d(),f(`hidden`)},g);return}a&&=(window.clearTimeout(a),null),f(`visible`),l(),u()},m=()=>{let e=window.location.pathname+window.location.search;if(e===n){console.log(`[FlowEngageTracking] route unchanged`,{currentPath:n});return}console.log(`[FlowEngageTracking] route changed`,{from:n,to:e}),c(n,r),n=e,r=Date.now(),s()},_=window.history.pushState.bind(window.history),v=window.history.replaceState.bind(window.history);window.history.pushState=(...e)=>{_(...e),m()},window.history.replaceState=(...e)=>{v(...e),m()};let y=()=>{c(n,r),e.emit(`visitor:session_end`,{chatId:t,timestamp:Date.now()})},b=()=>{y()},x=e=>{e.persisted||y()};return window.addEventListener(`popstate`,m),window.addEventListener(`hashchange`,m),window.addEventListener(`beforeunload`,b),window.addEventListener(`pagehide`,x),window.addEventListener(`visibilitychange`,p),o(),document.hidden?a=window.setTimeout(()=>{a=null,d(),f(`hidden`)},g):(l(),u()),{notifyRouteChange:m,cleanup:()=>{a&&=(window.clearTimeout(a),null),d(),window.history.pushState=_,window.history.replaceState=v,window.removeEventListener(`popstate`,m),window.removeEventListener(`hashchange`,m),window.removeEventListener(`beforeunload`,b),window.removeEventListener(`pagehide`,x),window.removeEventListener(`visibilitychange`,p)}}},fn=(0,d.createContext)(null),pn=()=>{let e=(0,d.useContext)(fn);if(!e)throw Error(`useFlowEngage must be used inside FlowEngageProvider`);return e};function mn(){if(typeof window>`u`)return!1;try{let e=window.localStorage?.getItem(`FE_DEBUG_VOICE`);if(e===`0`||e===`false`)return!1;if(e===`1`||e===`true`)return!0}catch{}return window.__FE_DEBUG_VOICE_TOOLS__===!1?!1:window.__FE_DEBUG_VOICE_TOOLS__===!0}var hn=80;function gn(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=hn+(window.innerHeight-hn)/2,i=window.pageYOffset+n-r;window.scrollTo({top:Math.max(0,i),behavior:`smooth`})})}function _n(e){e&&(e.hasAttribute(`data-fe-highlighted`)||(vn(),e.classList?.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`),gn(e),e.setAttribute(`data-fe-orig-style`,e.style.cssText),e.setAttribute(`data-fe-highlighted`,`true`),e.style.outline=`3px solid #2563eb`,e.style.outlineOffset=`8px`,e.style.background=`rgba(37, 99, 235, 0.08)`,e.style.borderRadius=`8px`,e.style.padding=`12px 16px`,e.style.transition=`all 0.4s ease`))}function vn(){let e=document.querySelector(`[data-fe-highlighted]`);e&&(e.style.cssText=e.getAttribute(`data-fe-orig-style`)||``,e.removeAttribute(`data-fe-highlighted`),e.removeAttribute(`data-fe-orig-style`))}var yn=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`;function bn(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(yn)}catch{return!1}}function xn(e){let t=e.cloneNode(!0);return t.querySelectorAll(`[aria-hidden], svg, .icon, [class*="icon"]`).forEach(e=>e.remove()),t.textContent.replace(/\s+/g,` `).trim()}function W(...e){mn()&&console.log(`[FlowEngage:shadowNavigate]`,...e)}var Sn=`fe_pending_nav_section`,Cn=15e3,wn=`fe_voice_nav_state`,Tn=2e4,En=!1,Dn=null;function On(e=3e3){En=!0,Dn&&clearTimeout(Dn),Dn=setTimeout(()=>{En=!1,Dn=null},e)}function kn(){return En}var An=!1,jn=null;function Mn(){An||typeof window>`u`||(An=!0,window.addEventListener(`popstate`,async()=>{let e=window.location.href;if(W(`popstate: body-swap to`,e),jn){try{Vn(jn)}catch{}try{Wn(jn)}catch{}}try{if(await ar(e,{skipPushState:!0,isBack:!0})){W(`popstate: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] popstate body-swap error:`,e)}W(`popstate: body-swap failed, falling back to reload`),window.location.reload()}))}var Nn=!1;function Pn(){Nn||typeof window>`u`||typeof document>`u`||(Nn=!0,document.addEventListener(`click`,async e=>{try{if(!window.history.state?.flowengageSpa)return}catch{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)){e.preventDefault(),e.stopPropagation(),W(`link-intercept: body-swap to`,r.href),Jn();try{try{Vn()}catch{}try{Wn()}catch{}if(await ar(r.href)){W(`link-intercept: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] link-intercept body-swap error:`,e)}W(`link-intercept: body-swap failed, falling back to normal navigation`),Yn(),window.location.href=r.href}},!0))}var Fn=null;function In(e){Fn=e===`spa`||e===`traditional`?e:null}function Ln(){if(typeof window>`u`||Fn===`traditional`)return null;if(window.next?.router||window.__NEXT_ROUTER__)return`nextjs`;if(window.__remixRouter||window.__staticRouterHydrationData)return`react-router`;if(window.___gatsby||window.___navigate)return`gatsby`;if(window.__VUE_ROUTER__)return`vue-router`;if(window.__NUXT__||window.$nuxt)return`nuxt`;if(window.ng?.getComponent||document.querySelector(`[ng-version]`))return`angular`;if(window[Symbol.for(`wouter_v3`)])return`wouter`;if(window.__sveltekit_data||document.querySelector(`[data-sveltekit-hydrate]`))return`sveltekit`;if(document.querySelector(`[data-astro-transition]`))return`astro`;for(let e of document.body.children)if(e.tagName?.toUpperCase()===`DIV`&&e.id!==`flowengage-root`&&(e.id===`root`||e.id===`app`)&&e.children.length>0)return`generic-spa`;return Fn===`spa`?`backend-spa`:null}var Rn=`data-fe-swap-css`;function zn(){typeof document>`u`||document.querySelectorAll(`[${Rn}]`).forEach(e=>e.remove())}var Bn=`fe_form_state:`;function Vn(e){if(typeof document>`u`||typeof sessionStorage>`u`)return;let t=document.querySelectorAll(`form`);if(!t.length)return;let n=[];if(t.forEach((e,t)=>{let r={};e.querySelectorAll(`input, textarea, select`).forEach(e=>{let t=e.name||e.id;t&&(e.type===`password`||e.type===`hidden`||(e.type===`checkbox`||e.type===`radio`?r[t+`::`+e.value]=e.checked:r[t]=e.value))}),Object.keys(r).length&&n.push({formIndex:t,fields:r})}),n.length)try{let t=Bn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({state:n,ts:Date.now()}))}catch{}}function Hn(){if(typeof document>`u`||typeof sessionStorage>`u`)return;let e=Bn+window.location.pathname,t;try{t=JSON.parse(sessionStorage.getItem(e)||`null`)}catch{return}if(!t||!t.state)return;if(Date.now()-t.ts>1800*1e3){try{sessionStorage.removeItem(e)}catch{}return}let n=document.querySelectorAll(`form`);for(let{formIndex:e,fields:r}of t.state){let t=n[e];if(t)for(let[e,n]of Object.entries(r))if(e.includes(`::`)){let[r,i]=e.split(`::`),a=t.querySelector(`input[name="${r}"][value="${i}"], input[id="${r}"][value="${i}"]`);a&&(a.checked=!!n)}else{let r=t.querySelector(`[name="${e}"], [id="${e}"]`);if(r&&r.type!==`file`){r.value=n;try{r.dispatchEvent(new Event(`input`,{bubbles:!0}))}catch{}try{r.dispatchEvent(new Event(`change`,{bubbles:!0}))}catch{}}}}try{sessionStorage.removeItem(e)}catch{}}var Un=`fe_scroll:`;function Wn(e){if(!(typeof window>`u`||typeof sessionStorage>`u`))try{let t=Un+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({y:window.scrollY,ts:Date.now()}))}catch{}}function Gn(){if(typeof window>`u`||typeof sessionStorage>`u`)return;let e=Un+window.location.pathname,t;try{t=JSON.parse(sessionStorage.getItem(e)||`null`)}catch{return}if(t){try{sessionStorage.removeItem(e)}catch{}Date.now()-t.ts>1800*1e3||setTimeout(()=>{window.scrollTo({top:t.y,behavior:`instant`})},80)}}function Kn(e){if(!(typeof window>`u`))try{window.dispatchEvent(new CustomEvent(`flowengage:pageswap`,{detail:{url:e,timestamp:Date.now()}}))}catch{}}var qn=`fe-nav-loader`;function Jn(){if(typeof document>`u`||document.getElementById(qn))return;let e=document.createElement(`div`);e.id=qn,e.style.cssText=[`position:fixed`,`top:0`,`left:0`,`width:0`,`height:3px`,`background:linear-gradient(90deg,#7c3aed,#6366f1)`,`z-index:2147483647`,`transition:width 0.4s ease`,`pointer-events:none`].join(`;`),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.width=`70%`})}function Yn(){if(typeof document>`u`)return;let e=document.getElementById(qn);e&&(e.style.width=`100%`,setTimeout(()=>{e.style.opacity=`0`,e.style.transition=`opacity 0.3s ease`,setTimeout(()=>e.remove(),350)},200))}function Xn(){if(typeof window>`u`||typeof document>`u`)return;try{window.history.state?.flowengageSpa&&Mn()}catch{}let e;try{e=JSON.parse(sessionStorage.getItem(Sn)||`null`)}catch{return}if(!e)return;try{sessionStorage.removeItem(Sn)}catch{}let{sectionText:t,ts:n}=e;if(!t)return;if(Date.now()-n>Cn){W(`initNavigationHighlight: pending section expired, skipping:`,t);return}W(`initNavigationHighlight: replaying section highlight:`,t);let r=0,i=()=>{r+=1;let e=Qn(null,t);if(e){$n(e),W(`initNavigationHighlight: highlighted on attempt`,r);return}r<8?setTimeout(i,300):W(`initNavigationHighlight: could not find element after 8 attempts:`,t)};setTimeout(i,250)}var Zn=()=>{if(typeof document>`u`||document.getElementById(`fe-highlight-styles`))return;let e=document.createElement(`style`);e.id=`fe-highlight-styles`,e.textContent=`
1
+ "use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(e&&(t=e(e=0)),t),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),u=e=>a.call(e,`module.exports`)?e[`module.exports`]:c(t({},`__esModule`,{value:!0}),e);let d=require(`react`);d=l(d);let f=require(`react/jsx-runtime`);var p=e=>{if(!e||typeof e!=`object`)throw Error(`FlowEngage config is required`);if(!e.siteId||typeof e.siteId!=`string`)throw Error(`[FlowEngage] config.siteId is required. Pass it as <FlowEngageProvider siteId="your-site-id" /> or config={{ siteId: 'your-site-id' }}.`);let t=(e.apiBaseUrl||`http://localhost:5008`).replace(/\/+$/,``);return{siteId:e.siteId.trim(),apiBaseUrl:t}},m=(e,t)=>{let n=Number.parseInt(String(e??``),10);return Number.isFinite(n)&&n>0?n:t},h=m(void 0,1e4),g=m(void 0,15e3),_={chatId:`flowengage.chatId`,isOpen:`flowengage.isOpen`,activeScreen:`flowengage.activeScreen`,isHumanHandled:`flowengage.isHumanHandled`,agentName:`flowengage.agentName`,agentHeadshot:`flowengage.agentHeadshot`,visitorEmail:`flowengage.visitorEmail`},v=6e4,y=480*60,b=3e4,x=typeof window<`u`,S=e=>e?`flowengage.visitorEmail.${e}`:null,C=()=>{if(!x)return null;let e=window.localStorage.getItem(_.chatId);return e&&String(e).trim()?String(e).trim():null},w=()=>{if(x)try{window.localStorage.removeItem(_.chatId)}catch{}},T=()=>x?typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`:`server-chat-id`,E=e=>e?`flowengage.entrySeen.${e}`:null,ee=e=>{if(!x||!e)return!1;try{let t=E(e);return t?window.localStorage.getItem(t)===`1`:!1}catch{return!1}},D=e=>{if(!(!x||!e))try{let t=E(e);t&&window.localStorage.setItem(t,`1`)}catch{}},O=e=>e?`flowengage.persistedChatId.${e}`:null,k=e=>{if(!x||!e)return null;try{let t=O(e),n=t?window.localStorage.getItem(t):null;return n&&String(n).trim()?String(n).trim():null}catch{return null}},te=e=>{if(!(!x||!e))try{let t=O(e);t&&window.localStorage.removeItem(t)}catch{}},A=(e,t)=>{if(!(!x||!e||!t))try{let n=O(e);n&&window.localStorage.setItem(n,String(t).trim())}catch{}},j=()=>x?{isOpen:!1,activeScreen:window.sessionStorage.getItem(_.activeScreen)||`ai`,isHumanHandled:window.sessionStorage.getItem(_.isHumanHandled)===`true`,agentName:window.sessionStorage.getItem(_.agentName),agentHeadshot:window.sessionStorage.getItem(_.agentHeadshot),visitorEmail:``}:{isOpen:!1,activeScreen:`ai`,isHumanHandled:!1,agentName:null,agentHeadshot:null,visitorEmail:``},ne=e=>{x&&Object.entries(e).forEach(([e,t])=>{let n=_[e];if(n){if(t==null||t===!1){window.sessionStorage.removeItem(n);return}window.sessionStorage.setItem(n,String(t))}})},re=e=>{if(!x||!e)return``;let t=S(e),n=window.localStorage.getItem(t);if(!n){let e=window.sessionStorage.getItem(_.visitorEmail);e&&(window.localStorage.setItem(t,e),window.sessionStorage.removeItem(_.visitorEmail),n=e)}return n||``},ie=(e,t)=>{if(!x)return;let n=S(t);if(!n)return;let r=typeof e==`string`?e.trim():``;if(!r){window.localStorage.removeItem(n),window.sessionStorage.removeItem(_.visitorEmail);return}window.localStorage.setItem(n,r),window.sessionStorage.removeItem(_.visitorEmail)},ae=e=>e?`flowengage.visitorId.${e}`:null,oe=()=>`v_${Date.now().toString(36)}_${typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,``).slice(0,16):Math.random().toString(36).slice(2,18)}`,se=e=>{if(!x||!e)return null;try{let t=ae(e),n=t?window.localStorage.getItem(t):null;return n&&String(n).trim()?String(n).trim():null}catch{return null}},ce=e=>{if(!x||!e)return null;try{let t=se(e);if(t)return t;let n=oe(),r=ae(e);return r&&window.localStorage.setItem(r,n),n}catch{return oe()}},le=`flowengage.tabId`,ue=()=>{if(!x)return`default`;try{let e=window.sessionStorage.getItem(le);return e||(e=typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,``).slice(0,12):Math.random().toString(36).slice(2,14),window.sessionStorage.setItem(le,e)),e}catch{return`default`}},de=e=>e?`flowengage.voice.transcript.${e}.${ue()}`:null,M=600*1e3,fe=(e,t,n={})=>{if(!x||!e)return;let r=typeof t==`string`?t.trim():``;if(!r)return;let i=Number.isFinite(n.ttlMs)?n.ttlMs:M,a={transcript:r,expiresAt:Date.now()+i};try{let t=de(e);t&&window.localStorage.setItem(t,JSON.stringify(a))}catch{}},pe=e=>{if(!x||!e)return null;try{let t=de(e),n=t?window.localStorage.getItem(t):null;if(!n)return null;let r=JSON.parse(n);return!r||typeof r.transcript!=`string`?null:Number.isFinite(r.expiresAt)&&Date.now()>r.expiresAt?(window.localStorage.removeItem(t),null):r}catch{return null}},me=e=>{if(!(!x||!e))try{let t=de(e);t&&window.localStorage.removeItem(t)}catch{}},he=`flowengage.voice.pendingResume`,ge=()=>{if(x)try{window.sessionStorage.setItem(he,`1`)}catch{}},_e=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(he)===`1`?(window.sessionStorage.removeItem(he),!0):!1}catch{return!1}},ve=`flowengage.chat.pendingReopen`,ye=()=>{if(x)try{window.sessionStorage.setItem(ve,`1`)}catch{}},be=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(ve)===`1`?(window.sessionStorage.removeItem(ve),!0):!1}catch{return!1}},xe=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(he)===`1`}catch{return!1}},N=e=>e?`flowengage.voice.navState.${e}.${ue()}`:null,P=(e,t,n,r)=>{if(!(!x||!e||!t))try{let i=N(e);i&&window.sessionStorage.setItem(i,JSON.stringify({previousPage:String(t),targetPath:n?new URL(String(n),window.location.href).pathname:null,pageName:r||null,ts:Date.now()}))}catch{}},Se=e=>{if(!x||!e)return null;try{let t=N(e);if(!t)return null;let n=window.sessionStorage.getItem(t);if(!n)return null;window.sessionStorage.removeItem(t);let r=JSON.parse(n);return!r||typeof r.previousPage!=`string`||Number.isFinite(r.ts)&&Date.now()-r.ts>6e4||r.targetPath&&(window.location.pathname.replace(/\/$/,``)||`/`)!==(r.targetPath.replace(/\/$/,``)||`/`)?null:{previousPage:r.previousPage,pageName:r.pageName||null}}catch{return null}},Ce=async e=>{let t=await e.json().catch(()=>({}));if(!e.ok){let n=Error(t.message||t.error||`Request failed with status ${e.status}`);throw n.status=e.status,n}return t},we=async(e,t={})=>{try{return await fetch(e,{mode:`cors`,...t})}catch(t){let n=Error(`Network error reaching ${e}. Check: (1) backend is running, (2) CORS allows this origin, (3) siteId is correct. Original: ${t.message}`);throw n.status=0,n.cause=t,n}},Te=async({apiBaseUrl:e,userId:t,siteId:n,priorChatId:r=null,forceNew:i=!1,resumeChatId:a=null,visitorId:o=null})=>{let s=`${e}/api/visitors/resolve-session`,c={siteId:n};return r&&String(r).trim()&&(c.priorChatId=String(r).trim()),i&&(c.forceNew=!0),a&&(c.resumeChatId=a),o&&(c.visitorId=o),Ce(await we(s,{method:`POST`,mode:`cors`,headers:{"Content-Type":`application/json`,"x-user-id":t==null?``:String(t),...n?{"x-site-id":n}:{},...o?{"x-visitor-id":o}:{}},body:JSON.stringify(c)}))},Ee=async({apiBaseUrl:e,siteId:t})=>{let n=typeof window<`u`?window.location.origin:`http://localhost`;return(await Ce(await we(`${e}/api/widget/chatbot-loader?${new URLSearchParams({siteId:t,origin:n}).toString()}`,{method:`GET`}))).data},De=({apiBaseUrl:e,userId:t,siteId:n,visitorId:r=null})=>{let i=(t,n)=>{let r=`${e}${t}`,i=JSON.stringify(n);if(typeof navigator<`u`&&navigator.sendBeacon)try{let e=new Blob([i],{type:`application/json`});return navigator.sendBeacon(r,e)}catch{}return typeof fetch<`u`?(fetch(r,{method:`POST`,mode:`cors`,keepalive:!0,headers:{"Content-Type":`application/json`},body:i}).catch(()=>{}),!0):!1},a=async(i,a={})=>Ce(await we(`${e}${i}`,{...a,headers:{"Content-Type":`application/json`,"x-user-id":t,...n?{"x-site-id":n}:{},...r?{"x-visitor-id":r}:{},...a.headers||{}}})),o=async(r,i,a={})=>{let o={"x-user-id":t,...n?{"x-site-id":n}:{},...a.headers||{}};return Ce(await we(`${e}${r}`,{...a,body:i,headers:o}))};return{async loadHistory(e,t=`en`,n=``){return a(`/api/ai/chat`,{method:`POST`,body:JSON.stringify({session_id:e,user_query:``,lang:t,category:n})})},async sendAiMessage(e,t,n=`en`,r=``,i=null,o={}){return a(`/api/ai/chat`,{method:`POST`,body:JSON.stringify({session_id:e,user_query:t,lang:n,category:r,...o||{},...i||{}})})},async uploadChatFile(e){let t=new FormData;return t.append(`file`,e),o(`/api/upload`,t,{method:`POST`})},async checkHumanHandled(e){return a(`/api/ai/check_human_handled`,{method:`POST`,body:JSON.stringify({session_id:e})})},async setChatMode(e,t){return a(`/api/ai/set_chat_mode`,{method:`POST`,body:JSON.stringify({session_id:e,mode:t})})},async toggleVoice(e){return a(`/api/ai/voice/toggle`,{method:`POST`,body:JSON.stringify({session_id:e})})},async syncVoice(e,r){return a(`/api/ai/voice/sync`,{method:`POST`,body:JSON.stringify({session_id:e,messages:r,...t?{userId:String(t)}:{},...n?{siteId:String(n)}:{}})})},async trackVisitor(e){return a(`/api/visitors/track`,{method:`POST`,body:JSON.stringify(e)})},async updateChatStatus(e,t){return a(`/api/chat/status`,{method:`POST`,body:JSON.stringify({chatId:e,type:t})})},async startConversation(e,t=`en`){return a(`/api/chat/status`,{method:`POST`,body:JSON.stringify({chatId:e,type:`open`,lang:t})})},async endConversation(e){return a(`/api/chat/status`,{method:`POST`,body:JSON.stringify({chatId:e,type:`closed`})})},async getVisitorChatHistory(){return a(`/api/visitors/my-chats`,{method:`GET`})},async getVisitorChatThread(e){return a(`/api/visitors/my-chats/${e}`,{method:`GET`})},async acceptCall(e,t){return a(`/api/calls/${e}/accept`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n})})},async rejectCall(e,t){return a(`/api/calls/${e}/reject`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n})})},async getIceServersConfig(){return Ce(await we(`${e}/api/calls/ice-config`,{method:`GET`,headers:{"x-user-id":t,...n?{"x-site-id":n}:{}}}))},async endWebRTCCall(e,t){return a(`/api/calls/${e}/end`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n,endedBy:`customer`})})},async markCustomerUnavailable(e,t){return a(`/api/calls/${e}/customer-unavailable`,{method:`POST`,body:JSON.stringify({session_id:t,site_id:n})})},async uploadRecording(e,t,n){let r=new FormData,i=`call-rec-${Date.now()}.webm`;return r.append(`audio`,t,i),r.append(`duration`,String(n)),o(`/api/calls/${e}/recording`,r,{method:`POST`})},beaconEndWebRTCCall(e,t){return i(`/api/calls/${e}/end`,{session_id:t,site_id:n,endedBy:`customer`})},beaconCustomerUnavailable(e,t){return i(`/api/calls/${e}/customer-unavailable`,{session_id:t,site_id:n})},beaconSyncVoice(r,i){if(typeof navigator>`u`||!navigator.sendBeacon)return!1;let a=new URLSearchParams;return a.append(`session_id`,r),a.append(`messages`,JSON.stringify(i)),t&&a.append(`userId`,String(t)),n&&a.append(`siteId`,String(n)),navigator.sendBeacon(`${e}/api/ai/voice/sync`,a)},beaconWidgetClosed(r){if(typeof navigator>`u`||!navigator.sendBeacon)return!1;let i=new URLSearchParams;return i.append(`chatId`,r),i.append(`type`,`widget_closed`),t&&i.append(`userId`,String(t)),n&&i.append(`siteId`,String(n)),navigator.sendBeacon(`${e}/api/chat/status`,i)}}},F=Object.create(null);F.open=`0`,F.close=`1`,F.ping=`2`,F.pong=`3`,F.message=`4`,F.upgrade=`5`,F.noop=`6`;var Oe=Object.create(null);Object.keys(F).forEach(e=>{Oe[F[e]]=e});var ke={type:`error`,data:`parser error`},Ae=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,je=typeof ArrayBuffer==`function`,Me=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Ne=({type:e,data:t},n,r)=>Ae&&t instanceof Blob?n?r(t):Pe(t,r):je&&(t instanceof ArrayBuffer||Me(t))?n?r(t):Pe(new Blob([t]),r):r(F[e]+(t||``)),Pe=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Fe(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var I;function Ie(e,t){if(Ae&&e.data instanceof Blob)return e.data.arrayBuffer().then(Fe).then(t);if(je&&(e.data instanceof ArrayBuffer||Me(e.data)))return t(Fe(e.data));Ne(e,!1,e=>{I||=new TextEncoder,t(I.encode(e))})}var L=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Le=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)Le[L.charCodeAt(e)]=e;var Re=e=>{let t=e.length*.75,n=e.length,r,i=0,a,o,s,c;e[e.length-1]===`=`&&(t--,e[e.length-2]===`=`&&t--);let l=new ArrayBuffer(t),u=new Uint8Array(l);for(r=0;r<n;r+=4)a=Le[e.charCodeAt(r)],o=Le[e.charCodeAt(r+1)],s=Le[e.charCodeAt(r+2)],c=Le[e.charCodeAt(r+3)],u[i++]=a<<2|o>>4,u[i++]=(o&15)<<4|s>>2,u[i++]=(s&3)<<6|c&63;return l},R=typeof ArrayBuffer==`function`,ze=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:Ve(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:Be(e.substring(1),t)}:Oe[n]?e.length>1?{type:Oe[n],data:e.substring(1)}:{type:Oe[n]}:ke},Be=(e,t)=>R?Ve(Re(e),t):{base64:!0,data:e},Ve=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},He=``,Ue=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{Ne(e,!1,e=>{r[a]=e,++i===n&&t(r.join(He))})})},We=(e,t)=>{let n=e.split(He),r=[];for(let e=0;e<n.length;e++){let i=ze(n[e],t);if(r.push(i),i.type===`error`)break}return r};function Ge(){return new TransformStream({transform(e,t){Ie(e,n=>{let r=n.length,i;if(r<126)i=new Uint8Array(1),new DataView(i.buffer).setUint8(0,r);else if(r<65536){i=new Uint8Array(3);let e=new DataView(i.buffer);e.setUint8(0,126),e.setUint16(1,r)}else{i=new Uint8Array(9);let e=new DataView(i.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(r))}e.data&&typeof e.data!=`string`&&(i[0]|=128),t.enqueue(i),t.enqueue(n)})}})}var Ke;function z(e){return e.reduce((e,t)=>e+t.length,0)}function B(e,t){if(e[0].length===t)return e.shift();let n=new Uint8Array(t),r=0;for(let i=0;i<t;i++)n[i]=e[0][r++],r===e[0].length&&(e.shift(),r=0);return e.length&&r<e[0].length&&(e[0]=e[0].slice(r)),n}function qe(e,t){Ke||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(z(n)<1)break;let e=B(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(z(n)<2)break;let e=B(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(z(n)<8)break;let e=B(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(ke);break}i=a*2**32+t.getUint32(4),r=3}else{if(z(n)<i)break;let e=B(n,i);s.enqueue(ze(a?e:Ke.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(ke);break}}}})}function V(e){if(e)return Je(e)}function Je(e){for(var t in V.prototype)e[t]=V.prototype[t];return e}V.prototype.on=V.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},V.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},V.prototype.off=V.prototype.removeListener=V.prototype.removeAllListeners=V.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var n=this._callbacks[`$`+e];if(!n)return this;if(arguments.length==1)return delete this._callbacks[`$`+e],this;for(var r,i=0;i<n.length;i++)if(r=n[i],r===t||r.fn===t){n.splice(i,1);break}return n.length===0&&delete this._callbacks[`$`+e],this},V.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=Array(arguments.length-1),n=this._callbacks[`$`+e],r=1;r<arguments.length;r++)t[r-1]=arguments[r];if(n){n=n.slice(0);for(var r=0,i=n.length;r<i;++r)n[r].apply(this,t)}return this},V.prototype.emitReserved=V.prototype.emit,V.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},V.prototype.hasListeners=function(e){return!!this.listeners(e).length};var H=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),U=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),Ye=`arraybuffer`;function Xe(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var Ze=U.setTimeout,Qe=U.clearTimeout;function $e(e,t){t.useNativeTimers?(e.setTimeoutFn=Ze.bind(U),e.clearTimeoutFn=Qe.bind(U)):(e.setTimeoutFn=U.setTimeout.bind(U),e.clearTimeoutFn=U.clearTimeout.bind(U))}var et=1.33;function tt(e){return typeof e==`string`?nt(e):Math.ceil((e.byteLength||e.size)*et)}function nt(e){let t=0,n=0;for(let r=0,i=e.length;r<i;r++)t=e.charCodeAt(r),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(r++,n+=4);return n}function rt(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function it(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function at(e){let t={},n=e.split(`&`);for(let e=0,r=n.length;e<r;e++){let r=n[e].split(`=`);t[decodeURIComponent(r[0])]=decodeURIComponent(r[1])}return t}var ot=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},st=class extends V{constructor(e){super(),this.writable=!1,$e(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved(`error`,new ot(e,t,n)),this}open(){return this.readyState=`opening`,this.doOpen(),this}close(){return(this.readyState===`opening`||this.readyState===`open`)&&(this.doClose(),this.onClose()),this}send(e){this.readyState===`open`&&this.write(e)}onOpen(){this.readyState=`open`,this.writable=!0,super.emitReserved(`open`)}onData(e){let t=ze(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved(`packet`,e)}onClose(e){this.readyState=`closed`,super.emitReserved(`close`,e)}pause(e){}createUri(e,t={}){return e+`://`+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){let e=this.opts.hostname;return e.indexOf(`:`)===-1?e:`[`+e+`]`}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?`:`+this.opts.port:``}_query(e){let t=it(e);return t.length?`?`+t:``}},ct=class extends st{constructor(){super(...arguments),this._polling=!1}get name(){return`polling`}doOpen(){this._poll()}pause(e){this.readyState=`pausing`;let t=()=>{this.readyState=`paused`,e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once(`pollComplete`,function(){--e||t()})),this.writable||(e++,this.once(`drain`,function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved(`poll`)}onData(e){We(e,this.socket.binaryType).forEach(e=>{if(this.readyState===`opening`&&e.type===`open`&&this.onOpen(),e.type===`close`)return this.onClose({description:`transport closed by the server`}),!1;this.onPacket(e)}),this.readyState!==`closed`&&(this._polling=!1,this.emitReserved(`pollComplete`),this.readyState===`open`&&this._poll())}doClose(){let e=()=>{this.write([{type:`close`}])};this.readyState===`open`?e():this.once(`open`,e)}write(e){this.writable=!1,Ue(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved(`drain`)})})}uri(){let e=this.opts.secure?`https`:`http`,t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=rt()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},lt=!1;try{lt=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var ut=lt;function dt(){}var ft=class extends ct{constructor(e){if(super(e),typeof location<`u`){let t=location.protocol===`https:`,n=location.port;n||=t?`443`:`80`,this.xd=typeof location<`u`&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){let n=this.request({method:`POST`,data:e});n.on(`success`,t),n.on(`error`,(e,t)=>{this.onError(`xhr post error`,e,t)})}doPoll(){let e=this.request();e.on(`data`,this.onData.bind(this)),e.on(`error`,(e,t)=>{this.onError(`xhr poll error`,e,t)}),this.pollXhr=e}},pt=class e extends V{constructor(e,t,n){super(),this.createRequest=e,$e(this,n),this._opts=n,this._method=n.method||`GET`,this._uri=t,this._data=n.data===void 0?null:n.data,this._create()}_create(){var t;let n=Xe(this._opts,`agent`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`autoUnref`);n.xdomain=!!this._opts.xd;let r=this._xhr=this.createRequest(n);try{r.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){r.setDisableHeaderCheck&&r.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&r.setRequestHeader(e,this._opts.extraHeaders[e])}}catch{}if(this._method===`POST`)try{r.setRequestHeader(`Content-type`,`text/plain;charset=UTF-8`)}catch{}try{r.setRequestHeader(`Accept`,`*/*`)}catch{}(t=this._opts.cookieJar)==null||t.addCookies(r),`withCredentials`in r&&(r.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(r.timeout=this._opts.requestTimeout),r.onreadystatechange=()=>{var e;r.readyState===3&&((e=this._opts.cookieJar)==null||e.parseCookies(r.getResponseHeader(`set-cookie`))),r.readyState===4&&(r.status===200||r.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof r.status==`number`?r.status:0)},0))},r.send(this._data)}catch(e){this.setTimeoutFn(()=>{this._onError(e)},0);return}typeof document<`u`&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved(`error`,e,this._xhr),this._cleanup(!0)}_cleanup(t){if(!(this._xhr===void 0||this._xhr===null)){if(this._xhr.onreadystatechange=dt,t)try{this._xhr.abort()}catch{}typeof document<`u`&&delete e.requests[this._index],this._xhr=null}}_onLoad(){let e=this._xhr.responseText;e!==null&&(this.emitReserved(`data`,e),this.emitReserved(`success`),this._cleanup())}abort(){this._cleanup()}};if(pt.requestsCount=0,pt.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,mt);else if(typeof addEventListener==`function`){let e=`onpagehide`in U?`pagehide`:`unload`;addEventListener(e,mt,!1)}}function mt(){for(let e in pt.requests)pt.requests.hasOwnProperty(e)&&pt.requests[e].abort()}var ht=(function(){let e=_t({xdomain:!1});return e&&e.responseType!==null})(),gt=class extends ft{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=ht&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new pt(_t,this.uri(),e)}};function _t(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||ut))return new XMLHttpRequest}catch{}if(!t)try{return new U[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var vt=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,yt=class extends st{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=vt?{}:Xe(this.opts,`agent`,`perMessageDeflate`,`pfx`,`key`,`passphrase`,`cert`,`ca`,`ciphers`,`rejectUnauthorized`,`localAddress`,`protocolVersion`,`origin`,`maxPayload`,`family`,`checkServerIdentity`);this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(e){return this.emitReserved(`error`,e)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:`websocket connection closed`,context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError(`websocket error`,e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;Ne(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&H(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){this.ws!==void 0&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){let e=this.opts.secure?`wss`:`ws`,t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=rt()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},bt=U.WebSocket||U.MozWebSocket,xt={websocket:class extends yt{createSocket(e,t,n){return vt?new bt(e,t,n):t?new bt(e,t):new bt(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends st{get name(){return`webtransport`}doOpen(){try{this._transport=new WebTransport(this.createUri(`https`),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved(`error`,e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError(`webtransport error`,e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{let t=qe(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=Ge();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();let i=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),i())}).catch(e=>{})};i();let a={type:`open`};this.query.sid&&(a.data=`{"sid":"${this.query.sid}"}`),this._writer.write(a).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){let n=e[t],r=t===e.length-1;this._writer.write(n).then(()=>{r&&H(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:gt},St=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ct=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function wt(e){if(e.length>8e3)throw`URI too long`;let t=e,n=e.indexOf(`[`),r=e.indexOf(`]`);n!=-1&&r!=-1&&(e=e.substring(0,n)+e.substring(n,r).replace(/:/g,`;`)+e.substring(r,e.length));let i=St.exec(e||``),a={},o=14;for(;o--;)a[Ct[o]]=i[o]||``;return n!=-1&&r!=-1&&(a.source=t,a.host=a.host.substring(1,a.host.length-1).replace(/;/g,`:`),a.authority=a.authority.replace(`[`,``).replace(`]`,``).replace(/;/g,`:`),a.ipv6uri=!0),a.pathNames=Tt(a,a.path),a.queryKey=Et(a,a.query),a}function Tt(e,t){let n=t.replace(/\/{2,9}/g,`/`).split(`/`);return(t.slice(0,1)==`/`||t.length===0)&&n.splice(0,1),t.slice(-1)==`/`&&n.splice(n.length-1,1),n}function Et(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var Dt=typeof addEventListener==`function`&&typeof removeEventListener==`function`,Ot=[];Dt&&addEventListener(`offline`,()=>{Ot.forEach(e=>e())},!1);var kt=class e extends V{constructor(e,t){if(super(),this.binaryType=Ye,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e==`object`&&(t=e,e=null),e){let n=wt(e);t.hostname=n.host,t.secure=n.protocol===`https`||n.protocol===`wss`,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=wt(t.host).host);$e(this,t),this.secure=t.secure==null?typeof location<`u`&&location.protocol===`https:`:t.secure,t.hostname&&!t.port&&(t.port=this.secure?`443`:`80`),this.hostname=t.hostname||(typeof location<`u`?location.hostname:`localhost`),this.port=t.port||(typeof location<`u`&&location.port?location.port:this.secure?`443`:`80`),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{let t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:`/engine.io`,agent:!1,withCredentials:!1,upgrade:!0,timestampParam:`t`,rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,``)+(this.opts.addTrailingSlash?`/`:``),typeof this.opts.query==`string`&&(this.opts.query=at(this.opts.query)),Dt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener(`beforeunload`,this._beforeunloadEventListener,!1)),this.hostname!==`localhost`&&(this._offlineEventListener=()=>{this._onClose(`transport close`,{description:`network connection lost`})},Ot.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){let t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);let n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved(`error`,`No transports available`)},0);return}let t=this.opts.rememberUpgrade&&e.priorWebsocketSuccess&&this.transports.indexOf(`websocket`)!==-1?`websocket`:this.transports[0];this.readyState=`opening`;let n=this.createTransport(t);n.open(),this.setTransport(n)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on(`drain`,this._onDrain.bind(this)).on(`packet`,this._onPacket.bind(this)).on(`error`,this._onError.bind(this)).on(`close`,e=>this._onClose(`transport close`,e))}onOpen(){this.readyState=`open`,e.priorWebsocketSuccess=this.transport.name===`websocket`,this.emitReserved(`open`),this.flush()}_onPacket(e){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`)switch(this.emitReserved(`packet`,e),this.emitReserved(`heartbeat`),e.type){case`open`:this.onHandshake(JSON.parse(e.data));break;case`ping`:this._sendPacket(`pong`),this.emitReserved(`ping`),this.emitReserved(`pong`),this._resetPingTimeout();break;case`error`:let t=Error(`server error`);t.code=e.data,this._onError(t);break;case`message`:this.emitReserved(`data`,e.data),this.emitReserved(`message`,e.data);break}}onHandshake(e){this.emitReserved(`handshake`,e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),this.readyState!==`closed`&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);let e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose(`ping timeout`)},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,this.writeBuffer.length===0?this.emitReserved(`drain`):this.flush()}flush(){if(this.readyState!==`closed`&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){let e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved(`flush`)}}_getWritablePackets(){if(!(this._maxPayload&&this.transport.name===`polling`&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){let n=this.writeBuffer[t].data;if(n&&(e+=tt(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;let e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,H(()=>{this._onClose(`ping timeout`)},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket(`message`,e,t,n),this}send(e,t,n){return this._sendPacket(`message`,e,t,n),this}_sendPacket(e,t,n,r){if(typeof t==`function`&&(r=t,t=void 0),typeof n==`function`&&(r=n,n=null),this.readyState===`closing`||this.readyState===`closed`)return;n||={},n.compress=!1!==n.compress;let i={type:e,data:t,options:n};this.emitReserved(`packetCreate`,i),this.writeBuffer.push(i),r&&this.once(`flush`,r),this.flush()}close(){let e=()=>{this._onClose(`forced close`),this.transport.close()},t=()=>{this.off(`upgrade`,t),this.off(`upgradeError`,t),e()},n=()=>{this.once(`upgrade`,t),this.once(`upgradeError`,t)};return(this.readyState===`opening`||this.readyState===`open`)&&(this.readyState=`closing`,this.writeBuffer.length?this.once(`drain`,()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(t){if(e.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState===`opening`)return this.transports.shift(),this._open();this.emitReserved(`error`,t),this._onClose(`transport error`,t)}_onClose(e,t){if(this.readyState===`opening`||this.readyState===`open`||this.readyState===`closing`){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners(`close`),this.transport.close(),this.transport.removeAllListeners(),Dt&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=Ot.indexOf(this._offlineEventListener);e!==-1&&Ot.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};kt.protocol=4;var At=class extends kt{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),this.readyState===`open`&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;kt.priorWebsocketSuccess=!1;let r=()=>{n||(t.send([{type:`ping`,data:`probe`}]),t.once(`packet`,e=>{if(!n)if(e.type===`pong`&&e.data===`probe`){if(this.upgrading=!0,this.emitReserved(`upgrading`,t),!t)return;kt.priorWebsocketSuccess=t.name===`websocket`,this.transport.pause(()=>{n||this.readyState!==`closed`&&(l(),this.setTransport(t),t.send([{type:`upgrade`}]),this.emitReserved(`upgrade`,t),t=null,this.upgrading=!1,this.flush())})}else{let e=Error(`probe error`);e.transport=t.name,this.emitReserved(`upgradeError`,e)}}))};function i(){n||(n=!0,l(),t.close(),t=null)}let a=e=>{let n=Error(`probe error: `+e);n.transport=t.name,i(),this.emitReserved(`upgradeError`,n)};function o(){a(`transport closed`)}function s(){a(`socket closed`)}function c(e){t&&e.name!==t.name&&i()}let l=()=>{t.removeListener(`open`,r),t.removeListener(`error`,a),t.removeListener(`close`,o),this.off(`close`,s),this.off(`upgrading`,c)};t.once(`open`,r),t.once(`error`,a),t.once(`close`,o),this.once(`close`,s),this.once(`upgrading`,c),this._upgrades.indexOf(`webtransport`)!==-1&&e!==`webtransport`?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){let t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}},jt=class extends At{constructor(e,t={}){let n=typeof e==`object`?e:t;(!n.transports||n.transports&&typeof n.transports[0]==`string`)&&(n.transports=(n.transports||[`polling`,`websocket`,`webtransport`]).map(e=>xt[e]).filter(e=>!!e)),super(e,n)}};jt.protocol;function Mt(e,t=``,n){let r=e;n||=typeof location<`u`&&location,e??=n.protocol+`//`+n.host,typeof e==`string`&&(e.charAt(0)===`/`&&(e=e.charAt(1)===`/`?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=n===void 0?`https://`+e:n.protocol+`//`+e),r=wt(e)),r.port||(/^(http|ws)$/.test(r.protocol)?r.port=`80`:/^(http|ws)s$/.test(r.protocol)&&(r.port=`443`)),r.path=r.path||`/`;let i=r.host.indexOf(`:`)===-1?r.host:`[`+r.host+`]`;return r.id=r.protocol+`://`+i+`:`+r.port+t,r.href=r.protocol+`://`+i+(n&&n.port===r.port?``:`:`+r.port),r}var Nt=typeof ArrayBuffer==`function`,Pt=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Ft=Object.prototype.toString,It=typeof Blob==`function`||typeof Blob<`u`&&Ft.call(Blob)===`[object BlobConstructor]`,Lt=typeof File==`function`||typeof File<`u`&&Ft.call(File)===`[object FileConstructor]`;function Rt(e){return Nt&&(e instanceof ArrayBuffer||Pt(e))||It&&e instanceof Blob||Lt&&e instanceof File}function zt(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(zt(e[t]))return!0;return!1}if(Rt(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return zt(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&zt(e[t]))return!0;return!1}function Bt(e){let t=[],n=e.data,r=e;return r.data=Vt(n,t),r.attachments=t.length,{packet:r,buffers:t}}function Vt(e,t){if(!e)return e;if(Rt(e)){let n={_placeholder:!0,num:t.length};return t.push(e),n}else if(Array.isArray(e)){let n=Array(e.length);for(let r=0;r<e.length;r++)n[r]=Vt(e[r],t);return n}else if(typeof e==`object`&&!(e instanceof Date)){let n={};for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=Vt(e[r],t));return n}return e}function Ht(e,t){return e.data=Ut(e.data,t),delete e.attachments,e}function Ut(e,t){if(!e)return e;if(e&&e._placeholder===!0){if(typeof e.num==`number`&&e.num>=0&&e.num<t.length)return t[e.num];throw Error(`illegal attachments`)}else if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=Ut(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=Ut(e[n],t));return e}var Wt=s({Decoder:()=>qt,Encoder:()=>Kt,PacketType:()=>W,isPacketValid:()=>en,protocol:()=>5}),Gt=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],W;(function(e){e[e.CONNECT=0]=`CONNECT`,e[e.DISCONNECT=1]=`DISCONNECT`,e[e.EVENT=2]=`EVENT`,e[e.ACK=3]=`ACK`,e[e.CONNECT_ERROR=4]=`CONNECT_ERROR`,e[e.BINARY_EVENT=5]=`BINARY_EVENT`,e[e.BINARY_ACK=6]=`BINARY_ACK`})(W||={});var Kt=class{constructor(e){this.replacer=e}encode(e){return(e.type===W.EVENT||e.type===W.ACK)&&zt(e)?this.encodeAsBinary({type:e.type===W.EVENT?W.BINARY_EVENT:W.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===W.BINARY_EVENT||e.type===W.BINARY_ACK)&&(t+=e.attachments+`-`),e.nsp&&e.nsp!==`/`&&(t+=e.nsp+`,`),e.id!=null&&(t+=e.id),e.data!=null&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){let t=Bt(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},qt=class e extends V{constructor(e){super(),this.opts=Object.assign({reviver:void 0,maxAttachments:10},typeof e==`function`?{reviver:e}:e)}add(e){let t;if(typeof e==`string`){if(this.reconstructor)throw Error(`got plaintext data when reconstructing a packet`);t=this.decodeString(e);let n=t.type===W.BINARY_EVENT;n||t.type===W.BINARY_ACK?(t.type=n?W.EVENT:W.ACK,this.reconstructor=new Jt(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(Rt(e)||e.base64)if(this.reconstructor)t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved(`decoded`,t));else throw Error(`got binary data when not reconstructing a packet`);else throw Error(`Unknown type: `+e)}decodeString(t){let n=0,r={type:Number(t.charAt(0))};if(W[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===W.BINARY_EVENT||r.type===W.BINARY_ACK){let e=n+1;for(;t.charAt(++n)!==`-`&&n!=t.length;);let i=t.substring(e,n);if(i!=Number(i)||t.charAt(n)!==`-`)throw Error(`Illegal attachments`);let a=Number(i);if(!Xt(a)||a<0)throw Error(`Illegal attachments`);if(a>this.opts.maxAttachments)throw Error(`too many attachments`);r.attachments=a}if(t.charAt(n+1)===`/`){let e=n+1;for(;++n&&!(t.charAt(n)===`,`||n===t.length););r.nsp=t.substring(e,n)}else r.nsp=`/`;let i=t.charAt(n+1);if(i!==``&&Number(i)==i){let e=n+1;for(;++n;){let e=t.charAt(n);if(e==null||Number(e)!=e){--n;break}if(n===t.length)break}r.id=Number(t.substring(e,n+1))}if(t.charAt(++n)){let i=this.tryParse(t.substr(n));if(e.isPayloadValid(r.type,i))r.data=i;else throw Error(`invalid payload`)}return r}tryParse(e){try{return JSON.parse(e,this.opts.reviver)}catch{return!1}}static isPayloadValid(e,t){switch(e){case W.CONNECT:return Qt(t);case W.DISCONNECT:return t===void 0;case W.CONNECT_ERROR:return typeof t==`string`||Qt(t);case W.EVENT:case W.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&Gt.indexOf(t[0])===-1);case W.ACK:case W.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},Jt=class{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){let e=Ht(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function Yt(e){return typeof e==`string`}var Xt=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function Zt(e){return e===void 0||Xt(e)}function Qt(e){return Object.prototype.toString.call(e)===`[object Object]`}function $t(e,t){switch(e){case W.CONNECT:return t===void 0||Qt(t);case W.DISCONNECT:return t===void 0;case W.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&Gt.indexOf(t[0])===-1);case W.ACK:return Array.isArray(t);case W.CONNECT_ERROR:return typeof t==`string`||Qt(t);default:return!1}}function en(e){return Yt(e.nsp)&&Zt(e.id)&&$t(e.type,e.data)}function tn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var nn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),rn=class extends V{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;let e=this.io;this.subs=[tn(e,`open`,this.onopen.bind(this)),tn(e,`packet`,this.onpacket.bind(this)),tn(e,`error`,this.onerror.bind(this)),tn(e,`close`,this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected?this:(this.subEvents(),this.io._reconnecting||this.io.open(),this.io._readyState===`open`&&this.onopen(),this)}open(){return this.connect()}send(...e){return e.unshift(`message`),this.emit.apply(this,e),this}emit(e,...t){if(nn.hasOwnProperty(e))throw Error(`"`+e.toString()+`" is a reserved event name`);if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;let n={type:W.EVENT,data:t};if(n.options={},n.options.compress=this.flags.compress!==!1,typeof t[t.length-1]==`function`){let e=this.ids++,r=t.pop();this._registerAckCallback(e,r),n.id=e}let r=this.io.engine?.transport?.writable,i=this.connected&&!this.io.engine?._hasPingExpired();return this.flags.volatile&&!r||(i?(this.notifyOutgoingListeners(n),this.packet(n)):this.sendBuffer.push(n)),this.flags={},this}_registerAckCallback(e,t){let n=this.flags.timeout??this._opts.ackTimeout;if(n===void 0){this.acks[e]=t;return}let r=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,Error(`operation has timed out`))},n),i=(...e)=>{this.io.clearTimeoutFn(r),t.apply(this,e)};i.withError=!0,this.acks[e]=i}emitWithAck(e,...t){return new Promise((n,r)=>{let i=(e,t)=>e?r(e):n(t);i.withError=!0,t.push(i),this.emit(e,...t)})}_addToQueue(e){let t;typeof e[e.length-1]==`function`&&(t=e.pop());let n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...r)=>(this._queue[0],e===null?(this._queue.shift(),t&&t(null,...r)):n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)),n.pending=!1,this._drainQueue())),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||this._queue.length===0)return;let t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){typeof this.auth==`function`?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:W.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved(`connect_error`,e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved(`disconnect`,e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){let t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,Error(`socket has been disconnected`))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case W.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved(`connect_error`,Error(`It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)`));break;case W.EVENT:case W.BINARY_EVENT:this.onevent(e);break;case W.ACK:case W.BINARY_ACK:this.onack(e);break;case W.DISCONNECT:this.ondisconnect();break;case W.CONNECT_ERROR:this.destroy();let t=Error(e.data.message);t.data=e.data.data,this.emitReserved(`connect_error`,t);break}}onevent(e){let t=e.data||[];e.id!=null&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){let t=this._anyListeners.slice();for(let n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&typeof e[e.length-1]==`string`&&(this._lastOffset=e[e.length-1])}ack(e){let t=this,n=!1;return function(...r){n||(n=!0,t.packet({type:W.ACK,id:e,data:r}))}}onack(e){let t=this.acks[e.id];typeof t==`function`&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this._drainQueue(!0),this.emitReserved(`connect`)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose(`io server disconnect`)}destroy(){this.subs&&=(this.subs.forEach(e=>e()),void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:W.DISCONNECT}),this.destroy(),this.connected&&this.onclose(`io client disconnect`),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){let t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){let t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){let t=this._anyOutgoingListeners.slice();for(let n of t)n.apply(this,e.data)}}};function an(e){e||={},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}an.prototype.duration=function(){var e=this.ms*this.factor**+ this.attempts++;if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=Math.floor(t*10)&1?e+n:e-n}return Math.min(e,this.max)|0},an.prototype.reset=function(){this.attempts=0},an.prototype.setMin=function(e){this.ms=e},an.prototype.setMax=function(e){this.max=e},an.prototype.setJitter=function(e){this.jitter=e};var on=class extends V{constructor(e,t){super(),this.nsps={},this.subs=[],e&&typeof e==`object`&&(t=e,e=void 0),t||={},t.path=t.path||`/socket.io`,this.opts=t,$e(this,t),this.reconnection(t.reconnection!==!1),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(t.randomizationFactor??.5),this.backoff=new an({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(t.timeout==null?2e4:t.timeout),this._readyState=`closed`,this.uri=e;let n=t.parser||Wt;this.encoder=new n.Encoder,this.decoder=new n.Decoder,this._autoConnect=t.autoConnect!==!1,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return e===void 0?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return e===void 0?this._reconnectionDelay:(this._reconnectionDelay=e,(t=this.backoff)==null||t.setMin(e),this)}randomizationFactor(e){var t;return e===void 0?this._randomizationFactor:(this._randomizationFactor=e,(t=this.backoff)==null||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return e===void 0?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,(t=this.backoff)==null||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&this.backoff.attempts===0&&this.reconnect()}open(e){if(~this._readyState.indexOf(`open`))return this;this.engine=new jt(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=tn(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=tn(t,`error`,i);if(!1!==this._timeout){let e=this._timeout,n=this.setTimeoutFn(()=>{r(),i(Error(`timeout`)),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(r),this.subs.push(a),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState=`open`,this.emitReserved(`open`);let e=this.engine;this.subs.push(tn(e,`ping`,this.onping.bind(this)),tn(e,`data`,this.ondata.bind(this)),tn(e,`error`,this.onerror.bind(this)),tn(e,`close`,this.onclose.bind(this)),tn(this.decoder,`decoded`,this.ondecoded.bind(this)))}onping(){this.emitReserved(`ping`)}ondata(e){try{this.decoder.add(e)}catch(e){this.onclose(`parse error`,e)}}ondecoded(e){H(()=>{this.emitReserved(`packet`,e)},this.setTimeoutFn)}onerror(e){this.emitReserved(`error`,e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new rn(this,e,t),this.nsps[e]=n),n}_destroy(e){let t=Object.keys(this.nsps);for(let e of t)if(this.nsps[e].active)return;this._close()}_packet(e){let t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose(`forced close`)}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),(n=this.engine)==null||n.close(),this.backoff.reset(),this._readyState=`closed`,this.emitReserved(`close`,e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;let e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved(`reconnect_failed`),this._reconnecting=!1;else{let t=this.backoff.duration();this._reconnecting=!0;let n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved(`reconnect_attempt`,e.backoff.attempts),!e.skipReconnect&&e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved(`reconnect_error`,t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){let e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved(`reconnect`,e)}},sn={};function cn(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=Mt(e,t.path||`/socket.io`),r=n.source,i=n.id,a=n.path,o=sn[i]&&a in sn[i].nsps,s=t.forceNew||t[`force new connection`]||!1===t.multiplex||o,c;return s?c=new on(r,t):(sn[i]||(sn[i]=new on(r,t)),c=sn[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(cn,{Manager:on,Socket:rn,io:cn,connect:cn});var ln=({apiBaseUrl:e,userId:t,chatId:n,siteId:r})=>cn(e,{transports:[`polling`,`websocket`],upgrade:!0,rememberUpgrade:!1,auth:{userId:t,chatId:n,siteId:r},query:{chatId:n,siteId:r}}),un=({socket:e,chatId:t})=>{if(!e||!t||typeof window>`u`)return()=>{};let n=window.location.pathname+window.location.search,r=Date.now(),i=null,a=null,o=()=>{console.log(`[FlowEngageTracking] visitor:session_start`,{chatId:t,path:n}),e.emit(`visitor:session_start`,{chatId:t,path:n,title:document.title,referrer:document.referrer,userAgent:navigator.userAgent,timestamp:Date.now()})},s=()=>{console.log(`[FlowEngageTracking] visitor:page_enter`,{chatId:t,path:n}),e.emit(`visitor:page_enter`,{chatId:t,path:n,title:document.title,timestamp:Date.now()})},c=(n,r)=>{console.log(`[FlowEngageTracking] visitor:page_leave`,{chatId:t,path:n,duration:Math.max(0,Math.floor((Date.now()-r)/1e3))}),e.emit(`visitor:page_leave`,{chatId:t,path:n,duration:Math.max(0,Math.floor((Date.now()-r)/1e3)),timestamp:Date.now()})},l=()=>{console.log(`[FlowEngageTracking] visitor:heartbeat`,{chatId:t,path:n}),e.emit(`visitor:heartbeat`,{chatId:t,path:n,title:document.title,timestamp:Date.now()})},u=()=>{i&&window.clearInterval(i),i=window.setInterval(l,h)},d=()=>{i&&=(window.clearInterval(i),null)},f=r=>{console.log(`[FlowEngageTracking] visitor:visibility`,{chatId:t,state:r}),e.emit(`visitor:visibility`,{chatId:t,state:r,path:n,title:document.title,timestamp:Date.now()})},p=()=>{if(document.hidden){a&&window.clearTimeout(a),a=window.setTimeout(()=>{a=null,d(),f(`hidden`)},g);return}a&&=(window.clearTimeout(a),null),f(`visible`),l(),u()},m=()=>{let e=window.location.pathname+window.location.search;if(e===n){console.log(`[FlowEngageTracking] route unchanged`,{currentPath:n});return}console.log(`[FlowEngageTracking] route changed`,{from:n,to:e}),c(n,r),n=e,r=Date.now(),s()},_=window.history.pushState.bind(window.history),v=window.history.replaceState.bind(window.history);window.history.pushState=(...e)=>{_(...e),m()},window.history.replaceState=(...e)=>{v(...e),m()};let y=()=>{c(n,r),e.emit(`visitor:session_end`,{chatId:t,timestamp:Date.now()})},b=()=>{y()},x=e=>{e.persisted||y()};return window.addEventListener(`popstate`,m),window.addEventListener(`hashchange`,m),window.addEventListener(`beforeunload`,b),window.addEventListener(`pagehide`,x),window.addEventListener(`visibilitychange`,p),o(),document.hidden?a=window.setTimeout(()=>{a=null,d(),f(`hidden`)},g):(l(),u()),{notifyRouteChange:m,cleanup:()=>{a&&=(window.clearTimeout(a),null),d(),window.history.pushState=_,window.history.replaceState=v,window.removeEventListener(`popstate`,m),window.removeEventListener(`hashchange`,m),window.removeEventListener(`beforeunload`,b),window.removeEventListener(`pagehide`,x),window.removeEventListener(`visibilitychange`,p)}}},dn=(0,d.createContext)(null),fn=()=>{let e=(0,d.useContext)(dn);if(!e)throw Error(`useFlowEngage must be used inside FlowEngageProvider`);return e};function pn(){if(typeof window>`u`)return!1;try{let e=window.localStorage?.getItem(`FE_DEBUG_VOICE`);if(e===`0`||e===`false`)return!1;if(e===`1`||e===`true`)return!0}catch{}return window.__FE_DEBUG_VOICE_TOOLS__===!1?!1:window.__FE_DEBUG_VOICE_TOOLS__===!0}var mn=80;function hn(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=mn+(window.innerHeight-mn)/2,i=window.pageYOffset+n-r;window.scrollTo({top:Math.max(0,i),behavior:`smooth`})})}function gn(e){e&&(e.hasAttribute(`data-fe-highlighted`)||(_n(),e.classList?.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`),hn(e),e.setAttribute(`data-fe-orig-style`,e.style.cssText),e.setAttribute(`data-fe-highlighted`,`true`),e.style.outline=`3px solid #2563eb`,e.style.outlineOffset=`8px`,e.style.background=`rgba(37, 99, 235, 0.08)`,e.style.borderRadius=`8px`,e.style.padding=`12px 16px`,e.style.transition=`all 0.4s ease`))}function _n(){let e=document.querySelector(`[data-fe-highlighted]`);e&&(e.style.cssText=e.getAttribute(`data-fe-orig-style`)||``,e.removeAttribute(`data-fe-highlighted`),e.removeAttribute(`data-fe-orig-style`))}var vn=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`;function yn(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(vn)}catch{return!1}}function bn(e){let t=e.cloneNode(!0);return t.querySelectorAll(`[aria-hidden], svg, .icon, [class*="icon"]`).forEach(e=>e.remove()),t.textContent.replace(/\s+/g,` `).trim()}function G(...e){pn()&&console.log(`[FlowEngage:shadowNavigate]`,...e)}var xn=`fe_pending_nav_section`,Sn=15e3,Cn=`fe_voice_nav_state`,wn=2e4,Tn=!1,En=null;function Dn(e=3e3){Tn=!0,En&&clearTimeout(En),En=setTimeout(()=>{Tn=!1,En=null},e)}function On(){return Tn}var kn=!1,An=null;function jn(){kn||typeof window>`u`||(kn=!0,window.addEventListener(`popstate`,async()=>{let e=window.location.href;if(G(`popstate: body-swap to`,e),An){try{Bn(An)}catch{}try{Un(An)}catch{}}try{if(await ir(e,{skipPushState:!0,isBack:!0})){G(`popstate: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] popstate body-swap error:`,e)}G(`popstate: body-swap failed, falling back to reload`),window.location.reload()}))}var Mn=!1;function Nn(){Mn||typeof window>`u`||typeof document>`u`||(Mn=!0,document.addEventListener(`click`,async e=>{try{if(!window.history.state?.flowengageSpa)return}catch{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)){e.preventDefault(),e.stopPropagation(),G(`link-intercept: body-swap to`,r.href),qn();try{try{Bn()}catch{}try{Un()}catch{}if(await ir(r.href)){G(`link-intercept: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] link-intercept body-swap error:`,e)}G(`link-intercept: body-swap failed, falling back to normal navigation`),Jn(),window.location.href=r.href}},!0))}var Pn=null;function Fn(e){Pn=e===`spa`||e===`traditional`?e:null}function In(){if(typeof window>`u`||Pn===`traditional`)return null;if(window.next?.router||window.__NEXT_ROUTER__)return`nextjs`;if(window.__remixRouter||window.__staticRouterHydrationData)return`react-router`;if(window.___gatsby||window.___navigate)return`gatsby`;if(window.__VUE_ROUTER__)return`vue-router`;if(window.__NUXT__||window.$nuxt)return`nuxt`;if(window.ng?.getComponent||document.querySelector(`[ng-version]`))return`angular`;if(window[Symbol.for(`wouter_v3`)])return`wouter`;if(window.__sveltekit_data||document.querySelector(`[data-sveltekit-hydrate]`))return`sveltekit`;if(document.querySelector(`[data-astro-transition]`))return`astro`;for(let e of document.body.children)if(e.tagName?.toUpperCase()===`DIV`&&e.id!==`flowengage-root`&&(e.id===`root`||e.id===`app`)&&e.children.length>0)return`generic-spa`;return Pn===`spa`?`backend-spa`:null}var Ln=`data-fe-swap-css`;function Rn(){typeof document>`u`||document.querySelectorAll(`[${Ln}]`).forEach(e=>e.remove())}var zn=`fe_form_state:`;function Bn(e){if(typeof document>`u`||typeof sessionStorage>`u`)return;let t=document.querySelectorAll(`form`);if(!t.length)return;let n=[];if(t.forEach((e,t)=>{let r={};e.querySelectorAll(`input, textarea, select`).forEach(e=>{let t=e.name||e.id;t&&(e.type===`password`||e.type===`hidden`||(e.type===`checkbox`||e.type===`radio`?r[t+`::`+e.value]=e.checked:r[t]=e.value))}),Object.keys(r).length&&n.push({formIndex:t,fields:r})}),n.length)try{let t=zn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({state:n,ts:Date.now()}))}catch{}}function Vn(){if(typeof document>`u`||typeof sessionStorage>`u`)return;let e=zn+window.location.pathname,t;try{t=JSON.parse(sessionStorage.getItem(e)||`null`)}catch{return}if(!t||!t.state)return;if(Date.now()-t.ts>1800*1e3){try{sessionStorage.removeItem(e)}catch{}return}let n=document.querySelectorAll(`form`);for(let{formIndex:e,fields:r}of t.state){let t=n[e];if(t)for(let[e,n]of Object.entries(r))if(e.includes(`::`)){let[r,i]=e.split(`::`),a=t.querySelector(`input[name="${r}"][value="${i}"], input[id="${r}"][value="${i}"]`);a&&(a.checked=!!n)}else{let r=t.querySelector(`[name="${e}"], [id="${e}"]`);if(r&&r.type!==`file`){r.value=n;try{r.dispatchEvent(new Event(`input`,{bubbles:!0}))}catch{}try{r.dispatchEvent(new Event(`change`,{bubbles:!0}))}catch{}}}}try{sessionStorage.removeItem(e)}catch{}}var Hn=`fe_scroll:`;function Un(e){if(!(typeof window>`u`||typeof sessionStorage>`u`))try{let t=Hn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({y:window.scrollY,ts:Date.now()}))}catch{}}function Wn(){if(typeof window>`u`||typeof sessionStorage>`u`)return;let e=Hn+window.location.pathname,t;try{t=JSON.parse(sessionStorage.getItem(e)||`null`)}catch{return}if(t){try{sessionStorage.removeItem(e)}catch{}Date.now()-t.ts>1800*1e3||setTimeout(()=>{window.scrollTo({top:t.y,behavior:`instant`})},80)}}function Gn(e){if(!(typeof window>`u`))try{window.dispatchEvent(new CustomEvent(`flowengage:pageswap`,{detail:{url:e,timestamp:Date.now()}}))}catch{}}var Kn=`fe-nav-loader`;function qn(){if(typeof document>`u`||document.getElementById(Kn))return;let e=document.createElement(`div`);e.id=Kn,e.style.cssText=[`position:fixed`,`top:0`,`left:0`,`width:0`,`height:3px`,`background:linear-gradient(90deg,#7c3aed,#6366f1)`,`z-index:2147483647`,`transition:width 0.4s ease`,`pointer-events:none`].join(`;`),document.body.appendChild(e),requestAnimationFrame(()=>{e.style.width=`70%`})}function Jn(){if(typeof document>`u`)return;let e=document.getElementById(Kn);e&&(e.style.width=`100%`,setTimeout(()=>{e.style.opacity=`0`,e.style.transition=`opacity 0.3s ease`,setTimeout(()=>e.remove(),350)},200))}function Yn(){if(typeof window>`u`||typeof document>`u`)return;try{window.history.state?.flowengageSpa&&jn()}catch{}let e;try{e=JSON.parse(sessionStorage.getItem(xn)||`null`)}catch{return}if(!e)return;try{sessionStorage.removeItem(xn)}catch{}let{sectionText:t,ts:n}=e;if(!t)return;if(Date.now()-n>Sn){G(`initNavigationHighlight: pending section expired, skipping:`,t);return}G(`initNavigationHighlight: replaying section highlight:`,t);let r=0,i=()=>{r+=1;let e=Zn(null,t);if(e){Qn(e),G(`initNavigationHighlight: highlighted on attempt`,r);return}r<8?setTimeout(i,300):G(`initNavigationHighlight: could not find element after 8 attempts:`,t)};setTimeout(i,250)}var Xn=()=>{if(typeof document>`u`||document.getElementById(`fe-highlight-styles`))return;let e=document.createElement(`style`);e.id=`fe-highlight-styles`,e.textContent=`
2
2
  .fe-highlight-section {
3
3
  outline: 3px solid #7c3aed !important;
4
4
  box-shadow: 0 0 15px rgba(124, 58, 237, 0.6) !important;
@@ -22,11 +22,11 @@
22
22
  box-shadow: none !important;
23
23
  transition: outline-color 0.25s ease, box-shadow 0.25s ease !important;
24
24
  }
25
- `,document.head.appendChild(e)};function Qn(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(bn(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(xn(e).toLowerCase()===n)return e;for(let e of i){let t=xn(e).toLowerCase();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=xn(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=xn(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=xn(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=>!bn(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(bn(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(bn(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(bn(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=>!bn(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(bn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function $n(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;Zn();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 er(){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`)),vn())}function tr(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 nr(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 rr(e,{siteId:t,apiBaseUrl:n}){if(!e)return{allowed:!1,correctedUrl:null};let r=!1;try{r=!!Ln()}catch{r=!1}let i=async()=>({allowed:r?!1:await nr(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 ir(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Sn,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function ar(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}Jn();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 Yn(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return Yn(),!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()}),zn();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(Rn,`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(Rn,`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,W(`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){W(`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,W(`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){W(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){W(`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;W(`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)){W(`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:`)&&(W(`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`)||``}),W(`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),W(`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(Mn(),Pn(),n){try{Hn()}catch{}try{Gn()}catch{}}else window.scrollTo(0,0);Yn(),Kn(e);try{sessionStorage.removeItem(Sn)}catch{}try{sessionStorage.removeItem(wn)}catch{}try{jn=new URL(e,window.location.origin).pathname}catch{}return W(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),Yn(),!1}}function or(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(wn,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function sr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(wn)}catch{}}function cr(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(wn)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(wn)}catch{}return e.voiceWasActive?Date.now()-e.ts>Tn?(W(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(W(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}function lr(){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 ur(e,t={}){if(typeof window>`u`)return{navigated:!1};let{sectionText:n,voiceActive:r=!1}=t;try{let t=tr(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(Ln()){n&&ir(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)),lr()){try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return n&&ir(n),r||be(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&ir(n),r||be(),window.location.assign(i.href),{navigated:!0}}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&ir(n);try{window.location.href=tr(e)}catch{window.location.href=e}return{navigated:!0}}}var dr=!1,fr=null;function pr(e){fr=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!dr&&(dr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!fr)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)){W(`voice-link-hook: saving state before navigation →`,r.href);try{fr.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(fr&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){W(`voice-form-hook: saving state before form submit`);try{fr.onBeforeNavigate()}catch{}}},!0)))}function mr(){fr=null,W(`voice-nav-hooks: deactivated`)}var hr=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(),gr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:hr(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function _r(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 vr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,yr=(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}:{}}},br=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},xr=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Sr({siteId:e,config:t,children:n,language:r=`en`}){let i=(0,d.useMemo)(()=>e?{...t||{},siteId:e}:t||null,[e,t]),[a,o]=(0,d.useState)(0),[s,c]=(0,d.useState)(`booting`),[l,u]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[x,S]=(0,d.useState)([]),E=(0,d.useCallback)(()=>{S(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()}])},[]),ee=(0,d.useCallback)(()=>{S(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()}])},[]),[D,O]=(0,d.useState)(ie().isOpen),[k,ce]=(0,d.useState)(ie().activeScreen),[le,A]=(0,d.useState)(ie().isHumanHandled),[de,j]=(0,d.useState)(ie().agentName),[fe,pe]=(0,d.useState)(ie().agentHeadshot),[me,he]=(0,d.useState)(()=>oe(i?.siteId)),[ge,ve]=(0,d.useState)(!1),[ye,be]=(0,d.useState)(!1),[xe,Se]=(0,d.useState)(`idle`),[M,N]=(0,d.useState)(!1),[Ce,we]=(0,d.useState)(!1),[P,I]=(0,d.useState)(``),[De,Oe]=(0,d.useState)(!1),[ke,Ae]=(0,d.useState)(0),[je,Me]=(0,d.useState)(0),[Ne,Pe]=(0,d.useState)(!1),[L,Fe]=(0,d.useState)(null),[Ie,Le]=(0,d.useState)(null),[Re,ze]=(0,d.useState)(`idle`),[Be,Ve]=(0,d.useState)(null),[He,Ue]=(0,d.useState)(!1),[We,Ge]=(0,d.useState)(``),[Ke,qe]=(0,d.useState)(!1),R=(0,d.useRef)(null),z=(0,d.useRef)(null),Je=(0,d.useRef)(``),B=(0,d.useRef)(!1),Ye=(0,d.useRef)(null),V=(0,d.useRef)(null),H=(0,d.useRef)(null),Xe=(0,d.useRef)(null),Ze=(0,d.useRef)(null),Qe=(0,d.useRef)(null),$e=(0,d.useRef)(null),et=(0,d.useRef)(!1),tt=(0,d.useRef)({url:null,at:0}),nt=(0,d.useCallback)((e,t)=>{let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=tt.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(tt.current={url:n,at:Date.now()},ur(e,t))},[]),rt=(0,d.useRef)([]),it=(0,d.useRef)(null),at=(0,d.useRef)(null),ot=(0,d.useRef)(null),st=(0,d.useRef)(!1),ct=(0,d.useRef)(!1),lt=(0,d.useRef)(``),ut=(0,d.useRef)(null),dt=(0,d.useRef)(null),ft=(0,d.useRef)([]),pt=(0,d.useRef)(0),mt=(0,d.useRef)(de),ht=(0,d.useRef)([]),gt=(0,d.useRef)(!1),_t=(0,d.useRef)(!1),vt=(0,d.useRef)(i),yt=(0,d.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),bt=(0,d.useCallback)((e={})=>{let t=!!e.is_human_handled;return A(t),t?(ce(`agent`),e.agent_info?.name&&j(e.agent_info.name),e.agent_info?.headshot&&pe(e.agent_info.headshot),t):(ce(`ai`),t)},[]),xt=(0,d.useMemo)(()=>{let e=m?.widgetSettings?.call?.maxDurationSeconds??i?.widgetSettings?.call?.maxDurationSeconds??i?.callMaxDurationSeconds,t=Number(e);return Number.isFinite(t)&&t>0?t:y},[i,m]);(0,d.useEffect)(()=>{V.current=L},[L]),(0,d.useEffect)(()=>{mt.current=de},[de]),(0,d.useEffect)(()=>{_t.current=De},[De]),(0,d.useEffect)(()=>{vt.current=i},[i]);let St=()=>{Ge(``)},Ct=(0,d.useCallback)(()=>{ot.current&&=(window.clearTimeout(ot.current),null)},[]),wt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return he(t),se(t,i?.siteId),t};(0,d.useEffect)(()=>{let e=i?.siteId;e&&he(oe(e))},[i?.siteId]);let Tt=(e=`unspecified`)=>{let t=it.current||Qe.current?.callId,n=pt.current,r=ut.current;if(ut.current=null,pt.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=ft.current;if(ft.current=[],e.length>0&&t&&z.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;z.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,ft.current=[]}}else if(r&&r.state===`inactive`){let e=ft.current;if(ft.current=[],e.length>0&&t&&z.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;z.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else ft.current=[];if(dt.current){try{dt.current.close()}catch{}dt.current=null}H.current&&=(H.current.close(),null),Xe.current&&=(Xe.current.getTracks().forEach(e=>e.stop()),null),Ze.current&&=(Ze.current.srcObject=null,Ze.current.remove(),null),Ct(),Qe.current=null,rt.current=[],it.current=null,at.current=null,st.current=!1,Ue(!1),Fe(null),Le(null),ze(`idle`),Ve(null)},Et=(e=new Date().toISOString())=>{let t=R.current,n=it.current||Qe.current?.callId;if(!(!t?.connected||!n||st.current)){st.current=!0,t.emit(`call:connected`,{callId:n,chatId:Je.current,connectedAt:e});try{let e=Xe.current,t=Ze.current?.srcObject;if(e&&t&&!ut.current){ft.current=[];let n=new(window.AudioContext||window.webkitAudioContext);dt.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&&ft.current.push(e.data)},ut.current=a,pt.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{}}},Dt=(e={})=>{if(!e.callId)return;let t=at.current===e.callId,n=it.current===e.callId,r=V.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Ct(),Fe(null),t||n){it.current=e.callId,Le(e.callId),ze(e=>e===`connected`?e:`connecting`),O(!0);return}ze(`idle`)}},Ot=(e={})=>{if(!e.callId)return;let t=at.current===e.callId,n=it.current===e.callId,r=V.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Ct(),n){Tt();return}at.current=null,Qe.current=null,rt.current=[],Fe(null),ze(`idle`)}},kt=async(e={})=>{let t=H.current,n=R.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:Je.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),Qe.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),rt.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:Je.current,queuedCount:rt.current.length});for(let e of rt.current)await t.addIceCandidate(new RTCIceCandidate(e));rt.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:Je.current})};(0,d.useEffect)(()=>{ae({isOpen:D,activeScreen:k,isHumanHandled:le,agentName:de,agentHeadshot:fe})},[D,k,le,de,fe]),(0,d.useEffect)(()=>{let e=!0;return(async()=>{qe(!0);try{let t=p(i),n=await Te(t);if(!e)return;let a=t.siteId,o=te(a),s=ue(a),l=``;try{let e=B.current,r=Ye.current;if(B.current=!1,Ye.current=null,l=(await F({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||C(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);w(),re(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||T(),re(a,l)}Je.current=l;let u=Ee({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});z.current=u,h({...n,apiBaseUrl:t.apiBaseUrl}),_(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,f=un({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});R.current=f,f.on(`connect`,async()=>{Se(`connected`);let e=Je.current;if(e&&z.current)try{bt(await z.current.checkHumanHandled(e))}catch{}}),f.on(`disconnect`,()=>{Se(`disconnected`)}),f.on(`aiTyping`,()=>{be(!0)}),f.on(`ai:typing`,()=>{be(!0)}),f.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:hr(t.message)};be(!1),ve(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&S(e=>[...e.filter(e=>!e.isPending),{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}])}),f.on(`conversationStarted`,e=>{e?.message&&S(t=>[...t,{id:`system-start-${Date.now()}`,sender:`system`,message:e.message,timestamp:new Date().toISOString(),isPending:!1}])}),f.on(`message:new`,e=>{let t=e.message||e,n={...t,message:hr(t.message)};be(!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`)&&ve(!1),S(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)&&(A(!0),ce(`agent`),j(br([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&pe(n.sender_headshot),O(!0),Ae(e=>e+1)))});let m=(e={})=>{let t=br([e.agent?.name,e.agentName,e.agent_name,mt.current],d);A(!0),ce(`agent`),j(t),pe(e.agent?.headshot||null),O(!0),Ae(e=>e+1),S(e=>xr(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},g=(e={})=>{let t=br([e.agent?.name,e.agentName,e.agent_name,mt.current],d);A(!1),ce(`ai`),S(e=>xr(e,{id:`agent-left-${Date.now()}`,sender:`system`,message:`${t} has left the chat.`,timestamp:new Date().toISOString(),isPending:!1}))};f.on(`agent:joined`,m),f.on(`agentJoined`,m),f.on(`agent:left`,g),f.on(`agentLeft`,g),f.on(`conversationEnded`,e=>{Pe(!0);let t=e?.message||`This conversation has ended. Thank you for reaching out!`;S(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:t,timestamp:new Date().toISOString(),isPending:!1}])}),f.on(`chat:history_update`,e=>{let t=gr(e.chat_history||[]);S(t),t.length===0&&(Pe(!1),A(!1),ce(`ai`),be(!1),ve(!1))}),f.on(`conversation:reset`,()=>{S([]),Pe(!1),A(!1),ce(`ai`),be(!1),ve(!1)}),f.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),Me(e=>e+1),O(!0),Ae(e=>e+1)}),f.on(`typing:start`,e=>{e.sender===`agent`&&ve(!0)}),f.on(`typing:stop`,e=>{e.sender===`agent`&&ve(!1)}),f.on(`call:incoming`,(e={})=>{let t=br([e.agentName,e.ownerName,e.agent?.name,mt.current],`Agent`);St(),Ct(),st.current=!1,Fe({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),j(e=>br([t,e],`Agent`)),ze(`incoming`),Ve(null),O(!0)}),f.on(`call:offer`,async(e={})=>{Qe.current=e;try{await kt(e)}catch(e){console.error(`[FlowEngageProvider] failed to apply remote offer`,e)}}),f.on(`call:ice-candidate-from-agent`,async(e={})=>{if(e.candidate)try{let t=yr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!H.current||!H.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||Je.current,queueSize:rt.current.length+1}),rt.current.push(t);return}await H.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),f.on(`call:ended`,()=>{St(),Tt(`socket:call_ended`)}),f.on(`call:accepted`,(e={})=>{Dt(e)}),f.on(`call:accepted_by_other`,(e={})=>{Dt(e)}),f.on(`call:rejected`,(e={})=>{Ot(e)}),f.on(`call:missed`,(e={})=>{Ot(e)}),f.on(`call:failed`,(e={})=>{Ot(e)}),f.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=at.current===e.callId,n=it.current===e.callId,r=Qe.current?.callId===e.callId,i=V.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Fe(null),ze(`idle`));return}st.current=!0,at.current=null,it.current=e.callId,Le(e.callId),Fe(null),ze(`connected`),Ve(e.connectedAt||new Date().toISOString()),O(!0)}),f.on(`call:unavailable`,(e={})=>{Tt(`socket:call_unavailable`),Ge(vr(e,`This visitor is not available for a call right now.`)),O(!0)}),f.on(`call:error`,(e={})=>{Tt(`socket:call_error`),Ge(vr(e,`We couldn't connect the call right now.`)),O(!0)}),f.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&nt(e,{voiceActive:_t.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?E():r===`already-on-page`&&ee();return}let i=t||n;!i||!_t.current||setTimeout(()=>{let e=Qn(null,i);e&&$n(e)},300)})}),f.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=Qn(e||null,t||null);n&&$n(n)}),f.on(`visitor:clear_highlight`,()=>{er()}),yt.current=dn({socket:f,chatId:l});let v=await u.loadHistory(l,r);if(!e)return;S(gr(v.chat_history||[])),A(!!v.is_human_handled),ce(v.is_human_handled?`agent`:k);let y=v?.visitor_email||v?.visitorEmail;if(y&&String(y).trim()&&wt(String(y).trim()),await new Promise(e=>setTimeout(e,500)),!e)return;c(`ready`)}catch(t){if(!e)return;u(t),c(`error`)}finally{e&&qe(!1)}})(),()=>{e=!1,yt.current?.cleanup?.(),Tt(),R.current?.disconnect()}},[i,r,a]),(0,d.useEffect)(()=>()=>{if(De&&!gt.current&&ht.current.length>0){let e=Je.current,t=ht.current,n=z.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(()=>{}),gt.current=!0)}},[De,m]);let At=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=z.current;!e||!g||At.current!==D&&(D&&At.current!==null?e.updateChatStatus(g,`open`).catch(()=>{}):At.current===!0&&e.updateChatStatus(g,`widget_closed`).catch(()=>{}),At.current=D)},[D,g]),(0,d.useEffect)(()=>{let e=()=>{let e=Je.current,t=z.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 jt=async()=>{if(!(!L?.callId||!z.current||!R.current||!g)){St(),at.current=L.callId,Ct();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});Xe.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await z.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});H.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();ze(`connected`),Ve(t=>t||e),Et(e);return}if(e===`connecting`){ze(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Tt(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();ze(`connected`),Ve(t=>t||e),Et(e);return}if(e===`checking`||e===`new`){ze(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&Tt(`peer:ice_${e}`)},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!R.current?.connected)return;let t=e.candidate;R.current.emit(`call:ice-candidate`,{callId:L.callId,candidate:t.candidate,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex,chatId:g,from:`customer`})},n.ontrack=e=>{let[t]=e.streams||[],[n]=t?.getAudioTracks?.()||[];if(!Ze.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=>{},Ze.current=e,document.body.appendChild(e)}Ze.current.srcObject=e.streams[0];let r=L?.callId,i=r&&(at.current===r||it.current===r);if(!st.current&&i){let e=new Date().toISOString();ze(`connected`),Ve(t=>t||e),it.current=r,Le(r),Et(e)}Ze.current.srcObject=t||null;let a=Ze.current.play?.();a?.catch&&a.catch(e=>{})};let r=Qe.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||L.callId,chatId:g}),await kt({...r,callId:r.callId||L.callId})),await z.current.acceptCall(L.callId,g),R.current?.emit(`call:accepted`,{callId:L.callId,chatId:g}),it.current=L.callId,Le(L.callId),ze(e=>e===`connected`||st.current?`connected`:`connecting`),Fe(null),O(!0)}catch(e){if(at.current=null,Tt(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){Ge(vr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await z.current.rejectCall(L.callId,g)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}Ge(`Microphone access was denied. Please allow microphone access to accept the call.`);return}Ge(`We couldn't connect the call right now. Please try again.`)}}},Mt=async()=>{if(!L?.callId||!z.current||!g){Tt(`reject_call_without_server_context`);return}let e=L.callId;Ct(),St(),R.current?.emit(`call:rejected`,{callId:e,chatId:g,reason:`visitor_declined`});try{await z.current.rejectCall(e,g)}catch(e){Ge(vr(e,`We couldn't decline the call cleanly.`))}finally{Tt(`reject_call_finally`)}},Nt=(0,d.useRef)(Mt);Nt.current=Mt,(0,d.useEffect)(()=>{if(!L?.callId||Ie){Ct();return}let e=L.callId;return Ct(),ot.current=window.setTimeout(()=>{V.current?.callId===e&&at.current!==e&&it.current!==e&&Nt.current()},b),()=>{ot.current&&=(window.clearTimeout(ot.current),null)}},[Ie,Ct,L?.callId]);let Pt=async()=>{if(!Ie||!z.current||!g){Tt(`end_call_without_server_context`);return}St();try{await z.current.endWebRTCCall(Ie,g)}catch(e){Ge(vr(e,`The call ended locally, but the server could not be updated.`))}finally{Tt(`end_call_finally`)}},Ft=()=>{let e=Xe.current?.getAudioTracks?.()||[],t=H.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!He;n.forEach(e=>{e.enabled=!r}),Ue(r)},It=async(e={})=>{let t=e.notifyChatInitiated===!0;if(O(!0),!(!t||!z.current||!g||typeof window>`u`)){try{await z.current.trackVisitor({chatId:g,currentPagePath:window.location.pathname||`/`})}catch{}try{await z.current.updateChatStatus(g,`open`)}catch{}}},Lt=async e=>{let t=wt(e);if(!t||!z.current||!Je.current)return t;try{await z.current.trackVisitor({chatId:Je.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},Rt=()=>{!g||!R.current?.connected||ct.current||(ct.current=!0,R.current.emit(`typing:start`,{chatId:g,sender:`user`}))},zt=()=>{!g||!R.current?.connected||!ct.current||(ct.current=!1,R.current.emit(`typing:stop`,{chatId:g,sender:`user`}))},Bt=(e=``)=>{let t=typeof e==`string`?e:``;!g||!R.current?.connected||t!==``&&lt.current===t||(lt.current=t,R.current.emit(`typing:update`,{chatId:g,sender:`user`,text:t}))};function Vt(){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 Ht=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!z.current||!g||s!==`ready`||Ne)return;zt(),et.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($e.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=$e.current;$e.current=null,et.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),nt(e,{voiceActive:_t.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?E():n===`already-on-page`&&ee();return}!t||!_t.current||setTimeout(()=>{let e=Qn(null,t);e&&$n(e)},300)})}else o.test(a)||($e.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||{}};S(e=>[...e,f]);let p=le;if(p)try{p=bt(await z.current.checkHumanHandled(g))}catch{}if(p&&R.current?.connected){R.current.emit(`customer:message`,{chatId:g,content:e,sender:`user`,email:me||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}N(!0);try{let o=await z.current.sendAiMessage(g,e,r,t,{...n||{},...me?{email:me}:{}},{...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:Vt()||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),nt(e.url,{voiceActive:_t.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?E():n===`already-on-page`&&ee();return}e.section&&setTimeout(()=>{let t=Qn(null,e.section);t&&$n(t)},300)})):($e.current=e,console.log(`[FWH Nav] Stored pending nav →`,$e.current))}if(o.navigate?.url)if(et.current)et.current=!1;else{let{url:e,section:t}=o.navigate;nt(e,{voiceActive:_t.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?E():n===`already-on-page`&&ee();return}!t||!_t.current||setTimeout(()=>{let e=Qn(null,t);e&&$n(e)},300)})}else{let e=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=_r(e.message);t&&rr(t.url,{siteId:vt.current?.siteId,apiBaseUrl:vt.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){E();return}nt(n||t.url,{voiceActive:_t.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?E():n===`already-on-page`&&ee();return}!t.section||!_t.current||setTimeout(()=>{let e=Qn(null,t.section);e&&$n(e)},300)})})}}S(gr(s)),A(!!o.is_human_handled),ce(o.is_human_handled?`agent`:`ai`),be(!1),N(!1),await z.current.updateChatStatus(g,`messageSent`)}catch(e){S(e=>e.filter(e=>e.id!==d)),be(!1),N(!1),e.status===429?(we(!0),I(e.message),window.setTimeout(()=>{we(!1),I(``)},v)):u(e)}},Ut=async e=>{if(!z.current||!e)throw Error(`Upload is unavailable right now.`);return z.current.uploadChatFile(e)},Wt=async e=>{if(!(!z.current||!g)){try{let t=e?`voice`:`text`;await z.current.setChatMode(g,t)}catch{}Oe(e),e&&(gt.current=!1)}},Gt=async e=>{if(gt.current)return;if(gt.current=!0,!z.current||!g||!e?.length){Oe(!1);return}let t=()=>{let t=gr(e);S(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 z.current.syncVoice(g,e);if(n?.chat_history?.length)S(gr(n.chat_history));else if(n?.success)try{let e=await z.current.loadHistory(g,r);e?.chat_history?.length?S(gr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{Oe(!1)}},Kt=async()=>{if(!(!z.current||!g)){De&&!gt.current&&ht.current.length>0&&await Gt(ht.current);try{await z.current.endConversation(g)}catch{try{await z.current.updateChatStatus(g,`ended`)}catch{}}Pe(!0),S(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,d.useEffect)(()=>{if(Re!==`connected`||!Ie||!g||!Be||!xt)return;let e=new Date(Be).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,xt*1e3-t),r=window.setTimeout(()=>{Ge(`The call ended because it reached the time limit.`),Pt()},n);return()=>window.clearTimeout(r)},[Ie,Be,Re,g,Pt,xt]),(0,d.useEffect)(()=>{let e=()=>{let e=Je.current,t=z.current;if(!t||!e)return;if(_t.current&&ht.current.length>0&&_e(),!gt.current&&ht.current.length>0&&(t.beaconSyncVoice(e,ht.current)||t.syncVoice(e,ht.current).catch(()=>{}),gt.current=!0),it.current){t.beaconEndWebRTCCall(it.current,e);return}let n=at.current||V.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 U=(0,d.useCallback)(()=>{let e=i?.siteId;ne(e),B.current=!0,Ye.current=null,R.current?.disconnect(),S([]),_(``),Je.current=``,Pe(!1),A(!1),j(null),pe(null),qe(!0),o(e=>e+1)},[i?.siteId]),qt=(0,d.useCallback)(e=>{i?.siteId,B.current=!1,Ye.current=e,R.current?.disconnect(),S([]),_(``),Je.current=``,Pe(!1),A(!1),j(null),pe(null),qe(!0),o(e=>e+1)},[i?.siteId]),Jt=(0,d.useMemo)(()=>({status:s,error:l,runtimeConfig:m,resolvedConfig:i,chatId:g,chatHistory:x,isOpen:D,activeScreen:k,isHumanHandled:le,agentName:de,agentHeadshot:fe,visitorEmail:me,isAgentTyping:ge,isAiTyping:ye,connectionStatus:xe,isLoading:M,isVoiceMode:De,isRateLimited:Ce,rateLimitMessage:P,isConversationEnded:Ne,isSessionRestoring:Ke,openToChatCounter:ke,voiceEndCounter:je,incomingCall:L,activeCallId:Ie,callConnectionState:Re,callConnectedAt:Be,isCallMuted:He,webRTCError:We,language:r,historyRef:ht,hasSyncedRef:gt,dismissCallError:St,captureVisitorEmail:Lt,startTyping:Rt,stopTyping:zt,updateTypingDraft:Bt,notifyRouteChange:()=>yt.current?.notifyRouteChange?.(),openWidget:It,closeWidget:()=>O(!1),toggleWidget:()=>{if(D){O(!1);return}It({notifyChatInitiated:!0})},sendMessage:Ht,uploadChatFile:Ut,setVoiceMode:Wt,onMessageSync:Gt,endConversation:Kt,startNewChat:U,resumeChat:qt,getVisitorChatHistory:()=>z.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>z.current?.getVisitorChatThread?.(e),acceptCall:jt,rejectCall:Mt,endWebRTCCall:Pt,toggleCallMute:Ft}),[s,l,m,i,g,x,D,k,le,de,fe,me,ge,ye,xe,M,De,Ce,P,Ne,Ke,ke,je,L,Ie,Re,Be,He,We,r,Lt,Rt,zt,Bt,jt,Mt,Pt,Ft,It,Ht,Ut,Wt,Gt,Kt,U,St]);return(0,f.jsx)(fn.Provider,{value:Jt,children:n})}var Cr=(0,d.createContext)({});function wr(e){let t=(0,d.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Tr=typeof window<`u`?d.useLayoutEffect:d.useEffect,Er=(0,d.createContext)(null);function Dr(e,t){e.indexOf(t)===-1&&e.push(t)}function Or(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var kr=(e,t,n)=>n>t?t:n<e?e:n;function Ar(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var jr=()=>{},Mr=()=>{};typeof process<`u`&&process.env.NODE_ENV!==`production`&&(jr=(e,t,n)=>{!e&&typeof console<`u`&&console.warn(Ar(t,n))},Mr=(e,t,n)=>{if(!e)throw Error(Ar(t,n))});var Nr={},Pr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Fr(e){return typeof e==`object`&&!!e}var Ir=e=>/^0[^.\s]+$/u.test(e);function Lr(e){let t;return()=>(t===void 0&&(t=e()),t)}var Rr=e=>e,zr=(e,t)=>n=>t(e(n)),Br=(...e)=>e.reduce(zr),Vr=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Hr=class{constructor(){this.subscriptions=[]}add(e){return Dr(this.subscriptions,e),()=>Or(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}},Ur=e=>e*1e3,Wr=e=>e/1e3;function Gr(e,t){return t?1e3/t*e:0}var Kr=new Set;function qr(e,t,n){e||Kr.has(t)||(console.warn(Ar(t,n)),Kr.add(t))}var Jr=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Yr=1e-7,Xr=12;function Zr(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=Jr(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Yr&&++s<Xr);return o}function Qr(e,t,n,r){if(e===t&&n===r)return Rr;let i=t=>Zr(t,0,1,e,n);return e=>e===0||e===1?e:Jr(i(e),t,r)}var $r=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ei=e=>t=>1-e(1-t),ti=Qr(.33,1.53,.69,.99),ni=ei(ti),ri=$r(ni),ii=e=>e>=1?1:(e*=2)<1?.5*ni(e):.5*(2-2**(-10*(e-1))),ai=e=>1-Math.sin(Math.acos(e)),oi=ei(ai),si=$r(ai),ci=Qr(.42,0,1,1),li=Qr(0,0,.58,1),ui=Qr(.42,0,.58,1),di=e=>Array.isArray(e)&&typeof e[0]!=`number`,fi=e=>Array.isArray(e)&&typeof e[0]==`number`,pi={linear:Rr,easeIn:ci,easeInOut:ui,easeOut:li,circIn:ai,circInOut:si,circOut:oi,backIn:ni,backInOut:ri,backOut:ti,anticipate:ii},mi=e=>typeof e==`string`,hi=e=>{if(fi(e)){Mr(e.length===4,`Cubic bezier arrays must contain four numerical values.`,`cubic-bezier-length`);let[t,n,r,i]=e;return Qr(t,n,r,i)}else if(mi(e))return Mr(pi[e]!==void 0,`Invalid easing type '${e}'`,`invalid-easing-type`),pi[e];return e},gi=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],_i={value:null,addProjectionMetrics:null};function vi(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&&_i.value&&_i.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var yi=40;function bi(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=gi.reduce((e,n)=>(e[n]=vi(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=Nr.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,yi),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:gi.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<gi.length;t++)o[gi[t]].cancel(e)},state:i,steps:o}}var{schedule:G,cancel:xi,state:Si,steps:Ci}=bi(typeof requestAnimationFrame<`u`?requestAnimationFrame:Rr,!0),wi;function Ti(){wi=void 0}var Ei={now:()=>(wi===void 0&&Ei.set(Si.isProcessing||Nr.useManualTiming?Si.timestamp:performance.now()),wi),set:e=>{wi=e,queueMicrotask(Ti)}},Di={layout:0,mainThread:0,waapi:0},Oi=e=>t=>typeof t==`string`&&t.startsWith(e),ki=Oi(`--`),Ai=Oi(`var(--`),ji=e=>Ai(e)?Mi.test(e.split(`/*`)[0].trim()):!1,Mi=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ni(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Pi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Fi={...Pi,transform:e=>kr(0,1,e)},Ii={...Pi,default:1},Li=e=>Math.round(e*1e5)/1e5,Ri=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function zi(e){return e==null}var Bi=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Vi=(e,t)=>n=>!!(typeof n==`string`&&Bi.test(n)&&n.startsWith(e)||t&&!zi(n)&&Object.prototype.hasOwnProperty.call(n,t)),Hi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ri);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Ui=e=>kr(0,255,e),Wi={...Pi,transform:e=>Math.round(Ui(e))},Gi={test:Vi(`rgb`,`red`),parse:Hi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Wi.transform(e)+`, `+Wi.transform(t)+`, `+Wi.transform(n)+`, `+Li(Fi.transform(r))+`)`};function Ki(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 qi={test:Vi(`#`),parse:Ki,transform:Gi.transform},Ji=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Yi=Ji(`deg`),Xi=Ji(`%`),K=Ji(`px`),Zi=Ji(`vh`),Qi=Ji(`vw`),$i={...Xi,parse:e=>Xi.parse(e)/100,transform:e=>Xi.transform(e*100)},ea={test:Vi(`hsl`,`hue`),parse:Hi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Xi.transform(Li(t))+`, `+Xi.transform(Li(n))+`, `+Li(Fi.transform(r))+`)`},q={test:e=>Gi.test(e)||qi.test(e)||ea.test(e),parse:e=>Gi.test(e)?Gi.parse(e):ea.test(e)?ea.parse(e):qi.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Gi.transform(e):ea.transform(e),getAnimatableNone:e=>{let t=q.parse(e);return t.alpha=0,q.transform(t)}},ta=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function na(e){return isNaN(e)&&typeof e==`string`&&(e.match(Ri)?.length||0)+(e.match(ta)?.length||0)>0}var ra=`number`,ia=`color`,aa=`var`,oa=`var(`,sa="${}",ca=/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 la(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(ca,e=>(q.test(e)?(r.color.push(a),i.push(ia),n.push(q.parse(e))):e.startsWith(oa)?(r.var.push(a),i.push(aa),n.push(e)):(r.number.push(a),i.push(ra),n.push(parseFloat(e))),++a,sa)).split(sa),indexes:r,types:i}}function ua(e){return la(e).values}function da({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===ra?i+=Li(r[a]):e===ia?i+=q.transform(r[a]):i+=r[a]}return i}}function fa(e){return da(la(e))}var pa=e=>typeof e==`number`?0:q.test(e)?q.getAnimatableNone(e):e,ma=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:pa(e);function ha(e){let t=la(e);return da(t)(t.values.map((e,n)=>ma(e,t.split[n])))}var ga={test:na,parse:ua,createTransformer:fa,getAnimatableNone:ha};function _a(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 va({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=_a(s,r,e+1/3),a=_a(s,r,e),o=_a(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function ya(e,t){return n=>n>0?t:e}var J=(e,t,n)=>e+(t-e)*n,ba=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},xa=[qi,Gi,ea],Sa=e=>xa.find(t=>t.test(e));function Ca(e){let t=Sa(e);if(jr(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,`color-not-animatable`),!t)return!1;let n=t.parse(e);return t===ea&&(n=va(n)),n}var wa=(e,t)=>{let n=Ca(e),r=Ca(t);if(!n||!r)return ya(e,t);let i={...n};return e=>(i.red=ba(n.red,r.red,e),i.green=ba(n.green,r.green,e),i.blue=ba(n.blue,r.blue,e),i.alpha=J(n.alpha,r.alpha,e),Gi.transform(i))},Ta=new Set([`none`,`hidden`]);function Ea(e,t){return Ta.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Da(e,t){return n=>J(e,t,n)}function Oa(e){return typeof e==`number`?Da:typeof e==`string`?ji(e)?ya:q.test(e)?wa:Ma:Array.isArray(e)?ka:typeof e==`object`?q.test(e)?wa:Aa:ya}function ka(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Oa(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Aa(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Oa(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function ja(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 Ma=(e,t)=>{let n=ga.createTransformer(t),r=la(e),i=la(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?Ta.has(e)&&!i.values.length||Ta.has(t)&&!r.values.length?Ea(e,t):Br(ka(ja(r,i),i.values),n):(jr(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,`complex-values-different`),ya(e,t))};function Na(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?J(e,t,n):Oa(e)(e,t)}var Pa=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>G.update(t,e),stop:()=>xi(t),now:()=>Si.isProcessing?Si.timestamp:Ei.now()}},Fa=(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)})`},Ia=2e4;function La(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 Ra(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(La(r),Ia);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Wr(i)}}var Y={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 za(e,t){return e*Math.sqrt(1-t*t)}var Ba=12;function Va(e,t,n){let r=n;for(let n=1;n<Ba;n++)r-=e(r)/t(r);return r}var Ha=.001;function Ua({duration:e=Y.duration,bounce:t=Y.bounce,velocity:n=Y.velocity,mass:r=Y.mass}){let i,a;jr(e<=Ur(Y.maxDuration),`Spring duration must be 10 seconds or less`,`spring-duration-limit`);let o=1-t;o=kr(Y.minDamping,Y.maxDamping,o),e=kr(Y.minDuration,Y.maxDuration,Wr(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=za(t,o),c=Math.exp(-i);return Ha-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=za(t**2,o);return(-i(t)+Ha>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Ha+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Va(i,a,s);if(e=Ur(e),isNaN(c))return{stiffness:Y.stiffness,damping:Y.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Wa=[`duration`,`bounce`],Ga=[`stiffness`,`damping`,`mass`];function Ka(e,t){return t.some(t=>e[t]!==void 0)}function qa(e){let t={velocity:Y.velocity,stiffness:Y.stiffness,damping:Y.damping,mass:Y.mass,isResolvedFromDuration:!1,...e};if(!Ka(e,Ga)&&Ka(e,Wa))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*kr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Y.mass,stiffness:i,damping:a}}else{let n=Ua({...e,velocity:0});t={...t,...n,mass:Y.mass},t.isResolvedFromDuration=!0}return t}function Ja(e=Y.visualDuration,t=Y.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}=qa({...n,velocity:-Wr(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Wr(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Y.restSpeed.granular:Y.restSpeed.default,i||=v?Y.restDelta.granular:Y.restDelta.default;let y,b,x,S,C,w;if(h<1)x=za(_,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 T={calculatedDuration:p&&d||null,velocity:e=>Ur(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=Ur(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=Ur(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(La(T),Ia),t=Fa(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}Ja.applyToOptions=e=>{let t=Ra(e,100,Ja);return e.ease=t.ease,e.duration=Ur(t.duration),e.type=`keyframes`,e};var Ya=5;function Xa(e,t,n){let r=Math.max(t-Ya,0);return Gr(n-e(r),t-r)}function Za({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=Ja({keyframes:[f.value,m(f.value)],velocity:Xa(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 Qa(e,t,n){let r=[],i=n||Nr.mix||Na,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Br(Array.isArray(t)?t[n]||Rr:t,a)),r.push(a)}return r}function $a(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(Mr(a===t.length,`Both input and output ranges must be the same length`,`range-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=Qa(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=Vr(e[r],e[r+1],n);return s[r](i)};return n?t=>l(kr(e[0],e[a-1],t)):l}function eo(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Vr(0,t,r);e.push(J(n,1,i))}}function to(e){let t=[0];return eo(t,e.length-1),t}function no(e,t){return e.map(e=>e*t)}function ro(e,t){return e.map(()=>t||ui).splice(0,e.length-1)}function io({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=di(r)?r.map(hi):hi(r),a={done:!1,value:t[0]},o=$a(no(n&&n.length===t.length?n:to(t),e),t,{ease:Array.isArray(i)?i:ro(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var ao=e=>e!==null;function oo(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(ao),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var so={decay:Za,inertia:Za,tween:io,keyframes:io,spring:Ja};function co(e){typeof e.type==`string`&&(e.type=so[e.type])}var lo=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)}},uo=e=>e/100,fo=class extends lo{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!==Ei.now()&&this.tick(Ei.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Di.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;co(e);let{type:t=io,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||io;process.env.NODE_ENV!==`production`&&s!==io&&Mr(o.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${o}`,`spring-two-frames`),s!==io&&typeof o[0]!=`number`&&(this.mixKeyframes=Br(uo,Na(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=La(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=kr(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!==Za&&(b.value=oo(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 Wr(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Wr(e)}get time(){return Wr(this.currentTime)}set time(e){e=Ur(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 Xa(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(Ei.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Wr(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Pa,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(Ei.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,Di.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 po(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var mo=e=>e*180/Math.PI,ho=e=>_o(mo(Math.atan2(e[1],e[0]))),go={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:ho,rotateZ:ho,skewX:e=>mo(Math.atan(e[1])),skewY:e=>mo(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},_o=e=>(e%=360,e<0&&(e+=360),e),vo=ho,yo=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),bo=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),xo={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:yo,scaleY:bo,scale:e=>(yo(e)+bo(e))/2,rotateX:e=>_o(mo(Math.atan2(e[6],e[5]))),rotateY:e=>_o(mo(Math.atan2(-e[2],e[0]))),rotateZ:vo,rotate:vo,skewX:e=>mo(Math.atan(e[4])),skewY:e=>mo(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function So(e){return e.includes(`scale`)?1:0}function Co(e,t){if(!e||e===`none`)return So(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=xo,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=go,i=t}if(!i)return So(t);let a=r[t],o=i[1].split(`,`).map(To);return typeof a==`function`?a(o):o[a]}var wo=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return Co(n,t)};function To(e){return parseFloat(e.trim())}var Eo=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Do=new Set(Eo),Oo=e=>e===Pi||e===K,ko=new Set([`x`,`y`,`z`]),Ao=Eo.filter(e=>!ko.has(e));function jo(e){let t=[];return Ao.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Mo={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})=>Co(t,`x`),y:(e,{transform:t})=>Co(t,`y`)};Mo.translateX=Mo.x,Mo.translateY=Mo.y;var No=new Set,Po=!1,Fo=!1,Io=!1;function Lo(){if(Fo){let e=Array.from(No).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=jo(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)})}Fo=!1,Po=!1,No.forEach(e=>e.complete(Io)),No.clear()}function Ro(){No.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Fo=!0)})}function zo(){Io=!0,Ro(),Lo(),Io=!1}var Bo=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?(No.add(this),Po||(Po=!0,G.read(Ro),G.resolveKeyframes(Lo))):(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])}po(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),No.delete(this)}cancel(){this.state===`scheduled`&&(No.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Vo=e=>e.startsWith(`--`);function Ho(e,t,n){Vo(t)?e.style.setProperty(t,n):e.style[t]=n}var Uo={};function Wo(e,t){let n=Lr(e);return()=>Uo[t]??n()}var Go=Wo(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Ko=Wo(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),qo=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Jo={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:qo([0,.65,.55,1]),circOut:qo([.55,0,1,.45]),backIn:qo([.31,.01,.66,-.59]),backOut:qo([.33,1.53,.69,.99])};function Yo(e,t){if(e)return typeof e==`function`?Ko()?Fa(e,t):`ease-out`:fi(e)?qo(e):Array.isArray(e)?e.map(e=>Yo(e,t)||Jo.easeOut):Jo[e]}function Xo(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=Yo(s,i);Array.isArray(d)&&(u.easing=d),_i.value&&Di.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 _i.value&&p.finished.finally(()=>{Di.waapi--}),p}function Zo(e){return typeof e==`function`&&`applyToOptions`in e}function Qo({type:e,...t}){return Zo(e)&&Ko()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var $o=class extends lo{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,Mr(typeof e.type!=`string`,`Mini animate() doesn't support "type" as a string.`,`mini-spring`);let c=Qo(e);this.animation=Xo(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=oo(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Ho(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 Wr(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Wr(e)}get time(){return Wr(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Ur(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&&Go()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Rr):r(this)}},es={anticipate:ii,backInOut:ri,circInOut:si};function ts(e){return e in es}function ns(e){typeof e.ease==`string`&&ts(e.ease)&&(e.ease=es[e.ease])}var rs=10,is=class extends $o{constructor(e){ns(e),co(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 fo({...a,autoplay:!1}),s=Math.max(rs,Ei.now()-this.startTime),c=kr(0,rs,s-rs),l=o.sample(s).value,{name:u}=this.options;i&&u&&Ho(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},as=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(ga.test(e)||e===`0`)&&!e.startsWith(`url(`));function os(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 ss(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=as(i,t),s=as(a,t);return jr(o===s,`You are trying to animate ${t} from "${i}" to "${a}". "${o?a:i}" is not an animatable value.`,`value-not-animatable`),!o||!s?!1:os(e)||(n===`spring`||Zo(n))&&r}function cs(e){e.duration=0,e.type=`keyframes`}var ls=new Set([`opacity`,`clipPath`,`filter`,`transform`]),us=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ds(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&us.test(e[t]))return!0;return!1}var fs=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),ps=Lr(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ms(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 ps()&&n&&(ls.has(n)||fs.has(n)&&ds(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var hs=40,gs=class extends lo{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=Ei.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||Bo)(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=Ei.now();let u=!0;ss(e,i,a,o)||(u=!1,(Nr.instantAnimations||!s)&&l?.(oo(e,n,t)),e[0]=e[e.length-1],cs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>hs?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&ms(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new is({...d,element:p})}catch{m=new fo(d)}else m=new fo(d);m.finished.then(()=>{this.notifyFinished()}).catch(Rr),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(),zo()),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 _s(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 vs=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function ys(e){let t=vs.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var bs=4;function xs(e,t,n=1){Mr(n<=bs,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,`max-css-var-depth`);let[r,i]=ys(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Pr(e)?parseFloat(e):e}return ji(i)?xs(i,t,n+1):i}var Ss={type:`spring`,stiffness:500,damping:25,restSpeed:10},Cs=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),ws={type:`keyframes`,duration:.8},Ts={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Es=(e,{keyframes:t})=>t.length>2?ws:Do.has(e)?e.startsWith(`scale`)?Cs(t[1]):Ss:Ts;function Ds(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Os(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Ds(n,e)}var ks=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function As(e){for(let t in e)if(!ks.has(t))return!0;return!1}var js=(e,t,n,r={},i,a)=>o=>{let s=Os(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Ur(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};As(s)||Object.assign(u,Es(e,u)),u.duration&&=Ur(u.duration),u.repeatDelay&&=Ur(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(cs(u),u.delay===0&&(d=!0)),(Nr.instantAnimations||Nr.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,cs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=oo(u.keyframes,s);if(e!==void 0){G.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new fo(u):new gs(u)};function Ms(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Ns(e,t,n,r){if(typeof t==`function`){let[i,a]=Ms(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]=Ms(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Ps(e,t,n){let r=e.getProps();return Ns(r,t,n===void 0?r.custom:n,e)}var Fs=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Eo]),Is=30,Ls=e=>!isNaN(parseFloat(e)),Rs={current:void 0},zs=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Ei.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=Ei.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Ls(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!==`production`&&qr(!1,`value.onChange(callback) is deprecated. Switch to value.on("change", callback).`),this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new Hr);let n=this.events[e].add(t);return e===`change`?()=>{n(),G.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 Rs.current&&Rs.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Ei.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Is)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Is);return Gr(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 Bs(e,t){return new zs(e,t)}var Vs=e=>Array.isArray(e);function Hs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Bs(n))}function Us(e){return Vs(e)?e[e.length-1]||0:e}function Ws(e,t){let{transitionEnd:n={},transition:r={},...i}=Ps(e,t)||{};i={...i,...n};for(let t in i)Hs(e,t,Us(i[t]))}var Gs=e=>!!(e&&e.getVelocity);function Ks(e){return!!(Gs(e)&&e.add)}function qs(e,t){let n=e.getValue(`willChange`);if(Ks(n))return n.add(t);if(!n&&Nr.WillChange){let n=new Nr.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function Js(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Ys=`data-`+Js(`framerAppearId`);function Xs(e){return e.props[Ys]}function Zs({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Qs(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Ds(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&&Zs(d,t))continue;let o={delay:n,...Os(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){G.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=Xs(e);if(n){let e=window.MotionHandoffAnimation(n,t,G);e!==null&&(o.startTime=e,f=!0)}}qs(e,t);let p=l??e.shouldReduceMotion;r.start(js(t,r,i,p&&Fs.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>G.update(()=>{o&&Ws(e,o)});u.length?Promise.all(u).then(t):t()}return u}function $s(e,t,n={}){let r=Ps(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(Qs(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return ec(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 ec(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($s(c,t,{...o,delay:n+(typeof r==`function`?0:r)+_s(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function tc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>$s(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=$s(e,t,n);else{let i=typeof t==`function`?Ps(e,t,n.custom):t;r=Promise.all(Qs(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var nc={test:e=>e===`auto`,parse:e=>e},rc=e=>t=>t.test(e),ic=[Pi,K,Xi,Yi,Qi,Zi,nc],ac=e=>ic.find(rc(e));function oc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Ir(e)}var sc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function cc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ri)||[];if(!r)return e;let i=n.replace(r,``),a=sc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var lc=/\b([a-z-]*)\(.*?\)/gu,uc={...ga,getAnimatableNone:e=>{let t=e.match(lc);return t?t.map(cc).join(` `):e}},dc={...ga,getAnimatableNone:e=>{let t=ga.parse(e);return ga.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},fc={...Pi,transform:Math.round},pc={borderWidth:K,borderTopWidth:K,borderRightWidth:K,borderBottomWidth:K,borderLeftWidth:K,borderRadius:K,borderTopLeftRadius:K,borderTopRightRadius:K,borderBottomRightRadius:K,borderBottomLeftRadius:K,width:K,maxWidth:K,height:K,maxHeight:K,top:K,right:K,bottom:K,left:K,inset:K,insetBlock:K,insetBlockStart:K,insetBlockEnd:K,insetInline:K,insetInlineStart:K,insetInlineEnd:K,padding:K,paddingTop:K,paddingRight:K,paddingBottom:K,paddingLeft:K,paddingBlock:K,paddingBlockStart:K,paddingBlockEnd:K,paddingInline:K,paddingInlineStart:K,paddingInlineEnd:K,margin:K,marginTop:K,marginRight:K,marginBottom:K,marginLeft:K,marginBlock:K,marginBlockStart:K,marginBlockEnd:K,marginInline:K,marginInlineStart:K,marginInlineEnd:K,fontSize:K,backgroundPositionX:K,backgroundPositionY:K,rotate:Yi,rotateX:Yi,rotateY:Yi,rotateZ:Yi,scale:Ii,scaleX:Ii,scaleY:Ii,scaleZ:Ii,skew:Yi,skewX:Yi,skewY:Yi,distance:K,translateX:K,translateY:K,translateZ:K,x:K,y:K,z:K,perspective:K,transformPerspective:K,opacity:Fi,originX:$i,originY:$i,originZ:K,zIndex:fc,fillOpacity:Fi,strokeOpacity:Fi,numOctaves:fc},mc={...pc,color:q,backgroundColor:q,outlineColor:q,fill:q,stroke:q,borderColor:q,borderTopColor:q,borderRightColor:q,borderBottomColor:q,borderLeftColor:q,filter:uc,WebkitFilter:uc,mask:dc,WebkitMask:dc},hc=e=>mc[e],gc=new Set([uc,dc]);function _c(e,t){let n=hc(e);return gc.has(n)||(n=ga),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var vc=new Set([`auto`,`none`,`0`]);function yc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!vc.has(t)&&la(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=_c(n,i)}var bc=class extends Bo{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(),ji(r))){let i=xs(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Fs.has(n)||e.length!==2)return;let[r,i]=e,a=ac(r),o=ac(i);if(Ni(r)!==Ni(i)&&Mo[n]){this.needsMeasurement=!0;return}if(a!==o)if(Oo(a)&&Oo(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Mo[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||oc(e[t]))&&n.push(t);n.length&&yc(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=Mo[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]=Mo[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 xc(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 Sc=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Cc(e){return Fr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:wc,cancel:Tc}=bi(queueMicrotask,!1),Ec={x:!1,y:!1};function Dc(){return Ec.x||Ec.y}function Oc(e){return e===`x`||e===`y`?Ec[e]?null:(Ec[e]=!0,()=>{Ec[e]=!1}):Ec.x||Ec.y?null:(Ec.x=Ec.y=!0,()=>{Ec.x=Ec.y=!1})}function kc(e,t){let n=xc(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Ac(e){return!(e.pointerType===`touch`||Dc())}function jc(e,t,n={}){let[r,i,a]=kc(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(!Ac(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 Mc=(e,t)=>t?e===t?!0:Mc(e,t.parentElement):!1,Nc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Pc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Fc(e){return Pc.has(e.tagName)||e.isContentEditable===!0}var Ic=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Lc(e){return Ic.has(e.tagName)||e.isContentEditable===!0}var Rc=new WeakSet;function zc(e){return t=>{t.key===`Enter`&&e(t)}}function Bc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Vc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=zc(()=>{if(Rc.has(n))return;Bc(n,`down`);let e=zc(()=>{Bc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Bc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Hc(e){return Nc(e)&&!Dc()}var Uc=new WeakSet;function Wc(e,t,n={}){let[r,i,a]=kc(e,n),o=e=>{let r=e.currentTarget;if(!Hc(e)||Uc.has(e))return;Rc.add(r),n.stopPropagation&&Uc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),Rc.has(r)&&Rc.delete(r),Hc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Mc(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),Cc(e)&&(e.addEventListener(`focus`,e=>Vc(e,i)),!Fc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function Gc(e){return Fr(e)&&`ownerSVGElement`in e}var Kc=new WeakMap,qc,Jc=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Gc(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Yc=Jc(`inline`,`width`,`offsetWidth`),Xc=Jc(`block`,`height`,`offsetHeight`);function Zc({target:e,borderBoxSize:t}){Kc.get(e)?.forEach(n=>{n(e,{get width(){return Yc(e,t)},get height(){return Xc(e,t)}})})}function Qc(e){e.forEach(Zc)}function $c(){typeof ResizeObserver>`u`||(qc=new ResizeObserver(Qc))}function el(e,t){qc||$c();let n=xc(e);return n.forEach(e=>{let n=Kc.get(e);n||(n=new Set,Kc.set(e,n)),n.add(t),qc?.observe(e)}),()=>{n.forEach(e=>{let n=Kc.get(e);n?.delete(t),n?.size||qc?.unobserve(e)})}}var tl=new Set,nl;function rl(){nl=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};tl.forEach(t=>t(e))},window.addEventListener(`resize`,nl)}function il(e){return tl.add(e),nl||rl(),()=>{tl.delete(e),!tl.size&&typeof nl==`function`&&(window.removeEventListener(`resize`,nl),nl=void 0)}}function al(e,t){return typeof e==`function`?il(e):el(e,t)}function ol(e){return Gc(e)&&e.tagName===`svg`}var sl=[...ic,q,ga],cl=e=>sl.find(rc(e)),ll=()=>({translate:0,scale:1,origin:0,originPoint:0}),ul=()=>({x:ll(),y:ll()}),dl=()=>({min:0,max:0}),X=()=>({x:dl(),y:dl()}),fl=new WeakMap;function pl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function ml(e){return typeof e==`string`||Array.isArray(e)}var hl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],gl=[`initial`,...hl];function _l(e){return pl(e.animate)||gl.some(t=>ml(e[t]))}function vl(e){return!!(_l(e)||e.variants)}function yl(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Gs(i))e.addValue(r,i);else if(Gs(a))e.addValue(r,Bs(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,Bs(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var bl={current:null},xl={current:!1},Sl=typeof window<`u`;function Cl(){if(xl.current=!0,Sl)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>bl.current=e.matches;e.addEventListener(`change`,t),t()}else bl.current=!1}var wl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Tl={};function El(e){Tl=e}function Dl(){return Tl}var Ol=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=Bo,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=Ei.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,G.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=_l(t),this.isVariantNode=vl(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&&Gs(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,fl.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:(xl.current||Cl(),this.shouldReduceMotion=bl.current),process.env.NODE_ENV!==`production`&&qr(this.shouldReduceMotion!==!0,`You have Reduced Motion enabled on your device. Animations may not appear as expected.`,`reduced-motion-disabled`),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),xi(this.notifyUpdate),xi(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&&ls.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new $o({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Ur(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Do.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&G.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 Tl){let t=Tl[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):X()}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<wl.length;t++){let n=wl[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=yl(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=Bs(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`&&(Pr(n)||Ir(n))?n=parseFloat(n):!cl(n)&&ga.test(t)&&(n=_c(e,t)),this.setBaseTarget(e,Gs(n)?n.get():n)),Gs(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=Ns(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&&!Gs(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 Hr),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){wc.render(this.render)}},kl=class extends Ol{constructor(){super(...arguments),this.KeyframeResolver=bc}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;Gs(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Al=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function jl({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Ml({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Nl(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 Pl(e){return e===void 0||e===1}function Fl({scale:e,scaleX:t,scaleY:n}){return!Pl(e)||!Pl(t)||!Pl(n)}function Il(e){return Fl(e)||Ll(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Ll(e){return Rl(e.x)||Rl(e.y)}function Rl(e){return e&&e!==`0%`}function zl(e,t,n){return n+t*(e-n)}function Bl(e,t,n,r,i){return i!==void 0&&(e=zl(e,i,r)),zl(e,n,r)+t}function Vl(e,t=0,n=1,r,i){e.min=Bl(e.min,t,n,r,i),e.max=Bl(e.max,t,n,r,i)}function Hl(e,{x:t,y:n}){Vl(e.x,t.translate,t.scale,t.originPoint),Vl(e.y,n.translate,n.scale,n.originPoint)}var Ul=.999999999999,Wl=1.0000000000001;function Gl(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&&(Kl(e.x,-a.scroll.offset.x),Kl(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Hl(e,o)),r&&Il(a.latestValues)&&Yl(e,a.latestValues,a.layout?.layoutBox))}t.x<Wl&&t.x>Ul&&(t.x=1),t.y<Wl&&t.y>Ul&&(t.y=1)}function Kl(e,t){e.min+=t,e.max+=t}function ql(e,t,n,r,i=.5){Vl(e,t,n,J(e.min,e.max,i),r)}function Jl(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function Yl(e,t,n){let r=n??e;ql(e.x,Jl(t.x,r.x),t.scaleX,t.scale,t.originX),ql(e.y,Jl(t.y,r.y),t.scaleY,t.scale,t.originY)}function Xl(e,t){return jl(Nl(e.getBoundingClientRect(),t))}function Zl(e,t,n){let r=Xl(e,n),{scroll:i}=t;return i&&(Kl(r.x,i.offset.x),Kl(r.y,i.offset.y)),r}var Ql={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},$l=Eo.length;function eu(e,t,n){let r=``,i=!0;for(let a=0;a<$l;a++){let o=Eo[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=Sc(s,pc[o]);if(!c){i=!1;let t=Ql[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function tu(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(Do.has(e)){o=!0;continue}else if(ki(e)){i[e]=n;continue}else{let t=Sc(n,pc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=eu(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 nu(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 ru(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var iu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(K.test(e))e=parseFloat(e);else return e;return`${ru(e,t.target.x)}% ${ru(e,t.target.y)}%`}},au={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=ga.parse(e);if(i.length>5)return r;let a=ga.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=J(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},ou={borderRadius:{...iu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:iu,borderTopRightRadius:iu,borderBottomLeftRadius:iu,borderBottomRightRadius:iu,boxShadow:au};function su(e,{layout:t,layoutId:n}){return Do.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!ou[e]||e===`opacity`)}function cu(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Gs(r[t])||i&&Gs(i[t])||su(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function lu(e){return window.getComputedStyle(e)}var uu=class extends kl{constructor(){super(...arguments),this.type=`html`,this.renderInstance=nu}readValueFromInstance(e,t){if(Do.has(t))return this.projection?.isProjecting?So(t):wo(e,t);{let n=lu(e),r=(ki(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Xl(e,t)}build(e,t,n){tu(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return cu(e,t,n)}},du={offset:`stroke-dashoffset`,array:`stroke-dasharray`},fu={offset:`strokeDashoffset`,array:`strokeDasharray`};function pu(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?du:fu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var mu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function hu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(tu(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 mu)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&&pu(d,i,a,o,!1)}var gu=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`]),_u=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function vu(e,t,n,r){nu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(gu.has(n)?n:Js(n),t.attrs[n])}function yu(e,t,n){let r=cu(e,t,n);for(let n in e)if(Gs(e[n])||Gs(t[n])){let t=Eo.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var bu=class extends kl{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=X}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Do.has(t)){let e=hc(t);return e&&e.default||0}return t=gu.has(t)?t:Js(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return yu(e,t,n)}build(e,t,n){hu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){vu(e,t,n,r)}mount(e){this.isSVGTag=_u(e.tagName),super.mount(e)}},xu=gl.length;function Su(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Su(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<xu;n++){let r=gl[n],i=e.props[r];(ml(i)||i===!1)&&(t[r]=i)}return t}function Cu(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 wu=[...hl].reverse(),Tu=hl.length;function Eu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>tc(e,t,n)))}function Du(e){let t=Eu(e),n=Au(),r=!0,i=!1,a=t=>(n,r)=>{let i=Ps(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=Su(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<Tu;t++){let p=wu[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=ml(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||pl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Ou(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,T={...w,...C},E=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 T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Vs(t)&&Vs(n)?!Cu(t,n):t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let ee=v&&y;b&&(!ee||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!ee&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Ps(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=_s(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Ps(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=Au(),i=!0}}}function Ou(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Cu(t,e):!1}function ku(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Au(){return{animate:ku(!0),whileInView:ku(),whileHover:ku(),whileTap:ku(),whileDrag:ku(),whileFocus:ku(),exit:ku()}}function ju(e,t){e.min=t.min,e.max=t.max}function Mu(e,t){ju(e.x,t.x),ju(e.y,t.y)}function Nu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Pu=1e-4,Fu=1-Pu,Iu=1+Pu,Lu=.01,Ru=0-Lu,zu=0+Lu;function Bu(e){return e.max-e.min}function Vu(e,t,n){return Math.abs(e-t)<=n}function Hu(e,t,n,r=.5){e.origin=r,e.originPoint=J(t.min,t.max,e.origin),e.scale=Bu(n)/Bu(t),e.translate=J(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Fu&&e.scale<=Iu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Ru&&e.translate<=zu||isNaN(e.translate))&&(e.translate=0)}function Uu(e,t,n,r){Hu(e.x,t.x,n.x,r?r.originX:void 0),Hu(e.y,t.y,n.y,r?r.originY:void 0)}function Wu(e,t,n,r=0){e.min=(r?J(n.min,n.max,r):n.min)+t.min,e.max=e.min+Bu(t)}function Gu(e,t,n,r){Wu(e.x,t.x,n.x,r?.x),Wu(e.y,t.y,n.y,r?.y)}function Ku(e,t,n,r=0){let i=r?J(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Bu(t)}function qu(e,t,n,r){Ku(e.x,t.x,n.x,r?.x),Ku(e.y,t.y,n.y,r?.y)}function Ju(e,t,n,r,i){return e-=t,e=zl(e,1/n,r),i!==void 0&&(e=zl(e,1/i,r)),e}function Yu(e,t=0,n=1,r=.5,i,a=e,o=e){if(Xi.test(t)&&(t=parseFloat(t),t=J(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=J(a.min,a.max,r);e===a&&(s-=t),e.min=Ju(e.min,t,n,s,i),e.max=Ju(e.max,t,n,s,i)}function Xu(e,t,[n,r,i],a,o){Yu(e,t[n],t[r],t[i],t.scale,a,o)}var Zu=[`x`,`scaleX`,`originX`],Qu=[`y`,`scaleY`,`originY`];function $u(e,t,n,r){Xu(e.x,t,Zu,n?n.x:void 0,r?r.x:void 0),Xu(e.y,t,Qu,n?n.y:void 0,r?r.y:void 0)}function ed(e){return e.translate===0&&e.scale===1}function td(e){return ed(e.x)&&ed(e.y)}function nd(e,t){return e.min===t.min&&e.max===t.max}function rd(e,t){return nd(e.x,t.x)&&nd(e.y,t.y)}function id(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function ad(e,t){return id(e.x,t.x)&&id(e.y,t.y)}function od(e){return Bu(e.x)/Bu(e.y)}function sd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function cd(e){return[e(`x`),e(`y`)]}function ld(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 ud=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],dd=ud.length,fd=e=>typeof e==`string`?parseFloat(e):e,pd=e=>typeof e==`number`||K.test(e);function md(e,t,n,r,i,a){i?(e.opacity=J(0,n.opacity??1,gd(r)),e.opacityExit=J(t.opacity??1,0,_d(r))):a&&(e.opacity=J(t.opacity??1,n.opacity??1,r));for(let i=0;i<dd;i++){let a=ud[i],o=hd(t,a),s=hd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||pd(o)===pd(s)?(e[a]=Math.max(J(fd(o),fd(s),r),0),(Xi.test(s)||Xi.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=J(t.rotate||0,n.rotate||0,r))}function hd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var gd=vd(0,.5,oi),_d=vd(.5,.95,Rr);function vd(e,t,n){return r=>r<e?0:r>t?1:n(Vr(e,t,r))}function yd(e,t,n){let r=Gs(e)?e:Bs(e);return r.start(js(``,r,t,n)),r.animation}function bd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var xd=(e,t)=>e.depth-t.depth,Sd=class{constructor(){this.children=[],this.isDirty=!1}add(e){Dr(this.children,e),this.isDirty=!0}remove(e){Or(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(xd),this.isDirty=!1,this.children.forEach(e)}};function Cd(e,t){let n=Ei.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(xi(r),e(a-t))};return G.setup(r,!0),()=>xi(r)}function wd(e){return Gs(e)?e.get():e}var Td=class{constructor(){this.members=[]}add(e){Dr(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&&(Or(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Or(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)}},Ed={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Dd={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Od=[``,`X`,`Y`,`Z`],kd=1e3,Ad=0;function jd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Md(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Xs(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,G,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Md(r)}function Nd({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Ad++,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,_i.value&&(Dd.nodes=Dd.calculatedTargetDeltas=Dd.calculatedProjections=0),this.nodes.forEach(Id),this.nodes.forEach(Gd),this.nodes.forEach(Kd),this.nodes.forEach(Ld),_i.addProjectionMetrics&&_i.addProjectionMetrics(Dd)},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 Sd)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Hr),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=Gc(t)&&!ol(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;G.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Cd(i,250),Ed.hasAnimatedSinceResize&&(Ed.hasAnimatedSinceResize=!1,this.nodes.forEach(Wd)))})}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()||$d,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!ad(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={...Os(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||Wd(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(),xi(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(qd),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&&Md(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(Bd),this.nodes.forEach(zd);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Vd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Hd),this.nodes.forEach(Ud),this.nodes.forEach(Pd),this.nodes.forEach(Fd)):this.nodes.forEach(Vd),this.clearAllSnapshots();let e=Ei.now();Si.delta=kr(0,1e3/60,e-Si.timestamp),Si.timestamp=e,Si.isProcessing=!0,Ci.update.process(Si),Ci.preRender.process(Si),Ci.render.process(Si),Si.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,wc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Rd),this.sharedNodes.forEach(Jd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,G.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){G.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Bu(this.snapshot.measuredBox.x)&&!Bu(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||=X(),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&&!td(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Il(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)),rf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return X();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(of))){let{scroll:e}=this.root;e&&(Kl(t.x,e.offset.x),Kl(t.y,e.offset.y))}return t}removeElementScroll(e){let t=X();if(Mu(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&&Mu(t,e),Kl(t.x,i.offset.x),Kl(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||X();Mu(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&&(Kl(r.x,-n.scroll.offset.x),Kl(r.y,-n.scroll.offset.y)),Il(n.latestValues)&&Yl(r,n.latestValues,n.layout?.layoutBox)}return Il(this.latestValues)&&Yl(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=X();Mu(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Il(n.latestValues))continue;let r;n.instance&&(Fl(n.latestValues)&&n.updateSnapshot(),r=X(),Mu(r,n.measurePageBox())),$u(t,n.latestValues,n.snapshot?.layoutBox,r)}return Il(this.latestValues)&&$u(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!==Si.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=Si.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=X(),this.targetWithTransforms=X()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Gu(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Mu(this.target,this.layout.layoutBox),Hl(this.target,this.targetDelta)):Mu(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),_i.value&&Dd.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Fl(this.parent.latestValues)||Ll(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=X(),this.relativeTargetOrigin=X(),qu(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Mu(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===Si.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;Mu(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Gl(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=X());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Nu(this.prevProjectionDelta.x,this.projectionDelta.x),Nu(this.prevProjectionDelta.y,this.projectionDelta.y)),Uu(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!sd(this.projectionDelta.x,this.prevProjectionDelta.x)||!sd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),_i.value&&Dd.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=ul(),this.projectionDelta=ul(),this.projectionDeltaWithTransform=ul()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=ul();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=X(),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(Qd));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;Yd(a.x,e.x,n),Yd(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),Zd(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&rd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=X(),Mu(d,this.relativeTarget)),s&&(this.animationValues=i,md(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&&=(xi(this.pendingAnimation),void 0),this.pendingAnimation=G.update(()=>{Ed.hasAnimatedSinceResize=!0,Di.layout++,this.motionValue||=Bs(0),this.motionValue.jump(0,!1),this.currentAnimation=yd(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Di.layout--},onComplete:()=>{Di.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(kd),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&&af(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||X();let t=Bu(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Bu(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Mu(t,n),Yl(t,i),Uu(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Td),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&&jd(`z`,e,r,this.animationValues);for(let t=0;t<Od.length;t++)jd(`rotate${Od[t]}`,e,r,this.animationValues),jd(`skew${Od[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=wd(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=wd(t?.pointerEvents)||``),this.hasProjected&&!Il(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=ld(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 ou){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=ou[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?wd(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(zd),this.root.sharedNodes.clear()}}}function Pd(e){e.updateLayout()}function Fd(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`)cd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Bu(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;ju(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else af(i,t.layoutBox,n)&&cd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Bu(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=ul();Uu(o,n,t.layoutBox);let s=ul();a?Uu(s,e.applyTransform(r,!0),t.measuredBox):Uu(s,n,t.layoutBox);let c=!td(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=X();qu(s,t.layoutBox,i.layoutBox,o);let c=X();qu(c,n,a.layoutBox,o),ad(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 Id(e){_i.value&&Dd.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 Ld(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Rd(e){e.clearSnapshot()}function zd(e){e.clearMeasurements()}function Bd(e){e.isLayoutDirty=!0,e.updateLayout()}function Vd(e){e.isLayoutDirty=!1}function Hd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Ud(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Wd(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Gd(e){e.resolveTargetDelta()}function Kd(e){e.calcProjection()}function qd(e){e.resetSkewAndRotation()}function Jd(e){e.removeLeadSnapshot()}function Yd(e,t,n){e.translate=J(t.translate,0,n),e.scale=J(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Xd(e,t,n,r){e.min=J(t.min,n.min,r),e.max=J(t.max,n.max,r)}function Zd(e,t,n,r){Xd(e.x,t.x,n.x,r),Xd(e.y,t.y,n.y,r)}function Qd(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var $d={duration:.45,ease:[.4,0,.1,1]},ef=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),tf=ef(`applewebkit/`)&&!ef(`chrome/`)?Math.round:Rr;function nf(e){e.min=tf(e.min),e.max=tf(e.max)}function rf(e){nf(e.x),nf(e.y)}function af(e,t,n){return e===`position`||e===`preserve-aspect`&&!Vu(od(t),od(n),.2)}function of(e){return e!==e.root&&e.scroll?.wasRoot}var sf=Nd({attachResizeListener:(e,t)=>bd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),cf={current:void 0},lf=Nd({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!cf.current){let e=new sf({});e.mount(window),e.setOptions({layoutScroll:!0}),cf.current=e}return cf.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),uf=(0,d.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function df(e=!0){let t=(0,d.useContext)(Er);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,d.useId)();(0,d.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,d.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var ff=(0,d.createContext)({strict:!1}),pf={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`]},mf=!1;function hf(){if(mf)return;let e={};for(let t in pf)e[t]={isEnabled:e=>pf[t].some(t=>!!e[t])};El(e),mf=!0}function gf(){return hf(),Dl()}function _f(e){let t=gf();for(let n in e)t[n]={...t[n],...e[n]};El(t)}var vf=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 yf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||vf.has(e)}var bf=s({default:()=>xf}),xf,Sf=o((()=>{throw xf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Cf=e=>!yf(e);function wf(e){typeof e==`function`&&(Cf=t=>t.startsWith(`on`)?!yf(t):e(t))}try{wf((Sf(),u(bf)).default)}catch{}function Tf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Gs(e[i])||(Cf(i)||n===!0&&yf(i)||!t&&!yf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Ef=(0,d.createContext)({});function Df(e,t){if(_l(e)){let{initial:t,animate:n}=e;return{initial:t===!1||ml(t)?t:void 0,animate:ml(n)?n:void 0}}return e.inherit===!1?{}:t}function Of(e){let{initial:t,animate:n}=Df(e,(0,d.useContext)(Ef));return(0,d.useMemo)(()=>({initial:t,animate:n}),[kf(t),kf(n)])}function kf(e){return Array.isArray(e)?e.join(` `):e}var Af=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function jf(e,t,n){for(let r in t)!Gs(t[r])&&!su(r,n)&&(e[r]=t[r])}function Mf({transformTemplate:e},t){return(0,d.useMemo)(()=>{let n=Af();return tu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Nf(e,t){let n=e.style||{},r={};return jf(r,n,e),Object.assign(r,Mf(e,t)),r}function Pf(e,t){let n={},r=Nf(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 Ff=()=>({...Af(),attrs:{}});function If(e,t,n,r){let i=(0,d.useMemo)(()=>{let n=Ff();return hu(n,t,_u(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};jf(t,e.style,e),i.style={...t,...i.style}}return i}var Lf=[`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 Rf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Lf.indexOf(e)>-1||/[A-Z]/u.test(e))}function zf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Rf(e)?If:Pf)(t,r,i,e),c=Tf(t,typeof e==`string`,a),l=e===d.Fragment?{}:{...c,...s,ref:n},{children:u}=t,f=(0,d.useMemo)(()=>Gs(u)?u.get():u,[u]);return(0,d.createElement)(e,{...l,children:f})}function Bf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Vf(n,r,i,e),renderState:t()}}function Vf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=wd(a[e]);let{initial:o,animate:s}=e,c=_l(e),l=vl(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`&&!pl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Ns(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 Hf=e=>(t,n)=>{let r=(0,d.useContext)(Ef),i=(0,d.useContext)(Er),a=()=>Bf(e,t,r,i);return n?a():wr(a)},Uf=Hf({scrapeMotionValuesFromProps:cu,createRenderState:Af}),Wf=Hf({scrapeMotionValuesFromProps:yu,createRenderState:Ff}),Gf=Symbol.for(`motionComponentSymbol`);function Kf(e,t,n){let r=(0,d.useRef)(n);(0,d.useInsertionEffect)(()=>{r.current=n});let i=(0,d.useRef)(null);return(0,d.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 qf=(0,d.createContext)({});function Jf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Yf(e,t,n,r,i,a){let{visualElement:o}=(0,d.useContext)(Ef),s=(0,d.useContext)(ff),c=(0,d.useContext)(Er),l=(0,d.useContext)(uf),u=l.reducedMotion,f=l.skipAnimations,p=(0,d.useRef)(null),m=(0,d.useRef)(!1);r||=s.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:f,isSVG:a}),m.current&&p.current&&(p.current.manuallyAnimateOnMount=!0));let h=p.current,g=(0,d.useContext)(qf);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&Xf(p.current,n,i,g);let _=(0,d.useRef)(!1);(0,d.useInsertionEffect)(()=>{h&&_.current&&h.update(n,c)});let v=n[Ys],y=(0,d.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return Tr(()=>{m.current=!0,h&&(_.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),y.current&&h.animationState&&h.animationState.animateChanges())}),(0,d.useEffect)(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),h.enteringChildren=void 0)}),h}function Xf(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:Zf(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&Jf(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function Zf(e){if(e)return e.options.allowProjection===!1?Zf(e.parent):e.projection}function Qf(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&_f(r);let a=n?n===`svg`:Rf(e),o=a?Wf:Uf;function s(n,s){let c,l={...(0,d.useContext)(uf),...n,layoutId:$f(n)},{isStatic:u}=l,p=Of(n),m=o(n,u);if(!u&&typeof window<`u`){ep(l,r);let t=tp(l);c=t.MeasureLayout,p.visualElement=Yf(e,m,l,i,t.ProjectionNode,a)}return(0,f.jsxs)(Ef.Provider,{value:p,children:[c&&p.visualElement?(0,f.jsx)(c,{visualElement:p.visualElement,...l}):null,zf(e,n,Kf(m,p.visualElement,s),m,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,d.forwardRef)(s);return c[Gf]=e,c}function $f({layoutId:e}){let t=(0,d.useContext)(Cr).id;return t&&e!==void 0?t+`-`+e:e}function ep(e,t){let n=(0,d.useContext)(ff).strict;if(process.env.NODE_ENV!==`production`&&t&&n){let t="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?jr(!1,t,`lazy-strict-mode`):Mr(!1,t,`lazy-strict-mode`)}}function tp(e){let{drag:t,layout:n}=gf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function np(e,t){if(typeof Proxy>`u`)return Qf;let n=new Map,r=(n,r)=>Qf(n,r,e,t);return new Proxy((e,t)=>(process.env.NODE_ENV!==`production`&&qr(!1,`motion() is deprecated. Use motion.create() instead.`),r(e,t)),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Qf(a,void 0,e,t)),n.get(a))})}var rp=(e,t)=>t.isSVG??Rf(e)?new bu(t):new uu(t,{allowProjection:e!==d.Fragment}),ip=class extends Al{constructor(e){super(e),e.animationState||=Du(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();pl(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?.()}},ap=0,op={animation:{Feature:ip},exit:{Feature:class extends Al{constructor(){super(...arguments),this.id=ap++,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=Ps(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 sp(e){return{point:{x:e.pageX,y:e.pageY}}}var cp=e=>t=>Nc(t)&&e(t,sp(t));function lp(e,t,n,r){return bd(e,t,cp(n),r)}var up=({current:e})=>e?e.ownerDocument.defaultView:null,dp=(e,t)=>Math.abs(e-t);function fp(e,t){let n=dp(e.x,t.x),r=dp(e.y,t.y);return Math.sqrt(n**2+r**2)}var pp=new Set([`auto`,`scroll`]),mp=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=hp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=_p(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=fp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Si;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=hp(t,this.transformPagePoint),G.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=_p(e.type===`pointercancel`?this.lastMoveEventInfo:hp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Nc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=hp(sp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Si;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,_p(s,this.history)),this.removeListeners=Br(lp(this.contextWindow,`pointermove`,this.handlePointerMove),lp(this.contextWindow,`pointerup`,this.handlePointerUp),lp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(pp.has(e.overflowX)||pp.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),G.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),xi(this.updatePoint)}};function hp(e,t){return t?{point:t(e.point)}:e}function gp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function _p({point:e},t){return{point:e,delta:gp(e,yp(t)),offset:gp(e,vp(t)),velocity:bp(t,.1)}}function vp(e){return e[0]}function yp(e){return e[e.length-1]}function bp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=yp(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Ur(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Ur(t)*2&&(r=e[1]);let a=Wr(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 xp(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?J(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?J(n,e,r.max):Math.min(e,n)),e}function Sp(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 Cp(e,{top:t,left:n,bottom:r,right:i}){return{x:Sp(e.x,n,i),y:Sp(e.y,t,r)}}function wp(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 Tp(e,t){return{x:wp(e.x,t.x),y:wp(e.y,t.y)}}function Ep(e,t){let n=.5,r=Bu(e),i=Bu(t);return i>r?n=Vr(t.min,t.max-r,e.min):r>i&&(n=Vr(e.min,e.max-i,t.min)),kr(0,1,n)}function Dp(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 Op=.35;function kp(e=Op){return e===!1?e=0:e===!0&&(e=Op),{x:Ap(e,`left`,`right`),y:Ap(e,`top`,`bottom`)}}function Ap(e,t,n){return{min:jp(e,t),max:jp(e,n)}}function jp(e,t){return typeof e==`number`?e:e[t]||0}var Mp=new WeakMap,Np=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=X(),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(sp(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=Oc(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),cd(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Xi.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Bu(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&G.update(()=>i(e,t),!1,!0),qs(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=Lp(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&&G.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 mp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:up(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&&G.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||!Ip(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=xp(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&&Jf(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Cp(n.layoutBox,e):this.constraints=!1,this.elastic=kp(t),r!==this.constraints&&!Jf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&cd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Dp(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!Jf(e))return!1;let n=e.current;Mr(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.",`drag-constraints-ref`);let{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=Zl(n,r.root,this.visualElement.getTransformPagePoint()),a=Tp(r.layout.layoutBox,i);if(t){let e=t(Ml(a));this.hasMutatedConstraints=!!e,e&&(a=jl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=cd(o=>{if(!Ip(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 qs(this.visualElement,e),n.start(js(e,n,0,t,this.visualElement,!1))}stopAnimation(){cd(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){cd(t=>{let{drag:n}=this.getProps();if(!Ip(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]-J(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!Jf(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};cd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Ep({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(),cd(t=>{if(!Ip(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(J(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Mp.set(this.visualElement,this);let e=this.visualElement.current,t=lp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Lc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();Jf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Fp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),G.read(r);let o=bd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(cd(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=Op,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Pp(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Fp(e,t,n){let r=al(e,Pp(n)),i=al(t,Pp(n));return()=>{r(),i()}}function Ip(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Lp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Rp=class extends Al{constructor(e){super(e),this.removeGroupControls=Rr,this.removeListeners=Rr,this.controls=new Np(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Rr}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()}},zp=e=>(t,n)=>{e&&G.update(()=>e(t,n),!1,!0)},Bp=class extends Al{constructor(){super(...arguments),this.removePointerDownListener=Rr}onPointerDown(e){this.session=new mp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:up(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:zp(e),onStart:zp(t),onMove:zp(n),onEnd:(e,t)=>{delete this.session,r&&G.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=lp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Vp=!1,Hp=class extends d.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),Vp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Ed.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}),Vp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||G.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(),wc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Vp=!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 Up(e){let[t,n]=df(),r=(0,d.useContext)(Cr);return(0,f.jsx)(Hp,{...e,layoutGroup:r,switchLayoutGroup:(0,d.useContext)(qf),isPresent:t,safeToRemove:n})}var Wp={pan:{Feature:Bp},drag:{Feature:Rp,ProjectionNode:lf,MeasureLayout:Up}};function Gp(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&G.postRender(()=>i(t,sp(t)))}var Kp=class extends Al{mount(){let{current:e}=this.node;e&&(this.unmount=jc(e,(e,t)=>(Gp(this.node,t,`Start`),e=>Gp(this.node,e,`End`))))}unmount(){}},qp=class extends Al{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=Br(bd(this.node.current,`focus`,()=>this.onFocus()),bd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function Jp(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&&G.postRender(()=>i(t,sp(t)))}var Yp=class extends Al{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Wc(e,(e,t)=>(Jp(this.node,t,`Start`),(e,{success:t})=>Jp(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},Xp=new WeakMap,Zp=new WeakMap,Qp=e=>{let t=Xp.get(e.target);t&&t(e)},$p=e=>{e.forEach(Qp)};function em({root:e,...t}){let n=e||document;Zp.has(n)||Zp.set(n,{});let r=Zp.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver($p,{root:e,...t})),r[i]}function tm(e,t,n){let r=em(t);return Xp.set(e,n),r.observe(e),()=>{Xp.delete(e),r.unobserve(e)}}var nm={some:0,all:1},rm=class extends Al{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:nm[r]};this.stopObserver=tm(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(im(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function im({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var am={inView:{Feature:rm},tap:{Feature:Yp},focus:{Feature:qp},hover:{Feature:Kp}},om={layout:{ProjectionNode:lf,MeasureLayout:Up}},sm=np({...op,...am,...Wp,...om},rp),cm=24e3,lm=2048;function um(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 dm(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}function fm(e,t){let n=0,r=[];return{enqueue:i=>{let a=dm(i),o=e.createBuffer(1,a.length,cm);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 pm(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 mm(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 pm(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:cm});p.state===`suspended`&&await p.resume();let m=new WebSocket(d.wsUrl,[`token`,d.token]);m.binaryType=`arraybuffer`;let h=!1,g=!1,_=!1,v=fm(p,()=>{_&&(_=!1,c?.({mode:`listening`}))}),y=p.createMediaStreamSource(f),b=p.createScriptProcessor(lm,1,1);b.onaudioprocess=e=>{h||g||m.readyState!==WebSocket.OPEN||m.send(um(e.inputBuffer.getChannelData(0)).buffer)},y.connect(b),b.connect(p.destination);let x=()=>{if(!h){h=!0,v.stop();try{b.disconnect(),y.disconnect()}catch{}f.getTracks().forEach(e=>e.stop()),p.close().catch(()=>{}),(m.readyState===WebSocket.OPEN||m.readyState===WebSocket.CONNECTING)&&m.close()}},S=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`}}},C=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await S(t);if(h||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??{})}))}},w=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`:v.stop(),_=!1,c?.({mode:`listening`});break;case`AgentStartedSpeaking`:_=!0,c?.({mode:`speaking`});break;case`AgentAudioDone`:v.isPlaying()||(_=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:C(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){v.enqueue(new Int16Array(e.data));return}try{w(JSON.parse(e.data))}catch{}},m.onerror=()=>l?.(Error(`Voice connection failed`)),m.onclose=()=>{x(),o?.()},{endSession:async()=>x(),sendContextualUpdate:e=>{h||m.readyState!==WebSocket.OPEN||!e||m.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:e=>{h||m.readyState!==WebSocket.OPEN||!e||m.send(JSON.stringify({type:`InjectUserMessage`,content:e}))},injectAgentSpeech:(e,t=`interrupt`)=>{h||m.readyState!==WebSocket.OPEN||!e||m.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setMicMuted:e=>{g=!!e},get status(){return h?`disconnected`:`connected`}}}var hm={startSession:mm},gm=({size:e=18,color:t=`currentColor`})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:t}),(0,f.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),_m=({size:e=20})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.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,f.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),vm=({size:e=18})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,f.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),ym=()=>(0,f.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,f.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),bm=()=>(0,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.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`})}),xm=({className:e=``})=>(0,f.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,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),Sm=({size:e=14})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`path`,{d:`M12 8V4H8`}),(0,f.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,f.jsx)(`path`,{d:`M2 14h2`}),(0,f.jsx)(`path`,{d:`M20 14h2`}),(0,f.jsx)(`path`,{d:`M15 13v2`}),(0,f.jsx)(`path`,{d:`M9 13v2`})]}),Cm=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,f.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),wm=({size:e=20,color:t=`currentColor`})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:t}),(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:t}),(0,f.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:t})]}),Tm=({size:e=20,color:t=`currentColor`})=>(0,f.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.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,f.jsx)(`path`,{d:`M11.9955 12H12.0045M15.991 12H16M8 12H8.00897`,stroke:`white`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]}),Em=()=>(0,f.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,f.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`})}),Dm=({size:e=24})=>(0,f.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,f.jsx)(`path`,{d:`M12 19v3`}),(0,f.jsx)(`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`}),(0,f.jsx)(`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`}),(0,f.jsx)(`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`}),(0,f.jsx)(`path`,{d:`m2 2 20 20`}),(0,f.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`})]}),Om=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),km=(e=``)=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),Am=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),jm=/^https?:\/\//i;function Mm(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Am.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;jm.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);Mm(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Nm(e){let t=document.createElement(`div`);return t.innerHTML=e,Mm(t),t.innerHTML}function Pm(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 Fm=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return Pm(Nm(t));let n=t.replace(/\r\n/g,`
25
+ `,document.head.appendChild(e)};function Zn(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(yn(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(bn(e).toLowerCase()===n)return e;for(let e of i){let t=bn(e).toLowerCase();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=bn(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=bn(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=bn(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=>!yn(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(yn(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(yn(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(yn(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=>!yn(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(yn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function Qn(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;Xn();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 $n(){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`)),_n())}function er(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 tr(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 nr(e,{siteId:t,apiBaseUrl:n}){if(!e)return{allowed:!1,correctedUrl:null};let r=!1;try{r=!!In()}catch{r=!1}let i=async()=>({allowed:r?!1:await tr(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 rr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(xn,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function ir(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}qn();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 Jn(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return Jn(),!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()}),Rn();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(Ln,`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(Ln,`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,G(`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){G(`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,G(`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){G(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){G(`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;G(`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)){G(`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:`)&&(G(`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`)||``}),G(`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),G(`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(jn(),Nn(),n){try{Vn()}catch{}try{Wn()}catch{}}else window.scrollTo(0,0);Jn(),Gn(e);try{sessionStorage.removeItem(xn)}catch{}try{sessionStorage.removeItem(Cn)}catch{}try{An=new URL(e,window.location.origin).pathname}catch{}return G(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),Jn(),!1}}function ar(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Cn,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function or(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(Cn)}catch{}}function sr(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(Cn)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(Cn)}catch{}return e.voiceWasActive?Date.now()-e.ts>wn?(G(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(G(`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 lr(e,t={}){if(typeof window>`u`)return{navigated:!1};let{sectionText:n,voiceActive:r=!1}=t;try{let t=er(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(In()){n&&rr(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&&rr(n),r||ye(),window.location.assign(i.href),{navigated:!0}}return{navigated:!0}}return n&&rr(n),r||ye(),window.location.assign(i.href),{navigated:!0}}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&rr(n);try{window.location.href=er(e)}catch{window.location.href=e}return{navigated:!0}}}var ur=!1,dr=null;function fr(e){dr=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!ur&&(ur=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!dr)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)){G(`voice-link-hook: saving state before navigation →`,r.href);try{dr.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(dr&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){G(`voice-form-hook: saving state before form submit`);try{dr.onBeforeNavigate()}catch{}}},!0)))}function pr(){dr=null,G(`voice-nav-hooks: deactivated`)}var mr=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(),hr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:mr(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function gr(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 _r=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,vr=(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}:{}}},yr=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},br=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function xr({siteId:e,config:t,children:n,language:r=`en`}){let i=(0,d.useMemo)(()=>e?{...t||{},siteId:e}:t||null,[e,t]),[a,o]=(0,d.useState)(0),[s,c]=(0,d.useState)(`booting`),[l,u]=(0,d.useState)(null),[m,h]=(0,d.useState)(null),[g,_]=(0,d.useState)(``),[x,S]=(0,d.useState)([]),E=(0,d.useCallback)(()=>{S(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()}])},[]),ee=(0,d.useCallback)(()=>{S(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()}])},[]),[D,O]=(0,d.useState)(j().isOpen),[ae,oe]=(0,d.useState)(j().activeScreen),[se,le]=(0,d.useState)(j().isHumanHandled),[ue,de]=(0,d.useState)(j().agentName),[M,fe]=(0,d.useState)(j().agentHeadshot),[pe,me]=(0,d.useState)(()=>re(i?.siteId)),[he,_e]=(0,d.useState)(!1),[ve,ye]=(0,d.useState)(!1),[be,xe]=(0,d.useState)(`idle`),[N,P]=(0,d.useState)(!1),[Se,Ce]=(0,d.useState)(!1),[we,F]=(0,d.useState)(``),[Oe,ke]=(0,d.useState)(!1),[Ae,je]=(0,d.useState)(0),[Me,Ne]=(0,d.useState)(0),[Pe,Fe]=(0,d.useState)(!1),[I,Ie]=(0,d.useState)(null),[L,Le]=(0,d.useState)(null),[Re,R]=(0,d.useState)(`idle`),[ze,Be]=(0,d.useState)(null),[Ve,He]=(0,d.useState)(!1),[Ue,We]=(0,d.useState)(``),[Ge,Ke]=(0,d.useState)(!1),z=(0,d.useRef)(null),B=(0,d.useRef)(null),qe=(0,d.useRef)(``),V=(0,d.useRef)(!1),Je=(0,d.useRef)(null),H=(0,d.useRef)(null),U=(0,d.useRef)(null),Ye=(0,d.useRef)(null),Xe=(0,d.useRef)(null),Ze=(0,d.useRef)(null),Qe=(0,d.useRef)(null),$e=(0,d.useRef)(!1),et=(0,d.useRef)({url:null,at:0}),tt=(0,d.useCallback)((e,t)=>{let n=e;try{n=new URL(e,window.location.origin).href}catch{}let r=et.current;return r.url===n&&Date.now()-r.at<4e3?Promise.resolve({navigated:!0,deduped:!0}):(et.current={url:n,at:Date.now()},lr(e,t))},[]),nt=(0,d.useRef)([]),rt=(0,d.useRef)(null),it=(0,d.useRef)(null),at=(0,d.useRef)(null),ot=(0,d.useRef)(!1),st=(0,d.useRef)(!1),ct=(0,d.useRef)(``),lt=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)([]),ft=(0,d.useRef)(0),pt=(0,d.useRef)(ue),mt=(0,d.useRef)([]),ht=(0,d.useRef)(!1),gt=(0,d.useRef)(!1),_t=(0,d.useRef)(i),vt=(0,d.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),yt=(0,d.useCallback)((e={})=>{let t=!!e.is_human_handled;return le(t),t?(oe(`agent`),e.agent_info?.name&&de(e.agent_info.name),e.agent_info?.headshot&&fe(e.agent_info.headshot),t):(oe(`ai`),t)},[]),bt=(0,d.useMemo)(()=>{let e=m?.widgetSettings?.call?.maxDurationSeconds??i?.widgetSettings?.call?.maxDurationSeconds??i?.callMaxDurationSeconds,t=Number(e);return Number.isFinite(t)&&t>0?t:y},[i,m]);(0,d.useEffect)(()=>{H.current=I},[I]),(0,d.useEffect)(()=>{pt.current=ue},[ue]),(0,d.useEffect)(()=>{gt.current=Oe},[Oe]),(0,d.useEffect)(()=>{_t.current=i},[i]);let xt=()=>{We(``)},St=(0,d.useCallback)(()=>{at.current&&=(window.clearTimeout(at.current),null)},[]),Ct=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return me(t),ie(t,i?.siteId),t};(0,d.useEffect)(()=>{let e=i?.siteId;if(!e)return;let t=re(e);if(t){me(t);return}me(t=>(t&&ie(t,e),t))},[i?.siteId]);let wt=(e=`unspecified`)=>{let t=rt.current||Ze.current?.callId,n=ft.current,r=lt.current;if(lt.current=null,ft.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=dt.current;if(dt.current=[],e.length>0&&t&&B.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;B.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,dt.current=[]}}else if(r&&r.state===`inactive`){let e=dt.current;if(dt.current=[],e.length>0&&t&&B.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;B.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else dt.current=[];if(ut.current){try{ut.current.close()}catch{}ut.current=null}U.current&&=(U.current.close(),null),Ye.current&&=(Ye.current.getTracks().forEach(e=>e.stop()),null),Xe.current&&=(Xe.current.srcObject=null,Xe.current.remove(),null),St(),Ze.current=null,nt.current=[],rt.current=null,it.current=null,ot.current=!1,He(!1),Ie(null),Le(null),R(`idle`),Be(null)},Tt=(e=new Date().toISOString())=>{let t=z.current,n=rt.current||Ze.current?.callId;if(!(!t?.connected||!n||ot.current)){ot.current=!0,t.emit(`call:connected`,{callId:n,chatId:qe.current,connectedAt:e});try{let e=Ye.current,t=Xe.current?.srcObject;if(e&&t&&!lt.current){dt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);ut.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&&dt.current.push(e.data)},lt.current=a,ft.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{}}},Et=(e={})=>{if(!e.callId)return;let t=it.current===e.callId,n=rt.current===e.callId,r=H.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(St(),Ie(null),t||n){rt.current=e.callId,Le(e.callId),R(e=>e===`connected`?e:`connecting`),O(!0);return}R(`idle`)}},Dt=(e={})=>{if(!e.callId)return;let t=it.current===e.callId,n=rt.current===e.callId,r=H.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(St(),n){wt();return}it.current=null,Ze.current=null,nt.current=[],Ie(null),R(`idle`)}},Ot=async(e={})=>{let t=U.current,n=z.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}),Ze.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),nt.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:qe.current,queuedCount:nt.current.length});for(let e of nt.current)await t.addIceCandidate(new RTCIceCandidate(e));nt.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:qe.current})};(0,d.useEffect)(()=>{ne({isOpen:D,activeScreen:ae,isHumanHandled:se,agentName:ue,agentHeadshot:M})},[D,ae,se,ue,M]),(0,d.useEffect)(()=>{let e=!0;return(async()=>{Ke(!0);try{let t=p(i),n=await Ee(t);if(!e)return;let a=t.siteId,o=k(a),s=ce(a),l=``;try{let e=V.current,r=Je.current;if(V.current=!1,Je.current=null,l=(await Te({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||C(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);w(),A(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||T(),A(a,l)}qe.current=l;let u=De({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});B.current=u,h({...n,apiBaseUrl:t.apiBaseUrl}),_(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,f=ln({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});z.current=f,f.on(`connect`,async()=>{xe(`connected`);let e=qe.current;if(e&&B.current)try{yt(await B.current.checkHumanHandled(e))}catch{}}),f.on(`disconnect`,()=>{xe(`disconnected`)}),f.on(`aiTyping`,()=>{ye(!0)}),f.on(`ai:typing`,()=>{ye(!0)}),f.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:mr(t.message)};ye(!1),_e(!1),!(n.type===`call_recording`||typeof n.message==`string`&&n.message.includes(`AI chat recording`))&&S(e=>[...e.filter(e=>!e.isPending),{...n,isPending:!1,id:n.messageId||`${n.sender}-${Date.now()}-${Math.random()}`}])}),f.on(`conversationStarted`,e=>{e?.message&&S(t=>[...t,{id:`system-start-${Date.now()}`,sender:`system`,message:e.message,timestamp:new Date().toISOString(),isPending:!1}])}),f.on(`message:new`,e=>{let t=e.message||e,n={...t,message:mr(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`)&&_e(!1),S(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)&&(le(!0),oe(`agent`),de(yr([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&fe(n.sender_headshot),O(!0),je(e=>e+1)))});let m=(e={})=>{let t=yr([e.agent?.name,e.agentName,e.agent_name,pt.current],d);le(!0),oe(`agent`),de(t),fe(e.agent?.headshot||null),O(!0),je(e=>e+1),S(e=>br(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},g=(e={})=>{let t=yr([e.agent?.name,e.agentName,e.agent_name,pt.current],d);le(!1),oe(`ai`),S(e=>br(e,{id:`agent-left-${Date.now()}`,sender:`system`,message:`${t} has left the chat.`,timestamp:new Date().toISOString(),isPending:!1}))};f.on(`agent:joined`,m),f.on(`agentJoined`,m),f.on(`agent:left`,g),f.on(`agentLeft`,g),f.on(`conversationEnded`,e=>{Fe(!0);let t=e?.message||`This conversation has ended. Thank you for reaching out!`;S(e=>[...e,{id:`conversation-ended-${Date.now()}`,sender:`system`,message:t,timestamp:new Date().toISOString(),isPending:!1}])}),f.on(`chat:history_update`,e=>{let t=hr(e.chat_history||[]);S(t),t.length===0&&(Fe(!1),le(!1),oe(`ai`),ye(!1),_e(!1))}),f.on(`conversation:reset`,()=>{S([]),Fe(!1),le(!1),oe(`ai`),ye(!1),_e(!1)}),f.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending voice session`),Ne(e=>e+1),O(!0),je(e=>e+1)}),f.on(`typing:start`,e=>{e.sender===`agent`&&_e(!0)}),f.on(`typing:stop`,e=>{e.sender===`agent`&&_e(!1)}),f.on(`call:incoming`,(e={})=>{let t=yr([e.agentName,e.ownerName,e.agent?.name,pt.current],`Agent`);xt(),St(),ot.current=!1,Ie({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),de(e=>yr([t,e],`Agent`)),R(`incoming`),Be(null),O(!0)}),f.on(`call:offer`,async(e={})=>{Ze.current=e;try{await Ot(e)}catch(e){console.error(`[FlowEngageProvider] failed to apply remote offer`,e)}}),f.on(`call:ice-candidate-from-agent`,async(e={})=>{if(e.candidate)try{let t=vr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!U.current||!U.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||qe.current,queueSize:nt.current.length+1}),nt.current.push(t);return}await U.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),f.on(`call:ended`,()=>{xt(),wt(`socket:call_ended`)}),f.on(`call:accepted`,(e={})=>{Et(e)}),f.on(`call:accepted_by_other`,(e={})=>{Et(e)}),f.on(`call:rejected`,(e={})=>{Dt(e)}),f.on(`call:missed`,(e={})=>{Dt(e)}),f.on(`call:failed`,(e={})=>{Dt(e)}),f.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=it.current===e.callId,n=rt.current===e.callId,r=Ze.current?.callId===e.callId,i=H.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Ie(null),R(`idle`));return}ot.current=!0,it.current=null,rt.current=e.callId,Le(e.callId),Ie(null),R(`connected`),Be(e.connectedAt||new Date().toISOString()),O(!0)}),f.on(`call:unavailable`,(e={})=>{wt(`socket:call_unavailable`),We(_r(e,`This visitor is not available for a call right now.`)),O(!0)}),f.on(`call:error`,(e={})=>{wt(`socket:call_error`),We(_r(e,`We couldn't connect the call right now.`)),O(!0)}),f.on(`visitor:navigate`,async({url:e,section:t,highlight:n}={})=>{e&&tt(e,{voiceActive:gt.current}).then(({navigated:e,reason:r})=>{if(!e){r===`not-found`?E():r===`already-on-page`&&ee();return}let i=t||n;!i||!gt.current||setTimeout(()=>{let e=Zn(null,i);e&&Qn(e)},300)})}),f.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=Zn(e||null,t||null);n&&Qn(n)}),f.on(`visitor:clear_highlight`,()=>{$n()}),vt.current=un({socket:f,chatId:l});let v=await u.loadHistory(l,r);if(!e)return;S(hr(v.chat_history||[])),le(!!v.is_human_handled),oe(v.is_human_handled?`agent`:ae);let y=v?.visitor_email||v?.visitorEmail;if(y&&String(y).trim()&&Ct(String(y).trim()),await new Promise(e=>setTimeout(e,500)),!e)return;c(`ready`)}catch(t){if(!e)return;u(t),c(`error`)}finally{e&&Ke(!1)}})(),()=>{e=!1,vt.current?.cleanup?.(),wt(),z.current?.disconnect()}},[i,r,a]),(0,d.useEffect)(()=>()=>{if(Oe&&!ht.current&&mt.current.length>0){let e=qe.current,t=mt.current,n=B.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(()=>{}),ht.current=!0)}},[Oe,m]);let kt=(0,d.useRef)(null);(0,d.useEffect)(()=>{let e=B.current;!e||!g||kt.current!==D&&(D&&kt.current!==null?e.updateChatStatus(g,`open`).catch(()=>{}):kt.current===!0&&e.updateChatStatus(g,`widget_closed`).catch(()=>{}),kt.current=D)},[D,g]),(0,d.useEffect)(()=>{let e=()=>{let e=qe.current,t=B.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 At=async()=>{if(!(!I?.callId||!B.current||!z.current||!g)){xt(),it.current=I.callId,St();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});Ye.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await B.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});U.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();R(`connected`),Be(t=>t||e),Tt(e);return}if(e===`connecting`){R(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&wt(`peer:connection_${e}`)},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();R(`connected`),Be(t=>t||e),Tt(e);return}if(e===`checking`||e===`new`){R(e=>e===`connected`?e:`connecting`);return}(e===`failed`||e===`closed`)&&wt(`peer:ice_${e}`)},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!z.current?.connected)return;let t=e.candidate;z.current.emit(`call:ice-candidate`,{callId:I.callId,candidate:t.candidate,sdpMid:t.sdpMid,sdpMLineIndex:t.sdpMLineIndex,chatId:g,from:`customer`})},n.ontrack=e=>{let[t]=e.streams||[],[n]=t?.getAudioTracks?.()||[];if(!Xe.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=>{},Xe.current=e,document.body.appendChild(e)}Xe.current.srcObject=e.streams[0];let r=I?.callId,i=r&&(it.current===r||rt.current===r);if(!ot.current&&i){let e=new Date().toISOString();R(`connected`),Be(t=>t||e),rt.current=r,Le(r),Tt(e)}Xe.current.srcObject=t||null;let a=Xe.current.play?.();a?.catch&&a.catch(e=>{})};let r=Ze.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||I.callId,chatId:g}),await Ot({...r,callId:r.callId||I.callId})),await B.current.acceptCall(I.callId,g),z.current?.emit(`call:accepted`,{callId:I.callId,chatId:g}),rt.current=I.callId,Le(I.callId),R(e=>e===`connected`||ot.current?`connected`:`connecting`),Ie(null),O(!0)}catch(e){if(it.current=null,wt(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){We(_r(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await B.current.rejectCall(I.callId,g)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}We(`Microphone access was denied. Please allow microphone access to accept the call.`);return}We(`We couldn't connect the call right now. Please try again.`)}}},jt=async()=>{if(!I?.callId||!B.current||!g){wt(`reject_call_without_server_context`);return}let e=I.callId;St(),xt(),z.current?.emit(`call:rejected`,{callId:e,chatId:g,reason:`visitor_declined`});try{await B.current.rejectCall(e,g)}catch(e){We(_r(e,`We couldn't decline the call cleanly.`))}finally{wt(`reject_call_finally`)}},Mt=(0,d.useRef)(jt);Mt.current=jt,(0,d.useEffect)(()=>{if(!I?.callId||L){St();return}let e=I.callId;return St(),at.current=window.setTimeout(()=>{H.current?.callId===e&&it.current!==e&&rt.current!==e&&Mt.current()},b),()=>{at.current&&=(window.clearTimeout(at.current),null)}},[L,St,I?.callId]);let Nt=async()=>{if(!L||!B.current||!g){wt(`end_call_without_server_context`);return}xt();try{await B.current.endWebRTCCall(L,g)}catch(e){We(_r(e,`The call ended locally, but the server could not be updated.`))}finally{wt(`end_call_finally`)}},Pt=()=>{let e=Ye.current?.getAudioTracks?.()||[],t=U.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!Ve;n.forEach(e=>{e.enabled=!r}),He(r)},Ft=async(e={})=>{let t=e.notifyChatInitiated===!0;if(O(!0),!(!t||!B.current||!g||typeof window>`u`)){try{await B.current.trackVisitor({chatId:g,currentPagePath:window.location.pathname||`/`})}catch{}try{await B.current.updateChatStatus(g,`open`)}catch{}}},It=async e=>{let t=Ct(e);if(!t||!B.current||!qe.current)return t;try{await B.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},Lt=()=>{!g||!z.current?.connected||st.current||(st.current=!0,z.current.emit(`typing:start`,{chatId:g,sender:`user`}))},Rt=()=>{!g||!z.current?.connected||!st.current||(st.current=!1,z.current.emit(`typing:stop`,{chatId:g,sender:`user`}))},zt=(e=``)=>{let t=typeof e==`string`?e:``;!g||!z.current?.connected||t!==``&&ct.current===t||(ct.current=t,z.current.emit(`typing:update`,{chatId:g,sender:`user`,text:t}))};function Bt(){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 Vt=async(e,t=``,n=null,i={})=>{let a=typeof e==`string`?e.trim():``;if(!a||!B.current||!g||s!==`ready`||Pe)return;Rt(),$e.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(Qe.current&&o.test(a)&&!c.test(a)){let{url:e,section:t}=Qe.current;Qe.current=null,$e.current=!0,console.log(`[FWH Nav] Client-side nav firing →`,e),tt(e,{voiceActive:gt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?E():n===`already-on-page`&&ee();return}!t||!gt.current||setTimeout(()=>{let e=Zn(null,t);e&&Qn(e)},300)})}else o.test(a)||(Qe.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||{}};S(e=>[...e,f]);let p=se;if(p)try{p=yt(await B.current.checkHumanHandled(g))}catch{}if(p&&z.current?.connected){z.current.emit(`customer:message`,{chatId:g,content:e,sender:`user`,email:pe||void 0,type:i?.type||`text`,metadata:i?.metadata||{},...n||{}});return}P(!0);try{let o=await B.current.sendAiMessage(g,e,r,t,{...n||{},...pe?{email:pe}:{}},{...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:Bt()||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),tt(e.url,{voiceActive:gt.current}).then(({navigated:t,reason:n})=>{if(!t){n===`not-found`?E():n===`already-on-page`&&ee();return}e.section&&setTimeout(()=>{let t=Zn(null,e.section);t&&Qn(t)},300)})):(Qe.current=e,console.log(`[FWH Nav] Stored pending nav →`,Qe.current))}if(o.navigate?.url)if($e.current)$e.current=!1;else{let{url:e,section:t}=o.navigate;tt(e,{voiceActive:gt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?E():n===`already-on-page`&&ee();return}!t||!gt.current||setTimeout(()=>{let e=Zn(null,t);e&&Qn(e)},300)})}else{let e=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(e?.message){let t=gr(e.message);t&&nr(t.url,{siteId:_t.current?.siteId,apiBaseUrl:_t.current?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{if(!e){E();return}tt(n||t.url,{voiceActive:gt.current}).then(({navigated:e,reason:n})=>{if(!e){n===`not-found`?E():n===`already-on-page`&&ee();return}!t.section||!gt.current||setTimeout(()=>{let e=Zn(null,t.section);e&&Qn(e)},300)})})}}S(hr(s)),le(!!o.is_human_handled),oe(o.is_human_handled?`agent`:`ai`),ye(!1),P(!1),await B.current.updateChatStatus(g,`messageSent`)}catch(e){S(e=>e.filter(e=>e.id!==d)),ye(!1),P(!1),e.status===429?(Ce(!0),F(e.message),window.setTimeout(()=>{Ce(!1),F(``)},v)):u(e)}},Ht=async e=>{if(!B.current||!e)throw Error(`Upload is unavailable right now.`);return B.current.uploadChatFile(e)},Ut=async e=>{if(!(!B.current||!g)){try{let t=e?`voice`:`text`;await B.current.setChatMode(g,t)}catch{}ke(e),e&&(ht.current=!1)}},Wt=async e=>{if(ht.current)return;if(ht.current=!0,!B.current||!g||!e?.length){ke(!1);return}let t=()=>{let t=hr(e);S(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 B.current.syncVoice(g,e);if(n?.chat_history?.length)S(hr(n.chat_history));else if(n?.success)try{let e=await B.current.loadHistory(g,r);e?.chat_history?.length?S(hr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{ke(!1)}},Gt=async()=>{if(!(!B.current||!g)){Oe&&!ht.current&&mt.current.length>0&&await Wt(mt.current);try{await B.current.endConversation(g)}catch{try{await B.current.updateChatStatus(g,`ended`)}catch{}}Fe(!0),S(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,d.useEffect)(()=>{if(Re!==`connected`||!L||!g||!ze||!bt)return;let e=new Date(ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,bt*1e3-t),r=window.setTimeout(()=>{We(`The call ended because it reached the time limit.`),Nt()},n);return()=>window.clearTimeout(r)},[L,ze,Re,g,Nt,bt]),(0,d.useEffect)(()=>{let e=()=>{let e=qe.current,t=B.current;if(!t||!e)return;if(gt.current&&mt.current.length>0&&ge(),!ht.current&&mt.current.length>0&&(t.beaconSyncVoice(e,mt.current)||t.syncVoice(e,mt.current).catch(()=>{}),ht.current=!0),rt.current){t.beaconEndWebRTCCall(rt.current,e);return}let n=it.current||H.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 W=(0,d.useCallback)(()=>{let e=i?.siteId;te(e),V.current=!0,Je.current=null,z.current?.disconnect(),S([]),_(``),qe.current=``,Fe(!1),le(!1),de(null),fe(null),Ke(!0),o(e=>e+1)},[i?.siteId]),Kt=(0,d.useCallback)(e=>{i?.siteId,V.current=!1,Je.current=e,z.current?.disconnect(),S([]),_(``),qe.current=``,Fe(!1),le(!1),de(null),fe(null),Ke(!0),o(e=>e+1)},[i?.siteId]),qt=(0,d.useMemo)(()=>({status:s,error:l,runtimeConfig:m,resolvedConfig:i,chatId:g,chatHistory:x,isOpen:D,activeScreen:ae,isHumanHandled:se,agentName:ue,agentHeadshot:M,visitorEmail:pe,isAgentTyping:he,isAiTyping:ve,connectionStatus:be,isLoading:N,isVoiceMode:Oe,isRateLimited:Se,rateLimitMessage:we,isConversationEnded:Pe,isSessionRestoring:Ge,openToChatCounter:Ae,voiceEndCounter:Me,incomingCall:I,activeCallId:L,callConnectionState:Re,callConnectedAt:ze,isCallMuted:Ve,webRTCError:Ue,language:r,historyRef:mt,hasSyncedRef:ht,dismissCallError:xt,captureVisitorEmail:It,startTyping:Lt,stopTyping:Rt,updateTypingDraft:zt,notifyRouteChange:()=>vt.current?.notifyRouteChange?.(),openWidget:Ft,closeWidget:()=>O(!1),toggleWidget:()=>{if(D){O(!1);return}Ft({notifyChatInitiated:!0})},sendMessage:Vt,uploadChatFile:Ht,setVoiceMode:Ut,onMessageSync:Wt,endConversation:Gt,startNewChat:W,resumeChat:Kt,getVisitorChatHistory:()=>B.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>B.current?.getVisitorChatThread?.(e),acceptCall:At,rejectCall:jt,endWebRTCCall:Nt,toggleCallMute:Pt}),[s,l,m,i,g,x,D,ae,se,ue,M,pe,he,ve,be,N,Oe,Se,we,Pe,Ge,Ae,Me,I,L,Re,ze,Ve,Ue,r,It,Lt,Rt,zt,At,jt,Nt,Pt,Ft,Vt,Ht,Ut,Wt,Gt,W,xt]);return(0,f.jsx)(dn.Provider,{value:qt,children:n})}var Sr=(0,d.createContext)({});function Cr(e){let t=(0,d.useRef)(null);return t.current===null&&(t.current=e()),t.current}var wr=typeof window<`u`?d.useLayoutEffect:d.useEffect,Tr=(0,d.createContext)(null);function Er(e,t){e.indexOf(t)===-1&&e.push(t)}function Dr(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Or=(e,t,n)=>n>t?t:n<e?e:n;function kr(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var Ar=()=>{},jr=()=>{};typeof process<`u`&&process.env.NODE_ENV!==`production`&&(Ar=(e,t,n)=>{!e&&typeof console<`u`&&console.warn(kr(t,n))},jr=(e,t,n)=>{if(!e)throw Error(kr(t,n))});var Mr={},Nr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Pr(e){return typeof e==`object`&&!!e}var Fr=e=>/^0[^.\s]+$/u.test(e);function Ir(e){let t;return()=>(t===void 0&&(t=e()),t)}var Lr=e=>e,Rr=(e,t)=>n=>t(e(n)),zr=(...e)=>e.reduce(Rr),Br=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Vr=class{constructor(){this.subscriptions=[]}add(e){return Er(this.subscriptions,e),()=>Dr(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}},Hr=e=>e*1e3,Ur=e=>e/1e3;function Wr(e,t){return t?1e3/t*e:0}var Gr=new Set;function Kr(e,t,n){e||Gr.has(t)||(console.warn(kr(t,n)),Gr.add(t))}var qr=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,Jr=1e-7,Yr=12;function Xr(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=qr(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>Jr&&++s<Yr);return o}function Zr(e,t,n,r){if(e===t&&n===r)return Lr;let i=t=>Xr(t,0,1,e,n);return e=>e===0||e===1?e:qr(i(e),t,r)}var Qr=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,$r=e=>t=>1-e(1-t),ei=Zr(.33,1.53,.69,.99),ti=$r(ei),ni=Qr(ti),ri=e=>e>=1?1:(e*=2)<1?.5*ti(e):.5*(2-2**(-10*(e-1))),ii=e=>1-Math.sin(Math.acos(e)),ai=$r(ii),oi=Qr(ii),si=Zr(.42,0,1,1),ci=Zr(0,0,.58,1),li=Zr(.42,0,.58,1),ui=e=>Array.isArray(e)&&typeof e[0]!=`number`,di=e=>Array.isArray(e)&&typeof e[0]==`number`,fi={linear:Lr,easeIn:si,easeInOut:li,easeOut:ci,circIn:ii,circInOut:oi,circOut:ai,backIn:ti,backInOut:ni,backOut:ei,anticipate:ri},pi=e=>typeof e==`string`,mi=e=>{if(di(e)){jr(e.length===4,`Cubic bezier arrays must contain four numerical values.`,`cubic-bezier-length`);let[t,n,r,i]=e;return Zr(t,n,r,i)}else if(pi(e))return jr(fi[e]!==void 0,`Invalid easing type '${e}'`,`invalid-easing-type`),fi[e];return e},hi=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],gi={value:null,addProjectionMetrics:null};function _i(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&&gi.value&&gi.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var vi=40;function yi(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=hi.reduce((e,n)=>(e[n]=_i(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=Mr.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,vi),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:hi.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<hi.length;t++)o[hi[t]].cancel(e)},state:i,steps:o}}var{schedule:K,cancel:bi,state:xi,steps:Si}=yi(typeof requestAnimationFrame<`u`?requestAnimationFrame:Lr,!0),Ci;function wi(){Ci=void 0}var Ti={now:()=>(Ci===void 0&&Ti.set(xi.isProcessing||Mr.useManualTiming?xi.timestamp:performance.now()),Ci),set:e=>{Ci=e,queueMicrotask(wi)}},Ei={layout:0,mainThread:0,waapi:0},Di=e=>t=>typeof t==`string`&&t.startsWith(e),Oi=Di(`--`),ki=Di(`var(--`),Ai=e=>ki(e)?ji.test(e.split(`/*`)[0].trim()):!1,ji=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Mi(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Ni={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Pi={...Ni,transform:e=>Or(0,1,e)},Fi={...Ni,default:1},Ii=e=>Math.round(e*1e5)/1e5,Li=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ri(e){return e==null}var zi=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Bi=(e,t)=>n=>!!(typeof n==`string`&&zi.test(n)&&n.startsWith(e)||t&&!Ri(n)&&Object.prototype.hasOwnProperty.call(n,t)),Vi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Li);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Hi=e=>Or(0,255,e),Ui={...Ni,transform:e=>Math.round(Hi(e))},Wi={test:Bi(`rgb`,`red`),parse:Vi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Ui.transform(e)+`, `+Ui.transform(t)+`, `+Ui.transform(n)+`, `+Ii(Pi.transform(r))+`)`};function Gi(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 Ki={test:Bi(`#`),parse:Gi,transform:Wi.transform},qi=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),Ji=qi(`deg`),Yi=qi(`%`),q=qi(`px`),Xi=qi(`vh`),Zi=qi(`vw`),Qi={...Yi,parse:e=>Yi.parse(e)/100,transform:e=>Yi.transform(e*100)},$i={test:Bi(`hsl`,`hue`),parse:Vi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+Yi.transform(Ii(t))+`, `+Yi.transform(Ii(n))+`, `+Ii(Pi.transform(r))+`)`},J={test:e=>Wi.test(e)||Ki.test(e)||$i.test(e),parse:e=>Wi.test(e)?Wi.parse(e):$i.test(e)?$i.parse(e):Ki.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Wi.transform(e):$i.transform(e),getAnimatableNone:e=>{let t=J.parse(e);return t.alpha=0,J.transform(t)}},ea=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ta(e){return isNaN(e)&&typeof e==`string`&&(e.match(Li)?.length||0)+(e.match(ea)?.length||0)>0}var na=`number`,ra=`color`,ia=`var`,aa=`var(`,oa="${}",sa=/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 ca(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(sa,e=>(J.test(e)?(r.color.push(a),i.push(ra),n.push(J.parse(e))):e.startsWith(aa)?(r.var.push(a),i.push(ia),n.push(e)):(r.number.push(a),i.push(na),n.push(parseFloat(e))),++a,oa)).split(oa),indexes:r,types:i}}function la(e){return ca(e).values}function ua({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===na?i+=Ii(r[a]):e===ra?i+=J.transform(r[a]):i+=r[a]}return i}}function da(e){return ua(ca(e))}var fa=e=>typeof e==`number`?0:J.test(e)?J.getAnimatableNone(e):e,pa=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:fa(e);function ma(e){let t=ca(e);return ua(t)(t.values.map((e,n)=>pa(e,t.split[n])))}var ha={test:ta,parse:la,createTransformer:da,getAnimatableNone:ma};function ga(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 _a({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=ga(s,r,e+1/3),a=ga(s,r,e),o=ga(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function va(e,t){return n=>n>0?t:e}var Y=(e,t,n)=>e+(t-e)*n,ya=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},ba=[Ki,Wi,$i],xa=e=>ba.find(t=>t.test(e));function Sa(e){let t=xa(e);if(Ar(!!t,`'${e}' is not an animatable color. Use the equivalent color code instead.`,`color-not-animatable`),!t)return!1;let n=t.parse(e);return t===$i&&(n=_a(n)),n}var Ca=(e,t)=>{let n=Sa(e),r=Sa(t);if(!n||!r)return va(e,t);let i={...n};return e=>(i.red=ya(n.red,r.red,e),i.green=ya(n.green,r.green,e),i.blue=ya(n.blue,r.blue,e),i.alpha=Y(n.alpha,r.alpha,e),Wi.transform(i))},wa=new Set([`none`,`hidden`]);function Ta(e,t){return wa.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Ea(e,t){return n=>Y(e,t,n)}function Da(e){return typeof e==`number`?Ea:typeof e==`string`?Ai(e)?va:J.test(e)?Ca:ja:Array.isArray(e)?Oa:typeof e==`object`?J.test(e)?Ca:ka:va}function Oa(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Da(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function ka(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Da(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Aa(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 ja=(e,t)=>{let n=ha.createTransformer(t),r=ca(e),i=ca(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?wa.has(e)&&!i.values.length||wa.has(t)&&!r.values.length?Ta(e,t):zr(Oa(Aa(r,i),i.values),n):(Ar(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`,`complex-values-different`),va(e,t))};function Ma(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Y(e,t,n):Da(e)(e,t)}var Na=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>K.update(t,e),stop:()=>bi(t),now:()=>xi.isProcessing?xi.timestamp:Ti.now()}},Pa=(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)})`},Fa=2e4;function Ia(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 La(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Ia(r),Fa);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Ur(i)}}var X={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 Ra(e,t){return e*Math.sqrt(1-t*t)}var za=12;function Ba(e,t,n){let r=n;for(let n=1;n<za;n++)r-=e(r)/t(r);return r}var Va=.001;function Ha({duration:e=X.duration,bounce:t=X.bounce,velocity:n=X.velocity,mass:r=X.mass}){let i,a;Ar(e<=Hr(X.maxDuration),`Spring duration must be 10 seconds or less`,`spring-duration-limit`);let o=1-t;o=Or(X.minDamping,X.maxDamping,o),e=Or(X.minDuration,X.maxDuration,Ur(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=Ra(t,o),c=Math.exp(-i);return Va-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=Ra(t**2,o);return(-i(t)+Va>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Va+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Ba(i,a,s);if(e=Hr(e),isNaN(c))return{stiffness:X.stiffness,damping:X.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Ua=[`duration`,`bounce`],Wa=[`stiffness`,`damping`,`mass`];function Ga(e,t){return t.some(t=>e[t]!==void 0)}function Ka(e){let t={velocity:X.velocity,stiffness:X.stiffness,damping:X.damping,mass:X.mass,isResolvedFromDuration:!1,...e};if(!Ga(e,Wa)&&Ga(e,Ua))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Or(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:X.mass,stiffness:i,damping:a}}else{let n=Ha({...e,velocity:0});t={...t,...n,mass:X.mass},t.isResolvedFromDuration=!0}return t}function qa(e=X.visualDuration,t=X.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}=Ka({...n,velocity:-Ur(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Ur(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?X.restSpeed.granular:X.restSpeed.default,i||=v?X.restDelta.granular:X.restDelta.default;let y,b,x,S,C,w;if(h<1)x=Ra(_,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 T={calculatedDuration:p&&d||null,velocity:e=>Hr(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=Hr(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=Hr(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(Ia(T),Fa),t=Pa(t=>T.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return T}qa.applyToOptions=e=>{let t=La(e,100,qa);return e.ease=t.ease,e.duration=Hr(t.duration),e.type=`keyframes`,e};var Ja=5;function Ya(e,t,n){let r=Math.max(t-Ja,0);return Wr(n-e(r),t-r)}function Xa({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=qa({keyframes:[f.value,m(f.value)],velocity:Ya(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 Za(e,t,n){let r=[],i=n||Mr.mix||Ma,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=zr(Array.isArray(t)?t[n]||Lr:t,a)),r.push(a)}return r}function Qa(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(jr(a===t.length,`Both input and output ranges must be the same length`,`range-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=Za(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=Br(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Or(e[0],e[a-1],t)):l}function $a(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Br(0,t,r);e.push(Y(n,1,i))}}function eo(e){let t=[0];return $a(t,e.length-1),t}function to(e,t){return e.map(e=>e*t)}function no(e,t){return e.map(()=>t||li).splice(0,e.length-1)}function ro({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=ui(r)?r.map(mi):mi(r),a={done:!1,value:t[0]},o=Qa(to(n&&n.length===t.length?n:eo(t),e),t,{ease:Array.isArray(i)?i:no(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var io=e=>e!==null;function ao(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(io),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var oo={decay:Xa,inertia:Xa,tween:ro,keyframes:ro,spring:qa};function so(e){typeof e.type==`string`&&(e.type=oo[e.type])}var co=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)}},lo=e=>e/100,uo=class extends co{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!==Ti.now()&&this.tick(Ti.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Ei.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;so(e);let{type:t=ro,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||ro;process.env.NODE_ENV!==`production`&&s!==ro&&jr(o.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${o}`,`spring-two-frames`),s!==ro&&typeof o[0]!=`number`&&(this.mixKeyframes=zr(lo,Ma(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=Ia(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=Or(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!==Xa&&(b.value=ao(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 Ur(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Ur(e)}get time(){return Ur(this.currentTime)}set time(e){e=Hr(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 Ya(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(Ti.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Ur(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Na,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(Ti.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,Ei.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 fo(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var po=e=>e*180/Math.PI,mo=e=>go(po(Math.atan2(e[1],e[0]))),ho={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:mo,rotateZ:mo,skewX:e=>po(Math.atan(e[1])),skewY:e=>po(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},go=e=>(e%=360,e<0&&(e+=360),e),_o=mo,vo=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),yo=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),bo={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:vo,scaleY:yo,scale:e=>(vo(e)+yo(e))/2,rotateX:e=>go(po(Math.atan2(e[6],e[5]))),rotateY:e=>go(po(Math.atan2(-e[2],e[0]))),rotateZ:_o,rotate:_o,skewX:e=>po(Math.atan(e[4])),skewY:e=>po(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function xo(e){return e.includes(`scale`)?1:0}function So(e,t){if(!e||e===`none`)return xo(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=bo,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=ho,i=t}if(!i)return xo(t);let a=r[t],o=i[1].split(`,`).map(wo);return typeof a==`function`?a(o):o[a]}var Co=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return So(n,t)};function wo(e){return parseFloat(e.trim())}var To=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Eo=new Set(To),Do=e=>e===Ni||e===q,Oo=new Set([`x`,`y`,`z`]),ko=To.filter(e=>!Oo.has(e));function Ao(e){let t=[];return ko.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var jo={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})=>So(t,`x`),y:(e,{transform:t})=>So(t,`y`)};jo.translateX=jo.x,jo.translateY=jo.y;var Mo=new Set,No=!1,Po=!1,Fo=!1;function Io(){if(Po){let e=Array.from(Mo).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Ao(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)})}Po=!1,No=!1,Mo.forEach(e=>e.complete(Fo)),Mo.clear()}function Lo(){Mo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Po=!0)})}function Ro(){Fo=!0,Lo(),Io(),Fo=!1}var zo=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?(Mo.add(this),No||(No=!0,K.read(Lo),K.resolveKeyframes(Io))):(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])}fo(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Mo.delete(this)}cancel(){this.state===`scheduled`&&(Mo.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Bo=e=>e.startsWith(`--`);function Vo(e,t,n){Bo(t)?e.style.setProperty(t,n):e.style[t]=n}var Ho={};function Uo(e,t){let n=Ir(e);return()=>Ho[t]??n()}var Wo=Uo(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),Go=Uo(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),Ko=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,qo={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:Ko([0,.65,.55,1]),circOut:Ko([.55,0,1,.45]),backIn:Ko([.31,.01,.66,-.59]),backOut:Ko([.33,1.53,.69,.99])};function Jo(e,t){if(e)return typeof e==`function`?Go()?Pa(e,t):`ease-out`:di(e)?Ko(e):Array.isArray(e)?e.map(e=>Jo(e,t)||qo.easeOut):qo[e]}function Yo(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=Jo(s,i);Array.isArray(d)&&(u.easing=d),gi.value&&Ei.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 gi.value&&p.finished.finally(()=>{Ei.waapi--}),p}function Xo(e){return typeof e==`function`&&`applyToOptions`in e}function Zo({type:e,...t}){return Xo(e)&&Go()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var Qo=class extends co{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,jr(typeof e.type!=`string`,`Mini animate() doesn't support "type" as a string.`,`mini-spring`);let c=Zo(e);this.animation=Yo(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=ao(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Vo(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 Ur(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Ur(e)}get time(){return Ur(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Hr(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&&Wo()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Lr):r(this)}},$o={anticipate:ri,backInOut:ni,circInOut:oi};function es(e){return e in $o}function ts(e){typeof e.ease==`string`&&es(e.ease)&&(e.ease=$o[e.ease])}var ns=10,rs=class extends Qo{constructor(e){ts(e),so(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 uo({...a,autoplay:!1}),s=Math.max(ns,Ti.now()-this.startTime),c=Or(0,ns,s-ns),l=o.sample(s).value,{name:u}=this.options;i&&u&&Vo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},is=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(ha.test(e)||e===`0`)&&!e.startsWith(`url(`));function as(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 os(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=is(i,t),s=is(a,t);return Ar(o===s,`You are trying to animate ${t} from "${i}" to "${a}". "${o?a:i}" is not an animatable value.`,`value-not-animatable`),!o||!s?!1:as(e)||(n===`spring`||Xo(n))&&r}function ss(e){e.duration=0,e.type=`keyframes`}var cs=new Set([`opacity`,`clipPath`,`filter`,`transform`]),ls=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function us(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&ls.test(e[t]))return!0;return!1}var ds=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),fs=Ir(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function ps(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 fs()&&n&&(cs.has(n)||ds.has(n)&&us(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var ms=40,hs=class extends co{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=Ti.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||zo)(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=Ti.now();let u=!0;os(e,i,a,o)||(u=!1,(Mr.instantAnimations||!s)&&l?.(ao(e,n,t)),e[0]=e[e.length-1],ss(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>ms?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&ps(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new rs({...d,element:p})}catch{m=new uo(d)}else m=new uo(d);m.finished.then(()=>{this.notifyFinished()}).catch(Lr),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(),Ro()),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 gs(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 _s=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function vs(e){let t=_s.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var ys=4;function bs(e,t,n=1){jr(n<=ys,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,`max-css-var-depth`);let[r,i]=vs(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Nr(e)?parseFloat(e):e}return Ai(i)?bs(i,t,n+1):i}var xs={type:`spring`,stiffness:500,damping:25,restSpeed:10},Ss=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Cs={type:`keyframes`,duration:.8},ws={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ts=(e,{keyframes:t})=>t.length>2?Cs:Eo.has(e)?e.startsWith(`scale`)?Ss(t[1]):xs:ws;function Es(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Ds(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Es(n,e)}var Os=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function ks(e){for(let t in e)if(!Os.has(t))return!0;return!1}var As=(e,t,n,r={},i,a)=>o=>{let s=Ds(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Hr(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};ks(s)||Object.assign(u,Ts(e,u)),u.duration&&=Hr(u.duration),u.repeatDelay&&=Hr(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(ss(u),u.delay===0&&(d=!0)),(Mr.instantAnimations||Mr.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,ss(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=ao(u.keyframes,s);if(e!==void 0){K.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new uo(u):new hs(u)};function js(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Ms(e,t,n,r){if(typeof t==`function`){let[i,a]=js(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]=js(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Ns(e,t,n){let r=e.getProps();return Ms(r,t,n===void 0?r.custom:n,e)}var Ps=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...To]),Fs=30,Is=e=>!isNaN(parseFloat(e)),Ls={current:void 0},Rs=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Ti.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=Ti.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Is(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!==`production`&&Kr(!1,`value.onChange(callback) is deprecated. Switch to value.on("change", callback).`),this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new Vr);let n=this.events[e].add(t);return e===`change`?()=>{n(),K.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 Ls.current&&Ls.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Ti.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Fs)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Fs);return Wr(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 zs(e,t){return new Rs(e,t)}var Bs=e=>Array.isArray(e);function Vs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,zs(n))}function Hs(e){return Bs(e)?e[e.length-1]||0:e}function Us(e,t){let{transitionEnd:n={},transition:r={},...i}=Ns(e,t)||{};i={...i,...n};for(let t in i)Vs(e,t,Hs(i[t]))}var Ws=e=>!!(e&&e.getVelocity);function Gs(e){return!!(Ws(e)&&e.add)}function Ks(e,t){let n=e.getValue(`willChange`);if(Gs(n))return n.add(t);if(!n&&Mr.WillChange){let n=new Mr.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function qs(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var Js=`data-`+qs(`framerAppearId`);function Ys(e){return e.props[Js]}function Xs({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Zs(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Es(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&&Xs(d,t))continue;let o={delay:n,...Ds(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){K.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=Ys(e);if(n){let e=window.MotionHandoffAnimation(n,t,K);e!==null&&(o.startTime=e,f=!0)}}Ks(e,t);let p=l??e.shouldReduceMotion;r.start(As(t,r,i,p&&Ps.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>K.update(()=>{o&&Us(e,o)});u.length?Promise.all(u).then(t):t()}return u}function Qs(e,t,n={}){let r=Ns(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(Zs(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return $s(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 $s(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(Qs(c,t,{...o,delay:n+(typeof r==`function`?0:r)+gs(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function ec(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>Qs(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=Qs(e,t,n);else{let i=typeof t==`function`?Ns(e,t,n.custom):t;r=Promise.all(Zs(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var tc={test:e=>e===`auto`,parse:e=>e},nc=e=>t=>t.test(e),rc=[Ni,q,Yi,Ji,Zi,Xi,tc],ic=e=>rc.find(nc(e));function ac(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Fr(e)}var oc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function sc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Li)||[];if(!r)return e;let i=n.replace(r,``),a=oc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var cc=/\b([a-z-]*)\(.*?\)/gu,lc={...ha,getAnimatableNone:e=>{let t=e.match(cc);return t?t.map(sc).join(` `):e}},uc={...ha,getAnimatableNone:e=>{let t=ha.parse(e);return ha.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},dc={...Ni,transform:Math.round},fc={borderWidth:q,borderTopWidth:q,borderRightWidth:q,borderBottomWidth:q,borderLeftWidth:q,borderRadius:q,borderTopLeftRadius:q,borderTopRightRadius:q,borderBottomRightRadius:q,borderBottomLeftRadius:q,width:q,maxWidth:q,height:q,maxHeight:q,top:q,right:q,bottom:q,left:q,inset:q,insetBlock:q,insetBlockStart:q,insetBlockEnd:q,insetInline:q,insetInlineStart:q,insetInlineEnd:q,padding:q,paddingTop:q,paddingRight:q,paddingBottom:q,paddingLeft:q,paddingBlock:q,paddingBlockStart:q,paddingBlockEnd:q,paddingInline:q,paddingInlineStart:q,paddingInlineEnd:q,margin:q,marginTop:q,marginRight:q,marginBottom:q,marginLeft:q,marginBlock:q,marginBlockStart:q,marginBlockEnd:q,marginInline:q,marginInlineStart:q,marginInlineEnd:q,fontSize:q,backgroundPositionX:q,backgroundPositionY:q,rotate:Ji,rotateX:Ji,rotateY:Ji,rotateZ:Ji,scale:Fi,scaleX:Fi,scaleY:Fi,scaleZ:Fi,skew:Ji,skewX:Ji,skewY:Ji,distance:q,translateX:q,translateY:q,translateZ:q,x:q,y:q,z:q,perspective:q,transformPerspective:q,opacity:Pi,originX:Qi,originY:Qi,originZ:q,zIndex:dc,fillOpacity:Pi,strokeOpacity:Pi,numOctaves:dc},pc={...fc,color:J,backgroundColor:J,outlineColor:J,fill:J,stroke:J,borderColor:J,borderTopColor:J,borderRightColor:J,borderBottomColor:J,borderLeftColor:J,filter:lc,WebkitFilter:lc,mask:uc,WebkitMask:uc},mc=e=>pc[e],hc=new Set([lc,uc]);function gc(e,t){let n=mc(e);return hc.has(n)||(n=ha),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var _c=new Set([`auto`,`none`,`0`]);function vc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!_c.has(t)&&ca(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=gc(n,i)}var yc=class extends zo{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(),Ai(r))){let i=bs(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Ps.has(n)||e.length!==2)return;let[r,i]=e,a=ic(r),o=ic(i);if(Mi(r)!==Mi(i)&&jo[n]){this.needsMeasurement=!0;return}if(a!==o)if(Do(a)&&Do(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else jo[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||ac(e[t]))&&n.push(t);n.length&&vc(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=jo[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]=jo[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 bc(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 xc=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function Sc(e){return Pr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Cc,cancel:wc}=yi(queueMicrotask,!1),Tc={x:!1,y:!1};function Ec(){return Tc.x||Tc.y}function Dc(e){return e===`x`||e===`y`?Tc[e]?null:(Tc[e]=!0,()=>{Tc[e]=!1}):Tc.x||Tc.y?null:(Tc.x=Tc.y=!0,()=>{Tc.x=Tc.y=!1})}function Oc(e,t){let n=bc(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function kc(e){return!(e.pointerType===`touch`||Ec())}function Ac(e,t,n={}){let[r,i,a]=Oc(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(!kc(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 jc=(e,t)=>t?e===t?!0:jc(e,t.parentElement):!1,Mc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Nc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Pc(e){return Nc.has(e.tagName)||e.isContentEditable===!0}var Fc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Ic(e){return Fc.has(e.tagName)||e.isContentEditable===!0}var Lc=new WeakSet;function Rc(e){return t=>{t.key===`Enter`&&e(t)}}function zc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Bc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=Rc(()=>{if(Lc.has(n))return;zc(n,`down`);let e=Rc(()=>{zc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>zc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Vc(e){return Mc(e)&&!Ec()}var Hc=new WeakSet;function Uc(e,t,n={}){let[r,i,a]=Oc(e,n),o=e=>{let r=e.currentTarget;if(!Vc(e)||Hc.has(e))return;Lc.add(r),n.stopPropagation&&Hc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),Lc.has(r)&&Lc.delete(r),Vc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||jc(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),Sc(e)&&(e.addEventListener(`focus`,e=>Bc(e,i)),!Pc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function Wc(e){return Pr(e)&&`ownerSVGElement`in e}var Gc=new WeakMap,Kc,qc=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:Wc(r)&&`getBBox`in r?r.getBBox()[t]:r[n],Jc=qc(`inline`,`width`,`offsetWidth`),Yc=qc(`block`,`height`,`offsetHeight`);function Xc({target:e,borderBoxSize:t}){Gc.get(e)?.forEach(n=>{n(e,{get width(){return Jc(e,t)},get height(){return Yc(e,t)}})})}function Zc(e){e.forEach(Xc)}function Qc(){typeof ResizeObserver>`u`||(Kc=new ResizeObserver(Zc))}function $c(e,t){Kc||Qc();let n=bc(e);return n.forEach(e=>{let n=Gc.get(e);n||(n=new Set,Gc.set(e,n)),n.add(t),Kc?.observe(e)}),()=>{n.forEach(e=>{let n=Gc.get(e);n?.delete(t),n?.size||Kc?.unobserve(e)})}}var el=new Set,tl;function nl(){tl=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};el.forEach(t=>t(e))},window.addEventListener(`resize`,tl)}function rl(e){return el.add(e),tl||nl(),()=>{el.delete(e),!el.size&&typeof tl==`function`&&(window.removeEventListener(`resize`,tl),tl=void 0)}}function il(e,t){return typeof e==`function`?rl(e):$c(e,t)}function al(e){return Wc(e)&&e.tagName===`svg`}var ol=[...rc,J,ha],sl=e=>ol.find(nc(e)),cl=()=>({translate:0,scale:1,origin:0,originPoint:0}),ll=()=>({x:cl(),y:cl()}),ul=()=>({min:0,max:0}),Z=()=>({x:ul(),y:ul()}),dl=new WeakMap;function fl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function pl(e){return typeof e==`string`||Array.isArray(e)}var ml=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],hl=[`initial`,...ml];function gl(e){return fl(e.animate)||hl.some(t=>pl(e[t]))}function _l(e){return!!(gl(e)||e.variants)}function vl(e,t,n){for(let r in t){let i=t[r],a=n[r];if(Ws(i))e.addValue(r,i);else if(Ws(a))e.addValue(r,zs(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,zs(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var yl={current:null},bl={current:!1},xl=typeof window<`u`;function Sl(){if(bl.current=!0,xl)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>yl.current=e.matches;e.addEventListener(`change`,t),t()}else yl.current=!1}var Cl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],wl={};function Tl(e){wl=e}function El(){return wl}var Dl=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=zo,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=Ti.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,K.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=gl(t),this.isVariantNode=_l(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&&Ws(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,dl.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:(bl.current||Sl(),this.shouldReduceMotion=yl.current),process.env.NODE_ENV!==`production`&&Kr(this.shouldReduceMotion!==!0,`You have Reduced Motion enabled on your device. Animations may not appear as expected.`,`reduced-motion-disabled`),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),bi(this.notifyUpdate),bi(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&&cs.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new Qo({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Hr(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Eo.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&K.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 wl){let t=wl[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):Z()}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<Cl.length;t++){let n=Cl[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=vl(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=zs(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`&&(Nr(n)||Fr(n))?n=parseFloat(n):!sl(n)&&ha.test(t)&&(n=gc(e,t)),this.setBaseTarget(e,Ws(n)?n.get():n)),Ws(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=Ms(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&&!Ws(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 Vr),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Cc.render(this.render)}},Ol=class extends Dl{constructor(){super(...arguments),this.KeyframeResolver=yc}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;Ws(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},kl=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Al({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function jl({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Ml(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 Nl(e){return e===void 0||e===1}function Pl({scale:e,scaleX:t,scaleY:n}){return!Nl(e)||!Nl(t)||!Nl(n)}function Fl(e){return Pl(e)||Il(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Il(e){return Ll(e.x)||Ll(e.y)}function Ll(e){return e&&e!==`0%`}function Rl(e,t,n){return n+t*(e-n)}function zl(e,t,n,r,i){return i!==void 0&&(e=Rl(e,i,r)),Rl(e,n,r)+t}function Bl(e,t=0,n=1,r,i){e.min=zl(e.min,t,n,r,i),e.max=zl(e.max,t,n,r,i)}function Vl(e,{x:t,y:n}){Bl(e.x,t.translate,t.scale,t.originPoint),Bl(e.y,n.translate,n.scale,n.originPoint)}var Hl=.999999999999,Ul=1.0000000000001;function Wl(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&&(Gl(e.x,-a.scroll.offset.x),Gl(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Vl(e,o)),r&&Fl(a.latestValues)&&Jl(e,a.latestValues,a.layout?.layoutBox))}t.x<Ul&&t.x>Hl&&(t.x=1),t.y<Ul&&t.y>Hl&&(t.y=1)}function Gl(e,t){e.min+=t,e.max+=t}function Kl(e,t,n,r,i=.5){Bl(e,t,n,Y(e.min,e.max,i),r)}function ql(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function Jl(e,t,n){let r=n??e;Kl(e.x,ql(t.x,r.x),t.scaleX,t.scale,t.originX),Kl(e.y,ql(t.y,r.y),t.scaleY,t.scale,t.originY)}function Yl(e,t){return Al(Ml(e.getBoundingClientRect(),t))}function Xl(e,t,n){let r=Yl(e,n),{scroll:i}=t;return i&&(Gl(r.x,i.offset.x),Gl(r.y,i.offset.y)),r}var Zl={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},Ql=To.length;function $l(e,t,n){let r=``,i=!0;for(let a=0;a<Ql;a++){let o=To[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=xc(s,fc[o]);if(!c){i=!1;let t=Zl[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function eu(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(Eo.has(e)){o=!0;continue}else if(Oi(e)){i[e]=n;continue}else{let t=xc(n,fc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=$l(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 tu(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 nu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var ru={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(q.test(e))e=parseFloat(e);else return e;return`${nu(e,t.target.x)}% ${nu(e,t.target.y)}%`}},iu={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=ha.parse(e);if(i.length>5)return r;let a=ha.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=Y(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},au={borderRadius:{...ru,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:ru,borderTopRightRadius:ru,borderBottomLeftRadius:ru,borderBottomRightRadius:ru,boxShadow:iu};function ou(e,{layout:t,layoutId:n}){return Eo.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!au[e]||e===`opacity`)}function su(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(Ws(r[t])||i&&Ws(i[t])||ou(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function cu(e){return window.getComputedStyle(e)}var lu=class extends Ol{constructor(){super(...arguments),this.type=`html`,this.renderInstance=tu}readValueFromInstance(e,t){if(Eo.has(t))return this.projection?.isProjecting?xo(t):Co(e,t);{let n=cu(e),r=(Oi(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return Yl(e,t)}build(e,t,n){eu(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return su(e,t,n)}},uu={offset:`stroke-dashoffset`,array:`stroke-dasharray`},du={offset:`strokeDashoffset`,array:`strokeDasharray`};function fu(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?uu:du;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var pu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function mu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(eu(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 pu)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&&fu(d,i,a,o,!1)}var hu=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`]),gu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function _u(e,t,n,r){tu(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(hu.has(n)?n:qs(n),t.attrs[n])}function vu(e,t,n){let r=su(e,t,n);for(let n in e)if(Ws(e[n])||Ws(t[n])){let t=To.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var yu=class extends Ol{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=Z}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Eo.has(t)){let e=mc(t);return e&&e.default||0}return t=hu.has(t)?t:qs(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return vu(e,t,n)}build(e,t,n){mu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){_u(e,t,n,r)}mount(e){this.isSVGTag=gu(e.tagName),super.mount(e)}},bu=hl.length;function xu(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&xu(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<bu;n++){let r=hl[n],i=e.props[r];(pl(i)||i===!1)&&(t[r]=i)}return t}function Su(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 Cu=[...ml].reverse(),wu=ml.length;function Tu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>ec(e,t,n)))}function Eu(e){let t=Tu(e),n=ku(),r=!0,i=!1,a=t=>(n,r)=>{let i=Ns(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=xu(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<wu;t++){let p=Cu[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=pl(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||fl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Du(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,T={...w,...C},E=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 T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Bs(t)&&Bs(n)?!Su(t,n):t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let ee=v&&y;b&&(!ee||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!ee&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Ns(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=gs(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Ns(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=ku(),i=!0}}}function Du(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Su(t,e):!1}function Ou(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function ku(){return{animate:Ou(!0),whileInView:Ou(),whileHover:Ou(),whileTap:Ou(),whileDrag:Ou(),whileFocus:Ou(),exit:Ou()}}function Au(e,t){e.min=t.min,e.max=t.max}function ju(e,t){Au(e.x,t.x),Au(e.y,t.y)}function Mu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Nu=1e-4,Pu=1-Nu,Fu=1+Nu,Iu=.01,Lu=0-Iu,Ru=0+Iu;function zu(e){return e.max-e.min}function Bu(e,t,n){return Math.abs(e-t)<=n}function Vu(e,t,n,r=.5){e.origin=r,e.originPoint=Y(t.min,t.max,e.origin),e.scale=zu(n)/zu(t),e.translate=Y(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Pu&&e.scale<=Fu||isNaN(e.scale))&&(e.scale=1),(e.translate>=Lu&&e.translate<=Ru||isNaN(e.translate))&&(e.translate=0)}function Hu(e,t,n,r){Vu(e.x,t.x,n.x,r?r.originX:void 0),Vu(e.y,t.y,n.y,r?r.originY:void 0)}function Uu(e,t,n,r=0){e.min=(r?Y(n.min,n.max,r):n.min)+t.min,e.max=e.min+zu(t)}function Wu(e,t,n,r){Uu(e.x,t.x,n.x,r?.x),Uu(e.y,t.y,n.y,r?.y)}function Gu(e,t,n,r=0){let i=r?Y(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+zu(t)}function Ku(e,t,n,r){Gu(e.x,t.x,n.x,r?.x),Gu(e.y,t.y,n.y,r?.y)}function qu(e,t,n,r,i){return e-=t,e=Rl(e,1/n,r),i!==void 0&&(e=Rl(e,1/i,r)),e}function Ju(e,t=0,n=1,r=.5,i,a=e,o=e){if(Yi.test(t)&&(t=parseFloat(t),t=Y(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Y(a.min,a.max,r);e===a&&(s-=t),e.min=qu(e.min,t,n,s,i),e.max=qu(e.max,t,n,s,i)}function Yu(e,t,[n,r,i],a,o){Ju(e,t[n],t[r],t[i],t.scale,a,o)}var Xu=[`x`,`scaleX`,`originX`],Zu=[`y`,`scaleY`,`originY`];function Qu(e,t,n,r){Yu(e.x,t,Xu,n?n.x:void 0,r?r.x:void 0),Yu(e.y,t,Zu,n?n.y:void 0,r?r.y:void 0)}function $u(e){return e.translate===0&&e.scale===1}function ed(e){return $u(e.x)&&$u(e.y)}function td(e,t){return e.min===t.min&&e.max===t.max}function nd(e,t){return td(e.x,t.x)&&td(e.y,t.y)}function rd(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function id(e,t){return rd(e.x,t.x)&&rd(e.y,t.y)}function ad(e){return zu(e.x)/zu(e.y)}function od(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function sd(e){return[e(`x`),e(`y`)]}function cd(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 ld=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],ud=ld.length,dd=e=>typeof e==`string`?parseFloat(e):e,fd=e=>typeof e==`number`||q.test(e);function pd(e,t,n,r,i,a){i?(e.opacity=Y(0,n.opacity??1,hd(r)),e.opacityExit=Y(t.opacity??1,0,gd(r))):a&&(e.opacity=Y(t.opacity??1,n.opacity??1,r));for(let i=0;i<ud;i++){let a=ld[i],o=md(t,a),s=md(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||fd(o)===fd(s)?(e[a]=Math.max(Y(dd(o),dd(s),r),0),(Yi.test(s)||Yi.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Y(t.rotate||0,n.rotate||0,r))}function md(e,t){return e[t]===void 0?e.borderRadius:e[t]}var hd=_d(0,.5,ai),gd=_d(.5,.95,Lr);function _d(e,t,n){return r=>r<e?0:r>t?1:n(Br(e,t,r))}function vd(e,t,n){let r=Ws(e)?e:zs(e);return r.start(As(``,r,t,n)),r.animation}function yd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var bd=(e,t)=>e.depth-t.depth,xd=class{constructor(){this.children=[],this.isDirty=!1}add(e){Er(this.children,e),this.isDirty=!0}remove(e){Dr(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(bd),this.isDirty=!1,this.children.forEach(e)}};function Sd(e,t){let n=Ti.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(bi(r),e(a-t))};return K.setup(r,!0),()=>bi(r)}function Cd(e){return Ws(e)?e.get():e}var wd=class{constructor(){this.members=[]}add(e){Er(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&&(Dr(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Dr(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)}},Td={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Ed={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Dd=[``,`X`,`Y`,`Z`],Od=1e3,kd=0;function Ad(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function jd(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=Ys(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,K,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&jd(r)}function Md({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=kd++,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,gi.value&&(Ed.nodes=Ed.calculatedTargetDeltas=Ed.calculatedProjections=0),this.nodes.forEach(Fd),this.nodes.forEach(Wd),this.nodes.forEach(Gd),this.nodes.forEach(Id),gi.addProjectionMetrics&&gi.addProjectionMetrics(Ed)},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 xd)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Vr),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=Wc(t)&&!al(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;K.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Sd(i,250),Td.hasAnimatedSinceResize&&(Td.hasAnimatedSinceResize=!1,this.nodes.forEach(Ud)))})}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()||Qd,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!id(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={...Ds(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||Ud(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(),bi(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(Kd),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&&jd(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(zd),this.nodes.forEach(Rd);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Bd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Vd),this.nodes.forEach(Hd),this.nodes.forEach(Nd),this.nodes.forEach(Pd)):this.nodes.forEach(Bd),this.clearAllSnapshots();let e=Ti.now();xi.delta=Or(0,1e3/60,e-xi.timestamp),xi.timestamp=e,xi.isProcessing=!0,Si.update.process(xi),Si.preRender.process(xi),Si.render.process(xi),xi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Cc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(Ld),this.sharedNodes.forEach(qd)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,K.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){K.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!zu(this.snapshot.measuredBox.x)&&!zu(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||=Z(),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&&!ed(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Fl(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)),nf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return Z();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(af))){let{scroll:e}=this.root;e&&(Gl(t.x,e.offset.x),Gl(t.y,e.offset.y))}return t}removeElementScroll(e){let t=Z();if(ju(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&&ju(t,e),Gl(t.x,i.offset.x),Gl(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||Z();ju(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&&(Gl(r.x,-n.scroll.offset.x),Gl(r.y,-n.scroll.offset.y)),Fl(n.latestValues)&&Jl(r,n.latestValues,n.layout?.layoutBox)}return Fl(this.latestValues)&&Jl(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=Z();ju(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Fl(n.latestValues))continue;let r;n.instance&&(Pl(n.latestValues)&&n.updateSnapshot(),r=Z(),ju(r,n.measurePageBox())),Qu(t,n.latestValues,n.snapshot?.layoutBox,r)}return Fl(this.latestValues)&&Qu(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!==xi.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=xi.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=Z(),this.targetWithTransforms=Z()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),Wu(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):ju(this.target,this.layout.layoutBox),Vl(this.target,this.targetDelta)):ju(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),gi.value&&Ed.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Pl(this.parent.latestValues)||Il(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=Z(),this.relativeTargetOrigin=Z(),Ku(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),ju(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===xi.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;ju(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;Wl(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=Z());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Mu(this.prevProjectionDelta.x,this.projectionDelta.x),Mu(this.prevProjectionDelta.y,this.projectionDelta.y)),Hu(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!od(this.projectionDelta.x,this.prevProjectionDelta.x)||!od(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),gi.value&&Ed.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=ll(),this.projectionDelta=ll(),this.projectionDeltaWithTransform=ll()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=ll();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=Z(),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(Zd));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;Jd(a.x,e.x,n),Jd(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Ku(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),Xd(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&nd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=Z(),ju(d,this.relativeTarget)),s&&(this.animationValues=i,pd(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&&=(bi(this.pendingAnimation),void 0),this.pendingAnimation=K.update(()=>{Td.hasAnimatedSinceResize=!0,Ei.layout++,this.motionValue||=zs(0),this.motionValue.jump(0,!1),this.currentAnimation=vd(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Ei.layout--},onComplete:()=>{Ei.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(Od),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&&rf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||Z();let t=zu(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=zu(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}ju(t,n),Jl(t,i),Hu(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new wd),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&&Ad(`z`,e,r,this.animationValues);for(let t=0;t<Dd.length;t++)Ad(`rotate${Dd[t]}`,e,r,this.animationValues),Ad(`skew${Dd[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=Cd(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=Cd(t?.pointerEvents)||``),this.hasProjected&&!Fl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=cd(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 au){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=au[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?Cd(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Rd),this.root.sharedNodes.clear()}}}function Nd(e){e.updateLayout()}function Pd(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`)sd(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=zu(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Au(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else rf(i,t.layoutBox,n)&&sd(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=zu(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=ll();Hu(o,n,t.layoutBox);let s=ll();a?Hu(s,e.applyTransform(r,!0),t.measuredBox):Hu(s,n,t.layoutBox);let c=!ed(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=Z();Ku(s,t.layoutBox,i.layoutBox,o);let c=Z();Ku(c,n,a.layoutBox,o),id(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 Fd(e){gi.value&&Ed.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 Id(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function Ld(e){e.clearSnapshot()}function Rd(e){e.clearMeasurements()}function zd(e){e.isLayoutDirty=!0,e.updateLayout()}function Bd(e){e.isLayoutDirty=!1}function Vd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Hd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function Ud(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function Wd(e){e.resolveTargetDelta()}function Gd(e){e.calcProjection()}function Kd(e){e.resetSkewAndRotation()}function qd(e){e.removeLeadSnapshot()}function Jd(e,t,n){e.translate=Y(t.translate,0,n),e.scale=Y(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function Yd(e,t,n,r){e.min=Y(t.min,n.min,r),e.max=Y(t.max,n.max,r)}function Xd(e,t,n,r){Yd(e.x,t.x,n.x,r),Yd(e.y,t.y,n.y,r)}function Zd(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var Qd={duration:.45,ease:[.4,0,.1,1]},$d=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),ef=$d(`applewebkit/`)&&!$d(`chrome/`)?Math.round:Lr;function tf(e){e.min=ef(e.min),e.max=ef(e.max)}function nf(e){tf(e.x),tf(e.y)}function rf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Bu(ad(t),ad(n),.2)}function af(e){return e!==e.root&&e.scroll?.wasRoot}var of=Md({attachResizeListener:(e,t)=>yd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),sf={current:void 0},cf=Md({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!sf.current){let e=new of({});e.mount(window),e.setOptions({layoutScroll:!0}),sf.current=e}return sf.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),lf=(0,d.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function uf(e=!0){let t=(0,d.useContext)(Tr);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,d.useId)();(0,d.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,d.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var df=(0,d.createContext)({strict:!1}),ff={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`]},pf=!1;function mf(){if(pf)return;let e={};for(let t in ff)e[t]={isEnabled:e=>ff[t].some(t=>!!e[t])};Tl(e),pf=!0}function hf(){return mf(),El()}function gf(e){let t=hf();for(let n in e)t[n]={...t[n],...e[n]};Tl(t)}var _f=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 vf(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||_f.has(e)}var yf=s({default:()=>bf}),bf,xf=o((()=>{throw bf={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Sf=e=>!vf(e);function Cf(e){typeof e==`function`&&(Sf=t=>t.startsWith(`on`)?!vf(t):e(t))}try{Cf((xf(),u(yf)).default)}catch{}function wf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||Ws(e[i])||(Sf(i)||n===!0&&vf(i)||!t&&!vf(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Tf=(0,d.createContext)({});function Ef(e,t){if(gl(e)){let{initial:t,animate:n}=e;return{initial:t===!1||pl(t)?t:void 0,animate:pl(n)?n:void 0}}return e.inherit===!1?{}:t}function Df(e){let{initial:t,animate:n}=Ef(e,(0,d.useContext)(Tf));return(0,d.useMemo)(()=>({initial:t,animate:n}),[Of(t),Of(n)])}function Of(e){return Array.isArray(e)?e.join(` `):e}var kf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Af(e,t,n){for(let r in t)!Ws(t[r])&&!ou(r,n)&&(e[r]=t[r])}function jf({transformTemplate:e},t){return(0,d.useMemo)(()=>{let n=kf();return eu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Mf(e,t){let n=e.style||{},r={};return Af(r,n,e),Object.assign(r,jf(e,t)),r}function Nf(e,t){let n={},r=Mf(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 Pf=()=>({...kf(),attrs:{}});function Ff(e,t,n,r){let i=(0,d.useMemo)(()=>{let n=Pf();return mu(n,t,gu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Af(t,e.style,e),i.style={...t,...i.style}}return i}var If=[`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 Lf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(If.indexOf(e)>-1||/[A-Z]/u.test(e))}function Rf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??Lf(e)?Ff:Nf)(t,r,i,e),c=wf(t,typeof e==`string`,a),l=e===d.Fragment?{}:{...c,...s,ref:n},{children:u}=t,f=(0,d.useMemo)(()=>Ws(u)?u.get():u,[u]);return(0,d.createElement)(e,{...l,children:f})}function zf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Bf(n,r,i,e),renderState:t()}}function Bf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Cd(a[e]);let{initial:o,animate:s}=e,c=gl(e),l=_l(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`&&!fl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Ms(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 Vf=e=>(t,n)=>{let r=(0,d.useContext)(Tf),i=(0,d.useContext)(Tr),a=()=>zf(e,t,r,i);return n?a():Cr(a)},Hf=Vf({scrapeMotionValuesFromProps:su,createRenderState:kf}),Uf=Vf({scrapeMotionValuesFromProps:vu,createRenderState:Pf}),Wf=Symbol.for(`motionComponentSymbol`);function Gf(e,t,n){let r=(0,d.useRef)(n);(0,d.useInsertionEffect)(()=>{r.current=n});let i=(0,d.useRef)(null);return(0,d.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 Kf=(0,d.createContext)({});function qf(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function Jf(e,t,n,r,i,a){let{visualElement:o}=(0,d.useContext)(Tf),s=(0,d.useContext)(df),c=(0,d.useContext)(Tr),l=(0,d.useContext)(lf),u=l.reducedMotion,f=l.skipAnimations,p=(0,d.useRef)(null),m=(0,d.useRef)(!1);r||=s.renderer,!p.current&&r&&(p.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:f,isSVG:a}),m.current&&p.current&&(p.current.manuallyAnimateOnMount=!0));let h=p.current,g=(0,d.useContext)(Kf);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&Yf(p.current,n,i,g);let _=(0,d.useRef)(!1);(0,d.useInsertionEffect)(()=>{h&&_.current&&h.update(n,c)});let v=n[Js],y=(0,d.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return wr(()=>{m.current=!0,h&&(_.current=!0,window.MotionIsMounted=!0,h.updateFeatures(),h.scheduleRenderMicrotask(),y.current&&h.animationState&&h.animationState.animateChanges())}),(0,d.useEffect)(()=>{h&&(!y.current&&h.animationState&&h.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),h.enteringChildren=void 0)}),h}function Yf(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:Xf(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 Xf(e){if(e)return e.options.allowProjection===!1?Xf(e.parent):e.projection}function Zf(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&gf(r);let a=n?n===`svg`:Lf(e),o=a?Uf:Hf;function s(n,s){let c,l={...(0,d.useContext)(lf),...n,layoutId:Qf(n)},{isStatic:u}=l,p=Df(n),m=o(n,u);if(!u&&typeof window<`u`){$f(l,r);let t=ep(l);c=t.MeasureLayout,p.visualElement=Jf(e,m,l,i,t.ProjectionNode,a)}return(0,f.jsxs)(Tf.Provider,{value:p,children:[c&&p.visualElement?(0,f.jsx)(c,{visualElement:p.visualElement,...l}):null,Rf(e,n,Gf(m,p.visualElement,s),m,u,t,a)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,d.forwardRef)(s);return c[Wf]=e,c}function Qf({layoutId:e}){let t=(0,d.useContext)(Sr).id;return t&&e!==void 0?t+`-`+e:e}function $f(e,t){let n=(0,d.useContext)(df).strict;if(process.env.NODE_ENV!==`production`&&t&&n){let t="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Ar(!1,t,`lazy-strict-mode`):jr(!1,t,`lazy-strict-mode`)}}function ep(e){let{drag:t,layout:n}=hf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function tp(e,t){if(typeof Proxy>`u`)return Zf;let n=new Map,r=(n,r)=>Zf(n,r,e,t);return new Proxy((e,t)=>(process.env.NODE_ENV!==`production`&&Kr(!1,`motion() is deprecated. Use motion.create() instead.`),r(e,t)),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,Zf(a,void 0,e,t)),n.get(a))})}var np=(e,t)=>t.isSVG??Lf(e)?new yu(t):new lu(t,{allowProjection:e!==d.Fragment}),rp=class extends kl{constructor(e){super(e),e.animationState||=Eu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();fl(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?.()}},ip=0,ap={animation:{Feature:rp},exit:{Feature:class extends kl{constructor(){super(...arguments),this.id=ip++,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=Ns(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 op(e){return{point:{x:e.pageX,y:e.pageY}}}var sp=e=>t=>Mc(t)&&e(t,op(t));function cp(e,t,n,r){return yd(e,t,sp(n),r)}var lp=({current:e})=>e?e.ownerDocument.defaultView:null,up=(e,t)=>Math.abs(e-t);function dp(e,t){let n=up(e.x,t.x),r=up(e.y,t.y);return Math.sqrt(n**2+r**2)}var fp=new Set([`auto`,`scroll`]),pp=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=mp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=gp(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=dp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=xi;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=mp(t,this.transformPagePoint),K.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=gp(e.type===`pointercancel`?this.lastMoveEventInfo:mp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Mc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=mp(op(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=xi;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,gp(s,this.history)),this.removeListeners=zr(cp(this.contextWindow,`pointermove`,this.handlePointerMove),cp(this.contextWindow,`pointerup`,this.handlePointerUp),cp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(fp.has(e.overflowX)||fp.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),K.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),bi(this.updatePoint)}};function mp(e,t){return t?{point:t(e.point)}:e}function hp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function gp({point:e},t){return{point:e,delta:hp(e,vp(t)),offset:hp(e,_p(t)),velocity:yp(t,.1)}}function _p(e){return e[0]}function vp(e){return e[e.length-1]}function yp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=vp(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Hr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Hr(t)*2&&(r=e[1]);let a=Ur(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 bp(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Y(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Y(n,e,r.max):Math.min(e,n)),e}function xp(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 Sp(e,{top:t,left:n,bottom:r,right:i}){return{x:xp(e.x,n,i),y:xp(e.y,t,r)}}function Cp(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 wp(e,t){return{x:Cp(e.x,t.x),y:Cp(e.y,t.y)}}function Tp(e,t){let n=.5,r=zu(e),i=zu(t);return i>r?n=Br(t.min,t.max-r,e.min):r>i&&(n=Br(e.min,e.max-i,t.min)),Or(0,1,n)}function Ep(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 Dp=.35;function Op(e=Dp){return e===!1?e=0:e===!0&&(e=Dp),{x:kp(e,`left`,`right`),y:kp(e,`top`,`bottom`)}}function kp(e,t,n){return{min:Ap(e,t),max:Ap(e,n)}}function Ap(e,t){return typeof e==`number`?e:e[t]||0}var jp=new WeakMap,Mp=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=Z(),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(op(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=Dc(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),sd(e=>{let t=this.getAxisMotionValue(e).get()||0;if(Yi.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=zu(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&K.update(()=>i(e,t),!1,!0),Ks(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=Ip(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&&K.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 pp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:lp(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&&K.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||!Fp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=bp(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=Sp(n.layoutBox,e):this.constraints=!1,this.elastic=Op(t),r!==this.constraints&&!qf(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&sd(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Ep(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!qf(e))return!1;let n=e.current;jr(n!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.",`drag-constraints-ref`);let{projection:r}=this.visualElement;if(!r||!r.layout)return!1;let i=Xl(n,r.root,this.visualElement.getTransformPagePoint()),a=wp(r.layout.layoutBox,i);if(t){let e=t(jl(a));this.hasMutatedConstraints=!!e,e&&(a=Al(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=sd(o=>{if(!Fp(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 Ks(this.visualElement,e),n.start(As(e,n,0,t,this.visualElement,!1))}stopAnimation(){sd(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){sd(t=>{let{drag:n}=this.getProps();if(!Fp(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]-Y(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};sd(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Tp({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(),sd(t=>{if(!Fp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Y(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;jp.set(this.visualElement,this);let e=this.visualElement.current,t=cp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Ic(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();qf(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Pp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),K.read(r);let o=yd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(sd(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=Dp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Np(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Pp(e,t,n){let r=il(e,Np(n)),i=il(t,Np(n));return()=>{r(),i()}}function Fp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Ip(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var Lp=class extends kl{constructor(e){super(e),this.removeGroupControls=Lr,this.removeListeners=Lr,this.controls=new Mp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Lr}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()}},Rp=e=>(t,n)=>{e&&K.update(()=>e(t,n),!1,!0)},zp=class extends kl{constructor(){super(...arguments),this.removePointerDownListener=Lr}onPointerDown(e){this.session=new pp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:lp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Rp(e),onStart:Rp(t),onMove:Rp(n),onEnd:(e,t)=>{delete this.session,r&&K.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=cp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Bp=!1,Vp=class extends d.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),Bp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Td.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}),Bp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||K.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(),Cc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Bp=!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 Hp(e){let[t,n]=uf(),r=(0,d.useContext)(Sr);return(0,f.jsx)(Vp,{...e,layoutGroup:r,switchLayoutGroup:(0,d.useContext)(Kf),isPresent:t,safeToRemove:n})}var Up={pan:{Feature:zp},drag:{Feature:Lp,ProjectionNode:cf,MeasureLayout:Hp}};function Wp(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&K.postRender(()=>i(t,op(t)))}var Gp=class extends kl{mount(){let{current:e}=this.node;e&&(this.unmount=Ac(e,(e,t)=>(Wp(this.node,t,`Start`),e=>Wp(this.node,e,`End`))))}unmount(){}},Kp=class extends kl{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=zr(yd(this.node.current,`focus`,()=>this.onFocus()),yd(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&&K.postRender(()=>i(t,op(t)))}var Jp=class extends kl{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Uc(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(){}},Yp=new WeakMap,Xp=new WeakMap,Zp=e=>{let t=Yp.get(e.target);t&&t(e)},Qp=e=>{e.forEach(Zp)};function $p({root:e,...t}){let n=e||document;Xp.has(n)||Xp.set(n,{});let r=Xp.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(Qp,{root:e,...t})),r[i]}function em(e,t,n){let r=$p(t);return Yp.set(e,n),r.observe(e),()=>{Yp.delete(e),r.unobserve(e)}}var tm={some:0,all:1},nm=class extends kl{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:tm[r]};this.stopObserver=em(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(rm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function rm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var im={inView:{Feature:nm},tap:{Feature:Jp},focus:{Feature:Kp},hover:{Feature:Gp}},am={layout:{ProjectionNode:cf,MeasureLayout:Hp}},om=tp({...ap,...im,...Up,...am},np),sm=24e3,cm=2048,lm=1200;function um(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 dm(e){let t=new Float32Array(e.length);for(let n=0;n<e.length;n++)t[n]=e[n]/32768;return t}function fm(e,t){let n=0,r=[];return{enqueue:i=>{let a=dm(i),o=e.createBuffer(1,a.length,sm);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 pm(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 mm(e){let{apiBaseUrl:t,siteId:n,chatId:r,clientTools:i={},onConnect:a,onDisconnect:o,onMessage:s,onModeChange:c,onError:l,onUnhandledClientToolCall:u,onAgentTurnEnd:d,onSessionInfo:f}=e,p=await pm(t,n,r);f?.({emailOnFile:!!p.emailOnFile}),e.greeting!==void 0&&(e.greeting?p.settings.agent.greeting=e.greeting:delete p.settings.agent.greeting);let m=await navigator.mediaDevices.getUserMedia({audio:{channelCount:1,echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0}}),h=new(window.AudioContext||window.webkitAudioContext)({sampleRate:sm});h.state===`suspended`&&await h.resume();let g=new WebSocket(p.wsUrl,[`token`,p.token]);g.binaryType=`arraybuffer`;let _=new Set,v={role:null,text:``,timer:null},y=``,b=()=>{v.timer&&=(clearTimeout(v.timer),null);let e=v.text.trim(),t=v.role;if(v.text=``,v.role=null,!(!e||!t)){if(t===`agent`){if(e===y){console.debug(`[FlowEngage] duplicate agent turn suppressed`);return}y=e}s?.({role:t,message:e})}},x=(e,t)=>{t&&(v.role&&v.role!==e&&b(),v.role=e,v.text=v.text?`${v.text} ${t}`.replace(/\s+/g,` `):t,v.timer&&clearTimeout(v.timer),v.timer=setTimeout(b,lm))},S=!1,C=!1,w=!1,T=!1,E=null,ee=()=>{E&&clearTimeout(E);let e=()=>{if(!S){if(D.isPlaying()){E=setTimeout(e,150);return}E=null,d?.()}};E=setTimeout(e,150)},D=fm(h,()=>{T&&(T=!1,c?.({mode:`listening`}))}),O=h.createMediaStreamSource(m),k=h.createScriptProcessor(cm,1,1);k.onaudioprocess=e=>{if(S||g.readyState!==WebSocket.OPEN)return;let t=e.inputBuffer.getChannelData(0);if(C){w||(w=!0,console.debug(`[FlowEngage] mic held — streaming silence to keep socket alive`)),g.send(new Int16Array(t.length).buffer);return}g.send(um(t).buffer)},O.connect(k),k.connect(h.destination);let te=()=>{if(!S){S=!0,E&&=(clearTimeout(E),null),b(),D.stop();try{k.disconnect(),O.disconnect()}catch{}m.getTracks().forEach(e=>e.stop()),h.close().catch(()=>{}),(g.readyState===WebSocket.OPEN||g.readyState===WebSocket.CONNECTING)&&g.close()}},A=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`}}},j=async e=>{for(let t of e.functions||[]){if(!t.client_side)continue;let e=await A(t);if(S||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??{})}))}},ne=e=>{switch(e.type){case`Welcome`:a?.({conversationId:e.request_id||p.token.slice(0,12)});break;case`ConversationText`:{let t=String(e.content||``);if(e.role===`user`){let e=t.trim();if(_.has(e)){_.delete(e);break}if(/^\[SYSTEM:/i.test(e)||/^Continue (now )?to the next section/i.test(e)||/^That was the last section/i.test(e)){console.debug(`[FlowEngage] widget instruction hidden from transcript`);break}}x(e.role===`user`?`user`:`agent`,t);break}case`UserStartedSpeaking`:b(),D.stop(),T=!1,c?.({mode:`listening`});break;case`AgentStartedSpeaking`:T=!0,c?.({mode:`speaking`});break;case`AgentAudioDone`:b(),ee(),D.isPlaying()||(T=!1,c?.({mode:`listening`}));break;case`FunctionCallRequest`:j(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 g.onopen=()=>g.send(JSON.stringify(p.settings)),g.onmessage=e=>{if(e.data instanceof ArrayBuffer){D.enqueue(new Int16Array(e.data));return}try{ne(JSON.parse(e.data))}catch{}},g.onerror=()=>l?.(Error(`Voice connection failed`)),g.onclose=()=>{te(),o?.()},{endSession:async()=>te(),sendContextualUpdate:e=>{S||g.readyState!==WebSocket.OPEN||!e||g.send(JSON.stringify({type:`UpdatePrompt`,prompt:e}))},sendUserMessage:(e,{silent:t=!0}={})=>{S||g.readyState!==WebSocket.OPEN||!e||(t&&_.add(e.trim()),g.send(JSON.stringify({type:`InjectUserMessage`,content:e})))},injectAgentSpeech:(e,t=`interrupt`)=>{S||g.readyState!==WebSocket.OPEN||!e||g.send(JSON.stringify({type:`InjectAgentMessage`,message:e,behavior:t}))},setMicMuted:e=>{C=!!e},get status(){return S?`disconnected`:`connected`}}}var hm={startSession:mm},gm=({size:e=18,color:t=`currentColor`})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`,fill:t}),(0,f.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`,stroke:t,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})]}),_m=({size:e=20})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.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,f.jsx)(`line`,{x1:`23`,y1:`1`,x2:`1`,y2:`23`})]}),vm=({size:e=18})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`5`}),(0,f.jsx)(`polyline`,{points:`5 12 12 5 19 12`})]}),ym=()=>(0,f.jsxs)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`polyline`,{points:`9 17 4 12 9 7`}),(0,f.jsx)(`path`,{d:`M20 18v-2a4 4 0 00-4-4H4`})]}),bm=()=>(0,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.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`})}),xm=({className:e=``})=>(0,f.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,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),Sm=({size:e=14})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`path`,{d:`M12 8V4H8`}),(0,f.jsx)(`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`}),(0,f.jsx)(`path`,{d:`M2 14h2`}),(0,f.jsx)(`path`,{d:`M20 14h2`}),(0,f.jsx)(`path`,{d:`M15 13v2`}),(0,f.jsx)(`path`,{d:`M9 13v2`})]}),Cm=({size:e=20,strokeWidth:t=2,color:n=`currentColor`})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:n,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`12`,y1:`5`,x2:`12`,y2:`19`}),(0,f.jsx)(`line`,{x1:`5`,y1:`12`,x2:`19`,y2:`12`})]}),wm=({size:e=20,color:t=`currentColor`})=>(0,f.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`,fill:t}),(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`,fill:t}),(0,f.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`,fill:t})]}),Tm=({size:e=20,color:t=`currentColor`})=>(0,f.jsxs)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.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,f.jsx)(`path`,{d:`M11.9955 12H12.0045M15.991 12H16M8 12H8.00897`,stroke:`white`,"stroke-width":`2`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]}),Em=()=>(0,f.jsx)(`svg`,{width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,f.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`})}),Dm=({size:e=24})=>(0,f.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,f.jsx)(`path`,{d:`M12 19v3`}),(0,f.jsx)(`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`}),(0,f.jsx)(`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`}),(0,f.jsx)(`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`}),(0,f.jsx)(`path`,{d:`m2 2 20 20`}),(0,f.jsx)(`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`})]}),Om=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),km=(e=``)=>String(e).replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),Am=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),jm=/^https?:\/\//i;function Mm(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!Am.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;jm.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);Mm(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function Nm(e){let t=document.createElement(`div`);return t.innerHTML=e,Mm(t),t.innerHTML}function Pm(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 Fm=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return Pm(Nm(t));let n=t.replace(/\r\n/g,`
26
26
  `).replace(/\n{3,}/g,`
27
27
 
28
28
  `).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>km(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 Pm(n.map(e=>{let t=e.split(`
29
- `).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(``))},Im=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),Lm=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),Rm=`image/png,image/jpeg,.pdf,.docx`;function zm(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`||Im.has(r)||Lm.has(n)}function Bm(e){return e?zm(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function Vm(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 Hm(e){return e?e.name||`Attachment`:``}function Um(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 Wm({src:e,name:t,imgStyle:n,initialsSpanStyle:r}){let[i,a]=(0,d.useState)(null),o=typeof e==`string`?e.trim():``;return(0,d.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,f.jsx)(`img`,{src:i,alt:``,style:n,onError:()=>a(null)}):(0,f.jsx)(`span`,{style:r,children:Um(t)})}function Gm({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}=pn(),u=(0,d.useRef)(null),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),_=(0,d.useRef)(e.length),v=(0,d.useRef)(!0),y=(0,d.useRef)(null),b=(0,d.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(),rr(t.href,{siteId:l?.siteId,apiBaseUrl:l?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{e&&ur(n||t.href)})}catch{}},[l]),x=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,d.useEffect)(()=>{if(v.current){v.current=!1,_.current=e.length,y.current&&(y.current.scrollTop=y.current.scrollHeight);return}let n=e.length>_.current;_.current=e.length,(n||t||r)&&u.current?.scrollIntoView({behavior:`smooth`})},[e.length,t,n,r]),(0,f.jsxs)(`div`,{ref:y,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,p=e.agent_name||e.agentName||e.metadata?.agentName||s,_=typeof e.sender_headshot==`string`&&e.sender_headshot.trim()||typeof o==`string`&&o.trim()||null,v=Om(e.replyToContent||e.replyContext?.message||``),y=e.replyToSender===`user`?`You`:e.replyToSender===`agent`?`Agent`:e.replyToSender===`ai`||e.replyToSender===`bot`?`AI Assistant`:`Message`;return t?(0,f.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,margin:`8px 0`},children:(0,f.jsx)(`div`,{style:{padding:`6px 12px`,borderRadius:`9999px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,fontWeight:500},children:e.message})},e.id):(0,f.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,f.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,f.jsx)(Sm,{size:16}):(0,f.jsx)(Wm,{src:_||``,name:p,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n?`flex-end`:`flex-start`,maxWidth:`75%`,minWidth:0},children:[!u&&l&&(0,f.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,f.jsx)(ym,{}),`Reply`]}),(0,f.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:[v&&(0,f.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,f.jsx)(`div`,{style:{marginBottom:`2px`,fontWeight:600},children:y}),(0,f.jsx)(`div`,{style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:v})]}),d?(()=>{let t=e.metadata.fileType||``,r=e.metadata.fileName||e.message||`File`,i=Vm(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,f.jsxs)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children:[c&&(0,f.jsx)(`div`,{style:{marginBottom:`6px`,fontSize:`14px`,color:n?`#fff`:`#111827`,whiteSpace:`normal`,wordBreak:`break-word`},children:s}),a?(0,f.jsx)(`button`,{type:`button`,onClick:()=>m({url:e.metadata.fileUrl,name:r}),onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(null),style:{display:`block`,width:`100%`,background:`transparent`,border:0,padding:0,margin:0,textAlign:`left`,cursor:`pointer`},children:(0,f.jsxs)(`div`,{style:{position:`relative`},children:[(0,f.jsx)(`img`,{src:e.metadata.fileUrl,alt:r,style:{width:`100%`,borderRadius:`10px`,display:`block`,maxHeight:`180px`,objectFit:`cover`}}),(0,f.jsx)(`div`,{style:{position:`absolute`,inset:0,borderRadius:`10px`,background:h===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:h===e.id?1:0,transition:`background 0.18s ease, opacity 0.18s ease`,pointerEvents:`none`},children:`Preview`})]})}):(0,f.jsx)(`a`,{href:e.metadata.fileUrl,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:`none`,display:`block`},children:(0,f.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,f.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,f.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,f.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,f.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,f.jsx)(`span`,{style:{fontSize:`7px`,fontWeight:800,letterSpacing:`0.04em`,color:n?`#fff`:l.color,lineHeight:1},children:l.label})]}),(0,f.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:n?`#fff`:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&(0,f.jsx)(`div`,{style:{fontSize:`11px`,marginTop:`3px`,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]}),(0,f.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,f.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,f.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})]})})]})})():r?(0,f.jsx)(`div`,{className:`flowengage-message-content fe-bot-message`,dangerouslySetInnerHTML:{__html:Fm(e.message)},onClick:b}):(0,f.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e.message})]}),(0,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,marginTop:`4px`,padding:`0 4px`,alignSelf:n?`flex-end`:`flex-start`},children:u?(0,f.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500,fontStyle:`italic`},children:`sending…`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500},children:x(e.timestamp||e.createdAt)}),(0,f.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:700,color:n?`var(--flowengage-primary)`:`#9ca3af`},children:`✓`})]})})]})]},e.id)}),(t||n)&&(0,f.jsxs)(`div`,{style:{marginBottom:`16px`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,f.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,f.jsx)(Sm,{size:16})}),(0,f.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,f.jsx)(`span`,{style:{animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`},children:`.`},e))]})]}),r&&(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,marginBottom:`12px`},children:[(0,f.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,overflow:`hidden`},children:(0,f.jsx)(Wm,{src:o||``,name:s,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,f.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,f.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,f.jsx)(`div`,{ref:u}),p&&(0,f.jsx)(`button`,{type:`button`,onClick:()=>m(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,f.jsxs)(`div`,{style:{position:`relative`,maxWidth:`min(96vw, 1100px)`,maxHeight:`96vh`,width:`100%`,display:`flex`,flexDirection:`column`,gap:`10px`,alignItems:`center`},children:[(0,f.jsx)(`img`,{src:p.url,alt:p.name,style:{width:`100%`,maxHeight:`calc(96vh - 72px)`,objectFit:`contain`,borderRadius:`16px`,boxShadow:`0 30px 80px rgba(0,0,0,0.42)`}}),(0,f.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:p.name})]})})]})}var Km=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:p,setEmailInput:m,emailError:h,showVoiceToggle:g=!1,voiceEnabled:_=!0,onFileSelect:v,selectedFile:y=null,onRemoveSelectedFile:b,attachmentError:x=``,isUploadingAttachment:S=!1,inputPlaceholder:C=`Type your message`}){let w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=e=>{e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};(0,d.useEffect)(()=>{u||E(T.current)},[e,u]);let ee=e=>{e.key===`Enter`&&(Km||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit()))},D=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,O=u?!!p?.trim():!!e?.trim()||!!y,te=s||S||!O,ne=!u&&_&&g;return(0,f.jsxs)(`div`,{style:{padding:`0 16px`,background:`transparent`},children:[c&&(0,f.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,f.jsxs)(`div`,{style:{minWidth:0,flex:1,borderLeft:`2px solid var(--flowengage-primary)`,paddingLeft:`12px`},children:[(0,f.jsxs)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`},children:[`Replying to `,D]}),(0,f.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`12px`,color:`#6b7280`},children:c.replyToContent||c.message})]}),(0,f.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,f.jsx)(`div`,{style:{marginBottom:`8px`,padding:`0 8px`},children:(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`#111827`,fontSize:`14px`,fontWeight:500,textAlign:`center`},children:[(0,f.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,f.jsx)(Sm,{size:13})}),(0,f.jsx)(`span`,{children:`Please provide your email address so we can help you.`})]})}),y&&!u&&(0,f.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,f.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,f.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`,marginBottom:`2px`},children:`Attachment ready`}),(0,f.jsx)(`div`,{style:{fontSize:`13px`,color:`#111827`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:Hm(y)}),(0,f.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:Vm(y.size)})]}),(0,f.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:b,"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,f.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:[ne?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{ref:w,type:`file`,accept:Rm,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&v?.(t),e.target.value=``}}),(0,f.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:()=>w.current?.click(),title:`Attach file`,"aria-label":`Attach file`,disabled:S,onMouseEnter:e=>{e.currentTarget.style.opacity=`0.8`},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,f.jsx)(Cm,{size:16,color:`currentColor`})})]}):null,u?(0,f.jsx)(`input`,{className:`flowengage-chat-text-input`,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,outline:`none`,padding:0,paddingLeft:ne?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,alignSelf:`center`},value:p,onChange:e=>m(e.target.value),placeholder:`Enter your Email`,disabled:s,type:`email`,autoComplete:`email`}):(0,f.jsx)(`textarea`,{ref:T,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:ne?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,resize:`none`,maxHeight:`120px`,overflowY:`auto`},value:e,onChange:e=>{t(e.target.value),E(e.target)},onKeyDown:ee,placeholder:o===`agent`?`Message the agent…`:C,disabled:s,autoComplete:`off`}),(0,f.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:te?`not-allowed`:`pointer`,opacity:te?.45:1,flexShrink:0},disabled:te,onMouseEnter:e=>{te||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,f.jsx)(vm,{size:16})})]}),!u&&x&&(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`7px 4px 0`},children:[(0,f.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,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,f.jsx)(`span`,{style:{fontSize:`11px`,color:`#dc2626`,fontWeight:500},children:x})]}),u&&h&&(0,f.jsx)(`div`,{style:{padding:`8px 16px 0`,fontSize:`12px`,fontWeight:500,color:`#f43f5e`},children:h})]})}function Jm({webRTCError:e,micError:t,setMicError:n,dismissCallError:r,isRateLimited:i,rateLimitMessage:a}){return(0,f.jsxs)(f.Fragment,{children:[(e||t)&&(0,f.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,f.jsx)(xm,{className:``}),(0,f.jsx)(`span`,{style:{fontSize:`12px`,color:`#b91c1c`,lineHeight:1.5,flex:1},children:e||t}),(0,f.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,f.jsx)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,fontSize:`13px`,borderRadius:`12px`,background:`#fee2e2`,color:`#991b1b`},children:a})]})}var Ym=[`#135bd8`,`#ef334b`,`#ffbd2e`];function Xm(e){return!Array.isArray(e)||e.length===0?Ym: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 Zm={idle:3,listening:.75,thinking:1,speaking:1.4,muted:.75,error:.08};function Qm(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 $m(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 eh=`
29
+ `).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(``))},Im=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),Lm=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),Rm=`image/png,image/jpeg,.pdf,.docx`;function zm(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`||Im.has(r)||Lm.has(n)}function Bm(e){return e?zm(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function Vm(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 Hm(e){return e?e.name||`Attachment`:``}function Um(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 Wm({src:e,name:t,imgStyle:n,initialsSpanStyle:r}){let[i,a]=(0,d.useState)(null),o=typeof e==`string`?e.trim():``;return(0,d.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,f.jsx)(`img`,{src:i,alt:``,style:n,onError:()=>a(null)}):(0,f.jsx)(`span`,{style:r,children:Um(t)})}function Gm({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}=fn(),u=(0,d.useRef)(null),[p,m]=(0,d.useState)(null),[h,g]=(0,d.useState)(null),_=(0,d.useRef)(e.length),v=(0,d.useRef)(!0),y=(0,d.useRef)(null),b=(0,d.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(),nr(t.href,{siteId:l?.siteId,apiBaseUrl:l?.apiBaseUrl}).then(({allowed:e,correctedUrl:n})=>{e&&lr(n||t.href)})}catch{}},[l]),x=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,d.useEffect)(()=>{if(v.current){v.current=!1,_.current=e.length,y.current&&(y.current.scrollTop=y.current.scrollHeight);return}let n=e.length>_.current;_.current=e.length,(n||t||r)&&u.current?.scrollIntoView({behavior:`smooth`})},[e.length,t,n,r]),(0,f.jsxs)(`div`,{ref:y,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,p=e.agent_name||e.agentName||e.metadata?.agentName||s,_=typeof e.sender_headshot==`string`&&e.sender_headshot.trim()||typeof o==`string`&&o.trim()||null,v=Om(e.replyToContent||e.replyContext?.message||``),y=e.replyToSender===`user`?`You`:e.replyToSender===`agent`?`Agent`:e.replyToSender===`ai`||e.replyToSender===`bot`?`AI Assistant`:`Message`;return t?(0,f.jsx)(`div`,{style:{display:`flex`,justifyContent:`center`,margin:`8px 0`},children:(0,f.jsx)(`div`,{style:{padding:`6px 12px`,borderRadius:`9999px`,background:`#f3f4f6`,color:`#6b7280`,fontSize:`12px`,fontWeight:500},children:e.message})},e.id):(0,f.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,f.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,f.jsx)(Sm,{size:16}):(0,f.jsx)(Wm,{src:_||``,name:p,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:n?`flex-end`:`flex-start`,maxWidth:`75%`,minWidth:0},children:[!u&&l&&(0,f.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,f.jsx)(ym,{}),`Reply`]}),(0,f.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:[v&&(0,f.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,f.jsx)(`div`,{style:{marginBottom:`2px`,fontWeight:600},children:y}),(0,f.jsx)(`div`,{style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`,overflow:`hidden`},children:v})]}),d?(()=>{let t=e.metadata.fileType||``,r=e.metadata.fileName||e.message||`File`,i=Vm(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,f.jsxs)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children:[c&&(0,f.jsx)(`div`,{style:{marginBottom:`6px`,fontSize:`14px`,color:n?`#fff`:`#111827`,whiteSpace:`normal`,wordBreak:`break-word`},children:s}),a?(0,f.jsx)(`button`,{type:`button`,onClick:()=>m({url:e.metadata.fileUrl,name:r}),onMouseEnter:()=>g(e.id),onMouseLeave:()=>g(null),style:{display:`block`,width:`100%`,background:`transparent`,border:0,padding:0,margin:0,textAlign:`left`,cursor:`pointer`},children:(0,f.jsxs)(`div`,{style:{position:`relative`},children:[(0,f.jsx)(`img`,{src:e.metadata.fileUrl,alt:r,style:{width:`100%`,borderRadius:`10px`,display:`block`,maxHeight:`180px`,objectFit:`cover`}}),(0,f.jsx)(`div`,{style:{position:`absolute`,inset:0,borderRadius:`10px`,background:h===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:h===e.id?1:0,transition:`background 0.18s ease, opacity 0.18s ease`,pointerEvents:`none`},children:`Preview`})]})}):(0,f.jsx)(`a`,{href:e.metadata.fileUrl,target:`_blank`,rel:`noopener noreferrer`,style:{textDecoration:`none`,display:`block`},children:(0,f.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,f.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,f.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,f.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,f.jsx)(`polyline`,{points:`14 2 14 8 20 8`})]}),(0,f.jsx)(`span`,{style:{fontSize:`7px`,fontWeight:800,letterSpacing:`0.04em`,color:n?`#fff`:l.color,lineHeight:1},children:l.label})]}),(0,f.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:n?`#fff`:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:r}),i&&(0,f.jsx)(`div`,{style:{fontSize:`11px`,marginTop:`3px`,color:n?`rgba(255,255,255,0.6)`:`#9ca3af`},children:i})]}),(0,f.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,f.jsx)(`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`}),(0,f.jsx)(`polyline`,{points:`7 10 12 15 17 10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`15`,x2:`12`,y2:`3`})]})]})})]})})():r?(0,f.jsx)(`div`,{className:`flowengage-message-content fe-bot-message`,dangerouslySetInnerHTML:{__html:Fm(e.message)},onClick:b}):(0,f.jsx)(`div`,{style:{whiteSpace:`pre-wrap`},children:e.message})]}),(0,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`4px`,marginTop:`4px`,padding:`0 4px`,alignSelf:n?`flex-end`:`flex-start`},children:u?(0,f.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500,fontStyle:`italic`},children:`sending…`}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`span`,{style:{fontSize:`10px`,color:`#9ca3af`,fontWeight:500},children:x(e.timestamp||e.createdAt)}),(0,f.jsx)(`span`,{style:{fontSize:`10px`,fontWeight:700,color:n?`var(--flowengage-primary)`:`#9ca3af`},children:`✓`})]})})]})]},e.id)}),(t||n)&&(0,f.jsxs)(`div`,{style:{marginBottom:`16px`,display:`flex`,alignItems:`center`,gap:`8px`},children:[(0,f.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,f.jsx)(Sm,{size:16})}),(0,f.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,f.jsx)(`span`,{style:{animation:`fe-dot-bounce 1.2s ease-in-out ${e*.2}s infinite`,display:`inline-block`},children:`.`},e))]})]}),r&&(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`flex-start`,gap:`8px`,marginBottom:`12px`},children:[(0,f.jsx)(`div`,{style:{width:`32px`,height:`32px`,flexShrink:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,overflow:`hidden`},children:(0,f.jsx)(Wm,{src:o||``,name:s,imgStyle:{width:`100%`,height:`100%`,objectFit:`cover`},initialsSpanStyle:{lineHeight:1}})}),(0,f.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,f.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,f.jsx)(`div`,{ref:u}),p&&(0,f.jsx)(`button`,{type:`button`,onClick:()=>m(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,f.jsxs)(`div`,{style:{position:`relative`,maxWidth:`min(96vw, 1100px)`,maxHeight:`96vh`,width:`100%`,display:`flex`,flexDirection:`column`,gap:`10px`,alignItems:`center`},children:[(0,f.jsx)(`img`,{src:p.url,alt:p.name,style:{width:`100%`,maxHeight:`calc(96vh - 72px)`,objectFit:`contain`,borderRadius:`16px`,boxShadow:`0 30px 80px rgba(0,0,0,0.42)`}}),(0,f.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:p.name})]})})]})}var Km=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:p,setEmailInput:m,emailError:h,showVoiceToggle:g=!1,voiceEnabled:_=!0,onFileSelect:v,selectedFile:y=null,onRemoveSelectedFile:b,attachmentError:x=``,isUploadingAttachment:S=!1,inputPlaceholder:C=`Type your message`}){let w=(0,d.useRef)(null),T=(0,d.useRef)(null),E=e=>{e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,120)}px`)};(0,d.useEffect)(()=>{u||E(T.current)},[e,u]);let ee=e=>{e.key===`Enter`&&(Km||e.shiftKey||e.altKey||e.ctrlKey||e.metaKey||(e.preventDefault(),e.currentTarget.form?.requestSubmit()))},D=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,O=u?!!p?.trim():!!e?.trim()||!!y,k=s||S||!O,te=!u&&_&&g;return(0,f.jsxs)(`div`,{style:{padding:`0 16px`,background:`transparent`},children:[c&&(0,f.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,f.jsxs)(`div`,{style:{minWidth:0,flex:1,borderLeft:`2px solid var(--flowengage-primary)`,paddingLeft:`12px`},children:[(0,f.jsxs)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`},children:[`Replying to `,D]}),(0,f.jsx)(`div`,{style:{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,fontSize:`12px`,color:`#6b7280`},children:c.replyToContent||c.message})]}),(0,f.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,f.jsx)(`div`,{style:{marginBottom:`8px`,padding:`0 8px`},children:(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`8px`,color:`#111827`,fontSize:`14px`,fontWeight:500,textAlign:`center`},children:[(0,f.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,f.jsx)(Sm,{size:13})}),(0,f.jsx)(`span`,{children:`Please provide your email address so we can help you.`})]})}),y&&!u&&(0,f.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,f.jsxs)(`div`,{style:{minWidth:0,flex:1},children:[(0,f.jsx)(`div`,{style:{fontSize:`12px`,fontWeight:600,color:`var(--flowengage-primary)`,marginBottom:`2px`},children:`Attachment ready`}),(0,f.jsx)(`div`,{style:{fontSize:`13px`,color:`#111827`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},children:Hm(y)}),(0,f.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:Vm(y.size)})]}),(0,f.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:b,"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,f.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:[te?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{ref:w,type:`file`,accept:Rm,style:{display:`none`},onChange:e=>{let t=e.target.files?.[0];t&&v?.(t),e.target.value=``}}),(0,f.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:()=>w.current?.click(),title:`Attach file`,"aria-label":`Attach file`,disabled:S,onMouseEnter:e=>{e.currentTarget.style.opacity=`0.8`},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,f.jsx)(Cm,{size:16,color:`currentColor`})})]}):null,u?(0,f.jsx)(`input`,{className:`flowengage-chat-text-input`,style:{flex:1,minWidth:0,border:`none`,fontFamily:`inherit`,fontSize:`14px`,outline:`none`,padding:0,paddingLeft:te?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,alignSelf:`center`},value:p,onChange:e=>m(e.target.value),placeholder:`Enter your Email`,disabled:s,type:`email`,autoComplete:`email`}):(0,f.jsx)(`textarea`,{ref:T,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:te?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`,resize:`none`,maxHeight:`120px`,overflowY:`auto`},value:e,onChange:e=>{t(e.target.value),E(e.target)},onKeyDown:ee,placeholder:o===`agent`?`Message the agent…`:C,disabled:s,autoComplete:`off`}),(0,f.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:k?`not-allowed`:`pointer`,opacity:k?.45:1,flexShrink:0},disabled:k,onMouseEnter:e=>{k||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,f.jsx)(vm,{size:16})})]}),!u&&x&&(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,padding:`7px 4px 0`},children:[(0,f.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,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,f.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,f.jsx)(`span`,{style:{fontSize:`11px`,color:`#dc2626`,fontWeight:500},children:x})]}),u&&h&&(0,f.jsx)(`div`,{style:{padding:`8px 16px 0`,fontSize:`12px`,fontWeight:500,color:`#f43f5e`},children:h})]})}function Jm({webRTCError:e,micError:t,setMicError:n,dismissCallError:r,isRateLimited:i,rateLimitMessage:a}){return(0,f.jsxs)(f.Fragment,{children:[(e||t)&&(0,f.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,f.jsx)(xm,{className:``}),(0,f.jsx)(`span`,{style:{fontSize:`12px`,color:`#b91c1c`,lineHeight:1.5,flex:1},children:e||t}),(0,f.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,f.jsx)(`div`,{style:{margin:`0 20px 10px`,padding:`12px 16px`,fontSize:`13px`,borderRadius:`12px`,background:`#fee2e2`,color:`#991b1b`},children:a})]})}var Ym=[`#135bd8`,`#ef334b`,`#ffbd2e`];function Xm(e){return!Array.isArray(e)||e.length===0?Ym: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 Zm={idle:3,listening:.75,thinking:1,speaking:1.4,muted:.75,error:.08};function Qm(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 $m(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 eh=`
30
30
  attribute vec2 a_pos;
31
31
  varying vec2 v_uv;
32
32
  void main() {
@@ -148,7 +148,7 @@
148
148
 
149
149
  gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
150
150
  }
151
- `;function nh(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 rh({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=Xm(r),u=t===`speaking`,p=e<=50,m=(0,d.useRef)(null),h=(0,d.useRef)(Zm[t]??.35);(0,d.useEffect)(()=>{h.current=Zm[t]??.35},[t]),(0,d.useEffect)(()=>{let t=m.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=nh(r,eh,th);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,Qm(s)),r.uniform3fv(u.c2,Qm(c)),r.uniform3fv(u.c3,Qm(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),f,p=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,h.current),r.drawArrays(r.TRIANGLES,0,6),f=requestAnimationFrame(p)};return f=requestAnimationFrame(p),()=>{cancelAnimationFrame(f),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let g=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,f.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!p&&(0,f.jsx)(sm.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${$m(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,f.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:g,transition:`filter 1.2s ease`},children:(0,f.jsx)(`canvas`,{ref:m,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,f.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,f.jsx)(sm.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 ih=`
151
+ `;function nh(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 rh({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=Xm(r),u=t===`speaking`,p=e<=50,m=(0,d.useRef)(null),h=(0,d.useRef)(Zm[t]??.35);(0,d.useEffect)(()=>{h.current=Zm[t]??.35},[t]),(0,d.useEffect)(()=>{let t=m.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=nh(r,eh,th);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,Qm(s)),r.uniform3fv(u.c2,Qm(c)),r.uniform3fv(u.c3,Qm(l)),r.viewport(0,0,t.width,t.height);let d=performance.now(),f,p=e=>{r.uniform1f(u.time,(e-d)/1e3),r.uniform1f(u.speed,h.current),r.drawArrays(r.TRIANGLES,0,6),f=requestAnimationFrame(p)};return f=requestAnimationFrame(p),()=>{cancelAnimationFrame(f),r.deleteProgram(i),r.deleteBuffer(a)}},[s,c,l,e]);let g=n?`saturate(0.3) brightness(1.1)`:t===`error`?`saturate(0.4) hue-rotate(28deg)`:`none`;return(0,f.jsxs)(`div`,{style:{position:`relative`,width:e,height:e,flexShrink:0,cursor:i?`pointer`:`default`,...a},className:o,onClick:i,children:[u&&!p&&(0,f.jsx)(om.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${$m(s,.18)} 0%, transparent 70%)`,pointerEvents:`none`},animate:{opacity:[.3,.75]},transition:{duration:1,repeat:1/0,repeatType:`mirror`,ease:`easeInOut`}}),(0,f.jsx)(`div`,{style:{width:e,height:e,borderRadius:`50%`,overflow:`hidden`,WebkitMaskImage:`-webkit-radial-gradient(white, black)`,filter:g,transition:`filter 1.2s ease`},children:(0,f.jsx)(`canvas`,{ref:m,style:{width:`100%`,height:`100%`,display:`block`}})}),u&&(0,f.jsx)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,borderRadius:`50%`,pointerEvents:`none`,zIndex:1},children:(0,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`3px`},children:[4,8,12,8,4].map((e,t)=>(0,f.jsx)(om.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 ih=`
152
152
  @keyframes fe-call-ring-pulse {
153
153
  0% { transform: scale(1); opacity: 0.55; }
154
154
  70% { transform: scale(1.85); opacity: 0; }
@@ -179,9 +179,9 @@
179
179
  }
180
180
  `;function ah(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 oh(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 sh(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 ch({headshot:e,name:t,size:n=80,primaryColor:r=`#3B82F6`}){let i=(t||`A`)[0].toUpperCase(),a=oh(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,f.jsx)(`img`,{src:e,alt:t||`Agent`,style:{width:n,height:n,borderRadius:`50%`,objectFit:`cover`,position:`relative`,zIndex:1,flexShrink:0,...o}}):(0,f.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 lh(e){let t=(0,d.useRef)(null),n=(0,d.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,d.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,d.useEffect)(()=>{if(e){r();return}n()},[e,r,n]),(0,d.useEffect)(()=>()=>n(),[n]),n}function uh({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:p,onMinimize:m,primaryColor:h=`#3B82F6`,orbColors:g,chatHistory:_=[]}){let v=a||s||`Agent`,y=e?`incoming`:n===`connecting`?`connecting`:`ongoing`,b=lh(!!e),x=async()=>{b(),await c()},S=async()=>{b(),await l()},C=i?`muted`:n===`connecting`?`idle`:`listening`,w=y===`ongoing`,T={position:`absolute`,inset:0,zIndex:10,display:`flex`,flexDirection:`column`,borderRadius:`inherit`,overflow:`hidden`,background:sh(g,h),animation:w?`fe-call-slide-up 0.36s cubic-bezier(0.16,1,0.3,1)`:`fe-call-fade-in 0.32s ease`};if(y===`incoming`){let e=Array.isArray(g)&&g.length>0?g:[h];return(0,f.jsxs)(`div`,{style:T,children:[(0,f.jsx)(`style`,{children:ih}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`space-between`,padding:`60px 32px 56px`},children:[(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`22px`},children:[(0,f.jsxs)(`div`,{style:{position:`relative`,width:`96px`,height:`96px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,f.jsx)(`div`,{style:{position:`absolute`,width:`96px`,height:`96px`,borderRadius:`50%`,background:`radial-gradient(circle, rgba(${ah(e[0])},0.2) 0%, transparent 70%)`,filter:`blur(10px)`,zIndex:0}}),[0,.5,1].map((t,n)=>(0,f.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,f.jsx)(ch,{headshot:o,name:v,size:82,primaryColor:h})]}),(0,f.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,f.jsx)(`div`,{style:{fontSize:`22px`,fontWeight:700,color:`#111827`,letterSpacing:`-0.015em`,lineHeight:1.2},children:v}),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`6px`,marginTop:`8px`},children:[(0,f.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,f.jsx)(`span`,{style:{fontSize:`13px`,color:`#6b7280`,letterSpacing:`0.01em`},children:`Incoming call`})]})]})]}),(0,f.jsxs)(`div`,{style:{display:`flex`,gap:`56px`,alignItems:`flex-end`},children:[(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`10px`},children:[(0,f.jsx)(`button`,{type:`button`,onClick:S,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,f.jsx)(_m,{size:26})}),(0,f.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Decline`})]}),(0,f.jsxs)(`div`,{style:{display:`flex`,flexDirection:`column`,alignItems:`center`,gap:`10px`},children:[(0,f.jsx)(`button`,{type:`button`,onClick:x,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,f.jsx)(bm,{})}),(0,f.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Accept`})]})]})]})]})}return y===`connecting`?(0,f.jsxs)(`div`,{style:T,children:[(0,f.jsx)(`style`,{children:ih}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`24px`},children:[(0,f.jsx)(ch,{headshot:o,name:v,size:64,primaryColor:h}),(0,f.jsx)(`div`,{style:{width:`48px`,height:`48px`,borderRadius:`50%`,border:`3px solid rgba(255,255,255,0.12)`,borderTopColor:Array.isArray(g)&&g[0]||h,animation:`fe-call-spin 0.9s linear infinite`}}),(0,f.jsx)(`span`,{style:{fontSize:`15px`,color:`#6b7280`,letterSpacing:`0.01em`},children:`Connecting…`})]})]}):(0,f.jsxs)(`div`,{style:T,children:[(0,f.jsx)(`style`,{children:ih}),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px 16px 10px`,gap:`10px`,flexShrink:0},children:[(0,f.jsx)(`button`,{type:`button`,onClick:m,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,f.jsx)(`svg`,{width:`18`,height:`18`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`polyline`,{points:`15 18 9 12 15 6`})})}),(0,f.jsx)(rh,{colors:g,size:36,voiceState:C}),(0,f.jsx)(`div`,{style:{flex:1,minWidth:0,fontSize:`15px`,fontWeight:600,color:`#111827`,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:v}),(0,f.jsx)(`div`,{style:{flexShrink:0,padding:`3px 10px`,borderRadius:`999px`,background:`${h}18`,border:`1px solid ${h}44`,display:`flex`,alignItems:`center`},children:(0,f.jsx)(`span`,{style:{fontSize:`11px`,fontWeight:600,color:h,letterSpacing:`0.02em`,lineHeight:1},children:`On Call`})})]}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`,padding:`0 24px 16px`},children:[(0,f.jsx)(ch,{headshot:o,name:v,size:116,primaryColor:h}),(0,f.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,f.jsx)(`div`,{style:{fontSize:`20px`,fontWeight:700,color:`#111827`,letterSpacing:`-0.01em`},children:v}),(0,f.jsx)(`div`,{style:{marginTop:`8px`,fontSize:`24px`,fontWeight:300,color:`#9ca3af`,letterSpacing:`0.06em`,fontVariantNumeric:`tabular-nums`},children:p(r)})]})]}),(0,f.jsxs)(`div`,{style:{flexShrink:0,display:`flex`,gap:`12px`,padding:`16px 24px 40px`},children:[(0,f.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,f.jsx)(Dm,{size:18}):(0,f.jsx)(gm,{size:18}),i?`Unmute`:`Mute`]}),(0,f.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,f.jsx)(_m,{size:18}),`End Call`]})]})]})}function dh({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,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`style`,{children:ih}),(0,f.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,f.jsxs)(`div`,{style:{position:`relative`,flexShrink:0,width:`42px`,height:`42px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:[(0,f.jsx)(`div`,{style:{position:`absolute`,inset:`-4px`,borderRadius:`50%`,background:`${l}28`,animation:`fe-call-avatar-breathe 2.8s ease-in-out infinite`}}),(0,f.jsx)(`div`,{style:{position:`absolute`,inset:`-2px`,borderRadius:`50%`,border:`1.5px solid ${l}55`}}),(0,f.jsx)(ch,{headshot:t,name:u,size:38,primaryColor:l})]}),(0,f.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(`div`,{style:{fontSize:`13px`,fontWeight:600,color:`#111827`,lineHeight:1.3,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:u}),(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`5px`,marginTop:`3px`},children:[(0,f.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,f.jsxs)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontVariantNumeric:`tabular-nums`,letterSpacing:`0.01em`},children:[`On Call\xA0•\xA0`,a(r)]})]})]}),(0,f.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`,flexShrink:0},children:[(0,f.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,f.jsx)(Dm,{size:15}):(0,f.jsx)(gm,{size:15})}),(0,f.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,f.jsx)(_m,{size:16})})]})]})]})}function fh(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(`
181
181
  `);return i.length>n&&(i=`…(earlier messages omitted)
182
- `+i.slice(-n)),i}var Z=`fe-vv`;function ph(){if(typeof document>`u`||document.getElementById(`${Z}-styles`))return;let e=`
182
+ `+i.slice(-n)),i}var Q=`fe-vv`;function ph(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
183
183
  /* ── Action toast ───────────────────────────────────────────────────────────── */
184
- #${Z}-toast {
184
+ #${Q}-toast {
185
185
  position: fixed;
186
186
  top: 16px;
187
187
  left: 50%;
@@ -210,27 +210,27 @@
210
210
  overflow: hidden;
211
211
  text-overflow: ellipsis;
212
212
  }
213
- #${Z}-toast.${Z}-show {
213
+ #${Q}-toast.${Q}-show {
214
214
  transform: translateX(-50%) translateY(0);
215
215
  opacity: 1;
216
216
  }
217
- #${Z}-toast .${Z}-spin {
217
+ #${Q}-toast .${Q}-spin {
218
218
  width: 13px;
219
219
  height: 13px;
220
220
  border: 2px solid rgba(255,255,255,0.25);
221
221
  border-top-color: #a78bfa;
222
222
  border-radius: 50%;
223
- animation: ${Z}-spin 0.65s linear infinite;
223
+ animation: ${Q}-spin 0.65s linear infinite;
224
224
  flex-shrink: 0;
225
225
  }
226
- #${Z}-toast .${Z}-icon {
226
+ #${Q}-toast .${Q}-icon {
227
227
  font-size: 14px;
228
228
  flex-shrink: 0;
229
229
  line-height: 1;
230
230
  }
231
231
 
232
232
  /* ── Navigation progress bar ────────────────────────────────────────────────── */
233
- #${Z}-bar {
233
+ #${Q}-bar {
234
234
  position: fixed;
235
235
  top: 0;
236
236
  left: 0;
@@ -243,14 +243,14 @@
243
243
  opacity: 0;
244
244
  transition: width 0.35s ease, opacity 0.25s ease;
245
245
  box-shadow: 0 0 12px #7c3aed88;
246
- animation: ${Z}-bar-shimmer 1.5s linear infinite;
246
+ animation: ${Q}-bar-shimmer 1.5s linear infinite;
247
247
  }
248
- #${Z}-bar.${Z}-bar-active {
248
+ #${Q}-bar.${Q}-bar-active {
249
249
  opacity: 1;
250
250
  }
251
251
 
252
252
  /* ── Field active highlight (about to fill) ─────────────────────────────────── */
253
- .${Z}-field-active {
253
+ .${Q}-field-active {
254
254
  outline: 2.5px solid #7c3aed !important;
255
255
  outline-offset: 3px !important;
256
256
  box-shadow: 0 0 0 5px rgba(124, 58, 237, 0.14), 0 0 20px rgba(124, 58, 237, 0.28) !important;
@@ -259,16 +259,16 @@
259
259
  }
260
260
 
261
261
  /* ── Field filled confirmation (green flash) ────────────────────────────────── */
262
- .${Z}-field-filled {
262
+ .${Q}-field-filled {
263
263
  outline: 2px solid #10b981 !important;
264
264
  outline-offset: 3px !important;
265
265
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12), 0 0 16px rgba(16, 185, 129, 0.22) !important;
266
266
  border-radius: 5px !important;
267
- animation: ${Z}-fill-flash 0.45s ease forwards !important;
267
+ animation: ${Q}-fill-flash 0.45s ease forwards !important;
268
268
  }
269
269
 
270
270
  /* ── Ghost cursor ────────────────────────────────────────────────────────────── */
271
- #${Z}-cursor {
271
+ #${Q}-cursor {
272
272
  position: fixed;
273
273
  width: 22px;
274
274
  height: 22px;
@@ -281,65 +281,65 @@
281
281
  opacity 0.2s ease;
282
282
  transform: translate(-4px, -4px);
283
283
  }
284
- #${Z}-cursor.${Z}-cursor-visible {
284
+ #${Q}-cursor.${Q}-cursor-visible {
285
285
  opacity: 1;
286
286
  }
287
- #${Z}-cursor.${Z}-cursor-click {
288
- animation: ${Z}-cursor-click 0.25s ease;
287
+ #${Q}-cursor.${Q}-cursor-click {
288
+ animation: ${Q}-cursor-click 0.25s ease;
289
289
  }
290
290
 
291
291
  /* ── Click ripple ────────────────────────────────────────────────────────────── */
292
- .${Z}-ripple {
292
+ .${Q}-ripple {
293
293
  position: absolute;
294
294
  border-radius: 50%;
295
295
  transform: scale(0);
296
296
  background: rgba(124, 58, 237, 0.35);
297
- animation: ${Z}-ripple-anim 0.55s linear forwards;
297
+ animation: ${Q}-ripple-anim 0.55s linear forwards;
298
298
  pointer-events: none;
299
299
  }
300
300
 
301
301
  /* ── Keyframes ───────────────────────────────────────────────────────────────── */
302
- @keyframes ${Z}-spin {
302
+ @keyframes ${Q}-spin {
303
303
  to { transform: rotate(360deg); }
304
304
  }
305
- @keyframes ${Z}-bar-shimmer {
305
+ @keyframes ${Q}-bar-shimmer {
306
306
  0% { background-position: 0% 0%; }
307
307
  100% { background-position: 200% 0%; }
308
308
  }
309
- @keyframes ${Z}-fill-flash {
309
+ @keyframes ${Q}-fill-flash {
310
310
  0% { background-color: rgba(16, 185, 129, 0.10); }
311
311
  40% { background-color: rgba(16, 185, 129, 0.22); }
312
312
  100% { background-color: transparent; }
313
313
  }
314
- @keyframes ${Z}-ripple-anim {
314
+ @keyframes ${Q}-ripple-anim {
315
315
  to { transform: scale(3.5); opacity: 0; }
316
316
  }
317
- @keyframes ${Z}-cursor-click {
317
+ @keyframes ${Q}-cursor-click {
318
318
  0% { transform: translate(-4px,-4px) scale(1); }
319
319
  50% { transform: translate(-4px,-4px) scale(0.82); }
320
320
  100% { transform: translate(-4px,-4px) scale(1); }
321
321
  }
322
- `,t=document.createElement(`style`);t.id=`${Z}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var mh=null,hh=null;function gh(){return(!mh||!mh.isConnected)&&(mh=document.createElement(`div`),mh.id=`${Z}-toast`,document.body.appendChild(mh)),mh}function _h(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;ph(),hh&&=(clearTimeout(hh),null);let i=gh();if(i.innerHTML=``,n){let e=document.createElement(`span`);e.className=`${Z}-icon`,e.textContent=n,i.appendChild(e)}else if(t){let e=document.createElement(`span`);e.className=`${Z}-spin`,i.appendChild(e)}let a=document.createElement(`span`);a.textContent=e,i.appendChild(a),i.classList.remove(`${Z}-show`),i.offsetHeight,i.classList.add(`${Z}-show`),r>0&&(hh=setTimeout(()=>vh(),r))}function vh(e=0){mh&&(e>0?hh=setTimeout(()=>{mh&&mh.classList.remove(`${Z}-show`)},e):mh&&mh.classList.remove(`${Z}-show`))}var Q=null,yh=[];function bh(){return(!Q||!Q.isConnected)&&(Q=document.createElement(`div`),Q.id=`${Z}-bar`,document.body.appendChild(Q)),Q}function xh(){if(typeof document>`u`)return;ph(),yh.forEach(clearTimeout),yh=[];let e=bh();e.style.transition=`none`,e.style.width=`0%`,e.classList.add(`${Z}-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;yh.push(setTimeout(()=>{Q&&(Q.style.transition=a,Q.style.width=`${i}%`)},t)),n+=800}}function Sh(){Q&&(yh.forEach(clearTimeout),yh=[],Q.style.transition=`width 0.2s ease`,Q.style.width=`100%`,yh.push(setTimeout(()=>{Q&&(Q.style.transition=`opacity 0.35s ease`,Q.style.opacity=`0`,yh.push(setTimeout(()=>{Q&&(Q.style.width=`0%`,Q.classList.remove(`${Z}-bar-active`))},380)))},220)))}var Ch=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
323
- <filter id="${Z}-csh">
322
+ `,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var mh=null,hh=null;function gh(){return(!mh||!mh.isConnected)&&(mh=document.createElement(`div`),mh.id=`${Q}-toast`,document.body.appendChild(mh)),mh}function _h(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;ph(),hh&&=(clearTimeout(hh),null);let i=gh();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&&(hh=setTimeout(()=>vh(),r))}function vh(e=0){mh&&(e>0?hh=setTimeout(()=>{mh&&mh.classList.remove(`${Q}-show`)},e):mh&&mh.classList.remove(`${Q}-show`))}var yh=null,bh=[];function xh(){return(!yh||!yh.isConnected)&&(yh=document.createElement(`div`),yh.id=`${Q}-bar`,document.body.appendChild(yh)),yh}function Sh(){if(typeof document>`u`)return;ph(),bh.forEach(clearTimeout),bh=[];let e=xh();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;bh.push(setTimeout(()=>{yh&&(yh.style.transition=a,yh.style.width=`${i}%`)},t)),n+=800}}function Ch(){yh&&(bh.forEach(clearTimeout),bh=[],yh.style.transition=`width 0.2s ease`,yh.style.width=`100%`,bh.push(setTimeout(()=>{yh&&(yh.style.transition=`opacity 0.35s ease`,yh.style.opacity=`0`,bh.push(setTimeout(()=>{yh&&(yh.style.width=`0%`,yh.classList.remove(`${Q}-bar-active`))},380)))},220)))}var wh=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
323
+ <filter id="${Q}-csh">
324
324
  <feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
325
325
  </filter>
326
326
  <path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
327
327
  fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
328
- filter="url(#${Z}-csh)"/>
329
- </svg>`,wh=null,Th=!1;function Eh(){return(!wh||!wh.isConnected)&&(wh=document.createElement(`div`),wh.id=`${Z}-cursor`,wh.innerHTML=Ch,document.body.appendChild(wh),Th=!1),wh}async function Dh(e){if(typeof document>`u`||!e)return;ph();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=Eh();Th||=(i.style.transition=`none`,i.style.left=`${window.innerWidth/2}px`,i.style.top=`${window.innerHeight*.4}px`,i.classList.add(`${Z}-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 jh(360)}function Oh(e=!1){wh&&(e?(wh.classList.remove(`${Z}-cursor-visible`),Th=!1):(wh.classList.remove(`${Z}-cursor-visible`),setTimeout(()=>{Th=!1},250)))}async function kh(e){wh&&(wh.classList.add(`${Z}-cursor-click`),await jh(280),wh.classList.remove(`${Z}-cursor-click`))}function Ah(e){if(!e||typeof document>`u`)return;ph();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=`${Z}-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 jh(e){return new Promise(t=>setTimeout(t,e))}function $(...e){mn()&&console.log(`[FlowEngage:voice-tools]`,...e)}function Mh(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function Nh(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(!bn(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function Ph(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function Fh(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 Ph(r.join(` `))}if(e.labels&&e.labels.length)return Ph(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return Ph(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return Ph(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return Ph(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=Ph(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 Ph(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return Ph(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?Ph(o):null}function Ih(){let e=[];return Nh(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(bn(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=Mh(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function Lh(){return Ih().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:Fh(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 Rh(){let e=[];return Nh(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(bn(e)||e.disabled)return!1;try{let t=Mh(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 zh(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 Bh(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 Vh(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 Hh(e,t,n){let r=[];Nh(e=>{let t=Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"], a[href]`));r.push(...t.filter(e=>{if(bn(e)||e.disabled)return!1;try{let t=Mh(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:Bh(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=>Vh(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=zh(n,r);i<t&&(t=i,e=n)}return e}return o[0]}function Uh(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 Wh(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 Gh(){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 Kh(){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=xn(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=xn(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=xn(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 qh(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(yn)),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(`
328
+ filter="url(#${Q}-csh)"/>
329
+ </svg>`,Th=null,Eh=!1;function Dh(){return(!Th||!Th.isConnected)&&(Th=document.createElement(`div`),Th.id=`${Q}-cursor`,Th.innerHTML=wh,document.body.appendChild(Th),Eh=!1),Th}async function Oh(e){if(typeof document>`u`||!e)return;ph();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=Dh();Eh||=(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 Mh(360)}function kh(e=!1){Th&&(e?(Th.classList.remove(`${Q}-cursor-visible`),Eh=!1):(Th.classList.remove(`${Q}-cursor-visible`),setTimeout(()=>{Eh=!1},250)))}async function Ah(e){Th&&(Th.classList.add(`${Q}-cursor-click`),await Mh(280),Th.classList.remove(`${Q}-cursor-click`))}function jh(e){if(!e||typeof document>`u`)return;ph();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 Mh(e){return new Promise(t=>setTimeout(t,e))}var Nh=/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i;function Ph(e){return String(e||``).replace(Nh,``).replace(/\/+$/,``).toLowerCase()||`/`}function Fh(e,t){return Ph(e)===Ph(t)}function $(...e){pn()&&console.log(`[FlowEngage:voice-tools]`,...e)}function Ih(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function Lh(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(!yn(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function Rh(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function zh(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 Rh(r.join(` `))}if(e.labels&&e.labels.length)return Rh(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return Rh(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return Rh(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return Rh(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=Rh(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 Rh(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return Rh(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?Rh(o):null}function Bh(){let e=[];return Lh(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(yn(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=Ih(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function Vh(){return Bh().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:zh(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 Hh(){let e=[];return Lh(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(yn(e)||e.disabled)return!1;try{let t=Ih(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 Uh(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 Wh(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 Gh(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 Kh(e,t,n){let r=[];Lh(e=>{let t=Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"], a[href]`));r.push(...t.filter(e=>{if(yn(e)||e.disabled)return!1;try{let t=Ih(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:Wh(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=>Gh(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=Uh(n,r);i<t&&(t=i,e=n)}return e}return o[0]}function qh(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 Jh(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 Yh(){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 Xh(){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=bn(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=bn(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, h4, h5`));n.length||(n=e(document.body.querySelectorAll(`h1, h2, h3, h4, h5`)));let r=[...new Set(n)].slice(0,30),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=bn(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 Zh(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(vn)),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(`
330
330
  `));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(`
331
331
  `));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(`
332
332
  `).replace(/\n{3,}/g,`
333
333
 
334
- `).trim()}function Jh(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=Uh(n),a=Wh(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 rr(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{_h(`Navigating to ${a}...`,{spinner:!0}),xh(),vn();try{let e=r?r():``;if(e&&t){let n=fh([{sender:`user`,message:e}]);n&&pe(t,n)}}catch{}_e();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`&&N(t,window.location.href,e,n),or(e),$(`fwh-navigate-mvp → real navigation`,a);let i=typeof window<`u`&&!!Ln();if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),i&&On(12e3),ur(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}=Kh(),!(s.length>=1)););Gh(),$(`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=Qn(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 lr()?(sr(),$(`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?(sr(),`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.`):(sr(),`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),_h(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Sh(),vh(900)}},"fwh-highlight-mvp":async e=>{$(`fwh-highlight-mvp ▶`,e);let t=Uh(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.`}Gh();let i=(e=>e&&e.replace(/^\d+\.\s*/,``).replace(/^["']|["']$/g,``).trim())(r),a=Qn(n||null,i||null);if(!a&&i){let e=Date.now()+600;for(;!a&&Date.now()<e;)await new Promise(e=>setTimeout(e,50)),Gh(),a=Qn(null,i)}if(!a){$(`fwh-highlight-mvp ✖ no element for:`,i||n);let{headings:e}=Kh(),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 _n(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=Uh(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=Qn(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=Uh(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=Uh(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(`
335
- `);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(Nh(t=>{for(let r of n)try{t.querySelectorAll(r).forEach(t=>{if(bn(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&&Mh(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(bn(t))return;let n=Fh(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(`
336
- `);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}=Kh();$(`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=Lh(),t=Rh();$(`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=Uh(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=Hh(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{_h(`Clicking ${n}...`,{spinner:!0});try{a.scrollIntoView({block:`center`,inline:`nearest`})}catch{a.scrollIntoView(!0)}await Dh(a),a.focus?.(),await kh(a),Ah(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),_h(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`fwh-click-button-mvp ✖`,t),_h(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Oh(),vh(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 Yh(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=mn();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 Xh={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function Zh(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 Qh(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 $h(e){let[t,n]=d.default.useState(null),r=typeof e==`string`?e.trim():``;return d.default.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 eg({logo:e,style:t}){let n=$h(typeof e==`string`?e:null);if(!e)return null;if(typeof e==`string`)return n?(0,f.jsx)(`img`,{src:n,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}}):null;let r=typeof e==`function`?d.default.createElement(e):d.default.isValidElement(e)?e:null;return r?(0,f.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:r}):null}function tg({title:e}){return(0,f.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 ng(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 rg({orbColors:e,...t}){return(0,f.jsx)(rh,{colors:e,...t})}function ig({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a,isClosing:o}){let s=n||Xh.green,c=Qh(s),l=a?72:94,u=(0,f.jsxs)(`div`,{style:{display:`flex`,alignItems:a?`flex-end`:`center`,gap:a?`7px`:`9px`},children:[(0,f.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(sm.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,f.jsxs)(sm.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,f.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,f.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,f.jsx)(sm.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,f.jsx)(rg,{size:l,orbColors:t})})]});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(sm.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,f.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,f.jsx)(`div`,{style:{animation:o?`fe-orb-slide-down 0.28s cubic-bezier(0.16,1,0.3,1) forwards`:``},children:u})]})}function ag({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a,isMobile:o,isClosing:s}){let c=n||Xh.green,l=Qh(c);return(0,f.jsxs)(sm.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,f.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,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,f.jsx)(rg,{size:72,orbColors:t}),(0,f.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,f.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,lineHeight:1.4},children:e.connectionTitle}),e.connectionSubtitle&&(0,f.jsx)(`p`,{style:{margin:`6px 0 0`,fontSize:`13px`,fontWeight:400,color:`#6b7280`,lineHeight:1.4},children:e.connectionSubtitle})]}),(0,f.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,width:`100%`},children:[(0,f.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,f.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 og({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,chatId:o,historyRef:s,onMessageSync:c,voiceEndCounter:l,websiteName:u,voiceFirstMessage:p,captureVisitorEmail:m,emailRequired:h,emailCaptureEnabled:g=!0,listeningLabel:_=`Listening...`,enterChatModeLabel:v=`Enter Chat Mode`,endConversationLabel:y=`End Conversation`}){(0,d.useEffect)(()=>(console.log(`[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED`),()=>console.log(`[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED`)),[]);let[b,x]=(0,d.useState)(`idle`),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),[E,ee]=(0,d.useState)(!1),[D,O]=(0,d.useState)(``),[te,ne]=(0,d.useState)(``),re=(0,d.useRef)(!1),ie=(0,d.useRef)(!1),ae=(0,d.useRef)(null),oe=(0,d.useRef)(0),se=(0,d.useRef)(``),k=(0,d.useRef)(null),ce=(0,d.useRef)(``),le=(0,d.useRef)(async()=>{}),ue=(0,d.useRef)(!1),A=(0,d.useRef)(!1),de=(0,d.useRef)(!1),j=(0,d.useRef)(!1),fe=(0,d.useRef)(`minimized`),ge=(0,d.useRef)(null),ve=(0,d.useRef)(null),ye=(0,d.useRef)(null),be=(0,d.useRef)(0),xe=(0,d.useRef)(!1),M=(0,d.useRef)(`idle`),N=(0,d.useRef)(!1),we=(0,d.useRef)(!1),P=(0,d.useRef)(null),F=(0,d.useRef)(null),Te=(0,d.useRef)(!1),Ee=(0,d.useCallback)((e=`minimized`)=>{console.warn(`[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called`,{destination:e,stack:Error().stack?.split(`
337
- `).slice(1,4).join(` | `)}),fe.current=e,j.current=!0,queueMicrotask(()=>{ue.current||(ue.current=!0,le.current?.())})},[s]),I=(0,d.useCallback)(()=>{ae.current&&=(clearTimeout(ae.current),null)},[]);(0,d.useEffect)(()=>{h||(re.current=!0,ie.current=!1,ee(!1),I())},[h,I]);let De=(0,d.useCallback)(()=>{I(),ae.current=setTimeout(()=>{if(!(!ie.current||re.current))if(oe.current<3){oe.current+=1;try{k.current?.injectAgentSpeech?.(`I still need your email in the box below to continue — could you enter it, please?`,`queue`)}catch{}De()}else{try{k.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{}ie.current=!1,ee(!1),I(),xe.current=!0}},1e4)},[I]),Oe=(0,d.useCallback)(async e=>{j.current=!0;try{vn()}catch{}if(i)try{Ce(i)}catch{}try{await k.current?.endSession?.()}catch{}let t=ge.current,n=ve.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(ge.current=null,ve.current=null,k.current=null,x(`idle`),C(!1),ue.current=!1,mr(),i)try{he(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);le.current=()=>Oe(fe.current===`chat`?t:n),(0,d.useEffect)(()=>{A.current=S},[S]),(0,d.useEffect)(()=>{l&&Ee(`chat`)},[l]),(0,d.useEffect)(()=>{let e=!1,l=null,d=null,f=null;return(async()=>{if(!i){x(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],ce.current=``,ue.current=!1,de.current=!1,j.current=!1,fe.current=`minimized`,pr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=fh(s.current);e&&pe(i,e)}catch{}if(!Ln()){let e=ge.current,t=ve.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(()=>{}),ge.current=null,ve.current=null}catch{}}_e()}});let t=Yh(Jh({siteId:i||null,apiBaseUrl:a||null,chatId:o||null,getLastUserVoiceText:()=>ce.current,requestEndSession:()=>{xe.current=!0},requestEmailCollection:()=>{g&&(re.current||ie.current||(ie.current=!0,oe.current=0,ee(!0),De()))}})),n=i?me(i):null,r=!!n?.transcript,c=i?Ce(i):null,m=!!c,_=typeof window<`u`?window.location.pathname:`/`,v=typeof document<`u`?document.title:``,y=_.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,``)||`/`,b=y===`/`||y===``,S={apiBaseUrl:a,siteId:i,chatId:o,clientTools:t},w=(_.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),T=``;v&&v.includes(`|`)&&(T=v.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let E=T||w||`this page`;if(m){let e=c?.pageName||E;S.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)S.greeting=`Welcome back! I see you're now on the ${E} 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||``;S.greeting=p||(b?e?`Hi, welcome to ${e}! How may I help you?`:`Hi, welcome! How may I help you?`:`Welcome to the ${E} page!`),b||console.log(`[FlowEngage] 🏠 Page-context greeting: "${E}" for ${_}`)}let D=!1,O=m?`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,te=!1,ne=!m&&!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,ae=r&&!m,le=!1,he=ae?`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,ye=!1,I=!1,Oe=g&&!!h,ke=await hm.startSession({...S,onConnect:({conversationId:e})=>{ge.current=e,ve.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`){F.current&&=(clearTimeout(F.current),null),x(`speaking`),M.current=`speaking`,N.current=!0,Te.current=!1,P.current&&=(clearTimeout(P.current),null);return}if(M.current=`listening`,xe.current){xe.current=!1,Ee();return}if(Oe&&!I&&!re.current){I=!0,D=!0,te=!0;try{k.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(O&&!D){D=!0;try{k.current?.sendContextualUpdate?.(O)}catch{}}if(he&&!le){le=!0;try{k.current?.sendContextualUpdate?.(he)}catch{}}if(ne&&!te){te=!0;try{k.current?.sendContextualUpdate?.(ne)}catch{}}F.current&&clearTimeout(F.current),F.current=setTimeout(()=>{e||M.current!==`speaking`&&(Te.current||(F.current=null,M.current=`listening`,x(`listening`),N.current&&we.current&&!A.current&&!ie.current&&(P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{if(!e&&M.current===`listening`&&!A.current&&!ie.current)try{k.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`){ce.current=r,Te.current=!0,we.current=!0,F.current&&=(clearTimeout(F.current),null),P.current&&=(clearTimeout(P.current),null);try{vn()}catch{}Oe&&!ye&&!re.current&&(ye=!0,se.current=r,ie.current||(ie.current=!0,oe.current=0,ee(!0),De()))}if(s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString()}],i)try{let e=fh(s.current);e&&pe(i,e)}catch{}if(ng(n,r)){xe.current=!0;return}if(A.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(be.current+=1,be.current===2)try{k.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 be.current>=5&&Ee(`minimized`)}},onError:t=>{if(!e&&!j.current&&!de.current&&!Se()){de.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{k.current?.setMicMuted?.(!0)}catch{}C(!0),x(`error`),Ee(`chat`)}},onDisconnect:t=>{if(e||j.current||de.current||Se())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:ce.current||``,wasMuted:A.current}),de.current=!0;try{k.current?.setMicMuted?.(!0)}catch{}C(!0),Ee(`chat`)}});if(e){console.warn(`[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately`),ke.endSession().catch(()=>{});return}l=ke,k.current=ke,x(`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&&!m?`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`:``;ke.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}. ${h?``:`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(kn()){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{vn()}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{k.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{}};d=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{d(...e),setTimeout(n,50)},f=()=>setTimeout(n,50),window.addEventListener(`popstate`,f)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(x(`error`),fe.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,j.current=!0;try{vn()}catch{}if(i)try{Ce(i)}catch{}typeof window<`u`&&(window.__fe_user_nav_during_speech=null),mr(),P.current&&=(clearTimeout(P.current),null),F.current&&=(clearTimeout(F.current),null),ae.current&&=(clearTimeout(ae.current),null),N.current=!1,Te.current=!1,M.current=`idle`,d&&typeof window<`u`&&(window.history.pushState=d),f&&typeof window<`u`&&window.removeEventListener(`popstate`,f);let t=l||k.current,n=ge.current,u=ve.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(()=>{}),ge.current=null,ve.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,Ee]),(0,d.useEffect)(()=>{if(!w)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;ye.current&&!ye.current.contains(t)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let ke=async()=>{if(k.current)try{if(S){be.current=0,await k.current.setMicMuted?.(!1),C(!1);try{k.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{be.current=0,await k.current.setMicMuted?.(!0),C(!0);try{k.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{}},Ae=(0,d.useCallback)(async e=>{e?.preventDefault?.();let t=D.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){ne(`Please enter a valid email address.`);return}ne(``);try{typeof m==`function`&&await m(t)}catch{}re.current=!0,ie.current=!1,I(),ee(!1),O(``);let n=se.current;se.current=``;try{k.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{}},[D,m,I]),je=Array.isArray(e)&&e[0]||`#3B82F6`;return(0,f.jsxs)(`div`,{ref:ye,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:[E&&(0,f.jsxs)(`form`,{onSubmit:Ae,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,f.jsx)(`span`,{style:{color:`white`,fontSize:`13px`,fontWeight:600,lineHeight:1.4},children:`Please enter your email to continue`}),(0,f.jsx)(`input`,{type:`email`,inputMode:`email`,autoComplete:`email`,autoFocus:!0,value:D,onChange:e=>{O(e.target.value),te&&ne(``)},placeholder:`you@example.com`,style:{width:`100%`,boxSizing:`border-box`,padding:`10px 12px`,borderRadius:`10px`,border:te?`1.5px solid #ef4444`:`1.5px solid #4b5563`,background:`#1f2937`,color:`white`,fontSize:`14px`,outline:`none`}}),te&&(0,f.jsx)(`span`,{style:{color:`#f87171`,fontSize:`12px`},children:te}),(0,f.jsx)(`button`,{type:`submit`,disabled:!D.trim(),style:{width:`100%`,padding:`10px 12px`,borderRadius:`10px`,border:`none`,background:D.trim()?je:`#374151`,color:`white`,fontSize:`14px`,fontWeight:600,cursor:D.trim()?`pointer`:`default`,transition:`background 0.2s ease`},children:`Submit`})]}),(0,f.jsxs)(`div`,{style:{position:`relative`},children:[b===`listening`&&!S&&(0,f.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:_}),S&&(0,f.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,f.jsx)(rg,{size:72,voiceState:b,isMuted:S,orbColors:e})]}),b===`error`&&(0,f.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,f.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,f.jsx)(`button`,{onClick:ke,title:S?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:S?`#7f1d1d`:`#1f2937`,border:S?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:S?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:S?(0,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,f.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,f.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,f.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,f.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,f.jsx)(gm,{size:16,color:`currentColor`})}),(0,f.jsx)(`button`,{onClick:()=>T(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,f.jsx)(wm,{size:16,color:`currentColor`})})]}),w&&(0,f.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,f.jsxs)(`button`,{onClick:()=>{T(!1),fe.current=`chat`,Oe(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,f.jsx)(Tm,{}),v]}),(0,f.jsxs)(`button`,{onClick:()=>{T(!1),fe.current=`minimized`,Oe(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,f.jsx)(Em,{}),y]}),(0,f.jsx)(`button`,{onClick:()=>T(!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,f.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,f.jsx)(`line`,{x1:`6`,y1:`6`,x2:`18`,y2:`18`})]})})]})]})}function sg({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,f.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,flexShrink:0,background:`
334
+ `).trim()}function Qh(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=qh(n),a=Jh(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 nr(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{_h(`Navigating to ${a}...`,{spinner:!0}),Sh(),_n();try{let e=r?r():``;if(e&&t){let n=fh([{sender:`user`,message:e}]);n&&fe(t,n)}}catch{}ge();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`&&P(t,window.location.href,e,n),ar(e),$(`fwh-navigate-mvp → real navigation`,a);let i=typeof window<`u`&&!!In();if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),i&&Dn(12e3),lr(a,{voiceActive:!0}).catch(()=>{}),i)try{let e=new URL(a,window.location.origin).pathname,t=window.location.pathname,n=Date.now()+2e3;for(;Date.now()<n&&!(typeof window<`u`&&window.location.pathname===e);)await new Promise(e=>setTimeout(e,80));let r=typeof window<`u`?window.location.pathname:e,i=typeof window<`u`?window.location.href:a;(r.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),$(`fwh-navigate-mvp → SPA nav complete. target:`,e,`actual:`,r);try{typeof window<`u`&&window.scrollTo(0,0)}catch{}let o=[],s=null,c=``,l=Date.now()+12e3;for(;Date.now()<l&&(await new Promise(e=>setTimeout(e,300)),{headings:o,pageTitleHeading:s,introText:c}=Xh(),!(o.length>=1)););Yh(),$(`fwh-navigate-mvp → page headings collected:`,o,`titleHeading:`,s);let u=o.length?o.join(` | `):`none`,d=o.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.`,f=s?` "${s}" 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: "${c||`(no intro text found)`}"`:c?` No separate page-title heading detected, but this intro text precedes the first section — mention it briefly before covering sections: "${c}"`:``,p=``;try{if(o.length>0){let e=o.slice(0,3),t=[];for(let n of e){let e=Zn(null,n);if(e){let r=Zh(e).substring(0,800);r&&t.push(`[Section: ${n}] ${r}`)}}t.length>0&&(p=` CONTENT FOR FIRST FEW SECTIONS: ${t.join(` | `)}. Use this content to answer immediately if the visitor asks about one of these sections.`)}}catch{}if(cr())return or(),$(`fwh-navigate-mvp ✖ landed on a not-found/404 page:`,i),`NAVIGATION_PAGE_NOT_FOUND. The page at ${i} 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.`;let m=Date.now()+4e3,h=typeof window<`u`?window.location.pathname:r;for(;Date.now()<m&&!Fh(h,e)&&Fh(h,t);)await new Promise(e=>setTimeout(e,120)),h=window.location.pathname;$(`fwh-navigate-mvp route settle:`,{startPath:t,targetPath:e,settledPath:h});let g=typeof window<`u`?window.location.href:i,_=(h.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())||`Home`,v=Fh(h,e),y=!Fh(h,t),b=v||y;return $(`fwh-navigate-mvp settled:`,h,`target:`,e,`match:`,b),b?(or(),`OK_NAVIGATE_SPA. Visitor is now on: ${g} (page: "${_}") | Section headings: ${u}.${f} ${d}${p} Now confirm the arrival in ONE short sentence phrased for what the visitor actually asked for — mention the page by name and what it lets them do (e.g. for a contact request: "I've taken you to the Contact Us page — filling in this form sends your query straight to our team."). Do NOT use a fixed template. Then, in the same breath, offer either a specific section or a full overview. Then STOP — wait for their reply.`):(or(),`NAVIGATION_DID_NOT_HAPPEN. The visitor is STILL on ${g} (page: "${_}") — 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),_h(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{Ch(),vh(900)}},"fwh-highlight-mvp":async e=>{$(`fwh-highlight-mvp ▶`,e);let t=qh(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.`}Yh();let i=(e=>e&&e.replace(/^\d+\.\s*/,``).replace(/^["']|["']$/g,``).trim())(r),a=Zn(n||null,i||null);if(!a&&i){let e=Date.now()+600;for(;!a&&Date.now()<e;)await new Promise(e=>setTimeout(e,50)),Yh(),a=Zn(null,i)}if(!a){$(`fwh-highlight-mvp ✖ no element for:`,i||n);let{headings:e}=Xh(),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 gn(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=qh(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=Zn(null,n);if(!t)return`Could not find section "${n}" on the page.`;e=Zh(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=qh(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=qh(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(`
335
+ `);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(Lh(t=>{for(let r of n)try{t.querySelectorAll(r).forEach(t=>{if(yn(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&&Ih(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(yn(t))return;let n=zh(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(`
336
+ `);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}=Xh();$(`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: do NOT drive it yourself. Do not call fwh-highlight-mvp and do not decide the order — highlighting and section order are handled for you. You will be told which section to describe, one at a time. When told, describe ONLY that section in 3-4 sentences and then stop; never announce another section, never ask whether to continue. ***`},"fwh-list-forms-mvp":async()=>{let e=Vh(),t=Hh();$(`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=qh(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=Kh(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{_h(`Clicking ${n}...`,{spinner:!0});try{a.scrollIntoView({block:`center`,inline:`nearest`})}catch{a.scrollIntoView(!0)}await Oh(a),a.focus?.(),await Ah(a),jh(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),_h(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`fwh-click-button-mvp ✖`,t),_h(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{kh(),vh(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`]}}var $h=/^(get in touch|contact us|let'?s (talk|connect)|subscribe|newsletter|follow us|quick links|company|solutions|what we do|resources|legal|sitemap|share this)/i;function eg(){try{let{headings:e}=Xh();return(e||[]).map(e=>typeof e==`string`?e:e?.text||``).filter(Boolean).filter(e=>!$h.test(e.trim()))}catch{return[]}}function tg(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=pn();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]=d.default.useState(null),r=typeof e==`string`?e.trim():``;return d.default.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,f.jsx)(`img`,{src:n,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}}):null;let r=typeof e==`function`?d.default.createElement(e):d.default.isValidElement(e)?e:null;return r?(0,f.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,f.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,f.jsx)(rh,{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,f.jsxs)(`div`,{style:{display:`flex`,alignItems:a?`flex-end`:`center`,gap:a?`7px`:`9px`},children:[(0,f.jsxs)(`div`,{style:{flex:1,minWidth:0},children:[(0,f.jsx)(om.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,f.jsxs)(om.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,f.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,f.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,f.jsx)(om.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,f.jsx)(lg,{size:l,orbColors:t})})]});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(om.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,f.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,f.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,f.jsxs)(om.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,f.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,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`polyline`,{points:`6 9 12 15 18 9`})})}),(0,f.jsx)(lg,{size:72,orbColors:t}),(0,f.jsxs)(`div`,{style:{textAlign:`center`},children:[(0,f.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,lineHeight:1.4},children:e.connectionTitle}),e.connectionSubtitle&&(0,f.jsx)(`p`,{style:{margin:`6px 0 0`,fontSize:`13px`,fontWeight:400,color:`#6b7280`,lineHeight:1.4},children:e.connectionSubtitle})]}),(0,f.jsxs)(`div`,{style:{display:`flex`,gap:`16px`,width:`100%`},children:[(0,f.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,f.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:p,captureVisitorEmail:m,emailRequired:h,emailCaptureEnabled:g=!0,listeningLabel:_=`Listening...`,enterChatModeLabel:v=`Enter Chat Mode`,endConversationLabel:y=`End Conversation`}){(0,d.useEffect)(()=>(console.log(`[FlowEngage:VoiceDebug] 🔵 VoiceMode MOUNTED`),()=>console.log(`[FlowEngage:VoiceDebug] 🔴 VoiceMode UNMOUNTED`)),[]);let[b,x]=(0,d.useState)(`idle`),[S,C]=(0,d.useState)(!1),[w,T]=(0,d.useState)(!1),[E,ee]=(0,d.useState)(!1),[D,O]=(0,d.useState)(``),[k,te]=(0,d.useState)(``),A=(0,d.useRef)(!1),j=(0,d.useRef)(!1),ne=(0,d.useRef)(null),re=(0,d.useRef)(0),ie=(0,d.useRef)(``),ae=(0,d.useRef)(!1),oe=(0,d.useRef)(0),se=(0,d.useRef)(!1),ce=(0,d.useRef)(!1),le=(0,d.useRef)([]),ue=(0,d.useRef)(null);ue.current=async()=>{let e=le.current;de.current+=1;let t=de.current,n=e[t];if(!n){se.current=!1,e.length&&M.current?.sendUserMessage?.(`That was the last section. Say so in one short sentence and ask if they want to explore any section further.`);return}try{await toolsRef.current?.highlightOnPage?.({section_text:n})}catch{}console.debug(`[FlowEngage] walkthrough step ${t+1}/${e.length}: ${n}`),M.current?.sendUserMessage?.(`Describe the section titled "${n}" in 3-4 sentences, starting with ${t===0?`Starting with`:`Next —`} ${n}. Describe ONLY this section. Do not mention any other section, do not ask whether to continue, then stop.`)};let de=(0,d.useRef)(0),M=(0,d.useRef)(null),he=(0,d.useRef)(``),_e=(0,d.useRef)(async()=>{}),ve=(0,d.useRef)(!1),ye=(0,d.useRef)(!1),be=(0,d.useRef)(!1),N=(0,d.useRef)(!1),P=(0,d.useRef)(`minimized`),Ce=(0,d.useRef)(null),we=(0,d.useRef)(null),Te=(0,d.useRef)(null),Ee=(0,d.useRef)(0),De=(0,d.useRef)(!1),F=(0,d.useRef)(`idle`),Oe=(0,d.useRef)(!1),ke=(0,d.useRef)(!1),Ae=(0,d.useRef)(null),je=(0,d.useRef)(null),Me=(0,d.useRef)(!1),Ne=(0,d.useCallback)((e=`minimized`)=>{console.warn(`[FlowEngage:VoiceDebug] 🛑 requestSessionShutdown called`,{destination:e,stack:Error().stack?.split(`
337
+ `).slice(1,4).join(` | `)}),P.current=e,N.current=!0,queueMicrotask(()=>{ve.current||(ve.current=!0,_e.current?.())})},[s]),Pe=(0,d.useCallback)(()=>{ne.current&&=(clearTimeout(ne.current),null)},[]);(0,d.useEffect)(()=>{if(h){A.current=!1;return}if(A.current=!0,j.current=!1,ee(!1),Pe(),ae.current){ae.current=!1,M.current?.setMicMuted?.(!1);let e=ie.current;ie.current=``,M.current?.injectAgentSpeech?.(`Thanks — I already have your email on file.`,`interrupt`),e&&M.current?.sendUserMessage?.(`The visitor's email is already on file — do not ask for it. Answer their question now: "${e}"`)}M.current?.sendContextualUpdate?.(`EMAIL REQUIREMENT SATISFIED — the visitor's email is already on file. All earlier instructions about requiring or asking for an email are VOID. Never ask for it again.`)},[h,Pe]);let Fe=/(walk me through|complete overview|full overview|tell me about (each|all)|go through (it|them|each)|overview of|one by one|tell me everything)/i,I=/(that covers everything|that was all|covered everything|anything else)/i,Ie=(0,d.useCallback)(()=>{Pe(),ne.current=setTimeout(()=>{if(!(!j.current||A.current))if(re.current<3){re.current+=1;try{M.current?.injectAgentSpeech?.(`I still need your email in the box below to continue — could you enter it, please?`,`queue`)}catch{}Ie()}else{try{M.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{}j.current=!1,ee(!1),Pe(),De.current=!0}},1e4)},[Pe]),L=(0,d.useCallback)(async e=>{N.current=!0;try{_n()}catch{}if(i)try{Se(i)}catch{}try{await M.current?.endSession?.()}catch{}let t=Ce.current,n=we.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(Ce.current=null,we.current=null,M.current=null,x(`idle`),C(!1),ve.current=!1,pr(),i)try{me(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);_e.current=()=>L(P.current===`chat`?t:n),(0,d.useEffect)(()=>{ye.current=S},[S]),(0,d.useEffect)(()=>{l&&Ne(`chat`)},[l]),(0,d.useEffect)(()=>{let e=!1,l=null,d=null,f=null;return(async()=>{if(!i){x(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],he.current=``,ve.current=!1,be.current=!1,N.current=!1,P.current=`minimized`,fr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=fh(s.current);e&&fe(i,e)}catch{}if(!In()){let e=Ce.current,t=we.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(()=>{}),Ce.current=null,we.current=null}catch{}}ge()}});let t=tg(Qh({siteId:i||null,apiBaseUrl:a||null,chatId:o||null,getLastUserVoiceText:()=>he.current,requestEndSession:()=>{De.current=!0},requestEmailCollection:()=>{g&&(A.current||j.current||(j.current=!0,re.current=0,ee(!0),Ie()))}})),n=i?pe(i):null,r=!!n?.transcript,c=i?Se(i):null,m=!!c,_=typeof window<`u`?window.location.pathname:`/`,v=typeof document<`u`?document.title:``,y=_.replace(/^\/[a-z]{2}(?:-[a-z]{2})?(?=\/|$)/i,``)||`/`,b=y===`/`||y===``,S={apiBaseUrl:a,siteId:i,chatId:o,clientTools:t},w=(_.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),T=``;v&&v.includes(`|`)&&(T=v.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let E=T||w||`this page`,D=(()=>{if(!c?.targetUrl)return!0;try{return new URL(c.targetUrl,window.location.href).pathname.replace(/\/$/,``)===window.location.pathname.replace(/\/$/,``)}catch{return!0}})();if(m&&!D)S.greeting=`You're on the ${E} page. What would you like to know?`,console.warn(`[FlowEngage] nav target "${c?.pageName}" not reached — on "${E}" instead; not claiming navigation`);else if(m){let e=c?.pageName||E;S.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)S.greeting=`Welcome back! I see you're now on the ${E} 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||``;S.greeting=p||(b?e?`Hi, welcome to ${e}! How may I help you?`:`Hi, welcome! How may I help you?`:`Welcome to the ${E} page!`),b||console.log(`[FlowEngage] 🏠 Page-context greeting: "${E}" for ${_}`)}let O=!1,k=m?`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,te=!1,ne=!m&&!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,me=r&&!m,_e=!1,Te=me?`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,L=!1,Le=!1,Re=g&&!!h&&!ce.current,R=await hm.startSession({...S,onConnect:({conversationId:e})=>{Ce.current=e,we.current=Date.now(),console.log(`[FlowEngage] 🎙️ AI chat session connected:`,e)},onUnhandledClientToolCall:e=>console.error(`[FlowEngage] Unhandled tool:`,e?.tool_name),onSessionInfo:({emailOnFile:e})=>{ce.current=!!e,e&&(A.current=!0,j.current=!1,ee(!1),Pe(),console.log(`[FlowEngage] email already on file per server — gate disabled`))},onAgentTurnEnd:()=>{e||se.current&&(ae.current||setTimeout(()=>ue.current?.(),250))},onModeChange:({mode:t})=>{if(!e){if(t===`speaking`){je.current&&=(clearTimeout(je.current),null),x(`speaking`),F.current=`speaking`,Oe.current=!0,Me.current=!1,Ae.current&&=(clearTimeout(Ae.current),null);return}if(F.current=`listening`,De.current){De.current=!1,Ne();return}if(Re&&!Le&&!A.current&&!ce.current){Le=!0,O=!0,te=!0;try{M.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(k&&!O){O=!0;try{M.current?.sendContextualUpdate?.(k)}catch{}}if(Te&&!_e){_e=!0;try{M.current?.sendContextualUpdate?.(Te)}catch{}}if(ne&&!te){te=!0;try{M.current?.sendContextualUpdate?.(ne)}catch{}}je.current&&clearTimeout(je.current),je.current=setTimeout(()=>{e||F.current!==`speaking`&&(Me.current||(je.current=null,F.current=`listening`,x(`listening`),Oe.current&&ke.current&&!ye.current&&!j.current&&(Ae.current&&clearTimeout(Ae.current),Ae.current=setTimeout(()=>{if(!e&&F.current===`listening`&&!ye.current&&!j.current)try{M.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||ae.current&&t.role!==`user`&&!/email/i.test(String(t.message||``)))return;t.role===`user`&&Fe.test(String(t.message||``))&&(se.current=!0,oe.current=0,de.current=-1,le.current=eg(),setTimeout(()=>ue.current?.(),400),console.log(`[FlowEngage] walkthrough armed — ${le.current.length} sections on this page`)),t.role!==`user`&&I.test(String(t.message||``))&&(se.current=!1);let n=t.role===`user`?`user`:`bot`,r=t.message||t.text||t.content||``;if(r){if(n===`user`){he.current=r,Me.current=!0,ke.current=!0,je.current&&=(clearTimeout(je.current),null),Ae.current&&=(clearTimeout(Ae.current),null);try{_n()}catch{}Re&&!L&&!A.current&&!ce.current&&(L=!0,ie.current=r,ae.current=!0,M.current?.injectAgentSpeech?.(`Before I answer that, could you please enter your email in the text box below?`,`interrupt`),M.current?.setMicMuted?.(!0),j.current||(j.current=!0,re.current=0,ee(!0),Ie()))}if(s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString()}],i)try{let e=fh(s.current);e&&fe(i,e)}catch{}if(cg(n,r)){De.current=!0;return}if(ye.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(Ee.current+=1,Ee.current===2)try{M.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 Ee.current>=5&&Ne(`minimized`)}},onError:t=>{if(!e&&!N.current&&!be.current&&!xe()){be.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{M.current?.setMicMuted?.(!0)}catch{}C(!0),x(`error`),Ne(`chat`)}},onDisconnect:t=>{if(e||N.current||be.current||xe())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:he.current||``,wasMuted:ye.current}),be.current=!0;try{M.current?.setMicMuted?.(!0)}catch{}C(!0),Ne(`chat`)}});if(e){console.warn(`[FlowEngage:VoiceDebug] ❌ cancelled=true after startSession resolved — killing session immediately`),R.endSession().catch(()=>{});return}l=R,M.current=R,x(`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&&!m?`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`:``;R.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}. ${h?``:`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(On()){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{_n()}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{M.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{}};d=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{d(...e),setTimeout(n,50)},f=()=>setTimeout(n,50),window.addEventListener(`popstate`,f)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(x(`error`),P.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,N.current=!0;try{_n()}catch{}if(i)try{Se(i)}catch{}typeof window<`u`&&(window.__fe_user_nav_during_speech=null),pr(),Ae.current&&=(clearTimeout(Ae.current),null),je.current&&=(clearTimeout(je.current),null),ne.current&&=(clearTimeout(ne.current),null),Oe.current=!1,Me.current=!1,F.current=`idle`,d&&typeof window<`u`&&(window.history.pushState=d),f&&typeof window<`u`&&window.removeEventListener(`popstate`,f);let t=l||M.current,n=Ce.current,u=we.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(()=>{}),Ce.current=null,we.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,Ne]),(0,d.useEffect)(()=>{if(!w)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Te.current&&!Te.current.contains(t)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[w]);let Le=async()=>{if(M.current)try{if(S){Ee.current=0,await M.current.setMicMuted?.(!1),C(!1);try{M.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{Ee.current=0,await M.current.setMicMuted?.(!0),C(!0);try{M.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{}},Re=(0,d.useCallback)(async e=>{e?.preventDefault?.();let t=D.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)){te(`Please enter a valid email address.`);return}te(``);try{typeof m==`function`&&await m(t)}catch{}A.current=!0,j.current=!1,Pe(),ee(!1),O(``),ae.current=!1,M.current?.setMicMuted?.(!1);let n=ie.current;ie.current=``;try{M.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{}},[D,m,Pe]),R=Array.isArray(e)&&e[0]||`#3B82F6`;return(0,f.jsxs)(`div`,{ref:Te,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:[E&&(0,f.jsxs)(`form`,{onSubmit:Re,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,f.jsx)(`span`,{style:{color:`white`,fontSize:`13px`,fontWeight:600,lineHeight:1.4},children:`Please enter your email to continue`}),(0,f.jsx)(`input`,{type:`email`,inputMode:`email`,autoComplete:`email`,autoFocus:!0,value:D,onChange:e=>{O(e.target.value),k&&te(``)},placeholder:`you@example.com`,style:{width:`100%`,boxSizing:`border-box`,padding:`10px 12px`,borderRadius:`10px`,border:k?`1.5px solid #ef4444`:`1.5px solid #4b5563`,background:`#1f2937`,color:`white`,fontSize:`14px`,outline:`none`}}),k&&(0,f.jsx)(`span`,{style:{color:`#f87171`,fontSize:`12px`},children:k}),(0,f.jsx)(`button`,{type:`submit`,disabled:!D.trim(),style:{width:`100%`,padding:`10px 12px`,borderRadius:`10px`,border:`none`,background:D.trim()?R:`#374151`,color:`white`,fontSize:`14px`,fontWeight:600,cursor:D.trim()?`pointer`:`default`,transition:`background 0.2s ease`},children:`Submit`})]}),(0,f.jsxs)(`div`,{style:{position:`relative`},children:[b===`listening`&&!S&&(0,f.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:_}),S&&(0,f.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,f.jsx)(lg,{size:72,voiceState:b,isMuted:S,orbColors:e})]}),b===`error`&&(0,f.jsx)(`span`,{style:{color:`#f87171`,fontSize:`13px`,fontWeight:500},children:`Could not start voice session.`}),(0,f.jsxs)(`div`,{style:{display:`flex`,gap:`12px`,alignItems:`center`},children:[(0,f.jsx)(`button`,{onClick:Le,title:S?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:S?`#7f1d1d`:`#1f2937`,border:S?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:S?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:S?(0,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`1`,y1:`1`,x2:`23`,y2:`23`}),(0,f.jsx)(`path`,{d:`M9 9v3a3 3 0 005.12 2.12M15 9.34V4a3 3 0 00-5.94-.6`}),(0,f.jsx)(`path`,{d:`M17 16.95A7 7 0 015 12v-2m14 0v2a7 7 0 01-.11 1.23`}),(0,f.jsx)(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),(0,f.jsx)(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]}):(0,f.jsx)(gm,{size:16,color:`currentColor`})}),(0,f.jsx)(`button`,{onClick:()=>T(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,f.jsx)(wm,{size:16,color:`currentColor`})})]}),w&&(0,f.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,f.jsxs)(`button`,{onClick:()=>{T(!1),P.current=`chat`,L(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,f.jsx)(Tm,{}),v]}),(0,f.jsxs)(`button`,{onClick:()=>{T(!1),P.current=`minimized`,L(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,f.jsx)(Em,{}),y]}),(0,f.jsx)(`button`,{onClick:()=>T(!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,f.jsxs)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`line`,{x1:`18`,y1:`6`,x2:`6`,y2:`18`}),(0,f.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,f.jsx)(`div`,{style:{width:`32px`,height:`32px`,borderRadius:`50%`,flexShrink:0,background:`
338
338
  radial-gradient(circle at 18% 50%, ${n} 0%, ${n}99 35%, transparent 65%),
339
339
  radial-gradient(circle at 82% 50%, ${r} 0%, ${r}99 35%, transparent 65%),
340
340
  radial-gradient(circle at 50% 82%, ${i} 0%, ${i}99 30%, transparent 58%),
341
341
  white
342
- `.replace(/\s+/g,` `).trim()}})}var cg=()=>(0,f.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,f.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,f.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 lg({copy:e,orbColors:t,primaryColor:n,chatBgGradient:r,logo:i,quickChatOptions:a,onQuickChatSelect:o,isMobile:s,chatHistory:c,isAiTyping:l,isAgentTyping:u,activeScreen:p,agentName:m,agentHeadshot:h,fallbackAgentName:g,input:_,setInput:v,onSubmit:y,isConversationEnded:b,isLoading:x,isRateLimited:S,rateLimitMessage:C,selectedFile:w,onFileSelect:T,onRemoveSelectedFile:E,attachmentError:ee,isUploadingAttachment:D,requiresEmail:O,emailInput:te,setEmailInput:ne,emailError:re,emailCaptureSuccess:ie,replyContext:ae,setReplyContext:oe,webRTCError:se,micError:k,setMicError:ce,dismissCallError:le,activeCallId:ue,isCallMuted:A,toggleCallMute:de,endWebRTCCall:j,formatCallDuration:fe,callDurationSeconds:pe,isCallMinimized:me,onExpand:he,onCollapse:ge,onStartVoice:_e,voiceEnabled:ve,headerBgColor:ye,onNewChat:be,showPoweredBy:xe,privacyPolicyUrl:Se,getVisitorChatHistory:M,resumeChat:N,isSessionRestoring:Ce,isClosing:we}){let P=c.length>0,F=x||S||b,Te=!!ue,[Ee,I]=(0,d.useState)(!1),[De,Oe]=(0,d.useState)(!1),[ke,Ae]=(0,d.useState)([]),[je,Me]=(0,d.useState)(!1),Ne=(0,d.useRef)(null),[Pe,L]=(0,d.useState)(()=>typeof window<`u`?window.visualViewport?.height??window.innerHeight:600),[Fe,Ie]=(0,d.useState)(0);(0,d.useEffect)(()=>{if(!s)return;let e=window.visualViewport;if(!e)return;let t=()=>{L(e.height),Ie(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 Le=s&&window.innerHeight-Pe>150,Re=async()=>{I(!1),Oe(!0),Me(!0);try{let e=await M();e?.data&&Ae(e.data)}catch(e){console.error(e)}finally{Me(!1)}},ze=async e=>{Oe(!1),N?.(e.chatId)};return(0,d.useEffect)(()=>{if(!Ee)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Ne.current&&!Ne.current.contains(t)&&I(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ee]),(0,f.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`0`,right:`0`,bottom:`${Fe}px`,height:Pe>0?`${Math.round(Pe*(Le?1:.92))}px`:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:we?`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:we?`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,f.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,f.jsx)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:(0,f.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,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.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,f.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,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,f.jsx)(eg,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,f.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,f.jsx)(tg,{title:e.chatTitle})})}),o&&(0,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:c?`flex-start`:`center`},children:(0,f.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,f.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Ne,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>I(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,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,f.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),Ee&&(0,f.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,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{I(!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,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,f.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,f.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}})]}),(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{I(!1),be?.()},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,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`path`,{d:`M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7`}),(0,f.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`]}),M&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,f.jsxs)(`button`,{type:`button`,onClick:Re,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,f.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`path`,{d:`M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z`})}),`Chat history`]})]}),(0,f.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{I(!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,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,f.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`Close conversation`]})]})]})]}),(0,f.jsx)(Jm,{webRTCError:se,micError:k,setMicError:ce,dismissCallError:le,isRateLimited:S,rateLimitMessage:C}),me&&(0,f.jsx)(dh,{agentName:m,agentHeadshot:h,fallbackAgentName:g,callDurationSeconds:pe,isCallMuted:A,formatCallDuration:fe,toggleCallMute:de,endWebRTCCall:j,onExpand:he,primaryColor:n}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[De?(0,f.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,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px`,borderBottom:`1px solid #f3f4f6`,flexShrink:0},children:(0,f.jsxs)(`button`,{onClick:()=>Oe(!1),style:{background:`none`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,color:`#6b7280`},children:[(0,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),(0,f.jsx)(`span`,{style:{marginLeft:`8px`,fontWeight:500,fontSize:`15px`},children:`Return to Chat`})]})}),(0,f.jsx)(`div`,{style:{flex:1,overflowY:`auto`,position:`relative`},children:je?(0,f.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):ke.length>0?(0,f.jsx)(`div`,{children:ke.map(e=>(0,f.jsxs)(`div`,{onClick:()=>ze(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,f.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,f.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,f.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#9ca3af`,fontSize:`14px`},children:`No previous chats found.`})})]}):null,P?(0,f.jsx)(Gm,{chatHistory:c,isAiTyping:l,isLoading:x,isAgentTyping:u,setReplyContext:oe,TypingDots:cg,primaryColor:n,agentHeadshot:h,agentDisplayName:m||g,botAvatarNode:(0,f.jsx)(sg,{orbColors:t})}):Ce?(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`},children:[(0,f.jsx)(`div`,{style:{width:`28px`,height:`28px`,border:`3px solid #f3f4f6`,borderTop:`3px solid ${n}`,borderRadius:`50%`,animation:`spin 1s linear infinite`},children:(0,f.jsx)(`style`,{children:`@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})}),(0,f.jsx)(`div`,{style:{color:`#6b7280`,fontSize:`14px`,fontWeight:500,animation:`fe-orb-fade-in 1s infinite alternate`},children:`Loading chat...`})]}):(0,f.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,f.jsx)(rg,{size:94,orbColors:t}),(0,f.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,f.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,f.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))})]})]}),ie&&(0,f.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,f.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,f.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,f.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`#065f46`},children:`Email saved — we'll be in touch!`})]}),(0,f.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:O?`6px 0 0`:`12px 0 0`},children:(0,f.jsx)(qm,{input:_,setInput:v,onSubmit:y,isConversationEnded:b,callUiActive:Te,handleToggleVoice:_e,showVoiceToggle:p===`agent`,activeScreen:p,inputDisabled:F,replyContext:ae,clearReplyContext:()=>oe(null),onFileSelect:T,selectedFile:w,onRemoveSelectedFile:E,attachmentError:ee,isUploadingAttachment:D,requiresEmail:O,emailInput:te,setEmailInput:ne,emailError:re,inputPlaceholder:e.inputPlaceholder})}),!Le&&(0,f.jsxs)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`8px 20px`,paddingBottom:`max(12px, env(safe-area-inset-bottom, 12px))`,pointerEvents:`none`},children:[Se&&(0,f.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,f.jsx)(`a`,{href:Se,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#6b7280`,textDecoration:`underline`},children:`See our privacy policy`})]}),xe&&(0,f.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,f.jsx)(`strong`,{style:{fontWeight:600,color:`#6b7280`},children:`FlowEngage`})]})]})]})}function ug(){let{status:e,runtimeConfig:t,resolvedConfig:n,chatHistory:r,isOpen:i,activeScreen:a,isHumanHandled:o,agentName:s,agentHeadshot:c,visitorEmail:l,isAgentTyping:u,isAiTyping:p,isLoading:m,isRateLimited:h,rateLimitMessage:g,isConversationEnded:_,incomingCall:v,activeCallId:y,callConnectionState:b,callConnectedAt:x,isCallMuted:S,webRTCError:C,language:w,chatId:T,historyRef:E,onMessageSync:O,sendMessage:te,uploadChatFile:ne,openWidget:re,captureVisitorEmail:ie,setVoiceMode:ae,endConversation:oe,startNewChat:se,acceptCall:k,rejectCall:ce,endWebRTCCall:le,toggleCallMute:ue,dismissCallError:A,startTyping:de,stopTyping:j,updateTypingDraft:fe,getVisitorChatHistory:pe,resumeChat:ge,isSessionRestoring:_e,openToChatCounter:ye,voiceEndCounter:be}=pn();(0,d.useEffect)(()=>{try{Xn()}catch{}},[]),(0,d.useEffect)(()=>{ye&&V!==`voice_mode`&&V!==`text_chat`&&V!==`call_screen`&&(ae?.(!1),H(`text_chat`))},[ye]);let Se=t?.widgetSettings||{},M=n?.widgetSettings||{},N={...Se.branding||{},...M.branding||{}},Ce={...Se.theme||{},...M.theme||{}},we={...Se.features||{},...M.features||{}},P=we.voice!==!1,F=Array.isArray(Ce.orbColors)&&Ce.orbColors.length>0?Ce.orbColors:null,Te=Ce.buttonColor||Ce.primaryColor||F?.[0]||`#3B82F6`,Ee={small:50,medium:64,large:80},I=Ee[Ce.orbSize]||Ee.small,De=Ce.position||`bottom-right`,Oe=N.fallbackAgentName||`Agent`,ke=Zh(F??Ce.chatBgColors),Ae=N.logo||N.logoUrl||null,je=w||`en`,Me=Se.recommendations?.[je]||[],Ne=(M.recommendations?.[je]??Me).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Pe=Array.isArray(N.quickChatOptions)&&N.quickChatOptions.length>0?N.quickChatOptions:Ne,L=N.hideWatermark===!0?!1:N.showPoweredBy!==!1,Fe=N.headerBgColor||null,Ie=Ce.bottomPosition==null?`1.5rem`:`${Ce.bottomPosition}px`,Le=N.privacyPolicyUrl||null,Re=N.chatbotEnabled!==!1&&Ce.chatbotEnabled!==!1,[ze,Be]=(0,d.useState)(()=>typeof window<`u`?window.location.pathname:`/`);(0,d.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>Be(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 Ve=(()=>{let e={...Se.pageVisibility||{},...M.pageVisibility||{}};return Array.isArray(e.allowedPaths)?e.allowedPaths.filter(Boolean):[]})(),He=Ve.length===0||Ve.some(e=>e===`*`||e===`/*`?!0:e.endsWith(`/*`)?ze.startsWith(e.slice(0,-1)):ze.replace(/\/$/,``)===e.replace(/\/$/,``)),Ue=Se.greetings?.[w]||M.greetings?.[w]||N.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,We={entryPrompt:N.entryPrompt||`Do you want to explore in a new way?`,yesLabel:N.yesLabel||`Yes`,laterLabel:N.laterLabel||`Later`,connectionTitle:N.connectionTitle||`How would you like to connect?`,connectionSubtitle:N.connectionSubtitle||``,voiceLabel:N.voiceLabel||`Voice`,textLabel:N.textLabel||`Text`,chatTitle:N.headerName||`Chat with FlowEngage`,hasCustomTitle:!!(N.headerName&&String(N.headerName).trim()),introGreeting:Ue,inputPlaceholder:N.inputPlaceholder||`Type your message`,analysingLabel:N.analysingLabel||`analysing...`},Ge=M.elevenLabsAgentId||t?.elevenLabsAgentId||null,Ke=t?.siteId||n?.siteId||null,qe=t?.apiBaseUrl||``;(0,d.useEffect)(()=>{In(t?.siteType||null)},[t?.siteType]);let R=(0,d.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),z=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,Je=r.some(e=>e.sender===`user`),B=(0,d.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]),Ye=!!(M._dashboardLivePreview||Se._dashboardLivePreview),[V,H]=(0,d.useState)(()=>Ye?`text_chat`:`entry_prompt`),[Xe,Ze]=(0,d.useState)(``),[Qe,$e]=(0,d.useState)(null),[et,tt]=(0,d.useState)(l||``),[nt,rt]=(0,d.useState)(``),[it,at]=(0,d.useState)(!1),[ot,st]=(0,d.useState)(0),[ct,lt]=(0,d.useState)(null),[ut,dt]=(0,d.useState)(null),[ft,pt]=(0,d.useState)(``),[mt,ht]=(0,d.useState)(!1),[gt,_t]=(0,d.useState)(!1),[vt,yt]=(0,d.useState)(!1),bt=(0,d.useRef)(null),xt=(0,d.useRef)(!1),St=!l&&Je&&B&&V!==`voice_mode`;(0,d.useLayoutEffect)(()=>{if(e!==`ready`||xt.current)return;if(xt.current=!0,!P){H(`minimized_orb`);return}let t=!1;try{t=cr().shouldResumeVoice}catch{}let n=ve(),r=Ke?me(Ke):null,i=n||!!r?.transcript;if(t){re?.({notifyChatInitiated:!0}),ae?.(!0),H(`voice_mode`);return}if(xe()){re?.({notifyChatInitiated:!1}),H(`text_chat`);return}if(i){if((typeof performance<`u`?performance.getEntriesByType?.(`navigation`)?.[0]?.type??`navigate`:`navigate`)===`reload`){H(`minimized_orb`);return}re?.({notifyChatInitiated:!0}),ae?.(!0),H(`voice_mode`);return}if(Ke)try{he(Ke)}catch{}if(ee(Ke)){H(`minimized_orb`);return}},[e,r]);let[Ct,wt]=(0,d.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,d.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>wt(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,d.useEffect)(()=>{tt(l||``),l&&rt(``)},[l]);let Tt=(0,d.useCallback)(()=>{dt(null),pt(``)},[]),Et=(0,d.useCallback)(e=>{let t=Bm(e);if(t){dt(null),pt(t);return}dt(e),pt(``)},[]);(0,d.useEffect)(()=>{if(!x||b!==`connected`){st(0);return}let e=()=>{let e=new Date(x).getTime();isNaN(e)||st(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[x,b]);let Dt=(0,d.useCallback)(()=>{H(`call_screen`),_t(!1)},[]),Ot=(0,d.useCallback)(()=>{H(`text_chat`),_t(!0)},[]);(0,d.useEffect)(()=>{let e=v?.callId||y||null;if(!e){bt.current=null;return}if(v?.callId||b===`connecting`||b===`connected`){if(V===`minimized_orb`&&gt&&y&&!v?.callId){bt.current=e;return}!(!i||V===`minimized_orb`||V===`voice_mode`)&&bt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:V,hasIncomingCall:!!v?.callId,activeCallId:y,callConnectionState:b}),bt.current=e,V===`voice_mode`&&ae?.(!1),re?.(),Dt())}},[y,b,Dt,v?.callId,i,re,ae,V]),(0,d.useEffect)(()=>{!v&&!y&&V===`call_screen`&&H(`text_chat`)},[v,y,V]),(0,d.useEffect)(()=>{!y&&gt&&_t(!1)},[y,gt]),(0,d.useEffect)(()=>{if(!o||_){fe?.(``),j?.();return}if(!Xe.trim()||ut){fe?.(``);let e=window.setTimeout(()=>j?.(),100);return()=>window.clearTimeout(e)}de?.();let e=window.setTimeout(()=>fe?.(Xe),120),t=window.setTimeout(()=>j?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[Xe,ut,o,_,de,j,fe]);let kt=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,At=async e=>{if(e.preventDefault(),_)return;if(St){let e=et.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){rt(`Please enter a valid email so we can continue helping you.`);return}await ie(e),rt(``),at(!0),setTimeout(()=>at(!1),3e3);return}let t=kt(Qe);if(!Xe.trim()&&!ut)return;if(ut){try{ht(!0),pt(``);let e=await ne(ut),n=e?.data||e,r=Xe.trim()||`Shared file: ${Hm(ut)}`;Ze(``),$e(null),Tt(),await te(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||ut.name,fileType:n?.fileType||ut.type,fileSize:n?.fileSize||ut.size}})}catch(e){pt(e?.message||`Failed to upload the selected file.`)}finally{ht(!1)}return}let n=Xe.trim();Ze(``),$e(null),await te(n,``,t)},jt=(0,d.useCallback)(()=>{r.length!==0&&se?.()},[r.length,se]),Mt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},Nt=(0,d.useCallback)(async e=>{if(_||m)return;let t=e.message||e.label||e.text||``;t.trim()&&await te(t.trim(),``)},[_,m,te]),Pt=Ct&&V===`entry_prompt`?{inset:0}:Ct&&V===`text_chat`?{left:0,right:0,bottom:0}:Ct&&V===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:Ct&&V===`connection_modal`?{left:`12px`,right:`12px`,bottom:`12px`}:V===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...De===`bottom-left`?{left:`1.5rem`,bottom:Ie}:{right:`1.5rem`,bottom:Ie}}:De===`bottom-left`?{left:`1.5rem`,bottom:Ie}:{right:`1.5rem`,bottom:Ie},Ft=(0,d.useCallback)(()=>{V!==`minimized_orb`&&(yt(!0),setTimeout(()=>{H(`minimized_orb`),yt(!1),y&&_t(!0)},280))},[y,V]),It=()=>H(`connection_modal`),Lt=()=>{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}),ae?.(!0),H(`voice_mode`)},Rt=()=>{re({notifyChatInitiated:!0}),ae?.(!1),H(`text_chat`)},zt=()=>{ae?.(!1),Ft()};return e!==`ready`||!Re||we.chat===!1||!He?null:(0,f.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...Pt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[V===`entry_prompt`&&(0,f.jsx)(ig,{copy:We,orbColors:F,primaryColor:Te,onYes:()=>{D(Ke),Lt()},onLater:()=>{D(Ke),Ft()},isMobile:Ct,isClosing:vt}),V===`minimized_orb`&&(0,f.jsxs)(sm.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:De===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[y&&(0,f.jsxs)(`button`,{type:`button`,onClick:Dt,style:{maxWidth:Ct?`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,f.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,f.jsxs)(`span`,{style:{minWidth:0},children:[(0,f.jsx)(`span`,{style:{display:`block`,fontSize:`12px`,fontWeight:700,color:`#111827`,lineHeight:1.2},children:b===`connected`?`Call in progress`:`Call is active`}),(0,f.jsx)(`span`,{style:{display:`block`,fontSize:`11px`,color:`#6b7280`,lineHeight:1.3,marginTop:`2px`,whiteSpace:`nowrap`},children:b===`connected`?`${Mt(ot)} with ${R}`:`Tap to return to ${R}`})]})]}),(0,f.jsx)(rg,{size:I,orbColors:F,onClick:y?Dt:P?It:Rt})]}),V===`connection_modal`&&(0,f.jsx)(ag,{copy:We,orbColors:F,primaryColor:Te,onVoice:Lt,onText:Rt,onClose:Ft,isMobile:Ct,isClosing:vt}),V===`voice_mode`&&(0,f.jsx)(og,{orbColors:F,onEnterChat:Rt,onEndChat:zt,agentId:Ge,siteId:Ke,apiBaseUrl:qe,chatId:T,historyRef:E,onMessageSync:O,voiceEndCounter:be,websiteName:t?.websiteName,voiceFirstMessage:Se.voiceFirstMessage||null,captureVisitorEmail:ie,emailRequired:!l,emailCaptureEnabled:N.disableEmailCapture!==!0,listeningLabel:N.voiceListeningLabel||`Listening...`,enterChatModeLabel:N.voiceEnterChatLabel||`Enter Chat Mode`,endConversationLabel:N.voiceEndConversationLabel||`End Conversation`},`voice`),V===`call_screen`&&(0,f.jsx)(uh,{incomingCall:v,activeCallId:y,callConnectionState:b,callDurationSeconds:ot,isCallMuted:S,agentName:R,agentHeadshot:z,fallbackAgentName:Oe,acceptCall:k,rejectCall:ce,endWebRTCCall:le,toggleCallMute:ue,formatCallDuration:Mt,onMinimize:Ot,primaryColor:Te,orbColors:F,chatHistory:r}),V===`text_chat`&&(0,f.jsx)(lg,{isClosing:vt,copy:We,orbColors:F,primaryColor:Te,chatBgGradient:ke,logo:Ae,quickChatOptions:Pe,onQuickChatSelect:Nt,isMobile:Ct,chatHistory:r,isAiTyping:p,isAgentTyping:u,activeScreen:a,agentName:R,agentHeadshot:z,fallbackAgentName:Oe,input:Xe,setInput:Ze,onSubmit:At,isConversationEnded:_,isLoading:m,isRateLimited:h,rateLimitMessage:g,selectedFile:ut,onFileSelect:Et,onRemoveSelectedFile:Tt,attachmentError:ft,isUploadingAttachment:mt,requiresEmail:St,emailInput:et,setEmailInput:tt,emailError:nt,emailCaptureSuccess:it,replyContext:Qe,setReplyContext:$e,webRTCError:C,micError:ct,setMicError:lt,dismissCallError:A,activeCallId:y,isCallMuted:S,toggleCallMute:ue,endWebRTCCall:le,formatCallDuration:Mt,callDurationSeconds:ot,onCollapse:Ft,onStartVoice:Lt,voiceEnabled:P,onNewChat:jt,onMinimize:Ot,onExpand:Dt,isCallMinimized:!!y,showPoweredBy:L,privacyPolicyUrl:Le,headerBgColor:Fe,getVisitorChatHistory:pe,resumeChat:ge,isSessionRestoring:_e}),(0,f.jsx)(`style`,{children:`
342
+ `.replace(/\s+/g,` `).trim()}})}var mg=()=>(0,f.jsx)(`div`,{style:{display:`flex`,marginBottom:`12px`,justifyContent:`flex-start`},children:(0,f.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,f.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:p,agentName:m,agentHeadshot:h,fallbackAgentName:g,input:_,setInput:v,onSubmit:y,isConversationEnded:b,isLoading:x,isRateLimited:S,rateLimitMessage:C,selectedFile:w,onFileSelect:T,onRemoveSelectedFile:E,attachmentError:ee,isUploadingAttachment:D,requiresEmail:O,emailInput:k,setEmailInput:te,emailError:A,emailCaptureSuccess:j,replyContext:ne,setReplyContext:re,webRTCError:ie,micError:ae,setMicError:oe,dismissCallError:se,activeCallId:ce,isCallMuted:le,toggleCallMute:ue,endWebRTCCall:de,formatCallDuration:M,callDurationSeconds:fe,isCallMinimized:pe,onExpand:me,onCollapse:he,onStartVoice:ge,voiceEnabled:_e,headerBgColor:ve,onNewChat:ye,showPoweredBy:be,privacyPolicyUrl:xe,getVisitorChatHistory:N,resumeChat:P,isSessionRestoring:Se,isClosing:Ce}){let we=c.length>0,Te=x||S||b,Ee=!!ce,[De,F]=(0,d.useState)(!1),[Oe,ke]=(0,d.useState)(!1),[Ae,je]=(0,d.useState)([]),[Me,Ne]=(0,d.useState)(!1),Pe=(0,d.useRef)(null),[Fe,I]=(0,d.useState)(()=>typeof window<`u`?window.visualViewport?.height??window.innerHeight:600),[Ie,L]=(0,d.useState)(0);(0,d.useEffect)(()=>{if(!s)return;let e=window.visualViewport;if(!e)return;let t=()=>{I(e.height),L(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 Le=s&&window.innerHeight-Fe>150,Re=async()=>{F(!1),ke(!0),Ne(!0);try{let e=await N();e?.data&&je(e.data)}catch(e){console.error(e)}finally{Ne(!1)}},R=async e=>{ke(!1),P?.(e.chatId)};return(0,d.useEffect)(()=>{if(!De)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Pe.current&&!Pe.current.contains(t)&&F(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[De]),(0,f.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`0`,right:`0`,bottom:`${Ie}px`,height:Fe>0?`${Math.round(Fe*(Le?1:.92))}px`:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:Ce?`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:Ce?`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,f.jsxs)(`div`,{style:{display:`grid`,gridTemplateColumns:`40px minmax(0, 1fr) 40px`,alignItems:`center`,columnGap:`14px`,padding:`16px 10px 14px`,background:ve||`transparent`,flexShrink:0,position:`relative`,zIndex:30},children:[(0,f.jsx)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:(0,f.jsx)(`button`,{onClick:he,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,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.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,f.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,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,f.jsx)(og,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,f.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,f.jsx)(sg,{title:e.chatTitle})})}),o&&(0,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:c?`flex-start`:`center`},children:(0,f.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,f.jsxs)(`div`,{style:{position:`relative`,isolation:`isolate`,zIndex:10},ref:Pe,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>F(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,f.jsxs)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`5`,r:`1.5`}),(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`1.5`}),(0,f.jsx)(`circle`,{cx:`12`,cy:`19`,r:`1.5`})]})}),De&&(0,f.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:[_e&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{F(!1),ge?.()},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,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`path`,{d:`M12 1a4 4 0 014 4v6a4 4 0 01-8 0V5a4 4 0 014-4z`}),(0,f.jsx)(`path`,{d:`M19 10a7 7 0 01-14 0M12 19v4M8 23h8`})]}),`Enter Voice Mode`]}),(0,f.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}})]}),(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{F(!1),ye?.()},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,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`path`,{d:`M12 5H5a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-7`}),(0,f.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`]}),N&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,f.jsxs)(`button`,{type:`button`,onClick:Re,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,f.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`path`,{d:`M12 8v4l3 3M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0z`})}),`Chat history`]})]}),(0,f.jsx)(`div`,{style:{height:`1px`,background:`rgba(255,255,255,0.07)`,margin:`0 14px`}}),(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{F(!1),he?.()},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,f.jsxs)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,f.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,f.jsx)(`line`,{x1:`15`,y1:`9`,x2:`9`,y2:`15`}),(0,f.jsx)(`line`,{x1:`9`,y1:`9`,x2:`15`,y2:`15`})]}),`Close conversation`]})]})]})]}),(0,f.jsx)(Jm,{webRTCError:ie,micError:ae,setMicError:oe,dismissCallError:se,isRateLimited:S,rateLimitMessage:C}),pe&&(0,f.jsx)(dh,{agentName:m,agentHeadshot:h,fallbackAgentName:g,callDurationSeconds:fe,isCallMuted:le,formatCallDuration:M,toggleCallMute:ue,endWebRTCCall:de,onExpand:me,primaryColor:n}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[Oe?(0,f.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,f.jsx)(`div`,{style:{display:`flex`,alignItems:`center`,padding:`16px`,borderBottom:`1px solid #f3f4f6`,flexShrink:0},children:(0,f.jsxs)(`button`,{onClick:()=>ke(!1),style:{background:`none`,border:`none`,cursor:`pointer`,display:`flex`,alignItems:`center`,color:`#6b7280`},children:[(0,f.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,f.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),(0,f.jsx)(`span`,{style:{marginLeft:`8px`,fontWeight:500,fontSize:`15px`},children:`Return to Chat`})]})}),(0,f.jsx)(`div`,{style:{flex:1,overflowY:`auto`,position:`relative`},children:Me?(0,f.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):Ae.length>0?(0,f.jsx)(`div`,{children:Ae.map(e=>(0,f.jsxs)(`div`,{onClick:()=>R(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,f.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,f.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,f.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#9ca3af`,fontSize:`14px`},children:`No previous chats found.`})})]}):null,we?(0,f.jsx)(Gm,{chatHistory:c,isAiTyping:l,isLoading:x,isAgentTyping:u,setReplyContext:re,TypingDots:mg,primaryColor:n,agentHeadshot:h,agentDisplayName:m||g,botAvatarNode:(0,f.jsx)(pg,{orbColors:t})}):Se?(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`16px`},children:[(0,f.jsx)(`div`,{style:{width:`28px`,height:`28px`,border:`3px solid #f3f4f6`,borderTop:`3px solid ${n}`,borderRadius:`50%`,animation:`spin 1s linear infinite`},children:(0,f.jsx)(`style`,{children:`@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }`})}),(0,f.jsx)(`div`,{style:{color:`#6b7280`,fontSize:`14px`,fontWeight:500,animation:`fe-orb-fade-in 1s infinite alternate`},children:`Loading chat...`})]}):(0,f.jsxs)(`div`,{style:{flex:1,overflowY:`auto`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`22px`,padding:`28px 24px`},children:[(0,f.jsx)(lg,{size:94,orbColors:t}),(0,f.jsx)(`p`,{style:{margin:0,textAlign:`center`,fontSize:`16px`,color:`#374151`,lineHeight:1.55,maxWidth:`270px`},children:e.introGreeting}),a.length>0&&(0,f.jsx)(`div`,{style:{display:`flex`,flexWrap:`wrap`,gap:`8px`,justifyContent:`center`,width:`100%`,padding:`0 8px`},children:a.map(e=>(0,f.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))})]})]}),j&&(0,f.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,f.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,f.jsx)(`polyline`,{points:`20 6 9 17 4 12`})}),(0,f.jsx)(`span`,{style:{fontSize:`13px`,fontWeight:500,color:`#065f46`},children:`Email saved — we'll be in touch!`})]}),(0,f.jsx)(`div`,{style:{background:`transparent`,flexShrink:0,position:`relative`,zIndex:1,padding:O?`6px 0 0`:`12px 0 0`},children:(0,f.jsx)(qm,{input:_,setInput:v,onSubmit:y,isConversationEnded:b,callUiActive:Ee,handleToggleVoice:ge,showVoiceToggle:p===`agent`,activeScreen:p,inputDisabled:Te,replyContext:ne,clearReplyContext:()=>re(null),onFileSelect:T,selectedFile:w,onRemoveSelectedFile:E,attachmentError:ee,isUploadingAttachment:D,requiresEmail:O,emailInput:k,setEmailInput:te,emailError:A,inputPlaceholder:e.inputPlaceholder})}),!Le&&(0,f.jsxs)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`8px 20px`,paddingBottom:`max(12px, env(safe-area-inset-bottom, 12px))`,pointerEvents:`none`},children:[xe&&(0,f.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,f.jsx)(`a`,{href:xe,target:`_blank`,rel:`noopener noreferrer`,style:{color:`#6b7280`,textDecoration:`underline`},children:`See our privacy policy`})]}),be&&(0,f.jsxs)(`span`,{style:{fontSize:`11px`,color:`#9ca3af`,letterSpacing:`0.01em`,userSelect:`none`},children:[`Powered by `,(0,f.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:p,isLoading:m,isRateLimited:h,rateLimitMessage:g,isConversationEnded:_,incomingCall:v,activeCallId:y,callConnectionState:b,callConnectedAt:x,isCallMuted:S,webRTCError:C,language:w,chatId:T,historyRef:E,onMessageSync:O,sendMessage:k,uploadChatFile:te,openWidget:A,captureVisitorEmail:j,setVoiceMode:ne,endConversation:re,startNewChat:ie,acceptCall:ae,rejectCall:oe,endWebRTCCall:se,toggleCallMute:ce,dismissCallError:le,startTyping:ue,stopTyping:de,updateTypingDraft:M,getVisitorChatHistory:fe,resumeChat:he,isSessionRestoring:ge,openToChatCounter:ve,voiceEndCounter:ye}=fn();(0,d.useEffect)(()=>{try{Yn()}catch{}},[]),(0,d.useEffect)(()=>{ve&&H!==`voice_mode`&&H!==`text_chat`&&H!==`call_screen`&&(ne?.(!1),U(`text_chat`))},[ve]);let xe=t?.widgetSettings||{},N=n?.widgetSettings||{},P={...xe.branding||{},...N.branding||{}},Se={...xe.theme||{},...N.theme||{}},Ce={...xe.features||{},...N.features||{}},we=Ce.voice!==!1,Te=Array.isArray(Se.orbColors)&&Se.orbColors.length>0?Se.orbColors:null,Ee=Se.buttonColor||Se.primaryColor||Te?.[0]||`#3B82F6`,De={small:50,medium:64,large:80},F=De[Se.orbSize]||De.small,Oe=Se.position||`bottom-right`,ke=P.fallbackAgentName||`Agent`,Ae=rg(Te??Se.chatBgColors),je=P.logo||P.logoUrl||null,Me=w||`en`,Ne=xe.recommendations?.[Me]||[],Pe=(N.recommendations?.[Me]??Ne).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Fe=Array.isArray(P.quickChatOptions)&&P.quickChatOptions.length>0?P.quickChatOptions:Pe,I=P.hideWatermark===!0?!1:P.showPoweredBy!==!1,Ie=P.headerBgColor||null,L=Se.bottomPosition==null?`1.5rem`:`${Se.bottomPosition}px`,Le=P.privacyPolicyUrl||null,Re=P.chatbotEnabled!==!1&&Se.chatbotEnabled!==!1,[R,ze]=(0,d.useState)(()=>typeof window<`u`?window.location.pathname:`/`);(0,d.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>ze(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 Be=(()=>{let e={...xe.pageVisibility||{},...N.pageVisibility||{}};return Array.isArray(e.allowedPaths)?e.allowedPaths.filter(Boolean):[]})(),Ve=Be.length===0||Be.some(e=>e===`*`||e===`/*`?!0:e.endsWith(`/*`)?R.startsWith(e.slice(0,-1)):R.replace(/\/$/,``)===e.replace(/\/$/,``)),He=xe.greetings?.[w]||N.greetings?.[w]||P.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,Ue={entryPrompt:P.entryPrompt||`Do you want to explore in a new way?`,yesLabel:P.yesLabel||`Yes`,laterLabel:P.laterLabel||`Later`,connectionTitle:P.connectionTitle||`How would you like to connect?`,connectionSubtitle:P.connectionSubtitle||``,voiceLabel:P.voiceLabel||`Voice`,textLabel:P.textLabel||`Text`,chatTitle:P.headerName||`Chat with FlowEngage`,hasCustomTitle:!!(P.headerName&&String(P.headerName).trim()),introGreeting:He,inputPlaceholder:P.inputPlaceholder||`Type your message`,analysingLabel:P.analysingLabel||`analysing...`},We=N.elevenLabsAgentId||t?.elevenLabsAgentId||null,Ge=t?.siteId||n?.siteId||null,Ke=t?.apiBaseUrl||``;(0,d.useEffect)(()=>{Fn(t?.siteType||null)},[t?.siteType]);let z=(0,d.useMemo)(()=>s&&String(s).trim()||t?.ownerName&&String(t.ownerName).trim()||t?.websiteName&&String(t.websiteName).trim()||`Agent`,[s,t?.ownerName,t?.websiteName]),B=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,qe=r.some(e=>e.sender===`user`),V=(0,d.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]),Je=!!(N._dashboardLivePreview||xe._dashboardLivePreview),[H,U]=(0,d.useState)(()=>Je?`text_chat`:`entry_prompt`),[Ye,Xe]=(0,d.useState)(``),[Ze,Qe]=(0,d.useState)(null),[$e,et]=(0,d.useState)(l||``),[tt,nt]=(0,d.useState)(``),[rt,it]=(0,d.useState)(!1),[at,ot]=(0,d.useState)(0),[st,ct]=(0,d.useState)(null),[lt,ut]=(0,d.useState)(null),[dt,ft]=(0,d.useState)(``),[pt,mt]=(0,d.useState)(!1),[ht,gt]=(0,d.useState)(!1),[_t,vt]=(0,d.useState)(!1),yt=(0,d.useRef)(null),bt=(0,d.useRef)(!1),xt=!l&&qe&&V&&H!==`voice_mode`;(0,d.useLayoutEffect)(()=>{if(e!==`ready`||bt.current)return;if(bt.current=!0,!we){U(`minimized_orb`);return}let t=!1;try{t=sr().shouldResumeVoice}catch{}let n=_e(),r=Ge?pe(Ge):null,i=n||!!r?.transcript;if(t){A?.({notifyChatInitiated:!0}),ne?.(!0),U(`voice_mode`);return}if(be()){A?.({notifyChatInitiated:!1}),U(`text_chat`);return}if(i){if((typeof performance<`u`?performance.getEntriesByType?.(`navigation`)?.[0]?.type??`navigate`:`navigate`)===`reload`){U(`minimized_orb`);return}A?.({notifyChatInitiated:!0}),ne?.(!0),U(`voice_mode`);return}if(Ge)try{me(Ge)}catch{}if(ee(Ge)){U(`minimized_orb`);return}},[e,r]);let[St,Ct]=(0,d.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,d.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>Ct(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,d.useEffect)(()=>{et(l||``),l&&nt(``)},[l]);let wt=(0,d.useCallback)(()=>{ut(null),ft(``)},[]),Tt=(0,d.useCallback)(e=>{let t=Bm(e);if(t){ut(null),ft(t);return}ut(e),ft(``)},[]);(0,d.useEffect)(()=>{if(!x||b!==`connected`){ot(0);return}let e=()=>{let e=new Date(x).getTime();isNaN(e)||ot(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[x,b]);let Et=(0,d.useCallback)(()=>{U(`call_screen`),gt(!1)},[]),Dt=(0,d.useCallback)(()=>{U(`text_chat`),gt(!0)},[]);(0,d.useEffect)(()=>{let e=v?.callId||y||null;if(!e){yt.current=null;return}if(v?.callId||b===`connecting`||b===`connected`){if(H===`minimized_orb`&&ht&&y&&!v?.callId){yt.current=e;return}!(!i||H===`minimized_orb`||H===`voice_mode`)&&yt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:H,hasIncomingCall:!!v?.callId,activeCallId:y,callConnectionState:b}),yt.current=e,H===`voice_mode`&&ne?.(!1),A?.(),Et())}},[y,b,Et,v?.callId,i,A,ne,H]),(0,d.useEffect)(()=>{!v&&!y&&H===`call_screen`&&U(`text_chat`)},[v,y,H]),(0,d.useEffect)(()=>{!y&&ht&&gt(!1)},[y,ht]),(0,d.useEffect)(()=>{if(!o||_){M?.(``),de?.();return}if(!Ye.trim()||lt){M?.(``);let e=window.setTimeout(()=>de?.(),100);return()=>window.clearTimeout(e)}ue?.();let e=window.setTimeout(()=>M?.(Ye),120),t=window.setTimeout(()=>de?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[Ye,lt,o,_,ue,de,M]);let Ot=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,kt=async e=>{if(e.preventDefault(),_)return;if(xt){let e=$e.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){nt(`Please enter a valid email so we can continue helping you.`);return}await j(e),nt(``),it(!0),setTimeout(()=>it(!1),3e3);return}let t=Ot(Ze);if(!Ye.trim()&&!lt)return;if(lt){try{mt(!0),ft(``);let e=await te(lt),n=e?.data||e,r=Ye.trim()||`Shared file: ${Hm(lt)}`;Xe(``),Qe(null),wt(),await k(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||lt.name,fileType:n?.fileType||lt.type,fileSize:n?.fileSize||lt.size}})}catch(e){ft(e?.message||`Failed to upload the selected file.`)}finally{mt(!1)}return}let n=Ye.trim();Xe(``),Qe(null),await k(n,``,t)},At=(0,d.useCallback)(()=>{r.length!==0&&ie?.()},[r.length,ie]),jt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},Mt=(0,d.useCallback)(async e=>{if(_||m)return;let t=e.message||e.label||e.text||``;t.trim()&&await k(t.trim(),``)},[_,m,k]),Nt=St&&H===`entry_prompt`?{inset:0}:St&&H===`text_chat`?{left:0,right:0,bottom:0}:St&&H===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:St&&H===`connection_modal`?{left:`12px`,right:`12px`,bottom:`12px`}:H===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...Oe===`bottom-left`?{left:`1.5rem`,bottom:L}:{right:`1.5rem`,bottom:L}}:Oe===`bottom-left`?{left:`1.5rem`,bottom:L}:{right:`1.5rem`,bottom:L},Pt=(0,d.useCallback)(()=>{H!==`minimized_orb`&&(vt(!0),setTimeout(()=>{U(`minimized_orb`),vt(!1),y&&gt(!0)},280))},[y,H]),Ft=()=>U(`connection_modal`),It=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}A({notifyChatInitiated:!0}),ne?.(!0),U(`voice_mode`)},Lt=()=>{A({notifyChatInitiated:!0}),ne?.(!1),U(`text_chat`)},Rt=()=>{ne?.(!1),Pt()};return e!==`ready`||!Re||Ce.chat===!1||!Ve?null:(0,f.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...Nt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[H===`entry_prompt`&&(0,f.jsx)(ug,{copy:Ue,orbColors:Te,primaryColor:Ee,onYes:()=>{D(Ge),It()},onLater:()=>{D(Ge),Pt()},isMobile:St,isClosing:_t}),H===`minimized_orb`&&(0,f.jsxs)(om.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:Oe===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[y&&(0,f.jsxs)(`button`,{type:`button`,onClick:Et,style:{maxWidth:St?`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,f.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,f.jsxs)(`span`,{style:{minWidth:0},children:[(0,f.jsx)(`span`,{style:{display:`block`,fontSize:`12px`,fontWeight:700,color:`#111827`,lineHeight:1.2},children:b===`connected`?`Call in progress`:`Call is active`}),(0,f.jsx)(`span`,{style:{display:`block`,fontSize:`11px`,color:`#6b7280`,lineHeight:1.3,marginTop:`2px`,whiteSpace:`nowrap`},children:b===`connected`?`${jt(at)} with ${z}`:`Tap to return to ${z}`})]})]}),(0,f.jsx)(lg,{size:F,orbColors:Te,onClick:y?Et:we?Ft:Lt})]}),H===`connection_modal`&&(0,f.jsx)(dg,{copy:Ue,orbColors:Te,primaryColor:Ee,onVoice:It,onText:Lt,onClose:Pt,isMobile:St,isClosing:_t}),H===`voice_mode`&&(0,f.jsx)(fg,{orbColors:Te,onEnterChat:Lt,onEndChat:Rt,agentId:We,siteId:Ge,apiBaseUrl:Ke,chatId:T,historyRef:E,onMessageSync:O,voiceEndCounter:ye,websiteName:t?.websiteName,voiceFirstMessage:xe.voiceFirstMessage||null,captureVisitorEmail:j,emailRequired:!l,emailCaptureEnabled:P.disableEmailCapture!==!0,listeningLabel:P.voiceListeningLabel||`Listening...`,enterChatModeLabel:P.voiceEnterChatLabel||`Enter Chat Mode`,endConversationLabel:P.voiceEndConversationLabel||`End Conversation`},`voice`),H===`call_screen`&&(0,f.jsx)(uh,{incomingCall:v,activeCallId:y,callConnectionState:b,callDurationSeconds:at,isCallMuted:S,agentName:z,agentHeadshot:B,fallbackAgentName:ke,acceptCall:ae,rejectCall:oe,endWebRTCCall:se,toggleCallMute:ce,formatCallDuration:jt,onMinimize:Dt,primaryColor:Ee,orbColors:Te,chatHistory:r}),H===`text_chat`&&(0,f.jsx)(hg,{isClosing:_t,copy:Ue,orbColors:Te,primaryColor:Ee,chatBgGradient:Ae,logo:je,quickChatOptions:Fe,onQuickChatSelect:Mt,isMobile:St,chatHistory:r,isAiTyping:p,isAgentTyping:u,activeScreen:a,agentName:z,agentHeadshot:B,fallbackAgentName:ke,input:Ye,setInput:Xe,onSubmit:kt,isConversationEnded:_,isLoading:m,isRateLimited:h,rateLimitMessage:g,selectedFile:lt,onFileSelect:Tt,onRemoveSelectedFile:wt,attachmentError:dt,isUploadingAttachment:pt,requiresEmail:xt,emailInput:$e,setEmailInput:et,emailError:tt,emailCaptureSuccess:rt,replyContext:Ze,setReplyContext:Qe,webRTCError:C,micError:st,setMicError:ct,dismissCallError:le,activeCallId:y,isCallMuted:S,toggleCallMute:ce,endWebRTCCall:se,formatCallDuration:jt,callDurationSeconds:at,onCollapse:Pt,onStartVoice:It,voiceEnabled:we,onNewChat:At,onMinimize:Dt,onExpand:Et,isCallMinimized:!!y,showPoweredBy:I,privacyPolicyUrl:Le,headerBgColor:Ie,getVisitorChatHistory:fe,resumeChat:he,isSessionRestoring:ge}),(0,f.jsx)(`style`,{children:`
343
343
  /* Force any SVG (or img) inside LogoSlot to fill the container height
344
344
  regardless of whether the component forwards its style prop. */
345
345
  .fe-logo-slot svg,
@@ -358,4 +358,4 @@
358
358
  @keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }
359
359
  @keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }
360
360
  @keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }
361
- `})]})}var dg=class extends d.default.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}};exports.AnimatedOrb=rh,exports.ErrorBoundary=dg,exports.FlowEngageProvider=Sr,exports.FlowEngageWidget=ug,exports.useFlowEngage=pn;
361
+ `})]})}var _g=class extends d.default.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}};exports.AnimatedOrb=rh,exports.ErrorBoundary=_g,exports.FlowEngageProvider=xr,exports.FlowEngageWidget=gg,exports.useFlowEngage=fn;