@flowengage/react-chatbot 6.0.6 → 6.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flowengage-embed.js +167 -167
- package/dist/flowengage-react-chatbot.cjs +159 -159
- package/dist/flowengage-react-chatbot.mjs +3745 -3751
- package/package.json +1 -1
|
@@ -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||`https://be-flowengage-stage.oslabs.app`).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,ee=()=>{if(!x)return null;let e=window.localStorage.getItem(_.chatId);return e&&String(e).trim()?String(e).trim():null},te=()=>{if(x)try{window.localStorage.removeItem(_.chatId)}catch{}},ne=()=>x?typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`:`server-chat-id`,re=e=>e?`flowengage.entrySeen.${e}`:null,C=e=>{if(!x||!e)return!1;try{let t=re(e);return t?window.localStorage.getItem(t)===`1`:!1}catch{return!1}},ie=e=>{if(!(!x||!e))try{let t=re(e);t&&window.localStorage.setItem(t,`1`)}catch{}},ae=e=>e?`flowengage.persistedChatId.${e}`:null,oe=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}},se=e=>{if(!(!x||!e))try{let t=ae(e);t&&window.localStorage.removeItem(t)}catch{}},ce=(e,t)=>{if(!(!x||!e||!t))try{let n=ae(e);n&&window.localStorage.setItem(n,String(t).trim())}catch{}},le=()=>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:``},ue=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))}})},de=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||``},fe=(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)},pe=e=>e?`flowengage.visitorId.${e}`:null,me=()=>`v_${Date.now().toString(36)}_${typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,``).slice(0,16):Math.random().toString(36).slice(2,18)}`,he=e=>{if(!x||!e)return null;try{let t=pe(e),n=t?window.localStorage.getItem(t):null;return n&&String(n).trim()?String(n).trim():null}catch{return null}},ge=e=>{if(!x||!e)return null;try{let t=he(e);if(t)return t;let n=me(),r=pe(e);return r&&window.localStorage.setItem(r,n),n}catch{return me()}},_e=`flowengage.tabId`,ve=()=>{if(!x)return`default`;try{let e=window.sessionStorage.getItem(_e);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(_e,e)),e}catch{return`default`}},ye=e=>e?`flowengage.voice.transcript.${e}.${ve()}`:null,be=600*1e3,xe=(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:be,a={transcript:r,expiresAt:Date.now()+i};try{let t=ye(e);t&&window.localStorage.setItem(t,JSON.stringify(a))}catch{}},Se=e=>{if(!x||!e)return null;try{let t=ye(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}},Ce=e=>{if(!(!x||!e))try{let t=ye(e);t&&window.localStorage.removeItem(t)}catch{}},we=`flowengage.voice.pendingResume`,Te=()=>{if(x)try{window.sessionStorage.setItem(we,`1`)}catch{}},Ee=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(we)===`1`?(window.sessionStorage.removeItem(we),!0):!1}catch{return!1}},De=`flowengage.chat.pendingReopen`,Oe=()=>{if(x)try{window.sessionStorage.setItem(De,`1`)}catch{}},ke=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(De)===`1`?(window.sessionStorage.removeItem(De),!0):!1}catch{return!1}},Ae=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(we)===`1`}catch{return!1}},je=e=>e?`flowengage.voice.navState.${e}.${ve()}`:null,Me=(e,t,n)=>{if(!(!x||!e||!t))try{let r=je(e);r&&window.sessionStorage.setItem(r,JSON.stringify({previousPage:String(t),targetPath:n?new URL(String(n),window.location.href).pathname:null,ts:Date.now()}))}catch{}},w=e=>{if(!x||!e)return null;try{let t=je(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}}catch{return null}},Ne=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},Pe=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}},Fe=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),Ne(await Pe(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)}))},Ie=async({apiBaseUrl:e,siteId:t})=>{let n=typeof window<`u`?window.location.origin:`http://localhost`;return(await Ne(await Pe(`${e}/api/widget/chatbot-loader?${new URLSearchParams({siteId:t,origin:n}).toString()}`,{method:`GET`}))).data},Le=({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={})=>Ne(await Pe(`${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 Ne(await Pe(`${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 getSignedVoiceUrl(e){return a(`/api/voice/signed-url?chatId=${encodeURIComponent(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 Ne(await Pe(`${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)}}},Re=Object.create(null);Re.open=`0`,Re.close=`1`,Re.ping=`2`,Re.pong=`3`,Re.message=`4`,Re.upgrade=`5`,Re.noop=`6`;var ze=Object.create(null);Object.keys(Re).forEach(e=>{ze[Re[e]]=e});var Be={type:`error`,data:`parser error`},Ve=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,He=typeof ArrayBuffer==`function`,Ue=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,We=({type:e,data:t},n,r)=>Ve&&t instanceof Blob?n?r(t):Ge(t,r):He&&(t instanceof ArrayBuffer||Ue(t))?n?r(t):Ge(new Blob([t]),r):r(Re[e]+(t||``)),Ge=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function Ke(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var qe;function Je(e,t){if(Ve&&e.data instanceof Blob)return e.data.arrayBuffer().then(Ke).then(t);if(He&&(e.data instanceof ArrayBuffer||Ue(e.data)))return t(Ke(e.data));We(e,!1,e=>{qe||=new TextEncoder,t(qe.encode(e))})}var Ye=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,Xe=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)Xe[Ye.charCodeAt(e)]=e;var Ze=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=Xe[e.charCodeAt(r)],o=Xe[e.charCodeAt(r+1)],s=Xe[e.charCodeAt(r+2)],c=Xe[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},Qe=typeof ArrayBuffer==`function`,$e=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:tt(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:et(e.substring(1),t)}:ze[n]?e.length>1?{type:ze[n],data:e.substring(1)}:{type:ze[n]}:Be},et=(e,t)=>Qe?tt(Ze(e),t):{base64:!0,data:e},tt=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},nt=``,rt=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{We(e,!1,e=>{r[a]=e,++i===n&&t(r.join(nt))})})},it=(e,t)=>{let n=e.split(nt),r=[];for(let e=0;e<n.length;e++){let i=$e(n[e],t);if(r.push(i),i.type===`error`)break}return r};function at(){return new TransformStream({transform(e,t){Je(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 T;function E(e){return e.reduce((e,t)=>e+t.length,0)}function ot(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 st(e,t){T||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(E(n)<1)break;let e=ot(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(E(n)<2)break;let e=ot(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(E(n)<8)break;let e=ot(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Be);break}i=a*2**32+t.getUint32(4),r=3}else{if(E(n)<i)break;let e=ot(n,i);s.enqueue($e(a?e:T.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Be);break}}}})}function D(e){if(e)return ct(e)}function ct(e){for(var t in D.prototype)e[t]=D.prototype[t];return e}D.prototype.on=D.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},D.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},D.prototype.off=D.prototype.removeListener=D.prototype.removeAllListeners=D.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},D.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},D.prototype.emitReserved=D.prototype.emit,D.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},D.prototype.hasListeners=function(e){return!!this.listeners(e).length};var lt=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),ut=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),dt=`arraybuffer`;function ft(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var pt=ut.setTimeout,mt=ut.clearTimeout;function ht(e,t){t.useNativeTimers?(e.setTimeoutFn=pt.bind(ut),e.clearTimeoutFn=mt.bind(ut)):(e.setTimeoutFn=ut.setTimeout.bind(ut),e.clearTimeoutFn=ut.clearTimeout.bind(ut))}var gt=1.33;function _t(e){return typeof e==`string`?vt(e):Math.ceil((e.byteLength||e.size)*gt)}function vt(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 yt(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function bt(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function xt(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 D{constructor(e){super(),this.writable=!1,ht(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=$e(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=bt(e);return t.length?`?`+t:``}},wt=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){it(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,rt(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]=yt()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},Tt=!1;try{Tt=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Et=Tt;function Dt(){}var Ot=class extends wt{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}},kt=class e extends D{constructor(e,t,n){super(),this.createRequest=e,ht(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=ft(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(kt.requestsCount=0,kt.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,At);else if(typeof addEventListener==`function`){let e=`onpagehide`in ut?`pagehide`:`unload`;addEventListener(e,At,!1)}}function At(){for(let e in kt.requests)kt.requests.hasOwnProperty(e)&&kt.requests[e].abort()}var jt=(function(){let e=Nt({xdomain:!1});return e&&e.responseType!==null})(),Mt=class extends Ot{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=jt&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new kt(Nt,this.uri(),e)}};function Nt(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Et))return new XMLHttpRequest}catch{}if(!t)try{return new ut[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var Pt=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,Ft=class extends Ct{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Pt?{}:ft(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;We(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&<(()=>{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]=yt()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},It=ut.WebSocket||ut.MozWebSocket,Lt={websocket:class extends Ft{createSocket(e,t,n){return Pt?new It(e,t,n):t?new It(e,t):new It(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=st(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=at();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&<(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:Mt},Rt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,zt=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function Bt(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=Rt.exec(e||``),a={},o=14;for(;o--;)a[zt[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=Vt(a,a.path),a.queryKey=Ht(a,a.query),a}function Vt(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 Ht(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var Ut=typeof addEventListener==`function`&&typeof removeEventListener==`function`,Wt=[];Ut&&addEventListener(`offline`,()=>{Wt.forEach(e=>e())},!1);var Gt=class e extends D{constructor(e,t){if(super(),this.binaryType=dt,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=Bt(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=Bt(t.host).host);ht(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=xt(this.opts.query)),Ut&&(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`})},Wt.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+=_t(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,lt(()=>{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(),Ut&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=Wt.indexOf(this._offlineEventListener);e!==-1&&Wt.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};Gt.protocol=4;var Kt=class extends Gt{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;Gt.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;Gt.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}},qt=class extends Kt{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=>Lt[e]).filter(e=>!!e)),super(e,n)}};qt.protocol;function Jt(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=Bt(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 Yt=typeof ArrayBuffer==`function`,Xt=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Zt=Object.prototype.toString,Qt=typeof Blob==`function`||typeof Blob<`u`&&Zt.call(Blob)===`[object BlobConstructor]`,$t=typeof File==`function`||typeof File<`u`&&Zt.call(File)===`[object FileConstructor]`;function en(e){return Yt&&(e instanceof ArrayBuffer||Xt(e))||Qt&&e instanceof Blob||$t&&e instanceof File}function tn(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(tn(e[t]))return!0;return!1}if(en(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return tn(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&tn(e[t]))return!0;return!1}function nn(e){let t=[],n=e.data,r=e;return r.data=rn(n,t),r.attachments=t.length,{packet:r,buffers:t}}function rn(e,t){if(!e)return e;if(en(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]=rn(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]=rn(e[r],t));return n}return e}function an(e,t){return e.data=on(e.data,t),delete e.attachments,e}function on(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]=on(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=on(e[n],t));return e}var sn=s({Decoder:()=>un,Encoder:()=>ln,PacketType:()=>O,isPacketValid:()=>_n,protocol:()=>5}),cn=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],O;(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`})(O||={});var ln=class{constructor(e){this.replacer=e}encode(e){return(e.type===O.EVENT||e.type===O.ACK)&&tn(e)?this.encodeAsBinary({type:e.type===O.EVENT?O.BINARY_EVENT:O.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===O.BINARY_EVENT||e.type===O.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=nn(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},un=class e extends D{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===O.BINARY_EVENT;n||t.type===O.BINARY_ACK?(t.type=n?O.EVENT:O.ACK,this.reconstructor=new dn(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if(en(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(O[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===O.BINARY_EVENT||r.type===O.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(!pn(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 O.CONNECT:return hn(t);case O.DISCONNECT:return t===void 0;case O.CONNECT_ERROR:return typeof t==`string`||hn(t);case O.EVENT:case O.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&cn.indexOf(t[0])===-1);case O.ACK:case O.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},dn=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=an(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function fn(e){return typeof e==`string`}var pn=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function mn(e){return e===void 0||pn(e)}function hn(e){return Object.prototype.toString.call(e)===`[object Object]`}function gn(e,t){switch(e){case O.CONNECT:return t===void 0||hn(t);case O.DISCONNECT:return t===void 0;case O.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&cn.indexOf(t[0])===-1);case O.ACK:return Array.isArray(t);case O.CONNECT_ERROR:return typeof t==`string`||hn(t);default:return!1}}function _n(e){return fn(e.nsp)&&mn(e.id)&&gn(e.type,e.data)}function vn(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var yn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),bn=class extends D{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=[vn(e,`open`,this.onopen.bind(this)),vn(e,`packet`,this.onpacket.bind(this)),vn(e,`error`,this.onerror.bind(this)),vn(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(yn.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:O.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:O.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 O.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 O.EVENT:case O.BINARY_EVENT:this.onevent(e);break;case O.ACK:case O.BINARY_ACK:this.onack(e);break;case O.DISCONNECT:this.ondisconnect();break;case O.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:O.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:O.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 xn(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}xn.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},xn.prototype.reset=function(){this.attempts=0},xn.prototype.setMin=function(e){this.ms=e},xn.prototype.setMax=function(e){this.max=e},xn.prototype.setJitter=function(e){this.jitter=e};var Sn=class extends D{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,ht(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 xn({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||sn;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 qt(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=vn(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=vn(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(vn(e,`ping`,this.onping.bind(this)),vn(e,`data`,this.ondata.bind(this)),vn(e,`error`,this.onerror.bind(this)),vn(e,`close`,this.onclose.bind(this)),vn(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){lt(()=>{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 bn(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 wn(e,t){typeof e==`object`&&(t=e,e=void 0),t||={};let n=Jt(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(wn,{Manager:Sn,Socket:bn,io:wn,connect:wn});var Tn=({apiBaseUrl:e,userId:t,chatId:n,siteId:r})=>wn(e,{transports:[`polling`,`websocket`],upgrade:!0,rememberUpgrade:!1,auth:{userId:t,chatId:n,siteId:r},query:{chatId:n,siteId:r}}),En=({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),On=()=>{let e=(0,d.useContext)(Dn);if(!e)throw Error(`useFlowEngage must be used inside FlowEngageProvider`);return e};function kn(){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}function An(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)}catch{return!1}}function k(...e){kn()&&console.log(`[FlowEngage:shadowNavigate]`,...e)}var jn=`fe_pending_nav_section`,Mn=15e3,Nn=`fe_voice_nav_state`,Pn=2e4,Fn=!1,In=null;function Ln(e=3e3){Fn=!0,In&&clearTimeout(In),In=setTimeout(()=>{Fn=!1,In=null},e)}function Rn(){return Fn}var zn=!1,Bn=null;function Vn(){zn||typeof window>`u`||(zn=!0,window.addEventListener(`popstate`,async()=>{let e=window.location.href;if(k(`popstate: body-swap to`,e),Bn){try{Jn(Bn)}catch{}try{Zn(Bn)}catch{}}try{if(await fr(e,{skipPushState:!0,isBack:!0})){k(`popstate: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] popstate body-swap error:`,e)}k(`popstate: body-swap failed, falling back to reload`),window.location.reload()}))}var Hn=!1;function Un(){Hn||typeof window>`u`||typeof document>`u`||(Hn=!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(),k(`link-intercept: body-swap to`,r.href),tr();try{try{Jn()}catch{}try{Zn()}catch{}if(await fr(r.href)){k(`link-intercept: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] link-intercept body-swap error:`,e)}k(`link-intercept: body-swap failed, falling back to normal navigation`),nr(),window.location.href=r.href}},!0))}function Wn(){if(typeof window>`u`)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.__sveltekit_data||document.querySelector(`[data-sveltekit-hydrate]`))return`sveltekit`;if(document.querySelector(`[data-astro-transition]`))return`astro`;let e=Array.from(document.body.children).filter(e=>{let t=e.tagName?.toUpperCase();return!(t===`SCRIPT`||t===`NOSCRIPT`||t===`LINK`||t===`STYLE`||e.id===`flowengage-root`)});return e.length===1&&e[0].id&&(e[0].querySelector(`[data-reactroot]`)||e[0]._reactRootContainer||e[0].__vue_app__)?`generic-spa`:null}var Gn=`data-fe-swap-css`;function Kn(){typeof document>`u`||document.querySelectorAll(`[${Gn}]`).forEach(e=>e.remove())}var qn=`fe_form_state:`;function Jn(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=qn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({state:n,ts:Date.now()}))}catch{}}function Yn(){if(typeof document>`u`||typeof sessionStorage>`u`)return;let e=qn+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 Xn=`fe_scroll:`;function Zn(e){if(!(typeof window>`u`||typeof sessionStorage>`u`))try{let t=Xn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({y:window.scrollY,ts:Date.now()}))}catch{}}function Qn(){if(typeof window>`u`||typeof sessionStorage>`u`)return;let e=Xn+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 $n(e){if(!(typeof window>`u`))try{window.dispatchEvent(new CustomEvent(`flowengage:pageswap`,{detail:{url:e,timestamp:Date.now()}}))}catch{}}var er=`fe-nav-loader`;function tr(){if(typeof document>`u`||document.getElementById(er))return;let e=document.createElement(`div`);e.id=er,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 nr(){if(typeof document>`u`)return;let e=document.getElementById(er);e&&(e.style.width=`100%`,setTimeout(()=>{e.style.opacity=`0`,e.style.transition=`opacity 0.3s ease`,setTimeout(()=>e.remove(),350)},200))}function rr(){if(typeof window>`u`||typeof document>`u`)return;try{window.history.state?.flowengageSpa&&Vn()}catch{}let e;try{e=JSON.parse(sessionStorage.getItem(jn)||`null`)}catch{return}if(!e)return;try{sessionStorage.removeItem(jn)}catch{}let{sectionText:t,ts:n}=e;if(!t)return;if(Date.now()-n>Mn){k(`initNavigationHighlight: pending section expired, skipping:`,t);return}k(`initNavigationHighlight: replaying section highlight:`,t);let r=0,i=()=>{r+=1;let e=ar(null,t);if(e){or(e),k(`initNavigationHighlight: highlighted on attempt`,r);return}r<8?setTimeout(i,300):k(`initNavigationHighlight: could not find element after 8 attempts:`,t)};setTimeout(i,250)}var ir=()=>{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||`https://be-flowengage-stage.oslabs.app`).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,ee=()=>{if(!x)return null;let e=window.localStorage.getItem(_.chatId);return e&&String(e).trim()?String(e).trim():null},te=()=>{if(x)try{window.localStorage.removeItem(_.chatId)}catch{}},ne=()=>x?typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():`${Date.now()}-${Math.random().toString(16).slice(2)}`:`server-chat-id`,re=e=>e?`flowengage.entrySeen.${e}`:null,C=e=>{if(!x||!e)return!1;try{let t=re(e);return t?window.localStorage.getItem(t)===`1`:!1}catch{return!1}},ie=e=>{if(!(!x||!e))try{let t=re(e);t&&window.localStorage.setItem(t,`1`)}catch{}},ae=e=>e?`flowengage.persistedChatId.${e}`:null,oe=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}},se=e=>{if(!(!x||!e))try{let t=ae(e);t&&window.localStorage.removeItem(t)}catch{}},ce=(e,t)=>{if(!(!x||!e||!t))try{let n=ae(e);n&&window.localStorage.setItem(n,String(t).trim())}catch{}},le=()=>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:``},ue=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))}})},de=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||``},fe=(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)},pe=e=>e?`flowengage.visitorId.${e}`:null,me=()=>`v_${Date.now().toString(36)}_${typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID().replace(/-/g,``).slice(0,16):Math.random().toString(36).slice(2,18)}`,he=e=>{if(!x||!e)return null;try{let t=pe(e),n=t?window.localStorage.getItem(t):null;return n&&String(n).trim()?String(n).trim():null}catch{return null}},ge=e=>{if(!x||!e)return null;try{let t=he(e);if(t)return t;let n=me(),r=pe(e);return r&&window.localStorage.setItem(r,n),n}catch{return me()}},_e=`flowengage.tabId`,ve=()=>{if(!x)return`default`;try{let e=window.sessionStorage.getItem(_e);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(_e,e)),e}catch{return`default`}},ye=e=>e?`flowengage.voice.transcript.${e}.${ve()}`:null,be=600*1e3,xe=(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:be,a={transcript:r,expiresAt:Date.now()+i};try{let t=ye(e);t&&window.localStorage.setItem(t,JSON.stringify(a))}catch{}},Se=e=>{if(!x||!e)return null;try{let t=ye(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}},Ce=e=>{if(!(!x||!e))try{let t=ye(e);t&&window.localStorage.removeItem(t)}catch{}},we=`flowengage.voice.pendingResume`,Te=()=>{if(x)try{window.sessionStorage.setItem(we,`1`)}catch{}},Ee=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(we)===`1`?(window.sessionStorage.removeItem(we),!0):!1}catch{return!1}},De=`flowengage.chat.pendingReopen`,Oe=()=>{if(x)try{window.sessionStorage.setItem(De,`1`)}catch{}},ke=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(De)===`1`?(window.sessionStorage.removeItem(De),!0):!1}catch{return!1}},Ae=()=>{if(!x)return!1;try{return window.sessionStorage.getItem(we)===`1`}catch{return!1}},je=e=>e?`flowengage.voice.navState.${e}.${ve()}`:null,Me=(e,t,n)=>{if(!(!x||!e||!t))try{let r=je(e);r&&window.sessionStorage.setItem(r,JSON.stringify({previousPage:String(t),targetPath:n?new URL(String(n),window.location.href).pathname:null,ts:Date.now()}))}catch{}},Ne=e=>{if(!x||!e)return null;try{let t=je(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}}catch{return null}},Pe=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},Fe=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}},Ie=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),Pe(await Fe(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)}))},Le=async({apiBaseUrl:e,siteId:t})=>{let n=typeof window<`u`?window.location.origin:`http://localhost`;return(await Pe(await Fe(`${e}/api/widget/chatbot-loader?${new URLSearchParams({siteId:t,origin:n}).toString()}`,{method:`GET`}))).data},Re=({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={})=>Pe(await Fe(`${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 Pe(await Fe(`${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 getSignedVoiceUrl(e){return a(`/api/voice/signed-url?chatId=${encodeURIComponent(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 Pe(await Fe(`${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)}}},ze=Object.create(null);ze.open=`0`,ze.close=`1`,ze.ping=`2`,ze.pong=`3`,ze.message=`4`,ze.upgrade=`5`,ze.noop=`6`;var Be=Object.create(null);Object.keys(ze).forEach(e=>{Be[ze[e]]=e});var Ve={type:`error`,data:`parser error`},He=typeof Blob==`function`||typeof Blob<`u`&&Object.prototype.toString.call(Blob)===`[object BlobConstructor]`,Ue=typeof ArrayBuffer==`function`,We=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,Ge=({type:e,data:t},n,r)=>He&&t instanceof Blob?n?r(t):Ke(t,r):Ue&&(t instanceof ArrayBuffer||We(t))?n?r(t):Ke(new Blob([t]),r):r(ze[e]+(t||``)),Ke=(e,t)=>{let n=new FileReader;return n.onload=function(){let e=n.result.split(`,`)[1];t(`b`+(e||``))},n.readAsDataURL(e)};function qe(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}var Je;function Ye(e,t){if(He&&e.data instanceof Blob)return e.data.arrayBuffer().then(qe).then(t);if(Ue&&(e.data instanceof ArrayBuffer||We(e.data)))return t(qe(e.data));Ge(e,!1,e=>{Je||=new TextEncoder,t(Je.encode(e))})}var Xe=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`,w=typeof Uint8Array>`u`?[]:new Uint8Array(256);for(let e=0;e<64;e++)w[Xe.charCodeAt(e)]=e;var Ze=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=w[e.charCodeAt(r)],o=w[e.charCodeAt(r+1)],s=w[e.charCodeAt(r+2)],c=w[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},Qe=typeof ArrayBuffer==`function`,$e=(e,t)=>{if(typeof e!=`string`)return{type:`message`,data:tt(e,t)};let n=e.charAt(0);return n===`b`?{type:`message`,data:et(e.substring(1),t)}:Be[n]?e.length>1?{type:Be[n],data:e.substring(1)}:{type:Be[n]}:Ve},et=(e,t)=>Qe?tt(Ze(e),t):{base64:!0,data:e},tt=(e,t)=>{switch(t){case`blob`:return e instanceof Blob?e:new Blob([e]);default:return e instanceof ArrayBuffer?e:e.buffer}},nt=``,rt=(e,t)=>{let n=e.length,r=Array(n),i=0;e.forEach((e,a)=>{Ge(e,!1,e=>{r[a]=e,++i===n&&t(r.join(nt))})})},T=(e,t)=>{let n=e.split(nt),r=[];for(let e=0;e<n.length;e++){let i=$e(n[e],t);if(r.push(i),i.type===`error`)break}return r};function E(){return new TransformStream({transform(e,t){Ye(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 D;function it(e){return e.reduce((e,t)=>e+t.length,0)}function at(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 ot(e,t){D||=new TextDecoder;let n=[],r=0,i=-1,a=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(r===0){if(it(n)<1)break;let e=at(n,1);a=(e[0]&128)==128,i=e[0]&127,r=i<126?3:i===126?1:2}else if(r===1){if(it(n)<2)break;let e=at(n,2);i=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),r=3}else if(r===2){if(it(n)<8)break;let e=at(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),a=t.getUint32(0);if(a>2**21-1){s.enqueue(Ve);break}i=a*2**32+t.getUint32(4),r=3}else{if(it(n)<i)break;let e=at(n,i);s.enqueue($e(a?e:D.decode(e),t)),r=0}if(i===0||i>e){s.enqueue(Ve);break}}}})}function O(e){if(e)return st(e)}function st(e){for(var t in O.prototype)e[t]=O.prototype[t];return e}O.prototype.on=O.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks[`$`+e]=this._callbacks[`$`+e]||[]).push(t),this},O.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},O.prototype.off=O.prototype.removeListener=O.prototype.removeAllListeners=O.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},O.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},O.prototype.emitReserved=O.prototype.emit,O.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks[`$`+e]||[]},O.prototype.hasListeners=function(e){return!!this.listeners(e).length};var ct=typeof Promise==`function`&&typeof Promise.resolve==`function`?e=>Promise.resolve().then(e):(e,t)=>t(e,0),lt=typeof self<`u`?self:typeof window<`u`?window:Function(`return this`)(),ut=`arraybuffer`;function dt(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}var ft=lt.setTimeout,pt=lt.clearTimeout;function mt(e,t){t.useNativeTimers?(e.setTimeoutFn=ft.bind(lt),e.clearTimeoutFn=pt.bind(lt)):(e.setTimeoutFn=lt.setTimeout.bind(lt),e.clearTimeoutFn=lt.clearTimeout.bind(lt))}var ht=1.33;function gt(e){return typeof e==`string`?_t(e):Math.ceil((e.byteLength||e.size)*ht)}function _t(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 vt(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function yt(e){let t=``;for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+=`&`),t+=encodeURIComponent(n)+`=`+encodeURIComponent(e[n]));return t}function bt(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 xt=class extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type=`TransportError`}},St=class extends O{constructor(e){super(),this.writable=!1,mt(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 xt(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=$e(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=yt(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){T(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,rt(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]=vt()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}},wt=!1;try{wt=typeof XMLHttpRequest<`u`&&`withCredentials`in new XMLHttpRequest}catch{}var Tt=wt;function Et(){}var Dt=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}},Ot=class e extends O{constructor(e,t,n){super(),this.createRequest=e,mt(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=dt(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=Et,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(Ot.requestsCount=0,Ot.requests={},typeof document<`u`){if(typeof attachEvent==`function`)attachEvent(`onunload`,kt);else if(typeof addEventListener==`function`){let e=`onpagehide`in lt?`pagehide`:`unload`;addEventListener(e,kt,!1)}}function kt(){for(let e in Ot.requests)Ot.requests.hasOwnProperty(e)&&Ot.requests[e].abort()}var At=(function(){let e=Mt({xdomain:!1});return e&&e.responseType!==null})(),jt=class extends Dt{constructor(e){super(e);let t=e&&e.forceBase64;this.supportsBinary=At&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new Ot(Mt,this.uri(),e)}};function Mt(e){let t=e.xdomain;try{if(typeof XMLHttpRequest<`u`&&(!t||Tt))return new XMLHttpRequest}catch{}if(!t)try{return new lt[[`Active`,`Object`].join(`X`)](`Microsoft.XMLHTTP`)}catch{}}var Nt=typeof navigator<`u`&&typeof navigator.product==`string`&&navigator.product.toLowerCase()===`reactnative`,Pt=class extends St{get name(){return`websocket`}doOpen(){let e=this.uri(),t=this.opts.protocols,n=Nt?{}:dt(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;Ge(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch{}r&&ct(()=>{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]=vt()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}},Ft=lt.WebSocket||lt.MozWebSocket,It={websocket:class extends Pt{createSocket(e,t,n){return Nt?new Ft(e,t,n):t?new Ft(e,t):new Ft(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=ot(2**53-1,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),r=E();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&&ct(()=>{this.writable=!0,this.emitReserved(`drain`)},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)==null||e.close()}},polling:jt},Lt=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Rt=[`source`,`protocol`,`authority`,`userInfo`,`user`,`password`,`host`,`port`,`relative`,`path`,`directory`,`file`,`query`,`anchor`];function zt(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=Lt.exec(e||``),a={},o=14;for(;o--;)a[Rt[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=Bt(a,a.path),a.queryKey=Vt(a,a.query),a}function Bt(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 Vt(e,t){let n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,r){t&&(n[t]=r)}),n}var Ht=typeof addEventListener==`function`&&typeof removeEventListener==`function`,Ut=[];Ht&&addEventListener(`offline`,()=>{Ut.forEach(e=>e())},!1);var Wt=class e extends O{constructor(e,t){if(super(),this.binaryType=ut,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=zt(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=zt(t.host).host);mt(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=bt(this.opts.query)),Ht&&(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`})},Ut.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+=gt(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,ct(()=>{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(),Ht&&(this._beforeunloadEventListener&&removeEventListener(`beforeunload`,this._beforeunloadEventListener,!1),this._offlineEventListener)){let e=Ut.indexOf(this._offlineEventListener);e!==-1&&Ut.splice(e,1)}this.readyState=`closed`,this.id=null,this.emitReserved(`close`,e,t),this.writeBuffer=[],this._prevBufferLen=0}}};Wt.protocol=4;var Gt=class extends Wt{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;Wt.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;Wt.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}},Kt=class extends Gt{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=>It[e]).filter(e=>!!e)),super(e,n)}};Kt.protocol;function qt(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=zt(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 Jt=typeof ArrayBuffer==`function`,Yt=e=>typeof ArrayBuffer.isView==`function`?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer,Xt=Object.prototype.toString,Zt=typeof Blob==`function`||typeof Blob<`u`&&Xt.call(Blob)===`[object BlobConstructor]`,Qt=typeof File==`function`||typeof File<`u`&&Xt.call(File)===`[object FileConstructor]`;function $t(e){return Jt&&(e instanceof ArrayBuffer||Yt(e))||Zt&&e instanceof Blob||Qt&&e instanceof File}function en(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(en(e[t]))return!0;return!1}if($t(e))return!0;if(e.toJSON&&typeof e.toJSON==`function`&&arguments.length===1)return en(e.toJSON(),!0);for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&en(e[t]))return!0;return!1}function tn(e){let t=[],n=e.data,r=e;return r.data=nn(n,t),r.attachments=t.length,{packet:r,buffers:t}}function nn(e,t){if(!e)return e;if($t(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]=nn(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]=nn(e[r],t));return n}return e}function rn(e,t){return e.data=an(e.data,t),delete e.attachments,e}function an(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]=an(e[n],t);else if(typeof e==`object`)for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=an(e[n],t));return e}var on=s({Decoder:()=>ln,Encoder:()=>cn,PacketType:()=>k,isPacketValid:()=>gn,protocol:()=>5}),sn=[`connect`,`connect_error`,`disconnect`,`disconnecting`,`newListener`,`removeListener`],k;(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`})(k||={});var cn=class{constructor(e){this.replacer=e}encode(e){return(e.type===k.EVENT||e.type===k.ACK)&&en(e)?this.encodeAsBinary({type:e.type===k.EVENT?k.BINARY_EVENT:k.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id}):[this.encodeAsString(e)]}encodeAsString(e){let t=``+e.type;return(e.type===k.BINARY_EVENT||e.type===k.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=tn(e),n=this.encodeAsString(t.packet),r=t.buffers;return r.unshift(n),r}},ln=class e extends O{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===k.BINARY_EVENT;n||t.type===k.BINARY_ACK?(t.type=n?k.EVENT:k.ACK,this.reconstructor=new un(t),t.attachments===0&&super.emitReserved(`decoded`,t)):super.emitReserved(`decoded`,t)}else if($t(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(k[r.type]===void 0)throw Error(`unknown packet type `+r.type);if(r.type===k.BINARY_EVENT||r.type===k.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(!fn(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 k.CONNECT:return mn(t);case k.DISCONNECT:return t===void 0;case k.CONNECT_ERROR:return typeof t==`string`||mn(t);case k.EVENT:case k.BINARY_EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&sn.indexOf(t[0])===-1);case k.ACK:case k.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&=(this.reconstructor.finishedReconstruction(),null)}},un=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=rn(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}};function dn(e){return typeof e==`string`}var fn=Number.isInteger||function(e){return typeof e==`number`&&isFinite(e)&&Math.floor(e)===e};function pn(e){return e===void 0||fn(e)}function mn(e){return Object.prototype.toString.call(e)===`[object Object]`}function hn(e,t){switch(e){case k.CONNECT:return t===void 0||mn(t);case k.DISCONNECT:return t===void 0;case k.EVENT:return Array.isArray(t)&&(typeof t[0]==`number`||typeof t[0]==`string`&&sn.indexOf(t[0])===-1);case k.ACK:return Array.isArray(t);case k.CONNECT_ERROR:return typeof t==`string`||mn(t);default:return!1}}function gn(e){return dn(e.nsp)&&pn(e.id)&&hn(e.type,e.data)}function _n(e,t,n){return e.on(t,n),function(){e.off(t,n)}}var vn=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1}),yn=class extends O{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=[_n(e,`open`,this.onopen.bind(this)),_n(e,`packet`,this.onpacket.bind(this)),_n(e,`error`,this.onerror.bind(this)),_n(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(vn.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:k.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:k.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 k.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 k.EVENT:case k.BINARY_EVENT:this.onevent(e);break;case k.ACK:case k.BINARY_ACK:this.onack(e);break;case k.DISCONNECT:this.ondisconnect();break;case k.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:k.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:k.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 bn(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}bn.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},bn.prototype.reset=function(){this.attempts=0},bn.prototype.setMin=function(e){this.ms=e},bn.prototype.setMax=function(e){this.max=e},bn.prototype.setJitter=function(e){this.jitter=e};var xn=class extends O{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,mt(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 bn({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||on;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 Kt(this.uri,this.opts);let t=this.engine,n=this;this._readyState=`opening`,this.skipReconnect=!1;let r=_n(t,`open`,function(){n.onopen(),e&&e()}),i=t=>{this.cleanup(),this._readyState=`closed`,this.emitReserved(`error`,t),e?e(t):this.maybeReconnectOnOpen()},a=_n(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(_n(e,`ping`,this.onping.bind(this)),_n(e,`data`,this.ondata.bind(this)),_n(e,`error`,this.onerror.bind(this)),_n(e,`close`,this.onclose.bind(this)),_n(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){ct(()=>{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 yn(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=qt(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 xn(r,t):(Sn[i]||(Sn[i]=new xn(r,t)),c=Sn[i]),n.query&&!t.query&&(t.query=n.queryKey),c.socket(n.path,t)}Object.assign(Cn,{Manager:xn,Socket:yn,io:Cn,connect:Cn});var wn=({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}}),Tn=({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)}}},En=(0,d.createContext)(null),Dn=()=>{let e=(0,d.useContext)(En);if(!e)throw Error(`useFlowEngage must be used inside FlowEngageProvider`);return e};function On(){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}function kn(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)}catch{return!1}}function A(...e){On()&&console.log(`[FlowEngage:shadowNavigate]`,...e)}var An=`fe_pending_nav_section`,jn=15e3,Mn=`fe_voice_nav_state`,Nn=2e4,Pn=!1,Fn=null;function In(e=3e3){Pn=!0,Fn&&clearTimeout(Fn),Fn=setTimeout(()=>{Pn=!1,Fn=null},e)}function Ln(){return Pn}var Rn=!1,zn=null;function Bn(){Rn||typeof window>`u`||(Rn=!0,window.addEventListener(`popstate`,async()=>{let e=window.location.href;if(A(`popstate: body-swap to`,e),zn){try{qn(zn)}catch{}try{Xn(zn)}catch{}}try{if(await dr(e,{skipPushState:!0,isBack:!0})){A(`popstate: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] popstate body-swap error:`,e)}A(`popstate: body-swap failed, falling back to reload`),window.location.reload()}))}var Vn=!1;function Hn(){Vn||typeof window>`u`||typeof document>`u`||(Vn=!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(),A(`link-intercept: body-swap to`,r.href),er();try{try{qn()}catch{}try{Xn()}catch{}if(await dr(r.href)){A(`link-intercept: body-swap succeeded`);return}}catch(e){console.warn(`[FlowEngage] link-intercept body-swap error:`,e)}A(`link-intercept: body-swap failed, falling back to normal navigation`),tr(),window.location.href=r.href}},!0))}function Un(){if(typeof window>`u`)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.__sveltekit_data||document.querySelector(`[data-sveltekit-hydrate]`))return`sveltekit`;if(document.querySelector(`[data-astro-transition]`))return`astro`;let e=Array.from(document.body.children).filter(e=>{let t=e.tagName?.toUpperCase();return!(t===`SCRIPT`||t===`NOSCRIPT`||t===`LINK`||t===`STYLE`||e.id===`flowengage-root`)});return e.length===1&&e[0].id&&(e[0].querySelector(`[data-reactroot]`)||e[0]._reactRootContainer||e[0].__vue_app__)?`generic-spa`:null}var Wn=`data-fe-swap-css`;function Gn(){typeof document>`u`||document.querySelectorAll(`[${Wn}]`).forEach(e=>e.remove())}var Kn=`fe_form_state:`;function qn(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=Kn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({state:n,ts:Date.now()}))}catch{}}function Jn(){if(typeof document>`u`||typeof sessionStorage>`u`)return;let e=Kn+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 Yn=`fe_scroll:`;function Xn(e){if(!(typeof window>`u`||typeof sessionStorage>`u`))try{let t=Yn+(e||window.location.pathname);sessionStorage.setItem(t,JSON.stringify({y:window.scrollY,ts:Date.now()}))}catch{}}function Zn(){if(typeof window>`u`||typeof sessionStorage>`u`)return;let e=Yn+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 Qn(e){if(!(typeof window>`u`))try{window.dispatchEvent(new CustomEvent(`flowengage:pageswap`,{detail:{url:e,timestamp:Date.now()}}))}catch{}}var $n=`fe-nav-loader`;function er(){if(typeof document>`u`||document.getElementById($n))return;let e=document.createElement(`div`);e.id=$n,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 tr(){if(typeof document>`u`)return;let e=document.getElementById($n);e&&(e.style.width=`100%`,setTimeout(()=>{e.style.opacity=`0`,e.style.transition=`opacity 0.3s ease`,setTimeout(()=>e.remove(),350)},200))}function nr(){if(typeof window>`u`||typeof document>`u`)return;try{window.history.state?.flowengageSpa&&Bn()}catch{}let e;try{e=JSON.parse(sessionStorage.getItem(An)||`null`)}catch{return}if(!e)return;try{sessionStorage.removeItem(An)}catch{}let{sectionText:t,ts:n}=e;if(!t)return;if(Date.now()-n>jn){A(`initNavigationHighlight: pending section expired, skipping:`,t);return}A(`initNavigationHighlight: replaying section highlight:`,t);let r=0,i=()=>{r+=1;let e=ir(null,t);if(e){ar(e),A(`initNavigationHighlight: highlighted on attempt`,r);return}r<8?setTimeout(i,300):A(`initNavigationHighlight: could not find element after 8 attempts:`,t)};setTimeout(i,250)}var rr=()=>{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,7 +22,7 @@
|
|
|
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 ar(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(An(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(e.textContent.replace(/\s+/g,` `).toLowerCase().trim()===n)return e;for(let e of i){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();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=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();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=n.textContent.replace(/\s+/g,` `).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=>!An(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(An(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(An(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(An(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=>!An(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(An(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function or(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;ir();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 sr(){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`))}function cr(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 lr(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 ur(e,{siteId:t,apiBaseUrl:n}){if(!e)return!1;if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),lr(e);let r=String(n).replace(/\/$/,``),i=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let t=await(await fetch(`${r}/api/widget/navigate-allowed?${i.toString()}`)).json().catch(()=>({}));return t.success&&t.allowed?!0:lr(e)}catch(t){return console.warn(`[FlowEngage] navigate-allowed check failed:`,t?.message),lr(e)}}function dr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(jn,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function fr(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}tr();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 nr(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return nr(),!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()}),Kn();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(Gn,`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(Gn,`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,k(`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){k(`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,k(`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){k(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){k(`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;k(`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)){k(`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:`)&&(k(`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`)||``}),k(`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),k(`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(Vn(),Un(),n){try{Yn()}catch{}try{Qn()}catch{}}else window.scrollTo(0,0);nr(),$n(e);try{sessionStorage.removeItem(jn)}catch{}try{sessionStorage.removeItem(Nn)}catch{}try{Bn=new URL(e,window.location.origin).pathname}catch{}return k(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),nr(),!1}}function pr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Nn,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function mr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(Nn)}catch{}}function hr(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(Nn)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(Nn)}catch{}return e.voiceWasActive?Date.now()-e.ts>Pn?(k(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(k(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}async function gr(e,t={}){if(typeof window>`u`)return!1;let{sectionText:n,voiceActive:r=!1}=t;try{let t=cr(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`}),!0}if(i.pathname===window.location.pathname&&i.search===window.location.search&&!i.hash)return!1;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(!0)};o.events?.on(`routeChangeComplete`,t),o.push(a),setTimeout(t,5e3)});if(window.__NEXT_ROUTER__?.push)return window.__NEXT_ROUTER__.push(a),!0;if(Wn()){n&&dr(n);try{window.history.pushState({},``,i.href),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return!0}return n&&dr(n),r||Oe(),window.location.assign(i.href),!0}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&dr(n);try{window.location.href=cr(e)}catch{window.location.href=e}return!0}}var _r=!1,vr=null;function yr(e){vr=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!_r&&(_r=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!vr)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)){k(`voice-link-hook: saving state before navigation →`,r.href);try{vr.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(vr&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){k(`voice-form-hook: saving state before form submit`);try{vr.onBeforeNavigate()}catch{}}},!0)))}function br(){vr=null,k(`voice-nav-hooks: deactivated`)}var xr=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(),Sr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:xr(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function Cr(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 wr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,Tr=(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}:{}}},Er=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},Dr=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Or({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)([]),[re,C]=(0,d.useState)(le().isOpen),[ie,ae]=(0,d.useState)(le().activeScreen),[pe,me]=(0,d.useState)(le().isHumanHandled),[he,_e]=(0,d.useState)(le().agentName),[ve,ye]=(0,d.useState)(le().agentHeadshot),[be,xe]=(0,d.useState)(()=>de(i?.siteId)),[Se,Ce]=(0,d.useState)(!1),[we,Ee]=(0,d.useState)(!1),[De,Oe]=(0,d.useState)(`idle`),[ke,Ae]=(0,d.useState)(!1),[je,Me]=(0,d.useState)(!1),[w,Ne]=(0,d.useState)(``),[Pe,Re]=(0,d.useState)(!1),[ze,Be]=(0,d.useState)(0),[Ve,He]=(0,d.useState)(0),[Ue,We]=(0,d.useState)(!1),[Ge,Ke]=(0,d.useState)(null),[qe,Je]=(0,d.useState)(null),[Ye,Xe]=(0,d.useState)(`idle`),[Ze,Qe]=(0,d.useState)(null),[$e,et]=(0,d.useState)(!1),[tt,nt]=(0,d.useState)(``),[rt,it]=(0,d.useState)(!1),at=(0,d.useRef)(null),T=(0,d.useRef)(null),E=(0,d.useRef)(``),ot=(0,d.useRef)(!1),st=(0,d.useRef)(null),D=(0,d.useRef)(null),ct=(0,d.useRef)(null),lt=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)(null),ft=(0,d.useRef)([]),pt=(0,d.useRef)(null),mt=(0,d.useRef)(null),ht=(0,d.useRef)(null),gt=(0,d.useRef)(!1),_t=(0,d.useRef)(!1),vt=(0,d.useRef)(``),yt=(0,d.useRef)(null),bt=(0,d.useRef)(null),xt=(0,d.useRef)([]),St=(0,d.useRef)(0),Ct=(0,d.useRef)(he),wt=(0,d.useRef)([]),Tt=(0,d.useRef)(!1),Et=(0,d.useRef)(!1),Dt=(0,d.useRef)(i),Ot=(0,d.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),kt=(0,d.useCallback)((e={})=>{let t=!!e.is_human_handled;return me(t),t?(ae(`agent`),e.agent_info?.name&&_e(e.agent_info.name),e.agent_info?.headshot&&ye(e.agent_info.headshot),t):(ae(`ai`),t)},[]),At=(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)(()=>{D.current=Ge},[Ge]),(0,d.useEffect)(()=>{Ct.current=he},[he]),(0,d.useEffect)(()=>{Et.current=Pe},[Pe]),(0,d.useEffect)(()=>{Dt.current=i},[i]);let jt=()=>{nt(``)},Mt=(0,d.useCallback)(()=>{ht.current&&=(window.clearTimeout(ht.current),null)},[]),Nt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return xe(t),fe(t,i?.siteId),t};(0,d.useEffect)(()=>{let e=i?.siteId;e&&xe(de(e))},[i?.siteId]);let Pt=(e=`unspecified`)=>{let t=pt.current||dt.current?.callId,n=St.current,r=yt.current;if(yt.current=null,St.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=xt.current;if(xt.current=[],e.length>0&&t&&T.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;T.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,xt.current=[]}}else if(r&&r.state===`inactive`){let e=xt.current;if(xt.current=[],e.length>0&&t&&T.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;T.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else xt.current=[];if(bt.current){try{bt.current.close()}catch{}bt.current=null}ct.current&&=(ct.current.close(),null),lt.current&&=(lt.current.getTracks().forEach(e=>e.stop()),null),ut.current&&=(ut.current.srcObject=null,ut.current.remove(),null),Mt(),dt.current=null,ft.current=[],pt.current=null,mt.current=null,gt.current=!1,et(!1),Ke(null),Je(null),Xe(`idle`),Qe(null)},Ft=(e=new Date().toISOString())=>{let t=at.current,n=pt.current||dt.current?.callId;if(!(!t?.connected||!n||gt.current)){gt.current=!0,t.emit(`call:connected`,{callId:n,chatId:E.current,connectedAt:e});try{let e=lt.current,t=ut.current?.srcObject;if(e&&t&&!yt.current){xt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);bt.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&&xt.current.push(e.data)},yt.current=a,St.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{}}},It=(e={})=>{if(!e.callId)return;let t=mt.current===e.callId,n=pt.current===e.callId,r=D.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Mt(),Ke(null),t||n){pt.current=e.callId,Je(e.callId),Xe(e=>e===`connected`?e:`connecting`),C(!0);return}Xe(`idle`)}},Lt=(e={})=>{if(!e.callId)return;let t=mt.current===e.callId,n=pt.current===e.callId,r=D.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(Mt(),n){Pt();return}mt.current=null,dt.current=null,ft.current=[],Ke(null),Xe(`idle`)}},Rt=async(e={})=>{let t=ct.current,n=at.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:E.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),dt.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),ft.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:E.current,queuedCount:ft.current.length});for(let e of ft.current)await t.addIceCandidate(new RTCIceCandidate(e));ft.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:E.current})};(0,d.useEffect)(()=>{ue({isOpen:re,activeScreen:ie,isHumanHandled:pe,agentName:he,agentHeadshot:ve})},[re,ie,pe,he,ve]),(0,d.useEffect)(()=>{let e=!0;return(async()=>{it(!0);try{let t=p(i),n=await Ie(t);if(!e)return;let a=t.siteId,o=oe(a),s=ge(a),l=``;try{let e=ot.current,r=st.current;if(ot.current=!1,st.current=null,l=(await Fe({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||ee(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);te(),ce(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||ne(),ce(a,l)}E.current=l;let u=Le({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});T.current=u,h({...n,apiBaseUrl:t.apiBaseUrl}),_(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,f=Tn({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});at.current=f,f.on(`connect`,()=>{Oe(`connected`)}),f.on(`disconnect`,()=>{Oe(`disconnected`)}),f.on(`aiTyping`,()=>{Ee(!0)}),f.on(`ai:typing`,()=>{Ee(!0)}),f.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:xr(t.message)};Ee(!1),Ce(!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:xr(t.message)};Ee(!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`)&&Ce(!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)&&(me(!0),ae(`agent`),_e(Er([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&ye(n.sender_headshot),C(!0),Be(e=>e+1)))});let m=(e={})=>{let t=Er([e.agent?.name,e.agentName,e.agent_name,Ct.current],d);me(!0),ae(`agent`),_e(t),ye(e.agent?.headshot||null),C(!0),Be(e=>e+1),S(e=>Dr(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},g=(e={})=>{let t=Er([e.agent?.name,e.agentName,e.agent_name,Ct.current],d);me(!1),ae(`ai`),S(e=>Dr(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=>{We(!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=Sr(e.chat_history||[]);S(t),t.length===0&&(We(!1),me(!1),ae(`ai`),Ee(!1),Ce(!1))}),f.on(`conversation:reset`,()=>{S([]),We(!1),me(!1),ae(`ai`),Ee(!1),Ce(!1)}),f.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending ElevenLabs session`),He(e=>e+1),C(!0),Be(e=>e+1)}),f.on(`typing:start`,e=>{e.sender===`agent`&&Ce(!0)}),f.on(`typing:stop`,e=>{e.sender===`agent`&&Ce(!1)}),f.on(`call:incoming`,(e={})=>{let t=Er([e.agentName,e.ownerName,e.agent?.name,Ct.current],`Agent`);jt(),Mt(),gt.current=!1,Ke({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),_e(e=>Er([t,e],`Agent`)),Xe(`incoming`),Qe(null),C(!0)}),f.on(`call:offer`,async(e={})=>{dt.current=e;try{await Rt(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=Tr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!ct.current||!ct.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||E.current,queueSize:ft.current.length+1}),ft.current.push(t);return}await ct.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),f.on(`call:ended`,()=>{jt(),Pt(`socket:call_ended`)}),f.on(`call:accepted`,(e={})=>{It(e)}),f.on(`call:accepted_by_other`,(e={})=>{It(e)}),f.on(`call:rejected`,(e={})=>{Lt(e)}),f.on(`call:missed`,(e={})=>{Lt(e)}),f.on(`call:failed`,(e={})=>{Lt(e)}),f.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=mt.current===e.callId,n=pt.current===e.callId,r=dt.current?.callId===e.callId,i=D.current?.callId===e.callId;if(!t&&!n&&!r){i&&(Ke(null),Xe(`idle`));return}gt.current=!0,mt.current=null,pt.current=e.callId,Je(e.callId),Ke(null),Xe(`connected`),Qe(e.connectedAt||new Date().toISOString()),C(!0)}),f.on(`call:unavailable`,(e={})=>{Pt(`socket:call_unavailable`),nt(wr(e,`This visitor is not available for a call right now.`)),C(!0)}),f.on(`call:error`,(e={})=>{Pt(`socket:call_error`),nt(wr(e,`We couldn't connect the call right now.`)),C(!0)}),f.on(`visitor:navigate`,async({url:e,section:n,highlight:r}={})=>{e&&await ur(e,{siteId:t.siteId,apiBaseUrl:t.apiBaseUrl})&&gr(e,{voiceActive:Et.current}).then(e=>{let t=n||r;t&&setTimeout(()=>{let e=ar(null,t);e&&or(e)},e?300:150)})}),f.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=ar(e||null,t||null);n&&or(n)}),f.on(`visitor:clear_highlight`,()=>{sr()}),Ot.current=En({socket:f,chatId:l});let v=await u.loadHistory(l,r);if(!e)return;S(Sr(v.chat_history||[])),me(!!v.is_human_handled),ae(v.is_human_handled?`agent`:ie);let y=v?.visitor_email||v?.visitorEmail;if(y&&String(y).trim()&&Nt(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&&it(!1)}})(),()=>{e=!1,Ot.current?.cleanup?.(),Pt(),at.current?.disconnect()}},[i,r,a]),(0,d.useEffect)(()=>()=>{if(Pe&&!Tt.current&&wt.current.length>0){let e=E.current,t=wt.current,n=T.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(()=>{}),Tt.current=!0)}},[Pe,m]);let zt=(0,d.useRef)(null),Bt=(0,d.useRef)(!1);(0,d.useEffect)(()=>{let e=T.current;!e||!g||zt.current!==re&&(re&&zt.current!==null?(e.updateChatStatus(g,`open`).catch(()=>{}),Bt.current=!0):zt.current===!0&&e.updateChatStatus(g,`widget_closed`).catch(()=>{}),zt.current=re)},[re,g]),(0,d.useEffect)(()=>{let e=()=>{let e=E.current,t=T.current;!e||!t||typeof navigator>`u`||t.beaconWidgetClosed?.(e)||t.updateChatStatus(e,`widget_closed`).catch(()=>{})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]),(0,d.useEffect)(()=>{if(!T.current||!g||s!==`ready`)return;let e=window.setInterval(async()=>{try{let e=await T.current.checkHumanHandled(g);me(!!e.is_human_handled),e.is_human_handled&&(ae(`agent`),e.agent_info?.name&&_e(Er([e.agent_info.name],`Agent`)),e.agent_info?.headshot&&ye(e.agent_info.headshot)),kt(e)}catch{}},1e4);return()=>window.clearInterval(e)},[g,s,kt]);let Vt=async()=>{if(!(!Ge?.callId||!T.current||!at.current||!g)){jt(),mt.current=Ge.callId,Mt();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});lt.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await T.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});ct.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();Xe(`connected`),Qe(t=>t||e),Ft(e);return}if(e===`connecting`){Xe(e=>e===`connected`?e:`connecting`);return}},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();Xe(`connected`),Qe(t=>t||e),Ft(e);return}if(e===`checking`||e===`new`){Xe(e=>e===`connected`?e:`connecting`);return}},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!at.current?.connected)return;let t=e.candidate;at.current.emit(`call:ice-candidate`,{callId:Ge.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(!ut.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=>{},ut.current=e,document.body.appendChild(e)}ut.current.srcObject=e.streams[0];let r=Ge?.callId,i=r&&(mt.current===r||pt.current===r);if(!gt.current&&i){let e=new Date().toISOString();Xe(`connected`),Qe(t=>t||e),pt.current=r,Je(r),Ft(e)}ut.current.srcObject=t||null;let a=ut.current.play?.();a?.catch&&a.catch(e=>{})};let r=dt.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||Ge.callId,chatId:g}),await Rt({...r,callId:r.callId||Ge.callId})),await T.current.acceptCall(Ge.callId,g),pt.current=Ge.callId,Je(Ge.callId),Xe(e=>e===`connected`||gt.current?`connected`:`connecting`),Ke(null),C(!0)}catch(e){if(mt.current=null,Pt(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){nt(wr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await T.current.rejectCall(Ge.callId,g)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}nt(`Microphone access was denied. Please allow microphone access to accept the call.`);return}nt(`We couldn't connect the call right now. Please try again.`)}}},Ht=async()=>{if(!Ge?.callId||!T.current||!g){Pt(`reject_call_without_server_context`);return}Mt(),jt();try{await T.current.rejectCall(Ge.callId,g)}catch(e){nt(wr(e,`We couldn't decline the call cleanly.`))}finally{Pt(`reject_call_finally`)}},Ut=(0,d.useRef)(Ht);Ut.current=Ht,(0,d.useEffect)(()=>{if(!Ge?.callId||qe){Mt();return}let e=Ge.callId;return Mt(),ht.current=window.setTimeout(()=>{D.current?.callId===e&&mt.current!==e&&pt.current!==e&&Ut.current()},b),()=>{ht.current&&=(window.clearTimeout(ht.current),null)}},[qe,Mt,Ge?.callId]);let Wt=async()=>{if(!qe||!T.current||!g){Pt(`end_call_without_server_context`);return}jt();try{await T.current.endWebRTCCall(qe,g)}catch(e){nt(wr(e,`The call ended locally, but the server could not be updated.`))}finally{Pt(`end_call_finally`)}},Gt=()=>{let e=lt.current?.getAudioTracks?.()||[],t=ct.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!$e;n.forEach(e=>{e.enabled=!r}),et(r)},Kt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(Bt.current=!0,C(!0),!(!t||!T.current||!g||typeof window>`u`)){try{await T.current.trackVisitor({chatId:g,currentPagePath:window.location.pathname||`/`})}catch{}try{await T.current.updateChatStatus(g,`open`)}catch{}}},qt=async e=>{let t=Nt(e);if(!t||!T.current||!E.current)return t;try{await T.current.trackVisitor({chatId:E.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},Jt=()=>{!g||!at.current?.connected||_t.current||(_t.current=!0,at.current.emit(`typing:start`,{chatId:g,sender:`user`}))},Yt=()=>{!g||!at.current?.connected||!_t.current||(_t.current=!1,at.current.emit(`typing:stop`,{chatId:g,sender:`user`}))},Xt=(e=``)=>{let t=typeof e==`string`?e:``;!g||!at.current?.connected||t!==``&&vt.current===t||(vt.current=t,at.current.emit(`typing:update`,{chatId:g,sender:`user`,text:t}))},Zt=async(e,t=``,n=null,a={})=>{if(!(typeof e==`string`&&e.trim())||!T.current||!g||s!==`ready`||Ue)return;Yt();let o=`pending-user-${Date.now()}`,c={id:o,sender:`user`,message:e,timestamp:new Date().toISOString(),isPending:!0,type:a?.type||`text`,metadata:a?.metadata||void 0,...n||{}};S(e=>[...e,c]);let l=pe;if(l)try{l=kt(await T.current.checkHumanHandled(g))}catch{}if(l&&at.current?.connected){at.current.emit(`customer:message`,{chatId:g,content:e,sender:`user`,email:be||void 0,type:a?.type||`text`,metadata:a?.metadata||{},...n||{}});return}Ae(!0);try{let o=await T.current.sendAiMessage(g,e,r,t,{...n||{},...be?{email:be}:{}},{...a,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}),s=o.chat_history||[],c=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(c?.message){let e=Cr(c.message);e&&ur(e.url,{siteId:i?.siteId,apiBaseUrl:i?.apiBaseUrl}).then(t=>{t&&gr(e.url,{voiceActive:Et.current}).then(t=>{e.section&&setTimeout(()=>{let t=ar(null,e.section);t&&or(t)},t?300:150)})})}S(Sr(s)),me(!!o.is_human_handled),ae(o.is_human_handled?`agent`:`ai`),Ee(!1),Ae(!1),await T.current.updateChatStatus(g,`messageSent`)}catch(e){S(e=>e.filter(e=>e.id!==o)),Ee(!1),Ae(!1),e.status===429?(Me(!0),Ne(e.message),window.setTimeout(()=>{Me(!1),Ne(``)},v)):u(e)}},Qt=async e=>{if(!T.current||!e)throw Error(`Upload is unavailable right now.`);return T.current.uploadChatFile(e)},$t=async e=>{if(!(!T.current||!g)){try{let t=e?`voice`:`text`;await T.current.setChatMode(g,t)}catch{}Re(e),e&&(Tt.current=!1)}},en=async e=>{if(Tt.current)return;if(Tt.current=!0,!T.current||!g||!e?.length){Re(!1);return}let t=()=>{let t=Sr(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 T.current.syncVoice(g,e);if(n?.chat_history?.length)S(Sr(n.chat_history));else if(n?.success)try{let e=await T.current.loadHistory(g,r);e?.chat_history?.length?S(Sr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{Re(!1)}},tn=async()=>{if(!(!T.current||!g)){Pe&&!Tt.current&&wt.current.length>0&&await en(wt.current);try{await T.current.endConversation(g)}catch{try{await T.current.updateChatStatus(g,`ended`)}catch{}}We(!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(Ye!==`connected`||!qe||!g||!Ze||!At)return;let e=new Date(Ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,At*1e3-t),r=window.setTimeout(()=>{nt(`The call ended because it reached the time limit.`),Wt()},n);return()=>window.clearTimeout(r)},[qe,Ze,Ye,g,Wt,At]),(0,d.useEffect)(()=>{let e=()=>{let e=E.current,t=T.current;if(!t||!e)return;if(Et.current&&wt.current.length>0&&Te(),!Tt.current&&wt.current.length>0&&(t.beaconSyncVoice(e,wt.current)||t.syncVoice(e,wt.current).catch(()=>{}),Tt.current=!0),pt.current){t.beaconEndWebRTCCall(pt.current,e);return}let n=mt.current||D.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 nn=(0,d.useCallback)(()=>{let e=i?.siteId;se(e),ot.current=!0,st.current=null,at.current?.disconnect(),S([]),_(``),E.current=``,We(!1),me(!1),_e(null),ye(null),it(!0),o(e=>e+1)},[i?.siteId]),rn=(0,d.useCallback)(e=>{i?.siteId,ot.current=!1,st.current=e,at.current?.disconnect(),S([]),_(``),E.current=``,We(!1),me(!1),_e(null),ye(null),it(!0),o(e=>e+1)},[i?.siteId]),an=(0,d.useMemo)(()=>({status:s,error:l,runtimeConfig:m,resolvedConfig:i,chatId:g,chatHistory:x,isOpen:re,activeScreen:ie,isHumanHandled:pe,agentName:he,agentHeadshot:ve,visitorEmail:be,isAgentTyping:Se,isAiTyping:we,connectionStatus:De,isLoading:ke,isVoiceMode:Pe,isRateLimited:je,rateLimitMessage:w,isConversationEnded:Ue,isSessionRestoring:rt,openToChatCounter:ze,voiceEndCounter:Ve,incomingCall:Ge,activeCallId:qe,callConnectionState:Ye,callConnectedAt:Ze,isCallMuted:$e,webRTCError:tt,language:r,historyRef:wt,hasSyncedRef:Tt,dismissCallError:jt,captureVisitorEmail:qt,startTyping:Jt,stopTyping:Yt,updateTypingDraft:Xt,notifyRouteChange:()=>Ot.current?.notifyRouteChange?.(),openWidget:Kt,closeWidget:()=>C(!1),toggleWidget:()=>{if(re){C(!1);return}Kt({notifyChatInitiated:!0})},sendMessage:Zt,uploadChatFile:Qt,setVoiceMode:$t,onMessageSync:en,endConversation:tn,startNewChat:nn,resumeChat:rn,getVisitorChatHistory:()=>T.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>T.current?.getVisitorChatThread?.(e),acceptCall:Vt,rejectCall:Ht,endWebRTCCall:Wt,toggleCallMute:Gt}),[s,l,m,i,g,x,re,ie,pe,he,ve,be,Se,we,De,ke,Pe,je,w,Ue,rt,ze,Ve,Ge,qe,Ye,Ze,$e,tt,r,qt,Jt,Yt,Xt,Vt,Ht,Wt,Gt,Kt,Zt,Qt,$t,en,tn,nn,jt]);return(0,f.jsx)(Dn.Provider,{value:an,children:n})}var kr=(0,d.createContext)({});function Ar(e){let t=(0,d.useRef)(null);return t.current===null&&(t.current=e()),t.current}var jr=typeof window<`u`?d.useLayoutEffect:d.useEffect,Mr=(0,d.createContext)(null);function Nr(e,t){e.indexOf(t)===-1&&e.push(t)}function Pr(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Fr=(e,t,n)=>n>t?t:n<e?e:n;function Ir(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var Lr=()=>{},Rr=()=>{};typeof process<`u`&&process.env.NODE_ENV!==`production`&&(Lr=(e,t,n)=>{!e&&typeof console<`u`&&console.warn(Ir(t,n))},Rr=(e,t,n)=>{if(!e)throw Error(Ir(t,n))});var zr={},Br=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Vr(e){return typeof e==`object`&&!!e}var Hr=e=>/^0[^.\s]+$/u.test(e);function Ur(e){let t;return()=>(t===void 0&&(t=e()),t)}var Wr=e=>e,Gr=(e,t)=>n=>t(e(n)),Kr=(...e)=>e.reduce(Gr),qr=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},Jr=class{constructor(){this.subscriptions=[]}add(e){return Nr(this.subscriptions,e),()=>Pr(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}},Yr=e=>e*1e3,Xr=e=>e/1e3;function Zr(e,t){return t?1e3/t*e:0}var Qr=new Set;function $r(e,t,n){e||Qr.has(t)||(console.warn(Ir(t,n)),Qr.add(t))}var ei=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ti=1e-7,ni=12;function ri(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=ei(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ti&&++s<ni);return o}function ii(e,t,n,r){if(e===t&&n===r)return Wr;let i=t=>ri(t,0,1,e,n);return e=>e===0||e===1?e:ei(i(e),t,r)}var ai=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,oi=e=>t=>1-e(1-t),si=ii(.33,1.53,.69,.99),ci=oi(si),li=ai(ci),ui=e=>e>=1?1:(e*=2)<1?.5*ci(e):.5*(2-2**(-10*(e-1))),di=e=>1-Math.sin(Math.acos(e)),fi=oi(di),pi=ai(di),mi=ii(.42,0,1,1),hi=ii(0,0,.58,1),gi=ii(.42,0,.58,1),_i=e=>Array.isArray(e)&&typeof e[0]!=`number`,vi=e=>Array.isArray(e)&&typeof e[0]==`number`,yi={linear:Wr,easeIn:mi,easeInOut:gi,easeOut:hi,circIn:di,circInOut:pi,circOut:fi,backIn:ci,backInOut:li,backOut:si,anticipate:ui},bi=e=>typeof e==`string`,xi=e=>{if(vi(e)){Rr(e.length===4,`Cubic bezier arrays must contain four numerical values.`,`cubic-bezier-length`);let[t,n,r,i]=e;return ii(t,n,r,i)}else if(bi(e))return Rr(yi[e]!==void 0,`Invalid easing type '${e}'`,`invalid-easing-type`),yi[e];return e},Si=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],Ci={value:null,addProjectionMetrics:null};function wi(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&&Ci.value&&Ci.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var Ti=40;function Ei(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=Si.reduce((e,n)=>(e[n]=wi(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=zr.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,Ti),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:Si.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<Si.length;t++)o[Si[t]].cancel(e)},state:i,steps:o}}var{schedule:A,cancel:Di,state:Oi,steps:ki}=Ei(typeof requestAnimationFrame<`u`?requestAnimationFrame:Wr,!0),Ai;function ji(){Ai=void 0}var Mi={now:()=>(Ai===void 0&&Mi.set(Oi.isProcessing||zr.useManualTiming?Oi.timestamp:performance.now()),Ai),set:e=>{Ai=e,queueMicrotask(ji)}},Ni={layout:0,mainThread:0,waapi:0},Pi=e=>t=>typeof t==`string`&&t.startsWith(e),Fi=Pi(`--`),Ii=Pi(`var(--`),Li=e=>Ii(e)?Ri.test(e.split(`/*`)[0].trim()):!1,Ri=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function zi(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var Bi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Vi={...Bi,transform:e=>Fr(0,1,e)},Hi={...Bi,default:1},Ui=e=>Math.round(e*1e5)/1e5,Wi=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Gi(e){return e==null}var Ki=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,qi=(e,t)=>n=>!!(typeof n==`string`&&Ki.test(n)&&n.startsWith(e)||t&&!Gi(n)&&Object.prototype.hasOwnProperty.call(n,t)),Ji=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Wi);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Yi=e=>Fr(0,255,e),Xi={...Bi,transform:e=>Math.round(Yi(e))},Zi={test:qi(`rgb`,`red`),parse:Ji(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Xi.transform(e)+`, `+Xi.transform(t)+`, `+Xi.transform(n)+`, `+Ui(Vi.transform(r))+`)`};function Qi(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 $i={test:qi(`#`),parse:Qi,transform:Zi.transform},ea=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ta=ea(`deg`),na=ea(`%`),j=ea(`px`),ra=ea(`vh`),ia=ea(`vw`),aa={...na,parse:e=>na.parse(e)/100,transform:e=>na.transform(e*100)},oa={test:qi(`hsl`,`hue`),parse:Ji(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+na.transform(Ui(t))+`, `+na.transform(Ui(n))+`, `+Ui(Vi.transform(r))+`)`},sa={test:e=>Zi.test(e)||$i.test(e)||oa.test(e),parse:e=>Zi.test(e)?Zi.parse(e):oa.test(e)?oa.parse(e):$i.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Zi.transform(e):oa.transform(e),getAnimatableNone:e=>{let t=sa.parse(e);return t.alpha=0,sa.transform(t)}},ca=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function la(e){return isNaN(e)&&typeof e==`string`&&(e.match(Wi)?.length||0)+(e.match(ca)?.length||0)>0}var ua=`number`,da=`color`,fa=`var`,pa=`var(`,ma="${}",ha=/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 ga(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(ha,e=>(sa.test(e)?(r.color.push(a),i.push(da),n.push(sa.parse(e))):e.startsWith(pa)?(r.var.push(a),i.push(fa),n.push(e)):(r.number.push(a),i.push(ua),n.push(parseFloat(e))),++a,ma)).split(ma),indexes:r,types:i}}function _a(e){return ga(e).values}function va({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===ua?i+=Ui(r[a]):e===da?i+=sa.transform(r[a]):i+=r[a]}return i}}function ya(e){return va(ga(e))}var ba=e=>typeof e==`number`?0:sa.test(e)?sa.getAnimatableNone(e):e,xa=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:ba(e);function Sa(e){let t=ga(e);return va(t)(t.values.map((e,n)=>xa(e,t.split[n])))}var Ca={test:la,parse:_a,createTransformer:ya,getAnimatableNone:Sa};function wa(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 Ta({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=wa(s,r,e+1/3),a=wa(s,r,e),o=wa(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Ea(e,t){return n=>n>0?t:e}var M=(e,t,n)=>e+(t-e)*n,Da=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Oa=[$i,Zi,oa],ka=e=>Oa.find(t=>t.test(e));function Aa(e){let t=ka(e);if(Lr(!!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===oa&&(n=Ta(n)),n}var ja=(e,t)=>{let n=Aa(e),r=Aa(t);if(!n||!r)return Ea(e,t);let i={...n};return e=>(i.red=Da(n.red,r.red,e),i.green=Da(n.green,r.green,e),i.blue=Da(n.blue,r.blue,e),i.alpha=M(n.alpha,r.alpha,e),Zi.transform(i))},Ma=new Set([`none`,`hidden`]);function Na(e,t){return Ma.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Pa(e,t){return n=>M(e,t,n)}function Fa(e){return typeof e==`number`?Pa:typeof e==`string`?Li(e)?Ea:sa.test(e)?ja:za:Array.isArray(e)?Ia:typeof e==`object`?sa.test(e)?ja:La:Ea}function Ia(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Fa(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function La(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Fa(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Ra(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 za=(e,t)=>{let n=Ca.createTransformer(t),r=ga(e),i=ga(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?Ma.has(e)&&!i.values.length||Ma.has(t)&&!r.values.length?Na(e,t):Kr(Ia(Ra(r,i),i.values),n):(Lr(!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`),Ea(e,t))};function Ba(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?M(e,t,n):Fa(e)(e,t)}var Va=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>A.update(t,e),stop:()=>Di(t),now:()=>Oi.isProcessing?Oi.timestamp:Mi.now()}},Ha=(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)})`},Ua=2e4;function Wa(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 Ga(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Wa(r),Ua);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Xr(i)}}var Ka={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 qa(e,t){return e*Math.sqrt(1-t*t)}var Ja=12;function Ya(e,t,n){let r=n;for(let n=1;n<Ja;n++)r-=e(r)/t(r);return r}var Xa=.001;function Za({duration:e=Ka.duration,bounce:t=Ka.bounce,velocity:n=Ka.velocity,mass:r=Ka.mass}){let i,a;Lr(e<=Yr(Ka.maxDuration),`Spring duration must be 10 seconds or less`,`spring-duration-limit`);let o=1-t;o=Fr(Ka.minDamping,Ka.maxDamping,o),e=Fr(Ka.minDuration,Ka.maxDuration,Xr(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=qa(t,o),c=Math.exp(-i);return Xa-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=qa(t**2,o);return(-i(t)+Xa>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Xa+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Ya(i,a,s);if(e=Yr(e),isNaN(c))return{stiffness:Ka.stiffness,damping:Ka.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Qa=[`duration`,`bounce`],$a=[`stiffness`,`damping`,`mass`];function eo(e,t){return t.some(t=>e[t]!==void 0)}function to(e){let t={velocity:Ka.velocity,stiffness:Ka.stiffness,damping:Ka.damping,mass:Ka.mass,isResolvedFromDuration:!1,...e};if(!eo(e,$a)&&eo(e,Qa))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Fr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ka.mass,stiffness:i,damping:a}}else{let n=Za({...e,velocity:0});t={...t,...n,mass:Ka.mass},t.isResolvedFromDuration=!0}return t}function no(e=Ka.visualDuration,t=Ka.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}=to({...n,velocity:-Xr(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Xr(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Ka.restSpeed.granular:Ka.restSpeed.default,i||=v?Ka.restDelta.granular:Ka.restDelta.default;let y,b,x,S,ee,te;if(h<1)x=qa(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),ee=h*_*S+g*x,te=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(ee*Math.sin(x*e)+te*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 ne={calculatedDuration:p&&d||null,velocity:e=>Yr(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=Yr(t*(ee*n+te*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=Yr(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(Wa(ne),Ua),t=Ha(t=>ne.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return ne}no.applyToOptions=e=>{let t=Ga(e,100,no);return e.ease=t.ease,e.duration=Yr(t.duration),e.type=`keyframes`,e};var ro=5;function io(e,t,n){let r=Math.max(t-ro,0);return Zr(n-e(r),t-r)}function ao({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,ee=e=>{p(f.value)&&(x=e,S=no({keyframes:[f.value,m(f.value)],velocity:io(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return ee(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),ee(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function oo(e,t,n){let r=[],i=n||zr.mix||Ba,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Kr(Array.isArray(t)?t[n]||Wr:t,a)),r.push(a)}return r}function so(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(Rr(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=oo(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=qr(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Fr(e[0],e[a-1],t)):l}function co(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=qr(0,t,r);e.push(M(n,1,i))}}function lo(e){let t=[0];return co(t,e.length-1),t}function uo(e,t){return e.map(e=>e*t)}function fo(e,t){return e.map(()=>t||gi).splice(0,e.length-1)}function po({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=_i(r)?r.map(xi):xi(r),a={done:!1,value:t[0]},o=so(uo(n&&n.length===t.length?n:lo(t),e),t,{ease:Array.isArray(i)?i:fo(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var mo=e=>e!==null;function ho(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(mo),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var go={decay:ao,inertia:ao,tween:po,keyframes:po,spring:no};function _o(e){typeof e.type==`string`&&(e.type=go[e.type])}var vo=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)}},yo=e=>e/100,bo=class extends vo{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!==Mi.now()&&this.tick(Mi.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Ni.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;_o(e);let{type:t=po,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||po;process.env.NODE_ENV!==`production`&&s!==po&&Rr(o.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${o}`,`spring-two-frames`),s!==po&&typeof o[0]!=`number`&&(this.mixKeyframes=Kr(yo,Ba(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=Wa(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=Fr(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!==ao&&(b.value=ho(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 Xr(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Xr(e)}get time(){return Xr(this.currentTime)}set time(e){e=Yr(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 io(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(Mi.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Xr(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Va,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(Mi.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,Ni.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 xo(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var So=e=>e*180/Math.PI,Co=e=>To(So(Math.atan2(e[1],e[0]))),wo={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Co,rotateZ:Co,skewX:e=>So(Math.atan(e[1])),skewY:e=>So(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},To=e=>(e%=360,e<0&&(e+=360),e),Eo=Co,Do=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Oo=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),ko={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Do,scaleY:Oo,scale:e=>(Do(e)+Oo(e))/2,rotateX:e=>To(So(Math.atan2(e[6],e[5]))),rotateY:e=>To(So(Math.atan2(-e[2],e[0]))),rotateZ:Eo,rotate:Eo,skewX:e=>So(Math.atan(e[4])),skewY:e=>So(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ao(e){return e.includes(`scale`)?1:0}function jo(e,t){if(!e||e===`none`)return Ao(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=ko,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=wo,i=t}if(!i)return Ao(t);let a=r[t],o=i[1].split(`,`).map(No);return typeof a==`function`?a(o):o[a]}var Mo=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return jo(n,t)};function No(e){return parseFloat(e.trim())}var Po=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Fo=new Set(Po),Io=e=>e===Bi||e===j,Lo=new Set([`x`,`y`,`z`]),Ro=Po.filter(e=>!Lo.has(e));function zo(e){let t=[];return Ro.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Bo={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})=>jo(t,`x`),y:(e,{transform:t})=>jo(t,`y`)};Bo.translateX=Bo.x,Bo.translateY=Bo.y;var Vo=new Set,Ho=!1,Uo=!1,Wo=!1;function Go(){if(Uo){let e=Array.from(Vo).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=zo(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)})}Uo=!1,Ho=!1,Vo.forEach(e=>e.complete(Wo)),Vo.clear()}function Ko(){Vo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Uo=!0)})}function qo(){Wo=!0,Ko(),Go(),Wo=!1}var Jo=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?(Vo.add(this),Ho||(Ho=!0,A.read(Ko),A.resolveKeyframes(Go))):(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])}xo(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Vo.delete(this)}cancel(){this.state===`scheduled`&&(Vo.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Yo=e=>e.startsWith(`--`);function Xo(e,t,n){Yo(t)?e.style.setProperty(t,n):e.style[t]=n}var Zo={};function Qo(e,t){let n=Ur(e);return()=>Zo[t]??n()}var $o=Qo(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),es=Qo(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ts=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,ns={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ts([0,.65,.55,1]),circOut:ts([.55,0,1,.45]),backIn:ts([.31,.01,.66,-.59]),backOut:ts([.33,1.53,.69,.99])};function rs(e,t){if(e)return typeof e==`function`?es()?Ha(e,t):`ease-out`:vi(e)?ts(e):Array.isArray(e)?e.map(e=>rs(e,t)||ns.easeOut):ns[e]}function is(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=rs(s,i);Array.isArray(d)&&(u.easing=d),Ci.value&&Ni.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 Ci.value&&p.finished.finally(()=>{Ni.waapi--}),p}function as(e){return typeof e==`function`&&`applyToOptions`in e}function os({type:e,...t}){return as(e)&&es()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var ss=class extends vo{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,Rr(typeof e.type!=`string`,`Mini animate() doesn't support "type" as a string.`,`mini-spring`);let c=os(e);this.animation=is(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=ho(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Xo(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 Xr(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Xr(e)}get time(){return Xr(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Yr(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&&$o()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Wr):r(this)}},cs={anticipate:ui,backInOut:li,circInOut:pi};function ls(e){return e in cs}function us(e){typeof e.ease==`string`&&ls(e.ease)&&(e.ease=cs[e.ease])}var ds=10,fs=class extends ss{constructor(e){us(e),_o(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 bo({...a,autoplay:!1}),s=Math.max(ds,Mi.now()-this.startTime),c=Fr(0,ds,s-ds),l=o.sample(s).value,{name:u}=this.options;i&&u&&Xo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},ps=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Ca.test(e)||e===`0`)&&!e.startsWith(`url(`));function ms(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 hs(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=ps(i,t),s=ps(a,t);return Lr(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:ms(e)||(n===`spring`||as(n))&&r}function gs(e){e.duration=0,e.type=`keyframes`}var _s=new Set([`opacity`,`clipPath`,`filter`,`transform`]),vs=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ys(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&vs.test(e[t]))return!0;return!1}var bs=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),xs=Ur(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Ss(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 xs()&&n&&(_s.has(n)||bs.has(n)&&ys(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Cs=40,ws=class extends vo{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=Mi.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||Jo)(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=Mi.now();let u=!0;hs(e,i,a,o)||(u=!1,(zr.instantAnimations||!s)&&l?.(ho(e,n,t)),e[0]=e[e.length-1],gs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Cs?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Ss(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new fs({...d,element:p})}catch{m=new bo(d)}else m=new bo(d);m.finished.then(()=>{this.notifyFinished()}).catch(Wr),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(),qo()),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 Ts(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 Es=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ds(e){let t=Es.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var Os=4;function ks(e,t,n=1){Rr(n<=Os,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,`max-css-var-depth`);let[r,i]=Ds(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return Br(e)?parseFloat(e):e}return Li(i)?ks(i,t,n+1):i}var As={type:`spring`,stiffness:500,damping:25,restSpeed:10},js=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ms={type:`keyframes`,duration:.8},Ns={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ps=(e,{keyframes:t})=>t.length>2?Ms:Fo.has(e)?e.startsWith(`scale`)?js(t[1]):As:Ns;function Fs(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Is(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Fs(n,e)}var Ls=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Rs(e){for(let t in e)if(!Ls.has(t))return!0;return!1}var zs=(e,t,n,r={},i,a)=>o=>{let s=Is(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Yr(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};Rs(s)||Object.assign(u,Ps(e,u)),u.duration&&=Yr(u.duration),u.repeatDelay&&=Yr(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(gs(u),u.delay===0&&(d=!0)),(zr.instantAnimations||zr.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,gs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=ho(u.keyframes,s);if(e!==void 0){A.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new bo(u):new ws(u)};function Bs(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Vs(e,t,n,r){if(typeof t==`function`){let[i,a]=Bs(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]=Bs(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Hs(e,t,n){let r=e.getProps();return Vs(r,t,n===void 0?r.custom:n,e)}var Us=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Po]),Ws=30,Gs=e=>!isNaN(parseFloat(e)),Ks={current:void 0},qs=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=Mi.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=Mi.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Gs(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return process.env.NODE_ENV!==`production`&&$r(!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 Jr);let n=this.events[e].add(t);return e===`change`?()=>{n(),A.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 Ks.current&&Ks.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=Mi.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Ws)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Ws);return Zr(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 Js(e,t){return new qs(e,t)}var Ys=e=>Array.isArray(e);function Xs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Js(n))}function Zs(e){return Ys(e)?e[e.length-1]||0:e}function Qs(e,t){let{transitionEnd:n={},transition:r={},...i}=Hs(e,t)||{};i={...i,...n};for(let t in i)Xs(e,t,Zs(i[t]))}var $s=e=>!!(e&&e.getVelocity);function ec(e){return!!($s(e)&&e.add)}function tc(e,t){let n=e.getValue(`willChange`);if(ec(n))return n.add(t);if(!n&&zr.WillChange){let n=new zr.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function nc(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var rc=`data-`+nc(`framerAppearId`);function ic(e){return e.props[rc]}function ac({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function oc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Fs(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&&ac(d,t))continue;let o={delay:n,...Is(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){A.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=ic(e);if(n){let e=window.MotionHandoffAnimation(n,t,A);e!==null&&(o.startTime=e,f=!0)}}tc(e,t);let p=l??e.shouldReduceMotion;r.start(zs(t,r,i,p&&Us.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>A.update(()=>{o&&Qs(e,o)});u.length?Promise.all(u).then(t):t()}return u}function sc(e,t,n={}){let r=Hs(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(oc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return cc(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 cc(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(sc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Ts(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function lc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>sc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=sc(e,t,n);else{let i=typeof t==`function`?Hs(e,t,n.custom):t;r=Promise.all(oc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var uc={test:e=>e===`auto`,parse:e=>e},dc=e=>t=>t.test(e),fc=[Bi,j,na,ta,ia,ra,uc],pc=e=>fc.find(dc(e));function mc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Hr(e)}var hc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function gc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Wi)||[];if(!r)return e;let i=n.replace(r,``),a=hc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var _c=/\b([a-z-]*)\(.*?\)/gu,vc={...Ca,getAnimatableNone:e=>{let t=e.match(_c);return t?t.map(gc).join(` `):e}},yc={...Ca,getAnimatableNone:e=>{let t=Ca.parse(e);return Ca.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},bc={...Bi,transform:Math.round},xc={borderWidth:j,borderTopWidth:j,borderRightWidth:j,borderBottomWidth:j,borderLeftWidth:j,borderRadius:j,borderTopLeftRadius:j,borderTopRightRadius:j,borderBottomRightRadius:j,borderBottomLeftRadius:j,width:j,maxWidth:j,height:j,maxHeight:j,top:j,right:j,bottom:j,left:j,inset:j,insetBlock:j,insetBlockStart:j,insetBlockEnd:j,insetInline:j,insetInlineStart:j,insetInlineEnd:j,padding:j,paddingTop:j,paddingRight:j,paddingBottom:j,paddingLeft:j,paddingBlock:j,paddingBlockStart:j,paddingBlockEnd:j,paddingInline:j,paddingInlineStart:j,paddingInlineEnd:j,margin:j,marginTop:j,marginRight:j,marginBottom:j,marginLeft:j,marginBlock:j,marginBlockStart:j,marginBlockEnd:j,marginInline:j,marginInlineStart:j,marginInlineEnd:j,fontSize:j,backgroundPositionX:j,backgroundPositionY:j,rotate:ta,rotateX:ta,rotateY:ta,rotateZ:ta,scale:Hi,scaleX:Hi,scaleY:Hi,scaleZ:Hi,skew:ta,skewX:ta,skewY:ta,distance:j,translateX:j,translateY:j,translateZ:j,x:j,y:j,z:j,perspective:j,transformPerspective:j,opacity:Vi,originX:aa,originY:aa,originZ:j,zIndex:bc,fillOpacity:Vi,strokeOpacity:Vi,numOctaves:bc},Sc={...xc,color:sa,backgroundColor:sa,outlineColor:sa,fill:sa,stroke:sa,borderColor:sa,borderTopColor:sa,borderRightColor:sa,borderBottomColor:sa,borderLeftColor:sa,filter:vc,WebkitFilter:vc,mask:yc,WebkitMask:yc},Cc=e=>Sc[e],wc=new Set([vc,yc]);function Tc(e,t){let n=Cc(e);return wc.has(n)||(n=Ca),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Ec=new Set([`auto`,`none`,`0`]);function Dc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Ec.has(t)&&ga(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Tc(n,i)}var Oc=class extends Jo{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(),Li(r))){let i=ks(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Us.has(n)||e.length!==2)return;let[r,i]=e,a=pc(r),o=pc(i);if(zi(r)!==zi(i)&&Bo[n]){this.needsMeasurement=!0;return}if(a!==o)if(Io(a)&&Io(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Bo[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||mc(e[t]))&&n.push(t);n.length&&Dc(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=Bo[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]=Bo[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 kc(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 Ac=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function jc(e){return Vr(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Mc,cancel:Nc}=Ei(queueMicrotask,!1),Pc={x:!1,y:!1};function Fc(){return Pc.x||Pc.y}function Ic(e){return e===`x`||e===`y`?Pc[e]?null:(Pc[e]=!0,()=>{Pc[e]=!1}):Pc.x||Pc.y?null:(Pc.x=Pc.y=!0,()=>{Pc.x=Pc.y=!1})}function Lc(e,t){let n=kc(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Rc(e){return!(e.pointerType===`touch`||Fc())}function zc(e,t,n={}){let[r,i,a]=Lc(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(!Rc(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 Bc=(e,t)=>t?e===t?!0:Bc(e,t.parentElement):!1,Vc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Hc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Uc(e){return Hc.has(e.tagName)||e.isContentEditable===!0}var Wc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Gc(e){return Wc.has(e.tagName)||e.isContentEditable===!0}var Kc=new WeakSet;function qc(e){return t=>{t.key===`Enter`&&e(t)}}function Jc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Yc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=qc(()=>{if(Kc.has(n))return;Jc(n,`down`);let e=qc(()=>{Jc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Jc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Xc(e){return Vc(e)&&!Fc()}var Zc=new WeakSet;function Qc(e,t,n={}){let[r,i,a]=Lc(e,n),o=e=>{let r=e.currentTarget;if(!Xc(e)||Zc.has(e))return;Kc.add(r),n.stopPropagation&&Zc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),Kc.has(r)&&Kc.delete(r),Xc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Bc(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),jc(e)&&(e.addEventListener(`focus`,e=>Yc(e,i)),!Uc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function $c(e){return Vr(e)&&`ownerSVGElement`in e}var el=new WeakMap,tl,nl=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:$c(r)&&`getBBox`in r?r.getBBox()[t]:r[n],rl=nl(`inline`,`width`,`offsetWidth`),il=nl(`block`,`height`,`offsetHeight`);function al({target:e,borderBoxSize:t}){el.get(e)?.forEach(n=>{n(e,{get width(){return rl(e,t)},get height(){return il(e,t)}})})}function ol(e){e.forEach(al)}function sl(){typeof ResizeObserver>`u`||(tl=new ResizeObserver(ol))}function cl(e,t){tl||sl();let n=kc(e);return n.forEach(e=>{let n=el.get(e);n||(n=new Set,el.set(e,n)),n.add(t),tl?.observe(e)}),()=>{n.forEach(e=>{let n=el.get(e);n?.delete(t),n?.size||tl?.unobserve(e)})}}var ll=new Set,ul;function dl(){ul=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ll.forEach(t=>t(e))},window.addEventListener(`resize`,ul)}function fl(e){return ll.add(e),ul||dl(),()=>{ll.delete(e),!ll.size&&typeof ul==`function`&&(window.removeEventListener(`resize`,ul),ul=void 0)}}function pl(e,t){return typeof e==`function`?fl(e):cl(e,t)}function ml(e){return $c(e)&&e.tagName===`svg`}var hl=[...fc,sa,Ca],gl=e=>hl.find(dc(e)),_l=()=>({translate:0,scale:1,origin:0,originPoint:0}),vl=()=>({x:_l(),y:_l()}),yl=()=>({min:0,max:0}),bl=()=>({x:yl(),y:yl()}),xl=new WeakMap;function Sl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Cl(e){return typeof e==`string`||Array.isArray(e)}var wl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Tl=[`initial`,...wl];function El(e){return Sl(e.animate)||Tl.some(t=>Cl(e[t]))}function Dl(e){return!!(El(e)||e.variants)}function Ol(e,t,n){for(let r in t){let i=t[r],a=n[r];if($s(i))e.addValue(r,i);else if($s(a))e.addValue(r,Js(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,Js(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var kl={current:null},Al={current:!1},jl=typeof window<`u`;function Ml(){if(Al.current=!0,jl)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>kl.current=e.matches;e.addEventListener(`change`,t),t()}else kl.current=!1}var Nl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Pl={};function Fl(e){Pl=e}function Il(){return Pl}var Ll=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=Jo,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=Mi.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,A.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=El(t),this.isVariantNode=Dl(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&&$s(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,xl.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:(Al.current||Ml(),this.shouldReduceMotion=kl.current),process.env.NODE_ENV!==`production`&&$r(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(),Di(this.notifyUpdate),Di(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&&_s.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new ss({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Yr(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Fo.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&A.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 Pl){let t=Pl[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):bl()}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<Nl.length;t++){let n=Nl[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=Ol(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=Js(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`&&(Br(n)||Hr(n))?n=parseFloat(n):!gl(n)&&Ca.test(t)&&(n=Tc(e,t)),this.setBaseTarget(e,$s(n)?n.get():n)),$s(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=Vs(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&&!$s(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 Jr),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Mc.render(this.render)}},Rl=class extends Ll{constructor(){super(...arguments),this.KeyframeResolver=Oc}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;$s(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},zl=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Bl({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Vl({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Hl(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 Ul(e){return e===void 0||e===1}function Wl({scale:e,scaleX:t,scaleY:n}){return!Ul(e)||!Ul(t)||!Ul(n)}function Gl(e){return Wl(e)||Kl(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Kl(e){return ql(e.x)||ql(e.y)}function ql(e){return e&&e!==`0%`}function Jl(e,t,n){return n+t*(e-n)}function Yl(e,t,n,r,i){return i!==void 0&&(e=Jl(e,i,r)),Jl(e,n,r)+t}function Xl(e,t=0,n=1,r,i){e.min=Yl(e.min,t,n,r,i),e.max=Yl(e.max,t,n,r,i)}function Zl(e,{x:t,y:n}){Xl(e.x,t.translate,t.scale,t.originPoint),Xl(e.y,n.translate,n.scale,n.originPoint)}var Ql=.999999999999,$l=1.0000000000001;function eu(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&&(tu(e.x,-a.scroll.offset.x),tu(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Zl(e,o)),r&&Gl(a.latestValues)&&iu(e,a.latestValues,a.layout?.layoutBox))}t.x<$l&&t.x>Ql&&(t.x=1),t.y<$l&&t.y>Ql&&(t.y=1)}function tu(e,t){e.min+=t,e.max+=t}function nu(e,t,n,r,i=.5){Xl(e,t,n,M(e.min,e.max,i),r)}function ru(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function iu(e,t,n){let r=n??e;nu(e.x,ru(t.x,r.x),t.scaleX,t.scale,t.originX),nu(e.y,ru(t.y,r.y),t.scaleY,t.scale,t.originY)}function au(e,t){return Bl(Hl(e.getBoundingClientRect(),t))}function ou(e,t,n){let r=au(e,n),{scroll:i}=t;return i&&(tu(r.x,i.offset.x),tu(r.y,i.offset.y)),r}var su={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},cu=Po.length;function lu(e,t,n){let r=``,i=!0;for(let a=0;a<cu;a++){let o=Po[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=Ac(s,xc[o]);if(!c){i=!1;let t=su[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function uu(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(Fo.has(e)){o=!0;continue}else if(Fi(e)){i[e]=n;continue}else{let t=Ac(n,xc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=lu(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 du(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 fu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var pu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(j.test(e))e=parseFloat(e);else return e;return`${fu(e,t.target.x)}% ${fu(e,t.target.y)}%`}},mu={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Ca.parse(e);if(i.length>5)return r;let a=Ca.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=M(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},hu={borderRadius:{...pu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:pu,borderTopRightRadius:pu,borderBottomLeftRadius:pu,borderBottomRightRadius:pu,boxShadow:mu};function gu(e,{layout:t,layoutId:n}){return Fo.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!hu[e]||e===`opacity`)}function _u(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)($s(r[t])||i&&$s(i[t])||gu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function vu(e){return window.getComputedStyle(e)}var yu=class extends Rl{constructor(){super(...arguments),this.type=`html`,this.renderInstance=du}readValueFromInstance(e,t){if(Fo.has(t))return this.projection?.isProjecting?Ao(t):Mo(e,t);{let n=vu(e),r=(Fi(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return au(e,t)}build(e,t,n){uu(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return _u(e,t,n)}},bu={offset:`stroke-dashoffset`,array:`stroke-dasharray`},xu={offset:`strokeDashoffset`,array:`strokeDasharray`};function Su(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?bu:xu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var Cu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function wu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(uu(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 Cu)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&&Su(d,i,a,o,!1)}var Tu=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`]),Eu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Du(e,t,n,r){du(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Tu.has(n)?n:nc(n),t.attrs[n])}function Ou(e,t,n){let r=_u(e,t,n);for(let n in e)if($s(e[n])||$s(t[n])){let t=Po.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var ku=class extends Rl{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=bl}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Fo.has(t)){let e=Cc(t);return e&&e.default||0}return t=Tu.has(t)?t:nc(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Ou(e,t,n)}build(e,t,n){wu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){Du(e,t,n,r)}mount(e){this.isSVGTag=Eu(e.tagName),super.mount(e)}},Au=Tl.length;function ju(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&ju(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Au;n++){let r=Tl[n],i=e.props[r];(Cl(i)||i===!1)&&(t[r]=i)}return t}function Mu(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 Nu=[...wl].reverse(),Pu=wl.length;function Fu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>lc(e,t,n)))}function Iu(e){let t=Fu(e),n=zu(),r=!0,i=!1,a=t=>(n,r)=>{let i=Hs(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=ju(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<Pu;t++){let p=Nu[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=Cl(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||Sl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Lu(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],ee=S.reduce(a(p),{});_===!1&&(ee={});let{prevResolvedValues:te={}}=m,ne={...te,...ee},re=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 ne){let t=ee[e],n=te[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Ys(t)&&Ys(n)?!Mu(t,n):t!==n,r?t==null?u.add(e):re(e):t!==void 0&&u.has(e)?re(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=ee,m.isActive&&(d={...d,...ee}),(r||i)&&e.blockInitialAnimation&&(b=!1);let C=v&&y;b&&(!C||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!C&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Hs(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Ts(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Hs(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=zu(),i=!0}}}function Lu(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Mu(t,e):!1}function Ru(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function zu(){return{animate:Ru(!0),whileInView:Ru(),whileHover:Ru(),whileTap:Ru(),whileDrag:Ru(),whileFocus:Ru(),exit:Ru()}}function Bu(e,t){e.min=t.min,e.max=t.max}function Vu(e,t){Bu(e.x,t.x),Bu(e.y,t.y)}function Hu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Uu=1e-4,Wu=1-Uu,Gu=1+Uu,Ku=.01,qu=0-Ku,Ju=0+Ku;function Yu(e){return e.max-e.min}function Xu(e,t,n){return Math.abs(e-t)<=n}function Zu(e,t,n,r=.5){e.origin=r,e.originPoint=M(t.min,t.max,e.origin),e.scale=Yu(n)/Yu(t),e.translate=M(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Wu&&e.scale<=Gu||isNaN(e.scale))&&(e.scale=1),(e.translate>=qu&&e.translate<=Ju||isNaN(e.translate))&&(e.translate=0)}function Qu(e,t,n,r){Zu(e.x,t.x,n.x,r?r.originX:void 0),Zu(e.y,t.y,n.y,r?r.originY:void 0)}function $u(e,t,n,r=0){e.min=(r?M(n.min,n.max,r):n.min)+t.min,e.max=e.min+Yu(t)}function ed(e,t,n,r){$u(e.x,t.x,n.x,r?.x),$u(e.y,t.y,n.y,r?.y)}function td(e,t,n,r=0){let i=r?M(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Yu(t)}function nd(e,t,n,r){td(e.x,t.x,n.x,r?.x),td(e.y,t.y,n.y,r?.y)}function rd(e,t,n,r,i){return e-=t,e=Jl(e,1/n,r),i!==void 0&&(e=Jl(e,1/i,r)),e}function id(e,t=0,n=1,r=.5,i,a=e,o=e){if(na.test(t)&&(t=parseFloat(t),t=M(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=M(a.min,a.max,r);e===a&&(s-=t),e.min=rd(e.min,t,n,s,i),e.max=rd(e.max,t,n,s,i)}function ad(e,t,[n,r,i],a,o){id(e,t[n],t[r],t[i],t.scale,a,o)}var od=[`x`,`scaleX`,`originX`],sd=[`y`,`scaleY`,`originY`];function cd(e,t,n,r){ad(e.x,t,od,n?n.x:void 0,r?r.x:void 0),ad(e.y,t,sd,n?n.y:void 0,r?r.y:void 0)}function ld(e){return e.translate===0&&e.scale===1}function ud(e){return ld(e.x)&&ld(e.y)}function dd(e,t){return e.min===t.min&&e.max===t.max}function fd(e,t){return dd(e.x,t.x)&&dd(e.y,t.y)}function pd(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function md(e,t){return pd(e.x,t.x)&&pd(e.y,t.y)}function hd(e){return Yu(e.x)/Yu(e.y)}function gd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function _d(e){return[e(`x`),e(`y`)]}function vd(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 yd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],bd=yd.length,xd=e=>typeof e==`string`?parseFloat(e):e,Sd=e=>typeof e==`number`||j.test(e);function Cd(e,t,n,r,i,a){i?(e.opacity=M(0,n.opacity??1,Td(r)),e.opacityExit=M(t.opacity??1,0,Ed(r))):a&&(e.opacity=M(t.opacity??1,n.opacity??1,r));for(let i=0;i<bd;i++){let a=yd[i],o=wd(t,a),s=wd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||Sd(o)===Sd(s)?(e[a]=Math.max(M(xd(o),xd(s),r),0),(na.test(s)||na.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=M(t.rotate||0,n.rotate||0,r))}function wd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Td=Dd(0,.5,fi),Ed=Dd(.5,.95,Wr);function Dd(e,t,n){return r=>r<e?0:r>t?1:n(qr(e,t,r))}function Od(e,t,n){let r=$s(e)?e:Js(e);return r.start(zs(``,r,t,n)),r.animation}function kd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var Ad=(e,t)=>e.depth-t.depth,jd=class{constructor(){this.children=[],this.isDirty=!1}add(e){Nr(this.children,e),this.isDirty=!0}remove(e){Pr(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Ad),this.isDirty=!1,this.children.forEach(e)}};function Md(e,t){let n=Mi.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Di(r),e(a-t))};return A.setup(r,!0),()=>Di(r)}function Nd(e){return $s(e)?e.get():e}var Pd=class{constructor(){this.members=[]}add(e){Nr(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&&(Pr(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Pr(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)}},Fd={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Id={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Ld=[``,`X`,`Y`,`Z`],Rd=1e3,zd=0;function Bd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Vd(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ic(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,A,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Vd(r)}function Hd({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=zd++,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,Ci.value&&(Id.nodes=Id.calculatedTargetDeltas=Id.calculatedProjections=0),this.nodes.forEach(Gd),this.nodes.forEach(ef),this.nodes.forEach(tf),this.nodes.forEach(Kd),Ci.addProjectionMetrics&&Ci.addProjectionMetrics(Id)},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 jd)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new Jr),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=$c(t)&&!ml(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;A.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Md(i,250),Fd.hasAnimatedSinceResize&&(Fd.hasAnimatedSinceResize=!1,this.nodes.forEach($d)))})}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()||lf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!md(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={...Is(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||$d(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(),Di(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(nf),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&&Vd(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(Yd),this.nodes.forEach(Jd);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Xd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Zd),this.nodes.forEach(Qd),this.nodes.forEach(Ud),this.nodes.forEach(Wd)):this.nodes.forEach(Xd),this.clearAllSnapshots();let e=Mi.now();Oi.delta=Fr(0,1e3/60,e-Oi.timestamp),Oi.timestamp=e,Oi.isProcessing=!0,ki.update.process(Oi),ki.preRender.process(Oi),ki.render.process(Oi),Oi.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Mc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(qd),this.sharedNodes.forEach(rf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,A.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){A.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Yu(this.snapshot.measuredBox.x)&&!Yu(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||=bl(),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&&!ud(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Gl(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)),pf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return bl();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(hf))){let{scroll:e}=this.root;e&&(tu(t.x,e.offset.x),tu(t.y,e.offset.y))}return t}removeElementScroll(e){let t=bl();if(Vu(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&&Vu(t,e),tu(t.x,i.offset.x),tu(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||bl();Vu(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&&(tu(r.x,-n.scroll.offset.x),tu(r.y,-n.scroll.offset.y)),Gl(n.latestValues)&&iu(r,n.latestValues,n.layout?.layoutBox)}return Gl(this.latestValues)&&iu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=bl();Vu(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Gl(n.latestValues))continue;let r;n.instance&&(Wl(n.latestValues)&&n.updateSnapshot(),r=bl(),Vu(r,n.measurePageBox())),cd(t,n.latestValues,n.snapshot?.layoutBox,r)}return Gl(this.latestValues)&&cd(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!==Oi.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=Oi.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=bl(),this.targetWithTransforms=bl()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ed(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Vu(this.target,this.layout.layoutBox),Zl(this.target,this.targetDelta)):Vu(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),Ci.value&&Id.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Wl(this.parent.latestValues)||Kl(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=bl(),this.relativeTargetOrigin=bl(),nd(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Vu(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===Oi.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;Vu(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;eu(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=bl());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hu(this.prevProjectionDelta.x,this.projectionDelta.x),Hu(this.prevProjectionDelta.y,this.projectionDelta.y)),Qu(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!gd(this.projectionDelta.x,this.prevProjectionDelta.x)||!gd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Ci.value&&Id.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=vl(),this.projectionDelta=vl(),this.projectionDeltaWithTransform=vl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=vl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=bl(),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(cf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;af(a.x,e.x,n),af(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(nd(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),sf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&fd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=bl(),Vu(d,this.relativeTarget)),s&&(this.animationValues=i,Cd(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&&=(Di(this.pendingAnimation),void 0),this.pendingAnimation=A.update(()=>{Fd.hasAnimatedSinceResize=!0,Ni.layout++,this.motionValue||=Js(0),this.motionValue.jump(0,!1),this.currentAnimation=Od(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Ni.layout--},onComplete:()=>{Ni.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(Rd),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&&mf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||bl();let t=Yu(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Yu(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Vu(t,n),iu(t,i),Qu(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Pd),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&&Bd(`z`,e,r,this.animationValues);for(let t=0;t<Ld.length;t++)Bd(`rotate${Ld[t]}`,e,r,this.animationValues),Bd(`skew${Ld[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=Nd(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=Nd(t?.pointerEvents)||``),this.hasProjected&&!Gl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=vd(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 hu){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=hu[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?Nd(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Jd),this.root.sharedNodes.clear()}}}function Ud(e){e.updateLayout()}function Wd(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`)_d(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Yu(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Bu(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else mf(i,t.layoutBox,n)&&_d(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Yu(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=vl();Qu(o,n,t.layoutBox);let s=vl();a?Qu(s,e.applyTransform(r,!0),t.measuredBox):Qu(s,n,t.layoutBox);let c=!ud(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=bl();nd(s,t.layoutBox,i.layoutBox,o);let c=bl();nd(c,n,a.layoutBox,o),md(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 Gd(e){Ci.value&&Id.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 Kd(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function qd(e){e.clearSnapshot()}function Jd(e){e.clearMeasurements()}function Yd(e){e.isLayoutDirty=!0,e.updateLayout()}function Xd(e){e.isLayoutDirty=!1}function Zd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Qd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function $d(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function ef(e){e.resolveTargetDelta()}function tf(e){e.calcProjection()}function nf(e){e.resetSkewAndRotation()}function rf(e){e.removeLeadSnapshot()}function af(e,t,n){e.translate=M(t.translate,0,n),e.scale=M(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function of(e,t,n,r){e.min=M(t.min,n.min,r),e.max=M(t.max,n.max,r)}function sf(e,t,n,r){of(e.x,t.x,n.x,r),of(e.y,t.y,n.y,r)}function cf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var lf={duration:.45,ease:[.4,0,.1,1]},uf=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),df=uf(`applewebkit/`)&&!uf(`chrome/`)?Math.round:Wr;function ff(e){e.min=df(e.min),e.max=df(e.max)}function pf(e){ff(e.x),ff(e.y)}function mf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Xu(hd(t),hd(n),.2)}function hf(e){return e!==e.root&&e.scroll?.wasRoot}var gf=Hd({attachResizeListener:(e,t)=>kd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),_f={current:void 0},vf=Hd({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!_f.current){let e=new gf({});e.mount(window),e.setOptions({layoutScroll:!0}),_f.current=e}return _f.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),yf=(0,d.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function bf(e=!0){let t=(0,d.useContext)(Mr);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 xf=(0,d.createContext)({strict:!1}),Sf={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`]},Cf=!1;function wf(){if(Cf)return;let e={};for(let t in Sf)e[t]={isEnabled:e=>Sf[t].some(t=>!!e[t])};Fl(e),Cf=!0}function Tf(){return wf(),Il()}function Ef(e){let t=Tf();for(let n in e)t[n]={...t[n],...e[n]};Fl(t)}var Df=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 Of(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Df.has(e)}var kf=s({default:()=>Af}),Af,jf=o((()=>{throw Af={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Mf=e=>!Of(e);function Nf(e){typeof e==`function`&&(Mf=t=>t.startsWith(`on`)?!Of(t):e(t))}try{Nf((jf(),u(kf)).default)}catch{}function Pf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||$s(e[i])||(Mf(i)||n===!0&&Of(i)||!t&&!Of(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Ff=(0,d.createContext)({});function If(e,t){if(El(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Cl(t)?t:void 0,animate:Cl(n)?n:void 0}}return e.inherit===!1?{}:t}function Lf(e){let{initial:t,animate:n}=If(e,(0,d.useContext)(Ff));return(0,d.useMemo)(()=>({initial:t,animate:n}),[Rf(t),Rf(n)])}function Rf(e){return Array.isArray(e)?e.join(` `):e}var zf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Bf(e,t,n){for(let r in t)!$s(t[r])&&!gu(r,n)&&(e[r]=t[r])}function Vf({transformTemplate:e},t){return(0,d.useMemo)(()=>{let n=zf();return uu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Hf(e,t){let n=e.style||{},r={};return Bf(r,n,e),Object.assign(r,Vf(e,t)),r}function Uf(e,t){let n={},r=Hf(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 Wf=()=>({...zf(),attrs:{}});function Gf(e,t,n,r){let i=(0,d.useMemo)(()=>{let n=Wf();return wu(n,t,Eu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Bf(t,e.style,e),i.style={...t,...i.style}}return i}var Kf=[`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 qf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Kf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Jf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??qf(e)?Gf:Uf)(t,r,i,e),c=Pf(t,typeof e==`string`,a),l=e===d.Fragment?{}:{...c,...s,ref:n},{children:u}=t,f=(0,d.useMemo)(()=>$s(u)?u.get():u,[u]);return(0,d.createElement)(e,{...l,children:f})}function Yf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Xf(n,r,i,e),renderState:t()}}function Xf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Nd(a[e]);let{initial:o,animate:s}=e,c=El(e),l=Dl(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`&&!Sl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Vs(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 Zf=e=>(t,n)=>{let r=(0,d.useContext)(Ff),i=(0,d.useContext)(Mr),a=()=>Yf(e,t,r,i);return n?a():Ar(a)},Qf=Zf({scrapeMotionValuesFromProps:_u,createRenderState:zf}),$f=Zf({scrapeMotionValuesFromProps:Ou,createRenderState:Wf}),ep=Symbol.for(`motionComponentSymbol`);function tp(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 np=(0,d.createContext)({});function rp(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function ip(e,t,n,r,i,a){let{visualElement:o}=(0,d.useContext)(Ff),s=(0,d.useContext)(xf),c=(0,d.useContext)(Mr),l=(0,d.useContext)(yf),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)(np);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&ap(p.current,n,i,g);let _=(0,d.useRef)(!1);(0,d.useInsertionEffect)(()=>{h&&_.current&&h.update(n,c)});let v=n[rc],y=(0,d.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return jr(()=>{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 ap(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:op(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&rp(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function op(e){if(e)return e.options.allowProjection===!1?op(e.parent):e.projection}function sp(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Ef(r);let a=n?n===`svg`:qf(e),o=a?$f:Qf;function s(n,s){let c,l={...(0,d.useContext)(yf),...n,layoutId:cp(n)},{isStatic:u}=l,p=Lf(n),m=o(n,u);if(!u&&typeof window<`u`){lp(l,r);let t=up(l);c=t.MeasureLayout,p.visualElement=ip(e,m,l,i,t.ProjectionNode,a)}return(0,f.jsxs)(Ff.Provider,{value:p,children:[c&&p.visualElement?(0,f.jsx)(c,{visualElement:p.visualElement,...l}):null,Jf(e,n,tp(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[ep]=e,c}function cp({layoutId:e}){let t=(0,d.useContext)(kr).id;return t&&e!==void 0?t+`-`+e:e}function lp(e,t){let n=(0,d.useContext)(xf).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?Lr(!1,t,`lazy-strict-mode`):Rr(!1,t,`lazy-strict-mode`)}}function up(e){let{drag:t,layout:n}=Tf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function dp(e,t){if(typeof Proxy>`u`)return sp;let n=new Map,r=(n,r)=>sp(n,r,e,t);return new Proxy((e,t)=>(process.env.NODE_ENV!==`production`&&$r(!1,`motion() is deprecated. Use motion.create() instead.`),r(e,t)),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,sp(a,void 0,e,t)),n.get(a))})}var fp=(e,t)=>t.isSVG??qf(e)?new ku(t):new yu(t,{allowProjection:e!==d.Fragment}),pp=class extends zl{constructor(e){super(e),e.animationState||=Iu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Sl(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?.()}},mp=0,hp={animation:{Feature:pp},exit:{Feature:class extends zl{constructor(){super(...arguments),this.id=mp++,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=Hs(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 gp(e){return{point:{x:e.pageX,y:e.pageY}}}var _p=e=>t=>Vc(t)&&e(t,gp(t));function vp(e,t,n,r){return kd(e,t,_p(n),r)}var yp=({current:e})=>e?e.ownerDocument.defaultView:null,bp=(e,t)=>Math.abs(e-t);function xp(e,t){let n=bp(e.x,t.x),r=bp(e.y,t.y);return Math.sqrt(n**2+r**2)}var Sp=new Set([`auto`,`scroll`]),Cp=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=wp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Ep(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=xp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Oi;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=wp(t,this.transformPagePoint),A.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=Ep(e.type===`pointercancel`?this.lastMoveEventInfo:wp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Vc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=wp(gp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Oi;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Ep(s,this.history)),this.removeListeners=Kr(vp(this.contextWindow,`pointermove`,this.handlePointerMove),vp(this.contextWindow,`pointerup`,this.handlePointerUp),vp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Sp.has(e.overflowX)||Sp.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),A.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Di(this.updatePoint)}};function wp(e,t){return t?{point:t(e.point)}:e}function Tp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ep({point:e},t){return{point:e,delta:Tp(e,Op(t)),offset:Tp(e,Dp(t)),velocity:kp(t,.1)}}function Dp(e){return e[0]}function Op(e){return e[e.length-1]}function kp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Op(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Yr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Yr(t)*2&&(r=e[1]);let a=Xr(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 Ap(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?M(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?M(n,e,r.max):Math.min(e,n)),e}function jp(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 Mp(e,{top:t,left:n,bottom:r,right:i}){return{x:jp(e.x,n,i),y:jp(e.y,t,r)}}function Np(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 Pp(e,t){return{x:Np(e.x,t.x),y:Np(e.y,t.y)}}function Fp(e,t){let n=.5,r=Yu(e),i=Yu(t);return i>r?n=qr(t.min,t.max-r,e.min):r>i&&(n=qr(e.min,e.max-i,t.min)),Fr(0,1,n)}function Ip(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 Lp=.35;function Rp(e=Lp){return e===!1?e=0:e===!0&&(e=Lp),{x:zp(e,`left`,`right`),y:zp(e,`top`,`bottom`)}}function zp(e,t,n){return{min:Bp(e,t),max:Bp(e,n)}}function Bp(e,t){return typeof e==`number`?e:e[t]||0}var Vp=new WeakMap,Hp=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=bl(),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(gp(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=Ic(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),_d(e=>{let t=this.getAxisMotionValue(e).get()||0;if(na.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Yu(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&A.update(()=>i(e,t),!1,!0),tc(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=Kp(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&&A.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 Cp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:yp(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&&A.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||!Gp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Ap(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&&rp(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Mp(n.layoutBox,e):this.constraints=!1,this.elastic=Rp(t),r!==this.constraints&&!rp(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&_d(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Ip(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!rp(e))return!1;let n=e.current;Rr(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=ou(n,r.root,this.visualElement.getTransformPagePoint()),a=Pp(r.layout.layoutBox,i);if(t){let e=t(Vl(a));this.hasMutatedConstraints=!!e,e&&(a=Bl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=_d(o=>{if(!Gp(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 tc(this.visualElement,e),n.start(zs(e,n,0,t,this.visualElement,!1))}stopAnimation(){_d(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){_d(t=>{let{drag:n}=this.getProps();if(!Gp(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]-M(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!rp(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};_d(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Fp({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(),_d(t=>{if(!Gp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(M(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Vp.set(this.visualElement,this);let e=this.visualElement.current,t=vp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Gc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();rp(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Wp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),A.read(r);let o=kd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(_d(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=Lp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Up(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Wp(e,t,n){let r=pl(e,Up(n)),i=pl(t,Up(n));return()=>{r(),i()}}function Gp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Kp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var qp=class extends zl{constructor(e){super(e),this.removeGroupControls=Wr,this.removeListeners=Wr,this.controls=new Hp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Wr}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()}},Jp=e=>(t,n)=>{e&&A.update(()=>e(t,n),!1,!0)},Yp=class extends zl{constructor(){super(...arguments),this.removePointerDownListener=Wr}onPointerDown(e){this.session=new Cp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:yp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Jp(e),onStart:Jp(t),onMove:Jp(n),onEnd:(e,t)=>{delete this.session,r&&A.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=vp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Xp=!1,Zp=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),Xp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Fd.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}),Xp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||A.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(),Mc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Xp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Qp(e){let[t,n]=bf(),r=(0,d.useContext)(kr);return(0,f.jsx)(Zp,{...e,layoutGroup:r,switchLayoutGroup:(0,d.useContext)(np),isPresent:t,safeToRemove:n})}var $p={pan:{Feature:Yp},drag:{Feature:qp,ProjectionNode:vf,MeasureLayout:Qp}};function em(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&A.postRender(()=>i(t,gp(t)))}var tm=class extends zl{mount(){let{current:e}=this.node;e&&(this.unmount=zc(e,(e,t)=>(em(this.node,t,`Start`),e=>em(this.node,e,`End`))))}unmount(){}},nm=class extends zl{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=Kr(kd(this.node.current,`focus`,()=>this.onFocus()),kd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function rm(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&&A.postRender(()=>i(t,gp(t)))}var im=class extends zl{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Qc(e,(e,t)=>(rm(this.node,t,`Start`),(e,{success:t})=>rm(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},am=new WeakMap,om=new WeakMap,sm=e=>{let t=am.get(e.target);t&&t(e)},cm=e=>{e.forEach(sm)};function lm({root:e,...t}){let n=e||document;om.has(n)||om.set(n,{});let r=om.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(cm,{root:e,...t})),r[i]}function um(e,t,n){let r=lm(t);return am.set(e,n),r.observe(e),()=>{am.delete(e),r.unobserve(e)}}var dm={some:0,all:1},fm=class extends zl{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:dm[r]};this.stopObserver=um(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(pm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function pm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var mm={inView:{Feature:fm},tap:{Feature:im},focus:{Feature:nm},hover:{Feature:tm}},hm={layout:{ProjectionNode:vf,MeasureLayout:Qp}},gm=dp({...hp,...mm,...$p,...hm},fp);function _m(e,t){return t.forEach(function(t){t&&typeof t!=`string`&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!==`default`&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}var vm=Object.defineProperty,ym=(e,t,n)=>t in e?vm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bm=(e,t,n)=>ym(e,typeof t==`symbol`?t:t+``,n),xm=class{constructor(){bm(this,`_locking`),bm(this,`_locks`),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e,t=new Promise(t=>e=()=>{--this._locks,t()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}};function Sm(e,t){if(!e)throw Error(t)}var Cm=34028234663852886e22,wm=-34028234663852886e22,Tm=4294967295,Em=2147483647,Dm=-2147483648;function Om(e){if(typeof e!=`number`)throw Error(`invalid int 32: `+typeof e);if(!Number.isInteger(e)||e>Em||e<Dm)throw Error(`invalid int 32: `+e)}function km(e){if(typeof e!=`number`)throw Error(`invalid uint 32: `+typeof e);if(!Number.isInteger(e)||e>Tm||e<0)throw Error(`invalid uint 32: `+e)}function Am(e){if(typeof e!=`number`)throw Error(`invalid float 32: `+typeof e);if(Number.isFinite(e)&&(e>Cm||e<wm))throw Error(`invalid float 32: `+e)}var jm=Symbol(`@bufbuild/protobuf/enum-type`);function Mm(e){let t=e[jm];return Sm(t,`missing enum type on enum object`),t}function Nm(e,t,n,r){e[jm]=Pm(t,n.map(t=>({no:t.no,name:t.name,localName:e[t.no]})))}function Pm(e,t,n){let r=Object.create(null),i=Object.create(null),a=[];for(let e of t){let t=Im(e);a.push(t),r[e.name]=t,i[e.no]=t}return{typeName:e,values:a,findName(e){return r[e]},findNumber(e){return i[e]}}}function Fm(e,t,n){let r={};for(let e of t){let t=Im(e);r[t.localName]=t.no,r[t.no]=t.localName}return Nm(r,e,t),r}function Im(e){return`localName`in e?e:Object.assign(Object.assign({},e),{localName:e.name})}var Lm=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){let n=this.getType().runtime.bin,r=n.makeReadOptions(t);return n.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){let n=this.getType(),r=n.runtime.json,i=r.makeReadOptions(t);return r.readMessage(n,e,i,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`cannot decode ${this.getType().typeName} from JSON: ${e instanceof Error?e.message:String(e)}`)}return this.fromJson(n,t)}toBinary(e){let t=this.getType().runtime.bin,n=t.makeWriteOptions(e),r=n.writerFactory();return t.writeMessage(this,r,n),r.finish()}toJson(e){let t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){let t=this.toJson(e);return JSON.stringify(t,null,e?.prettySpaces??0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function Rm(e,t,n,r){let i=r?.localName??t.substring(t.lastIndexOf(`.`)+1),a={[i]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[i];return Object.setPrototypeOf(a.prototype,new Lm),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary(e,t){return new a().fromBinary(e,t)},fromJson(e,t){return new a().fromJson(e,t)},fromJsonString(e,t){return new a().fromJsonString(e,t)},equals(t,n){return e.util.equals(a,t,n)}}),a}function zm(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function Bm(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}var Vm=4294967296;function Hm(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=Vm&&(i+=r/Vm|0,r%=Vm)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?qm(r,i):Km(r,i)}function Um(e,t){let n=Km(e,t),r=n.hi&2147483648;r&&(n=qm(n.lo,n.hi));let i=Wm(n.lo,n.hi);return r?`-`+i:i}function Wm(e,t){if({lo:e,hi:t}=Gm(e,t),t<=2097151)return String(Vm*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+Jm(o)+Jm(a)}function Gm(e,t){return{lo:e>>>0,hi:t>>>0}}function Km(e,t){return{lo:e|0,hi:t|0}}function qm(e,t){return t=~t,e?e=~e+1:t+=1,Km(e,t)}var Jm=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Ym(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Xm(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}function Zm(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`int64 invalid: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}let t=e=>Sm(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>Sm(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),t(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),n(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),t(e),Hm(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),Hm(e)},dec(e,t){return Um(e,t)},uDec(e,t){return Wm(e,t)}}}var Qm=Zm(),N;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(N||={});var $m;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})($m||={});function eh(e,t,n){if(t===n)return!0;if(e==N.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return t==n}return!1}function th(e,t){switch(e){case N.BOOL:return!1;case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return t==0?Qm.zero:`0`;case N.DOUBLE:case N.FLOAT:return 0;case N.BYTES:return new Uint8Array;case N.STRING:return``;default:return 0}}function nh(e,t){switch(e){case N.BOOL:return t===!1;case N.STRING:return t===``;case N.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}var rh;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(rh||={});var ih=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(km(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return Om(e),Ym(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Am(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){km(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Om(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Om(e),e=(e<<1^e>>31)>>>0,Ym(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Qm.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Qm.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=Qm.enc(e);return Bm(t.lo,t.hi,this.buf),this}sint64(e){let t=Qm.enc(e),n=t.hi>>31;return Bm(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Qm.uEnc(e);return Bm(t.lo,t.hi,this.buf),this}},ah=class{constructor(e,t){this.varint64=zm,this.uint32=Xm,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case rh.Varint:for(;this.buf[this.pos++]&128;);break;case rh.Bit64:this.pos+=4;case rh.Bit32:this.pos+=4;break;case rh.LengthDelimited:let n=this.uint32();this.pos+=n;break;case rh.StartGroup:for(;;){let[e,n]=this.tag();if(n===rh.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(n,e)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Qm.dec(...this.varint64())}uint64(){return Qm.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Qm.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Qm.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Qm.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function oh(e,t,n,r){let i;return{typeName:t,extendee:n,get field(){if(!i){let n=typeof r==`function`?r():r;n.name=t.split(`.`).pop(),n.jsonName=`[${t}]`,i=e.util.newFieldList([n]).list()[0]}return i},runtime:e}}function sh(e){let t=e.field.localName,n=Object.create(null);return n[t]=ch(e),[n,()=>n[t]]}function ch(e){let t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case`enum`:return t.T.values[0].no;case`scalar`:return th(t.T,t.L);case`message`:let e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case`map`:throw`map fields are not allowed to be extensions`}}function lh(e,t){if(!t.repeated&&(t.kind==`enum`||t.kind==`scalar`)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter(e=>e.no===t.no)}var uh=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),dh=[];for(let e=0;e<uh.length;e++)dh[uh[e].charCodeAt(0)]=e;dh[45]=uh.indexOf(`+`),dh[95]=uh.indexOf(`/`);var fh={dec(e){let t=e.length*3/4;e[e.length-2]==`=`?t-=2:e[e.length-1]==`=`&&--t;let n=new Uint8Array(t),r=0,i=0,a,o=0;for(let t=0;t<e.length;t++){if(a=dh[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
|
|
25
|
+
`,document.head.appendChild(e)};function ir(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(kn(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(e.textContent.replace(/\s+/g,` `).toLowerCase().trim()===n)return e;for(let e of i){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.startsWith(n)||t.endsWith(n))return e}let a=[];for(let e of i){let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();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=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();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=n.textContent.replace(/\s+/g,` `).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=>!kn(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(kn(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(kn(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(kn(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=>!kn(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(kn(e))continue;let t=e.textContent.replace(/\s+/g,` `).toLowerCase().trim();if(t.includes(n)&&t.length<800)return e}return null}function ar(e,{speaking:t=!1,scroll:n=!0}={}){if(!e||typeof document>`u`)return;rr();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 or(){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`))}function sr(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 cr(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 lr(e,{siteId:t,apiBaseUrl:n}){if(!e)return!1;if(!t||!n)return console.warn(`[FlowEngage] shouldProceedWithNavigation: missing siteId or apiBaseUrl`),cr(e);let r=String(n).replace(/\/$/,``),i=new URLSearchParams({siteId:String(t),url:String(e).trim()});try{let t=await(await fetch(`${r}/api/widget/navigate-allowed?${i.toString()}`)).json().catch(()=>({}));return t.success&&t.allowed?!0:cr(e)}catch(t){return console.warn(`[FlowEngage] navigate-allowed check failed:`,t?.message),cr(e)}}function ur(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(An,JSON.stringify({sectionText:e,ts:Date.now()}))}catch{}}async function dr(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}er();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 tr(),!1;let o=await a.text(),s=new DOMParser().parseFromString(o,`text/html`),c=document.getElementById(`flowengage-root`);if(!c)return tr(),!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()}),Gn();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(Wn,`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(Wn,`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,A(`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){A(`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,A(`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){A(`trySpaNavigate: blocked location.assign from replayed script:`,e);return}return d(e)},window.location.replace=e=>{if(p){A(`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;A(`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)){A(`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:`)&&(A(`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`)||``}),A(`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),A(`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(Bn(),Hn(),n){try{Jn()}catch{}try{Zn()}catch{}}else window.scrollTo(0,0);tr(),Qn(e);try{sessionStorage.removeItem(An)}catch{}try{sessionStorage.removeItem(Mn)}catch{}try{zn=new URL(e,window.location.origin).pathname}catch{}return A(`trySpaNavigate: succeeded →`,e),!0}catch{return clearTimeout(i),tr(),!1}}function fr(e){if(!(!e||typeof sessionStorage>`u`))try{sessionStorage.setItem(Mn,JSON.stringify({voiceWasActive:!0,targetUrl:String(e),ts:Date.now()}))}catch{}}function pr(){if(!(typeof sessionStorage>`u`))try{sessionStorage.removeItem(Mn)}catch{}}function mr(){if(typeof window>`u`||typeof sessionStorage>`u`)return{shouldResumeVoice:!1,targetUrl:null};let e;try{e=JSON.parse(sessionStorage.getItem(Mn)||`null`)}catch{return{shouldResumeVoice:!1,targetUrl:null}}if(!e)return{shouldResumeVoice:!1,targetUrl:null};try{sessionStorage.removeItem(Mn)}catch{}return e.voiceWasActive?Date.now()-e.ts>Nn?(A(`initVoiceNavResume: state expired, skipping`),{shouldResumeVoice:!1,targetUrl:null}):(A(`initVoiceNavResume: voice was active during navigation to`,e.targetUrl),{shouldResumeVoice:!0,targetUrl:e.targetUrl||null}):{shouldResumeVoice:!1,targetUrl:null}}async function hr(e,t={}){if(typeof window>`u`)return!1;let{sectionText:n,voiceActive:r=!1}=t;try{let t=sr(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`}),!0}if(i.pathname===window.location.pathname&&i.search===window.location.search&&!i.hash)return!1;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(!0)};o.events?.on(`routeChangeComplete`,t),o.push(a),setTimeout(t,5e3)});if(window.__NEXT_ROUTER__?.push)return window.__NEXT_ROUTER__.push(a),!0;if(Un()){n&&ur(n);try{window.history.pushState({},``,i.href),window.dispatchEvent(new PopStateEvent(`popstate`,{state:{}}))}catch{}return!0}return n&&ur(n),r||Oe(),window.location.assign(i.href),!0}catch(t){console.warn(`[FlowEngage] shadowNavigate error:`,t),n&&ur(n);try{window.location.href=sr(e)}catch{window.location.href=e}return!0}}var gr=!1,_r=null;function vr(e){_r=e,typeof window<`u`&&(window.__fe_triggerVoiceNavHooks=()=>{try{e.onBeforeNavigate()}catch{}}),!gr&&(gr=!0,!(typeof document>`u`)&&(document.addEventListener(`click`,e=>{if(!_r)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)){A(`voice-link-hook: saving state before navigation →`,r.href);try{_r.onBeforeNavigate()}catch{}}},!0),document.addEventListener(`submit`,e=>{if(_r&&!e.target?.closest?.(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)){A(`voice-form-hook: saving state before form submit`);try{_r.onBeforeNavigate()}catch{}}},!0)))}function yr(){_r=null,A(`voice-nav-hooks: deactivated`)}var br=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(),xr=(e=[])=>e.filter(e=>e.type!==`call_recording`&&!(typeof e.message==`string`&&e.message.includes(`AI chat recording`))).map(e=>({...e,message:br(e.message),isPending:!1,id:e.messageId||`${e.sender}-${e.timestamp||Date.now()}-${Math.random()}`}));function Sr(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 Cr=(e,t)=>e?typeof e==`string`?e:e.message||e.error||e.reason||t:t,wr=(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}:{}}},Tr=(e=[],t=`Agent`)=>{for(let t of e)if(typeof t==`string`&&t.trim())return t.trim();return t},Er=(e=[],t,n=6)=>!t?.message||e.slice(-n).some(e=>e.sender===`system`&&e.message===t.message)?e:[...e,t];function Dr({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)([]),[re,C]=(0,d.useState)(le().isOpen),[ie,ae]=(0,d.useState)(le().activeScreen),[pe,me]=(0,d.useState)(le().isHumanHandled),[he,_e]=(0,d.useState)(le().agentName),[ve,ye]=(0,d.useState)(le().agentHeadshot),[be,xe]=(0,d.useState)(()=>de(i?.siteId)),[Se,Ce]=(0,d.useState)(!1),[we,Ee]=(0,d.useState)(!1),[De,Oe]=(0,d.useState)(`idle`),[ke,Ae]=(0,d.useState)(!1),[je,Me]=(0,d.useState)(!1),[Ne,Pe]=(0,d.useState)(``),[Fe,ze]=(0,d.useState)(!1),[Be,Ve]=(0,d.useState)(0),[He,Ue]=(0,d.useState)(0),[We,Ge]=(0,d.useState)(!1),[Ke,qe]=(0,d.useState)(null),[Je,Ye]=(0,d.useState)(null),[Xe,w]=(0,d.useState)(`idle`),[Ze,Qe]=(0,d.useState)(null),[$e,et]=(0,d.useState)(!1),[tt,nt]=(0,d.useState)(``),[rt,T]=(0,d.useState)(!1),E=(0,d.useRef)(null),D=(0,d.useRef)(null),it=(0,d.useRef)(``),at=(0,d.useRef)(!1),ot=(0,d.useRef)(null),O=(0,d.useRef)(null),st=(0,d.useRef)(null),ct=(0,d.useRef)(null),lt=(0,d.useRef)(null),ut=(0,d.useRef)(null),dt=(0,d.useRef)([]),ft=(0,d.useRef)(null),pt=(0,d.useRef)(null),mt=(0,d.useRef)(null),ht=(0,d.useRef)(!1),gt=(0,d.useRef)(!1),_t=(0,d.useRef)(``),vt=(0,d.useRef)(null),yt=(0,d.useRef)(null),bt=(0,d.useRef)([]),xt=(0,d.useRef)(0),St=(0,d.useRef)(he),Ct=(0,d.useRef)([]),wt=(0,d.useRef)(!1),Tt=(0,d.useRef)(!1),Et=(0,d.useRef)(i),Dt=(0,d.useRef)({notifyRouteChange:()=>{},cleanup:()=>{}}),Ot=(0,d.useCallback)((e={})=>{let t=!!e.is_human_handled;return me(t),t?(ae(`agent`),e.agent_info?.name&&_e(e.agent_info.name),e.agent_info?.headshot&&ye(e.agent_info.headshot),t):(ae(`ai`),t)},[]),kt=(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)(()=>{O.current=Ke},[Ke]),(0,d.useEffect)(()=>{St.current=he},[he]),(0,d.useEffect)(()=>{Tt.current=Fe},[Fe]),(0,d.useEffect)(()=>{Et.current=i},[i]);let At=()=>{nt(``)},jt=(0,d.useCallback)(()=>{mt.current&&=(window.clearTimeout(mt.current),null)},[]),Mt=e=>{let t=typeof e==`string`?e.trim().toLowerCase():``;return xe(t),fe(t,i?.siteId),t};(0,d.useEffect)(()=>{let e=i?.siteId;e&&xe(de(e))},[i?.siteId]);let Nt=(e=`unspecified`)=>{let t=ft.current||ut.current?.callId,n=xt.current,r=vt.current;if(vt.current=null,xt.current=0,r&&r.state!==`inactive`){r.onstop=()=>{let e=bt.current;if(bt.current=[],e.length>0&&t&&D.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;D.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,bt.current=[]}}else if(r&&r.state===`inactive`){let e=bt.current;if(bt.current=[],e.length>0&&t&&D.current){let r=new Blob(e,{type:e[0].type}),i=n>0?Math.round((Date.now()-n)/1e3):0;D.current.uploadRecording(t,r,i).then(e=>console.log(`[FlowEngageCall] recording upload success`,e)).catch(e=>console.warn(`[FlowEngageCall] recording upload failed`,e))}}else bt.current=[];if(yt.current){try{yt.current.close()}catch{}yt.current=null}st.current&&=(st.current.close(),null),ct.current&&=(ct.current.getTracks().forEach(e=>e.stop()),null),lt.current&&=(lt.current.srcObject=null,lt.current.remove(),null),jt(),ut.current=null,dt.current=[],ft.current=null,pt.current=null,ht.current=!1,et(!1),qe(null),Ye(null),w(`idle`),Qe(null)},Pt=(e=new Date().toISOString())=>{let t=E.current,n=ft.current||ut.current?.callId;if(!(!t?.connected||!n||ht.current)){ht.current=!0,t.emit(`call:connected`,{callId:n,chatId:it.current,connectedAt:e});try{let e=ct.current,t=lt.current?.srcObject;if(e&&t&&!vt.current){bt.current=[];let n=new(window.AudioContext||window.webkitAudioContext);yt.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&&bt.current.push(e.data)},vt.current=a,xt.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{}}},Ft=(e={})=>{if(!e.callId)return;let t=pt.current===e.callId,n=ft.current===e.callId,r=O.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(jt(),qe(null),t||n){ft.current=e.callId,Ye(e.callId),w(e=>e===`connected`?e:`connecting`),C(!0);return}w(`idle`)}},It=(e={})=>{if(!e.callId)return;let t=pt.current===e.callId,n=ft.current===e.callId,r=O.current?.callId===e.callId;if(!(!t&&!n&&!r)){if(jt(),n){Nt();return}pt.current=null,ut.current=null,dt.current=[],qe(null),w(`idle`)}},Lt=async(e={})=>{let t=st.current,n=E.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:it.current,hasPeerConnection:!!t,socketConnected:!!n?.connected,hasOffer:!!r}),ut.current=e;return}if(await t.setRemoteDescription(new RTCSessionDescription({type:`offer`,sdp:r})),dt.current.length>0){console.log(`[FlowEngageProvider] flushing queued agent ICE candidates after remote offer`,{callId:e.callId,chatId:it.current,queuedCount:dt.current.length});for(let e of dt.current)await t.addIceCandidate(new RTCIceCandidate(e));dt.current=[]}let i=await t.createAnswer();await t.setLocalDescription(i),n.emit(`call:answer`,{callId:e.callId,sdpAnswer:i.sdp,chatId:it.current})};(0,d.useEffect)(()=>{ue({isOpen:re,activeScreen:ie,isHumanHandled:pe,agentName:he,agentHeadshot:ve})},[re,ie,pe,he,ve]),(0,d.useEffect)(()=>{let e=!0;return(async()=>{T(!0);try{let t=p(i),n=await Le(t);if(!e)return;let a=t.siteId,o=oe(a),s=ge(a),l=``;try{let e=at.current,r=ot.current;if(at.current=!1,ot.current=null,l=(await Ie({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:a,priorChatId:e||r?null:o||ee(),forceNew:e,resumeChatId:r,visitorId:s}))?.data?.chatId,!l)throw Error(`resolve-session returned no chatId`);te(),ce(a,l)}catch(e){console.warn(`[FlowEngageProvider] resolve-session failed, reusing persisted or ephemeral chat id`,e?.message||e),l=o||ne(),ce(a,l)}it.current=l;let u=Re({apiBaseUrl:t.apiBaseUrl,userId:n.userId,siteId:t.siteId,visitorId:s});D.current=u,h({...n,apiBaseUrl:t.apiBaseUrl}),_(l);let d=n?.widgetSettings?.branding?.fallbackAgentName||`Agent`,f=wn({apiBaseUrl:t.apiBaseUrl,userId:n.userId,chatId:l,siteId:t.siteId});E.current=f,f.on(`connect`,()=>{Oe(`connected`)}),f.on(`disconnect`,()=>{Oe(`disconnected`)}),f.on(`aiTyping`,()=>{Ee(!0)}),f.on(`ai:typing`,()=>{Ee(!0)}),f.on(`messageReceived`,e=>{let t=e.message||e,n={...t,message:br(t.message)};Ee(!1),Ce(!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:br(t.message)};Ee(!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`)&&Ce(!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)&&(me(!0),ae(`agent`),_e(Tr([n.agent_name,n.agentName,n.metadata?.agentName],d)),n.sender_headshot&&ye(n.sender_headshot),C(!0),Ve(e=>e+1)))});let m=(e={})=>{let t=Tr([e.agent?.name,e.agentName,e.agent_name,St.current],d);me(!0),ae(`agent`),_e(t),ye(e.agent?.headshot||null),C(!0),Ve(e=>e+1),S(e=>Er(e,{id:`agent-joined-${Date.now()}`,sender:`system`,message:`${t} has joined the chat.`,timestamp:new Date().toISOString(),isPending:!1}))},g=(e={})=>{let t=Tr([e.agent?.name,e.agentName,e.agent_name,St.current],d);me(!1),ae(`ai`),S(e=>Er(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=>{Ge(!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=xr(e.chat_history||[]);S(t),t.length===0&&(Ge(!1),me(!1),ae(`ai`),Ee(!1),Ce(!1))}),f.on(`conversation:reset`,()=>{S([]),Ge(!1),me(!1),ae(`ai`),Ee(!1),Ce(!1)}),f.on(`voice:end_session`,(e={})=>{console.log(`[FlowEngageProvider] voice:end_session received — ending ElevenLabs session`),Ue(e=>e+1),C(!0),Ve(e=>e+1)}),f.on(`typing:start`,e=>{e.sender===`agent`&&Ce(!0)}),f.on(`typing:stop`,e=>{e.sender===`agent`&&Ce(!1)}),f.on(`call:incoming`,(e={})=>{let t=Tr([e.agentName,e.ownerName,e.agent?.name,St.current],`Agent`);At(),jt(),ht.current=!1,qe({callId:e.callId,from:e.from||`owner`,agentId:e.agentId||null,agentName:t}),_e(e=>Tr([t,e],`Agent`)),w(`incoming`),Qe(null),C(!0)}),f.on(`call:offer`,async(e={})=>{ut.current=e;try{await Lt(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=wr(e);if(!t){console.warn(`[FlowEngageProvider] ignoring invalid ICE candidate payload`,e);return}if(!st.current||!st.current.remoteDescription){console.log(`[FlowEngageProvider] queueing agent ICE candidate until peer/remote description is ready`,{callId:e.callId,chatId:e.chatId||it.current,queueSize:dt.current.length+1}),dt.current.push(t);return}await st.current.addIceCandidate(new RTCIceCandidate(t))}catch(e){console.error(`[FlowEngageProvider] failed to add ICE candidate`,e)}}),f.on(`call:ended`,()=>{At(),Nt(`socket:call_ended`)}),f.on(`call:accepted`,(e={})=>{Ft(e)}),f.on(`call:accepted_by_other`,(e={})=>{Ft(e)}),f.on(`call:rejected`,(e={})=>{It(e)}),f.on(`call:missed`,(e={})=>{It(e)}),f.on(`call:failed`,(e={})=>{It(e)}),f.on(`call:connected`,(e={})=>{if(!e.callId)return;let t=pt.current===e.callId,n=ft.current===e.callId,r=ut.current?.callId===e.callId,i=O.current?.callId===e.callId;if(!t&&!n&&!r){i&&(qe(null),w(`idle`));return}ht.current=!0,pt.current=null,ft.current=e.callId,Ye(e.callId),qe(null),w(`connected`),Qe(e.connectedAt||new Date().toISOString()),C(!0)}),f.on(`call:unavailable`,(e={})=>{Nt(`socket:call_unavailable`),nt(Cr(e,`This visitor is not available for a call right now.`)),C(!0)}),f.on(`call:error`,(e={})=>{Nt(`socket:call_error`),nt(Cr(e,`We couldn't connect the call right now.`)),C(!0)}),f.on(`visitor:navigate`,async({url:e,section:n,highlight:r}={})=>{e&&await lr(e,{siteId:t.siteId,apiBaseUrl:t.apiBaseUrl})&&hr(e,{voiceActive:Tt.current}).then(e=>{let t=n||r;t&&setTimeout(()=>{let e=ir(null,t);e&&ar(e)},e?300:150)})}),f.on(`visitor:highlight`,({sectionId:e,sectionText:t}={})=>{if(!e&&!t)return;let n=ir(e||null,t||null);n&&ar(n)}),f.on(`visitor:clear_highlight`,()=>{or()}),Dt.current=Tn({socket:f,chatId:l});let v=await u.loadHistory(l,r);if(!e)return;S(xr(v.chat_history||[])),me(!!v.is_human_handled),ae(v.is_human_handled?`agent`:ie);let y=v?.visitor_email||v?.visitorEmail;if(y&&String(y).trim()&&Mt(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&&T(!1)}})(),()=>{e=!1,Dt.current?.cleanup?.(),Nt(),E.current?.disconnect()}},[i,r,a]),(0,d.useEffect)(()=>()=>{if(Fe&&!wt.current&&Ct.current.length>0){let e=it.current,t=Ct.current,n=D.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(()=>{}),wt.current=!0)}},[Fe,m]);let Rt=(0,d.useRef)(null),zt=(0,d.useRef)(!1);(0,d.useEffect)(()=>{let e=D.current;!e||!g||Rt.current!==re&&(re&&Rt.current!==null?(e.updateChatStatus(g,`open`).catch(()=>{}),zt.current=!0):Rt.current===!0&&e.updateChatStatus(g,`widget_closed`).catch(()=>{}),Rt.current=re)},[re,g]),(0,d.useEffect)(()=>{let e=()=>{let e=it.current,t=D.current;!e||!t||typeof navigator>`u`||t.beaconWidgetClosed?.(e)||t.updateChatStatus(e,`widget_closed`).catch(()=>{})};return window.addEventListener(`pagehide`,e),()=>window.removeEventListener(`pagehide`,e)},[]),(0,d.useEffect)(()=>{if(!D.current||!g||s!==`ready`)return;let e=window.setInterval(async()=>{try{let e=await D.current.checkHumanHandled(g);me(!!e.is_human_handled),e.is_human_handled&&(ae(`agent`),e.agent_info?.name&&_e(Tr([e.agent_info.name],`Agent`)),e.agent_info?.headshot&&ye(e.agent_info.headshot)),Ot(e)}catch{}},1e4);return()=>window.clearInterval(e)},[g,s,Ot]);let Bt=async()=>{if(!(!Ke?.callId||!D.current||!E.current||!g)){At(),pt.current=Ke.callId,jt();try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});ct.current=e;let t=[{urls:`stun:stun.l.google.com:19302`}];try{let e=await D.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});st.current=n,n.onconnectionstatechange=()=>{let e=n.connectionState;if(e===`connected`){let e=new Date().toISOString();w(`connected`),Qe(t=>t||e),Pt(e);return}if(e===`connecting`){w(e=>e===`connected`?e:`connecting`);return}},n.oniceconnectionstatechange=()=>{let e=n.iceConnectionState;if(e===`connected`||e===`completed`){let e=new Date().toISOString();w(`connected`),Qe(t=>t||e),Pt(e);return}if(e===`checking`||e===`new`){w(e=>e===`connected`?e:`connecting`);return}},n.onsignalingstatechange=()=>{},n.onicegatheringstatechange=()=>{},e.getTracks().forEach(t=>{n.addTrack(t,e)}),n.onicecandidate=e=>{if(!e.candidate||!E.current?.connected)return;let t=e.candidate;E.current.emit(`call:ice-candidate`,{callId:Ke.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(!lt.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=>{},lt.current=e,document.body.appendChild(e)}lt.current.srcObject=e.streams[0];let r=Ke?.callId,i=r&&(pt.current===r||ft.current===r);if(!ht.current&&i){let e=new Date().toISOString();w(`connected`),Qe(t=>t||e),ft.current=r,Ye(r),Pt(e)}lt.current.srcObject=t||null;let a=lt.current.play?.();a?.catch&&a.catch(e=>{})};let r=ut.current;r&&(console.log(`[FlowEngageProvider] found pending remote offer during accept`,{callId:r.callId||Ke.callId,chatId:g}),await Lt({...r,callId:r.callId||Ke.callId})),await D.current.acceptCall(Ke.callId,g),ft.current=Ke.callId,Ye(Ke.callId),w(e=>e===`connected`||ht.current?`connected`:`connecting`),qe(null),C(!0)}catch(e){if(pt.current=null,Nt(`accept_call_failed`),e?.status===404||e?.status===409||e?.status===422){nt(Cr(e,`This visitor call is no longer available.`));return}if(e?.name===`NotAllowedError`||e?.name===`PermissionDeniedError`){try{await D.current.rejectCall(Ke.callId,g)}catch(e){console.error(`[FlowEngageProvider] failed to reject call after microphone denial`,e)}nt(`Microphone access was denied. Please allow microphone access to accept the call.`);return}nt(`We couldn't connect the call right now. Please try again.`)}}},Vt=async()=>{if(!Ke?.callId||!D.current||!g){Nt(`reject_call_without_server_context`);return}jt(),At();try{await D.current.rejectCall(Ke.callId,g)}catch(e){nt(Cr(e,`We couldn't decline the call cleanly.`))}finally{Nt(`reject_call_finally`)}},Ht=(0,d.useRef)(Vt);Ht.current=Vt,(0,d.useEffect)(()=>{if(!Ke?.callId||Je){jt();return}let e=Ke.callId;return jt(),mt.current=window.setTimeout(()=>{O.current?.callId===e&&pt.current!==e&&ft.current!==e&&Ht.current()},b),()=>{mt.current&&=(window.clearTimeout(mt.current),null)}},[Je,jt,Ke?.callId]);let Ut=async()=>{if(!Je||!D.current||!g){Nt(`end_call_without_server_context`);return}At();try{await D.current.endWebRTCCall(Je,g)}catch(e){nt(Cr(e,`The call ended locally, but the server could not be updated.`))}finally{Nt(`end_call_finally`)}},Wt=()=>{let e=ct.current?.getAudioTracks?.()||[],t=st.current?.getSenders?.().map(e=>e.track).filter(e=>e?.kind===`audio`)||[],n=[...e,...t].filter(Boolean);if(n.length===0)return;let r=!$e;n.forEach(e=>{e.enabled=!r}),et(r)},Gt=async(e={})=>{let t=e.notifyChatInitiated===!0;if(zt.current=!0,C(!0),!(!t||!D.current||!g||typeof window>`u`)){try{await D.current.trackVisitor({chatId:g,currentPagePath:window.location.pathname||`/`})}catch{}try{await D.current.updateChatStatus(g,`open`)}catch{}}},Kt=async e=>{let t=Mt(e);if(!t||!D.current||!it.current)return t;try{await D.current.trackVisitor({chatId:it.current,currentPagePath:typeof window<`u`&&window.location.pathname||`/`,email:t})}catch(e){console.error(`[FlowEngageProvider] failed to persist visitor email`,e)}return t},qt=()=>{!g||!E.current?.connected||gt.current||(gt.current=!0,E.current.emit(`typing:start`,{chatId:g,sender:`user`}))},Jt=()=>{!g||!E.current?.connected||!gt.current||(gt.current=!1,E.current.emit(`typing:stop`,{chatId:g,sender:`user`}))},Yt=(e=``)=>{let t=typeof e==`string`?e:``;!g||!E.current?.connected||t!==``&&_t.current===t||(_t.current=t,E.current.emit(`typing:update`,{chatId:g,sender:`user`,text:t}))},Xt=async(e,t=``,n=null,a={})=>{if(!(typeof e==`string`&&e.trim())||!D.current||!g||s!==`ready`||We)return;Jt();let o=`pending-user-${Date.now()}`,c={id:o,sender:`user`,message:e,timestamp:new Date().toISOString(),isPending:!0,type:a?.type||`text`,metadata:a?.metadata||void 0,...n||{}};S(e=>[...e,c]);let l=pe;if(l)try{l=Ot(await D.current.checkHumanHandled(g))}catch{}if(l&&E.current?.connected){E.current.emit(`customer:message`,{chatId:g,content:e,sender:`user`,email:be||void 0,type:a?.type||`text`,metadata:a?.metadata||{},...n||{}});return}Ae(!0);try{let o=await D.current.sendAiMessage(g,e,r,t,{...n||{},...be?{email:be}:{}},{...a,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}),s=o.chat_history||[],c=[...s].reverse().find(e=>e.sender===`bot`||e.sender===`assistant`);if(c?.message){let e=Sr(c.message);e&&lr(e.url,{siteId:i?.siteId,apiBaseUrl:i?.apiBaseUrl}).then(t=>{t&&hr(e.url,{voiceActive:Tt.current}).then(t=>{e.section&&setTimeout(()=>{let t=ir(null,e.section);t&&ar(t)},t?300:150)})})}S(xr(s)),me(!!o.is_human_handled),ae(o.is_human_handled?`agent`:`ai`),Ee(!1),Ae(!1),await D.current.updateChatStatus(g,`messageSent`)}catch(e){S(e=>e.filter(e=>e.id!==o)),Ee(!1),Ae(!1),e.status===429?(Me(!0),Pe(e.message),window.setTimeout(()=>{Me(!1),Pe(``)},v)):u(e)}},Zt=async e=>{if(!D.current||!e)throw Error(`Upload is unavailable right now.`);return D.current.uploadChatFile(e)},Qt=async e=>{if(!(!D.current||!g)){try{let t=e?`voice`:`text`;await D.current.setChatMode(g,t)}catch{}ze(e),e&&(wt.current=!1)}},$t=async e=>{if(wt.current)return;if(wt.current=!0,!D.current||!g||!e?.length){ze(!1);return}let t=()=>{let t=xr(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 D.current.syncVoice(g,e);if(n?.chat_history?.length)S(xr(n.chat_history));else if(n?.success)try{let e=await D.current.loadHistory(g,r);e?.chat_history?.length?S(xr(e.chat_history)):t()}catch{t()}else t()}catch{t()}finally{ze(!1)}},en=async()=>{if(!(!D.current||!g)){Fe&&!wt.current&&Ct.current.length>0&&await $t(Ct.current);try{await D.current.endConversation(g)}catch{try{await D.current.updateChatStatus(g,`ended`)}catch{}}Ge(!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(Xe!==`connected`||!Je||!g||!Ze||!kt)return;let e=new Date(Ze).getTime(),t=Number.isFinite(e)?Date.now()-e:0,n=Math.max(0,kt*1e3-t),r=window.setTimeout(()=>{nt(`The call ended because it reached the time limit.`),Ut()},n);return()=>window.clearTimeout(r)},[Je,Ze,Xe,g,Ut,kt]),(0,d.useEffect)(()=>{let e=()=>{let e=it.current,t=D.current;if(!t||!e)return;if(Tt.current&&Ct.current.length>0&&Te(),!wt.current&&Ct.current.length>0&&(t.beaconSyncVoice(e,Ct.current)||t.syncVoice(e,Ct.current).catch(()=>{}),wt.current=!0),ft.current){t.beaconEndWebRTCCall(ft.current,e);return}let n=pt.current||O.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 tn=(0,d.useCallback)(()=>{let e=i?.siteId;se(e),at.current=!0,ot.current=null,E.current?.disconnect(),S([]),_(``),it.current=``,Ge(!1),me(!1),_e(null),ye(null),T(!0),o(e=>e+1)},[i?.siteId]),nn=(0,d.useCallback)(e=>{i?.siteId,at.current=!1,ot.current=e,E.current?.disconnect(),S([]),_(``),it.current=``,Ge(!1),me(!1),_e(null),ye(null),T(!0),o(e=>e+1)},[i?.siteId]),rn=(0,d.useMemo)(()=>({status:s,error:l,runtimeConfig:m,resolvedConfig:i,chatId:g,chatHistory:x,isOpen:re,activeScreen:ie,isHumanHandled:pe,agentName:he,agentHeadshot:ve,visitorEmail:be,isAgentTyping:Se,isAiTyping:we,connectionStatus:De,isLoading:ke,isVoiceMode:Fe,isRateLimited:je,rateLimitMessage:Ne,isConversationEnded:We,isSessionRestoring:rt,openToChatCounter:Be,voiceEndCounter:He,incomingCall:Ke,activeCallId:Je,callConnectionState:Xe,callConnectedAt:Ze,isCallMuted:$e,webRTCError:tt,language:r,historyRef:Ct,hasSyncedRef:wt,dismissCallError:At,captureVisitorEmail:Kt,startTyping:qt,stopTyping:Jt,updateTypingDraft:Yt,notifyRouteChange:()=>Dt.current?.notifyRouteChange?.(),openWidget:Gt,closeWidget:()=>C(!1),toggleWidget:()=>{if(re){C(!1);return}Gt({notifyChatInitiated:!0})},sendMessage:Xt,uploadChatFile:Zt,setVoiceMode:Qt,onMessageSync:$t,endConversation:en,startNewChat:tn,resumeChat:nn,getVisitorChatHistory:()=>D.current?.getVisitorChatHistory?.(),getVisitorChatThread:e=>D.current?.getVisitorChatThread?.(e),acceptCall:Bt,rejectCall:Vt,endWebRTCCall:Ut,toggleCallMute:Wt}),[s,l,m,i,g,x,re,ie,pe,he,ve,be,Se,we,De,ke,Fe,je,Ne,We,rt,Be,He,Ke,Je,Xe,Ze,$e,tt,r,Kt,qt,Jt,Yt,Bt,Vt,Ut,Wt,Gt,Xt,Zt,Qt,$t,en,tn,At]);return(0,f.jsx)(En.Provider,{value:rn,children:n})}var Or=(0,d.createContext)({});function kr(e){let t=(0,d.useRef)(null);return t.current===null&&(t.current=e()),t.current}var Ar=typeof window<`u`?d.useLayoutEffect:d.useEffect,jr=(0,d.createContext)(null);function Mr(e,t){e.indexOf(t)===-1&&e.push(t)}function Nr(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var Pr=(e,t,n)=>n>t?t:n<e?e:n;function Fr(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}var Ir=()=>{},Lr=()=>{};typeof process<`u`&&process.env.NODE_ENV!==`production`&&(Ir=(e,t,n)=>{!e&&typeof console<`u`&&console.warn(Fr(t,n))},Lr=(e,t,n)=>{if(!e)throw Error(Fr(t,n))});var Rr={},zr=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function Br(e){return typeof e==`object`&&!!e}var Vr=e=>/^0[^.\s]+$/u.test(e);function Hr(e){let t;return()=>(t===void 0&&(t=e()),t)}var Ur=e=>e,Wr=(e,t)=>n=>t(e(n)),Gr=(...e)=>e.reduce(Wr),Kr=(e,t,n)=>{let r=t-e;return r===0?1:(n-e)/r},qr=class{constructor(){this.subscriptions=[]}add(e){return Mr(this.subscriptions,e),()=>Nr(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}},Jr=e=>e*1e3,Yr=e=>e/1e3;function Xr(e,t){return t?1e3/t*e:0}var Zr=new Set;function Qr(e,t,n){e||Zr.has(t)||(console.warn(Fr(t,n)),Zr.add(t))}var $r=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ei=1e-7,ti=12;function ni(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=$r(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ei&&++s<ti);return o}function ri(e,t,n,r){if(e===t&&n===r)return Ur;let i=t=>ni(t,0,1,e,n);return e=>e===0||e===1?e:$r(i(e),t,r)}var ii=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,ai=e=>t=>1-e(1-t),oi=ri(.33,1.53,.69,.99),si=ai(oi),ci=ii(si),li=e=>e>=1?1:(e*=2)<1?.5*si(e):.5*(2-2**(-10*(e-1))),ui=e=>1-Math.sin(Math.acos(e)),di=ai(ui),fi=ii(ui),pi=ri(.42,0,1,1),mi=ri(0,0,.58,1),hi=ri(.42,0,.58,1),gi=e=>Array.isArray(e)&&typeof e[0]!=`number`,_i=e=>Array.isArray(e)&&typeof e[0]==`number`,vi={linear:Ur,easeIn:pi,easeInOut:hi,easeOut:mi,circIn:ui,circInOut:fi,circOut:di,backIn:si,backInOut:ci,backOut:oi,anticipate:li},yi=e=>typeof e==`string`,bi=e=>{if(_i(e)){Lr(e.length===4,`Cubic bezier arrays must contain four numerical values.`,`cubic-bezier-length`);let[t,n,r,i]=e;return ri(t,n,r,i)}else if(yi(e))return Lr(vi[e]!==void 0,`Invalid easing type '${e}'`,`invalid-easing-type`),vi[e];return e},xi=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`],Si={value:null,addProjectionMetrics:null};function Ci(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&&Si.value&&Si.value.frameloop[t].push(c),c=0,n.clear(),i=!1,a&&(a=!1,u.process(e))}};return u}var wi=40;function Ti(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=xi.reduce((e,n)=>(e[n]=Ci(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=Rr.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,wi),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:xi.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<xi.length;t++)o[xi[t]].cancel(e)},state:i,steps:o}}var{schedule:j,cancel:Ei,state:Di,steps:Oi}=Ti(typeof requestAnimationFrame<`u`?requestAnimationFrame:Ur,!0),ki;function Ai(){ki=void 0}var ji={now:()=>(ki===void 0&&ji.set(Di.isProcessing||Rr.useManualTiming?Di.timestamp:performance.now()),ki),set:e=>{ki=e,queueMicrotask(Ai)}},Mi={layout:0,mainThread:0,waapi:0},Ni=e=>t=>typeof t==`string`&&t.startsWith(e),Pi=Ni(`--`),Fi=Ni(`var(--`),Ii=e=>Fi(e)?Li.test(e.split(`/*`)[0].trim()):!1,Li=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ri(e){return typeof e==`string`?e.split(`/*`)[0].includes(`var(--`):!1}var zi={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},Bi={...zi,transform:e=>Pr(0,1,e)},Vi={...zi,default:1},Hi=e=>Math.round(e*1e5)/1e5,Ui=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Wi(e){return e==null}var Gi=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Ki=(e,t)=>n=>!!(typeof n==`string`&&Gi.test(n)&&n.startsWith(e)||t&&!Wi(n)&&Object.prototype.hasOwnProperty.call(n,t)),qi=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Ui);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},Ji=e=>Pr(0,255,e),Yi={...zi,transform:e=>Math.round(Ji(e))},Xi={test:Ki(`rgb`,`red`),parse:qi(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+Yi.transform(e)+`, `+Yi.transform(t)+`, `+Yi.transform(n)+`, `+Hi(Bi.transform(r))+`)`};function Zi(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:Ki(`#`),parse:Zi,transform:Xi.transform},$i=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),ea=$i(`deg`),ta=$i(`%`),M=$i(`px`),na=$i(`vh`),ra=$i(`vw`),ia={...ta,parse:e=>ta.parse(e)/100,transform:e=>ta.transform(e*100)},aa={test:Ki(`hsl`,`hue`),parse:qi(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ta.transform(Hi(t))+`, `+ta.transform(Hi(n))+`, `+Hi(Bi.transform(r))+`)`},oa={test:e=>Xi.test(e)||Qi.test(e)||aa.test(e),parse:e=>Xi.test(e)?Xi.parse(e):aa.test(e)?aa.parse(e):Qi.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?Xi.transform(e):aa.transform(e),getAnimatableNone:e=>{let t=oa.parse(e);return t.alpha=0,oa.transform(t)}},sa=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ca(e){return isNaN(e)&&typeof e==`string`&&(e.match(Ui)?.length||0)+(e.match(sa)?.length||0)>0}var la=`number`,ua=`color`,da=`var`,fa=`var(`,pa="${}",ma=/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 ha(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(ma,e=>(oa.test(e)?(r.color.push(a),i.push(ua),n.push(oa.parse(e))):e.startsWith(fa)?(r.var.push(a),i.push(da),n.push(e)):(r.number.push(a),i.push(la),n.push(parseFloat(e))),++a,pa)).split(pa),indexes:r,types:i}}function ga(e){return ha(e).values}function _a({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===la?i+=Hi(r[a]):e===ua?i+=oa.transform(r[a]):i+=r[a]}return i}}function va(e){return _a(ha(e))}var ya=e=>typeof e==`number`?0:oa.test(e)?oa.getAnimatableNone(e):e,ba=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:ya(e);function xa(e){let t=ha(e);return _a(t)(t.values.map((e,n)=>ba(e,t.split[n])))}var Sa={test:ca,parse:ga,createTransformer:va,getAnimatableNone:xa};function Ca(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 wa({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=Ca(s,r,e+1/3),a=Ca(s,r,e),o=Ca(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Ta(e,t){return n=>n>0?t:e}var Ea=(e,t,n)=>e+(t-e)*n,Da=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Oa=[Qi,Xi,aa],ka=e=>Oa.find(t=>t.test(e));function Aa(e){let t=ka(e);if(Ir(!!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===aa&&(n=wa(n)),n}var ja=(e,t)=>{let n=Aa(e),r=Aa(t);if(!n||!r)return Ta(e,t);let i={...n};return e=>(i.red=Da(n.red,r.red,e),i.green=Da(n.green,r.green,e),i.blue=Da(n.blue,r.blue,e),i.alpha=Ea(n.alpha,r.alpha,e),Xi.transform(i))},Ma=new Set([`none`,`hidden`]);function Na(e,t){return Ma.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Pa(e,t){return n=>Ea(e,t,n)}function Fa(e){return typeof e==`number`?Pa:typeof e==`string`?Ii(e)?Ta:oa.test(e)?ja:za:Array.isArray(e)?Ia:typeof e==`object`?oa.test(e)?ja:La:Ta}function Ia(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Fa(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function La(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Fa(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Ra(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 za=(e,t)=>{let n=Sa.createTransformer(t),r=ha(e),i=ha(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?Ma.has(e)&&!i.values.length||Ma.has(t)&&!r.values.length?Na(e,t):Gr(Ia(Ra(r,i),i.values),n):(Ir(!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`),Ta(e,t))};function Ba(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Ea(e,t,n):Fa(e)(e,t)}var Va=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>j.update(t,e),stop:()=>Ei(t),now:()=>Di.isProcessing?Di.timestamp:ji.now()}},Ha=(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)})`},Ua=2e4;function Wa(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 Ga(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Wa(r),Ua);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:Yr(i)}}var Ka={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 qa(e,t){return e*Math.sqrt(1-t*t)}var Ja=12;function Ya(e,t,n){let r=n;for(let n=1;n<Ja;n++)r-=e(r)/t(r);return r}var Xa=.001;function Za({duration:e=Ka.duration,bounce:t=Ka.bounce,velocity:n=Ka.velocity,mass:r=Ka.mass}){let i,a;Ir(e<=Jr(Ka.maxDuration),`Spring duration must be 10 seconds or less`,`spring-duration-limit`);let o=1-t;o=Pr(Ka.minDamping,Ka.maxDamping,o),e=Pr(Ka.minDuration,Ka.maxDuration,Yr(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=qa(t,o),c=Math.exp(-i);return Xa-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=qa(t**2,o);return(-i(t)+Xa>0?-1:1)*((a-s)*c)/l}):(i=t=>{let r=Math.exp(-t*e),i=(t-n)*e+1;return-Xa+r*i},a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=Ya(i,a,s);if(e=Jr(e),isNaN(c))return{stiffness:Ka.stiffness,damping:Ka.damping,duration:e};{let t=c**2*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var Qa=[`duration`,`bounce`],$a=[`stiffness`,`damping`,`mass`];function eo(e,t){return t.some(t=>e[t]!==void 0)}function to(e){let t={velocity:Ka.velocity,stiffness:Ka.stiffness,damping:Ka.damping,mass:Ka.mass,isResolvedFromDuration:!1,...e};if(!eo(e,$a)&&eo(e,Qa))if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*Pr(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:Ka.mass,stiffness:i,damping:a}}else{let n=Za({...e,velocity:0});t={...t,...n,mass:Ka.mass},t.isResolvedFromDuration=!0}return t}function no(e=Ka.visualDuration,t=Ka.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}=to({...n,velocity:-Yr(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=Yr(Math.sqrt(c/u)),v=Math.abs(g)<5;r||=v?Ka.restSpeed.granular:Ka.restSpeed.default,i||=v?Ka.restDelta.granular:Ka.restDelta.default;let y,b,x,S,ee,te;if(h<1)x=qa(_,h),S=(m+h*_*g)/x,y=e=>o-Math.exp(-h*_*e)*(S*Math.sin(x*e)+g*Math.cos(x*e)),ee=h*_*S+g*x,te=h*_*g-S*x,b=e=>Math.exp(-h*_*e)*(ee*Math.sin(x*e)+te*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 ne={calculatedDuration:p&&d||null,velocity:e=>Jr(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=Jr(t*(ee*n+te*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=Jr(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(Wa(ne),Ua),t=Ha(t=>ne.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return ne}no.applyToOptions=e=>{let t=Ga(e,100,no);return e.ease=t.ease,e.duration=Jr(t.duration),e.type=`keyframes`,e};var ro=5;function io(e,t,n){let r=Math.max(t-ro,0);return Xr(n-e(r),t-r)}function ao({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,ee=e=>{p(f.value)&&(x=e,S=no({keyframes:[f.value,m(f.value)],velocity:io(y,e,f.value),damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return ee(0),{calculatedDuration:null,next:e=>{let t=!1;return!S&&x===void 0&&(t=!0,b(e),ee(e)),x!==void 0&&e>=x?S.next(e-x):(!t&&b(e),f)}}}function oo(e,t,n){let r=[],i=n||Rr.mix||Ba,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=Gr(Array.isArray(t)?t[n]||Ur:t,a)),r.push(a)}return r}function so(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(Lr(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=oo(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=Kr(e[r],e[r+1],n);return s[r](i)};return n?t=>l(Pr(e[0],e[a-1],t)):l}function co(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=Kr(0,t,r);e.push(Ea(n,1,i))}}function lo(e){let t=[0];return co(t,e.length-1),t}function uo(e,t){return e.map(e=>e*t)}function fo(e,t){return e.map(()=>t||hi).splice(0,e.length-1)}function po({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=gi(r)?r.map(bi):bi(r),a={done:!1,value:t[0]},o=so(uo(n&&n.length===t.length?n:lo(t),e),t,{ease:Array.isArray(i)?i:fo(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var mo=e=>e!==null;function ho(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(mo),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var go={decay:ao,inertia:ao,tween:po,keyframes:po,spring:no};function _o(e){typeof e.type==`string`&&(e.type=go[e.type])}var vo=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)}},yo=e=>e/100,bo=class extends vo{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!==ji.now()&&this.tick(ji.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},Mi.mainThread++,this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;_o(e);let{type:t=po,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||po;process.env.NODE_ENV!==`production`&&s!==po&&Lr(o.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${o}`,`spring-two-frames`),s!==po&&typeof o[0]!=`number`&&(this.mixKeyframes=Gr(yo,Ba(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=Wa(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=Pr(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!==ao&&(b.value=ho(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 Yr(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Yr(e)}get time(){return Yr(this.currentTime)}set time(e){e=Jr(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 io(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(ji.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=Yr(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Va,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(ji.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,Mi.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 xo(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var So=e=>e*180/Math.PI,Co=e=>To(So(Math.atan2(e[1],e[0]))),wo={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:Co,rotateZ:Co,skewX:e=>So(Math.atan(e[1])),skewY:e=>So(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},To=e=>(e%=360,e<0&&(e+=360),e),Eo=Co,Do=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Oo=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),ko={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Do,scaleY:Oo,scale:e=>(Do(e)+Oo(e))/2,rotateX:e=>To(So(Math.atan2(e[6],e[5]))),rotateY:e=>To(So(Math.atan2(-e[2],e[0]))),rotateZ:Eo,rotate:Eo,skewX:e=>So(Math.atan(e[4])),skewY:e=>So(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ao(e){return e.includes(`scale`)?1:0}function jo(e,t){if(!e||e===`none`)return Ao(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=ko,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=wo,i=t}if(!i)return Ao(t);let a=r[t],o=i[1].split(`,`).map(No);return typeof a==`function`?a(o):o[a]}var Mo=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return jo(n,t)};function No(e){return parseFloat(e.trim())}var Po=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Fo=new Set(Po),Io=e=>e===zi||e===M,Lo=new Set([`x`,`y`,`z`]),Ro=Po.filter(e=>!Lo.has(e));function zo(e){let t=[];return Ro.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith(`scale`)?1:0))}),t}var Bo={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})=>jo(t,`x`),y:(e,{transform:t})=>jo(t,`y`)};Bo.translateX=Bo.x,Bo.translateY=Bo.y;var Vo=new Set,Ho=!1,Uo=!1,Wo=!1;function Go(){if(Uo){let e=Array.from(Vo).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=zo(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)})}Uo=!1,Ho=!1,Vo.forEach(e=>e.complete(Wo)),Vo.clear()}function Ko(){Vo.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Uo=!0)})}function qo(){Wo=!0,Ko(),Go(),Wo=!1}var Jo=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?(Vo.add(this),Ho||(Ho=!0,j.read(Ko),j.resolveKeyframes(Go))):(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])}xo(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Vo.delete(this)}cancel(){this.state===`scheduled`&&(Vo.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},Yo=e=>e.startsWith(`--`);function Xo(e,t,n){Yo(t)?e.style.setProperty(t,n):e.style[t]=n}var Zo={};function Qo(e,t){let n=Hr(e);return()=>Zo[t]??n()}var $o=Qo(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),es=Qo(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),ts=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,ns={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:ts([0,.65,.55,1]),circOut:ts([.55,0,1,.45]),backIn:ts([.31,.01,.66,-.59]),backOut:ts([.33,1.53,.69,.99])};function rs(e,t){if(e)return typeof e==`function`?es()?Ha(e,t):`ease-out`:_i(e)?ts(e):Array.isArray(e)?e.map(e=>rs(e,t)||ns.easeOut):ns[e]}function is(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=rs(s,i);Array.isArray(d)&&(u.easing=d),Si.value&&Mi.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 Si.value&&p.finished.finally(()=>{Mi.waapi--}),p}function as(e){return typeof e==`function`&&`applyToOptions`in e}function os({type:e,...t}){return as(e)&&es()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var ss=class extends vo{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,Lr(typeof e.type!=`string`,`Mini animate() doesn't support "type" as a string.`,`mini-spring`);let c=os(e);this.animation=is(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=ho(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),Xo(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 Yr(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+Yr(e)}get time(){return Yr(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=Jr(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&&$o()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),Ur):r(this)}},cs={anticipate:li,backInOut:ci,circInOut:fi};function ls(e){return e in cs}function us(e){typeof e.ease==`string`&&ls(e.ease)&&(e.ease=cs[e.ease])}var ds=10,fs=class extends ss{constructor(e){us(e),_o(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 bo({...a,autoplay:!1}),s=Math.max(ds,ji.now()-this.startTime),c=Pr(0,ds,s-ds),l=o.sample(s).value,{name:u}=this.options;i&&u&&Xo(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},ps=(e,t)=>t===`zIndex`?!1:!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(Sa.test(e)||e===`0`)&&!e.startsWith(`url(`));function ms(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 hs(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=ps(i,t),s=ps(a,t);return Ir(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:ms(e)||(n===`spring`||as(n))&&r}function gs(e){e.duration=0,e.type=`keyframes`}var _s=new Set([`opacity`,`clipPath`,`filter`,`transform`]),vs=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function ys(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&vs.test(e[t]))return!0;return!1}var bs=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),xs=Hr(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function Ss(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 xs()&&n&&(_s.has(n)||bs.has(n)&&ys(s))&&(n!==`transform`||!l)&&!c&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Cs=40,ws=class extends vo{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=ji.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||Jo)(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=ji.now();let u=!0;hs(e,i,a,o)||(u=!1,(Rr.instantAnimations||!s)&&l?.(ho(e,n,t)),e[0]=e[e.length-1],gs(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Cs?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&Ss(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new fs({...d,element:p})}catch{m=new bo(d)}else m=new bo(d);m.finished.then(()=>{this.notifyFinished()}).catch(Ur),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(),qo()),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 Ts(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 Es=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Ds(e){let t=Es.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}var Os=4;function ks(e,t,n=1){Lr(n<=Os,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,`max-css-var-depth`);let[r,i]=Ds(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return zr(e)?parseFloat(e):e}return Ii(i)?ks(i,t,n+1):i}var As={type:`spring`,stiffness:500,damping:25,restSpeed:10},js=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Ms={type:`keyframes`,duration:.8},Ns={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Ps=(e,{keyframes:t})=>t.length>2?Ms:Fo.has(e)?e.startsWith(`scale`)?js(t[1]):As:Ns;function Fs(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function Is(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Fs(n,e)}var Ls=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Rs(e){for(let t in e)if(!Ls.has(t))return!0;return!1}var zs=(e,t,n,r={},i,a)=>o=>{let s=Is(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=Jr(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};Rs(s)||Object.assign(u,Ps(e,u)),u.duration&&=Jr(u.duration),u.repeatDelay&&=Jr(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(gs(u),u.delay===0&&(d=!0)),(Rr.instantAnimations||Rr.skipAnimations||i?.shouldSkipAnimations)&&(d=!0,gs(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=ho(u.keyframes,s);if(e!==void 0){j.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new bo(u):new ws(u)};function Bs(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Vs(e,t,n,r){if(typeof t==`function`){let[i,a]=Bs(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]=Bs(r);t=t(n===void 0?e.custom:n,i,a)}return t}function Hs(e,t,n){let r=e.getProps();return Vs(r,t,n===void 0?r.custom:n,e)}var Us=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Po]),Ws=30,Gs=e=>!isNaN(parseFloat(e)),Ks={current:void 0},qs=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=ji.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=ji.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Gs(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 qr);let n=this.events[e].add(t);return e===`change`?()=>{n(),j.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 Ks.current&&Ks.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=ji.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Ws)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Ws);return Xr(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 Js(e,t){return new qs(e,t)}var Ys=e=>Array.isArray(e);function Xs(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Js(n))}function Zs(e){return Ys(e)?e[e.length-1]||0:e}function Qs(e,t){let{transitionEnd:n={},transition:r={},...i}=Hs(e,t)||{};i={...i,...n};for(let t in i)Xs(e,t,Zs(i[t]))}var $s=e=>!!(e&&e.getVelocity);function ec(e){return!!($s(e)&&e.add)}function tc(e,t){let n=e.getValue(`willChange`);if(ec(n))return n.add(t);if(!n&&Rr.WillChange){let n=new Rr.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function nc(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var rc=`data-`+nc(`framerAppearId`);function ic(e){return e.props[rc]}function ac({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function oc(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Fs(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&&ac(d,t))continue;let o={delay:n,...Is(a||{},t)},c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){j.update(()=>r.set(i));continue}let f=!1;if(window.MotionHandoffAnimation){let n=ic(e);if(n){let e=window.MotionHandoffAnimation(n,t,j);e!==null&&(o.startTime=e,f=!0)}}tc(e,t);let p=l??e.shouldReduceMotion;r.start(zs(t,r,i,p&&Us.has(t)?{type:!1}:o,e,f));let m=r.animation;m&&u.push(m)}if(o){let t=()=>j.update(()=>{o&&Qs(e,o)});u.length?Promise.all(u).then(t):t()}return u}function sc(e,t,n={}){let r=Hs(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(oc(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return cc(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 cc(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(sc(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Ts(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function lc(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>sc(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=sc(e,t,n);else{let i=typeof t==`function`?Hs(e,t,n.custom):t;r=Promise.all(oc(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var uc={test:e=>e===`auto`,parse:e=>e},dc=e=>t=>t.test(e),fc=[zi,M,ta,ea,ra,na,uc],pc=e=>fc.find(dc(e));function mc(e){return typeof e==`number`?e===0:e===null?!0:e===`none`||e===`0`||Vr(e)}var hc=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function gc(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Ui)||[];if(!r)return e;let i=n.replace(r,``),a=hc.has(t)?1:0;return r!==n&&(a*=100),t+`(`+a+i+`)`}var _c=/\b([a-z-]*)\(.*?\)/gu,vc={...Sa,getAnimatableNone:e=>{let t=e.match(_c);return t?t.map(gc).join(` `):e}},yc={...Sa,getAnimatableNone:e=>{let t=Sa.parse(e);return Sa.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},bc={...zi,transform:Math.round},xc={borderWidth:M,borderTopWidth:M,borderRightWidth:M,borderBottomWidth:M,borderLeftWidth:M,borderRadius:M,borderTopLeftRadius:M,borderTopRightRadius:M,borderBottomRightRadius:M,borderBottomLeftRadius:M,width:M,maxWidth:M,height:M,maxHeight:M,top:M,right:M,bottom:M,left:M,inset:M,insetBlock:M,insetBlockStart:M,insetBlockEnd:M,insetInline:M,insetInlineStart:M,insetInlineEnd:M,padding:M,paddingTop:M,paddingRight:M,paddingBottom:M,paddingLeft:M,paddingBlock:M,paddingBlockStart:M,paddingBlockEnd:M,paddingInline:M,paddingInlineStart:M,paddingInlineEnd:M,margin:M,marginTop:M,marginRight:M,marginBottom:M,marginLeft:M,marginBlock:M,marginBlockStart:M,marginBlockEnd:M,marginInline:M,marginInlineStart:M,marginInlineEnd:M,fontSize:M,backgroundPositionX:M,backgroundPositionY:M,rotate:ea,rotateX:ea,rotateY:ea,rotateZ:ea,scale:Vi,scaleX:Vi,scaleY:Vi,scaleZ:Vi,skew:ea,skewX:ea,skewY:ea,distance:M,translateX:M,translateY:M,translateZ:M,x:M,y:M,z:M,perspective:M,transformPerspective:M,opacity:Bi,originX:ia,originY:ia,originZ:M,zIndex:bc,fillOpacity:Bi,strokeOpacity:Bi,numOctaves:bc},Sc={...xc,color:oa,backgroundColor:oa,outlineColor:oa,fill:oa,stroke:oa,borderColor:oa,borderTopColor:oa,borderRightColor:oa,borderBottomColor:oa,borderLeftColor:oa,filter:vc,WebkitFilter:vc,mask:yc,WebkitMask:yc},Cc=e=>Sc[e],wc=new Set([vc,yc]);function Tc(e,t){let n=Cc(e);return wc.has(n)||(n=Sa),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Ec=new Set([`auto`,`none`,`0`]);function Dc(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Ec.has(t)&&ha(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Tc(n,i)}var Oc=class extends Jo{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(),Ii(r))){let i=ks(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!Us.has(n)||e.length!==2)return;let[r,i]=e,a=pc(r),o=pc(i);if(Ri(r)!==Ri(i)&&Bo[n]){this.needsMeasurement=!0;return}if(a!==o)if(Io(a)&&Io(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else Bo[n]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||mc(e[t]))&&n.push(t);n.length&&Dc(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=Bo[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]=Bo[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 kc(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 Ac=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function jc(e){return Br(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Mc,cancel:Nc}=Ti(queueMicrotask,!1),Pc={x:!1,y:!1};function Fc(){return Pc.x||Pc.y}function Ic(e){return e===`x`||e===`y`?Pc[e]?null:(Pc[e]=!0,()=>{Pc[e]=!1}):Pc.x||Pc.y?null:(Pc.x=Pc.y=!0,()=>{Pc.x=Pc.y=!1})}function Lc(e,t){let n=kc(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Rc(e){return!(e.pointerType===`touch`||Fc())}function zc(e,t,n={}){let[r,i,a]=Lc(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(!Rc(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 Bc=(e,t)=>t?e===t?!0:Bc(e,t.parentElement):!1,Vc=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Hc=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Uc(e){return Hc.has(e.tagName)||e.isContentEditable===!0}var Wc=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function Gc(e){return Wc.has(e.tagName)||e.isContentEditable===!0}var Kc=new WeakSet;function qc(e){return t=>{t.key===`Enter`&&e(t)}}function Jc(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var Yc=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=qc(()=>{if(Kc.has(n))return;Jc(n,`down`);let e=qc(()=>{Jc(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>Jc(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function Xc(e){return Vc(e)&&!Fc()}var Zc=new WeakSet;function Qc(e,t,n={}){let[r,i,a]=Lc(e,n),o=e=>{let r=e.currentTarget;if(!Xc(e)||Zc.has(e))return;Kc.add(r),n.stopPropagation&&Zc.add(e);let a=t(r,e),o=(e,t)=>{window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,c),Kc.has(r)&&Kc.delete(r),Xc(e)&&typeof a==`function`&&a(e,{success:t})},s=e=>{o(e,r===window||r===document||n.useGlobalTarget||Bc(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),jc(e)&&(e.addEventListener(`focus`,e=>Yc(e,i)),!Uc(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function $c(e){return Br(e)&&`ownerSVGElement`in e}var el=new WeakMap,tl,nl=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:$c(r)&&`getBBox`in r?r.getBBox()[t]:r[n],rl=nl(`inline`,`width`,`offsetWidth`),il=nl(`block`,`height`,`offsetHeight`);function al({target:e,borderBoxSize:t}){el.get(e)?.forEach(n=>{n(e,{get width(){return rl(e,t)},get height(){return il(e,t)}})})}function ol(e){e.forEach(al)}function sl(){typeof ResizeObserver>`u`||(tl=new ResizeObserver(ol))}function cl(e,t){tl||sl();let n=kc(e);return n.forEach(e=>{let n=el.get(e);n||(n=new Set,el.set(e,n)),n.add(t),tl?.observe(e)}),()=>{n.forEach(e=>{let n=el.get(e);n?.delete(t),n?.size||tl?.unobserve(e)})}}var ll=new Set,ul;function dl(){ul=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};ll.forEach(t=>t(e))},window.addEventListener(`resize`,ul)}function fl(e){return ll.add(e),ul||dl(),()=>{ll.delete(e),!ll.size&&typeof ul==`function`&&(window.removeEventListener(`resize`,ul),ul=void 0)}}function pl(e,t){return typeof e==`function`?fl(e):cl(e,t)}function ml(e){return $c(e)&&e.tagName===`svg`}var hl=[...fc,oa,Sa],gl=e=>hl.find(dc(e)),_l=()=>({translate:0,scale:1,origin:0,originPoint:0}),vl=()=>({x:_l(),y:_l()}),yl=()=>({min:0,max:0}),bl=()=>({x:yl(),y:yl()}),xl=new WeakMap;function Sl(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Cl(e){return typeof e==`string`||Array.isArray(e)}var wl=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Tl=[`initial`,...wl];function El(e){return Sl(e.animate)||Tl.some(t=>Cl(e[t]))}function Dl(e){return!!(El(e)||e.variants)}function Ol(e,t,n){for(let r in t){let i=t[r],a=n[r];if($s(i))e.addValue(r,i);else if($s(a))e.addValue(r,Js(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,Js(t===void 0?i:t,{owner:e}))}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var kl={current:null},Al={current:!1},jl=typeof window<`u`;function Ml(){if(Al.current=!0,jl)if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>kl.current=e.matches;e.addEventListener(`change`,t),t()}else kl.current=!1}var Nl=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Pl={};function Fl(e){Pl=e}function Il(){return Pl}var Ll=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=Jo,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=ji.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,j.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=El(t),this.isVariantNode=Dl(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&&$s(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,xl.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:(Al.current||Ml(),this.shouldReduceMotion=kl.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(),Ei(this.notifyUpdate),Ei(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&&_s.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new ss({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:Jr(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Fo.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&j.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 Pl){let t=Pl[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):bl()}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<Nl.length;t++){let n=Nl[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=Ol(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=Js(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`&&(zr(n)||Vr(n))?n=parseFloat(n):!gl(n)&&Sa.test(t)&&(n=Tc(e,t)),this.setBaseTarget(e,$s(n)?n.get():n)),$s(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=Vs(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&&!$s(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 qr),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Mc.render(this.render)}},Rl=class extends Ll{constructor(){super(...arguments),this.KeyframeResolver=Oc}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;$s(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},zl=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Bl({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Vl({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Hl(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 Ul(e){return e===void 0||e===1}function Wl({scale:e,scaleX:t,scaleY:n}){return!Ul(e)||!Ul(t)||!Ul(n)}function Gl(e){return Wl(e)||Kl(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Kl(e){return ql(e.x)||ql(e.y)}function ql(e){return e&&e!==`0%`}function Jl(e,t,n){return n+t*(e-n)}function Yl(e,t,n,r,i){return i!==void 0&&(e=Jl(e,i,r)),Jl(e,n,r)+t}function Xl(e,t=0,n=1,r,i){e.min=Yl(e.min,t,n,r,i),e.max=Yl(e.max,t,n,r,i)}function Zl(e,{x:t,y:n}){Xl(e.x,t.translate,t.scale,t.originPoint),Xl(e.y,n.translate,n.scale,n.originPoint)}var Ql=.999999999999,$l=1.0000000000001;function eu(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&&(tu(e.x,-a.scroll.offset.x),tu(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,Zl(e,o)),r&&Gl(a.latestValues)&&iu(e,a.latestValues,a.layout?.layoutBox))}t.x<$l&&t.x>Ql&&(t.x=1),t.y<$l&&t.y>Ql&&(t.y=1)}function tu(e,t){e.min+=t,e.max+=t}function nu(e,t,n,r,i=.5){Xl(e,t,n,Ea(e.min,e.max,i),r)}function ru(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function iu(e,t,n){let r=n??e;nu(e.x,ru(t.x,r.x),t.scaleX,t.scale,t.originX),nu(e.y,ru(t.y,r.y),t.scaleY,t.scale,t.originY)}function au(e,t){return Bl(Hl(e.getBoundingClientRect(),t))}function ou(e,t,n){let r=au(e,n),{scroll:i}=t;return i&&(tu(r.x,i.offset.x),tu(r.y,i.offset.y)),r}var su={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},cu=Po.length;function lu(e,t,n){let r=``,i=!0;for(let a=0;a<cu;a++){let o=Po[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=Ac(s,xc[o]);if(!c){i=!1;let t=su[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}return r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function uu(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(Fo.has(e)){o=!0;continue}else if(Pi(e)){i[e]=n;continue}else{let t=Ac(n,xc[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=lu(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 du(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 fu(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var pu={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`)if(M.test(e))e=parseFloat(e);else return e;return`${fu(e,t.target.x)}% ${fu(e,t.target.y)}%`}},mu={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=Sa.parse(e);if(i.length>5)return r;let a=Sa.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=Ea(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},hu={borderRadius:{...pu,applyTo:[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`]},borderTopLeftRadius:pu,borderTopRightRadius:pu,borderBottomLeftRadius:pu,borderBottomRightRadius:pu,boxShadow:mu};function gu(e,{layout:t,layoutId:n}){return Fo.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!hu[e]||e===`opacity`)}function _u(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)($s(r[t])||i&&$s(i[t])||gu(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function vu(e){return window.getComputedStyle(e)}var yu=class extends Rl{constructor(){super(...arguments),this.type=`html`,this.renderInstance=du}readValueFromInstance(e,t){if(Fo.has(t))return this.projection?.isProjecting?Ao(t):Mo(e,t);{let n=vu(e),r=(Pi(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return au(e,t)}build(e,t,n){uu(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return _u(e,t,n)}},bu={offset:`stroke-dashoffset`,array:`stroke-dasharray`},xu={offset:`strokeDashoffset`,array:`strokeDasharray`};function Su(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?bu:xu;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var Cu=[`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function wu(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(uu(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 Cu)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&&Su(d,i,a,o,!1)}var Tu=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`]),Eu=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Du(e,t,n,r){du(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Tu.has(n)?n:nc(n),t.attrs[n])}function Ou(e,t,n){let r=_u(e,t,n);for(let n in e)if($s(e[n])||$s(t[n])){let t=Po.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var ku=class extends Rl{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=bl}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Fo.has(t)){let e=Cc(t);return e&&e.default||0}return t=Tu.has(t)?t:nc(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Ou(e,t,n)}build(e,t,n){wu(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){Du(e,t,n,r)}mount(e){this.isSVGTag=Eu(e.tagName),super.mount(e)}},Au=Tl.length;function ju(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&ju(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Au;n++){let r=Tl[n],i=e.props[r];(Cl(i)||i===!1)&&(t[r]=i)}return t}function Mu(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 Nu=[...wl].reverse(),Pu=wl.length;function Fu(e){return t=>Promise.all(t.map(({animation:t,options:n})=>lc(e,t,n)))}function Iu(e){let t=Fu(e),n=zu(),r=!0,i=!1,a=t=>(n,r)=>{let i=Hs(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=ju(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<Pu;t++){let p=Nu[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=Cl(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||Sl(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=Lu(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],ee=S.reduce(a(p),{});_===!1&&(ee={});let{prevResolvedValues:te={}}=m,ne={...te,...ee},re=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 ne){let t=ee[e],n=te[e];if(d.hasOwnProperty(e))continue;let r=!1;r=Ys(t)&&Ys(n)?!Mu(t,n):t!==n,r?t==null?u.add(e):re(e):t!==void 0&&u.has(e)?re(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=ee,m.isActive&&(d={...d,...ee}),(r||i)&&e.blockInitialAnimation&&(b=!1);let C=v&&y;b&&(!C||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!C&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=Hs(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Ts(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=Hs(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=zu(),i=!0}}}function Lu(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Mu(t,e):!1}function Ru(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function zu(){return{animate:Ru(!0),whileInView:Ru(),whileHover:Ru(),whileTap:Ru(),whileDrag:Ru(),whileFocus:Ru(),exit:Ru()}}function Bu(e,t){e.min=t.min,e.max=t.max}function Vu(e,t){Bu(e.x,t.x),Bu(e.y,t.y)}function Hu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var Uu=1e-4,Wu=1-Uu,Gu=1+Uu,Ku=.01,qu=0-Ku,Ju=0+Ku;function Yu(e){return e.max-e.min}function Xu(e,t,n){return Math.abs(e-t)<=n}function Zu(e,t,n,r=.5){e.origin=r,e.originPoint=Ea(t.min,t.max,e.origin),e.scale=Yu(n)/Yu(t),e.translate=Ea(n.min,n.max,e.origin)-e.originPoint,(e.scale>=Wu&&e.scale<=Gu||isNaN(e.scale))&&(e.scale=1),(e.translate>=qu&&e.translate<=Ju||isNaN(e.translate))&&(e.translate=0)}function Qu(e,t,n,r){Zu(e.x,t.x,n.x,r?r.originX:void 0),Zu(e.y,t.y,n.y,r?r.originY:void 0)}function $u(e,t,n,r=0){e.min=(r?Ea(n.min,n.max,r):n.min)+t.min,e.max=e.min+Yu(t)}function ed(e,t,n,r){$u(e.x,t.x,n.x,r?.x),$u(e.y,t.y,n.y,r?.y)}function td(e,t,n,r=0){let i=r?Ea(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+Yu(t)}function nd(e,t,n,r){td(e.x,t.x,n.x,r?.x),td(e.y,t.y,n.y,r?.y)}function rd(e,t,n,r,i){return e-=t,e=Jl(e,1/n,r),i!==void 0&&(e=Jl(e,1/i,r)),e}function id(e,t=0,n=1,r=.5,i,a=e,o=e){if(ta.test(t)&&(t=parseFloat(t),t=Ea(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Ea(a.min,a.max,r);e===a&&(s-=t),e.min=rd(e.min,t,n,s,i),e.max=rd(e.max,t,n,s,i)}function ad(e,t,[n,r,i],a,o){id(e,t[n],t[r],t[i],t.scale,a,o)}var od=[`x`,`scaleX`,`originX`],sd=[`y`,`scaleY`,`originY`];function cd(e,t,n,r){ad(e.x,t,od,n?n.x:void 0,r?r.x:void 0),ad(e.y,t,sd,n?n.y:void 0,r?r.y:void 0)}function ld(e){return e.translate===0&&e.scale===1}function ud(e){return ld(e.x)&&ld(e.y)}function dd(e,t){return e.min===t.min&&e.max===t.max}function fd(e,t){return dd(e.x,t.x)&&dd(e.y,t.y)}function pd(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function md(e,t){return pd(e.x,t.x)&&pd(e.y,t.y)}function hd(e){return Yu(e.x)/Yu(e.y)}function gd(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function _d(e){return[e(`x`),e(`y`)]}function vd(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 yd=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomLeftRadius`,`borderBottomRightRadius`],bd=yd.length,xd=e=>typeof e==`string`?parseFloat(e):e,Sd=e=>typeof e==`number`||M.test(e);function Cd(e,t,n,r,i,a){i?(e.opacity=Ea(0,n.opacity??1,Td(r)),e.opacityExit=Ea(t.opacity??1,0,Ed(r))):a&&(e.opacity=Ea(t.opacity??1,n.opacity??1,r));for(let i=0;i<bd;i++){let a=yd[i],o=wd(t,a),s=wd(n,a);o===void 0&&s===void 0||(o||=0,s||=0,o===0||s===0||Sd(o)===Sd(s)?(e[a]=Math.max(Ea(xd(o),xd(s),r),0),(ta.test(s)||ta.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Ea(t.rotate||0,n.rotate||0,r))}function wd(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Td=Dd(0,.5,di),Ed=Dd(.5,.95,Ur);function Dd(e,t,n){return r=>r<e?0:r>t?1:n(Kr(e,t,r))}function Od(e,t,n){let r=$s(e)?e:Js(e);return r.start(zs(``,r,t,n)),r.animation}function kd(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}var Ad=(e,t)=>e.depth-t.depth,jd=class{constructor(){this.children=[],this.isDirty=!1}add(e){Mr(this.children,e),this.isDirty=!0}remove(e){Nr(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Ad),this.isDirty=!1,this.children.forEach(e)}};function Md(e,t){let n=ji.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Ei(r),e(a-t))};return j.setup(r,!0),()=>Ei(r)}function Nd(e){return $s(e)?e.get():e}var Pd=class{constructor(){this.members=[]}add(e){Mr(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&&(Nr(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(Nr(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)}},Fd={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Id={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Ld=[``,`X`,`Y`,`Z`],Rd=1e3,zd=0;function Bd(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Vd(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ic(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,j,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Vd(r)}function Hd({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=zd++,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,Si.value&&(Id.nodes=Id.calculatedTargetDeltas=Id.calculatedProjections=0),this.nodes.forEach(Gd),this.nodes.forEach(ef),this.nodes.forEach(tf),this.nodes.forEach(Kd),Si.addProjectionMetrics&&Si.addProjectionMetrics(Id)},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 jd)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new qr),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=$c(t)&&!ml(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;j.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=Md(i,250),Fd.hasAnimatedSinceResize&&(Fd.hasAnimatedSinceResize=!1,this.nodes.forEach($d)))})}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()||lf,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!md(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={...Is(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||$d(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(),Ei(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(nf),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&&Vd(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(Yd),this.nodes.forEach(Jd);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(Xd);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(Zd),this.nodes.forEach(Qd),this.nodes.forEach(Ud),this.nodes.forEach(Wd)):this.nodes.forEach(Xd),this.clearAllSnapshots();let e=ji.now();Di.delta=Pr(0,1e3/60,e-Di.timestamp),Di.timestamp=e,Di.isProcessing=!0,Oi.update.process(Di),Oi.preRender.process(Di),Oi.render.process(Di),Di.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Mc.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(qd),this.sharedNodes.forEach(rf)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,j.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){j.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Yu(this.snapshot.measuredBox.x)&&!Yu(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||=bl(),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&&!ud(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||Gl(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)),pf(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return bl();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(hf))){let{scroll:e}=this.root;e&&(tu(t.x,e.offset.x),tu(t.y,e.offset.y))}return t}removeElementScroll(e){let t=bl();if(Vu(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&&Vu(t,e),tu(t.x,i.offset.x),tu(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||bl();Vu(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&&(tu(r.x,-n.scroll.offset.x),tu(r.y,-n.scroll.offset.y)),Gl(n.latestValues)&&iu(r,n.latestValues,n.layout?.layoutBox)}return Gl(this.latestValues)&&iu(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=bl();Vu(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!Gl(n.latestValues))continue;let r;n.instance&&(Wl(n.latestValues)&&n.updateSnapshot(),r=bl(),Vu(r,n.measurePageBox())),cd(t,n.latestValues,n.snapshot?.layoutBox,r)}return Gl(this.latestValues)&&cd(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!==Di.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=Di.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=bl(),this.targetWithTransforms=bl()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),ed(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Vu(this.target,this.layout.layoutBox),Zl(this.target,this.targetDelta)):Vu(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),Si.value&&Id.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||Wl(this.parent.latestValues)||Kl(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=bl(),this.relativeTargetOrigin=bl(),nd(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Vu(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===Di.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;Vu(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;eu(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=bl());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Hu(this.prevProjectionDelta.x,this.projectionDelta.x),Hu(this.prevProjectionDelta.y,this.projectionDelta.y)),Qu(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!gd(this.projectionDelta.x,this.prevProjectionDelta.x)||!gd(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Si.value&&Id.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=vl(),this.projectionDelta=vl(),this.projectionDeltaWithTransform=vl()}setAnimationOrigin(e,t=!1){let n=this.snapshot,r=n?n.latestValues:{},i={...this.latestValues},a=vl();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let o=bl(),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(cf));this.animationProgress=0;let d;this.mixTargetDelta=t=>{let n=t/1e3;af(a.x,e.x,n),af(a.y,e.y,n),this.setTargetDelta(a),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(nd(o,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),sf(this.relativeTarget,this.relativeTargetOrigin,o,n),d&&fd(this.relativeTarget,d)&&(this.isProjectionDirty=!1),d||=bl(),Vu(d,this.relativeTarget)),s&&(this.animationValues=i,Cd(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&&=(Ei(this.pendingAnimation),void 0),this.pendingAnimation=j.update(()=>{Fd.hasAnimatedSinceResize=!0,Mi.layout++,this.motionValue||=Js(0),this.motionValue.jump(0,!1),this.currentAnimation=Od(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onStop:()=>{Mi.layout--},onComplete:()=>{Mi.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(Rd),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&&mf(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||bl();let t=Yu(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=Yu(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Vu(t,n),iu(t,i),Qu(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Pd),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&&Bd(`z`,e,r,this.animationValues);for(let t=0;t<Ld.length;t++)Bd(`rotate${Ld[t]}`,e,r,this.animationValues),Bd(`skew${Ld[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=Nd(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=Nd(t?.pointerEvents)||``),this.hasProjected&&!Gl(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=vd(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 hu){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=hu[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?Nd(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(Jd),this.root.sharedNodes.clear()}}}function Ud(e){e.updateLayout()}function Wd(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`)_d(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=Yu(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Bu(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else mf(i,t.layoutBox,n)&&_d(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=Yu(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=vl();Qu(o,n,t.layoutBox);let s=vl();a?Qu(s,e.applyTransform(r,!0),t.measuredBox):Qu(s,n,t.layoutBox);let c=!ud(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=bl();nd(s,t.layoutBox,i.layoutBox,o);let c=bl();nd(c,n,a.layoutBox,o),md(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 Gd(e){Si.value&&Id.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 Kd(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function qd(e){e.clearSnapshot()}function Jd(e){e.clearMeasurements()}function Yd(e){e.isLayoutDirty=!0,e.updateLayout()}function Xd(e){e.isLayoutDirty=!1}function Zd(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function Qd(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function $d(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function ef(e){e.resolveTargetDelta()}function tf(e){e.calcProjection()}function nf(e){e.resetSkewAndRotation()}function rf(e){e.removeLeadSnapshot()}function af(e,t,n){e.translate=Ea(t.translate,0,n),e.scale=Ea(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function of(e,t,n,r){e.min=Ea(t.min,n.min,r),e.max=Ea(t.max,n.max,r)}function sf(e,t,n,r){of(e.x,t.x,n.x,r),of(e.y,t.y,n.y,r)}function cf(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var lf={duration:.45,ease:[.4,0,.1,1]},uf=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),df=uf(`applewebkit/`)&&!uf(`chrome/`)?Math.round:Ur;function ff(e){e.min=df(e.min),e.max=df(e.max)}function pf(e){ff(e.x),ff(e.y)}function mf(e,t,n){return e===`position`||e===`preserve-aspect`&&!Xu(hd(t),hd(n),.2)}function hf(e){return e!==e.root&&e.scroll?.wasRoot}var gf=Hd({attachResizeListener:(e,t)=>kd(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),_f={current:void 0},vf=Hd({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!_f.current){let e=new gf({});e.mount(window),e.setOptions({layoutScroll:!0}),_f.current=e}return _f.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),yf=(0,d.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function bf(e=!0){let t=(0,d.useContext)(jr);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 xf=(0,d.createContext)({strict:!1}),Sf={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`]},Cf=!1;function wf(){if(Cf)return;let e={};for(let t in Sf)e[t]={isEnabled:e=>Sf[t].some(t=>!!e[t])};Fl(e),Cf=!0}function Tf(){return wf(),Il()}function Ef(e){let t=Tf();for(let n in e)t[n]={...t[n],...e[n]};Fl(t)}var Df=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 Of(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||Df.has(e)}var kf=s({default:()=>Af}),Af,jf=o((()=>{throw Af={},Error(`Could not resolve "@emotion/is-prop-valid" imported by "framer-motion". Is it installed?`)})),Mf=e=>!Of(e);function Nf(e){typeof e==`function`&&(Mf=t=>t.startsWith(`on`)?!Of(t):e(t))}try{Nf((jf(),u(kf)).default)}catch{}function Pf(e,t,n){let r={};for(let i in e)i===`values`&&typeof e.values==`object`||$s(e[i])||(Mf(i)||n===!0&&Of(i)||!t&&!Of(i)||e.draggable&&i.startsWith(`onDrag`))&&(r[i]=e[i]);return r}var Ff=(0,d.createContext)({});function If(e,t){if(El(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Cl(t)?t:void 0,animate:Cl(n)?n:void 0}}return e.inherit===!1?{}:t}function Lf(e){let{initial:t,animate:n}=If(e,(0,d.useContext)(Ff));return(0,d.useMemo)(()=>({initial:t,animate:n}),[Rf(t),Rf(n)])}function Rf(e){return Array.isArray(e)?e.join(` `):e}var zf=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Bf(e,t,n){for(let r in t)!$s(t[r])&&!gu(r,n)&&(e[r]=t[r])}function Vf({transformTemplate:e},t){return(0,d.useMemo)(()=>{let n=zf();return uu(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Hf(e,t){let n=e.style||{},r={};return Bf(r,n,e),Object.assign(r,Vf(e,t)),r}function Uf(e,t){let n={},r=Hf(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 Wf=()=>({...zf(),attrs:{}});function Gf(e,t,n,r){let i=(0,d.useMemo)(()=>{let n=Wf();return wu(n,t,Eu(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Bf(t,e.style,e),i.style={...t,...i.style}}return i}var Kf=[`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 qf(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(Kf.indexOf(e)>-1||/[A-Z]/u.test(e))}function Jf(e,t,n,{latestValues:r},i,a=!1,o){let s=(o??qf(e)?Gf:Uf)(t,r,i,e),c=Pf(t,typeof e==`string`,a),l=e===d.Fragment?{}:{...c,...s,ref:n},{children:u}=t,f=(0,d.useMemo)(()=>$s(u)?u.get():u,[u]);return(0,d.createElement)(e,{...l,children:f})}function Yf({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:Xf(n,r,i,e),renderState:t()}}function Xf(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Nd(a[e]);let{initial:o,animate:s}=e,c=El(e),l=Dl(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`&&!Sl(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Vs(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 Zf=e=>(t,n)=>{let r=(0,d.useContext)(Ff),i=(0,d.useContext)(jr),a=()=>Yf(e,t,r,i);return n?a():kr(a)},Qf=Zf({scrapeMotionValuesFromProps:_u,createRenderState:zf}),$f=Zf({scrapeMotionValuesFromProps:Ou,createRenderState:Wf}),ep=Symbol.for(`motionComponentSymbol`);function tp(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 np=(0,d.createContext)({});function rp(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function ip(e,t,n,r,i,a){let{visualElement:o}=(0,d.useContext)(Ff),s=(0,d.useContext)(xf),c=(0,d.useContext)(jr),l=(0,d.useContext)(yf),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)(np);h&&!h.projection&&i&&(h.type===`html`||h.type===`svg`)&&ap(p.current,n,i,g);let _=(0,d.useRef)(!1);(0,d.useInsertionEffect)(()=>{h&&_.current&&h.update(n,c)});let v=n[rc],y=(0,d.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return Ar(()=>{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 ap(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:op(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&rp(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function op(e){if(e)return e.options.allowProjection===!1?op(e.parent):e.projection}function sp(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Ef(r);let a=n?n===`svg`:qf(e),o=a?$f:Qf;function s(n,s){let c,l={...(0,d.useContext)(yf),...n,layoutId:cp(n)},{isStatic:u}=l,p=Lf(n),m=o(n,u);if(!u&&typeof window<`u`){lp(l,r);let t=up(l);c=t.MeasureLayout,p.visualElement=ip(e,m,l,i,t.ProjectionNode,a)}return(0,f.jsxs)(Ff.Provider,{value:p,children:[c&&p.visualElement?(0,f.jsx)(c,{visualElement:p.visualElement,...l}):null,Jf(e,n,tp(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[ep]=e,c}function cp({layoutId:e}){let t=(0,d.useContext)(Or).id;return t&&e!==void 0?t+`-`+e:e}function lp(e,t){let n=(0,d.useContext)(xf).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?Ir(!1,t,`lazy-strict-mode`):Lr(!1,t,`lazy-strict-mode`)}}function up(e){let{drag:t,layout:n}=Tf();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function dp(e,t){if(typeof Proxy>`u`)return sp;let n=new Map,r=(n,r)=>sp(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,sp(a,void 0,e,t)),n.get(a))})}var fp=(e,t)=>t.isSVG??qf(e)?new ku(t):new yu(t,{allowProjection:e!==d.Fragment}),pp=class extends zl{constructor(e){super(e),e.animationState||=Iu(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();Sl(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?.()}},mp=0,hp={animation:{Feature:pp},exit:{Feature:class extends zl{constructor(){super(...arguments),this.id=mp++,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=Hs(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 gp(e){return{point:{x:e.pageX,y:e.pageY}}}var _p=e=>t=>Vc(t)&&e(t,gp(t));function vp(e,t,n,r){return kd(e,t,_p(n),r)}var yp=({current:e})=>e?e.ownerDocument.defaultView:null,bp=(e,t)=>Math.abs(e-t);function xp(e,t){let n=bp(e.x,t.x),r=bp(e.y,t.y);return Math.sqrt(n**2+r**2)}var Sp=new Set([`auto`,`scroll`]),Cp=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=wp(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Ep(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=xp(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Di;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=wp(t,this.transformPagePoint),j.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=Ep(e.type===`pointercancel`?this.lastMoveEventInfo:wp(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Vc(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=wp(gp(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Di;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Ep(s,this.history)),this.removeListeners=Gr(vp(this.contextWindow,`pointermove`,this.handlePointerMove),vp(this.contextWindow,`pointerup`,this.handlePointerUp),vp(this.contextWindow,`pointercancel`,this.handlePointerUp)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Sp.has(e.overflowX)||Sp.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),j.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Ei(this.updatePoint)}};function wp(e,t){return t?{point:t(e.point)}:e}function Tp(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Ep({point:e},t){return{point:e,delta:Tp(e,Op(t)),offset:Tp(e,Dp(t)),velocity:kp(t,.1)}}function Dp(e){return e[0]}function Op(e){return e[e.length-1]}function kp(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Op(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>Jr(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>Jr(t)*2&&(r=e[1]);let a=Yr(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 Ap(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Ea(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Ea(n,e,r.max):Math.min(e,n)),e}function jp(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 Mp(e,{top:t,left:n,bottom:r,right:i}){return{x:jp(e.x,n,i),y:jp(e.y,t,r)}}function Np(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 Pp(e,t){return{x:Np(e.x,t.x),y:Np(e.y,t.y)}}function Fp(e,t){let n=.5,r=Yu(e),i=Yu(t);return i>r?n=Kr(t.min,t.max-r,e.min):r>i&&(n=Kr(e.min,e.max-i,t.min)),Pr(0,1,n)}function Ip(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 Lp=.35;function Rp(e=Lp){return e===!1?e=0:e===!0&&(e=Lp),{x:zp(e,`left`,`right`),y:zp(e,`top`,`bottom`)}}function zp(e,t,n){return{min:Bp(e,t),max:Bp(e,n)}}function Bp(e,t){return typeof e==`number`?e:e[t]||0}var Vp=new WeakMap,Hp=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=bl(),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(gp(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=Ic(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),_d(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ta.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=Yu(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&j.update(()=>i(e,t),!1,!0),tc(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=Kp(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&&j.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 Cp(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:yp(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&&j.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||!Gp(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Ap(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&&rp(e)?this.constraints||=this.resolveRefConstraints():e&&n?this.constraints=Mp(n.layoutBox,e):this.constraints=!1,this.elastic=Rp(t),r!==this.constraints&&!rp(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&_d(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Ip(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!rp(e))return!1;let n=e.current;Lr(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=ou(n,r.root,this.visualElement.getTransformPagePoint()),a=Pp(r.layout.layoutBox,i);if(t){let e=t(Vl(a));this.hasMutatedConstraints=!!e,e&&(a=Bl(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=_d(o=>{if(!Gp(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 tc(this.visualElement,e),n.start(zs(e,n,0,t,this.visualElement,!1))}stopAnimation(){_d(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){_d(t=>{let{drag:n}=this.getProps();if(!Gp(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]-Ea(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!rp(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};_d(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=Fp({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(),_d(t=>{if(!Gp(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Ea(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;Vp.set(this.visualElement,this);let e=this.visualElement.current,t=vp(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&Gc(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();rp(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=Wp(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),j.read(r);let o=kd(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(_d(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=Lp,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function Up(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function Wp(e,t,n){let r=pl(e,Up(n)),i=pl(t,Up(n));return()=>{r(),i()}}function Gp(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function Kp(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var qp=class extends zl{constructor(e){super(e),this.removeGroupControls=Ur,this.removeListeners=Ur,this.controls=new Hp(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Ur}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()}},Jp=e=>(t,n)=>{e&&j.update(()=>e(t,n),!1,!0)},Yp=class extends zl{constructor(){super(...arguments),this.removePointerDownListener=Ur}onPointerDown(e){this.session=new Cp(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:yp(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:Jp(e),onStart:Jp(t),onMove:Jp(n),onEnd:(e,t)=>{delete this.session,r&&j.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=vp(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},Xp=!1,Zp=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),Xp&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Fd.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}),Xp=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||j.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(),Mc.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;Xp=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function Qp(e){let[t,n]=bf(),r=(0,d.useContext)(Or);return(0,f.jsx)(Zp,{...e,layoutGroup:r,switchLayoutGroup:(0,d.useContext)(np),isPresent:t,safeToRemove:n})}var $p={pan:{Feature:Yp},drag:{Feature:qp,ProjectionNode:vf,MeasureLayout:Qp}};function em(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&j.postRender(()=>i(t,gp(t)))}var tm=class extends zl{mount(){let{current:e}=this.node;e&&(this.unmount=zc(e,(e,t)=>(em(this.node,t,`Start`),e=>em(this.node,e,`End`))))}unmount(){}},nm=class extends zl{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=Gr(kd(this.node.current,`focus`,()=>this.onFocus()),kd(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function rm(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&&j.postRender(()=>i(t,gp(t)))}var im=class extends zl{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=Qc(e,(e,t)=>(rm(this.node,t,`Start`),(e,{success:t})=>rm(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},am=new WeakMap,om=new WeakMap,sm=e=>{let t=am.get(e.target);t&&t(e)},cm=e=>{e.forEach(sm)};function lm({root:e,...t}){let n=e||document;om.has(n)||om.set(n,{});let r=om.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(cm,{root:e,...t})),r[i]}function um(e,t,n){let r=lm(t);return am.set(e,n),r.observe(e),()=>{am.delete(e),r.unobserve(e)}}var dm={some:0,all:1},fm=class extends zl{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:dm[r]};this.stopObserver=um(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(pm(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function pm({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var mm={inView:{Feature:fm},tap:{Feature:im},focus:{Feature:nm},hover:{Feature:tm}},hm={layout:{ProjectionNode:vf,MeasureLayout:Qp}},gm=dp({...hp,...mm,...$p,...hm},fp);function _m(e,t){return t.forEach(function(t){t&&typeof t!=`string`&&!Array.isArray(t)&&Object.keys(t).forEach(function(n){if(n!==`default`&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})}),Object.freeze(e)}var vm=Object.defineProperty,ym=(e,t,n)=>t in e?vm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bm=(e,t,n)=>ym(e,typeof t==`symbol`?t:t+``,n),xm=class{constructor(){bm(this,`_locking`),bm(this,`_locks`),this._locking=Promise.resolve(),this._locks=0}isLocked(){return this._locks>0}lock(){this._locks+=1;let e,t=new Promise(t=>e=()=>{--this._locks,t()}),n=this._locking.then(()=>e);return this._locking=this._locking.then(()=>t),n}};function Sm(e,t){if(!e)throw Error(t)}var Cm=34028234663852886e22,wm=-34028234663852886e22,Tm=4294967295,Em=2147483647,Dm=-2147483648;function Om(e){if(typeof e!=`number`)throw Error(`invalid int 32: `+typeof e);if(!Number.isInteger(e)||e>Em||e<Dm)throw Error(`invalid int 32: `+e)}function km(e){if(typeof e!=`number`)throw Error(`invalid uint 32: `+typeof e);if(!Number.isInteger(e)||e>Tm||e<0)throw Error(`invalid uint 32: `+e)}function Am(e){if(typeof e!=`number`)throw Error(`invalid float 32: `+typeof e);if(Number.isFinite(e)&&(e>Cm||e<wm))throw Error(`invalid float 32: `+e)}var jm=Symbol(`@bufbuild/protobuf/enum-type`);function Mm(e){let t=e[jm];return Sm(t,`missing enum type on enum object`),t}function Nm(e,t,n,r){e[jm]=Pm(t,n.map(t=>({no:t.no,name:t.name,localName:e[t.no]})))}function Pm(e,t,n){let r=Object.create(null),i=Object.create(null),a=[];for(let e of t){let t=Im(e);a.push(t),r[e.name]=t,i[e.no]=t}return{typeName:e,values:a,findName(e){return r[e]},findNumber(e){return i[e]}}}function Fm(e,t,n){let r={};for(let e of t){let t=Im(e);r[t.localName]=t.no,r[t.no]=t.localName}return Nm(r,e,t),r}function Im(e){return`localName`in e?e:Object.assign(Object.assign({},e),{localName:e.name})}var Lm=class{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){let n=this.getType().runtime.bin,r=n.makeReadOptions(t);return n.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){let n=this.getType(),r=n.runtime.json,i=r.makeReadOptions(t);return r.readMessage(n,e,i,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`cannot decode ${this.getType().typeName} from JSON: ${e instanceof Error?e.message:String(e)}`)}return this.fromJson(n,t)}toBinary(e){let t=this.getType().runtime.bin,n=t.makeWriteOptions(e),r=n.writerFactory();return t.writeMessage(this,r,n),r.finish()}toJson(e){let t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){let t=this.toJson(e);return JSON.stringify(t,null,e?.prettySpaces??0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}};function Rm(e,t,n,r){let i=r?.localName??t.substring(t.lastIndexOf(`.`)+1),a={[i]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[i];return Object.setPrototypeOf(a.prototype,new Lm),Object.assign(a,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary(e,t){return new a().fromBinary(e,t)},fromJson(e,t){return new a().fromJson(e,t)},fromJsonString(e,t){return new a().fromJsonString(e,t)},equals(t,n){return e.util.equals(a,t,n)}}),a}function zm(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function Bm(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}var Vm=4294967296;function Hm(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=Vm&&(i+=r/Vm|0,r%=Vm)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?qm(r,i):Km(r,i)}function Um(e,t){let n=Km(e,t),r=n.hi&2147483648;r&&(n=qm(n.lo,n.hi));let i=Wm(n.lo,n.hi);return r?`-`+i:i}function Wm(e,t){if({lo:e,hi:t}=Gm(e,t),t<=2097151)return String(Vm*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+Jm(o)+Jm(a)}function Gm(e,t){return{lo:e>>>0,hi:t>>>0}}function Km(e,t){return{lo:e|0,hi:t|0}}function qm(e,t){return t=~t,e?e=~e+1:t+=1,Km(e,t)}var Jm=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Ym(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Xm(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}function Zm(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`int64 invalid: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}let t=e=>Sm(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>Sm(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),t(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),n(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),t(e),Hm(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),n(e),Hm(e)},dec(e,t){return Um(e,t)},uDec(e,t){return Wm(e,t)}}}var Qm=Zm(),N;(function(e){e[e.DOUBLE=1]=`DOUBLE`,e[e.FLOAT=2]=`FLOAT`,e[e.INT64=3]=`INT64`,e[e.UINT64=4]=`UINT64`,e[e.INT32=5]=`INT32`,e[e.FIXED64=6]=`FIXED64`,e[e.FIXED32=7]=`FIXED32`,e[e.BOOL=8]=`BOOL`,e[e.STRING=9]=`STRING`,e[e.BYTES=12]=`BYTES`,e[e.UINT32=13]=`UINT32`,e[e.SFIXED32=15]=`SFIXED32`,e[e.SFIXED64=16]=`SFIXED64`,e[e.SINT32=17]=`SINT32`,e[e.SINT64=18]=`SINT64`})(N||={});var $m;(function(e){e[e.BIGINT=0]=`BIGINT`,e[e.STRING=1]=`STRING`})($m||={});function eh(e,t,n){if(t===n)return!0;if(e==N.BYTES){if(!(t instanceof Uint8Array)||!(n instanceof Uint8Array)||t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return t==n}return!1}function th(e,t){switch(e){case N.BOOL:return!1;case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return t==0?Qm.zero:`0`;case N.DOUBLE:case N.FLOAT:return 0;case N.BYTES:return new Uint8Array;case N.STRING:return``;default:return 0}}function nh(e,t){switch(e){case N.BOOL:return t===!1;case N.STRING:return t===``;case N.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return t==0}}var rh;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(rh||={});var ih=class{constructor(e){this.stack=[],this.textEncoder=e??new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(km(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return Om(e),Ym(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){Am(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){km(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Om(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Om(e),e=(e<<1^e>>31)>>>0,Ym(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Qm.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Qm.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=Qm.enc(e);return Bm(t.lo,t.hi,this.buf),this}sint64(e){let t=Qm.enc(e),n=t.hi>>31;return Bm(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Qm.uEnc(e);return Bm(t.lo,t.hi,this.buf),this}},ah=class{constructor(e,t){this.varint64=zm,this.uint32=Xm,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=t??new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case rh.Varint:for(;this.buf[this.pos++]&128;);break;case rh.Bit64:this.pos+=4;case rh.Bit32:this.pos+=4;break;case rh.LengthDelimited:let n=this.uint32();this.pos+=n;break;case rh.StartGroup:for(;;){let[e,n]=this.tag();if(n===rh.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(n,e)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Qm.dec(...this.varint64())}uint64(){return Qm.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Qm.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Qm.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Qm.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}};function oh(e,t,n,r){let i;return{typeName:t,extendee:n,get field(){if(!i){let n=typeof r==`function`?r():r;n.name=t.split(`.`).pop(),n.jsonName=`[${t}]`,i=e.util.newFieldList([n]).list()[0]}return i},runtime:e}}function sh(e){let t=e.field.localName,n=Object.create(null);return n[t]=ch(e),[n,()=>n[t]]}function ch(e){let t=e.field;if(t.repeated)return[];if(t.default!==void 0)return t.default;switch(t.kind){case`enum`:return t.T.values[0].no;case`scalar`:return th(t.T,t.L);case`message`:let e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case`map`:throw`map fields are not allowed to be extensions`}}function lh(e,t){if(!t.repeated&&(t.kind==`enum`||t.kind==`scalar`)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter(e=>e.no===t.no)}var uh=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`.split(``),dh=[];for(let e=0;e<uh.length;e++)dh[uh[e].charCodeAt(0)]=e;dh[45]=uh.indexOf(`+`),dh[95]=uh.indexOf(`/`);var fh={dec(e){let t=e.length*3/4;e[e.length-2]==`=`?t-=2:e[e.length-1]==`=`&&--t;let n=new Uint8Array(t),r=0,i=0,a,o=0;for(let t=0;t<e.length;t++){if(a=dh[e.charCodeAt(t)],a===void 0)switch(e[t]){case`=`:i=0;case`
|
|
26
26
|
`:case`\r`:case` `:case` `:continue;default:throw Error(`invalid base64 string.`)}switch(i){case 0:o=a,i=1;break;case 1:n[r++]=o<<2|(a&48)>>4,o=a,i=2;break;case 2:n[r++]=(o&15)<<4|(a&60)>>2,o=a,i=3;break;case 3:n[r++]=(o&3)<<6|a,i=0;break}}if(i==1)throw Error(`invalid base64 string.`);return n.subarray(0,r)},enc(e){let t=``,n=0,r,i=0;for(let a=0;a<e.length;a++)switch(r=e[a],n){case 0:t+=uh[r>>2],i=(r&3)<<4,n=1;break;case 1:t+=uh[i|r>>4],i=(r&15)<<2,n=2;break;case 2:t+=uh[i|r>>6],t+=uh[r&63],n=0;break}return n&&(t+=uh[i],t+=`=`,n==1&&(t+=`=`)),t}};function ph(e,t,n){gh(t,e);let r=t.runtime.bin.makeReadOptions(n),i=lh(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,o]=sh(t);for(let e of i)t.runtime.bin.readField(a,r.readerFactory(e.data),t.field,e.wireType,r);return o()}function mh(e,t,n,r){gh(t,e);let i=t.runtime.bin.makeReadOptions(r),a=t.runtime.bin.makeWriteOptions(r);if(hh(e,t)){let n=e.getType().runtime.bin.listUnknownFields(e).filter(e=>e.no!=t.field.no);e.getType().runtime.bin.discardUnknownFields(e);for(let t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}let o=a.writerFactory(),s=t.field;!s.opt&&!s.repeated&&(s.kind==`enum`||s.kind==`scalar`)&&(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,o,a);let c=i.readerFactory(o.finish());for(;c.pos<c.len;){let[t,n]=c.tag(),r=c.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,r)}}function hh(e,t){let n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find(e=>e.no==t.field.no)}function gh(e,t){Sm(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function _h(e,t){let n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case`enum`:case`scalar`:return e.opt||e.req?t[n]!==void 0:e.kind==`enum`?t[n]!==e.T.values[0].no:!nh(e.T,t[n]);case`message`:return t[n]!==void 0;case`map`:return Object.keys(t[n]).length>0}}function vh(e,t){let n=e.localName,r=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case`map`:t[n]={};break;case`enum`:t[n]=r?e.T.values[0].no:void 0;break;case`scalar`:t[n]=r?th(e.T,e.L):void 0;break;case`message`:t[n]=void 0;break}}function yh(e,t){if(typeof e!=`object`||!e||!Object.getOwnPropertyNames(Lm.prototype).every(t=>t in e&&typeof e[t]==`function`))return!1;let n=e.getType();return n===null||typeof n!=`function`||!(`typeName`in n)||typeof n.typeName!=`string`?!1:t===void 0?!0:n.typeName==t.typeName}function bh(e,t){return yh(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}N.DOUBLE,N.FLOAT,N.INT64,N.UINT64,N.INT32,N.UINT32,N.BOOL,N.STRING,N.BYTES;var xh={ignoreUnknownFields:!1},Sh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Ch(e){return e?Object.assign(Object.assign({},xh),e):xh}function wh(e){return e?Object.assign(Object.assign({},Sh),e):Sh}var Th=Symbol(),Eh=Symbol();function Dh(){return{makeReadOptions:Ch,makeWriteOptions:wh,readMessage(e,t,n,r){if(t==null||Array.isArray(t)||typeof t!=`object`)throw Error(`cannot decode message ${e.typeName} from JSON: ${Oh(t)}`);r??=new e;let i=new Map,a=n.typeRegistry;for(let[o,s]of Object.entries(t)){let t=e.fields.findJsonName(o);if(t){if(t.oneof){if(s===null&&t.kind==`scalar`)continue;let n=i.get(t.oneof);if(n!==void 0)throw Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${o}"`);i.set(t.oneof,o)}kh(r,s,t,n,e)}else{let t=!1;if(a?.findExtension&&o.startsWith(`[`)&&o.endsWith(`]`)){let i=a.findExtension(o.substring(1,o.length-1));if(i&&i.extendee.typeName==e.typeName){t=!0;let[e,a]=sh(i);kh(e,s,i.field,n,i),mh(r,i,a(),n)}}if(!t&&!n.ignoreUnknownFields)throw Error(`cannot decode message ${e.typeName} from JSON: key "${o}" is unknown`)}}return r},writeMessage(e,t){let n=e.getType(),r={},i;try{for(i of n.fields.byNumber()){if(!_h(i,e)){if(i.req)throw`required field not set`;if(!t.emitDefaultValues||!Nh(i))continue}let n=i.oneof?e[i.oneof.localName].value:e[i.localName],a=Ph(i,n,t);a!==void 0&&(r[t.useProtoFieldName?i.name:i.jsonName]=a)}let a=t.typeRegistry;if(a?.findExtensionFor)for(let i of n.runtime.bin.listUnknownFields(e)){let o=a.findExtensionFor(n.typeName,i.no);if(o&&hh(e,o)){let n=ph(e,o,t),i=Ph(o.field,n,t);i!==void 0&&(r[o.field.jsonName]=i)}}}catch(e){let t=i?`cannot encode field ${n.typeName}.${i.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,r=e instanceof Error?e.message:String(e);throw Error(t+(r.length>0?`: ${r}`:``))}return r},readScalar(e,t,n){return jh(e,t,n??$m.BIGINT,!0)},writeScalar(e,t,n){if(t!==void 0&&(n||nh(e,t)))return Ih(e,t)},debug:Oh}}function Oh(e){if(e===null)return`null`;switch(typeof e){case`object`:return Array.isArray(e)?`array`:`object`;case`string`:return e.length>100?`string`:`"${e.split(`"`).join(`\\"`)}"`;default:return String(e)}}function kh(e,t,n,r,i){let a=n.localName;if(n.repeated){if(Sm(n.kind!=`map`),t===null)return;if(!Array.isArray(t))throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${Oh(t)}`);let o=e[a];for(let e of t){if(e===null)throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${Oh(e)}`);switch(n.kind){case`message`:o.push(n.T.fromJson(e,r));break;case`enum`:let t=Mh(n.T,e,r.ignoreUnknownFields,!0);t!==Eh&&o.push(t);break;case`scalar`:try{o.push(jh(n.T,e,n.L,!0))}catch(t){let r=`cannot decode field ${i.typeName}.${n.name} from JSON: ${Oh(e)}`;throw t instanceof Error&&t.message.length>0&&(r+=`: ${t.message}`),Error(r)}break}}}else if(n.kind==`map`){if(t===null)return;if(typeof t!=`object`||Array.isArray(t))throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: ${Oh(t)}`);let o=e[a];for(let[e,a]of Object.entries(t)){if(a===null)throw Error(`cannot decode field ${i.typeName}.${n.name} from JSON: map value null`);let s;try{s=Ah(n.K,e)}catch(e){let r=`cannot decode map key for field ${i.typeName}.${n.name} from JSON: ${Oh(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r)}switch(n.V.kind){case`message`:o[s]=n.V.T.fromJson(a,r);break;case`enum`:let e=Mh(n.V.T,a,r.ignoreUnknownFields,!0);e!==Eh&&(o[s]=e);break;case`scalar`:try{o[s]=jh(n.V.T,a,$m.BIGINT,!0)}catch(e){let r=`cannot decode map value for field ${i.typeName}.${n.name} from JSON: ${Oh(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r)}break}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:a},a=`value`),n.kind){case`message`:let o=n.T;if(t===null&&o.typeName!=`google.protobuf.Value`)return;let s=e[a];yh(s)?s.fromJson(t,r):(e[a]=s=o.fromJson(t,r),o.fieldWrapper&&!n.oneof&&(e[a]=o.fieldWrapper.unwrapField(s)));break;case`enum`:let c=Mh(n.T,t,r.ignoreUnknownFields,!1);switch(c){case Th:vh(n,e);break;case Eh:break;default:e[a]=c;break}break;case`scalar`:try{let r=jh(n.T,t,n.L,!1);switch(r){case Th:vh(n,e);break;default:e[a]=r;break}}catch(e){let r=`cannot decode field ${i.typeName}.${n.name} from JSON: ${Oh(t)}`;throw e instanceof Error&&e.message.length>0&&(r+=`: ${e.message}`),Error(r)}break}}function Ah(e,t){if(e===N.BOOL)switch(t){case`true`:t=!0;break;case`false`:t=!1;break}return jh(e,t,$m.BIGINT,!0).toString()}function jh(e,t,n,r){if(t===null)return r?th(e,n):Th;switch(e){case N.DOUBLE:case N.FLOAT:if(t===`NaN`)return NaN;if(t===`Infinity`)return 1/0;if(t===`-Infinity`)return-1/0;if(t===``||typeof t==`string`&&t.trim().length!==t.length||typeof t!=`string`&&typeof t!=`number`)break;let r=Number(t);if(Number.isNaN(r)||!Number.isFinite(r))break;return e==N.FLOAT&&Am(r),r;case N.INT32:case N.FIXED32:case N.SFIXED32:case N.SINT32:case N.UINT32:let i;if(typeof t==`number`?i=t:typeof t==`string`&&t.length>0&&t.trim().length===t.length&&(i=Number(t)),i===void 0)break;return e==N.UINT32||e==N.FIXED32?km(i):Om(i),i;case N.INT64:case N.SFIXED64:case N.SINT64:if(typeof t!=`number`&&typeof t!=`string`)break;let a=Qm.parse(t);return n?a.toString():a;case N.FIXED64:case N.UINT64:if(typeof t!=`number`&&typeof t!=`string`)break;let o=Qm.uParse(t);return n?o.toString():o;case N.BOOL:if(typeof t!=`boolean`)break;return t;case N.STRING:if(typeof t!=`string`)break;return t;case N.BYTES:if(t===``)return new Uint8Array;if(typeof t!=`string`)break;return fh.dec(t)}throw Error()}function Mh(e,t,n,r){if(t===null)return e.typeName==`google.protobuf.NullValue`?0:r?e.values[0].no:Th;switch(typeof t){case`number`:if(Number.isInteger(t))return t;break;case`string`:let r=e.findName(t);if(r!==void 0)return r.no;if(n)return Eh;break}throw Error(`cannot decode enum ${e.typeName} from JSON: ${Oh(t)}`)}function Nh(e){return e.repeated||e.kind==`map`?!0:!(e.oneof||e.kind==`message`||e.opt||e.req)}function Ph(e,t,n){if(e.kind==`map`){Sm(typeof t==`object`&&!!t);let r={},i=Object.entries(t);switch(e.V.kind){case`scalar`:for(let[t,n]of i)r[t.toString()]=Ih(e.V.T,n);break;case`message`:for(let[e,t]of i)r[e.toString()]=t.toJson(n);break;case`enum`:let t=e.V.T;for(let[e,a]of i)r[e.toString()]=Fh(t,a,n.enumAsInteger);break}return n.emitDefaultValues||i.length>0?r:void 0}if(e.repeated){Sm(Array.isArray(t));let r=[];switch(e.kind){case`scalar`:for(let n=0;n<t.length;n++)r.push(Ih(e.T,t[n]));break;case`enum`:for(let i=0;i<t.length;i++)r.push(Fh(e.T,t[i],n.enumAsInteger));break;case`message`:for(let e=0;e<t.length;e++)r.push(t[e].toJson(n));break}return n.emitDefaultValues||r.length>0?r:void 0}switch(e.kind){case`scalar`:return Ih(e.T,t);case`enum`:return Fh(e.T,t,n.enumAsInteger);case`message`:return bh(e.T,t).toJson(n)}}function Fh(e,t,n){return Sm(typeof t==`number`),e.typeName==`google.protobuf.NullValue`?null:n?t:e.findNumber(t)?.name??t}function Ih(e,t){switch(e){case N.INT32:case N.SFIXED32:case N.SINT32:case N.FIXED32:case N.UINT32:return Sm(typeof t==`number`),t;case N.FLOAT:case N.DOUBLE:return Sm(typeof t==`number`),Number.isNaN(t)?`NaN`:t===1/0?`Infinity`:t===-1/0?`-Infinity`:t;case N.STRING:return Sm(typeof t==`string`),t;case N.BOOL:return Sm(typeof t==`boolean`),t;case N.UINT64:case N.FIXED64:case N.INT64:case N.SFIXED64:case N.SINT64:return Sm(typeof t==`bigint`||typeof t==`string`||typeof t==`number`),t.toString();case N.BYTES:return Sm(t instanceof Uint8Array),fh.enc(t)}}var Lh=Symbol(`@bufbuild/protobuf/unknown-fields`),Rh={readUnknownFields:!0,readerFactory:e=>new ah(e)},zh={writeUnknownFields:!0,writerFactory:()=>new ih};function Bh(e){return e?Object.assign(Object.assign({},Rh),e):Rh}function Vh(e){return e?Object.assign(Object.assign({},zh),e):zh}function Hh(){return{makeReadOptions:Bh,makeWriteOptions:Vh,listUnknownFields(e){return e[Lh]??[]},discardUnknownFields(e){delete e[Lh]},writeUnknownFields(e,t){let n=e[Lh];if(n)for(let e of n)t.tag(e.no,e.wireType).raw(e.data)},onUnknownField(e,t,n,r){let i=e;Array.isArray(i[Lh])||(i[Lh]=[]),i[Lh].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,i){let a=e.getType(),o=i?t.len:t.pos+n,s,c;for(;t.pos<o&&([s,c]=t.tag(),!(i===!0&&c==rh.EndGroup));){let n=a.fields.find(s);if(!n){let n=t.skip(c,s);r.readUnknownFields&&this.onUnknownField(e,s,c,n);continue}Uh(e,t,n,c,r)}if(i&&(c!=rh.EndGroup||s!==n))throw Error(`invalid end group tag`)},readField:Uh,writeMessage(e,t,n){let r=e.getType();for(let i of r.fields.byNumber()){if(!_h(i,e)){if(i.req)throw Error(`cannot encode field ${r.typeName}.${i.name} to binary: required field not set`);continue}Jh(i,i.oneof?e[i.oneof.localName].value:e[i.localName],t,n)}return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,r){t!==void 0&&Jh(e,t,n,r)}}}function Uh(e,t,n,r,i){let{repeated:a,localName:o}=n;switch(n.oneof&&(e=e[n.oneof.localName],e.case!=o&&delete e.value,e.case=o,o=`value`),n.kind){case`scalar`:case`enum`:let s=n.kind==`enum`?N.INT32:n.T,c=qh;if(n.kind==`scalar`&&n.L>0&&(c=Kh),a){let n=e[o];if(r==rh.LengthDelimited&&s!=N.STRING&&s!=N.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(c(t,s))}else n.push(c(t,s))}else e[o]=c(t,s);break;case`message`:let l=n.T;a?e[o].push(Wh(t,new l,i,n)):yh(e[o])?Wh(t,e[o],i,n):(e[o]=Wh(t,new l,i,n),l.fieldWrapper&&!n.oneof&&!n.repeated&&(e[o]=l.fieldWrapper.unwrapField(e[o])));break;case`map`:let[u,d]=Gh(n,t,i);e[o][u]=d;break}}function Wh(e,t,n,r){let i=t.getType().runtime.bin,a=r?.delimited;return i.readMessage(t,e,a?r.no:e.uint32(),n,a),t}function Gh(e,t,n){let r=t.uint32(),i=t.pos+r,a,o;for(;t.pos<i;){let[r]=t.tag();switch(r){case 1:a=qh(t,e.K);break;case 2:switch(e.V.kind){case`scalar`:o=qh(t,e.V.T);break;case`enum`:o=t.int32();break;case`message`:o=Wh(t,new e.V.T,n,void 0);break}break}}if(a===void 0&&(a=th(e.K,$m.BIGINT)),typeof a!=`string`&&typeof a!=`number`&&(a=a.toString()),o===void 0)switch(e.V.kind){case`scalar`:o=th(e.V.T,$m.BIGINT);break;case`enum`:o=e.V.T.values[0].no;break;case`message`:o=new e.V.T;break}return[a,o]}function Kh(e,t){let n=qh(e,t);return typeof n==`bigint`?n.toString():n}function qh(e,t){switch(t){case N.STRING:return e.string();case N.BOOL:return e.bool();case N.DOUBLE:return e.double();case N.FLOAT:return e.float();case N.INT32:return e.int32();case N.INT64:return e.int64();case N.UINT64:return e.uint64();case N.FIXED64:return e.fixed64();case N.BYTES:return e.bytes();case N.FIXED32:return e.fixed32();case N.SFIXED32:return e.sfixed32();case N.SFIXED64:return e.sfixed64();case N.SINT64:return e.sint64();case N.UINT32:return e.uint32();case N.SINT32:return e.sint32()}}function Jh(e,t,n,r){Sm(t!==void 0);let i=e.repeated;switch(e.kind){case`scalar`:case`enum`:let a=e.kind==`enum`?N.INT32:e.T;if(i)if(Sm(Array.isArray(t)),e.packed)Qh(n,a,e.no,t);else for(let r of t)Zh(n,a,e.no,r);else Zh(n,a,e.no,t);break;case`message`:if(i){Sm(Array.isArray(t));for(let i of t)Xh(n,r,e,i)}else Xh(n,r,e,t);break;case`map`:Sm(typeof t==`object`&&!!t);for(let[i,a]of Object.entries(t))Yh(n,r,e,i,a);break}}function Yh(e,t,n,r,i){e.tag(n.no,rh.LengthDelimited),e.fork();let a=r;switch(n.K){case N.INT32:case N.FIXED32:case N.UINT32:case N.SFIXED32:case N.SINT32:a=Number.parseInt(r);break;case N.BOOL:Sm(r==`true`||r==`false`),a=r==`true`;break}switch(Zh(e,n.K,1,a),n.V.kind){case`scalar`:Zh(e,n.V.T,2,i);break;case`enum`:Zh(e,N.INT32,2,i);break;case`message`:Sm(i!==void 0),e.tag(2,rh.LengthDelimited).bytes(i.toBinary(t));break}e.join()}function Xh(e,t,n,r){let i=bh(n.T,r);n.delimited?e.tag(n.no,rh.StartGroup).raw(i.toBinary(t)).tag(n.no,rh.EndGroup):e.tag(n.no,rh.LengthDelimited).bytes(i.toBinary(t))}function Zh(e,t,n,r){Sm(r!==void 0);let[i,a]=$h(t);e.tag(n,i)[a](r)}function Qh(e,t,n,r){if(!r.length)return;e.tag(n,rh.LengthDelimited).fork();let[,i]=$h(t);for(let t=0;t<r.length;t++)e[i](r[t]);e.join()}function $h(e){let t=rh.Varint;switch(e){case N.BYTES:case N.STRING:t=rh.LengthDelimited;break;case N.DOUBLE:case N.FIXED64:case N.SFIXED64:t=rh.Bit64;break;case N.FIXED32:case N.SFIXED32:case N.FLOAT:t=rh.Bit32;break}let n=N[e].toLowerCase();return[t,n]}function eg(){return{setEnumType:Nm,initPartial(e,t){if(e===void 0)return;let n=t.getType();for(let r of n.fields.byMember()){let n=r.localName,i=t,a=e;if(a[n]!=null)switch(r.kind){case`oneof`:let e=a[n].case;if(e===void 0)continue;let t=r.findField(e),o=a[n].value;t&&t.kind==`message`&&!yh(o,t.T)?o=new t.T(o):t&&t.kind===`scalar`&&t.T===N.BYTES&&(o=ng(o)),i[n]={case:e,value:o};break;case`scalar`:case`enum`:let s=a[n];r.T===N.BYTES&&(s=r.repeated?s.map(ng):ng(s)),i[n]=s;break;case`map`:switch(r.V.kind){case`scalar`:case`enum`:if(r.V.T===N.BYTES)for(let[e,t]of Object.entries(a[n]))i[n][e]=ng(t);else Object.assign(i[n],a[n]);break;case`message`:let e=r.V.T;for(let t of Object.keys(a[n])){let r=a[n][t];e.fieldWrapper||(r=new e(r)),i[n][t]=r}break}break;case`message`:let c=r.T;if(r.repeated)i[n]=a[n].map(e=>yh(e,c)?e:new c(e));else{let e=a[n];c.fieldWrapper?c.typeName===`google.protobuf.BytesValue`?i[n]=ng(e):i[n]=e:i[n]=yh(e,c)?e:new c(e)}break}}},equals(e,t,n){return t===n?!0:!t||!n?!1:e.fields.byMember().every(e=>{let r=t[e.localName],i=n[e.localName];if(e.repeated){if(r.length!==i.length)return!1;switch(e.kind){case`message`:return r.every((t,n)=>e.T.equals(t,i[n]));case`scalar`:return r.every((t,n)=>eh(e.T,t,i[n]));case`enum`:return r.every((e,t)=>eh(N.INT32,e,i[t]))}throw Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case`message`:let t=r,n=i;return e.T.fieldWrapper&&(t!==void 0&&!yh(t)&&(t=e.T.fieldWrapper.wrapField(t)),n!==void 0&&!yh(n)&&(n=e.T.fieldWrapper.wrapField(n))),e.T.equals(t,n);case`enum`:return eh(N.INT32,r,i);case`scalar`:return eh(e.T,r,i);case`oneof`:if(r.case!==i.case)return!1;let a=e.findField(r.case);if(a===void 0)return!0;switch(a.kind){case`message`:return a.T.equals(r.value,i.value);case`enum`:return eh(N.INT32,r.value,i.value);case`scalar`:return eh(a.T,r.value,i.value)}throw Error(`oneof cannot contain ${a.kind}`);case`map`:let o=Object.keys(r).concat(Object.keys(i));switch(e.V.kind){case`message`:let t=e.V.T;return o.every(e=>t.equals(r[e],i[e]));case`enum`:return o.every(e=>eh(N.INT32,r[e],i[e]));case`scalar`:let n=e.V.T;return o.every(e=>eh(n,r[e],i[e]))}break}})},clone(e){let t=e.getType(),n=new t,r=n;for(let n of t.fields.byMember()){let t=e[n.localName],i;if(n.repeated)i=t.map(tg);else if(n.kind==`map`){i=r[n.localName];for(let[e,n]of Object.entries(t))i[e]=tg(n)}else i=n.kind==`oneof`?n.findField(t.case)?{case:t.case,value:tg(t.value)}:{case:void 0}:tg(t);r[n.localName]=i}for(let n of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,n.no,n.wireType,n.data);return n}}}function tg(e){if(e===void 0)return e;if(yh(e))return e.clone();if(e instanceof Uint8Array){let t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function ng(e){return e instanceof Uint8Array?e:new Uint8Array(e)}function rg(e,t,n){return{syntax:e,json:Dh(),bin:Hh(),util:Object.assign(Object.assign({},eg()),{newFieldList:t,initFields:n}),makeMessageType(e,t,n){return Rm(this,e,t,n)},makeEnum:Fm,makeEnumType:Pm,getEnumType:Mm,makeExtension(e,t,n){return oh(this,e,t,n)}}}var ig=class{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){let e={};for(let t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){let e={};for(let t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||=this._normalizer(this._fields),this.all}byNumber(){return this.numbersAsc||=this.list().concat().sort((e,t)=>e.no-t.no),this.numbersAsc}byMember(){if(!this.members){this.members=[];let e=this.members,t;for(let n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}};function ag(e,t){let n=cg(e);return t?n:pg(fg(n))}function og(e){return ag(e,!1)}var sg=cg;function cg(e){let t=!1,n=[];for(let r=0;r<e.length;r++){let i=e.charAt(r);switch(i){case`_`:t=!0;break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n.push(i),t=!1;break;default:t&&(t=!1,i=i.toUpperCase()),n.push(i);break}}return n.join(``)}var lg=new Set([`constructor`,`toString`,`toJSON`,`valueOf`]),ug=new Set([`getType`,`clone`,`equals`,`fromBinary`,`fromJson`,`fromJsonString`,`toBinary`,`toJson`,`toJsonString`,`toObject`]),dg=e=>`${e}\$`,fg=e=>ug.has(e)?dg(e):e,pg=e=>lg.has(e)?dg(e):e,mg=class{constructor(e){this.kind=`oneof`,this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=og(e)}addField(e){Sm(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}};function hg(e,t){let n=[],r;for(let t of typeof e==`function`?e():e){let e=t;if(e.localName=ag(t.name,t.oneof!==void 0),e.jsonName=t.jsonName??sg(t.name),e.repeated=t.repeated??!1,t.kind==`scalar`&&(e.L=t.L??$m.BIGINT),e.delimited=t.delimited??!1,e.req=t.req??!1,e.opt=t.opt??!1,t.packed===void 0&&(e.packed=t.kind==`enum`||t.kind==`scalar`&&t.T!=N.BYTES&&t.T!=N.STRING),t.oneof!==void 0){let n=typeof t.oneof==`string`?t.oneof:t.oneof.name;(!r||r.name!=n)&&(r=new mg(n)),e.oneof=r,r.addField(e)}n.push(e)}return n}var P=rg(`proto3`,e=>new ig(e,e=>hg(e)),e=>{for(let t of e.getType().fields.byMember()){if(t.opt)continue;let n=t.localName,r=e;if(t.repeated){r[n]=[];continue}switch(t.kind){case`oneof`:r[n]={case:void 0};break;case`enum`:r[n]=0;break;case`map`:r[n]={};break;case`scalar`:r[n]=th(t.T,t.L);break}}}),gg=class e extends Lm{constructor(e){super(),this.seconds=Qm.zero,this.nanos=0,P.util.initPartial(e,this)}fromJson(e,t){if(typeof e!=`string`)throw Error(`cannot decode google.protobuf.Timestamp from JSON: ${P.json.debug(e)}`);let n=e.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);if(!n)throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);let r=Date.parse(n[1]+`-`+n[2]+`-`+n[3]+`T`+n[4]+`:`+n[5]+`:`+n[6]+(n[8]?n[8]:`Z`));if(Number.isNaN(r))throw Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);if(r<Date.parse(`0001-01-01T00:00:00Z`)||r>Date.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);return this.seconds=Qm.parse(r/1e3),this.nanos=0,n[7]&&(this.nanos=parseInt(`1`+n[7]+`0`.repeat(9-n[7].length))-1e9),this}toJson(e){let t=Number(this.seconds)*1e3;if(t<Date.parse(`0001-01-01T00:00:00Z`)||t>Date.parse(`9999-12-31T23:59:59Z`))throw Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);if(this.nanos<0)throw Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);let n=`Z`;if(this.nanos>0){let e=(this.nanos+1e9).toString().substring(1);n=e.substring(3)===`000000`?`.`+e.substring(0,3)+`Z`:e.substring(6)===`000`?`.`+e.substring(0,6)+`Z`:`.`+e+`Z`}return new Date(t).toISOString().replace(`.000Z`,n)}toDate(){return new Date(Number(this.seconds)*1e3+Math.ceil(this.nanos/1e6))}static now(){return e.fromDate(new Date)}static fromDate(t){let n=t.getTime();return new e({seconds:Qm.parse(Math.floor(n/1e3)),nanos:n%1e3*1e6})}static fromBinary(t,n){return new e().fromBinary(t,n)}static fromJson(t,n){return new e().fromJson(t,n)}static fromJsonString(t,n){return new e().fromJsonString(t,n)}static equals(t,n){return P.util.equals(e,t,n)}};gg.runtime=P,gg.typeName=`google.protobuf.Timestamp`,gg.fields=P.util.newFieldList(()=>[{no:1,name:`seconds`,kind:`scalar`,T:3},{no:2,name:`nanos`,kind:`scalar`,T:5}]);var _g=P.makeMessageType(`livekit.MetricsBatch`,()=>[{no:1,name:`timestamp_ms`,kind:`scalar`,T:3},{no:2,name:`normalized_timestamp`,kind:`message`,T:gg},{no:3,name:`str_data`,kind:`scalar`,T:9,repeated:!0},{no:4,name:`time_series`,kind:`message`,T:vg,repeated:!0},{no:5,name:`events`,kind:`message`,T:bg,repeated:!0}]),vg=P.makeMessageType(`livekit.TimeSeriesMetric`,()=>[{no:1,name:`label`,kind:`scalar`,T:13},{no:2,name:`participant_identity`,kind:`scalar`,T:13},{no:3,name:`track_sid`,kind:`scalar`,T:13},{no:4,name:`samples`,kind:`message`,T:yg,repeated:!0},{no:5,name:`rid`,kind:`scalar`,T:13}]),yg=P.makeMessageType(`livekit.MetricSample`,()=>[{no:1,name:`timestamp_ms`,kind:`scalar`,T:3},{no:2,name:`normalized_timestamp`,kind:`message`,T:gg},{no:3,name:`value`,kind:`scalar`,T:2}]),bg=P.makeMessageType(`livekit.EventMetric`,()=>[{no:1,name:`label`,kind:`scalar`,T:13},{no:2,name:`participant_identity`,kind:`scalar`,T:13},{no:3,name:`track_sid`,kind:`scalar`,T:13},{no:4,name:`start_timestamp_ms`,kind:`scalar`,T:3},{no:5,name:`end_timestamp_ms`,kind:`scalar`,T:3,opt:!0},{no:6,name:`normalized_start_timestamp`,kind:`message`,T:gg},{no:7,name:`normalized_end_timestamp`,kind:`message`,T:gg,opt:!0},{no:8,name:`metadata`,kind:`scalar`,T:9},{no:9,name:`rid`,kind:`scalar`,T:13}]),xg=P.makeEnum(`livekit.BackupCodecPolicy`,[{no:0,name:`PREFER_REGRESSION`},{no:1,name:`SIMULCAST`},{no:2,name:`REGRESSION`}]),Sg=P.makeEnum(`livekit.TrackType`,[{no:0,name:`AUDIO`},{no:1,name:`VIDEO`},{no:2,name:`DATA`}]),Cg=P.makeEnum(`livekit.TrackSource`,[{no:0,name:`UNKNOWN`},{no:1,name:`CAMERA`},{no:2,name:`MICROPHONE`},{no:3,name:`SCREEN_SHARE`},{no:4,name:`SCREEN_SHARE_AUDIO`}]),wg=P.makeEnum(`livekit.VideoQuality`,[{no:0,name:`LOW`},{no:1,name:`MEDIUM`},{no:2,name:`HIGH`},{no:3,name:`OFF`}]),Tg=P.makeEnum(`livekit.ConnectionQuality`,[{no:0,name:`POOR`},{no:1,name:`GOOD`},{no:2,name:`EXCELLENT`},{no:3,name:`LOST`}]),Eg=P.makeEnum(`livekit.ClientConfigSetting`,[{no:0,name:`UNSET`},{no:1,name:`DISABLED`},{no:2,name:`ENABLED`}]),Dg=P.makeEnum(`livekit.DisconnectReason`,[{no:0,name:`UNKNOWN_REASON`},{no:1,name:`CLIENT_INITIATED`},{no:2,name:`DUPLICATE_IDENTITY`},{no:3,name:`SERVER_SHUTDOWN`},{no:4,name:`PARTICIPANT_REMOVED`},{no:5,name:`ROOM_DELETED`},{no:6,name:`STATE_MISMATCH`},{no:7,name:`JOIN_FAILURE`},{no:8,name:`MIGRATION`},{no:9,name:`SIGNAL_CLOSE`},{no:10,name:`ROOM_CLOSED`},{no:11,name:`USER_UNAVAILABLE`},{no:12,name:`USER_REJECTED`},{no:13,name:`SIP_TRUNK_FAILURE`},{no:14,name:`CONNECTION_TIMEOUT`},{no:15,name:`MEDIA_FAILURE`}]),Og=P.makeEnum(`livekit.ReconnectReason`,[{no:0,name:`RR_UNKNOWN`},{no:1,name:`RR_SIGNAL_DISCONNECTED`},{no:2,name:`RR_PUBLISHER_FAILED`},{no:3,name:`RR_SUBSCRIBER_FAILED`},{no:4,name:`RR_SWITCH_CANDIDATE`}]),kg=P.makeEnum(`livekit.SubscriptionError`,[{no:0,name:`SE_UNKNOWN`},{no:1,name:`SE_CODEC_UNSUPPORTED`},{no:2,name:`SE_TRACK_NOTFOUND`}]),Ag=P.makeEnum(`livekit.AudioTrackFeature`,[{no:0,name:`TF_STEREO`},{no:1,name:`TF_NO_DTX`},{no:2,name:`TF_AUTO_GAIN_CONTROL`},{no:3,name:`TF_ECHO_CANCELLATION`},{no:4,name:`TF_NOISE_SUPPRESSION`},{no:5,name:`TF_ENHANCED_NOISE_CANCELLATION`},{no:6,name:`TF_PRECONNECT_BUFFER`}]),jg=P.makeMessageType(`livekit.Room`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`empty_timeout`,kind:`scalar`,T:13},{no:14,name:`departure_timeout`,kind:`scalar`,T:13},{no:4,name:`max_participants`,kind:`scalar`,T:13},{no:5,name:`creation_time`,kind:`scalar`,T:3},{no:15,name:`creation_time_ms`,kind:`scalar`,T:3},{no:6,name:`turn_password`,kind:`scalar`,T:9},{no:7,name:`enabled_codecs`,kind:`message`,T:Mg,repeated:!0},{no:8,name:`metadata`,kind:`scalar`,T:9},{no:9,name:`num_participants`,kind:`scalar`,T:13},{no:11,name:`num_publishers`,kind:`scalar`,T:13},{no:10,name:`active_recording`,kind:`scalar`,T:8},{no:13,name:`version`,kind:`message`,T:p_}]),Mg=P.makeMessageType(`livekit.Codec`,()=>[{no:1,name:`mime`,kind:`scalar`,T:9},{no:2,name:`fmtp_line`,kind:`scalar`,T:9}]),Ng=P.makeMessageType(`livekit.ParticipantPermission`,()=>[{no:1,name:`can_subscribe`,kind:`scalar`,T:8},{no:2,name:`can_publish`,kind:`scalar`,T:8},{no:3,name:`can_publish_data`,kind:`scalar`,T:8},{no:9,name:`can_publish_sources`,kind:`enum`,T:P.getEnumType(Cg),repeated:!0},{no:7,name:`hidden`,kind:`scalar`,T:8},{no:8,name:`recorder`,kind:`scalar`,T:8},{no:10,name:`can_update_metadata`,kind:`scalar`,T:8},{no:11,name:`agent`,kind:`scalar`,T:8},{no:12,name:`can_subscribe_metrics`,kind:`scalar`,T:8}]),Pg=P.makeMessageType(`livekit.ParticipantInfo`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`identity`,kind:`scalar`,T:9},{no:3,name:`state`,kind:`enum`,T:P.getEnumType(Fg)},{no:4,name:`tracks`,kind:`message`,T:zg,repeated:!0},{no:5,name:`metadata`,kind:`scalar`,T:9},{no:6,name:`joined_at`,kind:`scalar`,T:3},{no:17,name:`joined_at_ms`,kind:`scalar`,T:3},{no:9,name:`name`,kind:`scalar`,T:9},{no:10,name:`version`,kind:`scalar`,T:13},{no:11,name:`permission`,kind:`message`,T:Ng},{no:12,name:`region`,kind:`scalar`,T:9},{no:13,name:`is_publisher`,kind:`scalar`,T:8},{no:14,name:`kind`,kind:`enum`,T:P.getEnumType(Ig)},{no:15,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:16,name:`disconnect_reason`,kind:`enum`,T:P.getEnumType(Dg)},{no:18,name:`kind_details`,kind:`enum`,T:P.getEnumType(Lg),repeated:!0},{no:19,name:`data_tracks`,kind:`message`,T:Bg,repeated:!0}]),Fg=P.makeEnum(`livekit.ParticipantInfo.State`,[{no:0,name:`JOINING`},{no:1,name:`JOINED`},{no:2,name:`ACTIVE`},{no:3,name:`DISCONNECTED`}]),Ig=P.makeEnum(`livekit.ParticipantInfo.Kind`,[{no:0,name:`STANDARD`},{no:1,name:`INGRESS`},{no:2,name:`EGRESS`},{no:3,name:`SIP`},{no:4,name:`AGENT`},{no:7,name:`CONNECTOR`},{no:8,name:`BRIDGE`}]),Lg=P.makeEnum(`livekit.ParticipantInfo.KindDetail`,[{no:0,name:`CLOUD_AGENT`},{no:1,name:`FORWARDED`},{no:2,name:`CONNECTOR_WHATSAPP`},{no:3,name:`CONNECTOR_TWILIO`},{no:4,name:`BRIDGE_RTSP`}]),F=P.makeEnum(`livekit.Encryption.Type`,[{no:0,name:`NONE`},{no:1,name:`GCM`},{no:2,name:`CUSTOM`}]),Rg=P.makeMessageType(`livekit.SimulcastCodecInfo`,()=>[{no:1,name:`mime_type`,kind:`scalar`,T:9},{no:2,name:`mid`,kind:`scalar`,T:9},{no:3,name:`cid`,kind:`scalar`,T:9},{no:4,name:`layers`,kind:`message`,T:Hg,repeated:!0},{no:5,name:`video_layer_mode`,kind:`enum`,T:P.getEnumType(Ug)},{no:6,name:`sdp_cid`,kind:`scalar`,T:9}]),zg=P.makeMessageType(`livekit.TrackInfo`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`type`,kind:`enum`,T:P.getEnumType(Sg)},{no:3,name:`name`,kind:`scalar`,T:9},{no:4,name:`muted`,kind:`scalar`,T:8},{no:5,name:`width`,kind:`scalar`,T:13},{no:6,name:`height`,kind:`scalar`,T:13},{no:7,name:`simulcast`,kind:`scalar`,T:8},{no:8,name:`disable_dtx`,kind:`scalar`,T:8},{no:9,name:`source`,kind:`enum`,T:P.getEnumType(Cg)},{no:10,name:`layers`,kind:`message`,T:Hg,repeated:!0},{no:11,name:`mime_type`,kind:`scalar`,T:9},{no:12,name:`mid`,kind:`scalar`,T:9},{no:13,name:`codecs`,kind:`message`,T:Rg,repeated:!0},{no:14,name:`stereo`,kind:`scalar`,T:8},{no:15,name:`disable_red`,kind:`scalar`,T:8},{no:16,name:`encryption`,kind:`enum`,T:P.getEnumType(F)},{no:17,name:`stream`,kind:`scalar`,T:9},{no:18,name:`version`,kind:`message`,T:p_},{no:19,name:`audio_features`,kind:`enum`,T:P.getEnumType(Ag),repeated:!0},{no:20,name:`backup_codec_policy`,kind:`enum`,T:P.getEnumType(xg)}]),Bg=P.makeMessageType(`livekit.DataTrackInfo`,()=>[{no:1,name:`pub_handle`,kind:`scalar`,T:13},{no:2,name:`sid`,kind:`scalar`,T:9},{no:3,name:`name`,kind:`scalar`,T:9},{no:4,name:`encryption`,kind:`enum`,T:P.getEnumType(F)}]),Vg=P.makeMessageType(`livekit.DataTrackSubscriptionOptions`,()=>[{no:1,name:`target_fps`,kind:`scalar`,T:13,opt:!0}]),Hg=P.makeMessageType(`livekit.VideoLayer`,()=>[{no:1,name:`quality`,kind:`enum`,T:P.getEnumType(wg)},{no:2,name:`width`,kind:`scalar`,T:13},{no:3,name:`height`,kind:`scalar`,T:13},{no:4,name:`bitrate`,kind:`scalar`,T:13},{no:5,name:`ssrc`,kind:`scalar`,T:13},{no:6,name:`spatial_layer`,kind:`scalar`,T:5},{no:7,name:`rid`,kind:`scalar`,T:9},{no:8,name:`repair_ssrc`,kind:`scalar`,T:13}]),Ug=P.makeEnum(`livekit.VideoLayer.Mode`,[{no:0,name:`MODE_UNUSED`},{no:1,name:`ONE_SPATIAL_LAYER_PER_STREAM`},{no:2,name:`MULTIPLE_SPATIAL_LAYERS_PER_STREAM`},{no:3,name:`ONE_SPATIAL_LAYER_PER_STREAM_INCOMPLETE_RTCP_SR`}]),Wg=P.makeMessageType(`livekit.DataPacket`,()=>[{no:1,name:`kind`,kind:`enum`,T:P.getEnumType(Gg)},{no:4,name:`participant_identity`,kind:`scalar`,T:9},{no:5,name:`destination_identities`,kind:`scalar`,T:9,repeated:!0},{no:2,name:`user`,kind:`message`,T:Xg,oneof:`value`},{no:3,name:`speaker`,kind:`message`,T:Jg,oneof:`value`},{no:6,name:`sip_dtmf`,kind:`message`,T:Zg,oneof:`value`},{no:7,name:`transcription`,kind:`message`,T:Qg,oneof:`value`},{no:8,name:`metrics`,kind:`message`,T:_g,oneof:`value`},{no:9,name:`chat_message`,kind:`message`,T:e_,oneof:`value`},{no:10,name:`rpc_request`,kind:`message`,T:t_,oneof:`value`},{no:11,name:`rpc_ack`,kind:`message`,T:n_,oneof:`value`},{no:12,name:`rpc_response`,kind:`message`,T:r_,oneof:`value`},{no:13,name:`stream_header`,kind:`message`,T:__,oneof:`value`},{no:14,name:`stream_chunk`,kind:`message`,T:v_,oneof:`value`},{no:15,name:`stream_trailer`,kind:`message`,T:y_,oneof:`value`},{no:18,name:`encrypted_packet`,kind:`message`,T:Kg,oneof:`value`},{no:16,name:`sequence`,kind:`scalar`,T:13},{no:17,name:`participant_sid`,kind:`scalar`,T:9}]),Gg=P.makeEnum(`livekit.DataPacket.Kind`,[{no:0,name:`RELIABLE`},{no:1,name:`LOSSY`}]),Kg=P.makeMessageType(`livekit.EncryptedPacket`,()=>[{no:1,name:`encryption_type`,kind:`enum`,T:P.getEnumType(F)},{no:2,name:`iv`,kind:`scalar`,T:12},{no:3,name:`key_index`,kind:`scalar`,T:13},{no:4,name:`encrypted_value`,kind:`scalar`,T:12}]),qg=P.makeMessageType(`livekit.EncryptedPacketPayload`,()=>[{no:1,name:`user`,kind:`message`,T:Xg,oneof:`value`},{no:3,name:`chat_message`,kind:`message`,T:e_,oneof:`value`},{no:4,name:`rpc_request`,kind:`message`,T:t_,oneof:`value`},{no:5,name:`rpc_ack`,kind:`message`,T:n_,oneof:`value`},{no:6,name:`rpc_response`,kind:`message`,T:r_,oneof:`value`},{no:7,name:`stream_header`,kind:`message`,T:__,oneof:`value`},{no:8,name:`stream_chunk`,kind:`message`,T:v_,oneof:`value`},{no:9,name:`stream_trailer`,kind:`message`,T:y_,oneof:`value`}]),Jg=P.makeMessageType(`livekit.ActiveSpeakerUpdate`,()=>[{no:1,name:`speakers`,kind:`message`,T:Yg,repeated:!0}]),Yg=P.makeMessageType(`livekit.SpeakerInfo`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`level`,kind:`scalar`,T:2},{no:3,name:`active`,kind:`scalar`,T:8}]),Xg=P.makeMessageType(`livekit.UserPacket`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:5,name:`participant_identity`,kind:`scalar`,T:9},{no:2,name:`payload`,kind:`scalar`,T:12},{no:3,name:`destination_sids`,kind:`scalar`,T:9,repeated:!0},{no:6,name:`destination_identities`,kind:`scalar`,T:9,repeated:!0},{no:4,name:`topic`,kind:`scalar`,T:9,opt:!0},{no:8,name:`id`,kind:`scalar`,T:9,opt:!0},{no:9,name:`start_time`,kind:`scalar`,T:4,opt:!0},{no:10,name:`end_time`,kind:`scalar`,T:4,opt:!0},{no:11,name:`nonce`,kind:`scalar`,T:12}]),Zg=P.makeMessageType(`livekit.SipDTMF`,()=>[{no:3,name:`code`,kind:`scalar`,T:13},{no:4,name:`digit`,kind:`scalar`,T:9}]),Qg=P.makeMessageType(`livekit.Transcription`,()=>[{no:2,name:`transcribed_participant_identity`,kind:`scalar`,T:9},{no:3,name:`track_id`,kind:`scalar`,T:9},{no:4,name:`segments`,kind:`message`,T:$g,repeated:!0}]),$g=P.makeMessageType(`livekit.TranscriptionSegment`,()=>[{no:1,name:`id`,kind:`scalar`,T:9},{no:2,name:`text`,kind:`scalar`,T:9},{no:3,name:`start_time`,kind:`scalar`,T:4},{no:4,name:`end_time`,kind:`scalar`,T:4},{no:5,name:`final`,kind:`scalar`,T:8},{no:6,name:`language`,kind:`scalar`,T:9}]),e_=P.makeMessageType(`livekit.ChatMessage`,()=>[{no:1,name:`id`,kind:`scalar`,T:9},{no:2,name:`timestamp`,kind:`scalar`,T:3},{no:3,name:`edit_timestamp`,kind:`scalar`,T:3,opt:!0},{no:4,name:`message`,kind:`scalar`,T:9},{no:5,name:`deleted`,kind:`scalar`,T:8},{no:6,name:`generated`,kind:`scalar`,T:8}]),t_=P.makeMessageType(`livekit.RpcRequest`,()=>[{no:1,name:`id`,kind:`scalar`,T:9},{no:2,name:`method`,kind:`scalar`,T:9},{no:3,name:`payload`,kind:`scalar`,T:9},{no:4,name:`response_timeout_ms`,kind:`scalar`,T:13},{no:5,name:`version`,kind:`scalar`,T:13}]),n_=P.makeMessageType(`livekit.RpcAck`,()=>[{no:1,name:`request_id`,kind:`scalar`,T:9}]),r_=P.makeMessageType(`livekit.RpcResponse`,()=>[{no:1,name:`request_id`,kind:`scalar`,T:9},{no:2,name:`payload`,kind:`scalar`,T:9,oneof:`value`},{no:3,name:`error`,kind:`message`,T:i_,oneof:`value`}]),i_=P.makeMessageType(`livekit.RpcError`,()=>[{no:1,name:`code`,kind:`scalar`,T:13},{no:2,name:`message`,kind:`scalar`,T:9},{no:3,name:`data`,kind:`scalar`,T:9}]),a_=P.makeMessageType(`livekit.ParticipantTracks`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`track_sids`,kind:`scalar`,T:9,repeated:!0}]),o_=P.makeMessageType(`livekit.ServerInfo`,()=>[{no:1,name:`edition`,kind:`enum`,T:P.getEnumType(s_)},{no:2,name:`version`,kind:`scalar`,T:9},{no:3,name:`protocol`,kind:`scalar`,T:5},{no:4,name:`region`,kind:`scalar`,T:9},{no:5,name:`node_id`,kind:`scalar`,T:9},{no:6,name:`debug_info`,kind:`scalar`,T:9},{no:7,name:`agent_protocol`,kind:`scalar`,T:5}]),s_=P.makeEnum(`livekit.ServerInfo.Edition`,[{no:0,name:`Standard`},{no:1,name:`Cloud`}]),c_=P.makeMessageType(`livekit.ClientInfo`,()=>[{no:1,name:`sdk`,kind:`enum`,T:P.getEnumType(l_)},{no:2,name:`version`,kind:`scalar`,T:9},{no:3,name:`protocol`,kind:`scalar`,T:5},{no:4,name:`os`,kind:`scalar`,T:9},{no:5,name:`os_version`,kind:`scalar`,T:9},{no:6,name:`device_model`,kind:`scalar`,T:9},{no:7,name:`browser`,kind:`scalar`,T:9},{no:8,name:`browser_version`,kind:`scalar`,T:9},{no:9,name:`address`,kind:`scalar`,T:9},{no:10,name:`network`,kind:`scalar`,T:9},{no:11,name:`other_sdks`,kind:`scalar`,T:9}]),l_=P.makeEnum(`livekit.ClientInfo.SDK`,[{no:0,name:`UNKNOWN`},{no:1,name:`JS`},{no:2,name:`SWIFT`},{no:3,name:`ANDROID`},{no:4,name:`FLUTTER`},{no:5,name:`GO`},{no:6,name:`UNITY`},{no:7,name:`REACT_NATIVE`},{no:8,name:`RUST`},{no:9,name:`PYTHON`},{no:10,name:`CPP`},{no:11,name:`UNITY_WEB`},{no:12,name:`NODE`},{no:13,name:`UNREAL`},{no:14,name:`ESP32`}]),u_=P.makeMessageType(`livekit.ClientConfiguration`,()=>[{no:1,name:`video`,kind:`message`,T:d_},{no:2,name:`screen`,kind:`message`,T:d_},{no:3,name:`resume_connection`,kind:`enum`,T:P.getEnumType(Eg)},{no:4,name:`disabled_codecs`,kind:`message`,T:f_},{no:5,name:`force_relay`,kind:`enum`,T:P.getEnumType(Eg)}]),d_=P.makeMessageType(`livekit.VideoConfiguration`,()=>[{no:1,name:`hardware_encoder`,kind:`enum`,T:P.getEnumType(Eg)}]),f_=P.makeMessageType(`livekit.DisabledCodecs`,()=>[{no:1,name:`codecs`,kind:`message`,T:Mg,repeated:!0},{no:2,name:`publish`,kind:`message`,T:Mg,repeated:!0}]),p_=P.makeMessageType(`livekit.TimedVersion`,()=>[{no:1,name:`unix_micro`,kind:`scalar`,T:3},{no:2,name:`ticks`,kind:`scalar`,T:5}]),m_=P.makeEnum(`livekit.DataStream.OperationType`,[{no:0,name:`CREATE`},{no:1,name:`UPDATE`},{no:2,name:`DELETE`},{no:3,name:`REACTION`}]),h_=P.makeMessageType(`livekit.DataStream.TextHeader`,()=>[{no:1,name:`operation_type`,kind:`enum`,T:P.getEnumType(m_)},{no:2,name:`version`,kind:`scalar`,T:5},{no:3,name:`reply_to_stream_id`,kind:`scalar`,T:9},{no:4,name:`attached_stream_ids`,kind:`scalar`,T:9,repeated:!0},{no:5,name:`generated`,kind:`scalar`,T:8}],{localName:`DataStream_TextHeader`}),g_=P.makeMessageType(`livekit.DataStream.ByteHeader`,()=>[{no:1,name:`name`,kind:`scalar`,T:9}],{localName:`DataStream_ByteHeader`}),__=P.makeMessageType(`livekit.DataStream.Header`,()=>[{no:1,name:`stream_id`,kind:`scalar`,T:9},{no:2,name:`timestamp`,kind:`scalar`,T:3},{no:3,name:`topic`,kind:`scalar`,T:9},{no:4,name:`mime_type`,kind:`scalar`,T:9},{no:5,name:`total_length`,kind:`scalar`,T:4,opt:!0},{no:7,name:`encryption_type`,kind:`enum`,T:P.getEnumType(F)},{no:8,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:9,name:`text_header`,kind:`message`,T:h_,oneof:`content_header`},{no:10,name:`byte_header`,kind:`message`,T:g_,oneof:`content_header`}],{localName:`DataStream_Header`}),v_=P.makeMessageType(`livekit.DataStream.Chunk`,()=>[{no:1,name:`stream_id`,kind:`scalar`,T:9},{no:2,name:`chunk_index`,kind:`scalar`,T:4},{no:3,name:`content`,kind:`scalar`,T:12},{no:4,name:`version`,kind:`scalar`,T:5},{no:5,name:`iv`,kind:`scalar`,T:12,opt:!0}],{localName:`DataStream_Chunk`}),y_=P.makeMessageType(`livekit.DataStream.Trailer`,()=>[{no:1,name:`stream_id`,kind:`scalar`,T:9},{no:2,name:`reason`,kind:`scalar`,T:9},{no:3,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}}],{localName:`DataStream_Trailer`}),b_=P.makeMessageType(`livekit.SubscribedAudioCodec`,()=>[{no:1,name:`codec`,kind:`scalar`,T:9},{no:2,name:`enabled`,kind:`scalar`,T:8}]),x_=P.makeEnum(`livekit.SignalTarget`,[{no:0,name:`PUBLISHER`},{no:1,name:`SUBSCRIBER`}]),S_=P.makeEnum(`livekit.StreamState`,[{no:0,name:`ACTIVE`},{no:1,name:`PAUSED`}]),C_=P.makeEnum(`livekit.CandidateProtocol`,[{no:0,name:`UDP`},{no:1,name:`TCP`},{no:2,name:`TLS`}]),w_=P.makeMessageType(`livekit.SignalRequest`,()=>[{no:1,name:`offer`,kind:`message`,T:B_,oneof:`message`},{no:2,name:`answer`,kind:`message`,T:B_,oneof:`message`},{no:3,name:`trickle`,kind:`message`,T:P_,oneof:`message`},{no:4,name:`add_track`,kind:`message`,T:D_,oneof:`message`},{no:5,name:`mute`,kind:`message`,T:F_,oneof:`message`},{no:6,name:`subscription`,kind:`message`,T:H_,oneof:`message`},{no:7,name:`track_setting`,kind:`message`,T:G_,oneof:`message`},{no:8,name:`leave`,kind:`message`,T:J_,oneof:`message`},{no:10,name:`update_layers`,kind:`message`,T:X_,oneof:`message`},{no:11,name:`subscription_permission`,kind:`message`,T:uv,oneof:`message`},{no:12,name:`sync_state`,kind:`message`,T:pv,oneof:`message`},{no:13,name:`simulate`,kind:`message`,T:gv,oneof:`message`},{no:14,name:`ping`,kind:`scalar`,T:3,oneof:`message`},{no:15,name:`update_metadata`,kind:`message`,T:Z_,oneof:`message`},{no:16,name:`ping_req`,kind:`message`,T:_v,oneof:`message`},{no:17,name:`update_audio_track`,kind:`message`,T:K_,oneof:`message`},{no:18,name:`update_video_track`,kind:`message`,T:q_,oneof:`message`},{no:19,name:`publish_data_track_request`,kind:`message`,T:O_,oneof:`message`},{no:20,name:`unpublish_data_track_request`,kind:`message`,T:A_,oneof:`message`},{no:21,name:`update_data_subscription`,kind:`message`,T:U_,oneof:`message`}]),T_=P.makeMessageType(`livekit.SignalResponse`,()=>[{no:1,name:`join`,kind:`message`,T:I_,oneof:`message`},{no:2,name:`answer`,kind:`message`,T:B_,oneof:`message`},{no:3,name:`offer`,kind:`message`,T:B_,oneof:`message`},{no:4,name:`trickle`,kind:`message`,T:P_,oneof:`message`},{no:5,name:`update`,kind:`message`,T:V_,oneof:`message`},{no:6,name:`track_published`,kind:`message`,T:R_,oneof:`message`},{no:8,name:`leave`,kind:`message`,T:J_,oneof:`message`},{no:9,name:`mute`,kind:`message`,T:F_,oneof:`message`},{no:10,name:`speakers_changed`,kind:`message`,T:$_,oneof:`message`},{no:11,name:`room_update`,kind:`message`,T:ev,oneof:`message`},{no:12,name:`connection_quality`,kind:`message`,T:nv,oneof:`message`},{no:13,name:`stream_state_update`,kind:`message`,T:iv,oneof:`message`},{no:14,name:`subscribed_quality_update`,kind:`message`,T:sv,oneof:`message`},{no:15,name:`subscription_permission_update`,kind:`message`,T:dv,oneof:`message`},{no:16,name:`refresh_token`,kind:`scalar`,T:9,oneof:`message`},{no:17,name:`track_unpublished`,kind:`message`,T:z_,oneof:`message`},{no:18,name:`pong`,kind:`scalar`,T:3,oneof:`message`},{no:19,name:`reconnect`,kind:`message`,T:L_,oneof:`message`},{no:20,name:`pong_resp`,kind:`message`,T:vv,oneof:`message`},{no:21,name:`subscription_response`,kind:`message`,T:xv,oneof:`message`},{no:22,name:`request_response`,kind:`message`,T:Sv,oneof:`message`},{no:23,name:`track_subscribed`,kind:`message`,T:wv,oneof:`message`},{no:24,name:`room_moved`,kind:`message`,T:fv,oneof:`message`},{no:25,name:`media_sections_requirement`,kind:`message`,T:kv,oneof:`message`},{no:26,name:`subscribed_audio_codec_update`,kind:`message`,T:cv,oneof:`message`},{no:27,name:`publish_data_track_response`,kind:`message`,T:k_,oneof:`message`},{no:28,name:`unpublish_data_track_response`,kind:`message`,T:j_,oneof:`message`},{no:29,name:`data_track_subscriber_handles`,kind:`message`,T:M_,oneof:`message`}]),E_=P.makeMessageType(`livekit.SimulcastCodec`,()=>[{no:1,name:`codec`,kind:`scalar`,T:9},{no:2,name:`cid`,kind:`scalar`,T:9},{no:4,name:`layers`,kind:`message`,T:Hg,repeated:!0},{no:5,name:`video_layer_mode`,kind:`enum`,T:P.getEnumType(Ug)}]),D_=P.makeMessageType(`livekit.AddTrackRequest`,()=>[{no:1,name:`cid`,kind:`scalar`,T:9},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`type`,kind:`enum`,T:P.getEnumType(Sg)},{no:4,name:`width`,kind:`scalar`,T:13},{no:5,name:`height`,kind:`scalar`,T:13},{no:6,name:`muted`,kind:`scalar`,T:8},{no:7,name:`disable_dtx`,kind:`scalar`,T:8},{no:8,name:`source`,kind:`enum`,T:P.getEnumType(Cg)},{no:9,name:`layers`,kind:`message`,T:Hg,repeated:!0},{no:10,name:`simulcast_codecs`,kind:`message`,T:E_,repeated:!0},{no:11,name:`sid`,kind:`scalar`,T:9},{no:12,name:`stereo`,kind:`scalar`,T:8},{no:13,name:`disable_red`,kind:`scalar`,T:8},{no:14,name:`encryption`,kind:`enum`,T:P.getEnumType(F)},{no:15,name:`stream`,kind:`scalar`,T:9},{no:16,name:`backup_codec_policy`,kind:`enum`,T:P.getEnumType(xg)},{no:17,name:`audio_features`,kind:`enum`,T:P.getEnumType(Ag),repeated:!0}]),O_=P.makeMessageType(`livekit.PublishDataTrackRequest`,()=>[{no:1,name:`pub_handle`,kind:`scalar`,T:13},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`encryption`,kind:`enum`,T:P.getEnumType(F)}]),k_=P.makeMessageType(`livekit.PublishDataTrackResponse`,()=>[{no:1,name:`info`,kind:`message`,T:Bg}]),A_=P.makeMessageType(`livekit.UnpublishDataTrackRequest`,()=>[{no:1,name:`pub_handle`,kind:`scalar`,T:13}]),j_=P.makeMessageType(`livekit.UnpublishDataTrackResponse`,()=>[{no:1,name:`info`,kind:`message`,T:Bg}]),M_=P.makeMessageType(`livekit.DataTrackSubscriberHandles`,()=>[{no:1,name:`sub_handles`,kind:`map`,K:13,V:{kind:`message`,T:N_}}]),N_=P.makeMessageType(`livekit.DataTrackSubscriberHandles.PublishedDataTrack`,()=>[{no:1,name:`publisher_identity`,kind:`scalar`,T:9},{no:2,name:`publisher_sid`,kind:`scalar`,T:9},{no:3,name:`track_sid`,kind:`scalar`,T:9}],{localName:`DataTrackSubscriberHandles_PublishedDataTrack`}),P_=P.makeMessageType(`livekit.TrickleRequest`,()=>[{no:1,name:`candidateInit`,kind:`scalar`,T:9},{no:2,name:`target`,kind:`enum`,T:P.getEnumType(x_)},{no:3,name:`final`,kind:`scalar`,T:8}]),F_=P.makeMessageType(`livekit.MuteTrackRequest`,()=>[{no:1,name:`sid`,kind:`scalar`,T:9},{no:2,name:`muted`,kind:`scalar`,T:8}]),I_=P.makeMessageType(`livekit.JoinResponse`,()=>[{no:1,name:`room`,kind:`message`,T:jg},{no:2,name:`participant`,kind:`message`,T:Pg},{no:3,name:`other_participants`,kind:`message`,T:Pg,repeated:!0},{no:4,name:`server_version`,kind:`scalar`,T:9},{no:5,name:`ice_servers`,kind:`message`,T:Q_,repeated:!0},{no:6,name:`subscriber_primary`,kind:`scalar`,T:8},{no:7,name:`alternative_url`,kind:`scalar`,T:9},{no:8,name:`client_configuration`,kind:`message`,T:u_},{no:9,name:`server_region`,kind:`scalar`,T:9},{no:10,name:`ping_timeout`,kind:`scalar`,T:5},{no:11,name:`ping_interval`,kind:`scalar`,T:5},{no:12,name:`server_info`,kind:`message`,T:o_},{no:13,name:`sif_trailer`,kind:`scalar`,T:12},{no:14,name:`enabled_publish_codecs`,kind:`message`,T:Mg,repeated:!0},{no:15,name:`fast_publish`,kind:`scalar`,T:8}]),L_=P.makeMessageType(`livekit.ReconnectResponse`,()=>[{no:1,name:`ice_servers`,kind:`message`,T:Q_,repeated:!0},{no:2,name:`client_configuration`,kind:`message`,T:u_},{no:3,name:`server_info`,kind:`message`,T:o_},{no:4,name:`last_message_seq`,kind:`scalar`,T:13}]),R_=P.makeMessageType(`livekit.TrackPublishedResponse`,()=>[{no:1,name:`cid`,kind:`scalar`,T:9},{no:2,name:`track`,kind:`message`,T:zg}]),z_=P.makeMessageType(`livekit.TrackUnpublishedResponse`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9}]),B_=P.makeMessageType(`livekit.SessionDescription`,()=>[{no:1,name:`type`,kind:`scalar`,T:9},{no:2,name:`sdp`,kind:`scalar`,T:9},{no:3,name:`id`,kind:`scalar`,T:13},{no:4,name:`mid_to_track_id`,kind:`map`,K:9,V:{kind:`scalar`,T:9}}]),V_=P.makeMessageType(`livekit.ParticipantUpdate`,()=>[{no:1,name:`participants`,kind:`message`,T:Pg,repeated:!0}]),H_=P.makeMessageType(`livekit.UpdateSubscription`,()=>[{no:1,name:`track_sids`,kind:`scalar`,T:9,repeated:!0},{no:2,name:`subscribe`,kind:`scalar`,T:8},{no:3,name:`participant_tracks`,kind:`message`,T:a_,repeated:!0}]),U_=P.makeMessageType(`livekit.UpdateDataSubscription`,()=>[{no:1,name:`updates`,kind:`message`,T:W_,repeated:!0}]),W_=P.makeMessageType(`livekit.UpdateDataSubscription.Update`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`subscribe`,kind:`scalar`,T:8},{no:3,name:`options`,kind:`message`,T:Vg}],{localName:`UpdateDataSubscription_Update`}),G_=P.makeMessageType(`livekit.UpdateTrackSettings`,()=>[{no:1,name:`track_sids`,kind:`scalar`,T:9,repeated:!0},{no:3,name:`disabled`,kind:`scalar`,T:8},{no:4,name:`quality`,kind:`enum`,T:P.getEnumType(wg)},{no:5,name:`width`,kind:`scalar`,T:13},{no:6,name:`height`,kind:`scalar`,T:13},{no:7,name:`fps`,kind:`scalar`,T:13},{no:8,name:`priority`,kind:`scalar`,T:13}]),K_=P.makeMessageType(`livekit.UpdateLocalAudioTrack`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`features`,kind:`enum`,T:P.getEnumType(Ag),repeated:!0}]),q_=P.makeMessageType(`livekit.UpdateLocalVideoTrack`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`width`,kind:`scalar`,T:13},{no:3,name:`height`,kind:`scalar`,T:13}]),J_=P.makeMessageType(`livekit.LeaveRequest`,()=>[{no:1,name:`can_reconnect`,kind:`scalar`,T:8},{no:2,name:`reason`,kind:`enum`,T:P.getEnumType(Dg)},{no:3,name:`action`,kind:`enum`,T:P.getEnumType(Y_)},{no:4,name:`regions`,kind:`message`,T:yv}]),Y_=P.makeEnum(`livekit.LeaveRequest.Action`,[{no:0,name:`DISCONNECT`},{no:1,name:`RESUME`},{no:2,name:`RECONNECT`}]),X_=P.makeMessageType(`livekit.UpdateVideoLayers`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`layers`,kind:`message`,T:Hg,repeated:!0}]),Z_=P.makeMessageType(`livekit.UpdateParticipantMetadata`,()=>[{no:1,name:`metadata`,kind:`scalar`,T:9},{no:2,name:`name`,kind:`scalar`,T:9},{no:3,name:`attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:4,name:`request_id`,kind:`scalar`,T:13}]),Q_=P.makeMessageType(`livekit.ICEServer`,()=>[{no:1,name:`urls`,kind:`scalar`,T:9,repeated:!0},{no:2,name:`username`,kind:`scalar`,T:9},{no:3,name:`credential`,kind:`scalar`,T:9}]),$_=P.makeMessageType(`livekit.SpeakersChanged`,()=>[{no:1,name:`speakers`,kind:`message`,T:Yg,repeated:!0}]),ev=P.makeMessageType(`livekit.RoomUpdate`,()=>[{no:1,name:`room`,kind:`message`,T:jg}]),tv=P.makeMessageType(`livekit.ConnectionQualityInfo`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`quality`,kind:`enum`,T:P.getEnumType(Tg)},{no:3,name:`score`,kind:`scalar`,T:2}]),nv=P.makeMessageType(`livekit.ConnectionQualityUpdate`,()=>[{no:1,name:`updates`,kind:`message`,T:tv,repeated:!0}]),rv=P.makeMessageType(`livekit.StreamStateInfo`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`track_sid`,kind:`scalar`,T:9},{no:3,name:`state`,kind:`enum`,T:P.getEnumType(S_)}]),iv=P.makeMessageType(`livekit.StreamStateUpdate`,()=>[{no:1,name:`stream_states`,kind:`message`,T:rv,repeated:!0}]),av=P.makeMessageType(`livekit.SubscribedQuality`,()=>[{no:1,name:`quality`,kind:`enum`,T:P.getEnumType(wg)},{no:2,name:`enabled`,kind:`scalar`,T:8}]),ov=P.makeMessageType(`livekit.SubscribedCodec`,()=>[{no:1,name:`codec`,kind:`scalar`,T:9},{no:2,name:`qualities`,kind:`message`,T:av,repeated:!0}]),sv=P.makeMessageType(`livekit.SubscribedQualityUpdate`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`subscribed_qualities`,kind:`message`,T:av,repeated:!0},{no:3,name:`subscribed_codecs`,kind:`message`,T:ov,repeated:!0}]),cv=P.makeMessageType(`livekit.SubscribedAudioCodecUpdate`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`subscribed_audio_codecs`,kind:`message`,T:b_,repeated:!0}]),lv=P.makeMessageType(`livekit.TrackPermission`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`all_tracks`,kind:`scalar`,T:8},{no:3,name:`track_sids`,kind:`scalar`,T:9,repeated:!0},{no:4,name:`participant_identity`,kind:`scalar`,T:9}]),uv=P.makeMessageType(`livekit.SubscriptionPermission`,()=>[{no:1,name:`all_participants`,kind:`scalar`,T:8},{no:2,name:`track_permissions`,kind:`message`,T:lv,repeated:!0}]),dv=P.makeMessageType(`livekit.SubscriptionPermissionUpdate`,()=>[{no:1,name:`participant_sid`,kind:`scalar`,T:9},{no:2,name:`track_sid`,kind:`scalar`,T:9},{no:3,name:`allowed`,kind:`scalar`,T:8}]),fv=P.makeMessageType(`livekit.RoomMovedResponse`,()=>[{no:1,name:`room`,kind:`message`,T:jg},{no:2,name:`token`,kind:`scalar`,T:9},{no:3,name:`participant`,kind:`message`,T:Pg},{no:4,name:`other_participants`,kind:`message`,T:Pg,repeated:!0}]),pv=P.makeMessageType(`livekit.SyncState`,()=>[{no:1,name:`answer`,kind:`message`,T:B_},{no:2,name:`subscription`,kind:`message`,T:H_},{no:3,name:`publish_tracks`,kind:`message`,T:R_,repeated:!0},{no:4,name:`data_channels`,kind:`message`,T:hv,repeated:!0},{no:5,name:`offer`,kind:`message`,T:B_},{no:6,name:`track_sids_disabled`,kind:`scalar`,T:9,repeated:!0},{no:7,name:`datachannel_receive_states`,kind:`message`,T:mv,repeated:!0},{no:8,name:`publish_data_tracks`,kind:`message`,T:k_,repeated:!0}]),mv=P.makeMessageType(`livekit.DataChannelReceiveState`,()=>[{no:1,name:`publisher_sid`,kind:`scalar`,T:9},{no:2,name:`last_seq`,kind:`scalar`,T:13}]),hv=P.makeMessageType(`livekit.DataChannelInfo`,()=>[{no:1,name:`label`,kind:`scalar`,T:9},{no:2,name:`id`,kind:`scalar`,T:13},{no:3,name:`target`,kind:`enum`,T:P.getEnumType(x_)}]),gv=P.makeMessageType(`livekit.SimulateScenario`,()=>[{no:1,name:`speaker_update`,kind:`scalar`,T:5,oneof:`scenario`},{no:2,name:`node_failure`,kind:`scalar`,T:8,oneof:`scenario`},{no:3,name:`migration`,kind:`scalar`,T:8,oneof:`scenario`},{no:4,name:`server_leave`,kind:`scalar`,T:8,oneof:`scenario`},{no:5,name:`switch_candidate_protocol`,kind:`enum`,T:P.getEnumType(C_),oneof:`scenario`},{no:6,name:`subscriber_bandwidth`,kind:`scalar`,T:3,oneof:`scenario`},{no:7,name:`disconnect_signal_on_resume`,kind:`scalar`,T:8,oneof:`scenario`},{no:8,name:`disconnect_signal_on_resume_no_messages`,kind:`scalar`,T:8,oneof:`scenario`},{no:9,name:`leave_request_full_reconnect`,kind:`scalar`,T:8,oneof:`scenario`}]),_v=P.makeMessageType(`livekit.Ping`,()=>[{no:1,name:`timestamp`,kind:`scalar`,T:3},{no:2,name:`rtt`,kind:`scalar`,T:3}]),vv=P.makeMessageType(`livekit.Pong`,()=>[{no:1,name:`last_ping_timestamp`,kind:`scalar`,T:3},{no:2,name:`timestamp`,kind:`scalar`,T:3}]),yv=P.makeMessageType(`livekit.RegionSettings`,()=>[{no:1,name:`regions`,kind:`message`,T:bv,repeated:!0}]),bv=P.makeMessageType(`livekit.RegionInfo`,()=>[{no:1,name:`region`,kind:`scalar`,T:9},{no:2,name:`url`,kind:`scalar`,T:9},{no:3,name:`distance`,kind:`scalar`,T:3}]),xv=P.makeMessageType(`livekit.SubscriptionResponse`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9},{no:2,name:`err`,kind:`enum`,T:P.getEnumType(kg)}]),Sv=P.makeMessageType(`livekit.RequestResponse`,()=>[{no:1,name:`request_id`,kind:`scalar`,T:13},{no:2,name:`reason`,kind:`enum`,T:P.getEnumType(Cv)},{no:3,name:`message`,kind:`scalar`,T:9},{no:4,name:`trickle`,kind:`message`,T:P_,oneof:`request`},{no:5,name:`add_track`,kind:`message`,T:D_,oneof:`request`},{no:6,name:`mute`,kind:`message`,T:F_,oneof:`request`},{no:7,name:`update_metadata`,kind:`message`,T:Z_,oneof:`request`},{no:8,name:`update_audio_track`,kind:`message`,T:K_,oneof:`request`},{no:9,name:`update_video_track`,kind:`message`,T:q_,oneof:`request`},{no:10,name:`publish_data_track`,kind:`message`,T:O_,oneof:`request`},{no:11,name:`unpublish_data_track`,kind:`message`,T:A_,oneof:`request`}]),Cv=P.makeEnum(`livekit.RequestResponse.Reason`,[{no:0,name:`OK`},{no:1,name:`NOT_FOUND`},{no:2,name:`NOT_ALLOWED`},{no:3,name:`LIMIT_EXCEEDED`},{no:4,name:`QUEUED`},{no:5,name:`UNSUPPORTED_TYPE`},{no:6,name:`UNCLASSIFIED_ERROR`},{no:7,name:`INVALID_HANDLE`},{no:8,name:`INVALID_NAME`},{no:9,name:`DUPLICATE_HANDLE`},{no:10,name:`DUPLICATE_NAME`}]),wv=P.makeMessageType(`livekit.TrackSubscribed`,()=>[{no:1,name:`track_sid`,kind:`scalar`,T:9}]),Tv=P.makeMessageType(`livekit.ConnectionSettings`,()=>[{no:1,name:`auto_subscribe`,kind:`scalar`,T:8},{no:2,name:`adaptive_stream`,kind:`scalar`,T:8},{no:3,name:`subscriber_allow_pause`,kind:`scalar`,T:8,opt:!0},{no:4,name:`disable_ice_lite`,kind:`scalar`,T:8},{no:5,name:`auto_subscribe_data_track`,kind:`scalar`,T:8,opt:!0}]),Ev=P.makeMessageType(`livekit.JoinRequest`,()=>[{no:1,name:`client_info`,kind:`message`,T:c_},{no:2,name:`connection_settings`,kind:`message`,T:Tv},{no:3,name:`metadata`,kind:`scalar`,T:9},{no:4,name:`participant_attributes`,kind:`map`,K:9,V:{kind:`scalar`,T:9}},{no:5,name:`add_track_requests`,kind:`message`,T:D_,repeated:!0},{no:6,name:`publisher_offer`,kind:`message`,T:B_},{no:7,name:`reconnect`,kind:`scalar`,T:8},{no:8,name:`reconnect_reason`,kind:`enum`,T:P.getEnumType(Og)},{no:9,name:`participant_sid`,kind:`scalar`,T:9},{no:10,name:`sync_state`,kind:`message`,T:pv}]),Dv=P.makeMessageType(`livekit.WrappedJoinRequest`,()=>[{no:1,name:`compression`,kind:`enum`,T:P.getEnumType(Ov)},{no:2,name:`join_request`,kind:`scalar`,T:12}]),Ov=P.makeEnum(`livekit.WrappedJoinRequest.Compression`,[{no:0,name:`NONE`},{no:1,name:`GZIP`}]),kv=P.makeMessageType(`livekit.MediaSectionsRequirement`,()=>[{no:1,name:`num_audios`,kind:`scalar`,T:13},{no:2,name:`num_videos`,kind:`scalar`,T:13}]);function Av(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,`default`)?e.default:e}var jv={exports:{}},Mv=jv.exports,Nv;function Pv(){return Nv?jv.exports:(Nv=1,(function(e){(function(t,n){e.exports?e.exports=n():t.log=n()})(Mv,function(){var e=function(){},t=`undefined`,n=typeof window!==t&&typeof window.navigator!==t&&/Trident\/|MSIE /.test(window.navigator.userAgent),r=[`trace`,`debug`,`info`,`warn`,`error`],i={},a=null;function o(e,t){var n=e[t];if(typeof n.bind==`function`)return n.bind(e);try{return Function.prototype.bind.call(n,e)}catch{return function(){return Function.prototype.apply.apply(n,[e,arguments])}}}function s(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function c(r){return r===`debug`&&(r=`log`),typeof console===t?!1:r===`trace`&&n?s:console[r]===void 0?console.log===void 0?e:o(console,`log`):o(console,r)}function l(){for(var n=this.getLevel(),i=0;i<r.length;i++){var a=r[i];this[a]=i<n?e:this.methodFactory(a,n,this.name)}if(this.log=this.debug,typeof console===t&&n<this.levels.SILENT)return`No console available for logging`}function u(e){return function(){typeof console!==t&&(l.call(this),this[e].apply(this,arguments))}}function d(e,t,n){return c(e)||u.apply(this,arguments)}function f(e,n){var o=this,s,c,u,f=`loglevel`;typeof e==`string`?f+=`:`+e:typeof e==`symbol`&&(f=void 0);function p(e){var n=(r[e]||`silent`).toUpperCase();if(!(typeof window===t||!f)){try{window.localStorage[f]=n;return}catch{}try{window.document.cookie=encodeURIComponent(f)+`=`+n+`;`}catch{}}}function m(){var e;if(!(typeof window===t||!f)){try{e=window.localStorage[f]}catch{}if(typeof e===t)try{var n=window.document.cookie,r=encodeURIComponent(f),i=n.indexOf(r+`=`);i!==-1&&(e=/^([^;]+)/.exec(n.slice(i+r.length+1))[1])}catch{}return o.levels[e]===void 0&&(e=void 0),e}}function h(){if(!(typeof window===t||!f)){try{window.localStorage.removeItem(f)}catch{}try{window.document.cookie=encodeURIComponent(f)+`=; expires=Thu, 01 Jan 1970 00:00:00 UTC`}catch{}}}function g(e){var t=e;if(typeof t==`string`&&o.levels[t.toUpperCase()]!==void 0&&(t=o.levels[t.toUpperCase()]),typeof t==`number`&&t>=0&&t<=o.levels.SILENT)return t;throw TypeError(`log.setLevel() called with invalid level: `+e)}o.name=e,o.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},o.methodFactory=n||d,o.getLevel=function(){return u??c??s},o.setLevel=function(e,t){return u=g(e),t!==!1&&p(u),l.call(o)},o.setDefaultLevel=function(e){c=g(e),m()||o.setLevel(e,!1)},o.resetLevel=function(){u=null,h(),l.call(o)},o.enableAll=function(e){o.setLevel(o.levels.TRACE,e)},o.disableAll=function(e){o.setLevel(o.levels.SILENT,e)},o.rebuild=function(){if(a!==o&&(s=g(a.getLevel())),l.call(o),a===o)for(var e in i)i[e].rebuild()},s=g(a?a.getLevel():`WARN`);var _=m();_!=null&&(u=g(_)),l.call(o)}a=new f,a.getLogger=function(e){if(typeof e!=`symbol`&&typeof e!=`string`||e===``)throw TypeError(`You must supply a name when creating a logger.`);var t=i[e];return t||=i[e]=new f(e,a.methodFactory),t};var p=typeof window===t?void 0:window.log;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return i},a.default=a,a})})(jv),jv.exports)}var Fv=Pv(),Iv;(function(e){e[e.trace=0]=`trace`,e[e.debug=1]=`debug`,e[e.info=2]=`info`,e[e.warn=3]=`warn`,e[e.error=4]=`error`,e[e.silent=5]=`silent`})(Iv||={});var Lv;(function(e){e.Default=`livekit`,e.Room=`livekit-room`,e.TokenSource=`livekit-token-source`,e.Participant=`livekit-participant`,e.Track=`livekit-track`,e.Publication=`livekit-track-publication`,e.Engine=`livekit-engine`,e.Signal=`livekit-signal`,e.PCManager=`livekit-pc-manager`,e.PCTransport=`livekit-pc-transport`,e.E2EE=`lk-e2ee`,e.DataTracks=`livekit-data-tracks`})(Lv||={});var I=Fv.getLogger(`livekit`);Object.values(Lv).map(e=>Fv.getLogger(e)),I.setDefaultLevel(Iv.info);function Rv(e){let t=Fv.getLogger(e);return t.setDefaultLevel(I.getLevel()),t}var zv=Fv.getLogger(`lk-e2ee`),Bv=7e3,Vv=[0,300,4*300,9*300,16*300,Bv,Bv,Bv,Bv,Bv],Hv=class{constructor(e){this._retryDelays=e===void 0?Vv:[...e]}nextRetryDelayInMs(e){if(e.retryCount>=this._retryDelays.length)return null;let t=this._retryDelays[e.retryCount];return e.retryCount<=1?t:t+Math.random()*1e3}};function Uv(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function L(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Wv(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Gv(e){return this instanceof Gv?(this.v=e,this):new Gv(e)}function Kv(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Gv?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function qv(e){var t,n;return t={},r(`next`),r(`throw`,function(e){throw e}),r(`return`),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:Gv(e[r](t)),done:!1}:i?i(t):t}:i}}function Jv(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Wv==`function`?Wv(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}var Yv={exports:{}},Xv;function Zv(){if(Xv)return Yv.exports;Xv=1;var e=typeof Reflect==`object`?Reflect:null,t=e&&typeof e.apply==`function`?e.apply:function(e,t,n){return Function.prototype.apply.call(e,t,n)},n=e&&typeof e.ownKeys==`function`?e.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};function r(e){console&&console.warn&&console.warn(e)}var i=Number.isNaN||function(e){return e!==e};function a(){a.init.call(this)}Yv.exports=a,Yv.exports.once=_,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function s(e){if(typeof e!=`function`)throw TypeError(`The "listener" argument must be of type Function. Received type `+typeof e)}Object.defineProperty(a,`defaultMaxListeners`,{enumerable:!0,get:function(){return o},set:function(e){if(typeof e!=`number`||e<0||i(e))throw RangeError(`The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received `+e+`.`);o=e}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(e){if(typeof e!=`number`||e<0||i(e))throw RangeError(`The value of "n" is out of range. It must be a non-negative number. Received `+e+`.`);return this._maxListeners=e,this};function c(e){return e._maxListeners===void 0?a.defaultMaxListeners:e._maxListeners}a.prototype.getMaxListeners=function(){return c(this)},a.prototype.emit=function(e){for(var n=[],r=1;r<arguments.length;r++)n.push(arguments[r]);var i=e===`error`,a=this._events;if(a!==void 0)i&&=a.error===void 0;else if(!i)return!1;if(i){var o;if(n.length>0&&(o=n[0]),o instanceof Error)throw o;var s=Error(`Unhandled error.`+(o?` (`+o.message+`)`:``));throw s.context=o,s}var c=a[e];if(c===void 0)return!1;if(typeof c==`function`)t(c,this,n);else for(var l=c.length,u=m(c,l),r=0;r<l;++r)t(u[r],this,n);return!0};function l(e,t,n,i){var a,o,l;if(s(n),o=e._events,o===void 0?(o=e._events=Object.create(null),e._eventsCount=0):(o.newListener!==void 0&&(e.emit(`newListener`,t,n.listener?n.listener:n),o=e._events),l=o[t]),l===void 0)l=o[t]=n,++e._eventsCount;else if(typeof l==`function`?l=o[t]=i?[n,l]:[l,n]:i?l.unshift(n):l.push(n),a=c(e),a>0&&l.length>a&&!l.warned){l.warned=!0;var u=Error(`Possible EventEmitter memory leak detected. `+l.length+` `+String(t)+` listeners added. Use emitter.setMaxListeners() to increase limit`);u.name=`MaxListenersExceededWarning`,u.emitter=e,u.type=t,u.count=l.length,r(u)}return e}a.prototype.addListener=function(e,t){return l(this,e,t,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(e,t){return l(this,e,t,!0)};function u(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,n){var r={fired:!1,wrapFn:void 0,target:e,type:t,listener:n},i=u.bind(r);return i.listener=n,r.wrapFn=i,i}a.prototype.once=function(e,t){return s(t),this.on(e,d(this,e,t)),this},a.prototype.prependOnceListener=function(e,t){return s(t),this.prependListener(e,d(this,e,t)),this},a.prototype.removeListener=function(e,t){var n,r,i,a,o;if(s(t),r=this._events,r===void 0||(n=r[e],n===void 0))return this;if(n===t||n.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[e],r.removeListener&&this.emit(`removeListener`,e,n.listener||t));else if(typeof n!=`function`){for(i=-1,a=n.length-1;a>=0;a--)if(n[a]===t||n[a].listener===t){o=n[a].listener,i=a;break}if(i<0)return this;i===0?n.shift():h(n,i),n.length===1&&(r[e]=n[0]),r.removeListener!==void 0&&this.emit(`removeListener`,e,o||t)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(e){var t,n=this._events,r;if(n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var i=Object.keys(n),a;for(r=0;r<i.length;++r)a=i[r],a!==`removeListener`&&this.removeAllListeners(a);return this.removeAllListeners(`removeListener`),this._events=Object.create(null),this._eventsCount=0,this}if(t=n[e],typeof t==`function`)this.removeListener(e,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(e,t[r]);return this};function f(e,t,n){var r=e._events;if(r===void 0)return[];var i=r[t];return i===void 0?[]:typeof i==`function`?n?[i.listener||i]:[i]:n?g(i):m(i,i.length)}a.prototype.listeners=function(e){return f(this,e,!0)},a.prototype.rawListeners=function(e){return f(this,e,!1)},a.listenerCount=function(e,t){return typeof e.listenerCount==`function`?e.listenerCount(t):p.call(e,t)},a.prototype.listenerCount=p;function p(e){var t=this._events;if(t!==void 0){var n=t[e];if(typeof n==`function`)return 1;if(n!==void 0)return n.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function m(e,t){for(var n=Array(t),r=0;r<t;++r)n[r]=e[r];return n}function h(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function g(e){for(var t=Array(e.length),n=0;n<t.length;++n)t[n]=e[n].listener||e[n];return t}function _(e,t){return new Promise(function(n,r){function i(n){e.removeListener(t,a),r(n)}function a(){typeof e.removeListener==`function`&&e.removeListener(`error`,i),n([].slice.call(arguments))}y(e,t,a,{once:!0}),t!==`error`&&v(e,i,{once:!0})})}function v(e,t,n){typeof e.on==`function`&&y(e,`error`,t,n)}function y(e,t,n,r){if(typeof e.on==`function`)r.once?e.once(t,n):e.on(t,n);else if(typeof e.addEventListener==`function`)e.addEventListener(t,function i(a){r.once&&e.removeEventListener(t,i),n(a)});else throw TypeError(`The "emitter" argument must be of type EventEmitter. Received type `+typeof e)}return Yv.exports}var Qv=Zv(),$v=!0,ey=!0;function ty(e,t,n){let r=e.match(t);return r&&r.length>=n&&parseFloat(r[n],10)}function ny(e,t,n){if(!e.RTCPeerConnection)return;let r=e.RTCPeerConnection.prototype,i=r.addEventListener;r.addEventListener=function(e,r){if(e!==t)return i.apply(this,arguments);let a=e=>{let t=n(e);t&&(r.handleEvent?r.handleEvent(t):r(t))};return this._eventMap=this._eventMap||{},this._eventMap[t]||(this._eventMap[t]=new Map),this._eventMap[t].set(r,a),i.apply(this,[e,a])};let a=r.removeEventListener;r.removeEventListener=function(e,n){if(e!==t||!this._eventMap||!this._eventMap[t]||!this._eventMap[t].has(n))return a.apply(this,arguments);let r=this._eventMap[t].get(n);return this._eventMap[t].delete(n),this._eventMap[t].size===0&&delete this._eventMap[t],Object.keys(this._eventMap).length===0&&delete this._eventMap,a.apply(this,[e,r])},Object.defineProperty(r,`on`+t,{get(){return this[`_on`+t]},set(e){this[`_on`+t]&&(this.removeEventListener(t,this[`_on`+t]),delete this[`_on`+t]),e&&this.addEventListener(t,this[`_on`+t]=e)},enumerable:!0,configurable:!0})}function ry(e){return typeof e==`boolean`?($v=e,e?`adapter.js logging disabled`:`adapter.js logging enabled`):Error(`Argument type: `+typeof e+`. Please use a boolean.`)}function iy(e){return typeof e==`boolean`?(ey=!e,`adapter.js deprecation warnings `+(e?`disabled`:`enabled`)):Error(`Argument type: `+typeof e+`. Please use a boolean.`)}function ay(){if(typeof window==`object`){if($v)return;typeof console<`u`&&typeof console.log==`function`&&console.log.apply(console,arguments)}}function oy(e,t){ey&&console.warn(e+` is deprecated, please use `+t+` instead.`)}function sy(e){let t={browser:null,version:null};if(e===void 0||!e.navigator||!e.navigator.userAgent)return t.browser=`Not a browser.`,t;let{navigator:n}=e;if(n.userAgentData&&n.userAgentData.brands){let e=n.userAgentData.brands.find(e=>e.brand===`Chromium`);if(e)return{browser:`chrome`,version:parseInt(e.version,10)}}if(n.mozGetUserMedia)t.browser=`firefox`,t.version=parseInt(ty(n.userAgent,/Firefox\/(\d+)\./,1));else if(n.webkitGetUserMedia||e.isSecureContext===!1&&e.webkitRTCPeerConnection)t.browser=`chrome`,t.version=parseInt(ty(n.userAgent,/Chrom(e|ium)\/(\d+)\./,2));else if(e.RTCPeerConnection&&n.userAgent.match(/AppleWebKit\/(\d+)\./))t.browser=`safari`,t.version=parseInt(ty(n.userAgent,/AppleWebKit\/(\d+)\./,1)),t.supportsUnifiedPlan=e.RTCRtpTransceiver&&`currentDirection`in e.RTCRtpTransceiver.prototype,t._safariVersion=ty(n.userAgent,/Version\/(\d+(\.?\d+))/,1);else return t.browser=`Not a supported browser.`,t;return t}function cy(e){return Object.prototype.toString.call(e)===`[object Object]`}function ly(e){return cy(e)?Object.keys(e).reduce(function(t,n){let r=cy(e[n]),i=r?ly(e[n]):e[n],a=r&&!Object.keys(i).length;return i===void 0||a?t:Object.assign(t,{[n]:i})},{}):e}function uy(e,t,n){!t||n.has(t.id)||(n.set(t.id,t),Object.keys(t).forEach(r=>{r.endsWith(`Id`)?uy(e,e.get(t[r]),n):r.endsWith(`Ids`)&&t[r].forEach(t=>{uy(e,e.get(t),n)})}))}function dy(e,t,n){let r=n?`outbound-rtp`:`inbound-rtp`,i=new Map;if(t===null)return i;let a=[];return e.forEach(e=>{e.type===`track`&&e.trackIdentifier===t.id&&a.push(e)}),a.forEach(t=>{e.forEach(n=>{n.type===r&&n.trackId===t.id&&uy(e,n,i)})}),i}var fy=ay;function py(e,t){let n=e&&e.navigator;if(!n.mediaDevices)return;let r=function(e){if(typeof e!=`object`||e.mandatory||e.optional)return e;let t={};return Object.keys(e).forEach(n=>{if(n===`require`||n===`advanced`||n===`mediaSource`)return;let r=typeof e[n]==`object`?e[n]:{ideal:e[n]};r.exact!==void 0&&typeof r.exact==`number`&&(r.min=r.max=r.exact);let i=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):t===`deviceId`?`sourceId`:t};if(r.ideal!==void 0){t.optional=t.optional||[];let e={};typeof r.ideal==`number`?(e[i(`min`,n)]=r.ideal,t.optional.push(e),e={},e[i(`max`,n)]=r.ideal,t.optional.push(e)):(e[i(``,n)]=r.ideal,t.optional.push(e))}r.exact!==void 0&&typeof r.exact!=`number`?(t.mandatory=t.mandatory||{},t.mandatory[i(``,n)]=r.exact):[`min`,`max`].forEach(e=>{r[e]!==void 0&&(t.mandatory=t.mandatory||{},t.mandatory[i(e,n)]=r[e])})}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},i=function(e,i){if(t.version>=61)return i(e);if(e=JSON.parse(JSON.stringify(e)),e&&typeof e.audio==`object`){let t=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])};e=JSON.parse(JSON.stringify(e)),t(e.audio,`autoGainControl`,`googAutoGainControl`),t(e.audio,`noiseSuppression`,`googNoiseSuppression`),e.audio=r(e.audio)}if(e&&typeof e.video==`object`){let a=e.video.facingMode;a&&=typeof a==`object`?a:{ideal:a};let o=t.version<66;if(a&&(a.exact===`user`||a.exact===`environment`||a.ideal===`user`||a.ideal===`environment`)&&!(n.mediaDevices.getSupportedConstraints&&n.mediaDevices.getSupportedConstraints().facingMode&&!o)){delete e.video.facingMode;let t;if(a.exact===`environment`||a.ideal===`environment`?t=[`back`,`rear`]:(a.exact===`user`||a.ideal===`user`)&&(t=[`front`]),t)return n.mediaDevices.enumerateDevices().then(n=>{n=n.filter(e=>e.kind===`videoinput`);let o=n.find(e=>t.some(t=>e.label.toLowerCase().includes(t)));return!o&&n.length&&t.includes(`back`)&&(o=n[n.length-1]),o&&(e.video.deviceId=a.exact?{exact:o.deviceId}:{ideal:o.deviceId}),e.video=r(e.video),fy(`chrome: `+JSON.stringify(e)),i(e)})}e.video=r(e.video)}return fy(`chrome: `+JSON.stringify(e)),i(e)},a=function(e){return t.version>=64?e:{name:{PermissionDeniedError:`NotAllowedError`,PermissionDismissedError:`NotAllowedError`,InvalidStateError:`NotAllowedError`,DevicesNotFoundError:`NotFoundError`,ConstraintNotSatisfiedError:`OverconstrainedError`,TrackStartError:`NotReadableError`,MediaDeviceFailedDueToShutdown:`NotAllowedError`,MediaDeviceKillSwitchOn:`NotAllowedError`,TabCaptureError:`AbortError`,ScreenCaptureError:`AbortError`,DeviceCaptureError:`AbortError`}[e.name]||e.name,message:e.message,constraint:e.constraint||e.constraintName,toString(){return this.name+(this.message&&`: `)+this.message}}};if(n.getUserMedia=function(e,t,r){i(e,e=>{n.webkitGetUserMedia(e,t,e=>{r&&r(a(e))})})}.bind(n),n.mediaDevices.getUserMedia){let e=n.mediaDevices.getUserMedia.bind(n.mediaDevices);n.mediaDevices.getUserMedia=function(t){return i(t,t=>e(t).then(e=>{if(t.audio&&!e.getAudioTracks().length||t.video&&!e.getVideoTracks().length)throw e.getTracks().forEach(e=>{e.stop()}),new DOMException(``,`NotFoundError`);return e},e=>Promise.reject(a(e))))}}}function my(e){e.MediaStream=e.MediaStream||e.webkitMediaStream}function hy(e){if(typeof e==`object`&&e.RTCPeerConnection&&!(`ontrack`in e.RTCPeerConnection.prototype)){Object.defineProperty(e.RTCPeerConnection.prototype,`ontrack`,{get(){return this._ontrack},set(e){this._ontrack&&this.removeEventListener(`track`,this._ontrack),this.addEventListener(`track`,this._ontrack=e)},enumerable:!0,configurable:!0});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){return this._ontrackpoly||(this._ontrackpoly=t=>{t.stream.addEventListener(`addtrack`,n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.track.id):{track:n.track};let i=new Event(`track`);i.track=n.track,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)}),t.stream.getTracks().forEach(n=>{let r;r=e.RTCPeerConnection.prototype.getReceivers?this.getReceivers().find(e=>e.track&&e.track.id===n.id):{track:n};let i=new Event(`track`);i.track=n,i.receiver=r,i.transceiver={receiver:r},i.streams=[t.stream],this.dispatchEvent(i)})},this.addEventListener(`addstream`,this._ontrackpoly)),t.apply(this,arguments)}}else ny(e,`track`,e=>(e.transceiver||Object.defineProperty(e,`transceiver`,{value:{receiver:e.receiver}}),e))}function gy(e){if(typeof e==`object`&&e.RTCPeerConnection&&!(`getSenders`in e.RTCPeerConnection.prototype)&&`createDTMFSender`in e.RTCPeerConnection.prototype){let t=function(e,t){return{track:t,get dtmf(){return this._dtmf===void 0&&(t.kind===`audio`?this._dtmf=e.createDTMFSender(t):this._dtmf=null),this._dtmf},_pc:e}};if(!e.RTCPeerConnection.prototype.getSenders){e.RTCPeerConnection.prototype.getSenders=function(){return this._senders=this._senders||[],this._senders.slice()};let n=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,r){let i=n.apply(this,arguments);return i||(i=t(this,e),this._senders.push(i)),i};let r=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){r.apply(this,arguments);let t=this._senders.indexOf(e);t!==-1&&this._senders.splice(t,1)}}let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._senders=this._senders||[],n.apply(this,[e]),e.getTracks().forEach(e=>{this._senders.push(t(this,e))})};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._senders=this._senders||[],r.apply(this,[e]),e.getTracks().forEach(e=>{let t=this._senders.find(t=>t.track===e);t&&this._senders.splice(this._senders.indexOf(t),1)})}}else if(typeof e==`object`&&e.RTCPeerConnection&&`getSenders`in e.RTCPeerConnection.prototype&&`createDTMFSender`in e.RTCPeerConnection.prototype&&e.RTCRtpSender&&!(`dtmf`in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e},Object.defineProperty(e.RTCRtpSender.prototype,`dtmf`,{get(){return this._dtmf===void 0&&(this.track.kind===`audio`?this._dtmf=this._pc.createDTMFSender(this.track):this._dtmf=null),this._dtmf}})}}function _y(e){if(!(typeof e==`object`&&e.RTCPeerConnection&&e.RTCRtpSender&&e.RTCRtpReceiver))return;if(!(`getStats`in e.RTCRtpSender.prototype)){let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});let n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){let e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){let e=this;return this._pc.getStats().then(t=>dy(t,e.track,!0))}}if(!(`getStats`in e.RTCRtpReceiver.prototype)){let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),ny(e,`track`,e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){let e=this;return this._pc.getStats().then(t=>dy(t,e.track,!1))}}if(!(`getStats`in e.RTCRtpSender.prototype&&`getStats`in e.RTCRtpReceiver.prototype))return;let t=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){if(arguments.length>0&&arguments[0]instanceof e.MediaStreamTrack){let e=arguments[0],t,n,r;return this.getSenders().forEach(n=>{n.track===e&&(t?r=!0:t=n)}),this.getReceivers().forEach(t=>(t.track===e&&(n?r=!0:n=t),t.track===e)),r||t&&n?Promise.reject(new DOMException(`There are more than one sender or receiver for the track.`,`InvalidAccessError`)):t?t.getStats():n?n.getStats():Promise.reject(new DOMException(`There is no sender or receiver for the track.`,`InvalidAccessError`))}return t.apply(this,arguments)}}function vy(e){e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},Object.keys(this._shimmedLocalStreams).map(e=>this._shimmedLocalStreams[e][0])};let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addTrack=function(e,n){if(!n)return t.apply(this,arguments);this._shimmedLocalStreams=this._shimmedLocalStreams||{};let r=t.apply(this,arguments);return this._shimmedLocalStreams[n.id]?this._shimmedLocalStreams[n.id].indexOf(r)===-1&&this._shimmedLocalStreams[n.id].push(r):this._shimmedLocalStreams[n.id]=[n,r],r};let n=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(e){this._shimmedLocalStreams=this._shimmedLocalStreams||{},e.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException(`Track already exists.`,`InvalidAccessError`)});let t=this.getSenders();n.apply(this,arguments);let r=this.getSenders().filter(e=>t.indexOf(e)===-1);this._shimmedLocalStreams[e.id]=[e].concat(r)};let r=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},delete this._shimmedLocalStreams[e.id],r.apply(this,arguments)};let i=e.RTCPeerConnection.prototype.removeTrack;e.RTCPeerConnection.prototype.removeTrack=function(e){return this._shimmedLocalStreams=this._shimmedLocalStreams||{},e&&Object.keys(this._shimmedLocalStreams).forEach(t=>{let n=this._shimmedLocalStreams[t].indexOf(e);n!==-1&&this._shimmedLocalStreams[t].splice(n,1),this._shimmedLocalStreams[t].length===1&&delete this._shimmedLocalStreams[t]}),i.apply(this,arguments)}}function yy(e,t){if(!e.RTCPeerConnection)return;if(e.RTCPeerConnection.prototype.addTrack&&t.version>=65)return vy(e);let n=e.RTCPeerConnection.prototype.getLocalStreams;e.RTCPeerConnection.prototype.getLocalStreams=function(){let e=n.apply(this);return this._reverseStreams=this._reverseStreams||{},e.map(e=>this._reverseStreams[e.id])};let r=e.RTCPeerConnection.prototype.addStream;e.RTCPeerConnection.prototype.addStream=function(t){if(this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},t.getTracks().forEach(e=>{if(this.getSenders().find(t=>t.track===e))throw new DOMException(`Track already exists.`,`InvalidAccessError`)}),!this._reverseStreams[t.id]){let n=new e.MediaStream(t.getTracks());this._streams[t.id]=n,this._reverseStreams[n.id]=t,t=n}r.apply(this,[t])};let i=e.RTCPeerConnection.prototype.removeStream;e.RTCPeerConnection.prototype.removeStream=function(e){this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{},i.apply(this,[this._streams[e.id]||e]),delete this._reverseStreams[this._streams[e.id]?this._streams[e.id].id:e.id],delete this._streams[e.id]},e.RTCPeerConnection.prototype.addTrack=function(t,n){if(this.signalingState===`closed`)throw new DOMException(`The RTCPeerConnection's signalingState is 'closed'.`,`InvalidStateError`);let r=[].slice.call(arguments,1);if(r.length!==1||!r[0].getTracks().find(e=>e===t))throw new DOMException(`The adapter.js addTrack polyfill only supports a single stream which is associated with the specified track.`,`NotSupportedError`);if(this.getSenders().find(e=>e.track===t))throw new DOMException(`Track already exists.`,`InvalidAccessError`);this._streams=this._streams||{},this._reverseStreams=this._reverseStreams||{};let i=this._streams[n.id];if(i)i.addTrack(t),Promise.resolve().then(()=>{this.dispatchEvent(new Event(`negotiationneeded`))});else{let r=new e.MediaStream([t]);this._streams[n.id]=r,this._reverseStreams[r.id]=n,this.addStream(r)}return this.getSenders().find(e=>e.track===t)};function a(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{let r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(i.id,`g`),r.id)}),new RTCSessionDescription({type:t.type,sdp:n})}function o(e,t){let n=t.sdp;return Object.keys(e._reverseStreams||[]).forEach(t=>{let r=e._reverseStreams[t],i=e._streams[r.id];n=n.replace(new RegExp(r.id,`g`),i.id)}),new RTCSessionDescription({type:t.type,sdp:n})}[`createOffer`,`createAnswer`].forEach(function(t){let n=e.RTCPeerConnection.prototype[t],r={[t](){let e=arguments;return arguments.length&&typeof arguments[0]==`function`?n.apply(this,[t=>{let n=a(this,t);e[0].apply(null,[n])},t=>{e[1]&&e[1].apply(null,t)},arguments[2]]):n.apply(this,arguments).then(e=>a(this,e))}};e.RTCPeerConnection.prototype[t]=r[t]});let s=e.RTCPeerConnection.prototype.setLocalDescription;e.RTCPeerConnection.prototype.setLocalDescription=function(){return!arguments.length||!arguments[0].type||(arguments[0]=o(this,arguments[0])),s.apply(this,arguments)};let c=Object.getOwnPropertyDescriptor(e.RTCPeerConnection.prototype,`localDescription`);Object.defineProperty(e.RTCPeerConnection.prototype,`localDescription`,{get(){let e=c.get.apply(this);return e.type===``?e:a(this,e)}}),e.RTCPeerConnection.prototype.removeTrack=function(e){if(this.signalingState===`closed`)throw new DOMException(`The RTCPeerConnection's signalingState is 'closed'.`,`InvalidStateError`);if(!e._pc)throw new DOMException(`Argument 1 of RTCPeerConnection.removeTrack does not implement interface RTCRtpSender.`,`TypeError`);if(e._pc!==this)throw new DOMException(`Sender was not created by this connection.`,`InvalidAccessError`);this._streams=this._streams||{};let t;Object.keys(this._streams).forEach(n=>{this._streams[n].getTracks().find(t=>e.track===t)&&(t=this._streams[n])}),t&&(t.getTracks().length===1?this.removeStream(this._reverseStreams[t.id]):t.removeTrack(e.track),this.dispatchEvent(new Event(`negotiationneeded`)))}}function by(e,t){!e.RTCPeerConnection&&e.webkitRTCPeerConnection&&(e.RTCPeerConnection=e.webkitRTCPeerConnection),e.RTCPeerConnection&&t.version<53&&[`setLocalDescription`,`setRemoteDescription`,`addIceCandidate`].forEach(function(t){let n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new(t===`addIceCandidate`?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]})}function xy(e,t){ny(e,`negotiationneeded`,e=>{let n=e.target;if(!((t.version<72||n.getConfiguration&&n.getConfiguration().sdpSemantics===`plan-b`)&&n.signalingState!==`stable`))return e})}var Sy=Object.freeze({__proto__:null,fixNegotiationNeeded:xy,shimAddTrackRemoveTrack:yy,shimAddTrackRemoveTrackWithNative:vy,shimGetSendersWithDtmf:gy,shimGetUserMedia:py,shimMediaStream:my,shimOnTrack:hy,shimPeerConnection:by,shimSenderReceiverGetStats:_y});function Cy(e,t){let n=e&&e.navigator,r=e&&e.MediaStreamTrack;if(n.getUserMedia=function(e,t,r){oy(`navigator.getUserMedia`,`navigator.mediaDevices.getUserMedia`),n.mediaDevices.getUserMedia(e).then(t,r)},!(t.version>55&&`autoGainControl`in n.mediaDevices.getSupportedConstraints())){let e=function(e,t,n){t in e&&!(n in e)&&(e[n]=e[t],delete e[t])},t=n.mediaDevices.getUserMedia.bind(n.mediaDevices);if(n.mediaDevices.getUserMedia=function(n){return typeof n==`object`&&typeof n.audio==`object`&&(n=JSON.parse(JSON.stringify(n)),e(n.audio,`autoGainControl`,`mozAutoGainControl`),e(n.audio,`noiseSuppression`,`mozNoiseSuppression`)),t(n)},r&&r.prototype.getSettings){let t=r.prototype.getSettings;r.prototype.getSettings=function(){let n=t.apply(this,arguments);return e(n,`mozAutoGainControl`,`autoGainControl`),e(n,`mozNoiseSuppression`,`noiseSuppression`),n}}if(r&&r.prototype.applyConstraints){let t=r.prototype.applyConstraints;r.prototype.applyConstraints=function(n){return this.kind===`audio`&&typeof n==`object`&&(n=JSON.parse(JSON.stringify(n)),e(n,`autoGainControl`,`mozAutoGainControl`),e(n,`noiseSuppression`,`mozNoiseSuppression`)),t.apply(this,[n])}}}}function wy(e,t){e.navigator.mediaDevices&&`getDisplayMedia`in e.navigator.mediaDevices||e.navigator.mediaDevices&&(e.navigator.mediaDevices.getDisplayMedia=function(n){if(!(n&&n.video)){let e=new DOMException(`getDisplayMedia without video constraints is undefined`);return e.name=`NotFoundError`,e.code=8,Promise.reject(e)}return n.video===!0?n.video={mediaSource:t}:n.video.mediaSource=t,e.navigator.mediaDevices.getUserMedia(n)})}function Ty(e){typeof e==`object`&&e.RTCTrackEvent&&`receiver`in e.RTCTrackEvent.prototype&&!(`transceiver`in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,`transceiver`,{get(){return{receiver:this.receiver}}})}function Ey(e,t){if(typeof e!=`object`||!(e.RTCPeerConnection||e.mozRTCPeerConnection))return;!e.RTCPeerConnection&&e.mozRTCPeerConnection&&(e.RTCPeerConnection=e.mozRTCPeerConnection),t.version<53&&[`setLocalDescription`,`setRemoteDescription`,`addIceCandidate`].forEach(function(t){let n=e.RTCPeerConnection.prototype[t],r={[t](){return arguments[0]=new(t===`addIceCandidate`?e.RTCIceCandidate:e.RTCSessionDescription)(arguments[0]),n.apply(this,arguments)}};e.RTCPeerConnection.prototype[t]=r[t]});let n={inboundrtp:`inbound-rtp`,outboundrtp:`outbound-rtp`,candidatepair:`candidate-pair`,localcandidate:`local-candidate`,remotecandidate:`remote-candidate`},r=e.RTCPeerConnection.prototype.getStats;e.RTCPeerConnection.prototype.getStats=function(){let[e,i,a]=arguments;return r.apply(this,[e||null]).then(e=>{if(t.version<53&&!i)try{e.forEach(e=>{e.type=n[e.type]||e.type})}catch(t){if(t.name!==`TypeError`)throw t;e.forEach((t,r)=>{e.set(r,Object.assign({},t,{type:n[t.type]||t.type}))})}return e}).then(i,a)}}function Dy(e){if(!(typeof e==`object`&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&`getStats`in e.RTCRtpSender.prototype)return;let t=e.RTCPeerConnection.prototype.getSenders;t&&(e.RTCPeerConnection.prototype.getSenders=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e});let n=e.RTCPeerConnection.prototype.addTrack;n&&(e.RTCPeerConnection.prototype.addTrack=function(){let e=n.apply(this,arguments);return e._pc=this,e}),e.RTCRtpSender.prototype.getStats=function(){return this.track?this._pc.getStats(this.track):Promise.resolve(new Map)}}function Oy(e){if(!(typeof e==`object`&&e.RTCPeerConnection&&e.RTCRtpSender)||e.RTCRtpSender&&`getStats`in e.RTCRtpReceiver.prototype)return;let t=e.RTCPeerConnection.prototype.getReceivers;t&&(e.RTCPeerConnection.prototype.getReceivers=function(){let e=t.apply(this,[]);return e.forEach(e=>e._pc=this),e}),ny(e,`track`,e=>(e.receiver._pc=e.srcElement,e)),e.RTCRtpReceiver.prototype.getStats=function(){return this._pc.getStats(this.track)}}function ky(e){!e.RTCPeerConnection||`removeStream`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){oy(`removeStream`,`removeTrack`),this.getSenders().forEach(t=>{t.track&&e.getTracks().includes(t.track)&&this.removeTrack(t)})})}function Ay(e){e.DataChannel&&!e.RTCDataChannel&&(e.RTCDataChannel=e.DataChannel)}function jy(e){if(!(typeof e==`object`&&e.RTCPeerConnection))return;let t=e.RTCPeerConnection.prototype.addTransceiver;t&&(e.RTCPeerConnection.prototype.addTransceiver=function(){this.setParametersPromises=[];let e=arguments[1]&&arguments[1].sendEncodings;e===void 0&&(e=[]),e=[...e];let n=e.length>0;n&&e.forEach(e=>{if(`rid`in e&&!/^[a-z0-9]{0,16}$/i.test(e.rid))throw TypeError(`Invalid RID value provided.`);if(`scaleResolutionDownBy`in e&&!(parseFloat(e.scaleResolutionDownBy)>=1))throw RangeError(`scale_resolution_down_by must be >= 1.0`);if(`maxFramerate`in e&&!(parseFloat(e.maxFramerate)>=0))throw RangeError(`max_framerate must be >= 0.0`)});let r=t.apply(this,arguments);if(n){let{sender:t}=r,n=t.getParameters();(!(`encodings`in n)||n.encodings.length===1&&Object.keys(n.encodings[0]).length===0)&&(n.encodings=e,t.sendEncodings=e,this.setParametersPromises.push(t.setParameters(n).then(()=>{delete t.sendEncodings}).catch(()=>{delete t.sendEncodings})))}return r})}function My(e){if(!(typeof e==`object`&&e.RTCRtpSender))return;let t=e.RTCRtpSender.prototype.getParameters;t&&(e.RTCRtpSender.prototype.getParameters=function(){let e=t.apply(this,arguments);return`encodings`in e||(e.encodings=[].concat(this.sendEncodings||[{}])),e})}function Ny(e){if(!(typeof e==`object`&&e.RTCPeerConnection))return;let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}function Py(e){if(!(typeof e==`object`&&e.RTCPeerConnection))return;let t=e.RTCPeerConnection.prototype.createAnswer;e.RTCPeerConnection.prototype.createAnswer=function(){return this.setParametersPromises&&this.setParametersPromises.length?Promise.all(this.setParametersPromises).then(()=>t.apply(this,arguments)).finally(()=>{this.setParametersPromises=[]}):t.apply(this,arguments)}}var Fy=Object.freeze({__proto__:null,shimAddTransceiver:jy,shimCreateAnswer:Py,shimCreateOffer:Ny,shimGetDisplayMedia:wy,shimGetParameters:My,shimGetUserMedia:Cy,shimOnTrack:Ty,shimPeerConnection:Ey,shimRTCDataChannel:Ay,shimReceiverGetStats:Oy,shimRemoveStream:ky,shimSenderGetStats:Dy});function Iy(e){if(!(typeof e!=`object`||!e.RTCPeerConnection)){if(`getLocalStreams`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getLocalStreams=function(){return this._localStreams||=[],this._localStreams}),!(`addStream`in e.RTCPeerConnection.prototype)){let t=e.RTCPeerConnection.prototype.addTrack;e.RTCPeerConnection.prototype.addStream=function(e){this._localStreams||=[],this._localStreams.includes(e)||this._localStreams.push(e),e.getAudioTracks().forEach(n=>t.call(this,n,e)),e.getVideoTracks().forEach(n=>t.call(this,n,e))},e.RTCPeerConnection.prototype.addTrack=function(e){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r&&r.forEach(e=>{this._localStreams?this._localStreams.includes(e)||this._localStreams.push(e):this._localStreams=[e]}),t.apply(this,arguments)}}`removeStream`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.removeStream=function(e){this._localStreams||=[];let t=this._localStreams.indexOf(e);if(t===-1)return;this._localStreams.splice(t,1);let n=e.getTracks();this.getSenders().forEach(e=>{n.includes(e.track)&&this.removeTrack(e)})})}}function Ly(e){if(!(typeof e!=`object`||!e.RTCPeerConnection)&&(`getRemoteStreams`in e.RTCPeerConnection.prototype||(e.RTCPeerConnection.prototype.getRemoteStreams=function(){return this._remoteStreams?this._remoteStreams:[]}),!(`onaddstream`in e.RTCPeerConnection.prototype))){Object.defineProperty(e.RTCPeerConnection.prototype,`onaddstream`,{get(){return this._onaddstream},set(e){this._onaddstream&&(this.removeEventListener(`addstream`,this._onaddstream),this.removeEventListener(`track`,this._onaddstreampoly)),this.addEventListener(`addstream`,this._onaddstream=e),this.addEventListener(`track`,this._onaddstreampoly=e=>{e.streams.forEach(e=>{if(this._remoteStreams||=[],this._remoteStreams.includes(e))return;this._remoteStreams.push(e);let t=new Event(`addstream`);t.stream=e,this.dispatchEvent(t)})})}});let t=e.RTCPeerConnection.prototype.setRemoteDescription;e.RTCPeerConnection.prototype.setRemoteDescription=function(){let e=this;return this._onaddstreampoly||this.addEventListener(`track`,this._onaddstreampoly=function(t){t.streams.forEach(t=>{if(e._remoteStreams||=[],e._remoteStreams.indexOf(t)>=0)return;e._remoteStreams.push(t);let n=new Event(`addstream`);n.stream=t,e.dispatchEvent(n)})}),t.apply(e,arguments)}}}function Ry(e){if(typeof e!=`object`||!e.RTCPeerConnection)return;let t=e.RTCPeerConnection.prototype,n=t.createOffer,r=t.createAnswer,i=t.setLocalDescription,a=t.setRemoteDescription,o=t.addIceCandidate;t.createOffer=function(e,t){let r=arguments.length>=2?arguments[2]:arguments[0],i=n.apply(this,[r]);return t?(i.then(e,t),Promise.resolve()):i},t.createAnswer=function(e,t){let n=arguments.length>=2?arguments[2]:arguments[0],i=r.apply(this,[n]);return t?(i.then(e,t),Promise.resolve()):i};let s=function(e,t,n){let r=i.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r};t.setLocalDescription=s,s=function(e,t,n){let r=a.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.setRemoteDescription=s,s=function(e,t,n){let r=o.apply(this,[e]);return n?(r.then(t,n),Promise.resolve()):r},t.addIceCandidate=s}function zy(e){let t=e&&e.navigator;if(t.mediaDevices&&t.mediaDevices.getUserMedia){let e=t.mediaDevices,n=e.getUserMedia.bind(e);t.mediaDevices.getUserMedia=e=>n(By(e))}!t.getUserMedia&&t.mediaDevices&&t.mediaDevices.getUserMedia&&(t.getUserMedia=function(e,n,r){t.mediaDevices.getUserMedia(e).then(n,r)}.bind(t))}function By(e){return e&&e.video!==void 0?Object.assign({},e,{video:ly(e.video)}):e}function Vy(e){if(!e.RTCPeerConnection)return;let t=e.RTCPeerConnection;e.RTCPeerConnection=function(e,n){if(e&&e.iceServers){let t=[];for(let n=0;n<e.iceServers.length;n++){let r=e.iceServers[n];r.urls===void 0&&r.url?(oy(`RTCIceServer.url`,`RTCIceServer.urls`),r=JSON.parse(JSON.stringify(r)),r.urls=r.url,delete r.url,t.push(r)):t.push(e.iceServers[n])}e.iceServers=t}return new t(e,n)},e.RTCPeerConnection.prototype=t.prototype,`generateCertificate`in t&&Object.defineProperty(e.RTCPeerConnection,`generateCertificate`,{get(){return t.generateCertificate}})}function Hy(e){typeof e==`object`&&e.RTCTrackEvent&&`receiver`in e.RTCTrackEvent.prototype&&!(`transceiver`in e.RTCTrackEvent.prototype)&&Object.defineProperty(e.RTCTrackEvent.prototype,`transceiver`,{get(){return{receiver:this.receiver}}})}function Uy(e){let t=e.RTCPeerConnection.prototype.createOffer;e.RTCPeerConnection.prototype.createOffer=function(e){if(e){e.offerToReceiveAudio!==void 0&&(e.offerToReceiveAudio=!!e.offerToReceiveAudio);let t=this.getTransceivers().find(e=>e.receiver.track.kind===`audio`);e.offerToReceiveAudio===!1&&t?t.direction===`sendrecv`?t.setDirection?t.setDirection(`sendonly`):t.direction=`sendonly`:t.direction===`recvonly`&&(t.setDirection?t.setDirection(`inactive`):t.direction=`inactive`):e.offerToReceiveAudio===!0&&!t&&this.addTransceiver(`audio`,{direction:`recvonly`}),e.offerToReceiveVideo!==void 0&&(e.offerToReceiveVideo=!!e.offerToReceiveVideo);let n=this.getTransceivers().find(e=>e.receiver.track.kind===`video`);e.offerToReceiveVideo===!1&&n?n.direction===`sendrecv`?n.setDirection?n.setDirection(`sendonly`):n.direction=`sendonly`:n.direction===`recvonly`&&(n.setDirection?n.setDirection(`inactive`):n.direction=`inactive`):e.offerToReceiveVideo===!0&&!n&&this.addTransceiver(`video`,{direction:`recvonly`})}return t.apply(this,arguments)}}function Wy(e){typeof e!=`object`||e.AudioContext||(e.AudioContext=e.webkitAudioContext)}var Gy=Object.freeze({__proto__:null,shimAudioContext:Wy,shimCallbacksAPI:Ry,shimConstraints:By,shimCreateOfferLegacy:Uy,shimGetUserMedia:zy,shimLocalStreamsAPI:Iy,shimRTCIceServerUrls:Vy,shimRemoteStreamsAPI:Ly,shimTrackEventTransceiver:Hy}),Ky={exports:{}},qy;function Jy(){return qy?Ky.exports:(qy=1,(function(e){let t={};t.generateIdentifier=function(){return Math.random().toString(36).substring(2,12)},t.localCName=t.generateIdentifier(),t.splitLines=function(e){return e.trim().split(`
|
|
27
27
|
`).map(e=>e.trim())},t.splitSections=function(e){return e.split(`
|
|
28
28
|
m=`).map((e,t)=>(t>0?`m=`+e:e).trim()+`\r
|
|
@@ -327,18 +327,168 @@ class ScribeAudioProcessor extends AudioWorkletProcessor {
|
|
|
327
327
|
|
|
328
328
|
registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
|
|
329
329
|
|
|
330
|
-
`),nD,rD;(function(e){e.PCM_8000=`pcm_8000`,e.PCM_16000=`pcm_16000`,e.PCM_22050=`pcm_22050`,e.PCM_24000=`pcm_24000`,e.PCM_44100=`pcm_44100`,e.PCM_48000=`pcm_48000`,e.ULAW_8000=`ulaw_8000`})(nD||={}),function(e){e.MANUAL=`manual`,e.VAD=`vad`}(rD||={});var iD=class e{static getWebSocketUri(t=e.DEFAULT_BASE_URI){return`${t}/v1/speech-to-text/realtime`}static buildWebSocketUri(t){let n=e.getWebSocketUri(t.baseUri),r=new URLSearchParams;if(r.append(`model_id`,t.modelId),r.append(`token`,t.token),t.commitStrategy!==void 0&&r.append(`commit_strategy`,t.commitStrategy),t.audioFormat!==void 0&&r.append(`audio_format`,t.audioFormat),t.vadSilenceThresholdSecs!==void 0){if(t.vadSilenceThresholdSecs<=.3||t.vadSilenceThresholdSecs>3)throw Error(`vadSilenceThresholdSecs must be between 0.3 and 3.0`);r.append(`vad_silence_threshold_secs`,t.vadSilenceThresholdSecs.toString())}if(t.vadThreshold!==void 0){if(t.vadThreshold<.1||t.vadThreshold>.9)throw Error(`vadThreshold must be between 0.1 and 0.9`);r.append(`vad_threshold`,t.vadThreshold.toString())}if(t.minSpeechDurationMs!==void 0){if(t.minSpeechDurationMs<=50||t.minSpeechDurationMs>2e3)throw Error(`minSpeechDurationMs must be between 50 and 2000`);r.append(`min_speech_duration_ms`,t.minSpeechDurationMs.toString())}if(t.minSilenceDurationMs!==void 0){if(t.minSilenceDurationMs<=50||t.minSilenceDurationMs>2e3)throw Error(`minSilenceDurationMs must be between 50 and 2000`);r.append(`min_silence_duration_ms`,t.minSilenceDurationMs.toString())}t.languageCode!==void 0&&r.append(`language_code`,t.languageCode),t.includeTimestamps!==void 0&&r.append(`include_timestamps`,t.includeTimestamps?`true`:`false`);let i=r.toString();return i?`${n}?${i}`:n}static connect(t){if(!t.modelId)throw Error(`modelId is required`);let n=new eD(`microphone`in t&&t.microphone?16e3:t.sampleRate),r=e.buildWebSocketUri(t),i=new WebSocket(r);return`microphone`in t&&t.microphone&&i.addEventListener(`open`,()=>{e.streamFromMicrophone(t,n)}),n.setWebSocket(i),n}static async streamFromMicrophone(e,t){try{var n,r,i;let a=await navigator.mediaDevices.getUserMedia({audio:{deviceId:e.microphone?.deviceId,echoCancellation:(n=e.microphone?.echoCancellation)==null||n,noiseSuppression:(r=e.microphone?.noiseSuppression)==null||r,autoGainControl:(i=e.microphone?.autoGainControl)==null||i,channelCount:e.microphone?.channelCount??1,sampleRate:{ideal:16e3}}}),o=new AudioContext({sampleRate:16e3});await tD(o.audioWorklet);let s=o.createMediaStreamSource(a),c=new AudioWorkletNode(o,`scribeAudioProcessor`);c.port.onmessage=e=>{let{audioData:n}=e.data,r=new Uint8Array(n),i=``;for(let e=0;e<r.length;e++)i+=String.fromCharCode(r[e]);let a=btoa(i);t.send({audioBase64:a})},s.connect(c),o.state===`suspended`&&await o.resume(),t._audioCleanup=()=>{a.getTracks().forEach(e=>{e.stop()}),s.disconnect(),c.disconnect(),o.close()}}catch(e){throw console.error(`Failed to start microphone streaming:`,e),e}}};iD.DEFAULT_BASE_URI=`wss://api.elevenlabs.io`;var aD=class extends AE{static startSession(e){return e.textOnly?qE.startSession(e):QE.startSession(e)}},oD=80;function sD(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=oD,i=r+(window.innerHeight-r)/2,a=window.pageYOffset+n-i;window.scrollTo({top:Math.max(0,a),behavior:`smooth`})})}function cD(e){if(!e||e.hasAttribute(`data-fe-highlighted`))return;lD(),e.classList?.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`),sD(e);let t=e.style.cssText;e.setAttribute(`data-fe-highlighted`,`true`),e.setAttribute(`data-fe-orig-style`,t),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 lD(){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 uD=({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`})]}),dD=({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`})]}),fD=({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`})]}),pD=()=>(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`})]}),mD=()=>(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`})}),hD=({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`})]}),gD=({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`})]}),_D=({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`})]}),vD=({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})]}),yD=({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`})]}),bD=()=>(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`})}),xD=({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`})]}),SD=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),CD=(e=``)=>String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),wD=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),TD=/^https?:\/\//i;function ED(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!wD.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;TD.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);ED(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function DD(e){let t=document.createElement(`div`);return t.innerHTML=e,ED(t),t.innerHTML}function OD(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 kD=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return OD(DD(t));let n=t.replace(/\r\n/g,`
|
|
330
|
+
`),nD,rD;(function(e){e.PCM_8000=`pcm_8000`,e.PCM_16000=`pcm_16000`,e.PCM_22050=`pcm_22050`,e.PCM_24000=`pcm_24000`,e.PCM_44100=`pcm_44100`,e.PCM_48000=`pcm_48000`,e.ULAW_8000=`ulaw_8000`})(nD||={}),function(e){e.MANUAL=`manual`,e.VAD=`vad`}(rD||={});var iD=class e{static getWebSocketUri(t=e.DEFAULT_BASE_URI){return`${t}/v1/speech-to-text/realtime`}static buildWebSocketUri(t){let n=e.getWebSocketUri(t.baseUri),r=new URLSearchParams;if(r.append(`model_id`,t.modelId),r.append(`token`,t.token),t.commitStrategy!==void 0&&r.append(`commit_strategy`,t.commitStrategy),t.audioFormat!==void 0&&r.append(`audio_format`,t.audioFormat),t.vadSilenceThresholdSecs!==void 0){if(t.vadSilenceThresholdSecs<=.3||t.vadSilenceThresholdSecs>3)throw Error(`vadSilenceThresholdSecs must be between 0.3 and 3.0`);r.append(`vad_silence_threshold_secs`,t.vadSilenceThresholdSecs.toString())}if(t.vadThreshold!==void 0){if(t.vadThreshold<.1||t.vadThreshold>.9)throw Error(`vadThreshold must be between 0.1 and 0.9`);r.append(`vad_threshold`,t.vadThreshold.toString())}if(t.minSpeechDurationMs!==void 0){if(t.minSpeechDurationMs<=50||t.minSpeechDurationMs>2e3)throw Error(`minSpeechDurationMs must be between 50 and 2000`);r.append(`min_speech_duration_ms`,t.minSpeechDurationMs.toString())}if(t.minSilenceDurationMs!==void 0){if(t.minSilenceDurationMs<=50||t.minSilenceDurationMs>2e3)throw Error(`minSilenceDurationMs must be between 50 and 2000`);r.append(`min_silence_duration_ms`,t.minSilenceDurationMs.toString())}t.languageCode!==void 0&&r.append(`language_code`,t.languageCode),t.includeTimestamps!==void 0&&r.append(`include_timestamps`,t.includeTimestamps?`true`:`false`);let i=r.toString();return i?`${n}?${i}`:n}static connect(t){if(!t.modelId)throw Error(`modelId is required`);let n=new eD(`microphone`in t&&t.microphone?16e3:t.sampleRate),r=e.buildWebSocketUri(t),i=new WebSocket(r);return`microphone`in t&&t.microphone&&i.addEventListener(`open`,()=>{e.streamFromMicrophone(t,n)}),n.setWebSocket(i),n}static async streamFromMicrophone(e,t){try{var n,r,i;let a=await navigator.mediaDevices.getUserMedia({audio:{deviceId:e.microphone?.deviceId,echoCancellation:(n=e.microphone?.echoCancellation)==null||n,noiseSuppression:(r=e.microphone?.noiseSuppression)==null||r,autoGainControl:(i=e.microphone?.autoGainControl)==null||i,channelCount:e.microphone?.channelCount??1,sampleRate:{ideal:16e3}}}),o=new AudioContext({sampleRate:16e3});await tD(o.audioWorklet);let s=o.createMediaStreamSource(a),c=new AudioWorkletNode(o,`scribeAudioProcessor`);c.port.onmessage=e=>{let{audioData:n}=e.data,r=new Uint8Array(n),i=``;for(let e=0;e<r.length;e++)i+=String.fromCharCode(r[e]);let a=btoa(i);t.send({audioBase64:a})},s.connect(c),o.state===`suspended`&&await o.resume(),t._audioCleanup=()=>{a.getTracks().forEach(e=>{e.stop()}),s.disconnect(),c.disconnect(),o.close()}}catch(e){throw console.error(`Failed to start microphone streaming:`,e),e}}};iD.DEFAULT_BASE_URI=`wss://api.elevenlabs.io`;var aD=class extends AE{static startSession(e){return e.textOnly?qE.startSession(e):QE.startSession(e)}},oD=80;function sD(e){requestAnimationFrame(()=>{let t=e.getBoundingClientRect(),n=t.top+t.height/2,r=oD+(window.innerHeight-oD)/2,i=window.pageYOffset+n-r;window.scrollTo({top:Math.max(0,i),behavior:`smooth`})})}function cD(e){e&&(e.hasAttribute(`data-fe-highlighted`)||(lD(),e.classList?.remove(`fe-highlight-section`,`fe-highlight-speaking`,`fe-highlight-exiting`),sD(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 lD(){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`))}function uD(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(`
|
|
331
|
+
`);return i.length>n&&(i=`…(earlier messages omitted)
|
|
332
|
+
`+i.slice(-n)),i}var Q=`fe-vv`;function dD(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
|
|
333
|
+
/* ── Action toast ───────────────────────────────────────────────────────────── */
|
|
334
|
+
#${Q}-toast {
|
|
335
|
+
position: fixed;
|
|
336
|
+
top: 16px;
|
|
337
|
+
left: 50%;
|
|
338
|
+
transform: translateX(-50%) translateY(-160%);
|
|
339
|
+
background: rgba(10, 10, 20, 0.88);
|
|
340
|
+
color: #f1f5f9;
|
|
341
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
342
|
+
font-size: 13px;
|
|
343
|
+
font-weight: 500;
|
|
344
|
+
line-height: 1.4;
|
|
345
|
+
padding: 9px 18px 9px 14px;
|
|
346
|
+
border-radius: 999px;
|
|
347
|
+
z-index: 2147483640;
|
|
348
|
+
pointer-events: none;
|
|
349
|
+
opacity: 0;
|
|
350
|
+
transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
|
|
351
|
+
white-space: nowrap;
|
|
352
|
+
display: flex;
|
|
353
|
+
align-items: center;
|
|
354
|
+
gap: 9px;
|
|
355
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.2);
|
|
356
|
+
backdrop-filter: blur(12px);
|
|
357
|
+
-webkit-backdrop-filter: blur(12px);
|
|
358
|
+
border: 1px solid rgba(255,255,255,0.08);
|
|
359
|
+
max-width: 90vw;
|
|
360
|
+
overflow: hidden;
|
|
361
|
+
text-overflow: ellipsis;
|
|
362
|
+
}
|
|
363
|
+
#${Q}-toast.${Q}-show {
|
|
364
|
+
transform: translateX(-50%) translateY(0);
|
|
365
|
+
opacity: 1;
|
|
366
|
+
}
|
|
367
|
+
#${Q}-toast .${Q}-spin {
|
|
368
|
+
width: 13px;
|
|
369
|
+
height: 13px;
|
|
370
|
+
border: 2px solid rgba(255,255,255,0.25);
|
|
371
|
+
border-top-color: #a78bfa;
|
|
372
|
+
border-radius: 50%;
|
|
373
|
+
animation: ${Q}-spin 0.65s linear infinite;
|
|
374
|
+
flex-shrink: 0;
|
|
375
|
+
}
|
|
376
|
+
#${Q}-toast .${Q}-icon {
|
|
377
|
+
font-size: 14px;
|
|
378
|
+
flex-shrink: 0;
|
|
379
|
+
line-height: 1;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/* ── Navigation progress bar ────────────────────────────────────────────────── */
|
|
383
|
+
#${Q}-bar {
|
|
384
|
+
position: fixed;
|
|
385
|
+
top: 0;
|
|
386
|
+
left: 0;
|
|
387
|
+
width: 0%;
|
|
388
|
+
height: 3px;
|
|
389
|
+
background: linear-gradient(90deg, #7c3aed, #06b6d4, #7c3aed);
|
|
390
|
+
background-size: 200% 100%;
|
|
391
|
+
z-index: 2147483647;
|
|
392
|
+
pointer-events: none;
|
|
393
|
+
opacity: 0;
|
|
394
|
+
transition: width 0.35s ease, opacity 0.25s ease;
|
|
395
|
+
box-shadow: 0 0 12px #7c3aed88;
|
|
396
|
+
animation: ${Q}-bar-shimmer 1.5s linear infinite;
|
|
397
|
+
}
|
|
398
|
+
#${Q}-bar.${Q}-bar-active {
|
|
399
|
+
opacity: 1;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/* ── Field active highlight (about to fill) ─────────────────────────────────── */
|
|
403
|
+
.${Q}-field-active {
|
|
404
|
+
outline: 2.5px solid #7c3aed !important;
|
|
405
|
+
outline-offset: 3px !important;
|
|
406
|
+
box-shadow: 0 0 0 5px rgba(124, 58, 237, 0.14), 0 0 20px rgba(124, 58, 237, 0.28) !important;
|
|
407
|
+
border-radius: 5px !important;
|
|
408
|
+
transition: outline 0.18s ease, box-shadow 0.18s ease !important;
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/* ── Field filled confirmation (green flash) ────────────────────────────────── */
|
|
412
|
+
.${Q}-field-filled {
|
|
413
|
+
outline: 2px solid #10b981 !important;
|
|
414
|
+
outline-offset: 3px !important;
|
|
415
|
+
box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12), 0 0 16px rgba(16, 185, 129, 0.22) !important;
|
|
416
|
+
border-radius: 5px !important;
|
|
417
|
+
animation: ${Q}-fill-flash 0.45s ease forwards !important;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/* ── Ghost cursor ────────────────────────────────────────────────────────────── */
|
|
421
|
+
#${Q}-cursor {
|
|
422
|
+
position: fixed;
|
|
423
|
+
width: 22px;
|
|
424
|
+
height: 22px;
|
|
425
|
+
pointer-events: none;
|
|
426
|
+
z-index: 2147483645;
|
|
427
|
+
opacity: 0;
|
|
428
|
+
transition:
|
|
429
|
+
left 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94),
|
|
430
|
+
top 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94),
|
|
431
|
+
opacity 0.2s ease;
|
|
432
|
+
transform: translate(-4px, -4px);
|
|
433
|
+
}
|
|
434
|
+
#${Q}-cursor.${Q}-cursor-visible {
|
|
435
|
+
opacity: 1;
|
|
436
|
+
}
|
|
437
|
+
#${Q}-cursor.${Q}-cursor-click {
|
|
438
|
+
animation: ${Q}-cursor-click 0.25s ease;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/* ── Click ripple ────────────────────────────────────────────────────────────── */
|
|
442
|
+
.${Q}-ripple {
|
|
443
|
+
position: absolute;
|
|
444
|
+
border-radius: 50%;
|
|
445
|
+
transform: scale(0);
|
|
446
|
+
background: rgba(124, 58, 237, 0.35);
|
|
447
|
+
animation: ${Q}-ripple-anim 0.55s linear forwards;
|
|
448
|
+
pointer-events: none;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
/* ── Keyframes ───────────────────────────────────────────────────────────────── */
|
|
452
|
+
@keyframes ${Q}-spin {
|
|
453
|
+
to { transform: rotate(360deg); }
|
|
454
|
+
}
|
|
455
|
+
@keyframes ${Q}-bar-shimmer {
|
|
456
|
+
0% { background-position: 0% 0%; }
|
|
457
|
+
100% { background-position: 200% 0%; }
|
|
458
|
+
}
|
|
459
|
+
@keyframes ${Q}-fill-flash {
|
|
460
|
+
0% { background-color: rgba(16, 185, 129, 0.10); }
|
|
461
|
+
40% { background-color: rgba(16, 185, 129, 0.22); }
|
|
462
|
+
100% { background-color: transparent; }
|
|
463
|
+
}
|
|
464
|
+
@keyframes ${Q}-ripple-anim {
|
|
465
|
+
to { transform: scale(3.5); opacity: 0; }
|
|
466
|
+
}
|
|
467
|
+
@keyframes ${Q}-cursor-click {
|
|
468
|
+
0% { transform: translate(-4px,-4px) scale(1); }
|
|
469
|
+
50% { transform: translate(-4px,-4px) scale(0.82); }
|
|
470
|
+
100% { transform: translate(-4px,-4px) scale(1); }
|
|
471
|
+
}
|
|
472
|
+
`,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var fD=null,pD=null;function mD(){return(!fD||!fD.isConnected)&&(fD=document.createElement(`div`),fD.id=`${Q}-toast`,document.body.appendChild(fD)),fD}function hD(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;dD(),pD&&=(clearTimeout(pD),null);let i=mD();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&&(pD=setTimeout(()=>gD(),r))}function gD(e=0){fD&&(e>0?pD=setTimeout(()=>{fD&&fD.classList.remove(`${Q}-show`)},e):fD&&fD.classList.remove(`${Q}-show`))}var _D=null,vD=[];function yD(){return(!_D||!_D.isConnected)&&(_D=document.createElement(`div`),_D.id=`${Q}-bar`,document.body.appendChild(_D)),_D}function bD(){if(typeof document>`u`)return;dD(),vD.forEach(clearTimeout),vD=[];let e=yD();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;vD.push(setTimeout(()=>{_D&&(_D.style.transition=a,_D.style.width=`${i}%`)},t)),n+=800}}function xD(){_D&&(vD.forEach(clearTimeout),vD=[],_D.style.transition=`width 0.2s ease`,_D.style.width=`100%`,vD.push(setTimeout(()=>{_D&&(_D.style.transition=`opacity 0.35s ease`,_D.style.opacity=`0`,vD.push(setTimeout(()=>{_D&&(_D.style.width=`0%`,_D.classList.remove(`${Q}-bar-active`))},380)))},220)))}function SD(){typeof document>`u`||document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach(e=>e.classList.remove(`${Q}-field-active`,`${Q}-field-filled`))}function CD(e){!e||typeof document>`u`||(dD(),SD(),e.classList.add(`${Q}-field-active`))}function wD(e){e&&(e.classList.remove(`${Q}-field-active`),e.classList.add(`${Q}-field-filled`),setTimeout(()=>{e.isConnected&&e.classList.remove(`${Q}-field-filled`)},1400))}var TD=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
|
|
473
|
+
<filter id="${Q}-csh">
|
|
474
|
+
<feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
|
|
475
|
+
</filter>
|
|
476
|
+
<path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
|
|
477
|
+
fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
|
|
478
|
+
filter="url(#${Q}-csh)"/>
|
|
479
|
+
</svg>`,ED=null,DD=!1;function OD(){return(!ED||!ED.isConnected)&&(ED=document.createElement(`div`),ED.id=`${Q}-cursor`,ED.innerHTML=TD,document.body.appendChild(ED),DD=!1),ED}async function kD(e){if(typeof document>`u`||!e)return;dD();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=OD();DD||=(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 ND(360)}function AD(e=!1){ED&&(e?(ED.classList.remove(`${Q}-cursor-visible`),DD=!1):(ED.classList.remove(`${Q}-cursor-visible`),setTimeout(()=>{DD=!1},250)))}async function jD(e){ED&&(ED.classList.add(`${Q}-cursor-click`),await ND(280),ED.classList.remove(`${Q}-cursor-click`))}function MD(e){if(!e||typeof document>`u`)return;dD();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 ND(e){return new Promise(t=>setTimeout(t,e))}function $(...e){On()&&console.log(`[FlowEngage:voice-tools]`,...e)}function PD(e){return new Promise(t=>setTimeout(t,e))}var FD=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`;function ID(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(FD)}catch{return!1}}function LD(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function RD(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(!ID(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function zD(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function BD(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 zD(r.join(` `))}if(e.labels&&e.labels.length)return zD(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return zD(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return zD(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return zD(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=zD(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 zD(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return zD(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?zD(o):null}function VD(){let e=[];return RD(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(ID(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=LD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function HD(){return VD().map((e,t)=>({formIndex:0,fieldIndex:t,tag:e.tagName,type:e.type||`text`,name:e.name||null,id:e.id||null,label:BD(e),placeholder:e.placeholder||null}))}function UD(){let e=[];return RD(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(ID(e)||e.disabled)return!1;try{let t=LD(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 WD(e){return String(e||``).toLowerCase().replace(/\u00a0/g,` `).replace(/\*/g,``).replace(/\s+/g,` `).trim()}function GD(e){let t=WD(e);return t=t.replace(/\s+field\s*$/i,``).trim(),t}function KD(e,t){let n=GD(t);if(!n)return 0;let r=(e.name||``).toLowerCase(),i=(e.id||``).toLowerCase();if(r===`url`&&/url|website|domain|site|audit/.test(n)||(i===`url-input`||i.endsWith(`-url-input`))&&/url|website|domain|site|audit/.test(n))return 100;let a=[e.name,e.id,e.placeholder,BD(e),e.getAttribute(`aria-label`),e.getAttribute(`title`),e.getAttribute(`data-testid`),e.getAttribute(`autocomplete`)].filter(Boolean).map(e=>WD(e)),o=0;for(let e of a){if(!e)continue;if(e.includes(n)||n.includes(e)){o=Math.max(o,100);continue}let t=n.split(/\s+/).filter(e=>e.length>1);if(!t.length)continue;let r=0;for(let n of t)e.includes(n)&&(r+=1);o=Math.max(o,r/t.length*88)}return o}var qD=28;function JD(e,t){let n=null,r=0;for(let i of e){let e=KD(i,t);e>r&&(r=e,n=i)}return!n||r<qD?null:n}function YD(e,t,n){let r=String(t||``).toLowerCase().trim(),i=String(n||``).trim();if(!(/^https?:\/\//i.test(i)||/\.\w{2,}(\/|\s|$)/.test(i)||r.includes(`url`)||r.includes(`website`)||r.includes(`domain`)||r.includes(`site`)))return null;let a=null,o=0;for(let t of e){if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`)continue;let e=(t.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`checkbox`,`radio`].includes(e))continue;let n=0;(e===`url`||e===`text`||e===`search`)&&(n+=45);let r=[t.name,t.id,t.placeholder,BD(t),t.getAttribute(`aria-label`),t.getAttribute(`autocomplete`)].filter(Boolean).join(` `).toLowerCase();/(website|url|domain|site\s*url)/.test(r)&&(n+=55),n>o&&(o=n,a=t)}return!a||o<42?null:a}function XD(e){let t=String(e??``).trim();return t?/^https?:\/\//i.test(t)?!0:/\.\w{2,}(\/|\s|$)/.test(t):!1}function ZD(e){let t=String(e??``).toLowerCase().trim();return t?!!(t===`url`||t===`website`||t===`website url`||t===`website_url`||t===`enter website url`||t.includes(`website`)||t.includes(`domain`)||/(enter\s+website|site\s*url|page\s*url)/.test(t)):!1}function QD(e){if(!e||e.tagName!==`INPUT`&&e.tagName!==`TEXTAREA`)return!1;let t=(e.type||``).toLowerCase();return![`hidden`,`submit`,`button`,`checkbox`,`radio`,`file`].includes(t)}function $D(e){if(!QD(e))return!1;let t=(e.name||``).toLowerCase(),n=(e.id||``).toLowerCase(),r=[e.name,e.id,e.placeholder,BD(e),e.getAttribute(`aria-label`)].filter(Boolean).join(` `).toLowerCase();return t===`url`||n===`url-input`||n.endsWith(`-url-input`)||/(website\s*url|enter\s+website|site\s*url)/.test(r)||/(website|domain)/.test(r)&&/(url|site)/.test(r)}function eO(e,t,n){let r=String(t??``),i=String(n??``),a=rO(e,r)||JD(e,r)||YD(e,r,i);if(!a)return[];let o=new Set([a]);if(XD(i)&&ZD(r))for(let t of e)t!==a&&$D(t)&&o.add(t);let s=Array.from(o);return s.sort((e,t)=>{if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}),s}function tO(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 nO(e){if(!e||typeof e!=`string`)return null;let t=null;return RD(n=>{try{let r=n.getElementById(e);r&&!ID(r)&&r.matches?.(`input, select, textarea`)&&(t=r)}catch{}}),t}function rO(e,t){let n=String(t??``).trim();if(!n)return null;let r=n.match(/^name:\s*([\w.-]+)$/i);if(r){let t=r[1];for(let n of e)if(n.name===t)return n}let i=n.match(/^id:\s*([\w.-]+)$/i);if(i){let e=nO(i[1]);if(e)return e}let a=n.startsWith(`#`)?n.slice(1):n;if(/^[\w-]+$/.test(a)){let e=nO(a);if(e)return e}let o=n.toLowerCase().replace(/\s+/g,` `);if(o===`url`||o===`website`||o===`website url`||o===`website_url`||o===`enter website url`)for(let t of e){let e=(t.name||``).toLowerCase(),n=(t.id||``).toLowerCase();if(e===`url`||n===`url-input`||n.endsWith(`-url-input`))return t}return null}function iO(e,t){let n=String(t||``).toLowerCase().trim();if(!n)return 0;let r=[e.textContent,e.value,e.getAttribute(`aria-label`),e.getAttribute(`title`)].filter(Boolean).join(` `).toLowerCase().replace(/\s+/g,` `);if(r.includes(n))return 100;let i=n.split(/\s+/).filter(e=>e.length>1);if(!i.length)return 0;let a=0;for(let e of i)r.includes(e)&&(a+=1);return a/i.length*92}function aO(e,t){let n=[];RD(e=>{n.push(...Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(ID(e)||e.disabled)return!1;try{let t=LD(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))});let r=0,i=n.map(t=>({el:t,s:iO(t,e)}));for(let{s:e}of i)e>r&&(r=e);if(r<36)return null;let a=i.filter(({s:e})=>e===r).map(({el:e})=>e);if(a.length===1)return a[0];let o=Array.isArray(t)?t.filter(e=>e&&e.isConnected):[];if(o.length){let e=a[0],t=1/0;for(let n of a)for(let r of o){let i=tO(n,r);i<t&&(t=i,e=n)}return e}return a[0]}function oO(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 sO(e){let t=oO(e);if(Array.isArray(t)&&t.length>0){let e=t[0];if(e?.field_key!=null||e?.fieldKey!=null)return t.map(e=>({field_key:e.field_key??e.fieldKey,value:e.value}))}if(!t||typeof t!=`object`)return[];let n=t.fields??t.Fields??t.field_list??t.fieldList??t.data?.fields;if(typeof n==`string`)try{n=JSON.parse(n)}catch{n=null}n&&!Array.isArray(n)&&typeof n==`object`&&(n=Object.values(n)),(!n||n.length===0)&&(t.field_key!=null||t.fieldKey!=null)&&t.value!=null&&(n=[{field_key:t.field_key??t.fieldKey,value:t.value}]);let r=t.website_url??t.websiteUrl??t.url??t.website??t.domain??t.site_url??t.siteUrl;return(!n||n.length===0)&&r!=null&&String(r).trim()&&(n=[{field_key:t.field_key??t.fieldKey??`url`,value:String(r).trim()}]),Array.isArray(n)?n.map(e=>({field_key:e?.field_key??e?.fieldKey,value:e?.value??e?.Value})):[]}function cO(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t||/\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t))return[];let n=t.match(/https?:\/\/[^\s<>"']+/i);if(n)return[{field_key:`url`,value:n[0].replace(/[.,;:)]+$/,``)}];let r=t.match(/\b(?:[\w-]+\.)+[a-z]{2,}\b/i);if(r){let e=r[0].replace(/[.,;:)]+$/,``);return/^https?:/i.test(e)||(e=`https://${e}`),[{field_key:`url`,value:e}]}return[]}function lO(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t)return[];let n=[],r=new Set,i=/\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\b/i,a=(e,t)=>{let i=String(t??``).trim().replace(/^["']|["']$/g,``);if(!i||i.length>800)return;let a=`${e}\0${i}`;r.has(a)||(r.add(a),n.push({field_key:e,value:i}))},o=t.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);if(o)return a(`Email Address`,o[1]),n;let s=t.match(/\b(?:please\s+)?(?:enter|type|put)\s+(.+?)\s+in(?:to)?\s+(?:the\s+)?(?:full\s*name|full\s*name\s*field|name\s*field)\b/i);if(s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name,?\s*(?:please\s+)?(?:enter|type|put)\s+(.+?)(?:\.|$|!|\?)/i),s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name\s*(?:is|:|please\s+enter|-)\s*(.+?)(?:\.|$|(?=\s+(?:and|my\s+email|email|message))\b)/i),s&&a(`Full Name`,s[1]),s=t.match(/\b(.+?)\s+for\s+(?:the\s+)?full\s*name\b/i),s){let e=s[1].trim();e.length>1&&e.length<120&&!/@/.test(e)&&a(`Full Name`,e)}if(s=t.match(/\b(?:email|e-mail)(?:\s*address)?\s*(?:is|:|please\s+use|enter|-)\s*([^\s@]+@[^\s@]+\.[^\s,]+)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:enter|type|put)\s+([^\s@]+@[^\s@]+\.[^\s,]+)\s+in(?:to)?\s+(?:the\s+)?(?:email|e-mail)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:message|comment)\s*(?:is|:|please\s+enter|-)\s*(.+)$/is),s){let e=s[1].trim();e.length>0&&a(`Message`,e)}if(!n.some(e=>/email/i.test(String(e.field_key)))){let e=t.match(i);if(e){let r=t.replace(e[0],``).trim().replace(/^(please|it's|it is|use|is|my email is|e-?mail is)\s*/i,``).replace(/[.,;:!?]+$/,``).trim();if(t.length<=96&&r.length<=36)return a(`Email Address`,e[1]),n}}if(n.length===0){let e=t.split(/\s+/).filter(Boolean).length,n=/[.!?]/.test(t)||e>=6||t.length>=24&&e>=5||t.length>=42,r=/^[A-Z][a-z]+\s+[A-Z][a-z]+$/.test(t.trim());n&&t.length>=16&&!i.test(t)&&!r&&a(`Message`,t)}return n}function uO(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 dO(e){if(!e||typeof e!=`object`)return null;let t=e.query??e.q??e.search??e.text??e.keywords;return t==null?null:String(t).trim()||null}function fO(e,t,n){if(!n?.skipScroll)try{e.scrollIntoView({block:`center`,inline:`nearest`})}catch{try{e.scrollIntoView(!0)}catch{}}try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{}}let r=e.tagName,i=(e.type||``).toLowerCase();if(r===`SELECT`)return e.value=String(t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;if(i===`checkbox`||i===`radio`)return e.checked=[`1`,`true`,`yes`,`on`].includes(String(t).toLowerCase().trim()),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;let a=String(t);if(r===`INPUT`||r===`TEXTAREA`){let t=e.ownerDocument?.defaultView||window,n=r===`TEXTAREA`?t.HTMLTextAreaElement.prototype:t.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,`value`);i?.set?i.set.call(e,a):e.value=a}else e.value=a;let o={bubbles:!0,cancelable:!0,composed:!0};try{e.dispatchEvent(new InputEvent(`input`,{...o,inputType:`insertText`,data:a}))}catch{e.dispatchEvent(new Event(`input`,o))}e.dispatchEvent(new Event(`change`,o));try{queueMicrotask(()=>{try{e.dispatchEvent(new Event(`input`,o)),e.dispatchEvent(new Event(`change`,o))}catch{}})}catch{}return!0}function pO(){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 mO(){let e=document.querySelector(`main, [role='main'], article`)||document.body;return Array.from(e.querySelectorAll(`h1, h2, h3, h4`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200).slice(0,12)}function hO(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={flowengage_navigate:async n=>{$(`flowengage_navigate ▶ raw parameters:`,n);let i=oO(n),a=uO(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($(`flowengage_navigate · 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 $(`flowengage_navigate ✖`,e),e}if(typeof window<`u`)try{let e=new URL(a,window.location.href);e.origin!==window.location.origin&&/^https?:$/i.test(e.protocol)&&(a=e.pathname+e.search+e.hash,$(`flowengage_navigate · normalized cross-origin URL to path:`,a))}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 $(`flowengage_navigate ✖ 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{}if(!await lr(a,{siteId:t,apiBaseUrl:e.apiBaseUrl})){let e=`Page "${a}" could not be verified. Call flowengage_search with keywords from the topic to find the correct URL, then navigate to the URL from the search results.`;return $(`flowengage_navigate ✖ blocked`,e),e}try{hD(`Navigating to ${a}...`,{spinner:!0}),bD(),resetQueue(),lD();try{let e=r?r():``;if(e&&t){let n=uD([{sender:`user`,message:e}]);n&&xe(t,n)}}catch{}Te();let e=a;try{e=new URL(a,typeof window<`u`?window.location.href:``).href}catch{}t&&typeof window<`u`&&Me(t,window.location.href,e),fr(e),$(`flowengage_navigate → real navigation`,a);let n=typeof window<`u`&&!!(window.next?.router||window.__NEXT_ROUTER__||window.__remixRouter||window.__staticRouterHydrationData||window.___gatsby||window.___navigate||window.__VUE_ROUTER__||window.__NUXT__||window.$nuxt||window.ng?.getComponent||typeof document<`u`&&document.querySelector(`[ng-version]`)||window.__sveltekit_data||typeof document<`u`&&document.querySelector(`[data-sveltekit-hydrate]`));if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),n&&In(3e3),hr(a,{voiceActive:!0}).catch(()=>{}),n)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`;$(`flowengage_navigate → SPA nav complete. target:`,e,`actual:`,n);let s=[],c=Date.now()+2e3;for(;Date.now()<c&&(await new Promise(e=>setTimeout(e,250)),s=mO(),!(s.length>=3)););$(`flowengage_navigate → page headings collected:`,s);let l=s.length?s.join(` | `):`none`;return i?(pr(),`OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${l}. Use ONLY these exact heading strings for flowengage_highlight. Do NOT say "I have navigated you" or "I've taken you to" — start immediately with highlights and content about THIS page.`):(pr(),`OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${l}. Use ONLY these exact heading strings for flowengage_highlight. Describe THIS page only — do not mention the page you tried to navigate to.`)}catch{}return`OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, immediately introduce the new page and continue guiding the visitor — do not wait for the user to speak first.`}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`flowengage_navigate ✖`,t),hD(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{xD(),gD(900)}},flowengage_highlight:t=>{$(`flowengage_highlight ▶ (queued)`,t);let n=oO(t),r=n?.section_id||n?.sectionId,i=n?.section_text||n?.sectionText;pO();let a=ir(r||null,i||null);if(!a){$(`flowengage_highlight ✖ no element for:`,i||r);let e=mO(),t=e.length?`Page headings: ${e.join(` | `)}. Use one of these exact strings for section_text.`:`No headings found — skip highlight and continue.`;return`HIGHLIGHT_NOT_FOUND: "${i||r}" on the current page. ${t}`}return typeof e.onHighlightQueued==`function`?(e.onHighlightQueued({sectionId:r||null,sectionText:i||null}),$(`flowengage_highlight ✓ queued:`,i||r)):(cD(a),$(`flowengage_highlight ✓ applied (no scheduler):`,i||r)),`OK_HIGHLIGHT: "${i||r}". Continue immediately to the next section — do NOT pause between sections.`},flowengage_read_content:async e=>{$(`flowengage_read_content ▶`,e);let t=oO(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=ir(null,n);if(!t)return`Could not find section "${n}" on the page.`;let r=[t.textContent.trim()],i=t.nextElementSibling;for(;i&&!/^H[1-3]$/i.test(i.tagName);){let e=i.textContent.trim();e&&r.push(e),i=i.nextElementSibling}e=r.join(`
|
|
480
|
+
`)}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`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`flowengage_read_content ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`flowengage_read_content ✖`,e.message),`Could not read page content: ${e.message}`}},flowengage_search:async e=>{$(`flowengage_search ▶`,e);let r=dO(oO(e));if($(`flowengage_search · query:`,r,`siteId:`,t,`apiBase:`,n||`(empty)`),!r)return $(`flowengage_search ✖ missing query`),`Missing query parameter.`;if(!t)return $(`flowengage_search ✖ no siteId`),`Site is not configured for search.`;if(!n)return $(`flowengage_search ✖ no api base`),`API base URL is missing; cannot search.`;hD(`Searching${r?` for "${r}"`:``}…`,{spinner:!0});try{let e=`${n}/api/site-tools/search`;$(`flowengage_search → 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($(`flowengage_search · HTTP`,i.status,`success:`,a.success),!a.success){let e=a.error||`Search failed.`;return $(`flowengage_search ✖`,e),e}let o=a.results||[];return $(`flowengage_search ✓`,`${o.length} result(s)`,o.slice(0,3).map(e=>e?.url||e)),JSON.stringify(o)}catch(e){let t=`Search error: ${e.message||`network`}`;return $(`flowengage_search ✖`,t),t}finally{gD(600)}},flowengage_page_content:async e=>{$(`flowengage_page_content ▶`,e);let r=oO(e),i=r?.url||r?.page_url||``;if($(`flowengage_page_content · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`flowengage_page_content ✖ missing url`),`Missing url parameter.`;if(!t)return $(`flowengage_page_content ✖ no siteId`),`Site is not configured.`;if(!n)return $(`flowengage_page_content ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`flowengage_page_content → 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($(`flowengage_page_content · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`flowengage_page_content ✖`,e),`${e} FALLBACK REQUIRED: This page is not in the search index. Call flowengage_read_content (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 $(`flowengage_page_content ✓`,`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 $(`flowengage_page_content ✖`,t),t}},flowengage_end_session:async()=>($(`flowengage_end_session ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),flowengage_get_current_page:async()=>{if($(`flowengage_get_current_page ▶`),typeof window>`u`)return`Cannot determine current page (no browser context).`;let e=window.location.href,t=window.location.pathname,n=document.title||``,r=mO(),i=r.length?r.join(` | `):`none`;return $(`flowengage_get_current_page ✓`,{url:e,path:t,title:n}),$(`flowengage_get_current_page → page headings collected:`,r),`CURRENT_PAGE. URL: ${e} | Path: ${t} | Title: ${n} | Section headings: ${i}. Use ONLY these exact heading strings for flowengage_highlight — never invent or abbreviate section names.`},flowengage_list_forms:async()=>{let e=HD(),t=UD();return $(`flowengage_list_forms ✓`,`${e.length} field(s)`,`${t.length} button(s)`),JSON.stringify({fields:e,buttons:t,hint:`field_key: placeholder/label, name (e.g. url), id (e.g. url-input). If the page has two URL boxes, flowengage_fill_form sets all matching URL inputs. flowengage_click_button picks the Conduct Audit nearest the filled field when labels duplicate.`})},flowengage_fill_form:async e=>{try{$(`flowengage_fill_form ▶ raw:`,e),SD();let t=sO(e);if(!t.length&&r){let e=r(),n=cO(e);n.length?$(`flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):`,n):(n=lO(e),n.length&&$(`flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):`,n)),n.length&&(t=n)}if($(`flowengage_fill_form · normalized fields:`,t),!t.length)return`No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { "fields": [ { "field_key": "<label or placeholder from list>", "value": "<user value>" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.`;let n=[];for(let e of t){let t=e?.field_key,r=e?.value;if(t==null||r==null)continue;hD(`Filling ${String(t)}...`,{spinner:!0});let a=VD(),o=eO(a,String(t),r);if(o.length){for(let[e,t]of o.entries())CD(t),await kD(t),fO(t,r,{skipScroll:e>0}),wD(t),await PD(120);i=o,n.push(String(t));continue}let s=rO(a,String(t));s||=JD(a,String(t)),s||=YD(a,String(t),r),s&&(CD(s),await kD(s),fO(s,r),wD(s),await PD(120),i=[s],n.push(String(t)))}if(!n.length)return $(`flowengage_fill_form ✖ no matches`),`Could not match any fields. Call flowengage_list_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.`;let a=`OK_FILLED: ${n.join(`, `)}`;return $(`flowengage_fill_form ✓`,a),hD(`Form filled`,{spinner:!1,icon:`✅`,duration:1100}),a}catch(e){let t=`flowengage_fill_form error: ${e?.message||String(e)}`;return $(`flowengage_fill_form ✖`,t),hD(`Failed to fill form`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{AD(),SD(),gD(700)}},flowengage_click_button:async e=>{let t=oO(e),n=(t.button_text??t.buttonText??t.text??``).trim();if($(`flowengage_click_button ▶`,n),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let r=aO(n,i);if(!r)return $(`flowengage_click_button ✖ no match`),`Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;try{hD(`Clicking ${n}...`,{spinner:!0});try{r.scrollIntoView({block:`center`,inline:`nearest`})}catch{r.scrollIntoView(!0)}await kD(r),r.focus?.(),await jD(r),MD(r),r.click();let e=(r.textContent||r.value||r.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`flowengage_click_button ✓`,t),hD(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`flowengage_click_button ✖`,t),hD(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{AD(),gD(700)}}};return{...a,highlightOnPage:a.flowengage_highlight,searchSiteContent:a.flowengage_search,getPageContent:a.flowengage_page_content,endVoiceSession:a.flowengage_end_session,listPageForms:a.flowengage_list_forms,fillFormFields:a.flowengage_fill_form,clickPageButton:a.flowengage_click_button}}var gO=375,_O=500,vO=900,yO=new Set(`the.and.for.are.but.not.you.all.any.can.its.was.that.this.with.have.from.they.will.been.our.page.here.also.into.more.about.just.now.let.take.tell.show.your.each.very.what.how.when.where.which.who`.split(`.`));function bO(e){return e.toLowerCase().replace(/[^a-z0-9\s%]/g,` `).split(/\s+/).filter(e=>e.length>2&&!yO.has(e))}function xO(e){return e.toLowerCase().replace(/[^a-z0-9\s%]/g,` `).split(/\s+/).filter(Boolean)}function SO(e,t){return e===t?!0:e.length>4&&t.length>4?e.startsWith(t.slice(0,5))||t.startsWith(e.slice(0,5)):!1}function CO(e,t){let n=bO(e);if(!n.length)return null;let r=null;for(let e of n){let n=t.findIndex(t=>SO(t,e));n>=0&&(r===null||n<r)&&(r=n)}return r}function wO(e,t){if(!e.length||!t.trim())return[];let n=xO(t),r=n.length,i=Math.max(1,Math.floor(r/e.length)),a=e.map((e,t)=>{let r=CO(e.sectionText||e.sectionId||``,n)??t*i;return{...e,offset:r}});a.sort((e,t)=>e.offset-t.offset);let o=[],s=-1/0;for(let e of a){let t=Math.max(_O,e.offset*gO);t<s+vO&&(t=s+vO),s=t;let n=setTimeout(()=>{pO();let t=ir(e.sectionId||null,e.sectionText||null);t&&cD(t)},t);o.push(n)}return o}function TO(e){for(let t of e)clearTimeout(t)}var EO=({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`})]}),DO=({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`})]}),OO=({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`})]}),kO=()=>(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`})]}),AO=()=>(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`})}),jO=({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`})]}),MO=({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`})]}),NO=({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`})]}),PO=({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})]}),FO=({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`})]}),IO=()=>(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`})}),LO=({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`})]}),RO=(e=``)=>String(e).replace(/<[^>]+>/g,``).replace(/\s+/g,` `).trim(),zO=(e=``)=>String(e).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`),BO=new Set([`p`,`br`,`ul`,`ol`,`li`,`strong`,`em`,`b`,`i`,`a`]),VO=/^https?:\/\//i;function HO(e){let t=Array.from(e.childNodes);for(let n of t)if(n.nodeType===Node.ELEMENT_NODE){let t=n.tagName.toLowerCase();if(!BO.has(t)){e.replaceChild(document.createTextNode(n.textContent),n);continue}let r={};if(t===`a`){let e=n.getAttribute(`href`)||``;VO.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);HO(n)}else n.nodeType!==Node.TEXT_NODE&&e.removeChild(n)}function UO(e){let t=document.createElement(`div`);return t.innerHTML=e,HO(t),t.innerHTML}function WO(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 GO=(e=``)=>{let t=String(e||``).trim();if(!t)return``;if(/<(p|br|ul|ol|li|strong|em|a)\b/i.test(t))return WO(UO(t));let n=t.replace(/\r\n/g,`
|
|
331
481
|
`).replace(/\n{3,}/g,`
|
|
332
482
|
|
|
333
|
-
`).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>
|
|
334
|
-
`).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(``))},AD=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),jD=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),MD=`image/png,image/jpeg,.pdf,.docx`;function ND(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`||AD.has(r)||jD.has(n)}function PD(e){return e?ND(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function FD(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 ID(e){return e?e.name||`Attachment`:``}function LD(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 RD({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}):(0,f.jsx)(`span`,{style:r,children:LD(t)})}function zD({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}=On(),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(),ur(t.href,{siteId:l?.siteId,apiBaseUrl:l?.apiBaseUrl}).then(e=>{e&&gr(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=SD(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)(gD,{size:16}):(0,f.jsx)(RD,{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)(pD,{}),`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=FD(e.metadata.fileSize),a=t.startsWith(`image/`),o=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.jsx)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children: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`:o.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`:o.color,lineHeight:1},children:o.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:kD(e.message)},onClick:b}):(0,f.jsx)(`div`,{style:{whiteSpace:n||l?`normal`:`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)(gD,{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)(RD,{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})]})})]})}function BD({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:ee=`Type your message`}){let te=(0,d.useRef)(null),ne=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,re=u?!!p?.trim():!!e?.trim()||!!y,C=s||S||!re,ie=!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 `,ne]}),(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)(gD,{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:ID(y)}),(0,f.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:FD(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:`center`,gap:`8px`,height:`40px`,padding:`4px`,border:`1px solid rgba(0,0,0,0.06)`,borderRadius:`9999px`,background:`#fff`,boxShadow:`0 4px 14px rgba(0,0,0,0.04)`,opacity:1},onSubmit:n,children:[ie?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{ref:te,type:`file`,accept:MD,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:()=>te.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)(_D,{size:16,color:`currentColor`})})]}):null,(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:ie?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`},value:u?p:e,onChange:e=>{if(u){m(e.target.value);return}t(e.target.value)},placeholder:u?`Enter your Email`:o===`agent`?`Message the agent…`:ee,disabled:s,type:u?`email`:`text`,autoComplete:u?`email`:`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:C?`not-allowed`:`pointer`,opacity:C?.45:1,flexShrink:0},disabled:C,onMouseEnter:e=>{C||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,f.jsx)(fD,{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 VD({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)(hD,{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 HD=[`#135bd8`,`#ef334b`,`#ffbd2e`];function UD(e){return!Array.isArray(e)||e.length===0?HD: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 WD={idle:3,listening:.75,thinking:1,speaking:1.4,muted:.75,error:.08};function GD(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 KD(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 qD=`
|
|
483
|
+
`).split(/\n\s*\n/).map(e=>e.trim()).filter(Boolean),r=e=>zO(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 WO(n.map(e=>{let t=e.split(`
|
|
484
|
+
`).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(``))},KO=new Set([`application/pdf`,`application/vnd.openxmlformats-officedocument.wordprocessingml.document`]),qO=new Set([`.pdf`,`.docx`,`.png`,`.jpg`,`.jpeg`]),JO=`image/png,image/jpeg,.pdf,.docx`;function YO(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`||KO.has(r)||qO.has(n)}function XO(e){return e?YO(e)?e.size>2097152?`File must be 2 MB or smaller.`:``:`Only PNG, JPEG, PDF, and DOCX files are allowed.`:`No file selected.`}function ZO(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 QO(e){return e?e.name||`Attachment`:``}function $O(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 ek({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}):(0,f.jsx)(`span`,{style:r,children:$O(t)})}function tk({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}=Dn(),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(),lr(t.href,{siteId:l?.siteId,apiBaseUrl:l?.apiBaseUrl}).then(e=>{e&&hr(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=RO(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)(MO,{size:16}):(0,f.jsx)(ek,{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)(kO,{}),`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=ZO(e.metadata.fileSize),a=t.startsWith(`image/`),o=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.jsx)(`div`,{style:{minWidth:`200px`,maxWidth:`240px`},children: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`:o.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`:o.color,lineHeight:1},children:o.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:GO(e.message)},onClick:b}):(0,f.jsx)(`div`,{style:{whiteSpace:n||l?`normal`:`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)(MO,{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)(ek,{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})]})})]})}function nk({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:ee=`Type your message`}){let te=(0,d.useRef)(null),ne=c?.sender===`user`?`You`:c?.sender===`agent`?`Agent`:`AI Assistant`,re=u?!!p?.trim():!!e?.trim()||!!y,C=s||S||!re,ie=!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 `,ne]}),(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)(MO,{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:QO(y)}),(0,f.jsx)(`div`,{style:{fontSize:`12px`,color:`#6b7280`,marginTop:`2px`},children:ZO(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:`center`,gap:`8px`,height:`40px`,padding:`4px`,border:`1px solid rgba(0,0,0,0.06)`,borderRadius:`9999px`,background:`#fff`,boxShadow:`0 4px 14px rgba(0,0,0,0.04)`,opacity:1},onSubmit:n,children:[ie?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(`input`,{ref:te,type:`file`,accept:JO,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:()=>te.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)(NO,{size:16,color:`currentColor`})})]}):null,(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:ie?`0`:`8px`,color:`#111827`,background:`transparent`,cursor:`text`},value:u?p:e,onChange:e=>{if(u){m(e.target.value);return}t(e.target.value)},placeholder:u?`Enter your Email`:o===`agent`?`Message the agent…`:ee,disabled:s,type:u?`email`:`text`,autoComplete:u?`email`:`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:C?`not-allowed`:`pointer`,opacity:C?.45:1,flexShrink:0},disabled:C,onMouseEnter:e=>{C||(e.currentTarget.style.opacity=`0.85`)},onMouseLeave:e=>{e.currentTarget.style.opacity=`1`},children:(0,f.jsx)(OO,{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 rk({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)(jO,{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 ik=[`#135bd8`,`#ef334b`,`#ffbd2e`];function ak(e){return!Array.isArray(e)||e.length===0?ik: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 ok={idle:3,listening:.75,thinking:1,speaking:1.4,muted:.75,error:.08};function sk(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 ck(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 lk=`
|
|
335
485
|
attribute vec2 a_pos;
|
|
336
486
|
varying vec2 v_uv;
|
|
337
487
|
void main() {
|
|
338
488
|
v_uv = a_pos * 0.5 + 0.5;
|
|
339
489
|
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
340
490
|
}
|
|
341
|
-
`,
|
|
491
|
+
`,uk=`
|
|
342
492
|
precision highp float;
|
|
343
493
|
|
|
344
494
|
varying vec2 v_uv;
|
|
@@ -453,7 +603,7 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
|
|
|
453
603
|
|
|
454
604
|
gl_FragColor = vec4(clamp(col, 0.0, 1.0), 1.0);
|
|
455
605
|
}
|
|
456
|
-
`;function
|
|
606
|
+
`;function dk(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 fk({size:e=94,voiceState:t=`idle`,isMuted:n=!1,colors:r,onClick:i,style:a,className:o}){let[s,c,l]=ak(r),u=t===`speaking`,p=e<=50,m=(0,d.useRef)(null),h=(0,d.useRef)(ok[t]??.35);(0,d.useEffect)(()=>{h.current=ok[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=dk(r,lk,uk);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,sk(s)),r.uniform3fv(u.c2,sk(c)),r.uniform3fv(u.c3,sk(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)(gm.div,{style:{position:`absolute`,inset:-10,borderRadius:`50%`,background:`radial-gradient(circle, ${ck(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)(gm.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 pk=`
|
|
457
607
|
@keyframes fe-call-ring-pulse {
|
|
458
608
|
0% { transform: scale(1); opacity: 0.55; }
|
|
459
609
|
70% { transform: scale(1.85); opacity: 0; }
|
|
@@ -482,157 +632,7 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
|
|
|
482
632
|
0%, 100% { opacity: 0.5; transform: scale(1); }
|
|
483
633
|
50% { opacity: 0.9; transform: scale(1.12); }
|
|
484
634
|
}
|
|
485
|
-
`;function QD(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 $D(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 eO(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 tO({headshot:e,name:t,size:n=80,primaryColor:r=`#3B82F6`}){let i=(t||`A`)[0].toUpperCase(),a=$D(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 nO(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 rO({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=nO(!!e),x=async()=>{b(),await c()},S=async()=>{b(),await l()},ee=i?`muted`:n===`connecting`?`idle`:`listening`,te=y===`ongoing`,ne={position:`absolute`,inset:0,zIndex:10,display:`flex`,flexDirection:`column`,borderRadius:`inherit`,overflow:`hidden`,background:eO(g,h),animation:te?`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:ne,children:[(0,f.jsx)(`style`,{children:ZD}),(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(${QD(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)(tO,{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)(dD,{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)(mD,{})}),(0,f.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Accept`})]})]})]})]})}return y===`connecting`?(0,f.jsxs)(`div`,{style:ne,children:[(0,f.jsx)(`style`,{children:ZD}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`24px`},children:[(0,f.jsx)(tO,{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:ne,children:[(0,f.jsx)(`style`,{children:ZD}),(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)(XD,{colors:g,size:36,voiceState:ee}),(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)(tO,{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)(xD,{size:18}):(0,f.jsx)(uD,{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)(dD,{size:18}),`End Call`]})]})]})}function iO({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:ZD}),(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)(tO,{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)(xD,{size:15}):(0,f.jsx)(uD,{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)(dD,{size:16})})]})]})]})}function aO(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(`
|
|
486
|
-
`);return i.length>n&&(i=`…(earlier messages omitted)
|
|
487
|
-
`+i.slice(-n)),i}var Q=`fe-vv`;function oO(){if(typeof document>`u`||document.getElementById(`${Q}-styles`))return;let e=`
|
|
488
|
-
/* ── Action toast ───────────────────────────────────────────────────────────── */
|
|
489
|
-
#${Q}-toast {
|
|
490
|
-
position: fixed;
|
|
491
|
-
top: 16px;
|
|
492
|
-
left: 50%;
|
|
493
|
-
transform: translateX(-50%) translateY(-160%);
|
|
494
|
-
background: rgba(10, 10, 20, 0.88);
|
|
495
|
-
color: #f1f5f9;
|
|
496
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
497
|
-
font-size: 13px;
|
|
498
|
-
font-weight: 500;
|
|
499
|
-
line-height: 1.4;
|
|
500
|
-
padding: 9px 18px 9px 14px;
|
|
501
|
-
border-radius: 999px;
|
|
502
|
-
z-index: 2147483640;
|
|
503
|
-
pointer-events: none;
|
|
504
|
-
opacity: 0;
|
|
505
|
-
transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s ease;
|
|
506
|
-
white-space: nowrap;
|
|
507
|
-
display: flex;
|
|
508
|
-
align-items: center;
|
|
509
|
-
gap: 9px;
|
|
510
|
-
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35), 0 1px 4px rgba(0, 0, 0, 0.2);
|
|
511
|
-
backdrop-filter: blur(12px);
|
|
512
|
-
-webkit-backdrop-filter: blur(12px);
|
|
513
|
-
border: 1px solid rgba(255,255,255,0.08);
|
|
514
|
-
max-width: 90vw;
|
|
515
|
-
overflow: hidden;
|
|
516
|
-
text-overflow: ellipsis;
|
|
517
|
-
}
|
|
518
|
-
#${Q}-toast.${Q}-show {
|
|
519
|
-
transform: translateX(-50%) translateY(0);
|
|
520
|
-
opacity: 1;
|
|
521
|
-
}
|
|
522
|
-
#${Q}-toast .${Q}-spin {
|
|
523
|
-
width: 13px;
|
|
524
|
-
height: 13px;
|
|
525
|
-
border: 2px solid rgba(255,255,255,0.25);
|
|
526
|
-
border-top-color: #a78bfa;
|
|
527
|
-
border-radius: 50%;
|
|
528
|
-
animation: ${Q}-spin 0.65s linear infinite;
|
|
529
|
-
flex-shrink: 0;
|
|
530
|
-
}
|
|
531
|
-
#${Q}-toast .${Q}-icon {
|
|
532
|
-
font-size: 14px;
|
|
533
|
-
flex-shrink: 0;
|
|
534
|
-
line-height: 1;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
/* ── Navigation progress bar ────────────────────────────────────────────────── */
|
|
538
|
-
#${Q}-bar {
|
|
539
|
-
position: fixed;
|
|
540
|
-
top: 0;
|
|
541
|
-
left: 0;
|
|
542
|
-
width: 0%;
|
|
543
|
-
height: 3px;
|
|
544
|
-
background: linear-gradient(90deg, #7c3aed, #06b6d4, #7c3aed);
|
|
545
|
-
background-size: 200% 100%;
|
|
546
|
-
z-index: 2147483647;
|
|
547
|
-
pointer-events: none;
|
|
548
|
-
opacity: 0;
|
|
549
|
-
transition: width 0.35s ease, opacity 0.25s ease;
|
|
550
|
-
box-shadow: 0 0 12px #7c3aed88;
|
|
551
|
-
animation: ${Q}-bar-shimmer 1.5s linear infinite;
|
|
552
|
-
}
|
|
553
|
-
#${Q}-bar.${Q}-bar-active {
|
|
554
|
-
opacity: 1;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/* ── Field active highlight (about to fill) ─────────────────────────────────── */
|
|
558
|
-
.${Q}-field-active {
|
|
559
|
-
outline: 2.5px solid #7c3aed !important;
|
|
560
|
-
outline-offset: 3px !important;
|
|
561
|
-
box-shadow: 0 0 0 5px rgba(124, 58, 237, 0.14), 0 0 20px rgba(124, 58, 237, 0.28) !important;
|
|
562
|
-
border-radius: 5px !important;
|
|
563
|
-
transition: outline 0.18s ease, box-shadow 0.18s ease !important;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/* ── Field filled confirmation (green flash) ────────────────────────────────── */
|
|
567
|
-
.${Q}-field-filled {
|
|
568
|
-
outline: 2px solid #10b981 !important;
|
|
569
|
-
outline-offset: 3px !important;
|
|
570
|
-
box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.12), 0 0 16px rgba(16, 185, 129, 0.22) !important;
|
|
571
|
-
border-radius: 5px !important;
|
|
572
|
-
animation: ${Q}-fill-flash 0.45s ease forwards !important;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
/* ── Ghost cursor ────────────────────────────────────────────────────────────── */
|
|
576
|
-
#${Q}-cursor {
|
|
577
|
-
position: fixed;
|
|
578
|
-
width: 22px;
|
|
579
|
-
height: 22px;
|
|
580
|
-
pointer-events: none;
|
|
581
|
-
z-index: 2147483645;
|
|
582
|
-
opacity: 0;
|
|
583
|
-
transition:
|
|
584
|
-
left 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94),
|
|
585
|
-
top 0.32s cubic-bezier(0.25, 0.46, 0.45, 0.94),
|
|
586
|
-
opacity 0.2s ease;
|
|
587
|
-
transform: translate(-4px, -4px);
|
|
588
|
-
}
|
|
589
|
-
#${Q}-cursor.${Q}-cursor-visible {
|
|
590
|
-
opacity: 1;
|
|
591
|
-
}
|
|
592
|
-
#${Q}-cursor.${Q}-cursor-click {
|
|
593
|
-
animation: ${Q}-cursor-click 0.25s ease;
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
/* ── Click ripple ────────────────────────────────────────────────────────────── */
|
|
597
|
-
.${Q}-ripple {
|
|
598
|
-
position: absolute;
|
|
599
|
-
border-radius: 50%;
|
|
600
|
-
transform: scale(0);
|
|
601
|
-
background: rgba(124, 58, 237, 0.35);
|
|
602
|
-
animation: ${Q}-ripple-anim 0.55s linear forwards;
|
|
603
|
-
pointer-events: none;
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
/* ── Keyframes ───────────────────────────────────────────────────────────────── */
|
|
607
|
-
@keyframes ${Q}-spin {
|
|
608
|
-
to { transform: rotate(360deg); }
|
|
609
|
-
}
|
|
610
|
-
@keyframes ${Q}-bar-shimmer {
|
|
611
|
-
0% { background-position: 0% 0%; }
|
|
612
|
-
100% { background-position: 200% 0%; }
|
|
613
|
-
}
|
|
614
|
-
@keyframes ${Q}-fill-flash {
|
|
615
|
-
0% { background-color: rgba(16, 185, 129, 0.10); }
|
|
616
|
-
40% { background-color: rgba(16, 185, 129, 0.22); }
|
|
617
|
-
100% { background-color: transparent; }
|
|
618
|
-
}
|
|
619
|
-
@keyframes ${Q}-ripple-anim {
|
|
620
|
-
to { transform: scale(3.5); opacity: 0; }
|
|
621
|
-
}
|
|
622
|
-
@keyframes ${Q}-cursor-click {
|
|
623
|
-
0% { transform: translate(-4px,-4px) scale(1); }
|
|
624
|
-
50% { transform: translate(-4px,-4px) scale(0.82); }
|
|
625
|
-
100% { transform: translate(-4px,-4px) scale(1); }
|
|
626
|
-
}
|
|
627
|
-
`,t=document.createElement(`style`);t.id=`${Q}-styles`,t.textContent=e,(document.head||document.documentElement).appendChild(t)}var sO=null,cO=null;function lO(){return(!sO||!sO.isConnected)&&(sO=document.createElement(`div`),sO.id=`${Q}-toast`,document.body.appendChild(sO)),sO}function uO(e,{spinner:t=!0,icon:n=null,duration:r=0}={}){if(typeof document>`u`)return;oO(),cO&&=(clearTimeout(cO),null);let i=lO();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&&(cO=setTimeout(()=>dO(),r))}function dO(e=0){sO&&(e>0?cO=setTimeout(()=>{sO&&sO.classList.remove(`${Q}-show`)},e):sO&&sO.classList.remove(`${Q}-show`))}var fO=null,pO=[];function mO(){return(!fO||!fO.isConnected)&&(fO=document.createElement(`div`),fO.id=`${Q}-bar`,document.body.appendChild(fO)),fO}function hO(){if(typeof document>`u`)return;oO(),pO.forEach(clearTimeout),pO=[];let e=mO();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;pO.push(setTimeout(()=>{fO&&(fO.style.transition=a,fO.style.width=`${i}%`)},t)),n+=800}}function gO(){fO&&(pO.forEach(clearTimeout),pO=[],fO.style.transition=`width 0.2s ease`,fO.style.width=`100%`,pO.push(setTimeout(()=>{fO&&(fO.style.transition=`opacity 0.35s ease`,fO.style.opacity=`0`,pO.push(setTimeout(()=>{fO&&(fO.style.width=`0%`,fO.classList.remove(`${Q}-bar-active`))},380)))},220)))}function _O(){typeof document>`u`||document.querySelectorAll(`.${Q}-field-active, .${Q}-field-filled`).forEach(e=>e.classList.remove(`${Q}-field-active`,`${Q}-field-filled`))}function vO(e){!e||typeof document>`u`||(oO(),_O(),e.classList.add(`${Q}-field-active`))}function yO(e){e&&(e.classList.remove(`${Q}-field-active`),e.classList.add(`${Q}-field-filled`),setTimeout(()=>{e.isConnected&&e.classList.remove(`${Q}-field-filled`)},1400))}var bO=`<svg xmlns="http://www.w3.org/2000/svg" width="22" height="22" viewBox="0 0 22 22" fill="none">
|
|
628
|
-
<filter id="${Q}-csh">
|
|
629
|
-
<feDropShadow dx="1" dy="2" stdDeviation="1.5" flood-color="#00000060"/>
|
|
630
|
-
</filter>
|
|
631
|
-
<path d="M4 2L19 10.5L11 12.8L8 20L4 2Z"
|
|
632
|
-
fill="white" stroke="#1e1b4b" stroke-width="1.6" stroke-linejoin="round"
|
|
633
|
-
filter="url(#${Q}-csh)"/>
|
|
634
|
-
</svg>`,xO=null,SO=!1;function CO(){return(!xO||!xO.isConnected)&&(xO=document.createElement(`div`),xO.id=`${Q}-cursor`,xO.innerHTML=bO,document.body.appendChild(xO),SO=!1),xO}async function wO(e){if(typeof document>`u`||!e)return;oO();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=CO();SO||=(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 OO(360)}function TO(e=!1){xO&&(e?(xO.classList.remove(`${Q}-cursor-visible`),SO=!1):(xO.classList.remove(`${Q}-cursor-visible`),setTimeout(()=>{SO=!1},250)))}async function EO(e){xO&&(xO.classList.add(`${Q}-cursor-click`),await OO(280),xO.classList.remove(`${Q}-cursor-click`))}function DO(e){if(!e||typeof document>`u`)return;oO();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 OO(e){return new Promise(t=>setTimeout(t,e))}function $(...e){kn()&&console.log(`[FlowEngage:voice-tools]`,...e)}function kO(e){return new Promise(t=>setTimeout(t,e))}var AO=`#flowengage-root, .flowengage-shell, .flowengage-widget-root`;function jO(e){if(!e||typeof e.closest!=`function`)return!1;try{return!!e.closest(AO)}catch{return!1}}function MO(e){try{let t=e.ownerDocument?.defaultView;if(t)return t.getComputedStyle(e)}catch{}return window.getComputedStyle(e)}function NO(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(!jO(e))try{let t=e.contentDocument;t&&n(t)}catch{}}typeof document<`u`&&n(document)}function PO(e){return e==null?null:String(e).replace(/\u00a0/g,` `).replace(/\s*\*+\s*$/u,``).replace(/\s+/g,` `).trim()}function FO(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 PO(r.join(` `))}if(e.labels&&e.labels.length)return PO(e.labels[0].textContent);let r=e.id;if(r)try{let e=t.querySelector(`label[for="${CSS.escape(r)}"]`);if(e)return PO(e.textContent)}catch{let e=t.querySelector(`label[for="${r.replace(/"/g,`\\"`)}"]`);if(e)return PO(e.textContent)}let i=e.previousElementSibling;for(let e=0;e<6&&i;e+=1){if(i.tagName===`LABEL`)return PO(i.textContent);let e=(i.className||``).toString().toLowerCase();if(/chakra-form__label|formlabel|field-label|form-label|mui-form-label/.test(e)){let e=PO(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 PO(a.textContent);let e=a.querySelector?.(`:scope > label, :scope > [class*='FormLabel'], :scope > [class*='form__label']`);if(e?.textContent)return PO(e.textContent);a=a.parentElement}let o=e.getAttribute(`aria-label`);return o?PO(o):null}function IO(){let e=[];return NO(t=>{e.push(...Array.from(t.querySelectorAll(`input, select, textarea`)).filter(e=>{if(jO(e))return!1;let t=(e.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`image`].includes(t)||e.disabled||e.readOnly)return!1;try{let t=MO(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))}),e}function LO(){return IO().map((e,t)=>({formIndex:0,fieldIndex:t,tag:e.tagName,type:e.type||`text`,name:e.name||null,id:e.id||null,label:FO(e),placeholder:e.placeholder||null}))}function RO(){let e=[];return NO(t=>{e.push(...Array.from(t.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(jO(e)||e.disabled)return!1;try{let t=MO(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 zO(e){return String(e||``).toLowerCase().replace(/\u00a0/g,` `).replace(/\*/g,``).replace(/\s+/g,` `).trim()}function BO(e){let t=zO(e);return t=t.replace(/\s+field\s*$/i,``).trim(),t}function VO(e,t){let n=BO(t);if(!n)return 0;let r=(e.name||``).toLowerCase(),i=(e.id||``).toLowerCase();if(r===`url`&&/url|website|domain|site|audit/.test(n)||(i===`url-input`||i.endsWith(`-url-input`))&&/url|website|domain|site|audit/.test(n))return 100;let a=[e.name,e.id,e.placeholder,FO(e),e.getAttribute(`aria-label`),e.getAttribute(`title`),e.getAttribute(`data-testid`),e.getAttribute(`autocomplete`)].filter(Boolean).map(e=>zO(e)),o=0;for(let e of a){if(!e)continue;if(e.includes(n)||n.includes(e)){o=Math.max(o,100);continue}let t=n.split(/\s+/).filter(e=>e.length>1);if(!t.length)continue;let r=0;for(let n of t)e.includes(n)&&(r+=1);o=Math.max(o,r/t.length*88)}return o}var HO=28;function UO(e,t){let n=null,r=0;for(let i of e){let e=VO(i,t);e>r&&(r=e,n=i)}return!n||r<HO?null:n}function WO(e,t,n){let r=String(t||``).toLowerCase().trim(),i=String(n||``).trim();if(!(/^https?:\/\//i.test(i)||/\.\w{2,}(\/|\s|$)/.test(i)||r.includes(`url`)||r.includes(`website`)||r.includes(`domain`)||r.includes(`site`)))return null;let a=null,o=0;for(let t of e){if(t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`)continue;let e=(t.type||``).toLowerCase();if([`hidden`,`submit`,`button`,`checkbox`,`radio`].includes(e))continue;let n=0;(e===`url`||e===`text`||e===`search`)&&(n+=45);let r=[t.name,t.id,t.placeholder,FO(t),t.getAttribute(`aria-label`),t.getAttribute(`autocomplete`)].filter(Boolean).join(` `).toLowerCase();/(website|url|domain|site\s*url)/.test(r)&&(n+=55),n>o&&(o=n,a=t)}return!a||o<42?null:a}function GO(e){let t=String(e??``).trim();return t?/^https?:\/\//i.test(t)?!0:/\.\w{2,}(\/|\s|$)/.test(t):!1}function KO(e){let t=String(e??``).toLowerCase().trim();return t?!!(t===`url`||t===`website`||t===`website url`||t===`website_url`||t===`enter website url`||t.includes(`website`)||t.includes(`domain`)||/(enter\s+website|site\s*url|page\s*url)/.test(t)):!1}function qO(e){if(!e||e.tagName!==`INPUT`&&e.tagName!==`TEXTAREA`)return!1;let t=(e.type||``).toLowerCase();return![`hidden`,`submit`,`button`,`checkbox`,`radio`,`file`].includes(t)}function JO(e){if(!qO(e))return!1;let t=(e.name||``).toLowerCase(),n=(e.id||``).toLowerCase(),r=[e.name,e.id,e.placeholder,FO(e),e.getAttribute(`aria-label`)].filter(Boolean).join(` `).toLowerCase();return t===`url`||n===`url-input`||n.endsWith(`-url-input`)||/(website\s*url|enter\s+website|site\s*url)/.test(r)||/(website|domain)/.test(r)&&/(url|site)/.test(r)}function YO(e,t,n){let r=String(t??``),i=String(n??``),a=QO(e,r)||UO(e,r)||WO(e,r,i);if(!a)return[];let o=new Set([a]);if(GO(i)&&KO(r))for(let t of e)t!==a&&JO(t)&&o.add(t);let s=Array.from(o);return s.sort((e,t)=>{if(e===t)return 0;let n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING?-1:n&Node.DOCUMENT_POSITION_PRECEDING?1:0}),s}function XO(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 ZO(e){if(!e||typeof e!=`string`)return null;let t=null;return NO(n=>{try{let r=n.getElementById(e);r&&!jO(r)&&r.matches?.(`input, select, textarea`)&&(t=r)}catch{}}),t}function QO(e,t){let n=String(t??``).trim();if(!n)return null;let r=n.match(/^name:\s*([\w.-]+)$/i);if(r){let t=r[1];for(let n of e)if(n.name===t)return n}let i=n.match(/^id:\s*([\w.-]+)$/i);if(i){let e=ZO(i[1]);if(e)return e}let a=n.startsWith(`#`)?n.slice(1):n;if(/^[\w-]+$/.test(a)){let e=ZO(a);if(e)return e}let o=n.toLowerCase().replace(/\s+/g,` `);if(o===`url`||o===`website`||o===`website url`||o===`website_url`||o===`enter website url`)for(let t of e){let e=(t.name||``).toLowerCase(),n=(t.id||``).toLowerCase();if(e===`url`||n===`url-input`||n.endsWith(`-url-input`))return t}return null}function $O(e,t){let n=String(t||``).toLowerCase().trim();if(!n)return 0;let r=[e.textContent,e.value,e.getAttribute(`aria-label`),e.getAttribute(`title`)].filter(Boolean).join(` `).toLowerCase().replace(/\s+/g,` `);if(r.includes(n))return 100;let i=n.split(/\s+/).filter(e=>e.length>1);if(!i.length)return 0;let a=0;for(let e of i)r.includes(e)&&(a+=1);return a/i.length*92}function ek(e,t){let n=[];NO(e=>{n.push(...Array.from(e.querySelectorAll(`button, [role="button"], input[type="submit"], input[type="button"]`)).filter(e=>{if(jO(e)||e.disabled)return!1;try{let t=MO(e);if(t.display===`none`||t.visibility===`hidden`)return!1}catch{}return!0}))});let r=0,i=n.map(t=>({el:t,s:$O(t,e)}));for(let{s:e}of i)e>r&&(r=e);if(r<36)return null;let a=i.filter(({s:e})=>e===r).map(({el:e})=>e);if(a.length===1)return a[0];let o=Array.isArray(t)?t.filter(e=>e&&e.isConnected):[];if(o.length){let e=a[0],t=1/0;for(let n of a)for(let r of o){let i=XO(n,r);i<t&&(t=i,e=n)}return e}return a[0]}function tk(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 nk(e){let t=tk(e);if(Array.isArray(t)&&t.length>0){let e=t[0];if(e?.field_key!=null||e?.fieldKey!=null)return t.map(e=>({field_key:e.field_key??e.fieldKey,value:e.value}))}if(!t||typeof t!=`object`)return[];let n=t.fields??t.Fields??t.field_list??t.fieldList??t.data?.fields;if(typeof n==`string`)try{n=JSON.parse(n)}catch{n=null}n&&!Array.isArray(n)&&typeof n==`object`&&(n=Object.values(n)),(!n||n.length===0)&&(t.field_key!=null||t.fieldKey!=null)&&t.value!=null&&(n=[{field_key:t.field_key??t.fieldKey,value:t.value}]);let r=t.website_url??t.websiteUrl??t.url??t.website??t.domain??t.site_url??t.siteUrl;return(!n||n.length===0)&&r!=null&&String(r).trim()&&(n=[{field_key:t.field_key??t.fieldKey??`url`,value:String(r).trim()}]),Array.isArray(n)?n.map(e=>({field_key:e?.field_key??e?.fieldKey,value:e?.value??e?.Value})):[]}function rk(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t||/\b[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}\b/i.test(t))return[];let n=t.match(/https?:\/\/[^\s<>"']+/i);if(n)return[{field_key:`url`,value:n[0].replace(/[.,;:)]+$/,``)}];let r=t.match(/\b(?:[\w-]+\.)+[a-z]{2,}\b/i);if(r){let e=r[0].replace(/[.,;:)]+$/,``);return/^https?:/i.test(e)||(e=`https://${e}`),[{field_key:`url`,value:e}]}return[]}function ik(e){if(!e||typeof e!=`string`)return[];let t=e.trim();if(!t)return[];let n=[],r=new Set,i=/\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\b/i,a=(e,t)=>{let i=String(t??``).trim().replace(/^["']|["']$/g,``);if(!i||i.length>800)return;let a=`${e}\0${i}`;r.has(a)||(r.add(a),n.push({field_key:e,value:i}))},o=t.match(/^\s*([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,})\s*$/i);if(o)return a(`Email Address`,o[1]),n;let s=t.match(/\b(?:please\s+)?(?:enter|type|put)\s+(.+?)\s+in(?:to)?\s+(?:the\s+)?(?:full\s*name|full\s*name\s*field|name\s*field)\b/i);if(s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name,?\s*(?:please\s+)?(?:enter|type|put)\s+(.+?)(?:\.|$|!|\?)/i),s&&a(`Full Name`,s[1]),s=t.match(/\bfull\s*name\s*(?:is|:|please\s+enter|-)\s*(.+?)(?:\.|$|(?=\s+(?:and|my\s+email|email|message))\b)/i),s&&a(`Full Name`,s[1]),s=t.match(/\b(.+?)\s+for\s+(?:the\s+)?full\s*name\b/i),s){let e=s[1].trim();e.length>1&&e.length<120&&!/@/.test(e)&&a(`Full Name`,e)}if(s=t.match(/\b(?:email|e-mail)(?:\s*address)?\s*(?:is|:|please\s+use|enter|-)\s*([^\s@]+@[^\s@]+\.[^\s,]+)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:enter|type|put)\s+([^\s@]+@[^\s@]+\.[^\s,]+)\s+in(?:to)?\s+(?:the\s+)?(?:email|e-mail)/i),s&&a(`Email Address`,s[1]),s=t.match(/\b(?:message|comment)\s*(?:is|:|please\s+enter|-)\s*(.+)$/is),s){let e=s[1].trim();e.length>0&&a(`Message`,e)}if(!n.some(e=>/email/i.test(String(e.field_key)))){let e=t.match(i);if(e){let r=t.replace(e[0],``).trim().replace(/^(please|it's|it is|use|is|my email is|e-?mail is)\s*/i,``).replace(/[.,;:!?]+$/,``).trim();if(t.length<=96&&r.length<=36)return a(`Email Address`,e[1]),n}}if(n.length===0){let e=t.split(/\s+/).filter(Boolean).length,n=/[.!?]/.test(t)||e>=6||t.length>=24&&e>=5||t.length>=42,r=/^[A-Z][a-z]+\s+[A-Z][a-z]+$/.test(t.trim());n&&t.length>=16&&!i.test(t)&&!r&&a(`Message`,t)}return n}function ak(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 ok(e){if(!e||typeof e!=`object`)return null;let t=e.query??e.q??e.search??e.text??e.keywords;return t==null?null:String(t).trim()||null}function sk(e,t,n){if(!n?.skipScroll)try{e.scrollIntoView({block:`center`,inline:`nearest`})}catch{try{e.scrollIntoView(!0)}catch{}}try{e.focus({preventScroll:!0})}catch{try{e.focus()}catch{}}let r=e.tagName,i=(e.type||``).toLowerCase();if(r===`SELECT`)return e.value=String(t),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;if(i===`checkbox`||i===`radio`)return e.checked=[`1`,`true`,`yes`,`on`].includes(String(t).toLowerCase().trim()),e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0})),!0;let a=String(t);if(r===`INPUT`||r===`TEXTAREA`){let t=e.ownerDocument?.defaultView||window,n=r===`TEXTAREA`?t.HTMLTextAreaElement.prototype:t.HTMLInputElement.prototype,i=Object.getOwnPropertyDescriptor(n,`value`);i?.set?i.set.call(e,a):e.value=a}else e.value=a;let o={bubbles:!0,cancelable:!0,composed:!0};try{e.dispatchEvent(new InputEvent(`input`,{...o,inputType:`insertText`,data:a}))}catch{e.dispatchEvent(new Event(`input`,o))}e.dispatchEvent(new Event(`change`,o));try{queueMicrotask(()=>{try{e.dispatchEvent(new Event(`input`,o)),e.dispatchEvent(new Event(`change`,o))}catch{}})}catch{}return!0}function ck(){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 lk(){let e=document.querySelector(`main, [role='main'], article`)||document.body;return Array.from(e.querySelectorAll(`h1, h2, h3, h4`)).filter(e=>!e.closest(`#flowengage-root, .flowengage-shell, .flowengage-widget-root`)).map(e=>e.textContent.replace(/\s+/g,` `).trim()).filter(e=>e.length>2&&e.length<200).slice(0,12)}function uk(e){let t=e.siteId||null,n=(e.apiBaseUrl||``).replace(/\/$/,``),r=typeof e.getLastUserVoiceText==`function`?e.getLastUserVoiceText:null,i=[],a={flowengage_navigate:async n=>{$(`flowengage_navigate ▶ raw parameters:`,n);let i=tk(n),a=ak(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($(`flowengage_navigate · 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 $(`flowengage_navigate ✖`,e),e}if(typeof window<`u`)try{let e=new URL(a,window.location.href);e.origin!==window.location.origin&&/^https?:$/i.test(e.protocol)&&(a=e.pathname+e.search+e.hash,$(`flowengage_navigate · normalized cross-origin URL to path:`,a))}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 $(`flowengage_navigate ✖ 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{}if(!await ur(a,{siteId:t,apiBaseUrl:e.apiBaseUrl})){let e=`Page "${a}" could not be verified. Call flowengage_search with keywords from the topic to find the correct URL, then navigate to the URL from the search results.`;return $(`flowengage_navigate ✖ blocked`,e),e}try{uO(`Navigating to ${a}...`,{spinner:!0}),hO(),lD();try{let e=r?r():``;if(e&&t){let n=aO([{sender:`user`,message:e}]);n&&xe(t,n)}}catch{}Te();let e=a;try{e=new URL(a,typeof window<`u`?window.location.href:``).href}catch{}t&&typeof window<`u`&&Me(t,window.location.href,e),pr(e),$(`flowengage_navigate → real navigation`,a);let n=typeof window<`u`&&!!(window.next?.router||window.__NEXT_ROUTER__||window.__remixRouter||window.__staticRouterHydrationData||window.___gatsby||window.___navigate||window.__VUE_ROUTER__||window.__NUXT__||window.$nuxt||window.ng?.getComponent||typeof document<`u`&&document.querySelector(`[ng-version]`)||window.__sveltekit_data||typeof document<`u`&&document.querySelector(`[data-sveltekit-hydrate]`));if(typeof window<`u`&&window.__fe_triggerVoiceNavHooks&&window.__fe_triggerVoiceNavHooks(),n&&Ln(3e3),gr(a,{voiceActive:!0}).catch(()=>{}),n)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`;$(`flowengage_navigate → SPA nav complete. target:`,e,`actual:`,n);let s=[],c=Date.now()+2e3;for(;Date.now()<c&&(await new Promise(e=>setTimeout(e,250)),s=lk(),!(s.length>=3)););$(`flowengage_navigate → page headings collected:`,s);let l=s.length?s.join(` | `):`none`;return i?(mr(),`OK_NAVIGATE_SPA. Visitor is now on: ${r} (page: "${o}") | Section headings: ${l}. Use ONLY these exact heading strings for flowengage_highlight. Do NOT say "I have navigated you" or "I've taken you to" — start immediately with highlights and content about THIS page.`):(mr(),`OK_NAVIGATE_SPA. CURRENT PAGE IS: ${r} (page: "${o}") | Section headings: ${l}. Use ONLY these exact heading strings for flowengage_highlight. Describe THIS page only — do not mention the page you tried to navigate to.`)}catch{}return`OK_NAVIGATE_RELOADING. Navigating to the page now; the voice session will resume automatically on the new page. When the session resumes, immediately introduce the new page and continue guiding the visitor — do not wait for the user to speak first.`}catch(e){let t=`Navigation error: ${e?.message||String(e)}`;return $(`flowengage_navigate ✖`,t),uO(`Navigation failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{gO(),dO(900)}},flowengage_highlight:async e=>{$(`flowengage_highlight ▶`,e);let t=tk(e),n=t?.section_id||t?.sectionId,r=t?.section_text||t?.sectionText;ck();let i=ar(n||null,r||null);if(!i&&r&&(await new Promise(e=>setTimeout(e,500)),ck(),i=ar(null,r)),!i){$(`flowengage_highlight ✖ no element for:`,r||n);let e=lk(),t=e.length?`Page headings: ${e.join(` | `)}. Use one of these exact strings for section_text.`:`No headings found — skip highlight and continue.`;return`HIGHLIGHT_NOT_FOUND: "${r||n}" on the current page. ${t}`}return cD(i),$(`flowengage_highlight ✓`,r||n),`OK_HIGHLIGHT: "${r||n}". WALKTHROUGH: If you are mid-walkthrough and have more sections to cover, continue immediately to the next section — do NOT pause or wait for the visitor to speak between sections.`},flowengage_read_content:async e=>{$(`flowengage_read_content ▶`,e);let t=tk(e),n=t?.section_text||t?.sectionText||``;try{let e=``;if(n){let t=ar(null,n);if(!t)return`Could not find section "${n}" on the page.`;let r=[t.textContent.trim()],i=t.nextElementSibling;for(;i&&!/^H[1-3]$/i.test(i.tagName);){let e=i.textContent.trim();e&&r.push(e),i=i.nextElementSibling}e=r.join(`
|
|
635
|
-
`)}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`).forEach(e=>e.remove()),e=t.textContent.replace(/\s+/g,` `).trim()}return e.length>8e3&&(e=e.substring(0,8e3)+`... (truncated)`),$(`flowengage_read_content ✓`,`${e.length} chars`),e||`No readable content found on this page.`}catch(e){return $(`flowengage_read_content ✖`,e.message),`Could not read page content: ${e.message}`}},flowengage_search:async e=>{$(`flowengage_search ▶`,e);let r=ok(tk(e));if($(`flowengage_search · query:`,r,`siteId:`,t,`apiBase:`,n||`(empty)`),!r)return $(`flowengage_search ✖ missing query`),`Missing query parameter.`;if(!t)return $(`flowengage_search ✖ no siteId`),`Site is not configured for search.`;if(!n)return $(`flowengage_search ✖ no api base`),`API base URL is missing; cannot search.`;uO(`Searching${r?` for "${r}"`:``}…`,{spinner:!0});try{let e=`${n}/api/site-tools/search`;$(`flowengage_search → 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($(`flowengage_search · HTTP`,i.status,`success:`,a.success),!a.success){let e=a.error||`Search failed.`;return $(`flowengage_search ✖`,e),e}let o=a.results||[];return $(`flowengage_search ✓`,`${o.length} result(s)`,o.slice(0,3).map(e=>e?.url||e)),JSON.stringify(o)}catch(e){let t=`Search error: ${e.message||`network`}`;return $(`flowengage_search ✖`,t),t}finally{dO(600)}},flowengage_page_content:async e=>{$(`flowengage_page_content ▶`,e);let r=tk(e),i=r?.url||r?.page_url||``;if($(`flowengage_page_content · url:`,i,`siteId:`,t,`apiBase:`,n||`(empty)`),!i)return $(`flowengage_page_content ✖ missing url`),`Missing url parameter.`;if(!t)return $(`flowengage_page_content ✖ no siteId`),`Site is not configured.`;if(!n)return $(`flowengage_page_content ✖ no api base`),`API base URL is missing; cannot fetch page content.`;try{let e=`${n}/api/site-tools/page-content`;$(`flowengage_page_content → 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($(`flowengage_page_content · HTTP`,r.status,`success:`,a.success),!a.success){let e=a.error||`Failed to get page content.`;return $(`flowengage_page_content ✖`,e),`${e} FALLBACK REQUIRED: This page is not in the search index. Call flowengage_read_content (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 $(`flowengage_page_content ✓`,`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 $(`flowengage_page_content ✖`,t),t}},flowengage_end_session:async()=>($(`flowengage_end_session ▶`),typeof e.requestEndSession==`function`&&e.requestEndSession(),`Voice session is ending.`),flowengage_get_current_page:async()=>{if($(`flowengage_get_current_page ▶`),typeof window>`u`)return`Cannot determine current page (no browser context).`;let e=window.location.href,t=window.location.pathname,n=document.title||``,r=lk(),i=r.length?r.join(` | `):`none`;return $(`flowengage_get_current_page ✓`,{url:e,path:t,title:n}),$(`flowengage_get_current_page → page headings collected:`,r),`CURRENT_PAGE. URL: ${e} | Path: ${t} | Title: ${n} | Section headings: ${i}. Use ONLY these exact heading strings for flowengage_highlight — never invent or abbreviate section names.`},flowengage_list_forms:async()=>{let e=LO(),t=RO();return $(`flowengage_list_forms ✓`,`${e.length} field(s)`,`${t.length} button(s)`),JSON.stringify({fields:e,buttons:t,hint:`field_key: placeholder/label, name (e.g. url), id (e.g. url-input). If the page has two URL boxes, flowengage_fill_form sets all matching URL inputs. flowengage_click_button picks the Conduct Audit nearest the filled field when labels duplicate.`})},flowengage_fill_form:async e=>{try{$(`flowengage_fill_form ▶ raw:`,e),_O();let t=nk(e);if(!t.length&&r){let e=r(),n=rk(e);n.length?$(`flowengage_fill_form · inferred URL from last user utterance (model omitted usable fields):`,n):(n=ik(e),n.length&&$(`flowengage_fill_form · inferred contact fields from last user utterance (empty tool params):`,n)),n.length&&(t=n)}if($(`flowengage_fill_form · normalized fields:`,t),!t.length)return`No fields provided. Call flowengage_list_forms for field_key strings, then flowengage_fill_form with { "fields": [ { "field_key": "<label or placeholder from list>", "value": "<user value>" } ] }. Never use empty {}. Pass the value the user just said (email, message, name, URL) in fields.`;let n=[];for(let e of t){let t=e?.field_key??e?.fieldKey,r=e?.value;if(t==null||r==null)continue;uO(`Filling ${String(t)}...`,{spinner:!0});let a=IO(),o=YO(a,String(t),r);if(o.length){for(let[e,t]of o.entries())vO(t),await wO(t),sk(t,r,{skipScroll:e>0}),yO(t),await kO(120);i=o,n.push(String(t));continue}let s=QO(a,String(t));s||=UO(a,String(t)),s||=WO(a,String(t),r),s&&(vO(s),await wO(s),sk(s,r),yO(s),await kO(120),i=[s],n.push(String(t)))}if(!n.length)return $(`flowengage_fill_form ✖ no matches`),`Could not match any fields. Call flowengage_list_forms and use field_key values that match placeholder, label, name, or id (e.g. Enter Website URL). Ensure the form is on the page, not the chat panel.`;let a=`OK_FILLED: ${n.join(`, `)}`;return $(`flowengage_fill_form ✓`,a),uO(`Form filled`,{spinner:!1,icon:`✅`,duration:1100}),a}catch(e){let t=`flowengage_fill_form error: ${e?.message||String(e)}`;return $(`flowengage_fill_form ✖`,t),uO(`Failed to fill form`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{TO(),_O(),dO(700)}},flowengage_click_button:async e=>{let t=tk(e),n=(t.button_text??t.buttonText??t.text??``).trim();if($(`flowengage_click_button ▶`,n),!n)return`Missing button_text: pass the visible label, e.g. Conduct Audit.`;let r=ek(n,i);if(!r)return $(`flowengage_click_button ✖ no match`),`Could not find a button matching "${n}". Call flowengage_list_forms to see button texts.`;try{uO(`Clicking ${n}...`,{spinner:!0});try{r.scrollIntoView({block:`center`,inline:`nearest`})}catch{r.scrollIntoView(!0)}await wO(r),r.focus?.(),await EO(r),DO(r),r.click();let e=(r.textContent||r.value||r.getAttribute(`aria-label`)||``).trim().slice(0,80)||`button`,t=`OK_CLICK ${e}`;return $(`flowengage_click_button ✓`,t),uO(`Clicked ${e}`,{spinner:!1,icon:`✅`,duration:1200}),t}catch(e){let t=`Click failed: ${e?.message||String(e)}`;return $(`flowengage_click_button ✖`,t),uO(`Click failed`,{spinner:!1,icon:`⚠️`,duration:1800}),t}finally{TO(),dO(700)}}};return{...a,highlightOnPage:a.flowengage_highlight,searchSiteContent:a.flowengage_search,getPageContent:a.flowengage_page_content,endVoiceSession:a.flowengage_end_session,listPageForms:a.flowengage_list_forms,fillFormFields:a.flowengage_fill_form,clickPageButton:a.flowengage_click_button}}function dk(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=kn();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 fk={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function pk(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 mk(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 hk({logo:e,style:t}){if(!e)return null;if(typeof e==`string`)return(0,f.jsx)(`img`,{src:e,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}});let n=typeof e==`function`?d.default.createElement(e):d.default.isValidElement(e)?e:null;return n?(0,f.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:n}):null}function gk({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 _k(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)||/\b(that'?s all|we'?re done)\b/i.test(n)||e===`bot`&&(/\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))||/^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)):!1}function vk({orbColors:e,...t}){return(0,f.jsx)(XD,{colors:e,...t})}function yk({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a,isClosing:o}){let s=n||fk.green,c=mk(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)(gm.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:a?void 0:`210px`},children:e.entryPrompt}),(0,f.jsxs)(gm.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)(gm.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)(vk,{size:l,orbColors:t})})]});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(gm.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 bk({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a,isMobile:o,isClosing:s}){let c=n||fk.green,l=mk(c);return(0,f.jsxs)(gm.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)(vk,{size:72,orbColors:t}),(0,f.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,textAlign:`center`,lineHeight:1.4},children:e.connectionTitle}),(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 xk({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,voiceId:i,siteId:a,apiBaseUrl:o,chatId:s,historyRef:c,onMessageSync:l,voiceEndCounter:u}){let[p,m]=(0,d.useState)(`idle`),[h,g]=(0,d.useState)(!1),[_,v]=(0,d.useState)(!1),y=(0,d.useRef)(null),b=(0,d.useRef)(``),x=(0,d.useRef)(async()=>{}),S=(0,d.useRef)(!1),ee=(0,d.useRef)(!1),te=(0,d.useRef)(!1),ne=(0,d.useRef)(!1),re=(0,d.useRef)(`minimized`),C=(0,d.useRef)(null),ie=(0,d.useRef)(null),ae=(0,d.useRef)(null),oe=(0,d.useRef)(0),se=(0,d.useRef)(!1),ce=(0,d.useRef)(`idle`),le=(0,d.useRef)(!1),ue=(0,d.useRef)(null),de=(0,d.useRef)(null),fe=(0,d.useRef)(!1),pe=(0,d.useCallback)((e=`minimized`)=>{re.current=e,ne.current=!0,queueMicrotask(()=>{S.current||(S.current=!0,x.current?.())})},[c]),me=(0,d.useCallback)(async e=>{ne.current=!0;try{lD()}catch{}if(a)try{w(a)}catch{}try{await y.current?.endSession?.()}catch{}let t=C.current,n=ie.current;if(t&&s&&o){let e=n?Math.round((Date.now()-n)/1e3):0;fetch(`${o}/api/voice/save-chat-recording`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({chatId:s,elevenLabsConversationId:t,duration:e,siteId:a})}).catch(e=>console.warn(`[FlowEngage] save-chat-recording failed:`,e.message))}if(C.current=null,ie.current=null,y.current=null,m(`idle`),g(!1),S.current=!1,br(),a)try{Ce(a)}catch{}typeof l==`function`&&await l(c.current),e?.()},[c,l,a,s,o]);return x.current=()=>me(re.current===`chat`?t:n),(0,d.useEffect)(()=>{ee.current=h},[h]),(0,d.useEffect)(()=>{u&&pe(`chat`)},[u]),(0,d.useEffect)(()=>{let e=!1,i=null,u=null,d=null;return(async()=>{if(!r){m(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;c.current=[],b.current=``,S.current=!1,te.current=!1,ne.current=!1,re.current=`minimized`,yr({onBeforeNavigate:()=>{if(a&&c.current.length>0)try{let e=aO(c.current);e&&xe(a,e)}catch{}if(!Wn()){let e=C.current,t=ie.current;if(e&&s&&o)try{let n=t?Math.round((Date.now()-t)/1e3):0,r=JSON.stringify({chatId:s,elevenLabsConversationId:e,duration:n,siteId:a}),i=`${o}/api/voice/save-chat-recording`;fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:r,keepalive:!0}).catch(()=>{}),C.current=null,ie.current=null}catch{}}Te()}});let t=dk(uk({siteId:a||null,apiBaseUrl:o||null,getLastUserVoiceText:()=>b.current,requestEndSession:()=>{se.current=!0}})),n=a?Se(a):null,l=!!n?.transcript,f=!!(a&&w(a)),p=typeof window<`u`?window.location.pathname:`/`,h=typeof document<`u`?document.title:``,_=p===`/`||p===``,v=null;try{let e=await fetch(`${o}/api/voice/signed-url?siteId=${encodeURIComponent(a||``)}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(e.ok)v=(await e.json()).signedUrl||null,v&&console.log(`[FlowEngage] ✅ Using signed ElevenLabs URL`);else if(e.status===429){let t=await e.json().catch(()=>({}));throw Error(t.message||`Too many voice sessions started. Please wait a minute before trying again.`)}else console.warn(`[FlowEngage] ⚠️ Signed URL fetch failed, falling back to agentId`)}catch(e){if(e.message&&e.message.includes(`Too many voice sessions`))throw e;console.warn(`[FlowEngage] ⚠️ Signed URL fetch error:`,e.message)}let x={clientTools:t,connectionType:`websocket`,...v?{signedUrl:v}:{agentId:r}},ae=(p.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),me=``;h&&h.includes(`|`)&&(me=h.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let he=me||ae||`this page`;v?f?(x.overrides={agent:{firstMessage:`I've navigated you to the ${he} page. Let me walk you through what's here.`}},console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${he}" (${p})`)):l?x.overrides={agent:{firstMessage:`I'm still here. Go ahead!`}}:_||(x.overrides={agent:{firstMessage:`Hi! I see you are currently on the ${he} page. Are you looking for something specific here?`}},console.log(`[FlowEngage] 🏠 Page-context override: "${he}" for ${p}`)):l&&(x.overrides={agent:{firstMessage:``}});let ge=!1,_e=f?`NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(a?Se(a):null)?.transcript||``}\n\n`:null,ve=await aD.startSession({...x,onConnect:({conversationId:e})=>{C.current=e,ie.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`){de.current&&=(clearTimeout(de.current),null),m(`speaking`),ce.current=`speaking`,le.current=!0,fe.current=!1,ue.current&&=(clearTimeout(ue.current),null);return}if(ce.current=`listening`,se.current){se.current=!1,pe();return}if(_e&&!ge){ge=!0;try{y.current?.sendUserMessage?.(`continue with the tour`)}catch{}}de.current&&clearTimeout(de.current),de.current=setTimeout(()=>{e||ce.current!==`speaking`&&(fe.current||(de.current=null,ce.current=`listening`,m(`listening`),le.current&&!ee.current&&(ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{if(!e&&ce.current===`listening`&&!ee.current)try{y.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{}},4e3))))},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`&&(b.current=r,fe.current=!0,de.current&&=(clearTimeout(de.current),null),ue.current&&=(clearTimeout(ue.current),null)),c.current=[...c.current,{sender:n,message:r,timestamp:new Date().toISOString()}],a)try{let e=aO(c.current);e&&xe(a,e)}catch{}if(_k(n,r)){pe(`minimized`);return}if(ee.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(oe.current+=1,oe.current===2)try{y.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 flowengage_end_session tool to end the voice session. Do NOT ask again after that.`)}catch{}else oe.current>=5&&pe(`minimized`)}},onError:t=>{if(!e&&!ne.current&&!te.current&&!Ae()){te.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{y.current?.setMicMuted?.(!0)}catch{}g(!0),m(`error`),pe(`chat`)}},onDisconnect:t=>{if(e||ne.current||te.current||Ae())return;let n=c.current?.length||0;console.warn(`[FlowEngageVoiceCall] session:disconnected`,{historyCount:n,reason:t?.reason,closeCode:t?.context?.code,closeReason:t?.context?.reason||t?.message,lastUserText:b.current||``,wasMuted:ee.current}),te.current=!0;try{y.current?.setMicMuted?.(!0)}catch{}g(!0),pe(`chat`)}});if(e){ve.endSession().catch(()=>{});return}i=ve,y.current=ve,m(`listening`);try{let e=typeof window<`u`?window.location.href:``,r=`[]`;try{r=await t.list_page_forms()}catch{}let i=l&&!f?`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`:``;ve.sendContextualUpdate(`${i}Page: ${e}. SiteId: ${a||`unknown`}. Forms: ${r}. 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(Rn()){t=n;return}t=n;let r=window.location.href,i=typeof document<`u`?document.title:``,a=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{y.current?.sendContextualUpdate?.(`PAGE CHANGED — visitor navigated manually. Current URL is now: ${r}. Page title: "${i}". Sections on this page: ${JSON.stringify(a)}. When the visitor asks about "this page", "current page", or "what page am I on", refer to this new URL — not any previously mentioned page.`)}catch{}};u=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{u(...e),setTimeout(n,50)},d=()=>setTimeout(n,50),window.addEventListener(`popstate`,d)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(m(`error`),re.current=`chat`,window.setTimeout(()=>{e||t?.()},0)))}})(),()=>{e=!0,ne.current=!0;try{lD()}catch{}if(a)try{w(a)}catch{}br(),ue.current&&=(clearTimeout(ue.current),null),de.current&&=(clearTimeout(de.current),null),le.current=!1,fe.current=!1,ce.current=`idle`,u&&typeof window<`u`&&(window.history.pushState=u),d&&typeof window<`u`&&window.removeEventListener(`popstate`,d);let t=i||y.current,n=C.current,r=ie.current;if(t?.endSession?.().catch(()=>{}),n&&s&&o){let e=r?Math.round((Date.now()-r)/1e3):0,t=JSON.stringify({chatId:s,elevenLabsConversationId:n,duration:e,siteId:a}),i=`${o}/api/voice/save-chat-recording`;typeof navigator<`u`&&navigator.sendBeacon&&navigator.sendBeacon(i,new Blob([t],{type:`application/json`}))||fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`},body:t,keepalive:!0}).catch(()=>{}),C.current=null,ie.current=null}typeof l==`function`&&c.current.length>0&&l(c.current).catch?.(()=>{})}},[r,a,o,pe]),(0,d.useEffect)(()=>{if(!_)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;ae.current&&!ae.current.contains(t)&&v(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[_]),(0,f.jsxs)(`div`,{ref:ae,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:[(0,f.jsxs)(`div`,{style:{position:`relative`},children:[p===`listening`&&!h&&(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:`Listening...`}),h&&(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)(vk,{size:72,voiceState:p,isMuted:h,orbColors:e})]}),p===`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:async()=>{if(y.current)try{if(h){oe.current=0,await y.current.setMicMuted?.(!1),g(!1);try{y.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{oe.current=0,await y.current.setMicMuted?.(!0),g(!0);try{y.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{}},title:h?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:h?`#7f1d1d`:`#1f2937`,border:h?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:h?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:h?(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)(uD,{size:16,color:`currentColor`})}),(0,f.jsx)(`button`,{onClick:()=>v(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)(vD,{size:16,color:`currentColor`})})]}),_&&(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:()=>{v(!1),re.current=`chat`,me(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)(yD,{}),`Enter Chat Mode`]}),(0,f.jsxs)(`button`,{onClick:()=>{v(!1),re.current=`minimized`,me(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)(bD,{}),`End Conversation`]}),(0,f.jsx)(`button`,{onClick:()=>v(!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 Sk({orbColors:e}){return(0,f.jsx)(`div`,{style:{flexShrink:0,width:`36px`,height:`36px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,f.jsx)(vk,{size:36,orbColors:e})})}var Ck=()=>(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 wk({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:ee,selectedFile:te,onFileSelect:ne,onRemoveSelectedFile:re,attachmentError:C,isUploadingAttachment:ie,requiresEmail:ae,emailInput:oe,setEmailInput:se,emailError:ce,emailCaptureSuccess:le,replyContext:ue,setReplyContext:de,webRTCError:fe,micError:pe,setMicError:me,dismissCallError:he,activeCallId:ge,isCallMuted:_e,toggleCallMute:ve,endWebRTCCall:ye,formatCallDuration:be,callDurationSeconds:xe,isCallMinimized:Se,onExpand:Ce,onCollapse:we,onStartVoice:Te,onNewChat:Ee,onEndConversation:De,showPoweredBy:Oe,getVisitorChatHistory:ke,getVisitorChatThread:Ae,resumeChat:je,isSessionRestoring:Me,isClosing:w}){let Ne=c.length>0,Pe=x||S||b,Fe=!!ge,[Ie,Le]=(0,d.useState)(!1),[Re,ze]=(0,d.useState)(!1),[Be,Ve]=(0,d.useState)([]),[He,Ue]=(0,d.useState)(!1),[We,Ge]=(0,d.useState)(null),[Ke,qe]=(0,d.useState)([]),Je=(0,d.useRef)(null),Ye=async()=>{Le(!1),ze(!0),Ue(!0),Ge(null);try{let e=await ke();e?.data&&Ve(e.data)}catch(e){console.error(e)}finally{Ue(!1)}},Xe=async e=>{ze(!1),je?.(e.chatId)};return(0,d.useEffect)(()=>{if(!Ie)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Je.current&&!Je.current.contains(t)&&Le(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Ie]),(0,f.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`8px`,right:`8px`,bottom:0,width:`calc(100% - 16px)`,height:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:w?`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:w?`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:`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:we,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`})})})}),(0,f.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:`minmax(72px, 40%) minmax(0, 60%)`,alignItems:`center`},children:[(0,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,f.jsx)(hk,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,f.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,f.jsx)(gk,{title:e.chatTitle})})}),(0,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`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:Je,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>Le(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`})]})}),Ie&&(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:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{Le(!1),Te?.()},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:()=>{Le(!1),Ee?.()},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`]}),ke&&(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: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.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:()=>{Le(!1),we?.()},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)(VD,{webRTCError:fe,micError:pe,setMicError:me,dismissCallError:he,isRateLimited:S,rateLimitMessage:ee}),Se&&(0,f.jsx)(iO,{agentName:m,agentHeadshot:h,fallbackAgentName:g,callDurationSeconds:xe,isCallMuted:_e,formatCallDuration:be,toggleCallMute:ve,endWebRTCCall:ye,onExpand:Ce,primaryColor:n}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[Re?(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:We?(0,f.jsxs)(`button`,{onClick:()=>Ge(null),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:`Back to List`})]}):(0,f.jsxs)(`button`,{onClick:()=>ze(!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:He&&!We?(0,f.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):We?(0,f.jsxs)(`div`,{style:{padding:`20px 16px`},children:[Ke.length===0?(0,f.jsx)(`div`,{style:{color:`#9ca3af`,textAlign:`center`,marginTop:`20px`,fontSize:`14px`},children:`No messages`}):null,Ke.map((e,t)=>(0,f.jsx)(`div`,{style:{marginBottom:`16px`,display:`flex`,justifyContent:e.sender===`user`?`flex-end`:`flex-start`},children:(0,f.jsx)(`div`,{style:{maxWidth:`85%`,background:e.sender===`user`?n:`#f3f4f6`,color:e.sender===`user`?`white`:`#111827`,padding:`10px 14px`,borderRadius:`14px`,fontSize:`15px`,lineHeight:1.4,wordBreak:`break-word`},children:e.content})},e._id||t))]}):Be.length>0?(0,f.jsx)(`div`,{children:Be.map(e=>(0,f.jsxs)(`div`,{onClick:()=>Xe(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,Ne?(0,f.jsx)(zD,{chatHistory:c,isAiTyping:l,isLoading:x,isAgentTyping:u,setReplyContext:de,TypingDots:Ck,primaryColor:n,agentHeadshot:h,agentDisplayName:m||g,botAvatarNode:(0,f.jsx)(Sk,{orbColors:t})}):Me?(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)(vk,{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))})]})]}),le&&(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:ae?`6px 0 0`:`12px 0 0`},children:(0,f.jsx)(BD,{input:_,setInput:v,onSubmit:y,isConversationEnded:b,callUiActive:Fe,handleToggleVoice:Te,showVoiceToggle:p===`agent`,activeScreen:p,inputDisabled:Pe,replyContext:ue,clearReplyContext:()=>de(null),onFileSelect:ne,selectedFile:te,onRemoveSelectedFile:re,attachmentError:C,isUploadingAttachment:ie,requiresEmail:ae,emailInput:oe,setEmailInput:se,emailError:ce,inputPlaceholder:e.inputPlaceholder})}),(0,f.jsx)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`12px 20px 18px`,pointerEvents:`none`},children:Oe&&(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 Tk(){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:ee,language:te,chatId:ne,historyRef:re,onMessageSync:ae,sendMessage:oe,uploadChatFile:se,openWidget:ce,captureVisitorEmail:le,setVoiceMode:ue,endConversation:de,startNewChat:fe,acceptCall:pe,rejectCall:me,endWebRTCCall:he,toggleCallMute:ge,dismissCallError:_e,startTyping:ve,stopTyping:ye,updateTypingDraft:be,getVisitorChatHistory:xe,getVisitorChatThread:we,resumeChat:Te,isSessionRestoring:De,openToChatCounter:Oe,voiceEndCounter:Ae}=On();(0,d.useEffect)(()=>{try{rr()}catch{}},[]),(0,d.useEffect)(()=>{Oe&&T!==`text_chat`&&T!==`call_screen`&&(ue?.(!1),E(`text_chat`))},[Oe]);let je=t?.widgetSettings||{},Me=n?.widgetSettings||{},w={...je.branding||{},...Me.branding||{}},Ne={...je.theme||{},...Me.theme||{}},Pe={...je.features||{},...Me.features||{}},Fe=Pe.voice!==!1,Ie=Array.isArray(Ne.orbColors)&&Ne.orbColors.length>0?Ne.orbColors:null,Le=Ne.buttonColor||Ne.primaryColor||Ie?.[0]||`#3B82F6`,Re=Ne.position||`bottom-right`,ze=w.fallbackAgentName||`Agent`,Be=pk(Ie??Ne.chatBgColors),Ve=w.logo||w.logoUrl||null,He=te||`en`,Ue=je.recommendations?.[He]||[],We=(Me.recommendations?.[He]??Ue).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Ge=Array.isArray(w.quickChatOptions)&&w.quickChatOptions.length>0?w.quickChatOptions:We,Ke=w.hideWatermark===!0?!1:w.showPoweredBy!==!1,qe=w.chatbotEnabled!==!1&&Ne.chatbotEnabled!==!1,Je=je.greetings?.[te]||Me.greetings?.[te]||w.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,Ye={entryPrompt:w.entryPrompt||`Do you want to explore in a new way?`,yesLabel:w.yesLabel||`Yes`,laterLabel:w.laterLabel||`Later`,connectionTitle:w.connectionTitle||`How would you like to connect?`,voiceLabel:w.voiceLabel||`Voice`,textLabel:w.textLabel||`Text`,chatTitle:w.headerName||`Chat with FlowEngage`,introGreeting:Je,inputPlaceholder:w.inputPlaceholder||`Type your message`,analysingLabel:w.analysingLabel||`analysing...`},Xe=Me.elevenLabsAgentId||t?.elevenLabsAgentId||null,Ze=Me.elevenLabsVoiceId||t?.elevenLabsVoiceId||null,Qe=t?.siteId||n?.siteId||null,$e=t?.apiBaseUrl||``,et=(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]),tt=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,nt=r.some(e=>e.sender===`user`),rt=(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]),it=!l&&nt&&rt,at=!!(Me._dashboardLivePreview||je._dashboardLivePreview),[T,E]=(0,d.useState)(()=>at?`text_chat`:`entry_prompt`),[ot,st]=(0,d.useState)(``),[D,ct]=(0,d.useState)(null),[lt,ut]=(0,d.useState)(l||``),[dt,ft]=(0,d.useState)(``),[pt,mt]=(0,d.useState)(!1),[ht,gt]=(0,d.useState)(0),[_t,vt]=(0,d.useState)(null),[yt,bt]=(0,d.useState)(null),[xt,St]=(0,d.useState)(``),[Ct,wt]=(0,d.useState)(!1),[Tt,Et]=(0,d.useState)(!1),[Dt,Ot]=(0,d.useState)(!1),kt=(0,d.useRef)(null),At=(0,d.useRef)(!1);(0,d.useLayoutEffect)(()=>{if(e!==`ready`||At.current)return;if(At.current=!0,!Fe){E(`minimized_orb`);return}let t=!1;try{t=hr().shouldResumeVoice}catch{}let n=Ee(),r=Qe?Se(Qe):null,i=n||!!r?.transcript;if(t){ce?.({notifyChatInitiated:!0}),ue?.(!0),E(`voice_mode`);return}if(ke()){ce?.({notifyChatInitiated:!1}),E(`text_chat`);return}if(Qe)try{Ce(Qe)}catch{}if(i){E(`minimized_orb`);return}if(C(Qe)){E(`minimized_orb`);return}},[e,r]);let[jt,Mt]=(0,d.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,d.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>Mt(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,d.useEffect)(()=>{ut(l||``),l&&ft(``)},[l]);let Nt=(0,d.useCallback)(()=>{bt(null),St(``)},[]),Pt=(0,d.useCallback)(e=>{let t=PD(e);if(t){bt(null),St(t);return}bt(e),St(``)},[]);(0,d.useEffect)(()=>{if(!x||b!==`connected`){gt(0);return}let e=()=>{let e=new Date(x).getTime();isNaN(e)||gt(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[x,b]);let Ft=(0,d.useCallback)(()=>{E(`call_screen`),Et(!1)},[]),It=(0,d.useCallback)(()=>{E(`text_chat`),Et(!0)},[]);(0,d.useEffect)(()=>{let e=v?.callId||y||null;if(!e){kt.current=null;return}if(v?.callId||b===`connecting`||b===`connected`){if(T===`minimized_orb`&&Tt&&y&&!v?.callId){kt.current=e;return}!(!i||T===`minimized_orb`||T===`voice_mode`)&&kt.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:T,hasIncomingCall:!!v?.callId,activeCallId:y,callConnectionState:b}),kt.current=e,T===`voice_mode`&&ue?.(!1),ce?.(),Ft())}},[y,b,Ft,v?.callId,i,ce,ue,T]),(0,d.useEffect)(()=>{!v&&!y&&T===`call_screen`&&E(`text_chat`)},[v,y,T]),(0,d.useEffect)(()=>{!y&&Tt&&Et(!1)},[y,Tt]),(0,d.useEffect)(()=>{if(!o||_){be?.(``),ye?.();return}if(!ot.trim()||yt){be?.(``);let e=window.setTimeout(()=>ye?.(),100);return()=>window.clearTimeout(e)}ve?.();let e=window.setTimeout(()=>be?.(ot),120),t=window.setTimeout(()=>ye?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[ot,yt,o,_,ve,ye,be]);let Lt=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,Rt=async e=>{if(e.preventDefault(),_)return;if(it){let e=lt.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){ft(`Please enter a valid email so we can continue helping you.`);return}await le(e),ft(``),mt(!0),setTimeout(()=>mt(!1),3e3);return}let t=Lt(D);if(!ot.trim()&&!yt)return;if(yt){try{wt(!0),St(``);let e=await se(yt),n=e?.data||e,r=ot.trim()||`Shared file: ${ID(yt)}`;st(``),ct(null),Nt(),await oe(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||yt.name,fileType:n?.fileType||yt.type,fileSize:n?.fileSize||yt.size}})}catch(e){St(e?.message||`Failed to upload the selected file.`)}finally{wt(!1)}return}let n=ot.trim();st(``),ct(null),await oe(n,``,t)},zt=(0,d.useCallback)(()=>{r.length!==0&&fe?.()},[r.length,fe]),Bt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},Vt=(0,d.useCallback)(async e=>{if(_||m)return;let t=e.message||e.label||e.text||``;t.trim()&&await oe(t.trim(),``)},[_,m,oe]),Ht=jt&&T===`entry_prompt`?{inset:0}:jt&&T===`text_chat`?{left:0,right:0,bottom:0}:jt&&T===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:jt&&T===`connection_modal`?{left:`28px`,right:`12px`,bottom:`12px`}:T===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...Re===`bottom-left`?{left:`1.5rem`,bottom:`1.5rem`}:{right:`1.5rem`,bottom:`1.5rem`}}:Re===`bottom-left`?{left:`1.5rem`,bottom:`1.5rem`}:{right:`1.5rem`,bottom:`1.5rem`},Ut=(0,d.useCallback)(()=>{T!==`minimized_orb`&&(Ot(!0),setTimeout(()=>{E(`minimized_orb`),Ot(!1)},280))},[T]),Wt=()=>E(`connection_modal`),Gt=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}ce({notifyChatInitiated:!0}),ue?.(!0),E(`voice_mode`)},Kt=()=>{ce({notifyChatInitiated:!0}),ue?.(!1),E(`text_chat`)},qt=()=>{ue?.(!1),Ut()};return e!==`ready`||!qe||Pe.chat===!1?null:(0,f.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...Ht},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[T===`entry_prompt`&&(0,f.jsx)(yk,{copy:Ye,orbColors:Ie,primaryColor:Le,onYes:()=>{ie(Qe),Gt()},onLater:()=>{ie(Qe),Ut()},isMobile:jt,isClosing:Dt}),T===`minimized_orb`&&(0,f.jsxs)(gm.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:Re===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[y&&Tt&&(0,f.jsxs)(`button`,{type:`button`,onClick:Ft,style:{maxWidth:jt?`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`?`${Bt(ht)} with ${et}`:`Tap to return to ${et}`})]})]}),(0,f.jsx)(vk,{size:50,orbColors:Ie,onClick:y&&Tt?Ft:Fe?Wt:Kt})]}),T===`connection_modal`&&(0,f.jsx)(bk,{copy:Ye,orbColors:Ie,primaryColor:Le,onVoice:Gt,onText:Kt,onClose:Ut,isMobile:jt,isClosing:Dt}),T===`voice_mode`&&(0,f.jsx)(xk,{orbColors:Ie,onEnterChat:Kt,onEndChat:qt,agentId:Xe,voiceId:Ze,siteId:Qe,apiBaseUrl:$e,chatId:ne,historyRef:re,onMessageSync:ae,voiceEndCounter:Ae},`voice`),T===`call_screen`&&(0,f.jsx)(rO,{incomingCall:v,activeCallId:y,callConnectionState:b,callDurationSeconds:ht,isCallMuted:S,agentName:et,agentHeadshot:tt,fallbackAgentName:ze,acceptCall:pe,rejectCall:me,endWebRTCCall:he,toggleCallMute:ge,formatCallDuration:Bt,onMinimize:It,primaryColor:Le,orbColors:Ie,chatHistory:r}),T===`text_chat`&&(0,f.jsx)(wk,{isClosing:Dt,copy:Ye,orbColors:Ie,primaryColor:Le,chatBgGradient:Be,logo:Ve,quickChatOptions:Ge,onQuickChatSelect:Vt,isMobile:jt,chatHistory:r,isAiTyping:p,isAgentTyping:u,activeScreen:a,agentName:et,agentHeadshot:tt,fallbackAgentName:ze,input:ot,setInput:st,onSubmit:Rt,isConversationEnded:_,isLoading:m,isRateLimited:h,rateLimitMessage:g,selectedFile:yt,onFileSelect:Pt,onRemoveSelectedFile:Nt,attachmentError:xt,isUploadingAttachment:Ct,requiresEmail:it,emailInput:lt,setEmailInput:ut,emailError:dt,emailCaptureSuccess:pt,replyContext:D,setReplyContext:ct,webRTCError:ee,micError:_t,setMicError:vt,dismissCallError:_e,activeCallId:y,isCallMuted:S,toggleCallMute:ge,endWebRTCCall:he,formatCallDuration:Bt,callDurationSeconds:ht,onCollapse:Ut,onStartVoice:Gt,onNewChat:zt,onEndConversation:de,onMinimize:It,onExpand:Ft,isCallMinimized:Tt&&!!y,showPoweredBy:Ke,getVisitorChatHistory:xe,getVisitorChatThread:we,resumeChat:Te,isSessionRestoring:De}),(0,f.jsx)(`style`,{children:`
|
|
635
|
+
`;function mk(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 hk(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 gk(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 _k({headshot:e,name:t,size:n=80,primaryColor:r=`#3B82F6`}){let i=(t||`A`)[0].toUpperCase(),a=hk(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 vk(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 yk({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=vk(!!e),x=async()=>{b(),await c()},S=async()=>{b(),await l()},ee=i?`muted`:n===`connecting`?`idle`:`listening`,te=y===`ongoing`,ne={position:`absolute`,inset:0,zIndex:10,display:`flex`,flexDirection:`column`,borderRadius:`inherit`,overflow:`hidden`,background:gk(g,h),animation:te?`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:ne,children:[(0,f.jsx)(`style`,{children:pk}),(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(${mk(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)(_k,{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)(DO,{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)(AO,{})}),(0,f.jsx)(`span`,{style:{fontSize:`12px`,color:`#6b7280`,fontWeight:500,letterSpacing:`0.01em`},children:`Accept`})]})]})]})]})}return y===`connecting`?(0,f.jsxs)(`div`,{style:ne,children:[(0,f.jsx)(`style`,{children:pk}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`24px`},children:[(0,f.jsx)(_k,{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:ne,children:[(0,f.jsx)(`style`,{children:pk}),(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)(fk,{colors:g,size:36,voiceState:ee}),(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)(_k,{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)(LO,{size:18}):(0,f.jsx)(EO,{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)(DO,{size:18}),`End Call`]})]})]})}function bk({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:pk}),(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)(_k,{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)(LO,{size:15}):(0,f.jsx)(EO,{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)(DO,{size:16})})]})]})]})}function xk(e){return!e||typeof e!=`object`?e:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,async n=>{let r=On();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 Sk={blue:`#135bd8`,red:`#ef334b`,yellow:`#ffbd2e`,dark:`#0d1b2a`,highlight:`rgba(255,255,255,0.9)`,green:`#10b981`};function Ck(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 wk(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 Tk({logo:e,style:t}){if(!e)return null;if(typeof e==`string`)return(0,f.jsx)(`img`,{src:e,alt:``,style:{objectFit:`contain`,flexShrink:0,display:`block`,...t}});let n=typeof e==`function`?d.default.createElement(e):d.default.isValidElement(e)?e:null;return n?(0,f.jsx)(`span`,{className:`fe-logo-slot`,style:{display:`inline-flex`,alignItems:`center`,flexShrink:0,overflow:`hidden`,...t},children:n}):null}function Ek({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 Dk(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)||/\b(that'?s all|we'?re done)\b/i.test(n)||e===`bot`&&(/\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))||/^(goodbye|bye|that'?s all|we'?re done|hang up|disconnect)\b/i.test(n)):!1}function Ok({orbColors:e,...t}){return(0,f.jsx)(fk,{colors:e,...t})}function kk({copy:e,orbColors:t,primaryColor:n,onYes:r,onLater:i,isMobile:a,isClosing:o}){let s=n||Sk.green,c=wk(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)(gm.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:a?void 0:`210px`},children:e.entryPrompt}),(0,f.jsxs)(gm.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)(gm.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)(Ok,{size:l,orbColors:t})})]});return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(gm.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 Ak({copy:e,orbColors:t,primaryColor:n,onVoice:r,onText:i,onClose:a,isMobile:o,isClosing:s}){let c=n||Sk.green,l=wk(c);return(0,f.jsxs)(gm.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)(Ok,{size:72,orbColors:t}),(0,f.jsx)(`p`,{style:{margin:0,fontSize:`16px`,fontWeight:400,color:`#111827`,textAlign:`center`,lineHeight:1.4},children:e.connectionTitle}),(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 jk({orbColors:e,onEnterChat:t,onEndChat:n,agentId:r,siteId:i,apiBaseUrl:a,chatId:o,historyRef:s,onMessageSync:c,voiceEndCounter:l}){let[u,p]=(0,d.useState)(`idle`),[m,h]=(0,d.useState)(!1),[g,_]=(0,d.useState)(!1),v=(0,d.useRef)(null),y=(0,d.useRef)(``),b=(0,d.useRef)(async()=>{}),x=(0,d.useRef)(!1),S=(0,d.useRef)(!1),ee=(0,d.useRef)(!1),te=(0,d.useRef)(!1),ne=(0,d.useRef)(`minimized`),re=(0,d.useRef)(null),C=(0,d.useRef)(null),ie=(0,d.useRef)(null),ae=(0,d.useRef)(0),oe=(0,d.useRef)(!1),se=(0,d.useRef)(`idle`),ce=(0,d.useRef)(!1),le=(0,d.useRef)(null),ue=(0,d.useRef)(null),de=(0,d.useRef)(!1),fe=(0,d.useRef)([]),pe=(0,d.useRef)(``),me=(0,d.useRef)([]),he=(0,d.useCallback)((e=`minimized`)=>{ne.current=e,te.current=!0,queueMicrotask(()=>{x.current||(x.current=!0,b.current?.())})},[s]),ge=(0,d.useCallback)(async e=>{te.current=!0;try{lD()}catch{}if(TO(me.current),me.current=[],fe.current=[],pe.current=``,i)try{Ne(i)}catch{}try{await v.current?.endSession?.()}catch{}let t=re.current,n=C.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(re.current=null,C.current=null,v.current=null,p(`idle`),h(!1),x.current=!1,yr(),i)try{Ce(i)}catch{}typeof c==`function`&&await c(s.current),e?.()},[s,c,i,o,a]);return b.current=()=>ge(ne.current===`chat`?t:n),(0,d.useEffect)(()=>{S.current=m},[m]),(0,d.useEffect)(()=>{l&&he(`chat`)},[l]),(0,d.useEffect)(()=>{let e=!1,l=null,u=null,d=null;return(async()=>{if(!r){p(`error`);return}try{if((await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop()),e)return;s.current=[],y.current=``,x.current=!1,ee.current=!1,te.current=!1,ne.current=`minimized`,vr({onBeforeNavigate:()=>{if(i&&s.current.length>0)try{let e=uD(s.current);e&&xe(i,e)}catch{}if(!Un()){let e=re.current,t=C.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(()=>{}),re.current=null,C.current=null}catch{}}Te()}});let t=xk(hO({siteId:i||null,apiBaseUrl:a||null,getLastUserVoiceText:()=>y.current,requestEndSession:()=>{oe.current=!0},onHighlightQueued:e=>{fe.current.push(e)}})),n=i?Se(i):null,c=!!n?.transcript,f=!!(i&&Ne(i)),m=typeof window<`u`?window.location.pathname:`/`,g=typeof document<`u`?document.title:``,_=m===`/`||m===``,b=null;try{let e=await fetch(`${a}/api/voice/signed-url?siteId=${encodeURIComponent(i||``)}`,{method:`GET`,headers:{"Content-Type":`application/json`}});if(e.ok)b=(await e.json()).signedUrl||null,b&&console.log(`[FlowEngage] ✅ Using signed ElevenLabs URL`);else if(e.status===429){let t=await e.json().catch(()=>({}));throw Error(t.message||`Too many voice sessions started. Please wait a minute before trying again.`)}else console.warn(`[FlowEngage] ⚠️ Signed URL fetch failed, falling back to agentId`)}catch(e){if(e.message&&e.message.includes(`Too many voice sessions`))throw e;console.warn(`[FlowEngage] ⚠️ Signed URL fetch error:`,e.message)}let ie={clientTools:t,connectionType:`websocket`,...b?{signedUrl:b}:{agentId:r}},ge=(m.split(`/`).filter(Boolean).pop()||``).replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase()),_e=``;g&&g.includes(`|`)&&(_e=g.split(`|`).map(e=>e.trim()).filter(Boolean).reduce((e,t)=>e.length<=t.length?e:t));let ve=_e||ge||`this page`;b?f?(ie.overrides={agent:{firstMessage:`I've navigated you to the ${ve} page. Let me walk you through what's here.`}},console.log(`[FlowEngage] 🔄 Agent-nav resume: firstMessage set for "${ve}" (${m})`)):c?ie.overrides={agent:{firstMessage:`I'm still here. Go ahead!`}}:_||(ie.overrides={agent:{firstMessage:`Hi! I see you are currently on the ${ve} page. Are you looking for something specific here?`}},console.log(`[FlowEngage] 🏠 Page-context override: "${ve}" for ${m}`)):c&&(ie.overrides={agent:{firstMessage:``}});let ye=!1,be=f?`NAVIGATION RESUME — Your intro has been spoken. NOW — without waiting for the visitor to say anything — call flowengage_highlight for the first content section on this page, then speak one sentence about it. Continue section by section (highlight + one sentence each) until you have covered the key content. Prior conversation context:\n${(i?Se(i):null)?.transcript||``}\n\n`:null,Ce=await aD.startSession({...ie,onConnect:({conversationId:e})=>{re.current=e,C.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`){if(ue.current&&=(clearTimeout(ue.current),null),p(`speaking`),se.current=`speaking`,ce.current=!0,de.current=!1,le.current&&=(clearTimeout(le.current),null),fe.current.length>0){TO(me.current);let e=fe.current;fe.current=[],me.current=wO(e,pe.current)}return}if(se.current=`listening`,oe.current){oe.current=!1,he();return}if(be&&!ye){ye=!0;try{v.current?.sendUserMessage?.(`continue with the tour`)}catch{}}ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{e||se.current!==`speaking`&&(de.current||(ue.current=null,se.current=`listening`,p(`listening`),ce.current&&!S.current&&(le.current&&clearTimeout(le.current),le.current=setTimeout(()=>{if(!e&&se.current===`listening`&&!S.current)try{v.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{}},4e3))))},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`?(y.current=r,de.current=!0,ue.current&&=(clearTimeout(ue.current),null),le.current&&=(clearTimeout(le.current),null),TO(me.current),me.current=[],fe.current=[],pe.current=``):pe.current=r,s.current=[...s.current,{sender:n,message:r,timestamp:new Date().toISOString()}],i)try{let e=uD(s.current);e&&xe(i,e)}catch{}if(Dk(n,r)){he(`minimized`);return}if(S.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(ae.current+=1,ae.current===2)try{v.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 flowengage_end_session tool to end the voice session. Do NOT ask again after that.`)}catch{}else ae.current>=5&&he(`minimized`)}},onError:t=>{if(!e&&!te.current&&!ee.current&&!Ae()){ee.current=!0,console.error(`[FlowEngageVoiceCall] session:error`,{message:t?.message,name:t?.name,raw:t});try{v.current?.setMicMuted?.(!0)}catch{}h(!0),p(`error`),he(`chat`)}},onDisconnect:t=>{if(e||te.current||ee.current||Ae())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:y.current||``,wasMuted:S.current}),ee.current=!0;try{v.current?.setMicMuted?.(!0)}catch{}h(!0),he(`chat`)}});if(e){Ce.endSession().catch(()=>{});return}l=Ce,v.current=Ce,p(`listening`);try{let e=typeof window<`u`?window.location.href:``,r=`[]`;try{r=await t.list_page_forms()}catch{}let a=c&&!f?`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`:``;Ce.sendContextualUpdate(`${a}Page: ${e}. SiteId: ${i||`unknown`}. Forms: ${r}. 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(Ln()){t=n;return}t=n;let r=window.location.href,i=typeof document<`u`?document.title:``,a=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{v.current?.sendContextualUpdate?.(`PAGE CHANGED — visitor navigated manually. Current URL is now: ${r}. Page title: "${i}". Sections on this page: ${JSON.stringify(a)}. When the visitor asks about "this page", "current page", or "what page am I on", refer to this new URL — not any previously mentioned page.`)}catch{}};u=window.history.pushState.bind(window.history),window.history.pushState=(...e)=>{u(...e),setTimeout(n,50)},d=()=>setTimeout(n,50),window.addEventListener(`popstate`,d)}}catch(r){e||(console.error(`[FlowEngage] startSession failed`,r),r.message&&r.message.includes(`Too many voice sessions`)?(alert(r.message),n&&n(`minimized`)):(p(`error`),ne.current=`chat`,window.setTimeout(()=>{e||t?.()},0)))}})(),()=>{e=!0,te.current=!0;try{lD()}catch{}if(i)try{Ne(i)}catch{}yr(),le.current&&=(clearTimeout(le.current),null),ue.current&&=(clearTimeout(ue.current),null),ce.current=!1,de.current=!1,se.current=`idle`,u&&typeof window<`u`&&(window.history.pushState=u),d&&typeof window<`u`&&window.removeEventListener(`popstate`,d);let t=l||v.current,n=re.current,r=C.current;if(t?.endSession?.().catch(()=>{}),n&&o&&a){let e=r?Math.round((Date.now()-r)/1e3):0,t=JSON.stringify({chatId:o,elevenLabsConversationId:n,duration:e,siteId:i}),s=`${a}/api/voice/save-chat-recording`;typeof navigator<`u`&&navigator.sendBeacon&&navigator.sendBeacon(s,new Blob([t],{type:`application/json`}))||fetch(s,{method:`POST`,headers:{"Content-Type":`application/json`},body:t,keepalive:!0}).catch(()=>{}),re.current=null,C.current=null}typeof c==`function`&&s.current.length>0&&c(s.current).catch?.(()=>{})}},[r,i,a,he]),(0,d.useEffect)(()=>{if(!g)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;ie.current&&!ie.current.contains(t)&&_(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[g]),(0,f.jsxs)(`div`,{ref:ie,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:[(0,f.jsxs)(`div`,{style:{position:`relative`},children:[u===`listening`&&!m&&(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:`Listening...`}),m&&(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)(Ok,{size:72,voiceState:u,isMuted:m,orbColors:e})]}),u===`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:async()=>{if(v.current)try{if(m){ae.current=0,await v.current.setMicMuted?.(!1),h(!1);try{v.current.sendContextualUpdate?.(`The visitor has unmuted. Resume normal interaction and wait for them to speak.`)}catch{}}else{ae.current=0,await v.current.setMicMuted?.(!0),h(!0);try{v.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{}},title:m?`Unmute`:`Mute`,style:{width:`24px`,height:`24px`,borderRadius:`50%`,background:m?`#7f1d1d`:`#1f2937`,border:m?`1.5px solid #ef4444`:`1.5px solid #4b5563`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`,color:m?`#f87171`:`white`,transition:`all 0.2s ease`,boxShadow:`0 2px 8px rgba(0,0,0,0.4)`,padding:0,flexShrink:0},children:m?(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)(EO,{size:16,color:`currentColor`})}),(0,f.jsx)(`button`,{onClick:()=>_(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)(PO,{size:16,color:`currentColor`})})]}),g&&(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:()=>{_(!1),ne.current=`chat`,ge(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)(FO,{}),`Enter Chat Mode`]}),(0,f.jsxs)(`button`,{onClick:()=>{_(!1),ne.current=`minimized`,ge(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)(IO,{}),`End Conversation`]}),(0,f.jsx)(`button`,{onClick:()=>_(!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 Mk({orbColors:e}){return(0,f.jsx)(`div`,{style:{flexShrink:0,width:`36px`,height:`36px`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,f.jsx)(Ok,{size:36,orbColors:e})})}var Nk=()=>(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 Pk({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:ee,selectedFile:te,onFileSelect:ne,onRemoveSelectedFile:re,attachmentError:C,isUploadingAttachment:ie,requiresEmail:ae,emailInput:oe,setEmailInput:se,emailError:ce,emailCaptureSuccess:le,replyContext:ue,setReplyContext:de,webRTCError:fe,micError:pe,setMicError:me,dismissCallError:he,activeCallId:ge,isCallMuted:_e,toggleCallMute:ve,endWebRTCCall:ye,formatCallDuration:be,callDurationSeconds:xe,isCallMinimized:Se,onExpand:Ce,onCollapse:we,onStartVoice:Te,onNewChat:Ee,showPoweredBy:De,getVisitorChatHistory:Oe,resumeChat:ke,isSessionRestoring:Ae,isClosing:je}){let Me=c.length>0,Ne=x||S||b,Pe=!!ge,[Fe,Ie]=(0,d.useState)(!1),[Le,Re]=(0,d.useState)(!1),[ze,Be]=(0,d.useState)([]),[Ve,He]=(0,d.useState)(!1),Ue=(0,d.useRef)(null),We=async()=>{Ie(!1),Re(!0),He(!0);try{let e=await Oe();e?.data&&Be(e.data)}catch(e){console.error(e)}finally{He(!1)}},Ge=async e=>{Re(!1),ke?.(e.chatId)};return(0,d.useEffect)(()=>{if(!Fe)return;let e=e=>{let t=e.composedPath?.()?.[0]||e.target;Ue.current&&!Ue.current.contains(t)&&Ie(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Fe]),(0,f.jsxs)(`div`,{style:s?{"--flowengage-primary":n,"--flowengage-accent":n,position:`fixed`,left:`8px`,right:`8px`,bottom:0,width:`calc(100% - 16px)`,height:`90dvh`,background:r,borderRadius:`16px 16px 0 0`,display:`flex`,flexDirection:`column`,overflow:`hidden`,animation:je?`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:je?`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:`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:we,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`})})})}),(0,f.jsxs)(`div`,{style:{minWidth:0,maxWidth:s?`100%`:`250px`,width:`100%`,justifySelf:`center`,display:`grid`,gridTemplateColumns:`minmax(72px, 40%) minmax(0, 60%)`,alignItems:`center`},children:[(0,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`center`,justifyContent:`center`,height:`40px`},children:i?(0,f.jsx)(Tk,{logo:i,style:{height:`34px`,width:`100%`,maxWidth:`96px`}}):(0,f.jsx)(`div`,{style:{width:`40px`,height:`40px`,flexShrink:0},children:(0,f.jsx)(Ek,{title:e.chatTitle})})}),(0,f.jsx)(`div`,{style:{minWidth:0,display:`flex`,alignItems:`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:Ue,children:[(0,f.jsx)(`button`,{type:`button`,onClick:()=>Ie(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`})]})}),Fe&&(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:[(0,f.jsxs)(`button`,{type:`button`,onClick:()=>{Ie(!1),Te?.()},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:()=>{Ie(!1),Ee?.()},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`]}),Oe&&(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:We,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:()=>{Ie(!1),we?.()},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)(rk,{webRTCError:fe,micError:pe,setMicError:me,dismissCallError:he,isRateLimited:S,rateLimitMessage:ee}),Se&&(0,f.jsx)(bk,{agentName:m,agentHeadshot:h,fallbackAgentName:g,callDurationSeconds:xe,isCallMuted:_e,formatCallDuration:be,toggleCallMute:ve,endWebRTCCall:ye,onExpand:Ce,primaryColor:n}),(0,f.jsxs)(`div`,{style:{flex:1,display:`flex`,flexDirection:`column`,minHeight:0,background:`transparent`,position:`relative`},children:[Le?(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:()=>Re(!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:Ve?(0,f.jsx)(`div`,{style:{padding:`40px 20px`,textAlign:`center`,color:`#6b7280`,fontSize:`14px`},children:`Loading past conversations...`}):ze.length>0?(0,f.jsx)(`div`,{children:ze.map(e=>(0,f.jsxs)(`div`,{onClick:()=>Ge(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,Me?(0,f.jsx)(tk,{chatHistory:c,isAiTyping:l,isLoading:x,isAgentTyping:u,setReplyContext:de,TypingDots:Nk,primaryColor:n,agentHeadshot:h,agentDisplayName:m||g,botAvatarNode:(0,f.jsx)(Mk,{orbColors:t})}):Ae?(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)(Ok,{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))})]})]}),le&&(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:ae?`6px 0 0`:`12px 0 0`},children:(0,f.jsx)(nk,{input:_,setInput:v,onSubmit:y,isConversationEnded:b,callUiActive:Pe,handleToggleVoice:Te,showVoiceToggle:p===`agent`,activeScreen:p,inputDisabled:Ne,replyContext:ue,clearReplyContext:()=>de(null),onFileSelect:ne,selectedFile:te,onRemoveSelectedFile:re,attachmentError:C,isUploadingAttachment:ie,requiresEmail:ae,emailInput:oe,setEmailInput:se,emailError:ce,inputPlaceholder:e.inputPlaceholder})}),(0,f.jsx)(`div`,{style:{flexShrink:0,textAlign:`center`,padding:`12px 20px 18px`,pointerEvents:`none`},children:De&&(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 Fk(){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:ee,language:te,chatId:ne,historyRef:re,onMessageSync:ae,sendMessage:oe,uploadChatFile:se,openWidget:ce,captureVisitorEmail:le,setVoiceMode:ue,endConversation:de,startNewChat:fe,acceptCall:pe,rejectCall:me,endWebRTCCall:he,toggleCallMute:ge,dismissCallError:_e,startTyping:ve,stopTyping:ye,updateTypingDraft:be,getVisitorChatHistory:xe,resumeChat:we,isSessionRestoring:Te,openToChatCounter:De,voiceEndCounter:Oe}=Dn();(0,d.useEffect)(()=>{try{nr()}catch{}},[]),(0,d.useEffect)(()=>{De&&T!==`text_chat`&&T!==`call_screen`&&(ue?.(!1),E(`text_chat`))},[De]);let Ae=t?.widgetSettings||{},je=n?.widgetSettings||{},Me={...Ae.branding||{},...je.branding||{}},Ne={...Ae.theme||{},...je.theme||{}},Pe={...Ae.features||{},...je.features||{}},Fe=Pe.voice!==!1,Ie=Array.isArray(Ne.orbColors)&&Ne.orbColors.length>0?Ne.orbColors:null,Le=Ne.buttonColor||Ne.primaryColor||Ie?.[0]||`#3B82F6`,Re=Ne.position||`bottom-right`,ze=Me.fallbackAgentName||`Agent`,Be=Ck(Ie??Ne.chatBgColors),Ve=Me.logo||Me.logoUrl||null,He=te||`en`,Ue=Ae.recommendations?.[He]||[],We=(je.recommendations?.[He]??Ue).filter(e=>String(e?.label??``).trim()).map((e,t)=>({id:e.key||`qr-${t}`,label:e.label,message:e.label,text:e.label})),Ge=Array.isArray(Me.quickChatOptions)&&Me.quickChatOptions.length>0?Me.quickChatOptions:We,Ke=Me.hideWatermark===!0?!1:Me.showPoweredBy!==!1,qe=Me.chatbotEnabled!==!1&&Ne.chatbotEnabled!==!1,Je=Ae.greetings?.[te]||je.greetings?.[te]||Me.introGreeting||`Hello, I'm here to help you know more about OpenSense Labs.`,Ye={entryPrompt:Me.entryPrompt||`Do you want to explore in a new way?`,yesLabel:Me.yesLabel||`Yes`,laterLabel:Me.laterLabel||`Later`,connectionTitle:Me.connectionTitle||`How would you like to connect?`,voiceLabel:Me.voiceLabel||`Voice`,textLabel:Me.textLabel||`Text`,chatTitle:Me.headerName||`Chat with FlowEngage`,introGreeting:Je,inputPlaceholder:Me.inputPlaceholder||`Type your message`,analysingLabel:Me.analysingLabel||`analysing...`},Xe=je.elevenLabsAgentId||t?.elevenLabsAgentId||null,w=t?.siteId||n?.siteId||null,Ze=t?.apiBaseUrl||``,Qe=(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]),$e=c&&String(c).trim()||t?.ownerProfileImageUrl&&String(t.ownerProfileImageUrl).trim()||null,et=r.some(e=>e.sender===`user`),tt=(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]),nt=!l&&et&&tt,rt=!!(je._dashboardLivePreview||Ae._dashboardLivePreview),[T,E]=(0,d.useState)(()=>rt?`text_chat`:`entry_prompt`),[D,it]=(0,d.useState)(``),[at,ot]=(0,d.useState)(null),[O,st]=(0,d.useState)(l||``),[ct,lt]=(0,d.useState)(``),[ut,dt]=(0,d.useState)(!1),[ft,pt]=(0,d.useState)(0),[mt,ht]=(0,d.useState)(null),[gt,_t]=(0,d.useState)(null),[vt,yt]=(0,d.useState)(``),[bt,xt]=(0,d.useState)(!1),[St,Ct]=(0,d.useState)(!1),[wt,Tt]=(0,d.useState)(!1),Et=(0,d.useRef)(null),Dt=(0,d.useRef)(!1);(0,d.useLayoutEffect)(()=>{if(e!==`ready`||Dt.current)return;if(Dt.current=!0,!Fe){E(`minimized_orb`);return}let t=!1;try{t=mr().shouldResumeVoice}catch{}let n=Ee(),r=w?Se(w):null,i=n||!!r?.transcript;if(t){ce?.({notifyChatInitiated:!0}),ue?.(!0),E(`voice_mode`);return}if(ke()){ce?.({notifyChatInitiated:!1}),E(`text_chat`);return}if(w)try{Ce(w)}catch{}if(i){E(`minimized_orb`);return}if(C(w)){E(`minimized_orb`);return}},[e,r]);let[Ot,kt]=(0,d.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 640px)`).matches);(0,d.useEffect)(()=>{let e=window.matchMedia(`(max-width: 640px)`),t=e=>kt(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,d.useEffect)(()=>{st(l||``),l&<(``)},[l]);let At=(0,d.useCallback)(()=>{_t(null),yt(``)},[]),jt=(0,d.useCallback)(e=>{let t=XO(e);if(t){_t(null),yt(t);return}_t(e),yt(``)},[]);(0,d.useEffect)(()=>{if(!x||b!==`connected`){pt(0);return}let e=()=>{let e=new Date(x).getTime();isNaN(e)||pt(Math.max(0,Math.floor((Date.now()-e)/1e3)))};e();let t=window.setInterval(e,1e3);return()=>window.clearInterval(t)},[x,b]);let Mt=(0,d.useCallback)(()=>{E(`call_screen`),Ct(!1)},[]),Nt=(0,d.useCallback)(()=>{E(`text_chat`),Ct(!0)},[]);(0,d.useEffect)(()=>{let e=v?.callId||y||null;if(!e){Et.current=null;return}if(v?.callId||b===`connecting`||b===`connected`){if(T===`minimized_orb`&&St&&y&&!v?.callId){Et.current=e;return}!(!i||T===`minimized_orb`||T===`voice_mode`)&&Et.current===e||(console.log(`[FlowEngageWidget] forcing call UI to front`,{forcedKey:e,isOpen:i,surface:T,hasIncomingCall:!!v?.callId,activeCallId:y,callConnectionState:b}),Et.current=e,T===`voice_mode`&&ue?.(!1),ce?.(),Mt())}},[y,b,Mt,v?.callId,i,ce,ue,T]),(0,d.useEffect)(()=>{!v&&!y&&T===`call_screen`&&E(`text_chat`)},[v,y,T]),(0,d.useEffect)(()=>{!y&&St&&Ct(!1)},[y,St]),(0,d.useEffect)(()=>{if(!o||_){be?.(``),ye?.();return}if(!D.trim()||gt){be?.(``);let e=window.setTimeout(()=>ye?.(),100);return()=>window.clearTimeout(e)}ve?.();let e=window.setTimeout(()=>be?.(D),120),t=window.setTimeout(()=>ye?.(),1200);return()=>{window.clearTimeout(e),window.clearTimeout(t)}},[D,gt,o,_,ve,ye,be]);let Pt=e=>e?{replyTo:e.messageId||e.id||null,replyToContent:(e.replyToContent||e.message||``).replace(/<[^>]+>/g,``).trim().slice(0,200),replyToSender:e.sender||null}:null,Ft=async e=>{if(e.preventDefault(),_)return;if(nt){let e=O.trim().toLowerCase();if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)){lt(`Please enter a valid email so we can continue helping you.`);return}await le(e),lt(``),dt(!0),setTimeout(()=>dt(!1),3e3);return}let t=Pt(at);if(!D.trim()&&!gt)return;if(gt){try{xt(!0),yt(``);let e=await se(gt),n=e?.data||e,r=D.trim()||`Shared file: ${QO(gt)}`;it(``),ot(null),At(),await oe(r,``,t,{type:`file`,metadata:{fileUrl:n?.fileUrl,fileName:n?.fileName||gt.name,fileType:n?.fileType||gt.type,fileSize:n?.fileSize||gt.size}})}catch(e){yt(e?.message||`Failed to upload the selected file.`)}finally{xt(!1)}return}let n=D.trim();it(``),ot(null),await oe(n,``,t)},It=(0,d.useCallback)(()=>{r.length!==0&&fe?.()},[r.length,fe]),Lt=e=>{let t=Math.floor(e/60);return`${String(t).padStart(2,`0`)}:${String(e%60).padStart(2,`0`)}`},Rt=(0,d.useCallback)(async e=>{if(_||m)return;let t=e.message||e.label||e.text||``;t.trim()&&await oe(t.trim(),``)},[_,m,oe]),zt=Ot&&T===`entry_prompt`?{inset:0}:Ot&&T===`text_chat`?{left:0,right:0,bottom:0}:Ot&&T===`call_screen`?{left:0,right:0,bottom:0,height:`90dvh`,overflow:`hidden`,borderRadius:`16px 16px 0 0`}:Ot&&T===`connection_modal`?{left:`28px`,right:`12px`,bottom:`12px`}:T===`call_screen`?{width:`min(350px, calc(100vw - 40px))`,height:`min(640px, calc(100vh - 120px))`,borderRadius:`22px`,overflow:`hidden`,...Re===`bottom-left`?{left:`1.5rem`,bottom:`1.5rem`}:{right:`1.5rem`,bottom:`1.5rem`}}:Re===`bottom-left`?{left:`1.5rem`,bottom:`1.5rem`}:{right:`1.5rem`,bottom:`1.5rem`},Bt=(0,d.useCallback)(()=>{T!==`minimized_orb`&&(Tt(!0),setTimeout(()=>{E(`minimized_orb`),Tt(!1)},280))},[T]),Vt=()=>E(`connection_modal`),Ht=()=>{try{let e=window.AudioContext||window.webkitAudioContext;if(e){let t=new e;t.resume().catch(()=>{}),setTimeout(()=>t.close().catch(()=>{}),3e3)}}catch{}ce({notifyChatInitiated:!0}),ue?.(!0),E(`voice_mode`)},Ut=()=>{ce({notifyChatInitiated:!0}),ue?.(!1),E(`text_chat`)},Wt=()=>{ue?.(!1),Bt()};return e!==`ready`||!qe||Pe.chat===!1?null:(0,f.jsxs)(`div`,{className:`flowengage-widget-root`,style:{position:`fixed`,zIndex:999999,...zt},onWheel:e=>e.stopPropagation(),onTouchMove:e=>e.stopPropagation(),children:[T===`entry_prompt`&&(0,f.jsx)(kk,{copy:Ye,orbColors:Ie,primaryColor:Le,onYes:()=>{ie(w),Ht()},onLater:()=>{ie(w),Bt()},isMobile:Ot,isClosing:wt}),T===`minimized_orb`&&(0,f.jsxs)(gm.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:Re===`bottom-left`?`flex-start`:`flex-end`,gap:`10px`},children:[y&&St&&(0,f.jsxs)(`button`,{type:`button`,onClick:Mt,style:{maxWidth:Ot?`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`?`${Lt(ft)} with ${Qe}`:`Tap to return to ${Qe}`})]})]}),(0,f.jsx)(Ok,{size:50,orbColors:Ie,onClick:y&&St?Mt:Fe?Vt:Ut})]}),T===`connection_modal`&&(0,f.jsx)(Ak,{copy:Ye,orbColors:Ie,primaryColor:Le,onVoice:Ht,onText:Ut,onClose:Bt,isMobile:Ot,isClosing:wt}),T===`voice_mode`&&(0,f.jsx)(jk,{orbColors:Ie,onEnterChat:Ut,onEndChat:Wt,agentId:Xe,siteId:w,apiBaseUrl:Ze,chatId:ne,historyRef:re,onMessageSync:ae,voiceEndCounter:Oe},`voice`),T===`call_screen`&&(0,f.jsx)(yk,{incomingCall:v,activeCallId:y,callConnectionState:b,callDurationSeconds:ft,isCallMuted:S,agentName:Qe,agentHeadshot:$e,fallbackAgentName:ze,acceptCall:pe,rejectCall:me,endWebRTCCall:he,toggleCallMute:ge,formatCallDuration:Lt,onMinimize:Nt,primaryColor:Le,orbColors:Ie,chatHistory:r}),T===`text_chat`&&(0,f.jsx)(Pk,{isClosing:wt,copy:Ye,orbColors:Ie,primaryColor:Le,chatBgGradient:Be,logo:Ve,quickChatOptions:Ge,onQuickChatSelect:Rt,isMobile:Ot,chatHistory:r,isAiTyping:p,isAgentTyping:u,activeScreen:a,agentName:Qe,agentHeadshot:$e,fallbackAgentName:ze,input:D,setInput:it,onSubmit:Ft,isConversationEnded:_,isLoading:m,isRateLimited:h,rateLimitMessage:g,selectedFile:gt,onFileSelect:jt,onRemoveSelectedFile:At,attachmentError:vt,isUploadingAttachment:bt,requiresEmail:nt,emailInput:O,setEmailInput:st,emailError:ct,emailCaptureSuccess:ut,replyContext:at,setReplyContext:ot,webRTCError:ee,micError:mt,setMicError:ht,dismissCallError:_e,activeCallId:y,isCallMuted:S,toggleCallMute:ge,endWebRTCCall:he,formatCallDuration:Lt,callDurationSeconds:ft,onCollapse:Bt,onStartVoice:Ht,onNewChat:It,onMinimize:Nt,onExpand:Mt,isCallMinimized:St&&!!y,showPoweredBy:Ke,getVisitorChatHistory:xe,resumeChat:we,isSessionRestoring:Te}),(0,f.jsx)(`style`,{children:`
|
|
636
636
|
/* Force any SVG (or img) inside LogoSlot to fill the container height
|
|
637
637
|
regardless of whether the component forwards its style prop. */
|
|
638
638
|
.fe-logo-slot svg,
|
|
@@ -651,4 +651,4 @@ registerProcessor("scribeAudioProcessor", ScribeAudioProcessor);
|
|
|
651
651
|
@keyframes fe-orb-bar-3 { from{height:8px} to{height:20px} }
|
|
652
652
|
@keyframes fe-orb-bar-4 { from{height:6px} to{height:16px} }
|
|
653
653
|
@keyframes fe-dot-bounce { 0%,80%,100%{transform:translateY(0);opacity:.5} 40%{transform:translateY(-5px);opacity:1} }
|
|
654
|
-
`})]})}var
|
|
654
|
+
`})]})}var Ik=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=fk,exports.ErrorBoundary=Ik,exports.FlowEngageProvider=Dr,exports.FlowEngageWidget=Fk,exports.useFlowEngage=Dn;
|