Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@daily-co/daily-react

Package Overview
Dependencies
Maintainers
21
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daily-co/daily-react - npm Package Compare versions

Comparing version 0.11.4 to 0.11.5

dist/lib/customDeepEqual.d.ts

2

dist/daily-react.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=require("recoil"),r=e(require("lodash.throttle")),a=e(require("fast-deep-equal")),o=e(require("@daily-co/daily-js"));function u(e,n,t,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void t(e)}u.done?n(c):Promise.resolve(c).then(i,r)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var a=e.apply(n,t);function o(e){u(a,i,r,o,c,"next",e)}function c(e){u(a,i,r,o,c,"throw",e)}o(void 0)}))}}function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)n.indexOf(t=a[i])>=0||(r[t]=e[t]);return r}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=new Array(n);t<n;t++)i[t]=e[t];return i}function f(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return d(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var p=n.createContext(null),v=function(){return n.useContext(p)},m=n.createContext({on:function(){},off:function(){}}),y=0,g=function(){return y++},k=function(e,t){var i=n.useContext(m),r=i.off,a=i.on,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),s=n.useMemo((function(){return g()}),[]);n.useEffect((function(){if(e&&!u){if(l.current>1e5)return console.error("useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.\n Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.\n Passed callback for '"+e+"' event is NOT registered.",t),void c(!0);l.current++;var n=setTimeout((function(){l.current=0}),50);return a(e,t,s),function(){clearTimeout(n),r(e,s)}}}),[t,e,s,u,r,a])},b=function(e,t,i){void 0===i&&(i=100);var a=n.useContext(m),o=a.off,u=a.on,c=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=g(),e}),{}):((n={})[e]=g(),n)}),[e]),l=n.useRef([]),s=n.useMemo((function(){return r((function(){0!==l.current.length&&(t(l.current),l.current=[])}),i,{trailing:!0})}),[t,i]);n.useEffect((function(){if(e){var n=function(e){l.current.push(e),setTimeout(s,0)};return Array.isArray(e)?e.forEach((function(e){return u(e,n,c[e])})):u(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,c[e])})):o(e,c[e])}}}),[s,e,c,o,u])},S=i.atom({key:"daily-react-active-id",default:null}),h=i.atom({key:"daily-react-local-id",default:""}),C=i.atom({key:"daily-react-local-joined-date",default:null}),R=i.atom({key:"daily-react-participant-ids",default:[]}),A=i.atomFamily({key:"daily-react-participant-state",default:null}),E=i.selector({key:"daily-react-participants",get:function(e){var n=e.get;return n(R).map((function(e){return n(A(e))})).filter(Boolean)}}),w=i.atom({key:"daily-react-waiting-participants",default:[]}),x=i.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),T=i.selector({key:"daily-react-waitingParticipantsSelector",get:function(e){var n=e.get;return n(w).map((function(e){return n(x(e))}))}}),_=function(e){var r=e.children,a=v(),o=n.useState(!1),u=o[0],c=o[1],s=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(h,e.local.session_id);var i=Object.values(e),r=i.map((function(e){return e.session_id}));t(R,r),i.forEach((function(e){t(A(e.session_id),e)})),c(!0)}))}}),[]);n.useEffect((function(){if(a&&!u){var e=setInterval((function(){var n=a.participants();"local"in n&&(s(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,u,s]);var d=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&s(e)}}),[a,s]);return k("started-camera",d),k("access-state-updated",d),k("joining-meeting",i.useRecoilCallback((function(e){var n=e.set;return function(){n(C,new Date),d()}}),[d])),k("joined-meeting",n.useCallback((function(e){s(e.participants)}),[s])),b(["active-speaker-change","left-meeting","participant-joined","participant-updated","participant-left"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.get,i=n.reset,r=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":var n=e.activeSpeaker.peerId;r(S,n),r(A(n),(function(e){return e?l({},e,{last_active:new Date}):null}));break;case"participant-joined":r(R,(function(n){return n.includes(e.participant.session_id)?n:[].concat(n,[e.participant.session_id])})),r(A(e.participant.session_id),e.participant);break;case"participant-updated":r(A(e.participant.session_id),(function(n){return l({},n,e.participant)})),e.participant.local&&r(h,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));break;case"participant-left":r(R,(function(n){return n.includes(e.participant.session_id)?[].concat(n.filter((function(n){return n!==e.participant.session_id}))):n})),i(A(e.participant.session_id));break;case"left-meeting":i(h),t(R).forEach((function(e){return i(A(e))})),i(R)}}))}))}}),[])),b(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"waiting-participant-added":i(w,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),i(x(e.participant.id),e.participant);break;case"waiting-participant-updated":i(x(e.participant.id),e.participant);break;case"waiting-participant-removed":i(w,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(x(e.participant.id))}}))}))}}),[])),t.createElement(t.Fragment,null,r)},I=function(){return i.useRecoilValue(h)},L=function(){return!0},P=function(e){var t=void 0===e?{}:e,r=t.filter,a=void 0===r?L:r,o=t.ignoreLocal,u=void 0!==o&&o,c=I(),l=i.useRecoilValue(S),s=n.useState(null),d=s[0],f=s[1];return n.useEffect((function(){u&&l===c||null!=a&&a(l)&&f(l)}),[a,c,u,l]),d},D=function(e){return["blocked","off"].includes(e.state)},j=Boolean,M=function(){return 0},V=function(e){var t=void 0===e?{filter:j,sort:M}:e,r=t.filter,o=void 0===r?j:r,u=t.onActiveSpeakerChange,l=t.onParticipantJoined,s=t.onParticipantLeft,d=t.onParticipantUpdated,f=t.sort,p=void 0===f?M:f,v=n.useState([]),m=v[0],y=v[1],g=n.useMemo((function(){var e=j;switch(o){case"local":e=function(e){return e.local};break;case"owner":e=function(e){return e.owner};break;case"record":e=function(e){return e.record};break;case"remote":e=function(e){return!e.local};break;case"screen":e=function(e){return!D(e.tracks.screenAudio)||!D(e.tracks.screenVideo)};break;default:e=o}return e}),[o]),k=n.useMemo((function(){var e;switch(p){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,n){var t=e[p],i=n[p];if(void 0!==t||void 0!==i){if(void 0===t)return-1;if(void 0===i)return 1;if(t>i)return 1;if(t<i)return-1}return 0};break;default:e=p}return e}),[p]),S=n.useCallback((function(e){return e.filter(g).sort(k).map((function(e){return e.session_id})).filter(Boolean)}),[g,k]),h=n.useCallback((function(e){y((function(n){return a(n,e)?n:e}))}),[]),C=i.useRecoilCallback((function(e){var n=e.snapshot;return c((function*(){var e=S(yield n.getPromise(E));h(e)}))}),[S,h]);return n.useEffect((function(){C()}),[C]),i.useRecoilTransactionObserver_UNSTABLE(function(){var e=c((function*(e){var n=e.snapshot,t=yield n.getPromise(E),i=S(t);h(i)}));return function(n){return e.apply(this,arguments)}}()),b(["participant-joined","participant-updated","active-speaker-change","participant-left"],n.useCallback((function(e){e.length&&e.forEach((function(e){switch(e.action){case"participant-joined":null==l||l(e);break;case"participant-updated":null==d||d(e);break;case"active-speaker-change":null==u||u(e);break;case"participant-left":null==s||s(e)}}))}),[u,l,s,d])),m};function O(e,n){if(e===n)return!0;if(e instanceof MediaStream&&n instanceof MediaStream)return e.id===n.id&&e.active===n.active&&e.getTracks().length===n.getTracks().length&&e.getTracks().every((function(e,t){return O(e,n.getTracks()[t])}));if(e instanceof MediaStreamTrack&&n instanceof MediaStreamTrack)return e.id===n.id&&e.kind===n.kind&&e.readyState===n.readyState;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.source===n.source&&e.flags===n.flags;if(e instanceof Set&&n instanceof Set)return O([].concat(e),[].concat(n));if(e instanceof Map&&n instanceof Map)return O(Object.fromEntries(e),Object.fromEntries(n));if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var t=Object.keys(e),i=Object.keys(n);if(t.length!==i.length)return!1;for(var r,a=f(new Set([].concat(t,i)));!(r=a()).done;){var o=r.value;if(o in e&&!(o in n)||o in n&&!(o in e)||!O(e[o],n[o]))return!1}return!0}var B=function(e){var t=void 0===e?{}:e,r=t.onLocalScreenShareStarted,a=t.onLocalScreenShareStopped,o=v(),u=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==o||o.startScreenShare.apply(o,n)}),[o]),l=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==o||o.stopScreenShare.apply(o,n)}),[o]);k("local-screen-share-started",n.useCallback((function(){return null==r?void 0:r()}),[r])),k("local-screen-share-stopped",n.useCallback((function(){return null==a?void 0:a()}),[a]));var s=V({filter:"screen"}),d=n.useState([]),f=d[0],p=d[1],m=n.useCallback((function(e){p((function(n){return O(e,n)?n:e}))}),[]),y=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){return(yield Promise.all(e.map(function(){var e=c((function*(e){return yield n.getPromise(A(e))}));return function(n){return e.apply(this,arguments)}}()))).filter((function(e){return Boolean(e)})).map((function(e){return{local:e.local,screenAudio:e.tracks.screenAudio,screenVideo:e.tracks.screenVideo,screenId:e.session_id+"-screen",session_id:e.session_id}})).filter(Boolean)}));return function(n){return e.apply(this,arguments)}}()}),[]),g=n.useCallback(c((function*(){m(yield y(s))})),[y,m,s]);return n.useEffect((function(){g()}),[g]),i.useRecoilTransactionObserver_UNSTABLE(c((function*(){m(yield y(s))}))),{isSharingScreen:f.some((function(e){return e.local})),screens:f,startScreenShare:u,stopScreenShare:l}},U=function(e,n){return n.map((function(n){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(e,n)}))},F=i.selectorFamily({key:"daily-react-participant-property",get:function(e){var n=e.id,t=e.properties;return function(e){var i=(0,e.get)(A(n));return U(i,t)}}}),N=function(e,t){var r=v(),a=[];if(r&&!r.isDestroyed()){var o=Object.values(r.participants()).find((function(n){return n.session_id===e}));o&&(a=U(o,Array.isArray(t)?t:[t]))}var u=n.useState(a),l=u[0],s=u[1],d=n.useCallback((function(e){s((function(n){return O(e,n)?n:e}))}),[]),f=i.useRecoilCallback((function(n){var i=n.snapshot;return c((function*(){var n=yield i.getPromise(F({id:e,properties:Array.isArray(t)?t:[t]}));d(n)}))}),[d,e,t]);return n.useEffect((function(){f()}),[f]),i.useRecoilTransactionObserver_UNSTABLE(function(){var n=c((function*(n){var i=n.snapshot,r=yield i.getPromise(F({id:e,properties:Array.isArray(t)?t:[t]}));d(r)}));return function(e){return n.apply(this,arguments)}}()),Array.isArray(t)?l:l[0]},q=function(e,n){void 0===n&&(n="video");var t=N(e,"tracks."+n);return t?l({},t,{isOff:"blocked"===t.state||"off"===t.state}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1}};function W(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var i=t[n];"function"==typeof i?i(e):i&&"object"==typeof i&&(i.current=e)}}),t)}var z=["onPlayFailed","sessionId","type"],H=n.memo(n.forwardRef((function(e,i){var r=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,c=s(e,z),l=n.useRef(null),d=q(a,u),f=W(l,i);return n.useEffect((function(){var e=l.current;if(e&&null!=d&&d.persistentTrack){var n,t=function(){n=setTimeout((function(){(e.readyState!==e.HAVE_ENOUGH_DATA||e.paused)&&(null==r||r({sessionId:a,target:e,type:u}))}),1500)},i=function(){clearTimeout(n)};return e.addEventListener("canplay",t),e.addEventListener("play",i),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",t),null==e||e.removeEventListener("play",i)}}}),[null==d?void 0:d.persistentTrack,r,a,u]),t.createElement("audio",Object.assign({autoPlay:!0,playsInline:!0,ref:f},c,{"data-session-id":a,"data-audio-type":u}))})));H.displayName="DailyAudioTrack";var G=n.memo(n.forwardRef((function(e,r){var a=e.maxSpeakers,o=e.onPlayFailed,u=e.playLocalScreenAudio,l=void 0!==u&&u,s=n.useState(new Array(void 0===a?5:a).fill("")),d=s[0],f=s[1],p=B().screens,v=I(),m=P({ignoreLocal:!0}),y=n.useRef(null);n.useImperativeHandle(r,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=y.current)?void 0:n.querySelector('audio[data-session-id="'+m+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=y.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=y.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getRmpAudio:function(){var e,n;return Array.from(null!=(e=null==(n=y.current)?void 0:n.querySelectorAll('audio[data-audio-type="rmpAudio"]'))?e:[])},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=y.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getRmpAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=y.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="rmpAudio"]'))?n:null},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=y.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[m]);var g=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){var t=(yield n.getPromise(E)).filter((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)})),i=function(e){return t.some((function(n){return n.session_id===e}))};i(e)&&f((function(n){var r;if(n.includes(e))return n;var a=function(e){return!e||!i(e)};if(n.some(a)){var o=n.findIndex(a);return n[o]=e,[].concat(n)}var u=n.findIndex((function(e){return t.some((function(n){return n.session_id===e&&D(n.tracks.audio)}))}));if(u>=0)return n[u]=e,[].concat(n);var c=t.filter((function(e){return n.includes(e.session_id)&&e.session_id!==m})).sort((function(e,n){var t,i,r=null!=(t=null==e?void 0:e.last_active)?t:new Date("1970-01-01"),a=null!=(i=null==n?void 0:n.last_active)?i:new Date("1970-01-01");return r>a?1:r<a?-1:0}));if(!c.length){var l=n.findIndex((function(e){return e!==m}));return n[l]=e,[].concat(n)}var s=n.indexOf(null==(r=c[0])?void 0:r.session_id);return n[s]=e,[].concat(n)}))}));return function(n){return e.apply(this,arguments)}}()}),[m]),k=n.useCallback((function(e){f((function(n){if(!n.includes(e))return n;var t=[].concat(n),i=t.indexOf(e);return t[i]="",t}))}),[]);b(["active-speaker-change","track-started","participant-left"],n.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===v)return;g(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&g(e.participant.session_id);break;case"participant-left":k(e.participant.session_id)}}))}),[g,v,k]));var S=V({filter:n.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return t.createElement("div",{ref:y},d.map((function(e,n){return t.createElement(H,{key:"speaker-slot-"+n,onPlayFailed:o,sessionId:e,type:"audio"})})),p.filter((function(e){return!!l||!e.local})).map((function(e){return t.createElement(H,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:"screenAudio"})})),S.map((function(e){return t.createElement(H,{key:e+"-rmp",onPlayFailed:o,sessionId:e,type:"rmpAudio"})})))})));G.displayName="DailyAudio";var Q=["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"],J=n.forwardRef((function(e,i){var r=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,c=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,m=void 0===v?{}:v,y=e.type,g=void 0===y?"video":y,k=s(e,Q),b=I()===p,S="screenVideo"===g,h=b&&!S,C=n.useRef(null),R=W(C,i),A=q(p,g),E=A.persistentTrack,w=h||S||!A.isOff,x=N(p,"tracks."+g),T=null==x?void 0:x.subscribed,_=n.useMemo((function(){if("boolean"==typeof u)return u;if(!r)return!1;if(!E)return h;var e=E.getSettings();return"facingMode"in e?h&&"user"===e.facingMode:h}),[r,h,u,E]);return n.useEffect((function(){var e=C.current;if(e){var n=function(){var n=e.play();void 0!==n&&n.then((function(){e.controls=!1})).catch((function(n){e.controls=!0,console.warn("Failed to play video",n)}))},t=function(){e.paused&&n()},i=function(){e.style.transform="scale(1)"},r=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},a=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",i),e.addEventListener("leavepictureinpicture",r),document.addEventListener("visibilitychange",a),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",i),e.removeEventListener("leavepictureinpicture",r),document.removeEventListener("visibilitychange",a)}}}),[]),n.useEffect((function(){var e=C.current;if(e&&E)return e.srcObject=new MediaStream([E]),e.load(),function(){e.srcObject=null,e.load()}}),[E,null==E?void 0:E.id]),n.useEffect((function(){var e,n=C.current;if(c&&n)return t(),n.addEventListener("loadedmetadata",t),n.addEventListener("resize",t),function(){e&&cancelAnimationFrame(e),n.removeEventListener("loadedmetadata",t),n.removeEventListener("resize",t)};function t(){e&&cancelAnimationFrame(e),e=requestAnimationFrame((function(){var e=C.current;if(e&&!document.hidden){var n=e.videoWidth,t=e.videoHeight;n&&t&&(null==c||c({aspectRatio:n/t,height:t,width:n}))}}))}}),[c]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:R,"data-local":b,"data-mirrored":_||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":T,"data-video-type":g,style:l({objectFit:o,transform:_?"scale(-1, 1)":""},m,w?f:{})},k))}));J.displayName="DailyVideo";var $=n.createContext({refreshDevices:function(){return Promise.resolve()}}),K=i.atom({key:"daily-react-general-camera-state",default:"idle"}),X=i.atom({key:"daily-react-general-microphone-state",default:"idle"}),Y=i.atom({key:"daily-react-camera-devices",default:[]}),Z=i.atom({key:"daily-react-microphone-devices",default:[]}),ee=i.atom({key:"daily-react-speaker-devices",default:[]}),ne=i.atom({key:"daily-react-last-camera-error",default:null}),te=function(e){var r=e.children,a=v(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return c((function*(){var e,t,i,r;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(i=navigator)||null==(r=i.mediaDevices)?void 0:r.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,p=s.speaker,v=function(e,n,t){var i,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(i=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?i:"granted"}},m=function(e,n){return"default"===e.device.deviceId?-1:"default"===n.device.deviceId?1:e.device.label<n.device.label?-1:e.device.label>n.device.label?1:0};n((function(e){var n=e.set;n(Y,(function(e){return u.filter(Boolean).map((function(n){return v(d,n,e)})).sort(m)})),n(Z,(function(e){return c.filter(Boolean).map((function(n){return v(f,n,e)})).sort(m)})),n(ee,(function(e){return l.filter(Boolean).map((function(n){return v(p,n,e)})).sort(m)}))}))}catch(e){n((function(e){var n=e.set;n(K,"not-supported"),n(X,"not-supported")}))}}else n((function(e){var n=e.set;n(K,"not-supported"),n(X,"not-supported")}))}))}),[a]),u=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,i=e.transact_UNSTABLE;return c((function*(){var e,r,u,c,s,d,f,p,v,m,y,g,k,b;if(a){var S=yield t.getPromise(K),h=yield t.getPromise(X),C=a.participants();if(C.local){var R=C.local.tracks,A=["idle","pending"].includes(S)&&"interrupted"===R.video.state&&!R.video.persistentTrack,E=["idle","pending"].includes(S)&&!R.video.persistentTrack&&Boolean(null==(e=R.video.off)?void 0:e.byUser),w=["idle","pending"].includes(h)&&"interrupted"===R.audio.state&&!R.audio.persistentTrack,x=["idle","pending"].includes(h)&&!R.audio.persistentTrack&&Boolean(null==(r=R.audio.off)?void 0:r.byUser);null!=(u=R.audio)&&null!=(c=u.blocked)&&c.byDeviceInUse?i((function(e){var n=e.set;n(X,"in-use"),n(Z,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):null!=(s=R.audio)&&null!=(d=s.blocked)&&d.byDeviceMissing?n(X,"not-found"):null!=(f=R.audio)&&null!=(p=f.blocked)&&p.byPermissions?n(X,"blocked"):w?n(X,"pending"):x?n(X,"idle"):i((function(e){var n=e.set;n(X,"granted"),n(Z,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),null!=(v=R.video)&&null!=(m=v.blocked)&&m.byDeviceInUse?i((function(e){var n=e.set;n(K,"in-use"),n(Y,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):null!=(y=R.video)&&null!=(g=y.blocked)&&g.byDeviceMissing?n(K,"not-found"):null!=(k=R.video)&&null!=(b=k.blocked)&&b.byPermissions?n(K,"blocked"):A?n(K,"pending"):E?n(K,"idle"):i((function(e){var n=e.set;n(K,"granted"),n(Y,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return k("participant-updated",n.useCallback((function(e){e.participant.local&&u()}),[u])),k("available-devices-updated",o),k("selected-devices-updated",o),k("camera-error",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,i,r,a,o,u,c,l=n.set;switch(l(ne,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":l(K,"in-use");break;case"mic-in-use":l(X,"in-use");break;case"cam-mic-in-use":l(K,"in-use"),l(X,"in-use");break;case"not-found":null!=(i=e.error)&&i.missingMedia.includes("video")&&l(K,"not-found"),null!=(r=e.error)&&r.missingMedia.includes("audio")&&l(X,"not-found");break;case"permissions":null!=(a=e.error)&&a.blockedMedia.includes("video")&&l(K,"blocked"),null!=(o=e.error)&&o.blockedMedia.includes("audio")&&l(X,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(l(K,"constraints-invalid"),l(X,"constraints-invalid")):"none-specified"===(null==(c=e.error)?void 0:c.reason)&&(l(K,"constraints-none-specified"),l(X,"constraints-none-specified"));break;case"undefined-mediadevices":l(K,"undefined-mediadevices"),l(X,"undefined-mediadevices");break;case"unknown":default:l(K,"unknown"),l(X,"unknown")}}))}}),[])),k("started-camera",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(K,"granted"),n(X,"granted")})),u()}}),[u])),t.createElement($.Provider,{value:{refreshDevices:o}},r)},ie=i.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),re=function(e){var n=e.children;return k("live-streaming-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ie,{isLiveStreaming:!0,layout:null==e?void 0:e.layout})}}),[])),k("live-streaming-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ie,(function(e){return l({},e,{isLiveStreaming:!1,layout:void 0})}))}}),[])),k("live-streaming-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ie,(function(n){return l({},n,{errorMsg:e.errorMsg})}))}}),[])),t.createElement(t.Fragment,null,n)},ae=i.atom({key:"daily-react-meeting-state",default:"new"}),oe=i.atom({key:"meeting-session-data",default:{data:void 0,topology:"none"}}),ue=function(e){var n=e.children,r=v(),a=i.useRecoilCallback((function(e){var n=e.set;return function(){if(r){var e=r.meetingState();return n(ae,e),e}}}),[r]);k("loading",a),k("loaded",a),k("joining-meeting",a),k("joined-meeting",a),k("left-meeting",a),k("error",a);var o=i.useRecoilCallback((function(e){var n=e.set;return function(){r&&n(oe,r.meetingSessionState())}}),[r]);return k("joined-meeting",o),k("meeting-session-state-updated",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(oe,e.meetingSessionState)}}),[])),k("left-meeting",i.useRecoilCallback((function(e){var n=e.reset;return function(){n(oe)}}),[])),t.createElement(t.Fragment,null,n)},ce=i.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),le=function(e){var r=e.children,a=i.useSetRecoilState(ce),o=I(),u=V({filter:"record"});return n.useEffect((function(){var e=u.length>0,n=u.includes(o||"local");a((function(t){return l({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[o,u,a]),k("recording-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var i;o&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==o&&(t=!1)}n(ce,{error:!1,isLocalParticipantRecorded:t,isRecording:!0,layout:null==e?void 0:e.layout,local:null==e?void 0:e.local,recordingId:null==e?void 0:e.recordingId,recordingStartedDate:new Date,startedBy:null==e?void 0:e.startedBy,type:null==e?void 0:e.type})}}),[o])),k("recording-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ce,(function(e){return l({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),k("recording-error",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ce,(function(e){return l({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),t.createElement(t.Fragment,null,r)},se=function(){return i.useRecoilValue(ae)},de=i.atom({key:"daily-react-room",default:null}),fe=function(e){var n=e.children,r=v(),a=se(),o=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(r&&"left-meeting"!==a){var e=yield r.room();return e&&"id"in e&&n(de,e),e}}))}),[r,a]);return k("access-state-updated",o),t.createElement(t.Fragment,null,n)},pe=["children","recoilRootProps"],ve=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,o=r.onParticipantUpdated,u=i.useRecoilValue(A(e));return b(["participant-updated","participant-left"],n.useCallback((function(n){var t=n.filter((function(n){return n.participant.session_id===e}));t.length&&t.forEach((function(e){switch(e.action){case"participant-updated":null==o||o(e);break;case"participant-left":null==a||a(e)}}))}),[a,o,e])),u},me="data:application/javascript;charset=utf8,"+encodeURIComponent("\n class AudioLevelProcessor extends AudioWorkletProcessor {\n volume;\n interval;\n nextFrame;\n \n constructor() {\n super();\n this.volume = 0;\n this.interval = 25;\n this.nextFrame = this.interval;\n }\n \n get intervalInFrames() {\n // sampleRate is globally defined in AudioWorklets.\n // See https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope\n // eslint-disable-next-line no-undef\n return (this.interval / 1000) * sampleRate;\n }\n \n process(inputList) {\n const firstInput = inputList[0];\n \n if (firstInput.length > 0) {\n const inputData = firstInput[0];\n let total = 0;\n \n for (let i = 0; i < inputData.length; ++i) {\n total += Math.abs(inputData[i]);\n }\n \n const rms = Math.sqrt(total / inputData.length);\n this.volume = Math.max(0, Math.min(1, rms));\n \n this.nextFrame -= inputData.length;\n if (this.nextFrame < 0) {\n this.nextFrame += this.intervalInFrames;\n this.port.postMessage({ volume: this.volume });\n }\n }\n \n return true;\n }\n }\n \n registerProcessor('audiolevel', AudioLevelProcessor); \n"),ye=i.atom({key:"cpu-load-state",default:{state:"low",reason:"none"}}),ge=i.atom({key:"daily-react-input-settings",default:null}),ke=i.atom({key:"daily-react-input-settings-error",default:null}),be=i.atom({key:"daily-react-topology",default:"none"}),Se=i.atom({key:"daily-react-networkQuality",default:100}),he=i.atom({key:"daily-react-networkThreshold",default:"good"}),Ce=i.atom({key:"daily-react-participant-counts",default:{hidden:0,present:0}}),Re=i.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),Ae=function(){return i.useRecoilValue(de)},Ee=i.atom({key:"daily-react-send-settings",default:null}),we=i.atom({key:"daily-react-transcription",default:{isTranscriptionEnabled:!1,isTranscribing:!1,model:"general",language:"en",transcriptions:[]}});exports.DailyAudio=G,exports.DailyAudioTrack=H,exports.DailyProvider=function(e){var r=e.children,a=e.recoilRootProps,u=void 0===a?{}:a,d=s(e,pe),v="callObject"in d?d.callObject:null,y=n.useState(v),g=y[0],k=y[1],b=n.useRef({});n.useEffect((function(){v&&(v?((null==g?void 0:g._callFrameId)!==(null==v?void 0:v._callFrameId)||!g&&v)&&k(v):k(null))}),[g,v]);var S=n.useCallback((function(e){if("action"in e)for(var n,t=f(null!=(i=null==(r=b.current)||null==(a=r[e.action])?void 0:a.values())?i:[]);!(n=t()).done;){var i,r,a;(0,n.value)(e)}}),[]),h=n.useCallback((function(e){e&&Object.keys(b.current).forEach((function(n){e.off(n,S),e.isDestroyed()||e.on(n,S)}))}),[S]),C=n.useRef();n.useEffect((function(){if("callObject"in d)return k(d.callObject),void h(d.callObject);function e(){return(e=c((function*(e){yield e.destroy()}))).apply(this,arguments)}if(g)O(C.current,d)||function(n){e.apply(this,arguments)}(g);else{var n=o.getCallInstance();n||(n=o.createCallObject(l({},d)),C.current=d),k(n),h(n),n.once("call-instance-destroyed",(function(){k(null)}))}}),[g,h,d]);var R=n.useCallback((function(e,n,t){var i,r;b.current[e]||(b.current[e]=new Map,g&&(g.off(e,S),g.isDestroyed()||g.on(e,S))),null!=(i=b.current[e])&&i.has(t)||null==(r=b.current[e])||r.set(t,n)}),[g,S]),A=n.useCallback((function(e,n){var t,i;null==(t=b.current[e])||t.delete(n),0===(null==(i=b.current[e])?void 0:i.size)&&(null==g||g.off(e,S),delete b.current[e])}),[g,S]);return t.createElement(i.RecoilRoot,Object.assign({},u),t.createElement(p.Provider,{value:g},t.createElement(m.Provider,{value:{on:R,off:A}},t.createElement(fe,null,t.createElement(ue,null,t.createElement(_,null,t.createElement(le,null,t.createElement(re,null,t.createElement(te,null,r)))))))))},exports.DailyVideo=J,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=v(),c=i.useRecoilValue(S),l=n.useState(""),s=l[1],d=ve(l[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==n?void 0:n.session_id)||s(null!=c?c:"")}}),[u,a,c]),k("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),d},exports.useActiveSpeakerId=P,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,i=v(),r=n.useCallback((function(e,n){void 0===n&&(n="*"),i&&i.sendAppMessage(e,n)}),[i]),a=n.useCallback((function(e){null==t||t(e,r)}),[t,r]);return k("app-message",a),r},exports.useAudioLevel=function(e,t){var i=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){i.current||(i.current=new n);var r=i.current;if(r){var a,o=r.createMediaStreamSource(new MediaStream([e]));return function(){var e=c((function*(){try{a=new AudioWorkletNode(r,"audiolevel")}catch(e){try{yield r.audioWorklet.addModule(me),a=new AudioWorkletNode(r,"audiolevel")}catch(e){console.error(e)}}if(a){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)};try{o.connect(a).connect(r.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==o||o.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return q(e,"audio")},exports.useCPULoad=function(e){var t=(void 0===e?{}:e).onCPULoadChange,r=i.useRecoilValue(ye),o=v(),u=se(),l=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot;return function(){var e=c((function*(e){var i=yield t.getPromise(ye);a(i,e)||n(ye,e)}));return function(n){return e.apply(this,arguments)}}()}),[]);return n.useEffect((function(){var e=!0;if(o&&!o.isDestroyed()&&"joined-meeting"===u)return o.getCpuLoadStats().then((function(n){e&&l({state:n.cpuLoadState,reason:n.cpuLoadStateReason})})),function(){e=!1}}),[o,u,l]),k("cpu-load-change",n.useCallback((function(e){l({state:e.cpuLoadState,reason:e.cpuLoadStateReason}),null==t||t(e)}),[t,l])),r},exports.useDaily=v,exports.useDailyEvent=k,exports.useDevices=function(){var e=v(),t=i.useRecoilValue(K),r=i.useRecoilValue(X),a=i.useRecoilValue(Y),o=i.useRecoilValue(Z),u=i.useRecoilValue(ee),l=i.useRecoilValue(ne),s=n.useContext($).refreshDevices,d=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),m=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"];return{cameraError:l,cameras:a,camState:t,currentCam:a.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:m.includes(t),hasMicError:m.includes(r),microphones:o,micState:r,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:p,speakers:u}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(ge),u=i.useRecoilValue(ke),c=v(),l=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ge,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),k("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),k("nonfatal-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){"input-settings-error"===e.type&&(n(ke,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==c||c.updateInputSettings.apply(c,n)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=v(),c=i.useRecoilValue(ie);return k("live-streaming-started",n.useCallback((function(e){null==a||a(e)}),[a])),k("live-streaming-stopped",n.useCallback((function(e){null==o||o(e)}),[o])),k("live-streaming-error",n.useCallback((function(e){null==r||r(e)}),[r])),l({},c,{startLiveStreaming:n.useCallback((function(){u&&u.startLiveStreaming.apply(u,arguments)}),[u]),stopLiveStreaming:n.useCallback((function(){u&&u.stopLiveStreaming.apply(u,arguments)}),[u]),updateLiveStreaming:n.useCallback((function(){u&&u.updateLiveStreaming.apply(u,arguments)}),[u])})},exports.useLocalParticipant=function(){var e=i.useRecoilValue(h);return ve(e)},exports.useLocalSessionId=I,exports.useMediaTrack=q,exports.useMeetingSessionState=function(){var e=i.useRecoilValue(oe);return{data:null==e?void 0:e.data,topology:null==e?void 0:e.topology}},exports.useMeetingState=se,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,o=v(),u=i.useRecoilValue(be),l=i.useRecoilValue(Se),s=i.useRecoilValue(he),d=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(o){var e=yield o.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(be,e.topology)}}))}),[o]),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&t(be,"peer"),"sfu"===e.type&&t(be,"sfu")}})),null==r||r(e)}}),[r]),p=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(Se,(function(n){return n!==e.quality?e.quality:n})),t(he,(function(n){return n!==e.threshold?e.threshold:n}))})),null==a||a(e)}}),[a]);return k("joined-meeting",d),k("network-connection",f),k("network-quality-change",p),n.useEffect((function(){o&&!u&&d()}),[o,d,u]),{getStats:n.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u}},exports.useParticipant=ve,exports.useParticipantCounts=function(e){var t=(void 0===e?{}:e).onParticipantCountsUpdated,r=v(),a=i.useRecoilValue(Ce),o=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Ce,e)}}),[]);return k("participant-counts-updated",n.useCallback((function(e){o(e.participantCounts),null==t||t(e)}),[t,o])),n.useEffect((function(){r&&!r.isDestroyed()&&o(r.participantCounts())}),[r,o]),a},exports.useParticipantIds=V,exports.useParticipantProperty=N,exports.usePermissions=function(e){var n=I(),t=N(null!=e?e:n,"permissions"),i="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("audio"),r="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("video"),a="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("customAudio"),o="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("customVideo"),u="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("screenAudio"),c="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("screenVideo");return{canAdminParticipants:"boolean"==typeof(null==t?void 0:t.canAdmin)?null==t?void 0:t.canAdmin:null==t?void 0:t.canAdmin.has("participants"),canAdminStreaming:"boolean"==typeof(null==t?void 0:t.canAdmin)?null==t?void 0:t.canAdmin:null==t?void 0:t.canAdmin.has("streaming"),canAdminTranscription:"boolean"==typeof(null==t?void 0:t.canAdmin)?null==t?void 0:t.canAdmin:null==t?void 0:t.canAdmin.has("transcription"),canSendAudio:i,canSendCustomAudio:a,canSendCustomVideo:o,canSendScreenAudio:u,canSendScreenVideo:c,canSendVideo:r,hasPresence:null==t?void 0:t.hasPresence,permissions:t}},exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,u=i.useRecoilValue(Re("base")),c=i.useRecoilValue(Re(a)),s=v(),d=se(),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,i=n.set,r=l({},e),o=0,u=Object.entries(r);o<u.length;o++){var c=u[o],s=c[1];i(Re(c[0]),s)}a in r||t(Re(a))}))}}),[a]);k("receive-settings-updated",n.useCallback((function(e){f(e.receiveSettings),null==o||o(e)}),[o,f])),n.useEffect((function(){s&&!s.isDestroyed()&&s.getReceiveSettings().then(f)}),[s,f]);var p=n.useCallback((function(){if(s&&"joined-meeting"===d){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==s||null==s.updateReceiveSettings||s.updateReceiveSettings.apply(s,n)}}),[s,d]);return{receiveSettings:"base"===a||0===Object.keys(c).length?u:c,updateReceiveSettings:p}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,c=v(),s=i.useRecoilValue(ce);return k("recording-started",n.useCallback((function(e){null==o||o(e)}),[o])),k("recording-stopped",n.useCallback((function(e){null==u||u(e)}),[u])),k("recording-error",n.useCallback((function(e){null==a||a(e)}),[a])),k("recording-data",n.useCallback((function(e){null==r||r(e)}),[r])),l({},s,{startRecording:n.useCallback((function(){c&&c.startRecording.apply(c,arguments)}),[c]),stopRecording:n.useCallback((function(){c&&c.stopRecording.apply(c,arguments)}),[c]),updateRecording:n.useCallback((function(){c&&c.updateRecording.apply(c,arguments)}),[c])})},exports.useRoom=Ae,exports.useRoomExp=function(e){var t,r,a,o,u,c,l=(void 0===e?{}:e).onCountdown,s=i.useRecoilValue(C),d=Ae(),f=n.useState(null),p=f[0],v=f[1];return n.useEffect((function(){var e,n,t,i,r,a,o,u,c,l,f,p,m=null!=(e=null!=(n=null==d||null==(t=d.tokenConfig)?void 0:t.eject_after_elapsed)?n:null==d||null==(i=d.config)?void 0:i.eject_after_elapsed)?e:0,y=null!=(r=null!=(a=null==d||null==(o=d.tokenConfig)?void 0:o.exp)?a:null==d||null==(u=d.config)?void 0:u.exp)?r:0,g=null!=(c=null!=(l=null==d||null==(f=d.tokenConfig)?void 0:f.eject_at_token_exp)?l:null==d||null==(p=d.config)?void 0:p.eject_at_room_exp)&&c,k=new Date(0);if(m&&s&&(k=new Date(s.getTime()+1e3*m)),g&&y){var b=new Date(1e3*y);(!k.getTime()||k.getTime()>0&&b<k)&&(k=b)}0!==k.getTime()&&v((function(e){return(null==e?void 0:e.getTime())!==k.getTime()?k:e}))}),[s,null==d||null==(t=d.config)?void 0:t.eject_after_elapsed,null==d||null==(r=d.config)?void 0:r.eject_at_room_exp,null==d||null==(a=d.config)?void 0:a.exp,null==d||null==(o=d.tokenConfig)?void 0:o.eject_after_elapsed,null==d||null==(u=d.tokenConfig)?void 0:u.eject_at_token_exp,null==d||null==(c=d.tokenConfig)?void 0:c.exp]),n.useEffect((function(){if(p&&0!==p.getTime()){var e=setInterval((function(){var e,n=(null!=(e=null==p?void 0:p.getTime())?e:0)/1e3-Date.now()/1e3;if(!(n<0)){var t=Math.max(0,Math.floor(n/3600)),i=Math.max(0,Math.floor(n%3600/60)),r=Math.max(0,Math.floor(n%60));null==l||l({hours:t,minutes:i,seconds:r})}}),1e3);return function(){clearInterval(e)}}}),[p,l]),{ejectDate:p}},exports.useScreenAudioTrack=function(e){return q(e,"screenAudio")},exports.useScreenShare=B,exports.useScreenVideoTrack=function(e){return q(e,"screenVideo")},exports.useSendSettings=function(e){var t=(void 0===e?{}:e).onSendSettingsUpdated,r=v(),a=i.useRecoilValue(Ee);k("send-settings-updated",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Ee,e.sendSettings),null==t||t(e)}}),[t]));var o=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Ee,e)}}),[]);return n.useEffect((function(){r&&!r.isDestroyed()&&o(r.getSendSettings())}),[r,o]),{sendSettings:a,updateSendSettings:n.useCallback(c((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var i=yield null==r?void 0:r.updateSendSettings.apply(r,n);if(i)return o(i),i})),[r,o])}},exports.useThrottledDailyEvent=b,exports.useTranscription=function(e){var t,r=void 0===e?{}:e,a=r.onTranscriptionAppData,o=r.onTranscriptionError,u=r.onTranscriptionStarted,c=r.onTranscriptionStopped,s=v(),d=i.useRecoilValue(we),f=i.useSetRecoilState(we),p=Ae();return n.useEffect((function(){var e;null!=p&&null!=(e=p.domainConfig)&&e.enable_transcription&&f((function(e){return l({},e,{isTranscriptionEnabled:!0})}))}),[null==p||null==(t=p.domainConfig)?void 0:t.enable_transcription,f]),k("transcription-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(we,l({isTranscriptionEnabled:!0,error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e)),null==u||u(e)}}),[u])),k("transcription-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(we,(function(n){return l({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})})),null==c||c(e)}}),[c])),k("transcription-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(we,(function(e){return l({},e,{error:!0,isTranscribing:!1})})),null==o||o(e)}}),[o])),k("app-message",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t;"transcription"===(null==e?void 0:e.fromId)&&null!=e&&null!=(t=e.data)&&t.is_final&&(n(we,(function(n){return l({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})})),null==a||a(e))}}),[a])),l({},d,{startTranscription:n.useCallback((function(){s&&s.startTranscription.apply(s,arguments)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription.apply(s,arguments)}),[s])})},exports.useVideoTrack=function(e){return q(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=v(),c=i.useRecoilValue(T),l=n.useCallback((function(e){null==r||r(e)}),[r]),s=n.useCallback((function(e){null==a||a(e)}),[a]),d=n.useCallback((function(e){null==o||o(e)}),[o]);k("waiting-participant-added",l),k("waiting-participant-removed",s),k("waiting-participant-updated",d);var f=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){f(e,!0)}),[f]),denyAccess:n.useCallback((function(e){f(e,!1)}),[f])}};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react"),t=e(n),i=require("recoil"),r=e(require("lodash.throttle")),a=e(require("fast-deep-equal")),o=e(require("@daily-co/daily-js"));function u(e,n,t,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void t(e)}u.done?n(c):Promise.resolve(c).then(i,r)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var a=e.apply(n,t);function o(e){u(a,i,r,o,c,"next",e)}function c(e){u(a,i,r,o,c,"throw",e)}o(void 0)}))}}function l(){return(l=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)n.indexOf(t=a[i])>=0||(r[t]=e[t]);return r}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=new Array(n);t<n;t++)i[t]=e[t];return i}function f(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return d(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?d(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var p=n.createContext(null),v=function(){return n.useContext(p)},m=n.createContext({on:function(){},off:function(){}}),y=0,g=function(){return y++},k=function(e,t){var i=n.useContext(m),r=i.off,a=i.on,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),s=n.useMemo((function(){return g()}),[]);n.useEffect((function(){if(e&&!u){if(l.current>1e5)return console.error("useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.\n Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.\n Passed callback for '"+e+"' event is NOT registered.",t),void c(!0);l.current++;var n=setTimeout((function(){l.current=0}),50);return a(e,t,s),function(){clearTimeout(n),r(e,s)}}}),[t,e,s,u,r,a])},b=function(e,t,i){void 0===i&&(i=100);var a=n.useContext(m),o=a.off,u=a.on,c=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=g(),e}),{}):((n={})[e]=g(),n)}),[e]),l=n.useRef([]),s=n.useMemo((function(){return r((function(){0!==l.current.length&&(t(l.current),l.current=[])}),i,{trailing:!0})}),[t,i]);n.useEffect((function(){if(e){var n=function(e){l.current.push(e),setTimeout(s,0)};return Array.isArray(e)?e.forEach((function(e){return u(e,n,c[e])})):u(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,c[e])})):o(e,c[e])}}}),[s,e,c,o,u])},h=i.atom({key:"daily-react-active-id",default:null}),S=i.atom({key:"daily-react-local-id",default:""}),C=i.atom({key:"daily-react-local-joined-date",default:null}),R=i.atom({key:"daily-react-participant-ids",default:[]}),A=i.atomFamily({key:"daily-react-participant-state",default:null}),E=i.selector({key:"daily-react-participants",get:function(e){var n=e.get;return n(R).map((function(e){return n(A(e))})).filter(Boolean)}}),w=i.atom({key:"daily-react-waiting-participants",default:[]}),x=i.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),T=i.selector({key:"daily-react-waitingParticipantsSelector",get:function(e){var n=e.get;return n(w).map((function(e){return n(x(e))}))}}),_=function(e){var r=e.children,a=v(),o=n.useState(!1),u=o[0],c=o[1],s=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(S,e.local.session_id);var i=Object.values(e),r=i.map((function(e){return e.session_id}));t(R,r),i.forEach((function(e){t(A(e.session_id),e)})),c(!0)}))}}),[]);n.useEffect((function(){if(a&&!u){var e=setInterval((function(){var n=a.participants();"local"in n&&(s(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,u,s]);var d=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&s(e)}}),[a,s]);return k("started-camera",d),k("access-state-updated",d),k("joining-meeting",i.useRecoilCallback((function(e){var n=e.set;return function(){n(C,new Date),d()}}),[d])),k("joined-meeting",n.useCallback((function(e){s(e.participants)}),[s])),b(["active-speaker-change","left-meeting","participant-joined","participant-updated","participant-left"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.get,i=n.reset,r=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":var n=e.activeSpeaker.peerId;r(h,n),r(A(n),(function(e){return e?l({},e,{last_active:new Date}):null}));break;case"participant-joined":r(R,(function(n){return n.includes(e.participant.session_id)?n:[].concat(n,[e.participant.session_id])})),r(A(e.participant.session_id),e.participant);break;case"participant-updated":r(A(e.participant.session_id),(function(n){return l({},n,e.participant)})),e.participant.local&&r(S,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));break;case"participant-left":r(R,(function(n){return n.includes(e.participant.session_id)?[].concat(n.filter((function(n){return n!==e.participant.session_id}))):n})),i(A(e.participant.session_id));break;case"left-meeting":i(S),t(R).forEach((function(e){return i(A(e))})),i(R)}}))}))}}),[])),b(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"waiting-participant-added":i(w,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),i(x(e.participant.id),e.participant);break;case"waiting-participant-updated":i(x(e.participant.id),e.participant);break;case"waiting-participant-removed":i(w,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(x(e.participant.id))}}))}))}}),[])),t.createElement(t.Fragment,null,r)},I=function(){return i.useRecoilValue(S)},L=function(){return!0},P=function(e){var t=void 0===e?{}:e,r=t.filter,a=void 0===r?L:r,o=t.ignoreLocal,u=void 0!==o&&o,c=I(),l=i.useRecoilValue(h),s=n.useState(null),d=s[0],f=s[1];return n.useEffect((function(){u&&l===c||null!=a&&a(l)&&f(l)}),[a,c,u,l]),d},D=function(e){return["blocked","off"].includes(e.state)},j=Boolean,M=function(){return 0},V=function(e){var t=void 0===e?{filter:j,sort:M}:e,r=t.filter,o=void 0===r?j:r,u=t.onActiveSpeakerChange,l=t.onParticipantJoined,s=t.onParticipantLeft,d=t.onParticipantUpdated,f=t.sort,p=void 0===f?M:f,v=n.useState([]),m=v[0],y=v[1],g=n.useMemo((function(){var e=j;switch(o){case"local":e=function(e){return e.local};break;case"owner":e=function(e){return e.owner};break;case"record":e=function(e){return e.record};break;case"remote":e=function(e){return!e.local};break;case"screen":e=function(e){return!D(e.tracks.screenAudio)||!D(e.tracks.screenVideo)};break;default:e=o}return e}),[o]),k=n.useMemo((function(){var e;switch(p){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,n){var t=e[p],i=n[p];if(void 0!==t||void 0!==i){if(void 0===t)return-1;if(void 0===i)return 1;if(t>i)return 1;if(t<i)return-1}return 0};break;default:e=p}return e}),[p]),h=n.useCallback((function(e){return e.filter(g).sort(k).map((function(e){return e.session_id})).filter(Boolean)}),[g,k]),S=n.useCallback((function(e){y((function(n){return a(n,e)?n:e}))}),[]),C=i.useRecoilCallback((function(e){var n=e.snapshot;return c((function*(){var e=h(yield n.getPromise(E));S(e)}))}),[h,S]);return n.useEffect((function(){C()}),[C]),i.useRecoilTransactionObserver_UNSTABLE(function(){var e=c((function*(e){var n=e.snapshot,t=yield n.getPromise(E),i=h(t);S(i)}));return function(n){return e.apply(this,arguments)}}()),b(["participant-joined","participant-updated","active-speaker-change","participant-left"],n.useCallback((function(e){e.length&&e.forEach((function(e){switch(e.action){case"participant-joined":null==l||l(e);break;case"participant-updated":null==d||d(e);break;case"active-speaker-change":null==u||u(e);break;case"participant-left":null==s||s(e)}}))}),[u,l,s,d])),m};function O(e,n){if(e===n)return!0;if(e instanceof MediaStream&&n instanceof MediaStream)return e.id===n.id&&e.active===n.active&&e.getTracks().length===n.getTracks().length&&e.getTracks().every((function(e,t){return O(e,n.getTracks()[t])}));if(e instanceof MediaStreamTrack&&n instanceof MediaStreamTrack)return e.id===n.id&&e.kind===n.kind&&e.readyState===n.readyState;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.source===n.source&&e.flags===n.flags;if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(var t,i=f(e.values());!(t=i()).done;)if(!n.has(t.value))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(var r,a=f(e.entries());!(r=a()).done;){var o=r.value,u=o[0],c=o[1];if(!n.has(u))return!1;if(!O(c,n.get(u)))return!1}return!0}if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var l=Object.keys(e),s=Object.keys(n);if(l.length!==s.length)return!1;for(var d,p=f(new Set([].concat(l,s)));!(d=p()).done;){var v=d.value;if(v in e&&!(v in n)||v in n&&!(v in e)||!O(e[v],n[v]))return!1}return!0}var B=function(e){var t=void 0===e?{}:e,r=t.onLocalScreenShareStarted,a=t.onLocalScreenShareStopped,o=v(),u=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==o||o.startScreenShare.apply(o,n)}),[o]),l=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==o||o.stopScreenShare.apply(o,n)}),[o]);k("local-screen-share-started",n.useCallback((function(){return null==r?void 0:r()}),[r])),k("local-screen-share-stopped",n.useCallback((function(){return null==a?void 0:a()}),[a]));var s=V({filter:"screen"}),d=n.useState([]),f=d[0],p=d[1],m=n.useCallback((function(e){p((function(n){return O(e,n)?n:e}))}),[]),y=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){return(yield Promise.all(e.map(function(){var e=c((function*(e){return yield n.getPromise(A(e))}));return function(n){return e.apply(this,arguments)}}()))).filter((function(e){return Boolean(e)})).map((function(e){return{local:e.local,screenAudio:e.tracks.screenAudio,screenVideo:e.tracks.screenVideo,screenId:e.session_id+"-screen",session_id:e.session_id}})).filter(Boolean)}));return function(n){return e.apply(this,arguments)}}()}),[]),g=n.useCallback(c((function*(){m(yield y(s))})),[y,m,s]);return n.useEffect((function(){g()}),[g]),i.useRecoilTransactionObserver_UNSTABLE(c((function*(){m(yield y(s))}))),{isSharingScreen:f.some((function(e){return e.local})),screens:f,startScreenShare:u,stopScreenShare:l}},U=function(e,n){return n.map((function(n){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(e,n)}))},F=i.selectorFamily({key:"daily-react-participant-property",get:function(e){var n=e.id,t=e.properties;return function(e){var i=(0,e.get)(A(n));return U(i,t)}}}),N=function(e,t){var r=v(),a=[];if(r&&!r.isDestroyed()){var o=Object.values(r.participants()).find((function(n){return n.session_id===e}));o&&(a=U(o,Array.isArray(t)?t:[t]))}var u=n.useState(a),l=u[0],s=u[1],d=n.useCallback((function(e){s((function(n){return O(e,n)?n:e}))}),[]),f=i.useRecoilCallback((function(n){var i=n.snapshot;return c((function*(){var n=yield i.getPromise(F({id:e,properties:Array.isArray(t)?t:[t]}));d(n)}))}),[d,e,t]);return n.useEffect((function(){f()}),[f]),i.useRecoilTransactionObserver_UNSTABLE(function(){var n=c((function*(n){var i=n.snapshot,r=yield i.getPromise(F({id:e,properties:Array.isArray(t)?t:[t]}));d(r)}));return function(e){return n.apply(this,arguments)}}()),Array.isArray(t)?l:l[0]},q=function(e,n){void 0===n&&(n="video");var t=N(e,"tracks."+n);return t?l({},t,{isOff:"blocked"===t.state||"off"===t.state}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1}};function W(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var i=t[n];"function"==typeof i?i(e):i&&"object"==typeof i&&(i.current=e)}}),t)}var z=["onPlayFailed","sessionId","type"],H=n.memo(n.forwardRef((function(e,i){var r=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,c=s(e,z),l=n.useRef(null),d=q(a,u),f=W(l,i);return n.useEffect((function(){var e=l.current;if(e&&null!=d&&d.persistentTrack){var n,t=function(){n=setTimeout((function(){(e.readyState!==e.HAVE_ENOUGH_DATA||e.paused)&&(null==r||r({sessionId:a,target:e,type:u}))}),1500)},i=function(){clearTimeout(n)};return e.addEventListener("canplay",t),e.addEventListener("play",i),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",t),null==e||e.removeEventListener("play",i)}}}),[null==d?void 0:d.persistentTrack,r,a,u]),t.createElement("audio",Object.assign({autoPlay:!0,playsInline:!0,ref:f},c,{"data-session-id":a,"data-audio-type":u}))})));H.displayName="DailyAudioTrack";var G=n.memo(n.forwardRef((function(e,r){var a=e.maxSpeakers,o=e.onPlayFailed,u=e.playLocalScreenAudio,l=void 0!==u&&u,s=n.useState(new Array(void 0===a?5:a).fill("")),d=s[0],f=s[1],p=B().screens,v=I(),m=P({ignoreLocal:!0}),y=n.useRef(null);n.useImperativeHandle(r,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=y.current)?void 0:n.querySelector('audio[data-session-id="'+m+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=y.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=y.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getRmpAudio:function(){var e,n;return Array.from(null!=(e=null==(n=y.current)?void 0:n.querySelectorAll('audio[data-audio-type="rmpAudio"]'))?e:[])},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=y.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getRmpAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=y.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="rmpAudio"]'))?n:null},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=y.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[m]);var g=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){var t=(yield n.getPromise(E)).filter((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)})),i=function(e){return t.some((function(n){return n.session_id===e}))};i(e)&&f((function(n){var r;if(n.includes(e))return n;var a=function(e){return!e||!i(e)};if(n.some(a)){var o=n.findIndex(a);return n[o]=e,[].concat(n)}var u=n.findIndex((function(e){return t.some((function(n){return n.session_id===e&&D(n.tracks.audio)}))}));if(u>=0)return n[u]=e,[].concat(n);var c=t.filter((function(e){return n.includes(e.session_id)&&e.session_id!==m})).sort((function(e,n){var t,i,r=null!=(t=null==e?void 0:e.last_active)?t:new Date("1970-01-01"),a=null!=(i=null==n?void 0:n.last_active)?i:new Date("1970-01-01");return r>a?1:r<a?-1:0}));if(!c.length){var l=n.findIndex((function(e){return e!==m}));return n[l]=e,[].concat(n)}var s=n.indexOf(null==(r=c[0])?void 0:r.session_id);return n[s]=e,[].concat(n)}))}));return function(n){return e.apply(this,arguments)}}()}),[m]),k=n.useCallback((function(e){f((function(n){if(!n.includes(e))return n;var t=[].concat(n),i=t.indexOf(e);return t[i]="",t}))}),[]);b(["active-speaker-change","track-started","participant-left"],n.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===v)return;g(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&g(e.participant.session_id);break;case"participant-left":k(e.participant.session_id)}}))}),[g,v,k]));var h=V({filter:n.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return t.createElement("div",{ref:y},d.map((function(e,n){return t.createElement(H,{key:"speaker-slot-"+n,onPlayFailed:o,sessionId:e,type:"audio"})})),p.filter((function(e){return!!l||!e.local})).map((function(e){return t.createElement(H,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:"screenAudio"})})),h.map((function(e){return t.createElement(H,{key:e+"-rmp",onPlayFailed:o,sessionId:e,type:"rmpAudio"})})))})));G.displayName="DailyAudio";var Q=["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"],J=n.forwardRef((function(e,i){var r=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,c=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,m=void 0===v?{}:v,y=e.type,g=void 0===y?"video":y,k=s(e,Q),b=I()===p,h="screenVideo"===g,S=b&&!h,C=n.useRef(null),R=W(C,i),A=q(p,g),E=A.persistentTrack,w=S||h||!A.isOff,x=N(p,"tracks."+g),T=null==x?void 0:x.subscribed,_=n.useMemo((function(){if("boolean"==typeof u)return u;if(!r)return!1;if(!E)return S;var e=E.getSettings();return"facingMode"in e?S&&"user"===e.facingMode:S}),[r,S,u,E]);return n.useEffect((function(){var e=C.current;if(e){var n=function(){var n=e.play();void 0!==n&&n.then((function(){e.controls=!1})).catch((function(n){e.controls=!0,console.warn("Failed to play video",n)}))},t=function(){e.paused&&n()},i=function(){e.style.transform="scale(1)"},r=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},a=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",i),e.addEventListener("leavepictureinpicture",r),document.addEventListener("visibilitychange",a),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",i),e.removeEventListener("leavepictureinpicture",r),document.removeEventListener("visibilitychange",a)}}}),[]),n.useEffect((function(){var e=C.current;if(e&&E)return e.srcObject=new MediaStream([E]),e.load(),function(){e.srcObject=null,e.load()}}),[E,null==E?void 0:E.id]),n.useEffect((function(){var e,n=C.current;if(c&&n)return t(),n.addEventListener("loadedmetadata",t),n.addEventListener("resize",t),function(){e&&cancelAnimationFrame(e),n.removeEventListener("loadedmetadata",t),n.removeEventListener("resize",t)};function t(){e&&cancelAnimationFrame(e),e=requestAnimationFrame((function(){var e=C.current;if(e&&!document.hidden){var n=e.videoWidth,t=e.videoHeight;n&&t&&(null==c||c({aspectRatio:n/t,height:t,width:n}))}}))}}),[c]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:R,"data-local":b,"data-mirrored":_||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":T,"data-video-type":g,style:l({objectFit:o,transform:_?"scale(-1, 1)":""},m,w?f:{})},k))}));J.displayName="DailyVideo";var $=n.createContext({refreshDevices:function(){return Promise.resolve()}}),K=i.atom({key:"daily-react-general-camera-state",default:"idle"}),X=i.atom({key:"daily-react-general-microphone-state",default:"idle"}),Y=i.atom({key:"daily-react-camera-devices",default:[]}),Z=i.atom({key:"daily-react-microphone-devices",default:[]}),ee=i.atom({key:"daily-react-speaker-devices",default:[]}),ne=i.atom({key:"daily-react-last-camera-error",default:null}),te=function(e){var r=e.children,a=v(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return c((function*(){var e,t,i,r;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(i=navigator)||null==(r=i.mediaDevices)?void 0:r.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,p=s.speaker,v=function(e,n,t){var i,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(i=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?i:"granted"}},m=function(e,n){return"default"===e.device.deviceId?-1:"default"===n.device.deviceId?1:e.device.label<n.device.label?-1:e.device.label>n.device.label?1:0};n((function(e){var n=e.set;n(Y,(function(e){return u.filter(Boolean).map((function(n){return v(d,n,e)})).sort(m)})),n(Z,(function(e){return c.filter(Boolean).map((function(n){return v(f,n,e)})).sort(m)})),n(ee,(function(e){return l.filter(Boolean).map((function(n){return v(p,n,e)})).sort(m)}))}))}catch(e){n((function(e){var n=e.set;n(K,"not-supported"),n(X,"not-supported")}))}}else n((function(e){var n=e.set;n(K,"not-supported"),n(X,"not-supported")}))}))}),[a]),u=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,i=e.transact_UNSTABLE;return c((function*(){var e,r,u,c,s,d,f,p,v,m,y,g,k,b;if(a){var h=yield t.getPromise(K),S=yield t.getPromise(X),C=a.participants();if(C.local){var R=C.local.tracks,A=["idle","pending"].includes(h)&&"interrupted"===R.video.state&&!R.video.persistentTrack,E=["idle","pending"].includes(h)&&!R.video.persistentTrack&&Boolean(null==(e=R.video.off)?void 0:e.byUser),w=["idle","pending"].includes(S)&&"interrupted"===R.audio.state&&!R.audio.persistentTrack,x=["idle","pending"].includes(S)&&!R.audio.persistentTrack&&Boolean(null==(r=R.audio.off)?void 0:r.byUser);null!=(u=R.audio)&&null!=(c=u.blocked)&&c.byDeviceInUse?i((function(e){var n=e.set;n(X,"in-use"),n(Z,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):null!=(s=R.audio)&&null!=(d=s.blocked)&&d.byDeviceMissing?n(X,"not-found"):null!=(f=R.audio)&&null!=(p=f.blocked)&&p.byPermissions?n(X,"blocked"):w?n(X,"pending"):x?n(X,"idle"):i((function(e){var n=e.set;n(X,"granted"),n(Z,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),null!=(v=R.video)&&null!=(m=v.blocked)&&m.byDeviceInUse?i((function(e){var n=e.set;n(K,"in-use"),n(Y,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"in-use"}):e}))}))})):null!=(y=R.video)&&null!=(g=y.blocked)&&g.byDeviceMissing?n(K,"not-found"):null!=(k=R.video)&&null!=(b=k.blocked)&&b.byPermissions?n(K,"blocked"):A?n(K,"pending"):E?n(K,"idle"):i((function(e){var n=e.set;n(K,"granted"),n(Y,(function(e){return e.map((function(e){return e.selected?l({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return k("participant-updated",n.useCallback((function(e){e.participant.local&&u()}),[u])),k("available-devices-updated",o),k("selected-devices-updated",o),k("camera-error",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,i,r,a,o,u,c,l=n.set;switch(l(ne,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":l(K,"in-use");break;case"mic-in-use":l(X,"in-use");break;case"cam-mic-in-use":l(K,"in-use"),l(X,"in-use");break;case"not-found":null!=(i=e.error)&&i.missingMedia.includes("video")&&l(K,"not-found"),null!=(r=e.error)&&r.missingMedia.includes("audio")&&l(X,"not-found");break;case"permissions":null!=(a=e.error)&&a.blockedMedia.includes("video")&&l(K,"blocked"),null!=(o=e.error)&&o.blockedMedia.includes("audio")&&l(X,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(l(K,"constraints-invalid"),l(X,"constraints-invalid")):"none-specified"===(null==(c=e.error)?void 0:c.reason)&&(l(K,"constraints-none-specified"),l(X,"constraints-none-specified"));break;case"undefined-mediadevices":l(K,"undefined-mediadevices"),l(X,"undefined-mediadevices");break;case"unknown":default:l(K,"unknown"),l(X,"unknown")}}))}}),[])),k("started-camera",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(K,"granted"),n(X,"granted")})),u()}}),[u])),t.createElement($.Provider,{value:{refreshDevices:o}},r)},ie=i.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),re=function(e){var n=e.children;return k("live-streaming-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ie,{isLiveStreaming:!0,layout:null==e?void 0:e.layout})}}),[])),k("live-streaming-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ie,(function(e){return l({},e,{isLiveStreaming:!1,layout:void 0})}))}}),[])),k("live-streaming-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ie,(function(n){return l({},n,{errorMsg:e.errorMsg})}))}}),[])),t.createElement(t.Fragment,null,n)},ae=i.atom({key:"daily-react-meeting-state",default:"new"}),oe=i.atom({key:"meeting-session-data",default:{data:void 0,topology:"none"}}),ue=function(e){var n=e.children,r=v(),a=i.useRecoilCallback((function(e){var n=e.set;return function(){if(r){var e=r.meetingState();return n(ae,e),e}}}),[r]);k("loading",a),k("loaded",a),k("joining-meeting",a),k("joined-meeting",a),k("left-meeting",a),k("error",a);var o=i.useRecoilCallback((function(e){var n=e.set;return function(){r&&n(oe,r.meetingSessionState())}}),[r]);return k("joined-meeting",o),k("meeting-session-state-updated",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(oe,e.meetingSessionState)}}),[])),k("left-meeting",i.useRecoilCallback((function(e){var n=e.reset;return function(){n(oe)}}),[])),t.createElement(t.Fragment,null,n)},ce=i.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),le=function(e){var r=e.children,a=i.useSetRecoilState(ce),o=I(),u=V({filter:"record"});return n.useEffect((function(){var e=u.length>0,n=u.includes(o||"local");a((function(t){return l({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[o,u,a]),k("recording-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var i;o&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==o&&(t=!1)}n(ce,{error:!1,isLocalParticipantRecorded:t,isRecording:!0,layout:null==e?void 0:e.layout,local:null==e?void 0:e.local,recordingId:null==e?void 0:e.recordingId,recordingStartedDate:new Date,startedBy:null==e?void 0:e.startedBy,type:null==e?void 0:e.type})}}),[o])),k("recording-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ce,(function(e){return l({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),k("recording-error",i.useRecoilCallback((function(e){var n=e.set;return function(){n(ce,(function(e){return l({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),t.createElement(t.Fragment,null,r)},se=function(){return i.useRecoilValue(ae)},de=i.atom({key:"daily-react-room",default:null}),fe=function(e){var n=e.children,r=v(),a=se(),o=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(r&&"left-meeting"!==a){var e=yield r.room();return e&&"id"in e&&n(de,e),e}}))}),[r,a]);return k("access-state-updated",o),t.createElement(t.Fragment,null,n)},pe=["children","recoilRootProps"],ve=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,o=r.onParticipantUpdated,u=i.useRecoilValue(A(e));return b(["participant-updated","participant-left"],n.useCallback((function(n){var t=n.filter((function(n){return n.participant.session_id===e}));t.length&&t.forEach((function(e){switch(e.action){case"participant-updated":null==o||o(e);break;case"participant-left":null==a||a(e)}}))}),[a,o,e])),u},me="data:application/javascript;charset=utf8,"+encodeURIComponent("\n class AudioLevelProcessor extends AudioWorkletProcessor {\n volume;\n interval;\n nextFrame;\n \n constructor() {\n super();\n this.volume = 0;\n this.interval = 25;\n this.nextFrame = this.interval;\n }\n \n get intervalInFrames() {\n // sampleRate is globally defined in AudioWorklets.\n // See https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope\n // eslint-disable-next-line no-undef\n return (this.interval / 1000) * sampleRate;\n }\n \n process(inputList) {\n const firstInput = inputList[0];\n \n if (firstInput.length > 0) {\n const inputData = firstInput[0];\n let total = 0;\n \n for (let i = 0; i < inputData.length; ++i) {\n total += Math.abs(inputData[i]);\n }\n \n const rms = Math.sqrt(total / inputData.length);\n this.volume = Math.max(0, Math.min(1, rms));\n \n this.nextFrame -= inputData.length;\n if (this.nextFrame < 0) {\n this.nextFrame += this.intervalInFrames;\n this.port.postMessage({ volume: this.volume });\n }\n }\n \n return true;\n }\n }\n \n registerProcessor('audiolevel', AudioLevelProcessor); \n"),ye=i.atom({key:"cpu-load-state",default:{state:"low",reason:"none"}}),ge=i.atom({key:"daily-react-input-settings",default:null}),ke=i.atom({key:"daily-react-input-settings-error",default:null}),be=i.atom({key:"daily-react-topology",default:"none"}),he=i.atom({key:"daily-react-networkQuality",default:100}),Se=i.atom({key:"daily-react-networkThreshold",default:"good"}),Ce=i.atom({key:"daily-react-participant-counts",default:{hidden:0,present:0}}),Re=i.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),Ae=function(){return i.useRecoilValue(de)},Ee=i.atom({key:"daily-react-send-settings",default:null}),we=i.atom({key:"daily-react-transcription",default:{isTranscriptionEnabled:!1,isTranscribing:!1,model:"general",language:"en",transcriptions:[]}});exports.DailyAudio=G,exports.DailyAudioTrack=H,exports.DailyProvider=function(e){var r=e.children,a=e.recoilRootProps,u=void 0===a?{}:a,d=s(e,pe),v="callObject"in d?d.callObject:null,y=n.useState(v),g=y[0],k=y[1],b=n.useRef({});n.useEffect((function(){v&&(v?((null==g?void 0:g._callFrameId)!==(null==v?void 0:v._callFrameId)||!g&&v)&&k(v):k(null))}),[g,v]);var h=n.useCallback((function(e){if("action"in e)for(var n,t=f(null!=(i=null==(r=b.current)||null==(a=r[e.action])?void 0:a.values())?i:[]);!(n=t()).done;){var i,r,a;(0,n.value)(e)}}),[]),S=n.useCallback((function(e){e&&Object.keys(b.current).forEach((function(n){e.off(n,h),e.isDestroyed()||e.on(n,h)}))}),[h]),C=n.useRef();n.useEffect((function(){if("callObject"in d)return k(d.callObject),void S(d.callObject);function e(){return(e=c((function*(e){yield e.destroy()}))).apply(this,arguments)}if(g)O(C.current,d)||function(n){e.apply(this,arguments)}(g);else{var n=o.getCallInstance();n||(n=o.createCallObject(l({},d)),C.current=d),k(n),S(n),n.once("call-instance-destroyed",(function(){k(null)}))}}),[g,S,d]);var R=n.useCallback((function(e,n,t){var i,r;b.current[e]||(b.current[e]=new Map,g&&(g.off(e,h),g.isDestroyed()||g.on(e,h))),null!=(i=b.current[e])&&i.has(t)||null==(r=b.current[e])||r.set(t,n)}),[g,h]),A=n.useCallback((function(e,n){var t,i;null==(t=b.current[e])||t.delete(n),0===(null==(i=b.current[e])?void 0:i.size)&&(null==g||g.off(e,h),delete b.current[e])}),[g,h]);return t.createElement(i.RecoilRoot,Object.assign({},u),t.createElement(p.Provider,{value:g},t.createElement(m.Provider,{value:{on:R,off:A}},t.createElement(fe,null,t.createElement(ue,null,t.createElement(_,null,t.createElement(le,null,t.createElement(re,null,t.createElement(te,null,r)))))))))},exports.DailyVideo=J,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=v(),c=i.useRecoilValue(h),l=n.useState(""),s=l[1],d=ve(l[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==n?void 0:n.session_id)||s(null!=c?c:"")}}),[u,a,c]),k("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),d},exports.useActiveSpeakerId=P,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,i=v(),r=n.useCallback((function(e,n){void 0===n&&(n="*"),i&&i.sendAppMessage(e,n)}),[i]),a=n.useCallback((function(e){null==t||t(e,r)}),[t,r]);return k("app-message",a),r},exports.useAudioLevel=function(e,t){var i=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){i.current||(i.current=new n);var r=i.current;if(r){var a,o=r.createMediaStreamSource(new MediaStream([e]));return function(){var e=c((function*(){try{a=new AudioWorkletNode(r,"audiolevel")}catch(e){try{yield r.audioWorklet.addModule(me),a=new AudioWorkletNode(r,"audiolevel")}catch(e){console.error(e)}}if(a){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)};try{o.connect(a).connect(r.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==o||o.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return q(e,"audio")},exports.useCPULoad=function(e){var t=(void 0===e?{}:e).onCPULoadChange,r=i.useRecoilValue(ye),o=v(),u=se(),l=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot;return function(){var e=c((function*(e){var i=yield t.getPromise(ye);a(i,e)||n(ye,e)}));return function(n){return e.apply(this,arguments)}}()}),[]);return n.useEffect((function(){var e=!0;if(o&&!o.isDestroyed()&&"joined-meeting"===u)return o.getCpuLoadStats().then((function(n){e&&l({state:n.cpuLoadState,reason:n.cpuLoadStateReason})})),function(){e=!1}}),[o,u,l]),k("cpu-load-change",n.useCallback((function(e){l({state:e.cpuLoadState,reason:e.cpuLoadStateReason}),null==t||t(e)}),[t,l])),r},exports.useDaily=v,exports.useDailyEvent=k,exports.useDevices=function(){var e=v(),t=i.useRecoilValue(K),r=i.useRecoilValue(X),a=i.useRecoilValue(Y),o=i.useRecoilValue(Z),u=i.useRecoilValue(ee),l=i.useRecoilValue(ne),s=n.useContext($).refreshDevices,d=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),m=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"];return{cameraError:l,cameras:a,camState:t,currentCam:a.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:m.includes(t),hasMicError:m.includes(r),microphones:o,micState:r,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:p,speakers:u}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(ge),u=i.useRecoilValue(ke),c=v(),l=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ge,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),k("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),k("nonfatal-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){"input-settings-error"===e.type&&(n(ke,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==c||c.updateInputSettings.apply(c,n)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=v(),c=i.useRecoilValue(ie);return k("live-streaming-started",n.useCallback((function(e){null==a||a(e)}),[a])),k("live-streaming-stopped",n.useCallback((function(e){null==o||o(e)}),[o])),k("live-streaming-error",n.useCallback((function(e){null==r||r(e)}),[r])),l({},c,{startLiveStreaming:n.useCallback((function(){u&&u.startLiveStreaming.apply(u,arguments)}),[u]),stopLiveStreaming:n.useCallback((function(){u&&u.stopLiveStreaming.apply(u,arguments)}),[u]),updateLiveStreaming:n.useCallback((function(){u&&u.updateLiveStreaming.apply(u,arguments)}),[u])})},exports.useLocalParticipant=function(){var e=i.useRecoilValue(S);return ve(e)},exports.useLocalSessionId=I,exports.useMediaTrack=q,exports.useMeetingSessionState=function(){var e=i.useRecoilValue(oe);return{data:null==e?void 0:e.data,topology:null==e?void 0:e.topology}},exports.useMeetingState=se,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,o=v(),u=i.useRecoilValue(be),l=i.useRecoilValue(he),s=i.useRecoilValue(Se),d=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(o){var e=yield o.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(be,e.topology)}}))}),[o]),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&t(be,"peer"),"sfu"===e.type&&t(be,"sfu")}})),null==r||r(e)}}),[r]),p=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(he,(function(n){return n!==e.quality?e.quality:n})),t(Se,(function(n){return n!==e.threshold?e.threshold:n}))})),null==a||a(e)}}),[a]);return k("joined-meeting",d),k("network-connection",f),k("network-quality-change",p),n.useEffect((function(){o&&!u&&d()}),[o,d,u]),{getStats:n.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u}},exports.useParticipant=ve,exports.useParticipantCounts=function(e){var t=(void 0===e?{}:e).onParticipantCountsUpdated,r=v(),a=i.useRecoilValue(Ce),o=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Ce,e)}}),[]);return k("participant-counts-updated",n.useCallback((function(e){o(e.participantCounts),null==t||t(e)}),[t,o])),n.useEffect((function(){r&&!r.isDestroyed()&&o(r.participantCounts())}),[r,o]),a},exports.useParticipantIds=V,exports.useParticipantProperty=N,exports.usePermissions=function(e){var n=I(),t=N(null!=e?e:n,"permissions"),i="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("audio"),r="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("video"),a="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("customAudio"),o="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("customVideo"),u="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("screenAudio"),c="boolean"==typeof(null==t?void 0:t.canSend)?null==t?void 0:t.canSend:null==t?void 0:t.canSend.has("screenVideo");return{canAdminParticipants:"boolean"==typeof(null==t?void 0:t.canAdmin)?null==t?void 0:t.canAdmin:null==t?void 0:t.canAdmin.has("participants"),canAdminStreaming:"boolean"==typeof(null==t?void 0:t.canAdmin)?null==t?void 0:t.canAdmin:null==t?void 0:t.canAdmin.has("streaming"),canAdminTranscription:"boolean"==typeof(null==t?void 0:t.canAdmin)?null==t?void 0:t.canAdmin:null==t?void 0:t.canAdmin.has("transcription"),canSendAudio:i,canSendCustomAudio:a,canSendCustomVideo:o,canSendScreenAudio:u,canSendScreenVideo:c,canSendVideo:r,hasPresence:null==t?void 0:t.hasPresence,permissions:t}},exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,u=i.useRecoilValue(Re("base")),c=i.useRecoilValue(Re(a)),s=v(),d=se(),f=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,i=n.set,r=l({},e),o=0,u=Object.entries(r);o<u.length;o++){var c=u[o],s=c[1];i(Re(c[0]),s)}a in r||t(Re(a))}))}}),[a]);k("receive-settings-updated",n.useCallback((function(e){f(e.receiveSettings),null==o||o(e)}),[o,f])),n.useEffect((function(){s&&!s.isDestroyed()&&s.getReceiveSettings().then(f)}),[s,f]);var p=n.useCallback((function(){if(s&&"joined-meeting"===d){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==s||null==s.updateReceiveSettings||s.updateReceiveSettings.apply(s,n)}}),[s,d]);return{receiveSettings:"base"===a||0===Object.keys(c).length?u:c,updateReceiveSettings:p}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,c=v(),s=i.useRecoilValue(ce);return k("recording-started",n.useCallback((function(e){null==o||o(e)}),[o])),k("recording-stopped",n.useCallback((function(e){null==u||u(e)}),[u])),k("recording-error",n.useCallback((function(e){null==a||a(e)}),[a])),k("recording-data",n.useCallback((function(e){null==r||r(e)}),[r])),l({},s,{startRecording:n.useCallback((function(){c&&c.startRecording.apply(c,arguments)}),[c]),stopRecording:n.useCallback((function(){c&&c.stopRecording.apply(c,arguments)}),[c]),updateRecording:n.useCallback((function(){c&&c.updateRecording.apply(c,arguments)}),[c])})},exports.useRoom=Ae,exports.useRoomExp=function(e){var t,r,a,o,u,c,l=(void 0===e?{}:e).onCountdown,s=i.useRecoilValue(C),d=Ae(),f=n.useState(null),p=f[0],v=f[1];return n.useEffect((function(){var e,n,t,i,r,a,o,u,c,l,f,p,m=null!=(e=null!=(n=null==d||null==(t=d.tokenConfig)?void 0:t.eject_after_elapsed)?n:null==d||null==(i=d.config)?void 0:i.eject_after_elapsed)?e:0,y=null!=(r=null!=(a=null==d||null==(o=d.tokenConfig)?void 0:o.exp)?a:null==d||null==(u=d.config)?void 0:u.exp)?r:0,g=null!=(c=null!=(l=null==d||null==(f=d.tokenConfig)?void 0:f.eject_at_token_exp)?l:null==d||null==(p=d.config)?void 0:p.eject_at_room_exp)&&c,k=new Date(0);if(m&&s&&(k=new Date(s.getTime()+1e3*m)),g&&y){var b=new Date(1e3*y);(!k.getTime()||k.getTime()>0&&b<k)&&(k=b)}0!==k.getTime()&&v((function(e){return(null==e?void 0:e.getTime())!==k.getTime()?k:e}))}),[s,null==d||null==(t=d.config)?void 0:t.eject_after_elapsed,null==d||null==(r=d.config)?void 0:r.eject_at_room_exp,null==d||null==(a=d.config)?void 0:a.exp,null==d||null==(o=d.tokenConfig)?void 0:o.eject_after_elapsed,null==d||null==(u=d.tokenConfig)?void 0:u.eject_at_token_exp,null==d||null==(c=d.tokenConfig)?void 0:c.exp]),n.useEffect((function(){if(p&&0!==p.getTime()){var e=setInterval((function(){var e,n=(null!=(e=null==p?void 0:p.getTime())?e:0)/1e3-Date.now()/1e3;if(!(n<0)){var t=Math.max(0,Math.floor(n/3600)),i=Math.max(0,Math.floor(n%3600/60)),r=Math.max(0,Math.floor(n%60));null==l||l({hours:t,minutes:i,seconds:r})}}),1e3);return function(){clearInterval(e)}}}),[p,l]),{ejectDate:p}},exports.useScreenAudioTrack=function(e){return q(e,"screenAudio")},exports.useScreenShare=B,exports.useScreenVideoTrack=function(e){return q(e,"screenVideo")},exports.useSendSettings=function(e){var t=(void 0===e?{}:e).onSendSettingsUpdated,r=v(),a=i.useRecoilValue(Ee);k("send-settings-updated",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Ee,e.sendSettings),null==t||t(e)}}),[t]));var o=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(Ee,e)}}),[]);return n.useEffect((function(){r&&!r.isDestroyed()&&o(r.getSendSettings())}),[r,o]),{sendSettings:a,updateSendSettings:n.useCallback(c((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var i=yield null==r?void 0:r.updateSendSettings.apply(r,n);if(i)return o(i),i})),[r,o])}},exports.useThrottledDailyEvent=b,exports.useTranscription=function(e){var t,r=void 0===e?{}:e,a=r.onTranscriptionAppData,o=r.onTranscriptionError,u=r.onTranscriptionStarted,c=r.onTranscriptionStopped,s=v(),d=i.useRecoilValue(we),f=i.useSetRecoilState(we),p=Ae();return n.useEffect((function(){var e;null!=p&&null!=(e=p.domainConfig)&&e.enable_transcription&&f((function(e){return l({},e,{isTranscriptionEnabled:!0})}))}),[null==p||null==(t=p.domainConfig)?void 0:t.enable_transcription,f]),k("transcription-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(we,l({isTranscriptionEnabled:!0,error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e)),null==u||u(e)}}),[u])),k("transcription-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(we,(function(n){return l({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})})),null==c||c(e)}}),[c])),k("transcription-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(we,(function(e){return l({},e,{error:!0,isTranscribing:!1})})),null==o||o(e)}}),[o])),k("app-message",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t;"transcription"===(null==e?void 0:e.fromId)&&null!=e&&null!=(t=e.data)&&t.is_final&&(n(we,(function(n){return l({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})})),null==a||a(e))}}),[a])),l({},d,{startTranscription:n.useCallback((function(){s&&s.startTranscription.apply(s,arguments)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription.apply(s,arguments)}),[s])})},exports.useVideoTrack=function(e){return q(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=v(),c=i.useRecoilValue(T),l=n.useCallback((function(e){null==r||r(e)}),[r]),s=n.useCallback((function(e){null==a||a(e)}),[a]),d=n.useCallback((function(e){null==o||o(e)}),[o]);k("waiting-participant-added",l),k("waiting-participant-removed",s),k("waiting-participant-updated",d);var f=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){f(e,!0)}),[f]),denyAccess:n.useCallback((function(e){f(e,!1)}),[f])}};
//# sourceMappingURL=daily-react.cjs.production.min.js.map
{
"version": "0.11.4",
"version": "0.11.5",
"license": "BSD-2-Clause",

@@ -4,0 +4,0 @@ "keywords": [

@@ -13,3 +13,3 @@ import { useCallback, useEffect, useState } from 'react';

import { RECOIL_PREFIX } from '../lib/constants';
import { deepEqual } from '../lib/deepEqual';
import { customDeepEqual } from '../lib/customDeepEqual';
import type { NumericKeys } from '../types/NumericKeys';

@@ -82,3 +82,3 @@ import type { Paths } from '../types/paths';

setProperties((prevProperties) => {
if (deepEqual(properties, prevProperties)) return prevProperties;
if (customDeepEqual(properties, prevProperties)) return prevProperties;
return properties;

@@ -85,0 +85,0 @@ });

@@ -12,3 +12,3 @@ import { DailyCall, DailyTrackState } from '@daily-co/daily-js';

} from '../DailyParticipants';
import { deepEqual } from '../lib/deepEqual';
import { customDeepEqual } from '../lib/customDeepEqual';
import { useDaily } from './useDaily';

@@ -79,3 +79,3 @@ import { useDailyEvent } from './useDailyEvent';

setScreens((prevScreens) => {
if (deepEqual(screens, prevScreens)) return prevScreens;
if (customDeepEqual(screens, prevScreens)) return prevScreens;
return screens;

@@ -82,0 +82,0 @@ });

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc