@vocantly/widget 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/vocantly-widget-call.js +1 -1
- package/dist/vocantly-widget.js +1 -1
- package/package.json +2 -2
|
@@ -322,4 +322,4 @@ Error generating stack: `+e.message+`
|
|
|
322
322
|
.cafcall-mini-ctls .cafcall-ctl.danger .ic{ background:var(--caf-danger); color:#fff; }
|
|
323
323
|
.cafcall-mini-ctls .cafcall-ctl.on .ic{ background:var(--caf-danger); color:#fff; }
|
|
324
324
|
.cafcall-mini-ctls .cafcall-ctl span:last-child{ display:none; }
|
|
325
|
-
`;function ap(l=document){let a=l.getElementById($1);a||(a=l.createElement("style"),a.id=$1,l.head.appendChild(a)),a.textContent!==I1&&(a.textContent=I1)}function nh(l,{startInLobby:a=!1,incoming:t=null}={}){var xr;let[e,n]=(0,Q.useState)(t?"incoming":"idle"),[c,u]=(0,Q.useState)((t==null?void 0:t.callType)||"video"),[i,o]=(0,Q.useState)((xr=t==null?void 0:t.callerId)!=null?xr:null),[d,v]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!0),[g,S]=(0,Q.useState)(!1),[E,z]=(0,Q.useState)(!1),[s,r]=(0,Q.useState)(""),[h,y]=(0,Q.useState)(null),[x,M]=(0,Q.useState)(0),[T,A]=(0,Q.useState)(!1),[cl,Y]=(0,Q.useState)(!1),[za,hc]=(0,Q.useState)(null),[mh,oi]=(0,Q.useState)(!1),[hh,br]=(0,Q.useState)([]),[vh,gh]=(0,Q.useState)(""),[yh,ph]=(0,Q.useState)(!0),[bh,Sh]=(0,Q.useState)(1),vc=(0,Q.useRef)(null),gc=(0,Q.useRef)(null),wt=(0,Q.useRef)(null),yc=(0,Q.useRef)(null),rn=(0,Q.useRef)(e);rn.current=e,(0,Q.useEffect)(()=>{if(e!=="active"&&e!=="reconnecting")return;wt.current==null&&(wt.current=Date.now());let _=setInterval(()=>M(Math.floor((Date.now()-wt.current)/1e3)),1e3);return()=>clearInterval(_)},[e]);let Sr=(0,Q.useCallback)(_=>{var U,q,Rl,ua;vc.current=(Rl=(q=_==null?void 0:_.localStream)!=null?q:(U=l==null?void 0:l.getLocalStream)==null?void 0:U.call(l))!=null?Rl:vc.current;let D=_==null?void 0:_.remoteStream;if(!D&&(l!=null&&l.getRemoteStream)&&(_!=null&&_.remoteUserId)&&(D=(ua=l.getRemoteStream(_.remoteUserId))!=null?ua:l.getRemoteStream(String(_.remoteUserId))),!D&&(l!=null&&l.getAllRemoteStreams)){let ia=l.getAllRemoteStreams();D=ia&&(ia.values?[...ia.values()][0]:Object.values(ia)[0])}gc.current=D!=null?D:gc.current},[l]);(0,Q.useEffect)(()=>{if(!l)return;let _=[],D=(U,q)=>{l.on(U,q),_.push(()=>{var Rl;return(Rl=l.off)==null?void 0:Rl.call(l,U,q)})};return D("call_invite",U=>{var q;u((U==null?void 0:U.callType)||"video"),o((q=U==null?void 0:U.callerId)!=null?q:null),r(""),n("incoming")}),D("call_connected",U=>{Sr(U),U!=null&&U.remoteUserId&&o(U.remoteUserId),yc.current&&(clearTimeout(yc.current),yc.current=null),n("active")}),D("call_hangup",()=>Yt("remote_hangup")),D("call_timeout",()=>Yt("no_answer")),D("call_reject",()=>Yt("declined")),D("call_error",U=>{let q=(U==null?void 0:U.reason)||"";if(q==="permission_denied"){r((U==null?void 0:U.message)||"Camera / microphone blocked"),n("permission_denied");return}if(q==="ice_failed"){rn.current==="active"&&(n("reconnecting"),yc.current=setTimeout(()=>{rn.current==="reconnecting"&&Yt("connection_lost")},2e4));return}r((U==null?void 0:U.message)||"Call error")}),D("local_mute_changed",({muted:U})=>v(!!U)),D("local_video_changed",({enabled:U})=>m(!!U)),D("peer_mute",()=>S(!0)),D("peer_unmute",()=>S(!1)),D("peer_video_off",()=>z(!0)),D("peer_video_on",()=>z(!1)),D("screen_share_changed",({active:U})=>Y(!!U)),D("peer_left",()=>Yt("remote_hangup")),()=>{_.forEach(U=>{try{U()}catch{}})}},[l,Sr]),(0,Q.useEffect)(()=>{if(!l)return;let _=!1,D=q=>{var Rl,ua,ia,Er,Nr,Tr,zr;return{id:(Rl=q.id)!=null?Rl:q.message_id,text:(ia=(ua=q.content)!=null?ua:q.text)!=null?ia:"",sender:String((Nr=(Er=q.sender_id)!=null?Er:q.senderId)!=null?Nr:""),at:(zr=(Tr=q.created_at)!=null?Tr:q.sent_at)!=null?zr:Date.now()}},U=q=>br(Rl=>{let ua=D(q);return!ua.id||Rl.some(ia=>ia.id===ua.id)?Rl:[...Rl,ua]});return l.on("message",U),l.fetchMessages&&l.fetchMessages({limit:50}).then(q=>{var Rl,ua,ia;_||br(((ia=(ua=q==null?void 0:q.messages)!=null?ua:(Rl=q==null?void 0:q.data)==null?void 0:Rl.messages)!=null?ia:[]).map(D))}).catch(()=>{}),()=>{var q;_=!0,(q=l.off)==null||q.call(l,"message",U)}},[l]);let Yt=(0,Q.useCallback)(_=>{if(rn.current==="ended"||rn.current==="idle")return;let D=wt.current?Math.floor((Date.now()-wt.current)/1e3):0,U=q=>{y({reason:_,stats:q||null,seconds:D}),n("ended")};l!=null&&l.getCallStats?l.getCallStats().then(U).catch(()=>U(null)):U(null)},[l]),xh={openLobby:(_="video")=>{u(_),r(""),n("lobby")},start:_=>{let D=_||c;u(D),r(""),wt.current=null,M(0);try{l.startCall(D),n("outgoing")}catch(U){r((U==null?void 0:U.message)||"Failed to start call")}},accept:()=>{try{l.acceptCall()}catch(_){r((_==null?void 0:_.message)||"Failed to accept")}},acceptVoice:()=>{var _;u("voice");try{l.acceptCall(),(_=l.setVideoEnabled)==null||_.call(l,!1)}catch(D){r(D==null?void 0:D.message)}},decline:()=>{try{l.rejectCall()}catch{}Yt("declined_local")},hangup:()=>{try{l.endCall()}catch{}Yt("local_hangup")},toggleMute:()=>{let _=!d;v(_);try{l.setMuted(_)}catch{}},toggleCamera:()=>{let _=!p;m(_);try{l.setVideoEnabled(_)}catch{}},switchToVoice:()=>{u("voice");try{l.setVideoEnabled(!1)}catch{}},setCallOptions:_=>{var D;try{(D=l==null?void 0:l.setCallOptions)==null||D.call(l,_)}catch{}},listDevices:()=>l!=null&&l.listDevices?l.listDevices():Promise.resolve([]),setSpeaker:_=>gh(_),setMirror:_=>ph(!!_),setVolume:_=>Sh(Math.max(0,Math.min(1,_))),setVideoQuality:(_,D,U)=>{var q;try{(q=l==null?void 0:l.applyVideoConstraints)==null||q.call(l,{width:{ideal:_},height:{ideal:D},...U?{frameRate:{ideal:U}}:{}})}catch{}},setAudioProcessing:_=>{var D;try{(D=l==null?void 0:l.applyAudioConstraints)==null||D.call(l,_)}catch{}},switchDevice:(_,D)=>{var U;try{return(U=l==null?void 0:l.switchDevice)==null?void 0:U.call(l,_,D)}catch{}},setLowBandwidth:_=>{var D;try{return(D=l==null?void 0:l.setLowBandwidth)==null?void 0:D.call(l,_)}catch{}},minimize:()=>A(!0),maximize:()=>A(!1),openPanel:_=>{oi(!1),hc(D=>D===_?null:_)},closePanel:()=>hc(null),toggleMore:()=>oi(_=>!_),closeMore:()=>oi(!1),sendMessage:_=>{let D=(_||"").trim();if(D)try{l.sendMessage(D)}catch{}},toggleShare:async()=>{var _,D;try{if(cl)await((_=l.stopScreenShare)==null?void 0:_.call(l)),Y(!1);else{let U=await((D=l.startScreenShare)==null?void 0:D.call(l));Y(!!U)}}catch{}},reset:()=>{n("idle"),A(!1),y(null),M(0),wt.current=null,vc.current=null,gc.current=null}};return(0,Q.useEffect)(()=>{a&&e==="idle"&&n("lobby")},[a,e]),{phase:e,callType:c,peerId:i,muted:d,cameraOn:p,peerMuted:g,peerCameraOff:E,error:s,endedInfo:h,elapsed:x,minimized:T,sharing:cl,panel:za,moreOpen:mh,messages:hh,speakerId:vh,mirror:yh,volume:bh,localStream:vc,remoteStream:gc,actions:xh}}function ii(l){l=Math.max(0,l|0);let a=Math.floor(l/60),t=l%60;return`${String(a).padStart(2,"0")}:${String(t).padStart(2,"0")}`}var Al=l=>(0,N.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...l}),C={mic:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),(0,N.jsx)("path",{d:"M19 10a7 7 0 0 1-14 0"}),(0,N.jsx)("path",{d:"M12 19v3"})]}),micOff:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M1 1l22 22"}),(0,N.jsx)("path",{d:"M9 9v2a3 3 0 0 0 5.1 2.1"}),(0,N.jsx)("path",{d:"M15 9.3V5a3 3 0 0 0-5.9-.7"}),(0,N.jsx)("path",{d:"M19 10a7 7 0 0 1-1.2 3.9M5 10a7 7 0 0 0 10 6.3"}),(0,N.jsx)("path",{d:"M12 19v3"})]}),cam:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}),(0,N.jsx)("path",{d:"M22 8l-6 4 6 4V8z"})]}),camOff:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M1 1l22 22"}),(0,N.jsx)("path",{d:"M16 16H4a2 2 0 0 1-2-2V8"}),(0,N.jsx)("path",{d:"M9.5 6H14a2 2 0 0 1 2 2v4.5"}),(0,N.jsx)("path",{d:"M22 8l-6 4"})]}),end:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M22 16.9v2a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2 3.2 2 2 0 0 1 4 1h2a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.6a2 2 0 0 1-.5 2.1L7.1 8.6a16 16 0 0 0 6 6l1.2-1.1a2 2 0 0 1 2.1-.5c.8.3 1.7.6 2.6.7A2 2 0 0 1 22 16.9z",transform:"rotate(135 12 12)"})}),speaker:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),(0,N.jsx)("path",{d:"M15.5 8.5a5 5 0 0 1 0 7M19 5a9 9 0 0 1 0 14"})]}),share:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M4 16V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10"}),(0,N.jsx)("path",{d:"M2 20h20"}),(0,N.jsx)("path",{d:"M12 12V7m0 0l-2 2m2-2l2 2"})]}),people:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,N.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,N.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8"})]}),chat:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),more:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,N.jsx)("circle",{cx:"19",cy:"12",r:"1"}),(0,N.jsx)("circle",{cx:"5",cy:"12",r:"1"})]}),phone:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M22 16.9v2a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2 3.2 2 2 0 0 1 4 1h2a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.6a2 2 0 0 1-.5 2.1L7.1 8.6a16 16 0 0 0 6 6l1.2-1.1a2 2 0 0 1 2.1-.5c.8.3 1.7.6 2.6.7A2 2 0 0 1 22 16.9z"})}),lock:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),(0,N.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),check:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M20 6L9 17l-5-5"})}),wifi:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M5 12.5a10 10 0 0 1 14 0M8.5 16a5 5 0 0 1 7 0"}),(0,N.jsx)("path",{d:"M12 20h.01"})]}),shrink:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3"})}),info:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,N.jsx)("path",{d:"M12 16v-4M12 8h.01"})]}),spinner:()=>(0,N.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"cafcall-spin",children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"3"}),(0,N.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),settings:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,N.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})};function ca({name:l="?",src:a,size:t=96,className:e="",style:n={}}){let c=String(l).split(/\s+/).map(u=>u[0]).slice(0,2).join("").toUpperCase();return a?(0,N.jsx)("img",{className:`cafcall-avatar ${e}`,src:a,alt:l,style:{width:t,height:t,...n}}):(0,N.jsx)("span",{className:`cafcall-avatar ${e}`,style:{width:t,height:t,fontSize:t*.36,...n},children:c})}function gr({stream:l,muted:a,mirror:t,sinkId:e,volume:n,className:c,style:u,audioOnly:i}){var v,p;let o=(0,fi.useRef)(null),d=(p=(v=l==null?void 0:l.current)!=null?v:l)!=null?p:null;return(0,fi.useEffect)(()=>{var s;let m=o.current;if(!m)return;let g=!1,S=()=>{var r;g||!m||(m.srcObject!==d&&(m.srcObject=d||null),typeof n=="number"&&(m.volume=n),d&&((r=m.play)==null||r.call(m).catch(()=>{})),e&&typeof m.setSinkId=="function"&&m.setSinkId(e).catch(()=>{}))};S(),m.onloadedmetadata=S;let E=()=>S();(s=d==null?void 0:d.addEventListener)==null||s.call(d,"addtrack",E);let z=[120,400,900,1800].map(r=>setTimeout(S,r));return()=>{var r;g=!0,(r=d==null?void 0:d.removeEventListener)==null||r.call(d,"addtrack",E),z.forEach(clearTimeout)}},[d,e,n]),i?(0,N.jsx)("audio",{ref:o,autoPlay:!0,muted:a,style:{display:"none"}}):(0,N.jsx)("video",{ref:o,playsInline:!0,autoPlay:!0,muted:a,className:c,style:{...t?{transform:"scaleX(-1)"}:{},...u}})}function na({icon:l,name:a,label:t,onClick:e,tone:n="",active:c,on:u,disabled:i}){let o=C[l]||C.more;return(0,N.jsxs)("button",{type:"button",className:`cafcall-ctl ${n} ${c?"active":""} ${u?"on":""} ${a?`cafcall-ctl-${a}`:""}`,onClick:e,disabled:i,title:t,children:[(0,N.jsx)("span",{className:"ic",children:(0,N.jsx)(o,{})}),(0,N.jsx)("span",{children:t})]})}function mc(){return(0,N.jsxs)("span",{className:"cafcall-pill enc",children:[(0,N.jsx)(C.lock,{})," E2E Encrypted"]})}function P1({bars:l=9}){return(0,N.jsx)("span",{className:"cafcall-wave",children:Array.from({length:l}).map((a,t)=>(0,N.jsx)("i",{style:{animationDelay:`${t%5*.12}s`,height:5+t%4*4}},t))})}function ch(l){var e,n,c;if(!l)return{label:"Good",tone:"ok"};let a=(e=l.rtt_ms)!=null?e:0,t=(c=(n=l.packet_loss_pct)!=null?n:l.packetsLostPct)!=null?c:0;return a>300||t>5?{label:"Poor",tone:"warn"}:a>150||t>2?{label:"Fair",tone:"warn"}:{label:"Good",tone:"ok"}}var lh=[{label:"1080p HD",w:1920,h:1080},{label:"720p HD",w:1280,h:720},{label:"360p",w:640,h:360},{label:"180p",w:320,h:180}],tp=["devices","network","accessibility","privacy"],ah={mirror:!0,blur:!1,noiseSuppression:!0,echoCancellation:!0,adaptiveBitrate:!0,lowBandwidth:!1,hardwareAccel:!0},ep=({on:l,onClick:a})=>(0,O.jsx)("button",{type:"button",className:`cafcall-toggle ${l?"on":""}`,onClick:a,"aria-pressed":l,children:(0,O.jsx)("i",{})});function uh({c:l,cfg:a}){let[t,e]=(0,Ta.useState)("devices"),[n,c]=(0,Ta.useState)({cam:[],mic:[],spk:[]}),[u,i]=(0,Ta.useState)({cam:"",mic:"",spk:l.speakerId||""}),[o,d]=(0,Ta.useState)("720p HD"),[v,p]=(0,Ta.useState)({...ah,mirror:l.mirror}),m=(0,Ta.useRef)(null);if((0,Ta.useEffect)(()=>{l.actions.listDevices().then(s=>{let r=h=>s.filter(y=>y.kind===h).map(y=>({id:y.deviceId,label:y.label||h}));c({cam:r("videoinput"),mic:r("audioinput"),spk:r("audiooutput")})})},[]),(0,Ta.useEffect)(()=>{var h,y;let s=m.current,r=(h=l.localStream)==null?void 0:h.current;s&&r&&(s.srcObject=r,(y=s.play)==null||y.call(s).catch(()=>{}))}),l.panel!=="settings")return null;let g=s=>{d(s);let r=lh.find(h=>h.label===s);r&&l.actions.setVideoQuality(r.w,r.h)},S=s=>p(r=>{let h=!r[s];return s==="mirror"&&l.actions.setMirror(h),(s==="noiseSuppression"||s==="echoCancellation")&&l.actions.setAudioProcessing({[s]:h}),s==="lowBandwidth"&&(l.actions.setLowBandwidth(h),d(h?"360p":"720p HD")),{...r,[s]:h}}),E=({icon:s,list:r,value:h,onChange:y})=>{let x=C[s]||C.mic;return(0,O.jsxs)("div",{className:"cafcall-picker",children:[(0,O.jsx)("span",{className:"ic",children:(0,O.jsx)(x,{})}),(0,O.jsxs)("select",{value:h,onChange:M=>y(M.target.value),children:[(0,O.jsx)("option",{value:"",children:r.length?"Default":"Grant access to list devices"}),r.map(M=>(0,O.jsx)("option",{value:M.id,children:M.label},M.id))]})]})},z=({icon:s,title:r,sub:h,k:y})=>{let x=C[s]||C.info;return(0,O.jsxs)("div",{className:"cafcall-answerrow",style:{marginBottom:8},children:[(0,O.jsx)("span",{className:"ic",children:(0,O.jsx)(x,{})}),(0,O.jsxs)("div",{style:{flex:1},children:[(0,O.jsx)("div",{className:"t",children:r}),(0,O.jsx)("div",{className:"s",children:h})]}),(0,O.jsx)(ep,{on:v[y],onClick:()=>S(y)})]})};return(0,O.jsxs)("div",{className:"cafcall-drawer cafcall-settings",children:[(0,O.jsxs)("div",{className:"cafcall-drawer-head",children:[(0,O.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,O.jsx)("span",{className:"cafcall-set-badge",children:(0,O.jsx)(C.settings,{})}),(0,O.jsxs)("div",{children:[(0,O.jsx)("b",{children:"Settings"}),(0,O.jsx)("div",{className:"cafcall-prole",children:a.sessionTitle})]})]}),(0,O.jsx)("button",{className:"cafcall-iconbtn",style:{background:"#EEF2F7",color:"var(--caf-ink)"},onClick:l.actions.closePanel,children:"\u2715"})]}),(0,O.jsx)("div",{className:"cafcall-tabs",children:tp.map(s=>(0,O.jsx)("button",{className:`cafcall-tab ${t===s?"on":""}`,onClick:()=>e(s),children:s[0].toUpperCase()+s.slice(1)},s))}),(0,O.jsx)("div",{className:"cafcall-drawer-body",children:t==="devices"?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("div",{className:"cafcall-label",children:"Camera"}),(0,O.jsx)("div",{className:"cafcall-preview",style:{width:"100%"},children:(0,O.jsx)("div",{className:"frame",children:(0,O.jsx)("video",{ref:m,playsInline:!0,autoPlay:!0,muted:!0,style:{transform:v.mirror?"scaleX(-1)":"none"}})})}),(0,O.jsx)(E,{icon:"cam",list:n.cam,value:u.cam,onChange:s=>{i(r=>({...r,cam:s})),l.actions.switchDevice("video",s)}}),(0,O.jsxs)("div",{className:"cafcall-picker",children:[(0,O.jsx)("span",{className:"ic",children:(0,O.jsx)(C.settings,{})}),(0,O.jsx)("span",{style:{flex:1,fontSize:13,fontWeight:600},children:"Video Quality"}),(0,O.jsx)("select",{value:o,onChange:s=>g(s.target.value),children:lh.map(s=>(0,O.jsx)("option",{children:s.label},s.label))})]}),(0,O.jsx)(z,{icon:"cam",title:"Mirror My Video",sub:"Only affects your own preview",k:"mirror"}),(0,O.jsx)(z,{icon:"info",title:"Background Blur",sub:"Blur background for privacy \u2014 coming soon",k:"blur"}),(0,O.jsx)("div",{className:"cafcall-label",children:"Microphone"}),(0,O.jsx)(E,{icon:"mic",list:n.mic,value:u.mic,onChange:s=>{i(r=>({...r,mic:s})),l.actions.switchDevice("audio",s)}}),(0,O.jsx)(z,{icon:"mic",title:"Noise Suppression",sub:"Filter background noise for clearer audio",k:"noiseSuppression"}),(0,O.jsx)(z,{icon:"info",title:"Echo Cancellation",sub:"Reduce feedback and echo",k:"echoCancellation"}),(0,O.jsx)("div",{className:"cafcall-label",children:"Speaker & Output"}),(0,O.jsx)(E,{icon:"speaker",list:n.spk,value:u.spk,onChange:s=>{i(r=>({...r,spk:s})),l.actions.setSpeaker(s)}}),(0,O.jsxs)("div",{className:"cafcall-sliderrow",children:[(0,O.jsx)(C.speaker,{}),(0,O.jsx)("span",{children:"Speaker Volume"}),(0,O.jsx)("input",{type:"range",min:"0",max:"1",step:"0.05",value:l.volume,onChange:s=>l.actions.setVolume(Number(s.target.value))})]}),(0,O.jsx)("div",{className:"cafcall-label",children:"Bandwidth & Performance"}),(0,O.jsx)(z,{icon:"wifi",title:"Adaptive Bitrate",sub:"Auto-adjusts quality to network (automatic)",k:"adaptiveBitrate"}),(0,O.jsx)(z,{icon:"wifi",title:"Low Bandwidth Mode",sub:"Reduce video quality to save data",k:"lowBandwidth"}),(0,O.jsx)(z,{icon:"settings",title:"Hardware Acceleration",sub:"Use GPU for video \u2014 browser-managed",k:"hardwareAccel"})]}):(0,O.jsxs)("p",{className:"cafcall-p",style:{fontSize:13,padding:"18px 0"},children:[t[0].toUpperCase()+t.slice(1)," settings \u2014 coming soon."]})}),(0,O.jsxs)("div",{className:"cafcall-settings-foot",children:[(0,O.jsxs)("span",{className:"cafcall-pill enc",children:[(0,O.jsx)(C.lock,{})," E2E Encrypted"]}),(0,O.jsx)("button",{className:"cafcall-btn ghost",style:{width:"auto",margin:0,padding:"9px 14px"},onClick:()=>{p({...ah,mirror:l.mirror})},children:"Reset"}),(0,O.jsx)("button",{className:"cafcall-btn pri",style:{width:"auto",margin:0,padding:"9px 16px"},onClick:l.actions.closePanel,children:"Apply"})]})]})}var re=({cfg:l,right:a})=>(0,f.jsxs)("div",{className:"cafcall-head",children:[(0,f.jsxs)("div",{className:"cafcall-brand",children:[(0,f.jsx)("span",{className:"cafcall-logo",children:l.logoText}),(0,f.jsxs)("div",{style:{minWidth:0},children:[(0,f.jsx)("div",{className:"cafcall-title",children:l.sessionTitle}),(0,f.jsx)("div",{className:"cafcall-sub",children:l.sessionSubtitle})]})]}),(0,f.jsx)("div",{className:"cafcall-head-right",children:a})]}),yr=({on:l,onClick:a})=>(0,f.jsx)("button",{type:"button",className:`cafcall-toggle ${l?"on":""}`,onClick:a,"aria-pressed":l,children:(0,f.jsx)("i",{})});function vr({icon:l,list:a,value:t,onChange:e}){let n=C[l]||C.mic;return(0,f.jsxs)("div",{className:"cafcall-picker",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(n,{})}),(0,f.jsxs)("select",{value:t,onChange:c=>e(c.target.value),children:[(0,f.jsx)("option",{value:"",children:a.length?"Default":"No device / grant access"}),a.map(c=>(0,f.jsx)("option",{value:c.id,children:c.label},c.id))]})]})}function ui({title:l,sub:a,on:t,onToggle:e}){return(0,f.jsxs)("div",{className:"cafcall-prefrow",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"t",children:l}),(0,f.jsx)("div",{className:"s",children:a})]}),(0,f.jsx)(yr,{on:t,onClick:e})]})}function np({stream:l,ready:a,muted:t}){let[e,n]=(0,il.useState)(0);return(0,il.useEffect)(()=>{if(!l)return;let c,u,i=0;try{c=new(window.AudioContext||window.webkitAudioContext);let o=c.createMediaStreamSource(l),d=c.createAnalyser();d.fftSize=256,o.connect(d);let v=new Uint8Array(d.frequencyBinCount),p=m=>{u=requestAnimationFrame(p),!(m-i<90)&&(i=m,d.getByteFrequencyData(v),n(Math.min(100,v.reduce((g,S)=>g+S,0)/v.length*1.6)))};u=requestAnimationFrame(p)}catch{}return()=>{var o;cancelAnimationFrame(u),(o=c==null?void 0:c.close)==null||o.call(c)}},[l]),(0,f.jsxs)("div",{className:"cafcall-meter",children:[(0,f.jsx)(C.mic,{}),(0,f.jsx)("span",{children:"Microphone level"}),(0,f.jsx)("span",{className:"bar",children:(0,f.jsx)("i",{style:{width:`${t?0:e}%`}})}),(0,f.jsx)("span",{style:{color:a?"var(--caf-ok)":"var(--caf-muted)",fontWeight:600},children:a?"Detected":"\u2014"})]})}function cp({c:l,cfg:a}){let t=!!a.voiceOnly,e=!!a.simple,[n,c]=(0,il.useState)(t?"voice":l.callType||"video"),[u,i]=(0,il.useState)(!1),[o,d]=(0,il.useState)(null),v=(0,il.useRef)(null),p=(0,il.useRef)(null),[m,g]=(0,il.useState)({cam:[],mic:[],spk:[]}),[S,E]=(0,il.useState)({cam:"",mic:"",spk:""}),[z,s]=(0,il.useState)({startMuted:!1,startVideoOff:!1,noiseSuppression:!0,lowBandwidth:!1}),r=y=>s(x=>({...x,[y]:!x[y]}));(0,il.useEffect)(()=>{let y=!1;return l.actions.listDevices().then(x=>{if(y)return;let M=T=>x.filter(A=>A.kind===T).map(A=>({id:A.deviceId,label:A.label||T}));g({cam:M("videoinput"),mic:M("audioinput"),spk:M("audiooutput")})}),()=>{y=!0}},[u]),(0,il.useEffect)(()=>{let y=!1;return(async()=>{var x,M;try{let T=await navigator.mediaDevices.getUserMedia({video:n==="video"?S.cam?{deviceId:{exact:S.cam}}:!0:!1,audio:S.mic?{deviceId:{exact:S.mic}}:!0});if(y){T.getTracks().forEach(A=>A.stop());return}p.current=T,i(!0),d(T),v.current&&(v.current.srcObject=T,(M=(x=v.current).play)==null||M.call(x).catch(()=>{}))}catch{i(!1)}})(),()=>{var x;y=!0,(x=p.current)==null||x.getTracks().forEach(M=>M.stop()),d(null)}},[n,S.cam,S.mic]);let h=()=>{var y;(y=p.current)==null||y.getTracks().forEach(x=>x.stop()),l.actions.setCallOptions({videoDeviceId:S.cam||void 0,audioDeviceId:S.mic||void 0,noiseSuppression:z.noiseSuppression,lowBandwidth:z.lowBandwidth,startMuted:z.startMuted,startVideoOff:z.startVideoOff}),S.spk&&l.actions.setSpeaker(S.spk),l.actions.start(n)};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"cafcall-h",children:"Ready to join?"}),(0,f.jsx)("div",{className:"cafcall-p",children:e?`Start a voice call with ${a.peer.name}.`:"Preview your camera and microphone before entering the call. Adjust settings on the right."})]}),(0,f.jsxs)("div",{className:"cafcall-preview",children:[(0,f.jsx)("div",{className:"frame",children:n==="video"?(0,f.jsx)("video",{ref:v,playsInline:!0,autoPlay:!0,muted:!0,style:{opacity:z.startVideoOff?.25:1}}):(0,f.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:110})})}),(0,f.jsx)(np,{stream:o,ready:u,muted:z.startMuted})]})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[!e&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{style:{fontWeight:700,fontSize:15},children:"Device Setup"}),(0,f.jsx)("div",{className:"cafcall-p",style:{fontSize:13,margin:"4px 0 14px"},children:"Select your camera, microphone and speaker before joining."})]}),(0,f.jsxs)("div",{className:"cafcall-card cafcall-person",children:[(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"nm",children:a.self.name}),(0,f.jsxs)("div",{className:"rl",children:[a.self.role," \xB7 You"]})]}),(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," ",u?"Ready":"\u2026"]})]}),!t&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"cafcall-label",children:"Call type"}),(0,f.jsxs)("div",{className:"cafcall-seg",children:[(0,f.jsxs)("button",{className:`cafcall-btn ${n==="video"?"sel":"ghost"}`,onClick:()=>c("video"),children:[(0,f.jsx)(C.cam,{})," Video Call"]}),(0,f.jsxs)("button",{className:`cafcall-btn ${n==="voice"?"sel":"ghost"}`,onClick:()=>c("voice"),children:[(0,f.jsx)(C.mic,{})," Voice Only"]})]})]}),!e&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"cafcall-label",children:"Devices"}),n==="video"&&(0,f.jsx)(vr,{icon:"cam",list:m.cam,value:S.cam,onChange:y=>E(x=>({...x,cam:y}))}),(0,f.jsx)(vr,{icon:"mic",list:m.mic,value:S.mic,onChange:y=>E(x=>({...x,mic:y}))}),(0,f.jsx)(vr,{icon:"speaker",list:m.spk,value:S.spk,onChange:y=>E(x=>({...x,spk:y}))}),(0,f.jsx)("div",{className:"cafcall-label",children:"Preferences"}),(0,f.jsx)(ui,{title:"Start muted",sub:"Join with microphone off",on:z.startMuted,onToggle:()=>r("startMuted")}),n==="video"&&(0,f.jsx)(ui,{title:"Start with camera off",sub:"Join with video disabled",on:z.startVideoOff,onToggle:()=>r("startVideoOff")}),(0,f.jsx)(ui,{title:"Noise suppression",sub:"Filter background noise for clearer audio",on:z.noiseSuppression,onToggle:()=>r("noiseSuppression")}),(0,f.jsx)(ui,{title:"Low-bandwidth mode",sub:"Reduce video quality to save data",on:z.lowBandwidth,onToggle:()=>r("lowBandwidth")})]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Calling"}),(0,f.jsxs)("div",{className:"cafcall-card cafcall-person",children:[(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"nm",children:a.peer.name}),(0,f.jsx)("div",{className:"rl",children:a.peer.role})]}),(0,f.jsx)("span",{className:"cafcall-pill",children:"Waiting"})]}),(0,f.jsxs)("div",{style:{marginTop:18},children:[(0,f.jsxs)("button",{className:"cafcall-btn pri",onClick:h,children:[(0,f.jsx)(C.phone,{})," Join Call"]}),(0,f.jsx)("button",{className:"cafcall-btn ghost",onClick:l.actions.reset,children:"Cancel"})]})]})]})]})}function up({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsx)("div",{className:"cafcall-body",children:(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-pulse",children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:128})}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"cafcall-h",children:a.peer.name}),(0,f.jsx)("div",{className:"cafcall-p",children:a.peer.role})]}),(0,f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--caf-muted)"},children:["Calling ",(0,f.jsxs)("span",{className:"cafcall-dots",children:[(0,f.jsx)("i",{}),(0,f.jsx)("i",{}),(0,f.jsx)("i",{})]})]}),(0,f.jsx)("span",{className:"cafcall-pill",children:l.callType==="video"?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.cam,{})," Video call"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.mic,{})," Voice call"]})})]})}),(0,f.jsx)("div",{className:"cafcall-controls",children:(0,f.jsx)(na,{icon:"end",label:"Cancel",tone:"danger",onClick:l.actions.hangup})})]})}function ip({c:l,cfg:a}){let t=!!a.voiceOnly,e=!t&&l.callType==="video",[n,c]=(0,il.useState)({cam:e,mic:!0}),[u,i]=(0,il.useState)(!1),o=()=>{u||(i(!0),l.actions.setCallOptions({startVideoOff:e&&!n.cam,startMuted:!n.mic}),t||e&&!n.cam?l.actions.acceptVoice():l.actions.accept())},d=()=>{u||(i(!0),l.actions.acceptVoice())};return(0,il.useEffect)(()=>{if(!u)return;let v=setTimeout(()=>i(!1),2e4);return()=>clearTimeout(v)},[u]),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-pulse",children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:128})}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"cafcall-h",children:a.peer.name}),(0,f.jsx)("div",{className:"cafcall-p",children:a.peer.role})]}),(0,f.jsx)("span",{className:"cafcall-pill",children:e?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.cam,{})," Incoming Video Call"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.mic,{})," Incoming Voice Call"]})}),(0,f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--caf-muted)"},children:["Ringing ",(0,f.jsxs)("span",{className:"cafcall-dots",children:[(0,f.jsx)("i",{}),(0,f.jsx)("i",{}),(0,f.jsx)("i",{})]})]}),(0,f.jsxs)("div",{className:"cafcall-infostrip",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"k",children:"Call Type"}),(0,f.jsx)("div",{className:"v",children:e?"Video":"Voice"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"k",children:"Network"}),(0,f.jsx)("div",{className:"v",style:{color:"var(--caf-ok)"},children:"Good"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"k",children:"Encryption"}),(0,f.jsx)("div",{className:"v",children:"E2E"})]})]})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[(0,f.jsxs)("div",{className:"cafcall-note ok",children:[(0,f.jsxs)("b",{style:{color:"var(--caf-primary)"},children:["Incoming ",e?"video":"voice"," call"]}),(0,f.jsx)("br",{}),a.peer.name," is calling you",a.sessionTitle?` for a ${a.sessionTitle}.`:"."]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Caller"}),(0,f.jsxs)("div",{className:"cafcall-card cafcall-person",children:[(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"nm",children:a.peer.name}),(0,f.jsx)("div",{className:"rl",children:a.peer.role})]}),(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Calling"]})]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Answer with"}),e&&(0,f.jsxs)("div",{className:"cafcall-answerrow",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.cam,{})}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"t",children:"Camera"}),(0,f.jsx)("div",{className:"s",children:"Join with video"})]}),(0,f.jsx)(yr,{on:n.cam,onClick:()=>c(v=>({...v,cam:!v.cam}))})]}),(0,f.jsxs)("div",{className:"cafcall-answerrow",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.mic,{})}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"t",children:"Microphone"}),(0,f.jsx)("div",{className:"s",children:"Join with audio"})]}),(0,f.jsx)(yr,{on:n.mic,onClick:()=>c(v=>({...v,mic:!v.mic}))})]}),(0,f.jsxs)("div",{className:"cafcall-answerrow",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.wifi,{})}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"t",children:"Network Quality"}),(0,f.jsx)("div",{className:"s",children:"Good connection"})]}),(0,f.jsx)("span",{className:"cafcall-pill ok",children:"Good"})]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Can\u2019t answer?"}),(0,f.jsxs)("button",{className:"cafcall-answerrow as-btn",onClick:l.actions.decline,children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.chat,{})}),(0,f.jsxs)("div",{style:{flex:1,textAlign:"left"},children:[(0,f.jsx)("div",{className:"t",children:"Send a Message"}),(0,f.jsxs)("div",{className:"s",children:["Let ",a.peer.name," know you\u2019re unavailable"]})]})]}),(0,f.jsxs)("div",{style:{marginTop:18,display:"flex",gap:10},children:[(0,f.jsxs)("button",{className:"cafcall-btn dngghost",onClick:l.actions.decline,disabled:u,children:[(0,f.jsx)(C.end,{})," Decline"]}),(0,f.jsx)("button",{className:"cafcall-btn pri",onClick:o,disabled:u,children:u?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.spinner,{})," Connecting\u2026"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.phone,{})," Accept Call"]})})]}),e&&(0,f.jsx)("button",{className:"cafcall-btn ghost",style:{marginTop:10},onClick:d,disabled:u,children:u?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.spinner,{})," Connecting\u2026"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.mic,{})," Answer as Voice Only"]})})]})]})]})}function ih({c:l,videoCall:a,simple:t}){if(!l.moreOpen)return null;let e=(n,c,u,i)=>(0,f.jsxs)("button",{className:"cafcall-sheet-item",onClick:()=>{u(),l.actions.closeMore()},children:[(0,f.jsx)("span",{className:`ic ${i?"on":""}`,children:(()=>{let o=C[n]||C.more;return(0,f.jsx)(o,{})})()}),c]});return(0,f.jsx)("div",{className:"cafcall-sheet-scrim",onClick:l.actions.closeMore,children:(0,f.jsxs)("div",{className:"cafcall-sheet",onClick:n=>n.stopPropagation(),children:[(0,f.jsx)("div",{className:"cafcall-sheet-grab"}),(0,f.jsxs)("div",{className:"cafcall-sheet-grid",children:[e("people","People",()=>l.actions.openPanel("people")),e("chat","Chat",()=>l.actions.openPanel("chat")),a&&e("share",l.sharing?"Stop Share":"Share",l.actions.toggleShare,l.sharing),!t&&e("settings","Settings",()=>l.actions.openPanel("settings"))]})]})})}function fh({c:l,cfg:a}){let[t,e]=(0,il.useState)(""),n=(0,il.useRef)(null);if((0,il.useEffect)(()=>{var u;(u=n.current)==null||u.scrollIntoView({behavior:"smooth"})},[l.messages,l.panel]),!l.panel)return null;let c=()=>{l.actions.sendMessage(t),e("")};return(0,f.jsxs)("div",{className:"cafcall-drawer",children:[(0,f.jsxs)("div",{className:"cafcall-drawer-head",children:[(0,f.jsx)("b",{children:l.panel==="people"?"People":"Chat"}),(0,f.jsx)("button",{className:"cafcall-iconbtn",style:{background:"#EEF2F7",color:"var(--caf-ink)"},onClick:l.actions.closePanel,children:"\u2715"})]}),l.panel==="people"?(0,f.jsx)("div",{className:"cafcall-drawer-body",children:[{...a.self,you:!0,muted:l.muted,off:!l.cameraOn},{...a.peer,you:!1,muted:l.peerMuted,off:l.peerCameraOff}].map((u,i)=>(0,f.jsxs)("div",{className:"cafcall-person",style:{padding:"10px 4px"},children:[(0,f.jsx)(ca,{name:u.name,src:u.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsxs)("div",{className:"nm",children:[u.name,u.you?" (You)":""]}),(0,f.jsx)("div",{className:"rl",children:u.role})]}),(0,f.jsx)("span",{className:"ic",style:{color:u.muted?"var(--caf-danger)":"var(--caf-muted)"},children:u.muted?(0,f.jsx)(C.micOff,{}):(0,f.jsx)(C.mic,{})}),l.callType!=="voice"&&(0,f.jsx)("span",{className:"ic",style:{color:u.off?"var(--caf-danger)":"var(--caf-muted)"},children:u.off?(0,f.jsx)(C.camOff,{}):(0,f.jsx)(C.cam,{})})]},i))}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("div",{className:"cafcall-drawer-body cafcall-chat",children:[l.messages.length===0&&(0,f.jsx)("div",{className:"cafcall-p",style:{fontSize:13},children:"No messages yet. Say hello \u{1F44B}"}),l.messages.map(u=>{let i=String(u.sender)!==String(l.peerId);return(0,f.jsx)("div",{className:`cafcall-msg ${i?"mine":""}`,children:u.text},u.id)}),(0,f.jsx)("div",{ref:n})]}),(0,f.jsxs)("div",{className:"cafcall-chat-compose",children:[(0,f.jsx)("input",{value:t,onChange:u=>e(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:"Type a message\u2026"}),(0,f.jsx)("button",{className:"cafcall-btn pri",style:{width:"auto",padding:"10px 14px"},onClick:c,children:"Send"})]})]})]})}var oh=({c:l,videoCall:a,dark:t,simple:e})=>(0,f.jsxs)("div",{className:`cafcall-controls ${t?"dark":""}`,children:[(0,f.jsxs)("div",{className:"cafcall-controls-l",children:[(0,f.jsx)(na,{icon:"people",name:"people",label:"People",active:l.panel==="people",onClick:()=>l.actions.openPanel("people")}),(0,f.jsx)(na,{icon:"chat",name:"chat",label:"Chat",active:l.panel==="chat",onClick:()=>l.actions.openPanel("chat")})]}),(0,f.jsxs)("div",{className:"cafcall-controls-c",children:[(0,f.jsx)(na,{icon:l.muted?"micOff":"mic",name:"mute",label:l.muted?"Unmute":"Mute",on:l.muted,onClick:l.actions.toggleMute}),a&&(0,f.jsx)(na,{icon:l.cameraOn?"cam":"camOff",name:"camera",label:l.cameraOn?"Camera":"Camera Off",on:!l.cameraOn,onClick:l.actions.toggleCamera}),(0,f.jsx)(na,{icon:"end",name:"end",label:"End Call",tone:"danger",onClick:l.actions.hangup}),(0,f.jsx)(na,{icon:"speaker",name:"speaker",label:"Speaker",active:!0,onClick:()=>{}}),a&&(0,f.jsx)(na,{icon:"share",name:"share",label:l.sharing?"Stop Share":"Share",active:l.sharing,onClick:l.actions.toggleShare})]}),(0,f.jsxs)("div",{className:"cafcall-controls-r",children:[(0,f.jsx)(na,{icon:"more",name:"more",label:"More",active:l.moreOpen,onClick:l.actions.toggleMore}),!e&&(0,f.jsx)(na,{icon:"settings",name:"settings",label:"Settings",active:l.panel==="settings",onClick:()=>l.actions.openPanel("settings")})]})]});function th({c:l,cfg:a}){let t=ch(null),e=!l.peerMuted;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"cafcall-body",style:{flexDirection:"column"},children:(0,f.jsxs)("div",{className:"cafcall-stage",children:[(0,f.jsx)(gr,{stream:l.remoteStream,sinkId:l.speakerId,volume:l.volume}),l.sharing&&(0,f.jsxs)("div",{className:"cafcall-sharebar",children:[(0,f.jsx)(C.share,{})," You\u2019re sharing your screen"]}),l.peerCameraOff&&(0,f.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:110})}),(0,f.jsxs)("div",{className:"cafcall-stage-top",children:[(0,f.jsxs)("div",{className:"cafcall-stack",children:[(0,f.jsxs)("span",{className:"cafcall-titlechip",children:[(0,f.jsx)("span",{className:"cafcall-logo",children:a.logoText}),(0,f.jsxs)("span",{children:[(0,f.jsx)("b",{children:a.sessionTitle}),(0,f.jsx)("small",{children:a.sessionSubtitle})]})]}),(0,f.jsxs)("span",{className:"cafcall-peerchip",children:[a.peer.avatar&&(0,f.jsx)("img",{src:a.peer.avatar,alt:""}),(0,f.jsx)("b",{children:a.peer.name}),(0,f.jsxs)("span",{style:{opacity:.85},children:["\xB7 ",a.peer.role,l.peerMuted?" \xB7 muted":e?" \xB7 Speaking":""]})]})]}),(0,f.jsx)("div",{className:"cafcall-topmid",children:(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Connected\xA0\xA0",ii(l.elapsed)]})}),(0,f.jsxs)("div",{className:"cafcall-topright",children:[(0,f.jsxs)("div",{className:"row",children:[(0,f.jsxs)("span",{className:"cafcall-pill enc",children:[(0,f.jsx)(C.lock,{})," E2E Encrypted"]}),(0,f.jsx)("button",{className:"cafcall-iconbtn",title:"Call info",children:(0,f.jsx)(C.info,{})}),(0,f.jsx)("button",{className:"cafcall-iconbtn",title:"Minimize",onClick:l.actions.minimize,children:(0,f.jsx)(C.shrink,{})})]}),(0,f.jsxs)("span",{className:`cafcall-pill ${t.tone}`,children:[(0,f.jsx)(C.wifi,{})," ",t.label]})]})]}),(0,f.jsxs)("div",{className:"cafcall-selftile",children:[l.cameraOn?(0,f.jsx)(gr,{stream:l.localStream,muted:!0,mirror:l.mirror}):(0,f.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:44})}),(0,f.jsxs)("span",{className:"cafcall-name",children:[a.self.name," (You) ",l.muted?(0,f.jsx)(C.micOff,{}):(0,f.jsx)(C.mic,{})]})]}),(0,f.jsxs)("div",{className:"cafcall-floatctl",children:[(0,f.jsx)("button",{className:"cafcall-floatbtn",title:"Flip camera",onClick:l.actions.toggleCamera,children:(0,f.jsx)(C.cam,{})}),(0,f.jsx)("button",{className:"cafcall-floatbtn end",title:"End call",onClick:l.actions.hangup,children:(0,f.jsx)(C.end,{})}),(0,f.jsx)("button",{className:"cafcall-floatbtn",title:l.muted?"Unmute":"Mute",onClick:l.actions.toggleMute,children:l.muted?(0,f.jsx)(C.micOff,{}):(0,f.jsx)(C.mic,{})})]}),(0,f.jsx)(fh,{c:l,cfg:a}),!a.simple&&(0,f.jsx)(uh,{c:l,cfg:a})]})}),(0,f.jsx)(oh,{c:l,videoCall:!0,dark:!0,simple:a.simple}),(0,f.jsx)(ih,{c:l,videoCall:!0,simple:a.simple})]})}function fp({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Voice Only \xB7 ",ii(l.elapsed)]}),(0,f.jsx)(mc,{})]})}),(0,f.jsx)("div",{className:"cafcall-body",children:(0,f.jsxs)("div",{className:"cafcall-main cafcall-voice",children:[(0,f.jsx)(gr,{stream:l.remoteStream,sinkId:l.speakerId,volume:l.volume,audioOnly:!0}),(0,f.jsx)(fh,{c:l,cfg:a}),!a.simple&&(0,f.jsx)(uh,{c:l,cfg:a}),(0,f.jsxs)("div",{className:"cafcall-voice-row",children:[(0,f.jsxs)("div",{className:"cafcall-part",children:[(0,f.jsx)("div",{className:`cafcall-ring ${l.peerMuted?"":"speaking"}`,children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:120})}),(0,f.jsx)("div",{className:"cafcall-pname",children:a.peer.name}),(0,f.jsx)("div",{className:"cafcall-prole",children:a.peer.role}),l.peerMuted?(0,f.jsxs)("span",{className:"cafcall-pill warn",children:[(0,f.jsx)(C.micOff,{})," Muted"]}):(0,f.jsx)(P1,{})]}),(0,f.jsxs)("div",{className:"cafcall-part",children:[(0,f.jsx)("div",{className:`cafcall-ring ${l.muted?"":"speaking"}`,children:(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:120})}),(0,f.jsx)("div",{className:"cafcall-pname",children:a.self.name}),(0,f.jsxs)("div",{className:"cafcall-prole",children:[a.self.role," \xB7 You"]}),l.muted?(0,f.jsxs)("span",{className:"cafcall-pill warn",children:[(0,f.jsx)(C.micOff,{})," Microphone Muted"]}):(0,f.jsx)(P1,{})]})]})]})}),(0,f.jsx)(oh,{c:l,videoCall:!1,simple:a.simple}),(0,f.jsx)(ih,{c:l,videoCall:!1,simple:a.simple})]})}function op({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsxs)("span",{className:"cafcall-pill warn",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Reconnecting"]})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",style:{background:"var(--caf-stage)",color:"#fff"},children:[(0,f.jsx)("div",{className:"cafcall-icon-lg cafcall-spin",style:{background:"rgba(245,158,11,.15)",color:"var(--caf-warn)"},children:(0,f.jsx)(C.wifi,{})}),(0,f.jsx)("div",{className:"cafcall-h",style:{color:"#fff"},children:"Reconnecting\u2026"}),(0,f.jsx)("div",{className:"cafcall-p",style:{color:"#cbd5e1"},children:"Your connection was interrupted. Restoring the call automatically."})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[(0,f.jsxs)("div",{className:"cafcall-note warn",children:[(0,f.jsx)("b",{children:"Connection lost."}),(0,f.jsx)("br",{}),"Network instability detected \u2014 attempting to restore your call."]}),(0,f.jsxs)("div",{style:{marginTop:18},children:[(0,f.jsxs)("button",{className:"cafcall-btn ghost",onClick:l.actions.switchToVoice,children:[(0,f.jsx)(C.mic,{})," Switch to Voice Only"]}),(0,f.jsxs)("button",{className:"cafcall-btn dngghost",onClick:l.actions.hangup,children:[(0,f.jsx)(C.end,{})," End Call"]})]})]})]})]})}function rp({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a}),(0,f.jsx)("div",{className:"cafcall-body",children:(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-icon-lg",style:{background:"#FEF2F2",color:"var(--caf-danger)"},children:(0,f.jsx)(C.camOff,{})}),(0,f.jsx)("div",{className:"cafcall-h",children:"Camera & microphone blocked"}),(0,f.jsx)("div",{className:"cafcall-p",children:l.error||"Vocantly needs access to your camera and microphone to start the call. Enable them in your browser\u2019s site settings, then try again."}),(0,f.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,f.jsx)("button",{className:"cafcall-btn pri",onClick:()=>l.actions.start(l.callType),style:{width:160},children:"Try Again"}),(0,f.jsx)("button",{className:"cafcall-btn ghost",onClick:l.actions.reset,style:{width:120},children:"Cancel"})]})]})})]})}var sp={local_hangup:"You ended the call.",remote_hangup:"The other participant ended the call.",declined:"Call declined.",declined_local:"You declined the call.",no_answer:"No answer.",connection_lost:"The call ended due to a lost connection."};function dp({c:l,cfg:a}){let[t,e]=(0,il.useState)(0),[n,c]=(0,il.useState)(!1),u=l.endedInfo||{},i=u.stats||{},o=d=>{var v;e(d),c(!0),(v=a.onRate)==null||v.call(a,d)};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-icon-lg",style:{background:"#DCFCE7",color:"var(--caf-ok)"},children:(0,f.jsx)(C.check,{})}),(0,f.jsx)("div",{className:"cafcall-h",children:"Call Ended"}),(0,f.jsxs)("div",{className:"cafcall-p",children:[sp[u.reason]||"The call has concluded."," A summary is below."]}),(0,f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:26},children:[(0,f.jsxs)("div",{style:{textAlign:"center"},children:[(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:56}),(0,f.jsx)("div",{className:"cafcall-prole",style:{marginTop:6},children:a.self.name})]}),(0,f.jsx)(C.check,{}),(0,f.jsxs)("div",{style:{textAlign:"center"},children:[(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:56}),(0,f.jsx)("div",{className:"cafcall-prole",style:{marginTop:6},children:a.peer.name})]})]}),(0,f.jsxs)("div",{className:"cafcall-stats",style:{width:"min(520px,100%)"},children:[(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:ii(u.seconds||0)}),(0,f.jsx)("div",{className:"k",children:"Duration"})]}),(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:l.callType==="video"?"HD":"Voice"}),(0,f.jsx)("div",{className:"k",children:"Type"})]}),(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:ch(i).label}),(0,f.jsx)("div",{className:"k",children:"Network"})]}),(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:i.rtt_ms!=null?`${Math.round(i.rtt_ms)}ms`:"\u2014"}),(0,f.jsx)("div",{className:"k",children:"Latency"})]})]})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[(0,f.jsxs)("div",{className:"cafcall-note ok",children:[(0,f.jsx)("b",{style:{color:"var(--caf-primary)"},children:"Call complete"}),(0,f.jsx)("br",{}),"Both participants were connected for the session."]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Rate this call"}),(0,f.jsx)("div",{className:"cafcall-stars",children:[1,2,3,4,5].map(d=>(0,f.jsx)("button",{className:`cafcall-star ${d<=t?"on":""}`,onClick:()=>o(d),children:"\u2605"},d))}),n&&(0,f.jsx)("div",{className:"cafcall-prole",style:{marginTop:8},children:"Thanks for your feedback!"}),(0,f.jsxs)("div",{style:{marginTop:18},children:[(0,f.jsxs)("button",{className:"cafcall-btn pri",onClick:()=>l.actions.openLobby(l.callType),children:[(0,f.jsx)(C.phone,{})," Start New Call"]}),(0,f.jsx)("button",{className:"cafcall-btn ghost",onClick:l.actions.reset,children:"Close"})]})]})]})]})}function mp({c:l,cfg:a}){return(0,Ul.jsxs)("div",{className:"cafcall-mini",style:{"--caf-primary":a.primaryColor},children:[(0,Ul.jsx)("button",{className:"cafcall-mini-expand",onClick:l.actions.maximize,title:"Expand call",children:(0,Ul.jsx)(C.shrink,{})}),(0,Ul.jsxs)("div",{className:"cafcall-mini-info",children:[(0,Ul.jsx)("div",{className:"t",children:a.peer.name}),(0,Ul.jsxs)("div",{className:"s",children:[(0,Ul.jsx)("span",{className:"cafcall-dot",style:{color:"var(--caf-ok)"}})," ",ii(l.elapsed)]})]}),(0,Ul.jsxs)("div",{className:"cafcall-mini-ctls",children:[(0,Ul.jsx)(na,{icon:l.muted?"micOff":"mic",label:"",on:l.muted,onClick:l.actions.toggleMute}),l.callType!=="voice"&&(0,Ul.jsx)(na,{icon:l.cameraOn?"cam":"camOff",label:"",on:!l.cameraOn,onClick:l.actions.toggleCamera}),(0,Ul.jsx)(na,{icon:"end",label:"",tone:"danger",onClick:l.actions.hangup})]})]})}function rh({controller:l,config:a={},embed:t=!1}){let e=l,n={brandName:"Vocantly",logoText:"CA",sessionTitle:"Call",sessionSubtitle:"Secured via Vocantly",primaryColor:"#2563EB",self:{name:"You",role:"Participant",avatar:null},peer:{name:"Guest",role:"Participant",avatar:null},onRate:a.onRate,...a};if(e&&(e.actions.openChat=a.onChat),(0,eh.useEffect)(()=>{ap()},[]),!e||e.phase==="idle")return null;if(e.minimized&&(e.phase==="active"||e.phase==="reconnecting"))return(0,Ul.jsx)(mp,{c:e,cfg:n});let u={lobby:cp,outgoing:up,incoming:ip,active:e.callType==="voice"?fp:th,reconnecting:op,permission_denied:rp,ended:dp}[e.phase]||th;return(0,Ul.jsx)("div",{className:`cafcall ${t?"cafcall-embed":""}`,style:{"--caf-primary":n.primaryColor},children:(0,Ul.jsx)(u,{c:e,cfg:n})})}var pr=Kl(oe(),1);function hp({convo:l,config:a,bindApi:t}){let e=nh(l);return(0,sh.useEffect)(()=>{t({start:n=>e.actions.openLobby(n)})},[e]),(0,pr.jsx)(rh,{controller:e,config:a})}function vp(l,a,t){let e=(0,dh.createRoot)(l),n={api:null,pending:null};return e.render((0,pr.jsx)(hp,{convo:a,config:t,bindApi:c=>{n.api=c,n.pending&&(c.start(n.pending),n.pending=null)}})),{startCall:(c="voice")=>{n.api?n.api.start(c):n.pending=c},unmount:()=>{try{e.unmount()}catch{}}}}return Ah(gp);})();
|
|
325
|
+
`;function ap(l=document){let a=l.getElementById($1);a||(a=l.createElement("style"),a.id=$1,l.head.appendChild(a)),a.textContent!==I1&&(a.textContent=I1)}function nh(l,{startInLobby:a=!1,incoming:t=null}={}){var xr;let[e,n]=(0,Q.useState)(t?"incoming":"idle"),[c,u]=(0,Q.useState)((t==null?void 0:t.callType)||"video"),[i,o]=(0,Q.useState)((xr=t==null?void 0:t.callerId)!=null?xr:null),[d,v]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(!0),[g,S]=(0,Q.useState)(!1),[E,z]=(0,Q.useState)(!1),[s,r]=(0,Q.useState)(""),[h,y]=(0,Q.useState)(null),[x,M]=(0,Q.useState)(0),[T,A]=(0,Q.useState)(!1),[cl,Y]=(0,Q.useState)(!1),[za,hc]=(0,Q.useState)(null),[mh,oi]=(0,Q.useState)(!1),[hh,br]=(0,Q.useState)([]),[vh,gh]=(0,Q.useState)(""),[yh,ph]=(0,Q.useState)(!0),[bh,Sh]=(0,Q.useState)(1),vc=(0,Q.useRef)(null),gc=(0,Q.useRef)(null),wt=(0,Q.useRef)(null),yc=(0,Q.useRef)(null),rn=(0,Q.useRef)(e);rn.current=e,(0,Q.useEffect)(()=>{if(e!=="active"&&e!=="reconnecting")return;wt.current==null&&(wt.current=Date.now());let _=setInterval(()=>M(Math.floor((Date.now()-wt.current)/1e3)),1e3);return()=>clearInterval(_)},[e]);let Sr=(0,Q.useCallback)(_=>{var U,q,Rl,ua;vc.current=(Rl=(q=_==null?void 0:_.localStream)!=null?q:(U=l==null?void 0:l.getLocalStream)==null?void 0:U.call(l))!=null?Rl:vc.current;let D=_==null?void 0:_.remoteStream;if(!D&&(l!=null&&l.getRemoteStream)&&(_!=null&&_.remoteUserId)&&(D=(ua=l.getRemoteStream(_.remoteUserId))!=null?ua:l.getRemoteStream(String(_.remoteUserId))),!D&&(l!=null&&l.getAllRemoteStreams)){let ia=l.getAllRemoteStreams();D=ia&&(ia.values?[...ia.values()][0]:Object.values(ia)[0])}gc.current=D!=null?D:gc.current},[l]);(0,Q.useEffect)(()=>{if(!l)return;let _=[],D=(U,q)=>{l.on(U,q),_.push(()=>{var Rl;return(Rl=l.off)==null?void 0:Rl.call(l,U,q)})};return D("call_invite",U=>{var q;u((U==null?void 0:U.callType)||"video"),o((q=U==null?void 0:U.callerId)!=null?q:null),r(""),n("incoming")}),D("call_connected",U=>{Sr(U),U!=null&&U.remoteUserId&&o(U.remoteUserId),yc.current&&(clearTimeout(yc.current),yc.current=null),n("active")}),D("call_hangup",()=>Yt("remote_hangup")),D("call_timeout",()=>Yt("no_answer")),D("call_reject",()=>Yt("declined")),D("call_error",U=>{let q=(U==null?void 0:U.reason)||"";if(q==="permission_denied"){r((U==null?void 0:U.message)||"Camera / microphone blocked"),n("permission_denied");return}if(q==="ice_failed"){rn.current==="active"&&(n("reconnecting"),yc.current=setTimeout(()=>{rn.current==="reconnecting"&&Yt("connection_lost")},2e4));return}r((U==null?void 0:U.message)||"Call error")}),D("local_mute_changed",({muted:U})=>v(!!U)),D("local_video_changed",({enabled:U})=>m(!!U)),D("peer_mute",()=>S(!0)),D("peer_unmute",()=>S(!1)),D("peer_video_off",()=>z(!0)),D("peer_video_on",()=>z(!1)),D("screen_share_changed",({active:U})=>Y(!!U)),D("peer_left",()=>Yt("remote_hangup")),()=>{_.forEach(U=>{try{U()}catch{}})}},[l,Sr]),(0,Q.useEffect)(()=>{if(!l)return;let _=!1,D=q=>{var Rl,ua,ia,Er,Nr,Tr,zr;return{id:(Rl=q.id)!=null?Rl:q.message_id,text:(ia=(ua=q.content)!=null?ua:q.text)!=null?ia:"",sender:String((Nr=(Er=q.sender_id)!=null?Er:q.senderId)!=null?Nr:""),at:(zr=(Tr=q.created_at)!=null?Tr:q.sent_at)!=null?zr:Date.now()}},U=q=>br(Rl=>{let ua=D(q);return!ua.id||Rl.some(ia=>ia.id===ua.id)?Rl:[...Rl,ua]});return l.on("message",U),l.fetchMessages&&l.fetchMessages({limit:50}).then(q=>{var Rl,ua,ia;_||br(((ia=(ua=q==null?void 0:q.messages)!=null?ua:(Rl=q==null?void 0:q.data)==null?void 0:Rl.messages)!=null?ia:[]).map(D))}).catch(()=>{}),()=>{var q;_=!0,(q=l.off)==null||q.call(l,"message",U)}},[l]);let Yt=(0,Q.useCallback)(_=>{if(rn.current==="ended"||rn.current==="idle")return;let D=wt.current?Math.floor((Date.now()-wt.current)/1e3):0,U=q=>{y({reason:_,stats:q||null,seconds:D}),n("ended")};l!=null&&l.getCallStats?l.getCallStats().then(U).catch(()=>U(null)):U(null)},[l]),xh={openLobby:(_="video")=>{u(_),r(""),n("lobby")},start:_=>{let D=_||c;u(D),r(""),wt.current=null,M(0);try{l.startCall(D),n("outgoing")}catch(U){r((U==null?void 0:U.message)||"Failed to start call")}},accept:()=>{try{l.acceptCall()}catch(_){r((_==null?void 0:_.message)||"Failed to accept")}},acceptVoice:()=>{var _;u("voice");try{l.acceptCall(),(_=l.setVideoEnabled)==null||_.call(l,!1)}catch(D){r(D==null?void 0:D.message)}},decline:()=>{try{l.rejectCall()}catch{}Yt("declined_local")},hangup:()=>{try{l.endCall()}catch{}Yt("local_hangup")},toggleMute:()=>{let _=!d;v(_);try{l.setMuted(_)}catch{}},toggleCamera:()=>{let _=!p;m(_);try{l.setVideoEnabled(_)}catch{}},switchToVoice:()=>{u("voice");try{l.setVideoEnabled(!1)}catch{}},setCallOptions:_=>{var D;try{(D=l==null?void 0:l.setCallOptions)==null||D.call(l,_)}catch{}},listDevices:()=>l!=null&&l.listDevices?l.listDevices():Promise.resolve([]),setSpeaker:_=>gh(_),setMirror:_=>ph(!!_),setVolume:_=>Sh(Math.max(0,Math.min(1,_))),setVideoQuality:(_,D,U)=>{var q;try{(q=l==null?void 0:l.applyVideoConstraints)==null||q.call(l,{width:{ideal:_},height:{ideal:D},...U?{frameRate:{ideal:U}}:{}})}catch{}},setAudioProcessing:_=>{var D;try{(D=l==null?void 0:l.applyAudioConstraints)==null||D.call(l,_)}catch{}},switchDevice:(_,D)=>{var U;try{return(U=l==null?void 0:l.switchDevice)==null?void 0:U.call(l,_,D)}catch{}},setLowBandwidth:_=>{var D;try{return(D=l==null?void 0:l.setLowBandwidth)==null?void 0:D.call(l,_)}catch{}},minimize:()=>A(!0),maximize:()=>A(!1),openPanel:_=>{oi(!1),hc(D=>D===_?null:_)},closePanel:()=>hc(null),toggleMore:()=>oi(_=>!_),closeMore:()=>oi(!1),sendMessage:_=>{let D=(_||"").trim();if(D)try{l.sendMessage(D)}catch{}},toggleShare:async()=>{var _,D;try{if(cl)await((_=l.stopScreenShare)==null?void 0:_.call(l)),Y(!1);else{let U=await((D=l.startScreenShare)==null?void 0:D.call(l));Y(!!U)}}catch{}},reset:()=>{n("idle"),A(!1),y(null),M(0),wt.current=null,vc.current=null,gc.current=null}};return(0,Q.useEffect)(()=>{a&&e==="idle"&&n("lobby")},[a,e]),{phase:e,callType:c,peerId:i,muted:d,cameraOn:p,peerMuted:g,peerCameraOff:E,error:s,endedInfo:h,elapsed:x,minimized:T,sharing:cl,panel:za,moreOpen:mh,messages:hh,speakerId:vh,mirror:yh,volume:bh,localStream:vc,remoteStream:gc,actions:xh}}function ii(l){l=Math.max(0,l|0);let a=Math.floor(l/60),t=l%60;return`${String(a).padStart(2,"0")}:${String(t).padStart(2,"0")}`}var Al=l=>(0,N.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",...l}),C={mic:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M12 2a3 3 0 0 0-3 3v6a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"}),(0,N.jsx)("path",{d:"M19 10a7 7 0 0 1-14 0"}),(0,N.jsx)("path",{d:"M12 19v3"})]}),micOff:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M1 1l22 22"}),(0,N.jsx)("path",{d:"M9 9v2a3 3 0 0 0 5.1 2.1"}),(0,N.jsx)("path",{d:"M15 9.3V5a3 3 0 0 0-5.9-.7"}),(0,N.jsx)("path",{d:"M19 10a7 7 0 0 1-1.2 3.9M5 10a7 7 0 0 0 10 6.3"}),(0,N.jsx)("path",{d:"M12 19v3"})]}),cam:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("rect",{x:"2",y:"6",width:"14",height:"12",rx:"2"}),(0,N.jsx)("path",{d:"M22 8l-6 4 6 4V8z"})]}),camOff:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M1 1l22 22"}),(0,N.jsx)("path",{d:"M16 16H4a2 2 0 0 1-2-2V8"}),(0,N.jsx)("path",{d:"M9.5 6H14a2 2 0 0 1 2 2v4.5"}),(0,N.jsx)("path",{d:"M22 8l-6 4"})]}),end:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M22 16.9v2a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2 3.2 2 2 0 0 1 4 1h2a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.6a2 2 0 0 1-.5 2.1L7.1 8.6a16 16 0 0 0 6 6l1.2-1.1a2 2 0 0 1 2.1-.5c.8.3 1.7.6 2.6.7A2 2 0 0 1 22 16.9z",transform:"rotate(135 12 12)"})}),speaker:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M11 5L6 9H2v6h4l5 4V5z"}),(0,N.jsx)("path",{d:"M15.5 8.5a5 5 0 0 1 0 7M19 5a9 9 0 0 1 0 14"})]}),share:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M4 16V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10"}),(0,N.jsx)("path",{d:"M2 20h20"}),(0,N.jsx)("path",{d:"M12 12V7m0 0l-2 2m2-2l2 2"})]}),people:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,N.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,N.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.9M16 3.1a4 4 0 0 1 0 7.8"})]}),chat:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),more:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"1"}),(0,N.jsx)("circle",{cx:"19",cy:"12",r:"1"}),(0,N.jsx)("circle",{cx:"5",cy:"12",r:"1"})]}),phone:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M22 16.9v2a2 2 0 0 1-2.2 2 19.8 19.8 0 0 1-8.6-3.1 19.5 19.5 0 0 1-6-6A19.8 19.8 0 0 1 2 3.2 2 2 0 0 1 4 1h2a2 2 0 0 1 2 1.7c.1.9.4 1.8.7 2.6a2 2 0 0 1-.5 2.1L7.1 8.6a16 16 0 0 0 6 6l1.2-1.1a2 2 0 0 1 2.1-.5c.8.3 1.7.6 2.6.7A2 2 0 0 1 22 16.9z"})}),lock:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2"}),(0,N.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),check:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M20 6L9 17l-5-5"})}),wifi:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("path",{d:"M5 12.5a10 10 0 0 1 14 0M8.5 16a5 5 0 0 1 7 0"}),(0,N.jsx)("path",{d:"M12 20h.01"})]}),shrink:()=>(0,N.jsx)(Al,{children:(0,N.jsx)("path",{d:"M8 3v3a2 2 0 0 1-2 2H3M21 8h-3a2 2 0 0 1-2-2V3M3 16h3a2 2 0 0 1 2 2v3M16 21v-3a2 2 0 0 1 2-2h3"})}),info:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,N.jsx)("path",{d:"M12 16v-4M12 8h.01"})]}),spinner:()=>(0,N.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",className:"cafcall-spin",children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeOpacity:"0.25",strokeWidth:"3"}),(0,N.jsx)("path",{d:"M21 12a9 9 0 0 0-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]}),settings:()=>(0,N.jsxs)(Al,{children:[(0,N.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,N.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})};function ca({name:l="?",src:a,size:t=96,className:e="",style:n={}}){let c=String(l).split(/\s+/).map(u=>u[0]).slice(0,2).join("").toUpperCase();return a?(0,N.jsx)("img",{className:`cafcall-avatar ${e}`,src:a,alt:l,style:{width:t,height:t,...n}}):(0,N.jsx)("span",{className:`cafcall-avatar ${e}`,style:{width:t,height:t,fontSize:t*.36,...n},children:c})}function gr({stream:l,muted:a,mirror:t,sinkId:e,volume:n,className:c,style:u,audioOnly:i}){var v,p;let o=(0,fi.useRef)(null),d=(p=(v=l==null?void 0:l.current)!=null?v:l)!=null?p:null;return(0,fi.useEffect)(()=>{var s;let m=o.current;if(!m)return;let g=!1,S=()=>{var r;g||!m||(m.srcObject!==d&&(m.srcObject=d||null),typeof n=="number"&&(m.volume=n),d&&((r=m.play)==null||r.call(m).catch(()=>{})),e&&typeof m.setSinkId=="function"&&m.setSinkId(e).catch(()=>{}))};S(),m.onloadedmetadata=S;let E=()=>S();(s=d==null?void 0:d.addEventListener)==null||s.call(d,"addtrack",E);let z=[120,400,900,1800].map(r=>setTimeout(S,r));return()=>{var r;g=!0,(r=d==null?void 0:d.removeEventListener)==null||r.call(d,"addtrack",E),z.forEach(clearTimeout)}},[d,e,n]),i?(0,N.jsx)("audio",{ref:o,autoPlay:!0,muted:a,style:{display:"none"}}):(0,N.jsx)("video",{ref:o,playsInline:!0,autoPlay:!0,muted:a,className:c,style:{...t?{transform:"scaleX(-1)"}:{},...u}})}function na({icon:l,name:a,label:t,onClick:e,tone:n="",active:c,on:u,disabled:i}){let o=C[l]||C.more;return(0,N.jsxs)("button",{type:"button",className:`cafcall-ctl ${n} ${c?"active":""} ${u?"on":""} ${a?`cafcall-ctl-${a}`:""}`,onClick:e,disabled:i,title:t,children:[(0,N.jsx)("span",{className:"ic",children:(0,N.jsx)(o,{})}),(0,N.jsx)("span",{children:t})]})}function mc(){return(0,N.jsxs)("span",{className:"cafcall-pill enc",children:[(0,N.jsx)(C.lock,{})," E2E Encrypted"]})}function P1({bars:l=9}){return(0,N.jsx)("span",{className:"cafcall-wave",children:Array.from({length:l}).map((a,t)=>(0,N.jsx)("i",{style:{animationDelay:`${t%5*.12}s`,height:5+t%4*4}},t))})}function ch(l){var e,n,c;if(!l)return{label:"Good",tone:"ok"};let a=(e=l.rtt_ms)!=null?e:0,t=(c=(n=l.packet_loss_pct)!=null?n:l.packetsLostPct)!=null?c:0;return a>300||t>5?{label:"Poor",tone:"warn"}:a>150||t>2?{label:"Fair",tone:"warn"}:{label:"Good",tone:"ok"}}var lh=[{label:"1080p HD",w:1920,h:1080},{label:"720p HD",w:1280,h:720},{label:"360p",w:640,h:360},{label:"180p",w:320,h:180}],tp=["devices","network","accessibility","privacy"],ah={mirror:!0,blur:!1,noiseSuppression:!0,echoCancellation:!0,adaptiveBitrate:!0,lowBandwidth:!1,hardwareAccel:!0},ep=({on:l,onClick:a})=>(0,O.jsx)("button",{type:"button",className:`cafcall-toggle ${l?"on":""}`,onClick:a,"aria-pressed":l,children:(0,O.jsx)("i",{})});function uh({c:l,cfg:a}){let[t,e]=(0,Ta.useState)("devices"),[n,c]=(0,Ta.useState)({cam:[],mic:[],spk:[]}),[u,i]=(0,Ta.useState)({cam:"",mic:"",spk:l.speakerId||""}),[o,d]=(0,Ta.useState)("720p HD"),[v,p]=(0,Ta.useState)({...ah,mirror:l.mirror}),m=(0,Ta.useRef)(null);if((0,Ta.useEffect)(()=>{l.actions.listDevices().then(s=>{let r=h=>s.filter(y=>y.kind===h).map(y=>({id:y.deviceId,label:y.label||h}));c({cam:r("videoinput"),mic:r("audioinput"),spk:r("audiooutput")})})},[]),(0,Ta.useEffect)(()=>{var h,y;let s=m.current,r=(h=l.localStream)==null?void 0:h.current;s&&r&&(s.srcObject=r,(y=s.play)==null||y.call(s).catch(()=>{}))}),l.panel!=="settings")return null;let g=s=>{d(s);let r=lh.find(h=>h.label===s);r&&l.actions.setVideoQuality(r.w,r.h)},S=s=>p(r=>{let h=!r[s];return s==="mirror"&&l.actions.setMirror(h),(s==="noiseSuppression"||s==="echoCancellation")&&l.actions.setAudioProcessing({[s]:h}),s==="lowBandwidth"&&(l.actions.setLowBandwidth(h),d(h?"360p":"720p HD")),{...r,[s]:h}}),E=({icon:s,list:r,value:h,onChange:y})=>{let x=C[s]||C.mic;return(0,O.jsxs)("div",{className:"cafcall-picker",children:[(0,O.jsx)("span",{className:"ic",children:(0,O.jsx)(x,{})}),(0,O.jsxs)("select",{value:h,onChange:M=>y(M.target.value),children:[(0,O.jsx)("option",{value:"",children:r.length?"Default":"Grant access to list devices"}),r.map(M=>(0,O.jsx)("option",{value:M.id,children:M.label},M.id))]})]})},z=({icon:s,title:r,sub:h,k:y})=>{let x=C[s]||C.info;return(0,O.jsxs)("div",{className:"cafcall-answerrow",style:{marginBottom:8},children:[(0,O.jsx)("span",{className:"ic",children:(0,O.jsx)(x,{})}),(0,O.jsxs)("div",{style:{flex:1},children:[(0,O.jsx)("div",{className:"t",children:r}),(0,O.jsx)("div",{className:"s",children:h})]}),(0,O.jsx)(ep,{on:v[y],onClick:()=>S(y)})]})};return(0,O.jsxs)("div",{className:"cafcall-drawer cafcall-settings",children:[(0,O.jsxs)("div",{className:"cafcall-drawer-head",children:[(0,O.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,O.jsx)("span",{className:"cafcall-set-badge",children:(0,O.jsx)(C.settings,{})}),(0,O.jsxs)("div",{children:[(0,O.jsx)("b",{children:"Settings"}),(0,O.jsx)("div",{className:"cafcall-prole",children:a.sessionTitle})]})]}),(0,O.jsx)("button",{className:"cafcall-iconbtn",style:{background:"#EEF2F7",color:"var(--caf-ink)"},onClick:l.actions.closePanel,children:"\u2715"})]}),(0,O.jsx)("div",{className:"cafcall-tabs",children:tp.map(s=>(0,O.jsx)("button",{className:`cafcall-tab ${t===s?"on":""}`,onClick:()=>e(s),children:s[0].toUpperCase()+s.slice(1)},s))}),(0,O.jsx)("div",{className:"cafcall-drawer-body",children:t==="devices"?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)("div",{className:"cafcall-label",children:"Camera"}),(0,O.jsx)("div",{className:"cafcall-preview",style:{width:"100%"},children:(0,O.jsx)("div",{className:"frame",children:(0,O.jsx)("video",{ref:m,playsInline:!0,autoPlay:!0,muted:!0,style:{transform:v.mirror?"scaleX(-1)":"none"}})})}),(0,O.jsx)(E,{icon:"cam",list:n.cam,value:u.cam,onChange:s=>{i(r=>({...r,cam:s})),l.actions.switchDevice("video",s)}}),(0,O.jsxs)("div",{className:"cafcall-picker",children:[(0,O.jsx)("span",{className:"ic",children:(0,O.jsx)(C.settings,{})}),(0,O.jsx)("span",{style:{flex:1,fontSize:13,fontWeight:600},children:"Video Quality"}),(0,O.jsx)("select",{value:o,onChange:s=>g(s.target.value),children:lh.map(s=>(0,O.jsx)("option",{children:s.label},s.label))})]}),(0,O.jsx)(z,{icon:"cam",title:"Mirror My Video",sub:"Only affects your own preview",k:"mirror"}),(0,O.jsx)(z,{icon:"info",title:"Background Blur",sub:"Blur background for privacy \u2014 coming soon",k:"blur"}),(0,O.jsx)("div",{className:"cafcall-label",children:"Microphone"}),(0,O.jsx)(E,{icon:"mic",list:n.mic,value:u.mic,onChange:s=>{i(r=>({...r,mic:s})),l.actions.switchDevice("audio",s)}}),(0,O.jsx)(z,{icon:"mic",title:"Noise Suppression",sub:"Filter background noise for clearer audio",k:"noiseSuppression"}),(0,O.jsx)(z,{icon:"info",title:"Echo Cancellation",sub:"Reduce feedback and echo",k:"echoCancellation"}),(0,O.jsx)("div",{className:"cafcall-label",children:"Speaker & Output"}),(0,O.jsx)(E,{icon:"speaker",list:n.spk,value:u.spk,onChange:s=>{i(r=>({...r,spk:s})),l.actions.setSpeaker(s)}}),(0,O.jsxs)("div",{className:"cafcall-sliderrow",children:[(0,O.jsx)(C.speaker,{}),(0,O.jsx)("span",{children:"Speaker Volume"}),(0,O.jsx)("input",{type:"range",min:"0",max:"1",step:"0.05",value:l.volume,onChange:s=>l.actions.setVolume(Number(s.target.value))})]}),(0,O.jsx)("div",{className:"cafcall-label",children:"Bandwidth & Performance"}),(0,O.jsx)(z,{icon:"wifi",title:"Adaptive Bitrate",sub:"Auto-adjusts quality to network (automatic)",k:"adaptiveBitrate"}),(0,O.jsx)(z,{icon:"wifi",title:"Low Bandwidth Mode",sub:"Reduce video quality to save data",k:"lowBandwidth"}),(0,O.jsx)(z,{icon:"settings",title:"Hardware Acceleration",sub:"Use GPU for video \u2014 browser-managed",k:"hardwareAccel"})]}):(0,O.jsxs)("p",{className:"cafcall-p",style:{fontSize:13,padding:"18px 0"},children:[t[0].toUpperCase()+t.slice(1)," settings \u2014 coming soon."]})}),(0,O.jsxs)("div",{className:"cafcall-settings-foot",children:[(0,O.jsxs)("span",{className:"cafcall-pill enc",children:[(0,O.jsx)(C.lock,{})," E2E Encrypted"]}),(0,O.jsx)("button",{className:"cafcall-btn ghost",style:{width:"auto",margin:0,padding:"9px 14px"},onClick:()=>{p({...ah,mirror:l.mirror})},children:"Reset"}),(0,O.jsx)("button",{className:"cafcall-btn pri",style:{width:"auto",margin:0,padding:"9px 16px"},onClick:l.actions.closePanel,children:"Apply"})]})]})}var re=({cfg:l,right:a})=>(0,f.jsxs)("div",{className:"cafcall-head",children:[(0,f.jsxs)("div",{className:"cafcall-brand",children:[(0,f.jsx)("span",{className:"cafcall-logo",children:l.logoText}),(0,f.jsxs)("div",{style:{minWidth:0},children:[(0,f.jsx)("div",{className:"cafcall-title",children:l.sessionTitle}),(0,f.jsx)("div",{className:"cafcall-sub",children:l.sessionSubtitle})]})]}),(0,f.jsx)("div",{className:"cafcall-head-right",children:a})]}),yr=({on:l,onClick:a})=>(0,f.jsx)("button",{type:"button",className:`cafcall-toggle ${l?"on":""}`,onClick:a,"aria-pressed":l,children:(0,f.jsx)("i",{})});function vr({icon:l,list:a,value:t,onChange:e}){let n=C[l]||C.mic;return(0,f.jsxs)("div",{className:"cafcall-picker",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(n,{})}),(0,f.jsxs)("select",{value:t,onChange:c=>e(c.target.value),children:[(0,f.jsx)("option",{value:"",children:a.length?"Default":"No device / grant access"}),a.map(c=>(0,f.jsx)("option",{value:c.id,children:c.label},c.id))]})]})}function ui({title:l,sub:a,on:t,onToggle:e}){return(0,f.jsxs)("div",{className:"cafcall-prefrow",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"t",children:l}),(0,f.jsx)("div",{className:"s",children:a})]}),(0,f.jsx)(yr,{on:t,onClick:e})]})}function np({stream:l,ready:a,muted:t}){let[e,n]=(0,il.useState)(0);return(0,il.useEffect)(()=>{if(!l)return;let c,u,i=0;try{c=new(window.AudioContext||window.webkitAudioContext);let o=c.createMediaStreamSource(l),d=c.createAnalyser();d.fftSize=256,o.connect(d);let v=new Uint8Array(d.frequencyBinCount),p=m=>{u=requestAnimationFrame(p),!(m-i<90)&&(i=m,d.getByteFrequencyData(v),n(Math.min(100,v.reduce((g,S)=>g+S,0)/v.length*1.6)))};u=requestAnimationFrame(p)}catch{}return()=>{var o;cancelAnimationFrame(u),(o=c==null?void 0:c.close)==null||o.call(c)}},[l]),(0,f.jsxs)("div",{className:"cafcall-meter",children:[(0,f.jsx)(C.mic,{}),(0,f.jsx)("span",{children:"Microphone level"}),(0,f.jsx)("span",{className:"bar",children:(0,f.jsx)("i",{style:{width:`${t?0:e}%`}})}),(0,f.jsx)("span",{style:{color:a?"var(--caf-ok)":"var(--caf-muted)",fontWeight:600},children:a?"Detected":"\u2014"})]})}function cp({c:l,cfg:a}){let t=!!a.voiceOnly,e=!!a.simple,[n,c]=(0,il.useState)(t?"voice":l.callType||"video"),[u,i]=(0,il.useState)(!1),[o,d]=(0,il.useState)(null),v=(0,il.useRef)(null),p=(0,il.useRef)(null),[m,g]=(0,il.useState)({cam:[],mic:[],spk:[]}),[S,E]=(0,il.useState)({cam:"",mic:"",spk:""}),[z,s]=(0,il.useState)({startMuted:!1,startVideoOff:!1,noiseSuppression:!0,lowBandwidth:!1}),r=y=>s(x=>({...x,[y]:!x[y]}));(0,il.useEffect)(()=>{let y=!1;return l.actions.listDevices().then(x=>{if(y)return;let M=T=>x.filter(A=>A.kind===T).map(A=>({id:A.deviceId,label:A.label||T}));g({cam:M("videoinput"),mic:M("audioinput"),spk:M("audiooutput")})}),()=>{y=!0}},[u]),(0,il.useEffect)(()=>{let y=!1;return(async()=>{var x,M;try{let T=await navigator.mediaDevices.getUserMedia({video:n==="video"?S.cam?{deviceId:{exact:S.cam}}:!0:!1,audio:S.mic?{deviceId:{exact:S.mic}}:!0});if(y){T.getTracks().forEach(A=>A.stop());return}p.current=T,i(!0),d(T),v.current&&(v.current.srcObject=T,(M=(x=v.current).play)==null||M.call(x).catch(()=>{}))}catch{i(!1)}})(),()=>{var x;y=!0,(x=p.current)==null||x.getTracks().forEach(M=>M.stop()),d(null)}},[n,S.cam,S.mic]);let h=()=>{var y;(y=p.current)==null||y.getTracks().forEach(x=>x.stop()),l.actions.setCallOptions({videoDeviceId:S.cam||void 0,audioDeviceId:S.mic||void 0,noiseSuppression:z.noiseSuppression,lowBandwidth:z.lowBandwidth,startMuted:z.startMuted,startVideoOff:z.startVideoOff}),S.spk&&l.actions.setSpeaker(S.spk),l.actions.start(n)};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"cafcall-h",children:"Ready to join?"}),(0,f.jsx)("div",{className:"cafcall-p",children:e?`Start a voice call with ${a.peer.name}.`:"Preview your camera and microphone before entering the call. Adjust settings on the right."})]}),(0,f.jsxs)("div",{className:"cafcall-preview",children:[(0,f.jsx)("div",{className:"frame",children:n==="video"?(0,f.jsx)("video",{ref:v,playsInline:!0,autoPlay:!0,muted:!0,style:{opacity:z.startVideoOff?.25:1}}):(0,f.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:110})})}),(0,f.jsx)(np,{stream:o,ready:u,muted:z.startMuted})]})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[!e&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{style:{fontWeight:700,fontSize:15},children:"Device Setup"}),(0,f.jsx)("div",{className:"cafcall-p",style:{fontSize:13,margin:"4px 0 14px"},children:"Select your camera, microphone and speaker before joining."})]}),(0,f.jsxs)("div",{className:"cafcall-card cafcall-person",children:[(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"nm",children:a.self.name}),(0,f.jsxs)("div",{className:"rl",children:[a.self.role," \xB7 You"]})]}),(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," ",u?"Ready":"\u2026"]})]}),!t&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"cafcall-label",children:"Call type"}),(0,f.jsxs)("div",{className:"cafcall-seg",children:[(0,f.jsxs)("button",{className:`cafcall-btn ${n==="video"?"sel":"ghost"}`,onClick:()=>c("video"),children:[(0,f.jsx)(C.cam,{})," Video Call"]}),(0,f.jsxs)("button",{className:`cafcall-btn ${n==="voice"?"sel":"ghost"}`,onClick:()=>c("voice"),children:[(0,f.jsx)(C.mic,{})," Voice Only"]})]})]}),!e&&(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"cafcall-label",children:"Devices"}),n==="video"&&(0,f.jsx)(vr,{icon:"cam",list:m.cam,value:S.cam,onChange:y=>E(x=>({...x,cam:y}))}),(0,f.jsx)(vr,{icon:"mic",list:m.mic,value:S.mic,onChange:y=>E(x=>({...x,mic:y}))}),(0,f.jsx)(vr,{icon:"speaker",list:m.spk,value:S.spk,onChange:y=>E(x=>({...x,spk:y}))}),(0,f.jsx)("div",{className:"cafcall-label",children:"Preferences"}),(0,f.jsx)(ui,{title:"Start muted",sub:"Join with microphone off",on:z.startMuted,onToggle:()=>r("startMuted")}),n==="video"&&(0,f.jsx)(ui,{title:"Start with camera off",sub:"Join with video disabled",on:z.startVideoOff,onToggle:()=>r("startVideoOff")}),(0,f.jsx)(ui,{title:"Noise suppression",sub:"Filter background noise for clearer audio",on:z.noiseSuppression,onToggle:()=>r("noiseSuppression")}),(0,f.jsx)(ui,{title:"Low-bandwidth mode",sub:"Reduce video quality to save data",on:z.lowBandwidth,onToggle:()=>r("lowBandwidth")})]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Calling"}),(0,f.jsxs)("div",{className:"cafcall-card cafcall-person",children:[(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"nm",children:a.peer.name}),(0,f.jsx)("div",{className:"rl",children:a.peer.role})]}),(0,f.jsx)("span",{className:"cafcall-pill",children:"Waiting"})]}),(0,f.jsxs)("div",{style:{marginTop:18},children:[(0,f.jsxs)("button",{className:"cafcall-btn pri",onClick:h,children:[(0,f.jsx)(C.phone,{})," Join Call"]}),(0,f.jsx)("button",{className:"cafcall-btn ghost",onClick:l.actions.reset,children:"Cancel"})]})]})]})]})}function up({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsx)("div",{className:"cafcall-body",children:(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-pulse",children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:128})}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"cafcall-h",children:a.peer.name}),(0,f.jsx)("div",{className:"cafcall-p",children:a.peer.role})]}),(0,f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--caf-muted)"},children:["Calling ",(0,f.jsxs)("span",{className:"cafcall-dots",children:[(0,f.jsx)("i",{}),(0,f.jsx)("i",{}),(0,f.jsx)("i",{})]})]}),(0,f.jsx)("span",{className:"cafcall-pill",children:l.callType==="video"?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.cam,{})," Video call"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.mic,{})," Voice call"]})})]})}),(0,f.jsx)("div",{className:"cafcall-controls",children:(0,f.jsx)(na,{icon:"end",label:"Cancel",tone:"danger",onClick:l.actions.hangup})})]})}function ip({c:l,cfg:a}){let t=!!a.voiceOnly,e=!t&&l.callType==="video",[n,c]=(0,il.useState)({cam:e,mic:!0}),[u,i]=(0,il.useState)(!1),o=()=>{u||(i(!0),l.actions.setCallOptions({startVideoOff:e&&!n.cam,startMuted:!n.mic}),t||e&&!n.cam?l.actions.acceptVoice():l.actions.accept())},d=()=>{u||(i(!0),l.actions.acceptVoice())};return(0,il.useEffect)(()=>{if(!u)return;let v=setTimeout(()=>i(!1),2e4);return()=>clearTimeout(v)},[u]),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-pulse",children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:128})}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"cafcall-h",children:a.peer.name}),(0,f.jsx)("div",{className:"cafcall-p",children:a.peer.role})]}),(0,f.jsx)("span",{className:"cafcall-pill",children:e?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.cam,{})," Incoming Video Call"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.mic,{})," Incoming Voice Call"]})}),(0,f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10,color:"var(--caf-muted)"},children:["Ringing ",(0,f.jsxs)("span",{className:"cafcall-dots",children:[(0,f.jsx)("i",{}),(0,f.jsx)("i",{}),(0,f.jsx)("i",{})]})]}),(0,f.jsxs)("div",{className:"cafcall-infostrip",children:[(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"k",children:"Call Type"}),(0,f.jsx)("div",{className:"v",children:e?"Video":"Voice"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"k",children:"Network"}),(0,f.jsx)("div",{className:"v",style:{color:"var(--caf-ok)"},children:"Good"})]}),(0,f.jsxs)("div",{children:[(0,f.jsx)("div",{className:"k",children:"Encryption"}),(0,f.jsx)("div",{className:"v",children:"E2E"})]})]})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[(0,f.jsxs)("div",{className:"cafcall-note ok",children:[(0,f.jsxs)("b",{style:{color:"var(--caf-primary)"},children:["Incoming ",e?"video":"voice"," call"]}),(0,f.jsx)("br",{}),a.peer.name," is calling you",a.sessionTitle?` for a ${a.sessionTitle}.`:"."]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Caller"}),(0,f.jsxs)("div",{className:"cafcall-card cafcall-person",children:[(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"nm",children:a.peer.name}),(0,f.jsx)("div",{className:"rl",children:a.peer.role})]}),(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Calling"]})]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Answer with"}),e&&(0,f.jsxs)("div",{className:"cafcall-answerrow",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.cam,{})}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"t",children:"Camera"}),(0,f.jsx)("div",{className:"s",children:"Join with video"})]}),(0,f.jsx)(yr,{on:n.cam,onClick:()=>c(v=>({...v,cam:!v.cam}))})]}),(0,f.jsxs)("div",{className:"cafcall-answerrow",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.mic,{})}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"t",children:"Microphone"}),(0,f.jsx)("div",{className:"s",children:"Join with audio"})]}),(0,f.jsx)(yr,{on:n.mic,onClick:()=>c(v=>({...v,mic:!v.mic}))})]}),(0,f.jsxs)("div",{className:"cafcall-answerrow",children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.wifi,{})}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsx)("div",{className:"t",children:"Network Quality"}),(0,f.jsx)("div",{className:"s",children:"Good connection"})]}),(0,f.jsx)("span",{className:"cafcall-pill ok",children:"Good"})]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Can\u2019t answer?"}),(0,f.jsxs)("button",{className:"cafcall-answerrow as-btn",onClick:l.actions.decline,children:[(0,f.jsx)("span",{className:"ic",children:(0,f.jsx)(C.chat,{})}),(0,f.jsxs)("div",{style:{flex:1,textAlign:"left"},children:[(0,f.jsx)("div",{className:"t",children:"Send a Message"}),(0,f.jsxs)("div",{className:"s",children:["Let ",a.peer.name," know you\u2019re unavailable"]})]})]}),(0,f.jsxs)("div",{style:{marginTop:18,display:"flex",gap:10},children:[(0,f.jsxs)("button",{className:"cafcall-btn dngghost",onClick:l.actions.decline,disabled:u,children:[(0,f.jsx)(C.end,{})," Decline"]}),(0,f.jsx)("button",{className:"cafcall-btn pri",onClick:o,disabled:u,children:u?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.spinner,{})," Connecting\u2026"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.phone,{})," Accept Call"]})})]}),e&&(0,f.jsx)("button",{className:"cafcall-btn ghost",style:{marginTop:10},onClick:d,disabled:u,children:u?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.spinner,{})," Connecting\u2026"]}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(C.mic,{})," Answer as Voice Only"]})})]})]})]})}function ih({c:l,videoCall:a,simple:t}){if(!l.moreOpen)return null;let e=(n,c,u,i)=>(0,f.jsxs)("button",{className:"cafcall-sheet-item",onClick:()=>{u(),l.actions.closeMore()},children:[(0,f.jsx)("span",{className:`ic ${i?"on":""}`,children:(()=>{let o=C[n]||C.more;return(0,f.jsx)(o,{})})()}),c]});return(0,f.jsx)("div",{className:"cafcall-sheet-scrim",onClick:l.actions.closeMore,children:(0,f.jsxs)("div",{className:"cafcall-sheet",onClick:n=>n.stopPropagation(),children:[(0,f.jsx)("div",{className:"cafcall-sheet-grab"}),(0,f.jsxs)("div",{className:"cafcall-sheet-grid",children:[e("people","People",()=>l.actions.openPanel("people")),e("chat","Chat",()=>l.actions.openPanel("chat")),a&&e("share",l.sharing?"Stop Share":"Share",l.actions.toggleShare,l.sharing),!t&&e("settings","Settings",()=>l.actions.openPanel("settings"))]})]})})}function fh({c:l,cfg:a}){let[t,e]=(0,il.useState)(""),n=(0,il.useRef)(null);if((0,il.useEffect)(()=>{var u;(u=n.current)==null||u.scrollIntoView({behavior:"smooth"})},[l.messages,l.panel]),!l.panel)return null;let c=()=>{l.actions.sendMessage(t),e("")};return(0,f.jsxs)("div",{className:"cafcall-drawer",children:[(0,f.jsxs)("div",{className:"cafcall-drawer-head",children:[(0,f.jsx)("b",{children:l.panel==="people"?"People":"Chat"}),(0,f.jsx)("button",{className:"cafcall-iconbtn",style:{background:"#EEF2F7",color:"var(--caf-ink)"},onClick:l.actions.closePanel,children:"\u2715"})]}),l.panel==="people"?(0,f.jsx)("div",{className:"cafcall-drawer-body",children:[{...a.self,you:!0,muted:l.muted,off:!l.cameraOn},{...a.peer,you:!1,muted:l.peerMuted,off:l.peerCameraOff}].map((u,i)=>(0,f.jsxs)("div",{className:"cafcall-person",style:{padding:"10px 4px"},children:[(0,f.jsx)(ca,{name:u.name,src:u.avatar,size:40}),(0,f.jsxs)("div",{style:{flex:1},children:[(0,f.jsxs)("div",{className:"nm",children:[u.name,u.you?" (You)":""]}),(0,f.jsx)("div",{className:"rl",children:u.role})]}),(0,f.jsx)("span",{className:"ic",style:{color:u.muted?"var(--caf-danger)":"var(--caf-muted)"},children:u.muted?(0,f.jsx)(C.micOff,{}):(0,f.jsx)(C.mic,{})}),l.callType!=="voice"&&(0,f.jsx)("span",{className:"ic",style:{color:u.off?"var(--caf-danger)":"var(--caf-muted)"},children:u.off?(0,f.jsx)(C.camOff,{}):(0,f.jsx)(C.cam,{})})]},i))}):(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("div",{className:"cafcall-drawer-body cafcall-chat",children:[l.messages.length===0&&(0,f.jsx)("div",{className:"cafcall-p",style:{fontSize:13},children:"No messages yet. Say hello \u{1F44B}"}),l.messages.map(u=>{let i=String(u.sender)!==String(l.peerId);return(0,f.jsx)("div",{className:`cafcall-msg ${i?"mine":""}`,children:u.text},u.id)}),(0,f.jsx)("div",{ref:n})]}),(0,f.jsxs)("div",{className:"cafcall-chat-compose",children:[(0,f.jsx)("input",{value:t,onChange:u=>e(u.target.value),onKeyDown:u=>{u.key==="Enter"&&c()},placeholder:"Type a message\u2026"}),(0,f.jsx)("button",{className:"cafcall-btn pri",style:{width:"auto",padding:"10px 14px"},onClick:c,children:"Send"})]})]})]})}var oh=({c:l,videoCall:a,dark:t,simple:e})=>(0,f.jsxs)("div",{className:`cafcall-controls ${t?"dark":""}`,children:[(0,f.jsxs)("div",{className:"cafcall-controls-l",children:[(0,f.jsx)(na,{icon:"people",name:"people",label:"People",active:l.panel==="people",onClick:()=>l.actions.openPanel("people")}),(0,f.jsx)(na,{icon:"chat",name:"chat",label:"Chat",active:l.panel==="chat",onClick:()=>l.actions.openPanel("chat")})]}),(0,f.jsxs)("div",{className:"cafcall-controls-c",children:[(0,f.jsx)(na,{icon:l.muted?"micOff":"mic",name:"mute",label:l.muted?"Unmute":"Mute",on:l.muted,onClick:l.actions.toggleMute}),a&&(0,f.jsx)(na,{icon:l.cameraOn?"cam":"camOff",name:"camera",label:l.cameraOn?"Camera":"Camera Off",on:!l.cameraOn,onClick:l.actions.toggleCamera}),(0,f.jsx)(na,{icon:"end",name:"end",label:"End Call",tone:"danger",onClick:l.actions.hangup}),(0,f.jsx)(na,{icon:"speaker",name:"speaker",label:"Speaker",active:!0,onClick:()=>{}}),a&&(0,f.jsx)(na,{icon:"share",name:"share",label:l.sharing?"Stop Share":"Share",active:l.sharing,onClick:l.actions.toggleShare})]}),(0,f.jsxs)("div",{className:"cafcall-controls-r",children:[(0,f.jsx)(na,{icon:"more",name:"more",label:"More",active:l.moreOpen,onClick:l.actions.toggleMore}),!e&&(0,f.jsx)(na,{icon:"settings",name:"settings",label:"Settings",active:l.panel==="settings",onClick:()=>l.actions.openPanel("settings")})]})]});function th({c:l,cfg:a}){let t=ch(null),e=!l.peerMuted;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)("div",{className:"cafcall-body",style:{flexDirection:"column"},children:(0,f.jsxs)("div",{className:"cafcall-stage",children:[(0,f.jsx)(gr,{stream:l.remoteStream,sinkId:l.speakerId,volume:l.volume}),l.sharing&&(0,f.jsxs)("div",{className:"cafcall-sharebar",children:[(0,f.jsx)(C.share,{})," You\u2019re sharing your screen"]}),l.peerCameraOff&&(0,f.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"#fff"},children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:110})}),(0,f.jsxs)("div",{className:"cafcall-stage-top",children:[(0,f.jsxs)("div",{className:"cafcall-stack",children:[(0,f.jsxs)("span",{className:"cafcall-titlechip",children:[(0,f.jsx)("span",{className:"cafcall-logo",children:a.logoText}),(0,f.jsxs)("span",{children:[(0,f.jsx)("b",{children:a.sessionTitle}),(0,f.jsx)("small",{children:a.sessionSubtitle})]})]}),(0,f.jsxs)("span",{className:"cafcall-peerchip",children:[a.peer.avatar&&(0,f.jsx)("img",{src:a.peer.avatar,alt:""}),(0,f.jsx)("b",{children:a.peer.name}),(0,f.jsxs)("span",{style:{opacity:.85},children:["\xB7 ",a.peer.role,l.peerMuted?" \xB7 muted":e?" \xB7 Speaking":""]})]})]}),(0,f.jsx)("div",{className:"cafcall-topmid",children:(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Connected\xA0\xA0",ii(l.elapsed)]})}),(0,f.jsxs)("div",{className:"cafcall-topright",children:[(0,f.jsxs)("div",{className:"row",children:[(0,f.jsxs)("span",{className:"cafcall-pill enc",children:[(0,f.jsx)(C.lock,{})," E2E Encrypted"]}),(0,f.jsx)("button",{className:"cafcall-iconbtn",title:"Call info",children:(0,f.jsx)(C.info,{})}),(0,f.jsx)("button",{className:"cafcall-iconbtn",title:"Minimize",onClick:l.actions.minimize,children:(0,f.jsx)(C.shrink,{})})]}),(0,f.jsxs)("span",{className:`cafcall-pill ${t.tone}`,children:[(0,f.jsx)(C.wifi,{})," ",t.label]})]})]}),(0,f.jsxs)("div",{className:"cafcall-selftile",children:[l.cameraOn?(0,f.jsx)(gr,{stream:l.localStream,muted:!0,mirror:l.mirror}):(0,f.jsx)("div",{style:{height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:44})}),(0,f.jsxs)("span",{className:"cafcall-name",children:[a.self.name," (You) ",l.muted?(0,f.jsx)(C.micOff,{}):(0,f.jsx)(C.mic,{})]})]}),(0,f.jsxs)("div",{className:"cafcall-floatctl",children:[(0,f.jsx)("button",{className:"cafcall-floatbtn",title:"Flip camera",onClick:l.actions.toggleCamera,children:(0,f.jsx)(C.cam,{})}),(0,f.jsx)("button",{className:"cafcall-floatbtn end",title:"End call",onClick:l.actions.hangup,children:(0,f.jsx)(C.end,{})}),(0,f.jsx)("button",{className:"cafcall-floatbtn",title:l.muted?"Unmute":"Mute",onClick:l.actions.toggleMute,children:l.muted?(0,f.jsx)(C.micOff,{}):(0,f.jsx)(C.mic,{})})]}),(0,f.jsx)(fh,{c:l,cfg:a}),!a.simple&&(0,f.jsx)(uh,{c:l,cfg:a})]})}),(0,f.jsx)(oh,{c:l,videoCall:!0,dark:!0,simple:a.simple}),(0,f.jsx)(ih,{c:l,videoCall:!0,simple:a.simple})]})}function fp({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)("span",{className:"cafcall-pill ok",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Voice Only \xB7 ",ii(l.elapsed)]}),(0,f.jsx)(mc,{})]})}),(0,f.jsx)("div",{className:"cafcall-body",children:(0,f.jsxs)("div",{className:"cafcall-main cafcall-voice",children:[(0,f.jsx)(gr,{stream:l.remoteStream,sinkId:l.speakerId,volume:l.volume,audioOnly:!0}),(0,f.jsx)(fh,{c:l,cfg:a}),!a.simple&&(0,f.jsx)(uh,{c:l,cfg:a}),(0,f.jsxs)("div",{className:"cafcall-voice-row",children:[(0,f.jsxs)("div",{className:"cafcall-part",children:[(0,f.jsx)("div",{className:`cafcall-ring ${l.peerMuted?"":"speaking"}`,children:(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:120})}),(0,f.jsx)("div",{className:"cafcall-pname",children:a.peer.name}),(0,f.jsx)("div",{className:"cafcall-prole",children:a.peer.role}),l.peerMuted?(0,f.jsxs)("span",{className:"cafcall-pill warn",children:[(0,f.jsx)(C.micOff,{})," Muted"]}):(0,f.jsx)(P1,{})]}),(0,f.jsxs)("div",{className:"cafcall-part",children:[(0,f.jsx)("div",{className:`cafcall-ring ${l.muted?"":"speaking"}`,children:(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:120})}),(0,f.jsx)("div",{className:"cafcall-pname",children:a.self.name}),(0,f.jsxs)("div",{className:"cafcall-prole",children:[a.self.role," \xB7 You"]}),l.muted?(0,f.jsxs)("span",{className:"cafcall-pill warn",children:[(0,f.jsx)(C.micOff,{})," Microphone Muted"]}):(0,f.jsx)(P1,{})]})]})]})}),(0,f.jsx)(oh,{c:l,videoCall:!1,simple:a.simple}),(0,f.jsx)(ih,{c:l,videoCall:!1,simple:a.simple})]})}function op({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsxs)("span",{className:"cafcall-pill warn",children:[(0,f.jsx)("span",{className:"cafcall-dot"})," Reconnecting"]})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",style:{background:"var(--caf-stage)",color:"#fff"},children:[(0,f.jsx)("div",{className:"cafcall-icon-lg cafcall-spin",style:{background:"rgba(245,158,11,.15)",color:"var(--caf-warn)"},children:(0,f.jsx)(C.wifi,{})}),(0,f.jsx)("div",{className:"cafcall-h",style:{color:"#fff"},children:"Reconnecting\u2026"}),(0,f.jsx)("div",{className:"cafcall-p",style:{color:"#cbd5e1"},children:"Your connection was interrupted. Restoring the call automatically."})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[(0,f.jsxs)("div",{className:"cafcall-note warn",children:[(0,f.jsx)("b",{children:"Connection lost."}),(0,f.jsx)("br",{}),"Network instability detected \u2014 attempting to restore your call."]}),(0,f.jsxs)("div",{style:{marginTop:18},children:[(0,f.jsxs)("button",{className:"cafcall-btn ghost",onClick:l.actions.switchToVoice,children:[(0,f.jsx)(C.mic,{})," Switch to Voice Only"]}),(0,f.jsxs)("button",{className:"cafcall-btn dngghost",onClick:l.actions.hangup,children:[(0,f.jsx)(C.end,{})," End Call"]})]})]})]})]})}function rp({c:l,cfg:a}){return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a}),(0,f.jsx)("div",{className:"cafcall-body",children:(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-icon-lg",style:{background:"#FEF2F2",color:"var(--caf-danger)"},children:(0,f.jsx)(C.camOff,{})}),(0,f.jsx)("div",{className:"cafcall-h",children:"Camera & microphone blocked"}),(0,f.jsx)("div",{className:"cafcall-p",children:l.error||"Vocantly needs access to your camera and microphone to start the call. Enable them in your browser\u2019s site settings, then try again."}),(0,f.jsxs)("div",{style:{display:"flex",gap:10},children:[(0,f.jsx)("button",{className:"cafcall-btn pri",onClick:()=>l.actions.start(l.callType),style:{width:160},children:"Try Again"}),(0,f.jsx)("button",{className:"cafcall-btn ghost",onClick:l.actions.reset,style:{width:120},children:"Cancel"})]})]})})]})}var sp={local_hangup:"You ended the call.",remote_hangup:"The other participant ended the call.",declined:"Call declined.",declined_local:"You declined the call.",no_answer:"No answer.",connection_lost:"The call ended due to a lost connection."};function dp({c:l,cfg:a}){let[t,e]=(0,il.useState)(0),[n,c]=(0,il.useState)(!1),u=l.endedInfo||{},i=u.stats||{},o=d=>{var v;e(d),c(!0),(v=a.onRate)==null||v.call(a,d)};return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(re,{cfg:a,right:(0,f.jsx)(mc,{})}),(0,f.jsxs)("div",{className:"cafcall-body",children:[(0,f.jsxs)("div",{className:"cafcall-main cafcall-center",children:[(0,f.jsx)("div",{className:"cafcall-icon-lg",style:{background:"#DCFCE7",color:"var(--caf-ok)"},children:(0,f.jsx)(C.check,{})}),(0,f.jsx)("div",{className:"cafcall-h",children:"Call Ended"}),(0,f.jsxs)("div",{className:"cafcall-p",children:[sp[u.reason]||"The call has concluded."," A summary is below."]}),(0,f.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:26},children:[(0,f.jsxs)("div",{style:{textAlign:"center"},children:[(0,f.jsx)(ca,{name:a.self.name,src:a.self.avatar,size:56}),(0,f.jsx)("div",{className:"cafcall-prole",style:{marginTop:6},children:a.self.name})]}),(0,f.jsx)(C.check,{}),(0,f.jsxs)("div",{style:{textAlign:"center"},children:[(0,f.jsx)(ca,{name:a.peer.name,src:a.peer.avatar,size:56}),(0,f.jsx)("div",{className:"cafcall-prole",style:{marginTop:6},children:a.peer.name})]})]}),(0,f.jsxs)("div",{className:"cafcall-stats",style:{width:"min(520px,100%)"},children:[(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:ii(u.seconds||0)}),(0,f.jsx)("div",{className:"k",children:"Duration"})]}),(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:l.callType==="video"?"HD":"Voice"}),(0,f.jsx)("div",{className:"k",children:"Type"})]}),(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:ch(i).label}),(0,f.jsx)("div",{className:"k",children:"Network"})]}),(0,f.jsxs)("div",{className:"cafcall-stat",children:[(0,f.jsx)("div",{className:"v",children:i.rtt_ms!=null?`${Math.round(i.rtt_ms)}ms`:"\u2014"}),(0,f.jsx)("div",{className:"k",children:"Latency"})]})]})]}),(0,f.jsxs)("div",{className:"cafcall-side",children:[(0,f.jsxs)("div",{className:"cafcall-note ok",children:[(0,f.jsx)("b",{style:{color:"var(--caf-primary)"},children:"Call complete"}),(0,f.jsx)("br",{}),"Both participants were connected for the session."]}),(0,f.jsx)("div",{className:"cafcall-label",children:"Rate this call"}),(0,f.jsx)("div",{className:"cafcall-stars",children:[1,2,3,4,5].map(d=>(0,f.jsx)("button",{className:`cafcall-star ${d<=t?"on":""}`,onClick:()=>o(d),children:"\u2605"},d))}),n&&(0,f.jsx)("div",{className:"cafcall-prole",style:{marginTop:8},children:"Thanks for your feedback!"}),(0,f.jsxs)("div",{style:{marginTop:18},children:[(0,f.jsxs)("button",{className:"cafcall-btn pri",onClick:()=>l.actions.openLobby(l.callType),children:[(0,f.jsx)(C.phone,{})," Start New Call"]}),(0,f.jsx)("button",{className:"cafcall-btn ghost",onClick:l.actions.reset,children:"Close"})]})]})]})]})}function mp({c:l,cfg:a}){return(0,Ul.jsxs)("div",{className:"cafcall-mini",style:{"--caf-primary":a.primaryColor},children:[(0,Ul.jsx)("button",{className:"cafcall-mini-expand",onClick:l.actions.maximize,title:"Expand call",children:(0,Ul.jsx)(C.shrink,{})}),(0,Ul.jsxs)("div",{className:"cafcall-mini-info",children:[(0,Ul.jsx)("div",{className:"t",children:a.peer.name}),(0,Ul.jsxs)("div",{className:"s",children:[(0,Ul.jsx)("span",{className:"cafcall-dot",style:{color:"var(--caf-ok)"}})," ",ii(l.elapsed)]})]}),(0,Ul.jsxs)("div",{className:"cafcall-mini-ctls",children:[(0,Ul.jsx)(na,{icon:l.muted?"micOff":"mic",label:"",on:l.muted,onClick:l.actions.toggleMute}),l.callType!=="voice"&&(0,Ul.jsx)(na,{icon:l.cameraOn?"cam":"camOff",label:"",on:!l.cameraOn,onClick:l.actions.toggleCamera}),(0,Ul.jsx)(na,{icon:"end",label:"",tone:"danger",onClick:l.actions.hangup})]})]})}function rh({controller:l,config:a={},embed:t=!1}){let e=l,n={brandName:"Vocantly",logoText:"V",sessionTitle:"Call",sessionSubtitle:"Secured via Vocantly",primaryColor:"#2563EB",self:{name:"You",role:"Participant",avatar:null},peer:{name:"Guest",role:"Participant",avatar:null},onRate:a.onRate,...a};if(e&&(e.actions.openChat=a.onChat),(0,eh.useEffect)(()=>{ap()},[]),!e||e.phase==="idle")return null;if(e.minimized&&(e.phase==="active"||e.phase==="reconnecting"))return(0,Ul.jsx)(mp,{c:e,cfg:n});let u={lobby:cp,outgoing:up,incoming:ip,active:e.callType==="voice"?fp:th,reconnecting:op,permission_denied:rp,ended:dp}[e.phase]||th;return(0,Ul.jsx)("div",{className:`cafcall ${t?"cafcall-embed":""}`,style:{"--caf-primary":n.primaryColor},children:(0,Ul.jsx)(u,{c:e,cfg:n})})}var pr=Kl(oe(),1);function hp({convo:l,config:a,bindApi:t}){let e=nh(l);return(0,sh.useEffect)(()=>{t({start:n=>e.actions.openLobby(n)})},[e]),(0,pr.jsx)(rh,{controller:e,config:a})}function vp(l,a,t){let e=(0,dh.createRoot)(l),n={api:null,pending:null};return e.render((0,pr.jsx)(hp,{convo:a,config:t,bindApi:c=>{n.api=c,n.pending&&(c.start(n.pending),n.pending=null)}})),{startCall:(c="voice")=>{n.api?n.api.start(c):n.pending=c},unmount:()=>{try{e.unmount()}catch{}}}}return Ah(gp);})();
|