@voxket-ai/voxket-live 1.0.153 โ 1.0.154
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/core/client.d.ts +9 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +107 -85
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var zg=Object.defineProperty;var Ug=(e,t,n)=>t in e?zg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ot=(e,t,n)=>Ug(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("react"),h=require("react/jsx-runtime"),ce=require("livekit-client"),Ft=require("@livekit/components-react"),ze=require("lucide-react"),ja=require("clsx"),Hg=require("@emotion/styled");require("@emotion/react");const Wg=require("react-dom/client");function Gg(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const P=Gg(A),Ba=A.createContext({});function $a(e){const t=A.useRef(null);return t.current===null&&(t.current=e()),t.current}const Va=typeof window<"u",yf=Va?A.useLayoutEffect:A.useEffect,So=A.createContext(null);function za(e,t){e.indexOf(t)===-1&&e.push(t)}function Ua(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const yn=(e,t,n)=>n>t?t:n<e?e:n;function Zs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Nr=()=>{},xn=()=>{};process.env.NODE_ENV!=="production"&&(Nr=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Zs(t,n))},xn=(e,t,n)=>{if(!e)throw new Error(Zs(t,n))});const wn={},xf=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function wf(e){return typeof e=="object"&&e!==null}const vf=e=>/^0[^.\s]+$/u.test(e);function Ha(e){let t;return()=>(t===void 0&&(t=e()),t)}const Zt=e=>e,Kg=(e,t)=>n=>t(e(n)),hi=(...e)=>e.reduce(Kg),ni=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r};class Wa{constructor(){this.subscriptions=[]}add(t){return za(this.subscriptions,t),()=>Ua(this.subscriptions,t)}notify(t,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let o=0;o<i;o++){const s=this.subscriptions[o];s&&s(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const en=e=>e*1e3,ln=e=>e/1e3;function Ef(e,t){return t?e*(1e3/t):0}const mc=new Set;function Ga(e,t,n){e||mc.has(t)||(console.warn(Zs(t,n)),mc.add(t))}const kf=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,qg=1e-7,Yg=12;function Zg(e,t,n,r,i){let o,s,a=0;do s=t+(n-t)/2,o=kf(s,r,i)-e,o>0?n=s:t=s;while(Math.abs(o)>qg&&++a<Yg);return s}function pi(e,t,n,r){if(e===t&&n===r)return Zt;const i=o=>Zg(o,0,1,e,n);return o=>o===0||o===1?o:kf(i(o),t,r)}const Sf=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Cf=e=>t=>1-e(1-t),_f=pi(.33,1.53,.69,.99),Ka=Cf(_f),Tf=Sf(Ka),Nf=e=>(e*=2)<1?.5*Ka(e):.5*(2-Math.pow(2,-10*(e-1))),qa=e=>1-Math.sin(Math.acos(e)),Af=Cf(qa),Rf=Sf(qa),Xg=pi(.42,0,1,1),Qg=pi(0,0,.58,1),Mf=pi(.42,0,.58,1),Jg=e=>Array.isArray(e)&&typeof e[0]!="number",If=e=>Array.isArray(e)&&typeof e[0]=="number",gc={linear:Zt,easeIn:Xg,easeInOut:Mf,easeOut:Qg,circIn:qa,circInOut:Rf,circOut:Af,backIn:Ka,backInOut:Tf,backOut:_f,anticipate:Nf},eb=e=>typeof e=="string",bc=e=>{if(If(e)){xn(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,r,i]=e;return pi(t,n,r,i)}else if(eb(e))return xn(gc[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),gc[e];return e},Ri=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function tb(e,t){let n=new Set,r=new Set,i=!1,o=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(u){s.has(u)&&(c.schedule(u),e()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const g=f&&i?n:r;return d&&s.add(u),g.has(u)||g.add(u),u},cancel:u=>{r.delete(u),s.delete(u)},process:u=>{if(a=u,i){o=!0;return}i=!0,[n,r]=[r,n],n.forEach(l),n.clear(),i=!1,o&&(o=!1,c.process(u))}};return c}const nb=40;function Of(e,t){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,s=Ri.reduce((E,_)=>(E[_]=tb(o),E),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:p,postRender:g}=s,m=()=>{const E=wn.useManualTiming?i.timestamp:performance.now();n=!1,wn.useManualTiming||(i.delta=r?1e3/60:Math.max(Math.min(E-i.timestamp,nb),1)),i.timestamp=E,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),d.process(i),f.process(i),p.process(i),g.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(m))},x=()=>{n=!0,r=!0,i.isProcessing||e(m)};return{schedule:Ri.reduce((E,_)=>{const v=s[_];return E[_]=(C,M=!1,N=!1)=>(n||x(),v.schedule(C,M,N)),E},{}),cancel:E=>{for(let _=0;_<Ri.length;_++)s[Ri[_]].cancel(E)},state:i,steps:s}}const{schedule:it,cancel:Mn,state:Tt,steps:es}=Of(typeof requestAnimationFrame<"u"?requestAnimationFrame:Zt,!0);let Xi;function rb(){Xi=void 0}const jt={now:()=>(Xi===void 0&&jt.set(Tt.isProcessing||wn.useManualTiming?Tt.timestamp:performance.now()),Xi),set:e=>{Xi=e,queueMicrotask(rb)}},Pf=e=>t=>typeof t=="string"&&t.startsWith(e),Ya=Pf("--"),ib=Pf("var(--"),Za=e=>ib(e)?ob.test(e.split("/*")[0].trim()):!1,ob=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ar={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},ri={...Ar,transform:e=>yn(0,1,e)},Mi={...Ar,default:1},qr=e=>Math.round(e*1e5)/1e5,Xa=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sb(e){return e==null}const ab=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Qa=(e,t)=>n=>!!(typeof n=="string"&&ab.test(n)&&n.startsWith(e)||t&&!sb(n)&&Object.prototype.hasOwnProperty.call(n,t)),Df=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,o,s,a]=r.match(Xa);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(s),alpha:a!==void 0?parseFloat(a):1}},lb=e=>yn(0,255,e),ts={...Ar,transform:e=>Math.round(lb(e))},Un={test:Qa("rgb","red"),parse:Df("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+ts.transform(e)+", "+ts.transform(t)+", "+ts.transform(n)+", "+qr(ri.transform(r))+")"};function cb(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}}const Xs={test:Qa("#"),parse:cb,transform:Un.transform},mi=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),An=mi("deg"),cn=mi("%"),we=mi("px"),ub=mi("vh"),db=mi("vw"),yc={...cn,parse:e=>cn.parse(e)/100,transform:e=>cn.transform(e*100)},pr={test:Qa("hsl","hue"),parse:Df("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+cn.transform(qr(t))+", "+cn.transform(qr(n))+", "+qr(ri.transform(r))+")"},yt={test:e=>Un.test(e)||Xs.test(e)||pr.test(e),parse:e=>Un.test(e)?Un.parse(e):pr.test(e)?pr.parse(e):Xs.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Un.transform(e):pr.transform(e),getAnimatableNone:e=>{const t=yt.parse(e);return t.alpha=0,yt.transform(t)}},fb=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function hb(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Xa))==null?void 0:t.length)||0)+(((n=e.match(fb))==null?void 0:n.length)||0)>0}const Lf="number",Ff="color",pb="var",mb="var(",xc="${}",gb=/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 ii(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const a=t.replace(gb,l=>(yt.test(l)?(r.color.push(o),i.push(Ff),n.push(yt.parse(l))):l.startsWith(mb)?(r.var.push(o),i.push(pb),n.push(l)):(r.number.push(o),i.push(Lf),n.push(parseFloat(l))),++o,xc)).split(xc);return{values:n,split:a,indexes:r,types:i}}function jf(e){return ii(e).values}function Bf(e){const{split:t,types:n}=ii(e),r=t.length;return i=>{let o="";for(let s=0;s<r;s++)if(o+=t[s],i[s]!==void 0){const a=n[s];a===Lf?o+=qr(i[s]):a===Ff?o+=yt.transform(i[s]):o+=i[s]}return o}}const bb=e=>typeof e=="number"?0:yt.test(e)?yt.getAnimatableNone(e):e;function yb(e){const t=jf(e);return Bf(e)(t.map(bb))}const In={test:hb,parse:jf,createTransformer:Bf,getAnimatableNone:yb};function ns(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function xb({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,o=0,s=0;if(!t)i=o=s=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;i=ns(l,a,e+1/3),o=ns(l,a,e),s=ns(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(s*255),alpha:r}}function lo(e,t){return n=>n>0?t:e}const at=(e,t,n)=>e+(t-e)*n,rs=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},wb=[Xs,Un,pr],vb=e=>wb.find(t=>t.test(e));function wc(e){const t=vb(e);if(Nr(!!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===pr&&(n=xb(n)),n}const vc=(e,t)=>{const n=wc(e),r=wc(t);if(!n||!r)return lo(e,t);const i={...n};return o=>(i.red=rs(n.red,r.red,o),i.green=rs(n.green,r.green,o),i.blue=rs(n.blue,r.blue,o),i.alpha=at(n.alpha,r.alpha,o),Un.transform(i))},Qs=new Set(["none","hidden"]);function Eb(e,t){return Qs.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function kb(e,t){return n=>at(e,t,n)}function Ja(e){return typeof e=="number"?kb:typeof e=="string"?Za(e)?lo:yt.test(e)?vc:_b:Array.isArray(e)?$f:typeof e=="object"?yt.test(e)?vc:Sb:lo}function $f(e,t){const n=[...e],r=n.length,i=e.map((o,s)=>Ja(o)(o,t[s]));return o=>{for(let s=0;s<r;s++)n[s]=i[s](o);return n}}function Sb(e,t){const n={...e,...t},r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Ja(e[i])(e[i],t[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function Cb(e,t){const n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],s=e.indexes[o][r[o]],a=e.values[s]??0;n[i]=a,r[o]++}return n}const _b=(e,t)=>{const n=In.createTransformer(t),r=ii(e),i=ii(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?Qs.has(e)&&!i.values.length||Qs.has(t)&&!r.values.length?Eb(e,t):hi($f(Cb(r,i),i.values),n):(Nr(!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"),lo(e,t))};function Vf(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?at(e,t,n):Ja(e)(e,t)}const Tb=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>it.update(t,n),stop:()=>Mn(t),now:()=>Tt.isProcessing?Tt.timestamp:jt.now()}},zf=(e,t,n=10)=>{let r="";const i=Math.max(Math.round(t/n),2);for(let o=0;o<i;o++)r+=Math.round(e(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},co=2e4;function el(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<co;)t+=n,r=e.next(t);return t>=co?1/0:t}function Nb(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(el(r),co);return{type:"keyframes",ease:o=>r.next(i*o).value/t,duration:ln(i)}}const Ab=5;function Uf(e,t,n){const r=Math.max(t-Ab,0);return Ef(n-e(r),t-r)}const st={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},is=.001;function Rb({duration:e=st.duration,bounce:t=st.bounce,velocity:n=st.velocity,mass:r=st.mass}){let i,o;Nr(e<=en(st.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let s=1-t;s=yn(st.minDamping,st.maxDamping,s),e=yn(st.minDuration,st.maxDuration,ln(e)),s<1?(i=c=>{const u=c*s,d=u*e,f=u-n,p=Js(c,s),g=Math.exp(-d);return is-f/p*g},o=c=>{const d=c*s*e,f=d*n+n,p=Math.pow(s,2)*Math.pow(c,2)*e,g=Math.exp(-d),m=Js(Math.pow(c,2),s);return(-i(c)+is>0?-1:1)*((f-p)*g)/m}):(i=c=>{const u=Math.exp(-c*e),d=(c-n)*e+1;return-is+u*d},o=c=>{const u=Math.exp(-c*e),d=(n-c)*(e*e);return u*d});const a=5/e,l=Ib(i,o,a);if(e=en(e),isNaN(l))return{stiffness:st.stiffness,damping:st.damping,duration:e};{const c=Math.pow(l,2)*r;return{stiffness:c,damping:s*2*Math.sqrt(r*c),duration:e}}}const Mb=12;function Ib(e,t,n){let r=n;for(let i=1;i<Mb;i++)r=r-e(r)/t(r);return r}function Js(e,t){return e*Math.sqrt(1-t*t)}const Ob=["duration","bounce"],Pb=["stiffness","damping","mass"];function Ec(e,t){return t.some(n=>e[n]!==void 0)}function Db(e){let t={velocity:st.velocity,stiffness:st.stiffness,damping:st.damping,mass:st.mass,isResolvedFromDuration:!1,...e};if(!Ec(e,Pb)&&Ec(e,Ob))if(e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*yn(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:st.mass,stiffness:i,damping:o}}else{const n=Rb(e);t={...t,...n,mass:st.mass},t.isResolvedFromDuration=!0}return t}function uo(e=st.visualDuration,t=st.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:i}=n;const o=n.keyframes[0],s=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=Db({...n,velocity:-ln(n.velocity||0)}),g=f||0,m=c/(2*Math.sqrt(l*u)),x=s-o,y=ln(Math.sqrt(l/u)),k=Math.abs(x)<5;r||(r=k?st.restSpeed.granular:st.restSpeed.default),i||(i=k?st.restDelta.granular:st.restDelta.default);let E;if(m<1){const v=Js(y,m);E=C=>{const M=Math.exp(-m*y*C);return s-M*((g+m*y*x)/v*Math.sin(v*C)+x*Math.cos(v*C))}}else if(m===1)E=v=>s-Math.exp(-y*v)*(x+(g+y*x)*v);else{const v=y*Math.sqrt(m*m-1);E=C=>{const M=Math.exp(-m*y*C),N=Math.min(v*C,300);return s-M*((g+m*y*x)*Math.sinh(N)+v*x*Math.cosh(N))/v}}const _={calculatedDuration:p&&d||null,next:v=>{const C=E(v);if(p)a.done=v>=d;else{let M=v===0?g:0;m<1&&(M=v===0?en(g):Uf(E,v,C));const N=Math.abs(M)<=r,O=Math.abs(s-C)<=i;a.done=N&&O}return a.value=a.done?s:C,a},toString:()=>{const v=Math.min(el(_),co),C=zf(M=>_.next(v*M).value,v,30);return v+"ms "+C},toTransition:()=>{}};return _}uo.applyToOptions=e=>{const t=Nb(e,100,uo);return e.ease=t.ease,e.duration=en(t.duration),e.type="keyframes",e};function ea({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:s,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=e[0],f={done:!1,value:d},p=N=>a!==void 0&&N<a||l!==void 0&&N>l,g=N=>a===void 0?l:l===void 0||Math.abs(a-N)<Math.abs(l-N)?a:l;let m=n*t;const x=d+m,y=s===void 0?x:s(x);y!==x&&(m=y-d);const k=N=>-m*Math.exp(-N/r),E=N=>y+k(N),_=N=>{const O=k(N),b=E(N);f.done=Math.abs(O)<=c,f.value=f.done?y:b};let v,C;const M=N=>{p(f.value)&&(v=N,C=uo({keyframes:[f.value,g(f.value)],velocity:Uf(E,N,f.value),damping:i,stiffness:o,restDelta:c,restSpeed:u}))};return M(0),{calculatedDuration:null,next:N=>{let O=!1;return!C&&v===void 0&&(O=!0,_(N),M(N)),v!==void 0&&N>=v?C.next(N-v):(!O&&_(N),f)}}}function Lb(e,t,n){const r=[],i=n||wn.mix||Vf,o=e.length-1;for(let s=0;s<o;s++){let a=i(e[s],e[s+1]);if(t){const l=Array.isArray(t)?t[s]||Zt:t;a=hi(l,a)}r.push(a)}return r}function Fb(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const o=e.length;if(xn(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const s=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Lb(t,r,i),l=a.length,c=u=>{if(s&&u<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(u<e[d+1]);d++);const f=ni(e[d],e[d+1],u);return a[d](f)};return n?u=>c(yn(e[0],e[o-1],u)):c}function jb(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=ni(0,t,r);e.push(at(n,1,i))}}function Bb(e){const t=[0];return jb(t,e.length-1),t}function $b(e,t){return e.map(n=>n*t)}function Vb(e,t){return e.map(()=>t||Mf).splice(0,e.length-1)}function mr({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=Jg(r)?r.map(bc):bc(r),o={done:!1,value:t[0]},s=$b(n&&n.length===t.length?n:Bb(t),e),a=Fb(s,t,{ease:Array.isArray(i)?i:Vb(t,i)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const zb=e=>e!==null;function tl(e,{repeat:t,repeatType:n="loop"},r,i=1){const o=e.filter(zb),a=i<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||r===void 0?o[a]:r}const Ub={decay:ea,inertia:ea,tween:mr,keyframes:mr,spring:uo};function Hf(e){typeof e.type=="string"&&(e.type=Ub[e.type])}class nl{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Hb=e=>e/100;class rl extends nl{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var r,i;const{motionValue:n}=this.options;n&&n.updatedAt!==jt.now()&&this.tick(jt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(r=this.options).onStop)==null||i.call(r))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Hf(t);const{type:n=mr,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:s=0}=t;let{keyframes:a}=t;const l=n||mr;process.env.NODE_ENV!=="production"&&l!==mr&&xn(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==mr&&typeof a[0]!="number"&&(this.mixKeyframes=hi(Hb,Vf(a[0],a[1])),a=[0,100]);const c=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-s})),c.calculatedDuration===null&&(c.calculatedDuration=el(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=c}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:i,mixKeyframes:o,mirroredGenerator:s,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return r.next(0);const{delay:c=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:p,type:g,onUpdate:m,finalKeyframe:x}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const y=this.currentTime-c*(this.playbackSpeed>=0?1:-1),k=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let E=this.currentTime,_=r;if(d){const N=Math.min(this.currentTime,i)/a;let O=Math.floor(N),b=N%1;!b&&N>=1&&(b=1),b===1&&O--,O=Math.min(O,d+1),!!(O%2)&&(f==="reverse"?(b=1-b,p&&(b-=p/a)):f==="mirror"&&(_=s)),E=yn(0,1,b)*a}const v=k?{done:!1,value:u[0]}:_.next(E);o&&(v.value=o(v.value));let{done:C}=v;!k&&l!==null&&(C=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const M=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&C);return M&&g!==ea&&(v.value=tl(u,this.options,x,this.speed)),m&&m(v.value),M&&this.finish(),v}then(t,n){return this.finished.then(t,n)}get duration(){return ln(this.calculatedDuration)}get time(){return ln(this.currentTime)}set time(t){var n;t=en(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(jt.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=ln(this.currentTime))}play(){var i,o;if(this.isStopped)return;const{driver:t=Tb,startTime:n}=this.options;this.driver||(this.driver=t(s=>this.tick(s))),(o=(i=this.options).onPlay)==null||o.call(i);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),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(jt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Wb(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Hn=e=>e*180/Math.PI,ta=e=>{const t=Hn(Math.atan2(e[1],e[0]));return na(t)},Gb={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:ta,rotateZ:ta,skewX:e=>Hn(Math.atan(e[1])),skewY:e=>Hn(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},na=e=>(e=e%360,e<0&&(e+=360),e),kc=ta,Sc=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Cc=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Kb={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Sc,scaleY:Cc,scale:e=>(Sc(e)+Cc(e))/2,rotateX:e=>na(Hn(Math.atan2(e[6],e[5]))),rotateY:e=>na(Hn(Math.atan2(-e[2],e[0]))),rotateZ:kc,rotate:kc,skewX:e=>Hn(Math.atan(e[4])),skewY:e=>Hn(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function ra(e){return e.includes("scale")?1:0}function ia(e,t){if(!e||e==="none")return ra(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Kb,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Gb,i=a}if(!i)return ra(t);const o=r[t],s=i[1].split(",").map(Yb);return typeof o=="function"?o(s):s[o]}const qb=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return ia(n,t)};function Yb(e){return parseFloat(e.trim())}const Rr=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Mr=new Set(Rr),_c=e=>e===Ar||e===we,Zb=new Set(["x","y","z"]),Xb=Rr.filter(e=>!Zb.has(e));function Qb(e){const t=[];return Xb.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Gn={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-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})=>ia(t,"x"),y:(e,{transform:t})=>ia(t,"y")};Gn.translateX=Gn.x;Gn.translateY=Gn.y;const Kn=new Set;let oa=!1,sa=!1,aa=!1;function Wf(){if(sa){const e=Array.from(Kn).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const i=Qb(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([o,s])=>{var a;(a=r.getValue(o))==null||a.set(s)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}sa=!1,oa=!1,Kn.forEach(e=>e.complete(aa)),Kn.clear()}function Gf(){Kn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(sa=!0)})}function Jb(){aa=!0,Gf(),Wf(),aa=!1}class il{constructor(t,n,r,i,o,s=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=o,this.isAsync=s}scheduleResolve(){this.state="scheduled",this.isAsync?(Kn.add(this),oa||(oa=!0,it.read(Gf),it.resolveKeyframes(Wf))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;if(t[0]===null){const o=i==null?void 0:i.get(),s=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const a=r.readValue(n,s);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=s),i&&o===void 0&&i.set(t[0])}Wb(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Kn.delete(this)}cancel(){this.state==="scheduled"&&(Kn.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const ey=e=>e.startsWith("--");function ty(e,t,n){ey(t)?e.style.setProperty(t,n):e.style[t]=n}const ny=Ha(()=>window.ScrollTimeline!==void 0),ry={};function iy(e,t){const n=Ha(e);return()=>ry[t]??n()}const Kf=iy(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Wr=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Tc={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Wr([0,.65,.55,1]),circOut:Wr([.55,0,1,.45]),backIn:Wr([.31,.01,.66,-.59]),backOut:Wr([.33,1.53,.69,.99])};function qf(e,t){if(e)return typeof e=="function"?Kf()?zf(e,t):"ease-out":If(e)?Wr(e):Array.isArray(e)?e.map(n=>qf(n,t)||Tc.easeOut):Tc[e]}function oy(e,t,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:s="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[t]:n};l&&(u.offset=l);const d=qf(a,i);Array.isArray(d)&&(u.easing=d);const f={delay:r,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:s==="reverse"?"alternate":"normal"};return c&&(f.pseudoElement=c),e.animate(u,f)}function Yf(e){return typeof e=="function"&&"applyToOptions"in e}function sy({type:e,...t}){return Yf(e)&&Kf()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class ay extends nl{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:r,keyframes:i,pseudoElement:o,allowFlatten:s=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=s,this.options=t,xn(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=sy(t);this.animation=oy(n,r,i,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const u=tl(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):ty(n,r,u),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var t,n;this.isPseudoElement||(n=(t=this.animation).commitStyles)==null||n.call(t)}get duration(){var n,r;const t=((r=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:r.call(n).duration)||0;return ln(Number(t))}get time(){return ln(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=en(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){var r;return this.allowFlatten&&((r=this.animation.effect)==null||r.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&ny()?(this.animation.timeline=t,Zt):n(this)}}const Zf={anticipate:Nf,backInOut:Tf,circInOut:Rf};function ly(e){return e in Zf}function cy(e){typeof e.ease=="string"&&ly(e.ease)&&(e.ease=Zf[e.ease])}const Nc=10;class uy extends ay{constructor(t){cy(t),Hf(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:i,element:o,...s}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new rl({...s,autoplay:!1}),l=en(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-Nc).value,a.sample(l).value,Nc),a.stop()}}const Ac=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(In.test(e)||e==="0")&&!e.startsWith("url("));function dy(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function fy(e,t,n,r){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],s=Ac(i,t),a=Ac(o,t);return Nr(s===a,`You are trying to animate ${t} from "${i}" to "${o}". "${s?o:i}" is not an animatable value.`,"value-not-animatable"),!s||!a?!1:dy(e)||(n==="spring"||Yf(n))&&r}function la(e){e.duration=0,e.type}const hy=new Set(["opacity","clipPath","filter","transform"]),py=Ha(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function my(e){var u;const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:o,type:s}=e;if(!(((u=t==null?void 0:t.owner)==null?void 0:u.current)instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return py()&&n&&hy.has(n)&&(n!=="transform"||!c)&&!l&&!r&&i!=="mirror"&&o!==0&&s!=="inertia"}const gy=40;class by extends nl{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:s="loop",keyframes:a,name:l,motionValue:c,element:u,...d}){var g;super(),this.stop=()=>{var m,x;this._animation&&(this._animation.stop(),(m=this.stopTimeline)==null||m.call(this)),(x=this.keyframeResolver)==null||x.cancel()},this.createdAt=jt.now();const f={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:o,repeatType:s,name:l,motionValue:c,element:u,...d},p=(u==null?void 0:u.KeyframeResolver)||il;this.keyframeResolver=new p(a,(m,x,y)=>this.onKeyframesResolved(m,x,f,!y),l,c,u),(g=this.keyframeResolver)==null||g.scheduleResolve()}onKeyframesResolved(t,n,r,i){this.keyframeResolver=void 0;const{name:o,type:s,velocity:a,delay:l,isHandoff:c,onUpdate:u}=r;this.resolvedAt=jt.now(),fy(t,o,s,a)||((wn.instantAnimations||!l)&&(u==null||u(tl(t,r,n))),t[0]=t[t.length-1],la(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>gy?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},p=!c&&my(f)?new uy({...f,element:f.motionValue.owner.current}):new rl(f);p.finished.then(()=>this.notifyFinished()).catch(Zt),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),Jb()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}const yy=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function xy(e){const t=yy.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}const wy=4;function Xf(e,t,n=1){xn(n<=wy,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=xy(e);if(!r)return;const o=window.getComputedStyle(t).getPropertyValue(r);if(o){const s=o.trim();return xf(s)?parseFloat(s):s}return Za(i)?Xf(i,t,n+1):i}function ol(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const Qf=new Set(["width","height","top","left","right","bottom",...Rr]),vy={test:e=>e==="auto",parse:e=>e},Jf=e=>t=>t.test(e),eh=[Ar,we,cn,An,db,ub,vy],Rc=e=>eh.find(Jf(e));function Ey(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||vf(e):!0}const ky=new Set(["brightness","contrast","saturate","opacity"]);function Sy(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Xa)||[];if(!r)return e;const i=n.replace(r,"");let o=ky.has(t)?1:0;return r!==n&&(o*=100),t+"("+o+i+")"}const Cy=/\b([a-z-]*)\(.*?\)/gu,ca={...In,getAnimatableNone:e=>{const t=e.match(Cy);return t?t.map(Sy).join(" "):e}},Mc={...Ar,transform:Math.round},_y={rotate:An,rotateX:An,rotateY:An,rotateZ:An,scale:Mi,scaleX:Mi,scaleY:Mi,scaleZ:Mi,skew:An,skewX:An,skewY:An,distance:we,translateX:we,translateY:we,translateZ:we,x:we,y:we,z:we,perspective:we,transformPerspective:we,opacity:ri,originX:yc,originY:yc,originZ:we},sl={borderWidth:we,borderTopWidth:we,borderRightWidth:we,borderBottomWidth:we,borderLeftWidth:we,borderRadius:we,radius:we,borderTopLeftRadius:we,borderTopRightRadius:we,borderBottomRightRadius:we,borderBottomLeftRadius:we,width:we,maxWidth:we,height:we,maxHeight:we,top:we,right:we,bottom:we,left:we,padding:we,paddingTop:we,paddingRight:we,paddingBottom:we,paddingLeft:we,margin:we,marginTop:we,marginRight:we,marginBottom:we,marginLeft:we,backgroundPositionX:we,backgroundPositionY:we,..._y,zIndex:Mc,fillOpacity:ri,strokeOpacity:ri,numOctaves:Mc},Ty={...sl,color:yt,backgroundColor:yt,outlineColor:yt,fill:yt,stroke:yt,borderColor:yt,borderTopColor:yt,borderRightColor:yt,borderBottomColor:yt,borderLeftColor:yt,filter:ca,WebkitFilter:ca},th=e=>Ty[e];function nh(e,t){let n=th(e);return n!==ca&&(n=In),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ny=new Set(["auto","none","0"]);function Ay(e,t,n){let r=0,i;for(;r<e.length&&!i;){const o=e[r];typeof o=="string"&&!Ny.has(o)&&ii(o).values.length&&(i=e[r]),r++}if(i&&n)for(const o of t)e[o]=nh(n,i)}class Ry extends il{constructor(t,n,r,i,o){super(t,n,r,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let c=t[l];if(typeof c=="string"&&(c=c.trim(),Za(c))){const u=Xf(c,n.current);u!==void 0&&(t[l]=u),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Qf.has(r)||t.length!==2)return;const[i,o]=t,s=Rc(i),a=Rc(o);if(s!==a)if(_c(s)&&_c(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Gn[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let i=0;i<t.length;i++)(t[i]===null||Ey(t[i]))&&r.push(i);r.length&&Ay(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Gn[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(r,i).jump(i,!1)}measureEndState(){var a;const{element:t,name:n,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=r.length-1,s=r[o];r[o]=Gn[n](t.measureViewportBox(),window.getComputedStyle(t.current)),s!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=s),(a=this.removedTransforms)!=null&&a.length&&this.removedTransforms.forEach(([l,c])=>{t.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function My(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const i=(n==null?void 0:n[e])??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}const rh=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ih(e){return wf(e)&&"offsetHeight"in e}const Ic=30,Iy=e=>!isNaN(parseFloat(e));class Oy{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var o;const i=jt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const s of this.dependents)s.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=jt.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Iy(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Ga(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Wa);const r=this.events[t].add(n);return t==="change"?()=>{r(),it.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=jt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Ic)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Ic);return Ef(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),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(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function kr(e,t){return new Oy(e,t)}const{schedule:al}=Of(queueMicrotask,!1),Jt={x:!1,y:!1};function oh(){return Jt.x||Jt.y}function Py(e){return e==="x"||e==="y"?Jt[e]?null:(Jt[e]=!0,()=>{Jt[e]=!1}):Jt.x||Jt.y?null:(Jt.x=Jt.y=!0,()=>{Jt.x=Jt.y=!1})}function sh(e,t){const n=My(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function Oc(e){return!(e.pointerType==="touch"||oh())}function Dy(e,t,n={}){const[r,i,o]=sh(e,n),s=a=>{if(!Oc(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const u=d=>{Oc(d)&&(c(d),l.removeEventListener("pointerleave",u))};l.addEventListener("pointerleave",u,i)};return r.forEach(a=>{a.addEventListener("pointerenter",s,i)}),o}const ah=(e,t)=>t?e===t?!0:ah(e,t.parentElement):!1,ll=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Ly=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Fy(e){return Ly.has(e.tagName)||e.tabIndex!==-1}const Qi=new WeakSet;function Pc(e){return t=>{t.key==="Enter"&&e(t)}}function os(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const jy=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=Pc(()=>{if(Qi.has(n))return;os(n,"down");const i=Pc(()=>{os(n,"up")}),o=()=>os(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function Dc(e){return ll(e)&&!oh()}function By(e,t,n={}){const[r,i,o]=sh(e,n),s=a=>{const l=a.currentTarget;if(!Dc(a))return;Qi.add(l);const c=t(l,a),u=(p,g)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Qi.has(l)&&Qi.delete(l),Dc(p)&&typeof c=="function"&&c(p,{success:g})},d=p=>{u(p,l===window||l===document||n.useGlobalTarget||ah(l,p.target))},f=p=>{u(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",s,i),ih(a)&&(a.addEventListener("focus",c=>jy(c,i)),!Fy(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function lh(e){return wf(e)&&"ownerSVGElement"in e}function $y(e){return lh(e)&&e.tagName==="svg"}const Rt=e=>!!(e&&e.getVelocity),Vy=[...eh,yt,In],zy=e=>Vy.find(Jf(e)),cl=A.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Uy extends P.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const r=n.offsetParent,i=ih(r)&&r.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Hy({children:e,isPresent:t,anchorX:n,root:r}){const i=A.useId(),o=A.useRef(null),s=A.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=A.useContext(cl);return A.useInsertionEffect(()=>{const{width:l,height:c,top:u,left:d,right:f}=s.current;if(t||!o.current||!l||!c)return;const p=n==="left"?`left: ${d}`:`right: ${f}`;o.current.dataset.motionPopId=i;const g=document.createElement("style");a&&(g.nonce=a);const m=r??document.head;return m.appendChild(g),g.sheet&&g.sheet.insertRule(`
|
|
1
|
+
"use strict";var zg=Object.defineProperty;var Ug=(e,t,n)=>t in e?zg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var rt=(e,t,n)=>Ug(e,typeof t!="symbol"?t+"":t,n);Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const A=require("react"),h=require("react/jsx-runtime"),ce=require("livekit-client"),Ft=require("@livekit/components-react"),ze=require("lucide-react"),ja=require("clsx"),Hg=require("@emotion/styled");require("@emotion/react");const Wg=require("react-dom/client");function Gg(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const P=Gg(A),Ba=A.createContext({});function $a(e){const t=A.useRef(null);return t.current===null&&(t.current=e()),t.current}const Va=typeof window<"u",yf=Va?A.useLayoutEffect:A.useEffect,So=A.createContext(null);function za(e,t){e.indexOf(t)===-1&&e.push(t)}function Ua(e,t){const n=e.indexOf(t);n>-1&&e.splice(n,1)}const yn=(e,t,n)=>n>t?t:n<e?e:n;function Zs(e,t){return t?`${e}. For more information and steps for solving, visit https://motion.dev/troubleshooting/${t}`:e}let Nr=()=>{},xn=()=>{};process.env.NODE_ENV!=="production"&&(Nr=(e,t,n)=>{!e&&typeof console<"u"&&console.warn(Zs(t,n))},xn=(e,t,n)=>{if(!e)throw new Error(Zs(t,n))});const wn={},xf=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e);function wf(e){return typeof e=="object"&&e!==null}const vf=e=>/^0[^.\s]+$/u.test(e);function Ha(e){let t;return()=>(t===void 0&&(t=e()),t)}const Zt=e=>e,Kg=(e,t)=>n=>t(e(n)),hi=(...e)=>e.reduce(Kg),ni=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r};class Wa{constructor(){this.subscriptions=[]}add(t){return za(this.subscriptions,t),()=>Ua(this.subscriptions,t)}notify(t,n,r){const i=this.subscriptions.length;if(i)if(i===1)this.subscriptions[0](t,n,r);else for(let o=0;o<i;o++){const s=this.subscriptions[o];s&&s(t,n,r)}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}}const en=e=>e*1e3,ln=e=>e/1e3;function Ef(e,t){return t?e*(1e3/t):0}const mc=new Set;function Ga(e,t,n){e||mc.has(t)||(console.warn(Zs(t,n)),mc.add(t))}const kf=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,qg=1e-7,Yg=12;function Zg(e,t,n,r,i){let o,s,a=0;do s=t+(n-t)/2,o=kf(s,r,i)-e,o>0?n=s:t=s;while(Math.abs(o)>qg&&++a<Yg);return s}function pi(e,t,n,r){if(e===t&&n===r)return Zt;const i=o=>Zg(o,0,1,e,n);return o=>o===0||o===1?o:kf(i(o),t,r)}const Sf=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,Cf=e=>t=>1-e(1-t),_f=pi(.33,1.53,.69,.99),Ka=Cf(_f),Tf=Sf(Ka),Nf=e=>(e*=2)<1?.5*Ka(e):.5*(2-Math.pow(2,-10*(e-1))),qa=e=>1-Math.sin(Math.acos(e)),Af=Cf(qa),Rf=Sf(qa),Xg=pi(.42,0,1,1),Qg=pi(0,0,.58,1),Mf=pi(.42,0,.58,1),Jg=e=>Array.isArray(e)&&typeof e[0]!="number",If=e=>Array.isArray(e)&&typeof e[0]=="number",gc={linear:Zt,easeIn:Xg,easeInOut:Mf,easeOut:Qg,circIn:qa,circInOut:Rf,circOut:Af,backIn:Ka,backInOut:Tf,backOut:_f,anticipate:Nf},eb=e=>typeof e=="string",bc=e=>{if(If(e)){xn(e.length===4,"Cubic bezier arrays must contain four numerical values.","cubic-bezier-length");const[t,n,r,i]=e;return pi(t,n,r,i)}else if(eb(e))return xn(gc[e]!==void 0,`Invalid easing type '${e}'`,"invalid-easing-type"),gc[e];return e},Ri=["setup","read","resolveKeyframes","preUpdate","update","preRender","render","postRender"];function tb(e,t){let n=new Set,r=new Set,i=!1,o=!1;const s=new WeakSet;let a={delta:0,timestamp:0,isProcessing:!1};function l(u){s.has(u)&&(c.schedule(u),e()),u(a)}const c={schedule:(u,d=!1,f=!1)=>{const g=f&&i?n:r;return d&&s.add(u),g.has(u)||g.add(u),u},cancel:u=>{r.delete(u),s.delete(u)},process:u=>{if(a=u,i){o=!0;return}i=!0,[n,r]=[r,n],n.forEach(l),n.clear(),i=!1,o&&(o=!1,c.process(u))}};return c}const nb=40;function Of(e,t){let n=!1,r=!0;const i={delta:0,timestamp:0,isProcessing:!1},o=()=>n=!0,s=Ri.reduce((E,_)=>(E[_]=tb(o),E),{}),{setup:a,read:l,resolveKeyframes:c,preUpdate:u,update:d,preRender:f,render:p,postRender:g}=s,m=()=>{const E=wn.useManualTiming?i.timestamp:performance.now();n=!1,wn.useManualTiming||(i.delta=r?1e3/60:Math.max(Math.min(E-i.timestamp,nb),1)),i.timestamp=E,i.isProcessing=!0,a.process(i),l.process(i),c.process(i),u.process(i),d.process(i),f.process(i),p.process(i),g.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(m))},x=()=>{n=!0,r=!0,i.isProcessing||e(m)};return{schedule:Ri.reduce((E,_)=>{const v=s[_];return E[_]=(C,M=!1,N=!1)=>(n||x(),v.schedule(C,M,N)),E},{}),cancel:E=>{for(let _=0;_<Ri.length;_++)s[Ri[_]].cancel(E)},state:i,steps:s}}const{schedule:ot,cancel:Mn,state:Tt,steps:es}=Of(typeof requestAnimationFrame<"u"?requestAnimationFrame:Zt,!0);let Xi;function rb(){Xi=void 0}const jt={now:()=>(Xi===void 0&&jt.set(Tt.isProcessing||wn.useManualTiming?Tt.timestamp:performance.now()),Xi),set:e=>{Xi=e,queueMicrotask(rb)}},Pf=e=>t=>typeof t=="string"&&t.startsWith(e),Ya=Pf("--"),ib=Pf("var(--"),Za=e=>ib(e)?ob.test(e.split("/*")[0].trim()):!1,ob=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu,Ar={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},ri={...Ar,transform:e=>yn(0,1,e)},Mi={...Ar,default:1},qr=e=>Math.round(e*1e5)/1e5,Xa=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function sb(e){return e==null}const ab=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,Qa=(e,t)=>n=>!!(typeof n=="string"&&ab.test(n)&&n.startsWith(e)||t&&!sb(n)&&Object.prototype.hasOwnProperty.call(n,t)),Df=(e,t,n)=>r=>{if(typeof r!="string")return r;const[i,o,s,a]=r.match(Xa);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(s),alpha:a!==void 0?parseFloat(a):1}},lb=e=>yn(0,255,e),ts={...Ar,transform:e=>Math.round(lb(e))},Un={test:Qa("rgb","red"),parse:Df("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+ts.transform(e)+", "+ts.transform(t)+", "+ts.transform(n)+", "+qr(ri.transform(r))+")"};function cb(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}}const Xs={test:Qa("#"),parse:cb,transform:Un.transform},mi=e=>({test:t=>typeof t=="string"&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}),An=mi("deg"),cn=mi("%"),we=mi("px"),ub=mi("vh"),db=mi("vw"),yc={...cn,parse:e=>cn.parse(e)/100,transform:e=>cn.transform(e*100)},pr={test:Qa("hsl","hue"),parse:Df("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+cn.transform(qr(t))+", "+cn.transform(qr(n))+", "+qr(ri.transform(r))+")"},yt={test:e=>Un.test(e)||Xs.test(e)||pr.test(e),parse:e=>Un.test(e)?Un.parse(e):pr.test(e)?pr.parse(e):Xs.parse(e),transform:e=>typeof e=="string"?e:e.hasOwnProperty("red")?Un.transform(e):pr.transform(e),getAnimatableNone:e=>{const t=yt.parse(e);return t.alpha=0,yt.transform(t)}},fb=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function hb(e){var t,n;return isNaN(e)&&typeof e=="string"&&(((t=e.match(Xa))==null?void 0:t.length)||0)+(((n=e.match(fb))==null?void 0:n.length)||0)>0}const Lf="number",Ff="color",pb="var",mb="var(",xc="${}",gb=/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 ii(e){const t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[];let o=0;const a=t.replace(gb,l=>(yt.test(l)?(r.color.push(o),i.push(Ff),n.push(yt.parse(l))):l.startsWith(mb)?(r.var.push(o),i.push(pb),n.push(l)):(r.number.push(o),i.push(Lf),n.push(parseFloat(l))),++o,xc)).split(xc);return{values:n,split:a,indexes:r,types:i}}function jf(e){return ii(e).values}function Bf(e){const{split:t,types:n}=ii(e),r=t.length;return i=>{let o="";for(let s=0;s<r;s++)if(o+=t[s],i[s]!==void 0){const a=n[s];a===Lf?o+=qr(i[s]):a===Ff?o+=yt.transform(i[s]):o+=i[s]}return o}}const bb=e=>typeof e=="number"?0:yt.test(e)?yt.getAnimatableNone(e):e;function yb(e){const t=jf(e);return Bf(e)(t.map(bb))}const In={test:hb,parse:jf,createTransformer:Bf,getAnimatableNone:yb};function ns(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function xb({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,o=0,s=0;if(!t)i=o=s=n;else{const a=n<.5?n*(1+t):n+t-n*t,l=2*n-a;i=ns(l,a,e+1/3),o=ns(l,a,e),s=ns(l,a,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(s*255),alpha:r}}function lo(e,t){return n=>n>0?t:e}const at=(e,t,n)=>e+(t-e)*n,rs=(e,t,n)=>{const r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},wb=[Xs,Un,pr],vb=e=>wb.find(t=>t.test(e));function wc(e){const t=vb(e);if(Nr(!!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===pr&&(n=xb(n)),n}const vc=(e,t)=>{const n=wc(e),r=wc(t);if(!n||!r)return lo(e,t);const i={...n};return o=>(i.red=rs(n.red,r.red,o),i.green=rs(n.green,r.green,o),i.blue=rs(n.blue,r.blue,o),i.alpha=at(n.alpha,r.alpha,o),Un.transform(i))},Qs=new Set(["none","hidden"]);function Eb(e,t){return Qs.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function kb(e,t){return n=>at(e,t,n)}function Ja(e){return typeof e=="number"?kb:typeof e=="string"?Za(e)?lo:yt.test(e)?vc:_b:Array.isArray(e)?$f:typeof e=="object"?yt.test(e)?vc:Sb:lo}function $f(e,t){const n=[...e],r=n.length,i=e.map((o,s)=>Ja(o)(o,t[s]));return o=>{for(let s=0;s<r;s++)n[s]=i[s](o);return n}}function Sb(e,t){const n={...e,...t},r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Ja(e[i])(e[i],t[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}}function Cb(e,t){const n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){const o=t.types[i],s=e.indexes[o][r[o]],a=e.values[s]??0;n[i]=a,r[o]++}return n}const _b=(e,t)=>{const n=In.createTransformer(t),r=ii(e),i=ii(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?Qs.has(e)&&!i.values.length||Qs.has(t)&&!r.values.length?Eb(e,t):hi($f(Cb(r,i),i.values),n):(Nr(!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"),lo(e,t))};function Vf(e,t,n){return typeof e=="number"&&typeof t=="number"&&typeof n=="number"?at(e,t,n):Ja(e)(e,t)}const Tb=e=>{const t=({timestamp:n})=>e(n);return{start:(n=!0)=>ot.update(t,n),stop:()=>Mn(t),now:()=>Tt.isProcessing?Tt.timestamp:jt.now()}},zf=(e,t,n=10)=>{let r="";const i=Math.max(Math.round(t/n),2);for(let o=0;o<i;o++)r+=Math.round(e(o/(i-1))*1e4)/1e4+", ";return`linear(${r.substring(0,r.length-2)})`},co=2e4;function el(e){let t=0;const n=50;let r=e.next(t);for(;!r.done&&t<co;)t+=n,r=e.next(t);return t>=co?1/0:t}function Nb(e,t=100,n){const r=n({...e,keyframes:[0,t]}),i=Math.min(el(r),co);return{type:"keyframes",ease:o=>r.next(i*o).value/t,duration:ln(i)}}const Ab=5;function Uf(e,t,n){const r=Math.max(t-Ab,0);return Ef(n-e(r),t-r)}const st={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},is=.001;function Rb({duration:e=st.duration,bounce:t=st.bounce,velocity:n=st.velocity,mass:r=st.mass}){let i,o;Nr(e<=en(st.maxDuration),"Spring duration must be 10 seconds or less","spring-duration-limit");let s=1-t;s=yn(st.minDamping,st.maxDamping,s),e=yn(st.minDuration,st.maxDuration,ln(e)),s<1?(i=c=>{const u=c*s,d=u*e,f=u-n,p=Js(c,s),g=Math.exp(-d);return is-f/p*g},o=c=>{const d=c*s*e,f=d*n+n,p=Math.pow(s,2)*Math.pow(c,2)*e,g=Math.exp(-d),m=Js(Math.pow(c,2),s);return(-i(c)+is>0?-1:1)*((f-p)*g)/m}):(i=c=>{const u=Math.exp(-c*e),d=(c-n)*e+1;return-is+u*d},o=c=>{const u=Math.exp(-c*e),d=(n-c)*(e*e);return u*d});const a=5/e,l=Ib(i,o,a);if(e=en(e),isNaN(l))return{stiffness:st.stiffness,damping:st.damping,duration:e};{const c=Math.pow(l,2)*r;return{stiffness:c,damping:s*2*Math.sqrt(r*c),duration:e}}}const Mb=12;function Ib(e,t,n){let r=n;for(let i=1;i<Mb;i++)r=r-e(r)/t(r);return r}function Js(e,t){return e*Math.sqrt(1-t*t)}const Ob=["duration","bounce"],Pb=["stiffness","damping","mass"];function Ec(e,t){return t.some(n=>e[n]!==void 0)}function Db(e){let t={velocity:st.velocity,stiffness:st.stiffness,damping:st.damping,mass:st.mass,isResolvedFromDuration:!1,...e};if(!Ec(e,Pb)&&Ec(e,Ob))if(e.visualDuration){const n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,o=2*yn(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:st.mass,stiffness:i,damping:o}}else{const n=Rb(e);t={...t,...n,mass:st.mass},t.isResolvedFromDuration=!0}return t}function uo(e=st.visualDuration,t=st.bounce){const n=typeof e!="object"?{visualDuration:e,keyframes:[0,1],bounce:t}:e;let{restSpeed:r,restDelta:i}=n;const o=n.keyframes[0],s=n.keyframes[n.keyframes.length-1],a={done:!1,value:o},{stiffness:l,damping:c,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=Db({...n,velocity:-ln(n.velocity||0)}),g=f||0,m=c/(2*Math.sqrt(l*u)),x=s-o,y=ln(Math.sqrt(l/u)),k=Math.abs(x)<5;r||(r=k?st.restSpeed.granular:st.restSpeed.default),i||(i=k?st.restDelta.granular:st.restDelta.default);let E;if(m<1){const v=Js(y,m);E=C=>{const M=Math.exp(-m*y*C);return s-M*((g+m*y*x)/v*Math.sin(v*C)+x*Math.cos(v*C))}}else if(m===1)E=v=>s-Math.exp(-y*v)*(x+(g+y*x)*v);else{const v=y*Math.sqrt(m*m-1);E=C=>{const M=Math.exp(-m*y*C),N=Math.min(v*C,300);return s-M*((g+m*y*x)*Math.sinh(N)+v*x*Math.cosh(N))/v}}const _={calculatedDuration:p&&d||null,next:v=>{const C=E(v);if(p)a.done=v>=d;else{let M=v===0?g:0;m<1&&(M=v===0?en(g):Uf(E,v,C));const N=Math.abs(M)<=r,O=Math.abs(s-C)<=i;a.done=N&&O}return a.value=a.done?s:C,a},toString:()=>{const v=Math.min(el(_),co),C=zf(M=>_.next(v*M).value,v,30);return v+"ms "+C},toTransition:()=>{}};return _}uo.applyToOptions=e=>{const t=Nb(e,100,uo);return e.ease=t.ease,e.duration=en(t.duration),e.type="keyframes",e};function ea({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:o=500,modifyTarget:s,min:a,max:l,restDelta:c=.5,restSpeed:u}){const d=e[0],f={done:!1,value:d},p=N=>a!==void 0&&N<a||l!==void 0&&N>l,g=N=>a===void 0?l:l===void 0||Math.abs(a-N)<Math.abs(l-N)?a:l;let m=n*t;const x=d+m,y=s===void 0?x:s(x);y!==x&&(m=y-d);const k=N=>-m*Math.exp(-N/r),E=N=>y+k(N),_=N=>{const O=k(N),b=E(N);f.done=Math.abs(O)<=c,f.value=f.done?y:b};let v,C;const M=N=>{p(f.value)&&(v=N,C=uo({keyframes:[f.value,g(f.value)],velocity:Uf(E,N,f.value),damping:i,stiffness:o,restDelta:c,restSpeed:u}))};return M(0),{calculatedDuration:null,next:N=>{let O=!1;return!C&&v===void 0&&(O=!0,_(N),M(N)),v!==void 0&&N>=v?C.next(N-v):(!O&&_(N),f)}}}function Lb(e,t,n){const r=[],i=n||wn.mix||Vf,o=e.length-1;for(let s=0;s<o;s++){let a=i(e[s],e[s+1]);if(t){const l=Array.isArray(t)?t[s]||Zt:t;a=hi(l,a)}r.push(a)}return r}function Fb(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const o=e.length;if(xn(o===t.length,"Both input and output ranges must be the same length","range-length"),o===1)return()=>t[0];if(o===2&&t[0]===t[1])return()=>t[1];const s=e[0]===e[1];e[0]>e[o-1]&&(e=[...e].reverse(),t=[...t].reverse());const a=Lb(t,r,i),l=a.length,c=u=>{if(s&&u<e[0])return t[0];let d=0;if(l>1)for(;d<e.length-2&&!(u<e[d+1]);d++);const f=ni(e[d],e[d+1],u);return a[d](f)};return n?u=>c(yn(e[0],e[o-1],u)):c}function jb(e,t){const n=e[e.length-1];for(let r=1;r<=t;r++){const i=ni(0,t,r);e.push(at(n,1,i))}}function Bb(e){const t=[0];return jb(t,e.length-1),t}function $b(e,t){return e.map(n=>n*t)}function Vb(e,t){return e.map(()=>t||Mf).splice(0,e.length-1)}function mr({duration:e=300,keyframes:t,times:n,ease:r="easeInOut"}){const i=Jg(r)?r.map(bc):bc(r),o={done:!1,value:t[0]},s=$b(n&&n.length===t.length?n:Bb(t),e),a=Fb(s,t,{ease:Array.isArray(i)?i:Vb(t,i)});return{calculatedDuration:e,next:l=>(o.value=a(l),o.done=l>=e,o)}}const zb=e=>e!==null;function tl(e,{repeat:t,repeatType:n="loop"},r,i=1){const o=e.filter(zb),a=i<0||t&&n!=="loop"&&t%2===1?0:o.length-1;return!a||r===void 0?o[a]:r}const Ub={decay:ea,inertia:ea,tween:mr,keyframes:mr,spring:uo};function Hf(e){typeof e.type=="string"&&(e.type=Ub[e.type])}class nl{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(t=>{this.resolve=t})}notifyFinished(){this.resolve()}then(t,n){return this.finished.then(t,n)}}const Hb=e=>e/100;class rl extends nl{constructor(t){super(),this.state="idle",this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.stop=()=>{var r,i;const{motionValue:n}=this.options;n&&n.updatedAt!==jt.now()&&this.tick(jt.now()),this.isStopped=!0,this.state!=="idle"&&(this.teardown(),(i=(r=this.options).onStop)==null||i.call(r))},this.options=t,this.initAnimation(),this.play(),t.autoplay===!1&&this.pause()}initAnimation(){const{options:t}=this;Hf(t);const{type:n=mr,repeat:r=0,repeatDelay:i=0,repeatType:o,velocity:s=0}=t;let{keyframes:a}=t;const l=n||mr;process.env.NODE_ENV!=="production"&&l!==mr&&xn(a.length<=2,`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${a}`,"spring-two-frames"),l!==mr&&typeof a[0]!="number"&&(this.mixKeyframes=hi(Hb,Vf(a[0],a[1])),a=[0,100]);const c=l({...t,keyframes:a});o==="mirror"&&(this.mirroredGenerator=l({...t,keyframes:[...a].reverse(),velocity:-s})),c.calculatedDuration===null&&(c.calculatedDuration=el(c));const{calculatedDuration:u}=c;this.calculatedDuration=u,this.resolvedDuration=u+i,this.totalDuration=this.resolvedDuration*(r+1)-i,this.generator=c}updateTime(t){const n=Math.round(t-this.startTime)*this.playbackSpeed;this.holdTime!==null?this.currentTime=this.holdTime:this.currentTime=n}tick(t,n=!1){const{generator:r,totalDuration:i,mixKeyframes:o,mirroredGenerator:s,resolvedDuration:a,calculatedDuration:l}=this;if(this.startTime===null)return r.next(0);const{delay:c=0,keyframes:u,repeat:d,repeatType:f,repeatDelay:p,type:g,onUpdate:m,finalKeyframe:x}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,t):this.speed<0&&(this.startTime=Math.min(t-i/this.speed,this.startTime)),n?this.currentTime=t:this.updateTime(t);const y=this.currentTime-c*(this.playbackSpeed>=0?1:-1),k=this.playbackSpeed>=0?y<0:y>i;this.currentTime=Math.max(y,0),this.state==="finished"&&this.holdTime===null&&(this.currentTime=i);let E=this.currentTime,_=r;if(d){const N=Math.min(this.currentTime,i)/a;let O=Math.floor(N),b=N%1;!b&&N>=1&&(b=1),b===1&&O--,O=Math.min(O,d+1),!!(O%2)&&(f==="reverse"?(b=1-b,p&&(b-=p/a)):f==="mirror"&&(_=s)),E=yn(0,1,b)*a}const v=k?{done:!1,value:u[0]}:_.next(E);o&&(v.value=o(v.value));let{done:C}=v;!k&&l!==null&&(C=this.playbackSpeed>=0?this.currentTime>=i:this.currentTime<=0);const M=this.holdTime===null&&(this.state==="finished"||this.state==="running"&&C);return M&&g!==ea&&(v.value=tl(u,this.options,x,this.speed)),m&&m(v.value),M&&this.finish(),v}then(t,n){return this.finished.then(t,n)}get duration(){return ln(this.calculatedDuration)}get time(){return ln(this.currentTime)}set time(t){var n;t=en(t),this.currentTime=t,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=t:this.driver&&(this.startTime=this.driver.now()-t/this.playbackSpeed),(n=this.driver)==null||n.start(!1)}get speed(){return this.playbackSpeed}set speed(t){this.updateTime(jt.now());const n=this.playbackSpeed!==t;this.playbackSpeed=t,n&&(this.time=ln(this.currentTime))}play(){var i,o;if(this.isStopped)return;const{driver:t=Tb,startTime:n}=this.options;this.driver||(this.driver=t(s=>this.tick(s))),(o=(i=this.options).onPlay)==null||o.call(i);const r=this.driver.now();this.state==="finished"?(this.updateFinished(),this.startTime=r):this.holdTime!==null?this.startTime=r-this.holdTime:this.startTime||(this.startTime=n??r),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(jt.now()),this.holdTime=this.currentTime}complete(){this.state!=="running"&&this.play(),this.state="finished",this.holdTime=null}finish(){var t,n;this.notifyFinished(),this.teardown(),this.state="finished",(n=(t=this.options).onComplete)==null||n.call(t)}cancel(){var t,n;this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),(n=(t=this.options).onCancel)==null||n.call(t)}teardown(){this.state="idle",this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&(this.driver.stop(),this.driver=void 0)}sample(t){return this.startTime=0,this.tick(t,!0)}attachTimeline(t){var n;return this.options.allowFlatten&&(this.options.type="keyframes",this.options.ease="linear",this.initAnimation()),(n=this.driver)==null||n.stop(),t.observe(this)}}function Wb(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}const Hn=e=>e*180/Math.PI,ta=e=>{const t=Hn(Math.atan2(e[1],e[0]));return na(t)},Gb={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:ta,rotateZ:ta,skewX:e=>Hn(Math.atan(e[1])),skewY:e=>Hn(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},na=e=>(e=e%360,e<0&&(e+=360),e),kc=ta,Sc=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Cc=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),Kb={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Sc,scaleY:Cc,scale:e=>(Sc(e)+Cc(e))/2,rotateX:e=>na(Hn(Math.atan2(e[6],e[5]))),rotateY:e=>na(Hn(Math.atan2(-e[2],e[0]))),rotateZ:kc,rotate:kc,skewX:e=>Hn(Math.atan(e[4])),skewY:e=>Hn(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function ra(e){return e.includes("scale")?1:0}function ia(e,t){if(!e||e==="none")return ra(t);const n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u);let r,i;if(n)r=Kb,i=n;else{const a=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=Gb,i=a}if(!i)return ra(t);const o=r[t],s=i[1].split(",").map(Yb);return typeof o=="function"?o(s):s[o]}const qb=(e,t)=>{const{transform:n="none"}=getComputedStyle(e);return ia(n,t)};function Yb(e){return parseFloat(e.trim())}const Rr=["transformPerspective","x","y","z","translateX","translateY","translateZ","scale","scaleX","scaleY","rotate","rotateX","rotateY","rotateZ","skew","skewX","skewY"],Mr=new Set(Rr),_c=e=>e===Ar||e===we,Zb=new Set(["x","y","z"]),Xb=Rr.filter(e=>!Zb.has(e));function Qb(e){const t=[];return Xb.forEach(n=>{const r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(n.startsWith("scale")?1:0))}),t}const Gn={width:({x:e},{paddingLeft:t="0",paddingRight:n="0"})=>e.max-e.min-parseFloat(t)-parseFloat(n),height:({y:e},{paddingTop:t="0",paddingBottom:n="0"})=>e.max-e.min-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})=>ia(t,"x"),y:(e,{transform:t})=>ia(t,"y")};Gn.translateX=Gn.x;Gn.translateY=Gn.y;const Kn=new Set;let oa=!1,sa=!1,aa=!1;function Wf(){if(sa){const e=Array.from(Kn).filter(r=>r.needsMeasurement),t=new Set(e.map(r=>r.element)),n=new Map;t.forEach(r=>{const i=Qb(r);i.length&&(n.set(r,i),r.render())}),e.forEach(r=>r.measureInitialState()),t.forEach(r=>{r.render();const i=n.get(r);i&&i.forEach(([o,s])=>{var a;(a=r.getValue(o))==null||a.set(s)})}),e.forEach(r=>r.measureEndState()),e.forEach(r=>{r.suspendedScrollY!==void 0&&window.scrollTo(0,r.suspendedScrollY)})}sa=!1,oa=!1,Kn.forEach(e=>e.complete(aa)),Kn.clear()}function Gf(){Kn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(sa=!0)})}function Jb(){aa=!0,Gf(),Wf(),aa=!1}class il{constructor(t,n,r,i,o,s=!1){this.state="pending",this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...t],this.onComplete=n,this.name=r,this.motionValue=i,this.element=o,this.isAsync=s}scheduleResolve(){this.state="scheduled",this.isAsync?(Kn.add(this),oa||(oa=!0,ot.read(Gf),ot.resolveKeyframes(Wf))):(this.readKeyframes(),this.complete())}readKeyframes(){const{unresolvedKeyframes:t,name:n,element:r,motionValue:i}=this;if(t[0]===null){const o=i==null?void 0:i.get(),s=t[t.length-1];if(o!==void 0)t[0]=o;else if(r&&n){const a=r.readValue(n,s);a!=null&&(t[0]=a)}t[0]===void 0&&(t[0]=s),i&&o===void 0&&i.set(t[0])}Wb(t)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(t=!1){this.state="complete",this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,t),Kn.delete(this)}cancel(){this.state==="scheduled"&&(Kn.delete(this),this.state="pending")}resume(){this.state==="pending"&&this.scheduleResolve()}}const ey=e=>e.startsWith("--");function ty(e,t,n){ey(t)?e.style.setProperty(t,n):e.style[t]=n}const ny=Ha(()=>window.ScrollTimeline!==void 0),ry={};function iy(e,t){const n=Ha(e);return()=>ry[t]??n()}const Kf=iy(()=>{try{document.createElement("div").animate({opacity:0},{easing:"linear(0, 1)"})}catch{return!1}return!0},"linearEasing"),Wr=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,Tc={linear:"linear",ease:"ease",easeIn:"ease-in",easeOut:"ease-out",easeInOut:"ease-in-out",circIn:Wr([0,.65,.55,1]),circOut:Wr([.55,0,1,.45]),backIn:Wr([.31,.01,.66,-.59]),backOut:Wr([.33,1.53,.69,.99])};function qf(e,t){if(e)return typeof e=="function"?Kf()?zf(e,t):"ease-out":If(e)?Wr(e):Array.isArray(e)?e.map(n=>qf(n,t)||Tc.easeOut):Tc[e]}function oy(e,t,n,{delay:r=0,duration:i=300,repeat:o=0,repeatType:s="loop",ease:a="easeOut",times:l}={},c=void 0){const u={[t]:n};l&&(u.offset=l);const d=qf(a,i);Array.isArray(d)&&(u.easing=d);const f={delay:r,duration:i,easing:Array.isArray(d)?"linear":d,fill:"both",iterations:o+1,direction:s==="reverse"?"alternate":"normal"};return c&&(f.pseudoElement=c),e.animate(u,f)}function Yf(e){return typeof e=="function"&&"applyToOptions"in e}function sy({type:e,...t}){return Yf(e)&&Kf()?e.applyToOptions(t):(t.duration??(t.duration=300),t.ease??(t.ease="easeOut"),t)}class ay extends nl{constructor(t){if(super(),this.finishedTime=null,this.isStopped=!1,!t)return;const{element:n,name:r,keyframes:i,pseudoElement:o,allowFlatten:s=!1,finalKeyframe:a,onComplete:l}=t;this.isPseudoElement=!!o,this.allowFlatten=s,this.options=t,xn(typeof t.type!="string",`Mini animate() doesn't support "type" as a string.`,"mini-spring");const c=sy(t);this.animation=oy(n,r,i,c,o),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!o){const u=tl(i,this.options,a,this.speed);this.updateMotionValue?this.updateMotionValue(u):ty(n,r,u),this.animation.cancel()}l==null||l(),this.notifyFinished()}}play(){this.isStopped||(this.animation.play(),this.state==="finished"&&this.updateFinished())}pause(){this.animation.pause()}complete(){var t,n;(n=(t=this.animation).finish)==null||n.call(t)}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;const{state:t}=this;t==="idle"||t==="finished"||(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){var t,n;this.isPseudoElement||(n=(t=this.animation).commitStyles)==null||n.call(t)}get duration(){var n,r;const t=((r=(n=this.animation.effect)==null?void 0:n.getComputedTiming)==null?void 0:r.call(n).duration)||0;return ln(Number(t))}get time(){return ln(Number(this.animation.currentTime)||0)}set time(t){this.finishedTime=null,this.animation.currentTime=en(t)}get speed(){return this.animation.playbackRate}set speed(t){t<0&&(this.finishedTime=null),this.animation.playbackRate=t}get state(){return this.finishedTime!==null?"finished":this.animation.playState}get startTime(){return Number(this.animation.startTime)}set startTime(t){this.animation.startTime=t}attachTimeline({timeline:t,observe:n}){var r;return this.allowFlatten&&((r=this.animation.effect)==null||r.updateTiming({easing:"linear"})),this.animation.onfinish=null,t&&ny()?(this.animation.timeline=t,Zt):n(this)}}const Zf={anticipate:Nf,backInOut:Tf,circInOut:Rf};function ly(e){return e in Zf}function cy(e){typeof e.ease=="string"&&ly(e.ease)&&(e.ease=Zf[e.ease])}const Nc=10;class uy extends ay{constructor(t){cy(t),Hf(t),super(t),t.startTime&&(this.startTime=t.startTime),this.options=t}updateMotionValue(t){const{motionValue:n,onUpdate:r,onComplete:i,element:o,...s}=this.options;if(!n)return;if(t!==void 0){n.set(t);return}const a=new rl({...s,autoplay:!1}),l=en(this.finishedTime??this.time);n.setWithVelocity(a.sample(l-Nc).value,a.sample(l).value,Nc),a.stop()}}const Ac=(e,t)=>t==="zIndex"?!1:!!(typeof e=="number"||Array.isArray(e)||typeof e=="string"&&(In.test(e)||e==="0")&&!e.startsWith("url("));function dy(e){const t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function fy(e,t,n,r){const i=e[0];if(i===null)return!1;if(t==="display"||t==="visibility")return!0;const o=e[e.length-1],s=Ac(i,t),a=Ac(o,t);return Nr(s===a,`You are trying to animate ${t} from "${i}" to "${o}". "${s?o:i}" is not an animatable value.`,"value-not-animatable"),!s||!a?!1:dy(e)||(n==="spring"||Yf(n))&&r}function la(e){e.duration=0,e.type}const hy=new Set(["opacity","clipPath","filter","transform"]),py=Ha(()=>Object.hasOwnProperty.call(Element.prototype,"animate"));function my(e){var u;const{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:o,type:s}=e;if(!(((u=t==null?void 0:t.owner)==null?void 0:u.current)instanceof HTMLElement))return!1;const{onUpdate:l,transformTemplate:c}=t.owner.getProps();return py()&&n&&hy.has(n)&&(n!=="transform"||!c)&&!l&&!r&&i!=="mirror"&&o!==0&&s!=="inertia"}const gy=40;class by extends nl{constructor({autoplay:t=!0,delay:n=0,type:r="keyframes",repeat:i=0,repeatDelay:o=0,repeatType:s="loop",keyframes:a,name:l,motionValue:c,element:u,...d}){var g;super(),this.stop=()=>{var m,x;this._animation&&(this._animation.stop(),(m=this.stopTimeline)==null||m.call(this)),(x=this.keyframeResolver)==null||x.cancel()},this.createdAt=jt.now();const f={autoplay:t,delay:n,type:r,repeat:i,repeatDelay:o,repeatType:s,name:l,motionValue:c,element:u,...d},p=(u==null?void 0:u.KeyframeResolver)||il;this.keyframeResolver=new p(a,(m,x,y)=>this.onKeyframesResolved(m,x,f,!y),l,c,u),(g=this.keyframeResolver)==null||g.scheduleResolve()}onKeyframesResolved(t,n,r,i){this.keyframeResolver=void 0;const{name:o,type:s,velocity:a,delay:l,isHandoff:c,onUpdate:u}=r;this.resolvedAt=jt.now(),fy(t,o,s,a)||((wn.instantAnimations||!l)&&(u==null||u(tl(t,r,n))),t[0]=t[t.length-1],la(r),r.repeat=0);const f={startTime:i?this.resolvedAt?this.resolvedAt-this.createdAt>gy?this.resolvedAt:this.createdAt:this.createdAt:void 0,finalKeyframe:n,...r,keyframes:t},p=!c&&my(f)?new uy({...f,element:f.motionValue.owner.current}):new rl(f);p.finished.then(()=>this.notifyFinished()).catch(Zt),this.pendingTimeline&&(this.stopTimeline=p.attachTimeline(this.pendingTimeline),this.pendingTimeline=void 0),this._animation=p}get finished(){return this._animation?this.animation.finished:this._finished}then(t,n){return this.finished.finally(t).then(()=>{})}get animation(){var t;return this._animation||((t=this.keyframeResolver)==null||t.resume(),Jb()),this._animation}get duration(){return this.animation.duration}get time(){return this.animation.time}set time(t){this.animation.time=t}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(t){this.animation.speed=t}get startTime(){return this.animation.startTime}attachTimeline(t){return this._animation?this.stopTimeline=this.animation.attachTimeline(t):this.pendingTimeline=t,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){var t;this._animation&&this.animation.cancel(),(t=this.keyframeResolver)==null||t.cancel()}}const yy=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function xy(e){const t=yy.exec(e);if(!t)return[,];const[,n,r,i]=t;return[`--${n??r}`,i]}const wy=4;function Xf(e,t,n=1){xn(n<=wy,`Max CSS variable fallback depth detected in property "${e}". This may indicate a circular fallback dependency.`,"max-css-var-depth");const[r,i]=xy(e);if(!r)return;const o=window.getComputedStyle(t).getPropertyValue(r);if(o){const s=o.trim();return xf(s)?parseFloat(s):s}return Za(i)?Xf(i,t,n+1):i}function ol(e,t){return(e==null?void 0:e[t])??(e==null?void 0:e.default)??e}const Qf=new Set(["width","height","top","left","right","bottom",...Rr]),vy={test:e=>e==="auto",parse:e=>e},Jf=e=>t=>t.test(e),eh=[Ar,we,cn,An,db,ub,vy],Rc=e=>eh.find(Jf(e));function Ey(e){return typeof e=="number"?e===0:e!==null?e==="none"||e==="0"||vf(e):!0}const ky=new Set(["brightness","contrast","saturate","opacity"]);function Sy(e){const[t,n]=e.slice(0,-1).split("(");if(t==="drop-shadow")return e;const[r]=n.match(Xa)||[];if(!r)return e;const i=n.replace(r,"");let o=ky.has(t)?1:0;return r!==n&&(o*=100),t+"("+o+i+")"}const Cy=/\b([a-z-]*)\(.*?\)/gu,ca={...In,getAnimatableNone:e=>{const t=e.match(Cy);return t?t.map(Sy).join(" "):e}},Mc={...Ar,transform:Math.round},_y={rotate:An,rotateX:An,rotateY:An,rotateZ:An,scale:Mi,scaleX:Mi,scaleY:Mi,scaleZ:Mi,skew:An,skewX:An,skewY:An,distance:we,translateX:we,translateY:we,translateZ:we,x:we,y:we,z:we,perspective:we,transformPerspective:we,opacity:ri,originX:yc,originY:yc,originZ:we},sl={borderWidth:we,borderTopWidth:we,borderRightWidth:we,borderBottomWidth:we,borderLeftWidth:we,borderRadius:we,radius:we,borderTopLeftRadius:we,borderTopRightRadius:we,borderBottomRightRadius:we,borderBottomLeftRadius:we,width:we,maxWidth:we,height:we,maxHeight:we,top:we,right:we,bottom:we,left:we,padding:we,paddingTop:we,paddingRight:we,paddingBottom:we,paddingLeft:we,margin:we,marginTop:we,marginRight:we,marginBottom:we,marginLeft:we,backgroundPositionX:we,backgroundPositionY:we,..._y,zIndex:Mc,fillOpacity:ri,strokeOpacity:ri,numOctaves:Mc},Ty={...sl,color:yt,backgroundColor:yt,outlineColor:yt,fill:yt,stroke:yt,borderColor:yt,borderTopColor:yt,borderRightColor:yt,borderBottomColor:yt,borderLeftColor:yt,filter:ca,WebkitFilter:ca},th=e=>Ty[e];function nh(e,t){let n=th(e);return n!==ca&&(n=In),n.getAnimatableNone?n.getAnimatableNone(t):void 0}const Ny=new Set(["auto","none","0"]);function Ay(e,t,n){let r=0,i;for(;r<e.length&&!i;){const o=e[r];typeof o=="string"&&!Ny.has(o)&&ii(o).values.length&&(i=e[r]),r++}if(i&&n)for(const o of t)e[o]=nh(n,i)}class Ry extends il{constructor(t,n,r,i,o){super(t,n,r,i,o,!0)}readKeyframes(){const{unresolvedKeyframes:t,element:n,name:r}=this;if(!n||!n.current)return;super.readKeyframes();for(let l=0;l<t.length;l++){let c=t[l];if(typeof c=="string"&&(c=c.trim(),Za(c))){const u=Xf(c,n.current);u!==void 0&&(t[l]=u),l===t.length-1&&(this.finalKeyframe=c)}}if(this.resolveNoneKeyframes(),!Qf.has(r)||t.length!==2)return;const[i,o]=t,s=Rc(i),a=Rc(o);if(s!==a)if(_c(s)&&_c(a))for(let l=0;l<t.length;l++){const c=t[l];typeof c=="string"&&(t[l]=parseFloat(c))}else Gn[r]&&(this.needsMeasurement=!0)}resolveNoneKeyframes(){const{unresolvedKeyframes:t,name:n}=this,r=[];for(let i=0;i<t.length;i++)(t[i]===null||Ey(t[i]))&&r.push(i);r.length&&Ay(t,r,n)}measureInitialState(){const{element:t,unresolvedKeyframes:n,name:r}=this;if(!t||!t.current)return;r==="height"&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=Gn[r](t.measureViewportBox(),window.getComputedStyle(t.current)),n[0]=this.measuredOrigin;const i=n[n.length-1];i!==void 0&&t.getValue(r,i).jump(i,!1)}measureEndState(){var a;const{element:t,name:n,unresolvedKeyframes:r}=this;if(!t||!t.current)return;const i=t.getValue(n);i&&i.jump(this.measuredOrigin,!1);const o=r.length-1,s=r[o];r[o]=Gn[n](t.measureViewportBox(),window.getComputedStyle(t.current)),s!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=s),(a=this.removedTransforms)!=null&&a.length&&this.removedTransforms.forEach(([l,c])=>{t.getValue(l).set(c)}),this.resolveNoneKeyframes()}}function My(e,t,n){if(e instanceof EventTarget)return[e];if(typeof e=="string"){let r=document;const i=(n==null?void 0:n[e])??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e)}const rh=(e,t)=>t&&typeof e=="number"?t.transform(e):e;function ih(e){return wf(e)&&"offsetHeight"in e}const Ic=30,Iy=e=>!isNaN(parseFloat(e));class Oy{constructor(t,n={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=r=>{var o;const i=jt.now();if(this.updatedAt!==i&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(r),this.current!==this.prev&&((o=this.events.change)==null||o.notify(this.current),this.dependents))for(const s of this.dependents)s.dirty()},this.hasAnimated=!1,this.setCurrent(t),this.owner=n.owner}setCurrent(t){this.current=t,this.updatedAt=jt.now(),this.canTrackVelocity===null&&t!==void 0&&(this.canTrackVelocity=Iy(this.current))}setPrevFrameValue(t=this.current){this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt}onChange(t){return process.env.NODE_ENV!=="production"&&Ga(!1,'value.onChange(callback) is deprecated. Switch to value.on("change", callback).'),this.on("change",t)}on(t,n){this.events[t]||(this.events[t]=new Wa);const r=this.events[t].add(n);return t==="change"?()=>{r(),ot.read(()=>{this.events.change.getSize()||this.stop()})}:r}clearListeners(){for(const t in this.events)this.events[t].clear()}attach(t,n){this.passiveEffect=t,this.stopPassiveEffect=n}set(t){this.passiveEffect?this.passiveEffect(t,this.updateAndNotify):this.updateAndNotify(t)}setWithVelocity(t,n,r){this.set(n),this.prev=void 0,this.prevFrameValue=t,this.prevUpdatedAt=this.updatedAt-r}jump(t,n=!0){this.updateAndNotify(t),this.prev=t,this.prevUpdatedAt=this.prevFrameValue=void 0,n&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){var t;(t=this.events.change)==null||t.notify(this.current)}addDependent(t){this.dependents||(this.dependents=new Set),this.dependents.add(t)}removeDependent(t){this.dependents&&this.dependents.delete(t)}get(){return this.current}getPrevious(){return this.prev}getVelocity(){const t=jt.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||t-this.updatedAt>Ic)return 0;const n=Math.min(this.updatedAt-this.prevUpdatedAt,Ic);return Ef(parseFloat(this.current)-parseFloat(this.prevFrameValue),n)}start(t){return this.stop(),new Promise(n=>{this.hasAnimated=!0,this.animation=t(n),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(){var t,n;(t=this.dependents)==null||t.clear(),(n=this.events.destroy)==null||n.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}}function kr(e,t){return new Oy(e,t)}const{schedule:al}=Of(queueMicrotask,!1),Jt={x:!1,y:!1};function oh(){return Jt.x||Jt.y}function Py(e){return e==="x"||e==="y"?Jt[e]?null:(Jt[e]=!0,()=>{Jt[e]=!1}):Jt.x||Jt.y?null:(Jt.x=Jt.y=!0,()=>{Jt.x=Jt.y=!1})}function sh(e,t){const n=My(e),r=new AbortController,i={passive:!0,...t,signal:r.signal};return[n,i,()=>r.abort()]}function Oc(e){return!(e.pointerType==="touch"||oh())}function Dy(e,t,n={}){const[r,i,o]=sh(e,n),s=a=>{if(!Oc(a))return;const{target:l}=a,c=t(l,a);if(typeof c!="function"||!l)return;const u=d=>{Oc(d)&&(c(d),l.removeEventListener("pointerleave",u))};l.addEventListener("pointerleave",u,i)};return r.forEach(a=>{a.addEventListener("pointerenter",s,i)}),o}const ah=(e,t)=>t?e===t?!0:ah(e,t.parentElement):!1,ll=e=>e.pointerType==="mouse"?typeof e.button!="number"||e.button<=0:e.isPrimary!==!1,Ly=new Set(["BUTTON","INPUT","SELECT","TEXTAREA","A"]);function Fy(e){return Ly.has(e.tagName)||e.tabIndex!==-1}const Qi=new WeakSet;function Pc(e){return t=>{t.key==="Enter"&&e(t)}}function os(e,t){e.dispatchEvent(new PointerEvent("pointer"+t,{isPrimary:!0,bubbles:!0}))}const jy=(e,t)=>{const n=e.currentTarget;if(!n)return;const r=Pc(()=>{if(Qi.has(n))return;os(n,"down");const i=Pc(()=>{os(n,"up")}),o=()=>os(n,"cancel");n.addEventListener("keyup",i,t),n.addEventListener("blur",o,t)});n.addEventListener("keydown",r,t),n.addEventListener("blur",()=>n.removeEventListener("keydown",r),t)};function Dc(e){return ll(e)&&!oh()}function By(e,t,n={}){const[r,i,o]=sh(e,n),s=a=>{const l=a.currentTarget;if(!Dc(a))return;Qi.add(l);const c=t(l,a),u=(p,g)=>{window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",f),Qi.has(l)&&Qi.delete(l),Dc(p)&&typeof c=="function"&&c(p,{success:g})},d=p=>{u(p,l===window||l===document||n.useGlobalTarget||ah(l,p.target))},f=p=>{u(p,!1)};window.addEventListener("pointerup",d,i),window.addEventListener("pointercancel",f,i)};return r.forEach(a=>{(n.useGlobalTarget?window:a).addEventListener("pointerdown",s,i),ih(a)&&(a.addEventListener("focus",c=>jy(c,i)),!Fy(a)&&!a.hasAttribute("tabindex")&&(a.tabIndex=0))}),o}function lh(e){return wf(e)&&"ownerSVGElement"in e}function $y(e){return lh(e)&&e.tagName==="svg"}const Rt=e=>!!(e&&e.getVelocity),Vy=[...eh,yt,In],zy=e=>Vy.find(Jf(e)),cl=A.createContext({transformPagePoint:e=>e,isStatic:!1,reducedMotion:"never"});class Uy extends P.Component{getSnapshotBeforeUpdate(t){const n=this.props.childRef.current;if(n&&t.isPresent&&!this.props.isPresent){const r=n.offsetParent,i=ih(r)&&r.offsetWidth||0,o=this.props.sizeRef.current;o.height=n.offsetHeight||0,o.width=n.offsetWidth||0,o.top=n.offsetTop,o.left=n.offsetLeft,o.right=i-o.width-o.left}return null}componentDidUpdate(){}render(){return this.props.children}}function Hy({children:e,isPresent:t,anchorX:n,root:r}){const i=A.useId(),o=A.useRef(null),s=A.useRef({width:0,height:0,top:0,left:0,right:0}),{nonce:a}=A.useContext(cl);return A.useInsertionEffect(()=>{const{width:l,height:c,top:u,left:d,right:f}=s.current;if(t||!o.current||!l||!c)return;const p=n==="left"?`left: ${d}`:`right: ${f}`;o.current.dataset.motionPopId=i;const g=document.createElement("style");a&&(g.nonce=a);const m=r??document.head;return m.appendChild(g),g.sheet&&g.sheet.insertRule(`
|
|
2
2
|
[data-motion-pop-id="${i}"] {
|
|
3
3
|
position: absolute !important;
|
|
4
4
|
width: ${l}px !important;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
${p}px !important;
|
|
7
7
|
top: ${u}px !important;
|
|
8
8
|
}
|
|
9
|
-
`),()=>{m.contains(g)&&m.removeChild(g)}},[t]),h.jsx(Uy,{isPresent:t,childRef:o,sizeRef:s,children:P.cloneElement(e,{ref:o})})}const Wy=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:o,mode:s,anchorX:a,root:l})=>{const c=$a(Gy),u=A.useId();let d=!0,f=A.useMemo(()=>(d=!1,{id:u,initial:t,isPresent:n,custom:i,onExitComplete:p=>{c.set(p,!0);for(const g of c.values())if(!g)return;r&&r()},register:p=>(c.set(p,!1),()=>c.delete(p))}),[n,c,r]);return o&&d&&(f={...f}),A.useMemo(()=>{c.forEach((p,g)=>c.set(g,!1))},[n]),P.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),s==="popLayout"&&(e=h.jsx(Hy,{isPresent:n,anchorX:a,root:l,children:e})),h.jsx(So.Provider,{value:f,children:e})};function Gy(){return new Map}function ch(e=!0){const t=A.useContext(So);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,o=A.useId();A.useEffect(()=>{if(e)return i(o)},[e]);const s=A.useCallback(()=>e&&r&&r(o),[o,r,e]);return!n&&r?[!1,s]:[!0]}const Ii=e=>e.key||"";function Lc(e){const t=[];return A.Children.forEach(e,n=>{A.isValidElement(n)&&t.push(n)}),t}const Sr=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:o="sync",propagate:s=!1,anchorX:a="left",root:l})=>{const[c,u]=ch(s),d=A.useMemo(()=>Lc(e),[e]),f=s&&!c?[]:d.map(Ii),p=A.useRef(!0),g=A.useRef(d),m=$a(()=>new Map),[x,y]=A.useState(d),[k,E]=A.useState(d);yf(()=>{p.current=!1,g.current=d;for(let C=0;C<k.length;C++){const M=Ii(k[C]);f.includes(M)?m.delete(M):m.get(M)!==!0&&m.set(M,!1)}},[k,f.length,f.join("-")]);const _=[];if(d!==x){let C=[...d];for(let M=0;M<k.length;M++){const N=k[M],O=Ii(N);f.includes(O)||(C.splice(M,0,N),_.push(N))}return o==="wait"&&_.length&&(C=_),E(Lc(C)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&k.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:v}=A.useContext(Ba);return h.jsx(h.Fragment,{children:k.map(C=>{const M=Ii(C),N=s&&!c?!1:d===k||f.includes(M),O=()=>{if(m.has(M))m.set(M,!0);else return;let b=!0;m.forEach(R=>{R||(b=!1)}),b&&(v==null||v(),E(g.current),s&&(u==null||u()),r&&r())};return h.jsx(Wy,{isPresent:N,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:l,onExitComplete:N?void 0:O,anchorX:a,children:C},M)})})},uh=A.createContext({strict:!1}),Fc={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"]},Cr={};for(const e in Fc)Cr[e]={isEnabled:t=>Fc[e].some(n=>!!t[n])};function Ky(e){for(const t in e)Cr[t]={...Cr[t],...e[t]}}const qy=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","ignoreStrict","viewport"]);function fo(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||qy.has(e)}let dh=e=>!fo(e);function Yy(e){typeof e=="function"&&(dh=t=>t.startsWith("on")?!fo(t):e(t))}try{Yy(require("@emotion/is-prop-valid").default)}catch{}function Zy(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||(dh(i)||n===!0&&fo(i)||!t&&!fo(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}const Co=A.createContext({});function _o(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function oi(e){return typeof e=="string"||Array.isArray(e)}const ul=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],dl=["initial",...ul];function To(e){return _o(e.animate)||dl.some(t=>oi(e[t]))}function fh(e){return!!(To(e)||e.variants)}function Xy(e,t){if(To(e)){const{initial:n,animate:r}=e;return{initial:n===!1||oi(n)?n:void 0,animate:oi(r)?r:void 0}}return e.inherit!==!1?t:{}}function Qy(e){const{initial:t,animate:n}=Xy(e,A.useContext(Co));return A.useMemo(()=>({initial:t,animate:n}),[jc(t),jc(n)])}function jc(e){return Array.isArray(e)?e.join(" "):e}const si={};function Jy(e){for(const t in e)si[t]=e[t],Ya(t)&&(si[t].isCSSVariable=!0)}function hh(e,{layout:t,layoutId:n}){return Mr.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!si[e]||e==="opacity")}const ex={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},tx=Rr.length;function nx(e,t,n){let r="",i=!0;for(let o=0;o<tx;o++){const s=Rr[o],a=e[s];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(s.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const c=rh(a,sl[s]);if(!l){i=!1;const u=ex[s]||s;r+=`${u}(${c}) `}n&&(t[s]=c)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function fl(e,t,n){const{style:r,vars:i,transformOrigin:o}=e;let s=!1,a=!1;for(const l in t){const c=t[l];if(Mr.has(l)){s=!0;continue}else if(Ya(l)){i[l]=c;continue}else{const u=rh(c,sl[l]);l.startsWith("origin")?(a=!0,o[l]=u):r[l]=u}}if(t.transform||(s||n?r.transform=nx(t,e.transform,n):r.transform&&(r.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=o;r.transformOrigin=`${l} ${c} ${u}`}}const hl=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ph(e,t,n){for(const r in t)!Rt(t[r])&&!hh(r,n)&&(e[r]=t[r])}function rx({transformTemplate:e},t){return A.useMemo(()=>{const n=hl();return fl(n,t,e),Object.assign({},n.vars,n.style)},[t])}function ix(e,t){const n=e.style||{},r={};return ph(r,n,e),Object.assign(r,rx(e,t)),r}function ox(e,t){const n={},r=ix(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}const sx={offset:"stroke-dashoffset",array:"stroke-dasharray"},ax={offset:"strokeDashoffset",array:"strokeDasharray"};function lx(e,t,n=1,r=0,i=!0){e.pathLength=1;const o=i?sx:ax;e[o.offset]=we.transform(-r);const s=we.transform(t),a=we.transform(n);e[o.array]=`${s} ${a}`}function mh(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:s=0,...a},l,c,u){if(fl(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{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==null?void 0:u.transformBox)??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&lx(d,i,o,s,!1)}const gh=()=>({...hl(),attrs:{}}),bh=e=>typeof e=="string"&&e.toLowerCase()==="svg";function cx(e,t,n,r){const i=A.useMemo(()=>{const o=gh();return mh(o,t,bh(r),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};ph(o,e.style,e),i.style={...o,...i.style}}return i}const ux=["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 pl(e){return typeof e!="string"||e.includes("-")?!1:!!(ux.indexOf(e)>-1||/[A-Z]/u.test(e))}function dx(e,t,n,{latestValues:r},i,o=!1){const a=(pl(e)?cx:ox)(t,r,i,e),l=Zy(t,typeof e=="string",o),c=e!==A.Fragment?{...l,...a,ref:n}:{},{children:u}=t,d=A.useMemo(()=>Rt(u)?u.get():u,[u]);return A.createElement(e,{...c,children:d})}function Bc(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ml(e,t,n,r){if(typeof t=="function"){const[i,o]=Bc(r);t=t(n!==void 0?n:e.custom,i,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,o]=Bc(r);t=t(n!==void 0?n:e.custom,i,o)}return t}function Ji(e){return Rt(e)?e.get():e}function fx({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:hx(n,r,i,e),renderState:t()}}function hx(e,t,n,r){const i={},o=r(e,{});for(const f in o)i[f]=Ji(o[f]);let{initial:s,animate:a}=e;const l=To(e),c=fh(e);t&&c&&!l&&e.inherit!==!1&&(s===void 0&&(s=t.initial),a===void 0&&(a=t.animate));let u=n?n.initial===!1:!1;u=u||s===!1;const d=u?a:s;if(d&&typeof d!="boolean"&&!_o(d)){const f=Array.isArray(d)?d:[d];for(let p=0;p<f.length;p++){const g=ml(e,f[p]);if(g){const{transitionEnd:m,transition:x,...y}=g;for(const k in y){let E=y[k];if(Array.isArray(E)){const _=u?E.length-1:0;E=E[_]}E!==null&&(i[k]=E)}for(const k in m)i[k]=m[k]}}}return i}const yh=e=>(t,n)=>{const r=A.useContext(Co),i=A.useContext(So),o=()=>fx(e,t,r,i);return n?o():$a(o)};function gl(e,t,n){var o;const{style:r}=e,i={};for(const s in r)(Rt(r[s])||t.style&&Rt(t.style[s])||hh(s,e)||((o=n==null?void 0:n.getValue(s))==null?void 0:o.liveStyle)!==void 0)&&(i[s]=r[s]);return i}const px=yh({scrapeMotionValuesFromProps:gl,createRenderState:hl});function xh(e,t,n){const r=gl(e,t,n);for(const i in e)if(Rt(e[i])||Rt(t[i])){const o=Rr.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=e[i]}return r}const mx=yh({scrapeMotionValuesFromProps:xh,createRenderState:gh}),gx=Symbol.for("motionComponentSymbol");function gr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function bx(e,t,n){return A.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):gr(n)&&(n.current=r))},[t])}const bl=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),yx="framerAppearId",wh="data-"+bl(yx),vh=A.createContext({});function xx(e,t,n,r,i){var m,x;const{visualElement:o}=A.useContext(Co),s=A.useContext(uh),a=A.useContext(So),l=A.useContext(cl).reducedMotion,c=A.useRef(null);r=r||s.renderer,!c.current&&r&&(c.current=r(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const u=c.current,d=A.useContext(vh);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&wx(c.current,n,i,d);const f=A.useRef(!1);A.useInsertionEffect(()=>{u&&f.current&&u.update(n,a)});const p=n[wh],g=A.useRef(!!p&&!((m=window.MotionHandoffIsComplete)!=null&&m.call(window,p))&&((x=window.MotionHasOptimisedAnimation)==null?void 0:x.call(window,p)));return yf(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),g.current&&u.animationState&&u.animationState.animateChanges())}),A.useEffect(()=>{u&&(!g.current&&u.animationState&&u.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,p)}),g.current=!1),u.enteringChildren=void 0)}),u}function wx(e,t,n,r){const{layoutId:i,layout:o,drag:s,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Eh(e.parent)),e.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!s||a&&gr(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:u,layoutScroll:l,layoutRoot:c})}function Eh(e){if(e)return e.options.allowProjection!==!1?e.projection:Eh(e.parent)}function ss(e,{forwardMotionProps:t=!1}={},n,r){n&&Ky(n);const i=pl(e)?mx:px;function o(a,l){let c;const u={...A.useContext(cl),...a,layoutId:vx(a)},{isStatic:d}=u,f=Qy(a),p=i(a,d);if(!d&&Va){Ex(u,n);const g=kx(u);c=g.MeasureLayout,f.visualElement=xx(e,p,u,r,g.ProjectionNode)}return h.jsxs(Co.Provider,{value:f,children:[c&&f.visualElement?h.jsx(c,{visualElement:f.visualElement,...u}):null,dx(e,a,bx(p,f.visualElement,l),p,d,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const s=A.forwardRef(o);return s[gx]=e,s}function vx({layoutId:e}){const t=A.useContext(Ba).id;return t&&e!==void 0?t+"-"+e:e}function Ex(e,t){const n=A.useContext(uh).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const r="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Nr(!1,r,"lazy-strict-mode"):xn(!1,r,"lazy-strict-mode")}}function kx(e){const{drag:t,layout:n}=Cr;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Sx(e,t){if(typeof Proxy>"u")return ss;const n=new Map,r=(o,s)=>ss(o,s,e,t),i=(o,s)=>(process.env.NODE_ENV!=="production"&&Ga(!1,"motion() is deprecated. Use motion.create() instead."),r(o,s));return new Proxy(i,{get:(o,s)=>s==="create"?r:(n.has(s)||n.set(s,ss(s,void 0,e,t)),n.get(s))})}function kh({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Cx({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function _x(e,t){if(!t)return e;const 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 as(e){return e===void 0||e===1}function ua({scale:e,scaleX:t,scaleY:n}){return!as(e)||!as(t)||!as(n)}function zn(e){return ua(e)||Sh(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Sh(e){return $c(e.x)||$c(e.y)}function $c(e){return e&&e!=="0%"}function ho(e,t,n){const r=e-n,i=t*r;return n+i}function Vc(e,t,n,r,i){return i!==void 0&&(e=ho(e,i,r)),ho(e,n,r)+t}function da(e,t=0,n=1,r,i){e.min=Vc(e.min,t,n,r,i),e.max=Vc(e.max,t,n,r,i)}function Ch(e,{x:t,y:n}){da(e.x,t.translate,t.scale,t.originPoint),da(e.y,n.translate,n.scale,n.originPoint)}const zc=.999999999999,Uc=1.0000000000001;function Tx(e,t,n,r=!1){const i=n.length;if(!i)return;t.x=t.y=1;let o,s;for(let a=0;a<i;a++){o=n[a],s=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&yr(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),s&&(t.x*=s.x.scale,t.y*=s.y.scale,Ch(e,s)),r&&zn(o.latestValues)&&yr(e,o.latestValues))}t.x<Uc&&t.x>zc&&(t.x=1),t.y<Uc&&t.y>zc&&(t.y=1)}function br(e,t){e.min=e.min+t,e.max=e.max+t}function Hc(e,t,n,r,i=.5){const o=at(e.min,e.max,i);da(e,t,n,o,r)}function yr(e,t){Hc(e.x,t.x,t.scaleX,t.scale,t.originX),Hc(e.y,t.y,t.scaleY,t.scale,t.originY)}function _h(e,t){return kh(_x(e.getBoundingClientRect(),t))}function Nx(e,t,n){const r=_h(e,n),{scroll:i}=t;return i&&(br(r.x,i.offset.x),br(r.y,i.offset.y)),r}const Wc=()=>({translate:0,scale:1,origin:0,originPoint:0}),xr=()=>({x:Wc(),y:Wc()}),Gc=()=>({min:0,max:0}),pt=()=>({x:Gc(),y:Gc()}),fa={current:null},Th={current:!1};function Ax(){if(Th.current=!0,!!Va)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>fa.current=e.matches;e.addEventListener("change",t),t()}else fa.current=!1}const Rx=new WeakMap;function Mx(e,t,n){for(const r in t){const i=t[r],o=n[r];if(Rt(i))e.addValue(r,i);else if(Rt(o))e.addValue(r,kr(i,{owner:e}));else if(o!==i)if(e.hasValue(r)){const s=e.getValue(r);s.liveStyle===!0?s.jump(i):s.hasAnimated||s.set(i)}else{const s=e.getStaticValue(r);e.addValue(r,kr(s!==void 0?s:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const Kc=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Ix{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:o,visualState:s},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=il,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},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=()=>{const f=jt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,it.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=s;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=To(n),this.isVariantNode=fh(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const p=d[f];l[f]!==void 0&&Rt(p)&&p.set(l[f])}}mount(t){var n;this.current=t,Rx.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((r,i)=>this.bindToMotionValue(i,r)),Th.current||Ax(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:fa.current,process.env.NODE_ENV!=="production"&&Ga(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var t;this.projection&&this.projection.unmount(),Mn(this.notifyUpdate),Mn(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const r=this.features[n];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Mr.has(t);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",s=>{this.latestValues[t]=s,this.props.onUpdate&&it.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Cr){const n=Cr[t];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):pt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<Kc.length;r++){const i=Kc[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,s=t[o];s&&(this.propEventSubscriptions[i]=this.on(i,s))}this.prevMotionValues=Mx(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=kr(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(xf(r)||vf(r))?r=parseFloat(r):!zy(r)&&In.test(n)&&(r=nh(t,n)),this.setBaseTarget(t,Rt(r)?r.get():r)),Rt(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var o;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const s=ml(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);s&&(r=s[t])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!Rt(i)?i:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Wa),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){al.render(this.render)}}class Nh extends Ix{constructor(){super(...arguments),this.KeyframeResolver=Ry}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Rt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ah(e,{style:t,vars:n},r,i){const o=e.style;let s;for(s in t)o[s]=t[s];i==null||i.applyProjectionStyles(o,r);for(s in n)o.setProperty(s,n[s])}function Ox(e){return window.getComputedStyle(e)}class Px extends Nh{constructor(){super(...arguments),this.type="html",this.renderInstance=Ah}readValueFromInstance(t,n){var r;if(Mr.has(n))return(r=this.projection)!=null&&r.isProjecting?ra(n):qb(t,n);{const i=Ox(t),o=(Ya(n)?i.getPropertyValue(n):i[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return _h(t,n)}build(t,n,r){fl(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return gl(t,n,r)}}const Rh=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"]);function Dx(e,t,n,r){Ah(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(Rh.has(i)?i:bl(i),t.attrs[i])}class Lx extends Nh{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Mr.has(n)){const r=th(n);return r&&r.default||0}return n=Rh.has(n)?n:bl(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return xh(t,n,r)}build(t,n,r){mh(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,i){Dx(t,n,r,i)}mount(t){this.isSVGTag=bh(t.tagName),super.mount(t)}}const Fx=(e,t)=>pl(e)?new Lx(t):new Px(t,{allowProjection:e!==A.Fragment});function wr(e,t,n){const r=e.getProps();return ml(r,t,n!==void 0?n:r.custom,e)}const ha=e=>Array.isArray(e);function jx(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,kr(n))}function Bx(e){return ha(e)?e[e.length-1]||0:e}function $x(e,t){const n=wr(e,t);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const s in o){const a=Bx(o[s]);jx(e,s,a)}}function Vx(e){return!!(Rt(e)&&e.add)}function pa(e,t){const n=e.getValue("willChange");if(Vx(n))return n.add(t);if(!n&&wn.WillChange){const r=new wn.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function Mh(e){return e.props[wh]}const zx=e=>e!==null;function Ux(e,{repeat:t,repeatType:n="loop"},r){const i=e.filter(zx),o=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[o]}const Hx={type:"spring",stiffness:500,damping:25,restSpeed:10},Wx=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Gx={type:"keyframes",duration:.8},Kx={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},qx=(e,{keyframes:t})=>t.length>2?Gx:Mr.has(e)?e.startsWith("scale")?Wx(t[1]):Hx:Kx;function Yx({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:o,repeatType:s,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const yl=(e,t,n,r={},i,o)=>s=>{const a=ol(r,e)||{},l=a.delay||r.delay||0;let{elapsed:c=0}=r;c=c-en(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:f=>{t.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{s(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:i};Yx(a)||Object.assign(u,qx(e,u)),u.duration&&(u.duration=en(u.duration)),u.repeatDelay&&(u.repeatDelay=en(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(la(u),u.delay===0&&(d=!0)),(wn.instantAnimations||wn.skipAnimations)&&(d=!0,la(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!o&&t.get()!==void 0){const f=Ux(u.keyframes,a);if(f!==void 0){it.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new rl(u):new by(u)};function Zx({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Ih(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:s,...a}=t;r&&(o=r);const l=[],c=i&&e.animationState&&e.animationState.getState()[i];for(const u in a){const d=e.getValue(u,e.latestValues[u]??null),f=a[u];if(f===void 0||c&&Zx(c,u))continue;const p={delay:n,...ol(o||{},u)},g=d.get();if(g!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===g&&!p.velocity)continue;let m=!1;if(window.MotionHandoffAnimation){const y=Mh(e);if(y){const k=window.MotionHandoffAnimation(y,u,it);k!==null&&(p.startTime=k,m=!0)}}pa(e,u),d.start(yl(u,d,f,e.shouldReduceMotion&&Qf.has(u)?{type:!1}:p,e,m));const x=d.animation;x&&l.push(x)}return s&&Promise.all(l).then(()=>{it.update(()=>{s&&$x(e,s)})}),l}function Oh(e,t,n,r=0,i=1){const o=Array.from(e).sort((c,u)=>c.sortNodePosition(u)).indexOf(t),s=e.size,a=(s-1)*r;return typeof n=="function"?n(o,s):i===1?o*r:a-o*r}function ma(e,t,n={}){var l;const r=wr(e,t,n.type==="exit"?(l=e.presenceContext)==null?void 0:l.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const o=r?()=>Promise.all(Ih(e,r,n)):()=>Promise.resolve(),s=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:f}=i;return Xx(e,t,c,u,d,f,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,s]:[s,o];return c().then(()=>u())}else return Promise.all([o(),s(n.delay)])}function Xx(e,t,n=0,r=0,i=0,o=1,s){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(ma(l,t,{...s,delay:n+(typeof r=="function"?0:r)+Oh(e.variantChildren,l,r,i,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function Qx(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const i=t.map(o=>ma(e,o,n));r=Promise.all(i)}else if(typeof t=="string")r=ma(e,t,n);else{const i=typeof t=="function"?wr(e,t,n.custom):t;r=Promise.all(Ih(e,i,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}function Ph(e,t){if(!Array.isArray(t))return!1;const 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}const Jx=dl.length;function Dh(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Dh(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Jx;n++){const r=dl[n],i=e.props[r];(oi(i)||i===!1)&&(t[r]=i)}return t}const e0=[...ul].reverse(),t0=ul.length;function n0(e){return t=>Promise.all(t.map(({animation:n,options:r})=>Qx(e,n,r)))}function r0(e){let t=n0(e),n=qc(),r=!0;const i=l=>(c,u)=>{var f;const d=wr(e,u,l==="exit"?(f=e.presenceContext)==null?void 0:f.custom:void 0);if(d){const{transition:p,transitionEnd:g,...m}=d;c={...c,...m,...g}}return c};function o(l){t=l(e)}function s(l){const{props:c}=e,u=Dh(e.parent)||{},d=[],f=new Set;let p={},g=1/0;for(let x=0;x<t0;x++){const y=e0[x],k=n[y],E=c[y]!==void 0?c[y]:u[y],_=oi(E),v=y===l?k.isActive:null;v===!1&&(g=x);let C=E===u[y]&&E!==c[y]&&_;if(C&&r&&e.manuallyAnimateOnMount&&(C=!1),k.protectedKeys={...p},!k.isActive&&v===null||!E&&!k.prevProp||_o(E)||typeof E=="boolean")continue;const M=i0(k.prevProp,E);let N=M||y===l&&k.isActive&&!C&&_||x>g&&_,O=!1;const b=Array.isArray(E)?E:[E];let R=b.reduce(i(y),{});v===!1&&(R={});const{prevResolvedValues:I={}}=k,B={...I,...R},F=ee=>{N=!0,f.has(ee)&&(O=!0,f.delete(ee)),k.needsAnimating[ee]=!0;const $=e.getValue(ee);$&&($.liveStyle=!1)};for(const ee in B){const $=R[ee],D=I[ee];if(p.hasOwnProperty(ee))continue;let w=!1;ha($)&&ha(D)?w=!Ph($,D):w=$!==D,w?$!=null?F(ee):f.add(ee):$!==void 0&&f.has(ee)?F(ee):k.protectedKeys[ee]=!0}k.prevProp=E,k.prevResolvedValues=R,k.isActive&&(p={...p,...R}),r&&e.blockInitialAnimation&&(N=!1);const q=C&&M;N&&(!q||O)&&d.push(...b.map(ee=>{const $={type:y};if(typeof ee=="string"&&r&&!q&&e.manuallyAnimateOnMount&&e.parent){const{parent:D}=e,w=wr(D,ee);if(D.enteringChildren&&w){const{delayChildren:j}=w.transition||{};$.delay=Oh(D.enteringChildren,e,j)}}return{animation:ee,options:$}}))}if(f.size){const x={};if(typeof c.initial!="boolean"){const y=wr(e,Array.isArray(c.initial)?c.initial[0]:c.initial);y&&y.transition&&(x.transition=y.transition)}f.forEach(y=>{const k=e.getBaseTarget(y),E=e.getValue(y);E&&(E.liveStyle=!0),x[y]=k??null}),d.push({animation:x})}let m=!!d.length;return r&&(c.initial===!1||c.initial===c.animate)&&!e.manuallyAnimateOnMount&&(m=!1),r=!1,m?t(d):Promise.resolve()}function a(l,c){var d;if(n[l].isActive===c)return Promise.resolve();(d=e.variantChildren)==null||d.forEach(f=>{var p;return(p=f.animationState)==null?void 0:p.setActive(l,c)}),n[l].isActive=c;const u=s(l);for(const f in n)n[f].protectedKeys={};return u}return{animateChanges:s,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=qc(),r=!0}}}function i0(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Ph(t,e):!1}function Bn(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function qc(){return{animate:Bn(!0),whileInView:Bn(),whileHover:Bn(),whileTap:Bn(),whileDrag:Bn(),whileFocus:Bn(),exit:Bn()}}class Dn{constructor(t){this.isMounted=!1,this.node=t}update(){}}class o0 extends Dn{constructor(t){super(t),t.animationState||(t.animationState=r0(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();_o(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let s0=0;class a0 extends Dn{constructor(){super(...arguments),this.id=s0++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const l0={animation:{Feature:o0},exit:{Feature:a0}};function ai(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function gi(e){return{point:{x:e.pageX,y:e.pageY}}}const c0=e=>t=>ll(t)&&e(t,gi(t));function Yr(e,t,n,r){return ai(e,t,c0(n),r)}const Lh=1e-4,u0=1-Lh,d0=1+Lh,Fh=.01,f0=0-Fh,h0=0+Fh;function Dt(e){return e.max-e.min}function p0(e,t,n){return Math.abs(e-t)<=n}function Yc(e,t,n,r=.5){e.origin=r,e.originPoint=at(t.min,t.max,e.origin),e.scale=Dt(n)/Dt(t),e.translate=at(n.min,n.max,e.origin)-e.originPoint,(e.scale>=u0&&e.scale<=d0||isNaN(e.scale))&&(e.scale=1),(e.translate>=f0&&e.translate<=h0||isNaN(e.translate))&&(e.translate=0)}function Zr(e,t,n,r){Yc(e.x,t.x,n.x,r?r.originX:void 0),Yc(e.y,t.y,n.y,r?r.originY:void 0)}function Zc(e,t,n){e.min=n.min+t.min,e.max=e.min+Dt(t)}function m0(e,t,n){Zc(e.x,t.x,n.x),Zc(e.y,t.y,n.y)}function Xc(e,t,n){e.min=t.min-n.min,e.max=e.min+Dt(t)}function Xr(e,t,n){Xc(e.x,t.x,n.x),Xc(e.y,t.y,n.y)}function Kt(e){return[e("x"),e("y")]}const jh=({current:e})=>e?e.ownerDocument.defaultView:null,Qc=(e,t)=>Math.abs(e-t);function g0(e,t){const n=Qc(e.x,t.x),r=Qc(e.y,t.y);return Math.sqrt(n**2+r**2)}class Bh{constructor(t,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:s=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=cs(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,g=g0(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!g)return;const{point:m}=f,{timestamp:x}=Tt;this.history.push({...m,timestamp:x});const{onStart:y,onMove:k}=this.handlers;p||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),k&&k(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=ls(p,this.transformPagePoint),it.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:g,onSessionEnd:m,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=cs(f.type==="pointercancel"?this.lastMoveEventInfo:ls(p,this.transformPagePoint),this.history);this.startEvent&&g&&g(f,y),m&&m(f,y)},!ll(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=s,this.contextWindow=i||window;const a=gi(t),l=ls(a,this.transformPagePoint),{point:c}=l,{timestamp:u}=Tt;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(t,cs(l,this.history)),this.removeListeners=hi(Yr(this.contextWindow,"pointermove",this.handlePointerMove),Yr(this.contextWindow,"pointerup",this.handlePointerUp),Yr(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Mn(this.updatePoint)}}function ls(e,t){return t?{point:t(e.point)}:e}function Jc(e,t){return{x:e.x-t.x,y:e.y-t.y}}function cs({point:e},t){return{point:e,delta:Jc(e,$h(t)),offset:Jc(e,b0(t)),velocity:y0(t,.1)}}function b0(e){return e[0]}function $h(e){return e[e.length-1]}function y0(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=$h(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>en(t)));)n--;if(!r)return{x:0,y:0};const o=ln(i.timestamp-r.timestamp);if(o===0)return{x:0,y:0};const s={x:(i.x-r.x)/o,y:(i.y-r.y)/o};return s.x===1/0&&(s.x=0),s.y===1/0&&(s.y=0),s}function x0(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?at(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?at(n,e,r.max):Math.min(e,n)),e}function eu(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function w0(e,{top:t,left:n,bottom:r,right:i}){return{x:eu(e.x,n,i),y:eu(e.y,t,r)}}function tu(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 v0(e,t){return{x:tu(e.x,t.x),y:tu(e.y,t.y)}}function E0(e,t){let n=.5;const r=Dt(e),i=Dt(t);return i>r?n=ni(t.min,t.max-r,e.min):r>i&&(n=ni(e.min,e.max-i,t.min)),yn(0,1,n)}function k0(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ga=.35;function S0(e=ga){return e===!1?e=0:e===!0&&(e=ga),{x:nu(e,"left","right"),y:nu(e,"top","bottom")}}function nu(e,t,n){return{min:ru(e,t),max:ru(e,n)}}function ru(e,t){return typeof e=="number"?e:e[t]||0}const C0=new WeakMap;class _0{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(gi(d).point)},s=(d,f)=>{const{drag:p,dragPropagation:g,onDragStart:m}=this.getProps();if(p&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Py(p),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Kt(y=>{let k=this.getAxisMotionValue(y).get()||0;if(cn.test(k)){const{projection:E}=this.visualElement;if(E&&E.layout){const _=E.layout.layoutBox[y];_&&(k=Dt(_)*(parseFloat(k)/100))}}this.originPoint[y]=k}),m&&it.postRender(()=>m(d,f)),pa(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:g,onDirectionLock:m,onDrag:x}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:y}=f;if(g&&this.currentDirection===null){this.currentDirection=T0(y),this.currentDirection!==null&&m&&m(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),x&&x(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>Kt(d=>{var f;return this.getAnimationState(d)==="paused"&&((f=this.getAxisMotionValue(d).animation)==null?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Bh(t,{onSessionStart:o,onStart:s,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:r,contextWindow:jh(this.visualElement)})}stop(t,n){const r=t||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!r)return;const{velocity:s}=i;this.startAnimation(s);const{onDragEnd:a}=this.getProps();a&&it.postRender(()=>a(r,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:i}=this.getProps();if(!r||!Oi(t,i,this.currentDirection))return;const o=this.getAxisMotionValue(t);let s=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(s=x0(s,this.constraints[t],this.elastic[t])),o.set(s)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,i=this.constraints;t&&gr(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=w0(r.layoutBox,t):this.constraints=!1,this.elastic=S0(n),i!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Kt(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=k0(r.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!gr(t))return!1;const r=t.current;xn(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Nx(r,i.root,this.visualElement.getTransformPagePoint());let s=v0(i.layout.layoutBox,o);if(n){const a=n(Cx(s));this.hasMutatedConstraints=!!a,a&&(s=kh(a))}return s}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:o,dragSnapToOrigin:s,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=Kt(u=>{if(!Oi(u,n,this.currentDirection))return;let d=l&&l[u]||{};s&&(d={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,g={type:"inertia",velocity:r?t[u]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(u,g)});return Promise.all(c).then(a)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return pa(this.visualElement,t),r.start(yl(t,r,0,n,this.visualElement,!1))}stopAnimation(){Kt(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Kt(t=>{var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){Kt(n=>{const{drag:r}=this.getProps();if(!Oi(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:s,max:a}=i.layout.layoutBox[n];o.set(t[n]-at(s,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!gr(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Kt(s=>{const a=this.getAxisMotionValue(s);if(a&&this.constraints!==!1){const l=a.get();i[s]=E0({min:l,max:l},this.constraints[s])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Kt(s=>{if(!Oi(s,t,null))return;const a=this.getAxisMotionValue(s),{min:l,max:c}=this.constraints[s];a.set(at(l,c,i[s]))})}addListeners(){if(!this.visualElement.current)return;C0.set(this.visualElement,this);const t=this.visualElement.current,n=Yr(t,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),r=()=>{const{dragConstraints:l}=this.getProps();gr(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),it.read(r);const s=ai(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(Kt(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].translate))}),this.visualElement.render())});return()=>{s(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:s=ga,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:o,dragElastic:s,dragMomentum:a}}}function Oi(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function T0(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class N0 extends Dn{constructor(t){super(t),this.removeGroupControls=Zt,this.removeListeners=Zt,this.controls=new _0(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Zt}unmount(){this.removeGroupControls(),this.removeListeners()}}const iu=e=>(t,n)=>{e&&it.postRender(()=>e(t,n))};class A0 extends Dn{constructor(){super(...arguments),this.removePointerDownListener=Zt}onPointerDown(t){this.session=new Bh(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:jh(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:iu(t),onStart:iu(n),onMove:r,onEnd:(o,s)=>{delete this.session,i&&it.postRender(()=>i(o,s))}}}mount(){this.removePointerDownListener=Yr(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const eo={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ou(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Fr={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(we.test(e))e=parseFloat(e);else return e;const n=ou(e,t.target.x),r=ou(e,t.target.y);return`${n}% ${r}%`}},R0={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=In.parse(e);if(i.length>5)return r;const o=In.createTransformer(e),s=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+s]/=a,i[1+s]/=l;const c=at(a,l,.5);return typeof i[2+s]=="number"&&(i[2+s]/=c),typeof i[3+s]=="number"&&(i[3+s]/=c),o(i)}};let us=!1;class M0 extends A.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:o}=t;Jy(I0),o&&(n.group&&n.group.add(o),r&&r.register&&i&&r.register(o),us&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),eo.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:i,isPresent:o}=this.props,{projection:s}=r;return s&&(s.isPresent=o,us=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==o?s.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?s.promote():s.relegate()||it.postRender(()=>{const a=s.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),al.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;us=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Vh(e){const[t,n]=ch(),r=A.useContext(Ba);return h.jsx(M0,{...e,layoutGroup:r,switchLayoutGroup:A.useContext(vh),isPresent:t,safeToRemove:n})}const I0={borderRadius:{...Fr,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Fr,borderTopRightRadius:Fr,borderBottomLeftRadius:Fr,borderBottomRightRadius:Fr,boxShadow:R0};function O0(e,t,n){const r=Rt(e)?e:kr(e);return r.start(yl("",r,t,n)),r.animation}const P0=(e,t)=>e.depth-t.depth;class D0{constructor(){this.children=[],this.isDirty=!1}add(t){za(this.children,t),this.isDirty=!0}remove(t){Ua(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(P0),this.isDirty=!1,this.children.forEach(t)}}function L0(e,t){const n=jt.now(),r=({timestamp:i})=>{const o=i-n;o>=t&&(Mn(r),e(o-t))};return it.setup(r,!0),()=>Mn(r)}const zh=["TopLeft","TopRight","BottomLeft","BottomRight"],F0=zh.length,su=e=>typeof e=="string"?parseFloat(e):e,au=e=>typeof e=="number"||we.test(e);function j0(e,t,n,r,i,o){i?(e.opacity=at(0,n.opacity??1,B0(r)),e.opacityExit=at(t.opacity??1,0,$0(r))):o&&(e.opacity=at(t.opacity??1,n.opacity??1,r));for(let s=0;s<F0;s++){const a=`border${zh[s]}Radius`;let l=lu(t,a),c=lu(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||au(l)===au(c)?(e[a]=Math.max(at(su(l),su(c),r),0),(cn.test(c)||cn.test(l))&&(e[a]+="%")):e[a]=c}(t.rotate||n.rotate)&&(e.rotate=at(t.rotate||0,n.rotate||0,r))}function lu(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const B0=Uh(0,.5,Af),$0=Uh(.5,.95,Zt);function Uh(e,t,n){return r=>r<e?0:r>t?1:n(ni(e,t,r))}function cu(e,t){e.min=t.min,e.max=t.max}function Gt(e,t){cu(e.x,t.x),cu(e.y,t.y)}function uu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function du(e,t,n,r,i){return e-=t,e=ho(e,1/n,r),i!==void 0&&(e=ho(e,1/i,r)),e}function V0(e,t=0,n=1,r=.5,i,o=e,s=e){if(cn.test(t)&&(t=parseFloat(t),t=at(s.min,s.max,t/100)-s.min),typeof t!="number")return;let a=at(o.min,o.max,r);e===o&&(a-=t),e.min=du(e.min,t,n,a,i),e.max=du(e.max,t,n,a,i)}function fu(e,t,[n,r,i],o,s){V0(e,t[n],t[r],t[i],t.scale,o,s)}const z0=["x","scaleX","originX"],U0=["y","scaleY","originY"];function hu(e,t,n,r){fu(e.x,t,z0,n?n.x:void 0,r?r.x:void 0),fu(e.y,t,U0,n?n.y:void 0,r?r.y:void 0)}function pu(e){return e.translate===0&&e.scale===1}function Hh(e){return pu(e.x)&&pu(e.y)}function mu(e,t){return e.min===t.min&&e.max===t.max}function H0(e,t){return mu(e.x,t.x)&&mu(e.y,t.y)}function gu(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Wh(e,t){return gu(e.x,t.x)&&gu(e.y,t.y)}function bu(e){return Dt(e.x)/Dt(e.y)}function yu(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class W0{constructor(){this.members=[]}add(t){za(this.members,t),t.scheduleRender()}remove(t){if(Ua(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){r=o;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function G0(e,t,n){let r="";const i=e.x.translate/t.x,o=e.y.translate/t.y,s=(n==null?void 0:n.z)||0;if((i||o||s)&&(r=`translate3d(${i}px, ${o}px, ${s}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:u,rotateX:d,rotateY:f,skewX:p,skewY:g}=n;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),d&&(r+=`rotateX(${d}deg) `),f&&(r+=`rotateY(${f}deg) `),p&&(r+=`skewX(${p}deg) `),g&&(r+=`skewY(${g}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(r+=`scale(${a}, ${l})`),r||"none"}const ds=["","X","Y","Z"],K0=1e3;let q0=0;function fs(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Gh(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Mh(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",it,!(i||o))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Gh(r)}function Kh({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(s={},a=t==null?void 0:t()){this.id=q0++,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.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(X0),this.nodes.forEach(tw),this.nodes.forEach(nw),this.nodes.forEach(Q0)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=s,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new D0)}addEventListener(s,a){return this.eventHandlers.has(s)||this.eventHandlers.set(s,new Wa),this.eventHandlers.get(s).add(a)}notifyListeners(s,...a){const l=this.eventHandlers.get(s);l&&l.notify(...a)}hasListeners(s){return this.eventHandlers.has(s)}mount(s){if(this.instance)return;this.isSVG=lh(s)&&!$y(s),this.instance=s;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(s),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;it.read(()=>{d=window.innerWidth}),e(s,()=>{const p=window.innerWidth;p!==d&&(d=p,this.root.updateBlockedByResize=!0,u&&u(),u=L0(f,250),eo.hasAnimatedSinceResize&&(eo.hasAnimatedSinceResize=!1,this.nodes.forEach(vu)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const g=this.options.transition||c.getDefaultTransition()||aw,{onLayoutAnimationStart:m,onLayoutAnimationComplete:x}=c.getProps(),y=!this.targetLayout||!Wh(this.targetLayout,p),k=!d&&f;if(this.options.layoutRoot||this.resumeFrom||k||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...ol(g,"layout"),onPlay:m,onComplete:x};(c.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(u,k)}else d||vu(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const s=this.getStack();s&&s.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Mn(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(rw),this.animationId++)}getTransformTemplate(){const{visualElement:s}=this.options;return s&&s.getProps().transformTemplate}willUpdate(s=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Gh(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),s&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(xu);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(wu);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ew),this.nodes.forEach(Y0),this.nodes.forEach(Z0)):this.nodes.forEach(wu),this.clearAllSnapshots();const a=jt.now();Tt.delta=yn(0,1e3/60,a-Tt.timestamp),Tt.timestamp=a,Tt.isProcessing=!0,es.update.process(Tt),es.preRender.process(Tt),es.render.process(Tt),Tt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,al.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(J0),this.sharedNodes.forEach(iw)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,it.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){it.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Dt(this.snapshot.measuredBox.x)&&!Dt(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const s=this.layout;this.layout=this.measure(!1),this.layoutCorrected=pt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,s?s.layoutBox:void 0)}updateScroll(s="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===s&&(a=!1),a&&this.instance){const l=r(this.instance);this.scroll={animationId:this.root.animationId,phase:s,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const s=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Hh(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;s&&this.instance&&(a||zn(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(s=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return s&&(l=this.removeTransform(l)),lw(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:s}=this.options;if(!s)return pt();const a=s.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(cw))){const{scroll:u}=this.root;u&&(br(a.x,u.offset.x),br(a.y,u.offset.y))}return a}removeElementScroll(s){var l;const a=pt();if(Gt(a,s),(l=this.scroll)!=null&&l.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:d,options:f}=u;u!==this.root&&d&&f.layoutScroll&&(d.wasRoot&&Gt(a,s),br(a.x,d.offset.x),br(a.y,d.offset.y))}return a}applyTransform(s,a=!1){const l=pt();Gt(l,s);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&yr(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),zn(u.latestValues)&&yr(l,u.latestValues)}return zn(this.latestValues)&&yr(l,this.latestValues),l}removeTransform(s){const a=pt();Gt(a,s);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!zn(c.latestValues))continue;ua(c.latestValues)&&c.updateSnapshot();const u=pt(),d=c.measurePageBox();Gt(u,d),hu(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return zn(this.latestValues)&&hu(a,this.latestValues),a}setTargetDelta(s){this.targetDelta=s,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(s){this.options={...this.options,...s,crossfade:s.crossfade!==void 0?s.crossfade:!0}}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!==Tt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(s=!1){var f;const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(s||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(f=this.parent)!=null&&f.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:d}=this.options;if(!(!this.layout||!(u||d))){if(this.resolvedRelativeTargetAt=Tt.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pt(),this.relativeTargetOrigin=pt(),Xr(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),Gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=pt(),this.targetWithTransforms=pt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),m0(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Gt(this.target,this.layout.layoutBox),Ch(this.target,this.targetDelta)):Gt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pt(),this.relativeTargetOrigin=pt(),Xr(this.relativeTargetOrigin,this.target,p.target),Gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ua(this.parent.latestValues)||Sh(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var g;const s=this.getLead(),a=!!this.resumingFrom||this!==s;let l=!0;if((this.isProjectionDirty||(g=this.parent)!=null&&g.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Tt.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;Gt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Tx(this.layoutCorrected,this.treeScale,this.path,a),s.layout&&!s.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(s.target=s.layout.layoutBox,s.targetWithTransforms=pt());const{target:p}=s;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(uu(this.prevProjectionDelta.x,this.projectionDelta.x),uu(this.prevProjectionDelta.y,this.projectionDelta.y)),Zr(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!yu(this.projectionDelta.x,this.prevProjectionDelta.x)||!yu(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(s=!0){var a;if((a=this.options.visualElement)==null||a.scheduleRender(),s){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=xr(),this.projectionDelta=xr(),this.projectionDeltaWithTransform=xr()}setAnimationOrigin(s,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=xr();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=pt(),p=l?l.source:void 0,g=this.layout?this.layout.source:void 0,m=p!==g,x=this.getStack(),y=!x||x.members.length<=1,k=!!(m&&!y&&this.options.crossfade===!0&&!this.path.some(sw));this.animationProgress=0;let E;this.mixTargetDelta=_=>{const v=_/1e3;Eu(d.x,s.x,v),Eu(d.y,s.y,v),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Xr(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ow(this.relativeTarget,this.relativeTargetOrigin,f,v),E&&H0(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=pt()),Gt(E,this.relativeTarget)),m&&(this.animationValues=u,j0(u,c,this.latestValues,v,k,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=v},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(s){var a,l,c;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(Mn(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=it.update(()=>{eo.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=kr(0)),this.currentAnimation=O0(this.motionValue,[0,1e3],{...s,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),s.onUpdate&&s.onUpdate(u)},onStop:()=>{},onComplete:()=>{s.onComplete&&s.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);const s=this.getStack();s&&s.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(K0),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const s=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=s;if(!(!a||!l||!c)){if(this!==s&&this.layout&&c&&qh(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||pt();const d=Dt(this.layout.layoutBox.x);l.x.min=s.target.x.min,l.x.max=l.x.min+d;const f=Dt(this.layout.layoutBox.y);l.y.min=s.target.y.min,l.y.max=l.y.min+f}Gt(a,l),yr(a,u),Zr(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(s,a){this.sharedNodes.has(s)||this.sharedNodes.set(s,new W0),this.sharedNodes.get(s).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(a):void 0})}isLead(){const s=this.getStack();return s?s.lead===this:!0}getLead(){var a;const{layoutId:s}=this.options;return s?((a=this.getStack())==null?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:s}=this.options;return s?(a=this.getStack())==null?void 0:a.prevLead:void 0}getStack(){const{layoutId:s}=this.options;if(s)return this.root.sharedNodes.get(s)}promote({needsReset:s,transition:a,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),s&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const s=this.getStack();return s?s.relegate(this):!1}resetSkewAndRotation(){const{visualElement:s}=this.options;if(!s)return;let a=!1;const{latestValues:l}=s;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const c={};l.z&&fs("z",s,c,this.animationValues);for(let u=0;u<ds.length;u++)fs(`rotate${ds[u]}`,s,c,this.animationValues),fs(`skew${ds[u]}`,s,c,this.animationValues);s.render();for(const u in c)s.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);s.scheduleRender()}applyProjectionStyles(s,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){s.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,s.visibility="",s.opacity="",s.pointerEvents=Ji(a==null?void 0:a.pointerEvents)||"",s.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(s.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,s.pointerEvents=Ji(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!zn(this.latestValues)&&(s.transform=l?l({},""):"none",this.hasProjected=!1);return}s.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=G0(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),s.transform=d;const{x:f,y:p}=this.projectionDelta;s.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,c.animationValues?s.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:s.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const g in si){if(u[g]===void 0)continue;const{correct:m,applyTo:x,isCSSVariable:y}=si[g],k=d==="none"?u[g]:m(u[g],c);if(x){const E=x.length;for(let _=0;_<E;_++)s[x[_]]=k}else y?this.options.visualElement.renderState.vars[g]=k:s[g]=k}this.options.layoutId&&(s.pointerEvents=c===this?Ji(a==null?void 0:a.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(s=>{var a;return(a=s.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(xu),this.root.sharedNodes.clear()}}}function Y0(e){e.updateLayout()}function Z0(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:i}=e.layout,{animationType:o}=e.options,s=t.source!==e.layout.source;o==="size"?Kt(d=>{const f=s?t.measuredBox[d]:t.layoutBox[d],p=Dt(f);f.min=r[d].min,f.max=f.min+p}):qh(o,t.layoutBox,r)&&Kt(d=>{const f=s?t.measuredBox[d]:t.layoutBox[d],p=Dt(r[d]);f.max=f.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+p)});const a=xr();Zr(a,r,t.layoutBox);const l=xr();s?Zr(l,e.applyTransform(i,!0),t.measuredBox):Zr(l,r,t.layoutBox);const c=!Hh(a);let u=!1;if(!e.resumeFrom){const d=e.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:f,layout:p}=d;if(f&&p){const g=pt();Xr(g,t.layoutBox,f.layoutBox);const m=pt();Xr(m,r,p.layoutBox),Wh(g,m)||(u=!0),d.options.layoutRoot&&(e.relativeTarget=m,e.relativeTargetOrigin=g,e.relativeParent=d)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:l,layoutDelta:a,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function X0(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Q0(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function J0(e){e.clearSnapshot()}function xu(e){e.clearMeasurements()}function wu(e){e.isLayoutDirty=!1}function ew(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function vu(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function tw(e){e.resolveTargetDelta()}function nw(e){e.calcProjection()}function rw(e){e.resetSkewAndRotation()}function iw(e){e.removeLeadSnapshot()}function Eu(e,t,n){e.translate=at(t.translate,0,n),e.scale=at(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ku(e,t,n,r){e.min=at(t.min,n.min,r),e.max=at(t.max,n.max,r)}function ow(e,t,n,r){ku(e.x,t.x,n.x,r),ku(e.y,t.y,n.y,r)}function sw(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const aw={duration:.45,ease:[.4,0,.1,1]},Su=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Cu=Su("applewebkit/")&&!Su("chrome/")?Math.round:Zt;function _u(e){e.min=Cu(e.min),e.max=Cu(e.max)}function lw(e){_u(e.x),_u(e.y)}function qh(e,t,n){return e==="position"||e==="preserve-aspect"&&!p0(bu(t),bu(n),.2)}function cw(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const uw=Kh({attachResizeListener:(e,t)=>ai(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),hs={current:void 0},Yh=Kh({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!hs.current){const e=new uw({});e.mount(window),e.setOptions({layoutScroll:!0}),hs.current=e}return hs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),dw={pan:{Feature:A0},drag:{Feature:N0,ProjectionNode:Yh,MeasureLayout:Vh}};function Tu(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=r[i];o&&it.postRender(()=>o(t,gi(t)))}class fw extends Dn{mount(){const{current:t}=this.node;t&&(this.unmount=Dy(t,(n,r)=>(Tu(this.node,r,"Start"),i=>Tu(this.node,i,"End"))))}unmount(){}}class hw extends Dn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=hi(ai(this.node.current,"focus",()=>this.onFocus()),ai(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nu(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=r[i];o&&it.postRender(()=>o(t,gi(t)))}class pw extends Dn{mount(){const{current:t}=this.node;t&&(this.unmount=By(t,(n,r)=>(Nu(this.node,r,"Start"),(i,{success:o})=>Nu(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const ba=new WeakMap,ps=new WeakMap,mw=e=>{const t=ba.get(e.target);t&&t(e)},gw=e=>{e.forEach(mw)};function bw({root:e,...t}){const n=e||document;ps.has(n)||ps.set(n,{});const r=ps.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(gw,{root:e,...t})),r[i]}function yw(e,t,n){const r=bw(t);return ba.set(e,n),r.observe(e),()=>{ba.delete(e),r.unobserve(e)}}const xw={some:0,all:1};class ww extends Dn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:o}=t,s={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:xw[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,o&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};return yw(this.node.current,s,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(vw(t,n))&&this.startObserver()}unmount(){}}function vw({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Ew={inView:{Feature:ww},tap:{Feature:pw},focus:{Feature:hw},hover:{Feature:fw}},kw={layout:{ProjectionNode:Yh,MeasureLayout:Vh}},Sw={...l0,...Ew,...dw,...kw},Ae=Sx(Sw,Fx);function Cw(e){const[t,n]=A.useState(()=>e.getLocalParticipant()),[r,i]=A.useState(()=>e.getMicrophoneTrack());return A.useEffect(()=>{const o=()=>{const a=e.getLocalParticipant(),l=e.getMicrophoneTrack();console.log("๐ค useVoxketLocalParticipant: Updating state:",{hasParticipant:!!a,hasMicTrack:!!l,isMicEnabled:e.isMicrophoneEnabled,trackPublications:a?a.trackPublications.size:0}),n(a),i(l)};o(),e.on("connection.connected",o),e.on("connection.disconnected",o),e.on("track.muted",o),e.on("track.unmuted",o);const s=e.getRoom();if(s){const a=()=>{console.log("๐ค Track published, updating participant state"),o()},l=()=>{console.log("๐ค Track unpublished, updating participant state"),o()};return s.on("localTrackPublished",a),s.on("localTrackUnpublished",l),()=>{e.off("connection.connected",o),e.off("connection.disconnected",o),e.off("track.muted",o),e.off("track.unmuted",o),s.off("localTrackPublished",a),s.off("localTrackUnpublished",l)}}else return()=>{e.off("connection.connected",o),e.off("connection.disconnected",o),e.off("track.muted",o),e.off("track.unmuted",o)}},[e]),{localParticipant:t,microphoneTrack:r}}function to(e,t,n){const[r,i]=A.useState(!1),[o,s]=A.useState(!1);return A.useEffect(()=>{const l=()=>{let c=!1;switch(t){case"microphone":c=e.isMicrophoneEnabled;break;case"camera":c=e.isCameraEnabled;break;case"screenShare":c=e.isScreenShareEnabled;break}console.log(`๐ฌ useVoxketTrackToggle: ${t} enabled state updated:`,{oldEnabled:r,newEnabled:c,changed:r!==c}),i(c)};return l(),e.on("track.muted",l),e.on("track.unmuted",l),e.on("connection.connected",l),()=>{e.off("track.muted",l),e.off("track.unmuted",l),e.off("connection.connected",l)}},[e,t]),{enabled:r,pending:o,toggle:async l=>{try{s(!0);const c=l!==void 0?l:!r;switch(console.log(`๐ฌ useVoxketTrackToggle: ${t} toggle called`,{currentEnabled:r,targetEnabled:c,forceEnabled:l}),t){case"microphone":await e.toggleMicrophone(c);break;case"camera":await e.toggleCamera(c);break;case"screenShare":c?(console.log("๐ฌ useVoxketTrackToggle: Starting screen share"),await e.startScreenShare()):(console.log("๐ฌ useVoxketTrackToggle: Stopping screen share"),await e.stopScreenShare());break}console.log(`๐ฌ useVoxketTrackToggle: ${t} toggle completed`)}catch(c){console.error(`๐ฌ useVoxketTrackToggle: ${t} toggle failed:`,c)}finally{s(!1)}}}}function _w(e){const[t,n]=A.useState(()=>e.getRoom()),[r,i]=A.useState(()=>e.getConnectionState());return A.useEffect(()=>{const o=()=>{n(e.getRoom()),i(e.getConnectionState())};return e.on("connection.connected",o),e.on("connection.disconnected",o),e.on("connection.connecting",o),()=>{e.off("connection.connected",o),e.off("connection.disconnected",o),e.off("connection.connecting",o)}},[e]),t}function xl(e){const[t,n]=A.useState(()=>e.getIsAgentConnected()),[r,i]=A.useState(()=>e.getCurrentSession()),[o,s]=A.useState(()=>e.getCurrentAgentInfo()),[a,l]=A.useState(()=>e.getAgentState()),[c,u]=A.useState(()=>e.getAgentAudioTrack()),[d,f]=A.useState(()=>e.getAgentVideoTrack());return A.useEffect(()=>{const p=()=>{const E=e.getIsAgentConnected(),_=e.getCurrentSession(),v=e.getCurrentAgentInfo(),C=e.getAgentState(),M=e.getAgentAudioTrack(),N=e.getAgentVideoTrack();console.log("๐ค useVoxketVoiceAssistant: Updating state:",{isAgentConnected:E,hasSession:!!_,sessionId:_==null?void 0:_.id,hasAgentInfo:!!v,agentState:C,hasAudioTrack:!!M,hasVideoTrack:!!N}),n(E),i(_),s(v),l(C),u(M),f(N)};p();const g=()=>{console.log("๐ค useVoxketVoiceAssistant: Agent connected event"),p()},m=()=>{console.log("๐ค useVoxketVoiceAssistant: Agent disconnected event"),p()},x=()=>{console.log("๐ค useVoxketVoiceAssistant: Session changed event"),p()},y=()=>{console.log("๐ค useVoxketVoiceAssistant: Connection changed event"),p()},k=()=>{console.log("๐ค useVoxketVoiceAssistant: Agent state changed event"),p()};return e.on("agent.connected",g),e.on("agent.speaking",g),e.on("agent.thinking",g),e.on("agent.state.changed",k),e.on("connection.disconnected",m),e.on("session.created",x),e.on("session.ended",x),e.on("session.state.changed",x),e.on("connection.connected",y),()=>{e.off("agent.connected",g),e.off("agent.speaking",g),e.off("agent.thinking",g),e.off("agent.state.changed",k),e.off("connection.disconnected",m),e.off("session.created",x),e.off("session.ended",x),e.off("session.state.changed",x),e.off("connection.connected",y)}},[e]),{agent:{isActive:t,info:o},session:r,state:a,audioTrack:c,videoTrack:d}}function Tw(e){const[t,n]=A.useState(()=>e.getVideoTrackRefs()),[r,i]=A.useState(()=>e.getCameraTrackRefs()),[o,s]=A.useState(()=>e.getScreenShareTrackRefs());return A.useEffect(()=>{const a=()=>{const c=e.getVideoTrackRefs(),u=e.getCameraTrackRefs(),d=e.getScreenShareTrackRefs();console.log("๐น useVoxketVideoTracks: Updating tracks:",{videoCount:c.length,cameraCount:u.length,screenShareCount:d.length}),n(c),i(u),s(d)};a(),e.on("connection.connected",a),e.on("connection.disconnected",a),e.on("track.muted",a),e.on("track.unmuted",a),e.on("participant.joined",a),e.on("participant.left",a);const l=e.getRoom();if(l){const c=()=>{console.log("๐น Track event, updating video tracks"),a()};return l.on("localTrackPublished",c),l.on("localTrackUnpublished",c),l.on("trackPublished",c),l.on("trackUnpublished",c),l.on("trackSubscribed",c),l.on("trackUnsubscribed",c),()=>{e.off("connection.connected",a),e.off("connection.disconnected",a),e.off("track.muted",a),e.off("track.unmuted",a),e.off("participant.joined",a),e.off("participant.left",a),l.off("localTrackPublished",c),l.off("localTrackUnpublished",c),l.off("trackPublished",c),l.off("trackUnpublished",c),l.off("trackSubscribed",c),l.off("trackUnsubscribed",c)}}else return()=>{e.off("connection.connected",a),e.off("connection.disconnected",a),e.off("track.muted",a),e.off("track.unmuted",a),e.off("participant.joined",a),e.off("participant.left",a)}},[e]),{videoTrackRefs:t,cameraTrackRefs:r,screenShareTrackRefs:o}}const wl="-",Nw=e=>{const t=Rw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:s=>{const a=s.split(wl);return a[0]===""&&a.length!==1&&a.shift(),Zh(a,t)||Aw(s)},getConflictingClassGroupIds:(s,a)=>{const l=n[s]||[];return a&&r[s]?[...l,...r[s]]:l}}},Zh=(e,t)=>{var s;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?Zh(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const o=e.join(wl);return(s=t.validators.find(({validator:a})=>a(o)))==null?void 0:s.classGroupId},Au=/^\[(.+)\]$/,Aw=e=>{if(Au.test(e)){const t=Au.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Rw=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const i in n)ya(n[i],r,i,t);return r},ya=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const o=i===""?t:Ru(t,i);o.classGroupId=n;return}if(typeof i=="function"){if(Mw(i)){ya(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([o,s])=>{ya(s,Ru(t,o),n,r)})})},Ru=(e,t)=>{let n=e;return t.split(wl).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Mw=e=>e.isThemeGetter,Iw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(o,s)=>{n.set(o,s),t++,t>e&&(t=0,r=n,n=new Map)};return{get(o){let s=n.get(o);if(s!==void 0)return s;if((s=r.get(o))!==void 0)return i(o,s),s},set(o,s){n.has(o)?n.set(o,s):i(o,s)}}},xa="!",wa=":",Ow=wa.length,Pw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const o=[];let s=0,a=0,l=0,c;for(let g=0;g<i.length;g++){let m=i[g];if(s===0&&a===0){if(m===wa){o.push(i.slice(l,g)),l=g+Ow;continue}if(m==="/"){c=g;continue}}m==="["?s++:m==="]"?s--:m==="("?a++:m===")"&&a--}const u=o.length===0?i:i.substring(l),d=Dw(u),f=d!==u,p=c&&c>l?c-l:void 0;return{modifiers:o,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:p}};if(t){const i=t+wa,o=r;r=s=>s.startsWith(i)?o(s.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:s,maybePostfixModifierPosition:void 0}}if(n){const i=r;r=o=>n({className:o,parseClassName:i})}return r},Dw=e=>e.endsWith(xa)?e.substring(0,e.length-1):e.startsWith(xa)?e.substring(1):e,Lw=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let o=[];return r.forEach(s=>{s[0]==="["||t[s]?(i.push(...o.sort(),s),o=[]):o.push(s)}),i.push(...o.sort()),i}},Fw=e=>({cache:Iw(e.cacheSize),parseClassName:Pw(e),sortModifiers:Lw(e),...Nw(e)}),jw=/\s+/,Bw=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o}=t,s=[],a=e.trim().split(jw);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:m}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let x=!!m,y=r(x?g.substring(0,m):g);if(!y){if(!x){l=u+(l.length>0?" "+l:l);continue}if(y=r(g),!y){l=u+(l.length>0?" "+l:l);continue}x=!1}const k=o(f).join(":"),E=p?k+xa:k,_=E+y;if(s.includes(_))continue;s.push(_);const v=i(y,x);for(let C=0;C<v.length;++C){const M=v[C];s.push(E+M)}l=u+(l.length>0?" "+l:l)}return l};function $w(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Xh(t))&&(r&&(r+=" "),r+=n);return r}const Xh=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Xh(e[r]))&&(n&&(n+=" "),n+=t);return n};function Vw(e,...t){let n,r,i,o=s;function s(l){const c=t.reduce((u,d)=>d(u),e());return n=Fw(c),r=n.cache.get,i=n.cache.set,o=a,a(l)}function a(l){const c=r(l);if(c)return c;const u=Bw(l,n);return i(l,u),u}return function(){return o($w.apply(null,arguments))}}const vt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Qh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,zw=/^\d+\/\d+$/,Uw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ww=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Gw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Kw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nr=e=>zw.test(e),Me=e=>!!e&&!Number.isNaN(Number(e)),_n=e=>!!e&&Number.isInteger(Number(e)),ms=e=>e.endsWith("%")&&Me(e.slice(0,-1)),pn=e=>Uw.test(e),qw=()=>!0,Yw=e=>Hw.test(e)&&!Ww.test(e),ep=()=>!1,Zw=e=>Gw.test(e),Xw=e=>Kw.test(e),Qw=e=>!fe(e)&&!he(e),Jw=e=>Ir(e,rp,ep),fe=e=>Qh.test(e),$n=e=>Ir(e,ip,Yw),gs=e=>Ir(e,iv,Me),Mu=e=>Ir(e,tp,ep),ev=e=>Ir(e,np,Xw),Pi=e=>Ir(e,op,Zw),he=e=>Jh.test(e),jr=e=>Or(e,ip),tv=e=>Or(e,ov),Iu=e=>Or(e,tp),nv=e=>Or(e,rp),rv=e=>Or(e,np),Di=e=>Or(e,op,!0),Ir=(e,t,n)=>{const r=Qh.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Or=(e,t,n=!1)=>{const r=Jh.exec(e);return r?r[1]?t(r[1]):n:!1},tp=e=>e==="position"||e==="percentage",np=e=>e==="image"||e==="url",rp=e=>e==="length"||e==="size"||e==="bg-size",ip=e=>e==="length",iv=e=>e==="number",ov=e=>e==="family-name",op=e=>e==="shadow",sv=()=>{const e=vt("color"),t=vt("font"),n=vt("text"),r=vt("font-weight"),i=vt("tracking"),o=vt("leading"),s=vt("breakpoint"),a=vt("container"),l=vt("spacing"),c=vt("radius"),u=vt("shadow"),d=vt("inset-shadow"),f=vt("text-shadow"),p=vt("drop-shadow"),g=vt("blur"),m=vt("perspective"),x=vt("aspect"),y=vt("ease"),k=vt("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[..._(),he,fe],C=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],N=()=>[he,fe,l],O=()=>[nr,"full","auto",...N()],b=()=>[_n,"none","subgrid",he,fe],R=()=>["auto",{span:["full",_n,he,fe]},_n,he,fe],I=()=>[_n,"auto",he,fe],B=()=>["auto","min","max","fr",he,fe],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],ne=()=>["auto",...N()],ee=()=>[nr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],$=()=>[e,he,fe],D=()=>[..._(),Iu,Mu,{position:[he,fe]}],w=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",nv,Jw,{size:[he,fe]}],Y=()=>[ms,jr,$n],S=()=>["","none","full",c,he,fe],H=()=>["",Me,jr,$n],U=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>[Me,ms,Iu,Mu],ue=()=>["","none",g,he,fe],te=()=>["none",Me,he,fe],ae=()=>["none",Me,he,fe],Oe=()=>[Me,he,fe],L=()=>[nr,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pn],breakpoint:[pn],color:[qw],container:[pn],"drop-shadow":[pn],ease:["in","out","in-out"],font:[Qw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pn],shadow:[pn],spacing:["px",Me],text:[pn],"text-shadow":[pn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nr,fe,he,x]}],container:["container"],columns:[{columns:[Me,fe,he,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:v()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[_n,"auto",he,fe]}],basis:[{basis:[nr,"full","auto",a,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Me,nr,"auto","initial","none",fe]}],grow:[{grow:["",Me,he,fe]}],shrink:[{shrink:["",Me,he,fe]}],order:[{order:[_n,"first","last","none",he,fe]}],"grid-cols":[{"grid-cols":b()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":b()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":B()}],"auto-rows":[{"auto-rows":B()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:ne()}],mx:[{mx:ne()}],my:[{my:ne()}],ms:[{ms:ne()}],me:[{me:ne()}],mt:[{mt:ne()}],mr:[{mr:ne()}],mb:[{mb:ne()}],ml:[{ml:ne()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"space-y-reverse":["space-y-reverse"],size:[{size:ee()}],w:[{w:[a,"screen",...ee()]}],"min-w":[{"min-w":[a,"screen","none",...ee()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...ee()]}],h:[{h:["screen","lh",...ee()]}],"min-h":[{"min-h":["screen","lh","none",...ee()]}],"max-h":[{"max-h":["screen","lh",...ee()]}],"font-size":[{text:["base",n,jr,$n]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,he,gs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ms,fe]}],"font-family":[{font:[tv,fe,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,he,fe]}],"line-clamp":[{"line-clamp":[Me,"none",he,gs]}],leading:[{leading:[o,...N()]}],"list-image":[{"list-image":["none",he,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",he,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[Me,"from-font","auto",he,$n]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[Me,"auto",he,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",he,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",he,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:w()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_n,he,fe],radial:["",he,fe],conic:[_n,he,fe]},rv,ev]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:S()}],"rounded-s":[{"rounded-s":S()}],"rounded-e":[{"rounded-e":S()}],"rounded-t":[{"rounded-t":S()}],"rounded-r":[{"rounded-r":S()}],"rounded-b":[{"rounded-b":S()}],"rounded-l":[{"rounded-l":S()}],"rounded-ss":[{"rounded-ss":S()}],"rounded-se":[{"rounded-se":S()}],"rounded-ee":[{"rounded-ee":S()}],"rounded-es":[{"rounded-es":S()}],"rounded-tl":[{"rounded-tl":S()}],"rounded-tr":[{"rounded-tr":S()}],"rounded-br":[{"rounded-br":S()}],"rounded-bl":[{"rounded-bl":S()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":H()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Me,he,fe]}],"outline-w":[{outline:["",Me,jr,$n]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",u,Di,Pi]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",d,Di,Pi]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[Me,$n]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",f,Di,Pi]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[Me,he,fe]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Me]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[he,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[Me]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:w()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",he,fe]}],filter:[{filter:["","none",he,fe]}],blur:[{blur:ue()}],brightness:[{brightness:[Me,he,fe]}],contrast:[{contrast:[Me,he,fe]}],"drop-shadow":[{"drop-shadow":["","none",p,Di,Pi]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",Me,he,fe]}],"hue-rotate":[{"hue-rotate":[Me,he,fe]}],invert:[{invert:["",Me,he,fe]}],saturate:[{saturate:[Me,he,fe]}],sepia:[{sepia:["",Me,he,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",he,fe]}],"backdrop-blur":[{"backdrop-blur":ue()}],"backdrop-brightness":[{"backdrop-brightness":[Me,he,fe]}],"backdrop-contrast":[{"backdrop-contrast":[Me,he,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Me,he,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Me,he,fe]}],"backdrop-invert":[{"backdrop-invert":["",Me,he,fe]}],"backdrop-opacity":[{"backdrop-opacity":[Me,he,fe]}],"backdrop-saturate":[{"backdrop-saturate":[Me,he,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",Me,he,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",he,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Me,"initial",he,fe]}],ease:[{ease:["linear","initial",y,he,fe]}],delay:[{delay:[Me,he,fe]}],animate:[{animate:["none",k,he,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,he,fe]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:Oe()}],"skew-x":[{"skew-x":Oe()}],"skew-y":[{"skew-y":Oe()}],transform:[{transform:[he,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:L()}],"translate-x":[{"translate-x":L()}],"translate-y":[{"translate-y":L()}],"translate-z":[{"translate-z":L()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",he,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",he,fe]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[Me,jr,$n,gs]}],stroke:[{stroke:["none",...$()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},av=Vw(sv);function Qe(...e){return av(ja.clsx(e))}function No(e){var i;if(!e)return{sessionSettings:{},capabilities:{},modality:"voice"};const t={session_timer:((i=e.session_settings)==null?void 0:i.session_timer)||null},n=e.capabilities||{},r=e.modality||"voice";return{sessionSettings:t,capabilities:n,modality:r}}function lv(e,t){return e.capabilities[t]===!0}function Ao(e){return e.sessionSettings.session_timer||null}function sp(e){const t=e.capabilities;return{userVideoEnabled:t.user_video_enabled!==!1,agentAvatarEnabled:t.agent_avatar_enabled!==!1,screenshareEnabled:t.screenshare_session_enabled!==!1}}function ap(e){const t=e.capabilities;return{suggestedReplyEnabled:t.suggested_reply_enabled!==!1,attachmentsEnabled:t.support_in_chat_attachments!==!1}}function lp(e){return{...e.capabilities}}function cp(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}const up=A.forwardRef(({state:e,audioTrack:t,className:n},r)=>h.jsx("div",{ref:r,className:Qe("",n),children:t?h.jsx(Ft.BarVisualizer,{barCount:5,state:e,options:{minHeight:5},trackRef:t,className:Qe("flex aspect-video w-40 items-center justify-center gap-1"),children:h.jsx("span",{className:Qe(["bg-[#6721a4] min-h-2 w-2 rounded-full","origin-center transition-colors duration-250 ease-linear","data-[lk-highlighted=true]:bg-[#5c64f6]","data-[lk-muted=true]:bg-[#222222]"])})}):h.jsx("div",{className:Qe("flex aspect-video w-40 items-center justify-center"),children:h.jsx("div",{className:"flex flex-col items-center justify-center",children:h.jsx("div",{className:"flex gap-1",children:Array.from({length:5}).map((i,o)=>h.jsx("span",{className:Qe(["bg-[#6721a4] min-h-2 w-2 rounded-full","origin-center transition-colors duration-250 ease-linear",e==="speaking"&&"animate-pulse bg-[#5c64f6]",e==="thinking"&&"animate-pulse bg-yellow-500"])},o))})})})}));up.displayName="AgentTile";const cv=({videoTrack:e,className:t,ref:n})=>{var r,i;return!e||!e.publication||!e.participant?h.jsx("div",{ref:n,className:Qe(t),children:h.jsx("div",{className:"w-full h-full bg-gray-200 rounded-md flex items-center justify-center",children:h.jsx("span",{className:"text-gray-500",children:"No video available"})})}):h.jsx("div",{ref:n,className:Qe(t),children:h.jsx(Ft.VideoTrack,{trackRef:e,width:((r=e.publication.dimensions)==null?void 0:r.width)??0,height:((i=e.publication.dimensions)==null?void 0:i.height)??0,className:"rounded-md"})})},uv=Ae.create(Ft.VideoTrack),dv=({trackRef:e,className:t,ref:n})=>{var r,i;return h.jsx("div",{className:Qe("bg-muted overflow-hidden rounded-md",t),children:h.jsx(uv,{ref:n,trackRef:e,width:((r=e==null?void 0:e.publication.dimensions)==null?void 0:r.width)??0,height:((i=e==null?void 0:e.publication.dimensions)==null?void 0:i.height)??0,className:Qe("h-full w-auto")})})},Ou=Ae.create(dv),fv=Ae.create(up),hv=Ae.create(cv),mn={initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},exit:{opacity:0,scale:0},transition:{type:"spring",stiffness:675,damping:75,mass:1}},rr={grid:["h-full w-full","grid gap-x-2 place-content-center","grid-cols-[1fr_1fr] grid-rows-[90px_1fr_90px]"],agentChatOpenWithSecondTile:["col-start-1 row-start-1","self-center justify-self-end"],agentChatOpenWithoutSecondTile:["col-start-1 row-start-1","col-span-2","place-content-center"],agentChatClosed:["col-start-1 row-start-1","col-span-2","place-content-center"],secondTileChatOpen:["col-start-2 row-start-1","self-center justify-self-start"],secondTileChatClosed:["col-start-2 row-start-3","place-content-end"]};function pv(e,t){const{localParticipant:n}=Cw(t),r=n==null?void 0:n.getTrackPublication(e);return A.useMemo(()=>r&&n?{source:e,participant:n,publication:r}:void 0,[e,r,n])}function mv({chatOpen:e,client:t}){const{agent:{isActive:n=!1}={},session:r,state:i="idle",audioTrack:o,videoTrack:s}=t?xl(t):{agent:{isActive:!1},session:null,state:"idle",audioTrack:null,videoTrack:null},[a]=Ft.useTracks([ce.Track.Source.ScreenShare]),l=pv(ce.Track.Source.Camera,t),c=l&&!l.publication.isMuted,u=a&&!a.publication.isMuted,d=c||u,f=n||r&&r.state==="active",p={...mn.transition,delay:e?0:.15},g={...mn.animate,scale:e?1:3,transition:p},m={...mn.animate,transition:p},x=p,y=p,k=s&&s.publication&&s.participant;return h.jsx("div",{className:"relative w-full h-full z-10 flex items-center justify-center",children:h.jsx("div",{className:"relative w-full h-full max-w-2xl px-4 md:px-0",children:h.jsxs("div",{className:Qe(rr.grid),children:[f&&h.jsx("div",{className:Qe(["grid",!e&&rr.agentChatClosed,e&&d&&rr.agentChatOpenWithSecondTile,e&&!d&&rr.agentChatOpenWithoutSecondTile]),children:h.jsxs("div",{className:"h-full flex items-center justify-center",children:[!k&&h.jsx(fv,{layoutId:"agent",...mn,animate:g,transition:x,state:i,audioTrack:o||void 0,className:Qe(e?"h-[90px]":"h-auto w-full")},"agent"),k&&s&&h.jsx(hv,{layoutId:"avatar",...mn,animate:m,transition:y,videoTrack:s,className:Qe(e?"h-[90px] [&>video]:h-[90px] [&>video]:w-auto":"h-auto w-full")},"avatar")]})}),h.jsx("div",{className:Qe(["grid",e&&rr.secondTileChatOpen,!e&&rr.secondTileChatClosed]),children:h.jsxs("div",{className:"w-full px-10 flex items-center shadow-2xl justify-between",children:[l&&c&&h.jsx(Ou,{layout:"position",layoutId:"camera",...mn,trackRef:l,transition:{...mn.transition,delay:e?0:.15},className:"h-[60px] order-1"},"camera"),u&&h.jsx(Ou,{layout:"position",layoutId:"screen",...mn,trackRef:a,transition:{...mn.transition,delay:e?0:.15},className:"h-[70px] order-2"},"screen")]})})]})})})}const gv={card:" bg-gradient-to-br from-black to-gray-900 border border-gray-900 w-full h-full flex flex-col justify-between overflow-hidden relative rounded-2xl shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-black/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-gray-800/20 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-gray-600/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-gray-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-gray-400 to-gray-500 rounded-full blur-sm opacity-20 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-gray-500 to-gray-600 rounded-full blur-sm opacity-15 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-black to-gray-900 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-white via-gray-200 to-gray-300"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900",promptSlider:"absolute w-full py-3 px-2 bg-gray-900 rounded-xl text-center text-white text-sm transition-opacity duration-700 ease-in-out border border-gray-600",statusIndicator:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-gray-600/30 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-gray-500/20 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-gray-400/15 pulse-ring"},controlBar:"border border-gray-600 rounded-3xl py-4 flex flex-col justify-end h-full bg-gray-900/50 backdrop-blur-sm",chatInput:{container:"bg-gray-900 w-full border-gray-600",textarea:"bg-gray-800 border-none text-white placeholder-gray-400",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-gray-600 text-white",other:"bg-gray-700 text-white"},chatHeader:{container:"bg-gray-900 border-gray-600",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-gray-400 mb-2",suggestedResponse:{container:"bg-gray-800 text-blue-300 border-gray-700 hover:bg-gray-700 hover:text-white"},video:{container:"bg-gradient-to-br from-black to-gray-900 text-white",header:"border-gray-700 bg-gray-900/50",headerButton:"bg-gray-800 hover:bg-gray-700 text-gray-300",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-gray-900/80 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-gray-800 border border-gray-700 shadow-lg",placeholder:"bg-gray-800 text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},bv={card:" bg-gradient-to-br from-white to-gray-50 border border-gray-200 w-full h-full flex flex-col justify-between overflow-hidden relative shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-white/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-blue-500/5 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-purple-500/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-pink-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-blue-500 to-purple-500 rounded-full blur-sm opacity-30 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-pink-500 to-purple-500 rounded-full blur-sm opacity-20 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-white to-gray-50 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-gray-900",secondary:"text-gray-700",muted:"text-gray-500",accent:"bg-clip-text text-transparent bg-gradient-to-r from-blue-600 via-purple-600 to-pink-600"},micButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-white",promptSlider:"absolute w-full py-3 px-2 bg-gray-100 rounded-xl text-center text-gray-700 text-sm transition-opacity duration-700 ease-in-out border border-gray-200",statusIndicator:"w-2 h-2 bg-green-500 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-blue-500/20 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-purple-500/15 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-pink-500/10 pulse-ring"},controlBar:"border border-gray-200 rounded-3xl py-4 flex flex-col justify-end h-full bg-white/80 backdrop-blur-sm",chatInput:{container:"bg-white/90 border-gray-200 shadow-sm",textarea:"bg-white border-none text-gray-900 placeholder-gray-500 ",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 disabled:opacity-50 text-white",attachButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100 bg-blue-50",endButton:"bg-red-50 hover:bg-red-100 text-red-600 border-red-200"},chatMessage:{own:"bg-blue-50 text-gray-900 border border-blue-100",other:"bg-gray-50 text-gray-900 border border-gray-200"},chatHeader:{container:"bg-white border-gray-200",backButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100"},spinner:"w-10 h-10 animate-spin text-blue-500 mb-2",suggestedResponse:{container:"bg-white text-blue-700 border-blue-200 hover:bg-blue-50 hover:text-blue-900"},video:{container:"bg-gradient-to-br from-white to-gray-50 text-gray-900",header:"border-gray-200 bg-white/80",headerButton:"bg-gray-100 hover:bg-gray-200 text-gray-600",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-white/90 backdrop-blur-sm border-t border-gray-200",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-200 hover:bg-gray-300 text-gray-600",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-white border border-gray-200 shadow-sm",placeholder:"bg-gray-50 text-gray-600",avatar:"bg-gray-200 text-gray-600",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},yv={card:" text-white bg-gradient-to-br from-[#171727] to-[#12121F] border border-gray-800 w-full h-full flex flex-col justify-between overflow-hidden relative",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-[#171727]/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-[#3B82F6]/15 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-[#8B5CF6]/25 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-[#EC4899]/20 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full blur-sm opacity-50 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-[#EC4899] to-[#8B5CF6] rounded-full blur-sm opacity-40 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-[#171727] to-[#12121F] rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-[#3B82F6] via-[#8B5CF6] to-[#EC4899]"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 shadow-xl",promptSlider:"absolute w-full py-3 px-2 bg-[#1E1E2E] rounded-xl text-center text-gray-200 text-sm transition-opacity duration-700 ease-in-out border border-gray-700",statusIndicator:"w-2 h-2 bg-[#10B981] rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-[#3B82F6]/40 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-[#8B5CF6]/30 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-[#EC4899]/20 pulse-ring"},controlBar:"border border-border rounded-3xl py-4 flex flex-col justify-end h-full",chatInput:{container:"bg-[#1E1E2E] border-gray-700",textarea:"bg-[#1E1E2E] border-none text-white placeholder-gray-400",sendButton:"bg-[#3B82F6] hover:bg-[#2563EB] disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-[#1E1E2E]/80 text-white",other:"bg-[#1E1E2E] text-white border border-gray-700"},chatHeader:{container:"bg-[#1E1E2E] border-gray-700",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-blue-400 mb-2",suggestedResponse:{container:"bg-[#221f3f] text-white border-none"},video:{container:"bg-gradient-to-br from-[#171727] to-[#12121F] text-white",header:"border-gray-700 bg-[#1E1E2E]/80",headerButton:"bg-[#1E1E2E] hover:bg-gray-700 text-gray-300",statusDot:"bg-[#10B981] animate-pulse",controlsBackground:"bg-[#1E1E2E]/90 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-[#3B82F6] hover:bg-[#2563EB] text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-[#1E1E2E] border border-gray-700 shadow-xl",placeholder:"bg-[#1E1E2E] text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},xv={card:"text-white border border-[#2a3142] w-full h-full flex flex-col justify-between overflow-hidden relative rounded-2xl shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-16 z-10 bg-gradient-to-b from-[#0b1220]/95 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-cyan-400/18 via-transparent to-transparent",cardPurpleBlur:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-72 h-72 bg-gradient-to-br from-sky-500/25 to-transparent rounded-full blur-3xl",cardPinkBlur:"absolute bottom-0 left-0 w-44 h-44 bg-gradient-to-tr from-cyan-300/18 to-transparent rounded-full blur-2xl",cardPulse1:"hidden",cardPulse2:"hidden",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-white",muted:"text-white",accent:"text-cyan-300"},micButton:"absolute w-20 h-20 bg-[#171b26] text-white rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",chatButton:"absolute w-20 h-20 bg-[#171b26] text-white rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-[#171b26] text-white rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-[#0b8c8c] text-white font-medium hover:bg-[#0a7c7c] focus:outline-none focus:ring-2 focus:ring-[#0b8c8c] focus:ring-offset-2 focus:ring-offset-[#161a25] shadow-xl",promptSlider:"absolute w-full py-3 px-2 bg-[#1c2230] rounded-xl text-center text-gray-200 text-sm transition-opacity duration-700 ease-in-out border border-[#2a3142]",statusIndicator:"w-2 h-2 bg-emerald-500 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-cyan-400/20 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-cyan-300/15 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-cyan-200/10 pulse-ring"},controlBar:"border border-[#2a3142] rounded-3xl py-4 flex flex-col justify-end h-full bg-[#161a25] backdrop-blur-0",chatInput:{container:"bg-[#1c2230] w-full border-[#2a3142]",textarea:"bg-[#1c2230] border-none text-white placeholder-gray-400",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-[#2a3142]",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-[#243049] text-white",other:"bg-[#1c2230] text-white border border-[#2a3142]"},chatHeader:{container:"bg-[#1c2230] border-[#2a3142]",backButton:"text-white hover:text-white hover:bg-[#2a3142]"},spinner:"w-10 h-10 animate-spin text-blue-400 mb-2",suggestedResponse:{container:"bg-[#1c2230] text-white border-[#2a3142] hover:bg-[#222a3a] hover:text-white"},video:{container:"bg-[#161a25] text-white",header:"border-[#2a3142] bg-[#1c2230]",headerButton:"bg-[#1c2230] hover:bg-[#2a3142] text-white",statusDot:"bg-emerald-500 animate-pulse",controlsBackground:"bg-[#1c2230] backdrop-blur-0 border-t border-[#2a3142]",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-[#2a3142] hover:bg-[#334056] text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-[#1c2230] border border-[#2a3142] shadow-lg",placeholder:"bg-[#1c2230] text-white",avatar:"bg-[#2a3142] text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},Pu={dark:gv,light:bv,vox:yv,midnight:xv};function Ct(e){return Pu[e]||Pu.vox}function Du({timeout:e}){const[t,n]=A.useState(100),r=A.useRef(null),i=A.useRef(null);return A.useEffect(()=>{if(!e||e<=0)return;n(100),i.current=Date.now();const o=()=>{if(!e||i.current===null)return;const s=Date.now()-i.current,a=Math.max(0,100-s/e*100);n(a),a>0&&(r.current=requestAnimationFrame(o))};return r.current=requestAnimationFrame(o),()=>{r.current&&cancelAnimationFrame(r.current)}},[e]),!e||e<=0?null:h.jsx("div",{className:"w-full h-1 relative top-1 rounded-t-4xl bg-gray-700 overflow-hidden",children:h.jsx(Ae.div,{className:"h-1 rounded-t-4xl dark:bg-white bg-blue-200 ",initial:{width:"100%"},animate:{width:`${Math.max(t,2)}%`},transition:{duration:.1,ease:"linear"},style:{minWidth:"2%"}})})}function li({interaction:e,theme:t,onDismiss:n,client:r,addLocalMessage:i}){var a;if(!e||!e.isVisible||!e.component)return null;const[o]=P.useState(()=>Date.now()),s=()=>e.component?P.createElement(e.component,{handler:e.handler||void 0,timeout:e.timeout,loadData:async c=>{console.log("InteractiveComponent: Loading data:",c)},presentationMode:e.presentationMode,data:e.data,client:r,addLocalMessage:i}):h.jsx("div",{className:"p-4 text-red-500",children:"Component not found"});switch(e.presentationMode){case"fullscreen":return h.jsx(Sr,{children:h.jsxs(Ae.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[9999] bg-black",children:[h.jsxs("div",{className:"flex flex-col",children:[h.jsx(Du,{timeout:e.timeout}),h.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/80 text-white border-b border-gray-700",children:[h.jsx("h3",{className:"text-lg font-semibold",children:e.methodName.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}),h.jsx("button",{onClick:n||((a=e.handler)==null?void 0:a.dismissView),className:"p-2 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",children:h.jsx(ze.X,{className:"w-5 h-5"})})]})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:s()})]})});case"embedded":default:return h.jsx(Sr,{children:h.jsx(Ae.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-fit rounded-lg ",children:h.jsxs("div",{children:[h.jsx(Du,{timeout:e.timeout}),s()]})})})}}function ci({duration:e,theme:t="vox",onTimerExpired:n,className:r="",showIcon:i=!0}){const[o,s]=A.useState(e),[a,l]=A.useState(!1);A.useEffect(()=>{if(o<=0){l(!0),n==null||n();return}const u=setInterval(()=>{s(d=>{const f=d-1;return f<=0?(l(!0),n==null||n(),0):f})},1e3);return()=>clearInterval(u)},[o,n]),A.useEffect(()=>{s(e),l(!1)},[e]);const c=()=>a?"text-red-500":o<=60?"text-orange-500":o<=300?"text-yellow-500":t==="dark"?"text-gray-300":"text-gray-600";return h.jsxs("div",{className:`flex items-center gap-1 text-sm ${c()} ${r}`,children:[i&&h.jsx(ze.Clock,{className:"w-4 h-4"}),h.jsx("span",{className:"font-mono",children:cp(o)}),a&&h.jsx("span",{className:"text-xs ml-1 text-red-500",children:"(Expired)"})]})}const wv=({logLevel:e}={})=>{const t=Ft.useRoomContext();P.useEffect(()=>(ce.setLogLevel(e??"debug"),window.__lk_room=t,()=>{window.__lk_room=void 0}),[t,e])},dp=P.forwardRef((e,t)=>{const{alt:n,color:r="currentColor",size:i="1em",weight:o="regular",mirrored:s=!1,children:a,weights:l,...c}=e;return P.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,fill:r,viewBox:"0 0 256 256",transform:s?"scale(-1, 1)":void 0,...c},!!n&&P.createElement("title",null,n),a,l.get(o))});dp.displayName="SSRBase";const vv=new Map([["bold",P.createElement(P.Fragment,null,P.createElement("path",{d:"M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm33.25,62.75a12,12,0,0,0,8.49-3.52L204.37,68.6a12,12,0,0,0-17-17L164.77,74.26a12,12,0,0,0,8.48,20.49ZM224,116H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"}))],["duotone",P.createElement(P.Fragment,null,P.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),P.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["fill",P.createElement(P.Fragment,null,P.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm33.94,58.75,17-17a8,8,0,0,1,11.32,11.32l-17,17a8,8,0,0,1-11.31-11.31ZM48,136a8,8,0,0,1,0-16H72a8,8,0,0,1,0,16Zm46.06,37.25-17,17a8,8,0,0,1-11.32-11.32l17-17a8,8,0,0,1,11.31,11.31Zm0-79.19a8,8,0,0,1-11.31,0l-17-17A8,8,0,0,1,77.09,65.77l17,17A8,8,0,0,1,94.06,94.06ZM136,208a8,8,0,0,1-16,0V184a8,8,0,0,1,16,0Zm0-136a8,8,0,0,1-16,0V48a8,8,0,0,1,16,0Zm54.23,118.23a8,8,0,0,1-11.32,0l-17-17a8,8,0,0,1,11.31-11.31l17,17A8,8,0,0,1,190.23,190.23ZM208,136H184a8,8,0,0,1,0-16h24a8,8,0,0,1,0,16Z"}))],["light",P.createElement(P.Fragment,null,P.createElement("path",{d:"M134,32V64a6,6,0,0,1-12,0V32a6,6,0,0,1,12,0Zm39.25,56.75A6,6,0,0,0,177.5,87l22.62-22.63a6,6,0,0,0-8.48-8.48L169,78.5a6,6,0,0,0,4.24,10.25ZM224,122H192a6,6,0,0,0,0,12h32a6,6,0,0,0,0-12Zm-46.5,47A6,6,0,0,0,169,177.5l22.63,22.62a6,6,0,0,0,8.48-8.48ZM128,186a6,6,0,0,0-6,6v32a6,6,0,0,0,12,0V192A6,6,0,0,0,128,186ZM78.5,169,55.88,191.64a6,6,0,1,0,8.48,8.48L87,177.5A6,6,0,1,0,78.5,169ZM70,128a6,6,0,0,0-6-6H32a6,6,0,0,0,0,12H64A6,6,0,0,0,70,128ZM64.36,55.88a6,6,0,0,0-8.48,8.48L78.5,87A6,6,0,1,0,87,78.5Z"}))],["regular",P.createElement(P.Fragment,null,P.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["thin",P.createElement(P.Fragment,null,P.createElement("path",{d:"M132,32V64a4,4,0,0,1-8,0V32a4,4,0,0,1,8,0Zm41.25,54.75a4,4,0,0,0,2.83-1.18L198.71,63a4,4,0,0,0-5.66-5.66L170.43,79.92a4,4,0,0,0,2.82,6.83ZM224,124H192a4,4,0,0,0,0,8h32a4,4,0,0,0,0-8Zm-47.92,46.43a4,4,0,1,0-5.65,5.65l22.62,22.63a4,4,0,0,0,5.66-5.66ZM128,188a4,4,0,0,0-4,4v32a4,4,0,0,0,8,0V192A4,4,0,0,0,128,188ZM79.92,170.43,57.29,193.05A4,4,0,0,0,63,198.71l22.62-22.63a4,4,0,1,0-5.65-5.65ZM68,128a4,4,0,0,0-4-4H32a4,4,0,0,0,0,8H64A4,4,0,0,0,68,128ZM63,57.29A4,4,0,0,0,57.29,63L79.92,85.57a4,4,0,1,0,5.65-5.65Z"}))]]),vl=P.forwardRef((e,t)=>P.createElement(dp,{ref:t,...e,weights:vv}));vl.displayName="SpinnerIcon";function Ev({onSendMessage:e,onSendAttachments:t,disabled:n,theme:r,onEndChat:i,attachmentsEnabled:o=!0}){const[s,a]=P.useState(""),[l,c]=P.useState(!1),u=P.useRef(null),d=P.useRef(null),[f,p]=P.useState(!1),g=Ct(r);P.useEffect(()=>{const v=()=>{const C=navigator.userAgent.toLowerCase(),N=["android","iphone","ipad","mobile","tablet"].some(R=>C.includes(R)),O="ontouchstart"in window||navigator.maxTouchPoints>0,b=window.innerWidth<=768;p(N||O&&b)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]);const m=v=>{v.preventDefault(),s.trim()&&!n&&(e(s.trim()),a(""))},x=v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),m(v))},y=v=>{const C=v.target.files;if(C&&C.length>0){const M=Array.from(C),N=M.filter(O=>O.type.startsWith("image/"));if(N.length===0){console.warn("No valid image files selected");return}N.length!==M.length&&console.warn("Some non-image files were filtered out"),t(N),u.current&&(u.current.value="")}},k=()=>{!n&&u.current&&u.current.click()},E=()=>{!n&&f&&d.current&&d.current.click()},_=v=>{const C=v.target.files;if(C&&C.length>0){const M=C[0];M.type.startsWith("image/")?t([M]):console.warn("Selected file is not an image"),d.current&&(d.current.value="")}};return h.jsx("div",{className:"px-4 py-3 !w-full backdrop-blur-xl border-0 shadow-lg ",children:h.jsx("form",{onSubmit:m,className:"flex items-center !w-full",children:h.jsxs("div",{className:`flex items-center gap-2 !w-full backdrop-blur-md rounded-full px-3 py-2 shadow-sm hover:shadow-md focus-within:shadow-lg focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-500/50 transition-all duration-200 border ${r==="light"?"bg-white/90 border-gray-200":g.chatInput.container}`,children:[o&&h.jsx(Ae.button,{type:"button",onClick:k,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${g.chatInput.attachButton}`,disabled:n,"aria-label":"Attach file",children:h.jsx(ze.Paperclip,{className:"w-4 h-4"})}),o&&f&&h.jsx(Ae.button,{type:"button",onClick:E,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${g.chatInput.attachButton}`,disabled:n,"aria-label":"Take photo",children:h.jsx(ze.Camera,{className:"w-4 h-4"})}),o&&h.jsx("input",{ref:u,type:"file",multiple:!0,onChange:y,className:"hidden",accept:"image/*"}),o&&h.jsx("input",{ref:d,type:"file",onChange:_,className:"hidden",accept:"image/*",capture:"environment"}),h.jsx("textarea",{value:s,onChange:v=>a(v.target.value),onKeyDown:x,onFocus:()=>c(!0),onBlur:()=>c(!1),placeholder:"Type your message...",disabled:n,className:`flex-1 px-2 py-1 bg-transparent resize-none min-h-[32px] max-h-20 focus:outline-none text-sm border-0 ${g.chatInput.textarea}`,rows:1,style:{height:"auto",minHeight:"32px"},onInput:v=>{const C=v.target;C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,80)}px`}}),h.jsx(Ae.button,{type:"submit",disabled:n||!s.trim(),whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${s.trim()&&!n?g.chatInput.sendButton:r==="light"?"bg-gray-200 text-gray-400 cursor-not-allowed opacity-70":"bg-gray-600/50 text-gray-500 cursor-not-allowed opacity-50"}`,"aria-label":"Send message",children:h.jsx(ze.SendHorizontal,{className:"w-4 h-4"})}),i&&h.jsx(Ae.button,{type:"button",onClick:i,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${g.chatInput.endButton}`,"aria-label":"End chat",children:h.jsx(ze.PhoneOff,{className:"w-4 h-4"})})]})})})}function kv({text:e,isComplete:t,isRealTimeStream:n=!1,speed:r=50}){const[i,o]=P.useState(""),[s,a]=P.useState(0);return P.useEffect(()=>{if(n){o(e);return}if(t){o(e);return}if(s<e.length){const l=setTimeout(()=>{o(e.slice(0,s+1)),a(s+1)},r);return()=>clearTimeout(l)}},[e,s,t,r,n]),P.useEffect(()=>{n||(a(0),o(""))},[e,n]),h.jsxs("span",{className:"relative",children:[h.jsx("span",{className:"inline-block",children:i}),!t&&h.jsx("span",{className:"inline-flex items-center ml-1",children:[0,1,2].map(l=>h.jsx(Ae.span,{className:"w-1.5 h-1.5 bg-current rounded-full mx-0.5",animate:{y:[0,-4,0],opacity:[.4,1,.4],scale:[.8,1,.8]},transition:{duration:.8,repeat:1/0,repeatType:"mirror",delay:l*.2,ease:"easeInOut"}},l))})]})}function Sv(e,t){return e.startsWith("image/")?ze.Image:e.startsWith("video/")?ze.Video:e.startsWith("audio/")?ze.Music:e.includes("zip")||e.includes("rar")||e.includes("archive")?ze.Archive:ze.FileText}function Cv(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function _v({message:e,theme:t,isOwn:n}){const r=Ct(t),i=e.metadata,o=(i==null?void 0:i.fileName)||"Unknown file",s=(i==null?void 0:i.fileSize)||0,a=(i==null?void 0:i.mimeType)||"application/octet-stream",l=i==null?void 0:i.downloading,c=i==null?void 0:i.uploading,u=(i==null?void 0:i.downloadProgress)||0,d=(i==null?void 0:i.uploadProgress)||0,f=i==null?void 0:i.downloadUrl,p=i==null?void 0:i.file,g=Sv(a),m=l||c,x=l?u:d,y=l?"Downloading...":c?"Uploading...":"Complete",[k,E]=P.useState(null);P.useEffect(()=>{if(f)E(f);else if(p&&a.startsWith("image/")){const M=URL.createObjectURL(p);return E(M),()=>URL.revokeObjectURL(M)}else E(null)},[f,p,a]);const _=()=>{if(f){const M=document.createElement("a");M.href=f,M.download=o,M.click()}},C=a.startsWith("image/")&&k;return h.jsxs("div",{className:"flex flex-col gap-2 max-w-full sm:max-w-sm",children:[C&&h.jsxs("div",{className:"relative rounded-lg overflow-hidden",children:[h.jsx("img",{src:k,alt:o,className:"max-w-full h-auto max-h-48 object-cover rounded-lg cursor-pointer",onClick:_}),h.jsx("div",{className:"absolute inset-0 bg-black/0 hover:bg-black/10 transition-colors duration-200 cursor-pointer"})]}),h.jsxs("div",{className:`
|
|
9
|
+
`),()=>{m.contains(g)&&m.removeChild(g)}},[t]),h.jsx(Uy,{isPresent:t,childRef:o,sizeRef:s,children:P.cloneElement(e,{ref:o})})}const Wy=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:o,mode:s,anchorX:a,root:l})=>{const c=$a(Gy),u=A.useId();let d=!0,f=A.useMemo(()=>(d=!1,{id:u,initial:t,isPresent:n,custom:i,onExitComplete:p=>{c.set(p,!0);for(const g of c.values())if(!g)return;r&&r()},register:p=>(c.set(p,!1),()=>c.delete(p))}),[n,c,r]);return o&&d&&(f={...f}),A.useMemo(()=>{c.forEach((p,g)=>c.set(g,!1))},[n]),P.useEffect(()=>{!n&&!c.size&&r&&r()},[n]),s==="popLayout"&&(e=h.jsx(Hy,{isPresent:n,anchorX:a,root:l,children:e})),h.jsx(So.Provider,{value:f,children:e})};function Gy(){return new Map}function ch(e=!0){const t=A.useContext(So);if(t===null)return[!0,null];const{isPresent:n,onExitComplete:r,register:i}=t,o=A.useId();A.useEffect(()=>{if(e)return i(o)},[e]);const s=A.useCallback(()=>e&&r&&r(o),[o,r,e]);return!n&&r?[!1,s]:[!0]}const Ii=e=>e.key||"";function Lc(e){const t=[];return A.Children.forEach(e,n=>{A.isValidElement(n)&&t.push(n)}),t}const Sr=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:o="sync",propagate:s=!1,anchorX:a="left",root:l})=>{const[c,u]=ch(s),d=A.useMemo(()=>Lc(e),[e]),f=s&&!c?[]:d.map(Ii),p=A.useRef(!0),g=A.useRef(d),m=$a(()=>new Map),[x,y]=A.useState(d),[k,E]=A.useState(d);yf(()=>{p.current=!1,g.current=d;for(let C=0;C<k.length;C++){const M=Ii(k[C]);f.includes(M)?m.delete(M):m.get(M)!==!0&&m.set(M,!1)}},[k,f.length,f.join("-")]);const _=[];if(d!==x){let C=[...d];for(let M=0;M<k.length;M++){const N=k[M],O=Ii(N);f.includes(O)||(C.splice(M,0,N),_.push(N))}return o==="wait"&&_.length&&(C=_),E(Lc(C)),y(d),null}process.env.NODE_ENV!=="production"&&o==="wait"&&k.length>1&&console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);const{forceRender:v}=A.useContext(Ba);return h.jsx(h.Fragment,{children:k.map(C=>{const M=Ii(C),N=s&&!c?!1:d===k||f.includes(M),O=()=>{if(m.has(M))m.set(M,!0);else return;let b=!0;m.forEach(R=>{R||(b=!1)}),b&&(v==null||v(),E(g.current),s&&(u==null||u()),r&&r())};return h.jsx(Wy,{isPresent:N,initial:!p.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:o,root:l,onExitComplete:N?void 0:O,anchorX:a,children:C},M)})})},uh=A.createContext({strict:!1}),Fc={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"]},Cr={};for(const e in Fc)Cr[e]={isEnabled:t=>Fc[e].some(n=>!!t[n])};function Ky(e){for(const t in e)Cr[t]={...Cr[t],...e[t]}}const qy=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","ignoreStrict","viewport"]);function fo(e){return e.startsWith("while")||e.startsWith("drag")&&e!=="draggable"||e.startsWith("layout")||e.startsWith("onTap")||e.startsWith("onPan")||e.startsWith("onLayout")||qy.has(e)}let dh=e=>!fo(e);function Yy(e){typeof e=="function"&&(dh=t=>t.startsWith("on")?!fo(t):e(t))}try{Yy(require("@emotion/is-prop-valid").default)}catch{}function Zy(e,t,n){const r={};for(const i in e)i==="values"&&typeof e.values=="object"||(dh(i)||n===!0&&fo(i)||!t&&!fo(i)||e.draggable&&i.startsWith("onDrag"))&&(r[i]=e[i]);return r}const Co=A.createContext({});function _o(e){return e!==null&&typeof e=="object"&&typeof e.start=="function"}function oi(e){return typeof e=="string"||Array.isArray(e)}const ul=["animate","whileInView","whileFocus","whileHover","whileTap","whileDrag","exit"],dl=["initial",...ul];function To(e){return _o(e.animate)||dl.some(t=>oi(e[t]))}function fh(e){return!!(To(e)||e.variants)}function Xy(e,t){if(To(e)){const{initial:n,animate:r}=e;return{initial:n===!1||oi(n)?n:void 0,animate:oi(r)?r:void 0}}return e.inherit!==!1?t:{}}function Qy(e){const{initial:t,animate:n}=Xy(e,A.useContext(Co));return A.useMemo(()=>({initial:t,animate:n}),[jc(t),jc(n)])}function jc(e){return Array.isArray(e)?e.join(" "):e}const si={};function Jy(e){for(const t in e)si[t]=e[t],Ya(t)&&(si[t].isCSSVariable=!0)}function hh(e,{layout:t,layoutId:n}){return Mr.has(e)||e.startsWith("origin")||(t||n!==void 0)&&(!!si[e]||e==="opacity")}const ex={x:"translateX",y:"translateY",z:"translateZ",transformPerspective:"perspective"},tx=Rr.length;function nx(e,t,n){let r="",i=!0;for(let o=0;o<tx;o++){const s=Rr[o],a=e[s];if(a===void 0)continue;let l=!0;if(typeof a=="number"?l=a===(s.startsWith("scale")?1:0):l=parseFloat(a)===0,!l||n){const c=rh(a,sl[s]);if(!l){i=!1;const u=ex[s]||s;r+=`${u}(${c}) `}n&&(t[s]=c)}}return r=r.trim(),n?r=n(t,i?"":r):i&&(r="none"),r}function fl(e,t,n){const{style:r,vars:i,transformOrigin:o}=e;let s=!1,a=!1;for(const l in t){const c=t[l];if(Mr.has(l)){s=!0;continue}else if(Ya(l)){i[l]=c;continue}else{const u=rh(c,sl[l]);l.startsWith("origin")?(a=!0,o[l]=u):r[l]=u}}if(t.transform||(s||n?r.transform=nx(t,e.transform,n):r.transform&&(r.transform="none")),a){const{originX:l="50%",originY:c="50%",originZ:u=0}=o;r.transformOrigin=`${l} ${c} ${u}`}}const hl=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function ph(e,t,n){for(const r in t)!Rt(t[r])&&!hh(r,n)&&(e[r]=t[r])}function rx({transformTemplate:e},t){return A.useMemo(()=>{const n=hl();return fl(n,t,e),Object.assign({},n.vars,n.style)},[t])}function ix(e,t){const n=e.style||{},r={};return ph(r,n,e),Object.assign(r,rx(e,t)),r}function ox(e,t){const n={},r=ix(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}const sx={offset:"stroke-dashoffset",array:"stroke-dasharray"},ax={offset:"strokeDashoffset",array:"strokeDasharray"};function lx(e,t,n=1,r=0,i=!0){e.pathLength=1;const o=i?sx:ax;e[o.offset]=we.transform(-r);const s=we.transform(t),a=we.transform(n);e[o.array]=`${s} ${a}`}function mh(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:o=1,pathOffset:s=0,...a},l,c,u){if(fl(e,a,c),l){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};const{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==null?void 0:u.transformBox)??"fill-box",delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&lx(d,i,o,s,!1)}const gh=()=>({...hl(),attrs:{}}),bh=e=>typeof e=="string"&&e.toLowerCase()==="svg";function cx(e,t,n,r){const i=A.useMemo(()=>{const o=gh();return mh(o,t,bh(r),e.transformTemplate,e.style),{...o.attrs,style:{...o.style}}},[t]);if(e.style){const o={};ph(o,e.style,e),i.style={...o,...i.style}}return i}const ux=["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 pl(e){return typeof e!="string"||e.includes("-")?!1:!!(ux.indexOf(e)>-1||/[A-Z]/u.test(e))}function dx(e,t,n,{latestValues:r},i,o=!1){const a=(pl(e)?cx:ox)(t,r,i,e),l=Zy(t,typeof e=="string",o),c=e!==A.Fragment?{...l,...a,ref:n}:{},{children:u}=t,d=A.useMemo(()=>Rt(u)?u.get():u,[u]);return A.createElement(e,{...c,children:d})}function Bc(e){const t=[{},{}];return e==null||e.values.forEach((n,r)=>{t[0][r]=n.get(),t[1][r]=n.getVelocity()}),t}function ml(e,t,n,r){if(typeof t=="function"){const[i,o]=Bc(r);t=t(n!==void 0?n:e.custom,i,o)}if(typeof t=="string"&&(t=e.variants&&e.variants[t]),typeof t=="function"){const[i,o]=Bc(r);t=t(n!==void 0?n:e.custom,i,o)}return t}function Ji(e){return Rt(e)?e.get():e}function fx({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:hx(n,r,i,e),renderState:t()}}function hx(e,t,n,r){const i={},o=r(e,{});for(const f in o)i[f]=Ji(o[f]);let{initial:s,animate:a}=e;const l=To(e),c=fh(e);t&&c&&!l&&e.inherit!==!1&&(s===void 0&&(s=t.initial),a===void 0&&(a=t.animate));let u=n?n.initial===!1:!1;u=u||s===!1;const d=u?a:s;if(d&&typeof d!="boolean"&&!_o(d)){const f=Array.isArray(d)?d:[d];for(let p=0;p<f.length;p++){const g=ml(e,f[p]);if(g){const{transitionEnd:m,transition:x,...y}=g;for(const k in y){let E=y[k];if(Array.isArray(E)){const _=u?E.length-1:0;E=E[_]}E!==null&&(i[k]=E)}for(const k in m)i[k]=m[k]}}}return i}const yh=e=>(t,n)=>{const r=A.useContext(Co),i=A.useContext(So),o=()=>fx(e,t,r,i);return n?o():$a(o)};function gl(e,t,n){var o;const{style:r}=e,i={};for(const s in r)(Rt(r[s])||t.style&&Rt(t.style[s])||hh(s,e)||((o=n==null?void 0:n.getValue(s))==null?void 0:o.liveStyle)!==void 0)&&(i[s]=r[s]);return i}const px=yh({scrapeMotionValuesFromProps:gl,createRenderState:hl});function xh(e,t,n){const r=gl(e,t,n);for(const i in e)if(Rt(e[i])||Rt(t[i])){const o=Rr.indexOf(i)!==-1?"attr"+i.charAt(0).toUpperCase()+i.substring(1):i;r[o]=e[i]}return r}const mx=yh({scrapeMotionValuesFromProps:xh,createRenderState:gh}),gx=Symbol.for("motionComponentSymbol");function gr(e){return e&&typeof e=="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function bx(e,t,n){return A.useCallback(r=>{r&&e.onMount&&e.onMount(r),t&&(r?t.mount(r):t.unmount()),n&&(typeof n=="function"?n(r):gr(n)&&(n.current=r))},[t])}const bl=e=>e.replace(/([a-z])([A-Z])/gu,"$1-$2").toLowerCase(),yx="framerAppearId",wh="data-"+bl(yx),vh=A.createContext({});function xx(e,t,n,r,i){var m,x;const{visualElement:o}=A.useContext(Co),s=A.useContext(uh),a=A.useContext(So),l=A.useContext(cl).reducedMotion,c=A.useRef(null);r=r||s.renderer,!c.current&&r&&(c.current=r(e,{visualState:t,parent:o,props:n,presenceContext:a,blockInitialAnimation:a?a.initial===!1:!1,reducedMotionConfig:l}));const u=c.current,d=A.useContext(vh);u&&!u.projection&&i&&(u.type==="html"||u.type==="svg")&&wx(c.current,n,i,d);const f=A.useRef(!1);A.useInsertionEffect(()=>{u&&f.current&&u.update(n,a)});const p=n[wh],g=A.useRef(!!p&&!((m=window.MotionHandoffIsComplete)!=null&&m.call(window,p))&&((x=window.MotionHasOptimisedAnimation)==null?void 0:x.call(window,p)));return yf(()=>{u&&(f.current=!0,window.MotionIsMounted=!0,u.updateFeatures(),u.scheduleRenderMicrotask(),g.current&&u.animationState&&u.animationState.animateChanges())}),A.useEffect(()=>{u&&(!g.current&&u.animationState&&u.animationState.animateChanges(),g.current&&(queueMicrotask(()=>{var y;(y=window.MotionHandoffMarkAsComplete)==null||y.call(window,p)}),g.current=!1),u.enteringChildren=void 0)}),u}function wx(e,t,n,r){const{layoutId:i,layout:o,drag:s,dragConstraints:a,layoutScroll:l,layoutRoot:c,layoutCrossfade:u}=t;e.projection=new n(e.latestValues,t["data-framer-portal-id"]?void 0:Eh(e.parent)),e.projection.setOptions({layoutId:i,layout:o,alwaysMeasureLayout:!!s||a&&gr(a),visualElement:e,animationType:typeof o=="string"?o:"both",initialPromotionConfig:r,crossfade:u,layoutScroll:l,layoutRoot:c})}function Eh(e){if(e)return e.options.allowProjection!==!1?e.projection:Eh(e.parent)}function ss(e,{forwardMotionProps:t=!1}={},n,r){n&&Ky(n);const i=pl(e)?mx:px;function o(a,l){let c;const u={...A.useContext(cl),...a,layoutId:vx(a)},{isStatic:d}=u,f=Qy(a),p=i(a,d);if(!d&&Va){Ex(u,n);const g=kx(u);c=g.MeasureLayout,f.visualElement=xx(e,p,u,r,g.ProjectionNode)}return h.jsxs(Co.Provider,{value:f,children:[c&&f.visualElement?h.jsx(c,{visualElement:f.visualElement,...u}):null,dx(e,a,bx(p,f.visualElement,l),p,d,t)]})}o.displayName=`motion.${typeof e=="string"?e:`create(${e.displayName??e.name??""})`}`;const s=A.forwardRef(o);return s[gx]=e,s}function vx({layoutId:e}){const t=A.useContext(Ba).id;return t&&e!==void 0?t+"-"+e:e}function Ex(e,t){const n=A.useContext(uh).strict;if(process.env.NODE_ENV!=="production"&&t&&n){const r="You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";e.ignoreStrict?Nr(!1,r,"lazy-strict-mode"):xn(!1,r,"lazy-strict-mode")}}function kx(e){const{drag:t,layout:n}=Cr;if(!t&&!n)return{};const r={...t,...n};return{MeasureLayout:t!=null&&t.isEnabled(e)||n!=null&&n.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Sx(e,t){if(typeof Proxy>"u")return ss;const n=new Map,r=(o,s)=>ss(o,s,e,t),i=(o,s)=>(process.env.NODE_ENV!=="production"&&Ga(!1,"motion() is deprecated. Use motion.create() instead."),r(o,s));return new Proxy(i,{get:(o,s)=>s==="create"?r:(n.has(s)||n.set(s,ss(s,void 0,e,t)),n.get(s))})}function kh({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Cx({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function _x(e,t){if(!t)return e;const 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 as(e){return e===void 0||e===1}function ua({scale:e,scaleX:t,scaleY:n}){return!as(e)||!as(t)||!as(n)}function zn(e){return ua(e)||Sh(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function Sh(e){return $c(e.x)||$c(e.y)}function $c(e){return e&&e!=="0%"}function ho(e,t,n){const r=e-n,i=t*r;return n+i}function Vc(e,t,n,r,i){return i!==void 0&&(e=ho(e,i,r)),ho(e,n,r)+t}function da(e,t=0,n=1,r,i){e.min=Vc(e.min,t,n,r,i),e.max=Vc(e.max,t,n,r,i)}function Ch(e,{x:t,y:n}){da(e.x,t.translate,t.scale,t.originPoint),da(e.y,n.translate,n.scale,n.originPoint)}const zc=.999999999999,Uc=1.0000000000001;function Tx(e,t,n,r=!1){const i=n.length;if(!i)return;t.x=t.y=1;let o,s;for(let a=0;a<i;a++){o=n[a],s=o.projectionDelta;const{visualElement:l}=o.options;l&&l.props.style&&l.props.style.display==="contents"||(r&&o.options.layoutScroll&&o.scroll&&o!==o.root&&yr(e,{x:-o.scroll.offset.x,y:-o.scroll.offset.y}),s&&(t.x*=s.x.scale,t.y*=s.y.scale,Ch(e,s)),r&&zn(o.latestValues)&&yr(e,o.latestValues))}t.x<Uc&&t.x>zc&&(t.x=1),t.y<Uc&&t.y>zc&&(t.y=1)}function br(e,t){e.min=e.min+t,e.max=e.max+t}function Hc(e,t,n,r,i=.5){const o=at(e.min,e.max,i);da(e,t,n,o,r)}function yr(e,t){Hc(e.x,t.x,t.scaleX,t.scale,t.originX),Hc(e.y,t.y,t.scaleY,t.scale,t.originY)}function _h(e,t){return kh(_x(e.getBoundingClientRect(),t))}function Nx(e,t,n){const r=_h(e,n),{scroll:i}=t;return i&&(br(r.x,i.offset.x),br(r.y,i.offset.y)),r}const Wc=()=>({translate:0,scale:1,origin:0,originPoint:0}),xr=()=>({x:Wc(),y:Wc()}),Gc=()=>({min:0,max:0}),pt=()=>({x:Gc(),y:Gc()}),fa={current:null},Th={current:!1};function Ax(){if(Th.current=!0,!!Va)if(window.matchMedia){const e=window.matchMedia("(prefers-reduced-motion)"),t=()=>fa.current=e.matches;e.addEventListener("change",t),t()}else fa.current=!1}const Rx=new WeakMap;function Mx(e,t,n){for(const r in t){const i=t[r],o=n[r];if(Rt(i))e.addValue(r,i);else if(Rt(o))e.addValue(r,kr(i,{owner:e}));else if(o!==i)if(e.hasValue(r)){const s=e.getValue(r);s.liveStyle===!0?s.jump(i):s.hasAnimated||s.set(i)}else{const s=e.getStaticValue(r);e.addValue(r,kr(s!==void 0?s:i,{owner:e}))}}for(const r in n)t[r]===void 0&&e.removeValue(r);return t}const Kc=["AnimationStart","AnimationComplete","Update","BeforeLayoutMeasure","LayoutMeasure","LayoutAnimationStart","LayoutAnimationComplete"];class Ix{scrapeMotionValuesFromProps(t,n,r){return{}}constructor({parent:t,props:n,presenceContext:r,reducedMotionConfig:i,blockInitialAnimation:o,visualState:s},a={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.values=new Map,this.KeyframeResolver=il,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},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=()=>{const f=jt.now();this.renderScheduledAt<f&&(this.renderScheduledAt=f,ot.render(this.render,!1,!0))};const{latestValues:l,renderState:c}=s;this.latestValues=l,this.baseTarget={...l},this.initialValues=n.initial?{...l}:{},this.renderState=c,this.parent=t,this.props=n,this.presenceContext=r,this.depth=t?t.depth+1:0,this.reducedMotionConfig=i,this.options=a,this.blockInitialAnimation=!!o,this.isControllingVariants=To(n),this.isVariantNode=fh(n),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(t&&t.current);const{willChange:u,...d}=this.scrapeMotionValuesFromProps(n,{},this);for(const f in d){const p=d[f];l[f]!==void 0&&Rt(p)&&p.set(l[f])}}mount(t){var n;this.current=t,Rx.set(t,this),this.projection&&!this.projection.instance&&this.projection.mount(t),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((r,i)=>this.bindToMotionValue(i,r)),Th.current||Ax(),this.shouldReduceMotion=this.reducedMotionConfig==="never"?!1:this.reducedMotionConfig==="always"?!0:fa.current,process.env.NODE_ENV!=="production"&&Ga(this.shouldReduceMotion!==!0,"You have Reduced Motion enabled on your device. Animations may not appear as expected.","reduced-motion-disabled"),(n=this.parent)==null||n.addChild(this),this.update(this.props,this.presenceContext)}unmount(){var t;this.projection&&this.projection.unmount(),Mn(this.notifyUpdate),Mn(this.render),this.valueSubscriptions.forEach(n=>n()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),(t=this.parent)==null||t.removeChild(this);for(const n in this.events)this.events[n].clear();for(const n in this.features){const r=this.features[n];r&&(r.unmount(),r.isMounted=!1)}this.current=null}addChild(t){this.children.add(t),this.enteringChildren??(this.enteringChildren=new Set),this.enteringChildren.add(t)}removeChild(t){this.children.delete(t),this.enteringChildren&&this.enteringChildren.delete(t)}bindToMotionValue(t,n){this.valueSubscriptions.has(t)&&this.valueSubscriptions.get(t)();const r=Mr.has(t);r&&this.onBindTransform&&this.onBindTransform();const i=n.on("change",s=>{this.latestValues[t]=s,this.props.onUpdate&&ot.preRender(this.notifyUpdate),r&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()});let o;window.MotionCheckAppearSync&&(o=window.MotionCheckAppearSync(this,t,n)),this.valueSubscriptions.set(t,()=>{i(),o&&o(),n.owner&&n.stop()})}sortNodePosition(t){return!this.current||!this.sortInstanceNodePosition||this.type!==t.type?0:this.sortInstanceNodePosition(this.current,t.current)}updateFeatures(){let t="animation";for(t in Cr){const n=Cr[t];if(!n)continue;const{isEnabled:r,Feature:i}=n;if(!this.features[t]&&i&&r(this.props)&&(this.features[t]=new i(this)),this.features[t]){const o=this.features[t];o.isMounted?o.update():(o.mount(),o.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):pt()}getStaticValue(t){return this.latestValues[t]}setStaticValue(t,n){this.latestValues[t]=n}update(t,n){(t.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=t,this.prevPresenceContext=this.presenceContext,this.presenceContext=n;for(let r=0;r<Kc.length;r++){const i=Kc[r];this.propEventSubscriptions[i]&&(this.propEventSubscriptions[i](),delete this.propEventSubscriptions[i]);const o="on"+i,s=t[o];s&&(this.propEventSubscriptions[i]=this.on(i,s))}this.prevMotionValues=Mx(this,this.scrapeMotionValuesFromProps(t,this.prevProps,this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(t){return this.props.variants?this.props.variants[t]: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(t){const n=this.getClosestVariantNode();if(n)return n.variantChildren&&n.variantChildren.add(t),()=>n.variantChildren.delete(t)}addValue(t,n){const r=this.values.get(t);n!==r&&(r&&this.removeValue(t),this.bindToMotionValue(t,n),this.values.set(t,n),this.latestValues[t]=n.get())}removeValue(t){this.values.delete(t);const n=this.valueSubscriptions.get(t);n&&(n(),this.valueSubscriptions.delete(t)),delete this.latestValues[t],this.removeValueFromRenderState(t,this.renderState)}hasValue(t){return this.values.has(t)}getValue(t,n){if(this.props.values&&this.props.values[t])return this.props.values[t];let r=this.values.get(t);return r===void 0&&n!==void 0&&(r=kr(n===null?void 0:n,{owner:this}),this.addValue(t,r)),r}readValue(t,n){let r=this.latestValues[t]!==void 0||!this.current?this.latestValues[t]:this.getBaseTargetFromProps(this.props,t)??this.readValueFromInstance(this.current,t,this.options);return r!=null&&(typeof r=="string"&&(xf(r)||vf(r))?r=parseFloat(r):!zy(r)&&In.test(n)&&(r=nh(t,n)),this.setBaseTarget(t,Rt(r)?r.get():r)),Rt(r)?r.get():r}setBaseTarget(t,n){this.baseTarget[t]=n}getBaseTarget(t){var o;const{initial:n}=this.props;let r;if(typeof n=="string"||typeof n=="object"){const s=ml(this.props,n,(o=this.presenceContext)==null?void 0:o.custom);s&&(r=s[t])}if(n&&r!==void 0)return r;const i=this.getBaseTargetFromProps(this.props,t);return i!==void 0&&!Rt(i)?i:this.initialValues[t]!==void 0&&r===void 0?void 0:this.baseTarget[t]}on(t,n){return this.events[t]||(this.events[t]=new Wa),this.events[t].add(n)}notify(t,...n){this.events[t]&&this.events[t].notify(...n)}scheduleRenderMicrotask(){al.render(this.render)}}class Nh extends Ix{constructor(){super(...arguments),this.KeyframeResolver=Ry}sortInstanceNodePosition(t,n){return t.compareDocumentPosition(n)&2?1:-1}getBaseTargetFromProps(t,n){return t.style?t.style[n]:void 0}removeValueFromRenderState(t,{vars:n,style:r}){delete n[t],delete r[t]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);const{children:t}=this.props;Rt(t)&&(this.childSubscription=t.on("change",n=>{this.current&&(this.current.textContent=`${n}`)}))}}function Ah(e,{style:t,vars:n},r,i){const o=e.style;let s;for(s in t)o[s]=t[s];i==null||i.applyProjectionStyles(o,r);for(s in n)o.setProperty(s,n[s])}function Ox(e){return window.getComputedStyle(e)}class Px extends Nh{constructor(){super(...arguments),this.type="html",this.renderInstance=Ah}readValueFromInstance(t,n){var r;if(Mr.has(n))return(r=this.projection)!=null&&r.isProjecting?ra(n):qb(t,n);{const i=Ox(t),o=(Ya(n)?i.getPropertyValue(n):i[n])||0;return typeof o=="string"?o.trim():o}}measureInstanceViewportBox(t,{transformPagePoint:n}){return _h(t,n)}build(t,n,r){fl(t,n,r.transformTemplate)}scrapeMotionValuesFromProps(t,n,r){return gl(t,n,r)}}const Rh=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"]);function Dx(e,t,n,r){Ah(e,t,void 0,r);for(const i in t.attrs)e.setAttribute(Rh.has(i)?i:bl(i),t.attrs[i])}class Lx extends Nh{constructor(){super(...arguments),this.type="svg",this.isSVGTag=!1,this.measureInstanceViewportBox=pt}getBaseTargetFromProps(t,n){return t[n]}readValueFromInstance(t,n){if(Mr.has(n)){const r=th(n);return r&&r.default||0}return n=Rh.has(n)?n:bl(n),t.getAttribute(n)}scrapeMotionValuesFromProps(t,n,r){return xh(t,n,r)}build(t,n,r){mh(t,n,this.isSVGTag,r.transformTemplate,r.style)}renderInstance(t,n,r,i){Dx(t,n,r,i)}mount(t){this.isSVGTag=bh(t.tagName),super.mount(t)}}const Fx=(e,t)=>pl(e)?new Lx(t):new Px(t,{allowProjection:e!==A.Fragment});function wr(e,t,n){const r=e.getProps();return ml(r,t,n!==void 0?n:r.custom,e)}const ha=e=>Array.isArray(e);function jx(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,kr(n))}function Bx(e){return ha(e)?e[e.length-1]||0:e}function $x(e,t){const n=wr(e,t);let{transitionEnd:r={},transition:i={},...o}=n||{};o={...o,...r};for(const s in o){const a=Bx(o[s]);jx(e,s,a)}}function Vx(e){return!!(Rt(e)&&e.add)}function pa(e,t){const n=e.getValue("willChange");if(Vx(n))return n.add(t);if(!n&&wn.WillChange){const r=new wn.WillChange("auto");e.addValue("willChange",r),r.add(t)}}function Mh(e){return e.props[wh]}const zx=e=>e!==null;function Ux(e,{repeat:t,repeatType:n="loop"},r){const i=e.filter(zx),o=t&&n!=="loop"&&t%2===1?0:i.length-1;return i[o]}const Hx={type:"spring",stiffness:500,damping:25,restSpeed:10},Wx=e=>({type:"spring",stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Gx={type:"keyframes",duration:.8},Kx={type:"keyframes",ease:[.25,.1,.35,1],duration:.3},qx=(e,{keyframes:t})=>t.length>2?Gx:Mr.has(e)?e.startsWith("scale")?Wx(t[1]):Hx:Kx;function Yx({when:e,delay:t,delayChildren:n,staggerChildren:r,staggerDirection:i,repeat:o,repeatType:s,repeatDelay:a,from:l,elapsed:c,...u}){return!!Object.keys(u).length}const yl=(e,t,n,r={},i,o)=>s=>{const a=ol(r,e)||{},l=a.delay||r.delay||0;let{elapsed:c=0}=r;c=c-en(l);const u={keyframes:Array.isArray(n)?n:[null,n],ease:"easeOut",velocity:t.getVelocity(),...a,delay:-c,onUpdate:f=>{t.set(f),a.onUpdate&&a.onUpdate(f)},onComplete:()=>{s(),a.onComplete&&a.onComplete()},name:e,motionValue:t,element:o?void 0:i};Yx(a)||Object.assign(u,qx(e,u)),u.duration&&(u.duration=en(u.duration)),u.repeatDelay&&(u.repeatDelay=en(u.repeatDelay)),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(la(u),u.delay===0&&(d=!0)),(wn.instantAnimations||wn.skipAnimations)&&(d=!0,la(u),u.delay=0),u.allowFlatten=!a.type&&!a.ease,d&&!o&&t.get()!==void 0){const f=Ux(u.keyframes,a);if(f!==void 0){ot.update(()=>{u.onUpdate(f),u.onComplete()});return}}return a.isSync?new rl(u):new by(u)};function Zx({protectedKeys:e,needsAnimating:t},n){const r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function Ih(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:o=e.getDefaultTransition(),transitionEnd:s,...a}=t;r&&(o=r);const l=[],c=i&&e.animationState&&e.animationState.getState()[i];for(const u in a){const d=e.getValue(u,e.latestValues[u]??null),f=a[u];if(f===void 0||c&&Zx(c,u))continue;const p={delay:n,...ol(o||{},u)},g=d.get();if(g!==void 0&&!d.isAnimating&&!Array.isArray(f)&&f===g&&!p.velocity)continue;let m=!1;if(window.MotionHandoffAnimation){const y=Mh(e);if(y){const k=window.MotionHandoffAnimation(y,u,ot);k!==null&&(p.startTime=k,m=!0)}}pa(e,u),d.start(yl(u,d,f,e.shouldReduceMotion&&Qf.has(u)?{type:!1}:p,e,m));const x=d.animation;x&&l.push(x)}return s&&Promise.all(l).then(()=>{ot.update(()=>{s&&$x(e,s)})}),l}function Oh(e,t,n,r=0,i=1){const o=Array.from(e).sort((c,u)=>c.sortNodePosition(u)).indexOf(t),s=e.size,a=(s-1)*r;return typeof n=="function"?n(o,s):i===1?o*r:a-o*r}function ma(e,t,n={}){var l;const r=wr(e,t,n.type==="exit"?(l=e.presenceContext)==null?void 0:l.custom:void 0);let{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);const o=r?()=>Promise.all(Ih(e,r,n)):()=>Promise.resolve(),s=e.variantChildren&&e.variantChildren.size?(c=0)=>{const{delayChildren:u=0,staggerChildren:d,staggerDirection:f}=i;return Xx(e,t,c,u,d,f,n)}:()=>Promise.resolve(),{when:a}=i;if(a){const[c,u]=a==="beforeChildren"?[o,s]:[s,o];return c().then(()=>u())}else return Promise.all([o(),s(n.delay)])}function Xx(e,t,n=0,r=0,i=0,o=1,s){const a=[];for(const l of e.variantChildren)l.notify("AnimationStart",t),a.push(ma(l,t,{...s,delay:n+(typeof r=="function"?0:r)+Oh(e.variantChildren,l,r,i,o)}).then(()=>l.notify("AnimationComplete",t)));return Promise.all(a)}function Qx(e,t,n={}){e.notify("AnimationStart",t);let r;if(Array.isArray(t)){const i=t.map(o=>ma(e,o,n));r=Promise.all(i)}else if(typeof t=="string")r=ma(e,t,n);else{const i=typeof t=="function"?wr(e,t,n.custom):t;r=Promise.all(Ih(e,i,n))}return r.then(()=>{e.notify("AnimationComplete",t)})}function Ph(e,t){if(!Array.isArray(t))return!1;const 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}const Jx=dl.length;function Dh(e){if(!e)return;if(!e.isControllingVariants){const n=e.parent?Dh(e.parent)||{}:{};return e.props.initial!==void 0&&(n.initial=e.props.initial),n}const t={};for(let n=0;n<Jx;n++){const r=dl[n],i=e.props[r];(oi(i)||i===!1)&&(t[r]=i)}return t}const e0=[...ul].reverse(),t0=ul.length;function n0(e){return t=>Promise.all(t.map(({animation:n,options:r})=>Qx(e,n,r)))}function r0(e){let t=n0(e),n=qc(),r=!0;const i=l=>(c,u)=>{var f;const d=wr(e,u,l==="exit"?(f=e.presenceContext)==null?void 0:f.custom:void 0);if(d){const{transition:p,transitionEnd:g,...m}=d;c={...c,...m,...g}}return c};function o(l){t=l(e)}function s(l){const{props:c}=e,u=Dh(e.parent)||{},d=[],f=new Set;let p={},g=1/0;for(let x=0;x<t0;x++){const y=e0[x],k=n[y],E=c[y]!==void 0?c[y]:u[y],_=oi(E),v=y===l?k.isActive:null;v===!1&&(g=x);let C=E===u[y]&&E!==c[y]&&_;if(C&&r&&e.manuallyAnimateOnMount&&(C=!1),k.protectedKeys={...p},!k.isActive&&v===null||!E&&!k.prevProp||_o(E)||typeof E=="boolean")continue;const M=i0(k.prevProp,E);let N=M||y===l&&k.isActive&&!C&&_||x>g&&_,O=!1;const b=Array.isArray(E)?E:[E];let R=b.reduce(i(y),{});v===!1&&(R={});const{prevResolvedValues:I={}}=k,B={...I,...R},F=ee=>{N=!0,f.has(ee)&&(O=!0,f.delete(ee)),k.needsAnimating[ee]=!0;const $=e.getValue(ee);$&&($.liveStyle=!1)};for(const ee in B){const $=R[ee],D=I[ee];if(p.hasOwnProperty(ee))continue;let w=!1;ha($)&&ha(D)?w=!Ph($,D):w=$!==D,w?$!=null?F(ee):f.add(ee):$!==void 0&&f.has(ee)?F(ee):k.protectedKeys[ee]=!0}k.prevProp=E,k.prevResolvedValues=R,k.isActive&&(p={...p,...R}),r&&e.blockInitialAnimation&&(N=!1);const q=C&&M;N&&(!q||O)&&d.push(...b.map(ee=>{const $={type:y};if(typeof ee=="string"&&r&&!q&&e.manuallyAnimateOnMount&&e.parent){const{parent:D}=e,w=wr(D,ee);if(D.enteringChildren&&w){const{delayChildren:j}=w.transition||{};$.delay=Oh(D.enteringChildren,e,j)}}return{animation:ee,options:$}}))}if(f.size){const x={};if(typeof c.initial!="boolean"){const y=wr(e,Array.isArray(c.initial)?c.initial[0]:c.initial);y&&y.transition&&(x.transition=y.transition)}f.forEach(y=>{const k=e.getBaseTarget(y),E=e.getValue(y);E&&(E.liveStyle=!0),x[y]=k??null}),d.push({animation:x})}let m=!!d.length;return r&&(c.initial===!1||c.initial===c.animate)&&!e.manuallyAnimateOnMount&&(m=!1),r=!1,m?t(d):Promise.resolve()}function a(l,c){var d;if(n[l].isActive===c)return Promise.resolve();(d=e.variantChildren)==null||d.forEach(f=>{var p;return(p=f.animationState)==null?void 0:p.setActive(l,c)}),n[l].isActive=c;const u=s(l);for(const f in n)n[f].protectedKeys={};return u}return{animateChanges:s,setActive:a,setAnimateFunction:o,getState:()=>n,reset:()=>{n=qc(),r=!0}}}function i0(e,t){return typeof t=="string"?t!==e:Array.isArray(t)?!Ph(t,e):!1}function Bn(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function qc(){return{animate:Bn(!0),whileInView:Bn(),whileHover:Bn(),whileTap:Bn(),whileDrag:Bn(),whileFocus:Bn(),exit:Bn()}}class Dn{constructor(t){this.isMounted=!1,this.node=t}update(){}}class o0 extends Dn{constructor(t){super(t),t.animationState||(t.animationState=r0(t))}updateAnimationControlsSubscription(){const{animate:t}=this.node.getProps();_o(t)&&(this.unmountControls=t.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){const{animate:t}=this.node.getProps(),{animate:n}=this.node.prevProps||{};t!==n&&this.updateAnimationControlsSubscription()}unmount(){var t;this.node.animationState.reset(),(t=this.unmountControls)==null||t.call(this)}}let s0=0;class a0 extends Dn{constructor(){super(...arguments),this.id=s0++}update(){if(!this.node.presenceContext)return;const{isPresent:t,onExitComplete:n}=this.node.presenceContext,{isPresent:r}=this.node.prevPresenceContext||{};if(!this.node.animationState||t===r)return;const i=this.node.animationState.setActive("exit",!t);n&&!t&&i.then(()=>{n(this.id)})}mount(){const{register:t,onExitComplete:n}=this.node.presenceContext||{};n&&n(this.id),t&&(this.unmount=t(this.id))}unmount(){}}const l0={animation:{Feature:o0},exit:{Feature:a0}};function ai(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n)}function gi(e){return{point:{x:e.pageX,y:e.pageY}}}const c0=e=>t=>ll(t)&&e(t,gi(t));function Yr(e,t,n,r){return ai(e,t,c0(n),r)}const Lh=1e-4,u0=1-Lh,d0=1+Lh,Fh=.01,f0=0-Fh,h0=0+Fh;function Dt(e){return e.max-e.min}function p0(e,t,n){return Math.abs(e-t)<=n}function Yc(e,t,n,r=.5){e.origin=r,e.originPoint=at(t.min,t.max,e.origin),e.scale=Dt(n)/Dt(t),e.translate=at(n.min,n.max,e.origin)-e.originPoint,(e.scale>=u0&&e.scale<=d0||isNaN(e.scale))&&(e.scale=1),(e.translate>=f0&&e.translate<=h0||isNaN(e.translate))&&(e.translate=0)}function Zr(e,t,n,r){Yc(e.x,t.x,n.x,r?r.originX:void 0),Yc(e.y,t.y,n.y,r?r.originY:void 0)}function Zc(e,t,n){e.min=n.min+t.min,e.max=e.min+Dt(t)}function m0(e,t,n){Zc(e.x,t.x,n.x),Zc(e.y,t.y,n.y)}function Xc(e,t,n){e.min=t.min-n.min,e.max=e.min+Dt(t)}function Xr(e,t,n){Xc(e.x,t.x,n.x),Xc(e.y,t.y,n.y)}function Kt(e){return[e("x"),e("y")]}const jh=({current:e})=>e?e.ownerDocument.defaultView:null,Qc=(e,t)=>Math.abs(e-t);function g0(e,t){const n=Qc(e.x,t.x),r=Qc(e.y,t.y);return Math.sqrt(n**2+r**2)}class Bh{constructor(t,n,{transformPagePoint:r,contextWindow:i=window,dragSnapToOrigin:o=!1,distanceThreshold:s=3}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const f=cs(this.lastMoveEventInfo,this.history),p=this.startEvent!==null,g=g0(f.offset,{x:0,y:0})>=this.distanceThreshold;if(!p&&!g)return;const{point:m}=f,{timestamp:x}=Tt;this.history.push({...m,timestamp:x});const{onStart:y,onMove:k}=this.handlers;p||(y&&y(this.lastMoveEvent,f),this.startEvent=this.lastMoveEvent),k&&k(this.lastMoveEvent,f)},this.handlePointerMove=(f,p)=>{this.lastMoveEvent=f,this.lastMoveEventInfo=ls(p,this.transformPagePoint),ot.update(this.updatePoint,!0)},this.handlePointerUp=(f,p)=>{this.end();const{onEnd:g,onSessionEnd:m,resumeAnimation:x}=this.handlers;if(this.dragSnapToOrigin&&x&&x(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;const y=cs(f.type==="pointercancel"?this.lastMoveEventInfo:ls(p,this.transformPagePoint),this.history);this.startEvent&&g&&g(f,y),m&&m(f,y)},!ll(t))return;this.dragSnapToOrigin=o,this.handlers=n,this.transformPagePoint=r,this.distanceThreshold=s,this.contextWindow=i||window;const a=gi(t),l=ls(a,this.transformPagePoint),{point:c}=l,{timestamp:u}=Tt;this.history=[{...c,timestamp:u}];const{onSessionStart:d}=n;d&&d(t,cs(l,this.history)),this.removeListeners=hi(Yr(this.contextWindow,"pointermove",this.handlePointerMove),Yr(this.contextWindow,"pointerup",this.handlePointerUp),Yr(this.contextWindow,"pointercancel",this.handlePointerUp))}updateHandlers(t){this.handlers=t}end(){this.removeListeners&&this.removeListeners(),Mn(this.updatePoint)}}function ls(e,t){return t?{point:t(e.point)}:e}function Jc(e,t){return{x:e.x-t.x,y:e.y-t.y}}function cs({point:e},t){return{point:e,delta:Jc(e,$h(t)),offset:Jc(e,b0(t)),velocity:y0(t,.1)}}function b0(e){return e[0]}function $h(e){return e[e.length-1]}function y0(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null;const i=$h(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>en(t)));)n--;if(!r)return{x:0,y:0};const o=ln(i.timestamp-r.timestamp);if(o===0)return{x:0,y:0};const s={x:(i.x-r.x)/o,y:(i.y-r.y)/o};return s.x===1/0&&(s.x=0),s.y===1/0&&(s.y=0),s}function x0(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?at(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?at(n,e,r.max):Math.min(e,n)),e}function eu(e,t,n){return{min:t!==void 0?e.min+t:void 0,max:n!==void 0?e.max+n-(e.max-e.min):void 0}}function w0(e,{top:t,left:n,bottom:r,right:i}){return{x:eu(e.x,n,i),y:eu(e.y,t,r)}}function tu(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 v0(e,t){return{x:tu(e.x,t.x),y:tu(e.y,t.y)}}function E0(e,t){let n=.5;const r=Dt(e),i=Dt(t);return i>r?n=ni(t.min,t.max-r,e.min):r>i&&(n=ni(e.min,e.max-i,t.min)),yn(0,1,n)}function k0(e,t){const n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}const ga=.35;function S0(e=ga){return e===!1?e=0:e===!0&&(e=ga),{x:nu(e,"left","right"),y:nu(e,"top","bottom")}}function nu(e,t,n){return{min:ru(e,t),max:ru(e,n)}}function ru(e,t){return typeof e=="number"?e:e[t]||0}const C0=new WeakMap;class _0{constructor(t){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=pt(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=t}start(t,{snapToCursor:n=!1,distanceThreshold:r}={}){const{presenceContext:i}=this.visualElement;if(i&&i.isPresent===!1)return;const o=d=>{const{dragSnapToOrigin:f}=this.getProps();f?this.pauseAnimation():this.stopAnimation(),n&&this.snapToCursor(gi(d).point)},s=(d,f)=>{const{drag:p,dragPropagation:g,onDragStart:m}=this.getProps();if(p&&!g&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Py(p),!this.openDragLock))return;this.latestPointerEvent=d,this.latestPanInfo=f,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Kt(y=>{let k=this.getAxisMotionValue(y).get()||0;if(cn.test(k)){const{projection:E}=this.visualElement;if(E&&E.layout){const _=E.layout.layoutBox[y];_&&(k=Dt(_)*(parseFloat(k)/100))}}this.originPoint[y]=k}),m&&ot.postRender(()=>m(d,f)),pa(this.visualElement,"transform");const{animationState:x}=this.visualElement;x&&x.setActive("whileDrag",!0)},a=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f;const{dragPropagation:p,dragDirectionLock:g,onDirectionLock:m,onDrag:x}=this.getProps();if(!p&&!this.openDragLock)return;const{offset:y}=f;if(g&&this.currentDirection===null){this.currentDirection=T0(y),this.currentDirection!==null&&m&&m(this.currentDirection);return}this.updateAxis("x",f.point,y),this.updateAxis("y",f.point,y),this.visualElement.render(),x&&x(d,f)},l=(d,f)=>{this.latestPointerEvent=d,this.latestPanInfo=f,this.stop(d,f),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>Kt(d=>{var f;return this.getAnimationState(d)==="paused"&&((f=this.getAxisMotionValue(d).animation)==null?void 0:f.play())}),{dragSnapToOrigin:u}=this.getProps();this.panSession=new Bh(t,{onSessionStart:o,onStart:s,onMove:a,onSessionEnd:l,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:u,distanceThreshold:r,contextWindow:jh(this.visualElement)})}stop(t,n){const r=t||this.latestPointerEvent,i=n||this.latestPanInfo,o=this.isDragging;if(this.cancel(),!o||!i||!r)return;const{velocity:s}=i;this.startAnimation(s);const{onDragEnd:a}=this.getProps();a&&ot.postRender(()=>a(r,i))}cancel(){this.isDragging=!1;const{projection:t,animationState:n}=this.visualElement;t&&(t.isAnimationBlocked=!1),this.panSession&&this.panSession.end(),this.panSession=void 0;const{dragPropagation:r}=this.getProps();!r&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),n&&n.setActive("whileDrag",!1)}updateAxis(t,n,r){const{drag:i}=this.getProps();if(!r||!Oi(t,i,this.currentDirection))return;const o=this.getAxisMotionValue(t);let s=this.originPoint[t]+r[t];this.constraints&&this.constraints[t]&&(s=x0(s,this.constraints[t],this.elastic[t])),o.set(s)}resolveConstraints(){var o;const{dragConstraints:t,dragElastic:n}=this.getProps(),r=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):(o=this.visualElement.projection)==null?void 0:o.layout,i=this.constraints;t&&gr(t)?this.constraints||(this.constraints=this.resolveRefConstraints()):t&&r?this.constraints=w0(r.layoutBox,t):this.constraints=!1,this.elastic=S0(n),i!==this.constraints&&r&&this.constraints&&!this.hasMutatedConstraints&&Kt(s=>{this.constraints!==!1&&this.getAxisMotionValue(s)&&(this.constraints[s]=k0(r.layoutBox[s],this.constraints[s]))})}resolveRefConstraints(){const{dragConstraints:t,onMeasureDragConstraints:n}=this.getProps();if(!t||!gr(t))return!1;const r=t.current;xn(r!==null,"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.","drag-constraints-ref");const{projection:i}=this.visualElement;if(!i||!i.layout)return!1;const o=Nx(r,i.root,this.visualElement.getTransformPagePoint());let s=v0(i.layout.layoutBox,o);if(n){const a=n(Cx(s));this.hasMutatedConstraints=!!a,a&&(s=kh(a))}return s}startAnimation(t){const{drag:n,dragMomentum:r,dragElastic:i,dragTransition:o,dragSnapToOrigin:s,onDragTransitionEnd:a}=this.getProps(),l=this.constraints||{},c=Kt(u=>{if(!Oi(u,n,this.currentDirection))return;let d=l&&l[u]||{};s&&(d={min:0,max:0});const f=i?200:1e6,p=i?40:1e7,g={type:"inertia",velocity:r?t[u]:0,bounceStiffness:f,bounceDamping:p,timeConstant:750,restDelta:1,restSpeed:10,...o,...d};return this.startAxisValueAnimation(u,g)});return Promise.all(c).then(a)}startAxisValueAnimation(t,n){const r=this.getAxisMotionValue(t);return pa(this.visualElement,t),r.start(yl(t,r,0,n,this.visualElement,!1))}stopAnimation(){Kt(t=>this.getAxisMotionValue(t).stop())}pauseAnimation(){Kt(t=>{var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.pause()})}getAnimationState(t){var n;return(n=this.getAxisMotionValue(t).animation)==null?void 0:n.state}getAxisMotionValue(t){const n=`_drag${t.toUpperCase()}`,r=this.visualElement.getProps(),i=r[n];return i||this.visualElement.getValue(t,(r.initial?r.initial[t]:void 0)||0)}snapToCursor(t){Kt(n=>{const{drag:r}=this.getProps();if(!Oi(n,r,this.currentDirection))return;const{projection:i}=this.visualElement,o=this.getAxisMotionValue(n);if(i&&i.layout){const{min:s,max:a}=i.layout.layoutBox[n];o.set(t[n]-at(s,a,.5))}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;const{drag:t,dragConstraints:n}=this.getProps(),{projection:r}=this.visualElement;if(!gr(n)||!r||!this.constraints)return;this.stopAnimation();const i={x:0,y:0};Kt(s=>{const a=this.getAxisMotionValue(s);if(a&&this.constraints!==!1){const l=a.get();i[s]=E0({min:l,max:l},this.constraints[s])}});const{transformTemplate:o}=this.visualElement.getProps();this.visualElement.current.style.transform=o?o({},""):"none",r.root&&r.root.updateScroll(),r.updateLayout(),this.resolveConstraints(),Kt(s=>{if(!Oi(s,t,null))return;const a=this.getAxisMotionValue(s),{min:l,max:c}=this.constraints[s];a.set(at(l,c,i[s]))})}addListeners(){if(!this.visualElement.current)return;C0.set(this.visualElement,this);const t=this.visualElement.current,n=Yr(t,"pointerdown",l=>{const{drag:c,dragListener:u=!0}=this.getProps();c&&u&&this.start(l)}),r=()=>{const{dragConstraints:l}=this.getProps();gr(l)&&l.current&&(this.constraints=this.resolveRefConstraints())},{projection:i}=this.visualElement,o=i.addEventListener("measure",r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),ot.read(r);const s=ai(window,"resize",()=>this.scalePositionWithinConstraints()),a=i.addEventListener("didUpdate",({delta:l,hasLayoutChanged:c})=>{this.isDragging&&c&&(Kt(u=>{const d=this.getAxisMotionValue(u);d&&(this.originPoint[u]+=l[u].translate,d.set(d.get()+l[u].translate))}),this.visualElement.render())});return()=>{s(),n(),o(),a&&a()}}getProps(){const t=this.visualElement.getProps(),{drag:n=!1,dragDirectionLock:r=!1,dragPropagation:i=!1,dragConstraints:o=!1,dragElastic:s=ga,dragMomentum:a=!0}=t;return{...t,drag:n,dragDirectionLock:r,dragPropagation:i,dragConstraints:o,dragElastic:s,dragMomentum:a}}}function Oi(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function T0(e,t=10){let n=null;return Math.abs(e.y)>t?n="y":Math.abs(e.x)>t&&(n="x"),n}class N0 extends Dn{constructor(t){super(t),this.removeGroupControls=Zt,this.removeListeners=Zt,this.controls=new _0(t)}mount(){const{dragControls:t}=this.node.getProps();t&&(this.removeGroupControls=t.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||Zt}unmount(){this.removeGroupControls(),this.removeListeners()}}const iu=e=>(t,n)=>{e&&ot.postRender(()=>e(t,n))};class A0 extends Dn{constructor(){super(...arguments),this.removePointerDownListener=Zt}onPointerDown(t){this.session=new Bh(t,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:jh(this.node)})}createPanHandlers(){const{onPanSessionStart:t,onPanStart:n,onPan:r,onPanEnd:i}=this.node.getProps();return{onSessionStart:iu(t),onStart:iu(n),onMove:r,onEnd:(o,s)=>{delete this.session,i&&ot.postRender(()=>i(o,s))}}}mount(){this.removePointerDownListener=Yr(this.node.current,"pointerdown",t=>this.onPointerDown(t))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}}const eo={hasAnimatedSinceResize:!0,hasEverUpdated:!1};function ou(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}const Fr={correct:(e,t)=>{if(!t.target)return e;if(typeof e=="string")if(we.test(e))e=parseFloat(e);else return e;const n=ou(e,t.target.x),r=ou(e,t.target.y);return`${n}% ${r}%`}},R0={correct:(e,{treeScale:t,projectionDelta:n})=>{const r=e,i=In.parse(e);if(i.length>5)return r;const o=In.createTransformer(e),s=typeof i[0]!="number"?1:0,a=n.x.scale*t.x,l=n.y.scale*t.y;i[0+s]/=a,i[1+s]/=l;const c=at(a,l,.5);return typeof i[2+s]=="number"&&(i[2+s]/=c),typeof i[3+s]=="number"&&(i[3+s]/=c),o(i)}};let us=!1;class M0 extends A.Component{componentDidMount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r,layoutId:i}=this.props,{projection:o}=t;Jy(I0),o&&(n.group&&n.group.add(o),r&&r.register&&i&&r.register(o),us&&o.root.didUpdate(),o.addEventListener("animationComplete",()=>{this.safeToRemove()}),o.setOptions({...o.options,onExitComplete:()=>this.safeToRemove()})),eo.hasEverUpdated=!0}getSnapshotBeforeUpdate(t){const{layoutDependency:n,visualElement:r,drag:i,isPresent:o}=this.props,{projection:s}=r;return s&&(s.isPresent=o,us=!0,i||t.layoutDependency!==n||n===void 0||t.isPresent!==o?s.willUpdate():this.safeToRemove(),t.isPresent!==o&&(o?s.promote():s.relegate()||ot.postRender(()=>{const a=s.getStack();(!a||!a.members.length)&&this.safeToRemove()}))),null}componentDidUpdate(){const{projection:t}=this.props.visualElement;t&&(t.root.didUpdate(),al.postRender(()=>{!t.currentAnimation&&t.isLead()&&this.safeToRemove()}))}componentWillUnmount(){const{visualElement:t,layoutGroup:n,switchLayoutGroup:r}=this.props,{projection:i}=t;us=!0,i&&(i.scheduleCheckAfterUnmount(),n&&n.group&&n.group.remove(i),r&&r.deregister&&r.deregister(i))}safeToRemove(){const{safeToRemove:t}=this.props;t&&t()}render(){return null}}function Vh(e){const[t,n]=ch(),r=A.useContext(Ba);return h.jsx(M0,{...e,layoutGroup:r,switchLayoutGroup:A.useContext(vh),isPresent:t,safeToRemove:n})}const I0={borderRadius:{...Fr,applyTo:["borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius"]},borderTopLeftRadius:Fr,borderTopRightRadius:Fr,borderBottomLeftRadius:Fr,borderBottomRightRadius:Fr,boxShadow:R0};function O0(e,t,n){const r=Rt(e)?e:kr(e);return r.start(yl("",r,t,n)),r.animation}const P0=(e,t)=>e.depth-t.depth;class D0{constructor(){this.children=[],this.isDirty=!1}add(t){za(this.children,t),this.isDirty=!0}remove(t){Ua(this.children,t),this.isDirty=!0}forEach(t){this.isDirty&&this.children.sort(P0),this.isDirty=!1,this.children.forEach(t)}}function L0(e,t){const n=jt.now(),r=({timestamp:i})=>{const o=i-n;o>=t&&(Mn(r),e(o-t))};return ot.setup(r,!0),()=>Mn(r)}const zh=["TopLeft","TopRight","BottomLeft","BottomRight"],F0=zh.length,su=e=>typeof e=="string"?parseFloat(e):e,au=e=>typeof e=="number"||we.test(e);function j0(e,t,n,r,i,o){i?(e.opacity=at(0,n.opacity??1,B0(r)),e.opacityExit=at(t.opacity??1,0,$0(r))):o&&(e.opacity=at(t.opacity??1,n.opacity??1,r));for(let s=0;s<F0;s++){const a=`border${zh[s]}Radius`;let l=lu(t,a),c=lu(n,a);if(l===void 0&&c===void 0)continue;l||(l=0),c||(c=0),l===0||c===0||au(l)===au(c)?(e[a]=Math.max(at(su(l),su(c),r),0),(cn.test(c)||cn.test(l))&&(e[a]+="%")):e[a]=c}(t.rotate||n.rotate)&&(e.rotate=at(t.rotate||0,n.rotate||0,r))}function lu(e,t){return e[t]!==void 0?e[t]:e.borderRadius}const B0=Uh(0,.5,Af),$0=Uh(.5,.95,Zt);function Uh(e,t,n){return r=>r<e?0:r>t?1:n(ni(e,t,r))}function cu(e,t){e.min=t.min,e.max=t.max}function Gt(e,t){cu(e.x,t.x),cu(e.y,t.y)}function uu(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}function du(e,t,n,r,i){return e-=t,e=ho(e,1/n,r),i!==void 0&&(e=ho(e,1/i,r)),e}function V0(e,t=0,n=1,r=.5,i,o=e,s=e){if(cn.test(t)&&(t=parseFloat(t),t=at(s.min,s.max,t/100)-s.min),typeof t!="number")return;let a=at(o.min,o.max,r);e===o&&(a-=t),e.min=du(e.min,t,n,a,i),e.max=du(e.max,t,n,a,i)}function fu(e,t,[n,r,i],o,s){V0(e,t[n],t[r],t[i],t.scale,o,s)}const z0=["x","scaleX","originX"],U0=["y","scaleY","originY"];function hu(e,t,n,r){fu(e.x,t,z0,n?n.x:void 0,r?r.x:void 0),fu(e.y,t,U0,n?n.y:void 0,r?r.y:void 0)}function pu(e){return e.translate===0&&e.scale===1}function Hh(e){return pu(e.x)&&pu(e.y)}function mu(e,t){return e.min===t.min&&e.max===t.max}function H0(e,t){return mu(e.x,t.x)&&mu(e.y,t.y)}function gu(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Wh(e,t){return gu(e.x,t.x)&&gu(e.y,t.y)}function bu(e){return Dt(e.x)/Dt(e.y)}function yu(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}class W0{constructor(){this.members=[]}add(t){za(this.members,t),t.scheduleRender()}remove(t){if(Ua(this.members,t),t===this.prevLead&&(this.prevLead=void 0),t===this.lead){const n=this.members[this.members.length-1];n&&this.promote(n)}}relegate(t){const n=this.members.findIndex(i=>t===i);if(n===0)return!1;let r;for(let i=n;i>=0;i--){const o=this.members[i];if(o.isPresent!==!1){r=o;break}}return r?(this.promote(r),!0):!1}promote(t,n){const r=this.lead;if(t!==r&&(this.prevLead=r,this.lead=t,t.show(),r)){r.instance&&r.scheduleRender(),t.scheduleRender(),t.resumeFrom=r,n&&(t.resumeFrom.preserveOpacity=!0),r.snapshot&&(t.snapshot=r.snapshot,t.snapshot.latestValues=r.animationValues||r.latestValues),t.root&&t.root.isUpdating&&(t.isLayoutDirty=!0);const{crossfade:i}=t.options;i===!1&&r.hide()}}exitAnimationComplete(){this.members.forEach(t=>{const{options:n,resumingFrom:r}=t;n.onExitComplete&&n.onExitComplete(),r&&r.options.onExitComplete&&r.options.onExitComplete()})}scheduleRender(){this.members.forEach(t=>{t.instance&&t.scheduleRender(!1)})}removeLeadSnapshot(){this.lead&&this.lead.snapshot&&(this.lead.snapshot=void 0)}}function G0(e,t,n){let r="";const i=e.x.translate/t.x,o=e.y.translate/t.y,s=(n==null?void 0:n.z)||0;if((i||o||s)&&(r=`translate3d(${i}px, ${o}px, ${s}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){const{transformPerspective:c,rotate:u,rotateX:d,rotateY:f,skewX:p,skewY:g}=n;c&&(r=`perspective(${c}px) ${r}`),u&&(r+=`rotate(${u}deg) `),d&&(r+=`rotateX(${d}deg) `),f&&(r+=`rotateY(${f}deg) `),p&&(r+=`skewX(${p}deg) `),g&&(r+=`skewY(${g}deg) `)}const a=e.x.scale*t.x,l=e.y.scale*t.y;return(a!==1||l!==1)&&(r+=`scale(${a}, ${l})`),r||"none"}const ds=["","X","Y","Z"],K0=1e3;let q0=0;function fs(e,t,n,r){const{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Gh(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;const{visualElement:t}=e.options;if(!t)return;const n=Mh(t);if(window.MotionHasOptimisedAnimation(n,"transform")){const{layout:i,layoutId:o}=e.options;window.MotionCancelOptimisedAnimation(n,"transform",ot,!(i||o))}const{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Gh(r)}function Kh({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(s={},a=t==null?void 0:t()){this.id=q0++,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.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,this.nodes.forEach(X0),this.nodes.forEach(tw),this.nodes.forEach(nw),this.nodes.forEach(Q0)},this.resolvedRelativeTargetAt=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=s,this.root=a?a.root||a:this,this.path=a?[...a.path,a]:[],this.parent=a,this.depth=a?a.depth+1:0;for(let l=0;l<this.path.length;l++)this.path[l].shouldResetTransform=!0;this.root===this&&(this.nodes=new D0)}addEventListener(s,a){return this.eventHandlers.has(s)||this.eventHandlers.set(s,new Wa),this.eventHandlers.get(s).add(a)}notifyListeners(s,...a){const l=this.eventHandlers.get(s);l&&l.notify(...a)}hasListeners(s){return this.eventHandlers.has(s)}mount(s){if(this.instance)return;this.isSVG=lh(s)&&!$y(s),this.instance=s;const{layoutId:a,layout:l,visualElement:c}=this.options;if(c&&!c.current&&c.mount(s),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(l||a)&&(this.isLayoutDirty=!0),e){let u,d=0;const f=()=>this.root.updateBlockedByResize=!1;ot.read(()=>{d=window.innerWidth}),e(s,()=>{const p=window.innerWidth;p!==d&&(d=p,this.root.updateBlockedByResize=!0,u&&u(),u=L0(f,250),eo.hasAnimatedSinceResize&&(eo.hasAnimatedSinceResize=!1,this.nodes.forEach(vu)))})}a&&this.root.registerSharedNode(a,this),this.options.animate!==!1&&c&&(a||l)&&this.addEventListener("didUpdate",({delta:u,hasLayoutChanged:d,hasRelativeLayoutChanged:f,layout:p})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}const g=this.options.transition||c.getDefaultTransition()||aw,{onLayoutAnimationStart:m,onLayoutAnimationComplete:x}=c.getProps(),y=!this.targetLayout||!Wh(this.targetLayout,p),k=!d&&f;if(this.options.layoutRoot||this.resumeFrom||k||d&&(y||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);const E={...ol(g,"layout"),onPlay:m,onComplete:x};(c.shouldReduceMotion||this.options.layoutRoot)&&(E.delay=0,E.type=!1),this.startAnimation(E),this.setAnimationOrigin(u,k)}else d||vu(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=p})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);const s=this.getStack();s&&s.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Mn(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(rw),this.animationId++)}getTransformTemplate(){const{visualElement:s}=this.options;return s&&s.getProps().transformTemplate}willUpdate(s=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Gh(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let u=0;u<this.path.length;u++){const d=this.path[u];d.shouldResetTransform=!0,d.updateScroll("snapshot"),d.options.layoutRoot&&d.willUpdate(!1)}const{layoutId:a,layout:l}=this.options;if(a===void 0&&!l)return;const c=this.getTransformTemplate();this.prevTransformTemplateValue=c?c(this.latestValues,""):void 0,this.updateSnapshot(),s&&this.notifyListeners("willUpdate")}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){this.unblockUpdate(),this.clearAllSnapshots(),this.nodes.forEach(xu);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(wu);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ew),this.nodes.forEach(Y0),this.nodes.forEach(Z0)):this.nodes.forEach(wu),this.clearAllSnapshots();const a=jt.now();Tt.delta=yn(0,1e3/60,a-Tt.timestamp),Tt.timestamp=a,Tt.isProcessing=!0,es.update.process(Tt),es.preRender.process(Tt),es.render.process(Tt),Tt.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,al.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(J0),this.sharedNodes.forEach(iw)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,ot.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){ot.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){this.snapshot||!this.instance||(this.snapshot=this.measure(),this.snapshot&&!Dt(this.snapshot.measuredBox.x)&&!Dt(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 l=0;l<this.path.length;l++)this.path[l].updateScroll();const s=this.layout;this.layout=this.measure(!1),this.layoutCorrected=pt(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners("measure",this.layout.layoutBox);const{visualElement:a}=this.options;a&&a.notify("LayoutMeasure",this.layout.layoutBox,s?s.layoutBox:void 0)}updateScroll(s="measure"){let a=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===s&&(a=!1),a&&this.instance){const l=r(this.instance);this.scroll={animationId:this.root.animationId,phase:s,isRoot:l,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:l}}}resetTransform(){if(!i)return;const s=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,a=this.projectionDelta&&!Hh(this.projectionDelta),l=this.getTransformTemplate(),c=l?l(this.latestValues,""):void 0,u=c!==this.prevTransformTemplateValue;s&&this.instance&&(a||zn(this.latestValues)||u)&&(i(this.instance,c),this.shouldResetTransform=!1,this.scheduleRender())}measure(s=!0){const a=this.measurePageBox();let l=this.removeElementScroll(a);return s&&(l=this.removeTransform(l)),lw(l),{animationId:this.root.animationId,measuredBox:a,layoutBox:l,latestValues:{},source:this.id}}measurePageBox(){var c;const{visualElement:s}=this.options;if(!s)return pt();const a=s.measureViewportBox();if(!(((c=this.scroll)==null?void 0:c.wasRoot)||this.path.some(cw))){const{scroll:u}=this.root;u&&(br(a.x,u.offset.x),br(a.y,u.offset.y))}return a}removeElementScroll(s){var l;const a=pt();if(Gt(a,s),(l=this.scroll)!=null&&l.wasRoot)return a;for(let c=0;c<this.path.length;c++){const u=this.path[c],{scroll:d,options:f}=u;u!==this.root&&d&&f.layoutScroll&&(d.wasRoot&&Gt(a,s),br(a.x,d.offset.x),br(a.y,d.offset.y))}return a}applyTransform(s,a=!1){const l=pt();Gt(l,s);for(let c=0;c<this.path.length;c++){const u=this.path[c];!a&&u.options.layoutScroll&&u.scroll&&u!==u.root&&yr(l,{x:-u.scroll.offset.x,y:-u.scroll.offset.y}),zn(u.latestValues)&&yr(l,u.latestValues)}return zn(this.latestValues)&&yr(l,this.latestValues),l}removeTransform(s){const a=pt();Gt(a,s);for(let l=0;l<this.path.length;l++){const c=this.path[l];if(!c.instance||!zn(c.latestValues))continue;ua(c.latestValues)&&c.updateSnapshot();const u=pt(),d=c.measurePageBox();Gt(u,d),hu(a,c.latestValues,c.snapshot?c.snapshot.layoutBox:void 0,u)}return zn(this.latestValues)&&hu(a,this.latestValues),a}setTargetDelta(s){this.targetDelta=s,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(s){this.options={...this.options,...s,crossfade:s.crossfade!==void 0?s.crossfade:!0}}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!==Tt.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(s=!1){var f;const a=this.getLead();this.isProjectionDirty||(this.isProjectionDirty=a.isProjectionDirty),this.isTransformDirty||(this.isTransformDirty=a.isTransformDirty),this.isSharedProjectionDirty||(this.isSharedProjectionDirty=a.isSharedProjectionDirty);const l=!!this.resumingFrom||this!==a;if(!(s||l&&this.isSharedProjectionDirty||this.isProjectionDirty||(f=this.parent)!=null&&f.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;const{layout:u,layoutId:d}=this.options;if(!(!this.layout||!(u||d))){if(this.resolvedRelativeTargetAt=Tt.timestamp,!this.targetDelta&&!this.relativeTarget){const p=this.getClosestProjectingParent();p&&p.layout&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pt(),this.relativeTargetOrigin=pt(),Xr(this.relativeTargetOrigin,this.layout.layoutBox,p.layout.layoutBox),Gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}if(!(!this.relativeTarget&&!this.targetDelta)&&(this.target||(this.target=pt(),this.targetWithTransforms=pt()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),m0(this.target,this.relativeTarget,this.relativeParent.target)):this.targetDelta?(this.resumingFrom?this.target=this.applyTransform(this.layout.layoutBox):Gt(this.target,this.layout.layoutBox),Ch(this.target,this.targetDelta)):Gt(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget)){this.attemptToResolveRelativeTarget=!1;const p=this.getClosestProjectingParent();p&&!!p.resumingFrom==!!this.resumingFrom&&!p.options.layoutScroll&&p.target&&this.animationProgress!==1?(this.relativeParent=p,this.forceRelativeParentToResolveTarget(),this.relativeTarget=pt(),this.relativeTargetOrigin=pt(),Xr(this.relativeTargetOrigin,this.target,p.target),Gt(this.relativeTarget,this.relativeTargetOrigin)):this.relativeParent=this.relativeTarget=void 0}}}getClosestProjectingParent(){if(!(!this.parent||ua(this.parent.latestValues)||Sh(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}calcProjection(){var g;const s=this.getLead(),a=!!this.resumingFrom||this!==s;let l=!0;if((this.isProjectionDirty||(g=this.parent)!=null&&g.isProjectionDirty)&&(l=!1),a&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(l=!1),this.resolvedRelativeTargetAt===Tt.timestamp&&(l=!1),l)return;const{layout:c,layoutId:u}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(c||u))return;Gt(this.layoutCorrected,this.layout.layoutBox);const d=this.treeScale.x,f=this.treeScale.y;Tx(this.layoutCorrected,this.treeScale,this.path,a),s.layout&&!s.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(s.target=s.layout.layoutBox,s.targetWithTransforms=pt());const{target:p}=s;if(!p){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(uu(this.prevProjectionDelta.x,this.projectionDelta.x),uu(this.prevProjectionDelta.y,this.projectionDelta.y)),Zr(this.projectionDelta,this.layoutCorrected,p,this.latestValues),(this.treeScale.x!==d||this.treeScale.y!==f||!yu(this.projectionDelta.x,this.prevProjectionDelta.x)||!yu(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners("projectionUpdate",p))}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(s=!0){var a;if((a=this.options.visualElement)==null||a.scheduleRender(),s){const l=this.getStack();l&&l.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=xr(),this.projectionDelta=xr(),this.projectionDeltaWithTransform=xr()}setAnimationOrigin(s,a=!1){const l=this.snapshot,c=l?l.latestValues:{},u={...this.latestValues},d=xr();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!a;const f=pt(),p=l?l.source:void 0,g=this.layout?this.layout.source:void 0,m=p!==g,x=this.getStack(),y=!x||x.members.length<=1,k=!!(m&&!y&&this.options.crossfade===!0&&!this.path.some(sw));this.animationProgress=0;let E;this.mixTargetDelta=_=>{const v=_/1e3;Eu(d.x,s.x,v),Eu(d.y,s.y,v),this.setTargetDelta(d),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(Xr(f,this.layout.layoutBox,this.relativeParent.layout.layoutBox),ow(this.relativeTarget,this.relativeTargetOrigin,f,v),E&&H0(this.relativeTarget,E)&&(this.isProjectionDirty=!1),E||(E=pt()),Gt(E,this.relativeTarget)),m&&(this.animationValues=u,j0(u,c,this.latestValues,v,k,y)),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=v},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(s){var a,l,c;this.notifyListeners("animationStart"),(a=this.currentAnimation)==null||a.stop(),(c=(l=this.resumingFrom)==null?void 0:l.currentAnimation)==null||c.stop(),this.pendingAnimation&&(Mn(this.pendingAnimation),this.pendingAnimation=void 0),this.pendingAnimation=ot.update(()=>{eo.hasAnimatedSinceResize=!0,this.motionValue||(this.motionValue=kr(0)),this.currentAnimation=O0(this.motionValue,[0,1e3],{...s,velocity:0,isSync:!0,onUpdate:u=>{this.mixTargetDelta(u),s.onUpdate&&s.onUpdate(u)},onStop:()=>{},onComplete:()=>{s.onComplete&&s.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);const s=this.getStack();s&&s.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners("animationComplete")}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(K0),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){const s=this.getLead();let{targetWithTransforms:a,target:l,layout:c,latestValues:u}=s;if(!(!a||!l||!c)){if(this!==s&&this.layout&&c&&qh(this.options.animationType,this.layout.layoutBox,c.layoutBox)){l=this.target||pt();const d=Dt(this.layout.layoutBox.x);l.x.min=s.target.x.min,l.x.max=l.x.min+d;const f=Dt(this.layout.layoutBox.y);l.y.min=s.target.y.min,l.y.max=l.y.min+f}Gt(a,l),yr(a,u),Zr(this.projectionDeltaWithTransform,this.layoutCorrected,a,u)}}registerSharedNode(s,a){this.sharedNodes.has(s)||this.sharedNodes.set(s,new W0),this.sharedNodes.get(s).add(a);const c=a.options.initialPromotionConfig;a.promote({transition:c?c.transition:void 0,preserveFollowOpacity:c&&c.shouldPreserveFollowOpacity?c.shouldPreserveFollowOpacity(a):void 0})}isLead(){const s=this.getStack();return s?s.lead===this:!0}getLead(){var a;const{layoutId:s}=this.options;return s?((a=this.getStack())==null?void 0:a.lead)||this:this}getPrevLead(){var a;const{layoutId:s}=this.options;return s?(a=this.getStack())==null?void 0:a.prevLead:void 0}getStack(){const{layoutId:s}=this.options;if(s)return this.root.sharedNodes.get(s)}promote({needsReset:s,transition:a,preserveFollowOpacity:l}={}){const c=this.getStack();c&&c.promote(this,l),s&&(this.projectionDelta=void 0,this.needsReset=!0),a&&this.setOptions({transition:a})}relegate(){const s=this.getStack();return s?s.relegate(this):!1}resetSkewAndRotation(){const{visualElement:s}=this.options;if(!s)return;let a=!1;const{latestValues:l}=s;if((l.z||l.rotate||l.rotateX||l.rotateY||l.rotateZ||l.skewX||l.skewY)&&(a=!0),!a)return;const c={};l.z&&fs("z",s,c,this.animationValues);for(let u=0;u<ds.length;u++)fs(`rotate${ds[u]}`,s,c,this.animationValues),fs(`skew${ds[u]}`,s,c,this.animationValues);s.render();for(const u in c)s.setStaticValue(u,c[u]),this.animationValues&&(this.animationValues[u]=c[u]);s.scheduleRender()}applyProjectionStyles(s,a){if(!this.instance||this.isSVG)return;if(!this.isVisible){s.visibility="hidden";return}const l=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,s.visibility="",s.opacity="",s.pointerEvents=Ji(a==null?void 0:a.pointerEvents)||"",s.transform=l?l(this.latestValues,""):"none";return}const c=this.getLead();if(!this.projectionDelta||!this.layout||!c.target){this.options.layoutId&&(s.opacity=this.latestValues.opacity!==void 0?this.latestValues.opacity:1,s.pointerEvents=Ji(a==null?void 0:a.pointerEvents)||""),this.hasProjected&&!zn(this.latestValues)&&(s.transform=l?l({},""):"none",this.hasProjected=!1);return}s.visibility="";const u=c.animationValues||c.latestValues;this.applyTransformsToTarget();let d=G0(this.projectionDeltaWithTransform,this.treeScale,u);l&&(d=l(u,d)),s.transform=d;const{x:f,y:p}=this.projectionDelta;s.transformOrigin=`${f.origin*100}% ${p.origin*100}% 0`,c.animationValues?s.opacity=c===this?u.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:u.opacityExit:s.opacity=c===this?u.opacity!==void 0?u.opacity:"":u.opacityExit!==void 0?u.opacityExit:0;for(const g in si){if(u[g]===void 0)continue;const{correct:m,applyTo:x,isCSSVariable:y}=si[g],k=d==="none"?u[g]:m(u[g],c);if(x){const E=x.length;for(let _=0;_<E;_++)s[x[_]]=k}else y?this.options.visualElement.renderState.vars[g]=k:s[g]=k}this.options.layoutId&&(s.pointerEvents=c===this?Ji(a==null?void 0:a.pointerEvents)||"":"none")}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(s=>{var a;return(a=s.currentAnimation)==null?void 0:a.stop()}),this.root.nodes.forEach(xu),this.root.sharedNodes.clear()}}}function Y0(e){e.updateLayout()}function Z0(e){var n;const t=((n=e.resumeFrom)==null?void 0:n.snapshot)||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners("didUpdate")){const{layoutBox:r,measuredBox:i}=e.layout,{animationType:o}=e.options,s=t.source!==e.layout.source;o==="size"?Kt(d=>{const f=s?t.measuredBox[d]:t.layoutBox[d],p=Dt(f);f.min=r[d].min,f.max=f.min+p}):qh(o,t.layoutBox,r)&&Kt(d=>{const f=s?t.measuredBox[d]:t.layoutBox[d],p=Dt(r[d]);f.max=f.min+p,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[d].max=e.relativeTarget[d].min+p)});const a=xr();Zr(a,r,t.layoutBox);const l=xr();s?Zr(l,e.applyTransform(i,!0),t.measuredBox):Zr(l,r,t.layoutBox);const c=!Hh(a);let u=!1;if(!e.resumeFrom){const d=e.getClosestProjectingParent();if(d&&!d.resumeFrom){const{snapshot:f,layout:p}=d;if(f&&p){const g=pt();Xr(g,t.layoutBox,f.layoutBox);const m=pt();Xr(m,r,p.layoutBox),Wh(g,m)||(u=!0),d.options.layoutRoot&&(e.relativeTarget=m,e.relativeTargetOrigin=g,e.relativeParent=d)}}}e.notifyListeners("didUpdate",{layout:r,snapshot:t,delta:l,layoutDelta:a,hasLayoutChanged:c,hasRelativeLayoutChanged:u})}else if(e.isLead()){const{onExitComplete:r}=e.options;r&&r()}e.options.transition=void 0}function X0(e){e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||(e.isSharedProjectionDirty=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty)),e.isTransformDirty||(e.isTransformDirty=e.parent.isTransformDirty))}function Q0(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function J0(e){e.clearSnapshot()}function xu(e){e.clearMeasurements()}function wu(e){e.isLayoutDirty=!1}function ew(e){const{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify("BeforeLayoutMeasure"),e.resetTransform()}function vu(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function tw(e){e.resolveTargetDelta()}function nw(e){e.calcProjection()}function rw(e){e.resetSkewAndRotation()}function iw(e){e.removeLeadSnapshot()}function Eu(e,t,n){e.translate=at(t.translate,0,n),e.scale=at(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function ku(e,t,n,r){e.min=at(t.min,n.min,r),e.max=at(t.max,n.max,r)}function ow(e,t,n,r){ku(e.x,t.x,n.x,r),ku(e.y,t.y,n.y,r)}function sw(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}const aw={duration:.45,ease:[.4,0,.1,1]},Su=e=>typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),Cu=Su("applewebkit/")&&!Su("chrome/")?Math.round:Zt;function _u(e){e.min=Cu(e.min),e.max=Cu(e.max)}function lw(e){_u(e.x),_u(e.y)}function qh(e,t,n){return e==="position"||e==="preserve-aspect"&&!p0(bu(t),bu(n),.2)}function cw(e){var t;return e!==e.root&&((t=e.scroll)==null?void 0:t.wasRoot)}const uw=Kh({attachResizeListener:(e,t)=>ai(e,"resize",t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body.scrollLeft,y:document.documentElement.scrollTop||document.body.scrollTop}),checkIsScrollRoot:()=>!0}),hs={current:void 0},Yh=Kh({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!hs.current){const e=new uw({});e.mount(window),e.setOptions({layoutScroll:!0}),hs.current=e}return hs.current},resetTransform:(e,t)=>{e.style.transform=t!==void 0?t:"none"},checkIsScrollRoot:e=>window.getComputedStyle(e).position==="fixed"}),dw={pan:{Feature:A0},drag:{Feature:N0,ProjectionNode:Yh,MeasureLayout:Vh}};function Tu(e,t,n){const{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive("whileHover",n==="Start");const i="onHover"+n,o=r[i];o&&ot.postRender(()=>o(t,gi(t)))}class fw extends Dn{mount(){const{current:t}=this.node;t&&(this.unmount=Dy(t,(n,r)=>(Tu(this.node,r,"Start"),i=>Tu(this.node,i,"End"))))}unmount(){}}class hw extends Dn{constructor(){super(...arguments),this.isActive=!1}onFocus(){let t=!1;try{t=this.node.current.matches(":focus-visible")}catch{t=!0}!t||!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=hi(ai(this.node.current,"focus",()=>this.onFocus()),ai(this.node.current,"blur",()=>this.onBlur()))}unmount(){}}function Nu(e,t,n){const{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive("whileTap",n==="Start");const i="onTap"+(n==="End"?"":n),o=r[i];o&&ot.postRender(()=>o(t,gi(t)))}class pw extends Dn{mount(){const{current:t}=this.node;t&&(this.unmount=By(t,(n,r)=>(Nu(this.node,r,"Start"),(i,{success:o})=>Nu(this.node,i,o?"End":"Cancel")),{useGlobalTarget:this.node.props.globalTapTarget}))}unmount(){}}const ba=new WeakMap,ps=new WeakMap,mw=e=>{const t=ba.get(e.target);t&&t(e)},gw=e=>{e.forEach(mw)};function bw({root:e,...t}){const n=e||document;ps.has(n)||ps.set(n,{});const r=ps.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(gw,{root:e,...t})),r[i]}function yw(e,t,n){const r=bw(t);return ba.set(e,n),r.observe(e),()=>{ba.delete(e),r.unobserve(e)}}const xw={some:0,all:1};class ww extends Dn{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.unmount();const{viewport:t={}}=this.node.getProps(),{root:n,margin:r,amount:i="some",once:o}=t,s={root:n?n.current:void 0,rootMargin:r,threshold:typeof i=="number"?i:xw[i]},a=l=>{const{isIntersecting:c}=l;if(this.isInView===c||(this.isInView=c,o&&!c&&this.hasEnteredView))return;c&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive("whileInView",c);const{onViewportEnter:u,onViewportLeave:d}=this.node.getProps(),f=c?u:d;f&&f(l)};return yw(this.node.current,s,a)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>"u")return;const{props:t,prevProps:n}=this.node;["amount","margin","root"].some(vw(t,n))&&this.startObserver()}unmount(){}}function vw({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}const Ew={inView:{Feature:ww},tap:{Feature:pw},focus:{Feature:hw},hover:{Feature:fw}},kw={layout:{ProjectionNode:Yh,MeasureLayout:Vh}},Sw={...l0,...Ew,...dw,...kw},Ae=Sx(Sw,Fx);function Cw(e){const[t,n]=A.useState(()=>e.getLocalParticipant()),[r,i]=A.useState(()=>e.getMicrophoneTrack());return A.useEffect(()=>{const o=()=>{const a=e.getLocalParticipant(),l=e.getMicrophoneTrack();console.log("๐ค useVoxketLocalParticipant: Updating state:",{hasParticipant:!!a,hasMicTrack:!!l,isMicEnabled:e.isMicrophoneEnabled,trackPublications:a?a.trackPublications.size:0}),n(a),i(l)};o(),e.on("connection.connected",o),e.on("connection.disconnected",o),e.on("track.muted",o),e.on("track.unmuted",o);const s=e.getRoom();if(s){const a=()=>{console.log("๐ค Track published, updating participant state"),o()},l=()=>{console.log("๐ค Track unpublished, updating participant state"),o()};return s.on("localTrackPublished",a),s.on("localTrackUnpublished",l),()=>{e.off("connection.connected",o),e.off("connection.disconnected",o),e.off("track.muted",o),e.off("track.unmuted",o),s.off("localTrackPublished",a),s.off("localTrackUnpublished",l)}}else return()=>{e.off("connection.connected",o),e.off("connection.disconnected",o),e.off("track.muted",o),e.off("track.unmuted",o)}},[e]),{localParticipant:t,microphoneTrack:r}}function to(e,t,n){const[r,i]=A.useState(!1),[o,s]=A.useState(!1);return A.useEffect(()=>{const l=()=>{let c=!1;switch(t){case"microphone":c=e.isMicrophoneEnabled;break;case"camera":c=e.isCameraEnabled;break;case"screenShare":c=e.isScreenShareEnabled;break}console.log(`๐ฌ useVoxketTrackToggle: ${t} enabled state updated:`,{oldEnabled:r,newEnabled:c,changed:r!==c}),i(c)};return l(),e.on("track.muted",l),e.on("track.unmuted",l),e.on("connection.connected",l),()=>{e.off("track.muted",l),e.off("track.unmuted",l),e.off("connection.connected",l)}},[e,t]),{enabled:r,pending:o,toggle:async l=>{try{s(!0);const c=l!==void 0?l:!r;switch(console.log(`๐ฌ useVoxketTrackToggle: ${t} toggle called`,{currentEnabled:r,targetEnabled:c,forceEnabled:l}),t){case"microphone":await e.toggleMicrophone(c);break;case"camera":await e.toggleCamera(c);break;case"screenShare":c?(console.log("๐ฌ useVoxketTrackToggle: Starting screen share"),await e.startScreenShare()):(console.log("๐ฌ useVoxketTrackToggle: Stopping screen share"),await e.stopScreenShare());break}console.log(`๐ฌ useVoxketTrackToggle: ${t} toggle completed`)}catch(c){console.error(`๐ฌ useVoxketTrackToggle: ${t} toggle failed:`,c)}finally{s(!1)}}}}function _w(e){const[t,n]=A.useState(()=>e.getRoom()),[r,i]=A.useState(()=>e.getConnectionState());return A.useEffect(()=>{const o=()=>{n(e.getRoom()),i(e.getConnectionState())};return e.on("connection.connected",o),e.on("connection.disconnected",o),e.on("connection.connecting",o),()=>{e.off("connection.connected",o),e.off("connection.disconnected",o),e.off("connection.connecting",o)}},[e]),t}function xl(e){const[t,n]=A.useState(()=>e.getIsAgentConnected()),[r,i]=A.useState(()=>e.getCurrentSession()),[o,s]=A.useState(()=>e.getCurrentAgentInfo()),[a,l]=A.useState(()=>e.getAgentState()),[c,u]=A.useState(()=>e.getAgentAudioTrack()),[d,f]=A.useState(()=>e.getAgentVideoTrack());return A.useEffect(()=>{const p=()=>{const E=e.getIsAgentConnected(),_=e.getCurrentSession(),v=e.getCurrentAgentInfo(),C=e.getAgentState(),M=e.getAgentAudioTrack(),N=e.getAgentVideoTrack();console.log("๐ค useVoxketVoiceAssistant: Updating state:",{isAgentConnected:E,hasSession:!!_,sessionId:_==null?void 0:_.id,hasAgentInfo:!!v,agentState:C,hasAudioTrack:!!M,hasVideoTrack:!!N}),n(E),i(_),s(v),l(C),u(M),f(N)};p();const g=()=>{console.log("๐ค useVoxketVoiceAssistant: Agent connected event"),p()},m=()=>{console.log("๐ค useVoxketVoiceAssistant: Agent disconnected event"),p()},x=()=>{console.log("๐ค useVoxketVoiceAssistant: Session changed event"),p()},y=()=>{console.log("๐ค useVoxketVoiceAssistant: Connection changed event"),p()},k=()=>{console.log("๐ค useVoxketVoiceAssistant: Agent state changed event"),p()};return e.on("agent.connected",g),e.on("agent.speaking",g),e.on("agent.thinking",g),e.on("agent.state.changed",k),e.on("connection.disconnected",m),e.on("session.created",x),e.on("session.ended",x),e.on("session.state.changed",x),e.on("connection.connected",y),()=>{e.off("agent.connected",g),e.off("agent.speaking",g),e.off("agent.thinking",g),e.off("agent.state.changed",k),e.off("connection.disconnected",m),e.off("session.created",x),e.off("session.ended",x),e.off("session.state.changed",x),e.off("connection.connected",y)}},[e]),{agent:{isActive:t,info:o},session:r,state:a,audioTrack:c,videoTrack:d}}function Tw(e){const[t,n]=A.useState(()=>e.getVideoTrackRefs()),[r,i]=A.useState(()=>e.getCameraTrackRefs()),[o,s]=A.useState(()=>e.getScreenShareTrackRefs());return A.useEffect(()=>{const a=()=>{const c=e.getVideoTrackRefs(),u=e.getCameraTrackRefs(),d=e.getScreenShareTrackRefs();console.log("๐น useVoxketVideoTracks: Updating tracks:",{videoCount:c.length,cameraCount:u.length,screenShareCount:d.length}),n(c),i(u),s(d)};a(),e.on("connection.connected",a),e.on("connection.disconnected",a),e.on("track.muted",a),e.on("track.unmuted",a),e.on("participant.joined",a),e.on("participant.left",a);const l=e.getRoom();if(l){const c=()=>{console.log("๐น Track event, updating video tracks"),a()};return l.on("localTrackPublished",c),l.on("localTrackUnpublished",c),l.on("trackPublished",c),l.on("trackUnpublished",c),l.on("trackSubscribed",c),l.on("trackUnsubscribed",c),()=>{e.off("connection.connected",a),e.off("connection.disconnected",a),e.off("track.muted",a),e.off("track.unmuted",a),e.off("participant.joined",a),e.off("participant.left",a),l.off("localTrackPublished",c),l.off("localTrackUnpublished",c),l.off("trackPublished",c),l.off("trackUnpublished",c),l.off("trackSubscribed",c),l.off("trackUnsubscribed",c)}}else return()=>{e.off("connection.connected",a),e.off("connection.disconnected",a),e.off("track.muted",a),e.off("track.unmuted",a),e.off("participant.joined",a),e.off("participant.left",a)}},[e]),{videoTrackRefs:t,cameraTrackRefs:r,screenShareTrackRefs:o}}const wl="-",Nw=e=>{const t=Rw(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:s=>{const a=s.split(wl);return a[0]===""&&a.length!==1&&a.shift(),Zh(a,t)||Aw(s)},getConflictingClassGroupIds:(s,a)=>{const l=n[s]||[];return a&&r[s]?[...l,...r[s]]:l}}},Zh=(e,t)=>{var s;if(e.length===0)return t.classGroupId;const n=e[0],r=t.nextPart.get(n),i=r?Zh(e.slice(1),r):void 0;if(i)return i;if(t.validators.length===0)return;const o=e.join(wl);return(s=t.validators.find(({validator:a})=>a(o)))==null?void 0:s.classGroupId},Au=/^\[(.+)\]$/,Aw=e=>{if(Au.test(e)){const t=Au.exec(e)[1],n=t==null?void 0:t.substring(0,t.indexOf(":"));if(n)return"arbitrary.."+n}},Rw=e=>{const{theme:t,classGroups:n}=e,r={nextPart:new Map,validators:[]};for(const i in n)ya(n[i],r,i,t);return r},ya=(e,t,n,r)=>{e.forEach(i=>{if(typeof i=="string"){const o=i===""?t:Ru(t,i);o.classGroupId=n;return}if(typeof i=="function"){if(Mw(i)){ya(i(r),t,n,r);return}t.validators.push({validator:i,classGroupId:n});return}Object.entries(i).forEach(([o,s])=>{ya(s,Ru(t,o),n,r)})})},Ru=(e,t)=>{let n=e;return t.split(wl).forEach(r=>{n.nextPart.has(r)||n.nextPart.set(r,{nextPart:new Map,validators:[]}),n=n.nextPart.get(r)}),n},Mw=e=>e.isThemeGetter,Iw=e=>{if(e<1)return{get:()=>{},set:()=>{}};let t=0,n=new Map,r=new Map;const i=(o,s)=>{n.set(o,s),t++,t>e&&(t=0,r=n,n=new Map)};return{get(o){let s=n.get(o);if(s!==void 0)return s;if((s=r.get(o))!==void 0)return i(o,s),s},set(o,s){n.has(o)?n.set(o,s):i(o,s)}}},xa="!",wa=":",Ow=wa.length,Pw=e=>{const{prefix:t,experimentalParseClassName:n}=e;let r=i=>{const o=[];let s=0,a=0,l=0,c;for(let g=0;g<i.length;g++){let m=i[g];if(s===0&&a===0){if(m===wa){o.push(i.slice(l,g)),l=g+Ow;continue}if(m==="/"){c=g;continue}}m==="["?s++:m==="]"?s--:m==="("?a++:m===")"&&a--}const u=o.length===0?i:i.substring(l),d=Dw(u),f=d!==u,p=c&&c>l?c-l:void 0;return{modifiers:o,hasImportantModifier:f,baseClassName:d,maybePostfixModifierPosition:p}};if(t){const i=t+wa,o=r;r=s=>s.startsWith(i)?o(s.substring(i.length)):{isExternal:!0,modifiers:[],hasImportantModifier:!1,baseClassName:s,maybePostfixModifierPosition:void 0}}if(n){const i=r;r=o=>n({className:o,parseClassName:i})}return r},Dw=e=>e.endsWith(xa)?e.substring(0,e.length-1):e.startsWith(xa)?e.substring(1):e,Lw=e=>{const t=Object.fromEntries(e.orderSensitiveModifiers.map(r=>[r,!0]));return r=>{if(r.length<=1)return r;const i=[];let o=[];return r.forEach(s=>{s[0]==="["||t[s]?(i.push(...o.sort(),s),o=[]):o.push(s)}),i.push(...o.sort()),i}},Fw=e=>({cache:Iw(e.cacheSize),parseClassName:Pw(e),sortModifiers:Lw(e),...Nw(e)}),jw=/\s+/,Bw=(e,t)=>{const{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:o}=t,s=[],a=e.trim().split(jw);let l="";for(let c=a.length-1;c>=0;c-=1){const u=a[c],{isExternal:d,modifiers:f,hasImportantModifier:p,baseClassName:g,maybePostfixModifierPosition:m}=n(u);if(d){l=u+(l.length>0?" "+l:l);continue}let x=!!m,y=r(x?g.substring(0,m):g);if(!y){if(!x){l=u+(l.length>0?" "+l:l);continue}if(y=r(g),!y){l=u+(l.length>0?" "+l:l);continue}x=!1}const k=o(f).join(":"),E=p?k+xa:k,_=E+y;if(s.includes(_))continue;s.push(_);const v=i(y,x);for(let C=0;C<v.length;++C){const M=v[C];s.push(E+M)}l=u+(l.length>0?" "+l:l)}return l};function $w(){let e=0,t,n,r="";for(;e<arguments.length;)(t=arguments[e++])&&(n=Xh(t))&&(r&&(r+=" "),r+=n);return r}const Xh=e=>{if(typeof e=="string")return e;let t,n="";for(let r=0;r<e.length;r++)e[r]&&(t=Xh(e[r]))&&(n&&(n+=" "),n+=t);return n};function Vw(e,...t){let n,r,i,o=s;function s(l){const c=t.reduce((u,d)=>d(u),e());return n=Fw(c),r=n.cache.get,i=n.cache.set,o=a,a(l)}function a(l){const c=r(l);if(c)return c;const u=Bw(l,n);return i(l,u),u}return function(){return o($w.apply(null,arguments))}}const vt=e=>{const t=n=>n[e]||[];return t.isThemeGetter=!0,t},Qh=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jh=/^\((?:(\w[\w-]*):)?(.+)\)$/i,zw=/^\d+\/\d+$/,Uw=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Hw=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Ww=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,Gw=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,Kw=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,nr=e=>zw.test(e),Me=e=>!!e&&!Number.isNaN(Number(e)),_n=e=>!!e&&Number.isInteger(Number(e)),ms=e=>e.endsWith("%")&&Me(e.slice(0,-1)),pn=e=>Uw.test(e),qw=()=>!0,Yw=e=>Hw.test(e)&&!Ww.test(e),ep=()=>!1,Zw=e=>Gw.test(e),Xw=e=>Kw.test(e),Qw=e=>!fe(e)&&!he(e),Jw=e=>Ir(e,rp,ep),fe=e=>Qh.test(e),$n=e=>Ir(e,ip,Yw),gs=e=>Ir(e,iv,Me),Mu=e=>Ir(e,tp,ep),ev=e=>Ir(e,np,Xw),Pi=e=>Ir(e,op,Zw),he=e=>Jh.test(e),jr=e=>Or(e,ip),tv=e=>Or(e,ov),Iu=e=>Or(e,tp),nv=e=>Or(e,rp),rv=e=>Or(e,np),Di=e=>Or(e,op,!0),Ir=(e,t,n)=>{const r=Qh.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Or=(e,t,n=!1)=>{const r=Jh.exec(e);return r?r[1]?t(r[1]):n:!1},tp=e=>e==="position"||e==="percentage",np=e=>e==="image"||e==="url",rp=e=>e==="length"||e==="size"||e==="bg-size",ip=e=>e==="length",iv=e=>e==="number",ov=e=>e==="family-name",op=e=>e==="shadow",sv=()=>{const e=vt("color"),t=vt("font"),n=vt("text"),r=vt("font-weight"),i=vt("tracking"),o=vt("leading"),s=vt("breakpoint"),a=vt("container"),l=vt("spacing"),c=vt("radius"),u=vt("shadow"),d=vt("inset-shadow"),f=vt("text-shadow"),p=vt("drop-shadow"),g=vt("blur"),m=vt("perspective"),x=vt("aspect"),y=vt("ease"),k=vt("animate"),E=()=>["auto","avoid","all","avoid-page","page","left","right","column"],_=()=>["center","top","bottom","left","right","top-left","left-top","top-right","right-top","bottom-right","right-bottom","bottom-left","left-bottom"],v=()=>[..._(),he,fe],C=()=>["auto","hidden","clip","visible","scroll"],M=()=>["auto","contain","none"],N=()=>[he,fe,l],O=()=>[nr,"full","auto",...N()],b=()=>[_n,"none","subgrid",he,fe],R=()=>["auto",{span:["full",_n,he,fe]},_n,he,fe],I=()=>[_n,"auto",he,fe],B=()=>["auto","min","max","fr",he,fe],F=()=>["start","end","center","between","around","evenly","stretch","baseline","center-safe","end-safe"],q=()=>["start","end","center","stretch","center-safe","end-safe"],ne=()=>["auto",...N()],ee=()=>[nr,"auto","full","dvw","dvh","lvw","lvh","svw","svh","min","max","fit",...N()],$=()=>[e,he,fe],D=()=>[..._(),Iu,Mu,{position:[he,fe]}],w=()=>["no-repeat",{repeat:["","x","y","space","round"]}],j=()=>["auto","cover","contain",nv,Jw,{size:[he,fe]}],Y=()=>[ms,jr,$n],S=()=>["","none","full",c,he,fe],H=()=>["",Me,jr,$n],U=()=>["solid","dashed","dotted","double"],Z=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],W=()=>[Me,ms,Iu,Mu],ue=()=>["","none",g,he,fe],te=()=>["none",Me,he,fe],ae=()=>["none",Me,he,fe],Oe=()=>[Me,he,fe],L=()=>[nr,"full",...N()];return{cacheSize:500,theme:{animate:["spin","ping","pulse","bounce"],aspect:["video"],blur:[pn],breakpoint:[pn],color:[qw],container:[pn],"drop-shadow":[pn],ease:["in","out","in-out"],font:[Qw],"font-weight":["thin","extralight","light","normal","medium","semibold","bold","extrabold","black"],"inset-shadow":[pn],leading:["none","tight","snug","normal","relaxed","loose"],perspective:["dramatic","near","normal","midrange","distant","none"],radius:[pn],shadow:[pn],spacing:["px",Me],text:[pn],"text-shadow":[pn],tracking:["tighter","tight","normal","wide","wider","widest"]},classGroups:{aspect:[{aspect:["auto","square",nr,fe,he,x]}],container:["container"],columns:[{columns:[Me,fe,he,a]}],"break-after":[{"break-after":E()}],"break-before":[{"break-before":E()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],sr:["sr-only","not-sr-only"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:v()}],overflow:[{overflow:C()}],"overflow-x":[{"overflow-x":C()}],"overflow-y":[{"overflow-y":C()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:O()}],"inset-x":[{"inset-x":O()}],"inset-y":[{"inset-y":O()}],start:[{start:O()}],end:[{end:O()}],top:[{top:O()}],right:[{right:O()}],bottom:[{bottom:O()}],left:[{left:O()}],visibility:["visible","invisible","collapse"],z:[{z:[_n,"auto",he,fe]}],basis:[{basis:[nr,"full","auto",a,...N()]}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["nowrap","wrap","wrap-reverse"]}],flex:[{flex:[Me,nr,"auto","initial","none",fe]}],grow:[{grow:["",Me,he,fe]}],shrink:[{shrink:["",Me,he,fe]}],order:[{order:[_n,"first","last","none",he,fe]}],"grid-cols":[{"grid-cols":b()}],"col-start-end":[{col:R()}],"col-start":[{"col-start":I()}],"col-end":[{"col-end":I()}],"grid-rows":[{"grid-rows":b()}],"row-start-end":[{row:R()}],"row-start":[{"row-start":I()}],"row-end":[{"row-end":I()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":B()}],"auto-rows":[{"auto-rows":B()}],gap:[{gap:N()}],"gap-x":[{"gap-x":N()}],"gap-y":[{"gap-y":N()}],"justify-content":[{justify:[...F(),"normal"]}],"justify-items":[{"justify-items":[...q(),"normal"]}],"justify-self":[{"justify-self":["auto",...q()]}],"align-content":[{content:["normal",...F()]}],"align-items":[{items:[...q(),{baseline:["","last"]}]}],"align-self":[{self:["auto",...q(),{baseline:["","last"]}]}],"place-content":[{"place-content":F()}],"place-items":[{"place-items":[...q(),"baseline"]}],"place-self":[{"place-self":["auto",...q()]}],p:[{p:N()}],px:[{px:N()}],py:[{py:N()}],ps:[{ps:N()}],pe:[{pe:N()}],pt:[{pt:N()}],pr:[{pr:N()}],pb:[{pb:N()}],pl:[{pl:N()}],m:[{m:ne()}],mx:[{mx:ne()}],my:[{my:ne()}],ms:[{ms:ne()}],me:[{me:ne()}],mt:[{mt:ne()}],mr:[{mr:ne()}],mb:[{mb:ne()}],ml:[{ml:ne()}],"space-x":[{"space-x":N()}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":N()}],"space-y-reverse":["space-y-reverse"],size:[{size:ee()}],w:[{w:[a,"screen",...ee()]}],"min-w":[{"min-w":[a,"screen","none",...ee()]}],"max-w":[{"max-w":[a,"screen","none","prose",{screen:[s]},...ee()]}],h:[{h:["screen","lh",...ee()]}],"min-h":[{"min-h":["screen","lh","none",...ee()]}],"max-h":[{"max-h":["screen","lh",...ee()]}],"font-size":[{text:["base",n,jr,$n]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:[r,he,gs]}],"font-stretch":[{"font-stretch":["ultra-condensed","extra-condensed","condensed","semi-condensed","normal","semi-expanded","expanded","extra-expanded","ultra-expanded",ms,fe]}],"font-family":[{font:[tv,fe,t]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:[i,he,fe]}],"line-clamp":[{"line-clamp":[Me,"none",he,gs]}],leading:[{leading:[o,...N()]}],"list-image":[{"list-image":["none",he,fe]}],"list-style-position":[{list:["inside","outside"]}],"list-style-type":[{list:["disc","decimal","none",he,fe]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"placeholder-color":[{placeholder:$()}],"text-color":[{text:$()}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...U(),"wavy"]}],"text-decoration-thickness":[{decoration:[Me,"from-font","auto",he,$n]}],"text-decoration-color":[{decoration:$()}],"underline-offset":[{"underline-offset":[Me,"auto",he,fe]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:N()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",he,fe]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],wrap:[{wrap:["break-word","anywhere","normal"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",he,fe]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:D()}],"bg-repeat":[{bg:w()}],"bg-size":[{bg:j()}],"bg-image":[{bg:["none",{linear:[{to:["t","tr","r","br","b","bl","l","tl"]},_n,he,fe],radial:["",he,fe],conic:[_n,he,fe]},rv,ev]}],"bg-color":[{bg:$()}],"gradient-from-pos":[{from:Y()}],"gradient-via-pos":[{via:Y()}],"gradient-to-pos":[{to:Y()}],"gradient-from":[{from:$()}],"gradient-via":[{via:$()}],"gradient-to":[{to:$()}],rounded:[{rounded:S()}],"rounded-s":[{"rounded-s":S()}],"rounded-e":[{"rounded-e":S()}],"rounded-t":[{"rounded-t":S()}],"rounded-r":[{"rounded-r":S()}],"rounded-b":[{"rounded-b":S()}],"rounded-l":[{"rounded-l":S()}],"rounded-ss":[{"rounded-ss":S()}],"rounded-se":[{"rounded-se":S()}],"rounded-ee":[{"rounded-ee":S()}],"rounded-es":[{"rounded-es":S()}],"rounded-tl":[{"rounded-tl":S()}],"rounded-tr":[{"rounded-tr":S()}],"rounded-br":[{"rounded-br":S()}],"rounded-bl":[{"rounded-bl":S()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":H()}],"divide-y-reverse":["divide-y-reverse"],"border-style":[{border:[...U(),"hidden","none"]}],"divide-style":[{divide:[...U(),"hidden","none"]}],"border-color":[{border:$()}],"border-color-x":[{"border-x":$()}],"border-color-y":[{"border-y":$()}],"border-color-s":[{"border-s":$()}],"border-color-e":[{"border-e":$()}],"border-color-t":[{"border-t":$()}],"border-color-r":[{"border-r":$()}],"border-color-b":[{"border-b":$()}],"border-color-l":[{"border-l":$()}],"divide-color":[{divide:$()}],"outline-style":[{outline:[...U(),"none","hidden"]}],"outline-offset":[{"outline-offset":[Me,he,fe]}],"outline-w":[{outline:["",Me,jr,$n]}],"outline-color":[{outline:$()}],shadow:[{shadow:["","none",u,Di,Pi]}],"shadow-color":[{shadow:$()}],"inset-shadow":[{"inset-shadow":["none",d,Di,Pi]}],"inset-shadow-color":[{"inset-shadow":$()}],"ring-w":[{ring:H()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:$()}],"ring-offset-w":[{"ring-offset":[Me,$n]}],"ring-offset-color":[{"ring-offset":$()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":$()}],"text-shadow":[{"text-shadow":["none",f,Di,Pi]}],"text-shadow-color":[{"text-shadow":$()}],opacity:[{opacity:[Me,he,fe]}],"mix-blend":[{"mix-blend":[...Z(),"plus-darker","plus-lighter"]}],"bg-blend":[{"bg-blend":Z()}],"mask-clip":[{"mask-clip":["border","padding","content","fill","stroke","view"]},"mask-no-clip"],"mask-composite":[{mask:["add","subtract","intersect","exclude"]}],"mask-image-linear-pos":[{"mask-linear":[Me]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":$()}],"mask-image-linear-to-color":[{"mask-linear-to":$()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":$()}],"mask-image-t-to-color":[{"mask-t-to":$()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":$()}],"mask-image-r-to-color":[{"mask-r-to":$()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":$()}],"mask-image-b-to-color":[{"mask-b-to":$()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":$()}],"mask-image-l-to-color":[{"mask-l-to":$()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":$()}],"mask-image-x-to-color":[{"mask-x-to":$()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":$()}],"mask-image-y-to-color":[{"mask-y-to":$()}],"mask-image-radial":[{"mask-radial":[he,fe]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":$()}],"mask-image-radial-to-color":[{"mask-radial-to":$()}],"mask-image-radial-shape":[{"mask-radial":["circle","ellipse"]}],"mask-image-radial-size":[{"mask-radial":[{closest:["side","corner"],farthest:["side","corner"]}]}],"mask-image-radial-pos":[{"mask-radial-at":_()}],"mask-image-conic-pos":[{"mask-conic":[Me]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":$()}],"mask-image-conic-to-color":[{"mask-conic-to":$()}],"mask-mode":[{mask:["alpha","luminance","match"]}],"mask-origin":[{"mask-origin":["border","padding","content","fill","stroke","view"]}],"mask-position":[{mask:D()}],"mask-repeat":[{mask:w()}],"mask-size":[{mask:j()}],"mask-type":[{"mask-type":["alpha","luminance"]}],"mask-image":[{mask:["none",he,fe]}],filter:[{filter:["","none",he,fe]}],blur:[{blur:ue()}],brightness:[{brightness:[Me,he,fe]}],contrast:[{contrast:[Me,he,fe]}],"drop-shadow":[{"drop-shadow":["","none",p,Di,Pi]}],"drop-shadow-color":[{"drop-shadow":$()}],grayscale:[{grayscale:["",Me,he,fe]}],"hue-rotate":[{"hue-rotate":[Me,he,fe]}],invert:[{invert:["",Me,he,fe]}],saturate:[{saturate:[Me,he,fe]}],sepia:[{sepia:["",Me,he,fe]}],"backdrop-filter":[{"backdrop-filter":["","none",he,fe]}],"backdrop-blur":[{"backdrop-blur":ue()}],"backdrop-brightness":[{"backdrop-brightness":[Me,he,fe]}],"backdrop-contrast":[{"backdrop-contrast":[Me,he,fe]}],"backdrop-grayscale":[{"backdrop-grayscale":["",Me,he,fe]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Me,he,fe]}],"backdrop-invert":[{"backdrop-invert":["",Me,he,fe]}],"backdrop-opacity":[{"backdrop-opacity":[Me,he,fe]}],"backdrop-saturate":[{"backdrop-saturate":[Me,he,fe]}],"backdrop-sepia":[{"backdrop-sepia":["",Me,he,fe]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":N()}],"border-spacing-x":[{"border-spacing-x":N()}],"border-spacing-y":[{"border-spacing-y":N()}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["","all","colors","opacity","shadow","transform","none",he,fe]}],"transition-behavior":[{transition:["normal","discrete"]}],duration:[{duration:[Me,"initial",he,fe]}],ease:[{ease:["linear","initial",y,he,fe]}],delay:[{delay:[Me,he,fe]}],animate:[{animate:["none",k,he,fe]}],backface:[{backface:["hidden","visible"]}],perspective:[{perspective:[m,he,fe]}],"perspective-origin":[{"perspective-origin":v()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ae()}],"scale-x":[{"scale-x":ae()}],"scale-y":[{"scale-y":ae()}],"scale-z":[{"scale-z":ae()}],"scale-3d":["scale-3d"],skew:[{skew:Oe()}],"skew-x":[{"skew-x":Oe()}],"skew-y":[{"skew-y":Oe()}],transform:[{transform:[he,fe,"","none","gpu","cpu"]}],"transform-origin":[{origin:v()}],"transform-style":[{transform:["3d","flat"]}],translate:[{translate:L()}],"translate-x":[{"translate-x":L()}],"translate-y":[{"translate-y":L()}],"translate-z":[{"translate-z":L()}],"translate-none":["translate-none"],accent:[{accent:$()}],appearance:[{appearance:["none","auto"]}],"caret-color":[{caret:$()}],"color-scheme":[{scheme:["normal","dark","light","light-dark","only-dark","only-light"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",he,fe]}],"field-sizing":[{"field-sizing":["fixed","content"]}],"pointer-events":[{"pointer-events":["auto","none"]}],resize:[{resize:["none","","y","x"]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":N()}],"scroll-mx":[{"scroll-mx":N()}],"scroll-my":[{"scroll-my":N()}],"scroll-ms":[{"scroll-ms":N()}],"scroll-me":[{"scroll-me":N()}],"scroll-mt":[{"scroll-mt":N()}],"scroll-mr":[{"scroll-mr":N()}],"scroll-mb":[{"scroll-mb":N()}],"scroll-ml":[{"scroll-ml":N()}],"scroll-p":[{"scroll-p":N()}],"scroll-px":[{"scroll-px":N()}],"scroll-py":[{"scroll-py":N()}],"scroll-ps":[{"scroll-ps":N()}],"scroll-pe":[{"scroll-pe":N()}],"scroll-pt":[{"scroll-pt":N()}],"scroll-pr":[{"scroll-pr":N()}],"scroll-pb":[{"scroll-pb":N()}],"scroll-pl":[{"scroll-pl":N()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",he,fe]}],fill:[{fill:["none",...$()]}],"stroke-w":[{stroke:[Me,jr,$n,gs]}],stroke:[{stroke:["none",...$()]}],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-x","border-w-y","border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-x","border-color-y","border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],translate:["translate-x","translate-y","translate-none"],"translate-none":["translate","translate-x","translate-y","translate-z"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]},orderSensitiveModifiers:["*","**","after","backdrop","before","details-content","file","first-letter","first-line","marker","placeholder","selection"]}},av=Vw(sv);function Qe(...e){return av(ja.clsx(e))}function No(e){var i;if(!e)return{sessionSettings:{},capabilities:{},modality:"voice"};const t={session_timer:((i=e.session_settings)==null?void 0:i.session_timer)||null},n=e.capabilities||{},r=e.modality||"voice";return{sessionSettings:t,capabilities:n,modality:r}}function lv(e,t){return e.capabilities[t]===!0}function Ao(e){return e.sessionSettings.session_timer||null}function sp(e){const t=e.capabilities;return{userVideoEnabled:t.user_video_enabled!==!1,agentAvatarEnabled:t.agent_avatar_enabled!==!1,screenshareEnabled:t.screenshare_session_enabled!==!1}}function ap(e){const t=e.capabilities;return{suggestedReplyEnabled:t.suggested_reply_enabled!==!1,attachmentsEnabled:t.support_in_chat_attachments!==!1}}function lp(e){return{...e.capabilities}}function cp(e){const t=Math.floor(e/60),n=e%60;return`${t}:${n.toString().padStart(2,"0")}`}const up=A.forwardRef(({state:e,audioTrack:t,className:n},r)=>h.jsx("div",{ref:r,className:Qe("",n),children:t?h.jsx(Ft.BarVisualizer,{barCount:5,state:e,options:{minHeight:5},trackRef:t,className:Qe("flex aspect-video w-40 items-center justify-center gap-1"),children:h.jsx("span",{className:Qe(["bg-[#6721a4] min-h-2 w-2 rounded-full","origin-center transition-colors duration-250 ease-linear","data-[lk-highlighted=true]:bg-[#5c64f6]","data-[lk-muted=true]:bg-[#222222]"])})}):h.jsx("div",{className:Qe("flex aspect-video w-40 items-center justify-center"),children:h.jsx("div",{className:"flex flex-col items-center justify-center",children:h.jsx("div",{className:"flex gap-1",children:Array.from({length:5}).map((i,o)=>h.jsx("span",{className:Qe(["bg-[#6721a4] min-h-2 w-2 rounded-full","origin-center transition-colors duration-250 ease-linear",e==="speaking"&&"animate-pulse bg-[#5c64f6]",e==="thinking"&&"animate-pulse bg-yellow-500"])},o))})})})}));up.displayName="AgentTile";const cv=({videoTrack:e,className:t,ref:n})=>{var r,i;return!e||!e.publication||!e.participant?h.jsx("div",{ref:n,className:Qe(t),children:h.jsx("div",{className:"w-full h-full bg-gray-200 rounded-md flex items-center justify-center",children:h.jsx("span",{className:"text-gray-500",children:"No video available"})})}):h.jsx("div",{ref:n,className:Qe(t),children:h.jsx(Ft.VideoTrack,{trackRef:e,width:((r=e.publication.dimensions)==null?void 0:r.width)??0,height:((i=e.publication.dimensions)==null?void 0:i.height)??0,className:"rounded-md"})})},uv=Ae.create(Ft.VideoTrack),dv=({trackRef:e,className:t,ref:n})=>{var r,i;return h.jsx("div",{className:Qe("bg-muted overflow-hidden rounded-md",t),children:h.jsx(uv,{ref:n,trackRef:e,width:((r=e==null?void 0:e.publication.dimensions)==null?void 0:r.width)??0,height:((i=e==null?void 0:e.publication.dimensions)==null?void 0:i.height)??0,className:Qe("h-full w-auto")})})},Ou=Ae.create(dv),fv=Ae.create(up),hv=Ae.create(cv),mn={initial:{opacity:0,scale:0},animate:{opacity:1,scale:1},exit:{opacity:0,scale:0},transition:{type:"spring",stiffness:675,damping:75,mass:1}},rr={grid:["h-full w-full","grid gap-x-2 place-content-center","grid-cols-[1fr_1fr] grid-rows-[90px_1fr_90px]"],agentChatOpenWithSecondTile:["col-start-1 row-start-1","self-center justify-self-end"],agentChatOpenWithoutSecondTile:["col-start-1 row-start-1","col-span-2","place-content-center"],agentChatClosed:["col-start-1 row-start-1","col-span-2","place-content-center"],secondTileChatOpen:["col-start-2 row-start-1","self-center justify-self-start"],secondTileChatClosed:["col-start-2 row-start-3","place-content-end"]};function pv(e,t){const{localParticipant:n}=Cw(t),r=n==null?void 0:n.getTrackPublication(e);return A.useMemo(()=>r&&n?{source:e,participant:n,publication:r}:void 0,[e,r,n])}function mv({chatOpen:e,client:t}){const{agent:{isActive:n=!1}={},session:r,state:i="idle",audioTrack:o,videoTrack:s}=t?xl(t):{agent:{isActive:!1},session:null,state:"idle",audioTrack:null,videoTrack:null},[a]=Ft.useTracks([ce.Track.Source.ScreenShare]),l=pv(ce.Track.Source.Camera,t),c=l&&!l.publication.isMuted,u=a&&!a.publication.isMuted,d=c||u,f=n||r&&r.state==="active",p={...mn.transition,delay:e?0:.15},g={...mn.animate,scale:e?1:3,transition:p},m={...mn.animate,transition:p},x=p,y=p,k=s&&s.publication&&s.participant;return h.jsx("div",{className:"relative w-full h-full z-10 flex items-center justify-center",children:h.jsx("div",{className:"relative w-full h-full max-w-2xl px-4 md:px-0",children:h.jsxs("div",{className:Qe(rr.grid),children:[f&&h.jsx("div",{className:Qe(["grid",!e&&rr.agentChatClosed,e&&d&&rr.agentChatOpenWithSecondTile,e&&!d&&rr.agentChatOpenWithoutSecondTile]),children:h.jsxs("div",{className:"h-full flex items-center justify-center",children:[!k&&h.jsx(fv,{layoutId:"agent",...mn,animate:g,transition:x,state:i,audioTrack:o||void 0,className:Qe(e?"h-[90px]":"h-auto w-full")},"agent"),k&&s&&h.jsx(hv,{layoutId:"avatar",...mn,animate:m,transition:y,videoTrack:s,className:Qe(e?"h-[90px] [&>video]:h-[90px] [&>video]:w-auto":"h-auto w-full")},"avatar")]})}),h.jsx("div",{className:Qe(["grid",e&&rr.secondTileChatOpen,!e&&rr.secondTileChatClosed]),children:h.jsxs("div",{className:"w-full px-10 flex items-center shadow-2xl justify-between",children:[l&&c&&h.jsx(Ou,{layout:"position",layoutId:"camera",...mn,trackRef:l,transition:{...mn.transition,delay:e?0:.15},className:"h-[60px] order-1"},"camera"),u&&h.jsx(Ou,{layout:"position",layoutId:"screen",...mn,trackRef:a,transition:{...mn.transition,delay:e?0:.15},className:"h-[70px] order-2"},"screen")]})})]})})})}const gv={card:" bg-gradient-to-br from-black to-gray-900 border border-gray-900 w-full h-full flex flex-col justify-between overflow-hidden relative rounded-2xl shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-black/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-gray-800/20 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-gray-600/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-gray-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-gray-400 to-gray-500 rounded-full blur-sm opacity-20 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-gray-500 to-gray-600 rounded-full blur-sm opacity-15 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-black to-gray-900 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-white via-gray-200 to-gray-300"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900",promptSlider:"absolute w-full py-3 px-2 bg-gray-900 rounded-xl text-center text-white text-sm transition-opacity duration-700 ease-in-out border border-gray-600",statusIndicator:"w-2 h-2 bg-gray-400 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-gray-600/30 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-gray-500/20 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-gray-400/15 pulse-ring"},controlBar:"border border-gray-600 rounded-3xl py-4 flex flex-col justify-end h-full bg-gray-900/50 backdrop-blur-sm",chatInput:{container:"bg-gray-900 w-full border-gray-600",textarea:"bg-gray-800 border-none text-white placeholder-gray-400",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-gray-600 text-white",other:"bg-gray-700 text-white"},chatHeader:{container:"bg-gray-900 border-gray-600",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-gray-400 mb-2",suggestedResponse:{container:"bg-gray-800 text-blue-300 border-gray-700 hover:bg-gray-700 hover:text-white"},video:{container:"bg-gradient-to-br from-black to-gray-900 text-white",header:"border-gray-700 bg-gray-900/50",headerButton:"bg-gray-800 hover:bg-gray-700 text-gray-300",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-gray-900/80 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-gray-800 border border-gray-700 shadow-lg",placeholder:"bg-gray-800 text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},bv={card:" bg-gradient-to-br from-white to-gray-50 border border-gray-200 w-full h-full flex flex-col justify-between overflow-hidden relative shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-white/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-blue-500/5 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-purple-500/10 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-pink-500/8 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-blue-500 to-purple-500 rounded-full blur-sm opacity-30 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-pink-500 to-purple-500 rounded-full blur-sm opacity-20 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-white to-gray-50 rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-gray-900",secondary:"text-gray-700",muted:"text-gray-500",accent:"bg-clip-text text-transparent bg-gradient-to-r from-blue-600 via-purple-600 to-pink-600"},micButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute text-white w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-white",promptSlider:"absolute w-full py-3 px-2 bg-gray-100 rounded-xl text-center text-gray-700 text-sm transition-opacity duration-700 ease-in-out border border-gray-200",statusIndicator:"w-2 h-2 bg-green-500 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-blue-500/20 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-purple-500/15 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-pink-500/10 pulse-ring"},controlBar:"border border-gray-200 rounded-3xl py-4 flex flex-col justify-end h-full bg-white/80 backdrop-blur-sm",chatInput:{container:"bg-white/90 border-gray-200 shadow-sm",textarea:"bg-white border-none text-gray-900 placeholder-gray-500 ",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-300 disabled:opacity-50 text-white",attachButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100 bg-blue-50",endButton:"bg-red-50 hover:bg-red-100 text-red-600 border-red-200"},chatMessage:{own:"bg-blue-50 text-gray-900 border border-blue-100",other:"bg-gray-50 text-gray-900 border border-gray-200"},chatHeader:{container:"bg-white border-gray-200",backButton:"text-gray-500 hover:text-gray-700 hover:bg-gray-100"},spinner:"w-10 h-10 animate-spin text-blue-500 mb-2",suggestedResponse:{container:"bg-white text-blue-700 border-blue-200 hover:bg-blue-50 hover:text-blue-900"},video:{container:"bg-gradient-to-br from-white to-gray-50 text-gray-900",header:"border-gray-200 bg-white/80",headerButton:"bg-gray-100 hover:bg-gray-200 text-gray-600",statusDot:"bg-green-500 animate-pulse",controlsBackground:"bg-white/90 backdrop-blur-sm border-t border-gray-200",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-gray-200 hover:bg-gray-300 text-gray-600",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-white border border-gray-200 shadow-sm",placeholder:"bg-gray-50 text-gray-600",avatar:"bg-gray-200 text-gray-600",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},yv={card:" text-white bg-gradient-to-br from-[#171727] to-[#12121F] border border-gray-800 w-full h-full flex flex-col justify-between overflow-hidden relative",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-10 z-10 bg-gradient-to-b from-[#171727]/90 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-[#3B82F6]/15 via-transparent to-transparent",cardPurpleBlur:"absolute top-0 right-0 w-32 h-32 bg-gradient-to-br from-[#8B5CF6]/25 to-transparent rounded-full blur-2xl",cardPinkBlur:"absolute bottom-0 left-0 w-24 h-24 bg-gradient-to-tr from-[#EC4899]/20 to-transparent rounded-full blur-xl",cardPulse1:"absolute -top-2 -left-2 w-6 h-6 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full blur-sm opacity-50 animate-pulse",cardPulse2:"absolute -bottom-2 -right-2 w-4 h-4 bg-gradient-to-br from-[#EC4899] to-[#8B5CF6] rounded-full blur-sm opacity-40 animate-pulse",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto bg-gradient-to-br from-[#171727] to-[#12121F] rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-gray-300",muted:"text-gray-400",accent:"bg-clip-text text-transparent bg-gradient-to-r from-[#3B82F6] via-[#8B5CF6] to-[#EC4899]"},micButton:"absolute w-20 h-20 bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 mic-glow shadow-2xl group",chatButton:"absolute w-20 h-20 bg-gradient-to-br from-[#10B981] to-[#059669] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-gradient-to-br from-[#8B5CF6] to-[#EC4899] rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-gradient-to-br from-[#3B82F6] to-[#8B5CF6] text-white font-medium hover:from-[#2563EB] hover:to-[#7C3AED] focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 focus:ring-offset-gray-900 shadow-xl",promptSlider:"absolute w-full py-3 px-2 bg-[#1E1E2E] rounded-xl text-center text-gray-200 text-sm transition-opacity duration-700 ease-in-out border border-gray-700",statusIndicator:"w-2 h-2 bg-[#10B981] rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-[#3B82F6]/40 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-[#8B5CF6]/30 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-[#EC4899]/20 pulse-ring"},controlBar:"border border-border rounded-3xl py-4 flex flex-col justify-end h-full",chatInput:{container:"bg-[#1E1E2E] border-gray-700",textarea:"bg-[#1E1E2E] border-none text-white placeholder-gray-400",sendButton:"bg-[#3B82F6] hover:bg-[#2563EB] disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-gray-700",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-[#1E1E2E]/80 text-white",other:"bg-[#1E1E2E] text-white border border-gray-700"},chatHeader:{container:"bg-[#1E1E2E] border-gray-700",backButton:"text-gray-400 hover:text-white hover:bg-gray-700"},spinner:"w-10 h-10 animate-spin text-blue-400 mb-2",suggestedResponse:{container:"bg-[#221f3f] text-white border-none"},video:{container:"bg-gradient-to-br from-[#171727] to-[#12121F] text-white",header:"border-gray-700 bg-[#1E1E2E]/80",headerButton:"bg-[#1E1E2E] hover:bg-gray-700 text-gray-300",statusDot:"bg-[#10B981] animate-pulse",controlsBackground:"bg-[#1E1E2E]/90 backdrop-blur-sm border-t border-gray-700",controlEnabled:"bg-[#3B82F6] hover:bg-[#2563EB] text-white",controlDisabled:"bg-gray-700 hover:bg-gray-600 text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-[#1E1E2E] border border-gray-700 shadow-xl",placeholder:"bg-[#1E1E2E] text-gray-300",avatar:"bg-gray-700 text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},xv={card:"text-white border border-[#2a3142] w-full h-full flex flex-col justify-between overflow-hidden relative rounded-2xl shadow-lg",cardTopGradient:"pointer-events-none absolute top-0 left-0 w-full h-16 z-10 bg-gradient-to-b from-[#0b1220]/95 to-transparent",cardRadial:"absolute inset-0 bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-cyan-400/18 via-transparent to-transparent",cardPurpleBlur:"absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-72 h-72 bg-gradient-to-br from-sky-500/25 to-transparent rounded-full blur-3xl",cardPinkBlur:"absolute bottom-0 left-0 w-44 h-44 bg-gradient-to-tr from-cyan-300/18 to-transparent rounded-full blur-2xl",cardPulse1:"hidden",cardPulse2:"hidden",main:"w-full flex flex-col items-center justify-center max-w-md mx-auto rounded-2xl shadow-xl p-0 overflow-hidden h-full",text:{primary:"text-white",secondary:"text-white",muted:"text-white",accent:"text-cyan-300"},micButton:"absolute w-20 h-20 bg-[#171b26] text-white rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",chatButton:"absolute w-20 h-20 bg-[#171b26] text-white rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",videoButton:"absolute w-20 h-20 bg-[#171b26] text-white rounded-full flex items-center justify-center hover:scale-105 transition-all duration-300 shadow-2xl group",popupTrigger:"bg-[#0b8c8c] text-white font-medium hover:bg-[#0a7c7c] focus:outline-none focus:ring-2 focus:ring-[#0b8c8c] focus:ring-offset-2 focus:ring-offset-[#161a25] shadow-xl",promptSlider:"absolute w-full py-3 px-2 bg-[#1c2230] rounded-xl text-center text-gray-200 text-sm transition-opacity duration-700 ease-in-out border border-[#2a3142]",statusIndicator:"w-2 h-2 bg-emerald-500 rounded-full animate-pulse",pulseRings:{ring1:"w-32 h-32 rounded-full border-2 border-cyan-400/20 pulse-ring",ring2:"absolute w-28 h-28 rounded-full border-2 border-cyan-300/15 pulse-ring",ring3:"absolute w-24 h-24 rounded-full border-2 border-cyan-200/10 pulse-ring"},controlBar:"border border-[#2a3142] rounded-3xl py-4 flex flex-col justify-end h-full bg-[#161a25] backdrop-blur-0",chatInput:{container:"bg-[#1c2230] w-full border-[#2a3142]",textarea:"bg-[#1c2230] border-none text-white placeholder-gray-400",sendButton:"bg-blue-600 hover:bg-blue-700 disabled:bg-gray-600 disabled:opacity-50 text-white",attachButton:"text-gray-400 hover:text-gray-300 hover:bg-[#2a3142]",endButton:"bg-red-900/20 hover:bg-red-800/30 text-red-400 border-red-800"},chatMessage:{own:"bg-[#243049] text-white",other:"bg-[#1c2230] text-white border border-[#2a3142]"},chatHeader:{container:"bg-[#1c2230] border-[#2a3142]",backButton:"text-white hover:text-white hover:bg-[#2a3142]"},spinner:"w-10 h-10 animate-spin text-blue-400 mb-2",suggestedResponse:{container:"bg-[#1c2230] text-white border-[#2a3142] hover:bg-[#222a3a] hover:text-white"},video:{container:"bg-[#161a25] text-white",header:"border-[#2a3142] bg-[#1c2230]",headerButton:"bg-[#1c2230] hover:bg-[#2a3142] text-white",statusDot:"bg-emerald-500 animate-pulse",controlsBackground:"bg-[#1c2230] backdrop-blur-0 border-t border-[#2a3142]",controlEnabled:"bg-blue-600 hover:bg-blue-700 text-white",controlDisabled:"bg-[#2a3142] hover:bg-[#334056] text-gray-300",endCall:"bg-red-600 hover:bg-red-700 text-white",tile:"bg-[#1c2230] border border-[#2a3142] shadow-lg",placeholder:"bg-[#1c2230] text-white",avatar:"bg-[#2a3142] text-gray-300",nameOverlay:"bg-black/70 text-white",mutedIndicator:"bg-red-600/80 text-white"}},Pu={dark:gv,light:bv,vox:yv,midnight:xv};function Ct(e){return Pu[e]||Pu.vox}function Du({timeout:e}){const[t,n]=A.useState(100),r=A.useRef(null),i=A.useRef(null);return A.useEffect(()=>{if(!e||e<=0)return;n(100),i.current=Date.now();const o=()=>{if(!e||i.current===null)return;const s=Date.now()-i.current,a=Math.max(0,100-s/e*100);n(a),a>0&&(r.current=requestAnimationFrame(o))};return r.current=requestAnimationFrame(o),()=>{r.current&&cancelAnimationFrame(r.current)}},[e]),!e||e<=0?null:h.jsx("div",{className:"w-full h-1 relative top-1 rounded-t-4xl bg-gray-700 overflow-hidden",children:h.jsx(Ae.div,{className:"h-1 rounded-t-4xl dark:bg-white bg-blue-200 ",initial:{width:"100%"},animate:{width:`${Math.max(t,2)}%`},transition:{duration:.1,ease:"linear"},style:{minWidth:"2%"}})})}function li({interaction:e,theme:t,onDismiss:n,client:r,addLocalMessage:i}){var a;if(!e||!e.isVisible||!e.component)return null;const[o]=P.useState(()=>Date.now()),s=()=>e.component?P.createElement(e.component,{handler:e.handler||void 0,timeout:e.timeout,loadData:async c=>{console.log("InteractiveComponent: Loading data:",c)},presentationMode:e.presentationMode,data:e.data,client:r,addLocalMessage:i}):h.jsx("div",{className:"p-4 text-red-500",children:"Component not found"});switch(e.presentationMode){case"fullscreen":return h.jsx(Sr,{children:h.jsxs(Ae.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 z-[9999] bg-black",children:[h.jsxs("div",{className:"flex flex-col",children:[h.jsx(Du,{timeout:e.timeout}),h.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/80 text-white border-b border-gray-700",children:[h.jsx("h3",{className:"text-lg font-semibold",children:e.methodName.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}),h.jsx("button",{onClick:n||((a=e.handler)==null?void 0:a.dismissView),className:"p-2 rounded-full bg-white/20 hover:bg-white/30 text-white transition-colors",children:h.jsx(ze.X,{className:"w-5 h-5"})})]})]}),h.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:s()})]})});case"embedded":default:return h.jsx(Sr,{children:h.jsx(Ae.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-fit rounded-lg ",children:h.jsxs("div",{children:[h.jsx(Du,{timeout:e.timeout}),s()]})})})}}function ci({duration:e,theme:t="vox",onTimerExpired:n,className:r="",showIcon:i=!0}){const[o,s]=A.useState(e),[a,l]=A.useState(!1);A.useEffect(()=>{if(o<=0){l(!0),n==null||n();return}const u=setInterval(()=>{s(d=>{const f=d-1;return f<=0?(l(!0),n==null||n(),0):f})},1e3);return()=>clearInterval(u)},[o,n]),A.useEffect(()=>{s(e),l(!1)},[e]);const c=()=>a?"text-red-500":o<=60?"text-orange-500":o<=300?"text-yellow-500":t==="dark"?"text-gray-300":"text-gray-600";return h.jsxs("div",{className:`flex items-center gap-1 text-sm ${c()} ${r}`,children:[i&&h.jsx(ze.Clock,{className:"w-4 h-4"}),h.jsx("span",{className:"font-mono",children:cp(o)}),a&&h.jsx("span",{className:"text-xs ml-1 text-red-500",children:"(Expired)"})]})}const wv=({logLevel:e}={})=>{const t=Ft.useRoomContext();P.useEffect(()=>(ce.setLogLevel(e??"debug"),window.__lk_room=t,()=>{window.__lk_room=void 0}),[t,e])},dp=P.forwardRef((e,t)=>{const{alt:n,color:r="currentColor",size:i="1em",weight:o="regular",mirrored:s=!1,children:a,weights:l,...c}=e;return P.createElement("svg",{ref:t,xmlns:"http://www.w3.org/2000/svg",width:i,height:i,fill:r,viewBox:"0 0 256 256",transform:s?"scale(-1, 1)":void 0,...c},!!n&&P.createElement("title",null,n),a,l.get(o))});dp.displayName="SSRBase";const vv=new Map([["bold",P.createElement(P.Fragment,null,P.createElement("path",{d:"M140,32V64a12,12,0,0,1-24,0V32a12,12,0,0,1,24,0Zm33.25,62.75a12,12,0,0,0,8.49-3.52L204.37,68.6a12,12,0,0,0-17-17L164.77,74.26a12,12,0,0,0,8.48,20.49ZM224,116H192a12,12,0,0,0,0,24h32a12,12,0,0,0,0-24Zm-42.26,48.77a12,12,0,1,0-17,17l22.63,22.63a12,12,0,0,0,17-17ZM128,180a12,12,0,0,0-12,12v32a12,12,0,0,0,24,0V192A12,12,0,0,0,128,180ZM74.26,164.77,51.63,187.4a12,12,0,0,0,17,17l22.63-22.63a12,12,0,1,0-17-17ZM76,128a12,12,0,0,0-12-12H32a12,12,0,0,0,0,24H64A12,12,0,0,0,76,128ZM68.6,51.63a12,12,0,1,0-17,17L74.26,91.23a12,12,0,0,0,17-17Z"}))],["duotone",P.createElement(P.Fragment,null,P.createElement("path",{d:"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z",opacity:"0.2"}),P.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["fill",P.createElement(P.Fragment,null,P.createElement("path",{d:"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm33.94,58.75,17-17a8,8,0,0,1,11.32,11.32l-17,17a8,8,0,0,1-11.31-11.31ZM48,136a8,8,0,0,1,0-16H72a8,8,0,0,1,0,16Zm46.06,37.25-17,17a8,8,0,0,1-11.32-11.32l17-17a8,8,0,0,1,11.31,11.31Zm0-79.19a8,8,0,0,1-11.31,0l-17-17A8,8,0,0,1,77.09,65.77l17,17A8,8,0,0,1,94.06,94.06ZM136,208a8,8,0,0,1-16,0V184a8,8,0,0,1,16,0Zm0-136a8,8,0,0,1-16,0V48a8,8,0,0,1,16,0Zm54.23,118.23a8,8,0,0,1-11.32,0l-17-17a8,8,0,0,1,11.31-11.31l17,17A8,8,0,0,1,190.23,190.23ZM208,136H184a8,8,0,0,1,0-16h24a8,8,0,0,1,0,16Z"}))],["light",P.createElement(P.Fragment,null,P.createElement("path",{d:"M134,32V64a6,6,0,0,1-12,0V32a6,6,0,0,1,12,0Zm39.25,56.75A6,6,0,0,0,177.5,87l22.62-22.63a6,6,0,0,0-8.48-8.48L169,78.5a6,6,0,0,0,4.24,10.25ZM224,122H192a6,6,0,0,0,0,12h32a6,6,0,0,0,0-12Zm-46.5,47A6,6,0,0,0,169,177.5l22.63,22.62a6,6,0,0,0,8.48-8.48ZM128,186a6,6,0,0,0-6,6v32a6,6,0,0,0,12,0V192A6,6,0,0,0,128,186ZM78.5,169,55.88,191.64a6,6,0,1,0,8.48,8.48L87,177.5A6,6,0,1,0,78.5,169ZM70,128a6,6,0,0,0-6-6H32a6,6,0,0,0,0,12H64A6,6,0,0,0,70,128ZM64.36,55.88a6,6,0,0,0-8.48,8.48L78.5,87A6,6,0,1,0,87,78.5Z"}))],["regular",P.createElement(P.Fragment,null,P.createElement("path",{d:"M136,32V64a8,8,0,0,1-16,0V32a8,8,0,0,1,16,0Zm37.25,58.75a8,8,0,0,0,5.66-2.35l22.63-22.62a8,8,0,0,0-11.32-11.32L167.6,77.09a8,8,0,0,0,5.65,13.66ZM224,120H192a8,8,0,0,0,0,16h32a8,8,0,0,0,0-16Zm-45.09,47.6a8,8,0,0,0-11.31,11.31l22.62,22.63a8,8,0,0,0,11.32-11.32ZM128,184a8,8,0,0,0-8,8v32a8,8,0,0,0,16,0V192A8,8,0,0,0,128,184ZM77.09,167.6,54.46,190.22a8,8,0,0,0,11.32,11.32L88.4,178.91A8,8,0,0,0,77.09,167.6ZM72,128a8,8,0,0,0-8-8H32a8,8,0,0,0,0,16H64A8,8,0,0,0,72,128ZM65.78,54.46A8,8,0,0,0,54.46,65.78L77.09,88.4A8,8,0,0,0,88.4,77.09Z"}))],["thin",P.createElement(P.Fragment,null,P.createElement("path",{d:"M132,32V64a4,4,0,0,1-8,0V32a4,4,0,0,1,8,0Zm41.25,54.75a4,4,0,0,0,2.83-1.18L198.71,63a4,4,0,0,0-5.66-5.66L170.43,79.92a4,4,0,0,0,2.82,6.83ZM224,124H192a4,4,0,0,0,0,8h32a4,4,0,0,0,0-8Zm-47.92,46.43a4,4,0,1,0-5.65,5.65l22.62,22.63a4,4,0,0,0,5.66-5.66ZM128,188a4,4,0,0,0-4,4v32a4,4,0,0,0,8,0V192A4,4,0,0,0,128,188ZM79.92,170.43,57.29,193.05A4,4,0,0,0,63,198.71l22.62-22.63a4,4,0,1,0-5.65-5.65ZM68,128a4,4,0,0,0-4-4H32a4,4,0,0,0,0,8H64A4,4,0,0,0,68,128ZM63,57.29A4,4,0,0,0,57.29,63L79.92,85.57a4,4,0,1,0,5.65-5.65Z"}))]]),vl=P.forwardRef((e,t)=>P.createElement(dp,{ref:t,...e,weights:vv}));vl.displayName="SpinnerIcon";function Ev({onSendMessage:e,onSendAttachments:t,disabled:n,theme:r,onEndChat:i,attachmentsEnabled:o=!0}){const[s,a]=P.useState(""),[l,c]=P.useState(!1),u=P.useRef(null),d=P.useRef(null),[f,p]=P.useState(!1),g=Ct(r);P.useEffect(()=>{const v=()=>{const C=navigator.userAgent.toLowerCase(),N=["android","iphone","ipad","mobile","tablet"].some(R=>C.includes(R)),O="ontouchstart"in window||navigator.maxTouchPoints>0,b=window.innerWidth<=768;p(N||O&&b)};return v(),window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[]);const m=v=>{v.preventDefault(),s.trim()&&!n&&(e(s.trim()),a(""))},x=v=>{v.key==="Enter"&&!v.shiftKey&&(v.preventDefault(),m(v))},y=v=>{const C=v.target.files;if(C&&C.length>0){const M=Array.from(C),N=M.filter(O=>O.type.startsWith("image/"));if(N.length===0){console.warn("No valid image files selected");return}N.length!==M.length&&console.warn("Some non-image files were filtered out"),t(N),u.current&&(u.current.value="")}},k=()=>{!n&&u.current&&u.current.click()},E=()=>{!n&&f&&d.current&&d.current.click()},_=v=>{const C=v.target.files;if(C&&C.length>0){const M=C[0];M.type.startsWith("image/")?t([M]):console.warn("Selected file is not an image"),d.current&&(d.current.value="")}};return h.jsx("div",{className:"px-4 py-3 !w-full backdrop-blur-xl border-0 shadow-lg ",children:h.jsx("form",{onSubmit:m,className:"flex items-center !w-full",children:h.jsxs("div",{className:`flex items-center gap-2 !w-full backdrop-blur-md rounded-full px-3 py-2 shadow-sm hover:shadow-md focus-within:shadow-lg focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-500/50 transition-all duration-200 border ${r==="light"?"bg-white/90 border-gray-200":g.chatInput.container}`,children:[o&&h.jsx(Ae.button,{type:"button",onClick:k,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${g.chatInput.attachButton}`,disabled:n,"aria-label":"Attach file",children:h.jsx(ze.Paperclip,{className:"w-4 h-4"})}),o&&f&&h.jsx(Ae.button,{type:"button",onClick:E,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 ${g.chatInput.attachButton}`,disabled:n,"aria-label":"Take photo",children:h.jsx(ze.Camera,{className:"w-4 h-4"})}),o&&h.jsx("input",{ref:u,type:"file",multiple:!0,onChange:y,className:"hidden",accept:"image/*"}),o&&h.jsx("input",{ref:d,type:"file",onChange:_,className:"hidden",accept:"image/*",capture:"environment"}),h.jsx("textarea",{value:s,onChange:v=>a(v.target.value),onKeyDown:x,onFocus:()=>c(!0),onBlur:()=>c(!1),placeholder:"Type your message...",disabled:n,className:`flex-1 px-2 py-1 bg-transparent resize-none min-h-[32px] max-h-20 focus:outline-none text-sm border-0 ${g.chatInput.textarea}`,rows:1,style:{height:"auto",minHeight:"32px"},onInput:v=>{const C=v.target;C.style.height="auto",C.style.height=`${Math.min(C.scrollHeight,80)}px`}}),h.jsx(Ae.button,{type:"submit",disabled:n||!s.trim(),whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${s.trim()&&!n?g.chatInput.sendButton:r==="light"?"bg-gray-200 text-gray-400 cursor-not-allowed opacity-70":"bg-gray-600/50 text-gray-500 cursor-not-allowed opacity-50"}`,"aria-label":"Send message",children:h.jsx(ze.SendHorizontal,{className:"w-4 h-4"})}),i&&h.jsx(Ae.button,{type:"button",onClick:i,whileHover:{scale:1.05},whileTap:{scale:.95},className:`p-1 rounded-full transition-all duration-200 border-0 flex-shrink-0 ${g.chatInput.endButton}`,"aria-label":"End chat",children:h.jsx(ze.PhoneOff,{className:"w-4 h-4"})})]})})})}function kv({text:e,isComplete:t,isRealTimeStream:n=!1,speed:r=50}){const[i,o]=P.useState(""),[s,a]=P.useState(0);return P.useEffect(()=>{if(n){o(e);return}if(t){o(e);return}if(s<e.length){const l=setTimeout(()=>{o(e.slice(0,s+1)),a(s+1)},r);return()=>clearTimeout(l)}},[e,s,t,r,n]),P.useEffect(()=>{n||(a(0),o(""))},[e,n]),h.jsxs("span",{className:"relative",children:[h.jsx("span",{className:"inline-block",children:i}),!t&&h.jsx("span",{className:"inline-flex items-center ml-1",children:[0,1,2].map(l=>h.jsx(Ae.span,{className:"w-1.5 h-1.5 bg-current rounded-full mx-0.5",animate:{y:[0,-4,0],opacity:[.4,1,.4],scale:[.8,1,.8]},transition:{duration:.8,repeat:1/0,repeatType:"mirror",delay:l*.2,ease:"easeInOut"}},l))})]})}function Sv(e,t){return e.startsWith("image/")?ze.Image:e.startsWith("video/")?ze.Video:e.startsWith("audio/")?ze.Music:e.includes("zip")||e.includes("rar")||e.includes("archive")?ze.Archive:ze.FileText}function Cv(e){if(e===0)return"0 Bytes";const t=1024,n=["Bytes","KB","MB","GB"],r=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,r)).toFixed(2))+" "+n[r]}function _v({message:e,theme:t,isOwn:n}){const r=Ct(t),i=e.metadata,o=(i==null?void 0:i.fileName)||"Unknown file",s=(i==null?void 0:i.fileSize)||0,a=(i==null?void 0:i.mimeType)||"application/octet-stream",l=i==null?void 0:i.downloading,c=i==null?void 0:i.uploading,u=(i==null?void 0:i.downloadProgress)||0,d=(i==null?void 0:i.uploadProgress)||0,f=i==null?void 0:i.downloadUrl,p=i==null?void 0:i.file,g=Sv(a),m=l||c,x=l?u:d,y=l?"Downloading...":c?"Uploading...":"Complete",[k,E]=P.useState(null);P.useEffect(()=>{if(f)E(f);else if(p&&a.startsWith("image/")){const M=URL.createObjectURL(p);return E(M),()=>URL.revokeObjectURL(M)}else E(null)},[f,p,a]);const _=()=>{if(f){const M=document.createElement("a");M.href=f,M.download=o,M.click()}},C=a.startsWith("image/")&&k;return h.jsxs("div",{className:"flex flex-col gap-2 max-w-full sm:max-w-sm",children:[C&&h.jsxs("div",{className:"relative rounded-lg overflow-hidden",children:[h.jsx("img",{src:k,alt:o,className:"max-w-full h-auto max-h-48 object-cover rounded-lg cursor-pointer",onClick:_}),h.jsx("div",{className:"absolute inset-0 bg-black/0 hover:bg-black/10 transition-colors duration-200 cursor-pointer"})]}),h.jsxs("div",{className:`
|
|
10
10
|
flex items-center gap-3 p-3 rounded-lg border transition-all duration-200
|
|
11
11
|
${t==="light"?"bg-gray-50 border-gray-200 hover:bg-gray-100":"bg-gray-800/50 border-gray-700 hover:bg-gray-700/50"}
|
|
12
12
|
`,children:[h.jsx("div",{className:`
|
|
@@ -126,7 +126,7 @@ const theme1 = createTheme({ palette: {
|
|
|
126
126
|
|
|
127
127
|
const theme2 = createTheme({ palette: {
|
|
128
128
|
primary: { main: green[500] },
|
|
129
|
-
} });`:On(12,x?` (${x})`:"",JSON.stringify(m.main)));return ff(m,"light",k,r),ff(m,"dark",E,r),m.contrastText||(m.contrastText=d(m.main)),m};let p;return t==="light"?p=Zm():t==="dark"&&(p=Xm()),process.env.NODE_ENV!=="production"&&(p||console.error(`MUI: The palette mode \`${t}\` is not supported.`)),Wt({common:{...fi},mode:t,primary:f({color:o,name:"primary"}),secondary:f({color:s,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:f({color:a,name:"error"}),warning:f({color:u,name:"warning"}),info:f({color:l,name:"info"}),success:f({color:c,name:"success"}),grey:GR,contrastThreshold:n,getContrastText:d,augmentColor:f,tonalOffset:r,...p},i)}function eM(e){const t={};return Object.entries(e).forEach(r=>{const[i,o]=r;typeof o=="object"&&(t[i]=`${o.fontStyle?`${o.fontStyle} `:""}${o.fontVariant?`${o.fontVariant} `:""}${o.fontWeight?`${o.fontWeight} `:""}${o.fontStretch?`${o.fontStretch} `:""}${o.fontSize||""}${o.lineHeight?`/${o.lineHeight} `:""}${o.fontFamily||""}`)}),t}function tM(e,t){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...t}}function nM(e){return Math.round(e*1e5)/1e5}const hf={textTransform:"uppercase"},pf='"Roboto", "Helvetica", "Arial", sans-serif';function rM(e,t){const{fontFamily:n=pf,fontSize:r=14,fontWeightLight:i=300,fontWeightRegular:o=400,fontWeightMedium:s=500,fontWeightBold:a=700,htmlFontSize:l=16,allVariants:c,pxToRem:u,...d}=typeof t=="function"?t(e):t;process.env.NODE_ENV!=="production"&&(typeof r!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof l!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const f=r/14,p=u||(x=>`${x/l*f}rem`),g=(x,y,k,E,_)=>({fontFamily:n,fontWeight:x,fontSize:p(y),lineHeight:k,...n===pf?{letterSpacing:`${nM(E/y)}em`}:{},..._,...c}),m={h1:g(i,96,1.167,-1.5),h2:g(i,60,1.2,-.5),h3:g(o,48,1.167,0),h4:g(o,34,1.235,.25),h5:g(o,24,1.334,0),h6:g(s,20,1.6,.15),subtitle1:g(o,16,1.75,.15),subtitle2:g(s,14,1.57,.1),body1:g(o,16,1.5,.15),body2:g(o,14,1.43,.15),button:g(s,14,1.75,.4,hf),caption:g(o,12,1.66,.4),overline:g(o,12,2.66,1,hf),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Wt({htmlFontSize:l,pxToRem:p,fontFamily:n,fontSize:r,fontWeightLight:i,fontWeightRegular:o,fontWeightMedium:s,fontWeightBold:a,...m},d,{clone:!1})}const iM=.2,oM=.14,sM=.12;function
|
|
129
|
+
} });`:On(12,x?` (${x})`:"",JSON.stringify(m.main)));return ff(m,"light",k,r),ff(m,"dark",E,r),m.contrastText||(m.contrastText=d(m.main)),m};let p;return t==="light"?p=Zm():t==="dark"&&(p=Xm()),process.env.NODE_ENV!=="production"&&(p||console.error(`MUI: The palette mode \`${t}\` is not supported.`)),Wt({common:{...fi},mode:t,primary:f({color:o,name:"primary"}),secondary:f({color:s,name:"secondary",mainShade:"A400",lightShade:"A200",darkShade:"A700"}),error:f({color:a,name:"error"}),warning:f({color:u,name:"warning"}),info:f({color:l,name:"info"}),success:f({color:c,name:"success"}),grey:GR,contrastThreshold:n,getContrastText:d,augmentColor:f,tonalOffset:r,...p},i)}function eM(e){const t={};return Object.entries(e).forEach(r=>{const[i,o]=r;typeof o=="object"&&(t[i]=`${o.fontStyle?`${o.fontStyle} `:""}${o.fontVariant?`${o.fontVariant} `:""}${o.fontWeight?`${o.fontWeight} `:""}${o.fontStretch?`${o.fontStretch} `:""}${o.fontSize||""}${o.lineHeight?`/${o.lineHeight} `:""}${o.fontFamily||""}`)}),t}function tM(e,t){return{toolbar:{minHeight:56,[e.up("xs")]:{"@media (orientation: landscape)":{minHeight:48}},[e.up("sm")]:{minHeight:64}},...t}}function nM(e){return Math.round(e*1e5)/1e5}const hf={textTransform:"uppercase"},pf='"Roboto", "Helvetica", "Arial", sans-serif';function rM(e,t){const{fontFamily:n=pf,fontSize:r=14,fontWeightLight:i=300,fontWeightRegular:o=400,fontWeightMedium:s=500,fontWeightBold:a=700,htmlFontSize:l=16,allVariants:c,pxToRem:u,...d}=typeof t=="function"?t(e):t;process.env.NODE_ENV!=="production"&&(typeof r!="number"&&console.error("MUI: `fontSize` is required to be a number."),typeof l!="number"&&console.error("MUI: `htmlFontSize` is required to be a number."));const f=r/14,p=u||(x=>`${x/l*f}rem`),g=(x,y,k,E,_)=>({fontFamily:n,fontWeight:x,fontSize:p(y),lineHeight:k,...n===pf?{letterSpacing:`${nM(E/y)}em`}:{},..._,...c}),m={h1:g(i,96,1.167,-1.5),h2:g(i,60,1.2,-.5),h3:g(o,48,1.167,0),h4:g(o,34,1.235,.25),h5:g(o,24,1.334,0),h6:g(s,20,1.6,.15),subtitle1:g(o,16,1.75,.15),subtitle2:g(s,14,1.57,.1),body1:g(o,16,1.5,.15),body2:g(o,14,1.43,.15),button:g(s,14,1.75,.4,hf),caption:g(o,12,1.66,.4),overline:g(o,12,2.66,1,hf),inherit:{fontFamily:"inherit",fontWeight:"inherit",fontSize:"inherit",lineHeight:"inherit",letterSpacing:"inherit"}};return Wt({htmlFontSize:l,pxToRem:p,fontFamily:n,fontSize:r,fontWeightLight:i,fontWeightRegular:o,fontWeightMedium:s,fontWeightBold:a,...m},d,{clone:!1})}const iM=.2,oM=.14,sM=.12;function it(...e){return[`${e[0]}px ${e[1]}px ${e[2]}px ${e[3]}px rgba(0,0,0,${iM})`,`${e[4]}px ${e[5]}px ${e[6]}px ${e[7]}px rgba(0,0,0,${oM})`,`${e[8]}px ${e[9]}px ${e[10]}px ${e[11]}px rgba(0,0,0,${sM})`].join(",")}const aM=["none",it(0,2,1,-1,0,1,1,0,0,1,3,0),it(0,3,1,-2,0,2,2,0,0,1,5,0),it(0,3,3,-2,0,3,4,0,0,1,8,0),it(0,2,4,-1,0,4,5,0,0,1,10,0),it(0,3,5,-1,0,5,8,0,0,1,14,0),it(0,3,5,-1,0,6,10,0,0,1,18,0),it(0,4,5,-2,0,7,10,1,0,2,16,1),it(0,5,5,-3,0,8,10,1,0,3,14,2),it(0,5,6,-3,0,9,12,1,0,3,16,2),it(0,6,6,-3,0,10,14,1,0,4,18,3),it(0,6,7,-4,0,11,15,1,0,4,20,3),it(0,7,8,-4,0,12,17,2,0,5,22,4),it(0,7,8,-4,0,13,19,2,0,5,24,4),it(0,7,9,-4,0,14,21,2,0,5,26,4),it(0,8,9,-5,0,15,22,2,0,6,28,5),it(0,8,10,-5,0,16,24,2,0,6,30,5),it(0,8,11,-5,0,17,26,2,0,6,32,5),it(0,9,11,-5,0,18,28,2,0,7,34,6),it(0,9,12,-6,0,19,29,2,0,7,36,6),it(0,10,13,-6,0,20,31,3,0,8,38,7),it(0,10,13,-6,0,21,33,3,0,8,40,7),it(0,10,14,-6,0,22,35,3,0,8,42,7),it(0,11,14,-7,0,23,36,3,0,9,44,8),it(0,11,15,-7,0,24,38,3,0,9,46,8)],lM={easeInOut:"cubic-bezier(0.4, 0, 0.2, 1)",easeOut:"cubic-bezier(0.0, 0, 0.2, 1)",easeIn:"cubic-bezier(0.4, 0, 1, 1)",sharp:"cubic-bezier(0.4, 0, 0.6, 1)"},cM={shortest:150,shorter:200,short:250,standard:300,complex:375,enteringScreen:225,leavingScreen:195};function mf(e){return`${Math.round(e)}ms`}function uM(e){if(!e)return 0;const t=e/36;return Math.min(Math.round((4+15*t**.25+t/5)*10),3e3)}function dM(e){const t={...lM,...e.easing},n={...cM,...e.duration};return{getAutoHeightDuration:uM,create:(i=["all"],o={})=>{const{duration:s=n.standard,easing:a=t.easeInOut,delay:l=0,...c}=o;if(process.env.NODE_ENV!=="production"){const u=f=>typeof f=="string",d=f=>!Number.isNaN(parseFloat(f));!u(i)&&!Array.isArray(i)&&console.error('MUI: Argument "props" must be a string or Array.'),!d(s)&&!u(s)&&console.error(`MUI: Argument "duration" must be a number or a string but found ${s}.`),u(a)||console.error('MUI: Argument "easing" must be a string.'),!d(l)&&!u(l)&&console.error('MUI: Argument "delay" must be a number or a string.'),typeof o!="object"&&console.error(["MUI: Secong argument of transition.create must be an object.","Arguments should be either `create('prop1', options)` or `create(['prop1', 'prop2'], options)`"].join(`
|
|
130
130
|
`)),Object.keys(c).length!==0&&console.error(`MUI: Unrecognized argument(s) [${Object.keys(c).join(",")}].`)}return(Array.isArray(i)?i:[i]).map(u=>`${u} ${typeof s=="string"?s:mf(s)} ${a} ${typeof l=="string"?l:mf(l)}`).join(",")},...e,easing:t,duration:n}}const fM={mobileStepper:1e3,fab:1050,speedDial:1050,appBar:1100,drawer:1200,modal:1300,snackbar:1400,tooltip:1500};function hM(e){return bn(e)||typeof e>"u"||typeof e=="string"||typeof e=="boolean"||typeof e=="number"||Array.isArray(e)}function Qm(e={}){const t={...e};function n(r){const i=Object.entries(r);for(let o=0;o<i.length;o++){const[s,a]=i[o];!hM(a)||s.startsWith("unstable_")?delete r[s]:bn(a)&&(r[s]={...a},n(r[s]))}}return n(t),`import { unstable_createBreakpoints as createBreakpoints, createTransitions } from '@mui/material/styles';
|
|
131
131
|
|
|
132
132
|
const theme = ${JSON.stringify(t,null,2)};
|
|
@@ -140,7 +140,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${t}Chann
|
|
|
140
140
|
${n.promptSlider}
|
|
141
141
|
${s===r?"opacity-100":"opacity-0"}
|
|
142
142
|
whitespace-pre-line break-words
|
|
143
|
-
`,style:{minHeight:"2.5rem",display:s===r?"block":"none"},children:o},s))})}function LM({statusMessage:e,theme:t}){const n=Ct(t);return h.jsxs("div",{className:"z-10 flex items-center space-x-2 mt-2 pb-2",children:[h.jsx("div",{className:n.statusIndicator}),h.jsx("span",{className:`text-xs ${n.text.muted}`,children:e})]})}const ig=A.forwardRef(({disabled:e,onStartCall:t,onStartChat:n,onStartVideo:r,prompts:i=['"Book a meeting with the marketing team"',`"What's the status of project Alpha?"`,`"Summarize yesterday's sales report"`,'"Find a good Italian restaurant nearby"','"Remind me to call John tomorrow at 10 AM"'],statusMessage:o="Agent is ready",title:s="Choose how to interact",subTitle:a="Ask me anything or give me a task to complete",theme:l="vox",modalities:c=["voice","chat","video"]},u)=>{const d=Ct(l),f=c.includes("voice"),p=c.includes("chat"),g=c.includes("video"),m=[f,p,g].filter(Boolean).length;return h.jsxs("div",{className:"flex p-8 flex-col items-center h-full justify-center w-full relative","aria-disabled":e,style:{background:"transparent"},children:[h.jsxs("div",{className:"mt-1 relative flex items-center justify-center mb-8 w-full",style:{minHeight:"120px"},children:[h.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[h.jsx("div",{className:d.pulseRings.ring1}),h.jsx("div",{className:d.pulseRings.ring2,style:{animationDelay:"0.5s"}}),h.jsx("div",{className:d.pulseRings.ring3,style:{animationDelay:"1s"}})]}),h.jsx("div",{className:"relative z-10 flex items-center justify-center",children:f&&p&&g?h.jsxs("div",{className:"flex gap-4 items-center justify-center",children:[h.jsx(Zi,{onClick:t,disabled:e,theme:l}),h.jsx(Ks,{onClick:n,disabled:e,theme:l}),h.jsx(qs,{onClick:r||t,disabled:e,theme:l})]}):m>1?h.jsxs("div",{className:"flex gap-6 items-center justify-center",children:[f&&h.jsx(Zi,{onClick:t,disabled:e,theme:l}),p&&h.jsx(Ks,{onClick:n,disabled:e,theme:l}),g&&r&&h.jsx(qs,{onClick:r,disabled:e,theme:l})]}):h.jsx("div",{className:"flex items-center justify-center",children:f?h.jsx(Zi,{onClick:t,disabled:e,theme:l}):p?h.jsx(Ks,{onClick:n,disabled:e,theme:l}):g&&r?h.jsx(qs,{onClick:r,disabled:e,theme:l}):h.jsx(Zi,{onClick:t,disabled:e,theme:l})})})]}),h.jsxs("div",{className:"text-center flex flex-col items-center gap-y-2 mb-6 w-full",children:[l==="midnight"?h.jsx("h3",{className:"text-xl font-semibold mb-2 text-white",children:String(s).split(/(interact)/i).map((y,k)=>y.toLowerCase()==="interact"?h.jsx("span",{className:d.text.accent,children:y},k):h.jsx("span",{children:y},k))}):h.jsx("h3",{className:`text-xl font-semibold mb-2 ${d.text.accent}`,children:s}),h.jsx("p",{className:`text-sm leading-relaxed px-4 ${d.text.secondary}`,children:a}),m>1&&h.jsxs("div",{className:"flex gap-6 mt-4 text-xs justify-center",children:[f&&h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.jsx(ng,{className:"w-4 h-4"}),h.jsx("span",{className:d.text.muted,children:"Voice"})]}),p&&h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.jsx(tg,{className:"w-4 h-4"}),h.jsx("span",{className:d.text.muted,children:"Chat"})]}),g&&h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.jsx(rg,{className:"w-4 h-4"}),h.jsx("span",{className:d.text.muted,children:"Video"})]})]})]}),h.jsx(DM,{prompts:i,theme:l}),h.jsx(LM,{statusMessage:o,theme:l})]})});ig.displayName="Welcome";class Xl extends P.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("VoxketWidget Error:",t,n)}render(){if(this.state.hasError){if(this.props.fallback){const t=this.props.fallback;return P.createElement(t,{error:this.state.error})}return P.createElement("div",{style:{padding:"20px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"}},"VoxketWidget encountered an error. Please check the console for details.")}return this.props.children}}const og=({onClick:e,position:t="bottom-right",size:n=64,className:r="",style:i,ariaLabel:o="Open Voxket",logoScale:s=.95})=>{const a={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"},l={width:n,height:n,...i};return h.jsx(Ae.button,{type:"button",onClick:e,"aria-label":o,className:`fixed z-50 rounded-full bg-black shadow-xl flex items-center justify-center overflow-hidden focus:outline-none focus:ring-2 focus:ring-white/40 ${a[t]} ${r}`,style:l,initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},"data-position":t,children:h.jsx("img",{src:"/logo.png",alt:"Voxket",className:"object-contain select-none pointer-events-none",style:{width:`${Math.max(0,Math.min(1,s))*100}%`,height:`${Math.max(0,Math.min(1,s))*100}%`},draggable:!1})})};function sg({room:e,onSessionEnd:t,onSessionStart:n,enableConsoleLogging:r=!0,enableLocalStorage:i=!0,voxketSessionId:o}={}){const[s,a]=P.useState(null),[l,c]=P.useState([]),[u,d]=P.useState(null),[f,p]=P.useState([]),g=P.useCallback((k,E)=>{const _={timestamp:new Date,event:k,data:E,sessionId:s==null?void 0:s.sessionId,participantId:u==null?void 0:u.identity};if(c(v=>[...v,_]),i){const v=JSON.parse(localStorage.getItem("voxket-session-logs")||"[]");v.push(_),localStorage.setItem("voxket-session-logs",JSON.stringify(v))}return _},[s==null?void 0:s.sessionId,u==null?void 0:u.identity,r,i]);P.useEffect(()=>{if(!e)return;const k=()=>{const b=o||`session-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,R=new Date,I={sessionId:b,startTime:R,totalMessages:0,connectionIssues:0,participantCount:f.length,events:[]};a(I),g("SESSION_STARTED",{sessionId:b,startTime:R}),n==null||n(b)},E=()=>{if(s){const b=new Date,R=b.getTime()-s.startTime.getTime(),I={...s,endTime:b,duration:R,events:l};g("SESSION_ENDED",{sessionId:s.sessionId,duration:`${Math.round(R/1e3)}s`,totalMessages:s.totalMessages,connectionIssues:s.connectionIssues}),t==null||t(I),a(null),c([])}},_=b=>{g("CONNECTION_STATE_CHANGED",{state:b}),b===ce.ConnectionState.Reconnecting&&s&&(a(R=>R?{...R,connectionIssues:R.connectionIssues+1}:null),g("CONNECTION_ISSUE",{type:"reconnecting"}))},v=b=>{g("TRACK_PUBLISHED",{trackKind:b.kind,trackSource:b.source})},C=b=>{g("TRACK_UNPUBLISHED",{trackKind:b.kind,trackSource:b.source})},M=(b,R)=>{s&&a(I=>I?{...I,totalMessages:I.totalMessages+1}:null),g("DATA_RECEIVED",{participantId:R==null?void 0:R.identity,dataSize:b.length})},N=b=>{g("PARTICIPANT_CONNECTED",{participantId:b.identity,participantName:b.name}),p(R=>[...R,b]),s&&a(R=>R?{...R,participantCount:R.participantCount+1}:null)},O=b=>{g("PARTICIPANT_DISCONNECTED",{participantId:b.identity,participantName:b.name}),p(R=>R.filter(I=>I.identity!==b.identity))};return e.localParticipant&&d(e.localParticipant),e.on(ce.RoomEvent.Connected,k),e.on(ce.RoomEvent.Disconnected,E),e.on(ce.RoomEvent.ConnectionStateChanged,_),e.on(ce.RoomEvent.TrackPublished,v),e.on(ce.RoomEvent.TrackUnpublished,C),e.on(ce.RoomEvent.DataReceived,M),e.on(ce.RoomEvent.ParticipantConnected,N),e.on(ce.RoomEvent.ParticipantDisconnected,O),()=>{e.off(ce.RoomEvent.Connected,k),e.off(ce.RoomEvent.Disconnected,E),e.off(ce.RoomEvent.ConnectionStateChanged,_),e.off(ce.RoomEvent.TrackPublished,v),e.off(ce.RoomEvent.TrackUnpublished,C),e.off(ce.RoomEvent.DataReceived,M),e.off(ce.RoomEvent.ParticipantConnected,N),e.off(ce.RoomEvent.ParticipantDisconnected,O)}},[e,s,l,f.length,g,t,n]);const m=P.useCallback(()=>i?JSON.parse(localStorage.getItem("voxket-session-logs")||"[]"):l,[l,i]),x=P.useCallback(()=>{i&&localStorage.removeItem("voxket-session-logs"),c([])},[i]),y=P.useCallback(()=>{const k=m(),E=JSON.stringify(k,null,2),_="data:application/json;charset=utf-8,"+encodeURIComponent(E),v=`voxket-session-logs-${new Date().toISOString().split("T")[0]}.json`,C=document.createElement("a");C.setAttribute("href",_),C.setAttribute("download",v),C.click()},[m]);return{sessionMetrics:s,sessionLogs:l,logEvent:g,getSessionLogs:m,clearSessionLogs:x,exportSessionLogs:y}}class Ql{constructor(){ot(this,"listeners",{})}on(t,n){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n),()=>this.off(t,n)}once(t,n){const r=(...i)=>{this.off(t,r),n(...i)};return this.on(t,r)}off(t,n){const r=this.listeners[t];if(!r)return;const i=r.indexOf(n);i>-1&&r.splice(i,1)}removeAllListeners(t){t?delete this.listeners[t]:this.listeners={}}emit(t,...n){const r=this.listeners[t];if(!r)return;const i=[...r];for(const o of i)try{o(...n)}catch(s){console.error(`Error in event listener for ${String(t)}:`,s)}}listenerCount(t){var n;return((n=this.listeners[t])==null?void 0:n.length)??0}eventNames(){return Object.keys(this.listeners)}}class ag{constructor(t){ot(this,"plugins",new Map);ot(this,"installedPlugins",new Set);ot(this,"context");this.context={client:t,emit:t.emit.bind(t),on:t.on.bind(t),config:{}}}register(t){if(this.plugins.has(t.name))throw new Error(`Plugin '${t.name}' is already registered`);if(t.dependencies){for(const n of t.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin '${t.name}' depends on '${n}' which is not registered`)}this.plugins.set(t.name,t)}async install(t,n){const r=this.plugins.get(t);if(!r)throw new Error(`Plugin '${t}' is not registered`);if(this.installedPlugins.has(t))throw new Error(`Plugin '${t}' is already installed`);if(r.dependencies)for(const o of r.dependencies)this.installedPlugins.has(o)||await this.install(o);const i={...this.context,config:{...r.config,...n}};r.install&&await r.install(i),this.installedPlugins.add(t),this.setupPluginEvents(r,i)}async uninstall(t){var r;const n=this.plugins.get(t);if(!n)throw new Error(`Plugin '${t}' is not registered`);if(this.installedPlugins.has(t)){for(const[i,o]of this.plugins)if(this.installedPlugins.has(i)&&((r=o.dependencies)!=null&&r.includes(t)))throw new Error(`Cannot uninstall '${t}' because '${i}' depends on it`);n.uninstall&&await n.uninstall(this.context),this.installedPlugins.delete(t)}}isInstalled(t){return this.installedPlugins.has(t)}getInstalledPlugins(){return Array.from(this.installedPlugins)}getAvailablePlugins(){return Array.from(this.plugins.keys())}getPluginInfo(t){return this.plugins.get(t)}setupPluginEvents(t,n){t.onSessionStart&&n.on("session.started",r=>{t.onSessionStart(n,r.id)}),t.onSessionEnd&&n.on("session.ended",r=>{t.onSessionEnd(n,r.id)}),t.onAgentResponse&&n.on("agent.response",r=>{t.onAgentResponse(n,r)})}}function FM(e){return e}function Jl(e,t,n){return{name:e,version:"1.0.0",description:`${t} modality plugin`,install:async r=>{n.onActivate&&await n.onActivate(r)},uninstall:async r=>{n.onDeactivate&&await n.onDeactivate(r)},onAgentResponse:n.onMessage}}const jM={name:"analytics",version:"1.0.0",description:"Built-in analytics tracking",install:async e=>{console.log("Analytics plugin installed"),e.on("session.started",t=>{console.log("Analytics: Session started",t.id)}),e.on("session.ended",(t,n)=>{console.log("Analytics: Session ended",t.id,n)}),e.on("chat.message.sent",t=>{console.log("Analytics: User message sent",t.content.length)})}},BM={name:"debug",version:"1.0.0",description:"Debug logging and development tools",install:async e=>{console.log("Debug plugin installed");const t=e.emit;e.emit=(n,...r)=>(console.log(`[Debug] Event: ${String(n)}`,r),t(n,...r))}},$M={name:"metrics",version:"1.0.0",description:"Advanced metrics collection",install:async e=>{console.log("Metrics plugin installed");const t=new Map;e.on("session.started",n=>{t.set(n.id,{startTime:Date.now(),events:[]})}),e.on("agent.response",n=>{console.log("Metrics: Agent response analyzed",{type:n.type,length:n.content.length,timestamp:n.timestamp})})}},lg=A.createContext(null);function io({config:e,children:t,autoConnect:n=!1,client:r}){const[i,o]=A.useState(null),[s,a]=A.useState(!1),[l,c]=A.useState(!1),[u,d]=A.useState(null),[f,p]=A.useState(null),[g,m]=A.useState("idle"),[x,y]=A.useState(null),[k,E]=A.useState([]),[_,v]=A.useState([]),[C,M]=A.useState([]);A.useEffect(()=>{const D=r||new ki(e);o(D);const w=N(D);return n&&!r&&O(D),()=>{w(),r||D.disconnect().catch(console.error)}},[e,n,r]);const N=D=>{const w=()=>{c(!0),d(null)},j=()=>{a(!0),c(!1),d(null)},Y=()=>{a(!1),c(!1),p(null),m("idle"),E([]),v([]),M([])},S=K=>{d(K),c(!1)},H=K=>{p(K),m(K.state)},U=K=>{m(K),f&&p({...f,state:K})},Z=(K,Ee)=>{p(null),m("idle"),y(Ee),E([]),v([]),M([])},W=K=>{E(Ee=>[...Ee,K])},ue=K=>{E(Ee=>Ee.filter(le=>le.id!==K.id))},te=K=>{v(Ee=>[...Ee,K])},ae=K=>{v(Ee=>[...Ee,K])},Oe=K=>{console.log("๐ VoxketProvider: Received transcription:",K),M(Ee=>Ee.find(oe=>oe.id===K.id)?(console.log("๐ VoxketProvider: Duplicate transcription detected, skipping:",K.id),Ee):(console.log("๐ VoxketProvider: Adding new transcription:",K.id),[...Ee,K]))},L=()=>{console.log("๐งน VoxketProvider: Clearing chat messages and transcriptions"),v([]),M([])};return D.on("connection.connecting",w),D.on("connection.connected",j),D.on("connection.disconnected",Y),D.on("connection.error",S),D.on("session.created",H),D.on("session.state.changed",U),D.on("session.ended",Z),D.on("participant.joined",W),D.on("participant.left",ue),D.on("chat.message.received",te),D.on("chat.message.sent",ae),D.on("transcription.received",Oe),D.on("chat.history.cleared",L),()=>{console.log("๐ VoxketProvider: Cleaning up event listeners"),D.off("connection.connecting",w),D.off("connection.connected",j),D.off("connection.disconnected",Y),D.off("connection.error",S),D.off("session.created",H),D.off("session.state.changed",U),D.off("session.ended",Z),D.off("participant.joined",W),D.off("participant.left",ue),D.off("chat.message.received",te),D.off("chat.message.sent",ae),D.off("chat.history.cleared",L),D.off("transcription.received",Oe)}},O=async D=>{const w=D||i;if(w)try{await w.connect()}catch(j){console.error("Failed to connect:",j)}},$={client:i,isConnected:s,isConnecting:l,connectionError:u,currentSession:f,sessionState:g,sessionMetrics:x,participants:k,chatMessages:_,transcriptions:C,connect:()=>O(),disconnect:async()=>{if(i)try{await i.disconnect()}catch(D){console.error("Failed to disconnect:",D)}},createSession:async(D,w={})=>{if(!i)throw new Error("Client not initialized");const j={agentId:D,participantName:w.participantName||"User",metadata:w.metadata,modalities:w.modalities||["voice"]};return await i.createSession(j)},endSession:async()=>i?await i.endSession():null,sendChatMessage:async D=>{if(!i)throw new Error("Client not initialized");await i.sendChatMessage(D)},setMicrophoneEnabled:async D=>{if(!i)throw new Error("Client not initialized");await i.setMicrophoneEnabled(D)},setCameraEnabled:async D=>{if(!i)throw new Error("Client not initialized");await i.setCameraEnabled(D)},startScreenShare:async()=>{if(!i)throw new Error("Client not initialized");await i.startScreenShare()},stopScreenShare:async()=>{if(!i)throw new Error("Client not initialized");await i.stopScreenShare()}};return h.jsx(lg.Provider,{value:$,children:t})}function dn(){const e=A.useContext(lg);if(!e)throw new Error("useVoxket must be used within a VoxketProvider");return e}class VM extends Ql{constructor(n){super();ot(this,"room",null);ot(this,"registeredMethods",new Map);ot(this,"activeInteractions",new Map);ot(this,"currentInteraction",null);n&&this.setRoom(n)}setRoom(n){this.room=n}async registerFrontendRPC(n,r,i="embedded"){if(console.log(`RpcManager: Starting registration for method '${n}'`),!this.room)throw console.error(`RpcManager: Cannot register '${n}' - no room instance`),new Error("Room not initialized. Cannot register RPC method.");if(!this.room.localParticipant)throw console.error(`RpcManager: Cannot register '${n}' - no local participant`),new Error("Local participant not available for RPC registration");console.log(`RpcManager: Room state: ${this.room.state}`),console.log(`RpcManager: Local participant: ${this.room.localParticipant.identity}`),console.log(`RpcManager: Registering frontend RPC method: ${n}`);const o={methodName:n,component:r,presentationMode:i};this.registeredMethods.set(n,o);try{this.room.registerRpcMethod(n,async s=>{console.log(`RpcManager: RPC method '${n}' called by ${s.callerIdentity}`),console.log("RpcManager: Payload:",s.payload),this.emit("rpc.method.called",{methodName:n,data:s});let a;console.log(`RpcManager: Current registration for '${n}':`,o);let l=s.responseTimeout||30;try{a=JSON.parse(s.payload)}catch{a=s.payload}try{const c=await this.awaitUserInteraction(n,r,i,a,l);return JSON.stringify(c)}catch(c){throw console.error(`RpcManager: Error in RPC method '${n}':`,c),c}}),this.emit("rpc.method.registered",{methodName:n}),console.log(`RpcManager: Successfully registered RPC method: ${n}`)}catch(s){throw console.error(`RpcManager: Failed to register RPC method '${n}':`,s),s}}async awaitUserInteraction(n,r,i,o,s){return new Promise((a,l)=>{const c=`${n}_${Date.now()}`;console.log(`RpcManager: Starting user interaction for method: ${n}, timeout: ${s} seconds`);const u={didSuccess:(f,p)=>{console.log(`RpcManager: User interaction successful for method: ${n}`,f),this.clearInteraction(c),this.currentInteraction=null;const g={success:!0,message:"User interaction completed successfully",data:f,timestamp:new Date,...p?{successView:p}:{}};this.emit("rpc.interaction.completed",{methodName:n,response:g}),a(g)},didFail:f=>{console.log(`RpcManager: User interaction failed for method: ${n}`,f),this.clearInteraction(c);const p={success:!1,message:"User interaction failed",error:f,timestamp:new Date};this.emit("rpc.interaction.completed",{methodName:n,response:p}),a(p)},dismissView:()=>{var p;console.log(`RpcManager: User dismissed interaction for method: ${n}`),console.log("RpcManager: Current interaction before dismiss:",(p=this.currentInteraction)==null?void 0:p.methodName),this.clearInteraction(c),this.currentInteraction=null,console.log("RpcManager: Current interaction after dismiss:",this.currentInteraction);const f={success:!0,data:{dismissed:!0,reason:"User dismissed the interaction"},message:"User interaction dismissed",timestamp:new Date};this.emit("rpc.interaction.dismissed",{methodName:n,response:f}),this.emit("rpc.interaction.completed",{methodName:n,response:f}),setTimeout(()=>{var g;((g=this.currentInteraction)==null?void 0:g.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),a(f)},didTimeout:f=>{console.log(`RpcManager: User interaction timeout for method: ${n}`),this.clearInteraction(c),this.currentInteraction=null;const p={success:!0,message:`User interaction timed out after ${s} seconds, it should be considered as declined, agent don't need to retry`,timestamp:new Date,...f?{timeoutView:f}:{}};this.emit("rpc.interaction.timeout",{methodName:n,response:p}),setTimeout(()=>{var g;((g=this.currentInteraction)==null?void 0:g.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),a(p)}},d=setTimeout(()=>{u.didTimeout&&u.didTimeout()},s);this.activeInteractions.set(c,{resolve:f=>a(JSON.parse(f)),reject:l,timeoutId:d}),this.currentInteraction={isVisible:!0,methodName:n,component:r,presentationMode:i,timeout:s,data:o,handler:u},this.emit("rpc.interaction.started",{methodName:n,presentationMode:i}),setTimeout(async()=>{var f;if((f=this.currentInteraction)!=null&&f.handler)try{console.log(`RpcManager: Component created for method: ${n} with data:`,o)}catch(p){console.error("RpcManager: Error loading data into component:",p),u.didFail({error:"Failed to load data into component"})}},100)})}clearInteraction(n){const r=this.activeInteractions.get(n);r&&(console.log(`RpcManager: Clearing interaction: ${n}`),clearTimeout(r.timeoutId),this.activeInteractions.delete(n))}getCurrentInteraction(){return this.currentInteraction}dismissCurrentInteraction(){var n;this.currentInteraction&&(console.log(`RpcManager: Dismissing current interaction: ${this.currentInteraction.methodName}`),(n=this.currentInteraction.handler)==null||n.dismissView(),setTimeout(()=>{this.currentInteraction&&(console.log("RpcManager: Force clearing lingering interaction"),this.currentInteraction=null)},0))}getRegisteredMethods(){return Array.from(this.registeredMethods.keys())}unregisterMethod(n){this.registeredMethods.delete(n),console.log(`RpcManager: Unregistered RPC method: ${n}`)}clear(){for(const[n,r]of this.activeInteractions)clearTimeout(r.timeoutId);this.activeInteractions.clear(),this.registeredMethods.clear(),this.currentInteraction=null,console.log("RpcManager: Cleared all registrations and interactions")}}class We extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="VoxketError"}}const Nn=new WeakSet,Ys=new WeakSet;class ki extends Ql{constructor(n){super();ot(this,"config");ot(this,"room",null);ot(this,"pluginManager");ot(this,"rpcManager");ot(this,"isConnected",!1);ot(this,"currentSession",null);ot(this,"connectionState",ce.ConnectionState.Disconnected);ot(this,"renderedComponents",new Map);ot(this,"textStreamHandlersRegistered",!1);ot(this,"currentAgentInfo",null);ot(this,"chatMessages",[]);ot(this,"activeTranscriptions",new Map);ot(this,"isAgentConnected",!1);ot(this,"agentState","idle");this.config=n,this.pluginManager=new ag(this),this.rpcManager=new VM,this.setupEventListeners(),this.initializeClient()}setupEventListeners(){this.on("connection.connected",()=>{var n,r;this.isConnected=!0,(r=(n=this.config).onConnected)==null||r.call(n)}),this.on("connection.disconnected",n=>{var r,i;this.isConnected=!1,(i=(r=this.config).onDisconnected)==null||i.call(r,n)}),this.on("connection.error",n=>{var r,i;(i=(r=this.config).onError)==null||i.call(r,n)}),this.on("chat.message.received",n=>{var r,i;this.addChatMessage(n),(i=(r=this.config).onMessageReceived)==null||i.call(r,n)}),this.on("chat.message.updated",n=>{this.updateChatMessage(n)}),this.on("chat.message.sent",n=>{this.addChatMessage(n)}),this.on("transcription.received",n=>{var r,i;(i=(r=this.config).onTranscriptionReceived)==null||i.call(r,n)}),this.on("session.state.changed",n=>{var r,i;(i=(r=this.config).onSessionStateChanged)==null||i.call(r,n)}),this.on("session.created",n=>{var r,i;(i=(r=this.config).onSessionStart)==null||i.call(r,n.id)}),this.on("session.ended",(n,r)=>{var i,o;(o=(i=this.config).onSessionEnd)==null||o.call(i,r)}),this.on("participant.joined",n=>{var r,i;(i=(r=this.config).onUserJoined)==null||i.call(r,n.id)}),this.on("participant.left",n=>{var r,i;(i=(r=this.config).onUserLeft)==null||i.call(r,n.id)}),this.setupRpcEventForwarding()}setupRpcEventForwarding(){if(!this.rpcManager){console.warn("RpcManager not initialized, skipping event forwarding setup");return}this.rpcManager.on("rpc.method.registered",n=>this.emit("rpc.method.registered",n)),this.rpcManager.on("rpc.method.called",n=>this.emit("rpc.method.called",n)),this.rpcManager.on("rpc.interaction.started",n=>this.emit("rpc.interaction.started",n)),this.rpcManager.on("rpc.interaction.completed",n=>this.emit("rpc.interaction.completed",n)),this.rpcManager.on("rpc.interaction.timeout",n=>this.emit("rpc.interaction.timeout",n)),this.rpcManager.on("rpc.interaction.dismissed",n=>this.emit("rpc.interaction.dismissed",n))}initializeClient(){this.room=new ce.Room,this.setupRoomEventListeners()}setupRoomEventListeners(){this.room&&(this.room.on(ce.RoomEvent.Connected,()=>{var n,r;this.connectionState=ce.ConnectionState.Connected,this.emit("connection.connected"),this.rpcManager.setRoom(this.room),(r=(n=this.currentSession)==null?void 0:n.activeModalities)!=null&&r.includes("voice")&&setTimeout(async()=>{var i;try{(i=this.room)!=null&&i.localParticipant&&(this.room.localParticipant.isMicrophoneEnabled?this.emit("track.unmuted",{source:"microphone",enabled:!0}):(await this.room.localParticipant.setMicrophoneEnabled(!0),this.emit("track.unmuted",{source:"microphone",enabled:!0})))}catch(o){console.warn("VoxketClient: Failed to enable microphone after room connection:",o)}},1e3),this.textStreamHandlersRegistered||this.setupTextStreamHandlers()}),this.room.on(ce.RoomEvent.Disconnected,n=>{var r;console.log("๐ด VoxketClient: Room disconnected, reason:",n),this.connectionState=ce.ConnectionState.Disconnected,this.textStreamHandlersRegistered=!1,this.isAgentConnected=!1,console.log("๐ค VoxketClient: Agent marked as disconnected"),this.clearChatMessages(),n&&console.log("๐ VoxketClient: Disconnect reason details:",{reason:n.toString(),currentSession:(r=this.currentSession)==null?void 0:r.id,agentConnected:this.isAgentConnected,connectionState:this.connectionState}),this.emit("connection.disconnected",n==null?void 0:n.toString())}),this.room.on(ce.RoomEvent.ConnectionStateChanged,n=>{this.connectionState=n,n===ce.ConnectionState.Connecting&&this.emit("connection.connecting")}),this.room.on(ce.RoomEvent.ParticipantConnected,n=>{const r={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.joined",r)}),this.room.on(ce.RoomEvent.ParticipantDisconnected,n=>{const r={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.left",r)}),this.room.on(ce.RoomEvent.LocalTrackPublished,n=>{console.log("๐ฌ VoxketClient: Local track published:",n.source),n.source===ce.Track.Source.ScreenShare&&this.emit("track.unmuted",{source:"screenShare",enabled:!0})}),this.room.on(ce.RoomEvent.LocalTrackUnpublished,n=>{console.log("๐ฌ VoxketClient: Local track unpublished:",n.source),n.source===ce.Track.Source.ScreenShare&&this.emit("track.muted",{source:"screenShare",enabled:!1})}))}setupTextStreamHandlers(){if(!this.room)return;try{this.room.registerTextStreamHandler("lk.chat",async(r,i)=>{try{const o=await r.readAll(),s={id:`msg_${Date.now()}_${i.identity||"user"}_${Math.random().toString(36).substr(2,9)}`,content:o,timestamp:new Date,sender:{id:i.identity||"user",name:i.identity||"User",type:"participant"},metadata:{topic:"lk.chat"}};this.emit("chat.message.received",s)}catch(o){console.error("VoxketClient: Failed to process lk.chat message:",o)}})}catch(r){console.warn("VoxketClient: lk.chat handler already registered, skipping:",r)}try{console.log("๐ VoxketClient: Registering lk.transcription handler..."),this.room.registerTextStreamHandler("lk.transcription",async(r,i)=>{var o,s,a,l,c,u;console.log("๐ VoxketClient: Received transcription stream from:",i.identity);try{console.log("๐ VoxketClient: Processing transcription stream...");const d=i.identity===((s=(o=this.room)==null?void 0:o.localParticipant)==null?void 0:s.identity),f=Date.now(),p=i.identity,g=this.activeTranscriptions.get(p);let m,x=!0;g&&f-g.timestamp<1e3?(m=g.messageId,x=!1,console.log("๐ VoxketClient: Reusing existing transcription message ID:",m)):(m=`msg_${d?"user":"agent"}_${i.identity}_${f}`,this.activeTranscriptions.set(p,{messageId:m,timestamp:f}),console.log("๐ VoxketClient: Created new transcription message ID:",m));let y="";console.log("๐ VoxketClient: Current agent info:",this.currentAgentInfo);const k=((a=this.currentAgentInfo)==null?void 0:a.name)||i.identity||"AI Assistant";console.log("๐ VoxketClient: Using agent name:",k);const E=d?"participant":"agent",_=d?this.config.participantName||"User":k;console.log("๐ VoxketClient: Transcription sender info:",{participantIdentity:i.identity,localParticipantIdentity:(c=(l=this.room)==null?void 0:l.localParticipant)==null?void 0:c.identity,isFromUser:d,senderType:E,senderName:_});const v={id:m,content:"",timestamp:new Date,sender:{id:i.identity||"unknown",name:_,type:E},metadata:{topic:"lk.transcription",streaming:!0}};x&&this.emit("chat.message.received",v),console.log("๐ VoxketClient: Starting to read transcription stream...");for await(const O of r){console.log("๐ VoxketClient: Received chunk:",O.length,"chars"),y+=O;const b=this.convertMarkdownToText(y),R={...v,content:b,metadata:{...v.metadata,streaming:!0}};this.emit("chat.message.updated",R)}const C=this.convertMarkdownToText(y),M={...v,content:C,metadata:{...v.metadata,streaming:!1}};this.emit("chat.message.updated",M);const N={id:m,text:C,isFinal:!0,startTime:v.timestamp.getTime(),participantId:i.identity||"agent"};this.emit("transcription.received",N),console.log("๐ VoxketClient: Emitted transcription event:",N)}catch(d){console.error("VoxketClient: Failed to process lk.transcription message:",d);try{const f=await r.readAll(),p=((u=this.currentAgentInfo)==null?void 0:u.name)||i.identity||"AI Assistant",g={id:`msg_${Date.now()}_agent_transcription_${Math.random().toString(36).substr(2,9)}`,content:f,timestamp:new Date,sender:{id:i.identity||"agent",name:p,type:"agent"},metadata:{topic:"lk.transcription"}};this.emit("chat.message.received",g);const m={id:g.id,text:g.content,isFinal:!0,startTime:g.timestamp.getTime(),participantId:i.identity||"agent"};this.emit("transcription.received",m),console.log("๐ VoxketClient: Emitted fallback transcription event:",m)}catch(f){console.error("VoxketClient: Fallback failed for lk.transcription:",f)}}})}catch(r){console.warn("VoxketClient: lk.transcription handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("suggested_response",async r=>{const i=await r.readAll();let o=[];try{o=["tes","hello how are you","algebra make me learn that ","what is the meaning of life"]}catch(s){console.warn("VoxketClient: Failed to parse suggested_response:",s,i)}this.emit("suggested.response",o)})}catch(r){console.warn("VoxketClient: suggested_response handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("agent_state_changed",async(r,i)=>{const o=await r.readAll();console.log("๐ค VoxketClient: agent_state_changed stream received:",o);let s={};try{s=typeof o=="string"?JSON.parse(o.replace(/'/g,'"')):o}catch(a){console.warn("VoxketClient: Failed to parse agent_state_changed:",a,o)}this.isAgentConnected||(this.isAgentConnected=!0,console.log("๐ค VoxketClient: Agent marked as connected (first state change received)"),this.emit("agent.connected",s)),s.new_state==="speaking"?(this.setAgentState("speaking"),this.emit("agent.speaking",s)):s.new_state==="thinking"?(this.setAgentState("thinking"),this.emit("agent.thinking",s)):(s.new_state==="idle"||s.new_state==="listening")&&this.setAgentState("idle")})}catch(r){console.warn("VoxketClient: conversation_item_added handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("function_tools_executed",async(r,i)=>{const o=await r.readAll();console.log("๐ ๏ธ VoxketClient: function_tool_executed stream received:",o);let s={};try{if(typeof o=="string")try{s=JSON.parse(o)}catch(a){let l=o;try{l=l.replace(/\bTrue\b/g,"true"),l=l.replace(/\bFalse\b/g,"false"),l=l.replace(/\bNone\b/g,"null");const c=l.replace(/\\"/g,"___ESCAPED_QUOTE___");let u="",d=!1,f=!1;for(let p=0;p<c.length;p++){const g=c[p],m=p>0?c[p-1]:"";g==='"'&&m!=="\\"?(d=!d,u+=g):g==="'"&&m!=="\\"&&!d?u+='"':u+=g}l=u.replace(/___ESCAPED_QUOTE___/g,'\\"'),s=JSON.parse(l)}catch(c){console.warn("VoxketClient: Enhanced parsing also failed, trying eval approach:",c);try{let u=o.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null");s=new Function("return "+u)()}catch(u){throw console.error("VoxketClient: All parsing methods failed:",u),a}}}else s=o}catch(a){console.warn("VoxketClient: Failed to parse function_tool_executed:",a,o);let l=null;if(typeof o=="string"&&o.includes("visualization_data"))try{const c=o.match(/"arguments":\s*"({.*?})"/);if(c){const u=c[1].replace(/\\"/g,'"');l=JSON.parse(u),console.log("๐ ๏ธ VoxketClient: Extracted visualization data from failed parse:",l)}}catch(c){console.warn("VoxketClient: Failed to extract visualization data:",c)}s={type:"function_tools_executed",function_calls:[],function_call_outputs:[],created_at:Date.now()/1e3,parseError:!0,rawData:o,extractedVisualizationData:l}}this.emit("tool.executed",s)})}catch(r){console.warn("VoxketClient: function_tool_executed handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("images",async(r,i)=>{try{const o=await r.readAll()}catch(o){console.error("VoxketClient: Error processing images stream:",o)}})}catch(r){console.warn("VoxketClient: images handler already registered, skipping:",r)}try{this.room.registerByteStreamHandler("images",async(r,i)=>{var o,s;try{const a=r.info,l={id:`img_${Date.now()}_${i.identity||"agent"}_${Math.random().toString(36).substr(2,9)}`,content:`๏ฟฝ๏ธ ${a.name||"Image"}`,sender:{id:i.identity||"agent",name:i.identity||"Agent",type:i.identity===((s=(o=this.room)==null?void 0:o.localParticipant)==null?void 0:s.identity)?"participant":"agent"},timestamp:new Date,metadata:{type:"attachment",fileName:a.name,fileSize:a.size,mimeType:a.mimeType,streamId:a.id,downloading:!0}};this.emit("chat.message.received",l),r.onProgress&&(r.onProgress=p=>{const g={...l,metadata:{...l.metadata,downloadProgress:p||0}};this.emit("chat.message.updated",g)});const c=[];for await(const p of r)c.push(p);const u=new Blob(c,{type:a.mimeType||"application/octet-stream"}),d=URL.createObjectURL(u),f={...l,metadata:{...l.metadata,downloading:!1,downloadProgress:1,downloadUrl:d,blob:u}};this.emit("chat.message.updated",f)}catch(a){console.error("VoxketClient: Error processing image attachment:",a)}})}catch(r){console.warn("VoxketClient: image handler already registered, skipping:",r)}["error","warning","status","system","debug","info"].forEach(r=>{try{this.room.registerTextStreamHandler(r,async(i,o)=>{try{const s=await i.readAll();if(console.log(`๐ VoxketClient: Received '${r}' stream:`,s),r==="error"){let a={};try{a=typeof s=="string"?JSON.parse(s):s}catch{a={message:s}}console.warn("๏ฟฝ VoxketClient: Agent error:",a),this.emit("agent.error",a)}else this.emit("text.stream.received",{topic:r,data:s,participantInfo:o})}catch(s){console.error(`VoxketClient: Failed to process '${r}' stream:`,s)}})}catch(i){console.warn(`VoxketClient: Handler for '${r}' already registered, skipping:`,i)}});try{this.room.registerTextStreamHandler("*",async(r,i)=>{var o;try{const s=await r.readAll(),a=((o=r.info)==null?void 0:o.topic)||"unknown";console.log(`๐ VoxketClient: Received unhandled text stream for topic '${a}':`,s),this.emit("text.stream.unhandled",{topic:a,data:s,participantInfo:i})}catch(s){console.error("VoxketClient: Failed to process unhandled text stream:",s)}})}catch(r){console.warn("VoxketClient: Generic text stream handler already registered, skipping:",r)}this.textStreamHandlersRegistered=!0}async fetchConnectionDetails(n,r,i,o){const s=n||this.config.agentId||"default-agent",a=r||this.config.participantName||"User",l=i||this.config.modalities||["voice"],c=o||this.config.participantMetadata||{user_id:""};try{const u={agent_id:s,participant_name:a,participant_metadata:c,modality:l[0],modalities:l};console.log("๐ VoxketClient: Creating session with modalities:",l);const d=await fetch(`${this.config.baseUrl}/api/live/agent/session`,{method:"POST",headers:{accept:"application/json","X-APP-ID":this.config.appId,"X-APP-SECRET":this.config.appSecret,"Content-Type":"application/json"},body:JSON.stringify(u)});if(!d.ok){let g=`HTTP ${d.status}: Failed to fetch connection details`;try{const m=await d.json();m&&(m.error?g=`API Error: ${m.error}`:m.detail?g=`API Error: ${m.detail}`:m.message&&(g=`API Error: ${m.message}`))}catch{try{const x=await d.text();x&&(g=`API Error: ${x}`)}catch{}}throw new Error(g)}const f=await d.json();let p;return f.agent_info&&(p={id:f.agent_info.agent_info.id,name:f.agent_info.agent_info.name,capabilities:f.agent_info.capabilities,modality_supported:f.agent_info.modality_supported,session_settings:f.agent_info.session_settings||{}},this.currentAgentInfo=p),{serverUrl:f.wss_url,participantToken:f.token,voxketSessionId:f.session_id,agentInfo:p}}catch(u){console.error("VoxketClient: fetchConnectionDetails failed:",u);const d=new We(`Failed to fetch connection details: ${u instanceof Error?u.message:"Unknown error"}`,"CONNECTION_FAILED",u);throw this.emit("connection.error",d),d}}async connect(n,r,i,o){var s;try{this.emit("connection.connecting");const a=await this.fetchConnectionDetails(n,r,i,o);return await((s=this.room)==null?void 0:s.connect(a.serverUrl,a.participantToken)),this.isConnected=!0,a}catch(a){console.error("VoxketClient: Connection failed:",a);const l=new We(`Failed to connect to Voxket services: ${a instanceof Error?a.message:"Unknown error"}`,"CONNECTION_FAILED",a);throw this.emit("connection.error",l),l}}async disconnect(){var n;try{console.log("๐ VoxketClient: Starting disconnect process..."),this.room&&(console.log("๐ VoxketClient: Disconnecting from room:",{roomState:this.room.state,numParticipants:this.room.numParticipants,sessionId:(n=this.currentSession)==null?void 0:n.id}),await this.room.disconnect()),this.isConnected=!1,this.currentSession=null,this.currentAgentInfo=null,this.textStreamHandlersRegistered=!1,this.clearChatMessages(),console.log("๐ VoxketClient: Creating new room instance..."),this.room=new ce.Room,this.setupRoomEventListeners(),console.log("โ
VoxketClient: Disconnect completed successfully"),this.emit("connection.disconnected")}catch(r){console.error("โ VoxketClient: Disconnect failed:",r);const i=new We("Failed to disconnect properly","NETWORK_ERROR",r);throw this.emit("connection.error",i),i}}async createSession(n){var r,i,o,s;try{const a=await this.connect(n.agentId,n.participantName,n.modalities,n.participantMetadata),l={id:a.voxketSessionId,agentId:n.agentId,state:"connecting",startedAt:new Date,metadata:n.metadata||{},activeModalities:n.modalities||["voice"],agentInfo:a.agentInfo||this.currentAgentInfo};if(this.currentSession=l,this.emit("session.created",l),(r=n.modalities)!=null&&r.includes("voice"))try{await new Promise(c=>setTimeout(c,500)),(i=this.room)!=null&&i.localParticipant?(await this.room.localParticipant.setMicrophoneEnabled(!0,void 0,{preConnectBuffer:!0}),this.emit("track.unmuted",{source:"microphone",enabled:!0})):console.warn("VoxketClient: No local participant found, microphone not enabled")}catch(c){console.warn("VoxketClient: Failed to enable microphone, but continuing with session:",c)}if((o=n.modalities)!=null&&o.includes("video"))try{await new Promise(c=>setTimeout(c,200)),(s=this.room)!=null&&s.localParticipant&&(console.log("๐ฅ VoxketClient: Attempting to enable camera for video session"),await this.room.localParticipant.setCameraEnabled(!0),this.emit("track.unmuted",{source:"camera",enabled:!0}),console.log("๐ฅ VoxketClient: Camera enabled successfully"))}catch(c){console.warn("VoxketClient: Failed to enable camera, but continuing with session:",c)}return setTimeout(()=>{var c;this.currentSession&&(this.currentSession.state="active",this.emit("session.state.changed","active",this.currentSession.state),this.forceAgentConnected(),console.log("๐ค VoxketClient: Session marked as active:",{sessionId:this.currentSession.id,modalities:this.currentSession.activeModalities,agentConnected:this.isAgentConnected,hasRoom:!!this.room,remoteParticipants:((c=this.room)==null?void 0:c.remoteParticipants.size)||0}))},1e3),l}catch(a){throw console.error("VoxketClient: Failed to create session:",a),a instanceof We?a:a instanceof TypeError&&a.message.includes("fetch")?new We("Network connection failed","CONNECTION_FAILED",a):a instanceof Error&&a.message.includes("Failed to fetch connection details")?new We(`API connection failed: ${a.message}`,"CONNECTION_FAILED",a):new We(`Failed to create session: ${a instanceof Error?a.message:"Unknown error"}`,"SESSION_NOT_FOUND",a)}}async startSession(n,r){const i={agentId:n||this.config.agentId||"default-agent",participantName:(r==null?void 0:r.participantName)||this.config.participantName||"User",modalities:(r==null?void 0:r.modalities)||this.config.modalities||["voice","chat"],metadata:r==null?void 0:r.metadata,participantMetadata:r==null?void 0:r.participantMetadata};return this.createSession(i)}async endSession(){var n,r;if(!this.currentSession)return null;try{const i={sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((r=this.room)==null?void 0:r.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]};return this.currentSession.endedAt=new Date,this.currentSession.state="disconnected",this.emit("session.ended",this.currentSession,i),await this.disconnect(),i}catch(i){throw new We("Failed to end session","SESSION_NOT_FOUND",i)}}getCurrentSession(){return this.currentSession}getCurrentAgentInfo(){return this.currentAgentInfo}getIsAgentConnected(){return this.isAgentConnected}forceAgentConnected(){this.isAgentConnected||(this.isAgentConnected=!0,console.log("๐ค VoxketClient: Agent manually marked as connected"),this.emit("agent.connected",{forced:!0}))}getAgentState(){return this.agentState}setAgentState(n){this.agentState!==n&&(this.agentState=n,this.emit("agent.state.changed",{state:n}))}getAgentAudioTrack(){const n=this.getRemoteParticipants();for(const r of n){const i=r.getTrackPublication(ce.Track.Source.Microphone);if(i!=null&&i.track)return{source:ce.Track.Source.Microphone,participant:r,publication:i}}return null}getAgentVideoTrack(){const n=this.getRemoteParticipants();for(const r of n){const i=r.getTrackPublication(ce.Track.Source.Camera);if(i!=null&&i.track)return{source:ce.Track.Source.Camera,participant:r,publication:i}}return null}getVideoTrackRefs(){const n=[],r=this.getLocalParticipant();if(r){const o=r.getTrackPublication(ce.Track.Source.Camera);o!=null&&o.track&&n.push({source:ce.Track.Source.Camera,participant:r,publication:o});const s=r.getTrackPublication(ce.Track.Source.ScreenShare);s!=null&&s.track&&n.push({source:ce.Track.Source.ScreenShare,participant:r,publication:s})}const i=this.getRemoteParticipants();for(const o of i){const s=o.getTrackPublication(ce.Track.Source.Camera);s!=null&&s.track&&n.push({source:ce.Track.Source.Camera,participant:o,publication:s});const a=o.getTrackPublication(ce.Track.Source.ScreenShare);a!=null&&a.track&&n.push({source:ce.Track.Source.ScreenShare,participant:o,publication:a})}return n}getCameraTrackRefs(){return this.getVideoTrackRefs().filter(n=>n.source===ce.Track.Source.Camera)}getScreenShareTrackRefs(){return this.getVideoTrackRefs().filter(n=>n.source===ce.Track.Source.ScreenShare)}getChatMessages(){return[...this.chatMessages]}addChatMessage(n){this.chatMessages.some(i=>i.id===n.id)||this.chatMessages.push(n)}updateChatMessage(n){const r=this.chatMessages.findIndex(i=>i.id===n.id);r!==-1&&(this.chatMessages[r]=n)}clearChatMessages(){this.chatMessages=[],this.activeTranscriptions.clear(),this.dismissCurrentInteraction(),this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays(),console.log("๐งน VoxketClient: Cleared chat messages and transcription history"),this.emit("chat.history.cleared")}renderUI(n={}){var s,a,l,c,u,d,f,p,g;const r=this.resolveTarget(n.target||"body"),i=this.getTargetKey(r);if(Ys.has(r)){console.warn("โ ๏ธ VoxketClient: Target is already being processed, skipping renderUI");return}if(Nn.has(r)){console.log("โ VoxketClient: Target already has a React root in registry, updating existing props...");const m=this.renderedComponents.get(i);if(m&&m.root){const x={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((s=n.modality)==null?void 0:s.includes("chat"))!==!1,suportsVideoInput:((a=n.modality)==null?void 0:a.includes("video"))===!0,suportsScreenShare:((l=n.modality)==null?void 0:l.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this,participantMetadata:n.participantMetadata};try{m.root.render(A.createElement(io,{config:this.config,autoConnect:n.autoStart||!1,client:this,children:A.createElement(oo,x)})),console.log("โ
VoxketClient: Successfully updated existing widget with new props");return}catch(y){throw console.error("Error re-rendering existing widget:",y),new Error(`Failed to update existing widget: ${y instanceof Error?y.message:"Unknown error"}`)}}else console.warn("โ ๏ธ Registry inconsistency detected, cleaning up"),Nn.delete(r)}let o=this.renderedComponents.get(i);if(o&&o.target===r&&Nn.has(r)){console.log("๐ VoxketClient: Reusing existing React root for target:",i);const m=o.root,x={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((c=n.modality)==null?void 0:c.includes("chat"))!==!1,suportsVideoInput:((u=n.modality)==null?void 0:u.includes("video"))===!0,suportsScreenShare:((d=n.modality)==null?void 0:d.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this,participantMetadata:n.participantMetadata};try{m.render(A.createElement(io,{config:this.config,autoConnect:n.autoStart||!1,client:this,children:A.createElement(oo,x)}))}catch(y){throw console.error("Error rendering Voxket widget:",y),new Error(`Failed to render Voxket widget: ${y instanceof Error?y.message:"Unknown error"}`)}return}Ys.add(r);try{if(o){console.log("๐งน VoxketClient: Cleaning up existing component for different target");try{o.root.unmount(),this.renderedComponents.delete(i),Nn.delete(o.target),r.innerHTML=""}catch(y){console.warn("Failed to cleanup existing root:",y)}}if(Nn.has(r)){console.warn("โ ๏ธ VoxketClient: Target already in registry, skipping root creation");return}console.log("๐ VoxketClient: Creating new React root for target:",i);const m=Wg.createRoot(r);this.renderedComponents.set(i,{root:m,target:r}),Nn.add(r);const x={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((f=n.modality)==null?void 0:f.includes("chat"))!==!1,suportsVideoInput:((p=n.modality)==null?void 0:p.includes("video"))===!0,suportsScreenShare:((g=n.modality)==null?void 0:g.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this,participantMetadata:n.participantMetadata};if(!m||typeof m.render!="function")throw new Error("Invalid React root. Make sure React 18+ is properly installed and configured.");try{m.render(A.createElement(io,{config:this.config,autoConnect:n.autoStart||!1,client:this,children:A.createElement(oo,x)}))}catch(y){throw console.error("Error rendering Voxket widget:",y),new Error(`Failed to render Voxket widget: ${y instanceof Error?y.message:"Unknown error"}`)}}finally{Ys.delete(r)}}removeUI(n){var i;const r=n?this.resolveTarget(n):null;if(r){const o=this.getTargetKey(r),s=this.renderedComponents.get(o);if(s){console.log("๐๏ธ VoxketClient: Removing UI for target:",o),this.renderedComponents.delete(o),Nn.delete(r);try{const l=s.target;l&&l.isConnected?(typeof((i=s.root)==null?void 0:i.unmount)=="function"&&(s.root.unmount(),console.log("โ
VoxketClient: UI unmounted for target:",o)),l.hasChildNodes()&&(l.innerHTML="")):console.log("โน๏ธ VoxketClient: Target element already disconnected, skipping unmount")}catch(l){console.warn("Failed to unmount React root:",l)}}else console.log("โน๏ธ VoxketClient: No component found for target, cleaning registry:",o),Nn.delete(r),r.isConnected&&r.hasChildNodes()&&(r.innerHTML="");r.querySelectorAll('[id*="voxket"], [class*="voxket"], .fixed.inset-0.z-50').forEach(l=>{try{l.remove()}catch(c){console.warn("Failed to remove element:",c)}}),r===document.body&&r.querySelectorAll(".fixed.z-50, .fixed.inset-0").forEach(c=>{if(c.classList.contains("bg-black")&&(c.classList.contains("backdrop-blur-sm")||c.classList.contains("bg-opacity-30")))try{c.remove()}catch(u){console.warn("Failed to remove fixed element:",u)}})}}removeAllUI(){for(const[n,r]of this.renderedComponents)r.root.unmount();this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays()}forceCleanupFullscreenOverlays(){document.body.querySelectorAll(".fixed.inset-0.z-50").forEach(r=>{if(r.classList.contains("bg-black")&&(r.classList.contains("backdrop-blur-sm")||r.classList.contains("bg-opacity-30")))try{r.remove()}catch(i){console.warn("Failed to remove overlay:",i)}})}resolveTarget(n){if(typeof n=="string"){const r=document.querySelector(n);if(!r)throw new Error(`Target element not found: ${n}`);return r}return n}getTargetKey(n){return n.id?n.id:n.className?n.tagName+"_"+n.className.replace(/\s+/g,"_"):n.tagName+"_"+n.outerHTML.length%1e3}async sendMessage(n,r){var i;if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new We("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new We("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new We("No local participant","CONNECTION_FAILED");this.dismissCurrentInteraction();try{const o={id:`msg_${Date.now()}`,content:n,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:r||{}},s=await((i=this.room)==null?void 0:i.localParticipant.sendText(n,{topic:"lk.chat",destinationIdentities:[]}));this.emit("chat.message.sent",o)}catch(o){throw console.error("VoxketClient: Failed to send chat message:",o),new We("Failed to send message","NETWORK_ERROR",o)}}async sendChatMessage(n,r){return this.sendMessage(n,r)}async sendAttachments(n,r){if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new We("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new We("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new We("No local participant","CONNECTION_FAILED");if(!n||n.length===0)throw new We("No files provided","INVALID_PARAMETER");this.dismissCurrentInteraction();const i=n.filter(o=>o.type.startsWith("image/"));if(i.length===0)throw new We("Only image files are allowed","INVALID_PARAMETER");i.length!==n.length&&console.warn("VoxketClient: Some non-image files were filtered out");try{const o=i.map(async(s,a)=>{const c={id:`att_${Date.now()}_${a}`,content:`๐ ${s.name}`,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:{...r,type:"attachment",fileName:s.name,fileSize:s.size,mimeType:s.type,uploading:!0}};this.emit("chat.message.sent",c);const u=await this.room.localParticipant.sendFile(s,{mimeType:s.type,topic:"images",onProgress:f=>{const p={...c,metadata:{...c.metadata,uploadProgress:f}};this.emit("chat.message.updated",p)}});try{const f=new FileReader,p=new Promise((x,y)=>{f.onload=()=>{typeof f.result=="string"?x(f.result):y(new Error("Failed to convert to base64"))},f.onerror=y});f.readAsDataURL(s);const m={type:"image",data:await p,filename:s.name,mimeType:s.type,size:s.size};await this.room.localParticipant.sendText(JSON.stringify(m),{topic:"images",destinationIdentities:[]})}catch(f){console.warn("VoxketClient: Failed to send image data to agent:",f);try{const p=`I've shared an image: ${s.name}`;await this.room.localParticipant.sendText(p,{topic:"lk.chat",destinationIdentities:[]})}catch(p){console.warn("VoxketClient: Failed to send image notification to agent:",p)}}const d={...c,metadata:{...c.metadata,uploading:!1,uploadProgress:1,streamId:u.id}};return this.emit("chat.message.updated",d),u});await Promise.all(o)}catch(o){throw console.error("VoxketClient: Failed to send attachments:",o),new We("Failed to send attachments","NETWORK_ERROR",o)}}async sendAttachment(n,r){return this.sendAttachments([n],r)}toggleMicrophone(n){return this.setMicrophoneEnabled(n!==!1)}async setMicrophoneEnabled(n){var r,i;try{const o=(r=this.room)==null?void 0:r.localParticipant.isMicrophoneEnabled,s=n??!o;await((i=this.room)==null?void 0:i.localParticipant.setMicrophoneEnabled(s)),s?this.emit("track.unmuted",{source:"microphone",enabled:!0}):this.emit("track.muted",{source:"microphone",enabled:!1})}catch(o){throw console.error("VoxketClient: Failed to toggle microphone:",o),new We("Failed to toggle microphone","PERMISSION_DENIED",o)}}toggleCamera(n){return this.setCameraEnabled(n!==!1)}async setCameraEnabled(n){var r,i;try{const o=(r=this.room)==null?void 0:r.localParticipant.isCameraEnabled,s=n??!o;await((i=this.room)==null?void 0:i.localParticipant.setCameraEnabled(s)),s?this.emit("track.unmuted",{source:"camera",enabled:!0}):this.emit("track.muted",{source:"camera",enabled:!1})}catch(o){throw console.error("VoxketClient: Failed to toggle camera:",o),new We("Failed to toggle camera","PERMISSION_DENIED",o)}}async enableCamera(){return this.setCameraEnabled(!0)}async disableCamera(){return this.setCameraEnabled(!1)}async startScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!0)),this.emit("track.unmuted",{source:"screenShare",enabled:!0})}catch(r){throw new We("Failed to start screen share","PERMISSION_DENIED",r)}}async stopScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!1)),this.emit("track.muted",{source:"screenShare",enabled:!1})}catch(r){throw new We("Failed to stop screen share","PERMISSION_DENIED",r)}}async getAudioInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="audioinput")}catch(n){throw new We("Failed to get audio input devices","DEVICE_ERROR",n)}}async getVideoInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="videoinput")}catch(n){throw new We("Failed to get video input devices","DEVICE_ERROR",n)}}async setAudioInputDevice(n){var r;try{if(!((r=this.room)!=null&&r.localParticipant))throw new Error("Not connected to room")}catch(i){throw new We("Failed to set audio input device","DEVICE_ERROR",i)}}async setVideoInputDevice(n){var r;try{if(!((r=this.room)!=null&&r.localParticipant))throw new Error("Not connected to room")}catch(i){throw new We("Failed to set video input device","DEVICE_ERROR",i)}}getLocalParticipant(){var n;return((n=this.room)==null?void 0:n.localParticipant)??null}getRemoteParticipants(){var n;return Array.from(((n=this.room)==null?void 0:n.remoteParticipants.values())??[])}getPublishPermissions(){const n=this.getLocalParticipant();if(!n)return{camera:!1,microphone:!1,screenShare:!1,data:!1};const r=n.permissions;if(!r)return{camera:!0,microphone:!0,screenShare:!0,data:!0};const i=o=>!!r.canPublish&&(r.canPublishSources.length===0||r.canPublishSources.includes(o));return{camera:i(1),microphone:i(2),screenShare:i(3),data:r.canPublishData??!1}}canPublishSource(n){return this.getPublishPermissions()[n]}getRoom(){return this.room}getConnectionState(){return this.connectionState}get connected(){return this.isConnected&&this.connectionState===ce.ConnectionState.Connected}getMicrophoneTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,r]of n.trackPublications)if(r.source===ce.Track.Source.Microphone)return r.track;return null}getCameraTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,r]of n.trackPublications)if(r.source===ce.Track.Source.Camera)return r.track;return null}getScreenShareTrack(){const n=this.getLocalParticipant();if(!n)return console.log("๐ฌ VoxketClient: getScreenShareTrack - no local participant"),null;for(const[,r]of n.trackPublications)if(r.source===ce.Track.Source.ScreenShare)return console.log("๐ฌ VoxketClient: getScreenShareTrack - found screen share track:",{trackSid:r.trackSid,isMuted:r.isMuted,hasTrack:!!r.track}),r.track;return console.log("๐ฌ VoxketClient: getScreenShareTrack - no screen share track found"),null}get isMicrophoneEnabled(){const n=this.getMicrophoneTrack();return n?!n.isMuted:!1}get isCameraEnabled(){const n=this.getCameraTrack();return n?!n.isMuted:!1}get isScreenShareEnabled(){const n=this.getScreenShareTrack(),r=n?!n.isMuted:!1;return console.log("๐ฌ VoxketClient: isScreenShareEnabled check:",{hasTrack:!!n,trackMuted:n==null?void 0:n.isMuted,enabled:r}),r}registerPlugin(n){this.pluginManager.register(n)}getPluginManager(){return this.pluginManager}getParticipants(){if(!this.room)return[];const n=[];return this.room.localParticipant&&n.push({id:this.room.localParticipant.identity,name:this.room.localParticipant.name||this.room.localParticipant.identity,isLocal:!0}),this.room.remoteParticipants.forEach(r=>{n.push({id:r.identity,name:r.name||r.identity,isLocal:!1})}),n}getSessionMetrics(){var n,r;return this.currentSession?{sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((r=this.room)==null?void 0:r.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]}:null}updateConfig(n){this.config={...this.config,...n}}async startRecording(){var n;try{this.emit("recording.started",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(r){throw new We("Failed to start recording","RECORDING_ERROR",r)}}async stopRecording(){var n;try{this.emit("recording.stopped",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(r){throw new We("Failed to stop recording","RECORDING_ERROR",r)}}async registerFrontendRPC(n,r,i="embedded"){return this.rpcManager.registerFrontendRPC(n,r,i)}getCurrentInteraction(){return this.rpcManager.getCurrentInteraction()}dismissCurrentInteraction(){this.rpcManager.dismissCurrentInteraction()}getRegisteredRpcMethods(){return this.rpcManager.getRegisteredMethods()}unregisterRpcMethod(n){this.rpcManager.unregisterMethod(n)}setParticipantMetadata(n){this.config.participantMetadata=n}getParticipantMetadata(){return this.config.participantMetadata}registerEventListener(n,r){return this.on(n,r)}registerEventEmitter(n,r){if(!this.room)throw new Error("Room not available");try{this.room.registerTextStreamHandler(n,async i=>{try{const o=await i.readAll();r(o)}catch(o){console.error(`Error processing event for topic '${n}':`,o)}})}catch(i){console.warn(`VoxketClient: Handler for topic '${n}' may already be registered:`,i)}}convertMarkdownToText(n){if(!n)return"";let r=n;return r=r.replace(/\*\*(.*?)\*\*/g,"$1"),r=r.replace(/__(.*?)__/g,"$1"),r=r.replace(/\*(.*?)\*/g,"$1"),r=r.replace(/_(.*?)_/g,"$1"),r=r.replace(/~~(.*?)~~/g,"$1"),r=r.replace(/`([^`]+)`/g,"$1"),r=r.replace(/```[\s\S]*?```/g,""),r=r.replace(/^#{1,6}\s+/gm,""),r=r.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),r.trim()}}const zM=Ae.create(Fm),UM=Ae.create(Vl),HM=Ae.create(nA),WM=Ae.create(ig);function GM({theme:e,mode:t,loadingText:n}){const r=Ct(e),i=()=>{switch(t){case"voice":return n||"Connecting to voice agent...";case"chat":return n||"Starting chat session...";case"video":return n||"Connecting to video call...";default:return n||"Connecting..."}};return h.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8",children:[h.jsxs("div",{className:"text-center",children:[h.jsx("h3",{className:`text-lg font-semibold mb-2 ${r.text.accent}`,children:i()}),h.jsx("p",{className:`text-sm ${r.text.muted}`,children:"Please wait a moment..."})]}),h.jsxs("div",{className:"flex space-x-1 mt-4",children:[h.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"300ms"}})]})]})}const KM=Ae.create(GM);function bf({children:e,theme:t,displayType:n="widget",onClose:r,popupPosition:i="bottom-right",onExpand:o}){const s=Ct(t);if(n==="fullscreen")return h.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/40 bg-opacity-30 backdrop-blur-sm flex items-center justify-center p-8",onClick:a=>{a.target===a.currentTarget&&r&&r()},children:h.jsxs("div",{className:"w-full h-full max-w-7xl max-h-[95vh] rounded-2xl relative bg-transparent flex flex-col",onClick:a=>{a.stopPropagation()},children:[r&&h.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),r()},className:"absolute top-4 cursor-pointer right-4 z-[10000] w-12 h-12 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 shadow-lg border border-gray-700 backdrop-blur-sm",title:"Exit Fullscreen",type:"button",children:h.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),h.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${s.card} w-full h-full flex flex-col rounded-xl shadow-2xl relative overflow-hidden`,"data-theme":t,style:{minHeight:"600px",height:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[h.jsx("div",{className:s.cardTopGradient}),h.jsx("div",{className:s.cardPurpleBlur}),h.jsx("div",{className:s.cardPinkBlur}),h.jsx("div",{className:"relative z-10 flex flex-col h-full",children:e}),h.jsx("div",{className:s.cardPulse1}),h.jsx("div",{className:s.cardPulse2,style:{animationDelay:"1s"}})]})]})});if(n==="popup"){const a={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"};return h.jsx("div",{className:"fixed rounded-2xl inset-0 z-[9999] pointer-events-none",children:h.jsxs("div",{className:`fixed rounded-2xl ${a[i]} pointer-events-auto`,children:[r&&h.jsx("button",{onClick:r,className:"absolute -top-2 -right-2 z-10 w-8 h-8 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 text-sm shadow-lg border border-gray-700",children:"ร"}),h.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${s.card} rounded-2xl flex flex-col relative overflow-hidden`,"data-theme":t,style:{width:"350px",height:"500px",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[h.jsx("div",{className:s.cardTopGradient}),h.jsx("div",{className:s.cardPurpleBlur}),h.jsx("div",{className:s.cardPinkBlur}),h.jsx("div",{className:"relative z-10 flex flex-col h-full w-full",children:e}),h.jsx("div",{className:s.cardPulse1}),h.jsx("div",{className:s.cardPulse2,style:{animationDelay:"1s"}})]})]})})}return h.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${s.card} relative overflow-hidden w-full h-full`,"data-theme":t,style:{height:"100%",maxHeight:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[h.jsx("div",{className:s.cardTopGradient}),h.jsx("div",{className:s.cardPurpleBlur}),h.jsx("div",{className:s.cardPinkBlur}),h.jsx("div",{className:"relative z-10 flex flex-col h-full w-full",children:e}),h.jsx("div",{className:s.cardPulse1}),h.jsx("div",{className:s.cardPulse2,style:{animationDelay:"1s"}})]})}function qM(e){if(typeof window>"u")return null;const{agentId:t,participantName:n,baseUrl:r,appSecret:i,appId:o,prompts:s,statusMessage:a,welcomeTitle:l,welcomeSubTitle:c,className:u,width:d,height:f,loadingText:p,suportsChatInput:g=!0,suportsVideoInput:m=!0,suportsScreenShare:x=!0,theme:y="vox",onSessionStart:k,onSessionEnd:E,enableSessionLogging:_=!0,onSessionLogsUpdate:v,onSessionMetricsUpdate:C,modalities:M=["voice"],displayType:N="widget",popupPosition:O="bottom-right",popupTriggerText:b="Open Chat",onPopupToggle:R,voxketClient:I,onDisplayTypeChange:B,participantMetadata:F}=e,[q,ne]=P.useState(!1),[ee,$]=P.useState(null),[D,w]=P.useState(()=>{try{if(I)return!!I.getCurrentSession()}catch(re){console.error("Error checking existing session:",re)}return!1}),[j,Y]=P.useState(!1),[S,H]=P.useState(t||""),[U,Z]=P.useState(n||"User"),[W,ue]=P.useState(()=>{try{if(I)return I.getCurrentSession()}catch(re){console.error("Error getting current session:",re)}return null}),[te,ae]=P.useState(()=>{var re,Fe,qe;try{if(I){const Ye=I.getCurrentSession();if((re=Ye==null?void 0:Ye.activeModalities)!=null&&re.includes("chat"))return"chat";if((Fe=Ye==null?void 0:Ye.activeModalities)!=null&&Fe.includes("voice"))return"voice";if((qe=Ye==null?void 0:Ye.activeModalities)!=null&&qe.includes("video"))return"video"}}catch(Ye){console.error("Error determining current mode:",Ye)}return"welcome"}),[Oe,L]=P.useState(!1);P.useEffect(()=>{N==="fullscreen"&&console.log("๐ฏ Widget: Switched to fullscreen mode")},[N]),P.useEffect(()=>{D&&!j?console.log("๐ Session started:",{currentMode:te,sessionId:W==null?void 0:W.id}):!D&&!j&&te==="welcome"&&console.log("๐ Returned to welcome screen")},[D,te,j]);const K=P.useMemo(()=>{try{if(I)return console.log("๐ Using existing VoxketClient to preserve session state"),I;if(!o||!i||!r){const Fe=`Missing required props: ${o?"":"appId "}${i?"":"appSecret "}${r?"":"baseUrl"}`;return console.error("โ VoxketClient creation failed:",Fe),$(new Error(Fe)),ne(!0),null}const re={appId:o,appSecret:i,baseUrl:r,agentId:S,participantName:U||"User",modalities:M,participantMetadata:F};return console.log("๐ง Creating new VoxketClient with config:",{appId:o.substring(0,8)+"...",baseUrl:r,agentId:S,participantName:U||"User",modalities:M}),new ki(re)}catch(re){return console.error("โ Failed to create VoxketClient:",re),$(re),ne(!0),null}},[I,o,i,r,S,U,M]),Ee=M,le=P.useMemo(()=>{try{if(!K)return console.warn("โ ๏ธ No VoxketClient available, creating fallback room"),new ce.Room;const re=K.getRoom();return console.log("๐ Widget: Room reference updated:",{roomExists:!!re,roomState:re==null?void 0:re.state,sessionStarted:D,currentMode:te}),re||new ce.Room}catch(re){return console.error("โ Error getting room from client:",re),new ce.Room}},[K,D,te]);P.useEffect(()=>{if(le){const re=()=>{console.log("๐ Widget: Room state changed:",{state:le.state,numParticipants:le.numParticipants,isConnected:le.state==="connected",sessionId:W==null?void 0:W.id})},Fe=(qe,Ye,kt)=>{console.log("๐ต Widget: Track subscribed:",{trackKind:qe.kind,trackSource:qe.source,participantSid:kt.sid,participantIdentity:kt.identity,sessionId:W==null?void 0:W.id})};return le.on(ce.RoomEvent.Connected,re),le.on(ce.RoomEvent.Disconnected,re),le.on(ce.RoomEvent.TrackSubscribed,Fe),()=>{le.off(ce.RoomEvent.Connected,re),le.off(ce.RoomEvent.Disconnected,re),le.off(ce.RoomEvent.TrackSubscribed,Fe)}}},[le,W==null?void 0:W.id]),P.useEffect(()=>{!j&&te==="welcome"?console.log("๐ฌ Widget: Welcome screen ready"):D&&te!=="welcome"&&console.log("๐ฌ Widget: Session mode active:",te)},[te,j,D]),P.useEffect(()=>{(te==="voice"||te==="video"||te==="chat")&&!W&&!D&&!j&&K&&!K.connected&&(console.log("๐ Auto-correcting: Found orphaned mode without session, returning to welcome"),ae("welcome"),Y(!1))},[te,W,D,j,K]);const{sessionMetrics:oe,sessionLogs:ye,logEvent:ve}=sg({room:le,onSessionStart:k,onSessionEnd:E,enableConsoleLogging:_,enableLocalStorage:_,voxketSessionId:W==null?void 0:W.id});P.useEffect(()=>{v&&v(ye)},[ye,v]),P.useEffect(()=>{C&&oe&&C(oe)},[oe,C]),P.useEffect(()=>{if(!K)return;const re=()=>{const Fe=K.connected,qe=K.getCurrentSession();console.log("๐ Connection state changed:",{isConnected:Fe,currentSessionId:qe==null?void 0:qe.id,currentMode:te,loading:j,sessionStarted:D}),!Fe&&D&&!j&&(console.log("๐ด Connection lost during active session - returning to welcome"),Y(!1),w(!1),ue(null),ae("welcome")),Fe&&qe&&j&&(console.log("๐ข Connected with active session - removing loader"),Y(!1),w(!0),ue(qe))};return K.on("connectionStateChanged",re),K.on("sessionEnded",()=>{console.log("๐ Session ended - returning to welcome"),Y(!1),w(!1),ue(null),ae("welcome")}),()=>{K.off("connectionStateChanged",re),K.off("sessionEnded",()=>{})}},[K,te,j,D]),P.useEffect(()=>{const re=qe=>{console.log("๐ด Widget: Room disconnected:",qe),console.log("๐ Widget: Current state on disconnect:",{currentMode:te,sessionStarted:D,currentSessionId:W==null?void 0:W.id,loading:j}),Y(!1),w(!1),ue(null),ae("welcome"),console.log("๐ Widget: Automatically returning to welcome screen after disconnect")},Fe=qe=>{console.log("๐น Media devices error:",qe)};return le.on(ce.RoomEvent.MediaDevicesError,Fe),le.on(ce.RoomEvent.Disconnected,re),()=>{le.off(ce.RoomEvent.Disconnected,re),le.off(ce.RoomEvent.MediaDevicesError,Fe)}},[le,te,D,W==null?void 0:W.id,j]);const ke=async()=>{try{if(!K){console.error("โ VoxketClient not available"),$(new Error("VoxketClient not initialized")),ne(!0);return}Y(!0),ae("voice"),console.log("๐ค Starting voice session...",{agentId:S,participantName:U}),console.log("๐ค Pre-start state:",{currentMode:"voice",sessionStarted:!1,loading:!0}),ve("USER_STARTED_VOICE_SESSION",{agentId:S,participantName:U});const re=await K.startSession(S,{participantName:U||"User",modalities:["voice",...m?["video"]:[]],participantMetadata:K.getParticipantMetadata()||F});console.log("โ
Voice session started successfully:",re.id),ue(re),w(!0),Y(!1),k&&k(re.id)}catch(re){console.error("โ Failed to start voice session:",re),Y(!1),w(!1),ae("welcome")}},lt=async()=>{try{if(!K){console.error("โ VoxketClient not available"),$(new Error("VoxketClient not initialized")),ne(!0);return}Y(!0),ae("chat"),console.log("๐ฌ Starting chat session...",{agentId:S,participantName:U}),ve("USER_STARTED_CHAT_SESSION",{agentId:S,participantName:U});const re=await K.startSession(S,{participantName:U||"User",modalities:["chat"],participantMetadata:K.getParticipantMetadata()||F});console.log("โ
Chat session started successfully:",re.id),ue(re),w(!0),Y(!1),k&&k(re.id)}catch(re){console.error("โ Failed to start chat session:",re),Y(!1),w(!1),ae("welcome")}},Et=async()=>{try{if(!K){console.error("โ VoxketClient not available"),$(new Error("VoxketClient not initialized")),ne(!0);return}Y(!0),ae("video"),console.log("๐บ Starting video session...",{agentId:S,participantName:U}),console.log("๐บ Pre-start state:",{currentMode:"video",sessionStarted:!1,loading:!0}),ve("USER_STARTED_VIDEO_SESSION",{agentId:S,participantName:U});const re=await K.startSession(S,{participantName:U||"User",modalities:["video","voice"],participantMetadata:K.getParticipantMetadata()||F});console.log("โ
Video session started successfully:",re.id),ue(re),w(!0),Y(!1),k&&k(re.id)}catch(re){console.error("โ Failed to start video session:",re),Y(!1),w(!1),ae("welcome")}},Ke=()=>{ae("welcome"),Y(!1),B&&B(e.displayType||"widget"),W&&D?(console.log("๐งน Widget: Cleaning up active session"),w(!1),ue(null),K&&(console.log("๐ Widget: Disconnecting client and cleaning up room"),K.disconnect().catch(re=>{console.error("โ Widget: Error during disconnect:",re)}))):(console.log("๐ Widget: No active session to clean up"),K&&K.connected&&(console.log("๐ Widget: Force disconnecting client for fresh state"),K.disconnect().catch(re=>{console.error("โ Widget: Error during force disconnect:",re)}))),N==="popup"&&!Oe&&L(!0),console.log("โ
Widget: handleBackToWelcome completed",{newCurrentMode:"welcome",newLoading:!1,newSessionStarted:!1})},ct=()=>{const re=!Oe;L(re),R&&R(re),!re&&!(W&&D)&&(ae("welcome"),w(!1),ue(null))},xt=()=>{console.log("๐ Closing fullscreen, switching to widget display type"),e.onDisplayTypeChange?e.onDisplayTypeChange("widget"):console.warn("โ ๏ธ No onDisplayTypeChange callback provided")},fn=()=>{if(console.log("๐ Expand to fullscreen requested"),e.onDisplayTypeChange)e.onDisplayTypeChange("fullscreen");else{console.warn("โ ๏ธ No onDisplayTypeChange callback provided for expand functionality");const re=document.getElementById("voice-card")||document.querySelector(".voxket-widget-container");re&&re.requestFullscreen&&re.requestFullscreen().catch(Fe=>{console.warn("โ ๏ธ Fullscreen API not supported or failed:",Fe)})}};P.useEffect(()=>{var re,Fe,qe;if(I&&K){const Ye=K.getCurrentSession();K.connected,Ye&&(console.log("โ
Restoring session state:",Ye.id),ue(Ye),w(!0),Y(!1),(re=Ye.activeModalities)!=null&&re.includes("chat")?ae("chat"):(Fe=Ye.activeModalities)!=null&&Fe.includes("voice")?ae("voice"):(qe=Ye.activeModalities)!=null&&qe.includes("video")&&ae("video"))}},[I,K]),P.useEffect(()=>()=>{!I&&K&&K.disconnect()},[K,I]);let V=te==="video"?"w-[32rem]":"w-96",Q=te==="video"?"h-[30rem]":"h-[25rem]",xe={};if(d&&(d.startsWith("w-")?V=d:(xe.width=d,V="")),f&&(f.startsWith("h-")?Q=f:(xe.height=f,Q="")),N==="popup"&&!Oe)return console.log("๐ก Showing popup trigger button"),h.jsx(og,{onClick:ct,position:O,ariaLabel:b});if(q||!K){const re=(ee==null?void 0:ee.message)||"VoxketWidget encountered an error. Please check your configuration.";return h.jsx("div",{className:`voxket-widget-root theme-${y} flex items-center justify-center p-8 ${u||""}`,style:{width:d||"400px",height:f||"500px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"},children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"text-4xl mb-4",children:"โ ๏ธ"}),h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Widget Error"}),h.jsx("p",{className:"text-sm mb-4",children:re}),h.jsx("button",{onClick:()=>{ne(!1),$(null),window.location.reload()},className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:"Retry"})]})})}let Te=`voxket-widget-root theme-${y}`,De={scrollMargin:0,scrollPadding:0,contain:"layout style paint"};N==="widget"?(Te+=` flex min-h-fit ${V} ${Q} ${u}`,De={...De,...xe}):(Te=`${u||""}`,De={});const Nt=h.jsx("div",{className:"h-full w-full flex flex-col overflow-hidden relative z-10",children:h.jsxs(Sr,{mode:"wait",children:[te==="welcome"&&!j&&h.jsx(WM,{agentId:S,participantName:U||"",onAgentIdChange:H,onParticipantNameChange:Z,onStartCall:ke,onStartChat:lt,onStartVideo:Et,disabled:D||j,prompts:s,statusMessage:a,title:l,subTitle:c,theme:y,modalities:Ee,initial:{opacity:0,y:0},animate:{opacity:1,y:0},exit:{opacity:0,y:40},transition:{duration:.3,ease:"easeInOut"}},"welcome"),j&&(te==="voice"||te==="chat"||te==="video")&&h.jsx(KM,{theme:y,mode:te,loadingText:p,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.3,ease:"easeInOut"}},`loading-${te}`),te==="voice"&&!j&&D&&K&&h.jsxs(Ft.RoomContext.Provider,{value:le,children:[h.jsx(Ft.RoomAudioRenderer,{},`audio-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(Ft.StartAudio,{label:"Start Audio"},`start-audio-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(zM,{loadingText:p,participantName:U||"User",sessionStarted:D,disabled:!1,theme:y,client:K,displayType:N,onBack:N==="popup"?ct:Ke,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"voice-session")]}),te==="chat"&&!j&&D&&K&&h.jsx(UM,{client:K,theme:y,displayType:N,onBack:N==="popup"?ct:Ke,onEndChat:Ke,disabled:!1,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"chat-view"),te==="video"&&!j&&D&&K&&h.jsxs(Ft.RoomContext.Provider,{value:le,children:[h.jsx(Ft.RoomAudioRenderer,{},`audio-video-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(Ft.StartAudio,{label:"Start Audio"},`start-audio-video-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(HM,{client:K,theme:y,displayType:N,onBack:N==="popup"?ct:Ke,onEndCall:Ke,disabled:!1,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"video-session")]})]})});return N==="fullscreen"||N==="popup"?h.jsx(bf,{theme:y,displayType:N,popupPosition:O,onClose:N==="fullscreen"?xt:ct,children:Nt}):h.jsx("div",{className:Te,style:De,children:h.jsx(bf,{theme:y,displayType:N,popupPosition:O,onExpand:fn,children:Nt})})}function oo(e){return h.jsx(Xl,{children:h.jsx(qM,{...e})})}function YM({logs:e,onClear:t,onExport:n}){const[r,i]=A.useState(!1),[o,s]=A.useState(""),a=e.filter(l=>!o||l.event.toLowerCase().includes(o.toLowerCase()));return r?h.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] flex flex-col m-4",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[h.jsxs("h2",{className:"text-lg font-semibold",children:["Session Logs (",e.length,")"]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",placeholder:"Filter events...",value:o,onChange:l=>s(l.target.value),className:"px-3 py-1 border rounded text-sm"}),h.jsx("button",{onClick:t,className:"px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700",children:"Clear"}),h.jsx("button",{onClick:n,className:"px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Export"}),h.jsx("button",{onClick:()=>i(!1),className:"px-3 py-1 bg-gray-600 text-white rounded text-sm hover:bg-gray-700",children:"Close"})]})]}),h.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.length===0?h.jsx("p",{className:"text-gray-500 text-center py-8",children:"No logs found"}):h.jsx("div",{className:"space-y-2",children:a.map((l,c)=>h.jsxs("div",{className:"border rounded p-3 text-sm",children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("span",{className:"font-semibold text-blue-600",children:l.event}),h.jsx("span",{className:"text-gray-500 text-xs",children:new Date(l.timestamp).toLocaleTimeString()})]}),l.sessionId&&h.jsxs("div",{className:"text-xs text-gray-600 mb-1",children:["Session: ",l.sessionId]}),l.data&&h.jsx("div",{className:"bg-gray-50 p-2 rounded text-xs",children:h.jsx("pre",{className:"whitespace-pre-wrap overflow-auto",children:JSON.stringify(l.data,null,2)})})]},c))})})]})}):h.jsxs("button",{onClick:()=>i(!0),className:"fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700 transition-colors text-sm z-50",children:["Session Logs (",e.length,")"]})}function ZM({metrics:e}){return e?h.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[h.jsx("h3",{className:"font-semibold mb-2",children:"Current Session"}),h.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Session ID:"}),h.jsx("div",{className:"font-mono text-xs",children:e.sessionId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Start Time:"}),h.jsx("div",{children:new Date(e.startTime).toLocaleString()})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Messages:"}),h.jsx("div",{children:e.totalMessages})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Participants:"}),h.jsx("div",{children:e.participantCount})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Connection Issues:"}),h.jsx("div",{children:e.connectionIssues})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Duration:"}),h.jsxs("div",{children:[Math.round((Date.now()-new Date(e.startTime).getTime())/1e3),"s"]})]})]})]}):null}function er(){const{currentSession:e,sessionState:t,sessionMetrics:n,createSession:r,endSession:i}=dn(),o=A.useCallback(async(a,l)=>await r(a,l),[r]),s=A.useCallback(async()=>await i(),[i]);return{session:e,state:t,metrics:n,isActive:e!==null&&t!=="disconnected",isConnecting:t==="connecting",isConnected:t==="connected"||t==="active",start:o,stop:s}}function cg(){const{sessionMetrics:e,currentSession:t}=dn();return{metrics:e,sessionId:t==null?void 0:t.id,duration:e==null?void 0:e.duration,participantCount:e==null?void 0:e.participantCount,messageCount:e==null?void 0:e.messageCount,audioQuality:e==null?void 0:e.audioQuality,networkStats:e==null?void 0:e.networkStats}}function ug(){const{setMicrophoneEnabled:e,client:t}=dn(),[n,r]=A.useState(!1),[i,o]=A.useState(!1),s=A.useCallback(async()=>{if(!i){o(!0);try{const c=!n;await e(c),r(c)}catch(c){console.error("Failed to toggle microphone:",c)}finally{o(!1)}}},[n,i,e]),a=A.useCallback(async()=>{if(!(n||i)){o(!0);try{await e(!0),r(!0)}catch(c){console.error("Failed to enable microphone:",c)}finally{o(!1)}}},[n,i,e]),l=A.useCallback(async()=>{if(!(!n||i)){o(!0);try{await e(!1),r(!1)}catch(c){console.error("Failed to disable microphone:",c)}finally{o(!1)}}},[n,i,e]);return{isEnabled:n,isLoading:i,toggle:s,enable:a,disable:l}}function dg(){const{setCameraEnabled:e}=dn(),[t,n]=A.useState(!1),[r,i]=A.useState(!1),o=A.useCallback(async()=>{if(!r){i(!0);try{const l=!t;await e(l),n(l)}catch(l){console.error("Failed to toggle camera:",l)}finally{i(!1)}}},[t,r,e]),s=A.useCallback(async()=>{if(!(t||r)){i(!0);try{await e(!0),n(!0)}catch(l){console.error("Failed to enable camera:",l)}finally{i(!1)}}},[t,r,e]),a=A.useCallback(async()=>{if(!(!t||r)){i(!0);try{await e(!1),n(!1)}catch(l){console.error("Failed to disable camera:",l)}finally{i(!1)}}},[t,r,e]);return{isEnabled:t,isLoading:r,toggle:o,enable:s,disable:a}}function fg(){const{startScreenShare:e,stopScreenShare:t}=dn(),[n,r]=A.useState(!1),[i,o]=A.useState(!1),s=A.useCallback(async()=>{if(!(n||i)){o(!0);try{await e(),r(!0)}catch(c){console.error("Failed to start screen share:",c)}finally{o(!1)}}},[n,i,e]),a=A.useCallback(async()=>{if(!(!n||i)){o(!0);try{await t(),r(!1)}catch(c){console.error("Failed to stop screen share:",c)}finally{o(!1)}}},[n,i,t]),l=A.useCallback(async()=>{n?await a():await s()},[n,s,a]);return{isSharing:n,isLoading:i,start:s,stop:a,toggle:l}}function XM(){const{client:e}=dn(),[t,n]=A.useState({tracks:[],layout:{type:"grid",showLocalVideo:!0,aspectRatio:"16:9"},isRecording:!1}),r=A.useMemo(()=>t.tracks.find(m=>m.isLocal),[t.tracks]),i=A.useMemo(()=>t.tracks.filter(m=>!m.isLocal),[t.tracks]),o=A.useCallback(async()=>{try{r!=null&&r.isEnabled?await(e==null?void 0:e.disableCamera()):await(e==null?void 0:e.enableCamera())}catch(m){throw console.error("Failed to toggle camera:",m),m}},[e,r]),s=A.useCallback(async()=>{try{t.tracks.find(x=>x.isScreenShare)?await(e==null?void 0:e.stopScreenShare()):await(e==null?void 0:e.startScreenShare())}catch(m){throw console.error("Failed to toggle screen share:",m),m}},[e,t.tracks]),a=A.useCallback(m=>{n(x=>({...x,layout:m}))},[]),l=A.useCallback(m=>{n(x=>({...x,pinnedTrack:m}))},[]),c=A.useCallback(()=>{n(m=>({...m,pinnedTrack:void 0}))},[]),u=A.useCallback(async()=>{try{await(e==null?void 0:e.startRecording()),n(m=>({...m,isRecording:!0}))}catch(m){throw console.error("Failed to start recording:",m),m}},[e]),d=A.useCallback(async()=>{try{await(e==null?void 0:e.stopRecording()),n(m=>({...m,isRecording:!1}))}catch(m){throw console.error("Failed to stop recording:",m),m}},[e]),f=A.useCallback(m=>t.tracks.find(x=>x.id===m),[t.tracks]),p=A.useCallback(m=>t.tracks.filter(x=>x.participantId===m),[t.tracks]),g=A.useCallback(m=>m.isEnabled&&t.tracks.includes(m),[t.tracks]);return A.useEffect(()=>{if(!e)return;const m=k=>{n(E=>({...E,tracks:[...E.tracks.filter(_=>_.id!==k.id),k]}))},x=k=>{n(E=>{var _;return{...E,tracks:E.tracks.filter(v=>v.id!==k),pinnedTrack:((_=E.pinnedTrack)==null?void 0:_.id)===k?void 0:E.pinnedTrack}})},y=k=>{n(E=>({...E,tracks:E.tracks.map(_=>_.id===k.id?k:_)}))};return e.on("videoTrackAdded",m),e.on("videoTrackRemoved",x),e.on("videoTrackUpdated",y),()=>{e.off("videoTrackAdded",m),e.off("videoTrackRemoved",x),e.off("videoTrackUpdated",y)}},[e]),{tracks:t.tracks,localTrack:r,remoteTraracks:i,pinnedTrack:t.pinnedTrack,layout:t.layout,isRecording:t.isRecording,toggleCamera:o,toggleScreenShare:s,setLayout:a,pinTrack:l,unpinTrack:c,startRecording:u,stopRecording:d,getTrackById:f,getTracksByParticipant:p,isTrackActive:g}}function Ko(){const{chatMessages:e,sendChatMessage:t,currentSession:n}=dn(),[r,i]=A.useState(!1),o=A.useCallback(async c=>{if(!(!c.trim()||r||!n)){i(!0);try{await t(c.trim())}catch(u){throw console.error("Failed to send chat message:",u),u}finally{i(!1)}}},[t,r,n]),{userMessages:s,agentMessages:a,allMessages:l}=A.useMemo(()=>{const c=e.filter(d=>d.sender.type==="participant"),u=e.filter(d=>d.sender.type==="agent");return{userMessages:c,agentMessages:u,allMessages:e}},[e]);return{messages:l,userMessages:s,agentMessages:a,messageCount:l.length,isSending:r,canSend:!!n&&!r,send:o}}function QM(){const{send:e,isSending:t,canSend:n}=Ko(),[r,i]=A.useState(""),o=A.useCallback(async()=>{if(!(!r.trim()||!n))try{await e(r),i("")}catch(a){throw a}},[r,e,n]),s=A.useCallback(a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),o())},[o]);return{value:r,setValue:i,send:o,handleKeyPress:s,isSending:t,canSend:n&&r.trim().length>0}}function ec(){const{isConnected:e,isConnecting:t,connectionError:n,connect:r,disconnect:i}=dn(),o=A.useCallback(async()=>{if(!(e||t))try{await r()}catch(a){throw console.error("Failed to connect:",a),a}},[r,e,t]),s=A.useCallback(async()=>{if(e)try{await i()}catch(a){throw console.error("Failed to disconnect:",a),a}},[i,e]);return{isConnected:e,isConnecting:t,isDisconnected:!e&&!t,error:n,hasError:!!n,connect:o,disconnect:s}}function hg(){const{participants:e}=dn();return{participants:e,count:e.length,localParticipant:e.find(t=>t.isLocal),remoteParticipants:e.filter(t=>!t.isLocal)}}const pg=A.createContext({}),Si=()=>A.useContext(pg);function mg({children:e,...t}){return h.jsx(pg.Provider,{value:t,children:e})}function so({name:e,children:t,fallback:n,className:r}){return h.jsx("div",{className:`voxket-slot voxket-slot--${e} ${r||""}`,children:t||n})}function gg(e,t={}){return Object.assign(e,t)}function bg({showMicrophoneControl:e=!0,showCameraControl:t=!0,showScreenShareControl:n=!0,showSessionActions:r=!0,customControls:i,className:o=""}){const s=er(),a=ug(),l=dg(),c=fg(),u=Si(),d=["voxket-session-controls",`voxket-session-controls--${u.variant||"default"}`,`voxket-session-controls--${u.size||"md"}`,s.isActive?"voxket-session-controls--active":"voxket-session-controls--inactive",o].filter(Boolean).join(" ");return!s.isActive&&!r?h.jsx("div",{className:d,children:h.jsx("div",{className:"voxket-controls-inactive",children:h.jsx("p",{children:"Controls available during active session"})})}):h.jsxs("div",{className:d,children:[r&&h.jsx("div",{className:"voxket-session-actions",children:s.isActive?h.jsx("button",{onClick:s.stop,className:"voxket-button voxket-button--danger",children:"End Session"}):h.jsx(JM,{})}),s.isActive&&h.jsxs("div",{className:"voxket-media-controls",children:[e&&h.jsxs("button",{onClick:a.toggle,disabled:a.isLoading,className:`voxket-button voxket-button--media ${a.isEnabled?"voxket-button--active":""}`,title:a.isEnabled?"Mute microphone":"Unmute microphone",children:[h.jsx("span",{className:"voxket-icon",children:"๐ค"}),a.isLoading?"Loading...":a.isEnabled?"Mute":"Unmute"]}),t&&h.jsxs("button",{onClick:l.toggle,disabled:l.isLoading,className:`voxket-button voxket-button--media ${l.isEnabled?"voxket-button--active":""}`,title:l.isEnabled?"Stop camera":"Start camera",children:[h.jsx("span",{className:"voxket-icon",children:"๐น"}),l.isLoading?"Loading...":l.isEnabled?"Stop Video":"Start Video"]}),n&&h.jsxs("button",{onClick:c.toggle,disabled:c.isLoading,className:`voxket-button voxket-button--media ${c.isSharing?"voxket-button--active":""}`,title:c.isSharing?"Stop screen share":"Start screen share",children:[h.jsx("span",{className:"voxket-icon",children:"๐ฅ๏ธ"}),c.isLoading?"Loading...":c.isSharing?"Stop Share":"Share Screen"]})]}),i&&h.jsx("div",{className:"voxket-custom-controls",children:i})]})}function JM(){er();const[e,t]=A.useState(!1),n=async()=>{t(!0);try{console.log("Start session - agentId needed")}catch(r){console.error("Failed to start session:",r)}finally{t(!1)}};return h.jsx("button",{onClick:n,disabled:e,className:"voxket-button voxket-button--primary",children:e?"Starting...":"Start Session"})}function tc({showConnectionStatus:e=!0,showSessionInfo:t=!0,showAgentInfo:n=!0,className:r=""}){const i=er(),o=ec(),s=Si(),a=["voxket-session-header",`voxket-session-header--${s.variant||"default"}`,`voxket-session-header--${s.size||"md"}`,r].filter(Boolean).join(" ");return h.jsxs("div",{className:a,children:[e&&h.jsxs("div",{className:"voxket-connection-status",children:[h.jsx("div",{className:`voxket-status-indicator ${o.isConnected?"connected":"disconnected"}`}),h.jsx("span",{className:"voxket-status-text",children:o.isConnecting?"Connecting...":o.isConnected?"Connected":"Disconnected"})]}),t&&i.session&&h.jsxs("div",{className:"voxket-session-info",children:[h.jsxs("div",{className:"voxket-session-id",children:["Session: ",i.session.id.slice(-8)]}),h.jsxs("div",{className:"voxket-session-state",children:["State: ",i.state]})]}),n&&i.session&&h.jsxs("div",{className:"voxket-agent-info",children:[h.jsxs("div",{className:"voxket-agent-id",children:["Agent: ",i.session.agentId]}),h.jsxs("div",{className:"voxket-modalities",children:["Modalities: ",i.session.activeModalities.join(", ")]})]}),o.error&&h.jsxs("div",{className:"voxket-error-message",children:["Error: ",o.error.message]})]})}function nc({showChat:e=!0,showTranscriptions:t=!1,customContent:n,className:r=""}){const i=er(),o=Ko(),s=Si(),a=["voxket-session-content",`voxket-session-content--${s.variant||"default"}`,`voxket-session-content--${s.size||"md"}`,r].filter(Boolean).join(" ");return i.isActive?h.jsx("div",{className:a,children:n||h.jsxs(h.Fragment,{children:[e&&h.jsxs("div",{className:"voxket-chat-container",children:[h.jsxs("div",{className:"voxket-chat-messages",children:[o.messages.map(l=>h.jsxs("div",{className:`voxket-message voxket-message--${l.sender.type}`,children:[h.jsxs("div",{className:"voxket-message-header",children:[h.jsx("span",{className:"voxket-message-sender",children:l.sender.name}),h.jsx("span",{className:"voxket-message-time",children:l.timestamp.toLocaleTimeString()})]}),h.jsx("div",{className:"voxket-message-content",children:l.content})]},l.id)),o.messages.length===0&&h.jsx("div",{className:"voxket-empty-messages",children:h.jsx("p",{children:"No messages yet. Start the conversation!"})})]}),h.jsx(eI,{})]}),t&&h.jsx("div",{className:"voxket-transcriptions",children:h.jsx("div",{className:"voxket-transcription-placeholder",children:h.jsx("p",{children:"Voice transcriptions will appear here"})})})]})}):h.jsx("div",{className:a,children:h.jsx("div",{className:"voxket-inactive-state",children:h.jsxs("div",{className:"voxket-inactive-message",children:[h.jsx("h3",{children:"Start a conversation"}),h.jsx("p",{children:"Begin a session to start chatting with the AI agent"})]})})})}function eI(){const e=Ko(),[t,n]=A.useState(""),r=async()=>{if(!(!t.trim()||!e.canSend))try{await e.send(t),n("")}catch(o){console.error("Failed to send message:",o)}},i=o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),r())};return h.jsxs("div",{className:"voxket-chat-input",children:[h.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),onKeyPress:i,placeholder:"Type your message...",disabled:!e.canSend,className:"voxket-input"}),h.jsx("button",{onClick:r,disabled:!e.canSend||!t.trim(),className:"voxket-send-button",children:e.isSending?"Sending...":"Send"})]})}function rc({showMetrics:e=!0,showParticipants:t=!0,showStatus:n=!0,customFooter:r,className:i=""}){const o=er(),s=cg(),a=hg(),l=Si(),c=["voxket-session-footer",`voxket-session-footer--${l.variant||"default"}`,`voxket-session-footer--${l.size||"md"}`,i].filter(Boolean).join(" ");return o.isActive?h.jsx("div",{className:c,children:r||h.jsxs(h.Fragment,{children:[n&&h.jsxs("div",{className:"voxket-session-status",children:[h.jsx("div",{className:"voxket-status-indicator voxket-status-indicator--active"}),h.jsx("span",{className:"voxket-status-text",children:"Session Active"})]}),e&&s.metrics&&h.jsxs("div",{className:"voxket-session-metrics",children:[h.jsxs("div",{className:"voxket-metric",children:[h.jsx("span",{className:"voxket-metric-label",children:"Duration:"}),h.jsx("span",{className:"voxket-metric-value",children:tI(s.duration||0)})]}),h.jsxs("div",{className:"voxket-metric",children:[h.jsx("span",{className:"voxket-metric-label",children:"Messages:"}),h.jsx("span",{className:"voxket-metric-value",children:s.metrics.messageCount})]})]}),t&&h.jsxs("div",{className:"voxket-participants-info",children:[h.jsxs("span",{className:"voxket-participants-count",children:[a.count," participant",a.count!==1?"s":""]}),a.remoteParticipants.length>0&&h.jsx("div",{className:"voxket-participant-list",children:a.remoteParticipants.map(u=>h.jsx("span",{className:"voxket-participant-name",children:u.name},u.id))})]})]})}):h.jsx("div",{className:c,children:h.jsx("div",{className:"voxket-footer-inactive",children:h.jsx("span",{className:"voxket-status-text",children:"Ready to start session"})})})}function tI(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}:${(n%60).toString().padStart(2,"0")}:${(t%60).toString().padStart(2,"0")}`:`${n}:${(t%60).toString().padStart(2,"0")}`}function nI({agentId:e,sessionConfig:t,autoStart:n=!1,onSessionStart:r,onSessionEnd:i,variant:o="default",size:s="md",theme:a,className:l="",children:c}){var p;const u=er(),d=ec();A.useEffect(()=>{n&&e&&d.isConnected&&!u.isActive&&u.start(e,t).catch(console.error)},[n,e,d.isConnected,u.isActive]),A.useEffect(()=>{var g;(g=u.session)!=null&&g.id&&r&&r(u.session.id)},[(p=u.session)==null?void 0:p.id,r]),A.useEffect(()=>()=>{u.isActive&&i&&u.stop().then(i).catch(console.error)},[]);const f=["voxket-session",`voxket-session--${o}`,`voxket-session--${s}`,u.isActive?"voxket-session--active":"voxket-session--inactive",l].filter(Boolean).join(" ");return h.jsx(mg,{variant:o,size:s,theme:a,className:l,children:h.jsx("div",{className:f,children:c||h.jsxs(h.Fragment,{children:[h.jsx(so,{name:"header",fallback:h.jsx(tc,{})}),h.jsx(so,{name:"content",fallback:h.jsx(nc,{})}),h.jsx(so,{name:"footer",fallback:h.jsx(rc,{})})]})})})}const yg=gg(nI,{Header:tc,Content:nc,Footer:rc,Controls:bg}),Yn={name:"default",colors:{primary:"#3B82F6",secondary:"#6B7280",accent:"#8B5CF6",background:"#FFFFFF",surface:"#F9FAFB",text:{primary:"#111827",secondary:"#6B7280",muted:"#9CA3AF",inverse:"#FFFFFF"},status:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},border:"#E5E7EB",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700},lineHeight:{tight:1.25,normal:1.5,relaxed:1.75}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{none:"0",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1)"}},La={...Yn,name:"dark",colors:{primary:"#60A5FA",secondary:"#9CA3AF",accent:"#A78BFA",background:"#111827",surface:"#1F2937",text:{primary:"#F9FAFB",secondary:"#D1D5DB",muted:"#9CA3AF",inverse:"#111827"},status:{success:"#34D399",warning:"#FBBF24",error:"#F87171",info:"#60A5FA"},border:"#374151",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.3)"}},Fa={...Yn,name:"enterprise",colors:{primary:"#1E40AF",secondary:"#64748B",accent:"#7C3AED",background:"#FFFFFF",surface:"#F8FAFC",text:{primary:"#0F172A",secondary:"#475569",muted:"#94A3B8",inverse:"#FFFFFF"},status:{success:"#059669",warning:"#D97706",error:"#DC2626",info:"#1E40AF"},border:"#CBD5E1",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.375rem",full:"9999px"}},xg=A.createContext(null),wg=()=>{const e=A.useContext(xg);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};function rI({theme:e="default",themes:t={},children:n,cssVariables:r=!0,className:i=""}){const[o,s]=A.useState(()=>{const f={default:Yn,dark:La,enterprise:Fa,...t};return typeof e=="string"?f[e]||Yn:e}),[a,l]=A.useState(()=>({default:Yn,dark:La,enterprise:Fa,...t})),c=f=>{if(typeof f=="string"){const p=a[f];p&&s(p)}else s(f)},u=f=>{l(p=>({...p,[f.name]:f}))};A.useEffect(()=>{if(r&&typeof document<"u"){const f=document.documentElement;Object.entries(vg(o)).forEach(([p,g])=>{f.style.setProperty(`--voxket-${p}`,g)})}},[o,r]);const d={theme:o,setTheme:c,themes:a,registerTheme:u};return h.jsx(xg.Provider,{value:d,children:h.jsx("div",{className:`voxket-theme voxket-theme--${o.name} ${i}`,children:n})})}function vg(e){const t={},n=(r,i="")=>{for(const[o,s]of Object.entries(r)){const a=i?`${i}-${o}`:o;typeof s=="object"&&s!==null&&!Array.isArray(s)?n(s,a):t[a]=String(s)}};return n(e),t}function iI(e=Yn,t){return{...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows}}}function oI(e){var n;const{theme:t}=wg();return((n=t.components)==null?void 0:n[e])||{}}const sI=Jl("voice-modality","voice",{onActivate:async e=>{const t=e.config;t.enableTranscription&&aI(e),t.enableVoiceActivation&&lI(e,t),console.log("Voice modality activated",t)},onDeactivate:async e=>{console.log("Voice modality deactivated")},onMessage:async(e,t)=>{t.type==="audio"&&cI(e,t)}});function aI(e,t){e.on("participant.speaking.started",n=>{console.log("Transcription: Started for",n.name)}),e.on("participant.speaking.stopped",n=>{console.log("Transcription: Stopped for",n.name)})}function lI(e,t){const n=t.silenceThreshold||-50;console.log("Voice activation setup with threshold:",n)}function cI(e,t){console.log("Playing audio response:",t.content)}const uI=Jl("chat-modality","chat",{onActivate:async e=>{const t=e.config;t.enableRichText&&dI(),t.enableFileUpload&&fI(e),t.enableCustomComponents&&hI(),console.log("Chat modality activated",t)},onDeactivate:async e=>{console.log("Chat modality deactivated")},onMessage:async(e,t)=>{const n=e.config;t.type==="ui_component"?pI(e,t):t.type==="text"&&n.enableRichText&&mI(e,t)}});function dI(e){console.log("Rich text support enabled")}function fI(e){console.log("File upload enabled"),e.on("chat.file.uploaded",t=>{console.log("File uploaded:",t.name)})}function hI(e){console.log("Custom components enabled");const t=new Map;t.set("quick-actions",gI),t.set("form",bI),t.set("card",yI),t.set("chart",xI)}function pI(e,t){const{componentType:n,props:r}=t.metadata;console.log("Rendering custom component:",n,r),e.emit("chat.component.render",{type:n,props:r,timestamp:new Date})}function mI(e,t){console.log("Processing rich text message:",t.content)}function gI(e){return{type:"quick-actions",actions:e.actions||[],layout:e.layout||"horizontal"}}function bI(e){return{type:"form",fields:e.fields||[],submitAction:e.submitAction,validation:e.validation}}function yI(e){return{type:"card",title:e.title,content:e.content,actions:e.actions,variant:e.variant||"default"}}function xI(e){return{type:"chart",chartType:e.chartType||"line",data:e.data,options:e.options}}function ao({track:e,participantName:t,showControls:n=!0,showName:r=!0,showMuteIndicator:i=!0,isPinned:o=!1,className:s="",onClick:a,onPin:l,onUnpin:c}){const u=A.useRef(null),[d,f]=A.useState(!1);A.useEffect(()=>{if(!u.current||!e.isEnabled)return;const x=u.current;return x.srcObject=null,()=>{x.srcObject&&(x.srcObject=null)}},[e]);const p=()=>{a==null||a(e)},g=x=>{x.stopPropagation(),o?c==null||c(e):l==null||l(e)},m=["voxket-video-tile",e.isLocal?"voxket-video-tile--local":"voxket-video-tile--remote",e.isScreenShare?"voxket-video-tile--screen-share":"voxket-video-tile--camera",o?"voxket-video-tile--pinned":"",e.isEnabled?"":"voxket-video-tile--disabled",d?"voxket-video-tile--hovered":"",s].filter(Boolean).join(" ");return h.jsxs("div",{className:m,onClick:p,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{aspectRatio:e.dimensions?`${e.dimensions.width} / ${e.dimensions.height}`:"16 / 9"},children:[h.jsx("video",{ref:u,className:"voxket-video-element",autoPlay:!0,playsInline:!0,muted:e.isLocal}),!e.isEnabled&&h.jsxs("div",{className:"voxket-video-placeholder",children:[h.jsx("div",{className:"voxket-video-placeholder-icon",children:e.isScreenShare?"๐ฅ๏ธ":"๐น"}),h.jsx("p",{className:"voxket-video-placeholder-text",children:e.isScreenShare?"Screen sharing paused":"Camera off"})]}),h.jsxs("div",{className:"voxket-video-overlay",children:[r&&t&&h.jsxs("div",{className:"voxket-video-name",children:[t,e.isLocal&&" (You)"]}),i&&!e.isEnabled&&h.jsx("div",{className:"voxket-video-mute-indicator",children:"๐"}),n&&(d||o)&&h.jsxs("div",{className:"voxket-video-controls",children:[h.jsx("button",{className:`voxket-video-control-btn ${o?"voxket-video-control-btn--active":""}`,onClick:g,title:o?"Unpin video":"Pin video",children:"๐"}),e.isScreenShare&&h.jsx("div",{className:"voxket-video-indicator",children:"๐ฅ๏ธ"}),e.source&&h.jsx("div",{className:"voxket-video-source",children:e.source})]})]}),!e.isEnabled&&h.jsx("div",{className:"voxket-video-loading",children:h.jsx("div",{className:"voxket-spinner"})})]})}function wI({tracks:e,layout:t,className:n="",onLayoutChange:r,onTrackClick:i,maxVisibleTracks:o=9,showPagination:s=!0}){const[a,l]=A.useState(0),[c,u]=A.useState(null),d=A.useMemo(()=>{let k=[...e];t.type==="speaker"&&c&&(k=[c,...e.filter(v=>v.id!==c.id)]);const E=a*o,_=E+o;return k.slice(E,_)},[e,t,c,a,o]),f=Math.ceil(e.length/o),p=A.useMemo(()=>{const k=d.length;switch(t.type){case"grid":const E=Math.ceil(Math.sqrt(k)),_=Math.ceil(k/E);return{display:"grid",gridTemplateColumns:`repeat(${E}, 1fr)`,gridTemplateRows:`repeat(${_}, 1fr)`,gap:"8px"};case"speaker":return{display:"flex",flexDirection:"column",gap:"8px"};case"sidebar":return{display:"flex",gap:"8px"};case"gallery":return{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center"};default:return{}}},[t.type,d.length]),g=k=>{u(k)},m=()=>{u(null)},x=k=>{r==null||r({...t,type:k})},y=["voxket-video-grid",`voxket-video-grid--${t.type}`,`voxket-video-grid--${d.length}-tracks`,n].filter(Boolean).join(" ");return e.length===0?h.jsx("div",{className:"voxket-video-grid-empty",children:h.jsxs("div",{className:"voxket-video-grid-empty-content",children:[h.jsx("div",{className:"voxket-video-grid-empty-icon",children:"๐น"}),h.jsx("p",{children:"No video tracks available"})]})}):h.jsxs("div",{className:y,children:[h.jsxs("div",{className:"voxket-video-grid-controls",children:[h.jsx("div",{className:"voxket-video-layout-controls",children:["grid","speaker","sidebar","gallery"].map(k=>h.jsx("button",{className:`voxket-layout-btn ${t.type===k?"voxket-layout-btn--active":""}`,onClick:()=>x(k),title:`Switch to ${k} layout`,children:vI(k)},k))}),h.jsxs("div",{className:"voxket-video-count",children:[e.length," participant",e.length!==1?"s":""]})]}),h.jsx("div",{className:"voxket-video-grid-content",style:p,children:t.type==="speaker"&&c?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"voxket-video-speaker-main",children:h.jsx(ao,{track:c,participantName:`Participant ${c.participantId}`,isPinned:!0,onClick:i,onUnpin:m})}),h.jsx("div",{className:"voxket-video-speaker-sidebar",children:d.filter(k=>k.id!==c.id).map(k=>h.jsx(ao,{track:k,participantName:`Participant ${k.participantId}`,showControls:!1,onClick:i,onPin:g},k.id))})]}):d.map(k=>h.jsx(ao,{track:k,participantName:`Participant ${k.participantId}`,isPinned:(c==null?void 0:c.id)===k.id,onClick:i,onPin:g,onUnpin:m},k.id))}),s&&f>1&&h.jsxs("div",{className:"voxket-video-pagination",children:[h.jsx("button",{className:"voxket-pagination-btn",onClick:()=>l(Math.max(0,a-1)),disabled:a===0,children:"โ"}),h.jsxs("span",{className:"voxket-pagination-info",children:["Page ",a+1," of ",f]}),h.jsx("button",{className:"voxket-pagination-btn",onClick:()=>l(Math.min(f-1,a+1)),disabled:a===f-1,children:"โ"})]})]})}function vI(e){switch(e){case"grid":return"โ";case"speaker":return"๐ค";case"sidebar":return"โซธ";case"gallery":return"โก";case"picture-in-picture":return"โง";default:return"โ"}}function EI({localTrack:e,onToggleCamera:t,onToggleScreenShare:n,onLayoutChange:r,showLayoutControls:i=!0,showCameraControls:o=!0,showScreenShareControls:s=!0,className:a=""}){const l=["voxket-video-controls",a].filter(Boolean).join(" "),c=u=>{r==null||r({type:u,showLocalVideo:!0,aspectRatio:"16:9"})};return h.jsxs("div",{className:l,children:[o&&h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Camera"}),h.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isEnabled?"voxket-control-btn--active":""}`,onClick:t,title:e!=null&&e.isEnabled?"Turn off camera":"Turn on camera",children:[h.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isEnabled?"๐น":"๐ท"}),h.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isEnabled?"Camera On":"Camera Off"})]}),(e==null?void 0:e.dimensions)&&h.jsxs("div",{className:"voxket-video-info",children:[e.dimensions.width," ร ",e.dimensions.height]})]}),s&&h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Screen Share"}),h.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isScreenShare?"voxket-control-btn--active":""}`,onClick:n,title:e!=null&&e.isScreenShare?"Stop screen sharing":"Start screen sharing",children:[h.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isScreenShare?"๐":"๐ฅ๏ธ"}),h.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isScreenShare?"Stop Sharing":"Share Screen"})]})]}),i&&h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Layout"}),h.jsx("div",{className:"voxket-layout-buttons",children:[{type:"grid",icon:"โ",label:"Grid"},{type:"speaker",icon:"๐ค",label:"Speaker"},{type:"sidebar",icon:"โซธ",label:"Sidebar"},{type:"gallery",icon:"โก",label:"Gallery"}].map(({type:u,icon:d,label:f})=>h.jsxs("button",{className:"voxket-layout-control-btn",onClick:()=>c(u),title:`Switch to ${f} layout`,children:[h.jsx("span",{className:"voxket-control-icon",children:d}),h.jsx("span",{className:"voxket-control-label",children:f})]},u))})]}),h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Video Settings"}),h.jsxs("div",{className:"voxket-video-settings",children:[h.jsxs("div",{className:"voxket-setting-group",children:[h.jsx("label",{className:"voxket-setting-label",children:"Quality"}),h.jsxs("select",{className:"voxket-setting-select",children:[h.jsx("option",{value:"high",children:"High (720p)"}),h.jsx("option",{value:"medium",children:"Medium (480p)"}),h.jsx("option",{value:"low",children:"Low (240p)"})]})]}),h.jsxs("div",{className:"voxket-setting-group",children:[h.jsx("label",{className:"voxket-setting-label",children:"Frame Rate"}),h.jsxs("select",{className:"voxket-setting-select",children:[h.jsx("option",{value:"30",children:"30 fps"}),h.jsx("option",{value:"15",children:"15 fps"}),h.jsx("option",{value:"10",children:"10 fps"})]})]}),h.jsxs("div",{className:"voxket-setting-group",children:[h.jsx("label",{className:"voxket-setting-label",children:"Bandwidth"}),h.jsxs("select",{className:"voxket-setting-select",children:[h.jsx("option",{value:"unlimited",children:"Unlimited"}),h.jsx("option",{value:"1000",children:"1 Mbps"}),h.jsx("option",{value:"500",children:"500 Kbps"}),h.jsx("option",{value:"250",children:"250 Kbps"})]})]})]})]}),h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Statistics"}),h.jsxs("div",{className:"voxket-video-stats",children:[h.jsxs("div",{className:"voxket-stat-item",children:[h.jsx("span",{className:"voxket-stat-label",children:"Resolution:"}),h.jsx("span",{className:"voxket-stat-value",children:e!=null&&e.dimensions?`${e.dimensions.width}ร${e.dimensions.height}`:"N/A"})]}),h.jsxs("div",{className:"voxket-stat-item",children:[h.jsx("span",{className:"voxket-stat-label",children:"Source:"}),h.jsx("span",{className:"voxket-stat-value",children:(e==null?void 0:e.source)||"None"})]}),h.jsxs("div",{className:"voxket-stat-item",children:[h.jsx("span",{className:"voxket-stat-label",children:"Status:"}),h.jsx("span",{className:`voxket-stat-value ${e!=null&&e.isEnabled?"voxket-stat-value--active":"voxket-stat-value--inactive"}`,children:e!=null&&e.isEnabled?"Active":"Inactive"})]})]})]})]})}const Eg=({handler:e,loadData:t,data:n,client:r,addLocalMessage:i})=>{const[o,s]=P.useState(null),[a,l]=P.useState(!0),[c,u]=P.useState(!1),[d]=P.useState(Date.now());P.useEffect(()=>{(async()=>{try{if(l(!0),console.log("๐ AssignmentView: Loading assignment data..."),console.log("๐ AssignmentView: Received data from RPC:",n),n&&typeof n=="object"){const x={title:n.title||"Untitled Assignment",description:n.description||"No description provided",estimated_time_of_completion:n.estimated_time_of_completion||"Unknown"};s(x),console.log("๐ AssignmentView: Assignment loaded from RPC data:",x)}}catch(x){console.error("๐ AssignmentView: Error loading assignment:",x),s({title:"Assignment Loading Error",description:"There was an error loading the assignment details. Please try again.",estimated_time_of_completion:"Unknown"})}finally{l(!1)}})()},[n,t]);const f=({message:m,assignment:x})=>{const y=m.toLowerCase().includes("declined"),k=y?"bg-red-50 border-red-200":"bg-green-50 border-green-200",E=y?"text-red-700":"text-green-700",_=y?"โ":"๐";return h.jsxs("div",{className:`max-w-sm mx-auto ${k} border rounded-lg shadow p-3 flex flex-col items-center`,children:[h.jsx("div",{className:"text-2xl mb-2",children:_}),h.jsx("div",{className:`${E} font-semibold text-sm mb-1`,children:m}),h.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:x.title}),h.jsx("div",{className:"text-xs text-gray-500",children:"Thank you for your response!"})]})},p=async()=>{if(!(!o||!e)){u(!0);try{const m={message:"accepted"};console.log("๐ AssignmentView: Assignment accepted:",m),e.didSuccess(m,h.jsx(f,{message:"Assignment accepted!",assignment:o}))}catch(m){console.error("๐ AssignmentView: Error accepting assignment:",m),e.didFail({error:"Failed to accept assignment"})}finally{u(!1)}}},g=async()=>{if(!(!o||!e)){u(!0);try{const m={message:"declined"};console.log("๐ AssignmentView: Assignment declined:",m),e.didSuccess(m,h.jsx(f,{message:"Assignment declined",assignment:o}))}catch(m){console.error("๐ AssignmentView: Error declining assignment:",m),e.didFail({error:"Failed to decline assignment"})}finally{u(!1)}}};return a?h.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:h.jsxs("div",{className:"flex items-center justify-center py-4",children:[h.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),h.jsx("span",{className:"ml-2 text-xs text-gray-600",children:"Loading assignment..."})]})}):o?h.jsxs("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg overflow-hidden",children:[h.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-purple-600 text-white p-3",children:h.jsx("div",{className:"flex items-center justify-between",children:h.jsx("h3",{className:"text-xs font-semibold text-white truncate",children:o.title})})}),h.jsxs("div",{className:"p-3 text-black",children:[h.jsx("div",{className:"bg-gray-50 rounded p-2 mb-3",children:h.jsx("p",{className:"text-xs text-black leading-snug",children:o.description})}),h.jsx("div",{className:"mb-3 text-black",children:h.jsxs("div",{className:"flex items-center text-xs text-gray-600",children:[h.jsx("span",{className:"text-xs mr-1",children:"๐
"}),h.jsxs("span",{children:["Est: ",o.estimated_time_of_completion]})]})}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:p,disabled:c,className:"flex-1 bg-green-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:c?h.jsxs("span",{className:"flex items-center justify-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-2 w-2 border-b-2 border-white mr-1"}),h.jsx("span",{className:"text-xs",children:"Processing..."})]}):"Accept"}),h.jsx("button",{onClick:g,disabled:c,className:"flex-1 bg-red-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Decline"})]})]})]}):h.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:h.jsxs("div",{className:"text-center py-4",children:[h.jsx("div",{className:"text-red-600 text-sm font-semibold mb-2",children:"โ ๏ธ Assignment Error"}),h.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"Failed to load assignment details."})]})})};function kI(){const[e,t]=P.useState(null),[n,r]=P.useState([]);P.useEffect(()=>{const a=new ki({appId:"your-app-id",appSecret:"your-app-secret",baseUrl:"https://your-voxket-api.com",agentId:"your-agent-id",participantName:"User",modalities:["chat"]});return t(a),a.on("rpc.method.called",l=>{console.log("RPC Method Called:",l)}),a.on("rpc.interaction.completed",l=>{console.log("RPC Interaction Completed:",l)}),()=>{a.disconnect()}},[]);const i=async()=>{if(e)try{await e.registerFrontendRPC("give_assignment",Eg,"embedded");const a=e.getRegisteredRpcMethods();r(a),console.log("โ
Assignment RPC registered successfully")}catch(a){console.error("โ Failed to register assignment RPC:",a)}},o=async()=>{if(!e)return;const a=({handler:l,timeout:c})=>{const[u,d]=P.useState(""),f=[{id:"pro",name:"Pro Plan",price:"$29/month"},{id:"enterprise",name:"Enterprise Plan",price:"$99/month"},{id:"basic",name:"Basic Plan",price:"$9/month"}],p=m=>{d(m)},g=()=>{const m=f.find(x=>x.id===u);l==null||l.didSuccess({selectedProduct:u,productName:m==null?void 0:m.name,price:m==null?void 0:m.price,timestamp:new Date().toISOString()})};return h.jsxs("div",{className:"p-6 bg-white rounded-lg",children:[h.jsx("h3",{className:"text-xl font-bold mb-4",children:"Choose Your Plan"}),h.jsx("p",{className:"text-gray-600 mb-4",children:"Select the plan that best fits your needs:"}),h.jsx("div",{className:"space-y-3 mb-6",children:f.map(m=>h.jsx("div",{onClick:()=>p(m.id),className:`p-4 border rounded-lg cursor-pointer transition-all ${u===m.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:h.jsxs("div",{className:"flex justify-between items-center",children:[h.jsxs("div",{children:[h.jsx("h4",{className:"font-medium",children:m.name}),h.jsx("p",{className:"text-gray-600 text-sm",children:m.price})]}),h.jsx("div",{className:`w-4 h-4 rounded-full ${u===m.id?"bg-blue-500":"border-2 border-gray-300"}`})]})},m.id))}),h.jsxs("div",{className:"flex justify-end space-x-3",children:[h.jsx("button",{onClick:()=>l==null?void 0:l.dismissView(),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Cancel"}),h.jsx("button",{onClick:g,disabled:!u,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Select Plan"})]}),c&&h.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Time remaining: ",c," seconds"]})]})};try{await e.registerFrontendRPC("recommend_product",a,"modal");const l=e.getRegisteredRpcMethods();r(l),console.log("โ
Product Recommendation RPC registered successfully")}catch(l){console.error("โ Failed to register product recommendation RPC:",l)}},s=async()=>{if(!e)return;const a=({handler:l})=>{const[c,u]=P.useState(0),[d,f]=P.useState(""),p=()=>{l==null||l.didSuccess({rating:c,comment:d,timestamp:new Date().toISOString()})};return h.jsxs("div",{className:"p-4 bg-white rounded-lg",children:[h.jsx("h3",{className:"text-lg font-semibold mb-3",children:"How was your experience?"}),h.jsxs("div",{className:"mb-4",children:[h.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Rate your experience:"}),h.jsx("div",{className:"flex space-x-1",children:[1,2,3,4,5].map(g=>h.jsx("button",{onClick:()=>u(g),className:`text-2xl ${g<=c?"text-yellow-400":"text-gray-300"}`,children:"โญ"},g))})]}),h.jsxs("div",{className:"mb-4",children:[h.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Additional comments:"}),h.jsx("textarea",{value:d,onChange:g=>f(g.target.value),className:"w-full p-2 border border-gray-300 rounded text-sm",rows:3,placeholder:"Tell us more about your experience..."})]}),h.jsxs("div",{className:"flex justify-end space-x-2",children:[h.jsx("button",{onClick:()=>l==null?void 0:l.dismissView(),className:"px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Skip"}),h.jsx("button",{onClick:p,disabled:c===0,className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Submit"})]})]})};try{await e.registerFrontendRPC("collect_feedback",a,"embedded");const l=e.getRegisteredRpcMethods();r(l),console.log("โ
Feedback RPC registered successfully")}catch(l){console.error("โ Failed to register feedback RPC:",l)}};return h.jsxs("div",{className:"p-6",children:[h.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Frontend RPC Examples"}),h.jsxs("div",{className:"space-y-4 mb-6",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Register RPC Methods"}),h.jsxs("div",{className:"space-x-2",children:[h.jsx("button",{onClick:i,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Register Assignment RPC"}),h.jsx("button",{onClick:o,className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Register Product Recommendation RPC"}),h.jsx("button",{onClick:s,className:"px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600",children:"Register Feedback RPC"})]})]}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Registered Methods"}),n.length>0?h.jsx("ul",{className:"list-disc list-inside space-y-1",children:n.map(a=>h.jsx("li",{className:"text-gray-700",children:h.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:a})},a))}):h.jsx("p",{className:"text-gray-500",children:"No methods registered yet"})]})]}),h.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"How it works"}),h.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-gray-700",children:[h.jsxs("li",{children:["Register RPC methods with React components using ",h.jsx("code",{children:"client.registerFrontendRPC()"})]}),h.jsx("li",{children:"When the agent calls an RPC method, the corresponding component will be displayed"}),h.jsx("li",{children:"Users interact with the component, and the response is sent back to the agent"}),h.jsx("li",{children:"Components can be displayed in different modes: embedded, modal, or fullscreen"}),h.jsx("li",{children:"Each component has a timeout and can handle success/failure scenarios"})]})]}),h.jsxs("div",{className:"mt-6 bg-blue-50 p-4 rounded-lg",children:[h.jsx("h3",{className:"text-lg font-semibold mb-2 text-blue-800",children:"Agent Side"}),h.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"On the agent side, you can call these RPC methods like this:"}),h.jsx("pre",{className:"bg-white p-3 rounded text-xs text-gray-800 overflow-x-auto",children:`// Agent calls RPC method
|
|
143
|
+
`,style:{minHeight:"2.5rem",display:s===r?"block":"none"},children:o},s))})}function LM({statusMessage:e,theme:t}){const n=Ct(t);return h.jsxs("div",{className:"z-10 flex items-center space-x-2 mt-2 pb-2",children:[h.jsx("div",{className:n.statusIndicator}),h.jsx("span",{className:`text-xs ${n.text.muted}`,children:e})]})}const ig=A.forwardRef(({disabled:e,onStartCall:t,onStartChat:n,onStartVideo:r,prompts:i=['"Book a meeting with the marketing team"',`"What's the status of project Alpha?"`,`"Summarize yesterday's sales report"`,'"Find a good Italian restaurant nearby"','"Remind me to call John tomorrow at 10 AM"'],statusMessage:o="Agent is ready",title:s="Choose how to interact",subTitle:a="Ask me anything or give me a task to complete",theme:l="vox",modalities:c=["voice","chat","video"]},u)=>{const d=Ct(l),f=c.includes("voice"),p=c.includes("chat"),g=c.includes("video"),m=[f,p,g].filter(Boolean).length;return h.jsxs("div",{className:"flex p-8 flex-col items-center h-full justify-center w-full relative","aria-disabled":e,style:{background:"transparent"},children:[h.jsxs("div",{className:"mt-1 relative flex items-center justify-center mb-8 w-full",style:{minHeight:"120px"},children:[h.jsxs("div",{className:"absolute inset-0 flex items-center justify-center",children:[h.jsx("div",{className:d.pulseRings.ring1}),h.jsx("div",{className:d.pulseRings.ring2,style:{animationDelay:"0.5s"}}),h.jsx("div",{className:d.pulseRings.ring3,style:{animationDelay:"1s"}})]}),h.jsx("div",{className:"relative z-10 flex items-center justify-center",children:f&&p&&g?h.jsxs("div",{className:"flex gap-4 items-center justify-center",children:[h.jsx(Zi,{onClick:t,disabled:e,theme:l}),h.jsx(Ks,{onClick:n,disabled:e,theme:l}),h.jsx(qs,{onClick:r||t,disabled:e,theme:l})]}):m>1?h.jsxs("div",{className:"flex gap-6 items-center justify-center",children:[f&&h.jsx(Zi,{onClick:t,disabled:e,theme:l}),p&&h.jsx(Ks,{onClick:n,disabled:e,theme:l}),g&&r&&h.jsx(qs,{onClick:r,disabled:e,theme:l})]}):h.jsx("div",{className:"flex items-center justify-center",children:f?h.jsx(Zi,{onClick:t,disabled:e,theme:l}):p?h.jsx(Ks,{onClick:n,disabled:e,theme:l}):g&&r?h.jsx(qs,{onClick:r,disabled:e,theme:l}):h.jsx(Zi,{onClick:t,disabled:e,theme:l})})})]}),h.jsxs("div",{className:"text-center flex flex-col items-center gap-y-2 mb-6 w-full",children:[l==="midnight"?h.jsx("h3",{className:"text-xl font-semibold mb-2 text-white",children:String(s).split(/(interact)/i).map((y,k)=>y.toLowerCase()==="interact"?h.jsx("span",{className:d.text.accent,children:y},k):h.jsx("span",{children:y},k))}):h.jsx("h3",{className:`text-xl font-semibold mb-2 ${d.text.accent}`,children:s}),h.jsx("p",{className:`text-sm leading-relaxed px-4 ${d.text.secondary}`,children:a}),m>1&&h.jsxs("div",{className:"flex gap-6 mt-4 text-xs justify-center",children:[f&&h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.jsx(ng,{className:"w-4 h-4"}),h.jsx("span",{className:d.text.muted,children:"Voice"})]}),p&&h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.jsx(tg,{className:"w-4 h-4"}),h.jsx("span",{className:d.text.muted,children:"Chat"})]}),g&&h.jsxs("div",{className:"flex flex-col items-center gap-1",children:[h.jsx(rg,{className:"w-4 h-4"}),h.jsx("span",{className:d.text.muted,children:"Video"})]})]})]}),h.jsx(DM,{prompts:i,theme:l}),h.jsx(LM,{statusMessage:o,theme:l})]})});ig.displayName="Welcome";class Xl extends P.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(t){return{hasError:!0,error:t}}componentDidCatch(t,n){console.error("VoxketWidget Error:",t,n)}render(){if(this.state.hasError){if(this.props.fallback){const t=this.props.fallback;return P.createElement(t,{error:this.state.error})}return P.createElement("div",{style:{padding:"20px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"}},"VoxketWidget encountered an error. Please check the console for details.")}return this.props.children}}const og=({onClick:e,position:t="bottom-right",size:n=64,className:r="",style:i,ariaLabel:o="Open Voxket",logoScale:s=.95})=>{const a={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"},l={width:n,height:n,...i};return h.jsx(Ae.button,{type:"button",onClick:e,"aria-label":o,className:`fixed z-50 rounded-full bg-black shadow-xl flex items-center justify-center overflow-hidden focus:outline-none focus:ring-2 focus:ring-white/40 ${a[t]} ${r}`,style:l,initial:{scale:.9,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.9,opacity:0},whileHover:{scale:1.05},whileTap:{scale:.95},"data-position":t,children:h.jsx("img",{src:"/logo.png",alt:"Voxket",className:"object-contain select-none pointer-events-none",style:{width:`${Math.max(0,Math.min(1,s))*100}%`,height:`${Math.max(0,Math.min(1,s))*100}%`},draggable:!1})})};function sg({room:e,onSessionEnd:t,onSessionStart:n,enableConsoleLogging:r=!0,enableLocalStorage:i=!0,voxketSessionId:o}={}){const[s,a]=P.useState(null),[l,c]=P.useState([]),[u,d]=P.useState(null),[f,p]=P.useState([]),g=P.useCallback((k,E)=>{const _={timestamp:new Date,event:k,data:E,sessionId:s==null?void 0:s.sessionId,participantId:u==null?void 0:u.identity};if(c(v=>[...v,_]),i){const v=JSON.parse(localStorage.getItem("voxket-session-logs")||"[]");v.push(_),localStorage.setItem("voxket-session-logs",JSON.stringify(v))}return _},[s==null?void 0:s.sessionId,u==null?void 0:u.identity,r,i]);P.useEffect(()=>{if(!e)return;const k=()=>{const b=o||`session-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,R=new Date,I={sessionId:b,startTime:R,totalMessages:0,connectionIssues:0,participantCount:f.length,events:[]};a(I),g("SESSION_STARTED",{sessionId:b,startTime:R}),n==null||n(b)},E=()=>{if(s){const b=new Date,R=b.getTime()-s.startTime.getTime(),I={...s,endTime:b,duration:R,events:l};g("SESSION_ENDED",{sessionId:s.sessionId,duration:`${Math.round(R/1e3)}s`,totalMessages:s.totalMessages,connectionIssues:s.connectionIssues}),t==null||t(I),a(null),c([])}},_=b=>{g("CONNECTION_STATE_CHANGED",{state:b}),b===ce.ConnectionState.Reconnecting&&s&&(a(R=>R?{...R,connectionIssues:R.connectionIssues+1}:null),g("CONNECTION_ISSUE",{type:"reconnecting"}))},v=b=>{g("TRACK_PUBLISHED",{trackKind:b.kind,trackSource:b.source})},C=b=>{g("TRACK_UNPUBLISHED",{trackKind:b.kind,trackSource:b.source})},M=(b,R)=>{s&&a(I=>I?{...I,totalMessages:I.totalMessages+1}:null),g("DATA_RECEIVED",{participantId:R==null?void 0:R.identity,dataSize:b.length})},N=b=>{g("PARTICIPANT_CONNECTED",{participantId:b.identity,participantName:b.name}),p(R=>[...R,b]),s&&a(R=>R?{...R,participantCount:R.participantCount+1}:null)},O=b=>{g("PARTICIPANT_DISCONNECTED",{participantId:b.identity,participantName:b.name}),p(R=>R.filter(I=>I.identity!==b.identity))};return e.localParticipant&&d(e.localParticipant),e.on(ce.RoomEvent.Connected,k),e.on(ce.RoomEvent.Disconnected,E),e.on(ce.RoomEvent.ConnectionStateChanged,_),e.on(ce.RoomEvent.TrackPublished,v),e.on(ce.RoomEvent.TrackUnpublished,C),e.on(ce.RoomEvent.DataReceived,M),e.on(ce.RoomEvent.ParticipantConnected,N),e.on(ce.RoomEvent.ParticipantDisconnected,O),()=>{e.off(ce.RoomEvent.Connected,k),e.off(ce.RoomEvent.Disconnected,E),e.off(ce.RoomEvent.ConnectionStateChanged,_),e.off(ce.RoomEvent.TrackPublished,v),e.off(ce.RoomEvent.TrackUnpublished,C),e.off(ce.RoomEvent.DataReceived,M),e.off(ce.RoomEvent.ParticipantConnected,N),e.off(ce.RoomEvent.ParticipantDisconnected,O)}},[e,s,l,f.length,g,t,n]);const m=P.useCallback(()=>i?JSON.parse(localStorage.getItem("voxket-session-logs")||"[]"):l,[l,i]),x=P.useCallback(()=>{i&&localStorage.removeItem("voxket-session-logs"),c([])},[i]),y=P.useCallback(()=>{const k=m(),E=JSON.stringify(k,null,2),_="data:application/json;charset=utf-8,"+encodeURIComponent(E),v=`voxket-session-logs-${new Date().toISOString().split("T")[0]}.json`,C=document.createElement("a");C.setAttribute("href",_),C.setAttribute("download",v),C.click()},[m]);return{sessionMetrics:s,sessionLogs:l,logEvent:g,getSessionLogs:m,clearSessionLogs:x,exportSessionLogs:y}}class Ql{constructor(){rt(this,"listeners",{})}on(t,n){return this.listeners[t]||(this.listeners[t]=[]),this.listeners[t].push(n),()=>this.off(t,n)}once(t,n){const r=(...i)=>{this.off(t,r),n(...i)};return this.on(t,r)}off(t,n){const r=this.listeners[t];if(!r)return;const i=r.indexOf(n);i>-1&&r.splice(i,1)}removeAllListeners(t){t?delete this.listeners[t]:this.listeners={}}emit(t,...n){const r=this.listeners[t];if(!r)return;const i=[...r];for(const o of i)try{o(...n)}catch(s){console.error(`Error in event listener for ${String(t)}:`,s)}}listenerCount(t){var n;return((n=this.listeners[t])==null?void 0:n.length)??0}eventNames(){return Object.keys(this.listeners)}}class ag{constructor(t){rt(this,"plugins",new Map);rt(this,"installedPlugins",new Set);rt(this,"context");this.context={client:t,emit:t.emit.bind(t),on:t.on.bind(t),config:{}}}register(t){if(this.plugins.has(t.name))throw new Error(`Plugin '${t.name}' is already registered`);if(t.dependencies){for(const n of t.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin '${t.name}' depends on '${n}' which is not registered`)}this.plugins.set(t.name,t)}async install(t,n){const r=this.plugins.get(t);if(!r)throw new Error(`Plugin '${t}' is not registered`);if(this.installedPlugins.has(t))throw new Error(`Plugin '${t}' is already installed`);if(r.dependencies)for(const o of r.dependencies)this.installedPlugins.has(o)||await this.install(o);const i={...this.context,config:{...r.config,...n}};r.install&&await r.install(i),this.installedPlugins.add(t),this.setupPluginEvents(r,i)}async uninstall(t){var r;const n=this.plugins.get(t);if(!n)throw new Error(`Plugin '${t}' is not registered`);if(this.installedPlugins.has(t)){for(const[i,o]of this.plugins)if(this.installedPlugins.has(i)&&((r=o.dependencies)!=null&&r.includes(t)))throw new Error(`Cannot uninstall '${t}' because '${i}' depends on it`);n.uninstall&&await n.uninstall(this.context),this.installedPlugins.delete(t)}}isInstalled(t){return this.installedPlugins.has(t)}getInstalledPlugins(){return Array.from(this.installedPlugins)}getAvailablePlugins(){return Array.from(this.plugins.keys())}getPluginInfo(t){return this.plugins.get(t)}setupPluginEvents(t,n){t.onSessionStart&&n.on("session.started",r=>{t.onSessionStart(n,r.id)}),t.onSessionEnd&&n.on("session.ended",r=>{t.onSessionEnd(n,r.id)}),t.onAgentResponse&&n.on("agent.response",r=>{t.onAgentResponse(n,r)})}}function FM(e){return e}function Jl(e,t,n){return{name:e,version:"1.0.0",description:`${t} modality plugin`,install:async r=>{n.onActivate&&await n.onActivate(r)},uninstall:async r=>{n.onDeactivate&&await n.onDeactivate(r)},onAgentResponse:n.onMessage}}const jM={name:"analytics",version:"1.0.0",description:"Built-in analytics tracking",install:async e=>{console.log("Analytics plugin installed"),e.on("session.started",t=>{console.log("Analytics: Session started",t.id)}),e.on("session.ended",(t,n)=>{console.log("Analytics: Session ended",t.id,n)}),e.on("chat.message.sent",t=>{console.log("Analytics: User message sent",t.content.length)})}},BM={name:"debug",version:"1.0.0",description:"Debug logging and development tools",install:async e=>{console.log("Debug plugin installed");const t=e.emit;e.emit=(n,...r)=>(console.log(`[Debug] Event: ${String(n)}`,r),t(n,...r))}},$M={name:"metrics",version:"1.0.0",description:"Advanced metrics collection",install:async e=>{console.log("Metrics plugin installed");const t=new Map;e.on("session.started",n=>{t.set(n.id,{startTime:Date.now(),events:[]})}),e.on("agent.response",n=>{console.log("Metrics: Agent response analyzed",{type:n.type,length:n.content.length,timestamp:n.timestamp})})}},lg=A.createContext(null);function io({config:e,children:t,autoConnect:n=!1,client:r}){const[i,o]=A.useState(null),[s,a]=A.useState(!1),[l,c]=A.useState(!1),[u,d]=A.useState(null),[f,p]=A.useState(null),[g,m]=A.useState("idle"),[x,y]=A.useState(null),[k,E]=A.useState([]),[_,v]=A.useState([]),[C,M]=A.useState([]);A.useEffect(()=>{const D=r||new ki(e);o(D);const w=N(D);return n&&!r&&O(D),()=>{w(),r||D.disconnect().catch(console.error)}},[e,n,r]);const N=D=>{const w=()=>{c(!0),d(null)},j=()=>{a(!0),c(!1),d(null)},Y=()=>{a(!1),c(!1),p(null),m("idle"),E([]),v([]),M([])},S=K=>{d(K),c(!1)},H=K=>{p(K),m(K.state)},U=K=>{m(K),f&&p({...f,state:K})},Z=(K,Ee)=>{p(null),m("idle"),y(Ee),E([]),v([]),M([])},W=K=>{E(Ee=>[...Ee,K])},ue=K=>{E(Ee=>Ee.filter(le=>le.id!==K.id))},te=K=>{v(Ee=>[...Ee,K])},ae=K=>{v(Ee=>[...Ee,K])},Oe=K=>{console.log("๐ VoxketProvider: Received transcription:",K),M(Ee=>Ee.find(oe=>oe.id===K.id)?(console.log("๐ VoxketProvider: Duplicate transcription detected, skipping:",K.id),Ee):(console.log("๐ VoxketProvider: Adding new transcription:",K.id),[...Ee,K]))},L=()=>{console.log("๐งน VoxketProvider: Clearing chat messages and transcriptions"),v([]),M([])};return D.on("connection.connecting",w),D.on("connection.connected",j),D.on("connection.disconnected",Y),D.on("connection.error",S),D.on("session.created",H),D.on("session.state.changed",U),D.on("session.ended",Z),D.on("participant.joined",W),D.on("participant.left",ue),D.on("chat.message.received",te),D.on("chat.message.sent",ae),D.on("transcription.received",Oe),D.on("chat.history.cleared",L),()=>{console.log("๐ VoxketProvider: Cleaning up event listeners"),D.off("connection.connecting",w),D.off("connection.connected",j),D.off("connection.disconnected",Y),D.off("connection.error",S),D.off("session.created",H),D.off("session.state.changed",U),D.off("session.ended",Z),D.off("participant.joined",W),D.off("participant.left",ue),D.off("chat.message.received",te),D.off("chat.message.sent",ae),D.off("chat.history.cleared",L),D.off("transcription.received",Oe)}},O=async D=>{const w=D||i;if(w)try{await w.connect()}catch(j){console.error("Failed to connect:",j)}},$={client:i,isConnected:s,isConnecting:l,connectionError:u,currentSession:f,sessionState:g,sessionMetrics:x,participants:k,chatMessages:_,transcriptions:C,connect:()=>O(),disconnect:async()=>{if(i)try{await i.disconnect()}catch(D){console.error("Failed to disconnect:",D)}},createSession:async(D,w={})=>{if(!i)throw new Error("Client not initialized");const j={agentId:D,participantName:w.participantName||"User",metadata:w.metadata,modalities:w.modalities||["voice"]};return await i.createSession(j)},endSession:async()=>i?await i.endSession():null,sendChatMessage:async D=>{if(!i)throw new Error("Client not initialized");await i.sendChatMessage(D)},setMicrophoneEnabled:async D=>{if(!i)throw new Error("Client not initialized");await i.setMicrophoneEnabled(D)},setCameraEnabled:async D=>{if(!i)throw new Error("Client not initialized");await i.setCameraEnabled(D)},startScreenShare:async()=>{if(!i)throw new Error("Client not initialized");await i.startScreenShare()},stopScreenShare:async()=>{if(!i)throw new Error("Client not initialized");await i.stopScreenShare()}};return h.jsx(lg.Provider,{value:$,children:t})}function dn(){const e=A.useContext(lg);if(!e)throw new Error("useVoxket must be used within a VoxketProvider");return e}class VM extends Ql{constructor(n){super();rt(this,"room",null);rt(this,"registeredMethods",new Map);rt(this,"activeInteractions",new Map);rt(this,"currentInteraction",null);n&&this.setRoom(n)}setRoom(n){this.room=n}async registerFrontendRPC(n,r,i="embedded"){if(console.log(`RpcManager: Starting registration for method '${n}'`),!this.room)throw console.error(`RpcManager: Cannot register '${n}' - no room instance`),new Error("Room not initialized. Cannot register RPC method.");if(!this.room.localParticipant)throw console.error(`RpcManager: Cannot register '${n}' - no local participant`),new Error("Local participant not available for RPC registration");console.log(`RpcManager: Room state: ${this.room.state}`),console.log(`RpcManager: Local participant: ${this.room.localParticipant.identity}`),console.log(`RpcManager: Registering frontend RPC method: ${n}`);const o={methodName:n,component:r,presentationMode:i};this.registeredMethods.set(n,o);try{this.room.registerRpcMethod(n,async s=>{console.log(`RpcManager: RPC method '${n}' called by ${s.callerIdentity}`),console.log("RpcManager: Payload:",s.payload),this.emit("rpc.method.called",{methodName:n,data:s});let a;console.log(`RpcManager: Current registration for '${n}':`,o);let l=s.responseTimeout||30;try{a=JSON.parse(s.payload)}catch{a=s.payload}try{const c=await this.awaitUserInteraction(n,r,i,a,l);return JSON.stringify(c)}catch(c){throw console.error(`RpcManager: Error in RPC method '${n}':`,c),c}}),this.emit("rpc.method.registered",{methodName:n}),console.log(`RpcManager: Successfully registered RPC method: ${n}`)}catch(s){throw console.error(`RpcManager: Failed to register RPC method '${n}':`,s),s}}async awaitUserInteraction(n,r,i,o,s){return new Promise((a,l)=>{const c=`${n}_${Date.now()}`;console.log(`RpcManager: Starting user interaction for method: ${n}, timeout: ${s} seconds`);const u={didSuccess:(f,p)=>{console.log(`RpcManager: User interaction successful for method: ${n}`,f),this.clearInteraction(c),this.currentInteraction=null;const g={success:!0,message:"User interaction completed successfully",data:f,timestamp:new Date,...p?{successView:p}:{}};this.emit("rpc.interaction.completed",{methodName:n,response:g}),a(g)},didFail:f=>{console.log(`RpcManager: User interaction failed for method: ${n}`,f),this.clearInteraction(c);const p={success:!1,message:"User interaction failed",error:f,timestamp:new Date};this.emit("rpc.interaction.completed",{methodName:n,response:p}),a(p)},dismissView:()=>{var p;console.log(`RpcManager: User dismissed interaction for method: ${n}`),console.log("RpcManager: Current interaction before dismiss:",(p=this.currentInteraction)==null?void 0:p.methodName),this.clearInteraction(c),this.currentInteraction=null,console.log("RpcManager: Current interaction after dismiss:",this.currentInteraction);const f={success:!0,data:{dismissed:!0,reason:"User dismissed the interaction"},message:"User interaction dismissed",timestamp:new Date};this.emit("rpc.interaction.dismissed",{methodName:n,response:f}),this.emit("rpc.interaction.completed",{methodName:n,response:f}),setTimeout(()=>{var g;((g=this.currentInteraction)==null?void 0:g.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),a(f)},didTimeout:f=>{console.log(`RpcManager: User interaction timeout for method: ${n}`),this.clearInteraction(c),this.currentInteraction=null;const p={success:!0,message:`User interaction timed out after ${s} seconds, it should be considered as declined, agent don't need to retry`,timestamp:new Date,...f?{timeoutView:f}:{}};this.emit("rpc.interaction.timeout",{methodName:n,response:p}),setTimeout(()=>{var g;((g=this.currentInteraction)==null?void 0:g.methodName)===n&&(console.log(`RpcManager: Force clearing interaction for ${n}`),this.currentInteraction=null)},0),a(p)}},d=setTimeout(()=>{u.didTimeout&&u.didTimeout()},s);this.activeInteractions.set(c,{resolve:f=>a(JSON.parse(f)),reject:l,timeoutId:d}),this.currentInteraction={isVisible:!0,methodName:n,component:r,presentationMode:i,timeout:s,data:o,handler:u},this.emit("rpc.interaction.started",{methodName:n,presentationMode:i}),setTimeout(async()=>{var f;if((f=this.currentInteraction)!=null&&f.handler)try{console.log(`RpcManager: Component created for method: ${n} with data:`,o)}catch(p){console.error("RpcManager: Error loading data into component:",p),u.didFail({error:"Failed to load data into component"})}},100)})}clearInteraction(n){const r=this.activeInteractions.get(n);r&&(console.log(`RpcManager: Clearing interaction: ${n}`),clearTimeout(r.timeoutId),this.activeInteractions.delete(n))}getCurrentInteraction(){return this.currentInteraction}dismissCurrentInteraction(){var n;this.currentInteraction&&(console.log(`RpcManager: Dismissing current interaction: ${this.currentInteraction.methodName}`),(n=this.currentInteraction.handler)==null||n.dismissView(),setTimeout(()=>{this.currentInteraction&&(console.log("RpcManager: Force clearing lingering interaction"),this.currentInteraction=null)},0))}getRegisteredMethods(){return Array.from(this.registeredMethods.keys())}unregisterMethod(n){this.registeredMethods.delete(n),console.log(`RpcManager: Unregistered RPC method: ${n}`)}clear(){for(const[n,r]of this.activeInteractions)clearTimeout(r.timeoutId);this.activeInteractions.clear(),this.registeredMethods.clear(),this.currentInteraction=null,console.log("RpcManager: Cleared all registrations and interactions")}}class We extends Error{constructor(t,n,r){super(t),this.code=n,this.details=r,this.name="VoxketError"}}const Nn=new WeakSet,Ys=new WeakSet;class ki extends Ql{constructor(n){super();rt(this,"config");rt(this,"room",null);rt(this,"pluginManager");rt(this,"rpcManager");rt(this,"isConnected",!1);rt(this,"currentSession",null);rt(this,"connectionState",ce.ConnectionState.Disconnected);rt(this,"renderedComponents",new Map);rt(this,"textStreamHandlersRegistered",!1);rt(this,"currentAgentInfo",null);rt(this,"chatMessages",[]);rt(this,"activeTranscriptions",new Map);rt(this,"isAgentConnected",!1);rt(this,"agentState","idle");rt(this,"_eventEmitters",new Map);this.config=n,this.pluginManager=new ag(this),this.rpcManager=new VM,this.setupEventListeners(),this.initializeClient()}setupEventListeners(){this.on("connection.connected",()=>{var n,r;this.isConnected=!0,(r=(n=this.config).onConnected)==null||r.call(n)}),this.on("connection.disconnected",n=>{var r,i;this.isConnected=!1,(i=(r=this.config).onDisconnected)==null||i.call(r,n)}),this.on("connection.error",n=>{var r,i;(i=(r=this.config).onError)==null||i.call(r,n)}),this.on("chat.message.received",n=>{var r,i;this.addChatMessage(n),(i=(r=this.config).onMessageReceived)==null||i.call(r,n)}),this.on("chat.message.updated",n=>{this.updateChatMessage(n)}),this.on("chat.message.sent",n=>{this.addChatMessage(n)}),this.on("transcription.received",n=>{var r,i;(i=(r=this.config).onTranscriptionReceived)==null||i.call(r,n)}),this.on("session.state.changed",n=>{var r,i;(i=(r=this.config).onSessionStateChanged)==null||i.call(r,n)}),this.on("session.created",n=>{var r,i;(i=(r=this.config).onSessionStart)==null||i.call(r,n.id)}),this.on("session.ended",(n,r)=>{var i,o;(o=(i=this.config).onSessionEnd)==null||o.call(i,r)}),this.on("participant.joined",n=>{var r,i;(i=(r=this.config).onUserJoined)==null||i.call(r,n.id)}),this.on("participant.left",n=>{var r,i;(i=(r=this.config).onUserLeft)==null||i.call(r,n.id)}),this.setupRpcEventForwarding()}setupRpcEventForwarding(){if(!this.rpcManager){console.warn("RpcManager not initialized, skipping event forwarding setup");return}this.rpcManager.on("rpc.method.registered",n=>this.emit("rpc.method.registered",n)),this.rpcManager.on("rpc.method.called",n=>this.emit("rpc.method.called",n)),this.rpcManager.on("rpc.interaction.started",n=>this.emit("rpc.interaction.started",n)),this.rpcManager.on("rpc.interaction.completed",n=>this.emit("rpc.interaction.completed",n)),this.rpcManager.on("rpc.interaction.timeout",n=>this.emit("rpc.interaction.timeout",n)),this.rpcManager.on("rpc.interaction.dismissed",n=>this.emit("rpc.interaction.dismissed",n))}initializeClient(){this.room=new ce.Room,this.setupRoomEventListeners()}setupRoomEventListeners(){this.room&&(this.room.on(ce.RoomEvent.Connected,()=>{var n,r;this.connectionState=ce.ConnectionState.Connected,this.emit("connection.connected"),this.rpcManager.setRoom(this.room),(r=(n=this.currentSession)==null?void 0:n.activeModalities)!=null&&r.includes("voice")&&setTimeout(async()=>{var i;try{(i=this.room)!=null&&i.localParticipant&&(this.room.localParticipant.isMicrophoneEnabled?this.emit("track.unmuted",{source:"microphone",enabled:!0}):(await this.room.localParticipant.setMicrophoneEnabled(!0),this.emit("track.unmuted",{source:"microphone",enabled:!0})))}catch(o){console.warn("VoxketClient: Failed to enable microphone after room connection:",o)}},1e3),this.textStreamHandlersRegistered||this.setupTextStreamHandlers()}),this.room.on(ce.RoomEvent.Disconnected,n=>{var r;console.log("๐ด VoxketClient: Room disconnected, reason:",n),this.connectionState=ce.ConnectionState.Disconnected,this.textStreamHandlersRegistered=!1,this.isAgentConnected=!1,console.log("๐ค VoxketClient: Agent marked as disconnected"),this.clearChatMessages(),n&&console.log("๐ VoxketClient: Disconnect reason details:",{reason:n.toString(),currentSession:(r=this.currentSession)==null?void 0:r.id,agentConnected:this.isAgentConnected,connectionState:this.connectionState}),this.emit("connection.disconnected",n==null?void 0:n.toString())}),this.room.on(ce.RoomEvent.ConnectionStateChanged,n=>{this.connectionState=n,n===ce.ConnectionState.Connecting&&this.emit("connection.connecting")}),this.room.on(ce.RoomEvent.ParticipantConnected,n=>{const r={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.joined",r)}),this.room.on(ce.RoomEvent.ParticipantDisconnected,n=>{const r={id:n.identity,name:n.name||n.identity,isLocal:!1};this.emit("participant.left",r)}),this.room.on(ce.RoomEvent.LocalTrackPublished,n=>{console.log("๐ฌ VoxketClient: Local track published:",n.source),n.source===ce.Track.Source.ScreenShare&&this.emit("track.unmuted",{source:"screenShare",enabled:!0})}),this.room.on(ce.RoomEvent.LocalTrackUnpublished,n=>{console.log("๐ฌ VoxketClient: Local track unpublished:",n.source),n.source===ce.Track.Source.ScreenShare&&this.emit("track.muted",{source:"screenShare",enabled:!1})}))}setupTextStreamHandlers(){if(!this.room)return;try{this.room.registerTextStreamHandler("lk.chat",async(r,i)=>{try{const o=await r.readAll(),s={id:`msg_${Date.now()}_${i.identity||"user"}_${Math.random().toString(36).substr(2,9)}`,content:o,timestamp:new Date,sender:{id:i.identity||"user",name:i.identity||"User",type:"participant"},metadata:{topic:"lk.chat"}};this.emit("chat.message.received",s)}catch(o){console.error("VoxketClient: Failed to process lk.chat message:",o)}})}catch(r){console.warn("VoxketClient: lk.chat handler already registered, skipping:",r)}try{console.log("๐ VoxketClient: Registering lk.transcription handler..."),this.room.registerTextStreamHandler("lk.transcription",async(r,i)=>{var o,s,a,l,c,u;console.log("๐ VoxketClient: Received transcription stream from:",i.identity);try{console.log("๐ VoxketClient: Processing transcription stream...");const d=i.identity===((s=(o=this.room)==null?void 0:o.localParticipant)==null?void 0:s.identity),f=Date.now(),p=i.identity,g=this.activeTranscriptions.get(p);let m,x=!0;g&&f-g.timestamp<1e3?(m=g.messageId,x=!1,console.log("๐ VoxketClient: Reusing existing transcription message ID:",m)):(m=`msg_${d?"user":"agent"}_${i.identity}_${f}`,this.activeTranscriptions.set(p,{messageId:m,timestamp:f}),console.log("๐ VoxketClient: Created new transcription message ID:",m));let y="";console.log("๐ VoxketClient: Current agent info:",this.currentAgentInfo);const k=((a=this.currentAgentInfo)==null?void 0:a.name)||i.identity||"AI Assistant";console.log("๐ VoxketClient: Using agent name:",k);const E=d?"participant":"agent",_=d?this.config.participantName||"User":k;console.log("๐ VoxketClient: Transcription sender info:",{participantIdentity:i.identity,localParticipantIdentity:(c=(l=this.room)==null?void 0:l.localParticipant)==null?void 0:c.identity,isFromUser:d,senderType:E,senderName:_});const v={id:m,content:"",timestamp:new Date,sender:{id:i.identity||"unknown",name:_,type:E},metadata:{topic:"lk.transcription",streaming:!0}};x&&this.emit("chat.message.received",v),console.log("๐ VoxketClient: Starting to read transcription stream...");for await(const O of r){console.log("๐ VoxketClient: Received chunk:",O.length,"chars"),y+=O;const b=this.convertMarkdownToText(y),R={...v,content:b,metadata:{...v.metadata,streaming:!0}};this.emit("chat.message.updated",R)}const C=this.convertMarkdownToText(y),M={...v,content:C,metadata:{...v.metadata,streaming:!1}};this.emit("chat.message.updated",M);const N={id:m,text:C,isFinal:!0,startTime:v.timestamp.getTime(),participantId:i.identity||"agent"};this.emit("transcription.received",N),console.log("๐ VoxketClient: Emitted transcription event:",N)}catch(d){console.error("VoxketClient: Failed to process lk.transcription message:",d);try{const f=await r.readAll(),p=((u=this.currentAgentInfo)==null?void 0:u.name)||i.identity||"AI Assistant",g={id:`msg_${Date.now()}_agent_transcription_${Math.random().toString(36).substr(2,9)}`,content:f,timestamp:new Date,sender:{id:i.identity||"agent",name:p,type:"agent"},metadata:{topic:"lk.transcription"}};this.emit("chat.message.received",g);const m={id:g.id,text:g.content,isFinal:!0,startTime:g.timestamp.getTime(),participantId:i.identity||"agent"};this.emit("transcription.received",m),console.log("๐ VoxketClient: Emitted fallback transcription event:",m)}catch(f){console.error("VoxketClient: Fallback failed for lk.transcription:",f)}}})}catch(r){console.warn("VoxketClient: lk.transcription handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("suggested_response",async r=>{const i=await r.readAll();let o=[];try{o=["tes","hello how are you","algebra make me learn that ","what is the meaning of life"]}catch(s){console.warn("VoxketClient: Failed to parse suggested_response:",s,i)}this.emit("suggested.response",o)})}catch(r){console.warn("VoxketClient: suggested_response handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("agent_state_changed",async(r,i)=>{const o=await r.readAll();console.log("๐ค VoxketClient: agent_state_changed stream received:",o);let s={};try{s=typeof o=="string"?JSON.parse(o.replace(/'/g,'"')):o}catch(a){console.warn("VoxketClient: Failed to parse agent_state_changed:",a,o)}this.isAgentConnected||(this.isAgentConnected=!0,console.log("๐ค VoxketClient: Agent marked as connected (first state change received)"),this.emit("agent.connected",s)),s.new_state==="speaking"?(this.setAgentState("speaking"),this.emit("agent.speaking",s)):s.new_state==="thinking"?(this.setAgentState("thinking"),this.emit("agent.thinking",s)):(s.new_state==="idle"||s.new_state==="listening")&&this.setAgentState("idle")})}catch(r){console.warn("VoxketClient: conversation_item_added handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("function_tools_executed",async(r,i)=>{const o=await r.readAll();console.log("๐ ๏ธ VoxketClient: function_tool_executed stream received:",o);let s={};try{if(typeof o=="string")try{s=JSON.parse(o)}catch(a){let l=o;try{l=l.replace(/\bTrue\b/g,"true"),l=l.replace(/\bFalse\b/g,"false"),l=l.replace(/\bNone\b/g,"null");const c=l.replace(/\\"/g,"___ESCAPED_QUOTE___");let u="",d=!1,f=!1;for(let p=0;p<c.length;p++){const g=c[p],m=p>0?c[p-1]:"";g==='"'&&m!=="\\"?(d=!d,u+=g):g==="'"&&m!=="\\"&&!d?u+='"':u+=g}l=u.replace(/___ESCAPED_QUOTE___/g,'\\"'),s=JSON.parse(l)}catch(c){console.warn("VoxketClient: Enhanced parsing also failed, trying eval approach:",c);try{let u=o.replace(/\bTrue\b/g,"true").replace(/\bFalse\b/g,"false").replace(/\bNone\b/g,"null");s=new Function("return "+u)()}catch(u){throw console.error("VoxketClient: All parsing methods failed:",u),a}}}else s=o}catch(a){console.warn("VoxketClient: Failed to parse function_tool_executed:",a,o);let l=null;if(typeof o=="string"&&o.includes("visualization_data"))try{const c=o.match(/"arguments":\s*"({.*?})"/);if(c){const u=c[1].replace(/\\"/g,'"');l=JSON.parse(u),console.log("๐ ๏ธ VoxketClient: Extracted visualization data from failed parse:",l)}}catch(c){console.warn("VoxketClient: Failed to extract visualization data:",c)}s={type:"function_tools_executed",function_calls:[],function_call_outputs:[],created_at:Date.now()/1e3,parseError:!0,rawData:o,extractedVisualizationData:l}}this.emit("tool.executed",s)})}catch(r){console.warn("VoxketClient: function_tool_executed handler already registered, skipping:",r)}try{this.room.registerTextStreamHandler("images",async(r,i)=>{try{const o=await r.readAll()}catch(o){console.error("VoxketClient: Error processing images stream:",o)}})}catch(r){console.warn("VoxketClient: images handler already registered, skipping:",r)}try{this.room.registerByteStreamHandler("images",async(r,i)=>{var o,s;try{const a=r.info,l={id:`img_${Date.now()}_${i.identity||"agent"}_${Math.random().toString(36).substr(2,9)}`,content:`๏ฟฝ๏ธ ${a.name||"Image"}`,sender:{id:i.identity||"agent",name:i.identity||"Agent",type:i.identity===((s=(o=this.room)==null?void 0:o.localParticipant)==null?void 0:s.identity)?"participant":"agent"},timestamp:new Date,metadata:{type:"attachment",fileName:a.name,fileSize:a.size,mimeType:a.mimeType,streamId:a.id,downloading:!0}};this.emit("chat.message.received",l),r.onProgress&&(r.onProgress=p=>{const g={...l,metadata:{...l.metadata,downloadProgress:p||0}};this.emit("chat.message.updated",g)});const c=[];for await(const p of r)c.push(p);const u=new Blob(c,{type:a.mimeType||"application/octet-stream"}),d=URL.createObjectURL(u),f={...l,metadata:{...l.metadata,downloading:!1,downloadProgress:1,downloadUrl:d,blob:u}};this.emit("chat.message.updated",f)}catch(a){console.error("VoxketClient: Error processing image attachment:",a)}})}catch(r){console.warn("VoxketClient: image handler already registered, skipping:",r)}["error","warning","status","system","debug","info"].forEach(r=>{try{this.room.registerTextStreamHandler(r,async(i,o)=>{try{const s=await i.readAll();if(console.log(`๐ VoxketClient: Received '${r}' stream:`,s),r==="error"){let a={};try{a=typeof s=="string"?JSON.parse(s):s}catch{a={message:s}}console.warn("๏ฟฝ VoxketClient: Agent error:",a),this.emit("agent.error",a)}else this.emit("text.stream.received",{topic:r,data:s,participantInfo:o})}catch(s){console.error(`VoxketClient: Failed to process '${r}' stream:`,s)}})}catch(i){console.warn(`VoxketClient: Handler for '${r}' already registered, skipping:`,i)}});try{this.room.registerTextStreamHandler("*",async(r,i)=>{var o;try{const s=await r.readAll(),a=((o=r.info)==null?void 0:o.topic)||"unknown";if(this._eventEmitters.has(a)){const l=this._eventEmitters.get(a);try{l(s),console.log(`๐ VoxketClient: Processed custom topic '${a}' via event emitter`)}catch(c){console.error(`VoxketClient: Error in custom handler for topic '${a}':`,c)}}else console.log(`๐ VoxketClient: Received unhandled text stream for topic '${a}':`,s),this.emit("text.stream.unhandled",{topic:a,data:s,participantInfo:i})}catch(s){console.error("VoxketClient: Failed to process unhandled text stream:",s)}})}catch(r){console.warn("VoxketClient: Generic text stream handler already registered, skipping:",r)}this.textStreamHandlersRegistered=!0}async fetchConnectionDetails(n,r,i,o){const s=n||this.config.agentId||"default-agent",a=r||this.config.participantName||"User",l=i||this.config.modalities||["voice"],c=o||this.config.participantMetadata||{user_id:""};try{const u={agent_id:s,participant_name:a,participant_metadata:c,modality:l[0],modalities:l};console.log("๐ VoxketClient: Creating session with modalities:",l);const d=await fetch(`${this.config.baseUrl}/api/live/agent/session`,{method:"POST",headers:{accept:"application/json","X-APP-ID":this.config.appId,"X-APP-SECRET":this.config.appSecret,"Content-Type":"application/json"},body:JSON.stringify(u)});if(!d.ok){let g=`HTTP ${d.status}: Failed to fetch connection details`;try{const m=await d.json();m&&(m.error?g=`API Error: ${m.error}`:m.detail?g=`API Error: ${m.detail}`:m.message&&(g=`API Error: ${m.message}`))}catch{try{const x=await d.text();x&&(g=`API Error: ${x}`)}catch{}}throw new Error(g)}const f=await d.json();let p;return f.agent_info&&(p={id:f.agent_info.agent_info.id,name:f.agent_info.agent_info.name,capabilities:f.agent_info.capabilities,modality_supported:f.agent_info.modality_supported,session_settings:f.agent_info.session_settings||{}},this.currentAgentInfo=p),{serverUrl:f.wss_url,participantToken:f.token,voxketSessionId:f.session_id,agentInfo:p}}catch(u){console.error("VoxketClient: fetchConnectionDetails failed:",u);const d=new We(`Failed to fetch connection details: ${u instanceof Error?u.message:"Unknown error"}`,"CONNECTION_FAILED",u);throw this.emit("connection.error",d),d}}async connect(n,r,i,o){var s;try{this.emit("connection.connecting");const a=await this.fetchConnectionDetails(n,r,i,o);return await((s=this.room)==null?void 0:s.connect(a.serverUrl,a.participantToken)),this.isConnected=!0,a}catch(a){console.error("VoxketClient: Connection failed:",a);const l=new We(`Failed to connect to Voxket services: ${a instanceof Error?a.message:"Unknown error"}`,"CONNECTION_FAILED",a);throw this.emit("connection.error",l),l}}async disconnect(){var n;try{console.log("๐ VoxketClient: Starting disconnect process..."),this.room&&(console.log("๐ VoxketClient: Disconnecting from room:",{roomState:this.room.state,numParticipants:this.room.numParticipants,sessionId:(n=this.currentSession)==null?void 0:n.id}),await this.room.disconnect()),this.isConnected=!1,this.currentSession=null,this.currentAgentInfo=null,this.textStreamHandlersRegistered=!1,this.clearChatMessages(),console.log("๐ VoxketClient: Creating new room instance..."),this.room=new ce.Room,this.setupRoomEventListeners(),console.log("โ
VoxketClient: Disconnect completed successfully"),this.emit("connection.disconnected")}catch(r){console.error("โ VoxketClient: Disconnect failed:",r);const i=new We("Failed to disconnect properly","NETWORK_ERROR",r);throw this.emit("connection.error",i),i}}async createSession(n){var r,i,o,s;try{const a=await this.connect(n.agentId,n.participantName,n.modalities,n.participantMetadata),l={id:a.voxketSessionId,agentId:n.agentId,state:"connecting",startedAt:new Date,metadata:n.metadata||{},activeModalities:n.modalities||["voice"],agentInfo:a.agentInfo||this.currentAgentInfo};if(this.currentSession=l,this.emit("session.created",l),(r=n.modalities)!=null&&r.includes("voice"))try{await new Promise(c=>setTimeout(c,500)),(i=this.room)!=null&&i.localParticipant?(await this.room.localParticipant.setMicrophoneEnabled(!0,void 0,{preConnectBuffer:!0}),this.emit("track.unmuted",{source:"microphone",enabled:!0})):console.warn("VoxketClient: No local participant found, microphone not enabled")}catch(c){console.warn("VoxketClient: Failed to enable microphone, but continuing with session:",c)}if((o=n.modalities)!=null&&o.includes("video"))try{await new Promise(c=>setTimeout(c,200)),(s=this.room)!=null&&s.localParticipant&&(console.log("๐ฅ VoxketClient: Attempting to enable camera for video session"),await this.room.localParticipant.setCameraEnabled(!0),this.emit("track.unmuted",{source:"camera",enabled:!0}),console.log("๐ฅ VoxketClient: Camera enabled successfully"))}catch(c){console.warn("VoxketClient: Failed to enable camera, but continuing with session:",c)}return setTimeout(()=>{var c;this.currentSession&&(this.currentSession.state="active",this.emit("session.state.changed","active",this.currentSession.state),this.forceAgentConnected(),console.log("๐ค VoxketClient: Session marked as active:",{sessionId:this.currentSession.id,modalities:this.currentSession.activeModalities,agentConnected:this.isAgentConnected,hasRoom:!!this.room,remoteParticipants:((c=this.room)==null?void 0:c.remoteParticipants.size)||0}))},1e3),l}catch(a){throw console.error("VoxketClient: Failed to create session:",a),a instanceof We?a:a instanceof TypeError&&a.message.includes("fetch")?new We("Network connection failed","CONNECTION_FAILED",a):a instanceof Error&&a.message.includes("Failed to fetch connection details")?new We(`API connection failed: ${a.message}`,"CONNECTION_FAILED",a):new We(`Failed to create session: ${a instanceof Error?a.message:"Unknown error"}`,"SESSION_NOT_FOUND",a)}}async startSession(n,r){const i={agentId:n||this.config.agentId||"default-agent",participantName:(r==null?void 0:r.participantName)||this.config.participantName||"User",modalities:(r==null?void 0:r.modalities)||this.config.modalities||["voice","chat"],metadata:r==null?void 0:r.metadata,participantMetadata:r==null?void 0:r.participantMetadata};return this.createSession(i)}async endSession(){var n,r;if(!this.currentSession)return null;try{const i={sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((r=this.room)==null?void 0:r.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]};return this.currentSession.endedAt=new Date,this.currentSession.state="disconnected",this.emit("session.ended",this.currentSession,i),await this.disconnect(),i}catch(i){throw new We("Failed to end session","SESSION_NOT_FOUND",i)}}getCurrentSession(){return this.currentSession}getCurrentAgentInfo(){return this.currentAgentInfo}getIsAgentConnected(){return this.isAgentConnected}forceAgentConnected(){this.isAgentConnected||(this.isAgentConnected=!0,console.log("๐ค VoxketClient: Agent manually marked as connected"),this.emit("agent.connected",{forced:!0}))}getAgentState(){return this.agentState}setAgentState(n){this.agentState!==n&&(this.agentState=n,this.emit("agent.state.changed",{state:n}))}getAgentAudioTrack(){const n=this.getRemoteParticipants();for(const r of n){const i=r.getTrackPublication(ce.Track.Source.Microphone);if(i!=null&&i.track)return{source:ce.Track.Source.Microphone,participant:r,publication:i}}return null}getAgentVideoTrack(){const n=this.getRemoteParticipants();for(const r of n){const i=r.getTrackPublication(ce.Track.Source.Camera);if(i!=null&&i.track)return{source:ce.Track.Source.Camera,participant:r,publication:i}}return null}getVideoTrackRefs(){const n=[],r=this.getLocalParticipant();if(r){const o=r.getTrackPublication(ce.Track.Source.Camera);o!=null&&o.track&&n.push({source:ce.Track.Source.Camera,participant:r,publication:o});const s=r.getTrackPublication(ce.Track.Source.ScreenShare);s!=null&&s.track&&n.push({source:ce.Track.Source.ScreenShare,participant:r,publication:s})}const i=this.getRemoteParticipants();for(const o of i){const s=o.getTrackPublication(ce.Track.Source.Camera);s!=null&&s.track&&n.push({source:ce.Track.Source.Camera,participant:o,publication:s});const a=o.getTrackPublication(ce.Track.Source.ScreenShare);a!=null&&a.track&&n.push({source:ce.Track.Source.ScreenShare,participant:o,publication:a})}return n}getCameraTrackRefs(){return this.getVideoTrackRefs().filter(n=>n.source===ce.Track.Source.Camera)}getScreenShareTrackRefs(){return this.getVideoTrackRefs().filter(n=>n.source===ce.Track.Source.ScreenShare)}getChatMessages(){return[...this.chatMessages]}addChatMessage(n){this.chatMessages.some(i=>i.id===n.id)||this.chatMessages.push(n)}updateChatMessage(n){const r=this.chatMessages.findIndex(i=>i.id===n.id);r!==-1&&(this.chatMessages[r]=n)}clearChatMessages(){this.chatMessages=[],this.activeTranscriptions.clear(),this.dismissCurrentInteraction(),this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays(),console.log("๐งน VoxketClient: Cleared chat messages and transcription history"),this.emit("chat.history.cleared")}renderUI(n={}){var s,a,l,c,u,d,f,p,g;const r=this.resolveTarget(n.target||"body"),i=this.getTargetKey(r);if(Ys.has(r)){console.warn("โ ๏ธ VoxketClient: Target is already being processed, skipping renderUI");return}if(Nn.has(r)){console.log("โ VoxketClient: Target already has a React root in registry, updating existing props...");const m=this.renderedComponents.get(i);if(m&&m.root){const x={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((s=n.modality)==null?void 0:s.includes("chat"))!==!1,suportsVideoInput:((a=n.modality)==null?void 0:a.includes("video"))===!0,suportsScreenShare:((l=n.modality)==null?void 0:l.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this,participantMetadata:n.participantMetadata};try{m.root.render(A.createElement(io,{config:this.config,autoConnect:n.autoStart||!1,client:this,children:A.createElement(oo,x)})),console.log("โ
VoxketClient: Successfully updated existing widget with new props");return}catch(y){throw console.error("Error re-rendering existing widget:",y),new Error(`Failed to update existing widget: ${y instanceof Error?y.message:"Unknown error"}`)}}else console.warn("โ ๏ธ Registry inconsistency detected, cleaning up"),Nn.delete(r)}let o=this.renderedComponents.get(i);if(o&&o.target===r&&Nn.has(r)){console.log("๐ VoxketClient: Reusing existing React root for target:",i);const m=o.root,x={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((c=n.modality)==null?void 0:c.includes("chat"))!==!1,suportsVideoInput:((u=n.modality)==null?void 0:u.includes("video"))===!0,suportsScreenShare:((d=n.modality)==null?void 0:d.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this,participantMetadata:n.participantMetadata};try{m.render(A.createElement(io,{config:this.config,autoConnect:n.autoStart||!1,client:this,children:A.createElement(oo,x)}))}catch(y){throw console.error("Error rendering Voxket widget:",y),new Error(`Failed to render Voxket widget: ${y instanceof Error?y.message:"Unknown error"}`)}return}Ys.add(r);try{if(o){console.log("๐งน VoxketClient: Cleaning up existing component for different target");try{o.root.unmount(),this.renderedComponents.delete(i),Nn.delete(o.target),r.innerHTML=""}catch(y){console.warn("Failed to cleanup existing root:",y)}}if(Nn.has(r)){console.warn("โ ๏ธ VoxketClient: Target already in registry, skipping root creation");return}console.log("๐ VoxketClient: Creating new React root for target:",i);const m=Wg.createRoot(r);this.renderedComponents.set(i,{root:m,target:r}),Nn.add(r);const x={agentId:n.agentId||this.config.agentId||"default-agent",participantName:n.participantName||this.config.participantName||"User",baseUrl:this.config.baseUrl,appSecret:this.config.appSecret,appId:this.config.appId,className:n.className,theme:typeof n.theme=="string"?n.theme:void 0,modalities:n.modality||this.config.modalities||["voice"],suportsChatInput:((f=n.modality)==null?void 0:f.includes("chat"))!==!1,suportsVideoInput:((p=n.modality)==null?void 0:p.includes("video"))===!0,suportsScreenShare:((g=n.modality)==null?void 0:g.includes("screen_share"))===!0,autoStart:n.autoStart,displayType:n.displayType||"widget",popupPosition:n.popupPosition||"bottom-right",popupTriggerText:n.popupTriggerText||"Open Chat",width:n.width,height:n.height,onDisplayTypeChange:n.onDisplayTypeChange,prompts:n.prompts,statusMessage:n.statusMessage,welcomeTitle:n.welcomeTitle,welcomeSubTitle:n.welcomeSubTitle,loadingText:n.loadingText,voxketClient:this,participantMetadata:n.participantMetadata};if(!m||typeof m.render!="function")throw new Error("Invalid React root. Make sure React 18+ is properly installed and configured.");try{m.render(A.createElement(io,{config:this.config,autoConnect:n.autoStart||!1,client:this,children:A.createElement(oo,x)}))}catch(y){throw console.error("Error rendering Voxket widget:",y),new Error(`Failed to render Voxket widget: ${y instanceof Error?y.message:"Unknown error"}`)}}finally{Ys.delete(r)}}removeUI(n){var i;const r=n?this.resolveTarget(n):null;if(r){const o=this.getTargetKey(r),s=this.renderedComponents.get(o);if(s){console.log("๐๏ธ VoxketClient: Removing UI for target:",o),this.renderedComponents.delete(o),Nn.delete(r);try{const l=s.target;l&&l.isConnected?(typeof((i=s.root)==null?void 0:i.unmount)=="function"&&(s.root.unmount(),console.log("โ
VoxketClient: UI unmounted for target:",o)),l.hasChildNodes()&&(l.innerHTML="")):console.log("โน๏ธ VoxketClient: Target element already disconnected, skipping unmount")}catch(l){console.warn("Failed to unmount React root:",l)}}else console.log("โน๏ธ VoxketClient: No component found for target, cleaning registry:",o),Nn.delete(r),r.isConnected&&r.hasChildNodes()&&(r.innerHTML="");r.querySelectorAll('[id*="voxket"], [class*="voxket"], .fixed.inset-0.z-50').forEach(l=>{try{l.remove()}catch(c){console.warn("Failed to remove element:",c)}}),r===document.body&&r.querySelectorAll(".fixed.z-50, .fixed.inset-0").forEach(c=>{if(c.classList.contains("bg-black")&&(c.classList.contains("backdrop-blur-sm")||c.classList.contains("bg-opacity-30")))try{c.remove()}catch(u){console.warn("Failed to remove fixed element:",u)}})}}removeAllUI(){for(const[n,r]of this.renderedComponents)r.root.unmount();this.renderedComponents.clear(),this.forceCleanupFullscreenOverlays()}forceCleanupFullscreenOverlays(){document.body.querySelectorAll(".fixed.inset-0.z-50").forEach(r=>{if(r.classList.contains("bg-black")&&(r.classList.contains("backdrop-blur-sm")||r.classList.contains("bg-opacity-30")))try{r.remove()}catch(i){console.warn("Failed to remove overlay:",i)}})}resolveTarget(n){if(typeof n=="string"){const r=document.querySelector(n);if(!r)throw new Error(`Target element not found: ${n}`);return r}return n}getTargetKey(n){return n.id?n.id:n.className?n.tagName+"_"+n.className.replace(/\s+/g,"_"):n.tagName+"_"+n.outerHTML.length%1e3}async sendMessage(n,r){var i;if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new We("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new We("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new We("No local participant","CONNECTION_FAILED");this.dismissCurrentInteraction();try{const o={id:`msg_${Date.now()}`,content:n,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:r||{}},s=await((i=this.room)==null?void 0:i.localParticipant.sendText(n,{topic:"lk.chat",destinationIdentities:[]}));this.emit("chat.message.sent",o)}catch(o){throw console.error("VoxketClient: Failed to send chat message:",o),new We("Failed to send message","NETWORK_ERROR",o)}}async sendChatMessage(n,r){return this.sendMessage(n,r)}async sendAttachments(n,r){if(!this.currentSession)throw console.error("VoxketClient: No active session found"),new We("No active session","SESSION_NOT_FOUND");if(!this.room)throw console.error("VoxketClient: No room instance found"),new We("No room connection","CONNECTION_FAILED");if(!this.room.localParticipant)throw console.error("VoxketClient: No local participant found"),new We("No local participant","CONNECTION_FAILED");if(!n||n.length===0)throw new We("No files provided","INVALID_PARAMETER");this.dismissCurrentInteraction();const i=n.filter(o=>o.type.startsWith("image/"));if(i.length===0)throw new We("Only image files are allowed","INVALID_PARAMETER");i.length!==n.length&&console.warn("VoxketClient: Some non-image files were filtered out");try{const o=i.map(async(s,a)=>{const c={id:`att_${Date.now()}_${a}`,content:`๐ ${s.name}`,sender:{id:"user",name:this.config.participantName||"User",type:"participant"},timestamp:new Date,metadata:{...r,type:"attachment",fileName:s.name,fileSize:s.size,mimeType:s.type,uploading:!0}};this.emit("chat.message.sent",c);const u=await this.room.localParticipant.sendFile(s,{mimeType:s.type,topic:"images",onProgress:f=>{const p={...c,metadata:{...c.metadata,uploadProgress:f}};this.emit("chat.message.updated",p)}});try{const f=new FileReader,p=new Promise((x,y)=>{f.onload=()=>{typeof f.result=="string"?x(f.result):y(new Error("Failed to convert to base64"))},f.onerror=y});f.readAsDataURL(s);const m={type:"image",data:await p,filename:s.name,mimeType:s.type,size:s.size};await this.room.localParticipant.sendText(JSON.stringify(m),{topic:"images",destinationIdentities:[]})}catch(f){console.warn("VoxketClient: Failed to send image data to agent:",f);try{const p=`I've shared an image: ${s.name}`;await this.room.localParticipant.sendText(p,{topic:"lk.chat",destinationIdentities:[]})}catch(p){console.warn("VoxketClient: Failed to send image notification to agent:",p)}}const d={...c,metadata:{...c.metadata,uploading:!1,uploadProgress:1,streamId:u.id}};return this.emit("chat.message.updated",d),u});await Promise.all(o)}catch(o){throw console.error("VoxketClient: Failed to send attachments:",o),new We("Failed to send attachments","NETWORK_ERROR",o)}}async sendAttachment(n,r){return this.sendAttachments([n],r)}toggleMicrophone(n){return this.setMicrophoneEnabled(n!==!1)}async setMicrophoneEnabled(n){var r,i;try{const o=(r=this.room)==null?void 0:r.localParticipant.isMicrophoneEnabled,s=n??!o;await((i=this.room)==null?void 0:i.localParticipant.setMicrophoneEnabled(s)),s?this.emit("track.unmuted",{source:"microphone",enabled:!0}):this.emit("track.muted",{source:"microphone",enabled:!1})}catch(o){throw console.error("VoxketClient: Failed to toggle microphone:",o),new We("Failed to toggle microphone","PERMISSION_DENIED",o)}}toggleCamera(n){return this.setCameraEnabled(n!==!1)}async setCameraEnabled(n){var r,i;try{const o=(r=this.room)==null?void 0:r.localParticipant.isCameraEnabled,s=n??!o;await((i=this.room)==null?void 0:i.localParticipant.setCameraEnabled(s)),s?this.emit("track.unmuted",{source:"camera",enabled:!0}):this.emit("track.muted",{source:"camera",enabled:!1})}catch(o){throw console.error("VoxketClient: Failed to toggle camera:",o),new We("Failed to toggle camera","PERMISSION_DENIED",o)}}async enableCamera(){return this.setCameraEnabled(!0)}async disableCamera(){return this.setCameraEnabled(!1)}async startScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!0)),this.emit("track.unmuted",{source:"screenShare",enabled:!0})}catch(r){throw new We("Failed to start screen share","PERMISSION_DENIED",r)}}async stopScreenShare(){var n;try{await((n=this.room)==null?void 0:n.localParticipant.setScreenShareEnabled(!1)),this.emit("track.muted",{source:"screenShare",enabled:!1})}catch(r){throw new We("Failed to stop screen share","PERMISSION_DENIED",r)}}async getAudioInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="audioinput")}catch(n){throw new We("Failed to get audio input devices","DEVICE_ERROR",n)}}async getVideoInputDevices(){try{return(await navigator.mediaDevices.enumerateDevices()).filter(r=>r.kind==="videoinput")}catch(n){throw new We("Failed to get video input devices","DEVICE_ERROR",n)}}async setAudioInputDevice(n){var r;try{if(!((r=this.room)!=null&&r.localParticipant))throw new Error("Not connected to room")}catch(i){throw new We("Failed to set audio input device","DEVICE_ERROR",i)}}async setVideoInputDevice(n){var r;try{if(!((r=this.room)!=null&&r.localParticipant))throw new Error("Not connected to room")}catch(i){throw new We("Failed to set video input device","DEVICE_ERROR",i)}}getLocalParticipant(){var n;return((n=this.room)==null?void 0:n.localParticipant)??null}getRemoteParticipants(){var n;return Array.from(((n=this.room)==null?void 0:n.remoteParticipants.values())??[])}getPublishPermissions(){const n=this.getLocalParticipant();if(!n)return{camera:!1,microphone:!1,screenShare:!1,data:!1};const r=n.permissions;if(!r)return{camera:!0,microphone:!0,screenShare:!0,data:!0};const i=o=>!!r.canPublish&&(r.canPublishSources.length===0||r.canPublishSources.includes(o));return{camera:i(1),microphone:i(2),screenShare:i(3),data:r.canPublishData??!1}}canPublishSource(n){return this.getPublishPermissions()[n]}getRoom(){return this.room}getConnectionState(){return this.connectionState}get connected(){return this.isConnected&&this.connectionState===ce.ConnectionState.Connected}getMicrophoneTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,r]of n.trackPublications)if(r.source===ce.Track.Source.Microphone)return r.track;return null}getCameraTrack(){const n=this.getLocalParticipant();if(!n)return null;for(const[,r]of n.trackPublications)if(r.source===ce.Track.Source.Camera)return r.track;return null}getScreenShareTrack(){const n=this.getLocalParticipant();if(!n)return console.log("๐ฌ VoxketClient: getScreenShareTrack - no local participant"),null;for(const[,r]of n.trackPublications)if(r.source===ce.Track.Source.ScreenShare)return console.log("๐ฌ VoxketClient: getScreenShareTrack - found screen share track:",{trackSid:r.trackSid,isMuted:r.isMuted,hasTrack:!!r.track}),r.track;return console.log("๐ฌ VoxketClient: getScreenShareTrack - no screen share track found"),null}get isMicrophoneEnabled(){const n=this.getMicrophoneTrack();return n?!n.isMuted:!1}get isCameraEnabled(){const n=this.getCameraTrack();return n?!n.isMuted:!1}get isScreenShareEnabled(){const n=this.getScreenShareTrack(),r=n?!n.isMuted:!1;return console.log("๐ฌ VoxketClient: isScreenShareEnabled check:",{hasTrack:!!n,trackMuted:n==null?void 0:n.isMuted,enabled:r}),r}registerPlugin(n){this.pluginManager.register(n)}getPluginManager(){return this.pluginManager}getParticipants(){if(!this.room)return[];const n=[];return this.room.localParticipant&&n.push({id:this.room.localParticipant.identity,name:this.room.localParticipant.name||this.room.localParticipant.identity,isLocal:!0}),this.room.remoteParticipants.forEach(r=>{n.push({id:r.identity,name:r.name||r.identity,isLocal:!1})}),n}getSessionMetrics(){var n,r;return this.currentSession?{sessionId:this.currentSession.id,duration:Date.now()-(((n=this.currentSession.startedAt)==null?void 0:n.getTime())||0),messageCount:0,participantCount:((r=this.room)==null?void 0:r.remoteParticipants.size)||0,audioQuality:{avgBitrate:64e3,avgLatency:150,packetLoss:.01,jitter:.05},videoQuality:{avgBitrate:5e5,avgLatency:150,packetLoss:.01,jitter:.05},networkStats:{totalBytesReceived:0,totalBytesSent:0,connectionType:"webrtc",avgRoundTripTime:150},events:[]}:null}updateConfig(n){this.config={...this.config,...n}}async startRecording(){var n;try{this.emit("recording.started",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(r){throw new We("Failed to start recording","RECORDING_ERROR",r)}}async stopRecording(){var n;try{this.emit("recording.stopped",{sessionId:(n=this.currentSession)==null?void 0:n.id,timestamp:new Date})}catch(r){throw new We("Failed to stop recording","RECORDING_ERROR",r)}}async registerFrontendRPC(n,r,i="embedded"){return this.rpcManager.registerFrontendRPC(n,r,i)}getCurrentInteraction(){return this.rpcManager.getCurrentInteraction()}dismissCurrentInteraction(){this.rpcManager.dismissCurrentInteraction()}getRegisteredRpcMethods(){return this.rpcManager.getRegisteredMethods()}unregisterRpcMethod(n){this.rpcManager.unregisterMethod(n)}setParticipantMetadata(n){this.config.participantMetadata=n}getParticipantMetadata(){return this.config.participantMetadata}registerEventListener(n,r){return this.on(n,r)}registerEventEmitter(n,r){if(!this.room)throw new Error("Room not available");this._eventEmitters.set(n,r),console.log(`๐ VoxketClient: Stored handler for topic '${n}' in event emitters map`);try{this.room.registerTextStreamHandler(n,async i=>{try{const o=await i.readAll();console.log(`๐ VoxketClient: Direct handler called for topic '${n}'`),r(o)}catch(o){console.error(`Error processing event for topic '${n}':`,o)}}),console.log(`๐ VoxketClient: Successfully registered direct handler for topic '${n}'`)}catch(i){console.warn(`VoxketClient: Direct handler registration failed for topic '${n}':`,i),console.log(`๐ VoxketClient: Wildcard handler will process topic '${n}' instead`)}}getRegisteredEventEmitters(){return Array.from(this._eventEmitters.keys())}hasEventEmitter(n){return this._eventEmitters.has(n)}convertMarkdownToText(n){if(!n)return"";let r=n;return r=r.replace(/\*\*(.*?)\*\*/g,"$1"),r=r.replace(/__(.*?)__/g,"$1"),r=r.replace(/\*(.*?)\*/g,"$1"),r=r.replace(/_(.*?)_/g,"$1"),r=r.replace(/~~(.*?)~~/g,"$1"),r=r.replace(/`([^`]+)`/g,"$1"),r=r.replace(/```[\s\S]*?```/g,""),r=r.replace(/^#{1,6}\s+/gm,""),r=r.replace(/\[([^\]]+)\]\([^)]+\)/g,"$1"),r.trim()}}const zM=Ae.create(Fm),UM=Ae.create(Vl),HM=Ae.create(nA),WM=Ae.create(ig);function GM({theme:e,mode:t,loadingText:n}){const r=Ct(e),i=()=>{switch(t){case"voice":return n||"Connecting to voice agent...";case"chat":return n||"Starting chat session...";case"video":return n||"Connecting to video call...";default:return n||"Connecting..."}};return h.jsxs("div",{className:"flex flex-col items-center justify-center h-full w-full p-8",children:[h.jsxs("div",{className:"text-center",children:[h.jsx("h3",{className:`text-lg font-semibold mb-2 ${r.text.accent}`,children:i()}),h.jsx("p",{className:`text-sm ${r.text.muted}`,children:"Please wait a moment..."})]}),h.jsxs("div",{className:"flex space-x-1 mt-4",children:[h.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"0ms"}}),h.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"150ms"}}),h.jsx("div",{className:"w-2 h-2 rounded-full animate-bounce bg-blue-500",style:{animationDelay:"300ms"}})]})]})}const KM=Ae.create(GM);function bf({children:e,theme:t,displayType:n="widget",onClose:r,popupPosition:i="bottom-right",onExpand:o}){const s=Ct(t);if(n==="fullscreen")return h.jsx("div",{className:"fixed inset-0 z-[9999] bg-black/40 bg-opacity-30 backdrop-blur-sm flex items-center justify-center p-8",onClick:a=>{a.target===a.currentTarget&&r&&r()},children:h.jsxs("div",{className:"w-full h-full max-w-7xl max-h-[95vh] rounded-2xl relative bg-transparent flex flex-col",onClick:a=>{a.stopPropagation()},children:[r&&h.jsx("button",{onClick:a=>{a.preventDefault(),a.stopPropagation(),r()},className:"absolute top-4 cursor-pointer right-4 z-[10000] w-12 h-12 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 shadow-lg border border-gray-700 backdrop-blur-sm",title:"Exit Fullscreen",type:"button",children:h.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),h.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${s.card} w-full h-full flex flex-col rounded-xl shadow-2xl relative overflow-hidden`,"data-theme":t,style:{minHeight:"600px",height:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[h.jsx("div",{className:s.cardTopGradient}),h.jsx("div",{className:s.cardPurpleBlur}),h.jsx("div",{className:s.cardPinkBlur}),h.jsx("div",{className:"relative z-10 flex flex-col h-full",children:e}),h.jsx("div",{className:s.cardPulse1}),h.jsx("div",{className:s.cardPulse2,style:{animationDelay:"1s"}})]})]})});if(n==="popup"){const a={"top-left":"top-4 left-4","top-right":"top-4 right-4","bottom-left":"bottom-4 left-4","bottom-right":"bottom-4 right-4"};return h.jsx("div",{className:"fixed rounded-2xl inset-0 z-[9999] pointer-events-none",children:h.jsxs("div",{className:`fixed rounded-2xl ${a[i]} pointer-events-auto`,children:[r&&h.jsx("button",{onClick:r,className:"absolute -top-2 -right-2 z-10 w-8 h-8 rounded-full bg-gray-900 bg-opacity-90 text-white flex items-center justify-center hover:bg-gray-800 transition-all duration-200 text-sm shadow-lg border border-gray-700",children:"ร"}),h.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${s.card} rounded-2xl flex flex-col relative overflow-hidden`,"data-theme":t,style:{width:"350px",height:"500px",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[h.jsx("div",{className:s.cardTopGradient}),h.jsx("div",{className:s.cardPurpleBlur}),h.jsx("div",{className:s.cardPinkBlur}),h.jsx("div",{className:"relative z-10 flex flex-col h-full w-full",children:e}),h.jsx("div",{className:s.cardPulse1}),h.jsx("div",{className:s.cardPulse2,style:{animationDelay:"1s"}})]})]})})}return h.jsxs("div",{id:"voice-card",className:`voxket-widget-root theme-${t} ${s.card} relative overflow-hidden w-full h-full`,"data-theme":t,style:{height:"100%",maxHeight:"100%",contain:"layout style paint",overscrollBehavior:"contain",backgroundColor:t==="midnight"?"#161a25":void 0},children:[h.jsx("div",{className:s.cardTopGradient}),h.jsx("div",{className:s.cardPurpleBlur}),h.jsx("div",{className:s.cardPinkBlur}),h.jsx("div",{className:"relative z-10 flex flex-col h-full w-full",children:e}),h.jsx("div",{className:s.cardPulse1}),h.jsx("div",{className:s.cardPulse2,style:{animationDelay:"1s"}})]})}function qM(e){if(typeof window>"u")return null;const{agentId:t,participantName:n,baseUrl:r,appSecret:i,appId:o,prompts:s,statusMessage:a,welcomeTitle:l,welcomeSubTitle:c,className:u,width:d,height:f,loadingText:p,suportsChatInput:g=!0,suportsVideoInput:m=!0,suportsScreenShare:x=!0,theme:y="vox",onSessionStart:k,onSessionEnd:E,enableSessionLogging:_=!0,onSessionLogsUpdate:v,onSessionMetricsUpdate:C,modalities:M=["voice"],displayType:N="widget",popupPosition:O="bottom-right",popupTriggerText:b="Open Chat",onPopupToggle:R,voxketClient:I,onDisplayTypeChange:B,participantMetadata:F}=e,[q,ne]=P.useState(!1),[ee,$]=P.useState(null),[D,w]=P.useState(()=>{try{if(I)return!!I.getCurrentSession()}catch(re){console.error("Error checking existing session:",re)}return!1}),[j,Y]=P.useState(!1),[S,H]=P.useState(t||""),[U,Z]=P.useState(n||"User"),[W,ue]=P.useState(()=>{try{if(I)return I.getCurrentSession()}catch(re){console.error("Error getting current session:",re)}return null}),[te,ae]=P.useState(()=>{var re,Fe,qe;try{if(I){const Ye=I.getCurrentSession();if((re=Ye==null?void 0:Ye.activeModalities)!=null&&re.includes("chat"))return"chat";if((Fe=Ye==null?void 0:Ye.activeModalities)!=null&&Fe.includes("voice"))return"voice";if((qe=Ye==null?void 0:Ye.activeModalities)!=null&&qe.includes("video"))return"video"}}catch(Ye){console.error("Error determining current mode:",Ye)}return"welcome"}),[Oe,L]=P.useState(!1);P.useEffect(()=>{N==="fullscreen"&&console.log("๐ฏ Widget: Switched to fullscreen mode")},[N]),P.useEffect(()=>{D&&!j?console.log("๐ Session started:",{currentMode:te,sessionId:W==null?void 0:W.id}):!D&&!j&&te==="welcome"&&console.log("๐ Returned to welcome screen")},[D,te,j]);const K=P.useMemo(()=>{try{if(I)return console.log("๐ Using existing VoxketClient to preserve session state"),I;if(!o||!i||!r){const Fe=`Missing required props: ${o?"":"appId "}${i?"":"appSecret "}${r?"":"baseUrl"}`;return console.error("โ VoxketClient creation failed:",Fe),$(new Error(Fe)),ne(!0),null}const re={appId:o,appSecret:i,baseUrl:r,agentId:S,participantName:U||"User",modalities:M,participantMetadata:F};return console.log("๐ง Creating new VoxketClient with config:",{appId:o.substring(0,8)+"...",baseUrl:r,agentId:S,participantName:U||"User",modalities:M}),new ki(re)}catch(re){return console.error("โ Failed to create VoxketClient:",re),$(re),ne(!0),null}},[I,o,i,r,S,U,M]),Ee=M,le=P.useMemo(()=>{try{if(!K)return console.warn("โ ๏ธ No VoxketClient available, creating fallback room"),new ce.Room;const re=K.getRoom();return console.log("๐ Widget: Room reference updated:",{roomExists:!!re,roomState:re==null?void 0:re.state,sessionStarted:D,currentMode:te}),re||new ce.Room}catch(re){return console.error("โ Error getting room from client:",re),new ce.Room}},[K,D,te]);P.useEffect(()=>{if(le){const re=()=>{console.log("๐ Widget: Room state changed:",{state:le.state,numParticipants:le.numParticipants,isConnected:le.state==="connected",sessionId:W==null?void 0:W.id})},Fe=(qe,Ye,kt)=>{console.log("๐ต Widget: Track subscribed:",{trackKind:qe.kind,trackSource:qe.source,participantSid:kt.sid,participantIdentity:kt.identity,sessionId:W==null?void 0:W.id})};return le.on(ce.RoomEvent.Connected,re),le.on(ce.RoomEvent.Disconnected,re),le.on(ce.RoomEvent.TrackSubscribed,Fe),()=>{le.off(ce.RoomEvent.Connected,re),le.off(ce.RoomEvent.Disconnected,re),le.off(ce.RoomEvent.TrackSubscribed,Fe)}}},[le,W==null?void 0:W.id]),P.useEffect(()=>{!j&&te==="welcome"?console.log("๐ฌ Widget: Welcome screen ready"):D&&te!=="welcome"&&console.log("๐ฌ Widget: Session mode active:",te)},[te,j,D]),P.useEffect(()=>{(te==="voice"||te==="video"||te==="chat")&&!W&&!D&&!j&&K&&!K.connected&&(console.log("๐ Auto-correcting: Found orphaned mode without session, returning to welcome"),ae("welcome"),Y(!1))},[te,W,D,j,K]);const{sessionMetrics:oe,sessionLogs:ye,logEvent:ve}=sg({room:le,onSessionStart:k,onSessionEnd:E,enableConsoleLogging:_,enableLocalStorage:_,voxketSessionId:W==null?void 0:W.id});P.useEffect(()=>{v&&v(ye)},[ye,v]),P.useEffect(()=>{C&&oe&&C(oe)},[oe,C]),P.useEffect(()=>{if(!K)return;const re=()=>{const Fe=K.connected,qe=K.getCurrentSession();console.log("๐ Connection state changed:",{isConnected:Fe,currentSessionId:qe==null?void 0:qe.id,currentMode:te,loading:j,sessionStarted:D}),!Fe&&D&&!j&&(console.log("๐ด Connection lost during active session - returning to welcome"),Y(!1),w(!1),ue(null),ae("welcome")),Fe&&qe&&j&&(console.log("๐ข Connected with active session - removing loader"),Y(!1),w(!0),ue(qe))};return K.on("connectionStateChanged",re),K.on("sessionEnded",()=>{console.log("๐ Session ended - returning to welcome"),Y(!1),w(!1),ue(null),ae("welcome")}),()=>{K.off("connectionStateChanged",re),K.off("sessionEnded",()=>{})}},[K,te,j,D]),P.useEffect(()=>{const re=qe=>{console.log("๐ด Widget: Room disconnected:",qe),console.log("๐ Widget: Current state on disconnect:",{currentMode:te,sessionStarted:D,currentSessionId:W==null?void 0:W.id,loading:j}),Y(!1),w(!1),ue(null),ae("welcome"),console.log("๐ Widget: Automatically returning to welcome screen after disconnect")},Fe=qe=>{console.log("๐น Media devices error:",qe)};return le.on(ce.RoomEvent.MediaDevicesError,Fe),le.on(ce.RoomEvent.Disconnected,re),()=>{le.off(ce.RoomEvent.Disconnected,re),le.off(ce.RoomEvent.MediaDevicesError,Fe)}},[le,te,D,W==null?void 0:W.id,j]);const ke=async()=>{try{if(!K){console.error("โ VoxketClient not available"),$(new Error("VoxketClient not initialized")),ne(!0);return}Y(!0),ae("voice"),console.log("๐ค Starting voice session...",{agentId:S,participantName:U}),console.log("๐ค Pre-start state:",{currentMode:"voice",sessionStarted:!1,loading:!0}),ve("USER_STARTED_VOICE_SESSION",{agentId:S,participantName:U});const re=await K.startSession(S,{participantName:U||"User",modalities:["voice",...m?["video"]:[]],participantMetadata:K.getParticipantMetadata()||F});console.log("โ
Voice session started successfully:",re.id),ue(re),w(!0),Y(!1),k&&k(re.id)}catch(re){console.error("โ Failed to start voice session:",re),Y(!1),w(!1),ae("welcome")}},lt=async()=>{try{if(!K){console.error("โ VoxketClient not available"),$(new Error("VoxketClient not initialized")),ne(!0);return}Y(!0),ae("chat"),console.log("๐ฌ Starting chat session...",{agentId:S,participantName:U}),ve("USER_STARTED_CHAT_SESSION",{agentId:S,participantName:U});const re=await K.startSession(S,{participantName:U||"User",modalities:["chat"],participantMetadata:K.getParticipantMetadata()||F});console.log("โ
Chat session started successfully:",re.id),ue(re),w(!0),Y(!1),k&&k(re.id)}catch(re){console.error("โ Failed to start chat session:",re),Y(!1),w(!1),ae("welcome")}},Et=async()=>{try{if(!K){console.error("โ VoxketClient not available"),$(new Error("VoxketClient not initialized")),ne(!0);return}Y(!0),ae("video"),console.log("๐บ Starting video session...",{agentId:S,participantName:U}),console.log("๐บ Pre-start state:",{currentMode:"video",sessionStarted:!1,loading:!0}),ve("USER_STARTED_VIDEO_SESSION",{agentId:S,participantName:U});const re=await K.startSession(S,{participantName:U||"User",modalities:["video","voice"],participantMetadata:K.getParticipantMetadata()||F});console.log("โ
Video session started successfully:",re.id),ue(re),w(!0),Y(!1),k&&k(re.id)}catch(re){console.error("โ Failed to start video session:",re),Y(!1),w(!1),ae("welcome")}},Ke=()=>{ae("welcome"),Y(!1),B&&B(e.displayType||"widget"),W&&D?(console.log("๐งน Widget: Cleaning up active session"),w(!1),ue(null),K&&(console.log("๐ Widget: Disconnecting client and cleaning up room"),K.disconnect().catch(re=>{console.error("โ Widget: Error during disconnect:",re)}))):(console.log("๐ Widget: No active session to clean up"),K&&K.connected&&(console.log("๐ Widget: Force disconnecting client for fresh state"),K.disconnect().catch(re=>{console.error("โ Widget: Error during force disconnect:",re)}))),N==="popup"&&!Oe&&L(!0),console.log("โ
Widget: handleBackToWelcome completed",{newCurrentMode:"welcome",newLoading:!1,newSessionStarted:!1})},ct=()=>{const re=!Oe;L(re),R&&R(re),!re&&!(W&&D)&&(ae("welcome"),w(!1),ue(null))},xt=()=>{console.log("๐ Closing fullscreen, switching to widget display type"),e.onDisplayTypeChange?e.onDisplayTypeChange("widget"):console.warn("โ ๏ธ No onDisplayTypeChange callback provided")},fn=()=>{if(console.log("๐ Expand to fullscreen requested"),e.onDisplayTypeChange)e.onDisplayTypeChange("fullscreen");else{console.warn("โ ๏ธ No onDisplayTypeChange callback provided for expand functionality");const re=document.getElementById("voice-card")||document.querySelector(".voxket-widget-container");re&&re.requestFullscreen&&re.requestFullscreen().catch(Fe=>{console.warn("โ ๏ธ Fullscreen API not supported or failed:",Fe)})}};P.useEffect(()=>{var re,Fe,qe;if(I&&K){const Ye=K.getCurrentSession();K.connected,Ye&&(console.log("โ
Restoring session state:",Ye.id),ue(Ye),w(!0),Y(!1),(re=Ye.activeModalities)!=null&&re.includes("chat")?ae("chat"):(Fe=Ye.activeModalities)!=null&&Fe.includes("voice")?ae("voice"):(qe=Ye.activeModalities)!=null&&qe.includes("video")&&ae("video"))}},[I,K]),P.useEffect(()=>()=>{!I&&K&&K.disconnect()},[K,I]);let V=te==="video"?"w-[32rem]":"w-96",Q=te==="video"?"h-[30rem]":"h-[25rem]",xe={};if(d&&(d.startsWith("w-")?V=d:(xe.width=d,V="")),f&&(f.startsWith("h-")?Q=f:(xe.height=f,Q="")),N==="popup"&&!Oe)return console.log("๐ก Showing popup trigger button"),h.jsx(og,{onClick:ct,position:O,ariaLabel:b});if(q||!K){const re=(ee==null?void 0:ee.message)||"VoxketWidget encountered an error. Please check your configuration.";return h.jsx("div",{className:`voxket-widget-root theme-${y} flex items-center justify-center p-8 ${u||""}`,style:{width:d||"400px",height:f||"500px",border:"1px solid #ff4444",borderRadius:"8px",background:"#fff5f5",color:"#cc0000"},children:h.jsxs("div",{className:"text-center",children:[h.jsx("div",{className:"text-4xl mb-4",children:"โ ๏ธ"}),h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Widget Error"}),h.jsx("p",{className:"text-sm mb-4",children:re}),h.jsx("button",{onClick:()=>{ne(!1),$(null),window.location.reload()},className:"px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 transition-colors",children:"Retry"})]})})}let Te=`voxket-widget-root theme-${y}`,De={scrollMargin:0,scrollPadding:0,contain:"layout style paint"};N==="widget"?(Te+=` flex min-h-fit ${V} ${Q} ${u}`,De={...De,...xe}):(Te=`${u||""}`,De={});const Nt=h.jsx("div",{className:"h-full w-full flex flex-col overflow-hidden relative z-10",children:h.jsxs(Sr,{mode:"wait",children:[te==="welcome"&&!j&&h.jsx(WM,{agentId:S,participantName:U||"",onAgentIdChange:H,onParticipantNameChange:Z,onStartCall:ke,onStartChat:lt,onStartVideo:Et,disabled:D||j,prompts:s,statusMessage:a,title:l,subTitle:c,theme:y,modalities:Ee,initial:{opacity:0,y:0},animate:{opacity:1,y:0},exit:{opacity:0,y:40},transition:{duration:.3,ease:"easeInOut"}},"welcome"),j&&(te==="voice"||te==="chat"||te==="video")&&h.jsx(KM,{theme:y,mode:te,loadingText:p,initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},transition:{duration:.3,ease:"easeInOut"}},`loading-${te}`),te==="voice"&&!j&&D&&K&&h.jsxs(Ft.RoomContext.Provider,{value:le,children:[h.jsx(Ft.RoomAudioRenderer,{},`audio-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(Ft.StartAudio,{label:"Start Audio"},`start-audio-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(zM,{loadingText:p,participantName:U||"User",sessionStarted:D,disabled:!1,theme:y,client:K,displayType:N,onBack:N==="popup"?ct:Ke,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"voice-session")]}),te==="chat"&&!j&&D&&K&&h.jsx(UM,{client:K,theme:y,displayType:N,onBack:N==="popup"?ct:Ke,onEndChat:Ke,disabled:!1,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"chat-view"),te==="video"&&!j&&D&&K&&h.jsxs(Ft.RoomContext.Provider,{value:le,children:[h.jsx(Ft.RoomAudioRenderer,{},`audio-video-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(Ft.StartAudio,{label:"Start Audio"},`start-audio-video-${(W==null?void 0:W.id)||"no-session"}`),h.jsx(HM,{client:K,theme:y,displayType:N,onBack:N==="popup"?ct:Ke,onEndCall:Ke,disabled:!1,initial:{opacity:0,y:40},animate:{opacity:1,y:0},exit:{opacity:0,y:-40},transition:{duration:.3,ease:"easeInOut"}},"video-session")]})]})});return N==="fullscreen"||N==="popup"?h.jsx(bf,{theme:y,displayType:N,popupPosition:O,onClose:N==="fullscreen"?xt:ct,children:Nt}):h.jsx("div",{className:Te,style:De,children:h.jsx(bf,{theme:y,displayType:N,popupPosition:O,onExpand:fn,children:Nt})})}function oo(e){return h.jsx(Xl,{children:h.jsx(qM,{...e})})}function YM({logs:e,onClear:t,onExport:n}){const[r,i]=A.useState(!1),[o,s]=A.useState(""),a=e.filter(l=>!o||l.event.toLowerCase().includes(o.toLowerCase()));return r?h.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:h.jsxs("div",{className:"bg-white rounded-lg shadow-xl max-w-4xl w-full max-h-[80vh] flex flex-col m-4",children:[h.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[h.jsxs("h2",{className:"text-lg font-semibold",children:["Session Logs (",e.length,")"]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("input",{type:"text",placeholder:"Filter events...",value:o,onChange:l=>s(l.target.value),className:"px-3 py-1 border rounded text-sm"}),h.jsx("button",{onClick:t,className:"px-3 py-1 bg-red-600 text-white rounded text-sm hover:bg-red-700",children:"Clear"}),h.jsx("button",{onClick:n,className:"px-3 py-1 bg-green-600 text-white rounded text-sm hover:bg-green-700",children:"Export"}),h.jsx("button",{onClick:()=>i(!1),className:"px-3 py-1 bg-gray-600 text-white rounded text-sm hover:bg-gray-700",children:"Close"})]})]}),h.jsx("div",{className:"flex-1 overflow-auto p-4",children:a.length===0?h.jsx("p",{className:"text-gray-500 text-center py-8",children:"No logs found"}):h.jsx("div",{className:"space-y-2",children:a.map((l,c)=>h.jsxs("div",{className:"border rounded p-3 text-sm",children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("span",{className:"font-semibold text-blue-600",children:l.event}),h.jsx("span",{className:"text-gray-500 text-xs",children:new Date(l.timestamp).toLocaleTimeString()})]}),l.sessionId&&h.jsxs("div",{className:"text-xs text-gray-600 mb-1",children:["Session: ",l.sessionId]}),l.data&&h.jsx("div",{className:"bg-gray-50 p-2 rounded text-xs",children:h.jsx("pre",{className:"whitespace-pre-wrap overflow-auto",children:JSON.stringify(l.data,null,2)})})]},c))})})]})}):h.jsxs("button",{onClick:()=>i(!0),className:"fixed bottom-4 right-4 bg-blue-600 text-white px-4 py-2 rounded-lg shadow-lg hover:bg-blue-700 transition-colors text-sm z-50",children:["Session Logs (",e.length,")"]})}function ZM({metrics:e}){return e?h.jsxs("div",{className:"bg-gray-100 p-4 rounded-lg",children:[h.jsx("h3",{className:"font-semibold mb-2",children:"Current Session"}),h.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Session ID:"}),h.jsx("div",{className:"font-mono text-xs",children:e.sessionId})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Start Time:"}),h.jsx("div",{children:new Date(e.startTime).toLocaleString()})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Messages:"}),h.jsx("div",{children:e.totalMessages})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Participants:"}),h.jsx("div",{children:e.participantCount})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Connection Issues:"}),h.jsx("div",{children:e.connectionIssues})]}),h.jsxs("div",{children:[h.jsx("span",{className:"text-gray-600",children:"Duration:"}),h.jsxs("div",{children:[Math.round((Date.now()-new Date(e.startTime).getTime())/1e3),"s"]})]})]})]}):null}function er(){const{currentSession:e,sessionState:t,sessionMetrics:n,createSession:r,endSession:i}=dn(),o=A.useCallback(async(a,l)=>await r(a,l),[r]),s=A.useCallback(async()=>await i(),[i]);return{session:e,state:t,metrics:n,isActive:e!==null&&t!=="disconnected",isConnecting:t==="connecting",isConnected:t==="connected"||t==="active",start:o,stop:s}}function cg(){const{sessionMetrics:e,currentSession:t}=dn();return{metrics:e,sessionId:t==null?void 0:t.id,duration:e==null?void 0:e.duration,participantCount:e==null?void 0:e.participantCount,messageCount:e==null?void 0:e.messageCount,audioQuality:e==null?void 0:e.audioQuality,networkStats:e==null?void 0:e.networkStats}}function ug(){const{setMicrophoneEnabled:e,client:t}=dn(),[n,r]=A.useState(!1),[i,o]=A.useState(!1),s=A.useCallback(async()=>{if(!i){o(!0);try{const c=!n;await e(c),r(c)}catch(c){console.error("Failed to toggle microphone:",c)}finally{o(!1)}}},[n,i,e]),a=A.useCallback(async()=>{if(!(n||i)){o(!0);try{await e(!0),r(!0)}catch(c){console.error("Failed to enable microphone:",c)}finally{o(!1)}}},[n,i,e]),l=A.useCallback(async()=>{if(!(!n||i)){o(!0);try{await e(!1),r(!1)}catch(c){console.error("Failed to disable microphone:",c)}finally{o(!1)}}},[n,i,e]);return{isEnabled:n,isLoading:i,toggle:s,enable:a,disable:l}}function dg(){const{setCameraEnabled:e}=dn(),[t,n]=A.useState(!1),[r,i]=A.useState(!1),o=A.useCallback(async()=>{if(!r){i(!0);try{const l=!t;await e(l),n(l)}catch(l){console.error("Failed to toggle camera:",l)}finally{i(!1)}}},[t,r,e]),s=A.useCallback(async()=>{if(!(t||r)){i(!0);try{await e(!0),n(!0)}catch(l){console.error("Failed to enable camera:",l)}finally{i(!1)}}},[t,r,e]),a=A.useCallback(async()=>{if(!(!t||r)){i(!0);try{await e(!1),n(!1)}catch(l){console.error("Failed to disable camera:",l)}finally{i(!1)}}},[t,r,e]);return{isEnabled:t,isLoading:r,toggle:o,enable:s,disable:a}}function fg(){const{startScreenShare:e,stopScreenShare:t}=dn(),[n,r]=A.useState(!1),[i,o]=A.useState(!1),s=A.useCallback(async()=>{if(!(n||i)){o(!0);try{await e(),r(!0)}catch(c){console.error("Failed to start screen share:",c)}finally{o(!1)}}},[n,i,e]),a=A.useCallback(async()=>{if(!(!n||i)){o(!0);try{await t(),r(!1)}catch(c){console.error("Failed to stop screen share:",c)}finally{o(!1)}}},[n,i,t]),l=A.useCallback(async()=>{n?await a():await s()},[n,s,a]);return{isSharing:n,isLoading:i,start:s,stop:a,toggle:l}}function XM(){const{client:e}=dn(),[t,n]=A.useState({tracks:[],layout:{type:"grid",showLocalVideo:!0,aspectRatio:"16:9"},isRecording:!1}),r=A.useMemo(()=>t.tracks.find(m=>m.isLocal),[t.tracks]),i=A.useMemo(()=>t.tracks.filter(m=>!m.isLocal),[t.tracks]),o=A.useCallback(async()=>{try{r!=null&&r.isEnabled?await(e==null?void 0:e.disableCamera()):await(e==null?void 0:e.enableCamera())}catch(m){throw console.error("Failed to toggle camera:",m),m}},[e,r]),s=A.useCallback(async()=>{try{t.tracks.find(x=>x.isScreenShare)?await(e==null?void 0:e.stopScreenShare()):await(e==null?void 0:e.startScreenShare())}catch(m){throw console.error("Failed to toggle screen share:",m),m}},[e,t.tracks]),a=A.useCallback(m=>{n(x=>({...x,layout:m}))},[]),l=A.useCallback(m=>{n(x=>({...x,pinnedTrack:m}))},[]),c=A.useCallback(()=>{n(m=>({...m,pinnedTrack:void 0}))},[]),u=A.useCallback(async()=>{try{await(e==null?void 0:e.startRecording()),n(m=>({...m,isRecording:!0}))}catch(m){throw console.error("Failed to start recording:",m),m}},[e]),d=A.useCallback(async()=>{try{await(e==null?void 0:e.stopRecording()),n(m=>({...m,isRecording:!1}))}catch(m){throw console.error("Failed to stop recording:",m),m}},[e]),f=A.useCallback(m=>t.tracks.find(x=>x.id===m),[t.tracks]),p=A.useCallback(m=>t.tracks.filter(x=>x.participantId===m),[t.tracks]),g=A.useCallback(m=>m.isEnabled&&t.tracks.includes(m),[t.tracks]);return A.useEffect(()=>{if(!e)return;const m=k=>{n(E=>({...E,tracks:[...E.tracks.filter(_=>_.id!==k.id),k]}))},x=k=>{n(E=>{var _;return{...E,tracks:E.tracks.filter(v=>v.id!==k),pinnedTrack:((_=E.pinnedTrack)==null?void 0:_.id)===k?void 0:E.pinnedTrack}})},y=k=>{n(E=>({...E,tracks:E.tracks.map(_=>_.id===k.id?k:_)}))};return e.on("videoTrackAdded",m),e.on("videoTrackRemoved",x),e.on("videoTrackUpdated",y),()=>{e.off("videoTrackAdded",m),e.off("videoTrackRemoved",x),e.off("videoTrackUpdated",y)}},[e]),{tracks:t.tracks,localTrack:r,remoteTraracks:i,pinnedTrack:t.pinnedTrack,layout:t.layout,isRecording:t.isRecording,toggleCamera:o,toggleScreenShare:s,setLayout:a,pinTrack:l,unpinTrack:c,startRecording:u,stopRecording:d,getTrackById:f,getTracksByParticipant:p,isTrackActive:g}}function Ko(){const{chatMessages:e,sendChatMessage:t,currentSession:n}=dn(),[r,i]=A.useState(!1),o=A.useCallback(async c=>{if(!(!c.trim()||r||!n)){i(!0);try{await t(c.trim())}catch(u){throw console.error("Failed to send chat message:",u),u}finally{i(!1)}}},[t,r,n]),{userMessages:s,agentMessages:a,allMessages:l}=A.useMemo(()=>{const c=e.filter(d=>d.sender.type==="participant"),u=e.filter(d=>d.sender.type==="agent");return{userMessages:c,agentMessages:u,allMessages:e}},[e]);return{messages:l,userMessages:s,agentMessages:a,messageCount:l.length,isSending:r,canSend:!!n&&!r,send:o}}function QM(){const{send:e,isSending:t,canSend:n}=Ko(),[r,i]=A.useState(""),o=A.useCallback(async()=>{if(!(!r.trim()||!n))try{await e(r),i("")}catch(a){throw a}},[r,e,n]),s=A.useCallback(a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),o())},[o]);return{value:r,setValue:i,send:o,handleKeyPress:s,isSending:t,canSend:n&&r.trim().length>0}}function ec(){const{isConnected:e,isConnecting:t,connectionError:n,connect:r,disconnect:i}=dn(),o=A.useCallback(async()=>{if(!(e||t))try{await r()}catch(a){throw console.error("Failed to connect:",a),a}},[r,e,t]),s=A.useCallback(async()=>{if(e)try{await i()}catch(a){throw console.error("Failed to disconnect:",a),a}},[i,e]);return{isConnected:e,isConnecting:t,isDisconnected:!e&&!t,error:n,hasError:!!n,connect:o,disconnect:s}}function hg(){const{participants:e}=dn();return{participants:e,count:e.length,localParticipant:e.find(t=>t.isLocal),remoteParticipants:e.filter(t=>!t.isLocal)}}const pg=A.createContext({}),Si=()=>A.useContext(pg);function mg({children:e,...t}){return h.jsx(pg.Provider,{value:t,children:e})}function so({name:e,children:t,fallback:n,className:r}){return h.jsx("div",{className:`voxket-slot voxket-slot--${e} ${r||""}`,children:t||n})}function gg(e,t={}){return Object.assign(e,t)}function bg({showMicrophoneControl:e=!0,showCameraControl:t=!0,showScreenShareControl:n=!0,showSessionActions:r=!0,customControls:i,className:o=""}){const s=er(),a=ug(),l=dg(),c=fg(),u=Si(),d=["voxket-session-controls",`voxket-session-controls--${u.variant||"default"}`,`voxket-session-controls--${u.size||"md"}`,s.isActive?"voxket-session-controls--active":"voxket-session-controls--inactive",o].filter(Boolean).join(" ");return!s.isActive&&!r?h.jsx("div",{className:d,children:h.jsx("div",{className:"voxket-controls-inactive",children:h.jsx("p",{children:"Controls available during active session"})})}):h.jsxs("div",{className:d,children:[r&&h.jsx("div",{className:"voxket-session-actions",children:s.isActive?h.jsx("button",{onClick:s.stop,className:"voxket-button voxket-button--danger",children:"End Session"}):h.jsx(JM,{})}),s.isActive&&h.jsxs("div",{className:"voxket-media-controls",children:[e&&h.jsxs("button",{onClick:a.toggle,disabled:a.isLoading,className:`voxket-button voxket-button--media ${a.isEnabled?"voxket-button--active":""}`,title:a.isEnabled?"Mute microphone":"Unmute microphone",children:[h.jsx("span",{className:"voxket-icon",children:"๐ค"}),a.isLoading?"Loading...":a.isEnabled?"Mute":"Unmute"]}),t&&h.jsxs("button",{onClick:l.toggle,disabled:l.isLoading,className:`voxket-button voxket-button--media ${l.isEnabled?"voxket-button--active":""}`,title:l.isEnabled?"Stop camera":"Start camera",children:[h.jsx("span",{className:"voxket-icon",children:"๐น"}),l.isLoading?"Loading...":l.isEnabled?"Stop Video":"Start Video"]}),n&&h.jsxs("button",{onClick:c.toggle,disabled:c.isLoading,className:`voxket-button voxket-button--media ${c.isSharing?"voxket-button--active":""}`,title:c.isSharing?"Stop screen share":"Start screen share",children:[h.jsx("span",{className:"voxket-icon",children:"๐ฅ๏ธ"}),c.isLoading?"Loading...":c.isSharing?"Stop Share":"Share Screen"]})]}),i&&h.jsx("div",{className:"voxket-custom-controls",children:i})]})}function JM(){er();const[e,t]=A.useState(!1),n=async()=>{t(!0);try{console.log("Start session - agentId needed")}catch(r){console.error("Failed to start session:",r)}finally{t(!1)}};return h.jsx("button",{onClick:n,disabled:e,className:"voxket-button voxket-button--primary",children:e?"Starting...":"Start Session"})}function tc({showConnectionStatus:e=!0,showSessionInfo:t=!0,showAgentInfo:n=!0,className:r=""}){const i=er(),o=ec(),s=Si(),a=["voxket-session-header",`voxket-session-header--${s.variant||"default"}`,`voxket-session-header--${s.size||"md"}`,r].filter(Boolean).join(" ");return h.jsxs("div",{className:a,children:[e&&h.jsxs("div",{className:"voxket-connection-status",children:[h.jsx("div",{className:`voxket-status-indicator ${o.isConnected?"connected":"disconnected"}`}),h.jsx("span",{className:"voxket-status-text",children:o.isConnecting?"Connecting...":o.isConnected?"Connected":"Disconnected"})]}),t&&i.session&&h.jsxs("div",{className:"voxket-session-info",children:[h.jsxs("div",{className:"voxket-session-id",children:["Session: ",i.session.id.slice(-8)]}),h.jsxs("div",{className:"voxket-session-state",children:["State: ",i.state]})]}),n&&i.session&&h.jsxs("div",{className:"voxket-agent-info",children:[h.jsxs("div",{className:"voxket-agent-id",children:["Agent: ",i.session.agentId]}),h.jsxs("div",{className:"voxket-modalities",children:["Modalities: ",i.session.activeModalities.join(", ")]})]}),o.error&&h.jsxs("div",{className:"voxket-error-message",children:["Error: ",o.error.message]})]})}function nc({showChat:e=!0,showTranscriptions:t=!1,customContent:n,className:r=""}){const i=er(),o=Ko(),s=Si(),a=["voxket-session-content",`voxket-session-content--${s.variant||"default"}`,`voxket-session-content--${s.size||"md"}`,r].filter(Boolean).join(" ");return i.isActive?h.jsx("div",{className:a,children:n||h.jsxs(h.Fragment,{children:[e&&h.jsxs("div",{className:"voxket-chat-container",children:[h.jsxs("div",{className:"voxket-chat-messages",children:[o.messages.map(l=>h.jsxs("div",{className:`voxket-message voxket-message--${l.sender.type}`,children:[h.jsxs("div",{className:"voxket-message-header",children:[h.jsx("span",{className:"voxket-message-sender",children:l.sender.name}),h.jsx("span",{className:"voxket-message-time",children:l.timestamp.toLocaleTimeString()})]}),h.jsx("div",{className:"voxket-message-content",children:l.content})]},l.id)),o.messages.length===0&&h.jsx("div",{className:"voxket-empty-messages",children:h.jsx("p",{children:"No messages yet. Start the conversation!"})})]}),h.jsx(eI,{})]}),t&&h.jsx("div",{className:"voxket-transcriptions",children:h.jsx("div",{className:"voxket-transcription-placeholder",children:h.jsx("p",{children:"Voice transcriptions will appear here"})})})]})}):h.jsx("div",{className:a,children:h.jsx("div",{className:"voxket-inactive-state",children:h.jsxs("div",{className:"voxket-inactive-message",children:[h.jsx("h3",{children:"Start a conversation"}),h.jsx("p",{children:"Begin a session to start chatting with the AI agent"})]})})})}function eI(){const e=Ko(),[t,n]=A.useState(""),r=async()=>{if(!(!t.trim()||!e.canSend))try{await e.send(t),n("")}catch(o){console.error("Failed to send message:",o)}},i=o=>{o.key==="Enter"&&!o.shiftKey&&(o.preventDefault(),r())};return h.jsxs("div",{className:"voxket-chat-input",children:[h.jsx("input",{type:"text",value:t,onChange:o=>n(o.target.value),onKeyPress:i,placeholder:"Type your message...",disabled:!e.canSend,className:"voxket-input"}),h.jsx("button",{onClick:r,disabled:!e.canSend||!t.trim(),className:"voxket-send-button",children:e.isSending?"Sending...":"Send"})]})}function rc({showMetrics:e=!0,showParticipants:t=!0,showStatus:n=!0,customFooter:r,className:i=""}){const o=er(),s=cg(),a=hg(),l=Si(),c=["voxket-session-footer",`voxket-session-footer--${l.variant||"default"}`,`voxket-session-footer--${l.size||"md"}`,i].filter(Boolean).join(" ");return o.isActive?h.jsx("div",{className:c,children:r||h.jsxs(h.Fragment,{children:[n&&h.jsxs("div",{className:"voxket-session-status",children:[h.jsx("div",{className:"voxket-status-indicator voxket-status-indicator--active"}),h.jsx("span",{className:"voxket-status-text",children:"Session Active"})]}),e&&s.metrics&&h.jsxs("div",{className:"voxket-session-metrics",children:[h.jsxs("div",{className:"voxket-metric",children:[h.jsx("span",{className:"voxket-metric-label",children:"Duration:"}),h.jsx("span",{className:"voxket-metric-value",children:tI(s.duration||0)})]}),h.jsxs("div",{className:"voxket-metric",children:[h.jsx("span",{className:"voxket-metric-label",children:"Messages:"}),h.jsx("span",{className:"voxket-metric-value",children:s.metrics.messageCount})]})]}),t&&h.jsxs("div",{className:"voxket-participants-info",children:[h.jsxs("span",{className:"voxket-participants-count",children:[a.count," participant",a.count!==1?"s":""]}),a.remoteParticipants.length>0&&h.jsx("div",{className:"voxket-participant-list",children:a.remoteParticipants.map(u=>h.jsx("span",{className:"voxket-participant-name",children:u.name},u.id))})]})]})}):h.jsx("div",{className:c,children:h.jsx("div",{className:"voxket-footer-inactive",children:h.jsx("span",{className:"voxket-status-text",children:"Ready to start session"})})})}function tI(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}:${(n%60).toString().padStart(2,"0")}:${(t%60).toString().padStart(2,"0")}`:`${n}:${(t%60).toString().padStart(2,"0")}`}function nI({agentId:e,sessionConfig:t,autoStart:n=!1,onSessionStart:r,onSessionEnd:i,variant:o="default",size:s="md",theme:a,className:l="",children:c}){var p;const u=er(),d=ec();A.useEffect(()=>{n&&e&&d.isConnected&&!u.isActive&&u.start(e,t).catch(console.error)},[n,e,d.isConnected,u.isActive]),A.useEffect(()=>{var g;(g=u.session)!=null&&g.id&&r&&r(u.session.id)},[(p=u.session)==null?void 0:p.id,r]),A.useEffect(()=>()=>{u.isActive&&i&&u.stop().then(i).catch(console.error)},[]);const f=["voxket-session",`voxket-session--${o}`,`voxket-session--${s}`,u.isActive?"voxket-session--active":"voxket-session--inactive",l].filter(Boolean).join(" ");return h.jsx(mg,{variant:o,size:s,theme:a,className:l,children:h.jsx("div",{className:f,children:c||h.jsxs(h.Fragment,{children:[h.jsx(so,{name:"header",fallback:h.jsx(tc,{})}),h.jsx(so,{name:"content",fallback:h.jsx(nc,{})}),h.jsx(so,{name:"footer",fallback:h.jsx(rc,{})})]})})})}const yg=gg(nI,{Header:tc,Content:nc,Footer:rc,Controls:bg}),Yn={name:"default",colors:{primary:"#3B82F6",secondary:"#6B7280",accent:"#8B5CF6",background:"#FFFFFF",surface:"#F9FAFB",text:{primary:"#111827",secondary:"#6B7280",muted:"#9CA3AF",inverse:"#FFFFFF"},status:{success:"#10B981",warning:"#F59E0B",error:"#EF4444",info:"#3B82F6"},border:"#E5E7EB",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},typography:{fontFamily:"system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700},lineHeight:{tight:1.25,normal:1.5,relaxed:1.75}},spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{none:"0",sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},shadows:{sm:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",md:"0 4px 6px -1px rgba(0, 0, 0, 0.1)",lg:"0 10px 15px -3px rgba(0, 0, 0, 0.1)"}},La={...Yn,name:"dark",colors:{primary:"#60A5FA",secondary:"#9CA3AF",accent:"#A78BFA",background:"#111827",surface:"#1F2937",text:{primary:"#F9FAFB",secondary:"#D1D5DB",muted:"#9CA3AF",inverse:"#111827"},status:{success:"#34D399",warning:"#FBBF24",error:"#F87171",info:"#60A5FA"},border:"#374151",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.3)"}},Fa={...Yn,name:"enterprise",colors:{primary:"#1E40AF",secondary:"#64748B",accent:"#7C3AED",background:"#FFFFFF",surface:"#F8FAFC",text:{primary:"#0F172A",secondary:"#475569",muted:"#94A3B8",inverse:"#FFFFFF"},status:{success:"#059669",warning:"#D97706",error:"#DC2626",info:"#1E40AF"},border:"#CBD5E1",shadow:"0 1px 3px 0 rgba(0, 0, 0, 0.1)"},borderRadius:{none:"0",sm:"0.125rem",md:"0.25rem",lg:"0.375rem",full:"9999px"}},xg=A.createContext(null),wg=()=>{const e=A.useContext(xg);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e};function rI({theme:e="default",themes:t={},children:n,cssVariables:r=!0,className:i=""}){const[o,s]=A.useState(()=>{const f={default:Yn,dark:La,enterprise:Fa,...t};return typeof e=="string"?f[e]||Yn:e}),[a,l]=A.useState(()=>({default:Yn,dark:La,enterprise:Fa,...t})),c=f=>{if(typeof f=="string"){const p=a[f];p&&s(p)}else s(f)},u=f=>{l(p=>({...p,[f.name]:f}))};A.useEffect(()=>{if(r&&typeof document<"u"){const f=document.documentElement;Object.entries(vg(o)).forEach(([p,g])=>{f.style.setProperty(`--voxket-${p}`,g)})}},[o,r]);const d={theme:o,setTheme:c,themes:a,registerTheme:u};return h.jsx(xg.Provider,{value:d,children:h.jsx("div",{className:`voxket-theme voxket-theme--${o.name} ${i}`,children:n})})}function vg(e){const t={},n=(r,i="")=>{for(const[o,s]of Object.entries(r)){const a=i?`${i}-${o}`:o;typeof s=="object"&&s!==null&&!Array.isArray(s)?n(s,a):t[a]=String(s)}};return n(e),t}function iI(e=Yn,t){return{...e,...t,colors:{...e.colors,...t.colors},typography:{...e.typography,...t.typography},spacing:{...e.spacing,...t.spacing},borderRadius:{...e.borderRadius,...t.borderRadius},shadows:{...e.shadows,...t.shadows}}}function oI(e){var n;const{theme:t}=wg();return((n=t.components)==null?void 0:n[e])||{}}const sI=Jl("voice-modality","voice",{onActivate:async e=>{const t=e.config;t.enableTranscription&&aI(e),t.enableVoiceActivation&&lI(e,t),console.log("Voice modality activated",t)},onDeactivate:async e=>{console.log("Voice modality deactivated")},onMessage:async(e,t)=>{t.type==="audio"&&cI(e,t)}});function aI(e,t){e.on("participant.speaking.started",n=>{console.log("Transcription: Started for",n.name)}),e.on("participant.speaking.stopped",n=>{console.log("Transcription: Stopped for",n.name)})}function lI(e,t){const n=t.silenceThreshold||-50;console.log("Voice activation setup with threshold:",n)}function cI(e,t){console.log("Playing audio response:",t.content)}const uI=Jl("chat-modality","chat",{onActivate:async e=>{const t=e.config;t.enableRichText&&dI(),t.enableFileUpload&&fI(e),t.enableCustomComponents&&hI(),console.log("Chat modality activated",t)},onDeactivate:async e=>{console.log("Chat modality deactivated")},onMessage:async(e,t)=>{const n=e.config;t.type==="ui_component"?pI(e,t):t.type==="text"&&n.enableRichText&&mI(e,t)}});function dI(e){console.log("Rich text support enabled")}function fI(e){console.log("File upload enabled"),e.on("chat.file.uploaded",t=>{console.log("File uploaded:",t.name)})}function hI(e){console.log("Custom components enabled");const t=new Map;t.set("quick-actions",gI),t.set("form",bI),t.set("card",yI),t.set("chart",xI)}function pI(e,t){const{componentType:n,props:r}=t.metadata;console.log("Rendering custom component:",n,r),e.emit("chat.component.render",{type:n,props:r,timestamp:new Date})}function mI(e,t){console.log("Processing rich text message:",t.content)}function gI(e){return{type:"quick-actions",actions:e.actions||[],layout:e.layout||"horizontal"}}function bI(e){return{type:"form",fields:e.fields||[],submitAction:e.submitAction,validation:e.validation}}function yI(e){return{type:"card",title:e.title,content:e.content,actions:e.actions,variant:e.variant||"default"}}function xI(e){return{type:"chart",chartType:e.chartType||"line",data:e.data,options:e.options}}function ao({track:e,participantName:t,showControls:n=!0,showName:r=!0,showMuteIndicator:i=!0,isPinned:o=!1,className:s="",onClick:a,onPin:l,onUnpin:c}){const u=A.useRef(null),[d,f]=A.useState(!1);A.useEffect(()=>{if(!u.current||!e.isEnabled)return;const x=u.current;return x.srcObject=null,()=>{x.srcObject&&(x.srcObject=null)}},[e]);const p=()=>{a==null||a(e)},g=x=>{x.stopPropagation(),o?c==null||c(e):l==null||l(e)},m=["voxket-video-tile",e.isLocal?"voxket-video-tile--local":"voxket-video-tile--remote",e.isScreenShare?"voxket-video-tile--screen-share":"voxket-video-tile--camera",o?"voxket-video-tile--pinned":"",e.isEnabled?"":"voxket-video-tile--disabled",d?"voxket-video-tile--hovered":"",s].filter(Boolean).join(" ");return h.jsxs("div",{className:m,onClick:p,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{aspectRatio:e.dimensions?`${e.dimensions.width} / ${e.dimensions.height}`:"16 / 9"},children:[h.jsx("video",{ref:u,className:"voxket-video-element",autoPlay:!0,playsInline:!0,muted:e.isLocal}),!e.isEnabled&&h.jsxs("div",{className:"voxket-video-placeholder",children:[h.jsx("div",{className:"voxket-video-placeholder-icon",children:e.isScreenShare?"๐ฅ๏ธ":"๐น"}),h.jsx("p",{className:"voxket-video-placeholder-text",children:e.isScreenShare?"Screen sharing paused":"Camera off"})]}),h.jsxs("div",{className:"voxket-video-overlay",children:[r&&t&&h.jsxs("div",{className:"voxket-video-name",children:[t,e.isLocal&&" (You)"]}),i&&!e.isEnabled&&h.jsx("div",{className:"voxket-video-mute-indicator",children:"๐"}),n&&(d||o)&&h.jsxs("div",{className:"voxket-video-controls",children:[h.jsx("button",{className:`voxket-video-control-btn ${o?"voxket-video-control-btn--active":""}`,onClick:g,title:o?"Unpin video":"Pin video",children:"๐"}),e.isScreenShare&&h.jsx("div",{className:"voxket-video-indicator",children:"๐ฅ๏ธ"}),e.source&&h.jsx("div",{className:"voxket-video-source",children:e.source})]})]}),!e.isEnabled&&h.jsx("div",{className:"voxket-video-loading",children:h.jsx("div",{className:"voxket-spinner"})})]})}function wI({tracks:e,layout:t,className:n="",onLayoutChange:r,onTrackClick:i,maxVisibleTracks:o=9,showPagination:s=!0}){const[a,l]=A.useState(0),[c,u]=A.useState(null),d=A.useMemo(()=>{let k=[...e];t.type==="speaker"&&c&&(k=[c,...e.filter(v=>v.id!==c.id)]);const E=a*o,_=E+o;return k.slice(E,_)},[e,t,c,a,o]),f=Math.ceil(e.length/o),p=A.useMemo(()=>{const k=d.length;switch(t.type){case"grid":const E=Math.ceil(Math.sqrt(k)),_=Math.ceil(k/E);return{display:"grid",gridTemplateColumns:`repeat(${E}, 1fr)`,gridTemplateRows:`repeat(${_}, 1fr)`,gap:"8px"};case"speaker":return{display:"flex",flexDirection:"column",gap:"8px"};case"sidebar":return{display:"flex",gap:"8px"};case"gallery":return{display:"flex",flexWrap:"wrap",gap:"8px",justifyContent:"center"};default:return{}}},[t.type,d.length]),g=k=>{u(k)},m=()=>{u(null)},x=k=>{r==null||r({...t,type:k})},y=["voxket-video-grid",`voxket-video-grid--${t.type}`,`voxket-video-grid--${d.length}-tracks`,n].filter(Boolean).join(" ");return e.length===0?h.jsx("div",{className:"voxket-video-grid-empty",children:h.jsxs("div",{className:"voxket-video-grid-empty-content",children:[h.jsx("div",{className:"voxket-video-grid-empty-icon",children:"๐น"}),h.jsx("p",{children:"No video tracks available"})]})}):h.jsxs("div",{className:y,children:[h.jsxs("div",{className:"voxket-video-grid-controls",children:[h.jsx("div",{className:"voxket-video-layout-controls",children:["grid","speaker","sidebar","gallery"].map(k=>h.jsx("button",{className:`voxket-layout-btn ${t.type===k?"voxket-layout-btn--active":""}`,onClick:()=>x(k),title:`Switch to ${k} layout`,children:vI(k)},k))}),h.jsxs("div",{className:"voxket-video-count",children:[e.length," participant",e.length!==1?"s":""]})]}),h.jsx("div",{className:"voxket-video-grid-content",style:p,children:t.type==="speaker"&&c?h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"voxket-video-speaker-main",children:h.jsx(ao,{track:c,participantName:`Participant ${c.participantId}`,isPinned:!0,onClick:i,onUnpin:m})}),h.jsx("div",{className:"voxket-video-speaker-sidebar",children:d.filter(k=>k.id!==c.id).map(k=>h.jsx(ao,{track:k,participantName:`Participant ${k.participantId}`,showControls:!1,onClick:i,onPin:g},k.id))})]}):d.map(k=>h.jsx(ao,{track:k,participantName:`Participant ${k.participantId}`,isPinned:(c==null?void 0:c.id)===k.id,onClick:i,onPin:g,onUnpin:m},k.id))}),s&&f>1&&h.jsxs("div",{className:"voxket-video-pagination",children:[h.jsx("button",{className:"voxket-pagination-btn",onClick:()=>l(Math.max(0,a-1)),disabled:a===0,children:"โ"}),h.jsxs("span",{className:"voxket-pagination-info",children:["Page ",a+1," of ",f]}),h.jsx("button",{className:"voxket-pagination-btn",onClick:()=>l(Math.min(f-1,a+1)),disabled:a===f-1,children:"โ"})]})]})}function vI(e){switch(e){case"grid":return"โ";case"speaker":return"๐ค";case"sidebar":return"โซธ";case"gallery":return"โก";case"picture-in-picture":return"โง";default:return"โ"}}function EI({localTrack:e,onToggleCamera:t,onToggleScreenShare:n,onLayoutChange:r,showLayoutControls:i=!0,showCameraControls:o=!0,showScreenShareControls:s=!0,className:a=""}){const l=["voxket-video-controls",a].filter(Boolean).join(" "),c=u=>{r==null||r({type:u,showLocalVideo:!0,aspectRatio:"16:9"})};return h.jsxs("div",{className:l,children:[o&&h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Camera"}),h.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isEnabled?"voxket-control-btn--active":""}`,onClick:t,title:e!=null&&e.isEnabled?"Turn off camera":"Turn on camera",children:[h.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isEnabled?"๐น":"๐ท"}),h.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isEnabled?"Camera On":"Camera Off"})]}),(e==null?void 0:e.dimensions)&&h.jsxs("div",{className:"voxket-video-info",children:[e.dimensions.width," ร ",e.dimensions.height]})]}),s&&h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Screen Share"}),h.jsxs("button",{className:`voxket-control-btn ${e!=null&&e.isScreenShare?"voxket-control-btn--active":""}`,onClick:n,title:e!=null&&e.isScreenShare?"Stop screen sharing":"Start screen sharing",children:[h.jsx("span",{className:"voxket-control-icon",children:e!=null&&e.isScreenShare?"๐":"๐ฅ๏ธ"}),h.jsx("span",{className:"voxket-control-label",children:e!=null&&e.isScreenShare?"Stop Sharing":"Share Screen"})]})]}),i&&h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Layout"}),h.jsx("div",{className:"voxket-layout-buttons",children:[{type:"grid",icon:"โ",label:"Grid"},{type:"speaker",icon:"๐ค",label:"Speaker"},{type:"sidebar",icon:"โซธ",label:"Sidebar"},{type:"gallery",icon:"โก",label:"Gallery"}].map(({type:u,icon:d,label:f})=>h.jsxs("button",{className:"voxket-layout-control-btn",onClick:()=>c(u),title:`Switch to ${f} layout`,children:[h.jsx("span",{className:"voxket-control-icon",children:d}),h.jsx("span",{className:"voxket-control-label",children:f})]},u))})]}),h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Video Settings"}),h.jsxs("div",{className:"voxket-video-settings",children:[h.jsxs("div",{className:"voxket-setting-group",children:[h.jsx("label",{className:"voxket-setting-label",children:"Quality"}),h.jsxs("select",{className:"voxket-setting-select",children:[h.jsx("option",{value:"high",children:"High (720p)"}),h.jsx("option",{value:"medium",children:"Medium (480p)"}),h.jsx("option",{value:"low",children:"Low (240p)"})]})]}),h.jsxs("div",{className:"voxket-setting-group",children:[h.jsx("label",{className:"voxket-setting-label",children:"Frame Rate"}),h.jsxs("select",{className:"voxket-setting-select",children:[h.jsx("option",{value:"30",children:"30 fps"}),h.jsx("option",{value:"15",children:"15 fps"}),h.jsx("option",{value:"10",children:"10 fps"})]})]}),h.jsxs("div",{className:"voxket-setting-group",children:[h.jsx("label",{className:"voxket-setting-label",children:"Bandwidth"}),h.jsxs("select",{className:"voxket-setting-select",children:[h.jsx("option",{value:"unlimited",children:"Unlimited"}),h.jsx("option",{value:"1000",children:"1 Mbps"}),h.jsx("option",{value:"500",children:"500 Kbps"}),h.jsx("option",{value:"250",children:"250 Kbps"})]})]})]})]}),h.jsxs("div",{className:"voxket-video-controls-section",children:[h.jsx("h4",{className:"voxket-video-controls-title",children:"Statistics"}),h.jsxs("div",{className:"voxket-video-stats",children:[h.jsxs("div",{className:"voxket-stat-item",children:[h.jsx("span",{className:"voxket-stat-label",children:"Resolution:"}),h.jsx("span",{className:"voxket-stat-value",children:e!=null&&e.dimensions?`${e.dimensions.width}ร${e.dimensions.height}`:"N/A"})]}),h.jsxs("div",{className:"voxket-stat-item",children:[h.jsx("span",{className:"voxket-stat-label",children:"Source:"}),h.jsx("span",{className:"voxket-stat-value",children:(e==null?void 0:e.source)||"None"})]}),h.jsxs("div",{className:"voxket-stat-item",children:[h.jsx("span",{className:"voxket-stat-label",children:"Status:"}),h.jsx("span",{className:`voxket-stat-value ${e!=null&&e.isEnabled?"voxket-stat-value--active":"voxket-stat-value--inactive"}`,children:e!=null&&e.isEnabled?"Active":"Inactive"})]})]})]})]})}const Eg=({handler:e,loadData:t,data:n,client:r,addLocalMessage:i})=>{const[o,s]=P.useState(null),[a,l]=P.useState(!0),[c,u]=P.useState(!1),[d]=P.useState(Date.now()),[f,p]=P.useState("pending");P.useEffect(()=>{(async()=>{try{if(l(!0),n&&typeof n=="object"){const k={title:n.title||"Untitled Assignment",description:n.description||"No description provided",estimated_time_of_completion:n.estimated_time_of_completion||"Unknown"};s(k),console.log("๐ AssignmentView: Assignment loaded from RPC data:",k)}}catch(k){console.error("๐ AssignmentView: Error loading assignment:",k),s({title:"Assignment Loading Error",description:"There was an error loading the assignment details. Please try again.",estimated_time_of_completion:"Unknown"})}finally{l(!1)}})()},[n,t]);const g=({message:y,assignment:k})=>{const E=y.toLowerCase().includes("declined"),_=E?"bg-red-50 border-red-200":"bg-green-50 border-green-200",v=E?"text-red-700":"text-green-700",C=E?"โ":"๐";return h.jsxs("div",{className:`max-w-sm mx-auto ${_} border rounded-lg shadow p-3 flex flex-col items-center`,children:[h.jsx("div",{className:"text-2xl mb-2",children:C}),h.jsx("div",{className:`${v} font-semibold text-sm mb-1`,children:y}),h.jsx("div",{className:"text-xs text-gray-600 text-center mb-1",children:k.title}),h.jsx("div",{className:"text-xs text-gray-500",children:"Thank you for your response!"})]})},m=async()=>{if(!(!o||!e)){u(!0);try{const y={message:"accepted"};console.log("๐ AssignmentView: Assignment accepted:",y),e.didSuccess(y),p("accepted")}catch(y){console.error("๐ AssignmentView: Error accepting assignment:",y),e.didFail({error:"Failed to accept assignment"}),p("error")}finally{u(!1)}}},x=async()=>{if(!(!o||!e)){u(!0);try{const y={message:"declined"};console.log("๐ AssignmentView: Assignment declined:",y),e.didSuccess(y),p("declined")}catch(y){console.error("๐ AssignmentView: Error declining assignment:",y),e.didFail({error:"Failed to decline assignment"}),p("error")}finally{u(!1)}}};return a?h.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:h.jsxs("div",{className:"flex items-center justify-center py-4",children:[h.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-blue-600"}),h.jsx("span",{className:"ml-2 text-xs text-gray-600",children:"Loading assignment..."})]})}):o?f==="accepted"||f==="declined"||f==="error"?h.jsx(g,{message:f==="accepted"?"Assignment accepted!":f==="declined"?"Assignment declined":"Assignment error occurred",assignment:o}):h.jsxs("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg overflow-hidden",children:[h.jsx("div",{className:"bg-gradient-to-r from-blue-600 to-purple-600 text-white p-3",children:h.jsx("div",{className:"flex items-center justify-between",children:h.jsx("h3",{className:"text-xs font-semibold text-white truncate",children:o.title})})}),h.jsxs("div",{className:"p-3 text-black",children:[h.jsx("div",{className:"bg-gray-50 rounded p-2 mb-3",children:h.jsx("p",{className:"text-xs text-black leading-snug",children:o.description})}),h.jsx("div",{className:"mb-3 text-black",children:h.jsxs("div",{className:"flex items-center text-xs text-gray-600",children:[h.jsx("span",{className:"text-xs mr-1",children:"๐
"}),h.jsxs("span",{children:["Est: ",o.estimated_time_of_completion]})]})}),h.jsxs("div",{className:"flex gap-2",children:[h.jsx("button",{onClick:m,disabled:c,className:"flex-1 bg-green-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-green-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:c?h.jsxs("span",{className:"flex items-center justify-center",children:[h.jsx("div",{className:"animate-spin rounded-full h-2 w-2 border-b-2 border-white mr-1"}),h.jsx("span",{className:"text-xs",children:"Processing..."})]}):"Accept"}),h.jsx("button",{onClick:x,disabled:c,className:"flex-1 bg-red-600 text-white py-2 px-3 rounded text-xs font-medium hover:bg-red-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Decline"})]})]})]}):h.jsx("div",{className:"max-w-sm mx-auto bg-white rounded-lg shadow-lg p-3",children:h.jsxs("div",{className:"text-center py-4",children:[h.jsx("div",{className:"text-red-600 text-sm font-semibold mb-2",children:"โ ๏ธ Assignment Error"}),h.jsx("p",{className:"text-xs text-gray-600 mb-3",children:"Failed to load assignment details."})]})})};function kI(){const[e,t]=P.useState(null),[n,r]=P.useState([]);P.useEffect(()=>{const a=new ki({appId:"your-app-id",appSecret:"your-app-secret",baseUrl:"https://your-voxket-api.com",agentId:"your-agent-id",participantName:"User",modalities:["chat"]});return t(a),a.on("rpc.method.called",l=>{console.log("RPC Method Called:",l)}),a.on("rpc.interaction.completed",l=>{console.log("RPC Interaction Completed:",l)}),()=>{a.disconnect()}},[]);const i=async()=>{if(e)try{await e.registerFrontendRPC("give_assignment",Eg,"embedded");const a=e.getRegisteredRpcMethods();r(a),console.log("โ
Assignment RPC registered successfully")}catch(a){console.error("โ Failed to register assignment RPC:",a)}},o=async()=>{if(!e)return;const a=({handler:l,timeout:c})=>{const[u,d]=P.useState(""),f=[{id:"pro",name:"Pro Plan",price:"$29/month"},{id:"enterprise",name:"Enterprise Plan",price:"$99/month"},{id:"basic",name:"Basic Plan",price:"$9/month"}],p=m=>{d(m)},g=()=>{const m=f.find(x=>x.id===u);l==null||l.didSuccess({selectedProduct:u,productName:m==null?void 0:m.name,price:m==null?void 0:m.price,timestamp:new Date().toISOString()})};return h.jsxs("div",{className:"p-6 bg-white rounded-lg",children:[h.jsx("h3",{className:"text-xl font-bold mb-4",children:"Choose Your Plan"}),h.jsx("p",{className:"text-gray-600 mb-4",children:"Select the plan that best fits your needs:"}),h.jsx("div",{className:"space-y-3 mb-6",children:f.map(m=>h.jsx("div",{onClick:()=>p(m.id),className:`p-4 border rounded-lg cursor-pointer transition-all ${u===m.id?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"}`,children:h.jsxs("div",{className:"flex justify-between items-center",children:[h.jsxs("div",{children:[h.jsx("h4",{className:"font-medium",children:m.name}),h.jsx("p",{className:"text-gray-600 text-sm",children:m.price})]}),h.jsx("div",{className:`w-4 h-4 rounded-full ${u===m.id?"bg-blue-500":"border-2 border-gray-300"}`})]})},m.id))}),h.jsxs("div",{className:"flex justify-end space-x-3",children:[h.jsx("button",{onClick:()=>l==null?void 0:l.dismissView(),className:"px-4 py-2 border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Cancel"}),h.jsx("button",{onClick:g,disabled:!u,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Select Plan"})]}),c&&h.jsxs("p",{className:"text-xs text-gray-500 mt-2",children:["Time remaining: ",c," seconds"]})]})};try{await e.registerFrontendRPC("recommend_product",a,"modal");const l=e.getRegisteredRpcMethods();r(l),console.log("โ
Product Recommendation RPC registered successfully")}catch(l){console.error("โ Failed to register product recommendation RPC:",l)}},s=async()=>{if(!e)return;const a=({handler:l})=>{const[c,u]=P.useState(0),[d,f]=P.useState(""),p=()=>{l==null||l.didSuccess({rating:c,comment:d,timestamp:new Date().toISOString()})};return h.jsxs("div",{className:"p-4 bg-white rounded-lg",children:[h.jsx("h3",{className:"text-lg font-semibold mb-3",children:"How was your experience?"}),h.jsxs("div",{className:"mb-4",children:[h.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Rate your experience:"}),h.jsx("div",{className:"flex space-x-1",children:[1,2,3,4,5].map(g=>h.jsx("button",{onClick:()=>u(g),className:`text-2xl ${g<=c?"text-yellow-400":"text-gray-300"}`,children:"โญ"},g))})]}),h.jsxs("div",{className:"mb-4",children:[h.jsx("p",{className:"text-sm text-gray-600 mb-2",children:"Additional comments:"}),h.jsx("textarea",{value:d,onChange:g=>f(g.target.value),className:"w-full p-2 border border-gray-300 rounded text-sm",rows:3,placeholder:"Tell us more about your experience..."})]}),h.jsxs("div",{className:"flex justify-end space-x-2",children:[h.jsx("button",{onClick:()=>l==null?void 0:l.dismissView(),className:"px-3 py-1 text-sm border border-gray-300 text-gray-700 rounded hover:bg-gray-50",children:"Skip"}),h.jsx("button",{onClick:p,disabled:c===0,className:"px-3 py-1 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50",children:"Submit"})]})]})};try{await e.registerFrontendRPC("collect_feedback",a,"embedded");const l=e.getRegisteredRpcMethods();r(l),console.log("โ
Feedback RPC registered successfully")}catch(l){console.error("โ Failed to register feedback RPC:",l)}};return h.jsxs("div",{className:"p-6",children:[h.jsx("h2",{className:"text-2xl font-bold mb-6",children:"Frontend RPC Examples"}),h.jsxs("div",{className:"space-y-4 mb-6",children:[h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Register RPC Methods"}),h.jsxs("div",{className:"space-x-2",children:[h.jsx("button",{onClick:i,className:"px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600",children:"Register Assignment RPC"}),h.jsx("button",{onClick:o,className:"px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600",children:"Register Product Recommendation RPC"}),h.jsx("button",{onClick:s,className:"px-4 py-2 bg-purple-500 text-white rounded hover:bg-purple-600",children:"Register Feedback RPC"})]})]}),h.jsxs("div",{children:[h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"Registered Methods"}),n.length>0?h.jsx("ul",{className:"list-disc list-inside space-y-1",children:n.map(a=>h.jsx("li",{className:"text-gray-700",children:h.jsx("code",{className:"bg-gray-100 px-2 py-1 rounded",children:a})},a))}):h.jsx("p",{className:"text-gray-500",children:"No methods registered yet"})]})]}),h.jsxs("div",{className:"bg-gray-50 p-4 rounded-lg",children:[h.jsx("h3",{className:"text-lg font-semibold mb-2",children:"How it works"}),h.jsxs("ol",{className:"list-decimal list-inside space-y-2 text-sm text-gray-700",children:[h.jsxs("li",{children:["Register RPC methods with React components using ",h.jsx("code",{children:"client.registerFrontendRPC()"})]}),h.jsx("li",{children:"When the agent calls an RPC method, the corresponding component will be displayed"}),h.jsx("li",{children:"Users interact with the component, and the response is sent back to the agent"}),h.jsx("li",{children:"Components can be displayed in different modes: embedded, modal, or fullscreen"}),h.jsx("li",{children:"Each component has a timeout and can handle success/failure scenarios"})]})]}),h.jsxs("div",{className:"mt-6 bg-blue-50 p-4 rounded-lg",children:[h.jsx("h3",{className:"text-lg font-semibold mb-2 text-blue-800",children:"Agent Side"}),h.jsx("p",{className:"text-sm text-blue-700 mb-2",children:"On the agent side, you can call these RPC methods like this:"}),h.jsx("pre",{className:"bg-white p-3 rounded text-xs text-gray-800 overflow-x-auto",children:`// Agent calls RPC method
|
|
144
144
|
const response = await participant.performRpc({
|
|
145
145
|
method: 'give_assignment',
|
|
146
146
|
data: JSON.stringify({
|