PageSourceSearch

https://haitipal.com/static/js/180.2b7b3326.chunk.js

js haitipal.com collected 2026-10-07 03:33:42 UTC 433,416 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[180],{7937(e,t,a){a.d(t,{P:()=>l});var n=a(5544),s=a(5043),i=a(5088),r=a(579);function l(e){let t=e.endsAt,a=e.className,l=void 0===a?"":a;const o=(0,s.useState)(Date.now()),c=(0,n.A)(o,2),d=c[0],u=c[1],m=(0,s.useRef)(null);(0,s.useEffect)(()=>{if(!t)return;const e=setInterval(()=>u(Date.now()),250);return()=>clearInterval(e)},[t]);const h=t?Math.max(0,Math.floor((new Date(t).getTime()-d)/1e3)):0,x=h<=0,p=!x&&h<=10;if((0,s.useEffect)(()=>{if(p){if(m.current!==h){m.current=h;try{navigator.vibrate&&navigator.vibrate(h<=3?160:90)}catch(e){}}}else m.current=null},[p,h]),!t)return null;const f=String(Math.floor(h/60)).padStart(2,"0"),g=String(h%60).padStart(2,"0");return(0,r.jsxs)("span",{"data-testid":"competition-countdown","data-urgent":p?"1":"0",className:"flex items-center gap-1 rounded-full font-bold tabular-nums transition-all ".concat(x?"bg-white/10 px-2 py-0.5 text-xs text-gray-300":p?"px-3 py-1 text-base text-white comp-cd-urgent":"bg-black/40 px-2 py-0.5 text-xs text-[#00F0FF]"," ").concat(l),children:[(0,r.jsx)(i.A,{className:"".concat(p?"h-4 w-4":"h-3 w-3")})," ",x?"Fini":"".concat(f,":").concat(g),(0,r.jsx)("style",{children:"\n        @keyframes comp-cd-shake {\n          0%,100% { transform: translateX(0) scale(1); }\n          20% { transform: translateX(-2px) scale(1.06); }\n          40% { transform: translateX(2px) scale(1.06); }\n          60% { transform: translateX(-2px) scale(1.03); }\n          80% { transform: translateX(2px) scale(1.03); }\n        }\n        @keyframes comp-cd-flash {\n          0%,100% { background-color: #FF2A5F; box-shadow: 0 0 10px rgba(255,42,95,0.6); }\n          50% { background-color: #ff0033; box-shadow: 0 0 22px rgba(255,0,51,0.95); }\n        }\n        .comp-cd-urgent {\n          animation: comp-cd-shake 0.5s ease-in-out infinite, comp-cd-flash 0.9s ease-in-out infinite;\n        }\n      "})]})}},4370(e,t,a){a.d(t,{bq:()=>j,eb:()=>A,gC:()=>N,l6:()=>b,yv:()=>w});var n=a(9379),s=a(3986),i=a(5043),r=a(4092),l=a(6210),o=a(2382),c=a(5711),d=a(1089),u=a(579);const m=["className","children"],h=["className"],x=["className"],p=["className","children","position"],f=["className"],g=["className","children"],v=["className"],b=r.bL,w=(r.YJ,r.WT),j=i.forwardRef((e,t)=>{let a=e.className,i=e.children,l=(0,s.A)(e,m);return(0,u.jsxs)(r.l9,(0,n.A)((0,n.A)({ref:t,className:(0,d.cn)("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",a)},l),{},{children:[i,(0,u.jsx)(r.In,{asChild:!0,children:(0,u.jsx)(o.A,{className:"h-4 w-4 opacity-50"})})]}))});j.displayName=r.l9.displayName;const y=i.forwardRef((e,t)=>{let a=e.className,i=(0,s.A)(e,h);return(0,u.jsx)(r.PP,(0,n.A)((0,n.A)({ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",a)},i),{},{children:(0,u.jsx)(c.A,{className:"h-4 w-4"})}))});y.displayName=r.PP.displayName;const k=i.forwardRef((e,t)=>{let a=e.className,i=(0,s.A)(e,x);return(0,u.jsx)(r.wn,(0,n.A)((0,n.A)({ref:t,className:(0,d.cn)("flex cursor-default items-center justify-center py-1",a)},i),{},{children:(0,u.jsx)(o.A,{className:"h-4 w-4"})}))});k.displayName=r.wn.displayName;const N=i.forwardRef((e,t)=>{let a=e.className,i=e.children,l=e.position,o=void 0===l?"popper":l,c=(0,s.A)(e,p);return(0,u.jsx)(r.ZL,{children:(0,u.jsxs)(r.UC,(0,n.A)((0,n.A)({ref:t,className:(0,d.cn)("relative z-[110] max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:sli
1de-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]","popper"===o&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",a),position:o},c),{},{children:[(0,u.jsx)(y,{}),(0,u.jsx)(r.LM,{className:(0,d.cn)("p-1","popper"===o&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:i}),(0,u.jsx)(k,{})]}))})});N.displayName=r.UC.displayName;i.forwardRef((e,t)=>{let a=e.className,i=(0,s.A)(e,f);return(0,u.jsx)(r.JU,(0,n.A)({ref:t,className:(0,d.cn)("px-2 py-1.5 text-sm font-semibold",a)},i))}).displayName=r.JU.displayName;const A=i.forwardRef((e,t)=>{let a=e.className,i=e.children,o=(0,s.A)(e,g);return(0,u.jsxs)(r.q7,(0,n.A)((0,n.A)({ref:t,className:(0,d.cn)("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a)},o),{},{children:[(0,u.jsx)("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,u.jsx)(r.VF,{children:(0,u.jsx)(l.A,{className:"h-4 w-4"})})}),(0,u.jsx)(r.p4,{children:i})]}))});A.displayName=r.q7.displayName;i.forwardRef((e,t)=>{let a=e.className,i=(0,s.A)(e,v);return(0,u.jsx)(r.wv,(0,n.A)({ref:t,className:(0,d.cn)("-mx-1 my-1 h-px bg-muted",a)},i))}).displayName=r.wv.displayName},3325(e,t,a){function n(e){return e?e.is_admin||"admin"===e.role||"admin"===e.from_role?"admin":e.is_moderator||"moderator"===e.role||"moderator"===e.from_role?"moderator":e.is_vip||e.from_vip?"vip":null:null}function s(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const a=n(e);return"admin"===a?t?"text-red-400":"text-red-600":"moderator"===a?t?"text-green-400":"text-green-600":"vip"===a?t?"text-blue-400":"text-blue-600":null}function i(e){const t=s(e,arguments.length>1&&void 0!==arguments[1]&&arguments[1]);return t?"".concat(t," font-bold"):""}a.d(t,{Lc:()=>n,eR:()=>i,oL:()=>s})},5180(e,t,a){a.r(t),a.d(t,{default:()=>Bn});var n=a(9379),s=a(5544),i=a(5043),r=a(953),l=a(8847),o=a(8838),c=a(5187),d=a(6104),u=a(6328),m=a(3588);let h={"\u2764\ufe0f":"/reaction-sounds/ou-pa-gen-fanm.mp3","\ud83d\udd25":"/reaction-sounds/balil.mp3","\ud83d\ude02":"/reaction-sounds/manje-moun.mp3","\ud83d\udc4f":"/reaction-sounds/chalmas.mp3","\ud83d\ude2e":"/reaction-sounds/ti-john.mp3","\ud83c\udf89":"/reaction-sounds/radiyes.mp3","\ud83e\udd10":"/reaction-sounds/femen-dyol.mp3"};let x=(()=>{try{return"1"===localStorage.getItem("htv_sounds_muted")}catch(e){return!1}})();function p(e){if(x)return;const t=function(e){return e?e.startsWith("http")?e:e.startsWith("/api/")?"https://haitipal.com"+e:e:null}(h[e]);if(t)try{const e=new Audio(t);e.volume=.9,e.play().catch(()=>{})}catch(a){}}var f=a(6613);class g{constructor(e){let t=e.camStream,a=e.loopVideoEl,n=e.loopAudioTrack;this._render=()=>{if(this._stopped)return;const e=this.ctx,t=this.W,a=this.H;e.fillStyle="#000",e.fillRect(0,0,t,a);const n={m:this.camEl,mir:this.mirrorCam},s={m:this.loopVideoEl,mir:this.mirrorVid},i=this.swap?s:n,r=this.swap?n:s;if("split"===this.layout)this._drawCover(i.m,0,0,t,a/2,i.mir),this._drawCover(r.m,0,a/2,t,a/2,r.mir),e.fillStyle="rgba(255,255,255,0.18)",e.fillRect(0,a/2-1,t,2);else{this._drawCover(i.m,0,0,t,a,i.mir);const n=Math.round(.32*t),s=Math.round(.75*n),l=16,o=t-n-l,c=a-s-l;e.save(),e.shadowColor="rgba(0,0,0,0.6)",e.shadowBlur=14,e.fillStyle="#000",e.fillRect(o-2,c-2,n+4,s+4),e.restore(),this._drawCover(r.m,o,c,n,s,r.mir),e.strokeStyle="rgba(255,255,255,0.85)",e.lineWidth=3,e.strokeRect(o,c,n,s)}this._raf=requestAnimationFrame(this._render)},this.camStream=t,this.loopVideoEl=a,this.loopAudioTrack=n||null,this.layout="split",this.swap=!1,this.mirrorCam=!1,this.mirrorVid=!1,this.videoVolume=1,this.micVolume=1,this.W=720,this.H=720,this._raf=null,this._stopped=!1}
1async init(){const e=document.createElement("video");e.srcObject=new MediaStream(this.camStream.getVideoTracks()),e.muted=!0,e.playsInline=!0;try{await e.play()}catch(s){}this.camEl=e;const t=document.createElement("canvas");t.width=this.W,t.height=this.H,this.canvas=t,this.ctx=t.getContext("2d");const a=window.AudioContext||window.webkitAudioContext;this.ac=new a,this.dest=this.ac.createMediaStreamDestination(),this.loopAudioTrack&&(this.vSrc=this.ac.createMediaStreamSource(new MediaStream([this.loopAudioTrack])),this.vGain=this.ac.createGain(),this.vGain.gain.value=this.videoVolume,this.vSrc.connect(this.vGain).connect(this.dest));const n=this.camStream.getAudioTracks()[0];if(n&&(this.mSrc=this.ac.createMediaStreamSource(new MediaStream([n])),this.mGain=this.ac.createGain(),this.mGain.gain.value=this.micVolume,this.mSrc.connect(this.mGain).connect(this.dest)),this.loopVideoEl)try{this.loopVideoEl.volume=this.videoVolume}catch(i){}}_drawCover(e,t,a,n,s,i){const r=this.ctx,l=e.videoWidth||e.width||0,o=e.videoHeight||e.height||0;if(!l||!o)return;const c=Math.max(n/l,s/o),d=n/c,u=s/c,m=(l-d)/2,h=(o-u)/2;r.save(),r.beginPath(),r.rect(t,a,n,s),r.clip(),i&&(r.translate(t+n,a),r.scale(-1,1),r.translate(-t,-a));try{r.drawImage(e,m,h,d,u,t,a,n,s)}catch(x){}r.restore()}start(){this._stopped=!1,this._render(),this.outStream=this.canvas.captureStream(30);return{videoTrack:this.outStream.getVideoTracks()[0],audioTrack:this.dest.stream.getAudioTracks()[0]||null}}setLayout(e){this.layout=e}setSwap(e){this.swap=!!e}setMirrorCam(e){this.mirrorCam=!!e}setMirrorVid(e){this.mirrorVid=!!e}setVideoVolume(e){if(this.videoVolume=e,this.vGain&&(this.vGain.gain.value=e),this.loopVideoEl)try{this.loopVideoEl.volume=e}catch(t){}}setMicVolume(e){this.micVolume=e,this.mGain&&(this.mGain.gain.value=e)}stop(){this._stopped=!0,this._raf&&cancelAnimationFrame(this._raf);try{this.outStream&&this.outStream.getTracks().forEach(e=>e.stop())}catch(e){}try{this.camEl&&(this.camEl.srcObject=null)}catch(t){}try{this.ac&&this.ac.close()}catch(a){}}}class v{constructor(e){this._render=()=>{if(this._stopped)return;const e=this.ctx,t=this.vidEl,a=t.videoWidth||this.W,n=t.videoHeight||this.H;a&&n&&(this.canvas.width!==a||this.canvas.height!==n)&&(this.canvas.width=a,this.canvas.height=n,this.W=a,this.H=n),e.save(),e.clearRect(0,0,this.W,this.H),this.mirror&&(e.translate(this.W,0),e.scale(-1,1));try{e.drawImage(t,0,0,this.W,this.H)}catch(s){}e.restore(),this._raf=requestAnimationFrame(this._render)},this.track=e,this.mirror=!1,this._raf=null,this._stopped=!1}
1async init(){const e=this.track.getSettings&&this.track.getSettings()||{};this.W=e.width||1280,this.H=e.height||720;const t=document.createElement("video");t.srcObject=new MediaStream([this.track]),t.muted=!0,t.playsInline=!0;try{await t.play()}catch(n){}this.vidEl=t;const a=document.createElement("canvas");a.width=this.W,a.height=this.H,this.canvas=a,this.ctx=a.getContext("2d")}start(){return this._stopped=!1,this._render(),this.outStream=this.canvas.captureStream(30),this.outStream.getVideoTracks()[0]}setMirror(e){this.mirror=!!e}stop(){this._stopped=!0,this._raf&&cancelAnimationFrame(this._raf);try{this.outStream&&this.outStream.getTracks().forEach(e=>e.stop())}catch(e){}try{this.vidEl&&(this.vidEl.srcObject=null)}catch(t){}}}let b=null;const w=()=>b||(b=Promise.all([a.e(207),a.e(760)]).then(a.bind(a,2760))),j={bundlePolicy:"max-bundle",rtcpMuxPolicy:"require",iceCandidatePoolSize:0},y=(0,n.A)({iceServers:[{urls:"stun:global.stun.twilio.com:3478"}]},j),k=[{name:"high",maxBitrate:12e5,scaleResolutionDownBy:1,maxFramerate:30},{name:"medium",maxBitrate:6e5,scaleResolutionDownBy:1.5,maxFramerate:24},{name:"low",maxBitrate:3e5,scaleResolutionDownBy:2,maxFramerate:15}];function N(){let e=localStorage.getItem("htv_device");return e||(e=crypto.randomUUID?crypto.randomUUID():String(Date.now())+Math.random(),localStorage.setItem("htv_device",e)),e}function A(e){let t=e.room,a=void 0===t?"lobby":t,r=e.selfUserId,l=e.guest,o=void 0!==l&&l,c=e.onWalletUpdate,h=e.onGift,p=e.onSystem,b=e.onReaction;const A=(0,i.useState)({}),F=(0,s.A)(A,2),_=F[0],C=F[1],S=(0,i.useState)(null),R=(0,s.A)(S,2),E=R[0],T=R[1],M=(0,i.useState)(!1),P=(0,s.A)(M,2),D=P[0],I=P[1],L=(0,i.useState)("connecting"),z=(0,s.A)(L,2),V=z[0],O=z[1],q=(0,i.useState)(null),B=(0,s.A)(q,2),U=B[0],K=B[1],H=(0,i.useState)(!1),W=(0,s.A)(H,2),G=W[0],J=W[1],Y=(0,i.useState)(9),X=(0,s.A)(Y,2),Z=X[0],Q=X[1],$=(0,i.useState)(!1),ee=(0,s.A)($,2),te=ee[0],ae=ee[1],ne=(0,i.useState)([]),se=(0,s.A)(ne,2),ie=se[0],re=se[1],le=(0,i.useState)({video:!1,audio:!1}),oe=(0,s.A)(le,2),ce=oe[0],de=oe[1],ue=(0,i.useState)(!1),me=(0,s.A)(ue,2),he=me[0],xe=me[1],pe=(0,i.useState)(()=>new Set),fe=(0,s.A)(pe,2),ge=fe[0],ve=fe[1],be=(0,i.useState)({video:!1,audio:!1}),we=(0,s.A)(be,2),je=we[0],ye=we[1],ke=(0,i.useState)({cameras:[],mics:[],speakers:[]}),Ne=(0,s.A)(ke,2),Ae=Ne[0],Fe=Ne[1],_e=(0,i.useState)(()=>({camera:localStorage.getItem("htv_camera")||"",mic:localStorage.getItem("htv_mic")||"",speaker:localStorage.getItem("htv_speaker")||""})),Ce=(0,s.A)(_e,2),Se=Ce[0],Re=Ce[1],Ee=(0,i.useState)([]),Te=(0,s.A)(Ee,2),Me=Te[0],Pe=Te[1],De=(0,i.useState)({}),Ie=(0,s.A)(De,2),Le=Ie[0],ze=Ie[1],Ve=(0,i.useState)({}),Oe=(0,s.A)(Ve,2),qe=Oe[0],Be=Oe[1],Ue=(0,i.useState)({}),Ke=(0,s.A)(Ue,2),He=Ke[0],We=Ke[1],Ge=(0,i.useState)({}),Je=(0,s.A)(Ge,2),Ye=Je[0],Xe=Je[1],Ze=(0,i.useState)(new Set),Qe=(0,s.A)(Ze,2),$e=Qe[0],et=Qe[1],tt=(0,i.useState)(!1),at=(0,s.A)(tt,2),nt=at[0],st=at[1],it=(0,i.useState)(null),rt=(0,s.A)(it,2),lt=rt[0],ot=rt[1],ct=(0,i.useState)([]),dt=(0,s.A)(ct,2),ut=dt[0],mt=dt[1],ht=(0,i.useState)(()=>localStorage.getItem("htv_bg")||"none"),xt=(0,s.A)(ht,2),pt=xt[0],ft=xt[1],gt=(0,i.useState)(()=>localStorage.getItem("htv_bg_custom_url")||null),vt=(0,s.A)(gt,2),bt=vt[0],wt=vt[1],jt=(0,i.useState)(()=>localStorage.getItem("htv_filter")||"none"),yt=(0,s.A)(jt,2),kt=yt[0],Nt=yt[1],At=(0,i.useState)(()=>({brightness:parseFloat(localStorage.getItem("htv_bright"))||1,contrast:parseFloat(localStorage.getItem("htv_contrast"))||1})),Ft=(0,s.A)(At,2),_t=Ft[0],Ct=Ft[1],St=(0,i.useState)({status:"idle",peer:null,stream:null}),Rt=(0,s.A)(St,2),Et=Rt[0],Tt=Rt[1],Mt=(0,i.useState)({}),Pt=(0,s.A)(Mt,2),Dt=Pt[0],It=Pt[1],Lt=(0,i.useState)({status:"idle",callId:null,incoming:null}),zt=(0,s.A)(Lt,2),Vt=zt[0],Ot=zt[1],qt=(0,i.useState)({}),Bt=(0,s.A)(qt,2),Ut=Bt[0],Kt=Bt[1],Ht=(0,i.useState)({}),Wt=(0,s.A)(Ht,2),Gt=Wt[0],Jt=Wt[1],Yt=(0,i.useRef)(Vt);Yt.current=Vt;const Xt=(0,i.useRef)({}),Zt=(0,i.useRef)({}),Qt=(0,i.useRef)({}),$t=(0,i.useRef)({}),ea=(0,i.useState)([]),ta=(0,s.A)(ea,2),aa=ta[0],na=ta[1],sa=(0,i.useState)(!1),ia=(0,s.A)(sa,2),ra=ia[0],la=ia[1],oa=(0,i.useState)(null),ca=(0,s.A)(oa,2),da=ca[0],ua=ca[1],ma=(0,i.useState)(null),ha=(0,s.A)(ma,2),xa=ha[0],pa=ha[1],fa=(0,i.useState)(!1),ga=(0,s.A)(fa,2),va=ga[0],ba=ga[1],wa=(0,i.useState)({}),ja=(0,s.A)(wa,2),ya=ja[0],ka=ja[1],Na=(0,i.useRef)(null),Aa=(0,i.useRef)({}),Fa=(0,i.useRef)(y),_a=(0,i.useRef)(y),Ca=(0,i.useRef)(null),Sa=(0,i.useRef)(ce);Sa.current=ce;const Ra=(0,i.useRef)(pt);Ra.current=pt;const Ea=(0,i.useRef)(bt);Ea.current=bt;const Ta=(0,i.useRef)(kt);Ta.current=kt;const Ma=(0,i.useRef)(_t);Ma.current=_t;const Pa=(0,i.useRef)(null),Da=(0,i.useRef)(new Map),Ia=(0,i.useRef)(new Map),La=(0,i.useRef)(!1),za=(0,i.useRef)(!0),Va=(0,i.useRef)(null),Oa=(0,i.useRef)(null),qa=(0,i.useRef)(null),Ba=(0,i.useRef)(null),Ua=(0,i.useRef)({}),Ka=(0,i.useRef)({}),Ha=(0,i.useRef)(null),Wa=(0,i.useRef)(null),Ga=(0,i.useRef)(Et);Ga.current=Et;const Ja=(0,i.useRef)(da);
1Ja.current=da;const Ya=(0,i.useRef)(xa);Ya.current=xa;const Xa=(0,i.useRef)({});Xa.current={onGift:h,onWalletUpdate:c,onSystem:p,onReaction:b};const Za=(0,i.useRef)(null),Qa=(0,i.useRef)(null),$a=(0,i.useRef)(0),en=(0,i.useRef)(!1),tn=(0,i.useRef)(null),an=(0,i.useRef)(null),nn=(0,i.useRef)(null),sn=(0,i.useRef)(!1),rn=(0,i.useRef)({}),ln=(0,i.useRef)(0),on=(0,i.useRef)(0),cn=(0,i.useRef)(0),dn=(0,i.useRef)(0),un=(0,i.useRef)(null),mn=(0,i.useRef)(null),hn=(0,i.useRef)(null),xn=(0,i.useRef)(null),pn=(0,i.useRef)(null),fn=(0,i.useRef)(!1),gn=(0,i.useCallback)(e=>{const t=Na.current;t&&t.readyState===WebSocket.OPEN&&t.send(JSON.stringify(e))},[]),vn=(0,i.useCallback)(e=>{e&&(et(t=>{const a=new Set(t);return a.add(e),a}),clearTimeout(rn.current[e]),rn.current[e]=setTimeout(()=>{et(t=>{const a=new Set(t);return a.delete(e),a})},4e3))},[]),bn=(0,i.useCallback)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"lobby",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;const a=Date.now();a-ln.current<2e3||(ln.current=a,gn({type:"typing",scope:e,to:t}))},[gn]),wn=(0,i.useCallback)(e=>{var t,a;const n=Ca.current;if(!n)return;const s="active"===(null===(t=Ga.current)||void 0===t?void 0:t.status)||"active"===(null===(a=Yt.current)||void 0===a?void 0:a.status);n.getVideoTracks().forEach(t=>t.enabled=!!s||!!e.video),n.getAudioTracks().forEach(t=>t.enabled=!!s||!!e.audio)},[]),jn=(0,i.useCallback)((e,t)=>{if(Ua.current[e])return;const a=Ka.current[e]||0;a>=6||(Ua.current[e]=setTimeout(()=>{var t;delete Ua.current[e];const n=Aa.current[e];if(!n)return;const s=n.iceConnectionState;"connected"!==s&&"completed"!==s?(Ka.current[e]=a+1,null===(t=Ha.current)||void 0===t||t.call(Ha,e)):Ka.current[e]=0},t))},[]),yn=(0,i.useCallback)((e,t)=>{if(Aa.current[e])return Aa.current[e];const a=new RTCPeerConnection(_a.current);a._initiator=t,Aa.current[e]=a;const s=Ca.current;if(s&&s.getTracks().length){if(s.getTracks().forEach(t=>{const n=a.addTrack(t,s);if("video"===t.kind){if(Da.current.set(e,n),La.current)try{n.replaceTrack(null)}catch(i){}}else if("audio"===t.kind&&(Ia.current.set(e,n),La.current))try{n.replaceTrack(null)}catch(r){}}),!s.getVideoTracks().length)try{a.addTransceiver("video",{direction:"recvonly"})}catch(i){}}else try{a.addTransceiver("video",{direction:"recvonly"}),a.addTransceiver("audio",{direction:"recvonly"})}catch(r){}return a.onicecandidate=t=>{t.candidate&&gn({type:"rtc-ice",to:e,data:t.candidate})},a.oniceconnectionstatechange=async()=>{const t=a.iceConnectionState;if("connected"===t||"completed"===t)Ka.current[e]=0,a._iceRestarted=!1,Ua.current[e]&&(clearTimeout(Ua.current[e]),delete Ua.current[e]);else if("failed"===t)if(a._iceRestarted)jn(e,800);else{a._iceRestarted=!0;try{if(a._initiator)if("function"===typeof a.restartIce)a.restartIce();else{const t=await a.createOffer({iceRestart:!0});await a.setLocalDescription(t),gn({type:"rtc-offer",to:e,data:a.localDescription})}}catch(n){}jn(e,4e3)}else"disconnected"===t&&jn(e,6e3)},a.ontrack=t=>{const a=t.streams[0];C(t=>t[e]?(0,n.A)((0,n.A)({},t),{},{[e]:(0,n.A)((0,n.A)({},t[e]),{},{stream:a})}):t)},t&&(a.onnegotiationneeded=async()=>{try{const t=await a.createOffer();await a.setLocalDescription(t),gn({type:"rtc-offer",to:e,data:a.localDescription})}catch(t){}}),setTimeout(()=>{var e;return null===(e=un.current)||void 0===e?void 0:e.call(un)},0),a},[gn,jn]),kn=(0,i.useCallback)(async(e,t)=>{const a=Aa.current[e];if(a&&["failed","closed"].includes(a.connectionState||a.iceConnectionState)){try{a.close()}catch(s){}delete Aa.current[e],Da.current.delete(e),Ia.current.delete(e)}const n=yn(e,!1);try{await n.setRemoteDescription(new RTCSessionDescription(t));const a=await n.createAnswer();await n.setLocalDescription(a),gn({type:"rtc-answer",to:e,data:n.localDescription})}catch(i){}},[yn,gn]),Nn=(0,i.useCallback)(e=>{const t=Aa.current[e];if(t){try{t.close()}catch(a){}delete Aa.current[e]}Da.current.delete(e),Ia.current.delete(e),Ua.current[e]&&(clearTimeout(Ua.current[e]),delete Ua.current[e]),delete Ka.current[e],C(t=>{const a=(0,n.A)({},t);return delete a[e],a})},[]),An=(0,i.useCallback)(e=>{const t=Aa.current[e];if(t){try{t.close()}catch(s){}delete Aa.current[e]}Da.current.delete(e),Ia.current.delete(e),C(t=>t[e]?(0,n.A)((0,n.A)({},t),{},{[e]:(0,n.A)((0,n.A)({},t[e]),{},{stream:null})}):t);const a=String(r||"")<String(e);yn(e,a)},[yn,r]);Ha.current=An;const Fn=(0,i.useCallback)(e=>{if(!e)return;const t=Aa.current[e];if(t){try{t.close()}catch(a){}delete Aa.current[e]}Da.current.delete(e),Ia.current.delete(e),C(t=>t[e]?(0,n.A)((0,n.A)({},t),{},{[e]:(0,n.A)((0,n.A)({},t[e]),{},{stream:null})}):t),yn(e,!0)},[yn]),_n=(0,i.useCallback)(e=>{const t=new RTCPeerConnection(Fa.current);Ba.current=t;const a=Ca.current;
1if(a){if(a.getTracks().forEach(e=>t.addTrack(e,a)),!a.getVideoTracks().length)try{t.addTransceiver("video",{direction:"recvonly"})}catch(s){}}else try{t.addTransceiver("video",{direction:"recvonly"}),t.addTransceiver("audio",{direction:"recvonly"})}catch(i){}return t.onicecandidate=t=>{t.candidate&&gn({type:"call-ice",to:e,data:t.candidate})},t.ontrack=e=>{const t=e.streams[0];Tt(e=>"idle"===e.status?e:(0,n.A)((0,n.A)({},e),{},{stream:t}))},setTimeout(()=>{var e;return null===(e=un.current)||void 0===e?void 0:e.call(un)},0),t},[gn]),Cn=(0,i.useCallback)(()=>{if(Wa.current&&(clearTimeout(Wa.current),Wa.current=null),Ba.current){try{Ba.current.close()}catch(e){}Ba.current=null}Tt({status:"idle",peer:null,stream:null})},[]),Sn=(0,i.useCallback)((e,t)=>{const a=Zt.current[e]||{info:{},stream:null},s=t.info?(0,n.A)((0,n.A)({},a.info||{}),t.info):a.info,i=(0,n.A)((0,n.A)((0,n.A)({},a),t),{},{info:s});Zt.current=(0,n.A)((0,n.A)({},Zt.current),{},{[e]:i}),Kt((0,n.A)({},Zt.current))},[]),Rn=(0,i.useCallback)(e=>{const t=(0,n.A)({},Zt.current);delete t[e],Zt.current=t,Kt((0,n.A)({},t))},[]),En=(0,i.useCallback)(e=>{Qt.current=e,Jt((0,n.A)({},e))},[]),Tn=(0,i.useState)(!1),Mn=(0,s.A)(Tn,2),Pn=Mn[0],Dn=Mn[1],In=(0,i.useState)(null),Ln=(0,s.A)(In,2),zn=Ln[0],Vn=Ln[1],On=(0,i.useRef)(null),qn=(0,i.useRef)(null),Bn=(0,i.useRef)(null),Un=(0,i.useCallback)(e=>{if(Xt.current[e])return Xt.current[e];const t=new RTCPeerConnection(Fa.current);Xt.current[e]=t;const a=Ca.current;if(a){if(a.getTracks().forEach(e=>t.addTrack(e,a)),!a.getVideoTracks().length)try{t.addTransceiver("video",{direction:"recvonly"})}catch(n){}}else try{t.addTransceiver("video",{direction:"recvonly"}),t.addTransceiver("audio",{direction:"recvonly"})}catch(s){}if(t.onicecandidate=t=>{t.candidate&&gn({type:"gcall-ice",to:e,call_id:Yt.current.callId,data:t.candidate})},t.ontrack=t=>{const a=t.streams[0];Sn(e,{stream:a})},On.current){const e=t.getSenders().find(e=>e.track&&"video"===e.track.kind);if(e)try{e.replaceTrack(On.current)}catch(i){}}return setTimeout(()=>{var e;return null===(e=un.current)||void 0===e?void 0:e.call(un)},0),t},[gn,Sn]),Kn=(0,i.useCallback)(async e=>{const t=Un(e),a=await t.createOffer();await t.setLocalDescription(a),gn({type:"gcall-offer",to:e,call_id:Yt.current.callId,data:t.localDescription})},[Un,gn]),Hn=(0,i.useCallback)(e=>{const t=Xt.current[e];if(t){try{t.close()}catch(a){}delete Xt.current[e]}setTimeout(()=>{var e;return null===(e=un.current)||void 0===e?void 0:e.call(un)},0)},[]),Wn=(0,i.useCallback)(()=>{if(On.current){try{On.current.stop()}catch(e){}On.current=null}qn.current=null,Vn(null),Dn(!1),Object.values($t.current).forEach(e=>{try{clearTimeout(e)}catch(t){}}),$t.current={},Object.values(Xt.current).forEach(e=>{try{e.close()}catch(t){}}),Xt.current={},Zt.current={},Qt.current={},Kt({}),Jt({}),Ot({status:"idle",callId:null,incoming:null})},[]),Gn=(0,i.useCallback)(()=>{const e=qn.current;if(Object.values(Xt.current).forEach(t=>{const a=t.getSenders().find(e=>e.track&&"video"===e.track.kind);if(a&&e)try{a.replaceTrack(e)}catch(n){}}),On.current){try{On.current.stop()}catch(t){}On.current=null}qn.current=null,Vn(null),Dn(!1)},[]);Bn.current=Gn;const Jn=(0,i.useCallback)(async()=>{var e,t;if("active"!==Yt.current.status)return;if(On.current)return void Gn();let a;try{a=await navigator.mediaDevices.getDisplayMedia({video:!0})}catch(i){return}const n=a.getVideoTracks()[0];if(!n)return;On.current=n,qn.current=(null===(e=Ca.current)||void 0===e||null===(t=e.getVideoTracks)||void 0===t?void 0:t.call(e)[0])||null;let s=0;Object.values(Xt.current).forEach(e=>{const t=e.getSenders().find(e=>e.track&&"video"===e.track.kind);if(t)try{t.replaceTrack(n),s++}catch(a){}}),Vn(new MediaStream([n])),Dn(!0),n.onended=()=>{var e;null===(e=Bn.current)||void 0===e||e.call(Bn)},0!==s||qn.current||u.oR.info("Limen kamera w anvan pou pataje ekran an rive kot l\xf2t moun yo")},[Gn]),Yn=(0,i.useCallback)(()=>{"active"===Yt.current.status&&0===Object.keys(Zt.current).length&&0===Object.keys(Qt.current).length&&(Wn(),u.oR.info("Ap\xe8l la fini"))},[Wn]),Xn=(0,i.useCallback)((e,t)=>{En((0,n.A)((0,n.A)({},Qt.current),{},{[t.user_id]:t}));const a=Object.entries(Zt.current).map(e=>{var t,a;let n=(0,s.A)(e,2),i=n[0],r=n[1];return{user_id:i,name:null===(t=r.info)||void 0===t?void 0:t.name,picture:null===(a=r.info)||void 0===a?void 0:a.picture}});gn({type:"gcall-invite",to:t.user_id,call_id:e,members:a});try{clearTimeout($t.current[t.user_id])}catch(i){}$t.current[t.user_id]=setTimeout(()=>{if(Qt.current[t.user_id]&&!Zt.current[t.user_id]){gn({type:"gcall-cancel",to:t.user_id,call_id:e});const a=(0,n.A)({},Qt.current);delete a[t.user_id],En(a),u.oR.info("".concat(t.name||"Moun nan"," pa reponn")),Yn()}},35e3)},[gn,En,Yn]),Zn=(0,i.useCallback)(e=>{var t,a;if(o)return void u.oR.error("Envite pa ka rele ak kamera");if(!e||e.user_id===r)return;if(!Ca.current)return void u.oR.error("Limen kamera w pou w ka rele");if("idle"!==Yt.current.status||"idle"!==Ga.current.status||Ja.current)return void u.oR.error("Ou nan yon ap\xe8l deja");
1Ca.current.getVideoTracks().forEach(e=>e.enabled=!0),Ca.current.getAudioTracks().forEach(e=>e.enabled=!0);const n=(null===(t=window.crypto)||void 0===t||null===(a=t.randomUUID)||void 0===a?void 0:a.call(t))||"gc_".concat(Date.now(),"_").concat(Math.random().toString(36).slice(2));Zt.current={},Kt({}),Qt.current={},Jt({}),Ot({status:"active",callId:n,incoming:null}),Xn(n,e)},[o,r,Xn]),Qn=(0,i.useCallback)(e=>{if(!e||e.user_id===r)return;if("active"!==Yt.current.status)return void Zn(e);if(Zt.current[e.user_id]||Qt.current[e.user_id])return void u.oR.info("Moun sa a deja nan ap\xe8l la");Object.keys(Zt.current).length+Object.keys(Qt.current).length>=6?u.oR.error("Ap\xe8l la plen (maks 7 moun)"):Xn(Yt.current.callId,e)},[r,Zn,Xn]),$n=(0,i.useCallback)(()=>{const e=Yt.current.incoming;if(!e)return;if(!Ca.current)return gn({type:"gcall-decline",to:e.from.user_id,call_id:e.call_id}),Wn(),void u.oR.error("Limen kamera w pou w ka aksepte");Ca.current.getVideoTracks().forEach(e=>e.enabled=!0),Ca.current.getAudioTracks().forEach(e=>e.enabled=!0);const t=e.call_id,a=[e.from,...e.members||[]].filter(e=>e&&e.user_id&&e.user_id!==r),s={};Zt.current={},a.forEach(e=>{s[e.user_id]||(s[e.user_id]=1,Zt.current[e.user_id]={info:{name:e.name,picture:e.picture},stream:null})}),Kt((0,n.A)({},Zt.current)),Ot({status:"active",callId:t,incoming:null}),Object.keys(Zt.current).forEach(e=>{gn({type:"gcall-join",to:e,call_id:t}),String(r)<String(e)&&Kn(e)})},[r,gn,Wn,Kn]),es=(0,i.useCallback)(()=>{const e=Yt.current.incoming;e&&gn({type:"gcall-decline",to:e.from.user_id,call_id:e.call_id}),Ot(e=>({status:"active"===e.status?"active":"idle",callId:e.callId,incoming:null}))},[gn]),ts=(0,i.useCallback)(()=>{const e=Yt.current.callId;Object.keys(Zt.current).forEach(t=>gn({type:"gcall-leave",to:t,call_id:e})),Wn()},[gn,Wn]),as=(0,i.useCallback)(e=>{if("active"===Yt.current.status){if(Qt.current[e]){const a=(0,n.A)({},Qt.current);delete a[e],En(a);try{clearTimeout($t.current[e])}catch(t){}}Zt.current[e]&&(Hn(e),Rn(e)),Yn()}},[Hn,Rn,En,Yn]),ns=(0,i.useCallback)(e=>{if(o)return void gn({type:"gcall-decline",to:e.from.user_id,call_id:e.call_id});if("idle"!==Ga.current.status||Ja.current)return void gn({type:"gcall-decline",to:e.from.user_id,call_id:e.call_id,reason:"busy"});const t=Yt.current;"active"===t.status&&t.callId===e.call_id||("idle"===t.status?Ca.current?Ot({status:"ringing-in",callId:null,incoming:{call_id:e.call_id,from:e.from,members:e.members||[]}}):gn({type:"gcall-decline",to:e.from.user_id,call_id:e.call_id}):gn({type:"gcall-decline",to:e.from.user_id,call_id:e.call_id,reason:"busy"}))},[o,gn]),ss=(0,i.useCallback)(e=>{const t=Yt.current;if("active"!==t.status||t.callId!==e.call_id)return;const a=e.from;if(a&&a.user_id!==r){if(Qt.current[a.user_id]){const e=(0,n.A)({},Qt.current);delete e[a.user_id],En(e);try{clearTimeout($t.current[a.user_id])}catch(s){}}Sn(a.user_id,{info:{name:a.name,picture:a.picture}}),String(r)<String(a.user_id)&&Kn(a.user_id)}},[r,Sn,En,Kn]),is=(0,i.useCallback)(async e=>{const t=Yt.current;if("active"!==t.status||t.callId!==e.call_id)return;const a=e.from;Zt.current[a]||Sn(a,{info:{}});const n=Un(a);await n.setRemoteDescription(new RTCSessionDescription(e.data));const s=await n.createAnswer();await n.setLocalDescription(s),gn({type:"gcall-answer",to:a,call_id:t.callId,data:n.localDescription})},[Un,gn,Sn]),rs=(0,i.useCallback)(async e=>{const t=Xt.current[e.from];if(t)try{await t.setRemoteDescription(new RTCSessionDescription(e.data))}catch(a){}},[]),ls=(0,i.useCallback)(async e=>{const t=Xt.current[e.from];if(t)try{await t.addIceCandidate(new RTCIceCandidate(e.data))}catch(a){}},[]),os=(0,i.useCallback)(e=>{const t=e.from;if(Qt.current[t]){const e=(0,n.A)({},Qt.current);delete e[t],En(e);try{clearTimeout($t.current[t])}catch(a){}}u.oR.info("busy"===e.reason?"Moun nan nan yon l\xf2t ap\xe8l":"Moun nan refize ap\xe8l la"),Yn()},[En,Yn]),cs=(0,i.useCallback)(e=>{var t,a,n;const s=Yt.current;"ringing-in"===s.status&&(null===(t=s.incoming)||void 0===t?void 0:t.call_id)===e.call_id&&(null===(a=s.incoming)||void 0===a||null===(n=a.from)||void 0===n?void 0:n.user_id
1)===e.from&&(Ot({status:"idle",callId:null,incoming:null}),u.oR.info("Ap\xe8l la anile"))},[]),ds=(0,i.useCallback)(e=>{var t,a;const n=Yt.current;if("active"!==n.status||n.callId!==e.call_id)return;const s=e.from,i=null===(t=Zt.current[s])||void 0===t||null===(a=t.info)||void 0===a?void 0:a.name;Hn(s),Rn(s),i&&u.oR.info("".concat(i," kite ap\xe8l la")),0===Object.keys(Zt.current).length&&0===Object.keys(Qt.current).length&&(Wn(),u.oR.info("Ap\xe8l la fini"))},[Hn,Rn,Wn]);(0,i.useEffect)(()=>{let e=!1;return async function(){try{var t;try{const e=await fetch("".concat(d.fn,"/api/rtc/ice"),{headers:{Authorization:"Bearer ".concat((0,d.gf)())}});if(e.ok){const t=await e.json();Array.isArray(t.ice_servers)&&t.ice_servers.length&&(Fa.current=(0,n.A)({iceServers:t.ice_servers},j)),Array.isArray(t.lobby_ice_servers)&&t.lobby_ice_servers.length?_a.current=(0,n.A)({iceServers:t.lobby_ice_servers},j):Array.isArray(t.ice_servers)&&t.ice_servers.length&&(_a.current=(0,n.A)({iceServers:t.ice_servers},j))}}catch(c){}try{const e=await fetch("".concat(d.fn,"/api/polls/current"),{headers:{Authorization:"Bearer ".concat((0,d.gf)())}});if(e.ok){const t=await e.json();ot(t.poll||null),mt(t.my_votes||[])}}catch(h){}if(o)throw new Error("guest-no-media");const a=localStorage.getItem("htv_camera"),s=localStorage.getItem("htv_mic");let i;try{i=await navigator.mediaDevices.getUserMedia({video:!a||{deviceId:{ideal:a}},audio:!s||{deviceId:{ideal:s}}})}catch(p){const e=p&&("NotAllowedError"===p.name||"SecurityError"===p.name);try{i=await navigator.mediaDevices.getUserMedia({video:!1,audio:!s||{deviceId:{ideal:s}}})}catch(g){i=new MediaStream}e?u.oR.error("\ud83c\udfa5 Kamera w bloke pou sit sa a. Sou iPhone: peze 'aA'/ik\xf2n kadna nan ba adr\xe8s Safari \u2192 'Reglaj pou Sit Web' \u2192 Kamera \u2192 'Otorize', oswa Anrejistreman \u2192 Safari \u2192 Kamera. Answit rechaje paj la.",{duration:15e3}):u.oR.info("Kamera pa disponib \u2014 n ap itilize mikwo w s\xe8lman")}if(e)return void i.getTracks().forEach(e=>e.stop());Ca.current=i,T(i);const r=i.getVideoTracks()[0],l=i.getAudioTracks()[0];r&&(null===(t=hn.current)||void 0===t||t.call(hn,r)),Re(e=>{var t,a;return(0,n.A)((0,n.A)({},e),{},{camera:(null===r||void 0===r||null===(t=r.getSettings)||void 0===t?void 0:t.call(r).deviceId)||"",mic:(null===l||void 0===l||null===(a=l.getSettings)||void 0===a?void 0:a.call(l).deviceId)||""})}),js();const m=localStorage.getItem("htv_bg"),x=localStorage.getItem("htv_filter"),f=parseFloat(localStorage.getItem("htv_bright"))||1,v=parseFloat(localStorage.getItem("htv_contrast"))||1;(m&&"none"!==m||x&&"none"!==x||1!==f||1!==v)&&setTimeout(()=>{var e;return null===(e=qa.current)||void 0===e?void 0:e.call(qa)},500)}catch(v){Ca.current=null}try{const e=window.AudioContext||window.webkitAudioContext;if(e&&!tn.current){const t=new e,a=t.createOscillator(),n=t.createGain();n.gain.value=0,a.connect(n),n.connect(t.destination),a.start(),tn.current={ctx:t,osc:a}}}catch(b){}async function s(e){var t,a,s,i,l,c,d,h,p,g,v,b,w,j,y,k,N,A,F,_,S,R,E,T,M,P,D,L,z,V,q,B,U,H,W,G,Y,X,Z,$,ee,te,ne,se,ie,le,oe,ce,ue,me,he,pe;let fe;try{fe=JSON.parse(e.data)}catch(Ne){return}switch(fe.type){case"pong":case"approved":default:break;case"typing":fe.user_id&&fe.user_id!==r&&vn(fe.user_id);break;case"poll-update":ot(fe.poll||null);break;case"init":{var ge,be;O("admitted"),I(!0),(0,m.p)(fe.version);try{window.dispatchEvent(new Event("ws-live-sync"))}catch(Ae){}J(!!fe.is_host),Q(fe.cam_limit||9),ae(!!fe.stage_only),fe.room&&K(fe.room),Object.keys(Aa.current).forEach(e=>{try{Aa.current[e].close()}catch(t){}}),Aa.current={},Da.current.clear(),Ia.current.clear();const e={};(fe.peers||[]).forEach(t=>{e[t.user_id]={info:t,stream:null}}),C(e);const t={};(fe.peers||[]).forEach(e=>{e.ppv_available&&(t[e.user_id]=!0)}),ka(t);const a=(null===(ge=fe.self)||void 0===ge?void 0:ge.locked)||{video:!1,audio:!1};ye(a);const s=null===(be=fe.self)||void 0===be?void 0:be.media,i=s?{video:!!s.video,audio:!!s.audio}:{video:!1,audio:!1};de(i),wn(i),gn((0,n.A)({type:"media-state"}
1,i)),xe(!!fe.invisible),fe.is_host&&fe.pending&&re(fe.pending),na(fe.hands||[]);break}case"pending-approval":O("pending"),K(fe.room_name);break;case"denied":O("denied"),null===(t=(a=Xa.current).onSystem)||void 0===t||t.call(a,"denied",fe);break;case"kicked":O("kicked"),null===(s=(i=Xa.current).onSystem)||void 0===s||s.call(i,"kicked",fe);break;case"banned":O("banned"),null===(l=(c=Xa.current).onSystem)||void 0===l||l.call(c,"banned",fe);break;case"account-deleted":null===(d=(h=Xa.current).onSystem)||void 0===d||d.call(h,"account-deleted",fe);break;case"join-request":re(e=>[...e.filter(e=>e.user_id!==fe.user.user_id),fe.user]),null===(p=(g=Xa.current).onSystem)||void 0===p||p.call(g,"join-request",fe);break;case"join-cancel":re(e=>e.filter(e=>e.user_id!==fe.user_id));break;case"peer-joined":{const e=fe.peer;C(t=>(0,n.A)((0,n.A)({},t),{},{[e.user_id]:{info:e,stream:null}})),e.ppv_available&&ka(t=>(0,n.A)((0,n.A)({},t),{},{[e.user_id]:!0})),e.is_bot||yn(e.user_id,!0),e.is_bot||e.is_guest||(!function(){if(!x)try{const e=new Audio("/sounds/entry.m4a");e.volume=.85,e.play().catch(()=>{})}catch(e){}}(),(0,u.oR)("\ud83c\udf89 ".concat(e.name||"Yon moun"," antre nan lakou a")));break}case"peer-left":It(e=>{const t=(0,n.A)({},e);return delete t[fe.user_id],t}),ka(e=>{const t=(0,n.A)({},e);return delete t[fe.user_id],t}),(null===(v=Ga.current.peer)||void 0===v?void 0:v.user_id)===fe.user_id&&"idle"!==Ga.current.status&&(u.oR.info("Ap\xe8l la fini"),Cn()),as(fe.user_id),Nn(fe.user_id);break;case"media-state":fe.user_id===r&&(de(fe.media),wn(fe.media)),C(e=>e[fe.user_id]?(0,n.A)((0,n.A)({},e),{},{[fe.user_id]:(0,n.A)((0,n.A)({},e[fe.user_id]),{},{info:(0,n.A)((0,n.A)({},e[fe.user_id].info),{},{media:fe.media})})}):e);break;case"bot-cam":{const e=fe.user_id;C(t=>t[e]?(0,n.A)((0,n.A)({},t),{},{[e]:(0,n.A)((0,n.A)({},t[e]),{},{info:(0,n.A)((0,n.A)({},t[e].info),{},{media:(0,n.A)((0,n.A)({},t[e].info.media||{}),{},{video:!!fe.on}),locked:{video:!1,audio:!0},video_url:fe.on?fe.video_url:null})})}):t);break}case"status-changed":C(e=>e[fe.user_id]?(0,n.A)((0,n.A)({},e),{},{[fe.user_id]:(0,n.A)((0,n.A)({},e[fe.user_id]),{},{info:(0,n.A)((0,n.A)({},e[fe.user_id].info),{},{status:fe.status})})}):e);break;case"invisible-state":xe(!!fe.value),(0,u.oR)(fe.value?"\ud83d\udd75\ufe0f Ou envizib kounye a \u2014 l\xf2t moun pa w\xe8 ou":"\ud83d\udc41\ufe0f Ou vizib ank\xf2",{duration:4e3});break;case"peer-hidden":ve(e=>{const t=new Set(e);return t.add(fe.user_id),t}),Nn(fe.user_id);break;case"peer-unhidden":ve(e=>{const t=new Set(e);return t.delete(fe.user_id),t});break;case"kicked":u.oR.error("Yon modeat\xe8 mete w dey\xf2 nan lakou a");break;case"support-ticket":case"support-reply":case"pin-update":case"tv-lowerthird":case"tv-popup-open":case"jenipal-champ":case"live-ads":null===(b=(w=Xa.current).onSystem)||void 0===b||b.call(w,fe.type,fe);break;case"media-ack":de(fe.media),wn(fe.media),null!==(j=fe.media)&&void 0!==j&&j.video&&la(!1);break;case"hands":na(fe.hands||[]),la((fe.hands||[]).some(e=>e.user_id===r));break;case"invited-up":la(!1),null===(y=(k=Xa.current).onSystem)||void 0===y||y.call(k,"invited-up",fe);break;case"force-media":de(fe.media),ye(fe.locked||{video:!1,audio:!1}),wn(fe.media),null===(N=(A=Xa.current).onSystem)||void 0===N||N.call(A,"forced",fe);break;case"cam-limit":null===(F=(_=Xa.current).onSystem)||void 0===F||F.call(_,"cam-limit",fe);break;case"cam-blocked-competition":null===(S=(R=Xa.current).onSystem)||void 0===S||S.call(R,"cam-blocked-competition",fe);break;case"stage-only":ae(!!fe.enabled),null===(E=(T=Xa.current).onSystem)||void 0===E||E.call(T,"stage-only",fe);break;case"cam-request":null===(M=(P=Xa.current).onSystem)||void 0===M||M.call(P,"cam-request",fe);break;case"reaction":null===(D=(L=Xa.current).onReaction)||void 0===D||D.call(L,fe);break;case"payout-paid":case"payout-rejected":case"payout-proof-requested":null===(z=(V=Xa.current).onSystem)||void 0===z||z.call(V,fe.type,fe);break;case"media-reaction":case"media-comment":null===(q=(B=Xa.current).onSystem)||void 0===q||q.call(B,fe.type,fe);break;case"performer-approved":case"performer-rejected":case"performer-application":case"favorite-online":case"city-busy":case"new-post":case"post-reaction":case"post-comment":null===(U=(H=Xa.current).onSystem)||void 0===U||U.call(H,fe.type,fe);break;case"competition-start":case"competition-vote":case"competition-end":null===(W=(G=Xa.current).onSystem)||void 0===W||W.call(G,fe.type,fe);break;case"quiz-start":case"quiz-soon":case"quiz-won":case"quiz-timeout":case"quiz-closed":case"quiz-session-ended":null===(Y=(X=Xa.current).onSystem)||void 0===Y||Y.call(X,fe.type,fe);break;
1case"reward":null===(Z=($=Xa.current).onSystem)||void 0===Z||Z.call($,"reward",fe);break;case"notification":case"sportsfeed":case"live-list":case"guest-chat-count":case"guest-limit":case"live-ended":case"stage-restored":null===(ee=(te=Xa.current).onSystem)||void 0===ee||ee.call(te,fe.type,fe);break;case"force-refresh":(0,m.D)();break;case"session-replaced":en.current=!0,null===(ne=(se=Xa.current).onSystem)||void 0===ne||ne.call(se,"session-replaced",fe);try{Na.current&&Na.current.close()}catch(Fe){}break;case"rtc-offer":await kn(fe.from,fe.data);break;case"rtc-answer":{const e=Aa.current[fe.from];e&&await e.setRemoteDescription(new RTCSessionDescription(fe.data));break}case"rtc-ice":{const e=Aa.current[fe.from];if(e)try{await e.addIceCandidate(new RTCIceCandidate(fe.data))}catch(_e){}break}case"call-status":It(e=>(0,n.A)((0,n.A)({},e),{},{[fe.user_id]:!!fe.busy}));break;case"call-invite":if(o){gn({type:"call-decline",to:fe.from.user_id,reason:"guest-self"});break}if("idle"!==Ga.current.status||!Ca.current){gn({type:"call-decline",to:fe.from.user_id,reason:"busy"});break}Tt({status:"ringing-in",peer:fe.from,stream:null});break;case"call-accept":{const e=Ga.current;if("ringing-out"!==e.status||!e.peer)break;Wa.current&&(clearTimeout(Wa.current),Wa.current=null),Tt(e=>(0,n.A)((0,n.A)({},e),{},{status:"active"}));const t=_n(e.peer.user_id),a=await t.createOffer();await t.setLocalDescription(a),gn({type:"call-offer",to:e.peer.user_id,data:t.localDescription});break}case"call-decline":{var we;const e=(null===(we=Ga.current.peer)||void 0===we?void 0:we.name)||"Moun nan";"guest"===fe.reason?u.oR.info("Moun sa a se yon envite \u2014 li pa ka resevwa ap\xe8l"):"guest-self"===fe.reason?u.oR.error("Envite pa ka rele ak kamera"):"busy"===fe.reason?u.oR.info("".concat(e," nan yon l\xf2t ap\xe8l")):"offline"===fe.reason?u.oR.info("".concat(e," pa an liy")):u.oR.info("".concat(e," refize ap\xe8l la")),Cn();break}case"call-cancel":"ringing-in"===Ga.current.status&&(u.oR.info("Ap\xe8l la anile"),Cn());break;case"call-end":"idle"!==Ga.current.status&&(u.oR.info("Ap\xe8l la fini"),Cn());break;case"call-offer":{const e=Ga.current;if(!e.peer)break;const t=_n(e.peer.user_id);await t.setRemoteDescription(new RTCSessionDescription(fe.data));const a=await t.createAnswer();await t.setLocalDescription(a),gn({type:"call-answer",to:e.peer.user_id,data:t.localDescription});break}case"call-answer":Ba.current&&await Ba.current.setRemoteDescription(new RTCSessionDescription(fe.data));break;case"call-ice":if(Ba.current)try{await Ba.current.addIceCandidate(new RTCIceCandidate(fe.data))}catch(Ce){}break;case"gcall-invite":ns(fe);break;case"gcall-join":ss(fe);break;case"gcall-offer":await is(fe);break;case"gcall-answer":await rs(fe);break;case"gcall-ice":await ls(fe);break;case"gcall-decline":os(fe);break;case"gcall-cancel":cs(fe);break;case"gcall-leave":ds(fe);break;case"ppv-status":ka(e=>{const t=(0,n.A)({},e);return fe.available?t[fe.user_id]=!0:delete t[fe.user_id],t});break;case"ppv-available":ba(!!fe.available),"not-performer"===fe.error&&u.oR.error("Se admin ki dwe otorize w k\xf2m p\xe8f\xf2m\xe8");break;case"ppv-request":pa({from:fe.from,rate:fe.rate||20});break;case"ppv-declined":{const e=fe.reason;"insufficient"===e?u.oR.error("Ou bezwen omwen ".concat(fe.need||20," jeton pou k\xf2manse yon PPV")):"unavailable"===e?u.oR.info("P\xe8f\xf2m\xe8 sa a pa disponib pou PPV kounye a"):"offline"===e?u.oR.info("P\xe8f\xf2m\xe8 a pa an liy"):"busy"===e?u.oR.info("P\xe8f\xf2m\xe8 a nan yon l\xf2t sesyon PPV"):"guest"===e?u.oR.error("Envite pa ka mande yon PPV"):u.oR.info("P\xe8f\xf2m\xe8 a refize demann PPV la");break}case"ppv-start":var je,ke;if(null!=fe.balance&&(null===(je=(ke=Xa.current).onWalletUpdate)||void 0===je||je.call(ke,{tokens:fe.balance})),pa(null),Tt({status:"active",peer:fe.peer,stream:null}),ua({session_id:fe.session_id,role:fe.role,minute:fe.minute||1,rate:fe.rate||20,spent:fe.spent||0,earned:fe.earned||0,balance:fe.balance,grace:!1,peer:fe.peer}),"payer"===fe.role){const e=_n(fe.peer.user_id),t=await e.createOffer();await e.setLocalDescription(t),gn({type:"call-offer",to:fe.peer.user_id,data:e.localDescription})}break;case"ppv-tick":null!=fe.balance&&(null===(ie=(le=Xa.current).onWalletUpdate)||void 0===ie||ie.call(le,{tokens:fe.balance})),ua(e=>{var t,a,s;return e?(0,n.A)((0,n.A)({},e),{},{minute:fe.minute,spent:null!==(t=fe.spent)&&void 0!==t?t:e.spent,earned:null!==(a=fe.earned)&&void 0!==a?a:e.earned,balance:null!==(s=fe.balance)&&void 0!==s?s:e.balance,grace:!1}):e});break;case"ppv-grace":ua(e=>e?(0,n.A)((0,n.A)({},e),{},{grace:!0}):e),u.oR.warning("Jeton ou pr\xe8t pou fini \u2014 sesyon an ap f\xe8men nan ".concat(fe.seconds||15,"s si w pa achte plis"),{duration:9e3,action:(0,f.J)()?void 0:{label:"Achte jeton",onClick:()=>window.open("/wallet","_blank")}});break;case"ppv-ended":{const e=fe.reason;"insufficient"===e?u.oR.error("Sesyon PPV la fini \u2014 jeton pa ase"):"disconnect"===e?u.oR.info("Sesyon PPV la fini \u2014 koneksyon p\xe8di"):"offline"===e?u.oR.info("Sesyon PPV la pa t k
1a k\xf2manse"):"busy"===e?u.oR.info("P\xe8f\xf2m\xe8 a deja nan yon sesyon"):u.oR.info("Sesyon PPV la fini (".concat(fe.minutes||0," minit)")),ua(null),pa(null),"idle"!==Ga.current.status&&Cn();break}case"chat":{const e=fe.message;if("lobby"===e.scope)Pe(t=>[...t,e]);else if("channel"===e.scope)Be(t=>(0,n.A)((0,n.A)({},t),{},{[e.channel]:[...t[e.channel]||[],e]}));else{const t=e.from_id===r?e.to_id:e.from_id;ze(a=>(0,n.A)((0,n.A)({},a),{},{[t]:[...a[t]||[],e]}))}break}case"message-deleted":"lobby"===fe.scope?Pe(e=>e.filter(e=>e.id!==fe.id)):"channel"===fe.scope?Be(e=>(0,n.A)((0,n.A)({},e),{},{[fe.channel]:(e[fe.channel]||[]).filter(e=>e.id!==fe.id)})):ze(e=>(0,n.A)((0,n.A)({},e),{},{[fe.peer]:(e[fe.peer]||[]).filter(e=>e.id!==fe.id)}));break;case"message-reaction":{const e=e=>(e||[]).map(e=>e.id===fe.id?(0,n.A)((0,n.A)({},e),{},{reactions:fe.reactions}):e);"lobby"===fe.scope?Pe(t=>e(t)):"channel"===fe.scope?Be(t=>(0,n.A)((0,n.A)({},t),{},{[fe.channel]:e(t[fe.channel])})):ze(t=>(0,n.A)((0,n.A)({},t),{},{[fe.peer]:e(t[fe.peer])}));break}case"channel-count":We(e=>(0,n.A)((0,n.A)({},e),{},{[fe.channel]:fe.count}));break;case"channel-activity":Xe(e=>(0,n.A)((0,n.A)({},e),{},{[fe.channel]:(e[fe.channel]||0)+1}));break;case"chatrooms-updated":try{window.dispatchEvent(new CustomEvent("htv-chatrooms-updated",{detail:fe}))}catch(Se){}break;case"channel-cleared":Be(e=>(0,n.A)((0,n.A)({},e),{},{[fe.channel]:[]}));break;case"gift":null===(oe=(ce=Xa.current).onGift)||void 0===oe||oe.call(ce,fe),C(e=>{var t,a;const s=null===(t=fe.to)||void 0===t?void 0:t.user_id;return s&&e[s]?(0,n.A)((0,n.A)({},e),{},{[s]:(0,n.A)((0,n.A)({},e[s]),{},{info:(0,n.A)((0,n.A)({},e[s].info),{},{points:(e[s].info.points||0)+Math.max(1,Math.round(.1*((null===(a=fe.gift)||void 0===a?void 0:a.cost)||0)))})})}):e});break;case"wallet-update":case"points-update":null===(ue=(me=Xa.current).onWalletUpdate)||void 0===ue||ue.call(me,fe);break;case"vip-update":case"advertiser-update":null===(he=(pe=Xa.current).onSystem)||void 0===he||he.call(pe,fe.type,fe);break;case"error":"Room not found"===fe.message&&O("notfound")}}const i=()=>{if(e)return;const t=(0,d.gf)(),n=/Mobi|Android|iPhone|iPad|iPod|Tablet|Touch/i.test(navigator.userAgent)||(navigator.maxTouchPoints||0)>1,r=d.fn.replace(/^http/,"ws")+"/api/ws?token="+encodeURIComponent(t||"")+"&room="+encodeURIComponent(a||"lobby")+"&device="+(n?"mobile":"desktop"),l=new WebSocket(r);Na.current=l,l.onopen=()=>{I(!0),$a.current=0,Za.current&&clearInterval(Za.current),Za.current=setInterval(()=>{l.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"}))},2e4)},l.onclose=()=>{if(I(!1),Za.current&&(clearInterval(Za.current),Za.current=null),e||en.current)return;$a.current=Math.min($a.current+1,6);const t=Math.min(1e3*2**($a.current-1),15e3);Qa.current&&clearTimeout(Qa.current),Qa.current=setTimeout(i,t)},l.onerror=()=>{try{l.close()}catch(e){}},l.onmessage=s};i();const l=()=>{var t;if(e||en.current||"visible"!==document.visibilityState)return;null===(t=pn.current)||void 0===t||t.call(pn);const a=Na.current;a&&a.readyState!==WebSocket.CLOSED&&a.readyState!==WebSocket.CLOSING||(Qa.current&&clearTimeout(Qa.current),$a.current=0,i())};document.addEventListener("visibilitychange",l),window.addEventListener("online",l),an.current=()=>{document.removeEventListener("visibilitychange",l),window.removeEventListener("online",l)}}(),()=>{var t,a;if(e=!0,Za.current&&(clearInterval(Za.current),Za.current=null),Qa.current&&(clearTimeout(Qa.current),Qa.current=null),null===(t=an.current)||void 0===t||t.call(an),null===(a=xn.current)||void 0===a||a.call(xn),tn.current){try{tn.current.osc.stop(),tn.current.ctx.close()}catch(n){}tn.current=null}if(Object.keys(Aa.current).forEach(e=>{try{Aa.current[e].close()}catch(t){}}),Aa.current={},Object.values(Ua.current).forEach(e=>clearTimeout(e)),Ua.current={},Ka.current={},Wa.current&&(clearTimeout(Wa.current),Wa.current=null),Ba.current){try{Ba.current.close()}catch(s){}Ba.current=null}if(Na.current)try{Na.current.close()}catch(i){}if(Va.current){try{Va.current.stop()}catch(r){}Va.current=null}if(Pa.current){try{Pa.current.stop()}catch(l){}Pa.current=null}if(Hi.current){try{Hi.current.stop()}catch(o){}Hi.current=null}if(Ti.current){try{Ti.current.onended=null,Ti.current.pause(),Ti.current.removeAttribute("src"),Ti.current.load()}catch(c){}Ti.current=null}
1if(Mi.current){try{Mi.current.getTracks().forEach(e=>e.stop())}catch(d){}Mi.current=null}Ca.current&&Ca.current.getTracks().forEach(e=>e.stop())}},[]);const us=(0,i.useCallback)(function(e){let t=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:null,s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,i=arguments.length>8&&void 0!==arguments[8]?arguments[8]:null;return gn({type:"chat",text:e,scope:arguments.length>1&&void 0!==arguments[1]?arguments[1]:"lobby",to:arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,channel:arguments.length>7&&void 0!==arguments[7]?arguments[7]:null,font:null===t||void 0===t?void 0:t.font,color:null===t||void 0===t?void 0:t.color,bold:null===t||void 0===t?void 0:t.bold,italic:null===t||void 0===t?void 0:t.italic,image_url:a,audio_url:n,video_url:s,reply_to:i})},[gn]),ms=(0,i.useCallback)(e=>gn({type:"delete-message",id:e}),[gn]),hs=(0,i.useCallback)((e,t)=>gn({type:"chat-react",id:e,emoji:t}),[gn]),xs=(0,i.useCallback)(e=>gn({type:"set-invisible",value:!!e}),[gn]),ps=(0,i.useCallback)(e=>gn({type:"join-channel",channel:e}),[gn]),fs=(0,i.useCallback)(e=>gn({type:"leave-channel",channel:e}),[gn]),gs=(0,i.useCallback)(()=>gn({type:"raise-hand"}),[gn]),vs=(0,i.useCallback)(()=>gn({type:"lower-hand"}),[gn]),bs=(0,i.useCallback)(e=>gn({type:"invite-up",user_id:e}),[gn]),ws=(0,i.useRef)(!1);(0,i.useEffect)(()=>{const e="idle"!==Et.status;e!==ws.current&&(ws.current=e,gn({type:"call-status",busy:e}))},[Et.status,gn]),(0,i.useEffect)(()=>{const e="active"===Et.status||"active"===Vt.status;var t,a,n,s;if(e&&!La.current)La.current=!0,za.current=Sa.current.video,Da.current.forEach(e=>{try{e.replaceTrack(null)}catch(t){}}),Ia.current.forEach(e=>{try{e.replaceTrack(null)}catch(t){}}),null===(t=Ca.current)||void 0===t||null===(a=t.getVideoTracks)||void 0===a||a.call(t).forEach(e=>e.enabled=!0),null===(n=Ca.current)||void 0===n||null===(s=n.getAudioTracks)||void 0===s||s.call(n).forEach(e=>e.enabled=!0),gn({type:"lobby-media",video:!1,audio:!1});else if(!e&&La.current){var i,r,l,o;La.current=!1;const e=(null===(i=Ca.current)||void 0===i||null===(r=i.getVideoTracks)||void 0===r?void 0:r.call(i)[0])||null,t=(null===(l=Ca.current)||void 0===l||null===(o=l.getAudioTracks)||void 0===o?void 0:o.call(l)[0])||null;Da.current.forEach(t=>{try{t.replaceTrack(e)}catch(a){}}),Ia.current.forEach(e=>{try{e.replaceTrack(t)}catch(a){}});const a={video:!1,audio:!1};de(a),wn(a),gn({type:"lobby-media",video:!1,audio:!1})}},[Et.status,Vt.status,gn,wn]);const js=(0,i.useCallback)(async()=>{try{const e=await navigator.mediaDevices.enumerateDevices();Fe({cameras:e.filter(e=>"videoinput"===e.kind),mics:e.filter(e=>"audioinput"===e.kind),speakers:e.filter(e=>"audiooutput"===e.kind)})}catch(e){}},[]),ys=(0,i.useCallback)(e=>{const t=Ca.current;t&&(t.getVideoTracks().forEach(e=>{t.removeTrack(e),e.stop()}),t.addTrack(e),T(new MediaStream(t.getTracks())),Object.values(Aa.current).forEach(t=>{const a=t.getSenders().find(e=>e.track&&"video"===e.track.kind);a&&a.replaceTrack(e).catch(()=>{})}),setTimeout(()=>{var e;return null===(e=un.current)||void 0===e?void 0:e.call(un)},0))},[]),ks=()=>{const e=localStorage.getItem("htv_camera"),t={width:{ideal:1280},height:{ideal:720},frameRate:{ideal:30}};return e?(0,n.A)({deviceId:{ideal:e}},t):t},Ns=async(e,t)=>{if(e)try{const a=e.getParameters();a.encodings&&a.encodings.length||(a.encodings=[{}]);const n=k[t]||k[0];a.encodings[0].maxBitrate=n.maxBitrate,a.encodings[0].scaleResolutionDownBy=n.scaleResolutionDownBy,a.encodings[0].maxFramerate=n.maxFramerate,a.degradationPreference="balanced",await e.setParameters(a)}catch(a){}},As=(0,i.useCallback)(async()=>{const e=Math.min(2,function(){const e=navigator.connection||navigator.mozConnection||navigator.webkitConnection;if(!e)return 0;const t=e.effectiveType;if("slow-2g"===t||"2g"===t)return 2;if("3g"===t)return 1;const a="number"===typeof e.downlink?e.downlink:null;if(null!==a){if(a<.7)return 2;if(a<1.6)return 1}return 0}()+(()=>{const e=Object.keys(Aa.current).length+Object.keys(Xt.current).length;return e>=6?2:e>=4?1:0})()+cn.current);on.current=e;const t=(()=>{const e=[];Da.current.forEach(t=>{t&&e.push(t)});const t=Ba.current;if(t){const a=t.getSenders().find(e=>e.track&&"video"===e.track.kind);a&&e.push(a)}return Object.values(Xt.current).forEach(t=>{const a=t.getSenders().find(e=>e.track&&"video"===e.track.kind);a&&e.push(a)}),e})();for(const a of t)await Ns(a,e)},[]);un.current=As;const Fs=(0,i.useCallback)(async()=>{const e=Object.values(Aa.current);if(Ba.current&&e.push(Ba.current),e.push(...Object.values(Xt.current)),!e.length)return;let t=0,a=!1,n=!1;
1for(const i of e)try{(await i.getStats()).forEach(e=>{"remote-inbound-rtp"!==e.type||"video"!==e.kind&&"video"!==e.mediaType||"number"!==typeof e.fractionLost||(n=!0,t=Math.max(t,e.fractionLost)),"candidate-pair"===e.type&&"succeeded"===e.state&&"number"===typeof e.availableOutgoingBitrate&&(n=!0,e.availableOutgoingBitrate<4e5&&(a=!0))})}catch(s){}n&&(t>.08||a?(cn.current=Math.min(2,cn.current+1),dn.current=0):t<.02&&!a&&(dn.current+=1,dn.current>=3&&(cn.current=Math.max(0,cn.current-1),dn.current=0)),await As())},[As]);(0,i.useEffect)(()=>{const e=setInterval(()=>{Fs()},4e3),t=navigator.connection||navigator.mozConnection||navigator.webkitConnection,a=()=>{As()};return t&&t.addEventListener&&t.addEventListener("change",a),()=>{clearInterval(e),t&&t.removeEventListener&&t.removeEventListener("change",a)}},[Fs,As]);const _s=e=>{const t=e.find(e=>e.id===Ta.current)||e[0],a=Ma.current.brightness,n=Ma.current.contrast;return"".concat(t.css," brightness(").concat(a,") contrast(").concat(n,")").trim()},Cs=()=>"none"!==Ta.current||1!==Ma.current.brightness||1!==Ma.current.contrast,Ss=e=>!!(e.find(e=>e.id===Ta.current)||{}).beauty,Rs=(0,i.useCallback)(async()=>{const e=Ra.current,t="none"!==e||Cs();try{var a,n;null===(a=xn.current)||void 0===a||a.call(xn),Va.current&&(Va.current.stop(),Va.current=null),Pa.current&&(Pa.current.stop(),Pa.current=null);const s=(await navigator.mediaDevices.getUserMedia({video:ks()})).getVideoTracks()[0];if(null===(n=hn.current)||void 0===n||n.call(hn,s),!t)return s.enabled=Sa.current.video,void ys(s);const i=await w(),r=i.BackgroundFX,l=i.CameraFilterFX,o=i.BACKGROUNDS,c=i.FILTERS,d="custom"===e?{id:"custom",url:Ea.current}:o.find(t=>t.id===e)||o[0],u=_s(c);if("none"!==e){const e=new r(s);await e.init(),e.setMode(d.url?"image":"blur"),e.setImage(d.url||null),e.setFilter(u);const t=e.start();t.enabled=Sa.current.video,Va.current=e,ys(t)}else{const e=new l(s);await e.init(),e.setFilter(u,Ss(c));const t=e.start();t.enabled=Sa.current.video,Pa.current=e,ys(t)}}catch(s){u.oR.error("Nou pa ka aplike ef\xe8 kamera a")}},[ys]);qa.current=Rs;const Es=(0,i.useCallback)(async e=>{ft(e.id),Ra.current=e.id,localStorage.setItem("htv_bg",e.id),await Rs()},[Rs]);Oa.current=Es;const Ts=(0,i.useCallback)(e=>{const t=e?e.startsWith("http")?e:"".concat(d.fn).concat(e):null;wt(t),Ea.current=t,t?localStorage.setItem("htv_bg_custom_url",t):localStorage.removeItem("htv_bg_custom_url")},[]),Ms=(0,i.useCallback)(async e=>{try{const t=new FormData;t.append("file",e,e.name||"background.jpg");const a=await fetch("".concat(d.fn,"/api/uploads/camera-bg"),{method:"POST",headers:{Authorization:"Bearer ".concat((0,d.gf)())},body:t});if(!a.ok)return u.oR.error("Echwe pandan chajman background la"),!1;const n=(await a.json()).url,s=n.startsWith("http")?n:"".concat(d.fn).concat(n);return Ts(s),ft("custom"),Ra.current="custom",localStorage.setItem("htv_bg","custom"),await Rs(),u.oR.success("Backgroun
1d pa w anrejistre!"),!0}catch(t){return u.oR.error("Echwe pandan chajman background la"),!1}},[Rs,Ts]),Ps=(0,i.useCallback)(async()=>{try{await fetch("".concat(d.fn,"/api/uploads/camera-bg"),{method:"DELETE",headers:{Authorization:"Bearer ".concat((0,d.gf)())}})}catch(e){}Ts(null),"custom"===Ra.current&&(ft("none"),Ra.current="none",localStorage.setItem("htv_bg","none"),await Rs())},[Rs,Ts]),Ds=(0,i.useCallback)(async()=>{if(!Va.current&&!Pa.current&&!Cs())return;const e=(await w()).FILTERS,t=_s(e);if(!Va.current)return Pa.current?Cs()?void Pa.current.setFilter(t,Ss(e)):void await Rs():void(Cs()&&await Rs());Va.current.setFilter(t)},[Rs]),Is=(0,i.useCallback)(async e=>{Nt(e),Ta.current=e,localStorage.setItem("htv_filter",e),await Ds()},[Ds]),Ls=(0,i.useCallback)(async e=>{Ct(e),Ma.current=e,localStorage.setItem("htv_bright",String(e.brightness)),localStorage.setItem("htv_contrast",String(e.contrast)),await Ds()},[Ds]),zs=(0,i.useCallback)(async e=>{localStorage.setItem("htv_camera",e),Re(t=>(0,n.A)((0,n.A)({},t),{},{camera:e})),await Rs(),js()},[Rs,js]),Vs=(0,i.useCallback)(async e=>{try{const t=(await navigator.mediaDevices.getUserMedia({audio:{deviceId:{exact:e}}})).getAudioTracks()[0];if(!t)return;t.enabled=Sa.current.audio;const a=Ca.current;a&&(a.getAudioTracks().forEach(e=>{a.removeTrack(e),e.stop()}),a.addTrack(t),T(new MediaStream(a.getTracks()))),Object.values(Aa.current).forEach(e=>{const a=e.getSenders().find(e=>e.track&&"audio"===e.track.kind);a&&a.replaceTrack(t).catch(()=>{})}),Re(t=>(0,n.A)((0,n.A)({},t),{},{mic:e})),localStorage.setItem("htv_mic",e),js()}catch(t){u.oR.error("Nou pa ka itilize mikwo sa a")}},[js]),Os=(0,i.useCallback)(e=>{Re(t=>(0,n.A)((0,n.A)({},t),{},{speaker:e})),localStorage.setItem("htv_speaker",e)},[]),qs=(0,i.useRef)(!1),Bs=(0,i.useCallback)(async()=>{var e,t;let a;try{a=await navigator.mediaDevices.getUserMedia({video:ks()})}catch(r){const e=r&&r.name;return"NotAllowedError"===e||"SecurityError"===e?u.oR.error("\ud83c\udfa5 Kamera w bloke pou sit sa a. Sou iPhone: peze bouton 'aA' (oswa ik\xf2n kadna) nan ba adr\xe8s Safari \u2192 'Reglaj pou Sit Web' \u2192 mete Kamera sou 'Otorize'. Oswa ale nan Anrejistreman \u2192 Safari \u2192 Kamera. Answit rechaje paj la.",{duration:15e3}):"NotReadableError"===e||"AbortError"===e?u.oR.error("Kamera w ap itilize pa yon l\xf2t aplikasyon. F\xe8men FaceTime/Kamera/Instagram elatriye epi reeseye.",{duration:12e3}):u.oR.error("Nou pa ka jwenn kamera w la \u2014 tcheke p\xe8misyon kamera nan navigat\xe8 a"),!1}const n=a.getVideoTracks()[0];if(!n)return a.getTracks().forEach(e=>{try{e.stop()}catch(t){}}),!1;n.enabled=!0,null===(e=xn.current)||void 0===e||e.call(xn),null===(t=hn.current)||void 0===t||t.call(hn,n);const i=Ca.current;return i?(i.getVideoTracks().forEach(e=>{try{i.removeTrack(e),e.stop()}catch(t){}}),i.addTrack(n),T(new MediaStream(i.getTracks()))):(Ca.current=a,T(a)),Object.entries(Aa.current).forEach(e=>{let t=(0,s.A)(e,2),a=t[0],i=t[1],r=Da.current.get(a);var l;if(r||(r=i.getSenders().find(e=>e.track&&"video"===e.track.kind)),r)try{r.replaceTrack(n)}catch(o){}else null===(l=Ha.current)||void 0===l||l.call(Ha,a)}),qs.current=!0,!0},[]),Us=(0,i.useCallback)(()=>{const e=mn.current;if(e){try{e.track.removeEventListener("ended",e.onended),e.track.removeEventListener("mute",e.onmute),e.track.removeEventListener("unmute",e.onunmute)}catch(t){}e.muteTimer&&(clearTimeout(e.muteTimer),e.muteTimer=null),mn.current=null}},[]);xn.current=Us;const Ks=(0,i.useCallback)(async()=>{if(Sa.current.video&&!nn.current&&!Ti.current&&"active"!==Ga.current.status&&"visible"===document.visibilityState&&!fn.current){fn.current=!0,qs.current=!1;try{"none"!==Ra.current||Cs()?await Rs():await Bs()}catch(e){}setTimeout(()=>{fn.current=!1},1500)}},[Rs,Bs]),Hs=(0,i.useCallback)(e=>{if(!e||"video"!==e.kind)return;Us();const t={track:e,muteTimer:null,onended:null,onmute:null,onunmute:null};t.onended=()=>{Ks()},t.onmute=()=>{t.muteTimer&&clearTimeout(t.muteTimer),t.muteTimer=setTimeout(()=>{(e.muted||"ended"===e.readyState)&&Ks()},3e3)},t.onunmute=()=>{t.muteTimer&&(clearTimeout(t.muteTimer),t.muteTimer=null)},e.addEventListener("ended",t.onended),e.addEventListener("mute",t.onmute),e.addEventListener("unmute",t.onunmute),mn.current=t},[Ks,Us]);hn.current=Hs;const Ws=(0,i.useCallback)(()=>
1{if(!Sa.current.video)return;if(nn.current||Ti.current)return;if("active"===Ga.current.status)return;const e=mn.current;e&&"ended"!==e.track.readyState&&!e.track.muted||Ks()},[Ks]);pn.current=Ws;const Gs=(0,i.useCallback)(async()=>{var e,t;if("active"===Ga.current.status)return void u.oR.error("Kamera w f\xe8men nan lakou pandan ap\xe8l videyo prive a");if(je.video)return void u.oR.error("\xd2ganizat\xe8 a dezaktive kamera w");const a=!Sa.current.video,s=null===(e=Ca.current)||void 0===e||null===(t=e.getVideoTracks)||void 0===t?void 0:t.call(e).some(e=>"live"===e.readyState);if(a&&!s&&!qs.current&&!nn.current&&!Ti.current)if(Va.current||Pa.current||Cs()||"none"!==Ra.current)await Rs(),qs.current=!0;else{if(!await Bs())return}const i=(0,n.A)((0,n.A)({},Sa.current),{},{video:!Sa.current.video});de(i),wn(i),gn((0,n.A)({type:"media-state"},i))},[je,wn,gn,Rs,Bs]),Js=(0,i.useCallback)(()=>{if(je.audio)return void u.oR.error("\xd2ganizat\xe8 a mete w an silans");const e=(0,n.A)((0,n.A)({},ce),{},{audio:!ce.audio});de(e),wn(e),gn((0,n.A)({type:"media-state"},e))},[ce,je,wn,gn]),Ys=(0,i.useCallback)(e=>{gn({type:"approve",user_id:e}),re(t=>t.filter(t=>t.user_id!==e))},[gn]),Xs=(0,i.useCallback)(e=>{gn({type:"deny",user_id:e}),re(t=>t.filter(t=>t.user_id!==e))},[gn]),Zs=(0,i.useCallback)(e=>{gn({type:"kick",user_id:e}),Nn(e)},[gn,Nn]),Qs=(0,i.useCallback)((e,t)=>gn((0,n.A)({type:"force-media",user_id:e},t)),[gn]),$s=(0,i.useCallback)(e=>gn({type:"request-cam",to:e}),[gn]),ei=(0,i.useCallback)(e=>gn({type:"reaction",emoji:e}),[gn]),ti=(0,i.useCallback)(async(e,t)=>{try{const a=await fetch("".concat(d.fn,"/api/polls/").concat(e,"/vote"),{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat((0,d.gf)())},body:JSON.stringify({option_id:t,device_id:N()})}),n=await a.json().catch(()=>({}));return a.ok?(ot(n.poll||null),mt(n.my_votes||[]),u.oR.success("V\xf2t ou anrejistre! \u2713"),!0):(u.oR.error(n.detail||"Nou pa ka anrejistre v\xf2t ou a"),!1)}catch(a){return u.oR.error("Er\xe8 rezo \u2014 eseye ank\xf2"),!1}},[]),ai=(0,i.useState)(!1),ni=(0,s.A)(ai,2),si=ni[0],ii=ni[1],ri=(0,i.useRef)(!1),li=(0,i.useRef)(null),oi=(0,i.useRef)(null),ci=(0,i.useRef)(null),di=(0,i.useRef)(null),ui=(0,i.useRef)(null),mi=(0,i.useRef)(1),hi=(0,i.useRef)(1),xi=(0,i.useState)(1),pi=(0,s.A)(xi,2),fi=pi[0],gi=pi[1],vi=(0,i.useState)(1),bi=(0,s.A)(vi,2),wi=bi[0],ji=bi[1],yi=(0,i.useState)(!1),ki=(0,s.A)(yi,2),Ni=ki[0],Ai=ki[1],Fi=(0,i.useCallback)(async()=>{if(nn.current)return!1;let e;try{e=await navigator.mediaDevices.getDisplayMedia({video:!0,audio:!0})}catch(c){return!1}const t=e.getVideoTracks()[0];if(!t)return!1;nn.current=t,sn.current=Sa.current.video;let a=t;try{const e=new v(t);e.mirror=ri.current,await e.init(),a=e.start()||t,li.current=e}catch(d){li.current=null,a=t}Da.current.forEach(e=>{try{e.replaceTrack(a)}catch(t){}});const s=Ca.current;s&&T(new MediaStream([a,...s.getAudioTracks()])),st(!0);const i=e.getAudioTracks()[0]||null;if(oi.current=i,Ai(!!i),i){var r,l;let e=i;const t=(null===(r=Ca.current)||void 0===r||null===(l=r.getAudioTracks)||void 0===l?void 0:l.call(r)[0])||null;try{const a=new(window.AudioContext||window.webkitAudioContext),n=a.createMediaStreamDestination(),s=a.createGain();if(s.gain.value=mi.current,a.createMediaStreamSource(new MediaStream([i])).connect(s).connect(n),di.current=s,t&&"live"===t.readyState){const e=a.createGain();e.gain.value=hi.current,a.createMediaStreamSource(new MediaStream([t])).connect(e).connect(n),ui.current=e}ci.current=a,e=n.stream.getAudioTracks()[0]||i}catch(u){e=i}Ia.current.forEach(t=>{try{t.replaceTrack(e)}catch(a){}})}const o=(0,n.A)((0,n.A)({},Sa.current),{},{video:!0,audio:!!i||Sa.current.audio,screen:!0,screen_audio:!!i}
1);return de(o),gn((0,n.A)({type:"media-state"},o)),t.onended=()=>{var e;null===(e=Ei.current)||void 0===e||e.call(Ei)},!0},[gn]),_i=(0,i.useCallback)(async()=>{var e,t,a,s;if(li.current){try{li.current.stop()}catch(c){}li.current=null}const i=nn.current;if(i){try{i.stop()}catch(d){}nn.current=null}if(oi.current){try{oi.current.stop()}catch(u){}oi.current=null}if(ci.current){try{ci.current.close()}catch(m){}ci.current=null}di.current=null,ui.current=null,Ai(!1);const r=(null===(e=Ca.current)||void 0===e||null===(t=e.getAudioTracks)||void 0===t?void 0:t.call(e)[0])||null;Ia.current.forEach(e=>{try{e.replaceTrack(r)}catch(t){}}),st(!1);const l=(null===(a=Ca.current)||void 0===a||null===(s=a.getVideoTracks)||void 0===s?void 0:s.call(a)[0])||null;Da.current.forEach(e=>{try{e.replaceTrack(l)}catch(t){}}),Ca.current&&T(new MediaStream(Ca.current.getTracks()));const o=(0,n.A)((0,n.A)({},Sa.current),{},{video:sn.current,screen:!1,screen_audio:!1});de(o),wn(o),gn((0,n.A)({type:"media-state"},o))},[gn,wn]),Ci=(0,i.useCallback)(e=>{const t=Math.max(0,Math.min(1,Number(e)));if(mi.current=t,gi(t),di.current)try{di.current.gain.value=t}catch(a){}},[]),Si=(0,i.useCallback)(e=>{const t=Math.max(0,Math.min(1,Number(e)));if(hi.current=t,ji(t),ui.current)try{ui.current.gain.value=t}catch(a){}},[]),Ri=(0,i.useCallback)(()=>{ii(e=>{var t;const a=!e;return ri.current=a,null===(t=li.current)||void 0===t||t.setMirror(a),a})},[]),Ei=(0,i.useRef)(null);Ei.current=_i;const Ti=(0,i.useRef)(null),Mi=(0,i.useRef)(null),Pi=(0,i.useRef)(null),Di=(0,i.useRef)([]),Ii=(0,i.useRef)(0),Li=(0,i.useRef)(!0),zi=(0,i.useState)(!1),Vi=(0,s.A)(zi,2),Oi=Vi[0],qi=Vi[1],Bi=(0,i.useCallback)((e,t)=>{const a=e.getVideoTracks()[0];if(!a)return!1;Mi.current=e,Da.current.forEach(e=>{try{e.replaceTrack(a)}catch(t){}});const n=t?e.getAudioTracks()[0]:null;n&&Ia.current.forEach(e=>{try{e.replaceTrack(n)}catch(t){}});const s=Ca.current,i=n?[n]:s?s.getAudioTracks():[];return T(new MediaStream([a,...i])),!0},[]),Ui=(0,i.useCallback)(async function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const a=(Array.isArray(e)?e:[e]).filter(Boolean);if(!a.length)return!1;if(Ti.current)try{Ti.current.onended=null,Ti.current.pause()}catch(l){}Di.current=a,Ii.current=0;const s=document.createElement("video");s.src=a[0],s.loop=1===a.length,s.playsInline=!0,s.crossOrigin="anonymous",s.muted=!t;try{await s.play()}catch(o){try{s.muted=!0,await s.play(),t=!1}catch(c){return!1}}let i;try{i=s.captureStream?s.captureStream():s.mozCaptureStream()}catch(d){return!1}if(Ti.current=s,Li.current=t,Pi.current=(0,n.A)({},Sa.current),a.length>1&&(s.onended=async()=>{if(Ti.current===s){Ii.current=(Ii.current+1)%Di.current.length;try{s.src=Di.current[Ii.current],s.currentTime=0,await s.play();const e=s.captureStream?s.captureStream():s.mozCaptureStream();Bi(e,Li.current)}catch(e){}}}),!Bi(i,t))return!1;qi(!0);const r=(0,n.A)((0,n.A)({},Sa.current),{},{video:!0,audio:!!t||Sa.current.audio});return de(r),gn((0,n.A)({type:"media-state"},r)),!0},[gn,Bi]),Ki=(0,i.useCallback)(async()=>{var e,t,a,s;if(Hi.current){try{Hi.current.stop()}catch(d){}Hi.current=null,Yi(!1)}const i=Ti.current;if(i){try{i.onended=null,i.pause(),i.removeAttribute("src"),i.load()}catch(u){}Ti.current=null}if(Mi.current){try{Mi.current.getTracks().forEach(e=>e.stop())}catch(m){}Mi.current=null}Di.current=[],Ii.current=0,qi(!1);const r=(null===(e=Ca.current)||void 0===e||null===(t=e.getVideoTracks)||void 0===t?void 0:t.call(e)[0])||null,l=(null===(a=Ca.current)||void 0===a||null===(s=a.getAudioTracks)||void 0===s?void 0:s.call(a)[0])||null;Da.current.forEach(e=>{try{e.replaceTrack(r)}catch(t){}}),Ia.current.forEach(e=>{try{e.replaceTrack(l)}catch(t){}}),Ca.current&&T(new MediaStream(Ca.current.getTracks()));const o=Pi.current||Sa.current,c=(0,n.A)((0,n.A)({},Sa.current),{},{video:o.video,audio:o.audio});de(c),wn(c),gn((0,n.A)({type:"media-state"},c))},[gn,wn]),Hi=(0,i.useRef)(null),Wi=(0,i.useState)(!1),Gi=(0,s.A)(Wi,2),Ji=Gi[0],Yi=Gi[1],Xi=(0,i.useState)("split"),Zi=(0,s.A)(Xi,2),Qi=Zi[0],$i=Zi[1],er=(0,i.useState)(!1),tr=(0,s.A)(er,2),ar=tr[0],nr=tr[1],sr=(0,i.useState)(!1),ir=(0,s.A)(sr,2),rr=ir[0],lr=ir[1],or=(0,i.useState)(!1),cr=(0,s.A)(or,2),dr=cr[0],ur=cr[1],mr=(0,i.useState)(1),hr=(0,s.A)(mr,2),xr=hr[0],pr=hr[1],fr=(0,i.useState)(1),gr=(0,s.A)(fr,2),vr=gr[0],br=gr[1],wr=(0,i.useRef)("split"),jr=(0,i.useRef)(!1),yr=(0,i.useRef)(!1),kr=(0,i.useRef)(!1),Nr=(0,i.useRef)(1),Ar=(0,i.useRef)(1),Fr=(0,i.useCallback)(async()=>{var e,t,a,s;if(!Ti.current)return u.oR.error("K\xf2manse yon videyo an bouk anvan"),!1;if(Hi.current)return!0;let i=Ca.current,r=(null===i||void 0===i||null===(e=i.getVideoTracks)||void 0===e?void 0:e.call(i)[0])||null,l=(null===i||void 0===i||null===(t=i.getAudioTracks)||void 0===t?void 0:t.call(i)[0])||null;if(!r)try{const e=await navigator.mediaDevices.getUserMedia({video:ks(),audio:!0});r=e.getVideoTracks()[0],l=l||e.getAudioTracks()[0],Ca.current?e.getTracks().forEac
1h(e=>{try{Ca.current.addTrack(e)}catch(t){}}):Ca.current=e}catch(p){return u.oR.error("Nou pa ka jwenn kamera a"),!1}r&&(r.enabled=!0);const o=(null===(a=Mi.current)||void 0===a||null===(s=a.getAudioTracks)||void 0===s?void 0:s.call(a)[0])||null,c=new g({camStream:new MediaStream([r,...l?[l]:[]]),loopVideoEl:Ti.current,loopAudioTrack:o});c.layout=wr.current,c.swap=jr.current,c.mirrorCam=yr.current,c.mirrorVid=kr.current,c.videoVolume=Nr.current,c.micVolume=Ar.current;try{await c.init()}catch(f){return u.oR.error("Nou pa ka k\xf2manse mikser la"),!1}const d=c.start(),m=d.videoTrack,h=d.audioTrack;if(!m){try{c.stop()}catch(v){}return!1}Hi.current=c,Da.current.forEach(e=>{try{e.replaceTrack(m)}catch(t){}}),h&&Ia.current.forEach(e=>{try{e.replaceTrack(h)}catch(t){}}),T(new MediaStream([m,...h?[h]:[]])),Yi(!0);const x=(0,n.A)((0,n.A)({},Sa.current),{},{video:!0,audio:!0});return de(x),gn((0,n.A)({type:"media-state"},x)),!0},[gn]),_r=(0,i.useCallback)(()=>{var e,t,a,n;const s=Hi.current;if(Hi.current=null,s)try{s.stop()}catch(c){}Yi(!1);const i=Mi.current,r=(null===i||void 0===i||null===(e=i.getVideoTracks)||void 0===e?void 0:e.call(i)[0])||null,l=Li.current?(null===i||void 0===i||null===(t=i.getAudioTracks)||void 0===t?void 0:t.call(i)[0])||null:(null===(a=Ca.current)||void 0===a||null===(n=a.getAudioTracks)||void 0===n?void 0:n.call(a)[0])||null;Da.current.forEach(e=>{try{e.replaceTrack(r)}catch(t){}}),Ia.current.forEach(e=>{try{e.replaceTrack(l)}catch(t){}});const o=[r,...l?[l]:[]].filter(Boolean);o.length&&T(new MediaStream(o))},[]),Cr=(0,i.useCallback)(e=>{var t;wr.current=e,$i(e),null===(t=Hi.current)||void 0===t||t.setLayout(e)},[]),Sr=(0,i.useCallback)(()=>{nr(e=>{var t;const a=!e;return jr.current=a,null===(t=Hi.current)||void 0===t||t.setSwap(a),a})},[]),Rr=(0,i.useCallback)(()=>{lr(e=>{var t;const a=!e;return yr.current=a,null===(t=Hi.current)||void 0===t||t.setMirrorCam(a),a})},[]),Er=(0,i.useCallback)(()=>{ur(e=>{var t;const a=!e;return kr.current=a,null===(t=Hi.current)||void 0===t||t.setMirrorVid(a),a})},[]),Tr=(0,i.useCallback)(e=>{var t;if(Nr.current=e,pr(e),null===(t=Hi.current)||void 0===t||t.setVideoVolume(e),Ti.current)try{Ti.current.volume=e}catch(a){}},[]),Mr=(0,i.useCallback)(e=>{var t;Ar.current=e,br(e),null===(t=Hi.current)||void 0===t||t.setMicVolume(e)},[]),Pr=(0,i.useCallback)(e=>{o?u.oR.error("Envite pa ka rele ak kamera"):Ca.current?"idle"===Ga.current.status?(Tt({status:"ringing-out",peer:e,stream:null}),gn({type:"call-invite",to:e.user_id}
1),Wa.current=setTimeout(()=>{"ringing-out"===Ga.current.status&&(gn({type:"call-cancel",to:e.user_id}),u.oR.info("".concat(e.name," pa reponn")),Cn())},3e4)):u.oR.error("Ou nan yon ap\xe8l deja"):u.oR.error("Limen kamera w pou w ka rele")},[o,gn,Cn]),Dr=(0,i.useCallback)(()=>{const e=Ga.current;if("ringing-in"===e.status&&e.peer){if(!Ca.current)return gn({type:"call-decline",to:e.peer.user_id}),void Cn();Tt(e=>(0,n.A)((0,n.A)({},e),{},{status:"active"})),gn({type:"call-accept",to:e.peer.user_id})}},[gn,Cn]),Ir=(0,i.useCallback)(()=>{const e=Ga.current;e.peer&&gn({type:"call-decline",to:e.peer.user_id}),Cn()},[gn,Cn]),Lr=(0,i.useCallback)(()=>{const e=Ga.current;e.peer&&gn({type:"ringing-out"===e.status?"call-cancel":"call-end",to:e.peer.user_id}),Cn()},[gn,Cn]),zr=(0,i.useCallback)(e=>{gn({type:"ppv-available",available:!!e})},[gn]),Vr=(0,i.useCallback)(e=>{o?u.oR.error("Envite pa ka mande yon PPV"):Ca.current?"idle"===Ga.current.status?(gn({type:"ppv-request",to:e.user_id}),u.oR.info("Demann PPV voye bay ".concat(e.name,"\u2026"))):u.oR.error("Ou nan yon ap\xe8l deja"):u.oR.error("Limen kamera w pou w ka k\xf2manse yon PPV")},[o,gn]),Or=(0,i.useCallback)(()=>{const e=Ya.current;if(e){if(!Ca.current)return gn({type:"ppv-decline",to:e.from.user_id}),pa(null),void u.oR.error("Limen kamera w pou w ka aksepte");gn({type:"ppv-accept",to:e.from.user_id}),pa(null)}},[gn]),qr=(0,i.useCallback)(()=>{const e=Ya.current;e&&gn({type:"ppv-decline",to:e.from.user_id}),pa(null)},[gn]),Br=(0,i.useCallback)(()=>{const e=Ja.current;e&&gn({type:"ppv-end",session_id:e.session_id}),ua(null),Cn()},[gn,Cn]);return{peers:_,localStream:E,connected:D,status:V,roomName:U,isHost:G,camLimit:Z,stageOnly:te,pendingRequests:ie,mediaState:ce,mediaLocked:je,lobbyMessages:Me,dmMessages:Le,setDmMessages:ze,setLobbyMessages:Pe,typingIds:$e,sendTyping:bn,poll:lt,myPollVotes:ut,votePoll:ti,channelMessages:qe,setChannelMessages:Be,channelCounts:He,setChannelCounts:We,channelActivity:Ye,setChannelActivity:Xe,joinChannel:ps,leaveChannel:fs,sendChat:us,deleteMessage:ms,reactChat:hs,setInvisible:xs,invisible:he,hiddenIds:ge,toggleVideo:Gs,toggleAudio:Js,approve:Ys,deny:Xs,kick:Zs,forceMedia:Qs,requestCam:$s,sendReaction:ei,devices:Ae,selectedDevices:Se,switchCamera:zs,switchMic:Vs,switchSpeaker:Os,refreshDevices:js,bgEffect:pt,applyBackground:Es,customBgUrl:bt,uploadBackground:Ms,removeBackground:Ps,setCustomBgUrl:Ts,filterEffect:kt,applyFilter:Is,adjust:_t,setCameraAdjust:Ls,call:Et,startCall:Pr,acceptCall:Dr,declineCall:Ir,endCall:Lr,busyPeers:Dt,gcall:Vt,gcParticipants:Ut,gcRinging:Gt,startGroupCall:Zn,addToGroupCall:Qn,acceptGroupCall:$n,declineGroupCall:es,leaveGroupCall:ts,gcScreenOn:Pn,gcScreenStream:zn,gcShareScreen:Jn,screenSharing:nt,startScreenShare:Fi,stopScreenShare:_i,screenHasAudio:Ni,screenPageVol:fi,screenMicVol:wi,setScreenPageVolume:Ci,setScreenMicVolume:Si,screenMirror:si,toggleScreenMirror:Ri,loopVideo:Oi,startLoopVideo:Ui,stopLoopVideo:Ki,mixActive:Ji,startMix:Fr,stopMix:_r,mixLayout:Qi,setMixLayout:Cr,mixSwap:ar,toggleMixSwap:Sr,mirrorCam:rr,toggleMirrorCam:Rr,mirrorVid:dr,toggleMirrorVid:Er,videoVolume:xr,setVideoVolume:Tr,micVolume:vr,setMicVolume:Mr,raisedHands:aa,handRaised:ra,raiseHand:gs,lowerHand:vs,inviteUp:bs,reconnectPeer:Fn,ppv:da,ppvIncoming:xa,ppvAvailable:va,ppvPeers:ya,setPpvAvailable:zr,requestPpv:Vr,acceptPpv:Or,declinePpv:qr,endPpv:Br}}var F=a(5684),_=a(629),C=a(4651),S=a(2489),R=a(8384),E=a(2629),T=a(6382),M=a(7118),P=a(9552),D=a(3677),I=a(86),L=a(292),z=a(4574),V=a(5699),O=a(5087),q=a(5381),B=a(9333),U=a(6229),K=a(3559),H=a(746),W=a(6210),G=a(1884),J=a(3946),Y=a(3325),X=a(579);function Z(e){var t;let a=e.info,n=e.stream,r=e.isSelf,l=e.muted,o=e.onGift,c=e.isHost,d=e.isMod,u=e.onMute,m=e.onToggleCam,h=e.onKick,x=e.onProfile,p=(e.onRequestCam,e.sinkId),f=e.fill,g=e.localMuted,v=e.localHidden,b=e.onLocalMute,w=e.onLocalHide,j=e.mirror,y=void 0===j||j,k=e.canFollow,N=void 0!==k&&k,A=e.isFollowing,F=void 0!==A&&A,Z=e.onToggleFollow,Q=e.followIconOnly,$=void 0!==Q&&Q,ee=e.onDemote,te=e.liveParticipant,ae=void 0!==te&&te,ne=e.onReconnect,se=e.speaking,ie=void 0!==se&&se,re=e.onSpotlight,le=e.voteInfo;const oe=(0,i.useRef)(null),ce=(0,i.useRef)(null),de=(0,i.useState)(!1),ue=(0,s.A)(de,2),me=ue[0],he=ue[1],xe=(0,i.useState)(!1),pe=(0,s.A)(xe,2),fe=pe[0],ge=pe[1],ve=a.media||{video:!0,audio:!0},be=(0,i.useState)(1),we=(0,s.A)(be,2),je=we[0],ye=we[1],ke=(0,i.useState)(0),Ne=(0,s.A)(ke,2),Ae=Ne[0],Fe=Ne[1],_e=(0,i.useRef)(null===le||void 0===le?void 0:le.isLeader);(0,i.useEffect)(()=>{const e=!(null===le||void 0===le||!le.isLeader);e&&!1===_e.current&&Fe(e=>e+1),_e.current=e},[null===le||void 0===le?void 0:le.isLeader]);const Ce=(0,i.useMemo)(()=>
1{if(!Ae)return[];const e=["#FFD700","#FF2A5F","#00F0FF","#22c55e","#a855f7","#ffffff"];return Array.from({length:18}).map(()=>({left:100*Math.random(),bg:e[Math.floor(Math.random()*e.length)],delay:.18*Math.random(),dur:1+.8*Math.random(),rot:540*(2*Math.random()-1),tx:70*(2*Math.random()-1)}))},[Ae]),Se=n&&ve.video&&!v,Re=!n&&!!a.video_url&&ve.video&&!v,Ee=!(!ve.video&&!ve.audio),Te=!!ve.audio&&!ve.video,Me=!!ve.screen,Pe=!!ve.screen_audio;(0,i.useEffect)(()=>{const e=oe.current;if(!e||!n)return;const t=t=>{var a;if(t){try{e.srcObject=null}catch(i){}e.srcObject=n}else e.srcObject!==n&&(e.srcObject=n);const s=null===(a=e.play)||void 0===a?void 0:a.call(e);s&&s.catch&&s.catch(()=>{})};t(r&&Se);const a=()=>t(!1);return e.addEventListener("loadedmetadata",a),n.addEventListener("addtrack",a),n.addEventListener("removetrack",a),()=>{e.removeEventListener("loadedmetadata",a),n.removeEventListener("addtrack",a),n.removeEventListener("removetrack",a)}},[n,Se,r]),(0,i.useEffect)(()=>{oe.current&&(oe.current.volume=je)},[je,n,Se]),(0,i.useEffect)(()=>{const e=oe.current;e&&p&&"function"===typeof e.setSinkId&&e.setSinkId(p).catch(()=>{})},[p,n,Se]),(0,i.useEffect)(()=>{const e=()=>{const e=document.fullscreenElement||document.webkitFullscreenElement;he(e===ce.current)};return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e)}},[]);return(0,X.jsxs)("div",{ref:ce,"data-testid":r?"video-tile-self":"video-tile-".concat(a.user_id
1),"data-speaking":ie?"true":"false",className:"group relative overflow-hidden rounded-2xl surface transition-all duration-150 ".concat(f?"h-full w-full min-h-0":"aspect-video"," ").concat(null!==le&&void 0!==le&&le.isLeader?"comp-leader-tile ring-2 ring-[#FFD700] shadow-[0_0_28px_rgba(255,215,0,0.65)]":ie&&ve.audio&&!g?"ring-2 ring-green-400 shadow-[0_0_22px_rgba(74,222,128,0.55)]":""),style:{background:"#0b0b12"},children:[ie&&ve.audio&&!g&&(0,X.jsx)("span",{className:"absolute left-3 bottom-3 z-10 flex h-6 w-6 items-center justify-center rounded-full bg-green-500 text-white shadow","data-testid":"speaking-indicator",children:(0,X.jsx)(_.A,{className:"h-3.5 w-3.5"})}),n&&(!r||Se)&&(0,X.jsx)("video",{ref:oe,autoPlay:!0,playsInline:!0,muted:l||g,className:"h-full w-full object-cover ".concat(Se?"":"hidden"),style:{transform:r&&y?"scaleX(-1)":"none"}}),Re&&(0,X.jsx)("video",{src:a.video_url,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,"data-testid":"bot-cam-video-".concat(a.user_id),className:"h-full w-full object-cover"}),!Se&&!Re&&(0,X.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-2",children:[(0,X.jsx)("img",{src:a.picture,alt:a.name,className:"h-20 w-20 rounded-full object-cover opacity-90 ring-2 ".concat(!r&&Te&&ie&&!g?"ring-green-400 shadow-[0_0_22px_rgba(74,222,128,0.65)] animate-pulse":"ring-white/10")}),!r&&Te&&(ie&&!g?(0,X.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-green-500 px-3 py-1 text-[11px] font-bold uppercase tracking-wide text-white shadow","data-testid":"mic-only-speaking-".concat(a.user_id
1),children:[(0,X.jsx)(_.A,{className:"h-3.5 w-3.5"})," Ap Pale"]}):(0,X.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-black/60 px-3 py-1 text-[11px] font-semibold text-white/70","data-testid":"mic-only-badge-".concat(a.user_id),children:[(0,X.jsx)(_.A,{className:"h-3.5 w-3.5"})," Mikwo s\xe8lman"]})),v&&!r&&(0,X.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-black/60 px-3 py-1 text-[11px] font-semibold text-white/70","data-testid":"local-hidden-badge-".concat(a.user_id),children:[(0,X.jsx)(C.A,{className:"h-3.5 w-3.5"})," Ou kache kamera sa a"]})]}),re&&(0,X.jsx)("button",{type:"button","data-testid":"spotlight-btn-".concat(r?"self":a.user_id),onClick:()=>re(a),title:"Peze pou gwosi kamera a","aria-label":"Spotlight",className:"absolute inset-0 cursor-zoom-in bg-transparent"}),le&&Ae>0&&(0,X.jsx)("div",{className:"pointer-events-none absolute inset-0 z-30 overflow-hidden","data-testid":"comp-confetti-".concat(a.user_id),children:Ce.map((e,t)=>(0,X.jsx)("span",{className:"confetti-piece",style:{left:"".concat(e.left,"%"),background:e.bg,"--cf-tx":"".concat(e.tx,"px"),"--cf-rot":"".concat(e.rot,"deg"),"--cf-dur":"".concat(e.dur,"s"),"--cf-delay":"".concat(e.delay,"s")}},t))},"cf-".concat(Ae)),(0,X.jsx)("div",{className:"absolute inset-x-0 top-0 bg-gradient-to-b from-black/85 to-transparent p-3",children:(0,X.jsxs)("div",{className:"flex min-w-0 items-center gap-2 pl-9",children:[(0,X.jsxs)("button",{onClick:()=>null===x||void 0===x?void 0:x(a),"data-testid":"tile-name-".concat(a.user_id
1),className:"flex min-w-0 items-center gap-1 truncate text-left font-semibold hover:underline ".concat((0,Y.oL)(a,!0)||"text-white"),children:["admin"===(0,Y.Lc)(a)&&(0,X.jsx)(S.A,{className:"h-3.5 w-3.5 flex-shrink-0 text-red-400","data-testid":"role-tile-admin-".concat(a.user_id)}),"moderator"===(0,Y.Lc)(a)&&(0,X.jsx)(R.A,{className:"h-3.5 w-3.5 flex-shrink-0 text-green-400","data-testid":"role-tile-mod-".concat(a.user_id)}),"vip"===(0,Y.Lc)(a)&&(0,X.jsx)(E.A,{className:"h-3.5 w-3.5 flex-shrink-0 text-blue-400","data-testid":"vip-tile-crown-".concat(a.user_id)}),a.is_champion&&(0,X.jsx)(E.A,{className:"h-3.5 w-3.5 flex-shrink-0 text-[#FFD700]","data-testid":"champion-tile-crown-".concat(a.user_id),title:"Chanpyon konpetisyon"}),a.is_jenipal_champ&&(0,X.jsx)(T.A,{className:"h-3.5 w-3.5 flex-shrink-0 text-[#FFD700]","data-testid":"jenipal-champ-tile-".concat(a.user_id),title:"Chanpyon JeniPal mwa a"}),(0,X.jsx)("span",{className:"truncate",children:a.name})]}),!le&&(0,X.jsxs)("span",{"data-testid":"tile-followers-".concat(a.user_id
1),title:"Moun k ap swiv",className:"flex shrink-0 items-center gap-1 rounded-full bg-black/55 px-2 py-0.5 text-[11px] font-bold text-white/85",children:[(0,X.jsx)(M.A,{className:"h-3 w-3 text-[#FFD700]"})," ",null!==(t=a.followers_count)&&void 0!==t?t:0]})]})}),Me&&(0,X.jsxs)("div",{className:"absolute left-3 top-3 z-10 flex items-center gap-1.5 rounded-full bg-[#00F0FF] px-2.5 py-1 text-[11px] font-bold uppercase tracking-wide text-black shadow-[0_0_12px_rgba(0,240,255,0.7)]","data-testid":"screen-share-badge-".concat(a.user_id),children:[(0,X.jsx)(P.A,{className:"h-3.5 w-3.5"})," Ap Pataje Ekran"]}),Pe&&(0,X.jsxs)("div",{className:"absolute left-3 top-11 z-10 flex items-center gap-1.5 rounded-full bg-[#39FF14] px-2.5 py-1 text-[11px] font-bold uppercase tracking-wide text-black shadow-[0_0_12px_rgba(57,255,20,0.7)]","data-testid":"screen-audio-badge-".concat(a.user_id),children:[(0,X.jsx)(D.A,{className:"h-3.5 w-3.5"})," Son ap pataje"]}),r&&!(Ee&&!ae)&&(0,X.jsx)("div",{className:"absolute right-3 top-3 flex items-center gap-1.5 rounded-full bg-black/60 px-2.5 py-1 text-[11px] font-bold uppercase tracking-wide text-white/70","data-testid":"self-offair-badge",children:"Ou"}),(0,X.jsxs)("div",{className:"absolute left-3 top-3 z-10 flex flex-col gap-1.5",children:[!r&&ne&&(0,X.jsx)("button",{"data-testid":"reconnect-cam-".concat(a.user_id
1),onClick:()=>{ge(!0);try{ne(a)}catch(e){}setTimeout(()=>ge(!1),4e3)},title:"Rafrechi kamera sa a (si ekran an nwa)",className:"rounded-lg bg-black/70 p-2 text-white transition-colors hover:bg-[#00A8CC]",children:(0,X.jsx)(I.A,{className:"h-3.5 w-3.5 ".concat(fe?"animate-spin":"")})}),(0,X.jsx)("button",{"data-testid":"fullscreen-btn-".concat(r?"self":a.user_id),onClick:async()=>{const e=ce.current;if(!e)return;const t=document.fullscreenElement||document.webkitFullscreenElement;try{t?document.exitFullscreen?await document.exitFullscreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():e.requestFullscreen?await e.requestFullscreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():oe.current&&oe.current.webkitEnterFullscreen&&oe.current.webkitEnterFullscreen()}catch(a){}},title:me?"Kite plen ekran":"Plen ekran",className:"rounded-lg bg-black/70 p-2 text-white opacity-0 transition-opacity hover:bg-black/90 group-hover:opacity-100",children:me?(0,X.jsx)(L.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(z.A,{className:"h-3.5 w-3.5"})})]}),!r&&(0,X.jsxs)("div",{className:"absolute right-3 top-3 flex items-start gap-1.5 opacity-0 transition-opacity group-hover:opacity-100",children:[(0,X.jsxs)("div",{className:"flex flex-col items-center gap-1.5 rounded-lg bg-black/70 px-1.5 py-2","data-testid":"volume-control-".concat(a.user_id
1),children:[(0,X.jsx)("input",{type:"range",min:0,max:1,step:.05,value:g?0:je,onChange:e=>{const t=Number(e.target.value);ye(t),g&&t>0&&(null===b||void 0===b||b(a))},title:"Kontwole volim","data-testid":"volume-slider-".concat(a.user_id),style:{writingMode:"vertical-lr",direction:"rtl"},className:"h-20 w-1 cursor-pointer accent-[#00F0FF]"}),(0,X.jsx)("button",{"data-testid":"local-mute-".concat(a.user_id),onClick:()=>null===b||void 0===b?void 0:b(a),title:g?"Louvri son pou mwen":"F\xe8men son pou mwen",className:"rounded p-0.5 text-white ".concat(g?"text-[#FF2A5F]":""),children:g||0===je?(0,X.jsx)(V.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(D.A,{className:"h-3.5 w-3.5"})})]}),(0,X.jsx)("button",{"data-testid":"local-hide-".concat(a.user_id),onClick:()=>null===w||void 0===w?void 0:w(a),title:v?"Montre kamera pou mwen":"Kache kamera pou mwen",className:"rounded-lg p-2 text-white hover:bg-black/90 ".concat(v?"bg-[#FF2A5F]/80":"bg-black/70"),children:v?(0,X.jsx)(C.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(O.A,{className:"h-3.5 w-3.5"})}),(c||d)&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("span",{className:"mx-0.5 h-4 w-px bg-white/25"}),(0,X.jsx)("button",{"data-testid":"host-mute-".concat(a.user_id
1),onClick:()=>u(a),title:ve.audio?"Silans":"Retire silans",className:"rounded-lg bg-black/70 p-2 text-white hover:bg-black/90",children:ve.audio?(0,X.jsx)(_.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(q.A,{className:"h-3.5 w-3.5 text-red-400"})}),c&&(0,X.jsx)("button",{"data-testid":"host-cam-".concat(a.user_id),onClick:()=>m(a),title:ve.video?"F\xe8men kamera":"Louvri kamera",className:"rounded-lg bg-black/70 p-2 text-white hover:bg-black/90",children:ve.video?(0,X.jsx)(B.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(U.A,{className:"h-3.5 w-3.5 text-red-400"})}),ee&&(0,X.jsx)("button",{"data-testid":"demote-stage-".concat(a.user_id),onClick:()=>ee(a),title:"Retire sou kamera",className:"rounded-lg bg-[#FF8A00]/80 p-2 text-white hover:bg-[#FF8A00]",children:(0,X.jsx)(K.A,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("button",{"data-testid":"host-kick-".concat(a.user_id),onClick:()=>h(a),title:c?"Mete dey\xf2 & bloke":"Mete dey\xf2",className:"rounded-lg bg-red-500/80 p-2 text-white hover:bg-red-500",children:(0,X.jsx)(H.A,{className:"h-3.5 w-3.5"})})]})]}),(!ve.audio||!ve.video||!r&&g||N&&!le||!r&&!le)&&(0,X.jsx)("div",{className:"absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/85 to-transparent p-3",children:(0,X.jsx)("div",{className:"flex items-end justify-end",children:(0,X.jsxs)("div",{className:"flex items-center gap-1.5",children:[!ve.audio&&(0,X.jsx)("span",{className:"rounded-md bg-black/60 p-1.5 text-red-400",children:(0,X.jsx)(q.A,{className:"h-3.5 w-3.5"})}),!ve.video&&(0,X.jsx)("span",{className:"rounded-md bg-black/60 p-1.5 text-red-400",children:(0,X.jsx)(U.A,{className:"h-3.5 w-3.5"})}),!r&&g&&(0,X.jsx)("span",{title:"Ou f\xe8men son moun sa a",className:"rounded-md bg-[#FF2A5F]/70 p-1.5 text-white",children:(0,X.jsx)(V.A,{className:"h-3.5 w-3.5"})}),N&&!le&&(0,X.jsxs)("button",{"data-testid":"tile-follow-btn-".concat(a.user_id
1),onClick:()=>null===Z||void 0===Z?void 0:Z(a),title:F?"Ou ap swiv":"Swiv",className:"flex items-center gap-1 rounded-full font-bold transition-transform hover:scale-105 ".concat($?"p-2":"px-2.5 py-1.5 text-xs"," ").concat(F?"bg-white/15 text-white":"bg-[#FFD700] text-black"),children:[F?(0,X.jsx)(W.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(G.A,{className:"h-3.5 w-3.5"}),$?"":F?" Ap swiv":" Swiv"]}),!r&&!le&&o&&(0,X.jsx)("button",{"data-testid":"send-gift-btn-".concat(a.user_id),onClick:()=>o(a),title:"Voye yon kado",className:"flex items-center justify-center rounded-full bg-[#FF2A5F] p-2 text-white transition-transform hover:scale-105 glow-pink",children:(0,X.jsx)(J.A,{className:"h-3.5 w-3.5"})})]})})})]})}const Q=i.memo(Z);var $=a(1130);let ee=null,te=0;function ae(e){let t=e.voteInfo,a=e.userId;const n=(0,i.useState)(0),r=(0,s.A)(n,2),l=r[0],o=r[1],c=(0,i.useRef)(null===t||void 0===t?void 0:t.votes);return(0,i.useEffect)(()=>{const e=null===t||void 0===t?void 0:t.votes;null!=e?(null!=c.current&&e>c.current&&(o(e=>e+1),function(){if("undefined"===typeof window)return;try{if("1"===localStorage.getItem("comp_sfx_muted"))return}catch(t){}const e=Date.now();if(!(e-te<180)){te=e;try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;ee||(ee=new e);const t=ee;"suspended"===t.state&&t.resume();const a=t.createOscillator(),n=t.createGain();a.connect(n),n.connect(t.destination),a.type="sine";const s=t.currentTime;a.frequency.setValueAtTime(660,s),a.frequency.exponentialRampToValueAtTime(1046,s+.12),n.gain.setValueAtTime(1e-4,s),n.gain.exponentialRampToValueAtTime(.16,s+.02),n.gain.exponentialRampToValueAtTime(1e-4,s+.24),a.start(s),a.stop(s+.26)}catch(a){}}}()),c.current=e):c.current=e},[null===t||void 0===t?void 0:t.votes]),t?(0,X.jsxs)("div",{className:"relative flex shrink-0 items-center justify-between gap-2 rounded-xl bg-black/50 px-2.5 py-1.5","data-testid":"comp-vote-bar-".concat(a),children:[(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("span",{className:"flex h-6 w-6 items-center justify-center","data-testid":"comp-leader-badge-".concat(a),children:t.isLeader&&(0,X.jsx)(E.A,{className:"crown-flash h-6 w-6 text-[#FFD700] drop-shadow-[0_0_10px_rgba(255,215,0,0.95)]",title:"Devan"})}),(0,X.jsxs)("span",{className:"flex items-center gap-1 text-base font-black text-[#FFD700] ".concat(l?"vote-pop":""),"data-testid":"comp-vote-count-".concat(a),children:[(0,X.jsx)($.A,{className:"h-4 w-4"})," ",t.votes]},"vc-".concat(l)),l>0&&(0,X.jsx)("span",{className:"vote-float pointer-events-none absolute left-9 top-0 text-lg font-black text-[#FFD700] drop-shadow-[0_0_8px_rgba(255,215,0,0.8)]","data-testid":"comp-vote-float-".concat(a),children:"+1"},"vf-".concat(l))]}),(0,X.jsx)("button",{type:"button","data-testid":"comp-vote-btn-".concat(a),disabled:!t.canVote,onClick:e=>{e.stopPropagation(),t.canVote&&t.onVote(a)},title:t.reason||"Vote pou kandida sa a",className:"flex h-9 w-9 items-center justify-center rounded-full shadow-lg transition-transform ".concat(t.canVote?"bg-[#FF2A5F] text-white hover:scale-110 glow-pink":"cursor-not-allowed bg-white/10 text-white/40"),children:(0,X.jsx)(W.A,{className:"h-5 w-5",strokeWidth:3})})]}):null}var ne=a(9757),se=a(9432),ie=a(5731);const re=[{icon:B.A,title:"Dir\xe8k Videyo",desc:"Jiska 9 kamera an menm tan nan lakou a",from:"#00F0FF",to:"#00A8CC"},{icon:J.A,title:"Voye Kado",desc:"Animasyon kado ki briye pou moun ou renmen",from:"#FF2A5F",to:"#FF7AA8"},{icon:T.A,title:"JeniPal Kwiz",desc:"Jwe an dir\xe8k, reponn, epi genyen rekonpans",from:"#FFD93D",to:"#FF9F1C"},{icon:ne.A,title:"Radyo an Dir\xe8k",desc:"Koute pi bon estasyon peyi a san kanpe",from:"#22D3A6",to:"#0EA5A9"},{icon:se.A,title:"Jeton & Pwen",desc:"Monte nivo, f\xe8 lajan epi retire k\xf2b ou",from:"#A78BFA",to:"#7C3AED"},{icon:ie.A,title:"Chanm Vil",desc:"Chat pa vil ak tout diaspora ayisyen an",from:"#38BDF8",to:"#2563EB"}],le=["Vin premye moun an Dir\xe8k! \ud83c\udfa5","Voye kado, monte nivo! \ud83c\udf81","Jwe JeniPal, genyen rekonpans! \ud83e\udde0","Montre Ayiti bay tout moun! \ud83c\udded\ud83c\uddf9","Limen kamera w, f\xe8 bri! \ud83d\udd25"];function oe(e){let t=e.onGoLive,a=e.canGoLive,n=void 0!==a&&a;const r=(0,i.useState)(0),l=(0,s.A)(r,2),o=l[0],c=l[1];return(0,i.useEffect)(()=>{const e=setInterval(()=>c(e=>(e+1)%le.length),3500);return()=>clearInterval(e)},[]),(0,X.jsxs)("div",{"data-testid":"lobby-feature-showcase",className:"scroll-red relative h-full min-h-0 w-full overflow-y-auto overflow-x-hidden rounded-2xl border border-white/10 bg-gradient-to-br from-[#0b0b16] via-[#0d1020] to-[#120a1e]",children:[(0,X.jsx)("div",{className:"pointer-events-none absolute -left-16 -top-16 h-56 w-56 rounded-full bg-[#00F0FF]/10 blur-3xl"}),(0,X.jsx)("div",{className:"pointer-events-none absolute -bottom-20 -right-10 h-64 w-64 roun
1ded-full bg-[#FF2A5F]/10 blur-3xl"}),(0,X.jsxs)("div",{className:"relative z-10 flex min-h-full max-w-3xl flex-col items-center justify-center px-4 py-5 text-center sm:py-6 mx-auto",children:[(0,X.jsxs)("span",{className:"mb-3 inline-flex items-center gap-2 rounded-full border border-white/10 bg-white/5 px-3 py-1 text-[10px] font-bold uppercase tracking-widest text-white/60 sm:text-[11px]",children:[(0,X.jsx)("span",{className:"h-2 w-2 animate-pulse rounded-full bg-[#FF2A5F]"})," Kamera a vid pou kounye a"]}),(0,X.jsx)("h2",{className:"flex items-center justify-center",children:(0,X.jsx)("span",{"data-testid":"showcase-slogan",className:"font-display text-2xl font-black leading-tight sm:text-4xl lg:text-5xl",style:{backgroundImage:"linear-gradient(90deg,#00F0FF,#FFD93D,#FF2A5F,#A78BFA,#00F0FF)",backgroundSize:"300% 100%",WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent",animation:"showcaseGradient 6s linear infinite, sloganSwap .6s ease both"},children:le[o]},o)}),(0,X.jsx)("p",{className:"mt-2 text-xs font-semibold text-white/70 sm:text-base",children:"Limen kamera w epi montre Ayiti bay tout moun \u2014 pandan sa, men sa k ap tann ou:"}),n&&(0,X.jsxs)("button",{type:"button","data-testid":"showcase-go-live-btn",onClick:t,className:"group mt-4 inline-flex items-center gap-2.5 rounded-full bg-gradient-to-r from-[#FF2A5F] to-[#FF7AA8] px-6 py-3 font-display text-sm font-black uppercase tracking-wide text-white shadow-[0_10px_30px_-8px_rgba(255,42,95,0.7)] transition-transform hover:scale-105 active:scale-95 sm:mt-5 sm:px-7 sm:py-3.5 sm:text-lg",children:[(0,X.jsxs)("span",{className:"relative flex h-3 w-3 items-center justify-center",children:[(0,X.jsx)("span",{className:"absolute h-3 w-3 animate-ping rounded-full bg-white/70"}),(0,X.jsx)("span",{className:"h-2.5 w-2.5 rounded-full bg-white"})]}),(0,X.jsx)(B.A,{className:"h-5 w-5"})," Limen kamera m"]}),(0,X.jsx)("div",{className:"mt-5 grid w-full grid-cols-1 gap-2.5 sm:mt-6 sm:grid-cols-2 sm:gap-3 lg:grid-cols-3",children:re.map((e,t)=>{const a=e.icon;return(0,X.jsxs)("div",{className:"group flex items-center gap-3 rounded-2xl border border-white/10 bg-white/[0.04] p-2.5 text-left backdrop-blur-sm transition-transform hover:-translate-y-0.5 hover:border-white/20 sm:p-3",style:{animation:"showcaseIn .5s ease both",animationDelay:"".concat(90*t,"ms")},children:[(0,X.jsx)("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-xl text-white shadow-lg transition-transform group-hover:scale-110 sm:h-11 sm:w-11",style:{backgroundImage:"linear-gradient(135deg, ".concat(e.from,", ").concat(e.to,")")},children:(0,X.jsx)(a,{className:"h-5 w-5"})}),(0,X.jsxs)("div",{className:"min-w-0",children:[(0,X.jsx)("p",{className:"font-display text-sm font-black leading-tight sm:text-base",style:{backgroundImage:"linear-gradient(90deg, ".concat(e.from,", ").concat(e.to,")"),WebkitBackgroundClip:"text",backgroundClip:"text",color:"transparent"},children:e.title}),(0,X.jsx)("p",{className:"truncate text-[11px] font-medium text-white/55 sm:text-xs",children:e.desc})]})]},e.title)})})]})]})}function ce(e){let t=e.stream,a=e.muted,n=e.sinkId;const s=(0,i.useRef)(null);return(0,i.useEffect)(()=>{s.current&&t&&(s.current.srcObject=t)},[t]),(0,i.useEffect)(()=>{const e=s.current;e&&n&&"function"===typeof e.setSinkId&&e.setSinkId(n).catch(()=>{})},[n,t]),(0,X.jsx)("audio",{ref:s,autoPlay:!0,playsInline:!0,muted:!!a,className:"hidden"})}var de=a(7301);function ue(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const n=(0,i.useState)(()=>new Set),r=(0,s.A)(n,2),l=r[0],o=r[1],c=(0,i.useRef)(e);c.current=e;const d=(0,i.useRef)({stream:t,id:a});return d.current={stream:t,id:a},(0,i.useEffect)(()=>{const e=(0,de.vU)();if(!e)return;const t=new Map;let a,n=!1;const i=(a,n)=>{const s=t.get(a);if(!s||s.stream!==n){if(s)try{s.src.disconnect()}catch(i){}try{const s=e.createMediaStreamSource(n),i=e.createAnalyser();i.fftSize=512,s.connect(i),t.set(a,{src:s,analyser:i,data:new Uint8Array(i.frequencyBinCount),silent:0,speaking:!1,stream:n})}catch(r){}}},r=()=>{if(n)return;if((()=>{const e=new Set;Object.values(c.current||{}
1).forEach(t=>{var a,n,s;const r=null===(a=t.info)||void 0===a?void 0:a.user_id,l=t.stream;r&&l&&null!==(n=t.info)&&void 0!==n&&null!==(s=n.media)&&void 0!==s&&s.audio&&0!==l.getAudioTracks().length&&(e.add(r),i(r,l))});const a=d.current;a.id&&a.stream&&a.stream.getAudioTracks().length>0&&(e.add(a.id),i(a.id,a.stream));for(const i of t){var n=(0,s.A)(i,2);const a=n[0],l=n[1];if(!e.has(a)){try{l.src.disconnect()}catch(r){}t.delete(a)}}})(),0===t.size)return o(e=>0===e.size?e:new Set),void(a=setTimeout(r,66));const e=new Set;for(const a of t){var l=(0,s.A)(a,2);const t=l[0],n=l[1];n.analyser.getByteFrequencyData(n.data);let i=0;for(let e=0;e<n.data.length;e++)i+=n.data[e];i/n.data.length>16?(n.speaking=!0,n.silent=0):(n.silent++,n.silent>10&&(n.speaking=!1)),n.speaking&&e.add(t)}o(t=>t.size===e.size&&[...e].every(e=>t.has(e))?t:e),a=setTimeout(r,66)};return r(),()=>{n=!0,clearTimeout(a);for(const a of t){const t=(0,s.A)(a,2)[1];try{t.src.disconnect()}catch(e){}}t.clear()}},[]),l}var me=a(7950),he=a(2771),xe=a(2812),pe=a(6174),fe=a(1360),ge=a(614),ve=a(2024),be=a(6608),we=a(764),je=a(1286),ye=a(4637),ke=a(1622),Ne=a(9855),Ae=a(7922),Fe=a(8006),_e=a(3944),Ce=a(9868),Se=a(8326),Re=a(5469),Ee=a(4939),Te=a(8706),Me=a(2574),Pe=a(3786),De=a(4473),Ie=a(3961),Le=a(9292),ze=a(5327),Ve=a(6963),Oe=a(3799),qe=a(1367),Be=a(3728),Ue=a(2300),Ke=a(7033),He=a(5746),We=a(3908),Ge=a(38),Je=a(5598),Ye=a(5088),Xe=a(5727);function Ze(e){let t=e.open,a=e.onOpenChange,n=e.poll,s=e.myVotes,i=void 0===s?[]:s,r=e.onVote,l=e.isGuest;const o=(null===n||void 0===n?void 0:n.total_votes)||0,c=n&&"single"===n.vote_mode&&i.length>0;return(0,X.jsx)(Je.lG,{open:t,onOpenChange:a,children:(0,X.jsxs)(Je.Cf,{"data-testid":"poll-dialog",className:"max-w-md border-white/10 bg-[#0e1524] [html.light_&]:bg-[#e9edf4] text-white",children:[(0,X.jsx)(Je.c7,{children:(0,X.jsxs)(Je.L3,{className:"flex items-center gap-2 text-white",children:[(0,X.jsx)(Ke.A,{className:"h-5 w-5 text-[#FF2A5F]"})," Sondaj"]})}),!n&&(0,X.jsx)("div",{"data-testid":"poll-empty",className:"py-8 text-center text-sm text-gray-400",children:"Pa gen sondaj aktif kounye a."}),n&&(0,X.jsxs)("div",{className:"space-y-4",children:[(0,X.jsx)("h3",{"data-testid":"poll-question",className:"text-lg font-bold leading-snug",children:n.question}),n.scheduled&&(0,X.jsxs)("div",{className:"flex items-center gap-2 rounded-lg bg-yellow-500/15 px-3 py-2 text-xs font-semibold text-yellow-200",children:[(0,X.jsx)(Ye.A,{className:"h-4 w-4"})," Sondaj la ap k\xf2manse byento\u2026"]}),n.ended&&(0,X.jsxs)("div",{className:"flex items-center gap-2 rounded-lg bg-white/10 px-3 py-2 text-xs font-semibold text-gray-300",children:[(0,X.jsx)(Xe.A,{className:"h-4 w-4"})," Sondaj la f\xe8men"]}),(0,X.jsx)("div",{className:"space-y-2",children:n.options.map(e=>{const t=o?Math.round(e.votes/o*100):0,a=i.includes(e.id),s=!l&&n.active&&!("single"===n.vote_mode&&c);return(0,X.jsxs)("button",{type:"button","data-testid":"poll-option-".concat(e.id),disabled:!s,onClick:()=>s&&r(e.id),className:"relative w-full overflow-hidden rounded-xl border px-3 py-2.5 text-left transition-colors ".concat(a?"border-[#FF2A5F]":"border-white/10"," ").concat(s?"hover:border-[#FF2A5F]/60 cursor-pointer":"cursor-default"),children:[(0,X.jsx)("div",{className:"absolute inset-y-0 left-0 bg-gradient-to-r from-[#FF2A5F]/40 to-[#00F0FF]/25 transition-all",style:{width:"".concat(t,"%")}}),(0,X.jsxs)("div",{className:"relative flex items-center justify-between gap-2",children:[(0,X.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-semibold",children:[a&&(0,X.jsx)(W.A,{className:"h-4 w-4 text-[#FF2A5F]"})," ",e.text]}),(0,X.jsxs)("span",{className:"text-xs font-bold tabular-nums text-gray-200",children:[t,"% \xb7 ",e.votes]})]})]},e.id)})}),(0,X.jsxs)("div",{className:"flex items-center justify-between text-xs text-gray-400",children:[(0,X.jsxs)("span",{"data-testid":"poll-total",children:[o," v\xf2t"]}),(0,X.jsx)("span",{children:"single"===n.vote_mode?"1 v\xf2t pa moun":"V\xf2t miltip"})]}),l&&(0,X.jsx)("p",{className:"text-center text-xs text-yellow-300",children:"Konekte pou w ka vote."}),!l&&c&&n.active&&(0,X.jsx)("p",{className:"text-center text-xs text-[#00F0FF]",children:"Ou deja vote \u2713"})]})]})})}var Qe=a(4991),$e=a(4830),et=a(8132);const tt=e=>e&&e.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(e):e;function at(){return(0,X.jsx)("span",{"data-testid":"radio-eq",className:"flex items-end gap-0.5","aria-hidden":!0,
1children:[0,1,2].map(e=>(0,X.jsx)("span",{className:"inline-block w-0.5 origin-bottom rounded-full bg-current",style:{height:12,animation:"radioEq 0.9s ease-in-out ".concat(.18*e,"s infinite")}},e))})}function nt(){const e=(0,et.z)(),t=e.stations,a=e.currentId,n=e.playing,r=e.loading,l=e.fetchStations,o=e.play,c=(0,i.useState)(!1),d=(0,s.A)(c,2),u=d[0],m=d[1],h=t.find(e=>e.id===a);return(0,X.jsxs)("div",{className:"relative",children:[(0,X.jsxs)("button",{type:"button","data-testid":"open-radio-btn",onClick:()=>{m(e=>(e||l(),!e))},title:"Radyo an dir\xe8k",className:"relative flex h-8 items-center gap-1 rounded-lg px-1.5 ring-1 transition-colors ".concat(n?"bg-[#00F0FF] text-black ring-[#00F0FF]":"bg-white text-slate-700 ring-sky-200 hover:bg-sky-50"),children:[n&&null!==h&&void 0!==h&&h.logo_url?(0,X.jsx)("img",{src:tt(h.logo_url),alt:"",className:"h-5 w-8 rounded object-contain"}):(0,X.jsx)(ne.A,{className:"h-4 w-4"}),n&&(0,X.jsx)(at,{})]}),u&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"fixed inset-0 z-[75] bg-black/60 backdrop-blur-sm",onClick:()=>m(!1),"data-testid":"radio-backdrop"}),(0,X.jsx)("div",{className:"fixed inset-0 z-[76] flex items-center justify-center p-4",onClick:()=>m(!1),children:(0,X.jsxs)("div",{"data-testid":"radio-sheet",onClick:e=>e.stopPropagation(),className:"w-full max-w-md overflow-hidden rounded-2xl border border-[#00F0FF]/40 bg-[#0b0b12] shadow-2xl",style:{animation:"radioPop 0.22s cubic-bezier(.2,.8,.2,1)"},children:[(0,X.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 bg-black/50 px-4 py-3",children:[(0,X.jsxs)("span",{className:"flex items-center gap-1.5 text-sm font-black uppercase tracking-wide text-[#00F0FF]",children:[(0,X.jsx)(ne.A,{className:"h-4 w-4"})," Radyo an dir\xe8k"]}),(0,X.jsx)("button",{"data-testid":"radio-close",onClick:()=>m(!1),title:"F\xe8men",className:"flex h-7 w-7 items-center justify-center rounded-full text-white hover:bg-white/10",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsxs)("div",{className:"max-h-[65vh] overflow-y-auto scroll-red p-2",children:[0===t.length&&(0,X.jsx)("p",{className:"px-2 py-6 text-center text-xs text-gray-400",children:"Pa gen estasyon radyo disponib pou kounye a."}),t.map(e=>{const t=e.id===a;return(0,X.jsxs)("button",{"data-testid":"radio-station-".concat(e.id),onClick:()=>o(e),className:"mb-1 flex w-full items-center gap-3 rounded-xl px-2 py-2 text-left transition-colors ".concat(t?"bg-[#00F0FF]/15 ring-1 ring-[#00F0FF]/50":"hover:bg-white/5"),children:[(0,X.jsx)("div",{className:"flex h-10 w-16 shrink-0 items-center justify-center overflow-hidden rounded-md bg-white/10",children:e.logo_url?(0,X.jsx)("img",{src:tt(e.logo_url),alt:"",className:"h-full w-full object-contain"}):(0,X.jsx)(ne.A,{className:"h-5 w-5 text-white/50"})}),(0,X.jsx)("span",{className:"min-w-0 flex-1 break-words text-sm font-bold leading-tight text-white",children:e.name}),t&&r&&(0,X.jsx)(ve.A,{className:"h-4 w-4 shrink-0 animate-spin text-[#00F0FF]"}),t&&n&&(0,X.jsx)("span",{className:"text-[#00F0FF]",children:(0,X.jsx)(at,{})}),t&&(n||r)?(0,X.jsx)(Qe.A,{className:"h-4 w-4 shrink-0 text-[#FF2A5F]"}):(0,X.jsx)($e.A,{className:"h-4 w-4 shrink-0 text-[#00F0FF]"})]},e.id)})]})]})})]})]})}var st=a(2414),it=a(4259),rt=a(9788);const lt="https://haitipal.com",ot="".concat(lt,"/api/tv/playlist.m3u8");function ct(e){return(0,f.J)()?null:(0,X.jsx)(dt,(0,n.A)({},e))}function dt(e){let t=e.lowerThirds,a=void 0===t?[]:t,n=e.rotateSecs,r=void 0===n?8:n;const l=(0,i.useRef)(null),o=(0,i.useRef)(null),c=(0,i.useState)(!0),u=(0,s.A)(c,2),m=u[0],h=u[1],x=(0,i.useState)(!1),p=(0,s.A)(x,2),f=p[0],g=p[1],v=(0,i.useState)(!1),b=(0,s.A)(v,2),w=b[0],j=b[1],y=(0,i.useState)(0),k=(0,s.A)(y,2),N=k[0],A=k[1],F=f,_="undefined"!==typeof window&&window.matchMedia&&window.matchMedia("(min-width: 1024px)").matches,C=f||_;(0,i.useEffect)(()=>{const e=l.current;if(!e)return;let t,a=!1;const n=()=>e.play().then(()=>j(!1)).catch(()=>j(!0));let s=0;return rt.Ay.isSupported()?(t=new rt.Ay({enableWorker:!0,lowLatencyMode:!1}
1),t.attachMedia(e),t.on(rt.Ay.Events.MEDIA_ATTACHED,()=>{a||t.loadSource(ot)}),t.on(rt.Ay.Events.MANIFEST_PARSED,()=>{s=0,n()}),t.on(rt.Ay.Events.ERROR,(e,n)=>{if(n.fatal&&!a)if(n.type===rt.Ay.ErrorTypes.NETWORK_ERROR){if(s+=1,s>5)return void j(!0);setTimeout(()=>{a||t.startLoad()},Math.min(1e3*s,5e3))}else n.type===rt.Ay.ErrorTypes.MEDIA_ERROR?t.recoverMediaError():j(!0)})):e.canPlayType("application/vnd.apple.mpegurl")&&(e.src=ot,e.addEventListener("loadedmetadata",n)),()=>{a=!0,t&&t.destroy()}},[]);(0,i.useEffect)(()=>{l.current&&(l.current.muted=m)},[m]),(0,i.useEffect)(()=>{const e=()=>g(!(!document.fullscreenElement&&!document.webkitFullscreenElement));return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e)}},[]);const S=a.length;(0,i.useEffect)(()=>{N>=S&&A(0)},[S,N]),(0,i.useEffect)(()=>{if(!C||S<=1)return;const e=Math.max(3,r||8),t=setInterval(()=>A(e=>(e+1)%S),1e3*e);return()=>clearInterval(t)},[C,S,r]),(0,i.useEffect)(()=>{if(!C||0===S)return;const e=a[Math.min(N,S-1)];null!==e&&void 0!==e&&e.id&&d.Ay.post("/tv-lowerthird/impression",{id:e.id,text:e.text}).catch(()=>{})},[C,N,S]);const R=e=>{null!==e&&void 0!==e&&e.id&&d.Ay.post("/tv-lowerthird/click",{id:e.id,text:e.text}).catch(()=>{})};return(0,X.jsxs)("div",{ref:o,"data-testid":"livetv-tile",className:"group relative min-h-0 h-full w-full overflow-hidden rounded-2xl bg-black ring-1 ring-[#00F0FF]/30",children:[(0,X.jsx)("video",{ref:l,"data-testid":"livetv-video",className:"h-full w-full bg-black ".concat(f?"object-contain":"object-cover"),playsInline:!0,muted:m,autoPlay:!0,controls:!1}),w&&(0,X.jsxs)("button",{"data-testid":"livetv-tap-play",onClick:()=>{const e=l.current;e&&e.play().then(()=>j(!1)).catch(()=>{})},className:"absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 bg-black/60 text-white",children:[(0,X.jsx)("span",{className:"flex h-14 w-14 items-center justify-center rounded-full bg-[#FF2A5F] glow-pink",children:(0,X.jsx)($e.A,{className:"h-7 w-7 translate-x-0.5"})}),(0,X.jsx)("span",{className:"text-xs font-semibold uppercase tracking-widest",children:"Peze pou gade TV"})]}),(0,X.jsx)("div",{className:"pointer-events-none absolute left-3 top-3 flex items-center rounded-full bg-black/60 p-1.5",children:(0,X.jsx)("span",{className:"h-2.5 w-2.5 rounded-full bg-red-500 live-dot"})}),(0,X.jsxs)("div",{className:"absolute right-3 top-3 z-[210] flex items-center gap-1.5 transition-opacity ".concat(F?"opacity-100":"opacity-0 group-hover:opacity-100"),children:[(0,X.jsx)("button",{"data-testid":"livetv-mute-btn",onClick:()=>h(e=>!e),title:m?"Aktive son":"Silans",className:"rounded-lg bg-black/70 p-2 text-white hover:bg-black/90",children:m?(0,X.jsx)(V.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(D.A,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("button",{"data-testid":"livetv-fullscreen-btn",onClick:()=>{const e=o.current,t=l.current;var a;document.fullscreenElement||document.webkitFullscreenElement?null===(a=document.exitFullscreen||document.webkitExitFullscreen)||void 0===a||a.call(document):null!==e&&void 0!==e&&e.requestFullscreen?e.requestFullscreen().catch(()=>{null!==t&&void 0!==t&&t.webkitEnterFullscreen&&t.webkitEnterFullscreen()}):null!==e&&void 0!==e&&e.webkitRequestFullscreen?e.webkitRequestFullscreen():null!==t&&void 0!==t&&t.webkitEnterFullscreen&&t.webkitEnterFullscreen()},title:F?"Kite plen ekran":"Plen ekran",className:"rounded-lg bg-black/70 p-2 text-white hover:bg-black/90",children:F?(0,X.jsx)(L.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(z.A,{className:"h-3.5 w-3.5"})})]}),(()=>{const e=S>0?a[Math.min(N,S-1)]:null;return e&&C?(0,X.jsxs)("div",{"data-testid":"tv-lower-third",className:"absolute inset-x-0 bottom-0 z-[205] flex items-center gap-2.5 bg-gradient-to-t from-black/90 via-black/70 to-transparent px-3 pb-2.5 pt-6 lt-fade",children:[e.image_url&&(0,X.jsx)("img",{src:(t=e.image_url,t&&t.startsWith("/api/files/")?"".concat(lt).concat(t):t),alt:"",className:"h-11 w-11 shrink-0 rounded-md object-cover ring-1 ring-white/20","data-testid":"tv-lower-third-image"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsx)("span",{className:"mr-1.5 inline-block rounded bg-[#FF2A5F] px-1.5 py-0.5 text-[9px] font-black uppercase tracking-wider text-white align-middle",children:"Piblisite"}),(0,X.jsx)("span",{className:"align-middle text-sm font-bold leading-snug text-white drop-shadow",children:e.text}),(0,X.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-3",children:[e.link_url&&(0,X.jsxs)("a",{href:e.link_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>R(e),"data-testid":"tv-lower-third-link",className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#00F0FF] hover:underline",children:[(0,X.jsx)(we.A,{className:"h-3 w-3"})," Vizite"]}),e.phone&&(0,X.jsxs)("a",{href:"tel:".concat(e.phone),onClick:()=>R(e),"data-testid":"tv-lower-third-phone",className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#00F0FF] hover:underline",children:[(0,X.jsx)(je.A,{className:"h-3 w-3"})," ",e.phone]}
1)]})]}),S>1&&(0,X.jsx)("div",{className:"flex shrink-0 items-center gap-1 self-start pt-0.5","data-testid":"tv-lower-third-dots",children:a.map((e,t)=>(0,X.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(t===N?"bg-[#00F0FF]":"bg-white/30")},t))})]},e.id||N):null;var t})()]})}const ut="htv_tv_pos";function mt(e){let t=e.lowerThirds,a=e.rotateSecs;e.mobile;const n=(0,i.useState)(!1),r=(0,s.A)(n,2),l=r[0],o=r[1],c=(0,i.useState)({lowerThirds:[],rotateSecs:8}),u=(0,s.A)(c,2),m=u[0],h=u[1],x=null!==t&&void 0!==t?t:m.lowerThirds,p=null!==a&&void 0!==a?a:m.rotateSecs;(0,i.useEffect)(()=>{void 0===t&&d.Ay.get("/tv-lowerthird").then(e=>h({lowerThirds:e.data.lower_thirds||[],rotateSecs:e.data.rotate_secs||8})).catch(()=>{})},[t]);const g=(0,i.useState)(()=>{try{const e=localStorage.getItem(ut);return e?JSON.parse(e):null}catch(e){return null}}),v=(0,s.A)(g,2),b=v[0],w=v[1],j=(0,i.useRef)(null),y=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=()=>{o(!0),w(e=>{if(e)return e;if(!("undefined"!==typeof window&&window.matchMedia&&window.matchMedia("(min-width: 1024px)").matches))return e;const t=document.getElementById("desktop-chat-area"),a=t?t.getBoundingClientRect().right-300-12:window.innerWidth-300-16,n=t?t.getBoundingClientRect().top+12:72;return{x:Math.max(4,Math.min(a,window.innerWidth-300-4)),y:Math.max(4,n)}})};return window.addEventListener("htv-open-tv",e),()=>window.removeEventListener("htv-open-tv",e)},[]);const k=(0,i.useCallback)((e,t)=>{const a=j.current,n=a?a.offsetWidth:300,s=a?a.offsetHeight:220;return{x:Math.max(4,Math.min(e,window.innerWidth-n-4)),y:Math.max(4,Math.min(t,window.innerHeight-s-4))}},[]),N=(0,i.useCallback)(e=>{const t=y.current;if(t){if(!t.active){if(Math.abs(e.clientX-t.startX)<6&&Math.abs(e.clientY-t.startY)<6)return;t.active=!0}w(k(e.clientX-t.dx,e.clientY-t.dy))}},[k]),A=(0,i.useCallback)(()=>{const e=y.current;y.current=null,window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A),e&&e.active&&w(e=>{if(e)try{localStorage.setItem(ut,JSON.stringify(e))}catch(t){}return e})},[N]),F=(0,i.useCallback)(e=>{const t=j.current;if(!t)return;const a=t.getBoundingClientRect();y.current={dx:e.clientX-a.left,dy:e.clientY-a.top,startX:e.clientX,startY:e.clientY,active:!1},window.addEventListener("pointermove",N),window.addEventListener("pointerup",A),window.addEventListener("pointercancel",A)},[N,A]);if((0,i.useEffect)(()=>()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",A),window.removeEventListener("pointercancel",A)},[N,A]),(0,i.useEffect)(()=>{if(!l)return;const e=requestAnimationFrame(()=>w(e=>e?k(e.x,e.y):e));return()=>cancelAnimationFrame(e)},[l,k]),(0,i.useEffect)(()=>{if(!l||!b)return;const e=()=>w(e=>e?k(e.x,e.y):e);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[l,b,k]),(0,f.J)())return null;if(!l)return(0,X.jsxs)("button",{type:"button","data-testid":"livetv-launcher-btn",onClick:()=>o(!0),title:"Louvri Live TV",className:"relative flex h-8 items-center gap-1 rounded-lg bg-white px-1.5 text-slate-700 ring-1 ring-sky-200 transition-colors hover:bg-sky-50",children:[(0,X.jsx)(st.A,{className:"h-4 w-4"})," ",(0,X.jsx)("span",{className:"hidden text-[11px] font-bold uppercase tracking-wide sm:inline",children:"TV"})]});const _=b?{left:b.x,top:b.y,right:"auto",bottom:"auto"}:{};return(0,me.createPortal)((0,X.jsxs)("div",{ref:j,"data-testid":"livetv-popup",style:_,className:"fixed z-[120] w-[300px] max-w-[85vw] overflow-hidden rounded-2xl border border-[#00F0FF]/40 bg-[#0b0b12] shadow-2xl ".concat(b?"":"top-16 right-4"),children:[(0,X.jsxs)("div",{"data-testid":"livetv-drag-handle",onPointerDown:F,className:"flex touch-none cursor-move select-none items-center justify-between gap-2 border-b border-white/10 bg-black/60 px-3 py-2",children:[(0,X.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-black uppercase tracking-wide text-[#00F0FF]",children:[(0,X.jsx)(it.A,{className:"h-3.5 w-3.5 text-white/40"})," ",(0,X.jsx)(st.A,{className:"h-4 w-4"})," Live TV"]}),(0,X.jsx)("button",{"data-testid":"livetv-popup-close",onPointerDown:e=>e.stopPropagation(),onClick:()=>o(!1),title:"F\xe8men",className:"flex h-7 w-7 items-center justify-center rounded-full surface-2 text-white hover:bg-white/10",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsx)("div",{className:"aspect-video w-full",children:(0,X.jsx)(ct,{lowerThirds:x,rotateSecs:p})})]}),document.body)}function ht(e){let t=e.open,a=e.onClose,n=e.sessionId,r=void 0===n?null:n,l=e.videoUrl,o=void 0===l?null:l,c=e.imageUrl,m=void 0===c?null:c,h=e.defaultTitle,x=void 0===h?"":h;const p=(0,i.useState)(null),f=(0,s.A)(p,2),g=f[0],v=f[1],b=(0,i.useState)(!1),w=(0,s.A)(b,2),j=w[0],y=w[1],k=(0,i.useState)(!1),N=(0,s.A)(k,2),A=N[0],F=N[1],_=(0,i.useState)(x),C=(0,s.A)(_,2),S=C[0],R=C[1],E=(0,i.useState)("draft"),T=(0,s.A)(E,2),M=T[0],P=T[1],D=(0,i.useState)("SELF_ONLY"),I=(0,s.A)(D,2),L=I[0],z=I[1],V=(0,i.useState)(!0),O=(0,s.A)(V,2),q=O[0],B=O[1],U=(0,i.useState)(!0),K=(0,s.A)(U,2),H=K[0],G=K[1],J=(0,i.useState)(null),Y=(0,s.A)(J,2),Z=Y[0],Q=Y[1];if((0,i.useEffect)(()=>{t&&(Q(null),R(x),y(!0),d.Ay.get("/tiktok/status").then(e=>v(e.data)).catch(()=>v(null)).finally(()=>y(!1)))},[t,x]),!t)return null;return(0,me.createPortal)((0,X.jsxs)("div",{className:"fixed inset-0 z-[130] flex items-center justify-center p-4","data-testid":"tiktok-share-dialog",children:[(0,X.jsx)("div",{className:"absolute inset-0 bg-black/75 backdrop-blur-sm",onClick:a}),(0,X.jsxs)("div",{className:"relative z-10 w-full max-w-sm overflow-hidden rounded-3xl border border-white/15 bg-[#0b0b16] [html.light_&]:bg-[#e9edf4] p-5 shadow-2xl",children:[(0,X.jsx)("button",{"data-testid":"tiktok-dialog-close",onClick:a,className:"absolute right-3 top-3 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})}),(0,X.jsxs)("div",{className:"mb-4 flex items-center gap-2",children:[(0,X.jsx)("div",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-white text-black",children:(0,X.jsx)(ke.A,{className:"h-5 w-5"})}),(0,X.jsx)("h3",{className:"font-display text-lg font-black text-white",children:"Pataje sou TikTok"})]}),j?(0,X.jsx)("div",{className:"flex h-24 items-center justify-center",children:(0,X.jsx)(ve.A,{className:"h-6 w-6 animate-spin text-white/60"})}):null!==g&&void 0!==g&&g.connected?"done"===Z?(0,X.jsxs)("div",{"data-testid":"tiktok-done-view",className:"py-4 text-center",children:[(0,X.jsx)("div",{className:"mx-auto mb-3 flex h-14 w-14 items-center justify-center rounded-full bg-green-500 text-white",children:(0,X.jsx)(W.A,{className:"h-7 w-7"})}),(0,X.jsx)("p",{className:"text-sm font-semibold text-white",children:"draft"===M?"Voye nan bwat TikTok ou!":"Ap pibliye sou TikTok!"}),(0,X.jsx)("p",{className:"mt-1 text-xs text-white/50",children:"draft"===M?"Louvri app TikTok la pou w fini epi pibliye.":"Videyo a ap par\xe8t apre yon ti moman."}),(0,X.jsx)("button",{"data-testid":"tiktok-done-close",onClick:a,className:"mt-4 h-10 w-full rounded-full bg-white/10 text-sm font-bold text-white hover:bg-white/20",children:"F\xe8men"})]}):(0,X.jsxs)("div",{"data-testid":"tiktok-share-view",className:"space-y-3",children:[g.display_name&&(0,X.jsxs)("p",{className:"text-xs text-white/50",children:["Konekte k\xf2m ",(0,X.jsx)("span",{className:"font-bold text-white",children:g.display_name})]}),(0,X.jsxs)("div",{children:[(0,X.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wide text-white/40",children:"Tit / Kapsyon"}),(0,X.jsx)("textarea",{"data-testid":"tiktok-title-input",value:S,onChange:e=>R(e.target.value),rows:2,maxLength:2200,placeholder:"Ekri yon kapsyon\u2026",className:"w-full rounded-xl bg-white/5 p-3 text-sm text-white outline-none ring-1 ring-white/10 focus:ring-white/30"})]}),(0,X.jsxs)("div",{children:[(0,X.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wide text-white/40",children:"Kijan pou pataje"}),(0,X.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,X.jsx)("button",{"data-testid":"tiktok-mode-draft",onClick:()=>P("draft"),className:"h-10 rounded-xl text-xs font-bold transition-colors ".concat("draft"===M?"bg-white text-black":"bg-white/5 text-white/70 ring-1 ring-white/10"),children:"Bouyon (fini nan TikTok)"}),(0,X.jsx)("button",{"data-testid":"tiktok-mode-direct",onClick:()=>P("direct"),className:"h-10 rounded-xl text-xs font-bold transition-colors ".concat("direct"===M?"bg-white text-black":"bg-white/5 text-white/70 ring-1 ring-white/10"),children:"Pibliye kounye a"})]})]}),"direct"===M&&(0,X.jsxs)("div",{children:[(0,X.jsx)("label",{className:"mb-1 block text-[11px] font-bold uppercase tracking-wide text-white/40",children:"Konfidansyalite"}),(0,X.jsxs)("select",{"data-testid":"tiktok-privacy-select",value:L,onChange:e=>z(e.target.value),className:"h-10 w-full rounded-xl bg-white/5 px-3 text-sm text-white outline-none ring-1 ring-white/10",children:[(0,X.jsx)("option",{value:"SELF_ONLY",children:"S\xe8lman mwen"}),(0,X.jsx)("option",{value:"MUTUAL_FOLLOW_FRIENDS",children:"Zanmi"}),(0,X.jsx)("option",{value:"PUBLIC_TO_EVERYONE",children:"Tout moun"})]})]}),(0,X.jsxs)("div",{className:"rounded-xl bg-white/5 p-3 ring-1 ring-white/10",children:[(0,X.jsx)("p",{className:"mb-2 text-[11px] font-bold uppercase tracking-wide text-white/40",children:"Pataje an menm tan sou"}),(0,X.jsxs)("label",{"data-testid":"tiktok-also-fb",className:"flex cursor-pointer items-center justify-between py-1",children:[(0,X.jsx)("span",{className:"text-sm text-white/80",children:"Facebook (paj HAITIPAL)"}
1),(0,X.jsx)("input",{type:"checkbox",checked:q,onChange:e=>B(e.target.checked),className:"h-5 w-5 accent-[#1877F2]"})]}),(0,X.jsxs)("label",{"data-testid":"tiktok-also-x",className:"flex cursor-pointer items-center justify-between py-1",children:[(0,X.jsx)("span",{className:"text-sm text-white/80",children:"X (Twitter)"}),(0,X.jsx)("input",{type:"checkbox",checked:H,onChange:e=>G(e.target.checked),className:"h-5 w-5 accent-white"})]})]}),(0,X.jsx)("button",{"data-testid":"tiktok-share-submit",disabled:A,onClick:async()=>{F(!0),Q("posting");try{const e=(await d.Ay.post("/tiktok/share",{session_id:r,video_url:o,image_url:m,title:S,mode:M,privacy_level:L,also_facebook:q,also_x:H})).data;Q("done"),u.oR.success("draft"===M?"Videyo a voye nan bwat TikTok ou \u2014 fini l nan app TikTok la! \ud83c\udfb5":"Videyo a ap pibliye sou TikTok! \ud83c\udfb5"),e.publish_id&&setTimeout(()=>{d.Ay.get("/tiktok/share/".concat(e.publish_id)).catch(()=>{})},6e3)}catch(a){var e,t;Q(null),u.oR.error((null===a||void 0===a||null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Pataj TikTok la echwe")}finally{F(!1)}},className:"flex h-12 w-full items-center justify-center gap-2 rounded-full bg-gradient-to-r from-[#25F4EE] to-[#FE2C55] font-display text-sm font-black uppercase tracking-wide text-black transition-transform hover:scale-[1.02] disabled:opacity-60",children:A?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ke.A,{className:"h-4 w-4"})," Voye sou TikTok"]})})]}):(0,X.jsxs)("div",{"data-testid":"tiktok-connect-view",children:[(0,X.jsx)("p",{className:"mb-4 text-sm text-white/60",children:"Konekte kont TikTok ou pou w ka pataje videyo HAITIPAL yo dir\xe8kteman."}),(0,X.jsx)("button",{"data-testid":"tiktok-connect-btn",disabled:A,onClick:async()=>{F(!0);try{const e=(await d.Ay.get("/tiktok/oauth/start")).data;window.location.assign(e.authorize_url)}catch(a){var e,t;u.oR.error((null===a||void 0===a||null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Nou pa ka konekte TikTok"),F(!1)}},className:"flex h-12 w-full items-center justify-center gap-2 rounded-full bg-white font-display text-sm font-black uppercase tracking-wide text-black transition-transform hover:scale-[1.02] disabled:opacity-60",children:A?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ke.A,{className:"h-4 w-4"})," Konekte TikTok"]})})]})]})]}),document.body)}var xt=a(9340);function pt(e){(!isFinite(e)||e<0)&&(e=0);const t=Math.floor(e/60),a=Math.floor(e%60);return"".concat(t,":").concat(String(a).padStart(2,"0"))}function ft(e){let t=e.src,a=e.mine;const n=(0,i.useRef)(null),r=(0,i.useState)(null),l=(0,s.A)(r,2),o=l[0],c=l[1],d=(0,i.useState)(!1),u=(0,s.A)(d,2),m=u[0],h=u[1],x=(0,i.useState)(0),p=(0,s.A)(x,2),f=p[0],g=p[1],v=(0,i.useState)(0),b=(0,s.A)(v,2),w=b[0],j=b[1];(0,i.useEffect)(()=>{let e=!1;return(async()=>{try{const n=await fetch(t),s=await n.arrayBuffer(),i=new(window.AudioContext||window.webkitAudioContext),r=await i.decodeAudioData(s),l=r.getChannelData(0),o=Math.floor(l.length/40)||1,d=[];for(let e=0;e<40;e++){let t=0;for(let a=0;a<o;a++)t+=Math.abs(l[e*o+a]||0);d.push(t/o)}const u=Math.max(...d,1e-4),m=d.map(e=>Math.max(.1,e/u));try{i.close()}catch(a){}e||(c(m),isFinite(r.duration)&&r.duration>0&&g(r.duration))}catch(n){e||c(Array.from({length:40},(e,t)=>.25+.6*Math.abs(Math.sin(.7*t))))}})(),()=>{e=!0}},[t]);const y=f?w/f:0,k=o||Array.from({length:40},()=>.3),N=m?Math.max(0,f-w):f;return(0,X.jsxs)("div",{className:"mb-1 flex w-56 max-w-full items-center gap-2","data-testid":"voice-note",children:[(0,X.jsx)("audio",{ref:n,src:t,preload:"metadata",onLoadedMetadata:e=>{isFinite(e.target.duration)&&e.target.duration>0&&g(e.target.duration)},onDurationChange:e=>{isFinite(e.target.duration)&&e.target.duration>0&&g(e.target.duration)},onTimeUpdate:e=>j(e.target.currentTime),onPlay:()=>h(!0),onPause:()=>h(!1),onEnded:()=>{h(!1),j(0)}}),(0,X.jsx)("button",{type:"button",onClick:()=>{const e=n.current;e&&(m?e.pause():e.play().catch(()=>{}))},"data-testid":"voice-note-toggle",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-transform hover:scale-105 ".concat(a?"bg-white/25 text-white":"bg-[#FF2A5F] text-white"),children:m?(0,X.jsx)(xt.A,{className:"h-4 w-4"}):(0,X.jsx)($e.A,{className:"h-4 w-4 translate-x-[1px]"})}),(0,X.jsx)("div",{className:"flex h-8 flex-1 cursor-pointer items-center gap-[2px]",onClick:e=>{const t=n.current;if(!t||!f)return;const a=e.currentTarget.getBoundingClientRect(),s=Math.min(1,Math.max(0,(e.clientX-a.left)/a.width));t.currentTime=s*f,j(s*f)},"data-testid":"voice-note-waveform",children:k.map((e,t)=>{const n=t/40<=y;return(0,X.jsx)("span",{style:{height:"".concat(Math.round(100*e),"%")},className:"w-[3px] shrink-0 rounded-full transition-colors ".concat(n?a?"bg-white":"bg-[#FF2A5F]":a?"bg-white/40":"bg-slate-300")},t)}
1)}),(0,X.jsx)("span",{className:"shrink-0 text-[11px] tabular-nums ".concat(a?"text-white/80":"text-slate-500"),"data-testid":"voice-note-duration",children:pt(N)})]})}var gt=a(8371),vt=a(9871);const bt=new Map,wt=new Map;let jt=[],yt=null;async function kt(){yt=null;const e=jt;if(jt=[],!e.length)return;const t={};e.forEach(e=>{var a;(t[a=e.lang]||(t[a]=[])).push(e)});for(const i of Object.entries(t)){var a=(0,s.A)(i,2);const e=a[0],t=a[1],r=t.map(e=>e.text);try{const a=(await d.Ay.post("/translate/batch",{texts:r,target:e})).data,n=a&&a.translations||r;t.forEach((e,t)=>{var a;const s=null!==(a=n[t])&&void 0!==a?a:e.text;bt.set(e.key,s),(wt.get(e.key)||[]).forEach(e=>e(s)),wt.delete(e.key)})}catch(n){t.forEach(e=>{(wt.get(e.key)||[]).forEach(t=>t(e.text)),wt.delete(e.key)})}}}function Nt(e,t){const a="".concat(e,":").concat(t);return bt.has(a)?Promise.resolve(bt.get(a)):new Promise(n=>{wt.has(a)||(wt.set(a,[]),jt.push({lang:e,text:t,key:a})),wt.get(a).push(n),yt||(yt=setTimeout(kt,250))})}function At(e){let t=e.text,a=e.render,n=e.className,r=e.toggleClassName;const l=(0,vt.u)(),o=l.lang,c=l.t,d=(0,i.useState)(null),u=(0,s.A)(d,2),m=u[0],h=u[1],x=(0,i.useState)(!1),p=(0,s.A)(x,2),f=p[0],g=p[1],v=(0,i.useState)(!1),b=(0,s.A)(v,2),w=b[0],j=b[1],y=(0,i.useState)(!1),k=(0,s.A)(y,2),N=k[0],A=k[1],F=(0,i.useRef)(null),_="ht"!==o&&!!t;(0,i.useEffect)(()=>{if(!_)return void A(!1);const e="".concat(o,":").concat(t);if(bt.has(e))return void A(!0);const a=F.current;if(!a)return;const n=new IntersectionObserver(e=>{(0,s.A)(e,1)[0].isIntersecting&&(A(!0),n.disconnect())},{rootMargin:"150px"});return n.observe(a),()=>n.disconnect()},[t,o,_]),(0,i.useEffect)(()=>{if(g(!1),!_)return void h(null);const e="".concat(o,":").concat(t);if(bt.has(e))return void h(bt.get(e));if(!N)return;let a=!0;return j(!0),Nt(o,t).then(e=>{a&&h(e)}).finally(()=>{a&&j(!1)}),()=>{a=!1}},[t,o,_,N]);const C=a||(e=>e);if(!_)return(0,X.jsx)("span",{className:n,"data-notranslate":!0,children:C(t)});const S=f||null==m?t:m;return(0,X.jsxs)("span",{ref:F,className:n,"data-notranslate":!0,children:[C(S),w&&null==m&&(0,X.jsxs)("span",{className:"ml-1 opacity-60 text-[10px]",children:["\xb7 ",c("chat.translating")]}),null!=m&&m!==t&&(0,X.jsx)("button",{type:"button","data-testid":"chat-translate-toggle",onClick:e=>{e.stopPropagation(),g(e=>!e)},className:r||"mt-0.5 block text-[10px] font-semibold opacity-70 underline hover:opacity-100",children:c(f?"chat.see_translation":"chat.see_original")})]})}var Ft=a(8502),_t=a(1824),Ct=a.n(_t),St=a(4370);const Rt=e=>e&&/^[A-Za-z]{2}$/.test(e)?"https://flagcdn.com/20x15/".concat(e.toLowerCase(),".png"):null,Et={busy:he.A,idle:xe.A},Tt=e=>e&&e.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(e):e,Mt={sans:"'Outfit', sans-serif",display:"'Unbounded', sans-serif",mono:"'JetBrains Mono', monospace",serif:"Georgia, 'Times New Roman', serif"},Pt={sans:"N\xf2mal",display:"Tit",mono:"Mono",serif:"Serif"},Dt=["","#FF2A5F","#0EA5E9","#16A34A","#9333EA","#EA580C"];function It(e){const t=/\*\*([^*]+)\*\*|\*([^*]+)\*|_([^_]+)_/g,a=[];let n,s=0,i=0;for(;n=t.exec(e);)n.index>s&&a.push(e.slice(s,n.index)),void 0!==n[1]?a.push((0,X.jsx)("strong",{children:n[1]},i++)):void 0!==n[2]?a.push((0,X.jsx)("em",{children:n[2]},i++)):a.push((0,X.jsx)("u",{children:n[3]},i++)),s=t.lastIndex;return s<e.length&&a.push(e.slice(s)),a}function Lt(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",timeZone:"America/New_York"})}catch(t){return""}}const zt=["\ud83d\ude00","\ud83d\ude02","\ud83e\udd23","\ud83d\ude0a","\ud83d\ude0d","\ud83d\ude18","\ud83d\ude1c","\ud83e\udd14","\ud83d\ude0e","\ud83e\udd73","\ud83d\ude22","\ud83d\ude2d","\ud83d\ude21","\ud83d\ude31","\ud83e\udd70","\ud83d\ude34","\ud83d\udc4d","\ud83d\udc4e","\ud83d\udc4f","\ud83d\ude4f","\ud83d\udcaa","\ud83d\udd25","\u2764\ufe0f","\ud83d\udc94","\ud83d\udcaf","\ud83c\udf89","\ud83c\udf81","\u2b50","\u2728","\ud83d\udc83","\ud83d\udd7a","\ud83c\udfb6","\ud83d\ude07","\ud83e\udd17","\ud83d\ude0f","\ud83d\ude44","\ud83d\ude05","\ud83e\udd29","\ud83e\udd7a","\ud83d\udc8b"],Vt=["\ud83d\udc4d","\u2764\ufe0f","\ud83d\ude02","\ud83d\ude2e","\ud83d\ude22","\ud83d\udd25","\ud83c\udf89","\ud83d\udc4f"];function Ot(e){let t=e.src,a=e.onClose;const n=(0,i.useState)(1),r=(0,s.A)(n,2),l=r[0],o=r[1];if((0,i.useEffect)(()=>{o(1)},[t]),(0,i.useEffect)(()=>{const e=e=>{"Escape"===e.key&&a()};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[a]),!t)return null;const c=e=>Math.min(4,Math.max(1,e));return(0,X.jsxs)("div",{"data-testid":"chat-image-lightbox",onClick:a,className:"fixed inset-0 z-[120] flex items-center justify-center bg-black/90 backdrop-blur-sm",onWheel:e=>o(t=>c(t+(e.deltaY<0?.3:-.3))),children:[(0,X.jsxs)("div",{className:"absolute right-4 top-4 z-10 flex items-center gap-2",children:[(0,X.jsx)("button",{"data-testid":"lightbox-zoom-out",onClick:e=>{e.stopPropagation(),o(e=>c(e-.5))},title:"Rapiti",className:"flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:(0,X.jsx)(pe.A,{className:"h-5 w-5"})}),(0,X.jsx)("button",{"data-testid":"lightbox-zoom-in",onClick:e=>{e.stopPropagation(),o(e=>c(e+.5))},title:"Zoom",className:"flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20",children:(0,X.jsx)(fe.A,{className:"h-5 w-5"})}),(0,X.jsx)("button",{"data-testid":"lightbox-close",onClick:e=>{e.stopPropagation(),a()},title:"F\xe8men",className:"flex h-10 w-10 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-red-500/70",children:(0,X.jsx)(ge.A,{className:"h-5 w-5"})})]}),(0,X.jsx)("img",{src:t,alt:"foto","data-testid":"lightbox-image",onClick:e=>{e.stopPropagation(),o(e=>e>1?1:2.2)},style:{transform:"scale(".concat(l,")"),cursor:l>1?"zoom-out":"zoom-in"},className:"max-h-[88vh] max-w-[92vw] rounded-xl object-contain transition-transform duration-200"})]})}function qt(e){let t=e.userId,a=e.canSeeIp,n=e.children;const r=(0,i.useState)(null),l=(0,s.A)(r,2),o=l[0],c=l[1],u=(0,i.useState)(null),m=(0,s.A)(u,2),h=m[0],x=m[1],p=(0,i.useState)(!1),f=(0,s.A)(p,2),g=f[0],v=f[1],b=(0,i.useState)(null),w=(0,s.A)(b,2),j=w[0],y=w[1],k=(0,i.useState)(!1),N=(0,s.A)(k,2),A=N[0],F=N[1],_=(0,i.useRef)(null);if((0,i.useEffect)(()=>
1{if(!g)return;const e=()=>v(!1);return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e)}},[g]),!a||!t)return(0,X.jsx)(X.Fragment,{children:n});const C=async()=>{if(o)return o;try{const e=await d.Ay.get("/mod/user-ip/".concat(t)),a=e.data.ip||"\u2014";return c(a),a}catch(e){return c("\u2014"),"\u2014"}};return(0,X.jsxs)("span",{ref:_,className:"cursor-pointer",onMouseEnter:async()=>{var e;if(g)return;const t=null===(e=_.current)||void 0===e?void 0:e.getBoundingClientRect();t&&x({x:Math.round(t.left),y:Math.round(t.bottom+4)}),o||await C()},onMouseLeave:()=>x(null),onClick:async e=>{var t;e.preventDefault(),e.stopPropagation();const a=null===(t=_.current)||void 0===t?void 0:t.getBoundingClientRect();a&&x({x:Math.round(a.left),y:Math.round(a.bottom+4)}),v(!0);const n=await C();if(n&&"\u2014"!==n){F(!0);try{const e=(await d.Ay.get("/mod/ip-accounts",{params:{ip:n}})).data;y(e.accounts||[])}catch(s){y([])}finally{F(!1)}}else y([])},"data-testid":"name-ip-".concat(t),children:[n,h&&!g&&(0,me.createPortal)((0,X.jsxs)("span",{style:{position:"fixed",left:h.x,top:h.y,zIndex:9999},"data-testid":"ip-tooltip-".concat(t),className:"pointer-events-none whitespace-nowrap rounded-md bg-black px-2 py-1 font-mono text-[10px] font-normal text-white shadow-lg ring-1 ring-white/20",children:["IP: ",o||"\u2026"," \xb7 klike"]}),document.body),g&&h&&(0,me.createPortal)((0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:e=>{e.stopPropagation(),v(!1)}}),(0,X.jsxs)("div",{style:{position:"fixed",left:Math.min(h.x,("undefined"!==typeof window?window.innerWidth:1e3)-280),top:h.y,zIndex:9999,width:264},onClick:e=>e.stopPropagation(),"data-testid":"ip-accounts-panel-".concat(t),className:"max-h-80 overflow-y-auto rounded-xl border border-white/15 bg-[#0d0d14] [html.light_&]:bg-[#e9edf4] p-2 text-left shadow-2xl",children:[(0,X.jsxs)("div",{className:"mb-1.5 flex items-center justify-between px-1",children:[(0,X.jsxs)("span",{className:"font-mono text-[11px] font-bold text-[#00F0FF]",children:["IP: ",o||"\u2026"]}),(0,X.jsx)("button",{"data-testid":"ip-accounts-close-".concat(t),onClick:e=>{e.stopPropagation(),v(!1)},className:"rounded-full bg-white/10 p-1 text-gray-300 hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-3 w-3"})})]}),A||null===j?(0,X.jsxs)("div",{className:"flex items-center justify-center gap-2 py-4 text-xs text-gray-400",children:[(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"})," Chajman\u2026"]}):0===j.length?(0,X.jsx)("p",{className:"px-1 py-3 text-center text-xs text-gray-500",children:"Pa gen okenn kont sou IP sa a."}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("p",{className:"mb-1 px-1 text-[10px] font-bold uppercase tracking-wide text-gray-500",children:[j.length," kont sou IP sa a"]}),(0,X.jsx)("div",{className:"space-y-0.5",children:j.map(e=>(0,X.jsxs)("div",{"data-testid":"ip-account-".concat(e.user_id),className:"flex items-center gap-2 rounded-lg px-1.5 py-1.5 ".concat(e.user_id===t?"bg-[#9333EA]/15":"hover:bg-white/5"),children:[(0,X.jsx)("img",{src:Tt(e.picture)||"/haitipal-logo.png",alt:"",className:"h-7 w-7 shrink-0 rounded-full object-cover"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsxs)("p",{className:"truncate text-xs font-semibold text-white",children:[e.name,e.user_id===t&&(0,X.jsx)("span",{className:"ml-1 text-[9px] text-[#c084fc]",children:"(sa a)"})]}),e.username&&(0,X.jsxs)("p",{className:"truncate text-[10px] text-gray-400",children:["@",e.username]})]}),(0,X.jsxs)("div",{className:"flex shrink-0 flex-wrap items-center justify-end gap-1",children:[e.banned&&(0,X.jsx)("span",{className:"rounded bg-red-500/20 px-1 py-0.5 text-[9px] font-bold text-red-400",children:"bloke"}),e.is_guest&&(0,X.jsx)("span",{className:"rounded bg-white/10 px-1 py-0.5 text-[9px] font-bold text-gray-300",children:"envite"}),e.is_bot&&(0,X.jsx)("span",{className:"rounded bg-[#00A8CC]/20 px-1 py-0.5 text-[9px] font-bold text-[#00F0FF]",children:"robot"}),("admin"===e.role||"moderator"===e.role)&&(0,X.jsx)("span",{className:"rounded bg-[#FFD700]/15 px-1 py-0.5 text-[9px] font-bold text-[#FFD700]",children:"admin"===e.role?"admin":"mod"})]})]},e.user_id))})]})]})]}),document.body)]})}function Bt(e){let t=e.messages,a=e.selfUserId,n=e.overlay,l=e.showTime,o=e.onDelete,c=e.onAdClick,d=e.onReact,u=e.onReply,m=e.hostId,h=e.canSeeIp,x=void 0!==h&&h,p=e.onTiktokShare;const f=(0,i.useRef)(null),g=(0,r.Zp)(),v=(0,Ft.X)().openAvatar,b=(0,i.useState)(null),w=(0,s.A)(b,2),j=w[0],y=w[1],k=(0,i.useState)(null),N=(0,s.A)(k,2),A=N[0],F=N[1],_=(0,i.useState)(()=>new Set),C=(0,s.A)(_,2),M=C[0],P=C[1];(0,i.useEffect)(()=>{var e;null===(e=f.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})},[t]);const D=n?{maskImage:"linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.35) 18%, black 42%)",WebkitMaskImage:"linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.35) 18%, black 42%)"}:void 0;return(0,X.jsxs)("div",{className:"flex-1 space-y-3 overflow-y-auto px-4 py-3 scroll-red","data-testid":"chat-messages",style:D,children:[0===t.length&&(0,X.jsx)("p",{className:"mt-8 text-center text-sm ".concat(n?"text-white/70 drop-shadow":"text-slate-400"),children:"Poko gen mesaj. Di bonjou \ud83d\udc4b"}),t.map(e=>{const t=e.from_id===a,i=e.style||{};if(e.announcement)return(0,X.jsx)("div",{"data-testid":"announcement-".concat(e.id),className:"flex justify-center",children:(0,X.jsxs)("div",{className:"flex w-full items-start gap-2 rounded-2xl border border-[#FFD700]/50 bg-gradient-to-r from-[#FFD700]/20 to-[#FF2A5F]/10 px-3 py-2 shadow-sm",children:[(0,X.jsx)(be.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#FFD700]"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsxs)("p",{className:"text-[11px] font-bold uppercase tracking-wide text-[#FFD700] ".concat(n?"drop-shadow":""),children:["Anons \xb7 ",e.from_name,l&&e.created_at&&(0,X.jsx)("span",{className:"ml-1.5 font-normal opacity-70",children:Lt(e.created_at)})]}),(0,X.jsx)("div",{className:"mt-0.5 whitespace-pre-wrap break-words text-sm ".concat(n?"text-white drop-shadow":"text-slate-800"),children:(0,X.jsx)(At,{text:e.text,render:It})}),e.live_room&&(0,X.jsxs)("button",{"data-testid":"announcement-join-".concat(e.id),onClick:()=>g("/room/".concat(e.live_room)),className:"mt-2 inline-flex items-center gap-1.5 rounded-full bg-[#FF2A5F] px-3 py-1.5 text-xs font-bold text-white transition-transform hover:scale-105",children:[(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5"})," Antre nan dir\xe8k la"]})]})]})},e.id);if(e.radio_note)return(0,X.jsx)("div",{"data-testid":"radio-note-".concat(e.id),className:"flex justify-center",children:(0,X.jsxs)("div",{className:"flex items-center gap-2 rounded-full bg-[#00F0FF]/10 px-3 py-1 ring-1 ring-[#00F0FF]/30",children:[e.station_logo?(0,X.jsx)("img",{src:Tt(e.station_logo),alt:"",className:"h-4 w-4 roun
1ded object-cover"}):(0,X.jsx)("span",{className:"text-xs","aria-hidden":!0,children:"\ud83c\udfa7"}),(0,X.jsx)("span",{className:"text-[11px] font-semibold ".concat(n?"text-[#00F0FF]":"text-[#00A8CC]"),children:e.text})]})},e.id);if(e.ad)return M.has(e.id)?null:(0,X.jsx)("div",{"data-testid":"ad-banner-".concat(e.id),className:"flex justify-center",children:(0,X.jsxs)("div",{className:"w-full overflow-hidden rounded-2xl border border-[#FF2A5F]/50 bg-gradient-to-br from-[#FF2A5F]/15 to-[#9333EA]/15 shadow-sm",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between gap-1.5 bg-[#FF2A5F]/20 px-3 py-1",children:[(0,X.jsxs)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,X.jsx)(be.A,{className:"h-3 w-3 shrink-0 text-[#FF2A5F]"}),(0,X.jsxs)("span",{className:"truncate text-[10px] font-bold uppercase tracking-wide text-[#FF2A5F]",children:["Piblisite \xb7 ",e.ad.owner_name||e.from_name]})]}),(0,X.jsx)("button",{onClick:()=>P(t=>{const a=new Set(t);return a.add(e.id),a}),"data-testid":"ad-dismiss-".concat(e.id),title:"F\xe8men piblisite a",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[#FF2A5F] transition-colors hover:bg-[#FF2A5F]/25",children:(0,X.jsx)(ge.A,{className:"h-3.5 w-3.5"})})]}),e.image_url&&(0,X.jsx)("img",{src:e.image_url,alt:"",className:"max-h-24 w-full object-cover","data-testid":"ad-image-".concat(e.id)}),(0,X.jsxs)("div",{className:"px-3 py-1.5",children:[(0,X.jsx)("p",{className:"line-clamp-2 whitespace-pre-wrap break-words text-xs font-semibold ".concat(n?"text-white drop-shadow":"text-slate-800"),children:e.text}),(0,X.jsxs)("div",{className:"mt-1 flex flex-wrap items-center gap-3",children:[e.ad.link_url&&(0,X.jsxs)("a",{href:e.ad.link_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>null===c||void 0===c?void 0:c(e.ad.banner_id),"data-testid":"ad-link-".concat(e.id),className:"inline-flex items-center gap-1 text-xs font-bold text-[#00A8CC] hover:underline",children:[(0,X.jsx)(we.A,{className:"h-3.5 w-3.5"})," Vizite"]}),e.ad.phone&&(0,X.jsxs)("a",{href:"tel:".concat(e.ad.phone),onClick:()=>null===c||void 0===c?void 0:c(e.ad.banner_id),"data-testid":"ad-phone-".concat(e.id),className:"inline-flex items-center gap-1 text-xs font-bold text-[#00A8CC] hover:underline",children:[(0,X.jsx)(je.A,{className:"h-3.5 w-3.5"})," ",e.ad.phone]})]})]})]})},e.id);const r={fontFamily:i.font?Mt[i.font]:void 0,color:i.color||void 0,fontWeight:i.bold?700:void 0,fontStyle:i.italic?"italic":void 0},h=m&&e.from_id===m;return(0,X.jsxs)("div",{"data-msg-id":e.id,className:"group flex gap-2",children:[(0,X.jsx)("img",{src:e.from_picture,alt:"","data-testid":"chat-avatar-".concat(e.id),onClick:()=>e.from_picture&&v(e.from_picture,e.from_name),className:"h-7 w-7 flex-shrink-0 cursor-pointer rounded-full object-cover transition-transform hover:scale-110 ".concat(h?"ring-2 ring-[#FFD700]":"")}),(0,X.jsxs)("div",{className:"max-w-[75%]",children:[(0,X.jsxs)("p",{className:"flex items-center gap-1 text-[11px] ".concat((0,Y.eR)(e,!0)?"".concat((0,Y.oL)(e,n)," font-bold"):n?"text-white/80 drop-shadow":"text-slate-500"),children:[h&&(0,X.jsxs)("span",{"data-testid":"host-badge-".concat(e.id),className:"flex items-center gap-0.5 rounded-full bg-[#FFD700] px-1.5 py-0.5 text-[9px] font-black uppercase text-black",children:[(0,X.jsx)(ne.A,{className:"h-2.5 w-2.5"})," Host"]}),"admin"===e.from_role&&(0,X.jsx)(S.A,{className:"h-3 w-3 text-red-500","data-testid":"role-badge-admin-".concat(e.id)}),"moderator"===e.from_role&&(0,X.jsx)(R.A,{className:"h-3 w-3 text-green-500","data-testid":"role-badge-mod-".concat(e.id)}),e.from_vip&&"admin"!==e.from_role&&"moderator"!==e.from_role&&(0,X.jsx)(E.A,{className:"h-3 w-3 text-blue-500","data-testid":"vip-crown-".concat(e.id)}),e.from_champion&&(0,X.jsx)(E.A,{className:"h-3 w-3 text-[#FFD700]","data-testid":"champion-crown-".concat(e.id),title:"Chanpyon konpetisyon"}),e.from_jenipal_champ&&(0,X.jsx)(T.A,{className:"h-3 w-3 text-[#FFD700]","data-testid":"jenipal-champ-crown-".concat(e.id),title:"Chanpyon JeniPal mwa a"}),t?"Ou":(0,X.jsx)(qt,{userId:e.from_id,canSeeIp:x,children:e.from_name}),l&&e.created_at&&(0,X.jsx)("span",{className:"ml-1 opacity-70","data-testid":"dm-timestamp",children:Lt(e.created_at)})]}),(0,X.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5",children:[(0,X.jsxs)("div",{style:r,className:"inline-block whitespace-pre-wrap break-words rounded-2xl px-3 py-2 text-sm shadow-sm ".concat(t?"bg-[#FF2A5F] text-white":h?"bg-[#FFF8E1] text-slate-900 ring-1 ring-[#FFD700]/70":"bg-white text-slate-800 ring-1 ring-sky-100"),children:[e.reply_to&&(0,X.jsxs)("button",{type:"button","data-testid":"reply-quote-".concat(e.id),onClick:()=>{const t=document.querySelector('[data-msg-id="'.concat(e.reply_to.id,'"]'));t&&(t.scrollIntoView({behavior:"smooth",block:"center"}),t.classList.add("reply-flash"),setTimeout(()=>t.classList.remove("reply-flash"),1200))},className:"mb-1.5 flex w-full items-start gap-1.5 rounded-lg border-l-2 px-2 py-1 text-left text-[11px] ".concat(t?"border-white/70 bg-white/15 text-white/90":"border-[#00A8CC] bg-[#00A8CC]/10 text-slate-600"),children:[(0,X.jsx)(ye.A,{className:"mt-0.5 h-3 w-3 shrink-0 opacity-70"}),(0,X.jsxs)("span",{className:"min-w-0",children:[(0,X.jsx)("span",{className:"font-bold",children:e.reply_to.from_name}),e.reply_to.text&&(0,X.jsx)("span",{className:"ml-1 line-clamp-2 break-words opacity-85",children:e.reply_to.text})]})]}),e.image_url&&(0,X.jsx)("button",{type:"button",onClick:()=>y(e.image_url),"data-testid":"chat-image-link",className:"block cursor-zoom-in",children:(0,X.jsx)("img",{src:e.image_url,alt:"foto",className:"mb-1 max-h-52 w-auto max-w-full rounded-xl object-cover"})}),e.audio_url&&(0,X.jsx)(ft,{src:e.audio_url,mine:t}),e.video_url&&(0,X.jsxs)("div",{className:"mb-1",children:[(0,X.jsx)("video",{controls:!0,playsInl
1ine:!0,preload:"metadata",src:e.video_url,poster:e.poster_url||e.video_url.replace(/\.(mp4|webm|mov|ogg|m4v|avi)(?=$|\?)/i,".jpg"),"data-testid":"chat-video",className:"max-h-56 w-auto max-w-full rounded-xl bg-black object-cover"}),(0,X.jsxs)("button",{"data-testid":"chat-video-tiktok-btn",onClick:()=>null===p||void 0===p?void 0:p({videoUrl:e.video_url,imageUrl:e.poster_url||e.video_url.replace(/\.(mp4|webm|mov|ogg|m4v|avi)(?=$|\?)/i,".jpg")}),className:"mt-1 inline-flex items-center gap-1.5 rounded-full bg-white px-3 py-1 text-[11px] font-bold text-black transition-transform hover:scale-105",children:[(0,X.jsx)(ke.A,{className:"h-3 w-3"})," Pataje sou TikTok"]})]}),e.text&&(0,X.jsx)(At,{text:e.text,render:It})]}),t&&o&&(0,X.jsx)("button",{"data-testid":"delete-msg-".concat(e.id),onClick:()=>o(e),title:"Efase pou tout moun",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100 ".concat(n?"bg-white/15 text-white/80 hover:bg-red-500/70 hover:text-white":"text-slate-400 hover:bg-red-100 hover:text-red-600"),children:(0,X.jsx)(Ne.A,{className:"h-3.5 w-3.5"})}),u&&(0,X.jsx)("button",{"data-testid":"reply-btn-".concat(e.id),onClick:()=>u(e),title:"Reponn mesaj sa a",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100 ".concat(n?"text-white/80 hover:bg-white/15":"text-slate-400 hover:bg-slate-100"),children:(0,X.jsx)(ye.A,{className:"h-3.5 w-3.5"})}),d&&(0,X.jsxs)("div",{className:"relative shrink-0",children:[(0,X.jsx)("button",{"data-testid":"react-btn-".concat(e.id),onClick:()=>F(A===e.id?null:e.id),title:"Reyaji ak yon emoji",className:"flex h-7 w-7 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100 ".concat(n?"text-white/80 hover:bg-white/15":"text-slate-400 hover:bg-slate-100"),children:(0,X.jsx)(Ae.A,{className:"h-3.5 w-3.5"})}),A===e.id&&(0,X.jsx)("div",{"data-testid":"react-picker-".concat(e.id),className:"absolute bottom-8 left-0 z-30 flex gap-0.5 rounded-full border border-slate-200 bg-white p-1 shadow-xl",children:Vt.map(t=>(0,X.jsx)("button",{type:"button","data-testid":"react-emoji-".concat(t),onClick:()=>{d(e.id,t),F(null)},className:"flex h-7 w-7 items-center justify-center rounded-full text-base transition-transform hover:scale-125 hover:bg-slate-100",children:t},t))})]})]}),e.reactions&&Object.keys(e.reactions).length>0&&(0,X.jsx)("div",{className:"mt-1 flex flex-wrap gap-1","data-testid":"reactions-".concat(e.id),children:Object.entries(e.reactions).map(t=>{let i=(0,s.A)(t,2),r=i[0],l=i[1];const o=Array.isArray(l)?l.length:0;if(o<=0)return null;const c=Array.isArray(l)&&l.includes(a);return(0,X.jsxs)("button",{type:"button",onClick:()=>null===d||void 0===d?void 0:d(e.id,r),"data-testid":"reaction-chip-".concat(r),title:c?"Retire reyaksyon w":"Ajoute reyaksyon w",className:"flex items-center gap-0.5 rounded-full px-1.5 py-0.5 text-xs transition-colors ".concat(c?"bg-[#FF2A5F]/20 ring-1 ring-[#FF2A5F]/50":n?"bg-white/10 hover:bg-white/20":"bg-slate-100 hover:bg-slate-200"," ").concat(n?"text-white":"text-slate-700"),children:[(0,X.jsx)("span",{children:r}),(0,X.jsx)("span",{className:"font-semibold tabular-nums",children:o})]},r)})})]})]},e.id)}),(0,X.jsx)("div",{ref:f}),(0,X.jsx)(Ot,{src:j,onClose:()=>y(null)})]})}function Ut(e){var t,a;let r=e.self,l=e.selfUserId,o=e.peers,c=e.speakingIds,m=e.lobbyMessages,h=e.dmMessages,x=e.onSend,p=e.onDeleteMessage,f=e.onReact,g=e.onSelectDm,v=e.onStartCall,b=e.canCall,w=void 0!==b&&b,j=e.busyPeers,y=void 0===j?{}:j,k=e.friends,N=void 0===k?[]:k,A=e.onAddFriend,F=e.onRemoveFriend,C=e.members,P=void 0===C?[]:C,D=e.serverUnread,I=void 0===D?{}:D,L=e.onReadDm,z=e.overlay,V=void 0!==z&&z,O=e.mobile,q=void 0!==O&&O,U=e.canRecord,K=void 0!==U&&U,H=e.ppvPeers,Z=void 0===H?{}:H,Q=e.onRequestPpv,$=e.dmRequest,ee=void 0===$?null:$,te=e.onDmOpened,ae=e.freshMedia,se=void 0===ae?[]:ae,ie=e.onGift,re=e.onProfile,le=e.showFlags,oe=void 0===le||le,ce=e.pinnedAd,ue=void 0===ce?null:ce,me=e.channelMessages,he=void 0===me?{}:me,xe=e.channelCounts,pe=void 0===xe?{}:xe,be=e.channelActivity,ke=void 0===be?{}:be,Je=e.onJoinChannel,Ye=e.onLeaveChannel,Xe=e.onLoadChannel,Qe=e.onClearActivity,$e=e.typingIds,et=void 0===$e?new Set:$e,tt=e.onTyping,at=e.poll,st=void 0===at?null:at,it=e.myPollVotes,rt=void 0===it?[]:it,lt=e.onVotePoll,ot=e.isGuest,ct=void 0!==ot&&ot,dt=e.onGoLive,ut=e.onUpload,xt=e.hostId,pt=void 0===xt?null:xt,ft=e.liveMode,vt=void 0!==ft&&ft,bt=(e.guestChatUsed,e.guestChatLimit,e.onGuestUpgrade);const wt=(0,i.useState)("lobby"),jt=(0,s.A)(wt,2),yt=jt[0],kt=jt[1],Nt=!!(null!==r&&void 0!==r&&r.is_admin||null!==r&&void 0!==r&&r.is_moderator||"admin"===(null===r||void 0===r?void 0:r.role)||"moderator"===(null===r||void 0===r?void 0:r.role)),At=(0,i.useState)(null),Ft=(0,s.A)(At,2),_t=Ft[0],It=Ft[1],Lt=(0,i.useState)(null),Vt=(0,s.A)(Lt,2),Ot=Vt[0],Ut=Vt[1],Kt=(0,i.useState)(null),Ht=(0,s.A)(Kt,2),Wt=Ht[0],Gt=Ht[1],Jt=(0,i.useState)([]),Yt=(0,s.A)(Jt,2),Xt=Yt[0],Zt=Yt[1],Qt=(0,i.useState)("chat"),$t=(0,s.A)(Qt,2),ea=$t[0],ta=$t[1],aa=(0,i.useState)([]),na=(0,s.A)(aa,2),sa=na[0],ia=na[1],ra=e=>{e&&d.Ay.post("/ads/click/".concat(e)).catch(()=>{})},la=(0,i.useState)(""),oa=(0,s.A)(la,2),ca=oa[0],da=oa[1],ua=(0,i.useState)(null),ma=(0,s.A)(ua,2),ha=ma[0],xa=ma[1],pa=(0,i.useState)({}),fa=(0,s.A)(pa,2),ga=fa[0],va=fa[1],ba=(0,i.useState)(""),wa=(0,s.A)(ba,2),ja=wa[0],ya=wa[1],ka=(0,i.useState)(!1),Na=(0,s.A)(ka,2),Aa=Na[0],Fa=Na[1],_a=(0,i.useState)(null),Ca=(0,s.A)(_a,2),Sa=Ca[0],Ra=Ca[1],Ea=(0,i.useState)(null),Ta=(0,s.A)(Ea,2),Ma=Ta[0],Pa=Ta[1],Da=(0,i.useState)(0),Ia=(0,s.A)(Da,2),La=Ia[0],za=Ia[1],Va=(0,i.useState)(!1),Oa=(0,s.A)(Va,2),qa=Oa[0],Ba=Oa[1],Ua=(0,i.useState)(null),Ka=(0,s.A)(Ua,2),Ha=Ka[0],Wa=Ka[1],Ga=(0,i.useState)(null),Ja=(0,s.A)(Ga,2),Ya=Ja[0],Xa=Ja[1],Za=(0,i.useRef)(null),Qa=(0,i.useRef)(null),$a=(0,i.useRef)(null),en=(0,i.useRef)([]),tn=(0,i.useRef)(null),an=(0,i.useRef)(!1),nn=(0,i.useRef)(0),sn=(0,i.useRef)(null),rn=(0,i.useRef)({}),ln=(0,i.useRef)(!1);(0,i.useEffect)(()=>{"Notification"in window&&"default"===Notification.permission&&Notification.requestPermission().catch(()=>{})},[]);(0,i.useEffect)(()=>
1{if(I&&Object.keys(I).length&&(va(e=>{const t=(0,n.A)({},e);return Object.keys(I).forEach(e=>{I[e]>0&&(t[e]=!0)}),t}),!ln.current)){ln.current=!0;const e=Object.values(I).reduce((e,t)=>e+(t||0),0);e>0&&(0,u.oR)("\ud83d\udcac Ou gen ".concat(e," nouvo mesaj prive"),{description:"Louvri PAL la pou li yo."})}},[I]),(0,i.useEffect)(()=>{Object.entries(h).forEach(e=>{let t=(0,s.A)(e,2),a=t[0],i=t[1];const r=rn.current[a]||0;if(i.length>r)if((null===_t||void 0===_t?void 0:_t.user_id)===a)rn.current[a]=i.length;else{const e=i.slice(r).filter(e=>e.from_id&&e.from_id!==l);e.length&&(va(e=>(0,n.A)((0,n.A)({},e),{},{[a]:!0})),(e=>{if(!e)return;const t=(e.text||"").slice(0,120);try{(0,de.WU)()}catch(a){}(0,u.oR)("\ud83d\udcac ".concat(e.from_name),{description:t});try{if(document.hidden&&"Notification"in window&&"granted"===Notification.permission){const a=new Notification("Nouvo mesaj \u2014 ".concat(e.from_name),{body:t,icon:"/haitipal-logo.png",tag:"htv-dm"});a.onclick=()=>{window.focus(),a.close()}}}catch(n){}})(e[e.length-1])),rn.current[a]=i.length}})},[h,_t,l]),(0,i.useEffect)(()=>{_t&&(rn.current[_t.user_id]=(h[_t.user_id]||[]).length,va(e=>{if(!e[_t.user_id])return e;const t=(0,n.A)({},e);return delete t[_t.user_id],t}),null===L||void 0===L||L(_t.user_id))},[_t]);const on=(0,i.useState)(()=>localStorage.getItem("htv_chatfont")||"sans"),cn=(0,s.A)(on,2),dn=cn[0],un=cn[1],mn=(0,i.useState)(!1),hn=(0,s.A)(mn,2),xn=hn[0],pn=hn[1],fn=(0,i.useState)(()=>localStorage.getItem("htv_chatcolor")||""),gn=(0,s.A)(fn,2),vn=gn[0],bn=gn[1],wn=(0,i.useState)(()=>"1"===localStorage.getItem("htv_chatbold")),jn=(0,s.A)(wn,2),yn=jn[0],kn=jn[1],Nn=(0,i.useState)(()=>"1"===localStorage.getItem("htv_chatitalic")),An=(0,s.A)(Nn,2),Fn=An[0],_n=An[1],Cn=(0,i.useRef)(null),Sn={};Object.values(o).forEach(e=>{e.info&&(Sn[e.info.user_id]=e.info)});const Rn=new Set(Object.keys(Sn)),En=new Set(N.map(e=>e.user_id)),Tn=new Set(se||[]),Mn=(()=>{const e={};vt||P.forEach(t=>{e[t.user_id]=(0,n.A)((0,n.A)({},t),{},{online:!1})}),Object.values(Sn).forEach(t=>{e[t.user_id]=(0,n.A)((0,n.A)((0,n.A)({},e[t.user_id]||{}),t),{},{online:!0})});const t=ja.trim().toLowerCase(),a=e=>{const t=(0,Y.Lc)(e);return"admin"===t?0:"moderator"===t?1:"vip"===t?2:3};return Object.values(e).filter(e=>!t||(e.name||"").toLowerCase().includes(t)||(e.username||"").toLowerCase().includes(t)).sort((e,t)=>{if(e.online!==t.online)return e.online?-1:1;const n=!!e.is_bot&&!e.human_like;if(n!==(!!t.is_bot&&!t.human_like))return n?1:-1;const s=a(e),i=a(t);return s!==i?s-i:(e.name||"").localeCompare(t.name||"")})})();(0,i.useEffect)(()=>{Gt(null)},[_t,Ot,yt]);const Pn=!1,Dn=e=>{e&&((e.type||"").startsWith("video/")?(async e=>{if(!e)return;if(e.size>52428800)return void u.oR.error("Videyo a tw\xf2 gwo (maks 50MB)");const t=new FormData;t.append("file",e),Fa(!0),Ra(0);try{const e=(await d.Ay.post("/uploads/media",t,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:e=>{e.total&&Ra(Math.min(99,Math.round(e.loaded/e.total*100)))}})).data;Ra(100);const a=(null===Wt||void 0===Wt?void 0:Wt.id)||null;Ot?x("","channel",null,null,null,null,e.url,Ot,a):_t?x("","dm",_t.user_id,null,null,null,e.url,null,a):x("","lobby",null,null,null,null,e.url,null,a),Gt(null)}catch(s){var a,n;u.oR.error((null===s||void 0===s||null===(a=s.response)||void 0===a||null===(n=a.data)||void 0===n?void 0:n.detail)||"Nou pa ka voye videyo a")}finally{Fa(!1),Ra(null)}})(e):(async e=>{if(!e)return;if(e.size>5242880)return void u.oR.error("Imaj la tw\xf2 gwo (maks 5MB)");const t=new FormData;t.append("file",e),Fa(!0);try{const e=(await d.Ay.post("/uploads/chat",t,{headers:{"Content-Type":"multipart/form-data"}})).data,a=(null===Wt||void 0===Wt?void 0:Wt.id)||null;Ot?x("","channel",null,null,e.url,null,null,Ot,a):_t?x("","dm",_t.user_id,null,e.url,null,null,null,a):x("","lobby",null,null,e.url,null,null,null,a),Gt(null)}catch(a){u.oR.error("Nou pa ka voye foto a")}finally{Fa(!1)}})(e))},In=()=>{tn.current&&(clearInterval(tn.current),tn.current=null),$a.current&&($a.current.getTracks().forEach(e=>e.stop()),$a.current=null),Qa.current=null,en.current=[],Pa(null),za(0)},Ln=async e=>{if(!Ma)try{const t="video"===e?{audio:!0,video:{width:{ideal:640},height:{ideal:480},facingMode:"user"}}:{audio:!0},a=await navigator.mediaDevices.getUserMedia(t);$a.current=a;const n=(e=>{const t="video"===e?["video/webm;codecs=vp8,opus","video/webm","video/mp4"]:["audio/webm;codecs=opus","audio/webm","audio/mp4","audio/ogg"];for(const i of t)try{var a,n;if(null!==(a=window.MediaRecorder)&&void 0!==a&&null!==(n=a.isTypeSupp
1orted)&&void 0!==n&&n.call(a,i))return i}catch(s){}return""})(e),s=new MediaRecorder(a,n?{mimeType:n}:void 0);Qa.current=s,en.current=[],an.current=!1,s.ondataavailable=e=>{e.data&&e.data.size>0&&en.current.push(e.data)},s.onstop=async()=>{const t=en.current,a=an.current,i=nn.current?Date.now()-nn.current:0;if(In(),a||!t.length)return;const r=s.mimeType||n||("video"===e?"video/webm":"audio/webm");let l=new Blob(t,{type:r});if(r.includes("webm")&&i>0)try{l=await Ct()(l,i,{logger:!1})}catch(m){}if(l.size>26214400)return void u.oR.error("N\xf2t la tw\xf2 gwo (maks 25MB)");const o=r.includes("mp4")?"mp4":r.includes("ogg")?"ogg":"webm",c=new FormData;c.append("file",l,"note.".concat(o)),Fa(!0);try{const e=(await d.Ay.post("/uploads/media",c,{headers:{"Content-Type":"multipart/form-data"}})).data,t="video"===e.kind?null:e.url,a="video"===e.kind?e.url:null,n=(null===Wt||void 0===Wt?void 0:Wt.id)||null;Ot?x("","channel",null,null,null,t,a,Ot,n):_t?x("","dm",_t.user_id,null,null,t,a,null,n):x("","lobby",null,null,null,t,a,null,n),Gt(null)}catch(h){u.oR.error("Nou pa ka voye n\xf2t la")}finally{Fa(!1)}},s.start(),nn.current=Date.now(),Pa(e),za(0),tn.current=setInterval(()=>{za(e=>{if(e>=119)try{s.stop()}catch(t){}return e+1})},1e3),"video"===e&&setTimeout(()=>{var e,t;sn.current&&(sn.current.srcObject=a,null===(e=(t=sn.current).play)||void 0===e||e.call(t).catch(()=>{}))},50)}catch(t){In(),u.oR.error("video"===e?"Nou pa ka jwenn kamera/mikwo w":"Nou pa ka jwenn mikwo w")}};(0,i.useEffect)(()=>()=>{try{var e;null===(e=Qa.current)||void 0===e||e.stop()}catch(t){}In()},[]);const zn=e=>{It(e),g(e.user_id)};(0,i.useEffect)(()=>{ee&&ee.user_id&&(kt("lobby"),It(ee),g(ee.user_id),null===te||void 0===te||te())},[ee]);const Vn=e=>{p&&Wa(e)};(0,i.useEffect)(()=>{"cities"===yt&&0===Xt.length&&d.Ay.get("/rooms/cities").then(e=>Zt(e.data||[])).catch(()=>{})},[yt,Xt.length]),(0,i.useEffect)(()=>{const e=e=>{var t,a;d.Ay.get("/rooms/cities").then(e=>Zt(e.data||[])).catch(()=>{});const n=(null===(t=e.detail)||void 0===t?void 0:t.disabled)||[];Ot&&(n.includes(Ot)||(null===(a=e.detail)||void 0===a?void 0:a.removed)===Ot)&&(null===Ye||void 0===Ye||Ye(Ot),Ut(null),ia([]),u.oR.info("Chanm sa a f\xe8men pa yon administrat\xe8"))};return window.addEventListener("htv-chatrooms-updated",e),()=>window.removeEventListener("htv-chatrooms-updated",e)},[Ot,Ye]);(0,i.useEffect)(()=>{Ot&&(async e=>{if(e)try{const t=(await d.Ay.get("/rooms/cities/".concat(e,"/members"))).data;ia(t.members||[])}catch(t){ia([])}})(Ot)},[Ot,ea,pe[Ot]]);const On=e=>{var t;return(null===(t=Xt.find(t=>t.key===e))||void 0===t?void 0:t.name)||e},qn=[...Xt].sort((e,t)=>(t.is_favorite?1:0)-(e.is_favorite?1:0)),Bn=Object.entries(ke).reduce((e,t)=>{let a=(0,s.A)(t,2),n=a[0],i=a[1];return e+(n===Ot?0:i||0)},0),Un="lobby"===yt||"cities"===yt&&!!Ot;return(0,X.jsxs)("div",{className:"flex h-full w-full flex-col overflow-hidden rounded-2xl ".concat(V?"":"bg-[#E6F2FD] ring-1 ring-sky-200"),"data-testid":"chat-panel",children:[(0,X.jsxs)("div",{className:"flex gap-1 border-b p-2 ".concat(V?"border-white/10 bg-black/45 backdrop-blur-md":"border-sky-200 bg-[#D6EAFB]"),children:[(0,X.jsx)("button",{"data-testid":"chat-tab-lobby",onClick:()=>{kt("lobby"),It(null)},title:"Lakou",className:"flex flex-1 items-center justify-center rounded-xl px-3 py-2 transition-colors ".concat("lobby"===yt?"bg-[#FF2A5F] text-white":V?"text-white/80 hover:bg-white/10":"text-slate-500 hover:bg-white/60"),children:(0,X.jsx)(ne.A,{className:"h-5 w-5"})}),(0,X.jsx)("button",{"data-testid":"chat-tab-friends",onClick:()=>{kt("friends"),It(null)},title:"Zanmi",className:"flex flex-1 items-center justify-center rounded-xl px-3 py-2 transition-colors ".concat("friends"===yt?"bg-[#9333EA] text-white":V?"text-white/80 hover:bg-white/10":"text-slate-500 hover:bg-white/60"),children:(0,X.jsx)(M.A,{className:"h-5 w-5"})}),(0,X.jsxs)("button",{"data-testid":"chat-tab-cities",onClick:()=>{kt("cities"),It(null)},title:"Chanm Vil",className:"relative flex flex-1 items-center justify-center rounded-xl px-3 py-2 transition-colors ".concat("cities"===yt?"bg-[#00A8CC] text-white":V?"text-white/80 hover:bg-white/10":"text-slate-500 hover:bg-white/60"),children:[(0,X.jsx)(Fe.A,{className:"h-5 w-5"}),Bn>0&&"cities"!==yt&&(0,X.jsx)("span",{"data-testid":"cities-activity-badge",className:"absolute -right-0.5 -top-0.5 flex h-4 min-w-4 items-center justify-center rounded-full bg-[#FF2A5F] px-1 text-[9px] font-black text-white",children:Bn})]}),ut&&(0,X.jsx)("button",{"data-testid":"chat-upload-media-btn",onClick:ut,title:"Mete foto/videyo nan pwofil ou",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-[#FF2A5F] text-white shadow-lg shadow-[#FF2A5F]/30 transition-transform hover:scale-110",children:(0,X.jsx)(fe.A,{className:"h-6 w-6",strokeWidth:3})}),dt&&(0,X.jsxs)("button",{"data-testid":"chat-go-live-btn",onClick:dt,title:"Dir\xe8k (Live)",className:"flex shrink-0 items-center justify-center gap-1.5 rounded-xl border border-[#FF2A5F]/50 bg-[#FF2A5F]/15 px-3 py-2 text-xs font-bold text-[#FF2A5F] transition-colors hover:bg-[#FF2A5F]/25",children:[(0,X.jsx)(ne.A,{className:"h-4 w-4 live-dot"})," Dir\xe8k"]})]}),"cities"===yt?(0,X.jsx)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden","data-testid":"cities-panel",children:Ot?(0,X.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden","data-testid":"city-ch
1at",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 border-b px-3 py-2 ".concat(V?"border-white/10":"border-sky-200"),children:[(0,X.jsxs)("button",{onClick:()=>{Ot&&(null===Ye||void 0===Ye||Ye(Ot)),Ut(null),ia([])},"data-testid":"city-back-btn",className:"flex min-w-0 flex-1 items-center gap-2 text-sm font-semibold text-[#0284C7]",children:[(0,X.jsx)(Re.A,{className:"h-4 w-4 shrink-0"})," ",(0,X.jsx)(Fe.A,{className:"h-4 w-4 shrink-0"})," ",(0,X.jsx)("span",{className:"truncate",children:On(Ot)})]}),(0,X.jsxs)("div",{className:"flex shrink-0 items-center gap-0.5 rounded-full p-0.5 ".concat(V?"bg-white/10":"bg-white ring-1 ring-sky-200"),children:[(0,X.jsx)("button",{"data-testid":"city-view-chat-btn",onClick:()=>ta("chat"),className:"rounded-full px-2.5 py-1 text-[11px] font-bold transition-colors ".concat("chat"===ea?"bg-[#00A8CC] text-white":V?"text-white/70":"text-slate-500"),children:"Chat"}),(0,X.jsxs)("button",{"data-testid":"city-view-members-btn",onClick:()=>ta("members"),className:"flex items-center gap-1 rounded-full px-2.5 py-1 text-[11px] font-bold transition-colors ".concat("members"===ea?"bg-[#00A8CC] text-white":V?"text-white/70":"text-slate-500"),children:[(0,X.jsx)(M.A,{className:"h-3 w-3"})," ",null!==(t=null!==(a=pe[Ot])&&void 0!==a?a:sa.length)&&void 0!==t?t:0]})]})]}),"members"===ea?(0,X.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto p-2 scroll-red","data-testid":"city-members-list",children:[(0,X.jsxs)("p",{className:"mb-2 px-1 text-[11px] font-bold uppercase tracking-wide ".concat(V?"text-white/70":"text-slate-500"),children:["Moun ki nan ",On(Ot)," kounye a"]}),0===sa.length?(0,X.jsx)("p",{className:"px-2 py-6 text-center text-xs text-slate-500",children:"Pa gen okenn moun nan chanm sa a kounye a."}):sa.map(e=>{const t=e.user_id===l;return(0,X.jsxs)("div",{"data-testid":"city-member-".concat(e.user_id),className:"mb-1 flex items-center gap-2 rounded-xl px-2 py-2 ".concat(V?"hover:bg-white/10":"hover:bg-white/70"),children:[(0,X.jsxs)("div",{className:"relative shrink-0",children:[(0,X.jsx)("img",{src:e.picture||"/haitipal-logo.png",alt:"",className:"h-8 w-8 rounded-full object-cover"}),(0,X.jsx)(Ce.A,{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 fill-green-500 text-green-500"})]}),(0,X.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate text-xs font-semibold ".concat((0,Y.oL)(e,V)||(V?"text-white":"text-slate-800")),children:["admin"===(0,Y.Lc)(e)&&(0,X.jsx)(S.A,{className:"h-3 w-3 shrink-0 text-red-500"}),"moderator"===(0,Y.Lc)(e)&&(0,X.jsx)(R.A,{className:"h-3 w-3 shrink-0 text-green-500"}),"vip"===(0,Y.Lc)(e)&&(0,X.jsx)(E.A,{className:"h-3 w-3 shrink-0 text-blue-500"}),e.is_champion&&(0,X.jsx)(E.A,{className:"h-3 w-3 shrink-0 text-[#FFD700]",title:"Chanpyon konpetisyon"}),e.is_jenipal_champ&&(0,X.jsx)(T.A,{className:"h-3 w-3 shrink-0 text-[#FFD700]",title:"Chanpyon JeniPal mwa a"}),(0,X.jsx)("span",{className:"truncate",children:(0,X.jsx)(qt,{userId:e.user_id,canSeeIp:Nt,children:e.name})}),t&&(0,X.jsx)("span",{className:"shrink-0 text-[9px] ".concat(V?"text-white/50":"text-slate-400"),children:"(ou)"})]}),e.is_bot&&(0,X.jsxs)("span",{"data-testid":"city-member-bot-".concat(e.user_id),title:"Kont AI (robo)",className:"flex shrink-0 items-center gap-0.5 rounded-full bg-[#00F0FF]/20 px-1.5 py-0.5 text-[9px] font-black uppercase leading-none text-[#00A8CC]",children:[(0,X.jsx)(Ee.A,{className:"h-2.5 w-2.5"})," Robo"]}),oe&&Rt(e.country_code)&&(0,X.jsx)("img",{src:Rt(e.country_code),alt:e.country_code,title:e.country_code,onError:e=>{e.currentTarget.style.display="none"},className:"h-3 w-[18px] shrink-0 rounded-sm object-cover ring-1 ring-black/10"}),!t&&!e.is_guest&&!e.is_bot&&re&&(0,X.jsx)("button",{"data-testid":"city-member-profile-".concat(e.user_id),onClick:()=>re(e),title:"W\xe8 pwofil ".concat(e.name),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[#00A8CC]/15 text-[#0284C7] transition-transform hover:scale-110 hover:bg-[#00A8CC]/25",children:(0,X.jsx)(Te.A,{className:"h-3.5 w-3.5"})}),!t&&!e.is_guest&&!e.is_bot&&(0,X.jsx)("button",{"data-testid":"city-member-dm-".concat(e.user_id),onClick:()=>zn(e),title:"Chat prive ak ".concat(e.name),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[#FF2A5F]/15 text-[#FF2A5F] transition-transform hover:scale-110 hover:bg-[#FF2A5F]/25",children:(0,X.jsx)(Me.A,{className:"h-3.5 w-3.5"})})]},e.user_id)})]}):(0,X.jsx)(Bt,{messages:he[Ot]||[],selfUserId:l,overlay:V,showTime:!0,onDelete:Vn,onAdClick:ra,onReact:f,onReply:Gt,canSeeIp:Nt,onTiktokShare:Xa})]}):(0,X.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto p-2 scroll-red","data-testid":"city-list",children:[(0,X.jsx)("p",{className:"mb-2 px-1 text-xs font-bold uppercase tracking-wide ".concat(V?"text-white/70":"text-slate-500"),children:"Chanm vil \u2014 kominote ayisyen"}),qn.map(e=>{var t,a;const s=null!==(t=null!==(a=pe[e.key])&&void 0!==a?a:e.count)&&void 0!==t?t:0,i=ke[e.key]||0;return(0,X.jsxs)("div",{"data-testid":"city-row-".concat(e.key),className:"mb-1 flex items-center gap-1 rounded-xl transition-colors ".concat(V?"hover:bg-white/10":"hover:bg-white/70"),children:[(0,X.jsx)("button",{"data-testid":"city-fav-".concat(e.key),onClick:t=>(async(e,t)=>{null===t||void 0===t||t.stopPropagation();try{const t=(await d.Ay.post("/rooms/cities/".concat(e,"/favorite"))).data;Zt(a=>a.map(a=>a.key===e?(0,n.A)((0,n.A)({},a),{},{is_favorite:t.is_favorite}):a)),u.oR.success(t.is_favorite?"".concat(On(e)," ajoute nan favori"):"".concat(On(e)," retire nan favori"))}catch(a){u.oR.error("Nou pa ka mete favori a")}})(e.key,t),title:e.is_favorite?"Retire favori":"Mete k\xf2m vil pa m",className:"flex h-9 w-8 shrink-0 items-center justify-center",children:(0,X.jsx)(_e.A,{className:"h-4 w-4 ".concat(e.is_favorite?"fill-[#FFD700] text-[#FFD700]":V?"text-white/40":"text-slate-400")})}),(0,X.jsxs)("button",{"data-testid":"city-room-".concat(e.key),onClick:()=>{return t=e.key,null===Je||void 0===Je||Je(t),null===Xe||void 0===Xe||Xe(t),null===Qe||void 0===Qe||Qe(t),Ut(t),ta("chat"),void ia([]);var t},className:"flex min-w-0 flex-1 items-center gap-2 py-2.5 pr-2 text-left",children:[(0,X.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-[#00A8CC]/15 text-[#00A8CC]",children:(0,X.jsx)(Fe.A,{className:"h-4 w-4"})}),(0,X.jsx)("span",{className:"min-w-0 flex-1 truncate text-sm font-semibold ".concat(V?"text-white":"text-slate-800"),children:e.name}),i>0&&(0,X.jsx)("span",{"data-testid":"city-activity-".concat(e.key),className:"rounded-full bg-[#FF2A5F] px-1.5 text-[10px] font-black text-white",children:i}),(0,X.jsxs)("span",{"data-testid":"city-count-".concat(e.key),className:"flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-bold ".concat(s>0?"bg-green-500/20 text-green-500":V?"bg-white/10 text-white/50":"bg-slate-200 text-slate-500"),children:[(0,X.jsx)(Ce.A,{className:"h-2 w-2 ".concat(s>0?"fill-green-500 text-green-500":"fill-slate-400 text-slate-400")})," ",s]}),(0,X.jsx)(Se.A,{className:"h-4 w-4 shrink-0 ".concat(V?"text-white/40":"text-slate-400")})]})]},e.key)}),0===Xt.length&&(0,X.jsx)("p",{className:"px-2 py-6 text-center text-xs text-slate-500",children:"Chajman chanm yo\u2026"})]})}):"friends"===yt?(0,X.jsx)("div",{className:"flex-1 overflow-y-auto p-2 scroll-red","data-testid":"friends-list",children:0===N.length?(0,X.jsxs)("div",{className:"flex flex-col items-center gap-2 px-4 py-10 text-center text-slate-500",children:[(0,X.jsx)(G.A,{className:"h-8 w-8 text-slate-400"}),(0,X.jsx)("p",{className:"text-sm",children:"Ou poko gen zanmi."}),(0,X.jsx)("p",{className:"text-xs",children:"Klike sou non yon moun pou w w\xe8 pwofil li epi ajoute l k\xf2m zanmi."})]}):[...N].sort((e,t)=>
1(Rn.has(t.user_id)?1:0)-(Rn.has(e.user_id)?1:0)).map(e=>{const t=Rn.has(e.user_id),a=!!y[e.user_id],n=t&&!a&&w&&v;return(0,X.jsxs)("div",{"data-testid":"friend-".concat(e.user_id),className:"flex w-full items-center gap-3 rounded-xl px-3 py-2 hover:bg-white/70",children:[(0,X.jsxs)("div",{className:"relative",children:[(0,X.jsx)("img",{src:e.picture,alt:"",className:"h-9 w-9 rounded-full object-cover ".concat(Tn.has(e.user_id)?"ring-2 ring-[#FF2A5F] shadow-[0_0_10px_rgba(255,42,95,0.8)]":"")}),(0,X.jsx)(Ce.A,{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 ".concat(t?"fill-green-500 text-green-500":"fill-slate-400 text-slate-400")}),Tn.has(e.user_id)&&(0,X.jsx)("span",{"data-testid":"fresh-media-".concat(e.user_id),title:"Nouvo foto/videyo",className:"absolute -top-1.5 left-1/2 -translate-x-1/2 rounded-full bg-[#FF2A5F] px-1 text-[8px] font-black uppercase leading-tight text-white shadow",children:"nouvo"})]}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsxs)("p",{className:"flex items-center gap-1 truncate text-sm font-semibold text-slate-800",children:["admin"===(0,Y.Lc)(e)&&(0,X.jsx)(S.A,{className:"h-3.5 w-3.5 shrink-0 text-red-600","data-testid":"role-badge-admin-friend-".concat(e.user_id)}),"moderator"===(0,Y.Lc)(e)&&(0,X.jsx)(R.A,{className:"h-3.5 w-3.5 shrink-0 text-green-600","data-testid":"role-badge-mod-friend-".concat(e.user_id)}),"vip"===(0,Y.Lc)(e)&&(0,X.jsx)(E.A,{className:"h-3.5 w-3.5 shrink-0 text-blue-600","data-testid":"vip-crown-friend-".concat(e.user_id)}),e.is_champion&&(0,X.jsx)(E.A,{className:"h-3.5 w-3.5 shrink-0 text-[#FFD700]","data-testid":"champion-crown-friend-".concat(e.user_id),title:"Chanpyon konpetisyon"}),e.is_jenipal_champ&&(0,X.jsx)(T.A,{className:"h-3.5 w-3.5 shrink-0 text-[#FFD700]","data-testid":"jenipal-champ-friend-".concat(e.user_id),title:"Chanpyon JeniPal mwa a"}),(0,X.jsx)("span",{className:"truncate ".concat((0,Y.eR)(e,!1)),children:e.name})]}),t?(0,X.jsxs)("span",{"data-testid":"friend-online-".concat(e.user_id),className:"flex items-center gap-1 text-[11px] font-semibold text-green-600",children:[(0,X.jsx)("span",{className:"h-1.5 w-1.5 rounded-full bg-green-500 live-dot"})," ",a?"Nan ap\xe8l":"Nan lakou a"]}):(0,X.jsx)("span",{className:"text-[11px] text-slate-400",children:"Pa an liy"})]}),ha===e.user_id?(0,X.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5","data-testid":"remove-confirm-".concat(e.user_id),children:[(0,X.jsx)("span",{className:"text-[11px] font-semibold text-slate-500",children:"Retire?"}),(0,X.jsx)("button",{"data-testid":"confirm-remove-".concat(e.user_id),onClick:()=>{null===F||void 0===F||F(e),xa(null)},title:"Konfime",className:"flex h-9 items-center rounded-full bg-red-500 px-3 text-xs font-bold text-white transition-colors hover:bg-red-600",children:"Wi"}),(0,X.jsx)("button",{"data-testid":"cancel-remove-".concat(e.user_id),onClick:()=>xa(null),title:"Anile",className:"flex h-9 w-9 items-center justify-center rounded-full bg-slate-200 text-slate-600 transition-colors hover:bg-slate-300",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("button",{"data-testid":"friend-dm-".concat(e.user_id),onClick:()=>(e=>{kt("lobby"),zn(e)})(e),title:"Voye mesaj bay ".concat(e.name),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[#00A8CC] text-white transition-transform hover:scale-110",children:(0,X.jsx)(Me.A,{className:"h-4 w-4"})}),n&&(0,X.jsx)("button",{"data-testid":"friend-call-".concat(e.user_id),onClick:()=>v(e),title:"Rele ".concat(e.name," ak kamera"),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[#9333EA] text-white transition-transform hover:scale-110",children:(0,X.jsx)(B.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{"data-testid":"friend-remove-".concat(e.user_id),onClick:()=>xa(e.user_id),title:"Retire ".concat(e.name," nan zanmi"),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-slate-200 text-slate-500 transition-transform hover:scale-110 hover:bg-red-100 hover:text-red-600",children:(0,X.jsx)(Pe.A,{className:"h-4 w-4"})})]})]},e.user_id)})}):(0,X.jsxs)("div",{className:"flex min-h-0 flex-1 overflow-hidden",children:[(0,X.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[_t&&(0,X.jsxs)("div",{className:"flex items-center gap-2 border-b border-sky-200 px-3 py-2",children:[(0,X.jsxs)("button",{onClick:()=>It(null),className:"flex flex-1 items-center gap-2 text-sm font-semibold text-[#0284C7]","data-testid":"dm-back-btn",children:[(0,X.jsx)(Re.A,{className:"h-4 w-4"})," ",_t.name,et.has(_t.user_id)&&(0,X.jsxs)("span",{"data-testid":"typing-dm-".concat(_t.user_id),className:"flex items-center gap-1 text-[11px] font-normal text-[#00A8CC]",children:[(0,X.jsx)(De.A,{className:"h-3.5 w-3.5 animate-pulse"})," ap tape\u2026"]})]}),w&&(0,X.jsx)("button",{onClick:()=>null===v||void 0===v?void 0:v(_t),"data-testid":"start-call-btn",title:"Rele ak kamera",className:"flex h-9 w-9 items-center justify-center rounded-full bg-[#00A8CC] text-white transition-transform hover:scale-105",children:(0,X.jsx)(B.A,{className:"h-4 w-4"})})]}),!_t&&ue&&(0,X.jsxs)("div",{"data-testid":"pinned-ad",className:"mb-2 overflow-hidden rounded-2xl border border-[#9333EA]/60 bg-gradient-to-br from-[#9333EA]/25 to-[#FF2A5F]/15 shadow-md",children:[(0,X.jsxs)("div",{className:"flex items-center gap-1.5 bg-[#9333EA]/30 px-3 py-1",children:[(0,X.jsx)(Ie.A,{className:"h-3 w-3 text-[#c084fc]"}),(0,X.jsxs)("span",{className:"text-[10px] font-bold uppercase tracking-wide text-[#c084fc]",children:["Pinen \xb7 ",ue.owner_name]})]}),ue.image_url&&(0,X.jsx)("img",{src:Tt(ue.image_url),alt:"",className:"max-h-36 w-full object-cover","data-testid":"pinned-ad-image"}),(0,X.jsxs)("div",{className:"px-3 py-2",children:[(0,X.jsx)("p",{className:"whitespace-pre-wrap break-words text-sm font-semibold ".concat(V?"text-white drop-shadow":"text-slate-800"),children:ue.text}),(0,X.jsxs)("div",{className:"mt-1.5 flex flex-wrap items-center gap-3",children:[ue.link_url&&(0,X.jsxs)("a",{href:ue.link_url,target:"_blank",rel:"noopener noreferrer",onClick:()=>ra(ue.id),"data-testid":"pinned-ad-link",className:"inline-flex items-center gap-1 text-xs font-bold text-[#00A8CC] hover:underline",children:[(0,X.jsx)(we.A,{className:"h-3.5 w-3.5"})," Vizite"]}),ue.phone&&(0,X.jsxs)("a",{href:"tel:".concat(ue.phone),onClick:()=>ra(ue.id),"data-testid":"pinned-ad-phone",className:"inline-flex items-center gap-1 text-xs font-bold text-[#00A8CC] hover:underline",children:[(0,X.jsx)(je.A,{className:"h-3.5 w-3.5"})," ",ue.phone]}
1)]})]})]}),(0,X.jsx)(Bt,{messages:_t?h[_t.user_id]||[]:m,selfUserId:l,overlay:V,showTime:!0,onDelete:Vn,onAdClick:ra,onReact:f,onReply:Gt,hostId:_t?null:pt,canSeeIp:Nt,onTiktokShare:Xa})]}),(0,X.jsxs)("div",{className:"flex w-[172px] shrink-0 flex-col overflow-hidden border-l ".concat(V?"border-white/10 bg-black/40 backdrop-blur-md":"border-sky-200 bg-[#DCEBFA]"),"data-testid":"pal-list",children:[vt&&(0,X.jsxs)("div",{"data-testid":"pal-live-header",className:"flex items-center gap-1.5 border-b border-sky-200 bg-[#FF2A5F]/10 px-2.5 py-2 text-[11px] font-black uppercase tracking-wide text-[#FF2A5F]",children:[(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5 live-dot"})," ",Mn.length," ap gade"]}),(0,X.jsx)("div",{className:"border-b border-sky-200 p-1.5",children:(0,X.jsxs)("div",{className:"flex items-center gap-1.5 rounded-full bg-white px-2.5 py-1.5 ring-1 ring-sky-200",children:[(0,X.jsx)(Le.A,{className:"h-3.5 w-3.5 shrink-0 text-slate-400"}),(0,X.jsx)("input",{"data-testid":"pal-search-input",value:ja,onChange:e=>ya(e.target.value),placeholder:"Ch\xe8che moun\u2026",className:"w-full min-w-0 bg-transparent text-xs text-slate-800 outline-none placeholder:text-slate-400"}),ja&&(0,X.jsx)("button",{"data-testid":"pal-search-clear",onClick:()=>ya(""),className:"shrink-0 text-slate-400 hover:text-slate-600",children:(0,X.jsx)(ge.A,{className:"h-3.5 w-3.5"})})]})}),(0,X.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto p-1.5 scroll-red",children:[0===Mn.length&&(0,X.jsx)("p",{className:"px-2 py-4 text-center text-xs text-slate-500",children:ja?"Pa jwenn moun.":vt?"Poko gen moun k ap gade.":"Pa gen l\xf2t moun."}),Mn.map(e=>{var t;const a=!!e.online,n=!!y[e.user_id],s=a&&!e.is_guest&&!n,i=(null===_t||void 0===_t?void 0:_t.user_id)===e.user_id,r=!(null===c||void 0===c||null===(t=c.has)||void 0===t||!t.call(c,e.user_id));return(0,X.jsxs)("div",{"data-testid":"dm-peer-".concat(e.user_id),className:"mb-1 rounded-xl px-2 py-2 ".concat(i?"bg-white ring-1 ring-[#00A8CC]/40":"hover:bg-white/70"),children:[(0,X.jsxs)("button",{onClick:()=>zn(e),"data-testid":"open-dm-".concat(e.user_id),className:"flex w-full items-center gap-2 text-left",children:[(0,X.jsxs)("div",{className:"relative shrink-0",children:[(0,X.jsx)("img",{src:e.picture,alt:"",className:"h-8 w-8 rounded-full object-cover ".concat(a?"":"opacity-60 grayscale"," ").concat(r?"speaking-ring":Tn.has(e.user_id)?"ring-2 ring-[#FF2A5F] shadow-[0_0_10px_rgba(255,42,95,0.8)]":"")}),r?(0,X.jsx)("span",{"data-testid":"pal-speaking-".concat(e.user_id),title:"Ap pale kounye a",className:"absolute -bottom-0.5 -right-0.5 flex h-3.5 w-3.5 items-center justify-center rounded-full bg-green-500 ring-2 ring-white",children:(0,X.jsx)(_.A,{className:"h-2 w-2 text-white"})}):(0,X.jsx)(Ce.A,{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 ".concat(s?"fill-green-500 text-green-500":n?"fill-amber-400 text-amber-400":"fill-slate-400 text-slate-400")}),Tn.has(e.user_id)&&(0,X.jsx)("span",{"data-testid":"fresh-media-".concat(e.user_id),title:"Nouvo foto/videyo",className:"absolute -top-1.5 left-1/2 -translate-x-1/2 rounded-full bg-[#FF2A5F] px-1 text-[8px] font-black uppercase leading-tight text-white shadow",children:"nouvo"}),ga[e.user_id]&&(0,X.jsx)(ze.A,{"data-testid":"unread-dot-".concat(e.user_id),title:"Nouvo mesaj",className:"absolute -right-1.5 -top-1.5 h-4 w-4 text-yellow-400",fill:"rgba(250,204,21,0.25)"})]}),(0,X.jsxs)("span",{className:"flex min-w-0 flex-1 items-center gap-1 truncate text-xs font-semibold ".concat((0,Y.oL)(e,V)||(a?V?"text-white":"text-slate-800":V?"text-white/50":"text-slate-400")),children:["admin"===(0,Y.Lc)(e)&&(0,X.jsx)(S.A,{className:"h-3 w-3 shrink-0 text-red-500","data-testid":"role-badge-admin-pal-".concat(e.user_id)}),"moderator"===(0,Y.Lc)(e)&&(0,X.jsx)(R.A,{className:"h-3 w-3 shrink-0 text-green-500","data-testid":"role-badge-mod-pal-".concat(e.user_id)}),"vip"===(0,Y.Lc)(e)&&(0,X.jsx)(E.A,{className:"h-3 w-3 shrink-0 text-blue-500","data-testid":"vip-crown-pal-".concat(e.user_id)}),e.is_champion&&(0,X.jsx)(E.A,{className:"h-3 w-3 shrink-0 text-[#FFD700]","data-testid":"champion-crown-pal-".concat(e.user_id),title:"Chanpyon konpetisyon"}),e.is_jenipal_champ&&(0,X.jsx)(T.A,{className:"h-3 w-3 shrink-0 text-[#FFD700]","data-testid":"jenipal-champ-pal-".concat(e.user_id),title:"Chanpyon JeniPal mwa a"}),(0,X.jsx)("span",{className:"truncate",children:(0,X.jsx)(qt,{userId:e.user_id,canSeeIp:Nt,children:e.name})}),et.has(e.user_id)&&(0,X.jsx)(De.A,{"data-testid":"typing-".concat(e.user_id),title:"".concat(e.name," ap tape\u2026"),className:"h-3.5 w-3.5 shrink-0 animate-pulse text-[#00A8CC]"})]}),e.is_bot&&!e.mention_only&&!e.human_like&&(0,X.jsxs)("span",{"data-testid":"bot-badge-".concat(e.user_id),title:"Kont AI (robo)",className:"flex shrink-0 items-center gap-0.5 rounded-full bg-[#00F0FF]/20 px-1.5 py-0.5 text-[9px] font-black uppercase leading-none text-[#00A8CC]",children:[(0,X.jsx)(Ee.A,{className:"h-2.5 w-2.5"})," Robo"]}),oe&&Rt(e.country_code)&&(0,X.jsx)("img",{"data-testid":"flag-".concat(e.user_id),src:Rt(e.country_code),alt:e.country_code,title:e.country_code,onError:e=>{e.currentTarget.style.display="none"},className:"h-3 w-[18px] shrink-0 rounded-sm object-cover ring-1 ring-black/10"}),a&&e.status&&Et[e.status]&&(()=>{const t=Et[e.status];return(0,X.jsx)(t,{"data-testid":"status-icon-".concat(e.user_id),title:"busy"===e.status?"Bizi":"Idle",className:"h-3.5 w-3.5 shrink-0 ".concat("busy"===e.status?"text-red-400":"text-yellow-400")})})(),e.is_mobile&&(0,X.jsx)(Ve.A,{"data-testid":"device-mobile-".concat(e.user_id),title:"Sou telef\xf2n / tabl\xe8t",className:"h-3.5 w-3.5 shrink-0 text-[#00A8CC]"})]}),(0,X.jsxs)("div",{className:"mt-1.5 flex items-center gap-1",children:[!e.is_guest&&re&&(0,X.jsx)("button",{"data-testid":"profile-peer-".concat(e.user_id),onClick:()=>re(e),title:"W\xe8 pwofil ".concat(e.name),className:"flex h-7 w-7 items-center justify-center rounded-full bg-[#00A8CC]/15 text-[#0284C7] transition-transform hover:scale-110 hover:bg-[#00A8CC]/25",children:(0,X.jsx)(Te.A,{className:"h-3.5 w-3.5"})}),!e.is_guest&&(En.has(e.user_id)?(0,X.jsx)("span",{"data-testid":"is-friend-".concat(e.user_id),title:"Zanmi deja",className:"flex h-7 w-7 items-center justify-center rounded-full bg-green-100 text-green-600",children:(0,X.jsx)(W.A,{className:"h-3.5 w-3.5"})}):(0,X.jsx)("button",{"data-testid":"add-friend-".concat(e.user_id),onClick:()=>null===A||void 0===A?void 0:A(e),title:"Ajoute ".concat(e.name," k\xf2m zanmi"),className:"flex h-7 w-7 items-center justify-center rounded-full bg-[#9333EA] text-white transition-transform hover:scale-110",children:(0,X.jsx)(G.A,{className:"h-3.5 w-3.5"})})),!e.is_guest&&ie&&e.user_id!==l&&(0,X.jsx)("button",{"data-testid":"gift-peer-".concat(e.user_id),onClick:()=>ie(e),title:"Voye yon kado bay ".concat(e.name),className:"flex h-7 w-7 items-center justify-center rounded-full bg-[#FF2A5F] text-white transition-transform hover:scale-110",children:(0,X.jsx)(J.A,{className:"h-3.5 w-3.5"})}),s&&w&&v&&(0,X.jsx)("button",{"data-testid":"quick-call-".concat(e.user_id),onClick:()=>v(e),title:"Rele ".concat(e.name," ak kamera"),className:"flex h-7 w-7 items-center justify-center rounded-full bg-[#00A8CC] text-white transition-transform hover:scale-110",children:(0,X.jsx)(B.A,{className:"h-3.5 w-3.5"})}),s&&Z[e.user_id]&&Q&&(0,X.jsxs)("button",{"data-testid":"ppv-request-".concat(e.user_id),onClick:()=>
1Q(e),title:"Mande yon chat prive PPV ak ".concat(e.name," (20 jeton/min)"),className:"flex h-7 items-center gap-1 rounded-full bg-[#FFD700] px-2 text-[10px] font-bold text-black transition-transform hover:scale-105",children:[(0,X.jsx)(_e.A,{className:"h-3 w-3"})," PPV"]}),n?(0,X.jsxs)("span",{"data-testid":"presence-busy-".concat(e.user_id),className:"ml-auto flex items-center gap-1 text-[9px] font-bold uppercase text-slate-500",children:[(0,X.jsx)(Oe.A,{className:"h-2.5 w-2.5"})," ap\xe8l"]}):a?e.is_guest?(0,X.jsx)("span",{"data-testid":"presence-guest-".concat(e.user_id),className:"ml-auto text-[9px] font-bold uppercase text-slate-500",children:"envite"}):null:(0,X.jsx)("span",{"data-testid":"presence-offline-".concat(e.user_id),className:"ml-auto text-[9px] font-bold uppercase text-slate-400",children:"of liy"})]})]},e.user_id)})]})]})]}),Un&&(0,X.jsxs)("div",{className:"border-t p-2 ".concat(V?"border-white/10 bg-black/50 backdrop-blur-md":"border-sky-200 bg-[#D6EAFB]"),children:[(0,X.jsxs)("div",{className:"mb-2 flex items-center gap-1.5","data-testid":"chat-format-toolbar",children:[(0,X.jsx)("button",{type:"button","data-testid":"fmt-bold-btn","aria-pressed":yn,onClick:()=>{var e;kn(e=>{const t=!e;return localStorage.setItem("htv_chatbold",t?"1":"0"),t}),null===(e=Cn.current)||void 0===e||e.focus()},title:"Gra",className:"flex h-8 w-8 items-center justify-center rounded-lg ring-1 transition-colors ".concat(yn?"bg-[#00A8CC] text-white ring-[#00A8CC]":"bg-white text-slate-700 ring-sky-200 hover:bg-sky-50"),children:(0,X.jsx)(qe.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{type:"button","data-testid":"fmt-italic-btn","aria-pressed":Fn,onClick:()=>{var e;_n(e=>{const t=!e;return localStorage.setItem("htv_chatitalic",t?"1":"0"),t}),null===(e=Cn.current)||void 0===e||e.focus()},title:"Italik",className:"flex h-8 w-8 items-center justify-center rounded-lg ring-1 transition-colors ".concat(Fn?"bg-[#00A8CC] text-white ring-[#00A8CC]":"bg-white text-slate-700 ring-sky-200 hover:bg-sky-50"),children:(0,X.jsx)(Be.A,{className:"h-4 w-4"})}),!V&&!q&&(0,X.jsxs)(St.l6,{value:dn,onValueChange:e=>{un(e),localStorage.setItem("htv_chatfont",e)},children:[(0,X.jsxs)(St.bq,{"data-testid":"chat-font-select",className:"h-8 w-[104px] border-sky-200 bg-white text-slate-700",children:[(0,X.jsx)(Ue.A,{className:"h-3.5 w-3.5"}),(0,X.jsx)(St.yv,{})]}),(0,X.jsx)(St.gC,{children:Object.keys(Mt).map(e=>(0,X.jsx)(St.eb,{value:e,"data-testid":"chat-font-".concat(e),children:(0,X.jsx)("span",{style:{fontFamily:Mt[e]},children:Pt[e]})},e))})]}),(0,X.jsxs)("button",{type:"button","data-testid":"open-poll-btn",onClick:()=>pn(!0),title:"Sondaj",className:"relative flex h-8 w-8 items-center justify-center rounded-lg ring-1 transition-colors ".concat(null!==st&&void 0!==st&&st.active?"bg-[#FF2A5F] text-white ring-[#FF2A5F]":"bg-white text-slate-700 ring-sky-200 hover:bg-sky-50"),children:[(0,X.jsx)(Ke.A,{className:"h-4 w-4"}),(null===st||void 0===st?void 0:st.active)&&(0,X.jsx)("span",{className:"absolute -right-0.5 -top-0.5 h-2.5 w-2.5 animate-pulse rounded-full bg-[#00F0FF] ring-2 ring-white"})]}),(0,X.jsx)(nt,{}),(0,X.jsx)(mt,{mobile:q}),!V&&!q&&(0,X.jsx)("div",{className:"ml-auto flex items-center gap-1","data-testid":"chat-color-swatches",children:Dt.map(e=>(0,X.jsx)("button",{type:"button","data-testid":"chat-color-".concat(e?e.replace("#",""):"default"),onClick:()=>(e=>{bn(e),localStorage.setItem("htv_chatcolor",e)})(e),title:e||"Default",className:"h-5 w-5 rounded-full ring-2 transition-transform hover:scale-110 ".concat(vn===e?"ring-slate-700":"ring-white"),style:{background:e||"#64748b"}},e||"default"))})]}),(0,X.jsx)(Ze,{open:xn,onOpenChange:pn,poll:st,myVotes:rt,isGuest:ct,onVote:e=>st&&(null===lt||void 0===lt?void 0:lt(st.id,e))}),Wt&&(0,X.jsxs)("div",{"data-testid":"reply-preview-bar",className:"mb-2 flex items-center gap-2 rounded-xl border-l-4 px-3 py-2 ".concat(V?"border-[#00F0FF] bg-white/10":"border-[#00A8CC] bg-[#00A8CC]/10"),children:[(0,X.jsx)(ye.A,{className:"h-4 w-4 shrink-0 ".concat(V?"text-[#00F0FF]":"text-[#00A8CC]")}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsxs)("p",{className:"text-[11px] font-bold ".concat(V?"text-white":"text-[#00A8CC]"),children:["Ap reponn ",Wt.from_id===l?"t\xe8t ou":Wt.from_name]}),(0,X.jsx)("p",{className:"truncate text-xs ".concat(V?"text-white/80":"text-slate-600"),children:Wt.text||(Wt.image_url?"\ud83d\udcf7 Foto":Wt.audio_url?"\ud83c\udfa4 N\xf2t vwa":Wt.video_url?"\ud83c\udfa5 Videyo":"")})]}),(0,X.jsx)("button",{type:"button","data-testid":"reply-cancel-btn",onClick:()=>Gt(null),title:"Anile repons lan",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full ".concat(V?"text-white/80 hover:bg-white/15":"text-slate-500 hover:bg-slate-200"),children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),ct&&(0,X.jsxs)("div",{"data-testid":"guest-chat-banner",className:"mb-2 flex items-center gap-2 rounded-xl bg-gradient-to-r from-[#FF2A5F]/15 to-[#00F0FF]/10 px-3 py-2 ring-1 ring-[#FF2A5F]/30",children:[(0,X.jsx)(J.A,{className:"h-4 w-4 shrink-0 text-[#FF2A5F]"}),(0,X.jsx)("p",{className:"min-w-0 flex-1 text-[11px] font-semibold text-slate-700","data-testid":"guest-chat-hint",children:"M\xf2d envite \xb7 kreye yon kont pou voye kado, monte nivo epi f\xe8 lajan"}),(0,X.jsx)("button",{type:"button","data-testid":"guest-upgrade-btn",onClick:bt,className:"shrink-0 rounded-full bg-[#FF2A5F] px-3 py-1 text-[11px] font-bold text-white transition-transform hover:scale-105",children:"Kreye kont \xb7 100 \ud83e\ude99"})]}),(0,X.jsxs)("form",{onSubmit:e=>{e.preventDefault();const t=ca.trim();if(!t)return;const a={font:dn,color:vn,bold:yn,italic:Fn},n=(null===Wt||void 0===Wt?void 0:Wt.id)||null;Ot?x(t,"channel",null,a,null,null,null,Ot,n):_t?x(t,"dm",_t.user_id,a,null,
1null,null,null,n):x(t,"lobby",null,a,null,null,null,null,n),da(""),Gt(null)},className:"relative flex items-center gap-2",children:["video"===Ma&&(0,X.jsx)("div",{className:"absolute bottom-full left-0 mb-2","data-testid":"video-rec-preview",children:(0,X.jsx)("video",{ref:sn,muted:!0,autoPlay:!0,playsInline:!0,className:"h-28 w-40 rounded-xl object-cover ring-2 ring-red-400 shadow-lg"})}),(0,X.jsx)("input",{ref:Za,type:"file",accept:"image/png,image/jpeg,image/webp,video/mp4,video/webm,video/quicktime",className:"hidden","data-testid":"chat-image-input",onChange:e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];e.target.value="",Dn(a)}}),null!==Sa?(0,X.jsxs)("div",{"data-testid":"video-upload-progress",className:"flex flex-1 items-center gap-3 rounded-full bg-sky-500/10 px-4 py-2 ring-1 ring-sky-300",children:[(0,X.jsx)(ve.A,{className:"h-4 w-4 shrink-0 animate-spin text-sky-500"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsx)("p",{className:"mb-1 text-[11px] font-semibold text-sky-700",children:Sa<100?"Ap voye videyo a\u2026 ".concat(Sa,"%"):"Ap trete videyo a\u2026"}),(0,X.jsx)("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-sky-200",children:(0,X.jsx)("div",{className:"h-full rounded-full bg-sky-500 transition-all duration-200 ".concat(Sa>=100?"animate-pulse":""),style:{width:"".concat(Sa<100?Sa:100,"%")}})})]})]}):Ma?(0,X.jsxs)("div",{"data-testid":"recording-bar",className:"flex flex-1 items-center gap-2 rounded-full bg-red-500/10 px-3 py-2 ring-1 ring-red-300",children:[(0,X.jsx)("span",{className:"h-2.5 w-2.5 shrink-0 animate-pulse rounded-full bg-red-500"}),(0,X.jsxs)("span",{className:"text-sm font-semibold text-red-600",children:["video"===Ma?"Videyo n\xf2t":"Odyo n\xf2t"," \xb7 ",(Kn=La,"".concat(Math.floor(Kn/60),":").concat(String(Kn%60).padStart(2,"0")))]}),(0,X.jsx)("button",{type:"button",onClick:()=>{an.current=!0;try{var e;null===(e=Qa.current)||void 0===e||e.stop()}catch(t){In()}},"data-testid":"rec-cancel-btn",title:"Anile",className:"ml-auto flex h-9 w-9 items-center justify-center rounded-full bg-white text-slate-500 ring-1 ring-slate-200 transition-colors hover:bg-slate-50",children:(0,X.jsx)(Ne.A,{className:"h-4 w-4"})}),(0,X.jsxs)("button",{type:"button",onClick:()=>{an.current=!1;try{var e;null===(e=Qa.current)||void 0===e||e.stop()}catch(t){In()}},disabled:Aa,"data-testid":"rec-stop-btn",title:"Voye n\xf2t",className:"flex h-9 items-center gap-1.5 rounded-full bg-[#FF2A5F] px-4 text-sm font-bold text-white transition-transform hover:scale-105",children:[Aa?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(He.A,{className:"h-4 w-4"})," Voye"]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("button",{type:"button","data-testid":"chat-image-btn",onClick:()=>{var e;return null===(e=Za.current)||void 0===e?void 0:e.click()},disabled:Aa||Pn,title:"Voye yon foto oswa yon ti videyo",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full ring-1 transition-colors ".concat(V?"bg-white/15 text-white ring-white/20 hover:bg-white/25":"bg-white text-slate-600 ring-sky-200 hover:bg-sky-50"),children:Aa?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(We.A,{className:"h-4 w-4"})}),K&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("button",{type:"button","data-testid":"chat-audio-btn",onClick:()=>Ln("audio"),title:"Anrejistre yon n\xf2t vwa",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full ring-1 transition-colors ".concat(V?"bg-white/15 text-white ring-white/20 hover:bg-white/25":"bg-white text-slate-600 ring-sky-200 hover:bg-sky-50"),children:(0,X.jsx)(_.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{type:"button","data-testid":"chat-video-btn",onClick:()=>Ln("video"),title:"Anrejistre yon n\xf2t videyo",className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full ring-1 transition-colors ".concat(V?"bg-white/15 text-white ring-white/20 hover:bg-white/25":"bg-white text-slate-600 ring-sky-200 hover:bg-sky-50"),children:(0,X.jsx)(B.A,{className:"h-4 w-4"})})]}),!V&&!q&&(0,X.jsxs)("div",{className:"relative shrink-0",children:[(0,X.jsx)("button",{type:"button","data-testid":"chat-emoji-btn",onClick:()=>Ba(e=>!e),title:"Emotik\xf2n",className:"flex h-10 w-10 items-center justify-center rounded-full bg-white text-slate-600 ring-1 ring-sky-200 transition-colors hover:bg-sky-50",children:(0,X.jsx)(Ae.A,{className:"h-4 w-4"})}),qa&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"fixed inset-0 z-10",onClick:()=>Ba(!1)}),(0,X.jsx)("div",{"data-testid":"emoji-picker",className:"absolute bottom-full left-0 z-20 mb-2 grid w-64 grid-cols-8 gap-1 rounded-2xl border border-sky-200 bg-white p-2 shadow-xl",children:zt.map((e,t)=>(0,X.jsx)("button",{type:"button","data-testid":"emoji-".concat(t),onClick:()=>{var t;da(t=>t+e),Ba(!1),null===(t=Cn.current)||void 0===t||t.focus()},className:"flex h-7 w-7 items-center justify-center rounded-lg text-lg hover:bg-sky-100",children:e},t))})]})]}),(0,X.jsx)("input",{ref:Cn,"data-testid":"chat-input",value:ca,disabled:Pn,onChange:e=>{da(e.target.value),e.target.value&&(null===tt||void 0===tt||tt(Ot?"channel":_t?"dm":"lobby",(null===_t||void 0===_t?void 0:_t.user_id)||null))},placeholder:Ot?"Ekri nan ".concat(On(Ot),"\u2026"):_t?"Ekri ".concat(_t.name,"\u2026"):"Ekri nan lakou a\u2026",style:{fontFamily:Mt[dn],color:vn||void 0,fontWeight:yn?700:void 0,fontStyle:Fn?"italic":void 0},className:"flex-1 rounded-full bg-white px-4 py-2.5 text-sm text-slate-800 placeholder:text-slate-400 outline-none ring-1 ring-sky-200 focus:ring-2 focus:ring-[#00A8CC]/50 disabled:opacity-60"}),(0,X.jsx)("button",{"data-testid":"chat-send-btn",type:"submit",className:"flex h-10 w-10 items-center justify-center rounded-full bg-[#FF2A5F] text-white transition-transform hover:scale-105 disabled:opacity-60",disabled:Pn,children:(0,X.jsx)(He.A,{className:"h-4 w-4"})})]})]}),!Ma&&!ct&&null===Sa&&(0,X.jsx)("p",{"data-testid":"chat-media-hint",className:"mt-1 pl-1 text-[10px] ".concat(V?"text-white/50":"text-slate-400"),children:"Foto oswa ti videyo \xb7 maks 50MB \xb7 k\xe8k segonn (videyo efase apre 24\xe8)"})]}),!Un&&(0,X.jsx)("div",{className:"flex items-center gap-2 border-t border-sky-200 bg-[#D6EAFB] p-4 text-sm text-slate-500",children:"cities"===yt?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Fe.A,{className:"h-4 w-4"})," Chwazi yon chanm vil pou w antre nan chat la."]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ge.A,{className:"h-4 w-4"})," Chwazi yon moun pou k\xf2manse yon chat prive."]})}),(0,X.jsx)(gt.T,{open:!!Ha,onOpenChange:e=>{e||Wa(null)},title:"Efase mesaj la?",description:"Mesaj sa a ap dispar\xe8t pou tout moun. Ou p ap ka retabli l.",confirmLabel:"Efase pou tout moun",onConfirm:()=>{Ha&&p(Ha.id),Wa(null)}}),(0,X.jsx)(ht,{open:!!Ya,onClose:()=>Xa(null),videoUrl:null===Ya||void 0===Ya?void 0:Ya.videoUrl,imageUrl:null===Ya||void 0===Ya?void 0:Ya.imageUrl,defaultTitle:"\ud83c\udfac Gade sa sou HAITIPAL!"})]});var Kn}const Kt=i.memo(Ut);var Ht=a(243);function Wt(e){const t=e||0;return t>=500?"large":t>=150?"medium":"small"}function Gt(e){return e.animation_image?e.animation_image.startsWith("http")?e.animation_image:"https://haitipal.com"+e.animation_image:null}function Jt(e){var t,a;let n=e.g;const s=n.gift||{},i=s.color||"#FF2A5F",r=Wt(s.cost),l=Gt(s);return(0,X.jsx)("div",{className:"gift-slide-banner pointer-events-none","data-testid":"gift-banner-".concat(r),"data-gift-tier":r,style:{"--g-color":i},children:(0,X.jsxs)("div",{className:"gift-banner-glow flex items-center gap-3 rounded-2xl px-4 py-3 backdrop-blur-md ".concat("medium"===r?"min-w-[280px]":"min-w-[240px]"),style:{background:"".concat(i,"22"),border:"2px s
1olid ".concat(i,"88")},children:[(0,X.jsx)("div",{className:"flex h-14 w-14 shrink-0 items-center justify-center rounded-xl text-3xl gift-pop",style:{background:"".concat(i,"33"),boxShadow:"0 0 24px ".concat(i)},children:l?(0,X.jsx)("img",{src:l,alt:s.name||"kado",className:"h-12 w-12 object-contain","data-testid":"gift-animation-image"}):(0,X.jsx)("span",{className:"drop-shadow-[0_0_10px_rgba(255,255,255,0.6)]",children:s.emoji||"\ud83c\udf81"})}),(0,X.jsxs)("div",{className:"min-w-0 leading-tight",children:[(0,X.jsxs)("div",{className:"truncate text-sm font-bold text-white",children:[(0,X.jsx)("span",{className:"neon-pink",children:null===(t=n.from)||void 0===t?void 0:t.name})," ",(0,X.jsx)("span",{className:"text-white/60",children:"voye"})," ",s.emoji||"\ud83c\udf81"]}),(0,X.jsxs)("div",{className:"truncate text-xs font-semibold",style:{color:i},children:[s.name||"Kado"," ",(0,X.jsxs)("span",{className:"text-white/50",children:["\u2192 ",null===(a=n.to)||void 0===a?void 0:a.name]})]})]})]})})}function Yt(e){var t,a;let n=e.g;const s=n.gift||{},i=s.color||"#FFD700",r=Gt(s);return(0,X.jsx)("div",{className:"pointer-events-none fixed inset-0 z-[70] flex items-center justify-center","data-testid":"gift-banner-large",children:(0,X.jsxs)("div",{className:"gift-big-pop flex flex-col items-center gap-4",style:{"--g-color":i},children:[r?(0,X.jsx)("img",{src:r,alt:s.name||"kado",className:"h-44 w-44 object-contain drop-shadow-[0_0_60px_rgba(255,255,255,0.7)]",style:{filter:"drop-shadow(0 0 60px ".concat(i,")")},"data-testid":"gift-animation-image"}):(0,X.jsx)("span",{className:"gift-big-glow text-[9rem] leading-none",style:{"--g-color":i},children:s.emoji||"\ud83c\udf81"}),(0,X.jsxs)("div",{className:"glass rounded-2xl px-6 py-3 text-center",children:[(0,X.jsxs)("div",{className:"text-2xl font-extrabold text-white",children:[(0,X.jsx)("span",{className:"neon-pink",children:null===(t=n.from)||void 0===t?void 0:t.name})," voye yon ",(0,X.jsx)("span",{style:{color:i},children:s.name||"Gwo Kado"}),"!"]}),(0,X.jsxs)("div",{className:"mt-1 text-base font-bold text-white/80",children:["pou ",null===(a=n.to)||void 0===a?void 0:a.name," \ud83c\udf89"]})]})]})})}function Xt(e){let t=e.gifts;const a=t.filter(e=>{var t;return"large"!==Wt(null===(t=e.gift)||void 0===t?void 0:t.cost)}),n=t.filter(e=>{var t;return"large"===Wt(null===(t=e.gift)||void 0===t?void 0:t.cost)});return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"pointer-events-none fixed right-4 top-1/2 z-[60] flex -translate-y-1/2 flex-col items-end gap-3","data-testid":"gift-overlay",children:a.map(e=>(0,X.jsx)(Jt,{g:e},e.key))}),n.map(e=>(0,X.jsx)(Yt,{g:e},e.key))]})}function Zt(e){let t=e.open,a=e.onClose,n=e.onUpgrade;e.limit;return t?(0,X.jsx)("div",{className:"fixed inset-0 z-[90] flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm","data-testid":"guest-upgrade-modal",onClick:a,children:(0,X.jsxs)("div",{className:"relative w-full max-w-sm overflow-hidden rounded-3xl bg-[#12121a] ring-1 ring-[#FF2A5F]/40",onClick:e=>e.stopPropagation(),children:[(0,X.jsx)("button",{"data-testid":"guest-upgrade-close",onClick:a,className:"absolute right-3 top-3 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white/70 hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})}),(0,X.jsxs)("div",{className:"bg-gradient-to-br from-[#FF2A5F]/25 to-[#00F0FF]/15 px-6 pb-5 pt-8 text-center",children:[(0,X.jsx)("div",{className:"mx-auto flex h-16 w-16 items-center justify-center rounded-2xl bg-[#FF2A5F] glow-pink",children:(0,X.jsx)(J.A,{className:"h-8 w-8 text-white"})}),(0,X.jsx)("h3",{className:"mt-4 font-display text-2xl font-black text-white",children:"Kreye kont ou gratis!"}),(0,X.jsxs)("p",{className:"mt-1.5 text-sm text-gray-300",children:["K\xf2m Vizit\xe8 (Pal) ou ka gade epi chat. Enskri kounye a pou tout avantaj yo epi resevwa"," ",(0,X.jsx)("span",{className:"font-bold text-yellow-400",children:"100 jeton gratis"})," \ud83c\udf81"]})]}),(0,X.jsxs)("div",{className:"space-y-3 px-6 py-5",children:[(0,X.jsxs)("div",{className:"flex items-center gap-3 text-sm text-gray-200",children:[(0,X.jsx)(se.A,{className:"h-5 w-5 shrink-0 text-yellow-400"})," 100 jeton pou voye kado"]}),(0,X.jsxs)("div",{className:"flex items-center gap-3 text-sm text-gray-200",children:[(0,X.jsx)(B.A,{className:"h-5 w-5 shrink-0 text-[#00F0FF]"})," Chat san limit ak kamera an dir\xe8k"]}),(0,X.jsxs)("div",{className:"flex items-center gap-3 text-sm text-gray-200",children:[(0,X.jsx)($.A,{className:"h-5 w-5 shrink-0 text-[#FF2A5F]"})," Monte nan klasman an epi f\xe8 lajan"]}),(0,X.jsx)("button",{"data-testid":"guest-upgrade-confirm",onClick:n,className:"mt-2 flex h-12 w-full items-center justify-center gap-2 rounded-full bg-[#FF2A5F] font-bold text-white transition-transform hover:scale-[1.02] glow-pink",children:"Kreye kont \xb7 100 \ud83e\ude99"}),(0,X.jsx)("button",{"data-testid":"guest-upgrade-later",onClick:a,className:"w-full text-center text-xs text-gray-500 hover:text-gray-300",children:"Pita"})]})]})}):null}var Qt=a(6099);function $t(e){let t=e.open,a=e.onClose,n=e.amount,s=void 0===n?100:n;return t?(0,X.jsx)("div",{className:"fixed inset-0 z-[95] flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm","data-testid":"welcome-bonus-modal",onClick:a,children:(0,X.jsxs)("div",{className:"relative w-full max-w-sm overflow-hidden rounded-3xl bg-[#12121a] ring-1 ring-yellow-400/40",onClick:e=>e.stopPropagation(),children:[(0,X.jsx)("button",{"data-testid":"welcome-bonus-close",onClick:a,className:"absolute right-3 top-3 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white/70 hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})}),(0,X.jsxs)("div",{className:"bg-gradient-to-br from-yellow-400/25 via-[#FF2A5F]/15 to-[#00F0FF]/10 px-6 pb-6 pt-9 text-center",children:[(0,X.jsxs)("div",{className:"relative mx-auto flex h-20 w-20 items-center justify-center rounded-2xl bg-yellow-400 shadow-[0_0_40px_rgba(250,204,21,0.7)]",children:[(0,X.jsx)(se.A,{className:"h-10 w-10 text-[#12121a]"}),(0,X.jsx)(Qt.A,{className:"absolute -right-2 -top-2 h-6 w-6 text-white drop-shadow"})]}),(0,X.jsx)("h3",{className:"mt-4 font-display text-3xl font-black text-white",children:"Byenveni! \ud83c\udf89"}),(0,X.jsxs)("p",{className:"mt-2 text-base text-gray-200",children:["Ou resevwa ",(0,X.jsxs)("span",{className:"font-black text-yellow-400",children:[s," jeton"]})," gratis!"]}),(0,X.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"S\xe8vi av\xe8 yo pou voye kado ak sip\xf2te mou
1n ou renmen yo."})]}),(0,X.jsx)("div",{className:"px-6 py-5",children:(0,X.jsx)("button",{"data-testid":"welcome-bonus-confirm",onClick:a,className:"flex h-12 w-full items-center justify-center gap-2 rounded-full bg-[#FF2A5F] font-bold text-white transition-transform hover:scale-[1.02] glow-pink",children:"Ann k\xf2manse! \ud83d\ude80"})})]})}):null}var ea=a(6790),ta=a(6725);function aa(e){let t=e.open,a=e.onClose,n=e.amount,s=e.note;return(0,i.useEffect)(()=>{var e,n;if(!t)return;if(null===(e=(n=window).matchMedia)||void 0===e||!e.call(n,"(prefers-reduced-motion: reduce)").matches){const e=["#39FF14","#FFD700","#00F0FF","#FF2A5F"];(0,o.A)({particleCount:170,spread:100,startVelocity:50,origin:{y:.6},colors:e}),setTimeout(()=>(0,o.A)({particleCount:100,angle:60,spread:80,origin:{x:0,y:.7},colors:e}),200),setTimeout(()=>(0,o.A)({particleCount:100,angle:120,spread:80,origin:{x:1,y:.7},colors:e}),200)}const s=setTimeout(()=>a&&a(),3e4);return()=>clearTimeout(s)},[t,a]),t?(0,X.jsx)("div",{className:"fixed inset-0 z-[96] flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm","data-testid":"payout-congrats-modal",onClick:a,children:(0,X.jsxs)("div",{className:"relative w-full max-w-sm overflow-hidden rounded-3xl bg-[#12121a] ring-1 ring-green-400/40",onClick:e=>e.stopPropagation(),children:[(0,X.jsx)("button",{"data-testid":"payout-congrats-close",onClick:a,className:"absolute right-3 top-3 z-10 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white/70 hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})}),(0,X.jsxs)("div",{className:"bg-gradient-to-br from-green-400/25 via-[#00F0FF]/10 to-[#FFD700]/10 px-6 pb-6 pt-9 text-center",children:[(0,X.jsxs)("div",{className:"relative mx-auto flex h-20 w-20 items-center justify-center rounded-2xl bg-green-400 shadow-[0_0_40px_rgba(57,255,20,0.6)]",children:[(0,X.jsx)(ea.A,{className:"h-10 w-10 text-[#12121a]"}),(0,X.jsx)(ta.A,{className:"absolute -right-2 -top-2 h-6 w-6 text-white drop-shadow"})]}),(0,X.jsx)("h3",{className:"mt-4 font-display text-3xl font-black text-white",children:"Felisitasyon! \ud83c\udf89"}),(0,X.jsxs)("p",{className:"mt-2 text-base text-gray-200",children:["Retr\xe8 lajan ou an",null!=n?(0,X.jsxs)(X.Fragment,{children:[" (",(0,X.jsxs)("span",{className:"font-black text-green-400",children:["$",n]}),")"]}):""," apwouve epi peye!"]}),s&&(0,X.jsx)("p",{className:"mt-1 text-sm text-gray-400","data-testid":"payout-congrats-note",children:s}),(0,X.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"M\xe8si paske w f\xe8 pati kominote a. \ud83d\udc9a"})]}),(0,X.jsx)("div",{className:"px-6 py-5",children:(0,X.jsx)("button",{"data-testid":"payout-congrats-confirm",onClick:a,className:"flex h-12 w-full items-center justify-center gap-2 rounded-full bg-green-500 font-bold text-black transition-transform hover:scale-[1.02]",children:"Sip\xe8! \ud83d\ude80"})})]})}):null}var na=a(7057),sa=a(3308);const ia=[{id:"aurora",label:"Aurora",gradient:"linear-gradient(135deg,#0b0b12 0%,#241033 45%,#0b2233 100%)",swatch:"linear-gradient(135deg,#7c3aed,#06b6d4)"},{id:"sunset",label:"Sol\xe8y Kouche",gradient:"linear-gradient(135deg,#12060b 0%,#2e0b1e 50%,#3a1a08 100%)",swatch:"linear-gradient(135deg,#FF2A5F,#FF8A3D)"},{id:"ocean",label:"Lanm\xe8",gradient:"linear-gradient(135deg,#05121a 0%,#0b2e2e 50%,#0b1e33 100%)",swatch:"linear-gradient(135deg,#06b6d4,#3b82f6)"},{id:"forest",label:"For\xe8",gradient:"linear-gradient(135deg,#08120b 0%,#0b2e1a 50%,#0b2408 100%)",swatch:"linear-gradient(135deg,#22c55e,#84cc16)"},{id:"flag",label:"Ayiti",gradient:"linear-gradient(135deg,#0a1a3a 0%,#0b0b12 50%,#3a0a12 100%)",swatch:"linear-gradient(135deg,#00209F,#D21034)"}];function ra(e){let t=e.open,a=e.onOpenChange;const n=(0,r.Zp)(),l=(0,i.useRef)(null),o=(0,i.useState)(""),c=(0,s.A)(o,2),m=c[0],h=c[1],x=(0,i.useState)("aurora"),p=(0,s.A)(x,2),f=p[0],g=p[1],v=(0,i.useState)(""),b=(0,s.A)(v,2),w=b[0],j=b[1],y=(0,i.useState)(""),k=(0,s.A)(y,2),N=k[0],A=k[1],F=(0,i.useState)(""),_=(0,s.A)(F,2),C=_[0],S=_[1],R=(0,i.useState)(!1),E=(0,s.A)(R,2),T=E[0],M=E[1],P=(0,i.useState)(!1),D=(0,s.A)(P,2),I=D[0],L=D[1],z=(0,i.useState)(!1),V=(0,s.A)(z,2),O=V[0],q=V[1];return(0,X.jsx)(Je.lG,{open:t,onOpenChange:a,children:(0,X.jsxs)(Je.Cf,{className:"glass max-w-md border-white/10 text-white","data-testid":"rooms-dialog",children:[(0,X.jsxs)(Je.c7,{children:[(0,X.jsx)(Je.L3,{className:"font-display text-2xl",children:"Sal prive"}),(0,X.jsx)(Je.rr,{className:"text-gray-400",children:"Kreye yon sal ki sou envitasyon s\xe8lman, oswa antre nan youn ak yon k\xf2d."})]}),(0,X.jsxs)("div",{className:"space-y-3 rounded-2xl surface-2 p-4",children:[(0,X.jsxs)("p",{className:"flex items-center gap-2 text-sm font-semibold text-[#FF2A5F]",children:[(0,X.jsx)(fe.A,{className:"h-4 w-4"})," Kreye yon sal"]}),(0,X.jsx)("input",{"data-testid":"room-name-input",value:m,onChange:e=>h(e.target.value),placeholder:"Non sal la (egz. Late Night Vibes)",className:"h-11 w-full rounded-xl bg-white/5 px-4 text-sm text-white placeholder:text-gray-500 outline-none focus:ring-1 focus:ring-[#FF2A5F]/50"}),(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"mb-1.5 text-xs uppercase tracking-widest text-gray-400",children:"T\xe8m"}),(0,X.jsx)("div",{className:"flex gap-2","data-testid":"theme-picker",children:ia.map(e=>(0,X.jsx)("button",{type:"button","data-testid":"theme-".concat(e.id),onClick:()=>g(e.id),title:e.label,className:"h-9 flex-1 rounded-lg transition-transform hover:scale-105 ".concat(f===e.id?"ring-2 ring-white":"ring-1 ring-white/10"),style:{background:e.swatch}},e.id))})]}),(0,X.jsx)("textarea",{"data-testid":"room-welcome-input",value:w,onChange:e=>j(e.target.value),placeholder:"Mesaj byenveni pou envite yo (opsyon\xe8l)",rows:2,maxLength:200,className:"w-full resize-none rounded-xl bg-white/5 px-4 py-2.5 text-sm text-white placeholder:text-gray-500 outline-none focus:ring-1 focus:ring-[#FF2A5F]/50"}),(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"mb-1.5 text-xs uppercase tracking-widest text-gray-400",children:"Foto kouv\xe8ti (opsyon\xe8l)"}),(0,X.jsx)("input",{ref:l,type:"file",accept:"image/*",onChange:async e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(a)if(a.size>5242880)u.oR.error("Imaj la tw\xf2 gwo (maks 5MB)");else{M(!0);try{const e=new FormData;e.append("file",a);const t=(await d.Ay.post("/uploads/cover",e,{headers:{"Content-Type":"multipart/form-data"}})).data;S(t.url),u.oR.success("Foto kouv\xe8ti a chaje!")}catch(i){var n,s;u.oR.error((0,d.KI)(null===(n=i.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.detail)||"Echwe pandan chajman an")}finally{M(!1),l.current&&(l.current.value="")}}},className:"hidden","data-testid":"room-cover-input"}),C?(0,X.jsxs)("div",{className:"relative h-24 w-full overflow-hidden rounded-xl ring-1 ring-white/10","data-testid":"room-cover-preview",children:[(0,X.jsx)("img",{src:C,alt:"kouv\xe8ti",className:"h-full w-full object-cover"}),(0,X.jsx)("button",{type:"button","data-testid":"remove-cover-btn",onClick:()=>S(""),className:"absolute right-2 top-2 rounded-full bg-black/70 p-1.5 text-white hover:bg-black/90",children:(0,X.jsx)(ge.A,{className:"h-3.5 w-3.5"})})]}):(0,X.jsx)("button",{type:"button","data-testid":"upload-cover-btn",onClick:()=>{var e;return null===(e=l.current)||void 0===e?void 0:e.click()},disabled:T,className:"flex h-11 w-full items-center justify-center gap-2 rounded-xl border border-dashed border-white/20 bg-white/5 text-sm font-semibold text-gray-300 transition-colors hover:bg-white/10 disabled:opacity-50",children:T?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(We.A,{className:"h-4 w-4"})," Chwazi yon foto"]})})]}),(0,X.jsx)("button",{"data-testid":"create-room-btn",onClick:async()=>
1{if(m.trim()){L(!0);try{const e=(await d.Ay.post("/rooms",{name:m.trim(),theme:f,welcome:w.trim(),cover_url:C})).data;u.oR.success('Sal "'.concat(e.name,'" kreye!')),a(!1),n("/room/".concat(e.room_id))}catch(s){var e,t;u.oR.error((0,d.KI)(null===(e=s.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail))}finally{L(!1)}}},disabled:I||!m.trim(),className:"flex h-11 w-full items-center justify-center gap-2 rounded-full bg-[#FF2A5F] font-bold text-white transition-transform hover:scale-[1.02] disabled:opacity-40 glow-pink",children:I?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(na.A,{className:"h-4 w-4"})," Kreye epi antre"]})})]}),(0,X.jsxs)("div",{className:"space-y-3 rounded-2xl surface-2 p-4",children:[(0,X.jsxs)("p",{className:"flex items-center gap-2 text-sm font-semibold text-[#00F0FF]",children:[(0,X.jsx)(sa.A,{className:"h-4 w-4"})," Antre ak yon k\xf2d"]}),(0,X.jsx)("input",{"data-testid":"room-code-input",value:N,onChange:e=>A(e.target.value),placeholder:"Antre k\xf2d sal la",className:"h-11 w-full rounded-xl bg-white/5 px-4 font-mono uppercase tracking-widest text-white placeholder:text-gray-500 outline-none focus:ring-1 focus:ring-cyan-400/50"}),(0,X.jsx)("button",{"data-testid":"join-room-btn",onClick:async()=>{const e=N.trim().toUpperCase();if(e){q(!0);try{await d.Ay.get("/rooms/".concat(e)),a(!1),n("/room/".concat(e))}catch(i){var t,s;u.oR.error((0,d.KI)(null===(t=i.response)||void 0===t||null===(s=t.data)||void 0===s?void 0:s.detail)||"Nou pa jwenn sal la")}finally{q(!1)}}},disabled:O||!N.trim(),className:"flex h-11 w-full items-center justify-center gap-2 rounded-full bg-[#00F0FF] font-bold text-black transition-transform hover:scale-[1.02] disabled:opacity-40",children:O?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):"Antre nan sal la"})]})]})})}var la=a(73);function oa(e){let t=e.combo,a=e.onAgain,n=e.onClose;return t?(0,X.jsx)("div",{className:"fixed bottom-28 left-1/2 z-[70] -translate-x-1/2","data-testid":"combo-bar",children:(0,X.jsxs)("div",{className:"flex items-center gap-3 rounded-full glass px-4 py-2.5 glow-pink",children:[(0,X.jsx)("span",{className:"text-3xl gift-pop",children:t.gift.emoji},t.count),(0,X.jsxs)("div",{children:[(0,X.jsxs)("p",{className:"font-display text-lg font-black leading-none neon-pink","data-testid":"combo-count",children:["KONBO x",t.count]}),(0,X.jsx)("div",{className:"mt-1.5 h-1.5 w-32 overflow-hidden rounded-full bg-white/10",children:(0,X.jsx)("div",{className:"h-full bg-[#FF2A5F] combo-timer"},t.count)})]}),(0,X.jsxs)("button",{onClick:a,"data-testid":"combo-again-btn",className:"flex items-center gap-1 rounded-full bg-[#FF2A5F] px-4 py-2 text-sm font-bold text-white transition-transform hover:scale-105",children:[(0,X.jsx)(la.A,{className:"h-4 w-4"})," Voye ank\xf2"]}),(0,X.jsx)("button",{onClick:n,"data-testid":"combo-close-btn",className:"text-gray-400 hover:text-white",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]})}):null}var ca=a(7475),da=a(1876),ua=a(797);function ma(e){let t=e.open,n=e.onOpenChange,r=e.devices,l=e.selectedDevices,o=e.onCamera,c=e.onMic,d=e.onSpeaker,u=e.bgEffect,m=e.onBackground,h=e.customBgUrl,x=e.onUploadBackground,p=e.onRemoveBackground;const f=(null===r||void 0===r?void 0:r.cameras)||[],g=(null===r||void 0===r?void 0:r.mics)||[],v=(null===r||void 0===r?void 0:r.speakers)||[],b=(0,i.useRef)(null),w=(0,i.useState)(!1),j=(0,s.A)(w,2),y=j[0],k=j[1],N=(0,i.useState)([]),A=(0,s.A)(N,2),F=A[0],C=A[1];return(0,i.useEffect)(()=>{t&&!F.length&&Promise.all([a.e(207),a.e(760)]).then(a.bind(a,2760)).then(e=>C(e.BACKGROUNDS)).catch(()=>{})},[t,F.length]),(0,X.jsx)(Je.lG,{open:t,onOpenChange:n,children:(0,X.jsxs)(Je.Cf,{className:"glass max-w-md border-white/10 text-white","data-testid":"device-settings-dialog",children:[(0,X.jsxs)(Je.c7,{children:[(0,X.jsx)(Je.L3,{className:"font-display text-2xl",children:"Param\xe8t apar\xe8y"}),(0,X.jsx)(Je.rr,{className:"text-gray-400",children:"Chwazi kamera ak mikwo ou pi renmen. Apar\xe8y default yo chaje otomatikman."})]}),(0,X.jsxs)("div",{className:"space-y-4",children:[(0,X.jsxs)("div",{children:[(0,X.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 text-sm font-semibold text-[#00F0FF]",children:[(0,X.jsx)(B.A,{className:"h-4 w-4"})," Kamera"]}),(0,X.jsxs)(St.l6,{value:(null===l||void 0===l?void 0:l.camera)||"",onValueChange:o,children:[(0,X.jsx)(St.bq,{"data-testid":"camera-select",className:"h-11 surface-2 border-white/10 text-white",children:(0,X.jsx)(St.yv,{placeholder:"Chwazi kamera"})}),(0,X.jsxs)(St.gC,{className:"glass border-white/10 text-white",children:[0===f.length&&(0,X.jsx)(St.eb,{value:"none",disabled:!0,children:"Pa gen kamera"}),f.map((e,t)=>(0,X.jsx)(St.eb,{value:e.deviceId,"data-testid":"camera-option-".concat(t),children:e.label||"Kamera ".concat(t+1)},e.deviceId||t))]})]})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 text-sm font-semibold text-[#FF2A5F]",children:[(0,X.jsx)(_.A,{className:"h-4 w-4"})," Mikwo"]}),(0,X.jsxs)(St.l6,{value:(null===l||void 0===l?void 0:l.mic)||"",onValueChange:c,children:[(0,X.jsx)(St.bq,{"data-testid":"mic-select",className:"h-11 surface-2 border-white/10 text-white",children:(0,X.jsx)(St.yv,{placeholder:"Chwazi mikwo"})}),(0,X.jsxs)(St.gC,{className:"glass border-white/10 text-white",children:[0===g.length&&(0,X.jsx)(St.eb,{value:"none",disabled:!0,children:"Pa gen mikwo"}),g.map((e,t)=>(0,X.jsx)(St.eb,{value:e.deviceId,"data-testid":"mic-option-".concat(t),children:e.label||"Mikwo ".concat(t+1)},e.deviceId||t))]})]})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 text-sm font-semibold text-[#FFD700]",children:[(0,X.jsx)(D.A,{className:"h-4 w-4"})," Wo pal\xe8 (son soti)"]}),(0,X.jsxs)(St.l6,{value:(null===l||void 0===l?void 0:l.speaker)||"",onValueChange:d,children:[(0,X.jsx)(St.bq,{"data-testid":"speaker-select",className:"h-11 surface-2 border-white/10 text-white",children:(0,X.jsx)(St.yv,{placeholder:"Wo pal\xe8 default"})}),(0,X.jsxs)(St.gC,{className:"glass border-white/10 text-white",children:[0===v.length&&(0,X.jsx)(St.eb,{value:"none",disabled:!0,children:"Pa gen wo pal\xe8"}),v.map((e,t)=>(0,X.jsx)(St.eb,{value:e.deviceId,"data-testid":"speaker-option-".concat(t),children:e.label||"Wo pal\xe8 ".concat(t+1)},e.deviceId||t))]})]})]}),(0,X.jsxs)("div",{"data-testid":"background-section",children:[(0,X.jsxs)("p",{className:"mb-1.5 flex items-center gap-2 text-sm font-semibold text-[#B14EFF]",children:[(0,X.jsx)(Qt.A,{className:"h-4 w-4"}
1)," Background (pou vi prive)"]}),(0,X.jsxs)("div",{className:"grid grid-cols-5 gap-2",children:[F.map(e=>{const t=(u||"none")===e.id;return(0,X.jsxs)("button",{"data-testid":"bg-option-".concat(e.id),onClick:()=>null===m||void 0===m?void 0:m(e),title:e.label,className:"relative flex aspect-square flex-col items-center justify-center overflow-hidden rounded-xl border text-[10px] font-semibold transition-all ".concat(t?"border-[#B14EFF] ring-2 ring-[#B14EFF]/50":"border-white/10 hover:border-white/30"),style:e.url?{backgroundImage:"url(".concat(e.url,")"),backgroundSize:"cover",backgroundPosition:"center"}:{background:"#1a1a24"},children:["none"===e.id&&(0,X.jsx)(ca.A,{className:"h-5 w-5 text-gray-400"}),"blur"===e.id&&(0,X.jsx)(da.A,{className:"h-5 w-5 text-[#00F0FF]"}),(0,X.jsx)("span",{className:"mt-0.5 ".concat(e.url?"rounded bg-black/60 px-1 text-white":"text-gray-300"),children:e.label})]},e.id)}),h&&(0,X.jsxs)("button",{"data-testid":"bg-option-custom",onClick:()=>null===m||void 0===m?void 0:m({id:"custom",url:h}),title:"Background pa w",className:"relative flex aspect-square flex-col items-center justify-center overflow-hidden rounded-xl border text-[10px] font-semibold transition-all ".concat("custom"===(u||"none")?"border-[#B14EFF] ring-2 ring-[#B14EFF]/50":"border-white/10 hover:border-white/30"),style:{backgroundImage:"url(".concat(h,")"),backgroundSize:"cover",backgroundPosition:"center"},children:[(0,X.jsx)("span",{className:"mt-0.5 rounded bg-black/60 px-1 text-white",children:"Pa w"}),(0,X.jsx)("span",{role:"button","data-testid":"bg-remove-custom",onClick:e=>{e.stopPropagation(),null===p||void 0===p||p()},className:"absolute right-0.5 top-0.5 rounded-full bg-black/70 p-0.5 text-red-300 hover:text-red-400",children:(0,X.jsx)(Ne.A,{className:"h-3 w-3"})})]}),(0,X.jsxs)("button",{"data-testid":"bg-upload-btn",onClick:()=>{var e;return!y&&(null===(e=b.current)||void 0===e?void 0:e.click())},title:"Upload background pa w",disabled:y,className:"relative flex aspect-square flex-col items-center justify-center gap-0.5 rounded-xl border border-dashed border-[#B14EFF]/50 bg-[#B14EFF]/10 text-[10px] font-semibold text-[#B14EFF] transition-all hover:border-[#B14EFF] hover:bg-[#B14EFF]/20 disabled:opacity-60",children:[y?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):(0,X.jsx)(ua.A,{className:"h-5 w-5"}),(0,X.jsx)("span",{className:"mt-0.5",children:y?"...":"Upload"})]})]}),(0,X.jsx)("p",{className:"mt-1.5 text-[11px] text-gray-500",children:"Upload pw\xf2p foto/background pa w \u2014 l ap anrejistre sou kont ou."}),(0,X.jsx)("input",{ref:b,type:"file",accept:"image/*",className:"hidden","data-testid":"bg-file-input",onChange:async e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(e.target.value="",a&&a.type.startsWith("image/")){k(!0);try{const e=await function(e,t,a){return new Promise(n=>{const s=new Image,i=URL.createObjectURL(e);s.onload=()=>{URL.revokeObjectURL(i);let r=s.width,l=s.height;const o=Math.min(t/r,a/l,1);r=Math.round(r*o),l=Math.round(l*o);const c=document.createElement("canvas");c.width=r,c.height=l;c.getContext("2d").drawImage(s,0,0,r,l),c.toBlob(t=>n(new File([t||e],"background.jpg",{type:"image/jpeg"})),"image/jpeg",.85)},s.onerror=()=>{URL.revokeObjectURL(i),n(e)},s.src=i})}(a,1280,720);await(null===x||void 0===x?void 0:x(e))}finally{k(!1)}}}})]})]})]})})}var ha=a(3986),xa=a(9766),pa=a(1089);const fa=["className"],ga=i.forwardRef((e,t)=>{let a=e.className,s=(0,ha.A)(e,fa);return(0,X.jsxs)(xa.bL,(0,n.A)((0,n.A)({ref:t,className:(0,pa.cn)("relative flex w-full touch-none select-none items-center",a)},s),{},{children:[(0,X.jsx)(xa.CC,{className:"relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20",children:(0,X.jsx)(xa.Q6,{className:"absolute h-full bg-primary"})}),(0,X.jsx)(xa.zi,{className:"block h-4 w-4 rounded-full border border-primary/50 bg-background shadow transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50"})]}))});ga.displayName=xa.bL.displayName;var va=a(4805);const ba={none:"linear-gradient(135deg,#334155,#475569)",beauty:"linear-gradient(135deg,#ffd9c0,#ff9a8b)",warm:"linear-gradient(135deg,#ff9a44,#ff5e62)",cool:"linear-gradient(135deg,#43cea2,#185a9d)",vintage:"linear-gradient(135deg,#c9a26b,#7d5a3c)",bw:"linear-gradient(135deg,#e5e5e5,#111111)",vivid:"linear-gradient(135deg,#f857a6,#ff5858)",neon:"linear-gradient(135deg,#00f0ff,#ff00e5)"};function wa(e){let t=e.open,r=e.onOpenChange,l=e.filterEffect,o=e.onFilter,c=e.adjust,d=e.onAdjust;const u="none"===l&&1===c.brightness&&1===c.contrast,m=(0,i.useState)([]),h=(0,s.A)(m,2),x=h[0],p=h[1];return(0,i.useEffect)(()=>{t&&!x.length&&Promise.all([a.e(207),a.e(760)]).then(a.bind(a,2760)).then(e=>p(e.FILTERS)).catch(()=>{})},[t,x.length]),(0,X.jsx)(Je.lG,{open:t,onOpenChange:r,children:(0,X.jsxs)(Je.Cf,{className:"max-w-lg glass border-white/10 text-white","data-testid":"camera-filter-dialog",children:[(0,X.jsxs)(Je.c7,{children:[(0,X.jsxs)(Je.L3,{className:"flex items-center gap-2 font-display text-xl",children:[(0,X.jsx)(Qt.A,{className:"h-5 w-5 text-[#FF2A5F]"})," Filt\xe8 kamera"]}),(0,X.jsx)(Je.rr,{className:"text-gray-400",children:"Anbeli po w, chwazi yon koul\xe8, epi ajiste limy\xe8 ak kontras kamera w."})]}),(0,X.jsxs)("div",{className:"space-y-5",children:[(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"mb-2 text-xs font-semibold uppercase tracking-widest text-gray-400",children:"Estil"}),(0,X.jsx)("div",{className:"grid grid-cols-4 gap-2.5","data-testid":"filter-grid",children:x.map(e=>{const t=l===e.id;return(0,X.jsxs)("button",{"data-testid":"filter-".concat(e.id),onClick:()=>o(e.id),className:"group relative flex flex-col items-center gap-1.5 rounded-xl p-2 transition-all ".concat(t?"ring-2 ring-[#FF2A5F]":"ring-1 ring-white/10 hover:ring-white/30"),children:[(0,X.jsx)("span",{className:"h-12 w-full rounded-lg",style:{background:ba[e.id]||ba.none}}),(0,X.jsx)("span",{className:"text-[11px] font-semibold text-gray-200",children:e.label}),t&&(0,X.jsx)("span",{className:"absolute right-1 top-1 flex h-4 w-4 items-center justify-center rounded-full bg-[#FF2A5F]",children:(0,X.jsx)(W.A,{className:"h-3 w-3 text-white"})})]},e.id)})})]}),(0,X.jsxs)("div",{className:"space-y-4 rounded-xl bg-white/5 p-4",children:[(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{className:"mb-2 flex items-center justify-between text-sm",children:[(0,X.jsx)("span",{className:"font-semibold text-gray-200",children:"Limy\xe8"}),(0,X.jsxs)("span",{className:"font-mono text-xs text-cyan-300","data-testid":"brightness-value",children:[Math.round(100*c.brightness),"%"]})]}
1),(0,X.jsx)(ga,{"data-testid":"brightness-slider",value:[c.brightness],min:.5,max:1.5,step:.05,onValueChange:e=>{let t=(0,s.A)(e,1)[0];return d((0,n.A)((0,n.A)({},c),{},{brightness:t}))}})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{className:"mb-2 flex items-center justify-between text-sm",children:[(0,X.jsx)("span",{className:"font-semibold text-gray-200",children:"Kontras"}),(0,X.jsxs)("span",{className:"font-mono text-xs text-cyan-300","data-testid":"contrast-value",children:[Math.round(100*c.contrast),"%"]})]}),(0,X.jsx)(ga,{"data-testid":"contrast-slider",value:[c.contrast],min:.5,max:1.5,step:.05,onValueChange:e=>{let t=(0,s.A)(e,1)[0];return d((0,n.A)((0,n.A)({},c),{},{contrast:t}))}})]})]}),(0,X.jsxs)("button",{"data-testid":"filter-reset-btn",onClick:()=>{o("none"),d({brightness:1,contrast:1})},disabled:u,className:"flex w-full items-center justify-center gap-2 rounded-full surface-2 py-2.5 text-sm font-semibold text-white transition-colors hover:bg-white/10 disabled:opacity-40",children:[(0,X.jsx)(va.A,{className:"h-4 w-4"})," Retabli"]})]})]})})}function ja(e){let t=e.performers,a=void 0===t?[]:t,n=e.onRequest,s=e.canRequest,i=void 0!==s&&s;return a.length?(0,X.jsxs)("div",{"data-testid":"performer-shelf",className:"mb-3 shrink-0 rounded-2xl border border-[#FFD700]/25 bg-[#FFD700]/5 p-2.5",children:[(0,X.jsxs)("p",{className:"mb-2 flex items-center gap-1.5 px-1 text-[11px] font-bold uppercase tracking-widest text-[#FFD700]",children:[(0,X.jsx)(_e.A,{className:"h-3.5 w-3.5"})," P\xe8f\xf2m\xe8 an dir\xe8k \xb7 PPV (20 jeton/min)"]}),(0,X.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-1",children:a.map(e=>(0,X.jsxs)("div",{"data-testid":"shelf-performer-".concat(e.user_id),className:"flex shrink-0 items-center gap-2 rounded-full bg-black/30 py-1 pl-1 pr-2 ring-1 ring-[#FFD700]/20",children:[(0,X.jsx)("img",{src:e.picture||"/haitipal-logo.png",alt:"",className:"h-8 w-8 rounded-full object-cover ring-2 ring-[#FFD700]/50"}),(0,X.jsx)("span",{className:"max-w-[100px] truncate text-xs font-semibold text-white",children:e.name}),i&&(0,X.jsxs)("button",{"data-testid":"shelf-ppv-".concat(e.user_id),onClick:()=>null===n||void 0===n?void 0:n(e),title:"Mande yon chat prive PPV ak ".concat(e.name),className:"flex items-center gap-1 rounded-full bg-[#FFD700] px-2.5 py-1 text-[10px] font-bold text-black transition-transform hover:scale-105",children:[(0,X.jsx)(_e.A,{className:"h-3 w-3"})," PPV"]})]},e.user_id))})]}):null}var ya=a(879),ka=a(5711),Na=a(2382),Aa=a(6533);function Fa(e){let t=e.posts,a=void 0===t?[]:t,n=e.onOpenProfile,r=e.onCompose;const l=a.slice(0,20),o=l.length,c=(0,i.useState)(0),d=(0,s.A)(c,2),u=d[0],m=d[1];(0,i.useEffect)(()=>{u>=o&&o&&m(0)},[o,u]),(0,i.useEffect)(()=>{if(o<=1)return;const e=setInterval(()=>m(e=>(e+1)%o),4e3);return()=>clearInterval(e)},[o]);const h=e=>{o&&m(t=>(t+e+o)%o)},x=l[u];return(0,X.jsxs)("div",{"data-testid":"post-wheel",className:"hidden min-w-0 flex-1 items-center gap-2 lg:flex",children:[(0,X.jsx)("div",{className:"flex shrink-0 items-center gap-1 rounded-full bg-[#00A8CC] px-2 py-1.5 text-white",children:(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5 animate-pulse"})}),(0,X.jsx)("div",{onWheel:e=>{o>1&&(e.preventDefault(),h(e.deltaY>0?1:-1))},className:"relative h-8 min-w-0 flex-1 overflow-hidden rounded-full bg-white/5 ring-1 ring-white/10",children:x?(0,X.jsxs)("button",{"data-testid":"wheel-post-".concat(x.id),onClick:()=>null===n||void 0===n?void 0:n(x.user_id),className:"post-wheel-item absolute inset-0 flex w-full items-center gap-2 px-3 text-left transition-opacity hover:opacity-80",children:[(0,X.jsx)(ya.mL,{pic:x.user_picture,name:x.user_name,size:"h-6 w-6"}),(0,X.jsx)("span",{className:"shrink-0 text-xs font-bold text-[#00A8CC]",children:x.user_name}),(0,X.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-gray-200",children:x.text})]},"".concat(x.id,"-").concat(u)):(0,X.jsx)("p",{className:"flex h-full items-center px-3 text-xs text-gray-500",children:"Poko gen aktivite \u2014 se ou ki premye!"})}),o>1&&(0,X.jsxs)("div",{className:"flex shrink-0 flex-col leading-none",children:[(0,X.jsx)("button",{"data-testid":"wheel-prev-btn",onClick:()=>h(-1),title:"P\xf2s anvan",className:"text-gray-400 transition-colors hover:text-white",children:(0,X.jsx)(ka.A,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("button",{"data-testid":"wheel-next-btn",onClick:()=>h(1),title:"P\xf2s apre",className:"text-gray-400 transition-colors hover:text-white",children:(0,X.jsx)(Na.A,{className:"h-3.5 w-3.5"})})]}),r&&(0,X.jsx)("button",{"data-testid":"wheel-compose-btn",onClick:r,title:"Pataje yon p\xf2s",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-[#FF2A5F] text-white transition-transform hover:scale-105",children:(0,X.jsx)(Aa.A,{className:"h-3.5 w-3.5"})})]})}var _a=a(929);function Ca(e){let t=e.items,a=void 0===t?[]:t,n=e.className,r=void 0===n?"":n;const l=a||[],o=l.length,c=(0,i.useState)(0),d=(0,s.A)(c,2),u=d[0],m=d[1];(0,i.useEffect)(()=>{u>=o&&o&&m(0)},[o,u]),(0,i.useEffect)(()=>
1{if(o<=1)return;const e=setInterval(()=>m(e=>(e+1)%o),5e3);return()=>clearInterval(e)},[o]);const h=e=>{o&&m(t=>(t+e+o)%o)},x=l[u],p="news"===(null===x||void 0===x?void 0:x.type);return(0,X.jsxs)("div",{"data-testid":"sports-wheel",className:"min-w-0 items-center gap-2 ".concat(r),children:[(0,X.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-white ".concat(p?"bg-[#FF2A5F]":"bg-[#16A34A]"),children:p?(0,X.jsx)(_a.A,{className:"h-4 w-4"}):(0,X.jsx)($.A,{className:"h-4 w-4"})}),(0,X.jsx)("div",{onWheel:e=>{o>1&&(e.preventDefault(),h(e.deltaY>0?1:-1))},className:"relative h-8 min-w-0 flex-1 overflow-hidden rounded-full bg-white/5 ring-1 ring-white/10",children:x?p?(0,X.jsxs)("a",{href:x.link||"#",target:"_blank",rel:"noopener noreferrer","data-testid":"sports-news-".concat(u),className:"post-wheel-item absolute inset-0 flex w-full items-center gap-2 px-3 text-left transition-opacity hover:opacity-80",children:[(0,X.jsx)("span",{className:"shrink-0 rounded bg-[#FF2A5F]/20 px-1.5 py-0.5 text-[10px] font-bold text-[#FF7DA0]",children:x.source}),(0,X.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-gray-100",children:x.title}),(0,X.jsx)(we.A,{className:"h-3 w-3 shrink-0 text-gray-400"})]},"".concat(x.id,"-").concat(u)):(0,X.jsxs)("div",{"data-testid":"sports-match-".concat(u),className:"post-wheel-item absolute inset-0 flex w-full items-center gap-2 px-3",children:[(0,X.jsx)("span",{className:"shrink-0 rounded bg-white/10 px-1.5 py-0.5 text-[10px] font-bold uppercase text-[#8fe3ff]",children:x.league}),(0,X.jsxs)("span",{className:"min-w-0 flex-1 truncate text-xs font-semibold text-white",children:[x.home," ",(0,X.jsx)("span",{className:"text-gray-400",children:"vs"})," ",x.away]}),"result"===x.status?(0,X.jsxs)("span",{className:"shrink-0 rounded bg-[#16A34A]/25 px-1.5 py-0.5 text-xs font-black text-[#7ee0a0]",children:[x.home_score,"\u2013",x.away_score]}):(0,X.jsxs)("span",{className:"shrink-0 whitespace-nowrap text-[10px] font-semibold text-[#FFD84D]",children:[x.date,x.time?" \u2022 ".concat(x.time):""]})]},"".concat(x.id,"-").concat(u)):(0,X.jsx)("p",{className:"flex h-full items-center px-3 text-xs text-gray-500","data-testid":"sports-wheel-empty",children:"Esp\xf2 & nouv\xe8l ap chaje\u2026"})}),o>1&&(0,X.jsxs)("div",{className:"flex shrink-0 flex-col leading-none",children:[(0,X.jsx)("button",{"data-testid":"sports-prev-btn",onClick:()=>h(-1),title:"Anvan",className:"text-gray-400 transition-colors hover:text-white",children:(0,X.jsx)(ka.A,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("button",{"data-testid":"sports-next-btn",onClick:()=>h(1),title:"Apre",className:"text-gray-400 transition-colors hover:text-white",children:(0,X.jsx)(Na.A,{className:"h-3.5 w-3.5"})})]})]})}var Sa=a(7310),Ra=a(247),Ea=a(7937);const Ta=e=>e&&e.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(e):e,Ma="/haitipal-logo.png";function Pa(e){let t=e.quiz,a=e.onAnswer,r=e.selfUserId,l=e.selfPicture,o=e.onGoProfile,c=e.onClose,d=e.onLeaveSession,m=e.muted,h=e.onToggleMute,x=e.volume,p=void 0===x?.5:x,f=e.onVolumeChange;const g=(0,i.useState)(null),v=(0,s.A)(g,2),b=v[0],w=v[1],j=(0,i.useState)(!1),y=(0,s.A)(j,2),k=y[0],N=y[1],A=(0,i.useState)(null),F=(0,s.A)(A,2),_=F[0],C=F[1],S=(0,i.useState)(""),R=(0,s.A)(S,2),E=R[0],M=R[1],P=!l||l===Ma;(0,i.useEffect)(()=>{w(null),N(!1),M(""),C(null!==t&&void 0!==t&&t.answered_correct?"won":null!==t&&void 0!==t&&t.gave_up?"wrong":null)},[null===t||void 0===t?void 0:t.id,null===t||void 0===t?void 0:t.answered_correct,null===t||void 0===t?void 0:t.gave_up]);const I=t&&["won","ended","timeout","answered"].includes(t.status),L=(0,i.useState)(Date.now()),z=(0,s.A)(L,2),O=z[0],q=z[1];(0,i.useEffect)(()=>{if(null===t||void 0===t||!t.answer_at)return;const e=setInterval(()=>q(Date.now()),250);return()=>clearInterval(e)},[null===t||void 0===t?void 0:t.id,null===t||void 0===t?void 0:t.answer_at]);const B=null!==t&&void 0!==t&&t.answer_at?new Date(t.answer_at).getTime():0,U=!I&&!!B&&O<B,K=U?Math.max(1,Math.ceil((B-O)/1e3)):0;if((0,i.useEffect)(()=>{t&&!I&&P&&(0,u.oR)("\ud83d\udcf8 Chanje foto pwofil default ou a pou vr\xe8 foto w pou w ka jwe JeniPal.",{duration:6e3})},[null===t||void 0===t?void 0:t.id]),!t)return null;const H={onCopy:e=>e.preventDefault(),onCut:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),onDragStart:e=>e.preventDefault(),style:{userSelect:"none",WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none",WebkitTouchCallout:"none"}},G=t.winners||[],J=G.some(e=>e.user_id&&e.user_id===r),Y=t.option_images||[],Z="text"===t.answer_mode,Q=t.correct_option||("number"===typeof t.correct_index&&t.options?t.options[t.correct_index]:null),ee=!!t.dedicated_to,te=ee&&t.dedicated_to===r,ae=ee&&!te,
1ne=e=>{if(N(!1),e){if(e.picture_required)return C("picture"),void(0,u.oR)("\ud83d\udcf8 Chanje foto pwofil ou a pou w ka reponn.");if(!e.dedicated)if(e.hold)w(null);else{if(e.device_locked)return w(null),void C("device");if(!e.locked)return e.too_late?(w(null),void C("toolate")):void(!0===e.correct?C("won"):!1===e.correct?C("wrong"):e.closed&&C("late"));C("wrong")}}},se=async()=>{if(P)return void C("picture");const e=E.trim();U||ae||k||I||"won"===_||"wrong"===_||!e||(N(!0),ne(await a({text:e})))};return(0,X.jsxs)("div",{className:"fixed left-1/2 top-20 z-[80] w-[92vw] max-w-md -translate-x-1/2","data-testid":"jenipal-quiz",children:[d&&!I&&(0,X.jsx)("button",{"data-testid":"jenipal-leave-session-btn",onClick:d,title:"Kite sesyon JeniPal la \u2014 mwen pa enterese","aria-label":"Kite sesyon JeniPal la",className:"absolute -left-3 -top-3 z-[90] flex h-12 w-12 items-center justify-center rounded-full bg-[#FF2A5F] text-white shadow-[0_4px_22px_rgba(255,42,95,0.65)] ring-2 ring-white/40 transition-transform hover:scale-110 active:scale-95",children:(0,X.jsx)(ge.A,{className:"h-7 w-7",strokeWidth:3.5})}),(0,X.jsxs)("div",{className:"overflow-hidden rounded-3xl border border-[#9333EA]/40 bg-[#140a20] shadow-2xl",children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 bg-gradient-to-r from-[#9333EA] to-[#FF2A5F] px-4 py-2.5",children:[(0,X.jsx)(T.A,{className:"h-5 w-5 text-white"}),(0,X.jsx)("span",{className:"font-display text-lg font-extrabold text-white",children:"JeniPal"}),t.q_index&&t.q_total?(0,X.jsxs)("span",{"data-testid":"jenipal-question-number",className:"rounded-full bg-black/30 px-2 py-0.5 text-xs font-bold text-white",children:[t.q_index,"/",t.q_total]}):null,!I&&t.ends_at&&(0,X.jsx)(Ea.P,{endsAt:t.ends_at}),(0,X.jsxs)("span",{className:"ml-auto flex items-center gap-1 rounded-full bg-black/30 px-2 py-0.5 text-xs font-bold text-[#FFD700]",children:[(0,X.jsx)($.A,{className:"h-3 w-3"})," ",t.reward," pwen"]}),h&&(0,X.jsx)("button",{"data-testid":"jenipal-mute-btn",onClick:h,title:m?"Aktive son suspans lan":"Koupe son suspans lan",className:"flex h-7 w-7 items-center justify-center rounded-full bg-black/25 text-white transition-colors hover:bg-black/50",children:m?(0,X.jsx)(V.A,{className:"h-4 w-4"}):(0,X.jsx)(D.A,{className:"h-4 w-4"})}),f&&(0,X.jsx)("input",{"data-testid":"jenipal-volume-slider",type:"range",min:0,max:1,step:.05,value:m?0:p,onChange:e=>f(parseFloat(e.target.value)),title:"Volim son JeniPal",className:"h-1.5 w-16 cursor-pointer appearance-none rounded-full bg-white/30 accent-[#FFD700] sm:w-20"}),c&&(0,X.jsx)("button",{"data-testid":"jenipal-close-btn",onClick:c,title:"F\xe8men",className:"flex h-7 w-7 items-center justify-center rounded-full bg-black/25 text-white transition-colors hover:bg-black/50",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsx)("div",{className:"p-4",children:I?(0,X.jsxs)("div",{className:"py-3 text-center","data-testid":"jenipal-result",children:[(0,X.jsx)($.A,{className:"mx-auto mb-2 h-8 w-8 text-[#FFD700]"}),G.length?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("p",{className:"font-bold text-white",children:J?"\ud83c\udf89 Ou genyen ".concat(t.winner_reward," pwen!"):"".concat(G[0].name," genyen! \ud83c\udf89")}),(0,X.jsx)("div",{className:"mt-2 flex flex-wrap items-center justify-center gap-1.5","data-testid":"jenipal-winners",children:(0,X.jsxs)("span",{className:"flex items-center gap-1 rounded-full surface-2 py-0.5 pl-0.5 pr-2",children:[(0,X.jsx)("img",{src:Ta(G[0].picture)||Ma,alt:"",className:"h-5 w-5 rounded-full object-cover"}),(0,X.jsx)("span",{className:"max-w-[80px] truncate text-xs text-white",children:G[0].name})]})})]}):(0,X.jsx)("p",{className:"font-bold text-white",children:"Tan an fini \u2014 p\xe8s\xf2n pa reponn k\xf2r\xe8k"}),Q&&(0,X.jsxs)("p",{className:"mt-2 text-sm text-gray-300",children:["Bon repons: ",(0,X.jsx)("b",{className:"text-[#00F0FF]",children:Q})]})]}):(0,X.jsxs)(X.Fragment,{children:[t.question_image&&(0,X.jsx)("img",{"data-testid":"jenipal-question-image",src:Ta(t.question_image),alt:"",className:"mb-3 max-h-48 w-full rounded-xl object-contain"}),(0,X.jsx)("p",(0,n.A)((0,n.A)({className:"mb-3 select-none text-center text-base font-semibold text-white","data-testid":"jenipal-question"},H),{},{children:t.question})),ee&&(0,X.jsxs)("div",{className:"mb-3 flex items-center justify-center gap-1.5 rounded-xl px-3 py-2 text-center text-sm font-bold ".concat(te?"bg-[#FFD700]/15 text-[#FFD700]":"bg-[#00A8CC]/15 text-[#00F0FF]"),"data-testid":"jenipal-dedicated-badge",children:["\ud83c\udfaf ",te?"Kesyon sa a dedye pou OU!":"Dedye pou ".concat(t.dedicated_name||"yon moun")]}),U&&!P&&!ae&&(0,X.jsxs)("div",{"data-testid":"jenipal-hold",className:"mb-3 flex items-center justify-center gap-2 rounded-xl bg-[#FFD700]/10 px-4 py-3 text-center ring-1 ring-[#FFD700]/30",children:[(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin text-[#FFD700]"}),(0,X.jsxs)("span",{className:"text-sm font-bold text-[#FFD700]",children:["Gade byen\u2026 ou ka reponn nan ",K,"s"]})]}),P?(0,X.jsxs)("div",{className:"rounded-xl bg-[#FF2A5F]/10 px-4 py-5 text-center ring-1 ring-[#FF2A5F]/30","data-testid":"jenipal-picture-required",children:[(0,X.jsx)(Ra.A,{className:"mx-auto mb-2 h-7 w-7 text-[#FF2A5F]"}),(0,X.jsx)("p",{className:"text-sm font-bold text-white",children:"Ou dwe mete vr\xe8 foto w!"}),(0,X.jsx)("p",{className:"mt-1 text-xs text-gray-300",children:"Chanje foto pwofil default HAITIPAL la pou vr\xe8 foto w anvan ou ka reponn kesyon JeniPal yo."}),(0,X.jsxs)("button",{"data-testid":"jenipal-go-profile-btn",onClick:()=>null===o||void 0===o?void 0:o(),className:"mt-3 inline-flex h-10 items-center justify-center gap-2 rounded-full bg-[#FF2A5F] px-5 text-sm font-bold text-white transition-transform hover:scale-[1.02]",children:[(0,X.jsx)(Ra.A,{className:"h-4 w-4"})," Chanje foto m"]})]}):ae?(0,X.jsxs)("div",{className:"rounded-xl surface-2 px-4 py-5 text-center","data-testid":"jenipal-locked-out",children:[(0,X.jsxs)("p",{className:"text-sm text-gray-300",children:["Kesyon sa a dedye pou ",(0,X.jsx)("b",{className:"text-[#00F0FF]",children:t.dedicated_name||"yon l\xf2t moun"}),"."]}),(0,X.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"Ou ka gade, men se s\xe8lman li ki ka reponn."})]}):Z?(0,X.jsxs)("div",{className:"space-y-2","data-testid":"jenipal-text-answer",children:[(0,X.jsx)("input",{"data-testid":"jenipal-answer-input",value:E,onChange:e=>M(e.target.value),onKeyDown:e=>{"Enter"===e.key&&se()},disabled:U||k||"won"===_||"wrong"===_,maxLength:200,placeholder:U?"Tann ".concat(K,"s\u2026"):"Tape repons ou an\u2026",autoF
1ocus:!0,className:"h-12 w-full rounded-xl surface-2 px-4 text-sm text-white placeholder:text-gray-500 outline-none ring-1 ring-white/10 focus:ring-[#9333EA] disabled:opacity-50"}),(0,X.jsxs)("button",{"data-testid":"jenipal-answer-submit",onClick:se,disabled:U||k||"won"===_||"wrong"===_||!E.trim(),className:"flex h-11 w-full items-center justify-center gap-2 rounded-xl bg-[#9333EA] text-sm font-bold text-white transition-transform hover:scale-[1.01] disabled:cursor-not-allowed disabled:opacity-40",children:[k?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(W.A,{className:"h-4 w-4"})," Voye repons"]})]}):(0,X.jsx)("div",(0,n.A)((0,n.A)({className:"grid select-none gap-2"},H),{},{children:t.options.map((e,t)=>{const n=b===t,s=Y[t],i=n&&"won"===_?"bg-green-500 text-white":n&&"wrong"===_?"bg-red-500/80 text-white":n?"bg-[#9333EA] text-white":U?"surface-2 text-white/60":"surface-2 text-white hover:bg-white/10";return(0,X.jsxs)("button",{"data-testid":"jenipal-option-".concat(t),disabled:U||k||null!==b||"won"===_,onClick:()=>(async e=>{P?C("picture"):U||ae||k||I||"won"===_||null!==b||(w(e),N(!0),ne(await a(e)))})(t),className:"flex items-center justify-between gap-2 rounded-xl px-4 py-3 text-left text-sm font-semibold transition-colors disabled:cursor-not-allowed ".concat(i),children:[(0,X.jsxs)("span",{className:"flex items-center gap-2",children:[s&&(0,X.jsx)("img",{"data-testid":"jenipal-option-image-".concat(t),src:Ta(s),alt:"",className:"h-12 w-12 shrink-0 rounded-lg object-cover"}),e&&(0,X.jsx)("span",{children:e})]}),k&&n&&(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}),n&&"won"===_&&(0,X.jsx)(W.A,{className:"h-4 w-4"}),n&&"wrong"===_&&(0,X.jsx)(ge.A,{className:"h-4 w-4"})]},t)})})),"won"===_&&(0,X.jsx)("p",{className:"mt-3 text-center text-sm font-bold text-green-400","data-testid":"jenipal-feedback",children:"Bon repons! \u2705 Ou genyen rekonpans lan! \ud83c\udf89"}),"toolate"===_&&(0,X.jsx)("p",{className:"mt-3 text-center text-sm text-yellow-400","data-testid":"jenipal-feedback",children:"Yon l\xf2t moun reponn k\xf2r\xe8k anvan w \ud83d\ude05"}),"wrong"===_&&(0,X.jsx)("p",{className:"mt-3 text-center text-sm text-red-400","data-testid":"jenipal-feedback",children:"Repons pa bon \ud83d\ude14 \u2014 ou pa ka reponn kwiz sa a ank\xf2."}),"late"===_&&(0,X.jsx)("p",{className:"mt-3 text-center text-sm text-yellow-400","data-testid":"jenipal-feedback",children:"Kwiz la f\xe8men \ud83d\ude05"}),"device"===_&&(0,X.jsx)("p",{className:"mt-3 text-center text-sm text-[#FF2A5F]","data-testid":"jenipal-feedback",children:"Yon l\xf2t kont sou menm apar\xe8y/koneksyon (IP) an deja reponn kesyon sa a."}),"picture"===_&&(0,X.jsx)("p",{className:"mt-3 text-center text-sm text-[#FF2A5F]","data-testid":"jenipal-feedback",children:"Mete vr\xe8 foto w anvan ou ka reponn."})]})})]})]})}function Da(e){let t=e.notice,a=e.onClose,n=e.onOptOut;return(0,i.useEffect)(()=>{if(!t)return;const e=setTimeout(a,6e4);return()=>clearTimeout(e)},[t,a]),t?(0,me.createPortal)((0,X.jsxs)("div",{"data-testid":"jenipal-soon",className:"fixed left-1/2 top-24 z-[130] w-[92vw] max-w-sm -translate-x-1/2",style:{animation:"pop-in .35s ease-out"},children:[n&&(0,X.jsx)("button",{"data-testid":"jenipal-soon-optout",onClick:n,title:"Pa enterese \u2014 pa f\xe8 m patisipe nan sesyon sa a","aria-label":"Pa enterese nan sesyon JeniPal sa a",className:"absolute -left-3 -top-3 z-[10] flex h-12 w-12 items-center justify-center rounded-full bg-[#FF2A5F] text-white shadow-[0_4px_22px_rgba(255,42,95,0.65)] ring-2 ring-white/40 transition-transform hover:scale-110 active:scale-95",children:(0,X.jsx)(ge.A,{className:"h-7 w-7",strokeWidth:3.5})}),(0,X.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border border-[#9333EA]/50 bg-[#140a20] p-4 shadow-2xl",children:[(0,X.jsx)("button",{"data-testid":"jenipal-soon-close",onClick:a,title:"F\xe8men",className:"absolute right-2 top-2 flex h-7 w-7 items-center justify-center rounded-full bg-black/30 text-white transition-colors hover:bg-black/60",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})}),(0,X.jsxs)("div",{className:"flex items-center gap-3",children:[(0,X.jsx)("span",{className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-[#9333EA] to-[#FF2A5F]",children:(0,X.jsx)(T.A,{className:"h-6 w-6 text-white"})}),(0,X.jsxs)("div",{className:"min-w-0 pr-6",children:[(0,X.jsx)("p",{className:"font-display text-lg font-extrabold text-white",children:"JeniPal ap k\xf2manse!"}),(0,X.jsxs)("p",{className:"text-sm text-gray-300",children:["Yon sesyon kwiz ap k\xf2manse nan ",(0,X.jsxs)("b",{className:"text-[#FFD700]",children:[t.mins," minit"]}),t.count?" \u2014 ".concat(t.count," kesyon"):"",". Rete la pou w jwe epi genyen rekonpans! \ud83c\udfc6"]})]})]}),(0,X.jsx)("div",{className:"mt-3 h-1 w-full overflow-hidden rounded-full bg-white/10",children:(0,X.jsx)("div",{className:"h-full bg-[#9333EA]",style:{animation:"comboShrink 60s linear forwards"}})})]})]}),document.body):null}function Ia(e){let t=e.ads,a=void 0===t?[]:t,n=e.rotateSecs,r=void 0===n?8:n;const l=(0,i.useState)(0),o=(0,s.A)(l,2),c=o[0],u=o[1],m=a.length;if((0,i.useEffect)(()=>{c>=m&&u(0)},[m,c]),(0,i.useEffect)(()=>
1{if(m<=1)return;const e=setInterval(()=>u(e=>(e+1)%m),1e3*Math.max(3,r||8));return()=>clearInterval(e)},[m,r]),(0,i.useEffect)(()=>{if(!m)return;const e=a[Math.min(c,m-1)];null!==e&&void 0!==e&&e.id&&d.Ay.post("/live-ads/impression",{id:e.id,text:e.text}).catch(()=>{})},[c,m]),!m)return null;const h=a[Math.min(c,m-1)],x=()=>{null!==h&&void 0!==h&&h.id&&d.Ay.post("/live-ads/click",{id:h.id,text:h.text}).catch(()=>{})};return(0,X.jsxs)("div",{"data-testid":"live-ad-overlay",className:"lt-fade pointer-events-auto absolute inset-x-0 bottom-0 z-30 flex items-center gap-2.5 bg-gradient-to-t from-black/90 via-black/70 to-transparent px-3 pb-3 pt-6",children:[h.image_url&&(0,X.jsx)("img",{src:(p=h.image_url,p&&p.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(p):p),alt:"","data-testid":"live-ad-image",className:"h-11 w-11 shrink-0 rounded-md object-cover ring-1 ring-white/20"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsx)("span",{className:"mr-1.5 inline-block rounded bg-[#FF2A5F] px-1.5 py-0.5 align-middle text-[9px] font-black uppercase tracking-wider text-white",children:"Piblisite"}),(0,X.jsx)("span",{className:"align-middle text-sm font-bold leading-snug text-white drop-shadow",children:h.text}),(0,X.jsxs)("div",{className:"mt-0.5 flex flex-wrap items-center gap-3",children:[h.link_url&&(0,X.jsxs)("a",{href:h.link_url,target:"_blank",rel:"noopener noreferrer",onClick:x,"data-testid":"live-ad-link",className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#00F0FF] hover:underline",children:[(0,X.jsx)(we.A,{className:"h-3 w-3"})," Vizite"]}),h.phone&&(0,X.jsxs)("a",{href:"tel:".concat(h.phone),onClick:x,"data-testid":"live-ad-phone",className:"inline-flex items-center gap-1 text-[11px] font-bold text-[#00F0FF] hover:underline",children:[(0,X.jsx)(je.A,{className:"h-3 w-3"})," ",h.phone]})]})]}),m>1&&(0,X.jsx)("div",{className:"flex shrink-0 items-center gap-1 self-start pt-0.5","data-testid":"live-ad-dots",children:a.map((e,t)=>(0,X.jsx)("span",{className:"h-1.5 w-1.5 rounded-full ".concat(t===c?"bg-[#00F0FF]":"bg-white/30")},t))})]},h.id||c);var p}var La=a(6388),za=a(7655);const Va=e=>e&&e.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(e):e;function Oa(e){let t=e.open,a=e.onClose;const n=(0,r.Zp)(),l=(0,i.useState)([]),o=(0,s.A)(l,2),c=o[0],m=o[1],h=(0,i.useState)(!1),x=(0,s.A)(h,2),p=x[0],f=x[1],g=(0,i.useState)(1),v=(0,s.A)(g,2),b=v[0],w=v[1],j=(0,i.useState)(""),y=(0,s.A)(j,2),k=y[0],N=y[1],A=(0,i.useState)(""),F=(0,s.A)(A,2),_=F[0],C=F[1],S=(0,i.useState)(""),R=(0,s.A)(S,2),T=R[0],M=R[1],P=(0,i.useState)(null),D=(0,s.A)(P,2),I=D[0],L=D[1],z=(0,i.useState)(!1),V=(0,s.A)(z,2),q=V[0],B=V[1],U=(0,i.useState)(!1),K=(0,s.A)(U,2),H=K[0],G=K[1],J=(0,i.useRef)(null),Y=()=>d.Ay.get("/host-ads").then(e=>{m(e.data.ads||[]),f(!!e.data.is_vip),w(e.data.max||1)}).catch(()=>{});if((0,i.useEffect)(()=>{t&&Y()},[t]),!t)return null;const Z=c.length>=b;return(0,me.createPortal)((0,X.jsxs)("div",{className:"fixed inset-0 z-[126] flex items-center justify-center p-4","data-testid":"live-ad-manager",children:[(0,X.jsx)("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:a}),(0,X.jsxs)("div",{className:"relative z-10 flex max-h-[88vh] w-full max-w-md flex-col overflow-hidden rounded-3xl border border-[#FF2A5F]/40 bg-[#0b0b16] [html.light_&]:bg-[#e9edf4] shadow-2xl",style:{animation:"radioPop .25s cubic-bezier(.2,.8,.2,1)"},children:[(0,X.jsxs)("div",{className:"flex items-center gap-2 bg-gradient-to-r from-[#FF2A5F] to-[#9333EA] px-4 py-3",children:[(0,X.jsx)(be.A,{className:"h-5 w-5 text-white"}),(0,X.jsx)("span",{className:"font-display text-lg font-extrabold text-white",children:"Piblisite Dir\xe8k mwen"}),(0,X.jsx)("button",{"data-testid":"live-ad-manager-close",onClick:a,className:"ml-auto flex h-8 w-8 items-center justify-center rounded-full bg-black/25 text-white hover:bg-black/50",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsxs)("div",{className:"min-h-0 flex-1 overflow-y-auto p-4",children:[(0,X.jsxs)("div",{className:"mb-3 flex items-center justify-between rounded-xl surface-2 px-3 py-2",children:[(0,X.jsx)("span",{className:"flex items-center gap-1.5 text-xs font-bold text-gray-300",children:p?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(E.A,{className:"h-4 w-4 text-[#FFD700]"})," VIP"]}):"Kont regilye"}),(0,X.jsxs)("span",{className:"text-xs text-gray-400","data-testid":"live-ad-count",children:[c.length,"/",b," piblisite"]})]}),c.length>0&&(0,X.jsx)("div",{className:"mb-4 space-y-2","data-testid":"live-ad-list",children:c.map(e=>{var t,a;return(0,X.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl surface-2 p-2.5","data-testid":"live-ad-row-".concat(e.id),children:[e.image_url&&(0,X.jsx)("img",{src:Va(e.image_url),alt:"",className:"h-10 w-10 shrink-0 rounded-md object-cover"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsx)("p",{className:"truncate text-sm font-semibold text-white",children:e.text}),(0,X.jsxs)("div",{className:"mt-0.5 flex items-center gap-3",children:[(0,X.jsx)("span",{className:"text-[11px] font-bold ".concat(e.active?"text-green-400":"text-gray-500"),children:e.active?"\u25cf Aktif":"\u25cb Etenn"}),(0,X.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-gray-400","data-testid":"live-ad-impressions-".concat(e.id),children:[(0,X.jsx)(O.A,{className:"h-3 w-3"})," ",null!==(t=e.impressions)&&void 0!==t?t:0]}),(0,X.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-gray-400","data-testid":"live-ad-clicks-".concat(e.id),children:[(0,X.jsx)(La.A,{className:"h-3 w-3"})," ",null!==(a=e.clicks)&&void 0!==a?a:0]}),e.impressions>0&&(0,X.jsxs)("span",{className:"text-[11px] text-[#00F0FF]",children:[e.ctr,"% CTR"]})]})]}),(0,X.jsx)("button",{"data-testid":"live-ad-toggle-".concat(e.id),onClick:()=>(async e=>{try{await d.Ay.post("/host-ads/".concat(e.id,"/toggle")),Y()}catch(t){u.oR.error("Yon er\xe8 rive")}})(e),title:e.active?"Etenn":"Limen",className:"flex h-9 w-9 items-center justify-center rounded-full ".concat(e.active?"bg-green-500/20 text-green-400":"bg-white/10 text-gray-400"," hover:scale-105"),children:(0,X.jsx)(za.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{"data-testid":"live-ad-delete-".concat(e.id),onClick:()=>(async e=>{try{await d.Ay.delete("/host-ads/".concat(e.id)),Y(),(0,u.oR)("Piblisite efase")}catch(t){u.oR.error("Yon er\xe8 rive")}})(e),title:"Efase",className:"flex h-9 w-9 items-center justify-center rounded-full bg-red-500/15 text-red-400 hover:scale-105",children:(0,X.jsx)(Ne.A,{className:"h-4 w-4"})})]},e.id)})}),Z?(0,X.jsx)("div",{className:"rounded-2xl bg-[#FFD700]/10 px-4 py-5 text-center ring-1 ring-[#FFD700]/30","data-testid":"live-ad-limit",children:p?(0,X.jsxs)("p",{className:"text-sm text-gray-300",children:["Ou rive nan limit ",b," piblisite yo. Efase youn pou w ka ajoute yon l\xf2t."]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("span",{className:"mx-auto mb-3 flex h-14 w-14 items-center justify-center rounded-full bg-gradient-to-br from-[#FFD700] to-[#FF2A5F]",children:(0,X.jsx)(E.A,{className:"h-8 w-8 text-white"})}),(0,X.jsx)("p",{className:"font-display text-xl font-black text-white",children:"Vin VIP \ud83d\udc51"}),(0,X.jsx)("p",{className:"mt-1 text-xs text-gray-300",children:"Kont regilye ka gen yon s\xe8l piblisite. Manm VIP yo debloke plis:"}),(0,X.jsx)("ul",{className:"mx-auto mt-3 max-w-xs space-y-1.5 text-left",children:["Plizy\xe8 piblisite k ap woule nan dir\xe8k ou","Badj VIP dore + non dore nan chat la","Jeton gratis chak jou","Priyorite slot kamera nan lakou a"].map(e=>(0,X.jsxs)("li",{className:"flex items-start gap-2 text-sm text-gray-200",children:[(0,X.jsx)(W.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-[#FFD700]"})," ",e]},e))}),(0,X.jsxs)("button",{"data-testid":"live-ad-become-vip-btn",onClick:()=>{null===a||void 0===a||a(),n("/wallet")},className:"mt-4 inline-flex h-11 w-full items-center justify-center gap-2 rounded-full bg-gradient-to-r from-[#FFD700] to-[#FF2A5F] text-sm font-black text-white transition-transform hover:scale-[1.02]",children:[(0,X.jsx)(E.A,{className:"h-4 w-4"})," Vin VIP kounye a"]})]})}):(0,X.jsxs)("div",{className:"space-y-2.5 rounded-2xl surface-2 p-3","data-testid":"live-ad-form",children:[(0,X.jsx)("p",{className:"text-sm font-bold text-white",children:"Nouvo piblisite"}),(0,X.jsx)("input",{"data-testid":"live-ad-text",value:k,onChange:e=>N(e.target.value),maxLength:160,placeholder:"T\xe8ks piblisite a\u2026",className:"h-11 w-full rounded-xl surface px-3 text-sm text-white outline-none ring-1 ring-white/10 focus:ring-[#FF2A5F]"}
1),(0,X.jsx)("input",{"data-testid":"live-ad-link",value:_,onChange:e=>C(e.target.value),maxLength:300,placeholder:"Lyen (opsyon\xe8l) \u2014 egz. https://\u2026",className:"h-11 w-full rounded-xl surface px-3 text-sm text-white outline-none ring-1 ring-white/10 focus:ring-[#FF2A5F]"}),(0,X.jsx)("input",{"data-testid":"live-ad-phone",value:T,onChange:e=>M(e.target.value),maxLength:40,placeholder:"Telef\xf2n (opsyon\xe8l)",className:"h-11 w-full rounded-xl surface px-3 text-sm text-white outline-none ring-1 ring-white/10 focus:ring-[#FF2A5F]"}),(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("input",{ref:J,type:"file",accept:"image/*",onChange:async e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(a){G(!0);try{const e=new FormData;e.append("file",a);const t=(await d.Ay.post("/uploads/cover",e,{headers:{"Content-Type":"multipart/form-data"}})).data;L(t.url)}catch(n){u.oR.error("Echwe pandan chajman foto a")}finally{G(!1),J.current&&(J.current.value="")}}},className:"hidden","data-testid":"live-ad-image-input"}),(0,X.jsxs)("button",{onClick:()=>{var e;return null===(e=J.current)||void 0===e?void 0:e.click()},disabled:H,"data-testid":"live-ad-image-btn",className:"flex h-10 items-center gap-2 rounded-xl surface px-3 text-sm font-semibold text-white ring-1 ring-white/10 hover:bg-white/5 disabled:opacity-50",children:[H?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(We.A,{className:"h-4 w-4"})," ",I?"Chanje foto":"Ajoute foto"]}),I&&(0,X.jsx)("img",{src:Va(I),alt:"",className:"h-10 w-10 rounded-md object-cover ring-1 ring-white/20"})]}),(0,X.jsxs)("button",{"data-testid":"live-ad-create-btn",onClick:async()=>{if(k.trim()){B(!0);try{await d.Ay.post("/host-ads",{text:k.trim(),link_url:_.trim()||null,phone:T.trim()||null,image_url:I}),N(""),C(""),M(""),L(null),u.oR.success("Piblisite a kreye \u2014 l ap par\xe8t nan dir\xe8k ou! \ud83d\udce3"),Y()}catch(a){var e,t;u.oR.error((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Yon er\xe8 rive")}finally{B(!1)}}else u.oR.error("Ekri yon t\xe8ks pou piblisite a")},disabled:q||!k.trim(),className:"flex h-11 w-full items-center justify-center gap-2 rounded-full bg-[#FF2A5F] text-sm font-bold text-white transition-transform hover:scale-[1.01] disabled:opacity-50",children:[q?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(fe.A,{className:"h-4 w-4"})," Kreye piblisite"]})]})]})]})]}),document.body)}function qa(e){let t=e.celebration,a=e.onDone,n=e.selfUserId;const r=(0,i.useState)(!1),l=(0,s.A)(r,2),o=l[0],c=l[1],d=(0,i.useRef)(a);if((0,i.useEffect)(()=>{d.current=a},[a]),(0,i.useEffect)(()=>{if(!t)return;c(!0);const e=setTimeout(()=>c(!1),7e3),a=setTimeout(()=>d.current&&d.current(),7400);return()=>{clearTimeout(e),clearTimeout(a)}},[t]),!t)return null;const u=t.winners||[],m=t.count||u.length,h=t.reward,x=u.some(e=>e.user_id&&e.user_id===n),p=u.slice(0,5),f=m-p.length;return(0,X.jsx)("div",{"data-testid":"quiz-winner-spotlight",className:"pointer-events-none fixed inset-x-0 top-24 z-[95] flex justify-center px-4 transition-all duration-500 ".concat(o?"translate-y-0 opacity-100":"-translate-y-6 opacity-0"),children:(0,X.jsxs)("div",{className:"relative overflow-hidden rounded-3xl border border-[#FFD700]/50 bg-gradient-to-br from-[#9333EA] via-[#FF2A5F] to-[#9333EA] px-7 py-5 text-center shadow-2xl",children:[(0,X.jsx)("div",{className:"absolute inset-0 animate-pulse bg-white/5"}),(0,X.jsxs)("div",{className:"relative",children:[(0,X.jsxs)("div",{className:"mb-2 flex items-center justify-center gap-2",children:[(0,X.jsx)(T.A,{className:"h-6 w-6 text-white"}),(0,X.jsx)("span",{className:"font-display text-xl font-black uppercase tracking-wide text-white",children:"JeniPal"}),(0,X.jsx)($.A,{className:"h-6 w-6 text-[#FFD700]"})]}),(0,X.jsx)("p",{"data-testid":"spotlight-winner-name",className:"font-display text-2xl font-black text-[#FFD700] drop-shadow sm:text-3xl",children:0===m?"P\xe8s\xf2n pa genyen \ud83d\ude05":x?"\ud83c\udf89 OU GENYEN! \ud83c\udf89":1===m?"\ud83c\udf89 ".concat(u[0].name," GENYEN! \ud83c\udf89"):"\ud83c\udf89 ".concat(m," moun genyen! \ud83c\udf89")}),m>0&&(0,X.jsx)("p",{className:"mt-1 text-sm font-semibold text-white/90",children:x?"Ou pran ".concat(h," pwen!"):"Chak gayan pataje rekonpans lan"}),p.length>0&&(0,X.jsxs)("div",{className:"mt-3 flex flex-wrap items-center justify-center gap-2","data-testid":"spotlight-winners",children:[p.map(e=>{return(0,X.jsxs)("span",{className:"flex items-center gap-1.5 rounded-full bg-black/25 py-1 pl-1 pr-3",children:[(0,X.jsx)("img",{src:(t=e.picture,(t&&t.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(t):t)||"/haitipal-logo.png"),alt:"",className:"h-6 w-6 rounded-full object-cover ring-1 ring-white/40"}),(0,X.jsx)("span",{className:"max-w-[90px] truncate text-xs font-bold text-white",children:e.name})]},e.user_id);var t}),f>0&&(0,X.jsxs)("span",{className:"rounded-full bg-black/25 px-3 py-1.5 text-xs font-bold text-white",children:["+",f]})]})]})]})})}var Ba=a(2701),Ua=a(8306);const Ka=["#FFD700","#C0C0C0","#CD7F32"];function Ha(e){let t=e.results,a=e.selfUserId,n=e.onClose;const r=i.useState(!1),l=(0,s.A)(r,2),o=l[0],c=l[1],d=i.useRef(n);if(d.current=n,i.useEffect(()=>{if(!t)return;const e=setTimeout(()=>{var e;return null===(e=d.current)||void 0===e?void 0:e.call(d)},3e4);return()=>clearTimeout(e)},[t]),!t)return null;const m=t.scoreboard||[];return(0,me.createPortal)((0,X.jsxs)("div",{className:"fixed inset-0 z-[125] flex items-center justify-center p-4","data-testid":"jenipal-results",children:[(0,X.jsx)("div",{className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:n}),(0,X.jsxs)("div",{className:"relative z-10 w-full max-w-md overflow-hidden rounded-3xl border border-[#FFD700]/40 bg-[#0b0b16] [html.light_&]:bg-[#e9edf4] shadow-2xl",style:{animation:"radioPop .25s cubic-bezier(.2,.8,.2,1)"},children:[(0,X.jsx)("button",{"data-testid":"jenipal-results-close",onClick:n,className:"absolute right-3 top-3 z-20 flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})}),(0,X.jsxs)("div",{className:"bg-gradient-to-b from-[#FFD700]/20 to-transparent px-6 pb-4 pt-7 text-center",children:[(0,X.jsx)("div",{className:"mx-auto mb-2 flex h-14 w-14 items-center justify-center rounded-full bg-[#FFD700] text-black shadow-lg",children:(0,X.jsx)($.A,{className:"h-7 w-7"})}),(0,X.jsx)("h2",{className:"font-display text-2xl font-black text-white",children:"Sesyon JeniPal Fini! \ud83c\udf89"}),(0,X.jsxs)("p",{className:"mt-1 text-sm text-white/60",children:[t.totalQuestions?"".concat(t.totalQuestions," kesyon"):"",m.length?" \xb7 ".concat(m.length," patisipan"):""]})]}),(0,X.jsx)("div",{className:"max-h-[55vh] overflow-y-auto scroll-red px-4 pb-5",children:0===m.length?(0,X.jsx)("p",{className:"py-8 text-center text-sm text-white/50","data-testid":"jenipal-results-empty",children:"P\xe8s\xf2n pa reponn okenn kesyon nan sesyon sa a. \ud83d\ude05"}):(0,X.jsx)("ul",{className:"space-y-2",children:m.map((e,t)=>{const n=e.user_id===a,s=Ka[t]||"rgba(255,255,255,0.25)";return(0,X.jsxs)("li",{"data-testid":"jenipal-rank-".concat(t),className:"flex items-center gap-3 rounded-2xl p-2.5 ".concat(n?"bg-[#00F0FF]/10 ring-1 ring-[#00F0FF]/50":"bg-white/[0.04]"),children:[(0,X.jsx)("div",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full font-display text-sm font-black",style:{background:s,color:t<3?"#000":"#fff"},children:0===t?(0,X.jsx)(E.A,{className:"h-4 w-4"}):t<3?(0,X.jsx)(Ba.A,{className:"h-4 w-4"}
1):t+1}),e.picture?(0,X.jsx)("img",{src:e.picture,alt:"",className:"h-9 w-9 shrink-0 rounded-full object-cover ring-1 ring-white/15"}):(0,X.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-white/10 text-xs font-bold text-white",children:(e.name||"?")[0]}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsxs)("p",{className:"truncate text-sm font-bold text-white",children:[e.name,n?" (ou)":""]}),(0,X.jsxs)("p",{className:"text-[11px] text-white/50",children:[e.wins," bon repons"]})]}),(0,X.jsxs)("div",{className:"shrink-0 text-right",children:[(0,X.jsx)("p",{className:"font-display text-lg font-black text-[#FFD700]",children:e.points}),(0,X.jsx)("p",{className:"-mt-1 text-[10px] uppercase tracking-wide text-white/40",children:"pwen"}),e.usd&&(0,X.jsx)("p",{className:"mt-0.5 text-[11px] font-bold text-[#34D399]","data-testid":"jenipal-usd-".concat(t),children:e.usd})]})]},e.user_id)})})}),m.length>0&&(0,X.jsxs)("div",{className:"border-t border-white/10 px-4 py-3 space-y-2",children:[(0,X.jsxs)("button",{"data-testid":"jenipal-share-btn",onClick:async()=>{const e=["\ud83e\udd47","\ud83e\udd48","\ud83e\udd49"],t=m.slice(0,3).map((t,a)=>"".concat(e[a]||"\ud83c\udfc5"," ").concat(t.name," \u2014 ").concat(t.points," pwen").concat(t.usd?" (".concat(t.usd,")"):"")).join("\n"),a="\ud83e\udde0 Rezilta JeniPal sou HAITIPAL!\n".concat(t,"\n\nVin jwe pwochen kwiz la epi genyen rekonpans! \ud83c\udfc6"),n=window.location.origin;if(navigator.share)try{return void await navigator.share({title:"Rezilta JeniPal \u2014 HAITIPAL",text:a,url:n})}catch(s){return}try{await navigator.clipboard.writeText("".concat(a,"\n").concat(n)),u.oR.success("Rezilta a kopye \u2014 kole l kote w vle!")}catch(i){}window.open("https://www.facebook.com/sharer/sharer.php?u=".concat(encodeURIComponent(n),"&quote=").concat(encodeURIComponent(a)),"_blank","noopener,noreferrer,width=600,height=500")},className:"flex h-11 w-full items-center justify-center gap-2 rounded-full bg-gradient-to-r from-[#FFD700] to-[#FF9F1C] font-display text-sm font-black uppercase tracking-wide text-black transition-transform hover:scale-[1.02] active:scale-95",children:[(0,X.jsx)(Ua.A,{className:"h-4 w-4"})," Pataje rezilta yo"]}),(0,X.jsxs)("button",{"data-testid":"jenipal-tiktok-btn",onClick:()=>c(!0),className:"flex h-11 w-full items-center justify-center gap-2 rounded-full bg-white font-display text-sm font-black uppercase tracking-wide text-black transition-transform hover:scale-[1.02] active:scale-95",children:[(0,X.jsx)(ke.A,{className:"h-4 w-4"})," Pataje sou TikTok"]})]})]}),(0,X.jsx)(ht,{open:o,onClose:()=>c(!1),sessionId:t.sessionId,defaultTitle:"\ud83e\udde0 Rezilta JeniPal sou HAITIPAL! Vin jwe epi genyen rekonpans \ud83c\udfc6"})]}),document.body)}function Wa(e){let t=e.endsAt,a=e.active;const n=(0,i.useState)(null),r=(0,s.A)(n,2),l=r[0],o=r[1],c=(0,i.useRef)(null);return(0,i.useEffect)(()=>{if(!t||!a)return o(null),void(c.current=null);const e=()=>{const e=Math.ceil((new Date(t).getTime()-Date.now())/1e3);if(o(e),e>=1&&e<=10&&c.current!==e){c.current=e;try{(0,de.vC)(e<=3)}catch(a){}}};e();const n=setInterval(e,250);return()=>clearInterval(n)},[t,a]),null===l||l>10||l<=0?null:(0,X.jsxs)("div",{"data-testid":"competition-final-countdown",className:"pointer-events-none fixed inset-0 z-[90] flex items-center justify-center",children:[(0,X.jsx)("div",{className:"absolute inset-0 bg-black/25"}),(0,X.jsxs)("div",{className:"count-pop relative flex flex-col items-center",children:[(0,X.jsx)("span",{className:"font-display font-black leading-none drop-shadow-[0_0_40px_rgba(255,42,95,0.85)] ".concat(l<=3?"text-[#FF2A5F]":"text-white"),style:{fontSize:"clamp(6rem, 22vw, 14rem)"},children:l}),(0,X.jsx)("span",{"data-testid":"final-countdown-label",className:"mt-1 font-display text-xl font-black uppercase tracking-[0.3em] text-white drop-shadow sm:text-3xl",children:"D\xe8nye segond!"})]},l)]})}var Ga=a(5937),Ja=a(8236);function Ya(e){let t=e.schedule,a=e.myStatus,n=e.isGuest,r=e.me,l=e.onClose,o=e.onRegistered;const c=(0,i.useState)(""),m=(0,s.A)(c,2),h=m[0],x=m[1],p=(0,i.useState)((null===r||void 0===r?void 0:r.phone)||""),f=(0,s.A)(p,2),g=f[0],v=f[1],b=(0,i.useState)((null===r||void 0===r?void 0:r.email)||""),w=(0,s.A)(b,2),j=w[0],y=w[1],k=(0,i.useState)(""),N=(0,s.A)(k,2),A=N[0],F=N[1],_=(0,i.useState)(""),C=(0,s.A)(_,2),S=C[0],R=C[1],E=(0,i.useState)(!1),T=(0,s.A)(E,2),M=T[0],P=T[1],D=(0,i.useState)(!1),I=(0,s.A)(D,2),L=I[0],z=I[1],V=(0,i.useRef)(null);if(!t)return null;const O="w-full rounded-xl surface-2 px-3.5 py-3 text-base text-white placeholder:text-gray-500 outline-none ring-1 ring-white/10 focus:ring-[#FFD700]/50";return(0,X.jsx)("div",{"data-testid":"competition-register-dialog",className:"fixed inset-0 z-[120] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:l,children:(0,X.jsxs)("div",{className:"max-h-[92vh] w-full max-w-lg overflow-y-auto overflow-x-hidden rounded-3xl border border-[#FFD700]/30 bg-[#12121A] [html.light_&]:bg-[#e9edf4]",onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)("div",{className:"relative bg-gradient-to-r from-[#FF2A5F]/20 to-[#FFD700]/15 p-6",children:[(0,X.jsx)("button",{"data-testid":"competition-register-close",onClick:l,className:"absolute right-3 top-3 flex h-9 w-9 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60",children:(0,X.jsx)(ge.A,{className:"h-5 w-5"})}),(0,X.jsxs)("div",{className:"flex items-center gap-2 text-[#FFD700]",children:[(0,X.jsx)($.A,{className:"h-6 w-6"}),(0,X.jsx)("span",{className:"font-display text-sm font-black uppercase tracking-widest",children:"Konpetisyon V\xf2t"})]}),(0,X.jsx)("h2",{"data-testid":"competition-register-title",className:"mt-2 font-display text-3xl font-black leading-tight text-white",children:t.title})]}),(0,X.jsxs)("div",{className:"space-y-4 p-6",children:[t.description&&(0,X.jsx)("p",{className:"text-base leading-relaxed text-gray-200",children:t.description}),(0,X.jsxs)("div",{className:"grid gap-2.5",children:[t.prizes&&(0,X.jsxs)("div",{className:"flex items-start gap-2.5 rounded-xl bg-[#FFD700]/10 px-4 py-3 ring-1 ring-[#FFD700]/25","data-testid":"competition-register-prizes",children:[(0,X.jsx)(J.A,{className:"mt-0.5 h-5 w-5 shrink-0 text-[#FFD700]"}),(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"text-xs font-bold uppercase tracking-wide text-[#FFD700]",children:"Pri"}),(0,X.jsx)("p",{className:"text-base font-semibold text-white",children:t.prizes})]})]}),(0,X.jsxs)("div",{className:"flex items-center gap-2.5 rounded-xl surface-2 px-4 py-3","data-testid":"competition-register-when",children:[(0,X.jsx)(Ga.A,{className:"h-5 w-5 shrink-0 text-[#00F0FF]"}),(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"text-xs font-bold uppercase tracking-wide text-gray-500",children:"Dat & l\xe8"}),(0,X.jsx)("p",{className:"text-base font-semibold text-white",children:t.when_label||"Byento"})]})]})]}),n?(0,X.jsx)("div",{className:"rounded-xl bg-white/5 px-4 py-5 text-center text-base text-gray-200","data-testid":"competition-register-guest",children:"Kreye yon kont pou w ka enskri nan konpetisyon an."}):"approved"===a?(0,X.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl bg-[#39FF14]/10 px-4 py-5 text-base font-bold text-[#39FF14] ring-1 ring-[#39FF14]/30","data-testid":"competition-register-approved",children:[(0,X.jsx)(W.A,{className:"h-5 w-5"})," Ou apwouve! W ap yon kandida nan konpetisyon an. \ud83c\udf89"]}):"pending"===a?(0,X.jsxs)("div",{className:"flex items-center justify-center gap-2 rounded-xl bg-[#00A8CC]/10 px-4 py-5 text-base font-bold text-[#00F0FF] ring-1 ring-[#00F0FF]/30","data-testid":"competition-register-pending",children:[(0,X.jsx)(Ye.A,{className:"h-5 w-5"})," Enskripsyon ou an ap tann apwobasyon admin."]}):"rejected"===a?(0,X.jsx)("div",{className:"rounded-xl bg-red-500/10 px-4 py-5 text-center text-base font-bold text-red-400 ring-1 ring-red-500/30","data-testid":"competition-register-rejected",children:"Enskripsyon ou pa t apwouve fwa sa a."}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{className:"space-y-3",children:[(0,X.jsxs)("div",{children:[(0,X.jsxs)("label",{className:"mb-1.5 flex items-center gap-1.5 text-sm font-bold text-gray-300",children:[(0,X.jsx)(je.A,{className:"h-4 w-4 text-[#00F0FF]"})," Nimewo telef\xf2n ",(0,X.jsx)("span",{className:"text-[#FF2A5F]",children:"*"})]}),(0,X.jsx)("input",{"data-testid":"competition-register-phone",type:"tel",value:g,onChange:e=>v(e.target.value),maxLength:32,placeholder:"+509 3xxx xxxx",className:O})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("label",{className:"mb-1.5 flex items-center gap-1.5 text-sm font-bold text-gray-300",children:[(0,X.jsx)(ze.A,{className:"h-4 w-4 text-[#00F0FF]"})," Im\xe8l ",(0,X.jsx)("span",{className:"text-[#FF2A5F]",children:"*"})]}),(0,X.jsx)("input",{"data-testid":"competition-register-email",type:"email",value:j,onChange:e=>y(e.target.value),maxLength:120,placeholder:"[email protected]",className:O})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("label",{className:"mb-1.5 flex items-center gap-1.5 text-sm font-bold text-gray-300",children:[(0,X.jsx)(Ja.A,{className:"h-4 w-4 text-[#00F0FF]"})," Foto/dokiman idantite ",(0,X.jsx)("span",{className:"text-[#FF2A5F]",children:"*"})]}),(0,X.jsx)("input",{ref:V,"data-testid":"competition-register-id-input",type:"file",accept:"image/*,application/pdf",onChange:async e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(a){if(a.size>10485760)return u.oR.error("Fichye a tw\xf2 gwo (maks 10MB)");P(!0);try{const e=new FormData;e.append("file",a);const t=(await d.Ay.post("/uploads/id-document",e,{headers:{"Content-Type":"multipart/form-data"}})).data;F(t.url),R(a.name),u.oR.success("Dokiman idantite chaje \u2705")}catch(i){var n,s;u.oR.error((null===i||void 0===i||null===(n=i.response)||void 0===n||null===(s=n.data)||void 0===s?void 0:s.detail)||"Nou pa ka chaje fichye a")}finally{P(!1)}}},className:"hidden"}),(0,X.jsx)("button",{"data-testid":"competition-register-id-upload",type:"button",disabled:M,onClick:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.click()},className:"flex w-full items-center justify-center gap-2 rounded-xl px-3.5 py-3 text-base font-bold ring-1 transition-colors disabled:opacity-50 ".concat(A?"bg-[#39FF14]/10 text-[#39FF14] ring-[#39FF14]/40":"surface-2 text-white ring-white/10 hover:bg-white/10"),children:M?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):A?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(W.A,{className:"h-5 w-5"}
1)," ",S||"Dokiman chaje"]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ua.A,{className:"h-5 w-5"})," Chwazi kat idantite / pasp\xf2"]})}),(0,X.jsx)("p",{className:"mt-1 text-xs text-gray-500",children:"S\xe8lman admin ap w\xe8 dokiman sa a (verifikasyon). Imaj oswa PDF, maks 10MB."})]}),(0,X.jsx)("textarea",{"data-testid":"competition-register-message",value:h,onChange:e=>x(e.target.value),maxLength:300,rows:2,placeholder:"Yon ti mesaj (opsyon\xe8l) \u2014 poukisa ou vle patisipe?",className:"w-full resize-none rounded-xl surface-2 px-3.5 py-3 text-base text-white placeholder:text-gray-500 outline-none ring-1 ring-white/10 focus:ring-[#FFD700]/50"})]}),(0,X.jsx)("button",{"data-testid":"competition-register-submit",disabled:L||M,onClick:async()=>{if(!g.trim()||g.trim().length<6)return u.oR.error("Antre yon nimewo telef\xf2n valab");if(!/^\S+@\S+\.\S+$/.test(j.trim()))return u.oR.error("Antre yon im\xe8l valab");if(!A)return u.oR.error("Chaje foto/dokiman idantite w");z(!0);try{const e=(await d.Ay.post("/competition/registration/".concat(t.id,"/register"),{message:h.trim()||void 0,phone:g.trim(),email:j.trim(),id_document_url:A})).data;u.oR.success("Enskripsyon ou voye! Tann apwobasyon admin. \u2705"),o&&o(e.status)}catch(n){var e,a;u.oR.error((null===n||void 0===n||null===(e=n.response)||void 0===e||null===(a=e.data)||void 0===a?void 0:a.detail)||"Nou pa ka enskri w kounye a")}finally{z(!1)}},className:"flex min-h-[52px] w-full items-center justify-center gap-2 rounded-full bg-[#FF2A5F] text-lg font-bold text-white transition-transform hover:scale-[1.01] disabled:opacity-50 glow-pink",children:L?(0,X.jsx)(ve.A,{className:"h-6 w-6 animate-spin"}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($.A,{className:"h-5 w-5"})," Enskri nan konpetisyon an"]})}),(0,X.jsx)("p",{className:"text-center text-sm text-gray-400",children:"Admin nan ap apwouve kandida yo anvan konpetisyon an k\xf2manse."})]})]})]})})}var Xa=a(737),Za=a(7170);function Qa(e){let t=e.open,a=e.onClose,n=e.onUploaded;const r=(0,i.useState)(null),l=(0,s.A)(r,2),o=l[0],c=l[1],m=(0,i.useState)(""),h=(0,s.A)(m,2),x=h[0],p=h[1],f=(0,i.useState)(""),g=(0,s.A)(f,2),v=g[0],b=g[1],w=(0,i.useState)(!1),j=(0,s.A)(w,2),y=j[0],k=j[1],N=(0,i.useState)(!1),A=(0,s.A)(N,2),F=A[0],_=A[1],C=(0,i.useState)(0),S=(0,s.A)(C,2),R=S[0],E=S[1],T=(0,i.useRef)(null);if(!t)return null;const M=()=>{c(null),p(""),b(""),k(!1),E(0)},P=()=>{F||(M(),a())};return(0,X.jsx)("div",{className:"fixed inset-0 z-[120] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm","data-testid":"lobby-media-upload-modal",onClick:P,children:(0,X.jsxs)("div",{className:"w-full max-w-md rounded-2xl border border-white/10 bg-[#12121A] [html.light_&]:bg-[#e9edf4] p-5",onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)("div",{className:"mb-4 flex items-center justify-between",children:[(0,X.jsxs)("h3",{className:"flex items-center gap-2 text-lg font-black text-white",children:[(0,X.jsx)(Xa.A,{className:"h-5 w-5 text-[#00F0FF]"})," Mete yon foto/videyo"]}),(0,X.jsx)("button",{"data-testid":"lobby-upload-close",onClick:P,className:"text-gray-400 hover:text-white",children:(0,X.jsx)(ge.A,{className:"h-5 w-5"})})]}),(0,X.jsx)("input",{ref:T,"data-testid":"lobby-upload-file-input",type:"file",accept:"image/*,video/*",className:"hidden",onChange:e=>{var t;(e=>{if(!e)return;const t=e.type.startsWith("video/"),a=e.type.startsWith("image/");t||a?t&&e.size>26214400?u.oR.error("Videyo a tw\xf2 gwo (maks 25MB)"):a&&e.size>5242880?u.oR.error("Foto a tw\xf2 gwo (maks 5MB)"):(c(e),b(t?"video":"photo"),p(URL.createObjectURL(e))):u.oR.error("Chwazi yon foto oswa yon videyo")})(null===(t=e.target.files)||void 0===t?void 0:t[0]),e.target.value=""}}),x?(0,X.jsxs)("div",{className:"space-y-3",children:[(0,X.jsxs)("div",{className:"relative overflow-hidden rounded-2xl bg-black","data-testid":"lobby-upload-preview",children:["video"===v?(0,X.jsx)("video",{src:x,controls:!0,className:"max-h-64 w-full object-contain"}):(0,X.jsx)("img",{src:x,alt:"preview",className:"max-h-64 w-full object-contain"}),!F&&(0,X.jsx)("button",{"data-testid":"lobby-upload-change",onClick:()=>{var e;return null===(e=T.current)||void 0===e?void 0:e.click()},className:"absolute right-2 top-2 rounded-full bg-black/60 px-3 py-1 text-xs font-bold text-white hover:bg-black/80",children:"Chanje"})]}),(0,X.jsxs)("div",{className:"grid grid-cols-2 gap-2","data-testid":"lobby-upload-privacy",children:[(0,X.jsxs)("button",{onClick:()=>k(!1),disabled:F,className:"flex items-center justify-center gap-1.5 rounded-xl px-3 py-2.5 text-sm font-bold transition-colors ".concat(y?"bg-white/5 text-gray-400 ring-1 ring-white/10":"bg-[#39FF14]/15 text-[#39FF14] ring-1 ring-[#39FF14]/40"),children:[(0,X.jsx)(ie.A,{className:"h-4 w-4"})," Piblik ",!y&&(0,X.jsx)(W.A,{className:"h-3.5 w-3.5"})]}),(0,X.jsxs)("button",{onClick:()=>k(!0),disabled:F,className:"flex items-center justify-center gap-1.5 rounded-xl px-3 py-2.5 text-sm font-bold transition-colors ".concat(y?"bg-[#FFD700]/15 text-[#FFD700] ring-1 ring-[#FFD700]/40":"bg-white/5 text-gray-400 ring-1 ring-white/10"),children:[(0,X.jsx)(Xe.A,{className:"h-4 w-4"})," Prive ",y&&(0,X.jsx)(W.A,{className:"h-3.5 w-3.5"})]})]}),F&&(0,X.jsx)("div",{className:"h-2 w-full overflow-hidden rounded-full bg-white/10",children:(0,X.jsx)("div",{className:"h-full bg-[#00F0FF] transition-all",style:{width:"".concat(R,"%")},"data-testid":"lobby-upload-progress"})}),(0,X.jsx)("button",{"data-testid":"lobby-upload-submit",onClick:async()=>
1{if(o){_(!0),E(0);try{const e=new FormData;e.append("file",o),e.append("is_private",y?"true":"false");const t=(await d.Ay.post("/profile/media",e,{headers:{"Content-Type":"multipart/form-data"},onUploadProgress:e=>e.total&&E(Math.round(e.loaded/e.total*100))})).data;u.oR.success("video"===v?"Videyo a mete nan pwofil ou \u2705":"Foto a mete nan pwofil ou \u2705"),n&&n(t),M(),a()}catch(s){var e,t;u.oR.error((null===s||void 0===s||null===(e=s.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Nou pa ka f\xe8 chajman an kounye a")}finally{_(!1)}}},disabled:F,className:"flex w-full items-center justify-center gap-2 rounded-full bg-[#00A8CC] py-3 text-base font-bold text-white transition-transform hover:scale-[1.01] disabled:opacity-50",children:F?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"})," ",R,"%"]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Xa.A,{className:"h-5 w-5"})," Mete l nan pwofil mwen"]})})]}):(0,X.jsxs)("button",{"data-testid":"lobby-upload-pick-btn",onClick:()=>{var e;return null===(e=T.current)||void 0===e?void 0:e.click()},className:"flex w-full flex-col items-center justify-center gap-2 rounded-2xl border-2 border-dashed border-white/15 bg-white/5 py-10 text-gray-300 transition-colors hover:border-[#00F0FF]/50 hover:bg-[#00A8CC]/10",children:[(0,X.jsxs)("div",{className:"flex gap-3",children:[(0,X.jsx)(We.A,{className:"h-8 w-8 text-[#00F0FF]"}),(0,X.jsx)(Za.A,{className:"h-8 w-8 text-[#FF2A5F]"})]}),(0,X.jsx)("span",{className:"text-sm font-bold",children:"Klike pou chwazi yon foto oswa videyo"}),(0,X.jsx)("span",{className:"text-xs text-gray-500",children:"Foto jiska 5MB \xb7 Videyo jiska 25MB"})]})]})})}var $a=a(9463),en=a(2313),tn=a(4632);const an="haitipal_ref_hidden",nn=e=>(Number(e)||0).toLocaleString("en-US").replace(/,/g," ");function sn(){const e=(0,i.useState)(!1),t=(0,s.A)(e,2),a=t[0],n=t[1],r=(0,i.useState)(()=>{try{return"1"===localStorage.getItem(an)}catch(e){return!1}}),l=(0,s.A)(r,2),o=l[0],c=l[1],m=(0,i.useState)(null),h=(0,s.A)(m,2),x=h[0],p=h[1],f=(0,i.useState)(!1),g=(0,s.A)(f,2),v=g[0],b=g[1],w=(0,i.useState)("mine"),j=(0,s.A)(w,2),y=j[0],k=j[1],N=(0,i.useState)(null),A=(0,s.A)(N,2),F=A[0],_=A[1],C=(0,i.useState)(!1),S=(0,s.A)(C,2),R=S[0],E=S[1],T=e=>{c(e);try{localStorage.setItem(an,e?"1":"0")}catch(t){}};(0,i.useEffect)(()=>{a&&(b(!0),d.Ay.get("/referrals/me").then(e=>p(e.data)).catch(()=>{}).finally(()=>b(!1)),k("mine"))},[a]),(0,i.useEffect)(()=>{a&&"board"===y&&!F&&(E(!0),d.Ay.get("/referrals/leaderboard").then(e=>_(e.data.leaderboard||[])).catch(()=>_([])).finally(()=>E(!1)))},[a,y]);const P=()=>{var e;null!==x&&void 0!==x&&x.link&&(null===(e=navigator.clipboard)||void 0===e||e.
1writeText(x.link).then(()=>u.oR.success("Lyen kopye \u2705"),()=>u.oR.error("Nou pa ka kopye l")))},D=e=>{if(null===x||void 0===x||!x.link)return;const t=x.link,a="Vin jwenn mwen sou HAITIPAL CHAT-TV! \ud83c\udf81",n=encodeURIComponent(t),s=encodeURIComponent(a),i={whatsapp:"https://wa.me/?text=".concat(encodeURIComponent(a+" "+t)),facebook:"https://www.facebook.com/sharer/sharer.php?u=".concat(n,"&quote=").concat(s),telegram:"https://t.me/share/url?url=".concat(n,"&text=").concat(s)};window.open(i[e],"_blank","noopener,noreferrer")};return(0,X.jsxs)(X.Fragment,{children:[o?(0,X.jsx)("button",{"data-testid":"referral-reopen-handle",onClick:()=>T(!1),title:"Montre bouton referral la",className:"fixed left-0 top-1/2 z-[60] -translate-y-1/2 rounded-r-lg bg-[#00A8CC]/80 p-1 text-white shadow-lg hover:bg-[#00A8CC]",children:(0,X.jsx)(Se.A,{className:"h-4 w-4"})}):(0,X.jsxs)("div",{className:"fixed left-0 top-1/2 z-[60] flex -translate-y-1/2 items-stretch",children:[(0,X.jsxs)("button",{"data-testid":"referral-open-btn",onClick:()=>n(!0),className:"flex flex-col items-center gap-1.5 rounded-r-2xl bg-gradient-to-b from-[#FF2A5F] to-[#00A8CC] py-4 pl-2 pr-2.5 text-white shadow-xl transition-transform hover:pl-3",children:[(0,X.jsx)(J.A,{className:"h-5 w-5"}),(0,X.jsx)("span",{className:"text-[10px] font-black uppercase tracking-wider [writing-mode:vertical-rl]",children:"Referral"})]}),(0,X.jsx)("button",{"data-testid":"referral-hide-btn",onClick:()=>T(!0),title:"Kache",className:"flex items-center rounded-r-lg bg-black/40 px-0.5 text-gray-300 hover:bg-black/60 hover:text-white",children:(0,X.jsx)($a.A,{className:"h-4 w-4"})})]}),a&&(0,X.jsx)("div",{className:"fixed inset-0 z-[130] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm","data-testid":"referral-dashboard",onClick:()=>n(!1),children:(0,X.jsxs)("div",{className:"max-h-[92vh] w-full max-w-lg overflow-y-auto rounded-3xl border border-white/10 bg-[#12121A] [html.light_&]:bg-[#e9edf4]",onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)("div",{className:"relative bg-gradient-to-r from-[#FF2A5F]/25 to-[#00A8CC]/20 p-6",children:[(0,X.jsx)("button",{"data-testid":"referral-close-btn",onClick:()=>n(!1),className:"absolute right-3 top-3 flex h-9 w-9 items-center justify-center rounded-full bg-black/40 text-white hover:bg-black/60",children:(0,X.jsx)(ge.A,{className:"h-5 w-5"})}),(0,X.jsxs)("div",{className:"flex items-center gap-2 text-[#FFD700]",children:[(0,X.jsx)(J.A,{className:"h-6 w-6"}),(0,X.jsx)("span",{className:"font-display text-sm font-black uppercase tracking-widest",children:"Pwogram Referral"})]}),(0,X.jsx)("h2",{className:"mt-2 font-display text-2xl font-black leading-tight text-white",children:"Envite zanm
1i, f\xe8 lajan"}),x&&(0,X.jsxs)("p",{className:"mt-1 text-sm text-gray-200",children:["Genyen ",(0,X.jsxs)("b",{className:"text-[#39FF14]",children:[nn(x.reward_points)," pwen"]})," (",x.reward_usd,") pou chak zanmi ki rete aktif ",(0,X.jsxs)("b",{children:[x.active_days," jou"]})," youn d\xe8y\xe8 l\xf2t.",(x.signup_bonus_referrer>0||x.signup_bonus_referred>0)&&(0,X.jsxs)("span",{className:"mt-1 block text-[#FFD700]",children:["\u26a1 Bonis touswit: ou menm +",nn(x.signup_bonus_referrer)," jeton, zanmi ou +",nn(x.signup_bonus_referred)," jeton l\xe8 li enskri."]})]})]}),v||!x?(0,X.jsx)("div",{className:"flex justify-center py-16",children:(0,X.jsx)(ve.A,{className:"h-6 w-6 animate-spin text-gray-500"})}):(0,X.jsxs)("div",{className:"space-y-5 p-6",children:[(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"mb-1.5 text-xs font-bold uppercase tracking-wide text-gray-400",children:"Lyen referral ou"}),(0,X.jsxs)("div",{className:"flex items-center gap-2 rounded-xl surface-2 p-2 ring-1 ring-white/10",children:[(0,X.jsx)("input",{"data-testid":"referral-link",readOnly:!0,value:x.link,className:"min-w-0 flex-1 bg-transparent px-2 text-sm text-white outline-none"}),(0,X.jsxs)("button",{"data-testid":"referral-copy-btn",onClick:P,className:"flex shrink-0 items-center gap-1 rounded-lg bg-white/10 px-3 py-2 text-xs font-bold text-white hover:bg-white/20",children:[(0,X.jsx)(en.A,{className:"h-3.5 w-3.5"})," Kopye"]}),(0,X.jsxs)("button",{"data-testid":"referral-share-btn",onClick:async()=>{if(null===x||void 0===x||!x.link)return;if(navigator.share)try{return void await navigator.share({title:"HAITIPAL CHAT-TV",text:"Vin jwenn mwen sou HAITIPAL CHAT-TV! \ud83c\udf81",url:x.link})}catch(e){}P()},className:"flex shrink-0 items-center gap-1 rounded-lg bg-[#00A8CC] px-3 py-2 text-xs font-bold text-white hover:brightness-110",children:[(0,X.jsx)(Ua.A,{className:"h-3.5 w-3.5"})," Pataje"]})]}),(0,X.jsxs)("div",{className:"mt-2 grid grid-cols-3 gap-2","data-testid":"referral-social-share",children:[(0,X.jsxs)("button",{"data-testid":"referral-share-whatsapp",onClick:()=>D("whatsapp"),className:"flex items-center justify-center gap-1.5 rounded-xl bg-[#25D366]/15 py-2.5 text-xs font-bold text-[#25D366] ring-1 ring-[#25D366]/30 transition-colors hover:bg-[#25D366]/25",children:[(0,X.jsx)(Me.A,{className:"h-4 w-4"})," WhatsApp"]}),(0,X.jsxs)("button",{"data-testid":"referral-share-facebook",onClick:()=>D("facebook"),className:"flex items-center justify-center gap-1.5 rounded-xl bg-[#1877F2]/15 py-2.5 text-xs font-bold text-[#4B9BFF] ring-1 ring-[#1877F2]/30 transition-colors hover:bg-[#1877F2]/25",children:[(0,X.jsx)(tn.A,{className:"h-4 w-4"})," Facebook"]}),(0,X.jsxs)("button",{"data-testid":"referral-share-telegram",onClick:()=>D("telegram"),className:"flex items-center justify-center gap-1.5 rounded-xl bg-[#229ED9]/15 py-2.5 text-xs font-bold text-[#3BB0E6] ring-1 ring-[#229ED9]/30 transition-colors hover:bg-[#229ED9]/25",children:[(0,X.jsx)(He.A,{className:"h-4 w-4"})," Telegram"]})]})]}),(0,X.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[["Envite",x.total_referred,M.A,"#00F0FF"],["Aktif",x.active_count,$.A,"#FFD700"],["Reyisi",x.rewarded_count,W.A,"#39FF14"],["Pwen f\xe8t",nn(x.points_earned),se.A,"#FF2A5F"]].map(e=>{let t=(0,s.A)(e,4),a=t[0],n=t[1],i=t[2],r=t[3];return(0,X.jsxs)("div",{className:"rounded-xl surface-2 p-3 text-center","data-testid":"referral-stat-".concat(a),children:[(0,X.jsx)(i,{className:"mx-auto mb-1 h-4 w-4",style:{color:r}}),(0,X.jsx)("p",{className:"text-lg font-black text-white",children:n}),(0,X.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-wide text-gray-500",children:a})]},a)})}),(0,X.jsxs)("div",{className:"flex gap-2","data-testid":"referral-tabs",children:[(0,X.jsx)("button",{"data-testid":"referral-tab-mine",onClick:()=>k("mine"),className:"flex-1 rounded-full py-2 text-xs font-bold transition-colors ".concat("mine"===y?"bg-[#FF2A5F] text-white":"surface-2 text-gray-400"),children:"Zanmi ou"}),(0,X.jsx)("button",{"data-testid":"referral-tab-board",onClick:()=>k("board"),className:"flex-1 rounded-full py-2 text-xs font-bold transition-colors ".concat("board"===y?"bg-[#FF2A5F] text-white":"surface-2 text-gray-400"),children:"\ud83c\udfc6 Klasman"})]}),"mine"===y&&(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"mb-2 text-xs font-bold uppercase tracking-wide text-gray-400",children:"Zanmi ou envite"}),0===x.referrals.length?(0,X.jsx)("div",{className:"rounded-xl surface-2 py-8 text-center text-sm text-gray-400","data-testid":"referral-empty",children:"Poko gen zanmi. Pataje lyen ou an pou k\xf2manse f\xe8 lajan! \ud83c\udf81"}):(0,X.jsx)("div",{className:"space-y-2",children:x.referrals.map((e,t)=>(0,X.jsxs)("div",{className:"rounded-xl surface-2 p-3","data-testid":"referral-item-".concat(t),children:[(0,X.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,X.jsx)("img",{src:e.referred_picture||"/haitipal-logo.png",alt:"",className:"h-9 w-9 shrink-0 rounded-full object-cover"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsx)("p",{className:"truncate text-sm font-bold text-white",children:e.referred_name||e.referred_username}),(0,X.jsx)("p",{className:"text-[11px] text-gray-400",children:"blocked"===e.status?(0,X.jsx)("span",{className:"text-red-400",children:"Pa kalifye \u2014 menm apar\xe8y/IP"}):"".concat(e.current_streak,"/").concat(e.active_days_required," jou aktif")})]}),"rewarded"===e.status?(0,X.jsxs)("span",{className:"flex items-center gap-1 rounded-full bg-[#39FF14]/15 px-2.5 py-1 text-[10px] font-bold text-[#39FF14]",children:[(0,X.jsx)(W.A,{className:"h-3 w-3"})," Peye"]}):"blocked"===e.status?(0,X.jsx)("span",{className:"flex items-center gap-1 rounded-full bg-red-500/15 px-2.5 py-1 text-[10px] font-bold text-red-400",children:"Bloke"}):(0,X.jsxs)("span",{className:"rounded-full bg-[#FFD700]/15 px-2.5 py-1 text-[10px] font-bold text-[#FFD700]",children:[e.progress_pct,"%"]})]}),(0,X.jsx)("div",{className:"mt-2 h-1.5 w-full overflow-hidden rounded-full bg-white/10",children:(0,X.jsx)("div",{className:"h-full transition-all ".concat("rewarded"===e.status?"bg-[#39FF14]":"blocked"===e.status?"bg-red-500/60":"bg-[#00F0FF]"),style:{width:"".concat("blocked"===e.status?100:e.progress_pct,"%")}})})]},t))})]}),"board"===y&&(0,X.jsxs)("div",{"data-testid":"referral-leaderboard",children:[(0,X.jsx)("p",{className:"mb-2 text-xs font-bold uppercase tracking-wide text-gray-400",children:"Top referrers \u2014 plis pwen f\xe8t"}),R?(0,X.jsx)("div",{className:"flex justify-center py-8",children:(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin text-gray-500"})}):F&&0!==F.length?(0,X.jsx)("div",{className:"space-y-2",children:F.map(e=>(0,X.jsxs)("div",{"data-testid":"leaderboard-row-".concat(e.rank),className:"flex items-center gap-3 rounded-xl p-3 ".concat(e.is_me?"bg-[#FF2A5F]/15 ring-1 ring-[#FF2A5F]/40":"surface-2"),children:[(0,X.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-xs font-black ".concat(1===e.rank?"bg-[#FFD700] text-black":2===e.rank?"bg-gray-300 text-black":3===e.rank?"bg-amber-700 text-white":"bg-white/10 text-gray-300"),children:e.rank}),(0,X.jsx)("img",{src:e.picture||"/haitipal-logo.png",alt:"",className:"h-9 w-9 shrink-0 rounded-full object-cover"}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsxs)("p",{className:"truncate text-sm font-bold text-white",children:[e.name,e.is_me&&(0,X.jsx)("span",{className:"ml-1 text-[10px] font-bold text-[#FF2A5F]",children:"(ou menm)"})]}),(0,X.jsxs)("p",{className:"text-[11px] text-gray-400",children:[e.rewarded_count," referral reyisi \xb7 ",e.total_referred," total"]})]}),(0,X.jsxs)("div",{className:"shrink-0 text-right",children:[(0,X.jsx)("p",{className:"text-sm font-black text-[#39FF14]",children:nn(e.points_earned)}),(0,X.jsx)("p",{className:"text-[10px] font-bold uppercase text-gray-500",children:"pwen"})]})]},e.rank))}):(0,X.jsx)("div",{className:"rounded-xl surface-2 py-8 text-center text-sm text-gray-400","data-testid":"leaderboard-empty",children:"Poko gen okenn referral reyisi. Se ou ki ka premye! \ud83c\udfc6"})]})]})]})})]})}function rn(e){let t=e.startAt,a=e.title,n=e.onDone;const r=(0,i.useState)(null),l=(0,s.A)(r,2),o=l[0],c=l[1],d=(0,i.useRef)(null),u=(0,i.useRef)({}),m=e=>{try{navigator.vibrate&&navigator.vibrate("go"===e?[90,50,90,50,240]:130)}catch(t){}try{if(!d.current){const e=window.AudioContext||window.webkitAudioContext;if(!e)return;
1d.current=new e}const t=d.current;"suspended"===t.state&&t.resume().catch(()=>{});const a=t.currentTime,n=t.createOscillator(),s=t.createGain();n.connect(s),s.connect(t.destination),"go"===e?(n.type="sawtooth",n.frequency.setValueAtTime(620,a),n.frequency.exponentialRampToValueAtTime(1320,a+.35),s.gain.setValueAtTime(1e-4,a),s.gain.exponentialRampToValueAtTime(.4,a+.03),s.gain.exponentialRampToValueAtTime(1e-4,a+.8),n.start(a),n.stop(a+.85)):(n.type="square",n.frequency.value=740,s.gain.setValueAtTime(1e-4,a),s.gain.exponentialRampToValueAtTime(.3,a+.01),s.gain.exponentialRampToValueAtTime(1e-4,a+.16),n.start(a),n.stop(a+.2))}catch(a){}};if((0,i.useEffect)(()=>{if(u.current={},!t)return void c(null);const e=new Date(t).getTime(),a=()=>{const t=(e-Date.now())/1e3;if(c(t),t>0&&t<=3.5){const e=Math.max(1,Math.min(3,Math.ceil(t)));u.current[e]||(u.current[e]=!0,m("count"))}t<=0&&!u.current.go&&(u.current.go=!0,m("go")),t<=-1.4&&n&&n()};a();const s=setInterval(a,100);return()=>{clearInterval(s);try{d.current&&d.current.close()}catch(e){}d.current=null}},[t,n]),!t||null===o)return null;const h=o<=0,x=Math.max(1,Math.min(3,Math.ceil(o))),p=o>0&&o<=3.5,f=o>3.5;return(0,X.jsxs)("div",{"data-testid":"competition-start-countdown",className:"fixed inset-0 z-[125] flex flex-col items-center justify-center bg-black/80 backdrop-blur-md",children:[(0,X.jsxs)("div",{className:"mb-4 flex items-center gap-2 text-[#FFD700]",children:[(0,X.jsx)($.A,{className:"h-6 w-6"}),(0,X.jsx)("span",{className:"font-display text-sm font-black uppercase tracking-[0.3em]",children:a||"Konpetisyon V\xf2t"})]}),f&&(0,X.jsx)("p",{"data-testid":"countdown-prep",className:"animate-pulse font-display text-3xl font-black text-white sm:text-4xl",children:"Pare w\u2026 \ud83d\udd25"}),p&&(0,X.jsx)("div",{"data-testid":"countdown-digit",className:"font-display font-black leading-none text-white",style:{fontSize:"clamp(8rem, 40vw, 20rem)",animation:"cd-pop 1s ease-out",textShadow:"0 0 60px rgba(255,42,95,0.8), 0 0 120px rgba(255,215,0,0.5)"},children:x},x),h&&(0,X.jsx)("p",{"data-testid":"countdown-go",className:"font-display font-black text-[#39FF14]",style:{fontSize:"clamp(4rem, 18vw, 10rem)",animation:"cd-pop 0.6s ease-out",textShadow:"0 0 60px rgba(57,255,20,0.8)"},children:"K\xd2MANSE! \ud83c\udfc6"}),(0,X.jsx)("style",{children:"@keyframes cd-pop { 0% { transform: scale(0.3); opacity: 0; } 40% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }"})]})}var ln=a(5082),on=a(9493);function cn(){return(0,X.jsx)("div",{"data-testid":"session-ended-overlay",className:"fixed inset-0 z-[200] flex items-center justify-center bg-black/85 backdrop-blur-md p-6",children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl border border-[#FF2A5F]/30 bg-[#12121a] p-7 text-center shadow-2xl",children:[(0,X.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-[#FF2A5F]/15 ring-1 ring-[#FF2A5F]/40",children:(0,X.jsx)(ln.A,{className:"h-8 w-8 text-[#FF2A5F]"})}),(0,X.jsx)("h2",{className:"font-display text-2xl font-black text-white",children:"Ou konekte yon l\xf2t kote"}),(0,X.jsx)("p",{className:"mt-2 text-sm leading-relaxed text-gray-400",children:"Kont ou an konekte sou yon l\xf2t apar\xe8y oswa navigat\xe8. Pou sekirite, sesyon sa a f\xe8men."}),(0,X.jsxs)("div",{className:"mt-5 flex items-center justify-center gap-2 text-xs font-semibold text-gray-500",children:[(0,X.jsx)(on.A,{className:"h-3.5 w-3.5 animate-pulse"})," N ap voye w sou paj koneksyon an\u2026"]})]})})}var dn=a(7390);function un(e){let t=e.stream,a=e.muted,n=e.className;const s=(0,i.useRef)(null);return(0,i.useEffect)(()=>{s.current&&s.current.srcObject!==t&&(s.current.srcObject=t||null)},[t]),(0,X.jsx)("video",{ref:s,autoPlay:!0,playsInline:!0,muted:a,className:n})}function mn(e){var t,a,n;let r=e.call,l=e.localStream,o=e.onAccept,c=e.onDecline,d=e.onEnd,u=e.ppv,m=e.ppvIncoming,h=e.onPpvAccept,x=e.onPpvDecline,p=e.onBuyTokens;const g=(0,i.useState)({x:null,y:null}),v=(0,s.A)(g,2),b=v[0],w=v[1],j=(0,i.useRef)(null),y=(0,i.useRef)(null);var k,N,A,F;if((0,i.useEffect)(()=>
1{if("ringing-in"===(null===r||void 0===r?void 0:r.status)||"ringing-out"===(null===r||void 0===r?void 0:r.status)){return(0,de.hy)("ringing-out"===r.status)}},[null===r||void 0===r?void 0:r.status]),(0,i.useEffect)(()=>{if(m){return(0,de.hy)(!1)}},[m]),(0,i.useEffect)(()=>{const e=e=>{var t,a;if(!y.current)return;const n=(null===(t=j.current)||void 0===t?void 0:t.offsetWidth)||340,s=(null===(a=j.current)||void 0===a?void 0:a.offsetHeight)||260;let i=e.clientX-y.current.dx,r=e.clientY-y.current.dy;i=Math.max(8,Math.min(window.innerWidth-n-8,i)),r=Math.max(8,Math.min(window.innerHeight-s-8,r)),w({x:i,y:r})},t=()=>{y.current=null};return window.addEventListener("pointermove",e),window.addEventListener("pointerup",t),()=>{window.removeEventListener("pointermove",e),window.removeEventListener("pointerup",t)}},[]),m)return(0,X.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 backdrop-blur-sm","data-testid":"ppv-request-modal",children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl glass p-8 text-center",children:[(0,X.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-[#FFD700]/20 ring-4 ring-[#FFD700]/40 animate-pulse",children:(0,X.jsx)("img",{src:(null===(k=m.from)||void 0===k?void 0:k.picture)||"/haitipal-logo.png",alt:"",className:"h-16 w-16 rounded-full object-cover"})}),(0,X.jsxs)("p",{className:"mt-5 flex items-center justify-center gap-2 text-sm font-semibold uppercase tracking-widest text-[#FFD700]",children:[(0,X.jsx)(_e.A,{className:"h-4 w-4"})," Demann PPV prive"]}),(0,X.jsx)("h2",{className:"mt-1 font-display text-2xl font-extrabold text-white","data-testid":"ppv-request-name",children:(null===(N=m.from)||void 0===N?void 0:N.name)||"Yon moun"}),(0,X.jsxs)("p",{className:"mt-2 text-sm text-gray-300",children:["Ou pral touche ",(0,X.jsxs)("b",{className:"text-[#FFD700]",children:[Math.round((m.rate||20)/2)," jeton"]})," chak minit."]}),(0,X.jsxs)("div",{className:"mt-8 flex items-center justify-center gap-6",children:[(0,X.jsxs)("button",{"data-testid":"ppv-decline-btn",onClick:x,className:"flex flex-col items-center gap-1.5",children:[(0,X.jsx)("span",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-red-500 text-white shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(dn.A,{className:"h-7 w-7"})}),(0,X.jsx)("span",{className:"text-xs font-semibold text-gray-300",children:"Refize"})]}),(0,X.jsxs)("button",{"data-testid":"ppv-accept-btn",onClick:h,className:"flex flex-col items-center gap-1.5",children:[(0,X.jsx)("span",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-green-500 text-white shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(je.A,{className:"h-7 w-7"})}),(0,X.jsx)("span",{className:"text-xs font-semibold text-gray-300",children:"Aksepte"})]})]})]})});if(!r||"idle"===r.status)return null;if("ringing-in"===r.status)return(0,X.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 backdrop-blur-sm","data-testid":"incoming-call-modal",children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl glass p-8 text-center",children:[(0,X.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-[#FF2A5F]/20 ring-4 ring-[#FF2A5F]/40 animate-pulse",children:(0,X.jsx)("img",{src:(null===(A=r.peer)||void 0===A?void 0:A.picture)||"/haitipal-logo.png",alt:"",className:"h-16 w-16 rounded-full object-cover"})}),(0,X.jsxs)("p",{className:"mt-5 flex items-center justify-center gap-2 text-sm font-semibold uppercase tracking-widest text-[#00F0FF]",children:[(0,X.jsx)(Oe.A,{className:"h-4 w-4 animate-bounce"})," Ap\xe8l videyo k ap rantre"]}),(0,X.jsx)("h2",{className:"mt-1 font-display text-2xl font-extrabold text-white","data-testid":"incoming-call-name",children:(null===(F=r.peer)||void 0===F?void 0:F.name)||"Yon moun"}),(0,X.jsxs)("div",{className:"mt-8 flex items-center justify-center gap-6",children:[(0,X.jsxs)("button",{"data-testid":"decline-call-btn",onClick:c,className:"flex flex-col items-center gap-1.5",children:[(0,X.jsx)("span",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-red-500 text-white shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(dn.A,{className:"h-7 w-7"})}),(0,X.jsx)("span",{className:"text-xs font-semibold text-gray-300",children:"Refize"})]}),(0,X.jsxs)("button",{"data-testid":"accept-call-btn",onClick:o,className:"flex flex-col items-center gap-1.5",children:[(0,X.jsx)("span",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-green-500 text-white shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(je.A,{className:"h-7 w-7"})}),(0,X.jsx)("span",{className:"text-xs font-semibold text-gray-300",children:"Aksepte"})]})]})]})});const _=null!==b.x?{left:b.x,top:b.y,right:"auto",bottom:"auto"}:{right:20,bottom:20};return(0,X.jsxs)("div",{ref:j,style:_,className:"fixed z-[75] w-[340px] overflow-hidden rounded-2xl bg-[#0b0b12] shadow-2xl ring-1 ring-white/15","data-testid":"call-window",children:[(0,X.jsxs)("div",{onPointerDown:e=>{y.current={dx:e.clientX-j.current.getBoundingClientRect().left,dy:e.clientY-j.current.getBoundingClientRect().top}},className:"flex cursor-grab items-center gap-2 bg-[#131320] [html.light_&]:bg-[#e9edf4] px-3 py-2 active:cursor-grabbing",children:[(0,X.jsx)(B.A,{className:"h-4 w-4 text-[#00F0FF]"}),(0,X.jsx)("span",{className:"flex-1 truncate text-sm font-semibold text-white","data-testid":"call-peer-name",children:(null===(t=r.peer)||void 0===t?void 0:t.name)||"Ap\xe8l prive"}),"ringing-out"===r.status&&(0,X.jsx)("span",{className:"text-[11px] text-yellow-400",children:"Ap rele\u2026"}),"active"===r.status&&!u&&(0,X.jsx)("span",{className:"text-[11px] text-green-400",children:"\u25cf an dir\xe8k"}),u&&(0,X.jsxs)("span",{className:"flex items-center gap-1 text-[11px] font-bold text-[#FFD700]",children:[(0,X.jsx)(_e.A,{className:"h-3 w-3"})," PPV"]})]}),u&&(0,X.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-1.5 text-[11px] font-semibold ".concat(u.grace?"bg-red-500/25 text-red-200":"bg-[#FFD700]/10 text-[#FFD700]"),"data-testid":"ppv-billing-hud",children:[(0,X.jsxs)("span",{className:"flex items-center gap-1",children:[(0,X.jsx)(Ye.A,{className:"h-3.5 w-3.5"})," ",u.minute," min"]}),"payer"===u.role?(0,X.jsxs)("span",{className:"flex items-center gap-1","data-testid":"ppv-spent",children:[(0,X.jsx)(se.A,{className:"h-3.5 w-3.5"})," -",u.spent," jeton (",u.rate,"/min)"]}
1):(0,X.jsxs)("span",{className:"flex items-center gap-1","data-testid":"ppv-earned",children:[(0,X.jsx)(se.A,{className:"h-3.5 w-3.5"})," +",u.earned," jeton touche"]}),u.grace&&"payer"===u.role&&!(0,f.J)()&&(0,X.jsxs)("button",{"data-testid":"ppv-buy-tokens-btn",onClick:p,className:"ml-1 flex items-center gap-1 rounded-full bg-[#FFD700] px-2 py-0.5 text-[10px] font-bold text-black transition-transform hover:scale-105",children:[(0,X.jsx)(se.A,{className:"h-3 w-3"})," Achte jeton"]})]}),(0,X.jsxs)("div",{className:"relative aspect-video bg-black",children:["active"===r.status&&r.stream?(0,X.jsx)(un,{stream:r.stream,muted:!1,className:"h-full w-full object-cover"}):(0,X.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-3 text-white/70",children:[(0,X.jsx)("img",{src:(null===(a=r.peer)||void 0===a?void 0:a.picture)||"/haitipal-logo.png",alt:"",className:"h-16 w-16 rounded-full object-cover ring-2 ring-white/20"}),(0,X.jsxs)("span",{className:"flex items-center gap-2 text-sm",children:[(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"})," Ap tann ",null===(n=r.peer)||void 0===n?void 0:n.name,"\u2026"]})]}),(0,X.jsx)("div",{className:"absolute bottom-2 right-2 h-20 w-28 overflow-hidden rounded-lg ring-2 ring-white/30",children:(0,X.jsx)(un,{stream:l,muted:!0,className:"h-full w-full scale-x-[-1] object-cover"})})]}),(0,X.jsx)("div",{className:"flex items-center justify-center bg-[#131320] [html.light_&]:bg-[#e9edf4] py-2.5",children:(0,X.jsx)("button",{"data-testid":"end-call-btn",onClick:d,className:"flex h-11 w-11 items-center justify-center rounded-full bg-red-500 text-white transition-transform hover:scale-110",children:(0,X.jsx)(dn.A,{className:"h-5 w-5"})})})]})}var hn=a(5919),xn=a(3735),pn=a(8969),fn=a(1523),gn=a(7090),vn=a(7178);function bn(e){let t=e.stream,a=e.muted,n=e.mirror,s=e.className;const r=(0,i.useRef)(null);return(0,i.useEffect)(()=>{const e=r.current;if(e&&(e.srcObject!==t&&(e.srcObject=t||null),t)){var a;const t=null===(a=e.play)||void 0===a?void 0:a.call(e);t&&t.catch&&t.catch(()=>{})}},[t]),(0,X.jsx)("video",{ref:r,autoPlay:!0,playsInline:!0,muted:a,className:"".concat(s," ").concat(n?"scale-x-[-1]":"")})}function wn(e){let t=e.name,a=e.picture,n=e.stream,s=e.self,i=e.muted,r=e.mirror,l=e.badge,o=e.onClick,c=e.active,d=e.speaking;return(0,X.jsxs)("div",{onClick:o,"data-testid":"gcall-tile-".concat(s?"self":t),"data-speaking":d?"1":"0",className:"relative min-h-0 overflow-hidden rounded-xl bg-[#05050A] ring-2 transition-shadow ".concat(d?"ring-green-400 shadow-[0_0_0_2px_rgba(74,222,128,0.5)]":c?"ring-[#00F0FF]":"ring-white/10"," ").concat(o?"cursor-pointer hover:ring-[#00F0FF]/60":""),children:[n?(0,X.jsx)(bn,{stream:n,muted:i,mirror:r,className:"h-full w-full object-cover"}):(0,X.jsxs)("div",{className:"flex h-full w-full flex-col items-center justify-center gap-1.5 bg-gradient-to-b from-[#12121a] to-[#05050A] text-white/70",children:[(0,X.jsx)("img",{src:a||"/haitipal-logo.png",alt:"",className:"h-1/2 max-h-16 min-h-8 w-auto aspect-square rounded-full object-cover ring-2 ring-white/20"}),l?(0,X.jsxs)("span",{className:"flex items-center gap-1 px-1 text-center text-[10px] font-semibold leading-tight",children:[(0,X.jsx)(ve.A,{className:"h-3 w-3 shrink-0 animate-spin"})," ",l]}):null]}),(0,X.jsx)("div",{className:"absolute bottom-0 left-0 right-0 flex items-center gap-1 bg-gradient-to-t from-black/70 to-transparent px-1.5 py-1",children:(0,X.jsx)("span",{className:"truncate text-[10px] font-bold text-white",children:s?"Ou menm":t||"Moun"})})]})}function jn(e){let t=e.gcall,a=e.participants,r=void 0===a?{}:a,l=e.ringing,o=void 0===l?{}:l,c=e.localStream,d=e.selfInfo,u=e.onAccept,m=e.onDecline,h=e.onAdd,x=e.onLeave,p=e.members,f=void 0===p?[]:p,g=e.maxOthers,v=void 0===g?6:g,b=e.onShareScreen,w=e.screenOn,j=void 0!==w&&w,y=e.screenStream,k=void 0===y?null:y;const N=(0,i.useState)(!0),A=(0,s.A)(N,2),F=A[0],C=A[1],S=(0,i.useState)(!0),R=(0,s.A)(S,2),E=R[0],T=R[1],P=(0,i.useState)(!1),D=(0,s.A)(P,2),I=D[0],L=D[1],z=(0,i.useState)(""),V=(0,s.A)(z,2),O=V[0],K=V[1],H=(0,i.useState)("mini"),W=(0,s.A)(H,2),J=W[0],Y=W[1],Z=(0,i.useState)(!0),Q=(0,s.A)(Z,2),$=Q[0],ee=Q[1],te=(0,i.useState)(null),ae=(0,s.A)(te,2),ne=ae[0],se=ae[1],ie=(0,i.useState)(null),re=(0,s.A)(ie,2),le=re[0],oe=re[1],ce=(0,i.useRef)(null),ue=(null===t||void 0===t?void 0:t.status)||"idle";(0,i.useEffect)(()=>
1{if("ringing-in"===ue){return(0,de.hy)(!1)}},[ue]),(0,i.useEffect)(()=>{"idle"===ue&&(C(!0),T(!0),L(!1),ee(!0),Y("mini"),oe(null),se(null))},[ue]);const me=(0,i.useCallback)(e=>{const t=e.clientX,a=e.clientY,n=ce.current;if(!n)return;const s=n.getBoundingClientRect(),i=t-s.left,r=a-s.top,l=e=>{const t=Math.max(6,Math.min(window.innerWidth-s.width-6,e.clientX-i)),a=Math.max(6,Math.min(window.innerHeight-60,e.clientY-r));oe({x:t,y:a})},o=()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",o)};window.addEventListener("pointermove",l),window.addEventListener("pointerup",o)},[]),he=Object.entries(r).map(e=>{let t=(0,s.A)(e,2),a=t[0],i=t[1];return(0,n.A)({uid:a},i)}),xe=Object.entries(o).map(e=>{let t=(0,s.A)(e,2);return{uid:t[0],info:t[1]}}),pe=he.length+xe.length>=v,fe=(0,i.useMemo)(()=>[{key:"self",self:!0,name:null===d||void 0===d?void 0:d.name,picture:null===d||void 0===d?void 0:d.picture,stream:j?k:E?c:null,muted:!0,mirror:!j},...he.map(e=>{var t,a;return{key:e.uid,name:null===(t=e.info)||void 0===t?void 0:t.name,picture:null===(a=e.info)||void 0===a?void 0:a.picture,stream:e.stream,muted:!1}}),...xe.map(e=>{var t,a,n;return{key:e.uid,name:null===(t=e.info)||void 0===t?void 0:t.name,picture:null===(a=e.info)||void 0===a?void 0:a.picture,stream:null,badge:"Ap rele ".concat((null===(n=e.info)||void 0===n?void 0:n.name)||"","\u2026")}})],[r,o,E,c,d,j,k]),ve=function(e){const t=(0,i.useState)({}),a=(0,s.A)(t,2),n=a[0],r=a[1],l=(0,i.useRef)(e);l.current=e;const o=(0,i.useRef)({});return(0,i.useEffect)(()=>{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;const t=new e,a=setInterval(()=>{try{"suspended"===t.state&&t.resume()}catch(n){}const e=new Set;(l.current||[]).forEach(a=>{var n;let s=a.key,i=a.stream;const r=null===i||void 0===i||null===(n=i.getAudioTracks)||void 0===n?void 0:n.call(i);if(r&&r.length&&r[0].enabled&&(e.add(s),!o.current[s]))try{const e=t.createMediaStreamSource(new MediaStream([r[0]])),a=t.createAnalyser();a.fftSize=512,e.connect(a),o.current[s]={analyser:a,data:new Uint8Array(a.fftSize),source:e}}catch(l){}}),Object.keys(o.current).forEach(t=>{if(!e.has(t)){try{o.current[t].source.disconnect()}catch(a){}delete o.current[t]}});const a={};Object.entries(o.current).forEach(e=>{let t=(0,s.A)(e,2),n=t[0],i=t[1];i.analyser.getByteTimeDomainData(i.data);let r=0;for(let a=0;a<i.data.length;a++){const e=(i.data[a]-128)/128;r+=e*e}Math.sqrt(r/i.data.length)>.045&&(a[n]=!0)}),r(a)},200);return()=>{clearInterval(a),Object.values(o.current).forEach(e=>{try{e.source.disconnect()}catch(t){}}),o.current={};try{t.close()}catch(e){}}},[]),n}((0,i.useMemo)(()=>[{key:"self",stream:c},...he.map(e=>({key:e.uid,stream:e.stream}))],[c,r])),be=(0,i.useMemo)(()=>fe.find(e=>e.key===ne)||fe.find(e=>!e.self)||fe[0],[fe,ne]),we=(0,i.useMemo)(()=>{const e=new Set([...Object.keys(r),...Object.keys(o)]),t=O.trim().toLowerCase();return(f||[]).filter(t=>t&&t.user_id&&!t.is_guest&&!e.has(t.user_id)&&t.user_id!==(null===d||void 0===d?void 0:d.user_id)).filter(e=>!t||(e.name||"").toLowerCase().includes(t)).slice(0,60)},[f,r,o,O,d]);if("idle"===ue)return null;if("ringing-in"===ue){var ye,ke,Ne;const e=t.incoming||{},a=((null===(ye=e.members)||void 0===ye?void 0:ye.length)||0)+1;return(0,X.jsx)("div",{className:"fixed inset-0 z-[90] flex items-center justify-center bg-black/70 backdrop-blur-sm","data-testid":"gcall-incoming-modal",children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl glass p-8 text-center",children:[(0,X.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-[#FF2A5F]/20 ring-4 ring-[#FF2A5F]/40 animate-pulse",children:(0,X.jsx)("img",{src:(null===(ke=e.from)||void 0===ke?void 0:ke.picture)||"/haitipal-logo.png",alt:"",className:"h-16 w-16 rounded-full object-cover"})}),(0,X.jsxs)("p",{className:"mt-5 flex items-center justify-center gap-2 text-sm font-semibold uppercase tracking-widest text-[#00F0FF]",children:[(0,X.jsx)(Oe.A,{className:"h-4 w-4 animate-bounce"})," Ap\xe8l an gwoup"]}),(0,X.jsx)("h2",{className:"mt-1 font-display text-2xl font-extrabold text-white","data-testid":"gcall-incoming-name",children:(null===(Ne=e.from)||void 0===Ne?void 0:Ne.name)||"Yon moun"}),(0,X.jsxs)("p",{className:"mt-2 flex items-center justify-center gap-1.5 text-sm text-gray-300",children:[(0,X.jsx)(M.A,{className:"h-4 w-4"})," ",a," moun nan ap\xe8l la"]}),(0,X.jsxs)("div",{className:"mt-8 flex items-center justify-center gap-6",children:[(0,X.jsxs)("button",{"data-testid":"gcall-decline-btn",onClick:m,className:"flex flex-col items-center gap-1.5",children:[(0,X.jsx)("span",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-red-500 text-white shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(dn.A,{className:"h-7 w-7"})}),(0,X.jsx)("span",{className:"text-xs font-semibold text-gray-300",children:"Refize"})]}),(0,X.jsxs)("button",{"data-testid":"gcall-accept-btn",onClick:u,className:"flex flex-col items-center gap-1.5",children:[(0,X.jsx)("span",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-green-500 text-white shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(je.A,{className:"h-7 w-7"})}),(0,X.jsx)("span",{className:"text-xs font-semibold text-gray-300",children:"Aksepte"})]})]})]})})}const Ae=fe.length,Fe="large"===J?"w-[92vw] max-w-[560px]":"w-[208px] sm:w-[224px]",_e="large"===J?"grid-cols-3":"grid-cols-2",Se="large"===J?"h-28":"h-16",Re=le?{left:le.x,top:le.y}:{left:12,bottom:12};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)("div",{ref:ce,style:Re,"data-testid":"gcall-window",className:"fixed z-[70] ".concat(Fe," overflow-hidden rounded-2xl border border-[#00F0FF]/30 bg-[#0b0b12]/95 shadow-2xl backdrop-blur-md"),children:[(0,X.jsxs)("div",{onPointerDown:me,className:"flex cursor-grab touch-none items-center justify-between border-b border-white/10 bg-black/50 px-2.5 py-1.5 active:cursor-grabbing",children:[(0,X.jsxs)("span",{className:"flex items-center gap-1.5 text-[11px] font-black uppercase tracking-wide text-[#00F0FF]",children:[(0,X.jsx)(it.A,{className:"h-3.5 w-3.5 text-white/40"})," Ap\xe8l gwoup",(0,X.jsxs)("span",{className:"rounded-full bg-white/10 px-1.5 py-0.5 text-[10px] font-bold text-white","data-testid":"gcall-count",children:[Ae,"/",v+1]})]}),(0,X.jsxs)("div",{className:"flex items-center gap-1",children:[(0,X.jsx)("button",{"data-testid":"gcall-swap-btn",onClick:()=>ee(e=>!e),title:"Chanje/Swap",className:"flex h-6 w-6 items-center justify-center rounded-md ".concat($?"bg-[#00F0FF] text-black":"text-white hover:bg-white/10"),children:$?(0,X.jsx)(hn.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(xn.A,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("button",{"data-testid":"gcall-size-btn",onClick:()=>Y(e=>"mini"===e?"large":"mini"),title:"mini"===J?"F\xe8 l pi gwo":"F\xe8 l pi piti",className:"flex h-6 w-6 items-center justify-center rounded-md text-white hover:bg-white/10",children:"mini"===J?(0,X.jsx)(pn.A,{className:"h-3.5 w-3.5"}):(0,X.jsx)(fn.A,{className:"h-3.5 w-3.5"})}),(0,X.jsx)("button",{"data-testid":"gcall-leave-top",onClick:x,title:"Kite ap\xe8l la",className:"flex h-6 w-6 items-center justify-center rounded-md bg-red-500 text-white hover:bg-red-600",children:(0,X.jsx)(dn.A,{className:"h-3.5 w-3.5"})})]})]}),(0,X.jsx)("div",{className:"p-2",children:$?(0,X.jsxs)("div",{children:[(0,X.jsxs)("div",{className:"relative ".concat("large"===J?"h-64":"h-40"," overflow-hidden rounded-xl"),children:[(0,X.jsx)(wn,{self:null===be||void 0===be?void 0:be.self,name:null===be||void 0===be?void 0:be.name,picture:null===be||void 0===be?void 0:be.picture,stream
1:null===be||void 0===be?void 0:be.stream,muted:null===be||void 0===be?void 0:be.muted,mirror:null===be||void 0===be?void 0:be.mirror,badge:null===be||void 0===be?void 0:be.badge,speaking:ve[null===be||void 0===be?void 0:be.key]}),Ae>1&&(0,X.jsx)("button",{"data-testid":"gcall-swap-next",onClick:()=>{const e=fe.findIndex(e=>e.key===(null===be||void 0===be?void 0:be.key)),t=fe[(e+1)%fe.length];se(null===t||void 0===t?void 0:t.key)},title:"Pwochen kamera",className:"absolute right-2 top-1/2 -translate-y-1/2 flex h-9 w-9 items-center justify-center rounded-full bg-black/60 text-white ring-1 ring-white/20 hover:bg-black/80",children:(0,X.jsx)(xn.A,{className:"h-4 w-4"})})]}),(0,X.jsx)("div",{className:"mt-2 flex gap-1.5 overflow-x-auto",children:fe.filter(e=>e.key!==(null===be||void 0===be?void 0:be.key)).map(e=>(0,X.jsx)("div",{className:"h-12 w-12 shrink-0",children:(0,X.jsx)(wn,{self:e.self,name:e.name,picture:e.picture,stream:e.stream,muted:e.muted,mirror:e.mirror,badge:null,onClick:()=>se(e.key),speaking:ve[e.key]})},e.key))})]}):(0,X.jsx)("div",{className:"grid ".concat(_e," gap-1.5"),children:fe.map(e=>(0,X.jsx)("div",{className:Se,children:(0,X.jsx)(wn,{self:e.self,name:e.name,picture:e.picture,stream:e.stream,muted:e.muted,mirror:e.mirror,badge:e.badge,speaking:ve[e.key]})},e.key))})}),(0,X.jsxs)("div",{className:"flex items-center justify-center gap-2 border-t border-white/10 bg-black/40 py-2",children:[(0,X.jsx)("button",{"data-testid":"gcall-toggle-mic",onClick:()=>{const e=c;if(!e)return;const t=!F;C(t),e.getAudioTracks().forEach(e=>{e.enabled=t})},title:F?"F\xe8men mikwo":"Louvri mikwo",className:"flex h-9 w-9 items-center justify-center rounded-full transition-transform hover:scale-110 ".concat(F?"bg-white/10 text-white":"bg-red-500 text-white"),children:F?(0,X.jsx)(_.A,{className:"h-4 w-4"}):(0,X.jsx)(q.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{"data-testid":"gcall-toggle-cam",onClick:()=>{const e=c;if(!e)return;const t=!E;T(t),e.getVideoTracks().forEach(e=>{e.enabled=t})},title:E?"F\xe8men kamera":"Louvri kamera",className:"flex h-9 w-9 items-center justify-center rounded-full transition-transform hover:scale-110 ".concat(E?"bg-white/10 text-white":"bg-red-500 text-white"),children:E?(0,X.jsx)(B.A,{className:"h-4 w-4"}):(0,X.jsx)(U.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{"data-testid":"gcall-screen-btn",onClick:b,title:j?"Sispann pataje ekran":"Pataje ekran",className:"flex h-9 w-9 items-center justify-center rounded-full transition-transform hover:scale-110 ".concat(j?"bg-[#00F0FF] text-black":"bg-white/10 text-white"),children:j?(0,X.jsx)(gn.A,{className:"h-4 w-4"}):(0,X.jsx)(vn.A,{className:"h-4 w-4"})}),(0,X.jsxs)("button",{"data-testid":"gcall-add-btn",onClick:()=>L(!0),disabled:pe,title:pe?"Ap\xe8l la plen":"Ajoute yon moun",className:"flex h-9 items-center gap-1.5 rounded-full bg-[#00A8CC] px-4 text-xs font-bold text-white transition-transform hover:scale-105 disabled:opacity-40",children:[(0,X.jsx)(G.A,{className:"h-4 w-4"})," Ajoute"]}),(0,X.jsx)("button",{"data-testid":"gcall-leave-btn",onClick:x,title:"Kite ap\xe8l la",className:"flex h-9 w-9 items-center justify-center rounded-full bg-red-500 text-white transition-transform hover:scale-110",children:(0,X.jsx)(dn.A,{className:"h-4 w-4"})})]})]}),I&&(0,X.jsx)("div",{className:"fixed inset-0 z-[91] flex items-end justify-center bg-black/60 p-4 backdrop-blur-sm sm:items-center",onClick:()=>L(!1),children:(0,X.jsxs)("div",{className:"w-full max-w-md overflow-hidden rounded-3xl border border-white/10 bg-[#0e0e16] [html.light_&]:bg-[#e9edf4]",onClick:e=>e.stopPropagation(),"data-testid":"gcall-add-picker",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between border-b border-white/10 px-5 py-4",children:[(0,X.jsxs)("h2",{className:"flex items-center gap-2 font-display text-lg font-extrabold text-white",children:[(0,X.jsx)(G.A,{className:"h-5 w-5 text-[#00F0FF]"})," Ajoute nan ap\xe8l la"]}),(0,X.jsx)("button",{"data-testid":"gcall-picker-close",onClick:()=>L(!1),className:"text-gray-400 hover:text-white",children:(0,X.jsx)(ge.A,{className:"h-5 w-5"})})]}),(0,X.jsxs)("div",{className:"p-3",children:[(0,X.jsxs)("div",{className:"mb-2 flex items-center gap-2 rounded-xl bg-white/5 px-3 py-2 [html.light_&]:bg-black/5",children:[(0,X.jsx)(Le.A,{className:"h-4 w-4 text-gray-400"}),(0,X.jsx)("input",{"data-testid":"gcall-picker-search",value:O,onChange:e=>K(e.target.value),placeholder:"Ch\xe8che yon moun\u2026",className:"w-full bg-transparent text-sm text-white outline-none placeholder:text-gray-500 [html.light_&]:text-[#14162b]"})]}),(0,X.jsx)("div",{className:"max-h-[50vh] overflow-y-auto",children:0===we.length?(0,X.jsx)("p",{className:"py-8 text-center text-sm text-gray-500","data-testid":"gcall-picker-empty",children:"Pa gen l\xf2t moun disponib pou ajoute."}):we.map(e=>(0,X.jsxs)("button",{"data-testid":"gcall-add-user-".concat(e.user_id),onClick:()=>{h(e),L(!1)},className:"flex w-full items-center gap-3 rounded-2xl p-2.5 text-left transition-colors hover:bg-white/5 [html.light_&]:hover:bg-black/5",children:[(0,X.jsxs)("div",{className:"relative shrink-0",children:[(0,X.jsx)("img",{src:e.picture||"/haitipal-logo.png",alt:"",className:"h-10 w-10 rounded-full object-cover ring-2 ring-white/10"}),e.online&&(0,X.jsx)(Ce.A,{className:"absolute -bottom-0.5 -right-0.5 h-3 w-3 fill-green-500 text-green-500"})]}),(0,X.jsxs)("span",{className:"min-w-0 flex-1 truncate text-sm font-bold text-white [html.light_&]:text-[#14162b]",children:[e.name,e.online?"":(0,X.jsx)("span",{className:"ml-1 text-[10px] font-normal text-gray-500",children:"(pa anliy)"})]}),(0,X.jsx)("span",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-[#00A8CC] text-white",children:(0,X.jsx)(je.A,{className:"h-4 w-4"})})]},e.user_id))})]})]})})]})}const yn="https://haitipal.com";function kn(){const e=(0,i.useState)(!1),t=(0,s.A)(e,2),a=t[0],n=t[1],r=(0,i.useState)(!1),l=(0,s.A)(r,2),o=l[0],m=l[1],h=(0,i.useRef)(null),x=(0,c.A)().refreshUser,p=(0,(0,vt.u)().t)("share.text"),f=async()=>{try{const e=(await d.Ay.post("/share/claim")).data;e.awarded>0&&(u.oR.success("\ud83c\udf81 Ou genyen ".concat(e.awarded," pwen paske w pataje!"),{duration:4e3}),null===x||void 0===x||x())}catch(e){}};(0,i.useEffect)(()=>{const e=e=>{h.current&&!h.current.contains(e.target)&&n(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const g=e=>{window.open(e,"_blank","noopener,noreferrer"),f(),n(!1)},v="https://www.facebook.com/sharer/sharer.php?u=".concat(encodeURIComponent(yn)),b="https://wa.me/?text=".concat(encodeURIComponent("".concat(p," ").concat(yn))
1);return(0,X.jsxs)("div",{className:"relative",ref:h,children:[(0,X.jsx)("button",{onClick:async()=>{await(async()=>{if(navigator.share)try{return await navigator.share({title:"HAITIPAL CHAT - TV",text:p,url:yn}),f(),!0}catch(e){return!0}return!1})()||n(e=>!e)},"data-testid":"share-btn",className:"flex h-9 w-9 items-center justify-center rounded-full bg-[#00F0FF] text-black transition-transform hover:scale-105 active:scale-95",title:"Pataje",children:(0,X.jsx)(Ua.A,{className:"h-4 w-4"})}),a&&(0,X.jsxs)("div",{"data-testid":"share-menu",className:"absolute right-0 z-50 mt-2 w-52 overflow-hidden rounded-2xl border border-white/10 bg-[#12121a] p-1.5 shadow-xl",children:[(0,X.jsxs)("button",{"data-testid":"share-facebook",onClick:()=>g(v),className:"flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-white hover:bg-white/10",children:[(0,X.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[#1877F2] text-xs font-black text-white",children:"f"})," Facebook"]}),(0,X.jsxs)("button",{"data-testid":"share-whatsapp",onClick:()=>g(b),className:"flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-white hover:bg-white/10",children:[(0,X.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-[#25D366] text-white",children:(0,X.jsx)(Me.A,{className:"h-4 w-4"})})," WhatsApp"]}),(0,X.jsxs)("button",{"data-testid":"share-copy",onClick:async()=>{try{await navigator.clipboard.writeText(yn),m(!0),u.oR.success("Lyen an kopye!"),f(),setTimeout(()=>m(!1),1800)}catch(e){u.oR.error("Nou pa ka kopye lyen an")}n(!1)},className:"flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-left text-sm text-white hover:bg-white/10",children:[(0,X.jsx)("span",{className:"flex h-7 w-7 items-center justify-center rounded-full bg-white/10 text-white",children:o?(0,X.jsx)(W.A,{className:"h-4 w-4 text-green-400"}):(0,X.jsx)(en.A,{className:"h-4 w-4"})})," Kopye lyen"]})]})]})}var Nn=a(2672),An=a(5830),Fn=a(5610),_n=a(3829),Cn=a(8864);function Sn(e){let t=e.open,a=e.onClose,n=e.rs;if(!t)return null;const s=n.mixActive;return(0,X.jsxs)("div",{"data-testid":"live-mixer-panel",className:"fixed inset-x-0 bottom-0 z-[115] mx-auto w-full max-w-md rounded-t-3xl border border-white/10 bg-[#0B0B12]/95 p-4 shadow-2xl backdrop-blur-xl sm:bottom-6 sm:rounded-3xl",children:[(0,X.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,X.jsxs)("h3",{className:"flex items-center gap-2 font-display text-lg font-black text-white",children:[(0,X.jsx)(Za.A,{className:"h-5 w-5 text-[#00F0FF]"})," Mikser Live"]}),(0,X.jsx)("button",{"data-testid":"live-mixer-close",onClick:a,className:"flex h-8 w-8 items-center justify-center rounded-full bg-white/10 text-white hover:bg-white/20",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsxs)("button",{"data-testid":"live-mixer-toggle-cam",onClick:()=>s?n.stopMix():n.startMix(),className:"mb-3 flex w-full items-center justify-center gap-2 rounded-xl px-4 py-3 text-sm font-bold transition-colors ".concat(s?"bg-[#00F0FF] text-black glow-cyan":"bg-white/10 text-white hover:bg-white/20"),children:[(0,X.jsx)(B.A,{className:"h-4 w-4"})," ",s?"Kanpe melanj kamera":"Melanje kamera w ak videyo a"]}),(0,X.jsxs)("div",{className:"space-y-3 transition-opacity ".concat(s?"opacity-100":"pointer-events-none opacity-40"),children:[(0,X.jsxs)("div",{children:[(0,X.jsx)("p",{className:"mb-1.5 text-[11px] font-bold uppercase tracking-wide text-gray-400",children:"F\xf2m ekran"}),(0,X.jsxs)("div",{className:"flex gap-2",children:[(0,X.jsxs)("button",{"data-testid":"live-mixer-layout-split",onClick:()=>n.setMixLayout("split"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-xl px-3 py-2.5 text-xs font-bold transition-colors ".concat("split"===n.mixLayout?"bg-[#FF2A5F] text-white":"bg-white/10 text-white hover:bg-white/20"),children:[(0,X.jsx)(An.A,{className:"h-4 w-4"})," Divize 50/50"]}),(0,X.jsxs)("button",{"data-testid":"live-mixer-layout-pip",onClick:()=>n.setMixLayout("pip"),className:"flex flex-1 items-center justify-center gap-1.5 rounded-xl px-3 py-2.5 text-xs font-bold transition-colors ".concat("pip"===n.mixLayout?"bg-[#FF2A5F] text-white":"bg-white/10 text-white hover:bg-white/20"),children:[(0,X.jsx)(Fn.A,{className:"h-4 w-4"})," PiP"]})]})]}),(0,X.jsxs)("button",{"data-testid":"live-mixer-swap",onClick:n.toggleMixSwap,className:"flex w-full items-center justify-center gap-2 rounded-xl bg-white/10 px-4 py-2.5 text-xs font-bold text-white transition-colors hover:bg-white/20",children:[(0,X.jsx)(_n.A,{className:"h-4 w-4"})," Chanje l\xf2d (","pip"===n.mixLayout?"gwo/ti":"anl\xe8/anba",")"]}),(0,X.jsxs)("div",{className:"flex gap-2",children:[(0,X.jsxs)("button",{"data-testid":"live-mixer-mirror-cam",onClick:n.toggleMirrorCam,className:"flex flex-1 items-center justify-center gap-1.5 rounded-xl px-3 py-2.5 text-xs font-bold transition-colors ".concat(n.mirrorCam?"bg-[#7C3AED] text-white":"bg-white/10 text-white hover:bg-white/20"),children:[(0,X.jsx)(Cn.A,{className:"h-4 w-4"})," Mirror kamera"]}),(0,X.jsxs)("button",{"data-testid":"live-mixer-mirror-vid",onClick:n.toggleMirrorVid,className:"flex flex-1 items-center justify-center gap-1.5 rounded-xl px-3 py-2.5 text-xs font-bold transition-colors ".concat(n.mirrorVid?"bg-[#7C3AED] text-white":"bg-white/10 text-white hover:bg-white/20"),children:[(0,X.jsx)(Cn.A,{className:"h-4 w-4"})," Mirror videyo"]})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("p",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wide text-gray-400",children:[(0,X.jsx)(Za.A,{className:"h-3.5 w-3.5"})," Volim videyo ",(0,X.jsxs)("span",{className:"ml-auto font-mono text-[#00F0FF]",children:[Math.round(100*n.videoVolume),"%"]})]}),(0,X.jsx)("input",{"data-testid":"live-mixer-video-volume",type:"range",min:"0",max:"1",step:"0.01",value:n.videoVolume,onChange:e=>n.setVideoVolume(parseFloat(e.target.value)),className:"h-2 w-full cursor-pointer appearance-none rounded-full bg-white/15 accent-[#00F0FF]"})]}),(0,X.jsxs)("div",{children:[(0,X.jsxs)("p",{className:"mb-1 flex items-center gap-1.5 text-[11px] font-bold uppercase tracking-wide text-gray-400",children:[(0,X.jsx)(_.A,{className:"h-3.5 w-3.5"})," Volim mikwo ",(0,X.jsxs)("span",{className:"ml-auto font-mono text-[#FF2A5F]",children:[Math.round(100*n.micVolume),"%"]})]}),(0,X.jsx)("input",{"data-testid":"live-mixer-mic-volume",type:"range",min:"0",max:"1",step:"0.01",value:n.micVolume,onChange:e=>n.setMicVolume(parseFloat(e.target.value)),className:"h-2 w-full cursor-pointer appearance-none rounded-full bg-white/15 accent-[#FF2A5F]"})]})]}),!s&&(0,X.jsxs)("p",{className:"mt-3 flex items-center gap-1.5 text-center text-[11px] text-gray-500",children:[(0,X.jsx)(D.A,{className:"h-3.5 w-3.5 shrink-0"}
1)," Melanje kamera w pou w kontwole f\xf2m, mirror ak volim yo."]})]})}var Rn=a(9829),En=a(3572),Tn=a(3769),Mn=a(2368),Pn=a(6797),Dn=a(7365),In=a(3329),Ln=a(9233),zn=a(7104);function Vn(e){let t=e.competition;const a=(0,i.useRef)(null),n=(0,i.useState)(!1),r=(0,s.A)(n,2),l=r[0],o=r[1],c=(null===t||void 0===t?void 0:t.music_urls)||[],d=(null===t||void 0===t?void 0:t.music_state)||{playing:!0,track_idx:0,volume:.55,muted:!1},u=c.length?Number(d.track_idx||0)%c.length:0,m="number"===typeof d.volume?d.volume:.55,h=!0===d.muted,x=!1!==d.playing;if((0,i.useEffect)(()=>{const e=a.current;e&&(e.volume=m,e.muted=h)},[m,h,u]),(0,i.useEffect)(()=>{const e=a.current;e&&(x&&c.length?e.play().then(()=>o(!1)).catch(()=>o(!0)):e.pause())},[x,u,c.length]),!c.length)return null;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("audio",{ref:a,src:(p=c[u],p&&p.startsWith("/api/files/")?"".concat("https://haitipal.com").concat(p):p),preload:"auto","data-testid":"lobby-comp-music"}),l&&(0,X.jsxs)("button",{"data-testid":"lobby-comp-music-enable",onClick:()=>{const e=a.current;e&&e.play().then(()=>o(!1)).catch(()=>{})},className:"mb-2 flex shrink-0 items-center justify-center gap-2 self-center rounded-full bg-[#FF2A5F] px-4 py-1.5 text-xs font-bold text-white animate-pulse",children:[(0,X.jsx)(Rn.A,{className:"h-4 w-4"})," Tape pou tande mizik la"]})]});var p}function On(){try{const e=window.AudioContext||window.webkitAudioContext;if(!e)return;const t=new e,a=t.currentTime;[880,1174.7].forEach((e,n)=>{const s=t.createOscillator(),i=t.createGain();s.type="sine",s.frequency.value=e,s.connect(i),i.connect(t.destination);const r=a+.18*n;i.gain.setValueAtTime(1e-4,r),i.gain.exponentialRampToValueAtTime(.25,r+.02),i.gain.exponentialRampToValueAtTime(1e-4,r+.5),s.start(r),s.stop(r+.55)}),setTimeout(()=>{try{t.close()}catch(e){}},1600)}catch(e){}}function qn(e){var t,a,m,g;let v=e.room;const b=(0,c.A)(),w=b.user,j=b.setUser,y=b.refreshUser,k=b.logout,N=b.siteConfig,S=(0,r.Zp)(),E=(0,i.useRef)(null===w||void 0===w?void 0:w.user_id);(0,i.useEffect)(()=>{E.current=null===w||void 0===w?void 0:w.user_id},[null===w||void 0===w?void 0:w.user_id]);const T=(0,l.e)(),I=T.openOverlay,z=T.overlay,K=T.dmRequest,H=T.clearDmRequest,G=T.ppvRequest,J=T.clearPpvRequest,Y=T.openLive,Z=((0,vt.u)().t,"lobby"!==v),ee=v.startsWith("LIVE_"),te=!(null===w||void 0===w||!w.is_guest),se="admin"===(null===w||void 0===w?void 0:w.role)||"moderator"===(null===w||void 0===w?void 0:w.role)||!(null===w||void 0===w||!w.is_admin),ie=(0,i.useState)([]),re=(0,s.A)(ie,2),le=re[0],me=re[1],he=(0,i.useState)([]),xe=(0,s.A)(he,2),pe=xe[0],we=xe[1],je=(0,i.useState)([]),ye=(0,s.A)(je,2),ke=ye[0],Ne=ye[1],Ae=(0,i.useState)([]),Fe=(0,s.A)(Ae,2),Ce=Fe[0],Re=Fe[1],Ee=(0,i.useState)({used:0,limit:5}),Me=(0,s.A)(Ee,2),Pe=Me[0],De=Me[1],Ie=(0,i.useState)(!1),Le=(0,s.A)(Ie,2),ze=Le[0],Ve=Le[1],Oe=(0,i.useState)(!1),qe=(0,s.A)(Oe,2),Be=qe[0],Ue=qe[1],Ke=(0,i.useState)(null),Ge=(0,s.A)(Ke,2),Je=Ge[0],Ye=Ge[1];(0,i.useEffect)(()=>{if(!te)return;const e=setTimeout(()=>{(0,u.oR)("\ud83d\udc4b Byenveni nan lakou a!",{description:"Ou antre k\xf2m Vizit\xe8 (Pal). Ou ka gade dir\xe8k la epi chat lib. Kreye yon kont gratis pou voye kado, monte nivo epi f\xe8 lajan \ud83c\udf81",duration:9e3})},1500),t=setInterval(()=>Ve(!0),12e4);return()=>{clearTimeout(e),clearInterval(t)}},[te]),(0,i.useEffect)(()=>{var e,t;let a;try{a=sessionStorage.getItem("hp_welcome_bonus"),a&&sessionStorage.removeItem("hp_welcome_bonus")}catch(s){}if(!a)return;if(Ue(!0),null!==(e=(t=window).matchMedia)&&void 0!==e&&e.call(t,"(prefers-reduced-motion: reduce)").matches)return;const n=["#FFD700","#FF2A5F","#00F0FF","#39FF14"];(0,o.A)({particleCount:160,spread:100,startVelocity:50,origin:{y:.6},colors:n}),setTimeout(()=>(0,o.A)({particleCount:100,angle:60,spread:80,origin:{x:0,y:.7},colors:n}),200),setTimeout(()=>(0,o.A)({particleCount:100,angle:120,spread:80,origin:{x:1,y:.7},colors:n}),200),setTimeout(()=>(0,o.A)({particleCount:120,spread:120,startVelocity:45,origin:{y:.4},colors:n}),550)},[]);const Ze=(0,i.useCallback)(e=>{Ye(null),e&&d.Ay.post("/payouts/congrats/ack",{id:e}).catch(()=>{})},[]);(0,i.useEffect)(()=>{te||d.Ay.get("/payouts/congrats").then(e=>{var t;const a=null===(t=e.data)||void 0===t?void 0:t.payout;a&&Ye({id:a.id,amount_usd:a.amount_usd,note:a.admin_note})}).catch(()=>{})},[te]);const Qe=(0,i.useCallback)(async()=>{try{await k()}catch(e){}S("/login?register=1")},[k,S]),$e=(0,i.useState)(!1),et=(0,s.A)($e,2),tt=et[0],at=et[1],nt=(0,i.useState)(!1),st=(0,s.A)(nt,2),it=st[0],rt=st[1],lt=(0,i.useState)(""),ot=(0,s.A)(lt,2),ct=ot[0],dt=ot[1],ut=(0,i.useState)(""),mt=(0,s.A)(ut,2),ht=mt[0],xt=mt[1],pt=(0,i.useState)(!1),ft=(0,s.A)(pt,2),gt=ft[0],bt=ft[1],wt=(0,i.useState)(!1),jt=(0,s.A)(wt,2),yt=jt[0],kt=jt[1],Nt=(0,i.useRef)(null),At=(0,i.useState)(null),Ft=(0,s.A)(At,2),_t=Ft[0],Ct=Ft[1],St=(0,i.useState)(null),Rt=(0,s.A)(St,2),Et=Rt[0],Tt=Rt[1],Mt=(0,i.useState)(!1),Pt=(0,s.A)(Mt,2),Dt=Pt[0],It=Pt[1],Lt=(0,i.useState)(!1),zt=(0,s.A)(Lt,2),Vt=zt[0],Ot=zt[1],qt=(0,i.useState)(!1),Bt=(0,s.A)(qt,2),Ut=Bt[0],Wt=Bt[1],Gt=(0,i.useState)(!1),Jt=(0,s.A)(Gt,2),Yt=Jt[0],ea=Jt[1],ta=(0,i.useState)(!1),na=(0,s.A)(ta,2),sa=na[0],la=na[1],ca=(0,i.useRef)(null),da=(0,i.useState)(!1),ua=(0,s.A)(da,2),ha=ua[0],xa=ua[1],pa=(0,i.useState)(null),fa=(0,s.A)(pa,2),ga=fa[0],va=fa[1],ba=(0,i.useRef)({list:[],index:-1}),ya=(0,i.useRef)(null),_a=(0,i.useCallback)(e=>
1{const t=ba.current,a=t.list,n=t.index;if(a.length<2||n<0)return;const s=(n+e+a.length)%a.length;va(a[s].info.user_id)},[]);(0,i.useEffect)(()=>{if(!ga)return;const e=e=>{"Escape"===e.key?va(null):"ArrowRight"===e.key?_a(1):"ArrowLeft"===e.key&&_a(-1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[ga,_a]);const Ra=(0,i.useState)(null),Ea=(0,s.A)(Ra,2),Ta=Ea[0],Ma=Ea[1],La=(0,i.useState)(!1),za=(0,s.A)(La,2),Va=za[0],Ba=za[1],Ua=(0,i.useState)({}),Ka=(0,s.A)(Ua,2),Ga=Ka[0],Ja=Ka[1],Xa=(0,i.useState)(!1),tn=(0,s.A)(Xa,2),an=tn[0],nn=tn[1],ln=(0,i.useState)(!1),dn=(0,s.A)(ln,2),un=dn[0],hn=dn[1],xn=(0,i.useState)(60),pn=(0,s.A)(xn,2),fn=pn[0],gn=pn[1],vn=(0,i.useState)(""),bn=(0,s.A)(vn,2),wn=bn[0],yn=bn[1],An=(0,i.useState)(null),Fn=(0,s.A)(An,2),_n=Fn[0],Rn=Fn[1],qn=(0,i.useState)(!1),Bn=(0,s.A)(qn,2),Un=Bn[0],Kn=Bn[1],Hn=(0,i.useState)(null),Wn=(0,s.A)(Hn,2),Gn=Wn[0],Jn=Wn[1],Yn=(0,i.useRef)(null),Xn=(0,i.useRef)(!1),Zn=(0,i.useRef)(null),Qn=(0,i.useState)(null),$n=(0,s.A)(Qn,2),es=$n[0],ts=$n[1],as=(0,i.useState)(!1),ns=(0,s.A)(as,2),ss=ns[0],is=ns[1],rs=(0,i.useRef)(null),ls=(0,i.useRef)(!1),os=(0,i.useState)([]),cs=(0,s.A)(os,2),ds=cs[0],us=cs[1],ms=(0,i.useState)(()=>localStorage.getItem("htv_density")||"grid"),hs=(0,s.A)(ms,2),xs=hs[0],ps=(hs[1],(0,i.useState)(!1)),fs=(0,s.A)(ps,2),gs=(fs[0],fs[1]),vs=(0,i.useState)({}),bs=(0,s.A)(vs,2),ws=bs[0],js=bs[1],ys=(0,i.useState)({}),ks=(0,s.A)(ys,2),Ns=ks[0],As=ks[1],Fs=(0,i.useState)(!1),_s=(0,s.A)(Fs,2),Cs=_s[0],Ss=_s[1],Rs=(0,i.useState)(x),Es=(0,s.A)(Rs,2),Ts=Es[0],Ms=Es[1],Ps=(0,i.useRef)(null),Ds=(0,i.useRef)(null),Is=(0,i.useState)(null),Ls=(0,s.A)(Is,2),zs=Ls[0],Vs=Ls[1],Os=(0,i.useState)(null),qs=(0,s.A)(Os,2),Bs=qs[0],Us=qs[1],Ks=(0,i.useRef)([]),Hs=(0,i.useState)(!1),Ws=(0,s.A)(Hs,2),Gs=Ws[0],Js=Ws[1],Ys=(0,i.useState)(""),Xs=(0,s.A)(Ys,2),Zs=Xs[0],Qs=Xs[1],$s=(0,i.useState)(!1),ei=(0,s.A)($s,2),ti=ei[0],ai=ei[1];(0,i.useEffect)(()=>{const e=()=>gs(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",e),()=>document.removeEventListener("fullscreenchange",e)},[]);const ni=(0,i.useCallback)((e,t)=>{const a=Math.random().toString(36).slice(2),n=8+84*Math.random();us(s=>[...s,{key:a,emoji:e,left:n,name:t}]),setTimeout(()=>us(e=>e.filter(e=>e.key!==a)),2600)},[]),si=(0,i.useCallback)(e=>{e.emoji&&e.from_id!==(null===w||void 0===w?void 0:w.user_id)&&(ni(e.emoji,e.from_name),p(e.emoji))},[ni,null===w||void 0===w?void 0:w.user_id]),ii=(0,i.useCallback)(e=>{var t,a;const s=Math.random().toString(36).slice(2),i=e.gift||{},r=i.cost||0,l=r>=500?"large":r>=150?"medium":"small";if(we(t=>[...t,(0,n.A)({key:s},e)].slice(-5)),setTimeout(()=>we(e=>e.filter(e=>e.key!==s)),"large"===l?4600:4400),(0,de.qg)(i),null!==(t=(a=window).matchMedia)&&void 0!==t&&t.call(a,"(prefers-reduced-motion: reduce)").matches)return;const c=[i.color||"#FF2A5F","#FFD700","#00F0FF","#FF2A5F"];"medium"===l?(0,o.A)({particleCount:70,spread:70,startVelocity:35,origin:{x:.9,y:.5},colors:c}):"large"===l&&((0,o.A)({particleCount:160,spread:100,startVelocity:50,origin:{y:.6},colors:c}),setTimeout(()=>(0,o.A)({particleCount:100,angle:60,spread:80,origin:{x:0,y:.7},colors:c}),200),setTimeout(()=>(0,o.A)({particleCount:100,angle:120,spread:80,origin:{x:1,y:.7},colors:c}),200),setTimeout(()=>(0,o.A)({particleCount:120,spread:120,startVelocity:45,origin:{y:.4},colors:c}),550))},[]),ri=(0,i.useCallback)(e=>{j(t=>{var a,s,i,r;return t?(0,n.A)((0,n.A)({},t),{},{tokens:null!==(a=e.tokens)&&void 0!==a?a:t.tokens,points:null!==(s=e.points)&&void 0!==s?s:t.points,level:null!==(i=e.level)&&void 0!==i?i:t.level,tier:null!==(r=e.tier)&&void 0!==r?r:t.tier}):t})},[j]),li=(0,i.useCallback)((e,t)=>{try{e.startsWith("competition-")?window.dispatchEvent(new Event("comp-refresh")):e.startsWith("quiz-")&&window.dispatchEvent(new Event("quiz-refresh"))}catch(c){}if("session-replaced"===e)return Ll(!0),void setTimeout(()=>{try{k()}catch(e){}window.location.replace("/login")},3500);if("denied"===e)u.oR.error("\xd2ganizat\xe8 a refize demann ou an"),S("/lobby");else if("kicked"===e)u.oR.error("Yo retire w nan sal sa a"),S("/lobby");else if("banned"===e)u.oR.error("Yo bloke kont ou an"),k();else if("account-deleted"===e)u.oR.error("Kont ou an efase pa yon administrat\xe8"),k();else if("cam-limit"===e)u.oR.error(t.live?"Plas kamera yo plen \u2014 maks ".concat(t.limit||6," envite sou kamera an menm tan."):"Limit kamera rive (maks ".concat(t.limit||9," kamera)"));else if("cam-blocked-competition"===e)u.oR.error("\ud83c\udfc6 Gen yon konpetisyon k ap f\xe8t \u2014 s\xe8l moderat\xe8/admin ka limen kamera. Ekran an rez\xe8ve pou konpetisyon an.");else if("stage-only"===e)se||(0,u.oR)(t.enabled?"\ud83c\udfc6 Vi S\xe8n: s\xe8l kamera estaf yo montre kounye a":"Vi n\xf2mal tounen \u2014 tout kamera montre",{duration:4e3});else if("join-request"===e){var a;u.oR.info("".concat(null===(a=t.user)||void 0===a?void 0:a.name," vle antre"))}else if("sportsfeed"===e)Re(t.items||[]);else if("live-list"===e)try{window.dispatchEvent(new CustomEvent("live-list",{detail:t.lives||[]}))}catch(d){}else if("guest-chat-count"===e){De({used:t.used||0,limit:t.limit||5}
1);try{window.dispatchEvent(new CustomEvent("guest-chat",{detail:{used:t.used||0,limit:t.limit||5}}))}catch(m){}}else if("guest-limit"===e){const e=t.limit||Pe.limit||5;De({used:e,limit:e});try{window.dispatchEvent(new CustomEvent("guest-chat",{detail:{used:e,limit:e}}))}catch(h){}Ve(!0)}else if("notification"===e){const e=t.notification||{};if("live"===e.type)try{(0,de.Jv)()}catch(x){}"follow"===e.type?u.oR.success(e.text||"".concat(e.actor_name||"Yon moun"," k\xf2manse swiv ou! \ud83d\udd14"),{duration:6e3}):e.text&&u.oR.info(e.text,{duration:6e3});try{window.dispatchEvent(new CustomEvent("notif-push",{detail:e}))}catch(p){}}else if("live-ended"===e){var s;(!(null!==(s=Zn.current)&&void 0!==s&&s.isHost)||t.force_host)&&(t.by_admin?u.oR.error(t.reason||"Yon administrat\xe8 f\xe8men dir\xe8k la.",{duration:8e3}):t.cancelled?u.oR.error(t.reason||"Dir\xe8k la anile. \xd2ganizat\xe8 a kite epi li pa tounen.",{duration:7e3}):u.oR.info("Dir\xe8k la fini."),S("/lobby"))}else if("stage-restored"===e)u.oR.success("Ou tounen sou kamera! Koneksyon w retabli. \ud83c\udfa5",{duration:5e3});else if("forced"===e){const e=t.media||{};e.audio&&e.video||u.oR.info("Yon \xf2ganizat\xe8 ajiste mikwo/kamera w")}else if("reward"===e){const e=[];t.tokens&&e.push("".concat(t.tokens," jeton")),t.points&&e.push("".concat(t.points," pwen"));const a=e.join(" + ")||"yon rekonpans";u.oR.success("\ud83c\udf81 Admin rekonpanse w ".concat(a,"!"),{description:t.note||void 0,duration:6e3}),y()}else if("payout-paid"===e)Ye({id:t.id,amount_usd:t.amount_usd,note:t.note}),y(),window.dispatchEvent(new Event("hp-payouts-refresh"));else if("vip-update"===e)t.is_vip&&u.oR.success("\ud83d\udc51 Ou se yon manm VIP kounye a!",{duration:6e3}),y();else if("advertiser-update"===e)y();else if("referral-signup"===e){const e=t.referred_name||"Yon zanmi";t.tokens>0?u.oR.success("\ud83c\udf89 ".concat(e," f\xe8k enskri ak lyen referral ou! +").concat(t.tokens," jeton"),{duration:6e3}):(0,u.oR)("\ud83d\udc4b ".concat(e," f\xe8k enskri ak lyen referral ou!"),{duration:5e3}),y()}else if("referral-reward"===e)u.oR.success("\ud83c\udfc6 ".concat(t.referred_name||"Yon zanmi"," rete aktif \u2014 ou touche ").concat((t.points||0).toLocaleString()," pwen kachab!"),{duration:8e3}),y();else if("payout-rejected"===e){var i;u.oR.error("Demann retire lajan ou an refize \u2014 ".concat(null===(i=t.points)||void 0===i?void 0:i.toLocaleString()," pwen rem\xe8t.").concat(t.note?" ".concat(t.note):""),{duration:7e3}),y(),window.dispatchEvent(new Event("hp-payouts-refresh"))}else if("payout-proof-requested"===e)(0,u.oR)("\ud83d\udcc4 Admin mande plis pr\xe8v pou demann retr\xe8 ou an.".concat(t.note?" ".concat(t.note):""," Ale nan Bous ou pou voye l."),{duration:8e3});else if("invited-up"===e)t.auto?u.oR.success("\u2705 ".concat(t.by||"\xd2ganizat\xe8 a"," apwouve w! Kamera w ak mikwo w limen otomatikman. \ud83c\udfa5"),{duration:6e3}):(0,u.oR)("\u270b ".concat(t.by||"Yon modeat\xe8"," envite w monte! Limen kamera w?"),{duration:1e4,action:{label:"Limen kamera",onClick:()=>{Zn.current&&!Zn.current.mediaState.video&&Zn.current.toggleVideo()}}});else if("cam-request"===e){var r;(0,u.oR)("\ud83d\udcf8 ".concat((null===(r=t.from)||void 0===r?void 0:r.name)||"Yon moun"," mande w limen kamera w"),{duration:8e3,action:{label:"Limen",onClick:()=>{Zn.current&&!Zn.current.mediaState.video&&Zn.current.toggleVideo()}}})}else if("media-reaction"===e){const e="video"===t.kind?"videyo":"foto";(0,u.oR)("".concat(t.emoji||"\u2764\ufe0f"," ").concat(t.from_name||"Yon moun"," renmen ").concat(e," ou!"),{duration:6e3}),y()}else if("media-comment"===e)(0,u.oR)("\ud83d\udcac ".concat(t.from_name||"Yon moun"," komante sou kontni ou"),{description:(t.text||"").slice(0,100),duration:6e3});else if("performer-approved"===e)u.oR.success("\ud83c\udf89 Ou vin yon p\xe8f\xf2m\xe8 kounye a!",{description:"Tarif ou: ".concat(t.ppv_rate," jeton/minit"),duration:8e3}),y();else if("performer-rejected"===e)(0,u.oR)("Aplikasyon p\xe8f\xf2m\xe8 ou pa apwouve fwa sa a.",{duration:7e3}),y();else if("performer-application"===e)(0,u.oR)("\u2b50 Nouvo aplikasyon p\xe8f\xf2m\xe8: ".concat(t.name||"yon moun"),{description:"Ale nan Admin pou revize l.",duration:8e3});else if("favorite-online"===e){const e=t.performer||{};(0,u.oR)("\u2b50 ".concat(e.name||"Yon p\xe8f\xf2m\xe8"," anliy kounye a!"),{duration:7e3})}else if("city-busy"===e)(0,u.oR)("\ud83d\udd25 Chanm ".concat(t.name," cho kounye a!"),{description:"".concat(t.count," moun ap chat la \u2014 vin jwenn yo!"),duration:8e3});else if("new-post"===e)t.post&&Ne(e=>[t.post,...e.filter(e=>e.id!==t.post.id)].slice(0,25));else if("post-reaction"===e)(0,u.oR)("".concat(t.emoji," ").concat(t.from_name||"Yon moun"," reyaji sou p\xf2s ou a"),{duration:5e3});else if("post-comment"===e)(0,u.oR)("\ud83d\udcac ".concat(t.from_name||"Yon moun"," komante sou p\xf2s ou a"),{description:t.text,duration:6e3});else if("support-ticket"===e)(0,u.oR)("\ud83c\udd98 Nouvo demann sip\xf2: ".concat(t.name||"yon moun"),{description:t.subject||"",duration:8e3});else if("support-reply"===e)u.oR.success("\u2705 Ekip sip\xf2 a reponn demann ou: ".concat(t.subject||""),{duration:7e3});else if("pin-update"===e)ql(t.pinned||null);else if("tv-lowerthird"===e)Kl(t.lower_thirds||[]),"number"===typeof t.rotate_secs&&Gl(t.rotate_secs);else if("tv-popup-open"===e){try{window.dispatchEvent(new Event("htv-open-tv"))}catch(f){}(0,u.oR)("\ud83d\udcfa Live TV ap jwe kounye a!",{duration:5e3})}else if("jenipal-champ"===e){const e=t.user_id===E.current;
1try{const e=["#FFD700","#FF2A5F","#FFB800","#00F0FF"];(0,o.A)({particleCount:160,spread:105,origin:{y:.4},colors:e}),setTimeout(()=>(0,o.A)({particleCount:90,angle:60,spread:75,origin:{x:0},colors:e}),150),setTimeout(()=>(0,o.A)({particleCount:90,angle:120,spread:75,origin:{x:1},colors:e}),150)}catch(g){}e?(u.oR.success("\ud83e\udde0\ud83d\udc51 Ou vin Chanpyon JeniPal mwa a!",{duration:7e3}),y()):(0,u.oR)("\ud83e\udde0\ud83d\udc51 ".concat(t.name||"Yon moun"," vin nouvo Chanpyon JeniPal mwa a!"),{duration:6e3})}else if("competition-start"===e)Ui((0,n.A)((0,n.A)({},t.competition),{},{leaderboard:[]})),$i(0),al(null),(0,u.oR)("\ud83c\udfc6 Yon nouvo konpetisyon k\xf2manse! Vote kounye a.",{duration:6e3});else if("competition-vote"===e)Ui(e=>e&&e.id===t.id?(0,n.A)((0,n.A)({},e),{},{candidates:t.candidates||e.candidates,leaderboard:t.leaderboard||e.leaderboard||[]}):e);else if("competition-cost"===e)Ui(e=>e&&e.id===t.id?(0,n.A)((0,n.A)({},e),{},{vote_cost:t.vote_cost}):e);else if("competition-music"===e)Ui(e=>e&&e.id===t.id?(0,n.A)((0,n.A)({},e),{},{music_urls:t.music_urls||[],music_names:t.music_names||e.music_names||{}}):e);else if("competition-music-control"===e)Ui(e=>e&&e.id===t.id?(0,n.A)((0,n.A)({},e),{},{music_state:t.music_state}):e);else if("competition-registration"===e)_l(!0);else if("competition-registration-rejected"===e){dl("rejected"),xl({reason:t.reason||null});try{On()}catch(v){}}else if("competition-reminder"===e){var l;const e=(null===(l=t.schedule)||void 0===l?void 0:l.title)||"yon konpetisyon";(0,u.oR)('\u23f0 Konpetisyon "'.concat(e,'" ap k\xf2manse nan ~').concat(t.minutes," minit! Vin vote \ud83c\udfc6"),{duration:1e4});try{On()}catch(b){}_l(!0)}else if("competition-countdown"===e)vl(!1),Fl(t.start_at);else if("competition-end"===e){Ui(e=>e&&e.id===t.id?(0,n.A)((0,n.A)({},e),{},{status:"ended",winner:t.winner,candidates:t.candidates||e.candidates}):e);const e=t.candidates||[],a=t.winner&&"tie"!==t.winner?e.find(e=>e.user_id===t.winner):null;if(a){const n=[...e].sort((e,t)=>(t.votes||0)-(e.votes||0)).slice(0,3);al({user_id:a.user_id,name:a.name,picture:a.picture,podium:n,title:t.title,prizes:t.prizes,reward:t.reward||0}),a.user_id===(null===w||void 0===w?void 0:w.user_id)&&(t.reward&&u.oR.success("\ud83c\udf89 Ou genyen ".concat(t.reward.toLocaleString()," jeton!"),{duration:8e3}),setTimeout(()=>{try{y()}catch(e){}},1200));try{const e=["#FFD700","#FF2A5F","#FFB800","#00F0FF"];(0,o.A)({particleCount:170,spread:110,origin:{y:.4},colors:e}),setTimeout(()=>(0,o.A)({particleCount:100,angle:60,spread:80,origin:{x:0},colors:e}),180),setTimeout(()=>(0,o.A)({particleCount:100,angle:120,spread:80,origin:{x:1},colors:e}),180)}catch(j){}}else(0,u.oR)("\ud83c\udfc1 Konpetisyon an fini \u2014 egalite!",{duration:5e3})}else if("quiz-start"===e){const e=t.quiz?t.quiz.session_id||t.quiz.id:null;if(Jr.current)return Jr.current=!1,e&&(Gr.current=e),ur(null),void lr(!0);if(e&&Gr.current===e)return;e&&Gr.current&&Gr.current!==e&&(Gr.current=null),lr(!1),nr(t.quiz),ur(null),Dr(!0),(0,u.oR)("\ud83e\udde0 JeniPal! Reponn k\xf2r\xe8k anvan tan an fini!",{duration:6e3})}else if("quiz-soon"===e)Jr.current=!1,lr(!1),ur({mins:t.mins||5,count:t.count,category:t.category,at:Date.now()});else if("quiz-timeout"===e){const e=t.winners||[];if(nr(a=>a&&a.id===t.id?(0,n.A)((0,n.A)({},a),{},{status:"timeout",winners:e,winner_reward:t.winner_reward,correct_index:t.correct_index,correct_option:t.correct_option}):a),!Hr.current)try{!function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:.5;try{const t=window.AudioContext||window.webkitAudioContext;if(!t)return;const a=new t,n=a.currentTime,s=.6*Math.max(1e-4,Math.min(1,e));[1318.5,1760,2637].forEach((e,t)=>{const i=a.createOscillator(),r=a.createGain();i.type="triangle",i.frequency.value=e,i.connect(r),r.connect(a.destination);const l=n+.09*t;r.gain.setValueAtTime(1e-4,l),r.gain.exponentialRampToValueAtTime(s,l+.015),r.gain.exponentialRampToValueAtTime(1e-4,l+.45),i.start(l),i.stop(l+.5)}),setTimeout(()=>{try{a.close()}catch(e){}},1400)}catch(t){}}(Wr.current)}catch(N){}if(e.length){const a=e[0];a.user_id===E.current?(u.oR.success("\ud83c\udf89 Ou genyen ".concat(t.winner_reward," pwen!"),{duration:5e3}),y()):(0,u.oR)("\ud83e\udde0 ".concat(a.name," genyen!"),{duration:5e3})}else(0,u.oR)("\u23f1\ufe0f Tan an fini! P\xe8s\xf2n pa reponn k\xf2r\xe8k.",{duration:5e3});nr(e=>(e&&e.id===t.id&&(e.q_total>1||e.session_id)||setTimeout(()=>Dr(!1),7e3),e)),setTimeout(()=>nr(e=>e&&e.id===t.id?null:e),7e3)}else if("live-ads"===e)pr(t.ads||[]),br(t.rotate_secs||8);else if("quiz-closed"===e)Dr(!1),nr(e=>e&&e.id===t.id?null:e);else if("quiz-session-ended"===e){Gr.current=null,Jr.current=!1,lr(!1),Dr(!1),nr(null),_r(null),Er({scoreboard:t.scoreboard||[],totalQuestions:t.total_questions||0,sessionId:t.session_id});try{if((t.scoreboard||[]).length){const e=["#FFD700","#9333EA","#FF2A5F","#00F0FF"];(0,o.A)({particleCount:180,spread:110,origin:{y:.35}
1,colors:e})}}catch(A){}}},[S,k,y]),oi=A({room:v,selfUserId:null===w||void 0===w?void 0:w.user_id,guest:te,onGift:ii,onWalletUpdate:ri,onSystem:li,onReaction:si});Zn.current=oi,(0,i.useEffect)(()=>{null!==w&&void 0!==w&&w.camera_bg_url&&oi.setCustomBgUrl(w.camera_bg_url)},[null===w||void 0===w?void 0:w.camera_bg_url]);const ci=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(!ee||!oi.isHost||!oi.localStream||oi.loopVideo||ci.current)return;let e;try{e=sessionStorage.getItem("haitipal_loop")}catch(t){e=null}if(e){ci.current=!0;try{sessionStorage.removeItem("haitipal_loop")}catch(a){}try{const t=JSON.parse(e),a=t.url,n=t.urls,s=t.audio,i=Array.isArray(n)&&n.length?n:a?[a]:[];i.length&&oi.startLoopVideo(i,!1!==s)}catch(n){}}},[ee,oi.isHost,oi.localStream,oi.loopVideo,oi]);const di=ee&&(null===Ta||void 0===Ta?void 0:Ta.host_id)||null,ui=ee&&!oi.isHost&&!te&&!!di&&di!==(null===w||void 0===w?void 0:w.user_id);(0,i.useEffect)(()=>{ui?d.Ay.get("/users/".concat(di,"/follow-info")).then(e=>Ba(!!e.data.is_following)).catch(()=>{}):Ba(!1)},[ui,di]),(0,i.useEffect)(()=>{ee&&di?d.Ay.get("/live-ads/".concat(di)).then(e=>{pr(e.data.ads||[]),br(e.data.rotate_secs||8)}).catch(()=>{}):pr([])},[ee,di]);const mi=async()=>{try{Va?(await d.Ay.delete("/users/".concat(di,"/follow")),Ba(!1)):(await d.Ay.post("/users/".concat(di,"/follow")),Ba(!0),u.oR.success("Ou ap swiv ".concat((null===Ta||void 0===Ta?void 0:Ta.host_name)||"host la"," kounye a! \ud83d\udd14")))}catch(a){var e,t;u.oR.error((null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Yon er\xe8 rive")}},hi=!te&&!(null===w||void 0===w||!w.user_id);(0,i.useEffect)(()=>{hi?d.Ay.get("/users/".concat(w.user_id,"/following")).then(e=>{const t={};(e.data||[]).forEach(e=>{null!==e&&void 0!==e&&e.user_id&&(t[e.user_id]=!0)}),Ja(t)}).catch(()=>{}):Ja({})},[hi,null===w||void 0===w?void 0:w.user_id]);const xi=async e=>{const t=null===e||void 0===e?void 0:e.user_id;if(!t)return;const a=!!Ga[t];Ja(e=>(0,n.A)((0,n.A)({},e),{},{[t]:!a}));try{a?await d.Ay.delete("/users/".concat(t,"/follow")):(await d.Ay.post("/users/".concat(t,"/follow")),u.oR.success("Ou ap swiv ".concat(e.name||"moun sa a"," kounye a! \ud83d\udd14")))}catch(r){var s,i;Ja(e=>(0,n.A)((0,n.A)({},e),{},{[t]:a})),u.oR.error((null===(s=r.response)||void 0===s||null===(i=s.data)||void 0===i?void 0:i.detail)||"Yon er\xe8 rive")}},pi=async()=>{try{oi.stopLoopVideo()}catch(a){}let e=null;try{var t;e=null===(t=(await d.Ay.post("/live/end",{note:wn.trim()||null})).data)||void 0===t?void 0:t.stats}catch(n){}nn(!1),wn.trim()&&u.oR.success("N\xf2t la voye bay swiv\xe8 ou yo."),Rn(e||{viewers:0,new_followers:0,gifts_count:0,gifts_tokens:0})},fi=(0,i.useRef)(Date.now());(0,i.useEffect)(()=>{if(!ee||!oi.isHost)return void hn(!1);fi.current=Date.now();const e=()=>{fi.current=Date.now(),hn(!1)},t=["pointerdown","keydown","touchstart"];t.forEach(t=>window.addEventListener(t,e,{passive:!0}));let a=0;const n=()=>{const t=Date.now();t-a>5e3&&(a=t,e())};window.addEventListener("mousemove",n,{passive:!0});const s=setInterval(()=>{Date.now()-fi.current>=24e4&&hn(!0)},5e3);return()=>{t.forEach(t=>window.removeEventListener(t,e)),window.removeEventListener("mousemove",n),clearInterval(s)}},[ee,oi.isHost]),(0,i.useEffect)(()=>{if(!un)return void gn(60);gn(60);const e=setInterval(()=>{gn(t=>t<=1?(clearInterval(e),hn(!1),pi(),60):t-1)},1e3);return()=>clearInterval(e)},[un]),(0,i.useEffect)(()=>{if("pending"!==oi.status)return void Kn(!1);const e=setTimeout(()=>Kn(!0),6e4);return()=>clearTimeout(e)},[oi.status]);const gi=()=>{oi.mediaLocked.video?oi.handRaised?(oi.lowerHand(),(0,u.oR)("Ou anile demann pou vin sou kamera a.")):(oi.raiseHand(),u.oR.success("Demann voye bay \xf2ganizat\xe8 a! N ap tann apwobasyon.")):oi.toggleVideo()},vi=(0,i.useState)(["\u2764\ufe0f","\ud83d\udd25","\ud83d\ude02","\ud83d\udc4f","\ud83d\ude2e","\ud83c\udf89","\ud83e\udd10"]),bi=(0,s.A)(vi,2),wi=bi[0],ji=bi[1];(0,i.useEffect)(()=>{te||d.Ay.get("/reactions/config").then(e=>{const t=e.data.reactions||[];t.length&&(ji(t.map(e=>e.emoji)),function(e){if(!Array.isArray(e))return;const t={};
1e.forEach(e=>{e.emoji&&e.sound&&(t[e.emoji]=e.sound)}),Object.keys(t).length&&(h=t)}(t))}).catch(()=>{})},[te]);const yi=wi,ki=(0,i.useCallback)(()=>{d.Ay.get("/combos/top-today").then(e=>{var t;return ts((null===(t=e.data)||void 0===t?void 0:t[0])||null)}).catch(()=>{})},[]);(0,i.useEffect)(()=>{d.Ay.get("/gifts/catalog").then(e=>me(e.data)).catch(()=>{}),ki()},[ki]),(0,i.useEffect)(()=>(rs.current&&clearTimeout(rs.current),es&&ls.current?(ls.current=!1,is(!0),rs.current=setTimeout(()=>is(!1),3e4)):is(!1),()=>{rs.current&&clearTimeout(rs.current)}),[es]),(0,i.useEffect)(()=>{Z&&d.Ay.get("/rooms/".concat(v)).then(e=>Ma(e.data)).catch(()=>{})},[v,Z]),(0,i.useEffect)(()=>{"admitted"!==oi.status||!Z||null===Ta||void 0===Ta||!Ta.welcome||null!==Ta&&void 0!==Ta&&Ta.is_host||Xn.current||(Xn.current=!0,u.oR.info("\ud83d\udc4b ".concat(Ta.welcome),{duration:6e3}))},[oi.status,Z,Ta]);const Ni=(0,i.useState)([]),Ai=(0,s.A)(Ni,2),Fi=Ai[0],_i=Ai[1],Ci=(0,i.useState)([]),Si=(0,s.A)(Ci,2),Ri=Si[0],Ei=Si[1],Ti=(0,i.useState)({}),Mi=(0,s.A)(Ti,2),Pi=Mi[0],Di=Mi[1],Ii=(0,i.useState)([]),Li=(0,s.A)(Ii,2),zi=Li[0],Vi=Li[1],Oi=(0,i.useState)(null),qi=(0,s.A)(Oi,2),Bi=qi[0],Ui=qi[1],Ki=!!Bi&&"ended"!==Bi.status,Hi=Ki&&(Bi.candidates||[]).some(e=>e.user_id===(null===w||void 0===w?void 0:w.user_id)),Wi=Ki&&!Hi,Gi=!!Bi&&"ended"===Bi.status,Ji=null===Bi||void 0===Bi?void 0:Bi.id,Yi=(null===Bi||void 0===Bi?void 0:Bi.winner)&&"tie"!==Bi.winner;(0,i.useEffect)(()=>{if(!Gi)return;const e=setTimeout(()=>Ui(e=>e&&e.id===Ji&&"ended"===e.status?null:e),Yi?13e3:6e3);return()=>clearTimeout(e)},[Gi,Ji,Yi]);const Xi=(0,i.useState)(0),Zi=(0,s.A)(Xi,2),Qi=Zi[0],$i=Zi[1],er=(0,i.useState)(null),tr=(0,s.A)(er,2),ar=tr[0],nr=tr[1],sr=(0,i.useState)(!1),ir=(0,s.A)(sr,2),rr=ir[0],lr=ir[1],or=(0,i.useState)(null),cr=(0,s.A)(or,2),dr=cr[0],ur=cr[1],mr=(0,i.useState)([]),hr=(0,s.A)(mr,2),xr=hr[0],pr=hr[1],fr=(0,i.useState)(8),gr=(0,s.A)(fr,2),vr=gr[0],br=gr[1],wr=(0,i.useState)(!1),jr=(0,s.A)(wr,2),yr=jr[0],kr=jr[1],Nr=(0,i.useState)(null),Ar=(0,s.A)(Nr,2),Fr=Ar[0],_r=Ar[1],Cr=(0,i.useState)(null),Sr=(0,s.A)(Cr,2),Rr=Sr[0],Er=Sr[1],Tr=(0,i.useState)(!1),Mr=(0,s.A)(Tr,2),Pr=Mr[0],Dr=Mr[1],Ir=(0,i.useState)(()=>"1"===localStorage.getItem("htv_jenipal_muted")),Lr=(0,s.A)(Ir,2),zr=Lr[0],Vr=Lr[1],Or=(0,i.useState)(()=>{const e=parseFloat(localStorage.getItem("htv_jenipal_volume"));return Number.isFinite(e)?Math.max(0,Math.min(1,e)):.5}),qr=(0,s.A)(Or,2),Br=qr[0],Ur=qr[1],Kr=(0,i.useRef)(null),Hr=(0,i.useRef)(zr),Wr=(0,i.useRef)(Br),Gr=(0,i.useRef)(null),Jr=(0,i.useRef)(!1);(0,i.useEffect)(()=>{Hr.current=zr},[zr]),(0,i.useEffect)(()=>{Wr.current=Br},[Br]);const Yr=(0,i.useCallback)(()=>{nr(e=>(Gr.current=e?e.session_id||e.id:Gr.current,null)),Dr(!1),ur(null),lr(!0),(0,u.oR)("\ud83d\udc4b Ou kite sesyon JeniPal la. Ou ka rejwenn nenp\xf2t kil\xe8.",{duration:5e3})},[]),Xr=(0,i.useCallback)(()=>{Jr.current=!0,ur(null),lr(!0),(0,u.oR)("\ud83d\udc4b Ou p ap patisipe nan sesyon JeniPal sa a. Ou ka rejwenn nenp\xf2t kil\xe8.",{duration:5e3})},[]),Zr=(0,i.useCallback)(()=>{Gr.current=null,Jr.current=!1,lr(!1),d.Ay.get("/quiz/active").then(e=>{const t=e.data.quiz&&!e.data.quiz.gave_up?e.data.quiz:null;t?(nr(t),["won","ended","timeout","answered"].includes(t.status)||Dr(!0),(0,u.oR)("\ud83e\udde0 Ou rejwenn JeniPal la!",{duration:4e3})):(0,u.oR)("Pa gen okenn kesyon JeniPal aktif kounye a.",{duration:4e3})}).catch(()=>{})},[]),Qr=(0,i.useCallback)(()=>{Vr(e=>{const t=!e;try{localStorage.setItem("htv_jenipal_muted",t?"1":"0")}catch(a){}return t})},[]),$r=(0,i.useCallback)(e=>{const t=Math.max(0,Math.min(1,e));Ur(t);try{localStorage.setItem("htv_jenipal_volume",String(t))}catch(a){}if(t>0&&Hr.current){Vr(!1);try{localStorage.setItem("htv_jenipal_muted","0")}catch(n){}}},[]);(0,i.useEffect)(()=>{if(!Kr.current){const e=new Audio("/suspense.mp3");e.loop=!0,e.preload="auto",Kr.current=e}const e=Kr.current;if(e.volume=Br,Pr&&!zr&&Br>0)try{e.play().catch(()=>{})}catch(t){}else try{e.pause(),Pr||(e.currentTime=0)}catch(a){}},[Pr,zr,Br]),(0,i.useEffect)(()=>()=>{try{Kr.current&&Kr.current.pause()}catch(e){}},[]);const el=(0,i.useState)(null),tl=(0,s.A)(el,2),al=(tl[0],tl[1]),nl=(0,i.useState)(null),sl=(0,s.A)(nl,2),il=sl[0],rl=sl[1],ll=(0,i.useState)(null),ol=(0,s.A)(ll,2),cl=ol[0],dl=ol[1],ul=(0,i.useState)(null),ml=(0,s.A)(ul,2),hl=ml[0],xl=ml[1],pl=(0,i.useState)(!1),fl=(0,s.A)(pl,2),gl=fl[0],vl=fl[1],bl=(0,i.useState)(!1),wl=(0,s.A)(bl,2),jl=wl[0],yl=wl[1],kl=(0,i.useState)(null),Nl=(0,s.A)(kl,2),Al=Nl[0],Fl=Nl[1],_l=(0,i.useCallback)(function(){d.Ay.get("/competition/registration").then(e=>{const t=e.data.schedule||null;if(rl(e=>(((null===e||void 0===e?void 0:e.id)||null)!==((null===t||void 0===t?void 0:t.id)||null)&&yl(!1),t)),dl(e.data.my_registration||null),"rejected"===e.data.my_registration&&t){const n="htv_reg_rejected_".concat(t.id);if("1"!==localStorage.getItem(n)){xl({reason:e.data.reject_reason||null});try{localStorage.setItem(n,"1")}catch(a){}}}t||vl(!1)}).catch(()=>{})},[]);(0,i.useEffect)(()=>{_l(!0)},[_l]);const Cl=(0,i.useCallback)(()=>
1{if(vl(!1),il)try{sessionStorage.setItem("htv_reg_dismissed",il.id)}catch(e){}},[il]),Sl=(0,i.useState)(!1),Rl=(0,s.A)(Sl,2),El=Rl[0],Tl=Rl[1],Ml=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(oi.connected)return Ml.current=!0,void Tl(!1);if(!Ml.current)return;const e=setTimeout(()=>Tl(!0),1500);return()=>clearTimeout(e)},[oi.connected]);const Pl=(0,i.useState)(!1),Dl=(0,s.A)(Pl,2),Il=Dl[0],Ll=Dl[1],zl=(0,i.useState)(null),Vl=(0,s.A)(zl,2),Ol=Vl[0],ql=Vl[1],Bl=(0,i.useState)([]),Ul=(0,s.A)(Bl,2),Kl=(Ul[0],Ul[1]),Hl=(0,i.useState)(8),Wl=(0,s.A)(Hl,2),Gl=(Wl[0],Wl[1]);(0,i.useEffect)(()=>{te||(d.Ay.get("/quiz/active").then(e=>{const t=e.data.quiz&&!e.data.quiz.gave_up?e.data.quiz:null,a=t?t.session_id||t.id:null;a&&Gr.current===a||(nr(t),t&&!["won","ended","timeout","answered"].includes(t.status)&&Dr(!0))}).catch(()=>{}),d.Ay.get("/ads/pin/status").then(e=>ql(e.data.pinned||null)).catch(()=>{}),d.Ay.get("/tv-lowerthird").then(e=>{Kl(e.data.lower_thirds||[]),Gl(e.data.rotate_secs||8)}).catch(()=>{}))},[te]);const Jl=(0,i.useCallback)(async e=>{if(!ar)return null;try{const t={quiz_id:ar.id};"number"===typeof e?t.choice=e:e&&null!=e.text&&(t.text=e.text);const a=(await d.Ay.post("/quiz/answer",t)).data;return a.won&&y(),a}catch(n){var t,a;return u.oR.error((null===(t=n.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail)||"Yon er\xe8 rive"),null}},[ar,y]),Yl=(0,i.useCallback)(()=>{d.Ay.get("/media/fresh").then(e=>{var t;return Vi((null===(t=e.data)||void 0===t?void 0:t.user_ids)||[])}).catch(()=>{})},[]);(0,i.useEffect)(()=>{d.Ay.get("/competition/active").then(e=>{Ui(e.data.competition?(0,n.A)((0,n.A)({},e.data.competition),{},{leaderboard:e.data.leaderboard||[]}):null),$i(e.data.my_votes||0)}).catch(()=>{})},[]),(0,i.useEffect)(()=>{if(te)return;let e=!0;const t=async()=>{if(!document.hidden)try{const t=await Promise.all([d.Ay.get("/quiz/active").catch(()=>null),d.Ay.get("/competition/active").catch(()=>null)]),a=(0,s.A)(t,2),i=a[0],r=a[1];if(!e)return;if(i){const e=i.data.quiz;nr(t=>e?t&&t.id===e.id||e.gave_up?t:e:!t||"won"!==t.status&&"ended"!==t.status&&"timeout"!==t.status?null:t)}if(r){const e=r.data.competition,t=r.data.leaderboard||[];let a=!1;Ui(s=>e?s&&s.id===e.id?"ended"===s.status?s:(0,n.A)((0,n.A)({},s),{},{candidates:e.candidates,leaderboard:t}):(a=!0,(0,n.A)((0,n.A)({},e),{},{leaderboard:t})):s&&"ended"===s.status?s:null),a&&$i(r.data.my_votes||0)}}catch(t){}},a=()=>t();return t(),window.addEventListener("ws-live-sync",a),()=>{e=!1,window.removeEventListener("ws-live-sync",a)}},[te]);const Xl=(0,i.useCallback)(async e=>{if(Bi)try{await d.Ay.post("/competition/".concat(Bi.id,"/vote"),{candidate_id:e}),$i(e=>e+1),u.oR.success("V\xf2t ou konte! \ud83d\uddf3\ufe0f"),y()}catch(n){var t,a;u.oR.error((null===(t=n.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail)||"Yon er\xe8 rive")}},[Bi,y]),Zl=(0,i.useRef)(null);(0,i.useEffect)(()=>{var e,t;if(te||!Bi||"ended"===Bi.status)return;if(!(Bi.candidates||[]).some(e=>e.user_id===(null===w||void 0===w?void 0:w.user_id)))return;if(Zl.current===Bi.id)return;Zl.current=Bi.id;let a=!1;oi.mediaState.video||null!==(e=oi.mediaLocked)&&void 0!==e&&e.video||(oi.toggleVideo(),a=!0),oi.mediaState.audio||null!==(t=oi.mediaLocked)&&void 0!==t&&t.audio||(oi.toggleAudio(),a=!0),a&&(0,u.oR)("\ud83d\udcf9 Kamera ak mikwo w limen paske ou nan konpetisyon an",{duration:5e3})},[Bi,null===w||void 0===w?void 0:w.user_id,te,oi]);const Ql=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=Ds.current;if(!e||"undefined"===typeof ResizeObserver)return;const t=new ResizeObserver(e=>{var t;const a=null===(t=e[0])||void 0===t?void 0:t.contentRect;a&&Vs({w:a.width,h:a.height})});return t.observe(e),()=>t.disconnect()},[ee]),(0,i.useEffect)(()=>{const e=!Z&&((null===w||void 0===w?void 0:w.is_admin)||(null===w||void 0===w?void 0:w.is_moderator)||"admin"===(null===w||void 0===w?void 0:w.role)||"moderator"===(null===w||void 0===w?void 0:w.role)||oi.isHost),t=new Set(oi.raisedHands.map(e=>e.user_id));if(e){if(null!==Ql.current){const e=oi.raisedHands.filter(e=>!Ql.current.has(e.user_id));if(e.length>0){var a;try{(0,de.uJ)()}catch(n){}(0,u.oR)("\u270b ".concat((null===(a=e[e.length-1])||void 0===a?void 0:a.name)||"Yon moun"," leve men"),{duration:4e3})}}Ql.current=t}else Ql.current=t},[oi.raisedHands,oi.isHost,Z,w]),(0,i.useEffect)(()=>
1{te||(d.Ay.get("/messages?scope=lobby&room=".concat(v)).then(e=>oi.setLobbyMessages(e.data)).catch(()=>{}),d.Ay.get("/friends").then(e=>_i(e.data)).catch(()=>{}),d.Ay.get("/members").then(e=>Ei(e.data)).catch(()=>{}),d.Ay.get("/dm/unread").then(e=>Di(e.data||{})).catch(()=>{}),Yl())},[]),(0,i.useEffect)(()=>{te||null!==z||Yl()},[z,te,Yl]),(0,i.useEffect)(()=>{G&&(Tt(G),J())},[G,J]);const $l=e=>{d.Ay.post("/dm/read/".concat(e)).catch(()=>{}),Di(t=>{if(!t[e])return t;const a=(0,n.A)({},t);return delete a[e],a})},eo=(0,i.useMemo)(()=>{var e;return{user_id:null===w||void 0===w?void 0:w.user_id,name:null===w||void 0===w?void 0:w.name,picture:null===w||void 0===w?void 0:w.picture,level:null===w||void 0===w?void 0:w.level,tier:null===w||void 0===w?void 0:w.tier,points:null===w||void 0===w?void 0:w.points,media:oi.mediaState,followers_count:null!==(e=null===w||void 0===w?void 0:w.followers_count)&&void 0!==e?e:0,role:null===w||void 0===w?void 0:w.role,is_admin:null===w||void 0===w?void 0:w.is_admin,is_moderator:null===w||void 0===w?void 0:w.is_moderator}},[w,oi.mediaState]),to=(0,i.useMemo)(()=>Object.values(oi.peers).filter(e=>{var t;return!(null!==(t=e.info)&&void 0!==t&&t.is_guest)}),[oi.peers]),ao=(0,i.useMemo)(()=>{const e=new Map;return(Ri||[]).forEach(t=>{!t||!t.user_id||t.user_id===(null===w||void 0===w?void 0:w.user_id)||t.is_guest||t.is_bot&&!t.human_like||e.set(t.user_id,{user_id:t.user_id,name:t.name,picture:t.picture,is_guest:t.is_guest,online:!!t.online})}),Object.values(oi.peers).forEach(t=>{const a=t.info;
1if(!a||!a.user_id)return;if(a.user_id===(null===w||void 0===w?void 0:w.user_id)||a.is_guest)return;if(a.is_bot&&!a.human_like)return;const n=e.get(a.user_id)||{};e.set(a.user_id,{user_id:a.user_id,name:a.name||n.name,picture:a.picture||n.picture,is_guest:a.is_guest,online:!0})}),Array.from(e.values()).sort((e,t)=>e.online===t.online?0:e.online?-1:1)},[Ri,oi.peers,w]),no=ue(oi.peers,oi.localStream,null===w||void 0===w?void 0:w.user_id),so=(0,i.useMemo)(()=>to.filter(e=>{var t,a,n,s,i,r,l,o;if(!(null!==(t=e.info)&&void 0!==t&&null!==(a=t.media)&&void 0!==a&&a.video||null!==(n=e.info)&&void 0!==n&&null!==(s=n.media)&&void 0!==s&&s.audio))return!1;const c=(null===(i=e.info)||void 0===i?void 0:i.is_admin)||(null===(r=e.info)||void 0===r?void 0:r.is_moderator)||"admin"===(null===(l=e.info)||void 0===l?void 0:l.role)||"moderator"===(null===(o=e.info)||void 0===o?void 0:o.role);if(Ki){return((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).some(t=>{var a;return t.user_id===(null===(a=e.info)||void 0===a?void 0:a.user_id)})||c}return!(oi.stageOnly&&!c)}),[to,oi.stageOnly,Ki,Bi]),io=(0,i.useCallback)(e=>I("profile",e.user_id),[I]),ro=(0,i.useCallback)(e=>Ct(e),[]),lo=(0,i.useCallback)(e=>va(e.user_id),[]),oo=(0,i.useCallback)(()=>Ve(!0),[]),co=(0,i.useMemo)(()=>Ri.filter(e=>!oi.hiddenIds.has(e.user_id)),[Ri,oi.hiddenIds]);(0,i.useEffect)(()=>{te||d.Ay.get("/posts/recent").then(e=>Ne(e.data||[])).catch(()=>{})},[te]);const uo=!!Bs&&so.some(e=>e.info.user_id===Bs);(0,i.useEffect)(()=>{Bs&&!uo&&Us(null)}
1,[Bs,uo]);const mo=async(e,t)=>{try{const a=(await d.Ay.post("/gifts/send",{to_user:t.user_id,gift_id:e.id})).data;return j(e=>(0,n.A)((0,n.A)({},e),{},{tokens:a.sender.tokens})),!0}catch(r){var a,s,i;const e=(0,d.KI)(null===(a=r.response)||void 0===a||null===(s=a.data)||void 0===s?void 0:s.detail);return 400===(null===(i=r.response)||void 0===i?void 0:i.status)&&/ase jeton/i.test(e)?u.oR.error(e,{action:(0,f.J)()?void 0:{label:"Achte jeton",onClick:()=>I("wallet")}}):u.oR.error(e),!1}},ho=()=>{Yn.current&&clearTimeout(Yn.current),Yn.current=setTimeout(()=>Jn(null),4200)},xo=()=>{Yn.current&&clearTimeout(Yn.current),Jn(null)},po=async e=>{try{const t=(await d.Ay.get("/messages?scope=dm&peer=".concat(e))).data;oi.setDmMessages(a=>(0,n.A)((0,n.A)({},a),{},{[e]:t}))}catch(t){}},fo=async e=>{try{const t=(await d.Ay.get("/messages?scope=channel&channel=".concat(e))).data;oi.setChannelMessages(a=>(0,n.A)((0,n.A)({},a),{},{[e]:t}))}catch(t){}},go=e=>oi.setChannelActivity(t=>(0,n.A)((0,n.A)({},t),{},{[e]:0})),vo=async e=>{try{await d.Ay.post("/friends/".concat(e.user_id)),_i(t=>t.some(t=>t.user_id===e.user_id)?t:[...t,e]),u.oR.success("Ou ajoute ".concat(e.name," k\xf2m zanmi!"))}catch(n){var t,a;u.oR.error((0,d.KI)(null===(t=n.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail))}},bo=async e=>{try{await d.Ay.delete("/friends/".concat(e.user_id)),_i(t=>t.filter(t=>t.user_id!==e.user_id)),u.oR.success("Ou retire ".concat(e.name," nan zanmi ou"))}catch(n){var t,a;u.oR.error((0,d.KI)(null===(t=n.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail))}},wo=e=>{var t;return oi.forceMedia(e.user_id,{audio:!(null!==(t=e.media)&&void 0!==t&&t.audio)})},jo=e=>{var t;return oi.forceMedia(e.user_id,{video:!(null!==(t=e.media)&&void 0!==t&&t.video)})},yo=e=>oi.kick(e.user_id),ko=e=>{oi.forceMedia(e.user_id,{video:!1,audio:!1}),u.oR.success("".concat(e.name," retire sou kamera \u2014 li tounen vizit\xe8."))},No=(0,i.useCallback)(e=>{js(t=>{const a=!t[e.user_id];return u.oR.info(a?"Ou f\xe8men son ".concat(e.name," (pou ou s\xe8lman)"):"Ou louvri son ".concat(e.name)),(0,n.A)((0,n.A)({},t),{},{[e.user_id]:a})})},[]),Ao=(0,i.useCallback)(e=>{As(t=>{const a=!t[e.user_id];return u.oR.info(a?"Ou kache kamera ".concat(e.name," (pou ou s\xe8lman)"):"Ou montre kamera ".concat(e.name)),(0,n.A)((0,n.A)({},t),{},{[e.user_id]:a})})},[]);if("pending"===oi.status)return(0,X.jsx)(F.G,{children:(0,X.jsx)("div",{className:"flex min-h-[60vh] items-center justify-center",children:(0,X.jsx)("div",{className:"w-full max-w-md rounded-3xl glass p-10 text-center","data-testid":"waiting-approval",children:Un?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-yellow-400/15",children:(0,X.jsx)(En.A,{className:"h-7 w-7 text-yellow-400"})}),(0,X.jsx)("h2",{className:"mt-5 font-display text-2xl font-extrabold","data-testid":"waiting-timeout-title",children:"\xd2ganizat\xe8 a poko reponn"}),(0,X.jsxs)("p",{className:"mt-2 text-gray-400",children:["\xd2ganizat\xe8 ",(0,X.jsx)("span",{className:"neon-cyan",children:oi.roomName||"sal sa a"})," poko kite w antre. Ou ka kontinye tann oswa retounen nan lakou a."]}),(0,X.jsxs)("div",{className:"mt-6 flex gap-2",children:[(0,X.jsx)("button",{onClick:()=>Kn(!1),className:"flex-1 h-11 rounded-full surface-2 font-bold text-white hover:bg-white/10","data-testid":"keep-waiting-btn",children:"Kontinye tann"}),(0,X.jsx)("button",{onClick:()=>S("/lobby"),className:"flex-1 h-11 rounded-full bg-[#FF2A5F] font-bold text-white glow-pink","data-testid":"cancel-wait-btn",children:"Retounen nan lakou"})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ve.A,{className:"mx-auto h-14 w-14 animate-spin text-cyan-400"}),(0,X.jsx)("h2",{className:"mt-5 font-display text-2xl font-extrabold",children:"Ap tann apwobasyon"}),(0,X.jsxs)("p",{className:"mt-2 text-gray-400",children:["\xd2ganizat\xe8 ",(0,X.jsx)("span",{className:"neon-cyan",children:oi.roomName||"sal sa a"})," dwe kite w antre."]}),(0,X.jsx)("button",{onClick:()=>S("/lobby"),className:"mt-6 h-11 w-full rounded-full surface-2 font-bold text-white hover:bg-white/10","data-testid":"cancel-wait-btn",children:"Anile"})]})})})});if("notfound"===oi.status)return(0,X.jsx)(F.G,{children:(0,X.jsx)("div",{className:"flex min-h-[60vh] items-center justify-center",children:(0,X.jsxs)("div",{className:"w-full max-w-md rounded-3xl glass p-10 text-center",children:[(0,X.jsx)(ge.A,{className:"mx-auto h-14 w-14 text-red-400"}),(0,X.jsx)("h2",{className:"mt-5 font-display text-2xl font-extrabold",children:"Nou pa jwenn sal la"}),(0,X.jsx)("button",{onClick:()=>S("/lobby"),className:"mt-6 h-11 w-full rounded-full bg-[#FF2A5F] font-bold text-white glow-pink",children:"Retounen nan lakou"})]})})});const Fo=to.length+(te?0:1),_o="active"===(null===(t=oi.call)||void 0===t?void 0:t.status),Co=!te&&(oi.mediaState.video||oi.mediaState.audio)&&!_o&&(!oi.stageOnly||se)&&(!Ki||Hi||se),So=!!(null!==w&&void 0!==w&&w.is_admin||"admin"===(null===w||void 0===w?void 0:w.role)),Ro=ee&&oi.isHost||So&&oi.mediaState.video,Eo=Object.keys(oi.ppvPeers||{}).map(e=>{var t;return null===(t=oi.peers[e])||void 0===t?void 0:t.info}
1).filter(Boolean),To=!Z&&((null===w||void 0===w?void 0:w.is_admin)||(null===w||void 0===w?void 0:w.is_moderator)||"admin"===(null===w||void 0===w?void 0:w.role)||"moderator"===(null===w||void 0===w?void 0:w.role)),Mo="spotlight"===xs?4:9,Po=so.map(e=>e.info.user_id);Ks.current=Ks.current.filter(e=>Po.includes(e)),Po.forEach(e=>{Ks.current.includes(e)||Ks.current.push(e)});const Do=Ks.current.map(e=>so.find(t=>t.info.user_id===e)).filter(Boolean),Io=[...Do.filter(e=>{var t;return null===(t=e.info)||void 0===t?void 0:t.is_vip}),...Do.filter(e=>{var t;return!(null!==(t=e.info)&&void 0!==t&&t.is_vip)})],Lo=Math.max(0,Mo-(Co?1:0)),zo=Io.slice(0,Lo),Vo=Io.slice(Lo),Oo=zo.length+(Co?1:0),qo=new Set(zo.map(e=>e.info.user_id)),Bo=to.filter(e=>{var t,a;return!(!e.stream||null===(t=e.info)||void 0===t||null===(a=t.media)||void 0===a||!a.audio)&&(ga?e.info.user_id!==ga:!qo.has(e.info.user_id))}),Uo=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:9;const a=Math.min(Math.max(0,e),t);let n,s,i;return n=a<=1?1:2===a?2:a<=4?4:a<=6?6:9,n<=1?(s=1,i=1):2===n?(s=2,i=1):n<=4?(s=2,i=2):n<=6?(s=3,i=2):(s=3,i=3),{cells:n,style:{gridTemplateColumns:"repeat(".concat(s,", minmax(0, 1fr))"),gridTemplateRows:"repeat(".concat(i,", minmax(0, 1fr))"),height:"100%"}}}(Ki?function(){const e=new Set(((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).map(e=>e.user_id)),t=zo.filter(t=>!e.has(t.info.user_id)).length+(Co&&!e.has(null===w||void 0===w?void 0:w.user_id)?1:0);return e.size+t}():Oo,Mo),Ko=Uo.cells,Ho=[],Wo={};((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).forEach(e=>{Wo[e.user_id]=e.votes||0});const Go=Object.values(Wo).reduce((e,t)=>Math.max(e,t),0),Jo=(null===Bi||void 0===Bi?void 0:Bi.vote_cost)||0,Yo=Ki&&!(null!==Bi&&void 0!==Bi&&Bi.multi_vote)&&Qi>0,Xo=Ki?te?"Konekte pou vote":Yo?"Ou deja vote":(null!==(a=null===w||void 0===w?void 0:w.tokens)&&void 0!==a?a:0)<Jo?"Pa gen ase jeton":null:null,Zo=e=>Ki&&((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).some(t=>t.user_id===e),Qo=e=>{if(Zo(e))return{votes:Wo[e]||0,isLeader:Go>0&&Wo[e]===Go,canVote:!Xo,reason:Xo,voteCost:Jo,onVote:Xl}},$o=()=>(0,X.jsx)(Q,{fill:!0,info:eo,stream:oi.localStream,isSelf:!0,muted:!0,speaking:no.has(null===w||void 0===w?void 0:w.user_id),onGift:()=>{},onProfile:io,onSpotlight:lo,voteInfo:Qo(null===w||void 0===w?void 0:w.user_id)},"self"),ec=e=>(0,X.jsx)(Q,{fill:!0,info:e.info,stream:e.stream,muted:!1,speaking:no.has(e.info.user_id),sinkId:oi.selectedDevices.speaker,voteInfo:Qo(e.info.user_id),localMuted:Cs||!!ws[e.info.user_id],localHidden:!!Ns[e.info.user_id],onLocalMute:No,onLocalHide:Ao,onGift:te?void 0:ro,onProfile:io,onRequestCam:te?void 0:e=>{oi.requestCam(e.user_id),u.oR.success("Ou mande ".concat(e.name," limen kamera l"))},canFollow:e.info.user_id===di?ui:hi&&e.info.user_id!==(null===w||void 0===w?void 0:w.user_id),isFollowing:e.info.user_id===di?Va:!!Ga[e.info.user_id],onToggleFollow:e.info.user_id===di?mi:xi,followIconOnly:!0,onReconnect:e=>oi.reconnectPeer(e.user_id),onSpotlight:lo,isHost:oi.isHost,isMod:To,onMute:wo,onToggleCam:jo,onKick:yo},e.info.user_id);if(Ki){const e=null===w||void 0===w?void 0:w.user_id,t={};zo.forEach(e=>{t[e.info.user_id]=e});const a=new Set(((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).map(e=>e.user_id)),n=(e,t)=>(0,X.jsxs)("div",{className:"flex h-full w-full min-h-0 flex-col gap-1.5",children:[(0,X.jsx)("div",{className:"cam-square-wrap flex-1 min-h-0",children:(0,X.jsx)("div",{className:"cam-square",children:e})}),(0,X.jsx)(ae,{voteInfo:Qo(t),userId:t})]},"cc-".concat(t)),s=(e,t)=>(0,X.jsx)("div",{className:"cam-square-wrap",children:(0,X.jsx)("div",{className:"cam-square",children:e})},"pc-".concat(t));((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).forEach(a=>{let s;s=a.user_id===e&&Co?$o():t[a.user_id]?ec(t[a.user_id]):(e=>(0,X.jsx)(Q,{fill:!0,stream:null,muted:!0,info:{user_id:e.user_id,name:e.name,picture:e.picture,media:{video:!1,audio:!1}},onProfile:io,onSpotlight:lo,voteInfo:Qo(e.user_id)},"cand-".concat(e.user_id)))(a),Ho.push(n(s,a.user_id))}
1),Co&&!a.has(e)&&Ho.push(s($o(),e)),zo.forEach(e=>{a.has(e.info.user_id)||Ho.push(s(ec(e),e.info.user_id))})}else Co&&Ho.push($o()),zo.forEach(e=>Ho.push(ec(e)));const tc=[];for(let n=0;n<Ko;n++)n<Ho.length?Ki?tc.push((0,X.jsx)("div",{className:"h-full w-full min-h-0",children:Ho[n]},"cell-".concat(n))):tc.push((0,X.jsx)("div",{className:"cam-square-wrap",children:(0,X.jsx)("div",{className:"cam-square",children:Ho[n]})},"cell-".concat(n))):Ki?0===Ho.length&&0===tc.length&&tc.push((0,X.jsxs)("div",{"data-testid":"lobby-competition-hold",className:"flex h-full min-h-0 w-full flex-col items-center justify-center gap-3 rounded-2xl border-2 border-[#FF2A5F]/40 bg-gradient-to-br from-[#FF2A5F]/10 to-[#00A8CC]/10 p-6 text-center",children:[(0,X.jsx)($.A,{className:"h-12 w-12 text-[#FFD700]"}),(0,X.jsx)("p",{className:"text-lg font-black text-white",children:"Konpetisyon an sesyon"}),(0,X.jsx)("p",{className:"max-w-sm text-sm text-gray-300",children:"Kandida yo ap par\xe8t tal\xe8. Kamera lakou a ap disponib ank\xf2 l\xe8 konpetisyon an fini."})]},"comp-hold")):0!==Oo?tc.push((0,X.jsxs)("div",{"data-testid":"cam-placeholder-".concat(n),className:"flex h-full min-h-0 w-full flex-col items-center justify-center gap-1.5 rounded-2xl border-2 border-dashed border-white/15 bg-white/[0.03] text-white/40 transition-colors hover:border-[#00F0FF]/40 hover:text-[#00F0FF]/70",children:[(0,X.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border-2 border-current",children:(0,X.jsx)(fe.A,{className:"h-5 w-5"})}),(0,X.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-widest",children:0===Oo?"Plas kamera":"Pare pou pwochen"})]},"slot-".concat(n))):tc.push((0,X.jsx)(oe,{canGoLive:!te,onGoLive:gi},"showcase-".concat(n)));const ac=Bs?so.find(e=>e.info.user_id===Bs):null,nc=[];if(Ki){const e=null===w||void 0===w?void 0:w.user_id,t={};zo.forEach(e=>{t[e.info.user_id]=e}),((null===Bi||void 0===Bi?void 0:Bi.candidates)||[]).forEach(a=>{a.user_id===e&&Co?nc.push({info:eo,stream:oi.localStream,isSelf:!0}):t[a.user_id]?nc.push({info:t[a.user_id].info,stream:t[a.user_id].stream}):nc.push({info:{user_id:a.user_id,name:a.name,picture:a.picture,media:{video:!1,audio:!1}},stream:null})})}else Co&&nc.push({info:eo,stream:oi.localStream,isSelf:!0}),zo.forEach(e=>nc.push({info:e.info,stream:e.stream}));const sc=ga?nc.findIndex(e=>e.info.user_id===ga):-1,ic=sc>=0?nc[sc]:null;ba.current={list:nc,index:sc};const rc=di?oi.peers[di]:null,lc=oi.isHost?eo:(null===rc||void 0===rc?void 0:rc.info)||{user_id:di,name:null===Ta||void 0===Ta?void 0:Ta.host_name,picture:null===Ta||void 0===Ta?void 0:Ta.host_picture,media:{video:!1,audio:!1}},oc=oi.isHost?oi.localStream:null===rc||void 0===rc?void 0:rc.stream,cc=[...Co&&!oi.isHost?[{info:eo,stream:oi.localStream,isSelf:!0}]:[],...zo.filter(e=>e.info.user_id!==di).map(e=>({info:e.info,stream:e.stream,isSelf:!1}))],dc=ee&&!oi.isHost&&!te&&!Co,uc=so.filter(e=>e.info.user_id!==di).length+(Co&&!oi.isHost?1:0),mc=ee&&uc>=6,hc=[...cc.map(e=>({kind:"guest",g:e})),...dc?[{kind:"request"}]:[]],xc=hc.length>0,pc=hc.slice(0,Math.min(hc.length,3)),fc=hc.slice(pc.length),gc=(e,t,a)=>Math.max(e,Math.min(t,a));let vc,bc;if(xc)if(zs&&zs.h>0){const e=Math.round(gc(150,.6*zs.h,.56*zs.w));vc={flex:"0 0 ".concat(e,"px"),maxWidth:"".concat(e,"px")},fc.length&&(bc=Math.round(gc(88,Math.min(zs.w/fc.length,.34*zs.h),.46*zs.h)))}else vc={flex:"0 0 44%",maxWidth:"44%",minWidth:180};else vc={flex:"0 0 auto",width:"min(100%, 52vh)",maxWidth:"100%"};const wc=function(e){let t,a,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("request"===e.kind)a="request-slot",t=mc?(0,X.jsxs)("div",{"data-testid":"stage-full-slot",className:"flex h-full w-full min-h-0 flex-col items-center justify-center gap-1.5 rounded-2xl border-2 border-dashed border-white/10 bg-white/[0.02] px-1 text-center text-white/40",children:[(0,X.jsx)(U.A,{className:"h-6 w-6"}),(0,X.jsx)("span",{className:"text-[10px] font-semibold uppercase tracking-widest",children:"Plas kamera yo plen (6/6)"})]}):(0,X.jsxs)("button",{onClick:gi,"data-testid":"request-broadcast-slot",className:"flex h-full w-full min-h-0 flex-col items-center justify-center gap-1.5 rounded-2xl border-2 border-dashed transition-colors ".concat(oi.handRaised?"border-[#FFD93D] bg-[#FFD93D]/10 text-[#FFD93D]":"border-white/15 bg-white/[0.03] text-white/50 hover:border-[#00F0FF]/50 hover:text-[#00F0FF]"),children:[(0,X.jsx)("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border-2 border-current",children:oi.handRaised?(0,X.jsx)(Tn.A,{className:"h-5 w-5"}):(0,X.jsx)(fe.A,{className:"h-5 w-5"})}),(0,X.jsx)("span",{className:"px-1 text-center text-[10px] font-semibold uppercase tracking-widest",children:oi.handRaised?"Ap tann apwobasyon\u2026":"Plas kamera"})]});else{const n=e.g;a=n.info.user_id,t=(0,X.jsx)(Q,{fill:!0,info:n.info,stream:n.stream,isSelf:n.isSelf,muted:n.isSelf,speaking:no.has(n.info.user_id
1),sinkId:oi.selectedDevices.speaker,localMuted:Cs||!!ws[n.info.user_id],localHidden:!!Ns[n.info.user_id],onLocalMute:No,onLocalHide:Ao,onGift:te||n.isSelf?void 0:ro,onProfile:io,isHost:oi.isHost,isMod:!1,onMute:wo,onToggleCam:jo,onKick:yo,liveParticipant:!oi.isHost,canFollow:hi&&!n.isSelf,isFollowing:!!Ga[n.info.user_id],onToggleFollow:xi,followIconOnly:!0,onReconnect:n.isSelf?void 0:e=>oi.reconnectPeer(e.user_id),onDemote:oi.isHost&&!n.isSelf?ko:void 0})}return(0,X.jsx)("div",{className:"flex min-h-0 min-w-0 items-center justify-center ".concat(n),style:{containerType:"size"},"data-testid":"stage-cell-".concat(a),children:(0,X.jsx)("div",{className:"relative min-h-0 min-w-0 overflow-hidden rounded-2xl",style:{width:"100cqmin",height:"100cqmin"},children:t})},a)};return(0,X.jsxs)(F.G,{children:[Bo.map(e=>(0,X.jsx)(ce,{stream:e.stream,muted:Cs||!!ws[e.info.user_id],sinkId:oi.selectedDevices.speaker},"sink-".concat(e.info.user_id))),(0,X.jsxs)("div",{className:"lobby-viewport flex min-h-[520px] flex-col overflow-hidden",children:[!Z&&(0,X.jsx)("div",{className:"mb-3 flex shrink-0 lg:hidden","data-testid":"sports-wheel-mobile-bar",children:(0,X.jsx)(Ca,{items:Ce,className:"flex w-full"})}),(0,X.jsxs)("div",{className:"mb-3 flex shrink-0 flex-nowrap items-center justify-between gap-2 sm:gap-3",children:[(0,X.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2 sm:gap-3",children:[Z?(0,X.jsxs)("div",{className:"flex shrink-0 items-center gap-2 rounded-full bg-[#00F0FF] px-3 py-1.5 text-sm font-bold uppercase tracking-wide text-black","data-testid":"room-banner",children:[(0,X.jsx)(Xe.A,{className:"h-4 w-4"})," ",(null===Ta||void 0===Ta?void 0:Ta.name)||"Sal Prive"]}):(0,X.jsx)("div",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-[#FF2A5F]","data-testid":"lobby-live-badge",title:"Lakou an dir\xe8k",children:(0,X.jsx)(ne.A,{className:"h-4 w-4 live-dot text-white"})}),(0,X.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-sm text-gray-400","data-testid":"online-count",children:[(0,X.jsx)(M.A,{className:"h-4 w-4"})," ",Fo]}),ee&&(0,X.jsxs)("span",{className:"flex shrink-0 items-center gap-1 rounded-full bg-[#FF2A5F]/15 px-2.5 py-1 text-xs font-bold text-[#FF6B93]","data-testid":"live-viewer-count",children:[(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5 live-dot"})," ",Fo," ap gade"]}),(0,X.jsx)("span",{className:"min-w-0 truncate text-xs font-semibold ".concat(oi.connected||"admitted"===oi.status?"text-green-400":"text-yellow-400"),"data-testid":"connection-status",children:oi.connected||"admitted"===oi.status?"\u25cf ".concat((null===w||void 0===w?void 0:w.name)||(null===w||void 0===w?void 0:w.username)||""):"\u25cb ap konekte\u2026"}),!Z&&!te&&(0,X.jsx)(Fa,{posts:ke,onOpenProfile:e=>I("profile",e),onCompose:()=>at(!0)}),!Z&&(0,X.jsx)(Ca,{items:Ce,className:"hidden flex-1 lg:flex"}),Z&&(0,X.jsxs)("button",{onClick:()=>{var e;
1null===(e=navigator.clipboard)||void 0===e||e.writeText(v),u.oR.success("K\xf2d sal la kopye!")},"data-testid":"copy-room-code-btn",className:"flex shrink-0 items-center gap-1.5 rounded-full surface-2 px-3 py-1.5 text-xs font-mono text-cyan-300 hover:bg-white/10",children:[(0,X.jsx)(en.A,{className:"h-3.5 w-3.5"})," ",v]}),oi.isHost&&(0,X.jsx)("span",{className:"shrink-0 rounded-full bg-yellow-400/15 px-2.5 py-1 text-[11px] font-bold uppercase text-yellow-400",children:"\xd2ganizat\xe8"})]}),(0,X.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5 sm:gap-2",children:[!te&&(0,X.jsx)("button",{onClick:()=>I("profile"),"data-testid":"my-profile-btn",title:"Pwofil mwen",className:"flex h-9 w-9 items-center justify-center rounded-full bg-[#00A8CC] text-white transition-transform hover:scale-105",children:(0,X.jsx)(Te.A,{className:"h-4 w-4"})}),!te&&(0,X.jsx)(Sa.w,{variant:"compact",lowBalance:le.length>0&&(null!==(m=null===w||void 0===w?void 0:w.tokens)&&void 0!==m?m:0)<Math.min(...le.map(e=>e.cost||0))}),(0,X.jsx)(kn,{}),ee&&oi.isHost&&!te&&(0,X.jsxs)("button",{onClick:()=>kr(!0),"data-testid":"live-ad-manage-btn",title:"Piblisite nan dir\xe8k mwen",className:"flex shrink-0 items-center gap-2 rounded-full bg-[#9333EA] px-2.5 py-2 text-sm font-bold text-white transition-transform hover:scale-105 sm:px-4",children:[(0,X.jsx)(be.A,{className:"h-4 w-4"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:"Piblisite"})]}),ee&&oi.isHost?(0,X.jsxs)("button",{onClick:()=>{yn(""),nn(!0)},"data-testid":"end-live-btn",className:"flex shrink-0 items-center gap-2 rounded-full bg-[#FF2A5F] px-2.5 py-2 text-sm font-bold text-white glow-pink transition-transform hover:scale-105 sm:px-4",children:[(0,X.jsx)(ne.A,{className:"h-4 w-4 live-dot"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:"Fini dir\xe8k la"})]}):Z?(0,X.jsxs)("button",{onClick:()=>S("/lobby"),"data-testid":"leave-room-btn",className:"flex shrink-0 items-center gap-2 rounded-full surface-2 px-2.5 py-2 text-sm font-semibold text-white hover:bg-white/10 sm:px-4",children:[(0,X.jsx)(on.A,{className:"h-4 w-4"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:ee?"Kite dir\xe8k la":"Kite pou lakou"})]}):null]})]}),es&&ss&&(0,X.jsxs)("div",{className:"mb-3 flex shrink-0 items-center gap-3 rounded-2xl border border-[#FFD700]/30 bg-gradient-to-r from-[#FFD700]/10 to-[#FF2A5F]/10 px-4 py-2","data-testid":"combo-leaderboard-banner",children:[(0,X.jsx)("span",{className:"text-2xl gift-pop",children:es.gift_emoji}),(0,X.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,X.jsx)("p",{className:"text-[11px] font-bold uppercase tracking-widest text-[#FFD700]",children:"\ud83c\udfc6 Pi gwo konbo jodi a"}),(0,X.jsxs)("p",{className:"truncate text-sm text-white",children:[(0,X.jsx)("span",{className:"font-bold",children:es.from_name}),(0,X.jsxs)("span",{className:"ml-2 font-display font-black neon-pink","data-testid":"top-combo-count",children:["KONBO x",es.count]})]})]}),es.from_picture&&(0,X.jsx)("img",{src:es.from_picture,alt:"",className:"h-9 w-9 rounded-full object-cover ring-2 ring-[#FFD700]/40"})]}),oi.isHost&&oi.pendingRequests.length>0&&(0,X.jsxs)("div",{className:"mb-3 shrink-0 rounded-2xl border border-yellow-400/40 bg-yellow-400/5 p-3","data-testid":"join-requests-panel",children:[(0,X.jsxs)("p",{className:"mb-2 flex items-center gap-2 text-sm font-bold text-yellow-400",children:[(0,X.jsx)(En.A,{className:"h-4 w-4"})," Demann pou antre (",oi.pendingRequests.length,")"]}),(0,X.jsx)("div",{className:"space-y-2",children:oi.pendingRequests.map(e=>(0,X.jsxs)("div",{className:"flex items-center gap-3 rounded-xl surface-2 p-2.5","data-testid":"join-request-".concat(e.user_id),children:[(0,X.jsx)("img",{src:e.picture,alt:"",className:"h-9 w-9 rounded-full object-cover"}),(0,X.jsx)("span",{className:"flex-1 truncate text-sm font-semibold",children:e.name}),(0,X.jsxs)("button",{onClick:()=>oi.approve(e.user_id),"data-testid":"approve-".concat(e.user_id),className:"flex items-center gap-1 rounded-full bg-green-500 px-3 py-1.5 text-xs font-bold text-black hover:scale-105",children:[(0,X.jsx)(W.A,{className:"h-3.5 w-3.5"})," Aksepte"]}),(0,X.jsxs)("button",{onClick:()=>oi.deny(e.user_id),"data-testid":"deny-".concat(e.user_id),className:"flex items-center gap-1 rounded-full bg-red-500/80 px-3 py-1.5 text-xs font-bold text-white hover:scale-105",children:[(0,X.jsx)(ge.A,{className:"h-3.5 w-3.5"})," Refize"]})]},e.user_id))})]}),!Z&&(0,X.jsx)(ja,{performers:Eo,onRequest:Tt,canRequest:!te}),(0,X.jsxs)("div",{className:"grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(0,1fr)_720px]",children:[(0,X.jsxs)("div",{ref:Ps,className:"relative flex min-h-0 flex-col overflow-hidden rounded-3xl bg-[#0b0b12]",style:Z?null!==Ta&&void 0!==Ta&&Ta.cover_url?{backgroundImage:"url(".concat(Ta.cover_url,")"),backgroundSize:"cover",backgroundPosition:"center",padding:"0.75rem"}:{background:(jc=null===Ta||void 0===Ta?void 0:Ta.theme,(ia.find(e=>e.id===jc)||ia[0]).gradient),padding:"0.75rem"}:{padding:"0.75rem"},children:[Z&&(null===Ta||void 0===Ta?void 0:Ta.cover_url)&&(0,X.jsx)("div",{className:"pointer-events-none absolute inset-0 bg-black/55"}),(0,X.jsx)("div",{className:"pointer-events-none absolute inset-0 z-20 overflow-hidden","data-testid":"reactions-overlay",children:ds.map(e=>(0,X.jsxs)("span",{className:"react-float absolute bottom-24 flex flex-col items-center",style:{left:"".concat(e.left,"%")},"data-testid":"float-reaction",children:[(0,X.jsx)("span",{className:"text-4xl",children:e.emoji}),e.name&&(0,X.jsx)("span",{className:"mt-0.5 rounded-full bg-black/70 px-2 py-0.5 text-[10px] font-bold text-white whitespace-nowrap",children:e.name})]},e.key))}),ee&&(0,X.jsx)(Ia,{ads:xr,rotateSecs:vr}),Ki&&(0,X.jsx)(Vn,{competition:Bi}),(0,X.jsxs)("div",{className:"relative min-h-0 flex-1",children:[ee?(0,X.jsxs)("div",{ref:Ds,className:"flex h-full min-h-0 flex-col gap-3","data-testid":"live-stage",children:[(0,X.jsxs)("div",{className:"flex min-h-0 flex-1 gap-3",children:[(0,X.jsxs)("div",{className:"relative h-full min-h-0 ".concat(xc?"":"mx-auto"),style:vc,"data-testid":"live-host-portrait",children:[(0,X.jsx)(Q,{fill:!0,info:lc,stream:oc,isSelf:oi.isHost,muted:oi.isHost,speaking:no.has(lc.user_id
1),sinkId:oi.selectedDevices.speaker,localMuted:Cs||!!ws[di],localHidden:!!Ns[di],onLocalMute:No,onLocalHide:Ao,onGift:te||oi.isHost?void 0:()=>Ct(lc),onProfile:io,canFollow:ui,isFollowing:Va,onToggleFollow:mi,onReconnect:oi.isHost?void 0:e=>oi.reconnectPeer(e.user_id)}),(0,X.jsxs)("span",{className:"pointer-events-none absolute left-3 top-12 z-10 flex items-center gap-1.5 rounded-full bg-[#FF2A5F] px-3 py-1 text-xs font-black uppercase tracking-wide text-white shadow-lg","data-testid":"live-host-badge",children:[(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5 live-dot"})," \xd2ganizat\xe8"]})]}),pc.length>0&&(0,X.jsx)("div",{className:"flex min-h-0 flex-1 flex-col items-center gap-2","data-testid":"live-guest-right",children:pc.map(e=>wc(e,"w-full flex-1"))})]}),fc.length>0&&(0,X.jsx)("div",{className:"grid shrink-0 gap-2",style:{gridTemplateColumns:"repeat(".concat(fc.length,", minmax(0, 1fr))"),height:bc?"".concat(bc,"px"):"26%",minHeight:96},"data-testid":"live-guest-strip",children:fc.map(e=>wc(e,"h-full w-full"))})]}):ic?(0,X.jsxs)("div",{"data-testid":"comp-focus-inline",className:"flex h-full min-h-0 flex-col gap-2",onTouchStart:e=>{ya.current=e.touches[0].clientX},onTouchEnd:e=>{if(null==ya.current)return;const t=e.changedTouches[0].clientX-ya.current;ya.current=null,Math.abs(t)>50&&_a(t<0?1:-1)},children:[(0,X.jsx)("div",{className:"relative min-h-0 flex-1 cam-square-wrap",children:(0,X.jsxs)("div",{className:"cam-square relative",children:[(0,X.jsx)(Q,{fill:!0,info:ic.info,stream:ic.stream,isSelf:ic.isSelf,muted:ic.isSelf,speaking:no.has(ic.info.user_id),sinkId:oi.selectedDevices.speaker,localMuted:Cs||!!ws[ic.info.user_id],localHidden:!!Ns[ic.info.user_id],onLocalMute:No,onLocalHide:Ao,onProfile:io,onGift:te||ic.isSelf||Ki?void 0:ro,onReconnect:ic.isSelf?void 0:e=>oi.reconnectPeer(e.user_id),voteInfo:Qo(ic.info.user_id),onSpotlight:()=>va(null)},ic.info.user_id),(()=>{const e=nc.filter(e=>no.has(e.info.user_id));return e.length?(0,X.jsx)("div",{"data-testid":"focus-speaking-indicator",className:"absolute left-2 top-2 z-30 flex max-w-[70%] flex-wrap items-center gap-1.5",children:e.map(e=>{const t=e.info.user_id===ic.info.user_id;return(0,X.jsxs)("button",{"data-testid":"focus-speaker-".concat(e.info.user_id),onClick:()=>va(e.info.user_id),title:t?"".concat(e.info.name," ap pale"):"Ale sou ".concat(e.info.name," k ap pale"),className:"flex items-center gap-1.5 rounded-full py-1 pl-1 pr-2.5 text-[11px] font-bold shadow-lg backdrop-blur transition-transform hover:scale-105 ".concat(t?"bg-green-500/90 text-white ring-2 ring-green-300":"bg-black/70 text-white"),children:[(0,X.jsx)("img",{src:e.info.picture,alt:"",className:"h-5 w-5 rounded-full object-cover ring-2 ring-green-400"}),(0,X.jsx)(_.A,{className:"h-3.5 w-3.5 animate-pulse text-green-300"}),(0,X.jsx)("span",{className:"max-w-[90px] truncate",children:e.info.name})]},e.info.user_id)})}):null})(),(0,X.jsxs)("button",{"data-testid":"comp-focus-close",onClick:()=>va(null),title:"Retounen nan gri a",className:"absolute right-3 top-3 z-30 flex h-9 items-center gap-1.5 rounded-full bg-[#FF2A5F] px-3 text-xs font-bold text-white shadow-lg transition-transform hover:scale-105 glow-pink",children:[(0,X.jsx)(L.A,{className:"h-4 w-4"})," Gri"]}),nc.length>1&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("button",{"data-testid":"comp-focus-prev",onClick:()=>_a(-1),title:"Kandida anvan",className:"absolute left-2 top-1/2 z-30 flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white backdrop-blur transition-colors hover:bg-black/70",children:(0,X.jsx)($a.A,{className:"h-6 w-6"})}),(0,X.jsx)("button",{"data-testid":"comp-focus-next",onClick:()=>_a(1),title:"Kandida apre",className:"absolute right-2 top-1/2 z-30 flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full bg-black/50 text-white backdrop-blur transition-colors hover:bg-black/70",children:(0,X.jsx)(Se.A,{className:"h-6 w-6"})}),(0,X.jsxs)("div",{"data-testid":"comp-focus-counter",className:"absolute bottom-2 left-1/2 z-30 -translate-x-1/2 rounded-full bg-black/60 px-3 py-1 text-[11px] font-bold text-white/80 backdrop-blur",children:[sc+1," / ",nc.length," \xb7 Balanse pou chanje"]})]})]})}
1),Zo(ic.info.user_id)&&(0,X.jsx)("div",{className:"mx-auto w-full max-w-md",children:(0,X.jsx)(ae,{voteInfo:Qo(ic.info.user_id),userId:ic.info.user_id})})]}):(0,X.jsx)("div",{className:"grid gap-3",style:Uo.style,"data-testid":"video-grid",children:tc}),(To||ee&&oi.isHost)&&oi.raisedHands.length>0&&(0,X.jsxs)("div",{"data-testid":"raised-hands-panel",className:"absolute left-3 top-12 z-20 w-56 rounded-2xl border border-white/10 bg-black/75 p-3 backdrop-blur-md",children:[(0,X.jsxs)("p",{className:"mb-2 flex items-center gap-1.5 text-xs font-bold uppercase tracking-wide text-[#FFD93D]",children:[(0,X.jsx)(Tn.A,{className:"h-4 w-4"})," ",ee?"Demann kamera":"Men leve"," (",oi.raisedHands.length,")"]}),(0,X.jsx)("div",{className:"max-h-40 space-y-1.5 overflow-y-auto",children:oi.raisedHands.map(e=>(0,X.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,X.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-white",children:e.name}),(0,X.jsx)("button",{"data-testid":"invite-up-".concat(e.user_id),onClick:()=>{oi.inviteUp(e.user_id),u.oR.success("Ou apwouve ".concat(e.name," pou vin sou kamera"))},className:"shrink-0 rounded-full bg-[#00A8CC] px-2.5 py-1 text-[11px] font-bold text-white transition-transform hover:scale-105",children:ee?"Apwouve":"Envite"})]},e.user_id))})]})]}),Vo.length>0&&(0,X.jsxs)("div",{"data-testid":"cam-overflow-strip",className:"relative z-10 mt-2 flex shrink-0 items-center gap-3 overflow-x-auto rounded-2xl bg-black/40 px-3 py-2",children:[(0,X.jsxs)("span",{className:"flex shrink-0 items-center gap-1.5 text-[11px] font-bold uppercase tracking-wide text-[#00F0FF]",children:[(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5 live-dot"})," L\xf2t kamera an dir\xe8k (",Vo.length,")"]}),Vo.map(e=>(0,X.jsxs)("button",{"data-testid":"overflow-cam-".concat(e.info.user_id),onClick:()=>Us(e.info.user_id),title:"Gade kamera ".concat(e.info.name),className:"group flex shrink-0 flex-col items-center gap-1",children:[(0,X.jsxs)("span",{className:"relative",children:[(0,X.jsx)("img",{src:e.info.picture,alt:e.info.name,className:"h-11 w-11 rounded-full object-cover ring-2 ring-[#00F0FF]/50 transition-transform group-hover:scale-110"}),(0,X.jsx)("span",{className:"absolute -bottom-0.5 -right-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-[#FF2A5F] ring-2 ring-[#0b0b12]",children:(0,X.jsx)(B.A,{className:"h-2.5 w-2.5 text-white"})})]}),(0,X.jsx)("span",{className:"max-w-[60px] truncate text-[10px] text-white/80",children:e.info.name})]},e.info.user_id))]}),(0,X.jsxs)("div",{className:"relative z-10 order-first mb-2 flex shrink-0 flex-wrap items-center justify-center gap-3",children:[!te&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("button",{"data-testid":"toggle-audio-btn",onClick:oi.toggleAudio,className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(oi.mediaLocked.audio?"bg-red-500/50 text-white":oi.mediaState.audio?"surface-2 text-white hover:bg-white/10":"bg-red-500/90 text-white"),children:oi.mediaState.audio?(0,X.jsx)(_.A,{className:"h-5 w-5"}):(0,X.jsx)(q.A,{className:"h-5 w-5"})}),(0,X.jsxs)("div",{className:"relative",children:[(0,X.jsx)("button",{"data-testid":"toggle-video-btn",onClick:()=>{Wi?u.oR.error("\ud83c\udfc6 Konpetisyon an sesyon \u2014 s\xe8l moderat\xe8/admin ka limen kamera."):oi.toggleVideo()},disabled:Wi,title:Wi?"Konpetisyon an sesyon \u2014 kamera rez\xe8ve pou estaf":void 0,className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(Wi?"cursor-not-allowed bg-white/5 text-gray-600 opacity-60":oi.mediaLocked.video?"bg-red-500/50 text-white":oi.mediaState.video?"surface-2 text-white hover:bg-white/10":"bg-red-500/90 text-white"),children:oi.mediaState.video?(0,X.jsx)(B.A,{className:"h-5 w-5"}):(0,X.jsx)(U.A,{className:"h-5 w-5"})}),Wi&&(0,X.jsx)("span",{"data-testid":"cam-comp-lock-label",className:"pointer-events-none absolute -bottom-4 left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full bg-[#FFD700]/15 px-1.5 text-[9px] font-bold text-[#FFD700]",children:"\ud83c\udfc6 an sesyon"})]}),((null===w||void 0===w?void 0:w.is_admin)||"admin"===(null===w||void 0===w?void 0:w.role))&&(0,X.jsxs)("button",{"data-testid":"toggle-screen-share-btn",onClick:()=>oi.screenSharing?oi.stopScreenShare():oi.startScreenShare(),title:oi.screenSharing?oi.screenHasAudio?"Kanpe pataj ekran (ak son)":"Kanpe pataj ekran":"Pataje ekran ou ak son paj la (admin s\xe8lman)",className:"relative flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(oi.screenSharing?"bg-[#00F0FF] text-black glow-cyan":"surface-2 text-white hover:bg-white/10"),children:[oi.screenSharing?(0,X.jsx)(Mn.A,{className:"h-5 w-5"}):(0,X.jsx)(P.A,{className:"h-5 w-5"}),oi.screenSharing&&oi.screenHasAudio&&(0,X.jsx)("span",{"data-testid":"screen-audio-badge",title:"Son paj la ap pataje",className:"absolute -right-0.5 -top-0.5 flex h-4 w-4 items-center justify-center rounded-full bg-[#39FF14] text-black ring-2 ring-[#0b0b12]",children:(0,X.jsx)(D.A,{className:"h-2.5 w-2.5"})})]}),((null===w||void 0===w?void 0:w.is_admin)||"admin"===(null===w||void 0===w?void 0:w.role))&&(0,X.jsx)("button",{"data-testid":"toggle-stage-only-btn",onClick:async()=>{try{await d.Ay.post("/admin/stage-only",{enabled:!oi.stageOnly}),u.oR.success(oi.stageOnly?"M\xf2d S\xe8n S\xe8lman DEZAKTIVE":"M\xf2d S\xe8n S\xe8lman AKTIVE \u2014 s\xe8l kamera estaf yo montre")}catch(e){u.oR.error("Er\xe8")}},title:oi.stageOnly?"M\xf2d S\xe8n S\xe8lman aktive \u2014 peze pou montre tout kamera":"Kache kamera itilizat\xe8 yo, montre s\xe8l estaf (pou konpetisyon)",className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(oi.stageOnly?"bg-[#FFD700] text-black":"surface-2 text-white hover:bg-white/10"),children:(0,X.jsx)($.A,{className:"h-5 w-5"})}),((null===w||void 0===w?void 0:w.is_admin)||"admin"===(null===w||void 0===w?void 0:w.role))&&oi.screenSharing&&(0,X.jsx)("button",{"data-testid":"toggle-screen-mirror-btn",onClick:oi.toggleScreenMirror,title:oi.screenMirror?"Retire mirror sou ekran an":"Mirror (retounen) ekran w ap pataje a",className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(oi.screenMirror?"bg-[#7C3AED] text-white glow-pink":"surface-2 text-white hover:bg-white/10"),children:(0,X.jsx)(Cn.A,{className:"h-5 w-5"})}),Ro&&(0,X.jsx)("button",{"data-testid":"toggle-loop-video-btn",onClick:()=>oi.loopVideo?oi.stopLoopVideo():Wt(!0),title:oi.loopVideo?"Kanpe videyo an bouk, tounen sou kamera":"Jwe yon videyo an bouk olye kamera a",className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(oi.loopVideo?"bg-[#00F0FF] text-black glow-cyan":"surface-2 text-white hover:bg-white/10"),children:(0,X.jsx)(Za.A,{className:"h-5 w-5"})}),Ro&&oi.loopVideo&&(0,X.jsx)("button",{"data-testid":"open-live-mixer-btn",onClick:()=>ea(!0),title:"Mikser: melanje kamera + videyo, mirror, volim",className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat(oi.mixActive?"bg-[#7C3AED] text-white glow-pink":"surface-2 text-white hover:bg-white/10"),children:(0,X.jsx)(Pn.A,{className:"h-5 w-5"})}),!oi.mediaState.video&&!ee&&(0,X.jsxs)("button",{"data-testid":"raise-hand-btn",onClick:()=>oi.handRaised?oi.lowerHand():oi.raiseHand(),title:oi.handRaised?"Bese men":"Leve men pou mande yon plas kamera",className:"flex h-11 items-center gap-2 rounded-full px-4 text-sm font-semibold transition-colors ".concat(oi.handRaised?"bg-[#FFD93D] text-black":"surface-2 text-white hover:bg-white/10"),children:[(0,X.jsx)(Tn.A,{className:"h-5 w-5"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:oi.handRaised?"Men leve":"Leve men"})]}),(0,X.jsx)("button",{"data-testid":"open-settings-btn",onClick:()=>{oi.refreshDevices(),Ot(!0)},title:"Param\xe8t kamera & mikwo",className:"flex h-11 w-11 items-center justify-center rounded-full surface-2 text-white transition-colors hover:bg-white/10",children:(0,X.jsx)(Dn.A,{className:"h-5 w-5"})}),(0,X.jsx)("button",{"data-testid":"open-filters-btn",onClick:()=>xa(!0),title:"Filt\xe8 kamera",className:"flex h-11 w-11 items-center justify-center rounded-full transition-colors ".concat("none"!==oi.filterEffect||1!==oi.adjust.brightness||1!==oi.adjust.contrast?"bg-[#FF2A5F] text-white glow-pink":"surface-2 text-white hover:bg-white/10"),children:(0,X.jsx)(Qt.A,{className:"h-5 w-5"})}),(null===w||void 0===w?void 0:w.is_performer)&&(0,X.jsxs)("button",{"data-testid":"ppv-available-toggle",onClick:()=>oi.setPpvAvailable(!oi.ppvAvailable),title:oi.ppvAvailable?"Ou disponib pou PPV \u2014 peze pou f\xe8men":"Vin disponib pou chat prive PPV",className:"flex h-11 items-center gap-2 rounded-full px-4 text-sm font-semibold transition-colors ".concat(oi.ppvAvailable?"bg-[#FFD700] text-black glow-pink":"surface-2 text-white hover:bg-white/10"),children:[(0,X.jsx)(_e.A,{className:"h-5 w-5"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:oi.ppvAvailable?"PPV aktif":"PPV"})]}),To&&(0,X.jsxs)("button",{"data-testid":"open-announce-btn",onClick:()=>Js(!0),title:"Voye yon anons bay tout moun",className:"flex h-11 items-center gap-2 rounded-full bg-[#FFD700] px-4 text-sm font-bold text-black transition-transform hover:scale-105",children:[(0,X.jsx)(be.A,{className:"h-5 w-5"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:"Anons"})]}),To&&(0,X.jsxs)("button",{"data-testid":"open-moderation-lobby-btn",onClick:()=>I("moderation"),title:"Kons\xf2l moderasyon",className:"flex h-11 items-center gap-2 rounded-full bg-green-500 px-4 text-sm font-bold text-white transition-transform hover:scale-105",children:[(0,X.jsx)(R.A,{className:"h-5 w-5"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:"Moderasyon"})]}),((null===w||void 0===w?void 0:w.is_admin)||"admin"===(null===w||void 0===w?void 0:w.role))&&(0,X.jsxs)("button",{"data-testid":"toggle-invisible-btn",onClick:()=>oi.setInvisible(!oi.invisible),title:oi.invisible?"Ou envizib \u2014 peze pou vin vizib":"Vin envizib (l\xf2t moun p ap w\xe8 ou)",className:"flex h-11 items-center gap-2 rounded-full px-4 text-sm font-semibold transition-colors ".concat(oi.invisible?"bg-[#7C3AED] text-white glow-pink":"surface-2 text-white hover:bg-white/10"),children:[oi.invisible?(0,X.jsx)(C.A,{className:"h-5 w-5"}):(0,X.jsx)(O.A,{className:"h-5 w-5"}),(0,X.jsx)("span",{className:"hidden sm:inline",children:oi.invisible?"Envizib":"Envizib?"})]}),(0,X.jsx)("div",{className:"mx-1 h-8 w-px bg-white/10"})]}),te&&(0,X.jsxs)("span",{"data-testid":"guest-badge",className:"flex items-center gap-1.5 rounded-full bg-white/10 px-3 py-1.5 text-xs font-semibold text-gray-300",children:[(0,X.jsx)(O.A,{className:"h-4 w-4"})," M\xf2d envite \u2014 chat s\xe8lman"]}),Vo.length>0&&(0,X.jsxs)("button",{"data-testid":"overflow-count-badge",onClick:()=>
1Us(Vo[0].info.user_id),title:"L\xf2t kamera an dir\xe8k anba a \u2014 peze pou gade",className:"flex h-11 items-center gap-1.5 rounded-full bg-[#00F0FF]/15 px-4 text-sm font-bold text-[#00F0FF] transition-colors hover:bg-[#00F0FF]/25",children:[(0,X.jsx)(B.A,{className:"h-4 w-4"})," +",Vo.length," ap tann ",(0,X.jsx)(Na.A,{className:"h-4 w-4"})]}),!te&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)("div",{className:"mx-1 hidden h-8 w-px bg-white/10 sm:block"}),(0,X.jsxs)("div",{className:"flex items-center gap-1 sm:gap-1.5","data-testid":"reactions-bar",children:[oi.isHost&&ee&&(0,X.jsxs)("button",{"data-testid":"force-mute-all-guests-btn",onClick:()=>{const e=Object.values(oi.peers).filter(e=>{var t,a;return(null===(t=e.info)||void 0===t||null===(a=t.media)||void 0===a?void 0:a.audio)&&e.info.user_id!==(null===w||void 0===w?void 0:w.user_id)});0!==e.length?(e.forEach(e=>oi.forceMedia(e.info.user_id,{audio:!1})),u.oR.success("Ou f\xe8men mikwo ".concat(e.length," envite").concat((e.length,"")))):u.oR.info("Pa gen envite k ap pale kounye a")},title:"F\xe8men mikwo tout envite (pou tout moun)",className:"flex h-9 shrink-0 items-center gap-1.5 rounded-full bg-[#FF2A5F]/15 px-3 text-xs font-bold text-[#FF2A5F] transition-colors hover:bg-[#FF2A5F]/25 sm:h-10",children:[(0,X.jsx)(q.A,{className:"h-4 w-4"})," ",(0,X.jsx)("span",{className:"hidden sm:inline",children:"Silans envite"})]}),(0,X.jsx)("button",{"data-testid":"toggle-mute-all-btn",onClick:()=>{Ss(e=>{const t=!e;return u.oR.info(t?"Ou f\xe8men son tout moun (pou ou s\xe8lman)":"Ou louvri son tout moun"),t})},title:Cs?"Louvri son tout moun":"Silans tout moun",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors sm:h-10 sm:w-10 ".concat(Cs?"bg-[#FF2A5F] text-white glow-pink":"surface-2 text-white hover:bg-white/10"),children:Cs?(0,X.jsx)(V.A,{className:"h-5 w-5"}):(0,X.jsx)(D.A,{className:"h-5 w-5"})}),(0,X.jsx)("button",{"data-testid":"toggle-sound-fx-btn",onClick:()=>{const e=!Ts;!function(e){x=!!e;try{localStorage.setItem("htv_sounds_muted",x?"1":"0")}catch(t){}}(e),Ms(e),u.oR.info(e?"Son ef\xe8 yo f\xe8men \ud83d\udd15":"Son ef\xe8 yo louvri \ud83d\udd14")},title:Ts?"Limen son antre & reyaksyon":"F\xe8men son antre & reyaksyon",className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full transition-colors sm:h-10 sm:w-10 ".concat(Ts?"bg-[#FF2A5F] text-white glow-pink":"surface-2 text-white hover:bg-white/10"),children:Ts?(0,X.jsx)(In.A,{className:"h-5 w-5"}):(0,X.jsx)(Ln.A,{className:"h-5 w-5"})}),yi.map(e=>(0,X.jsx)("button",{"data-testid":"reaction-btn-".concat(e),onClick:()=>(e=>{ni(e,null===w||void 0===w?void 0:w.name),p(e),oi.sendReaction(e)})(e),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full surface-2 text-lg transition-transform hover:scale-125 active:scale-95 sm:h-10 sm:w-10 sm:text-xl",title:"Voye reyaksyon",children:e},e))]})]})]}),oi.screenSharing&&oi.screenHasAudio&&(0,X.jsxs)("div",{"data-testid":"screen-audio-balance",className:"mt-2 flex flex-col gap-2 rounded-2xl border border-[#39FF14]/30 bg-black/40 p-3 sm:flex-row sm:items-center sm:gap-5",children:[(0,X.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-bold uppercase tracking-wide text-[#39FF14]",children:[(0,X.jsx)(D.A,{className:"h-4 w-4"})," Balans son pataj"]}),(0,X.jsxs)("label",{className:"flex flex-1 items-center gap-2 text-xs font-semibold text-gray-300",children:[(0,X.jsx)(P.A,{className:"h-4 w-4 shrink-0 text-[#00F0FF]"})," Son paj",(0,X.jsx)("input",{"data-testid":"screen-page-volume",type:"range",min:0,max:1,step:.05,value:oi.screenPageVol,onChange:e=>oi.setScreenPageVolume(e.target.value),className:"h-1.5 flex-1 cursor-pointer accent-[#00F0FF]"}),(0,X.jsxs)("span",{className:"w-8 shrink-0 text-right tabular-nums text-gray-400",children:[Math.round(100*oi.screenPageVol),"%"]})]}),(0,X.jsxs)("label",{className:"flex flex-1 items-center gap-2 text-xs font-semibold text-gray-300",children:[(0,X.jsx)(_.A,{className:"h-4 w-4 shrink-0 text-[#FF2A5F]"})," Vwa w",(0,X.jsx)("input",{"data-testid":"screen-mic-volume",type:"range",min:0,max:1,step:.
105,value:oi.screenMicVol,onChange:e=>oi.setScreenMicVolume(e.target.value),className:"h-1.5 flex-1 cursor-pointer accent-[#FF2A5F]"}),(0,X.jsxs)("span",{className:"w-8 shrink-0 text-right tabular-nums text-gray-400",children:[Math.round(100*oi.screenMicVol),"%"]})]})]})]}),(0,X.jsx)("div",{id:"desktop-chat-area",className:"hidden min-h-0 lg:block",children:(0,X.jsx)(Kt,{speakingIds:no,self:eo,selfUserId:null===w||void 0===w?void 0:w.user_id,peers:oi.peers,lobbyMessages:oi.lobbyMessages,dmMessages:oi.dmMessages,onSend:oi.sendChat,onDeleteMessage:oi.deleteMessage,onReact:oi.reactChat,onSelectDm:po,onStartCall:oi.startGroupCall,canCall:!te,busyPeers:oi.busyPeers,friends:Fi,onAddFriend:vo,onRemoveFriend:bo,members:co,serverUnread:Pi,onReadDm:$l,canRecord:!te,ppvPeers:oi.ppvPeers,onRequestPpv:Tt,dmRequest:K,onDmOpened:H,freshMedia:zi,onGift:te?void 0:e=>Ct(e),onProfile:io,showFlags:!1!==(null===N||void 0===N?void 0:N.country_flags_enabled),pinnedAd:Ol,channelMessages:oi.channelMessages,channelCounts:oi.channelCounts,channelActivity:oi.channelActivity,onJoinChannel:oi.joinChannel,onLeaveChannel:oi.leaveChannel,onLoadChannel:fo,onClearActivity:go,typingIds:oi.typingIds,onTyping:oi.sendTyping,poll:oi.poll,myPollVotes:oi.myPollVotes,onVotePoll:oi.votePoll,isGuest:te,onGoLive:Y,onUpload:te?void 0:()=>rt(!0),hostId:ee?di:null,liveMode:ee,guestChatUsed:Pe.used,guestChatLimit:Pe.limit,onGuestUpgrade:oo})})]}),(0,X.jsx)("nav",{"data-testid":"lobby-footer-links",className:"shrink-0 pt-1.5 pb-12 lg:pb-2",children:(0,X.jsxs)("div",{className:"flex items-center justify-center gap-x-4 gap-y-1 overflow-x-auto whitespace-nowrap px-3 text-[11px] text-gray-500 lg:flex-wrap lg:overflow-visible lg:whitespace-normal",children:[(0,X.jsx)(r.N_,{to:"/a-propos","data-testid":"footer-link-about",className:"shrink-0 hover:text-white hover:underline",children:"Kons\xe8nan"}),(0,X.jsx)(r.N_,{to:"/faq","data-testid":"footer-link-faq",className:"shrink-0 hover:text-white hover:underline",children:"FAQ"}),(0,X.jsx)(r.N_,{to:"/blog","data-testid":"footer-link-blog",className:"shrink-0 hover:text-white hover:underline",children:"Blog"}),(0,X.jsx)(r.N_,{to:"/istwa-konpetisyon","data-testid":"footer-link-competition",className:"shrink-0 hover:text-white hover:underline",children:"Konpetisyon"}),(0,X.jsx)(r.N_,{to:"/privacy","data-testid":"footer-link-privacy",className:"shrink-0 hover:text-white hover:underline",children:"Konfidansyalite"}),(0,X.jsx)(r.N_,{to:"/terms","data-testid":"footer-link-terms",className:"shrink-0 hover:text-white hover:underline",children:"Kondisyon"}),(0,X.jsx)(r.N_,{to:"/data-deletion","data-testid":"footer-link-data-deletion",className:"shrink-0 hover:text-white hover:underline",children:"Efase done"}),(0,X.jsx)(r.N_,{to:"/login","data-testid":"footer-link-login",className:"shrink-0 font-semibold text-[#00F0FF] hover:underline",children:"Konekte"})]})})]}),ac&&(0,X.jsxs)("div",{"data-testid":"cam-popup",className:"fixed bottom-24 right-4 z-[70] w-[320px] max-w-[85vw] overflow-hidden rounded-2xl border border-[#00F0FF]/40 bg-[#0b0b12] shadow-2xl sm:bottom-6",children:[(0,X.jsxs)("div",{className:"flex items-center justify-between gap-2 border-b border-white/10 bg-black/60 px-3 py-2",children:[(0,X.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5 text-xs font-bold text-white",children:[(0,X.jsx)(ne.A,{className:"h-3.5 w-3.5 live-dot text-[#FF2A5F]"})," ",(0,X.jsx)("span",{className:"truncate",children:ac.info.name})]}),(0,X.jsx)("button",{"data-testid":"cam-popup-close",onClick:()=>Us(null),title:"F\xe8men",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-full surface-2 text-white hover:bg-white/10",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsx)("div",{className:"aspect-video w-full",children:(0,X.jsx)(Q,{fill:!0,info:ac.info,stream:ac.stream,muted:!1,speaking:no.has(ac.info.user_id),sinkId:oi.selectedDevices.speaker,localMuted:Cs||!!ws[ac.info.user_id],localHidden:!!Ns[ac.info.user_id],onLocalMute:No,onLocalHide:Ao,onGift:te?void 0:ro,onProfile:io,onReconnect:e=>oi.reconnectPeer(e.user_id)})})]}),(0,X.jsxs)("div",{"data-testid":"mobile-chat-sheet",className:"fixed inset-x-0 bottom-0 z-[60] flex h-[68vh
1] flex-col transition-transform duration-300 ease-out lg:hidden ".concat(sa?"translate-y-[calc(100%-2.75rem)]":"translate-y-0"),children:[(0,X.jsx)("button",{"data-testid":"chat-swipe-handle",onClick:()=>la(e=>!e),onTouchStart:e=>{ca.current=e.touches[0].clientY},onTouchEnd:e=>{if(null==ca.current)return;const t=e.changedTouches[0].clientY-ca.current;t>40?la(!0):t<-40&&la(!1),ca.current=null},className:"mx-auto flex h-11 w-40 shrink-0 items-center justify-center gap-2 rounded-t-2xl bg-black/50 backdrop-blur-md",title:sa?"Rale monte pou chat":"Rale desann pou w\xe8 kamera",children:sa?(0,X.jsx)(ka.A,{className:"h-4 w-4 text-white/80"}):(0,X.jsx)("span",{className:"h-1.5 w-12 rounded-full bg-white/70"})}),(0,X.jsx)("div",{className:"min-h-0 flex-1 pb-safe",children:(0,X.jsx)(Kt,{mobile:!0,speakingIds:no,self:eo,selfUserId:null===w||void 0===w?void 0:w.user_id,peers:oi.peers,lobbyMessages:oi.lobbyMessages,dmMessages:oi.dmMessages,onSend:oi.sendChat,onDeleteMessage:oi.deleteMessage,onReact:oi.reactChat,onSelectDm:po,onStartCall:oi.startGroupCall,canCall:!te,busyPeers:oi.busyPeers,friends:Fi,onAddFriend:vo,onRemoveFriend:bo,members:co,serverUnread:Pi,onReadDm:$l,canRecord:!te,ppvPeers:oi.ppvPeers,onRequestPpv:Tt,dmRequest:K,onDmOpened:H,freshMedia:zi,onGift:te?void 0:e=>Ct(e),onProfile:io,showFlags:!1!==(null===N||void 0===N?void 0:N.country_flags_enabled),pinnedAd:Ol,channelMessages:oi.channelMessages,channelCounts:oi.channelCounts,channelActivity:oi.channelActivity,onJoinChannel:oi.joinChannel,onLeaveChannel:oi.leaveChannel,onLoadChannel:fo,onClearActivity:go,typingIds:oi.typingIds,onTyping:oi.sendTyping,poll:oi.poll,myPollVotes:oi.myPollVotes,onVotePoll:oi.votePoll,isGuest:te,onGoLive:Y,onUpload:te?void 0:()=>rt(!0),hostId:ee?di:null,liveMode:ee,guestChatUsed:Pe.used,guestChatLimit:Pe.limit,onGuestUpgrade:oo})})]}),(0,X.jsx)(Ht.n,{open:!!_t,onOpenChange:e=>!e&&Ct(null),recipient:_t,gifts:le,balance:null!==(g=null===w||void 0===w?void 0:w.tokens)&&void 0!==g?g:0,onSend:async e=>{const t=_t;Ct(null);await mo(e,t)&&(Jn({gift:e,target:t,count:1}),ho())},onBuyTokens:()=>I("wallet")}),(0,X.jsx)(Qa,{open:it,onClose:()=>rt(!1),onUploaded:()=>Yl()}),!te&&(0,X.jsx)(sn,{}),tt&&(0,X.jsxs)("div",{className:"fixed inset-0 z-[85] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm","data-testid":"post-compose-modal",onClick:()=>!gt&&at(!1),children:["          ",(0,X.jsxs)("div",{className:"w-full max-w-md rounded-3xl glass p-6",onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)("div",{className:"flex items-center justify-between",children:[(0,X.jsxs)("h2",{className:"flex items-center gap-2 font-display text-lg font-bold text-white",children:[(0,X.jsx)(Aa.A,{className:"h-5 w-5 text-[#FF2A5F]"})," Nouvo p\xf2s"]}),(0,X.jsx)("button",{onClick:()=>at(!1),className:"text-gray-400 hover:text-white",children:(0,X.jsx)(ge.A,{className:"h-5 w-5"})})]}),(0,X.jsx)("textarea",{"data-testid":"lobby-post-text",value:ct,onChange:e=>dt(e.target.value),maxLength:600,rows:4,autoFocus:!0,placeholder:"Ki sa k ap pase?",className:"mt-4 w-full resize-none rounded-xl bg-black/30 p-3 text-sm text-white placeholder:text-gray-500 outline-none ring-1 ring-white/10 focus:ring-[#FF2A5F]/50"}),ht&&(0,X.jsxs)("div",{className:"relative mt-2 inline-block",children:[(0,X.jsx)("img",{src:"".concat("https://haitipal.com").concat(ht),alt:"",className:"max-h-40 rounded-xl"}),(0,X.jsx)("button",{"data-testid":"download-photo-btn",onClick:async()=>{if(ht)try{const e=await fetch("".concat("https://haitipal.com").concat(ht)),t=await e.blob(),a=URL.createObjectURL(t),n=document.createElement("a");n.href=a,n.download="haitipal-chat-".concat(Date.now(),".png"),document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(a),u.oR.success("Foto telechaje sou apar\xe8y ou!")}catch(e){u.oR.error("Nou pa ka telechaje foto a")}},title:"Telechaje foto a sou apar\xe8y ou (san pibliye l)",className:"absolute -left-2 -top-2 rounded-full bg-[#00F0FF] p-1.5 text-black shadow-lg transition-transform hover:scale-110",children:(0,X.jsx)(zn.A,{className:"h-4 w-4"})}),(0,X.jsx)("button",{onClick:()=>xt(""),className:"absolute -right-2 -top-2 rounded-full bg-black/70 p-1 text-white",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),(0,X.jsxs)("div",{className:"mt-4 flex items-center justify-between",children:[(0,X.jsxs)("button",{"data-testid":"lobby-post-image-btn",onClick:()=>{var e;return null===(e=Nt.current)||void 0===e?void 0:e.click()},disabled:yt,className:"flex items-center gap-1.5 rounded-full surface-2 px-3 py-1.5 text-xs font-semibold text-gray-300 ring-1 ring-white/10 hover:bg-white/10 disabled:opacity-50",children:[yt?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(We.A,{className:"h-4 w-4"})," Foto"]}),(0,X.jsx)("input",{ref:Nt,type:"file",accept:"image/*",className:"hidden",onChange:async e=>{var t;const a=null===(t=e.target.files)||void 0===t?void 0:t[0];if(a){kt(!0);try{const e=new FormData;e.append("file",a);const t=(await d.Ay.post("/uploads/chat",e,{headers:{"Content-Type":"multipart/form-data"}})).data;xt(t.url)}catch(n){u.oR.error("Nou pa ka telechaje foto a")}finally{kt(!1),Nt.current&&(Nt.current.value="")}}}}),(0,X.jsxs)("button",{"data-testid":"lobby-post-submit",onClick:async()=>{const e=ct.trim();if(e){bt(!0);try{await d.Ay.post("/profile/posts",{text:e,image_url:ht||null}),dt(""),xt(""),at(!1),u.oR.success("P\xf2s pibliye!")}catch(n){var t,a;u.oR.error((0,d.KI)(null===(t=n.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail)||"Nou pa ka pibliye p\xf2s la")}finally{bt(!1)}}},disabled:gt||!ct.trim(),className:"flex items-center gap-1.5 rounded-full bg-[#FF2A5F] px-5 py-2 text-sm font-bold text-white transition-transform hover:scale-105 disabled:opacity-50",children:[gt?(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin"}):(0,X.jsx)(He.A,{className:"h-4 w-4"})," Pibliye"]})]})]})]}),Et&&(0,X.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm","data-testid":"ppv-confirm-modal",onClick:()=>Tt(null),children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl glass p-7 text-center",onClick:e=>e.stopPropagation(),children:[(0,X.jsx)("div",{className:"mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-[#FFD700]/15 ring-4 ring-[#FFD700]/30",children:(0,X.jsx)("img",{src:Et.picture||"/haitipal-logo.png",alt:"",className:"h-16 w-16 rounded-full object-cover"})}),(0,X.jsxs)("p",{className:"mt-4 flex items-center justify-center gap-1.5 text-[11px] font-bold uppercase tracking-widest text-[#FFD700]",children:[(0,X.jsx)(_e.A,{className:"h-4 w-4"})," Chat prive PPV"]}),(0,X.jsx)("h2",{className:"mt-1 font-display text-2xl font-extrabold text-white","data-testid":"ppv-confirm-name",children:Et.name}),Et.ppv_bio?(0,X.jsxs)("p",{className:"mt-3 rounded-2xl bg-white/5 p-3 text-sm text-gray-200","data-testid":"ppv-confirm-bio",children:["\u201c",Et.ppv_bio,"\u201d"]}
1):(0,X.jsx)("p",{className:"mt-3 text-sm text-gray-400",children:"P\xe8f\xf2m\xe8 sa a pa mete yon bio."}),(0,X.jsxs)("p",{className:"mt-4 text-sm text-gray-300",children:["Tarif: ",(0,X.jsxs)("b",{className:"text-[#FFD700]",children:[Et.ppv_rate||20," jeton/minit"]}),". Premye minit lan chaje kounye a."]}),(0,X.jsxs)("div",{className:"mt-6 flex gap-3",children:[(0,X.jsx)("button",{"data-testid":"ppv-confirm-cancel-btn",onClick:()=>Tt(null),className:"flex-1 rounded-full surface-2 px-4 py-3 text-sm font-bold text-white hover:bg-white/10",children:"Anile"}),(0,X.jsx)("button",{"data-testid":"ppv-confirm-start-btn",onClick:()=>{oi.requestPpv(Et),Tt(null)},className:"flex-1 rounded-full bg-[#FFD700] px-4 py-3 text-sm font-bold text-black transition-transform hover:scale-105",children:"K\xf2manse"})]})]})}),Gs&&(0,X.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm","data-testid":"announce-modal",onClick:()=>!ti&&Js(!1),children:(0,X.jsxs)("div",{className:"w-full max-w-md rounded-3xl glass p-6",onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)("div",{className:"flex items-center gap-2",children:[(0,X.jsx)("span",{className:"flex h-10 w-10 items-center justify-center rounded-2xl bg-[#FFD700]/15 text-[#FFD700]",children:(0,X.jsx)(be.A,{className:"h-5 w-5"})}),(0,X.jsxs)("div",{children:[(0,X.jsx)("h2",{className:"font-display text-2xl font-extrabold text-white",children:"Voye yon anons"}),(0,X.jsx)("p",{className:"text-xs text-gray-400",children:"L ap par\xe8t nan chat piblik la epi nan DM tout manm yo."})]})]}),(0,X.jsx)("textarea",{"data-testid":"announce-textarea",value:Zs,onChange:e=>Qs(e.target.value),maxLength:2e3,rows:4,placeholder:"Ekri anons ou an\u2026",className:"mt-4 w-full resize-none rounded-2xl surface-2 px-4 py-3 text-sm text-white placeholder:text-gray-500 outline-none ring-1 ring-white/10 focus:ring-[#FFD700]/50"}),(0,X.jsxs)("div",{className:"mt-4 flex gap-3",children:[(0,X.jsx)("button",{"data-testid":"announce-cancel-btn",onClick:()=>Js(!1),disabled:ti,className:"flex-1 rounded-full surface-2 px-4 py-3 text-sm font-bold text-white hover:bg-white/10 disabled:opacity-50",children:"Anile"}),(0,X.jsx)("button",{"data-testid":"send-announce-btn",onClick:async()=>{const e=Zs.trim();if(e){ai(!0);try{const t=(await d.Ay.post("/announce",{text:e})).data;u.oR.success("Anons voye nan chat piblik la ak DM ".concat(t.recipients," manm")),Qs(""),Js(!1)}catch(n){var t,a;u.oR.error((0,d.KI)(null===(t=n.response)||void 0===t||null===(a=t.data)||void 0===a?void 0:a.detail))}finally{ai(!1)}}},disabled:ti||!Zs.trim(),className:"flex flex-1 items-center justify-center gap-2 rounded-full bg-[#FFD700] px-4 py-3 text-sm font-bold text-black transition-transform hover:scale-105 disabled:opacity-50",children:ti?(0,X.jsx)(ve.A,{className:"h-5 w-5 animate-spin"}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(be.A,{className:"h-4 w-4"})," Voye bay tout moun"]})})]})]})}),(0,X.jsx)(Xt,{gifts:pe}),(0,X.jsx)(Zt,{open:ze,onClose:()=>Ve(!1),onUpgrade:Qe,limit:Pe.limit}),(0,X.jsx)($t,{open:Be,onClose:()=>Ue(!1),amount:100}),(0,X.jsx)(aa,{open:!!Je,onClose:()=>Ze(null===Je||void 0===Je?void 0:Je.id),amount:null===Je||void 0===Je?void 0:Je.amount_usd,note:null===Je||void 0===Je?void 0:Je.note}),ar&&(0,X.jsx)(Pa,{quiz:ar,onAnswer:Jl,selfUserId:null===w||void 0===w?void 0:w.user_id,selfPicture:null===w||void 0===w?void 0:w.picture,onGoProfile:()=>S("/profile"),onClose:()=>nr(null),onLeaveSession:Yr,muted:zr,onToggleMute:Qr,volume:Br,onVolumeChange:$r}),rr&&!ar&&(0,X.jsxs)("button",{"data-testid":"jenipal-rejoin-btn",onClick:Zr,className:"fixed bottom-24 right-4 z-[60] flex items-center gap-2 rounded-full bg-gradient-to-r from-[#7C3AED] to-[#00A8CC] px-4 py-2.5 text-sm font-black text-white shadow-[0_0_20px_rgba(124,58,237,0.6)] transition-transform hover:scale-105 sm:bottom-6",children:[(0,X.jsx)(Qt.A,{className:"h-4 w-4"})," Rejwenn JeniPal"]}),(0,X.jsx)(Da,{notice:dr,onClose:()=>ur(null),onOptOut:Xr}),(0,X.jsx)(qa,{celebration:Fr,onDone:()=>_r(null),selfUserId:null===w||void 0===w?void 0:w.user_id}),(0,X.jsx)(Oa,{open:yr,onClose:()=>kr(!1)}),(0,X.jsx)(Ha,{results:Rr,selfUserId:null===w||void 0===w?void 0:w.user_id,onClose:()=>Er(null)}),(0,X.jsx)(Wa,{endsAt:null===Bi||void 0===Bi?void 0:Bi.ends_at,active:!!Bi&&"ended"!==Bi.status}),(0,X.jsx)(rn,{startAt:Al,title:null===il||void 0===il?void 0:il.title,onDone:()=>Fl(null)}),il&&!gl&&!cl&&!jl&&(0,X.jsxs)("div",{className:"fixed z-[110] top-16 right-3 flex items-center gap-1.5 sm:bottom-6 sm:left-4 sm:right-auto sm:top-auto",children:[(0,X.jsxs)("button",{"data-testid":"competition-register-fab",onClick:()=>vl(!0),className:"flex items-center gap-2 rounded-full bg-gradient-to-r from-[#FF2A5F] to-[#FFD700] px-4 py-2.5 text-sm font-bold text-white shadow-xl transition-transform hover:scale-105",children:[(0,X.jsx)($.A,{className:"h-4 w-4"})," Enskri"]}),(0,X.jsx)("button",{"data-testid":"competition-register-fab-dismiss",onClick:()=>yl(!0),title:"Retire",className:"flex h-8 w-8 items-center justify-center rounded-full bg-black/60 text-white shadow-lg transition-colors hover:bg-black/80",children:(0,X.jsx)(ge.A,{className:"h-4 w-4"})})]}),gl&&(0,X.jsx)(Ya,{schedule:il,myStatus:cl,isGuest:te,me:w,onClose:Cl,onReg
1istered:e=>{dl(e)}}),hl&&(0,X.jsx)("div",{"data-testid":"competition-rejected-popup",className:"fixed inset-0 z-[130] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm",onClick:()=>xl(null),children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl border border-red-500/30 bg-[#12121a] p-6 text-center shadow-2xl",onClick:e=>e.stopPropagation(),children:[(0,X.jsx)("div",{className:"mx-auto mb-3 flex h-14 w-14 items-center justify-center rounded-full bg-red-500/15",children:(0,X.jsx)(ge.A,{className:"h-7 w-7 text-red-400"})}),(0,X.jsx)("h3",{className:"font-display text-xl font-black text-white",children:"Enskripsyon w lan pa apwouve"}),(0,X.jsx)("p",{className:"mt-2 text-sm text-gray-300",children:"Malerezman, admin nan pa apwouve enskripsyon w lan pou konpetisyon sa a."}),hl.reason&&(0,X.jsxs)("div",{className:"mt-3 rounded-xl bg-red-500/10 p-3 text-left ring-1 ring-red-500/25",children:[(0,X.jsx)("p",{className:"text-[11px] font-bold uppercase tracking-wide text-red-400",children:"Rezon"}),(0,X.jsx)("p",{className:"mt-1 text-sm text-white",children:hl.reason})]}),(0,X.jsx)("button",{"data-testid":"competition-rejected-ok",onClick:()=>xl(null),className:"mt-5 w-full rounded-full bg-white/10 px-4 py-2.5 text-sm font-bold text-white transition-colors hover:bg-white/20",children:"Konprann"})]})}),El&&(0,X.jsxs)("div",{"data-testid":"reconnecting-indicator",className:"fixed left-1/2 top-4 z-[130] flex -translate-x-1/2 items-center gap-2 rounded-full border border-white/15 bg-black/80 px-4 py-2 text-sm font-semibold text-white shadow-xl backdrop-blur-md",children:[(0,X.jsx)(ve.A,{className:"h-4 w-4 animate-spin text-[#FFD700]"}),"K ap rekonekte\u2026"]}),_n&&(0,X.jsx)("div",{className:"fixed inset-0 z-[85] flex items-center justify-center bg-black/75 p-4 backdrop-blur-sm","data-testid":"live-stats-modal",children:(0,X.jsxs)("div",{className:"w-full max-w-md rounded-3xl border border-white/10 bg-[#12121a] p-6 text-center",children:[(0,X.jsx)("div",{className:"mx-auto flex h-14 w-14 items-center justify-center rounded-full bg-[#FF2A5F]/15",children:(0,X.jsx)(ne.A,{className:"h-7 w-7 text-[#FF2A5F]"})}),(0,X.jsx)("h2",{className:"mt-3 font-display text-2xl font-extrabold text-white",children:"Dir\xe8k ou a fini! \ud83c\udf89"}),(0,X.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Men rezilta dir\xe8k ou a:"}),(0,X.jsxs)("div",{className:"mt-5 grid grid-cols-3 gap-3",children:[(0,X.jsxs)("div",{className:"rounded-2xl bg-white/[0.04] p-4",children:[(0,X.jsx)("p",{className:"font-display text-3xl font-black text-[#00F0FF]","data-testid":"stat-viewers",children:_n.viewers}),(0,X.jsx)("p",{className:"mt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Moun te gade"})]}),(0,X.jsxs)("div",{className:"rounded-2xl bg-white/[0.04] p-4",children:[(0,X.jsx)("p",{className:"font-display text-3xl font-black text-[#FF6B93]","data-testid":"stat-new-followers",children:_n.new_followers}),(0,X.jsx)("p",{className:"mt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:"Nouvo swiv\xe8"})]}),(0,X.jsxs)("div",{className:"rounded-2xl bg-white/[0.04] p-4",children:[(0,X.jsx)("p",{className:"font-display text-3xl font-black text-[#FFD700]","data-testid":"stat-gifts",children:_n.gifts_count}),(0,X.jsxs)("p",{className:"mt-1 text-[11px] font-semibold uppercase tracking-wide text-gray-400",children:["Kado",_n.gifts_tokens?" \xb7 ".concat(_n.gifts_tokens," jeton"):""]})]})]}),(0,X.jsx)("button",{"data-testid":"live-stats-close-btn",onClick:()=>{Rn(null),S("/lobby")},className:"mt-6 h-12 w-full rounded-full bg-[#FF2A5F] font-bold text-white glow-pink transition-transform hover:scale-[1.01]",children:"Retounen nan lakou"})]})}),Il&&(0,X.jsx)(cn,{}),an&&(0,X.jsx)("div",{className:"fixed inset-0 z-[80] flex items-center justify-center bg-black/70 p-4 backdrop-blur-sm","data-testid":"end-live-modal",onClick:()=>nn(!1),children:(0,X.jsxs)("div",{className:"w-full max-w-md rounded-3xl border border-white/10 bg-[#12121a] p-6",onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)("h2",{className:"flex items-center gap-2 font-display text-xl font-extrabold text-white",children:[(0,X.jsx)(ne.A,{className:"h-5 w-5 text-[#FF2A5F] live-dot"})," Fini dir\xe8k la?"]}),(0,X.jsx)("p",{className:"mt-1 text-sm text-gray-400",children:"Ou ka voye yon ti n\xf2t bay tout swiv\xe8 ou yo (opsyon\xe8l)."}),(0,X.jsx)("textarea",{"data-testid":"end-live-note-input",value:wn,onChange:e=>yn(e.target.value.slice(0,200)),rows:3,maxLength:200,placeholder:"Egz: M\xe8si anpil! M ap tounen demen menm l\xe8 a. \ud83d\ude4f",className:"mt-3 w-full rounded-2xl bg-[#1c1c26] [html.light_&]:bg-white p-3 text-sm text-white outline-none ring-1 ring-white/10 focus:ring-2 focus:ring-[#FF2A5F]/50"}),(0,X.jsxs)("div",{className:"mt-1 text-right text-[11px] text-gray-500",children:[wn.length,"/200"]}),(0,X.jsxs)("div",{className:"mt-3 flex gap-2",children:[(0,X.jsx)("button",{"data-testid":"end-live-cancel-btn",onClick:()=>nn(!1),className:"flex-1 rounded-full surface-2 px-4 py-3 text-sm font-bold text-white hover:bg-white/10",children:"Anile"}),(0,X.jsx)("button",{"data-testid":"end-live-confirm-btn",onClick:pi,className:"flex-1 rounded-full bg-[#FF2A5F] px-4 py-3 text-sm font-bold text-white glow-pink",children:"Fini dir\xe8k la"})]})]})}),un&&(0,X.jsx)("div",{className:"fixed inset-0 z-[95] flex items-center justify-center bg-black/80 p-4 backdrop-blur-sm","data-testid":"host-idle-warning",children:(0,X.jsxs)("div",{className:"w-full max-w-sm rounded-3xl border border-[#FFD700]/40 bg-[#12121a] p-6 text-center",children:[(0,X.jsx)("div",{className:"mx-auto mb-3 flex h-16 w-16 items-center justify-center rounded-full bg-[#FFD700]/15",children:(0,X.jsx)(ne.A,{className:"h-8 w-8 text-[#FFD700] live-dot"})}),(0,X.jsx)("h2",{className:"font-display text-xl font-extrabold text-white",children:"Ou la toujou?"}),(0,X.jsx)("p",{className:"mt-2 text-sm text-gray-400",children:"Nou pa w\xe8 okenn aktivite. Dir\xe8k ou a ap f\xe8men otomatikman nan"}),(0,X.jsxs)("p",{className:"my-2 font-display text-4xl font-black text-[#FFD700]","data-testid":"host-idle-countdown",children:[fn,"s"]}),(0,X.jsx)("button",{"data-testid":"host-idle-stay-btn",onClick:()=>{fi.current=Date.now(),hn(!1)},className:"mt-2 w-full rounded-full bg-[#FF2A5F] px-4 py-3 text-sm font-bold text-white glow-pink transition-transform hover:scale-[1.02]",children:"Wi, m la \u2014 kontinye dir\xe8k la"}),(0,X.jsx)("button",{"data-testid":"host-idle-end-btn",onClick:()=>{hn(!1),pi()},className:"mt-2 w-full rounded-full surface-2 px-4 py-2.5 text-sm font-bold text-gray-300 hover:bg-white/10",children:"Fini dir\xe8k la kounye a"})]})}),(0,X.jsx)(oa,{combo:Gn,onAgain:async()=>
1{if(!Gn)return;if(await mo(Gn.gift,Gn.target)){const e=Gn.count+1;Jn(t=>(0,n.A)((0,n.A)({},t),{},{count:e})),ho(),d.Ay.post("/combos/report",{gift_id:Gn.gift.id,count:e}).then(()=>{ls.current=!0,ki()}).catch(()=>{})}else xo()},onClose:xo}),(0,X.jsx)(ra,{open:Dt,onOpenChange:It}),(0,X.jsx)(ma,{open:Vt,onOpenChange:Ot,devices:oi.devices,selectedDevices:oi.selectedDevices,onCamera:oi.switchCamera,onMic:oi.switchMic,onSpeaker:oi.switchSpeaker,onRefresh:oi.refreshDevices,bgEffect:oi.bgEffect,onBackground:oi.applyBackground,customBgUrl:oi.customBgUrl,onUploadBackground:oi.uploadBackground,onRemoveBackground:oi.removeBackground}),(0,X.jsx)(wa,{open:ha,onOpenChange:xa,filterEffect:oi.filterEffect,onFilter:oi.applyFilter,adjust:oi.adjust,onAdjust:oi.setCameraAdjust}),(0,X.jsx)(Nn.Q,{open:Ut,onClose:()=>Wt(!1),maxSelect:null!==w&&void 0!==w&&w.is_admin||"admin"===(null===w||void 0===w?void 0:w.role)?10:null!==w&&void 0!==w&&w.is_vip?5:1,onConfirm:(e,t)=>oi.startLoopVideo(e,t)}),(0,X.jsx)(Sn,{open:Yt,onClose:()=>ea(!1),rs:oi}),(0,X.jsx)(mn,{call:oi.call,localStream:oi.localStream,ppv:oi.ppv,ppvIncoming:oi.ppvIncoming,onPpvAccept:oi.acceptPpv,onPpvDecline:oi.declinePpv,onBuyTokens:()=>window.open("/wallet","_blank"),onAccept:oi.acceptCall,onDecline:oi.declineCall,onEnd:oi.ppv?oi.endPpv:oi.endCall}),(0,X.jsx)(jn,{gcall:oi.gcall,participants:oi.gcParticipants,ringing:oi.gcRinging,localStream:oi.localStream,selfInfo:eo,members:ao,maxOthers:6,onAccept:oi.acceptGroupCall,onDecline:oi.declineGroupCall,onAdd:oi.addToGroupCall,onLeave:oi.leaveGroupCall,onShareScreen:oi.gcShareScreen,screenOn:oi.gcScreenOn,screenStream:oi.gcScreenStream})]});var jc}function Bn(){const e=(0,r.g)().code,t=e?e.toUpperCase():"lobby";return(0,X.jsx)(qn,{room:t},t)}}}]);
2//# sourceMappingURL=180.2b7b3326.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.